joist-codegen 2.3.0-next.42 → 2.3.0-next.43

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 (337) hide show
  1. package/build/EntityDbMetadata.cjs +608 -0
  2. package/build/EntityDbMetadata.cjs.map +1 -0
  3. package/build/EntityDbMetadata.d.cts +274 -0
  4. package/build/EntityDbMetadata.d.cts.map +1 -0
  5. package/build/EntityDbMetadata.d.mts +274 -0
  6. package/build/EntityDbMetadata.d.mts.map +1 -0
  7. package/build/EntityDbMetadata.js +485 -664
  8. package/build/EntityDbMetadata.js.map +1 -1
  9. package/build/_virtual/_rolldown/runtime.cjs +23 -0
  10. package/build/_virtual/_rolldown/runtime.js +5 -0
  11. package/build/assignTags.cjs +45 -0
  12. package/build/assignTags.cjs.map +1 -0
  13. package/build/{assignTags.d.ts → assignTags.d.cts} +8 -3
  14. package/build/assignTags.d.cts.map +1 -0
  15. package/build/assignTags.d.mts +16 -0
  16. package/build/assignTags.d.mts.map +1 -0
  17. package/build/assignTags.js +37 -59
  18. package/build/assignTags.js.map +1 -1
  19. package/build/codemods/Codemod.cjs +2 -0
  20. package/build/codemods/Codemod.d.cts +17 -0
  21. package/build/codemods/Codemod.d.cts.map +1 -0
  22. package/build/codemods/Codemod.d.mts +17 -0
  23. package/build/codemods/Codemod.d.mts.map +1 -0
  24. package/build/codemods/Codemod.js +2 -3
  25. package/build/codemods/JscodeshiftMod.cjs +42 -0
  26. package/build/codemods/JscodeshiftMod.cjs.map +1 -0
  27. package/build/codemods/JscodeshiftMod.d.cts +14 -0
  28. package/build/codemods/JscodeshiftMod.d.cts.map +1 -0
  29. package/build/codemods/JscodeshiftMod.d.mts +14 -0
  30. package/build/codemods/JscodeshiftMod.d.mts.map +1 -0
  31. package/build/codemods/JscodeshiftMod.js +33 -33
  32. package/build/codemods/JscodeshiftMod.js.map +1 -1
  33. package/build/codemods/codemod_0001-rename_has_async_property.cjs +30 -0
  34. package/build/codemods/codemod_0001-rename_has_async_property.cjs.map +1 -0
  35. package/build/codemods/codemod_0001-rename_has_async_property.d.cts +9 -0
  36. package/build/codemods/codemod_0001-rename_has_async_property.d.cts.map +1 -0
  37. package/build/codemods/codemod_0001-rename_has_async_property.d.mts +9 -0
  38. package/build/codemods/codemod_0001-rename_has_async_property.d.mts.map +1 -0
  39. package/build/codemods/codemod_0001-rename_has_async_property.js +21 -25
  40. package/build/codemods/codemod_0001-rename_has_async_property.js.map +1 -1
  41. package/build/codemods/codemod_0002-rename_async_query_fields.cjs +50 -0
  42. package/build/codemods/codemod_0002-rename_async_query_fields.cjs.map +1 -0
  43. package/build/codemods/codemod_0002-rename_async_query_fields.d.cts +9 -0
  44. package/build/codemods/codemod_0002-rename_async_query_fields.d.cts.map +1 -0
  45. package/build/codemods/codemod_0002-rename_async_query_fields.d.mts +9 -0
  46. package/build/codemods/codemod_0002-rename_async_query_fields.d.mts.map +1 -0
  47. package/build/codemods/codemod_0002-rename_async_query_fields.js +38 -46
  48. package/build/codemods/codemod_0002-rename_async_query_fields.js.map +1 -1
  49. package/build/codemods/codemod_0003-rename_find_paginated.cjs +25 -0
  50. package/build/codemods/codemod_0003-rename_find_paginated.cjs.map +1 -0
  51. package/build/codemods/codemod_0003-rename_find_paginated.d.cts +9 -0
  52. package/build/codemods/codemod_0003-rename_find_paginated.d.cts.map +1 -0
  53. package/build/codemods/codemod_0003-rename_find_paginated.d.mts +9 -0
  54. package/build/codemods/codemod_0003-rename_find_paginated.d.mts.map +1 -0
  55. package/build/codemods/codemod_0003-rename_find_paginated.js +17 -26
  56. package/build/codemods/codemod_0003-rename_find_paginated.js.map +1 -1
  57. package/build/codemods/index.cjs +49 -0
  58. package/build/codemods/index.cjs.map +1 -0
  59. package/build/codemods/index.d.cts +12 -0
  60. package/build/codemods/index.d.cts.map +1 -0
  61. package/build/codemods/index.d.mts +12 -0
  62. package/build/codemods/index.d.mts.map +1 -0
  63. package/build/codemods/index.js +34 -42
  64. package/build/codemods/index.js.map +1 -1
  65. package/build/config.cjs +377 -0
  66. package/build/config.cjs.map +1 -0
  67. package/build/config.d.cts +181 -0
  68. package/build/config.d.cts.map +1 -0
  69. package/build/config.d.mts +181 -0
  70. package/build/config.d.mts.map +1 -0
  71. package/build/config.js +300 -382
  72. package/build/config.js.map +1 -1
  73. package/build/docs/cache.cjs +62 -0
  74. package/build/docs/cache.cjs.map +1 -0
  75. package/build/docs/cache.d.cts +17 -0
  76. package/build/docs/cache.d.cts.map +1 -0
  77. package/build/docs/cache.d.mts +17 -0
  78. package/build/docs/cache.d.mts.map +1 -0
  79. package/build/docs/cache.js +52 -53
  80. package/build/docs/cache.js.map +1 -1
  81. package/build/docs/generate-metadata-docs.cjs +32 -0
  82. package/build/docs/generate-metadata-docs.cjs.map +1 -0
  83. package/build/docs/generate-metadata-docs.d.cts +9 -0
  84. package/build/docs/generate-metadata-docs.d.cts.map +1 -0
  85. package/build/docs/generate-metadata-docs.d.mts +9 -0
  86. package/build/docs/generate-metadata-docs.d.mts.map +1 -0
  87. package/build/docs/generate-metadata-docs.js +18 -20
  88. package/build/docs/generate-metadata-docs.js.map +1 -1
  89. package/build/docs/index.cjs +90 -0
  90. package/build/docs/index.cjs.map +1 -0
  91. package/build/docs/index.d.cts +16 -0
  92. package/build/docs/index.d.cts.map +1 -0
  93. package/build/docs/index.d.mts +16 -0
  94. package/build/docs/index.d.mts.map +1 -0
  95. package/build/docs/index.js +72 -91
  96. package/build/docs/index.js.map +1 -1
  97. package/build/docs/markdown.cjs +181 -0
  98. package/build/docs/markdown.cjs.map +1 -0
  99. package/build/docs/{markdown.d.ts → markdown.d.cts} +14 -11
  100. package/build/docs/markdown.d.cts.map +1 -0
  101. package/build/docs/markdown.d.mts +32 -0
  102. package/build/docs/markdown.d.mts.map +1 -0
  103. package/build/docs/markdown.js +152 -220
  104. package/build/docs/markdown.js.map +1 -1
  105. package/build/docs/parsing.cjs +117 -0
  106. package/build/docs/parsing.cjs.map +1 -0
  107. package/build/docs/parsing.d.cts +48 -0
  108. package/build/docs/parsing.d.cts.map +1 -0
  109. package/build/docs/parsing.d.mts +48 -0
  110. package/build/docs/parsing.d.mts.map +1 -0
  111. package/build/docs/parsing.js +86 -91
  112. package/build/docs/parsing.js.map +1 -1
  113. package/build/findEntityScopes.cjs +119 -0
  114. package/build/findEntityScopes.cjs.map +1 -0
  115. package/build/findEntityScopes.d.cts +14 -0
  116. package/build/findEntityScopes.d.cts.map +1 -0
  117. package/build/findEntityScopes.d.mts +14 -0
  118. package/build/findEntityScopes.d.mts.map +1 -0
  119. package/build/findEntityScopes.js +79 -121
  120. package/build/findEntityScopes.js.map +1 -1
  121. package/build/foreignKeyOrdering.cjs +52 -0
  122. package/build/foreignKeyOrdering.cjs.map +1 -0
  123. package/build/foreignKeyOrdering.d.cts +8 -0
  124. package/build/foreignKeyOrdering.d.cts.map +1 -0
  125. package/build/foreignKeyOrdering.d.mts +8 -0
  126. package/build/foreignKeyOrdering.d.mts.map +1 -0
  127. package/build/foreignKeyOrdering.js +46 -55
  128. package/build/foreignKeyOrdering.js.map +1 -1
  129. package/build/generate.cjs +127 -0
  130. package/build/generate.cjs.map +1 -0
  131. package/build/generate.d.cts +17 -0
  132. package/build/generate.d.cts.map +1 -0
  133. package/build/generate.d.mts +17 -0
  134. package/build/generate.d.mts.map +1 -0
  135. package/build/generate.js +109 -129
  136. package/build/generate.js.map +1 -1
  137. package/build/generateEntitiesFile.cjs +46 -0
  138. package/build/generateEntitiesFile.cjs.map +1 -0
  139. package/build/generateEntitiesFile.d.cts +11 -0
  140. package/build/generateEntitiesFile.d.cts.map +1 -0
  141. package/build/generateEntitiesFile.d.mts +11 -0
  142. package/build/generateEntitiesFile.d.mts.map +1 -0
  143. package/build/generateEntitiesFile.js +28 -25
  144. package/build/generateEntitiesFile.js.map +1 -1
  145. package/build/generateEntityCodegenFile.cjs +936 -0
  146. package/build/generateEntityCodegenFile.cjs.map +1 -0
  147. package/build/generateEntityCodegenFile.d.cts +16 -0
  148. package/build/generateEntityCodegenFile.d.cts.map +1 -0
  149. package/build/generateEntityCodegenFile.d.mts +16 -0
  150. package/build/generateEntityCodegenFile.d.mts.map +1 -0
  151. package/build/generateEntityCodegenFile.js +707 -852
  152. package/build/generateEntityCodegenFile.js.map +1 -1
  153. package/build/generateEntityFile.cjs +23 -0
  154. package/build/generateEntityFile.cjs.map +1 -0
  155. package/build/generateEntityFile.d.cts +9 -0
  156. package/build/generateEntityFile.d.cts.map +1 -0
  157. package/build/generateEntityFile.d.mts +9 -0
  158. package/build/generateEntityFile.d.mts.map +1 -0
  159. package/build/generateEntityFile.js +11 -8
  160. package/build/generateEntityFile.js.map +1 -1
  161. package/build/generateEntityTestFile.cjs +25 -0
  162. package/build/generateEntityTestFile.cjs.map +1 -0
  163. package/build/generateEntityTestFile.d.cts +9 -0
  164. package/build/generateEntityTestFile.d.cts.map +1 -0
  165. package/build/generateEntityTestFile.d.mts +9 -0
  166. package/build/generateEntityTestFile.d.mts.map +1 -0
  167. package/build/generateEntityTestFile.js +10 -7
  168. package/build/generateEntityTestFile.js.map +1 -1
  169. package/build/generateEnumFile.cjs +73 -0
  170. package/build/generateEnumFile.cjs.map +1 -0
  171. package/build/generateEnumFile.d.cts +9 -0
  172. package/build/generateEnumFile.d.cts.map +1 -0
  173. package/build/generateEnumFile.d.mts +9 -0
  174. package/build/generateEnumFile.d.mts.map +1 -0
  175. package/build/generateEnumFile.js +33 -43
  176. package/build/generateEnumFile.js.map +1 -1
  177. package/build/generateFactoriesFiles.cjs +28 -0
  178. package/build/generateFactoriesFiles.cjs.map +1 -0
  179. package/build/generateFactoriesFiles.d.cts +7 -0
  180. package/build/generateFactoriesFiles.d.cts.map +1 -0
  181. package/build/generateFactoriesFiles.d.mts +7 -0
  182. package/build/generateFactoriesFiles.d.mts.map +1 -0
  183. package/build/generateFactoriesFiles.js +21 -16
  184. package/build/generateFactoriesFiles.js.map +1 -1
  185. package/build/generateFlushFunction.cjs +61 -0
  186. package/build/generateFlushFunction.cjs.map +1 -0
  187. package/build/{generateFlushFunction.d.ts → generateFlushFunction.d.cts} +8 -4
  188. package/build/generateFlushFunction.d.cts.map +1 -0
  189. package/build/generateFlushFunction.d.mts +23 -0
  190. package/build/generateFlushFunction.d.mts.map +1 -0
  191. package/build/generateFlushFunction.js +32 -73
  192. package/build/generateFlushFunction.js.map +1 -1
  193. package/build/generateMetadataFile.cjs +290 -0
  194. package/build/generateMetadataFile.cjs.map +1 -0
  195. package/build/generateMetadataFile.d.cts +8 -0
  196. package/build/generateMetadataFile.d.cts.map +1 -0
  197. package/build/generateMetadataFile.d.mts +8 -0
  198. package/build/generateMetadataFile.d.mts.map +1 -0
  199. package/build/generateMetadataFile.js +111 -142
  200. package/build/generateMetadataFile.js.map +1 -1
  201. package/build/generatePgEnumFile.cjs +21 -0
  202. package/build/generatePgEnumFile.cjs.map +1 -0
  203. package/build/generatePgEnumFile.d.cts +9 -0
  204. package/build/generatePgEnumFile.d.cts.map +1 -0
  205. package/build/generatePgEnumFile.d.mts +9 -0
  206. package/build/generatePgEnumFile.d.mts.map +1 -0
  207. package/build/generatePgEnumFile.js +12 -9
  208. package/build/generatePgEnumFile.js.map +1 -1
  209. package/build/index.cjs +135 -0
  210. package/build/index.cjs.map +1 -0
  211. package/build/index.d.cts +12 -0
  212. package/build/index.d.cts.map +1 -0
  213. package/build/index.d.mts +12 -0
  214. package/build/index.d.mts.map +1 -0
  215. package/build/index.js +105 -147
  216. package/build/index.js.map +1 -1
  217. package/build/inheritance.cjs +213 -0
  218. package/build/inheritance.cjs.map +1 -0
  219. package/build/inheritance.d.cts +12 -0
  220. package/build/inheritance.d.cts.map +1 -0
  221. package/build/inheritance.d.mts +12 -0
  222. package/build/inheritance.d.mts.map +1 -0
  223. package/build/inheritance.js +193 -247
  224. package/build/inheritance.js.map +1 -1
  225. package/build/installSkills.cjs +68 -0
  226. package/build/installSkills.cjs.map +1 -0
  227. package/build/{installSkills.d.ts → installSkills.d.cts} +5 -1
  228. package/build/installSkills.d.cts.map +1 -0
  229. package/build/installSkills.d.mts +16 -0
  230. package/build/installSkills.d.mts.map +1 -0
  231. package/build/installSkills.js +55 -57
  232. package/build/installSkills.js.map +1 -1
  233. package/build/keywords.cjs +7 -0
  234. package/build/keywords.cjs.map +1 -0
  235. package/build/keywords.d.cts +5 -0
  236. package/build/keywords.d.cts.map +1 -0
  237. package/build/keywords.d.mts +5 -0
  238. package/build/keywords.d.mts.map +1 -0
  239. package/build/keywords.js +5 -4
  240. package/build/keywords.js.map +1 -1
  241. package/build/loadMetadata.cjs +39 -0
  242. package/build/loadMetadata.cjs.map +1 -0
  243. package/build/loadMetadata.d.cts +31 -0
  244. package/build/loadMetadata.d.cts.map +1 -0
  245. package/build/loadMetadata.d.mts +31 -0
  246. package/build/loadMetadata.d.mts.map +1 -0
  247. package/build/loadMetadata.js +32 -39
  248. package/build/loadMetadata.js.map +1 -1
  249. package/build/logger.cjs +28 -0
  250. package/build/logger.cjs.map +1 -0
  251. package/build/logger.d.cts +13 -0
  252. package/build/logger.d.cts.map +1 -0
  253. package/build/logger.d.mts +13 -0
  254. package/build/logger.d.mts.map +1 -0
  255. package/build/logger.js +17 -16
  256. package/build/logger.js.map +1 -1
  257. package/build/scanEntityFiles.cjs +46 -0
  258. package/build/scanEntityFiles.cjs.map +1 -0
  259. package/build/scanEntityFiles.d.cts +8 -0
  260. package/build/scanEntityFiles.d.cts.map +1 -0
  261. package/build/scanEntityFiles.d.mts +8 -0
  262. package/build/scanEntityFiles.d.mts.map +1 -0
  263. package/build/scanEntityFiles.js +37 -42
  264. package/build/scanEntityFiles.js.map +1 -1
  265. package/build/sortForeignKeys.cjs +99 -0
  266. package/build/sortForeignKeys.cjs.map +1 -0
  267. package/build/{sortForeignKeys.d.ts → sortForeignKeys.d.cts} +8 -4
  268. package/build/sortForeignKeys.d.cts.map +1 -0
  269. package/build/sortForeignKeys.d.mts +35 -0
  270. package/build/sortForeignKeys.d.mts.map +1 -0
  271. package/build/sortForeignKeys.js +88 -117
  272. package/build/sortForeignKeys.js.map +1 -1
  273. package/build/symbols.cjs +226 -0
  274. package/build/symbols.cjs.map +1 -0
  275. package/build/symbols.d.cts +114 -0
  276. package/build/symbols.d.cts.map +1 -0
  277. package/build/symbols.d.mts +114 -0
  278. package/build/symbols.d.mts.map +1 -0
  279. package/build/symbols.js +115 -116
  280. package/build/symbols.js.map +1 -1
  281. package/build/tsdoc.cjs +22 -0
  282. package/build/tsdoc.cjs.map +1 -0
  283. package/build/tsdoc.d.cts +15 -0
  284. package/build/tsdoc.d.cts.map +1 -0
  285. package/build/tsdoc.d.mts +15 -0
  286. package/build/tsdoc.d.mts.map +1 -0
  287. package/build/tsdoc.js +18 -15
  288. package/build/tsdoc.js.map +1 -1
  289. package/build/utils.cjs +173 -0
  290. package/build/utils.cjs.map +1 -0
  291. package/build/utils.d.cts +34 -0
  292. package/build/utils.d.cts.map +1 -0
  293. package/build/utils.d.mts +34 -0
  294. package/build/utils.d.mts.map +1 -0
  295. package/build/utils.js +112 -166
  296. package/build/utils.js.map +1 -1
  297. package/build/write-json-schema.cjs +23 -0
  298. package/build/write-json-schema.cjs.map +1 -0
  299. package/build/write-json-schema.d.cts +1 -0
  300. package/build/write-json-schema.d.mts +1 -0
  301. package/build/write-json-schema.js +19 -13
  302. package/build/write-json-schema.js.map +1 -1
  303. package/package.json +28 -5
  304. package/build/EntityDbMetadata.d.ts +0 -271
  305. package/build/codemods/Codemod.d.ts +0 -13
  306. package/build/codemods/Codemod.js.map +0 -1
  307. package/build/codemods/JscodeshiftMod.d.ts +0 -10
  308. package/build/codemods/codemod_0001-rename_has_async_property.d.ts +0 -6
  309. package/build/codemods/codemod_0002-rename_async_query_fields.d.ts +0 -6
  310. package/build/codemods/codemod_0003-rename_find_paginated.d.ts +0 -6
  311. package/build/codemods/index.d.ts +0 -8
  312. package/build/config.d.ts +0 -178
  313. package/build/docs/cache.d.ts +0 -13
  314. package/build/docs/generate-metadata-docs.d.ts +0 -5
  315. package/build/docs/index.d.ts +0 -13
  316. package/build/docs/parsing.d.ts +0 -45
  317. package/build/findEntityScopes.d.ts +0 -10
  318. package/build/foreignKeyOrdering.d.ts +0 -2
  319. package/build/generate.d.ts +0 -11
  320. package/build/generateEntitiesFile.d.ts +0 -6
  321. package/build/generateEntityCodegenFile.d.ts +0 -11
  322. package/build/generateEntityFile.d.ts +0 -5
  323. package/build/generateEntityTestFile.d.ts +0 -5
  324. package/build/generateEnumFile.d.ts +0 -4
  325. package/build/generateFactoriesFiles.d.ts +0 -3
  326. package/build/generateMetadataFile.d.ts +0 -4
  327. package/build/generatePgEnumFile.d.ts +0 -4
  328. package/build/index.d.ts +0 -11
  329. package/build/inheritance.d.ts +0 -9
  330. package/build/keywords.d.ts +0 -1
  331. package/build/loadMetadata.d.ts +0 -25
  332. package/build/logger.d.ts +0 -9
  333. package/build/scanEntityFiles.d.ts +0 -4
  334. package/build/symbols.d.ts +0 -110
  335. package/build/tsdoc.d.ts +0 -11
  336. package/build/utils.d.ts +0 -30
  337. package/build/write-json-schema.d.ts +0 -1
