@happyvertical/smrt-sales 0.40.11 → 0.40.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -0
- package/dist/agreements.js +1 -1
- package/dist/chunks/{__smrt-register__-CPynA4ag.js → __smrt-register__-ClaEBEfu.js} +2 -2
- package/dist/chunks/{__smrt-register__-CPynA4ag.js.map → __smrt-register__-ClaEBEfu.js.map} +1 -1
- package/dist/chunks/{commissions-CelWwvjZ.js → commissions-BAsJWmKg.js} +127 -127
- package/dist/chunks/{commissions-CelWwvjZ.js.map → commissions-BAsJWmKg.js.map} +1 -1
- package/dist/chunks/{referrals-CJUOZxpa.js → referrals-CeS9N5PI.js} +126 -126
- package/dist/chunks/{referrals-CJUOZxpa.js.map → referrals-CeS9N5PI.js.map} +1 -1
- package/dist/commissions/collections/index.d.ts +1 -0
- package/dist/commissions/collections/index.d.ts.map +1 -1
- package/dist/commissions/models/index.d.ts +1 -0
- package/dist/commissions/models/index.d.ts.map +1 -1
- package/dist/commissions.js +3 -3
- package/dist/crm.js +1 -1
- package/dist/index.js +4 -4
- package/dist/manifest.json +3447 -3447
- package/dist/referrals/index.d.ts +2 -0
- package/dist/referrals/index.d.ts.map +1 -1
- package/dist/referrals.js +3 -3
- package/dist/smrt-knowledge.json +1883 -1883
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__smrt-register__-
|
|
1
|
+
{"version":3,"file":"__smrt-register__-ClaEBEfu.js","names":[],"sources":["../../src/__smrt-register__.ts"],"sourcesContent":["import { ObjectRegistry } from '@happyvertical/smrt-core';\n\nObjectRegistry.registerPackageManifest(\n new URL('./manifest.json', import.meta.url),\n);\n"],"mappings":""}
|
|
@@ -194,7 +194,7 @@ var CommissionAdjustmentCollection = class extends SmrtCollection {
|
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
//#endregion
|
|
197
|
-
//#region src/commissions/models/
|
|
197
|
+
//#region src/commissions/models/CommissionAdjustmentOperation.ts
|
|
198
198
|
var __defProp$6 = Object.defineProperty;
|
|
199
199
|
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
200
200
|
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
@@ -203,6 +203,76 @@ var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
|
203
203
|
if (kind && result) __defProp$6(target, key, result);
|
|
204
204
|
return result;
|
|
205
205
|
};
|
|
206
|
+
var CommissionAdjustmentOperation = class extends SmrtObject {
|
|
207
|
+
tenantId = "";
|
|
208
|
+
adjustmentId;
|
|
209
|
+
constructor(options = {}) {
|
|
210
|
+
super(options);
|
|
211
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
212
|
+
if (options.adjustmentId !== void 0) this.adjustmentId = options.adjustmentId;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
__decorateClass$6([tenantId()], CommissionAdjustmentOperation.prototype, "tenantId", 2);
|
|
216
|
+
__decorateClass$6([field({
|
|
217
|
+
sqlType: "UUID",
|
|
218
|
+
required: true,
|
|
219
|
+
readonly: true,
|
|
220
|
+
indexed: true
|
|
221
|
+
})], CommissionAdjustmentOperation.prototype, "adjustmentId", 2);
|
|
222
|
+
CommissionAdjustmentOperation = __decorateClass$6([TenantScoped({ mode: "required" }), smrt({
|
|
223
|
+
api: false,
|
|
224
|
+
mcp: false,
|
|
225
|
+
cli: false
|
|
226
|
+
})], CommissionAdjustmentOperation);
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/commissions/collections/CommissionAdjustmentOperationCollection.ts
|
|
229
|
+
var CommissionAdjustmentOperationCollection = class extends SmrtCollection {
|
|
230
|
+
static _itemClass = CommissionAdjustmentOperation;
|
|
231
|
+
/** Tenant-scoped lookup; foreign-tenant operation payloads stay invisible. */
|
|
232
|
+
async findByOperationId(operationId) {
|
|
233
|
+
const tenantId = requireTenantId();
|
|
234
|
+
const [operation] = await this.query(`SELECT
|
|
235
|
+
id, slug, context, created_at, updated_at, tenant_id,
|
|
236
|
+
CAST(adjustment_id AS TEXT) AS adjustment_id
|
|
237
|
+
FROM ${this.tableName}
|
|
238
|
+
WHERE id = ? AND tenant_id = ?
|
|
239
|
+
LIMIT 1`, [operationId, tenantId], { allowRawOnTenantScoped: true });
|
|
240
|
+
return operation ?? null;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Claim the globally unique operation UUID without changing an existing
|
|
244
|
+
* winner. This must run inside the same transaction that creates the
|
|
245
|
+
* corresponding adjustment.
|
|
246
|
+
*/
|
|
247
|
+
async claim(input) {
|
|
248
|
+
if (requireTenantId().toLowerCase() !== input.tenantId.toLowerCase()) throw new Error("CommissionAdjustment operation tenant mismatch");
|
|
249
|
+
const inserted = await this.query(`INSERT INTO ${this.tableName} (
|
|
250
|
+
id, slug, context, tenant_id, adjustment_id
|
|
251
|
+
) VALUES (?, ?, ?, ?, ?)
|
|
252
|
+
ON CONFLICT (id) DO NOTHING
|
|
253
|
+
RETURNING id`, [
|
|
254
|
+
input.operationId,
|
|
255
|
+
input.operationId,
|
|
256
|
+
"",
|
|
257
|
+
input.tenantId,
|
|
258
|
+
input.adjustmentId
|
|
259
|
+
], { allowRawOnTenantScoped: true });
|
|
260
|
+
return {
|
|
261
|
+
operation: await this.findByOperationId(input.operationId),
|
|
262
|
+
claimed: inserted.length === 1
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/commissions/models/Commission.ts
|
|
268
|
+
var __defProp$5 = Object.defineProperty;
|
|
269
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
270
|
+
var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
271
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
|
|
272
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
273
|
+
if (kind && result) __defProp$5(target, key, result);
|
|
274
|
+
return result;
|
|
275
|
+
};
|
|
206
276
|
var COMMISSION_STATUS_TRANSITIONS = {
|
|
207
277
|
pending: ["earned"],
|
|
208
278
|
earned: ["approved"],
|
|
@@ -468,12 +538,12 @@ var Commission = class extends SmrtObject {
|
|
|
468
538
|
return null;
|
|
469
539
|
}
|
|
470
540
|
};
|
|
471
|
-
__decorateClass$
|
|
472
|
-
__decorateClass$
|
|
473
|
-
__decorateClass$
|
|
474
|
-
__decorateClass$
|
|
475
|
-
__decorateClass$
|
|
476
|
-
Commission = __decorateClass$
|
|
541
|
+
__decorateClass$5([tenantId({ nullable: true })], Commission.prototype, "tenantId", 2);
|
|
542
|
+
__decorateClass$5([foreignKey("Earner", { required: true })], Commission.prototype, "earnerId", 2);
|
|
543
|
+
__decorateClass$5([foreignKey("EarningEvent")], Commission.prototype, "earningEventId", 2);
|
|
544
|
+
__decorateClass$5([foreignKey("CommissionPayout")], Commission.prototype, "payoutId", 2);
|
|
545
|
+
__decorateClass$5([field({ required: true })], Commission.prototype, "dedupeKey", 2);
|
|
546
|
+
Commission = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
|
|
477
547
|
conflictColumns: ["dedupe_key"],
|
|
478
548
|
api: { include: [
|
|
479
549
|
"list",
|
|
@@ -608,12 +678,12 @@ var CommissionCollection = class extends SmrtCollection {
|
|
|
608
678
|
};
|
|
609
679
|
//#endregion
|
|
610
680
|
//#region src/commissions/models/CommissionPayout.ts
|
|
611
|
-
var __defProp$
|
|
612
|
-
var __getOwnPropDesc$
|
|
613
|
-
var __decorateClass$
|
|
614
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
681
|
+
var __defProp$4 = Object.defineProperty;
|
|
682
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
683
|
+
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
684
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
|
|
615
685
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
616
|
-
if (kind && result) __defProp$
|
|
686
|
+
if (kind && result) __defProp$4(target, key, result);
|
|
617
687
|
return result;
|
|
618
688
|
};
|
|
619
689
|
var PAYOUT_STATUS_TRANSITIONS = {
|
|
@@ -874,12 +944,12 @@ ${memo}` : memo;
|
|
|
874
944
|
return null;
|
|
875
945
|
}
|
|
876
946
|
};
|
|
877
|
-
__decorateClass$
|
|
878
|
-
__decorateClass$
|
|
879
|
-
__decorateClass$
|
|
880
|
-
__decorateClass$
|
|
881
|
-
__decorateClass$
|
|
882
|
-
CommissionPayout = __decorateClass$
|
|
947
|
+
__decorateClass$4([tenantId({ nullable: true })], CommissionPayout.prototype, "tenantId", 2);
|
|
948
|
+
__decorateClass$4([foreignKey("Earner", { required: true })], CommissionPayout.prototype, "earnerId", 2);
|
|
949
|
+
__decorateClass$4([crossPackageRef("@happyvertical/smrt-commerce:Invoice")], CommissionPayout.prototype, "invoiceId", 2);
|
|
950
|
+
__decorateClass$4([field({ required: true })], CommissionPayout.prototype, "idempotencyKey", 2);
|
|
951
|
+
__decorateClass$4([field({ indexed: true })], CommissionPayout.prototype, "sourceId", 2);
|
|
952
|
+
CommissionPayout = __decorateClass$4([TenantScoped({ mode: "optional" }), smrt({
|
|
883
953
|
conflictColumns: ["idempotency_key"],
|
|
884
954
|
api: { include: ["list", "get"] },
|
|
885
955
|
mcp: { include: ["list", "get"] },
|
|
@@ -1010,12 +1080,12 @@ var ADJUSTMENT_SETTLEABLE_COMMISSION_STATUSES = [
|
|
|
1010
1080
|
];
|
|
1011
1081
|
//#endregion
|
|
1012
1082
|
//#region src/commissions/models/CommissionPlan.ts
|
|
1013
|
-
var __defProp$
|
|
1014
|
-
var __getOwnPropDesc$
|
|
1015
|
-
var __decorateClass$
|
|
1016
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1083
|
+
var __defProp$3 = Object.defineProperty;
|
|
1084
|
+
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
1085
|
+
var __decorateClass$3 = (decorators, target, key, kind) => {
|
|
1086
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
|
|
1017
1087
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1018
|
-
if (kind && result) __defProp$
|
|
1088
|
+
if (kind && result) __defProp$3(target, key, result);
|
|
1019
1089
|
return result;
|
|
1020
1090
|
};
|
|
1021
1091
|
var PLAN_STATUS_TRANSITIONS = {
|
|
@@ -1246,9 +1316,9 @@ var CommissionPlan = class extends SmrtObject {
|
|
|
1246
1316
|
return null;
|
|
1247
1317
|
}
|
|
1248
1318
|
};
|
|
1249
|
-
__decorateClass$
|
|
1250
|
-
__decorateClass$
|
|
1251
|
-
CommissionPlan = __decorateClass$
|
|
1319
|
+
__decorateClass$3([tenantId({ nullable: true })], CommissionPlan.prototype, "tenantId", 2);
|
|
1320
|
+
__decorateClass$3([field({ required: true })], CommissionPlan.prototype, "planKey", 2);
|
|
1321
|
+
CommissionPlan = __decorateClass$3([TenantScoped({ mode: "optional" }), smrt({
|
|
1252
1322
|
conflictColumns: [
|
|
1253
1323
|
"tenant_id",
|
|
1254
1324
|
"plan_key",
|
|
@@ -1353,12 +1423,12 @@ var CommissionPlanCollection = class extends SmrtCollection {
|
|
|
1353
1423
|
};
|
|
1354
1424
|
//#endregion
|
|
1355
1425
|
//#region src/commissions/models/Earner.ts
|
|
1356
|
-
var __defProp$
|
|
1357
|
-
var __getOwnPropDesc$
|
|
1358
|
-
var __decorateClass$
|
|
1359
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1426
|
+
var __defProp$2 = Object.defineProperty;
|
|
1427
|
+
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
1428
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
1429
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
1360
1430
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1361
|
-
if (kind && result) __defProp$
|
|
1431
|
+
if (kind && result) __defProp$2(target, key, result);
|
|
1362
1432
|
return result;
|
|
1363
1433
|
};
|
|
1364
1434
|
var Earner = class extends SmrtObject {
|
|
@@ -1424,9 +1494,9 @@ var Earner = class extends SmrtObject {
|
|
|
1424
1494
|
this.metadata = JSON.stringify(data ?? {});
|
|
1425
1495
|
}
|
|
1426
1496
|
};
|
|
1427
|
-
__decorateClass$
|
|
1428
|
-
__decorateClass$
|
|
1429
|
-
Earner = __decorateClass$
|
|
1497
|
+
__decorateClass$2([tenantId({ nullable: true })], Earner.prototype, "tenantId", 2);
|
|
1498
|
+
__decorateClass$2([crossPackageRef("@happyvertical/smrt-profiles:Profile")], Earner.prototype, "profileId", 2);
|
|
1499
|
+
Earner = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
|
|
1430
1500
|
api: { include: [
|
|
1431
1501
|
"list",
|
|
1432
1502
|
"get",
|
|
@@ -1465,12 +1535,12 @@ var EarnerCollection = class extends SmrtCollection {
|
|
|
1465
1535
|
};
|
|
1466
1536
|
//#endregion
|
|
1467
1537
|
//#region src/commissions/models/EarnerSourceAttribution.ts
|
|
1468
|
-
var __defProp$
|
|
1469
|
-
var __getOwnPropDesc$
|
|
1470
|
-
var __decorateClass$
|
|
1471
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1538
|
+
var __defProp$1 = Object.defineProperty;
|
|
1539
|
+
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
1540
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
1541
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
|
|
1472
1542
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1473
|
-
if (kind && result) __defProp$
|
|
1543
|
+
if (kind && result) __defProp$1(target, key, result);
|
|
1474
1544
|
return result;
|
|
1475
1545
|
};
|
|
1476
1546
|
var EarnerSourceAttribution = class extends SmrtObject {
|
|
@@ -1544,14 +1614,14 @@ var EarnerSourceAttribution = class extends SmrtObject {
|
|
|
1544
1614
|
if (earnerTenant !== mappingTenant) throw new Error(`EarnerSourceAttribution ${this.id ?? "<new>"}: mapping tenant '${mappingTenant ?? "global"}' does not match earner tenant '${earnerTenant ?? "global"}' \u2014 a mapping must live in its earner's tenant.`);
|
|
1545
1615
|
}
|
|
1546
1616
|
};
|
|
1547
|
-
__decorateClass$
|
|
1548
|
-
__decorateClass$
|
|
1549
|
-
__decorateClass$
|
|
1550
|
-
__decorateClass$
|
|
1617
|
+
__decorateClass$1([tenantId({ nullable: true })], EarnerSourceAttribution.prototype, "tenantId", 2);
|
|
1618
|
+
__decorateClass$1([foreignKey("Earner", { required: true })], EarnerSourceAttribution.prototype, "earnerId", 2);
|
|
1619
|
+
__decorateClass$1([field({ required: true })], EarnerSourceAttribution.prototype, "sourceKind", 2);
|
|
1620
|
+
__decorateClass$1([field({
|
|
1551
1621
|
required: true,
|
|
1552
1622
|
indexed: true
|
|
1553
1623
|
})], EarnerSourceAttribution.prototype, "sourceId", 2);
|
|
1554
|
-
EarnerSourceAttribution = __decorateClass$
|
|
1624
|
+
EarnerSourceAttribution = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
|
|
1555
1625
|
conflictColumns: [
|
|
1556
1626
|
"tenant_id",
|
|
1557
1627
|
"source_kind",
|
|
@@ -1617,12 +1687,12 @@ var EarnerSourceAttributionCollection = class extends SmrtCollection {
|
|
|
1617
1687
|
};
|
|
1618
1688
|
//#endregion
|
|
1619
1689
|
//#region src/commissions/models/EarningEvent.ts
|
|
1620
|
-
var __defProp
|
|
1621
|
-
var __getOwnPropDesc
|
|
1622
|
-
var __decorateClass
|
|
1623
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc
|
|
1690
|
+
var __defProp = Object.defineProperty;
|
|
1691
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1692
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
1693
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
1624
1694
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1625
|
-
if (kind && result) __defProp
|
|
1695
|
+
if (kind && result) __defProp(target, key, result);
|
|
1626
1696
|
return result;
|
|
1627
1697
|
};
|
|
1628
1698
|
var persistedEventState = /* @__PURE__ */ new WeakMap();
|
|
@@ -1770,18 +1840,18 @@ var EarningEvent = class extends SmrtObject {
|
|
|
1770
1840
|
return null;
|
|
1771
1841
|
}
|
|
1772
1842
|
};
|
|
1773
|
-
__decorateClass
|
|
1774
|
-
__decorateClass
|
|
1775
|
-
__decorateClass
|
|
1843
|
+
__decorateClass([tenantId({ nullable: true })], EarningEvent.prototype, "tenantId", 2);
|
|
1844
|
+
__decorateClass([field({ required: true })], EarningEvent.prototype, "eventKind", 2);
|
|
1845
|
+
__decorateClass([field({
|
|
1776
1846
|
type: "integer",
|
|
1777
1847
|
nullable: true
|
|
1778
1848
|
})], EarningEvent.prototype, "netAmountCents", 2);
|
|
1779
|
-
__decorateClass
|
|
1849
|
+
__decorateClass([field({
|
|
1780
1850
|
type: "integer",
|
|
1781
1851
|
nullable: true
|
|
1782
1852
|
})], EarningEvent.prototype, "marginCents", 2);
|
|
1783
|
-
__decorateClass
|
|
1784
|
-
EarningEvent = __decorateClass
|
|
1853
|
+
__decorateClass([field({ required: true })], EarningEvent.prototype, "dedupeKey", 2);
|
|
1854
|
+
EarningEvent = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
|
|
1785
1855
|
conflictColumns: ["dedupe_key"],
|
|
1786
1856
|
api: { include: [
|
|
1787
1857
|
"create",
|
|
@@ -1863,76 +1933,6 @@ function calculateCommissionAmountCents(baseCents, rate, shareFraction) {
|
|
|
1863
1933
|
return roundCents(baseCents * rate * (shareFraction ?? 1));
|
|
1864
1934
|
}
|
|
1865
1935
|
//#endregion
|
|
1866
|
-
//#region src/commissions/models/CommissionAdjustmentOperation.ts
|
|
1867
|
-
var __defProp = Object.defineProperty;
|
|
1868
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
1869
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
1870
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
1871
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1872
|
-
if (kind && result) __defProp(target, key, result);
|
|
1873
|
-
return result;
|
|
1874
|
-
};
|
|
1875
|
-
var CommissionAdjustmentOperation = class extends SmrtObject {
|
|
1876
|
-
tenantId = "";
|
|
1877
|
-
adjustmentId;
|
|
1878
|
-
constructor(options = {}) {
|
|
1879
|
-
super(options);
|
|
1880
|
-
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
1881
|
-
if (options.adjustmentId !== void 0) this.adjustmentId = options.adjustmentId;
|
|
1882
|
-
}
|
|
1883
|
-
};
|
|
1884
|
-
__decorateClass([tenantId()], CommissionAdjustmentOperation.prototype, "tenantId", 2);
|
|
1885
|
-
__decorateClass([field({
|
|
1886
|
-
sqlType: "UUID",
|
|
1887
|
-
required: true,
|
|
1888
|
-
readonly: true,
|
|
1889
|
-
indexed: true
|
|
1890
|
-
})], CommissionAdjustmentOperation.prototype, "adjustmentId", 2);
|
|
1891
|
-
CommissionAdjustmentOperation = __decorateClass([TenantScoped({ mode: "required" }), smrt({
|
|
1892
|
-
api: false,
|
|
1893
|
-
mcp: false,
|
|
1894
|
-
cli: false
|
|
1895
|
-
})], CommissionAdjustmentOperation);
|
|
1896
|
-
//#endregion
|
|
1897
|
-
//#region src/commissions/collections/CommissionAdjustmentOperationCollection.ts
|
|
1898
|
-
var CommissionAdjustmentOperationCollection = class extends SmrtCollection {
|
|
1899
|
-
static _itemClass = CommissionAdjustmentOperation;
|
|
1900
|
-
/** Tenant-scoped lookup; foreign-tenant operation payloads stay invisible. */
|
|
1901
|
-
async findByOperationId(operationId) {
|
|
1902
|
-
const tenantId = requireTenantId();
|
|
1903
|
-
const [operation] = await this.query(`SELECT
|
|
1904
|
-
id, slug, context, created_at, updated_at, tenant_id,
|
|
1905
|
-
CAST(adjustment_id AS TEXT) AS adjustment_id
|
|
1906
|
-
FROM ${this.tableName}
|
|
1907
|
-
WHERE id = ? AND tenant_id = ?
|
|
1908
|
-
LIMIT 1`, [operationId, tenantId], { allowRawOnTenantScoped: true });
|
|
1909
|
-
return operation ?? null;
|
|
1910
|
-
}
|
|
1911
|
-
/**
|
|
1912
|
-
* Claim the globally unique operation UUID without changing an existing
|
|
1913
|
-
* winner. This must run inside the same transaction that creates the
|
|
1914
|
-
* corresponding adjustment.
|
|
1915
|
-
*/
|
|
1916
|
-
async claim(input) {
|
|
1917
|
-
if (requireTenantId().toLowerCase() !== input.tenantId.toLowerCase()) throw new Error("CommissionAdjustment operation tenant mismatch");
|
|
1918
|
-
const inserted = await this.query(`INSERT INTO ${this.tableName} (
|
|
1919
|
-
id, slug, context, tenant_id, adjustment_id
|
|
1920
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
1921
|
-
ON CONFLICT (id) DO NOTHING
|
|
1922
|
-
RETURNING id`, [
|
|
1923
|
-
input.operationId,
|
|
1924
|
-
input.operationId,
|
|
1925
|
-
"",
|
|
1926
|
-
input.tenantId,
|
|
1927
|
-
input.adjustmentId
|
|
1928
|
-
], { allowRawOnTenantScoped: true });
|
|
1929
|
-
return {
|
|
1930
|
-
operation: await this.findByOperationId(input.operationId),
|
|
1931
|
-
claimed: inserted.length === 1
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
};
|
|
1935
|
-
//#endregion
|
|
1936
1936
|
//#region src/commissions/services/CommissionAdjustmentService.ts
|
|
1937
1937
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
1938
1938
|
var CommissionAdjustmentReplayConflictError = class extends Error {
|
|
@@ -3550,6 +3550,6 @@ var EarnerAttributionService = class EarnerAttributionService {
|
|
|
3550
3550
|
}
|
|
3551
3551
|
};
|
|
3552
3552
|
//#endregion
|
|
3553
|
-
export { EARNING_EVENT_KINDS as A, COMMISSION_ADJUSTMENT_KINDS as C, COMMISSION_STATUSES as D, COMMISSION_PLAN_STATUSES as E, Commission as F,
|
|
3553
|
+
export { EARNING_EVENT_KINDS as A, COMMISSION_ADJUSTMENT_KINDS as C, COMMISSION_STATUSES as D, COMMISSION_PLAN_STATUSES as E, Commission as F, CommissionAdjustmentOperationCollection as I, CommissionAdjustmentOperation as L, CommissionPayoutCollection as M, CommissionPayout as N, EARNER_SOURCE_ATTRIBUTION_STATUSES as O, CommissionCollection as P, CommissionAdjustmentCollection as R, ADJUSTMENT_SETTLEABLE_COMMISSION_STATUSES as S, COMMISSION_PAYOUT_STATUSES as T, EarnerCollection as _, CommissionBalanceService as a, CommissionPlan as b, CommissionAdjustmentValidationError as c, centsToAmount as d, roundCents as f, EarnerSourceAttribution as g, EarnerSourceAttributionCollection as h, CommissionCalculationService as i, PAYOUT_METHODS as j, EARNER_STATUSES as k, amountToCents as l, EarningEvent as m, CommissionSettlementService as n, CommissionAdjustmentReplayConflictError as o, EarningEventCollection as p, CommissionPayoutService as r, CommissionAdjustmentService as s, EarnerAttributionService as t, calculateCommissionAmountCents as u, Earner as v, COMMISSION_BASES as w, validateCommissionPlanComponents as x, CommissionPlanCollection as y, CommissionAdjustment as z };
|
|
3554
3554
|
|
|
3555
|
-
//# sourceMappingURL=commissions-
|
|
3555
|
+
//# sourceMappingURL=commissions-BAsJWmKg.js.map
|