prismic-ts-codegen 0.1.29-pr.80.577ac11 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/bin/prismic-ts-codegen.js +1 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/cli/configSchema.cjs +31 -0
  4. package/dist/cli/configSchema.cjs.map +1 -0
  5. package/dist/cli/{configSchema.d.mts → configSchema.d.cts} +1 -1
  6. package/dist/cli/{configSchema.d.mts.map → configSchema.d.cts.map} +1 -1
  7. package/dist/cli/configSchema.d.ts +39 -0
  8. package/dist/cli/configSchema.d.ts.map +1 -0
  9. package/dist/cli/{configSchema.mjs → configSchema.js} +1 -1
  10. package/dist/cli/configSchema.js.map +1 -0
  11. package/dist/cli/constants.cjs +6 -0
  12. package/dist/cli/{constants.mjs.map → constants.cjs.map} +1 -1
  13. package/dist/cli/{constants.d.mts → constants.d.cts} +1 -1
  14. package/dist/cli/constants.d.cts.map +1 -0
  15. package/dist/cli/constants.d.ts +5 -0
  16. package/dist/cli/constants.d.ts.map +1 -0
  17. package/dist/cli/{constants.mjs → constants.js} +1 -1
  18. package/dist/cli/constants.js.map +1 -0
  19. package/dist/cli/loadConfig.cjs +22 -0
  20. package/dist/cli/loadConfig.cjs.map +1 -0
  21. package/dist/cli/{loadConfig.mjs → loadConfig.js} +1 -1
  22. package/dist/cli/loadConfig.js.map +1 -0
  23. package/dist/cli/loadLocaleIDs.cjs +21 -0
  24. package/dist/cli/loadLocaleIDs.cjs.map +1 -0
  25. package/dist/cli/{loadLocaleIDs.mjs → loadLocaleIDs.js} +1 -1
  26. package/dist/cli/loadLocaleIDs.js.map +1 -0
  27. package/dist/cli/loadModels.cjs +54 -0
  28. package/dist/cli/loadModels.cjs.map +1 -0
  29. package/dist/cli/{loadModels.mjs → loadModels.js} +1 -1
  30. package/dist/cli/loadModels.js.map +1 -0
  31. package/dist/cli.cjs +110 -0
  32. package/dist/cli.cjs.map +1 -0
  33. package/dist/cli.d.ts +1 -0
  34. package/dist/{cli.mjs → cli.js} +9 -10
  35. package/dist/cli.js.map +1 -0
  36. package/dist/constants.cjs +33 -0
  37. package/dist/{constants.mjs.map → constants.cjs.map} +1 -1
  38. package/dist/{constants.mjs → constants.js} +1 -1
  39. package/dist/constants.js.map +1 -0
  40. package/dist/detectTypesProvider.cjs +25 -0
  41. package/dist/{detectTypesProvider.mjs.map → detectTypesProvider.cjs.map} +1 -1
  42. package/dist/{detectTypesProvider.d.mts → detectTypesProvider.d.cts} +2 -2
  43. package/dist/{detectTypesProvider.d.mts.map → detectTypesProvider.d.cts.map} +1 -1
  44. package/dist/detectTypesProvider.d.ts +17 -0
  45. package/dist/detectTypesProvider.d.ts.map +1 -0
  46. package/dist/{detectTypesProvider.mjs → detectTypesProvider.js} +1 -1
  47. package/dist/detectTypesProvider.js.map +1 -0
  48. package/dist/generateTypes.cjs +144 -0
  49. package/dist/generateTypes.cjs.map +1 -0
  50. package/dist/{generateTypes.d.mts → generateTypes.d.cts} +2 -2
  51. package/dist/{generateTypes.d.mts.map → generateTypes.d.cts.map} +1 -1
  52. package/dist/generateTypes.d.ts +21 -0
  53. package/dist/generateTypes.d.ts.map +1 -0
  54. package/dist/{generateTypes.mjs → generateTypes.js} +6 -6
  55. package/dist/generateTypes.js.map +1 -0
  56. package/dist/index.cjs +7 -0
  57. package/dist/{index.d.mts → index.d.cts} +4 -4
  58. package/dist/index.d.ts +5 -0
  59. package/dist/index.js +4 -0
  60. package/dist/lib/addBlankLine.cjs +10 -0
  61. package/dist/lib/addBlankLine.cjs.map +1 -0
  62. package/dist/lib/{addBlankLine.mjs → addBlankLine.js} +2 -2
  63. package/dist/lib/addBlankLine.js.map +1 -0
  64. package/dist/lib/addLine.cjs +9 -0
  65. package/dist/lib/addLine.cjs.map +1 -0
  66. package/dist/lib/{addLine.mjs → addLine.js} +2 -2
  67. package/dist/lib/addLine.js.map +1 -0
  68. package/dist/lib/addSection.cjs +9 -0
  69. package/dist/lib/addSection.cjs.map +1 -0
  70. package/dist/lib/{addSection.mjs → addSection.js} +2 -2
  71. package/dist/lib/addSection.js.map +1 -0
  72. package/dist/lib/addTrailingNewLine.cjs +9 -0
  73. package/dist/lib/{addTrailingNewLine.mjs.map → addTrailingNewLine.cjs.map} +1 -1
  74. package/dist/lib/{addTrailingNewLine.mjs → addTrailingNewLine.js} +1 -1
  75. package/dist/lib/addTrailingNewLine.js.map +1 -0
  76. package/dist/lib/buildCustomTypeDataType.cjs +51 -0
  77. package/dist/lib/buildCustomTypeDataType.cjs.map +1 -0
  78. package/dist/lib/{buildCustomTypeDataType.mjs → buildCustomTypeDataType.js} +4 -4
  79. package/dist/lib/buildCustomTypeDataType.js.map +1 -0
  80. package/dist/lib/buildCustomTypeType.cjs +63 -0
  81. package/dist/lib/buildCustomTypeType.cjs.map +1 -0
  82. package/dist/lib/{buildCustomTypeType.mjs → buildCustomTypeType.js} +9 -9
  83. package/dist/lib/buildCustomTypeType.js.map +1 -0
  84. package/dist/lib/buildFieldDocs.cjs +66 -0
  85. package/dist/lib/buildFieldDocs.cjs.map +1 -0
  86. package/dist/lib/{buildFieldDocs.mjs → buildFieldDocs.js} +6 -6
  87. package/dist/lib/buildFieldDocs.js.map +1 -0
  88. package/dist/lib/buildFieldProperties.cjs +285 -0
  89. package/dist/lib/buildFieldProperties.cjs.map +1 -0
  90. package/dist/lib/{buildFieldProperties.mjs → buildFieldProperties.js} +7 -7
  91. package/dist/lib/buildFieldProperties.js.map +1 -0
  92. package/dist/lib/buildSharedSliceType.cjs +152 -0
  93. package/dist/lib/buildSharedSliceType.cjs.map +1 -0
  94. package/dist/lib/{buildSharedSliceType.mjs → buildSharedSliceType.js} +9 -9
  95. package/dist/lib/buildSharedSliceType.js.map +1 -0
  96. package/dist/lib/buildTypeName.cjs +12 -0
  97. package/dist/lib/buildTypeName.cjs.map +1 -0
  98. package/dist/lib/{buildTypeName.mjs → buildTypeName.js} +1 -1
  99. package/dist/lib/buildTypeName.js.map +1 -0
  100. package/dist/lib/buildUnion.cjs +8 -0
  101. package/dist/lib/{buildUnion.mjs.map → buildUnion.cjs.map} +1 -1
  102. package/dist/lib/{buildUnion.mjs → buildUnion.js} +1 -1
  103. package/dist/lib/buildUnion.js.map +1 -0
  104. package/dist/lib/checkHasUIDFIeld.cjs +8 -0
  105. package/dist/lib/{checkHasUIDFIeld.mjs.map → checkHasUIDFIeld.cjs.map} +1 -1
  106. package/dist/lib/{checkHasUIDFIeld.mjs → checkHasUIDFIeld.js} +1 -1
  107. package/dist/lib/checkHasUIDFIeld.js.map +1 -0
  108. package/dist/lib/getAPIIDPath.cjs +24 -0
  109. package/dist/lib/{getAPIIDPath.mjs.map → getAPIIDPath.cjs.map} +1 -1
  110. package/dist/lib/{getAPIIDPath.mjs → getAPIIDPath.js} +1 -1
  111. package/dist/lib/getAPIIDPath.js.map +1 -0
  112. package/dist/lib/getCacheKey.cjs +17 -0
  113. package/dist/lib/getCacheKey.cjs.map +1 -0
  114. package/dist/lib/{getCacheKey.mjs → getCacheKey.js} +1 -1
  115. package/dist/lib/getCacheKey.js.map +1 -0
  116. package/dist/lib/getHumanReadableModelName.cjs +15 -0
  117. package/dist/lib/{getHumanReadableModelName.mjs.map → getHumanReadableModelName.cjs.map} +1 -1
  118. package/dist/lib/{getHumanReadableModelName.mjs → getHumanReadableModelName.js} +1 -1
  119. package/dist/lib/getHumanReadableModelName.js.map +1 -0
  120. package/dist/lib/getHumanReadablePath.cjs +16 -0
  121. package/dist/lib/getHumanReadablePath.cjs.map +1 -0
  122. package/dist/lib/{getHumanReadablePath.mjs → getHumanReadablePath.js} +2 -2
  123. package/dist/lib/getHumanReadablePath.js.map +1 -0
  124. package/dist/{types.d.mts → types.d.cts} +1 -1
  125. package/dist/types.d.cts.map +1 -0
  126. package/dist/types.d.ts +14 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/package.json +7 -2
  129. package/dist/cli/configSchema.mjs.map +0 -1
  130. package/dist/cli/constants.d.mts.map +0 -1
  131. package/dist/cli/loadConfig.mjs.map +0 -1
  132. package/dist/cli/loadLocaleIDs.mjs.map +0 -1
  133. package/dist/cli/loadModels.mjs.map +0 -1
  134. package/dist/cli.mjs.map +0 -1
  135. package/dist/generateTypes.mjs.map +0 -1
  136. package/dist/index.mjs +0 -4
  137. package/dist/lib/addBlankLine.mjs.map +0 -1
  138. package/dist/lib/addLine.mjs.map +0 -1
  139. package/dist/lib/addSection.mjs.map +0 -1
  140. package/dist/lib/buildCustomTypeDataType.mjs.map +0 -1
  141. package/dist/lib/buildCustomTypeType.mjs.map +0 -1
  142. package/dist/lib/buildFieldDocs.mjs.map +0 -1
  143. package/dist/lib/buildFieldProperties.mjs.map +0 -1
  144. package/dist/lib/buildSharedSliceType.mjs.map +0 -1
  145. package/dist/lib/buildTypeName.mjs.map +0 -1
  146. package/dist/lib/getCacheKey.mjs.map +0 -1
  147. package/dist/lib/getHumanReadablePath.mjs.map +0 -1
  148. package/dist/types.d.mts.map +0 -1
  149. /package/dist/{cli.d.mts → cli.d.cts} +0 -0
