ddd-ts-kit 0.14.0 → 0.16.0

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 (500) hide show
  1. package/README.md +31 -2
  2. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  3. package/dist/check/catalogue/architecture-rules.js +2 -0
  4. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  5. package/dist/check/explain/domain-docs.d.ts +3 -0
  6. package/dist/check/explain/domain-docs.d.ts.map +1 -0
  7. package/dist/check/explain/domain-docs.js +30 -0
  8. package/dist/check/explain/domain-docs.js.map +1 -0
  9. package/dist/check/explain/rule-docs.d.ts.map +1 -1
  10. package/dist/check/explain/rule-docs.js +2 -0
  11. package/dist/check/explain/rule-docs.js.map +1 -1
  12. package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
  13. package/dist/check/explain/tenancy-docs.js +3 -1
  14. package/dist/check/explain/tenancy-docs.js.map +1 -1
  15. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  16. package/dist/check/fixtures/fixtures.js +4 -0
  17. package/dist/check/fixtures/fixtures.js.map +1 -1
  18. package/dist/check/fixtures/model-function-fixtures.d.ts +4 -0
  19. package/dist/check/fixtures/model-function-fixtures.d.ts.map +1 -0
  20. package/dist/check/fixtures/model-function-fixtures.js +52 -0
  21. package/dist/check/fixtures/model-function-fixtures.js.map +1 -0
  22. package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
  23. package/dist/check/fixtures/tenancy-fixtures.js +28 -0
  24. package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
  25. package/dist/check/fixtures/value-object-file-fixtures.d.ts +4 -0
  26. package/dist/check/fixtures/value-object-file-fixtures.d.ts.map +1 -0
  27. package/dist/check/fixtures/value-object-file-fixtures.js +54 -0
  28. package/dist/check/fixtures/value-object-file-fixtures.js.map +1 -0
  29. package/dist/check/fixtures/value-object-files.d.ts +34 -0
  30. package/dist/check/fixtures/value-object-files.d.ts.map +1 -0
  31. package/dist/check/fixtures/value-object-files.js +46 -0
  32. package/dist/check/fixtures/value-object-files.js.map +1 -0
  33. package/dist/check/rules/domain-value-object-class.d.ts +3 -0
  34. package/dist/check/rules/domain-value-object-class.d.ts.map +1 -0
  35. package/dist/check/rules/domain-value-object-class.js +21 -0
  36. package/dist/check/rules/domain-value-object-class.js.map +1 -0
  37. package/dist/check/structure/class-body-brace.d.ts +6 -0
  38. package/dist/check/structure/class-body-brace.d.ts.map +1 -0
  39. package/dist/check/structure/class-body-brace.js +22 -0
  40. package/dist/check/structure/class-body-brace.js.map +1 -0
  41. package/dist/check/structure/read-structure.d.ts.map +1 -1
  42. package/dist/check/structure/read-structure.js +3 -1
  43. package/dist/check/structure/read-structure.js.map +1 -1
  44. package/dist/check/tenancy/knex-unscoped.d.ts +6 -1
  45. package/dist/check/tenancy/knex-unscoped.d.ts.map +1 -1
  46. package/dist/check/tenancy/knex-unscoped.js +19 -6
  47. package/dist/check/tenancy/knex-unscoped.js.map +1 -1
  48. package/dist/check/tenancy/raw-reaches-rows.d.ts +8 -0
  49. package/dist/check/tenancy/raw-reaches-rows.d.ts.map +1 -0
  50. package/dist/check/tenancy/raw-reaches-rows.js +91 -0
  51. package/dist/check/tenancy/raw-reaches-rows.js.map +1 -0
  52. package/dist/check/tenancy/raw-sql-text.d.ts +9 -0
  53. package/dist/check/tenancy/raw-sql-text.d.ts.map +1 -0
  54. package/dist/check/tenancy/raw-sql-text.js +29 -0
  55. package/dist/check/tenancy/raw-sql-text.js.map +1 -0
  56. package/dist/check/values/answered-literals.d.ts +8 -0
  57. package/dist/check/values/answered-literals.d.ts.map +1 -0
  58. package/dist/check/values/answered-literals.js +20 -0
  59. package/dist/check/values/answered-literals.js.map +1 -0
  60. package/dist/check/values/arrow-body.d.ts +4 -0
  61. package/dist/check/values/arrow-body.d.ts.map +1 -0
  62. package/dist/check/values/arrow-body.js +52 -0
  63. package/dist/check/values/arrow-body.js.map +1 -0
  64. package/dist/check/values/entry-role.d.ts +10 -0
  65. package/dist/check/values/entry-role.d.ts.map +1 -0
  66. package/dist/check/values/entry-role.js +40 -0
  67. package/dist/check/values/entry-role.js.map +1 -0
  68. package/dist/check/values/exported-function-body.d.ts +9 -0
  69. package/dist/check/values/exported-function-body.d.ts.map +1 -0
  70. package/dist/check/values/exported-function-body.js +29 -0
  71. package/dist/check/values/exported-function-body.js.map +1 -0
  72. package/dist/check/values/exported-values.d.ts +9 -0
  73. package/dist/check/values/exported-values.d.ts.map +1 -0
  74. package/dist/check/values/exported-values.js +48 -0
  75. package/dist/check/values/exported-values.js.map +1 -0
  76. package/dist/check/values/extends-value-object.d.ts +9 -0
  77. package/dist/check/values/extends-value-object.d.ts.map +1 -0
  78. package/dist/check/values/extends-value-object.js +25 -0
  79. package/dist/check/values/extends-value-object.js.map +1 -0
  80. package/dist/check/values/function-body.d.ts +10 -0
  81. package/dist/check/values/function-body.d.ts.map +1 -0
  82. package/dist/check/values/function-body.js +2 -0
  83. package/dist/check/values/function-body.js.map +1 -0
  84. package/dist/check/values/generate-hint.d.ts +4 -0
  85. package/dist/check/values/generate-hint.d.ts.map +1 -0
  86. package/dist/check/values/generate-hint.js +8 -0
  87. package/dist/check/values/generate-hint.js.map +1 -0
  88. package/dist/check/values/initializer-of.d.ts +3 -0
  89. package/dist/check/values/initializer-of.d.ts.map +1 -0
  90. package/dist/check/values/initializer-of.js +15 -0
  91. package/dist/check/values/initializer-of.js.map +1 -0
  92. package/dist/check/values/is-model-file.d.ts +8 -0
  93. package/dist/check/values/is-model-file.d.ts.map +1 -0
  94. package/dist/check/values/is-model-file.js +15 -0
  95. package/dist/check/values/is-model-file.js.map +1 -0
  96. package/dist/check/values/is-value-object-file.d.ts +7 -0
  97. package/dist/check/values/is-value-object-file.d.ts.map +1 -0
  98. package/dist/check/values/is-value-object-file.js +14 -0
  99. package/dist/check/values/is-value-object-file.js.map +1 -0
  100. package/dist/check/values/javascript-globals.d.ts +3 -0
  101. package/dist/check/values/javascript-globals.d.ts.map +1 -0
  102. package/dist/check/values/javascript-globals.js +22 -0
  103. package/dist/check/values/javascript-globals.js.map +1 -0
  104. package/dist/check/values/literal-at.d.ts +3 -0
  105. package/dist/check/values/literal-at.d.ts.map +1 -0
  106. package/dist/check/values/literal-at.js +7 -0
  107. package/dist/check/values/literal-at.js.map +1 -0
  108. package/dist/check/values/local-declaration.d.ts +8 -0
  109. package/dist/check/values/local-declaration.d.ts.map +1 -0
  110. package/dist/check/values/local-declaration.js +31 -0
  111. package/dist/check/values/local-declaration.js.map +1 -0
  112. package/dist/check/values/nested-bodies.d.ts +8 -0
  113. package/dist/check/values/nested-bodies.d.ts.map +1 -0
  114. package/dist/check/values/nested-bodies.js +28 -0
  115. package/dist/check/values/nested-bodies.js.map +1 -0
  116. package/dist/check/values/plain-value-functions.d.ts +10 -0
  117. package/dist/check/values/plain-value-functions.d.ts.map +1 -0
  118. package/dist/check/values/plain-value-functions.js +33 -0
  119. package/dist/check/values/plain-value-functions.js.map +1 -0
  120. package/dist/check/values/returns-package-type.d.ts +9 -0
  121. package/dist/check/values/returns-package-type.d.ts.map +1 -0
  122. package/dist/check/values/returns-package-type.js +12 -0
  123. package/dist/check/values/returns-package-type.js.map +1 -0
  124. package/dist/check/values/stands-for-a-value.d.ts +9 -0
  125. package/dist/check/values/stands-for-a-value.d.ts.map +1 -0
  126. package/dist/check/values/stands-for-a-value.js +28 -0
  127. package/dist/check/values/stands-for-a-value.js.map +1 -0
  128. package/dist/check/values/value-object-file-findings.d.ts +5 -0
  129. package/dist/check/values/value-object-file-findings.d.ts.map +1 -0
  130. package/dist/check/values/value-object-file-findings.js +96 -0
  131. package/dist/check/values/value-object-file-findings.js.map +1 -0
  132. package/dist/commands/generate.js +2 -0
  133. package/dist/commands/generate.js.map +1 -1
  134. package/dist/commands/init.d.ts.map +1 -1
  135. package/dist/commands/init.js +12 -1
  136. package/dist/commands/init.js.map +1 -1
  137. package/dist/config/index.d.ts +1 -1
  138. package/dist/config/index.d.ts.map +1 -1
  139. package/dist/config/index.js +1 -1
  140. package/dist/config/index.js.map +1 -1
  141. package/dist/config/parse-stack.d.ts.map +1 -1
  142. package/dist/config/parse-stack.js +2 -1
  143. package/dist/config/parse-stack.js.map +1 -1
  144. package/dist/config/stack.d.ts +8 -0
  145. package/dist/config/stack.d.ts.map +1 -1
  146. package/dist/config/stack.js +1 -0
  147. package/dist/config/stack.js.map +1 -1
  148. package/dist/declared/injection/laid-out-calls.d.ts +7 -0
  149. package/dist/declared/injection/laid-out-calls.d.ts.map +1 -0
  150. package/dist/declared/injection/laid-out-calls.js +14 -0
  151. package/dist/declared/injection/laid-out-calls.js.map +1 -0
  152. package/dist/declared/render-barrel.d.ts.map +1 -1
  153. package/dist/declared/render-barrel.js +2 -1
  154. package/dist/declared/render-barrel.js.map +1 -1
  155. package/dist/declared/render-dependencies-file.d.ts.map +1 -1
  156. package/dist/declared/render-dependencies-file.js +2 -1
  157. package/dist/declared/render-dependencies-file.js.map +1 -1
  158. package/dist/generate/kind.d.ts +2 -0
  159. package/dist/generate/kind.d.ts.map +1 -1
  160. package/dist/generate/kinds/context-kind.d.ts.map +1 -1
  161. package/dist/generate/kinds/context-kind.js +13 -6
  162. package/dist/generate/kinds/context-kind.js.map +1 -1
  163. package/dist/generate/kinds/next-adr-number.d.ts +4 -0
  164. package/dist/generate/kinds/next-adr-number.d.ts.map +1 -0
  165. package/dist/generate/kinds/next-adr-number.js +7 -0
  166. package/dist/generate/kinds/next-adr-number.js.map +1 -0
  167. package/dist/generate/kinds/write-adr.js +3 -6
  168. package/dist/generate/kinds/write-adr.js.map +1 -1
  169. package/dist/help/usage.d.ts +1 -1
  170. package/dist/help/usage.d.ts.map +1 -1
  171. package/dist/help/usage.js +2 -2
  172. package/dist/init/manifest/versions.js +24 -24
  173. package/dist/init/run-init.d.ts +2 -0
  174. package/dist/init/run-init.d.ts.map +1 -1
  175. package/dist/init/run-init.js +15 -1
  176. package/dist/init/run-init.js.map +1 -1
  177. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  178. package/dist/init/stack/resolve-stack.js +3 -1
  179. package/dist/init/stack/resolve-stack.js.map +1 -1
  180. package/dist/init/stack/stack-options.d.ts +2 -0
  181. package/dist/init/stack/stack-options.d.ts.map +1 -1
  182. package/dist/presets/apply-preset.d.ts +15 -0
  183. package/dist/presets/apply-preset.d.ts.map +1 -0
  184. package/dist/presets/apply-preset.js +94 -0
  185. package/dist/presets/apply-preset.js.map +1 -0
  186. package/dist/presets/grant-to-signed-in.d.ts +9 -0
  187. package/dist/presets/grant-to-signed-in.d.ts.map +1 -0
  188. package/dist/presets/grant-to-signed-in.js +61 -0
  189. package/dist/presets/grant-to-signed-in.js.map +1 -0
  190. package/dist/presets/identity-preset.d.ts +9 -0
  191. package/dist/presets/identity-preset.d.ts.map +1 -0
  192. package/dist/presets/identity-preset.js +44 -0
  193. package/dist/presets/identity-preset.js.map +1 -0
  194. package/dist/presets/identity-refusal.d.ts +5 -0
  195. package/dist/presets/identity-refusal.d.ts.map +1 -0
  196. package/dist/presets/identity-refusal.js +29 -0
  197. package/dist/presets/identity-refusal.js.map +1 -0
  198. package/dist/presets/identity-terms.d.ts +4 -0
  199. package/dist/presets/identity-terms.d.ts.map +1 -0
  200. package/dist/presets/identity-terms.js +57 -0
  201. package/dist/presets/identity-terms.js.map +1 -0
  202. package/dist/presets/no-flags.d.ts +4 -0
  203. package/dist/presets/no-flags.d.ts.map +1 -0
  204. package/dist/presets/no-flags.js +18 -0
  205. package/dist/presets/no-flags.js.map +1 -0
  206. package/dist/presets/organisations-as-tenants.d.ts +9 -0
  207. package/dist/presets/organisations-as-tenants.d.ts.map +1 -0
  208. package/dist/presets/organisations-as-tenants.js +43 -0
  209. package/dist/presets/organisations-as-tenants.js.map +1 -0
  210. package/dist/presets/preset-decision.d.ts +8 -0
  211. package/dist/presets/preset-decision.d.ts.map +1 -0
  212. package/dist/presets/preset-decision.js +19 -0
  213. package/dist/presets/preset-decision.js.map +1 -0
  214. package/dist/presets/preset-file.d.ts +13 -0
  215. package/dist/presets/preset-file.d.ts.map +1 -0
  216. package/dist/presets/preset-file.js +2 -0
  217. package/dist/presets/preset-file.js.map +1 -0
  218. package/dist/presets/preset-files.d.ts +9 -0
  219. package/dist/presets/preset-files.d.ts.map +1 -0
  220. package/dist/presets/preset-files.js +34 -0
  221. package/dist/presets/preset-files.js.map +1 -0
  222. package/dist/presets/preset-named.d.ts +3 -0
  223. package/dist/presets/preset-named.d.ts.map +1 -0
  224. package/dist/presets/preset-named.js +12 -0
  225. package/dist/presets/preset-named.js.map +1 -0
  226. package/dist/presets/preset-refusal.d.ts +6 -0
  227. package/dist/presets/preset-refusal.d.ts.map +1 -0
  228. package/dist/presets/preset-refusal.js +2 -0
  229. package/dist/presets/preset-refusal.js.map +1 -0
  230. package/dist/presets/preset-step.d.ts +8 -0
  231. package/dist/presets/preset-step.d.ts.map +1 -0
  232. package/dist/presets/preset-step.js +2 -0
  233. package/dist/presets/preset-step.js.map +1 -0
  234. package/dist/presets/preset.d.ts +36 -0
  235. package/dist/presets/preset.d.ts.map +1 -0
  236. package/dist/presets/preset.js +2 -0
  237. package/dist/presets/preset.js.map +1 -0
  238. package/dist/presets/with-authorizer-import.d.ts +6 -0
  239. package/dist/presets/with-authorizer-import.d.ts.map +1 -0
  240. package/dist/presets/with-authorizer-import.js +27 -0
  241. package/dist/presets/with-authorizer-import.js.map +1 -0
  242. package/dist/stack/stack-vars.js +2 -1
  243. package/dist/stack/stack-vars.js.map +1 -1
  244. package/dist/version.d.ts +1 -1
  245. package/dist/version.js +1 -1
  246. package/dist/workspace/workspace.d.ts +2 -0
  247. package/dist/workspace/workspace.d.ts.map +1 -1
  248. package/dist/workspace/workspace.js +4 -0
  249. package/dist/workspace/workspace.js.map +1 -1
  250. package/package.json +2 -2
  251. package/templates/init/rules/domain.md.tpl +1 -1
  252. package/templates/pipeline/package-scripts.json +1 -1
  253. package/templates/presets/identity/context/application/authorization/__context__.permissions.ts.tpl +23 -0
  254. package/templates/presets/identity/context/application/authorization/change-member-roles.policy.ts.tpl +17 -0
  255. package/templates/presets/identity/context/application/authorization/grant-delegations.policy.ts.tpl +17 -0
  256. package/templates/presets/identity/context/application/authorization/invite-members.policy.ts.tpl +17 -0
  257. package/templates/presets/identity/context/application/authorization/read-members.policy.ts.tpl +17 -0
  258. package/templates/presets/identity/context/application/authorization/remove-members.policy.ts.tpl +17 -0
  259. package/templates/presets/identity/context/application/authorization/revoke-delegations.policy.ts.tpl +17 -0
  260. package/templates/presets/identity/context/application/authorization/revoke-invitations.policy.ts.tpl +17 -0
  261. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.command.ts.tpl +14 -0
  262. package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +56 -0
  263. package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.command.ts.tpl +17 -0
  264. package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.handler.ts.tpl +82 -0
  265. package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.command.ts.tpl +7 -0
  266. package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.handler.ts.tpl +69 -0
  267. package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.command.ts.tpl +14 -0
  268. package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.handler.ts.tpl +36 -0
  269. package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.command.ts.tpl +21 -0
  270. package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.handler.ts.tpl +43 -0
  271. package/templates/presets/identity/context/application/commands/invite-member/invite-member.command.ts.tpl +16 -0
  272. package/templates/presets/identity/context/application/commands/invite-member/invite-member.handler.ts.tpl +53 -0
  273. package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.command.ts.tpl +14 -0
  274. package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.handler.ts.tpl +50 -0
  275. package/templates/presets/identity/context/application/commands/provision-account/provision-account.command.ts.tpl +14 -0
  276. package/templates/presets/identity/context/application/commands/provision-account/provision-account.handler.ts.tpl +41 -0
  277. package/templates/presets/identity/context/application/commands/remove-member/remove-member.command.ts.tpl +15 -0
  278. package/templates/presets/identity/context/application/commands/remove-member/remove-member.handler.ts.tpl +79 -0
  279. package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.command.ts.tpl +15 -0
  280. package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.handler.ts.tpl +39 -0
  281. package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.command.ts.tpl +15 -0
  282. package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.handler.ts.tpl +42 -0
  283. package/templates/presets/identity/context/application/integration/handlers/account-deactivated.integration-handler.ts.tpl +19 -0
  284. package/templates/presets/identity/context/application/integration/handlers/member-joined.integration-handler.ts.tpl +33 -0
  285. package/templates/presets/identity/context/application/integration/handlers/member-removed.integration-handler.ts.tpl +30 -0
  286. package/templates/presets/identity/context/application/integration/handlers/organisation-opened.integration-handler.ts.tpl +19 -0
  287. package/templates/presets/identity/context/application/integration/publishers/account-deactivated.publisher.ts.tpl +24 -0
  288. package/templates/presets/identity/context/application/integration/publishers/delegation-granted.publisher.ts.tpl +36 -0
  289. package/templates/presets/identity/context/application/integration/publishers/delegation-revoked.publisher.ts.tpl +33 -0
  290. package/templates/presets/identity/context/application/integration/publishers/member-joined.publisher.ts.tpl +33 -0
  291. package/templates/presets/identity/context/application/integration/publishers/member-removed.publisher.ts.tpl +33 -0
  292. package/templates/presets/identity/context/application/integration/publishers/member-role-changed.publisher.ts.tpl +35 -0
  293. package/templates/presets/identity/context/application/integration/publishers/organisation-opened.publisher.ts.tpl +32 -0
  294. package/templates/presets/identity/context/application/ports/identity-provider-admin.port.ts.tpl +17 -0
  295. package/templates/presets/identity/context/application/ports/identity-provider-connection.port.ts.tpl +14 -0
  296. package/templates/presets/identity/context/application/ports/invitation-tokens.port.ts.tpl +7 -0
  297. package/templates/presets/identity/context/application/ports/search-members-reader.port.ts.tpl +10 -0
  298. package/templates/presets/identity/context/application/queries/search-members/search-members.handler.ts.tpl +33 -0
  299. package/templates/presets/identity/context/application/queries/search-members/search-members.query.ts.tpl +19 -0
  300. package/templates/presets/identity/context/application/queries/search-members/search-members.result.ts.tpl +17 -0
  301. package/templates/presets/identity/context/domain/aggregates/account.aggregate.ts.tpl +92 -0
  302. package/templates/presets/identity/context/domain/aggregates/delegation.aggregate.ts.tpl +117 -0
  303. package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +128 -0
  304. package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +149 -0
  305. package/templates/presets/identity/context/domain/aggregates/organisation.aggregate.ts.tpl +52 -0
  306. package/templates/presets/identity/context/domain/errors/account.error.ts.tpl +40 -0
  307. package/templates/presets/identity/context/domain/errors/delegation.error.ts.tpl +45 -0
  308. package/templates/presets/identity/context/domain/errors/invitation.error.ts.tpl +30 -0
  309. package/templates/presets/identity/context/domain/errors/member.error.ts.tpl +50 -0
  310. package/templates/presets/identity/context/domain/errors/organisation.error.ts.tpl +32 -0
  311. package/templates/presets/identity/context/domain/events/account-deactivated.event.ts.tpl +13 -0
  312. package/templates/presets/identity/context/domain/events/account-provisioned.event.ts.tpl +17 -0
  313. package/templates/presets/identity/context/domain/events/delegation-granted.event.ts.tpl +22 -0
  314. package/templates/presets/identity/context/domain/events/delegation-revoked.event.ts.tpl +18 -0
  315. package/templates/presets/identity/context/domain/events/invitation-accepted.event.ts.tpl +17 -0
  316. package/templates/presets/identity/context/domain/events/invitation-declined.event.ts.tpl +16 -0
  317. package/templates/presets/identity/context/domain/events/invitation-issued.event.ts.tpl +22 -0
  318. package/templates/presets/identity/context/domain/events/invitation-revoked.event.ts.tpl +16 -0
  319. package/templates/presets/identity/context/domain/events/member-joined.event.ts.tpl +19 -0
  320. package/templates/presets/identity/context/domain/events/member-removed.event.ts.tpl +19 -0
  321. package/templates/presets/identity/context/domain/events/member-role-changed.event.ts.tpl +22 -0
  322. package/templates/presets/identity/context/domain/events/organisation-opened.event.ts.tpl +17 -0
  323. package/templates/presets/identity/context/domain/repositories/account.repository.ts.tpl +5 -0
  324. package/templates/presets/identity/context/domain/repositories/delegation.repository.ts.tpl +10 -0
  325. package/templates/presets/identity/context/domain/repositories/invitation.repository.ts.tpl +7 -0
  326. package/templates/presets/identity/context/domain/repositories/member.repository.ts.tpl +13 -0
  327. package/templates/presets/identity/context/domain/repositories/organisation.repository.ts.tpl +5 -0
  328. package/templates/presets/identity/context/domain/services/role-rights.service.ts.tpl +59 -0
  329. package/templates/presets/identity/context/domain/value-objects/delegation-period.vo.ts.tpl +42 -0
  330. package/templates/presets/identity/context/domain/value-objects/display-name.vo.ts.tpl +29 -0
  331. package/templates/presets/identity/context/domain/value-objects/email-address.vo.ts.tpl +31 -0
  332. package/templates/presets/identity/context/domain/value-objects/organisation-name.vo.ts.tpl +29 -0
  333. package/templates/presets/identity/context/domain/value-objects/organisation-rights.vo.ts.tpl +43 -0
  334. package/templates/presets/identity/context/domain/value-objects/organisation-slug.vo.ts.tpl +30 -0
  335. package/templates/presets/identity/context/domain/vocabularies/account-status.vocabulary.ts.tpl +7 -0
  336. package/templates/presets/identity/context/domain/vocabularies/invitation-status.vocabulary.ts.tpl +9 -0
  337. package/templates/presets/identity/context/domain/vocabularies/member-right.vocabulary.ts.tpl +9 -0
  338. package/templates/presets/identity/context/domain/vocabularies/member-role.vocabulary.ts.tpl +8 -0
  339. package/templates/presets/identity/context/infrastructure/external/crypto-invitation-tokens.adapter.ts.tpl +20 -0
  340. package/templates/presets/identity/context/infrastructure/external/environment-identity-provider-connection.adapter.ts.tpl +37 -0
  341. package/templates/presets/identity/context/infrastructure/external/keycloak-identity-provider-admin.adapter.ts.tpl +149 -0
  342. package/templates/presets/identity/context/infrastructure/persistence/__context__.schema.drizzle.ts.tpl +102 -0
  343. package/templates/presets/identity/context/infrastructure/persistence/account-row.schema.knex.ts.tpl +15 -0
  344. package/templates/presets/identity/context/infrastructure/persistence/account.mapper.drizzle.ts.tpl +38 -0
  345. package/templates/presets/identity/context/infrastructure/persistence/account.mapper.knex.ts.tpl +33 -0
  346. package/templates/presets/identity/context/infrastructure/persistence/create-__context__-tables.schema.knex.ts.tpl +107 -0
  347. package/templates/presets/identity/context/infrastructure/persistence/delegation-row.schema.knex.ts.tpl +17 -0
  348. package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.drizzle.ts.tpl +50 -0
  349. package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.knex.ts.tpl +45 -0
  350. package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +59 -0
  351. package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +77 -0
  352. package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +65 -0
  353. package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +84 -0
  354. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +59 -0
  355. package/templates/presets/identity/context/infrastructure/persistence/drizzle-search-members-reader.repository.drizzle.ts.tpl +53 -0
  356. package/templates/presets/identity/context/infrastructure/persistence/invitation-row.schema.knex.ts.tpl +20 -0
  357. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.drizzle.ts.tpl +45 -0
  358. package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.knex.ts.tpl +40 -0
  359. package/templates/presets/identity/context/infrastructure/persistence/knex-account.repository.knex.ts.tpl +61 -0
  360. package/templates/presets/identity/context/infrastructure/persistence/knex-delegation.repository.knex.ts.tpl +80 -0
  361. package/templates/presets/identity/context/infrastructure/persistence/knex-invitation.repository.knex.ts.tpl +67 -0
  362. package/templates/presets/identity/context/infrastructure/persistence/knex-member.repository.knex.ts.tpl +82 -0
  363. package/templates/presets/identity/context/infrastructure/persistence/knex-organisation.repository.knex.ts.tpl +61 -0
  364. package/templates/presets/identity/context/infrastructure/persistence/knex-search-members-reader.repository.knex.ts.tpl +77 -0
  365. package/templates/presets/identity/context/infrastructure/persistence/member-row.schema.knex.ts.tpl +15 -0
  366. package/templates/presets/identity/context/infrastructure/persistence/member.mapper.drizzle.ts.tpl +36 -0
  367. package/templates/presets/identity/context/infrastructure/persistence/member.mapper.knex.ts.tpl +31 -0
  368. package/templates/presets/identity/context/infrastructure/persistence/organisation-row.schema.knex.ts.tpl +12 -0
  369. package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.drizzle.ts.tpl +28 -0
  370. package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.knex.ts.tpl +26 -0
  371. package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.accepted.class-validator.per-route.ts.tpl +6 -0
  372. package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.controller.ts.tpl +71 -0
  373. package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.accepted.class-validator.per-route.ts.tpl +6 -0
  374. package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.body.class-validator.ts.tpl +9 -0
  375. package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.controller.ts.tpl +85 -0
  376. package/templates/presets/identity/context/presentation/http/accounts.routes.ts.tpl +5 -0
  377. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
  378. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.body.class-validator.per-route.ts.tpl +8 -0
  379. package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.ts.tpl +100 -0
  380. package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
  381. package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.body.class-validator.per-route.ts.tpl +8 -0
  382. package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.controller.ts.tpl +98 -0
  383. package/templates/presets/identity/context/presentation/http/invitations.routes.ts.tpl +5 -0
  384. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.accepted.class-validator.per-route.ts.tpl +6 -0
  385. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.body.class-validator.ts.tpl +7 -0
  386. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.controller.ts.tpl +83 -0
  387. package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.params.class-validator.ts.tpl +11 -0
  388. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.accepted.class-validator.per-route.ts.tpl +6 -0
  389. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.body.class-validator.ts.tpl +18 -0
  390. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.controller.ts.tpl +103 -0
  391. package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.params.class-validator.ts.tpl +7 -0
  392. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.accepted.class-validator.ts.tpl +10 -0
  393. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.body.class-validator.ts.tpl +10 -0
  394. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.controller.ts.tpl +65 -0
  395. package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.params.class-validator.ts.tpl +7 -0
  396. package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.accepted.class-validator.per-route.ts.tpl +6 -0
  397. package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.body.class-validator.ts.tpl +12 -0
  398. package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.controller.ts.tpl +79 -0
  399. package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.accepted.class-validator.per-route.ts.tpl +6 -0
  400. package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.controller.ts.tpl +73 -0
  401. package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.params.class-validator.ts.tpl +11 -0
  402. package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.accepted.class-validator.per-route.ts.tpl +6 -0
  403. package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.controller.ts.tpl +73 -0
  404. package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.params.class-validator.ts.tpl +11 -0
  405. package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
  406. package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.controller.ts.tpl +73 -0
  407. package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.params.class-validator.ts.tpl +11 -0
  408. package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.controller.ts.tpl +86 -0
  409. package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.line.class-validator.ts.tpl +22 -0
  410. package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.params.class-validator.ts.tpl +7 -0
  411. package/templates/presets/identity/context/presentation/http/organisations.routes.ts.tpl +5 -0
  412. package/templates/presets/identity/context/presentation/http/shared/invitation-token.schema.class-validator.shared.ts.tpl +9 -0
  413. package/templates/presets/identity/context/presentation/http/shared/invitation-token.schema.zod.shared.ts.tpl +9 -0
  414. package/templates/presets/identity/context/published-language/account-deactivated.v1.integration-event.ts.tpl +33 -0
  415. package/templates/presets/identity/context/published-language/account-deactivated.v1.payload.class-validator.ts.tpl +7 -0
  416. package/templates/presets/identity/context/published-language/delegation-granted.v1.integration-event.ts.tpl +39 -0
  417. package/templates/presets/identity/context/published-language/delegation-granted.v1.payload.class-validator.ts.tpl +28 -0
  418. package/templates/presets/identity/context/published-language/delegation-revoked.v1.integration-event.ts.tpl +36 -0
  419. package/templates/presets/identity/context/published-language/delegation-revoked.v1.payload.class-validator.ts.tpl +16 -0
  420. package/templates/presets/identity/context/published-language/member-joined.v1.integration-event.ts.tpl +36 -0
  421. package/templates/presets/identity/context/published-language/member-joined.v1.payload.class-validator.ts.tpl +16 -0
  422. package/templates/presets/identity/context/published-language/member-removed.v1.integration-event.ts.tpl +36 -0
  423. package/templates/presets/identity/context/published-language/member-removed.v1.payload.class-validator.ts.tpl +18 -0
  424. package/templates/presets/identity/context/published-language/member-role-changed.v1.integration-event.ts.tpl +38 -0
  425. package/templates/presets/identity/context/published-language/member-role-changed.v1.payload.class-validator.ts.tpl +24 -0
  426. package/templates/presets/identity/context/published-language/organisation-opened.v1.integration-event.ts.tpl +35 -0
  427. package/templates/presets/identity/context/published-language/organisation-opened.v1.payload.class-validator.ts.tpl +13 -0
  428. package/templates/presets/identity/context/test/builders/account.builder.ts.tpl +59 -0
  429. package/templates/presets/identity/context/test/builders/delegation.builder.ts.tpl +67 -0
  430. package/templates/presets/identity/context/test/builders/invitation.builder.ts.tpl +60 -0
  431. package/templates/presets/identity/context/test/builders/member.builder.ts.tpl +59 -0
  432. package/templates/presets/identity/context/test/builders/organisation.builder.ts.tpl +44 -0
  433. package/templates/presets/identity/context/test/fakes/account.repository.fake.ts.tpl +10 -0
  434. package/templates/presets/identity/context/test/fakes/delegation.repository.fake.ts.tpl +26 -0
  435. package/templates/presets/identity/context/test/fakes/identity-provider-admin.fake.ts.tpl +41 -0
  436. package/templates/presets/identity/context/test/fakes/invitation-tokens.fake.ts.tpl +18 -0
  437. package/templates/presets/identity/context/test/fakes/invitation.repository.fake.ts.tpl +14 -0
  438. package/templates/presets/identity/context/test/fakes/member.repository.fake.ts.tpl +29 -0
  439. package/templates/presets/identity/context/test/fakes/organisation.repository.fake.ts.tpl +10 -0
  440. package/templates/presets/identity/context/test/fakes/search-members-reader.fake.ts.tpl +25 -0
  441. package/templates/presets/identity/context/test/integration/account.repository.contract.spec.ts.tpl +48 -0
  442. package/templates/presets/identity/context/test/integration/delegation.repository.contract.spec.ts.tpl +84 -0
  443. package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +76 -0
  444. package/templates/presets/identity/context/test/integration/keycloak-identity-provider-admin.adapter.spec.ts.tpl +123 -0
  445. package/templates/presets/identity/context/test/integration/member.repository.contract.spec.ts.tpl +92 -0
  446. package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +46 -0
  447. package/templates/presets/identity/context/test/integration/search-members-reader.spec.ts.tpl +86 -0
  448. package/templates/presets/identity/context/test/unit/accept-invitation.controller.spec.ts.tpl +57 -0
  449. package/templates/presets/identity/context/test/unit/accept-invitation.handler.spec.ts.tpl +69 -0
  450. package/templates/presets/identity/context/test/unit/account-deactivated.integration-handler.spec.ts.tpl +24 -0
  451. package/templates/presets/identity/context/test/unit/account-deactivated.publisher.spec.ts.tpl +25 -0
  452. package/templates/presets/identity/context/test/unit/account.aggregate.spec.ts.tpl +72 -0
  453. package/templates/presets/identity/context/test/unit/change-member-role.controller.spec.ts.tpl +57 -0
  454. package/templates/presets/identity/context/test/unit/change-member-role.handler.spec.ts.tpl +135 -0
  455. package/templates/presets/identity/context/test/unit/crypto-invitation-tokens.adapter.spec.ts.tpl +15 -0
  456. package/templates/presets/identity/context/test/unit/deactivate-account.controller.spec.ts.tpl +44 -0
  457. package/templates/presets/identity/context/test/unit/deactivate-account.handler.spec.ts.tpl +106 -0
  458. package/templates/presets/identity/context/test/unit/decline-invitation.controller.spec.ts.tpl +57 -0
  459. package/templates/presets/identity/context/test/unit/decline-invitation.handler.spec.ts.tpl +40 -0
  460. package/templates/presets/identity/context/test/unit/delegation-granted.publisher.spec.ts.tpl +36 -0
  461. package/templates/presets/identity/context/test/unit/delegation-period.vo.spec.ts.tpl +32 -0
  462. package/templates/presets/identity/context/test/unit/delegation-revoked.publisher.spec.ts.tpl +35 -0
  463. package/templates/presets/identity/context/test/unit/delegation.aggregate.spec.ts.tpl +111 -0
  464. package/templates/presets/identity/context/test/unit/display-name.vo.spec.ts.tpl +13 -0
  465. package/templates/presets/identity/context/test/unit/email-address.vo.spec.ts.tpl +24 -0
  466. package/templates/presets/identity/context/test/unit/environment-identity-provider-connection.adapter.spec.ts.tpl +41 -0
  467. package/templates/presets/identity/context/test/unit/grant-delegation.controller.spec.ts.tpl +57 -0
  468. package/templates/presets/identity/context/test/unit/grant-delegation.handler.spec.ts.tpl +66 -0
  469. package/templates/presets/identity/context/test/unit/identity-application.ts.tpl +79 -0
  470. package/templates/presets/identity/context/test/unit/invitation.aggregate.spec.ts.tpl +118 -0
  471. package/templates/presets/identity/context/test/unit/invite-member.controller.spec.ts.tpl +57 -0
  472. package/templates/presets/identity/context/test/unit/invite-member.handler.spec.ts.tpl +110 -0
  473. package/templates/presets/identity/context/test/unit/member-joined.integration-handler.spec.ts.tpl +38 -0
  474. package/templates/presets/identity/context/test/unit/member-joined.publisher.spec.ts.tpl +36 -0
  475. package/templates/presets/identity/context/test/unit/member-removed.integration-handler.spec.ts.tpl +45 -0
  476. package/templates/presets/identity/context/test/unit/member-removed.publisher.spec.ts.tpl +35 -0
  477. package/templates/presets/identity/context/test/unit/member-role-changed.publisher.spec.ts.tpl +36 -0
  478. package/templates/presets/identity/context/test/unit/member.aggregate.spec.ts.tpl +142 -0
  479. package/templates/presets/identity/context/test/unit/open-organisation.controller.spec.ts.tpl +57 -0
  480. package/templates/presets/identity/context/test/unit/open-organisation.handler.spec.ts.tpl +52 -0
  481. package/templates/presets/identity/context/test/unit/organisation-name.vo.spec.ts.tpl +13 -0
  482. package/templates/presets/identity/context/test/unit/organisation-opened.integration-handler.spec.ts.tpl +24 -0
  483. package/templates/presets/identity/context/test/unit/organisation-opened.publisher.spec.ts.tpl +35 -0
  484. package/templates/presets/identity/context/test/unit/organisation-rights.vo.spec.ts.tpl +23 -0
  485. package/templates/presets/identity/context/test/unit/organisation-slug.vo.spec.ts.tpl +17 -0
  486. package/templates/presets/identity/context/test/unit/organisation.aggregate.spec.ts.tpl +33 -0
  487. package/templates/presets/identity/context/test/unit/provision-account.controller.spec.ts.tpl +73 -0
  488. package/templates/presets/identity/context/test/unit/provision-account.handler.spec.ts.tpl +65 -0
  489. package/templates/presets/identity/context/test/unit/remove-member.controller.spec.ts.tpl +44 -0
  490. package/templates/presets/identity/context/test/unit/remove-member.handler.spec.ts.tpl +125 -0
  491. package/templates/presets/identity/context/test/unit/revoke-delegation.controller.spec.ts.tpl +44 -0
  492. package/templates/presets/identity/context/test/unit/revoke-delegation.handler.spec.ts.tpl +51 -0
  493. package/templates/presets/identity/context/test/unit/revoke-invitation.controller.spec.ts.tpl +44 -0
  494. package/templates/presets/identity/context/test/unit/revoke-invitation.handler.spec.ts.tpl +44 -0
  495. package/templates/presets/identity/context/test/unit/role-rights.service.spec.ts.tpl +54 -0
  496. package/templates/presets/identity/context/test/unit/search-members.controller.spec.ts.tpl +43 -0
  497. package/templates/presets/identity/context/test/unit/search-members.handler.spec.ts.tpl +38 -0
  498. package/templates/presets/identity/decision.md.tpl +37 -0
  499. package/templates/presets/identity/design.md.tpl +71 -0
  500. package/templates/presets/signed-in-grants.ts.tpl +12 -0
