@endora-commerce/mod-price-lists 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 (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/admin/components/ApplicationRuleBuilder.d.ts +24 -0
  4. package/dist/admin/components/ApplicationRuleBuilder.d.ts.map +1 -0
  5. package/dist/admin/components/ApplicationRuleBuilder.js +249 -0
  6. package/dist/admin/components/ApplicationRuleBuilder.js.map +1 -0
  7. package/dist/admin/components/BracketGrid.d.ts +29 -0
  8. package/dist/admin/components/BracketGrid.d.ts.map +1 -0
  9. package/dist/admin/components/BracketGrid.js +252 -0
  10. package/dist/admin/components/BracketGrid.js.map +1 -0
  11. package/dist/admin/components/DisplayModeOverrideRow.d.ts +46 -0
  12. package/dist/admin/components/DisplayModeOverrideRow.d.ts.map +1 -0
  13. package/dist/admin/components/DisplayModeOverrideRow.js +109 -0
  14. package/dist/admin/components/DisplayModeOverrideRow.js.map +1 -0
  15. package/dist/admin/components/LinkedPriceListsPanel.d.ts +55 -0
  16. package/dist/admin/components/LinkedPriceListsPanel.d.ts.map +1 -0
  17. package/dist/admin/components/LinkedPriceListsPanel.js +131 -0
  18. package/dist/admin/components/LinkedPriceListsPanel.js.map +1 -0
  19. package/dist/admin/index.d.ts +34 -0
  20. package/dist/admin/index.d.ts.map +1 -0
  21. package/dist/admin/index.js +119 -0
  22. package/dist/admin/index.js.map +1 -0
  23. package/dist/admin/pages/DisplayModeOverridesPage.d.ts +25 -0
  24. package/dist/admin/pages/DisplayModeOverridesPage.d.ts.map +1 -0
  25. package/dist/admin/pages/DisplayModeOverridesPage.js +266 -0
  26. package/dist/admin/pages/DisplayModeOverridesPage.js.map +1 -0
  27. package/dist/admin/pages/PriceListDetailPage.d.ts +23 -0
  28. package/dist/admin/pages/PriceListDetailPage.d.ts.map +1 -0
  29. package/dist/admin/pages/PriceListDetailPage.js +421 -0
  30. package/dist/admin/pages/PriceListDetailPage.js.map +1 -0
  31. package/dist/admin/pages/PriceListsPage.d.ts +17 -0
  32. package/dist/admin/pages/PriceListsPage.d.ts.map +1 -0
  33. package/dist/admin/pages/PriceListsPage.js +198 -0
  34. package/dist/admin/pages/PriceListsPage.js.map +1 -0
  35. package/dist/admin/zones/CategoryDisplayMode.d.ts +27 -0
  36. package/dist/admin/zones/CategoryDisplayMode.d.ts.map +1 -0
  37. package/dist/admin/zones/CategoryDisplayMode.js +11 -0
  38. package/dist/admin/zones/CategoryDisplayMode.js.map +1 -0
  39. package/dist/admin/zones/OrganizationDisplayMode.d.ts +36 -0
  40. package/dist/admin/zones/OrganizationDisplayMode.d.ts.map +1 -0
  41. package/dist/admin/zones/OrganizationDisplayMode.js +12 -0
  42. package/dist/admin/zones/OrganizationDisplayMode.js.map +1 -0
  43. package/dist/admin/zones/ProductLinkedPriceLists.d.ts +16 -0
  44. package/dist/admin/zones/ProductLinkedPriceLists.d.ts.map +1 -0
  45. package/dist/admin/zones/ProductLinkedPriceLists.js +7 -0
  46. package/dist/admin/zones/ProductLinkedPriceLists.js.map +1 -0
  47. package/dist/backend/entities/price-display-mode-override.entity.d.ts +23 -0
  48. package/dist/backend/entities/price-display-mode-override.entity.d.ts.map +1 -0
  49. package/dist/backend/entities/price-display-mode-override.entity.js +58 -0
  50. package/dist/backend/entities/price-display-mode-override.entity.js.map +1 -0
  51. package/dist/backend/entities/price-list-price-bracket.entity.d.ts +26 -0
  52. package/dist/backend/entities/price-list-price-bracket.entity.d.ts.map +1 -0
  53. package/dist/backend/entities/price-list-price-bracket.entity.js +73 -0
  54. package/dist/backend/entities/price-list-price-bracket.entity.js.map +1 -0
  55. package/dist/backend/entities/price-list-product.entity.d.ts +15 -0
  56. package/dist/backend/entities/price-list-product.entity.d.ts.map +1 -0
  57. package/dist/backend/entities/price-list-product.entity.js +43 -0
  58. package/dist/backend/entities/price-list-product.entity.js.map +1 -0
  59. package/dist/backend/entities/price-list.entity.d.ts +34 -0
  60. package/dist/backend/entities/price-list.entity.d.ts.map +1 -0
  61. package/dist/backend/entities/price-list.entity.js +115 -0
  62. package/dist/backend/entities/price-list.entity.js.map +1 -0
  63. package/dist/backend/index.d.ts +125 -0
  64. package/dist/backend/index.d.ts.map +1 -0
  65. package/dist/backend/index.js +179 -0
  66. package/dist/backend/index.js.map +1 -0
  67. package/dist/backend/plugin.d.ts +68 -0
  68. package/dist/backend/plugin.d.ts.map +1 -0
  69. package/dist/backend/plugin.js +88 -0
  70. package/dist/backend/plugin.js.map +1 -0
  71. package/dist/backend/routes.d.ts +40 -0
  72. package/dist/backend/routes.d.ts.map +1 -0
  73. package/dist/backend/routes.js +447 -0
  74. package/dist/backend/routes.js.map +1 -0
  75. package/dist/backend/routes.storefront.d.ts +47 -0
  76. package/dist/backend/routes.storefront.d.ts.map +1 -0
  77. package/dist/backend/routes.storefront.js +131 -0
  78. package/dist/backend/routes.storefront.js.map +1 -0
  79. package/dist/backend/services/application-rule-evaluator.d.ts +25 -0
  80. package/dist/backend/services/application-rule-evaluator.d.ts.map +1 -0
  81. package/dist/backend/services/application-rule-evaluator.js +2 -0
  82. package/dist/backend/services/application-rule-evaluator.js.map +1 -0
  83. package/dist/backend/services/audit-references.d.ts +11 -0
  84. package/dist/backend/services/audit-references.d.ts.map +1 -0
  85. package/dist/backend/services/audit-references.js +23 -0
  86. package/dist/backend/services/audit-references.js.map +1 -0
  87. package/dist/backend/services/default-price-list-migration.d.ts +70 -0
  88. package/dist/backend/services/default-price-list-migration.d.ts.map +1 -0
  89. package/dist/backend/services/default-price-list-migration.js +177 -0
  90. package/dist/backend/services/default-price-list-migration.js.map +1 -0
  91. package/dist/backend/services/display-mode-resolver.d.ts +78 -0
  92. package/dist/backend/services/display-mode-resolver.d.ts.map +1 -0
  93. package/dist/backend/services/display-mode-resolver.js +71 -0
  94. package/dist/backend/services/display-mode-resolver.js.map +1 -0
  95. package/dist/backend/services/listing-price-chain.d.ts +26 -0
  96. package/dist/backend/services/listing-price-chain.d.ts.map +1 -0
  97. package/dist/backend/services/listing-price-chain.js +55 -0
  98. package/dist/backend/services/listing-price-chain.js.map +1 -0
  99. package/dist/backend/services/price-bracket-resolver.d.ts +24 -0
  100. package/dist/backend/services/price-bracket-resolver.d.ts.map +1 -0
  101. package/dist/backend/services/price-bracket-resolver.js +16 -0
  102. package/dist/backend/services/price-bracket-resolver.js.map +1 -0
  103. package/dist/backend/services/price-list-candidate-vector.d.ts +116 -0
  104. package/dist/backend/services/price-list-candidate-vector.d.ts.map +1 -0
  105. package/dist/backend/services/price-list-candidate-vector.js +133 -0
  106. package/dist/backend/services/price-list-candidate-vector.js.map +1 -0
  107. package/dist/backend/services/price-list-currency-reference.d.ts +12 -0
  108. package/dist/backend/services/price-list-currency-reference.d.ts.map +1 -0
  109. package/dist/backend/services/price-list-currency-reference.js +24 -0
  110. package/dist/backend/services/price-list-currency-reference.js.map +1 -0
  111. package/dist/backend/services/price-list-read-port.d.ts +29 -0
  112. package/dist/backend/services/price-list-read-port.d.ts.map +1 -0
  113. package/dist/backend/services/price-list-read-port.js +64 -0
  114. package/dist/backend/services/price-list-read-port.js.map +1 -0
  115. package/dist/backend/services/price-list-resolver.d.ts +26 -0
  116. package/dist/backend/services/price-list-resolver.d.ts.map +1 -0
  117. package/dist/backend/services/price-list-resolver.js +37 -0
  118. package/dist/backend/services/price-list-resolver.js.map +1 -0
  119. package/dist/backend/services/price-list-service.d.ts +431 -0
  120. package/dist/backend/services/price-list-service.d.ts.map +1 -0
  121. package/dist/backend/services/price-list-service.js +1238 -0
  122. package/dist/backend/services/price-list-service.js.map +1 -0
  123. package/dist/backend/services/price-list-status-worker.d.ts +28 -0
  124. package/dist/backend/services/price-list-status-worker.d.ts.map +1 -0
  125. package/dist/backend/services/price-list-status-worker.js +38 -0
  126. package/dist/backend/services/price-list-status-worker.js.map +1 -0
  127. package/dist/backend/services/pricing-cache.d.ts +53 -0
  128. package/dist/backend/services/pricing-cache.d.ts.map +1 -0
  129. package/dist/backend/services/pricing-cache.js +88 -0
  130. package/dist/backend/services/pricing-cache.js.map +1 -0
  131. package/dist/backend/services/pricing-service.d.ts +304 -0
  132. package/dist/backend/services/pricing-service.d.ts.map +1 -0
  133. package/dist/backend/services/pricing-service.interface.d.ts +151 -0
  134. package/dist/backend/services/pricing-service.interface.d.ts.map +1 -0
  135. package/dist/backend/services/pricing-service.interface.js +10 -0
  136. package/dist/backend/services/pricing-service.interface.js.map +1 -0
  137. package/dist/backend/services/pricing-service.js +803 -0
  138. package/dist/backend/services/pricing-service.js.map +1 -0
  139. package/dist/backend/services/unit-price-ordering.d.ts +121 -0
  140. package/dist/backend/services/unit-price-ordering.d.ts.map +1 -0
  141. package/dist/backend/services/unit-price-ordering.js +164 -0
  142. package/dist/backend/services/unit-price-ordering.js.map +1 -0
  143. package/dist/manifest.d.ts +218 -0
  144. package/dist/manifest.d.ts.map +1 -0
  145. package/dist/manifest.js +228 -0
  146. package/dist/manifest.js.map +1 -0
  147. package/dist/migrations/20260426T075235_price_lists_pricing_init.d.ts +24 -0
  148. package/dist/migrations/20260426T075235_price_lists_pricing_init.d.ts.map +1 -0
  149. package/dist/migrations/20260426T075235_price_lists_pricing_init.js +89 -0
  150. package/dist/migrations/20260426T075235_price_lists_pricing_init.js.map +1 -0
  151. package/dist/migrations/20260504T125655_price_lists_engine.d.ts +6 -0
  152. package/dist/migrations/20260504T125655_price_lists_engine.d.ts.map +1 -0
  153. package/dist/migrations/20260504T125655_price_lists_engine.js +319 -0
  154. package/dist/migrations/20260504T125655_price_lists_engine.js.map +1 -0
  155. package/dist/migrations/20260817T055457_price_lists_single_system_price_list.d.ts +15 -0
  156. package/dist/migrations/20260817T055457_price_lists_single_system_price_list.d.ts.map +1 -0
  157. package/dist/migrations/20260817T055457_price_lists_single_system_price_list.js +58 -0
  158. package/dist/migrations/20260817T055457_price_lists_single_system_price_list.js.map +1 -0
  159. package/dist/migrations/20260821T135907_price_lists_unit_price_amount_index.d.ts +40 -0
  160. package/dist/migrations/20260821T135907_price_lists_unit_price_amount_index.d.ts.map +1 -0
  161. package/dist/migrations/20260821T135907_price_lists_unit_price_amount_index.js +46 -0
  162. package/dist/migrations/20260821T135907_price_lists_unit_price_amount_index.js.map +1 -0
  163. package/dist/migrations/index.d.ts +30 -0
  164. package/dist/migrations/index.d.ts.map +1 -0
  165. package/dist/migrations/index.js +35 -0
  166. package/dist/migrations/index.js.map +1 -0
  167. package/docs/price_lists.md +278 -0
  168. package/i18n/en.json +14 -0
  169. package/i18n/pl.json +14 -0
  170. package/package.json +99 -0
  171. package/tailwind.css +14 -0
@@ -0,0 +1,43 @@
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, Index, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
11
+ import { GlobalEntity } from '@endora-commerce/platform/tenancy';
12
+ /**
13
+ * PriceListProduct — assignment join between a price list and a product.
14
+ *
15
+ * Composite primary key on `(priceListId, productId)`. The bracket rows in
16
+ * `price_list_price_brackets` cascade off this assignment: removing a product
17
+ * from a list deletes its bracket rows.
18
+ */
19
+ let PriceListProduct = class PriceListProduct {
20
+ [OptionalProps];
21
+ priceListId;
22
+ productId;
23
+ createdAt = new Date();
24
+ };
25
+ __decorate([
26
+ PrimaryKey({ type: 'uuid' }),
27
+ __metadata("design:type", String)
28
+ ], PriceListProduct.prototype, "priceListId", void 0);
29
+ __decorate([
30
+ PrimaryKey({ type: 'uuid' }),
31
+ __metadata("design:type", String)
32
+ ], PriceListProduct.prototype, "productId", void 0);
33
+ __decorate([
34
+ Property({ type: 'datetime', onCreate: () => new Date() }),
35
+ Index(),
36
+ __metadata("design:type", Date)
37
+ ], PriceListProduct.prototype, "createdAt", void 0);
38
+ PriceListProduct = __decorate([
39
+ GlobalEntity(),
40
+ Entity({ tableName: 'price_list_products' })
41
+ ], PriceListProduct);
42
+ export { PriceListProduct };
43
+ //# sourceMappingURL=price-list-product.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-list-product.entity.js","sourceRoot":"","sources":["../../../src/backend/entities/price-list-product.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE;;;;;;GAMG;AAGI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,CAAC,aAAa,CAAC,CAAe;IAG9B,WAAW,CAAU;IAGrB,SAAS,CAAU;IAInB,SAAS,GAAS,IAAI,IAAI,EAAE,CAAC;CAC9B,CAAA;AARC;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDACR;AAGrB;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACV;AAInB;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;IAC1D,KAAK,EAAE;8BACG,IAAI;mDAAc;AAXlB,gBAAgB;IAF5B,YAAY,EAAE;IACd,MAAM,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC;GAChC,gBAAgB,CAY5B"}
@@ -0,0 +1,34 @@
1
+ import { OptionalProps } from '@mikro-orm/core';
2
+ import type { ApplicationRule } from '@endora-commerce/contracts';
3
+ /**
4
+ * PriceList — feature-011 engine shape.
5
+ *
6
+ * Carries lifecycle (`status`, `startsAt`, `endsAt`), type discriminator
7
+ * (`type`), the application rule expressed as a JSONB AST, the system flag
8
+ * marking the seeded `Default` row, and `modifiedAt` driving the resolver's
9
+ * tie-break (FR-027).
10
+ *
11
+ * Legacy columns from feature 014 (`code`, `currency`, `priority`,
12
+ * `isDefault`) are preserved for the duration of the expand→migrate→contract
13
+ * rollout. They will be dropped by a follow-up migration once US5 wires every
14
+ * reader through the new resolver.
15
+ */
16
+ export declare class PriceList {
17
+ [OptionalProps]?: 'id' | 'createdAt' | 'updatedAt' | 'modifiedAt' | 'isDefault' | 'isSystem' | 'priority' | 'type' | 'status' | 'startsAt' | 'endsAt' | 'applicationRule';
18
+ id: string;
19
+ code: string;
20
+ name: string;
21
+ currency: string;
22
+ isDefault: boolean;
23
+ priority: number;
24
+ type: 'base' | 'sale';
25
+ status: 'draft' | 'active' | 'scheduled' | 'expired';
26
+ startsAt?: Date | null;
27
+ endsAt?: Date | null;
28
+ applicationRule: ApplicationRule;
29
+ isSystem: boolean;
30
+ modifiedAt: Date;
31
+ createdAt: Date;
32
+ updatedAt: Date;
33
+ }
34
+ //# sourceMappingURL=price-list.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-list.entity.d.ts","sourceRoot":"","sources":["../../../src/backend/entities/price-list.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAE7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;;;;;;;;;GAYG;AACH,qBAEa,SAAS;IACpB,CAAC,aAAa,CAAC,CAAC,EACZ,IAAI,GACJ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,WAAW,GACX,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,iBAAiB,CAAC;IAGtB,EAAE,EAAE,MAAM,CAAgB;IAM1B,IAAI,EAAG,MAAM,CAAC;IAGd,IAAI,EAAG,MAAM,CAAC;IAGd,QAAQ,EAAG,MAAM,CAAC;IAGlB,SAAS,EAAE,OAAO,CAAS;IAG3B,QAAQ,EAAE,MAAM,CAAK;IAMrB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAU;IAI/B,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAW;IAG/D,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGvB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAGrB,eAAe,EAAE,eAAe,CAAmB;IAGnD,QAAQ,EAAE,OAAO,CAAS;IAG1B,UAAU,EAAE,IAAI,CAAc;IAK9B,SAAS,EAAE,IAAI,CAAc;IAG7B,SAAS,EAAE,IAAI,CAAc;CAC9B"}
@@ -0,0 +1,115 @@
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, Index, OptionalProps, PrimaryKey, Property, Unique } from '@mikro-orm/core';
11
+ import { randomUUID } from 'crypto';
12
+ import { RuleScoped } from '@endora-commerce/platform/tenancy';
13
+ /**
14
+ * PriceList — feature-011 engine shape.
15
+ *
16
+ * Carries lifecycle (`status`, `startsAt`, `endsAt`), type discriminator
17
+ * (`type`), the application rule expressed as a JSONB AST, the system flag
18
+ * marking the seeded `Default` row, and `modifiedAt` driving the resolver's
19
+ * tie-break (FR-027).
20
+ *
21
+ * Legacy columns from feature 014 (`code`, `currency`, `priority`,
22
+ * `isDefault`) are preserved for the duration of the expand→migrate→contract
23
+ * rollout. They will be dropped by a follow-up migration once US5 wires every
24
+ * reader through the new resolver.
25
+ */
26
+ let PriceList = class PriceList {
27
+ [OptionalProps];
28
+ id = randomUUID();
29
+ // ----- Legacy columns (kept until expand→migrate→contract completes) -----
30
+ code;
31
+ name;
32
+ currency;
33
+ isDefault = false;
34
+ priority = 0;
35
+ // ----- Engine columns (feature 011) -------------------------------------
36
+ type = 'base';
37
+ status = 'draft';
38
+ startsAt;
39
+ endsAt;
40
+ applicationRule = { kind: 'all' };
41
+ isSystem = false;
42
+ modifiedAt = new Date();
43
+ // ----- Timestamps -------------------------------------------------------
44
+ createdAt = new Date();
45
+ updatedAt = new Date();
46
+ };
47
+ __decorate([
48
+ PrimaryKey({ type: 'uuid' }),
49
+ __metadata("design:type", String)
50
+ ], PriceList.prototype, "id", void 0);
51
+ __decorate([
52
+ Property({ type: 'string', length: 64 }),
53
+ Unique(),
54
+ __metadata("design:type", String)
55
+ ], PriceList.prototype, "code", void 0);
56
+ __decorate([
57
+ Property({ type: 'string', length: 200 }),
58
+ __metadata("design:type", String)
59
+ ], PriceList.prototype, "name", void 0);
60
+ __decorate([
61
+ Property({ type: 'string', length: 3 }),
62
+ __metadata("design:type", String)
63
+ ], PriceList.prototype, "currency", void 0);
64
+ __decorate([
65
+ Property({ type: 'boolean' }),
66
+ __metadata("design:type", Boolean)
67
+ ], PriceList.prototype, "isDefault", void 0);
68
+ __decorate([
69
+ Property({ type: 'integer' }),
70
+ __metadata("design:type", Number)
71
+ ], PriceList.prototype, "priority", void 0);
72
+ __decorate([
73
+ Property({ type: 'string', length: 8 }),
74
+ Index(),
75
+ __metadata("design:type", String)
76
+ ], PriceList.prototype, "type", void 0);
77
+ __decorate([
78
+ Property({ type: 'string', length: 16 }),
79
+ Index(),
80
+ __metadata("design:type", String)
81
+ ], PriceList.prototype, "status", void 0);
82
+ __decorate([
83
+ Property({ type: 'datetime', nullable: true }),
84
+ __metadata("design:type", Object)
85
+ ], PriceList.prototype, "startsAt", void 0);
86
+ __decorate([
87
+ Property({ type: 'datetime', nullable: true }),
88
+ __metadata("design:type", Object)
89
+ ], PriceList.prototype, "endsAt", void 0);
90
+ __decorate([
91
+ Property({ type: 'json' }),
92
+ __metadata("design:type", Object)
93
+ ], PriceList.prototype, "applicationRule", void 0);
94
+ __decorate([
95
+ Property({ type: 'boolean' }),
96
+ __metadata("design:type", Boolean)
97
+ ], PriceList.prototype, "isSystem", void 0);
98
+ __decorate([
99
+ Property({ type: 'datetime' }),
100
+ __metadata("design:type", Date)
101
+ ], PriceList.prototype, "modifiedAt", void 0);
102
+ __decorate([
103
+ Property({ type: 'datetime', onCreate: () => new Date() }),
104
+ __metadata("design:type", Date)
105
+ ], PriceList.prototype, "createdAt", void 0);
106
+ __decorate([
107
+ Property({ type: 'datetime', onUpdate: () => new Date() }),
108
+ __metadata("design:type", Date)
109
+ ], PriceList.prototype, "updatedAt", void 0);
110
+ PriceList = __decorate([
111
+ RuleScoped(),
112
+ Entity({ tableName: 'price_lists' })
113
+ ], PriceList);
114
+ export { PriceList };
115
+ //# sourceMappingURL=price-list.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-list.entity.js","sourceRoot":"","sources":["../../../src/backend/entities/price-list.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D;;;;;;;;;;;;GAYG;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;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxC,KAAK,EAAE;;yCACuD;AAG/D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACxB;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC1B;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACwB;AAGnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;2CACJ;AAG1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BACnB,IAAI;6CAAc;AAK9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAChD,IAAI;4CAAc;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAChD,IAAI;4CAAc;AAnElB,SAAS;IAFrB,UAAU,EAAE;IACZ,MAAM,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;GACxB,SAAS,CAoErB"}
@@ -0,0 +1,125 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql';
2
+ import type { CatalogCategoryReadPort, CatalogProductReadPort, OrganizationDetailsPort } from '@endora-commerce/contracts';
3
+ import type { AuditPort } from '@endora-commerce/platform/kernel';
4
+ import type { CommandBus } from '@endora-commerce/platform/commands';
5
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
6
+ import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
7
+ import { priceListsModule, type PriceListsModuleOptions } from './plugin.js';
8
+ import type { PricingServiceContract } from './services/pricing-service.interface.js';
9
+ import { PriceDisplayModeOverride } from './entities/price-display-mode-override.entity.js';
10
+ import { PriceListPriceBracket } from './entities/price-list-price-bracket.entity.js';
11
+ import { PriceListProduct } from './entities/price-list-product.entity.js';
12
+ import { PriceList } from './entities/price-list.entity.js';
13
+ /**
14
+ * `price_lists` — the decoration proof target (feature 072, wave 3, T127).
15
+ *
16
+ * It is still that, and it no longer knows it. `decoratePricingService` was a
17
+ * contribution point this module owned and defaulted absent, which a
18
+ * composition root filled from a file under `apps/<deployment>/decorations/`.
19
+ * That seam is retired: a deployment overrides a service from its own overlay
20
+ * module with `ctx.di.decorate('pricingService', …)` (D-103), which wraps the
21
+ * **registration** below rather than an argument to the engine factory. D-28's
22
+ * argument is unchanged and is now the container's to keep — a client override
23
+ * receives the core implementation and delegates to it — and the module is out
24
+ * of the loop entirely, which is the property the contribution point could not
25
+ * have: overriding a second service costs this module nothing, where the
26
+ * contribution point cost one field here and one `composition.ts` edit each.
27
+ *
28
+ * Two options are root-supplied rather than env-derived, and for the reason
29
+ * that has now bitten four conversions: the test harness genuinely differs.
30
+ * `enableStatusSweeper` is off there because a wall-clock interval per test
31
+ * file writes to the database at random moments, and `pricingCacheTtlMs` is 0
32
+ * because a test writes a price and reads it back in the same breath. Neither
33
+ * is a property of the module, and neither should be inferred from a missing
34
+ * argument.
35
+ *
36
+ * **The TTL's default came home in T143a cluster 6.** `pricingCacheTtlMs` is a
37
+ * contribution point, so it needs a default, and the default is this module's
38
+ * `DEFAULT_PRICING_CACHE_TTL_MS` — which production was importing *out of this
39
+ * module* to hand straight back to it. A root repeating a module's own constant
40
+ * is a knob that can drift while looking like configuration: the harness's 0 is
41
+ * a real composition decision and stays, and production now contributes
42
+ * nothing, which is what "no opinion" should look like.
43
+ *
44
+ * `resolveOrgChain` becomes a real port read. It is `organizations`'
45
+ * inheritance resolver, and its absence made feature 056 resolve flat — a
46
+ * descendant never picked up an ancestor's org-named list. Both roots passed
47
+ * it; the manifest now declares the dependency that was always there.
48
+ *
49
+ * The admin audit context stays contributed, because the two compositions
50
+ * disagree on something real: production substitutes a zero UUID for a
51
+ * non-admin caller and the harness substitutes its test admin. That is a
52
+ * composition's answer to "who is acting", not the module's.
53
+ */
54
+ /** What `price_lists` resolves from the container, and the names it owns. */
55
+ export interface PriceListsCradle {
56
+ readonly emFactory: () => EntityManager;
57
+ readonly auditLogService: AuditPort;
58
+ readonly commandBus: CommandBus;
59
+ readonly requireAdmin: RequireAdminFactory;
60
+ readonly organizationInheritancePort: {
61
+ priceListOrgChain: (orgId: string) => Promise<readonly string[]>;
62
+ };
63
+ /**
64
+ * Feature 075 Phase C — the neighbour reads this module made by importing
65
+ * `catalog`'s and `organizations`' entities. Each is resolved lazily, so a
66
+ * switched-off owner refuses at the call rather than at composition.
67
+ */
68
+ readonly catalogProductReadPort: CatalogProductReadPort;
69
+ readonly catalogCategoryReadPort: CatalogCategoryReadPort;
70
+ readonly organizationDetailsPort: OrganizationDetailsPort;
71
+ /** Composition-specific: a wall-clock sweeper is wrong in a test harness. */
72
+ readonly priceListsEnableStatusSweeper: boolean;
73
+ /**
74
+ * Contribution point, defaulted to this module's own `DEFAULT_PRICING_CACHE_TTL_MS`.
75
+ * A composition overrides it where it means something: the harness sets 0, so
76
+ * the LRU is off and a write is read back at once.
77
+ */
78
+ readonly priceListsPricingCacheTtlMs: number;
79
+ /** Root-shaped: production and the harness name a non-admin caller differently. */
80
+ readonly priceListsAdminAuditContext: NonNullable<PriceListsModuleOptions['resolveAdminAuditContext']>;
81
+ readonly priceLists: ReturnType<typeof priceListsModule>;
82
+ readonly pricingService: PricingServiceContract;
83
+ readonly priceListService: ReturnType<typeof priceListsModule>['handle']['priceListService'];
84
+ }
85
+ export declare function registerModule(ctx: ModuleContext): void;
86
+ /**
87
+ * The module's persisted entity classes, on the `./backend` subpath, as one
88
+ * array and **no named class export** (D-168).
89
+ *
90
+ * This is the shape the platform reads when the package is *installed*: the
91
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
92
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
93
+ * which is the third source of `check:module-boundary`'s `table->owner` map and
94
+ * the package pass of `check-entity-tenant-classification`. A missing array is
95
+ * answered with `[]` — zero entities registered, no error anywhere.
96
+ *
97
+ * The order is the one `db/entities-registry.generated.ts` declared before this
98
+ * module became a package, so the registered set is the same list in the same
99
+ * sequence.
100
+ */
101
+ export declare const entities: (typeof PriceList | typeof PriceListProduct | typeof PriceListPriceBracket | typeof PriceDisplayModeOverride)[];
102
+ /**
103
+ * The one-off migrator that creates this module's system price list and fills
104
+ * it from the catalog, published **by name** on `./backend`.
105
+ *
106
+ * The host's demo composition runs it, and a host program is composed
107
+ * against this package's `dist` while the ORM is registered from the same
108
+ * `entities` array above — so a filesystem path into this file's source would
109
+ * evaluate `price-list.entity.ts` a second time and the migrator would
110
+ * `em.create` a `PriceList` class the ORM has never heard of (D-160.6.1).
111
+ * D-168 bars an entity class from leaving by this door; a service is not an
112
+ * entity, and `pim_ergonode`'s `ErgonodeRequestError` is the precedent for
113
+ * publishing the binding a caller genuinely needs to hold the same copy of.
114
+ */
115
+ export { DefaultPriceListMigrator, DEFAULT_PRICE_LIST_ID } from './services/default-price-list-migration.js';
116
+ /**
117
+ * The price-list write service, published **by name** for the same reason as
118
+ * the migrator above: two integration tests construct it directly over their
119
+ * own `EntityManager`, in a process that already holds this package's published
120
+ * artefact, and a second copy would `em.create` a `PriceList` the ORM never
121
+ * registered (D-160.6.1). The container name `priceListService` stays the
122
+ * production seam; this export exists so a host-side test holds the same class.
123
+ */
124
+ export { PriceListService } from './services/price-list-service.js';
125
+ //# 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,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAA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Q,CAAC,6BAA6B,EAAE,OAAO,CAAC;IAChD;;;;OAIG;IACH,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAC7C,mFAAmF;IACnF,QAAQ,CAAC,2BAA2B,EAAE,WAAW,CAC/C,uBAAuB,CAAC,0BAA0B,CAAC,CACpD,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACzD,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD,QAAQ,CAAC,gBAAgB,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC;CAC9F;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA0KvD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,iHAKpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAE7G;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,179 @@
1
+ import { lazyPort } from '@endora-commerce/platform/kernel';
2
+ import { registerPriceListAuditReferences } from './services/audit-references.js';
3
+ import { priceListsModule } from './plugin.js';
4
+ import { DEFAULT_PRICING_CACHE_TTL_MS } from './services/pricing-cache.js';
5
+ import { PriceListReadService, toPriceListRecord } from './services/price-list-read-port.js';
6
+ import { registerPriceListCurrencyReferences } from './services/price-list-currency-reference.js';
7
+ import { PriceDisplayModeOverride } from './entities/price-display-mode-override.entity.js';
8
+ import { PriceListPriceBracket } from './entities/price-list-price-bracket.entity.js';
9
+ import { PriceListProduct } from './entities/price-list-product.entity.js';
10
+ import { PriceList } from './entities/price-list.entity.js';
11
+ export function registerModule(ctx) {
12
+ ctx.di.register({
13
+ // Contribution point, defaulted to the module's own constant (T143a). A
14
+ // root that wants the shipped behaviour now writes nothing; the harness
15
+ // overrides it in the root contribution slot — after `composeModules`,
16
+ // before `runBootHooks()` — which is the order a contribution point needs:
17
+ // earlier and this default overwrites the root, later and a boot hook has
18
+ // already read this default.
19
+ priceListsPricingCacheTtlMs: ctx
20
+ .asFunction(() => DEFAULT_PRICING_CACHE_TTL_MS)
21
+ .singleton(),
22
+ priceLists: ctx
23
+ .asFunction(({ emFactory, auditLogService, commandBus, priceListsEnableStatusSweeper, priceListsPricingCacheTtlMs, }) => priceListsModule({
24
+ emFactory,
25
+ auditLogService,
26
+ commandBus,
27
+ enableStatusSweeper: priceListsEnableStatusSweeper,
28
+ pricingCacheTtlMs: priceListsPricingCacheTtlMs,
29
+ requireAdmin: (permission) => async (req, reply) => ctx.cradle().requireAdmin(permission)(req, reply),
30
+ resolveAdminAuditContext: (req) => ctx.cradle().priceListsAdminAuditContext(req),
31
+ resolveOrgChain: (orgId) => ctx.cradle().organizationInheritancePort.priceListOrgChain(orgId),
32
+ // Feature 075 Phase C. `lazyPort` rather than a cradle read: these
33
+ // are handed to services this factory builds as a singleton, and a
34
+ // captured gate keeps answering after its owner is switched off.
35
+ targetReads: {
36
+ catalogProductRead: lazyPort(ctx, 'catalogProductReadPort'),
37
+ catalogCategoryRead: lazyPort(ctx, 'catalogCategoryReadPort'),
38
+ organizationDetails: lazyPort(ctx, 'organizationDetailsPort'),
39
+ // Feature 076 (D-79). This module used to *publish* this port;
40
+ // customer groups belong to the customer, so it reads it now.
41
+ customerGroupRead: lazyPort(ctx, 'customerGroupReadPort'),
42
+ },
43
+ // Feature 076 (D-79) — the admin resolved-price probe's customer
44
+ // read, which was the one entry in this module's ledger shard. It
45
+ // fails closed, deliberately: refusing the probe is better than
46
+ // pricing for a customer the platform will not identify.
47
+ customerAccountRead: lazyPort(ctx, 'customerAccountReadPort'),
48
+ }))
49
+ .singleton(),
50
+ });
51
+ ctx.di.providePort('pricingService', ctx.asFunction(({ priceLists }) => priceLists.handle.pricingService).singleton());
52
+ ctx.di.providePort('priceListService', ctx
53
+ .asFunction(({ priceLists }) => priceLists.handle.priceListService)
54
+ .singleton());
55
+ // ---------------------------------------------------------------------------
56
+ // Feature 075, Phase P — the published surface.
57
+ //
58
+ // The two ports above hand out services built inside the plugin, and the
59
+ // heaviest consumers do not want a service at all: `organizations` and
60
+ // `product_feeds` read a price-list *row*. Both reached the entity class
61
+ // before `priceListReadPort` existed.
62
+ //
63
+ // `customerGroupReadPort` used to be published here as well. It left with the
64
+ // entity in feature 076 (D-79) — a customer group describes the customer, so
65
+ // `customer_accounts` owns it and this module resolves it.
66
+ //
67
+ // `priceListAdminPort` narrows `PriceListService` to the five methods
68
+ // `pim_ergonode` measurably calls during an import run.
69
+ //
70
+ // `PricingServiceContract` used to be pinned to
71
+ // `services/pricing-service.interface.ts` because it was the feature-057
72
+ // decoration's contract gate: a deployment's `decorations/pricing-service.ts`
73
+ // imported it, so `tsc` refused a wrapper that had stopped matching. That
74
+ // seam is retired, and the gate went with it — an overlay module's
75
+ // `ctx.di.decorate<T>` asserts `T`, so nothing compares the wrapper to this
76
+ // interface. The type is free to move now. If the gate is wanted back, the
77
+ // way to get it is to publish this interface on this module's `./ports`
78
+ // subpath once it is a package and have the overlay name it there (D-171
79
+ // makes a type-only `./ports` reach not a boundary reach) — not to
80
+ // reintroduce a file seam.
81
+ // ---------------------------------------------------------------------------
82
+ ctx.di.providePort('priceListReadPort', ctx.asFunction(({ emFactory }) => new PriceListReadService(emFactory)).singleton());
83
+ ctx.di.providePort('priceListAdminPort', ctx
84
+ .asFunction(() => {
85
+ const service = () => ctx.cradle().priceLists.handle.priceListService;
86
+ return {
87
+ getById: async (id) => toPriceListRecord(await service().getById(id)),
88
+ listProducts: (priceListId) => service().listProducts(priceListId),
89
+ addProduct: (priceListId, productId) => service().addProduct(priceListId, productId),
90
+ replaceBrackets: (priceListId, productId, bracketsByCurrency) => service().replaceBrackets(priceListId, productId, bracketsByCurrency),
91
+ summarizeBracketsForProduct: (productId) => service().summarizeBracketsForProduct(productId),
92
+ };
93
+ })
94
+ .singleton());
95
+ ctx.routes(async (app) => {
96
+ await ctx.cradle().priceLists.plugin(app);
97
+ });
98
+ /**
99
+ * This module's rows carry a currency code, so it answers "who still points at
100
+ * this currency?" about its own tables (feature 077, D-87), where the owner used
101
+ * to count them with SQL naming this module's tables.
102
+ *
103
+ * A **contribution** hook: it pushes an inert descriptor into `currencyReferenceRegistry`,
104
+ * an ungated registry, and carries no presence probe (D-62/D-68). Probing
105
+ * would be wrong in the dangerous direction — a switched-off module still owns
106
+ * the rows, so its currency must still refuse the delete, which is the
107
+ * enumeration policy the registry states.
108
+ */
109
+ ctx.onBoot(() => {
110
+ registerPriceListCurrencyReferences(lazyPort(ctx, 'currencyReferenceRegistry'), ctx.cradle().emFactory);
111
+ });
112
+ /**
113
+ * What an audit row about a price list is called, and where the admin app shows it
114
+ * (feature 075, D-87 drain).
115
+ *
116
+ * `audit_logs` used to answer both by hand — one SQL statement naming this
117
+ * module's table, and this module's admin route spelled into its own switch.
118
+ * A read port would have been the wrong repair: `audit_logs` is a
119
+ * cross-cutting reader, and five ports into it would be five edges pointing
120
+ * from the record towards the things it records. One of the five contributors
121
+ * (`inventory`) is switchable, and `audit_logs` is `nonDeactivatable`, so that
122
+ * edge would also have taken the operator's switch away. A push costs nothing
123
+ * and reads the same for all five.
124
+ *
125
+ * A **contribution** hook: it pushes an inert resolver into
126
+ * `auditReferenceRegistry`, an ungated registry, and carries no presence probe
127
+ * (D-67/D-68). The registry's own enumeration policy is what drops this entry
128
+ * while the module is absent — probing here would make the drop survive a
129
+ * reactivation until the next restart.
130
+ */
131
+ ctx.onBoot(() => {
132
+ registerPriceListAuditReferences(lazyPort(ctx, 'auditReferenceRegistry'), ctx.cradle().emFactory);
133
+ });
134
+ }
135
+ /**
136
+ * The module's persisted entity classes, on the `./backend` subpath, as one
137
+ * array and **no named class export** (D-168).
138
+ *
139
+ * This is the shape the platform reads when the package is *installed*: the
140
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
141
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
142
+ * which is the third source of `check:module-boundary`'s `table->owner` map and
143
+ * the package pass of `check-entity-tenant-classification`. A missing array is
144
+ * answered with `[]` — zero entities registered, no error anywhere.
145
+ *
146
+ * The order is the one `db/entities-registry.generated.ts` declared before this
147
+ * module became a package, so the registered set is the same list in the same
148
+ * sequence.
149
+ */
150
+ export const entities = [
151
+ PriceDisplayModeOverride,
152
+ PriceListPriceBracket,
153
+ PriceListProduct,
154
+ PriceList,
155
+ ];
156
+ /**
157
+ * The one-off migrator that creates this module's system price list and fills
158
+ * it from the catalog, published **by name** on `./backend`.
159
+ *
160
+ * The host's demo composition runs it, and a host program is composed
161
+ * against this package's `dist` while the ORM is registered from the same
162
+ * `entities` array above — so a filesystem path into this file's source would
163
+ * evaluate `price-list.entity.ts` a second time and the migrator would
164
+ * `em.create` a `PriceList` class the ORM has never heard of (D-160.6.1).
165
+ * D-168 bars an entity class from leaving by this door; a service is not an
166
+ * entity, and `pim_ergonode`'s `ErgonodeRequestError` is the precedent for
167
+ * publishing the binding a caller genuinely needs to hold the same copy of.
168
+ */
169
+ export { DefaultPriceListMigrator, DEFAULT_PRICE_LIST_ID } from './services/default-price-list-migration.js';
170
+ /**
171
+ * The price-list write service, published **by name** for the same reason as
172
+ * the migrator above: two integration tests construct it directly over their
173
+ * own `EntityManager`, in a process that already holds this package's published
174
+ * artefact, and a second copy would `em.create` a `PriceList` the ORM never
175
+ * registered (D-160.6.1). The container name `priceListService` stays the
176
+ * production seam; this export exists so a host-side test holds the same class.
177
+ */
178
+ export { PriceListService } from './services/price-list-service.js';
179
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,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AG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACvB,MAAM,GAAG,CAAC,MAAM,EAAoB,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;OAUG;IACH,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;QACd,mCAAmC,CACjC,QAAQ,CAAkC,GAAG,EAAE,2BAA2B,CAAC,EAC3E,GAAG,CAAC,MAAM,EAAoB,CAAC,SAAS,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;;;;;;;;;OAkBG;IACH,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;QACd,gCAAgC,CAC9B,QAAQ,CAA6B,GAAG,EAAE,wBAAwB,CAAC,EACnE,GAAG,CAAC,MAAM,EAAoB,CAAC,SAAS,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wBAAwB;IACxB,qBAAqB;IACrB,gBAAgB;IAChB,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAE7G;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { FastifyInstance, FastifyRequest } from 'fastify';
2
+ import type { EntityManager } from '@mikro-orm/postgresql';
3
+ import type { CustomerAccountReadPort } from '@endora-commerce/contracts';
4
+ import { PriceListService } from './services/price-list-service.js';
5
+ import type { PriceListTargetReads } from './services/price-list-service.js';
6
+ import type { PricingServiceContract } from './services/pricing-service.interface.js';
7
+ import { PriceListStatusWorker } from './services/price-list-status-worker.js';
8
+ import type { AuditPort } from '@endora-commerce/platform/kernel';
9
+ import type { CommandBus } from '@endora-commerce/platform/commands';
10
+ import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
11
+ export interface PriceListsAuditContext {
12
+ actorAdminUserId: string;
13
+ impersonatedCustomerAccountId?: string | null;
14
+ ipAddress?: string | null;
15
+ userAgent?: string | null;
16
+ requestId?: string | null;
17
+ }
18
+ export interface PriceListsModuleOptions {
19
+ emFactory: () => EntityManager;
20
+ requireAdmin: RequireAdminFactory;
21
+ /**
22
+ * Set to `false` to skip the in-process status sweeper (tests drive
23
+ * the worker directly via `internal/sweep`; production keeps it on).
24
+ * The platform doesn't yet ship a BullMQ-class repeatable-job
25
+ * registry — when it does, swap this for a Queue/Worker pair on the
26
+ * existing pricing queue (research §R13).
27
+ */
28
+ enableStatusSweeper?: boolean;
29
+ /** Pass `0` to disable the in-memory pricing LRU (tests). */
30
+ pricingCacheTtlMs?: number;
31
+ /** Feature 024 — optional cross-module hook so price-list mutations land in the audit log. */
32
+ auditLogService?: AuditPort;
33
+ /** Feature 054 — audits `patch` co-transactionally when provided. */
34
+ commandBus?: CommandBus;
35
+ /** Feature 024 — resolves the admin actor identity for audit entries. */
36
+ resolveAdminAuditContext?: (req: FastifyRequest) => {
37
+ actorAdminUserId: string;
38
+ impersonatedCustomerAccountId?: string | null;
39
+ };
40
+ /**
41
+ * Feature 056 — resolves the acting org's inheritance chain (nearest-first)
42
+ * so a descendant inherits an ancestor's org-named price list. Absent ⇒ flat.
43
+ */
44
+ resolveOrgChain?: (orgId: string) => Promise<readonly string[]>;
45
+ /**
46
+ * Feature 075 Phase C — the neighbour read ports this module resolves instead
47
+ * of importing `catalog`'s, `organizations`' and `customer_accounts`'
48
+ * entities. Required: every one of them is a real dependency this module has
49
+ * always had, and the manifest declares all of them.
50
+ */
51
+ targetReads: PriceListTargetReads;
52
+ /**
53
+ * Feature 076 (D-79) — the admin resolved-price probe's customer read. It is
54
+ * not a rule target, so it is its own option rather than a fifth member of
55
+ * `targetReads`.
56
+ */
57
+ customerAccountRead: CustomerAccountReadPort;
58
+ }
59
+ export interface PriceListsModuleHandle {
60
+ priceListService: PriceListService;
61
+ pricingService: PricingServiceContract;
62
+ statusWorker: PriceListStatusWorker;
63
+ }
64
+ export declare function priceListsModule(options: PriceListsModuleOptions): {
65
+ plugin: (app: FastifyInstance) => Promise<void>;
66
+ handle: PriceListsModuleHandle;
67
+ };
68
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/backend/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAI/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAM5E,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,6BAA6B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,aAAa,CA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