prismic-ts-codegen 0.1.15 → 0.1.17

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 (565) hide show
  1. package/bin/prismic-ts-codegen.js +3 -0
  2. package/dist/_node_modules/@babel/code-frame/lib/index.cjs +144 -0
  3. package/dist/_node_modules/@babel/code-frame/lib/index.cjs.map +1 -0
  4. package/dist/_node_modules/@babel/code-frame/lib/index.js +143 -0
  5. package/dist/_node_modules/@babel/code-frame/lib/index.js.map +1 -0
  6. package/dist/_node_modules/@babel/helper-validator-identifier/lib/identifier.cjs +82 -0
  7. package/dist/_node_modules/@babel/helper-validator-identifier/lib/identifier.cjs.map +1 -0
  8. package/dist/_node_modules/@babel/helper-validator-identifier/lib/identifier.js +83 -0
  9. package/dist/_node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +1 -0
  10. package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.cjs +62 -0
  11. package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.cjs.map +1 -0
  12. package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.js +61 -0
  13. package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.js.map +1 -0
  14. package/dist/_node_modules/@babel/helper-validator-identifier/lib/keyword.cjs +35 -0
  15. package/dist/_node_modules/@babel/helper-validator-identifier/lib/keyword.cjs.map +1 -0
  16. package/dist/_node_modules/@babel/helper-validator-identifier/lib/keyword.js +36 -0
  17. package/dist/_node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +1 -0
  18. package/dist/_node_modules/@babel/highlight/lib/index.cjs +100 -0
  19. package/dist/_node_modules/@babel/highlight/lib/index.cjs.map +1 -0
  20. package/dist/_node_modules/@babel/highlight/lib/index.js +99 -0
  21. package/dist/_node_modules/@babel/highlight/lib/index.js.map +1 -0
  22. package/dist/_node_modules/ansi-styles/index.cjs +146 -0
  23. package/dist/_node_modules/ansi-styles/index.cjs.map +1 -0
  24. package/dist/_node_modules/ansi-styles/index.js +146 -0
  25. package/dist/_node_modules/ansi-styles/index.js.map +1 -0
  26. package/dist/_node_modules/arrify/index.cjs +10 -0
  27. package/dist/_node_modules/arrify/index.cjs.map +1 -0
  28. package/dist/_node_modules/arrify/index.js +10 -0
  29. package/dist/_node_modules/arrify/index.js.map +1 -0
  30. package/dist/_node_modules/camelcase/index.cjs +83 -0
  31. package/dist/_node_modules/camelcase/index.cjs.map +1 -0
  32. package/dist/_node_modules/camelcase/index.js +84 -0
  33. package/dist/_node_modules/camelcase/index.js.map +1 -0
  34. package/dist/_node_modules/camelcase-keys/index.cjs +55 -0
  35. package/dist/_node_modules/camelcase-keys/index.cjs.map +1 -0
  36. package/dist/_node_modules/camelcase-keys/index.js +56 -0
  37. package/dist/_node_modules/camelcase-keys/index.js.map +1 -0
  38. package/dist/_node_modules/chalk/index.cjs +172 -0
  39. package/dist/_node_modules/chalk/index.cjs.map +1 -0
  40. package/dist/_node_modules/chalk/index.js +172 -0
  41. package/dist/_node_modules/chalk/index.js.map +1 -0
  42. package/dist/_node_modules/chalk/templates.cjs +108 -0
  43. package/dist/_node_modules/chalk/templates.cjs.map +1 -0
  44. package/dist/_node_modules/chalk/templates.js +108 -0
  45. package/dist/_node_modules/chalk/templates.js.map +1 -0
  46. package/dist/_node_modules/color-convert/conversions.cjs +710 -0
  47. package/dist/_node_modules/color-convert/conversions.cjs.map +1 -0
  48. package/dist/_node_modules/color-convert/conversions.js +710 -0
  49. package/dist/_node_modules/color-convert/conversions.js.map +1 -0
  50. package/dist/_node_modules/color-convert/index.cjs +59 -0
  51. package/dist/_node_modules/color-convert/index.cjs.map +1 -0
  52. package/dist/_node_modules/color-convert/index.js +59 -0
  53. package/dist/_node_modules/color-convert/index.js.map +1 -0
  54. package/dist/_node_modules/color-convert/route.cjs +69 -0
  55. package/dist/_node_modules/color-convert/route.cjs.map +1 -0
  56. package/dist/_node_modules/color-convert/route.js +69 -0
  57. package/dist/_node_modules/color-convert/route.js.map +1 -0
  58. package/dist/_node_modules/color-name/index.cjs +154 -0
  59. package/dist/_node_modules/color-name/index.cjs.map +1 -0
  60. package/dist/_node_modules/color-name/index.js +154 -0
  61. package/dist/_node_modules/color-name/index.js.map +1 -0
  62. package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
  63. package/dist/_node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
  64. package/dist/_node_modules/data-uri-to-buffer/dist/index.js +41 -0
  65. package/dist/_node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
  66. package/dist/_node_modules/decamelize/index.cjs +38 -0
  67. package/dist/_node_modules/decamelize/index.cjs.map +1 -0
  68. package/dist/_node_modules/decamelize/index.js +39 -0
  69. package/dist/_node_modules/decamelize/index.js.map +1 -0
  70. package/dist/_node_modules/decamelize-keys/index.cjs +50 -0
  71. package/dist/_node_modules/decamelize-keys/index.cjs.map +1 -0
  72. package/dist/_node_modules/decamelize-keys/index.js +51 -0
  73. package/dist/_node_modules/decamelize-keys/index.js.map +1 -0
  74. package/dist/_node_modules/error-ex/index.cjs +109 -0
  75. package/dist/_node_modules/error-ex/index.cjs.map +1 -0
  76. package/dist/_node_modules/error-ex/index.js +109 -0
  77. package/dist/_node_modules/error-ex/index.js.map +1 -0
  78. package/dist/_node_modules/escape-string-regexp/index.cjs +11 -0
  79. package/dist/_node_modules/escape-string-regexp/index.cjs.map +1 -0
  80. package/dist/_node_modules/escape-string-regexp/index.js +11 -0
  81. package/dist/_node_modules/escape-string-regexp/index.js.map +1 -0
  82. package/dist/_node_modules/fetch-blob/file.cjs +61 -0
  83. package/dist/_node_modules/fetch-blob/file.cjs.map +1 -0
  84. package/dist/_node_modules/fetch-blob/file.js +61 -0
  85. package/dist/_node_modules/fetch-blob/file.js.map +1 -0
  86. package/dist/_node_modules/fetch-blob/index.cjs +223 -0
  87. package/dist/_node_modules/fetch-blob/index.cjs.map +1 -0
  88. package/dist/_node_modules/fetch-blob/index.js +223 -0
  89. package/dist/_node_modules/fetch-blob/index.js.map +1 -0
  90. package/dist/_node_modules/fetch-blob/streams.cjs +43 -0
  91. package/dist/_node_modules/fetch-blob/streams.cjs.map +1 -0
  92. package/dist/_node_modules/fetch-blob/streams.js +42 -0
  93. package/dist/_node_modules/fetch-blob/streams.js.map +1 -0
  94. package/dist/_node_modules/formdata-polyfill/esm.min.cjs +116 -0
  95. package/dist/_node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
  96. package/dist/_node_modules/formdata-polyfill/esm.min.js +116 -0
  97. package/dist/_node_modules/formdata-polyfill/esm.min.js.map +1 -0
  98. package/dist/_node_modules/function-bind/implementation.cjs +47 -0
  99. package/dist/_node_modules/function-bind/implementation.cjs.map +1 -0
  100. package/dist/_node_modules/function-bind/implementation.js +47 -0
  101. package/dist/_node_modules/function-bind/implementation.js.map +1 -0
  102. package/dist/_node_modules/function-bind/index.cjs +7 -0
  103. package/dist/_node_modules/function-bind/index.cjs.map +1 -0
  104. package/dist/_node_modules/function-bind/index.js +7 -0
  105. package/dist/_node_modules/function-bind/index.js.map +1 -0
  106. package/dist/_node_modules/hard-rejection/index.cjs +25 -0
  107. package/dist/_node_modules/hard-rejection/index.cjs.map +1 -0
  108. package/dist/_node_modules/hard-rejection/index.js +26 -0
  109. package/dist/_node_modules/hard-rejection/index.js.map +1 -0
  110. package/dist/_node_modules/has/src/index.cjs +7 -0
  111. package/dist/_node_modules/has/src/index.cjs.map +1 -0
  112. package/dist/_node_modules/has/src/index.js +7 -0
  113. package/dist/_node_modules/has/src/index.js.map +1 -0
  114. package/dist/_node_modules/hosted-git-info/lib/from-url.cjs +93 -0
  115. package/dist/_node_modules/hosted-git-info/lib/from-url.cjs.map +1 -0
  116. package/dist/_node_modules/hosted-git-info/lib/from-url.js +93 -0
  117. package/dist/_node_modules/hosted-git-info/lib/from-url.js.map +1 -0
  118. package/dist/_node_modules/hosted-git-info/lib/hosts.cjs +164 -0
  119. package/dist/_node_modules/hosted-git-info/lib/hosts.cjs.map +1 -0
  120. package/dist/_node_modules/hosted-git-info/lib/hosts.js +164 -0
  121. package/dist/_node_modules/hosted-git-info/lib/hosts.js.map +1 -0
  122. package/dist/_node_modules/hosted-git-info/lib/index.cjs +168 -0
  123. package/dist/_node_modules/hosted-git-info/lib/index.cjs.map +1 -0
  124. package/dist/_node_modules/hosted-git-info/lib/index.js +168 -0
  125. package/dist/_node_modules/hosted-git-info/lib/index.js.map +1 -0
  126. package/dist/_node_modules/hosted-git-info/lib/parse-url.cjs +51 -0
  127. package/dist/_node_modules/hosted-git-info/lib/parse-url.cjs.map +1 -0
  128. package/dist/_node_modules/hosted-git-info/lib/parse-url.js +51 -0
  129. package/dist/_node_modules/hosted-git-info/lib/parse-url.js.map +1 -0
  130. package/dist/_node_modules/indent-string/index.cjs +34 -0
  131. package/dist/_node_modules/indent-string/index.cjs.map +1 -0
  132. package/dist/_node_modules/indent-string/index.js +35 -0
  133. package/dist/_node_modules/indent-string/index.js.map +1 -0
  134. package/dist/_node_modules/is-arrayish/index.cjs +10 -0
  135. package/dist/_node_modules/is-arrayish/index.cjs.map +1 -0
  136. package/dist/_node_modules/is-arrayish/index.js +10 -0
  137. package/dist/_node_modules/is-arrayish/index.js.map +1 -0
  138. package/dist/_node_modules/is-core-module/core.json.cjs +496 -0
  139. package/dist/_node_modules/is-core-module/core.json.cjs.map +1 -0
  140. package/dist/_node_modules/is-core-module/core.json.js +496 -0
  141. package/dist/_node_modules/is-core-module/core.json.js.map +1 -0
  142. package/dist/_node_modules/is-core-module/index.cjs +62 -0
  143. package/dist/_node_modules/is-core-module/index.cjs.map +1 -0
  144. package/dist/_node_modules/is-core-module/index.js +62 -0
  145. package/dist/_node_modules/is-core-module/index.js.map +1 -0
  146. package/dist/_node_modules/is-plain-obj/index.cjs +9 -0
  147. package/dist/_node_modules/is-plain-obj/index.cjs.map +1 -0
  148. package/dist/_node_modules/is-plain-obj/index.js +9 -0
  149. package/dist/_node_modules/is-plain-obj/index.js.map +1 -0
  150. package/dist/_node_modules/js-tokens/index.cjs +27 -0
  151. package/dist/_node_modules/js-tokens/index.cjs.map +1 -0
  152. package/dist/_node_modules/js-tokens/index.js +26 -0
  153. package/dist/_node_modules/js-tokens/index.js.map +1 -0
  154. package/dist/_node_modules/json-parse-even-better-errors/index.cjs +90 -0
  155. package/dist/_node_modules/json-parse-even-better-errors/index.cjs.map +1 -0
  156. package/dist/_node_modules/json-parse-even-better-errors/index.js +90 -0
  157. package/dist/_node_modules/json-parse-even-better-errors/index.js.map +1 -0
  158. package/dist/_node_modules/kind-of/index.cjs +129 -0
  159. package/dist/_node_modules/kind-of/index.cjs.map +1 -0
  160. package/dist/_node_modules/kind-of/index.js +129 -0
  161. package/dist/_node_modules/kind-of/index.js.map +1 -0
  162. package/dist/_node_modules/lines-and-columns/build/index.cjs +67 -0
  163. package/dist/_node_modules/lines-and-columns/build/index.cjs.map +1 -0
  164. package/dist/_node_modules/lines-and-columns/build/index.js +66 -0
  165. package/dist/_node_modules/lines-and-columns/build/index.js.map +1 -0
  166. package/dist/_node_modules/lru-cache/index.cjs +1015 -0
  167. package/dist/_node_modules/lru-cache/index.cjs.map +1 -0
  168. package/dist/_node_modules/lru-cache/index.js +1015 -0
  169. package/dist/_node_modules/lru-cache/index.js.map +1 -0
  170. package/dist/_node_modules/map-obj/index.cjs +49 -0
  171. package/dist/_node_modules/map-obj/index.cjs.map +1 -0
  172. package/dist/_node_modules/map-obj/index.js +50 -0
  173. package/dist/_node_modules/map-obj/index.js.map +1 -0
  174. package/dist/_node_modules/meow/source/index.cjs +88 -0
  175. package/dist/_node_modules/meow/source/index.cjs.map +1 -0
  176. package/dist/_node_modules/meow/source/index.js +89 -0
  177. package/dist/_node_modules/meow/source/index.js.map +1 -0
  178. package/dist/_node_modules/meow/source/options.cjs +83 -0
  179. package/dist/_node_modules/meow/source/options.cjs.map +1 -0
  180. package/dist/_node_modules/meow/source/options.js +83 -0
  181. package/dist/_node_modules/meow/source/options.js.map +1 -0
  182. package/dist/_node_modules/meow/source/parser.cjs +61 -0
  183. package/dist/_node_modules/meow/source/parser.cjs.map +1 -0
  184. package/dist/_node_modules/meow/source/parser.js +61 -0
  185. package/dist/_node_modules/meow/source/parser.js.map +1 -0
  186. package/dist/_node_modules/meow/source/utils.cjs +8 -0
  187. package/dist/_node_modules/meow/source/utils.cjs.map +1 -0
  188. package/dist/_node_modules/meow/source/utils.js +8 -0
  189. package/dist/_node_modules/meow/source/utils.js.map +1 -0
  190. package/dist/_node_modules/meow/source/validate.cjs +102 -0
  191. package/dist/_node_modules/meow/source/validate.cjs.map +1 -0
  192. package/dist/_node_modules/meow/source/validate.js +102 -0
  193. package/dist/_node_modules/meow/source/validate.js.map +1 -0
  194. package/dist/_node_modules/min-indent/index.cjs +12 -0
  195. package/dist/_node_modules/min-indent/index.cjs.map +1 -0
  196. package/dist/_node_modules/min-indent/index.js +13 -0
  197. package/dist/_node_modules/min-indent/index.js.map +1 -0
  198. package/dist/_node_modules/minimist-options/index.cjs +94 -0
  199. package/dist/_node_modules/minimist-options/index.cjs.map +1 -0
  200. package/dist/_node_modules/minimist-options/index.js +95 -0
  201. package/dist/_node_modules/minimist-options/index.js.map +1 -0
  202. package/dist/_node_modules/node-domexception/index.cjs +11 -0
  203. package/dist/_node_modules/node-domexception/index.cjs.map +1 -0
  204. package/dist/_node_modules/node-domexception/index.js +10 -0
  205. package/dist/_node_modules/node-domexception/index.js.map +1 -0
  206. package/dist/_node_modules/node-fetch/src/body.cjs +262 -0
  207. package/dist/_node_modules/node-fetch/src/body.cjs.map +1 -0
  208. package/dist/_node_modules/node-fetch/src/body.js +262 -0
  209. package/dist/_node_modules/node-fetch/src/body.js.map +1 -0
  210. package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
  211. package/dist/_node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
  212. package/dist/_node_modules/node-fetch/src/errors/abort-error.js +10 -0
  213. package/dist/_node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
  214. package/dist/_node_modules/node-fetch/src/errors/base.cjs +17 -0
  215. package/dist/_node_modules/node-fetch/src/errors/base.cjs.map +1 -0
  216. package/dist/_node_modules/node-fetch/src/errors/base.js +17 -0
  217. package/dist/_node_modules/node-fetch/src/errors/base.js.map +1 -0
  218. package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs +19 -0
  219. package/dist/_node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
  220. package/dist/_node_modules/node-fetch/src/errors/fetch-error.js +19 -0
  221. package/dist/_node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
  222. package/dist/_node_modules/node-fetch/src/headers.cjs +190 -0
  223. package/dist/_node_modules/node-fetch/src/headers.cjs.map +1 -0
  224. package/dist/_node_modules/node-fetch/src/headers.js +190 -0
  225. package/dist/_node_modules/node-fetch/src/headers.js.map +1 -0
  226. package/dist/_node_modules/node-fetch/src/index.cjs +292 -0
  227. package/dist/_node_modules/node-fetch/src/index.cjs.map +1 -0
  228. package/dist/_node_modules/node-fetch/src/index.js +292 -0
  229. package/dist/_node_modules/node-fetch/src/index.js.map +1 -0
  230. package/dist/_node_modules/node-fetch/src/request.cjs +206 -0
  231. package/dist/_node_modules/node-fetch/src/request.cjs.map +1 -0
  232. package/dist/_node_modules/node-fetch/src/request.js +206 -0
  233. package/dist/_node_modules/node-fetch/src/request.js.map +1 -0
  234. package/dist/_node_modules/node-fetch/src/response.cjs +122 -0
  235. package/dist/_node_modules/node-fetch/src/response.cjs.map +1 -0
  236. package/dist/_node_modules/node-fetch/src/response.js +123 -0
  237. package/dist/_node_modules/node-fetch/src/response.js.map +1 -0
  238. package/dist/_node_modules/node-fetch/src/utils/get-search.cjs +12 -0
  239. package/dist/_node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
  240. package/dist/_node_modules/node-fetch/src/utils/get-search.js +12 -0
  241. package/dist/_node_modules/node-fetch/src/utils/get-search.js.map +1 -0
  242. package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
  243. package/dist/_node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
  244. package/dist/_node_modules/node-fetch/src/utils/is-redirect.js +8 -0
  245. package/dist/_node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
  246. package/dist/_node_modules/node-fetch/src/utils/is.cjs +28 -0
  247. package/dist/_node_modules/node-fetch/src/utils/is.cjs.map +1 -0
  248. package/dist/_node_modules/node-fetch/src/utils/is.js +28 -0
  249. package/dist/_node_modules/node-fetch/src/utils/is.js.map +1 -0
  250. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs +356 -0
  251. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
  252. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js +356 -0
  253. package/dist/_node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
  254. package/dist/_node_modules/node-fetch/src/utils/referrer.cjs +149 -0
  255. package/dist/_node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
  256. package/dist/_node_modules/node-fetch/src/utils/referrer.js +149 -0
  257. package/dist/_node_modules/node-fetch/src/utils/referrer.js.map +1 -0
  258. package/dist/_node_modules/normalize-package-data/lib/extract_description.cjs +24 -0
  259. package/dist/_node_modules/normalize-package-data/lib/extract_description.cjs.map +1 -0
  260. package/dist/_node_modules/normalize-package-data/lib/extract_description.js +24 -0
  261. package/dist/_node_modules/normalize-package-data/lib/extract_description.js.map +1 -0
  262. package/dist/_node_modules/normalize-package-data/lib/fixer.cjs +438 -0
  263. package/dist/_node_modules/normalize-package-data/lib/fixer.cjs.map +1 -0
  264. package/dist/_node_modules/normalize-package-data/lib/fixer.js +438 -0
  265. package/dist/_node_modules/normalize-package-data/lib/fixer.js.map +1 -0
  266. package/dist/_node_modules/normalize-package-data/lib/make_warning.cjs +26 -0
  267. package/dist/_node_modules/normalize-package-data/lib/make_warning.cjs.map +1 -0
  268. package/dist/_node_modules/normalize-package-data/lib/make_warning.js +26 -0
  269. package/dist/_node_modules/normalize-package-data/lib/make_warning.js.map +1 -0
  270. package/dist/_node_modules/normalize-package-data/lib/normalize.cjs +58 -0
  271. package/dist/_node_modules/normalize-package-data/lib/normalize.cjs.map +1 -0
  272. package/dist/_node_modules/normalize-package-data/lib/normalize.js +59 -0
  273. package/dist/_node_modules/normalize-package-data/lib/normalize.js.map +1 -0
  274. package/dist/_node_modules/normalize-package-data/lib/typos.json.cjs +41 -0
  275. package/dist/_node_modules/normalize-package-data/lib/typos.json.cjs.map +1 -0
  276. package/dist/_node_modules/normalize-package-data/lib/typos.json.js +41 -0
  277. package/dist/_node_modules/normalize-package-data/lib/typos.json.js.map +1 -0
  278. package/dist/_node_modules/normalize-package-data/lib/warning_messages.json.cjs +90 -0
  279. package/dist/_node_modules/normalize-package-data/lib/warning_messages.json.cjs.map +1 -0
  280. package/dist/_node_modules/normalize-package-data/lib/warning_messages.json.js +90 -0
  281. package/dist/_node_modules/normalize-package-data/lib/warning_messages.json.js.map +1 -0
  282. package/dist/_node_modules/parse-json/index.cjs +54 -0
  283. package/dist/_node_modules/parse-json/index.cjs.map +1 -0
  284. package/dist/_node_modules/parse-json/index.js +55 -0
  285. package/dist/_node_modules/parse-json/index.js.map +1 -0
  286. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host-info.cjs +159 -0
  287. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host-info.cjs.map +1 -0
  288. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host-info.js +159 -0
  289. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host-info.js.map +1 -0
  290. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host.cjs +88 -0
  291. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host.cjs.map +1 -0
  292. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host.js +88 -0
  293. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/git-host.js.map +1 -0
  294. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/index.cjs +180 -0
  295. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/index.cjs.map +1 -0
  296. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/index.js +180 -0
  297. package/dist/_node_modules/read-pkg/_node_modules/hosted-git-info/index.js.map +1 -0
  298. package/dist/_node_modules/read-pkg/_node_modules/lru-cache/index.cjs +268 -0
  299. package/dist/_node_modules/read-pkg/_node_modules/lru-cache/index.cjs.map +1 -0
  300. package/dist/_node_modules/read-pkg/_node_modules/lru-cache/index.js +268 -0
  301. package/dist/_node_modules/read-pkg/_node_modules/lru-cache/index.js.map +1 -0
  302. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/extract_description.cjs +20 -0
  303. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/extract_description.cjs.map +1 -0
  304. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/extract_description.js +20 -0
  305. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/extract_description.js.map +1 -0
  306. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.cjs +438 -0
  307. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.cjs.map +1 -0
  308. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.js +438 -0
  309. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.js.map +1 -0
  310. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/make_warning.cjs +26 -0
  311. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/make_warning.cjs.map +1 -0
  312. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/make_warning.js +26 -0
  313. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/make_warning.js.map +1 -0
  314. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/normalize.cjs +58 -0
  315. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/normalize.cjs.map +1 -0
  316. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/normalize.js +59 -0
  317. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/normalize.js.map +1 -0
  318. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/typos.json.cjs +41 -0
  319. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/typos.json.cjs.map +1 -0
  320. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/typos.json.js +41 -0
  321. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/typos.json.js.map +1 -0
  322. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/warning_messages.json.cjs +90 -0
  323. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/warning_messages.json.cjs.map +1 -0
  324. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/warning_messages.json.js +90 -0
  325. package/dist/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/warning_messages.json.js.map +1 -0
  326. package/dist/_node_modules/read-pkg/index.cjs +20 -0
  327. package/dist/_node_modules/read-pkg/index.cjs.map +1 -0
  328. package/dist/_node_modules/read-pkg/index.js +20 -0
  329. package/dist/_node_modules/read-pkg/index.js.map +1 -0
  330. package/dist/_node_modules/read-pkg-up/_node_modules/find-up/index.cjs +48 -0
  331. package/dist/_node_modules/read-pkg-up/_node_modules/find-up/index.cjs.map +1 -0
  332. package/dist/_node_modules/read-pkg-up/_node_modules/find-up/index.js +48 -0
  333. package/dist/_node_modules/read-pkg-up/_node_modules/find-up/index.js.map +1 -0
  334. package/dist/_node_modules/read-pkg-up/_node_modules/locate-path/index.cjs +43 -0
  335. package/dist/_node_modules/read-pkg-up/_node_modules/locate-path/index.cjs.map +1 -0
  336. package/dist/_node_modules/read-pkg-up/_node_modules/locate-path/index.js +43 -0
  337. package/dist/_node_modules/read-pkg-up/_node_modules/locate-path/index.js.map +1 -0
  338. package/dist/_node_modules/read-pkg-up/index.cjs +17 -0
  339. package/dist/_node_modules/read-pkg-up/index.cjs.map +1 -0
  340. package/dist/_node_modules/read-pkg-up/index.js +17 -0
  341. package/dist/_node_modules/read-pkg-up/index.js.map +1 -0
  342. package/dist/_node_modules/redent/index.cjs +8 -0
  343. package/dist/_node_modules/redent/index.cjs.map +1 -0
  344. package/dist/_node_modules/redent/index.js +9 -0
  345. package/dist/_node_modules/redent/index.js.map +1 -0
  346. package/dist/_node_modules/semver/classes/semver.cjs +245 -0
  347. package/dist/_node_modules/semver/classes/semver.cjs.map +1 -0
  348. package/dist/_node_modules/semver/classes/semver.js +245 -0
  349. package/dist/_node_modules/semver/classes/semver.js.map +1 -0
  350. package/dist/_node_modules/semver/functions/clean.cjs +11 -0
  351. package/dist/_node_modules/semver/functions/clean.cjs.map +1 -0
  352. package/dist/_node_modules/semver/functions/clean.js +11 -0
  353. package/dist/_node_modules/semver/functions/clean.js.map +1 -0
  354. package/dist/_node_modules/semver/functions/parse.cjs +20 -0
  355. package/dist/_node_modules/semver/functions/parse.cjs.map +1 -0
  356. package/dist/_node_modules/semver/functions/parse.js +20 -0
  357. package/dist/_node_modules/semver/functions/parse.js.map +1 -0
  358. package/dist/_node_modules/semver/functions/valid.cjs +11 -0
  359. package/dist/_node_modules/semver/functions/valid.cjs.map +1 -0
  360. package/dist/_node_modules/semver/functions/valid.js +11 -0
  361. package/dist/_node_modules/semver/functions/valid.js.map +1 -0
  362. package/dist/_node_modules/semver/internal/constants.cjs +29 -0
  363. package/dist/_node_modules/semver/internal/constants.cjs.map +1 -0
  364. package/dist/_node_modules/semver/internal/constants.js +29 -0
  365. package/dist/_node_modules/semver/internal/constants.js.map +1 -0
  366. package/dist/_node_modules/semver/internal/debug.cjs +7 -0
  367. package/dist/_node_modules/semver/internal/debug.cjs.map +1 -0
  368. package/dist/_node_modules/semver/internal/debug.js +7 -0
  369. package/dist/_node_modules/semver/internal/debug.js.map +1 -0
  370. package/dist/_node_modules/semver/internal/identifiers.cjs +19 -0
  371. package/dist/_node_modules/semver/internal/identifiers.cjs.map +1 -0
  372. package/dist/_node_modules/semver/internal/identifiers.js +19 -0
  373. package/dist/_node_modules/semver/internal/identifiers.js.map +1 -0
  374. package/dist/_node_modules/semver/internal/parse-options.cjs +16 -0
  375. package/dist/_node_modules/semver/internal/parse-options.cjs.map +1 -0
  376. package/dist/_node_modules/semver/internal/parse-options.js +16 -0
  377. package/dist/_node_modules/semver/internal/parse-options.js.map +1 -0
  378. package/dist/_node_modules/semver/internal/re.cjs +82 -0
  379. package/dist/_node_modules/semver/internal/re.cjs.map +1 -0
  380. package/dist/_node_modules/semver/internal/re.js +82 -0
  381. package/dist/_node_modules/semver/internal/re.js.map +1 -0
  382. package/dist/_node_modules/spdx-correct/index.cjs +334 -0
  383. package/dist/_node_modules/spdx-correct/index.cjs.map +1 -0
  384. package/dist/_node_modules/spdx-correct/index.js +334 -0
  385. package/dist/_node_modules/spdx-correct/index.js.map +1 -0
  386. package/dist/_node_modules/spdx-exceptions/index.json.cjs +43 -0
  387. package/dist/_node_modules/spdx-exceptions/index.json.cjs.map +1 -0
  388. package/dist/_node_modules/spdx-exceptions/index.json.js +44 -0
  389. package/dist/_node_modules/spdx-exceptions/index.json.js.map +1 -0
  390. package/dist/_node_modules/spdx-expression-parse/index.cjs +11 -0
  391. package/dist/_node_modules/spdx-expression-parse/index.cjs.map +1 -0
  392. package/dist/_node_modules/spdx-expression-parse/index.js +11 -0
  393. package/dist/_node_modules/spdx-expression-parse/index.js.map +1 -0
  394. package/dist/_node_modules/spdx-expression-parse/parse.cjs +111 -0
  395. package/dist/_node_modules/spdx-expression-parse/parse.cjs.map +1 -0
  396. package/dist/_node_modules/spdx-expression-parse/parse.js +111 -0
  397. package/dist/_node_modules/spdx-expression-parse/parse.js.map +1 -0
  398. package/dist/_node_modules/spdx-expression-parse/scan.cjs +104 -0
  399. package/dist/_node_modules/spdx-expression-parse/scan.cjs.map +1 -0
  400. package/dist/_node_modules/spdx-expression-parse/scan.js +104 -0
  401. package/dist/_node_modules/spdx-expression-parse/scan.js.map +1 -0
  402. package/dist/_node_modules/spdx-license-ids/deprecated.json.cjs +30 -0
  403. package/dist/_node_modules/spdx-license-ids/deprecated.json.cjs.map +1 -0
  404. package/dist/_node_modules/spdx-license-ids/deprecated.json.js +31 -0
  405. package/dist/_node_modules/spdx-license-ids/deprecated.json.js.map +1 -0
  406. package/dist/_node_modules/spdx-license-ids/index.json.cjs +510 -0
  407. package/dist/_node_modules/spdx-license-ids/index.json.cjs.map +1 -0
  408. package/dist/_node_modules/spdx-license-ids/index.json.js +511 -0
  409. package/dist/_node_modules/spdx-license-ids/index.json.js.map +1 -0
  410. package/dist/_node_modules/strip-indent/index.cjs +12 -0
  411. package/dist/_node_modules/strip-indent/index.cjs.map +1 -0
  412. package/dist/_node_modules/strip-indent/index.js +13 -0
  413. package/dist/_node_modules/strip-indent/index.js.map +1 -0
  414. package/dist/_node_modules/supports-color/browser.cjs +8 -0
  415. package/dist/_node_modules/supports-color/browser.cjs.map +1 -0
  416. package/dist/_node_modules/supports-color/browser.js +8 -0
  417. package/dist/_node_modules/supports-color/browser.js.map +1 -0
  418. package/dist/_node_modules/trim-newlines/index.cjs +15 -0
  419. package/dist/_node_modules/trim-newlines/index.cjs.map +1 -0
  420. package/dist/_node_modules/trim-newlines/index.js +15 -0
  421. package/dist/_node_modules/trim-newlines/index.js.map +1 -0
  422. package/dist/_node_modules/validate-npm-package-license/index.cjs +71 -0
  423. package/dist/_node_modules/validate-npm-package-license/index.cjs.map +1 -0
  424. package/dist/_node_modules/validate-npm-package-license/index.js +71 -0
  425. package/dist/_node_modules/validate-npm-package-license/index.js.map +1 -0
  426. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3822 -0
  427. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
  428. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3822 -0
  429. package/dist/_node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
  430. package/dist/_node_modules/yallist/iterator.cjs +19 -0
  431. package/dist/_node_modules/yallist/iterator.cjs.map +1 -0
  432. package/dist/_node_modules/yallist/iterator.js +19 -0
  433. package/dist/_node_modules/yallist/iterator.js.map +1 -0
  434. package/dist/_node_modules/yallist/yallist.cjs +367 -0
  435. package/dist/_node_modules/yallist/yallist.cjs.map +1 -0
  436. package/dist/_node_modules/yallist/yallist.js +367 -0
  437. package/dist/_node_modules/yallist/yallist.js.map +1 -0
  438. package/dist/_node_modules/yargs-parser/build/lib/index.cjs +56 -0
  439. package/dist/_node_modules/yargs-parser/build/lib/index.cjs.map +1 -0
  440. package/dist/_node_modules/yargs-parser/build/lib/index.js +57 -0
  441. package/dist/_node_modules/yargs-parser/build/lib/index.js.map +1 -0
  442. package/dist/_node_modules/yargs-parser/build/lib/string-utils.cjs +63 -0
  443. package/dist/_node_modules/yargs-parser/build/lib/string-utils.cjs.map +1 -0
  444. package/dist/_node_modules/yargs-parser/build/lib/string-utils.js +63 -0
  445. package/dist/_node_modules/yargs-parser/build/lib/string-utils.js.map +1 -0
  446. package/dist/_node_modules/yargs-parser/build/lib/tokenize-arg-string.cjs +39 -0
  447. package/dist/_node_modules/yargs-parser/build/lib/tokenize-arg-string.cjs.map +1 -0
  448. package/dist/_node_modules/yargs-parser/build/lib/tokenize-arg-string.js +39 -0
  449. package/dist/_node_modules/yargs-parser/build/lib/tokenize-arg-string.js.map +1 -0
  450. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser-types.cjs +15 -0
  451. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser-types.cjs.map +1 -0
  452. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser-types.js +16 -0
  453. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser-types.js.map +1 -0
  454. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser.cjs +847 -0
  455. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser.cjs.map +1 -0
  456. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser.js +847 -0
  457. package/dist/_node_modules/yargs-parser/build/lib/yargs-parser.js.map +1 -0
  458. package/dist/_virtual/_commonjsHelpers.cjs +9 -0
  459. package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
  460. package/dist/_virtual/_commonjsHelpers.js +9 -0
  461. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  462. package/dist/_virtual/conversions.cjs +5 -0
  463. package/dist/_virtual/conversions.cjs.map +1 -0
  464. package/dist/_virtual/conversions.js +5 -0
  465. package/dist/_virtual/conversions.js.map +1 -0
  466. package/dist/_virtual/identifier.cjs +5 -0
  467. package/dist/_virtual/identifier.cjs.map +1 -0
  468. package/dist/_virtual/identifier.js +5 -0
  469. package/dist/_virtual/identifier.js.map +1 -0
  470. package/dist/_virtual/index.cjs +5 -0
  471. package/dist/_virtual/index.cjs.map +1 -0
  472. package/dist/_virtual/index.js +5 -0
  473. package/dist/_virtual/index.js.map +1 -0
  474. package/dist/_virtual/index10.cjs +5 -0
  475. package/dist/_virtual/index10.cjs.map +1 -0
  476. package/dist/_virtual/index10.js +5 -0
  477. package/dist/_virtual/index10.js.map +1 -0
  478. package/dist/_virtual/index11.cjs +5 -0
  479. package/dist/_virtual/index11.cjs.map +1 -0
  480. package/dist/_virtual/index11.js +5 -0
  481. package/dist/_virtual/index11.js.map +1 -0
  482. package/dist/_virtual/index2.cjs +5 -0
  483. package/dist/_virtual/index2.cjs.map +1 -0
  484. package/dist/_virtual/index2.js +5 -0
  485. package/dist/_virtual/index2.js.map +1 -0
  486. package/dist/_virtual/index3.cjs +5 -0
  487. package/dist/_virtual/index3.cjs.map +1 -0
  488. package/dist/_virtual/index3.js +5 -0
  489. package/dist/_virtual/index3.js.map +1 -0
  490. package/dist/_virtual/index4.cjs +5 -0
  491. package/dist/_virtual/index4.cjs.map +1 -0
  492. package/dist/_virtual/index4.js +5 -0
  493. package/dist/_virtual/index4.js.map +1 -0
  494. package/dist/_virtual/index5.cjs +5 -0
  495. package/dist/_virtual/index5.cjs.map +1 -0
  496. package/dist/_virtual/index5.js +5 -0
  497. package/dist/_virtual/index5.js.map +1 -0
  498. package/dist/_virtual/index6.cjs +5 -0
  499. package/dist/_virtual/index6.cjs.map +1 -0
  500. package/dist/_virtual/index6.js +5 -0
  501. package/dist/_virtual/index6.js.map +1 -0
  502. package/dist/_virtual/index7.cjs +5 -0
  503. package/dist/_virtual/index7.cjs.map +1 -0
  504. package/dist/_virtual/index7.js +5 -0
  505. package/dist/_virtual/index7.js.map +1 -0
  506. package/dist/_virtual/index8.cjs +5 -0
  507. package/dist/_virtual/index8.cjs.map +1 -0
  508. package/dist/_virtual/index8.js +5 -0
  509. package/dist/_virtual/index8.js.map +1 -0
  510. package/dist/_virtual/index9.cjs +5 -0
  511. package/dist/_virtual/index9.cjs.map +1 -0
  512. package/dist/_virtual/index9.js +5 -0
  513. package/dist/_virtual/index9.js.map +1 -0
  514. package/dist/_virtual/keyword.cjs +5 -0
  515. package/dist/_virtual/keyword.cjs.map +1 -0
  516. package/dist/_virtual/keyword.js +5 -0
  517. package/dist/_virtual/keyword.js.map +1 -0
  518. package/dist/_virtual/ponyfill.es2018.cjs +5 -0
  519. package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
  520. package/dist/_virtual/ponyfill.es2018.js +5 -0
  521. package/dist/_virtual/ponyfill.es2018.js.map +1 -0
  522. package/dist/_virtual/re.cjs +5 -0
  523. package/dist/_virtual/re.cjs.map +1 -0
  524. package/dist/_virtual/re.js +5 -0
  525. package/dist/_virtual/re.js.map +1 -0
  526. package/dist/cli/loadLocaleIDs.cjs +2 -2
  527. package/dist/cli/loadLocaleIDs.cjs.map +1 -1
  528. package/dist/cli/loadLocaleIDs.js +1 -1
  529. package/dist/cli/loadModels.cjs +2 -2
  530. package/dist/cli/loadModels.cjs.map +1 -1
  531. package/dist/cli/loadModels.js +1 -1
  532. package/dist/cli.cjs +2 -2
  533. package/dist/cli.cjs.map +1 -1
  534. package/dist/cli.js +1 -1
  535. package/dist/generateTypes.cjs +2 -3
  536. package/dist/generateTypes.cjs.map +1 -1
  537. package/dist/generateTypes.js +2 -3
  538. package/dist/generateTypes.js.map +1 -1
  539. package/dist/lib/buildCustomTypeDataType.cjs +4 -1
  540. package/dist/lib/buildCustomTypeDataType.cjs.map +1 -1
  541. package/dist/lib/buildCustomTypeDataType.d.ts +1 -0
  542. package/dist/lib/buildCustomTypeDataType.js +4 -1
  543. package/dist/lib/buildCustomTypeDataType.js.map +1 -1
  544. package/dist/lib/buildCustomTypeType.cjs +5 -2
  545. package/dist/lib/buildCustomTypeType.cjs.map +1 -1
  546. package/dist/lib/buildCustomTypeType.d.ts +1 -1
  547. package/dist/lib/buildCustomTypeType.js +5 -2
  548. package/dist/lib/buildCustomTypeType.js.map +1 -1
  549. package/dist/lib/buildFieldProperties.cjs +10 -2
  550. package/dist/lib/buildFieldProperties.cjs.map +1 -1
  551. package/dist/lib/buildFieldProperties.d.ts +1 -0
  552. package/dist/lib/buildFieldProperties.js +10 -2
  553. package/dist/lib/buildFieldProperties.js.map +1 -1
  554. package/dist/lib/buildSharedSliceType.cjs +9 -2
  555. package/dist/lib/buildSharedSliceType.cjs.map +1 -1
  556. package/dist/lib/buildSharedSliceType.d.ts +1 -1
  557. package/dist/lib/buildSharedSliceType.js +9 -2
  558. package/dist/lib/buildSharedSliceType.js.map +1 -1
  559. package/package.json +2 -2
  560. package/src/generateTypes.ts +2 -3
  561. package/src/lib/buildCustomTypeDataType.ts +4 -0
  562. package/src/lib/buildCustomTypeType.ts +5 -2
  563. package/src/lib/buildFieldProperties.ts +10 -0
  564. package/src/lib/buildSharedSliceType.ts +12 -2
  565. package/bin/prismic-ts-codegen.mjs +0 -3
