@decocms/blocks-cli 7.77.9 → 7.77.11

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.77.9",
3
+ "version": "7.77.11",
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.77.9",
36
+ "@decocms/blocks": "7.77.11",
37
37
  "ts-morph": "^27.0.0",
38
38
  "tsx": "^4.22.5"
39
39
  },
@@ -549,3 +549,23 @@ describe("generate-schema default output path (.deco/)", () => {
549
549
  expect(stderr).not.toContain("Generator default output moved");
550
550
  }, 30_000);
551
551
  });
552
+
553
+ describe("typeToJsonSchema with RequestURLParam", () => {
554
+ it("points a RequestURLParam prop at the requestToParam picker", () => {
555
+ const project = strictProject();
556
+ const sf = project.createSourceFile(
557
+ "/props.ts",
558
+ `
559
+ type RequestURLParam = string;
560
+ export interface Props {
561
+ slug?: RequestURLParam;
562
+ plain?: string;
563
+ }
564
+ `,
565
+ );
566
+ const schema = typeToJsonSchema(sf.getInterfaceOrThrow("Props").getType());
567
+ const key = `${Buffer.from("website/functions/requestToParam.ts").toString("base64")}@RequestURLParam`;
568
+ expect(schema.properties.slug).toEqual({ $ref: `#/definitions/${key}`, title: "Slug" });
569
+ expect(schema.properties.plain.type).toBe("string");
570
+ });
571
+ });
@@ -305,6 +305,10 @@ export function applyWidgetFormat(schema: any, typeHint: string): void {
305
305
  const SECTION_REF_DEF_KEY = "__SECTION_REF__";
306
306
  // Well-known definition key for Resolvable (saved blocks picker)
307
307
  const RESOLVABLE_KEY = "Resolvable";
308
+ // Well-known definition key for `RequestURLParam` ("Force param" / "Get params
309
+ // from request parameters"), baked by composeMeta. Same base64 of the function
310
+ // key deco-cx/deco used, with the type name as suffix.
311
+ const REQUEST_URL_PARAM_DEF_KEY = `${toBase64("website/functions/requestToParam.ts")}@RequestURLParam`;
308
312
 
309
313
  /**
310
314
  * Whether a prop annotated `Section` / `Section[]` is the framework's opaque
@@ -691,6 +695,24 @@ export function typeToJsonSchema(type: Type, visited = new Set<string>(), ctx?:
691
695
  continue;
692
696
  }
693
697
 
698
+ // `RequestURLParam` (`@decocms/apps-website/functions/requestToParam`) →
699
+ // the requestToParam picker, as deco-cx/deco emitted it. The alias
700
+ // resolves to `string`, so without this the admin only offered a fixed
701
+ // value and lost "Get params from request parameters".
702
+ const nonNullTypes = propType.isUnion()
703
+ ? propType.getUnionTypes().filter((t) => !t.isNull() && !t.isUndefined())
704
+ : [propType];
705
+ if (baseHint === "RequestURLParam" && nonNullTypes.every((t) => t.isString())) {
706
+ const paramSchema: any = {
707
+ $ref: `#/definitions/${REQUEST_URL_PARAM_DEF_KEY}`,
708
+ title: name.charAt(0).toUpperCase() + name.slice(1),
709
+ };
710
+ applyJsDocToSchema(paramSchema, tags);
711
+ properties[name] = paramSchema;
712
+ if (!prop.isOptional()) required.push(name);
713
+ continue;
714
+ }
715
+
694
716
  // Loader output type → block-ref: emit anyOf [Resolvable, ...matchingLoaders]
695
717
  // baseHint strips "| null | undefined" so "ProductListingPage | null" → "ProductListingPage"
696
718
  if (ctx?.outputTypeToLoaderKeys) {