prismic-ts-codegen 0.1.6 → 0.1.7
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/README.md +5 -5
- package/bin/prismic-ts-codegen.mjs +3 -0
- package/dist/cli/configSchema.cjs +38 -0
- package/dist/cli/configSchema.cjs.map +1 -0
- package/dist/cli/configSchema.d.ts +3 -0
- package/dist/cli/configSchema.js +38 -0
- package/dist/cli/configSchema.js.map +1 -0
- package/dist/cli/constants.cjs +5 -0
- package/dist/cli/constants.cjs.map +1 -0
- package/dist/cli/constants.d.ts +1 -0
- package/dist/cli/constants.js +5 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/loadConfig.cjs +32 -0
- package/dist/cli/loadConfig.cjs.map +1 -0
- package/dist/cli/loadConfig.d.ts +6 -0
- package/dist/cli/loadConfig.js +32 -0
- package/dist/cli/loadConfig.js.map +1 -0
- package/dist/cli/loadLocaleIDs.cjs +37 -0
- package/dist/cli/loadLocaleIDs.cjs.map +1 -0
- package/dist/cli/loadLocaleIDs.d.ts +10 -0
- package/dist/cli/loadLocaleIDs.js +20 -0
- package/dist/cli/loadLocaleIDs.js.map +1 -0
- package/dist/cli/loadModels.cjs +79 -0
- package/dist/cli/loadModels.cjs.map +1 -0
- package/dist/cli/loadModels.d.ts +15 -0
- package/dist/cli/loadModels.js +62 -0
- package/dist/cli/loadModels.js.map +1 -0
- package/dist/cli/types.d.ts +175 -0
- package/dist/cli.cjs +119 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +118 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.cjs +29 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +29 -0
- package/dist/constants.js.map +1 -0
- package/dist/detectTypesProvider.cjs +16 -0
- package/dist/detectTypesProvider.cjs.map +1 -0
- package/dist/detectTypesProvider.d.ts +13 -0
- package/dist/detectTypesProvider.js +16 -0
- package/dist/detectTypesProvider.js.map +1 -0
- package/dist/generateTypes.cjs +109 -0
- package/dist/generateTypes.cjs.map +1 -0
- package/dist/generateTypes.d.ts +15 -0
- package/dist/generateTypes.js +109 -0
- package/dist/generateTypes.js.map +1 -0
- package/dist/index.cjs +6 -1086
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -192
- package/dist/index.js +5 -1081
- package/dist/index.js.map +1 -1
- package/dist/lib/addInterfacePropertiesForFields.cjs +490 -0
- package/dist/lib/addInterfacePropertiesForFields.cjs.map +1 -0
- package/dist/lib/addInterfacePropertiesForFields.d.ts +21 -0
- package/dist/lib/addInterfacePropertiesForFields.js +490 -0
- package/dist/lib/addInterfacePropertiesForFields.js.map +1 -0
- package/dist/lib/addTypeAliasForCustomType.cjs +81 -0
- package/dist/lib/addTypeAliasForCustomType.cjs.map +1 -0
- package/dist/lib/addTypeAliasForCustomType.d.ts +11 -0
- package/dist/lib/addTypeAliasForCustomType.js +81 -0
- package/dist/lib/addTypeAliasForCustomType.js.map +1 -0
- package/dist/lib/addTypeAliasForSharedSlice.cjs +149 -0
- package/dist/lib/addTypeAliasForSharedSlice.cjs.map +1 -0
- package/dist/lib/addTypeAliasForSharedSlice.d.ts +10 -0
- package/dist/lib/addTypeAliasForSharedSlice.js +149 -0
- package/dist/lib/addTypeAliasForSharedSlice.js.map +1 -0
- package/dist/lib/buildFieldDocs.cjs +43 -0
- package/dist/lib/buildFieldDocs.cjs.map +1 -0
- package/dist/lib/buildFieldDocs.d.ts +14 -0
- package/dist/lib/buildFieldDocs.js +43 -0
- package/dist/lib/buildFieldDocs.js.map +1 -0
- package/dist/lib/buildSharedSliceInterfaceNamePart.cjs +8 -0
- package/dist/lib/buildSharedSliceInterfaceNamePart.cjs.map +1 -0
- package/dist/lib/buildSharedSliceInterfaceNamePart.d.ts +5 -0
- package/dist/lib/buildSharedSliceInterfaceNamePart.js +8 -0
- package/dist/lib/buildSharedSliceInterfaceNamePart.js.map +1 -0
- package/dist/lib/buildTypeName.cjs +12 -0
- package/dist/lib/buildTypeName.cjs.map +1 -0
- package/dist/lib/buildTypeName.d.ts +1 -0
- package/dist/lib/buildTypeName.js +12 -0
- package/dist/lib/buildTypeName.js.map +1 -0
- package/dist/lib/getAPIIDPath.cjs +23 -0
- package/dist/lib/getAPIIDPath.cjs.map +1 -0
- package/dist/lib/getAPIIDPath.d.ts +10 -0
- package/dist/lib/getAPIIDPath.js +23 -0
- package/dist/lib/getAPIIDPath.js.map +1 -0
- package/dist/lib/getFieldDocumentationURL.cjs +8 -0
- package/dist/lib/getFieldDocumentationURL.cjs.map +1 -0
- package/dist/lib/getFieldDocumentationURL.d.ts +6 -0
- package/dist/lib/getFieldDocumentationURL.js +8 -0
- package/dist/lib/getFieldDocumentationURL.js.map +1 -0
- package/dist/lib/getHumanReadableFieldPath.cjs +19 -0
- package/dist/lib/getHumanReadableFieldPath.cjs.map +1 -0
- package/dist/lib/getHumanReadableFieldPath.d.ts +10 -0
- package/dist/lib/getHumanReadableFieldPath.js +19 -0
- package/dist/lib/getHumanReadableFieldPath.js.map +1 -0
- package/dist/lib/getHumanReadableFieldType.cjs +37 -0
- package/dist/lib/getHumanReadableFieldType.cjs.map +1 -0
- package/dist/lib/getHumanReadableFieldType.d.ts +6 -0
- package/dist/lib/getHumanReadableFieldType.js +37 -0
- package/dist/lib/getHumanReadableFieldType.js.map +1 -0
- package/dist/lib/getHumanReadableModelName.cjs +24 -0
- package/dist/lib/getHumanReadableModelName.cjs.map +1 -0
- package/dist/lib/getHumanReadableModelName.d.ts +7 -0
- package/dist/lib/getHumanReadableModelName.js +24 -0
- package/dist/lib/getHumanReadableModelName.js.map +1 -0
- package/dist/lib/getSourceFileText.cjs +9 -0
- package/dist/lib/getSourceFileText.cjs.map +1 -0
- package/dist/lib/getSourceFileText.d.ts +2 -0
- package/dist/lib/getSourceFileText.js +9 -0
- package/dist/lib/getSourceFileText.js.map +1 -0
- package/dist/lib/hasOwnProperty.cjs +7 -0
- package/dist/lib/hasOwnProperty.cjs.map +1 -0
- package/dist/lib/hasOwnProperty.d.ts +10 -0
- package/dist/lib/hasOwnProperty.js +7 -0
- package/dist/lib/hasOwnProperty.js.map +1 -0
- package/dist/lib/isCustomTypeModel.cjs +7 -0
- package/dist/lib/isCustomTypeModel.cjs.map +1 -0
- package/dist/lib/isCustomTypeModel.d.ts +2 -0
- package/dist/lib/isCustomTypeModel.js +7 -0
- package/dist/lib/isCustomTypeModel.js.map +1 -0
- package/dist/lib/isCustomTypeModelField.cjs +7 -0
- package/dist/lib/isCustomTypeModelField.cjs.map +1 -0
- package/dist/lib/isCustomTypeModelField.d.ts +2 -0
- package/dist/lib/isCustomTypeModelField.js +7 -0
- package/dist/lib/isCustomTypeModelField.js.map +1 -0
- package/dist/lib/isCustomTypeModelSlice.cjs +9 -0
- package/dist/lib/isCustomTypeModelSlice.cjs.map +1 -0
- package/dist/lib/isCustomTypeModelSlice.d.ts +2 -0
- package/dist/lib/isCustomTypeModelSlice.js +9 -0
- package/dist/lib/isCustomTypeModelSlice.js.map +1 -0
- package/dist/lib/isSharedSliceModel.cjs +9 -0
- package/dist/lib/isSharedSliceModel.cjs.map +1 -0
- package/dist/lib/isSharedSliceModel.d.ts +2 -0
- package/dist/lib/isSharedSliceModel.js +9 -0
- package/dist/lib/isSharedSliceModel.js.map +1 -0
- package/dist/lib/pascalCase.cjs +8 -0
- package/dist/lib/pascalCase.cjs.map +1 -0
- package/dist/lib/pascalCase.d.ts +1 -0
- package/dist/lib/pascalCase.js +8 -0
- package/dist/lib/pascalCase.js.map +1 -0
- package/dist/lib/writeFieldDocsDescription.cjs +29 -0
- package/dist/lib/writeFieldDocsDescription.cjs.map +1 -0
- package/dist/lib/writeFieldDocsDescription.d.ts +13 -0
- package/dist/lib/writeFieldDocsDescription.js +29 -0
- package/dist/lib/writeFieldDocsDescription.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/package.json +45 -36
- package/src/cli/configSchema.ts +2 -0
- package/src/cli/index.ts +9 -5
- package/src/cli/loadConfig.ts +4 -2
- package/src/cli/loadModels.ts +3 -3
- package/src/cli/types.ts +10 -0
- package/src/constants.ts +6 -3
- package/src/detectTypesProvider.ts +32 -0
- package/src/generateTypes.ts +11 -6
- package/src/index.ts +4 -1
- package/src/lib/addInterfacePropertiesForFields.ts +27 -27
- package/src/lib/addTypeAliasForCustomType.ts +7 -5
- package/src/lib/addTypeAliasForSharedSlice.ts +5 -4
- package/src/lib/buildFieldDocs.ts +2 -1
- package/src/lib/getAPIIDPath.ts +3 -2
- package/src/lib/getFieldDocumentationURL.ts +1 -1
- package/src/lib/getHumanReadableFieldPath.ts +2 -1
- package/src/lib/getHumanReadableFieldType.ts +2 -2
- package/src/lib/getHumanReadableModelName.ts +1 -1
- package/src/lib/getSourceFileText.ts +1 -1
- package/src/lib/isCustomTypeModel.ts +1 -1
- package/src/lib/isCustomTypeModelField.ts +1 -1
- package/src/lib/isCustomTypeModelSlice.ts +1 -1
- package/src/lib/isSharedSliceModel.ts +1 -1
- package/src/types.ts +1 -1
- package/bin/cli.mjs +0 -1342
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const writeFieldDocsDescription = (config) => {
|
|
4
|
+
if (config.description) {
|
|
5
|
+
config.writer.writeLine(config.description);
|
|
6
|
+
}
|
|
7
|
+
config.writer.blankLineIfLastNot();
|
|
8
|
+
if (config.fieldType) {
|
|
9
|
+
config.writer.writeLine(`- **Field Type**: ${config.fieldType}`);
|
|
10
|
+
}
|
|
11
|
+
if (config.placeholder) {
|
|
12
|
+
config.writer.writeLine(`- **Placeholder**: ${config.placeholder}`);
|
|
13
|
+
}
|
|
14
|
+
if (config.defaultValue !== void 0) {
|
|
15
|
+
const stringifiedDefaultValue = typeof config.defaultValue === "boolean" ? `${config.defaultValue}` : config.defaultValue;
|
|
16
|
+
config.writer.writeLine(`- **Default Value**: ${stringifiedDefaultValue}`);
|
|
17
|
+
}
|
|
18
|
+
if (config.apiIDPath) {
|
|
19
|
+
config.writer.writeLine(`- **API ID Path**: ${config.apiIDPath}`);
|
|
20
|
+
}
|
|
21
|
+
if (config.tabName) {
|
|
22
|
+
config.writer.writeLine(`- **Tab**: ${config.tabName}`);
|
|
23
|
+
}
|
|
24
|
+
if (config.documentationURL) {
|
|
25
|
+
config.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.writeFieldDocsDescription = writeFieldDocsDescription;
|
|
29
|
+
//# sourceMappingURL=writeFieldDocsDescription.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeFieldDocsDescription.cjs","sources":["../../../src/lib/writeFieldDocsDescription.ts"],"sourcesContent":["import type { CodeBlockWriter } from \"ts-morph\";\n\ntype BuildFieldDocsConfig = {\n\twriter: CodeBlockWriter;\n\tdescription?: string;\n\tfieldType?: string;\n\tdefaultValue?: string | boolean;\n\tplaceholder?: string;\n\tapiIDPath?: string;\n\ttabName?: string;\n\tdocumentationURL?: string;\n};\n\nexport const writeFieldDocsDescription = (\n\tconfig: BuildFieldDocsConfig,\n): void => {\n\tif (config.description) {\n\t\tconfig.writer.writeLine(config.description);\n\t}\n\n\tconfig.writer.blankLineIfLastNot();\n\n\tif (config.fieldType) {\n\t\tconfig.writer.writeLine(`- **Field Type**: ${config.fieldType}`);\n\t}\n\n\tif (config.placeholder) {\n\t\tconfig.writer.writeLine(`- **Placeholder**: ${config.placeholder}`);\n\t}\n\n\tif (config.defaultValue !== undefined) {\n\t\tconst stringifiedDefaultValue =\n\t\t\ttypeof config.defaultValue === \"boolean\"\n\t\t\t\t? `${config.defaultValue}`\n\t\t\t\t: config.defaultValue;\n\n\t\tconfig.writer.writeLine(`- **Default Value**: ${stringifiedDefaultValue}`);\n\t}\n\n\tif (config.apiIDPath) {\n\t\tconfig.writer.writeLine(`- **API ID Path**: ${config.apiIDPath}`);\n\t}\n\n\tif (config.tabName) {\n\t\tconfig.writer.writeLine(`- **Tab**: ${config.tabName}`);\n\t}\n\n\tif (config.documentationURL) {\n\t\tconfig.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);\n\t}\n};\n"],"names":[],"mappings":";;AAaa,MAAA,4BAA4B,CACxC,WACS;AACT,MAAI,OAAO,aAAa;AAChB,WAAA,OAAO,UAAU,OAAO,WAAW;AAAA,EAC1C;AAED,SAAO,OAAO;AAEd,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO,UAAU,qBAAqB,OAAO,WAAW;AAAA,EAC/D;AAED,MAAI,OAAO,aAAa;AACvB,WAAO,OAAO,UAAU,sBAAsB,OAAO,aAAa;AAAA,EAClE;AAEG,MAAA,OAAO,iBAAiB,QAAW;AAChC,UAAA,0BACL,OAAO,OAAO,iBAAiB,YAC5B,GAAG,OAAO,iBACV,OAAO;AAEJ,WAAA,OAAO,UAAU,wBAAwB,yBAAyB;AAAA,EACzE;AAED,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO,UAAU,sBAAsB,OAAO,WAAW;AAAA,EAChE;AAED,MAAI,OAAO,SAAS;AACnB,WAAO,OAAO,UAAU,cAAc,OAAO,SAAS;AAAA,EACtD;AAED,MAAI,OAAO,kBAAkB;AAC5B,WAAO,OAAO,UAAU,wBAAwB,OAAO,kBAAkB;AAAA,EACzE;AACF;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CodeBlockWriter } from "ts-morph";
|
|
2
|
+
type BuildFieldDocsConfig = {
|
|
3
|
+
writer: CodeBlockWriter;
|
|
4
|
+
description?: string;
|
|
5
|
+
fieldType?: string;
|
|
6
|
+
defaultValue?: string | boolean;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
apiIDPath?: string;
|
|
9
|
+
tabName?: string;
|
|
10
|
+
documentationURL?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const writeFieldDocsDescription: (config: BuildFieldDocsConfig) => void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const writeFieldDocsDescription = (config) => {
|
|
2
|
+
if (config.description) {
|
|
3
|
+
config.writer.writeLine(config.description);
|
|
4
|
+
}
|
|
5
|
+
config.writer.blankLineIfLastNot();
|
|
6
|
+
if (config.fieldType) {
|
|
7
|
+
config.writer.writeLine(`- **Field Type**: ${config.fieldType}`);
|
|
8
|
+
}
|
|
9
|
+
if (config.placeholder) {
|
|
10
|
+
config.writer.writeLine(`- **Placeholder**: ${config.placeholder}`);
|
|
11
|
+
}
|
|
12
|
+
if (config.defaultValue !== void 0) {
|
|
13
|
+
const stringifiedDefaultValue = typeof config.defaultValue === "boolean" ? `${config.defaultValue}` : config.defaultValue;
|
|
14
|
+
config.writer.writeLine(`- **Default Value**: ${stringifiedDefaultValue}`);
|
|
15
|
+
}
|
|
16
|
+
if (config.apiIDPath) {
|
|
17
|
+
config.writer.writeLine(`- **API ID Path**: ${config.apiIDPath}`);
|
|
18
|
+
}
|
|
19
|
+
if (config.tabName) {
|
|
20
|
+
config.writer.writeLine(`- **Tab**: ${config.tabName}`);
|
|
21
|
+
}
|
|
22
|
+
if (config.documentationURL) {
|
|
23
|
+
config.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
writeFieldDocsDescription
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=writeFieldDocsDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeFieldDocsDescription.js","sources":["../../../src/lib/writeFieldDocsDescription.ts"],"sourcesContent":["import type { CodeBlockWriter } from \"ts-morph\";\n\ntype BuildFieldDocsConfig = {\n\twriter: CodeBlockWriter;\n\tdescription?: string;\n\tfieldType?: string;\n\tdefaultValue?: string | boolean;\n\tplaceholder?: string;\n\tapiIDPath?: string;\n\ttabName?: string;\n\tdocumentationURL?: string;\n};\n\nexport const writeFieldDocsDescription = (\n\tconfig: BuildFieldDocsConfig,\n): void => {\n\tif (config.description) {\n\t\tconfig.writer.writeLine(config.description);\n\t}\n\n\tconfig.writer.blankLineIfLastNot();\n\n\tif (config.fieldType) {\n\t\tconfig.writer.writeLine(`- **Field Type**: ${config.fieldType}`);\n\t}\n\n\tif (config.placeholder) {\n\t\tconfig.writer.writeLine(`- **Placeholder**: ${config.placeholder}`);\n\t}\n\n\tif (config.defaultValue !== undefined) {\n\t\tconst stringifiedDefaultValue =\n\t\t\ttypeof config.defaultValue === \"boolean\"\n\t\t\t\t? `${config.defaultValue}`\n\t\t\t\t: config.defaultValue;\n\n\t\tconfig.writer.writeLine(`- **Default Value**: ${stringifiedDefaultValue}`);\n\t}\n\n\tif (config.apiIDPath) {\n\t\tconfig.writer.writeLine(`- **API ID Path**: ${config.apiIDPath}`);\n\t}\n\n\tif (config.tabName) {\n\t\tconfig.writer.writeLine(`- **Tab**: ${config.tabName}`);\n\t}\n\n\tif (config.documentationURL) {\n\t\tconfig.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);\n\t}\n};\n"],"names":[],"mappings":"AAaa,MAAA,4BAA4B,CACxC,WACS;AACT,MAAI,OAAO,aAAa;AAChB,WAAA,OAAO,UAAU,OAAO,WAAW;AAAA,EAC1C;AAED,SAAO,OAAO;AAEd,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO,UAAU,qBAAqB,OAAO,WAAW;AAAA,EAC/D;AAED,MAAI,OAAO,aAAa;AACvB,WAAO,OAAO,UAAU,sBAAsB,OAAO,aAAa;AAAA,EAClE;AAEG,MAAA,OAAO,iBAAiB,QAAW;AAChC,UAAA,0BACL,OAAO,OAAO,iBAAiB,YAC5B,GAAG,OAAO,iBACV,OAAO;AAEJ,WAAA,OAAO,UAAU,wBAAwB,yBAAyB;AAAA,EACzE;AAED,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO,UAAU,sBAAsB,OAAO,WAAW;AAAA,EAChE;AAED,MAAI,OAAO,SAAS;AACnB,WAAO,OAAO,UAAU,cAAc,OAAO,SAAS;AAAA,EACtD;AAED,MAAI,OAAO,kBAAkB;AAC5B,WAAO,OAAO,UAAU,wBAAwB,OAAO,kBAAkB;AAAA,EACzE;AACF;"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CustomTypeModel, CustomTypeModelField, CustomTypeModelSlice, SharedSliceModel } from "@prismicio/client";
|
|
2
|
+
export type PathElement<Model extends CustomTypeModel | SharedSliceModel | CustomTypeModelField | CustomTypeModelSlice> = {
|
|
3
|
+
id: string;
|
|
4
|
+
model?: Model;
|
|
5
|
+
label?: string;
|
|
6
|
+
};
|
|
7
|
+
export type FieldConfigs = {
|
|
8
|
+
embed?: {
|
|
9
|
+
providerTypes?: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
integrationFields?: {
|
|
12
|
+
catalogTypes?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismic-ts-codegen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "An experimental Prismic model-to-TypeScript-type generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -20,69 +20,78 @@
|
|
|
20
20
|
},
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
|
-
"main": "dist/index.cjs",
|
|
24
|
-
"module": "dist/index.js",
|
|
25
|
-
"types": "dist/index.d.ts",
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
26
|
"bin": {
|
|
27
|
-
"prismic-ts-codegen": "bin/
|
|
27
|
+
"prismic-ts-codegen": "./bin/prismic-ts-codegen.mjs"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"dev": "
|
|
34
|
+
"build": "vite build",
|
|
35
|
+
"dev": "vite build --watch",
|
|
36
36
|
"format": "prettier --write .",
|
|
37
|
-
"lint": "eslint --ext .js,.ts .",
|
|
38
37
|
"prepare": "npm run build",
|
|
39
38
|
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
39
|
+
"release:dry": "standard-version --dry-run",
|
|
40
40
|
"release:alpha": "npm run test && standard-version --release-as major --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
41
41
|
"release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run",
|
|
42
|
-
"
|
|
42
|
+
"lint": "eslint --ext .js,.ts .",
|
|
43
|
+
"types": "tsc --noEmit",
|
|
44
|
+
"unit": "vitest run --coverage",
|
|
45
|
+
"unit:watch": "vitest watch",
|
|
43
46
|
"size": "size-limit",
|
|
44
|
-
"test": "npm run lint && npm run unit && npm run build && npm run size"
|
|
45
|
-
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
47
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
|
-
"@prismicio/client": "^
|
|
49
|
-
"@prismicio/
|
|
50
|
+
"@prismicio/custom-types-client": "^1.1.0",
|
|
51
|
+
"@prismicio/client": "^7.0.0",
|
|
50
52
|
"common-tags": "^1.8.2",
|
|
51
|
-
"fast-glob": "^3.2.
|
|
52
|
-
"jiti": "^1.
|
|
53
|
-
"joi": "^17.
|
|
54
|
-
"meow": "^
|
|
55
|
-
"node-fetch": "^3.
|
|
53
|
+
"fast-glob": "^3.2.12",
|
|
54
|
+
"jiti": "^1.18.2",
|
|
55
|
+
"joi": "^17.9.2",
|
|
56
|
+
"meow": "^12.0.1",
|
|
57
|
+
"node-fetch": "^3.3.1",
|
|
56
58
|
"pascal-case": "^3.1.2",
|
|
57
|
-
"prettier": "^2.
|
|
58
|
-
"ts-morph": "^
|
|
59
|
+
"prettier": "^2.8.8",
|
|
60
|
+
"ts-morph": "^18.0.0"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
|
-
"@prismicio/mock": "^0.
|
|
63
|
+
"@prismicio/mock": "^0.2.0",
|
|
62
64
|
"@prismicio/types": "^0.2.0",
|
|
63
|
-
"@size-limit/preset-small-lib": "^8.
|
|
65
|
+
"@size-limit/preset-small-lib": "^8.2.4",
|
|
66
|
+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
64
67
|
"@types/common-tags": "^1.8.1",
|
|
65
|
-
"@types/prettier": "^2.7.
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
67
|
-
"@typescript-eslint/parser": "^5.
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"eslint": "^8.
|
|
71
|
-
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"@types/prettier": "^2.7.2",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
70
|
+
"@typescript-eslint/parser": "^5.59.6",
|
|
71
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
72
|
+
"eslint": "^8.40.0",
|
|
73
|
+
"eslint-config-prettier": "^8.8.0",
|
|
72
74
|
"eslint-plugin-prettier": "^4.2.1",
|
|
73
|
-
"eslint-plugin-tsdoc": "^0.2.
|
|
74
|
-
"nyc": "^15.1.0",
|
|
75
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
75
76
|
"prettier-plugin-jsdoc": "^0.4.2",
|
|
76
|
-
"
|
|
77
|
-
"size-limit": "^8.0.1",
|
|
77
|
+
"size-limit": "^8.2.4",
|
|
78
78
|
"standard-version": "^9.5.0",
|
|
79
|
-
"typescript": "^
|
|
79
|
+
"typescript": "^5.0.4",
|
|
80
|
+
"vite": "^4.3.7",
|
|
81
|
+
"vite-plugin-sdk": "^0.1.1",
|
|
82
|
+
"vitest": "^0.31.1"
|
|
80
83
|
},
|
|
81
84
|
"peerDependencies": {
|
|
85
|
+
"@prismicio/client": "^6.6 || ^7",
|
|
82
86
|
"@prismicio/types": "^0.2"
|
|
83
87
|
},
|
|
84
|
-
"
|
|
85
|
-
"@prismicio/client":
|
|
88
|
+
"peerDependenciesMeta": {
|
|
89
|
+
"@prismicio/client": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"@prismicio/types": {
|
|
93
|
+
"optional": true
|
|
94
|
+
}
|
|
86
95
|
},
|
|
87
96
|
"engines": {
|
|
88
97
|
"node": ">=12.7.0"
|
package/src/cli/configSchema.ts
CHANGED
|
@@ -17,6 +17,8 @@ export const configSchema = Joi.object<Config>({
|
|
|
17
17
|
|
|
18
18
|
output: Joi.string(),
|
|
19
19
|
|
|
20
|
+
typesProvider: Joi.string().allow("@prismicio/client", "@prismicio/client"),
|
|
21
|
+
|
|
20
22
|
clientIntegration: Joi.object({
|
|
21
23
|
includeCreateClientInterface: Joi.boolean(),
|
|
22
24
|
includeContentNamespace: Joi.boolean(),
|
package/src/cli/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { stripIndent } from "common-tags";
|
|
1
2
|
import { existsSync, writeFileSync } from "fs";
|
|
2
|
-
import { resolve as resolvePath } from "path";
|
|
3
3
|
import meow from "meow";
|
|
4
|
-
import {
|
|
4
|
+
import { resolve as resolvePath } from "path";
|
|
5
5
|
|
|
6
|
-
import { generateTypes } from "../index";
|
|
6
|
+
import { detectTypesProvider, generateTypes } from "../index";
|
|
7
7
|
|
|
8
8
|
import { configSchema } from "./configSchema";
|
|
9
|
+
import { NON_EDITABLE_FILE_HEADER } from "./constants";
|
|
10
|
+
import { loadConfig } from "./loadConfig";
|
|
9
11
|
import { loadLocaleIDs } from "./loadLocaleIDs";
|
|
10
12
|
import { loadModels } from "./loadModels";
|
|
11
|
-
import { loadConfig } from "./loadConfig";
|
|
12
|
-
import { NON_EDITABLE_FILE_HEADER } from "./constants";
|
|
13
13
|
|
|
14
14
|
const cli = meow(
|
|
15
15
|
`
|
|
@@ -101,6 +101,9 @@ const main = async () => {
|
|
|
101
101
|
config.locales.fetchFromRepository,
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
const typesProvider =
|
|
105
|
+
config.typesProvider || (await detectTypesProvider());
|
|
106
|
+
|
|
104
107
|
const hasCustomTypeModels = customTypeModels.length > 0;
|
|
105
108
|
|
|
106
109
|
if (
|
|
@@ -124,6 +127,7 @@ const main = async () => {
|
|
|
124
127
|
includeContentNamespace:
|
|
125
128
|
config.clientIntegration?.includeContentNamespace ?? true,
|
|
126
129
|
},
|
|
130
|
+
typesProvider,
|
|
127
131
|
});
|
|
128
132
|
|
|
129
133
|
const fileContents = `${NON_EDITABLE_FILE_HEADER}\n\n${types}`;
|
package/src/cli/loadConfig.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _jiti from "jiti";
|
|
2
1
|
import { existsSync } from "fs";
|
|
2
|
+
import _jiti from "jiti";
|
|
3
3
|
import { resolve as resolvePath } from "path";
|
|
4
4
|
|
|
5
5
|
import type { Config } from "./types";
|
|
@@ -9,7 +9,9 @@ const jiti = _jiti(process.cwd());
|
|
|
9
9
|
const loadModuleWithJiti = <TModule>(id: string): TModule => {
|
|
10
10
|
const mod = jiti(id) as TModule | { default: TModule };
|
|
11
11
|
|
|
12
|
-
return "
|
|
12
|
+
return typeof mod === "object" && mod !== null && "default" in mod
|
|
13
|
+
? mod.default
|
|
14
|
+
: mod;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
const DEFAULT_CONFIG_PATHS = [
|
package/src/cli/loadModels.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import fg from "fast-glob";
|
|
3
1
|
import * as prismicCT from "@prismicio/custom-types-client";
|
|
4
|
-
import type { CustomTypeModel, SharedSliceModel } from "@prismicio/
|
|
2
|
+
import type { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
5
|
import fetch from "node-fetch";
|
|
6
6
|
|
|
7
7
|
const isCustomTypeModel = (input: unknown): input is CustomTypeModel => {
|
package/src/cli/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TypesProvider } from "../generateTypes";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Configuration to control the generated types.
|
|
3
5
|
*/
|
|
@@ -26,6 +28,14 @@ export type Config = {
|
|
|
26
28
|
*/
|
|
27
29
|
output?: string;
|
|
28
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The package that provides TypeScript types for Prismic data. Most projects
|
|
33
|
+
* will not need to configure this option.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue Automatically detected using the project's `package.json`.
|
|
36
|
+
*/
|
|
37
|
+
typesProvider?: TypesProvider;
|
|
38
|
+
|
|
29
39
|
/**
|
|
30
40
|
* Configuration for automatic `@prismicio/client` integration.
|
|
31
41
|
*/
|
package/src/constants.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomTypeModelFieldType } from "@prismicio/
|
|
1
|
+
import type { CustomTypeModelFieldType } from "@prismicio/client";
|
|
2
2
|
|
|
3
3
|
export const BLANK_LINE_IDENTIFIER = "// ___BLANK_LINE_TO_BE_REPLACED___";
|
|
4
4
|
|
|
@@ -9,7 +9,10 @@ export const SHARED_SLICES_DOCUMENTATION_URL =
|
|
|
9
9
|
"https://prismic.io/docs/core-concepts/reusing-slices";
|
|
10
10
|
|
|
11
11
|
export const FIELD_DOCUMENTATION_URLS: Record<
|
|
12
|
-
Exclude<
|
|
12
|
+
Exclude<
|
|
13
|
+
(typeof CustomTypeModelFieldType)[keyof typeof CustomTypeModelFieldType],
|
|
14
|
+
"Range" | "Separator"
|
|
15
|
+
>,
|
|
13
16
|
string
|
|
14
17
|
> = {
|
|
15
18
|
UID: "https://prismic.io/docs/core-concepts/uid",
|
|
@@ -28,5 +31,5 @@ export const FIELD_DOCUMENTATION_URLS: Record<
|
|
|
28
31
|
Group: "https://prismic.io/docs/core-concepts/group",
|
|
29
32
|
IntegrationFields: "https://prismic.io/docs/core-concepts/integration-fields",
|
|
30
33
|
Slices: "https://prismic.io/docs/core-concepts/slices",
|
|
31
|
-
|
|
34
|
+
Choice: "https://prismic.io/docs/core-concepts/slices",
|
|
32
35
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
import { TypesProvider } from "./generateTypes";
|
|
4
|
+
|
|
5
|
+
export type DetectTypesProviderConfig = {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Detects which types provider should be used for a project.
|
|
11
|
+
*
|
|
12
|
+
* @param config - Configures the detection.
|
|
13
|
+
*
|
|
14
|
+
* @returns The types provider identifier to use, or `undefined` if on cannot be
|
|
15
|
+
* determined.
|
|
16
|
+
*/
|
|
17
|
+
export const detectTypesProvider = async (
|
|
18
|
+
config: DetectTypesProviderConfig = {},
|
|
19
|
+
): Promise<TypesProvider | undefined> => {
|
|
20
|
+
const require = createRequire(config.cwd || process.cwd());
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
// Only @prismicio/client >= v7 exports types.
|
|
24
|
+
Number.parseInt(
|
|
25
|
+
require("@prismicio/client/package.json").version.split(".")[0],
|
|
26
|
+
) >= 7
|
|
27
|
+
) {
|
|
28
|
+
return "@prismicio/client";
|
|
29
|
+
} else if (require.resolve("@prismicio/types")) {
|
|
30
|
+
return "@prismicio/types";
|
|
31
|
+
}
|
|
32
|
+
};
|
package/src/generateTypes.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
2
|
+
import { ModuleDeclarationKind, Project } from "ts-morph";
|
|
3
3
|
|
|
4
|
-
import { BLANK_LINE_IDENTIFIER } from "./constants";
|
|
5
4
|
import { addTypeAliasForCustomType } from "./lib/addTypeAliasForCustomType";
|
|
6
5
|
import { addTypeAliasForSharedSlice } from "./lib/addTypeAliasForSharedSlice";
|
|
6
|
+
import { buildTypeName } from "./lib/buildTypeName";
|
|
7
7
|
import { getSourceFileText } from "./lib/getSourceFileText";
|
|
8
|
+
|
|
8
9
|
import { FieldConfigs } from "./types";
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
import { BLANK_LINE_IDENTIFIER } from "./constants";
|
|
12
|
+
|
|
13
|
+
export type TypesProvider = "@prismicio/client" | "@prismicio/types";
|
|
10
14
|
|
|
11
15
|
export type GenerateTypesConfig = {
|
|
12
16
|
customTypeModels?: CustomTypeModel[];
|
|
13
17
|
sharedSliceModels?: SharedSliceModel[];
|
|
14
18
|
localeIDs?: string[];
|
|
15
19
|
fieldConfigs?: FieldConfigs;
|
|
20
|
+
typesProvider?: TypesProvider;
|
|
16
21
|
clientIntegration?: {
|
|
17
22
|
includeCreateClientInterface?: boolean;
|
|
18
23
|
includeContentNamespace?: boolean;
|
|
@@ -27,8 +32,8 @@ export const generateTypes = (config: GenerateTypesConfig = {}) => {
|
|
|
27
32
|
const sourceFile = project.createSourceFile("types.d.ts");
|
|
28
33
|
|
|
29
34
|
sourceFile.addImportDeclaration({
|
|
30
|
-
moduleSpecifier: "@prismicio/types",
|
|
31
|
-
namespaceImport: "
|
|
35
|
+
moduleSpecifier: config.typesProvider || "@prismicio/types",
|
|
36
|
+
namespaceImport: "prismic",
|
|
32
37
|
isTypeOnly: true,
|
|
33
38
|
});
|
|
34
39
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { generateTypes } from "./generateTypes";
|
|
2
|
-
export type { GenerateTypesConfig } from "./generateTypes";
|
|
2
|
+
export type { GenerateTypesConfig, TypesProvider } from "./generateTypes";
|
|
3
|
+
|
|
4
|
+
export { detectTypesProvider } from "./detectTypesProvider";
|
|
5
|
+
export type { DetectTypesProviderConfig } from "./detectTypesProvider";
|
|
3
6
|
|
|
4
7
|
// The CLI configuration type is exported at the root level for ease of access.
|
|
5
8
|
// It is not used in the the library's code.
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
CustomTypeModelField,
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
|
-
} from "@prismicio/
|
|
6
|
+
} from "@prismicio/client";
|
|
7
7
|
import {
|
|
8
|
-
CustomTypeModelSliceType,
|
|
9
8
|
CustomTypeModelLinkSelectType,
|
|
10
|
-
|
|
9
|
+
CustomTypeModelSliceType,
|
|
10
|
+
} from "@prismicio/client";
|
|
11
11
|
import type { InterfaceDeclaration, SourceFile } from "ts-morph";
|
|
12
12
|
|
|
13
13
|
import { FieldConfigs, PathElement } from "../types";
|
|
@@ -42,7 +42,7 @@ const addInterfacePropertyForField = (
|
|
|
42
42
|
case "Boolean": {
|
|
43
43
|
config.interface.addProperty({
|
|
44
44
|
name: config.id,
|
|
45
|
-
type: "
|
|
45
|
+
type: "prismic.BooleanField",
|
|
46
46
|
docs: buildFieldDocs({
|
|
47
47
|
id: config.id,
|
|
48
48
|
model: config.model,
|
|
@@ -57,7 +57,7 @@ const addInterfacePropertyForField = (
|
|
|
57
57
|
case "Color": {
|
|
58
58
|
config.interface.addProperty({
|
|
59
59
|
name: config.id,
|
|
60
|
-
type: "
|
|
60
|
+
type: "prismic.ColorField",
|
|
61
61
|
docs: buildFieldDocs({
|
|
62
62
|
id: config.id,
|
|
63
63
|
model: config.model,
|
|
@@ -72,7 +72,7 @@ const addInterfacePropertyForField = (
|
|
|
72
72
|
case "Date": {
|
|
73
73
|
config.interface.addProperty({
|
|
74
74
|
name: config.id,
|
|
75
|
-
type: "
|
|
75
|
+
type: "prismic.DateField",
|
|
76
76
|
docs: buildFieldDocs({
|
|
77
77
|
id: config.id,
|
|
78
78
|
model: config.model,
|
|
@@ -102,10 +102,10 @@ const addInterfacePropertyForField = (
|
|
|
102
102
|
name: config.id,
|
|
103
103
|
type:
|
|
104
104
|
providerTypes.length > 0
|
|
105
|
-
? `
|
|
105
|
+
? `prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypes.join(
|
|
106
106
|
" | ",
|
|
107
107
|
)})>`
|
|
108
|
-
: "
|
|
108
|
+
: "prismic.EmbedField",
|
|
109
109
|
docs: buildFieldDocs({
|
|
110
110
|
id: config.id,
|
|
111
111
|
model: config.model,
|
|
@@ -120,7 +120,7 @@ const addInterfacePropertyForField = (
|
|
|
120
120
|
case "GeoPoint": {
|
|
121
121
|
config.interface.addProperty({
|
|
122
122
|
name: config.id,
|
|
123
|
-
type: "
|
|
123
|
+
type: "prismic.GeoPointField",
|
|
124
124
|
docs: buildFieldDocs({
|
|
125
125
|
id: config.id,
|
|
126
126
|
model: config.model,
|
|
@@ -143,7 +143,7 @@ const addInterfacePropertyForField = (
|
|
|
143
143
|
|
|
144
144
|
config.interface.addProperty({
|
|
145
145
|
name: config.id,
|
|
146
|
-
type: `
|
|
146
|
+
type: `prismic.ImageField<${thumbnailNames}>`,
|
|
147
147
|
docs: buildFieldDocs({
|
|
148
148
|
id: config.id,
|
|
149
149
|
model: config.model,
|
|
@@ -154,7 +154,7 @@ const addInterfacePropertyForField = (
|
|
|
154
154
|
} else {
|
|
155
155
|
config.interface.addProperty({
|
|
156
156
|
name: config.id,
|
|
157
|
-
type: "
|
|
157
|
+
type: "prismic.ImageField<never>",
|
|
158
158
|
docs: buildFieldDocs({
|
|
159
159
|
id: config.id,
|
|
160
160
|
model: config.model,
|
|
@@ -177,8 +177,8 @@ const addInterfacePropertyForField = (
|
|
|
177
177
|
config.interface.addProperty({
|
|
178
178
|
name: config.id,
|
|
179
179
|
type: catalogType
|
|
180
|
-
? `
|
|
181
|
-
: "
|
|
180
|
+
? `prismic.IntegrationFields<${catalogType}>`
|
|
181
|
+
: "prismic.IntegrationFields",
|
|
182
182
|
docs: buildFieldDocs({
|
|
183
183
|
id: config.id,
|
|
184
184
|
model: config.model,
|
|
@@ -200,10 +200,10 @@ const addInterfacePropertyForField = (
|
|
|
200
200
|
"customtypes" in config.model.config &&
|
|
201
201
|
config.model.config.customtypes &&
|
|
202
202
|
config.model.config.customtypes.length > 0
|
|
203
|
-
? `
|
|
203
|
+
? `prismic.RelationField<${config.model.config.customtypes
|
|
204
204
|
.map((type) => `"${type}"`)
|
|
205
205
|
.join(" | ")}>`
|
|
206
|
-
: "
|
|
206
|
+
: "prismic.RelationField",
|
|
207
207
|
docs: buildFieldDocs({
|
|
208
208
|
id: config.id,
|
|
209
209
|
model: config.model,
|
|
@@ -218,7 +218,7 @@ const addInterfacePropertyForField = (
|
|
|
218
218
|
case CustomTypeModelLinkSelectType.Media: {
|
|
219
219
|
config.interface.addProperty({
|
|
220
220
|
name: config.id,
|
|
221
|
-
type: "
|
|
221
|
+
type: "prismic.LinkToMediaField",
|
|
222
222
|
docs: buildFieldDocs({
|
|
223
223
|
id: config.id,
|
|
224
224
|
model: config.model,
|
|
@@ -233,7 +233,7 @@ const addInterfacePropertyForField = (
|
|
|
233
233
|
default: {
|
|
234
234
|
config.interface.addProperty({
|
|
235
235
|
name: config.id,
|
|
236
|
-
type: "
|
|
236
|
+
type: "prismic.LinkField",
|
|
237
237
|
docs: buildFieldDocs({
|
|
238
238
|
id: config.id,
|
|
239
239
|
model: config.model,
|
|
@@ -250,7 +250,7 @@ const addInterfacePropertyForField = (
|
|
|
250
250
|
case "Number": {
|
|
251
251
|
config.interface.addProperty({
|
|
252
252
|
name: config.id,
|
|
253
|
-
type: "
|
|
253
|
+
type: "prismic.NumberField",
|
|
254
254
|
docs: buildFieldDocs({
|
|
255
255
|
id: config.id,
|
|
256
256
|
model: config.model,
|
|
@@ -274,7 +274,7 @@ const addInterfacePropertyForField = (
|
|
|
274
274
|
if (isTitleField) {
|
|
275
275
|
config.interface.addProperty({
|
|
276
276
|
name: config.id,
|
|
277
|
-
type: "
|
|
277
|
+
type: "prismic.TitleField",
|
|
278
278
|
docs: buildFieldDocs({
|
|
279
279
|
id: config.id,
|
|
280
280
|
model: config.model,
|
|
@@ -285,7 +285,7 @@ const addInterfacePropertyForField = (
|
|
|
285
285
|
} else {
|
|
286
286
|
config.interface.addProperty({
|
|
287
287
|
name: config.id,
|
|
288
|
-
type: "
|
|
288
|
+
type: "prismic.RichTextField",
|
|
289
289
|
docs: buildFieldDocs({
|
|
290
290
|
id: config.id,
|
|
291
291
|
model: config.model,
|
|
@@ -307,7 +307,7 @@ const addInterfacePropertyForField = (
|
|
|
307
307
|
if (hasDefault) {
|
|
308
308
|
config.interface.addProperty({
|
|
309
309
|
name: config.id,
|
|
310
|
-
type: `
|
|
310
|
+
type: `prismic.SelectField<${options || "string"}, "filled">`,
|
|
311
311
|
docs: buildFieldDocs({
|
|
312
312
|
id: config.id,
|
|
313
313
|
model: config.model,
|
|
@@ -318,7 +318,7 @@ const addInterfacePropertyForField = (
|
|
|
318
318
|
} else {
|
|
319
319
|
config.interface.addProperty({
|
|
320
320
|
name: config.id,
|
|
321
|
-
type: `
|
|
321
|
+
type: `prismic.SelectField<${options}>`,
|
|
322
322
|
docs: buildFieldDocs({
|
|
323
323
|
id: config.id,
|
|
324
324
|
model: config.model,
|
|
@@ -334,7 +334,7 @@ const addInterfacePropertyForField = (
|
|
|
334
334
|
case "Text": {
|
|
335
335
|
config.interface.addProperty({
|
|
336
336
|
name: config.id,
|
|
337
|
-
type: "
|
|
337
|
+
type: "prismic.KeyTextField",
|
|
338
338
|
docs: buildFieldDocs({
|
|
339
339
|
id: config.id,
|
|
340
340
|
model: config.model,
|
|
@@ -349,7 +349,7 @@ const addInterfacePropertyForField = (
|
|
|
349
349
|
case "Timestamp": {
|
|
350
350
|
config.interface.addProperty({
|
|
351
351
|
name: config.id,
|
|
352
|
-
type: "
|
|
352
|
+
type: "prismic.TimestampField",
|
|
353
353
|
docs: buildFieldDocs({
|
|
354
354
|
id: config.id,
|
|
355
355
|
model: config.model,
|
|
@@ -408,7 +408,7 @@ const addInterfacePropertyForField = (
|
|
|
408
408
|
|
|
409
409
|
config.interface.addProperty({
|
|
410
410
|
name: config.id,
|
|
411
|
-
type: `
|
|
411
|
+
type: `prismic.GroupField<Simplify<${itemInterface.getName()}>>`,
|
|
412
412
|
docs: buildFieldDocs({
|
|
413
413
|
id: config.id,
|
|
414
414
|
model: config.model,
|
|
@@ -569,7 +569,7 @@ const addInterfacePropertyForField = (
|
|
|
569
569
|
choiceId,
|
|
570
570
|
"Slice",
|
|
571
571
|
),
|
|
572
|
-
type: `
|
|
572
|
+
type: `prismic.Slice<"${choiceId}", ${
|
|
573
573
|
primaryInterface
|
|
574
574
|
? `Simplify<${primaryInterface.getName()}>`
|
|
575
575
|
: "Record<string, never>"
|
|
@@ -617,7 +617,7 @@ const addInterfacePropertyForField = (
|
|
|
617
617
|
|
|
618
618
|
config.interface.addProperty({
|
|
619
619
|
name: config.id,
|
|
620
|
-
type: `
|
|
620
|
+
type: `prismic.SliceZone<${slicesType.getName()}>`,
|
|
621
621
|
docs: buildFieldDocs({
|
|
622
622
|
id: config.id,
|
|
623
623
|
model: config.model,
|