@endora-commerce/mod-credit-limits 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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -0
  3. package/dist/admin/index.d.ts +31 -0
  4. package/dist/admin/index.d.ts.map +1 -0
  5. package/dist/admin/index.js +32 -0
  6. package/dist/admin/index.js.map +1 -0
  7. package/dist/admin/pages/CreditLimitsPage.d.ts +4 -0
  8. package/dist/admin/pages/CreditLimitsPage.d.ts.map +1 -0
  9. package/dist/admin/pages/CreditLimitsPage.js +144 -0
  10. package/dist/admin/pages/CreditLimitsPage.js.map +1 -0
  11. package/dist/backend/entities/credit-limit-reservation.entity.d.ts +35 -0
  12. package/dist/backend/entities/credit-limit-reservation.entity.d.ts.map +1 -0
  13. package/dist/backend/entities/credit-limit-reservation.entity.js +99 -0
  14. package/dist/backend/entities/credit-limit-reservation.entity.js.map +1 -0
  15. package/dist/backend/entities/credit-limit-return-topup.entity.d.ts +29 -0
  16. package/dist/backend/entities/credit-limit-return-topup.entity.d.ts.map +1 -0
  17. package/dist/backend/entities/credit-limit-return-topup.entity.js +71 -0
  18. package/dist/backend/entities/credit-limit-return-topup.entity.js.map +1 -0
  19. package/dist/backend/entities/credit-limit.entity.d.ts +21 -0
  20. package/dist/backend/entities/credit-limit.entity.d.ts.map +1 -0
  21. package/dist/backend/entities/credit-limit.entity.js +66 -0
  22. package/dist/backend/entities/credit-limit.entity.js.map +1 -0
  23. package/dist/backend/index.d.ts +80 -0
  24. package/dist/backend/index.d.ts.map +1 -0
  25. package/dist/backend/index.js +112 -0
  26. package/dist/backend/index.js.map +1 -0
  27. package/dist/backend/routes.d.ts +59 -0
  28. package/dist/backend/routes.d.ts.map +1 -0
  29. package/dist/backend/routes.js +114 -0
  30. package/dist/backend/routes.js.map +1 -0
  31. package/dist/backend/services/credit-limit-read.d.ts +23 -0
  32. package/dist/backend/services/credit-limit-read.d.ts.map +1 -0
  33. package/dist/backend/services/credit-limit-read.js +35 -0
  34. package/dist/backend/services/credit-limit-read.js.map +1 -0
  35. package/dist/backend/services/credit-limit-service.d.ts +179 -0
  36. package/dist/backend/services/credit-limit-service.d.ts.map +1 -0
  37. package/dist/backend/services/credit-limit-service.js +487 -0
  38. package/dist/backend/services/credit-limit-service.js.map +1 -0
  39. package/dist/backend/services/credit-topup.d.ts +33 -0
  40. package/dist/backend/services/credit-topup.d.ts.map +1 -0
  41. package/dist/backend/services/credit-topup.js +46 -0
  42. package/dist/backend/services/credit-topup.js.map +1 -0
  43. package/dist/manifest.d.ts +169 -0
  44. package/dist/manifest.d.ts.map +1 -0
  45. package/dist/manifest.js +138 -0
  46. package/dist/manifest.js.map +1 -0
  47. package/dist/migrations/20260425T063333_credit_limits_init.d.ts +15 -0
  48. package/dist/migrations/20260425T063333_credit_limits_init.d.ts.map +1 -0
  49. package/dist/migrations/20260425T063333_credit_limits_init.js +56 -0
  50. package/dist/migrations/20260425T063333_credit_limits_init.js.map +1 -0
  51. package/dist/migrations/20260817T201111_credit_limits_return_topups.d.ts +17 -0
  52. package/dist/migrations/20260817T201111_credit_limits_return_topups.d.ts.map +1 -0
  53. package/dist/migrations/20260817T201111_credit_limits_return_topups.js +36 -0
  54. package/dist/migrations/20260817T201111_credit_limits_return_topups.js.map +1 -0
  55. package/dist/migrations/20260818T081252_credit_limits_credit_limit_reservation_order_fk.d.ts +44 -0
  56. package/dist/migrations/20260818T081252_credit_limits_credit_limit_reservation_order_fk.d.ts.map +1 -0
  57. package/dist/migrations/20260818T081252_credit_limits_credit_limit_reservation_order_fk.js +81 -0
  58. package/dist/migrations/20260818T081252_credit_limits_credit_limit_reservation_order_fk.js.map +1 -0
  59. package/dist/migrations/20260821T140323_credit_limits_reservation_reserving_organization.d.ts +29 -0
  60. package/dist/migrations/20260821T140323_credit_limits_reservation_reserving_organization.d.ts.map +1 -0
  61. package/dist/migrations/20260821T140323_credit_limits_reservation_reserving_organization.js +45 -0
  62. package/dist/migrations/20260821T140323_credit_limits_reservation_reserving_organization.js.map +1 -0
  63. package/dist/migrations/index.d.ts +39 -0
  64. package/dist/migrations/index.d.ts.map +1 -0
  65. package/dist/migrations/index.js +44 -0
  66. package/dist/migrations/index.js.map +1 -0
  67. package/dist/ports/index.d.ts +93 -0
  68. package/dist/ports/index.d.ts.map +1 -0
  69. package/dist/ports/index.js +2 -0
  70. package/dist/ports/index.js.map +1 -0
  71. package/docs/credit_limits.md +53 -0
  72. package/i18n/en.json +9 -0
  73. package/i18n/pl.json +9 -0
  74. package/package.json +92 -0
  75. package/tailwind.css +14 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-limit-service.js","sourceRoot":"","sources":["../../../src/backend/services/credit-limit-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AA+DzF,MAAM,OAAO,kBAAkB;IAEV;IACA;IAOA;IAOA;IAhBnB,YACmB,SAA8B,EAC9B,MAA2B;IAC5C;;;;;OAKG;IACc,UAAuB;IACxC;;;;;OAKG;IACc,WAAyC;QAfzC,cAAS,GAAT,SAAS,CAAqB;QAC9B,WAAM,GAAN,MAAM,CAAqB;QAO3B,eAAU,GAAV,UAAU,CAAa;QAOvB,gBAAW,GAAX,WAAW,CAA8B;IACzD,CAAC;IAEJ,KAAK,CAAC,kBAAkB,CAAC,cAAsB;QAC7C,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAC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,OAAO,CAAC,CAAS;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,sBAAsB,CAAC,EAAiB,EAAE,aAAqB;QACnE,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,OAAO,CAC3B;;uDAEiD,EACjD,CAAC,aAAa,CAAC,CAChB,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ import type { CreditTopupInput, CreditTopupPort, CreditTopupResult } from '@endora-commerce/contracts';