@@ -0,0 +1,213 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utils = require("./utils.cjs");
3
+ require("./config.cjs");
4
+ const require_EntityDbMetadata = require("./EntityDbMetadata.cjs");
5
+ //#region src/inheritance.ts
6
+ function applyInheritanceUpdates(config, db) {
7
+ const { entities, entitiesByName } = db;
8
+ setClassTableInheritance(entities, entitiesByName);
9
+ expandSingleTableInheritance(config, entitiesByName, entities);
10
+ rewriteSingleTableForeignKeys(config, entities);
11
+ setupSubTypeSpecialization(config, entities);
12
+ require_EntityDbMetadata.canonicalizeOtherEntities(db);
13
+ }
14
+ /**
15
+ * Looks for subtypes specializing a FK of their base type, and give them a specialized m2o.
16
+ *
17
+ * I.e. `SmallPublishers.group: SmallPublisherGroup`.
18
+ *
19
+ * This means the `publishers.group_id` FK will actually be in the `EntityDbMetadata` twice,
20
+ * once for the base and once for the child, which is unusual, but gets the types generated
21
+ * that we want, and then we fixup/dedupe them at runtime in `configure.ts` when creating
22
+ * `meta.allFields`.
23
+ */
24
+ function setupSubTypeSpecialization(config, entities) {
25
+ for (const entity of entities) if (entity.baseType) {
26
+ const entityConfig = config.entities[entity.name];
27
+ const baseConfig = config.entities[entity.baseType.name];
28
+ for (const rel of [...entity.baseType.manyToOnes, ...entity.baseType.oneToManys]) {
29
+ const { notNull } = entityConfig?.relations?.[rel.fieldName] ?? {};
30
+ const subType = entityConfig?.relations?.[rel.fieldName]?.subType ?? baseConfig?.relations?.[rel.fieldName]?.subType ?? baseConfig?.relations?.[rel.otherFieldName]?.subType ?? (notNull ? rel.otherEntity.name : void 0);
31
+ if (!subType) {} else if (subType === "self" && rel.kind === "m2o") entity.manyToOnes.push({
32
+ ...rel,
33
+ ...notNull ? { notNull } : {},
34
+ otherEntity: require_EntityDbMetadata.makeEntity(entity.name)
35
+ });
36
+ else if (subType === "self" && rel.kind === "o2m") entity.oneToManys.push({
37
+ ...rel,
38
+ ...notNull ? { notNull } : {},
39
+ otherEntity: require_EntityDbMetadata.makeEntity(entity.name)
40
+ });
41
+ else if (rel.kind === "m2o") entity.manyToOnes.push({
42
+ ...rel,
43
+ ...notNull ? { notNull } : {},
44
+ otherEntity: require_EntityDbMetadata.makeEntity(subType)
45
+ });
46
+ else if (rel.kind === "o2m") entity.oneToManys.push({
47
+ ...rel,
48
+ ...notNull ? { notNull } : {},
49
+ otherEntity: require_EntityDbMetadata.makeEntity(subType)
50
+ });
51
+ }
52
+ for (const field of entity.baseType?.primitives ?? []) {
53
+ const { notNull } = entityConfig?.fields?.[field.fieldName] ?? {};
54
+ if (notNull) entity.primitives.push({
55
+ ...field,
56
+ notNull
57
+ });
58
+ }
59
+ }
60
+ }
61
+ /**
62
+ * Ensure CTI base types have their inheritanceType set.
63
+ *
64
+ * (We automatically set `inheritanceType` for STI tables when we see their config
65
+ * setup, see `expandSingleTableInheritance`.)
66
+ */
67
+ function setClassTableInheritance(entities, entitiesByName) {
68
+ const ctiBaseNames = [];
69
+ for (const entity of entities) if (entity.baseClassName) {
70
+ ctiBaseNames.push(entity.baseClassName);
71
+ const base = entitiesByName[entity.baseClassName];
72
+ entity.baseType = base;
73
+ base.subTypes.push(entity);
74
+ }
75
+ for (const entity of entities) if (ctiBaseNames.includes(entity.name)) entity.inheritanceType = "cti";
76
+ }
77
+ /** Expands STI tables into multiple entities, so they get separate `SubTypeCodegen.ts` & `SubType.ts` files. */
78
+ function expandSingleTableInheritance(config, entitiesByName, entities) {
79
+ for (const entity of entities) {
80
+ const [fieldName, stiField] = Object.entries(config.entities[entity.name]?.fields || {}).find(([, f]) => !!f.stiDiscriminator) ?? [];
81
+ if (fieldName && stiField && stiField.stiDiscriminator) {
82
+ entity.inheritanceType = "sti";
83
+ const enumField = entity.enums.find((e) => e.fieldName === fieldName) ?? require_utils.fail(`No enum column found for ${entity.name}.${fieldName}, which is required to use singleTableInheritance`);
84
+ entity.stiDiscriminatorField = enumField.fieldName;
85
+ const subTypes = Object.entries(stiField.stiDiscriminator);
86
+ const allFields = [...Object.entries(config.entities[entity.name]?.fields ?? {}), ...Object.entries(config.entities[entity.name]?.relations ?? {})];
87
+ const availableCodes = subTypes.map(([code]) => code);
88
+ const availableNames = subTypes.map(([, name]) => name);
89
+ const available = [...availableCodes, ...availableNames];
90
+ allFields.filter(([name, f]) => {
91
+ if (f.stiType && !available.includes(f.stiType)) require_utils.fail(`${name}.stiType '${f.stiType}' is invalid, expected one of ${available.join(", ")}`);
92
+ });
93
+ for (const [enumCode, subTypeName] of subTypes) {
94
+ const subTypeFields = allFields.filter(([, f]) => f.stiType === subTypeName || f.stiType === enumCode);
95
+ const subTypeFieldNames = subTypeFields.map(([name]) => name);
96
+ function maybeRequired(field) {
97
+ if ((subTypeFields.find(([name]) => name === field.fieldName)?.[1]).notNull) field.notNull = true;
98
+ return field;
99
+ }
100
+ const subEntity = {
101
+ name: subTypeName,
102
+ entity: require_EntityDbMetadata.makeEntity(subTypeName),
103
+ tableName: entity.tableName,
104
+ primaryKey: entity.primaryKey,
105
+ primitives: entity.primitives.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),
106
+ enums: entity.enums.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),
107
+ pgEnums: entity.pgEnums.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),
108
+ manyToOnes: entity.manyToOnes.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),
109
+ oneToManys: entity.oneToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),
110
+ largeOneToManys: entity.largeOneToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),
111
+ oneToOnes: entity.oneToOnes.filter((f) => subTypeFieldNames.includes(f.fieldName)),
112
+ manyToManys: entity.manyToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),
113
+ largeManyToManys: entity.largeManyToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),
114
+ manyToManyEnums: entity.manyToManyEnums.filter((f) => subTypeFieldNames.includes(f.fieldName)),
115
+ polymorphics: entity.polymorphics.filter((f) => subTypeFieldNames.includes(f.fieldName)),
116
+ tagName: entity.tagName,
117
+ createdAt: void 0,
118
+ updatedAt: void 0,
119
+ deletedAt: void 0,
120
+ baseClassName: entity.name,
121
+ baseType: entity,
122
+ subTypes: [],
123
+ inheritanceType: "sti",
124
+ stiDiscriminatorValue: (enumField.enumRows.find((r) => r.code === enumCode) ?? require_utils.fail(`No enum row found for ${entity.name}.${fieldName}.${enumCode}`)).id,
125
+ abstract: false,
126
+ nonDeferredFkOrder: entity.nonDeferredFkOrder,
127
+ get nonDeferredFks() {
128
+ return [...this.manyToOnes.filter((r) => !r.isDeferredAndDeferrable), ...this.polymorphics.flatMap((p) => p.components).filter((c) => !c.isDeferredAndDeferrable)];
129
+ },
130
+ get nonDeferredManyToManyFks() {
131
+ return this.manyToManys.filter((r) => !r.isDeferredAndDeferrable);
132
+ }
133
+ };
134
+ entity.primitives = entity.primitives.filter((f) => !subTypeFieldNames.includes(f.fieldName));
135
+ entity.enums = entity.enums.filter((f) => !subTypeFieldNames.includes(f.fieldName));
136
+ entity.pgEnums = entity.pgEnums.filter((f) => !subTypeFieldNames.includes(f.fieldName));
137
+ entity.manyToOnes = entity.manyToOnes.filter((f) => !subTypeFieldNames.includes(f.fieldName));
138
+ entity.oneToManys = entity.oneToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));
139
+ entity.largeOneToManys = entity.largeOneToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));
140
+ entity.oneToOnes = entity.oneToOnes.filter((f) => !subTypeFieldNames.includes(f.fieldName));
141
+ entity.manyToManys = entity.manyToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));
142
+ entity.largeManyToManys = entity.largeManyToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));
143
+ entity.manyToManyEnums = entity.manyToManyEnums.filter((f) => !subTypeFieldNames.includes(f.fieldName));
144
+ entity.polymorphics = entity.polymorphics.filter((f) => !subTypeFieldNames.includes(f.fieldName));
145
+ entity.subTypes.push(subEntity);
146
+ entities.push(subEntity);
147
+ entitiesByName[subEntity.name] = subEntity;
148
+ }
149
+ }
150
+ }
151
+ }
152
+ let stiEntities;
153
+ function getStiEntities(entities) {
154
+ if (stiEntities) return stiEntities;
155
+ stiEntities = /* @__PURE__ */ new Map();
156
+ for (const entity of entities) if (entity.inheritanceType === "sti" && entity.stiDiscriminatorField) {
157
+ const base = entity;
158
+ const subTypes = entities.filter((s) => s.baseClassName === entity.name && s !== entity);
159
+ stiEntities.set(entity.name, {
160
+ base,
161
+ subTypes
162
+ });
163
+ for (const subType of subTypes) stiEntities.set(subType.name, {
164
+ base,
165
+ subTypes: []
166
+ });
167
+ }
168
+ return stiEntities;
169
+ }
170
+ /** Finds FKs pointing to the base table and, if configured, rewrites them to point to the sub-tables. */
171
+ function rewriteSingleTableForeignKeys(config, entities) {
172
+ const stiEntities = getStiEntities(entities);
173
+ if (stiEntities.size === 0) return;
174
+ for (const entity of entities) {
175
+ for (const m2o of entity.manyToOnes) {
176
+ const target = stiEntities.get(m2o.otherEntity.name);
177
+ const base = target?.base.entity.name;
178
+ const stiType = base && config.entities[base]?.relations?.[m2o.otherFieldName]?.stiType;
179
+ if (target && stiType) {
180
+ const { subTypes } = target;
181
+ m2o.otherEntity = (subTypes.find((s) => s.name === stiType) ?? require_utils.fail(`Could not find STI type '${stiType}' in ${subTypes.map((s) => s.name)}`)).entity;
182
+ }
183
+ }
184
+ for (const poly of entity.polymorphics) for (const comp of poly.components) {
185
+ const target = stiEntities.get(comp.otherEntity.name);
186
+ const base = target?.base.entity.name;
187
+ const stiType = base && config.entities[base]?.relations?.[comp.otherFieldName]?.stiType;
188
+ if (target && stiType) {
189
+ const { subTypes } = target;
190
+ comp.otherEntity = (subTypes.find((s) => s.name === stiType) ?? require_utils.fail(`Could not find STI type '${stiType}' in ${subTypes.map((s) => s.name)}`)).entity;
191
+ }
192
+ }
193
+ for (const o2m of entity.oneToManys) {
194
+ const target = stiEntities.get(o2m.otherEntity.name);
195
+ if (target && target.base.inheritanceType === "sti") {
196
+ const otherField = target.subTypes.find((st) => !target.base.manyToOnes.some((m) => m.fieldName === o2m.otherFieldName) && st.manyToOnes.some((m) => m.fieldName === o2m.otherFieldName));
197
+ if (otherField) o2m.otherEntity = otherField.entity;
198
+ }
199
+ }
200
+ for (const m2m of entity.manyToManys) {
201
+ const target = stiEntities.get(m2m.otherEntity.name);
202
+ if (target && target.base.inheritanceType === "sti") {
203
+ const otherField = target.subTypes.find((st) => !target.base.manyToManys.some((m) => m.fieldName === m2m.otherFieldName) && st.manyToManys.some((m) => m.fieldName === m2m.otherFieldName));
204
+ if (otherField) m2m.otherEntity = otherField.entity;
205
+ }
206
+ }
207
+ }
208
+ }
209
+ //#endregion
210
+ exports.applyInheritanceUpdates = applyInheritanceUpdates;
211
+ exports.getStiEntities = getStiEntities;
212
+
213
+ //# sourceMappingURL=inheritance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritance.cjs","names":["makeEntity","fail"],"sources":["../src/inheritance.ts"],"sourcesContent":["import { type Config } from \"./config.ts\";\nimport {\n type DbMetadata,\n type EntityDbMetadata,\n type ManyToManyField,\n type ManyToOneField,\n type PolymorphicFieldComponent,\n canonicalizeOtherEntities,\n makeEntity,\n} from \"./EntityDbMetadata.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport function applyInheritanceUpdates(config: Config, db: DbMetadata): void {\n const { entities, entitiesByName } = db;\n setClassTableInheritance(entities, entitiesByName);\n expandSingleTableInheritance(config, entitiesByName, entities);\n rewriteSingleTableForeignKeys(config, entities);\n setupSubTypeSpecialization(config, entities);\n // Now that all relations (incl. specialized ones) exist, collapse the duplicate `otherEntity` objects\n canonicalizeOtherEntities(db);\n}\n\n/**\n * Looks for subtypes specializing a FK of their base type, and give them a specialized m2o.\n *\n * I.e. `SmallPublishers.group: SmallPublisherGroup`.\n *\n * This means the `publishers.group_id` FK will actually be in the `EntityDbMetadata` twice,\n * once for the base and once for the child, which is unusual, but gets the types generated\n * that we want, and then we fixup/dedupe them at runtime in `configure.ts` when creating\n * `meta.allFields`.\n */\nfunction setupSubTypeSpecialization(config: Config, entities: EntityDbMetadata[]): void {\n for (const entity of entities) {\n if (entity.baseType) {\n const entityConfig = config.entities[entity.name];\n const baseConfig = config.entities[entity.baseType.name];\n // Look through the base's m2os & o2ms, looking for a config specialization\n for (const rel of [...entity.baseType.manyToOnes, ...entity.baseType.oneToManys]) {\n const { notNull } = entityConfig?.relations?.[rel.fieldName] ?? {};\n const subType =\n entityConfig?.relations?.[rel.fieldName]?.subType ??\n baseConfig?.relations?.[rel.fieldName]?.subType ??\n // Probe the otherFieldName for a `subType: \"self\"` on self-referential relations in STI tables\n baseConfig?.relations?.[rel.otherFieldName]?.subType ??\n // if we are only marking the relation as required and not specifying a subtype, then use the original type\n (notNull ? rel.otherEntity.name : undefined);\n\n if (!subType) {\n // continue...\n } else if (subType === \"self\" && rel.kind === \"m2o\") {\n // Specialize `TaskNew.copiedFrom: TaskNew` & `TaskOld.copiedFrom: TaskOld`\n entity.manyToOnes.push({ ...rel, ...(notNull ? { notNull } : {}), otherEntity: makeEntity(entity.name) });\n } else if (subType === \"self\" && rel.kind === \"o2m\") {\n // Specialize `TaskNew.copiedTo: TaskNew[]` & `TaskOld.copiedTo: TaskOld[]`\n entity.oneToManys.push({ ...rel, ...(notNull ? { notNull } : {}), otherEntity: makeEntity(entity.name) });\n } else if (rel.kind === \"m2o\") {\n // Specialize `SmallPublisher.group: SmallPublisherGroup`\n entity.manyToOnes.push({ ...rel, ...(notNull ? { notNull } : {}), otherEntity: makeEntity(subType) });\n } else if (rel.kind === \"o2m\") {\n // Specialize `SmallPublisherGroup.publishers: SmallPublisher`\n entity.oneToManys.push({ ...rel, ...(notNull ? { notNull } : {}), otherEntity: makeEntity(subType) });\n }\n }\n\n // Look through the base's primitives looking for a config specialization\n for (const field of entity.baseType?.primitives ?? []) {\n // the only specialization a primitive can have is nullability\n const { notNull } = entityConfig?.fields?.[field.fieldName] ?? {};\n if (notNull) {\n entity.primitives.push({ ...field, notNull });\n }\n }\n }\n }\n}\n\n/**\n * Ensure CTI base types have their inheritanceType set.\n *\n * (We automatically set `inheritanceType` for STI tables when we see their config\n * setup, see `expandSingleTableInheritance`.)\n */\nfunction setClassTableInheritance(\n entities: EntityDbMetadata[],\n entitiesByName: Record<string, EntityDbMetadata>,\n): void {\n const ctiBaseNames: string[] = [];\n for (const entity of entities) {\n if (entity.baseClassName) {\n ctiBaseNames.push(entity.baseClassName);\n const base = entitiesByName[entity.baseClassName];\n entity.baseType = base;\n base.subTypes.push(entity);\n }\n }\n for (const entity of entities) {\n if (ctiBaseNames.includes(entity.name)) entity.inheritanceType = \"cti\";\n }\n}\n\n/** Expands STI tables into multiple entities, so they get separate `SubTypeCodegen.ts` & `SubType.ts` files. */\nfunction expandSingleTableInheritance(\n config: Config,\n entitiesByName: Record<string, EntityDbMetadata>,\n entities: EntityDbMetadata[],\n): void {\n for (const entity of entities) {\n const [fieldName, stiField] =\n Object.entries(config.entities[entity.name]?.fields || {}).find(([, f]) => !!f.stiDiscriminator) ?? [];\n if (fieldName && stiField && stiField.stiDiscriminator) {\n entity.inheritanceType = \"sti\";\n\n // Ensure we have an enum field so that we can bake the STI discriminators into the metadata.ts file\n const enumField =\n entity.enums.find((e) => e.fieldName === fieldName) ??\n fail(`No enum column found for ${entity.name}.${fieldName}, which is required to use singleTableInheritance`);\n entity.stiDiscriminatorField = enumField.fieldName;\n\n // Find the available discriminators/subtypes, i.e. NEW => NewTask, OLD => OldTask, etc.\n const subTypes = Object.entries(stiField.stiDiscriminator);\n\n const allFields = [\n ...Object.entries(config.entities[entity.name]?.fields ?? {}),\n ...Object.entries(config.entities[entity.name]?.relations ?? {}),\n ];\n\n // Make sure there aren't any typos in `stiType`s\n const availableCodes = subTypes.map(([code]) => code);\n const availableNames = subTypes.map(([, name]) => name);\n const available = [...availableCodes, ...availableNames];\n allFields.filter(([name, f]) => {\n if (f.stiType && !available.includes(f.stiType)) {\n fail(`${name}.stiType '${f.stiType}' is invalid, expected one of ${available.join(\", \")}`);\n }\n });\n\n // Now split each subType out into its out entity\n for (const [enumCode, subTypeName] of subTypes) {\n // Find all the base entity's fields that belong to us\n const subTypeFields = allFields.filter(([, f]) => f.stiType === subTypeName || f.stiType === enumCode);\n const subTypeFieldNames = subTypeFields.map(([name]) => name);\n\n // Make fields as required\n function maybeRequired<T extends { notNull: boolean; fieldName: string }>(field: T): T {\n const config = subTypeFields.find(([name]) => name === field.fieldName)?.[1]!;\n if (config.notNull) field.notNull = true;\n return field;\n }\n\n // Synthesize an entity for this STI sub-entity\n const subEntity: EntityDbMetadata = {\n name: subTypeName,\n entity: makeEntity(subTypeName),\n tableName: entity.tableName,\n primaryKey: entity.primaryKey,\n primitives: entity.primitives.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),\n enums: entity.enums.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),\n pgEnums: entity.pgEnums.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),\n manyToOnes: entity.manyToOnes.filter((f) => subTypeFieldNames.includes(f.fieldName)).map(maybeRequired),\n oneToManys: entity.oneToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n largeOneToManys: entity.largeOneToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n oneToOnes: entity.oneToOnes.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n manyToManys: entity.manyToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n largeManyToManys: entity.largeManyToManys.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n manyToManyEnums: entity.manyToManyEnums.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n polymorphics: entity.polymorphics.filter((f) => subTypeFieldNames.includes(f.fieldName)),\n tagName: entity.tagName,\n createdAt: undefined,\n updatedAt: undefined,\n deletedAt: undefined,\n baseClassName: entity.name,\n baseType: entity,\n subTypes: [],\n inheritanceType: \"sti\",\n stiDiscriminatorValue: (\n enumField.enumRows.find((r) => r.code === enumCode) ??\n fail(`No enum row found for ${entity.name}.${fieldName}.${enumCode}`)\n ).id,\n abstract: false,\n nonDeferredFkOrder: entity.nonDeferredFkOrder,\n get nonDeferredFks(): Array<ManyToOneField | PolymorphicFieldComponent> {\n return [\n ...this.manyToOnes.filter((r) => !r.isDeferredAndDeferrable),\n ...this.polymorphics.flatMap((p) => p.components).filter((c) => !c.isDeferredAndDeferrable),\n ];\n },\n get nonDeferredManyToManyFks(): Array<ManyToManyField> {\n return this.manyToManys.filter((r) => !r.isDeferredAndDeferrable);\n },\n };\n\n // Now strip all the subclass fields from the base class\n entity.primitives = entity.primitives.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.enums = entity.enums.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.pgEnums = entity.pgEnums.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.manyToOnes = entity.manyToOnes.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.oneToManys = entity.oneToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.largeOneToManys = entity.largeOneToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.oneToOnes = entity.oneToOnes.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.manyToManys = entity.manyToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.largeManyToManys = entity.largeManyToManys.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.manyToManyEnums = entity.manyToManyEnums.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.polymorphics = entity.polymorphics.filter((f) => !subTypeFieldNames.includes(f.fieldName));\n entity.subTypes.push(subEntity);\n\n entities.push(subEntity);\n entitiesByName[subEntity.name] = subEntity;\n }\n }\n }\n}\n\ntype StiEntityMap = Map<string, { base: EntityDbMetadata; subTypes: EntityDbMetadata[] }>;\nlet stiEntities: StiEntityMap;\n\nexport function getStiEntities(entities: EntityDbMetadata[]): StiEntityMap {\n if (stiEntities) return stiEntities;\n stiEntities = new Map();\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorField) {\n const base = entity;\n const subTypes = entities.filter((s) => s.baseClassName === entity.name && s !== entity);\n stiEntities.set(entity.name, { base, subTypes });\n // Allow looking up by subType name\n for (const subType of subTypes) {\n stiEntities.set(subType.name, { base, subTypes: [] });\n }\n }\n }\n return stiEntities;\n}\n\n/** Finds FKs pointing to the base table and, if configured, rewrites them to point to the sub-tables. */\nfunction rewriteSingleTableForeignKeys(config: Config, entities: EntityDbMetadata[]): void {\n // See if we even have any STI tables\n const stiEntities = getStiEntities(entities);\n if (stiEntities.size === 0) return;\n // Scan for other entities/relations that point to the STI table\n for (const entity of entities) {\n // m2os -- Look for `entity.task_id` FKs pointing at `Task` and, if configured, rewrite them to point at `TaskOld`\n for (const m2o of entity.manyToOnes) {\n const target = stiEntities.get(m2o.otherEntity.name);\n const base = target?.base.entity.name;\n // See if the user has pushed `Task.entities` down to a subtype\n const stiType = base && config.entities[base]?.relations?.[m2o.otherFieldName]?.stiType;\n if (target && stiType) {\n const { subTypes } = target;\n m2o.otherEntity = (\n subTypes.find((s) => s.name === stiType) ??\n fail(`Could not find STI type '${stiType}' in ${subTypes.map((s) => s.name)}`)\n ).entity;\n }\n }\n // polys -- Look for `entity.parent_task_id` FKs pointing at `Task` and, if configured, rewrite them to point at `TaskOld`\n for (const poly of entity.polymorphics) {\n for (const comp of poly.components) {\n const target = stiEntities.get(comp.otherEntity.name);\n const base = target?.base.entity.name;\n // See if the user has pushed `Task.entities` down to a subtype\n const stiType = base && config.entities[base]?.relations?.[comp.otherFieldName]?.stiType;\n if (target && stiType) {\n const { subTypes } = target;\n comp.otherEntity = (\n subTypes.find((s) => s.name === stiType) ??\n fail(`Could not find STI type '${stiType}' in ${subTypes.map((s) => s.name)}`)\n ).entity;\n }\n }\n }\n // o2ms -- Look for `entity.tasks` collections loading `task.entity_id`, but entity has been pushed down to `TaskOld`\n for (const o2m of entity.oneToManys) {\n const target = stiEntities.get(o2m.otherEntity.name);\n if (target && target.base.inheritanceType === \"sti\") {\n // Ensure the incoming FK is not in the base type, and find the 1st subtype (eventually N subtypes?)\n const otherField = target.subTypes.find(\n (st) =>\n !target.base.manyToOnes.some((m) => m.fieldName === o2m.otherFieldName) &&\n st.manyToOnes.some((m) => m.fieldName === o2m.otherFieldName),\n );\n if (otherField) {\n o2m.otherEntity = otherField.entity;\n }\n }\n }\n // m2ms -- Look for `entity.tasks` collections loading m2m rows, but `entity` has been pushed down to `TaskOld`\n for (const m2m of entity.manyToManys) {\n const target = stiEntities.get(m2m.otherEntity.name);\n if (target && target.base.inheritanceType === \"sti\") {\n // Ensure the incoming FK is not in the base type, and find the 1st subtype (eventually N subtypes?)\n const otherField = target.subTypes.find(\n (st) =>\n !target.base.manyToManys.some((m) => m.fieldName === m2m.otherFieldName) &&\n st.manyToManys.some((m) => m.fieldName === m2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M,aAAa,OAAO,SAAS,MAChC,OACC,CAAC,OAAO,KAAK,WAAW,MAAM,MAAM,EAAE,cAAc,IAAI,cAAc,KACtE,GAAG,WAAW,MAAM,MAAM,EAAE,cAAc,IAAI,cAAc,CAChE;IACA,IAAI,YACF,IAAI,cAAc,WAAW;GAEjC;EACF;EAEA,KAAK,MAAM,OAAO,OAAO,aAAa;GACpC,MAAM,SAAS,YAAY,IAAI,IAAI,YAAY,IAAI;GACnD,IAAI,UAAU,OAAO,KAAK,oBAAoB,OAAO;IAEnD,MAAM,aAAa,OAAO,SAAS,MAChC,OACC,CAAC,OAAO,KAAK,YAAY,MAAM,MAAM,EAAE,cAAc,IAAI,cAAc,KACvE,GAAG,YAAY,MAAM,MAAM,EAAE,cAAc,IAAI,cAAc,CACjE;IACA,IAAI,YACF,IAAI,cAAc,WAAW;GAEjC;EACF;CACF;AACF"}
@@ -0,0 +1,12 @@
1
+ import { Config } from "./config.cjs";
2
+ import { DbMetadata, EntityDbMetadata } from "./EntityDbMetadata.cjs";
3
+ //#region src/inheritance.d.ts
4
+ declare function applyInheritanceUpdates(config: Config, db: DbMetadata): void;
5
+ type StiEntityMap = Map<string, {
6
+ base: EntityDbMetadata;
7
+ subTypes: EntityDbMetadata[];
8
+ }>;
9
+ declare function getStiEntities(entities: EntityDbMetadata[]): StiEntityMap;
10
+ //#endregion
11
+ export { applyInheritanceUpdates, getStiEntities };
12
+ //# sourceMappingURL=inheritance.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritance.d.cts","names":[],"sources":["../src/inheritance.ts"],"mappings":";;;iBAYgB,wBAAwB,QAAQ,QAAQ,IAAI;KAyMvD,eAAe;EAAc,MAAM;EAAkB,UAAU;;iBAGpD,eAAe,UAAU,qBAAqB"}
@@ -0,0 +1,12 @@
1
+ import { Config } from "./config.mjs";
2
+ import { DbMetadata, EntityDbMetadata } from "./EntityDbMetadata.mjs";
3
+ //#region src/inheritance.d.ts
4
+ declare function applyInheritanceUpdates(config: Config, db: DbMetadata): void;
5
+ type StiEntityMap = Map<string, {
6
+ base: EntityDbMetadata;
7
+ subTypes: EntityDbMetadata[];
8
+ }>;
9
+ declare function getStiEntities(entities: EntityDbMetadata[]): StiEntityMap;
10
+ //#endregion
11
+ export { applyInheritanceUpdates, getStiEntities };
12
+ //# sourceMappingURL=inheritance.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritance.d.mts","names":[],"sources":["../src/inheritance.ts"],"mappings":";;;iBAYgB,wBAAwB,QAAQ,QAAQ,IAAI;KAyMvD,eAAe;EAAc,MAAM;EAAkB,UAAU;;iBAGpD,eAAe,UAAU,qBAAqB"}