@easy-web/core 1.4.1 → 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 @@
|
|
|
1
|
+
{"version":3,"file":"locale-inputs.d.ts","sourceRoot":"","sources":["../../src/i18n/locale-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AA8C7B,eAAO,MAAM,iBAAiB;;;EAAuB,CAAA;AACrD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC3D,eAAO,MAAM,mBAAmB,yDAA8F,CAAA;AAC9H,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC/D,eAAO,MAAM,kBAAkB,wDAA4G,CAAA;AAC3I,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,eAAO,MAAM,kBAAkB,wDAAiF,CAAA;AAChH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAG7D,eAAO,MAAM,kBAAkB,wDAGN,CAAA;AACzB,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,eAAO,MAAM,0BAA0B,uEAAgC,CAAA;AAEvE,+FAA+F;AAC/F,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAQpF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
// RFC 5646 language tags, including private-use and grandfathered tags.
|
|
3
|
+
const languageTag = /^(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})(?:-[a-z]{4})?(?:-[a-z]{2}|-\d{3})?(?:-(?:[a-z\d]{5,8}|\d[a-z\d]{3}))*(?:-[a-wy-z\d](?:-[a-z\d]{2,8})+)*(?:-x(?:-[a-z\d]{1,8})+)?$|^x(?:-[a-z\d]{1,8})+$|^(?:en-GB-oed|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)|sgn-(?:BE-FR|BE-NL|CH-DE)|art-lojban|cel-gaulish|no-bok|no-nyn|zh-(?:guoyu|hakka|min|min-nan|xiang))$/i;
|
|
4
|
+
function isContentLocale(value) {
|
|
5
|
+
if (!languageTag.test(value))
|
|
6
|
+
return false;
|
|
7
|
+
const segments = value.toLowerCase().split('-');
|
|
8
|
+
if (segments[0] === 'x' || /^(i-|sgn-|en-gb-oed$)/.test(value.toLowerCase()))
|
|
9
|
+
return true;
|
|
10
|
+
const extensions = new Set();
|
|
11
|
+
const variants = new Set();
|
|
12
|
+
for (const segment of segments.slice(1)) {
|
|
13
|
+
if (segment === 'x')
|
|
14
|
+
break;
|
|
15
|
+
if (segment.length === 1) {
|
|
16
|
+
if (extensions.has(segment))
|
|
17
|
+
return false;
|
|
18
|
+
extensions.add(segment);
|
|
19
|
+
}
|
|
20
|
+
else if (extensions.size === 0 && /^(?:[a-z\d]{5,8}|\d[a-z\d]{3})$/.test(segment)) {
|
|
21
|
+
if (variants.has(segment))
|
|
22
|
+
return false;
|
|
23
|
+
variants.add(segment);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
function supportsFormatLocale(value) {
|
|
29
|
+
try {
|
|
30
|
+
return Intl.DateTimeFormat.supportedLocalesOf(value, { localeMatcher: 'lookup' }).length === 1
|
|
31
|
+
&& Intl.NumberFormat.supportedLocalesOf(value, { localeMatcher: 'lookup' }).length === 1;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof RangeError)
|
|
35
|
+
return false;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isTimeZone(value) {
|
|
40
|
+
// Intl also accepts numeric offsets; the create contract accepts named IANA zones only.
|
|
41
|
+
if (!/^[A-Za-z][A-Za-z\d._+-]*(?:\/[A-Za-z\d._+-]+)*$/.test(value))
|
|
42
|
+
return false;
|
|
43
|
+
try {
|
|
44
|
+
new Intl.DateTimeFormat('en', { timeZone: value });
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof RangeError)
|
|
49
|
+
return false;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export const cliUiLocaleSchema = z.enum(['en', 'de']);
|
|
54
|
+
export const contentLocaleSchema = z.string().refine(isContentLocale, 'Invalid BCP47 content locale').brand();
|
|
55
|
+
export const formatLocaleSchema = z.string().refine(supportsFormatLocale, 'Unsupported or malformed format locale').brand();
|
|
56
|
+
export const ianaTimeZoneSchema = z.string().refine(isTimeZone, 'Invalid IANA timezone').brand();
|
|
57
|
+
// Intl accepts any three-letter code, so check its ISO 4217 catalog as well as shape.
|
|
58
|
+
export const currencyCodeSchema = z.string().regex(/^[A-Z]{3}$/).refine((value) => Intl.supportedValuesOf('currency').includes(value), 'Unsupported ISO 4217 currency').brand();
|
|
59
|
+
export const optionalCurrencyCodeSchema = currencyCodeSchema.optional();
|
|
60
|
+
/** Only auto-detected interview languages fall back; explicit input uses cliUiLocaleSchema. */
|
|
61
|
+
export function resolveDetectedCliUiLocale(detected) {
|
|
62
|
+
if (detected === undefined)
|
|
63
|
+
return 'en';
|
|
64
|
+
try {
|
|
65
|
+
return new Intl.Locale(detected).language === 'de' ? 'de' : 'en';
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof RangeError)
|
|
69
|
+
return 'en';
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=locale-inputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-inputs.js","sourceRoot":"","sources":["../../src/i18n/locale-inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAE7B,wEAAwE;AACxE,MAAM,WAAW,GAAG,gZAAgZ,CAAA;AAEpa,SAAS,eAAe,CAAC,KAAa;IAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,WA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C,KAAK,EAAkB,CAAA;AAEzB,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAA;AAEvE,+FAA+F;AAC/F,MAAM,UAAU,0BAA0B,CAAC,QAA4B;IACnE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACvC,IAAI,CAAC;QACD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAI,KAAK,YAAY,UAAU;YAAE,OAAO,IAAI,CAAA;QAC5C,MAAM,KAAK,CAAA;IACf,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
export interface RecipeCompatibilityPolicy {
|
|
3
|
+
readonly cliVersion: string;
|
|
4
|
+
readonly runtimeVersion: string;
|
|
5
|
+
/** Return false for invalid semver ranges as well as out-of-range versions. */
|
|
6
|
+
readonly satisfies: (version: string, range: string) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const recipeAdmissionInputSchema: z.ZodReadonly<z.ZodObject<{
|
|
9
|
+
registry: z.ZodReadonly<z.ZodObject<{
|
|
10
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
11
|
+
recipes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
12
|
+
packageName: z.ZodEnum<{
|
|
13
|
+
"@easy-web/core": "@easy-web/core";
|
|
14
|
+
"@easy-web/cms-adapters": "@easy-web/cms-adapters";
|
|
15
|
+
"@easy-web/swa": "@easy-web/swa";
|
|
16
|
+
"@easy-web/auth": "@easy-web/auth";
|
|
17
|
+
"@easy-web/brand": "@easy-web/brand";
|
|
18
|
+
}>;
|
|
19
|
+
version: z.ZodString;
|
|
20
|
+
integrity: z.ZodString;
|
|
21
|
+
exportPath: z.ZodString;
|
|
22
|
+
}, z.core.$strict>>>>;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
artifacts: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
25
|
+
receipt: z.ZodReadonly<z.ZodObject<{
|
|
26
|
+
source: z.ZodEnum<{
|
|
27
|
+
"cli-pinned": "cli-pinned";
|
|
28
|
+
bundled: "bundled";
|
|
29
|
+
}>;
|
|
30
|
+
pin: z.ZodReadonly<z.ZodObject<{
|
|
31
|
+
packageName: z.ZodEnum<{
|
|
32
|
+
"@easy-web/core": "@easy-web/core";
|
|
33
|
+
"@easy-web/cms-adapters": "@easy-web/cms-adapters";
|
|
34
|
+
"@easy-web/swa": "@easy-web/swa";
|
|
35
|
+
"@easy-web/auth": "@easy-web/auth";
|
|
36
|
+
"@easy-web/brand": "@easy-web/brand";
|
|
37
|
+
}>;
|
|
38
|
+
version: z.ZodString;
|
|
39
|
+
integrity: z.ZodString;
|
|
40
|
+
exportPath: z.ZodString;
|
|
41
|
+
}, z.core.$strict>>;
|
|
42
|
+
verifiedIntegrity: z.ZodString;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
recipe: z.ZodReadonly<z.ZodObject<{
|
|
45
|
+
optionsSchema: z.ZodInstanceOf<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
46
|
+
validators: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
phase: z.ZodEnum<{
|
|
49
|
+
output: "output";
|
|
50
|
+
options: "options";
|
|
51
|
+
}>;
|
|
52
|
+
validate: z.ZodCustom<import("./types.js").RecipeValidateHook<unknown>, import("./types.js").RecipeValidateHook<unknown>>;
|
|
53
|
+
}, z.core.$strict>>>>;
|
|
54
|
+
generate: z.ZodCustom<import("./types.js").RecipeGenerateHook<unknown>, import("./types.js").RecipeGenerateHook<unknown>>;
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
version: z.ZodString;
|
|
57
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
58
|
+
compatibleCliRange: z.ZodString;
|
|
59
|
+
compatibleRuntimeRange: z.ZodString;
|
|
60
|
+
provides: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
61
|
+
requires: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
62
|
+
conflicts: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
63
|
+
order: z.ZodReadonly<z.ZodObject<{
|
|
64
|
+
priority: z.ZodNumber;
|
|
65
|
+
key: z.ZodString;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
outputContributions: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
68
|
+
kind: z.ZodEnum<{
|
|
69
|
+
file: "file";
|
|
70
|
+
dependency: "dependency";
|
|
71
|
+
route: "route";
|
|
72
|
+
content: "content";
|
|
73
|
+
binding: "binding";
|
|
74
|
+
configuration: "configuration";
|
|
75
|
+
}>;
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
target: z.ZodString;
|
|
78
|
+
}, z.core.$strict>>>>;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
}, z.core.$strict>>>>;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
/**
|
|
83
|
+
* Pure admission only: checks an explicitly selected set, never selects dependencies,
|
|
84
|
+
* sorts recipes, emits a capability graph, imports sources or invokes any hook.
|
|
85
|
+
* Receipts cannot prove byte integrity: the trusted loader must hash BEFORE import.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createRecipeAdmissionSchema(policy: RecipeCompatibilityPolicy): z.ZodReadonly<z.ZodObject<{
|
|
88
|
+
registry: z.ZodReadonly<z.ZodObject<{
|
|
89
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
90
|
+
recipes: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
91
|
+
packageName: z.ZodEnum<{
|
|
92
|
+
"@easy-web/core": "@easy-web/core";
|
|
93
|
+
"@easy-web/cms-adapters": "@easy-web/cms-adapters";
|
|
94
|
+
"@easy-web/swa": "@easy-web/swa";
|
|
95
|
+
"@easy-web/auth": "@easy-web/auth";
|
|
96
|
+
"@easy-web/brand": "@easy-web/brand";
|
|
97
|
+
}>;
|
|
98
|
+
version: z.ZodString;
|
|
99
|
+
integrity: z.ZodString;
|
|
100
|
+
exportPath: z.ZodString;
|
|
101
|
+
}, z.core.$strict>>>>;
|
|
102
|
+
}, z.core.$strict>>;
|
|
103
|
+
artifacts: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
104
|
+
receipt: z.ZodReadonly<z.ZodObject<{
|
|
105
|
+
source: z.ZodEnum<{
|
|
106
|
+
"cli-pinned": "cli-pinned";
|
|
107
|
+
bundled: "bundled";
|
|
108
|
+
}>;
|
|
109
|
+
pin: z.ZodReadonly<z.ZodObject<{
|
|
110
|
+
packageName: z.ZodEnum<{
|
|
111
|
+
"@easy-web/core": "@easy-web/core";
|
|
112
|
+
"@easy-web/cms-adapters": "@easy-web/cms-adapters";
|
|
113
|
+
"@easy-web/swa": "@easy-web/swa";
|
|
114
|
+
"@easy-web/auth": "@easy-web/auth";
|
|
115
|
+
"@easy-web/brand": "@easy-web/brand";
|
|
116
|
+
}>;
|
|
117
|
+
version: z.ZodString;
|
|
118
|
+
integrity: z.ZodString;
|
|
119
|
+
exportPath: z.ZodString;
|
|
120
|
+
}, z.core.$strict>>;
|
|
121
|
+
verifiedIntegrity: z.ZodString;
|
|
122
|
+
}, z.core.$strict>>;
|
|
123
|
+
recipe: z.ZodReadonly<z.ZodObject<{
|
|
124
|
+
optionsSchema: z.ZodInstanceOf<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
125
|
+
validators: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
phase: z.ZodEnum<{
|
|
128
|
+
output: "output";
|
|
129
|
+
options: "options";
|
|
130
|
+
}>;
|
|
131
|
+
validate: z.ZodCustom<import("./types.js").RecipeValidateHook<unknown>, import("./types.js").RecipeValidateHook<unknown>>;
|
|
132
|
+
}, z.core.$strict>>>>;
|
|
133
|
+
generate: z.ZodCustom<import("./types.js").RecipeGenerateHook<unknown>, import("./types.js").RecipeGenerateHook<unknown>>;
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
version: z.ZodString;
|
|
136
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
137
|
+
compatibleCliRange: z.ZodString;
|
|
138
|
+
compatibleRuntimeRange: z.ZodString;
|
|
139
|
+
provides: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
140
|
+
requires: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
141
|
+
conflicts: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
142
|
+
order: z.ZodReadonly<z.ZodObject<{
|
|
143
|
+
priority: z.ZodNumber;
|
|
144
|
+
key: z.ZodString;
|
|
145
|
+
}, z.core.$strict>>;
|
|
146
|
+
outputContributions: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
147
|
+
kind: z.ZodEnum<{
|
|
148
|
+
file: "file";
|
|
149
|
+
dependency: "dependency";
|
|
150
|
+
route: "route";
|
|
151
|
+
content: "content";
|
|
152
|
+
binding: "binding";
|
|
153
|
+
configuration: "configuration";
|
|
154
|
+
}>;
|
|
155
|
+
id: z.ZodString;
|
|
156
|
+
target: z.ZodString;
|
|
157
|
+
}, z.core.$strict>>>>;
|
|
158
|
+
}, z.core.$strict>>;
|
|
159
|
+
}, z.core.$strict>>>>;
|
|
160
|
+
}, z.core.$strict>>;
|
|
161
|
+
//# sourceMappingURL=admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../src/recipes/admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAI9B,MAAM,WAAW,yBAAyB;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACnE;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAM1B,CAAC;AAEd;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAoD5E"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'astro/zod';
|
|
2
|
+
import { recipeArtifactReceiptSchema, recipeRegistryManifestSchema } from './registry.js';
|
|
3
|
+
import { recipeMetadataSchema } from './types.js';
|
|
4
|
+
export const recipeAdmissionInputSchema = z.strictObject({
|
|
5
|
+
registry: recipeRegistryManifestSchema,
|
|
6
|
+
artifacts: z.array(z.strictObject({
|
|
7
|
+
receipt: recipeArtifactReceiptSchema,
|
|
8
|
+
recipe: recipeMetadataSchema,
|
|
9
|
+
}).readonly()).readonly(),
|
|
10
|
+
}).readonly();
|
|
11
|
+
/**
|
|
12
|
+
* Pure admission only: checks an explicitly selected set, never selects dependencies,
|
|
13
|
+
* sorts recipes, emits a capability graph, imports sources or invokes any hook.
|
|
14
|
+
* Receipts cannot prove byte integrity: the trusted loader must hash BEFORE import.
|
|
15
|
+
*/
|
|
16
|
+
export function createRecipeAdmissionSchema(policy) {
|
|
17
|
+
return recipeAdmissionInputSchema.superRefine(({ registry, artifacts }, context) => {
|
|
18
|
+
const fail = (message, index) => context.addIssue({
|
|
19
|
+
code: 'custom', message, path: ['artifacts', index],
|
|
20
|
+
});
|
|
21
|
+
const providers = new Map();
|
|
22
|
+
const ids = new Set();
|
|
23
|
+
for (const [index, { recipe, receipt }] of artifacts.entries()) {
|
|
24
|
+
const pinned = registry.recipes.some((pin) => pin.packageName === receipt.pin.packageName && pin.version === receipt.pin.version &&
|
|
25
|
+
pin.integrity === receipt.pin.integrity && pin.exportPath === receipt.pin.exportPath);
|
|
26
|
+
if (!pinned)
|
|
27
|
+
fail('source-outside-pinned-set', index);
|
|
28
|
+
if (receipt.verifiedIntegrity !== receipt.pin.integrity)
|
|
29
|
+
fail('artifact-integrity-mismatch', index);
|
|
30
|
+
if (recipe.version !== receipt.pin.version)
|
|
31
|
+
fail('recipe-version-mismatch', index);
|
|
32
|
+
if (!policy.satisfies(policy.cliVersion, recipe.compatibleCliRange))
|
|
33
|
+
fail('incompatible-cli-range', index);
|
|
34
|
+
if (!policy.satisfies(policy.runtimeVersion, recipe.compatibleRuntimeRange))
|
|
35
|
+
fail('incompatible-runtime-range', index);
|
|
36
|
+
if (ids.has(recipe.id))
|
|
37
|
+
fail('duplicate-recipe-id', index);
|
|
38
|
+
ids.add(recipe.id);
|
|
39
|
+
for (const capability of recipe.provides) {
|
|
40
|
+
if (providers.has(capability))
|
|
41
|
+
fail('duplicate-provider-id', index);
|
|
42
|
+
providers.set(capability, index);
|
|
43
|
+
}
|
|
44
|
+
for (const field of ['requires', 'conflicts']) {
|
|
45
|
+
if (new Set(recipe[field]).size !== recipe[field].length)
|
|
46
|
+
fail(`duplicate-${field}`, index);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const [index, { recipe }] of artifacts.entries()) {
|
|
50
|
+
for (const requirement of recipe.requires) {
|
|
51
|
+
if (!providers.has(requirement))
|
|
52
|
+
fail('missing-requirement', index);
|
|
53
|
+
}
|
|
54
|
+
for (const conflict of recipe.conflicts) {
|
|
55
|
+
if (providers.has(conflict))
|
|
56
|
+
fail('conflicting-capability', index);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Reachability validation, not topological ordering or a graph resolver.
|
|
60
|
+
const complete = new Set();
|
|
61
|
+
const active = new Set();
|
|
62
|
+
const visit = (index) => {
|
|
63
|
+
if (active.has(index)) {
|
|
64
|
+
fail('dependency-cycle', index);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (complete.has(index))
|
|
68
|
+
return;
|
|
69
|
+
const artifact = artifacts[index];
|
|
70
|
+
if (!artifact)
|
|
71
|
+
return;
|
|
72
|
+
active.add(index);
|
|
73
|
+
for (const requirement of artifact.recipe.requires) {
|
|
74
|
+
const provider = providers.get(requirement);
|
|
75
|
+
if (provider !== undefined)
|
|
76
|
+
visit(provider);
|
|
77
|
+
}
|
|
78
|
+
active.delete(index);
|
|
79
|
+
complete.add(index);
|
|
80
|
+
};
|
|
81
|
+
for (const index of artifacts.keys())
|
|
82
|
+
visit(index);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
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AE,OAAO;YACtB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClB,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACjD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBAC5C,IAAI,QAAQ,KAAK,SAAS;oBAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChD,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE;YAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { RecipeOutputContribution } from './schema.js';
|
|
2
|
+
import type { RecipeMetadata } from './types.js';
|
|
3
|
+
export type GraphResult<T, E> = {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
readonly value: T;
|
|
6
|
+
} | {
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly error: E;
|
|
9
|
+
};
|
|
10
|
+
export type RecipeInclusion = {
|
|
11
|
+
readonly kind: 'direct';
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'transitive';
|
|
14
|
+
readonly requiredBy: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
export type GraphProvenance = {
|
|
17
|
+
readonly contributedBy: string;
|
|
18
|
+
readonly recipeVersion: string;
|
|
19
|
+
readonly inclusion: RecipeInclusion;
|
|
20
|
+
};
|
|
21
|
+
export type ResolvedRecipeNode = {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly version: string;
|
|
24
|
+
readonly provides: readonly string[];
|
|
25
|
+
readonly requires: readonly string[];
|
|
26
|
+
readonly conflicts: readonly string[];
|
|
27
|
+
readonly provenance: GraphProvenance;
|
|
28
|
+
};
|
|
29
|
+
export type ResolvedCapabilityNode = {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly providerRecipeId: string;
|
|
32
|
+
readonly provenance: GraphProvenance;
|
|
33
|
+
};
|
|
34
|
+
export type ResolvedRequirementEdge = {
|
|
35
|
+
readonly capability: string;
|
|
36
|
+
readonly consumerRecipeId: string;
|
|
37
|
+
readonly providerRecipeId: string;
|
|
38
|
+
};
|
|
39
|
+
export type ResolvedContributionNode = RecipeOutputContribution & {
|
|
40
|
+
readonly provenance: GraphProvenance;
|
|
41
|
+
};
|
|
42
|
+
export type ResolvedAdaptationNode = ResolvedContributionNode & {
|
|
43
|
+
readonly kind: 'binding';
|
|
44
|
+
readonly targetContributionId: string;
|
|
45
|
+
};
|
|
46
|
+
export type ResolvedCapabilityGraph = {
|
|
47
|
+
readonly recipes: readonly ResolvedRecipeNode[];
|
|
48
|
+
readonly capabilities: readonly ResolvedCapabilityNode[];
|
|
49
|
+
readonly requirements: readonly ResolvedRequirementEdge[];
|
|
50
|
+
readonly contributions: readonly ResolvedContributionNode[];
|
|
51
|
+
readonly fixedPages: readonly ResolvedContributionNode[];
|
|
52
|
+
readonly contentTypes: {
|
|
53
|
+
readonly primary?: ResolvedContributionNode;
|
|
54
|
+
readonly additional: readonly ResolvedContributionNode[];
|
|
55
|
+
};
|
|
56
|
+
readonly adaptations: readonly ResolvedAdaptationNode[];
|
|
57
|
+
};
|
|
58
|
+
export type GraphResolutionError = {
|
|
59
|
+
readonly code: 'duplicate-recipe-id';
|
|
60
|
+
readonly recipeId: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly code: 'duplicate-provider';
|
|
63
|
+
readonly capability: string;
|
|
64
|
+
readonly recipeIds: readonly string[];
|
|
65
|
+
} | {
|
|
66
|
+
readonly code: 'missing-requirement';
|
|
67
|
+
readonly recipeId: string;
|
|
68
|
+
readonly capability: string;
|
|
69
|
+
} | {
|
|
70
|
+
readonly code: 'dependency-cycle';
|
|
71
|
+
readonly recipeIds: readonly string[];
|
|
72
|
+
} | {
|
|
73
|
+
readonly code: 'conflicting-capability';
|
|
74
|
+
readonly recipeId: string;
|
|
75
|
+
readonly conflictingRecipeId: string;
|
|
76
|
+
readonly capability: string;
|
|
77
|
+
} | {
|
|
78
|
+
readonly code: 'duplicate-contribution-id';
|
|
79
|
+
readonly contributionId: string;
|
|
80
|
+
readonly recipeIds: readonly string[];
|
|
81
|
+
} | {
|
|
82
|
+
readonly code: 'output-conflict';
|
|
83
|
+
readonly kind: 'file' | 'route';
|
|
84
|
+
readonly target: string;
|
|
85
|
+
readonly recipeIds: readonly string[];
|
|
86
|
+
} | {
|
|
87
|
+
readonly code: 'invalid-content-role';
|
|
88
|
+
readonly contributionId: string;
|
|
89
|
+
readonly target: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly code: 'multiple-primary-content';
|
|
92
|
+
readonly contributionIds: readonly string[];
|
|
93
|
+
readonly recipeIds: readonly string[];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Resolves admitted in-memory recipe metadata without executing hooks or observing a target.
|
|
97
|
+
* Route contributions are fixed pages. Content targets are `primary` or `additional`.
|
|
98
|
+
* Binding ids prefixed with `adaptation.` activate only when their target contribution exists.
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveCapabilityGraph(recipes: readonly RecipeMetadata[]): GraphResult<ResolvedCapabilityGraph, GraphResolutionError>;
|
|
101
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/recipes/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IACtB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CA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order.priority - right.order.priority || compareText(left.order.key, right.order.key) || compareText(left.id, right.id);
|
|
3
|
+
const compareContribution = (left, right) => compareText(left.kind, right.kind) || compareText(left.id, right.id) || compareText(left.target, right.target) ||
|
|
4
|
+
compareText(left.provenance.contributedBy, right.provenance.contributedBy);
|
|
5
|
+
const failure = (error) => ({ ok: false, error });
|
|
6
|
+
/**
|
|
7
|
+
* Resolves admitted in-memory recipe metadata without executing hooks or observing a target.
|
|
8
|
+
* Route contributions are fixed pages. Content targets are `primary` or `additional`.
|
|
9
|
+
* Binding ids prefixed with `adaptation.` activate only when their target contribution exists.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveCapabilityGraph(recipes) {
|
|
12
|
+
const canonical = [...recipes].sort(compareRecipe);
|
|
13
|
+
const recipeById = new Map();
|
|
14
|
+
const providerByCapability = new Map();
|
|
15
|
+
for (const recipe of canonical) {
|
|
16
|
+
if (recipeById.has(recipe.id))
|
|
17
|
+
return failure({ code: 'duplicate-recipe-id', recipeId: recipe.id });
|
|
18
|
+
recipeById.set(recipe.id, recipe);
|
|
19
|
+
for (const capability of [...recipe.provides].sort(compareText)) {
|
|
20
|
+
const provider = providerByCapability.get(capability);
|
|
21
|
+
if (provider) {
|
|
22
|
+
return failure({
|
|
23
|
+
code: 'duplicate-provider', capability,
|
|
24
|
+
recipeIds: [provider.id, recipe.id].sort(compareText),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
providerByCapability.set(capability, recipe);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const requirements = [];
|
|
31
|
+
const dependencyIds = new Map();
|
|
32
|
+
const requiredBy = new Map();
|
|
33
|
+
for (const recipe of canonical) {
|
|
34
|
+
const dependencies = new Set();
|
|
35
|
+
for (const capability of [...recipe.requires].sort(compareText)) {
|
|
36
|
+
const provider = providerByCapability.get(capability);
|
|
37
|
+
if (!provider)
|
|
38
|
+
return failure({ code: 'missing-requirement', recipeId: recipe.id, capability });
|
|
39
|
+
dependencies.add(provider.id);
|
|
40
|
+
const consumers = requiredBy.get(provider.id) ?? new Set();
|
|
41
|
+
consumers.add(recipe.id);
|
|
42
|
+
requiredBy.set(provider.id, consumers);
|
|
43
|
+
requirements.push({ capability, consumerRecipeId: recipe.id, providerRecipeId: provider.id });
|
|
44
|
+
}
|
|
45
|
+
dependencyIds.set(recipe.id, dependencies);
|
|
46
|
+
}
|
|
47
|
+
const visiting = new Set();
|
|
48
|
+
const visited = new Set();
|
|
49
|
+
const stack = [];
|
|
50
|
+
const findCycle = (recipeId) => {
|
|
51
|
+
if (visiting.has(recipeId)) {
|
|
52
|
+
const start = stack.indexOf(recipeId);
|
|
53
|
+
return [...stack.slice(start), recipeId];
|
|
54
|
+
}
|
|
55
|
+
if (visited.has(recipeId))
|
|
56
|
+
return undefined;
|
|
57
|
+
visiting.add(recipeId);
|
|
58
|
+
stack.push(recipeId);
|
|
59
|
+
const dependencies = [...(dependencyIds.get(recipeId) ?? [])].sort(compareText);
|
|
60
|
+
for (const dependencyId of dependencies) {
|
|
61
|
+
const cycle = findCycle(dependencyId);
|
|
62
|
+
if (cycle)
|
|
63
|
+
return cycle;
|
|
64
|
+
}
|
|
65
|
+
stack.pop();
|
|
66
|
+
visiting.delete(recipeId);
|
|
67
|
+
visited.add(recipeId);
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
for (const recipe of canonical) {
|
|
71
|
+
const cycle = findCycle(recipe.id);
|
|
72
|
+
if (cycle)
|
|
73
|
+
return failure({ code: 'dependency-cycle', recipeIds: cycle });
|
|
74
|
+
}
|
|
75
|
+
for (const recipe of canonical) {
|
|
76
|
+
for (const capability of [...recipe.conflicts].sort(compareText)) {
|
|
77
|
+
const provider = providerByCapability.get(capability);
|
|
78
|
+
if (provider) {
|
|
79
|
+
return failure({
|
|
80
|
+
code: 'conflicting-capability', recipeId: recipe.id,
|
|
81
|
+
conflictingRecipeId: provider.id, capability,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const contributionOwners = new Map();
|
|
87
|
+
const outputOwners = new Map();
|
|
88
|
+
for (const recipe of canonical) {
|
|
89
|
+
for (const contribution of [...recipe.outputContributions].sort((left, right) => compareText(left.id, right.id))) {
|
|
90
|
+
const idOwner = contributionOwners.get(contribution.id);
|
|
91
|
+
if (idOwner) {
|
|
92
|
+
return failure({
|
|
93
|
+
code: 'duplicate-contribution-id', contributionId: contribution.id,
|
|
94
|
+
recipeIds: [idOwner.id, recipe.id].sort(compareText),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
contributionOwners.set(contribution.id, recipe);
|
|
98
|
+
if (contribution.kind === 'file' || contribution.kind === 'route') {
|
|
99
|
+
const key = `${contribution.kind}:${contribution.target}`;
|
|
100
|
+
const outputOwner = outputOwners.get(key);
|
|
101
|
+
if (outputOwner) {
|
|
102
|
+
return failure({
|
|
103
|
+
code: 'output-conflict', kind: contribution.kind, target: contribution.target,
|
|
104
|
+
recipeIds: [outputOwner.id, recipe.id].sort(compareText),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
outputOwners.set(key, recipe);
|
|
108
|
+
}
|
|
109
|
+
if (contribution.kind === 'content' && contribution.target !== 'primary' && contribution.target !== 'additional') {
|
|
110
|
+
return failure({ code: 'invalid-content-role', contributionId: contribution.id, target: contribution.target });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const ordered = [];
|
|
115
|
+
const remainingDependencies = new Map([...dependencyIds].map(([id, values]) => [id, new Set(values)]));
|
|
116
|
+
while (ordered.length < canonical.length) {
|
|
117
|
+
const ready = canonical.filter((recipe) => !ordered.some((item) => item.id === recipe.id) && remainingDependencies.get(recipe.id)?.size === 0);
|
|
118
|
+
const next = ready.sort(compareRecipe)[0];
|
|
119
|
+
if (!next)
|
|
120
|
+
break;
|
|
121
|
+
ordered.push(next);
|
|
122
|
+
for (const dependencies of remainingDependencies.values())
|
|
123
|
+
dependencies.delete(next.id);
|
|
124
|
+
}
|
|
125
|
+
const provenanceFor = (recipe) => {
|
|
126
|
+
const consumers = [...(requiredBy.get(recipe.id) ?? [])].sort(compareText);
|
|
127
|
+
return {
|
|
128
|
+
contributedBy: recipe.id,
|
|
129
|
+
recipeVersion: recipe.version,
|
|
130
|
+
inclusion: consumers.length === 0 ? { kind: 'direct' } : { kind: 'transitive', requiredBy: consumers },
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const contributions = ordered.flatMap((recipe) => recipe.outputContributions
|
|
134
|
+
.filter((item) => !item.id.startsWith('adaptation.') || contributionOwners.has(item.target))
|
|
135
|
+
.map((item) => ({ ...item, provenance: provenanceFor(recipe) })))
|
|
136
|
+
.sort(compareContribution);
|
|
137
|
+
const primary = contributions.filter((item) => item.kind === 'content' && item.target === 'primary');
|
|
138
|
+
if (primary.length > 1) {
|
|
139
|
+
return failure({
|
|
140
|
+
code: 'multiple-primary-content',
|
|
141
|
+
contributionIds: primary.map((item) => item.id).sort(compareText),
|
|
142
|
+
recipeIds: primary.map((item) => item.provenance.contributedBy).sort(compareText),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return { ok: true, value: {
|
|
146
|
+
recipes: ordered.map((recipe) => ({
|
|
147
|
+
id: recipe.id, version: recipe.version,
|
|
148
|
+
provides: [...recipe.provides].sort(compareText),
|
|
149
|
+
requires: [...recipe.requires].sort(compareText),
|
|
150
|
+
conflicts: [...recipe.conflicts].sort(compareText),
|
|
151
|
+
provenance: provenanceFor(recipe),
|
|
152
|
+
})),
|
|
153
|
+
capabilities: [...providerByCapability].sort(([left], [right]) => compareText(left, right))
|
|
154
|
+
.map(([id, provider]) => ({ id, providerRecipeId: provider.id, provenance: provenanceFor(provider) })),
|
|
155
|
+
requirements: requirements.sort((left, right) => compareText(left.consumerRecipeId, right.consumerRecipeId) || compareText(left.capability, right.capability)),
|
|
156
|
+
contributions,
|
|
157
|
+
fixedPages: contributions.filter((item) => item.kind === 'route'),
|
|
158
|
+
contentTypes: {
|
|
159
|
+
...(primary[0] ? { primary: primary[0] } : {}),
|
|
160
|
+
additional: contributions.filter((item) => item.kind === 'content' && item.target === 'additional'),
|
|
161
|
+
},
|
|
162
|
+
adaptations: contributions.filter((item) => item.kind === 'binding' && item.id.startsWith('adaptation.'))
|
|
163
|
+
.map((item) => ({ ...item, targetContributionId: item.target })),
|
|
164
|
+
} };
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=graph.js.map
|