@timardex/cluemart-server-shared 1.0.157 → 1.0.159
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-UG4QCIIG.mjs → chunk-BIIAHQ4Y.mjs} +7 -4
- package/dist/chunk-BIIAHQ4Y.mjs.map +1 -0
- package/dist/index.cjs +46 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.mjs +46 -67
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +6 -3
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +44 -65
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +0 -10
- package/dist/service/index.d.ts +0 -10
- package/dist/service/index.mjs +39 -63
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-UG4QCIIG.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1710,7 +1710,7 @@ __export(index_exports, {
|
|
|
1710
1710
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
1711
1711
|
locationGeoSchema: () => locationGeoSchema,
|
|
1712
1712
|
locationsSchema: () => locationsSchema,
|
|
1713
|
-
mongoose: () =>
|
|
1713
|
+
mongoose: () => import_mongoose31.default,
|
|
1714
1714
|
refundPolicySchema: () => refundPolicySchema,
|
|
1715
1715
|
relationDatesSchema: () => relationDatesSchema,
|
|
1716
1716
|
resourceRelationsSchema: () => resourceRelationsSchema,
|
|
@@ -10108,6 +10108,7 @@ var GAME_FIELDS_FRAGMENT = gql`
|
|
|
10108
10108
|
...GameHistoryFields
|
|
10109
10109
|
}
|
|
10110
10110
|
gameType
|
|
10111
|
+
gameTypeId
|
|
10111
10112
|
updatedAt
|
|
10112
10113
|
}
|
|
10113
10114
|
${GAME_DATA_FIELDS_FRAGMENT}
|
|
@@ -10164,6 +10165,7 @@ var GET_GAME_LEADERBOARD = gql`
|
|
|
10164
10165
|
`;
|
|
10165
10166
|
var BASE_GAME_FIELDS_FRAGMENT = gql`
|
|
10166
10167
|
fragment BaseGameFields on BaseGameType {
|
|
10168
|
+
gameTypeId
|
|
10167
10169
|
gameType
|
|
10168
10170
|
dailyClue {
|
|
10169
10171
|
...DailyClueBaseGameFields
|
|
@@ -10343,9 +10345,9 @@ var UPDATE_DAILY_CLUE_MUTATION = gql`
|
|
|
10343
10345
|
var UPDATE_MINI_QUIZ_MUTATION = gql`
|
|
10344
10346
|
mutation updateMiniQuizGame(
|
|
10345
10347
|
$_id: ID!
|
|
10346
|
-
$
|
|
10348
|
+
$answeredQuestions: [MiniQuizAnsweredQuestionInputType!]!
|
|
10347
10349
|
) {
|
|
10348
|
-
updateMiniQuizGame(_id: $_id,
|
|
10350
|
+
updateMiniQuizGame(_id: $_id, answeredQuestions: $answeredQuestions) {
|
|
10349
10351
|
...GameDocFields
|
|
10350
10352
|
}
|
|
10351
10353
|
}
|
|
@@ -12559,7 +12561,8 @@ var gameTypeSchema = new MongooseSchema22(
|
|
|
12559
12561
|
enum: Object.values(EnumGameType),
|
|
12560
12562
|
required: true,
|
|
12561
12563
|
type: String
|
|
12562
|
-
}
|
|
12564
|
+
},
|
|
12565
|
+
gameTypeId: { required: true, type: String }
|
|
12563
12566
|
},
|
|
12564
12567
|
{ timestamps: true }
|
|
12565
12568
|
);
|
|
@@ -12800,9 +12803,6 @@ async function updateAdStatuses() {
|
|
|
12800
12803
|
);
|
|
12801
12804
|
}
|
|
12802
12805
|
|
|
12803
|
-
// src/service/vendor.ts
|
|
12804
|
-
var import_mongoose28 = __toESM(require("mongoose"));
|
|
12805
|
-
|
|
12806
12806
|
// src/service/associate.ts
|
|
12807
12807
|
var import_mongoose26 = __toESM(require("mongoose"));
|
|
12808
12808
|
async function removeAssociateFromResource({
|
|
@@ -12810,11 +12810,9 @@ async function removeAssociateFromResource({
|
|
|
12810
12810
|
resourceOwnerId,
|
|
12811
12811
|
resourceType
|
|
12812
12812
|
}) {
|
|
12813
|
-
const normalizedResourceId = resourceId.toString();
|
|
12814
|
-
const normalizedOwnerId = typeof resourceOwnerId === "string" ? new import_mongoose26.default.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
|
|
12815
|
-
const session = await import_mongoose26.default.startSession();
|
|
12816
12813
|
try {
|
|
12817
|
-
|
|
12814
|
+
const normalizedResourceId = resourceId.toString();
|
|
12815
|
+
const normalizedOwnerId = typeof resourceOwnerId === "string" ? new import_mongoose26.default.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
|
|
12818
12816
|
const usersWithAssociates = await UserModel.find(
|
|
12819
12817
|
{
|
|
12820
12818
|
associates: {
|
|
@@ -12826,16 +12824,18 @@ async function removeAssociateFromResource({
|
|
|
12826
12824
|
},
|
|
12827
12825
|
{
|
|
12828
12826
|
associates: 1
|
|
12829
|
-
// Only fetch associates field for efficiency
|
|
12830
12827
|
}
|
|
12831
|
-
).lean()
|
|
12832
|
-
const associateEmails =
|
|
12833
|
-
|
|
12834
|
-
(
|
|
12835
|
-
|
|
12836
|
-
|
|
12828
|
+
).lean();
|
|
12829
|
+
const associateEmails = [
|
|
12830
|
+
...new Set(
|
|
12831
|
+
usersWithAssociates.flatMap(
|
|
12832
|
+
(user) => (user.associates ?? []).filter(
|
|
12833
|
+
(associate) => associate.resourceId === normalizedResourceId && associate.resourceType === resourceType
|
|
12834
|
+
).map((associate) => associate.email)
|
|
12835
|
+
)
|
|
12836
|
+
)
|
|
12837
|
+
];
|
|
12837
12838
|
if (associateEmails.length === 0) {
|
|
12838
|
-
await session.commitTransaction();
|
|
12839
12839
|
return;
|
|
12840
12840
|
}
|
|
12841
12841
|
await UserModel.updateMany(
|
|
@@ -12854,8 +12854,7 @@ async function removeAssociateFromResource({
|
|
|
12854
12854
|
resourceType
|
|
12855
12855
|
}
|
|
12856
12856
|
}
|
|
12857
|
-
}
|
|
12858
|
-
{ session }
|
|
12857
|
+
}
|
|
12859
12858
|
);
|
|
12860
12859
|
await ChatModel.updateMany(
|
|
12861
12860
|
{
|
|
@@ -12870,103 +12869,83 @@ async function removeAssociateFromResource({
|
|
|
12870
12869
|
},
|
|
12871
12870
|
{
|
|
12872
12871
|
$set: {
|
|
12873
|
-
"participants.$[
|
|
12872
|
+
"participants.$[associate].active": false
|
|
12874
12873
|
}
|
|
12875
12874
|
},
|
|
12876
12875
|
{
|
|
12877
12876
|
arrayFilters: [
|
|
12878
12877
|
{
|
|
12879
|
-
"
|
|
12880
|
-
"
|
|
12878
|
+
"associate.isAssociate": true,
|
|
12879
|
+
"associate.userEmail": {
|
|
12880
|
+
$in: associateEmails
|
|
12881
|
+
}
|
|
12881
12882
|
}
|
|
12882
|
-
]
|
|
12883
|
-
session
|
|
12883
|
+
]
|
|
12884
12884
|
}
|
|
12885
12885
|
);
|
|
12886
|
-
await session.commitTransaction();
|
|
12887
12886
|
} catch (error) {
|
|
12888
|
-
await session.abortTransaction();
|
|
12889
12887
|
console.error(
|
|
12890
|
-
`[removeAssociateFromResource] Failed for resourceId=${
|
|
12888
|
+
`[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,
|
|
12891
12889
|
error
|
|
12892
12890
|
);
|
|
12893
|
-
throw error;
|
|
12894
|
-
} finally {
|
|
12895
|
-
session.endSession();
|
|
12896
12891
|
}
|
|
12897
12892
|
}
|
|
12898
12893
|
|
|
12899
12894
|
// src/service/vendor.ts
|
|
12900
12895
|
async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
12901
|
-
const session = await import_mongoose28.default.startSession();
|
|
12902
12896
|
try {
|
|
12903
|
-
|
|
12904
|
-
const user = await UserModel.findById(userId).select("vendor").lean().session(session);
|
|
12897
|
+
const user = await UserModel.findById(userId).select("vendor").lean();
|
|
12905
12898
|
if (!user?.vendor) {
|
|
12906
|
-
console.warn(`[updateVendor] No vendor for userId=${userId}`);
|
|
12907
|
-
await session.abortTransaction();
|
|
12899
|
+
console.warn(`[updateVendor] No vendor found for userId=${userId}`);
|
|
12908
12900
|
return;
|
|
12909
12901
|
}
|
|
12910
|
-
const vendor = await VendorModel.findById(user.vendor).lean()
|
|
12902
|
+
const vendor = await VendorModel.findById(user.vendor).lean();
|
|
12911
12903
|
if (!vendor) {
|
|
12912
12904
|
console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
|
|
12913
|
-
await session.abortTransaction();
|
|
12914
12905
|
return;
|
|
12915
12906
|
}
|
|
12916
|
-
const
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12907
|
+
const updateData = {};
|
|
12908
|
+
const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;
|
|
12909
|
+
if (isStandardVendor) {
|
|
12910
|
+
updateData.associates = [];
|
|
12911
|
+
updateData.availability = {
|
|
12920
12912
|
corporate: false,
|
|
12921
12913
|
private: false,
|
|
12922
12914
|
school: false
|
|
12923
12915
|
};
|
|
12924
|
-
|
|
12916
|
+
updateData.products = {
|
|
12925
12917
|
active: false,
|
|
12926
12918
|
productsList: vendor.products?.productsList ?? []
|
|
12927
12919
|
};
|
|
12928
|
-
|
|
12920
|
+
updateData.calendar = {
|
|
12929
12921
|
active: false,
|
|
12930
12922
|
calendarData: vendor.calendar?.calendarData ?? []
|
|
12931
12923
|
};
|
|
12932
|
-
vendorUpdateData.images = (vendor.images ?? []).map((img, index) => ({
|
|
12933
|
-
...img,
|
|
12934
|
-
active: index < 6
|
|
12935
|
-
}));
|
|
12936
|
-
} else {
|
|
12937
|
-
vendorUpdateData.images = (vendor.images ?? []).map((img) => ({
|
|
12938
|
-
...img,
|
|
12939
|
-
active: true
|
|
12940
|
-
}));
|
|
12941
12924
|
}
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
);
|
|
12947
|
-
if (
|
|
12925
|
+
updateData.images = (vendor.images ?? []).map((image, index) => ({
|
|
12926
|
+
...image,
|
|
12927
|
+
active: isStandardVendor ? index < 6 : true
|
|
12928
|
+
}));
|
|
12929
|
+
await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
|
|
12930
|
+
if (isStandardVendor) {
|
|
12948
12931
|
await removeAssociateFromResource({
|
|
12949
12932
|
resourceId: vendor._id,
|
|
12950
12933
|
resourceOwnerId: vendor.owner.userId,
|
|
12951
12934
|
resourceType: EnumResourceType.VENDOR
|
|
12952
12935
|
});
|
|
12953
12936
|
}
|
|
12954
|
-
await session.commitTransaction();
|
|
12955
12937
|
} catch (error) {
|
|
12956
|
-
await session.abortTransaction();
|
|
12957
12938
|
console.error("[updateVendorBasedOnUserLicense] Failed:", error);
|
|
12958
|
-
} finally {
|
|
12959
|
-
session.endSession();
|
|
12960
12939
|
}
|
|
12961
12940
|
}
|
|
12962
12941
|
|
|
12963
12942
|
// src/service/objectIdToString.ts
|
|
12964
|
-
var
|
|
12943
|
+
var import_mongoose29 = __toESM(require("mongoose"));
|
|
12965
12944
|
function convertObjectIdsToStrings(obj) {
|
|
12966
12945
|
if (obj === null || obj === void 0) {
|
|
12967
12946
|
return obj;
|
|
12968
12947
|
}
|
|
12969
|
-
if (obj instanceof
|
|
12948
|
+
if (obj instanceof import_mongoose29.default.Types.ObjectId) {
|
|
12970
12949
|
return obj.toString();
|
|
12971
12950
|
}
|
|
12972
12951
|
if (Array.isArray(obj)) {
|
|
@@ -12997,7 +12976,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
12997
12976
|
|
|
12998
12977
|
// src/types/index.ts
|
|
12999
12978
|
var import_express = __toESM(require("express"));
|
|
13000
|
-
var
|
|
12979
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
13001
12980
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
13002
12981
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
13003
12982
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|