@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,4 +1,4 @@
|
|
|
1
|
-
import { P as CommissionCollection, i as CommissionCalculationService, y as CommissionPlanCollection } from "./commissions-
|
|
1
|
+
import { P as CommissionCollection, i as CommissionCalculationService, y as CommissionPlanCollection } from "./commissions-BAsJWmKg.js";
|
|
2
2
|
import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
3
3
|
import { TenantScoped, requireTenantId, tenantId } from "@happyvertical/smrt-tenancy";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -930,7 +930,7 @@ var ReferralAgreementCollection = class extends SmrtCollection {
|
|
|
930
930
|
}
|
|
931
931
|
};
|
|
932
932
|
//#endregion
|
|
933
|
-
//#region src/referrals/models/
|
|
933
|
+
//#region src/referrals/models/ReferralClickOperation.ts
|
|
934
934
|
var __defProp$6 = Object.defineProperty;
|
|
935
935
|
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
936
936
|
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
@@ -939,6 +939,113 @@ var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
|
939
939
|
if (kind && result) __defProp$6(target, key, result);
|
|
940
940
|
return result;
|
|
941
941
|
};
|
|
942
|
+
var ReferralClickOperation = class extends SmrtObject {
|
|
943
|
+
tenantId = null;
|
|
944
|
+
keyHash;
|
|
945
|
+
linkId;
|
|
946
|
+
touchId;
|
|
947
|
+
intentHash;
|
|
948
|
+
callerEvidenceHash;
|
|
949
|
+
requestedOccurredAt;
|
|
950
|
+
constructor(options = {}) {
|
|
951
|
+
super(options);
|
|
952
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
953
|
+
if (options.keyHash !== void 0) this.keyHash = options.keyHash;
|
|
954
|
+
if (options.linkId !== void 0) this.linkId = options.linkId;
|
|
955
|
+
if (options.touchId !== void 0) this.touchId = options.touchId;
|
|
956
|
+
if (options.intentHash !== void 0) this.intentHash = options.intentHash;
|
|
957
|
+
if (options.callerEvidenceHash !== void 0) this.callerEvidenceHash = options.callerEvidenceHash;
|
|
958
|
+
if (options.requestedOccurredAt !== void 0) this.requestedOccurredAt = options.requestedOccurredAt;
|
|
959
|
+
}
|
|
960
|
+
/** Keep the TEXT replay marker a string when adapters parse `*_at`. */
|
|
961
|
+
async initialize() {
|
|
962
|
+
await super.initialize();
|
|
963
|
+
const value = this.requestedOccurredAt;
|
|
964
|
+
if (value instanceof Date) this.requestedOccurredAt = value.toISOString();
|
|
965
|
+
return this;
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
__decorateClass$6([tenantId({ nullable: true })], ReferralClickOperation.prototype, "tenantId", 2);
|
|
969
|
+
__decorateClass$6([field({
|
|
970
|
+
required: true,
|
|
971
|
+
readonly: true
|
|
972
|
+
})], ReferralClickOperation.prototype, "keyHash", 2);
|
|
973
|
+
__decorateClass$6([field({
|
|
974
|
+
sqlType: "UUID",
|
|
975
|
+
required: true,
|
|
976
|
+
readonly: true,
|
|
977
|
+
indexed: true
|
|
978
|
+
})], ReferralClickOperation.prototype, "linkId", 2);
|
|
979
|
+
__decorateClass$6([field({
|
|
980
|
+
sqlType: "UUID",
|
|
981
|
+
required: true,
|
|
982
|
+
readonly: true,
|
|
983
|
+
indexed: true
|
|
984
|
+
})], ReferralClickOperation.prototype, "touchId", 2);
|
|
985
|
+
__decorateClass$6([field({
|
|
986
|
+
required: true,
|
|
987
|
+
readonly: true
|
|
988
|
+
})], ReferralClickOperation.prototype, "intentHash", 2);
|
|
989
|
+
__decorateClass$6([field({
|
|
990
|
+
required: true,
|
|
991
|
+
readonly: true
|
|
992
|
+
})], ReferralClickOperation.prototype, "callerEvidenceHash", 2);
|
|
993
|
+
__decorateClass$6([field({
|
|
994
|
+
required: true,
|
|
995
|
+
readonly: true
|
|
996
|
+
})], ReferralClickOperation.prototype, "requestedOccurredAt", 2);
|
|
997
|
+
ReferralClickOperation = __decorateClass$6([TenantScoped({ mode: "optional" }), smrt({
|
|
998
|
+
api: false,
|
|
999
|
+
mcp: false,
|
|
1000
|
+
cli: false
|
|
1001
|
+
})], ReferralClickOperation);
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region src/referrals/collections/ReferralClickOperationCollection.ts
|
|
1004
|
+
var ReferralClickOperationCollection = class extends SmrtCollection {
|
|
1005
|
+
static _itemClass = ReferralClickOperation;
|
|
1006
|
+
/** Tenant-filtered lookup; a foreign operation payload remains invisible. */
|
|
1007
|
+
async findByOperationId(operationId) {
|
|
1008
|
+
return await this.get({ id: operationId }, { cache: false });
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Claim the deterministic operation UUID without changing a winner.
|
|
1012
|
+
* Must run in the transaction that creates the touch and increments the
|
|
1013
|
+
* link counter.
|
|
1014
|
+
*/
|
|
1015
|
+
async claim(input) {
|
|
1016
|
+
const inserted = await this.query(`INSERT INTO ${this.tableName} (
|
|
1017
|
+
id, slug, context, tenant_id, key_hash, link_id, touch_id,
|
|
1018
|
+
intent_hash, caller_evidence_hash, requested_occurred_at
|
|
1019
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1020
|
+
ON CONFLICT (id) DO NOTHING
|
|
1021
|
+
RETURNING id`, [
|
|
1022
|
+
input.operationId,
|
|
1023
|
+
input.operationId,
|
|
1024
|
+
"",
|
|
1025
|
+
input.tenantId,
|
|
1026
|
+
input.keyHash,
|
|
1027
|
+
input.linkId,
|
|
1028
|
+
input.touchId,
|
|
1029
|
+
input.intentHash,
|
|
1030
|
+
input.callerEvidenceHash,
|
|
1031
|
+
input.requestedOccurredAt
|
|
1032
|
+
], { allowRawOnTenantScoped: true });
|
|
1033
|
+
return {
|
|
1034
|
+
operation: await this.findByOperationId(input.operationId),
|
|
1035
|
+
claimed: inserted.length === 1
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region src/referrals/models/Referral.ts
|
|
1041
|
+
var __defProp$5 = Object.defineProperty;
|
|
1042
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
1043
|
+
var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
1044
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
|
|
1045
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1046
|
+
if (kind && result) __defProp$5(target, key, result);
|
|
1047
|
+
return result;
|
|
1048
|
+
};
|
|
942
1049
|
var REFERRAL_STATUS_TRANSITIONS = {
|
|
943
1050
|
pending: [
|
|
944
1051
|
"attributed",
|
|
@@ -1143,11 +1250,11 @@ var Referral = class extends SmrtObject {
|
|
|
1143
1250
|
return null;
|
|
1144
1251
|
}
|
|
1145
1252
|
};
|
|
1146
|
-
__decorateClass$
|
|
1147
|
-
__decorateClass$
|
|
1148
|
-
__decorateClass$
|
|
1149
|
-
__decorateClass$
|
|
1150
|
-
Referral = __decorateClass$
|
|
1253
|
+
__decorateClass$5([tenantId({ nullable: true })], Referral.prototype, "tenantId", 2);
|
|
1254
|
+
__decorateClass$5([foreignKey("Referrer", { required: true })], Referral.prototype, "referrerId", 2);
|
|
1255
|
+
__decorateClass$5([foreignKey("ReferralProgram", { required: true })], Referral.prototype, "programId", 2);
|
|
1256
|
+
__decorateClass$5([foreignKey("ReferralTouch")], Referral.prototype, "primaryTouchId", 2);
|
|
1257
|
+
Referral = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
|
|
1151
1258
|
api: { include: [
|
|
1152
1259
|
"list",
|
|
1153
1260
|
"get",
|
|
@@ -1217,12 +1324,12 @@ var ReferralCollection = class extends SmrtCollection {
|
|
|
1217
1324
|
};
|
|
1218
1325
|
//#endregion
|
|
1219
1326
|
//#region src/referrals/models/ReferralLink.ts
|
|
1220
|
-
var __defProp$
|
|
1221
|
-
var __getOwnPropDesc$
|
|
1222
|
-
var __decorateClass$
|
|
1223
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1327
|
+
var __defProp$4 = Object.defineProperty;
|
|
1328
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
1329
|
+
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
1330
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
|
|
1224
1331
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1225
|
-
if (kind && result) __defProp$
|
|
1332
|
+
if (kind && result) __defProp$4(target, key, result);
|
|
1226
1333
|
return result;
|
|
1227
1334
|
};
|
|
1228
1335
|
function assertHttpTargetUrl(targetUrl) {
|
|
@@ -1308,11 +1415,11 @@ var ReferralLink = class extends SmrtObject {
|
|
|
1308
1415
|
return await super.save();
|
|
1309
1416
|
}
|
|
1310
1417
|
};
|
|
1311
|
-
__decorateClass$
|
|
1312
|
-
__decorateClass$
|
|
1313
|
-
__decorateClass$
|
|
1314
|
-
__decorateClass$
|
|
1315
|
-
ReferralLink = __decorateClass$
|
|
1418
|
+
__decorateClass$4([tenantId({ nullable: true })], ReferralLink.prototype, "tenantId", 2);
|
|
1419
|
+
__decorateClass$4([foreignKey("Referrer", { required: true })], ReferralLink.prototype, "referrerId", 2);
|
|
1420
|
+
__decorateClass$4([foreignKey("ReferralProgram", { required: true })], ReferralLink.prototype, "programId", 2);
|
|
1421
|
+
__decorateClass$4([field({ required: true })], ReferralLink.prototype, "code", 2);
|
|
1422
|
+
ReferralLink = __decorateClass$4([TenantScoped({ mode: "optional" }), smrt({
|
|
1316
1423
|
conflictColumns: ["code"],
|
|
1317
1424
|
api: { include: [
|
|
1318
1425
|
"list",
|
|
@@ -1328,113 +1435,6 @@ ReferralLink = __decorateClass$5([TenantScoped({ mode: "optional" }), smrt({
|
|
|
1328
1435
|
cli: true
|
|
1329
1436
|
})], ReferralLink);
|
|
1330
1437
|
//#endregion
|
|
1331
|
-
//#region src/referrals/models/ReferralClickOperation.ts
|
|
1332
|
-
var __defProp$4 = Object.defineProperty;
|
|
1333
|
-
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
1334
|
-
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
1335
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
|
|
1336
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1337
|
-
if (kind && result) __defProp$4(target, key, result);
|
|
1338
|
-
return result;
|
|
1339
|
-
};
|
|
1340
|
-
var ReferralClickOperation = class extends SmrtObject {
|
|
1341
|
-
tenantId = null;
|
|
1342
|
-
keyHash;
|
|
1343
|
-
linkId;
|
|
1344
|
-
touchId;
|
|
1345
|
-
intentHash;
|
|
1346
|
-
callerEvidenceHash;
|
|
1347
|
-
requestedOccurredAt;
|
|
1348
|
-
constructor(options = {}) {
|
|
1349
|
-
super(options);
|
|
1350
|
-
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
1351
|
-
if (options.keyHash !== void 0) this.keyHash = options.keyHash;
|
|
1352
|
-
if (options.linkId !== void 0) this.linkId = options.linkId;
|
|
1353
|
-
if (options.touchId !== void 0) this.touchId = options.touchId;
|
|
1354
|
-
if (options.intentHash !== void 0) this.intentHash = options.intentHash;
|
|
1355
|
-
if (options.callerEvidenceHash !== void 0) this.callerEvidenceHash = options.callerEvidenceHash;
|
|
1356
|
-
if (options.requestedOccurredAt !== void 0) this.requestedOccurredAt = options.requestedOccurredAt;
|
|
1357
|
-
}
|
|
1358
|
-
/** Keep the TEXT replay marker a string when adapters parse `*_at`. */
|
|
1359
|
-
async initialize() {
|
|
1360
|
-
await super.initialize();
|
|
1361
|
-
const value = this.requestedOccurredAt;
|
|
1362
|
-
if (value instanceof Date) this.requestedOccurredAt = value.toISOString();
|
|
1363
|
-
return this;
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
__decorateClass$4([tenantId({ nullable: true })], ReferralClickOperation.prototype, "tenantId", 2);
|
|
1367
|
-
__decorateClass$4([field({
|
|
1368
|
-
required: true,
|
|
1369
|
-
readonly: true
|
|
1370
|
-
})], ReferralClickOperation.prototype, "keyHash", 2);
|
|
1371
|
-
__decorateClass$4([field({
|
|
1372
|
-
sqlType: "UUID",
|
|
1373
|
-
required: true,
|
|
1374
|
-
readonly: true,
|
|
1375
|
-
indexed: true
|
|
1376
|
-
})], ReferralClickOperation.prototype, "linkId", 2);
|
|
1377
|
-
__decorateClass$4([field({
|
|
1378
|
-
sqlType: "UUID",
|
|
1379
|
-
required: true,
|
|
1380
|
-
readonly: true,
|
|
1381
|
-
indexed: true
|
|
1382
|
-
})], ReferralClickOperation.prototype, "touchId", 2);
|
|
1383
|
-
__decorateClass$4([field({
|
|
1384
|
-
required: true,
|
|
1385
|
-
readonly: true
|
|
1386
|
-
})], ReferralClickOperation.prototype, "intentHash", 2);
|
|
1387
|
-
__decorateClass$4([field({
|
|
1388
|
-
required: true,
|
|
1389
|
-
readonly: true
|
|
1390
|
-
})], ReferralClickOperation.prototype, "callerEvidenceHash", 2);
|
|
1391
|
-
__decorateClass$4([field({
|
|
1392
|
-
required: true,
|
|
1393
|
-
readonly: true
|
|
1394
|
-
})], ReferralClickOperation.prototype, "requestedOccurredAt", 2);
|
|
1395
|
-
ReferralClickOperation = __decorateClass$4([TenantScoped({ mode: "optional" }), smrt({
|
|
1396
|
-
api: false,
|
|
1397
|
-
mcp: false,
|
|
1398
|
-
cli: false
|
|
1399
|
-
})], ReferralClickOperation);
|
|
1400
|
-
//#endregion
|
|
1401
|
-
//#region src/referrals/collections/ReferralClickOperationCollection.ts
|
|
1402
|
-
var ReferralClickOperationCollection = class extends SmrtCollection {
|
|
1403
|
-
static _itemClass = ReferralClickOperation;
|
|
1404
|
-
/** Tenant-filtered lookup; a foreign operation payload remains invisible. */
|
|
1405
|
-
async findByOperationId(operationId) {
|
|
1406
|
-
return await this.get({ id: operationId }, { cache: false });
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Claim the deterministic operation UUID without changing a winner.
|
|
1410
|
-
* Must run in the transaction that creates the touch and increments the
|
|
1411
|
-
* link counter.
|
|
1412
|
-
*/
|
|
1413
|
-
async claim(input) {
|
|
1414
|
-
const inserted = await this.query(`INSERT INTO ${this.tableName} (
|
|
1415
|
-
id, slug, context, tenant_id, key_hash, link_id, touch_id,
|
|
1416
|
-
intent_hash, caller_evidence_hash, requested_occurred_at
|
|
1417
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1418
|
-
ON CONFLICT (id) DO NOTHING
|
|
1419
|
-
RETURNING id`, [
|
|
1420
|
-
input.operationId,
|
|
1421
|
-
input.operationId,
|
|
1422
|
-
"",
|
|
1423
|
-
input.tenantId,
|
|
1424
|
-
input.keyHash,
|
|
1425
|
-
input.linkId,
|
|
1426
|
-
input.touchId,
|
|
1427
|
-
input.intentHash,
|
|
1428
|
-
input.callerEvidenceHash,
|
|
1429
|
-
input.requestedOccurredAt
|
|
1430
|
-
], { allowRawOnTenantScoped: true });
|
|
1431
|
-
return {
|
|
1432
|
-
operation: await this.findByOperationId(input.operationId),
|
|
1433
|
-
claimed: inserted.length === 1
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
//#endregion
|
|
1438
1438
|
//#region src/referrals/models/ReferralTouch.ts
|
|
1439
1439
|
var __defProp$3 = Object.defineProperty;
|
|
1440
1440
|
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
@@ -3353,6 +3353,6 @@ var ReferralQualificationService = class ReferralQualificationService {
|
|
|
3353
3353
|
}
|
|
3354
3354
|
};
|
|
3355
3355
|
//#endregion
|
|
3356
|
-
export {
|
|
3356
|
+
export { ReferralClickOperation as A, ATTRIBUTION_RESOLUTION_MODES as B, ReferralTouchCollection as C, ReferralCollection as D, assertHttpTargetUrl as E, validateAttributionPolicyTerms as F, REFERRAL_STATUSES as G, REFERRAL_AGREEMENT_STATUSES as H, ATTRIBUTION_CONFLICT_BEHAVIORS as I, AttributionExceptionCollection as J, REFERRAL_TOUCH_KINDS as K, ATTRIBUTION_CREDIT_MODES as L, ReferralAgreement as M, AttributionPolicyCollection as N, Referral as O, AttributionPolicy as P, ATTRIBUTION_EXCEPTION_STATUSES as R, generateReferralCode as S, ReferralLink as T, REFERRAL_LINK_STATUSES as U, REFERRAL_AGREEMENT_APPROVAL_MODES as V, REFERRAL_PROGRAM_STATUSES as W, AttributionException as Y, REFERRAL_CODE_ALPHABET as _, ReferralAgreementExecutionService as a, ReferralClickValidationError as b, ReferrerCollection as c, ReferralTermSnapshot as d, ReferralProgramCollection as f, MAX_REFERRAL_CLICK_IDEMPOTENCY_KEY_BYTES as g, MAX_CODE_GENERATION_ATTEMPTS as h, REFERRAL_AGREEMENT_SOURCE_KIND as i, ReferralAgreementCollection as j, ReferralClickOperationCollection as k, Referrer as l, DEFAULT_REFERRAL_CLICK_EVIDENCE_MAX_BYTES as m, REFERRAL_TERMS_SNAPSHOT_KIND as n, AttributionService as o, ReferralProgram as p, REFERRER_STATUSES as q, ReferralCommissionService as r, QualifiedReferralOverrideError as s, ReferralQualificationService as t, ReferralTermSnapshotCollection as u, REFERRAL_CODE_LENGTH as v, ReferralTouch as w, ReferralLinkCollection as x, ReferralClickReplayConflictError as y, ATTRIBUTION_POLICY_STATUSES as z };
|
|
3357
3357
|
|
|
3358
|
-
//# sourceMappingURL=referrals-
|
|
3358
|
+
//# sourceMappingURL=referrals-CeS9N5PI.js.map
|