@@ -0,0 +1,21 @@
1
+ import { perFile } from '../support/per-file.js';
2
+ import { isModelFile } from '../values/is-model-file.js';
3
+ import { isValueObjectFile } from '../values/is-value-object-file.js';
4
+ import { plainValueFunctions } from '../values/plain-value-functions.js';
5
+ import { valueObjectFileFindings } from '../values/value-object-file-findings.js';
6
+ export const domainValueObjectClass = {
7
+ id: 'domain/value-object-class',
8
+ description: 'Under "stack.values": "classes", a value object is a class: a file of domain/value-objects/ (or a *.vo.ts of the shared kernel) exports one class extending ValueObject, with a private or protected constructor and static factories, and no function or object literal; no exported function of domain/ or of the shared kernel answers a record of data (no spread, nothing a call of the model built).',
9
+ scope: 'file',
10
+ run(project) {
11
+ return project.config.stack.values === 'classes' ? perFile(project, this.id, (file) => judge(project, file)) : [];
12
+ },
13
+ };
14
+ function judge(project, file) {
15
+ const { sharedKernelDir } = project.config;
16
+ if (isValueObjectFile(file.path, file.location, sharedKernelDir)) {
17
+ return valueObjectFileFindings(file, sharedKernelDir);
18
+ }
19
+ return isModelFile(file.path, file.location, sharedKernelDir) && !file.isTest ? plainValueFunctions(file) : [];
20
+ }
21
+ //# sourceMappingURL=domain-value-object-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-value-object-class.js","sourceRoot":"","sources":["../../../src/check/rules/domain-value-object-class.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,EAAE,EAAE,2BAA2B;IAC/B,WAAW,EACT,4YAA4Y;IAC9Y,KAAK,EAAE,MAAM;IACb,GAAG,CAAC,OAAO;QACT,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpH,CAAC;CACF,CAAC;AAEF,SAAS,KAAK,CAAC,OAAgB,EAAE,IAAgB;IAC/C,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAE3C,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,CAAC;QACjE,OAAO,uBAAuB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjH,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The brace opening the body of a class whose heritage starts at `from`, past the object types
3
+ * its type arguments may hold: `class Money extends ValueObject<{ readonly cents: number }> {`.
4
+ */
5
+ export declare function classBodyBrace(code: string, from: number): number;
6
+ //# sourceMappingURL=class-body-brace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-body-brace.d.ts","sourceRoot":"","sources":["../../../src/check/structure/class-body-brace.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBjE"}
@@ -0,0 +1,22 @@
1
+ import { matchingBracket } from '../text/matching-bracket.js';
2
+ /**
3
+ * The brace opening the body of a class whose heritage starts at `from`, past the object types
4
+ * its type arguments may hold: `class Money extends ValueObject<{ readonly cents: number }> {`.
5
+ */
6
+ export function classBodyBrace(code, from) {
7
+ let angles = 0;
8
+ for (let i = from; i < code.length; i += 1) {
9
+ const char = code.charAt(i);
10
+ if (char === '{' && angles === 0) {
11
+ return i;
12
+ }
13
+ if (char === '<' || (char === '>' && code.charAt(i - 1) !== '=')) {
14
+ angles += char === '<' ? 1 : -1;
15
+ }
16
+ else if ('({['.includes(char)) {
17
+ i = matchingBracket(code, i);
18
+ }
19
+ }
20
+ return code.length - 1;
21
+ }
22
+ //# sourceMappingURL=class-body-brace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-body-brace.js","sourceRoot":"","sources":["../../../src/check/structure/class-body-brace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,MAAM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,SAAS,CAKnD"}
1
+ {"version":3,"file":"read-structure.d.ts","sourceRoot":"","sources":["../../../src/check/structure/read-structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACjD;AAQD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAKnD"}
@@ -1,4 +1,5 @@
1
1
  import { braceDepthAt } from '../text/brace-depth-at.js';
2
+ import { classBodyBrace } from './class-body-brace.js';
2
3
  import { matchingBracket } from '../text/matching-bracket.js';
3
4
  import { methodsOf } from './methods-of.js';
4
5
  import { signatureAt } from './signature-at.js';
@@ -18,7 +19,8 @@ export function readStructure(scan) {
18
19
  }
19
20
  function classShape(scan, match) {
20
21
  const { code } = scan;
21
- const bodyStart = match.index + match[0].length - 1;
22
+ const named = /^class\s+[\w$]+/.exec(match[0])?.[0].length ?? 0;
23
+ const bodyStart = classBodyBrace(code, match.index + named);
22
24
  const bodyClose = matchingBracket(code, bodyStart);
23
25
  const before = BEFORE_CLASS.exec(code.slice(Math.max(0, match.index - 40), match.index));
24
26
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"read-structure.js","sourceRoot":"","sources":["../../../src/check/structure/read-structure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,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C;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL;gBACE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;gBACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,GAAG,EAAE,SAAS,CAAC,SAAS;gBACxB,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,SAAS,EAAE,SAAS,CAAC,QAAQ;gBAC7B,SAAS,EAAE,SAAS,CAAC,SAAS;gBAC9B,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS;aACjC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +1,10 @@
1
1
  import type { SourceFile } from '../model/source-file.js';
2
- /** What a Knex adapter of tenant data reaches without the helpers: the executor called, chained or held, and raw SQL. */
2
+ /**
3
+ * What a Knex adapter of tenant data reaches without the helpers: the executor called, chained or
4
+ * held, and raw SQL. A raw call whose first argument is a literal that reaches no row by itself
5
+ * (an aggregate in a select, a constraint of the schema: `rawReachesRows`) is not reported, since
6
+ * the statement it is put in is what the tenant confines; any other raw call is.
7
+ */
3
8
  export declare function knexUnscoped(file: SourceFile): readonly {
4
9
  offset: number;
5
10
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"knex-unscoped.d.ts","sourceRoot":"","sources":["../../../src/check/tenancy/knex-unscoped.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D,yHAAyH;AACzH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAgB7F"}
1
+ {"version":3,"file":"knex-unscoped.d.ts","sourceRoot":"","sources":["../../../src/check/tenancy/knex-unscoped.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAW1D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAe7F"}
@@ -1,19 +1,32 @@
1
1
  import { executorUses } from './executor-uses.js';
2
+ import { rawReachesRows } from './raw-reaches-rows.js';
3
+ import { rawSqlText } from './raw-sql-text.js';
2
4
  /** Raw SQL, which no helper confines. */
3
5
  const RAW = /\.raw\s*\(/g;
4
- /** What a Knex adapter of tenant data reaches without the helpers: the executor called, chained or held, and raw SQL. */
6
+ /** A raw use of the executor: judged by what its SQL says, as any raw SQL. */
7
+ const RAW_STATEMENT = /^\s*\.raw\s*\(/;
8
+ /**
9
+ * What a Knex adapter of tenant data reaches without the helpers: the executor called, chained or
10
+ * held, and raw SQL. A raw call whose first argument is a literal that reaches no row by itself
11
+ * (an aggregate in a select, a constraint of the schema: `rawReachesRows`) is not reported, since
12
+ * the statement it is put in is what the tenant confines; any other raw call is.
13
+ */
5
14
  export function knexUnscoped(file) {
6
15
  const { code } = file.scan;
7
16
  const straight = executorUses(code)
8
- .filter((use) => !use.handedOver)
17
+ .filter((use) => !use.handedOver && !RAW_STATEMENT.test(use.statement))
9
18
  .map((use) => ({
10
19
  offset: use.offset,
11
20
  message: 'The executor is used straight (called, chained or held): no tenant condition confines it.',
12
21
  }));
13
- const raw = [...code.matchAll(RAW)].map((match) => ({
14
- offset: match.index,
15
- message: 'Raw SQL reaches the tables with no tenant condition.',
16
- }));
22
+ const raw = [...code.matchAll(RAW)]
23
+ .filter((match) => reachesRows(file, match.index + match[0].length))
24
+ .map((match) => ({ offset: match.index, message: 'Raw SQL reaches the tables with no tenant condition.' }));
17
25
  return [...straight, ...raw];
18
26
  }
27
+ /** True unless the first argument is a literal whose SQL reaches no row by itself. */
28
+ function reachesRows(file, argumentsStart) {
29
+ const text = rawSqlText(file, argumentsStart);
30
+ return text === undefined || rawReachesRows(text);
31
+ }
19
32
  //# sourceMappingURL=knex-unscoped.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"knex-unscoped.js","sourceRoot":"","sources":["../../../src/check/tenancy/knex-unscoped.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,yCAAyC;AACzC,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B,yHAAyH;AACzH,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;IAE3B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC;SAChC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;SAChC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACb,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,2FAA2F;KACrG,CAAC,CAAC,CAAC;IAEN,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,KAAK,CAAC,KAAK;QACnB,OAAO,EAAE,sDAAsD;KAChE,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC;AAC/B,CAAC"}
1
+ {"version":3,"file":"knex-unscoped.js","sourceRoot":"","sources":["../../../src/check/tenancy/knex-unscoped.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,yCA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of a raw call can reach rows by itself. A statement of the schema that
3
+ * holds no word of rows cannot; an expression can only if it holds a word that reads or writes
4
+ * rows, starts a statement, or calls a function outside the expressions known to work on the
5
+ * rows already confined (a function call may run any statement).
6
+ */
7
+ export declare function rawReachesRows(sql: string): boolean;
8
+ //# sourceMappingURL=raw-reaches-rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-reaches-rows.d.ts","sourceRoot":"","sources":["../../../src/check/tenancy/raw-reaches-rows.ts"],"names":[],"mappings":"AAuEA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAYnD"}
@@ -0,0 +1,91 @@
1
+ /** A statement of the schema: it changes tables, never reads or writes their rows. */
2
+ const SCHEMA_STATEMENT = /^\s*(?:create|alter|drop|comment)\b/i;
3
+ /** The words of SQL that read or write rows, whatever the statement they are in. */
4
+ const ROW_WORDS = /\b(?:select|insert|update|delete|from|join|into|truncate|merge|copy|values|call|execute|returning)\b/i;
5
+ /** Further words that start a statement or name a table in an expression: `table invoices`, `with ...`, `do ...`, `lock ...`. */
6
+ const STATEMENT_WORDS = /\b(?:table|with|do|lock|using|exists)\b/i;
7
+ /** What may be called in an expression over the rows a confined statement reads: aggregates, casts, arithmetic, text. */
8
+ const EXPRESSION_FUNCTIONS = new Set([
9
+ 'count',
10
+ 'sum',
11
+ 'avg',
12
+ 'min',
13
+ 'max',
14
+ 'coalesce',
15
+ 'nullif',
16
+ 'greatest',
17
+ 'least',
18
+ 'round',
19
+ 'floor',
20
+ 'ceil',
21
+ 'abs',
22
+ 'date_part',
23
+ 'date_trunc',
24
+ 'extract',
25
+ 'lower',
26
+ 'upper',
27
+ 'length',
28
+ 'concat',
29
+ 'to_char',
30
+ 'cast',
31
+ 'string_agg',
32
+ 'array_agg',
33
+ 'bool_and',
34
+ 'bool_or',
35
+ 'json_agg',
36
+ 'jsonb_agg',
37
+ 'json_build_object',
38
+ 'jsonb_build_object',
39
+ 'numeric',
40
+ 'decimal',
41
+ 'varchar',
42
+ 'char',
43
+ 'timestamp',
44
+ 'interval',
45
+ ]);
46
+ /** Words of SQL followed by a parenthesis that call nothing. */
47
+ const SYNTAX_BEFORE_PARENTHESIS = new Set([
48
+ 'in',
49
+ 'filter',
50
+ 'over',
51
+ 'any',
52
+ 'all',
53
+ 'and',
54
+ 'or',
55
+ 'not',
56
+ 'as',
57
+ 'by',
58
+ 'when',
59
+ 'then',
60
+ 'else',
61
+ 'where',
62
+ 'is',
63
+ ]);
64
+ const CALL = /([A-Za-z_][\w$]*)\s*\(/g;
65
+ /**
66
+ * Whether the literal SQL of a raw call can reach rows by itself. A statement of the schema that
67
+ * holds no word of rows cannot; an expression can only if it holds a word that reads or writes
68
+ * rows, starts a statement, or calls a function outside the expressions known to work on the
69
+ * rows already confined (a function call may run any statement).
70
+ */
71
+ export function rawReachesRows(sql) {
72
+ const text = withoutQuotedText(sql);
73
+ if (ROW_WORDS.test(text)) {
74
+ return true;
75
+ }
76
+ if (SCHEMA_STATEMENT.test(text)) {
77
+ return false;
78
+ }
79
+ return STATEMENT_WORDS.test(text) || callsAnUnknownFunction(text);
80
+ }
81
+ function callsAnUnknownFunction(text) {
82
+ return [...text.matchAll(CALL)].some(([, name = '']) => {
83
+ const word = name.toLowerCase();
84
+ return !EXPRESSION_FUNCTIONS.has(word) && !SYNTAX_BEFORE_PARENTHESIS.has(word);
85
+ });
86
+ }
87
+ /** Text in quotes says nothing of what the SQL does: `'.'`, `'epoch'`, a quoted identifier. */
88
+ function withoutQuotedText(sql) {
89
+ return sql.replace(/'(?:[^']|'')*'/g, "''").replace(/"(?:[^"]|"")*"/g, '""');
90
+ }
91
+ //# sourceMappingURL=raw-reaches-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-reaches-rows.js","sourceRoot":"","sources":["../../../src/check/tenancy/raw-reaches-rows.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;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sB,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEhC,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,+FAA+F;AAC/F,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { SourceFile } from '../model/source-file.js';
2
+ /**
3
+ * The SQL text of the first argument of a raw call, from the source: a string literal, or a
4
+ * template without interpolation. `undefined` when the argument is not a literal (a variable, a
5
+ * call) or is a template that interpolates: what an interpolation holds may be SQL of its own,
6
+ * and cannot be read here.
7
+ */
8
+ export declare function rawSqlText(file: SourceFile, argumentsStart: number): string | undefined;
9
+ //# sourceMappingURL=raw-sql-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-sql-text.d.ts","sourceRoot":"","sources":["../../../src/check/tenancy/raw-sql-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAK1D;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBvF"}
@@ -0,0 +1,29 @@
1
+ const QUOTES = new Set(["'", '"']);
2
+ const BACKTICK = '`';
3
+ /**
4
+ * The SQL text of the first argument of a raw call, from the source: a string literal, or a
5
+ * template without interpolation. `undefined` when the argument is not a literal (a variable, a
6
+ * call) or is a template that interpolates: what an interpolation holds may be SQL of its own,
7
+ * and cannot be read here.
8
+ */
9
+ export function rawSqlText(file, argumentsStart) {
10
+ const start = firstArgument(file.scan.code, argumentsStart);
11
+ const opening = file.scan.code.charAt(start);
12
+ if (QUOTES.has(opening)) {
13
+ return file.scan.strings.find((literal) => literal.start === start)?.value;
14
+ }
15
+ if (opening !== BACKTICK) {
16
+ return undefined;
17
+ }
18
+ const end = file.scan.code.indexOf(BACKTICK, start + 1);
19
+ const template = end === -1 ? undefined : file.text.slice(start + 1, end);
20
+ return template === undefined || template.includes('${') ? undefined : template;
21
+ }
22
+ function firstArgument(code, from) {
23
+ let index = from;
24
+ while (/\s/.test(code.charAt(index))) {
25
+ index += 1;
26
+ }
27
+ return index;
28
+ }
29
+ //# sourceMappingURL=raw-sql-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-sql-text.js","sourceRoot":"","sources":["../../../src/check/tenancy/raw-sql-text.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACnC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,cAAsB;IACjE,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC;IAC7E,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAE1E,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClF,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,IAAY;IAC/C,IAAI,KAAK,GAAG,IAAI,CAAC;IAEjB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { FunctionBody } from './function-body.js';
2
+ /**
3
+ * The object literals a function answers by itself, as the offsets of their `{`: the expression
4
+ * of an arrow, or what a `return` of its own block gives back. A `return` of a function nested
5
+ * in it answers for that function, not for this one.
6
+ */
7
+ export declare function answeredLiterals(code: string, body: FunctionBody): number[];
8
+ //# sourceMappingURL=answered-literals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answered-literals.d.ts","sourceRoot":"","sources":["../../../src/check/values/answered-literals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,CAa3E"}
@@ -0,0 +1,20 @@
1
+ import { literalAt } from './literal-at.js';
2
+ import { nestedBodies } from './nested-bodies.js';
3
+ const RETURN = /(?<![\w$.])return\b/g;
4
+ /**
5
+ * The object literals a function answers by itself, as the offsets of their `{`: the expression
6
+ * of an arrow, or what a `return` of its own block gives back. A `return` of a function nested
7
+ * in it answers for that function, not for this one.
8
+ */
9
+ export function answeredLiterals(code, body) {
10
+ if (body.kind === 'expression') {
11
+ const literal = literalAt(code, body.start);
12
+ return literal === undefined ? [] : [literal];
13
+ }
14
+ const nested = nestedBodies(code, body.open, body.close);
15
+ const own = (index) => !nested.some(([open, close]) => index > open && index < close);
16
+ return [...code.matchAll(RETURN)]
17
+ .filter(({ index }) => index > body.open && index < body.close && own(index))
18
+ .flatMap(({ index, 0: keyword }) => literalAt(code, index + keyword.length) ?? []);
19
+ }
20
+ //# sourceMappingURL=answered-literals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answered-literals.js","sourceRoot":"","sources":["../../../src/check/values/answered-literals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,sBAAsB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,IAAkB;IAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,KAAK,CAAC,CAAC;IAEvG,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC9B,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5E,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FunctionBody } from './function-body.js';
2
+ /** The body of the arrow function the expression at `from` is; undefined when the expression is not one. */
3
+ export declare function arrowBody(code: string, from: number): FunctionBody | undefined;
4
+ //# sourceMappingURL=arrow-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrow-body.d.ts","sourceRoot":"","sources":["../../../src/check/values/arrow-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,4GAA4G;AAC5G,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAY9E"}
@@ -0,0 +1,52 @@
1
+ import { BRACKETS } from '../text/brackets.js';
2
+ import { matchingBracket } from '../text/matching-bracket.js';
3
+ /** What may stand before the arrow of an arrow function: its type parameters, its parameters and its return type. */
4
+ const PARAMETERS = /^(?:async\s*)?(?:<[\s\S]*>\s*)?(?:\([\s\S]*\)|[\w$]+)(?:\s*:[\s\S]*)?$/;
5
+ /** The body of the arrow function the expression at `from` is; undefined when the expression is not one. */
6
+ export function arrowBody(code, from) {
7
+ const arrow = arrowAtDepthZero(code, afterTypeParameters(code, from));
8
+ if (arrow === undefined || !PARAMETERS.test(code.slice(from, arrow).trim())) {
9
+ return undefined;
10
+ }
11
+ const start = arrow + 2 + (/^\s*/.exec(code.slice(arrow + 2))?.[0].length ?? 0);
12
+ return code.charAt(start) === '{'
13
+ ? { kind: 'block', open: start, close: matchingBracket(code, start) }
14
+ : { kind: 'expression', start };
15
+ }
16
+ /** Past the type parameters an arrow may open with, `<T,>` included, whose commas do not end the expression. */
17
+ function afterTypeParameters(code, from) {
18
+ const start = from + (/^(?:async\s*)?/.exec(code.slice(from))?.[0].length ?? 0);
19
+ let angles = 0;
20
+ for (let i = start; code.charAt(start) === '<' && i < code.length; i += 1) {
21
+ angles += code.charAt(i) === '<' ? 1 : 0;
22
+ angles -= code.charAt(i) === '>' && code.charAt(i - 1) !== '=' ? 1 : 0;
23
+ if (angles === 0) {
24
+ return i + 1;
25
+ }
26
+ }
27
+ return from;
28
+ }
29
+ /** The first `=>` outside any bracket before the expression ends. */
30
+ function arrowAtDepthZero(code, from) {
31
+ let depth = 0;
32
+ for (let i = from; i < code.length - 1 && depth >= 0; i += 1) {
33
+ const char = code.charAt(i);
34
+ if (depth === 0 && endsBefore(code, i)) {
35
+ return char === '=' ? i : undefined;
36
+ }
37
+ depth += depthChange(char);
38
+ }
39
+ return undefined;
40
+ }
41
+ /** At depth zero: the arrow found, or the end of the expression without one. */
42
+ function endsBefore(code, at) {
43
+ const char = code.charAt(at);
44
+ return (char === '=' && code.charAt(at + 1) === '>') || char === ';' || char === ',';
45
+ }
46
+ function depthChange(char) {
47
+ if (BRACKETS.openers.includes(char)) {
48
+ return 1;
49
+ }
50
+ return BRACKETS.closers.includes(char) ? -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AAC;QAED,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,gFAAgF;AAChF,SAAS,UAAU,CAAC,IAAY,EAAE,EAAU;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAE7B,OAAO,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;AACvF,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * What an entry of an object literal holds: `behaviour`, a function; `built`, what a call or
3
+ * `new` of the model built (`Money.of(1)`, `total.add(tax)`, `new Slot(..)`), a call of the
4
+ * language aside (`Math.round(..)`, `new Date(..)`); `data`, anything else: a literal, a
5
+ * parameter, an operation on them.
6
+ */
7
+ export type EntryRole = 'behaviour' | 'built' | 'data';
8
+ /** The role of an expression, in blanked code; a name is read from its first declaration in `module`, found by name. */
9
+ export declare function expressionRole(expression: string, module: string, seen?: ReadonlySet<string>): EntryRole;
10
+ //# sourceMappingURL=entry-role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-role.d.ts","sourceRoot":"","sources":["../../../src/check/values/entry-role.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAOvD,wHAAwH;AACxH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GAAG,SAAS,CAenH"}
@@ -0,0 +1,40 @@
1
+ import { endAtDepthZero } from '../text/end-at-depth-zero.js';
2
+ import { escapeRegExp } from '../text/escape-reg-exp.js';
3
+ import { arrowBody } from './arrow-body.js';
4
+ import { JAVASCRIPT_GLOBALS } from './javascript-globals.js';
5
+ const FUNCTION_EXPRESSION = /^(?:async\s+)?function\b/;
6
+ const NEW = /^new\s+([A-Za-z_$][\w$]*)/;
7
+ const CALL = /^([A-Za-z_$][\w$]*)(?:\s*\??\.\s*[\w$]+|\s*!)*\s*(?:<[^()]*>)?\s*\(/;
8
+ const NAME = /^([A-Za-z_$][\w$]*)\s*!?\s*(?:(?:as|satisfies)\b[\s\S]*)?$/;
9
+ /** The role of an expression, in blanked code; a name is read from its first declaration in `module`, found by name. */
10
+ export function expressionRole(expression, module, seen = new Set()) {
11
+ const text = expression.trim();
12
+ if (FUNCTION_EXPRESSION.test(text) || arrowBody(text, 0) !== undefined) {
13
+ return 'behaviour';
14
+ }
15
+ const inner = text.replace(/^(?:\(\s*|await\s+)+/, '');
16
+ const built = NEW.exec(inner) ?? CALL.exec(inner);
17
+ if (built !== null) {
18
+ return JAVASCRIPT_GLOBALS.has(built[1] ?? '') ? 'data' : 'built';
19
+ }
20
+ return namedRole(inner, module, seen);
21
+ }
22
+ /** A name alone, `as` or `satisfies` a type: the role of what it binds; anything else is data. */
23
+ function namedRole(text, module, seen) {
24
+ const name = NAME.exec(text)?.[1];
25
+ return name === undefined || seen.has(name) ? 'data' : boundRole(module, name, new Set([...seen, name]));
26
+ }
27
+ /** The role of what the first declaration of `name` binds: a parameter, declared nowhere, is data. */
28
+ function boundRole(module, name, seen) {
29
+ const escaped = escapeRegExp(name);
30
+ const declared = new RegExp(`(?<![\\w$.])(?:(?:async\\s+)?function\\s*\\*?\\s*${escaped}(?![\\w$])|(?:const|let|var)\\s+${escaped}\\s*(?::[^;]*?)?=(?![=>]))`).exec(module);
31
+ if (declared === null) {
32
+ return 'data';
33
+ }
34
+ if (!/^(?:const|let|var)\b/.test(declared[0])) {
35
+ return 'behaviour';
36
+ }
37
+ const start = declared.index + declared[0].length;
38
+ return expressionRole(module.slice(start, endAtDepthZero(module, start, ';')), module, seen);
39
+ }
40
+ //# sourceMappingURL=entry-role.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-role.js","sourceRoot":"","sources":["../../../src/check/values/entry-role.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAU7D,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AACvD,MAAM,GAAG,GAAG,2BAA2B,CAAC;AACxC,MAAM,IAAI,GAAG,qEAAqE,CAAC;AACnF,MAAM,IAAI,GAAG,4DAA4D,CAAC;AAE1E,wHAAwH;AACxH,MAAM,UAAU,cAAc,CAAC,UAAkB,EAAE,MAAc,EAAE,IAAI,GAAwB,IAAI,GAAG,EAAE;IACtG,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;IAE/B,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QACvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,C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AAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Exported } from '../exports/exported.js';
2
+ import type { FunctionBody } from './function-body.js';
3
+ /**
4
+ * The body of an exported function, in the text of its declaration: a function declaration, or
5
+ * a constant bound to an arrow or a function expression. Undefined for anything else, and for an
6
+ * overload, which has no body.
7
+ */
8
+ export declare function exportedFunctionBody({ kind, text, signature }: Exported): FunctionBody | undefined;
9
+ //# sourceMappingURL=exported-function-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exported-function-body.d.ts","sourceRoot":"","sources":["../../../src/check/values/exported-function-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CA0BlG"}
@@ -0,0 +1,29 @@
1
+ import { signatureAt } from '../structure/signature-at.js';
2
+ import { arrowBody } from './arrow-body.js';
3
+ import { initializerOf } from './initializer-of.js';
4
+ const FUNCTION_EXPRESSION = /^(?:async\s+)?function\b[\s*]*(?:[\w$]+)?\s*(?:<[^()]*>)?\s*\(/;
5
+ /**
6
+ * The body of an exported function, in the text of its declaration: a function declaration, or
7
+ * a constant bound to an arrow or a function expression. Undefined for anything else, and for an
8
+ * overload, which has no body.
9
+ */
10
+ export function exportedFunctionBody({ kind, text, signature }) {
11
+ if (kind === 'function') {
12
+ const open = signature.length;
13
+ return text.charAt(open) === '{' ? { kind: 'block', open, close: text.length - 1 } : undefined;
14
+ }
15
+ if (kind !== 'const') {
16
+ return undefined;
17
+ }
18
+ const start = initializerOf(text);
19
+ if (start === undefined) {
20
+ return undefined;
21
+ }
22
+ const expression = FUNCTION_EXPRESSION.exec(text.slice(start));
23
+ if (expression === null) {
24
+ return arrowBody(text, start);
25
+ }
26
+ const body = signatureAt(text, start + expression[0].length - 1);
27
+ return body === undefined ? undefined : { kind: 'block', open: body.bodyOpen, close: body.bodyClose };
28
+ }
29
+ //# sourceMappingURL=exported-function-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exported-function-body.js","sourceRoot":"","sources":["../../../src/check/values/exported-function-body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,mBAAmB,GAAG,gEAAgE,CAAC;AAE7F;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAY;IACtE,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC;QAE9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/D,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEjE,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;AACxG,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Exported } from '../exports/exported.js';
2
+ import type { SourceFile } from '../model/source-file.js';
3
+ /**
4
+ * What a file exports, as `fileExports` reads it, with the values it leaves unread: a constant
5
+ * exported by `export { money }` is read from its declaration, and `export default <expression>`
6
+ * is read as a constant named `default` (`export default money` as what `money` declares).
7
+ */
8
+ export declare function exportedValues(file: SourceFile): Exported[];
9
+ //# sourceMappingURL=exported-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exported-values.d.ts","sourceRoot":"","sources":["../../../src/check/values/exported-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAY1D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,CAoB3D"}