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
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { CustomTypeModel, CustomTypeModelField } from "@prismicio/
|
|
1
|
+
import type { CustomTypeModel, CustomTypeModelField } from "@prismicio/client";
|
|
2
2
|
import type {
|
|
3
|
+
InterfaceDeclaration,
|
|
3
4
|
SourceFile,
|
|
4
5
|
TypeAliasDeclaration,
|
|
5
|
-
InterfaceDeclaration,
|
|
6
6
|
} from "ts-morph";
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { FieldConfigs } from "../types";
|
|
9
9
|
|
|
10
|
+
import { CUSTOM_TYPES_DOCUMENTATION_URL } from "../constants";
|
|
11
|
+
|
|
10
12
|
import { addInterfacePropertiesForFields } from "./addInterfacePropertiesForFields";
|
|
11
13
|
import { buildTypeName } from "./buildTypeName";
|
|
12
14
|
|
|
@@ -88,10 +90,10 @@ export const addTypeAliasForCustomType = ({
|
|
|
88
90
|
},
|
|
89
91
|
],
|
|
90
92
|
type: hasUIDField
|
|
91
|
-
? `
|
|
93
|
+
? `prismic.PrismicDocumentWithUID<Simplify<${dataInterface.getName()}>, "${
|
|
92
94
|
model.id
|
|
93
95
|
}", Lang>`
|
|
94
|
-
: `
|
|
96
|
+
: `prismic.PrismicDocumentWithoutUID<Simplify<${dataInterface.getName()}>, "${
|
|
95
97
|
model.id
|
|
96
98
|
}", Lang>`,
|
|
97
99
|
docs: [
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { SharedSliceModel } from "@prismicio/
|
|
1
|
+
import type { SharedSliceModel } from "@prismicio/client";
|
|
2
2
|
import type {
|
|
3
3
|
InterfaceDeclaration,
|
|
4
4
|
SourceFile,
|
|
5
5
|
TypeAliasDeclaration,
|
|
6
6
|
} from "ts-morph";
|
|
7
7
|
|
|
8
|
-
import { SHARED_SLICES_DOCUMENTATION_URL } from "../constants";
|
|
9
8
|
import { FieldConfigs } from "../types";
|
|
10
9
|
|
|
10
|
+
import { SHARED_SLICES_DOCUMENTATION_URL } from "../constants";
|
|
11
|
+
|
|
11
12
|
import { addInterfacePropertiesForFields } from "./addInterfacePropertiesForFields";
|
|
12
13
|
import { buildSharedSliceInterfaceNamePart } from "./buildSharedSliceInterfaceNamePart";
|
|
13
14
|
import { buildTypeName } from "./buildTypeName";
|
|
@@ -125,7 +126,7 @@ export const addTypeAliasForSharedSlice = (
|
|
|
125
126
|
buildSharedSliceInterfaceNamePart({ id: config.model.id }),
|
|
126
127
|
variation.id,
|
|
127
128
|
),
|
|
128
|
-
type: `
|
|
129
|
+
type: `prismic.SharedSliceVariation<"${variation.id}", ${
|
|
129
130
|
primaryInterface
|
|
130
131
|
? `Simplify<${primaryInterface.getName()}>`
|
|
131
132
|
: "Record<string, never>"
|
|
@@ -177,7 +178,7 @@ export const addTypeAliasForSharedSlice = (
|
|
|
177
178
|
name: buildTypeName(
|
|
178
179
|
buildSharedSliceInterfaceNamePart({ id: config.model.id }),
|
|
179
180
|
),
|
|
180
|
-
type: `
|
|
181
|
+
type: `prismic.SharedSlice<"${
|
|
181
182
|
config.model.id
|
|
182
183
|
}", ${variationsType.getName()}>`,
|
|
183
184
|
docs: [
|
|
@@ -3,10 +3,11 @@ import type {
|
|
|
3
3
|
CustomTypeModelField,
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
|
-
} from "@prismicio/
|
|
6
|
+
} from "@prismicio/client";
|
|
7
7
|
import type { JSDocableNodeStructure } from "ts-morph";
|
|
8
8
|
|
|
9
9
|
import { PathElement } from "../types";
|
|
10
|
+
|
|
10
11
|
import { getAPIIDPath } from "./getAPIIDPath";
|
|
11
12
|
import { getFieldDocumentationURL } from "./getFieldDocumentationURL";
|
|
12
13
|
import { getHumanReadableFieldPath } from "./getHumanReadableFieldPath";
|
package/src/lib/getAPIIDPath.ts
CHANGED
|
@@ -3,10 +3,11 @@ import type {
|
|
|
3
3
|
CustomTypeModelField,
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
|
-
} from "@prismicio/
|
|
7
|
-
import { CustomTypeModelFieldType } from "@prismicio/
|
|
6
|
+
} from "@prismicio/client";
|
|
7
|
+
import { CustomTypeModelFieldType } from "@prismicio/client";
|
|
8
8
|
|
|
9
9
|
import { PathElement } from "../types";
|
|
10
|
+
|
|
10
11
|
import { isCustomTypeModelField } from "./isCustomTypeModelField";
|
|
11
12
|
import { isCustomTypeModelSlice } from "./isCustomTypeModelSlice";
|
|
12
13
|
import { isSharedSliceModel } from "./isSharedSliceModel";
|
|
@@ -3,9 +3,10 @@ import type {
|
|
|
3
3
|
CustomTypeModelField,
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
|
-
} from "@prismicio/
|
|
6
|
+
} from "@prismicio/client";
|
|
7
7
|
|
|
8
8
|
import { PathElement } from "../types";
|
|
9
|
+
|
|
9
10
|
import { getHumanReadableModelName } from "./getHumanReadableModelName";
|
|
10
11
|
|
|
11
12
|
type GetHumanReadableFieldPathConfig = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CustomTypeModelField } from "@prismicio/
|
|
2
|
-
import { CustomTypeModelLinkSelectType } from "@prismicio/
|
|
1
|
+
import type { CustomTypeModelField } from "@prismicio/client";
|
|
2
|
+
import { CustomTypeModelLinkSelectType } from "@prismicio/client";
|
|
3
3
|
|
|
4
4
|
type GetFieldHumanReadableTypeConfig = {
|
|
5
5
|
model: CustomTypeModelField;
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
CustomTypeModelField,
|
|
4
4
|
CustomTypeModelSlice,
|
|
5
5
|
SharedSliceModel,
|
|
6
|
-
} from "@prismicio/
|
|
6
|
+
} from "@prismicio/client";
|
|
7
7
|
|
|
8
8
|
import { isCustomTypeModel } from "./isCustomTypeModel";
|
|
9
9
|
import { isCustomTypeModelField } from "./isCustomTypeModelField";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomTypeModel } from "@prismicio/
|
|
1
|
+
import type { CustomTypeModel } from "@prismicio/client";
|
|
2
2
|
|
|
3
3
|
export const isCustomTypeModel = (model: unknown): model is CustomTypeModel => {
|
|
4
4
|
return typeof model === "object" && model !== null && "json" in model;
|