@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.
- package/dist/lib/bootstrap/factory.js +4 -3
- package/dist/lib/bootstrap/factory.js.map +2 -2
- package/dist/lib/commands/command-bus.js +45 -13
- package/dist/lib/commands/command-bus.js.map +2 -2
- package/dist/lib/commands/types.js.map +2 -2
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/webhooks/body.js +7 -3
- package/dist/lib/webhooks/body.js.map +2 -2
- package/dist/lib/webhooks/index.js +2 -0
- package/dist/lib/webhooks/index.js.map +2 -2
- package/dist/modules/payment_gateways/types.js +14 -1
- package/dist/modules/payment_gateways/types.js.map +2 -2
- package/dist/modules/widgets/injection-loader.js +14 -3
- package/dist/modules/widgets/injection-loader.js.map +2 -2
- package/package.json +4 -3
- package/src/lib/bootstrap/__tests__/factory.test.ts +18 -6
- package/src/lib/bootstrap/factory.ts +8 -3
- package/src/lib/bootstrap/types.ts +5 -1
- package/src/lib/commands/__tests__/command-bus.test.ts +100 -1
- package/src/lib/commands/command-bus.ts +42 -10
- package/src/lib/commands/command-interceptor.ts +4 -0
- package/src/lib/commands/types.ts +14 -0
- package/src/lib/encryption/__tests__/tenantDataEncryptionService.test.ts +23 -0
- package/src/lib/webhooks/__tests__/body.test.ts +48 -0
- package/src/lib/webhooks/body.ts +11 -4
- package/src/lib/webhooks/index.ts +1 -0
- package/src/modules/payment_gateways/__tests__/types.test.ts +44 -0
- package/src/modules/payment_gateways/types.ts +52 -6
- package/src/modules/widgets/__tests__/injection-loader.partitioned-registration.test.ts +78 -0
- package/src/modules/widgets/injection-loader.ts +33 -3
|
@@ -141,11 +141,41 @@ function notifyInjectionRegistryChanged() {
|
|
|
141
141
|
}))
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
export
|
|
145
|
-
|
|
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
|
|
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()
|