@powerhousedao/codegen 6.0.0-dev.12 → 6.0.0-dev.120

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 (656) hide show
  1. package/{dist/src/templates/boilerplate/LICENSE.js → LICENSE} +1 -4
  2. package/dist/file-builders-BRJcuumC.mjs +1675 -0
  3. package/dist/file-builders-BRJcuumC.mjs.map +1 -0
  4. package/dist/index-CJZGVSYg.d.mts +65 -0
  5. package/dist/index-CJZGVSYg.d.mts.map +1 -0
  6. package/dist/index-bxxFsCxV.d.mts +202 -0
  7. package/dist/index-bxxFsCxV.d.mts.map +1 -0
  8. package/dist/index.d.mts +301 -0
  9. package/dist/index.d.mts.map +1 -0
  10. package/dist/index.mjs +5221 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/src/file-builders/index.d.mts +3 -0
  13. package/dist/src/file-builders/index.mjs +3 -0
  14. package/dist/src/name-builders/index.d.mts +2 -0
  15. package/dist/src/name-builders/index.mjs +146 -0
  16. package/dist/src/name-builders/index.mjs.map +1 -0
  17. package/dist/src/templates/index.d.mts +405 -0
  18. package/dist/src/templates/index.d.mts.map +1 -0
  19. package/dist/src/templates/index.mjs +2 -0
  20. package/dist/src/utils/index.d.mts +127 -0
  21. package/dist/src/utils/index.d.mts.map +1 -0
  22. package/dist/src/utils/index.mjs +374 -0
  23. package/dist/src/utils/index.mjs.map +1 -0
  24. package/dist/templates-BYDhXDXu.mjs +4632 -0
  25. package/dist/templates-BYDhXDXu.mjs.map +1 -0
  26. package/dist/types-BcTGclWR.d.mts +89 -0
  27. package/dist/types-BcTGclWR.d.mts.map +1 -0
  28. package/dist/validation-Bpg_44mW.d.mts +43 -0
  29. package/dist/validation-Bpg_44mW.d.mts.map +1 -0
  30. package/package.json +27 -57
  31. package/dist/index.d.ts +0 -8
  32. package/dist/index.d.ts.map +0 -1
  33. package/dist/index.js +0 -7
  34. package/dist/index.js.map +0 -1
  35. package/dist/src/codegen/.hygen/package.json +0 -6
  36. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +0 -10
  37. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +0 -17
  38. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +0 -16
  39. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/actions.esm.t +0 -16
  40. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/creators.esm.t +0 -9
  41. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/customUtils.esm.t +0 -5
  42. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-schema.esm.t +0 -56
  43. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-type.esm.t +0 -6
  44. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModel.esm.t +0 -7
  45. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModelTest.esm.t +0 -121
  46. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/hooks.esm.t +0 -49
  47. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.esm.t +0 -23
  48. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +0 -127
  49. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/module.esm.t +0 -22
  50. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t +0 -93
  51. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +0 -46
  52. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/root-utils.esm.t +0 -11
  53. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootActions.esm.t +0 -13
  54. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootIndex.esm.t +0 -14
  55. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/schema.esm.t +0 -6
  56. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/src-index.esm.t +0 -5
  57. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +0 -31
  58. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +0 -77
  59. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/actions.esm.t +0 -22
  60. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/creators.esm.t +0 -37
  61. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +0 -44
  62. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +0 -36
  63. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +0 -71
  64. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/operations.esm.t +0 -17
  65. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.js +0 -118
  66. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +0 -130
  67. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +0 -44
  68. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +0 -58
  69. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveContents.esm.t +0 -23
  70. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +0 -32
  71. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EmptyState.esm.t +0 -19
  72. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/Files.esm.t +0 -29
  73. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +0 -108
  74. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/Folders.esm.t +0 -28
  75. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/NavigationBreadcrumbs.esm.t +0 -14
  76. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/config.esm.t +0 -11
  77. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +0 -18
  78. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js +0 -25
  79. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/module.esm.t +0 -15
  80. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/editor.esm.t +0 -80
  81. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +0 -90
  82. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/module.esm.t +0 -16
  83. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.esm.t +0 -59
  84. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js +0 -9
  85. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/utils.esm.t +0 -100
  86. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/factory.esm.t +0 -22
  87. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +0 -62
  88. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js +0 -12
  89. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.root.esm.t +0 -10
  90. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.root.inject.esm.t +0 -12
  91. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.esm.t +0 -34
  92. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_call.esm.t +0 -7
  93. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_export.esm.t +0 -7
  94. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_import.esm.t +0 -7
  95. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/factory.esm.t +0 -40
  96. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.esm.t +0 -47
  97. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.js +0 -12
  98. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.root.esm.t +0 -10
  99. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.root.inject.esm.t +0 -12
  100. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.esm.t +0 -34
  101. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.inject_call.esm.t +0 -7
  102. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.inject_export.esm.t +0 -9
  103. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.inject_import.esm.t +0 -7
  104. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/migrations.esm.t +0 -23
  105. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/schema.esm.t +0 -13
  106. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +0 -17
  107. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js +0 -10
  108. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/lib.esm.t +0 -9
  109. package/dist/src/codegen/__tests__/config.d.ts +0 -3
  110. package/dist/src/codegen/__tests__/config.d.ts.map +0 -1
  111. package/dist/src/codegen/__tests__/config.js +0 -3
  112. package/dist/src/codegen/__tests__/config.js.map +0 -1
  113. package/dist/src/codegen/__tests__/constants.d.ts +0 -16
  114. package/dist/src/codegen/__tests__/constants.d.ts.map +0 -1
  115. package/dist/src/codegen/__tests__/constants.js +0 -16
  116. package/dist/src/codegen/__tests__/constants.js.map +0 -1
  117. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.d.ts +0 -2
  118. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.d.ts.map +0 -1
  119. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.js +0 -9
  120. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.js.map +0 -1
  121. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.d.ts +0 -3
  122. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.d.ts.map +0 -1
  123. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.js +0 -33
  124. package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.js.map +0 -1
  125. package/dist/src/codegen/__tests__/fixtures/run-generated-tests.d.ts +0 -2
  126. package/dist/src/codegen/__tests__/fixtures/run-generated-tests.d.ts.map +0 -1
  127. package/dist/src/codegen/__tests__/fixtures/run-generated-tests.js +0 -23
  128. package/dist/src/codegen/__tests__/fixtures/run-generated-tests.js.map +0 -1
  129. package/dist/src/codegen/__tests__/fixtures/typecheck.d.ts +0 -2
  130. package/dist/src/codegen/__tests__/fixtures/typecheck.d.ts.map +0 -1
  131. package/dist/src/codegen/__tests__/fixtures/typecheck.js +0 -23
  132. package/dist/src/codegen/__tests__/fixtures/typecheck.js.map +0 -1
  133. package/dist/src/codegen/__tests__/generate-doc-model.test.d.ts +0 -2
  134. package/dist/src/codegen/__tests__/generate-doc-model.test.d.ts.map +0 -1
  135. package/dist/src/codegen/__tests__/generate-doc-model.test.js +0 -233
  136. package/dist/src/codegen/__tests__/generate-doc-model.test.js.map +0 -1
  137. package/dist/src/codegen/__tests__/generate-drive-editor.test.d.ts +0 -2
  138. package/dist/src/codegen/__tests__/generate-drive-editor.test.d.ts.map +0 -1
  139. package/dist/src/codegen/__tests__/generate-drive-editor.test.js +0 -156
  140. package/dist/src/codegen/__tests__/generate-drive-editor.test.js.map +0 -1
  141. package/dist/src/codegen/__tests__/generate-editor.test.d.ts +0 -2
  142. package/dist/src/codegen/__tests__/generate-editor.test.d.ts.map +0 -1
  143. package/dist/src/codegen/__tests__/generate-editor.test.js +0 -115
  144. package/dist/src/codegen/__tests__/generate-editor.test.js.map +0 -1
  145. package/dist/src/codegen/__tests__/generate-manifest.test.d.ts +0 -2
  146. package/dist/src/codegen/__tests__/generate-manifest.test.d.ts.map +0 -1
  147. package/dist/src/codegen/__tests__/generate-manifest.test.js +0 -192
  148. package/dist/src/codegen/__tests__/generate-manifest.test.js.map +0 -1
  149. package/dist/src/codegen/__tests__/generate-versioned-document-model.test.d.ts +0 -2
  150. package/dist/src/codegen/__tests__/generate-versioned-document-model.test.d.ts.map +0 -1
  151. package/dist/src/codegen/__tests__/generate-versioned-document-model.test.js +0 -159
  152. package/dist/src/codegen/__tests__/generate-versioned-document-model.test.js.map +0 -1
  153. package/dist/src/codegen/__tests__/global-setup.d.ts +0 -2
  154. package/dist/src/codegen/__tests__/global-setup.d.ts.map +0 -1
  155. package/dist/src/codegen/__tests__/global-setup.js +0 -21
  156. package/dist/src/codegen/__tests__/global-setup.js.map +0 -1
  157. package/dist/src/codegen/__tests__/ts-morph-generator.test.d.ts +0 -2
  158. package/dist/src/codegen/__tests__/ts-morph-generator.test.d.ts.map +0 -1
  159. package/dist/src/codegen/__tests__/ts-morph-generator.test.js +0 -73
  160. package/dist/src/codegen/__tests__/ts-morph-generator.test.js.map +0 -1
  161. package/dist/src/codegen/__tests__/utils.d.ts +0 -7
  162. package/dist/src/codegen/__tests__/utils.d.ts.map +0 -1
  163. package/dist/src/codegen/__tests__/utils.js +0 -52
  164. package/dist/src/codegen/__tests__/utils.js.map +0 -1
  165. package/dist/src/codegen/generate.d.ts +0 -79
  166. package/dist/src/codegen/generate.d.ts.map +0 -1
  167. package/dist/src/codegen/generate.js +0 -334
  168. package/dist/src/codegen/generate.js.map +0 -1
  169. package/dist/src/codegen/graphql.d.ts +0 -36
  170. package/dist/src/codegen/graphql.d.ts.map +0 -1
  171. package/dist/src/codegen/graphql.js +0 -146
  172. package/dist/src/codegen/graphql.js.map +0 -1
  173. package/dist/src/codegen/hygen.d.ts +0 -47
  174. package/dist/src/codegen/hygen.d.ts.map +0 -1
  175. package/dist/src/codegen/hygen.js +0 -230
  176. package/dist/src/codegen/hygen.js.map +0 -1
  177. package/dist/src/codegen/index.d.ts +0 -7
  178. package/dist/src/codegen/index.d.ts.map +0 -1
  179. package/dist/src/codegen/index.js +0 -7
  180. package/dist/src/codegen/index.js.map +0 -1
  181. package/dist/src/codegen/kysely.d.ts +0 -6
  182. package/dist/src/codegen/kysely.d.ts.map +0 -1
  183. package/dist/src/codegen/kysely.js +0 -51
  184. package/dist/src/codegen/kysely.js.map +0 -1
  185. package/dist/src/codegen/types.d.ts +0 -9
  186. package/dist/src/codegen/types.d.ts.map +0 -1
  187. package/dist/src/codegen/types.js +0 -2
  188. package/dist/src/codegen/types.js.map +0 -1
  189. package/dist/src/codegen/utils.d.ts +0 -7
  190. package/dist/src/codegen/utils.d.ts.map +0 -1
  191. package/dist/src/codegen/utils.js +0 -79
  192. package/dist/src/codegen/utils.js.map +0 -1
  193. package/dist/src/create-lib/checkout-project.d.ts +0 -13
  194. package/dist/src/create-lib/checkout-project.d.ts.map +0 -1
  195. package/dist/src/create-lib/checkout-project.js +0 -47
  196. package/dist/src/create-lib/checkout-project.js.map +0 -1
  197. package/dist/src/create-lib/create-project.d.ts +0 -10
  198. package/dist/src/create-lib/create-project.d.ts.map +0 -1
  199. package/dist/src/create-lib/create-project.js +0 -98
  200. package/dist/src/create-lib/create-project.js.map +0 -1
  201. package/dist/src/create-lib/feature-flags.d.ts +0 -4
  202. package/dist/src/create-lib/feature-flags.d.ts.map +0 -1
  203. package/dist/src/create-lib/feature-flags.js +0 -4
  204. package/dist/src/create-lib/feature-flags.js.map +0 -1
  205. package/dist/src/create-lib/index.d.ts +0 -3
  206. package/dist/src/create-lib/index.d.ts.map +0 -1
  207. package/dist/src/create-lib/index.js +0 -3
  208. package/dist/src/create-lib/index.js.map +0 -1
  209. package/dist/src/create-lib/utils.d.ts +0 -8
  210. package/dist/src/create-lib/utils.d.ts.map +0 -1
  211. package/dist/src/create-lib/utils.js +0 -34
  212. package/dist/src/create-lib/utils.js.map +0 -1
  213. package/dist/src/file-builders/boilerplate/build-package-json.test.d.ts +0 -2
  214. package/dist/src/file-builders/boilerplate/build-package-json.test.d.ts.map +0 -1
  215. package/dist/src/file-builders/boilerplate/build-package-json.test.js +0 -28
  216. package/dist/src/file-builders/boilerplate/build-package-json.test.js.map +0 -1
  217. package/dist/src/file-builders/boilerplate/package-json-versions.test.d.ts +0 -2
  218. package/dist/src/file-builders/boilerplate/package-json-versions.test.d.ts.map +0 -1
  219. package/dist/src/file-builders/boilerplate/package-json-versions.test.js +0 -34
  220. package/dist/src/file-builders/boilerplate/package-json-versions.test.js.map +0 -1
  221. package/dist/src/file-builders/boilerplate/package.json.d.ts +0 -6
  222. package/dist/src/file-builders/boilerplate/package.json.d.ts.map +0 -1
  223. package/dist/src/file-builders/boilerplate/package.json.js +0 -18
  224. package/dist/src/file-builders/boilerplate/package.json.js.map +0 -1
  225. package/dist/src/file-builders/document-editor.d.ts +0 -8
  226. package/dist/src/file-builders/document-editor.d.ts.map +0 -1
  227. package/dist/src/file-builders/document-editor.js +0 -57
  228. package/dist/src/file-builders/document-editor.js.map +0 -1
  229. package/dist/src/file-builders/document-model/document-model.d.ts +0 -8
  230. package/dist/src/file-builders/document-model/document-model.d.ts.map +0 -1
  231. package/dist/src/file-builders/document-model/document-model.js +0 -246
  232. package/dist/src/file-builders/document-model/document-model.js.map +0 -1
  233. package/dist/src/file-builders/document-model/gen-dir.d.ts +0 -3
  234. package/dist/src/file-builders/document-model/gen-dir.d.ts.map +0 -1
  235. package/dist/src/file-builders/document-model/gen-dir.js +0 -201
  236. package/dist/src/file-builders/document-model/gen-dir.js.map +0 -1
  237. package/dist/src/file-builders/document-model/root-dir.d.ts +0 -3
  238. package/dist/src/file-builders/document-model/root-dir.d.ts.map +0 -1
  239. package/dist/src/file-builders/document-model/root-dir.js +0 -51
  240. package/dist/src/file-builders/document-model/root-dir.js.map +0 -1
  241. package/dist/src/file-builders/document-model/src-dir.d.ts +0 -3
  242. package/dist/src/file-builders/document-model/src-dir.d.ts.map +0 -1
  243. package/dist/src/file-builders/document-model/src-dir.js +0 -118
  244. package/dist/src/file-builders/document-model/src-dir.js.map +0 -1
  245. package/dist/src/file-builders/document-model/tests-dir.d.ts +0 -3
  246. package/dist/src/file-builders/document-model/tests-dir.d.ts.map +0 -1
  247. package/dist/src/file-builders/document-model/tests-dir.js +0 -127
  248. package/dist/src/file-builders/document-model/tests-dir.js.map +0 -1
  249. package/dist/src/file-builders/document-model/upgrades-dir.d.ts +0 -31
  250. package/dist/src/file-builders/document-model/upgrades-dir.d.ts.map +0 -1
  251. package/dist/src/file-builders/document-model/upgrades-dir.js +0 -135
  252. package/dist/src/file-builders/document-model/upgrades-dir.js.map +0 -1
  253. package/dist/src/file-builders/drive-editor.d.ts +0 -9
  254. package/dist/src/file-builders/drive-editor.d.ts.map +0 -1
  255. package/dist/src/file-builders/drive-editor.js +0 -164
  256. package/dist/src/file-builders/drive-editor.js.map +0 -1
  257. package/dist/src/file-builders/editor-common.d.ts +0 -13
  258. package/dist/src/file-builders/editor-common.d.ts.map +0 -1
  259. package/dist/src/file-builders/editor-common.js +0 -26
  260. package/dist/src/file-builders/editor-common.js.map +0 -1
  261. package/dist/src/file-builders/index-files.d.ts +0 -18
  262. package/dist/src/file-builders/index-files.d.ts.map +0 -1
  263. package/dist/src/file-builders/index-files.js +0 -25
  264. package/dist/src/file-builders/index-files.js.map +0 -1
  265. package/dist/src/file-builders/index.d.ts +0 -10
  266. package/dist/src/file-builders/index.d.ts.map +0 -1
  267. package/dist/src/file-builders/index.js +0 -9
  268. package/dist/src/file-builders/index.js.map +0 -1
  269. package/dist/src/file-builders/module-files.d.ts +0 -52
  270. package/dist/src/file-builders/module-files.d.ts.map +0 -1
  271. package/dist/src/file-builders/module-files.js +0 -230
  272. package/dist/src/file-builders/module-files.js.map +0 -1
  273. package/dist/src/file-builders/subgraphs.d.ts +0 -6
  274. package/dist/src/file-builders/subgraphs.d.ts.map +0 -1
  275. package/dist/src/file-builders/subgraphs.js +0 -53
  276. package/dist/src/file-builders/subgraphs.js.map +0 -1
  277. package/dist/src/file-builders/types.d.ts +0 -66
  278. package/dist/src/file-builders/types.d.ts.map +0 -1
  279. package/dist/src/file-builders/types.js +0 -2
  280. package/dist/src/file-builders/types.js.map +0 -1
  281. package/dist/src/index.d.ts +0 -5
  282. package/dist/src/index.d.ts.map +0 -1
  283. package/dist/src/index.js +0 -5
  284. package/dist/src/index.js.map +0 -1
  285. package/dist/src/name-builders/get-action-names.d.ts +0 -6
  286. package/dist/src/name-builders/get-action-names.d.ts.map +0 -1
  287. package/dist/src/name-builders/get-action-names.js +0 -16
  288. package/dist/src/name-builders/get-action-names.js.map +0 -1
  289. package/dist/src/name-builders/get-variable-names.d.ts +0 -48
  290. package/dist/src/name-builders/get-variable-names.d.ts.map +0 -1
  291. package/dist/src/name-builders/get-variable-names.js +0 -147
  292. package/dist/src/name-builders/get-variable-names.js.map +0 -1
  293. package/dist/src/name-builders/index.d.ts +0 -3
  294. package/dist/src/name-builders/index.d.ts.map +0 -1
  295. package/dist/src/name-builders/index.js +0 -3
  296. package/dist/src/name-builders/index.js.map +0 -1
  297. package/dist/src/templates/boilerplate/AGENTS.md.d.ts +0 -2
  298. package/dist/src/templates/boilerplate/AGENTS.md.d.ts.map +0 -1
  299. package/dist/src/templates/boilerplate/AGENTS.md.js +0 -408
  300. package/dist/src/templates/boilerplate/AGENTS.md.js.map +0 -1
  301. package/dist/src/templates/boilerplate/CLAUDE.md.d.ts +0 -2
  302. package/dist/src/templates/boilerplate/CLAUDE.md.d.ts.map +0 -1
  303. package/dist/src/templates/boilerplate/CLAUDE.md.js +0 -408
  304. package/dist/src/templates/boilerplate/CLAUDE.md.js.map +0 -1
  305. package/dist/src/templates/boilerplate/LICENSE.d.ts +0 -2
  306. package/dist/src/templates/boilerplate/LICENSE.d.ts.map +0 -1
  307. package/dist/src/templates/boilerplate/LICENSE.js.map +0 -1
  308. package/dist/src/templates/boilerplate/README.md.d.ts +0 -2
  309. package/dist/src/templates/boilerplate/README.md.d.ts.map +0 -1
  310. package/dist/src/templates/boilerplate/README.md.js +0 -194
  311. package/dist/src/templates/boilerplate/README.md.js.map +0 -1
  312. package/dist/src/templates/boilerplate/claude/settings.local.json.d.ts +0 -2
  313. package/dist/src/templates/boilerplate/claude/settings.local.json.d.ts.map +0 -1
  314. package/dist/src/templates/boilerplate/claude/settings.local.json.js +0 -18
  315. package/dist/src/templates/boilerplate/claude/settings.local.json.js.map +0 -1
  316. package/dist/src/templates/boilerplate/cursor/mcp.json.d.ts +0 -2
  317. package/dist/src/templates/boilerplate/cursor/mcp.json.d.ts.map +0 -1
  318. package/dist/src/templates/boilerplate/cursor/mcp.json.js +0 -12
  319. package/dist/src/templates/boilerplate/cursor/mcp.json.js.map +0 -1
  320. package/dist/src/templates/boilerplate/document-models/document-models.d.ts +0 -2
  321. package/dist/src/templates/boilerplate/document-models/document-models.d.ts.map +0 -1
  322. package/dist/src/templates/boilerplate/document-models/document-models.js +0 -7
  323. package/dist/src/templates/boilerplate/document-models/document-models.js.map +0 -1
  324. package/dist/src/templates/boilerplate/document-models/index.d.ts +0 -2
  325. package/dist/src/templates/boilerplate/document-models/index.d.ts.map +0 -1
  326. package/dist/src/templates/boilerplate/document-models/index.js +0 -2
  327. package/dist/src/templates/boilerplate/document-models/index.js.map +0 -1
  328. package/dist/src/templates/boilerplate/editors/editors.d.ts +0 -2
  329. package/dist/src/templates/boilerplate/editors/editors.d.ts.map +0 -1
  330. package/dist/src/templates/boilerplate/editors/editors.js +0 -7
  331. package/dist/src/templates/boilerplate/editors/editors.js.map +0 -1
  332. package/dist/src/templates/boilerplate/editors/index.d.ts +0 -2
  333. package/dist/src/templates/boilerplate/editors/index.d.ts.map +0 -1
  334. package/dist/src/templates/boilerplate/editors/index.js +0 -2
  335. package/dist/src/templates/boilerplate/editors/index.js.map +0 -1
  336. package/dist/src/templates/boilerplate/eslint.config.js.d.ts +0 -2
  337. package/dist/src/templates/boilerplate/eslint.config.js.d.ts.map +0 -1
  338. package/dist/src/templates/boilerplate/eslint.config.js.js +0 -140
  339. package/dist/src/templates/boilerplate/eslint.config.js.js.map +0 -1
  340. package/dist/src/templates/boilerplate/gemini/settings.json.d.ts +0 -2
  341. package/dist/src/templates/boilerplate/gemini/settings.json.d.ts.map +0 -1
  342. package/dist/src/templates/boilerplate/gemini/settings.json.js +0 -12
  343. package/dist/src/templates/boilerplate/gemini/settings.json.js.map +0 -1
  344. package/dist/src/templates/boilerplate/gitignore.d.ts +0 -2
  345. package/dist/src/templates/boilerplate/gitignore.d.ts.map +0 -1
  346. package/dist/src/templates/boilerplate/gitignore.js +0 -11
  347. package/dist/src/templates/boilerplate/gitignore.js.map +0 -1
  348. package/dist/src/templates/boilerplate/index.d.ts +0 -2
  349. package/dist/src/templates/boilerplate/index.d.ts.map +0 -1
  350. package/dist/src/templates/boilerplate/index.html.d.ts +0 -2
  351. package/dist/src/templates/boilerplate/index.html.d.ts.map +0 -1
  352. package/dist/src/templates/boilerplate/index.html.js +0 -31
  353. package/dist/src/templates/boilerplate/index.html.js.map +0 -1
  354. package/dist/src/templates/boilerplate/index.html.legacy.d.ts +0 -2
  355. package/dist/src/templates/boilerplate/index.html.legacy.d.ts.map +0 -1
  356. package/dist/src/templates/boilerplate/index.html.legacy.js +0 -36
  357. package/dist/src/templates/boilerplate/index.html.legacy.js.map +0 -1
  358. package/dist/src/templates/boilerplate/index.js +0 -8
  359. package/dist/src/templates/boilerplate/index.js.map +0 -1
  360. package/dist/src/templates/boilerplate/mcp.json.d.ts +0 -2
  361. package/dist/src/templates/boilerplate/mcp.json.d.ts.map +0 -1
  362. package/dist/src/templates/boilerplate/mcp.json.js +0 -12
  363. package/dist/src/templates/boilerplate/mcp.json.js.map +0 -1
  364. package/dist/src/templates/boilerplate/npmrc.d.ts +0 -2
  365. package/dist/src/templates/boilerplate/npmrc.d.ts.map +0 -1
  366. package/dist/src/templates/boilerplate/npmrc.js +0 -2
  367. package/dist/src/templates/boilerplate/npmrc.js.map +0 -1
  368. package/dist/src/templates/boilerplate/package.json.d.ts +0 -2
  369. package/dist/src/templates/boilerplate/package.json.d.ts.map +0 -1
  370. package/dist/src/templates/boilerplate/package.json.js +0 -115
  371. package/dist/src/templates/boilerplate/package.json.js.map +0 -1
  372. package/dist/src/templates/boilerplate/package.json.legacy.d.ts +0 -55
  373. package/dist/src/templates/boilerplate/package.json.legacy.d.ts.map +0 -1
  374. package/dist/src/templates/boilerplate/package.json.legacy.js +0 -55
  375. package/dist/src/templates/boilerplate/package.json.legacy.js.map +0 -1
  376. package/dist/src/templates/boilerplate/powerhouse.config.json.d.ts +0 -6
  377. package/dist/src/templates/boilerplate/powerhouse.config.json.d.ts.map +0 -1
  378. package/dist/src/templates/boilerplate/powerhouse.config.json.js +0 -46
  379. package/dist/src/templates/boilerplate/powerhouse.config.json.js.map +0 -1
  380. package/dist/src/templates/boilerplate/powerhouse.manifest.json.d.ts +0 -2
  381. package/dist/src/templates/boilerplate/powerhouse.manifest.json.d.ts.map +0 -1
  382. package/dist/src/templates/boilerplate/powerhouse.manifest.json.js +0 -19
  383. package/dist/src/templates/boilerplate/powerhouse.manifest.json.js.map +0 -1
  384. package/dist/src/templates/boilerplate/processors/index.d.ts +0 -2
  385. package/dist/src/templates/boilerplate/processors/index.d.ts.map +0 -1
  386. package/dist/src/templates/boilerplate/processors/index.js +0 -2
  387. package/dist/src/templates/boilerplate/processors/index.js.map +0 -1
  388. package/dist/src/templates/boilerplate/style.css.d.ts +0 -2
  389. package/dist/src/templates/boilerplate/style.css.d.ts.map +0 -1
  390. package/dist/src/templates/boilerplate/style.css.js +0 -17
  391. package/dist/src/templates/boilerplate/style.css.js.map +0 -1
  392. package/dist/src/templates/boilerplate/subgraphs/index.d.ts +0 -2
  393. package/dist/src/templates/boilerplate/subgraphs/index.d.ts.map +0 -1
  394. package/dist/src/templates/boilerplate/subgraphs/index.js +0 -2
  395. package/dist/src/templates/boilerplate/subgraphs/index.js.map +0 -1
  396. package/dist/src/templates/boilerplate/tsconfig.json.d.ts +0 -2
  397. package/dist/src/templates/boilerplate/tsconfig.json.d.ts.map +0 -1
  398. package/dist/src/templates/boilerplate/tsconfig.json.js +0 -46
  399. package/dist/src/templates/boilerplate/tsconfig.json.js.map +0 -1
  400. package/dist/src/templates/boilerplate/vite.config.ts.d.ts +0 -2
  401. package/dist/src/templates/boilerplate/vite.config.ts.d.ts.map +0 -1
  402. package/dist/src/templates/boilerplate/vite.config.ts.js +0 -21
  403. package/dist/src/templates/boilerplate/vite.config.ts.js.map +0 -1
  404. package/dist/src/templates/boilerplate/vitest.config.ts.d.ts +0 -2
  405. package/dist/src/templates/boilerplate/vitest.config.ts.d.ts.map +0 -1
  406. package/dist/src/templates/boilerplate/vitest.config.ts.js +0 -21
  407. package/dist/src/templates/boilerplate/vitest.config.ts.js.map +0 -1
  408. package/dist/src/templates/document-editor/editor.d.ts +0 -5
  409. package/dist/src/templates/document-editor/editor.d.ts.map +0 -1
  410. package/dist/src/templates/document-editor/editor.js +0 -85
  411. package/dist/src/templates/document-editor/editor.js.map +0 -1
  412. package/dist/src/templates/document-editor/module.d.ts +0 -7
  413. package/dist/src/templates/document-editor/module.d.ts.map +0 -1
  414. package/dist/src/templates/document-editor/module.js +0 -16
  415. package/dist/src/templates/document-editor/module.js.map +0 -1
  416. package/dist/src/templates/document-model/actions.d.ts +0 -3
  417. package/dist/src/templates/document-model/actions.d.ts.map +0 -1
  418. package/dist/src/templates/document-model/actions.js +0 -28
  419. package/dist/src/templates/document-model/actions.js.map +0 -1
  420. package/dist/src/templates/document-model/gen/actions.d.ts +0 -3
  421. package/dist/src/templates/document-model/gen/actions.d.ts.map +0 -1
  422. package/dist/src/templates/document-model/gen/actions.js +0 -40
  423. package/dist/src/templates/document-model/gen/actions.js.map +0 -1
  424. package/dist/src/templates/document-model/gen/creators.d.ts +0 -3
  425. package/dist/src/templates/document-model/gen/creators.d.ts.map +0 -1
  426. package/dist/src/templates/document-model/gen/creators.js +0 -16
  427. package/dist/src/templates/document-model/gen/creators.js.map +0 -1
  428. package/dist/src/templates/document-model/gen/document-schema.d.ts +0 -3
  429. package/dist/src/templates/document-model/gen/document-schema.d.ts.map +0 -1
  430. package/dist/src/templates/document-model/gen/document-schema.js +0 -56
  431. package/dist/src/templates/document-model/gen/document-schema.js.map +0 -1
  432. package/dist/src/templates/document-model/gen/document-type.d.ts +0 -3
  433. package/dist/src/templates/document-model/gen/document-type.d.ts.map +0 -1
  434. package/dist/src/templates/document-model/gen/document-type.js +0 -5
  435. package/dist/src/templates/document-model/gen/document-type.js.map +0 -1
  436. package/dist/src/templates/document-model/gen/index.d.ts +0 -3
  437. package/dist/src/templates/document-model/gen/index.d.ts.map +0 -1
  438. package/dist/src/templates/document-model/gen/index.js +0 -29
  439. package/dist/src/templates/document-model/gen/index.js.map +0 -1
  440. package/dist/src/templates/document-model/gen/modules/actions.d.ts +0 -8
  441. package/dist/src/templates/document-model/gen/modules/actions.d.ts.map +0 -1
  442. package/dist/src/templates/document-model/gen/modules/actions.js +0 -39
  443. package/dist/src/templates/document-model/gen/modules/actions.js.map +0 -1
  444. package/dist/src/templates/document-model/gen/modules/creators.d.ts +0 -3
  445. package/dist/src/templates/document-model/gen/modules/creators.d.ts.map +0 -1
  446. package/dist/src/templates/document-model/gen/modules/creators.js +0 -97
  447. package/dist/src/templates/document-model/gen/modules/creators.js.map +0 -1
  448. package/dist/src/templates/document-model/gen/modules/error.d.ts +0 -3
  449. package/dist/src/templates/document-model/gen/modules/error.d.ts.map +0 -1
  450. package/dist/src/templates/document-model/gen/modules/error.js +0 -73
  451. package/dist/src/templates/document-model/gen/modules/error.js.map +0 -1
  452. package/dist/src/templates/document-model/gen/modules/operations.d.ts +0 -3
  453. package/dist/src/templates/document-model/gen/modules/operations.d.ts.map +0 -1
  454. package/dist/src/templates/document-model/gen/modules/operations.js +0 -61
  455. package/dist/src/templates/document-model/gen/modules/operations.js.map +0 -1
  456. package/dist/src/templates/document-model/gen/ph-factories.d.ts +0 -3
  457. package/dist/src/templates/document-model/gen/ph-factories.d.ts.map +0 -1
  458. package/dist/src/templates/document-model/gen/ph-factories.js +0 -93
  459. package/dist/src/templates/document-model/gen/ph-factories.js.map +0 -1
  460. package/dist/src/templates/document-model/gen/reducer.d.ts +0 -3
  461. package/dist/src/templates/document-model/gen/reducer.d.ts.map +0 -1
  462. package/dist/src/templates/document-model/gen/reducer.js +0 -106
  463. package/dist/src/templates/document-model/gen/reducer.js.map +0 -1
  464. package/dist/src/templates/document-model/gen/schema/index.d.ts +0 -2
  465. package/dist/src/templates/document-model/gen/schema/index.d.ts.map +0 -1
  466. package/dist/src/templates/document-model/gen/schema/index.js +0 -6
  467. package/dist/src/templates/document-model/gen/schema/index.js.map +0 -1
  468. package/dist/src/templates/document-model/gen/types.d.ts +0 -3
  469. package/dist/src/templates/document-model/gen/types.d.ts.map +0 -1
  470. package/dist/src/templates/document-model/gen/types.js +0 -38
  471. package/dist/src/templates/document-model/gen/types.js.map +0 -1
  472. package/dist/src/templates/document-model/gen/utils.d.ts +0 -3
  473. package/dist/src/templates/document-model/gen/utils.d.ts.map +0 -1
  474. package/dist/src/templates/document-model/gen/utils.js +0 -77
  475. package/dist/src/templates/document-model/gen/utils.js.map +0 -1
  476. package/dist/src/templates/document-model/hooks.d.ts +0 -3
  477. package/dist/src/templates/document-model/hooks.d.ts.map +0 -1
  478. package/dist/src/templates/document-model/hooks.js +0 -52
  479. package/dist/src/templates/document-model/hooks.js.map +0 -1
  480. package/dist/src/templates/document-model/index.d.ts +0 -2
  481. package/dist/src/templates/document-model/index.d.ts.map +0 -1
  482. package/dist/src/templates/document-model/index.js +0 -9
  483. package/dist/src/templates/document-model/index.js.map +0 -1
  484. package/dist/src/templates/document-model/module.d.ts +0 -9
  485. package/dist/src/templates/document-model/module.d.ts.map +0 -1
  486. package/dist/src/templates/document-model/module.js +0 -26
  487. package/dist/src/templates/document-model/module.js.map +0 -1
  488. package/dist/src/templates/document-model/src/index.d.ts +0 -2
  489. package/dist/src/templates/document-model/src/index.d.ts.map +0 -1
  490. package/dist/src/templates/document-model/src/index.js +0 -5
  491. package/dist/src/templates/document-model/src/index.js.map +0 -1
  492. package/dist/src/templates/document-model/src/tests/document-model.test.d.ts +0 -3
  493. package/dist/src/templates/document-model/src/tests/document-model.test.d.ts.map +0 -1
  494. package/dist/src/templates/document-model/src/tests/document-model.test.js +0 -121
  495. package/dist/src/templates/document-model/src/tests/document-model.test.js.map +0 -1
  496. package/dist/src/templates/document-model/src/tests/module.test.d.ts +0 -6
  497. package/dist/src/templates/document-model/src/tests/module.test.d.ts.map +0 -1
  498. package/dist/src/templates/document-model/src/tests/module.test.js +0 -87
  499. package/dist/src/templates/document-model/src/tests/module.test.js.map +0 -1
  500. package/dist/src/templates/document-model/src/utils.d.ts +0 -2
  501. package/dist/src/templates/document-model/src/utils.d.ts.map +0 -1
  502. package/dist/src/templates/document-model/src/utils.js +0 -5
  503. package/dist/src/templates/document-model/src/utils.js.map +0 -1
  504. package/dist/src/templates/document-model/upgrades/upgrade-transition.d.ts +0 -7
  505. package/dist/src/templates/document-model/upgrades/upgrade-transition.d.ts.map +0 -1
  506. package/dist/src/templates/document-model/upgrades/upgrade-transition.js +0 -22
  507. package/dist/src/templates/document-model/upgrades/upgrade-transition.js.map +0 -1
  508. package/dist/src/templates/document-model/utils.d.ts +0 -3
  509. package/dist/src/templates/document-model/utils.d.ts.map +0 -1
  510. package/dist/src/templates/document-model/utils.js +0 -11
  511. package/dist/src/templates/document-model/utils.js.map +0 -1
  512. package/dist/src/templates/drive-editor/components/CreateDocument.d.ts +0 -2
  513. package/dist/src/templates/drive-editor/components/CreateDocument.d.ts.map +0 -1
  514. package/dist/src/templates/drive-editor/components/CreateDocument.js +0 -58
  515. package/dist/src/templates/drive-editor/components/CreateDocument.js.map +0 -1
  516. package/dist/src/templates/drive-editor/components/DriveContents.d.ts +0 -2
  517. package/dist/src/templates/drive-editor/components/DriveContents.d.ts.map +0 -1
  518. package/dist/src/templates/drive-editor/components/DriveContents.js +0 -24
  519. package/dist/src/templates/drive-editor/components/DriveContents.js.map +0 -1
  520. package/dist/src/templates/drive-editor/components/DriveExplorer.d.ts +0 -2
  521. package/dist/src/templates/drive-editor/components/DriveExplorer.d.ts.map +0 -1
  522. package/dist/src/templates/drive-editor/components/DriveExplorer.js +0 -32
  523. package/dist/src/templates/drive-editor/components/DriveExplorer.js.map +0 -1
  524. package/dist/src/templates/drive-editor/components/EmptyState.d.ts +0 -2
  525. package/dist/src/templates/drive-editor/components/EmptyState.d.ts.map +0 -1
  526. package/dist/src/templates/drive-editor/components/EmptyState.js +0 -19
  527. package/dist/src/templates/drive-editor/components/EmptyState.js.map +0 -1
  528. package/dist/src/templates/drive-editor/components/Files.d.ts +0 -2
  529. package/dist/src/templates/drive-editor/components/Files.d.ts.map +0 -1
  530. package/dist/src/templates/drive-editor/components/Files.js +0 -30
  531. package/dist/src/templates/drive-editor/components/Files.js.map +0 -1
  532. package/dist/src/templates/drive-editor/components/FolderTree.d.ts +0 -2
  533. package/dist/src/templates/drive-editor/components/FolderTree.d.ts.map +0 -1
  534. package/dist/src/templates/drive-editor/components/FolderTree.js +0 -108
  535. package/dist/src/templates/drive-editor/components/FolderTree.js.map +0 -1
  536. package/dist/src/templates/drive-editor/components/Folders.d.ts +0 -2
  537. package/dist/src/templates/drive-editor/components/Folders.d.ts.map +0 -1
  538. package/dist/src/templates/drive-editor/components/Folders.js +0 -28
  539. package/dist/src/templates/drive-editor/components/Folders.js.map +0 -1
  540. package/dist/src/templates/drive-editor/components/NavigationBreadcrumbs.d.ts +0 -2
  541. package/dist/src/templates/drive-editor/components/NavigationBreadcrumbs.d.ts.map +0 -1
  542. package/dist/src/templates/drive-editor/components/NavigationBreadcrumbs.js +0 -14
  543. package/dist/src/templates/drive-editor/components/NavigationBreadcrumbs.js.map +0 -1
  544. package/dist/src/templates/drive-editor/config.d.ts +0 -5
  545. package/dist/src/templates/drive-editor/config.d.ts.map +0 -1
  546. package/dist/src/templates/drive-editor/config.js +0 -11
  547. package/dist/src/templates/drive-editor/config.js.map +0 -1
  548. package/dist/src/templates/drive-editor/editor.d.ts +0 -2
  549. package/dist/src/templates/drive-editor/editor.d.ts.map +0 -1
  550. package/dist/src/templates/drive-editor/editor.js +0 -18
  551. package/dist/src/templates/drive-editor/editor.js.map +0 -1
  552. package/dist/src/templates/index.d.ts +0 -65
  553. package/dist/src/templates/index.d.ts.map +0 -1
  554. package/dist/src/templates/index.js +0 -65
  555. package/dist/src/templates/index.js.map +0 -1
  556. package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.d.ts +0 -2
  557. package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.d.ts.map +0 -1
  558. package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.js +0 -491
  559. package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.js.map +0 -1
  560. package/dist/src/ts-morph-generator/core/FileGenerator.d.ts +0 -11
  561. package/dist/src/ts-morph-generator/core/FileGenerator.d.ts.map +0 -1
  562. package/dist/src/ts-morph-generator/core/FileGenerator.js +0 -11
  563. package/dist/src/ts-morph-generator/core/FileGenerator.js.map +0 -1
  564. package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +0 -39
  565. package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +0 -1
  566. package/dist/src/ts-morph-generator/core/GenerationContext.js +0 -2
  567. package/dist/src/ts-morph-generator/core/GenerationContext.js.map +0 -1
  568. package/dist/src/ts-morph-generator/core/ReducerGenerator.d.ts +0 -12
  569. package/dist/src/ts-morph-generator/core/ReducerGenerator.d.ts.map +0 -1
  570. package/dist/src/ts-morph-generator/core/ReducerGenerator.js +0 -147
  571. package/dist/src/ts-morph-generator/core/ReducerGenerator.js.map +0 -1
  572. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +0 -20
  573. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +0 -1
  574. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +0 -120
  575. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +0 -1
  576. package/dist/src/ts-morph-generator/index.d.ts +0 -4
  577. package/dist/src/ts-morph-generator/index.d.ts.map +0 -1
  578. package/dist/src/ts-morph-generator/index.js +0 -4
  579. package/dist/src/ts-morph-generator/index.js.map +0 -1
  580. package/dist/src/ts-morph-generator/utilities/DeclarationManager.d.ts +0 -5
  581. package/dist/src/ts-morph-generator/utilities/DeclarationManager.d.ts.map +0 -1
  582. package/dist/src/ts-morph-generator/utilities/DeclarationManager.js +0 -10
  583. package/dist/src/ts-morph-generator/utilities/DeclarationManager.js.map +0 -1
  584. package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts +0 -13
  585. package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts.map +0 -1
  586. package/dist/src/ts-morph-generator/utilities/DirectoryManager.js +0 -45
  587. package/dist/src/ts-morph-generator/utilities/DirectoryManager.js.map +0 -1
  588. package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts +0 -15
  589. package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts.map +0 -1
  590. package/dist/src/ts-morph-generator/utilities/ImportManager.js +0 -50
  591. package/dist/src/ts-morph-generator/utilities/ImportManager.js.map +0 -1
  592. package/dist/src/ts-morph-generator/utilities/index.d.ts +0 -4
  593. package/dist/src/ts-morph-generator/utilities/index.d.ts.map +0 -1
  594. package/dist/src/ts-morph-generator/utilities/index.js +0 -4
  595. package/dist/src/ts-morph-generator/utilities/index.js.map +0 -1
  596. package/dist/src/utils/cli.d.ts +0 -26
  597. package/dist/src/utils/cli.d.ts.map +0 -1
  598. package/dist/src/utils/cli.js +0 -57
  599. package/dist/src/utils/cli.js.map +0 -1
  600. package/dist/src/utils/constants.d.ts +0 -13
  601. package/dist/src/utils/constants.d.ts.map +0 -1
  602. package/dist/src/utils/constants.js +0 -29
  603. package/dist/src/utils/constants.js.map +0 -1
  604. package/dist/src/utils/dependencies.d.ts +0 -12
  605. package/dist/src/utils/dependencies.d.ts.map +0 -1
  606. package/dist/src/utils/dependencies.js +0 -34
  607. package/dist/src/utils/dependencies.js.map +0 -1
  608. package/dist/src/utils/document-type-metadata.d.ts +0 -15
  609. package/dist/src/utils/document-type-metadata.d.ts.map +0 -1
  610. package/dist/src/utils/document-type-metadata.js +0 -67
  611. package/dist/src/utils/document-type-metadata.js.map +0 -1
  612. package/dist/src/utils/format-with-prettier.d.ts +0 -5
  613. package/dist/src/utils/format-with-prettier.d.ts.map +0 -1
  614. package/dist/src/utils/format-with-prettier.js +0 -20
  615. package/dist/src/utils/format-with-prettier.js.map +0 -1
  616. package/dist/src/utils/index.d.ts +0 -14
  617. package/dist/src/utils/index.d.ts.map +0 -1
  618. package/dist/src/utils/index.js +0 -14
  619. package/dist/src/utils/index.js.map +0 -1
  620. package/dist/src/utils/mock.d.ts +0 -3
  621. package/dist/src/utils/mock.d.ts.map +0 -1
  622. package/dist/src/utils/mock.js +0 -5
  623. package/dist/src/utils/mock.js.map +0 -1
  624. package/dist/src/utils/source-files.d.ts +0 -18
  625. package/dist/src/utils/source-files.d.ts.map +0 -1
  626. package/dist/src/utils/source-files.js +0 -39
  627. package/dist/src/utils/source-files.js.map +0 -1
  628. package/dist/src/utils/spawn-async.d.ts +0 -5
  629. package/dist/src/utils/spawn-async.d.ts.map +0 -1
  630. package/dist/src/utils/spawn-async.js +0 -29
  631. package/dist/src/utils/spawn-async.js.map +0 -1
  632. package/dist/src/utils/syntax-builders.d.ts +0 -8
  633. package/dist/src/utils/syntax-builders.d.ts.map +0 -1
  634. package/dist/src/utils/syntax-builders.js +0 -72
  635. package/dist/src/utils/syntax-builders.js.map +0 -1
  636. package/dist/src/utils/syntax-getters.d.ts +0 -9
  637. package/dist/src/utils/syntax-getters.d.ts.map +0 -1
  638. package/dist/src/utils/syntax-getters.js +0 -20
  639. package/dist/src/utils/syntax-getters.js.map +0 -1
  640. package/dist/src/utils/ts-morph-project.d.ts +0 -15
  641. package/dist/src/utils/ts-morph-project.d.ts.map +0 -1
  642. package/dist/src/utils/ts-morph-project.js +0 -28
  643. package/dist/src/utils/ts-morph-project.js.map +0 -1
  644. package/dist/src/utils/unsafe-utils.d.ts +0 -8
  645. package/dist/src/utils/unsafe-utils.d.ts.map +0 -1
  646. package/dist/src/utils/unsafe-utils.js +0 -23
  647. package/dist/src/utils/unsafe-utils.js.map +0 -1
  648. package/dist/src/utils/validation.d.ts +0 -18
  649. package/dist/src/utils/validation.d.ts.map +0 -1
  650. package/dist/src/utils/validation.js +0 -138
  651. package/dist/src/utils/validation.js.map +0 -1
  652. package/dist/tsconfig.tsbuildinfo +0 -1
  653. package/dist/vitest.config.d.ts +0 -3
  654. package/dist/vitest.config.d.ts.map +0 -1
  655. package/dist/vitest.config.js +0 -19
  656. package/dist/vitest.config.js.map +0 -1
