From c65daee53d6f0f256ede02295b6bef0786318e8a Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Mon, 11 May 2026 11:41:58 -1000 Subject: [PATCH 1/2] feat: add default UID field to new repeatable types Repeatable types need a UID for routing and references. Adding it by default removes a manual step after `prismic type create`. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/commands/type-create.ts | 2 ++ test/type-create.test.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/commands/type-create.ts b/src/commands/type-create.ts index 268bdc1..b11efb6 100644 --- a/src/commands/type-create.ts +++ b/src/commands/type-create.ts @@ -86,6 +86,8 @@ export default createCommand(config, async ({ positionals, values }) => { } : { Main: {} }; + if (!single) json.Main.uid = { type: "UID", config: { label: "UID" } }; + const model: CustomType = { id, label: name, diff --git a/test/type-create.test.ts b/test/type-create.test.ts index 60ecce6..1d02530 100644 --- a/test/type-create.test.ts +++ b/test/type-create.test.ts @@ -18,6 +18,7 @@ it("creates a custom type", async ({ expect, prismic, project }) => { const id = snakeCase(label!); const created = await readLocalCustomType(project, id); expect(created).toMatchObject({ label, format: "custom", repeatable: true }); + expect(created.json.Main.uid).toEqual({ type: "UID", config: { label: "UID" } }); }); it("creates a page type with --format page", async ({ expect, prismic, project }) => { @@ -32,6 +33,7 @@ it("creates a page type with --format page", async ({ expect, prismic, project } expect(created).toMatchObject({ format: "page", repeatable: true }); expect(created.json).toHaveProperty("SEO & Metadata"); expect(created.json.Main).toHaveProperty("slices"); + expect(created.json.Main.uid).toEqual({ type: "UID", config: { label: "UID" } }); }); it("creates a single custom type", async ({ expect, prismic, project }) => { @@ -43,6 +45,7 @@ it("creates a single custom type", async ({ expect, prismic, project }) => { const id = snakeCase(label!); const created = await readLocalCustomType(project, id); expect(created).toMatchObject({ format: "custom", repeatable: false }); + expect(created.json.Main).not.toHaveProperty("uid"); }); it("creates a custom type with a custom id", async ({ expect, prismic, project }) => { From 9929bcb864762d01a355e520bb235bb03acb94e2 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Mon, 11 May 2026 12:05:06 -1000 Subject: [PATCH 2/2] fix: place default UID field first in Main tab Co-Authored-By: Claude Opus 4.7 (1M context) --- src/commands/type-create.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands/type-create.ts b/src/commands/type-create.ts index b11efb6..b3e7d3d 100644 --- a/src/commands/type-create.ts +++ b/src/commands/type-create.ts @@ -86,7 +86,12 @@ export default createCommand(config, async ({ positionals, values }) => { } : { Main: {} }; - if (!single) json.Main.uid = { type: "UID", config: { label: "UID" } }; + if (!single) { + json.Main = { + uid: { type: "UID", config: { label: "UID" } }, + ...json.Main, + }; + } const model: CustomType = { id,