@endora-commerce/platform 0.100.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 (657) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/cli/dispatch.d.ts +146 -0
  4. package/dist/cli/dispatch.d.ts.map +1 -0
  5. package/dist/cli/dispatch.js +259 -0
  6. package/dist/cli/dispatch.js.map +1 -0
  7. package/dist/cli/index.d.ts +58 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +58 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/cli/module-commands.d.ts +118 -0
  12. package/dist/cli/module-commands.d.ts.map +1 -0
  13. package/dist/cli/module-commands.js +120 -0
  14. package/dist/cli/module-commands.js.map +1 -0
  15. package/dist/commands/actor.d.ts +19 -0
  16. package/dist/commands/actor.d.ts.map +1 -0
  17. package/dist/commands/actor.js +45 -0
  18. package/dist/commands/actor.js.map +1 -0
  19. package/dist/commands/audit-from-context.d.ts +24 -0
  20. package/dist/commands/audit-from-context.d.ts.map +1 -0
  21. package/dist/commands/audit-from-context.js +28 -0
  22. package/dist/commands/audit-from-context.js.map +1 -0
  23. package/dist/commands/command-bus.d.ts +40 -0
  24. package/dist/commands/command-bus.d.ts.map +1 -0
  25. package/dist/commands/command-bus.js +46 -0
  26. package/dist/commands/command-bus.js.map +1 -0
  27. package/dist/commands/command.d.ts +76 -0
  28. package/dist/commands/command.d.ts.map +1 -0
  29. package/dist/commands/command.js +2 -0
  30. package/dist/commands/command.js.map +1 -0
  31. package/dist/commands/index.d.ts +65 -0
  32. package/dist/commands/index.d.ts.map +1 -0
  33. package/dist/commands/index.js +57 -0
  34. package/dist/commands/index.js.map +1 -0
  35. package/dist/commands/reversible.d.ts +66 -0
  36. package/dist/commands/reversible.d.ts.map +1 -0
  37. package/dist/commands/reversible.js +41 -0
  38. package/dist/commands/reversible.js.map +1 -0
  39. package/dist/composition/compose-app.d.ts +305 -0
  40. package/dist/composition/compose-app.d.ts.map +1 -0
  41. package/dist/composition/compose-app.js +939 -0
  42. package/dist/composition/compose-app.js.map +1 -0
  43. package/dist/composition/index.d.ts +92 -0
  44. package/dist/composition/index.d.ts.map +1 -0
  45. package/dist/composition/index.js +175 -0
  46. package/dist/composition/index.js.map +1 -0
  47. package/dist/composition/newsletter-token-secret.d.ts +19 -0
  48. package/dist/composition/newsletter-token-secret.d.ts.map +1 -0
  49. package/dist/composition/newsletter-token-secret.js +24 -0
  50. package/dist/composition/newsletter-token-secret.js.map +1 -0
  51. package/dist/composition/process-runs-workers.d.ts +17 -0
  52. package/dist/composition/process-runs-workers.d.ts.map +1 -0
  53. package/dist/composition/process-runs-workers.js +19 -0
  54. package/dist/composition/process-runs-workers.js.map +1 -0
  55. package/dist/db/baseline-migration-inventory.d.ts +15 -0
  56. package/dist/db/baseline-migration-inventory.d.ts.map +1 -0
  57. package/dist/db/baseline-migration-inventory.js +115 -0
  58. package/dist/db/baseline-migration-inventory.js.map +1 -0
  59. package/dist/db/configured-entities.d.ts +74 -0
  60. package/dist/db/configured-entities.d.ts.map +1 -0
  61. package/dist/db/configured-entities.js +20 -0
  62. package/dist/db/configured-entities.js.map +1 -0
  63. package/dist/db/configured-migrations.d.ts +199 -0
  64. package/dist/db/configured-migrations.d.ts.map +1 -0
  65. package/dist/db/configured-migrations.js +181 -0
  66. package/dist/db/configured-migrations.js.map +1 -0
  67. package/dist/db/index.d.ts +54 -0
  68. package/dist/db/index.d.ts.map +1 -0
  69. package/dist/db/index.js +54 -0
  70. package/dist/db/index.js.map +1 -0
  71. package/dist/db/migrate.d.ts +21 -0
  72. package/dist/db/migrate.d.ts.map +1 -0
  73. package/dist/db/migrate.js +48 -0
  74. package/dist/db/migrate.js.map +1 -0
  75. package/dist/db/migration-order.d.ts +159 -0
  76. package/dist/db/migration-order.d.ts.map +1 -0
  77. package/dist/db/migration-order.js +273 -0
  78. package/dist/db/migration-order.js.map +1 -0
  79. package/dist/db/mikro-orm.config.d.ts +51 -0
  80. package/dist/db/mikro-orm.config.d.ts.map +1 -0
  81. package/dist/db/mikro-orm.config.js +64 -0
  82. package/dist/db/mikro-orm.config.js.map +1 -0
  83. package/dist/db/orm.d.ts +40 -0
  84. package/dist/db/orm.d.ts.map +1 -0
  85. package/dist/db/orm.js +25 -0
  86. package/dist/db/orm.js.map +1 -0
  87. package/dist/db/platform-schema.d.ts +102 -0
  88. package/dist/db/platform-schema.d.ts.map +1 -0
  89. package/dist/db/platform-schema.js +79 -0
  90. package/dist/db/platform-schema.js.map +1 -0
  91. package/dist/db/pluralizing-naming-strategy.d.ts +16 -0
  92. package/dist/db/pluralizing-naming-strategy.d.ts.map +1 -0
  93. package/dist/db/pluralizing-naming-strategy.js +66 -0
  94. package/dist/db/pluralizing-naming-strategy.js.map +1 -0
  95. package/dist/demo/guard.d.ts +101 -0
  96. package/dist/demo/guard.d.ts.map +1 -0
  97. package/dist/demo/guard.js +168 -0
  98. package/dist/demo/guard.js.map +1 -0
  99. package/dist/demo/host-command.d.ts +133 -0
  100. package/dist/demo/host-command.d.ts.map +1 -0
  101. package/dist/demo/host-command.js +113 -0
  102. package/dist/demo/host-command.js.map +1 -0
  103. package/dist/demo/index.d.ts +82 -0
  104. package/dist/demo/index.d.ts.map +1 -0
  105. package/dist/demo/index.js +82 -0
  106. package/dist/demo/index.js.map +1 -0
  107. package/dist/demo/packages.d.ts +67 -0
  108. package/dist/demo/packages.d.ts.map +1 -0
  109. package/dist/demo/packages.js +132 -0
  110. package/dist/demo/packages.js.map +1 -0
  111. package/dist/demo/plan.d.ts +111 -0
  112. package/dist/demo/plan.d.ts.map +1 -0
  113. package/dist/demo/plan.js +74 -0
  114. package/dist/demo/plan.js.map +1 -0
  115. package/dist/demo/report.d.ts +17 -0
  116. package/dist/demo/report.d.ts.map +1 -0
  117. package/dist/demo/report.js +85 -0
  118. package/dist/demo/report.js.map +1 -0
  119. package/dist/demo/runner.d.ts +207 -0
  120. package/dist/demo/runner.d.ts.map +1 -0
  121. package/dist/demo/runner.js +169 -0
  122. package/dist/demo/runner.js.map +1 -0
  123. package/dist/demo/scope.d.ts +44 -0
  124. package/dist/demo/scope.d.ts.map +1 -0
  125. package/dist/demo/scope.js +44 -0
  126. package/dist/demo/scope.js.map +1 -0
  127. package/dist/env/index.d.ts +68 -0
  128. package/dist/env/index.d.ts.map +1 -0
  129. package/dist/env/index.js +427 -0
  130. package/dist/env/index.js.map +1 -0
  131. package/dist/events/bus.d.ts +29 -0
  132. package/dist/events/bus.d.ts.map +1 -0
  133. package/dist/events/bus.js +67 -0
  134. package/dist/events/bus.js.map +1 -0
  135. package/dist/events/index.d.ts +19 -0
  136. package/dist/events/index.d.ts.map +1 -0
  137. package/dist/events/index.js +19 -0
  138. package/dist/events/index.js.map +1 -0
  139. package/dist/http/cursor.d.ts +10 -0
  140. package/dist/http/cursor.d.ts.map +1 -0
  141. package/dist/http/cursor.js +20 -0
  142. package/dist/http/cursor.js.map +1 -0
  143. package/dist/http/error-envelope.d.ts +127 -0
  144. package/dist/http/error-envelope.d.ts.map +1 -0
  145. package/dist/http/error-envelope.js +402 -0
  146. package/dist/http/error-envelope.js.map +1 -0
  147. package/dist/http/health.d.ts +88 -0
  148. package/dist/http/health.d.ts.map +1 -0
  149. package/dist/http/health.js +77 -0
  150. package/dist/http/health.js.map +1 -0
  151. package/dist/http/index.d.ts +50 -0
  152. package/dist/http/index.d.ts.map +1 -0
  153. package/dist/http/index.js +50 -0
  154. package/dist/http/index.js.map +1 -0
  155. package/dist/http/interceptors/dispatch.d.ts +14 -0
  156. package/dist/http/interceptors/dispatch.d.ts.map +1 -0
  157. package/dist/http/interceptors/dispatch.js +113 -0
  158. package/dist/http/interceptors/dispatch.js.map +1 -0
  159. package/dist/http/interceptors/index.d.ts +6 -0
  160. package/dist/http/interceptors/index.d.ts.map +1 -0
  161. package/dist/http/interceptors/index.js +5 -0
  162. package/dist/http/interceptors/index.js.map +1 -0
  163. package/dist/http/interceptors/registry.d.ts +44 -0
  164. package/dist/http/interceptors/registry.d.ts.map +1 -0
  165. package/dist/http/interceptors/registry.js +123 -0
  166. package/dist/http/interceptors/registry.js.map +1 -0
  167. package/dist/http/interceptors/route-table.d.ts +33 -0
  168. package/dist/http/interceptors/route-table.d.ts.map +1 -0
  169. package/dist/http/interceptors/route-table.js +39 -0
  170. package/dist/http/interceptors/route-table.js.map +1 -0
  171. package/dist/http/interceptors/types.d.ts +101 -0
  172. package/dist/http/interceptors/types.d.ts.map +1 -0
  173. package/dist/http/interceptors/types.js +2 -0
  174. package/dist/http/interceptors/types.js.map +1 -0
  175. package/dist/http/interceptors/validation.d.ts +22 -0
  176. package/dist/http/interceptors/validation.d.ts.map +1 -0
  177. package/dist/http/interceptors/validation.js +39 -0
  178. package/dist/http/interceptors/validation.js.map +1 -0
  179. package/dist/http/logger.d.ts +9 -0
  180. package/dist/http/logger.d.ts.map +1 -0
  181. package/dist/http/logger.js +25 -0
  182. package/dist/http/logger.js.map +1 -0
  183. package/dist/http/openapi.d.ts +21 -0
  184. package/dist/http/openapi.d.ts.map +1 -0
  185. package/dist/http/openapi.js +114 -0
  186. package/dist/http/openapi.js.map +1 -0
  187. package/dist/http/product-audience.d.ts +78 -0
  188. package/dist/http/product-audience.d.ts.map +1 -0
  189. package/dist/http/product-audience.js +92 -0
  190. package/dist/http/product-audience.js.map +1 -0
  191. package/dist/http/request-actor.d.ts +82 -0
  192. package/dist/http/request-actor.d.ts.map +1 -0
  193. package/dist/http/request-actor.js +2 -0
  194. package/dist/http/request-actor.js.map +1 -0
  195. package/dist/http/server.d.ts +60 -0
  196. package/dist/http/server.d.ts.map +1 -0
  197. package/dist/http/server.js +117 -0
  198. package/dist/http/server.js.map +1 -0
  199. package/dist/http/storefront-revalidator.d.ts +29 -0
  200. package/dist/http/storefront-revalidator.d.ts.map +1 -0
  201. package/dist/http/storefront-revalidator.js +34 -0
  202. package/dist/http/storefront-revalidator.js.map +1 -0
  203. package/dist/http/test-actor-carrier.d.ts +28 -0
  204. package/dist/http/test-actor-carrier.d.ts.map +1 -0
  205. package/dist/http/test-actor-carrier.js +10 -0
  206. package/dist/http/test-actor-carrier.js.map +1 -0
  207. package/dist/http/trusted-proxy.d.ts +48 -0
  208. package/dist/http/trusted-proxy.d.ts.map +1 -0
  209. package/dist/http/trusted-proxy.js +136 -0
  210. package/dist/http/trusted-proxy.js.map +1 -0
  211. package/dist/kernel/audit/audit-log-entry.entity.d.ts +33 -0
  212. package/dist/kernel/audit/audit-log-entry.entity.d.ts.map +1 -0
  213. package/dist/kernel/audit/audit-log-entry.entity.js +102 -0
  214. package/dist/kernel/audit/audit-log-entry.entity.js.map +1 -0
  215. package/dist/kernel/audit/audit-log-service.d.ts +63 -0
  216. package/dist/kernel/audit/audit-log-service.d.ts.map +1 -0
  217. package/dist/kernel/audit/audit-log-service.js +107 -0
  218. package/dist/kernel/audit/audit-log-service.js.map +1 -0
  219. package/dist/kernel/cache/in-process-cache-registry.d.ts +93 -0
  220. package/dist/kernel/cache/in-process-cache-registry.d.ts.map +1 -0
  221. package/dist/kernel/cache/in-process-cache-registry.js +78 -0
  222. package/dist/kernel/cache/in-process-cache-registry.js.map +1 -0
  223. package/dist/kernel/cache/shared-drop-marks.d.ts +39 -0
  224. package/dist/kernel/cache/shared-drop-marks.d.ts.map +1 -0
  225. package/dist/kernel/cache/shared-drop-marks.js +68 -0
  226. package/dist/kernel/cache/shared-drop-marks.js.map +1 -0
  227. package/dist/kernel/compose.d.ts +234 -0
  228. package/dist/kernel/compose.d.ts.map +1 -0
  229. package/dist/kernel/compose.js +279 -0
  230. package/dist/kernel/compose.js.map +1 -0
  231. package/dist/kernel/container.d.ts +95 -0
  232. package/dist/kernel/container.d.ts.map +1 -0
  233. package/dist/kernel/container.js +90 -0
  234. package/dist/kernel/container.js.map +1 -0
  235. package/dist/kernel/contribution-sinks.d.ts +106 -0
  236. package/dist/kernel/contribution-sinks.d.ts.map +1 -0
  237. package/dist/kernel/contribution-sinks.js +153 -0
  238. package/dist/kernel/contribution-sinks.js.map +1 -0
  239. package/dist/kernel/crypto/password-hasher.d.ts +3 -0
  240. package/dist/kernel/crypto/password-hasher.d.ts.map +1 -0
  241. package/dist/kernel/crypto/password-hasher.js +44 -0
  242. package/dist/kernel/crypto/password-hasher.js.map +1 -0
  243. package/dist/kernel/i18n/error-envelope-options.d.ts +56 -0
  244. package/dist/kernel/i18n/error-envelope-options.d.ts.map +1 -0
  245. package/dist/kernel/i18n/error-envelope-options.js +46 -0
  246. package/dist/kernel/i18n/error-envelope-options.js.map +1 -0
  247. package/dist/kernel/i18n/error-translation.d.ts +144 -0
  248. package/dist/kernel/i18n/error-translation.d.ts.map +1 -0
  249. package/dist/kernel/i18n/error-translation.js +84 -0
  250. package/dist/kernel/i18n/error-translation.js.map +1 -0
  251. package/dist/kernel/i18n/request-language.d.ts +80 -0
  252. package/dist/kernel/i18n/request-language.d.ts.map +1 -0
  253. package/dist/kernel/i18n/request-language.js +168 -0
  254. package/dist/kernel/i18n/request-language.js.map +1 -0
  255. package/dist/kernel/index.d.ts +142 -0
  256. package/dist/kernel/index.d.ts.map +1 -0
  257. package/dist/kernel/index.js +160 -0
  258. package/dist/kernel/index.js.map +1 -0
  259. package/dist/kernel/lazy-port.d.ts +59 -0
  260. package/dist/kernel/lazy-port.d.ts.map +1 -0
  261. package/dist/kernel/lazy-port.js +78 -0
  262. package/dist/kernel/lazy-port.js.map +1 -0
  263. package/dist/kernel/lifecycle/activation-resolver.d.ts +63 -0
  264. package/dist/kernel/lifecycle/activation-resolver.d.ts.map +1 -0
  265. package/dist/kernel/lifecycle/activation-resolver.js +70 -0
  266. package/dist/kernel/lifecycle/activation-resolver.js.map +1 -0
  267. package/dist/kernel/lifecycle/capability-registry.d.ts +145 -0
  268. package/dist/kernel/lifecycle/capability-registry.d.ts.map +1 -0
  269. package/dist/kernel/lifecycle/capability-registry.js +170 -0
  270. package/dist/kernel/lifecycle/capability-registry.js.map +1 -0
  271. package/dist/kernel/lifecycle/effective-state.d.ts +126 -0
  272. package/dist/kernel/lifecycle/effective-state.d.ts.map +1 -0
  273. package/dist/kernel/lifecycle/effective-state.js +111 -0
  274. package/dist/kernel/lifecycle/effective-state.js.map +1 -0
  275. package/dist/kernel/lifecycle/module-registration.entity.d.ts +57 -0
  276. package/dist/kernel/lifecycle/module-registration.entity.d.ts.map +1 -0
  277. package/dist/kernel/lifecycle/module-registration.entity.js +111 -0
  278. package/dist/kernel/lifecycle/module-registration.entity.js.map +1 -0
  279. package/dist/kernel/lifecycle/plugin-helpers.d.ts +165 -0
  280. package/dist/kernel/lifecycle/plugin-helpers.d.ts.map +1 -0
  281. package/dist/kernel/lifecycle/plugin-helpers.js +395 -0
  282. package/dist/kernel/lifecycle/plugin-helpers.js.map +1 -0
  283. package/dist/kernel/lifecycle/registry-cache.d.ts +318 -0
  284. package/dist/kernel/lifecycle/registry-cache.d.ts.map +1 -0
  285. package/dist/kernel/lifecycle/registry-cache.js +509 -0
  286. package/dist/kernel/lifecycle/registry-cache.js.map +1 -0
  287. package/dist/kernel/lifecycle/required-modules.d.ts +137 -0
  288. package/dist/kernel/lifecycle/required-modules.d.ts.map +1 -0
  289. package/dist/kernel/lifecycle/required-modules.js +80 -0
  290. package/dist/kernel/lifecycle/required-modules.js.map +1 -0
  291. package/dist/kernel/lifecycle/unique-module-ids.d.ts +58 -0
  292. package/dist/kernel/lifecycle/unique-module-ids.d.ts.map +1 -0
  293. package/dist/kernel/lifecycle/unique-module-ids.js +82 -0
  294. package/dist/kernel/lifecycle/unique-module-ids.js.map +1 -0
  295. package/dist/kernel/logging.d.ts +116 -0
  296. package/dist/kernel/logging.d.ts.map +1 -0
  297. package/dist/kernel/logging.js +71 -0
  298. package/dist/kernel/logging.js.map +1 -0
  299. package/dist/kernel/module-context.d.ts +563 -0
  300. package/dist/kernel/module-context.d.ts.map +1 -0
  301. package/dist/kernel/module-context.js +670 -0
  302. package/dist/kernel/module-context.js.map +1 -0
  303. package/dist/kernel/ports/audit.d.ts +115 -0
  304. package/dist/kernel/ports/audit.d.ts.map +1 -0
  305. package/dist/kernel/ports/audit.js +2 -0
  306. package/dist/kernel/ports/audit.js.map +1 -0
  307. package/dist/kernel/ports/organizations.d.ts +56 -0
  308. package/dist/kernel/ports/organizations.d.ts.map +1 -0
  309. package/dist/kernel/ports/organizations.js +2 -0
  310. package/dist/kernel/ports/organizations.js.map +1 -0
  311. package/dist/kernel/ports/provide.d.ts +14 -0
  312. package/dist/kernel/ports/provide.d.ts.map +1 -0
  313. package/dist/kernel/ports/provide.js +50 -0
  314. package/dist/kernel/ports/provide.js.map +1 -0
  315. package/dist/kernel/ports/require-admin.d.ts +61 -0
  316. package/dist/kernel/ports/require-admin.d.ts.map +1 -0
  317. package/dist/kernel/ports/require-admin.js +2 -0
  318. package/dist/kernel/ports/require-admin.js.map +1 -0
  319. package/dist/kernel/ports/require-customer.d.ts +17 -0
  320. package/dist/kernel/ports/require-customer.d.ts.map +1 -0
  321. package/dist/kernel/ports/require-customer.js +2 -0
  322. package/dist/kernel/ports/require-customer.js.map +1 -0
  323. package/dist/kernel/ports/sales-channel.d.ts +84 -0
  324. package/dist/kernel/ports/sales-channel.d.ts.map +1 -0
  325. package/dist/kernel/ports/sales-channel.js +2 -0
  326. package/dist/kernel/ports/sales-channel.js.map +1 -0
  327. package/dist/kernel/ports/settings.d.ts +59 -0
  328. package/dist/kernel/ports/settings.d.ts.map +1 -0
  329. package/dist/kernel/ports/settings.js +2 -0
  330. package/dist/kernel/ports/settings.js.map +1 -0
  331. package/dist/kernel/public-api-base-url.d.ts +98 -0
  332. package/dist/kernel/public-api-base-url.d.ts.map +1 -0
  333. package/dist/kernel/public-api-base-url.js +144 -0
  334. package/dist/kernel/public-api-base-url.js.map +1 -0
  335. package/dist/kernel/request-scope-hook.d.ts +63 -0
  336. package/dist/kernel/request-scope-hook.d.ts.map +1 -0
  337. package/dist/kernel/request-scope-hook.js +67 -0
  338. package/dist/kernel/request-scope-hook.js.map +1 -0
  339. package/dist/kernel/sales-channels/channel-bridge-registry.d.ts +109 -0
  340. package/dist/kernel/sales-channels/channel-bridge-registry.d.ts.map +1 -0
  341. package/dist/kernel/sales-channels/channel-bridge-registry.js +75 -0
  342. package/dist/kernel/sales-channels/channel-bridge-registry.js.map +1 -0
  343. package/dist/kernel/sales-channels/compose.d.ts +69 -0
  344. package/dist/kernel/sales-channels/compose.d.ts.map +1 -0
  345. package/dist/kernel/sales-channels/compose.js +43 -0
  346. package/dist/kernel/sales-channels/compose.js.map +1 -0
  347. package/dist/kernel/sales-channels/default-channel-reconciler.d.ts +66 -0
  348. package/dist/kernel/sales-channels/default-channel-reconciler.d.ts.map +1 -0
  349. package/dist/kernel/sales-channels/default-channel-reconciler.js +91 -0
  350. package/dist/kernel/sales-channels/default-channel-reconciler.js.map +1 -0
  351. package/dist/kernel/sales-channels/no-system-default-channel.error.d.ts +28 -0
  352. package/dist/kernel/sales-channels/no-system-default-channel.error.d.ts.map +1 -0
  353. package/dist/kernel/sales-channels/no-system-default-channel.error.js +33 -0
  354. package/dist/kernel/sales-channels/no-system-default-channel.error.js.map +1 -0
  355. package/dist/kernel/sales-channels/request-channel-assortment.d.ts +72 -0
  356. package/dist/kernel/sales-channels/request-channel-assortment.d.ts.map +1 -0
  357. package/dist/kernel/sales-channels/request-channel-assortment.js +83 -0
  358. package/dist/kernel/sales-channels/request-channel-assortment.js.map +1 -0
  359. package/dist/kernel/sales-channels/sales-channel-membership.service.d.ts +157 -0
  360. package/dist/kernel/sales-channels/sales-channel-membership.service.d.ts.map +1 -0
  361. package/dist/kernel/sales-channels/sales-channel-membership.service.js +302 -0
  362. package/dist/kernel/sales-channels/sales-channel-membership.service.js.map +1 -0
  363. package/dist/kernel/sales-channels/sales-channel-resolver.middleware.d.ts +76 -0
  364. package/dist/kernel/sales-channels/sales-channel-resolver.middleware.d.ts.map +1 -0
  365. package/dist/kernel/sales-channels/sales-channel-resolver.middleware.js +184 -0
  366. package/dist/kernel/sales-channels/sales-channel-resolver.middleware.js.map +1 -0
  367. package/dist/kernel/sales-channels/sales-channel-resolver.service.d.ts +82 -0
  368. package/dist/kernel/sales-channels/sales-channel-resolver.service.d.ts.map +1 -0
  369. package/dist/kernel/sales-channels/sales-channel-resolver.service.js +126 -0
  370. package/dist/kernel/sales-channels/sales-channel-resolver.service.js.map +1 -0
  371. package/dist/kernel/sales-channels/sales-channel.entity.d.ts +50 -0
  372. package/dist/kernel/sales-channels/sales-channel.entity.d.ts.map +1 -0
  373. package/dist/kernel/sales-channels/sales-channel.entity.js +132 -0
  374. package/dist/kernel/sales-channels/sales-channel.entity.js.map +1 -0
  375. package/dist/kernel/sales-channels/sales-channels-cache.d.ts +170 -0
  376. package/dist/kernel/sales-channels/sales-channels-cache.d.ts.map +1 -0
  377. package/dist/kernel/sales-channels/sales-channels-cache.js +243 -0
  378. package/dist/kernel/sales-channels/sales-channels-cache.js.map +1 -0
  379. package/dist/kernel/scope.d.ts +153 -0
  380. package/dist/kernel/scope.d.ts.map +1 -0
  381. package/dist/kernel/scope.js +172 -0
  382. package/dist/kernel/scope.js.map +1 -0
  383. package/dist/kernel/settings/compose.d.ts +49 -0
  384. package/dist/kernel/settings/compose.d.ts.map +1 -0
  385. package/dist/kernel/settings/compose.js +21 -0
  386. package/dist/kernel/settings/compose.js.map +1 -0
  387. package/dist/kernel/settings/manifest-reconciler.d.ts +78 -0
  388. package/dist/kernel/settings/manifest-reconciler.d.ts.map +1 -0
  389. package/dist/kernel/settings/manifest-reconciler.js +343 -0
  390. package/dist/kernel/settings/manifest-reconciler.js.map +1 -0
  391. package/dist/kernel/settings/secret-value-codec.d.ts +52 -0
  392. package/dist/kernel/settings/secret-value-codec.d.ts.map +1 -0
  393. package/dist/kernel/settings/secret-value-codec.js +102 -0
  394. package/dist/kernel/settings/secret-value-codec.js.map +1 -0
  395. package/dist/kernel/settings/setting-group.entity.d.ts +25 -0
  396. package/dist/kernel/settings/setting-group.entity.d.ts.map +1 -0
  397. package/dist/kernel/settings/setting-group.entity.js +79 -0
  398. package/dist/kernel/settings/setting-group.entity.js.map +1 -0
  399. package/dist/kernel/settings/setting-value.entity.d.ts +23 -0
  400. package/dist/kernel/settings/setting-value.entity.d.ts.map +1 -0
  401. package/dist/kernel/settings/setting-value.entity.js +66 -0
  402. package/dist/kernel/settings/setting-value.entity.js.map +1 -0
  403. package/dist/kernel/settings/setting.entity.d.ts +56 -0
  404. package/dist/kernel/settings/setting.entity.d.ts.map +1 -0
  405. package/dist/kernel/settings/setting.entity.js +147 -0
  406. package/dist/kernel/settings/setting.entity.js.map +1 -0
  407. package/dist/kernel/settings/settings-cache.d.ts +158 -0
  408. package/dist/kernel/settings/settings-cache.d.ts.map +1 -0
  409. package/dist/kernel/settings/settings-cache.js +253 -0
  410. package/dist/kernel/settings/settings-cache.js.map +1 -0
  411. package/dist/kernel/settings/settings.service.d.ts +142 -0
  412. package/dist/kernel/settings/settings.service.d.ts.map +1 -0
  413. package/dist/kernel/settings/settings.service.js +294 -0
  414. package/dist/kernel/settings/settings.service.js.map +1 -0
  415. package/dist/lifecycle/backend.d.ts +51 -0
  416. package/dist/lifecycle/backend.d.ts.map +1 -0
  417. package/dist/lifecycle/backend.js +40 -0
  418. package/dist/lifecycle/backend.js.map +1 -0
  419. package/dist/lifecycle/commands/activation.commands.d.ts +97 -0
  420. package/dist/lifecycle/commands/activation.commands.d.ts.map +1 -0
  421. package/dist/lifecycle/commands/activation.commands.js +142 -0
  422. package/dist/lifecycle/commands/activation.commands.js.map +1 -0
  423. package/dist/lifecycle/commands/disable.d.ts +3 -0
  424. package/dist/lifecycle/commands/disable.d.ts.map +1 -0
  425. package/dist/lifecycle/commands/disable.js +126 -0
  426. package/dist/lifecycle/commands/disable.js.map +1 -0
  427. package/dist/lifecycle/commands/enable.d.ts +3 -0
  428. package/dist/lifecycle/commands/enable.d.ts.map +1 -0
  429. package/dist/lifecycle/commands/enable.js +102 -0
  430. package/dist/lifecycle/commands/enable.js.map +1 -0
  431. package/dist/lifecycle/commands/install.d.ts +3 -0
  432. package/dist/lifecycle/commands/install.d.ts.map +1 -0
  433. package/dist/lifecycle/commands/install.js +263 -0
  434. package/dist/lifecycle/commands/install.js.map +1 -0
  435. package/dist/lifecycle/commands/operator-entry.d.ts +104 -0
  436. package/dist/lifecycle/commands/operator-entry.d.ts.map +1 -0
  437. package/dist/lifecycle/commands/operator-entry.js +127 -0
  438. package/dist/lifecycle/commands/operator-entry.js.map +1 -0
  439. package/dist/lifecycle/commands/operator-runtime.d.ts +147 -0
  440. package/dist/lifecycle/commands/operator-runtime.d.ts.map +1 -0
  441. package/dist/lifecycle/commands/operator-runtime.js +40 -0
  442. package/dist/lifecycle/commands/operator-runtime.js.map +1 -0
  443. package/dist/lifecycle/commands/status.d.ts +3 -0
  444. package/dist/lifecycle/commands/status.d.ts.map +1 -0
  445. package/dist/lifecycle/commands/status.js +108 -0
  446. package/dist/lifecycle/commands/status.js.map +1 -0
  447. package/dist/lifecycle/commands/uninstall.d.ts +3 -0
  448. package/dist/lifecycle/commands/uninstall.d.ts.map +1 -0
  449. package/dist/lifecycle/commands/uninstall.js +223 -0
  450. package/dist/lifecycle/commands/uninstall.js.map +1 -0
  451. package/dist/lifecycle/divergence-declaration.d.ts +74 -0
  452. package/dist/lifecycle/divergence-declaration.d.ts.map +1 -0
  453. package/dist/lifecycle/divergence-declaration.js +92 -0
  454. package/dist/lifecycle/divergence-declaration.js.map +1 -0
  455. package/dist/lifecycle/i18n/en.json +4 -0
  456. package/dist/lifecycle/i18n/pl.json +4 -0
  457. package/dist/lifecycle/index.d.ts +110 -0
  458. package/dist/lifecycle/index.d.ts.map +1 -0
  459. package/dist/lifecycle/index.js +189 -0
  460. package/dist/lifecycle/index.js.map +1 -0
  461. package/dist/lifecycle/manifest-registry.d.ts +244 -0
  462. package/dist/lifecycle/manifest-registry.d.ts.map +1 -0
  463. package/dist/lifecycle/manifest-registry.js +223 -0
  464. package/dist/lifecycle/manifest-registry.js.map +1 -0
  465. package/dist/lifecycle/manifest.d.ts +166 -0
  466. package/dist/lifecycle/manifest.d.ts.map +1 -0
  467. package/dist/lifecycle/manifest.js +121 -0
  468. package/dist/lifecycle/manifest.js.map +1 -0
  469. package/dist/lifecycle/plugin.d.ts +56 -0
  470. package/dist/lifecycle/plugin.d.ts.map +1 -0
  471. package/dist/lifecycle/plugin.js +59 -0
  472. package/dist/lifecycle/plugin.js.map +1 -0
  473. package/dist/lifecycle/resident.d.ts +16 -0
  474. package/dist/lifecycle/resident.d.ts.map +1 -0
  475. package/dist/lifecycle/resident.js +59 -0
  476. package/dist/lifecycle/resident.js.map +1 -0
  477. package/dist/lifecycle/routes.admin.d.ts +57 -0
  478. package/dist/lifecycle/routes.admin.d.ts.map +1 -0
  479. package/dist/lifecycle/routes.admin.js +162 -0
  480. package/dist/lifecycle/routes.admin.js.map +1 -0
  481. package/dist/lifecycle/routes.storefront.d.ts +26 -0
  482. package/dist/lifecycle/routes.storefront.d.ts.map +1 -0
  483. package/dist/lifecycle/routes.storefront.js +36 -0
  484. package/dist/lifecycle/routes.storefront.js.map +1 -0
  485. package/dist/lifecycle/services/deactivation-ledger.d.ts +216 -0
  486. package/dist/lifecycle/services/deactivation-ledger.d.ts.map +1 -0
  487. package/dist/lifecycle/services/deactivation-ledger.js +171 -0
  488. package/dist/lifecycle/services/deactivation-ledger.js.map +1 -0
  489. package/dist/lifecycle/services/dep-graph.d.ts +119 -0
  490. package/dist/lifecycle/services/dep-graph.d.ts.map +1 -0
  491. package/dist/lifecycle/services/dep-graph.js +334 -0
  492. package/dist/lifecycle/services/dep-graph.js.map +1 -0
  493. package/dist/lifecycle/services/gating-graph.d.ts +164 -0
  494. package/dist/lifecycle/services/gating-graph.d.ts.map +1 -0
  495. package/dist/lifecycle/services/gating-graph.js +203 -0
  496. package/dist/lifecycle/services/gating-graph.js.map +1 -0
  497. package/dist/lifecycle/services/lock.d.ts +27 -0
  498. package/dist/lifecycle/services/lock.d.ts.map +1 -0
  499. package/dist/lifecycle/services/lock.js +82 -0
  500. package/dist/lifecycle/services/lock.js.map +1 -0
  501. package/dist/lifecycle/services/manifest-loader.d.ts +125 -0
  502. package/dist/lifecycle/services/manifest-loader.d.ts.map +1 -0
  503. package/dist/lifecycle/services/manifest-loader.js +210 -0
  504. package/dist/lifecycle/services/manifest-loader.js.map +1 -0
  505. package/dist/lifecycle/services/migration-ownership.d.ts +36 -0
  506. package/dist/lifecycle/services/migration-ownership.d.ts.map +1 -0
  507. package/dist/lifecycle/services/migration-ownership.js +15 -0
  508. package/dist/lifecycle/services/migration-ownership.js.map +1 -0
  509. package/dist/lifecycle/services/module-id-claims.d.ts +38 -0
  510. package/dist/lifecycle/services/module-id-claims.d.ts.map +1 -0
  511. package/dist/lifecycle/services/module-id-claims.js +123 -0
  512. package/dist/lifecycle/services/module-id-claims.js.map +1 -0
  513. package/dist/lifecycle/services/module-origin.d.ts +55 -0
  514. package/dist/lifecycle/services/module-origin.d.ts.map +1 -0
  515. package/dist/lifecycle/services/module-origin.js +47 -0
  516. package/dist/lifecycle/services/module-origin.js.map +1 -0
  517. package/dist/lifecycle/services/orchestrator.d.ts +235 -0
  518. package/dist/lifecycle/services/orchestrator.d.ts.map +1 -0
  519. package/dist/lifecycle/services/orchestrator.js +954 -0
  520. package/dist/lifecycle/services/orchestrator.js.map +1 -0
  521. package/dist/lifecycle/services/presence-load.d.ts +281 -0
  522. package/dist/lifecycle/services/presence-load.d.ts.map +1 -0
  523. package/dist/lifecycle/services/presence-load.js +437 -0
  524. package/dist/lifecycle/services/presence-load.js.map +1 -0
  525. package/dist/lifecycle/services/static-registry.d.ts +47 -0
  526. package/dist/lifecycle/services/static-registry.d.ts.map +1 -0
  527. package/dist/lifecycle/services/static-registry.js +41 -0
  528. package/dist/lifecycle/services/static-registry.js.map +1 -0
  529. package/dist/migrations/20260424T165847_core_foundation_init.d.ts +25 -0
  530. package/dist/migrations/20260424T165847_core_foundation_init.d.ts.map +1 -0
  531. package/dist/migrations/20260424T165847_core_foundation_init.js +238 -0
  532. package/dist/migrations/20260424T165847_core_foundation_init.js.map +1 -0
  533. package/dist/migrations/20260425T050720_core_commerce_init.d.ts +19 -0
  534. package/dist/migrations/20260425T050720_core_commerce_init.d.ts.map +1 -0
  535. package/dist/migrations/20260425T050720_core_commerce_init.js +200 -0
  536. package/dist/migrations/20260425T050720_core_commerce_init.js.map +1 -0
  537. package/dist/migrations/20260430T101450_core_settings_init.d.ts +25 -0
  538. package/dist/migrations/20260430T101450_core_settings_init.d.ts.map +1 -0
  539. package/dist/migrations/20260430T101450_core_settings_init.js +113 -0
  540. package/dist/migrations/20260430T101450_core_settings_init.js.map +1 -0
  541. package/dist/migrations/20260430T170044_core_sales_channels_promote.d.ts +67 -0
  542. package/dist/migrations/20260430T170044_core_sales_channels_promote.d.ts.map +1 -0
  543. package/dist/migrations/20260430T170044_core_sales_channels_promote.js +101 -0
  544. package/dist/migrations/20260430T170044_core_sales_channels_promote.js.map +1 -0
  545. package/dist/migrations/20260506T200657_core_module_lifecycle_init.d.ts +21 -0
  546. package/dist/migrations/20260506T200657_core_module_lifecycle_init.d.ts.map +1 -0
  547. package/dist/migrations/20260506T200657_core_module_lifecycle_init.js +41 -0
  548. package/dist/migrations/20260506T200657_core_module_lifecycle_init.js.map +1 -0
  549. package/dist/migrations/20260514T111329_core_settings_global_value.d.ts +30 -0
  550. package/dist/migrations/20260514T111329_core_settings_global_value.d.ts.map +1 -0
  551. package/dist/migrations/20260514T111329_core_settings_global_value.js +34 -0
  552. package/dist/migrations/20260514T111329_core_settings_global_value.js.map +1 -0
  553. package/dist/migrations/20260611T140411_core_settings_secret_value_type.d.ts +26 -0
  554. package/dist/migrations/20260611T140411_core_settings_secret_value_type.d.ts.map +1 -0
  555. package/dist/migrations/20260611T140411_core_settings_secret_value_type.js +63 -0
  556. package/dist/migrations/20260611T140411_core_settings_secret_value_type.js.map +1 -0
  557. package/dist/migrations/20260611T140419_core_settings_enum_options.d.ts +19 -0
  558. package/dist/migrations/20260611T140419_core_settings_enum_options.d.ts.map +1 -0
  559. package/dist/migrations/20260611T140419_core_settings_enum_options.js +23 -0
  560. package/dist/migrations/20260611T140419_core_settings_enum_options.js.map +1 -0
  561. package/dist/migrations/20260629T090100_core_settings_hidden_flag.d.ts +20 -0
  562. package/dist/migrations/20260629T090100_core_settings_hidden_flag.d.ts.map +1 -0
  563. package/dist/migrations/20260629T090100_core_settings_hidden_flag.js +24 -0
  564. package/dist/migrations/20260629T090100_core_settings_hidden_flag.js.map +1 -0
  565. package/dist/migrations/20260717T134752_core_tenant_scope_indexes.d.ts +27 -0
  566. package/dist/migrations/20260717T134752_core_tenant_scope_indexes.d.ts.map +1 -0
  567. package/dist/migrations/20260717T134752_core_tenant_scope_indexes.js +32 -0
  568. package/dist/migrations/20260717T134752_core_tenant_scope_indexes.js.map +1 -0
  569. package/dist/migrations/20260721T011510_core_settings_credential_ref_value_type.d.ts +24 -0
  570. package/dist/migrations/20260721T011510_core_settings_credential_ref_value_type.d.ts.map +1 -0
  571. package/dist/migrations/20260721T011510_core_settings_credential_ref_value_type.js +57 -0
  572. package/dist/migrations/20260721T011510_core_settings_credential_ref_value_type.js.map +1 -0
  573. package/dist/migrations/20260816T203339_core_retire_core_activation_settings.d.ts +39 -0
  574. package/dist/migrations/20260816T203339_core_retire_core_activation_settings.d.ts.map +1 -0
  575. package/dist/migrations/20260816T203339_core_retire_core_activation_settings.js +59 -0
  576. package/dist/migrations/20260816T203339_core_retire_core_activation_settings.js.map +1 -0
  577. package/dist/migrations/20260919T101500_core_module_registrations_boot_converged.d.ts +34 -0
  578. package/dist/migrations/20260919T101500_core_module_registrations_boot_converged.d.ts.map +1 -0
  579. package/dist/migrations/20260919T101500_core_module_registrations_boot_converged.js +38 -0
  580. package/dist/migrations/20260919T101500_core_module_registrations_boot_converged.js.map +1 -0
  581. package/dist/migrations/baseline-migrations.generated.d.ts +2 -0
  582. package/dist/migrations/baseline-migrations.generated.d.ts.map +1 -0
  583. package/dist/migrations/baseline-migrations.generated.js +136 -0
  584. package/dist/migrations/baseline-migrations.generated.js.map +1 -0
  585. package/dist/migrations/index.d.ts +62 -0
  586. package/dist/migrations/index.d.ts.map +1 -0
  587. package/dist/migrations/index.js +75 -0
  588. package/dist/migrations/index.js.map +1 -0
  589. package/dist/overlay/deployment-roots.d.ts +37 -0
  590. package/dist/overlay/deployment-roots.d.ts.map +1 -0
  591. package/dist/overlay/deployment-roots.js +90 -0
  592. package/dist/overlay/deployment-roots.js.map +1 -0
  593. package/dist/overlay/index.d.ts +62 -0
  594. package/dist/overlay/index.d.ts.map +1 -0
  595. package/dist/overlay/index.js +62 -0
  596. package/dist/overlay/index.js.map +1 -0
  597. package/dist/overlay/overlay-runtime.d.ts +173 -0
  598. package/dist/overlay/overlay-runtime.d.ts.map +1 -0
  599. package/dist/overlay/overlay-runtime.js +281 -0
  600. package/dist/overlay/overlay-runtime.js.map +1 -0
  601. package/dist/overlay/resolve-overlay.d.ts +41 -0
  602. package/dist/overlay/resolve-overlay.d.ts.map +1 -0
  603. package/dist/overlay/resolve-overlay.js +72 -0
  604. package/dist/overlay/resolve-overlay.js.map +1 -0
  605. package/dist/packages/index.d.ts +57 -0
  606. package/dist/packages/index.d.ts.map +1 -0
  607. package/dist/packages/index.js +57 -0
  608. package/dist/packages/index.js.map +1 -0
  609. package/dist/packages/installed-packages.d.ts +79 -0
  610. package/dist/packages/installed-packages.d.ts.map +1 -0
  611. package/dist/packages/installed-packages.js +312 -0
  612. package/dist/packages/installed-packages.js.map +1 -0
  613. package/dist/packages/package-entity-lookup.d.ts +120 -0
  614. package/dist/packages/package-entity-lookup.d.ts.map +1 -0
  615. package/dist/packages/package-entity-lookup.js +17 -0
  616. package/dist/packages/package-entity-lookup.js.map +1 -0
  617. package/dist/packages/package-runtime.d.ts +177 -0
  618. package/dist/packages/package-runtime.d.ts.map +1 -0
  619. package/dist/packages/package-runtime.js +386 -0
  620. package/dist/packages/package-runtime.js.map +1 -0
  621. package/dist/tenancy/derived-scope.d.ts +43 -0
  622. package/dist/tenancy/derived-scope.d.ts.map +1 -0
  623. package/dist/tenancy/derived-scope.js +76 -0
  624. package/dist/tenancy/derived-scope.js.map +1 -0
  625. package/dist/tenancy/escape-hatch.d.ts +30 -0
  626. package/dist/tenancy/escape-hatch.d.ts.map +1 -0
  627. package/dist/tenancy/escape-hatch.js +50 -0
  628. package/dist/tenancy/escape-hatch.js.map +1 -0
  629. package/dist/tenancy/filters.d.ts +87 -0
  630. package/dist/tenancy/filters.d.ts.map +1 -0
  631. package/dist/tenancy/filters.js +126 -0
  632. package/dist/tenancy/filters.js.map +1 -0
  633. package/dist/tenancy/index.d.ts +63 -0
  634. package/dist/tenancy/index.d.ts.map +1 -0
  635. package/dist/tenancy/index.js +61 -0
  636. package/dist/tenancy/index.js.map +1 -0
  637. package/dist/tenancy/org-scoped.decorator.d.ts +150 -0
  638. package/dist/tenancy/org-scoped.decorator.d.ts.map +1 -0
  639. package/dist/tenancy/org-scoped.decorator.js +339 -0
  640. package/dist/tenancy/org-scoped.decorator.js.map +1 -0
  641. package/dist/tenancy/org-write-guard.d.ts +106 -0
  642. package/dist/tenancy/org-write-guard.d.ts.map +1 -0
  643. package/dist/tenancy/org-write-guard.js +141 -0
  644. package/dist/tenancy/org-write-guard.js.map +1 -0
  645. package/dist/tenancy/resolve-tenant-context.d.ts +91 -0
  646. package/dist/tenancy/resolve-tenant-context.d.ts.map +1 -0
  647. package/dist/tenancy/resolve-tenant-context.js +85 -0
  648. package/dist/tenancy/resolve-tenant-context.js.map +1 -0
  649. package/dist/tenancy/scoped-em.d.ts +10 -0
  650. package/dist/tenancy/scoped-em.d.ts.map +1 -0
  651. package/dist/tenancy/scoped-em.js +11 -0
  652. package/dist/tenancy/scoped-em.js.map +1 -0
  653. package/dist/tenancy/tenant-context.d.ts +154 -0
  654. package/dist/tenancy/tenant-context.d.ts.map +1 -0
  655. package/dist/tenancy/tenant-context.js +109 -0
  656. package/dist/tenancy/tenant-context.js.map +1 -0
  657. package/package.json +123 -0
