prismic-ts-codegen 0.1.29 → 0.1.30-pr.82.96148f3
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.js +1 -1
- package/dist/cli/{configSchema.d.ts → configSchema.d.mts} +3 -5
- package/dist/cli/configSchema.d.mts.map +1 -0
- package/dist/cli/configSchema.mjs +154 -0
- package/dist/cli/configSchema.mjs.map +1 -0
- package/dist/cli/constants.d.mts +4 -0
- package/dist/cli/constants.d.mts.map +1 -0
- package/dist/cli/{constants.js → constants.mjs} +1 -1
- package/dist/cli/{constants.cjs.map → constants.mjs.map} +1 -1
- package/dist/cli/loadConfig.mjs +20 -0
- package/dist/cli/loadConfig.mjs.map +1 -0
- package/dist/cli/{loadLocaleIDs.js → loadLocaleIDs.mjs} +1 -2
- package/dist/cli/loadLocaleIDs.mjs.map +1 -0
- package/dist/cli/{loadModels.js → loadModels.mjs} +14 -11
- package/dist/cli/loadModels.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{cli.js → cli.mjs} +51 -25
- package/dist/cli.mjs.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/{constants.cjs.map → constants.mjs.map} +1 -1
- package/dist/detectTypesProvider.d.mts +15 -0
- package/dist/detectTypesProvider.d.mts.map +1 -0
- package/dist/{detectTypesProvider.js → detectTypesProvider.mjs} +1 -1
- package/dist/{detectTypesProvider.cjs.map → detectTypesProvider.mjs.map} +1 -1
- package/dist/{generateTypes.d.ts → generateTypes.d.mts} +5 -7
- package/dist/generateTypes.d.mts.map +1 -0
- package/dist/{generateTypes.js → generateTypes.mjs} +21 -18
- package/dist/generateTypes.mjs.map +1 -0
- package/dist/{index.d.cts → index.d.mts} +4 -4
- package/dist/index.mjs +4 -0
- package/dist/lib/{addBlankLine.js → addBlankLine.mjs} +2 -2
- package/dist/lib/addBlankLine.mjs.map +1 -0
- package/dist/lib/{addLine.js → addLine.mjs} +2 -2
- package/dist/lib/addLine.mjs.map +1 -0
- package/dist/lib/{addSection.js → addSection.mjs} +2 -2
- package/dist/lib/addSection.mjs.map +1 -0
- package/dist/lib/{addTrailingNewLine.js → addTrailingNewLine.mjs} +1 -1
- package/dist/lib/{addTrailingNewLine.cjs.map → addTrailingNewLine.mjs.map} +1 -1
- package/dist/lib/{buildCustomTypeDataType.js → buildCustomTypeDataType.mjs} +6 -6
- package/dist/lib/buildCustomTypeDataType.mjs.map +1 -0
- package/dist/lib/{buildCustomTypeType.js → buildCustomTypeType.mjs} +11 -11
- package/dist/lib/buildCustomTypeType.mjs.map +1 -0
- package/dist/lib/{buildFieldDocs.js → buildFieldDocs.mjs} +15 -10
- package/dist/lib/buildFieldDocs.mjs.map +1 -0
- package/dist/lib/{buildFieldProperties.js → buildFieldProperties.mjs} +25 -21
- package/dist/lib/buildFieldProperties.mjs.map +1 -0
- package/dist/lib/{buildSharedSliceType.js → buildSharedSliceType.mjs} +19 -19
- package/dist/lib/buildSharedSliceType.mjs.map +1 -0
- package/dist/lib/buildTypeName.mjs +11 -0
- package/dist/lib/buildTypeName.mjs.map +1 -0
- package/dist/lib/{buildUnion.js → buildUnion.mjs} +1 -1
- package/dist/lib/{buildUnion.cjs.map → buildUnion.mjs.map} +1 -1
- package/dist/lib/{checkHasUIDFIeld.js → checkHasUIDFIeld.mjs} +1 -1
- package/dist/lib/{checkHasUIDFIeld.cjs.map → checkHasUIDFIeld.mjs.map} +1 -1
- package/dist/lib/dedent.mjs +12 -0
- package/dist/lib/dedent.mjs.map +1 -0
- package/dist/lib/{getAPIIDPath.js → getAPIIDPath.mjs} +1 -1
- package/dist/lib/{getAPIIDPath.cjs.map → getAPIIDPath.mjs.map} +1 -1
- package/dist/lib/{getCacheKey.js → getCacheKey.mjs} +1 -1
- package/dist/lib/getCacheKey.mjs.map +1 -0
- package/dist/lib/{getHumanReadableModelName.js → getHumanReadableModelName.mjs} +1 -1
- package/dist/lib/{getHumanReadableModelName.cjs.map → getHumanReadableModelName.mjs.map} +1 -1
- package/dist/lib/{getHumanReadablePath.js → getHumanReadablePath.mjs} +2 -2
- package/dist/lib/getHumanReadablePath.mjs.map +1 -0
- package/dist/package.mjs +7 -0
- package/dist/package.mjs.map +1 -0
- package/dist/{types.d.ts → types.d.mts} +2 -4
- package/dist/types.d.mts.map +1 -0
- package/package.json +19 -29
- package/src/cli/index.ts +38 -22
- package/src/cli/loadConfig.ts +7 -9
- package/src/cli/loadLocaleIDs.ts +0 -1
- package/src/cli/loadModels.ts +30 -12
- package/src/generateTypes.ts +3 -3
- package/src/lib/buildCustomTypeDataType.ts +2 -2
- package/src/lib/buildCustomTypeType.ts +6 -6
- package/src/lib/buildFieldProperties.ts +7 -7
- package/src/lib/buildSharedSliceType.ts +22 -33
- package/src/lib/buildTypeName.ts +9 -4
- package/src/lib/dedent.ts +14 -0
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
- package/dist/cli/configSchema.cjs +0 -31
- package/dist/cli/configSchema.cjs.map +0 -1
- package/dist/cli/configSchema.d.cts +0 -39
- package/dist/cli/configSchema.d.cts.map +0 -1
- package/dist/cli/configSchema.d.ts.map +0 -1
- package/dist/cli/configSchema.js +0 -30
- package/dist/cli/configSchema.js.map +0 -1
- package/dist/cli/constants.cjs +0 -6
- package/dist/cli/constants.d.cts +0 -5
- package/dist/cli/constants.d.cts.map +0 -1
- package/dist/cli/constants.d.ts +0 -5
- package/dist/cli/constants.d.ts.map +0 -1
- package/dist/cli/constants.js.map +0 -1
- package/dist/cli/loadConfig.cjs +0 -22
- package/dist/cli/loadConfig.cjs.map +0 -1
- package/dist/cli/loadConfig.js +0 -20
- package/dist/cli/loadConfig.js.map +0 -1
- package/dist/cli/loadLocaleIDs.cjs +0 -21
- package/dist/cli/loadLocaleIDs.cjs.map +0 -1
- package/dist/cli/loadLocaleIDs.js.map +0 -1
- package/dist/cli/loadModels.cjs +0 -54
- package/dist/cli/loadModels.cjs.map +0 -1
- package/dist/cli/loadModels.js.map +0 -1
- package/dist/cli.cjs +0 -110
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/constants.cjs +0 -33
- package/dist/constants.js.map +0 -1
- package/dist/detectTypesProvider.cjs +0 -25
- package/dist/detectTypesProvider.d.cts +0 -17
- package/dist/detectTypesProvider.d.cts.map +0 -1
- package/dist/detectTypesProvider.d.ts +0 -17
- package/dist/detectTypesProvider.d.ts.map +0 -1
- package/dist/detectTypesProvider.js.map +0 -1
- package/dist/generateTypes.cjs +0 -144
- package/dist/generateTypes.cjs.map +0 -1
- package/dist/generateTypes.d.cts +0 -21
- package/dist/generateTypes.d.cts.map +0 -1
- package/dist/generateTypes.d.ts.map +0 -1
- package/dist/generateTypes.js.map +0 -1
- package/dist/index.cjs +0 -7
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -4
- package/dist/lib/addBlankLine.cjs +0 -10
- package/dist/lib/addBlankLine.cjs.map +0 -1
- package/dist/lib/addBlankLine.js.map +0 -1
- package/dist/lib/addLine.cjs +0 -9
- package/dist/lib/addLine.cjs.map +0 -1
- package/dist/lib/addLine.js.map +0 -1
- package/dist/lib/addSection.cjs +0 -9
- package/dist/lib/addSection.cjs.map +0 -1
- package/dist/lib/addSection.js.map +0 -1
- package/dist/lib/addTrailingNewLine.cjs +0 -9
- package/dist/lib/addTrailingNewLine.js.map +0 -1
- package/dist/lib/buildCustomTypeDataType.cjs +0 -51
- package/dist/lib/buildCustomTypeDataType.cjs.map +0 -1
- package/dist/lib/buildCustomTypeDataType.js.map +0 -1
- package/dist/lib/buildCustomTypeType.cjs +0 -63
- package/dist/lib/buildCustomTypeType.cjs.map +0 -1
- package/dist/lib/buildCustomTypeType.js.map +0 -1
- package/dist/lib/buildFieldDocs.cjs +0 -66
- package/dist/lib/buildFieldDocs.cjs.map +0 -1
- package/dist/lib/buildFieldDocs.js.map +0 -1
- package/dist/lib/buildFieldProperties.cjs +0 -285
- package/dist/lib/buildFieldProperties.cjs.map +0 -1
- package/dist/lib/buildFieldProperties.js.map +0 -1
- package/dist/lib/buildSharedSliceType.cjs +0 -152
- package/dist/lib/buildSharedSliceType.cjs.map +0 -1
- package/dist/lib/buildSharedSliceType.js.map +0 -1
- package/dist/lib/buildTypeName.cjs +0 -12
- package/dist/lib/buildTypeName.cjs.map +0 -1
- package/dist/lib/buildTypeName.js +0 -11
- package/dist/lib/buildTypeName.js.map +0 -1
- package/dist/lib/buildUnion.cjs +0 -8
- package/dist/lib/buildUnion.js.map +0 -1
- package/dist/lib/checkHasUIDFIeld.cjs +0 -8
- package/dist/lib/checkHasUIDFIeld.js.map +0 -1
- package/dist/lib/getAPIIDPath.cjs +0 -24
- package/dist/lib/getAPIIDPath.js.map +0 -1
- package/dist/lib/getCacheKey.cjs +0 -17
- package/dist/lib/getCacheKey.cjs.map +0 -1
- package/dist/lib/getCacheKey.js.map +0 -1
- package/dist/lib/getHumanReadableModelName.cjs +0 -15
- package/dist/lib/getHumanReadableModelName.js.map +0 -1
- package/dist/lib/getHumanReadablePath.cjs +0 -16
- package/dist/lib/getHumanReadablePath.cjs.map +0 -1
- package/dist/lib/getHumanReadablePath.js.map +0 -1
- package/dist/types.d.cts +0 -14
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
|
+
//#region src/lib/buildTypeName.ts
|
|
3
|
+
const buildTypeName = (...parts) => {
|
|
4
|
+
let name = pascalCase(parts.filter(Boolean).join(" ").replace(/[^A-Z0-9]+/gi, " "), { mergeAmbiguousCharacters: true });
|
|
5
|
+
if (/^[0-9]/.test(name) ? "_" : "") name = `_${name}`;
|
|
6
|
+
return name;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { buildTypeName };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=buildTypeName.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTypeName.mjs","names":[],"sources":["../../src/lib/buildTypeName.ts"],"sourcesContent":["import { pascalCase } from \"change-case\";\n\nexport const buildTypeName = (...parts: string[]): string => {\n\t// Non-ASCII characters are separators, as they were with the previous `pascal-case` package.\n\tlet name = pascalCase(\n\t\tparts\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \")\n\t\t\t.replace(/[^A-Z0-9]+/gi, \" \"),\n\t\t{ mergeAmbiguousCharacters: true },\n\t);\n\n\tif (/^[0-9]/.test(name) ? \"_\" : \"\") {\n\t\tname = `_${name}`;\n\t}\n\n\treturn name;\n};\n"],"mappings":";;AAEA,MAAa,iBAAiB,GAAG,UAA4B;CAE5D,IAAI,OAAO,WACV,MACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,CAAC,CACT,QAAQ,gBAAgB,GAAG,GAC7B,EAAE,0BAA0B,KAAK,CAClC;CAEA,IAAI,SAAS,KAAK,IAAI,IAAI,MAAM,IAC/B,OAAO,IAAI;CAGZ,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUnion.
|
|
1
|
+
{"version":3,"file":"buildUnion.mjs","names":[],"sources":["../../src/lib/buildUnion.ts"],"sourcesContent":["export function buildUnion(types: string[]): string {\n\treturn types.filter(Boolean).join(\" | \") || \"never\";\n}\n"],"mappings":";AAAA,SAAgB,WAAW,OAAyB;CACnD,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasUIDFIeld.
|
|
1
|
+
{"version":3,"file":"checkHasUIDFIeld.mjs","names":[],"sources":["../../src/lib/checkHasUIDFIeld.ts"],"sourcesContent":["import type { CustomTypeModel } from \"@prismicio/client\";\n\nexport function checkHasUIDField(model: CustomTypeModel): boolean {\n\treturn \"uid\" in Object.assign({}, ...Object.values(model.json));\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAiC;CACjE,OAAO,SAAS,OAAO,OAAO,CAAC,GAAG,GAAG,OAAO,OAAO,MAAM,IAAI,CAAC;AAC/D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import baseDedent from "dedent";
|
|
2
|
+
//#region src/lib/dedent.ts
|
|
3
|
+
const baseDedentWithOptions = baseDedent.withOptions({ alignValues: true });
|
|
4
|
+
function dedent(strings, ...values) {
|
|
5
|
+
if (typeof strings === "string") return baseDedentWithOptions(strings);
|
|
6
|
+
const resolved = Array.from(strings);
|
|
7
|
+
return baseDedentWithOptions(Object.assign(resolved, { raw: resolved }), ...values);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { dedent };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=dedent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedent.mjs","names":[],"sources":["../../src/lib/dedent.ts"],"sourcesContent":["import baseDedent from \"dedent\";\n\nconst baseDedentWithOptions = baseDedent.withOptions({ alignValues: true });\n\nexport function dedent(strings: TemplateStringsArray | string, ...values: unknown[]): string {\n\tif (typeof strings === \"string\") {\n\t\treturn baseDedentWithOptions(strings);\n\t}\n\n\t// dedent reads `strings.raw` by default, which keeps escapes in string literals. Point `raw` at\n\t// the regular string segments instead, where escapes are already resolved.\n\tconst resolved = Array.from(strings);\n\treturn baseDedentWithOptions(Object.assign(resolved, { raw: resolved }), ...values);\n}\n"],"mappings":";;AAEA,MAAM,wBAAwB,WAAW,YAAY,EAAE,aAAa,KAAK,CAAC;AAE1E,SAAgB,OAAO,SAAwC,GAAG,QAA2B;CAC5F,IAAI,OAAO,YAAY,UACtB,OAAO,sBAAsB,OAAO;CAKrC,MAAM,WAAW,MAAM,KAAK,OAAO;CACnC,OAAO,sBAAsB,OAAO,OAAO,UAAU,EAAE,KAAK,SAAS,CAAC,GAAG,GAAG,MAAM;AACnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAPIIDPath.
|
|
1
|
+
{"version":3,"file":"getAPIIDPath.mjs","names":[],"sources":["../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\n\ntype GetAPIIDPathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getAPIIDPath(args: GetAPIIDPathArgs): string {\n\tlet result = \"\";\n\n\tfor (let i = 0; i < args.path.length; i++) {\n\t\tif (i > 0) {\n\t\t\tresult += \".\";\n\t\t}\n\n\t\tconst element = args.path[i];\n\n\t\tif (\n\t\t\telement.model &&\n\t\t\t\"type\" in element.model &&\n\t\t\t(element.model.type === \"Group\" || element.model.type === \"Slices\")\n\t\t) {\n\t\t\tresult += `${element.name}[]`;\n\t\t} else {\n\t\t\tif (element.name === \"items\") {\n\t\t\t\tconst previousElement = args.path[i - 1];\n\n\t\t\t\tif (\n\t\t\t\t\t(previousElement.model && \"json\" in previousElement.model) ||\n\t\t\t\t\t(previousElement.model &&\n\t\t\t\t\t\t\"type\" in previousElement.model &&\n\t\t\t\t\t\tpreviousElement.model.type === \"SharedSlice\")\n\t\t\t\t) {\n\t\t\t\t\tresult += `${element.name}[]`;\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult += element.name;\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"mappings":";AAMA,SAAgB,aAAa,MAAgC;CAC5D,IAAI,SAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,QAAQ,KAAK;EAC1C,IAAI,IAAI,GACP,UAAU;EAGX,MAAM,UAAU,KAAK,KAAK;EAE1B,IACC,QAAQ,SACR,UAAU,QAAQ,UACjB,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,WAE1D,UAAU,GAAG,QAAQ,KAAK;OACpB;GACN,IAAI,QAAQ,SAAS,SAAS;IAC7B,MAAM,kBAAkB,KAAK,KAAK,IAAI;IAEtC,IACE,gBAAgB,SAAS,UAAU,gBAAgB,SACnD,gBAAgB,SAChB,UAAU,gBAAgB,SAC1B,gBAAgB,MAAM,SAAS,eAC/B;KACD,UAAU,GAAG,QAAQ,KAAK;KAE1B;IACD;GACD;GAEA,UAAU,QAAQ;EACnB;CACD;CAEA,OAAO;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCacheKey.mjs","names":[],"sources":["../../src/lib/getCacheKey.ts"],"sourcesContent":["import * as crypto from \"node:crypto\";\n\n/**\n * Returns a key based on the provided input that can be used as a cache identifier.\n *\n * @param input - The value used to create a key.\n * @returns The cache key.\n */\nexport const getCacheKey = (input: unknown): string => {\n\treturn crypto.createHash(\"sha1\").update(JSON.stringify(input)).digest(\"hex\");\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,eAAe,UAA2B;CACtD,OAAO,OAAO,WAAW,MAAM,CAAC,CAAC,OAAO,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK;AAC5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHumanReadableModelName.
|
|
1
|
+
{"version":3,"file":"getHumanReadableModelName.mjs","names":[],"sources":["../../src/lib/getHumanReadableModelName.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\n\ntype GetModelHumanNameArgs = {\n\tname: string;\n\tmodel: CustomTypeModel | SharedSliceModel | CustomTypeModelField | CustomTypeModelSlice;\n};\n\nexport const getHumanReadableModelName = (args: GetModelHumanNameArgs): string => {\n\tif (\"json\" in args.model) {\n\t\t// Custom type model\n\n\t\treturn args.model.label || args.model.id;\n\t} else if (\"type\" in args.model && args.model.type === \"SharedSlice\") {\n\t\t// Shared Slice model\n\n\t\treturn args.model.name;\n\t} else if (\"type\" in args.model && args.model.type === \"Slice\") {\n\t\t// Legacy Slice model\n\n\t\treturn args.model.fieldset || args.name;\n\t} else if (\"type\" in args.model) {\n\t\t// Field model\n\n\t\tif (args.model.config && \"label\" in args.model.config) {\n\t\t\t// Non-Slice Zone fields\n\t\t\treturn args.model.config.label || args.name;\n\t\t} else if (args.model.config && \"fieldset\" in args.model) {\n\t\t\t// Slice Zone\n\t\t\treturn args.model.fieldset || args.name;\n\t\t}\n\t}\n\n\treturn `\\`${args.name}\\``;\n};\n"],"mappings":";AAYA,MAAa,6BAA6B,SAAwC;CACjF,IAAI,UAAU,KAAK,OAGlB,OAAO,KAAK,MAAM,SAAS,KAAK,MAAM;MAChC,IAAI,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,eAGtD,OAAO,KAAK,MAAM;MACZ,IAAI,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,SAGtD,OAAO,KAAK,MAAM,YAAY,KAAK;MAC7B,IAAI,UAAU,KAAK,OAAO;EAGhC,IAAI,KAAK,MAAM,UAAU,WAAW,KAAK,MAAM,QAE9C,OAAO,KAAK,MAAM,OAAO,SAAS,KAAK;OACjC,IAAI,KAAK,MAAM,UAAU,cAAc,KAAK,OAElD,OAAO,KAAK,MAAM,YAAY,KAAK;CAErC;CAEA,OAAO,KAAK,KAAK,KAAK;AACvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getHumanReadableModelName } from "./getHumanReadableModelName.
|
|
1
|
+
import { getHumanReadableModelName } from "./getHumanReadableModelName.mjs";
|
|
2
2
|
//#region src/lib/getHumanReadablePath.ts
|
|
3
3
|
function getHumanReadablePath(args) {
|
|
4
4
|
return args.path.map((element) => {
|
|
@@ -13,4 +13,4 @@ function getHumanReadablePath(args) {
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { getHumanReadablePath };
|
|
15
15
|
|
|
16
|
-
//# sourceMappingURL=getHumanReadablePath.
|
|
16
|
+
//# sourceMappingURL=getHumanReadablePath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadablePath.mjs","names":[],"sources":["../../src/lib/getHumanReadablePath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\n\ntype GetHumanReadablePathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getHumanReadablePath(args: GetHumanReadablePathArgs): string {\n\treturn args.path\n\t\t.map((element) => {\n\t\t\tif (element.label) {\n\t\t\t\treturn element.label;\n\t\t\t} else if (element.model) {\n\t\t\t\treturn getHumanReadableModelName({\n\t\t\t\t\tmodel: element.model,\n\t\t\t\t\tname: element.name,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treturn element.name;\n\t\t\t}\n\t\t})\n\t\t.join(\" → \");\n}\n"],"mappings":";;AAOA,SAAgB,qBAAqB,MAAwC;CAC5E,OAAO,KAAK,KACV,KAAK,YAAY;EACjB,IAAI,QAAQ,OACX,OAAO,QAAQ;OACT,IAAI,QAAQ,OAClB,OAAO,0BAA0B;GAChC,OAAO,QAAQ;GACf,MAAM,QAAQ;EACf,CAAC;OAED,OAAO,QAAQ;CAEjB,CAAC,CAAC,CACD,KAAK,KAAK;AACb"}
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
2
|
-
|
|
3
2
|
//#region src/types.d.ts
|
|
4
|
-
type FieldConfigs = {
|
|
3
|
+
export type FieldConfigs = {
|
|
5
4
|
embed?: {
|
|
6
5
|
providerTypes?: Record<string, string>;
|
|
7
6
|
};
|
|
@@ -10,5 +9,4 @@ type FieldConfigs = {
|
|
|
10
9
|
};
|
|
11
10
|
};
|
|
12
11
|
//#endregion
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|
|
12
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;YAyBY;EACX;IACC,gBAAgB;;EAEjB;IACC,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismic-ts-codegen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30-pr.82.96148f3",
|
|
4
4
|
"description": "An experimental Prismic model-to-TypeScript-type generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -21,14 +21,8 @@
|
|
|
21
21
|
"bin"
|
|
22
22
|
],
|
|
23
23
|
"type": "module",
|
|
24
|
-
"main": "./dist/index.cjs",
|
|
25
|
-
"module": "./dist/index.js",
|
|
26
|
-
"types": "./dist/index.d.cts",
|
|
27
24
|
"exports": {
|
|
28
|
-
".":
|
|
29
|
-
"import": "./dist/index.js",
|
|
30
|
-
"require": "./dist/index.cjs"
|
|
31
|
-
},
|
|
25
|
+
".": "./dist/index.mjs",
|
|
32
26
|
"./package.json": "./package.json"
|
|
33
27
|
},
|
|
34
28
|
"publishConfig": {
|
|
@@ -48,28 +42,24 @@
|
|
|
48
42
|
"bench:watch": "vitest bench"
|
|
49
43
|
},
|
|
50
44
|
"dependencies": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"pascal-case": "^3.1.2",
|
|
58
|
-
"quick-lru": "^6.1.2",
|
|
59
|
-
"zod": "^4.3.6"
|
|
45
|
+
"change-case": "^5.4.4",
|
|
46
|
+
"dedent": "^1.7.2",
|
|
47
|
+
"jiti": "^2.7.0",
|
|
48
|
+
"quick-lru": "^7.3.0",
|
|
49
|
+
"tinyglobby": "^0.2.17",
|
|
50
|
+
"zod": "^4.6.5"
|
|
60
51
|
},
|
|
61
52
|
"devDependencies": {
|
|
62
|
-
"@prismicio/client": "7.
|
|
63
|
-
"@prismicio/mock": "0.7.
|
|
64
|
-
"@types/
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"vitest": "^4.1.2"
|
|
53
|
+
"@prismicio/client": "7.22.3",
|
|
54
|
+
"@prismicio/mock": "0.7.2",
|
|
55
|
+
"@types/node": "^26.6.4",
|
|
56
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
57
|
+
"oxfmt": "^0.72.0",
|
|
58
|
+
"oxlint": "^1.87.0",
|
|
59
|
+
"ts-morph": "^28.0.0",
|
|
60
|
+
"tsdown": "^0.23.0",
|
|
61
|
+
"typescript": "^7.0.2",
|
|
62
|
+
"vitest": "^5.0.3"
|
|
73
63
|
},
|
|
74
64
|
"peerDependencies": {
|
|
75
65
|
"@prismicio/client": "^6.6 || ^7",
|
|
@@ -84,6 +74,6 @@
|
|
|
84
74
|
}
|
|
85
75
|
},
|
|
86
76
|
"engines": {
|
|
87
|
-
"node": ">=
|
|
77
|
+
"node": ">=22"
|
|
88
78
|
}
|
|
89
79
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { existsSync, writeFileSync } from "fs";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
2
3
|
import { resolve as resolvePath } from "path";
|
|
3
4
|
|
|
4
|
-
import
|
|
5
|
-
import meow from "meow";
|
|
6
|
-
|
|
5
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
7
6
|
import { detectTypesProvider, generateTypes } from "../index";
|
|
7
|
+
import { dedent } from "../lib/dedent";
|
|
8
8
|
import { configSchema } from "./configSchema";
|
|
9
9
|
import { NON_EDITABLE_FILE_HEADER } from "./constants";
|
|
10
10
|
import { loadConfig } from "./loadConfig";
|
|
11
11
|
import { loadLocaleIDs } from "./loadLocaleIDs";
|
|
12
12
|
import { loadModels } from "./loadModels";
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const HELP = dedent`
|
|
15
|
+
${packageJson.description}
|
|
16
|
+
|
|
16
17
|
Usage:
|
|
17
18
|
prismic-ts-codegen [options...]
|
|
18
19
|
prismic-ts-codegen init [options...]
|
|
@@ -22,22 +23,37 @@ const cli = meow(
|
|
|
22
23
|
|
|
23
24
|
Options:
|
|
24
25
|
-c, --config <path> Path to a prismic-ts-codegen configuration file.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
flags: {
|
|
29
|
-
config: {
|
|
30
|
-
type: "string",
|
|
31
|
-
shortFlag: "c",
|
|
32
|
-
isRequired: false,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
);
|
|
26
|
+
-h, --help Show this help.
|
|
27
|
+
-v, --version Show the version.
|
|
28
|
+
`;
|
|
37
29
|
|
|
38
30
|
const main = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
const {
|
|
32
|
+
positionals: [command],
|
|
33
|
+
values: { config: configFlag, help, version },
|
|
34
|
+
} = parseArgs({
|
|
35
|
+
options: {
|
|
36
|
+
config: { type: "string", short: "c" },
|
|
37
|
+
help: { type: "boolean", short: "h" },
|
|
38
|
+
version: { type: "boolean", short: "v" },
|
|
39
|
+
},
|
|
40
|
+
allowPositionals: true,
|
|
41
|
+
strict: false,
|
|
42
|
+
});
|
|
43
|
+
const configPathFlag = typeof configFlag === "string" ? configFlag : undefined;
|
|
44
|
+
|
|
45
|
+
if (help) {
|
|
46
|
+
console.info(`\n${HELP}\n`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (version) {
|
|
51
|
+
console.info(packageJson.version);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (command === "init") {
|
|
56
|
+
const configPath = configPathFlag || "prismicCodegen.config.ts";
|
|
41
57
|
|
|
42
58
|
if (existsSync(configPath)) {
|
|
43
59
|
console.info(`\n${configPath} already exists.`);
|
|
@@ -45,7 +61,7 @@ const main = async () => {
|
|
|
45
61
|
let contents = "";
|
|
46
62
|
|
|
47
63
|
if (existsSync("slicemachine.config.json") || existsSync("sm.json")) {
|
|
48
|
-
contents =
|
|
64
|
+
contents = dedent`
|
|
49
65
|
import type { Config } from "prismic-ts-codegen";
|
|
50
66
|
|
|
51
67
|
const config: Config = {
|
|
@@ -56,7 +72,7 @@ const main = async () => {
|
|
|
56
72
|
export default config;
|
|
57
73
|
`;
|
|
58
74
|
} else {
|
|
59
|
-
contents =
|
|
75
|
+
contents = dedent`
|
|
60
76
|
import type { Config } from "prismic-ts-codegen";
|
|
61
77
|
|
|
62
78
|
const config: Config = {
|
|
@@ -72,7 +88,7 @@ const main = async () => {
|
|
|
72
88
|
console.info(`\nCreated prismic-ts-codegen config file: ${configPath}`);
|
|
73
89
|
}
|
|
74
90
|
} else {
|
|
75
|
-
const unvalidatedConfig = loadConfig({ path:
|
|
91
|
+
const unvalidatedConfig = await loadConfig({ path: configPathFlag });
|
|
76
92
|
|
|
77
93
|
const result = configSchema.safeParse(unvalidatedConfig);
|
|
78
94
|
|
package/src/cli/loadConfig.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { existsSync } from "fs";
|
|
2
2
|
import { resolve as resolvePath } from "path";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { createJiti } from "jiti";
|
|
5
5
|
|
|
6
6
|
import type { Config } from "./configSchema";
|
|
7
7
|
|
|
8
|
-
const jiti =
|
|
8
|
+
const jiti = createJiti(process.cwd());
|
|
9
9
|
|
|
10
|
-
const loadModuleWithJiti = <TModule>(id: string): TModule => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
|
|
10
|
+
const loadModuleWithJiti = async <TModule>(id: string): Promise<TModule> => {
|
|
11
|
+
return await jiti.import<TModule>(id, { default: true });
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
const DEFAULT_CONFIG_PATHS = ["prismicCodegen.config.ts", "prismicCodegen.config.js"];
|
|
@@ -19,17 +17,17 @@ type LoadConfigConfig = {
|
|
|
19
17
|
path?: string;
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
export const loadConfig = (config: LoadConfigConfig): Config => {
|
|
20
|
+
export const loadConfig = async (config: LoadConfigConfig): Promise<Config> => {
|
|
23
21
|
if (config.path) {
|
|
24
22
|
if (existsSync(config.path)) {
|
|
25
|
-
return loadModuleWithJiti(resolvePath(config.path));
|
|
23
|
+
return await loadModuleWithJiti(resolvePath(config.path));
|
|
26
24
|
} else {
|
|
27
25
|
throw new Error(`Config file does not exist: ${config.path}`);
|
|
28
26
|
}
|
|
29
27
|
} else {
|
|
30
28
|
for (const configPath of DEFAULT_CONFIG_PATHS) {
|
|
31
29
|
if (existsSync(configPath)) {
|
|
32
|
-
return loadModuleWithJiti(resolvePath(configPath));
|
|
30
|
+
return await loadModuleWithJiti(resolvePath(configPath));
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
}
|
package/src/cli/loadLocaleIDs.ts
CHANGED
package/src/cli/loadModels.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
2
|
|
|
3
3
|
import type { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { glob } from "tinyglobby";
|
|
5
|
+
|
|
6
|
+
const CUSTOM_TYPES_API_ENDPOINT = "https://customtypes.prismic.io/";
|
|
7
7
|
|
|
8
8
|
const isCustomTypeModel = (input: unknown): input is CustomTypeModel => {
|
|
9
9
|
return typeof input === "object" && input !== null && "json" in input;
|
|
@@ -14,7 +14,10 @@ const isSharedSliceModel = (input: unknown): input is SharedSliceModel => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {
|
|
17
|
-
const paths = await
|
|
17
|
+
const paths = await glob(
|
|
18
|
+
globs.split(",").map((path) => path.trim()),
|
|
19
|
+
{ expandDirectories: false },
|
|
20
|
+
);
|
|
18
21
|
|
|
19
22
|
return paths.map((path) => {
|
|
20
23
|
const raw = readFileSync(path, "utf8");
|
|
@@ -23,6 +26,27 @@ const readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {
|
|
|
23
26
|
});
|
|
24
27
|
};
|
|
25
28
|
|
|
29
|
+
const fetchCustomTypesAPI = async <T>(
|
|
30
|
+
path: string,
|
|
31
|
+
config: { repositoryName: string; customTypesAPIToken: string },
|
|
32
|
+
): Promise<T[]> => {
|
|
33
|
+
const url = new URL(path, CUSTOM_TYPES_API_ENDPOINT);
|
|
34
|
+
const res = await fetch(url, {
|
|
35
|
+
headers: {
|
|
36
|
+
repository: config.repositoryName,
|
|
37
|
+
Authorization: `Bearer ${config.customTypesAPIToken}`,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Failed to fetch models from the Custom Types API (${res.status}): ${await res.text()}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return await res.json();
|
|
48
|
+
};
|
|
49
|
+
|
|
26
50
|
type LoadModelsConfig =
|
|
27
51
|
| {
|
|
28
52
|
localPaths?: string[];
|
|
@@ -44,16 +68,10 @@ export const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsRe
|
|
|
44
68
|
const sharedSliceModels: Record<string, SharedSliceModel> = {};
|
|
45
69
|
|
|
46
70
|
if ("customTypesAPIToken" in config) {
|
|
47
|
-
const customTypesClient = prismicCT.createClient({
|
|
48
|
-
repositoryName: config.repositoryName,
|
|
49
|
-
token: config.customTypesAPIToken,
|
|
50
|
-
fetch,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
71
|
if (config.fetchFromRepository) {
|
|
54
72
|
const [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
fetchCustomTypesAPI<CustomTypeModel>("customtypes", config),
|
|
74
|
+
fetchCustomTypesAPI<SharedSliceModel>("slices", config),
|
|
57
75
|
]);
|
|
58
76
|
|
|
59
77
|
for (const customTypeModel of remoteCustomTypeModels) {
|
package/src/generateTypes.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
2
|
-
import { source } from "common-tags";
|
|
3
2
|
import QuickLRU from "quick-lru";
|
|
4
3
|
|
|
5
4
|
import { addLine } from "./lib/addLine";
|
|
@@ -7,6 +6,7 @@ import { addSection } from "./lib/addSection";
|
|
|
7
6
|
import { buildCustomTypeType } from "./lib/buildCustomTypeType";
|
|
8
7
|
import { buildSharedSliceType } from "./lib/buildSharedSliceType";
|
|
9
8
|
import { buildUnion } from "./lib/buildUnion";
|
|
9
|
+
import { dedent } from "./lib/dedent";
|
|
10
10
|
import type { FieldConfigs } from "./types";
|
|
11
11
|
|
|
12
12
|
export type TypesProvider = "@prismicio/client" | "@prismicio/types";
|
|
@@ -207,7 +207,7 @@ type ContentRelationshipFieldWithData<
|
|
|
207
207
|
|
|
208
208
|
if (config.clientIntegration.includeContentNamespace) {
|
|
209
209
|
clientModuleCode = addSection(
|
|
210
|
-
|
|
210
|
+
dedent`
|
|
211
211
|
namespace Content {
|
|
212
212
|
export type {
|
|
213
213
|
${contentTypeNames.join(",\n")}
|
|
@@ -219,7 +219,7 @@ type ContentRelationshipFieldWithData<
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
code = addSection(
|
|
222
|
-
|
|
222
|
+
dedent`
|
|
223
223
|
declare module "@prismicio/client" {
|
|
224
224
|
${clientModuleCode}
|
|
225
225
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CustomTypeModel } from "@prismicio/client";
|
|
2
|
-
import { source } from "common-tags";
|
|
3
2
|
|
|
4
3
|
import { buildTypeName } from "../lib/buildTypeName";
|
|
5
4
|
import type { AuxiliaryType, FieldConfigs } from "../types";
|
|
6
5
|
import { buildFieldProperties } from "./buildFieldProperties";
|
|
6
|
+
import { dedent } from "./dedent";
|
|
7
7
|
import { getHumanReadableModelName } from "./getHumanReadableModelName";
|
|
8
8
|
|
|
9
9
|
type BuildCustomTypeDataTypeArgs = {
|
|
@@ -55,7 +55,7 @@ export function buildCustomTypeDataType(
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (fieldProperties) {
|
|
58
|
-
code =
|
|
58
|
+
code = dedent`
|
|
59
59
|
/**
|
|
60
60
|
* Content for ${humanReadableName} documents
|
|
61
61
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CustomTypeModel } from "@prismicio/client";
|
|
2
|
-
import { source } from "common-tags";
|
|
3
2
|
import type QuickLRU from "quick-lru";
|
|
4
3
|
|
|
5
4
|
import { CUSTOM_TYPES_DOCUMENTATION_URL } from "../constants";
|
|
@@ -9,6 +8,7 @@ import { buildCustomTypeDataType } from "./buildCustomTypeDataType";
|
|
|
9
8
|
import { buildTypeName } from "./buildTypeName";
|
|
10
9
|
import { buildUnion } from "./buildUnion";
|
|
11
10
|
import { checkHasUIDField } from "./checkHasUIDFIeld";
|
|
11
|
+
import { dedent } from "./dedent";
|
|
12
12
|
import { getCacheKey } from "./getCacheKey";
|
|
13
13
|
import { getHumanReadableModelName } from "./getHumanReadableModelName";
|
|
14
14
|
|
|
@@ -27,7 +27,7 @@ type BuildCustomTypeTypeReturnValue = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export function buildCustomTypeType(
|
|
30
|
-
args: BuildCustomTypeTypesArgs
|
|
30
|
+
args: BuildCustomTypeTypesArgs,
|
|
31
31
|
): BuildCustomTypeTypeReturnValue {
|
|
32
32
|
if (args.cache) {
|
|
33
33
|
const key = getCacheKey(args.model);
|
|
@@ -68,7 +68,7 @@ export function buildCustomTypeType(
|
|
|
68
68
|
code = addSection(dataType.code, code);
|
|
69
69
|
|
|
70
70
|
code = addSection(
|
|
71
|
-
|
|
71
|
+
dedent`
|
|
72
72
|
/**
|
|
73
73
|
* ${humanReadableName} document from Prismic
|
|
74
74
|
*
|
|
@@ -79,10 +79,10 @@ export function buildCustomTypeType(
|
|
|
79
79
|
* @typeParam Lang - Language API ID of the document.
|
|
80
80
|
*/
|
|
81
81
|
export type ${name}<Lang extends string = ${langDefault}> = prismic.${baseDocumentType}<Simplify<${
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
dataType.name
|
|
83
|
+
}>, "${args.model.id}", Lang>;
|
|
84
84
|
`,
|
|
85
|
-
code
|
|
85
|
+
code,
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
const result = {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type CustomTypeModelField, CustomTypeModelFieldType } from "@prismicio/client";
|
|
2
|
-
import { source, stripIndent } from "common-tags";
|
|
3
2
|
|
|
4
3
|
import type { AuxiliaryType, FieldConfigs, FieldPath } from "../types";
|
|
5
4
|
import { addLine } from "./addLine";
|
|
@@ -7,6 +6,7 @@ import { addSection } from "./addSection";
|
|
|
7
6
|
import { buildFieldDocs } from "./buildFieldDocs";
|
|
8
7
|
import { buildTypeName } from "./buildTypeName";
|
|
9
8
|
import { buildUnion } from "./buildUnion";
|
|
9
|
+
import { dedent } from "./dedent";
|
|
10
10
|
import { getHumanReadablePath } from "./getHumanReadablePath";
|
|
11
11
|
|
|
12
12
|
type BuildFieldPropertyArgs = Pick<
|
|
@@ -284,7 +284,7 @@ function buildFieldProperty(args: BuildFieldPropertyArgs): BuildFieldPropertyRet
|
|
|
284
284
|
|
|
285
285
|
auxiliaryTypes.push({
|
|
286
286
|
name: itemName,
|
|
287
|
-
code:
|
|
287
|
+
code: dedent`
|
|
288
288
|
/**
|
|
289
289
|
* Item in *${humanReadablePath}*
|
|
290
290
|
*/
|
|
@@ -362,14 +362,14 @@ function buildFieldProperty(args: BuildFieldPropertyArgs): BuildFieldPropertyRet
|
|
|
362
362
|
auxiliaryTypes.push(...primaryFieldProperties.auxiliaryTypes);
|
|
363
363
|
contentTypeNames.push(...primaryFieldProperties.contentTypeNames);
|
|
364
364
|
|
|
365
|
-
let primaryCode =
|
|
365
|
+
let primaryCode = dedent`
|
|
366
366
|
/**
|
|
367
367
|
* Primary content in *${humanReadablePath}*
|
|
368
368
|
*/
|
|
369
369
|
`;
|
|
370
370
|
primaryCode = primaryFieldProperties.code
|
|
371
371
|
? addLine(
|
|
372
|
-
|
|
372
|
+
dedent`
|
|
373
373
|
export interface ${primaryInterfaceName} {
|
|
374
374
|
${primaryFieldProperties.code}
|
|
375
375
|
}
|
|
@@ -414,14 +414,14 @@ function buildFieldProperty(args: BuildFieldPropertyArgs): BuildFieldPropertyRet
|
|
|
414
414
|
auxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);
|
|
415
415
|
contentTypeNames.push(...itemFieldProperties.contentTypeNames);
|
|
416
416
|
|
|
417
|
-
let itemCode =
|
|
417
|
+
let itemCode = dedent`
|
|
418
418
|
/**
|
|
419
419
|
* Item content in *${humanReadablePath}*
|
|
420
420
|
*/
|
|
421
421
|
`;
|
|
422
422
|
itemCode = itemFieldProperties.code
|
|
423
423
|
? addLine(
|
|
424
|
-
|
|
424
|
+
dedent`
|
|
425
425
|
export interface ${itemInterfaceName} {
|
|
426
426
|
${itemFieldProperties.code}
|
|
427
427
|
}
|
|
@@ -439,7 +439,7 @@ function buildFieldProperty(args: BuildFieldPropertyArgs): BuildFieldPropertyRet
|
|
|
439
439
|
|
|
440
440
|
auxiliaryTypes.push({
|
|
441
441
|
name: sliceName,
|
|
442
|
-
code:
|
|
442
|
+
code: dedent`
|
|
443
443
|
/**
|
|
444
444
|
* Slice for *${getHumanReadablePath({
|
|
445
445
|
path: [
|