@@ -14,6 +14,7 @@ function buildFieldProperty(args) {
14
14
  tabName: args.tabName
15
15
  });
16
16
  const auxiliaryTypes = [];
17
+ const contentTypeNames = [];
17
18
  const name = args.name.includes("-") || args.name.includes(":") || /^[0-9]/.test(args.name) ? `"${args.name}"` : args.name;
18
19
  switch (args.field.type) {
19
20
  case "UID": {
@@ -194,6 +195,7 @@ function buildFieldProperty(args) {
194
195
  name: primaryInterfaceName,
195
196
  code: primaryCode
196
197
  });
198
+ contentTypeNames.push(primaryInterfaceName);
197
199
  }
198
200
  let itemInterfaceName;
199
201
  if (choice.repeat && Object.keys(choice.repeat).length > 0) {
@@ -233,6 +235,7 @@ function buildFieldProperty(args) {
233
235
  name: itemInterfaceName,
234
236
  code: itemCode
235
237
  });
238
+ contentTypeNames.push(itemInterfaceName);
236
239
  }
237
240
  auxiliaryTypes.push({
238
241
  name: sliceName,
@@ -261,6 +264,7 @@ function buildFieldProperty(args) {
261
264
  name: choiceUnionName,
262
265
  code: `type ${choiceUnionName} = ${choiceUnion}`
263
266
  });
267
+ contentTypeNames.push(choiceUnionName);
264
268
  code = addLine(`${name}: prismic.SliceZone<${choiceUnionName}>;`, code);
265
269
  break;
266
270
  }
