@timardex/cluemart-server-shared 1.0.280 → 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-EH7TOKEH.mjs → chunk-4FWW5CDC.mjs} +13 -1
- package/dist/chunk-4FWW5CDC.mjs.map +1 -0
- package/dist/index.cjs +106 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +236 -150
- package/dist/index.d.ts +236 -150
- package/dist/index.mjs +91 -0
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +11 -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 +470 -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-EH7TOKEH.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,
|
|
@@ -3700,6 +3707,7 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
|
|
|
3700
3707
|
})(EnumGameType || {});
|
|
3701
3708
|
var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType2) => {
|
|
3702
3709
|
EnumAffiliateRewardType2["ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS"] = "ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS";
|
|
3710
|
+
EnumAffiliateRewardType2["ACTIVE_VENDOR_BONUS_REWARD"] = "ACTIVE_VENDOR_BONUS_REWARD";
|
|
3703
3711
|
EnumAffiliateRewardType2["ACTIVE_VENDOR_PRO_SUBSCRIPTION"] = "ACTIVE_VENDOR_PRO_SUBSCRIPTION";
|
|
3704
3712
|
EnumAffiliateRewardType2["ACTIVE_VENDOR_STANDARD_SUBSCRIPTION"] = "ACTIVE_VENDOR_STANDARD_SUBSCRIPTION";
|
|
3705
3713
|
EnumAffiliateRewardType2["NEW_EVENT_REGISTRATION"] = "NEW_EVENT_REGISTRATION";
|
|
@@ -7509,6 +7517,7 @@ var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
|
|
|
7509
7517
|
var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
|
|
7510
7518
|
fragment AffiliateResourceFields on AffiliateResourceType {
|
|
7511
7519
|
resourceActive
|
|
7520
|
+
resourceDeletedAt
|
|
7512
7521
|
resourceId
|
|
7513
7522
|
resourceName
|
|
7514
7523
|
resourceType
|
|
@@ -7548,6 +7557,9 @@ var AFFILIATE_FIELDS_FRAGMENT = gql`
|
|
|
7548
7557
|
fragment AffiliateFields on AffiliateType {
|
|
7549
7558
|
_id
|
|
7550
7559
|
active
|
|
7560
|
+
affiliateBonusRewards {
|
|
7561
|
+
...AffiliateRewardFields
|
|
7562
|
+
}
|
|
7551
7563
|
affiliateCode
|
|
7552
7564
|
affiliateDetails {
|
|
7553
7565
|
...AffiliateDetailsFields
|
|
@@ -9299,6 +9311,7 @@ var affiliateRewardSchema = new MongooseSchema25(
|
|
|
9299
9311
|
var affiliateResourceSchema = new MongooseSchema25(
|
|
9300
9312
|
{
|
|
9301
9313
|
resourceActive: { default: true, required: true, type: Boolean },
|
|
9314
|
+
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
9302
9315
|
resourceId: {
|
|
9303
9316
|
required: true,
|
|
9304
9317
|
type: import_mongoose25.default.Schema.Types.ObjectId
|
|
@@ -9346,6 +9359,11 @@ var affiliateDetailsSchema = new MongooseSchema25(
|
|
|
9346
9359
|
var schema17 = new MongooseSchema25(
|
|
9347
9360
|
{
|
|
9348
9361
|
active: { default: false, required: true, type: Boolean },
|
|
9362
|
+
affiliateBonusRewards: {
|
|
9363
|
+
default: [],
|
|
9364
|
+
required: false,
|
|
9365
|
+
type: [affiliateRewardSchema]
|
|
9366
|
+
},
|
|
9349
9367
|
affiliateCode: { required: true, type: String },
|
|
9350
9368
|
affiliateDetails: { required: false, type: affiliateDetailsSchema },
|
|
9351
9369
|
affiliateResources: {
|
|
@@ -9377,8 +9395,81 @@ schema17.index(
|
|
|
9377
9395
|
);
|
|
9378
9396
|
var AffiliateModel = import_mongoose25.default.models.Affiliate || import_mongoose25.default.model("Affiliate", schema17);
|
|
9379
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
|
+
|
|
9380
9471
|
// src/service/database.ts
|
|
9381
|
-
var
|
|
9472
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
9382
9473
|
var connectToDatabase = async ({
|
|
9383
9474
|
appName,
|
|
9384
9475
|
dbName,
|
|
@@ -9391,7 +9482,7 @@ var connectToDatabase = async ({
|
|
|
9391
9482
|
// Fallback to MongoDB Atlas connection string
|
|
9392
9483
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
9393
9484
|
);
|
|
9394
|
-
await
|
|
9485
|
+
await import_mongoose28.default.connect(mongoUri);
|
|
9395
9486
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
9396
9487
|
console.log(
|
|
9397
9488
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -9571,9 +9662,9 @@ async function updateAdStatuses() {
|
|
|
9571
9662
|
}
|
|
9572
9663
|
|
|
9573
9664
|
// src/service/associate.ts
|
|
9574
|
-
var
|
|
9665
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
9575
9666
|
function normalizeObjectId(id) {
|
|
9576
|
-
return typeof id === "string" ? new
|
|
9667
|
+
return typeof id === "string" ? new import_mongoose30.default.Types.ObjectId(id) : id;
|
|
9577
9668
|
}
|
|
9578
9669
|
async function getAssociateEmailsForResource({
|
|
9579
9670
|
normalizedResourceId,
|
|
@@ -9725,12 +9816,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
9725
9816
|
}
|
|
9726
9817
|
|
|
9727
9818
|
// src/service/objectIdToString.ts
|
|
9728
|
-
var
|
|
9819
|
+
var import_mongoose33 = __toESM(require("mongoose"));
|
|
9729
9820
|
function convertObjectIdsToStrings(obj) {
|
|
9730
9821
|
if (obj === null || obj === void 0) {
|
|
9731
9822
|
return obj;
|
|
9732
9823
|
}
|
|
9733
|
-
if (obj instanceof
|
|
9824
|
+
if (obj instanceof import_mongoose33.default.Types.ObjectId) {
|
|
9734
9825
|
return obj.toString();
|
|
9735
9826
|
}
|
|
9736
9827
|
if (obj instanceof Date) {
|
|
@@ -9914,7 +10005,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
9914
10005
|
|
|
9915
10006
|
// src/types/index.ts
|
|
9916
10007
|
var import_express = __toESM(require("express"));
|
|
9917
|
-
var
|
|
10008
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
9918
10009
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
9919
10010
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
9920
10011
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -9924,6 +10015,8 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
9924
10015
|
})(EnumPubSubEvents || {});
|
|
9925
10016
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9926
10017
|
0 && (module.exports = {
|
|
10018
|
+
ACTIVE_NOT_DELETED_FILTER,
|
|
10019
|
+
AFFILIATE_REWARDS,
|
|
9927
10020
|
APP_SETTINGS_ID,
|
|
9928
10021
|
AdModel,
|
|
9929
10022
|
AffiliateModel,
|
|
@@ -9954,17 +10047,22 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
9954
10047
|
VendorInfoModel,
|
|
9955
10048
|
VendorModel,
|
|
9956
10049
|
VerificationTokenModel,
|
|
10050
|
+
activeAffiliateCodeExists,
|
|
9957
10051
|
associatesSchema,
|
|
9958
10052
|
baseResourceFields,
|
|
9959
10053
|
connectToDatabase,
|
|
9960
10054
|
convertObjectIdsToStrings,
|
|
10055
|
+
createAffiliateReward,
|
|
9961
10056
|
dateTimeSchema,
|
|
9962
10057
|
didRemoveAnyEventDates,
|
|
9963
10058
|
express,
|
|
10059
|
+
findAffiliateByPromoCode,
|
|
9964
10060
|
findEventOrImportedMarketById,
|
|
9965
10061
|
locationGeoSchema,
|
|
9966
10062
|
locationsSchema,
|
|
9967
10063
|
mongoose,
|
|
10064
|
+
normalizeAffiliatePromoCodes,
|
|
10065
|
+
normalizePromoCode,
|
|
9968
10066
|
refundPolicySchema,
|
|
9969
10067
|
relatedPostSchema,
|
|
9970
10068
|
relationDatesSchema,
|