@@ -0,0 +1,1675 @@
1
+ import { $ as documentModelGenActionsFileTemplate, A as makeActionImportNames, B as documentModelSchemaIndexTemplate, C as driveEditorDriveContentsFileTemplate, D as upgradeManifestTemplate, E as upgradeTransitionTemplate, F as documentModelModuleFileTemplate, G as documentModelOperationsModuleCreatorsFileTemplate, H as documentModelPhFactoriesFileTemplate, I as documentModelIndexTemplate, J as documentModelGenIndexFileTemplate, K as documentModelOperationModuleActionsFileTemplate, L as documentModelHooksFileTemplate, M as makeTestCaseForAction, N as documentModelTestFileTemplate, O as documentModelSrcUtilsTemplate, P as documentModelSrcIndexFileTemplate, Q as documentModelGenControllerFileTemplate, R as documentModelGenUtilsTemplate, S as driveExplorerFileTemplate, T as documentModelUtilsTemplate, U as documentModelOperationsModuleOperationsFileTemplate, V as documentModelGenReducerFileTemplate, W as documentModelOperationsModuleErrorFileTemplate, X as documentModelDocumentSchemaFileTemplate, Y as documentModelDocumentTypeTemplate, Z as documentModelGenCreatorsFileTemplate, _ as driveExplorerNavigationBreadcrumbsFileTemplate, a as subgraphLibFileTemplate, b as driveEditorFilesFileTemplate, c as relationalDbMigrationsTemplate, d as processorsIndexTemplate, et as documentModelRootActionsFileTemplate, f as processorsFactoryTemplate, g as driveEditorConfigFileTemplate, h as driveEditorEditorFileTemplate, i as customSubgraphSchemaTemplate, l as relationalDbIndexTemplate, m as analyticsFactoryTemplate, mt as packageJsonTemplate, n as documentModelSubgraphSchemaTemplate, nt as documentEditorEditorFileTemplate, o as subgraphIndexFileTemplate, p as analyticsIndexTemplate, r as customSubgraphResolversTemplate, rt as docsFromCliHelpTemplate, s as relationalDbSchemaTemplate, t as documentModelSubgraphResolversTemplate, tt as documentEditorModuleFileTemplate, u as relationalDbFactoryTemplate, v as folderTreeFileTemplate, w as createDocumentFileTemplate, x as emptyStateFileTemplate, y as driveEditorFoldersFileTemplate, z as documentModelGenTypesTemplate } from "./templates-BYDhXDXu.mjs";
2
+ import { getDocumentModelDirName, getDocumentModelOperationsModuleVariableNames, getDocumentModelVariableNames, getEditorVariableNames } from "./src/name-builders/index.mjs";
3
+ import { applyGraphQLTypePrefixes, buildObjectLiteral, buildTsMorphProject, ensureDirectoriesExist, extractTypeNames, formatSourceFileWithPrettier, getDocumentTypeMetadata, getInitialStates, getObjectLiteral, getOrCreateDirectory, getOrCreateSourceFile, getPreviousVersionSourceFile, getVariableDeclarationByTypeName } from "./src/utils/index.mjs";
4
+ import { VERSIONED_DEPENDENCIES, VERSIONED_DEV_DEPENDENCIES, directoryExists, fileExists, makeVersionedDependencies } from "@powerhousedao/shared/clis";
5
+ import { camelCase, kebabCase, pascalCase } from "change-case";
6
+ import fs, { copyFile, mkdir, readdir, rename, writeFile } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { stripVTControlCharacters } from "node:util";
9
+ import path$1 from "path";
10
+ import { ts } from "@tmpl/core";
11
+ import { IndentationText, Project, SyntaxKind, VariableDeclarationKind, ts as ts$1 } from "ts-morph";
12
+ import { format } from "prettier";
13
+ import { generate } from "@graphql-codegen/cli";
14
+ import { generatorTypeDefs, validationSchema } from "@powerhousedao/document-engineering/graphql";
15
+ import { existsSync } from "fs";
16
+ //#region src/file-builders/processors/analytics.ts
17
+ async function tsMorphGenerateAnalyticsProcessor(args) {
18
+ const { project, documentTypes, pascalCaseName, dirPath, camelCaseName } = args;
19
+ await makeIndexFile$1({
20
+ project,
21
+ pascalCaseName,
22
+ dirPath
23
+ });
24
+ await makeFactoryFile$1({
25
+ project,
26
+ pascalCaseName,
27
+ camelCaseName,
28
+ dirPath,
29
+ documentTypes
30
+ });
31
+ }
32
+ async function makeIndexFile$1(v) {
33
+ const template = analyticsIndexTemplate(v);
34
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "index.ts"));
35
+ if (alreadyExists) return;
36
+ sourceFile.replaceWithText(template);
37
+ await formatSourceFileWithPrettier(sourceFile);
38
+ }
39
+ async function makeFactoryFile$1(v) {
40
+ const template = analyticsFactoryTemplate(v);
41
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "factory.ts"));
42
+ if (alreadyExists) return;
43
+ sourceFile.replaceWithText(template);
44
+ await formatSourceFileWithPrettier(sourceFile);
45
+ }
46
+ //#endregion
47
+ //#region src/file-builders/processors/relational-db.ts
48
+ async function tsMorphGenerateRelationalDbProcessor(args) {
49
+ const { project, documentTypes, camelCaseName, pascalCaseName, dirPath } = args;
50
+ await makeIndexFile({
51
+ project,
52
+ pascalCaseName,
53
+ dirPath
54
+ });
55
+ await makeFactoryFile({
56
+ project,
57
+ pascalCaseName,
58
+ camelCaseName,
59
+ dirPath,
60
+ documentTypes
61
+ });
62
+ await makeMigrationsFile({
63
+ project,
64
+ dirPath
65
+ });
66
+ await makeSchemaFile({
67
+ project,
68
+ dirPath
69
+ });
70
+ }
71
+ async function makeIndexFile(v) {
72
+ const template = relationalDbIndexTemplate(v);
73
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "index.ts"));
74
+ if (alreadyExists) return;
75
+ sourceFile.replaceWithText(template);
76
+ await formatSourceFileWithPrettier(sourceFile);
77
+ }
78
+ async function makeFactoryFile(v) {
79
+ const template = relationalDbFactoryTemplate(v);
80
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "factory.ts"));
81
+ if (alreadyExists) return;
82
+ sourceFile.replaceWithText(template);
83
+ await formatSourceFileWithPrettier(sourceFile);
84
+ }
85
+ async function makeSchemaFile(v) {
86
+ const template = relationalDbSchemaTemplate();
87
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "schema.ts"));
88
+ if (alreadyExists) return;
89
+ sourceFile.replaceWithText(template);
90
+ await formatSourceFileWithPrettier(sourceFile);
91
+ }
92
+ async function makeMigrationsFile(v) {
93
+ const template = relationalDbMigrationsTemplate();
94
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(v.project, path$1.join(v.dirPath, "migrations.ts"));
95
+ if (alreadyExists) return;
96
+ sourceFile.replaceWithText(template);
97
+ await formatSourceFileWithPrettier(sourceFile);
98
+ }
99
+ //#endregion
100
+ //#region src/file-builders/processors/processor.ts
101
+ async function tsMorphGenerateProcessor(args) {
102
+ const { processorName, documentTypes, rootDir, processorType, processorApps } = args;
103
+ const kebabCaseName = kebabCase(processorName);
104
+ const camelCaseName = camelCase(processorName);
105
+ const pascalCaseName = pascalCase(processorName);
106
+ const processorsDirPath = path$1.join(rootDir, "processors");
107
+ const dirPath = path$1.join(processorsDirPath, kebabCaseName);
108
+ const sourceFilesPath = path$1.join(processorsDirPath, "**/*");
109
+ const project = buildTsMorphProject(rootDir);
110
+ await ensureDirectoriesExist(project, processorsDirPath, dirPath);
111
+ project.addSourceFilesAtPaths(sourceFilesPath);
112
+ if (processorType === "analytics") await tsMorphGenerateAnalyticsProcessor({
113
+ processorName,
114
+ documentTypes,
115
+ rootDir,
116
+ camelCaseName,
117
+ dirPath,
118
+ kebabCaseName,
119
+ pascalCaseName,
120
+ processorsDirPath,
121
+ project
122
+ });
123
+ else await tsMorphGenerateRelationalDbProcessor({
124
+ processorName,
125
+ documentTypes,
126
+ rootDir,
127
+ camelCaseName,
128
+ dirPath,
129
+ kebabCaseName,
130
+ pascalCaseName,
131
+ processorsDirPath,
132
+ project
133
+ });
134
+ await updateIndexFile({
135
+ processorsDirPath,
136
+ project
137
+ });
138
+ for (const processorApp of processorApps) {
139
+ await updateFactoryFile({
140
+ processorsDirPath,
141
+ project,
142
+ camelCaseName,
143
+ dirPath,
144
+ processorApp
145
+ });
146
+ await updateAppProcessorsFile({
147
+ processorsDirPath,
148
+ processorApp,
149
+ project,
150
+ dirPath,
151
+ pascalCaseName,
152
+ camelCaseName
153
+ });
154
+ }
155
+ await project.save();
156
+ }
157
+ async function updateAppProcessorsFile(args) {
158
+ const { project, processorsDirPath, processorApp, dirPath, pascalCaseName, camelCaseName } = args;
159
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(processorsDirPath, `${processorApp}.ts`));
160
+ const processorClassName = `${pascalCaseName}Processor`;
161
+ const processorClassModuleSpecifier = `./${path$1.join(path$1.basename(dirPath), "index.js")}`;
162
+ const processorFactoryName = `${camelCaseName}ProcessorFactory`;
163
+ const processorFactoryModuleSpecifier = `./${path$1.join(path$1.basename(dirPath), "factory.js")}`;
164
+ const exportedNames = sourceFile.getExportDeclarations().flatMap((e) => e.getNamedExports().map((n) => n.getText()));
165
+ if (!exportedNames.includes(processorClassName)) sourceFile.addExportDeclaration({
166
+ namedExports: [processorClassName],
167
+ moduleSpecifier: processorClassModuleSpecifier
168
+ });
169
+ if (!exportedNames.includes(processorFactoryName)) sourceFile.addExportDeclaration({
170
+ namedExports: [processorFactoryName],
171
+ moduleSpecifier: processorFactoryModuleSpecifier
172
+ });
173
+ await formatSourceFileWithPrettier(sourceFile);
174
+ }
175
+ async function updateIndexFile(v) {
176
+ const { project, processorsDirPath } = v;
177
+ const template = processorsIndexTemplate;
178
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(processorsDirPath, "index.ts"));
179
+ if (!alreadyExists) sourceFile.replaceWithText(template);
180
+ if (!sourceFile.getExportDeclarations().flatMap((e) => e.getNamedExports().map((n) => n.getText())).includes("processorFactory")) sourceFile.addExportDeclaration({
181
+ namedExports: ["processorFactory"],
182
+ moduleSpecifier: "./factory.ts"
183
+ });
184
+ await formatSourceFileWithPrettier(sourceFile);
185
+ }
186
+ async function updateFactoryFile(v) {
187
+ const { project, processorsDirPath, processorApp, dirPath, camelCaseName } = v;
188
+ const template = processorsFactoryTemplate;
189
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(processorsDirPath, "factory.ts"));
190
+ if (!alreadyExists) sourceFile.replaceWithText(template);
191
+ const processorFactoryName = `${camelCaseName}ProcessorFactory`;
192
+ const processorFactoryModuleSpecifier = `./${path$1.join(path$1.basename(dirPath), "factory.js")}`;
193
+ const addFactoriesFunctionName = camelCase(`add_${processorApp}_ProcessorFactories`);
194
+ const factoriesArrayName = camelCase(`${processorApp}ProcessorFactories`);
195
+ const functionBody = sourceFile.getFunctionOrThrow(addFactoriesFunctionName).getBodyOrThrow().asKindOrThrow(ts$1.SyntaxKind.Block);
196
+ const factoriesArray = functionBody.getDescendantsOfKind(ts$1.SyntaxKind.VariableStatement).flatMap((d) => d.getDescendantsOfKind(ts$1.SyntaxKind.VariableDeclaration)).find((d) => d.getName() === factoriesArrayName)?.getDescendantsOfKind(ts$1.SyntaxKind.ArrayLiteralExpression).at(0);
197
+ if (!factoriesArray) throw new Error(`"${factoriesArrayName}" array is missing in "${addFactoriesFunctionName}"`);
198
+ const factoryFunctionInvocation = `${processorFactoryName}(module)`;
199
+ if (!factoriesArray.getElements().map((e) => e.getText()).includes(factoryFunctionInvocation)) {
200
+ functionBody.insertStatements(0, `const { ${processorFactoryName} } = await import("${processorFactoryModuleSpecifier}");`);
201
+ factoriesArray.addElement(factoryFunctionInvocation);
202
+ }
203
+ await formatSourceFileWithPrettier(sourceFile);
204
+ }
205
+ //#endregion
206
+ //#region src/codegen/graphql.ts
207
+ const getDirectories = async (source) => {
208
+ return (await fs.readdir(source, { withFileTypes: true })).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent);
209
+ };
210
+ const scalars = {
211
+ Unknown: "unknown",
212
+ DateTime: "string",
213
+ Attachment: "string",
214
+ Address: "`${string}:0x${string}`",
215
+ ...generatorTypeDefs
216
+ };
217
+ const scalarsValidation = {
218
+ Unknown: "z.unknown()",
219
+ DateTime: "z.string().datetime()",
220
+ Attachment: "z.string()",
221
+ Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
222
+ ...validationSchema
223
+ };
224
+ const avoidOptionals = {
225
+ field: true,
226
+ inputValue: false
227
+ };
228
+ const maybeValue = "T | null | undefined";
229
+ const typescriptConfig = {
230
+ avoidOptionals,
231
+ scalars,
232
+ strictScalars: true,
233
+ enumsAsTypes: true,
234
+ skipTypename: true,
235
+ maybeValue
236
+ };
237
+ const validationSchemaConfig = {
238
+ avoidOptionals,
239
+ scalars,
240
+ strictScalars: true,
241
+ enumsAsTypes: true,
242
+ skipTypename: true,
243
+ importFrom: `./types.js`,
244
+ schema: "zodv4",
245
+ useTypeImports: true,
246
+ scalarSchemas: scalarsValidation,
247
+ directives: { equals: { value: ["regex", "/^$1$/"] } },
248
+ withObjectType: true,
249
+ maybeValue
250
+ };
251
+ function buildSchemasForModules(modules) {
252
+ const schemaStrings = [];
253
+ for (const module of modules) {
254
+ schemaStrings.push(`# ${module.name}`);
255
+ const operationsSchemas = module.operations.map((operation) => operation.schema).filter((schema) => schema !== null);
256
+ schemaStrings.push(...operationsSchemas);
257
+ }
258
+ return schemaStrings;
259
+ }
260
+ function buildGraphqlDocumentStringForSpecification(specification) {
261
+ const customScalarSchemas = Object.keys(scalars).map((k) => `scalar ${k}`).join("\n");
262
+ const stateSchemas = Object.values(specification.state).map((state) => state.schema);
263
+ const moduleSchemas = buildSchemasForModules(specification.modules);
264
+ return [
265
+ customScalarSchemas,
266
+ ...stateSchemas,
267
+ ...moduleSchemas
268
+ ];
269
+ }
270
+ async function formatContentWithPrettier(path, content) {
271
+ return await format(content, { parser: "typescript" });
272
+ }
273
+ async function generateTypesAndZodSchemasFromGraphql(args) {
274
+ const { dirName, schema, skipFormat, writeFile, watch } = args;
275
+ await generate({
276
+ overwrite: true,
277
+ watch,
278
+ hooks: { beforeOneFileWrite: skipFormat ? void 0 : formatContentWithPrettier },
279
+ generates: {
280
+ [`${dirName}/gen/schema/types.ts`]: {
281
+ schema,
282
+ config: typescriptConfig,
283
+ plugins: [{ typescript: typescriptConfig }]
284
+ },
285
+ [`${dirName}/gen/schema/zod.ts`]: {
286
+ schema,
287
+ config: validationSchemaConfig,
288
+ plugins: [{ add: { content: "/* eslint-disable @typescript-eslint/no-empty-object-type */" } }, { "graphql-codegen-typescript-validation-schema": validationSchemaConfig }]
289
+ }
290
+ }
291
+ }, writeFile);
292
+ }
293
+ async function generateDocumentModelZodSchemas(args) {
294
+ const { documentModelDirPath, specification, writeFile = true, skipFormat = false, watch = false } = args;
295
+ const schema = buildGraphqlDocumentStringForSpecification(specification).filter(Boolean).join("\n\n");
296
+ await generateTypesAndZodSchemasFromGraphql({
297
+ dirName: documentModelDirPath,
298
+ schema,
299
+ writeFile,
300
+ skipFormat,
301
+ watch
302
+ });
303
+ await fs.writeFile(path.join(documentModelDirPath, "schema.graphql"), schema);
304
+ }
305
+ const generateSchemas = async (inDir, { watch = false, skipFormat = false, writeFile = true, outDir = inDir } = {}) => {
306
+ const dirs = await getDirectories(inDir);
307
+ const inputs = await Promise.all(dirs.map(async (dir) => {
308
+ const documentModelJsonFile = await fs.readFile(path.join(dir.parentPath, dir.name, `${dir.name}.json`), "utf-8");
309
+ const parsedJson = JSON.parse(documentModelJsonFile);
310
+ const latestSpecification = parsedJson.specifications[parsedJson.specifications.length - 1];
311
+ const schema = buildGraphqlDocumentStringForSpecification(latestSpecification).filter(Boolean).join("\n\n");
312
+ return {
313
+ dirName: path.join(outDir, dir.name),
314
+ schema
315
+ };
316
+ }));
317
+ await Promise.all(inputs.map(async ({ schema, dirName }) => {
318
+ await generateTypesAndZodSchemasFromGraphql({
319
+ schema,
320
+ dirName,
321
+ writeFile,
322
+ skipFormat,
323
+ watch
324
+ });
325
+ }));
326
+ };
327
+ //#endregion
328
+ //#region src/file-builders/boilerplate/package.json.ts
329
+ async function buildBoilerplatePackageJson(args) {
330
+ const { name, tag, version, workspace } = args;
331
+ return packageJsonTemplate(name, await makeVersionedDependencies({
332
+ names: VERSIONED_DEPENDENCIES,
333
+ tag,
334
+ version
335
+ }), await makeVersionedDependencies({
336
+ names: VERSIONED_DEV_DEPENDENCIES,
337
+ tag,
338
+ version
339
+ }));
340
+ }
341
+ //#endregion
342
+ //#region src/file-builders/clis/generate-cli-docs.ts
343
+ function getCommandHelpInfo(entry) {
344
+ return {
345
+ name: entry.name,
346
+ description: entry.command.description ?? "",
347
+ helpTopics: entry.command.helpTopics?.() ?? []
348
+ };
349
+ }
350
+ function getCommandsHelpInfo(entries) {
351
+ return entries.map(getCommandHelpInfo);
352
+ }
353
+ function makeCliDocsFromHelp(args) {
354
+ const { cliDescription, docsIntroduction, docsTitle, entries } = args;
355
+ return stripVTControlCharacters(docsFromCliHelpTemplate({
356
+ cliDescription,
357
+ docsIntroduction,
358
+ docsTitle,
359
+ commandsHelpInfo: getCommandsHelpInfo(entries)
360
+ }));
361
+ }
362
+ async function writeCliDocsMarkdownFile(args) {
363
+ const { filePath, ...restArgs } = args;
364
+ await writeFile(filePath, makeCliDocsFromHelp(restArgs), { encoding: "utf-8" });
365
+ }
366
+ //#endregion
367
+ //#region src/file-builders/editor-common.ts
368
+ /** Generates the `module.ts` file for a document editor or drive editor */
369
+ function makeEditorModuleFile({ project, editorDirPath, editorName, documentModelId, editorId, legacyMultipleDocumentTypes }) {
370
+ if (documentModelId && !!legacyMultipleDocumentTypes) throw new Error("Cannot specify both documentModelId and legacyMultipleDocumentTypes");
371
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "module.ts"));
372
+ sourceFile.replaceWithText("");
373
+ const template = documentEditorModuleFileTemplate({
374
+ editorName,
375
+ editorId,
376
+ pascalCaseEditorName: pascalCase(editorName),
377
+ documentTypes: documentModelId ? `["${documentModelId}"]` : JSON.stringify(legacyMultipleDocumentTypes)
378
+ });
379
+ sourceFile.replaceWithText(template);
380
+ }
381
+ //#endregion
382
+ //#region src/file-builders/index-files.ts
383
+ /**
384
+ * Makes a legacy index.ts file for the modules file which exports the modules as individual exports instead of an array of named exports.
385
+ */
386
+ function makeLegacyIndexFile({ project, modulesDirPath, modules }) {
387
+ const indexSourceFilePath = path.join(modulesDirPath, "index.ts");
388
+ let indexSourceFile = project.getSourceFile(indexSourceFilePath);
389
+ if (!indexSourceFile) indexSourceFile = project.createSourceFile(indexSourceFilePath, "");
390
+ else indexSourceFile.replaceWithText("");
391
+ indexSourceFile.addExportDeclarations(modules.map(({ versionedName, unversionedName, moduleSpecifier }) => ({
392
+ namedExports: [versionedName ? `${unversionedName} as ${versionedName}` : unversionedName],
393
+ moduleSpecifier
394
+ })));
395
+ }
396
+ //#endregion
397
+ //#region src/file-builders/module-files.ts
398
+ /**
399
+ * Makes a file which exports the modules from the module.ts files in the given directory as a variable declaration.
400
+ */
401
+ async function makeModulesFile({ project, modulesDirPath, outputFileName, typeName, variableName, variableType, shouldMakeLegacyIndexFile = true, moduleFileName = "module.ts" }) {
402
+ await ensureDirectoriesExist(project, modulesDirPath);
403
+ const modulesSourceFilesPath = path.join(modulesDirPath, "**/*");
404
+ project.addSourceFilesAtPaths(modulesSourceFilesPath);
405
+ const { directory: modulesDir } = getOrCreateDirectory(project, modulesDirPath);
406
+ const modules = modulesDir.getDescendantSourceFiles().filter((file) => file.getBaseName().includes(moduleFileName)).map((file) => getVariableDeclarationByTypeName(file, typeName)).filter((v) => v !== void 0).map((module) => {
407
+ const sourceFile = module.getSourceFile();
408
+ const moduleSpecifier = modulesDir.getRelativePathAsModuleSpecifierTo(sourceFile.getFilePath()) + ".js";
409
+ const versionDir = getVersionDirFromModuleSpecifier(moduleSpecifier);
410
+ const unversionedName = module.getName();
411
+ return {
412
+ versionedName: versionDir ? `${unversionedName}${pascalCase(versionDir)}` : void 0,
413
+ unversionedName,
414
+ moduleSpecifier
415
+ };
416
+ });
417
+ const { sourceFile: moduleExportsSourceFile } = getOrCreateSourceFile(project, path.join(modulesDirPath, outputFileName));
418
+ moduleExportsSourceFile.replaceWithText("");
419
+ const importDeclarations = [{
420
+ namedImports: [typeName],
421
+ moduleSpecifier: "document-model",
422
+ isTypeOnly: true
423
+ }, ...modules.map(({ versionedName, unversionedName, moduleSpecifier }) => ({
424
+ namedImports: [versionedName ? `${unversionedName} as ${versionedName}` : unversionedName],
425
+ moduleSpecifier
426
+ }))];
427
+ for (const declaration of importDeclarations) if (!moduleExportsSourceFile.getImportDeclaration((importDeclaration) => importDeclaration.getNamedImports().some((importSpecifier) => declaration.namedImports.includes(importSpecifier.getName())))) moduleExportsSourceFile.addImportDeclaration(declaration);
428
+ const moduleExportsVariableStatementInput = {
429
+ isExported: true,
430
+ declarationKind: VariableDeclarationKind.Const,
431
+ declarations: [{
432
+ name: variableName,
433
+ type: variableType,
434
+ initializer: `[]`
435
+ }]
436
+ };
437
+ let moduleExportsVariableStatement = moduleExportsSourceFile.getVariableStatement(variableName);
438
+ if (!moduleExportsVariableStatement) moduleExportsVariableStatement = moduleExportsSourceFile.addVariableStatement(moduleExportsVariableStatementInput);
439
+ else moduleExportsVariableStatement.set(moduleExportsVariableStatementInput);
440
+ (moduleExportsVariableStatement.getDeclarations().at(0)?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression))?.addElements(modules.map((module) => module.versionedName ?? module.unversionedName), { useNewLines: true });
441
+ if (shouldMakeLegacyIndexFile) makeLegacyIndexFile({
442
+ project,
443
+ modulesDirPath,
444
+ modules
445
+ });
446
+ await project.save();
447
+ }
448
+ async function makeUpgradeManifestsFile(args) {
449
+ const { project, projectDir } = args;
450
+ await makeModulesFile({
451
+ project,
452
+ modulesDirPath: path.join(projectDir, "document-models"),
453
+ outputFileName: "upgrade-manifests.ts",
454
+ typeName: "UpgradeManifest",
455
+ variableName: "upgradeManifests",
456
+ variableType: "UpgradeManifest<readonly number[]>[]",
457
+ moduleFileName: "upgrade-manifest.ts",
458
+ shouldMakeLegacyIndexFile: false
459
+ });
460
+ }
461
+ /** Generates the `document-models.ts` file which exports the document models defined in each document model dir's `module.ts` file */
462
+ async function makeDocumentModelModulesFile({ project, projectDir }) {
463
+ await makeModulesFile({
464
+ project,
465
+ modulesDirPath: path.join(projectDir, "document-models"),
466
+ outputFileName: "document-models.ts",
467
+ typeName: "DocumentModelModule",
468
+ variableName: "documentModels",
469
+ variableType: "DocumentModelModule<any>[]"
470
+ });
471
+ }
472
+ /** Generates the `editors.ts` file which exports the editors defined in each editor dir's `module.ts` file */
473
+ async function makeEditorsModulesFile(project, projectDir) {
474
+ await makeModulesFile({
475
+ project,
476
+ modulesDirPath: path.join(projectDir, "editors"),
477
+ outputFileName: "editors.ts",
478
+ typeName: "EditorModule",
479
+ variableName: "editors",
480
+ variableType: "EditorModule[]"
481
+ });
482
+ }
483
+ function getVersionDirFromModuleSpecifier(moduleSpecifier) {
484
+ return moduleSpecifier.match(/\/(v\d+)(?=\/)/)?.[1];
485
+ }
486
+ /**
487
+ * Adds the upgradeManifests export to an existing document-models.ts file.
488
+ * Searches for upgrade-manifest.ts files in each document model's upgrades directory,
489
+ * adds imports for each, and creates the upgradeManifests array export.
490
+ */
491
+ function makeUpgradeManifestsExport({ project, modulesDirPath, outputFilePath, variableName, variableType, typeName }) {
492
+ const absoluteModulesDirPath = path.resolve(modulesDirPath);
493
+ const absoluteOutputFilePath = path.resolve(outputFilePath);
494
+ const upgradeManifestGlob = `${absoluteModulesDirPath}/**/upgrade-manifest.ts`;
495
+ project.addSourceFilesAtPaths(upgradeManifestGlob);
496
+ const upgradeManifestFiles = project.getSourceFiles().filter((file) => file.getFilePath().includes("upgrade-manifest.ts")).filter((file) => file.getFilePath().startsWith(absoluteModulesDirPath));
497
+ if (upgradeManifestFiles.length === 0) return;
498
+ let outputSourceFile = project.getSourceFile(absoluteOutputFilePath);
499
+ if (outputSourceFile) outputSourceFile.refreshFromFileSystemSync();
500
+ else {
501
+ project.addSourceFilesAtPaths(absoluteOutputFilePath);
502
+ outputSourceFile = project.getSourceFile(absoluteOutputFilePath);
503
+ }
504
+ if (!outputSourceFile) return;
505
+ const modulesDir = project.getDirectory(absoluteModulesDirPath);
506
+ if (!modulesDir) return;
507
+ const manifests = upgradeManifestFiles.map((file) => {
508
+ const filePath = file.getFilePath();
509
+ const pathParts = filePath.split("/");
510
+ const upgradesIndex = pathParts.indexOf("upgrades");
511
+ const documentModelName = upgradesIndex > 0 ? pathParts[upgradesIndex - 1] : "unknown";
512
+ const moduleSpecifier = modulesDir.getRelativePathAsModuleSpecifierTo(filePath) + ".js";
513
+ return {
514
+ originalName: "upgradeManifest",
515
+ aliasedName: `${camelCase(documentModelName)}UpgradeManifest`,
516
+ moduleSpecifier
517
+ };
518
+ });
519
+ const existingTypeImport = outputSourceFile.getImportDeclarations().find((imp) => imp.getModuleSpecifierValue() === "document-model" && imp.isTypeOnly());
520
+ if (existingTypeImport) {
521
+ if (!existingTypeImport.getNamedImports().some((ni) => ni.getName() === typeName)) existingTypeImport.addNamedImport(typeName);
522
+ }
523
+ const existingImports = outputSourceFile.getImportDeclarations();
524
+ const lastImport = existingImports[existingImports.length - 1];
525
+ if (lastImport) {
526
+ const insertText = "\n" + manifests.map(({ originalName, aliasedName, moduleSpecifier }) => `import { ${originalName} as ${aliasedName} } from "${moduleSpecifier}";`).join("\n");
527
+ const insertPos = lastImport.getEnd();
528
+ outputSourceFile.insertText(insertPos, insertText);
529
+ }
530
+ const variableStatementInput = {
531
+ isExported: true,
532
+ declarationKind: VariableDeclarationKind.Const,
533
+ declarations: [{
534
+ name: variableName,
535
+ type: variableType,
536
+ initializer: `[]`
537
+ }]
538
+ };
539
+ (outputSourceFile.addVariableStatement(variableStatementInput).getDeclarations().at(0)?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression))?.addElements(manifests.map((m) => m.aliasedName), { useNewLines: true });
540
+ }
541
+ //#endregion
542
+ //#region src/file-builders/document-editor.ts
543
+ /** Generates a document editor for the given `documentModelId` (also called `documentType`) */
544
+ async function tsMorphGenerateDocumentEditor({ packageName, projectDir, editorDir, editorName, editorId, documentModelId }) {
545
+ const documentModelsDirPath = path$1.join(projectDir, "document-models");
546
+ const editorsDirPath = path$1.join(projectDir, "editors");
547
+ const editorDirPath = path$1.join(editorsDirPath, editorDir);
548
+ const componentsDirPath = path$1.join(editorDirPath, "components");
549
+ const editorSourceFilesPath = path$1.join(editorsDirPath, "/**/*");
550
+ const documentModelsSourceFilesPath = path$1.join(documentModelsDirPath, "/**/*");
551
+ const project = buildTsMorphProject(projectDir);
552
+ await ensureDirectoriesExist(project, documentModelsDirPath, editorsDirPath, editorDirPath, componentsDirPath);
553
+ project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
554
+ project.addSourceFilesAtPaths(editorSourceFilesPath);
555
+ const documentTypeMetadata = getDocumentTypeMetadata({
556
+ project,
557
+ packageName,
558
+ documentModelId,
559
+ documentModelsDirPath
560
+ });
561
+ const editorVariableNames = getEditorVariableNames(documentTypeMetadata);
562
+ await makeEditorComponent({
563
+ project,
564
+ editorDirPath,
565
+ ...documentTypeMetadata,
566
+ ...editorVariableNames
567
+ });
568
+ makeEditorModuleFile({
569
+ project,
570
+ editorName,
571
+ editorId,
572
+ documentModelId,
573
+ editorDirPath
574
+ });
575
+ await makeEditorsModulesFile(project, projectDir);
576
+ await project.save();
577
+ }
578
+ async function makeEditorComponent(args) {
579
+ const { project, editorDirPath } = args;
580
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "editor.tsx"));
581
+ if (alreadyExists) {
582
+ const functionDeclaration = sourceFile.getFunction("Editor");
583
+ if (functionDeclaration) {
584
+ if (!functionDeclaration.isDefaultExport()) functionDeclaration.setIsDefaultExport(true);
585
+ return;
586
+ }
587
+ }
588
+ const template = documentEditorEditorFileTemplate(args);
589
+ sourceFile.replaceWithText(template);
590
+ await formatSourceFileWithPrettier(sourceFile);
591
+ }
592
+ //#endregion
593
+ //#region src/file-builders/document-model/gen-dir.ts
594
+ async function makeGenDirFiles(fileMakerArgs) {
595
+ await makeDocumentModelSchemaIndexFile(fileMakerArgs);
596
+ await makeDocumentModelGenUtilsFile(fileMakerArgs);
597
+ await makeDocumentModelGenTypesFile(fileMakerArgs);
598
+ await makeDocumentModelGenCreatorsFile(fileMakerArgs);
599
+ await makeDocumentModelGenActionsFile(fileMakerArgs);
600
+ await makeDocumentModelGenDocumentSchemaFile(fileMakerArgs);
601
+ await makeDocumentModelGenReducerFile(fileMakerArgs);
602
+ await makeDocumentModelDocumentTypeFile(fileMakerArgs);
603
+ await makeDocumentModelGenIndexFile(fileMakerArgs);
604
+ await makeDocumentModelGenDocumentModelFile(fileMakerArgs);
605
+ await makeDocumentModelGenPhFactoriesFile(fileMakerArgs);
606
+ await makeDocumentModelGenControllerFile(fileMakerArgs);
607
+ const modules = fileMakerArgs.modules;
608
+ for (const module of modules) {
609
+ const operationsModuleVariableNames = getDocumentModelOperationsModuleVariableNames(module);
610
+ await makeGenDirOperationModuleFiles({
611
+ module,
612
+ ...fileMakerArgs,
613
+ ...operationsModuleVariableNames
614
+ });
615
+ }
616
+ }
617
+ async function makeGenDirOperationModuleFiles(fileMakerArgs) {
618
+ await makeOperationModuleGenActionsFile(fileMakerArgs);
619
+ await makeOperationModuleGenCreatorsFile(fileMakerArgs);
620
+ await makeOperationModuleGenOperationsFile(fileMakerArgs);
621
+ await makeOperationModuleGenErrorFile(fileMakerArgs);
622
+ }
623
+ async function makeDocumentModelGenUtilsFile(args) {
624
+ const template = documentModelGenUtilsTemplate(args);
625
+ const { project, genDirPath } = args;
626
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "utils.ts"));
627
+ sourceFile.replaceWithText(template);
628
+ await formatSourceFileWithPrettier(sourceFile);
629
+ }
630
+ async function makeDocumentModelDocumentTypeFile(args) {
631
+ const template = documentModelDocumentTypeTemplate(args);
632
+ const { project, genDirPath } = args;
633
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "document-type.ts"));
634
+ sourceFile.replaceWithText(template);
635
+ await formatSourceFileWithPrettier(sourceFile);
636
+ }
637
+ async function makeDocumentModelSchemaIndexFile(args) {
638
+ const template = documentModelSchemaIndexTemplate;
639
+ const { project, schemaDirPath } = args;
640
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(schemaDirPath, "index.ts"));
641
+ sourceFile.replaceWithText(template);
642
+ await formatSourceFileWithPrettier(sourceFile);
643
+ }
644
+ async function makeDocumentModelGenTypesFile(args) {
645
+ const template = documentModelGenTypesTemplate(args);
646
+ const { project, genDirPath } = args;
647
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "types.ts"));
648
+ sourceFile.replaceWithText(template);
649
+ await formatSourceFileWithPrettier(sourceFile);
650
+ }
651
+ async function makeDocumentModelGenDocumentModelFile(args) {
652
+ const { project, genDirPath, documentModelState } = args;
653
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "document-model.ts"));
654
+ sourceFile.replaceWithText("");
655
+ sourceFile.addImportDeclaration({
656
+ namedImports: ["DocumentModelGlobalState"],
657
+ moduleSpecifier: "document-model",
658
+ isTypeOnly: true
659
+ });
660
+ const documentModelStateString = buildObjectLiteral(documentModelState, sourceFile);
661
+ sourceFile.addVariableStatement({
662
+ declarationKind: VariableDeclarationKind.Const,
663
+ isExported: true,
664
+ declarations: [{
665
+ name: "documentModel",
666
+ type: "DocumentModelGlobalState",
667
+ initializer: documentModelStateString
668
+ }]
669
+ });
670
+ await formatSourceFileWithPrettier(sourceFile);
671
+ }
672
+ async function makeDocumentModelGenDocumentSchemaFile(args) {
673
+ const template = documentModelDocumentSchemaFileTemplate(args);
674
+ const { project, genDirPath } = args;
675
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "document-schema.ts"));
676
+ sourceFile.replaceWithText(template);
677
+ await formatSourceFileWithPrettier(sourceFile);
678
+ }
679
+ async function makeDocumentModelGenCreatorsFile(args) {
680
+ const template = documentModelGenCreatorsFileTemplate(args);
681
+ const { project, genDirPath } = args;
682
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "creators.ts"));
683
+ sourceFile.replaceWithText(template);
684
+ await formatSourceFileWithPrettier(sourceFile);
685
+ }
686
+ async function makeDocumentModelGenPhFactoriesFile(args) {
687
+ const template = documentModelPhFactoriesFileTemplate(args);
688
+ const { project, genDirPath } = args;
689
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "ph-factories.ts"));
690
+ sourceFile.replaceWithText(template);
691
+ await formatSourceFileWithPrettier(sourceFile);
692
+ }
693
+ async function makeDocumentModelGenControllerFile(args) {
694
+ const template = documentModelGenControllerFileTemplate(args);
695
+ const { project, genDirPath } = args;
696
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "controller.ts"));
697
+ sourceFile.replaceWithText(template);
698
+ await formatSourceFileWithPrettier(sourceFile);
699
+ }
700
+ async function makeDocumentModelGenIndexFile(args) {
701
+ const template = documentModelGenIndexFileTemplate(args);
702
+ const { project, genDirPath } = args;
703
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "index.ts"));
704
+ sourceFile.replaceWithText(template);
705
+ await formatSourceFileWithPrettier(sourceFile);
706
+ }
707
+ async function makeDocumentModelGenActionsFile(args) {
708
+ const template = documentModelGenActionsFileTemplate(args);
709
+ const { project, genDirPath } = args;
710
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "actions.ts"));
711
+ sourceFile.replaceWithText(template);
712
+ await formatSourceFileWithPrettier(sourceFile);
713
+ }
714
+ async function makeDocumentModelGenReducerFile(args) {
715
+ const template = documentModelGenReducerFileTemplate(args);
716
+ const { project, genDirPath } = args;
717
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(genDirPath, "reducer.ts"));
718
+ sourceFile.replaceWithText(template);
719
+ await formatSourceFileWithPrettier(sourceFile);
720
+ }
721
+ async function makeOperationModuleGenActionsFile(args) {
722
+ const { module } = args;
723
+ const { actions } = getDocumentModelOperationsModuleVariableNames(module);
724
+ const pascalCaseModuleName = pascalCase(module.name);
725
+ const kebabCaseModuleName = kebabCase(module.name);
726
+ const template = documentModelOperationModuleActionsFileTemplate({
727
+ ...args,
728
+ actions,
729
+ pascalCaseModuleName
730
+ });
731
+ const { project, genDirPath } = args;
732
+ const dirPath = path$1.join(genDirPath, kebabCaseModuleName);
733
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "actions.ts"));
734
+ sourceFile.replaceWithText(template);
735
+ await formatSourceFileWithPrettier(sourceFile);
736
+ }
737
+ async function makeOperationModuleGenCreatorsFile(args) {
738
+ const { module } = args;
739
+ const moduleVariableNames = getDocumentModelOperationsModuleVariableNames(module);
740
+ const kebabCaseModuleName = kebabCase(module.name);
741
+ const template = documentModelOperationsModuleCreatorsFileTemplate({
742
+ ...args,
743
+ ...moduleVariableNames
744
+ });
745
+ const { project, genDirPath } = args;
746
+ const dirPath = path$1.join(genDirPath, kebabCaseModuleName);
747
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "creators.ts"));
748
+ sourceFile.replaceWithText(template);
749
+ await formatSourceFileWithPrettier(sourceFile);
750
+ }
751
+ async function makeOperationModuleGenOperationsFile(args) {
752
+ const { module } = args;
753
+ const moduleVariableNames = getDocumentModelOperationsModuleVariableNames(module);
754
+ const kebabCaseModuleName = kebabCase(module.name);
755
+ const template = documentModelOperationsModuleOperationsFileTemplate({
756
+ ...args,
757
+ ...moduleVariableNames
758
+ });
759
+ const { project, genDirPath } = args;
760
+ const dirPath = path$1.join(genDirPath, kebabCaseModuleName);
761
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "operations.ts"));
762
+ sourceFile.replaceWithText(template);
763
+ await formatSourceFileWithPrettier(sourceFile);
764
+ }
765
+ async function makeOperationModuleGenErrorFile(args) {
766
+ const { module } = args;
767
+ const moduleVariableNames = getDocumentModelOperationsModuleVariableNames(module);
768
+ const kebabCaseModuleName = kebabCase(module.name);
769
+ const template = documentModelOperationsModuleErrorFileTemplate({
770
+ ...args,
771
+ ...moduleVariableNames
772
+ });
773
+ const { project, genDirPath } = args;
774
+ const dirPath = path$1.join(genDirPath, kebabCaseModuleName);
775
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "error.ts"));
776
+ sourceFile.replaceWithText(template);
777
+ await formatSourceFileWithPrettier(sourceFile);
778
+ }
779
+ //#endregion
780
+ //#region src/file-builders/document-model/migrate-legacy.ts
781
+ /**
782
+ * Detects whether a document model directory has a legacy (non-versioned)
783
+ * structure and migrates it to the versioned layout expected by `--use-versioning`.
784
+ *
785
+ * Detection: a directory is "legacy" when `src/reducers/` exists at root level
786
+ * AND no `v1/` directory exists yet.
787
+ *
788
+ * Migration steps:
789
+ * 1. Move legacy root-level items (`gen/`, `src/`, `tests/`, and known root files)
790
+ * into a `legacy/` subfolder for reference / backup.
791
+ * 2. Copy custom source files (reducers, tests, utils) from `legacy/` into the
792
+ * soon-to-be-created `v1/` directory so that ts-morph picks them up during
793
+ * generation and preserves business logic.
794
+ *
795
+ * This function is idempotent — calling it on an already-migrated directory is a
796
+ * no-op.
797
+ */
798
+ async function migrateLegacyToVersioned(documentModelDirPath) {
799
+ const srcReducersPath = path$1.join(documentModelDirPath, "src", "reducers");
800
+ const v1Path = path$1.join(documentModelDirPath, "v1");
801
+ const legacyPath = path$1.join(documentModelDirPath, "legacy");
802
+ const hasSrcReducers = await directoryExists(srcReducersPath);
803
+ const hasV1 = await directoryExists(v1Path);
804
+ if (!hasSrcReducers || hasV1) return;
805
+ console.log(`[migrate-legacy] Detected legacy structure in ${documentModelDirPath}`);
806
+ await mkdir(legacyPath, { recursive: true });
807
+ const dirsToMove = [
808
+ "gen",
809
+ "src",
810
+ "tests"
811
+ ];
812
+ const filesToMove = [
813
+ "module.ts",
814
+ "actions.ts",
815
+ "hooks.ts",
816
+ "utils.ts",
817
+ "index.ts",
818
+ "schema.graphql"
819
+ ];
820
+ for (const dirName of dirsToMove) {
821
+ const srcPath = path$1.join(documentModelDirPath, dirName);
822
+ if (await directoryExists(srcPath)) {
823
+ await rename(srcPath, path$1.join(legacyPath, dirName));
824
+ console.log(`[migrate-legacy] Moved ${dirName}/ → legacy/${dirName}/`);
825
+ }
826
+ }
827
+ for (const fileName of filesToMove) {
828
+ const srcPath = path$1.join(documentModelDirPath, fileName);
829
+ if (await fileExists(srcPath)) {
830
+ await rename(srcPath, path$1.join(legacyPath, fileName));
831
+ console.log(`[migrate-legacy] Moved ${fileName} → legacy/${fileName}`);
832
+ }
833
+ }
834
+ const v1SrcReducersPath = path$1.join(v1Path, "src", "reducers");
835
+ const v1SrcPath = path$1.join(v1Path, "src");
836
+ const v1TestsPath = path$1.join(v1Path, "tests");
837
+ const legacySrcReducersPath = path$1.join(legacyPath, "src", "reducers");
838
+ if (await directoryExists(legacySrcReducersPath)) {
839
+ await mkdir(v1SrcReducersPath, { recursive: true });
840
+ await copyDirectoryFiles(legacySrcReducersPath, v1SrcReducersPath);
841
+ console.log(`[migrate-legacy] Copied src/reducers/ → v1/src/reducers/`);
842
+ }
843
+ const legacySrcTestsPath = path$1.join(legacyPath, "src", "tests");
844
+ if (await directoryExists(legacySrcTestsPath)) {
845
+ const v1SrcTestsPath = path$1.join(v1SrcPath, "tests");
846
+ await mkdir(v1SrcTestsPath, { recursive: true });
847
+ await copyDirectoryFiles(legacySrcTestsPath, v1SrcTestsPath);
848
+ console.log(`[migrate-legacy] Copied src/tests/ → v1/src/tests/`);
849
+ }
850
+ const legacyTestsPath = path$1.join(legacyPath, "tests");
851
+ if (await directoryExists(legacyTestsPath)) {
852
+ await mkdir(v1TestsPath, { recursive: true });
853
+ await copyDirectoryFiles(legacyTestsPath, v1TestsPath);
854
+ console.log(`[migrate-legacy] Copied tests/ → v1/tests/`);
855
+ }
856
+ const legacyUtilsPath = path$1.join(legacyPath, "src", "utils.ts");
857
+ if (await fileExists(legacyUtilsPath)) {
858
+ await mkdir(v1SrcPath, { recursive: true });
859
+ await copyFile(legacyUtilsPath, path$1.join(v1SrcPath, "utils.ts"));
860
+ console.log(`[migrate-legacy] Copied src/utils.ts → v1/src/utils.ts`);
861
+ }
862
+ console.log(`[migrate-legacy] Migration complete for ${documentModelDirPath}`);
863
+ }
864
+ /** Copy all files (non-recursive) from srcDir to destDir */
865
+ async function copyDirectoryFiles(srcDir, destDir) {
866
+ const entries = await readdir(srcDir, { withFileTypes: true });
867
+ for (const entry of entries) if (entry.isFile()) await copyFile(path$1.join(srcDir, entry.name), path$1.join(destDir, entry.name));
868
+ }
869
+ //#endregion
870
+ //#region src/file-builders/document-model/root-dir.ts
871
+ async function makeRootDirFiles(fileMakerArgs) {
872
+ await makeDocumentModelVersionIndexFile(fileMakerArgs);
873
+ await makeDocumentModelRootActionsFile(fileMakerArgs);
874
+ await makeDocumentModelModuleFile(fileMakerArgs);
875
+ await makeDocumentModelUtilsFile(fileMakerArgs);
876
+ await makeDocumentModelHooksFile(fileMakerArgs);
877
+ }
878
+ async function makeDocumentModelVersionIndexFile(args) {
879
+ const template = documentModelIndexTemplate;
880
+ const { project, documentModelVersionDirPath } = args;
881
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelVersionDirPath, "index.ts"));
882
+ sourceFile.replaceWithText(template);
883
+ await formatSourceFileWithPrettier(sourceFile);
884
+ }
885
+ async function makeDocumentModelUtilsFile(args) {
886
+ const template = documentModelUtilsTemplate(args);
887
+ const { project, documentModelVersionDirPath } = args;
888
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelVersionDirPath, "utils.ts"));
889
+ sourceFile.replaceWithText(template);
890
+ await formatSourceFileWithPrettier(sourceFile);
891
+ }
892
+ async function makeDocumentModelRootActionsFile(args) {
893
+ const template = documentModelRootActionsFileTemplate(args);
894
+ const { project, documentModelVersionDirPath } = args;
895
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelVersionDirPath, "actions.ts"));
896
+ sourceFile.replaceWithText(template);
897
+ await formatSourceFileWithPrettier(sourceFile);
898
+ }
899
+ async function makeDocumentModelHooksFile(args) {
900
+ const template = documentModelHooksFileTemplate(args);
901
+ const { project, documentModelVersionDirPath } = args;
902
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelVersionDirPath, "hooks.ts"));
903
+ sourceFile.replaceWithText(template);
904
+ await formatSourceFileWithPrettier(sourceFile);
905
+ }
906
+ async function makeDocumentModelModuleFile(args) {
907
+ const { project, documentModelVersionDirPath } = args;
908
+ const template = documentModelModuleFileTemplate(args);
909
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelVersionDirPath, "module.ts"));
910
+ sourceFile.replaceWithText(template);
911
+ await formatSourceFileWithPrettier(sourceFile);
912
+ }
913
+ //#endregion
914
+ //#region src/file-builders/document-model/src-dir.ts
915
+ async function makeSrcDirFiles(fileMakerArgs) {
916
+ await makeDocumentModelSrcIndexFile(fileMakerArgs);
917
+ await makeDocumentModelSrcUtilsFile(fileMakerArgs);
918
+ await makeReducerOperationHandlersForModules(fileMakerArgs);
919
+ }
920
+ async function makeReducerOperationHandlersForModules(fileMakerArgs) {
921
+ const { modules } = fileMakerArgs;
922
+ for (const module of modules) await makeReducerOperationHandlerForModule({
923
+ ...fileMakerArgs,
924
+ module
925
+ });
926
+ }
927
+ async function makeReducerOperationHandlerForModule({ project, module, version, reducersDirPath, pascalCaseDocumentType, camelCaseDocumentType, versionedDocumentModelPackageImportPath }) {
928
+ const kebabCaseModuleName = kebabCase(module.name);
929
+ const pascalCaseModuleName = pascalCase(module.name);
930
+ const filePath = path$1.join(reducersDirPath, `${kebabCaseModuleName}.ts`);
931
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, filePath);
932
+ if (!alreadyExists) {
933
+ const previousVersionFile = getPreviousVersionSourceFile({
934
+ project,
935
+ version,
936
+ filePath
937
+ });
938
+ if (previousVersionFile) sourceFile.replaceWithText(previousVersionFile.getText());
939
+ }
940
+ const operationsInterfaceTypeName = `${pascalCaseDocumentType}${pascalCaseModuleName}Operations`;
941
+ const operationsInterfaceVariableName = `${camelCaseDocumentType}${pascalCaseModuleName}Operations`;
942
+ const existingOperationsInterfaceTypeImport = sourceFile.getImportDeclaration((importDeclaration) => !!importDeclaration.getNamedImports().find((importSpecifier) => importSpecifier.getName() === operationsInterfaceTypeName));
943
+ if (existingOperationsInterfaceTypeImport) existingOperationsInterfaceTypeImport.remove();
944
+ const operationsInterfaceTypeProperties = sourceFile.addImportDeclaration({
945
+ namedImports: [operationsInterfaceTypeName],
946
+ moduleSpecifier: versionedDocumentModelPackageImportPath,
947
+ isTypeOnly: true
948
+ }).getNamedImports().find((value) => value.getName() === operationsInterfaceTypeName)?.getNameNode().getType().getProperties().map((symbol) => symbol.getName());
949
+ if (!operationsInterfaceTypeProperties) throw new Error("Failed to create operation handler object");
950
+ let operationsInterfaceVariableStatement = sourceFile.getVariableStatement(operationsInterfaceVariableName);
951
+ if (!operationsInterfaceVariableStatement) operationsInterfaceVariableStatement = sourceFile.addVariableStatement({
952
+ declarationKind: VariableDeclarationKind.Const,
953
+ isExported: true,
954
+ declarations: [{
955
+ name: operationsInterfaceVariableName,
956
+ type: operationsInterfaceTypeName,
957
+ initializer: "{}"
958
+ }]
959
+ });
960
+ const operationsInterfaceObject = getObjectLiteral(operationsInterfaceVariableStatement);
961
+ if (!operationsInterfaceObject) throw new Error("Failed to build reducer object");
962
+ const operationsByMethodName = /* @__PURE__ */ new Map();
963
+ for (const operation of module.operations) if (operation.name) {
964
+ const methodName = `${camelCase(operation.name)}Operation`;
965
+ operationsByMethodName.set(methodName, operation);
966
+ }
967
+ for (const name of operationsInterfaceTypeProperties) {
968
+ if (operationsInterfaceObject.getProperty(name)) continue;
969
+ const reducerCode = operationsByMethodName.get(name)?.reducer?.trim();
970
+ operationsInterfaceObject.addMethod({
971
+ name,
972
+ parameters: [{ name: "state" }, { name: "action" }],
973
+ statements: reducerCode ? [reducerCode] : [`// TODO: implement ${name} reducer`, ts`throw new Error("Reducer for '${name}' not implemented.")`.raw]
974
+ });
975
+ }
976
+ addErrorImportsForModule(sourceFile, module);
977
+ await formatSourceFileWithPrettier(sourceFile);
978
+ }
979
+ async function makeDocumentModelSrcIndexFile({ project, ...variableNames }) {
980
+ const template = documentModelSrcIndexFileTemplate;
981
+ const { srcDirPath } = variableNames;
982
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(srcDirPath, "index.ts"));
983
+ sourceFile.replaceWithText(template);
984
+ await formatSourceFileWithPrettier(sourceFile);
985
+ }
986
+ async function makeDocumentModelSrcUtilsFile({ project, srcDirPath, version }) {
987
+ const template = documentModelSrcUtilsTemplate;
988
+ const filePath = path$1.join(srcDirPath, "utils.ts");
989
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, filePath);
990
+ if (!alreadyExists) {
991
+ const previousVersionSourceFile = getPreviousVersionSourceFile({
992
+ project,
993
+ version,
994
+ filePath
995
+ });
996
+ if (previousVersionSourceFile) sourceFile.replaceWithText(previousVersionSourceFile.getText());
997
+ else sourceFile.replaceWithText(template);
998
+ }
999
+ await formatSourceFileWithPrettier(sourceFile);
1000
+ }
1001
+ function addErrorImportsForModule(sourceFile, module) {
1002
+ const allErrors = [];
1003
+ for (const operation of module.operations) if (Array.isArray(operation.errors)) {
1004
+ for (const error of operation.errors) if (error.name && !allErrors.find((e) => e.name === error.name)) allErrors.push({ name: error.name });
1005
+ }
1006
+ if (allErrors.length === 0) return;
1007
+ const sourceFileContent = sourceFile.getFullText();
1008
+ const usedErrors = [];
1009
+ for (const error of allErrors) if (new RegExp(`\\b${error.name}\\b`, "g").test(sourceFileContent)) usedErrors.push(error.name);
1010
+ if (usedErrors.length === 0) return;
1011
+ const errorImportPath = `../../gen/${kebabCase(module.name)}/error.js`;
1012
+ const existingErrorImport = sourceFile.getImportDeclarations().find((importDecl) => importDecl.getModuleSpecifierValue() === errorImportPath);
1013
+ if (existingErrorImport) {
1014
+ const existingNamedImports = existingErrorImport.getNamedImports().map((namedImport) => namedImport.getName());
1015
+ const newErrorsToImport = usedErrors.filter((errorName) => !existingNamedImports.includes(errorName));
1016
+ if (newErrorsToImport.length > 0) existingErrorImport.addNamedImports(newErrorsToImport);
1017
+ } else sourceFile.addImportDeclaration({
1018
+ namedImports: usedErrors,
1019
+ moduleSpecifier: errorImportPath
1020
+ });
1021
+ }
1022
+ //#endregion
1023
+ //#region src/file-builders/document-model/tests-dir.ts
1024
+ async function makeTestsDirFiles(fileMakerArgs) {
1025
+ await makeDocumentModelTestFile(fileMakerArgs);
1026
+ const modules = fileMakerArgs.modules;
1027
+ for (const module of modules) await makeOperationModuleTestFile({
1028
+ ...fileMakerArgs,
1029
+ module
1030
+ });
1031
+ }
1032
+ async function makeOperationModuleTestFile(args) {
1033
+ const { project, module, version, testsDirPath, documentModelPackageImportPath, versionedDocumentModelPackageImportPath, isPhDocumentOfTypeFunctionName } = args;
1034
+ const moduleVariableNames = getDocumentModelOperationsModuleVariableNames(module);
1035
+ const { actions } = moduleVariableNames;
1036
+ const kebabCaseModuleName = kebabCase(module.name);
1037
+ const moduleOperationsTypeName = `${pascalCase(module.name)}Operations`;
1038
+ const filePath = path$1.join(testsDirPath, `${kebabCaseModuleName}.test.ts`);
1039
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, filePath);
1040
+ if (!alreadyExists) {
1041
+ const previousVersionSourceFile = getPreviousVersionSourceFile({
1042
+ project,
1043
+ version,
1044
+ filePath
1045
+ });
1046
+ if (previousVersionSourceFile) sourceFile.replaceWithText(previousVersionSourceFile.getText());
1047
+ else sourceFile.replaceWithText(ts`
1048
+ import { generateMock } from "document-model";
1049
+ import { describe, expect, it } from "vitest";
1050
+
1051
+ describe("${moduleOperationsTypeName}", () => {
1052
+
1053
+ });
1054
+ `.raw);
1055
+ }
1056
+ const importNames = makeActionImportNames({
1057
+ ...args,
1058
+ ...moduleVariableNames
1059
+ });
1060
+ const namedImports = importNames.map((name) => ({ name }));
1061
+ let actionsImportDeclaration = sourceFile.getImportDeclarations().filter((i) => !i.isTypeOnly()).find((importDeclaration) => importDeclaration.getModuleSpecifier().getText().includes(documentModelPackageImportPath));
1062
+ if (!actionsImportDeclaration) actionsImportDeclaration = sourceFile.addImportDeclaration({
1063
+ namedImports,
1064
+ moduleSpecifier: versionedDocumentModelPackageImportPath
1065
+ });
1066
+ else {
1067
+ actionsImportDeclaration.setModuleSpecifier(versionedDocumentModelPackageImportPath);
1068
+ const existingNamedImports = actionsImportDeclaration.getNamedImports().map((value) => value.getName());
1069
+ for (const name of importNames) if (!existingNamedImports.includes(name)) actionsImportDeclaration.addNamedImport(name);
1070
+ }
1071
+ const describeCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((call) => {
1072
+ const expressionText = call.getExpression().getText();
1073
+ const firstArg = call.getArguments()[0];
1074
+ return expressionText === "describe" && pascalCase(firstArg.getText()).includes(moduleOperationsTypeName);
1075
+ });
1076
+ if (!describeCall) {
1077
+ console.error(`Test file at path ${filePath} has no describe block for ${moduleOperationsTypeName}`);
1078
+ return;
1079
+ }
1080
+ const describeCallBody = describeCall.getArguments()[1].asKindOrThrow(SyntaxKind.ArrowFunction);
1081
+ const testCaseNames = describeCall.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => {
1082
+ const expressionText = call.getExpression().getText();
1083
+ return expressionText === "it" || expressionText === "test";
1084
+ }).map((c) => c.getArguments()[0].getText());
1085
+ const testCasesToAdd = actions.filter((action) => {
1086
+ const camelCaseActionName = camelCase(action.name);
1087
+ return !testCaseNames.some((c) => c.includes(camelCaseActionName));
1088
+ }).map((action) => makeTestCaseForAction(action, isPhDocumentOfTypeFunctionName));
1089
+ describeCallBody.addStatements(testCasesToAdd);
1090
+ const GENERATE_MOCK_NAME = "generateMock";
1091
+ const GENERATE_MOCK_MODULE_SPECIFIER = "@powerhousedao/codegen";
1092
+ const generateMockImport = sourceFile.getImportDeclaration((i) => i.getNamedImports().some((v) => v.getText().includes(GENERATE_MOCK_NAME)));
1093
+ if (sourceFile.getText().includes(GENERATE_MOCK_NAME) && !generateMockImport) sourceFile.addImportDeclaration({
1094
+ namedImports: [GENERATE_MOCK_NAME],
1095
+ moduleSpecifier: GENERATE_MOCK_MODULE_SPECIFIER
1096
+ });
1097
+ sourceFile.fixUnusedIdentifiers();
1098
+ await formatSourceFileWithPrettier(sourceFile);
1099
+ }
1100
+ async function makeDocumentModelTestFile(args) {
1101
+ const { project, testsDirPath } = args;
1102
+ const template = documentModelTestFileTemplate(args);
1103
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(testsDirPath, "document-model.test.ts"));
1104
+ if (alreadyExists) return;
1105
+ sourceFile.replaceWithText(template);
1106
+ await formatSourceFileWithPrettier(sourceFile);
1107
+ }
1108
+ //#endregion
1109
+ //#region src/file-builders/document-model/upgrades-dir.ts
1110
+ async function makeUpgradeFile(args) {
1111
+ const { project, version, upgradesDirPath, documentModelPackageImportPath, phStateName } = args;
1112
+ if (version < 2) return;
1113
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(upgradesDirPath, `v${version}.ts`));
1114
+ if (alreadyExists) return;
1115
+ const template = upgradeTransitionTemplate({
1116
+ version,
1117
+ previousVersion: version - 1,
1118
+ documentModelPackageImportPath,
1119
+ phStateName
1120
+ });
1121
+ sourceFile.replaceWithText(template);
1122
+ await formatSourceFileWithPrettier(sourceFile);
1123
+ }
1124
+ async function createOrUpdateUpgradeManifestFile(args) {
1125
+ const { project, specVersions, upgradesDirPath, documentModelId, upgradeManifestName } = args;
1126
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(upgradesDirPath, "upgrade-manifest.ts"));
1127
+ const template = upgradeManifestTemplate({
1128
+ documentModelId,
1129
+ upgradeManifestName
1130
+ });
1131
+ sourceFile.replaceWithText(template);
1132
+ const upgradeTransitionImports = buildUpgradeTransitionImports(specVersions);
1133
+ sourceFile.addImportDeclarations(upgradeTransitionImports);
1134
+ const upgradeManifestStatement = getVariableDeclarationByTypeName(sourceFile, "UpgradeManifest")?.getVariableStatementOrThrow();
1135
+ const upgradesProperty = getObjectLiteral(upgradeManifestStatement)?.getProperty("upgrades");
1136
+ const upgrades = buildUpgrades(specVersions);
1137
+ upgradesProperty?.replaceWithText(upgrades);
1138
+ await formatSourceFileWithPrettier(sourceFile);
1139
+ }
1140
+ function buildUpgrades(specVersions) {
1141
+ const upgradeStrings = [];
1142
+ for (const version of specVersions) {
1143
+ if (version < 2) continue;
1144
+ upgradeStrings.push(`v${version}`);
1145
+ }
1146
+ return `upgrades: { ${upgradeStrings.join(",\n")} }`;
1147
+ }
1148
+ function buildUpgradeTransitionImports(specVersions) {
1149
+ const imports = [];
1150
+ for (const version of specVersions) {
1151
+ if (version < 2) continue;
1152
+ const namedImports = [`v${version}`];
1153
+ const moduleSpecifier = `./v${version}.js`;
1154
+ imports.push({
1155
+ namedImports,
1156
+ moduleSpecifier
1157
+ });
1158
+ }
1159
+ return imports;
1160
+ }
1161
+ async function createOrUpdateVersionConstantsFile({ specVersions, latestVersion, project, upgradesDirPath }) {
1162
+ const SUPPORTED_VERSIONS = "supportedVersions";
1163
+ const LATEST_VERSION = "latestVersion";
1164
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(upgradesDirPath, "versions.ts"));
1165
+ sourceFile.replaceWithText("");
1166
+ const latestVersionIndex = specVersions.indexOf(latestVersion);
1167
+ const versionInitializer = `[${specVersions.join(", ")}] as const;`;
1168
+ const latestInitializer = `${SUPPORTED_VERSIONS}[${latestVersionIndex}];`;
1169
+ sourceFile.addVariableStatement({
1170
+ declarationKind: VariableDeclarationKind.Const,
1171
+ isExported: true,
1172
+ declarations: [{
1173
+ name: SUPPORTED_VERSIONS,
1174
+ initializer: versionInitializer
1175
+ }]
1176
+ });
1177
+ sourceFile.addVariableStatement({
1178
+ declarationKind: VariableDeclarationKind.Const,
1179
+ isExported: true,
1180
+ declarations: [{
1181
+ name: LATEST_VERSION,
1182
+ initializer: latestInitializer
1183
+ }]
1184
+ });
1185
+ await formatSourceFileWithPrettier(sourceFile);
1186
+ }
1187
+ async function makeUpgradesIndexFile({ project, upgradesDirPath, specVersions, upgradeManifestName }) {
1188
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(upgradesDirPath, "index.ts"));
1189
+ sourceFile.replaceWithText("");
1190
+ const upgradeReducerExports = makeUpgradeReducerExports(specVersions);
1191
+ sourceFile.addExportDeclarations([
1192
+ {
1193
+ namedExports: [upgradeManifestName],
1194
+ moduleSpecifier: "./upgrade-manifest.js"
1195
+ },
1196
+ {
1197
+ namedExports: ["supportedVersions", "latestVersion"],
1198
+ moduleSpecifier: "./versions.js"
1199
+ },
1200
+ ...upgradeReducerExports
1201
+ ]);
1202
+ await formatSourceFileWithPrettier(sourceFile);
1203
+ }
1204
+ function makeUpgradeReducerExports(specVersions) {
1205
+ const exports = [];
1206
+ for (const version of specVersions) {
1207
+ if (version < 2) continue;
1208
+ const namedExports = [`v${version}`];
1209
+ const moduleSpecifier = `./v${version}.js`;
1210
+ exports.push({
1211
+ namedExports,
1212
+ moduleSpecifier
1213
+ });
1214
+ }
1215
+ return exports;
1216
+ }
1217
+ //#endregion
1218
+ //#region src/file-builders/document-model/document-model.ts
1219
+ /** Generates a document model from the given `documentModelState`
1220
+ *
1221
+ * If `useVersioning` is set to true, it will generate versioned document model code
1222
+ * for each `specification` in the `documentModelState`
1223
+ */
1224
+ async function tsMorphGenerateDocumentModel({ projectDir, packageName, documentModelState, useVersioning, migrateLegacy }) {
1225
+ if (migrateLegacy) await migrateLegacyToVersioned(path$1.join(projectDir, "document-models", getDocumentModelDirName(documentModelState)));
1226
+ const project = buildTsMorphProject(projectDir);
1227
+ const documentModelsSourceFilesPath = path$1.join(projectDir, "document-models/**/*");
1228
+ const documentModelsDirPath = path$1.join(projectDir, "document-models");
1229
+ const documentModelDirName = getDocumentModelDirName(documentModelState);
1230
+ const documentModelDirPath = path$1.join(documentModelsDirPath, documentModelDirName);
1231
+ const upgradesDirPath = path$1.join(documentModelDirPath, "upgrades");
1232
+ const documentModelVariableNames = getDocumentModelVariableNames(documentModelState.name);
1233
+ await ensureDirectoriesExist(project, documentModelsDirPath, documentModelDirPath);
1234
+ if (useVersioning) await ensureDirectoriesExist(project, upgradesDirPath);
1235
+ project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
1236
+ const documentModelPackageImportPath = path$1.join("document-models", documentModelDirName);
1237
+ const specVersions = [...new Set([...documentModelState.specifications.map((spec) => spec.version)])].toSorted();
1238
+ if (specVersions.length !== documentModelState.specifications.length) throw new Error("Document model specifications array is misconfigured. Length is not match with spec versions.");
1239
+ const latestVersion = specVersions[specVersions.length - 1];
1240
+ if (documentModelState.specifications[documentModelState.specifications.length - 1].version !== latestVersion) throw new Error("Document model has incorrect version at the latest version index");
1241
+ await writeDocumentModelStateJsonFile({
1242
+ documentModelState,
1243
+ documentModelDirName,
1244
+ documentModelDirPath
1245
+ });
1246
+ if (useVersioning) {
1247
+ await Promise.all(specVersions.map(async (version) => await generateDocumentModelForSpec({
1248
+ project,
1249
+ version,
1250
+ useVersioning: true,
1251
+ packageName,
1252
+ documentModelState,
1253
+ projectDir,
1254
+ documentModelsDirPath,
1255
+ documentModelDirName,
1256
+ documentModelDirPath,
1257
+ documentModelPackageImportPath,
1258
+ ...documentModelVariableNames
1259
+ })));
1260
+ for (const version of specVersions) await makeUpgradeFile({
1261
+ version,
1262
+ upgradesDirPath,
1263
+ project,
1264
+ documentModelPackageImportPath,
1265
+ ...documentModelVariableNames
1266
+ });
1267
+ await makeDocumentModelIndexFile({
1268
+ project,
1269
+ documentModelDirPath,
1270
+ latestVersion
1271
+ });
1272
+ await createOrUpdateVersionConstantsFile({
1273
+ project,
1274
+ specVersions,
1275
+ latestVersion,
1276
+ upgradesDirPath
1277
+ });
1278
+ await createOrUpdateUpgradeManifestFile({
1279
+ project,
1280
+ specVersions,
1281
+ latestVersion,
1282
+ upgradesDirPath,
1283
+ documentModelId: documentModelState.id,
1284
+ ...documentModelVariableNames
1285
+ });
1286
+ await makeUpgradesIndexFile({
1287
+ project,
1288
+ upgradesDirPath,
1289
+ specVersions,
1290
+ ...documentModelVariableNames
1291
+ });
1292
+ } else await generateDocumentModelForSpec({
1293
+ project,
1294
+ useVersioning: false,
1295
+ version: latestVersion,
1296
+ packageName,
1297
+ documentModelState,
1298
+ projectDir,
1299
+ documentModelsDirPath,
1300
+ documentModelDirName,
1301
+ documentModelDirPath,
1302
+ documentModelPackageImportPath,
1303
+ ...documentModelVariableNames
1304
+ });
1305
+ await project.save();
1306
+ }
1307
+ /** Generates document model code for a given `specification` from a `documentModelState` object */
1308
+ async function generateDocumentModelForSpec({ project, projectDir, packageName, documentModelState, documentModelPackageImportPath, documentModelsDirPath, documentModelDirName, documentModelDirPath, useVersioning, version, ...documentModelVariableNames }) {
1309
+ const specification = documentModelState.specifications.find((spec) => spec.version === version);
1310
+ if (!specification) throw new Error(`Document model specifications array is misconfigured, no specification found for version: ${version}`);
1311
+ const versionDirName = useVersioning ? `v${version}` : "";
1312
+ const documentModelVersionDirName = path$1.join(documentModelDirName, versionDirName);
1313
+ const documentModelVersionDirPath = path$1.join(documentModelDirPath, versionDirName);
1314
+ const versionedDocumentModelPackageImportPath = path$1.join(documentModelPackageImportPath, versionDirName);
1315
+ const fileExtension = documentModelState.extension;
1316
+ const documentTypeId = documentModelState.id;
1317
+ const srcDirPath = path$1.join(documentModelVersionDirPath, "src");
1318
+ const reducersDirPath = path$1.join(srcDirPath, "reducers");
1319
+ const testsDirPath = path$1.join(documentModelVersionDirPath, "tests");
1320
+ const genDirPath = path$1.join(documentModelVersionDirPath, "gen");
1321
+ const schemaDirPath = path$1.join(genDirPath, "schema");
1322
+ const { initialGlobalState, initialLocalState } = getInitialStates(specification.state);
1323
+ const hasLocalSchema = specification.state.local.schema !== "";
1324
+ const modules = specification.modules;
1325
+ await ensureDirectoriesExist(project, documentModelVersionDirPath, reducersDirPath, testsDirPath, schemaDirPath, ...modules.map((module) => path$1.join(genDirPath, kebabCase(module.name))));
1326
+ const fileMakerArgs = {
1327
+ project,
1328
+ projectDir,
1329
+ packageName,
1330
+ version,
1331
+ useVersioning,
1332
+ documentTypeId,
1333
+ documentModelState,
1334
+ initialGlobalState,
1335
+ initialLocalState,
1336
+ modules,
1337
+ hasLocalSchema,
1338
+ documentModelsDirPath,
1339
+ documentModelDirPath,
1340
+ documentModelDirName,
1341
+ documentModelVersionDirName,
1342
+ documentModelVersionDirPath,
1343
+ documentModelPackageImportPath,
1344
+ versionedDocumentModelPackageImportPath,
1345
+ srcDirPath,
1346
+ genDirPath,
1347
+ testsDirPath,
1348
+ schemaDirPath,
1349
+ reducersDirPath,
1350
+ fileExtension,
1351
+ ...documentModelVariableNames
1352
+ };
1353
+ await generateDocumentModelZodSchemas({
1354
+ documentModelDirPath: documentModelVersionDirPath,
1355
+ specification
1356
+ });
1357
+ await makeRootDirFiles(fileMakerArgs);
1358
+ await makeGenDirFiles(fileMakerArgs);
1359
+ await makeSrcDirFiles(fileMakerArgs);
1360
+ await makeTestsDirFiles(fileMakerArgs);
1361
+ await makeDocumentModelModulesFile(fileMakerArgs);
1362
+ if (!useVersioning) return;
1363
+ await makeUpgradeManifestsFile({
1364
+ project,
1365
+ projectDir
1366
+ });
1367
+ const previousVersionDirPath = getPreviousVersionDirPath(documentModelDirPath, version);
1368
+ if (!previousVersionDirPath) return;
1369
+ await persistCustomFilesFromPreviousVersion({
1370
+ currentVersionDirPath: documentModelVersionDirPath,
1371
+ previousVersionDirPath
1372
+ });
1373
+ }
1374
+ /** Writes a json file derived from a `documentModelState` */
1375
+ async function writeDocumentModelStateJsonFile({ documentModelState, documentModelDirName, documentModelDirPath }) {
1376
+ await writeFile(path$1.join(documentModelDirPath, `${documentModelDirName}.json`), JSON.stringify(documentModelState, null, 2));
1377
+ }
1378
+ function getPreviousVersionDirPath(documentModelDirPath, version) {
1379
+ const previousVersion = version - 1;
1380
+ if (previousVersion < 1) return;
1381
+ const previousVersionDirName = `v${previousVersion}`;
1382
+ return path$1.join(documentModelDirPath, previousVersionDirName);
1383
+ }
1384
+ async function makeDocumentModelIndexFile(args) {
1385
+ const { project, documentModelDirPath, latestVersion } = args;
1386
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(documentModelDirPath, "index.ts"));
1387
+ sourceFile.replaceWithText("");
1388
+ sourceFile.addExportDeclarations([{ moduleSpecifier: `./v${latestVersion}/index.js` }, { moduleSpecifier: `./upgrades/index.js` }]);
1389
+ await formatSourceFileWithPrettier(sourceFile);
1390
+ }
1391
+ async function persistCustomFilesFromPreviousVersion(args) {
1392
+ const { currentVersionDirPath, previousVersionDirPath } = args;
1393
+ if (!await directoryExists(previousVersionDirPath)) return;
1394
+ const previousVersionFiles = (await readdir(previousVersionDirPath, {
1395
+ withFileTypes: true,
1396
+ recursive: true
1397
+ })).filter((dirEnt) => dirEnt.isFile()).map(({ name, parentPath }) => ({
1398
+ name,
1399
+ parentPath,
1400
+ relativePath: path$1.relative(previousVersionDirPath, parentPath)
1401
+ }));
1402
+ for (const { name, relativePath } of previousVersionFiles) {
1403
+ const filePathInCurrentVersionDir = path$1.join(currentVersionDirPath, relativePath, name);
1404
+ const filePathInPreviousVersionDir = path$1.join(previousVersionDirPath, relativePath, name);
1405
+ const existsInPreviousVersionDir = await fileExists(filePathInPreviousVersionDir);
1406
+ const existsInCurrentVersionDir = await fileExists(filePathInCurrentVersionDir);
1407
+ if (existsInPreviousVersionDir && !existsInCurrentVersionDir) {
1408
+ console.log(`Persisting file "${path$1.join(relativePath, name)}" from previous version directory.`);
1409
+ await mkdir(path$1.join(currentVersionDirPath, relativePath), { recursive: true });
1410
+ await copyFile(filePathInPreviousVersionDir, filePathInCurrentVersionDir);
1411
+ }
1412
+ }
1413
+ }
1414
+ //#endregion
1415
+ //#region src/file-builders/drive-editor.ts
1416
+ /** Generates a drive editor with the configs for `allowedDocumentModelIds` and `isDragAndDropEnabled` */
1417
+ async function tsMorphGenerateDriveEditor({ projectDir, editorDir, editorName, editorId, allowedDocumentModelIds, isDragAndDropEnabled }) {
1418
+ const documentModelsDirPath = path$1.join(projectDir, "document-models");
1419
+ const documentModelsSourceFilesPath = path$1.join(documentModelsDirPath, "/**/*");
1420
+ const editorsDirPath = path$1.join(projectDir, "editors");
1421
+ const editorSourceFilesPath = path$1.join(editorsDirPath, "/**/*");
1422
+ const editorDirPath = path$1.join(editorsDirPath, editorDir);
1423
+ const editorComponentsDirPath = path$1.join(editorDirPath, "components");
1424
+ const project = buildTsMorphProject(projectDir);
1425
+ await ensureDirectoriesExist(project, documentModelsDirPath, editorsDirPath, editorDirPath, editorComponentsDirPath);
1426
+ project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
1427
+ project.addSourceFilesAtPaths(editorSourceFilesPath);
1428
+ await makeNavigationBreadcrumbsFile({
1429
+ project,
1430
+ editorComponentsDirPath
1431
+ });
1432
+ await makeCreateDocumentFile({
1433
+ project,
1434
+ editorComponentsDirPath
1435
+ });
1436
+ await makeEmptyStateFile({
1437
+ project,
1438
+ editorComponentsDirPath
1439
+ });
1440
+ await makeFoldersFile({
1441
+ project,
1442
+ editorComponentsDirPath
1443
+ });
1444
+ await makeFolderTreeFile({
1445
+ project,
1446
+ editorComponentsDirPath
1447
+ });
1448
+ await makeFilesFile({
1449
+ project,
1450
+ editorComponentsDirPath
1451
+ });
1452
+ await makeDriveExplorerFile({
1453
+ project,
1454
+ editorComponentsDirPath
1455
+ });
1456
+ await makeDriveContentsFile({
1457
+ project,
1458
+ editorComponentsDirPath
1459
+ });
1460
+ await makeDriveEditorComponent({
1461
+ project,
1462
+ editorDirPath
1463
+ });
1464
+ await makeDriveEditorConfigFile({
1465
+ project,
1466
+ allowedDocumentModelIds,
1467
+ isDragAndDropEnabled,
1468
+ editorDirPath
1469
+ });
1470
+ makeEditorModuleFile({
1471
+ project,
1472
+ editorName,
1473
+ editorId,
1474
+ editorDirPath,
1475
+ documentModelId: "powerhouse/document-drive"
1476
+ });
1477
+ await makeEditorsModulesFile(project, projectDir);
1478
+ await project.save();
1479
+ }
1480
+ async function makeDriveEditorComponent({ project, editorDirPath }) {
1481
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "editor.tsx"));
1482
+ if (alreadyExists) {
1483
+ const editorFunction = sourceFile.getFunction("Editor");
1484
+ if (editorFunction) {
1485
+ if (!editorFunction.isDefaultExport()) editorFunction.setIsDefaultExport(true);
1486
+ return;
1487
+ }
1488
+ }
1489
+ const template = driveEditorEditorFileTemplate();
1490
+ sourceFile.replaceWithText(template);
1491
+ await formatSourceFileWithPrettier(sourceFile);
1492
+ }
1493
+ async function makeDriveEditorConfigFile({ project, editorDirPath, allowedDocumentModelIds, isDragAndDropEnabled }) {
1494
+ const { sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "config.ts"));
1495
+ const allowedDocumentTypesString = JSON.stringify(allowedDocumentModelIds);
1496
+ const template = driveEditorConfigFileTemplate({
1497
+ isDragAndDropEnabledString: isDragAndDropEnabled ? "true" : "false",
1498
+ allowedDocumentTypesString
1499
+ });
1500
+ sourceFile.replaceWithText(template);
1501
+ await formatSourceFileWithPrettier(sourceFile);
1502
+ }
1503
+ async function makeDriveContentsFile({ project, editorComponentsDirPath }) {
1504
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveContents.tsx"));
1505
+ if (alreadyExists) return;
1506
+ const template = driveEditorDriveContentsFileTemplate();
1507
+ sourceFile.replaceWithText(template);
1508
+ await formatSourceFileWithPrettier(sourceFile);
1509
+ }
1510
+ async function makeNavigationBreadcrumbsFile({ project, editorComponentsDirPath }) {
1511
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "NavigationBreadcrumbs.tsx"));
1512
+ if (alreadyExists) return;
1513
+ sourceFile.replaceWithText(driveExplorerNavigationBreadcrumbsFileTemplate());
1514
+ await formatSourceFileWithPrettier(sourceFile);
1515
+ }
1516
+ async function makeFoldersFile({ project, editorComponentsDirPath }) {
1517
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Folders.tsx"));
1518
+ if (alreadyExists) return;
1519
+ const template = driveEditorFoldersFileTemplate();
1520
+ sourceFile.replaceWithText(template);
1521
+ await formatSourceFileWithPrettier(sourceFile);
1522
+ }
1523
+ async function makeFilesFile({ project, editorComponentsDirPath }) {
1524
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Files.tsx"));
1525
+ if (alreadyExists) return;
1526
+ const template = driveEditorFilesFileTemplate();
1527
+ sourceFile.replaceWithText(template);
1528
+ await formatSourceFileWithPrettier(sourceFile);
1529
+ }
1530
+ async function makeDriveExplorerFile({ project, editorComponentsDirPath }) {
1531
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveExplorer.tsx"));
1532
+ if (alreadyExists) return;
1533
+ sourceFile.replaceWithText(driveExplorerFileTemplate);
1534
+ await formatSourceFileWithPrettier(sourceFile);
1535
+ }
1536
+ async function makeFolderTreeFile({ project, editorComponentsDirPath }) {
1537
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "FolderTree.tsx"));
1538
+ if (alreadyExists) return;
1539
+ sourceFile.replaceWithText(folderTreeFileTemplate);
1540
+ await formatSourceFileWithPrettier(sourceFile);
1541
+ }
1542
+ async function makeEmptyStateFile({ project, editorComponentsDirPath }) {
1543
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "EmptyState.tsx"));
1544
+ if (alreadyExists) return;
1545
+ sourceFile.replaceWithText(emptyStateFileTemplate);
1546
+ await formatSourceFileWithPrettier(sourceFile);
1547
+ }
1548
+ async function makeCreateDocumentFile({ project, editorComponentsDirPath }) {
1549
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "CreateDocument.tsx"));
1550
+ if (alreadyExists) return;
1551
+ sourceFile.replaceWithText(createDocumentFileTemplate);
1552
+ await formatSourceFileWithPrettier(sourceFile);
1553
+ }
1554
+ //#endregion
1555
+ //#region src/file-builders/subgraph.ts
1556
+ async function tsMorphGenerateSubgraph(args) {
1557
+ const { subgraphsDir, subgraphName, packageName, documentModel } = args;
1558
+ const project = new Project({
1559
+ skipAddingFilesFromTsConfig: true,
1560
+ skipLoadingLibFiles: true
1561
+ });
1562
+ const kebabCaseName = kebabCase(subgraphName);
1563
+ const pascalCaseName = pascalCase(subgraphName);
1564
+ const camelCaseName = camelCase(subgraphName);
1565
+ const subgraphDir = path$1.join(subgraphsDir, kebabCaseName);
1566
+ if (existsSync(subgraphDir)) for (const name of [
1567
+ "index.ts",
1568
+ "lib.ts",
1569
+ "schema.ts",
1570
+ "resolvers.ts"
1571
+ ]) {
1572
+ const filePath = path$1.join(subgraphDir, name);
1573
+ if (existsSync(filePath)) project.addSourceFileAtPath(filePath);
1574
+ }
1575
+ await makeBaseSubgraphIndexFile(project, subgraphDir, {
1576
+ pascalCaseName,
1577
+ kebabCaseName
1578
+ });
1579
+ await makeBaseSubgraphLibFile(project, subgraphDir);
1580
+ if (documentModel !== null) await makeDocumentModelSubgraphFiles(project, subgraphDir, {
1581
+ documentModel,
1582
+ packageName
1583
+ });
1584
+ else await makeCustomSubgraphFiles(project, subgraphDir, {
1585
+ pascalCaseName,
1586
+ camelCaseName
1587
+ });
1588
+ await project.save();
1589
+ }
1590
+ async function makeBaseSubgraphIndexFile(project, dirPath, v) {
1591
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "index.ts"));
1592
+ if (alreadyExists) return;
1593
+ sourceFile.replaceWithText(subgraphIndexFileTemplate(v));
1594
+ await formatSourceFileWithPrettier(sourceFile);
1595
+ }
1596
+ async function makeBaseSubgraphLibFile(project, dirPath) {
1597
+ const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(dirPath, "lib.ts"));
1598
+ if (alreadyExists) return;
1599
+ sourceFile.replaceWithText(subgraphLibFileTemplate());
1600
+ await formatSourceFileWithPrettier(sourceFile);
1601
+ }
1602
+ async function makeCustomSubgraphFiles(project, dirPath, v) {
1603
+ const schema = getOrCreateSourceFile(project, path$1.join(dirPath, "schema.ts"));
1604
+ if (!schema.alreadyExists) schema.sourceFile.replaceWithText(customSubgraphSchemaTemplate(v));
1605
+ const resolvers = getOrCreateSourceFile(project, path$1.join(dirPath, "resolvers.ts"));
1606
+ if (!resolvers.alreadyExists) {
1607
+ resolvers.sourceFile.replaceWithText(customSubgraphResolversTemplate(v));
1608
+ await formatSourceFileWithPrettier(resolvers.sourceFile);
1609
+ }
1610
+ }
1611
+ async function makeDocumentModelSubgraphFiles(project, dirPath, args) {
1612
+ const { documentModel, packageName } = args;
1613
+ const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
1614
+ const documentType = documentModel.name;
1615
+ const pascalCaseDocumentType = pascalCase(documentType);
1616
+ const camelCaseDocumentType = camelCase(documentType);
1617
+ const phDocumentTypeName = `${pascalCaseDocumentType}Document`;
1618
+ const documentTypeVariableName = `${camelCaseDocumentType}DocumentType`;
1619
+ const documentModelDir = `${packageName}/document-models/${kebabCase(documentType)}`;
1620
+ const stateSchema = latestSpec.state.global.schema;
1621
+ const stateTypeNames = extractTypeNames(stateSchema);
1622
+ const modules = latestSpec.modules.filter((m) => m.name !== null).map((m) => ({
1623
+ name: kebabCase(m.name),
1624
+ operations: m.operations.filter((op) => op.name !== null).map((op) => ({
1625
+ name: op.name,
1626
+ schema: applyGraphQLTypePrefixes(op.schema ?? "", pascalCaseDocumentType, stateTypeNames)
1627
+ }))
1628
+ }));
1629
+ getOrCreateSourceFile(project, path$1.join(dirPath, "schema.ts")).sourceFile.replaceWithText(documentModelSubgraphSchemaTemplate({
1630
+ pascalCaseDocumentType,
1631
+ modules
1632
+ }));
1633
+ getOrCreateSourceFile(project, path$1.join(dirPath, "resolvers.ts")).sourceFile.replaceWithText(documentModelSubgraphResolversTemplate({
1634
+ pascalCaseDocumentType,
1635
+ camelCaseDocumentType,
1636
+ phDocumentTypeName,
1637
+ documentTypeVariableName,
1638
+ documentModelDir,
1639
+ modules
1640
+ }));
1641
+ }
1642
+ //#endregion
1643
+ //#region src/file-builders/subgraphs.ts
1644
+ async function makeSubgraphsIndexFile({ projectDir }) {
1645
+ const project = new Project({
1646
+ tsConfigFilePath: path$1.join(projectDir, "tsconfig.json"),
1647
+ skipAddingFilesFromTsConfig: true,
1648
+ skipLoadingLibFiles: true,
1649
+ manipulationSettings: {
1650
+ useTrailingCommas: true,
1651
+ indentationText: IndentationText.TwoSpaces
1652
+ }
1653
+ });
1654
+ project.addSourceFilesAtPaths(`${projectDir}/subgraphs/**/*`);
1655
+ const subgraphsSubdirs = project.getDirectory(path$1.join(projectDir, "subgraphs"))?.getDirectories() ?? [];
1656
+ let subgraphsIndexSourceFile = project.getSourceFile(path$1.join(projectDir, "subgraphs/index.ts"));
1657
+ if (!subgraphsIndexSourceFile) subgraphsIndexSourceFile = project.createSourceFile(path$1.join(projectDir, "subgraphs/index.js"), "");
1658
+ for (const subgraphSubdir of subgraphsSubdirs) {
1659
+ const subgraphIndexSourceFilePath = `${subgraphSubdir.getPath()}/index.ts`;
1660
+ const subgraphIndexSourceFile = project.getSourceFile(subgraphIndexSourceFilePath);
1661
+ if (!subgraphIndexSourceFile) continue;
1662
+ const subgraphClassName = subgraphIndexSourceFile.getClasses().find((c) => c.getBaseClass()?.getText().includes("BaseSubgraph"))?.getName();
1663
+ if (!subgraphClassName) continue;
1664
+ if (subgraphsIndexSourceFile.getExportDeclarations().map((e) => e.getNamespaceExport()?.getText()).filter((e) => e !== void 0).join().includes(subgraphClassName)) continue;
1665
+ subgraphsIndexSourceFile.addExportDeclaration({
1666
+ namespaceExport: subgraphClassName,
1667
+ moduleSpecifier: `./${subgraphSubdir.getBaseName()}/index.js`
1668
+ });
1669
+ }
1670
+ await project.save();
1671
+ }
1672
+ //#endregion
1673
+ export { tsMorphGenerateProcessor as C, scalarsValidation as S, buildBoilerplatePackageJson as _, tsMorphGenerateDocumentEditor as a, generateTypesAndZodSchemasFromGraphql as b, makeModulesFile as c, makeLegacyIndexFile as d, makeEditorModuleFile as f, writeCliDocsMarkdownFile as g, makeCliDocsFromHelp as h, tsMorphGenerateDocumentModel as i, makeUpgradeManifestsExport as l, getCommandsHelpInfo as m, tsMorphGenerateSubgraph as n, makeDocumentModelModulesFile as o, getCommandHelpInfo as p, tsMorphGenerateDriveEditor as r, makeEditorsModulesFile as s, makeSubgraphsIndexFile as t, makeUpgradeManifestsFile as u, generateDocumentModelZodSchemas as v, scalars as x, generateSchemas as y };
1674
+
1675
+ //# sourceMappingURL=file-builders-BRJcuumC.mjs.map