@timardex/cluemart-server-shared 1.0.263 → 1.0.265
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/{chunk-BDHZYR65.mjs → chunk-SHBCW7T5.mjs} +140 -29
- package/dist/chunk-SHBCW7T5.mjs.map +1 -0
- package/dist/index.cjs +147 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.mjs +146 -35
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +139 -27
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +23 -4
- package/dist/mongoose/index.d.ts +23 -4
- package/dist/mongoose/index.mjs +3 -1
- package/dist/service/index.cjs +141 -31
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-BDHZYR65.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
APP_SETTINGS_ID: () => APP_SETTINGS_ID,
|
|
34
34
|
AdModel: () => AdModel,
|
|
35
|
+
AffiliateModel: () => AffiliateModel,
|
|
35
36
|
AppSettingModel: () => AppSettingModel,
|
|
36
37
|
CategorySchema: () => CategorySchema,
|
|
37
38
|
ChatModel: () => ChatModel,
|
|
@@ -69,7 +70,7 @@ __export(index_exports, {
|
|
|
69
70
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
70
71
|
locationGeoSchema: () => locationGeoSchema,
|
|
71
72
|
locationsSchema: () => locationsSchema,
|
|
72
|
-
mongoose: () =>
|
|
73
|
+
mongoose: () => import_mongoose34.default,
|
|
73
74
|
refundPolicySchema: () => refundPolicySchema,
|
|
74
75
|
relatedPostSchema: () => relatedPostSchema,
|
|
75
76
|
relationDatesSchema: () => relationDatesSchema,
|
|
@@ -3569,6 +3570,7 @@ var gameScreenIdentifierList = [
|
|
|
3569
3570
|
match: "/visitors"
|
|
3570
3571
|
}
|
|
3571
3572
|
];
|
|
3573
|
+
var PROMO_CODE_PREFIX = "CM-";
|
|
3572
3574
|
var EnumAdShowOn = /* @__PURE__ */ ((EnumAdShowOn2) => {
|
|
3573
3575
|
EnumAdShowOn2["EVENTS_PAGE"] = "Events_page";
|
|
3574
3576
|
EnumAdShowOn2["FRONT_PAGE"] = "Front_page";
|
|
@@ -3627,6 +3629,12 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
|
|
|
3627
3629
|
EnumGameType2["ODD_ONE_OUT"] = "oddOneOut";
|
|
3628
3630
|
return EnumGameType2;
|
|
3629
3631
|
})(EnumGameType || {});
|
|
3632
|
+
var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType2) => {
|
|
3633
|
+
EnumAffiliateRewardType2["NEW_EVENT_REGISTRATION"] = "NEW_EVENT_REGISTRATION";
|
|
3634
|
+
EnumAffiliateRewardType2["NEW_VENDOR_REGISTRATION"] = "NEW_VENDOR_REGISTRATION";
|
|
3635
|
+
EnumAffiliateRewardType2["NEW_PARTNER_REGISTRATION"] = "NEW_PARTNER_REGISTRATION";
|
|
3636
|
+
return EnumAffiliateRewardType2;
|
|
3637
|
+
})(EnumAffiliateRewardType || {});
|
|
3630
3638
|
var mapArrayToOptions = (items) => items.map((item) => ({
|
|
3631
3639
|
label: item,
|
|
3632
3640
|
value: item
|
|
@@ -3644,6 +3652,8 @@ var paymentMethodOptions = mapArrayToOptions(
|
|
|
3644
3652
|
Object.values(EnumPaymentMethod)
|
|
3645
3653
|
);
|
|
3646
3654
|
var CLUEMART_MAIN_DOMAIN_URL = "https://cluemart.co.nz";
|
|
3655
|
+
var CM_SCHOOL_PROMO_CODE = `${PROMO_CODE_PREFIX}SCHOOL`;
|
|
3656
|
+
var CM_AFFILIATE_PROMO_CODE = `${PROMO_CODE_PREFIX}AFFILIATE`;
|
|
3647
3657
|
var dateFormat = "DD-MM-YYYY";
|
|
3648
3658
|
var timeFormat = "HH:mm";
|
|
3649
3659
|
import_dayjs.default.extend(import_customParseFormat.default);
|
|
@@ -5039,12 +5049,6 @@ var REDEEMED_REWARD_FIELDS_FRAGMENT = gql`
|
|
|
5039
5049
|
redeemedAt
|
|
5040
5050
|
}
|
|
5041
5051
|
`;
|
|
5042
|
-
var AFFILIATE_FIELDS_FRAGMENT = gql`
|
|
5043
|
-
fragment AffiliateFields on AffiliateType {
|
|
5044
|
-
affiliateCode
|
|
5045
|
-
pointsAvailable
|
|
5046
|
-
}
|
|
5047
|
-
`;
|
|
5048
5052
|
var USER_FIELDS_FRAGMENT = gql`
|
|
5049
5053
|
fragment UserFields on UserType {
|
|
5050
5054
|
_id
|
|
@@ -5052,9 +5056,7 @@ var USER_FIELDS_FRAGMENT = gql`
|
|
|
5052
5056
|
associates {
|
|
5053
5057
|
...AssociatesFields
|
|
5054
5058
|
}
|
|
5055
|
-
affiliate
|
|
5056
|
-
...AffiliateFields
|
|
5057
|
-
}
|
|
5059
|
+
affiliate
|
|
5058
5060
|
avatar {
|
|
5059
5061
|
...ResourceImageFields
|
|
5060
5062
|
}
|
|
@@ -5098,7 +5100,6 @@ var USER_FIELDS_FRAGMENT = gql`
|
|
|
5098
5100
|
${LICENCE_FIELDS_FRAGMENT}
|
|
5099
5101
|
${LOCATION_FIELDS_FRAGMENT}
|
|
5100
5102
|
${REDEEMED_REWARD_FIELDS_FRAGMENT}
|
|
5101
|
-
${AFFILIATE_FIELDS_FRAGMENT}
|
|
5102
5103
|
`;
|
|
5103
5104
|
var STALL_TYPE_FIELDS_FRAGMENT = gql`
|
|
5104
5105
|
fragment StallTypeFields on StallTypeType {
|
|
@@ -7444,6 +7445,63 @@ var REQUEST_MARKETING_MATERIAL_MUTATION = gql`
|
|
|
7444
7445
|
}
|
|
7445
7446
|
}
|
|
7446
7447
|
`;
|
|
7448
|
+
var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
|
|
7449
|
+
fragment AffiliateRewardFields on AffiliateRewardType {
|
|
7450
|
+
createdAt
|
|
7451
|
+
deletedAt
|
|
7452
|
+
redeemedAt
|
|
7453
|
+
rewardDescription
|
|
7454
|
+
rewardType
|
|
7455
|
+
rewardValue
|
|
7456
|
+
updatedAt
|
|
7457
|
+
}
|
|
7458
|
+
`;
|
|
7459
|
+
var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
|
|
7460
|
+
fragment AffiliateResourceFields on AffiliateResourceType {
|
|
7461
|
+
resourceActive
|
|
7462
|
+
resourceId
|
|
7463
|
+
resourceType
|
|
7464
|
+
rewards {
|
|
7465
|
+
...AffiliateRewardFields
|
|
7466
|
+
}
|
|
7467
|
+
}
|
|
7468
|
+
${AFFILIATE_REWARD_FIELDS_FRAGMENT}
|
|
7469
|
+
`;
|
|
7470
|
+
var AFFILIATE_FIELDS_FRAGMENT = gql`
|
|
7471
|
+
fragment AffiliateFields on AffiliateType {
|
|
7472
|
+
_id
|
|
7473
|
+
active
|
|
7474
|
+
affiliateCode
|
|
7475
|
+
affiliateResources {
|
|
7476
|
+
...AffiliateResourceFields
|
|
7477
|
+
}
|
|
7478
|
+
createdAt
|
|
7479
|
+
deletedAt
|
|
7480
|
+
overallPoints
|
|
7481
|
+
owner {
|
|
7482
|
+
...OwnerFields
|
|
7483
|
+
}
|
|
7484
|
+
updatedAt
|
|
7485
|
+
}
|
|
7486
|
+
${AFFILIATE_RESOURCE_FIELDS_FRAGMENT}
|
|
7487
|
+
${OWNER_FIELDS_FRAGMENT}
|
|
7488
|
+
`;
|
|
7489
|
+
var GET_AFFILIATE = gql`
|
|
7490
|
+
query getAffiliate($_id: ID!) {
|
|
7491
|
+
affiliate(_id: $_id) {
|
|
7492
|
+
...AffiliateFields
|
|
7493
|
+
}
|
|
7494
|
+
}
|
|
7495
|
+
${AFFILIATE_FIELDS_FRAGMENT}
|
|
7496
|
+
`;
|
|
7497
|
+
var GET_AFFILIATES = gql`
|
|
7498
|
+
query getAffiliates {
|
|
7499
|
+
affiliates {
|
|
7500
|
+
...AffiliateFields
|
|
7501
|
+
}
|
|
7502
|
+
}
|
|
7503
|
+
${AFFILIATE_FIELDS_FRAGMENT}
|
|
7504
|
+
`;
|
|
7447
7505
|
var PKG = "@timardex/cluemart-shared";
|
|
7448
7506
|
var IMAGE_EXTENSION = ".webp";
|
|
7449
7507
|
var posterIds = [
|
|
@@ -8458,19 +8516,13 @@ var redeemedRewardSchema = new MongooseSchema11(
|
|
|
8458
8516
|
},
|
|
8459
8517
|
{ _id: false }
|
|
8460
8518
|
);
|
|
8461
|
-
var affiliateSchema = new MongooseSchema11(
|
|
8462
|
-
{
|
|
8463
|
-
affiliateCode: { required: true, type: String },
|
|
8464
|
-
pointsAvailable: { required: true, type: Number }
|
|
8465
|
-
},
|
|
8466
|
-
{ _id: false }
|
|
8467
|
-
);
|
|
8468
8519
|
var schema7 = new MongooseSchema11(
|
|
8469
8520
|
{
|
|
8470
8521
|
active: { default: false, required: true, type: Boolean },
|
|
8471
8522
|
affiliate: {
|
|
8523
|
+
ref: "Affiliate",
|
|
8472
8524
|
required: false,
|
|
8473
|
-
type:
|
|
8525
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
8474
8526
|
},
|
|
8475
8527
|
associates: {
|
|
8476
8528
|
required: false,
|
|
@@ -8570,13 +8622,6 @@ var schema7 = new MongooseSchema11(
|
|
|
8570
8622
|
},
|
|
8571
8623
|
{ strict: false, timestamps: true }
|
|
8572
8624
|
);
|
|
8573
|
-
schema7.index(
|
|
8574
|
-
{ "affiliate.affiliateCode": 1 },
|
|
8575
|
-
{
|
|
8576
|
-
partialFilterExpression: { active: true, deletedAt: null },
|
|
8577
|
-
unique: true
|
|
8578
|
-
}
|
|
8579
|
-
);
|
|
8580
8625
|
schema7.index({ "associates.email": 1 });
|
|
8581
8626
|
schema7.index({ "licences.expiryDate": 1 });
|
|
8582
8627
|
schema7.index({ "licences.licenceType": 1 });
|
|
@@ -9067,9 +9112,9 @@ var gameDataSchemas = {
|
|
|
9067
9112
|
[EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
9068
9113
|
};
|
|
9069
9114
|
var gameDataDefinition = Object.fromEntries(
|
|
9070
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
9115
|
+
Object.entries(gameDataSchemas).map(([key, schema18]) => [
|
|
9071
9116
|
key,
|
|
9072
|
-
{ default: null, required: false, type:
|
|
9117
|
+
{ default: null, required: false, type: schema18 }
|
|
9073
9118
|
])
|
|
9074
9119
|
);
|
|
9075
9120
|
var gameHistorySchema = new MongooseSchema23(
|
|
@@ -9168,8 +9213,74 @@ schema16.index(
|
|
|
9168
9213
|
);
|
|
9169
9214
|
var SchoolModel = import_mongoose24.default.models.School || import_mongoose24.default.model("School", schema16);
|
|
9170
9215
|
|
|
9171
|
-
// src/
|
|
9216
|
+
// src/mongoose/Affiliate.ts
|
|
9172
9217
|
var import_mongoose25 = __toESM(require("mongoose"));
|
|
9218
|
+
var MongooseSchema25 = import_mongoose25.default.Schema;
|
|
9219
|
+
var affiliateRewardSchema = new MongooseSchema25(
|
|
9220
|
+
{
|
|
9221
|
+
createdAt: { required: true, type: Date },
|
|
9222
|
+
deletedAt: { default: null, required: false, type: Date },
|
|
9223
|
+
redeemedAt: { default: null, required: false, type: Date },
|
|
9224
|
+
rewardDescription: { required: true, type: String },
|
|
9225
|
+
rewardType: {
|
|
9226
|
+
enum: Object.values(EnumAffiliateRewardType),
|
|
9227
|
+
required: true,
|
|
9228
|
+
type: String
|
|
9229
|
+
},
|
|
9230
|
+
rewardValue: { required: true, type: Number },
|
|
9231
|
+
updatedAt: { default: null, required: false, type: Date }
|
|
9232
|
+
},
|
|
9233
|
+
{ _id: false }
|
|
9234
|
+
);
|
|
9235
|
+
var affiliateResourceSchema = new MongooseSchema25(
|
|
9236
|
+
{
|
|
9237
|
+
resourceActive: { default: true, required: true, type: Boolean },
|
|
9238
|
+
resourceId: {
|
|
9239
|
+
required: true,
|
|
9240
|
+
type: import_mongoose25.default.Schema.Types.ObjectId
|
|
9241
|
+
},
|
|
9242
|
+
resourceType: {
|
|
9243
|
+
enum: Object.values(EnumResourceType),
|
|
9244
|
+
required: true,
|
|
9245
|
+
type: String
|
|
9246
|
+
},
|
|
9247
|
+
rewards: {
|
|
9248
|
+
default: [],
|
|
9249
|
+
required: false,
|
|
9250
|
+
type: [affiliateRewardSchema]
|
|
9251
|
+
}
|
|
9252
|
+
},
|
|
9253
|
+
{ _id: false }
|
|
9254
|
+
);
|
|
9255
|
+
var schema17 = new MongooseSchema25(
|
|
9256
|
+
{
|
|
9257
|
+
active: { default: true, required: true, type: Boolean },
|
|
9258
|
+
affiliateCode: { required: true, type: String },
|
|
9259
|
+
affiliateResources: {
|
|
9260
|
+
default: [],
|
|
9261
|
+
required: false,
|
|
9262
|
+
type: [affiliateResourceSchema]
|
|
9263
|
+
},
|
|
9264
|
+
deletedAt: { default: null, required: false, type: Date },
|
|
9265
|
+
overallPoints: { default: 0, required: true, type: Number },
|
|
9266
|
+
owner: {
|
|
9267
|
+
required: true,
|
|
9268
|
+
type: OwnerTypeSchema
|
|
9269
|
+
}
|
|
9270
|
+
},
|
|
9271
|
+
{ timestamps: true }
|
|
9272
|
+
);
|
|
9273
|
+
schema17.index(
|
|
9274
|
+
{ affiliateCode: 1 },
|
|
9275
|
+
{
|
|
9276
|
+
partialFilterExpression: { deletedAt: null },
|
|
9277
|
+
unique: true
|
|
9278
|
+
}
|
|
9279
|
+
);
|
|
9280
|
+
var AffiliateModel = import_mongoose25.default.models.Affiliate || import_mongoose25.default.model("Affiliate", schema17);
|
|
9281
|
+
|
|
9282
|
+
// src/service/database.ts
|
|
9283
|
+
var import_mongoose26 = __toESM(require("mongoose"));
|
|
9173
9284
|
var connectToDatabase = async ({
|
|
9174
9285
|
appName,
|
|
9175
9286
|
dbName,
|
|
@@ -9182,7 +9293,7 @@ var connectToDatabase = async ({
|
|
|
9182
9293
|
// Fallback to MongoDB Atlas connection string
|
|
9183
9294
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
9184
9295
|
);
|
|
9185
|
-
await
|
|
9296
|
+
await import_mongoose26.default.connect(mongoUri);
|
|
9186
9297
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
9187
9298
|
console.log(
|
|
9188
9299
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -9362,9 +9473,9 @@ async function updateAdStatuses() {
|
|
|
9362
9473
|
}
|
|
9363
9474
|
|
|
9364
9475
|
// src/service/associate.ts
|
|
9365
|
-
var
|
|
9476
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
9366
9477
|
function normalizeObjectId(id) {
|
|
9367
|
-
return typeof id === "string" ? new
|
|
9478
|
+
return typeof id === "string" ? new import_mongoose28.default.Types.ObjectId(id) : id;
|
|
9368
9479
|
}
|
|
9369
9480
|
async function getAssociateEmailsForResource({
|
|
9370
9481
|
normalizedResourceId,
|
|
@@ -9516,12 +9627,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
9516
9627
|
}
|
|
9517
9628
|
|
|
9518
9629
|
// src/service/objectIdToString.ts
|
|
9519
|
-
var
|
|
9630
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
9520
9631
|
function convertObjectIdsToStrings(obj) {
|
|
9521
9632
|
if (obj === null || obj === void 0) {
|
|
9522
9633
|
return obj;
|
|
9523
9634
|
}
|
|
9524
|
-
if (obj instanceof
|
|
9635
|
+
if (obj instanceof import_mongoose31.default.Types.ObjectId) {
|
|
9525
9636
|
return obj.toString();
|
|
9526
9637
|
}
|
|
9527
9638
|
if (obj instanceof Date) {
|
|
@@ -9705,7 +9816,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
9705
9816
|
|
|
9706
9817
|
// src/types/index.ts
|
|
9707
9818
|
var import_express = __toESM(require("express"));
|
|
9708
|
-
var
|
|
9819
|
+
var import_mongoose34 = __toESM(require("mongoose"));
|
|
9709
9820
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
9710
9821
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
9711
9822
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -9717,6 +9828,7 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
9717
9828
|
0 && (module.exports = {
|
|
9718
9829
|
APP_SETTINGS_ID,
|
|
9719
9830
|
AdModel,
|
|
9831
|
+
AffiliateModel,
|
|
9720
9832
|
AppSettingModel,
|
|
9721
9833
|
CategorySchema,
|
|
9722
9834
|
ChatModel,
|