@quadnix/octo 0.0.22 → 0.0.24

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 (356) hide show
  1. package/dist/app.type.d.ts +236 -27
  2. package/dist/app.type.js +92 -1
  3. package/dist/app.type.js.map +1 -1
  4. package/dist/decorators/action.decorator.d.ts +4 -5
  5. package/dist/decorators/action.decorator.js +42 -41
  6. package/dist/decorators/action.decorator.js.map +1 -1
  7. package/dist/decorators/anchor.decorator.d.ts +2 -2
  8. package/dist/decorators/anchor.decorator.js +16 -11
  9. package/dist/decorators/anchor.decorator.js.map +1 -1
  10. package/dist/decorators/enable-hook.decorator.d.ts +5 -0
  11. package/dist/decorators/enable-hook.decorator.js +7 -2
  12. package/dist/decorators/enable-hook.decorator.js.map +1 -1
  13. package/dist/decorators/event-source.decorator.d.ts +5 -1
  14. package/dist/decorators/event-source.decorator.js +5 -1
  15. package/dist/decorators/event-source.decorator.js.map +1 -1
  16. package/dist/decorators/factory.decorator.d.ts +14 -2
  17. package/dist/decorators/factory.decorator.js +12 -3
  18. package/dist/decorators/factory.decorator.js.map +1 -1
  19. package/dist/decorators/model.decorator.d.ts +19 -5
  20. package/dist/decorators/model.decorator.js +40 -14
  21. package/dist/decorators/model.decorator.js.map +1 -1
  22. package/dist/decorators/module.decorator.d.ts +4 -75
  23. package/dist/decorators/module.decorator.js +18 -58
  24. package/dist/decorators/module.decorator.js.map +1 -1
  25. package/dist/decorators/on-event.decorator.d.ts +1 -1
  26. package/dist/decorators/on-event.decorator.js +1 -1
  27. package/dist/decorators/on-event.decorator.js.map +1 -1
  28. package/dist/decorators/overlay.decorator.d.ts +16 -6
  29. package/dist/decorators/overlay.decorator.js +36 -15
  30. package/dist/decorators/overlay.decorator.js.map +1 -1
  31. package/dist/decorators/resource.decorator.d.ts +17 -6
  32. package/dist/decorators/resource.decorator.js +37 -15
  33. package/dist/decorators/resource.decorator.js.map +1 -1
  34. package/dist/decorators/validate.decorator.d.ts +12 -4
  35. package/dist/decorators/validate.decorator.js +24 -2
  36. package/dist/decorators/validate.decorator.js.map +1 -1
  37. package/dist/errors/container.error.d.ts +20 -0
  38. package/dist/errors/container.error.js +29 -0
  39. package/dist/errors/container.error.js.map +1 -0
  40. package/dist/errors/index.d.ts +6 -0
  41. package/dist/errors/index.js +7 -0
  42. package/dist/errors/index.js.map +1 -0
  43. package/dist/errors/input.error.d.ts +49 -0
  44. package/dist/errors/input.error.js +59 -0
  45. package/dist/errors/input.error.js.map +1 -0
  46. package/dist/errors/module.error.d.ts +7 -0
  47. package/dist/errors/module.error.js +11 -0
  48. package/dist/errors/module.error.js.map +1 -0
  49. package/dist/errors/node.error.d.ts +63 -0
  50. package/dist/errors/node.error.js +87 -0
  51. package/dist/errors/node.error.js.map +1 -0
  52. package/dist/errors/schema.error.d.ts +7 -0
  53. package/dist/errors/schema.error.js +11 -0
  54. package/dist/errors/schema.error.js.map +1 -0
  55. package/dist/errors/transaction.error.d.ts +56 -0
  56. package/dist/errors/transaction.error.js +79 -0
  57. package/dist/errors/transaction.error.js.map +1 -0
  58. package/dist/events/action.event.d.ts +14 -0
  59. package/dist/events/action.event.js +12 -0
  60. package/dist/events/action.event.js.map +1 -0
  61. package/dist/events/event.model.d.ts +8 -12
  62. package/dist/events/event.model.js +7 -11
  63. package/dist/events/event.model.js.map +1 -1
  64. package/dist/events/hook/commit.hook.event.d.ts +28 -0
  65. package/dist/events/hook/commit.hook.event.js +29 -0
  66. package/dist/events/hook/commit.hook.event.js.map +1 -0
  67. package/dist/events/hook/hook.event.d.ts +10 -0
  68. package/dist/events/hook/hook.event.js +11 -0
  69. package/dist/events/hook/hook.event.js.map +1 -0
  70. package/dist/events/hook/index.d.ts +4 -0
  71. package/dist/events/hook/index.js +5 -0
  72. package/dist/events/hook/index.js.map +1 -0
  73. package/dist/events/hook/model.hook.event.d.ts +28 -0
  74. package/dist/events/hook/model.hook.event.js +29 -0
  75. package/dist/events/hook/model.hook.event.js.map +1 -0
  76. package/dist/events/hook/resource.hook.event.d.ts +28 -0
  77. package/dist/events/hook/resource.hook.event.js +29 -0
  78. package/dist/events/hook/resource.hook.event.js.map +1 -0
  79. package/dist/events/index.d.ts +7 -0
  80. package/dist/events/index.js +8 -0
  81. package/dist/events/index.js.map +1 -0
  82. package/dist/events/module.event.d.ts +3 -7
  83. package/dist/events/module.event.js +2 -6
  84. package/dist/events/module.event.js.map +1 -1
  85. package/dist/events/registration.event.d.ts +22 -57
  86. package/dist/events/registration.event.js +29 -70
  87. package/dist/events/registration.event.js.map +1 -1
  88. package/dist/events/serialization.event.d.ts +34 -41
  89. package/dist/events/serialization.event.js +59 -37
  90. package/dist/events/serialization.event.js.map +1 -1
  91. package/dist/events/transaction.event.d.ts +72 -29
  92. package/dist/events/transaction.event.js +63 -27
  93. package/dist/events/transaction.event.js.map +1 -1
  94. package/dist/functions/container/container.d.ts +56 -9
  95. package/dist/functions/container/container.js +108 -19
  96. package/dist/functions/container/container.js.map +1 -1
  97. package/dist/functions/container/test-container.d.ts +11 -13
  98. package/dist/functions/container/test-container.js +35 -38
  99. package/dist/functions/container/test-container.js.map +1 -1
  100. package/dist/functions/dependency/dependency.d.ts +9 -0
  101. package/dist/functions/dependency/dependency.js +10 -3
  102. package/dist/functions/dependency/dependency.js.map +1 -1
  103. package/dist/functions/diff/diff-metadata.d.ts +6 -5
  104. package/dist/functions/diff/diff-metadata.js +6 -2
  105. package/dist/functions/diff/diff-metadata.js.map +1 -1
  106. package/dist/functions/diff/diff.d.ts +16 -5
  107. package/dist/functions/diff/diff.js +11 -4
  108. package/dist/functions/diff/diff.js.map +1 -1
  109. package/dist/functions/diff/diff.utility.d.ts +5 -2
  110. package/dist/functions/diff/diff.utility.js +28 -4
  111. package/dist/functions/diff/diff.utility.js.map +1 -1
  112. package/dist/functions/hook/commit.hook.d.ts +17 -3
  113. package/dist/functions/hook/commit.hook.js +19 -16
  114. package/dist/functions/hook/commit.hook.js.map +1 -1
  115. package/dist/functions/hook/hook.interface.d.ts +10 -6
  116. package/dist/functions/hook/model-action.hook.d.ts +20 -5
  117. package/dist/functions/hook/model-action.hook.js +23 -39
  118. package/dist/functions/hook/model-action.hook.js.map +1 -1
  119. package/dist/functions/hook/resource-action.hook.d.ts +20 -5
  120. package/dist/functions/hook/resource-action.hook.js +21 -18
  121. package/dist/functions/hook/resource-action.hook.js.map +1 -1
  122. package/dist/functions/node/node-action.abstract.d.ts +10 -0
  123. package/dist/functions/node/node-action.abstract.js +23 -0
  124. package/dist/functions/node/node-action.abstract.js.map +1 -0
  125. package/dist/functions/node/node.abstract.d.ts +20 -9
  126. package/dist/functions/node/node.abstract.js +101 -32
  127. package/dist/functions/node/node.abstract.js.map +1 -1
  128. package/dist/functions/node/node.interface.d.ts +22 -18
  129. package/dist/functions/schema/schema.d.ts +21 -0
  130. package/dist/functions/schema/schema.js +55 -0
  131. package/dist/functions/schema/schema.js.map +1 -0
  132. package/dist/index.d.ts +31 -32
  133. package/dist/index.js +29 -12
  134. package/dist/index.js.map +1 -1
  135. package/dist/main.d.ts +32 -15
  136. package/dist/main.js +65 -50
  137. package/dist/main.js.map +1 -1
  138. package/dist/models/account/account.model.d.ts +26 -0
  139. package/dist/models/account/account.model.js +71 -0
  140. package/dist/models/account/account.model.js.map +1 -0
  141. package/dist/models/account/account.schema.d.ts +13 -0
  142. package/dist/models/account/account.schema.js +18 -0
  143. package/dist/models/account/account.schema.js.map +1 -0
  144. package/dist/models/app/app.model.d.ts +9 -14
  145. package/dist/models/app/app.model.js +27 -27
  146. package/dist/models/app/app.model.js.map +1 -1
  147. package/dist/models/app/app.schema.d.ts +6 -0
  148. package/dist/models/app/app.schema.js +24 -0
  149. package/dist/models/app/app.schema.js.map +1 -0
  150. package/dist/models/deployment/deployment.model.d.ts +9 -12
  151. package/dist/models/deployment/deployment.model.js +11 -11
  152. package/dist/models/deployment/deployment.model.js.map +1 -1
  153. package/dist/models/deployment/deployment.schema.d.ts +10 -0
  154. package/dist/models/deployment/deployment.schema.js +28 -0
  155. package/dist/models/deployment/deployment.schema.js.map +1 -0
  156. package/dist/models/environment/environment.model.d.ts +8 -14
  157. package/dist/models/environment/environment.model.js +10 -22
  158. package/dist/models/environment/environment.model.js.map +1 -1
  159. package/dist/models/environment/environment.schema.d.ts +16 -0
  160. package/dist/models/environment/environment.schema.js +41 -0
  161. package/dist/models/environment/environment.schema.js.map +1 -0
  162. package/dist/models/execution/execution.model.d.ts +9 -13
  163. package/dist/models/execution/execution.model.js +18 -25
  164. package/dist/models/execution/execution.model.js.map +1 -1
  165. package/dist/models/execution/execution.schema.d.ts +17 -0
  166. package/dist/models/execution/execution.schema.js +37 -0
  167. package/dist/models/execution/execution.schema.js.map +1 -0
  168. package/dist/models/filesystem/filesystem.model.d.ts +13 -0
  169. package/dist/models/filesystem/filesystem.model.js +46 -0
  170. package/dist/models/filesystem/filesystem.model.js.map +1 -0
  171. package/dist/models/filesystem/filesystem.schema.d.ts +6 -0
  172. package/dist/models/filesystem/filesystem.schema.js +24 -0
  173. package/dist/models/filesystem/filesystem.schema.js.map +1 -0
  174. package/dist/models/image/image.model.d.ts +10 -40
  175. package/dist/models/image/image.model.js +17 -27
  176. package/dist/models/image/image.model.js.map +1 -1
  177. package/dist/models/image/image.schema.d.ts +12 -0
  178. package/dist/models/image/image.schema.js +34 -0
  179. package/dist/models/image/image.schema.js.map +1 -0
  180. package/dist/models/model-action.interface.d.ts +5 -13
  181. package/dist/models/model.abstract.d.ts +28 -13
  182. package/dist/models/model.abstract.js +179 -13
  183. package/dist/models/model.abstract.js.map +1 -1
  184. package/dist/models/model.interface.d.ts +17 -6
  185. package/dist/models/pipeline/pipeline.model.d.ts +8 -7
  186. package/dist/models/pipeline/pipeline.model.js +10 -10
  187. package/dist/models/pipeline/pipeline.model.js.map +1 -1
  188. package/dist/models/pipeline/pipeline.schema.d.ts +7 -0
  189. package/dist/models/pipeline/pipeline.schema.js +25 -0
  190. package/dist/models/pipeline/pipeline.schema.js.map +1 -0
  191. package/dist/models/region/region.model.d.ts +11 -8
  192. package/dist/models/region/region.model.js +25 -12
  193. package/dist/models/region/region.model.js.map +1 -1
  194. package/dist/models/region/region.schema.d.ts +6 -0
  195. package/dist/models/region/region.schema.js +24 -0
  196. package/dist/models/region/region.schema.js.map +1 -0
  197. package/dist/models/server/server.model.d.ts +8 -10
  198. package/dist/models/server/server.model.js +13 -11
  199. package/dist/models/server/server.model.js.map +1 -1
  200. package/dist/models/server/server.schema.d.ts +9 -0
  201. package/dist/models/server/server.schema.js +27 -0
  202. package/dist/models/server/server.schema.js.map +1 -0
  203. package/dist/models/service/service.model.d.ts +7 -9
  204. package/dist/models/service/service.model.js +15 -13
  205. package/dist/models/service/service.model.js.map +1 -1
  206. package/dist/models/service/service.schema.d.ts +9 -0
  207. package/dist/models/service/service.schema.js +27 -0
  208. package/dist/models/service/service.schema.js.map +1 -0
  209. package/dist/models/subnet/subnet.model.d.ts +11 -33
  210. package/dist/models/subnet/subnet.model.js +14 -34
  211. package/dist/models/subnet/subnet.model.js.map +1 -1
  212. package/dist/models/subnet/subnet.schema.d.ts +38 -0
  213. package/dist/models/subnet/subnet.schema.js +53 -0
  214. package/dist/models/subnet/subnet.schema.js.map +1 -0
  215. package/dist/modules/module.abstract.d.ts +24 -0
  216. package/dist/modules/module.abstract.js +17 -0
  217. package/dist/modules/module.abstract.js.map +1 -0
  218. package/dist/modules/module.container.d.ts +38 -18
  219. package/dist/modules/module.container.js +140 -81
  220. package/dist/modules/module.container.js.map +1 -1
  221. package/dist/modules/module.interface.d.ts +18 -2
  222. package/dist/modules/test-module.container.d.ts +39 -15
  223. package/dist/modules/test-module.container.js +262 -26
  224. package/dist/modules/test-module.container.js.map +1 -1
  225. package/dist/overlays/anchor.abstract.d.ts +16 -8
  226. package/dist/overlays/anchor.abstract.js +4 -1
  227. package/dist/overlays/anchor.abstract.js.map +1 -1
  228. package/dist/overlays/anchor.interface.d.ts +8 -8
  229. package/dist/overlays/anchor.schema.d.ts +14 -0
  230. package/dist/overlays/anchor.schema.js +12 -0
  231. package/dist/overlays/anchor.schema.js.map +1 -0
  232. package/dist/overlays/overlay-data.repository.d.ts +9 -4
  233. package/dist/overlays/overlay-data.repository.js +20 -10
  234. package/dist/overlays/overlay-data.repository.js.map +1 -1
  235. package/dist/overlays/overlay.abstract.d.ts +15 -13
  236. package/dist/overlays/overlay.abstract.js +22 -8
  237. package/dist/overlays/overlay.abstract.js.map +1 -1
  238. package/dist/overlays/overlay.interface.d.ts +6 -7
  239. package/dist/overlays/overlay.schema.d.ts +11 -0
  240. package/dist/overlays/overlay.schema.js +12 -0
  241. package/dist/overlays/overlay.schema.js.map +1 -0
  242. package/dist/resources/resource-action.interface.d.ts +7 -3
  243. package/dist/resources/resource-data.repository.d.ts +8 -3
  244. package/dist/resources/resource-data.repository.js +64 -82
  245. package/dist/resources/resource-data.repository.js.map +1 -1
  246. package/dist/resources/resource.abstract.d.ts +53 -27
  247. package/dist/resources/resource.abstract.js +233 -57
  248. package/dist/resources/resource.abstract.js.map +1 -1
  249. package/dist/resources/resource.interface.d.ts +45 -8
  250. package/dist/resources/resource.schema.d.ts +17 -0
  251. package/dist/resources/resource.schema.js +14 -0
  252. package/dist/resources/resource.schema.js.map +1 -0
  253. package/dist/services/capture/capture.service.d.ts +12 -6
  254. package/dist/services/capture/capture.service.js +14 -5
  255. package/dist/services/capture/capture.service.js.map +1 -1
  256. package/dist/services/event/event.service.d.ts +8 -2
  257. package/dist/services/event/event.service.js +9 -2
  258. package/dist/services/event/event.service.js.map +1 -1
  259. package/dist/services/input/input.service.d.ts +68 -6
  260. package/dist/services/input/input.service.js +296 -14
  261. package/dist/services/input/input.service.js.map +1 -1
  262. package/dist/services/schema-translation/schema-translation.service.d.ts +19 -0
  263. package/dist/services/schema-translation/schema-translation.service.js +48 -0
  264. package/dist/services/schema-translation/schema-translation.service.js.map +1 -0
  265. package/dist/services/serialization/model/model-serialization.service.d.ts +7 -4
  266. package/dist/services/serialization/model/model-serialization.service.js +65 -33
  267. package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
  268. package/dist/services/serialization/resource/resource-serialization.service.d.ts +7 -1
  269. package/dist/services/serialization/resource/resource-serialization.service.js +64 -80
  270. package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
  271. package/dist/services/state-management/local.state-provider.d.ts +3 -1
  272. package/dist/services/state-management/local.state-provider.js +8 -7
  273. package/dist/services/state-management/local.state-provider.js.map +1 -1
  274. package/dist/services/state-management/state-management.service.d.ts +8 -3
  275. package/dist/services/state-management/state-management.service.js +25 -8
  276. package/dist/services/state-management/state-management.service.js.map +1 -1
  277. package/dist/services/state-management/state-provider.interface.d.ts +3 -1
  278. package/dist/services/state-management/test.state-provider.d.ts +3 -1
  279. package/dist/services/state-management/test.state-provider.js +5 -1
  280. package/dist/services/state-management/test.state-provider.js.map +1 -1
  281. package/dist/services/transaction/transaction.service.d.ts +22 -11
  282. package/dist/services/transaction/transaction.service.js +215 -66
  283. package/dist/services/transaction/transaction.service.js.map +1 -1
  284. package/dist/services/validation/validation.service.d.ts +8 -3
  285. package/dist/services/validation/validation.service.js +33 -12
  286. package/dist/services/validation/validation.service.js.map +1 -1
  287. package/dist/utilities/array/array.utility.d.ts +3 -0
  288. package/dist/utilities/array/array.utility.js +3 -0
  289. package/dist/utilities/array/array.utility.js.map +1 -1
  290. package/dist/utilities/cidr/cidr.utility.d.ts +3 -0
  291. package/dist/utilities/cidr/cidr.utility.js +3 -0
  292. package/dist/utilities/cidr/cidr.utility.js.map +1 -1
  293. package/dist/utilities/node/node.utility.d.ts +7 -0
  294. package/dist/utilities/node/node.utility.js +25 -0
  295. package/dist/utilities/node/node.utility.js.map +1 -0
  296. package/dist/utilities/object/object.utility.d.ts +6 -0
  297. package/dist/utilities/object/object.utility.js +36 -0
  298. package/dist/utilities/object/object.utility.js.map +1 -1
  299. package/dist/utilities/test-helpers/test-classes.d.ts +84 -0
  300. package/dist/utilities/test-helpers/test-classes.js +103 -0
  301. package/dist/utilities/test-helpers/test-classes.js.map +1 -0
  302. package/dist/utilities/test-helpers/test-models.d.ts +47 -0
  303. package/dist/utilities/test-helpers/test-models.js +230 -0
  304. package/dist/utilities/test-helpers/test-models.js.map +1 -0
  305. package/dist/utilities/test-helpers/test-overlays.d.ts +13 -0
  306. package/dist/utilities/test-helpers/test-overlays.js +56 -0
  307. package/dist/utilities/test-helpers/test-overlays.js.map +1 -0
  308. package/dist/utilities/test-helpers/test-resources.d.ts +31 -0
  309. package/dist/utilities/test-helpers/test-resources.js +171 -0
  310. package/dist/utilities/test-helpers/test-resources.js.map +1 -0
  311. package/dist/utilities/validation/validation.utility.d.ts +34 -3
  312. package/dist/utilities/validation/validation.utility.js +124 -2
  313. package/dist/utilities/validation/validation.utility.js.map +1 -1
  314. package/package.json +7 -7
  315. package/dist/events/error.event.d.ts +0 -35
  316. package/dist/events/error.event.js +0 -36
  317. package/dist/events/error.event.js.map +0 -1
  318. package/dist/events/hook.event.d.ts +0 -194
  319. package/dist/events/hook.event.js +0 -195
  320. package/dist/events/hook.event.js.map +0 -1
  321. package/dist/models/app/app.interface.d.ts +0 -9
  322. package/dist/models/app/app.interface.js +0 -2
  323. package/dist/models/app/app.interface.js.map +0 -1
  324. package/dist/models/deployment/deployment.interface.d.ts +0 -9
  325. package/dist/models/deployment/deployment.interface.js +0 -2
  326. package/dist/models/deployment/deployment.interface.js.map +0 -1
  327. package/dist/models/environment/environment.interface.d.ts +0 -12
  328. package/dist/models/environment/environment.interface.js +0 -2
  329. package/dist/models/environment/environment.interface.js.map +0 -1
  330. package/dist/models/execution/execution.interface.d.ts +0 -14
  331. package/dist/models/execution/execution.interface.js +0 -2
  332. package/dist/models/execution/execution.interface.js.map +0 -1
  333. package/dist/models/image/image.interface.d.ts +0 -12
  334. package/dist/models/image/image.interface.js +0 -2
  335. package/dist/models/image/image.interface.js.map +0 -1
  336. package/dist/models/pipeline/pipeline.interface.d.ts +0 -10
  337. package/dist/models/pipeline/pipeline.interface.js +0 -2
  338. package/dist/models/pipeline/pipeline.interface.js.map +0 -1
  339. package/dist/models/region/region.interface.d.ts +0 -9
  340. package/dist/models/region/region.interface.js +0 -2
  341. package/dist/models/region/region.interface.js.map +0 -1
  342. package/dist/models/server/server.interface.d.ts +0 -9
  343. package/dist/models/server/server.interface.js +0 -2
  344. package/dist/models/server/server.interface.js.map +0 -1
  345. package/dist/models/service/service.interface.d.ts +0 -9
  346. package/dist/models/service/service.interface.js +0 -2
  347. package/dist/models/service/service.interface.js.map +0 -1
  348. package/dist/models/subnet/subnet.interface.d.ts +0 -13
  349. package/dist/models/subnet/subnet.interface.js +0 -2
  350. package/dist/models/subnet/subnet.interface.js.map +0 -1
  351. package/dist/overlays/overlay.service.d.ts +0 -17
  352. package/dist/overlays/overlay.service.js +0 -41
  353. package/dist/overlays/overlay.service.js.map +0 -1
  354. package/dist/resources/shared-resource.abstract.d.ts +0 -13
  355. package/dist/resources/shared-resource.abstract.js +0 -47
  356. package/dist/resources/shared-resource.abstract.js.map +0 -1
