@open-mercato/shared 0.9.0 → 0.9.1-develop.7459.1.99e3accd30

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 (31) hide show
  1. package/dist/lib/bootstrap/factory.js +4 -3
  2. package/dist/lib/bootstrap/factory.js.map +2 -2
  3. package/dist/lib/commands/command-bus.js +45 -13
  4. package/dist/lib/commands/command-bus.js.map +2 -2
  5. package/dist/lib/commands/types.js.map +2 -2
  6. package/dist/lib/version.js +1 -1
  7. package/dist/lib/version.js.map +1 -1
  8. package/dist/lib/webhooks/body.js +7 -3
  9. package/dist/lib/webhooks/body.js.map +2 -2
  10. package/dist/lib/webhooks/index.js +2 -0
  11. package/dist/lib/webhooks/index.js.map +2 -2
  12. package/dist/modules/payment_gateways/types.js +14 -1
  13. package/dist/modules/payment_gateways/types.js.map +2 -2
  14. package/dist/modules/widgets/injection-loader.js +14 -3
  15. package/dist/modules/widgets/injection-loader.js.map +2 -2
  16. package/package.json +4 -3
  17. package/src/lib/bootstrap/__tests__/factory.test.ts +18 -6
  18. package/src/lib/bootstrap/factory.ts +8 -3
  19. package/src/lib/bootstrap/types.ts +5 -1
  20. package/src/lib/commands/__tests__/command-bus.test.ts +100 -1
  21. package/src/lib/commands/command-bus.ts +42 -10
  22. package/src/lib/commands/command-interceptor.ts +4 -0
  23. package/src/lib/commands/types.ts +14 -0
  24. package/src/lib/encryption/__tests__/tenantDataEncryptionService.test.ts +23 -0
  25. package/src/lib/webhooks/__tests__/body.test.ts +48 -0
  26. package/src/lib/webhooks/body.ts +11 -4
  27. package/src/lib/webhooks/index.ts +1 -0
  28. package/src/modules/payment_gateways/__tests__/types.test.ts +44 -0
  29. package/src/modules/payment_gateways/types.ts +52 -6
  30. package/src/modules/widgets/__tests__/injection-loader.partitioned-registration.test.ts +78 -0
  31. package/src/modules/widgets/injection-loader.ts +33 -3
@@ -141,11 +141,41 @@ function notifyInjectionRegistryChanged() {
141
141
  }))
142
142
  }
143
143
 
144
- export function registerCoreInjectionWidgets(entries: ModuleInjectionWidgetEntry[]) {
145
- if (_coreInjectionWidgetEntries !== null && process.env.NODE_ENV === 'development') {
144
+ export type RegisterCoreInjectionWidgetsOptions = {
145
+ /**
146
+ * `replace` (default) publishes `entries` as the whole registry.
147
+ *
148
+ * `merge` adds only the entries the registry does not already carry, keeping whatever a
149
+ * previous bootstrap published. A process may run more than one bootstrap partition (the
150
+ * API-only one and the full page one share a Node process in a mixed web host), and the
151
+ * partition that registers second must not shrink the registry the first one populated.
152
+ */
153
+ mode?: 'replace' | 'merge'
154
+ }
155
+
156
+ export function registerCoreInjectionWidgets(
157
+ entries: ModuleInjectionWidgetEntry[],
158
+ options: RegisterCoreInjectionWidgetsOptions = {},
159
+ ) {
160
+ if (_coreInjectionWidgetEntries !== null && process.env.NODE_ENV === 'development' && options.mode !== 'merge') {
146
161
  logger.debug('Core injection widgets re-registered (this may occur during HMR)')
147
162
  }
148
- const finalEntries = applyInjectionWidgetOverridesToEntries(entries)
163
+ const incoming = applyInjectionWidgetOverridesToEntries(entries)
164
+ if (options.mode !== 'merge') {
165
+ _coreInjectionWidgetEntries = incoming
166
+ writeGlobalInjectionWidgets(incoming)
167
+ notifyInjectionRegistryChanged()
168
+ return
169
+ }
170
+
171
+ const existing = readGlobalInjectionWidgets() ?? _coreInjectionWidgetEntries ?? []
172
+ const known = new Set(existing.map((entry) => entry.key))
173
+ const added = incoming.filter((entry) => !known.has(entry.key))
174
+ // Nothing to contribute: leave the registry exactly as it was. Publishing an empty array here
175
+ // would turn "never registered" into "registered with no widgets", which downgrades the loud
176
+ // bootstrap error into silently missing contributions.
177
+ if (!added.length) return
178
+ const finalEntries = [...existing, ...added]
149
179
  _coreInjectionWidgetEntries = finalEntries
150
180
  writeGlobalInjectionWidgets(finalEntries)
151
181
  notifyInjectionRegistryChanged()