prismic-ts-codegen 0.1.8 → 0.1.9
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/bin/prismic-ts-codegen.mjs +0 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/detectTypesProvider.cjs +2 -1
- package/dist/detectTypesProvider.cjs.map +1 -1
- package/dist/detectTypesProvider.js +2 -1
- package/dist/detectTypesProvider.js.map +1 -1
- package/dist/generateTypes.cjs +7 -5
- package/dist/generateTypes.cjs.map +1 -1
- package/dist/generateTypes.js +7 -5
- package/dist/generateTypes.js.map +1 -1
- package/dist/lib/addInterfacePropertiesForFields.cjs +4 -5
- package/dist/lib/addInterfacePropertiesForFields.cjs.map +1 -1
- package/dist/lib/addInterfacePropertiesForFields.js +4 -5
- package/dist/lib/addInterfacePropertiesForFields.js.map +1 -1
- package/dist/lib/getAPIIDPath.cjs +1 -2
- package/dist/lib/getAPIIDPath.cjs.map +1 -1
- package/dist/lib/getAPIIDPath.js +1 -2
- package/dist/lib/getAPIIDPath.js.map +1 -1
- package/dist/lib/getHumanReadableFieldType.cjs +2 -3
- package/dist/lib/getHumanReadableFieldType.cjs.map +1 -1
- package/dist/lib/getHumanReadableFieldType.js +2 -3
- package/dist/lib/getHumanReadableFieldType.js.map +1 -1
- package/dist/lib/isCustomTypeModelSlice.cjs +1 -2
- package/dist/lib/isCustomTypeModelSlice.cjs.map +1 -1
- package/dist/lib/isCustomTypeModelSlice.d.ts +1 -1
- package/dist/lib/isCustomTypeModelSlice.js +1 -2
- package/dist/lib/isCustomTypeModelSlice.js.map +1 -1
- package/dist/lib/isSharedSliceModel.cjs +1 -2
- package/dist/lib/isSharedSliceModel.cjs.map +1 -1
- package/dist/lib/isSharedSliceModel.d.ts +1 -1
- package/dist/lib/isSharedSliceModel.js +1 -2
- package/dist/lib/isSharedSliceModel.js.map +1 -1
- package/package.json +2 -2
- package/src/cli/index.ts +2 -2
- package/src/detectTypesProvider.ts +3 -1
- package/src/generateTypes.ts +9 -5
- package/src/lib/addInterfacePropertiesForFields.ts +4 -8
- package/src/lib/getAPIIDPath.ts +1 -3
- package/src/lib/getHumanReadableFieldType.ts +2 -3
- package/src/lib/isCustomTypeModelSlice.ts +2 -5
- package/src/lib/isSharedSliceModel.ts +2 -2
|
File without changes
|
package/dist/cli.cjs
CHANGED
|
@@ -25,7 +25,7 @@ const cli = meow(`
|
|
|
25
25
|
flags: {
|
|
26
26
|
config: {
|
|
27
27
|
type: "string",
|
|
28
|
-
|
|
28
|
+
shortFlag: "c",
|
|
29
29
|
isRequired: false
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -39,7 +39,7 @@ const main = async () => {
|
|
|
39
39
|
${configPath} already exists.`);
|
|
40
40
|
} else {
|
|
41
41
|
let contents = "";
|
|
42
|
-
if (fs.existsSync("sm.json")) {
|
|
42
|
+
if (fs.existsSync("slicemachine.config.json") || fs.existsSync("sm.json")) {
|
|
43
43
|
contents = commonTags.stripIndent`
|
|
44
44
|
import type { Config } from "prismic-ts-codegen";
|
|
45
45
|
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","sources":["../../src/cli/index.ts"],"sourcesContent":["import { stripIndent } from \"common-tags\";\nimport { existsSync, writeFileSync } from \"fs\";\nimport meow from \"meow\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\n\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\
|
|
1
|
+
{"version":3,"file":"cli.cjs","sources":["../../src/cli/index.ts"],"sourcesContent":["import { stripIndent } from \"common-tags\";\nimport { existsSync, writeFileSync } from \"fs\";\nimport meow from \"meow\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\n\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tshortFlag: \"c\",\n\t\t\t\tisRequired: false,\n\t\t\t},\n\t\t},\n\t},\n);\n\nconst main = async () => {\n\tif (cli.input[0] === \"init\") {\n\t\tconst configPath = cli.flags.config || \"prismicCodegen.config.ts\";\n\n\t\tif (existsSync(configPath)) {\n\t\t\tconsole.info(`\\n${configPath} already exists.`);\n\t\t} else {\n\t\t\tlet contents = \"\";\n\n\t\t\tif (existsSync(\"slicemachine.config.json\") || existsSync(\"sm.json\")) {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t models: [\"./customtypes/**/index.json\", \"./slices/**/model.json\"],\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t}\n\n\t\t\twriteFileSync(configPath, contents);\n\n\t\t\tconsole.info(`\\nCreated prismic-ts-codegen config file: ${configPath}`);\n\t\t}\n\t} else {\n\t\tconst unvalidatedConfig = loadConfig({ path: cli.flags.config });\n\n\t\tconst { value: config, error } = configSchema.validate(unvalidatedConfig);\n\n\t\tif (config && !error) {\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models)\n\t\t\t\t\t? config.models\n\t\t\t\t\t: config.models?.files,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\tcustomTypesAPIToken: config.customTypesAPIToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.models &&\n\t\t\t\t\t\"fetchFromRepository\" in config.models &&\n\t\t\t\t\tconfig.models.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst localeIDs = await loadLocaleIDs({\n\t\t\t\tlocaleIDs: Array.isArray(config.locales)\n\t\t\t\t\t? config.locales\n\t\t\t\t\t: config.locales?.ids,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\taccessToken: config.accessToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.locales &&\n\t\t\t\t\t\"fetchFromRepository\" in config.locales &&\n\t\t\t\t\tconfig.locales.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst typesProvider =\n\t\t\t\tconfig.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (\n\t\t\t\tconfig.clientIntegration?.includeCreateClientInterface &&\n\t\t\t\t!hasCustomTypeModels\n\t\t\t) {\n\t\t\t\tconsole.info(\n\t\t\t\t\t\"[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst types = generateTypes({\n\t\t\t\tcustomTypeModels,\n\t\t\t\tsharedSliceModels,\n\t\t\t\tlocaleIDs,\n\t\t\t\tfieldConfigs: config.fields,\n\t\t\t\tclientIntegration: {\n\t\t\t\t\tincludeCreateClientInterface: hasCustomTypeModels\n\t\t\t\t\t\t? config.clientIntegration?.includeCreateClientInterface ?? true\n\t\t\t\t\t\t: false,\n\t\t\t\t\tincludeContentNamespace:\n\t\t\t\t\t\tconfig.clientIntegration?.includeContentNamespace ?? true,\n\t\t\t\t},\n\t\t\t\ttypesProvider,\n\t\t\t});\n\n\t\t\tconst fileContents = `${NON_EDITABLE_FILE_HEADER}\\n\\n${types}`;\n\n\t\t\tif (config.output) {\n\t\t\t\twriteFileSync(resolvePath(config.output), fileContents);\n\n\t\t\t\tconsole.info(`\\nGenerated types in: ${config.output}`);\n\t\t\t} else {\n\t\t\t\tprocess.stdout.write(types + \"\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(error.message);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\nmain().catch((error) => console.error(error));\n"],"names":["existsSync","stripIndent","writeFileSync","loadConfig","configSchema","loadModels","loadLocaleIDs","detectTypesProvider","generateTypes","NON_EDITABLE_FILE_HEADER","resolvePath"],"mappings":";;;;;;;;;;;;AAaA,MAAM,MAAM,KACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACC,YAAY,EAAA,KAAA,OAAA,aAAA,cAAA,QAAA,KAAA,EAAA,cAAA,UAAA,EAAA,OAAA,SAAA,iBAAA,SAAA,cAAA,OAAA,IAAA,IAAA,WAAA,SAAA,OAAA,EAAA,KAAA;AAAA,EACZ,OAAO;AAAA,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AAgB,OAAO;AAAA,QACvB,aAAa,OAAO;AAAA,QACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;AAAA,MAAA,CAChB;AAED,YAAM,gBACL,OAAO,iBAAkB,MAAMC,oBAAqB,oBAAA;AAE/C,YAAA,sBAAsB,iBAAiB,SAAS;AAEtD,YACC,YAAO,sBAAP,mBAA0B,iCAC1B,CAAC,qBACA;AACD,gBAAQ,KACP,+OAA+O;AAAA,MAEhP;AAED,YAAM,QAAQC,cAAAA,cAAc;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,OAAO;AAAA,QACrB,mBAAmB;AAAA,UAClB,8BAA8B,wBAC3B,YAAO,sBAAP,mBAA0B,iCAAgC,OAC1D;AAAA,UACH,2BACC,YAAO,sBAAP,mBAA0B,4BAA2B;AAAA,QACtD;AAAA,QACD;AAAA,MAAA,CACA;AAED,YAAM,eAAe,GAAGC;;EAA+B;AAEvD,UAAI,OAAO,QAAQ;AAClBP,WAAAA,cAAcQ,KAAAA,QAAY,OAAO,MAAM,GAAG,YAAY;AAEtD,gBAAQ,KAAK;AAAA,sBAAyB,OAAO,QAAQ;AAAA,MAAA,OAC/C;AACE,gBAAA,OAAO,MAAM,QAAQ,IAAI;AAAA,MACjC;AAAA,IAAA,OACK;AACN,UAAI,OAAO;AACF,gBAAA,MAAM,MAAM,OAAO;AAE3B;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACF;AAEA,OAAO,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,CAAC;"}
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ const cli = meow(`
|
|
|
24
24
|
flags: {
|
|
25
25
|
config: {
|
|
26
26
|
type: "string",
|
|
27
|
-
|
|
27
|
+
shortFlag: "c",
|
|
28
28
|
isRequired: false
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -38,7 +38,7 @@ const main = async () => {
|
|
|
38
38
|
${configPath} already exists.`);
|
|
39
39
|
} else {
|
|
40
40
|
let contents = "";
|
|
41
|
-
if (existsSync("sm.json")) {
|
|
41
|
+
if (existsSync("slicemachine.config.json") || existsSync("sm.json")) {
|
|
42
42
|
contents = stripIndent`
|
|
43
43
|
import type { Config } from "prismic-ts-codegen";
|
|
44
44
|
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../../src/cli/index.ts"],"sourcesContent":["import { stripIndent } from \"common-tags\";\nimport { existsSync, writeFileSync } from \"fs\";\nimport meow from \"meow\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\n\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../../src/cli/index.ts"],"sourcesContent":["import { stripIndent } from \"common-tags\";\nimport { existsSync, writeFileSync } from \"fs\";\nimport meow from \"meow\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\n\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tshortFlag: \"c\",\n\t\t\t\tisRequired: false,\n\t\t\t},\n\t\t},\n\t},\n);\n\nconst main = async () => {\n\tif (cli.input[0] === \"init\") {\n\t\tconst configPath = cli.flags.config || \"prismicCodegen.config.ts\";\n\n\t\tif (existsSync(configPath)) {\n\t\t\tconsole.info(`\\n${configPath} already exists.`);\n\t\t} else {\n\t\t\tlet contents = \"\";\n\n\t\t\tif (existsSync(\"slicemachine.config.json\") || existsSync(\"sm.json\")) {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t models: [\"./customtypes/**/index.json\", \"./slices/**/model.json\"],\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t}\n\n\t\t\twriteFileSync(configPath, contents);\n\n\t\t\tconsole.info(`\\nCreated prismic-ts-codegen config file: ${configPath}`);\n\t\t}\n\t} else {\n\t\tconst unvalidatedConfig = loadConfig({ path: cli.flags.config });\n\n\t\tconst { value: config, error } = configSchema.validate(unvalidatedConfig);\n\n\t\tif (config && !error) {\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models)\n\t\t\t\t\t? config.models\n\t\t\t\t\t: config.models?.files,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\tcustomTypesAPIToken: config.customTypesAPIToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.models &&\n\t\t\t\t\t\"fetchFromRepository\" in config.models &&\n\t\t\t\t\tconfig.models.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst localeIDs = await loadLocaleIDs({\n\t\t\t\tlocaleIDs: Array.isArray(config.locales)\n\t\t\t\t\t? config.locales\n\t\t\t\t\t: config.locales?.ids,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\taccessToken: config.accessToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.locales &&\n\t\t\t\t\t\"fetchFromRepository\" in config.locales &&\n\t\t\t\t\tconfig.locales.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst typesProvider =\n\t\t\t\tconfig.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (\n\t\t\t\tconfig.clientIntegration?.includeCreateClientInterface &&\n\t\t\t\t!hasCustomTypeModels\n\t\t\t) {\n\t\t\t\tconsole.info(\n\t\t\t\t\t\"[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst types = generateTypes({\n\t\t\t\tcustomTypeModels,\n\t\t\t\tsharedSliceModels,\n\t\t\t\tlocaleIDs,\n\t\t\t\tfieldConfigs: config.fields,\n\t\t\t\tclientIntegration: {\n\t\t\t\t\tincludeCreateClientInterface: hasCustomTypeModels\n\t\t\t\t\t\t? config.clientIntegration?.includeCreateClientInterface ?? true\n\t\t\t\t\t\t: false,\n\t\t\t\t\tincludeContentNamespace:\n\t\t\t\t\t\tconfig.clientIntegration?.includeContentNamespace ?? true,\n\t\t\t\t},\n\t\t\t\ttypesProvider,\n\t\t\t});\n\n\t\t\tconst fileContents = `${NON_EDITABLE_FILE_HEADER}\\n\\n${types}`;\n\n\t\t\tif (config.output) {\n\t\t\t\twriteFileSync(resolvePath(config.output), fileContents);\n\n\t\t\t\tconsole.info(`\\nGenerated types in: ${config.output}`);\n\t\t\t} else {\n\t\t\t\tprocess.stdout.write(types + \"\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(error.message);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n};\n\nmain().catch((error) => console.error(error));\n"],"names":["resolvePath"],"mappings":";;;;;;;;;;;AAaA,MAAM,MAAM,KACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACC,YAAY;AAAA,EACZ,OAAO;AAAA,IACN,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,WAAW;AAAA,MACX,YAAY;AAAA,IACZ;AAAA,EACD;AACD,CAAA;AAGF,MAAM,OAAO,YAAW;;AACvB,MAAI,IAAI,MAAM,CAAC,MAAM,QAAQ;AACtB,UAAA,aAAa,IAAI,MAAM,UAAU;AAEnC,QAAA,WAAW,UAAU,GAAG;AAC3B,cAAQ,KAAK;AAAA,EAAK,4BAA4B;AAAA,IAAA,OACxC;AACN,UAAI,WAAW;AAEf,UAAI,WAAW,0BAA0B,KAAK,WAAW,SAAS,GAAG;AACzD,mBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAA,OAUL;AACK,mBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASX;AAED,oBAAc,YAAY,QAAQ;AAElC,cAAQ,KAAK;AAAA,0CAA6C,YAAY;AAAA,IACtE;AAAA,EAAA,OACK;AACN,UAAM,oBAAoB,WAAW,EAAE,MAAM,IAAI,MAAM,QAAQ;AAE/D,UAAM,EAAE,OAAO,QAAQ,MAAU,IAAA,aAAa,SAAS,iBAAiB;AAEpE,QAAA,UAAU,CAAC,OAAO;AACrB,YAAM,EAAE,kBAAkB,sBAA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D;AACF;AAEA,OAAO,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,CAAC;"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const node_module = require("node:module");
|
|
4
4
|
const detectTypesProvider = async (config = {}) => {
|
|
5
|
-
const
|
|
5
|
+
const cwd = config.cwd || process.cwd();
|
|
6
|
+
const require2 = node_module.createRequire(cwd.endsWith("/") ? cwd : cwd + "/");
|
|
6
7
|
try {
|
|
7
8
|
if (Number.parseInt(require2("@prismicio/client/package.json").version.split(".")[0]) >= 7) {
|
|
8
9
|
return "@prismicio/client";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectTypesProvider.cjs","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst
|
|
1
|
+
{"version":3,"file":"detectTypesProvider.cjs","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (\n\t\t\tNumber.parseInt(\n\t\t\t\trequire(\"@prismicio/client/package.json\").version.split(\".\")[0],\n\t\t\t) >= 7\n\t\t) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"names":["require","createRequire"],"mappings":";;;AAgBO,MAAM,sBAAsB,OAClC,SAAoC,OACG;AACvC,QAAM,MAAM,OAAO,OAAO,QAAQ,IAAG;AAE/B,QAAAA,WAAUC,0BAAc,IAAI,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG;AAE7D,MAAA;AACH,QACC,OAAO,SACND,SAAQ,gCAAgC,EAAE,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAC3D,GACJ;AACM,aAAA;AAAA,IACP;AAAA,EAAA,QACA;AAAA,EAED;AAEG,MAAA;AACH,IAAAA,SAAQ,QAAQ,kBAAkB;AAE3B,WAAA;AAAA,EAAA,QACN;AAAA,EAED;AACF;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
const detectTypesProvider = async (config = {}) => {
|
|
3
|
-
const
|
|
3
|
+
const cwd = config.cwd || process.cwd();
|
|
4
|
+
const require2 = createRequire(cwd.endsWith("/") ? cwd : cwd + "/");
|
|
4
5
|
try {
|
|
5
6
|
if (Number.parseInt(require2("@prismicio/client/package.json").version.split(".")[0]) >= 7) {
|
|
6
7
|
return "@prismicio/client";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectTypesProvider.js","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst
|
|
1
|
+
{"version":3,"file":"detectTypesProvider.js","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (\n\t\t\tNumber.parseInt(\n\t\t\t\trequire(\"@prismicio/client/package.json\").version.split(\".\")[0],\n\t\t\t) >= 7\n\t\t) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"names":["require"],"mappings":";AAgBO,MAAM,sBAAsB,OAClC,SAAoC,OACG;AACvC,QAAM,MAAM,OAAO,OAAO,QAAQ,IAAG;AAE/B,QAAAA,WAAU,cAAc,IAAI,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG;AAE7D,MAAA;AACH,QACC,OAAO,SACNA,SAAQ,gCAAgC,EAAE,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAC3D,GACJ;AACM,aAAA;AAAA,IACP;AAAA,EAAA,QACA;AAAA,EAED;AAEG,MAAA;AACH,IAAAA,SAAQ,QAAQ,kBAAkB;AAE3B,WAAA;AAAA,EAAA,QACN;AAAA,EAED;AACF;"}
|
package/dist/generateTypes.cjs
CHANGED
|
@@ -54,11 +54,13 @@ const generateTypes = (config = {}) => {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
if (((_a = config.clientIntegration) == null ? void 0 : _a.includeCreateClientInterface) || ((_b = config.clientIntegration) == null ? void 0 : _b.includeContentNamespace)) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
if (config.typesProvider !== "@prismicio/client") {
|
|
58
|
+
sourceFile.addImportDeclaration({
|
|
59
|
+
moduleSpecifier: "@prismicio/client",
|
|
60
|
+
namespaceImport: "prismic",
|
|
61
|
+
isTypeOnly: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
62
64
|
const clientModuleDeclaration = sourceFile.addModule({
|
|
63
65
|
name: '"@prismicio/client"',
|
|
64
66
|
hasDeclareKeyword: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTypes.cjs","sources":["../../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { ModuleDeclarationKind, Project } from \"ts-morph\";\n\nimport { addTypeAliasForCustomType } from \"./lib/addTypeAliasForCustomType\";\nimport { addTypeAliasForSharedSlice } from \"./lib/addTypeAliasForSharedSlice\";\nimport { buildTypeName } from \"./lib/buildTypeName\";\nimport { getSourceFileText } from \"./lib/getSourceFileText\";\n\nimport { FieldConfigs } from \"./types\";\n\nimport { BLANK_LINE_IDENTIFIER } from \"./constants\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n};\n\nexport const generateTypes = (config: GenerateTypesConfig = {}) => {\n\tconst project = new Project({\n\t\tuseInMemoryFileSystem: true,\n\t});\n\n\tconst sourceFile = project.createSourceFile(\"types.d.ts\");\n\n\tsourceFile.addImportDeclaration({\n\t\tmoduleSpecifier: config.typesProvider || \"@prismicio/types\",\n\t\tnamespaceImport: \"prismic\",\n\t\tisTypeOnly: true,\n\t});\n\n\tsourceFile.addStatements(BLANK_LINE_IDENTIFIER);\n\n\tconst simplifyTypeAlias = sourceFile.addTypeAlias({\n\t\tname: \"Simplify\",\n\t\ttypeParameters: [\n\t\t\t{\n\t\t\t\tname: \"T\",\n\t\t\t},\n\t\t],\n\t\ttype: `{ [KeyType in keyof T]: T[KeyType] }`,\n\t});\n\n\tif (config.customTypeModels) {\n\t\tfor (const model of config.customTypeModels) {\n\t\t\taddTypeAliasForCustomType({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tlocaleIDs: config.localeIDs || [],\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tsourceFile.addTypeAlias({\n\t\t\t\tname: \"AllDocumentTypes\",\n\t\t\t\ttype: config.customTypeModels\n\t\t\t\t\t.map((customTypeModel) =>\n\t\t\t\t\t\tbuildTypeName(customTypeModel.id, \"Document\"),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\" | \"),\n\t\t\t\tisExported: true,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\taddTypeAliasForSharedSlice({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tsourceFile.addImportDeclaration({\n\t\t\tmoduleSpecifier: \"@prismicio/client\",\n\t\t\tnamespaceImport: \"prismic\",\n\t\t\tisTypeOnly: true,\n\t\t});\n\n\t\tconst clientModuleDeclaration = sourceFile.addModule({\n\t\t\tname: '\"@prismicio/client\"',\n\t\t\thasDeclareKeyword: true,\n\t\t\tdeclarationKind: ModuleDeclarationKind.Module,\n\t\t});\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tclientModuleDeclaration.addInterface({\n\t\t\t\tname: \"CreateClient\",\n\t\t\t\tcallSignatures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"repositoryNameOrEndpoint\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\t\ttype: \"prismic.ClientConfig\",\n\t\t\t\t\t\t\t\thasQuestionToken: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\treturnType:\n\t\t\t\t\t\t\t(config.customTypeModels?.length || 0) > 0\n\t\t\t\t\t\t\t\t? \"prismic.Client<AllDocumentTypes>\"\n\t\t\t\t\t\t\t\t: \"prismic.Client\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tconst contentNamespaceDeclaration = clientModuleDeclaration.addModule({\n\t\t\t\tname: \"Content\",\n\t\t\t\tdeclarationKind: ModuleDeclarationKind.Namespace,\n\t\t\t});\n\n\t\t\tconst exportSymbols = sourceFile\n\t\t\t\t.getExportSymbols()\n\t\t\t\t.filter((exportSymbol) => {\n\t\t\t\t\t// The Simplify utility type should not\n\t\t\t\t\t// be exported, but it is included in\n\t\t\t\t\t// `getExportSymbols()`'s result.\n\t\t\t\t\treturn exportSymbol.getName() !== simplifyTypeAlias.getName();\n\t\t\t\t});\n\n\t\t\tcontentNamespaceDeclaration.addExportDeclaration({\n\t\t\t\tisTypeOnly: true,\n\t\t\t\tnamedExports: exportSymbols.map((exportSymbol) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: exportSymbol.getName(),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn getSourceFileText(sourceFile);\n};\n"],"names":["Project","BLANK_LINE_IDENTIFIER","addTypeAliasForCustomType","buildTypeName","addTypeAliasForSharedSlice","ModuleDeclarationKind","getSourceFileText"],"mappings":";;;;;;;;AA0BO,MAAM,gBAAgB,CAAC,SAA8B,OAAM;;AAC3D,QAAA,UAAU,IAAIA,gBAAQ;AAAA,IAC3B,uBAAuB;AAAA,EAAA,CACvB;AAEK,QAAA,aAAa,QAAQ,iBAAiB,YAAY;AAExD,aAAW,qBAAqB;AAAA,IAC/B,iBAAiB,OAAO,iBAAiB;AAAA,IACzC,iBAAiB;AAAA,IACjB,YAAY;AAAA,EAAA,CACZ;AAED,aAAW,cAAcC,UAAAA,qBAAqB;AAExC,QAAA,oBAAoB,WAAW,aAAa;AAAA,IACjD,MAAM;AAAA,IACN,gBAAgB;AAAA,MACf;AAAA,QACC,MAAM;AAAA,MACN;AAAA,IACD;AAAA,IACD,MAAM;AAAA,EAAA,CACN;AAED,MAAI,OAAO,kBAAkB;AACjB,eAAA,SAAS,OAAO,kBAAkB;AAClBC,0DAAA;AAAA,QACzB;AAAA,QACA;AAAA,QACA,WAAW,OAAO,aAAa,CAAE;AAAA,QACjC,cAAc,OAAO,gBAAgB,CAAE;AAAA,MAAA,CACvC;AAAA,IACD;AAEG,QAAA,OAAO,iBAAiB,SAAS,GAAG;AACvC,iBAAW,aAAa;AAAA,QACvB,MAAM;AAAA,QACN,MAAM,OAAO,iBACX,IAAI,CAAC,oBACLC,cAAAA,cAAc,gBAAgB,IAAI,UAAU,CAAC,EAE7C,KAAK,KAAK;AAAA,QACZ,YAAY;AAAA,MAAA,CACZ;AAAA,IACD;AAAA,EACD;AAED,MAAI,OAAO,mBAAmB;AAClB,eAAA,SAAS,OAAO,mBAAmB;AAClBC,4DAAA;AAAA,QAC1B;AAAA,QACA;AAAA,QACA,cAAc,OAAO,gBAAgB,CAAE;AAAA,MAAA,CACvC;AAAA,IACD;AAAA,EACD;AAED,QACC,YAAO,sBAAP,mBAA0B,mCAC1B,YAAO,sBAAP,mBAA0B,0BACzB;
|
|
1
|
+
{"version":3,"file":"generateTypes.cjs","sources":["../../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { ModuleDeclarationKind, Project } from \"ts-morph\";\n\nimport { addTypeAliasForCustomType } from \"./lib/addTypeAliasForCustomType\";\nimport { addTypeAliasForSharedSlice } from \"./lib/addTypeAliasForSharedSlice\";\nimport { buildTypeName } from \"./lib/buildTypeName\";\nimport { getSourceFileText } from \"./lib/getSourceFileText\";\n\nimport { FieldConfigs } from \"./types\";\n\nimport { BLANK_LINE_IDENTIFIER } from \"./constants\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n};\n\nexport const generateTypes = (config: GenerateTypesConfig = {}) => {\n\tconst project = new Project({\n\t\tuseInMemoryFileSystem: true,\n\t});\n\n\tconst sourceFile = project.createSourceFile(\"types.d.ts\");\n\n\tsourceFile.addImportDeclaration({\n\t\tmoduleSpecifier: config.typesProvider || \"@prismicio/types\",\n\t\tnamespaceImport: \"prismic\",\n\t\tisTypeOnly: true,\n\t});\n\n\tsourceFile.addStatements(BLANK_LINE_IDENTIFIER);\n\n\tconst simplifyTypeAlias = sourceFile.addTypeAlias({\n\t\tname: \"Simplify\",\n\t\ttypeParameters: [\n\t\t\t{\n\t\t\t\tname: \"T\",\n\t\t\t},\n\t\t],\n\t\ttype: `{ [KeyType in keyof T]: T[KeyType] }`,\n\t});\n\n\tif (config.customTypeModels) {\n\t\tfor (const model of config.customTypeModels) {\n\t\t\taddTypeAliasForCustomType({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tlocaleIDs: config.localeIDs || [],\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tsourceFile.addTypeAlias({\n\t\t\t\tname: \"AllDocumentTypes\",\n\t\t\t\ttype: config.customTypeModels\n\t\t\t\t\t.map((customTypeModel) =>\n\t\t\t\t\t\tbuildTypeName(customTypeModel.id, \"Document\"),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\" | \"),\n\t\t\t\tisExported: true,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\taddTypeAliasForSharedSlice({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\t// This import declaration would be a duplicate if the types\n\t\t// provider is @prismicio/client.\n\t\tif (config.typesProvider !== \"@prismicio/client\") {\n\t\t\tsourceFile.addImportDeclaration({\n\t\t\t\tmoduleSpecifier: \"@prismicio/client\",\n\t\t\t\tnamespaceImport: \"prismic\",\n\t\t\t\tisTypeOnly: true,\n\t\t\t});\n\t\t}\n\n\t\tconst clientModuleDeclaration = sourceFile.addModule({\n\t\t\tname: '\"@prismicio/client\"',\n\t\t\thasDeclareKeyword: true,\n\t\t\tdeclarationKind: ModuleDeclarationKind.Module,\n\t\t});\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tclientModuleDeclaration.addInterface({\n\t\t\t\tname: \"CreateClient\",\n\t\t\t\tcallSignatures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"repositoryNameOrEndpoint\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\t\ttype: \"prismic.ClientConfig\",\n\t\t\t\t\t\t\t\thasQuestionToken: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\treturnType:\n\t\t\t\t\t\t\t(config.customTypeModels?.length || 0) > 0\n\t\t\t\t\t\t\t\t? \"prismic.Client<AllDocumentTypes>\"\n\t\t\t\t\t\t\t\t: \"prismic.Client\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tconst contentNamespaceDeclaration = clientModuleDeclaration.addModule({\n\t\t\t\tname: \"Content\",\n\t\t\t\tdeclarationKind: ModuleDeclarationKind.Namespace,\n\t\t\t});\n\n\t\t\tconst exportSymbols = sourceFile\n\t\t\t\t.getExportSymbols()\n\t\t\t\t.filter((exportSymbol) => {\n\t\t\t\t\t// The Simplify utility type should not\n\t\t\t\t\t// be exported, but it is included in\n\t\t\t\t\t// `getExportSymbols()`'s result.\n\t\t\t\t\treturn exportSymbol.getName() !== simplifyTypeAlias.getName();\n\t\t\t\t});\n\n\t\t\tcontentNamespaceDeclaration.addExportDeclaration({\n\t\t\t\tisTypeOnly: true,\n\t\t\t\tnamedExports: exportSymbols.map((exportSymbol) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: exportSymbol.getName(),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn getSourceFileText(sourceFile);\n};\n"],"names":["Project","BLANK_LINE_IDENTIFIER","addTypeAliasForCustom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
|
if (((_a = config.clientIntegration) == null ? void 0 : _a.includeCreateClientInterface) || ((_b = config.clientIntegration) == null ? void 0 : _b.includeContentNamespace)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
if (config.typesProvider !== "@prismicio/client") {
|
|
56
|
+
sourceFile.addImportDeclaration({
|
|
57
|
+
moduleSpecifier: "@prismicio/client",
|
|
58
|
+
namespaceImport: "prismic",
|
|
59
|
+
isTypeOnly: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
60
62
|
const clientModuleDeclaration = sourceFile.addModule({
|
|
61
63
|
name: '"@prismicio/client"',
|
|
62
64
|
hasDeclareKeyword: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTypes.js","sources":["../../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { ModuleDeclarationKind, Project } from \"ts-morph\";\n\nimport { addTypeAliasForCustomType } from \"./lib/addTypeAliasForCustomType\";\nimport { addTypeAliasForSharedSlice } from \"./lib/addTypeAliasForSharedSlice\";\nimport { buildTypeName } from \"./lib/buildTypeName\";\nimport { getSourceFileText } from \"./lib/getSourceFileText\";\n\nimport { FieldConfigs } from \"./types\";\n\nimport { BLANK_LINE_IDENTIFIER } from \"./constants\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n};\n\nexport const generateTypes = (config: GenerateTypesConfig = {}) => {\n\tconst project = new Project({\n\t\tuseInMemoryFileSystem: true,\n\t});\n\n\tconst sourceFile = project.createSourceFile(\"types.d.ts\");\n\n\tsourceFile.addImportDeclaration({\n\t\tmoduleSpecifier: config.typesProvider || \"@prismicio/types\",\n\t\tnamespaceImport: \"prismic\",\n\t\tisTypeOnly: true,\n\t});\n\n\tsourceFile.addStatements(BLANK_LINE_IDENTIFIER);\n\n\tconst simplifyTypeAlias = sourceFile.addTypeAlias({\n\t\tname: \"Simplify\",\n\t\ttypeParameters: [\n\t\t\t{\n\t\t\t\tname: \"T\",\n\t\t\t},\n\t\t],\n\t\ttype: `{ [KeyType in keyof T]: T[KeyType] }`,\n\t});\n\n\tif (config.customTypeModels) {\n\t\tfor (const model of config.customTypeModels) {\n\t\t\taddTypeAliasForCustomType({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tlocaleIDs: config.localeIDs || [],\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tsourceFile.addTypeAlias({\n\t\t\t\tname: \"AllDocumentTypes\",\n\t\t\t\ttype: config.customTypeModels\n\t\t\t\t\t.map((customTypeModel) =>\n\t\t\t\t\t\tbuildTypeName(customTypeModel.id, \"Document\"),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\" | \"),\n\t\t\t\tisExported: true,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\taddTypeAliasForSharedSlice({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tsourceFile.addImportDeclaration({\n\t\t\tmoduleSpecifier: \"@prismicio/client\",\n\t\t\tnamespaceImport: \"prismic\",\n\t\t\tisTypeOnly: true,\n\t\t});\n\n\t\tconst clientModuleDeclaration = sourceFile.addModule({\n\t\t\tname: '\"@prismicio/client\"',\n\t\t\thasDeclareKeyword: true,\n\t\t\tdeclarationKind: ModuleDeclarationKind.Module,\n\t\t});\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tclientModuleDeclaration.addInterface({\n\t\t\t\tname: \"CreateClient\",\n\t\t\t\tcallSignatures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"repositoryNameOrEndpoint\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\t\ttype: \"prismic.ClientConfig\",\n\t\t\t\t\t\t\t\thasQuestionToken: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\treturnType:\n\t\t\t\t\t\t\t(config.customTypeModels?.length || 0) > 0\n\t\t\t\t\t\t\t\t? \"prismic.Client<AllDocumentTypes>\"\n\t\t\t\t\t\t\t\t: \"prismic.Client\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tconst contentNamespaceDeclaration = clientModuleDeclaration.addModule({\n\t\t\t\tname: \"Content\",\n\t\t\t\tdeclarationKind: ModuleDeclarationKind.Namespace,\n\t\t\t});\n\n\t\t\tconst exportSymbols = sourceFile\n\t\t\t\t.getExportSymbols()\n\t\t\t\t.filter((exportSymbol) => {\n\t\t\t\t\t// The Simplify utility type should not\n\t\t\t\t\t// be exported, but it is included in\n\t\t\t\t\t// `getExportSymbols()`'s result.\n\t\t\t\t\treturn exportSymbol.getName() !== simplifyTypeAlias.getName();\n\t\t\t\t});\n\n\t\t\tcontentNamespaceDeclaration.addExportDeclaration({\n\t\t\t\tisTypeOnly: true,\n\t\t\t\tnamedExports: exportSymbols.map((exportSymbol) => {\n\t\t\t\t\treturn {\n\t\t\t\t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A0B,0BACzB;
|
|
1
|
+
{"version":3,"file":"generateTypes.js","sources":["../../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { ModuleDeclarationKind, Project } from \"ts-morph\";\n\nimport { addTypeAliasForCustomType } from \"./lib/addTypeAliasForCustomType\";\nimport { addTypeAliasForSharedSlice } from \"./lib/addTypeAliasForSharedSlice\";\nimport { buildTypeName } from \"./lib/buildTypeName\";\nimport { getSourceFileText } from \"./lib/getSourceFileText\";\n\nimport { FieldConfigs } from \"./types\";\n\nimport { BLANK_LINE_IDENTIFIER } from \"./constants\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n};\n\nexport const generateTypes = (config: GenerateTypesConfig = {}) => {\n\tconst project = new Project({\n\t\tuseInMemoryFileSystem: true,\n\t});\n\n\tconst sourceFile = project.createSourceFile(\"types.d.ts\");\n\n\tsourceFile.addImportDeclaration({\n\t\tmoduleSpecifier: config.typesProvider || \"@prismicio/types\",\n\t\tnamespaceImport: \"prismic\",\n\t\tisTypeOnly: true,\n\t});\n\n\tsourceFile.addStatements(BLANK_LINE_IDENTIFIER);\n\n\tconst simplifyTypeAlias = sourceFile.addTypeAlias({\n\t\tname: \"Simplify\",\n\t\ttypeParameters: [\n\t\t\t{\n\t\t\t\tname: \"T\",\n\t\t\t},\n\t\t],\n\t\ttype: `{ [KeyType in keyof T]: T[KeyType] }`,\n\t});\n\n\tif (config.customTypeModels) {\n\t\tfor (const model of config.customTypeModels) {\n\t\t\taddTypeAliasForCustomType({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tlocaleIDs: config.localeIDs || [],\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tsourceFile.addTypeAlias({\n\t\t\t\tname: \"AllDocumentTypes\",\n\t\t\t\ttype: config.customTypeModels\n\t\t\t\t\t.map((customTypeModel) =>\n\t\t\t\t\t\tbuildTypeName(customTypeModel.id, \"Document\"),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\" | \"),\n\t\t\t\tisExported: true,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\taddTypeAliasForSharedSlice({\n\t\t\t\tmodel,\n\t\t\t\tsourceFile,\n\t\t\t\tfieldConfigs: config.fieldConfigs || {},\n\t\t\t});\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\t// This import declaration would be a duplicate if the types\n\t\t// provider is @prismicio/client.\n\t\tif (config.typesProvider !== \"@prismicio/client\") {\n\t\t\tsourceFile.addImportDeclaration({\n\t\t\t\tmoduleSpecifier: \"@prismicio/client\",\n\t\t\t\tnamespaceImport: \"prismic\",\n\t\t\t\tisTypeOnly: true,\n\t\t\t});\n\t\t}\n\n\t\tconst clientModuleDeclaration = sourceFile.addModule({\n\t\t\tname: '\"@prismicio/client\"',\n\t\t\thasDeclareKeyword: true,\n\t\t\tdeclarationKind: ModuleDeclarationKind.Module,\n\t\t});\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tclientModuleDeclaration.addInterface({\n\t\t\t\tname: \"CreateClient\",\n\t\t\t\tcallSignatures: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"repositoryNameOrEndpoint\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"options\",\n\t\t\t\t\t\t\t\ttype: \"prismic.ClientConfig\",\n\t\t\t\t\t\t\t\thasQuestionToken: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\treturnType:\n\t\t\t\t\t\t\t(config.customTypeModels?.length || 0) > 0\n\t\t\t\t\t\t\t\t? \"prismic.Client<AllDocumentTypes>\"\n\t\t\t\t\t\t\t\t: \"prismic.Client\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tconst contentNamespaceDeclaration = clientModuleDeclaration.addModule({\n\t\t\t\tname: \"Content\",\n\t\t\t\tdeclarationKind: ModuleDeclarationKind.Namespace,\n\t\t\t});\n\n\t\t\tconst exportSymbols = sourceFile\n\t\t\t\t.getExportSymbols()\n\t\t\t\t.filter((exportSymbol) => {\n\t\t\t\t\t// The Simplify utility type should not\n\t\t\t\t\t// be exported, but it is included in\n\t\t\t\t\t// `getExportSymbols()`'s result.\n\t\t\t\t\treturn exportSymbol.getName() !== simplifyTypeAlias.getName();\n\t\t\t\t});\n\n\t\t\tcontentNamespaceDeclaration.addExportDeclaration({\n\t\t\t\tisTypeOnly: true,\n\t\t\t\tnamedExports: exportSymbols.map((exportSymbol) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: exportSymbol.getName(),\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn getSourceFileText(sourceFile);\n};\n"],"names":[],"mappings":";;;;;;AA0BO,MAAM,gBAAgB,CAAC,SAA8B,OAAM;;AAC3D,QAAA,UAAU,IAAI,QAAQ;AAAA,IAC3B,uBAAuB;AAAA,EAAA,CACvB;AAEK,QAAA,aAAa,QAAQ,iBAAiB,YAAY;AAExD,aAAW,qBAAqB;AAAA,IAC/B,iBAAiB,OAAO,iBAAiB;AAA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AAM;AAAA,QACN,gBAAgB;AAAA,UACf;AAAA,YACC,YAAY;AAAA,cACX;AAAA,gBACC,MAAM;AAAA,gBACN,MAAM;AAAA,cACN;AAAA,cACD;AAAA,gBACC,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,kBAAkB;AAAA,cAClB;AAAA,YACD;AAAA,YACD,eACE,YAAO,qBAAP,mBAAyB,WAAU,KAAK,IACtC,qCACA;AAAA,UACJ;AAAA,QACD;AAAA,MAAA,CACD;AAAA,IACD;AAEG,QAAA,OAAO,kBAAkB,yBAAyB;AAC/C,YAAA,8BAA8B,wBAAwB,UAAU;AAAA,QACrE,MAAM;AAAA,QACN,iBAAiB,sBAAsB;AAAA,MAAA,CACvC;AAED,YAAM,gBAAgB,WACpB,iBACA,EAAA,OAAO,CAAC,iBAAgB;AAIxB,eAAO,aAAa,QAAA,MAAc,kBAAkB,QAAO;AAAA,MAAA,CAC3D;AAEF,kCAA4B,qBAAqB;AAAA,QAChD,YAAY;AAAA,QACZ,cAAc,cAAc,IAAI,CAAC,iBAAgB;AACzC,iBAAA;AAAA,YACN,MAAM,aAAa,QAAS;AAAA,UAAA;AAAA,SAE7B;AAAA,MAAA,CACD;AAAA,IACD;AAAA,EACD;AAED,SAAO,kBAAkB,UAAU;AACpC;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const prismic = require("@prismicio/client");
|
|
4
3
|
const buildFieldDocs = require("./buildFieldDocs.cjs");
|
|
5
4
|
const buildSharedSliceInterfaceNamePart = require("./buildSharedSliceInterfaceNamePart.cjs");
|
|
6
5
|
const buildTypeName = require("./buildTypeName.cjs");
|
|
@@ -126,7 +125,7 @@ const addInterfacePropertyForField = (config) => {
|
|
|
126
125
|
}
|
|
127
126
|
case "Link": {
|
|
128
127
|
switch ((_h = config.model.config) == null ? void 0 : _h.select) {
|
|
129
|
-
case
|
|
128
|
+
case "document": {
|
|
130
129
|
config.model.config;
|
|
131
130
|
config.interface.addProperty({
|
|
132
131
|
name: config.id,
|
|
@@ -140,7 +139,7 @@ const addInterfacePropertyForField = (config) => {
|
|
|
140
139
|
});
|
|
141
140
|
break;
|
|
142
141
|
}
|
|
143
|
-
case
|
|
142
|
+
case "media": {
|
|
144
143
|
config.interface.addProperty({
|
|
145
144
|
name: config.id,
|
|
146
145
|
type: "prismic.LinkToMediaField",
|
|
@@ -315,9 +314,9 @@ const addInterfacePropertyForField = (config) => {
|
|
|
315
314
|
if ((_m = config.model.config) == null ? void 0 : _m.choices) {
|
|
316
315
|
for (const choiceId in config.model.config.choices) {
|
|
317
316
|
const choice = config.model.config.choices[choiceId];
|
|
318
|
-
if (choice.type ===
|
|
317
|
+
if (choice.type === "SharedSlice") {
|
|
319
318
|
choiceInterfaceNames.push(buildSharedSliceInterfaceNamePart.buildSharedSliceInterfaceNamePart({ id: choiceId }));
|
|
320
|
-
} else if (choice.type ===
|
|
319
|
+
} else if (choice.type === "Slice") {
|
|
321
320
|
let primaryInterface;
|
|
322
321
|
if (choice["non-repeat"] && Object.keys(choice["non-repeat"]).length > 0) {
|
|
323
322
|
primaryInterface = config.sourceFile.addInterface({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addInterfacePropertiesForFields.cjs","sources":["../../../src/lib/addInterfacePropertiesForFields.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\nimport {\n\tCustomTypeModelLinkSelectType,\n\tCustomTypeModelSliceType,\n} from \"@prismicio/client\";\nimport type { InterfaceDeclaration, SourceFile } from \"ts-morph\";\n\nimport { FieldConfigs, PathElement } from \"../types\";\n\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildSharedSliceInterfaceNamePart } from \"./buildSharedSliceInterfaceNamePart\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { getHumanReadableFieldPath } from \"./getHumanReadableFieldPath\";\n\ntype AddInterfacePropertyFromFieldConfig = {\n\tid: string;\n\tmodel: CustomTypeModelField;\n\tinterface: InterfaceDeclaration;\n\tsourceFile: SourceFile;\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\nconst addInterfacePropertyForField = (\n\tconfig: AddInterfacePropertyFromFieldConfig,\n) => {\n\tswitch (config.model.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.BooleanField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.ColorField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.DateField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\tconfig.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype:\n\t\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t\t? `prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypes.join(\n\t\t\t\t\t\t\t\t\" | \",\n\t\t\t\t\t\t )})>`\n\t\t\t\t\t\t: \"prismic.EmbedField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.GeoPointField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\tconfig.model.config?.thumbnails &&\n\t\t\t\tconfig.model.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = config.model.config.thumbnails\n\t\t\t\t\t.map((thumbnail) => `\"${thumbnail.name}\"`)\n\t\t\t\t\t.join(\" | \");\n\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.ImageField<${thumbnailNames}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.ImageField<never>\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = config.model.config?.catalog\n\t\t\t\t? config.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\tconfig.model.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: catalogType\n\t\t\t\t\t? `prismic.IntegrationFields<${catalogType}>`\n\t\t\t\t\t: \"prismic.IntegrationFields\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase CustomTypeModelLinkSelectType.Document: {\n\t\t\t\t\tconfig.model.config;\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\"customtypes\" in config.model.config &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes.length > 0\n\t\t\t\t\t\t\t\t? `prismic.RelationField<${config.model.config.customtypes\n\t\t\t\t\t\t\t\t\t\t.map((type) => `\"${type}\"`)\n\t\t\t\t\t\t\t\t\t\t.join(\" | \")}>`\n\t\t\t\t\t\t\t\t: \"prismic.RelationField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CustomTypeModelLinkSelectType.Media: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkToMediaField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.NumberField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.TitleField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.RichTextField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options = config.model.config?.options\n\t\t\t\t?.map((option) => `\"${option}\"`)\n\t\t\t\t.join(\" | \");\n\t\t\tconst hasDefault = Boolean(config.model.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options || \"string\"}, \"filled\">`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.KeyTextField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.TimestampField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemInterface = config.sourceFile.addInterface({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Item\",\n\t\t\t\t),\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tisExported: true,\n\t\t\t});\n\n\t\t\tif (config.model.config?.fields) {\n\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\tfields: config.model.config.fields,\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.GroupField<Simplify<${itemInterface.getName()}>>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceInterfaceNames: string[] = [];\n\n\t\t\tif (config.model.config?.choices) {\n\t\t\t\tfor (const choiceId in config.model.config.choices) {\n\t\t\t\t\tconst choice = config.model.config.choices[choiceId];\n\n\t\t\t\t\tif (choice.type === CustomTypeModelSliceType.SharedSlice) {\n\t\t\t\t\t\tchoiceInterfaceNames.push(\n\t\t\t\t\t\t\tbuildSharedSliceInterfaceNamePart({ id: choiceId }),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (choice.type === CustomTypeModelSliceType.Slice) {\n\t\t\t\t\t\tlet primaryInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Primary\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(\n\t\t\t\t\t\t\t\t\t\t\t\t`Primary content in ${humanReadablePath}`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: primaryInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Item\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliceType = config.sourceFile.addTypeAlias({\n\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttype: `prismic.Slice<\"${choiceId}\", ${\n\t\t\t\t\t\t\t\tprimaryInterface\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterface.getName()}>`\n\t\t\t\t\t\t\t\t\t: \"Record<string, never>\"\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterface ? `Simplify<${itemInterface.getName()}>` : \"never\"\n\t\t\t\t\t\t\t}>`,\n\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceInterfaceNames.push(sliceType.getName());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst slicesType = config.sourceFile.addTypeAlias({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Slice\",\n\t\t\t\t),\n\t\t\t\ttype:\n\t\t\t\t\tchoiceInterfaceNames.length > 0\n\t\t\t\t\t\t? choiceInterfaceNames.join(\" | \")\n\t\t\t\t\t\t: \"never\",\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Slice for *${humanReadablePath}*`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.SliceZone<${slicesType.getName()}>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"unknown\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n};\n\ntype AddInterfacePropertiesForFieldsConfig = Omit<\n\tAddInterfacePropertyFromFieldConfig,\n\t\"id\" | \"model\"\n> & {\n\tfields: Record<string, AddInterfacePropertyFromFieldConfig[\"model\"]>;\n\ttabName?: string;\n};\n\nexport const addInterfacePropertiesForFields = (\n\tconfig: AddInterfacePropertiesForFieldsConfig,\n) => {\n\tfor (const name in config.fields) {\n\t\taddInterfacePropertyForField({\n\t\t\t...config,\n\t\t\tid:\n\t\t\t\tname.includes(\"-\") || name.includes(\":\") || /^[0-9]/.test(name)\n\t\t\t\t\t? `\"${name}\"`\n\t\t\t\t\t: name,\n\t\t\tmodel: config.fields[name],\n\t\t\ttabName: config.tabName,\n\t\t});\n\t}\n};\n"],"names":["buildFieldDocs","CustomTypeModelLinkSelectType","buildTypeName","getHumanReadableFieldPath","CustomTypeModelSliceType","buildSharedSliceInterfaceNamePart"],"mappings":";;;;;;;AAgCA,MAAM,+BAA+B,CACpC,WACG;;AACK,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,OAAO;AAEX;AAAA,IACA;AAAA,IAED,KAAK,WAAW;AACf,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAMA,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,KAAK,SAAS;AACb,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAMA,eAAAA,eAAe;AAAA,UACpB,IAAI,O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V;AAAA,oBACC,IAAI,OAAO;AAAA,oBACX,OAAO,OAAO;AAAA,kBACd;AAAA,gBACD;AAAA,cAAA,CACD;AAEM,qBAAA,UAAU,cAAc,oBAAoB;AAAA,YACpD;AAAA,UACA;AAAA,QACD;AAAA,MAAA,CACD;AAED,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM,qBAAqB,WAAW;QACtC,MAAMH,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,SAAS;AACR,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAMA,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAAA,IACD;AAAA,EACD;AACF;AAUa,MAAA,kCAAkC,CAC9C,WACG;AACQ,aAAA,QAAQ,OAAO,QAAQ;AACJ,iCAAA;AAAA,MAC5B,GAAG;AAAA,MACH,IACC,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,SAAS,KAAK,IAAI,IAC3D,IAAI,UACJ;AAAA,MACJ,OAAO,OAAO,OAAO,IAAI;AAAA,MACzB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,EACD;AACF;;"}
|
|
1
|
+
{"version":3,"file":"addInterfacePropertiesForFields.cjs","sources":["../../../src/lib/addInterfacePropertiesForFields.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\nimport type { InterfaceDeclaration, SourceFile } from \"ts-morph\";\n\nimport { FieldConfigs, PathElement } from \"../types\";\n\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildSharedSliceInterfaceNamePart } from \"./buildSharedSliceInterfaceNamePart\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { getHumanReadableFieldPath } from \"./getHumanReadableFieldPath\";\n\ntype AddInterfacePropertyFromFieldConfig = {\n\tid: string;\n\tmodel: CustomTypeModelField;\n\tinterface: InterfaceDeclaration;\n\tsourceFile: SourceFile;\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\nconst addInterfacePropertyForField = (\n\tconfig: AddInterfacePropertyFromFieldConfig,\n) => {\n\tswitch (config.model.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.BooleanField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.ColorField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.DateField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\tconfig.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype:\n\t\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t\t? `prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypes.join(\n\t\t\t\t\t\t\t\t\" | \",\n\t\t\t\t\t\t )})>`\n\t\t\t\t\t\t: \"prismic.EmbedField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.GeoPointField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\tconfig.model.config?.thumbnails &&\n\t\t\t\tconfig.model.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = config.model.config.thumbnails\n\t\t\t\t\t.map((thumbnail) => `\"${thumbnail.name}\"`)\n\t\t\t\t\t.join(\" | \");\n\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.ImageField<${thumbnailNames}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.ImageField<never>\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = config.model.config?.catalog\n\t\t\t\t? config.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\tconfig.model.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: catalogType\n\t\t\t\t\t? `prismic.IntegrationFields<${catalogType}>`\n\t\t\t\t\t: \"prismic.IntegrationFields\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\tconfig.model.config;\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\"customtypes\" in config.model.config &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes.length > 0\n\t\t\t\t\t\t\t\t? `prismic.RelationField<${config.model.config.customtypes\n\t\t\t\t\t\t\t\t\t\t.map((type) => `\"${type}\"`)\n\t\t\t\t\t\t\t\t\t\t.join(\" | \")}>`\n\t\t\t\t\t\t\t\t: \"prismic.RelationField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkToMediaField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.NumberField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.TitleField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.RichTextField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options = config.model.config?.options\n\t\t\t\t?.map((option) => `\"${option}\"`)\n\t\t\t\t.join(\" | \");\n\t\t\tconst hasDefault = Boolean(config.model.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options || \"string\"}, \"filled\">`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.KeyTextField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.TimestampField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemInterface = config.sourceFile.addInterface({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Item\",\n\t\t\t\t),\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tisExported: true,\n\t\t\t});\n\n\t\t\tif (config.model.config?.fields) {\n\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\tfields: config.model.config.fields,\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.GroupField<Simplify<${itemInterface.getName()}>>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceInterfaceNames: string[] = [];\n\n\t\t\tif (config.model.config?.choices) {\n\t\t\t\tfor (const choiceId in config.model.config.choices) {\n\t\t\t\t\tconst choice = config.model.config.choices[choiceId];\n\n\t\t\t\t\tif (choice.type === \"SharedSlice\") {\n\t\t\t\t\t\tchoiceInterfaceNames.push(\n\t\t\t\t\t\t\tbuildSharedSliceInterfaceNamePart({ id: choiceId }),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (choice.type === \"Slice\") {\n\t\t\t\t\t\tlet primaryInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Primary\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(\n\t\t\t\t\t\t\t\t\t\t\t\t`Primary content in ${humanReadablePath}`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: primaryInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Item\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliceType = config.sourceFile.addTypeAlias({\n\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttype: `prismic.Slice<\"${choiceId}\", ${\n\t\t\t\t\t\t\t\tprimaryInterface\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterface.getName()}>`\n\t\t\t\t\t\t\t\t\t: \"Record<string, never>\"\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterface ? `Simplify<${itemInterface.getName()}>` : \"never\"\n\t\t\t\t\t\t\t}>`,\n\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceInterfaceNames.push(sliceType.getName());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst slicesType = config.sourceFile.addTypeAlias({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Slice\",\n\t\t\t\t),\n\t\t\t\ttype:\n\t\t\t\t\tchoiceInterfaceNames.length > 0\n\t\t\t\t\t\t? choiceInterfaceNames.join(\" | \")\n\t\t\t\t\t\t: \"never\",\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Slice for *${humanReadablePath}*`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.SliceZone<${slicesType.getName()}>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"unknown\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n};\n\ntype AddInterfacePropertiesForFieldsConfig = Omit<\n\tAddInterfacePropertyFromFieldConfig,\n\t\"id\" | \"model\"\n> & {\n\tfields: Record<string, AddInterfacePropertyFromFieldConfig[\"model\"]>;\n\ttabName?: string;\n};\n\nexport const addInterfacePropertiesForFields = (\n\tconfig: AddInterfacePropertiesForFieldsConfig,\n) => {\n\tfor (const name in config.fields) {\n\t\taddInterfacePropertyForField({\n\t\t\t...config,\n\t\t\tid:\n\t\t\t\tname.includes(\"-\") || name.includes(\":\") || /^[0-9]/.test(name)\n\t\t\t\t\t? `\"${name}\"`\n\t\t\t\t\t: name,\n\t\t\tmodel: config.fields[name],\n\t\t\ttabName: config.tabName,\n\t\t});\n\t}\n};\n"],"names":["buildFieldDocs","buildTypeName","getHumanReadableFieldPath","buildSharedSliceInterfaceNamePart"],"mappings":";;;;;;AA4BA,MAAM,+BAA+B,CACpC,WACG;;AACK,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,OAAO;AAEX;AAAA,IACA;AAAA,IAED,KAAK,WAAW;AACf,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAMA,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,KAAK,SAAS;AACb,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;A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IAAI,OAAO;AAAA,oBACX,OAAO,OAAO;AAAA,kBACd;AAAA,gBACD;AAAA,cAAA,CACD;AAEM,qBAAA,UAAU,cAAc,oBAAoB;AAAA,YACpD;AAAA,UACA;AAAA,QACD;AAAA,MAAA,CACD;AAED,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM,qBAAqB,WAAW;QACtC,MAAMF,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,SAAS;AACR,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAMA,eAAAA,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAAA,IACD;AAAA,EACD;AACF;AAUa,MAAA,kCAAkC,CAC9C,WACG;AACQ,aAAA,QAAQ,OAAO,QAAQ;AACJ,iCAAA;AAAA,MAC5B,GAAG;AAAA,MACH,IACC,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,SAAS,KAAK,IAAI,IAC3D,IAAI,UACJ;AAAA,MACJ,OAAO,OAAO,OAAO,IAAI;AAAA,MACzB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,EACD;AACF;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomTypeModelSliceType, CustomTypeModelLinkSelectType } from "@prismicio/client";
|
|
2
1
|
import { buildFieldDocs } from "./buildFieldDocs.js";
|
|
3
2
|
import { buildSharedSliceInterfaceNamePart } from "./buildSharedSliceInterfaceNamePart.js";
|
|
4
3
|
import { buildTypeName } from "./buildTypeName.js";
|
|
@@ -124,7 +123,7 @@ const addInterfacePropertyForField = (config) => {
|
|
|
124
123
|
}
|
|
125
124
|
case "Link": {
|
|
126
125
|
switch ((_h = config.model.config) == null ? void 0 : _h.select) {
|
|
127
|
-
case
|
|
126
|
+
case "document": {
|
|
128
127
|
config.model.config;
|
|
129
128
|
config.interface.addProperty({
|
|
130
129
|
name: config.id,
|
|
@@ -138,7 +137,7 @@ const addInterfacePropertyForField = (config) => {
|
|
|
138
137
|
});
|
|
139
138
|
break;
|
|
140
139
|
}
|
|
141
|
-
case
|
|
140
|
+
case "media": {
|
|
142
141
|
config.interface.addProperty({
|
|
143
142
|
name: config.id,
|
|
144
143
|
type: "prismic.LinkToMediaField",
|
|
@@ -313,9 +312,9 @@ const addInterfacePropertyForField = (config) => {
|
|
|
313
312
|
if ((_m = config.model.config) == null ? void 0 : _m.choices) {
|
|
314
313
|
for (const choiceId in config.model.config.choices) {
|
|
315
314
|
const choice = config.model.config.choices[choiceId];
|
|
316
|
-
if (choice.type ===
|
|
315
|
+
if (choice.type === "SharedSlice") {
|
|
317
316
|
choiceInterfaceNames.push(buildSharedSliceInterfaceNamePart({ id: choiceId }));
|
|
318
|
-
} else if (choice.type ===
|
|
317
|
+
} else if (choice.type === "Slice") {
|
|
319
318
|
let primaryInterface;
|
|
320
319
|
if (choice["non-repeat"] && Object.keys(choice["non-repeat"]).length > 0) {
|
|
321
320
|
primaryInterface = config.sourceFile.addInterface({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addInterfacePropertiesForFields.js","sources":["../../../src/lib/addInterfacePropertiesForFields.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\nimport {\n\tCustomTypeModelLinkSelectType,\n\tCustomTypeModelSliceType,\n} from \"@prismicio/client\";\nimport type { InterfaceDeclaration, SourceFile } from \"ts-morph\";\n\nimport { FieldConfigs, PathElement } from \"../types\";\n\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildSharedSliceInterfaceNamePart } from \"./buildSharedSliceInterfaceNamePart\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { getHumanReadableFieldPath } from \"./getHumanReadableFieldPath\";\n\ntype AddInterfacePropertyFromFieldConfig = {\n\tid: string;\n\tmodel: CustomTypeModelField;\n\tinterface: InterfaceDeclaration;\n\tsourceFile: SourceFile;\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\nconst addInterfacePropertyForField = (\n\tconfig: AddInterfacePropertyFromFieldConfig,\n) => {\n\tswitch (config.model.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.BooleanField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.ColorField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.DateField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\tconfig.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype:\n\t\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t\t? `prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypes.join(\n\t\t\t\t\t\t\t\t\" | \",\n\t\t\t\t\t\t )})>`\n\t\t\t\t\t\t: \"prismic.EmbedField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.GeoPointField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\tconfig.model.config?.thumbnails &&\n\t\t\t\tconfig.model.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = config.model.config.thumbnails\n\t\t\t\t\t.map((thumbnail) => `\"${thumbnail.name}\"`)\n\t\t\t\t\t.join(\" | \");\n\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.ImageField<${thumbnailNames}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.ImageField<never>\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = config.model.config?.catalog\n\t\t\t\t? config.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\tconfig.model.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: catalogType\n\t\t\t\t\t? `prismic.IntegrationFields<${catalogType}>`\n\t\t\t\t\t: \"prismic.IntegrationFields\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase CustomTypeModelLinkSelectType.Document: {\n\t\t\t\t\tconfig.model.config;\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\"customtypes\" in config.model.config &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes.length > 0\n\t\t\t\t\t\t\t\t? `prismic.RelationField<${config.model.config.customtypes\n\t\t\t\t\t\t\t\t\t\t.map((type) => `\"${type}\"`)\n\t\t\t\t\t\t\t\t\t\t.join(\" | \")}>`\n\t\t\t\t\t\t\t\t: \"prismic.RelationField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CustomTypeModelLinkSelectType.Media: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkToMediaField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.NumberField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.TitleField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.RichTextField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options = config.model.config?.options\n\t\t\t\t?.map((option) => `\"${option}\"`)\n\t\t\t\t.join(\" | \");\n\t\t\tconst hasDefault = Boolean(config.model.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options || \"string\"}, \"filled\">`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.KeyTextField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.TimestampField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemInterface = config.sourceFile.addInterface({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Item\",\n\t\t\t\t),\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tisExported: true,\n\t\t\t});\n\n\t\t\tif (config.model.config?.fields) {\n\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\tfields: config.model.config.fields,\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.GroupField<Simplify<${itemInterface.getName()}>>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceInterfaceNames: string[] = [];\n\n\t\t\tif (config.model.config?.choices) {\n\t\t\t\tfor (const choiceId in config.model.config.choices) {\n\t\t\t\t\tconst choice = config.model.config.choices[choiceId];\n\n\t\t\t\t\tif (choice.type === CustomTypeModelSliceType.SharedSlice) {\n\t\t\t\t\t\tchoiceInterfaceNames.push(\n\t\t\t\t\t\t\tbuildSharedSliceInterfaceNamePart({ id: choiceId }),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (choice.type === CustomTypeModelSliceType.Slice) {\n\t\t\t\t\t\tlet primaryInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Primary\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(\n\t\t\t\t\t\t\t\t\t\t\t\t`Primary content in ${humanReadablePath}`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: primaryInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Item\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliceType = config.sourceFile.addTypeAlias({\n\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttype: `prismic.Slice<\"${choiceId}\", ${\n\t\t\t\t\t\t\t\tprimaryInterface\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterface.getName()}>`\n\t\t\t\t\t\t\t\t\t: \"Record<string, never>\"\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterface ? `Simplify<${itemInterface.getName()}>` : \"never\"\n\t\t\t\t\t\t\t}>`,\n\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceInterfaceNames.push(sliceType.getName());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst slicesType = config.sourceFile.addTypeAlias({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Slice\",\n\t\t\t\t),\n\t\t\t\ttype:\n\t\t\t\t\tchoiceInterfaceNames.length > 0\n\t\t\t\t\t\t? choiceInterfaceNames.join(\" | \")\n\t\t\t\t\t\t: \"never\",\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Slice for *${humanReadablePath}*`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.SliceZone<${slicesType.getName()}>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"unknown\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n};\n\ntype AddInterfacePropertiesForFieldsConfig = Omit<\n\tAddInterfacePropertyFromFieldConfig,\n\t\"id\" | \"model\"\n> & {\n\tfields: Record<string, AddInterfacePropertyFromFieldConfig[\"model\"]>;\n\ttabName?: string;\n};\n\nexport const addInterfacePropertiesForFields = (\n\tconfig: AddInterfacePropertiesForFieldsConfig,\n) => {\n\tfor (const name in config.fields) {\n\t\taddInterfacePropertyForField({\n\t\t\t...config,\n\t\t\tid:\n\t\t\t\tname.includes(\"-\") || name.includes(\":\") || /^[0-9]/.test(name)\n\t\t\t\t\t? `\"${name}\"`\n\t\t\t\t\t: name,\n\t\t\tmodel: config.fields[name],\n\t\t\ttabName: config.tabName,\n\t\t});\n\t}\n};\n"],"names":[],"mappings":";;;;;AAgCA,MAAM,+BAA+B,CACpC,WACG;;AACK,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,OAAO;AAEX;AAAA,IACA;AAAA,IAED,KAAK,WAAW;AACf,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,KAAK,SAAS;AACb,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI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ACtC,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,SAAS;AACR,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAAA,IACD;AAAA,EACD;AACF;AAUa,MAAA,kCAAkC,CAC9C,WACG;AACQ,aAAA,QAAQ,OAAO,QAAQ;AACJ,iCAAA;AAAA,MAC5B,GAAG;AAAA,MACH,IACC,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,SAAS,KAAK,IAAI,IAC3D,IAAI,UACJ;AAAA,MACJ,OAAO,OAAO,OAAO,IAAI;AAAA,MACzB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,EACD;AACF;"}
|
|
1
|
+
{"version":3,"file":"addInterfacePropertiesForFields.js","sources":["../../../src/lib/addInterfacePropertiesForFields.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\nimport type { InterfaceDeclaration, SourceFile } from \"ts-morph\";\n\nimport { FieldConfigs, PathElement } from \"../types\";\n\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildSharedSliceInterfaceNamePart } from \"./buildSharedSliceInterfaceNamePart\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { getHumanReadableFieldPath } from \"./getHumanReadableFieldPath\";\n\ntype AddInterfacePropertyFromFieldConfig = {\n\tid: string;\n\tmodel: CustomTypeModelField;\n\tinterface: InterfaceDeclaration;\n\tsourceFile: SourceFile;\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\nconst addInterfacePropertyForField = (\n\tconfig: AddInterfacePropertyFromFieldConfig,\n) => {\n\tswitch (config.model.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.BooleanField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.ColorField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.DateField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in config.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\tconfig.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype:\n\t\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t\t? `prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypes.join(\n\t\t\t\t\t\t\t\t\" | \",\n\t\t\t\t\t\t )})>`\n\t\t\t\t\t\t: \"prismic.EmbedField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.GeoPointField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\tconfig.model.config?.thumbnails &&\n\t\t\t\tconfig.model.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = config.model.config.thumbnails\n\t\t\t\t\t.map((thumbnail) => `\"${thumbnail.name}\"`)\n\t\t\t\t\t.join(\" | \");\n\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.ImageField<${thumbnailNames}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.ImageField<never>\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = config.model.config?.catalog\n\t\t\t\t? config.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\tconfig.model.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: catalogType\n\t\t\t\t\t? `prismic.IntegrationFields<${catalogType}>`\n\t\t\t\t\t: \"prismic.IntegrationFields\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\tconfig.model.config;\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\"customtypes\" in config.model.config &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes &&\n\t\t\t\t\t\t\tconfig.model.config.customtypes.length > 0\n\t\t\t\t\t\t\t\t? `prismic.RelationField<${config.model.config.customtypes\n\t\t\t\t\t\t\t\t\t\t.map((type) => `\"${type}\"`)\n\t\t\t\t\t\t\t\t\t\t.join(\" | \")}>`\n\t\t\t\t\t\t\t\t: \"prismic.RelationField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkToMediaField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\t\tname: config.id,\n\t\t\t\t\t\ttype: \"prismic.LinkField\",\n\t\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.NumberField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.TitleField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: \"prismic.RichTextField\",\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options = config.model.config?.options\n\t\t\t\t?.map((option) => `\"${option}\"`)\n\t\t\t\t.join(\" | \");\n\t\t\tconst hasDefault = Boolean(config.model.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options || \"string\"}, \"filled\">`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconfig.interface.addProperty({\n\t\t\t\t\tname: config.id,\n\t\t\t\t\ttype: `prismic.SelectField<${options}>`,\n\t\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\tpath: config.path,\n\t\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.KeyTextField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"prismic.TimestampField\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemInterface = config.sourceFile.addInterface({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Item\",\n\t\t\t\t),\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tisExported: true,\n\t\t\t});\n\n\t\t\tif (config.model.config?.fields) {\n\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\tfields: config.model.config.fields,\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.GroupField<Simplify<${itemInterface.getName()}>>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceInterfaceNames: string[] = [];\n\n\t\t\tif (config.model.config?.choices) {\n\t\t\t\tfor (const choiceId in config.model.config.choices) {\n\t\t\t\t\tconst choice = config.model.config.choices[choiceId];\n\n\t\t\t\t\tif (choice.type === \"SharedSlice\") {\n\t\t\t\t\t\tchoiceInterfaceNames.push(\n\t\t\t\t\t\t\tbuildSharedSliceInterfaceNamePart({ id: choiceId }),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (choice.type === \"Slice\") {\n\t\t\t\t\t\tlet primaryInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Primary\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(\n\t\t\t\t\t\t\t\t\t\t\t\t`Primary content in ${humanReadablePath}`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: primaryInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"primary\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterface: InterfaceDeclaration | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterface = config.sourceFile.addInterface({\n\t\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t\t\t\"Item\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tdocs: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\twriter.writeLine(`Item in ${humanReadablePath}`);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\taddInterfacePropertiesForFields({\n\t\t\t\t\t\t\t\tinterface: itemInterface,\n\t\t\t\t\t\t\t\tsourceFile: config.sourceFile,\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: choiceId,\n\t\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"items\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tfieldConfigs: config.fieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sliceType = config.sourceFile.addTypeAlias({\n\t\t\t\t\t\t\tname: buildTypeName(\n\t\t\t\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\t\tconfig.id,\n\t\t\t\t\t\t\t\tchoiceId,\n\t\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttype: `prismic.Slice<\"${choiceId}\", ${\n\t\t\t\t\t\t\t\tprimaryInterface\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterface.getName()}>`\n\t\t\t\t\t\t\t\t\t: \"Record<string, never>\"\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterface ? `Simplify<${itemInterface.getName()}>` : \"never\"\n\t\t\t\t\t\t\t}>`,\n\t\t\t\t\t\t\tisExported: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceInterfaceNames.push(sliceType.getName());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst slicesType = config.sourceFile.addTypeAlias({\n\t\t\t\tname: buildTypeName(\n\t\t\t\t\tconfig.path[0].id,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\tconfig.id,\n\t\t\t\t\t\"Slice\",\n\t\t\t\t),\n\t\t\t\ttype:\n\t\t\t\t\tchoiceInterfaceNames.length > 0\n\t\t\t\t\t\t? choiceInterfaceNames.join(\" | \")\n\t\t\t\t\t\t: \"never\",\n\t\t\t\tdocs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: (writer) => {\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadableFieldPath({\n\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t...config.path,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: config.id,\n\t\t\t\t\t\t\t\t\t\tmodel: config.model,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\twriter.writeLine(`Slice for *${humanReadablePath}*`);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: `prismic.SliceZone<${slicesType.getName()}>`,\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tconfig.interface.addProperty({\n\t\t\t\tname: config.id,\n\t\t\t\ttype: \"unknown\",\n\t\t\t\tdocs: buildFieldDocs({\n\t\t\t\t\tid: config.id,\n\t\t\t\t\tmodel: config.model,\n\t\t\t\t\tpath: config.path,\n\t\t\t\t\ttabName: config.tabName,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t}\n};\n\ntype AddInterfacePropertiesForFieldsConfig = Omit<\n\tAddInterfacePropertyFromFieldConfig,\n\t\"id\" | \"model\"\n> & {\n\tfields: Record<string, AddInterfacePropertyFromFieldConfig[\"model\"]>;\n\ttabName?: string;\n};\n\nexport const addInterfacePropertiesForFields = (\n\tconfig: AddInterfacePropertiesForFieldsConfig,\n) => {\n\tfor (const name in config.fields) {\n\t\taddInterfacePropertyForField({\n\t\t\t...config,\n\t\t\tid:\n\t\t\t\tname.includes(\"-\") || name.includes(\":\") || /^[0-9]/.test(name)\n\t\t\t\t\t? `\"${name}\"`\n\t\t\t\t\t: name,\n\t\t\tmodel: config.fields[name],\n\t\t\ttabName: config.tabName,\n\t\t});\n\t}\n};\n"],"names":[],"mappings":";;;;AA4BA,MAAM,+BAA+B,CACpC,WACG;;AACK,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,OAAO;AAEX;AAAA,IACA;AAAA,IAED,KAAK,WAAW;AACf,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,KAAK,SAAS;AACb,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAED;AAAA,IACA;AAAA,IAED,KAAK,QAAQ;AACZ,aAAO,UAAU,YAAY;AAAA,QAC5B,MAAM,OAAO;AAAA,QACb,MAAM;AAAA,QACN,MAAM,eAAe;AAAA,UACpB,IAAI,OAAO;AAAA,UACX,OAAO,OAAO;AAAA,UACd,MAAM,OA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UACb,SAAS,OAAO;AAAA,QAAA,CAChB;AAAA,MAAA,CACD;AAAA,IACD;AAAA,EACD;AACF;AAUa,MAAA,kCAAkC,CAC9C,WACG;AACQ,aAAA,QAAQ,OAAO,QAAQ;AACJ,iCAAA;AAAA,MAC5B,GAAG;AAAA,MACH,IACC,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,SAAS,KAAK,IAAI,IAC3D,IAAI,UACJ;AAAA,MACJ,OAAO,OAAO,OAAO,IAAI;AAAA,MACzB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,EACD;AACF;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const prismic = require("@prismicio/client");
|
|
4
3
|
const isCustomTypeModelField = require("./isCustomTypeModelField.cjs");
|
|
5
4
|
const isCustomTypeModelSlice = require("./isCustomTypeModelSlice.cjs");
|
|
6
5
|
const isSharedSliceModel = require("./isSharedSliceModel.cjs");
|
|
7
6
|
const getAPIIDPath = (config) => {
|
|
8
7
|
return config.path.map((element, i) => {
|
|
9
|
-
if (isCustomTypeModelField.isCustomTypeModelField(element.model) && (element.model.type ===
|
|
8
|
+
if (isCustomTypeModelField.isCustomTypeModelField(element.model) && (element.model.type === "Group" || element.model.type === "Slices")) {
|
|
10
9
|
return `${element.id}[]`;
|
|
11
10
|
} else {
|
|
12
11
|
if (element.id === "items") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAPIIDPath.cjs","sources":["../../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"getAPIIDPath.cjs","sources":["../../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\n\nimport { PathElement } from \"../types\";\n\nimport { isCustomTypeModelField } from \"./isCustomTypeModelField\";\nimport { isCustomTypeModelSlice } from \"./isCustomTypeModelSlice\";\nimport { isSharedSliceModel } from \"./isSharedSliceModel\";\n\ntype GetAPIIDPathConfig = {\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n};\n\nexport const getAPIIDPath = (config: GetAPIIDPathConfig): string => {\n\treturn config.path\n\t\t.map((element, i) => {\n\t\t\tif (\n\t\t\t\tisCustomTypeModelField(element.model) &&\n\t\t\t\t(element.model.type === \"Group\" || element.model.type === \"Slices\")\n\t\t\t) {\n\t\t\t\treturn `${element.id}[]`;\n\t\t\t} else {\n\t\t\t\tif (element.id === \"items\") {\n\t\t\t\t\tconst previousElement = config.path[i - 1];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tisCustomTypeModelSlice(previousElement.model) ||\n\t\t\t\t\t\tisSharedSliceModel(previousElement.model)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn `${element.id}[]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn element.id;\n\t\t\t}\n\t\t})\n\t\t.join(\".\");\n};\n"],"names":["isCustomTypeModelField","isCustomTypeModelSlice","isSharedSliceModel"],"mappings":";;;;;AAoBa,MAAA,eAAe,CAAC,WAAsC;AAClE,SAAO,OAAO,KACZ,IAAI,CAAC,SAAS,MAAK;AAElB,QAAAA,uBAAA,uBAAuB,QAAQ,KAAK,MACnC,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,WACzD;AACD,aAAO,GAAG,QAAQ;AAAA,IAAA,OACZ;AACF,UAAA,QAAQ,OAAO,SAAS;AAC3B,cAAM,kBAAkB,OAAO,KAAK,IAAI,CAAC;AAEzC,YACCC,uBAAAA,uBAAuB,gBAAgB,KAAK,KAC5CC,mBAAAA,mBAAmB,gBAAgB,KAAK,GACvC;AACD,iBAAO,GAAG,QAAQ;AAAA,QAClB;AAAA,MACD;AAED,aAAO,QAAQ;AAAA,IACf;AAAA,EAAA,CACD,EACA,KAAK,GAAG;AACX;;"}
|
package/dist/lib/getAPIIDPath.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CustomTypeModelFieldType } from "@prismicio/client";
|
|
2
1
|
import { isCustomTypeModelField } from "./isCustomTypeModelField.js";
|
|
3
2
|
import { isCustomTypeModelSlice } from "./isCustomTypeModelSlice.js";
|
|
4
3
|
import { isSharedSliceModel } from "./isSharedSliceModel.js";
|
|
5
4
|
const getAPIIDPath = (config) => {
|
|
6
5
|
return config.path.map((element, i) => {
|
|
7
|
-
if (isCustomTypeModelField(element.model) && (element.model.type ===
|
|
6
|
+
if (isCustomTypeModelField(element.model) && (element.model.type === "Group" || element.model.type === "Slices")) {
|
|
8
7
|
return `${element.id}[]`;
|
|
9
8
|
} else {
|
|
10
9
|
if (element.id === "items") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAPIIDPath.js","sources":["../../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"getAPIIDPath.js","sources":["../../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\n\nimport { PathElement } from \"../types\";\n\nimport { isCustomTypeModelField } from \"./isCustomTypeModelField\";\nimport { isCustomTypeModelSlice } from \"./isCustomTypeModelSlice\";\nimport { isSharedSliceModel } from \"./isSharedSliceModel\";\n\ntype GetAPIIDPathConfig = {\n\tpath: [\n\t\tPathElement<CustomTypeModel | SharedSliceModel>,\n\t\t...PathElement<CustomTypeModelField | CustomTypeModelSlice>[],\n\t];\n};\n\nexport const getAPIIDPath = (config: GetAPIIDPathConfig): string => {\n\treturn config.path\n\t\t.map((element, i) => {\n\t\t\tif (\n\t\t\t\tisCustomTypeModelField(element.model) &&\n\t\t\t\t(element.model.type === \"Group\" || element.model.type === \"Slices\")\n\t\t\t) {\n\t\t\t\treturn `${element.id}[]`;\n\t\t\t} else {\n\t\t\t\tif (element.id === \"items\") {\n\t\t\t\t\tconst previousElement = config.path[i - 1];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tisCustomTypeModelSlice(previousElement.model) ||\n\t\t\t\t\t\tisSharedSliceModel(previousElement.model)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn `${element.id}[]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn element.id;\n\t\t\t}\n\t\t})\n\t\t.join(\".\");\n};\n"],"names":[],"mappings":";;;AAoBa,MAAA,eAAe,CAAC,WAAsC;AAClE,SAAO,OAAO,KACZ,IAAI,CAAC,SAAS,MAAK;AAElB,QAAA,uBAAuB,QAAQ,KAAK,MACnC,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,WACzD;AACD,aAAO,GAAG,QAAQ;AAAA,IAAA,OACZ;AACF,UAAA,QAAQ,OAAO,SAAS;AAC3B,cAAM,kBAAkB,OAAO,KAAK,IAAI,CAAC;AAEzC,YACC,uBAAuB,gBAAgB,KAAK,KAC5C,mBAAmB,gBAAgB,KAAK,GACvC;AACD,iBAAO,GAAG,QAAQ;AAAA,QAClB;AAAA,MACD;AAED,aAAO,QAAQ;AAAA,IACf;AAAA,EAAA,CACD,EACA,KAAK,GAAG;AACX;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const prismic = require("@prismicio/client");
|
|
4
3
|
const getHumanReadableFieldType = (config) => {
|
|
5
4
|
var _a, _b;
|
|
6
5
|
switch (config.model.type) {
|
|
@@ -14,10 +13,10 @@ const getHumanReadableFieldType = (config) => {
|
|
|
14
13
|
}
|
|
15
14
|
case "Link": {
|
|
16
15
|
switch ((_b = config.model.config) == null ? void 0 : _b.select) {
|
|
17
|
-
case
|
|
16
|
+
case "document": {
|
|
18
17
|
return "Content Relationship";
|
|
19
18
|
}
|
|
20
|
-
case
|
|
19
|
+
case "media": {
|
|
21
20
|
return "Link to Media";
|
|
22
21
|
}
|
|
23
22
|
default: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHumanReadableFieldType.cjs","sources":["../../../src/lib/getHumanReadableFieldType.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"getHumanReadableFieldType.cjs","sources":["../../../src/lib/getHumanReadableFieldType.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\n\ntype GetFieldHumanReadableTypeConfig = {\n\tmodel: CustomTypeModelField;\n};\n\nexport const getHumanReadableFieldType = (\n\tconfig: GetFieldHumanReadableTypeConfig,\n): string => {\n\tswitch (config.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\treturn isTitleField ? \"Title\" : \"Rich Text\";\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalog = config.model.config?.catalog;\n\n\t\t\treturn `Integration Fields (Catalog: ${\n\t\t\t\tcatalog ? `\\`${catalog}\\`` : \"*unknown*\"\n\t\t\t})`;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\treturn \"Content Relationship\";\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\treturn \"Link to Media\";\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn \"Link\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\treturn \"Slice Zone\";\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn config.model.type;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAMa,MAAA,4BAA4B,CACxC,WACW;;AACH,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,kBAAkB;AAChB,YAAA,eACL,OAAO,MAAM,UACb,YAAY,OAAO,MAAM,UACzB,OAAO,MAAM,OAAO,UACpB,OAAO,MAAM,OAAO,OAClB,MAAM,GAAG,EACT,MAAM,CAAC,cAAc,UAAU,KAAK,SAAS,CAAC;AAEjD,aAAO,eAAe,UAAU;AAAA,IAChC;AAAA,IAED,KAAK,qBAAqB;AACnB,YAAA,WAAU,YAAO,MAAM,WAAb,mBAAqB;AAE9B,aAAA,gCACN,UAAU,KAAK,cAAc;AAAA,IAE9B;AAAA,IAED,KAAK,QAAQ;AACJ,eAAA,YAAO,MAAM,WAAb,mBAAqB,QAAQ;AAAA,QACpC,KAAK,YAAY;AACT,iBAAA;AAAA,QACP;AAAA,QAED,KAAK,SAAS;AACN,iBAAA;AAAA,QACP;AAAA,QAED,SAAS;AACD,iBAAA;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IAED,KAAK,UAAU;AACP,aAAA;AAAA,IACP;AAAA,IAED,SAAS;AACR,aAAO,OAAO,MAAM;AAAA,IACpB;AAAA,EACD;AACF;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomTypeModelLinkSelectType } from "@prismicio/client";
|
|
2
1
|
const getHumanReadableFieldType = (config) => {
|
|
3
2
|
var _a, _b;
|
|
4
3
|
switch (config.model.type) {
|
|
@@ -12,10 +11,10 @@ const getHumanReadableFieldType = (config) => {
|
|
|
12
11
|
}
|
|
13
12
|
case "Link": {
|
|
14
13
|
switch ((_b = config.model.config) == null ? void 0 : _b.select) {
|
|
15
|
-
case
|
|
14
|
+
case "document": {
|
|
16
15
|
return "Content Relationship";
|
|
17
16
|
}
|
|
18
|
-
case
|
|
17
|
+
case "media": {
|
|
19
18
|
return "Link to Media";
|
|
20
19
|
}
|
|
21
20
|
default: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHumanReadableFieldType.js","sources":["../../../src/lib/getHumanReadableFieldType.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"getHumanReadableFieldType.js","sources":["../../../src/lib/getHumanReadableFieldType.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\n\ntype GetFieldHumanReadableTypeConfig = {\n\tmodel: CustomTypeModelField;\n};\n\nexport const getHumanReadableFieldType = (\n\tconfig: GetFieldHumanReadableTypeConfig,\n): string => {\n\tswitch (config.model.type) {\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\tconfig.model.config &&\n\t\t\t\t\"single\" in config.model.config &&\n\t\t\t\tconfig.model.config.single &&\n\t\t\t\tconfig.model.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\treturn isTitleField ? \"Title\" : \"Rich Text\";\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalog = config.model.config?.catalog;\n\n\t\t\treturn `Integration Fields (Catalog: ${\n\t\t\t\tcatalog ? `\\`${catalog}\\`` : \"*unknown*\"\n\t\t\t})`;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (config.model.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\treturn \"Content Relationship\";\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\treturn \"Link to Media\";\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn \"Link\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\treturn \"Slice Zone\";\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn config.model.type;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":"AAMa,MAAA,4BAA4B,CACxC,WACW;AAFC;AAGJ,UAAA,OAAO,MAAM,MAAM;AAAA,IAC1B,KAAK,kBAAkB;AAChB,YAAA,eACL,OAAO,MAAM,UACb,YAAY,OAAO,MAAM,UACzB,OAAO,MAAM,OAAO,UACpB,OAAO,MAAM,OAAO,OAClB,MAAM,GAAG,EACT,MAAM,CAAC,cAAc,UAAU,KAAK,SAAS,CAAC;AAEjD,aAAO,eAAe,UAAU;AAAA,IAChC;AAAA,IAED,KAAK,qBAAqB;AACnB,YAAA,WAAU,YAAO,MAAM,WAAb,mBAAqB;AAE9B,aAAA,gCACN,UAAU,KAAK,cAAc;AAAA,IAE9B;AAAA,IAED,KAAK,QAAQ;AACJ,eAAA,YAAO,MAAM,WAAb,mBAAqB,QAAQ;AAAA,QACpC,KAAK,YAAY;AACT,iBAAA;AAAA,QACP;AAAA,QAED,KAAK,SAAS;AACN,iBAAA;AAAA,QACP;AAAA,QAED,SAAS;AACD,iBAAA;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IAED,KAAK,UAAU;AACP,aAAA;AAAA,IACP;AAAA,IAED,SAAS;AACR,aAAO,OAAO,MAAM;AAAA,IACpB;AAAA,EACD;AACF;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const prismic = require("@prismicio/client");
|
|
4
3
|
const hasOwnProperty = require("./hasOwnProperty.cjs");
|
|
5
4
|
const isCustomTypeModelSlice = (model) => {
|
|
6
|
-
return typeof model === "object" && model !== null && hasOwnProperty.hasOwnProperty(model, "type") && model.type ===
|
|
5
|
+
return typeof model === "object" && model !== null && hasOwnProperty.hasOwnProperty(model, "type") && model.type === "Slice";
|
|
7
6
|
};
|
|
8
7
|
exports.isCustomTypeModelSlice = isCustomTypeModelSlice;
|
|
9
8
|
//# sourceMappingURL=isCustomTypeModelSlice.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCustomTypeModelSlice.cjs","sources":["../../../src/lib/isCustomTypeModelSlice.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"isCustomTypeModelSlice.cjs","sources":["../../../src/lib/isCustomTypeModelSlice.ts"],"sourcesContent":["import type { CustomTypeModelSlice } from \"@prismicio/client\";\n\nimport { hasOwnProperty } from \"./hasOwnProperty\";\n\nexport const isCustomTypeModelSlice = (\n\tmodel: unknown,\n): model is CustomTypeModelSlice => {\n\treturn (\n\t\ttypeof model === \"object\" &&\n\t\tmodel !== null &&\n\t\thasOwnProperty(model, \"type\") &&\n\t\tmodel.type === \"Slice\"\n\t);\n};\n"],"names":["hasOwnProperty"],"mappings":";;;AAIa,MAAA,yBAAyB,CACrC,UACkC;AAEjC,SAAA,OAAO,UAAU,YACjB,UAAU,QACVA,eAAAA,eAAe,OAAO,MAAM,KAC5B,MAAM,SAAS;AAEjB;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CustomTypeModelSlice } from "@prismicio/client";
|
|
1
|
+
import type { CustomTypeModelSlice } from "@prismicio/client";
|
|
2
2
|
export declare const isCustomTypeModelSlice: (model: unknown) => model is CustomTypeModelSlice<Record<string, import("@prismicio/client").CustomTypeModelFieldForGroup>, Record<string, import("@prismicio/client").CustomTypeModelFieldForGroup>>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CustomTypeModelSliceType } from "@prismicio/client";
|
|
2
1
|
import { hasOwnProperty } from "./hasOwnProperty.js";
|
|
3
2
|
const isCustomTypeModelSlice = (model) => {
|
|
4
|
-
return typeof model === "object" && model !== null && hasOwnProperty(model, "type") && model.type ===
|
|
3
|
+
return typeof model === "object" && model !== null && hasOwnProperty(model, "type") && model.type === "Slice";
|
|
5
4
|
};
|
|
6
5
|
export {
|
|
7
6
|
isCustomTypeModelSlice
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCustomTypeModelSlice.js","sources":["../../../src/lib/isCustomTypeModelSlice.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"isCustomTypeModelSlice.js","sources":["../../../src/lib/isCustomTypeModelSlice.ts"],"sourcesContent":["import type { CustomTypeModelSlice } from \"@prismicio/client\";\n\nimport { hasOwnProperty } from \"./hasOwnProperty\";\n\nexport const isCustomTypeModelSlice = (\n\tmodel: unknown,\n): model is CustomTypeModelSlice => {\n\treturn (\n\t\ttypeof model === \"object\" &&\n\t\tmodel !== null &&\n\t\thasOwnProperty(model, \"type\") &&\n\t\tmodel.type === \"Slice\"\n\t);\n};\n"],"names":[],"mappings":";AAIa,MAAA,yBAAyB,CACrC,UACkC;AAEjC,SAAA,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,OAAO,MAAM,KAC5B,MAAM,SAAS;AAEjB;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const prismic = require("@prismicio/client");
|
|
4
3
|
const hasOwnProperty = require("./hasOwnProperty.cjs");
|
|
5
4
|
const isSharedSliceModel = (model) => {
|
|
6
|
-
return typeof model === "object" && model !== null && hasOwnProperty.hasOwnProperty(model, "type") && model.type ===
|
|
5
|
+
return typeof model === "object" && model !== null && hasOwnProperty.hasOwnProperty(model, "type") && model.type === "SharedSlice";
|
|
7
6
|
};
|
|
8
7
|
exports.isSharedSliceModel = isSharedSliceModel;
|
|
9
8
|
//# sourceMappingURL=isSharedSliceModel.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSharedSliceModel.cjs","sources":["../../../src/lib/isSharedSliceModel.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"isSharedSliceModel.cjs","sources":["../../../src/lib/isSharedSliceModel.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\n\nimport { hasOwnProperty } from \"./hasOwnProperty\";\n\nexport const isSharedSliceModel = (\n\tmodel: unknown,\n): model is SharedSliceModel => {\n\treturn (\n\t\ttypeof model === \"object\" &&\n\t\tmodel !== null &&\n\t\thasOwnProperty(model, \"type\") &&\n\t\tmodel.type === \"SharedSlice\"\n\t);\n};\n"],"names":["hasOwnProperty"],"mappings":";;;AAIa,MAAA,qBAAqB,CACjC,UAC8B;AAE7B,SAAA,OAAO,UAAU,YACjB,UAAU,QACVA,eAAAA,eAAe,OAAO,MAAM,KAC5B,MAAM,SAAS;AAEjB;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SharedSliceModel } from "@prismicio/client";
|
|
1
|
+
import type { SharedSliceModel } from "@prismicio/client";
|
|
2
2
|
export declare const isSharedSliceModel: (model: unknown) => model is SharedSliceModel<string, import("@prismicio/client").SharedSliceModelVariation<string, Record<string, import("@prismicio/client").CustomTypeModelFieldForGroup>, Record<string, import("@prismicio/client").CustomTypeModelFieldForGroup>>>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CustomTypeModelSliceType } from "@prismicio/client";
|
|
2
1
|
import { hasOwnProperty } from "./hasOwnProperty.js";
|
|
3
2
|
const isSharedSliceModel = (model) => {
|
|
4
|
-
return typeof model === "object" && model !== null && hasOwnProperty(model, "type") && model.type ===
|
|
3
|
+
return typeof model === "object" && model !== null && hasOwnProperty(model, "type") && model.type === "SharedSlice";
|
|
5
4
|
};
|
|
6
5
|
export {
|
|
7
6
|
isSharedSliceModel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSharedSliceModel.js","sources":["../../../src/lib/isSharedSliceModel.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"isSharedSliceModel.js","sources":["../../../src/lib/isSharedSliceModel.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\n\nimport { hasOwnProperty } from \"./hasOwnProperty\";\n\nexport const isSharedSliceModel = (\n\tmodel: unknown,\n): model is SharedSliceModel => {\n\treturn (\n\t\ttypeof model === \"object\" &&\n\t\tmodel !== null &&\n\t\thasOwnProperty(model, \"type\") &&\n\t\tmodel.type === \"SharedSlice\"\n\t);\n};\n"],"names":[],"mappings":";AAIa,MAAA,qBAAqB,CACjC,UAC8B;AAE7B,SAAA,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,OAAO,MAAM,KAC5B,MAAM,SAAS;AAEjB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismic-ts-codegen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "An experimental Prismic model-to-TypeScript-type generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@prismicio/custom-types-client": "^1.1.0",
|
|
51
|
-
"@prismicio/client": "^7.0.0",
|
|
52
51
|
"common-tags": "^1.8.2",
|
|
53
52
|
"fast-glob": "^3.2.12",
|
|
54
53
|
"jiti": "^1.18.2",
|
|
@@ -60,6 +59,7 @@
|
|
|
60
59
|
"ts-morph": "^18.0.0"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
62
|
+
"@prismicio/client": "^7.0.0",
|
|
63
63
|
"@prismicio/mock": "^0.2.0",
|
|
64
64
|
"@prismicio/types": "^0.2.0",
|
|
65
65
|
"@size-limit/preset-small-lib": "^8.2.4",
|
package/src/cli/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ const cli = meow(
|
|
|
28
28
|
flags: {
|
|
29
29
|
config: {
|
|
30
30
|
type: "string",
|
|
31
|
-
|
|
31
|
+
shortFlag: "c",
|
|
32
32
|
isRequired: false,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
@@ -44,7 +44,7 @@ const main = async () => {
|
|
|
44
44
|
} else {
|
|
45
45
|
let contents = "";
|
|
46
46
|
|
|
47
|
-
if (existsSync("sm.json")) {
|
|
47
|
+
if (existsSync("slicemachine.config.json") || existsSync("sm.json")) {
|
|
48
48
|
contents = stripIndent`
|
|
49
49
|
import type { Config } from "prismic-ts-codegen";
|
|
50
50
|
|
|
@@ -17,7 +17,9 @@ export type DetectTypesProviderConfig = {
|
|
|
17
17
|
export const detectTypesProvider = async (
|
|
18
18
|
config: DetectTypesProviderConfig = {},
|
|
19
19
|
): Promise<TypesProvider | undefined> => {
|
|
20
|
-
const
|
|
20
|
+
const cwd = config.cwd || process.cwd();
|
|
21
|
+
|
|
22
|
+
const require = createRequire(cwd.endsWith("/") ? cwd : cwd + "/");
|
|
21
23
|
|
|
22
24
|
try {
|
|
23
25
|
if (
|
package/src/generateTypes.ts
CHANGED
|
@@ -86,11 +86,15 @@ export const generateTypes = (config: GenerateTypesConfig = {}) => {
|
|
|
86
86
|
config.clientIntegration?.includeCreateClientInterface ||
|
|
87
87
|
config.clientIntegration?.includeContentNamespace
|
|
88
88
|
) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
// This import declaration would be a duplicate if the types
|
|
90
|
+
// provider is @prismicio/client.
|
|
91
|
+
if (config.typesProvider !== "@prismicio/client") {
|
|
92
|
+
sourceFile.addImportDeclaration({
|
|
93
|
+
moduleSpecifier: "@prismicio/client",
|
|
94
|
+
namespaceImport: "prismic",
|
|
95
|
+
isTypeOnly: true,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
94
98
|
|
|
95
99
|
const clientModuleDeclaration = sourceFile.addModule({
|
|
96
100
|
name: '"@prismicio/client"',
|
|
@@ -4,10 +4,6 @@ import type {
|
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
6
|
} from "@prismicio/client";
|
|
7
|
-
import {
|
|
8
|
-
CustomTypeModelLinkSelectType,
|
|
9
|
-
CustomTypeModelSliceType,
|
|
10
|
-
} from "@prismicio/client";
|
|
11
7
|
import type { InterfaceDeclaration, SourceFile } from "ts-morph";
|
|
12
8
|
|
|
13
9
|
import { FieldConfigs, PathElement } from "../types";
|
|
@@ -192,7 +188,7 @@ const addInterfacePropertyForField = (
|
|
|
192
188
|
|
|
193
189
|
case "Link": {
|
|
194
190
|
switch (config.model.config?.select) {
|
|
195
|
-
case
|
|
191
|
+
case "document": {
|
|
196
192
|
config.model.config;
|
|
197
193
|
config.interface.addProperty({
|
|
198
194
|
name: config.id,
|
|
@@ -215,7 +211,7 @@ const addInterfacePropertyForField = (
|
|
|
215
211
|
break;
|
|
216
212
|
}
|
|
217
213
|
|
|
218
|
-
case
|
|
214
|
+
case "media": {
|
|
219
215
|
config.interface.addProperty({
|
|
220
216
|
name: config.id,
|
|
221
217
|
type: "prismic.LinkToMediaField",
|
|
@@ -427,11 +423,11 @@ const addInterfacePropertyForField = (
|
|
|
427
423
|
for (const choiceId in config.model.config.choices) {
|
|
428
424
|
const choice = config.model.config.choices[choiceId];
|
|
429
425
|
|
|
430
|
-
if (choice.type ===
|
|
426
|
+
if (choice.type === "SharedSlice") {
|
|
431
427
|
choiceInterfaceNames.push(
|
|
432
428
|
buildSharedSliceInterfaceNamePart({ id: choiceId }),
|
|
433
429
|
);
|
|
434
|
-
} else if (choice.type ===
|
|
430
|
+
} else if (choice.type === "Slice") {
|
|
435
431
|
let primaryInterface: InterfaceDeclaration | undefined;
|
|
436
432
|
if (
|
|
437
433
|
choice["non-repeat"] &&
|
package/src/lib/getAPIIDPath.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
6
|
} from "@prismicio/client";
|
|
7
|
-
import { CustomTypeModelFieldType } from "@prismicio/client";
|
|
8
7
|
|
|
9
8
|
import { PathElement } from "../types";
|
|
10
9
|
|
|
@@ -24,8 +23,7 @@ export const getAPIIDPath = (config: GetAPIIDPathConfig): string => {
|
|
|
24
23
|
.map((element, i) => {
|
|
25
24
|
if (
|
|
26
25
|
isCustomTypeModelField(element.model) &&
|
|
27
|
-
(element.model.type ===
|
|
28
|
-
element.model.type === CustomTypeModelFieldType.Slices)
|
|
26
|
+
(element.model.type === "Group" || element.model.type === "Slices")
|
|
29
27
|
) {
|
|
30
28
|
return `${element.id}[]`;
|
|
31
29
|
} else {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CustomTypeModelField } from "@prismicio/client";
|
|
2
|
-
import { CustomTypeModelLinkSelectType } from "@prismicio/client";
|
|
3
2
|
|
|
4
3
|
type GetFieldHumanReadableTypeConfig = {
|
|
5
4
|
model: CustomTypeModelField;
|
|
@@ -31,11 +30,11 @@ export const getHumanReadableFieldType = (
|
|
|
31
30
|
|
|
32
31
|
case "Link": {
|
|
33
32
|
switch (config.model.config?.select) {
|
|
34
|
-
case
|
|
33
|
+
case "document": {
|
|
35
34
|
return "Content Relationship";
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
case
|
|
37
|
+
case "media": {
|
|
39
38
|
return "Link to Media";
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CustomTypeModelSlice,
|
|
3
|
-
CustomTypeModelSliceType,
|
|
4
|
-
} from "@prismicio/client";
|
|
1
|
+
import type { CustomTypeModelSlice } from "@prismicio/client";
|
|
5
2
|
|
|
6
3
|
import { hasOwnProperty } from "./hasOwnProperty";
|
|
7
4
|
|
|
@@ -12,6 +9,6 @@ export const isCustomTypeModelSlice = (
|
|
|
12
9
|
typeof model === "object" &&
|
|
13
10
|
model !== null &&
|
|
14
11
|
hasOwnProperty(model, "type") &&
|
|
15
|
-
model.type ===
|
|
12
|
+
model.type === "Slice"
|
|
16
13
|
);
|
|
17
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SharedSliceModel } from "@prismicio/client";
|
|
2
2
|
|
|
3
3
|
import { hasOwnProperty } from "./hasOwnProperty";
|
|
4
4
|
|
|
@@ -9,6 +9,6 @@ export const isSharedSliceModel = (
|
|
|
9
9
|
typeof model === "object" &&
|
|
10
10
|
model !== null &&
|
|
11
11
|
hasOwnProperty(model, "type") &&
|
|
12
|
-
model.type ===
|
|
12
|
+
model.type === "SharedSlice"
|
|
13
13
|
);
|
|
14
14
|
};
|