prismic-ts-codegen 0.1.29 → 0.1.30

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 (149) hide show
  1. package/bin/prismic-ts-codegen.js +1 -1
  2. package/dist/cli/{configSchema.d.cts → configSchema.d.mts} +1 -1
  3. package/dist/cli/{configSchema.d.cts.map → configSchema.d.mts.map} +1 -1
  4. package/dist/cli/{configSchema.js → configSchema.mjs} +1 -1
  5. package/dist/cli/configSchema.mjs.map +1 -0
  6. package/dist/cli/{constants.d.cts → constants.d.mts} +1 -1
  7. package/dist/cli/constants.d.mts.map +1 -0
  8. package/dist/cli/{constants.js → constants.mjs} +1 -1
  9. package/dist/cli/{constants.cjs.map → constants.mjs.map} +1 -1
  10. package/dist/cli/{loadConfig.js → loadConfig.mjs} +1 -1
  11. package/dist/cli/loadConfig.mjs.map +1 -0
  12. package/dist/cli/{loadLocaleIDs.js → loadLocaleIDs.mjs} +1 -1
  13. package/dist/cli/loadLocaleIDs.mjs.map +1 -0
  14. package/dist/cli/{loadModels.js → loadModels.mjs} +1 -1
  15. package/dist/cli/loadModels.mjs.map +1 -0
  16. package/dist/{cli.js → cli.mjs} +10 -9
  17. package/dist/cli.mjs.map +1 -0
  18. package/dist/{constants.js → constants.mjs} +1 -1
  19. package/dist/{constants.cjs.map → constants.mjs.map} +1 -1
  20. package/dist/{detectTypesProvider.d.cts → detectTypesProvider.d.mts} +2 -2
  21. package/dist/{detectTypesProvider.d.cts.map → detectTypesProvider.d.mts.map} +1 -1
  22. package/dist/{detectTypesProvider.js → detectTypesProvider.mjs} +1 -1
  23. package/dist/{detectTypesProvider.cjs.map → detectTypesProvider.mjs.map} +1 -1
  24. package/dist/{generateTypes.d.ts → generateTypes.d.mts} +2 -2
  25. package/dist/{generateTypes.d.cts.map → generateTypes.d.mts.map} +1 -1
  26. package/dist/{generateTypes.js → generateTypes.mjs} +6 -6
  27. package/dist/generateTypes.mjs.map +1 -0
  28. package/dist/{index.d.cts → index.d.mts} +4 -4
  29. package/dist/index.mjs +4 -0
  30. package/dist/lib/{addBlankLine.js → addBlankLine.mjs} +2 -2
  31. package/dist/lib/addBlankLine.mjs.map +1 -0
  32. package/dist/lib/{addLine.js → addLine.mjs} +2 -2
  33. package/dist/lib/addLine.mjs.map +1 -0
  34. package/dist/lib/{addSection.js → addSection.mjs} +2 -2
  35. package/dist/lib/addSection.mjs.map +1 -0
  36. package/dist/lib/{addTrailingNewLine.js → addTrailingNewLine.mjs} +1 -1
  37. package/dist/lib/{addTrailingNewLine.cjs.map → addTrailingNewLine.mjs.map} +1 -1
  38. package/dist/lib/{buildCustomTypeDataType.js → buildCustomTypeDataType.mjs} +4 -4
  39. package/dist/lib/buildCustomTypeDataType.mjs.map +1 -0
  40. package/dist/lib/{buildCustomTypeType.js → buildCustomTypeType.mjs} +9 -9
  41. package/dist/lib/buildCustomTypeType.mjs.map +1 -0
  42. package/dist/lib/{buildFieldDocs.js → buildFieldDocs.mjs} +6 -6
  43. package/dist/lib/buildFieldDocs.mjs.map +1 -0
  44. package/dist/lib/{buildFieldProperties.js → buildFieldProperties.mjs} +7 -7
  45. package/dist/lib/buildFieldProperties.mjs.map +1 -0
  46. package/dist/lib/{buildSharedSliceType.js → buildSharedSliceType.mjs} +9 -9
  47. package/dist/lib/buildSharedSliceType.mjs.map +1 -0
  48. package/dist/lib/{buildTypeName.js → buildTypeName.mjs} +1 -1
  49. package/dist/lib/buildTypeName.mjs.map +1 -0
  50. package/dist/lib/{buildUnion.js → buildUnion.mjs} +1 -1
  51. package/dist/lib/{buildUnion.cjs.map → buildUnion.mjs.map} +1 -1
  52. package/dist/lib/{checkHasUIDFIeld.js → checkHasUIDFIeld.mjs} +1 -1
  53. package/dist/lib/{checkHasUIDFIeld.cjs.map → checkHasUIDFIeld.mjs.map} +1 -1
  54. package/dist/lib/{getAPIIDPath.js → getAPIIDPath.mjs} +1 -1
  55. package/dist/lib/{getAPIIDPath.cjs.map → getAPIIDPath.mjs.map} +1 -1
  56. package/dist/lib/{getCacheKey.js → getCacheKey.mjs} +1 -1
  57. package/dist/lib/getCacheKey.mjs.map +1 -0
  58. package/dist/lib/{getHumanReadableModelName.js → getHumanReadableModelName.mjs} +1 -1
  59. package/dist/lib/{getHumanReadableModelName.cjs.map → getHumanReadableModelName.mjs.map} +1 -1
  60. package/dist/lib/{getHumanReadablePath.js → getHumanReadablePath.mjs} +2 -2
  61. package/dist/lib/getHumanReadablePath.mjs.map +1 -0
  62. package/dist/{types.d.cts → types.d.mts} +1 -1
  63. package/dist/types.d.mts.map +1 -0
  64. package/package.json +2 -8
  65. package/dist/_virtual/_rolldown/runtime.cjs +0 -23
  66. package/dist/cli/configSchema.cjs +0 -31
  67. package/dist/cli/configSchema.cjs.map +0 -1
  68. package/dist/cli/configSchema.d.ts +0 -39
  69. package/dist/cli/configSchema.d.ts.map +0 -1
  70. package/dist/cli/configSchema.js.map +0 -1
  71. package/dist/cli/constants.cjs +0 -6
  72. package/dist/cli/constants.d.cts.map +0 -1
  73. package/dist/cli/constants.d.ts +0 -5
  74. package/dist/cli/constants.d.ts.map +0 -1
  75. package/dist/cli/constants.js.map +0 -1
  76. package/dist/cli/loadConfig.cjs +0 -22
  77. package/dist/cli/loadConfig.cjs.map +0 -1
  78. package/dist/cli/loadConfig.js.map +0 -1
  79. package/dist/cli/loadLocaleIDs.cjs +0 -21
  80. package/dist/cli/loadLocaleIDs.cjs.map +0 -1
  81. package/dist/cli/loadLocaleIDs.js.map +0 -1
  82. package/dist/cli/loadModels.cjs +0 -54
  83. package/dist/cli/loadModels.cjs.map +0 -1
  84. package/dist/cli/loadModels.js.map +0 -1
  85. package/dist/cli.cjs +0 -110
  86. package/dist/cli.cjs.map +0 -1
  87. package/dist/cli.d.ts +0 -1
  88. package/dist/cli.js.map +0 -1
  89. package/dist/constants.cjs +0 -33
  90. package/dist/constants.js.map +0 -1
  91. package/dist/detectTypesProvider.cjs +0 -25
  92. package/dist/detectTypesProvider.d.ts +0 -17
  93. package/dist/detectTypesProvider.d.ts.map +0 -1
  94. package/dist/detectTypesProvider.js.map +0 -1
  95. package/dist/generateTypes.cjs +0 -144
  96. package/dist/generateTypes.cjs.map +0 -1
  97. package/dist/generateTypes.d.cts +0 -21
  98. package/dist/generateTypes.d.ts.map +0 -1
  99. package/dist/generateTypes.js.map +0 -1
  100. package/dist/index.cjs +0 -7
  101. package/dist/index.d.ts +0 -5
  102. package/dist/index.js +0 -4
  103. package/dist/lib/addBlankLine.cjs +0 -10
  104. package/dist/lib/addBlankLine.cjs.map +0 -1
  105. package/dist/lib/addBlankLine.js.map +0 -1
  106. package/dist/lib/addLine.cjs +0 -9
  107. package/dist/lib/addLine.cjs.map +0 -1
  108. package/dist/lib/addLine.js.map +0 -1
  109. package/dist/lib/addSection.cjs +0 -9
  110. package/dist/lib/addSection.cjs.map +0 -1
  111. package/dist/lib/addSection.js.map +0 -1
  112. package/dist/lib/addTrailingNewLine.cjs +0 -9
  113. package/dist/lib/addTrailingNewLine.js.map +0 -1
  114. package/dist/lib/buildCustomTypeDataType.cjs +0 -51
  115. package/dist/lib/buildCustomTypeDataType.cjs.map +0 -1
  116. package/dist/lib/buildCustomTypeDataType.js.map +0 -1
  117. package/dist/lib/buildCustomTypeType.cjs +0 -63
  118. package/dist/lib/buildCustomTypeType.cjs.map +0 -1
  119. package/dist/lib/buildCustomTypeType.js.map +0 -1
  120. package/dist/lib/buildFieldDocs.cjs +0 -66
  121. package/dist/lib/buildFieldDocs.cjs.map +0 -1
  122. package/dist/lib/buildFieldDocs.js.map +0 -1
  123. package/dist/lib/buildFieldProperties.cjs +0 -285
  124. package/dist/lib/buildFieldProperties.cjs.map +0 -1
  125. package/dist/lib/buildFieldProperties.js.map +0 -1
  126. package/dist/lib/buildSharedSliceType.cjs +0 -152
  127. package/dist/lib/buildSharedSliceType.cjs.map +0 -1
  128. package/dist/lib/buildSharedSliceType.js.map +0 -1
  129. package/dist/lib/buildTypeName.cjs +0 -12
  130. package/dist/lib/buildTypeName.cjs.map +0 -1
  131. package/dist/lib/buildTypeName.js.map +0 -1
  132. package/dist/lib/buildUnion.cjs +0 -8
  133. package/dist/lib/buildUnion.js.map +0 -1
  134. package/dist/lib/checkHasUIDFIeld.cjs +0 -8
  135. package/dist/lib/checkHasUIDFIeld.js.map +0 -1
  136. package/dist/lib/getAPIIDPath.cjs +0 -24
  137. package/dist/lib/getAPIIDPath.js.map +0 -1
  138. package/dist/lib/getCacheKey.cjs +0 -17
  139. package/dist/lib/getCacheKey.cjs.map +0 -1
  140. package/dist/lib/getCacheKey.js.map +0 -1
  141. package/dist/lib/getHumanReadableModelName.cjs +0 -15
  142. package/dist/lib/getHumanReadableModelName.js.map +0 -1
  143. package/dist/lib/getHumanReadablePath.cjs +0 -16
  144. package/dist/lib/getHumanReadablePath.cjs.map +0 -1
  145. package/dist/lib/getHumanReadablePath.js.map +0 -1
  146. package/dist/types.d.cts.map +0 -1
  147. package/dist/types.d.ts +0 -14
  148. package/dist/types.d.ts.map +0 -1
  149. /package/dist/{cli.d.cts → cli.d.mts} +0 -0
