@timardex/cluemart-server-shared 1.0.281 → 1.0.284
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/dist/Affiliate-C_g6TdeG.d.ts +396 -0
- package/dist/Affiliate-CmS0A1gU.d.mts +396 -0
- package/dist/{Chat-DYkhie3G.d.mts → Chat-Bnqec74U.d.mts} +4 -4
- package/dist/{Chat-DYkhie3G.d.ts → Chat-Bnqec74U.d.ts} +4 -4
- package/dist/{chunk-6IK6D2KS.mjs → chunk-4FWW5CDC.mjs} +4 -1
- package/dist/chunk-4FWW5CDC.mjs.map +1 -0
- package/dist/index.cjs +97 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +235 -149
- package/dist/index.d.ts +235 -149
- package/dist/index.mjs +82 -0
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +2 -0
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +40 -387
- package/dist/mongoose/index.d.ts +40 -387
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +461 -374
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +91 -5
- package/dist/service/index.d.ts +91 -5
- package/dist/service/index.mjs +83 -1
- package/dist/service/index.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/Relation-6t3Gn4pM.d.ts +0 -47
- package/dist/Relation-BjYghDE9.d.mts +0 -47
- package/dist/chunk-6IK6D2KS.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ACTIVE_NOT_DELETED_FILTER: () => ACTIVE_NOT_DELETED_FILTER,
|
|
34
|
+
AFFILIATE_REWARDS: () => AFFILIATE_REWARDS,
|
|
33
35
|
APP_SETTINGS_ID: () => APP_SETTINGS_ID,
|
|
34
36
|
AdModel: () => AdModel,
|
|
35
37
|
AffiliateModel: () => AffiliateModel,
|
|
@@ -60,17 +62,22 @@ __export(index_exports, {
|
|
|
60
62
|
VendorInfoModel: () => VendorInfoModel,
|
|
61
63
|
VendorModel: () => VendorModel,
|
|
62
64
|
VerificationTokenModel: () => VerificationTokenModel,
|
|
65
|
+
activeAffiliateCodeExists: () => activeAffiliateCodeExists,
|
|
63
66
|
associatesSchema: () => associatesSchema,
|
|
64
67
|
baseResourceFields: () => baseResourceFields,
|
|
65
68
|
connectToDatabase: () => connectToDatabase,
|
|
66
69
|
convertObjectIdsToStrings: () => convertObjectIdsToStrings,
|
|
70
|
+
createAffiliateReward: () => createAffiliateReward,
|
|
67
71
|
dateTimeSchema: () => dateTimeSchema2,
|
|
68
72
|
didRemoveAnyEventDates: () => didRemoveAnyEventDates,
|
|
69
73
|
express: () => import_express.default,
|
|
74
|
+
findAffiliateByPromoCode: () => findAffiliateByPromoCode,
|
|
70
75
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
71
76
|
locationGeoSchema: () => locationGeoSchema,
|
|
72
77
|
locationsSchema: () => locationsSchema,
|
|
73
|
-
mongoose: () =>
|
|
78
|
+
mongoose: () => import_mongoose36.default,
|
|
79
|
+
normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
|
|
80
|
+
normalizePromoCode: () => normalizePromoCode,
|
|
74
81
|
refundPolicySchema: () => refundPolicySchema,
|
|
75
82
|
relatedPostSchema: () => relatedPostSchema,
|
|
76
83
|
relationDatesSchema: () => relationDatesSchema,
|
|
@@ -7510,6 +7517,7 @@ var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
|
|
|
7510
7517
|
var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
|
|
7511
7518
|
fragment AffiliateResourceFields on AffiliateResourceType {
|
|
7512
7519
|
resourceActive
|
|
7520
|
+
resourceDeletedAt
|
|
7513
7521
|
resourceId
|
|
7514
7522
|
resourceName
|
|
7515
7523
|
resourceType
|
|
@@ -9303,6 +9311,7 @@ var affiliateRewardSchema = new MongooseSchema25(
|
|
|
9303
9311
|
var affiliateResourceSchema = new MongooseSchema25(
|
|
9304
9312
|
{
|
|
9305
9313
|
resourceActive: { default: true, required: true, type: Boolean },
|
|
9314
|
+
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
9306
9315
|
resourceId: {
|
|
9307
9316
|
required: true,
|
|
9308
9317
|
type: import_mongoose25.default.Schema.Types.ObjectId
|
|
@@ -9386,8 +9395,81 @@ schema17.index(
|
|
|
9386
9395
|
);
|
|
9387
9396
|
var AffiliateModel = import_mongoose25.default.models.Affiliate || import_mongoose25.default.model("Affiliate", schema17);
|
|
9388
9397
|
|
|
9398
|
+
// src/service/promoCode/constants.ts
|
|
9399
|
+
var ACTIVE_NOT_DELETED_FILTER = {
|
|
9400
|
+
active: true,
|
|
9401
|
+
deletedAt: null
|
|
9402
|
+
};
|
|
9403
|
+
|
|
9404
|
+
// src/service/affiliate/activeAffiliateCodeExists.ts
|
|
9405
|
+
async function activeAffiliateCodeExists(affiliateCode) {
|
|
9406
|
+
const existing = await AffiliateModel.exists({
|
|
9407
|
+
...ACTIVE_NOT_DELETED_FILTER,
|
|
9408
|
+
affiliateCode
|
|
9409
|
+
}).exec();
|
|
9410
|
+
return existing !== null;
|
|
9411
|
+
}
|
|
9412
|
+
|
|
9413
|
+
// src/service/affiliate/createAffiliateReward.ts
|
|
9414
|
+
var AFFILIATE_REWARDS = {
|
|
9415
|
+
[EnumAffiliateRewardType.NEW_EVENT_REGISTRATION]: {
|
|
9416
|
+
description: "10 points for new event registration (one-time reward)",
|
|
9417
|
+
value: 10
|
|
9418
|
+
},
|
|
9419
|
+
[EnumAffiliateRewardType.NEW_VENDOR_REGISTRATION]: {
|
|
9420
|
+
description: "5 points for new vendor registration (one-time reward)",
|
|
9421
|
+
value: 5
|
|
9422
|
+
},
|
|
9423
|
+
[EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION]: {
|
|
9424
|
+
description: "3 points for active vendor pro subscription (monthly reward)",
|
|
9425
|
+
value: 3
|
|
9426
|
+
},
|
|
9427
|
+
[EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION]: {
|
|
9428
|
+
description: "1 point for active vendor standard subscription (monthly reward)",
|
|
9429
|
+
value: 1
|
|
9430
|
+
},
|
|
9431
|
+
[EnumAffiliateRewardType.ACTIVE_VENDOR_BONUS_REWARD]: {
|
|
9432
|
+
description: "5 bonus points for every 10th active vendor (one-time reward)",
|
|
9433
|
+
value: 5
|
|
9434
|
+
},
|
|
9435
|
+
[EnumAffiliateRewardType.ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS]: {
|
|
9436
|
+
description: "50 points for active event with vendor registrations (one-time reward)",
|
|
9437
|
+
value: 50
|
|
9438
|
+
}
|
|
9439
|
+
};
|
|
9440
|
+
function createAffiliateReward(rewardType, createdAt) {
|
|
9441
|
+
const reward = AFFILIATE_REWARDS[rewardType];
|
|
9442
|
+
return {
|
|
9443
|
+
createdAt,
|
|
9444
|
+
redeemedAt: null,
|
|
9445
|
+
rewardDescription: reward.description,
|
|
9446
|
+
rewardType,
|
|
9447
|
+
rewardValue: reward.value
|
|
9448
|
+
};
|
|
9449
|
+
}
|
|
9450
|
+
|
|
9451
|
+
// src/service/affiliate/findAffiliateByPromoCode.ts
|
|
9452
|
+
async function findAffiliateByPromoCode(promoCode) {
|
|
9453
|
+
return AffiliateModel.findOne({
|
|
9454
|
+
affiliateCode: promoCode,
|
|
9455
|
+
deletedAt: null
|
|
9456
|
+
}).exec();
|
|
9457
|
+
}
|
|
9458
|
+
|
|
9459
|
+
// src/service/promoCode/normalizePromoCode.ts
|
|
9460
|
+
function normalizePromoCode(decoratedPromoCode) {
|
|
9461
|
+
const normalized = decoratedPromoCode?.trim().toUpperCase();
|
|
9462
|
+
return normalized || null;
|
|
9463
|
+
}
|
|
9464
|
+
|
|
9465
|
+
// src/service/affiliate/normalizeAffiliatePromoCodes.ts
|
|
9466
|
+
function normalizeAffiliatePromoCodes(promoCodes) {
|
|
9467
|
+
const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);
|
|
9468
|
+
return [...new Set(normalized)];
|
|
9469
|
+
}
|
|
9470
|
+
|
|
9389
9471
|
// src/service/database.ts
|
|
9390
|
-
var
|
|
9472
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
9391
9473
|
var connectToDatabase = async ({
|
|
9392
9474
|
appName,
|
|
9393
9475
|
dbName,
|
|
@@ -9400,7 +9482,7 @@ var connectToDatabase = async ({
|
|
|
9400
9482
|
// Fallback to MongoDB Atlas connection string
|
|
9401
9483
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
9402
9484
|
);
|
|
9403
|
-
await
|
|
9485
|
+
await import_mongoose28.default.connect(mongoUri);
|
|
9404
9486
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
9405
9487
|
console.log(
|
|
9406
9488
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -9580,9 +9662,9 @@ async function updateAdStatuses() {
|
|
|
9580
9662
|
}
|
|
9581
9663
|
|
|
9582
9664
|
// src/service/associate.ts
|
|
9583
|
-
var
|
|
9665
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
9584
9666
|
function normalizeObjectId(id) {
|
|
9585
|
-
return typeof id === "string" ? new
|
|
9667
|
+
return typeof id === "string" ? new import_mongoose30.default.Types.ObjectId(id) : id;
|
|
9586
9668
|
}
|
|
9587
9669
|
async function getAssociateEmailsForResource({
|
|
9588
9670
|
normalizedResourceId,
|
|
@@ -9734,12 +9816,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
9734
9816
|
}
|
|
9735
9817
|
|
|
9736
9818
|
// src/service/objectIdToString.ts
|
|
9737
|
-
var
|
|
9819
|
+
var import_mongoose33 = __toESM(require("mongoose"));
|
|
9738
9820
|
function convertObjectIdsToStrings(obj) {
|
|
9739
9821
|
if (obj === null || obj === void 0) {
|
|
9740
9822
|
return obj;
|
|
9741
9823
|
}
|
|
9742
|
-
if (obj instanceof
|
|
9824
|
+
if (obj instanceof import_mongoose33.default.Types.ObjectId) {
|
|
9743
9825
|
return obj.toString();
|
|
9744
9826
|
}
|
|
9745
9827
|
if (obj instanceof Date) {
|
|
@@ -9923,7 +10005,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
9923
10005
|
|
|
9924
10006
|
// src/types/index.ts
|
|
9925
10007
|
var import_express = __toESM(require("express"));
|
|
9926
|
-
var
|
|
10008
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
9927
10009
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
9928
10010
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
9929
10011
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -9933,6 +10015,8 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
9933
10015
|
})(EnumPubSubEvents || {});
|
|
9934
10016
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9935
10017
|
0 && (module.exports = {
|
|
10018
|
+
ACTIVE_NOT_DELETED_FILTER,
|
|
10019
|
+
AFFILIATE_REWARDS,
|
|
9936
10020
|
APP_SETTINGS_ID,
|
|
9937
10021
|
AdModel,
|
|
9938
10022
|
AffiliateModel,
|
|
@@ -9963,17 +10047,22 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
9963
10047
|
VendorInfoModel,
|
|
9964
10048
|
VendorModel,
|
|
9965
10049
|
VerificationTokenModel,
|
|
10050
|
+
activeAffiliateCodeExists,
|
|
9966
10051
|
associatesSchema,
|
|
9967
10052
|
baseResourceFields,
|
|
9968
10053
|
connectToDatabase,
|
|
9969
10054
|
convertObjectIdsToStrings,
|
|
10055
|
+
createAffiliateReward,
|
|
9970
10056
|
dateTimeSchema,
|
|
9971
10057
|
didRemoveAnyEventDates,
|
|
9972
10058
|
express,
|
|
10059
|
+
findAffiliateByPromoCode,
|
|
9973
10060
|
findEventOrImportedMarketById,
|
|
9974
10061
|
locationGeoSchema,
|
|
9975
10062
|
locationsSchema,
|
|
9976
10063
|
mongoose,
|
|
10064
|
+
normalizeAffiliatePromoCodes,
|
|
10065
|
+
normalizePromoCode,
|
|
9977
10066
|
refundPolicySchema,
|
|
9978
10067
|
relatedPostSchema,
|
|
9979
10068
|
relationDatesSchema,
|