@timardex/cluemart-server-shared 1.0.289 → 1.0.292
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-CmS0A1gU.d.mts → Affiliate-6XcZ131C.d.mts} +22 -10
- package/dist/{Affiliate-C_g6TdeG.d.ts → Affiliate-DCvdeKW7.d.ts} +22 -10
- package/dist/{chunk-KRG2CATM.mjs → chunk-IGEC5D7N.mjs} +12 -14
- package/dist/{chunk-KRG2CATM.mjs.map → chunk-IGEC5D7N.mjs.map} +1 -1
- package/dist/chunk-YXUJ4VQU.mjs +17 -0
- package/dist/chunk-YXUJ4VQU.mjs.map +1 -0
- package/dist/index.cjs +75 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +45 -11
- package/dist/index.d.ts +45 -11
- package/dist/index.mjs +73 -28
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +10 -12
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +2 -2
- package/dist/mongoose/index.d.ts +2 -2
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +67 -16
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +25 -3
- package/dist/service/index.d.ts +25 -3
- package/dist/service/index.mjs +49 -1
- package/dist/service/index.mjs.map +1 -1
- package/dist/types/index.mjs +5 -10
- package/dist/types/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/types/index.ts
|
|
2
|
+
import express from "express";
|
|
3
|
+
import mongoose from "mongoose";
|
|
4
|
+
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
5
|
+
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
6
|
+
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
7
|
+
EnumPubSubEvents2["GET_NOTIFICATIONS_COUNT"] = "GET_NOTIFICATIONS_COUNT";
|
|
8
|
+
EnumPubSubEvents2["USER_TYPING"] = "USER_TYPING";
|
|
9
|
+
return EnumPubSubEvents2;
|
|
10
|
+
})(EnumPubSubEvents || {});
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
express,
|
|
14
|
+
mongoose,
|
|
15
|
+
EnumPubSubEvents
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-YXUJ4VQU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["import { EnumUserRole } from \"@timardex/cluemart-shared\";\nimport { NotificationCount } from \"@timardex/cluemart-shared/types\";\nimport express from \"express\";\nimport mongoose from \"mongoose\";\n\nimport { SchemaChatType } from \"../mongoose/chat/Chat\";\nimport { SchemaNotificationType } from \"../mongoose/Notification\";\n\n// chnage to export type ObjectId = mongoose.Types.ObjectId;\n// chnage in server when setting decideGameType\nexport type ObjectId = mongoose.Types.ObjectId;\n\nexport enum EnumPubSubEvents {\n GET_CHAT_MESSAGE = \"GET_CHAT_MESSAGE\",\n GET_NOTIFICATIONS = \"GET_NOTIFICATIONS\",\n GET_NOTIFICATIONS_COUNT = \"GET_NOTIFICATIONS_COUNT\",\n USER_TYPING = \"USER_TYPING\",\n}\n\nexport interface AuthUser {\n email: string;\n role: EnumUserRole;\n userId: ObjectId;\n}\n\nexport interface SubscriptionPayload {\n getChatMessage?: SchemaChatType;\n userTyping?: SchemaChatType; // NOT USED\n getNotifications?: SchemaNotificationType[];\n // Used only for filtering; not part of the GraphQL schema output\n getNotificationsUserId?: ObjectId;\n getNotificationsCount?: NotificationCount & { userId: ObjectId };\n}\n\nexport interface GraphQLContext {\n appVersion: string | null;\n user: AuthUser | null;\n pubsub: {\n publish: (\n eventName: EnumPubSubEvents,\n payload: SubscriptionPayload,\n ) => void;\n subscribe: (eventName: EnumPubSubEvents) => AsyncIterable<any>;\n };\n request: express.Request;\n response: express.Response;\n}\n\nexport { mongoose, express };\n"],"mappings":";AAEA,OAAO,aAAa;AACpB,OAAO,cAAc;AASd,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,sBAAmB;AACnB,EAAAA,kBAAA,uBAAoB;AACpB,EAAAA,kBAAA,6BAA0B;AAC1B,EAAAA,kBAAA,iBAAc;AAJJ,SAAAA;AAAA,GAAA;","names":["EnumPubSubEvents"]}
|
package/dist/index.cjs
CHANGED
|
@@ -78,9 +78,11 @@ __export(index_exports, {
|
|
|
78
78
|
locationGeoSchema: () => locationGeoSchema,
|
|
79
79
|
locationsSchema: () => locationsSchema,
|
|
80
80
|
mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
|
|
81
|
-
mongoose: () =>
|
|
81
|
+
mongoose: () => import_mongoose30.default,
|
|
82
82
|
normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
|
|
83
83
|
normalizePromoCode: () => normalizePromoCode,
|
|
84
|
+
notifyUsers: () => notifyUsers,
|
|
85
|
+
publishNotificationEvents: () => publishNotificationEvents,
|
|
84
86
|
refundPolicySchema: () => refundPolicySchema,
|
|
85
87
|
relatedPostSchema: () => relatedPostSchema,
|
|
86
88
|
relationDatesSchema: () => relationDatesSchema,
|
|
@@ -8303,6 +8305,14 @@ var relatedPostSchema = new MongooseSchema6(
|
|
|
8303
8305
|
{ _id: false }
|
|
8304
8306
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
8305
8307
|
);
|
|
8308
|
+
var socialShareResourceSchema = new MongooseSchema6(
|
|
8309
|
+
{
|
|
8310
|
+
qrCode: { required: true, type: ResourceImageTypeSchema },
|
|
8311
|
+
socialImage: { required: true, type: ResourceImageTypeSchema }
|
|
8312
|
+
},
|
|
8313
|
+
{ _id: false }
|
|
8314
|
+
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
8315
|
+
);
|
|
8306
8316
|
var baseResourceFields = {
|
|
8307
8317
|
active: { default: false, required: true, type: Boolean },
|
|
8308
8318
|
adIds: {
|
|
@@ -8334,18 +8344,11 @@ var baseResourceFields = {
|
|
|
8334
8344
|
region: { required: true, type: String },
|
|
8335
8345
|
relatedPost: { required: false, type: relatedPostSchema },
|
|
8336
8346
|
reviewCount: { required: false, type: Number },
|
|
8347
|
+
sharePublic: { required: false, type: socialShareResourceSchema },
|
|
8337
8348
|
slug: { required: true, type: String },
|
|
8338
8349
|
socialMedia: { required: false, type: [SocialMediaTypeSchema] },
|
|
8339
8350
|
termsAgreement: { required: true, type: termsAgreementSchema }
|
|
8340
8351
|
};
|
|
8341
|
-
var socialShareResourceSchema = new MongooseSchema6(
|
|
8342
|
-
{
|
|
8343
|
-
qrCode: { required: true, type: ResourceImageTypeSchema },
|
|
8344
|
-
socialImage: { required: true, type: ResourceImageTypeSchema }
|
|
8345
|
-
},
|
|
8346
|
-
{ _id: false }
|
|
8347
|
-
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
8348
|
-
);
|
|
8349
8352
|
|
|
8350
8353
|
// src/mongoose/GoogleImportedMarket.ts
|
|
8351
8354
|
var import_mongoose7 = __toESM(require("mongoose"));
|
|
@@ -8822,7 +8825,6 @@ var schema9 = new MongooseSchema13(
|
|
|
8822
8825
|
required: false,
|
|
8823
8826
|
type: [resourceRelationsSchema]
|
|
8824
8827
|
},
|
|
8825
|
-
sharePublic: { required: false, type: socialShareResourceSchema },
|
|
8826
8828
|
shareRelation: { required: false, type: socialShareResourceSchema },
|
|
8827
8829
|
unregisteredVendorId: {
|
|
8828
8830
|
ref: "UnregisteredVendor",
|
|
@@ -8975,7 +8977,6 @@ var schema12 = new MongooseSchema16(
|
|
|
8975
8977
|
required: false,
|
|
8976
8978
|
type: [resourceRelationsSchema]
|
|
8977
8979
|
},
|
|
8978
|
-
sharePublic: { required: false, type: socialShareResourceSchema },
|
|
8979
8980
|
shareRelation: { required: false, type: socialShareResourceSchema },
|
|
8980
8981
|
tags: { required: true, type: [String] }
|
|
8981
8982
|
},
|
|
@@ -9007,8 +9008,7 @@ var schema13 = new MongooseSchema17(
|
|
|
9007
9008
|
enum: Object.values(EnumPartnerType),
|
|
9008
9009
|
required: true,
|
|
9009
9010
|
type: String
|
|
9010
|
-
}
|
|
9011
|
-
sharePublic: { required: false, type: socialShareResourceSchema }
|
|
9011
|
+
}
|
|
9012
9012
|
},
|
|
9013
9013
|
{ timestamps: true }
|
|
9014
9014
|
);
|
|
@@ -9861,6 +9861,62 @@ var connectToDatabase = async ({
|
|
|
9861
9861
|
}
|
|
9862
9862
|
};
|
|
9863
9863
|
|
|
9864
|
+
// src/types/index.ts
|
|
9865
|
+
var import_express = __toESM(require("express"));
|
|
9866
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
9867
|
+
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
9868
|
+
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
9869
|
+
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
9870
|
+
EnumPubSubEvents2["GET_NOTIFICATIONS_COUNT"] = "GET_NOTIFICATIONS_COUNT";
|
|
9871
|
+
EnumPubSubEvents2["USER_TYPING"] = "USER_TYPING";
|
|
9872
|
+
return EnumPubSubEvents2;
|
|
9873
|
+
})(EnumPubSubEvents || {});
|
|
9874
|
+
|
|
9875
|
+
// src/service/notifyUsers.ts
|
|
9876
|
+
async function publishNotificationEvents(userId, pubsub) {
|
|
9877
|
+
try {
|
|
9878
|
+
const userNotifications = await NotificationModel.find({
|
|
9879
|
+
userId
|
|
9880
|
+
}).sort({ createdAt: -1 });
|
|
9881
|
+
const [total, unread] = await Promise.all([
|
|
9882
|
+
NotificationModel.countDocuments({ userId }),
|
|
9883
|
+
NotificationModel.countDocuments({ isRead: false, userId })
|
|
9884
|
+
]);
|
|
9885
|
+
pubsub.publish("GET_NOTIFICATIONS" /* GET_NOTIFICATIONS */, {
|
|
9886
|
+
getNotifications: userNotifications,
|
|
9887
|
+
getNotificationsUserId: userId
|
|
9888
|
+
});
|
|
9889
|
+
pubsub.publish("GET_NOTIFICATIONS_COUNT" /* GET_NOTIFICATIONS_COUNT */, {
|
|
9890
|
+
getNotificationsCount: { total, unread, userId }
|
|
9891
|
+
});
|
|
9892
|
+
console.log(`Published notification events for user: ${String(userId)}`);
|
|
9893
|
+
} catch (error) {
|
|
9894
|
+
console.error(
|
|
9895
|
+
`Failed to publish notification events for user ${String(userId)}:`,
|
|
9896
|
+
error
|
|
9897
|
+
);
|
|
9898
|
+
}
|
|
9899
|
+
}
|
|
9900
|
+
async function notifyUsers({
|
|
9901
|
+
payload,
|
|
9902
|
+
pubsub
|
|
9903
|
+
}) {
|
|
9904
|
+
try {
|
|
9905
|
+
await sendPushNotifications(payload);
|
|
9906
|
+
const uniqueUserIds = await saveNotificationsInDb(payload);
|
|
9907
|
+
const persisted = payload.userIds.length === 0 || uniqueUserIds.length > 0;
|
|
9908
|
+
if (pubsub) {
|
|
9909
|
+
for (const userId of uniqueUserIds) {
|
|
9910
|
+
await publishNotificationEvents(userId, pubsub);
|
|
9911
|
+
}
|
|
9912
|
+
}
|
|
9913
|
+
return persisted;
|
|
9914
|
+
} catch (error) {
|
|
9915
|
+
console.error("Error in notifyUsers:", error);
|
|
9916
|
+
return false;
|
|
9917
|
+
}
|
|
9918
|
+
}
|
|
9919
|
+
|
|
9864
9920
|
// src/service/updateAdStatus.ts
|
|
9865
9921
|
async function updateAdStatuses() {
|
|
9866
9922
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -9897,9 +9953,9 @@ async function updateAdStatuses() {
|
|
|
9897
9953
|
}
|
|
9898
9954
|
|
|
9899
9955
|
// src/service/associate.ts
|
|
9900
|
-
var
|
|
9956
|
+
var import_mongoose32 = __toESM(require("mongoose"));
|
|
9901
9957
|
function normalizeObjectId(id) {
|
|
9902
|
-
return typeof id === "string" ? new
|
|
9958
|
+
return typeof id === "string" ? new import_mongoose32.default.Types.ObjectId(id) : id;
|
|
9903
9959
|
}
|
|
9904
9960
|
async function getAssociateEmailsForResource({
|
|
9905
9961
|
normalizedResourceId,
|
|
@@ -10051,12 +10107,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
10051
10107
|
}
|
|
10052
10108
|
|
|
10053
10109
|
// src/service/objectIdToString.ts
|
|
10054
|
-
var
|
|
10110
|
+
var import_mongoose35 = __toESM(require("mongoose"));
|
|
10055
10111
|
function convertObjectIdsToStrings(obj) {
|
|
10056
10112
|
if (obj === null || obj === void 0) {
|
|
10057
10113
|
return obj;
|
|
10058
10114
|
}
|
|
10059
|
-
if (obj instanceof
|
|
10115
|
+
if (obj instanceof import_mongoose35.default.Types.ObjectId) {
|
|
10060
10116
|
return obj.toString();
|
|
10061
10117
|
}
|
|
10062
10118
|
if (obj instanceof Date) {
|
|
@@ -10237,17 +10293,6 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
10237
10293
|
};
|
|
10238
10294
|
});
|
|
10239
10295
|
}
|
|
10240
|
-
|
|
10241
|
-
// src/types/index.ts
|
|
10242
|
-
var import_express = __toESM(require("express"));
|
|
10243
|
-
var import_mongoose37 = __toESM(require("mongoose"));
|
|
10244
|
-
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
10245
|
-
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
10246
|
-
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
10247
|
-
EnumPubSubEvents2["GET_NOTIFICATIONS_COUNT"] = "GET_NOTIFICATIONS_COUNT";
|
|
10248
|
-
EnumPubSubEvents2["USER_TYPING"] = "USER_TYPING";
|
|
10249
|
-
return EnumPubSubEvents2;
|
|
10250
|
-
})(EnumPubSubEvents || {});
|
|
10251
10296
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10252
10297
|
0 && (module.exports = {
|
|
10253
10298
|
ACTIVE_NOT_DELETED_FILTER,
|
|
@@ -10301,6 +10346,8 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
|
10301
10346
|
mongoose,
|
|
10302
10347
|
normalizeAffiliatePromoCodes,
|
|
10303
10348
|
normalizePromoCode,
|
|
10349
|
+
notifyUsers,
|
|
10350
|
+
publishNotificationEvents,
|
|
10304
10351
|
refundPolicySchema,
|
|
10305
10352
|
relatedPostSchema,
|
|
10306
10353
|
relationDatesSchema,
|