prismic-ts-codegen 0.1.30 → 0.1.31

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