@@ -7,20 +7,25 @@ import { CommitHook } from '../functions/hook/commit.hook.js';
7
7
  * @EnableHook('CommitHook')
8
8
  * async commitTransaction(): Promise<void> { ... }
9
9
  * ```
10
+ *
10
11
  * @group Decorators
12
+ *
11
13
  * @internal
14
+ *
12
15
  * @param hook The only values supported are `CommitHook`.
16
+ *
13
17
  * @returns The decorated method.
18
+ *
14
19
  * @see Definition of [Hooks](/docs/fundamentals/modules#hooks).
15
20
  */
16
21
  export function EnableHook(hook) {
17
- return function (target, propertyKey, descriptor) {
22
+ return function (_target, _propertyKey, descriptor) {
18
23
  switch (hook) {
19
24
  case 'CommitHook':
20
25
  CommitHook.getInstance().registrar(descriptor);
21
26
  break;
22
27
  default:
23
- throw new Error('Invalid hook!');
28
+ throw new Error(`Invalid hook "${hook}"!`);
24
29
  }
25
30
  };
26
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enable-hook.decorator.js","sourceRoot":"","sources":["../../src/decorators/enable-hook.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAI9D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,YAAY;gBACf,UAAU,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC/C,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"enable-hook.decorator.js","sourceRoot":"","sources":["../../src/decorators/enable-hook.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAI9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QACjF,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,YAAY;gBACf,UAAU,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC/C,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Constructable } from '../app.type.js';
2
- import type { Event } from '../events/event.model.js';
2
+ import type { Event } from '../events/index.js';
3
3
  /**
4
4
  * An `@EventSource` is a method decorator to enable automatic event emission.
5
5
  * The `registrar()` method of the Event class is used to decorate the method to auto-emit events.
@@ -10,9 +10,13 @@ import type { Event } from '../events/event.model.js';
10
10
  * @EventSource(MyEvent)
11
11
  * myMethod(): void { ... }
12
12
  * ```
