@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
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
export const SHELL_RECIPE_ID = 'site.shell';
|
|
3
|
+
const shellOptionsSchema = z.strictObject({
|
|
4
|
+
siteName: z.string().min(1).default('Example Site'),
|
|
5
|
+
defaultLocale: z.string().default('en'),
|
|
6
|
+
noIndex: z.boolean().default(false),
|
|
7
|
+
});
|
|
8
|
+
const PLACEHOLDER_SITE_URL = 'https://replace-with-your-domain.example';
|
|
9
|
+
function astroConfig(options) {
|
|
10
|
+
return `import { defineConfig } from 'astro/config';
|
|
11
|
+
import easyWebSeo from '@easy-web/core/seo';
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
site: ${JSON.stringify(PLACEHOLDER_SITE_URL)},
|
|
15
|
+
integrations: [
|
|
16
|
+
easyWebSeo({ noIndex: ${options.noIndex ? 'true' : 'false'} }),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
const packageJsonFragment = `${JSON.stringify({
|
|
22
|
+
type: 'module',
|
|
23
|
+
scripts: { dev: 'astro dev', build: 'astro build', preview: 'astro preview' },
|
|
24
|
+
dependencies: { '@easy-web/core': '^1.5.0', astro: '^7.3.5' },
|
|
25
|
+
devDependencies: { typescript: '^5.5.0' },
|
|
26
|
+
}, null, 2)}\n`;
|
|
27
|
+
const pnpmWorkspace = `allowBuilds:
|
|
28
|
+
esbuild: true
|
|
29
|
+
sharp: true
|
|
30
|
+
`;
|
|
31
|
+
function baseLayout(options) {
|
|
32
|
+
return `---
|
|
33
|
+
import PageShell from '@easy-web/core/components/PageShell.astro';
|
|
34
|
+
import Header from '@easy-web/core/components/Header.astro';
|
|
35
|
+
import Footer from '@easy-web/core/components/Footer.astro';
|
|
36
|
+
|
|
37
|
+
interface Props {
|
|
38
|
+
title: string;
|
|
39
|
+
}
|
|
40
|
+
const { title } = Astro.props;
|
|
41
|
+
const siteName = ${JSON.stringify(options.siteName)};
|
|
42
|
+
const currentLang = ${JSON.stringify(options.defaultLocale)};
|
|
43
|
+
const navItems = [{ label: 'Home', href: '/' }];
|
|
44
|
+
---
|
|
45
|
+
<!doctype html>
|
|
46
|
+
<html lang=${JSON.stringify(options.defaultLocale)}>
|
|
47
|
+
<head>
|
|
48
|
+
<meta charset="utf-8" />
|
|
49
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
50
|
+
<title>{title}</title>
|
|
51
|
+
</head>
|
|
52
|
+
<body>
|
|
53
|
+
<PageShell lang={currentLang}>
|
|
54
|
+
<Header
|
|
55
|
+
slot="header"
|
|
56
|
+
lang={currentLang}
|
|
57
|
+
siteName={siteName}
|
|
58
|
+
navItems={navItems}
|
|
59
|
+
currentLang={currentLang}
|
|
60
|
+
pathname={Astro.url.pathname}
|
|
61
|
+
brandHref="/"
|
|
62
|
+
locales={[currentLang]}
|
|
63
|
+
/>
|
|
64
|
+
<slot />
|
|
65
|
+
<Footer slot="footer" lang={currentLang} siteName={siteName} legalLinks={[
|
|
66
|
+
{ label: 'Imprint (sample)', href: '/imprint' },
|
|
67
|
+
{ label: 'Privacy (sample)', href: '/privacy' },
|
|
68
|
+
]} />
|
|
69
|
+
</PageShell>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
function homePage(options) {
|
|
75
|
+
return `---
|
|
76
|
+
import Base from '../layouts/Base.astro';
|
|
77
|
+
---
|
|
78
|
+
<Base title=${JSON.stringify(options.siteName)}>
|
|
79
|
+
<h1>Welcome</h1>
|
|
80
|
+
<p>This is a generated placeholder home page. Replace this content before production.</p>
|
|
81
|
+
</Base>
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
function notFoundPage(options) {
|
|
85
|
+
return `---
|
|
86
|
+
import Base from '../layouts/Base.astro';
|
|
87
|
+
import NotFound from '@easy-web/core/components/NotFound.astro';
|
|
88
|
+
---
|
|
89
|
+
<Base title="Page not found">
|
|
90
|
+
<NotFound currentLang=${JSON.stringify(options.defaultLocale)} defaultLocale=${JSON.stringify(options.defaultLocale)} />
|
|
91
|
+
</Base>
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
const localizedPaths = `import type { LocalizedPathGroup } from '@easy-web/core/i18n';
|
|
95
|
+
|
|
96
|
+
export const localizedPaths: readonly LocalizedPathGroup[] = [];
|
|
97
|
+
`;
|
|
98
|
+
const robotsTxt = `Disallow: /admin/
|
|
99
|
+
Sitemap: ${PLACEHOLDER_SITE_URL}/sitemap-index.xml
|
|
100
|
+
`;
|
|
101
|
+
const gitignore = `node_modules
|
|
102
|
+
dist
|
|
103
|
+
.astro
|
|
104
|
+
`;
|
|
105
|
+
export function buildShellFiles(rawOptions) {
|
|
106
|
+
const options = shellOptionsSchema.parse(rawOptions ?? {});
|
|
107
|
+
return [
|
|
108
|
+
{ path: 'astro.config.mjs', content: astroConfig(options) },
|
|
109
|
+
{ path: 'package.json', content: packageJsonFragment },
|
|
110
|
+
{ path: 'pnpm-workspace.yaml', content: pnpmWorkspace },
|
|
111
|
+
{ path: 'src/layouts/Base.astro', content: baseLayout(options) },
|
|
112
|
+
{ path: 'src/pages/index.astro', content: homePage(options) },
|
|
113
|
+
{ path: 'src/pages/404.astro', content: notFoundPage(options) },
|
|
114
|
+
{ path: 'src/lib/localized-paths.ts', content: localizedPaths },
|
|
115
|
+
{ path: 'public/robots.txt', content: robotsTxt },
|
|
116
|
+
{ path: '.gitignore', content: gitignore },
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
export const shellRecipe = {
|
|
120
|
+
id: SHELL_RECIPE_ID,
|
|
121
|
+
version: '1.5.0',
|
|
122
|
+
protocolVersion: 1,
|
|
123
|
+
compatibleCliRange: '^0.1.0',
|
|
124
|
+
compatibleRuntimeRange: '^1.5.0',
|
|
125
|
+
provides: [SHELL_RECIPE_ID],
|
|
126
|
+
requires: [],
|
|
127
|
+
conflicts: [],
|
|
128
|
+
order: { priority: 0, key: 'shell' },
|
|
129
|
+
optionsSchema: shellOptionsSchema,
|
|
130
|
+
outputContributions: [
|
|
131
|
+
{ kind: 'configuration', id: 'shell.astro-config', target: 'astro.config.mjs' },
|
|
132
|
+
{ kind: 'dependency', id: 'shell.dependencies', target: 'package.json' },
|
|
133
|
+
{ kind: 'configuration', id: 'shell.pnpm-workspace', target: 'pnpm-workspace.yaml' },
|
|
134
|
+
{ kind: 'file', id: 'shell.base-layout', target: 'src/layouts/Base.astro' },
|
|
135
|
+
{ kind: 'route', id: 'shell.home', target: '/' },
|
|
136
|
+
{ kind: 'route', id: 'shell.404', target: '/404' },
|
|
137
|
+
{ kind: 'file', id: 'shell.localized-paths', target: 'src/lib/localized-paths.ts' },
|
|
138
|
+
{ kind: 'file', id: 'shell.robots', target: 'public/robots.txt' },
|
|
139
|
+
{ kind: 'file', id: 'shell.gitignore', target: '.gitignore' },
|
|
140
|
+
],
|
|
141
|
+
validators: [],
|
|
142
|
+
generate: (context) => ({ files: buildShellFiles(context.options) }),
|
|
143
|
+
};
|
|
144
|
+
export default shellRecipe;
|
|
145
|
+
//# sourceMappingURL=shell-recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-recipe.js","sourceRoot":"","sources":["../../src/recipes/shell-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAG9B,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,kBAAkB,GAAG,CAAC,CAAC,YAAY,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IACnD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACtC,CAAC,CAAC;AAIH,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AAExE,SAAS,WAAW,CAAC,OAA2B;IAC5C,OAAO;;;;UAID,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;;4BAElB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;;;CAG7D,CAAC;AACF,CAAC;AAED,MAAM,mBAAm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AE,eAAe,EAAE,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,qBAAqB,EAAE;QACpF,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,wBAAwB,EAAE;QAC3E,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE;QAChD,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;QAClD,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,uBAAuB,EAAE,MAAM,EAAE,4BAA4B,EAAE;QACnF,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE;QACjE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE;KAChE;IACD,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,CAAC,OAA8B,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;CACjD,CAAC;AAE/C,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { recipeValidatorDescriptorSchema } from './schema.js';
|
|
3
|
+
import type { RecipeOutputContribution } from './schema.js';
|
|
4
|
+
export interface RecipeGeneratedFile {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly content: string | Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
/** Hooks return output data; they receive no filesystem/process/target-node_modules access. */
|
|
9
|
+
export interface RecipeGenerationContext<Options = unknown> {
|
|
10
|
+
readonly options: Options;
|
|
11
|
+
readonly capabilities: readonly string[];
|
|
12
|
+
readonly contributions: readonly RecipeOutputContribution[];
|
|
13
|
+
}
|
|
14
|
+
export interface RecipeGenerationOutput {
|
|
15
|
+
readonly files: readonly RecipeGeneratedFile[];
|
|
16
|
+
}
|
|
17
|
+
export type RecipeGenerateHook<Options = unknown> = (context: RecipeGenerationContext<Options>) => RecipeGenerationOutput | Promise<RecipeGenerationOutput>;
|
|
18
|
+
export interface RecipeValidationContext<Options = unknown> extends RecipeGenerationContext<Options> {
|
|
19
|
+
readonly output?: RecipeGenerationOutput;
|
|
20
|
+
}
|
|
21
|
+
export interface RecipeValidationIssue {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly path?: string;
|
|
25
|
+
}
|
|
26
|
+
export type RecipeValidateHook<Options = unknown> = (context: RecipeValidationContext<Options>) => readonly RecipeValidationIssue[] | Promise<readonly RecipeValidationIssue[]>;
|
|
27
|
+
/** Shape admission never calls options parsing, validators or generation hooks. */
|
|
28
|
+
export declare const recipeMetadataSchema: z.ZodReadonly<z.ZodObject<{
|
|
29
|
+
optionsSchema: z.ZodInstanceOf<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
30
|
+
validators: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
phase: z.ZodEnum<{
|
|
33
|
+
output: "output";
|
|
34
|
+
options: "options";
|
|
35
|
+
}>;
|
|
36
|
+
validate: z.ZodCustom<RecipeValidateHook<unknown>, RecipeValidateHook<unknown>>;
|
|
37
|
+
}, z.core.$strict>>>>;
|
|
38
|
+
generate: z.ZodCustom<RecipeGenerateHook<unknown>, RecipeGenerateHook<unknown>>;
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
version: z.ZodString;
|
|
41
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
42
|
+
compatibleCliRange: z.ZodString;
|
|
43
|
+
compatibleRuntimeRange: z.ZodString;
|
|
44
|
+
provides: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
45
|
+
requires: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
46
|
+
conflicts: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
47
|
+
order: z.ZodReadonly<z.ZodObject<{
|
|
48
|
+
priority: z.ZodNumber;
|
|
49
|
+
key: z.ZodString;
|
|
50
|
+
}, z.core.$strict>>;
|
|
51
|
+
outputContributions: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
52
|
+
kind: z.ZodEnum<{
|
|
53
|
+
file: "file";
|
|
54
|
+
dependency: "dependency";
|
|
55
|
+
route: "route";
|
|
56
|
+
content: "content";
|
|
57
|
+
binding: "binding";
|
|
58
|
+
configuration: "configuration";
|
|
59
|
+
}>;
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
target: z.ZodString;
|
|
62
|
+
}, z.core.$strict>>>>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
/** Typed recipe implementations can use their own inferred Zod options. */
|
|
65
|
+
export type RecipeMetadata<Options = unknown> = Omit<z.infer<typeof recipeMetadataSchema>, 'optionsSchema' | 'generate' | 'validators'> & {
|
|
66
|
+
readonly optionsSchema: z.ZodType<Options>;
|
|
67
|
+
readonly generate: RecipeGenerateHook<Options>;
|
|
68
|
+
readonly validators: readonly (z.infer<typeof recipeValidatorDescriptorSchema> & {
|
|
69
|
+
readonly validate: RecipeValidateHook<Options>;
|
|
70
|
+
})[];
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/recipes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EAEH,+BAA+B,EAClC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC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,OAAO,oBAAoB,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,YAAY,CACpF,GAAG;IACA,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,GAAG;QAC7E,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;KAClD,CAAC,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { recipeMetadataFields, recipeValidatorDescriptorSchema, } from './schema.js';
|
|
3
|
+
const validatorSchema = recipeValidatorDescriptorSchema.unwrap().extend({
|
|
4
|
+
validate: z.custom((value) => typeof value === 'function'),
|
|
5
|
+
}).readonly();
|
|
6
|
+
/** Shape admission never calls options parsing, validators or generation hooks. */
|
|
7
|
+
export const recipeMetadataSchema = z.strictObject({
|
|
8
|
+
...recipeMetadataFields,
|
|
9
|
+
optionsSchema: z.instanceof(z.ZodType),
|
|
10
|
+
validators: z.array(validatorSchema).readonly(),
|
|
11
|
+
generate: z.custom((value) => typeof value === 'function'),
|
|
12
|
+
}).readonly();
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/recipes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAC9B,OAAO,EACH,oBAAoB,EACpB,+BAA+B,GAClC,MAAM,aAAa,CAAC;AAqCrB,MAAM,eAAe,GAAG,+BAA+B,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC;IACpE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC;CACjF,CAAC,CAAC,QAAQ,EAAE,CAAC;AAEd,mFAAmF;AACnF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC/C,GAAG,oBAAoB;IACvB,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IAC/C,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC;CACjF,CAAC,CAAC,QAAQ,EAAE,CAAC"}
|
|
@@ -63,10 +63,10 @@ declare const galleryHeroSliderSchema: z.ZodObject<{
|
|
|
63
63
|
autoplay: z.ZodDefault<z.ZodBoolean>;
|
|
64
64
|
interval: z.ZodDefault<z.ZodNumber>;
|
|
65
65
|
height: z.ZodDefault<z.ZodEnum<{
|
|
66
|
+
full: "full";
|
|
66
67
|
sm: "sm";
|
|
67
68
|
md: "md";
|
|
68
69
|
lg: "lg";
|
|
69
|
-
full: "full";
|
|
70
70
|
}>>;
|
|
71
71
|
slides: z.ZodArray<z.ZodObject<{
|
|
72
72
|
src: z.ZodString;
|
|
@@ -205,10 +205,10 @@ export declare const gallerySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
205
205
|
autoplay: z.ZodDefault<z.ZodBoolean>;
|
|
206
206
|
interval: z.ZodDefault<z.ZodNumber>;
|
|
207
207
|
height: z.ZodDefault<z.ZodEnum<{
|
|
208
|
+
full: "full";
|
|
208
209
|
sm: "sm";
|
|
209
210
|
md: "md";
|
|
210
211
|
lg: "lg";
|
|
211
|
-
full: "full";
|
|
212
212
|
}>>;
|
|
213
213
|
slides: z.ZodArray<z.ZodObject<{
|
|
214
214
|
src: z.ZodString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-web/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,6 +11,22 @@
|
|
|
11
11
|
"types": "./dist/contracts/index.d.ts",
|
|
12
12
|
"import": "./dist/contracts/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./recipes": {
|
|
15
|
+
"types": "./dist/recipes/index.d.ts",
|
|
16
|
+
"import": "./dist/recipes/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./recipes/schema": {
|
|
19
|
+
"types": "./dist/recipes/schema.d.ts",
|
|
20
|
+
"import": "./dist/recipes/schema.js"
|
|
21
|
+
},
|
|
22
|
+
"./recipes/registry": {
|
|
23
|
+
"types": "./dist/recipes/registry.d.ts",
|
|
24
|
+
"import": "./dist/recipes/registry.js"
|
|
25
|
+
},
|
|
26
|
+
"./demo": {
|
|
27
|
+
"types": "./dist/demo/index.d.ts",
|
|
28
|
+
"import": "./dist/demo/index.js"
|
|
29
|
+
},
|
|
14
30
|
"./theme": {
|
|
15
31
|
"types": "./dist/theme/index.d.ts",
|
|
16
32
|
"import": "./dist/theme/index.js"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DemoLegalShell - sample legal/privacy page shell with a prominent disclaimer.
|
|
4
|
+
* Reuses LegalLayout. Structural placeholder only, never legal advice.
|
|
5
|
+
*/
|
|
6
|
+
import LegalLayout from './LegalLayout.astro';
|
|
7
|
+
import type { DemoLegalShell } from '../demo/legal-shells.js';
|
|
8
|
+
|
|
9
|
+
export interface Props {
|
|
10
|
+
shell: DemoLegalShell;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { shell } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<LegalLayout title={shell.title}>
|
|
17
|
+
<div class="ew-demo-disclaimer" role="alert" data-demo-disclaimer>
|
|
18
|
+
<strong>{shell.disclaimer}</strong>
|
|
19
|
+
</div>
|
|
20
|
+
{shell.sections.map((s) => (
|
|
21
|
+
<section>
|
|
22
|
+
<h2>{s.heading}</h2>
|
|
23
|
+
<p>{s.body}</p>
|
|
24
|
+
</section>
|
|
25
|
+
))}
|
|
26
|
+
</LegalLayout>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.ew-demo-disclaimer {
|
|
30
|
+
border: 3px solid var(--ew-danger, #b00020);
|
|
31
|
+
background: var(--ew-surface, #fff);
|
|
32
|
+
padding: var(--ew-space-4, 1rem);
|
|
33
|
+
margin: 0 0 var(--ew-space-6, 2rem);
|
|
34
|
+
text-align: center;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
composeContentTraitSchema,
|
|
4
|
+
contentCompositionSchema,
|
|
5
|
+
contentTypeDefinitionSchema,
|
|
6
|
+
moneyTraitSchema,
|
|
7
|
+
presentationBindings,
|
|
8
|
+
} from '../index.js';
|
|
9
|
+
|
|
10
|
+
const localization = {
|
|
11
|
+
contentLocales: ['de', 'en'],
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
const genericTypes = [
|
|
15
|
+
{
|
|
16
|
+
name: 'configured product',
|
|
17
|
+
definition: {
|
|
18
|
+
id: 'catalog-item',
|
|
19
|
+
primary: true,
|
|
20
|
+
labels: { de: 'Produkte', en: 'Products' },
|
|
21
|
+
routes: { de: '/produkte/', en: '/en/products/' },
|
|
22
|
+
traits: ['title', 'slug', 'summary', 'body', 'image', 'cta', 'money', 'featured'],
|
|
23
|
+
bindings: ['homepage', 'list', 'detail', 'navigation', 'cms-admin'],
|
|
24
|
+
currency: 'EUR',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'scheduled event',
|
|
29
|
+
definition: {
|
|
30
|
+
id: 'scheduled-event',
|
|
31
|
+
labels: { de: 'Termine', en: 'Events' },
|
|
32
|
+
routes: { de: '/termine/', en: '/en/events/' },
|
|
33
|
+
traits: ['title', 'slug', 'summary', 'body', 'schedule', 'location'],
|
|
34
|
+
bindings: ['list', 'detail', 'navigation', 'cms-admin'],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'gallery item',
|
|
39
|
+
definition: {
|
|
40
|
+
id: 'gallery-item',
|
|
41
|
+
labels: { de: 'Galerie', en: 'Gallery' },
|
|
42
|
+
routes: { de: '/galerie/', en: '/en/gallery/' },
|
|
43
|
+
traits: ['title', 'slug', 'image', 'photos'],
|
|
44
|
+
bindings: ['list', 'navigation', 'cms-admin'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
describe('content composition contracts', () => {
|
|
50
|
+
it.each(genericTypes)('accepts a valid $name', ({ definition }) => {
|
|
51
|
+
// Given / When
|
|
52
|
+
const result = contentCompositionSchema.safeParse({ ...localization, contentTypes: [definition] });
|
|
53
|
+
|
|
54
|
+
// Then
|
|
55
|
+
expect(result.success).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('keeps the presentation binding set closed', () => {
|
|
59
|
+
// Given / When
|
|
60
|
+
const result = contentTypeDefinitionSchema.safeParse({
|
|
61
|
+
...genericTypes[2].definition,
|
|
62
|
+
bindings: ['search'],
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Then
|
|
66
|
+
expect(presentationBindings).toEqual(['homepage', 'list', 'detail', 'navigation', 'cms-admin']);
|
|
67
|
+
expect(result.success).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('rejects a detail binding when the body trait is missing', () => {
|
|
71
|
+
// Given
|
|
72
|
+
const definition = { ...genericTypes[2].definition, bindings: ['detail'] };
|
|
73
|
+
|
|
74
|
+
// When
|
|
75
|
+
const result = contentCompositionSchema.safeParse({ ...localization, contentTypes: [definition] });
|
|
76
|
+
|
|
77
|
+
// Then
|
|
78
|
+
expect(result.error?.issues[0]?.message).toContain('Binding "detail" requires trait(s): body');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('rejects a second primary content type', () => {
|
|
82
|
+
// Given
|
|
83
|
+
const definitions = genericTypes.slice(0, 2).map(({ definition }) => ({ ...definition, primary: true }));
|
|
84
|
+
|
|
85
|
+
// When
|
|
86
|
+
const result = contentCompositionSchema.safeParse({ ...localization, contentTypes: definitions });
|
|
87
|
+
|
|
88
|
+
// Then
|
|
89
|
+
expect(result.error?.issues.some((issue) => issue.message.includes('Only one primary content type'))).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('rejects a reserved content route', () => {
|
|
93
|
+
// Given
|
|
94
|
+
const definition = { ...genericTypes[2].definition, routes: { de: '/admin/', en: '/en/gallery/' } };
|
|
95
|
+
|
|
96
|
+
// When
|
|
97
|
+
const result = contentCompositionSchema.safeParse({ ...localization, contentTypes: [definition] });
|
|
98
|
+
|
|
99
|
+
// Then
|
|
100
|
+
expect(result.error?.issues.some((issue) => issue.message.includes('Route "/admin/" is reserved'))).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('rejects homepage binding without the featured trait', () => {
|
|
104
|
+
// Given
|
|
105
|
+
const definition = { ...genericTypes[2].definition, bindings: ['homepage'] };
|
|
106
|
+
|
|
107
|
+
// When
|
|
108
|
+
const result = contentCompositionSchema.safeParse({ ...localization, contentTypes: [definition] });
|
|
109
|
+
|
|
110
|
+
// Then
|
|
111
|
+
expect(result.error?.issues.some((issue) => issue.message.includes('featured'))).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it.each([
|
|
115
|
+
['duplicate content type ID', { contentTypes: [genericTypes[1].definition, genericTypes[1].definition] }, 'Duplicate content type ID'],
|
|
116
|
+
['missing localized label', { contentTypes: [{ ...genericTypes[1].definition, labels: { de: 'Termine' } }] }, 'Missing configured locale(s): en'],
|
|
117
|
+
['colliding content route', {
|
|
118
|
+
contentTypes: [genericTypes[1].definition, { ...genericTypes[2].definition, routes: genericTypes[1].definition.routes }],
|
|
119
|
+
}, 'collides with content type'],
|
|
120
|
+
] as const)('rejects %s', (_name, input, message) => {
|
|
121
|
+
// Given / When
|
|
122
|
+
const result = contentCompositionSchema.safeParse({ ...localization, ...input });
|
|
123
|
+
|
|
124
|
+
// Then
|
|
125
|
+
expect(result.error?.issues.some((issue) => issue.message.includes(message))).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('requires currency only on money-enabled content selections', () => {
|
|
129
|
+
// Given / When
|
|
130
|
+
const missingMoneyCurrency = contentTypeDefinitionSchema.safeParse({
|
|
131
|
+
...genericTypes[0].definition,
|
|
132
|
+
currency: undefined,
|
|
133
|
+
});
|
|
134
|
+
const currencyOnNonMoney = contentTypeDefinitionSchema.safeParse({
|
|
135
|
+
...genericTypes[2].definition,
|
|
136
|
+
currency: 'EUR',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Then
|
|
140
|
+
expect(missingMoneyCurrency.success).toBe(true);
|
|
141
|
+
expect(currencyOnNonMoney.success).toBe(false);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('content trait data schemas', () => {
|
|
146
|
+
it('composes selected trait shapes without allowing unselected fields', () => {
|
|
147
|
+
// Given
|
|
148
|
+
const schema = composeContentTraitSchema(['title', 'slug']);
|
|
149
|
+
|
|
150
|
+
// When
|
|
151
|
+
const selected = schema.safeParse({ title: 'Example', slug: 'example' });
|
|
152
|
+
const unselected = schema.safeParse({ title: 'Example', slug: 'example', currency: 'EUR' });
|
|
153
|
+
|
|
154
|
+
// Then
|
|
155
|
+
expect(selected.success).toBe(true);
|
|
156
|
+
expect(unselected.success).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it.each([
|
|
160
|
+
['EUR', true],
|
|
161
|
+
['usd', false],
|
|
162
|
+
['ZZZ', false],
|
|
163
|
+
] as const)('validates money currency %s', (currency, expected) => {
|
|
164
|
+
// Given / When
|
|
165
|
+
const result = moneyTraitSchema.safeParse({ amount: 25, currency });
|
|
166
|
+
|
|
167
|
+
// Then
|
|
168
|
+
expect(result.success).toBe(expected);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -1,6 +1,20 @@
|
|
|
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';
|
|
3
5
|
|
|
6
|
+
export interface HasTitle {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HasSlug {
|
|
11
|
+
readonly slug: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface HasSummary {
|
|
15
|
+
readonly summary: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
export interface HasImage {
|
|
5
19
|
image: Image;
|
|
6
20
|
}
|
|
@@ -9,6 +23,41 @@ export interface HasPhotos {
|
|
|
9
23
|
photos: Image[];
|
|
10
24
|
}
|
|
11
25
|
|
|
26
|
+
export interface HasOrder {
|
|
27
|
+
readonly order: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface HasTaxonomy {
|
|
31
|
+
readonly taxonomy: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HasPublication {
|
|
35
|
+
readonly publishDate: Date;
|
|
36
|
+
readonly modifiedDate?: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface HasSchedule {
|
|
40
|
+
readonly startDate: Date;
|
|
41
|
+
readonly endDate?: Date;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface HasLocation {
|
|
45
|
+
readonly location: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface HasCta {
|
|
49
|
+
readonly cta: Link;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface HasMoney {
|
|
53
|
+
readonly amount: number;
|
|
54
|
+
readonly currency: CurrencyCode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface HasFeatured {
|
|
58
|
+
readonly featured: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
12
61
|
export type RenderedContent = AstroComponentFactory;
|
|
13
62
|
|
|
14
63
|
export interface HasBody {
|