@decocms/blocks-cli 7.79.1 → 7.79.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks-cli",
3
- "version": "7.79.1",
3
+ "version": "7.79.2",
4
4
  "type": "module",
5
5
  "description": "Deco codegen (generate-blocks, generate-schema, generate-invoke) and Fresh-to-TanStack migration tooling",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "lint:unused": "knip"
34
34
  },
35
35
  "dependencies": {
36
- "@decocms/blocks": "7.79.1",
36
+ "@decocms/blocks": "7.79.2",
37
37
  "ts-morph": "^27.0.0",
38
38
  "tsx": "^4.22.5"
39
39
  },
@@ -0,0 +1,213 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
6
+
7
+ interface Schema {
8
+ type?: string;
9
+ title?: string;
10
+ description?: string;
11
+ nullable?: boolean;
12
+ $ref?: string;
13
+ allOf?: Schema[];
14
+ anyOf?: Schema[];
15
+ enum?: string[];
16
+ properties?: Record<string, Schema>;
17
+ items?: Schema;
18
+ required?: string[];
19
+ }
20
+
21
+ // Regression: site multivariate flags (`src/flags/**`, e.g. a
22
+ // `MultivariateFlag<BannerContent>`) were never scanned, so `root.flags`
23
+ // was empty and a prop holding `{ __resolveType: "site/flags/…", variants }`
24
+ // had no schema branch for it. The admin then drew the bare object form over
25
+ // the flag: no variants, every field empty. Driven through the real CLI so the
26
+ // flag pass runs before the loader/section passes that consume it.
27
+ describe("generate-schema site multivariate flags", () => {
28
+ let fixture: string;
29
+ let meta: any;
30
+
31
+ const FLAG = "site/flags/multivariate/content.ts";
32
+ const LIST_FLAG = "site/flags/multivariate/products.ts";
33
+
34
+ beforeAll(() => {
35
+ fixture = mkdtempSync(path.join(tmpdir(), "schema-flags-"));
36
+ const write = (relative: string, contents: string) => {
37
+ const file = path.join(fixture, relative);
38
+ mkdirSync(path.dirname(file), { recursive: true });
39
+ writeFileSync(file, contents);
40
+ };
41
+ write(
42
+ "tsconfig.json",
43
+ JSON.stringify({
44
+ compilerOptions: {
45
+ target: "ES2022",
46
+ module: "ESNext",
47
+ moduleResolution: "Bundler",
48
+ strict: true,
49
+ },
50
+ }),
51
+ );
52
+ // Same shape as @decocms/apps-website's types, declared locally so the
53
+ // fixture has no package to resolve.
54
+ write(
55
+ "src/flags/types.ts",
56
+ `export interface Variant<T> { rule: unknown; value: T; }
57
+ export interface MultivariateProps<T> { variants: Variant<T>[]; }
58
+ export interface MultivariateFlag<T> { variants: Variant<T>[]; }`,
59
+ );
60
+ write(
61
+ "src/types.ts",
62
+ `export interface Content { matcher?: string[]; label: string; }
63
+ export interface Kit { name: string; content: Content; }
64
+ export interface Product { productID: string; }`,
65
+ );
66
+ write(
67
+ "src/flags/multivariate/content.ts",
68
+ `import type { MultivariateFlag, MultivariateProps } from "../types";
69
+ import type { Content } from "../../types";
70
+ /** @title Content Variants */
71
+ export default function content(p: MultivariateProps<Content>): MultivariateFlag<Content> { return p; }`,
72
+ );
73
+ write(
74
+ "src/flags/multivariate/products.ts",
75
+ `import type { MultivariateFlag, MultivariateProps } from "../types";
76
+ import type { Product } from "../../types";
77
+ export default function products(
78
+ p: MultivariateProps<Product[] | null>,
79
+ ): MultivariateFlag<Product[] | null> { return p; }`,
80
+ );
81
+ write("src/flags/helpers.ts", "export const notAFlag = 1;");
82
+ write(
83
+ "src/loaders/kits.ts",
84
+ `import type { Kit } from "../types";
85
+ interface Props { kits: Kit[]; }
86
+ export default function kits({ kits }: Props): Kit[] { return kits; }`,
87
+ );
88
+ write(
89
+ "src/loaders/products.ts",
90
+ `import type { Product } from "../types";
91
+ export default function load(): Product[] { throw new Error("fixture only"); }`,
92
+ );
93
+ write(
94
+ "src/sections/Example.tsx",
95
+ `import type { Content, Product } from "../types";
96
+ export interface Props {
97
+ /**
98
+ * @title Main content
99
+ * @description Shown on top
100
+ */
101
+ content: Content;
102
+ optional?: Content | null;
103
+ products: Product[] | null;
104
+ /** @hide */
105
+ hidden?: Content;
106
+ }
107
+ export default function Example(_props: Props) { return null; }`,
108
+ );
109
+
110
+ const run = spawnSync(
111
+ process.execPath,
112
+ [
113
+ "--import",
114
+ import.meta.resolve("tsx"),
115
+ path.resolve(__dirname, "generate-schema.ts"),
116
+ "--skip-apps",
117
+ ],
118
+ { cwd: fixture, encoding: "utf8", timeout: 30_000 },
119
+ );
120
+ expect(run.status, run.error?.message ?? run.stderr).toBe(0);
121
+ meta = JSON.parse(readFileSync(path.join(fixture, ".deco/meta.gen.json"), "utf8"));
122
+ }, 30_000);
123
+
124
+ afterAll(() => {
125
+ if (fixture) rmSync(fixture, { recursive: true, force: true });
126
+ });
127
+
128
+ const def = (key: string): Schema => meta.schema.definitions[key];
129
+
130
+ function sectionProps(): Record<string, Schema> {
131
+ const section = def(btoa("site/sections/Example.tsx"));
132
+ const ref = section.allOf!.find((part) => part.$ref)!.$ref!;
133
+ return def(ref.replace("#/definitions/", "")).properties!;
134
+ }
135
+
136
+ function expectFlagged(schema: Schema, flagKey: string, title: string) {
137
+ expect(schema.anyOf).toHaveLength(2);
138
+ const [inline, flag] = schema.anyOf!;
139
+ expect(inline.type).toBe("object");
140
+ expect(inline.properties?.label.type).toBe("string");
141
+ // Inline, with its own __resolveType: how the admin tells a block option
142
+ // from the plain branch and renders the field with variants.
143
+ expect(flag).toEqual({
144
+ title,
145
+ type: "object",
146
+ allOf: [{ $ref: `#/definitions/${btoa(flagKey)}@Props` }],
147
+ required: ["__resolveType"],
148
+ properties: { __resolveType: { type: "string", enum: [flagKey], default: flagKey } },
149
+ });
150
+ }
151
+
152
+ it("registers each flag in the manifest and in root.flags", () => {
153
+ expect(meta.manifest.blocks.flags).toEqual({
154
+ [FLAG]: { $ref: `#/definitions/${btoa(FLAG)}`, namespace: "site" },
155
+ [LIST_FLAG]: { $ref: `#/definitions/${btoa(LIST_FLAG)}`, namespace: "site" },
156
+ });
157
+ expect(meta.schema.root.flags.anyOf).toContainEqual({
158
+ $ref: `#/definitions/${btoa(FLAG)}`,
159
+ inputSchema: `#/definitions/${btoa(FLAG)}@Props`,
160
+ });
161
+ expect(def(btoa(FLAG)).title).toBe("Content Variants");
162
+ // No @title → the key, as for loaders.
163
+ expect(def(btoa(LIST_FLAG)).title).toBe(LIST_FLAG);
164
+ });
165
+
166
+ it("emits the variants schema over the flag's value type", () => {
167
+ const variant = def(`${btoa(FLAG)}@Props`).properties!.variants.items!;
168
+ expect(variant.required).toEqual(["rule", "value"]);
169
+ expect(variant.properties!.rule.required).toEqual(["__resolveType"]);
170
+ expect(variant.properties!.value.properties!.label.type).toBe("string");
171
+ });
172
+
173
+ it("skips files under src/flags that are not multivariate flags", () => {
174
+ expect(Object.keys(meta.manifest.blocks.flags)).not.toContain("site/flags/helpers.ts");
175
+ expect(Object.keys(meta.manifest.blocks.flags)).not.toContain("site/flags/types.ts");
176
+ });
177
+
178
+ it("offers the flag on a section prop of the flag's type, keeping its annotations", () => {
179
+ const content = sectionProps().content;
180
+ expectFlagged(content, FLAG, "Content Variants");
181
+ expect(content.title).toBe("Main content");
182
+ expect(content.description).toBe("Shown on top");
183
+ expect(sectionProps().optional.nullable).toBe(true);
184
+ expectFlagged(sectionProps().optional, FLAG, "Content Variants");
185
+ });
186
+
187
+ it("offers the flag on a nested prop of a loader's props (a list of items with flagged content)", () => {
188
+ const loader = def(btoa("site/loaders/kits.ts"));
189
+ const kit = loader.properties!.kits.items!;
190
+ expect(kit.properties!.name.type).toBe("string");
191
+ expectFlagged(kit.properties!.content, FLAG, "Content Variants");
192
+ });
193
+
194
+ it("adds the flag to a loader block-ref picker over the same type", () => {
195
+ const loaderPicker = [
196
+ { $ref: "#/definitions/Resolvable" },
197
+ { $ref: `#/definitions/${btoa("site/loaders/products.ts")}` },
198
+ ];
199
+ expect(sectionProps().products.anyOf).toEqual([
200
+ ...loaderPicker,
201
+ { $ref: `#/definitions/${btoa(LIST_FLAG)}` },
202
+ ]);
203
+ // Each variant is itself a loader pick, not the whole inlined Product type.
204
+ const variant = def(`${btoa(LIST_FLAG)}@Props`).properties!.variants.items!;
205
+ expect(variant.properties!.value.anyOf).toEqual(loaderPicker);
206
+ });
207
+
208
+ it("leaves a hidden prop alone", () => {
209
+ const hidden = sectionProps().hidden;
210
+ expect(hidden.anyOf).toBeUndefined();
211
+ expect(hidden.type).toBe("object");
212
+ });
213
+ });
@@ -23,6 +23,7 @@ import { fileURLToPath } from "node:url";
23
23
  * --version Framework version (default: "1.0.0")