13
+ *
13
14
  * @group Decorators
15
+ *
14
16
  * @internal
17
+ *
15
18
  * @param ofType The type of event being emitted.
19
+ *
16
20
  * @returns The decorated method.
17
21
  */
18
22
  export declare function EventSource(ofType: Constructable<Event<unknown>>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -9,13 +9,17 @@ import { EventService } from '../services/event/event.service.js';
9
9
  * @EventSource(MyEvent)
10
10
  * myMethod(): void { ... }
11
11
  * ```
12
+ *
12
13
  * @group Decorators
14
+ *
13
15
  * @internal
16
+ *
14
17
  * @param ofType The type of event being emitted.
18
+ *
15
19
  * @returns The decorated method.
16
20
  */
17
21
  export function EventSource(ofType) {
18
- return function (target, propertyKey, descriptor) {
22
+ return function (_target, _propertyKey, descriptor) {
19
23
  ofType.registrar(EventService.getInstance(), descriptor);
20
24
  };
21
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"event-source.decorator.js","sourceRoot":"","sources":["../../src/decorators/event-source.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CACzB,MAAqC;IAErC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC9E,MAAc,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"event-source.decorator.js","sourceRoot":"","sources":["../../src/decorators/event-source.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CACzB,MAAqC;IAErC,OAAO,UAAU,OAAY,EAAE,YAAoB,EAAE,UAA8B;QAChF,MAAc,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
@@ -3,10 +3,14 @@ import type { Constructable } from '../app.type.js';
3
3
  * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
4
  * A factory is responsible for creating instances of a class.
5
5
  *
6
+ * It is possible to generate multiple factories for the same class
7
+ * by assigning a unique set of metadata to the factory.
8
+ * Of all registered factories, only one can be the default factory.
9
+ *
6
10
  * @example
7
11
  * ```ts
8
12
  * // Factory definition.
9
- * @Factory<MyService>(MyService)
13
+ * @Factory<MyService>(MyService, { metadata: { key: 'value' } })
10
14
  * export class MyServiceFactory {
11
15
  * static async create(arg1, arg2, ...): Promise<MyService> { ... }
12
16
  * }
@@ -14,11 +18,15 @@ import type { Constructable } from '../app.type.js';
14
18
  * // Get instance using default factory.
15
19
  * const myService = await Container.get(MyService);
16
20
  *
21
+ * // Get instance using specific factory.
22
+ * const myService = await Container.get(MyService, { metadata: { key: 'value' } });
23
+ *
17
24
  * // Pass args to factory.
18
25
  * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
19
26
  * ```
20
27
  * @group Decorators
21
28
  * @param type The type of class that the factory creates.
29
+ * @param options Allows registering multiple factories for the same class that differ by metadata.
22
30
  * @remarks
23
31
  * If the factory is dependent on other factories, it should not block creation of its instance.
24
32
  * ```ts
@@ -52,6 +60,10 @@ import type { Constructable } from '../app.type.js';
52
60
  * ```
53
61
  * @returns The decorated class.
54
62
  */
55
- export declare function Factory<T>(type: Constructable<T> | string): (constructor: {
63
+ export declare function Factory<T>(type: Constructable<T> | string, options?: {
64
+ metadata?: {
65
+ [key: string]: string;
66
+ };
67
+ }): (constructor: {
56
68
  create: (...args: unknown[]) => Promise<T>;
57
69
  }) => void;
@@ -3,10 +3,14 @@ import { Container } from '../functions/container/container.js';
3
3
  * A `@Factory` is a class decorator to be placed on top of a class that represents a factory.
4
4
  * A factory is responsible for creating instances of a class.
5
5
  *
6
+ * It is possible to generate multiple factories for the same class
7
+ * by assigning a unique set of metadata to the factory.
8
+ * Of all registered factories, only one can be the default factory.
9
+ *
6
10
  * @example
7
11
  * ```ts
8
12
  * // Factory definition.
9
- * @Factory<MyService>(MyService)
13
+ * @Factory<MyService>(MyService, { metadata: { key: 'value' } })
10
14
  * export class MyServiceFactory {
11
15
  * static async create(arg1, arg2, ...): Promise<MyService> { ... }
12
16
  * }
@@ -14,11 +18,15 @@ import { Container } from '../functions/container/container.js';
14
18
  * // Get instance using default factory.
15
19
  * const myService = await Container.get(MyService);
16
20
  *
21
+ * // Get instance using specific factory.
22
+ * const myService = await Container.get(MyService, { metadata: { key: 'value' } });
23
+ *
17
24
  * // Pass args to factory.
18
25
  * const myService = await Container.get(MyService, { args: [arg1, arg2, ...] });
19
26
  * ```
20
27
  * @group Decorators
21
28
  * @param type The type of class that the factory creates.
29
+ * @param options Allows registering multiple factories for the same class that differ by metadata.
22
30
  * @remarks
23
31
  * If the factory is dependent on other factories, it should not block creation of its instance.
24
32
  * ```ts
@@ -52,9 +60,10 @@ import { Container } from '../functions/container/container.js';
52
60
  * ```
53
61
  * @returns The decorated class.
54
62
  */
55
- export function Factory(type) {
63
+ export function Factory(type, options) {
64
+ const container = Container.getInstance();
56
65
  return function (constructor) {
57
- Container.registerFactory(type, constructor);
66
+ container.registerFactory(type, constructor, options);
58
67
  };
59
68
  }
60
69
  //# sourceMappingURL=factory.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.decorator.js","sourceRoot":"","sources":["../../src/decorators/factory.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,UAAU,OAAO,CACrB,IAA+B;IAE/B,OAAO,UAAU,WAA2D;QAC1E,SAAS,CAAC,eAAe,CAAI,IAAI,EAAE,WAAW,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"factory.decorator.js","sourceRoot":"","sources":["../../src/decorators/factory.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,UAAU,OAAO,CACrB,IAA+B,EAC/B,OAEC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,UAAU,WAA2D;QAC1E,SAAS,CAAC,eAAe,CAAI,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC"}
@@ -1,14 +1,28 @@
1
+ import { type Constructable, type ModelSchema, type UnknownModel } from '../app.type.js';
1
2
  /**
2
- * A `@Model` is a class decorator to be placed on top of a class that represents a model.
3
- * - A model must extend the {@link AModel} class.
3
+ * A `@Model` is a class decorator and must be placed on top of a class representing a model.
4
+ * - A model must also extend a base model class.
5
+ * - For type safety, the type of model being decorated is passed to the decorator.
4
6
  *
5
7
  * @example
6
8
  * ```ts
7
- * @Model()
8
- * export class MyModel extends AModel<IMyModel, MyModel> { ... }
9
+ * @Model<MyModel>('@example', 'region', MyModelSchema)
10
+ * export class MyModel extends Region { ... }
9
11
  * ```
12
+ *
10
13
  * @group Decorators
14
+ *
15
+ * @param packageName - The name of the package under which the model is registered.
16
+ * Selecting a unique package name helps avoid collisions between same model class names across different libraries.
17
+ * You will reuse the same package name throughout your library for different Octo components you create.
18
+ * @param modelName - a string that uniquely represents the base model you are extending.
19
+ * Octo provides names for each of the base models, and you must use the same name.
20
+ * E.g. for region base model, the model name is `region`.
21
+ * @param schema - The schema of the model.
22
+ *
11
23
  * @returns The decorated class.
24
+ *
12
25
  * @see Definition of [Models](/docs/fundamentals/models).
26
+ * @see {@link App} and {@link Region} are a few base models. More can be found in the same folder.
13
27
  */
14
- export declare function Model(): (constructor: any) => void;
28
+ export declare function Model<T extends UnknownModel>(packageName: string, modelName: string, schema: Constructable<ModelSchema<T>>): (constructor: any) => void;
@@ -1,29 +1,55 @@
1
- import { RegistrationErrorEvent } from '../events/error.event.js';
2
- import { EventService } from '../services/event/event.service.js';
3
- import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
1
+ import { NodeType } from '../app.type.js';
4
2
  import { Container } from '../functions/container/container.js';
3
+ import { AModel } from '../models/model.abstract.js';
4
+ import { AOverlay } from '../overlays/overlay.abstract.js';
5
+ import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
6
+ import { ValidationUtility } from '../utilities/validation/validation.utility.js';
5
7
  /**
6
- * A `@Model` is a class decorator to be placed on top of a class that represents a model.
7
- * - A model must extend the {@link AModel} class.
8
+ * A `@Model` is a class decorator and must be placed on top of a class representing a model.
9
+ * - A model must also extend a base model class.
10
+ * - For type safety, the type of model being decorated is passed to the decorator.
8
11
  *
9
12
  * @example
10
13
  * ```ts
11
- * @Model()
12
- * export class MyModel extends AModel<IMyModel, MyModel> { ... }
14
+ * @Model<MyModel>('@example', 'region', MyModelSchema)
15
+ * export class MyModel extends Region { ... }
13
16
  * ```
17
+ *
14
18
  * @group Decorators
19
+ *
20
+ * @param packageName - The name of the package under which the model is registered.
21
+ * Selecting a unique package name helps avoid collisions between same model class names across different libraries.
22
+ * You will reuse the same package name throughout your library for different Octo components you create.
23
+ * @param modelName - a string that uniquely represents the base model you are extending.
24
+ * Octo provides names for each of the base models, and you must use the same name.
25
+ * E.g. for region base model, the model name is `region`.
26
+ * @param schema - The schema of the model.
27
+ *
15
28
  * @returns The decorated class.
29
+ *
16
30
  * @see Definition of [Models](/docs/fundamentals/models).
31
+ * @see {@link App} and {@link Region} are a few base models. More can be found in the same folder.
17
32
  */
18
- export function Model() {
33
+ export function Model(packageName, modelName, schema) {
34
+ const container = Container.getInstance();
19
35
  return function (constructor) {
20
- Container.get(ModelSerializationService)
21
- .then((modelSerializationService) => {
22
- modelSerializationService.registerClass(constructor.name, constructor);
23
- })
24
- .catch((error) => {
25
- EventService.getInstance().emit(new RegistrationErrorEvent(error));
36
+ if (!ValidationUtility.validateRegex(packageName, /^[@A-Za-z][\w-]+[A-Za-z]$/)) {
37
+ throw new Error(`Invalid package name: ${packageName}`);
38
+ }
39
+ if (!ValidationUtility.validateRegex(modelName, /^[A-Za-z][\w-]+[A-Za-z]$/)) {
40
+ throw new Error(`Invalid model name: ${modelName}`);
41
+ }
42
+ if (!(constructor.prototype instanceof AModel) || constructor.prototype instanceof AOverlay) {
43
+ throw new Error(`Class "${constructor.name}" must extend the AModel class!`);
44
+ }
45
+ constructor.NODE_NAME = modelName;
46
+ constructor.NODE_PACKAGE = packageName;
47
+ constructor.NODE_SCHEMA = schema;
48
+ constructor.NODE_TYPE = NodeType.MODEL;
49
+ const promise = container.get(ModelSerializationService).then((modelSerializationService) => {
50
+ modelSerializationService.registerClass(`${packageName}/${constructor.name}`, constructor);
26
51
  });
52
+ container.registerStartupUnhandledPromise(promise);
27
53
  };
28
54
  }
29
55
  //# sourceMappingURL=model.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,QAAQ,EAAqB,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,KAAK,CACnB,WAAmB,EACnB,SAAiB,EACjB,MAAqC;IAErC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,UAAU,WAAgB;QAC/B,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,2BAA2B,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,SAAS,EAAE,0BAA0B,CAAC,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,uBAAuB,SAAS,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,YAAY,MAAM,CAAC,IAAI,WAAW,CAAC,SAAS,YAAY,QAAQ,EAAE,CAAC;YAC5F,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,CAAC,IAAI,iCAAiC,CAAC,CAAC;QAC/E,CAAC;QAED,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC;QACvC,WAAW,CAAC,WAAW,GAAG,MAAM,CAAC;QACjC,WAAW,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC;QAEvC,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAC1F,yBAAyB,CAAC,aAAa,CAAC,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC"}
@@ -1,92 +1,21 @@
1
- import type { Constructable } from '../app.type.js';
2
- import type { DiffMetadata } from '../functions/diff/diff-metadata.js';
3
- import type { App } from '../models/app/app.model.js';
4
- import type { IModelAction } from '../models/model-action.interface.js';
5
- import { type IModule } from '../modules/module.interface.js';
6
- import type { IResourceAction } from '../resources/resource-action.interface.js';
7
- type CommitHooksCallback = (app: App, modelTransaction: DiffMetadata[][], resourceTransaction: DiffMetadata[][]) => Promise<void>;
8
- export interface IModuleOptions {
9
- args?: {
10
- isArg: (arg: unknown) => boolean;
11
- name: string;
12
- }[];
13
- imports?: (Constructable<IModule<unknown>> | string)[];
14
- postCommitHooks?: {
15
- callback: CommitHooksCallback;
16
- }[];
17
- postModelActionHooks?: {
18
- ACTION_NAME: string;
19
- collectInput?: IModelAction['collectInput'];
20
- handle: IModelAction['handle'];
21
- }[];
22
- postResourceActionHooks?: {
23
- ACTION_NAME: string;
24
- handle: IResourceAction['handle'];
25
- }[];
26
- preCommitHooks?: {
27
- callback: CommitHooksCallback;
28
- }[];
29
- preModelActionHooks?: {
30
- ACTION_NAME: string;
31
- collectInput?: IModelAction['collectInput'];
32
- handle: IModelAction['handle'];
33
- }[];
34
- preResourceActionHooks?: {
35
- ACTION_NAME: string;
36
- handle: IResourceAction['handle'];
37
- }[];
38
- }
1
+ import type { Constructable, ModuleSchema } from '../app.type.js';
39
2
  /**
40
3
  * A `@Module` is a class decorator to be placed on top of a class that represents a module.
41
4
  * - A Module class must implement the {@link IModule} interface.
42
- * - A Module class constructor is injected with the outputs of the modules it imports.
43
5
  * - The {@link IModule.onInit} method is called to initialize the module,
44
6
  * and is where you will *define* your infrastructure.
45
7
  *
46
8
  * @example
47
9
  * ```ts
48
- * @Module({
49
- * args: [{ isArg: (app: App) => app instanceof App, name: 'app' }],
50
- * imports: [OtherModule],
51
- * postModelActionHooks: [{ ACTION_NAME: 'SomeAction', collectInput: () => { ... }, handle: () => { ... } }],
52
- * })
10
+ * @Module<MyInputInterface, OutputModel>('my-package', {})
53
11
  * export class MyModule implements IModule<Region> {
54
- * constructor(app: App) { ... }
12
+ * constructor(inputs: IMyInputs) { ... }
55
13
  *
56
14
  * async onInit(): Promise<Region> { ... }
57
15
  * }
58
16
  * ```
59
17
  * @group Decorators
60
- * @param options - Options to the module.
61
- * @param options.args - (optional) An array of arg validators to verify the args passed to the module's constructor.
62
- * - The `isArg` method receives an argument, and you must do your own type checking and return a boolean.
63
- * - The `name` property is the name of the argument.
64
- * @param options.imports - (optional) An array of modules to import.
65
- * @param options.postCommitHooks - (optional) An array of post-commit hooks.
66
- * - The `callback` method will be called after the transaction is committed.
67
- * This method receives the same arguments as {@link Octo.commitTransaction}.
68
- * @param options.postModelActionHooks - (optional) An array of post-model action hooks.
69
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
70
- * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
71
- * - The `handle` method will be called after the action is executed.
72
- * This method receives the same arguments as {@link IModelAction.handle}.
73
- * @param options.postResourceActionHooks - (optional) An array of post-resource action hooks.
74
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
75
- * - The `handle` method will be called after the action is executed.
76
- * This method receives the same arguments as {@link IResourceAction.handle}.
77
- * @param options.preCommitHooks - (optional) An array of pre-commit hooks.
78
- * - The `callback` method will be called before the transaction is committed.
79
- * This method receives the same arguments as {@link Octo.commitTransaction}.
80
- * @param options.preModelActionHooks - (optional) An array of pre-model action hooks.
81
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
82
- * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
83
- * - The `handle` method will be called before the action is executed.
84
- * This method receives the same arguments as {@link IModelAction.handle}.
85
- * @param options.preResourceActionHooks - (optional) An array of pre-resource action hooks.
86
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
87
- * - The `handle` method will be called before the action is executed.
88
18
  * @returns The decorated class.
89
19
  * @see Definition of [Modules](/docs/fundamentals/modules).
90
20
  */
91
- export declare function Module({ args, imports, postCommitHooks, postModelActionHooks, postResourceActionHooks, preCommitHooks, preModelActionHooks, preResourceActionHooks, }?: IModuleOptions): (constructor: any) => void;
92
- export {};
21
+ export declare function Module<T>(packageName: string, schema: Constructable<ModuleSchema<T>>): (constructor: any) => void;
@@ -1,81 +1,41 @@
1
- import { RegistrationErrorEvent } from '../events/error.event.js';
2
- import { ModuleContainer } from '../modules/module.container.js';
3
- import { EventService } from '../services/event/event.service.js';
4
1
  import { Container } from '../functions/container/container.js';
2
+ import { AModule } from '../modules/module.abstract.js';
3
+ import { ModuleContainer } from '../modules/module.container.js';
4
+ import { ValidationUtility } from '../utilities/validation/validation.utility.js';
5
5
  /**
6
6
  * A `@Module` is a class decorator to be placed on top of a class that represents a module.
7
7
  * - A Module class must implement the {@link IModule} interface.
8
- * - A Module class constructor is injected with the outputs of the modules it imports.
9
8
  * - The {@link IModule.onInit} method is called to initialize the module,
10
9
  * and is where you will *define* your infrastructure.
11
10
  *
12
11
  * @example
13
12
  * ```ts
14
- * @Module({
15
- * args: [{ isArg: (app: App) => app instanceof App, name: 'app' }],
16
- * imports: [OtherModule],
17
- * postModelActionHooks: [{ ACTION_NAME: 'SomeAction', collectInput: () => { ... }, handle: () => { ... } }],
18
- * })
13
+ * @Module<MyInputInterface, OutputModel>('my-package', {})
19
14
  * export class MyModule implements IModule<Region> {
20
- * constructor(app: App) { ... }
15
+ * constructor(inputs: IMyInputs) { ... }
21
16
  *
22
17
  * async onInit(): Promise<Region> { ... }
23
18
  * }
24
19
  * ```
25
20
  * @group Decorators
26
- * @param options - Options to the module.
27
- * @param options.args - (optional) An array of arg validators to verify the args passed to the module's constructor.
28
- * - The `isArg` method receives an argument, and you must do your own type checking and return a boolean.
29
- * - The `name` property is the name of the argument.
30
- * @param options.imports - (optional) An array of modules to import.
31
- * @param options.postCommitHooks - (optional) An array of post-commit hooks.
32
- * - The `callback` method will be called after the transaction is committed.
33
- * This method receives the same arguments as {@link Octo.commitTransaction}.
34
- * @param options.postModelActionHooks - (optional) An array of post-model action hooks.
35
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
36
- * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
37
- * - The `handle` method will be called after the action is executed.
38
- * This method receives the same arguments as {@link IModelAction.handle}.
39
- * @param options.postResourceActionHooks - (optional) An array of post-resource action hooks.
40
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
41
- * - The `handle` method will be called after the action is executed.
42
- * This method receives the same arguments as {@link IResourceAction.handle}.
43
- * @param options.preCommitHooks - (optional) An array of pre-commit hooks.
44
- * - The `callback` method will be called before the transaction is committed.
45
- * This method receives the same arguments as {@link Octo.commitTransaction}.
46
- * @param options.preModelActionHooks - (optional) An array of pre-model action hooks.
47
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
48
- * - The `collectInput` method can be used to enrich the action inputs. It works the same as in {@link IModelAction}.
49
- * - The `handle` method will be called before the action is executed.
50
- * This method receives the same arguments as {@link IModelAction.handle}.
51
- * @param options.preResourceActionHooks - (optional) An array of pre-resource action hooks.
52
- * - The `ACTION_NAME` identifies the action on which this hook is registered.
53
- * - The `handle` method will be called before the action is executed.
54
21
  * @returns The decorated class.
55
22
  * @see Definition of [Modules](/docs/fundamentals/modules).
56
23
  */
57
- export function Module({ args = [], imports = [], postCommitHooks = [], postModelActionHooks = [], postResourceActionHooks = [], preCommitHooks = [], preModelActionHooks = [], preResourceActionHooks = [], } = {}) {
24
+ export function Module(packageName, schema) {
25
+ const container = Container.getInstance();
58
26
  return function (constructor) {
59
- Container.get(ModuleContainer)
60
- .then((moduleContainer) => {
61
- // Verify classes with @Module implements IModule.
62
- if (!('onInit' in constructor.prototype)) {
63
- throw new Error(`Class "${constructor.name}" does not implement IModule!`);
64
- }
65
- moduleContainer.register(constructor, {
66
- args,
67
- imports,
68
- postCommitHooks,
69
- postModelActionHooks,
70
- postResourceActionHooks,
71
- preCommitHooks,
72
- preModelActionHooks,
73
- preResourceActionHooks,
74
- });
75
- })
76
- .catch((error) => {
77
- EventService.getInstance().emit(new RegistrationErrorEvent(error));
27
+ if (!ValidationUtility.validateRegex(packageName, /^[@A-Za-z][\w-]+[A-Za-z]$/)) {
28
+ throw new Error(`Invalid package name: ${packageName}`);
29
+ }
30
+ if (!(constructor.prototype instanceof AModule)) {
31
+ throw new Error(`Class "${constructor.name}" must extend the AModule class!`);
32
+ }
33
+ constructor.MODULE_PACKAGE = packageName;
34
+ constructor.MODULE_SCHEMA = schema;
35
+ const promise = container.get(ModuleContainer).then((moduleContainer) => {
36
+ moduleContainer.register(constructor, { packageName });
78
37
  });
38
+ container.registerStartupUnhandledPromise(promise);
79
39
  };
80
40
  }
81
41
  //# sourceMappingURL=module.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.decorator.js","sourceRoot":"","sources":["../../src/decorators/module.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAiChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,EAAE,EACZ,eAAe,GAAG,EAAE,EACpB,oBAAoB,GAAG,EAAE,EACzB,uBAAuB,GAAG,EAAE,EAC5B,cAAc,GAAG,EAAE,EACnB,mBAAmB,GAAG,EAAE,EACxB,sBAAsB,GAAG,EAAE,MACT,EAAE;IACpB,OAAO,UAAU,WAA4C;QAC3D,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;aAC3B,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YACxB,kDAAkD;YAClD,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,CAAC,IAAI,+BAA+B,CAAC,CAAC;YAC7E,CAAC;YAED,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE;gBACpC,IAAI;gBACJ,OAAO;gBACP,eAAe;gBACf,oBAAoB;gBACpB,uBAAuB;gBACvB,cAAc;gBACd,mBAAmB;gBACnB,sBAAsB;aACvB,CAAC,CAAC;QACL,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"module.decorator.js","sourceRoot":"","sources":["../../src/decorators/module.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,MAAM,CAAI,WAAmB,EAAE,MAAsC;IACnF,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,UAAU,WAAgB;QAC/B,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,2BAA2B,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,YAAY,OAAO,CAAC,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,CAAC,IAAI,kCAAkC,CAAC,CAAC;QAChF,CAAC;QAED,WAAW,CAAC,cAAc,GAAG,WAAW,CAAC;QACzC,WAAW,CAAC,aAAa,GAAG,MAAM,CAAC;QAEnC,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YACtE,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Constructable } from '../app.type.js';
2
- import type { Event } from '../events/event.model.js';
2
+ import type { Event } from '../events/index.js';
3
3
  /**
4
4
  * An `@OnEvent` is a method decorator to listen to an event.
5
5
  *
@@ -17,7 +17,7 @@ import { EventService } from '../services/event/event.service.js';
17
17
  * @returns The decorated method.
18
18
  */
19
19
  export function OnEvent(ofType) {
20
- return function (target, propertyKey, descriptor) {
20
+ return function (target, _propertyKey, descriptor) {
21
21
  EventService.getInstance().registerListeners(ofType, target, descriptor);
22
22
  };
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"on-event.decorator.js","sourceRoot":"","sources":["../../src/decorators/on-event.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,OAAO,CACrB,MAAqC;IAErC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,YAAY,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"on-event.decorator.js","sourceRoot":"","sources":["../../src/decorators/on-event.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,OAAO,CACrB,MAAqC;IAErC,OAAO,UAAU,MAAW,EAAE,YAAoB,EAAE,UAA8B;QAChF,YAAY,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC"}
@@ -1,14 +1,24 @@
1
+ import { type Constructable, type OverlaySchema, type UnknownOverlay } from '../app.type.js';
1
2
  /**
2
- * An `@Overlay` is a class decorator to be placed on top of a class that represents an overlay.
3
- * - An overlay must extend the {@link AOverlay} class.
3
+ * An `@Overlay` is a class decorator and must be placed on top of a class representing an overlay.
4
+ * - An overlay must also extend the {@link AOverlay} class.
5
+ * - For type safety, the type of overlay being decorated is passed to the decorator.
4
6
  *
5
7
  * @example
6
8
  * ```ts
7
- * @Overlay()
8
- * export class MyOverlay extends AOverlay<MyOverlay> { ... }
9
+ * @Overlay<MyOverlay>('@example', 'my-name', MyOverlaySchema)
10
+ * export class MyOverlay extends AOverlay<MyOverlaySchema, MyOverlay> { ... }
9
11
  * ```
10
12
  * @group Decorators
13
+ *
14
+ * @param packageName - The name of the package under which the overlay is registered.
15
+ * Selecting a unique package name helps avoid collisions between same overlay class names across different libraries.
16
+ * You will reuse the same package name throughout your library for different Octo components you create.
17
+ * @param overlayName - a string that uniquely represents the name of the overlay.
18
+ * @param schema - The schema of the overlay.
19
+ *
11
20
  * @returns The decorated class.
12
- * @see Definition of [Overlays](/docs/fundamentals/overlay-and-anchor).
21
+ *
22
+ * @see Definition of [Overlays](/docs/fundamentals/overlays).
13
23
  */
14
- export declare function Overlay(): (constructor: any) => void;
24
+ export declare function Overlay<T extends UnknownOverlay>(packageName: string, overlayName: string, schema: Constructable<OverlaySchema<T>>): (constructor: any) => void;
@@ -1,29 +1,50 @@
1
- import { RegistrationErrorEvent } from '../events/error.event.js';
2
- import { EventService } from '../services/event/event.service.js';
3
- import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
1
+ import { NodeType } from '../app.type.js';
4
2
  import { Container } from '../functions/container/container.js';
3
+ import { AOverlay } from '../overlays/overlay.abstract.js';
4
+ import { ModelSerializationService } from '../services/serialization/model/model-serialization.service.js';
5
+ import { ValidationUtility } from '../utilities/validation/validation.utility.js';
5
6
  /**
6
- * An `@Overlay` is a class decorator to be placed on top of a class that represents an overlay.
7
- * - An overlay must extend the {@link AOverlay} class.
7
+ * An `@Overlay` is a class decorator and must be placed on top of a class representing an overlay.
8
+ * - An overlay must also extend the {@link AOverlay} class.
9
+ * - For type safety, the type of overlay being decorated is passed to the decorator.
8
10
  *
9
11
  * @example
10
12
  * ```ts
11
- * @Overlay()
12
- * export class MyOverlay extends AOverlay<MyOverlay> { ... }
13
+ * @Overlay<MyOverlay>('@example', 'my-name', MyOverlaySchema)
14
+ * export class MyOverlay extends AOverlay<MyOverlaySchema, MyOverlay> { ... }
13
15
  * ```
14
16
  * @group Decorators
17
+ *
18
+ * @param packageName - The name of the package under which the overlay is registered.
19
+ * Selecting a unique package name helps avoid collisions between same overlay class names across different libraries.
20
+ * You will reuse the same package name throughout your library for different Octo components you create.
21
+ * @param overlayName - a string that uniquely represents the name of the overlay.
22
+ * @param schema - The schema of the overlay.
23
+ *
15
24
  * @returns The decorated class.
16
- * @see Definition of [Overlays](/docs/fundamentals/overlay-and-anchor).
25
+ *
26
+ * @see Definition of [Overlays](/docs/fundamentals/overlays).
17
27
  */
18
- export function Overlay() {
28
+ export function Overlay(packageName, overlayName, schema) {
29
+ const container = Container.getInstance();
19
30
  return function (constructor) {
20
- Container.get(ModelSerializationService)
21
- .then((modelSerializationService) => {
22
- modelSerializationService.registerClass(constructor.name, constructor);
23
- })
24
- .catch((error) => {
25
- EventService.getInstance().emit(new RegistrationErrorEvent(error));
31
+ if (!ValidationUtility.validateRegex(packageName, /^[@A-Za-z][\w-]+[A-Za-z]$/)) {
32
+ throw new Error(`Invalid package name: ${packageName}`);
33
+ }
34
+ if (!ValidationUtility.validateRegex(overlayName, /^[A-Za-z][\w-]+[A-Za-z]$/)) {
35
+ throw new Error(`Invalid overlay name: ${overlayName}`);
36
+ }
37
+ if (!(constructor.prototype instanceof AOverlay)) {
38
+ throw new Error(`Class "${constructor.name}" must extend the AOverlay class!`);
39
+ }
40
+ constructor.NODE_NAME = overlayName;
41
+ constructor.NODE_PACKAGE = packageName;
42
+ constructor.NODE_SCHEMA = schema;
43
+ constructor.NODE_TYPE = NodeType.OVERLAY;
44
+ const promise = container.get(ModelSerializationService).then((modelSerializationService) => {
45
+ modelSerializationService.registerClass(`${packageName}/${constructor.name}`, constructor);
26
46
  });
47
+ container.registerStartupUnhandledPromise(promise);
27
48
  };
28
49
  }
29
50
  //# sourceMappingURL=overlay.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.decorator.js","sourceRoot":"","sources":["../../src/decorators/overlay.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,OAAO;IACrB,OAAO,UAAU,WAAgB;QAC/B,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC;aACrC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAClC,yBAAyB,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"overlay.decorator.js","sourceRoot":"","sources":["../../src/decorators/overlay.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAA2C,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,OAAO,CACrB,WAAmB,EACnB,WAAmB,EACnB,MAAuC;IAEvC,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAE1C,OAAO,UAAU,WAAgB;QAC/B,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,2BAA2B,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,0BAA0B,CAAC,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,CAAC,WAAW,CAAC,SAAS,YAAY,QAAQ,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,CAAC,IAAI,mCAAmC,CAAC,CAAC;QACjF,CAAC;QAED,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC;QACpC,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC;QACvC,WAAW,CAAC,WAAW,GAAG,MAAM,CAAC;QACjC,WAAW,CAAC,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC;QAEzC,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;YAC1F,yBAAyB,CAAC,aAAa,CAAC,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC"}