@endora-commerce/mod-delivery-methods 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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/admin/api/delivery-methods-client.d.ts +41 -0
  4. package/dist/admin/api/delivery-methods-client.d.ts.map +1 -0
  5. package/dist/admin/api/delivery-methods-client.js +20 -0
  6. package/dist/admin/api/delivery-methods-client.js.map +1 -0
  7. package/dist/admin/index.d.ts +34 -0
  8. package/dist/admin/index.d.ts.map +1 -0
  9. package/dist/admin/index.js +44 -0
  10. package/dist/admin/index.js.map +1 -0
  11. package/dist/admin/pages/DeliveryMethodsPage.d.ts +4 -0
  12. package/dist/admin/pages/DeliveryMethodsPage.d.ts.map +1 -0
  13. package/dist/admin/pages/DeliveryMethodsPage.js +167 -0
  14. package/dist/admin/pages/DeliveryMethodsPage.js.map +1 -0
  15. package/dist/admin/renderers/registry.d.ts +15 -0
  16. package/dist/admin/renderers/registry.d.ts.map +1 -0
  17. package/dist/admin/renderers/registry.js +18 -0
  18. package/dist/admin/renderers/registry.js.map +1 -0
  19. package/dist/backend/adapters/built-in-adapters.d.ts +46 -0
  20. package/dist/backend/adapters/built-in-adapters.d.ts.map +1 -0
  21. package/dist/backend/adapters/built-in-adapters.js +62 -0
  22. package/dist/backend/adapters/built-in-adapters.js.map +1 -0
  23. package/dist/backend/commands/delivery-method.commands.d.ts +61 -0
  24. package/dist/backend/commands/delivery-method.commands.d.ts.map +1 -0
  25. package/dist/backend/commands/delivery-method.commands.js +107 -0
  26. package/dist/backend/commands/delivery-method.commands.js.map +1 -0
  27. package/dist/backend/demo/reset.d.ts +12 -0
  28. package/dist/backend/demo/reset.d.ts.map +1 -0
  29. package/dist/backend/demo/reset.js +13 -0
  30. package/dist/backend/demo/reset.js.map +1 -0
  31. package/dist/backend/demo/rows.d.ts +24 -0
  32. package/dist/backend/demo/rows.d.ts.map +1 -0
  33. package/dist/backend/demo/rows.js +22 -0
  34. package/dist/backend/demo/rows.js.map +1 -0
  35. package/dist/backend/demo/seed.d.ts +14 -0
  36. package/dist/backend/demo/seed.d.ts.map +1 -0
  37. package/dist/backend/demo/seed.js +28 -0
  38. package/dist/backend/demo/seed.js.map +1 -0
  39. package/dist/backend/entities/delivery-method.entity.d.ts +30 -0
  40. package/dist/backend/entities/delivery-method.entity.d.ts.map +1 -0
  41. package/dist/backend/entities/delivery-method.entity.js +91 -0
  42. package/dist/backend/entities/delivery-method.entity.js.map +1 -0
  43. package/dist/backend/index.d.ts +88 -0
  44. package/dist/backend/index.d.ts.map +1 -0
  45. package/dist/backend/index.js +144 -0
  46. package/dist/backend/index.js.map +1 -0
  47. package/dist/backend/routes.d.ts +51 -0
  48. package/dist/backend/routes.d.ts.map +1 -0
  49. package/dist/backend/routes.js +152 -0
  50. package/dist/backend/routes.js.map +1 -0
  51. package/dist/backend/services/delivery-method-read-port.d.ts +25 -0
  52. package/dist/backend/services/delivery-method-read-port.d.ts.map +1 -0
  53. package/dist/backend/services/delivery-method-read-port.js +56 -0
  54. package/dist/backend/services/delivery-method-read-port.js.map +1 -0
  55. package/dist/backend/services/delivery-method-reconciler.d.ts +97 -0
  56. package/dist/backend/services/delivery-method-reconciler.d.ts.map +1 -0
  57. package/dist/backend/services/delivery-method-reconciler.js +157 -0
  58. package/dist/backend/services/delivery-method-reconciler.js.map +1 -0
  59. package/dist/backend/services/order-status-registry.port.d.ts +50 -0
  60. package/dist/backend/services/order-status-registry.port.d.ts.map +1 -0
  61. package/dist/backend/services/order-status-registry.port.js +45 -0
  62. package/dist/backend/services/order-status-registry.port.js.map +1 -0
  63. package/dist/backend/services/registry-singleton.d.ts +20 -0
  64. package/dist/backend/services/registry-singleton.d.ts.map +1 -0
  65. package/dist/backend/services/registry-singleton.js +21 -0
  66. package/dist/backend/services/registry-singleton.js.map +1 -0
  67. package/dist/backend/services/shipment-usage-guard.d.ts +31 -0
  68. package/dist/backend/services/shipment-usage-guard.d.ts.map +1 -0
  69. package/dist/backend/services/shipment-usage-guard.js +33 -0
  70. package/dist/backend/services/shipment-usage-guard.js.map +1 -0
  71. package/dist/backend/services/shipping-adapter-registry.d.ts +98 -0
  72. package/dist/backend/services/shipping-adapter-registry.d.ts.map +1 -0
  73. package/dist/backend/services/shipping-adapter-registry.js +92 -0
  74. package/dist/backend/services/shipping-adapter-registry.js.map +1 -0
  75. package/dist/backend/services/shipping-method-eligibility.d.ts +24 -0
  76. package/dist/backend/services/shipping-method-eligibility.d.ts.map +1 -0
  77. package/dist/backend/services/shipping-method-eligibility.js +46 -0
  78. package/dist/backend/services/shipping-method-eligibility.js.map +1 -0
  79. package/dist/install/index.d.ts +59 -0
  80. package/dist/install/index.d.ts.map +1 -0
  81. package/dist/install/index.js +59 -0
  82. package/dist/install/index.js.map +1 -0
  83. package/dist/manifest.d.ts +193 -0
  84. package/dist/manifest.d.ts.map +1 -0
  85. package/dist/manifest.js +185 -0
  86. package/dist/manifest.js.map +1 -0
  87. package/dist/migrations/20260611T140354_delivery_methods_shipping_methods_adapter_and_shipments.d.ts +30 -0
  88. package/dist/migrations/20260611T140354_delivery_methods_shipping_methods_adapter_and_shipments.d.ts.map +1 -0
  89. package/dist/migrations/20260611T140354_delivery_methods_shipping_methods_adapter_and_shipments.js +72 -0
  90. package/dist/migrations/20260611T140354_delivery_methods_shipping_methods_adapter_and_shipments.js.map +1 -0
  91. package/dist/migrations/20260611T140416_delivery_methods_fix_in_person_pickup_adapter.d.ts +24 -0
  92. package/dist/migrations/20260611T140416_delivery_methods_fix_in_person_pickup_adapter.d.ts.map +1 -0
  93. package/dist/migrations/20260611T140416_delivery_methods_fix_in_person_pickup_adapter.js +28 -0
  94. package/dist/migrations/20260611T140416_delivery_methods_fix_in_person_pickup_adapter.js.map +1 -0
  95. package/dist/migrations/20260912T094638_delivery_methods_sales_channel_delivery_methods.d.ts +27 -0
  96. package/dist/migrations/20260912T094638_delivery_methods_sales_channel_delivery_methods.d.ts.map +1 -0
  97. package/dist/migrations/20260912T094638_delivery_methods_sales_channel_delivery_methods.js +44 -0
  98. package/dist/migrations/20260912T094638_delivery_methods_sales_channel_delivery_methods.js.map +1 -0
  99. package/dist/migrations/index.d.ts +29 -0
  100. package/dist/migrations/index.d.ts.map +1 -0
  101. package/dist/migrations/index.js +33 -0
  102. package/dist/migrations/index.js.map +1 -0
  103. package/dist/ports/index.d.ts +129 -0
  104. package/dist/ports/index.d.ts.map +1 -0
  105. package/dist/ports/index.js +2 -0
  106. package/dist/ports/index.js.map +1 -0
  107. package/docs/delivery_methods.md +197 -0
  108. package/i18n/en.json +5 -0
  109. package/i18n/pl.json +5 -0
  110. package/package.json +100 -0
  111. package/tailwind.css +14 -0