2
+ import type { CreditLimitService } from './credit-limit-service.js';
3
+ /**
4
+ * Credit-limits-side implementation of the returns module's `CreditTopupPort`
5
+ * (feature 046, R7). The three declarations are read from `@endora-commerce/contracts`,
6
+ * where Phase P published them: `returns` still states the shape and this
7
+ * module still satisfies it, but neither names a file in the other's directory
8
+ * (feature 075, Phase C). A "credit toward future orders" resolution increases the
9
+ * organization's credit-limit grant by the refund amount; the credit_limits
10
+ * checkout credit-check already provides redemption. Returns `applied: false`
11
+ * when the organization has no grant.
12
+ *
13
+ * **The rule is one credit per return case (D-91).** This adapter used to read
14
+ * the grant and adjust it to `granted + amount`, ignoring the `returnCaseId`
15
+ * the input has always carried, so a settlement retried after a later step
16
+ * refused credited the organization a second time. The rule now lives in
17
+ * `CreditLimitService.creditFromReturn`, where the credit and the record of it
18
+ * are written by one Command in one transaction; this class is back to being
19
+ * the shape adapter it reads as.
20
+ */
21
+ export declare class CreditTopupProvider implements CreditTopupPort {
22
+ private readonly creditLimitService;
23
+ /**
24
+ * The service arrives as an accessor, not as an instance: `creditLimitService`
25
+ * is a gated port, and a composition root that resolves it while wiring this
26
+ * provider asks about `credit_limits`' effective state at boot — which is how
27
+ * switching the module off used to stop the whole backend from starting. Read
28
+ * per settlement, the gate answers at the call it is about.
29
+ */
30
+ constructor(creditLimitService: () => CreditLimitService);
31
+ creditFromReturn(input: CreditTopupInput): Promise<CreditTopupResult>;
32
+ }
33
+ //# sourceMappingURL=credit-topup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-topup.d.ts","sourceRoot":"","sources":["../../../src/backend/services/credit-topup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAQ7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAP/C;;;;;;OAMG;gBAC0B,kBAAkB,EAAE,MAAM,kBAAkB;IAEnE,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAc5E"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Credit-limits-side implementation of the returns module's `CreditTopupPort`
3
+ * (feature 046, R7). The three declarations are read from `@endora-commerce/contracts`,
4
+ * where Phase P published them: `returns` still states the shape and this
5
+ * module still satisfies it, but neither names a file in the other's directory
6
+ * (feature 075, Phase C). A "credit toward future orders" resolution increases the
7
+ * organization's credit-limit grant by the refund amount; the credit_limits
8
+ * checkout credit-check already provides redemption. Returns `applied: false`
9
+ * when the organization has no grant.
10
+ *
11
+ * **The rule is one credit per return case (D-91).** This adapter used to read
12
+ * the grant and adjust it to `granted + amount`, ignoring the `returnCaseId`
13
+ * the input has always carried, so a settlement retried after a later step
14
+ * refused credited the organization a second time. The rule now lives in
15
+ * `CreditLimitService.creditFromReturn`, where the credit and the record of it
16
+ * are written by one Command in one transaction; this class is back to being
17
+ * the shape adapter it reads as.
18
+ */
19
+ export class CreditTopupProvider {
20
+ creditLimitService;
21
+ /**
22
+ * The service arrives as an accessor, not as an instance: `creditLimitService`
23
+ * is a gated port, and a composition root that resolves it while wiring this
24
+ * provider asks about `credit_limits`' effective state at boot — which is how
25
+ * switching the module off used to stop the whole backend from starting. Read
26
+ * per settlement, the gate answers at the call it is about.
27
+ */
28
+ constructor(creditLimitService) {
29
+ this.creditLimitService = creditLimitService;
30
+ }
31
+ async creditFromReturn(input) {
32
+ const outcome = await this.creditLimitService().creditFromReturn({
33
+ organizationId: input.organizationId,
34
+ amount: input.amount,
35
+ currency: input.currency,
36
+ returnCaseId: input.returnCaseId,
37
+ });
38
+ return {
39
+ applied: outcome.applied,
40
+ ...(outcome.availableAmountAfter !== undefined
41
+ ? { availableAmountAfter: outcome.availableAmountAfter }
42
+ : {}),
43
+ };
44
+ }
45
+ }
46
+ //# sourceMappingURL=credit-topup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credit-topup.js","sourceRoot":"","sources":["../../../src/backend/services/credit-topup.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,mBAAmB;IAQD;IAP7B;;;;;;OAMG;IACH,YAA6B,kBAA4C;QAA5C,uBAAkB,GAAlB,kBAAkB,CAA0B;IAAG,CAAC;IAE7E,KAAK,CAAC,gBAAgB,CAAC,KAAuB;QAC5C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC,gBAAgB,CAAC;YAC/D,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,YAAY,EAAE,KAAK,CAAC,YAAY;SACjC,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,CAAC,OAAO,CAAC,oBAAoB,KAAK,SAAS;gBAC5C,CAAC,CAAC,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,EAAE;gBACxD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Credit Limits module — manifest backfill (Module Lifecycle, feature 018).
3
+ *
4
+ * Predates the lifecycle system; this manifest is the static record
5
+ * required so the module participates in the registry. No install /
6
+ * uninstall hook today — the module's schema is owned by earlier
7
+ * platform-wide migrations.
8
+ */
9
+ export declare const manifest: {
10
+ id: string;
11
+ name: string;
12
+ version: string;
13
+ dependencies: string[];
14
+ description?: string | undefined;
15
+ acknowledgedDependencies?: {
16
+ moduleId: string;
17
+ port: string;
18
+ reason: string;
19
+ }[] | undefined;
20
+ nonBindingDependencies?: {
21
+ moduleId: string;
22
+ name: string;
23
+ kind: "contributes-to" | "degrades-without" | "refuses-without";
24
+ reason: string;
25
+ whenAbsent?: string | undefined;
26
+ }[] | undefined;
27
+ activation?: {
28
+ settingCode: string;
29
+ default: boolean;
30
+ } | {
31
+ nonDeactivatable: true;
32
+ reason: string;
33
+ } | undefined;
34
+ settings?: {
35
+ moduleCode: string;
36
+ groups: {
37
+ code: string;
38
+ name: string;
39
+ salesChannelCodes?: string[] | undefined;
40
+ isSystemProtected?: boolean | undefined;
41
+ }[];
42
+ settings: {
43
+ code: string;
44
+ name: string;
45
+ valueType: "string" | "number" | "boolean" | "json" | "string_list" | "secret" | "credential_ref";
46
+ defaultValue: unknown;
47
+ description?: string | undefined;
48
+ groupCode?: string | undefined;
49
+ previousDefaultValues?: unknown[] | undefined;
50
+ salesChannelCodes?: string[] | undefined;
51
+ enumOptions?: string[] | undefined;
52
+ configurationType?: string | undefined;
53
+ hidden?: boolean | undefined;
54
+ }[];
55
+ } | undefined;
56
+ i18n?: {
57
+ bundlesDir: string;
58
+ } | undefined;
59
+ docs?: false | {
60
+ dir: string;
61
+ } | undefined;
62
+ demo?: false | {
63
+ summary: string;
64
+ seed: (context: import("@endora-commerce/contracts").ModuleDemoContext<never>) => Promise<import("@endora-commerce/contracts").DemoSeedResult>;
65
+ reset: (context: import("@endora-commerce/contracts").ModuleDemoContext<never>) => Promise<import("@endora-commerce/contracts").DemoResetResult>;
66
+ after?: readonly string[] | undefined;
67
+ package?: string | undefined;
68
+ } | undefined;
69
+ actions?: {
70
+ id: string;
71
+ labelKey: string;
72
+ icon: "Plus" | "Sparkles" | "Settings" | "Search" | "Boxes" | "Layers" | "Menu" | "PlusCircle" | "PlusSquare" | "FilePlus" | "FolderPlus" | "Upload" | "FileUp" | "CloudUpload" | "Download" | "FileDown" | "FileText" | "BookOpen" | "Rss" | "Package" | "Tag" | "ShoppingCart" | "Receipt" | "CreditCard" | "Users" | "UserPlus" | "Inbox" | "ListChecks" | "ClipboardList" | "Image" | "Video" | "LayoutDashboard" | "PanelLeft" | "KeyRound" | "ShieldCheck" | "Edit" | "Archive" | "Box" | "Truck" | "CircleDollarSign" | "Activity" | "LineChart" | "Smartphone" | "Webhook" | "Scale" | "PlugZap" | "PercentDiamond" | "Newspaper" | "Languages" | "Eraser" | "Warehouse" | "TrendingDown" | "Bell" | "PackageOpen" | "Building2" | "Store" | "ClipboardCheck";
73
+ targetRoute: string;
74
+ keywords: string[];
75
+ weight: number;
76
+ descriptionKey?: string | undefined;
77
+ requiredPermission?: string | undefined;
78
+ }[] | undefined;
79
+ permissions?: {
80
+ code: string;
81
+ label: string;
82
+ module?: string | undefined;
83
+ description?: string | undefined;
84
+ requires?: string[] | undefined;
85
+ }[] | undefined;
86
+ transactionalEmails?: {
87
+ code: string;
88
+ name: string;
89
+ variables: {
90
+ key: string;
91
+ label: string;
92
+ sampleValue?: string | undefined;
93
+ description?: string | undefined;
94
+ }[];
95
+ description?: string | undefined;
96
+ group?: string | undefined;
97
+ }[] | undefined;
98
+ capabilities?: string[] | undefined;
99
+ exclusiveCapabilities?: {
100
+ key: string;
101
+ errorCode: string;
102
+ }[] | undefined;
103
+ errorCodes?: {
104
+ code: string;
105
+ tokens?: string[] | undefined;
106
+ }[] | undefined;
107
+ blocks?: {
108
+ name: string;
109
+ labelKey: string;
110
+ category: string;
111
+ contexts: ("invoice" | "email" | "cms" | "newsletter")[];
112
+ fields: Record<string, {
113
+ type: "number" | "object" | "array" | "text" | "textarea" | "select" | "radio" | "external" | "uuid" | "richtext";
114
+ label?: string | undefined;
115
+ required?: boolean | undefined;
116
+ options?: {
117
+ label: string;
118
+ value: string | number;
119
+ }[] | undefined;
120
+ refKind?: string | undefined;
121
+ }>;
122
+ descriptionKey?: string | undefined;
123
+ defaultProps?: Record<string, unknown> | undefined;
124
+ responsiveFields?: string[] | undefined;
125
+ previewIcon?: string | undefined;
126
+ weight?: number | undefined;
127
+ }[] | undefined;
128
+ blockCategories?: {
129
+ key: string;
130
+ titleKey: string;
131
+ contexts: ("invoice" | "email" | "cms" | "newsletter")[];
132
+ weight?: number | undefined;
133
+ visible?: boolean | undefined;
134
+ }[] | undefined;
135
+ env?: {
136
+ name: string;
137
+ describes: {
138
+ en: string;
139
+ pl: string;
140
+ };
141
+ requirement: {
142
+ kind: "required";
143
+ } | {
144
+ kind: "requiredWhen";
145
+ input: string;
146
+ equals: string;
147
+ } | {
148
+ kind: "optional";
149
+ without: {
150
+ en: string;
151
+ pl: string;
152
+ };
153
+ };
154
+ secret: boolean;
155
+ generable: boolean;
156
+ owner: {
157
+ kind: "platform";
158
+ } | {
159
+ kind: "application";
160
+ application: "admin" | "backend" | "storefront";
161
+ } | {
162
+ kind: "module";
163
+ moduleId: string;
164
+ };
165
+ consumers: ("admin" | "backend" | "storefront")[];
166
+ addressOf: "admin" | "backend" | "storefront" | null;
167
+ }[] | undefined;
168
+ };
169
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiInB,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { defineModuleManifest } from '@endora-commerce/contracts';
2
+ /**
3
+ * Credit Limits module — manifest backfill (Module Lifecycle, feature 018).
4
+ *
5
+ * Predates the lifecycle system; this manifest is the static record
6
+ * required so the module participates in the registry. No install /
7
+ * uninstall hook today — the module's schema is owned by earlier
8
+ * platform-wide migrations.
9
+ */
10
+ export const manifest = defineModuleManifest({
11
+ id: 'credit_limits',
12
+ name: 'Credit Limits',
13
+ description: 'Per-organization credit limits and credit-check enforcement at checkout.',
14
+ version: '1.0.0',
15
+ // `auth` owns the `requireAdmin` port, the customer guard and the customer
16
+ // context resolver this module now resolves from the container.
17
+ //
18
+ // D-94.1 adds `orders`, for the foreign key
19
+ // `credit_limit_reservations_order_fk` (`credit_limit_reservations.order_id`
20
+ // -> `orders.id`, `on delete restrict`). AGENTS.md § Migrations item 4: a
21
+ // cross-module foreign key is declared here or the build fails, and an
22
+ // `acknowledgedDependencies` entry does not satisfy it. The edge is mutual —
23
+ // `placeOrder` calls `reserve({ tx })` on this module's service and this
24
+ // module records a row against the order — so the cycle it closes is broken
25
+ // on the *other* side: `orders` re-expresses `creditLimitService` as an
26
+ // acknowledged edge, which drops the install ordering the constraint says is
27
+ // backwards and keeps the bind (D-94.3).
28
+ dependencies: ['organizations', 'auth', 'orders'],
29
+ settings: {
30
+ moduleCode: 'credit_limits',
31
+ groups: [{ code: 'credit_limits', name: 'Credit limits' }],
32
+ settings: [
33
+ {
34
+ // Feature 073 — the operator's activation control. Platform-wide.
35
+ code: 'credit_limits.enabled',
36
+ name: 'Credit limits enabled',
37
+ description: 'Switches deferred-payment credit limits on or off: the admin screens, the customer-facing balance and the reservation orders take against it. Nothing is dropped — configured limits and their history stay in the database and apply again when you switch it back on.',
38
+ groupCode: 'credit_limits',
39
+ valueType: 'boolean',
40
+ defaultValue: true,
41
+ },
42
+ ],
43
+ },
44
+ // Feature 091 (Phase 4, batch 8) — the palette row `AppShell.tsx` carried by
45
+ // hand, arriving as the declaration Principle XVI names. It was a
46
+ // `PALETTE_ITEMS` literal, which is a copy of an advertisement the server was
47
+ // never asked about: it went on offering this screen after an operator
48
+ // switched the module off, because nothing filtered it by the effective
49
+ // enabled-set. `credit_limits:manage` is what gates
50
+ // `GET /api/v1/admin/credit-limits`, so the palette never advertises a 403.
51
+ actions: [
52
+ {
53
+ id: 'open-credit-limits',
54
+ labelKey: 'actions.openCreditLimits.label',
55
+ descriptionKey: 'actions.openCreditLimits.description',
56
+ icon: 'CreditCard',
57
+ targetRoute: '/credit-limits',
58
+ requiredPermission: 'credit_limits:manage',
59
+ keywords: ['credit', 'limit', 'limits', 'balance', 'terms', 'limity kredytowe', 'saldo'],
60
+ weight: 400,
61
+ },
62
+ ],
63
+ /**
64
+ * Nothing to demonstrate of its own (feature 113, T222 — contract §1.2).
65
+ *
66
+ * The demo shop does have a granted credit limit, and it is not this module's
67
+ * demo data: a grant's whole content is a reference to an `organizations` row,
68
+ * so it is two modules' rows in one statement and belongs to whoever owns the
69
+ * instance (§5.1). It is a step of `backend/src/seeds/demo-composition.ts`,
70
+ * guarded on both modules, and this module does not declare `organizations` —
71
+ * §2.3's rule that `demo` may not become a way of acquiring a dependency.
72
+ *
73
+ * `false` rather than absent, because the two are different states: this is a
74
+ * decision that the module owes nothing, not a module nobody has looked at.
75
+ */
76
+ demo: false,
77
+ activation: { settingCode: 'credit_limits.enabled', default: true },
78
+ /**
79
+ * This module's first i18n bundle — D-129's remaining sweep, MR 5.
80
+ *
81
+ * It exists because a **declaring** module that contributes no bundle file is
82
+ * `check:error-translations` exit 2 for the whole tree rather than a finding
83
+ * (`specs/090-module-owned-error-codes/contracts/error-translation-population.md`
84
+ * §2.1, §2.3; `d129-sweep.md` §3.4). The bundle lives at the **package
85
+ * root**, not under `dist`: `manifest-locations.ts` resolves a packaged
86
+ * module's `manifestPath` to its `package.json`, so `dirname` is the package
87
+ * directory. The files are a **flat** `{"a.b.c": "text"}` map, because a
88
+ * nested object fails `TranslationBundleEntriesSchema` and the boot
89
+ * reconciler logs and skips it — silently.
90
+ */
91
+ i18n: { bundlesDir: 'i18n' },
92
+ docs: { dir: 'docs' },
93
+ /**
94
+ * The credit-limit refusals — D-129's remaining sweep, Tier B
95
+ * (`specs/090-module-owned-error-codes/d129-sweep.md` §5.2, Appendix A;
96
+ * MR 5).
97
+ *
98
+ * All five were declared by `_i18n` until this merge request, not because
99
+ * anybody judged them the platform's but because the deleted prefix chain had
100
+ * no rule for them and its last line was `return 'core'`. **D-121 T1 puts
101
+ * them here**: the noun in every one is the credit limit or a reservation
102
+ * against it, and both are this module's entities (`credit_limits`,
103
+ * `credit_limit_reservations`).
104
+ *
105
+ * Two of the five are places the noun and the raise-site count disagree, and
106
+ * both are the shape D-95.2 ruled for `INVOICE_NOT_READY`. `LIMIT_INSUFFICIENT`
107
+ * is raised only by `orders`, because this module's reserve seam *returns*
108
+ * `{ ok: false, code: 'LIMIT_INSUFFICIENT' }` as a typed result and the caller
109
+ * turns it into a 409 inside the placement transaction — a `readonly code`
110
+ * claim is not a raise, and the limit the code names is this module's row.
111
+ * `CREDIT_LIMIT_NOT_GRANTED` has six raise sites, five of them here and one in
112
+ * `orders` for the same reason.
113
+ *
114
+ * **Four of the five arrive with a sentence, and the fifth does not.** Each
115
+ * carried a placeholder in `_i18n`'s bundle — `"Limit Insufficient."` /
116
+ * `"Błąd: limit insufficient."` — which D-186 §2 deletes rather than carries,
117
+ * because in this module's own bundle it would read as this module's answer.
118
+ * §5.4 keeps writing the prose available and is not a re-opening of that
119
+ * ruling, so the decision was taken per code: the four with a live raise site
120
+ * and a person who meets it are written here, and
121
+ * `ACTIVE_RESERVATIONS_EXIST` — which **nothing in the tree raises** — is
122
+ * deleted and joins `UNTRANSLATED_ERROR_CODES` under this module, because
123
+ * with no raise site there is no refusal to describe.
124
+ *
125
+ * **`tokens` is derived from the raise sites, not from the bundle**
126
+ * (runbook §5), and there are none: every raise is a bare
127
+ * `HttpError(status, code, message)` with no `details` argument, measured by
128
+ * balanced-paren extraction of each call's own arguments.
129
+ */
130
+ errorCodes: [
131
+ { code: 'ACTIVE_RESERVATIONS_EXIST' },
132
+ { code: 'ADJUSTMENT_BELOW_ACTIVE' },
133
+ { code: 'CREDIT_LIMIT_ALREADY_GRANTED' },
134
+ { code: 'CREDIT_LIMIT_NOT_GRANTED' },
135
+ { code: 'LIMIT_INSUFFICIENT' },
136
+ ],
137
+ });
138
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAC;IAC3C,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,0EAA0E;IAC5E,OAAO,EAAE,OAAO;IAChB,2EAA2E;IAC3E,gEAAgE;IAChE,EAAE;IACF,4CAA4C;IAC5C,6EAA6E;IAC7E,0EAA0E;IAC1E,uEAAuE;IACvE,6EAA6E;IAC7E,yEAAyE;IACzE,4EAA4E;IAC5E,wEAAwE;IACxE,6EAA6E;IAC7E,yCAAyC;IACzC,YAAY,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC;IACjD,QAAQ,EAAE;QACR,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;QAC1D,QAAQ,EAAE;YACR;gBACE,kEAAkE;gBAClE,IAAI,EAAE,uBAAuB;gBAC7B,IAAI,EAAE,uBAAuB;gBAC7B,WAAW,EACT,yQAAyQ;gBAC3Q,SAAS,EAAE,eAAe;gBAC1B,SAAS,EAAE,SAAS;gBACpB,YAAY,EAAE,IAAI;aACnB;SACF;KACF;IACD,6EAA6E;IAC7E,kEAAkE;IAClE,8EAA8E;IAC9E,uEAAuE;IACvE,wEAAwE;IACxE,oDAAoD;IACpD,4EAA4E;IAC5E,OAAO,EAAE;QACP;YACE,EAAE,EAAE,oBAAoB;YACxB,QAAQ,EAAE,gCAAgC;YAC1C,cAAc,EAAE,sCAAsC;YACtD,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,gBAAgB;YAC7B,kBAAkB,EAAE,sBAAsB;YAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC;YACxF,MAAM,EAAE,GAAG;SACZ;KACF;IACD;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,KAAK;IACX,UAAU,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE;IACnE;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;IAC5B,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,UAAU,EAAE;QACV,EAAE,IAAI,EAAE,2BAA2B,EAAE;QACrC,EAAE,IAAI,EAAE,yBAAyB,EAAE;QACnC,EAAE,IAAI,EAAE,8BAA8B,EAAE;QACxC,EAAE,IAAI,EAAE,0BAA0B,EAAE;QACpC,EAAE,IAAI,EAAE,oBAAoB,EAAE;KAC/B;CACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * Credit Limit module — Phase 8 (T212).
4
+ *
5
+ * - One CreditLimit row per Organization (partial unique index — soft-revoked
6
+ * rows aren't unique, but at most one "live" grant per org).
7
+ * - CreditLimitReservation indexed on (credit_limit_id, status) so the FOR
8
+ * UPDATE inside the order-placement transaction can sum active reservations
9
+ * cheaply.
10
+ */
11
+ export declare class Migration20260425T063333CreditLimitsInit extends Migration {
12
+ up(): Promise<void>;
13
+ down(): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=20260425T063333_credit_limits_init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260425T063333_credit_limits_init.d.ts","sourceRoot":"","sources":["../../src/migrations/20260425T063333_credit_limits_init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;GAQG;AACH,qBAAa,wCAAyC,SAAQ,SAAS;IACtD,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IA6CnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
@@ -0,0 +1,56 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * Credit Limit module — Phase 8 (T212).
4
+ *
5
+ * - One CreditLimit row per Organization (partial unique index — soft-revoked
6
+ * rows aren't unique, but at most one "live" grant per org).
7
+ * - CreditLimitReservation indexed on (credit_limit_id, status) so the FOR
8
+ * UPDATE inside the order-placement transaction can sum active reservations
9
+ * cheaply.
10
+ */
11
+ export class Migration20260425T063333CreditLimitsInit extends Migration {
12
+ async up() {
13
+ this.addSql(`
14
+ create table "credit_limits" (
15
+ "id" uuid not null,
16
+ "organization_id" uuid not null,
17
+ "granted_amount" numeric(14,2) not null,
18
+ "currency" varchar(3) not null,
19
+ "granted_by_admin_user_id" uuid null,
20
+ "created_at" timestamptz not null,
21
+ "updated_at" timestamptz not null,
22
+ constraint "credit_limits_pkey" primary key ("id"),
23
+ constraint "credit_limits_org_fk" foreign key ("organization_id")
24
+ references "organizations" ("id") on delete restrict
25
+ );
26
+ `);
27
+ this.addSql('create index "credit_limits_organization_id_index" on "credit_limits" ("organization_id");');
28
+ this.addSql(`create unique index "credit_limits_one_per_organization" on "credit_limits" ("organization_id");`);
29
+ this.addSql(`
30
+ create table "credit_limit_reservations" (
31
+ "id" uuid not null,
32
+ "credit_limit_id" uuid not null,
33
+ "order_id" uuid not null,
34
+ "amount" numeric(14,2) not null,
35
+ "currency" varchar(3) not null,
36
+ "status" varchar(16) not null default 'active',
37
+ "released_at" timestamptz null,
38
+ "released_reason" varchar(32) null,
39
+ "created_at" timestamptz not null,
40
+ "updated_at" timestamptz not null,
41
+ constraint "credit_limit_reservations_pkey" primary key ("id"),
42
+ constraint "credit_limit_reservations_credit_limit_fk" foreign key ("credit_limit_id")
43
+ references "credit_limits" ("id") on delete restrict
44
+ );
45
+ `);
46
+ this.addSql('create index "credit_limit_reservations_credit_limit_status_index" on "credit_limit_reservations" ("credit_limit_id", "status");');
47
+ this.addSql('create index "credit_limit_reservations_order_id_index" on "credit_limit_reservations" ("order_id");');
48
+ // At most one active reservation per order (idempotency guard).
49
+ this.addSql(`create unique index "credit_limit_reservations_one_active_per_order" on "credit_limit_reservations" ("order_id") where "status" = 'active';`);
50
+ }
51
+ async down() {
52
+ this.addSql('drop table if exists "credit_limit_reservations" cascade;');
53
+ this.addSql('drop table if exists "credit_limits" cascade;');
54
+ }
55
+ }
56
+ //# sourceMappingURL=20260425T063333_credit_limits_init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260425T063333_credit_limits_init.js","sourceRoot":"","sources":["../../src/migrations/20260425T063333_credit_limits_init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,OAAO,wCAAyC,SAAQ,SAAS;IAC5D,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;KAaX,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,4FAA4F,CAAC,CAAC;QAC1G,IAAI,CAAC,MAAM,CACT,kGAAkG,CACnG,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;KAgBX,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,kIAAkI,CAAC,CAAC;QAChJ,IAAI,CAAC,MAAM,CAAC,sGAAsG,CAAC,CAAC;QACpH,gEAAgE;QAChE,IAAI,CAAC,MAAM,CACT,6IAA6I,CAC9I,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,2DAA2D,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM,CAAC,+CAA+C,CAAC,CAAC;IAC/D,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * `credit_limit_return_topups` — one credit per return case (D-91).
4
+ *
5
+ * The settlement ordering law attempts every external effect before it writes
6
+ * any state, so a refusal from a later step leaves a retryable case and the
7
+ * retry calls `creditFromReturn` again with the same `returnCaseId`. This table
8
+ * is what makes the second call a no-op instead of a second credit.
9
+ *
10
+ * `return_case_id` is unique and carries no foreign key: `returns` depends on
11
+ * `credit_limits`, and a constraint the other way would invert that dependency.
12
+ */
13
+ export declare class Migration20260817T201111CreditLimitsReturnTopups extends Migration {
14
+ up(): Promise<void>;
15
+ down(): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=20260817T201111_credit_limits_return_topups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260817T201111_credit_limits_return_topups.d.ts","sourceRoot":"","sources":["../../src/migrations/20260817T201111_credit_limits_return_topups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,qBAAa,gDAAiD,SAAQ,SAAS;IAC9D,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
@@ -0,0 +1,36 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * `credit_limit_return_topups` — one credit per return case (D-91).
4
+ *
5
+ * The settlement ordering law attempts every external effect before it writes
6
+ * any state, so a refusal from a later step leaves a retryable case and the
7
+ * retry calls `creditFromReturn` again with the same `returnCaseId`. This table
8
+ * is what makes the second call a no-op instead of a second credit.
9
+ *
10
+ * `return_case_id` is unique and carries no foreign key: `returns` depends on
11
+ * `credit_limits`, and a constraint the other way would invert that dependency.
12
+ */
13
+ export class Migration20260817T201111CreditLimitsReturnTopups extends Migration {
14
+ async up() {
15
+ this.addSql(`
16
+ create table "credit_limit_return_topups" (
17
+ "id" uuid not null,
18
+ "return_case_id" uuid not null,
19
+ "organization_id" uuid not null,
20
+ "amount" numeric(14,2) not null,
21
+ "currency" varchar(3) not null,
22
+ "applied_at" timestamptz not null,
23
+ constraint "credit_limit_return_topups_pkey" primary key ("id"),
24
+ constraint "credit_limit_return_topups_return_case_id_unique" unique ("return_case_id")
25
+ );
26
+ `);
27
+ this.addSql(`
28
+ create index "credit_limit_return_topups_organization_id_index"
29
+ on "credit_limit_return_topups" ("organization_id");
30
+ `);
31
+ }
32
+ async down() {
33
+ this.addSql(`drop table if exists "credit_limit_return_topups";`);
34
+ }
35
+ }
36
+ //# sourceMappingURL=20260817T201111_credit_limits_return_topups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260817T201111_credit_limits_return_topups.js","sourceRoot":"","sources":["../../src/migrations/20260817T201111_credit_limits_return_topups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gDAAiD,SAAQ,SAAS;IACpE,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;KAWX,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * `credit_limit_reservations.order_id` gains the foreign key it never had
4
+ * (D-94.1, site 4 — the site the D-94 sweep found, of exactly the shape D-90
5
+ * repaired for `shipments.order_id`).
6
+ *
7
+ * `CreditLimitService.reserve({ tx })` is called from `placeOrder` with the
8
+ * placement `EntityManager`, so the `PESSIMISTIC_WRITE` on the organization's
9
+ * `credit_limits` row — or the owning ancestor's row, taken with
10
+ * `select … for update` — is held until placement commits. A separate
11
+ * transaction would leave credit consumed for an order that rolled back:
12
+ * `stock_allocations`' argument, in money. D-78 point 2 rules such a seam
13
+ * permanent and *declared*, and what makes the declaration honest is a
14
+ * constraint. The omission tracks the module boundary and nothing else — the
15
+ * same `create table` (`20260425T063333_credit_limits_init.ts:34-48`) declares
16
+ * `credit_limit_reservations_credit_limit_fk` on `credit_limit_id` and leaves
17
+ * `order_id` bare.
18
+ *
19
+ * `on delete restrict`: a reservation row is one half of a counter. Deleting
20
+ * an order under `cascade` would drop the reservation while the credit stays
21
+ * drawn. `restrict` says the only correct thing — release it first.
22
+ *
23
+ * The column accepted unconstrained values from 2026-04-25 until this
24
+ * migration, so the constraint is preceded by an explicit orphan report. Any
25
+ * orphan with `status = 'active'` has been silently consuming an
26
+ * organization's available credit, and `releaseByOrder` — which looks the
27
+ * reservation up **by order id** — cannot reach it. Export first (it is a
28
+ * money record), then delete; releasing rather than deleting does not satisfy
29
+ * the constraint, because the row still names a missing order. If the locked
30
+ * amount is non-zero, tell the organization's owner what their available
31
+ * credit was and what it now is: this is a customer-facing correction, not a
32
+ * schema chore (D-94.2, remedy 3).
33
+ *
34
+ * `credit_limits` declares `orders` in its manifest `dependencies` for this
35
+ * edge (AGENTS.md § Migrations item 4). The reverse port edge — `orders`
36
+ * resolving `creditLimitService` — moves to `acknowledgedDependencies`, which
37
+ * drops the install ordering the constraint says is backwards and keeps every
38
+ * refusal exactly as it was (D-94.3).
39
+ */
40
+ export declare class Migration20260818T081252CreditLimitsCreditLimitReservationOrderFk extends Migration {
41
+ up(): Promise<void>;
42
+ down(): Promise<void>;
43
+ }
44
+ //# sourceMappingURL=20260818T081252_credit_limits_credit_limit_reservation_order_fk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260818T081252_credit_limits_credit_limit_reservation_order_fk.d.ts","sourceRoot":"","sources":["../../src/migrations/20260818T081252_credit_limits_credit_limit_reservation_order_fk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,iEAAkE,SAAQ,SAAS;IAC/E,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAsCnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAKrC"}