The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
refactor: make content optional in registry item file schema and specify type for blocks
vholikc3b3d9a1e4e5
diff --git a/packages/cli/src/registry/schema.ts b/packages/cli/src/registry/schema.tsindex 1c5c0bc38..56f601c6f 100644--- a/packages/cli/src/registry/schema.ts+++ b/packages/cli/src/registry/schema.ts@@ -22,7 +22,7 @@ export const registryItemTypeSchema = z.enum([// File with required content (for fetched items)export const registryItemFileSchema = z.object({path: z.string(),- content: z.string(),+ content: z.string().optional(),type: registryItemTypeSchema,target: z.string().optional(),});@@ -31,7 +31,6 @@ export const registryItemFileSchema = z.object({const registryItemBaseSchema = z.object({$schema: z.string().optional(),name: z.string(),- type: registryItemTypeSchema,title: z.string().optional(),author: z.string().min(2).optional(),description: z.string().optional(),diff --git a/packages/registry/public/schema/registry-item.json b/packages/registry/public/schema/registry-item.jsonnew file mode 100644index 000000000..1cafd889e--- /dev/null+++ b/packages/registry/public/schema/registry-item.json@@ -0,0 +1,109 @@+{+ "$schema": "https://json-schema.org/draft-07/schema#",+ "type": "object",+ "properties": {+ "$schema": {+ "type": "string",+ "description": "The JSON schema reference for validation."+ },+ "name": {+ "type": "string",+ "description": "The name of the item. This is used to identify the item in the registry. It should be unique for your registry."+ },+ "title": {+ "type": "string",+ "description": "The human-readable title for your registry item. Keep it short and descriptive."+ },+ "author": {+ "type": "string",+ "minLength": 2,+ "description": "The author of the item. Recommended format: username <url>"+ },+ "description": {+ "type": "string",+ "description": "The description of the item. This is used to provide a brief overview of the item."+ },+ "dependencies": {+ "type": "array",+ "description": "An array of NPM dependencies required by the registry item.",+ "items": {+ "type": "string"+ }+ },+ "devDependencies": {+ "type": "array",+ "description": "An array of NPM dev dependencies required by the registry item.",+ "items": {+ "type": "string"+ }+ },+ "registryDependencies": {+ "type": "array",+ "description": "An array of registry items that this item depends on. Use the name of the item to reference @mercurjs components and urls to reference other registries.",+ "items": {+ "type": "string"+ }+ },+ "files": {+ "type": "array",+ "description": "The main payload of the registry item. This is an array of files that are part of the registry item.",+ "items": {+ "type": "object",+ "properties": {+ "path": {+ "type": "string",+ "description": "The path to the file relative to the registry root."+ },+ "content": {+ "type": "string",+ "description": "The content of the file. This is populated when the item is fetched."+ },+ "type": {+ "type": "string",+ "enum": [+ "registry:workflow",+ "registry:api",+ "registry:link",+ "registry:module",+ "registry:vendor",+ "registry:admin",+ "registry:lib"+ ],+ "description": "The type of the file. This determines how the file is handled when installed."+ },+ "target": {+ "type": "string",+ "description": "The target path of the file. This is the destination path in the user's project."+ }+ },+ "required": ["path", "type"]+ }+ },+ "meta": {+ "type": "object",+ "description": "Additional metadata for the registry item. This is an object with any key value pairs.",+ "additionalProperties": true+ },+ "docs": {+ "type": "string",+ "description": "The documentation for the registry item. This is a markdown string."+ },+ "categories": {+ "type": "array",+ "description": "The categories of the registry item. Used for filtering and organization.",+ "items": {+ "type": "string",+ "enum": [+ "workflows",+ "api",+ "links",+ "modules",+ "vendor",+ "admin",+ "lib"+ ]+ }+ }+ },+ "required": ["name", "files"]+}diff --git a/packages/registry/public/schema/registry.json b/packages/registry/public/schema/registry.jsonnew file mode 100644index 000000000..304cf7009--- /dev/null+++ b/packages/registry/public/schema/registry.json@@ -0,0 +1,29 @@+{+ "$schema": "https://json-schema.org/draft-07/schema#",+ "description": "A MercurJS registry of modules, workflows, links, API routes, and more.",+ "type": "object",+ "properties": {+ "name": {+ "type": "string",+ "description": "The name of the registry. Should start with @ (e.g., @mercurjs)."+ },+ "homepage": {+ "type": "string",+ "description": "The homepage URL of the registry."+ },+ "items": {+ "type": "array",+ "description": "The registry items.",+ "items": {+ "$ref": "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/public/schema/registry-item.json"+ },+ "minItems": 1,+ "uniqueItems": true+ }+ },+ "required": [+ "name",+ "homepage",+ "items"+ ]+}\ No newline at end of filediff --git a/packages/registry/src/registry.ts b/packages/registry/src/registry.tsindex af292cfa1..c3d8307f8 100644--- a/packages/registry/src/registry.ts+++ b/packages/registry/src/registry.ts@@ -1,7 +1,7 @@import { Registry, registryItemSchema } from '@mercurjs/cli'import { z } from "zod"-const blocks = [+const blocks: Registry['items'] = [{name: "block-1",description: "A block with a test module, product-test link, and API route.",