@easy-web/core 1.5.0 → 1.6.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/README.md +42 -1
- package/dist/contracts/capabilities.d.ts +38 -0
- package/dist/contracts/capabilities.d.ts.map +1 -1
- package/dist/contracts/content-composition.d.ts +144 -0
- package/dist/contracts/content-composition.d.ts.map +1 -0
- package/dist/contracts/content-composition.js +143 -0
- package/dist/contracts/content-composition.js.map +1 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/traits.d.ts +98 -0
- package/dist/contracts/traits.d.ts.map +1 -0
- package/dist/contracts/traits.js +84 -0
- package/dist/contracts/traits.js.map +1 -0
- package/dist/demo/demo-content.d.ts +37 -0
- package/dist/demo/demo-content.d.ts.map +1 -0
- package/dist/demo/demo-content.js +171 -0
- package/dist/demo/demo-content.js.map +1 -0
- package/dist/demo/index.d.ts +3 -0
- package/dist/demo/index.d.ts.map +1 -0
- package/dist/demo/index.js +3 -0
- package/dist/demo/index.js.map +1 -0
- package/dist/demo/legal-shells.d.ts +18 -0
- package/dist/demo/legal-shells.d.ts.map +1 -0
- package/dist/demo/legal-shells.js +40 -0
- package/dist/demo/legal-shells.js.map +1 -0
- package/dist/i18n/cli-catalogs.d.ts +42 -0
- package/dist/i18n/cli-catalogs.d.ts.map +1 -0
- package/dist/i18n/cli-catalogs.js +29 -0
- package/dist/i18n/cli-catalogs.js.map +1 -0
- package/dist/i18n/create-localization.d.ts +37 -0
- package/dist/i18n/create-localization.d.ts.map +1 -0
- package/dist/i18n/create-localization.js +68 -0
- package/dist/i18n/create-localization.js.map +1 -0
- package/dist/i18n/explicit-formatters.d.ts +20 -0
- package/dist/i18n/explicit-formatters.d.ts.map +1 -0
- package/dist/i18n/explicit-formatters.js +18 -0
- package/dist/i18n/explicit-formatters.js.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/locale-inputs.d.ts +18 -0
- package/dist/i18n/locale-inputs.d.ts.map +1 -0
- package/dist/i18n/locale-inputs.js +73 -0
- package/dist/i18n/locale-inputs.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/recipes/admission.d.ts +161 -0
- package/dist/recipes/admission.d.ts.map +1 -0
- package/dist/recipes/admission.js +85 -0
- package/dist/recipes/admission.js.map +1 -0
- package/dist/recipes/graph.d.ts +101 -0
- package/dist/recipes/graph.d.ts.map +1 -0
- package/dist/recipes/graph.js +166 -0
- package/dist/recipes/graph.js.map +1 -0
- package/dist/recipes/index.d.ts +9 -0
- package/dist/recipes/index.d.ts.map +1 -0
- package/dist/recipes/index.js +9 -0
- package/dist/recipes/index.js.map +1 -0
- package/dist/recipes/mermaid.d.ts +3 -0
- package/dist/recipes/mermaid.d.ts.map +1 -0
- package/dist/recipes/mermaid.js +79 -0
- package/dist/recipes/mermaid.js.map +1 -0
- package/dist/recipes/registry.d.ts +82 -0
- package/dist/recipes/registry.d.ts.map +1 -0
- package/dist/recipes/registry.js +40 -0
- package/dist/recipes/registry.js.map +1 -0
- package/dist/recipes/schema.d.ts +129 -0
- package/dist/recipes/schema.d.ts.map +1 -0
- package/dist/recipes/schema.js +41 -0
- package/dist/recipes/schema.js.map +1 -0
- package/dist/recipes/serialize.d.ts +20 -0
- package/dist/recipes/serialize.d.ts.map +1 -0
- package/dist/recipes/serialize.js +56 -0
- package/dist/recipes/serialize.js.map +1 -0
- package/dist/recipes/shell-recipe.d.ts +59 -0
- package/dist/recipes/shell-recipe.d.ts.map +1 -0
- package/dist/recipes/shell-recipe.js +145 -0
- package/dist/recipes/shell-recipe.js.map +1 -0
- package/dist/recipes/types.d.ts +72 -0
- package/dist/recipes/types.d.ts.map +1 -0
- package/dist/recipes/types.js +13 -0
- package/dist/recipes/types.js.map +1 -0
- package/dist/schemas/galleries.d.ts +2 -2
- package/package.json +17 -1
- package/src/components/DemoLegalShell.astro +36 -0
- package/src/contracts/__tests__/content-composition.test.ts +170 -0
- package/src/contracts/capabilities.ts +49 -0
- package/src/contracts/content-composition.ts +176 -0
- package/src/contracts/index.ts +2 -0
- package/src/contracts/traits.ts +107 -0
- package/src/demo/__tests__/demo-content.test.ts +107 -0
- package/src/demo/demo-content.ts +210 -0
- package/src/demo/index.ts +2 -0
- package/src/demo/legal-shells.ts +52 -0
- package/src/i18n/__tests__/create-localization.test.ts +138 -0
- package/src/i18n/__tests__/explicit-formatters.test.ts +82 -0
- package/src/i18n/cli-catalogs.ts +44 -0
- package/src/i18n/create-localization.ts +67 -0
- package/src/i18n/explicit-formatters.ts +36 -0
- package/src/i18n/index.ts +4 -0
- package/src/i18n/locale-inputs.ts +73 -0
- package/src/index.ts +1 -0
- package/src/recipes/__tests__/graph.test.ts +139 -0
- package/src/recipes/__tests__/protocol.test.ts +180 -0
- package/src/recipes/__tests__/serialize.test.ts +128 -0
- package/src/recipes/__tests__/shell-recipe.test.ts +75 -0
- package/src/recipes/admission.ts +77 -0
- package/src/recipes/graph.ts +244 -0
- package/src/recipes/index.ts +8 -0
- package/src/recipes/mermaid.ts +75 -0
- package/src/recipes/registry.ts +48 -0
- package/src/recipes/schema.ts +53 -0
- package/src/recipes/serialize.ts +77 -0
- package/src/recipes/shell-recipe.ts +162 -0
- package/src/recipes/types.ts +63 -0
package/README.md
CHANGED
|
@@ -5,6 +5,9 @@ The base package for the `@easy-web/*` family. It owns the shared content contra
|
|
|
5
5
|
## Subpaths
|
|
6
6
|
|
|
7
7
|
- `@easy-web/core/contracts` - content and capability contracts
|
|
8
|
+
- `@easy-web/core/recipes` - first-party recipe protocol, hook types and pure admission schemas
|
|
9
|
+
- `@easy-web/core/recipes/schema` - serializable metadata Zod schema and JSON Schema
|
|
10
|
+
- `@easy-web/core/recipes/registry` - CLI-pinned package/version/integrity/export manifest schema
|
|
8
11
|
- `@easy-web/core/theme` - theme helpers and tokens
|
|
9
12
|
- `@easy-web/core/i18n` - localization helpers
|
|
10
13
|
- `@easy-web/core/seo` - SEO integration and components
|
|
@@ -14,7 +17,45 @@ The base package for the `@easy-web/*` family. It owns the shared content contra
|
|
|
14
17
|
- `@easy-web/core/styles/tokens.css` and `@easy-web/core/styles/fonts.css` - shared styles
|
|
15
18
|
|
|
16
19
|
## Add-ons
|
|
17
|
-
|
|
20
|
+
|
|
18
21
|
Four concerns remain separate because they depend on a specific platform or runtime: `@easy-web/swa` for Azure Static Web Apps, the `cms-adapters` package for Decap CMS, `@easy-web/auth` for React and MSAL authentication, and `@easy-web/brand` for brand tooling.
|
|
19
22
|
|
|
23
|
+
## Recipe protocol version 1
|
|
24
|
+
|
|
25
|
+
Recipes declare `provides`, `requires`, `conflicts`, compatibility ranges, output
|
|
26
|
+
contributions and deterministic ordering (`priority`, then `key`, then recipe id;
|
|
27
|
+
dependencies precede consumers). Capability ids describe traits, like `HasImage`
|
|
28
|
+
and `Linkable`, not customer-specific content types.
|
|
29
|
+
|
|
30
|
+
`RecipeMetadata<Options>` carries a Zod `optionsSchema`, validator hooks and a
|
|
31
|
+
direct `generate(context)` hook returning file data. The serializable descriptor
|
|
32
|
+
uses a JSON Schema options object, validator descriptors and `generate: "direct"`;
|
|
33
|
+
functions cannot be represented in JSON Schema. Its exported JSON Schema validates
|
|
34
|
+
shape only. Pure `createRecipeAdmissionSchema(policy)` additionally checks selected
|
|
35
|
+
set invariants and compatibility using an injected semver `satisfies` policy.
|
|
36
|
+
The policy must reject malformed ranges. Admission never executes hooks or emits
|
|
37
|
+
a resolved graph; dependency selection and ordering belong to the CLI resolver.
|
|
38
|
+
|
|
39
|
+
Recipes are NEVER loaded from the generation target's `node_modules`. Only
|
|
40
|
+
CLI-pinned or bundled verified artifacts from the closed first-party package set
|
|
41
|
+
are allowed. A registry pin identifies package name, exact version, SHA-512 SRI
|
|
42
|
+
and package-relative export path. The future loader must verify artifact bytes
|
|
43
|
+
before importing executable code; admission checks its receipt against the
|
|
44
|
+
CLI-owned registry, not a registry supplied by the target. A receipt schema alone
|
|
45
|
+
is not cryptographic verification. No loader or recipe implementation ships here.
|
|
46
|
+
|
|
47
|
+
## Generic content composition
|
|
48
|
+
|
|
49
|
+
Content types select additive traits from `title`, `slug`, `summary`, `body`,
|
|
50
|
+
`image`, `photos`, `order`, `taxonomy`, `publication`, `schedule`, `location`,
|
|
51
|
+
`cta`, `money`, and `featured`. They opt into the closed bindings `homepage`,
|
|
52
|
+
`list`, `detail`, `navigation`, and `cms-admin`; each binding has exported trait
|
|
53
|
+
requirements enforced by `contentCompositionSchema`. Labels and complete public
|
|
54
|
+
routes are declared per configured content locale. A content type exposes a
|
|
55
|
+
`primary` marker, while aggregate validation permits at most one primary type.
|
|
56
|
+
|
|
57
|
+
Only a money-enabled selection accepts `currency`, validated by the shared ISO
|
|
58
|
+
4217 input schema. `homepage` requires `featured`, so a type cannot occupy that
|
|
59
|
+
featured presentation slot merely by defining an image.
|
|
60
|
+
|
|
20
61
|
This package is private while the consolidation is in progress and is made publishable only by the family release task.
|
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
import type { AstroComponentFactory } from 'astro/runtime/server/index.js';
|
|
2
|
+
import type { CurrencyCode } from '../i18n/locale-inputs.js';
|
|
3
|
+
import type { Link } from './types.js';
|
|
2
4
|
import type { Image } from './types.js';
|
|
5
|
+
export interface HasTitle {
|
|
6
|
+
readonly title: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HasSlug {
|
|
9
|
+
readonly slug: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HasSummary {
|
|
12
|
+
readonly summary: string;
|
|
13
|
+
}
|
|
3
14
|
export interface HasImage {
|
|
4
15
|
image: Image;
|
|
5
16
|
}
|
|
6
17
|
export interface HasPhotos {
|
|
7
18
|
photos: Image[];
|
|
8
19
|
}
|
|
20
|
+
export interface HasOrder {
|
|
21
|
+
readonly order: number;
|
|
22
|
+
}
|
|
23
|
+
export interface HasTaxonomy {
|
|
24
|
+
readonly taxonomy: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface HasPublication {
|
|
27
|
+
readonly publishDate: Date;
|
|
28
|
+
readonly modifiedDate?: Date;
|
|
29
|
+
}
|
|
30
|
+
export interface HasSchedule {
|
|
31
|
+
readonly startDate: Date;
|
|
32
|
+
readonly endDate?: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface HasLocation {
|
|
35
|
+
readonly location: string;
|
|
36
|
+
}
|
|
37
|
+
export interface HasCta {
|
|
38
|
+
readonly cta: Link;
|
|
39
|
+
}
|
|
40
|
+
export interface HasMoney {
|
|
41
|
+
readonly amount: number;
|
|
42
|
+
readonly currency: CurrencyCode;
|
|
43
|
+
}
|
|
44
|
+
export interface HasFeatured {
|
|
45
|
+
readonly featured: boolean;
|
|
46
|
+
}
|
|
9
47
|
export type RenderedContent = AstroComponentFactory;
|
|
10
48
|
export interface HasBody {
|
|
11
49
|
Content: RenderedContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/contracts/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,CAAC,I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AAI,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
export declare const presentationBindings: readonly ["homepage", "list", "detail", "navigation", "cms-admin"];
|
|
3
|
+
export declare const presentationBindingSchema: z.ZodEnum<{
|
|
4
|
+
homepage: "homepage";
|
|
5
|
+
list: "list";
|
|
6
|
+
detail: "detail";
|
|
7
|
+
navigation: "navigation";
|
|
8
|
+
"cms-admin": "cms-admin";
|
|
9
|
+
}>;
|
|
10
|
+
export type PresentationBinding = z.infer<typeof presentationBindingSchema>;
|
|
11
|
+
export declare const presentationBindingRequirements: {
|
|
12
|
+
readonly homepage: readonly ["title", "slug", "image", "featured"];
|
|
13
|
+
readonly list: readonly ["title", "slug"];
|
|
14
|
+
readonly detail: readonly ["title", "slug", "body"];
|
|
15
|
+
readonly navigation: readonly ["title", "slug"];
|
|
16
|
+
readonly 'cms-admin': readonly ["title", "slug"];
|
|
17
|
+
};
|
|
18
|
+
export declare const contentTypeIdSchema: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
19
|
+
export type ContentTypeId = z.infer<typeof contentTypeIdSchema>;
|
|
20
|
+
export declare const contentTypeDefinitionSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
21
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
22
|
+
title: "title";
|
|
23
|
+
slug: "slug";
|
|
24
|
+
summary: "summary";
|
|
25
|
+
body: "body";
|
|
26
|
+
image: "image";
|
|
27
|
+
photos: "photos";
|
|
28
|
+
order: "order";
|
|
29
|
+
taxonomy: "taxonomy";
|
|
30
|
+
publication: "publication";
|
|
31
|
+
schedule: "schedule";
|
|
32
|
+
location: "location";
|
|
33
|
+
cta: "cta";
|
|
34
|
+
money: "money";
|
|
35
|
+
featured: "featured";
|
|
36
|
+
}>>>;
|
|
37
|
+
currency: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "CurrencyCode", "out">>;
|
|
38
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
39
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
40
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
41
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
42
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
43
|
+
homepage: "homepage";
|
|
44
|
+
list: "list";
|
|
45
|
+
detail: "detail";
|
|
46
|
+
navigation: "navigation";
|
|
47
|
+
"cms-admin": "cms-admin";
|
|
48
|
+
}>>>;
|
|
49
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
50
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
51
|
+
title: "title";
|
|
52
|
+
slug: "slug";
|
|
53
|
+
summary: "summary";
|
|
54
|
+
body: "body";
|
|
55
|
+
image: "image";
|
|
56
|
+
photos: "photos";
|
|
57
|
+
order: "order";
|
|
58
|
+
taxonomy: "taxonomy";
|
|
59
|
+
publication: "publication";
|
|
60
|
+
schedule: "schedule";
|
|
61
|
+
location: "location";
|
|
62
|
+
cta: "cta";
|
|
63
|
+
money: "money";
|
|
64
|
+
featured: "featured";
|
|
65
|
+
}>>>;
|
|
66
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
67
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
69
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
70
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
71
|
+
homepage: "homepage";
|
|
72
|
+
list: "list";
|
|
73
|
+
detail: "detail";
|
|
74
|
+
navigation: "navigation";
|
|
75
|
+
"cms-admin": "cms-admin";
|
|
76
|
+
}>>>;
|
|
77
|
+
}, z.core.$strict>>]>;
|
|
78
|
+
export type ContentTypeDefinition = z.infer<typeof contentTypeDefinitionSchema>;
|
|
79
|
+
export declare const defaultReservedContentRoutes: readonly ["/", "/404/", "/admin/"];
|
|
80
|
+
export declare const contentCompositionSchema: z.ZodReadonly<z.ZodObject<{
|
|
81
|
+
contentLocales: z.ZodReadonly<z.ZodArray<z.core.$ZodBranded<z.ZodString, "ContentLocale", "out">>>;
|
|
82
|
+
contentTypes: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
83
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
84
|
+
title: "title";
|
|
85
|
+
slug: "slug";
|
|
86
|
+
summary: "summary";
|
|
87
|
+
body: "body";
|
|
88
|
+
image: "image";
|
|
89
|
+
photos: "photos";
|
|
90
|
+
order: "order";
|
|
91
|
+
taxonomy: "taxonomy";
|
|
92
|
+
publication: "publication";
|
|
93
|
+
schedule: "schedule";
|
|
94
|
+
location: "location";
|
|
95
|
+
cta: "cta";
|
|
96
|
+
money: "money";
|
|
97
|
+
featured: "featured";
|
|
98
|
+
}>>>;
|
|
99
|
+
currency: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "CurrencyCode", "out">>;
|
|
100
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
101
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
102
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
103
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
104
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
105
|
+
homepage: "homepage";
|
|
106
|
+
list: "list";
|
|
107
|
+
detail: "detail";
|
|
108
|
+
navigation: "navigation";
|
|
109
|
+
"cms-admin": "cms-admin";
|
|
110
|
+
}>>>;
|
|
111
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
112
|
+
traits: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
113
|
+
title: "title";
|
|
114
|
+
slug: "slug";
|
|
115
|
+
summary: "summary";
|
|
116
|
+
body: "body";
|
|
117
|
+
image: "image";
|
|
118
|
+
photos: "photos";
|
|
119
|
+
order: "order";
|
|
120
|
+
taxonomy: "taxonomy";
|
|
121
|
+
publication: "publication";
|
|
122
|
+
schedule: "schedule";
|
|
123
|
+
location: "location";
|
|
124
|
+
cta: "cta";
|
|
125
|
+
money: "money";
|
|
126
|
+
featured: "featured";
|
|
127
|
+
}>>>;
|
|
128
|
+
id: z.core.$ZodBranded<z.ZodString, "ContentTypeId", "out">;
|
|
129
|
+
primary: z.ZodDefault<z.ZodBoolean>;
|
|
130
|
+
labels: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
131
|
+
routes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
132
|
+
bindings: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
133
|
+
homepage: "homepage";
|
|
134
|
+
list: "list";
|
|
135
|
+
detail: "detail";
|
|
136
|
+
navigation: "navigation";
|
|
137
|
+
"cms-admin": "cms-admin";
|
|
138
|
+
}>>>;
|
|
139
|
+
}, z.core.$strict>>]>>>;
|
|
140
|
+
reservedRoutes: z.ZodReadonly<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
142
|
+
export type ContentComposition = z.infer<typeof contentCompositionSchema>;
|
|
143
|
+
export declare function parseContentComposition(input: unknown): ContentComposition;
|
|
144
|
+
//# sourceMappingURL=content-composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-composition.d.ts","sourceRoot":"","sources":["../../src/contracts/content-composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAK9B,eAAO,MAAM,oBAAoB,oEAAqE,CAAC;AACvG,eAAO,MAAM,yBAAyB;;;;;;EAA+B,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,+BAA+B;;;;;;CAMuC,CAAC;AAEpF,eAAO,MAAM,mBAAmB,yDAEL,CAAC;AAC5B,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAqChE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAA+D,CAAC;AACxG,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,4BAA4B,oCAAqC,CAAC;AAE/E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAwCxB,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAqE1E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAE1E"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { contentLocaleSchema, optionalCurrencyCodeSchema } from '../i18n/locale-inputs.js';
|
|
3
|
+
import { normalizeLocalizedPath, validateLocalizedPaths } from '../i18n/localized-paths.js';
|
|
4
|
+
import { contentTraitSchema } from './traits.js';
|
|
5
|
+
export const presentationBindings = ['homepage', 'list', 'detail', 'navigation', 'cms-admin'];
|
|
6
|
+
export const presentationBindingSchema = z.enum(presentationBindings);
|
|
7
|
+
export const presentationBindingRequirements = {
|
|
8
|
+
homepage: ['title', 'slug', 'image', 'featured'],
|
|
9
|
+
list: ['title', 'slug'],
|
|
10
|
+
detail: ['title', 'slug', 'body'],
|
|
11
|
+
navigation: ['title', 'slug'],
|
|
12
|
+
'cms-admin': ['title', 'slug'],
|
|
13
|
+
};
|
|
14
|
+
export const contentTypeIdSchema = z.string()
|
|
15
|
+
.regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, 'Content type ID must use lowercase kebab-case')
|
|
16
|
+
.brand();
|
|
17
|
+
const localizedTextSchema = z.record(z.string(), z.string().min(1)).readonly();
|
|
18
|
+
const localizedRoutesSchema = z.record(z.string(), z.string().regex(/^\/(?!\/)(?!.*[?#]).*$/, 'Route must be an absolute path without query or hash')).readonly();
|
|
19
|
+
const selectedTraitsSchema = z.array(contentTraitSchema).min(1).superRefine((traits, context) => {
|
|
20
|
+
if (new Set(traits).size !== traits.length) {
|
|
21
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: 'Selected traits must be unique' });
|
|
22
|
+
}
|
|
23
|
+
}).readonly();
|
|
24
|
+
const selectedBindingsSchema = z.array(presentationBindingSchema).min(1).superRefine((bindings, context) => {
|
|
25
|
+
if (new Set(bindings).size !== bindings.length) {
|
|
26
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: 'Selected bindings must be unique' });
|
|
27
|
+
}
|
|
28
|
+
}).readonly();
|
|
29
|
+
const contentTypeBaseShape = {
|
|
30
|
+
id: contentTypeIdSchema,
|
|
31
|
+
primary: z.boolean().default(false),
|
|
32
|
+
labels: localizedTextSchema,
|
|
33
|
+
routes: localizedRoutesSchema,
|
|
34
|
+
bindings: selectedBindingsSchema,
|
|
35
|
+
};
|
|
36
|
+
const moneyContentTypeSchema = z.object({
|
|
37
|
+
...contentTypeBaseShape,
|
|
38
|
+
traits: selectedTraitsSchema.refine((traits) => traits.includes('money'), 'Money selection must include the money trait'),
|
|
39
|
+
currency: optionalCurrencyCodeSchema,
|
|
40
|
+
}).strict().readonly();
|
|
41
|
+
const nonMoneyContentTypeSchema = z.object({
|
|
42
|
+
...contentTypeBaseShape,
|
|
43
|
+
traits: selectedTraitsSchema.refine((traits) => !traits.includes('money'), 'Non-money selection cannot include the money trait'),
|
|
44
|
+
}).strict().readonly();
|
|
45
|
+
export const contentTypeDefinitionSchema = z.union([moneyContentTypeSchema, nonMoneyContentTypeSchema]);
|
|
46
|
+
export const defaultReservedContentRoutes = ['/', '/404/', '/admin/'];
|
|
47
|
+
export const contentCompositionSchema = z.object({
|
|
48
|
+
contentLocales: z.array(contentLocaleSchema).min(1).readonly(),
|
|
49
|
+
contentTypes: z.array(contentTypeDefinitionSchema).readonly(),
|
|
50
|
+
reservedRoutes: z.array(z.string()).default(() => [...defaultReservedContentRoutes]).readonly(),
|
|
51
|
+
}).strict().superRefine((composition, context) => {
|
|
52
|
+
const locales = composition.contentLocales;
|
|
53
|
+
const normalizedReserved = new Set(composition.reservedRoutes.map(normalizeLocalizedPath));
|
|
54
|
+
const ids = new Map();
|
|
55
|
+
const routes = new Map();
|
|
56
|
+
let primaryId;
|
|
57
|
+
composition.contentTypes.forEach((contentType, index) => {
|
|
58
|
+
const path = ['contentTypes', index];
|
|
59
|
+
const existingId = ids.get(contentType.id);
|
|
60
|
+
if (existingId !== undefined) {
|
|
61
|
+
context.addIssue({
|
|
62
|
+
code: z.ZodIssueCode.custom,
|
|
63
|
+
path: [...path, 'id'],
|
|
64
|
+
message: `Duplicate content type ID "${contentType.id}"; first declared at contentTypes[${existingId}]`,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
ids.set(contentType.id, index);
|
|
69
|
+
}
|
|
70
|
+
if (contentType.primary) {
|
|
71
|
+
if (primaryId !== undefined) {
|
|
72
|
+
context.addIssue({
|
|
73
|
+
code: z.ZodIssueCode.custom,
|
|
74
|
+
path: [...path, 'primary'],
|
|
75
|
+
message: `Only one primary content type is allowed; "${primaryId}" is already primary`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
primaryId = contentType.id;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
validateLocales(contentType, locales, path, context);
|
|
83
|
+
validateBindings(contentType, path, context);
|
|
84
|
+
validateRoutes(contentType, path, normalizedReserved, routes, context);
|
|
85
|
+
});
|
|
86
|
+
}).readonly();
|
|
87
|
+
function validateLocales(contentType, locales, path, context) {
|
|
88
|
+
for (const [name, localized] of [['labels', contentType.labels], ['routes', contentType.routes]]) {
|
|
89
|
+
const declared = Object.keys(localized);
|
|
90
|
+
const missing = locales.filter((locale) => !declared.includes(locale));
|
|
91
|
+
const unknown = declared.filter((locale) => !locales.includes(locale));
|
|
92
|
+
if (missing.length > 0)
|
|
93
|
+
context.addIssue({
|
|
94
|
+
code: z.ZodIssueCode.custom,
|
|
95
|
+
path: [...path, name],
|
|
96
|
+
message: `Missing configured locale(s): ${missing.join(', ')}`,
|
|
97
|
+
});
|
|
98
|
+
if (unknown.length > 0)
|
|
99
|
+
context.addIssue({
|
|
100
|
+
code: z.ZodIssueCode.custom,
|
|
101
|
+
path: [...path, name],
|
|
102
|
+
message: `Unknown content locale(s): ${unknown.join(', ')}`,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
for (const problem of validateLocalizedPaths([contentType.routes], locales)) {
|
|
106
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: [...path, 'routes'], message: problem });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function validateBindings(contentType, path, context) {
|
|
110
|
+
const selected = new Set(contentType.traits);
|
|
111
|
+
for (const binding of contentType.bindings) {
|
|
112
|
+
const missing = presentationBindingRequirements[binding].filter((trait) => !selected.has(trait));
|
|
113
|
+
if (missing.length > 0)
|
|
114
|
+
context.addIssue({
|
|
115
|
+
code: z.ZodIssueCode.custom,
|
|
116
|
+
path: [...path, 'bindings'],
|
|
117
|
+
message: `Binding "${binding}" requires trait(s): ${missing.join(', ')}`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function validateRoutes(contentType, path, reserved, routes, context) {
|
|
122
|
+
for (const route of Object.values(contentType.routes)) {
|
|
123
|
+
const normalized = normalizeLocalizedPath(route);
|
|
124
|
+
if (reserved.has(normalized))
|
|
125
|
+
context.addIssue({
|
|
126
|
+
code: z.ZodIssueCode.custom,
|
|
127
|
+
path: [...path, 'routes'],
|
|
128
|
+
message: `Route "${route}" is reserved`,
|
|
129
|
+
});
|
|
130
|
+
const owner = routes.get(normalized);
|
|
131
|
+
if (owner !== undefined && owner !== contentType.id)
|
|
132
|
+
context.addIssue({
|
|
133
|
+
code: z.ZodIssueCode.custom,
|
|
134
|
+
path: [...path, 'routes'],
|
|
135
|
+
message: `Route "${route}" collides with content type "${owner}"`,
|
|
136
|
+
});
|
|
137
|
+
routes.set(normalized, contentType.id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export function parseContentComposition(input) {
|
|
141
|
+
return contentCompositionSchema.parse(input);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=content-composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-composition.js","sourceRoot":"","sources":["../../src/contracts/content-composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,0B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IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC;gBACzB,OAAO,EAAE,UAAU,KAAK,eAAe;aACxC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,CAAC,EAAE;YAAE,OAAO,CAAC,QAAQ,CAAC;gBACpE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC;gBACzB,OAAO,EAAE,UAAU,KAAK,iCAAiC,KAAK,GAAG;aAClE,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,OAAO,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './capabilities.js';
|
|
2
|
+
export * from './content-composition.js';
|
|
2
3
|
export * from './implements.js';
|
|
3
4
|
export * from './props.js';
|
|
4
5
|
export * from './publish.js';
|
|
5
6
|
export * from './types.js';
|
|
7
|
+
export * from './traits.js';
|
|
6
8
|
export * from './jsonld.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './capabilities.js';
|
|
2
|
+
export * from './content-composition.js';
|
|
2
3
|
export * from './implements.js';
|
|
3
4
|
export * from './props.js';
|
|
4
5
|
export * from './publish.js';
|
|
5
6
|
export * from './types.js';
|
|
7
|
+
export * from './traits.js';
|
|
6
8
|
export * from './jsonld.js';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
export declare const contentTraits: readonly ["title", "slug", "summary", "body", "image", "photos", "order", "taxonomy", "publication", "schedule", "location", "cta", "money", "featured"];
|
|
3
|
+
export declare const contentTraitSchema: z.ZodEnum<{
|
|
4
|
+
title: "title";
|
|
5
|
+
slug: "slug";
|
|
6
|
+
summary: "summary";
|
|
7
|
+
body: "body";
|
|
8
|
+
image: "image";
|
|
9
|
+
photos: "photos";
|
|
10
|
+
order: "order";
|
|
11
|
+
taxonomy: "taxonomy";
|
|
12
|
+
publication: "publication";
|
|
13
|
+
schedule: "schedule";
|
|
14
|
+
location: "location";
|
|
15
|
+
cta: "cta";
|
|
16
|
+
money: "money";
|
|
17
|
+
featured: "featured";
|
|
18
|
+
}>;
|
|
19
|
+
export type ContentTrait = z.infer<typeof contentTraitSchema>;
|
|
20
|
+
export declare const titleTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
21
|
+
title: z.ZodString;
|
|
22
|
+
}, z.core.$strict>>;
|
|
23
|
+
export declare const slugTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
24
|
+
slug: z.ZodString;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
export declare const summaryTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
27
|
+
summary: z.ZodString;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
export declare const bodyTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
30
|
+
body: z.ZodString;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
export declare const imageTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
33
|
+
image: z.ZodReadonly<z.ZodObject<{
|
|
34
|
+
src: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
35
|
+
src: z.ZodString;
|
|
36
|
+
}, z.core.$loose>]>;
|
|
37
|
+
alt: z.ZodString;
|
|
38
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strict>>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
export declare const photosTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
42
|
+
photos: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
43
|
+
src: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
44
|
+
src: z.ZodString;
|
|
45
|
+
}, z.core.$loose>]>;
|
|
46
|
+
alt: z.ZodString;
|
|
47
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strict>>>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
export declare const orderTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
51
|
+
order: z.ZodNumber;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
export declare const taxonomyTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
54
|
+
taxonomy: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
export declare const publicationTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
57
|
+
publishDate: z.ZodDate;
|
|
58
|
+
modifiedDate: z.ZodOptional<z.ZodDate>;
|
|
59
|
+
}, z.core.$strict>>;
|
|
60
|
+
export declare const scheduleTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
61
|
+
startDate: z.ZodDate;
|
|
62
|
+
endDate: z.ZodOptional<z.ZodDate>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
export declare const locationTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
65
|
+
location: z.ZodString;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
export declare const ctaTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
68
|
+
cta: z.ZodReadonly<z.ZodObject<{
|
|
69
|
+
label: z.ZodString;
|
|
70
|
+
href: z.ZodString;
|
|
71
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
}, z.core.$strict>>;
|
|
74
|
+
export declare const moneyTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
75
|
+
amount: z.ZodNumber;
|
|
76
|
+
currency: z.core.$ZodBranded<z.ZodString, "CurrencyCode", "out">;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
export declare const featuredTraitSchema: z.ZodReadonly<z.ZodObject<{
|
|
79
|
+
featured: z.ZodBoolean;
|
|
80
|
+
}, z.core.$strict>>;
|
|
81
|
+
export type TitleTrait = z.infer<typeof titleTraitSchema>;
|
|
82
|
+
export type SlugTrait = z.infer<typeof slugTraitSchema>;
|
|
83
|
+
export type SummaryTrait = z.infer<typeof summaryTraitSchema>;
|
|
84
|
+
export type BodyTrait = z.infer<typeof bodyTraitSchema>;
|
|
85
|
+
export type ImageTrait = z.infer<typeof imageTraitSchema>;
|
|
86
|
+
export type PhotosTrait = z.infer<typeof photosTraitSchema>;
|
|
87
|
+
export type OrderTrait = z.infer<typeof orderTraitSchema>;
|
|
88
|
+
export type TaxonomyTrait = z.infer<typeof taxonomyTraitSchema>;
|
|
89
|
+
export type PublicationTrait = z.infer<typeof publicationTraitSchema>;
|
|
90
|
+
export type ScheduleTrait = z.infer<typeof scheduleTraitSchema>;
|
|
91
|
+
export type LocationTrait = z.infer<typeof locationTraitSchema>;
|
|
92
|
+
export type CtaTrait = z.infer<typeof ctaTraitSchema>;
|
|
93
|
+
export type MoneyTrait = z.infer<typeof moneyTraitSchema>;
|
|
94
|
+
export type FeaturedTrait = z.infer<typeof featuredTraitSchema>;
|
|
95
|
+
export declare function composeContentTraitSchema(traits: readonly ContentTrait[]): z.ZodReadonly<z.ZodObject<{
|
|
96
|
+
[x: string]: z.ZodTypeAny<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
//# sourceMappingURL=traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../../src/contracts/traits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAmC9B,eAAO,MAAM,aAAa,0JAehB,CAAC;AAE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C5D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAmBhE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE;;oBAIxE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { currencyCodeSchema } from '../i18n/locale-inputs.js';
|
|
3
|
+
const imageSourceSchema = z.union([
|
|
4
|
+
z.string().min(1),
|
|
5
|
+
z.object({ src: z.string().min(1) }).passthrough(),
|
|
6
|
+
]);
|
|
7
|
+
const imageSchema = z.object({
|
|
8
|
+
src: imageSourceSchema,
|
|
9
|
+
alt: z.string().min(1),
|
|
10
|
+
caption: z.string().optional(),
|
|
11
|
+
}).strict().readonly();
|
|
12
|
+
const linkSchema = z.object({
|
|
13
|
+
label: z.string().min(1),
|
|
14
|
+
href: z.string().min(1),
|
|
15
|
+
external: z.boolean().optional(),
|
|
16
|
+
}).strict().readonly();
|
|
17
|
+
const titleShape = { title: z.string().min(1) };
|
|
18
|
+
const slugShape = { slug: z.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must use lowercase kebab-case') };
|
|
19
|
+
const summaryShape = { summary: z.string().min(1) };
|
|
20
|
+
const bodyShape = { body: z.string().min(1) };
|
|
21
|
+
const imageShape = { image: imageSchema };
|
|
22
|
+
const photosShape = { photos: z.array(imageSchema).readonly() };
|
|
23
|
+
const orderShape = { order: z.number().int() };
|
|
24
|
+
const taxonomyShape = { taxonomy: z.array(z.string().min(1)).readonly() };
|
|
25
|
+
const publicationShape = { publishDate: z.date(), modifiedDate: z.date().optional() };
|
|
26
|
+
const scheduleShape = { startDate: z.date(), endDate: z.date().optional() };
|
|
27
|
+
const locationShape = { location: z.string().min(1) };
|
|
28
|
+
const ctaShape = { cta: linkSchema };
|
|
29
|
+
const moneyShape = { amount: z.number().finite(), currency: currencyCodeSchema };
|
|
30
|
+
const featuredShape = { featured: z.boolean() };
|
|
31
|
+
export const contentTraits = [
|
|
32
|
+
'title',
|
|
33
|
+
'slug',
|
|
34
|
+
'summary',
|
|
35
|
+
'body',
|
|
36
|
+
'image',
|
|
37
|
+
'photos',
|
|
38
|
+
'order',
|
|
39
|
+
'taxonomy',
|
|
40
|
+
'publication',
|
|
41
|
+
'schedule',
|
|
42
|
+
'location',
|
|
43
|
+
'cta',
|
|
44
|
+
'money',
|
|
45
|
+
'featured',
|
|
46
|
+
];
|
|
47
|
+
export const contentTraitSchema = z.enum(contentTraits);
|
|
48
|
+
export const titleTraitSchema = z.object(titleShape).strict().readonly();
|
|
49
|
+
export const slugTraitSchema = z.object(slugShape).strict().readonly();
|
|
50
|
+
export const summaryTraitSchema = z.object(summaryShape).strict().readonly();
|
|
51
|
+
export const bodyTraitSchema = z.object(bodyShape).strict().readonly();
|
|
52
|
+
export const imageTraitSchema = z.object(imageShape).strict().readonly();
|
|
53
|
+
export const photosTraitSchema = z.object(photosShape).strict().readonly();
|
|
54
|
+
export const orderTraitSchema = z.object(orderShape).strict().readonly();
|
|
55
|
+
export const taxonomyTraitSchema = z.object(taxonomyShape).strict().readonly();
|
|
56
|
+
export const publicationTraitSchema = z.object(publicationShape).strict().readonly();
|
|
57
|
+
export const scheduleTraitSchema = z.object(scheduleShape).strict().readonly();
|
|
58
|
+
export const locationTraitSchema = z.object(locationShape).strict().readonly();
|
|
59
|
+
export const ctaTraitSchema = z.object(ctaShape).strict().readonly();
|
|
60
|
+
export const moneyTraitSchema = z.object(moneyShape).strict().readonly();
|
|
61
|
+
export const featuredTraitSchema = z.object(featuredShape).strict().readonly();
|
|
62
|
+
const contentTraitShapes = {
|
|
63
|
+
title: titleShape,
|
|
64
|
+
slug: slugShape,
|
|
65
|
+
summary: summaryShape,
|
|
66
|
+
body: bodyShape,
|
|
67
|
+
image: imageShape,
|
|
68
|
+
photos: photosShape,
|
|
69
|
+
order: orderShape,
|
|
70
|
+
taxonomy: taxonomyShape,
|
|
71
|
+
publication: publicationShape,
|
|
72
|
+
schedule: scheduleShape,
|
|
73
|
+
location: locationShape,
|
|
74
|
+
cta: ctaShape,
|
|
75
|
+
money: moneyShape,
|
|
76
|
+
featured: featuredShape,
|
|
77
|
+
};
|
|
78
|
+
export function composeContentTraitSchema(traits) {
|
|
79
|
+
const shape = {};
|
|
80
|
+
for (const trait of traits)
|
|
81
|
+
Object.assign(shape, contentTraitShapes[trait]);
|
|
82
|
+
return z.object(shape).strict().readonly();
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=traits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../../src/contracts/traits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC;IAChC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACj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