@@ -28,4 +28,4 @@ const FIELD_DOCUMENTATION_URLS = {
28
28
  //#endregion
29
29
  export { CUSTOM_TYPES_DOCUMENTATION_URL, FIELD_DOCUMENTATION_URLS, SHARED_SLICES_DOCUMENTATION_URL };
30
30
 
31
- //# sourceMappingURL=constants.mjs.map
31
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"@prismicio/client\";\n\nexport const CUSTOM_TYPES_DOCUMENTATION_URL = \"https://prismic.io/docs/content-modeling\";\n\nexport const SHARED_SLICES_DOCUMENTATION_URL = \"https://prismic.io/docs/slices\";\n\nexport const FIELD_DOCUMENTATION_URLS = {\n\tUID: \"https://prismic.io/docs/fields/uid\",\n\tBoolean: \"https://prismic.io/docs/fields/boolean\",\n\tColor: \"https://prismic.io/docs/fields/color\",\n\tDate: \"https://prismic.io/docs/fields/date\",\n\tTimestamp: \"https://prismic.io/docs/fields/timestamp\",\n\tNumber: \"https://prismic.io/docs/fields/number\",\n\tText: \"https://prismic.io/docs/fields/text\",\n\tSelect: \"https://prismic.io/docs/fields/select\",\n\tStructuredText: \"https://prismic.io/docs/fields/rich-text\",\n\tImage: \"https://prismic.io/docs/fields/image\",\n\tLink: {\n\t\tcontentRelationship: \"https://prismic.io/docs/fields/content-relationship\",\n\t\tlink: \"https://prismic.io/docs/fields/link\",\n\t\tlinkToMedia: \"https://prismic.io/docs/fields/link-to-media\",\n\t},\n\tEmbed: \"https://prismic.io/docs/fields/embed\",\n\tGeoPoint: \"https://prismic.io/docs/fields/geopoint\",\n\tTable: \"https://prismic.io/docs/fields/table\",\n\tGroup: \"https://prismic.io/docs/fields/repeatable-group\",\n\tIntegrationFields: \"https://prismic.io/docs/fields/integration\",\n\tSlices: \"https://prismic.io/docs/slices\",\n\tChoice: \"https://prismic.io/docs/slices\",\n} satisfies Record<\n\tExclude<\n\t\t(typeof CustomTypeModelFieldType)[keyof typeof CustomTypeModelFieldType],\n\t\t\"Range\" | \"Separator\"\n\t>,\n\tstring | Record<string, string>\n>;\n"],"mappings":";AAEA,MAAa,iCAAiC;AAE9C,MAAa,kCAAkC;AAE/C,MAAa,2BAA2B;CACvC,KAAK;CACL,SAAS;CACT,OAAO;CACP,MAAM;CACN,WAAW;CACX,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,MAAM;EACL,qBAAqB;EACrB,MAAM;EACN,aAAa;EACb;CACD,OAAO;CACP,UAAU;CACV,OAAO;CACP,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,QAAQ;CACR"}
@@ -0,0 +1,25 @@
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
+ let node_module = require("node:module");
3
+ //#region src/detectTypesProvider.ts
4
+ /**
5
+ * Detects which types provider should be used for a project.
6
+ *
7
+ * @param config - Configures the detection.
8
+ * @returns The types provider identifier to use, or `undefined` if on cannot be
9
+ * determined.
10
+ */
11
+ const detectTypesProvider = async (config = {}) => {
12
+ const cwd = config.cwd || process.cwd();
13
+ const require = (0, node_module.createRequire)(cwd.endsWith("/") ? cwd : cwd + "/");
14
+ try {
15
+ if (Number.parseInt(require("@prismicio/client/package.json").version.split(".")[0]) >= 7) return "@prismicio/client";
16
+ } catch {}
17
+ try {
18
+ require.resolve("@prismicio/types");
19
+ return "@prismicio/types";
20
+ } catch {}
21
+ };
22
+ //#endregion
23
+ exports.detectTypesProvider = detectTypesProvider;
24
+
25
+ //# sourceMappingURL=detectTypesProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectTypesProvider.mjs","names":[],"sources":["../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (Number.parseInt(require(\"@prismicio/client/package.json\").version.split(\".\")[0]) >= 7) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,sBAAsB,OAClC,SAAoC,EAAE,KACE;CACxC,MAAM,MAAM,OAAO,OAAO,QAAQ,KAAK;CAEvC,MAAM,UAAU,cAAc,IAAI,SAAS,IAAI,GAAG,MAAM,MAAM,IAAI;AAElE,KAAI;AACH,MAAI,OAAO,SAAS,QAAQ,iCAAiC,CAAC,QAAQ,MAAM,IAAI,CAAC,GAAG,IAAI,EACvF,QAAO;SAED;AAIR,KAAI;AACH,UAAQ,QAAQ,mBAAmB;AAEnC,SAAO;SACA"}
1
+ {"version":3,"file":"detectTypesProvider.cjs","names":[],"sources":["../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (Number.parseInt(require(\"@prismicio/client/package.json\").version.split(\".\")[0]) >= 7) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,sBAAsB,OAClC,SAAoC,EAAE,KACE;CACxC,MAAM,MAAM,OAAO,OAAO,QAAQ,KAAK;CAEvC,MAAM,WAAA,GAAA,YAAA,eAAwB,IAAI,SAAS,IAAI,GAAG,MAAM,MAAM,IAAI;AAElE,KAAI;AACH,MAAI,OAAO,SAAS,QAAQ,iCAAiC,CAAC,QAAQ,MAAM,IAAI,CAAC,GAAG,IAAI,EACvF,QAAO;SAED;AAIR,KAAI;AACH,UAAQ,QAAQ,mBAAmB;AAEnC,SAAO;SACA"}
@@ -1,4 +1,4 @@
1
- import { TypesProvider } from "./generateTypes.mjs";
1
+ import { TypesProvider } from "./generateTypes.cjs";
2
2
 
3
3
  //#region src/detectTypesProvider.d.ts
4
4
  type DetectTypesProviderConfig = {
@@ -14,4 +14,4 @@ type DetectTypesProviderConfig = {
14
14
  declare const detectTypesProvider: (config?: DetectTypesProviderConfig) => Promise<TypesProvider | undefined>;
15
15
  //#endregion
16
16
  export { DetectTypesProviderConfig, detectTypesProvider };
17
- //# sourceMappingURL=detectTypesProvider.d.mts.map
17
+ //# sourceMappingURL=detectTypesProvider.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectTypesProvider.d.mts","names":[],"sources":["../src/detectTypesProvider.ts"],"mappings":";;;KAIY,yBAAA;EACX,GAAA;AAAA;;;;;AAUD;;;cAAa,mBAAA,GACZ,MAAA,GAAQ,yBAAA,KACN,OAAA,CAAQ,aAAA"}
1
+ {"version":3,"file":"detectTypesProvider.d.cts","names":[],"sources":["../src/detectTypesProvider.ts"],"mappings":";;;KAIY,yBAAA;EACX,GAAA;AAAA;;;;;AAUD;;;cAAa,mBAAA,GACZ,MAAA,GAAQ,yBAAA,KACN,OAAA,CAAQ,aAAA"}
@@ -0,0 +1,17 @@
1
+ import { TypesProvider } from "./generateTypes.js";
2
+
3
+ //#region src/detectTypesProvider.d.ts
4
+ type DetectTypesProviderConfig = {
5
+ cwd?: string;
6
+ };
7
+ /**
8
+ * Detects which types provider should be used for a project.
9
+ *
10
+ * @param config - Configures the detection.
11
+ * @returns The types provider identifier to use, or `undefined` if on cannot be
12
+ * determined.
13
+ */
14
+ declare const detectTypesProvider: (config?: DetectTypesProviderConfig) => Promise<TypesProvider | undefined>;
15
+ //#endregion
16
+ export { DetectTypesProviderConfig, detectTypesProvider };
17
+ //# sourceMappingURL=detectTypesProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectTypesProvider.d.ts","names":[],"sources":["../src/detectTypesProvider.ts"],"mappings":";;;KAIY,yBAAA;EACX,GAAA;AAAA;;;;;AAUD;;;cAAa,mBAAA,GACZ,MAAA,GAAQ,yBAAA,KACN,OAAA,CAAQ,aAAA"}
@@ -21,4 +21,4 @@ const detectTypesProvider = async (config = {}) => {
21
21
  //#endregion
22
22
  export { detectTypesProvider };
23
23
 
24
- //# sourceMappingURL=detectTypesProvider.mjs.map
24
+ //# sourceMappingURL=detectTypesProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectTypesProvider.js","names":[],"sources":["../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst cwd = config.cwd || process.cwd();\n\n\tconst require = createRequire(cwd.endsWith(\"/\") ? cwd : cwd + \"/\");\n\n\ttry {\n\t\tif (Number.parseInt(require(\"@prismicio/client/package.json\").version.split(\".\")[0]) >= 7) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,sBAAsB,OAClC,SAAoC,EAAE,KACE;CACxC,MAAM,MAAM,OAAO,OAAO,QAAQ,KAAK;CAEvC,MAAM,UAAU,cAAc,IAAI,SAAS,IAAI,GAAG,MAAM,MAAM,IAAI;AAElE,KAAI;AACH,MAAI,OAAO,SAAS,QAAQ,iCAAiC,CAAC,QAAQ,MAAM,IAAI,CAAC,GAAG,IAAI,EACvF,QAAO;SAED;AAIR,KAAI;AACH,UAAQ,QAAQ,mBAAmB;AAEnC,SAAO;SACA"}
@@ -0,0 +1,144 @@
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_addLine = require("./lib/addLine.cjs");
3
+ const require_addSection = require("./lib/addSection.cjs");
4
+ const require_buildUnion = require("./lib/buildUnion.cjs");
5
+ const require_buildCustomTypeType = require("./lib/buildCustomTypeType.cjs");
6
+ const require_buildSharedSliceType = require("./lib/buildSharedSliceType.cjs");
7
+ let common_tags = require("common-tags");
8
+ let quick_lru = require("quick-lru");
9
+ quick_lru = require_runtime.__toESM(quick_lru);
10
+ //#region src/generateTypes.ts
11
+ const cache = new quick_lru.default({ maxSize: 1e3 });
12
+ function generateTypes(config = {}) {
13
+ const fieldConfigs = config.fieldConfigs || {};
14
+ const shouldUseCache = config.cache ?? true;
15
+ let code = "";
16
+ const typesProvider = config.typesProvider || "@prismicio/types";
17
+ let clientImportName = "prismic";
18
+ code = require_addLine.addLine(`import type * as prismic from "${typesProvider}";`, code);
19
+ if (config.clientIntegration?.includeCreateClientInterface || config.clientIntegration?.includeContentNamespace) {
20
+ if (typesProvider !== "@prismicio/client") {
21
+ clientImportName = "prismicClient";
22
+ code = require_addLine.addLine(`import type * as ${clientImportName} from "@prismicio/client";`, code);
23
+ }
24
+ }
25
+ code = require_addSection.addSection(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`, code);
26
+ code = require_addSection.addSection(`
27
+ type PickContentRelationshipFieldData<
28
+ TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
29
+ TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
30
+ TLang extends string
31
+ > = |
32
+ // Content relationship fields
33
+ {
34
+ [TSubRelationship in Extract<
35
+ TRelationship["fields"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1
36
+ > as TSubRelationship["id"]]:
37
+ ContentRelationshipFieldWithData<TSubRelationship["customtypes"], TLang>;
38
+ } &
39
+ // Group
40
+ {
41
+ [TGroup in Extract<
42
+ TRelationship["fields"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2
43
+ > as TGroup["id"]]:
44
+ TData[TGroup["id"]] extends prismic.GroupField<infer TGroupData>
45
+ ? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>
46
+ : never
47
+ } &
48
+ // Other fields
49
+ {
50
+ [TFieldKey in Extract<TRelationship["fields"][number], string>]:
51
+ TFieldKey extends keyof TData ? TData[TFieldKey] : never;
52
+ };
53
+
54
+ type ContentRelationshipFieldWithData<
55
+ TCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],
56
+ TLang extends string = string
57
+ > = {
58
+ [ID in Exclude<TCustomType[number], string>["id"]]:
59
+ prismic.ContentRelationshipField<
60
+ ID,
61
+ TLang,
62
+ PickContentRelationshipFieldData<
63
+ Extract<TCustomType[number], { id: ID }>,
64
+ Extract<prismic.Content.AllDocumentTypes, { type: ID }>["data"],
65
+ TLang
66
+ >
67
+ >
68
+ }[Exclude<TCustomType[number], string>["id"]];
69
+ `, code);
70
+ const contentTypeNames = [];
71
+ if (config.customTypeModels) {
72
+ const allDocumentTypesTypeNames = [];
73
+ for (const model of config.customTypeModels) {
74
+ const customTypeType = require_buildCustomTypeType.buildCustomTypeType({
75
+ model,
76
+ localeIDs: config.localeIDs,
77
+ fieldConfigs,
78
+ cache: shouldUseCache ? cache : void 0
79
+ });
80
+ for (const auxiliaryType of customTypeType.auxiliaryTypes) code = require_addSection.addSection(auxiliaryType.code, code);
81
+ code = require_addSection.addSection(customTypeType.code, code);
82
+ allDocumentTypesTypeNames.push(customTypeType.name);
83
+ contentTypeNames.push(customTypeType.name);
84
+ contentTypeNames.push(...customTypeType.contentTypeNames);
85
+ }
86
+ if (config.customTypeModels.length > 0) {
87
+ const allDocumentTypesUnionName = "AllDocumentTypes";
88
+ code = require_addSection.addSection(`export type ${allDocumentTypesUnionName} = ${require_buildUnion.buildUnion(allDocumentTypesTypeNames)};`, code);
89
+ contentTypeNames.push(allDocumentTypesUnionName);
90
+ }
91
+ }
92
+ if (config.sharedSliceModels) for (const model of config.sharedSliceModels) {
93
+ const sharedSliceType = require_buildSharedSliceType.buildSharedSliceType({
94
+ model,
95
+ fieldConfigs,
96
+ cache: shouldUseCache ? cache : void 0
97
+ });
98
+ for (const auxiliaryType of sharedSliceType.auxiliaryTypes) code = require_addSection.addSection(auxiliaryType.code, code);
99
+ code = require_addSection.addSection(sharedSliceType.code, code);
100
+ contentTypeNames.push(sharedSliceType.name);
101
+ contentTypeNames.push(...sharedSliceType.contentTypeNames);
102
+ }
103
+ if (config.clientIntegration?.includeCreateClientInterface || config.clientIntegration?.includeContentNamespace) {
104
+ let clientModuleCode = "";
105
+ if (config.clientIntegration.includeCreateClientInterface) if ((config.customTypeModels?.length || 0) > 0) {
106
+ clientModuleCode = require_addSection.addSection(`interface CreateClient {
107
+ (repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client<AllDocumentTypes>;
108
+ }`, clientModuleCode);
109
+ clientModuleCode = require_addSection.addSection(`interface CreateWriteClient {
110
+ (repositoryNameOrEndpoint: string, options: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient<AllDocumentTypes>;
111
+ }`, clientModuleCode);
112
+ clientModuleCode = require_addSection.addSection(`interface CreateMigration {
113
+ (): ${clientImportName}.Migration<AllDocumentTypes>;
114
+ }`, clientModuleCode);
115
+ } else {
116
+ clientModuleCode = require_addSection.addSection(`interface CreateClient {
117
+ (repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client;
118
+ }`, clientModuleCode);
119
+ clientModuleCode = require_addSection.addSection(`interface CreateWriteClient {
120
+ (repositoryNameOrEndpoint: string, options?: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient;
121
+ }`, clientModuleCode);
122
+ clientModuleCode = require_addSection.addSection(`interface CreateMigration {
123
+ (): ${clientImportName}.Migration;
124
+ }`, clientModuleCode);
125
+ }
126
+ if (config.clientIntegration.includeContentNamespace) clientModuleCode = require_addSection.addSection(common_tags.source`
127
+ namespace Content {
128
+ export type {
129
+ ${contentTypeNames.join(",\n")}
130
+ }
131
+ }
132
+ `, clientModuleCode);
133
+ code = require_addSection.addSection(common_tags.source`
134
+ declare module "@prismicio/client" {
135
+ ${clientModuleCode}
136
+ }
137
+ `, code);
138
+ }
139
+ return code;
140
+ }
141
+ //#endregion
142
+ exports.generateTypes = generateTypes;
143
+
144
+ //# sourceMappingURL=generateTypes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateTypes.cjs","names":["QuickLRU","addLine","addSection","buildCustomTypeType","buildUnion","buildSharedSliceType"],"sources":["../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { source } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { addLine } from \"./lib/addLine\";\nimport { addSection } from \"./lib/addSection\";\nimport { buildCustomTypeType } from \"./lib/buildCustomTypeType\";\nimport { buildSharedSliceType } from \"./lib/buildSharedSliceType\";\nimport { buildUnion } from \"./lib/buildUnion\";\nimport type { FieldConfigs } from \"./types\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nconst cache = new QuickLRU<string, unknown>({ maxSize: 1000 });\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n\tcache?: boolean;\n};\n\nexport function generateTypes(config: GenerateTypesConfig = {}): string {\n\tconst fieldConfigs = config.fieldConfigs || {};\n\tconst shouldUseCache = config.cache ?? true;\n\n\tlet code = \"\";\n\n\tconst typesProvider = config.typesProvider || \"@prismicio/types\";\n\tlet clientImportName = \"prismic\";\n\n\tcode = addLine(`import type * as prismic from \"${typesProvider}\";`, code);\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tif (typesProvider !== \"@prismicio/client\") {\n\t\t\tclientImportName = \"prismicClient\";\n\n\t\t\t// This import declaration would be a duplicate if the types\n\t\t\t// provider is @prismicio/client.\n\t\t\tcode = addLine(`import type * as ${clientImportName} from \"@prismicio/client\";`, code);\n\t\t}\n\t}\n\n\tcode = addSection(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`, code);\n\n\tcode = addSection(\n\t\t`\ntype PickContentRelationshipFieldData<\n\tTRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,\n\tTData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,\n\tTLang extends string\n> = |\n\t// Content relationship fields\n\t{\n\t\t[TSubRelationship in Extract<\n\t\t\tTRelationship[\"fields\"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1\n\t\t> as TSubRelationship[\"id\"]]:\n\t\t\tContentRelationshipFieldWithData<TSubRelationship[\"customtypes\"], TLang>;\n\t} &\n\t// Group\n\t{\n\t\t[TGroup in Extract<\n\t\t\tTRelationship[\"fields\"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2\n\t\t> as TGroup[\"id\"]]:\n\t\t\tTData[TGroup[\"id\"]] extends prismic.GroupField<infer TGroupData>\n\t\t\t\t? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>\n\t\t\t\t: never\n\t} &\n\t// Other fields\n\t{\n\t\t[TFieldKey in Extract<TRelationship[\"fields\"][number], string>]:\n\t\t\tTFieldKey extends keyof TData ? TData[TFieldKey] : never;\n\t};\n\ntype ContentRelationshipFieldWithData<\n\tTCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],\n\tTLang extends string = string\n> = {\n\t[ID in Exclude<TCustomType[number], string>[\"id\"]]:\n\t\tprismic.ContentRelationshipField<\n\t\t\tID,\n\t\t\tTLang,\n\t\t\tPickContentRelationshipFieldData<\n\t\t\t\tExtract<TCustomType[number], { id: ID }>,\n\t\t\t\tExtract<prismic.Content.AllDocumentTypes, { type: ID }>[\"data\"],\n\t\t\t\tTLang\n\t\t\t>\n\t\t>\n}[Exclude<TCustomType[number], string>[\"id\"]];\n`,\n\t\tcode,\n\t);\n\n\tconst contentTypeNames: string[] = [];\n\n\tif (config.customTypeModels) {\n\t\tconst allDocumentTypesTypeNames: string[] = [];\n\n\t\tfor (const model of config.customTypeModels) {\n\t\t\tconst customTypeType = buildCustomTypeType({\n\t\t\t\tmodel,\n\t\t\t\tlocaleIDs: config.localeIDs,\n\t\t\t\tfieldConfigs,\n\t\t\t\tcache: shouldUseCache ? cache : undefined,\n\t\t\t});\n\n\t\t\tfor (const auxiliaryType of customTypeType.auxiliaryTypes) {\n\t\t\t\tcode = addSection(auxiliaryType.code, code);\n\t\t\t}\n\n\t\t\tcode = addSection(customTypeType.code, code);\n\n\t\t\tallDocumentTypesTypeNames.push(customTypeType.name);\n\n\t\t\tcontentTypeNames.push(customTypeType.name);\n\t\t\tcontentTypeNames.push(...customTypeType.contentTypeNames);\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tconst allDocumentTypesUnionName = \"AllDocumentTypes\";\n\t\t\tconst allDocumentTypesUnion = buildUnion(allDocumentTypesTypeNames);\n\n\t\t\tcode = addSection(\n\t\t\t\t`export type ${allDocumentTypesUnionName} = ${allDocumentTypesUnion};`,\n\t\t\t\tcode,\n\t\t\t);\n\n\t\t\tcontentTypeNames.push(allDocumentTypesUnionName);\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\tconst sharedSliceType = buildSharedSliceType({\n\t\t\t\tmodel,\n\t\t\t\tfieldConfigs,\n\t\t\t\tcache: shouldUseCache ? cache : undefined,\n\t\t\t});\n\n\t\t\tfor (const auxiliaryType of sharedSliceType.auxiliaryTypes) {\n\t\t\t\tcode = addSection(auxiliaryType.code, code);\n\t\t\t}\n\n\t\t\tcode = addSection(sharedSliceType.code, code);\n\n\t\t\tcontentTypeNames.push(sharedSliceType.name);\n\t\t\tcontentTypeNames.push(...sharedSliceType.contentTypeNames);\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tlet clientModuleCode = \"\";\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tif ((config.customTypeModels?.length || 0) > 0) {\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateWriteClient {\n\t(repositoryNameOrEndpoint: string, options: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateMigration {\n\t(): ${clientImportName}.Migration<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateWriteClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateMigration {\n\t(): ${clientImportName}.Migration;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tclientModuleCode = addSection(\n\t\t\t\tsource`\n\t\t\t\t\tnamespace Content {\n\t\t\t\t\t\texport type {\n\t\t\t\t\t\t\t${contentTypeNames.join(\",\\n\")}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t`,\n\t\t\t\tclientModuleCode,\n\t\t\t);\n\t\t}\n\n\t\tcode = addSection(\n\t\t\tsource`\n\t\t\t\tdeclare module \"@prismicio/client\" {\n\t\t\t\t\t${clientModuleCode}\n\t\t\t\t}\n\t\t\t`,\n\t\t\tcode,\n\t\t);\n\t}\n\n\treturn code;\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,QAAQ,IAAIA,UAAAA,QAA0B,EAAE,SAAS,KAAM,CAAC;AAe9D,SAAgB,cAAc,SAA8B,EAAE,EAAU;CACvE,MAAM,eAAe,OAAO,gBAAgB,EAAE;CAC9C,MAAM,iBAAiB,OAAO,SAAS;CAEvC,IAAI,OAAO;CAEX,MAAM,gBAAgB,OAAO,iBAAiB;CAC9C,IAAI,mBAAmB;AAEvB,QAAOC,gBAAAA,QAAQ,kCAAkC,cAAc,KAAK,KAAK;AAEzE,KACC,OAAO,mBAAmB,gCAC1B,OAAO,mBAAmB;MAEtB,kBAAkB,qBAAqB;AAC1C,sBAAmB;AAInB,UAAOA,gBAAAA,QAAQ,oBAAoB,iBAAiB,6BAA6B,KAAK;;;AAIxF,QAAOC,mBAAAA,WAAW,4DAA4D,KAAK;AAEnF,QAAOA,mBAAAA,WACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CA,KACA;CAED,MAAM,mBAA6B,EAAE;AAErC,KAAI,OAAO,kBAAkB;EAC5B,MAAM,4BAAsC,EAAE;AAE9C,OAAK,MAAM,SAAS,OAAO,kBAAkB;GAC5C,MAAM,iBAAiBC,4BAAAA,oBAAoB;IAC1C;IACA,WAAW,OAAO;IAClB;IACA,OAAO,iBAAiB,QAAQ,KAAA;IAChC,CAAC;AAEF,QAAK,MAAM,iBAAiB,eAAe,eAC1C,QAAOD,mBAAAA,WAAW,cAAc,MAAM,KAAK;AAG5C,UAAOA,mBAAAA,WAAW,eAAe,MAAM,KAAK;AAE5C,6BAA0B,KAAK,eAAe,KAAK;AAEnD,oBAAiB,KAAK,eAAe,KAAK;AAC1C,oBAAiB,KAAK,GAAG,eAAe,iBAAiB;;AAG1D,MAAI,OAAO,iBAAiB,SAAS,GAAG;GACvC,MAAM,4BAA4B;AAGlC,UAAOA,mBAAAA,WACN,eAAe,0BAA0B,KAHZE,mBAAAA,WAAW,0BAA0B,CAGE,IACpE,KACA;AAED,oBAAiB,KAAK,0BAA0B;;;AAIlD,KAAI,OAAO,kBACV,MAAK,MAAM,SAAS,OAAO,mBAAmB;EAC7C,MAAM,kBAAkBC,6BAAAA,qBAAqB;GAC5C;GACA;GACA,OAAO,iBAAiB,QAAQ,KAAA;GAChC,CAAC;AAEF,OAAK,MAAM,iBAAiB,gBAAgB,eAC3C,QAAOH,mBAAAA,WAAW,cAAc,MAAM,KAAK;AAG5C,SAAOA,mBAAAA,WAAW,gBAAgB,MAAM,KAAK;AAE7C,mBAAiB,KAAK,gBAAgB,KAAK;AAC3C,mBAAiB,KAAK,GAAG,gBAAgB,iBAAiB;;AAI5D,KACC,OAAO,mBAAmB,gCAC1B,OAAO,mBAAmB,yBACzB;EACD,IAAI,mBAAmB;AAEvB,MAAI,OAAO,kBAAkB,6BAC5B,MAAK,OAAO,kBAAkB,UAAU,KAAK,GAAG;AAC/C,sBAAmBA,mBAAAA,WAClB;gDAC2C,iBAAiB,kBAAkB,iBAAiB;IAE/F,iBACA;AACD,sBAAmBA,mBAAAA,WAClB;+CAC0C,iBAAiB,uBAAuB,iBAAiB;IAEnG,iBACA;AACD,sBAAmBA,mBAAAA,WAClB;OACE,iBAAiB;IAEnB,iBACA;SACK;AACN,sBAAmBA,mBAAAA,WAClB;gDAC2C,iBAAiB,kBAAkB,iBAAiB;IAE/F,iBACA;AACD,sBAAmBA,mBAAAA,WAClB;gDAC2C,iBAAiB,uBAAuB,iBAAiB;IAEpG,iBACA;AACD,sBAAmBA,mBAAAA,WAClB;OACE,iBAAiB;IAEnB,iBACA;;AAIH,MAAI,OAAO,kBAAkB,wBAC5B,oBAAmBA,mBAAAA,WAClB,YAAA,MAAM;;;SAGD,iBAAiB,KAAK,MAAM,CAAC;;;OAIlC,iBACA;AAGF,SAAOA,mBAAAA,WACN,YAAA,MAAM;;OAEF,iBAAiB;;MAGrB,KACA;;AAGF,QAAO"}
@@ -1,4 +1,4 @@
1
- import { FieldConfigs } from "./types.mjs";
1
+ import { FieldConfigs } from "./types.cjs";
2
2
  import { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
3
3
 
4
4
  //#region src/generateTypes.d.ts
@@ -18,4 +18,4 @@ type GenerateTypesConfig = {
18
18
  declare function generateTypes(config?: GenerateTypesConfig): string;
19
19
  //#endregion
20
20
  export { GenerateTypesConfig, TypesProvider, generateTypes };
21
- //# sourceMappingURL=generateTypes.d.mts.map
21
+ //# sourceMappingURL=generateTypes.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateTypes.d.mts","names":[],"sources":["../src/generateTypes.ts"],"mappings":";;;;KAWY,aAAA;AAAA,KAIA,mBAAA;EACX,gBAAA,GAAmB,eAAA;EACnB,iBAAA,GAAoB,gBAAA;EACpB,SAAA;EACA,YAAA,GAAe,YAAA;EACf,aAAA,GAAgB,aAAA;EAChB,iBAAA;IACC,4BAAA;IACA,uBAAA;EAAA;EAED,KAAA;AAAA;AAAA,iBAGe,aAAA,CAAc,MAAA,GAAQ,mBAAA"}
1
+ {"version":3,"file":"generateTypes.d.cts","names":[],"sources":["../src/generateTypes.ts"],"mappings":";;;;KAWY,aAAA;AAAA,KAIA,mBAAA;EACX,gBAAA,GAAmB,eAAA;EACnB,iBAAA,GAAoB,gBAAA;EACpB,SAAA;EACA,YAAA,GAAe,YAAA;EACf,aAAA,GAAgB,aAAA;EAChB,iBAAA;IACC,4BAAA;IACA,uBAAA;EAAA;EAED,KAAA;AAAA;AAAA,iBAGe,aAAA,CAAc,MAAA,GAAQ,mBAAA"}
@@ -0,0 +1,21 @@
1
+ import { FieldConfigs } from "./types.js";
2
+ import { CustomTypeModel, SharedSliceModel } from "@prismicio/client";
3
+
4
+ //#region src/generateTypes.d.ts
5
+ type TypesProvider = "@prismicio/client" | "@prismicio/types";
6
+ type GenerateTypesConfig = {
7
+ customTypeModels?: CustomTypeModel[];
8
+ sharedSliceModels?: SharedSliceModel[];
9
+ localeIDs?: string[];
10
+ fieldConfigs?: FieldConfigs;
11
+ typesProvider?: TypesProvider;
12
+ clientIntegration?: {
13
+ includeCreateClientInterface?: boolean;
14
+ includeContentNamespace?: boolean;
15
+ };
16
+ cache?: boolean;
17
+ };
18
+ declare function generateTypes(config?: GenerateTypesConfig): string;
19
+ //#endregion
20
+ export { GenerateTypesConfig, TypesProvider, generateTypes };
21
+ //# sourceMappingURL=generateTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateTypes.d.ts","names":[],"sources":["../src/generateTypes.ts"],"mappings":";;;;KAWY,aAAA;AAAA,KAIA,mBAAA;EACX,gBAAA,GAAmB,eAAA;EACnB,iBAAA,GAAoB,gBAAA;EACpB,SAAA;EACA,YAAA,GAAe,YAAA;EACf,aAAA,GAAgB,aAAA;EAChB,iBAAA;IACC,4BAAA;IACA,uBAAA;EAAA;EAED,KAAA;AAAA;AAAA,iBAGe,aAAA,CAAc,MAAA,GAAQ,mBAAA"}
@@ -1,8 +1,8 @@
1
- import { addLine } from "./lib/addLine.mjs";
2
- import { addSection } from "./lib/addSection.mjs";
3
- import { buildUnion } from "./lib/buildUnion.mjs";
4
- import { buildCustomTypeType } from "./lib/buildCustomTypeType.mjs";
5
- import { buildSharedSliceType } from "./lib/buildSharedSliceType.mjs";
1
+ import { addLine } from "./lib/addLine.js";
2
+ import { addSection } from "./lib/addSection.js";
3
+ import { buildUnion } from "./lib/buildUnion.js";
4
+ import { buildCustomTypeType } from "./lib/buildCustomTypeType.js";
5
+ import { buildSharedSliceType } from "./lib/buildSharedSliceType.js";
6
6
  import { source } from "common-tags";
7
7
  import QuickLRU from "quick-lru";
8
8
  //#region src/generateTypes.ts
@@ -139,4 +139,4 @@ type ContentRelationshipFieldWithData<
139
139
  //#endregion
140
140
  export { generateTypes };
141
141
 
142
- //# sourceMappingURL=generateTypes.mjs.map
142
+ //# sourceMappingURL=generateTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateTypes.js","names":[],"sources":["../src/generateTypes.ts"],"sourcesContent":["import type { CustomTypeModel, SharedSliceModel } from \"@prismicio/client\";\nimport { source } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { addLine } from \"./lib/addLine\";\nimport { addSection } from \"./lib/addSection\";\nimport { buildCustomTypeType } from \"./lib/buildCustomTypeType\";\nimport { buildSharedSliceType } from \"./lib/buildSharedSliceType\";\nimport { buildUnion } from \"./lib/buildUnion\";\nimport type { FieldConfigs } from \"./types\";\n\nexport type TypesProvider = \"@prismicio/client\" | \"@prismicio/types\";\n\nconst cache = new QuickLRU<string, unknown>({ maxSize: 1000 });\n\nexport type GenerateTypesConfig = {\n\tcustomTypeModels?: CustomTypeModel[];\n\tsharedSliceModels?: SharedSliceModel[];\n\tlocaleIDs?: string[];\n\tfieldConfigs?: FieldConfigs;\n\ttypesProvider?: TypesProvider;\n\tclientIntegration?: {\n\t\tincludeCreateClientInterface?: boolean;\n\t\tincludeContentNamespace?: boolean;\n\t};\n\tcache?: boolean;\n};\n\nexport function generateTypes(config: GenerateTypesConfig = {}): string {\n\tconst fieldConfigs = config.fieldConfigs || {};\n\tconst shouldUseCache = config.cache ?? true;\n\n\tlet code = \"\";\n\n\tconst typesProvider = config.typesProvider || \"@prismicio/types\";\n\tlet clientImportName = \"prismic\";\n\n\tcode = addLine(`import type * as prismic from \"${typesProvider}\";`, code);\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tif (typesProvider !== \"@prismicio/client\") {\n\t\t\tclientImportName = \"prismicClient\";\n\n\t\t\t// This import declaration would be a duplicate if the types\n\t\t\t// provider is @prismicio/client.\n\t\t\tcode = addLine(`import type * as ${clientImportName} from \"@prismicio/client\";`, code);\n\t\t}\n\t}\n\n\tcode = addSection(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`, code);\n\n\tcode = addSection(\n\t\t`\ntype PickContentRelationshipFieldData<\n\tTRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,\n\tTData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,\n\tTLang extends string\n> = |\n\t// Content relationship fields\n\t{\n\t\t[TSubRelationship in Extract<\n\t\t\tTRelationship[\"fields\"][number], prismic.CustomTypeModelFetchContentRelationshipLevel1\n\t\t> as TSubRelationship[\"id\"]]:\n\t\t\tContentRelationshipFieldWithData<TSubRelationship[\"customtypes\"], TLang>;\n\t} &\n\t// Group\n\t{\n\t\t[TGroup in Extract<\n\t\t\tTRelationship[\"fields\"][number], prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2\n\t\t> as TGroup[\"id\"]]:\n\t\t\tTData[TGroup[\"id\"]] extends prismic.GroupField<infer TGroupData>\n\t\t\t\t? prismic.GroupField<PickContentRelationshipFieldData<TGroup, TGroupData, TLang>>\n\t\t\t\t: never\n\t} &\n\t// Other fields\n\t{\n\t\t[TFieldKey in Extract<TRelationship[\"fields\"][number], string>]:\n\t\t\tTFieldKey extends keyof TData ? TData[TFieldKey] : never;\n\t};\n\ntype ContentRelationshipFieldWithData<\n\tTCustomType extends readonly (prismic.CustomTypeModelFetchCustomTypeLevel1 | string)[] | readonly (prismic.CustomTypeModelFetchCustomTypeLevel2 | string)[],\n\tTLang extends string = string\n> = {\n\t[ID in Exclude<TCustomType[number], string>[\"id\"]]:\n\t\tprismic.ContentRelationshipField<\n\t\t\tID,\n\t\t\tTLang,\n\t\t\tPickContentRelationshipFieldData<\n\t\t\t\tExtract<TCustomType[number], { id: ID }>,\n\t\t\t\tExtract<prismic.Content.AllDocumentTypes, { type: ID }>[\"data\"],\n\t\t\t\tTLang\n\t\t\t>\n\t\t>\n}[Exclude<TCustomType[number], string>[\"id\"]];\n`,\n\t\tcode,\n\t);\n\n\tconst contentTypeNames: string[] = [];\n\n\tif (config.customTypeModels) {\n\t\tconst allDocumentTypesTypeNames: string[] = [];\n\n\t\tfor (const model of config.customTypeModels) {\n\t\t\tconst customTypeType = buildCustomTypeType({\n\t\t\t\tmodel,\n\t\t\t\tlocaleIDs: config.localeIDs,\n\t\t\t\tfieldConfigs,\n\t\t\t\tcache: shouldUseCache ? cache : undefined,\n\t\t\t});\n\n\t\t\tfor (const auxiliaryType of customTypeType.auxiliaryTypes) {\n\t\t\t\tcode = addSection(auxiliaryType.code, code);\n\t\t\t}\n\n\t\t\tcode = addSection(customTypeType.code, code);\n\n\t\t\tallDocumentTypesTypeNames.push(customTypeType.name);\n\n\t\t\tcontentTypeNames.push(customTypeType.name);\n\t\t\tcontentTypeNames.push(...customTypeType.contentTypeNames);\n\t\t}\n\n\t\tif (config.customTypeModels.length > 0) {\n\t\t\tconst allDocumentTypesUnionName = \"AllDocumentTypes\";\n\t\t\tconst allDocumentTypesUnion = buildUnion(allDocumentTypesTypeNames);\n\n\t\t\tcode = addSection(\n\t\t\t\t`export type ${allDocumentTypesUnionName} = ${allDocumentTypesUnion};`,\n\t\t\t\tcode,\n\t\t\t);\n\n\t\t\tcontentTypeNames.push(allDocumentTypesUnionName);\n\t\t}\n\t}\n\n\tif (config.sharedSliceModels) {\n\t\tfor (const model of config.sharedSliceModels) {\n\t\t\tconst sharedSliceType = buildSharedSliceType({\n\t\t\t\tmodel,\n\t\t\t\tfieldConfigs,\n\t\t\t\tcache: shouldUseCache ? cache : undefined,\n\t\t\t});\n\n\t\t\tfor (const auxiliaryType of sharedSliceType.auxiliaryTypes) {\n\t\t\t\tcode = addSection(auxiliaryType.code, code);\n\t\t\t}\n\n\t\t\tcode = addSection(sharedSliceType.code, code);\n\n\t\t\tcontentTypeNames.push(sharedSliceType.name);\n\t\t\tcontentTypeNames.push(...sharedSliceType.contentTypeNames);\n\t\t}\n\t}\n\n\tif (\n\t\tconfig.clientIntegration?.includeCreateClientInterface ||\n\t\tconfig.clientIntegration?.includeContentNamespace\n\t) {\n\t\tlet clientModuleCode = \"\";\n\n\t\tif (config.clientIntegration.includeCreateClientInterface) {\n\t\t\tif ((config.customTypeModels?.length || 0) > 0) {\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateWriteClient {\n\t(repositoryNameOrEndpoint: string, options: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateMigration {\n\t(): ${clientImportName}.Migration<AllDocumentTypes>;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.ClientConfig): ${clientImportName}.Client;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateWriteClient {\n\t(repositoryNameOrEndpoint: string, options?: ${clientImportName}.WriteClientConfig): ${clientImportName}.WriteClient;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t\tclientModuleCode = addSection(\n\t\t\t\t\t`interface CreateMigration {\n\t(): ${clientImportName}.Migration;\n}`,\n\t\t\t\t\tclientModuleCode,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (config.clientIntegration.includeContentNamespace) {\n\t\t\tclientModuleCode = addSection(\n\t\t\t\tsource`\n\t\t\t\t\tnamespace Content {\n\t\t\t\t\t\texport type {\n\t\t\t\t\t\t\t${contentTypeNames.join(\",\\n\")}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t`,\n\t\t\t\tclientModuleCode,\n\t\t\t);\n\t\t}\n\n\t\tcode = addSection(\n\t\t\tsource`\n\t\t\t\tdeclare module \"@prismicio/client\" {\n\t\t\t\t\t${clientModuleCode}\n\t\t\t\t}\n\t\t\t`,\n\t\t\tcode,\n\t\t);\n\t}\n\n\treturn code;\n}\n"],"mappings":";;;;;;;;AAaA,MAAM,QAAQ,IAAI,SAA0B,EAAE,SAAS,KAAM,CAAC;AAe9D,SAAgB,cAAc,SAA8B,EAAE,EAAU;CACvE,MAAM,eAAe,OAAO,gBAAgB,EAAE;CAC9C,MAAM,iBAAiB,OAAO,SAAS;CAEvC,IAAI,OAAO;CAEX,MAAM,gBAAgB,OAAO,iBAAiB;CAC9C,IAAI,mBAAmB;AAEvB,QAAO,QAAQ,kCAAkC,cAAc,KAAK,KAAK;AAEzE,KACC,OAAO,mBAAmB,gCAC1B,OAAO,mBAAmB;MAEtB,kBAAkB,qBAAqB;AAC1C,sBAAmB;AAInB,UAAO,QAAQ,oBAAoB,iBAAiB,6BAA6B,KAAK;;;AAIxF,QAAO,WAAW,4DAA4D,KAAK;AAEnF,QAAO,WACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CA,KACA;CAED,MAAM,mBAA6B,EAAE;AAErC,KAAI,OAAO,kBAAkB;EAC5B,MAAM,4BAAsC,EAAE;AAE9C,OAAK,MAAM,SAAS,OAAO,kBAAkB;GAC5C,MAAM,iBAAiB,oBAAoB;IAC1C;IACA,WAAW,OAAO;IAClB;IACA,OAAO,iBAAiB,QAAQ,KAAA;IAChC,CAAC;AAEF,QAAK,MAAM,iBAAiB,eAAe,eAC1C,QAAO,WAAW,cAAc,MAAM,KAAK;AAG5C,UAAO,WAAW,eAAe,MAAM,KAAK;AAE5C,6BAA0B,KAAK,eAAe,KAAK;AAEnD,oBAAiB,KAAK,eAAe,KAAK;AAC1C,oBAAiB,KAAK,GAAG,eAAe,iBAAiB;;AAG1D,MAAI,OAAO,iBAAiB,SAAS,GAAG;GACvC,MAAM,4BAA4B;AAGlC,UAAO,WACN,eAAe,0BAA0B,KAHZ,WAAW,0BAA0B,CAGE,IACpE,KACA;AAED,oBAAiB,KAAK,0BAA0B;;;AAIlD,KAAI,OAAO,kBACV,MAAK,MAAM,SAAS,OAAO,mBAAmB;EAC7C,MAAM,kBAAkB,qBAAqB;GAC5C;GACA;GACA,OAAO,iBAAiB,QAAQ,KAAA;GAChC,CAAC;AAEF,OAAK,MAAM,iBAAiB,gBAAgB,eAC3C,QAAO,WAAW,cAAc,MAAM,KAAK;AAG5C,SAAO,WAAW,gBAAgB,MAAM,KAAK;AAE7C,mBAAiB,KAAK,gBAAgB,KAAK;AAC3C,mBAAiB,KAAK,GAAG,gBAAgB,iBAAiB;;AAI5D,KACC,OAAO,mBAAmB,gCAC1B,OAAO,mBAAmB,yBACzB;EACD,IAAI,mBAAmB;AAEvB,MAAI,OAAO,kBAAkB,6BAC5B,MAAK,OAAO,kBAAkB,UAAU,KAAK,GAAG;AAC/C,sBAAmB,WAClB;gDAC2C,iBAAiB,kBAAkB,iBAAiB;IAE/F,iBACA;AACD,sBAAmB,WAClB;+CAC0C,iBAAiB,uBAAuB,iBAAiB;IAEnG,iBACA;AACD,sBAAmB,WAClB;OACE,iBAAiB;IAEnB,iBACA;SACK;AACN,sBAAmB,WAClB;gDAC2C,iBAAiB,kBAAkB,iBAAiB;IAE/F,iBACA;AACD,sBAAmB,WAClB;gDAC2C,iBAAiB,uBAAuB,iBAAiB;IAEpG,iBACA;AACD,sBAAmB,WAClB;OACE,iBAAiB;IAEnB,iBACA;;AAIH,MAAI,OAAO,kBAAkB,wBAC5B,oBAAmB,WAClB,MAAM;;;SAGD,iBAAiB,KAAK,MAAM,CAAC;;;OAIlC,iBACA;AAGF,SAAO,WACN,MAAM;;OAEF,iBAAiB;;MAGrB,KACA;;AAGF,QAAO"}
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_generateTypes = require("./generateTypes.cjs");
3
+ const require_detectTypesProvider = require("./detectTypesProvider.cjs");
4
+ const require_constants = require("./cli/constants.cjs");
5
+ exports.NON_EDITABLE_FILE_HEADER = require_constants.NON_EDITABLE_FILE_HEADER;
6
+ exports.detectTypesProvider = require_detectTypesProvider.detectTypesProvider;
7
+ exports.generateTypes = require_generateTypes.generateTypes;
@@ -1,5 +1,5 @@
1
- import { GenerateTypesConfig, TypesProvider, generateTypes } from "./generateTypes.mjs";
2
- import { DetectTypesProviderConfig, detectTypesProvider } from "./detectTypesProvider.mjs";
3
- import { Config } from "./cli/configSchema.mjs";
4
- import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.mjs";
1
+ import { GenerateTypesConfig, TypesProvider, generateTypes } from "./generateTypes.cjs";
2
+ import { DetectTypesProviderConfig, detectTypesProvider } from "./detectTypesProvider.cjs";
3
+ import { Config } from "./cli/configSchema.cjs";
4
+ import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.cjs";
5
5
  export { type Config, type DetectTypesProviderConfig, type GenerateTypesConfig, NON_EDITABLE_FILE_HEADER, type TypesProvider, detectTypesProvider, generateTypes };
@@ -0,0 +1,5 @@
1
+ import { GenerateTypesConfig, TypesProvider, generateTypes } from "./generateTypes.js";
2
+ import { DetectTypesProviderConfig, detectTypesProvider } from "./detectTypesProvider.js";
3
+ import { Config } from "./cli/configSchema.js";
4
+ import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.js";
5
+ export { type Config, type DetectTypesProviderConfig, type GenerateTypesConfig, NON_EDITABLE_FILE_HEADER, type TypesProvider, detectTypesProvider, generateTypes };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { generateTypes } from "./generateTypes.js";
2
+ import { detectTypesProvider } from "./detectTypesProvider.js";
3
+ import { NON_EDITABLE_FILE_HEADER } from "./cli/constants.js";
4
+ export { NON_EDITABLE_FILE_HEADER, detectTypesProvider, generateTypes };
@@ -0,0 +1,10 @@
1
+ const require_addTrailingNewLine = require("./addTrailingNewLine.cjs");
2
+ //#region src/lib/addBlankLine.ts
3
+ function addBlankLine(state, config) {
4
+ if ((!state || state.endsWith("\n\n")) && !config?.force) return state;
5
+ else return require_addTrailingNewLine.addTrailingNewLine(state) + "\n";
6
+ }
7
+ //#endregion
8
+ exports.addBlankLine = addBlankLine;
9
+
10
+ //# sourceMappingURL=addBlankLine.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addBlankLine.cjs","names":["addTrailingNewLine"],"sources":["../../src/lib/addBlankLine.ts"],"sourcesContent":["import { addTrailingNewLine } from \"./addTrailingNewLine\";\n\ntype AddBlankLineConfig = {\n\tforce?: boolean;\n};\n\nexport function addBlankLine(state: string, config?: AddBlankLineConfig): string {\n\tif ((!state || state.endsWith(\"\\n\\n\")) && !config?.force) {\n\t\treturn state;\n\t} else {\n\t\treturn addTrailingNewLine(state) + \"\\n\";\n\t}\n}\n"],"mappings":";;AAMA,SAAgB,aAAa,OAAe,QAAqC;AAChF,MAAK,CAAC,SAAS,MAAM,SAAS,OAAO,KAAK,CAAC,QAAQ,MAClD,QAAO;KAEP,QAAOA,2BAAAA,mBAAmB,MAAM,GAAG"}
@@ -1,4 +1,4 @@
1
- import { addTrailingNewLine } from "./addTrailingNewLine.mjs";
1
+ import { addTrailingNewLine } from "./addTrailingNewLine.js";
2
2
  //#region src/lib/addBlankLine.ts
3
3
  function addBlankLine(state, config) {
4
4
  if ((!state || state.endsWith("\n\n")) && !config?.force) return state;
@@ -7,4 +7,4 @@ function addBlankLine(state, config) {
7
7
  //#endregion
8
8
  export { addBlankLine };
9
9
 
10
- //# sourceMappingURL=addBlankLine.mjs.map
10
+ //# sourceMappingURL=addBlankLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addBlankLine.js","names":[],"sources":["../../src/lib/addBlankLine.ts"],"sourcesContent":["import { addTrailingNewLine } from \"./addTrailingNewLine\";\n\ntype AddBlankLineConfig = {\n\tforce?: boolean;\n};\n\nexport function addBlankLine(state: string, config?: AddBlankLineConfig): string {\n\tif ((!state || state.endsWith(\"\\n\\n\")) && !config?.force) {\n\t\treturn state;\n\t} else {\n\t\treturn addTrailingNewLine(state) + \"\\n\";\n\t}\n}\n"],"mappings":";;AAMA,SAAgB,aAAa,OAAe,QAAqC;AAChF,MAAK,CAAC,SAAS,MAAM,SAAS,OAAO,KAAK,CAAC,QAAQ,MAClD,QAAO;KAEP,QAAO,mBAAmB,MAAM,GAAG"}
@@ -0,0 +1,9 @@
1
+ const require_addTrailingNewLine = require("./addTrailingNewLine.cjs");
2
+ //#region src/lib/addLine.ts
3
+ function addLine(line, state) {
4
+ return require_addTrailingNewLine.addTrailingNewLine(state) + line;
5
+ }
6
+ //#endregion
7
+ exports.addLine = addLine;
8
+
9
+ //# sourceMappingURL=addLine.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addLine.cjs","names":["addTrailingNewLine"],"sources":["../../src/lib/addLine.ts"],"sourcesContent":["import { addTrailingNewLine } from \"./addTrailingNewLine\";\n\nexport function addLine(line: string, state: string): string {\n\treturn addTrailingNewLine(state) + line;\n}\n"],"mappings":";;AAEA,SAAgB,QAAQ,MAAc,OAAuB;AAC5D,QAAOA,2BAAAA,mBAAmB,MAAM,GAAG"}
@@ -1,4 +1,4 @@
1
- import { addTrailingNewLine } from "./addTrailingNewLine.mjs";
1
+ import { addTrailingNewLine } from "./addTrailingNewLine.js";
2
2
  //#region src/lib/addLine.ts
3
3
  function addLine(line, state) {
4
4
  return addTrailingNewLine(state) + line;
@@ -6,4 +6,4 @@ function addLine(line, state) {
6
6
  //#endregion
7
7
  export { addLine };
8
8
 
9
- //# sourceMappingURL=addLine.mjs.map
9
+ //# sourceMappingURL=addLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addLine.js","names":[],"sources":["../../src/lib/addLine.ts"],"sourcesContent":["import { addTrailingNewLine } from \"./addTrailingNewLine\";\n\nexport function addLine(line: string, state: string): string {\n\treturn addTrailingNewLine(state) + line;\n}\n"],"mappings":";;AAEA,SAAgB,QAAQ,MAAc,OAAuB;AAC5D,QAAO,mBAAmB,MAAM,GAAG"}
@@ -0,0 +1,9 @@
1
+ const require_addBlankLine = require("./addBlankLine.cjs");
2
+ //#region src/lib/addSection.ts
3
+ function addSection(section, state) {
4
+ return require_addBlankLine.addBlankLine(state) + section;
5
+ }
6
+ //#endregion
7
+ exports.addSection = addSection;
8
+
9
+ //# sourceMappingURL=addSection.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSection.cjs","names":["addBlankLine"],"sources":["../../src/lib/addSection.ts"],"sourcesContent":["import { addBlankLine } from \"./addBlankLine\";\n\nexport function addSection(section: string, state: string): string {\n\treturn addBlankLine(state) + section;\n}\n"],"mappings":";;AAEA,SAAgB,WAAW,SAAiB,OAAuB;AAClE,QAAOA,qBAAAA,aAAa,MAAM,GAAG"}
@@ -1,4 +1,4 @@
1
- import { addBlankLine } from "./addBlankLine.mjs";
1
+ import { addBlankLine } from "./addBlankLine.js";
2
2
  //#region src/lib/addSection.ts
3
3
  function addSection(section, state) {
4
4
  return addBlankLine(state) + section;
@@ -6,4 +6,4 @@ function addSection(section, state) {
6
6
  //#endregion
7
7
  export { addSection };
8
8
 
9
- //# sourceMappingURL=addSection.mjs.map
9
+ //# sourceMappingURL=addSection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSection.js","names":[],"sources":["../../src/lib/addSection.ts"],"sourcesContent":["import { addBlankLine } from \"./addBlankLine\";\n\nexport function addSection(section: string, state: string): string {\n\treturn addBlankLine(state) + section;\n}\n"],"mappings":";;AAEA,SAAgB,WAAW,SAAiB,OAAuB;AAClE,QAAO,aAAa,MAAM,GAAG"}
@@ -0,0 +1,9 @@
1
+ //#region src/lib/addTrailingNewLine.ts
2
+ function addTrailingNewLine(state, config) {
3
+ if ((!state || state.endsWith("\n")) && !config?.force) return state;
4
+ else return state + "\n";
5
+ }
6
+ //#endregion
7
+ exports.addTrailingNewLine = addTrailingNewLine;
8
+
9
+ //# sourceMappingURL=addTrailingNewLine.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"addTrailingNewLine.mjs","names":[],"sources":["../../src/lib/addTrailingNewLine.ts"],"sourcesContent":["type AddTrailingNewLineConfig = {\n\tforce?: boolean;\n};\n\nexport function addTrailingNewLine(state: string, config?: AddTrailingNewLineConfig): string {\n\tif ((!state || state.endsWith(\"\\n\")) && !config?.force) {\n\t\treturn state;\n\t} else {\n\t\treturn state + \"\\n\";\n\t}\n}\n"],"mappings":";AAIA,SAAgB,mBAAmB,OAAe,QAA2C;AAC5F,MAAK,CAAC,SAAS,MAAM,SAAS,KAAK,KAAK,CAAC,QAAQ,MAChD,QAAO;KAEP,QAAO,QAAQ"}
1
+ {"version":3,"file":"addTrailingNewLine.cjs","names":[],"sources":["../../src/lib/addTrailingNewLine.ts"],"sourcesContent":["type AddTrailingNewLineConfig = {\n\tforce?: boolean;\n};\n\nexport function addTrailingNewLine(state: string, config?: AddTrailingNewLineConfig): string {\n\tif ((!state || state.endsWith(\"\\n\")) && !config?.force) {\n\t\treturn state;\n\t} else {\n\t\treturn state + \"\\n\";\n\t}\n}\n"],"mappings":";AAIA,SAAgB,mBAAmB,OAAe,QAA2C;AAC5F,MAAK,CAAC,SAAS,MAAM,SAAS,KAAK,KAAK,CAAC,QAAQ,MAChD,QAAO;KAEP,QAAO,QAAQ"}
@@ -6,4 +6,4 @@ function addTrailingNewLine(state, config) {
6
6
  //#endregion
7
7
  export { addTrailingNewLine };
8
8
 
9
- //# sourceMappingURL=addTrailingNewLine.mjs.map
9
+ //# sourceMappingURL=addTrailingNewLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addTrailingNewLine.js","names":[],"sources":["../../src/lib/addTrailingNewLine.ts"],"sourcesContent":["type AddTrailingNewLineConfig = {\n\tforce?: boolean;\n};\n\nexport function addTrailingNewLine(state: string, config?: AddTrailingNewLineConfig): string {\n\tif ((!state || state.endsWith(\"\\n\")) && !config?.force) {\n\t\treturn state;\n\t} else {\n\t\treturn state + \"\\n\";\n\t}\n}\n"],"mappings":";AAIA,SAAgB,mBAAmB,OAAe,QAA2C;AAC5F,MAAK,CAAC,SAAS,MAAM,SAAS,KAAK,KAAK,CAAC,QAAQ,MAChD,QAAO;KAEP,QAAO,QAAQ"}
@@ -0,0 +1,51 @@
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_buildTypeName = require("./buildTypeName.cjs");
3
+ const require_getHumanReadableModelName = require("./getHumanReadableModelName.cjs");
4
+ const require_buildFieldProperties = require("./buildFieldProperties.cjs");
5
+ let common_tags = require("common-tags");
6
+ //#region src/lib/buildCustomTypeDataType.ts
7
+ function buildCustomTypeDataType(args) {
8
+ let code = "";
9
+ const auxiliaryTypes = [];
10
+ const contentTypeNames = [];
11
+ const name = require_buildTypeName.buildTypeName(args.model.id, "Document", "Data");
12
+ const humanReadableName = require_getHumanReadableModelName.getHumanReadableModelName({
13
+ name: args.model.id,
14
+ model: args.model
15
+ });
16
+ let fieldProperties = "";
17
+ for (const tabName in args.model.json) {
18
+ const { uid: _uid, ...fields } = args.model.json[tabName];
19
+ const tabFieldProperties = require_buildFieldProperties.buildFieldProperties({
20
+ fields,
21
+ fieldConfigs: args.fieldConfigs,
22
+ path: [{
23
+ name: args.model.id,
24
+ model: args.model
25
+ }],
26
+ tabName
27
+ });
28
+ fieldProperties += tabFieldProperties.code;
29
+ auxiliaryTypes.push(...tabFieldProperties.auxiliaryTypes);
30
+ contentTypeNames.push(...tabFieldProperties.contentTypeNames);
31
+ }
32
+ if (fieldProperties) code = common_tags.source`
33
+ /**
34
+ * Content for ${humanReadableName} documents
35
+ */
36
+ interface ${name} {
37
+ ${fieldProperties}
38
+ }
39
+ `;
40
+ else code = `interface ${name} {}`;
41
+ return {
42
+ name,
43
+ code,
44
+ auxiliaryTypes,
45
+ contentTypeNames
46
+ };
47
+ }
48
+ //#endregion
49
+ exports.buildCustomTypeDataType = buildCustomTypeDataType;
50
+
51
+ //# sourceMappingURL=buildCustomTypeDataType.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildCustomTypeDataType.cjs","names":["buildTypeName","getHumanReadableModelName","buildFieldProperties"],"sources":["../../src/lib/buildCustomTypeDataType.ts"],"sourcesContent":["import type { CustomTypeModel } from \"@prismicio/client\";\nimport { source } from \"common-tags\";\n\nimport { buildTypeName } from \"../lib/buildTypeName\";\nimport type { AuxiliaryType, FieldConfigs } from \"../types\";\nimport { buildFieldProperties } from \"./buildFieldProperties\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\n\ntype BuildCustomTypeDataTypeArgs = {\n\tmodel: CustomTypeModel;\n\tfieldConfigs: FieldConfigs;\n};\n\ntype BuildCustomTypeDataTypeReturnValue = {\n\tname: string;\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildCustomTypeDataType(\n\targs: BuildCustomTypeDataTypeArgs,\n): BuildCustomTypeDataTypeReturnValue {\n\tlet code = \"\";\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name = buildTypeName(args.model.id, \"Document\", \"Data\");\n\tconst humanReadableName = getHumanReadableModelName({\n\t\tname: args.model.id,\n\t\tmodel: args.model,\n\t});\n\n\tlet fieldProperties = \"\";\n\n\tfor (const tabName in args.model.json) {\n\t\tconst { uid: _uid, ...fields } = args.model.json[tabName];\n\n\t\tconst tabFieldProperties = buildFieldProperties({\n\t\t\tfields,\n\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\tpath: [\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],\n\t\t\ttabName,\n\t\t});\n\n\t\tfieldProperties += tabFieldProperties.code;\n\n\t\tauxiliaryTypes.push(...tabFieldProperties.auxiliaryTypes);\n\t\tcontentTypeNames.push(...tabFieldProperties.contentTypeNames);\n\t}\n\n\tif (fieldProperties) {\n\t\tcode = source`\n\t\t\t/**\n\t\t\t * Content for ${humanReadableName} documents\n\t\t\t */\n\t\t\tinterface ${name} {\n\t\t\t\t${fieldProperties}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcode = `interface ${name} {}`;\n\t}\n\n\treturn {\n\t\tname,\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,wBACf,MACqC;CACrC,IAAI,OAAO;CACX,MAAM,iBAAkC,EAAE;CAC1C,MAAM,mBAA6B,EAAE;CAErC,MAAM,OAAOA,sBAAAA,cAAc,KAAK,MAAM,IAAI,YAAY,OAAO;CAC7D,MAAM,oBAAoBC,kCAAAA,0BAA0B;EACnD,MAAM,KAAK,MAAM;EACjB,OAAO,KAAK;EACZ,CAAC;CAEF,IAAI,kBAAkB;AAEtB,MAAK,MAAM,WAAW,KAAK,MAAM,MAAM;EACtC,MAAM,EAAE,KAAK,MAAM,GAAG,WAAW,KAAK,MAAM,KAAK;EAEjD,MAAM,qBAAqBC,6BAAAA,qBAAqB;GAC/C;GACA,cAAc,KAAK;GACnB,MAAM,CACL;IACC,MAAM,KAAK,MAAM;IACjB,OAAO,KAAK;IACZ,CACD;GACD;GACA,CAAC;AAEF,qBAAmB,mBAAmB;AAEtC,iBAAe,KAAK,GAAG,mBAAmB,eAAe;AACzD,mBAAiB,KAAK,GAAG,mBAAmB,iBAAiB;;AAG9D,KAAI,gBACH,QAAO,YAAA,MAAM;;oBAEK,kBAAkB;;eAEvB,KAAK;MACd,gBAAgB;;;KAIpB,QAAO,aAAa,KAAK;AAG1B,QAAO;EACN;EACA;EACA;EACA;EACA"}
@@ -1,6 +1,6 @@
1
- import { buildTypeName } from "./buildTypeName.mjs";
2
- import { getHumanReadableModelName } from "./getHumanReadableModelName.mjs";
3
- import { buildFieldProperties } from "./buildFieldProperties.mjs";
1
+ import { buildTypeName } from "./buildTypeName.js";
2
+ import { getHumanReadableModelName } from "./getHumanReadableModelName.js";
3
+ import { buildFieldProperties } from "./buildFieldProperties.js";
4
4
  import { source } from "common-tags";
5
5
  //#region src/lib/buildCustomTypeDataType.ts
6
6
  function buildCustomTypeDataType(args) {
@@ -47,4 +47,4 @@ function buildCustomTypeDataType(args) {
47
47
  //#endregion
48
48
  export { buildCustomTypeDataType };
49
49
 
50
- //# sourceMappingURL=buildCustomTypeDataType.mjs.map
50
+ //# sourceMappingURL=buildCustomTypeDataType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildCustomTypeDataType.js","names":[],"sources":["../../src/lib/buildCustomTypeDataType.ts"],"sourcesContent":["import type { CustomTypeModel } from \"@prismicio/client\";\nimport { source } from \"common-tags\";\n\nimport { buildTypeName } from \"../lib/buildTypeName\";\nimport type { AuxiliaryType, FieldConfigs } from \"../types\";\nimport { buildFieldProperties } from \"./buildFieldProperties\";\nimport { getHumanReadableModelName } from \"./getHumanReadableModelName\";\n\ntype BuildCustomTypeDataTypeArgs = {\n\tmodel: CustomTypeModel;\n\tfieldConfigs: FieldConfigs;\n};\n\ntype BuildCustomTypeDataTypeReturnValue = {\n\tname: string;\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildCustomTypeDataType(\n\targs: BuildCustomTypeDataTypeArgs,\n): BuildCustomTypeDataTypeReturnValue {\n\tlet code = \"\";\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name = buildTypeName(args.model.id, \"Document\", \"Data\");\n\tconst humanReadableName = getHumanReadableModelName({\n\t\tname: args.model.id,\n\t\tmodel: args.model,\n\t});\n\n\tlet fieldProperties = \"\";\n\n\tfor (const tabName in args.model.json) {\n\t\tconst { uid: _uid, ...fields } = args.model.json[tabName];\n\n\t\tconst tabFieldProperties = buildFieldProperties({\n\t\t\tfields,\n\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\tpath: [\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],\n\t\t\ttabName,\n\t\t});\n\n\t\tfieldProperties += tabFieldProperties.code;\n\n\t\tauxiliaryTypes.push(...tabFieldProperties.auxiliaryTypes);\n\t\tcontentTypeNames.push(...tabFieldProperties.contentTypeNames);\n\t}\n\n\tif (fieldProperties) {\n\t\tcode = source`\n\t\t\t/**\n\t\t\t * Content for ${humanReadableName} documents\n\t\t\t */\n\t\t\tinterface ${name} {\n\t\t\t\t${fieldProperties}\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tcode = `interface ${name} {}`;\n\t}\n\n\treturn {\n\t\tname,\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n"],"mappings":";;;;;AAoBA,SAAgB,wBACf,MACqC;CACrC,IAAI,OAAO;CACX,MAAM,iBAAkC,EAAE;CAC1C,MAAM,mBAA6B,EAAE;CAErC,MAAM,OAAO,cAAc,KAAK,MAAM,IAAI,YAAY,OAAO;CAC7D,MAAM,oBAAoB,0BAA0B;EACnD,MAAM,KAAK,MAAM;EACjB,OAAO,KAAK;EACZ,CAAC;CAEF,IAAI,kBAAkB;AAEtB,MAAK,MAAM,WAAW,KAAK,MAAM,MAAM;EACtC,MAAM,EAAE,KAAK,MAAM,GAAG,WAAW,KAAK,MAAM,KAAK;EAEjD,MAAM,qBAAqB,qBAAqB;GAC/C;GACA,cAAc,KAAK;GACnB,MAAM,CACL;IACC,MAAM,KAAK,MAAM;IACjB,OAAO,KAAK;IACZ,CACD;GACD;GACA,CAAC;AAEF,qBAAmB,mBAAmB;AAEtC,iBAAe,KAAK,GAAG,mBAAmB,eAAe;AACzD,mBAAiB,KAAK,GAAG,mBAAmB,iBAAiB;;AAG9D,KAAI,gBACH,QAAO,MAAM;;oBAEK,kBAAkB;;eAEvB,KAAK;MACd,gBAAgB;;;KAIpB,QAAO,aAAa,KAAK;AAG1B,QAAO;EACN;EACA;EACA;EACA;EACA"}