@@ -0,0 +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":";;;;;;;;;;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,MAAM,KAAK,MAAM;EACjB,OAAO,KAAK;EACZ,CAAC;CAEF,MAAM,iBAA2B,EAAE;AACnC,MAAK,MAAM,kBAAkB,KAAK,MAAM,YAAY;EACnD,MAAM,gBAAgB,cAAc,MAAM,eAAe,GAAG;EAE5D,IAAI;AACJ,MACC,eAAe,WACf,OAAO,KAAK,eAAe,QAAQ,CAAC,SAAS,GAC5C;AACD,0BAAuB,cAAc,eAAe,UAAU;GAE9D,MAAM,OAAkB;IACvB;KACC,MAAM,KAAK,MAAM;KACjB,OAAO,KAAK;KACZ;IACD;KACC,MAAM,eAAe;KACrB,OAAO,eAAe;KACtB;IACD;KACC,MAAM;KACN,OAAO;KACP;IACD;GACD,MAAM,oBAAoB,qBAAqB,EAAE,MAAM,CAAC;GAExD,MAAM,yBAAyB,qBAAqB;IACnD,QAAQ,eAAe;IACvB,cAAc,KAAK;IACnB;IACA,CAAC;AACF,kBAAe,KAAK,GAAG,uBAAuB,eAAe;AAC7D,oBAAiB,KAAK,GAAG,uBAAuB,iBAAiB;AAEjE,oBAAiB,KAAK,qBAAqB;GAE3C,MAAM,OAAO,WAAW;;6BAEE,kBAAkB;;;AAI5C,UAAO,WACN,uBAAuB,OACpB,MAAM;QACL,KAAK;yBACY,qBAAqB;SACrC,uBAAuB,KAAK;;SAG9B,MAAM;QACL,KAAK;yBACY,qBAAqB;QAE1C,KACA;;EAGF,IAAI;AACJ,MAAI,eAAe,SAAS,OAAO,KAAK,eAAe,MAAM,CAAC,SAAS,GAAG;AACzE,uBAAoB,cAAc,eAAe,OAAO;GAExD,MAAM,OAAkB,CACvB;IACC,MAAM,KAAK,MAAM;IACjB,OAAO,KAAK;IACZ,EACD;IACC,MAAM;IACN,OAAO;IACP,CACD;GACD,MAAM,oBAAoB,qBAAqB,EAAE,MAAM,CAAC;GAExD,MAAM,sBAAsB,qBAAqB;IAChD,QAAQ,eAAe;IACvB,cAAc,KAAK;IACnB;IACA,CAAC;AACF,kBAAe,KAAK,GAAG,oBAAoB,eAAe;AAC1D,oBAAiB,KAAK,GAAG,oBAAoB,iBAAiB;AAE9D,oBAAiB,KAAK,kBAAkB;GAExC,MAAM,OAAO,WAAW;;6BAEE,kBAAkB;;;AAI5C,UAAO,WACN,oBAAoB,OACjB,MAAM;QACL,KAAK;yBACY,kBAAkB;SAClC,oBAAoB,KAAK;;SAG3B,MAAM;QACL,KAAK;yBACY,kBAAkB;QAEvC,KACA;;AAGF,SAAO,WACN,MAAM;;SAEA,eAAe,KAAK,iBAAiB,kBAAkB;;yBAEvC,eAAe,GAAG;4BACf,eAAe,eAAe,SAAS;8BACrC,gCAAgC;;kBAE5C,cAAc,mCAC5B,eAAe,GACf,KACA,uBACG,YAAY,qBAAqB,KACjC,wBACH,IAAI,oBAAoB,YAAY,kBAAkB,KAAK,QAAQ;MAEpE,KACA;AAED,iBAAe,KAAK,cAAc;;CAGnC,MAAM,qBAAqB,cAAc,MAAM,YAAY;CAC3D,MAAM,kBAAkB,WAAW,eAAe;AAElD,kBAAiB,KAAK,mBAAmB;AACzC,kBAAiB,KAAK,GAAG,eAAe;AAExC,QAAO,WACN,MAAM;;6BAEqB,kBAAkB;;UAErC,mBAAmB,KAC1B,eAAe,SAAS,IAAI,kBAAkB,QAC9C;KAED,KACA;AAED,QAAO,WACN,MAAM;;QAEA,kBAAkB;;wBAEF,KAAK,MAAM,GAAG;2BACX,KAAK,MAAM,eAAe,SAAS;6BACjC,gCAAgC;;iBAE5C,KAAK,0BACnB,KAAK,MAAM,GACX,KAAK,mBAAmB;KAEzB,KACA;CAED,MAAM,SAAS;EACd;EACA;EACA;EACA;EACA;EACA;AAED,KAAI,KAAK,OAAO;EACf,MAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,aAAa,CAAC;AAExD,OAAK,MAAM,IAAI,KAAK,OAAO;;AAG5B,QAAO"}
@@ -8,4 +8,4 @@ const buildTypeName = (...parts) => {
8
8
  //#endregion
9
9
  export { buildTypeName };
10
10
 
11
- //# sourceMappingURL=buildTypeName.js.map
11
+ //# sourceMappingURL=buildTypeName.mjs.map
@@ -0,0 +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"}
@@ -5,4 +5,4 @@ function buildUnion(types) {
5
5
  //#endregion
6
6
  export { buildUnion };
7
7
 
8
- //# sourceMappingURL=buildUnion.js.map
8
+ //# sourceMappingURL=buildUnion.mjs.map
@@ -1 +1 @@
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"}
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"}
@@ -5,4 +5,4 @@ function checkHasUIDField(model) {
5
5
  //#endregion
6
6
  export { checkHasUIDField };
7
7
 
8
- //# sourceMappingURL=checkHasUIDFIeld.js.map
8
+ //# sourceMappingURL=checkHasUIDFIeld.mjs.map
@@ -1 +1 @@
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"}
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"}
@@ -21,4 +21,4 @@ function getAPIIDPath(args) {
21
21
  //#endregion
22
22
  export { getAPIIDPath };
23
23
 
24
- //# sourceMappingURL=getAPIIDPath.js.map
24
+ //# sourceMappingURL=getAPIIDPath.mjs.map
@@ -1 +1 @@
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"}
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"}
@@ -12,4 +12,4 @@ const getCacheKey = (input) => {
12
12
  //#endregion
13
13
  export { getCacheKey };
14
14
 
15
- //# sourceMappingURL=getCacheKey.js.map
15
+ //# sourceMappingURL=getCacheKey.mjs.map
@@ -0,0 +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"}
@@ -12,4 +12,4 @@ const getHumanReadableModelName = (args) => {
12
12
  //#endregion
13
13
  export { getHumanReadableModelName };
14
14
 
15
- //# sourceMappingURL=getHumanReadableModelName.js.map
15
+ //# sourceMappingURL=getHumanReadableModelName.mjs.map
@@ -1 +1 @@
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"}
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,4 +1,4 @@
1
- import { getHumanReadableModelName } from "./getHumanReadableModelName.js";
1
+ import { getHumanReadableModelName } from "./getHumanReadableModelName.mjs";
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.js.map
16
+ //# sourceMappingURL=getHumanReadablePath.mjs.map
@@ -0,0 +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"}
@@ -11,4 +11,4 @@ type FieldConfigs = {
11
11
  };
12
12
  //#endregion
13
13
  export { FieldConfigs };
14
- //# sourceMappingURL=types.d.cts.map
14
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +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"}
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.30",
4
4
  "description": "An experimental Prismic model-to-TypeScript-type generator",
5
5
  "keywords": [
6
6
  "prismic",
@@ -21,14 +21,8 @@
21
21
  "bin"
22
22
  ],
23
23
  "type": "module",
24
- "main": "./dist/index.cjs",
25
- "module": "./dist/index.js",
26
- "types": "./dist/index.d.cts",
27
24
  "exports": {
28
- ".": {
29
- "import": "./dist/index.js",
30
- "require": "./dist/index.cjs"
31
- },
25
+ ".": "./dist/index.mjs",
32
26
  "./package.json": "./package.json"
33
27
  },
34
28
  "publishConfig": {
@@ -1,23 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- exports.__toESM = __toESM;
@@ -1,31 +0,0 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
- let zod = require("zod");
3
- //#region src/cli/configSchema.ts
4
- /** Configuration to control the generated types. */
5
- const configSchema = zod.z.object({
6
- repositoryName: zod.z.string().optional(),
7
- accessToken: zod.z.string().optional(),
8
- customTypesAPIToken: zod.z.string().optional(),
9
- output: zod.z.string().optional(),
10
- typesProvider: zod.z.enum(["@prismicio/client", "@prismicio/types"]).optional(),
11
- clientIntegration: zod.z.object({
12
- includeCreateClientInterface: zod.z.boolean().optional(),
13
- includeContentNamespace: zod.z.boolean().optional()
14
- }).optional(),
15
- locales: zod.z.union([zod.z.array(zod.z.string()), zod.z.object({
16
- ids: zod.z.array(zod.z.string()).optional(),
17
- fetchFromRepository: zod.z.boolean().optional()
18
- })]).optional(),
19
- models: zod.z.union([zod.z.array(zod.z.string()), zod.z.object({
20
- files: zod.z.array(zod.z.string()).optional(),
21
- fetchFromRepository: zod.z.boolean().optional()
22
- })]).optional(),
23
- fields: zod.z.object({
24
- embed: zod.z.object({ providerTypes: zod.z.record(zod.z.string(), zod.z.string()).optional() }).optional(),
25
- integrationFields: zod.z.object({ catalogTypes: zod.z.record(zod.z.string(), zod.z.string()).optional() }).optional()
26
- }).optional()
27
- });
28
- //#endregion
29
- exports.configSchema = configSchema;
30
-
31
- //# sourceMappingURL=configSchema.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configSchema.cjs","names":["z"],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;;AAGA,MAAa,eAAeA,IAAAA,EAAE,OAAO;CAEpC,gBAAgBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAMrC,aAAaA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAMlC,qBAAqBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAM1C,QAAQA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAQ7B,eAAeA,IAAAA,EAAE,KAAK,CAAC,qBAAqB,mBAAmB,CAAC,CAAC,UAAU;CAG3E,mBAAmBA,IAAAA,EACjB,OAAO;EAgBP,8BAA8BA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAgBpD,yBAAyBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CAqBZ,SAASA,IAAAA,EACP,MAAM,CACNA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,EACnBA,IAAAA,EAAE,OAAO;EAUR,KAAKA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;EAMnC,qBAAqBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAQZ,QAAQA,IAAAA,EACN,MAAM,CACNA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,EACnBA,IAAAA,EAAE,OAAO;EAER,OAAOA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;EAQrC,qBAAqBA,IAAAA,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAGZ,QAAQA,IAAAA,EACN,OAAO;EAEP,OAAOA,IAAAA,EACL,OAAO,EAcP,eAAeA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU,EAC1D,CAAC,CACD,UAAU;EAGZ,mBAAmBA,IAAAA,EACjB,OAAO,EAaP,cAAcA,IAAAA,EAAE,OAAOA,IAAAA,EAAE,QAAQ,EAAEA,IAAAA,EAAE,QAAQ,CAAC,CAAC,UAAU,EACzD,CAAC,CACD,UAAU;EACZ,CAAC,CACD,UAAU;CACZ,CAAC"}
@@ -1,39 +0,0 @@
1
- import { z } from "zod";
2
-
3
- //#region src/cli/configSchema.d.ts
4
- /** Configuration to control the generated types. */
5
- declare const configSchema: z.ZodObject<{
6
- repositoryName: z.ZodOptional<z.ZodString>;
7
- accessToken: z.ZodOptional<z.ZodString>;
8
- customTypesAPIToken: z.ZodOptional<z.ZodString>;
9
- output: z.ZodOptional<z.ZodString>;
10
- typesProvider: z.ZodOptional<z.ZodEnum<{
11
- "@prismicio/client": "@prismicio/client";
12
- "@prismicio/types": "@prismicio/types";
13
- }>>;
14
- clientIntegration: z.ZodOptional<z.ZodObject<{
15
- includeCreateClientInterface: z.ZodOptional<z.ZodBoolean>;
16
- includeContentNamespace: z.ZodOptional<z.ZodBoolean>;
17
- }, z.core.$strip>>;
18
- locales: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
19
- ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
- fetchFromRepository: z.ZodOptional<z.ZodBoolean>;
21
- }, z.core.$strip>]>>;
22
- models: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
23
- files: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
- fetchFromRepository: z.ZodOptional<z.ZodBoolean>;
25
- }, z.core.$strip>]>>;
26
- fields: z.ZodOptional<z.ZodObject<{
27
- embed: z.ZodOptional<z.ZodObject<{
28
- providerTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
29
- }, z.core.$strip>>;
30
- integrationFields: z.ZodOptional<z.ZodObject<{
31
- catalogTypes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
32
- }, z.core.$strip>>;
33
- }, z.core.$strip>>;
34
- }, z.core.$strip>;
35
- /** Configuration to control the generated types. */
36
- type Config = z.infer<typeof configSchema>;
37
- //#endregion
38
- export { Config };
39
- //# sourceMappingURL=configSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configSchema.d.ts","names":[],"sources":["../../src/cli/configSchema.ts"],"mappings":";;;;cAGa,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqLb,MAAA,GAAS,CAAA,CAAE,KAAA,QAAa,YAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"configSchema.js","names":[],"sources":["../../src/cli/configSchema.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Configuration to control the generated types. */\nexport const configSchema = z.object({\n\t/** The name of the Prismic repository. */\n\trepositoryName: z.string().optional(),\n\n\t/**\n\t * The access token for the Prismic repository. If the repository is private and\n\t * `locales.fetchFromRepository` is `true`, providing a token is required.\n\t */\n\taccessToken: z.string().optional(),\n\n\t/**\n\t * The Custom Types API token for the Prismic repository. If `models.fetchFromRepository` is\n\t * `true`, providing a token is required.\n\t */\n\tcustomTypesAPIToken: z.string().optional(),\n\n\t/**\n\t * The file path where the generated types will be saved. This path is relative to where the\n\t * command is called.\n\t */\n\toutput: z.string().optional(),\n\n\t/**\n\t * The package that provides TypeScript types for Prismic data. Most projects will not need to\n\t * configure this option.\n\t *\n\t * @defaultValue Automatically detected using the project's `package.json`.\n\t */\n\ttypesProvider: z.enum([\"@prismicio/client\", \"@prismicio/types\"]).optional(),\n\n\t/** Configuration for automatic `@prismicio/client` integration. */\n\tclientIntegration: z\n\t\t.object({\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` integration with automatic typing should be included in\n\t\t\t * the output.\n\t\t\t *\n\t\t\t * If set to `true`, Prismic clients will automatically be typed with the generated Custom\n\t\t\t * Types and Slices.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeCreateClientInterface` to `true` for the primary repository and `false` or any\n\t\t\t * other repository. The generated `AllDocumentTypes` type for non-primary repositories can be\n\t\t\t * provided to `@prismicio/client`'s `createClient()` function as its only type parameter to\n\t\t\t * type the client.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeCreateClientInterface: z.boolean().optional(),\n\n\t\t\t/**\n\t\t\t * Determines if a `@prismicio/client` namespace named `Content` containing all Document and\n\t\t\t * Slice types should be included in the output.\n\t\t\t *\n\t\t\t * If set to `true`, a `Content` namespace from `@prismicio/client` will be available to\n\t\t\t * import to easily access types for your Prismic repository content.\n\t\t\t *\n\t\t\t * **Note**: If your project queries content from multiple Prismic repositories, set\n\t\t\t * `includeContentNamespace` to `true` for the primary repository and `false` or any other\n\t\t\t * repository. Types for non-primary repositories should be imported directly from the\n\t\t\t * generated file rather than via the `Content` namespace.\n\t\t\t *\n\t\t\t * @defaultValue `true`\n\t\t\t */\n\t\t\tincludeContentNamespace: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\n\t/**\n\t * Configuration for languages for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of locale IDs configured for the repository or an\n\t * object with finer control.\n\t *\n\t * @example\n\t * \t```ts\n\t * \t[\"en-us\", \"fr-fr\"];\n\t * \t```;\n\t *\n\t * @example\n\t * \t```ts\n\t * \t{\n\t * \t\"ids\": [\"en-us\", \"fr-fr\"],\n\t * \t\"fetchFromRepository\": true\n\t * \t}\n\t * \t```;\n\t */\n\tlocales: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/**\n\t\t\t\t * A list of locales configured for the Prismic repository. This is used to type a\n\t\t\t\t * document's `lang` property.\n\t\t\t\t *\n\t\t\t\t * @example\n\t\t\t\t * \t```ts\n\t\t\t\t * \t[\"en-us\", \"fr-fr\"];\n\t\t\t\t * \t```;\n\t\t\t\t */\n\t\t\t\tids: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's locales should be fetched from the repository's\n\t\t\t\t * API.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/**\n\t * Configuration for Custom Type and Slice models for the Prismic repository.\n\t *\n\t * It can be configured by providing an array of file paths to Custom Type and Slice JSON models\n\t * or an object with finer control.\n\t */\n\tmodels: z\n\t\t.union([\n\t\t\tz.array(z.string()),\n\t\t\tz.object({\n\t\t\t\t/** A list of file paths to Custom Type and Slice models. Globs are supported. */\n\t\t\t\tfiles: z.array(z.string()).optional(),\n\n\t\t\t\t/**\n\t\t\t\t * Determines if the Prismic repository's Custom Type and Slice models should be fetched\n\t\t\t\t * from the repository's API.\n\t\t\t\t *\n\t\t\t\t * `customTypesAPIToken` must be provided if set to `true`.\n\t\t\t\t */\n\t\t\t\tfetchFromRepository: z.boolean().optional(),\n\t\t\t}),\n\t\t])\n\t\t.optional(),\n\n\t/** Configuration for types generated for fields. */\n\tfields: z\n\t\t.object({\n\t\t\t/** Configuration for Embed fields. */\n\t\t\tembed: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping oEmbed providers to their type. The type should be provided as a\n\t\t\t\t\t * string and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"YouTube\": \"import('./types').OEmbedYouTube\"\n\t\t\t\t\t * \t\"Twitter\": \"import('./types').OEmbedTwitter\"\n\t\t\t\t\t * \t\"Vimeo\": \"import('./types').OEmbedVimeo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tproviderTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\n\t\t\t/** Configuration for Integration Fields. */\n\t\t\tintegrationFields: z\n\t\t\t\t.object({\n\t\t\t\t\t/**\n\t\t\t\t\t * An object mapping catalog IDs to their type. The type should be provided as a string\n\t\t\t\t\t * and is added directly into the generated types.\n\t\t\t\t\t *\n\t\t\t\t\t * @example\n\t\t\t\t\t * \t```ts\n\t\t\t\t\t * \t{\n\t\t\t\t\t * \t\"shopify_products\": \"import('./types').IntegrationFieldShopifyProduct\"\n\t\t\t\t\t * \t\"mux_videos\": \"import('./types').IntegrationFieldMuxVideo\"\n\t\t\t\t\t * \t}\n\t\t\t\t\t * \t```;\n\t\t\t\t\t */\n\t\t\t\t\tcatalogTypes: z.record(z.string(), z.string()).optional(),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/** Configuration to control the generated types. */\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAGA,MAAa,eAAe,EAAE,OAAO;CAEpC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CAMrC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAMlC,qBAAqB,EAAE,QAAQ,CAAC,UAAU;CAM1C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAQ7B,eAAe,EAAE,KAAK,CAAC,qBAAqB,mBAAmB,CAAC,CAAC,UAAU;CAG3E,mBAAmB,EACjB,OAAO;EAgBP,8BAA8B,EAAE,SAAS,CAAC,UAAU;EAgBpD,yBAAyB,EAAE,SAAS,CAAC,UAAU;EAC/C,CAAC,CACD,UAAU;CAqBZ,SAAS,EACP,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAUR,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAMnC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAQZ,QAAQ,EACN,MAAM,CACN,EAAE,MAAM,EAAE,QAAQ,CAAC,EACnB,EAAE,OAAO;EAER,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAQrC,qBAAqB,EAAE,SAAS,CAAC,UAAU;EAC3C,CAAC,CACF,CAAC,CACD,UAAU;CAGZ,QAAQ,EACN,OAAO;EAEP,OAAO,EACL,OAAO,EAcP,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EAC1D,CAAC,CACD,UAAU;EAGZ,mBAAmB,EACjB,OAAO,EAaP,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU,EACzD,CAAC,CACD,UAAU;EACZ,CAAC,CACD,UAAU;CACZ,CAAC"}
@@ -1,6 +0,0 @@
1
- //#region src/cli/constants.ts
2
- const NON_EDITABLE_FILE_HEADER = "// Code generated by prismic-ts-codegen. DO NOT EDIT.";
3
- //#endregion
4
- exports.NON_EDITABLE_FILE_HEADER = NON_EDITABLE_FILE_HEADER;
5
-
6
- //# sourceMappingURL=constants.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";cAAa,wBAAA"}
@@ -1,5 +0,0 @@
1
- //#region src/cli/constants.d.ts
2
- declare const NON_EDITABLE_FILE_HEADER = "// Code generated by prismic-ts-codegen. DO NOT EDIT.";
3
- //#endregion
4
- export { NON_EDITABLE_FILE_HEADER };
5
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/cli/constants.ts"],"mappings":";cAAa,wBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../../src/cli/constants.ts"],"sourcesContent":["export const NON_EDITABLE_FILE_HEADER = \"// Code generated by prismic-ts-codegen. DO NOT EDIT.\";\n"],"mappings":";AAAA,MAAa,2BAA2B"}
@@ -1,22 +0,0 @@
1
- const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
- let fs = require("fs");
3
- let path = require("path");
4
- let jiti = require("jiti");
5
- jiti = require_runtime.__toESM(jiti);
6
- //#region src/cli/loadConfig.ts
7
- const jiti$1 = (0, jiti.default)(process.cwd());
8
- const loadModuleWithJiti = (id) => {
9
- const mod = jiti$1(id);
10
- return typeof mod === "object" && mod !== null && "default" in mod ? mod.default : mod;
11
- };
12
- const DEFAULT_CONFIG_PATHS = ["prismicCodegen.config.ts", "prismicCodegen.config.js"];
13
- const loadConfig = (config) => {
14
- if (config.path) if ((0, fs.existsSync)(config.path)) return loadModuleWithJiti((0, path.resolve)(config.path));
15
- else throw new Error(`Config file does not exist: ${config.path}`);
16
- else for (const configPath of DEFAULT_CONFIG_PATHS) if ((0, fs.existsSync)(configPath)) return loadModuleWithJiti((0, path.resolve)(configPath));
17
- return {};
18
- };
19
- //#endregion
20
- exports.loadConfig = loadConfig;
21
-
22
- //# sourceMappingURL=loadConfig.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadConfig.cjs","names":["jiti"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport _jiti from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = _jiti(process.cwd());\n\nconst loadModuleWithJiti = <TModule>(id: string): TModule => {\n\tconst mod = jiti(id) as TModule | { default: TModule };\n\n\treturn typeof mod === \"object\" && mod !== null && \"default\" in mod ? mod.default : mod;\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = (config: LoadConfigConfig): Config => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;;;AAOA,MAAMA,UAAAA,GAAAA,KAAAA,SAAa,QAAQ,KAAK,CAAC;AAEjC,MAAM,sBAA+B,OAAwB;CAC5D,MAAM,MAAMA,OAAK,GAAG;AAEpB,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAAM,IAAI,UAAU;;AAGpF,MAAM,uBAAuB,CAAC,4BAA4B,2BAA2B;AAMrF,MAAa,cAAc,WAAqC;AAC/D,KAAI,OAAO,KACV,MAAA,GAAA,GAAA,YAAe,OAAO,KAAK,CAC1B,QAAO,oBAAA,GAAA,KAAA,SAA+B,OAAO,KAAK,CAAC;KAEnD,OAAM,IAAI,MAAM,+BAA+B,OAAO,OAAO;KAG9D,MAAK,MAAM,cAAc,qBACxB,MAAA,GAAA,GAAA,YAAe,WAAW,CACzB,QAAO,oBAAA,GAAA,KAAA,SAA+B,WAAW,CAAC;AAMrD,QAAO,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadConfig.js","names":["resolvePath"],"sources":["../../src/cli/loadConfig.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport _jiti from \"jiti\";\n\nimport type { Config } from \"./configSchema\";\n\nconst jiti = _jiti(process.cwd());\n\nconst loadModuleWithJiti = <TModule>(id: string): TModule => {\n\tconst mod = jiti(id) as TModule | { default: TModule };\n\n\treturn typeof mod === \"object\" && mod !== null && \"default\" in mod ? mod.default : mod;\n};\n\nconst DEFAULT_CONFIG_PATHS = [\"prismicCodegen.config.ts\", \"prismicCodegen.config.js\"];\n\ntype LoadConfigConfig = {\n\tpath?: string;\n};\n\nexport const loadConfig = (config: LoadConfigConfig): Config => {\n\tif (config.path) {\n\t\tif (existsSync(config.path)) {\n\t\t\treturn loadModuleWithJiti(resolvePath(config.path));\n\t\t} else {\n\t\t\tthrow new Error(`Config file does not exist: ${config.path}`);\n\t\t}\n\t} else {\n\t\tfor (const configPath of DEFAULT_CONFIG_PATHS) {\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn loadModuleWithJiti(resolvePath(configPath));\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config file exists, an empty config is returned.\n\treturn {};\n};\n"],"mappings":";;;;AAOA,MAAM,OAAO,MAAM,QAAQ,KAAK,CAAC;AAEjC,MAAM,sBAA+B,OAAwB;CAC5D,MAAM,MAAM,KAAK,GAAG;AAEpB,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,aAAa,MAAM,IAAI,UAAU;;AAGpF,MAAM,uBAAuB,CAAC,4BAA4B,2BAA2B;AAMrF,MAAa,cAAc,WAAqC;AAC/D,KAAI,OAAO,KACV,KAAI,WAAW,OAAO,KAAK,CAC1B,QAAO,mBAAmBA,QAAY,OAAO,KAAK,CAAC;KAEnD,OAAM,IAAI,MAAM,+BAA+B,OAAO,OAAO;KAG9D,MAAK,MAAM,cAAc,qBACxB,KAAI,WAAW,WAAW,CACzB,QAAO,mBAAmBA,QAAY,WAAW,CAAC;AAMrD,QAAO,EAAE"}
@@ -1,21 +0,0 @@
1
- const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
- let _prismicio_client = require("@prismicio/client");
3
- _prismicio_client = require_runtime.__toESM(_prismicio_client);
4
- let node_fetch = require("node-fetch");
5
- node_fetch = require_runtime.__toESM(node_fetch);
6
- //#region src/cli/loadLocaleIDs.ts
7
- const loadLocaleIDs = async (config) => {
8
- const localeIDs = new Set(config.localeIDs || []);
9
- if ("repositoryName" in config && config.fetchFromRepository) {
10
- const repository = await _prismicio_client.createClient(config.repositoryName, {
11
- accessToken: config.accessToken,
12
- fetch: node_fetch.default
13
- }).getRepository();
14
- for (const language of repository.languages) localeIDs.add(language.id);
15
- }
16
- return [...localeIDs];
17
- };
18
- //#endregion
19
- exports.loadLocaleIDs = loadLocaleIDs;
20
-
21
- //# sourceMappingURL=loadLocaleIDs.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadLocaleIDs.cjs","names":["prismic"],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport fetch from \"node-fetch\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;;;;;AAcA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,EAAE,CAAC;AAEzD,KAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJA,kBAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB,OAAA,WAAA;GACA,CAAC,CAE8B,eAAe;AAE/C,OAAK,MAAM,YAAY,WAAW,UACjC,WAAU,IAAI,SAAS,GAAG;;AAI5B,QAAO,CAAC,GAAG,UAAU"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadLocaleIDs.js","names":[],"sources":["../../src/cli/loadLocaleIDs.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport fetch from \"node-fetch\";\n\ntype LoadLocalesConfig =\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t }\n\t| {\n\t\t\tlocaleIDs?: string[];\n\t\t\trepositoryName: string;\n\t\t\taccessToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\nexport const loadLocaleIDs = async (config: LoadLocalesConfig): Promise<string[]> => {\n\tconst localeIDs = new Set<string>(config.localeIDs || []);\n\n\tif (\"repositoryName\" in config && config.fetchFromRepository) {\n\t\tconst client = prismic.createClient(config.repositoryName, {\n\t\t\taccessToken: config.accessToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tconst repository = await client.getRepository();\n\n\t\tfor (const language of repository.languages) {\n\t\t\tlocaleIDs.add(language.id);\n\t\t}\n\t}\n\n\treturn [...localeIDs];\n};\n"],"mappings":";;;AAcA,MAAa,gBAAgB,OAAO,WAAiD;CACpF,MAAM,YAAY,IAAI,IAAY,OAAO,aAAa,EAAE,CAAC;AAEzD,KAAI,oBAAoB,UAAU,OAAO,qBAAqB;EAM7D,MAAM,aAAa,MALJ,QAAQ,aAAa,OAAO,gBAAgB;GAC1D,aAAa,OAAO;GACpB;GACA,CAAC,CAE8B,eAAe;AAE/C,OAAK,MAAM,YAAY,WAAW,UACjC,WAAU,IAAI,SAAS,GAAG;;AAI5B,QAAO,CAAC,GAAG,UAAU"}
@@ -1,54 +0,0 @@
1
- const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
- let fs = require("fs");
3
- let node_fetch = require("node-fetch");
4
- node_fetch = require_runtime.__toESM(node_fetch);
5
- let _prismicio_custom_types_client = require("@prismicio/custom-types-client");
6
- _prismicio_custom_types_client = require_runtime.__toESM(_prismicio_custom_types_client);
7
- let fast_glob = require("fast-glob");
8
- fast_glob = require_runtime.__toESM(fast_glob);
9
- //#region src/cli/loadModels.ts
10
- const isCustomTypeModel = (input) => {
11
- return typeof input === "object" && input !== null && "json" in input;
12
- };
13
- const isSharedSliceModel = (input) => {
14
- return typeof input === "object" && input !== null && "variations" in input;
15
- };
16
- const readJSONFromGlob = async (globs) => {
17
- return (await (0, fast_glob.default)(globs.split(",").map((path) => path.trim()))).map((path) => {
18
- const raw = (0, fs.readFileSync)(path, "utf8");
19
- return JSON.parse(raw);
20
- });
21
- };
22
- const loadModels = async (config) => {
23
- const customTypeModels = {};
24
- const sharedSliceModels = {};
25
- if ("customTypesAPIToken" in config) {
26
- const customTypesClient = _prismicio_custom_types_client.createClient({
27
- repositoryName: config.repositoryName,
28
- token: config.customTypesAPIToken,
29
- fetch: node_fetch.default
30
- });
31
- if (config.fetchFromRepository) {
32
- const [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([customTypesClient.getAllCustomTypes(), customTypesClient.getAllSharedSlices()]);
33
- for (const customTypeModel of remoteCustomTypeModels) customTypeModels[customTypeModel.id] = customTypeModel;
34
- for (const sharedSliceModel of remoteSharedSliceModels) sharedSliceModels[sharedSliceModel.id] = sharedSliceModel;
35
- }
36
- }
37
- if (config.localPaths) {
38
- const models = (await Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))).flat();
39
- for (const model of models) if (isCustomTypeModel(model)) customTypeModels[model.id] = model;
40
- else if (isSharedSliceModel(model)) sharedSliceModels[model.id] = model;
41
- }
42
- return {
43
- customTypeModels: Object.values(customTypeModels).sort((a, b) => {
44
- return a.id.localeCompare(b.id);
45
- }),
46
- sharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {
47
- return a.id.localeCompare(b.id);
48
- })
49
- };
50
- };
51
- //#endregion
52
- exports.loadModels = loadModels;
53
-
54
- //# sourceMappingURL=loadModels.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadModels.cjs","names":["prismicCT"],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport * as prismicCT from \"@prismicio/custom-types-client\";\nimport fg from \"fast-glob\";\nimport fetch from \"node-fetch\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await fg(globs.split(\",\").map((path) => path.trim()));\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tconst customTypesClient = prismicCT.createClient({\n\t\t\trepositoryName: config.repositoryName,\n\t\t\ttoken: config.customTypesAPIToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tcustomTypesClient.getAllCustomTypes(),\n\t\t\t\tcustomTypesClient.getAllSharedSlices(),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;;;;;;;AAOA,MAAM,qBAAqB,UAA6C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAGjE,MAAM,sBAAsB,UAA8C;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;;AAGvE,MAAM,mBAAmB,OAAU,UAAgC;AAGlE,SAFc,OAAA,GAAA,UAAA,SAAS,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,EAEtD,KAAK,SAAS;EAC1B,MAAM,OAAA,GAAA,GAAA,cAAmB,MAAM,OAAO;AAEtC,SAAO,KAAK,MAAM,IAAI;GACrB;;AAmBH,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,EAAE;CAC5D,MAAM,oBAAsD,EAAE;AAE9D,KAAI,yBAAyB,QAAQ;EACpC,MAAM,oBAAoBA,+BAAU,aAAa;GAChD,gBAAgB,OAAO;GACvB,OAAO,OAAO;GACd,OAAA,WAAA;GACA,CAAC;AAEF,MAAI,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,kBAAkB,mBAAmB,EACrC,kBAAkB,oBAAoB,CACtC,CAAC;AAEF,QAAK,MAAM,mBAAmB,uBAC7B,kBAAiB,gBAAgB,MAAM;AAExC,QAAK,MAAM,oBAAoB,wBAC9B,mBAAkB,iBAAiB,MAAM;;;AAK5C,KAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,KAAK,CAAC,CAAC,EACzE,MAAM;AAER,OAAK,MAAM,SAAS,OACnB,KAAI,kBAAkB,MAAM,CAC3B,kBAAiB,MAAM,MAAM;WACnB,mBAAmB,MAAM,CACnC,mBAAkB,MAAM,MAAM;;AAKjC,QAAO;EACN,kBAAkB,OAAO,OAAO,iBAAiB,CAAC,MAAM,GAAG,MAAM;AAChE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF,mBAAmB,OAAO,OAAO,kBAAkB,CAAC,MAAM,GAAG,MAAM;AAClE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadModels.js","names":[],"sources":["../../src/cli/loadModels.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\n\nimport type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport * as prismicCT from \"@prismicio/custom-types-client\";\nimport fg from \"fast-glob\";\nimport fetch from \"node-fetch\";\n\nconst isCustomTypeModel = (input: unknown): input is CustomTypeModel => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nconst isSharedSliceModel = (input: unknown): input is SharedSliceModel => {\n\treturn typeof input === \"object\" && input !== null && \"variations\" in input;\n};\n\nconst readJSONFromGlob = async <T>(globs: string): Promise<T[]> => {\n\tconst paths = await fg(globs.split(\",\").map((path) => path.trim()));\n\n\treturn paths.map((path) => {\n\t\tconst raw = readFileSync(path, \"utf8\");\n\n\t\treturn JSON.parse(raw);\n\t});\n};\n\ntype LoadModelsConfig =\n\t| {\n\t\t\tlocalPaths?: string[];\n\t }\n\t| {\n\t\t\tlocalPaths?: string[];\n\t\t\trepositoryName: string;\n\t\t\tcustomTypesAPIToken: string;\n\t\t\tfetchFromRepository?: boolean;\n\t };\n\ntype LoadModelsReturnType = {\n\tcustomTypeModels: CustomTypeModel[];\n\tsharedSliceModels: SharedSliceModel[];\n};\n\nexport const loadModels = async (config: LoadModelsConfig): Promise<LoadModelsReturnType> => {\n\tconst customTypeModels: Record<string, CustomTypeModel> = {};\n\tconst sharedSliceModels: Record<string, SharedSliceModel> = {};\n\n\tif (\"customTypesAPIToken\" in config) {\n\t\tconst customTypesClient = prismicCT.createClient({\n\t\t\trepositoryName: config.repositoryName,\n\t\t\ttoken: config.customTypesAPIToken,\n\t\t\tfetch,\n\t\t});\n\n\t\tif (config.fetchFromRepository) {\n\t\t\tconst [remoteCustomTypeModels, remoteSharedSliceModels] = await Promise.all([\n\t\t\t\tcustomTypesClient.getAllCustomTypes(),\n\t\t\t\tcustomTypesClient.getAllSharedSlices(),\n\t\t\t]);\n\n\t\t\tfor (const customTypeModel of remoteCustomTypeModels) {\n\t\t\t\tcustomTypeModels[customTypeModel.id] = customTypeModel;\n\t\t\t}\n\t\t\tfor (const sharedSliceModel of remoteSharedSliceModels) {\n\t\t\t\tsharedSliceModels[sharedSliceModel.id] = sharedSliceModel;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.localPaths) {\n\t\tconst models = (\n\t\t\tawait Promise.all(config.localPaths.map((glob) => readJSONFromGlob(glob)))\n\t\t).flat();\n\n\t\tfor (const model of models) {\n\t\t\tif (isCustomTypeModel(model)) {\n\t\t\t\tcustomTypeModels[model.id] = model;\n\t\t\t} else if (isSharedSliceModel(model)) {\n\t\t\t\tsharedSliceModels[model.id] = model;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tcustomTypeModels: Object.values(customTypeModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t\tsharedSliceModels: Object.values(sharedSliceModels).sort((a, b) => {\n\t\t\treturn a.id.localeCompare(b.id);\n\t\t}),\n\t};\n};\n"],"mappings":";;;;;AAOA,MAAM,qBAAqB,UAA6C;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAGjE,MAAM,sBAAsB,UAA8C;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;;AAGvE,MAAM,mBAAmB,OAAU,UAAgC;AAGlE,SAFc,MAAM,GAAG,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,EAEtD,KAAK,SAAS;EAC1B,MAAM,MAAM,aAAa,MAAM,OAAO;AAEtC,SAAO,KAAK,MAAM,IAAI;GACrB;;AAmBH,MAAa,aAAa,OAAO,WAA4D;CAC5F,MAAM,mBAAoD,EAAE;CAC5D,MAAM,oBAAsD,EAAE;AAE9D,KAAI,yBAAyB,QAAQ;EACpC,MAAM,oBAAoB,UAAU,aAAa;GAChD,gBAAgB,OAAO;GACvB,OAAO,OAAO;GACd;GACA,CAAC;AAEF,MAAI,OAAO,qBAAqB;GAC/B,MAAM,CAAC,wBAAwB,2BAA2B,MAAM,QAAQ,IAAI,CAC3E,kBAAkB,mBAAmB,EACrC,kBAAkB,oBAAoB,CACtC,CAAC;AAEF,QAAK,MAAM,mBAAmB,uBAC7B,kBAAiB,gBAAgB,MAAM;AAExC,QAAK,MAAM,oBAAoB,wBAC9B,mBAAkB,iBAAiB,MAAM;;;AAK5C,KAAI,OAAO,YAAY;EACtB,MAAM,UACL,MAAM,QAAQ,IAAI,OAAO,WAAW,KAAK,SAAS,iBAAiB,KAAK,CAAC,CAAC,EACzE,MAAM;AAER,OAAK,MAAM,SAAS,OACnB,KAAI,kBAAkB,MAAM,CAC3B,kBAAiB,MAAM,MAAM;WACnB,mBAAmB,MAAM,CACnC,mBAAkB,MAAM,MAAM;;AAKjC,QAAO;EACN,kBAAkB,OAAO,OAAO,iBAAiB,CAAC,MAAM,GAAG,MAAM;AAChE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF,mBAAmB,OAAO,OAAO,kBAAkB,CAAC,MAAM,GAAG,MAAM;AAClE,UAAO,EAAE,GAAG,cAAc,EAAE,GAAG;IAC9B;EACF"}
package/dist/cli.cjs DELETED
@@ -1,110 +0,0 @@
1
- const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
- const require_generateTypes = require("./generateTypes.cjs");
3
- const require_detectTypesProvider = require("./detectTypesProvider.cjs");
4
- const require_constants = require("./cli/constants.cjs");
5
- require("./index.cjs");
6
- const require_configSchema = require("./cli/configSchema.cjs");
7
- const require_loadConfig = require("./cli/loadConfig.cjs");
8
- const require_loadLocaleIDs = require("./cli/loadLocaleIDs.cjs");
9
- const require_loadModels = require("./cli/loadModels.cjs");
10
- let common_tags = require("common-tags");
11
- let fs = require("fs");
12
- let path = require("path");
13
- let meow = require("meow");
14
- meow = require_runtime.__toESM(meow);
15
- //#region src/cli/index.ts
16
- const cli = (0, meow.default)(`
17
- Usage:
18
- prismic-ts-codegen [options...]
19
- prismic-ts-codegen init [options...]
20
-
21
- Commands:
22
- init [options]
23
-
24
- Options:
25
- -c, --config <path> Path to a prismic-ts-codegen configuration file.
26
- `, {
27
- importMeta: {},
28
- flags: { config: {
29
- type: "string",
30
- shortFlag: "c",
31
- isRequired: false
32
- } }
33
- });
34
- const main = async () => {
35
- if (cli.input[0] === "init") {
36
- const configPath = cli.flags.config || "prismicCodegen.config.ts";
37
- if ((0, fs.existsSync)(configPath)) console.info(`\n${configPath} already exists.`);
38
- else {
39
- let contents = "";
40
- if ((0, fs.existsSync)("slicemachine.config.json") || (0, fs.existsSync)("sm.json")) contents = common_tags.stripIndent`
41
- import type { Config } from "prismic-ts-codegen";
42
-
43
- const config: Config = {
44
- output: "./types.generated.ts",
45
- models: ["./customtypes/**/index.json", "./slices/**/model.json"],
46
- };
47
-
48
- export default config;
49
- `;
50
- else contents = common_tags.stripIndent`
51
- import type { Config } from "prismic-ts-codegen";
52
-
53
- const config: Config = {
54
- output: "./types.generated.ts",
55
- };
56
-
57
- export default config;
58
- `;
59
- (0, fs.writeFileSync)(configPath, contents);
60
- console.info(`\nCreated prismic-ts-codegen config file: ${configPath}`);
61
- }
62
- } else {
63
- const unvalidatedConfig = require_loadConfig.loadConfig({ path: cli.flags.config });
64
- const result = require_configSchema.configSchema.safeParse(unvalidatedConfig);
65
- if (result.success) {
66
- const config = result.data;
67
- const { customTypeModels, sharedSliceModels } = await require_loadModels.loadModels({
68
- localPaths: Array.isArray(config.models) ? config.models : config.models?.files,
69
- repositoryName: config.repositoryName,
70
- customTypesAPIToken: config.customTypesAPIToken,
71
- fetchFromRepository: config.models && "fetchFromRepository" in config.models && config.models.fetchFromRepository
72
- });
73
- const localeIDs = await require_loadLocaleIDs.loadLocaleIDs({
74
- localeIDs: Array.isArray(config.locales) ? config.locales : config.locales?.ids,
75
- repositoryName: config.repositoryName,
76
- accessToken: config.accessToken,
77
- fetchFromRepository: config.locales && "fetchFromRepository" in config.locales && config.locales.fetchFromRepository
78
- });
79
- const typesProvider = config.typesProvider || await require_detectTypesProvider.detectTypesProvider();
80
- const hasCustomTypeModels = customTypeModels.length > 0;
81
- if (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) console.info("[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.");
82
- const types = require_generateTypes.generateTypes({
83
- customTypeModels,
84
- sharedSliceModels,
85
- localeIDs,
86
- fieldConfigs: config.fields,
87
- clientIntegration: {
88
- includeCreateClientInterface: hasCustomTypeModels ? config.clientIntegration?.includeCreateClientInterface ?? true : false,
89
- includeContentNamespace: config.clientIntegration?.includeContentNamespace ?? true
90
- },
91
- typesProvider
92
- });
93
- const fileContents = `${require_constants.NON_EDITABLE_FILE_HEADER}\n\n${types}`;
94
- if (config.output) {
95
- (0, fs.writeFileSync)((0, path.resolve)(config.output), fileContents);
96
- console.info(`\nGenerated types in: ${config.output}`);
97
- } else process.stdout.write(types + "\n");
98
- } else {
99
- console.error(result.error.message);
100
- process.exit(1);
101
- }
102
- }
103
- };
104
- main().catch((error) => {
105
- console.error(error);
106
- process.exit(1);
107
- });
108
- //#endregion
109
-
110
- //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.cjs","names":["loadConfig","configSchema","loadModels","loadLocaleIDs","detectTypesProvider","generateTypes","NON_EDITABLE_FILE_HEADER"],"sources":["../src/cli/index.ts"],"sourcesContent":["import { existsSync, writeFileSync } from \"fs\";\nimport { resolve as resolvePath } from \"path\";\n\nimport { stripIndent } from \"common-tags\";\nimport meow from \"meow\";\n\nimport { detectTypesProvider, generateTypes } from \"../index\";\nimport { configSchema } from \"./configSchema\";\nimport { NON_EDITABLE_FILE_HEADER } from \"./constants\";\nimport { loadConfig } from \"./loadConfig\";\nimport { loadLocaleIDs } from \"./loadLocaleIDs\";\nimport { loadModels } from \"./loadModels\";\n\nconst cli = meow(\n\t`\n\tUsage:\n\t prismic-ts-codegen [options...]\n\t prismic-ts-codegen init [options...]\n\n\tCommands:\n\t init [options]\n\n\tOptions:\n\t -c, --config <path> Path to a prismic-ts-codegen configuration file.\n\t`,\n\t{\n\t\timportMeta: import.meta,\n\t\tflags: {\n\t\t\tconfig: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tshortFlag: \"c\",\n\t\t\t\tisRequired: false,\n\t\t\t},\n\t\t},\n\t},\n);\n\nconst main = async () => {\n\tif (cli.input[0] === \"init\") {\n\t\tconst configPath = cli.flags.config || \"prismicCodegen.config.ts\";\n\n\t\tif (existsSync(configPath)) {\n\t\t\tconsole.info(`\\n${configPath} already exists.`);\n\t\t} else {\n\t\t\tlet contents = \"\";\n\n\t\t\tif (existsSync(\"slicemachine.config.json\") || existsSync(\"sm.json\")) {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t models: [\"./customtypes/**/index.json\", \"./slices/**/model.json\"],\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t} else {\n\t\t\t\tcontents = stripIndent`\n\t\t\t\t\timport type { Config } from \"prismic-ts-codegen\";\n\n\t\t\t\t\tconst config: Config = {\n\t\t\t\t\t output: \"./types.generated.ts\",\n\t\t\t\t\t};\n\n\t\t\t\t\texport default config;\n\t\t\t\t`;\n\t\t\t}\n\n\t\t\twriteFileSync(configPath, contents);\n\n\t\t\tconsole.info(`\\nCreated prismic-ts-codegen config file: ${configPath}`);\n\t\t}\n\t} else {\n\t\tconst unvalidatedConfig = loadConfig({ path: cli.flags.config });\n\n\t\tconst result = configSchema.safeParse(unvalidatedConfig);\n\n\t\tif (result.success) {\n\t\t\tconst config = result.data;\n\t\t\tconst { customTypeModels, sharedSliceModels } = await loadModels({\n\t\t\t\tlocalPaths: Array.isArray(config.models) ? config.models : config.models?.files,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\tcustomTypesAPIToken: config.customTypesAPIToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.models &&\n\t\t\t\t\t\"fetchFromRepository\" in config.models &&\n\t\t\t\t\tconfig.models.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst localeIDs = await loadLocaleIDs({\n\t\t\t\tlocaleIDs: Array.isArray(config.locales) ? config.locales : config.locales?.ids,\n\t\t\t\trepositoryName: config.repositoryName,\n\t\t\t\taccessToken: config.accessToken,\n\t\t\t\tfetchFromRepository:\n\t\t\t\t\tconfig.locales &&\n\t\t\t\t\t\"fetchFromRepository\" in config.locales &&\n\t\t\t\t\tconfig.locales.fetchFromRepository,\n\t\t\t});\n\n\t\t\tconst typesProvider = config.typesProvider || (await detectTypesProvider());\n\n\t\t\tconst hasCustomTypeModels = customTypeModels.length > 0;\n\n\t\t\tif (config.clientIntegration?.includeCreateClientInterface && !hasCustomTypeModels) {\n\t\t\t\tconsole.info(\n\t\t\t\t\t\"[INFO]: prismic-ts-codegen was configured to automatically integrate with `@prismicio/client`, but the integration was not generated because no Custom Type models were found. Automatic integration requires at least one Custom Type model.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst types = generateTypes({\n\t\t\t\tcustomTypeModels,\n\t\t\t\tsharedSliceModels,\n\t\t\t\tlocaleIDs,\n\t\t\t\tfieldConfigs: config.fields,\n\t\t\t\tclientIntegration: {\n\t\t\t\t\tincludeCreateClientInterface: hasCustomTypeModels\n\t\t\t\t\t\t? (config.clientIntegration?.includeCreateClientInterface ?? true)\n\t\t\t\t\t\t: false,\n\t\t\t\t\tincludeContentNamespace: config.clientIntegration?.includeContentNamespace ?? true,\n\t\t\t\t},\n\t\t\t\ttypesProvider,\n\t\t\t});\n\n\t\t\tconst fileContents = `${NON_EDITABLE_FILE_HEADER}\\n\\n${types}`;\n\n\t\t\tif (config.output) {\n\t\t\t\twriteFileSync(resolvePath(config.output), fileContents);\n\n\t\t\t\tconsole.info(`\\nGenerated types in: ${config.output}`);\n\t\t\t} else {\n\t\t\t\tprocess.stdout.write(types + \"\\n\");\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.error(result.error.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n};\n\nmain().catch((error) => {\n\tconsole.error(error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,OAAA,GAAA,KAAA,SACL;;;;;;;;;;IAWA;CACC,YAAA,EAAA;CACA,OAAO,EACN,QAAQ;EACP,MAAM;EACN,WAAW;EACX,YAAY;EACZ,EACD;CACD,CACD;AAED,MAAM,OAAO,YAAY;AACxB,KAAI,IAAI,MAAM,OAAO,QAAQ;EAC5B,MAAM,aAAa,IAAI,MAAM,UAAU;AAEvC,OAAA,GAAA,GAAA,YAAe,WAAW,CACzB,SAAQ,KAAK,KAAK,WAAW,kBAAkB;OACzC;GACN,IAAI,WAAW;AAEf,QAAA,GAAA,GAAA,YAAe,2BAA2B,KAAA,GAAA,GAAA,YAAe,UAAU,CAClE,YAAW,YAAA,WAAW;;;;;;;;;;OAWtB,YAAW,YAAA,WAAW;;;;;;;;;AAWvB,IAAA,GAAA,GAAA,eAAc,YAAY,SAAS;AAEnC,WAAQ,KAAK,6CAA6C,aAAa;;QAElE;EACN,MAAM,oBAAoBA,mBAAAA,WAAW,EAAE,MAAM,IAAI,MAAM,QAAQ,CAAC;EAEhE,MAAM,SAASC,qBAAAA,aAAa,UAAU,kBAAkB;AAExD,MAAI,OAAO,SAAS;GACnB,MAAM,SAAS,OAAO;GACtB,MAAM,EAAE,kBAAkB,sBAAsB,MAAMC,mBAAAA,WAAW;IAChE,YAAY,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,SAAS,OAAO,QAAQ;IAC1E,gBAAgB,OAAO;IACvB,qBAAqB,OAAO;IAC5B,qBACC,OAAO,UACP,yBAAyB,OAAO,UAChC,OAAO,OAAO;IACf,CAAC;GAEF,MAAM,YAAY,MAAMC,sBAAAA,cAAc;IACrC,WAAW,MAAM,QAAQ,OAAO,QAAQ,GAAG,OAAO,UAAU,OAAO,SAAS;IAC5E,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,qBACC,OAAO,WACP,yBAAyB,OAAO,WAChC,OAAO,QAAQ;IAChB,CAAC;GAEF,MAAM,gBAAgB,OAAO,iBAAkB,MAAMC,4BAAAA,qBAAqB;GAE1E,MAAM,sBAAsB,iBAAiB,SAAS;AAEtD,OAAI,OAAO,mBAAmB,gCAAgC,CAAC,oBAC9D,SAAQ,KACP,gPACA;GAGF,MAAM,QAAQC,sBAAAA,cAAc;IAC3B;IACA;IACA;IACA,cAAc,OAAO;IACrB,mBAAmB;KAClB,8BAA8B,sBAC1B,OAAO,mBAAmB,gCAAgC,OAC3D;KACH,yBAAyB,OAAO,mBAAmB,2BAA2B;KAC9E;IACD;IACA,CAAC;GAEF,MAAM,eAAe,GAAGC,kBAAAA,yBAAyB,MAAM;AAEvD,OAAI,OAAO,QAAQ;AAClB,KAAA,GAAA,GAAA,gBAAA,GAAA,KAAA,SAA0B,OAAO,OAAO,EAAE,aAAa;AAEvD,YAAQ,KAAK,yBAAyB,OAAO,SAAS;SAEtD,SAAQ,OAAO,MAAM,QAAQ,KAAK;SAE7B;AACN,WAAQ,MAAM,OAAO,MAAM,QAAQ;AACnC,WAAQ,KAAK,EAAE;;;;AAKlB,MAAM,CAAC,OAAO,UAAU;AACvB,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EACd"}
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export { };