@@ -0,0 +1,165 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import { type Worker } from 'bullmq';
3
+ import { HttpError } from '../../http/error-envelope.js';
4
+ import type { ModulePlugin } from '../../http/server.js';
5
+ import type { PlatformLogger } from '../logging.js';
6
+ /**
7
+ * Thrown when service-to-service code calls into a disabled module's
8
+ * surface. Surfaces as `503 Service Unavailable` via the standard error
9
+ * envelope, with `Retry-After` so a well-behaved client backs off rather than
10
+ * treating the module as gone.
11
+ *
12
+ * **`details` names the module** (issue #161, `moduleDisabledDetailsSchema`).
13
+ * The id was on the error object from the start, and every caller that catches
14
+ * the throw could read it — but the envelope replaces an operator-visible
15
+ * message with the registered sentence for its *code*, and this one code covers
16
+ * every gated port in the platform, so the wire carried a generic "Module
17
+ * Disabled." An operator refused a refund because a payment gateway is switched
18
+ * off was not told which module to switch back on, which also undercut D-71's
19
+ * own rationale: the remedy was named on the object, not on the response.
20
+ * `details` is the part of the envelope that survives the replacement, and the
21
+ * sentence interpolates `{module}` out of it. `carts` had already written the
22
+ * same key by hand for its one contribution-point refusal
23
+ * (`src/modules/carts/backend.ts`); this makes the platform-wide throw agree.
24
+ */
25
+ export declare class ModuleDisabledError extends HttpError {
26
+ readonly moduleId: string;
27
+ constructor(moduleId: string);
28
+ }
29
+ /**
30
+ * Let a module's presence answer through a `catch` that legitimately absorbs
31
+ * everything else (issue #84 — the deferred half of feature 072's D-43).
32
+ *
33
+ * `lazyPort` resolves inside the forwarded call, so a switched-off owner
34
+ * surfaces as {@link ModuleDisabledError} **at the call site**. A
35
+ * `try { … } catch { return null }` around one silently converts fail-closed
36
+ * into fail-open: the caller answers "no data" where the truthful answer is
37
+ * "this capability is off", and the operator reads a working screen that is
38
+ * lying to them.
39
+ *
40
+ * The first fix for that is to delete the `catch` — most of them exist only
41
+ * because somebody was being defensive, and where a degrade genuinely belongs
42
+ * it belongs **inside the owner's implementation**, expressed in the return
43
+ * type (`allowedIdsFor(): Promise<string[] | null>` is the worked example).
44
+ *
45
+ * This helper is for the remainder: a tolerance that is correct *as a
46
+ * tolerance* — a per-item import failure recorded as an issue rather than
47
+ * failing the run, a compensating cleanup on a rollback path, a notification
48
+ * that must not undo the write it announces. None of those wants to absorb the
49
+ * presence answer too, because that answer is about the whole operation rather
50
+ * than the one item, and the run that "completed with 4 000 failures" is a
51
+ * worse report than the one that stopped saying `catalog` is switched off.
52
+ *
53
+ * ```ts
54
+ * } catch (error) {
55
+ * rethrowIfModuleDisabled(error);
56
+ * state.countFailed();
57
+ * }
58
+ * ```
59
+ *
60
+ * It is deliberately greppable: `scripts/check-port-catches.ts` reads it as the
61
+ * one spelling that distinguishes a narrowed tolerance from a bare `catch`.
62
+ */
63
+ export declare function rethrowIfModuleDisabled(error: unknown): void;
64
+ /**
65
+ * Programmatic gate. Throw from anywhere outside an HTTP request when
66
+ * an absent module's logic should not run. Surfaces consistently as
67
+ * the same 503 envelope when reached from a route handler.
68
+ *
69
+ * "Absent" is the **effective** state — platform availability AND operator
70
+ * activation (Constitution XVII). A caller never learns there are two axes;
71
+ * it learns the module is not there.
72
+ */
73
+ export declare function requireModuleEnabled(moduleId: string): void;
74
+ /**
75
+ * Wrap a Fastify plugin so every route registered inside it is gated on
76
+ * the module's effective state. Absent module → 503 with
77
+ * `Retry-After: 60`; enabled module → handler runs normally.
78
+ *
79
+ * Use it at the top of every module's `routes.admin.ts` /
80
+ * `routes.storefront.ts`:
81
+ *
82
+ * export const blogRoutes = defineModuleRoutes('blog', async (app) => {
83
+ * app.get('/api/v1/admin/blog/posts', { preHandler: requireAdmin() }, h);
84
+ * });
85
+ *
86
+ * Two HTTP-level effects:
87
+ * 1. The wrapper registers a child encapsulated context, so the
88
+ * preHandler hook only fires for routes registered inside `register`.
89
+ * 2. The 503 response includes `Retry-After: 60` so well-behaved
90
+ * clients back off until the next enable-check window. The header now
91
+ * travels on {@link ModuleDisabledError} itself, so the same 503 from a
92
+ * service call or a port resolution carries it too.
93
+ */
94
+ export declare function defineModuleRoutes(moduleId: string, register: (app: FastifyInstance) => Promise<void> | void): ModulePlugin;
95
+ export interface DefineModuleWorkerOptions {
96
+ /**
97
+ * When provided, the worker's lifecycle events (ready / active / completed /
98
+ * failed / stalled / error) are logged with this logger. This gives the
99
+ * `worker` / `worker:dev` processes a visible heartbeat so operators can tell
100
+ * a queue is actually consuming jobs (and see why one fails or stalls).
101
+ */
102
+ logger?: PlatformLogger;
103
+ }
104
+ /**
105
+ * The fetch gate — bring every registered worker into agreement with its
106
+ * module's effective state.
107
+ *
108
+ * Level-triggered and idempotent, so it is safe to run on every presence
109
+ * install: BullMQ's own `pause()` and `resume()` are no-ops when the worker is
110
+ * already there, and the comparison below keeps even those off the common path.
111
+ *
112
+ * This is what makes the repair work across processes. Every composed process —
113
+ * API, `BACKEND_ROLE=worker`, `all` — keeps its own {@link registryCache} fresh
114
+ * from the same `b2b:module:state-changed` channel (and from the degraded-mode
115
+ * timer when Redis is unavailable), so following the cache means the worker
116
+ * process reacts to a flip written anywhere, including by a CLI that composed
117
+ * nothing.
118
+ */
119
+ export declare function reconcileModuleWorkers(): void;
120
+ /**
121
+ * Register a BullMQ Worker as its module's, so both gates apply to it.
122
+ *
123
+ * Two things happen, and only the first was ever true: the worker joins the
124
+ * per-module registry {@link pauseWorkersFor} iterates, **and** its processor is
125
+ * wrapped in the work gate while the registry itself is reconciled against the
126
+ * cache on every presence install. The returned worker is the same instance.
127
+ *
128
+ * A worker constructed outside this seam is a worker nothing can stop —
129
+ * `check:worker-seam` is the ratchet for that, and `pwa`'s push consumer was
130
+ * the live instance when it landed.
131
+ */
132
+ export declare function defineModuleWorker<W extends Worker>(moduleId: string, worker: W, options?: DefineModuleWorkerOptions): W;
133
+ /**
134
+ * Pause a module's workers now, without waiting for the next presence install.
135
+ *
136
+ * An **optimisation**, since the fetch gate above: the orchestrator's disable
137
+ * path refreshes the cache and publishes the state change, which reconciles
138
+ * every process including this one. Calling it here simply makes the local
139
+ * process's answer immediate rather than one refresh away.
140
+ */
141
+ export declare function pauseWorkersFor(moduleId: string): Promise<void>;
142
+ /**
143
+ * Resume a module's workers now. The mirror of {@link pauseWorkersFor}, and an
144
+ * optimisation on the same terms — note that it resumes on the **platform**
145
+ * axis alone, which is safe only because the work gate re-asks for the
146
+ * conjunction on every job.
147
+ */
148
+ export declare function resumeWorkersFor(moduleId: string): Promise<void>;
149
+ /**
150
+ * Test seam — empty the per-process worker registry.
151
+ *
152
+ * The suite shares one process per fork, so a worker registered by an earlier
153
+ * test is still there for the reconcile the next one triggers. Production never
154
+ * calls it: workers leave the registry when they close.
155
+ */
156
+ export declare function resetModuleWorkersForTesting(): void;
157
+ /**
158
+ * Wrap an EventBus subscription so the handler is a no-op when the
159
+ * owning module is absent. Mirrors `EventBus.on(eventName, handler)`'s
160
+ * unsubscribe-returning shape.
161
+ */
162
+ export declare function subscribeForModule<E, P>(moduleId: string, bus: {
163
+ on(event: E, handler: (payload: P) => void | Promise<void>): () => void;
164
+ }, event: E, handler: (payload: P) => void | Promise<void>): () => void;
165
+ //# sourceMappingURL=plugin-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-helpers.d.ts","sourceRoot":"","sources":["../../../src/kernel/lifecycle/plugin-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAYpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;aACpB,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAU7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,E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I,CAAC,GAC5C,MAAM,IAAI,CAMZ"}
@@ -0,0 +1,395 @@
1
+ import { RateLimitError } from 'bullmq';
2
+ import { ERROR_CODES } from '@endora-commerce/contracts';
3
+ import { HttpError } from '../../http/error-envelope.js';
4
+ import { effectiveState } from './effective-state.js';
5
+ import { FALLBACK_TTL_MS, registryCache } from './registry-cache.js';
6
+ /**
7
+ * How long a client should wait before retrying a surface whose module is
8
+ * absent — one enable-check window. Carried by the error itself, so a route
9
+ * gate, a `requireModuleEnabled` call and a port resolution all answer the
10
+ * same thing (feature 072, T059).
11
+ */
12
+ const RETRY_AFTER_SECONDS = '60';
13
+ /**
14
+ * Thrown when service-to-service code calls into a disabled module's
15
+ * surface. Surfaces as `503 Service Unavailable` via the standard error
16
+ * envelope, with `Retry-After` so a well-behaved client backs off rather than
17
+ * treating the module as gone.
18
+ *
19
+ * **`details` names the module** (issue #161, `moduleDisabledDetailsSchema`).
20
+ * The id was on the error object from the start, and every caller that catches
21
+ * the throw could read it — but the envelope replaces an operator-visible
22
+ * message with the registered sentence for its *code*, and this one code covers
23
+ * every gated port in the platform, so the wire carried a generic "Module
24
+ * Disabled." An operator refused a refund because a payment gateway is switched
25
+ * off was not told which module to switch back on, which also undercut D-71's
26
+ * own rationale: the remedy was named on the object, not on the response.
27
+ * `details` is the part of the envelope that survives the replacement, and the
28
+ * sentence interpolates `{module}` out of it. `carts` had already written the
29
+ * same key by hand for its one contribution-point refusal
30
+ * (`src/modules/carts/backend.ts`); this makes the platform-wide throw agree.
31
+ */
32
+ export class ModuleDisabledError extends HttpError {
33
+ moduleId;
34
+ constructor(moduleId) {
35
+ super(503, ERROR_CODES.MODULE_DISABLED, `Module '${moduleId}' is currently disabled.`, { module: moduleId }, { 'Retry-After': RETRY_AFTER_SECONDS });
36
+ this.moduleId = moduleId;
37
+ this.name = 'ModuleDisabledError';
38
+ }
39
+ }
40
+ /**
41
+ * Let a module's presence answer through a `catch` that legitimately absorbs
42
+ * everything else (issue #84 — the deferred half of feature 072's D-43).
43
+ *
44
+ * `lazyPort` resolves inside the forwarded call, so a switched-off owner
45
+ * surfaces as {@link ModuleDisabledError} **at the call site**. A
46
+ * `try { … } catch { return null }` around one silently converts fail-closed
47
+ * into fail-open: the caller answers "no data" where the truthful answer is
48
+ * "this capability is off", and the operator reads a working screen that is
49
+ * lying to them.
50
+ *
51
+ * The first fix for that is to delete the `catch` — most of them exist only
52
+ * because somebody was being defensive, and where a degrade genuinely belongs
53
+ * it belongs **inside the owner's implementation**, expressed in the return
54
+ * type (`allowedIdsFor(): Promise<string[] | null>` is the worked example).
55
+ *
56
+ * This helper is for the remainder: a tolerance that is correct *as a
57
+ * tolerance* — a per-item import failure recorded as an issue rather than
58
+ * failing the run, a compensating cleanup on a rollback path, a notification
59
+ * that must not undo the write it announces. None of those wants to absorb the
60
+ * presence answer too, because that answer is about the whole operation rather
61
+ * than the one item, and the run that "completed with 4 000 failures" is a
62
+ * worse report than the one that stopped saying `catalog` is switched off.
63
+ *
64
+ * ```ts
65
+ * } catch (error) {
66
+ * rethrowIfModuleDisabled(error);
67
+ * state.countFailed();
68
+ * }
69
+ * ```
70
+ *
71
+ * It is deliberately greppable: `scripts/check-port-catches.ts` reads it as the
72
+ * one spelling that distinguishes a narrowed tolerance from a bare `catch`.
73
+ */
74
+ export function rethrowIfModuleDisabled(error) {
75
+ if (error instanceof ModuleDisabledError)
76
+ throw error;
77
+ }
78
+ /**
79
+ * Programmatic gate. Throw from anywhere outside an HTTP request when
80
+ * an absent module's logic should not run. Surfaces consistently as
81
+ * the same 503 envelope when reached from a route handler.
82
+ *
83
+ * "Absent" is the **effective** state — platform availability AND operator
84
+ * activation (Constitution XVII). A caller never learns there are two axes;
85
+ * it learns the module is not there.
86
+ */
87
+ export function requireModuleEnabled(moduleId) {
88
+ if (!effectiveState.isPresent(moduleId)) {
89
+ throw new ModuleDisabledError(moduleId);
90
+ }
91
+ }
92
+ /**
93
+ * Wrap a Fastify plugin so every route registered inside it is gated on
94
+ * the module's effective state. Absent module → 503 with
95
+ * `Retry-After: 60`; enabled module → handler runs normally.
96
+ *
97
+ * Use it at the top of every module's `routes.admin.ts` /
98
+ * `routes.storefront.ts`:
99
+ *
100
+ * export const blogRoutes = defineModuleRoutes('blog', async (app) => {
101
+ * app.get('/api/v1/admin/blog/posts', { preHandler: requireAdmin() }, h);
102
+ * });
103
+ *
104
+ * Two HTTP-level effects:
105
+ * 1. The wrapper registers a child encapsulated context, so the
106
+ * preHandler hook only fires for routes registered inside `register`.
107
+ * 2. The 503 response includes `Retry-After: 60` so well-behaved
108
+ * clients back off until the next enable-check window. The header now
109
+ * travels on {@link ModuleDisabledError} itself, so the same 503 from a
110
+ * service call or a port resolution carries it too.
111
+ */
112
+ export function defineModuleRoutes(moduleId, register) {
113
+ return async (app) => {
114
+ await app.register(async (scoped) => {
115
+ scoped.addHook('onRequest', async () => {
116
+ if (!effectiveState.isPresent(moduleId)) {
117
+ throw new ModuleDisabledError(moduleId);
118
+ }
119
+ });
120
+ await register(scoped);
121
+ });
122
+ };
123
+ }
124
+ /**
125
+ * Attach structured lifecycle logging to a BullMQ worker. Every queue consumer
126
+ * gets the same shape of log line — `{ module, queue, jobId, jobName, ... }` —
127
+ * so the `worker` process output reads consistently across modules.
128
+ */
129
+ function attachWorkerLogging(moduleId, worker, logger) {
130
+ const queue = worker.name;
131
+ const base = { module: moduleId, queue };
132
+ logger.info(base, 'queue consumer registered');
133
+ worker.on('ready', () => {
134
+ logger.info(base, 'queue consumer ready (connected to Redis)');
135
+ });
136
+ worker.on('active', (job) => {
137
+ logger.info({ ...base, jobId: job.id, jobName: job.name, data: job.data }, 'queue job active');
138
+ });
139
+ worker.on('completed', (job) => {
140
+ const durationMs = job.finishedOn != null && job.processedOn != null
141
+ ? job.finishedOn - job.processedOn
142
+ : undefined;
143
+ logger.info({ ...base, jobId: job.id, jobName: job.name, durationMs }, 'queue job completed');
144
+ });
145
+ worker.on('failed', (job, err) => {
146
+ logger.error({
147
+ ...base,
148
+ jobId: job?.id,
149
+ jobName: job?.name,
150
+ data: job?.data,
151
+ attemptsMade: job?.attemptsMade,
152
+ err,
153
+ }, 'queue job failed');
154
+ });
155
+ worker.on('stalled', (jobId) => {
156
+ logger.warn({ ...base, jobId }, 'queue job stalled — moved back to wait list');
157
+ });
158
+ worker.on('error', (err) => {
159
+ logger.error({ ...base, err }, 'queue consumer error');
160
+ });
161
+ }
162
+ /**
163
+ * Every worker a module registered, in **this** process.
164
+ *
165
+ * Which is the whole reason the registry alone was never the gate: a push into
166
+ * it reaches the process that pushed and nothing else, and the two processes
167
+ * that flip presence are exactly the two that hold no workers — the API process
168
+ * serving `/api/v1/admin/modules/:id/activation`, and the `module:*` CLI, which
169
+ * composes nothing (D-157.2) and therefore registers nothing. See
170
+ * {@link reconcileModuleWorkers}.
171
+ */
172
+ const moduleWorkers = new Map();
173
+ /**
174
+ * How long a worker backs off after refusing a job for an absent module.
175
+ *
176
+ * One presence-refresh window — the degraded-mode cadence, which is the longest
177
+ * a process's answer can be behind the database when the notification channel
178
+ * is down. That makes the backoff "ask again when this process could plausibly
179
+ * have learned something new", which is the only thing it is for: once
180
+ * {@link reconcileModuleWorkers} has paused the worker nothing is fetched at
181
+ * all, so this is a fallback's cadence and never a steady state's.
182
+ *
183
+ * It is deliberately **not** {@link RETRY_AFTER_SECONDS}, the 60 s a 503'd HTTP
184
+ * client is told to wait, and the difference was measured rather than reasoned
185
+ * about: BullMQ's `waitForRateLimit` delays the fetch loop for the whole
186
+ * remaining window, and it holds across a `resume()`. At 60 s a job caught in
187
+ * the flip window sat for the better part of a minute after the operator
188
+ * switched the module back on — correct, and indistinguishable from broken.
189
+ */
190
+ const ABSENT_JOB_BACKOFF_MS = FALLBACK_TTL_MS;
191
+ /** Marks a worker whose processor already carries the work gate. */
192
+ const GATED = Symbol.for('endora.moduleWorker.presenceGated');
193
+ /**
194
+ * The work gate — Constitution XVII, and AGENTS.md's rule for an entry point
195
+ * with nowhere to throw to: *presence is decided before the work, first and
196
+ * outside the `try`*.
197
+ *
198
+ * A BullMQ processor is such an entry point. The fetch gate below stops a
199
+ * worker within one presence install of the flip, but a job already fetched
200
+ * when presence moved would still run its module's business logic — which for
201
+ * `google_analytics` means one more disclosure to a third party after the
202
+ * operator withdrew it. So the decision is per job.
203
+ *
204
+ * **What happens to the job: it is left waiting.** `Worker.rateLimit` plus
205
+ * `RateLimitError` is BullMQ's own idiom for "not now, put it back": the worker
206
+ * handles that error with `job.moveToWait(token)`, which RPUSHes the job onto
207
+ * the wait list, emits `waiting`, consumes no attempt and fires no `failed`
208
+ * handler. Failing the job would burn its retries against a decision that is
209
+ * not about the job, and completing it would drop work an operator never asked
210
+ * to lose. Deactivation is "non-destructive and reversible" (Principle XVII),
211
+ * so the job drains when the module comes back.
212
+ */
213
+ function installWorkGate(moduleId, worker) {
214
+ const slot = worker;
215
+ if (slot[GATED])
216
+ return;
217
+ const inner = slot.processFn;
218
+ if (typeof inner !== 'function') {
219
+ throw new Error(`[kernel] module '${moduleId}' registered a queue consumer whose processor could not be ` +
220
+ `found (BullMQ's \`Worker.processFn\`). Without it the worker would keep running the ` +
221
+ `module's business logic after an operator switched the module off (Constitution XVII). ` +
222
+ `If BullMQ has renamed the property, \`installWorkGate\` is the one place that names it.`);
223
+ }
224
+ slot.processFn = async (job, token, signal) => {
225
+ // First, and outside every `try`: a switched-off module and a genuine
226
+ // failure must not share one silent no-op. `isPresent` throws on a cache
227
+ // nothing has loaded, and "nothing has read the database yet" is not an
228
+ // answer a processor can act on either — so it reads as absent, which is
229
+ // the direction that loses no work.
230
+ if (!isPresentOrUnresolved(moduleId)) {
231
+ await worker.rateLimit(ABSENT_JOB_BACKOFF_MS);
232
+ throw new RateLimitError();
233
+ }
234
+ return inner.call(worker, job, token, signal);
235
+ };
236
+ slot[GATED] = true;
237
+ }
238
+ /** Effective presence, with an unloaded cache reading as absent rather than throwing. */
239
+ function isPresentOrUnresolved(moduleId) {
240
+ return registryCache.isLoaded() && effectiveState.isPresent(moduleId);
241
+ }
242
+ /**
243
+ * The fetch gate — bring every registered worker into agreement with its
244
+ * module's effective state.
245
+ *
246
+ * Level-triggered and idempotent, so it is safe to run on every presence
247
+ * install: BullMQ's own `pause()` and `resume()` are no-ops when the worker is
248
+ * already there, and the comparison below keeps even those off the common path.
249
+ *
250
+ * This is what makes the repair work across processes. Every composed process —
251
+ * API, `BACKEND_ROLE=worker`, `all` — keeps its own {@link registryCache} fresh
252
+ * from the same `b2b:module:state-changed` channel (and from the degraded-mode
253
+ * timer when Redis is unavailable), so following the cache means the worker
254
+ * process reacts to a flip written anywhere, including by a CLI that composed
255
+ * nothing.
256
+ */
257
+ export function reconcileModuleWorkers() {
258
+ if (!registryCache.isLoaded())
259
+ return;
260
+ for (const [moduleId, workers] of moduleWorkers) {
261
+ const present = effectiveState.isPresent(moduleId);
262
+ for (const worker of workers) {
263
+ if (present === !worker.isPaused())
264
+ continue;
265
+ applyWorkerPresence(moduleId, worker, present);
266
+ }
267
+ }
268
+ }
269
+ /**
270
+ * Pause or resume one worker, without waiting for it.
271
+ *
272
+ * A presence install is synchronous — it happens inside a pub/sub callback or a
273
+ * timer tick — so this cannot be awaited, and `pause()` deliberately waits for
274
+ * the jobs already running to finish (the non-destructive half: an in-flight job
275
+ * completes, and nothing new is fetched).
276
+ *
277
+ * The `catch` is not a tolerance and is not a port catch (`Worker.pause` reaches
278
+ * no module): it is what keeps a fire-and-forget promise from becoming an
279
+ * **unhandled rejection**, which in a Node process is a crash rather than a
280
+ * message. It is reachable — `pause()` reconnects the blocking connection to
281
+ * wait for the active job, and a connection that is closing rejects — and it
282
+ * costs nothing to say so out loud. The worker is left where it was; the next
283
+ * presence install (the pub/sub message, or the degraded timer five seconds
284
+ * later) tries again, which is what level-triggering buys.
285
+ */
286
+ function applyWorkerPresence(moduleId, worker, present) {
287
+ let settled;
288
+ try {
289
+ settled = present ? Promise.resolve(worker.resume()) : worker.pause();
290
+ }
291
+ catch (err) {
292
+ warnWorkerPresenceFailed(moduleId, worker, present, err);
293
+ return;
294
+ }
295
+ // No re-read once it settles, deliberately. `pause()` awaits the job already
296
+ // running, so two flips can settle out of order — but BullMQ sets `paused`
297
+ // **synchronously** and clears it the same way, so the flag already agrees
298
+ // with the last caller before either promise resolves. A convergence loop here
299
+ // would be machinery for a hazard nothing in this stack has.
300
+ void settled.catch((err) => warnWorkerPresenceFailed(moduleId, worker, present, err));
301
+ }
302
+ function warnWorkerPresenceFailed(moduleId, worker, present, err) {
303
+ console.warn(`[module-lifecycle] could not ${present ? 'resume' : 'pause'} a queue consumer of ` +
304
+ `'${moduleId}' (${worker.name}); the next presence refresh will retry: ${err instanceof Error ? err.message : String(err)}`);
305
+ }
306
+ let reconcilerArmed = false;
307
+ function armWorkerReconciler() {
308
+ if (reconcilerArmed)
309
+ return;
310
+ reconcilerArmed = true;
311
+ registryCache.onPresenceInstalled(reconcileModuleWorkers);
312
+ }
313
+ /**
314
+ * Register a BullMQ Worker as its module's, so both gates apply to it.
315
+ *
316
+ * Two things happen, and only the first was ever true: the worker joins the
317
+ * per-module registry {@link pauseWorkersFor} iterates, **and** its processor is
318
+ * wrapped in the work gate while the registry itself is reconciled against the
319
+ * cache on every presence install. The returned worker is the same instance.
320
+ *
321
+ * A worker constructed outside this seam is a worker nothing can stop —
322
+ * `check:worker-seam` is the ratchet for that, and `pwa`'s push consumer was
323
+ * the live instance when it landed.
324
+ */
325
+ export function defineModuleWorker(moduleId, worker, options) {
326
+ const set = moduleWorkers.get(moduleId) ?? new Set();
327
+ set.add(worker);
328
+ moduleWorkers.set(moduleId, set);
329
+ if (options?.logger) {
330
+ attachWorkerLogging(moduleId, worker, options.logger);
331
+ }
332
+ installWorkGate(moduleId, worker);
333
+ armWorkerReconciler();
334
+ // A closed worker is not a paused one, and resuming it would restart a queue
335
+ // consumer whose owner has gone. Leaving it in the registry is also how the
336
+ // map grew without bound across a long-lived process.
337
+ worker.on('closed', () => {
338
+ set.delete(worker);
339
+ if (set.size === 0)
340
+ moduleWorkers.delete(moduleId);
341
+ });
342
+ // If the module is currently absent at registration time, start paused.
343
+ if (!isPresentOrUnresolved(moduleId)) {
344
+ applyWorkerPresence(moduleId, worker, false);
345
+ }
346
+ return worker;
347
+ }
348
+ /**
349
+ * Pause a module's workers now, without waiting for the next presence install.
350
+ *
351
+ * An **optimisation**, since the fetch gate above: the orchestrator's disable
352
+ * path refreshes the cache and publishes the state change, which reconciles
353
+ * every process including this one. Calling it here simply makes the local
354
+ * process's answer immediate rather than one refresh away.
355
+ */
356
+ export async function pauseWorkersFor(moduleId) {
357
+ for (const w of moduleWorkers.get(moduleId) ?? []) {
358
+ await w.pause();
359
+ }
360
+ }
361
+ /**
362
+ * Resume a module's workers now. The mirror of {@link pauseWorkersFor}, and an
363
+ * optimisation on the same terms — note that it resumes on the **platform**
364
+ * axis alone, which is safe only because the work gate re-asks for the
365
+ * conjunction on every job.
366
+ */
367
+ export async function resumeWorkersFor(moduleId) {
368
+ for (const w of moduleWorkers.get(moduleId) ?? []) {
369
+ await w.resume();
370
+ }
371
+ }
372
+ /**
373
+ * Test seam — empty the per-process worker registry.
374
+ *
375
+ * The suite shares one process per fork, so a worker registered by an earlier
376
+ * test is still there for the reconcile the next one triggers. Production never
377
+ * calls it: workers leave the registry when they close.
378
+ */
379
+ export function resetModuleWorkersForTesting() {
380
+ moduleWorkers.clear();
381
+ }
382
+ /**
383
+ * Wrap an EventBus subscription so the handler is a no-op when the
384
+ * owning module is absent. Mirrors `EventBus.on(eventName, handler)`'s
385
+ * unsubscribe-returning shape.
386
+ */
387
+ export function subscribeForModule(moduleId, bus, event, handler) {
388
+ const wrapped = async (payload) => {
389
+ if (!effectiveState.isPresent(moduleId))
390
+ return;
391
+ await handler(payload);
392
+ };
393
+ return bus.on(event, wrapped);
394
+ }
395
+ //# sourceMappingURL=plugin-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-helpers.js","sourceRoot":"","sources":["../../../src/kernel/lifecycle/plugin-helpers.ts"],"names":[],"mappings":"AACA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