@@ -0,0 +1,61 @@
1
+ import { type DeliveryMethodUpsert } from '@endora-commerce/contracts';
2
+ import type { Command } from '@endora-commerce/platform/commands';
3
+ import { DeliveryMethod } from '../entities/delivery-method.entity.js';
4
+ /**
5
+ * Delivery-method configuration as Commands — issue #125, Principle XIII.
6
+ *
7
+ * The mirror image of `payment_methods/commands/payment-method.commands.ts`,
8
+ * and deliberately so: the two surfaces are the same shape, an operator edits
9
+ * them from the same screen family, and a reviewer who has read one should not
10
+ * have to re-derive the other. What a shop charges for shipping, and which order
11
+ * status a delivery result moves an order to, is operator configuration with
12
+ * money behind it — so it runs on the bus rather than auditing by hand.
13
+ *
14
+ * **Not `reversible`**, for the reason the payment twin gives: `reversible`
15
+ * marks the commands wired into feature 054's stored-revert undo, and a single
16
+ * configuration row has no such surface. The audit row's `stateBefore` is what
17
+ * an operator restores from, by re-sending it.
18
+ */
19
+ /** The audit projection of a delivery method — configuration only. */
20
+ export declare function deliveryMethodAuditState(row: DeliveryMethod): Record<string, unknown>;
21
+ export interface UpsertDeliveryMethodInput {
22
+ readonly code: string;
23
+ readonly body: DeliveryMethodUpsert;
24
+ /**
25
+ * The id of the row carrying this code when the caller looked, or `null` for a
26
+ * creation — see the payment twin: it fixes the action name and the audited
27
+ * object id, so the transaction refuses a row that appeared in between.
28
+ */
29
+ readonly existingId: string | null;
30
+ }
31
+ export interface UpsertDeliveryMethodResult {
32
+ readonly method: DeliveryMethod;
33
+ /** True when the transaction created the row — the caller binds a new method to a channel. */
34
+ readonly created: boolean;
35
+ }
36
+ export declare function makeUpsertDeliveryMethodCommand(input: UpsertDeliveryMethodInput): Command<UpsertDeliveryMethodResult>;
37
+ /**
38
+ * How many shipments reference a delivery method — supplied by the caller
39
+ * because the rows belong to `shipments` (feature 075, the `delivery_methods`
40
+ * shard).
41
+ *
42
+ * This used to be a `select count(*) from "shipments"` written here, on the
43
+ * Command's own transaction. The comment above it said that made the guard and
44
+ * the delete "the same moment", and the claim did not survive being looked at:
45
+ * neither statement takes a lock, so a shipment created between the count and
46
+ * the commit was always possible. What the statement really was is a read of
47
+ * another module's table that named no import specifier, and so crossed the
48
+ * boundary invisibly until D-87 gave `check:module-boundary` a second
49
+ * predicate.
50
+ *
51
+ * The owner answers on its own `EntityManager`, outside this transaction. That
52
+ * costs nothing here: `shipments` is a table this transaction never writes, so
53
+ * there is no write of its own for the read to be blind to.
54
+ *
55
+ * @see `services/shipment-usage-guard.ts` for what happens when `shipments` is
56
+ * switched off — the answer is a refusal, and it is the caller's to make
57
+ * before it resolves anything.
58
+ */
59
+ export type ShipmentUsageCounter = (deliveryMethodId: string) => Promise<number>;
60
+ export declare function makeDeleteDeliveryMethodCommand(id: string, countShipmentsForMethod: ShipmentUsageCounter): Command<void>;
61
+ //# sourceMappingURL=delivery-method.commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-method.commands.d.ts","sourceRoot":"","sources":["../../../src/backend/commands/delivery-method.commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AAEH,sEAAsE;AACtE,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYrF;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAuDrC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEjF,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,MAAM,EACV,uBAAuB,EAAE,oBAAoB,GAC5C,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,107 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { ERROR_CODES } from '@endora-commerce/contracts';
3
+ import { HttpError } from '@endora-commerce/platform/http';
4
+ import { DeliveryMethod } from '../entities/delivery-method.entity.js';
5
+ /**
6
+ * Delivery-method configuration as Commands — issue #125, Principle XIII.
7
+ *
8
+ * The mirror image of `payment_methods/commands/payment-method.commands.ts`,
9
+ * and deliberately so: the two surfaces are the same shape, an operator edits
10
+ * them from the same screen family, and a reviewer who has read one should not
11
+ * have to re-derive the other. What a shop charges for shipping, and which order
12
+ * status a delivery result moves an order to, is operator configuration with
13
+ * money behind it — so it runs on the bus rather than auditing by hand.
14
+ *
15
+ * **Not `reversible`**, for the reason the payment twin gives: `reversible`
16
+ * marks the commands wired into feature 054's stored-revert undo, and a single
17
+ * configuration row has no such surface. The audit row's `stateBefore` is what
18
+ * an operator restores from, by re-sending it.
19
+ */
20
+ /** The audit projection of a delivery method — configuration only. */
21
+ export function deliveryMethodAuditState(row) {
22
+ return {
23
+ id: row.id,
24
+ code: row.code,
25
+ name: row.name,
26
+ cost: row.cost,
27
+ currency: row.currency,
28
+ adapter: row.adapter,
29
+ status: row.status,
30
+ statusOnSuccess: row.statusOnSuccess,
31
+ statusOnFailure: row.statusOnFailure,
32
+ };
33
+ }
34
+ export function makeUpsertDeliveryMethodCommand(input) {
35
+ const { body } = input;
36
+ const id = input.existingId ?? randomUUID();
37
+ return {
38
+ action: input.existingId === null ? 'delivery_method.create' : 'delivery_method.update',
39
+ objectType: 'delivery_method',
40
+ objectId: id,
41
+ run: async ({ em }) => {
42
+ let row = await em.findOne(DeliveryMethod, { code: input.code });
43
+ if (row !== null && input.existingId === null) {
44
+ throw new HttpError(409, ERROR_CODES.VERSION_CONFLICT, `Delivery method "${input.code}" was created by someone else. Reload and try again.`);
45
+ }
46
+ const before = row === null ? null : deliveryMethodAuditState(row);
47
+ // The adapter is set at registration time and rarely changed; preserve an
48
+ // existing row's adapter unless the body explicitly overrides it. A new
49
+ // row defaults its adapter to the code. Resolved here rather than in the
50
+ // caller so it reads the row the transaction sees.
51
+ const adapter = body.adapter ?? row?.adapter ?? input.code;
52
+ if (row) {
53
+ row.name = body.name;
54
+ row.cost = body.cost.toFixed(2);
55
+ row.currency = body.currency;
56
+ row.adapter = adapter;
57
+ if (body.status !== undefined)
58
+ row.status = body.status;
59
+ if (body.statusOnSuccess !== undefined)
60
+ row.statusOnSuccess = body.statusOnSuccess;
61
+ if (body.statusOnFailure !== undefined)
62
+ row.statusOnFailure = body.statusOnFailure;
63
+ }
64
+ else {
65
+ row = em.create(DeliveryMethod, {
66
+ id,
67
+ code: input.code,
68
+ name: body.name,
69
+ cost: body.cost.toFixed(2),
70
+ currency: body.currency,
71
+ adapter,
72
+ status: body.status ?? 'active',
73
+ statusOnSuccess: body.statusOnSuccess ?? 'shipment_sent',
74
+ statusOnFailure: body.statusOnFailure ?? 'processing',
75
+ });
76
+ em.persist(row);
77
+ }
78
+ await em.flush();
79
+ return {
80
+ result: { method: row, created: before === null },
81
+ before,
82
+ after: deliveryMethodAuditState(row),
83
+ };
84
+ },
85
+ };
86
+ }
87
+ export function makeDeleteDeliveryMethodCommand(id, countShipmentsForMethod) {
88
+ return {
89
+ action: 'delivery_method.delete',
90
+ objectType: 'delivery_method',
91
+ objectId: id,
92
+ run: async ({ em }) => {
93
+ const row = await em.findOne(DeliveryMethod, { id });
94
+ if (!row) {
95
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Delivery method not found.');
96
+ }
97
+ const referencing = await countShipmentsForMethod(row.id);
98
+ if (referencing > 0) {
99
+ throw new HttpError(409, ERROR_CODES.VALIDATION_FAILED, `Cannot delete delivery method: ${referencing} shipment(s) reference it. Set status to "inactive" instead.`);
100
+ }
101
+ const before = deliveryMethodAuditState(row);
102
+ await em.removeAndFlush(row);
103
+ return { result: undefined, before, after: null };
104
+ },
105
+ };
106
+ }
107
+ //# sourceMappingURL=delivery-method.commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-method.commands.js","sourceRoot":"","sources":["../../../src/backend/commands/delivery-method.commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAA6B,MAAM,4BAA4B,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AAEH,sEAAsE;AACtE,MAAM,UAAU,wBAAwB,CAAC,GAAmB;IAC1D,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI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G,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE;gBACjD,MAAM;gBACN,KAAK,EAAE,wBAAwB,CAAC,GAAG,CAAC;aACrC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AA0BD,MAAM,UAAU,+BAA+B,CAC7C,EAAU,EACV,uBAA6C;IAE7C,OAAO;QACL,MAAM,EAAE,wBAAwB;QAChC,UAAU,EAAE,iBAAiB;QAC7B,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;YAChF,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC1D,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,IAAI,SAAS,CACjB,GAAG,EACH,WAAW,CAAC,iBAAiB,EAC7B,kCAAkC,WAAW,8DAA8D,CAC5G,CAAC;YACJ,CAAC;YACD,MAAM,MAAM,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;YAC7C,MAAM,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Withdraw `delivery_methods`' demo data (feature 113, T220 — contract §2.5).
3
+ *
4
+ * By the fixed codes `seed` assigns. This replaces `delivery_methods`' line in
5
+ * the host's 29-table `truncate … cascade`, which took every row in the table —
6
+ * an operator's own methods included, and, through the cascade, the sales
7
+ * channel and organisation bindings that pointed at them.
8
+ */
9
+ import type { DemoResetResult, ModuleDemoContext } from '@endora-commerce/contracts';
10
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
11
+ export declare function resetDemo(context: ModuleDemoContext<ModuleContext>): Promise<DemoResetResult>;
12
+ //# sourceMappingURL=reset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/reset.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAStE,wBAAsB,SAAS,CAC7B,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,CAS1B"}
@@ -0,0 +1,13 @@
1
+ import { DeliveryMethod } from '../entities/delivery-method.entity.js';
2
+ import { DEMO_DELIVERY_METHOD_CODES } from './rows.js';
3
+ export async function resetDemo(context) {
4
+ // command-coverage-ignore: the withdrawal half of the demo data above. Same
5
+ // entry point, same `mustBeNonProduction()` guard, same absence of an
6
+ // operator to attribute the write to (contract §2.7).
7
+ const em = context.ctx.cradle().emFactory();
8
+ const removed = await em.nativeDelete(DeliveryMethod, {
9
+ code: { $in: [...DEMO_DELIVERY_METHOD_CODES] },
10
+ });
11
+ return { removed: [{ entity: 'DeliveryMethod', count: removed }] };
12
+ }
13
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/backend/demo/reset.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAMvD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAAyC;IAEzC,4EAA4E;IAC5E,sEAAsE;IACtE,sDAAsD;IACtD,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAA6B,CAAC,SAAS,EAAE,CAAC;IACvE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE;QACpD,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,0BAA0B,CAAC,EAAE;KAC/C,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The delivery method this module's demo data creates (feature 113, T220).
3
+ *
4
+ * One place holding the data, imported by both bodies: `seed.ts` creates these
5
+ * rows and `reset.ts` withdraws exactly them, by the `code` they are keyed on
6
+ * (contract §2.5). The values are the host seed's verbatim; the frozen copy
7
+ * that was the parity comparison's reference side went with the corpus at
8
+ * T226, and `test/integration/demo/demo-shop.test.ts`' recorded delta is what
9
+ * holds them now.
10
+ */
11
+ /** One demo delivery method, in `DeliveryMethod`'s own field names. */
12
+ export interface DemoDeliveryMethodRow {
13
+ readonly code: string;
14
+ /** Per-language, covering every shipped language (contract §2.6). */
15
+ readonly name: Readonly<Record<string, string>>;
16
+ readonly cost: string;
17
+ readonly currency: string;
18
+ /** The shipping adapter backing this method (feature 035). */
19
+ readonly adapter: string;
20
+ }
21
+ export declare const DEMO_DELIVERY_METHOD_ROWS: readonly DemoDeliveryMethodRow[];
22
+ /** The codes `reset` withdraws — derived from the rows, never a second list. */
23
+ export declare const DEMO_DELIVERY_METHOD_CODES: readonly string[];
24
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,yBAAyB,EAAE,SAAS,qBAAqB,EAQrE,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAEvD,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The delivery method this module's demo data creates (feature 113, T220).
3
+ *
4
+ * One place holding the data, imported by both bodies: `seed.ts` creates these
5
+ * rows and `reset.ts` withdraws exactly them, by the `code` they are keyed on
6
+ * (contract §2.5). The values are the host seed's verbatim; the frozen copy
7
+ * that was the parity comparison's reference side went with the corpus at
8
+ * T226, and `test/integration/demo/demo-shop.test.ts`' recorded delta is what
9
+ * holds them now.
10
+ */
11
+ export const DEMO_DELIVERY_METHOD_ROWS = [
12
+ {
13
+ code: 'in_person_pickup',
14
+ name: { 'en-US': 'In-person pickup', 'pl-PL': 'Odbior osobisty' },
15
+ cost: '0',
16
+ currency: 'PLN',
17
+ adapter: 'personal_pickup',
18
+ },
19
+ ];
20
+ /** The codes `reset` withdraws — derived from the rows, never a second list. */
21
+ export const DEMO_DELIVERY_METHOD_CODES = DEMO_DELIVERY_METHOD_ROWS.map((row) => row.code);
22
+ //# sourceMappingURL=rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.js","sourceRoot":"","sources":["../../../src/backend/demo/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,MAAM,CAAC,MAAM,yBAAyB,GAAqC;IACzE;QACE,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,EAAE;QACjE,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,iBAAiB;KAC3B;CACF,CAAC;AAEF,gFAAgF;AAChF,MAAM,CAAC,MAAM,0BAA0B,GAAsB,yBAAyB,CAAC,GAAG,CACxF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAClB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `delivery_methods`' demo data (feature 113, T220 — contract §2).
3
+ *
4
+ * The free in-person pickup the demo shop checks out with, in the module that
5
+ * owns the table. It writes `delivery_methods` and nothing else (§2.1), reads
6
+ * no other module's table and resolves no port (§2.2), so declaring it added no
7
+ * entry to this module's manifest `dependencies` (§2.3).
8
+ *
9
+ * Idempotent by an existence probe on the natural key (§2.4).
10
+ */
11
+ import type { DemoSeedResult, ModuleDemoContext } from '@endora-commerce/contracts';
12
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
13
+ export declare function seedDemo(context: ModuleDemoContext<ModuleContext>): Promise<DemoSeedResult>;
14
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAStE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CAyBzB"}
@@ -0,0 +1,28 @@
1
+ import { DeliveryMethod } from '../entities/delivery-method.entity.js';
2
+ import { DEMO_DELIVERY_METHOD_ROWS } from './rows.js';
3
+ export async function seedDemo(context) {
4
+ // command-coverage-ignore: demo data, reached only by `endora demo seed`,
5
+ // whose entry point calls `mustBeNonProduction()` as its first statement and
6
+ // outside every `try` (contract §2.7, §3.3). The guard is the enforcement:
7
+ // this write has no operator, no tenant and no audit reader.
8
+ const em = context.ctx.cradle().emFactory();
9
+ for (const row of DEMO_DELIVERY_METHOD_ROWS) {
10
+ const existing = await em.findOne(DeliveryMethod, { code: row.code });
11
+ // Present already: left as it is — see `taxes`' body for why `seed` does
12
+ // not overwrite what an operator may have edited.
13
+ if (existing)
14
+ continue;
15
+ em.create(DeliveryMethod, {
16
+ code: row.code,
17
+ name: { ...row.name },
18
+ cost: row.cost,
19
+ currency: row.currency,
20
+ adapter: row.adapter,
21
+ });
22
+ }
23
+ await em.flush();
24
+ return {
25
+ created: [{ entity: 'DeliveryMethod', count: DEMO_DELIVERY_METHOD_ROWS.length }],
26
+ };
27
+ }
28
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../../src/backend/demo/seed.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAMtD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAyC;IAEzC,0EAA0E;IAC1E,6EAA6E;IAC7E,2EAA2E;IAC3E,6DAA6D;IAC7D,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAA6B,CAAC,SAAS,EAAE,CAAC;IAEvE,KAAK,MAAM,GAAG,IAAI,yBAAyB,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,yEAAyE;QACzE,kDAAkD;QAClD,IAAI,QAAQ;YAAE,SAAS;QACvB,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE;YACxB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,EAAE,GAAG,GAAG,CAAC,IAAI,EAAE;YACrB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;IAEjB,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,yBAAyB,CAAC,MAAM,EAAE,CAAC;KACjF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { OptionalProps } from '@mikro-orm/core';
2
+ /**
3
+ * DeliveryMethod — a configurable shipping option (courier, pickup, pallet).
4
+ * Referenced by Order at creation time; the cost is captured as a snapshot
5
+ * on the Order so later changes to this row do not rewrite history.
6
+ */
7
+ export declare class DeliveryMethod {
8
+ [OptionalProps]?: 'id' | 'createdAt' | 'updatedAt' | 'status' | 'cost' | 'adapter' | 'statusOnSuccess' | 'statusOnFailure';
9
+ id: string;
10
+ code: string;
11
+ name: Record<string, string>;
12
+ /** Flat surcharge for choosing this method — the spec's `price` (feature 035). */
13
+ cost: string;
14
+ currency: string;
15
+ status: 'active' | 'inactive';
16
+ /**
17
+ * Registry key of the ShippingAdapter realising the logic (feature 035).
18
+ * Backfilled from `code` for rows predating the adapter framework. Defaults
19
+ * to '' so generic insert paths still work; an empty adapter never resolves
20
+ * to a registered adapter, so the row is simply not offered (FR-003).
21
+ */
22
+ adapter: string;
23
+ /** Order-status reference applied when shipment generation succeeds. */
24
+ statusOnSuccess: string;
25
+ /** Order-status reference applied when shipment generation fails. */
26
+ statusOnFailure: string;
27
+ createdAt: Date;
28
+ updatedAt: Date;
29
+ }
30
+ //# sourceMappingURL=delivery-method.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-method.entity.d.ts","sourceRoot":"","sources":["../../../src/backend/entities/delivery-method.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAItF;;;;GAIG;AACH,qBAEa,cAAc;IACzB,CAAC,aAAa,CAAC,CAAC,EACZ,IAAI,GACJ,WAAW,GACX,WAAW,GACX,QAAQ,GACR,MAAM,GACN,SAAS,GACT,iBAAiB,GACjB,iBAAiB,CAAC;IAGtB,EAAE,EAAE,MAAM,CAAgB;IAI1B,IAAI,EAAG,MAAM,CAAC;IAGd,IAAI,EAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B,kFAAkF;IAElF,IAAI,EAAE,MAAM,CAAO;IAGnB,QAAQ,EAAG,MAAM,CAAC;IAGlB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAY;IAEzC;;;;;OAKG;IAEH,OAAO,EAAE,MAAM,CAAM;IAErB,wEAAwE;IAExE,eAAe,EAAE,MAAM,CAAmB;IAE1C,qEAAqE;IAErE,eAAe,EAAE,MAAM,CAAgB;IAGvC,SAAS,EAAE,IAAI,CAAc;IAG7B,SAAS,EAAE,IAAI,CAAc;CAC9B"}
@@ -0,0 +1,91 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Entity, OptionalProps, PrimaryKey, Property, Unique } from '@mikro-orm/core';
11
+ import { GlobalEntity } from '@endora-commerce/platform/tenancy';
12
+ import { randomUUID } from 'crypto';
13
+ /**
14
+ * DeliveryMethod — a configurable shipping option (courier, pickup, pallet).
15
+ * Referenced by Order at creation time; the cost is captured as a snapshot
16
+ * on the Order so later changes to this row do not rewrite history.
17
+ */
18
+ let DeliveryMethod = class DeliveryMethod {
19
+ [OptionalProps];
20
+ id = randomUUID();
21
+ code;
22
+ name;
23
+ /** Flat surcharge for choosing this method — the spec's `price` (feature 035). */
24
+ cost = '0';
25
+ currency;
26
+ status = 'active';
27
+ /**
28
+ * Registry key of the ShippingAdapter realising the logic (feature 035).
29
+ * Backfilled from `code` for rows predating the adapter framework. Defaults
30
+ * to '' so generic insert paths still work; an empty adapter never resolves
31
+ * to a registered adapter, so the row is simply not offered (FR-003).
32
+ */
33
+ adapter = '';
34
+ /** Order-status reference applied when shipment generation succeeds. */
35
+ statusOnSuccess = 'shipment_sent';
36
+ /** Order-status reference applied when shipment generation fails. */
37
+ statusOnFailure = 'processing';
38
+ createdAt = new Date();
39
+ updatedAt = new Date();
40
+ };
41
+ __decorate([
42
+ PrimaryKey({ type: 'uuid' }),
43
+ __metadata("design:type", String)
44
+ ], DeliveryMethod.prototype, "id", void 0);
45
+ __decorate([
46
+ Property({ type: 'string', length: 64 }),
47
+ Unique(),
48
+ __metadata("design:type", String)
49
+ ], DeliveryMethod.prototype, "code", void 0);
50
+ __decorate([
51
+ Property({ type: 'json' }),
52
+ __metadata("design:type", Object)
53
+ ], DeliveryMethod.prototype, "name", void 0);
54
+ __decorate([
55
+ Property({ type: 'decimal', precision: 12, scale: 2 }),
56
+ __metadata("design:type", String)
57
+ ], DeliveryMethod.prototype, "cost", void 0);
58
+ __decorate([
59
+ Property({ type: 'string', length: 3 }),
60
+ __metadata("design:type", String)
61
+ ], DeliveryMethod.prototype, "currency", void 0);
62
+ __decorate([
63
+ Property({ type: 'string', length: 16 }),
64
+ __metadata("design:type", String)
65
+ ], DeliveryMethod.prototype, "status", void 0);
66
+ __decorate([
67
+ Property({ type: 'string', length: 64 }),
68
+ __metadata("design:type", String)
69
+ ], DeliveryMethod.prototype, "adapter", void 0);
70
+ __decorate([
71
+ Property({ type: 'string', length: 64 }),
72
+ __metadata("design:type", String)
73
+ ], DeliveryMethod.prototype, "statusOnSuccess", void 0);
74
+ __decorate([
75
+ Property({ type: 'string', length: 64 }),
76
+ __metadata("design:type", String)
77
+ ], DeliveryMethod.prototype, "statusOnFailure", void 0);
78
+ __decorate([
79
+ Property({ type: 'datetime', onCreate: () => new Date() }),
80
+ __metadata("design:type", Date)
81
+ ], DeliveryMethod.prototype, "createdAt", void 0);
82
+ __decorate([
83
+ Property({ type: 'datetime', onUpdate: () => new Date() }),
84
+ __metadata("design:type", Date)
85
+ ], DeliveryMethod.prototype, "updatedAt", void 0);
86
+ DeliveryMethod = __decorate([
87
+ GlobalEntity(),
88
+ Entity({ tableName: 'delivery_methods' })
89
+ ], DeliveryMethod);
90
+ export { DeliveryMethod };
91
+ //# sourceMappingURL=delivery-method.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-method.entity.js","sourceRoot":"","sources":["../../../src/backend/entities/delivery-method.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;GAIG;AAGI,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,CAAC,aAAa,CAAC,CAQO;IAGtB,EAAE,GAAW,UAAU,EAAE,CAAC;IAI1B,IAAI,CAAU;IAGd,IAAI,CAA0B;IAE9B,kFAAkF;IAElF,IAAI,GAAW,GAAG,CAAC;IAGnB,QAAQ,CAAU;IAGlB,MAAM,GAA0B,QAAQ,CAAC;IAEzC;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AE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAChD,IAAI;iDAAc;AApDlB,cAAc;IAF1B,YAAY,EAAE;IACd,MAAM,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;GAC7B,cAAc,CAqD1B"}
@@ -0,0 +1,88 @@
1
+ import type { FastifyRequest } from 'fastify';
2
+ import type { EntityManager } from '@mikro-orm/postgresql';
3
+ import type { ChannelMemberEntityType } from '@endora-commerce/contracts';
4
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
5
+ import type { CommandBus } from '@endora-commerce/platform/commands';
6
+ import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
7
+ import type { SalesChannelMembershipPort } from '@endora-commerce/platform/kernel';
8
+ import { EnumOrderStatusRegistry } from './services/order-status-registry.port.js';
9
+ import { shippingAdapterRegistry } from './services/registry-singleton.js';
10
+ import { ShippingMethodEligibilityService } from './services/shipping-method-eligibility.js';
11
+ import { DeliveryMethod } from './entities/delivery-method.entity.js';
12
+ /**
13
+ * `delivery_methods` — the payment twin's mirror image (feature 072, wave 1,
14
+ * T095).
15
+ *
16
+ * Converted alongside `payment_methods` rather than after it. The two are
17
+ * mounted from the same forty lines of `orders/plugin.ts` and share the same
18
+ * registry, eligibility and order-status shape, so converting one and not the
19
+ * other would leave `commerceModule` half-rewired — an intermediate state that
20
+ * costs more to hold than the pair costs to do together.
21
+ *
22
+ * One asymmetry survives the pairing, and it is not cosmetic: this module's
23
+ * built-in adapters live in **its own** `adapters/built-in-adapters.ts`, while
24
+ * the payment built-ins live in `payments`. So this module seeds its own and
25
+ * `payment_methods` does not — a root contributes those. Seeding is done in the
26
+ * factory and is idempotent because a provider module's plugin may already have
27
+ * registered into the same instance.
28
+ *
29
+ * The registry stays the process singleton for the reason spelled out in
30
+ * `payment_methods/backend.ts`: replacing it while the provider modules still
31
+ * import it directly would create a second registry, which is the defect this
32
+ * wave keeps removing rather than adding.
33
+ */
34
+ export interface DeliveryMethodsCradle {
35
+ /**
36
+ * Feature 120 (FR-015) — the platform's channel-bridge registry, resolved by
37
+ * **container name** rather than imported. The shape is the narrow one this
38
+ * module needs, which is what `ctx.cradle<C>()` asks an author to declare;
39
+ * the registry itself is the kernel's and is published on no barrel.
40
+ */
41
+ readonly salesChannelBridgeRegistry: {
42
+ register(bridge: {
43
+ entityType: ChannelMemberEntityType;
44
+ table: string;
45
+ entityIdColumn: string;
46
+ }): void;
47
+ };
48
+ readonly emFactory: () => EntityManager;
49
+ readonly requireAdmin: RequireAdminFactory;
50
+ readonly commandBus: CommandBus;
51
+ readonly salesChannelMembershipPort: SalesChannelMembershipPort | undefined;
52
+ /** The two halves the allow-list is composed from — see the payment twin (T138). */
53
+ readonly customerOrganizationIdResolver: (req: FastifyRequest) => string | null;
54
+ readonly organizationRestrictionPort: {
55
+ allowedIdsFor(organizationId: string, kind: 'paymentMethodIds' | 'deliveryMethodIds' | 'warehouseIds'): Promise<string[] | null>;
56
+ };
57
+ readonly shippingAdapterRegistry: typeof shippingAdapterRegistry;
58
+ readonly shippingMethodEligibility: ShippingMethodEligibilityService;
59
+ readonly shippingOrderStatusRegistry: EnumOrderStatusRegistry;
60
+ }
61
+ export declare function registerModule(ctx: ModuleContext): void;
62
+ /**
63
+ * The module's persisted entity classes, on the `./backend` subpath, as one
64
+ * array and **no named class export** (D-168).
65
+ *
66
+ * This is the shape the platform reads when the package is *installed*: the
67
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
68
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
69
+ * which is the third source of `check:module-boundary`'s `table→owner` map and
70
+ * the package pass of `check-entity-tenant-classification`. A missing array is
71
+ * answered with `[]` — zero entities registered, no error anywhere.
72
+ */
73
+ export declare const entities: (typeof DeliveryMethod)[];
74
+ /**
75
+ * The sales-channel membership bridge this module owns (feature 120, FR-015).
76
+ *
77
+ * Exported as well as registered because the owning module is the only honest
78
+ * source for it: a caller that composes no platform — the bare-database test
79
+ * harness, which constructs the kernel's membership service directly — declares
80
+ * these from here rather than from a list of nine it keeps itself, which is
81
+ * exactly the total map this feature deleted.
82
+ */
83
+ export declare const salesChannelBridges: ReadonlyArray<{
84
+ readonly entityType: ChannelMemberEntityType;
85
+ readonly table: string;
86
+ readonly entityIdColumn: string;
87
+ }>;
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAMnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAE7F,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,0BAA0B,EAAE;QACnC,QAAQ,CAAC,MAAM,EAAE;YACf,UAAU,EAAE,uBAAuB,CAAC;YACpC,KAAK,EAAE,MAAM,CAAC;YACd,cAAc,EAAE,MAAM,CAAC;SACxB,GAAG,IAAI,CAAC;KACV,CA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