prismic-ts-codegen 0.1.29-pr.80.577ac11 → 0.1.29
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/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cli/configSchema.cjs +31 -0
- package/dist/cli/configSchema.cjs.map +1 -0
- package/dist/cli/{configSchema.d.mts → configSchema.d.cts} +1 -1
- package/dist/cli/{configSchema.d.mts.map → configSchema.d.cts.map} +1 -1
- package/dist/cli/configSchema.d.ts +39 -0
- package/dist/cli/configSchema.d.ts.map +1 -0
- package/dist/cli/{configSchema.mjs → configSchema.js} +1 -1
- package/dist/cli/configSchema.js.map +1 -0
- package/dist/cli/constants.cjs +6 -0
- package/dist/cli/{constants.mjs.map → constants.cjs.map} +1 -1
- package/dist/cli/{constants.d.mts → constants.d.cts} +1 -1
- package/dist/cli/constants.d.cts.map +1 -0
- package/dist/cli/constants.d.ts +5 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/{constants.mjs → constants.js} +1 -1
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/loadConfig.cjs +22 -0
- package/dist/cli/loadConfig.cjs.map +1 -0
- package/dist/cli/{loadConfig.mjs → loadConfig.js} +1 -1
- package/dist/cli/loadConfig.js.map +1 -0
- package/dist/cli/loadLocaleIDs.cjs +21 -0
- package/dist/cli/loadLocaleIDs.cjs.map +1 -0
- package/dist/cli/{loadLocaleIDs.mjs → loadLocaleIDs.js} +1 -1
- package/dist/cli/loadLocaleIDs.js.map +1 -0
- package/dist/cli/loadModels.cjs +54 -0
- package/dist/cli/loadModels.cjs.map +1 -0
- package/dist/cli/{loadModels.mjs → loadModels.js} +1 -1
- package/dist/cli/loadModels.js.map +1 -0
- package/dist/cli.cjs +110 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/{cli.mjs → cli.js} +9 -10
- package/dist/cli.js.map +1 -0
- package/dist/constants.cjs +33 -0
- package/dist/{constants.mjs.map → constants.cjs.map} +1 -1
- package/dist/{constants.mjs → constants.js} +1 -1
- package/dist/constants.js.map +1 -0
- package/dist/detectTypesProvider.cjs +25 -0
- package/dist/{detectTypesProvider.mjs.map → detectTypesProvider.cjs.map} +1 -1
- package/dist/{detectTypesProvider.d.mts → detectTypesProvider.d.cts} +2 -2
- package/dist/{detectTypesProvider.d.mts.map → detectTypesProvider.d.cts.map} +1 -1
- package/dist/detectTypesProvider.d.ts +17 -0
- package/dist/detectTypesProvider.d.ts.map +1 -0
- package/dist/{detectTypesProvider.mjs → detectTypesProvider.js} +1 -1
- package/dist/detectTypesProvider.js.map +1 -0
- package/dist/generateTypes.cjs +144 -0
- package/dist/generateTypes.cjs.map +1 -0
- package/dist/{generateTypes.d.mts → generateTypes.d.cts} +2 -2
- package/dist/{generateTypes.d.mts.map → generateTypes.d.cts.map} +1 -1
- package/dist/generateTypes.d.ts +21 -0
- package/dist/generateTypes.d.ts.map +1 -0
- package/dist/{generateTypes.mjs → generateTypes.js} +6 -6
- package/dist/generateTypes.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/{index.d.mts → index.d.cts} +4 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/lib/addBlankLine.cjs +10 -0
- package/dist/lib/addBlankLine.cjs.map +1 -0
- package/dist/lib/{addBlankLine.mjs → addBlankLine.js} +2 -2
- package/dist/lib/addBlankLine.js.map +1 -0
- package/dist/lib/addLine.cjs +9 -0
- package/dist/lib/addLine.cjs.map +1 -0
- package/dist/lib/{addLine.mjs → addLine.js} +2 -2
- package/dist/lib/addLine.js.map +1 -0
- package/dist/lib/addSection.cjs +9 -0
- package/dist/lib/addSection.cjs.map +1 -0
- package/dist/lib/{addSection.mjs → addSection.js} +2 -2
- package/dist/lib/addSection.js.map +1 -0
- package/dist/lib/addTrailingNewLine.cjs +9 -0
- package/dist/lib/{addTrailingNewLine.mjs.map → addTrailingNewLine.cjs.map} +1 -1
- package/dist/lib/{addTrailingNewLine.mjs → addTrailingNewLine.js} +1 -1
- package/dist/lib/addTrailingNewLine.js.map +1 -0
- package/dist/lib/buildCustomTypeDataType.cjs +51 -0
- package/dist/lib/buildCustomTypeDataType.cjs.map +1 -0
- package/dist/lib/{buildCustomTypeDataType.mjs → buildCustomTypeDataType.js} +4 -4
- package/dist/lib/buildCustomTypeDataType.js.map +1 -0
- package/dist/lib/buildCustomTypeType.cjs +63 -0
- package/dist/lib/buildCustomTypeType.cjs.map +1 -0
- package/dist/lib/{buildCustomTypeType.mjs → buildCustomTypeType.js} +9 -9
- package/dist/lib/buildCustomTypeType.js.map +1 -0
- package/dist/lib/buildFieldDocs.cjs +66 -0
- package/dist/lib/buildFieldDocs.cjs.map +1 -0
- package/dist/lib/{buildFieldDocs.mjs → buildFieldDocs.js} +6 -6
- package/dist/lib/buildFieldDocs.js.map +1 -0
- package/dist/lib/buildFieldProperties.cjs +285 -0
- package/dist/lib/buildFieldProperties.cjs.map +1 -0
- package/dist/lib/{buildFieldProperties.mjs → buildFieldProperties.js} +7 -7
- package/dist/lib/buildFieldProperties.js.map +1 -0
- package/dist/lib/buildSharedSliceType.cjs +152 -0
- package/dist/lib/buildSharedSliceType.cjs.map +1 -0
- package/dist/lib/{buildSharedSliceType.mjs → buildSharedSliceType.js} +9 -9
- package/dist/lib/buildSharedSliceType.js.map +1 -0
- package/dist/lib/buildTypeName.cjs +12 -0
- package/dist/lib/buildTypeName.cjs.map +1 -0
- package/dist/lib/{buildTypeName.mjs → buildTypeName.js} +1 -1
- package/dist/lib/buildTypeName.js.map +1 -0
- package/dist/lib/buildUnion.cjs +8 -0
- package/dist/lib/{buildUnion.mjs.map → buildUnion.cjs.map} +1 -1
- package/dist/lib/{buildUnion.mjs → buildUnion.js} +1 -1
- package/dist/lib/buildUnion.js.map +1 -0
- package/dist/lib/checkHasUIDFIeld.cjs +8 -0
- package/dist/lib/{checkHasUIDFIeld.mjs.map → checkHasUIDFIeld.cjs.map} +1 -1
- package/dist/lib/{checkHasUIDFIeld.mjs → checkHasUIDFIeld.js} +1 -1
- package/dist/lib/checkHasUIDFIeld.js.map +1 -0
- package/dist/lib/getAPIIDPath.cjs +24 -0
- package/dist/lib/{getAPIIDPath.mjs.map → getAPIIDPath.cjs.map} +1 -1
- package/dist/lib/{getAPIIDPath.mjs → getAPIIDPath.js} +1 -1
- package/dist/lib/getAPIIDPath.js.map +1 -0
- package/dist/lib/getCacheKey.cjs +17 -0
- package/dist/lib/getCacheKey.cjs.map +1 -0
- package/dist/lib/{getCacheKey.mjs → getCacheKey.js} +1 -1
- package/dist/lib/getCacheKey.js.map +1 -0
- package/dist/lib/getHumanReadableModelName.cjs +15 -0
- package/dist/lib/{getHumanReadableModelName.mjs.map → getHumanReadableModelName.cjs.map} +1 -1
- package/dist/lib/{getHumanReadableModelName.mjs → getHumanReadableModelName.js} +1 -1
- package/dist/lib/getHumanReadableModelName.js.map +1 -0
- package/dist/lib/getHumanReadablePath.cjs +16 -0
- package/dist/lib/getHumanReadablePath.cjs.map +1 -0
- package/dist/lib/{getHumanReadablePath.mjs → getHumanReadablePath.js} +2 -2
- package/dist/lib/getHumanReadablePath.js.map +1 -0
- package/dist/{types.d.mts → types.d.cts} +1 -1
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +7 -2
- package/dist/cli/configSchema.mjs.map +0 -1
- package/dist/cli/constants.d.mts.map +0 -1
- package/dist/cli/loadConfig.mjs.map +0 -1
- package/dist/cli/loadLocaleIDs.mjs.map +0 -1
- package/dist/cli/loadModels.mjs.map +0 -1
- package/dist/cli.mjs.map +0 -1
- package/dist/generateTypes.mjs.map +0 -1
- package/dist/index.mjs +0 -4
- package/dist/lib/addBlankLine.mjs.map +0 -1
- package/dist/lib/addLine.mjs.map +0 -1
- package/dist/lib/addSection.mjs.map +0 -1
- package/dist/lib/buildCustomTypeDataType.mjs.map +0 -1
- package/dist/lib/buildCustomTypeType.mjs.map +0 -1
- package/dist/lib/buildFieldDocs.mjs.map +0 -1
- package/dist/lib/buildFieldProperties.mjs.map +0 -1
- package/dist/lib/buildSharedSliceType.mjs.map +0 -1
- package/dist/lib/buildTypeName.mjs.map +0 -1
- package/dist/lib/getCacheKey.mjs.map +0 -1
- package/dist/lib/getHumanReadablePath.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
- /package/dist/{cli.d.mts → cli.d.cts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/cli/configSchema.ts
|
|
4
|
+
/** Configuration to control the generated types. */
|
|
5
|
+
const configSchema = zod.z.object({
|
|
6
|
+
repositoryName: zod.z.string().optional(),
|
|
7
|
+
accessToken: zod.z.string().optional(),
|
|
8
|
+
customTypesAPIToken: zod.z.string().optional(),
|
|
9
|
+
output: zod.z.string().optional(),
|
|
10
|
+
typesProvider: zod.z.enum(["@prismicio/client", "@prismicio/types"]).optional(),
|
|
11
|
+
clientIntegration: zod.z.object({
|
|
12
|
+
includeCreateClientInterface: zod.z.boolean().optional(),
|
|
13
|
+
includeContentNamespace: zod.z.boolean().optional()
|
|
14
|
+
}).optional(),
|
|
15
|
+
locales: zod.z.union([zod.z.array(zod.z.string()), zod.z.object({
|
|
16
|
+
ids: zod.z.array(zod.z.string()).optional(),
|
|
17
|
+
fetchFromRepository: zod.z.boolean().optional()
|
|
18
|
+
})]).optional(),
|
|
19
|
+
models: zod.z.union([zod.z.array(zod.z.string()), zod.z.object({
|
|
20
|
+
files: zod.z.array(zod.z.string()).optional(),
|
|
21
|
+
fetchFromRepository: zod.z.boolean().optional()
|
|
22
|
+
})]).optional(),
|
|
23
|
+
fields: zod.z.object({
|
|
24
|
+
embed: zod.z.object({ providerTypes: zod.z.record(zod.z.string(), zod.z.string()).optional() }).optional(),
|
|
25
|
+
integrationFields: zod.z.object({ catalogTypes: zod.z.record(zod.z.string(), zod.z.string()).optional() }).optional()
|
|
26
|
+
}).optional()
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.configSchema = configSchema;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=configSchema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.cjs","names":["z"],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;;AAGA,MAAa,eAAeA,IAAAA,EAAE,OAAO;CAEpC,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAMrC,aAAaA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAMlC,qBAAqBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAM1C,QAAQA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAQ7B,eAAeA,IAAAA,EAAE,KAAK,CAAC,qBAAqB,mBAAmB,CAAC,CAAC,UAAU;CAG3E,mBAAmBA,IAAAA,EACjB,OAAO;EAgBP,8BAA8BA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAgBpD,yBAAyBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CAqBZ,SAASA,IAAAA,EACP,MAAM,CACNA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,EACnBA,IAAAA,EAAE,OAAO;EAUR,KAAKA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;EAMnC,qBAAqBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAQZ,QAAQA,IAAAA,EACN,MAAM,CACNA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,EACnBA,IAAAA,EAAE,OAAO;EAER,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;EAQrC,qBAAqBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAGZ,QAAQA,IAAAA,EACN,OAAO;EAEP,OAAOA,IAAAA,EACL,OAAO,EAcP,eAAeA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU,EAC1D,CAAC,CACD,UAAU;EAGZ,mBAAmBA,IAAAA,EACjB,OAAO,EAaP,cAAcA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU,EACzD,CAAC,CACD,UAAU;EACZ,CAAC,CACD,UAAU;CACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configSchema.d.
|
|
1
|
+
{"version":3,"file":"configSchema.d.cts","names":[],"sources":["../../src/cli/configSchema.ts"],"mappings":";;;;cAGa,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqLb,MAAA,GAAS,CAAA,CAAE,KAAA,QAAa,YAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/configSchema.d.ts
|
|
4
|
+
/** Configuration to control the generated types. */
|
|
5
|
+
declare const configSchema: z.ZodObject<{
|
|
6
|
+
repositoryName: z.ZodOptional<z.ZodString>;
|
|
7
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
8
|
+
customTypesAPIToken: z.ZodOptional<z.ZodString>;
|
|
9
|
+
output: z.ZodOptional<z.ZodString>;
|
|
10
|
+
typesProvider: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
"@prismicio/client": "@prismicio/client";
|
|
12
|
+
"@prismicio/types": "@prismicio/types";
|
|
13
|
+
}>>;
|
|
14
|
+
clientIntegration: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
includeCreateClientInterface: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
includeContentNamespace: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
locales: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
19
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
fetchFromRepository: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strip>]>>;
|
|
22
|
+
models: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
|
|
23
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
fetchFromRepository: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strip>]>>;
|
|
26
|
+
fields: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
embed: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
providerTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
integrationFields: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
catalogTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/** Configuration to control the generated types. */
|
|
36
|
+
type Config = z.infer<typeof configSchema>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Config };
|
|
39
|
+
//# sourceMappingURL=configSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.d.ts","names":[],"sources":["../../src/cli/configSchema.ts"],"mappings":";;;;cAGa,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqLb,MAAA,GAAS,CAAA,CAAE,KAAA,QAAa,YAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","names":[],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAGA,MAAa,eAAe,EAAE,OAAO;CAEpC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CAMrC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAMlC,qBAAqB,EAAE,QAAQ,CAAC,UAAU;CAM1C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAQ7B,eAAe,EAAE,KAAK,CAAC,qBAAqB,mBAAmB,CAAC,CAAC,UAAU;CAG3E,mBAAmB,EACjB,OAAO;EAgBP,8BAA8B,EAAE,SAAS,CAAC,UAAU;EAgBpD,yBAAyB,EAAE,SAAS,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CAqBZ,SAAS,EACP,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAUR,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAMnC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAQZ,QAAQ,EACN,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAER,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAQrC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAGZ,QAAQ,EACN,OAAO;EAEP,OAAO,EACL,OAAO,EAcP,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EAC1D,CAAC,CACD,UAAU;EAGZ,mBAAmB,EACjB,OAAO,EAaP,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EACzD,CAAC,CACD,UAAU;EACZ,CAAC,CACD,UAAU;CACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/cli/constants.ts"],"sourcesContent":["export const NON_EDITABLE_FILE_HEADER = \"// Code generated by prismic-ts-codegen. DO NOT EDIT.\";\n"],"mappings":";AAAA,MAAa,2BAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";cAAa,wBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";cAAa,wBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/cli/constants.ts"],"sourcesContent":["export const NON_EDITABLE_FILE_HEADER = \"// Code generated by prismic-ts-codegen. DO NOT EDIT.\";\n"],"mappings":";AAAA,MAAa,2BAA2B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
let path = require("path");
|
|
4
|
+
let jiti = require("jiti");
|
|
5
|
+
jiti = require_runtime.__toESM(jiti);
|
|
6
|
+
//#region src/cli/loadConfig.ts
|
|
7
|
+
const jiti$1 = (0, jiti.default)(process.cwd());
|
|
8
|
+
const loadModuleWithJiti = (id) => {
|
|
9
|
+
const mod = jiti$1(id);
|
|
10
|
+
return typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
|
|
11
|
+
};
|
|
12
|
+
const DEFAULT_CONFIG_PATHS = ["prismicCodegen.config.ts", "prismicCodegen.config.js"];
|
|
13
|
+
const loadConfig = (config) => {
|
|
14
|
+
if (config.path) if ((0, fs.existsSync)(config.path)) return loadModuleWithJiti((0, path.resolve)(config.path));
|
|
15
|
+
else throw new Error(`Config file does not exist: ${config.path}`);
|
|
16
|
+
else for (const configPath of DEFAULT_CONFIG_PATHS) if ((0, fs.existsSync)(configPath)) return loadModuleWithJiti((0, path.resolve)(configPath));
|
|
17
|
+
return {};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.loadConfig = loadConfig;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=loadConfig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadConfig.cjs","names":["jiti"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport _jiti from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = _jiti(process.cwd());\n\nconst loadModuleWithJiti = <TModule>(id: string): TModule => {\n\tconst mod = jiti(id) as TModule | { default: TModule };\n\n\treturn typeof mod === \"object\" && mod !== null && \"default\" in mod ? mod.default : mod;\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = (config: LoadConfigConfig): Config => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;;;AAOA,MAAMA,UAAAA,GAAAA,KAAAA,SAAa,QAAQ,KAAK,CAAC;AAEjC,MAAM,sBAA+B,OAAwB;CAC5D,MAAM,MAAMA,OAAK,GAAG;AAEpB,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAAM,IAAI,UAAU;;AAGpF,MAAM,uBAAuB,CAAC,4BAA4B,2BAA2B;AAMrF,MAAa,cAAc,WAAqC;AAC/D,KAAI,OAAO,KACV,MAAA,GAAA,GAAA,YAAe,OAAO,KAAK,CAC1B,QAAO,oBAAA,GAAA,KAAA,SAA+B,OAAO,KAAK,CAAC;KAEnD,OAAM,IAAI,MAAM,+BAA+B,OAAO,OAAO;KAG9D,MAAK,MAAM,cAAc,qBACxB,MAAA,GAAA,GAAA,YAAe,WAAW,CACzB,QAAO,oBAAA,GAAA,KAAA,SAA+B,WAAW,CAAC;AAMrD,QAAO,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadConfig.js","names":["resolvePath"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport _jiti from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = _jiti(process.cwd());\n\nconst loadModuleWithJiti = <TModule>(id: string): TModule => {\n\tconst mod = jiti(id) as TModule | { default: TModule };\n\n\treturn typeof mod === \"object\" && mod !== null && \"default\" in mod ? mod.default : mod;\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = (config: LoadConfigConfig): Config => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;AAOA,MAAM,OAAO,MAAM,QAAQ,KAAK,CAAC;AAEjC,MAAM,sBAA+B,OAAwB;CAC5D,MAAM,MAAM,KAAK,GAAG;AAEpB,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAAM,IAAI,UAAU;;AAGpF,MAAM,uBAAuB,CAAC,4BAA4B,2BAA2B;AAMrF,MAAa,cAAc,WAAqC;AAC/D,KAAI,OAAO,KACV,KAAI,WAAW,OAAO,KAAK,CAC1B,QAAO,mBAAmBA,QAAY,OAAO,KAAK,CAAC;KAEnD,OAAM,IAAI,MAAM,+BAA+B,OAAO,OAAO;KAG9D,MAAK,MAAM,cAAc,qBACxB,KAAI,WAAW,WAAW,CACzB,QAAO,mBAAmBA,QAAY,WAAW,CAAC;AAMrD,QAAO,EAAE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _prismicio_client = require("@prismicio/client");
|
|
3
|
+
_prismicio_client = require_runtime.__toESM(_prismicio_client);
|
|
4
|
+
let node_fetch = require("node-fetch");
|
|
5
|
+
node_fetch = require_runtime.__toESM(node_fetch);
|
|
6
|
+
//#region src/cli/loadLocaleIDs.ts
|
|
7
|
+
const loadLocaleIDs = async (config) => {
|
|
8
|
+
const localeIDs = new Set(config.localeIDs || []);
|
|
9
|
+
if ("repositoryName" in config && config.fetchFromRepository) {
|
|
10
|
+
const repository = await _prismicio_client.createClient(config.repositoryName, {
|
|
11
|
+
accessToken: config.accessToken,
|
|
12
|
+
fetch: node_fetch.default
|
|
13
|
+
}).getRepository();
|
|
14
|
+
for (const language of repository.languages) localeIDs.add(language.id);
|
|
15
|
+
}
|
|
16
|
+
return [...localeIDs];
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.loadLocaleIDs = loadLocaleIDs;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=loadLocaleIDs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadLocaleIDs.cjs","names":["prismic"],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport fetch from \"node-fetch\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;;;;;AAcA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,EAAE,CAAC;AAEzD,KAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJA,kBAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB,OAAA,WAAA;GACA,CAAC,CAE8B,eAAe;AAE/C,OAAK,MAAM,YAAY,WAAW,UACjC,WAAU,IAAI,SAAS,GAAG;;AAI5B,QAAO,CAAC,GAAG,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadLocaleIDs.js","names":[],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport fetch from \"node-fetch\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;;AAcA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,EAAE,CAAC;AAEzD,KAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJ,QAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB;GACA,CAAC,CAE8B,eAAe;AAE/C,OAAK,MAAM,YAAY,WAAW,UACjC,WAAU,IAAI,SAAS,GAAG;;AAI5B,QAAO,CAAC,GAAG,UAAU"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let fs = require("fs");
|
|
3
|
+
let node_fetch = require("node-fetch");
|
|
4
|
+
node_fetch = require_runtime.__toESM(node_fetch);
|
|
5
|
+
let _prismicio_custom_types_client = require("@prismicio/custom-types-client");
|
|
6
|
+
_prismicio_custom_types_client = require_runtime.__toESM(_prismicio_custom_types_client);
|
|
7
|
+
let fast_glob = require("fast-glob");
|
|
8
|
+
fast_glob = require_runtime.__toESM(fast_glob);
|
|
9
|
+
//#region src/cli/loadModels.ts
|
|
10
|
+
const isCustomTypeModel = (input) => {
|
|
11
|
+
return typeof input === "object" && input !== null && "json" in input;
|
|
12
|
+
};
|
|
13
|
+
const isSharedSliceModel = (input) => {
|
|
14
|
+
return typeof input === "object" && input !== null && "variations" in input;
|
|
15
|
+
};
|
|
16
|
+
const readJSONFromGlob = async (globs) => {
|
|
17
|
+
return (await (0, fast_glob.default)(globs.split(",").map((path) => path.trim()))).map((path) => {
|
|
18
|
+
const raw = (0, fs.readFileSync)(path, "utf8");
|
|
19
|
+
return JSON.parse(raw);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const loadModels = async (config) => {
|
|
23
|
+
const customTypeModels = {};
|
|
24
|
+
const sharedSliceModels = {};
|
|
25
|
+
if ("customTypesAPIToken" in config) {
|
|
26
|
+
const customTypesClient = _prismicio_custom_types_client.createClient({
|
|
27
|
+
repositoryName: config.repositoryName,
|
|
28
|
+
token: config.customTypesAPIToken,
|
|
29
|
+
fetch: node_fetch.default
|
|
30
|
+
});
|
|
31
|
+
if (config.fetchFromRepository) {
|
|
32
|
+
const [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([customTypesClient.getAllCustomTypes(), customTypesClient.getAllSharedSlices()]);
|
|
33
|
+
for (const customTypeModel of remoteCustomTypeModels) customTypeModels[customTypeModel.id] = customTypeModel;
|
|
34
|
+
for (const sharedSliceModel of remoteSharedSliceModels) sharedSliceModels[sharedSliceModel.id] = sharedSliceModel;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (config.localPaths) {
|
|
38
|
+
const models = (await Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))).flat();
|
|
39
|
+
for (const model of models) if (isCustomTypeModel(model)) customTypeModels[model.id] = model;
|
|
40
|
+
else if (isSharedSliceModel(model)) sharedSliceModels[model.id] = model;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
customTypeModels: Object.values(customTypeModels).sort((a, b) => {
|
|
44
|
+
return a.id.localeCompare(b.id);
|
|
45
|
+
}),
|
|
46
|
+
sharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {
|
|
47
|
+
return a.id.localeCompare(b.id);
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.loadModels = loadModels;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=loadModels.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadModels.cjs","names":["prismicCT"],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport * as prismicCT from \"@prismicio/custom-types-client\";\nimport fg from \"fast-glob\";\nimport fetch from \"node-fetch\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await fg(globs.split(\",\").map((path) => path.trim()));\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tconst customTypesClient = prismicCT.createClient({\n\t\t\trepositoryName: config.repositoryName,\n\t\t\ttoken: config.customTypesAPIToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tcustomTypesClient.getAllCustomTypes(),\n\t\t\t\tcustomTypesClient.getAllSharedSlices(),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;;;;;;;AAOA,MAAM,qBAAqB,UAA6C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAGjE,MAAM,sBAAsB,UAA8C;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;;AAGvE,MAAM,mBAAmB,OAAU,UAAgC;AAGlE,SAFc,OAAA,GAAA,UAAA,SAAS,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,EAEtD,KAAK,SAAS;EAC1B,MAAM,OAAA,GAAA,GAAA,cAAmB,MAAM,OAAO;AAEtC,SAAO,KAAK,MAAM,IAAI;GACrB;;AAmBH,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,EAAE;CAC5D,MAAM,oBAAsD,EAAE;AAE9D,KAAI,yBAAyB,QAAQ;EACpC,MAAM,oBAAoBA,+BAAU,aAAa;GAChD,gBAAgB,OAAO;GACvB,OAAO,OAAO;GACd,OAAA,WAAA;GACA,CAAC;AAEF,MAAI,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,kBAAkB,mBAAmB,EACrC,kBAAkB,oBAAoB,CACtC,CAAC;AAEF,QAAK,MAAM,mBAAmB,uBAC7B,kBAAiB,gBAAgB,MAAM;AAExC,QAAK,MAAM,oBAAoB,wBAC9B,mBAAkB,iBAAiB,MAAM;;;AAK5C,KAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,KAAK,CAAC,CAAC,EACzE,MAAM;AAER,OAAK,MAAM,SAAS,OACnB,KAAI,kBAAkB,MAAM,CAC3B,kBAAiB,MAAM,MAAM;WACnB,mBAAmB,MAAM,CACnC,mBAAkB,MAAM,MAAM;;AAKjC,QAAO;EACN,kBAAkB,OAAO,OAAO,iBAAiB,CAAC,MAAM,GAAG,MAAM;AAChE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF,mBAAmB,OAAO,OAAO,kBAAkB,CAAC,MAAM,GAAG,MAAM;AAClE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadModels.js","names":[],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport * as prismicCT from \"@prismicio/custom-types-client\";\nimport fg from \"fast-glob\";\nimport fetch from \"node-fetch\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await fg(globs.split(\",\").map((path) => path.trim()));\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tconst customTypesClient = prismicCT.createClient({\n\t\t\trepositoryName: config.repositoryName,\n\t\t\ttoken: config.customTypesAPIToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tcustomTypesClient.getAllCustomTypes(),\n\t\t\t\tcustomTypesClient.getAllSharedSlices(),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;;;AAOA,MAAM,qBAAqB,UAA6C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAGjE,MAAM,sBAAsB,UAA8C;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;;AAGvE,MAAM,mBAAmB,OAAU,UAAgC;AAGlE,SAFc,MAAM,GAAG,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,EAEtD,KAAK,SAAS;EAC1B,MAAM,MAAM,aAAa,MAAM,OAAO;AAEtC,SAAO,KAAK,MAAM,IAAI;GACrB;;AAmBH,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,EAAE;CAC5D,MAAM,oBAAsD,EAAE;AAE9D,KAAI,yBAAyB,QAAQ;EACpC,MAAM,oBAAoB,UAAU,aAAa;GAChD,gBAAgB,OAAO;GACvB,OAAO,OAAO;GACd;GACA,CAAC;AAEF,MAAI,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,kBAAkB,mBAAmB,EACrC,kBAAkB,oBAAoB,CACtC,CAAC;AAEF,QAAK,MAAM,mBAAmB,uBAC7B,kBAAiB,gBAAgB,MAAM;AAExC,QAAK,MAAM,oBAAoB,wBAC9B,mBAAkB,iBAAiB,MAAM;;;AAK5C,KAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,KAAK,CAAC,CAAC,EACzE,MAAM;AAER,OAAK,MAAM,SAAS,OACnB,KAAI,kBAAkB,MAAM,CAC3B,kBAAiB,MAAM,MAAM;WACnB,mBAAmB,MAAM,CACnC,mBAAkB,MAAM,MAAM;;AAKjC,QAAO;EACN,kBAAkB,OAAO,OAAO,iBAAiB,CAAC,MAAM,GAAG,MAAM;AAChE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF,mBAAmB,OAAO,OAAO,kBAAkB,CAAC,MAAM,GAAG,MAAM;AAClE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF"}
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_generateTypes = require("./generateTypes.cjs");
|
|
3
|
+
const require_detectTypesProvider = require("./detectTypesProvider.cjs");
|
|
4
|
+
const require_constants = require("./cli/constants.cjs");
|
|
5
|
+
require("./index.cjs");
|
|
6
|
+
const require_configSchema = require("./cli/configSchema.cjs");
|
|
7
|
+
const require_loadConfig = require("./cli/loadConfig.cjs");
|
|
8
|
+
const require_loadLocaleIDs = require("./cli/loadLocaleIDs.cjs");
|
|
9
|
+
const require_loadModels = require("./cli/loadModels.cjs");
|
|
10
|
+
let common_tags = require("common-tags");
|
|
11
|
+
let fs = require("fs");
|
|
12
|
+
let path = require("path");
|
|
13
|
+
let meow = require("meow");
|
|
14
|
+
meow = require_runtime.__toESM(meow);
|
|
15
|
+
//#region src/cli/index.ts
|
|
16
|
+
const cli = (0, meow.default)(`
|
|
17
|
+
Usage:
|
|
18
|
+
prismic-ts-codegen [options...]
|
|
19
|
+
prismic-ts-codegen init [options...]
|
|
20
|
+
|
|
21
|
+
Commands:
|
|
22
|
+
init [options]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
-c, --config <path> Path to a prismic-ts-codegen configuration file.
|
|
26
|
+
`, {
|
|
27
|
+
importMeta: {},
|
|
28
|
+
flags: { config: {
|
|
29
|
+
type: "string",
|
|
30
|
+
shortFlag: "c",
|
|
31
|
+
isRequired: false
|
|
32
|
+
} }
|
|
33
|
+
});
|
|
34
|
+
const main = async () => {
|
|
35
|
+
if (cli.input[0] === "init") {
|
|
36
|
+
const configPath = cli.flags.config || "prismicCodegen.config.ts";
|
|
37
|
+
if ((0, fs.existsSync)(configPath)) console.info(`\n${configPath} already exists.`);
|
|
38
|
+
else {
|
|
39
|
+
let contents = "";
|
|
40
|
+
if ((0, fs.existsSync)("slicemachine.config.json") || (0, fs.existsSync)("sm.json")) contents = common_tags.stripIndent`
|
|
41
|
+
import type { Config } from "prismic-ts-codegen";
|
|
42
|
+
|
|
43
|
+
const config: Config = {
|
|
44
|
+
output: "./types.generated.ts",
|
|
45
|
+
models: ["./customtypes/**/index.json", "./slices/**/model.json"],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default config;
|
|
49
|
+
`;
|
|
50
|
+
else contents = common_tags.stripIndent`
|
|
51
|
+
import type { Config } from "prismic-ts-codegen";
|
|
52
|
+
|
|
53
|
+
const config: Config = {
|
|
54
|
+
output: "./types.generated.ts",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default config;
|
|
58
|
+
`;
|
|
59
|
+
(0, fs.writeFileSync)(configPath, contents);
|
|
60
|
+
console.info(`\nCreated prismic-ts-codegen config file: ${configPath}`);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
const unvalidatedConfig = require_loadConfig.loadConfig({ path: cli.flags.config });
|
|
64
|
+
const result = require_configSchema.configSchema.safeParse(unvalidatedConfig);
|
|
65
|
+
if (result.success) {
|
|
66
|
+
const config = result.data;
|
|
67
|
+
const { customTypeModels, sharedSliceModels } = await require_loadModels.loadModels({
|
|
68
|
+
localPaths: Array.isArray(config.models) ? config.models : config.models?.files,
|
|
69
|
+
repositoryName: config.repositoryName,
|
|
70
|
+
customTypesAPIToken: config.customTypesAPIToken,
|
|
71
|
+
fetchFromRepository: config.models && "fetchFromRepository" in config.models && config.models.fetchFromRepository
|
|
72
|
+
});
|
|
73
|
+
const localeIDs = await require_loadLocaleIDs.loadLocaleIDs({
|
|
74
|
+
localeIDs: Array.isArray(config.locales) ? config.locales : config.locales?.ids,
|
|
75
|
+
repositoryName: config.repositoryName,
|
|
76
|
+
accessToken: config.accessToken,
|
|
77
|
+
fetchFromRepository: config.locales && "fetchFromRepository" in config.locales && config.locales.fetchFromRepository
|
|
78
|
+
});
|
|
79
|
+
const typesProvider = config.typesProvider || await require_detectTypesProvider.detectTypesProvider();
|
|
80
|
+
const hasCustomTypeModels = customTypeModels.length > 0;
|
|
81
|
+
if (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) console.info("[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.");
|
|
82
|
+
const types = require_generateTypes.generateTypes({
|
|
83
|
+
customTypeModels,
|
|
84
|
+
sharedSliceModels,
|
|
85
|
+
localeIDs,
|
|
86
|
+
fieldConfigs: config.fields,
|
|
87
|
+
clientIntegration: {
|
|
88
|
+
includeCreateClientInterface: hasCustomTypeModels ? config.clientIntegration?.includeCreateClientInterface ?? true : false,
|
|
89
|
+
includeContentNamespace: config.clientIntegration?.includeContentNamespace ?? true
|
|
90
|
+
},
|
|
91
|
+
typesProvider
|
|
92
|
+
});
|
|
93
|
+
const fileContents = `${require_constants.NON_EDITABLE_FILE_HEADER}\n\n${types}`;
|
|
94
|
+
if (config.output) {
|
|
95
|
+
(0, fs.writeFileSync)((0, path.resolve)(config.output), fileContents);
|
|
96
|
+
console.info(`\nGenerated types in: ${config.output}`);
|
|
97
|
+
} else process.stdout.write(types + "\n");
|
|
98
|
+
} else {
|
|
99
|
+
console.error(result.error.message);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
main().catch((error) => {
|
|
105
|
+
console.error(error);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
});
|
|
108
|
+
//#endregion
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["loadConfig","configSchema","loadModels","loadLocaleIDs","detectTypesProvider","generateTypes","NON_EDITABLE_FILE_HEADER"],"sources":["../src/cli/index.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { stripIndent } from \"common-tags\";\nimport meow from \"meow\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\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 result = configSchema.safeParse(unvalidatedConfig);\n\n\t\tif (result.success) {\n\t\t\tconst config = result.data;\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models) ? config.models : 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) ? config.locales : 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 = config.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) {\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: config.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\tconsole.error(result.error.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n};\n\nmain().catch((error) => {\n\tconsole.error(error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,OAAA,GAAA,KAAA,SACL;;;;;;;;;;IAWA;CACC,YAAA,EAAA;CACA,OAAO,EACN,QAAQ;EACP,MAAM;EACN,WAAW;EACX,YAAY;EACZ,EACD;CACD,CACD;AAED,MAAM,OAAO,YAAY;AACxB,KAAI,IAAI,MAAM,OAAO,QAAQ;EAC5B,MAAM,aAAa,IAAI,MAAM,UAAU;AAEvC,OAAA,GAAA,GAAA,YAAe,WAAW,CACzB,SAAQ,KAAK,KAAK,WAAW,kBAAkB;OACzC;GACN,IAAI,WAAW;AAEf,QAAA,GAAA,GAAA,YAAe,2BAA2B,KAAA,GAAA,GAAA,YAAe,UAAU,CAClE,YAAW,YAAA,WAAW;;;;;;;;;;OAWtB,YAAW,YAAA,WAAW;;;;;;;;;AAWvB,IAAA,GAAA,GAAA,eAAc,YAAY,SAAS;AAEnC,WAAQ,KAAK,6CAA6C,aAAa;;QAElE;EACN,MAAM,oBAAoBA,mBAAAA,WAAW,EAAE,MAAM,IAAI,MAAM,QAAQ,CAAC;EAEhE,MAAM,SAASC,qBAAAA,aAAa,UAAU,kBAAkB;AAExD,MAAI,OAAO,SAAS;GACnB,MAAM,SAAS,OAAO;GACtB,MAAM,EAAE,kBAAkB,sBAAsB,MAAMC,mBAAAA,WAAW;IAChE,YAAY,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,SAAS,OAAO,QAAQ;IAC1E,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,qBACC,OAAO,UACP,yBAAyB,OAAO,UAChC,OAAO,OAAO;IACf,CAAC;GAEF,MAAM,YAAY,MAAMC,sBAAAA,cAAc;IACrC,WAAW,MAAM,QAAQ,OAAO,QAAQ,GAAG,OAAO,UAAU,OAAO,SAAS;IAC5E,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;IAChB,CAAC;GAEF,MAAM,gBAAgB,OAAO,iBAAkB,MAAMC,4BAAAA,qBAAqB;GAE1E,MAAM,sBAAsB,iBAAiB,SAAS;AAEtD,OAAI,OAAO,mBAAmB,gCAAgC,CAAC,oBAC9D,SAAQ,KACP,gPACA;GAGF,MAAM,QAAQC,sBAAAA,cAAc;IAC3B;IACA;IACA;IACA,cAAc,OAAO;IACrB,mBAAmB;KAClB,8BAA8B,sBAC1B,OAAO,mBAAmB,gCAAgC,OAC3D;KACH,yBAAyB,OAAO,mBAAmB,2BAA2B;KAC9E;IACD;IACA,CAAC;GAEF,MAAM,eAAe,GAAGC,kBAAAA,yBAAyB,MAAM;AAEvD,OAAI,OAAO,QAAQ;AAClB,KAAA,GAAA,GAAA,gBAAA,GAAA,KAAA,SAA0B,OAAO,OAAO,EAAE,aAAa;AAEvD,YAAQ,KAAK,yBAAyB,OAAO,SAAS;SAEtD,SAAQ,OAAO,MAAM,QAAQ,KAAK;SAE7B;AACN,WAAQ,MAAM,OAAO,MAAM,QAAQ;AACnC,WAAQ,KAAK,EAAE;;;;AAKlB,MAAM,CAAC,OAAO,UAAU;AACvB,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EACd"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/{cli.mjs → cli.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { generateTypes } from "./generateTypes.
|
|
2
|
-
import { detectTypesProvider } from "./detectTypesProvider.
|
|
3
|
-
import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.
|
|
4
|
-
import "./index.
|
|
5
|
-
import { configSchema } from "./cli/configSchema.
|
|
6
|
-
import { loadConfig } from "./cli/loadConfig.
|
|
7
|
-
import { loadLocaleIDs } from "./cli/loadLocaleIDs.
|
|
8
|
-
import { loadModels } from "./cli/loadModels.
|
|
1
|
+
import { generateTypes } from "./generateTypes.js";
|
|
2
|
+
import { detectTypesProvider } from "./detectTypesProvider.js";
|
|
3
|
+
import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.js";
|
|
4
|
+
import "./index.js";
|
|
5
|
+
import { configSchema } from "./cli/configSchema.js";
|
|
6
|
+
import { loadConfig } from "./cli/loadConfig.js";
|
|
7
|
+
import { loadLocaleIDs } from "./cli/loadLocaleIDs.js";
|
|
8
|
+
import { loadModels } from "./cli/loadModels.js";
|
|
9
9
|
import { stripIndent } from "common-tags";
|
|
10
10
|
import { existsSync, writeFileSync } from "fs";
|
|
11
11
|
import { resolve } from "path";
|
|
@@ -104,6 +104,5 @@ main().catch((error) => {
|
|
|
104
104
|
process.exit(1);
|
|
105
105
|
});
|
|
106
106
|
//#endregion
|
|
107
|
-
export {};
|
|
108
107
|
|
|
109
|
-
//# sourceMappingURL=cli.
|
|
108
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":["resolvePath"],"sources":["../src/cli/index.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { stripIndent } from \"common-tags\";\nimport meow from \"meow\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\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 result = configSchema.safeParse(unvalidatedConfig);\n\n\t\tif (result.success) {\n\t\t\tconst config = result.data;\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models) ? config.models : 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) ? config.locales : 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 = config.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) {\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: config.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\tconsole.error(result.error.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n};\n\nmain().catch((error) => {\n\tconsole.error(error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,MAAM,KACX;;;;;;;;;;IAWA;CACC,YAAY,OAAO;CACnB,OAAO,EACN,QAAQ;EACP,MAAM;EACN,WAAW;EACX,YAAY;EACZ,EACD;CACD,CACD;AAED,MAAM,OAAO,YAAY;AACxB,KAAI,IAAI,MAAM,OAAO,QAAQ;EAC5B,MAAM,aAAa,IAAI,MAAM,UAAU;AAEvC,MAAI,WAAW,WAAW,CACzB,SAAQ,KAAK,KAAK,WAAW,kBAAkB;OACzC;GACN,IAAI,WAAW;AAEf,OAAI,WAAW,2BAA2B,IAAI,WAAW,UAAU,CAClE,YAAW,WAAW;;;;;;;;;;OAWtB,YAAW,WAAW;;;;;;;;;AAWvB,iBAAc,YAAY,SAAS;AAEnC,WAAQ,KAAK,6CAA6C,aAAa;;QAElE;EACN,MAAM,oBAAoB,WAAW,EAAE,MAAM,IAAI,MAAM,QAAQ,CAAC;EAEhE,MAAM,SAAS,aAAa,UAAU,kBAAkB;AAExD,MAAI,OAAO,SAAS;GACnB,MAAM,SAAS,OAAO;GACtB,MAAM,EAAE,kBAAkB,sBAAsB,MAAM,WAAW;IAChE,YAAY,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,SAAS,OAAO,QAAQ;IAC1E,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,qBACC,OAAO,UACP,yBAAyB,OAAO,UAChC,OAAO,OAAO;IACf,CAAC;GAEF,MAAM,YAAY,MAAM,cAAc;IACrC,WAAW,MAAM,QAAQ,OAAO,QAAQ,GAAG,OAAO,UAAU,OAAO,SAAS;IAC5E,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;IAChB,CAAC;GAEF,MAAM,gBAAgB,OAAO,iBAAkB,MAAM,qBAAqB;GAE1E,MAAM,sBAAsB,iBAAiB,SAAS;AAEtD,OAAI,OAAO,mBAAmB,gCAAgC,CAAC,oBAC9D,SAAQ,KACP,gPACA;GAGF,MAAM,QAAQ,cAAc;IAC3B;IACA;IACA;IACA,cAAc,OAAO;IACrB,mBAAmB;KAClB,8BAA8B,sBAC1B,OAAO,mBAAmB,gCAAgC,OAC3D;KACH,yBAAyB,OAAO,mBAAmB,2BAA2B;KAC9E;IACD;IACA,CAAC;GAEF,MAAM,eAAe,GAAG,yBAAyB,MAAM;AAEvD,OAAI,OAAO,QAAQ;AAClB,kBAAcA,QAAY,OAAO,OAAO,EAAE,aAAa;AAEvD,YAAQ,KAAK,yBAAyB,OAAO,SAAS;SAEtD,SAAQ,OAAO,MAAM,QAAQ,KAAK;SAE7B;AACN,WAAQ,MAAM,OAAO,MAAM,QAAQ;AACnC,WAAQ,KAAK,EAAE;;;;AAKlB,MAAM,CAAC,OAAO,UAAU;AACvB,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EACd"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const CUSTOM_TYPES_DOCUMENTATION_URL = "https://prismic.io/docs/content-modeling";
|
|
3
|
+
const SHARED_SLICES_DOCUMENTATION_URL = "https://prismic.io/docs/slices";
|
|
4
|
+
const FIELD_DOCUMENTATION_URLS = {
|
|
5
|
+
UID: "https://prismic.io/docs/fields/uid",
|
|
6
|
+
Boolean: "https://prismic.io/docs/fields/boolean",
|
|
7
|
+
Color: "https://prismic.io/docs/fields/color",
|
|
8
|
+
Date: "https://prismic.io/docs/fields/date",
|
|
9
|
+
Timestamp: "https://prismic.io/docs/fields/timestamp",
|
|
10
|
+
Number: "https://prismic.io/docs/fields/number",
|
|
11
|
+
Text: "https://prismic.io/docs/fields/text",
|
|
12
|
+
Select: "https://prismic.io/docs/fields/select",
|
|
13
|
+
StructuredText: "https://prismic.io/docs/fields/rich-text",
|
|
14
|
+
Image: "https://prismic.io/docs/fields/image",
|
|
15
|
+
Link: {
|
|
16
|
+
contentRelationship: "https://prismic.io/docs/fields/content-relationship",
|
|
17
|
+
link: "https://prismic.io/docs/fields/link",
|
|
18
|
+
linkToMedia: "https://prismic.io/docs/fields/link-to-media"
|
|
19
|
+
},
|
|
20
|
+
Embed: "https://prismic.io/docs/fields/embed",
|
|
21
|
+
GeoPoint: "https://prismic.io/docs/fields/geopoint",
|
|
22
|
+
Table: "https://prismic.io/docs/fields/table",
|
|
23
|
+
Group: "https://prismic.io/docs/fields/repeatable-group",
|
|
24
|
+
IntegrationFields: "https://prismic.io/docs/fields/integration",
|
|
25
|
+
Slices: "https://prismic.io/docs/slices",
|
|
26
|
+
Choice: "https://prismic.io/docs/slices"
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.CUSTOM_TYPES_DOCUMENTATION_URL = CUSTOM_TYPES_DOCUMENTATION_URL;
|
|
30
|
+
exports.FIELD_DOCUMENTATION_URLS = FIELD_DOCUMENTATION_URLS;
|
|
31
|
+
exports.SHARED_SLICES_DOCUMENTATION_URL = SHARED_SLICES_DOCUMENTATION_URL;
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"@prismicio/client\";\n\nexport const CUSTOM_TYPES_DOCUMENTATION_URL = \"https://prismic.io/docs/content-modeling\";\n\nexport const SHARED_SLICES_DOCUMENTATION_URL = \"https://prismic.io/docs/slices\";\n\nexport const FIELD_DOCUMENTATION_URLS = {\n\tUID: \"https://prismic.io/docs/fields/uid\",\n\tBoolean: \"https://prismic.io/docs/fields/boolean\",\n\tColor: \"https://prismic.io/docs/fields/color\",\n\tDate: \"https://prismic.io/docs/fields/date\",\n\tTimestamp: \"https://prismic.io/docs/fields/timestamp\",\n\tNumber: \"https://prismic.io/docs/fields/number\",\n\tText: \"https://prismic.io/docs/fields/text\",\n\tSelect: \"https://prismic.io/docs/fields/select\",\n\tStructuredText: \"https://prismic.io/docs/fields/rich-text\",\n\tImage: \"https://prismic.io/docs/fields/image\",\n\tLink: {\n\t\tcontentRelationship: \"https://prismic.io/docs/fields/content-relationship\",\n\t\tlink: \"https://prismic.io/docs/fields/link\",\n\t\tlinkToMedia: \"https://prismic.io/docs/fields/link-to-media\",\n\t},\n\tEmbed: \"https://prismic.io/docs/fields/embed\",\n\tGeoPoint: \"https://prismic.io/docs/fields/geopoint\",\n\tTable: \"https://prismic.io/docs/fields/table\",\n\tGroup: \"https://prismic.io/docs/fields/repeatable-group\",\n\tIntegrationFields: \"https://prismic.io/docs/fields/integration\",\n\tSlices: \"https://prismic.io/docs/slices\",\n\tChoice: \"https://prismic.io/docs/slices\",\n} satisfies Record<\n\tExclude<\n\t\t(typeof CustomTypeModelFieldType)[keyof typeof CustomTypeModelFieldType],\n\t\t\"Range\" | \"Separator\"\n\t>,\n\tstring | Record<string, string>\n>;\n"],"mappings":";AAEA,MAAa,iCAAiC;AAE9C,MAAa,kCAAkC;AAE/C,MAAa,2BAA2B;CACvC,KAAK;CACL,SAAS;CACT,OAAO;CACP,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,MAAM;EACL,qBAAqB;EACrB,MAAM;EACN,aAAa;EACb;CACD,OAAO;CACP,UAAU;CACV,OAAO;CACP,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,QAAQ;CACR"}
|