@@ -270,12 +274,14 @@ function buildFieldProperty(args) {
270
274
  }
271
275
  return {
272
276
  code,
273
- auxiliaryTypes
277
+ auxiliaryTypes,
278
+ contentTypeNames
274
279
  };
275
280
  }
276
281
  function buildFieldProperties(args) {
277
282
  let code = "";
278
283
  const auxiliaryTypes = [];
284
+ const contentTypeNames = [];
279
285
  for (const name in args.fields) {
280
286
  const field = args.fields[name];
281
287
  const fieldProperty = buildFieldProperty({
@@ -287,10 +293,12 @@ function buildFieldProperties(args) {
287
293
  });
288
294
  code = addSection(fieldProperty.code, code);
289
295
  auxiliaryTypes.push(...fieldProperty.auxiliaryTypes);
296
+ contentTypeNames.push(...fieldProperty.contentTypeNames);
290
297
  }
291
298
  return {
292
299
  code,
293
- auxiliaryTypes
300
+ auxiliaryTypes,
301
+ contentTypeNames
294
302
  };
295
303
  }
296
304
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"buildFieldProperties.js","sources":["../../../src/lib/buildFieldProperties.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\n\nimport { AuxiliaryType, FieldConfigs, FieldPath } from \"../types\";\n\nimport { addLine } from \"./addLine\";\nimport { addSection } from \"./addSection\";\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { buildUnion } from \"./buildUnion\";\nimport { getHumanReadablePath } from \"./getHumanReadablePath\";\n\ntype BuildFieldPropertyArgs = Pick<\n\tBuildFieldPropertiesArgs,\n\t\"path\" | \"fieldConfigs\" | \"tabName\"\n> & {\n\tname: string;\n\tfield: CustomTypeModelField;\n};\n\ntype BuildFieldPropertyReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n};\n\nfunction buildFieldProperty(\n\targs: BuildFieldPropertyArgs,\n): BuildFieldPropertyReturnType {\n\tlet code = buildFieldDocs({\n\t\tname: args.name,\n\t\tfield: args.field,\n\t\tpath: args.path,\n\t\ttabName: args.tabName,\n\t});\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\n\tconst name =\n\t\targs.name.includes(\"-\") ||\n\t\targs.name.includes(\":\") ||\n\t\t/^[0-9]/.test(args.name)\n\t\t\t? `\"${args.name}\"`\n\t\t\t: args.name;\n\n\tswitch (args.field.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tcode = addLine(`${name}: prismic.BooleanField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tcode = addLine(`${name}: prismic.ColorField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tcode = addLine(`${name}: prismic.DateField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\targs.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst providerTypesUnion = buildUnion(providerTypes);\n\n\t\t\tcode =\n\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t`${name}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypesUnion})>`,\n\t\t\t\t\t\t\tcode,\n\t\t\t\t\t )\n\t\t\t\t\t: addLine(`${name}: prismic.EmbedField`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tcode = addLine(`${name}: prismic.GeoPointField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\targs.field.config?.thumbnails &&\n\t\t\t\targs.field.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = buildUnion(\n\t\t\t\t\targs.field.config.thumbnails.map((thumb) => `\"${thumb.name}\"`),\n\t\t\t\t);\n\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<${thumbnailNames}>;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<never>;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = args.field.config?.catalog\n\t\t\t\t? args.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\targs.field.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tif (catalogType) {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.IntegrationField<${catalogType}>;`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.IntegrationField;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (args.field.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\tif (\n\t\t\t\t\t\t\"customtypes\" in args.field.config &&\n\t\t\t\t\t\targs.field.config.customtypes &&\n\t\t\t\t\t\targs.field.config.customtypes.length > 0\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst customTypeIDsUnion = buildUnion(\n\t\t\t\t\t\t\targs.field.config.customtypes.map((type) => `\"${type}\"`),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcode = addLine(\n\t\t\t\t\t\t\t`${name}: prismic.ContentRelationshipField<${customTypeIDsUnion}>;`,\n\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcode = addLine(`${name}: prismic.ContentRelationshipField;`, code);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\tcode = addLine(`${name}: prismic.LinkToMediaField;`, code);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tcode = addLine(`${name}: prismic.LinkField;`, code);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tcode = addLine(`${name}: prismic.NumberField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\targs.field.config &&\n\t\t\t\t\"single\" in args.field.config &&\n\t\t\t\targs.field.config.single &&\n\t\t\t\targs.field.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tcode = addLine(`${name}: prismic.TitleField;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.RichTextField;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options: string[] =\n\t\t\t\targs.field.config?.options?.map((option) => `\"${option}\"`) || [];\n\t\t\tconst optionsType = options.length ? buildUnion(options) : \"string\";\n\n\t\t\tconst hasDefault = Boolean(args.field.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.SelectField<${optionsType}, \"filled\">;`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.SelectField${\n\t\t\t\t\t\toptions.length > 0 ? `<${optionsType}>` : \"\"\n\t\t\t\t\t};`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tcode = addLine(`${name}: prismic.KeyTextField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tcode = addLine(`${name}: prismic.TimestampField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemName = buildTypeName(\n\t\t\t\targs.path[0].name,\n\t\t\t\t\"Document\",\n\t\t\t\t\"Data\",\n\t\t\t\targs.name,\n\t\t\t\t\"Item\",\n\t\t\t);\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t...args.path,\n\t\t\t\t{\n\t\t\t\t\tname: name,\n\t\t\t\t\tmodel: args.field,\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\tfields: args.field.config?.fields || {},\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: itemName,\n\t\t\t\tcode: source`\n\t\t\t\t\t/**\n\t\t\t\t\t * Item in *${humanReadablePath}*\n\t\t\t\t\t */\n\t\t\t\t\texport interface ${itemName} {\n\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t}\n\t\t\t\t`,\n\t\t\t});\n\n\t\t\tcode = addLine(\n\t\t\t\t`${name}: prismic.GroupField<Simplify<${itemName}>>;`,\n\t\t\t\tcode,\n\t\t\t);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceNames: string[] = [];\n\n\t\t\tif (args.field.config?.choices) {\n\t\t\t\tfor (const choiceID in args.field.config.choices) {\n\t\t\t\t\tconst choice = args.field.config.choices[choiceID];\n\n\t\t\t\t\tif (choice.type === \"SharedSlice\") {\n\t\t\t\t\t\t// TODO: Verify that the Shared Slice\n\t\t\t\t\t\t// is provided to the global\n\t\t\t\t\t\t// `sharedSlices` array. If it is not,\n\t\t\t\t\t\t// the type won't exist, so we can't\n\t\t\t\t\t\t// add it to the union. We should\n\t\t\t\t\t\t// probably throw an error if we reach\n\t\t\t\t\t\t// that state, or maybe the input can\n\t\t\t\t\t\t// be validated early so we don't\n\t\t\t\t\t\t// generate any code using invalid\n\t\t\t\t\t\t// models.\n\t\t\t\t\t\tchoiceNames.push(buildTypeName(choiceID, \"Slice\"));\n\t\t\t\t\t} else if (choice.type === \"Slice\") {\n\t\t\t\t\t\tconst sliceName = buildTypeName(\n\t\t\t\t\t\t\targs.path[0].name,\n\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\targs.name,\n\t\t\t\t\t\t\tchoiceID,\n\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet primaryInterfaceName: string | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterfaceName = buildTypeName(sliceName, \"Primary\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"primary\",\n\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst primaryFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet primaryCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\tprimaryCode = primaryFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${primaryInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${primaryFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\tprimaryCode,\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: addLine(\n\t\t\t\t\t\t\t\t\t\t`export interface ${primaryInterfaceName} {}`,\n\t\t\t\t\t\t\t\t\t\tprimaryCode,\n\t\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: primaryInterfaceName,\n\t\t\t\t\t\t\t\tcode: primaryCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterfaceName: string | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterfaceName = buildTypeName(sliceName, \"Item\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"items\",\n\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet itemCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Item content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\titemCode = itemFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${itemInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\titemCode,\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: addLine(`export interface ${itemInterfaceName} {}`, itemCode);\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: itemInterfaceName,\n\t\t\t\t\t\t\t\tcode: itemCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\tname: sliceName,\n\t\t\t\t\t\t\tcode: stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Slice for *${getHumanReadablePath({\n\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t})}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\texport type ${sliceName} = prismic.Slice<\"${choiceID}\", ${\n\t\t\t\t\t\t\t\tprimaryInterfaceName\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterfaceName}>`\n\t\t\t\t\t\t\t\t\t: `Record<string, never>`\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceNames.push(sliceName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst choiceUnionName = buildTypeName(\n\t\t\t\targs.path[0].name,\n\t\t\t\t\"Document\",\n\t\t\t\t\"Data\",\n\t\t\t\targs.name,\n\t\t\t\t\"Slice\",\n\t\t\t);\n\t\t\tconst choiceUnion = buildUnion(choiceNames);\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: choiceUnionName,\n\t\t\t\tcode: `type ${choiceUnionName} = ${choiceUnion}`,\n\t\t\t});\n\n\t\t\tcode = addLine(`${name}: prismic.SliceZone<${choiceUnionName}>;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tcode = addLine(`${name}: unknown;`, code);\n\t\t}\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t};\n}\n\ntype BuildFieldPropertiesArgs = {\n\tfields: Record<string, CustomTypeModelField>;\n\tpath: FieldPath;\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\ntype BuildFieldPropertiesReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n};\n\nexport function buildFieldProperties(\n\targs: BuildFieldPropertiesArgs,\n): BuildFieldPropertiesReturnType {\n\tlet code = \"\";\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\n\tfor (const name in args.fields) {\n\t\tconst field = args.fields[name];\n\n\t\tconst fieldProperty = buildFieldProperty({\n\t\t\tname,\n\t\t\tfield,\n\t\t\tpath: args.path,\n\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\ttabName: args.tabName,\n\t\t});\n\n\t\tcode = addSection(fieldProperty.code, code);\n\n\t\tauxiliaryTypes.push(...fieldProperty.auxiliaryTypes);\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t};\n}\n"],"names":[],"mappings":";;;;;;;AAyBA,SAAS,mBACR,MAA4B;;AAE5B,MAAI,OAAO,eAAe;AAAA,IACzB,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ,MAAM,KAAK;AAAA,IACX,SAAS,KAAK;AAAA,EAA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kB,cACvB,KAAK,KAAK,CAAC,EAAE,MACb,YACA,QACA,KAAK,MACL,OAAO;AAEF,YAAA,cAAc,WAAW,WAAW;AAC1C,qBAAe,KAAK;AAAA,QACnB,MAAM;AAAA,QACN,MAAM,QAAQ,qBAAqB;AAAA,MAAA,CACnC;AAED,aAAO,QAAQ,GAAG,2BAA2B,qBAAqB,IAAI;AAEtE;AAAA,IACA;AAAA,IAED,SAAS;AACD,aAAA,QAAQ,GAAG,kBAAkB,IAAI;AAAA,IACxC;AAAA,EACD;AAEM,SAAA;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEF;AAcM,SAAU,qBACf,MAA8B;AAE9B,MAAI,OAAO;AAEX,QAAM,iBAAkC,CAAA;AAE7B,aAAA,QAAQ,KAAK,QAAQ;AACzB,UAAA,QAAQ,KAAK,OAAO,IAAI;AAE9B,UAAM,gBAAgB,mBAAmB;AAAA,MACxC;AAAA,MACA;AAAA,MACA,MAAM,KAAK;AAAA,MACX,cAAc,KAAK;AAAA,MACnB,SAAS,KAAK;AAAA,IAAA,CACd;AAEM,WAAA,WAAW,cAAc,MAAM,IAAI;AAE3B,mBAAA,KAAK,GAAG,cAAc,cAAc;AAAA,EACnD;AAEM,SAAA;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"buildFieldProperties.js","sources":["../../../src/lib/buildFieldProperties.ts"],"sourcesContent":["import type { CustomTypeModelField } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\n\nimport { AuxiliaryType, FieldConfigs, FieldPath } from \"../types\";\n\nimport { addLine } from \"./addLine\";\nimport { addSection } from \"./addSection\";\nimport { buildFieldDocs } from \"./buildFieldDocs\";\nimport { buildTypeName } from \"./buildTypeName\";\nimport { buildUnion } from \"./buildUnion\";\nimport { getHumanReadablePath } from \"./getHumanReadablePath\";\n\ntype BuildFieldPropertyArgs = Pick<\n\tBuildFieldPropertiesArgs,\n\t\"path\" | \"fieldConfigs\" | \"tabName\"\n> & {\n\tname: string;\n\tfield: CustomTypeModelField;\n};\n\ntype BuildFieldPropertyReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nfunction buildFieldProperty(\n\targs: BuildFieldPropertyArgs,\n): BuildFieldPropertyReturnType {\n\tlet code = buildFieldDocs({\n\t\tname: args.name,\n\t\tfield: args.field,\n\t\tpath: args.path,\n\t\ttabName: args.tabName,\n\t});\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tconst name =\n\t\targs.name.includes(\"-\") ||\n\t\targs.name.includes(\":\") ||\n\t\t/^[0-9]/.test(args.name)\n\t\t\t? `\"${args.name}\"`\n\t\t\t: args.name;\n\n\tswitch (args.field.type) {\n\t\tcase \"UID\": {\n\t\t\t// UID fields are not included in Data.\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Boolean\": {\n\t\t\tcode = addLine(`${name}: prismic.BooleanField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Color\": {\n\t\t\tcode = addLine(`${name}: prismic.ColorField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Date\": {\n\t\t\tcode = addLine(`${name}: prismic.DateField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Embed\": {\n\t\t\tconst providerTypes: string[] = [];\n\n\t\t\tif (args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\tfor (const providerType in args.fieldConfigs.embed?.providerTypes) {\n\t\t\t\t\tconst configuredProviderType =\n\t\t\t\t\t\targs.fieldConfigs.embed?.providerTypes[providerType];\n\n\t\t\t\t\tproviderTypes.push(\n\t\t\t\t\t\t`({ provider_name: \"${providerType}\" } & ${configuredProviderType})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst providerTypesUnion = buildUnion(providerTypes);\n\n\t\t\tcode =\n\t\t\t\tproviderTypes.length > 0\n\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t`${name}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${providerTypesUnion})>`,\n\t\t\t\t\t\t\tcode,\n\t\t\t\t\t )\n\t\t\t\t\t: addLine(`${name}: prismic.EmbedField`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"GeoPoint\": {\n\t\t\tcode = addLine(`${name}: prismic.GeoPointField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Image\": {\n\t\t\tif (\n\t\t\t\targs.field.config?.thumbnails &&\n\t\t\t\targs.field.config.thumbnails.length > 0\n\t\t\t) {\n\t\t\t\tconst thumbnailNames = buildUnion(\n\t\t\t\t\targs.field.config.thumbnails.map((thumb) => `\"${thumb.name}\"`),\n\t\t\t\t);\n\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<${thumbnailNames}>;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.ImageField<never>;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"IntegrationFields\": {\n\t\t\tconst catalogType = args.field.config?.catalog\n\t\t\t\t? args.fieldConfigs.integrationFields?.catalogTypes?.[\n\t\t\t\t\t\targs.field.config.catalog\n\t\t\t\t ]\n\t\t\t\t: undefined;\n\n\t\t\tif (catalogType) {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.IntegrationField<${catalogType}>;`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.IntegrationField;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Link\": {\n\t\t\tswitch (args.field.config?.select) {\n\t\t\t\tcase \"document\": {\n\t\t\t\t\tif (\n\t\t\t\t\t\t\"customtypes\" in args.field.config &&\n\t\t\t\t\t\targs.field.config.customtypes &&\n\t\t\t\t\t\targs.field.config.customtypes.length > 0\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst customTypeIDsUnion = buildUnion(\n\t\t\t\t\t\t\targs.field.config.customtypes.map((type) => `\"${type}\"`),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcode = addLine(\n\t\t\t\t\t\t\t`${name}: prismic.ContentRelationshipField<${customTypeIDsUnion}>;`,\n\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcode = addLine(`${name}: prismic.ContentRelationshipField;`, code);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"media\": {\n\t\t\t\t\tcode = addLine(`${name}: prismic.LinkToMediaField;`, code);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tcode = addLine(`${name}: prismic.LinkField;`, code);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Number\": {\n\t\t\tcode = addLine(`${name}: prismic.NumberField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"StructuredText\": {\n\t\t\tconst isTitleField =\n\t\t\t\targs.field.config &&\n\t\t\t\t\"single\" in args.field.config &&\n\t\t\t\targs.field.config.single &&\n\t\t\t\targs.field.config.single\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.every((blockType) => /heading/.test(blockType));\n\n\t\t\tif (isTitleField) {\n\t\t\t\tcode = addLine(`${name}: prismic.TitleField;`, code);\n\t\t\t} else {\n\t\t\t\tcode = addLine(`${name}: prismic.RichTextField;`, code);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Select\": {\n\t\t\tconst options: string[] =\n\t\t\t\targs.field.config?.options?.map((option) => `\"${option}\"`) || [];\n\t\t\tconst optionsType = options.length ? buildUnion(options) : \"string\";\n\n\t\t\tconst hasDefault = Boolean(args.field.config?.default_value);\n\n\t\t\tif (hasDefault) {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.SelectField<${optionsType}, \"filled\">;`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcode = addLine(\n\t\t\t\t\t`${name}: prismic.SelectField${\n\t\t\t\t\t\toptions.length > 0 ? `<${optionsType}>` : \"\"\n\t\t\t\t\t};`,\n\t\t\t\t\tcode,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Text\": {\n\t\t\tcode = addLine(`${name}: prismic.KeyTextField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Timestamp\": {\n\t\t\tcode = addLine(`${name}: prismic.TimestampField;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Group\": {\n\t\t\tconst itemName = buildTypeName(\n\t\t\t\targs.path[0].name,\n\t\t\t\t\"Document\",\n\t\t\t\t\"Data\",\n\t\t\t\targs.name,\n\t\t\t\t\"Item\",\n\t\t\t);\n\n\t\t\tconst path: FieldPath = [\n\t\t\t\t...args.path,\n\t\t\t\t{\n\t\t\t\t\tname: name,\n\t\t\t\t\tmodel: args.field,\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\tfields: args.field.config?.fields || {},\n\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\tpath,\n\t\t\t});\n\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: itemName,\n\t\t\t\tcode: source`\n\t\t\t\t\t/**\n\t\t\t\t\t * Item in *${humanReadablePath}*\n\t\t\t\t\t */\n\t\t\t\t\texport interface ${itemName} {\n\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t}\n\t\t\t\t`,\n\t\t\t});\n\n\t\t\tcode = addLine(\n\t\t\t\t`${name}: prismic.GroupField<Simplify<${itemName}>>;`,\n\t\t\t\tcode,\n\t\t\t);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"Slices\": {\n\t\t\tconst choiceNames: string[] = [];\n\n\t\t\tif (args.field.config?.choices) {\n\t\t\t\tfor (const choiceID in args.field.config.choices) {\n\t\t\t\t\tconst choice = args.field.config.choices[choiceID];\n\n\t\t\t\t\tif (choice.type === \"SharedSlice\") {\n\t\t\t\t\t\t// TODO: Verify that the Shared Slice\n\t\t\t\t\t\t// is provided to the global\n\t\t\t\t\t\t// `sharedSlices` array. If it is not,\n\t\t\t\t\t\t// the type won't exist, so we can't\n\t\t\t\t\t\t// add it to the union. We should\n\t\t\t\t\t\t// probably throw an error if we reach\n\t\t\t\t\t\t// that state, or maybe the input can\n\t\t\t\t\t\t// be validated early so we don't\n\t\t\t\t\t\t// generate any code using invalid\n\t\t\t\t\t\t// models.\n\t\t\t\t\t\tchoiceNames.push(buildTypeName(choiceID, \"Slice\"));\n\t\t\t\t\t} else if (choice.type === \"Slice\") {\n\t\t\t\t\t\tconst sliceName = buildTypeName(\n\t\t\t\t\t\t\targs.path[0].name,\n\t\t\t\t\t\t\t\"Document\",\n\t\t\t\t\t\t\t\"Data\",\n\t\t\t\t\t\t\targs.name,\n\t\t\t\t\t\t\tchoiceID,\n\t\t\t\t\t\t\t\"Slice\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet primaryInterfaceName: string | undefined;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tchoice[\"non-repeat\"] &&\n\t\t\t\t\t\t\tObject.keys(choice[\"non-repeat\"]).length > 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tprimaryInterfaceName = buildTypeName(sliceName, \"Primary\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"primary\",\n\t\t\t\t\t\t\t\t\tlabel: \"Primary\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst primaryFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice[\"non-repeat\"],\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet primaryCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Primary content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\tprimaryCode = primaryFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${primaryInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${primaryFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\tprimaryCode,\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: addLine(\n\t\t\t\t\t\t\t\t\t\t`export interface ${primaryInterfaceName} {}`,\n\t\t\t\t\t\t\t\t\t\tprimaryCode,\n\t\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: primaryInterfaceName,\n\t\t\t\t\t\t\t\tcode: primaryCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontentTypeNames.push(primaryInterfaceName);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet itemInterfaceName: string | undefined;\n\t\t\t\t\t\tif (choice.repeat && Object.keys(choice.repeat).length > 0) {\n\t\t\t\t\t\t\titemInterfaceName = buildTypeName(sliceName, \"Item\");\n\n\t\t\t\t\t\t\tconst path: FieldPath = [\n\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: choiceID,\n\t\t\t\t\t\t\t\t\tmodel: choice,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"items\",\n\t\t\t\t\t\t\t\t\tlabel: \"Items\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tconst humanReadablePath = getHumanReadablePath({ path });\n\n\t\t\t\t\t\t\tconst itemFieldProperties = buildFieldProperties({\n\t\t\t\t\t\t\t\tfields: choice.repeat,\n\t\t\t\t\t\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet itemCode = stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Item content in *${humanReadablePath}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t`;\n\t\t\t\t\t\t\titemCode = itemFieldProperties.code\n\t\t\t\t\t\t\t\t? addLine(\n\t\t\t\t\t\t\t\t\t\tsource`\n\t\t\t\t\t\t\t\t\t\t\texport interface ${itemInterfaceName} {\n\t\t\t\t\t\t\t\t\t\t\t\t${itemFieldProperties.code}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t\t\t\t\titemCode,\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: addLine(`export interface ${itemInterfaceName} {}`, itemCode);\n\n\t\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\t\tname: itemInterfaceName,\n\t\t\t\t\t\t\t\tcode: itemCode,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcontentTypeNames.push(itemInterfaceName);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tauxiliaryTypes.push({\n\t\t\t\t\t\t\tname: sliceName,\n\t\t\t\t\t\t\tcode: stripIndent`\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Slice for *${getHumanReadablePath({\n\t\t\t\t\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\t\t\t\t...args.path,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\t\t\t\tmodel: args.field,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t})}*\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\texport type ${sliceName} = prismic.Slice<\"${choiceID}\", ${\n\t\t\t\t\t\t\t\tprimaryInterfaceName\n\t\t\t\t\t\t\t\t\t? `Simplify<${primaryInterfaceName}>`\n\t\t\t\t\t\t\t\t\t: `Record<string, never>`\n\t\t\t\t\t\t\t}, ${\n\t\t\t\t\t\t\t\titemInterfaceName ? `Simplify<${itemInterfaceName}>` : `never`\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t\t`,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchoiceNames.push(sliceName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst choiceUnionName = buildTypeName(\n\t\t\t\targs.path[0].name,\n\t\t\t\t\"Document\",\n\t\t\t\t\"Data\",\n\t\t\t\targs.name,\n\t\t\t\t\"Slice\",\n\t\t\t);\n\t\t\tconst choiceUnion = buildUnion(choiceNames);\n\t\t\tauxiliaryTypes.push({\n\t\t\t\tname: choiceUnionName,\n\t\t\t\tcode: `type ${choiceUnionName} = ${choiceUnion}`,\n\t\t\t});\n\t\t\tcontentTypeNames.push(choiceUnionName);\n\n\t\t\tcode = addLine(`${name}: prismic.SliceZone<${choiceUnionName}>;`, code);\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tcode = addLine(`${name}: unknown;`, code);\n\t\t}\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n\ntype BuildFieldPropertiesArgs = {\n\tfields: Record<string, CustomTypeModelField>;\n\tpath: FieldPath;\n\tfieldConfigs: FieldConfigs;\n\ttabName?: string;\n};\n\ntype BuildFieldPropertiesReturnType = {\n\tcode: string;\n\tauxiliaryTypes: AuxiliaryType[];\n\tcontentTypeNames: string[];\n};\n\nexport function buildFieldProperties(\n\targs: BuildFieldPropertiesArgs,\n): BuildFieldPropertiesReturnType {\n\tlet code = \"\";\n\n\tconst auxiliaryTypes: AuxiliaryType[] = [];\n\tconst contentTypeNames: string[] = [];\n\n\tfor (const name in args.fields) {\n\t\tconst field = args.fields[name];\n\n\t\tconst fieldProperty = buildFieldProperty({\n\t\t\tname,\n\t\t\tfield,\n\t\t\tpath: args.path,\n\t\t\tfieldConfigs: args.fieldConfigs,\n\t\t\ttabName: args.tabName,\n\t\t});\n\n\t\tcode = addSection(fieldProperty.code, code);\n\n\t\tauxiliaryTypes.push(...fieldProperty.auxiliaryTypes);\n\t\tcontentTypeNames.push(...fieldProperty.contentTypeNames);\n\t}\n\n\treturn {\n\t\tcode,\n\t\tauxiliaryTypes,\n\t\tcontentTypeNames,\n\t};\n}\n"],"names":[],"mappings":";;;;;;;AA0BA,SAAS,mBACR,MAA4B;;AAE5B,MAAI,OAAO,eAAe;AAAA,IACzB,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ,MAAM,KAAK;AAAA,IACX,SAAS,KAAK;AAAA,EAAA,C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CAGxD;AAED,wBAAY,KAAK,SAAS;AAAA,UAC1B;AAAA,QACD;AAAA,MACD;AAEK,YAAA,kBAAkB,cACvB,KAAK,KAAK,CAAC,EAAE,MACb,YACA,QACA,KAAK,MACL,OAAO;AAEF,YAAA,cAAc,WAAW,WAAW;AAC1C,qBAAe,KAAK;AAAA,QACnB,MAAM;AAAA,QACN,MAAM,QAAQ,qBAAqB;AAAA,MAAA,CACnC;AACD,uBAAiB,KAAK,eAAe;AAErC,aAAO,QAAQ,GAAG,2BAA2B,qBAAqB,IAAI;AAEtE;AAAA,IACA;AAAA,IAED,SAAS;AACD,aAAA,QAAQ,GAAG,kBAAkB,IAAI;AAAA,IACxC;AAAA,EACD;AAEM,SAAA;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEF;AAeM,SAAU,qBACf,MAA8B;AAE9B,MAAI,OAAO;AAEX,QAAM,iBAAkC,CAAA;AACxC,QAAM,mBAA6B,CAAA;AAExB,aAAA,QAAQ,KAAK,QAAQ;AACzB,UAAA,QAAQ,KAAK,OAAO,IAAI;AAE9B,UAAM,gBAAgB,mBAAmB;AAAA,MACxC;AAAA,MACA;AAAA,MACA,MAAM,KAAK;AAAA,MACX,cAAc,KAAK;AAAA,MACnB,SAAS,KAAK;AAAA,IAAA,CACd;AAEM,WAAA,WAAW,cAAc,MAAM,IAAI;AAE3B,mBAAA,KAAK,GAAG,cAAc,cAAc;AAClC,qBAAA,KAAK,GAAG,cAAc,gBAAgB;AAAA,EACvD;AAEM,SAAA;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEF;"}
@@ -18,6 +18,7 @@ function buildSharedSliceType(args) {
18
18
  }
