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 @@
|
|
|
1
|
+
{"version":3,"file":"buildFieldProperties.js","names":[],"sources":["../../src/lib/buildFieldProperties.ts"],"sourcesContent":["import { type CustomTypeModelField, CustomTypeModelFieldType } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\n\nimport type { AuxiliaryType, FieldConfigs, FieldPath } from \"../types\";\nimport { addLine } from \"./addLine\";\nimport { addSection } from \"./addSection\";\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { buildUnion } from \"./buildUnion\";\nimport { getHumanReadablePath } from \"./getHumanReadablePath\";\n\ntype BuildFieldPropertyArgs = Pick<\n\tBuildFieldPropertiesArgs,\n\t\"path\" | \"fieldConfigs\" | \"tabName\"\n> & {\n\tname: string;\n\tfield: CustomTypeModelField;\n};\n\ntype BuildFieldPropertyReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nfunction buildFieldProperty(args: BuildFieldPropertyArgs): BuildFieldPropertyReturnType {\n\tlet code = buildFieldDocs({\n\t\tname: args.name,\n\t\tfield: args.field,\n\t\tpath: args.path,\n\t\ttabName: args.tabName,\n\t});\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name =\n\t\targs.name.includes(\"-\") || args.name.includes(\":\") || /^[0-9]/.test(args.name)\n\t\t\t? `\"${args.name}\"`\n\t\t\t: args.name;\n\n\tswitch (args.field.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tcode = addLine(`${name}: prismic.BooleanField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tcode = addLine(`${name}: prismic.ColorField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tcode = addLine(`${name}: prismic.DateField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType = args.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst providerTypesUnion = buildUnion(providerTypes);\n\n\t\t\tcode =\n\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t`${name}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypesUnion})>`,\n\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t)\n\t\t\t\t\t: addLine(`${name}: prismic.EmbedField`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tcode = addLine(`${name}: prismic.GeoPointField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (args.field.config?.thumbnails && args.field.config.thumbnails.length > 0) {\n\t\t\t\tconst thumbnailNames = buildUnion(\n\t\t\t\t\targs.field.config.thumbnails.map((thumb) => `\"${thumb.name}\"`),\n\t\t\t\t);\n\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<${thumbnailNames}>;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<never>;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = args.field.config?.catalog\n\t\t\t\t? args.fieldConfigs.integrationFields?.catalogTypes?.[args.field.config.catalog]\n\t\t\t\t: undefined;\n\n\t\t\tif (catalogType) {\n\t\t\t\tcode = addLine(`${name}: prismic.IntegrationField<${catalogType}>;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.IntegrationField;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tconst variants =\n\t\t\t\targs.field.config &&\n\t\t\t\t\"variants\" in args.field.config &&\n\t\t\t\tArray.isArray(args.field.config.variants) &&\n\t\t\t\targs.field.config.variants.length > 0\n\t\t\t\t\t? args.field.config.variants\n\t\t\t\t\t\t\t.map((variant) => `\"${variant.replace(/\"/g, '\\\\\"')}\"`)\n\t\t\t\t\t\t\t.join(\" | \")\n\t\t\t\t\t: \"never\";\n\n\t\t\tswitch (args.field.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\tif (\n\t\t\t\t\t\t\"customtypes\" in args.field.config &&\n\t\t\t\t\t\targs.field.config.customtypes &&\n\t\t\t\t\t\targs.field.config.customtypes.length > 0\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst contentRelationshipUnion = buildUnion(\n\t\t\t\t\t\t\targs.field.config.customtypes.map((type) => {\n\t\t\t\t\t\t\t\tif (typeof type === \"string\") {\n\t\t\t\t\t\t\t\t\treturn `prismic.ContentRelationshipField<\"${type}\">`;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn `ContentRelationshipFieldWithData<${JSON.stringify([type])}>`;\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcode = addLine(`${name}: ${contentRelationshipUnion};`, code);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcode = addLine(`${name}: prismic.ContentRelationshipField;`, code);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\tcode = addLine(\n\t\t\t\t\t\t`${name}: prismic.LinkToMediaField<prismic.FieldState, ${variants}>;`,\n\t\t\t\t\t\tcode,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tlet type = `prismic.LinkField<string, string, unknown, prismic.FieldState, ${variants}>`;\n\n\t\t\t\t\tif (args.field.config?.repeat) {\n\t\t\t\t\t\ttype = `prismic.Repeatable<${type}>`;\n\t\t\t\t\t}\n\n\t\t\t\t\tcode = addLine(`${name}: ${type};`, code);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tcode = addLine(`${name}: prismic.NumberField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tcode = addLine(`${name}: prismic.RichTextField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options: string[] = args.field.config?.options?.map((option) => `\"${option}\"`) || [];\n\t\t\tconst optionsType = options.length ? buildUnion(options) : \"string\";\n\n\t\t\tconst hasDefault = Boolean(args.field.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tcode = addLine(`${name}: prismic.SelectField<${optionsType}, \"filled\">;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.SelectField${options.length > 0 ? `<${optionsType}>` : \"\"};`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Table\": {\n\t\t\tcode = addLine(`${name}: prismic.TableField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tcode = addLine(`${name}: prismic.KeyTextField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tcode = addLine(`${name}: prismic.TimestampField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst groupPathParts = args.path.filter(\n\t\t\t\t(part) =>\n\t\t\t\t\tpart.model !== undefined &&\n\t\t\t\t\t\"type\" in part.model &&\n\t\t\t\t\tpart.model.type === CustomTypeModelFieldType.Group,\n\t\t\t);\n\t\t\tconst isNestedGroup = groupPathParts.length > 0;\n\n\t\t\tlet itemName;\n\t\t\tif (\n\t\t\t\targs.path[0].model &&\n\t\t\t\t\"type\" in args.path[0].model &&\n\t\t\t\targs.path[0].model.type === \"SharedSlice\"\n\t\t\t) {\n\t\t\t\tconst [slicePathPart, variationPathPart, zonePathPart] = args.path;\n\n\t\t\t\titemName = buildTypeName(\n\t\t\t\t\tslicePathPart.name,\n\t\t\t\t\t\"Slice\",\n\t\t\t\t\tvariationPathPart.name,\n\t\t\t\t\tzonePathPart.name,\n\t\t\t\t\t...groupPathParts.map((part) => part.name),\n\t\t\t\t\targs.name,\n\t\t\t\t\t\"Item\",\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\titemName = buildTypeName(\n\t\t\t\t\targs.path[0].name,\n\t\t\t\t\t\"Document\",\n\t\t\t\t\t\"Data\",\n\t\t\t\t\t...groupPathParts.map((part) => part.name),\n\t\t\t\t\targs.name,\n\t\t\t\t\t\"Item\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t...args.path,\n\t\t\t\t{\n\t\t\t\t\tname: name,\n\t\t\t\t\tmodel: args.field,\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\tfields: args.field.config?.fields || {},\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\t\t\tauxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);\n\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\n\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: itemName,\n\t\t\t\tcode: source`\n\t\t\t\t\t/**\n\t\t\t\t\t * Item in *${humanReadablePath}*\n\t\t\t\t\t */\n\t\t\t\t\texport interface ${itemName} {\n\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t}\n\t\t\t\t`,\n\t\t\t});\n\t\t\tcontentTypeNames.push(itemName);\n\n\t\t\tif (isNestedGroup) {\n\t\t\t\tcode = addLine(`${name}: prismic.NestedGroupField<Simplify<${itemName}>>;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.GroupField<Simplify<${itemName}>>;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceNames: string[] = [];\n\n\t\t\tif (args.field.config?.choices) {\n\t\t\t\tfor (const choiceID in args.field.config.choices) {\n\t\t\t\t\tconst choice = args.field.config.choices[choiceID];\n\n\t\t\t\t\tif (choice.type === \"SharedSlice\") {\n\t\t\t\t\t\t// TODO: Verify that the Shared Slice\n\t\t\t\t\t\t// is provided to the global\n\t\t\t\t\t\t// `sharedSlices` array. If it is not,\n\t\t\t\t\t\t// the type won't exist, so we can't\n\t\t\t\t\t\t// add it to the union. We should\n\t\t\t\t\t\t// probably throw an error if we reach\n\t\t\t\t\t\t// that state, or maybe the input can\n\t\t\t\t\t\t// be validated early so we don't\n\t\t\t\t\t\t// generate any code using invalid\n\t\t\t\t\t\t// models.\n\t\t\t\t\t\tchoiceNames.push(buildTypeName(choiceID, \"Slice\"));\n\t\t\t\t\t} else if (choice.type === \"Slice\") {\n\t\t\t\t\t\tconst sliceName = buildTypeName(\n\t\t\t\t\t\t\targs.path[0].name,\n\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\targs.name,\n\t\t\t\t\t\t\tchoiceID,\n\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet primaryInterfaceName: string | undefined;\n\t\t\t\t\t\tif (choice[\"non-repeat\"] && Object.keys(choice[\"non-repeat\"]).length > 0) {\n\t\t\t\t\t\t\tprimaryInterfaceName = buildTypeName(sliceName, \"Primary\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"primary\",\n\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst primaryFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tauxiliaryTypes.push(...primaryFieldProperties.auxiliaryTypes);\n\t\t\t\t\t\t\tcontentTypeNames.push(...primaryFieldProperties.contentTypeNames);\n\n\t\t\t\t\t\t\tlet primaryCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\tprimaryCode = primaryFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${primaryInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${primaryFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\tprimaryCode,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: addLine(`export interface ${primaryInterfaceName} {}`, primaryCode);\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: primaryInterfaceName,\n\t\t\t\t\t\t\t\tcode: primaryCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontentTypeNames.push(primaryInterfaceName);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterfaceName: string | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterfaceName = buildTypeName(sliceName, \"Item\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"items\",\n\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tauxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);\n\t\t\t\t\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\n\n\t\t\t\t\t\t\tlet itemCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Item content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\titemCode = itemFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${itemInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\titemCode,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: addLine(`export interface ${itemInterfaceName} {}`, itemCode);\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: itemInterfaceName,\n\t\t\t\t\t\t\t\tcode: itemCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontentTypeNames.push(itemInterfaceName);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\tname: sliceName,\n\t\t\t\t\t\t\tcode: stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Slice for *${getHumanReadablePath({\n\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t})}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\texport type ${sliceName} = prismic.Slice<\"${choiceID}\", ${\n\t\t\t\t\t\t\t\t\tprimaryInterfaceName\n\t\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterfaceName}>`\n\t\t\t\t\t\t\t\t\t\t: `Record<string, never>`\n\t\t\t\t\t\t\t\t}, ${itemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`}>\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceNames.push(sliceName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst choiceUnionName = buildTypeName(\n\t\t\t\targs.path[0].name,\n\t\t\t\t\"Document\",\n\t\t\t\t\"Data\",\n\t\t\t\targs.name,\n\t\t\t\t\"Slice\",\n\t\t\t);\n\t\t\tconst choiceUnion = buildUnion(choiceNames);\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: choiceUnionName,\n\t\t\t\tcode: `type ${choiceUnionName} = ${choiceUnion}`,\n\t\t\t});\n\t\t\tcontentTypeNames.push(choiceUnionName);\n\n\t\t\tcode = addLine(`${name}: prismic.SliceZone<${choiceUnionName}>;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tcode = addLine(`${name}: unknown;`, code);\n\t\t}\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n\ntype BuildFieldPropertiesArgs = {\n\tfields: Record<string, CustomTypeModelField>;\n\tpath: FieldPath;\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\ntype BuildFieldPropertiesReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildFieldProperties(\n\targs: BuildFieldPropertiesArgs,\n): BuildFieldPropertiesReturnType {\n\tlet code = \"\";\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tfor (const name in args.fields) {\n\t\tconst field = args.fields[name];\n\n\t\tconst fieldProperty = buildFieldProperty({\n\t\t\tname,\n\t\t\tfield,\n\t\t\tpath: args.path,\n\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\ttabName: args.tabName,\n\t\t});\n\n\t\tcode = addSection(fieldProperty.code, code);\n\n\t\tauxiliaryTypes.push(...fieldProperty.auxiliaryTypes);\n\t\tcontentTypeNames.push(...fieldProperty.contentTypeNames);\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAS,mBAAmB,MAA4D;CACvF,IAAI,OAAO,eAAe;EACzB,MAAM,KAAK;EACX,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,SAAS,KAAK;EACd,CAAC;CAEF,MAAM,iBAAkC,EAAE;CAC1C,MAAM,mBAA6B,EAAE;CAErC,MAAM,OACL,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,SAAS,KAAK,KAAK,KAAK,GAC3E,IAAI,KAAK,KAAK,KACd,KAAK;AAET,SAAQ,KAAK,MAAM,MAAnB;EACC,KAAK,MAEJ;EAGD,KAAK;AACJ,UAAO,QAAQ,GAAG,KAAK,0BAA0B,KAAK;AAEtD;EAGD,KAAK;AACJ,UAAO,QAAQ,GAAG,KAAK,wBAAwB,KAAK;AAEpD;EAGD,KAAK;AACJ,UAAO,QAAQ,GAAG,KAAK,uBAAuB,KAAK;AAEnD;EAGD,KAAK,SAAS;GACb,MAAM,gBAA0B,EAAE;AAElC,OAAI,KAAK,aAAa,OAAO,cAC5B,MAAK,MAAM,gBAAgB,KAAK,aAAa,OAAO,eAAe;IAClE,MAAM,yBAAyB,KAAK,aAAa,OAAO,cAAc;AAEtE,kBAAc,KA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AAO;EAE1B,MAAM,gBAAgB,mBAAmB;GACxC;GACA;GACA,MAAM,KAAK;GACX,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,CAAC;AAEF,SAAO,WAAW,cAAc,MAAM,KAAK;AAE3C,iBAAe,KAAK,GAAG,cAAc,eAAe;AACpD,mBAAiB,KAAK,GAAG,cAAc,iBAAiB;;AAGzD,QAAO;EACN;EACA;EACA;EACA"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_addSection = require("./addSection.cjs");
|
|
3
|
+
const require_constants = require("../constants.cjs");
|
|
4
|
+
const require_buildTypeName = require("./buildTypeName.cjs");
|
|
5
|
+
const require_getHumanReadableModelName = require("./getHumanReadableModelName.cjs");
|
|
6
|
+
const require_getHumanReadablePath = require("./getHumanReadablePath.cjs");
|
|
7
|
+
const require_buildUnion = require("./buildUnion.cjs");
|
|
8
|
+
const require_buildFieldProperties = require("./buildFieldProperties.cjs");
|
|
9
|
+
const require_getCacheKey = require("./getCacheKey.cjs");
|
|
10
|
+
let common_tags = require("common-tags");
|
|
11
|
+
//#region src/lib/buildSharedSliceType.ts
|
|
12
|
+
function buildSharedSliceType(args) {
|
|
13
|
+
if (args.cache) {
|
|
14
|
+
const key = require_getCacheKey.getCacheKey([args.model, args.fieldConfigs]);
|
|
15
|
+
const cached = args.cache.get(key);
|
|
16
|
+
if (cached) return cached;
|
|
17
|
+
}
|
|
18
|
+
let code = "";
|
|
19
|
+
const auxiliaryTypes = [];
|
|
20
|
+
const contentTypeNames = [];
|
|
21
|
+
const name = require_buildTypeName.buildTypeName(args.model.id, "Slice");
|
|
22
|
+
const humanReadableName = require_getHumanReadableModelName.getHumanReadableModelName({
|
|
23
|
+
name: args.model.id,
|
|
24
|
+
model: args.model
|
|
25
|
+
});
|
|
26
|
+
const variationNames = [];
|
|
27
|
+
for (const variationModel of args.model.variations) {
|
|
28
|
+
const variationName = require_buildTypeName.buildTypeName(name, variationModel.id);
|
|
29
|
+
let primaryInterfaceName;
|
|
30
|
+
if (variationModel.primary && Object.keys(variationModel.primary).length > 0) {
|
|
31
|
+
primaryInterfaceName = require_buildTypeName.buildTypeName(variationName, "Primary");
|
|
32
|
+
const path = [
|
|
33
|
+
{
|
|
34
|
+
name: args.model.id,
|
|
35
|
+
model: args.model
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: variationModel.id,
|
|
39
|
+
label: variationModel.name
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "primary",
|
|
43
|
+
label: "Primary"
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
const humanReadablePath = require_getHumanReadablePath.getHumanReadablePath({ path });
|
|
47
|
+
const primaryFieldProperties = require_buildFieldProperties.buildFieldProperties({
|
|
48
|
+
fields: variationModel.primary,
|
|
49
|
+
fieldConfigs: args.fieldConfigs,
|
|
50
|
+
path
|
|
51
|
+
});
|
|
52
|
+
auxiliaryTypes.push(...primaryFieldProperties.auxiliaryTypes);
|
|
53
|
+
contentTypeNames.push(...primaryFieldProperties.contentTypeNames);
|
|
54
|
+
contentTypeNames.push(primaryInterfaceName);
|
|
55
|
+
const docs = common_tags.stripIndent`
|
|
56
|
+
/**
|
|
57
|
+
* Primary content in *${humanReadablePath}*
|
|
58
|
+
*/
|
|
59
|
+
`;
|
|
60
|
+
code = require_addSection.addSection(primaryFieldProperties.code ? common_tags.source`
|
|
61
|
+
${docs}
|
|
62
|
+
export interface ${primaryInterfaceName} {
|
|
63
|
+
${primaryFieldProperties.code}
|
|
64
|
+
}
|
|
65
|
+
` : common_tags.source`
|
|
66
|
+
${docs}
|
|
67
|
+
export interface ${primaryInterfaceName} {}
|
|
68
|
+
`, code);
|
|
69
|
+
}
|
|
70
|
+
let itemInterfaceName;
|
|
71
|
+
if (variationModel.items && Object.keys(variationModel.items).length > 0) {
|
|
72
|
+
itemInterfaceName = require_buildTypeName.buildTypeName(variationName, "Item");
|
|
73
|
+
const path = [{
|
|
74
|
+
name: args.model.id,
|
|
75
|
+
model: args.model
|
|
76
|
+
}, {
|
|
77
|
+
name: "items",
|
|
78
|
+
label: "Items"
|
|
79
|
+
}];
|
|
80
|
+
const humanReadablePath = require_getHumanReadablePath.getHumanReadablePath({ path });
|
|
81
|
+
const itemFieldProperties = require_buildFieldProperties.buildFieldProperties({
|
|
82
|
+
fields: variationModel.items,
|
|
83
|
+
fieldConfigs: args.fieldConfigs,
|
|
84
|
+
path
|
|
85
|
+
});
|
|
86
|
+
auxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);
|
|
87
|
+
contentTypeNames.push(...itemFieldProperties.contentTypeNames);
|
|
88
|
+
contentTypeNames.push(itemInterfaceName);
|
|
89
|
+
const docs = common_tags.stripIndent`
|
|
90
|
+
/**
|
|
91
|
+
* Primary content in *${humanReadablePath}*
|
|
92
|
+
*/
|
|
93
|
+
`;
|
|
94
|
+
code = require_addSection.addSection(itemFieldProperties.code ? common_tags.source`
|
|
95
|
+
${docs}
|
|
96
|
+
export interface ${itemInterfaceName} {
|
|
97
|
+
${itemFieldProperties.code}
|
|
98
|
+
}
|
|
99
|
+
` : common_tags.source`
|
|
100
|
+
${docs}
|
|
101
|
+
export interface ${itemInterfaceName} {}
|
|
102
|
+
`, code);
|
|
103
|
+
}
|
|
104
|
+
code = require_addSection.addSection(common_tags.source`
|
|
105
|
+
/**
|
|
106
|
+
* ${variationModel.name} variation for ${humanReadableName} Slice
|
|
107
|
+
*
|
|
108
|
+
* - **API ID**: \`${variationModel.id}\`
|
|
109
|
+
* - **Description**: ${variationModel.description || "*None*"}
|
|
110
|
+
* - **Documentation**: ${require_constants.SHARED_SLICES_DOCUMENTATION_URL}
|
|
111
|
+
*/
|
|
112
|
+
export type ${variationName} = prismic.SharedSliceVariation<"${variationModel.id}", ${primaryInterfaceName ? `Simplify<${primaryInterfaceName}>` : `Record<string, never>`}, ${itemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`}>;
|
|
113
|
+
`, code);
|
|
114
|
+
variationNames.push(variationName);
|
|
115
|
+
}
|
|
116
|
+
const variationUnionName = require_buildTypeName.buildTypeName(name, "Variation");
|
|
117
|
+
const variationsUnion = require_buildUnion.buildUnion(variationNames);
|
|
118
|
+
contentTypeNames.push(variationUnionName);
|
|
119
|
+
contentTypeNames.push(...variationNames);
|
|
120
|
+
code = require_addSection.addSection(common_tags.source`
|
|
121
|
+
/**
|
|
122
|
+
* Slice variation for *${humanReadableName}*
|
|
123
|
+
*/
|
|
124
|
+
type ${variationUnionName} = ${variationNames.length > 0 ? variationsUnion : "never"}
|
|
125
|
+
`, code);
|
|
126
|
+
code = require_addSection.addSection(common_tags.source`
|
|
127
|
+
/**
|
|
128
|
+
* ${humanReadableName} Shared Slice
|
|
129
|
+
*
|
|
130
|
+
* - **API ID**: \`${args.model.id}\`
|
|
131
|
+
* - **Description**: ${args.model.description || "*None*"}
|
|
132
|
+
* - **Documentation**: ${require_constants.SHARED_SLICES_DOCUMENTATION_URL}
|
|
133
|
+
*/
|
|
134
|
+
export type ${name} = prismic.SharedSlice<"${args.model.id}", ${variationUnionName}>;
|
|
135
|
+
`, code);
|
|
136
|
+
const result = {
|
|
137
|
+
name,
|
|
138
|
+
variationNames,
|
|
139
|
+
code,
|
|
140
|
+
auxiliaryTypes,
|
|
141
|
+
contentTypeNames
|
|
142
|
+
};
|
|
143
|
+
if (args.cache) {
|
|
144
|
+
const key = require_getCacheKey.getCacheKey([args.model, args.fieldConfigs]);
|
|
145
|
+
args.cache.set(key, result);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
exports.buildSharedSliceType = buildSharedSliceType;
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=buildSharedSliceType.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSharedSliceType.cjs","names":["getCacheKey","buildTypeName","getHumanReadableModelName","getHumanReadablePath","buildFieldProperties","addSection","SHARED_SLICES_DOCUMENTATION_URL","buildUnion"],"sources":["../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport type QuickLRU from \"quick-lru\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\nimport type { AuxiliaryType, FieldConfigs, FieldPath } from \"../types\";\nimport { addSection } from \"./addSection\";\nimport { buildFieldProperties } from \"./buildFieldProperties\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { buildUnion } from \"./buildUnion\";\nimport { getCacheKey } from \"./getCacheKey\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\nimport { getHumanReadablePath } from \"./getHumanReadablePath\";\n\ntype BuildSharedSliceTypeArgs = {\n\tmodel: SharedSliceModel;\n\tfieldConfigs: FieldConfigs;\n\tcache?: QuickLRU<string, unknown>;\n};\n\ntype BuildSharedSliceTypeReturnValue = {\n\tname: string;\n\tvariationNames: string[];\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildSharedSliceType(\n\targs: BuildSharedSliceTypeArgs\n): BuildSharedSliceTypeReturnValue {\n\tif (args.cache) {\n\t\tconst key = getCacheKey([args.model, args.fieldConfigs]);\n\t\tconst cached = args.cache.get(key);\n\n\t\tif (cached) {\n\t\t\treturn cached as BuildSharedSliceTypeReturnValue;\n\t\t}\n\t}\n\n\tlet code = \"\";\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name = buildTypeName(args.model.id, \"Slice\");\n\tconst humanReadableName = getHumanReadableModelName({\n\t\tname: args.model.id,\n\t\tmodel: args.model,\n\t});\n\n\tconst variationNames: string[] = [];\n\tfor (const variationModel of args.model.variations) {\n\t\tconst variationName = buildTypeName(name, variationModel.id);\n\n\t\tlet primaryInterfaceName: string | undefined;\n\t\tif (\n\t\t\tvariationModel.primary &&\n\t\t\tObject.keys(variationModel.primary).length > 0\n\t\t) {\n\t\t\tprimaryInterfaceName = buildTypeName(variationName, \"Primary\");\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t{\n\t\t\t\t\tname: args.model.id,\n\t\t\t\t\tmodel: args.model,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: variationModel.id,\n\t\t\t\t\tlabel: variationModel.name,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"primary\",\n\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst primaryFieldProperties = buildFieldProperties({\n\t\t\t\tfields: variationModel.primary,\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\t\t\tauxiliaryTypes.push(...primaryFieldProperties.auxiliaryTypes);\n\t\t\tcontentTypeNames.push(...primaryFieldProperties.contentTypeNames);\n\n\t\t\tcontentTypeNames.push(primaryInterfaceName);\n\n\t\t\tconst docs = stripIndent`\n\t\t\t\t/**\n\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t */\n\t\t\t`;\n\n\t\t\tcode = addSection(\n\t\t\t\tprimaryFieldProperties.code\n\t\t\t\t\t? source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${primaryInterfaceName} {\n\t\t\t\t\t\t\t${primaryFieldProperties.code}\n\t\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t: source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${primaryInterfaceName} {}\n\t\t\t\t\t`,\n\t\t\t\tcode\n\t\t\t);\n\t\t}\n\n\t\tlet itemInterfaceName: string | undefined;\n\t\tif (variationModel.items && Object.keys(variationModel.items).length > 0) {\n\t\t\titemInterfaceName = buildTypeName(variationName, \"Item\");\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t{\n\t\t\t\t\tname: args.model.id,\n\t\t\t\t\tmodel: args.model,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"items\",\n\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\tfields: variationModel.items,\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\t\t\tauxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);\n\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\n\n\t\t\tcontentTypeNames.push(itemInterfaceName);\n\n\t\t\tconst docs = stripIndent`\n\t\t\t\t/**\n\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t */\n\t\t\t`;\n\n\t\t\tcode = addSection(\n\t\t\t\titemFieldProperties.code\n\t\t\t\t\t? source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${itemInterfaceName} {\n\t\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t: source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${itemInterfaceName} {}\n\t\t\t\t\t`,\n\t\t\t\tcode\n\t\t\t);\n\t\t}\n\n\t\tcode = addSection(\n\t\t\tsource`\n\t\t\t\t/**\n\t\t\t\t * ${variationModel.name} variation for ${humanReadableName} Slice\n\t\t\t\t *\n\t\t\t\t * - **API ID**: \\`${variationModel.id}\\`\n\t\t\t\t * - **Description**: ${variationModel.description || \"*None*\"}\n\t\t\t\t * - **Documentation**: ${SHARED_SLICES_DOCUMENTATION_URL}\n\t\t\t\t */\n\t\t\t\texport type ${variationName} = prismic.SharedSliceVariation<\"${\n\t\t\t\tvariationModel.id\n\t\t\t}\", ${\n\t\t\t\tprimaryInterfaceName\n\t\t\t\t\t? `Simplify<${primaryInterfaceName}>`\n\t\t\t\t\t: `Record<string, never>`\n\t\t\t}, ${itemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`}>;\n\t\t\t`,\n\t\t\tcode\n\t\t);\n\n\t\tvariationNames.push(variationName);\n\t}\n\n\tconst variationUnionName = buildTypeName(name, \"Variation\");\n\tconst variationsUnion = buildUnion(variationNames);\n\n\tcontentTypeNames.push(variationUnionName);\n\tcontentTypeNames.push(...variationNames);\n\n\tcode = addSection(\n\t\tsource`\n\t\t\t/**\n\t\t\t * Slice variation for *${humanReadableName}*\n\t\t\t */\n\t\t\ttype ${variationUnionName} = ${\n\t\t\tvariationNames.length > 0 ? variationsUnion : \"never\"\n\t\t}\n\t\t`,\n\t\tcode\n\t);\n\n\tcode = addSection(\n\t\tsource`\n\t\t\t/**\n\t\t\t * ${humanReadableName} Shared Slice\n\t\t\t *\n\t\t\t * - **API ID**: \\`${args.model.id}\\`\n\t\t\t * - **Description**: ${args.model.description || \"*None*\"}\n\t\t\t * - **Documentation**: ${SHARED_SLICES_DOCUMENTATION_URL}\n\t\t\t */\n\t\t\texport type ${name} = prismic.SharedSlice<\"${\n\t\t\targs.model.id\n\t\t}\", ${variationUnionName}>;\n\t\t`,\n\t\tcode\n\t);\n\n\tconst result = {\n\t\tname,\n\t\tvariationNames,\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n\n\tif (args.cache) {\n\t\tconst key = getCacheKey([args.model, args.fieldConfigs]);\n\n\t\targs.cache.set(key, result);\n\t}\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,qBACf,MACkC;AAClC,KAAI,KAAK,OAAO;EACf,MAAM,MAAMA,oBAAAA,YAAY,CAAC,KAAK,OAAO,KAAK,aAAa,CAAC;EACxD,MAAM,SAAS,KAAK,MAAM,IAAI,IAAI;AAElC,MAAI,OACH,QAAO;;CAIT,IAAI,OAAO;CAEX,MAAM,iBAAkC,EAAE;CAC1C,MAAM,mBAA6B,EAAE;CAErC,MAAM,OAAOC,sBAAAA,c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ACA;CAED,MAAM,SAAS;EACd;EACA;EACA;EACA;EACA;EACA;AAED,KAAI,KAAK,OAAO;EACf,MAAM,MAAMN,oBAAAA,YAAY,CAAC,KAAK,OAAO,KAAK,aAAa,CAAC;AAExD,OAAK,MAAM,IAAI,KAAK,OAAO;;AAG5B,QAAO"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { addSection } from "./addSection.
|
|
2
|
-
import { SHARED_SLICES_DOCUMENTATION_URL } from "../constants.
|
|
3
|
-
import { buildTypeName } from "./buildTypeName.
|
|
4
|
-
import { getHumanReadableModelName } from "./getHumanReadableModelName.
|
|
5
|
-
import { getHumanReadablePath } from "./getHumanReadablePath.
|
|
6
|
-
import { buildUnion } from "./buildUnion.
|
|
7
|
-
import { buildFieldProperties } from "./buildFieldProperties.
|
|
8
|
-
import { getCacheKey } from "./getCacheKey.
|
|
1
|
+
import { addSection } from "./addSection.js";
|
|
2
|
+
import { SHARED_SLICES_DOCUMENTATION_URL } from "../constants.js";
|
|
3
|
+
import { buildTypeName } from "./buildTypeName.js";
|
|
4
|
+
import { getHumanReadableModelName } from "./getHumanReadableModelName.js";
|
|
5
|
+
import { getHumanReadablePath } from "./getHumanReadablePath.js";
|
|
6
|
+
import { buildUnion } from "./buildUnion.js";
|
|
7
|
+
import { buildFieldProperties } from "./buildFieldProperties.js";
|
|
8
|
+
import { getCacheKey } from "./getCacheKey.js";
|
|
9
9
|
import { source, stripIndent } from "common-tags";
|
|
10
10
|
//#region src/lib/buildSharedSliceType.ts
|
|
11
11
|
function buildSharedSliceType(args) {
|
|
@@ -148,4 +148,4 @@ function buildSharedSliceType(args) {
|
|
|
148
148
|
//#endregion
|
|
149
149
|
export { buildSharedSliceType };
|
|
150
150
|
|
|
151
|
-
//# sourceMappingURL=buildSharedSliceType.
|
|
151
|
+
//# sourceMappingURL=buildSharedSliceType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSharedSliceType.js","names":[],"sources":["../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport type QuickLRU from \"quick-lru\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\nimport type { AuxiliaryType, FieldConfigs, FieldPath } from \"../types\";\nimport { addSection } from \"./addSection\";\nimport { buildFieldProperties } from \"./buildFieldProperties\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { buildUnion } from \"./buildUnion\";\nimport { getCacheKey } from \"./getCacheKey\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\nimport { getHumanReadablePath } from \"./getHumanReadablePath\";\n\ntype BuildSharedSliceTypeArgs = {\n\tmodel: SharedSliceModel;\n\tfieldConfigs: FieldConfigs;\n\tcache?: QuickLRU<string, unknown>;\n};\n\ntype BuildSharedSliceTypeReturnValue = {\n\tname: string;\n\tvariationNames: string[];\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildSharedSliceType(\n\targs: BuildSharedSliceTypeArgs\n): BuildSharedSliceTypeReturnValue {\n\tif (args.cache) {\n\t\tconst key = getCacheKey([args.model, args.fieldConfigs]);\n\t\tconst cached = args.cache.get(key);\n\n\t\tif (cached) {\n\t\t\treturn cached as BuildSharedSliceTypeReturnValue;\n\t\t}\n\t}\n\n\tlet code = \"\";\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name = buildTypeName(args.model.id, \"Slice\");\n\tconst humanReadableName = getHumanReadableModelName({\n\t\tname: args.model.id,\n\t\tmodel: args.model,\n\t});\n\n\tconst variationNames: string[] = [];\n\tfor (const variationModel of args.model.variations) {\n\t\tconst variationName = buildTypeName(name, variationModel.id);\n\n\t\tlet primaryInterfaceName: string | undefined;\n\t\tif (\n\t\t\tvariationModel.primary &&\n\t\t\tObject.keys(variationModel.primary).length > 0\n\t\t) {\n\t\t\tprimaryInterfaceName = buildTypeName(variationName, \"Primary\");\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t{\n\t\t\t\t\tname: args.model.id,\n\t\t\t\t\tmodel: args.model,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: variationModel.id,\n\t\t\t\t\tlabel: variationModel.name,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"primary\",\n\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst primaryFieldProperties = buildFieldProperties({\n\t\t\t\tfields: variationModel.primary,\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\t\t\tauxiliaryTypes.push(...primaryFieldProperties.auxiliaryTypes);\n\t\t\tcontentTypeNames.push(...primaryFieldProperties.contentTypeNames);\n\n\t\t\tcontentTypeNames.push(primaryInterfaceName);\n\n\t\t\tconst docs = stripIndent`\n\t\t\t\t/**\n\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t */\n\t\t\t`;\n\n\t\t\tcode = addSection(\n\t\t\t\tprimaryFieldProperties.code\n\t\t\t\t\t? source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${primaryInterfaceName} {\n\t\t\t\t\t\t\t${primaryFieldProperties.code}\n\t\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t: source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${primaryInterfaceName} {}\n\t\t\t\t\t`,\n\t\t\t\tcode\n\t\t\t);\n\t\t}\n\n\t\tlet itemInterfaceName: string | undefined;\n\t\tif (variationModel.items && Object.keys(variationModel.items).length > 0) {\n\t\t\titemInterfaceName = buildTypeName(variationName, \"Item\");\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t{\n\t\t\t\t\tname: args.model.id,\n\t\t\t\t\tmodel: args.model,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"items\",\n\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\tfields: variationModel.items,\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\t\t\tauxiliaryTypes.push(...itemFieldProperties.auxiliaryTypes);\n\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\n\n\t\t\tcontentTypeNames.push(itemInterfaceName);\n\n\t\t\tconst docs = stripIndent`\n\t\t\t\t/**\n\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t */\n\t\t\t`;\n\n\t\t\tcode = addSection(\n\t\t\t\titemFieldProperties.code\n\t\t\t\t\t? source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${itemInterfaceName} {\n\t\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t\t}\n\t\t\t\t\t`\n\t\t\t\t\t: source`\n\t\t\t\t\t\t${docs}\n\t\t\t\t\t\texport interface ${itemInterfaceName} {}\n\t\t\t\t\t`,\n\t\t\t\tcode\n\t\t\t);\n\t\t}\n\n\t\tcode = addSection(\n\t\t\tsource`\n\t\t\t\t/**\n\t\t\t\t * ${variationModel.name} variation for ${humanReadableName} Slice\n\t\t\t\t *\n\t\t\t\t * - **API ID**: \\`${variationModel.id}\\`\n\t\t\t\t * - **Description**: ${variationModel.description || \"*None*\"}\n\t\t\t\t * - **Documentation**: ${SHARED_SLICES_DOCUMENTATION_URL}\n\t\t\t\t */\n\t\t\t\texport type ${variationName} = prismic.SharedSliceVariation<\"${\n\t\t\t\tvariationModel.id\n\t\t\t}\", ${\n\t\t\t\tprimaryInterfaceName\n\t\t\t\t\t? `Simplify<${primaryInterfaceName}>`\n\t\t\t\t\t: `Record<string, never>`\n\t\t\t}, ${itemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`}>;\n\t\t\t`,\n\t\t\tcode\n\t\t);\n\n\t\tvariationNames.push(variationName);\n\t}\n\n\tconst variationUnionName = buildTypeName(name, \"Variation\");\n\tconst variationsUnion = buildUnion(variationNames);\n\n\tcontentTypeNames.push(variationUnionName);\n\tcontentTypeNames.push(...variationNames);\n\n\tcode = addSection(\n\t\tsource`\n\t\t\t/**\n\t\t\t * Slice variation for *${humanReadableName}*\n\t\t\t */\n\t\t\ttype ${variationUnionName} = ${\n\t\t\tvariationNames.length > 0 ? variationsUnion : \"never\"\n\t\t}\n\t\t`,\n\t\tcode\n\t);\n\n\tcode = addSection(\n\t\tsource`\n\t\t\t/**\n\t\t\t * ${humanReadableName} Shared Slice\n\t\t\t *\n\t\t\t * - **API ID**: \\`${args.model.id}\\`\n\t\t\t * - **Description**: ${args.model.description || \"*None*\"}\n\t\t\t * - **Documentation**: ${SHARED_SLICES_DOCUMENTATION_URL}\n\t\t\t */\n\t\t\texport type ${name} = prismic.SharedSlice<\"${\n\t\t\targs.model.id\n\t\t}\", ${variationUnionName}>;\n\t\t`,\n\t\tcode\n\t);\n\n\tconst result = {\n\t\tname,\n\t\tvariationNames,\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n\n\tif (args.cache) {\n\t\tconst key = getCacheKey([args.model, args.fieldConfigs]);\n\n\t\targs.cache.set(key, result);\n\t}\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;AA4BA,SAAgB,qBACf,MACkC;AAClC,KAAI,KAAK,OAAO;EACf,MAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,aAAa,CAAC;EACxD,MAAM,SAAS,KAAK,MAAM,IAAI,IAAI;AAElC,MAAI,OACH,QAAO;;CAIT,IAAI,OAAO;CAEX,MAAM,iBAAkC,EAAE;CAC1C,MAAM,mBAA6B,EAAE;CAErC,MAAM,OAAO,cAAc,KAAK,MAAM,IAAI,QAAQ;CAClD,MAAM,oBAAoB,0BAA0B;EACnD,M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
3
|
+
//#region src/lib/buildTypeName.ts
|
|
4
|
+
const buildTypeName = (...parts) => {
|
|
5
|
+
let name = (0, pascal_case.pascalCase)(parts.filter(Boolean).join(" "), { transform: pascal_case.pascalCaseTransformMerge });
|
|
6
|
+
if (/^[0-9]/.test(name) ? "_" : "") name = `_${name}`;
|
|
7
|
+
return name;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.buildTypeName = buildTypeName;
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=buildTypeName.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTypeName.cjs","names":["pascalCaseTransformMerge"],"sources":["../../src/lib/buildTypeName.ts"],"sourcesContent":["import { pascalCase, pascalCaseTransformMerge } from \"pascal-case\";\n\nexport const buildTypeName = (...parts: string[]): string => {\n\tlet name = pascalCase(parts.filter(Boolean).join(\" \"), {\n\t\ttransform: pascalCaseTransformMerge,\n\t});\n\n\tif (/^[0-9]/.test(name) ? \"_\" : \"\") {\n\t\tname = `_${name}`;\n\t}\n\n\treturn name;\n};\n"],"mappings":";;;AAEA,MAAa,iBAAiB,GAAG,UAA4B;CAC5D,IAAI,QAAA,GAAA,YAAA,YAAkB,MAAM,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,EACtD,WAAWA,YAAAA,0BACX,CAAC;AAEF,KAAI,SAAS,KAAK,KAAK,GAAG,MAAM,GAC/B,QAAO,IAAI;AAGZ,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTypeName.js","names":[],"sources":["../../src/lib/buildTypeName.ts"],"sourcesContent":["import { pascalCase, pascalCaseTransformMerge } from \"pascal-case\";\n\nexport const buildTypeName = (...parts: string[]): string => {\n\tlet name = pascalCase(parts.filter(Boolean).join(\" \"), {\n\t\ttransform: pascalCaseTransformMerge,\n\t});\n\n\tif (/^[0-9]/.test(name) ? \"_\" : \"\") {\n\t\tname = `_${name}`;\n\t}\n\n\treturn name;\n};\n"],"mappings":";;AAEA,MAAa,iBAAiB,GAAG,UAA4B;CAC5D,IAAI,OAAO,WAAW,MAAM,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,EACtD,WAAW,0BACX,CAAC;AAEF,KAAI,SAAS,KAAK,KAAK,GAAG,MAAM,GAC/B,QAAO,IAAI;AAGZ,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUnion.
|
|
1
|
+
{"version":3,"file":"buildUnion.cjs","names":[],"sources":["../../src/lib/buildUnion.ts"],"sourcesContent":["export function buildUnion(types: string[]): string {\n\treturn types.filter(Boolean).join(\" | \") || \"never\";\n}\n"],"mappings":";AAAA,SAAgB,WAAW,OAAyB;AACnD,QAAO,MAAM,OAAO,QAAQ,CAAC,KAAK,MAAM,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUnion.js","names":[],"sources":["../../src/lib/buildUnion.ts"],"sourcesContent":["export function buildUnion(types: string[]): string {\n\treturn types.filter(Boolean).join(\" | \") || \"never\";\n}\n"],"mappings":";AAAA,SAAgB,WAAW,OAAyB;AACnD,QAAO,MAAM,OAAO,QAAQ,CAAC,KAAK,MAAM,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkHasUIDFIeld.
|
|
1
|
+
{"version":3,"file":"checkHasUIDFIeld.cjs","names":[],"sources":["../../src/lib/checkHasUIDFIeld.ts"],"sourcesContent":["import type { CustomTypeModel } from \"@prismicio/client\";\n\nexport function checkHasUIDField(model: CustomTypeModel): boolean {\n\treturn \"uid\" in Object.assign({}, ...Object.values(model.json));\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAiC;AACjE,QAAO,SAAS,OAAO,OAAO,EAAE,EAAE,GAAG,OAAO,OAAO,MAAM,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkHasUIDFIeld.js","names":[],"sources":["../../src/lib/checkHasUIDFIeld.ts"],"sourcesContent":["import type { CustomTypeModel } from \"@prismicio/client\";\n\nexport function checkHasUIDField(model: CustomTypeModel): boolean {\n\treturn \"uid\" in Object.assign({}, ...Object.values(model.json));\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAiC;AACjE,QAAO,SAAS,OAAO,OAAO,EAAE,EAAE,GAAG,OAAO,OAAO,MAAM,KAAK,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/lib/getAPIIDPath.ts
|
|
2
|
+
function getAPIIDPath(args) {
|
|
3
|
+
let result = "";
|
|
4
|
+
for (let i = 0; i < args.path.length; i++) {
|
|
5
|
+
if (i > 0) result += ".";
|
|
6
|
+
const element = args.path[i];
|
|
7
|
+
if (element.model && "type" in element.model && (element.model.type === "Group" || element.model.type === "Slices")) result += `${element.name}[]`;
|
|
8
|
+
else {
|
|
9
|
+
if (element.name === "items") {
|
|
10
|
+
const previousElement = args.path[i - 1];
|
|
11
|
+
if (previousElement.model && "json" in previousElement.model || previousElement.model && "type" in previousElement.model && previousElement.model.type === "SharedSlice") {
|
|
12
|
+
result += `${element.name}[]`;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
result += element.name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getAPIIDPath = getAPIIDPath;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=getAPIIDPath.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAPIIDPath.
|
|
1
|
+
{"version":3,"file":"getAPIIDPath.cjs","names":[],"sources":["../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\n\ntype GetAPIIDPathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getAPIIDPath(args: GetAPIIDPathArgs): string {\n\tlet result = \"\";\n\n\tfor (let i = 0; i < args.path.length; i++) {\n\t\tif (i > 0) {\n\t\t\tresult += \".\";\n\t\t}\n\n\t\tconst element = args.path[i];\n\n\t\tif (\n\t\t\telement.model &&\n\t\t\t\"type\" in element.model &&\n\t\t\t(element.model.type === \"Group\" || element.model.type === \"Slices\")\n\t\t) {\n\t\t\tresult += `${element.name}[]`;\n\t\t} else {\n\t\t\tif (element.name === \"items\") {\n\t\t\t\tconst previousElement = args.path[i - 1];\n\n\t\t\t\tif (\n\t\t\t\t\t(previousElement.model && \"json\" in previousElement.model) ||\n\t\t\t\t\t(previousElement.model &&\n\t\t\t\t\t\t\"type\" in previousElement.model &&\n\t\t\t\t\t\tpreviousElement.model.type === \"SharedSlice\")\n\t\t\t\t) {\n\t\t\t\t\tresult += `${element.name}[]`;\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult += element.name;\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"mappings":";AAMA,SAAgB,aAAa,MAAgC;CAC5D,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,QAAQ,KAAK;AAC1C,MAAI,IAAI,EACP,WAAU;EAGX,MAAM,UAAU,KAAK,KAAK;AAE1B,MACC,QAAQ,SACR,UAAU,QAAQ,UACjB,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,UAE1D,WAAU,GAAG,QAAQ,KAAK;OACpB;AACN,OAAI,QAAQ,SAAS,SAAS;IAC7B,MAAM,kBAAkB,KAAK,KAAK,IAAI;AAEtC,QACE,gBAAgB,SAAS,UAAU,gBAAgB,SACnD,gBAAgB,SAChB,UAAU,gBAAgB,SAC1B,gBAAgB,MAAM,SAAS,eAC/B;AACD,eAAU,GAAG,QAAQ,KAAK;AAE1B;;;AAIF,aAAU,QAAQ;;;AAIpB,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAPIIDPath.js","names":[],"sources":["../../src/lib/getAPIIDPath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\n\ntype GetAPIIDPathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getAPIIDPath(args: GetAPIIDPathArgs): string {\n\tlet result = \"\";\n\n\tfor (let i = 0; i < args.path.length; i++) {\n\t\tif (i > 0) {\n\t\t\tresult += \".\";\n\t\t}\n\n\t\tconst element = args.path[i];\n\n\t\tif (\n\t\t\telement.model &&\n\t\t\t\"type\" in element.model &&\n\t\t\t(element.model.type === \"Group\" || element.model.type === \"Slices\")\n\t\t) {\n\t\t\tresult += `${element.name}[]`;\n\t\t} else {\n\t\t\tif (element.name === \"items\") {\n\t\t\t\tconst previousElement = args.path[i - 1];\n\n\t\t\t\tif (\n\t\t\t\t\t(previousElement.model && \"json\" in previousElement.model) ||\n\t\t\t\t\t(previousElement.model &&\n\t\t\t\t\t\t\"type\" in previousElement.model &&\n\t\t\t\t\t\tpreviousElement.model.type === \"SharedSlice\")\n\t\t\t\t) {\n\t\t\t\t\tresult += `${element.name}[]`;\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult += element.name;\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"mappings":";AAMA,SAAgB,aAAa,MAAgC;CAC5D,IAAI,SAAS;AAEb,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,QAAQ,KAAK;AAC1C,MAAI,IAAI,EACP,WAAU;EAGX,MAAM,UAAU,KAAK,KAAK;AAE1B,MACC,QAAQ,SACR,UAAU,QAAQ,UACjB,QAAQ,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,UAE1D,WAAU,GAAG,QAAQ,KAAK;OACpB;AACN,OAAI,QAAQ,SAAS,SAAS;IAC7B,MAAM,kBAAkB,KAAK,KAAK,IAAI;AAEtC,QACE,gBAAgB,SAAS,UAAU,gBAAgB,SACnD,gBAAgB,SAChB,UAAU,gBAAgB,SAC1B,gBAAgB,MAAM,SAAS,eAC/B;AACD,eAAU,GAAG,QAAQ,KAAK;AAE1B;;;AAIF,aAAU,QAAQ;;;AAIpB,QAAO"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let node_crypto = require("node:crypto");
|
|
3
|
+
node_crypto = require_runtime.__toESM(node_crypto);
|
|
4
|
+
//#region src/lib/getCacheKey.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns a key based on the provided input that can be used as a cache identifier.
|
|
7
|
+
*
|
|
8
|
+
* @param input - The value used to create a key.
|
|
9
|
+
* @returns The cache key.
|
|
10
|
+
*/
|
|
11
|
+
const getCacheKey = (input) => {
|
|
12
|
+
return node_crypto.createHash("sha1").update(JSON.stringify(input)).digest("hex");
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.getCacheKey = getCacheKey;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=getCacheKey.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCacheKey.cjs","names":["crypto"],"sources":["../../src/lib/getCacheKey.ts"],"sourcesContent":["import * as crypto from \"node:crypto\";\n\n/**\n * Returns a key based on the provided input that can be used as a cache identifier.\n *\n * @param input - The value used to create a key.\n * @returns The cache key.\n */\nexport const getCacheKey = (input: unknown): string => {\n\treturn crypto.createHash(\"sha1\").update(JSON.stringify(input)).digest(\"hex\");\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,eAAe,UAA2B;AACtD,QAAOA,YAAO,WAAW,OAAO,CAAC,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,OAAO,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCacheKey.js","names":[],"sources":["../../src/lib/getCacheKey.ts"],"sourcesContent":["import * as crypto from \"node:crypto\";\n\n/**\n * Returns a key based on the provided input that can be used as a cache identifier.\n *\n * @param input - The value used to create a key.\n * @returns The cache key.\n */\nexport const getCacheKey = (input: unknown): string => {\n\treturn crypto.createHash(\"sha1\").update(JSON.stringify(input)).digest(\"hex\");\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,eAAe,UAA2B;AACtD,QAAO,OAAO,WAAW,OAAO,CAAC,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,OAAO,MAAM"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/lib/getHumanReadableModelName.ts
|
|
2
|
+
const getHumanReadableModelName = (args) => {
|
|
3
|
+
if ("json" in args.model) return args.model.label || args.model.id;
|
|
4
|
+
else if ("type" in args.model && args.model.type === "SharedSlice") return args.model.name;
|
|
5
|
+
else if ("type" in args.model && args.model.type === "Slice") return args.model.fieldset || args.name;
|
|
6
|
+
else if ("type" in args.model) {
|
|
7
|
+
if (args.model.config && "label" in args.model.config) return args.model.config.label || args.name;
|
|
8
|
+
else if (args.model.config && "fieldset" in args.model) return args.model.fieldset || args.name;
|
|
9
|
+
}
|
|
10
|
+
return `\`${args.name}\``;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.getHumanReadableModelName = getHumanReadableModelName;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=getHumanReadableModelName.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHumanReadableModelName.
|
|
1
|
+
{"version":3,"file":"getHumanReadableModelName.cjs","names":[],"sources":["../../src/lib/getHumanReadableModelName.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\n\ntype GetModelHumanNameArgs = {\n\tname: string;\n\tmodel: CustomTypeModel | SharedSliceModel | CustomTypeModelField | CustomTypeModelSlice;\n};\n\nexport const getHumanReadableModelName = (args: GetModelHumanNameArgs): string => {\n\tif (\"json\" in args.model) {\n\t\t// Custom type model\n\n\t\treturn args.model.label || args.model.id;\n\t} else if (\"type\" in args.model && args.model.type === \"SharedSlice\") {\n\t\t// Shared Slice model\n\n\t\treturn args.model.name;\n\t} else if (\"type\" in args.model && args.model.type === \"Slice\") {\n\t\t// Legacy Slice model\n\n\t\treturn args.model.fieldset || args.name;\n\t} else if (\"type\" in args.model) {\n\t\t// Field model\n\n\t\tif (args.model.config && \"label\" in args.model.config) {\n\t\t\t// Non-Slice Zone fields\n\t\t\treturn args.model.config.label || args.name;\n\t\t} else if (args.model.config && \"fieldset\" in args.model) {\n\t\t\t// Slice Zone\n\t\t\treturn args.model.fieldset || args.name;\n\t\t}\n\t}\n\n\treturn `\\`${args.name}\\``;\n};\n"],"mappings":";AAYA,MAAa,6BAA6B,SAAwC;AACjF,KAAI,UAAU,KAAK,MAGlB,QAAO,KAAK,MAAM,SAAS,KAAK,MAAM;UAC5B,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,cAGtD,QAAO,KAAK,MAAM;UACR,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,QAGtD,QAAO,KAAK,MAAM,YAAY,KAAK;UACzB,UAAU,KAAK;MAGrB,KAAK,MAAM,UAAU,WAAW,KAAK,MAAM,OAE9C,QAAO,KAAK,MAAM,OAAO,SAAS,KAAK;WAC7B,KAAK,MAAM,UAAU,cAAc,KAAK,MAElD,QAAO,KAAK,MAAM,YAAY,KAAK;;AAIrC,QAAO,KAAK,KAAK,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadableModelName.js","names":[],"sources":["../../src/lib/getHumanReadableModelName.ts"],"sourcesContent":["import type {\n\tCustomTypeModel,\n\tCustomTypeModelField,\n\tCustomTypeModelSlice,\n\tSharedSliceModel,\n} from \"@prismicio/client\";\n\ntype GetModelHumanNameArgs = {\n\tname: string;\n\tmodel: CustomTypeModel | SharedSliceModel | CustomTypeModelField | CustomTypeModelSlice;\n};\n\nexport const getHumanReadableModelName = (args: GetModelHumanNameArgs): string => {\n\tif (\"json\" in args.model) {\n\t\t// Custom type model\n\n\t\treturn args.model.label || args.model.id;\n\t} else if (\"type\" in args.model && args.model.type === \"SharedSlice\") {\n\t\t// Shared Slice model\n\n\t\treturn args.model.name;\n\t} else if (\"type\" in args.model && args.model.type === \"Slice\") {\n\t\t// Legacy Slice model\n\n\t\treturn args.model.fieldset || args.name;\n\t} else if (\"type\" in args.model) {\n\t\t// Field model\n\n\t\tif (args.model.config && \"label\" in args.model.config) {\n\t\t\t// Non-Slice Zone fields\n\t\t\treturn args.model.config.label || args.name;\n\t\t} else if (args.model.config && \"fieldset\" in args.model) {\n\t\t\t// Slice Zone\n\t\t\treturn args.model.fieldset || args.name;\n\t\t}\n\t}\n\n\treturn `\\`${args.name}\\``;\n};\n"],"mappings":";AAYA,MAAa,6BAA6B,SAAwC;AACjF,KAAI,UAAU,KAAK,MAGlB,QAAO,KAAK,MAAM,SAAS,KAAK,MAAM;UAC5B,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,cAGtD,QAAO,KAAK,MAAM;UACR,UAAU,KAAK,SAAS,KAAK,MAAM,SAAS,QAGtD,QAAO,KAAK,MAAM,YAAY,KAAK;UACzB,UAAU,KAAK;MAGrB,KAAK,MAAM,UAAU,WAAW,KAAK,MAAM,OAE9C,QAAO,KAAK,MAAM,OAAO,SAAS,KAAK;WAC7B,KAAK,MAAM,UAAU,cAAc,KAAK,MAElD,QAAO,KAAK,MAAM,YAAY,KAAK;;AAIrC,QAAO,KAAK,KAAK,KAAK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_getHumanReadableModelName = require("./getHumanReadableModelName.cjs");
|
|
2
|
+
//#region src/lib/getHumanReadablePath.ts
|
|
3
|
+
function getHumanReadablePath(args) {
|
|
4
|
+
return args.path.map((element) => {
|
|
5
|
+
if (element.label) return element.label;
|
|
6
|
+
else if (element.model) return require_getHumanReadableModelName.getHumanReadableModelName({
|
|
7
|
+
model: element.model,
|
|
8
|
+
name: element.name
|
|
9
|
+
});
|
|
10
|
+
else return element.name;
|
|
11
|
+
}).join(" → ");
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.getHumanReadablePath = getHumanReadablePath;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getHumanReadablePath.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadablePath.cjs","names":["getHumanReadableModelName"],"sources":["../../src/lib/getHumanReadablePath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\n\ntype GetHumanReadablePathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getHumanReadablePath(args: GetHumanReadablePathArgs): string {\n\treturn args.path\n\t\t.map((element) => {\n\t\t\tif (element.label) {\n\t\t\t\treturn element.label;\n\t\t\t} else if (element.model) {\n\t\t\t\treturn getHumanReadableModelName({\n\t\t\t\t\tmodel: element.model,\n\t\t\t\t\tname: element.name,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treturn element.name;\n\t\t\t}\n\t\t})\n\t\t.join(\" → \");\n}\n"],"mappings":";;AAOA,SAAgB,qBAAqB,MAAwC;AAC5E,QAAO,KAAK,KACV,KAAK,YAAY;AACjB,MAAI,QAAQ,MACX,QAAO,QAAQ;WACL,QAAQ,MAClB,QAAOA,kCAAAA,0BAA0B;GAChC,OAAO,QAAQ;GACf,MAAM,QAAQ;GACd,CAAC;MAEF,QAAO,QAAQ;GAEf,CACD,KAAK,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getHumanReadableModelName } from "./getHumanReadableModelName.
|
|
1
|
+
import { getHumanReadableModelName } from "./getHumanReadableModelName.js";
|
|
2
2
|
//#region src/lib/getHumanReadablePath.ts
|
|
3
3
|
function getHumanReadablePath(args) {
|
|
4
4
|
return args.path.map((element) => {
|
|
@@ -13,4 +13,4 @@ function getHumanReadablePath(args) {
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { getHumanReadablePath };
|
|
15
15
|
|
|
16
|
-
//# sourceMappingURL=getHumanReadablePath.
|
|
16
|
+
//# sourceMappingURL=getHumanReadablePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHumanReadablePath.js","names":[],"sources":["../../src/lib/getHumanReadablePath.ts"],"sourcesContent":["import type { FieldPath } from \"../types\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\n\ntype GetHumanReadablePathArgs = {\n\tpath: FieldPath;\n};\n\nexport function getHumanReadablePath(args: GetHumanReadablePathArgs): string {\n\treturn args.path\n\t\t.map((element) => {\n\t\t\tif (element.label) {\n\t\t\t\treturn element.label;\n\t\t\t} else if (element.model) {\n\t\t\t\treturn getHumanReadableModelName({\n\t\t\t\t\tmodel: element.model,\n\t\t\t\t\tname: element.name,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treturn element.name;\n\t\t\t}\n\t\t})\n\t\t.join(\" → \");\n}\n"],"mappings":";;AAOA,SAAgB,qBAAqB,MAAwC;AAC5E,QAAO,KAAK,KACV,KAAK,YAAY;AACjB,MAAI,QAAQ,MACX,QAAO,QAAQ;WACL,QAAQ,MAClB,QAAO,0BAA0B;GAChC,OAAO,QAAQ;GACf,MAAM,QAAQ;GACd,CAAC;MAEF,QAAO,QAAQ;GAEf,CACD,KAAK,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;KAyBY,YAAA;EACX,KAAA;IACC,aAAA,GAAgB,MAAA;EAAA;EAEjB,iBAAA;IACC,YAAA,GAAe,MAAA;EAAA;AAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type FieldConfigs = {
|
|
5
|
+
embed?: {
|
|
6
|
+
providerTypes?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
integrationFields?: {
|
|
9
|
+
catalogTypes?: Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { FieldConfigs };
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;KAyBY,YAAA;EACX,KAAA;IACC,aAAA,GAAgB,MAAA;EAAA;EAEjB,iBAAA;IACC,YAAA,GAAe,MAAA;EAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismic-ts-codegen",
|
|
3
|
-
"version": "0.1.29
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "An experimental Prismic model-to-TypeScript-type generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -21,9 +21,14 @@
|
|
|
21
21
|
"bin"
|
|
22
22
|
],
|
|
23
23
|
"type": "module",
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.js",
|
|
24
26
|
"types": "./dist/index.d.cts",
|
|
25
27
|
"exports": {
|
|
26
|
-
".":
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
},
|
|
27
32
|
"./package.json": "./package.json"
|
|
28
33
|
},
|
|
29
34
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configSchema.mjs","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,CAA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