24
24
  * --sections Sections directory (default: "src/sections")
25
25
  * --loaders Loaders directory (default: "src/loaders")
26
+ * --flags Flags directory (default: "src/flags")
26
27
  * --apps Apps directory (default: "src/apps")
27
28
  * --skip-apps Skip app schema generation
28
29
  * --out Output file (default: ".deco/meta.gen.json")
@@ -71,6 +72,7 @@ let SITE_NAME = "storefront";
71
72
  let FRAMEWORK_VERSION = "1.0.0";
72
73
  let SECTIONS_REL = "src/sections";
73
74
  let LOADERS_REL = "src/loaders";
75
+ let FLAGS_REL = "src/flags";
74
76
  let APPS_REL = "src/apps";
75
77
  let SKIP_APPS = false;
76
78
  let OUT_REL = NEW_DEFAULT_OUT_REL;
@@ -89,6 +91,7 @@ if (isMainModule()) {
89
91
  FRAMEWORK_VERSION = arg("version", FRAMEWORK_VERSION);
90
92
  SECTIONS_REL = arg("sections", SECTIONS_REL);
91
93
  LOADERS_REL = arg("loaders", LOADERS_REL);
94
+ FLAGS_REL = arg("flags", FLAGS_REL);
92
95
  APPS_REL = arg("apps", APPS_REL);
93
96
  SKIP_APPS = argv.includes("--skip-apps");
94
97
  OUT_REL = arg("out", NEW_DEFAULT_OUT_REL);
@@ -373,6 +376,12 @@ const RUNTIME_INJECTED_TYPES = new Set([
373
376
  interface GenerationContext {
374
377
  /** Loader output type name → loader keys, for block-ref pickers. Sections only. */
375
378
  outputTypeToLoaderKeys?: Map<string, string[]>;
379
+ /**
380
+ * Flag value type name → the site's flag blocks over that type (see
381
+ * flagBranch). A prop of that type also accepts the flag, which is what
382
+ * makes the admin offer — and recognize — variants on that field.
383
+ */
384
+ outputTypeToFlags?: Map<string, FlagBlock[]>;
376
385
  /**
377
386
  * Shared definitions sink. When present, a recursive named type (e.g.
378
387
  * `interface Link { submenu?: Link[] }`) is emitted once as a definition and
@@ -477,6 +486,87 @@ function extractLoaderOutputTypeName(sourceFile: SourceFile): string | null {
477
486
  return loaderTypeName(ret);
478
487
  }
479
488
 
489
+ /** A site flag block (`src/flags/**`): its key, picker title and definition id. */
490
+ export interface FlagBlock {
491
+ key: string;
492
+ title: string;
493
+ defKey: string;
494
+ }
495
+
496
+ /**
497
+ * The value type a multivariate flag chooses between: `T` in
498
+ * `export default function (props: MultivariateProps<T>): MultivariateFlag<T>`,
499
+ * read from the props' `variants[].value` so it does not depend on what the
500
+ * helper types are called or where they are imported from.
501
+ */
502
+ export function extractFlagValueType(sourceFile: SourceFile): Type | null {
503
+ const propsType = extractDefaultExportPropsType(sourceFile);
504
+ const variants = propsType?.getProperty("variants");
505
+ if (!variants) return null;
506
+ let variantsType = variants.getTypeAtLocation(sourceFile);
507
+ if (variantsType.isUnion()) {
508
+ const nonNull = variantsType.getUnionTypes().filter((t) => !t.isNull() && !t.isUndefined());
509
+ if (nonNull.length !== 1) return null;
510
+ variantsType = nonNull[0];
511
+ }
512
+ const value = variantsType.getArrayElementType()?.getProperty("value");
513
+ return value ? value.getTypeAtLocation(sourceFile) : null;
514
+ }
515
+
516
+ /**
517
+ * A flag block as an `anyOf` branch of a prop it can fill, in deco-cx/deco's
518
+ * shape: inline, carrying its own `__resolveType`, with the variants schema
519
+ * behind the `allOf`. The admin recognizes a block option by the
520
+ * `__resolveType` on the branch itself, and treats a field whose only block
521
+ * option is a flag with `variants` as a field with variants — a `$ref` branch
522
+ * would make it a plain block picker instead.
523
+ */
524
+ export function flagBranch(flag: FlagBlock): any {
525
+ return {
526
+ title: flag.title,
527
+ type: "object",
528
+ allOf: [{ $ref: `#/definitions/${flag.defKey}@Props` }],
529
+ required: ["__resolveType"],
530
+ properties: {
531
+ __resolveType: { type: "string", enum: [flag.key], default: flag.key },
532
+ },
533
+ };
534
+ }
535
+
536
+ /**
537
+ * Input schema of a multivariate flag over a value schema. `rule` is any
538
+ * matcher; the admin edits it with its own matcher picker, so it only needs to
539
+ * be a block reference (same shape composeMeta gives the section flag).
540
+ */
541
+ export function multivariatePropsSchema(valueSchema: any): any {
542
+ return {
543
+ title: "Multivariate",
544
+ type: "object",
545
+ required: ["variants"],
546
+ properties: {
547
+ variants: {
548
+ type: "array",
549
+ title: "Variants",
550
+ minItems: 1,
551
+ items: {
552
+ type: "object",
553
+ required: ["rule", "value"],
554
+ properties: {
555
+ rule: {
556
+ title: "Rule",
557
+ type: "object",
558
+ required: ["__resolveType"],
559
+ properties: { __resolveType: { type: "string" } },
560
+ additionalProperties: true,
561
+ },
562
+ value: { ...valueSchema, title: "Content" },
563
+ },
564
+ },
565
+ },
566
+ },
567
+ };
568
+ }
569
+
480
570
  export function typeToJsonSchema(type: Type, visited = new Set<string>(), ctx?: GenerationContext): any {
481
571
  const typeText = type.getText();
482
572
  if (visited.has(typeText)) return recursiveTypeRef(type, ctx) ?? { type: "object" };
@@ -713,10 +803,13 @@ export function typeToJsonSchema(type: Type, visited = new Set<string>(), ctx?:
713
803
  continue;
714
804
  }
715
805
 
806
+ const outputTypeName = loaderTypeName(propType);
807
+ const matchingFlags =
808
+ (outputTypeName ? ctx?.outputTypeToFlags?.get(outputTypeName) : undefined) ?? [];
809
+
716
810
  // Loader output type → block-ref: emit anyOf [Resolvable, ...matchingLoaders]
717
811
  // baseHint strips "| null | undefined" so "ProductListingPage | null" → "ProductListingPage"
718
812
  if (ctx?.outputTypeToLoaderKeys) {
719
- const outputTypeName = loaderTypeName(propType);
720
813
  const matchingLoaders =
721
814
  (outputTypeName ? ctx.outputTypeToLoaderKeys.get(outputTypeName) : undefined) ??
722
815
  (outputTypeName !== baseHint ? ctx.outputTypeToLoaderKeys.get(baseHint) : undefined);
@@ -725,6 +818,7 @@ export function typeToJsonSchema(type: Type, visited = new Set<string>(), ctx?:
725
818
  anyOf: [
726
819
  { $ref: `#/definitions/${RESOLVABLE_KEY}` },
727
820
  ...matchingLoaders.map((k) => ({ $ref: `#/definitions/${toBase64(k)}` })),
821
+ ...matchingFlags.map((f) => ({ $ref: `#/definitions/${f.defKey}` })),
728
822
  ],
729
823
  title: name.charAt(0).toUpperCase() + name.slice(1),
730
824
  };
@@ -749,6 +843,22 @@ export function typeToJsonSchema(type: Type, visited = new Set<string>(), ctx?:
749
843
 
750
844
  if (!schema.title) schema.title = name.charAt(0).toUpperCase() + name.slice(1);
751
845
 
846
+ // A site flag over this prop's type → the value may also be that flag
847
+ // (`{ __resolveType: "site/flags/…", variants }`). Without the branch the
848
+ // admin can't read a stored flag and shows the bare, empty object form.
849
+ if (matchingFlags.length > 0 && schema.hide !== "true") {
850
+ const { title, description, nullable, ...inline } = schema;
851
+ const flagged: any = {
852
+ anyOf: [{ ...inline, title }, ...matchingFlags.map(flagBranch)],
853
+ title,
854
+ };
855
+ if (description) flagged.description = description;
856
+ if (nullable) flagged.nullable = true;
857
+ properties[name] = flagged;
858
+ if (!prop.isOptional()) required.push(name);
859
+ continue;
860
+ }
861
+
752
862
  properties[name] = schema;
753
863
  // A hidden prop (runtime-injected type, ReactNode, @hide) can never be
754
864
  // filled in by the CMS user — requiring it would deadlock the form.
@@ -1053,6 +1163,7 @@ function generateMeta(): MetaResponse {
1053
1163
  const root = process.cwd();
1054
1164
  const sectionsDir = path.resolve(root, SECTIONS_REL);
1055
1165
  const loadersDir = path.resolve(root, LOADERS_REL);
1166
+ const flagsDir = path.resolve(root, FLAGS_REL);
1056
1167
  const srcDir = path.join(root, "src");
1057
1168
 
1058
1169
  const project = new Project({
@@ -1065,12 +1176,20 @@ function generateMeta(): MetaResponse {
1065
1176
  const loaderBlocks: Record<string, any> = {};
1066
1177
  const sectionRootAnyOf: any[] = [];
1067
1178
  const loaderRootAnyOf: any[] = [{ $ref: `#/definitions/${RESOLVABLE_KEY}` }];
1179
+ const flagBlocks: Record<string, any> = {};
1180
+ const flagRootAnyOf: any[] = [{ $ref: `#/definitions/${RESOLVABLE_KEY}` }];
1068
1181
  const outputTypeToLoaderKeys = new Map<string, string[]>();
1182
+ const outputTypeToFlags = new Map<string, FlagBlock[]>();
1069
1183
  const sourceFileCache: SourceFileCache = new Map();
1070
1184
  const moduleResolutionCache: ModuleResolutionCache = new Map();
1071
1185
  const propsSchemaCache: PropsSchemaCache = new Map();
1072
1186
  // Shared by every pass so each recursive type is emitted as one definition.
1073
- const schemaRefs: GenerationContext = { definitions, rootDir: root, recursiveRefs: new Set() };
1187
+ const schemaRefs: GenerationContext = {
1188
+ definitions,
1189
+ rootDir: root,
1190
+ recursiveRefs: new Set(),
1191
+ outputTypeToFlags,
1192
+ };
1074
1193
 
1075
1194
  // Resolvable: the admin's deRefUntil expects the LITERAL key "Resolvable",
1076
1195
  // not a base64-encoded version. We store both for compatibility.
@@ -1086,6 +1205,46 @@ function generateMeta(): MetaResponse {
1086
1205
  definitions[resolvableB64Key] = resolvableDef;
1087
1206
  sectionRootAnyOf.push({ $ref: `#/definitions/${RESOLVABLE_KEY}` });
1088
1207
 
1208
+ // ---------------------------------------------------------------------------
1209
+ // Flags pass: the site's multivariate flags (src/flags/**, e.g.
1210
+ // `MultivariateFlag<BannerContent>`). Only registers each flag's value type
1211
+ // here, before every props pass: a prop of that type gets the flag as an
1212
+ // extra branch (see flagBranch), wherever the prop is — section, loader or
1213
+ // app. The flags' own schemas are built after the loader passes (below), so
1214
+ // a `Product[]` inside a flag's value is a loader picker, not the whole
1215
+ // inlined Product type.
1216
+ // ---------------------------------------------------------------------------
1217
+ const flagFiles = fs.existsSync(flagsDir) ? findTsxFiles(flagsDir) : [];
1218
+ const siteFlags: Array<{ flag: FlagBlock; valueType: Type; valueTypeName: string | null }> = [];
1219
+ for (const filePath of flagFiles) {
1220
+ const relativePath = path.relative(srcDir, filePath).replaceAll("\\", "/");
1221
+ const flagKey = `${SITE_NAMESPACE}/${relativePath}`;
1222
+ try {
1223
+ const sourceFile = getSourceFile(project, filePath, sourceFileCache);
1224
+ const defaultSym = sourceFile.getDefaultExportSymbol();
1225
+ const valueType = extractFlagValueType(sourceFile);
1226
+ if (!defaultSym || !valueType) {
1227
+ console.log(` · flag ${flagKey} (not a multivariate flag, skipped)`);
1228
+ continue;
1229
+ }
1230
+ const titleTag = getJsDocTags(defaultSym).title;
1231
+ const flag: FlagBlock = {
1232
+ key: flagKey,
1233
+ title: titleTag && !titleTag.includes("/") ? titleTag : flagKey,
1234
+ defKey: toBase64(flagKey),
1235
+ };
1236
+ const valueTypeName = loaderTypeName(valueType);
1237
+ siteFlags.push({ flag, valueType, valueTypeName });
1238
+ if (valueTypeName) {
1239
+ const existing = outputTypeToFlags.get(valueTypeName) ?? [];
1240
+ existing.push(flag);
1241
+ outputTypeToFlags.set(valueTypeName, existing);
1242
+ }
1243
+ } catch (e) {
1244
+ console.warn(` ✗ flag ${flagKey}: ${(e as Error).message}`);
1245
+ }
1246
+ }
1247
+
1089
1248
  // ---------------------------------------------------------------------------
1090
1249
  // First pass: scan loaders — build input schemas + outputTypeToLoaderKeys map
1091
1250
  // ---------------------------------------------------------------------------
@@ -1329,6 +1488,33 @@ function generateMeta(): MetaResponse {
1329
1488
 
1330
1489
  const ctx: GenerationContext = { ...schemaRefs, outputTypeToLoaderKeys };
1331
1490
 
1491
+ // The flags' own schemas (registered in the flags pass above). A value type
1492
+ // loaders return (`Product[] | null`) is a loader picker, as for a prop.
1493
+ for (const { flag, valueType, valueTypeName } of siteFlags) {
1494
+ try {
1495
+ const matchingLoaders = valueTypeName ? outputTypeToLoaderKeys.get(valueTypeName) : undefined;
1496
+ const valueSchema = matchingLoaders?.length
1497
+ ? {
1498
+ anyOf: [
1499
+ { $ref: `#/definitions/${RESOLVABLE_KEY}` },
1500
+ ...matchingLoaders.map((k) => ({ $ref: `#/definitions/${toBase64(k)}` })),
1501
+ ],
1502
+ }
1503
+ : typeToJsonSchema(valueType, undefined, ctx);
1504
+ definitions[`${flag.defKey}@Props`] = multivariatePropsSchema(valueSchema);
1505
+ const { allOf, required, properties } = flagBranch(flag);
1506
+ definitions[flag.defKey] = { title: flag.title, type: "object", allOf, required, properties };
1507
+ flagBlocks[flag.key] = { $ref: `#/definitions/${flag.defKey}`, namespace: SITE_NAMESPACE };
1508
+ flagRootAnyOf.push({
1509
+ $ref: `#/definitions/${flag.defKey}`,
1510
+ inputSchema: `#/definitions/${flag.defKey}@Props`,
1511
+ });
1512
+ console.log(` ✓ flag ${flag.key}${valueTypeName ? ` → ${valueTypeName}` : ""}`);
1513
+ } catch (e) {
1514
+ console.warn(` ✗ flag ${flag.key}: ${(e as Error).message}`);
1515
+ }
1516
+ }
1517
+
1332
1518
  // ---------------------------------------------------------------------------
1333
1519
  // Commerce "extension wrapper" loaders (deco-cx parity).
1334
1520
  //
@@ -1600,7 +1786,14 @@ function generateMeta(): MetaResponse {
1600
1786
  version: FRAMEWORK_VERSION,
1601
1787
  namespace: SITE_NAMESPACE,
1602
1788
  site: SITE_NAME,
1603
- manifest: { blocks: { sections: sectionBlocks, loaders: loaderBlocks, apps: appBlocks } },
1789
+ manifest: {
1790
+ blocks: {
1791
+ sections: sectionBlocks,
1792
+ loaders: loaderBlocks,
1793
+ flags: flagBlocks,
1794
+ apps: appBlocks,
1795
+ },
1796
+ },
1604
1797
  schema: {
1605
1798
  definitions,
1606
1799
  root: {
@@ -1610,7 +1803,7 @@ function generateMeta(): MetaResponse {
1610
1803
  pages: emptyAnyOf,
1611
1804
  handlers: emptyAnyOf,
1612
1805
  matchers: emptyAnyOf,
1613
- flags: emptyAnyOf,
1806
+ flags: { anyOf: flagRootAnyOf },
1614
1807
  functions: emptyAnyOf,
1615
1808
  apps: { anyOf: appRootAnyOf },
1616
1809
  },