19
19
  }
20
20
  let code = "";
21
+ const contentTypeNames = [];
21
22
  const name = buildTypeName.buildTypeName(args.model.id, "Slice");
22
23
  const humanReadableName = getHumanReadableModelName.getHumanReadableModelName({
23
24
  name: args.model.id,
@@ -45,6 +46,8 @@ function buildSharedSliceType(args) {
45
46
  fieldConfigs: args.fieldConfigs,
46
47
  path
47
48
  });
49
+ contentTypeNames.push(...primaryFieldProperties.contentTypeNames);
50
+ contentTypeNames.push(primaryInterfaceName);
48
51
  const docs = commonTags.stripIndent`
49
52
  /**
50
53
  * Primary content in *${humanReadablePath}*
@@ -79,6 +82,8 @@ function buildSharedSliceType(args) {
79
82
  fieldConfigs: args.fieldConfigs,
80
83
  path
81
84
  });
85
+ contentTypeNames.push(...itemFieldProperties.contentTypeNames);
86
+ contentTypeNames.push(itemInterfaceName);
82
87
  const docs = commonTags.stripIndent`
83
88
  /**
84
89
  * Primary content in *${humanReadablePath}*
@@ -108,6 +113,8 @@ function buildSharedSliceType(args) {
108
113
  }
109
114
  const variationUnionName = buildTypeName.buildTypeName(name, "Variation");
110
115
  const variationsUnion = buildUnion.buildUnion(variationNames);
116
+ contentTypeNames.push(variationUnionName);
117
+ contentTypeNames.push(...variationNames);
111
118
  code = addSection.addSection(commonTags.source`
112
119
  /**
113
120
  * Slice variation for *${humanReadableName}*
@@ -126,9 +133,9 @@ function buildSharedSliceType(args) {
126
133
  `, code);
127
134
  const result = {
128
135
  name,
129
- variationUnionName,
130
136
  variationNames,
131
- code
137
+ code,
138
+ contentTypeNames
132
139
  };
133
140
  if (args.cache) {
134
141
  const key = getCacheKey.getCacheKey([args.model, args.fieldConfigs]);
@@ -1 +1 @@
1
- {"version":3,"file":"buildSharedSliceType.cjs","sources":["../../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { FieldConfigs, FieldPath } from \"../types\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\n\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\tvariationUnionName: string;\n\tvariationNames: string[];\n\tcode: 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 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: \"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\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\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\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\tvariationUnionName,\n\t\tvariationNames,\n\t\tcode,\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"],"names":["getCacheKey","buildTypeName","getHumanReadableModelName","getHumanReadablePath","buildFieldProperties","stripIndent","addSection","source","SHARED_SLICES_DOCUMENTATION_URL","buildUnion"],"mappings":";;;;;;;;;;;AA6BM,SAAU,qBACf,MAA8B;AAE9B,MAAI,KAAK,OAAO;AACf,UAAM,MAAMA,YAAAA,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AACvD,UAAM,SAAS,KAAK,MAAM,IAAI,GAAG;AAEjC,QAAI,QAAQ;AACJ,aAAA;AAAA,IACP;AAAA,EACD;AAED,MAAI,OAAO;AAEX,QAAM,OAAOC,cAAAA,cAAc,KAAK,MAAM,IAAI,OAAO;AACjD,QAAM,oBAAoBC,0BAAAA,0BAA0B;AAAA,IACnD,MAAM,KAAK,MAAM;AAAA,IACjB,OAAO,KAAK;AAAA,EAAA,CACZ;AAED,QAAM,iBAA2B,CAAA;AACtB,aAAA,kBAAkB,KAAK,MAAM,YAAY;AACnD,UAAM,gBAAgBD,cAAA,cAAc,MAAM,eAAe,EAAE;AAEvD,QAAA;AAEH,QAAA,eAAe,WACf,OAAO,KAAK,eAAe,OAAO,EAAE,SAAS,GAC5C;AACsB,6BAAAA,cAAA,cAAc,eAAe,SAAS;AAE7D,YAAM,OAAkB;AAAA,QACvB;AAAA,UACC,MAAM,KAAK,MAAM;AAAA,UACjB,OAAO,KAAK;AAAA,QACZ;AAAA,QACD;AAAA,UACC,MAAM;AAAA,UACN,OAAO;AAAA,QACP;AAAA,MAAA;AAEF,YAAM,oBAAoBE,qBAAAA,qBAAqB,EAAE,KAAM,CAAA;AAEvD,YAAM,yBAAyBC,qBAAAA,qBAAqB;AAAA,QACnD,QAAQ,eAAe;AAAA,QACvB,cAAc,KAAK;AAAA,QACnB;AAAA,MAAA,CACA;AAED,YAAM,OAAOC,WAAAA;AAAAA;AAAAA,6BAEa;AAAA;AAAA;AAInB,aAAAC,WAAA,WACN,uBAAuB,OACpBC,WAAAA;AAAAA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,KAG/C,IAAI;AAGL,SAAOD,WACN,WAAAC;;QAEM;AAAA;AAAA,wBAEgB,KAAK,MAAM;AAAA,2BACR,KAAK,MAAM,eAAe;AAAA,6BACxBC;;iBAEZ,+BACd,KAAK,MAAM,QACN;AAAA,KAEN,IAAI;AAGL,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGD,MAAI,KAAK,OAAO;AACf,UAAM,MAAMR,YAAAA,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AAElD,SAAA,MAAM,IAAI,KAAK,MAAM;AAAA,EAC1B;AAEM,SAAA;AACR;;"}
1
+ {"version":3,"file":"buildSharedSliceType.cjs","sources":["../../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { FieldConfigs, FieldPath } from \"../types\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\n\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\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\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: \"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\n\t\t\tcontentTypeNames.push(...primaryFieldProperties.contentTypeNames);\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\n\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\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\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"],"names":["getCacheKey","buildTypeName","getHumanReadableModelName","getHumanReadablePath","buildFieldProperties","stripIndent","addSection","source","SHARED_SLICES_DOCUMENTATION_URL","buildUnion"],"mappings":";;;;;;;;;;;AA6BM,SAAU,qBACf,MAA8B;AAE9B,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AAAA;AAAA,UAEnB,wBACP,eAAe,SAAS,IAAI,kBAAkB;AAAA,KAG/C,IAAI;AAGL,SAAOD,WACN,WAAAC;;QAEM;AAAA;AAAA,wBAEgB,KAAK,MAAM;AAAA,2BACR,KAAK,MAAM,eAAe;AAAA,6BACxBC;;iBAEZ,+BACd,KAAK,MAAM,QACN;AAAA,KAEN,IAAI;AAGL,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGD,MAAI,KAAK,OAAO;AACf,UAAM,MAAMR,YAAAA,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AAElD,SAAA,MAAM,IAAI,KAAK,MAAM;AAAA,EAC1B;AAEM,SAAA;AACR;;"}
@@ -8,9 +8,9 @@ type BuildSharedSliceTypeArgs = {
8
8
  };
9
9
  type BuildSharedSliceTypeReturnValue = {
10
10
  name: string;
11
- variationUnionName: string;
12
11
  variationNames: string[];
13
12
  code: string;
13
+ contentTypeNames: string[];
14
14
  };
15
15
  export declare function buildSharedSliceType(args: BuildSharedSliceTypeArgs): BuildSharedSliceTypeReturnValue;
16
16
  export {};
@@ -16,6 +16,7 @@ function buildSharedSliceType(args) {
16
16
  }
17
17
  }
18
18
  let code = "";
19
+ const contentTypeNames = [];
19
20
  const name = buildTypeName(args.model.id, "Slice");
20
21
  const humanReadableName = getHumanReadableModelName({
21
22
  name: args.model.id,
@@ -43,6 +44,8 @@ function buildSharedSliceType(args) {
43
44
  fieldConfigs: args.fieldConfigs,
44
45
  path
45
46
  });
47
+ contentTypeNames.push(...primaryFieldProperties.contentTypeNames);
48
+ contentTypeNames.push(primaryInterfaceName);
46
49
  const docs = stripIndent`
47
50
  /**
48
51
  * Primary content in *${humanReadablePath}*
@@ -77,6 +80,8 @@ function buildSharedSliceType(args) {
77
80
  fieldConfigs: args.fieldConfigs,
78
81
  path
79
82
  });
83
+ contentTypeNames.push(...itemFieldProperties.contentTypeNames);
84
+ contentTypeNames.push(itemInterfaceName);
80
85
  const docs = stripIndent`
81
86
  /**
82
87
  * Primary content in *${humanReadablePath}*
@@ -106,6 +111,8 @@ function buildSharedSliceType(args) {
106
111
  }
107
112
  const variationUnionName = buildTypeName(name, "Variation");
108
113
  const variationsUnion = buildUnion(variationNames);
114
+ contentTypeNames.push(variationUnionName);
115
+ contentTypeNames.push(...variationNames);
109
116
  code = addSection(source`
110
117
  /**
111
118
  * Slice variation for *${humanReadableName}*
@@ -124,9 +131,9 @@ function buildSharedSliceType(args) {
124
131
  `, code);
125
132
  const result = {
126
133
  name,
127
- variationUnionName,
128
134
  variationNames,
129
- code
135
+ code,
136
+ contentTypeNames
130
137
  };
131
138
  if (args.cache) {
132
139
  const key = getCacheKey([args.model, args.fieldConfigs]);
@@ -1 +1 @@
1
- {"version":3,"file":"buildSharedSliceType.js","sources":["../../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { FieldConfigs, FieldPath } from \"../types\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\n\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\tvariationUnionName: string;\n\tvariationNames: string[];\n\tcode: 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 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: \"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\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\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\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\tvariationUnionName,\n\t\tvariationNames,\n\t\tcode,\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"],"names":[],"mappings":";;;;;;;;;AA6BM,SAAU,qBACf,MAA8B;AAE9B,MAAI,KAAK,OAAO;AACf,UAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AACvD,UAAM,SAAS,KAAK,MAAM,IAAI,GAAG;AAEjC,QAAI,QAAQ;AACJ,aAAA;AAAA,IACP;AAAA,EACD;AAED,MAAI,OAAO;AAEX,QAAM,OAAO,cAAc,KAAK,MAAM,IAAI,OAAO;AACjD,QAAM,oBAAoB,0BAA0B;AAAA,IACnD,MA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,OAAO;AAAA;AAAA,6BAEa;AAAA;AAAA;AAInB,aAAA,WACN,oBAAoB,OACjB;AAAA,QACC;AAAA,yBACiB;AAAA,SAChB,oBAAoB;AAAA;AAAA,SAGtB;AAAA,QACC;AAAA,yBACiB;AAAA,QAErB,IAAI;AAAA,IAEL;AAED,WAAO,WACN;AAAA;AAAA,SAEM,eAAe,sBAAsB;AAAA;AAAA,yBAErB,eAAe;AAAA,4BACZ,eAAe,eAAe;AAAA,8BAC5B;AAAA;AAAA,kBAEZ,iDACd,eAAe,QAEf,uBACG,YAAY,0BACZ,4BACC,oBAAoB,YAAY,uBAAuB;AAAA,MAE5D,IAAI;AAGL,mBAAe,KAAK,aAAa;AAAA,EACjC;AAEK,QAAA,qBAAqB,cAAc,MAAM,WAAW;AACpD,QAAA,kBAAkB,WAAW,cAAc;AAEjD,SAAO,WACN;AAAA;AAAA,6BAE2B;AAAA;AAAA,UAEnB,wBACP,eAAe,SAAS,IAAI,kBAAkB;AAAA,KAG/C,IAAI;AAGL,SAAO,WACN;AAAA;AAAA,QAEM;AAAA;AAAA,wBAEgB,KAAK,MAAM;AAAA,2BACR,KAAK,MAAM,eAAe;AAAA,6BACxB;AAAA;AAAA,iBAEZ,+BACd,KAAK,MAAM,QACN;AAAA,KAEN,IAAI;AAGL,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGD,MAAI,KAAK,OAAO;AACf,UAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AAElD,SAAA,MAAM,IAAI,KAAK,MAAM;AAAA,EAC1B;AAEM,SAAA;AACR;"}
1
+ {"version":3,"file":"buildSharedSliceType.js","sources":["../../../src/lib/buildSharedSliceType.ts"],"sourcesContent":["import type { SharedSliceModel } from \"@prismicio/client\";\nimport { source, stripIndent } from \"common-tags\";\nimport QuickLRU from \"quick-lru\";\n\nimport { FieldConfigs, FieldPath } from \"../types\";\n\nimport { SHARED_SLICES_DOCUMENTATION_URL } from \"../constants\";\n\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\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\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: \"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\n\t\t\tcontentTypeNames.push(...primaryFieldProperties.contentTypeNames);\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\n\t\t\tcontentTypeNames.push(...itemFieldProperties.contentTypeNames);\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\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"],"names":[],"mappings":";;;;;;;;;AA6BM,SAAU,qBACf,MAA8B;AAE9B,MAAI,KAAK,OAAO;AACf,UAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AACvD,UAAM,SAAS,KAAK,MAAM,IAAI,GAAG;AAEjC,QAAI,QAAQ;AACJ,aAAA;AAAA,IACP;AAAA,EACD;AAED,MAAI,OAAO;AACX,QAAM,mBAA6B,CAAA;AAEnC,QAAM,OAAO,cAAc,KAAK,MAAM,IAAI,OAAO;AACjD,QAAM,oBAAoB,0BAA0B;AAAA,IACnD,MAAM,KAAK,MAAM;AAAA,IACjB,OAAO,KAAK;AAAA,EAAA,CACZ;AAED,QAAM,iBAA2B,CAAA;AACtB,aAAA,kBAAkB,KAAK,MAAM,YAAY;AACnD,UAAM,gBAAgB,cAAc,MAAM,eAAe,EAAE;AAEvD,QAAA;AAEH,QAAA,eAAe,WACf,OAAO,KAAK,eAAe,OAAO,EAAE,SAAS,GAC5C;AACsB,6BAAA,cAAc,eAAe,SAAS;AAE7D,YAAM,OAAkB;AAAA,QACvB;AAAA,UACC,MAAM,KAAK,MAAM;AAAA,UACjB,OAAO,KAAK;AAAA,QACZ;AAAA,QACD;AAAA,UACC,MAAM;AAAA,UACN,OAAO;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BACZ,eAAe,eAAe;AAAA,8BAC5B;AAAA;AAAA,kBAEZ,iDACd,eAAe,QAEf,uBACG,YAAY,0BACZ,4BACC,oBAAoB,YAAY,uBAAuB;AAAA,MAE5D,IAAI;AAGL,mBAAe,KAAK,aAAa;AAAA,EACjC;AAEK,QAAA,qBAAqB,cAAc,MAAM,WAAW;AACpD,QAAA,kBAAkB,WAAW,cAAc;AAEjD,mBAAiB,KAAK,kBAAkB;AACvB,mBAAA,KAAK,GAAG,cAAc;AAEvC,SAAO,WACN;AAAA;AAAA,6BAE2B;AAAA;AAAA,UAEnB,wBACP,eAAe,SAAS,IAAI,kBAAkB;AAAA,KAG/C,IAAI;AAGL,SAAO,WACN;AAAA;AAAA,QAEM;AAAA;AAAA,wBAEgB,KAAK,MAAM;AAAA,2BACR,KAAK,MAAM,eAAe;AAAA,6BACxB;AAAA;AAAA,iBAEZ,+BACd,KAAK,MAAM,QACN;AAAA,KAEN,IAAI;AAGL,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGD,MAAI,KAAK,OAAO;AACf,UAAM,MAAM,YAAY,CAAC,KAAK,OAAO,KAAK,YAAY,CAAC;AAElD,SAAA,MAAM,IAAI,KAAK,MAAM;AAAA,EAC1B;AAEM,SAAA;AACR;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prismic-ts-codegen",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "An experimental Prismic model-to-TypeScript-type generator",
5
5
  "keywords": [
6
6
  "typescript",
@@ -24,7 +24,7 @@
24
24
  "module": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts",
26
26
  "bin": {
27
- "prismic-ts-codegen": "./bin/prismic-ts-codegen.mjs"
27
+ "prismic-ts-codegen": "./bin/prismic-ts-codegen.js"
28
28
  },
29
29
  "files": [
30
30
  "dist",
@@ -81,7 +81,7 @@ export function generateTypes(config: GenerateTypesConfig = {}): string {
81
81
  allDocumentTypesTypeNames.push(customTypeType.name);
82
82
 
83
83
  contentTypeNames.push(customTypeType.name);
84
- contentTypeNames.push(customTypeType.dataName);
84
+ contentTypeNames.push(...customTypeType.contentTypeNames);
85
85
  }
86
86
 
87
87
  if (config.customTypeModels.length > 0) {
@@ -108,8 +108,7 @@ export function generateTypes(config: GenerateTypesConfig = {}): string {
108
108
  code = addSection(sharedSliceType.code, code);
109
109
 
110
110
  contentTypeNames.push(sharedSliceType.name);
111
- contentTypeNames.push(sharedSliceType.variationUnionName);
112
- contentTypeNames.push(...sharedSliceType.variationNames);
111
+ contentTypeNames.push(...sharedSliceType.contentTypeNames);
113
112
  }
114
113
  }
115
114
 
@@ -17,6 +17,7 @@ type BuildCustomTypeDataTypeReturnValue = {
17
17
  name: string;
18
18
  code: string;
19
19
  auxiliaryTypes: AuxiliaryType[];
20
+ contentTypeNames: string[];
20
21
  };
21
22
 
22
23
  export function buildCustomTypeDataType(
@@ -24,6 +25,7 @@ export function buildCustomTypeDataType(
24
25
  ): BuildCustomTypeDataTypeReturnValue {
25
26
  let code = "";
26
27
  const auxiliaryTypes: AuxiliaryType[] = [];
28
+ const contentTypeNames: string[] = [];
27
29
 
28
30
  const name = buildTypeName(args.model.id, "Document", "Data");
29
31
  const humanReadableName = getHumanReadableModelName({
@@ -51,6 +53,7 @@ export function buildCustomTypeDataType(
51
53
  fieldProperties += tabFieldProperties.code;
52
54
 
53
55
  auxiliaryTypes.push(...tabFieldProperties.auxiliaryTypes);
56
+ contentTypeNames.push(...tabFieldProperties.contentTypeNames);
54
57
  }
55
58
 
56
59
  if (fieldProperties) {
@@ -70,5 +73,6 @@ export function buildCustomTypeDataType(
70
73
  name,
71
74
  code,
72
75
  auxiliaryTypes,
76
+ contentTypeNames,
73
77
  };
74
78
  }
@@ -23,9 +23,9 @@ type BuildCustomTypeTypesArgs = {
23
23
 
24
24
  type BuildCustomTypeTypeReturnValue = {
25
25
  name: string;
26
- dataName: string;
27
26
  code: string;
28
27
  auxiliaryTypes: AuxiliaryType[];
28
+ contentTypeNames: string[];
29
29
  };
30
30
 
31
31
  export function buildCustomTypeType(
@@ -43,6 +43,7 @@ export function buildCustomTypeType(
43
43
  let code = "";
44
44
 
45
45
  const auxiliaryTypes: AuxiliaryType[] = [];
46
+ const contentTypeNames: string[] = [];
46
47
 
47
48
  const name = buildTypeName(args.model.id, "Document");
48
49
  const langDefault =
@@ -63,6 +64,8 @@ export function buildCustomTypeType(
63
64
  });
64
65
 
65
66
  auxiliaryTypes.push(...dataType.auxiliaryTypes);
67
+ contentTypeNames.push(dataType.name);
68
+ contentTypeNames.push(...dataType.contentTypeNames);
66
69
 
67
70
  code = addSection(dataType.code, code);
68
71
 
@@ -86,9 +89,9 @@ export function buildCustomTypeType(
86
89
 
87
90
  const result = {
88
91
  name,
89
- dataName: dataType.name,
90
92
  code,
91
93
  auxiliaryTypes,
94
+ contentTypeNames,
92
95
  };
93
96
 
94
97
  if (args.cache) {
@@ -21,6 +21,7 @@ type BuildFieldPropertyArgs = Pick<
21
21
  type BuildFieldPropertyReturnType = {
22
22
  code: string;
23
23
  auxiliaryTypes: AuxiliaryType[];
24
+ contentTypeNames: string[];
24
25
  };
25
26
 
26
27
  function buildFieldProperty(
@@ -34,6 +35,7 @@ function buildFieldProperty(
34
35
  });
35
36
 
36
37
  const auxiliaryTypes: AuxiliaryType[] = [];
38
+ const contentTypeNames: string[] = [];
37
39
 
38
40
  const name =
39
41
  args.name.includes("-") ||
@@ -358,6 +360,7 @@ function buildFieldProperty(
358
360
  name: primaryInterfaceName,
359
361
  code: primaryCode,
360
362
  });
363
+ contentTypeNames.push(primaryInterfaceName);
361
364
  }
362
365
 
363
366
  let itemInterfaceName: string | undefined;
@@ -407,6 +410,7 @@ function buildFieldProperty(
407
410
  name: itemInterfaceName,
408
411
  code: itemCode,
409
412
  });
413
+ contentTypeNames.push(itemInterfaceName);
410
414
  }
411
415
 
412
416
  auxiliaryTypes.push({
@@ -450,6 +454,7 @@ function buildFieldProperty(
450
454
  name: choiceUnionName,
451
455
  code: `type ${choiceUnionName} = ${choiceUnion}`,
452
456
  });
457
+ contentTypeNames.push(choiceUnionName);
453
458
 
454
459
  code = addLine(`${name}: prismic.SliceZone<${choiceUnionName}>;`, code);
455
460
 
@@ -464,6 +469,7 @@ function buildFieldProperty(
464
469
  return {
465
470
  code,
466
471
  auxiliaryTypes,
472
+ contentTypeNames,
467
473
  };
468
474
  }
469
475
 
@@ -477,6 +483,7 @@ type BuildFieldPropertiesArgs = {
477
483
  type BuildFieldPropertiesReturnType = {
478
484
  code: string;
479
485
  auxiliaryTypes: AuxiliaryType[];
486
+ contentTypeNames: string[];
480
487
  };
481
488
 
482
489
  export function buildFieldProperties(
@@ -485,6 +492,7 @@ export function buildFieldProperties(
485
492
  let code = "";
486
493
 
487
494
  const auxiliaryTypes: AuxiliaryType[] = [];
495
+ const contentTypeNames: string[] = [];
488
496
 
489
497
  for (const name in args.fields) {
490
498
  const field = args.fields[name];
@@ -500,10 +508,12 @@ export function buildFieldProperties(
500
508
  code = addSection(fieldProperty.code, code);
501
509
 
502
510
  auxiliaryTypes.push(...fieldProperty.auxiliaryTypes);
511
+ contentTypeNames.push(...fieldProperty.contentTypeNames);
503
512
  }
504
513
 
505
514
  return {
506
515
  code,
507
516
  auxiliaryTypes,
517
+ contentTypeNames,
508
518
  };
509
519
  }
@@ -22,9 +22,9 @@ type BuildSharedSliceTypeArgs = {
22
22
 
23
23
  type BuildSharedSliceTypeReturnValue = {
24
24
  name: string;
25
- variationUnionName: string;
26
25
  variationNames: string[];
27
26
  code: string;
27
+ contentTypeNames: string[];
28
28
  };
29
29
 
30
30
  export function buildSharedSliceType(
@@ -40,6 +40,7 @@ export function buildSharedSliceType(
40
40
  }
41
41
 
42
42
  let code = "";
43
+ const contentTypeNames: string[] = [];
43
44
 
44
45
  const name = buildTypeName(args.model.id, "Slice");
45
46
  const humanReadableName = getHumanReadableModelName({
@@ -76,6 +77,9 @@ export function buildSharedSliceType(
76
77
  path,
77
78
  });
78
79
 
80
+ contentTypeNames.push(...primaryFieldProperties.contentTypeNames);
81
+ contentTypeNames.push(primaryInterfaceName);
82
+
79
83
  const docs = stripIndent`
80
84
  /**
81
85
  * Primary content in *${humanReadablePath}*
@@ -120,6 +124,9 @@ export function buildSharedSliceType(
120
124
  path,
121
125
  });
122
126
 
127
+ contentTypeNames.push(...itemFieldProperties.contentTypeNames);
128
+ contentTypeNames.push(itemInterfaceName);
129
+
123
130
  const docs = stripIndent`
124
131
  /**
125
132
  * Primary content in *${humanReadablePath}*
@@ -168,6 +175,9 @@ export function buildSharedSliceType(
168
175
  const variationUnionName = buildTypeName(name, "Variation");
169
176
  const variationsUnion = buildUnion(variationNames);
170
177
 
178
+ contentTypeNames.push(variationUnionName);
179
+ contentTypeNames.push(...variationNames);
180
+
171
181
  code = addSection(
172
182
  source`
173
183
  /**
@@ -198,9 +208,9 @@ export function buildSharedSliceType(
198
208
 
199
209
  const result = {
200
210
  name,
201
- variationUnionName,
202
211
  variationNames,
203
212
  code,
213
+ contentTypeNames,
204
214
  };
205
215
 
206
216
  if (args.cache) {
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import("../dist/cli.js");