@dowel-ui/registry 0.5.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/schema.ts CHANGED
@@ -38,6 +38,18 @@ export const registryItemTypeSchema = z.enum([
38
38
 
39
39
  export type RegistryItemType = z.infer<typeof registryItemTypeSchema>;
40
40
 
41
+ /**
42
+ * Whether an item's source is public.
43
+ *
44
+ * `free` is the default and stays the default: an item that has ever been
45
+ * installable without a licence must never quietly become one that is not.
46
+ * Existing registries carry no `access` field at all, which parses as `free` —
47
+ * so an older registry read by a newer CLI behaves exactly as it did.
48
+ */
49
+ export const registryAccessSchema = z.enum(["free", "pro"]).default("free");
50
+
51
+ export type RegistryAccess = z.infer<typeof registryAccessSchema>;
52
+
41
53
  export const registryFileSchema = z.object({
42
54
  /**
43
55
  * Logical path within the registry, e.g. `ui/button.tsx`, `lib/utils.ts`.
@@ -76,10 +88,20 @@ export const registryItemSchema = z.object({
76
88
  registryDependencies: z.array(z.string()),
77
89
  files: z.array(registryFileSchema).min(1),
78
90
  a11y: z.string().optional(),
91
+ access: registryAccessSchema,
79
92
  });
80
93
 
81
94
  export type RegistryItem = z.infer<typeof registryItemSchema>;
82
95
 
96
+ /**
97
+ * The index entry.
98
+ *
99
+ * Carries `access` so a licensed item is *listed* — with its title, what it
100
+ * depends on and how many files it has — while its source is not. Hiding paid
101
+ * items entirely would mean nobody could discover them; including their source
102
+ * would mean nobody needed to buy them. The index is the catalogue; the item
103
+ * body is the goods.
104
+ */
83
105
  export const registryIndexEntrySchema = registryItemSchema
84
106
  .pick({
85
107
  name: true,
@@ -90,6 +112,7 @@ export const registryIndexEntrySchema = registryItemSchema
90
112
  status: true,
91
113
  dependencies: true,
92
114
  registryDependencies: true,
115
+ access: true,
93
116
  })
94
117
  .extend({ fileCount: z.number().int().positive() });
95
118
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-ByqIpT47.js","names":[],"sources":["../src/hash.ts","../src/schema.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\n/**\n * Content hash used to detect local edits to an installed file.\n *\n * Line endings are normalised before hashing so a Windows checkout does not\n * read as \"every file modified\", which would make `update` useless there.\n */\nexport function hashContent(content: string): string {\n const normalised = content.replace(/\\r\\n/g, \"\\n\");\n return `sha256:${createHash(\"sha256\").update(normalised, \"utf8\").digest(\"hex\")}`;\n}\n","import { z } from \"zod\";\n\n/**\n * The public registry contract.\n *\n * This is the boundary between the library and every consumer's project, so it\n * is validated on both sides: the build refuses to emit anything that does not\n * satisfy it, and the CLI refuses to install anything that does not parse. A\n * registry that serves malformed data breaks builds in someone else's\n * repository, where it is hardest to diagnose.\n */\n\n/** Bumped only for a breaking change to the shape below. */\nexport const REGISTRY_VERSION = 1;\n\nexport const registryFileTypeSchema = z.enum([\n /** A component. Installed under the `ui` alias. */\n \"registry:ui\",\n /** A shared utility. Installed under the `lib` alias. */\n \"registry:lib\",\n /** A hook. Installed under the `hooks` alias. */\n \"registry:hook\",\n /** A whole page section. Installed under the `blocks` alias. */\n \"registry:block\",\n /** CSS appended to the project stylesheet rather than written as a file. */\n \"registry:style\",\n]);\n\nexport type RegistryFileType = z.infer<typeof registryFileTypeSchema>;\n\nexport const registryItemTypeSchema = z.enum([\n \"registry:ui\",\n \"registry:lib\",\n \"registry:hook\",\n \"registry:theme\",\n \"registry:block\",\n]);\n\nexport type RegistryItemType = z.infer<typeof registryItemTypeSchema>;\n\nexport const registryFileSchema = z.object({\n /**\n * Logical path within the registry, e.g. `ui/button.tsx`, `lib/utils.ts`.\n *\n * The leading segment selects which of the consumer's aliases the file is\n * written under. The registry deliberately does not know the destination —\n * that depends on a project layout it has never seen.\n */\n path: z.string().min(1),\n type: registryFileTypeSchema,\n content: z.string(),\n /**\n * `sha256:<hex>` of `content` as published.\n *\n * Recorded at install time so `update` can tell an untouched file from one\n * the user has edited. This cannot be added later: an install that did not\n * record a hash leaves no way to know what it originally wrote.\n */\n hash: z.string().regex(/^sha256:[0-9a-f]{64}$/),\n});\n\nexport type RegistryFile = z.infer<typeof registryFileSchema>;\n\nexport const registryItemSchema = z.object({\n $schema: z.string().optional(),\n registryVersion: z.literal(REGISTRY_VERSION),\n name: z.string().regex(/^[a-z][a-z0-9-]*$/),\n type: registryItemTypeSchema,\n title: z.string().min(1),\n description: z.string().min(10),\n category: z.string().min(1),\n status: z.enum([\"stable\", \"beta\", \"experimental\"]),\n /** npm packages to install alongside the files. */\n dependencies: z.array(z.string()),\n /** Other registry items to install first. */\n registryDependencies: z.array(z.string()),\n files: z.array(registryFileSchema).min(1),\n a11y: z.string().optional(),\n});\n\nexport type RegistryItem = z.infer<typeof registryItemSchema>;\n\nexport const registryIndexEntrySchema = registryItemSchema\n .pick({\n name: true,\n type: true,\n title: true,\n description: true,\n category: true,\n status: true,\n dependencies: true,\n registryDependencies: true,\n })\n .extend({ fileCount: z.number().int().positive() });\n\nexport type RegistryIndexEntry = z.infer<typeof registryIndexEntrySchema>;\n\nexport const registryIndexSchema = z.object({\n $schema: z.string().optional(),\n registryVersion: z.literal(REGISTRY_VERSION),\n /** Version of the package the registry was generated from. */\n generatedFrom: z.string().min(1),\n items: z.array(registryIndexEntrySchema),\n});\n\nexport type RegistryIndex = z.infer<typeof registryIndexSchema>;\n"],"mappings":";;;;;;;;;AAQA,SAAgB,YAAY,SAAyB;CACnD,MAAM,aAAa,QAAQ,QAAQ,SAAS,IAAI;CAChD,OAAO,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,CAAC,OAAO,KAAK;AAC/E;;;;;;;;;;;;;ACEA,MAAa,mBAAmB;AAEhC,MAAa,yBAAyB,EAAE,KAAK;CAE3C;CAEA;CAEA;CAEA;CAEA;AACF,CAAC;AAID,MAAa,yBAAyB,EAAE,KAAK;CAC3C;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,qBAAqB,EAAE,OAAO;;;;;;;;CAQzC,MAAM,EAAE,OAAO,CAAC,CAAC,IAA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