@chat-de-hp/site 0.3.4 → 0.3.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"check-core.d.ts","sourceRoot":"","sources":["../src/check-core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,WAAW,GACX,MAAM,GACN,aAAa,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAAG;IACjC,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAuBF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,iBAAiB,CAAC;CACzB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAwBlC"}
1
+ {"version":3,"file":"check-core.d.ts","sourceRoot":"","sources":["../src/check-core.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,WAAW,GACX,MAAM,GACN,aAAa,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAAG;IACjC,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA2BF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,KAAK,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,iBAAiB,CAAC;CACzB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAwBlC"}
@@ -18,7 +18,7 @@ export async function checkSiteConformanceSources(options) {
18
18
  return sortViolations(violations);
19
19
  }
20
20
  function checkSeedSchema(seed) {
21
- return seed.collections
21
+ const violations = seed.collections
22
22
  .filter((collection) => collection.supportsDrafts && !collection.supportsRevisions)
23
23
  .map((collection) => ({
24
24
  field: collection.slug,
@@ -27,6 +27,36 @@ function checkSeedSchema(seed) {
27
27
  message: `Collection "${collection.slug}" enables "drafts" without "revisions". Add "revisions", or remove "drafts" and do not use the publish flow.`,
28
28
  rule: "seed-schema",
29
29
  }));
30
+ const collections = new Set(seed.collections.map((collection) => collection.slug));
31
+ const unknownCollections = new Set();
32
+ for (const provided of seed.provided) {
33
+ const separator = provided.indexOf(".");
34
+ const collection = provided.slice(0, separator);
35
+ const field = provided.slice(separator + 1);
36
+ if (!collections.has(collection)) {
37
+ if (!unknownCollections.has(collection)) {
38
+ unknownCollections.add(collection);
39
+ violations.push({
40
+ field: collection,
41
+ file: seed.file,
42
+ line: 1,
43
+ message: `Content collection "${collection}" has seed data but no matching collection is declared.`,
44
+ rule: "seed-schema",
45
+ });
46
+ }
47
+ continue;
48
+ }
49
+ if (!seed.declared.has(provided)) {
50
+ violations.push({
51
+ field,
52
+ file: seed.file,
53
+ line: 1,
54
+ message: `Content field "${collection}.${field}" is provided but not declared in collection "${collection}".`,
55
+ rule: "seed-schema",
56
+ });
57
+ }
58
+ }
59
+ return violations;
30
60
  }
31
61
  function sortViolations(violations) {
32
62
  return violations.sort((left, right) => left.file.localeCompare(right.file) ||
@@ -534,10 +564,19 @@ function lineAt(code, index) {
534
564
  function parseSeed(source) {
535
565
  const parsed = JSON.parse(source.source);
536
566
  const seedCollections = [];
567
+ const declared = new Set();
537
568
  const fields = new Map();
569
+ const provided = new Set();
538
570
  const seeded = new Set();
539
571
  if (!isRecord(parsed)) {
540
- return { collections: seedCollections, fields, file: source.file, seeded };
572
+ return {
573
+ collections: seedCollections,
574
+ declared,
575
+ fields,
576
+ file: source.file,
577
+ provided,
578
+ seeded,
579
+ };
541
580
  }
542
581
  const collections = Array.isArray(parsed.collections)
543
582
  ? parsed.collections
@@ -565,6 +604,7 @@ function parseSeed(source) {
565
604
  const entries = fields.get(field.slug) ?? [];
566
605
  entries.push({ collection: collectionSlug, slug: field.slug });
567
606
  fields.set(field.slug, entries);
607
+ declared.add(`${collectionSlug}.${field.slug}`);
568
608
  }
569
609
  }
570
610
  const content = isRecord(parsed.content) ? parsed.content : {};
@@ -577,6 +617,7 @@ function parseSeed(source) {
577
617
  continue;
578
618
  }
579
619
  for (const [slug, value] of Object.entries(entry.data)) {
620
+ provided.add(`${collectionSlug}.${slug}`);
580
621
  if (value !== null && value !== undefined && value !== "") {
581
622
  seeded.add(`${collectionSlug}.${slug}`);
582
623
  }
@@ -585,8 +626,10 @@ function parseSeed(source) {
585
626
  }
586
627
  return {
587
628
  collections: seedCollections,
629
+ declared,
588
630
  fields,
589
631
  file: source.file,
632
+ provided,
590
633
  seeded,
591
634
  };
592
635
  }
@@ -1,10 +1,10 @@
1
- import { z } from "zod";
1
+ import { type infer as InferSchema } from "zod/mini";
2
2
  export declare const SITE_RUNTIME_NAME: "@chat-de-hp/site";
3
3
  export declare const SITE_RUNTIME_VERSION: string;
4
4
  export declare const SITE_RUNTIME_PROTOCOL_VERSION: 1;
5
- export declare const siteRuntimeBindingSchema: z.ZodObject<{
6
- name: z.ZodString;
7
- type: z.ZodEnum<{
5
+ export declare const siteRuntimeBindingSchema: import("zod/mini").ZodMiniObject<{
6
+ name: import("zod/mini").ZodMiniString<string>;
7
+ type: import("zod/mini").ZodMiniEnum<{
8
8
  d1: "d1";
9
9
  images: "images";
10
10
  kv_namespace: "kv_namespace";
@@ -12,20 +12,20 @@ export declare const siteRuntimeBindingSchema: z.ZodObject<{
12
12
  send_email: "send_email";
13
13
  worker_loader: "worker_loader";
14
14
  }>;
15
- }, z.core.$loose>;
16
- export declare const siteRuntimeManifestSchema: z.ZodObject<{
17
- capabilities: z.ZodArray<z.ZodObject<{
18
- id: z.ZodString;
19
- provider: z.ZodString;
20
- schemaVersion: z.ZodNumber;
21
- }, z.core.$loose>>;
22
- primitives: z.ZodArray<z.ZodObject<{
23
- id: z.ZodString;
24
- schemaVersion: z.ZodNumber;
25
- }, z.core.$loose>>;
26
- requiredBindings: z.ZodArray<z.ZodObject<{
27
- name: z.ZodString;
28
- type: z.ZodEnum<{
15
+ }, import("zod/v4/core").$loose>;
16
+ export declare const siteRuntimeManifestSchema: import("zod/mini").ZodMiniObject<{
17
+ capabilities: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniObject<{
18
+ id: import("zod/mini").ZodMiniString<string>;
19
+ provider: import("zod/mini").ZodMiniString<string>;
20
+ schemaVersion: import("zod/mini").ZodMiniNumber<number>;
21
+ }, import("zod/v4/core").$loose>>;
22
+ primitives: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniObject<{
23
+ id: import("zod/mini").ZodMiniString<string>;
24
+ schemaVersion: import("zod/mini").ZodMiniNumber<number>;
25
+ }, import("zod/v4/core").$loose>>;
26
+ requiredBindings: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniObject<{
27
+ name: import("zod/mini").ZodMiniString<string>;
28
+ type: import("zod/mini").ZodMiniEnum<{
29
29
  d1: "d1";
30
30
  images: "images";
31
31
  kv_namespace: "kv_namespace";
@@ -33,15 +33,15 @@ export declare const siteRuntimeManifestSchema: z.ZodObject<{
33
33
  send_email: "send_email";
34
34
  worker_loader: "worker_loader";
35
35
  }>;
36
- }, z.core.$loose>>;
37
- runtime: z.ZodObject<{
38
- name: z.ZodLiteral<"@chat-de-hp/site">;
39
- protocolVersion: z.ZodLiteral<1>;
40
- version: z.ZodString;
41
- }, z.core.$loose>;
42
- schemaVersion: z.ZodLiteral<1>;
43
- }, z.core.$loose>;
44
- export type SiteRuntimeBinding = z.infer<typeof siteRuntimeBindingSchema>;
45
- export type SiteRuntimeManifest = z.infer<typeof siteRuntimeManifestSchema>;
36
+ }, import("zod/v4/core").$loose>>;
37
+ runtime: import("zod/mini").ZodMiniObject<{
38
+ name: import("zod/mini").ZodMiniLiteral<"@chat-de-hp/site">;
39
+ protocolVersion: import("zod/mini").ZodMiniLiteral<1>;
40
+ version: import("zod/mini").ZodMiniString<string>;
41
+ }, import("zod/v4/core").$loose>;
42
+ schemaVersion: import("zod/mini").ZodMiniLiteral<1>;
43
+ }, import("zod/v4/core").$loose>;
44
+ export type SiteRuntimeBinding = InferSchema<typeof siteRuntimeBindingSchema>;
45
+ export type SiteRuntimeManifest = InferSchema<typeof siteRuntimeManifestSchema>;
46
46
  export declare function parseSiteRuntimeManifest(value: unknown): SiteRuntimeManifest;
47
47
  //# sourceMappingURL=control-plane.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB,EAAG,kBAA2B,CAAC;AAC7D,eAAO,MAAM,oBAAoB,QAAsB,CAAC;AACxD,eAAO,MAAM,6BAA6B,EAAG,CAAU,CAAC;AAExD,eAAO,MAAM,wBAAwB;;;;;;;;;;iBAYrB,CAAC;AAEjB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BtB,CAAC;AAEjB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAE5E"}
1
+ {"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,KAAK,IAAI,WAAW,EAQ1B,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,iBAAiB,EAAG,kBAA2B,CAAC;AAC7D,eAAO,MAAM,oBAAoB,QAAsB,CAAC;AACxD,eAAO,MAAM,6BAA6B,EAAG,CAAU,CAAC;AAExD,eAAO,MAAM,wBAAwB;;;;;;;;;;gCAUnC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAqBpC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC9E,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAQ5E"}
@@ -1,12 +1,11 @@
1
- import { z } from "zod";
1
+ import { array, enum as enumSchema, int, literal, looseObject, minLength, number, positive, string, } from "zod/mini";
2
2
  import packageJson from "../package.json" with { type: "json" };
3
3
  export const SITE_RUNTIME_NAME = "@chat-de-hp/site";
4
4
  export const SITE_RUNTIME_VERSION = packageJson.version;
5
5
  export const SITE_RUNTIME_PROTOCOL_VERSION = 1;
6
- export const siteRuntimeBindingSchema = z
7
- .object({
8
- name: z.string().min(1),
9
- type: z.enum([
6
+ export const siteRuntimeBindingSchema = looseObject({
7
+ name: string().check(minLength(1)),
8
+ type: enumSchema([
10
9
  "d1",
11
10
  "images",
12
11
  "kv_namespace",
@@ -14,34 +13,32 @@ export const siteRuntimeBindingSchema = z
14
13
  "send_email",
15
14
  "worker_loader",
16
15
  ]),
17
- })
18
- .passthrough();
19
- export const siteRuntimeManifestSchema = z
20
- .object({
21
- capabilities: z.array(z
22
- .object({
23
- id: z.string().min(1),
24
- provider: z.string().min(1),
25
- schemaVersion: z.number().int().positive(),
26
- })
27
- .passthrough()),
28
- primitives: z.array(z
29
- .object({
30
- id: z.string().min(1),
31
- schemaVersion: z.number().int().positive(),
32
- })
33
- .passthrough()),
34
- requiredBindings: z.array(siteRuntimeBindingSchema),
35
- runtime: z
36
- .object({
37
- name: z.literal(SITE_RUNTIME_NAME),
38
- protocolVersion: z.literal(SITE_RUNTIME_PROTOCOL_VERSION),
39
- version: z.string().min(1),
40
- })
41
- .passthrough(),
42
- schemaVersion: z.literal(1),
43
- })
44
- .passthrough();
16
+ });
17
+ export const siteRuntimeManifestSchema = looseObject({
18
+ capabilities: array(looseObject({
19
+ id: string().check(minLength(1)),
20
+ provider: string().check(minLength(1)),
21
+ schemaVersion: number().check(int(), positive()),
22
+ })),
23
+ primitives: array(looseObject({
24
+ id: string().check(minLength(1)),
25
+ schemaVersion: number().check(int(), positive()),
26
+ })),
27
+ requiredBindings: array(siteRuntimeBindingSchema),
28
+ runtime: looseObject({
29
+ name: literal(SITE_RUNTIME_NAME),
30
+ protocolVersion: literal(SITE_RUNTIME_PROTOCOL_VERSION),
31
+ version: string().check(minLength(1)),
32
+ }),
33
+ schemaVersion: literal(1),
34
+ });
45
35
  export function parseSiteRuntimeManifest(value) {
46
- return siteRuntimeManifestSchema.parse(value);
36
+ try {
37
+ return siteRuntimeManifestSchema.parse(value);
38
+ }
39
+ catch (error) {
40
+ throw new Error("Invalid input: site runtime manifest failed validation.", {
41
+ cause: error,
42
+ });
43
+ }
47
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat-de-hp/site",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "description": "Managed Astro site runtime and primitive composition for Chat de HP",
6
6
  "license": "MIT",
@@ -13,6 +13,9 @@
13
13
  "README.md"
14
14
  ],
15
15
  "type": "module",
16
+ "sideEffects": [
17
+ "./dist/primitives/forms-styles.css"
18
+ ],
16
19
  "exports": {
17
20
  ".": {
18
21
  "types": "./dist/index.d.ts",