@timardex/cluemart-server-shared 1.0.149 → 1.0.150
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/{Chat-G9w7Bdl9.d.mts → Chat-Ctmtatmi.d.mts} +1 -12
- package/dist/{Chat-G9w7Bdl9.d.ts → Chat-Ctmtatmi.d.ts} +1 -12
- package/dist/{chunk-XT6SQI4D.mjs → chunk-YNM5IJGO.mjs} +4 -2
- package/dist/chunk-YNM5IJGO.mjs.map +1 -0
- package/dist/index.cjs +109 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -12
- package/dist/index.d.ts +1 -12
- package/dist/index.mjs +109 -37
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +2 -2
- 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 -3
- package/dist/service/index.cjs +107 -34
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +1 -1
- package/dist/service/index.d.ts +1 -1
- package/dist/service/index.mjs +108 -35
- 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/chunk-XT6SQI4D.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -84,17 +84,6 @@ type SchemaChatType = Omit<ChatType, "participants" | "messages"> & {
|
|
|
84
84
|
participants: SchemaParticipantType[];
|
|
85
85
|
messages: SchemaChatMessageType[];
|
|
86
86
|
};
|
|
87
|
-
declare const ParticipantSchema: mongoose.Schema<SchemaParticipantType, mongoose.Model<SchemaParticipantType, any, any, any, mongoose.Document<unknown, any, SchemaParticipantType, any, {}> & Omit<ParticipantType, "userId"> & {
|
|
88
|
-
userId: ObjectId;
|
|
89
|
-
} & {
|
|
90
|
-
_id: mongoose.Types.ObjectId;
|
|
91
|
-
} & {
|
|
92
|
-
__v: number;
|
|
93
|
-
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, SchemaParticipantType, mongoose.Document<unknown, {}, mongoose.FlatRecord<SchemaParticipantType>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<SchemaParticipantType> & {
|
|
94
|
-
_id: mongoose.Types.ObjectId;
|
|
95
|
-
} & {
|
|
96
|
-
__v: number;
|
|
97
|
-
}>;
|
|
98
87
|
declare const ChatModel: mongoose.Model<SchemaChatType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaChatType, {}, {}> & Omit<ChatType, "participants" | "messages"> & {
|
|
99
88
|
participants: SchemaParticipantType[];
|
|
100
89
|
messages: SchemaChatMessageType[];
|
|
@@ -737,4 +726,4 @@ type EventOrMarket = {
|
|
|
737
726
|
*/
|
|
738
727
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
739
728
|
|
|
740
|
-
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema,
|
|
729
|
+
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateVendorBasedOnUserLicense, userLicenseSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -84,17 +84,6 @@ type SchemaChatType = Omit<ChatType, "participants" | "messages"> & {
|
|
|
84
84
|
participants: SchemaParticipantType[];
|
|
85
85
|
messages: SchemaChatMessageType[];
|
|
86
86
|
};
|
|
87
|
-
declare const ParticipantSchema: mongoose.Schema<SchemaParticipantType, mongoose.Model<SchemaParticipantType, any, any, any, mongoose.Document<unknown, any, SchemaParticipantType, any, {}> & Omit<ParticipantType, "userId"> & {
|
|
88
|
-
userId: ObjectId;
|
|
89
|
-
} & {
|
|
90
|
-
_id: mongoose.Types.ObjectId;
|
|
91
|
-
} & {
|
|
92
|
-
__v: number;
|
|
93
|
-
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, SchemaParticipantType, mongoose.Document<unknown, {}, mongoose.FlatRecord<SchemaParticipantType>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<SchemaParticipantType> & {
|
|
94
|
-
_id: mongoose.Types.ObjectId;
|
|
95
|
-
} & {
|
|
96
|
-
__v: number;
|
|
97
|
-
}>;
|
|
98
87
|
declare const ChatModel: mongoose.Model<SchemaChatType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaChatType, {}, {}> & Omit<ChatType, "participants" | "messages"> & {
|
|
99
88
|
participants: SchemaParticipantType[];
|
|
100
89
|
messages: SchemaChatMessageType[];
|
|
@@ -737,4 +726,4 @@ type EventOrMarket = {
|
|
|
737
726
|
*/
|
|
738
727
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
739
728
|
|
|
740
|
-
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema,
|
|
729
|
+
export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateVendorBasedOnUserLicense, userLicenseSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -8989,6 +8989,7 @@ var CHAT_MESSAGE_FIELDS_FRAGMENT = gql`
|
|
|
8989
8989
|
var CHAT_PARTICIPANT = gql`
|
|
8990
8990
|
fragment ChatParticipantFields on ChatParticipantType {
|
|
8991
8991
|
active
|
|
8992
|
+
isAssociate
|
|
8992
8993
|
userAvatar
|
|
8993
8994
|
userEmail
|
|
8994
8995
|
userId
|
|
@@ -11183,6 +11184,7 @@ var MessageSchema = new MongooseSchema2(
|
|
|
11183
11184
|
var ParticipantSchema = new MongooseSchema2(
|
|
11184
11185
|
{
|
|
11185
11186
|
active: { default: true, required: true, type: Boolean },
|
|
11187
|
+
isAssociate: { default: null, required: false, type: Boolean },
|
|
11186
11188
|
userAvatar: { required: false, type: String },
|
|
11187
11189
|
userEmail: { required: true, type: String },
|
|
11188
11190
|
userId: {
|
|
@@ -12621,10 +12623,44 @@ async function updateAdStatuses() {
|
|
|
12621
12623
|
);
|
|
12622
12624
|
}
|
|
12623
12625
|
|
|
12626
|
+
// src/service/vendor.ts
|
|
12627
|
+
import mongoose24 from "mongoose";
|
|
12628
|
+
|
|
12624
12629
|
// src/service/associate.ts
|
|
12625
|
-
|
|
12630
|
+
import mongoose23 from "mongoose";
|
|
12631
|
+
async function removeAssociateFromResource({
|
|
12632
|
+
resourceId,
|
|
12633
|
+
resourceOwnerId,
|
|
12634
|
+
resourceType
|
|
12635
|
+
}) {
|
|
12626
12636
|
const normalizedResourceId = resourceId.toString();
|
|
12637
|
+
const normalizedOwnerId = typeof resourceOwnerId === "string" ? new mongoose23.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
|
|
12638
|
+
const session = await mongoose23.startSession();
|
|
12627
12639
|
try {
|
|
12640
|
+
session.startTransaction();
|
|
12641
|
+
const usersWithAssociates = await UserModel.find(
|
|
12642
|
+
{
|
|
12643
|
+
associates: {
|
|
12644
|
+
$elemMatch: {
|
|
12645
|
+
resourceId: normalizedResourceId,
|
|
12646
|
+
resourceType
|
|
12647
|
+
}
|
|
12648
|
+
}
|
|
12649
|
+
},
|
|
12650
|
+
{
|
|
12651
|
+
associates: 1
|
|
12652
|
+
// Only fetch associates field for efficiency
|
|
12653
|
+
}
|
|
12654
|
+
).lean().session(session);
|
|
12655
|
+
const associateEmails = usersWithAssociates.flatMap(
|
|
12656
|
+
(user) => (user.associates ?? []).filter(
|
|
12657
|
+
(assoc) => assoc.resourceId === normalizedResourceId && assoc.resourceType === resourceType
|
|
12658
|
+
).map((assoc) => assoc.email)
|
|
12659
|
+
);
|
|
12660
|
+
if (associateEmails.length === 0) {
|
|
12661
|
+
await session.commitTransaction();
|
|
12662
|
+
return;
|
|
12663
|
+
}
|
|
12628
12664
|
await UserModel.updateMany(
|
|
12629
12665
|
{
|
|
12630
12666
|
associates: {
|
|
@@ -12641,34 +12677,67 @@ async function removeAssociateFromResource(resourceId, resourceType) {
|
|
|
12641
12677
|
resourceType
|
|
12642
12678
|
}
|
|
12643
12679
|
}
|
|
12680
|
+
},
|
|
12681
|
+
{ session }
|
|
12682
|
+
);
|
|
12683
|
+
await ChatModel.updateMany(
|
|
12684
|
+
{
|
|
12685
|
+
active: true,
|
|
12686
|
+
chatType: EnumChatType.RELATION,
|
|
12687
|
+
deletedAt: null,
|
|
12688
|
+
participants: {
|
|
12689
|
+
$elemMatch: {
|
|
12690
|
+
userId: normalizedOwnerId
|
|
12691
|
+
}
|
|
12692
|
+
}
|
|
12693
|
+
},
|
|
12694
|
+
{
|
|
12695
|
+
$set: {
|
|
12696
|
+
"participants.$[assoc].active": false
|
|
12697
|
+
}
|
|
12698
|
+
},
|
|
12699
|
+
{
|
|
12700
|
+
arrayFilters: [
|
|
12701
|
+
{
|
|
12702
|
+
"assoc.isAssociate": true,
|
|
12703
|
+
"assoc.userEmail": { $in: associateEmails }
|
|
12704
|
+
}
|
|
12705
|
+
],
|
|
12706
|
+
session
|
|
12644
12707
|
}
|
|
12645
|
-
)
|
|
12708
|
+
);
|
|
12709
|
+
await session.commitTransaction();
|
|
12646
12710
|
} catch (error) {
|
|
12711
|
+
await session.abortTransaction();
|
|
12647
12712
|
console.error(
|
|
12648
|
-
`[removeAssociateFromResource] Failed
|
|
12713
|
+
`[removeAssociateFromResource] Failed for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
|
|
12649
12714
|
error
|
|
12650
12715
|
);
|
|
12651
12716
|
throw error;
|
|
12717
|
+
} finally {
|
|
12718
|
+
session.endSession();
|
|
12652
12719
|
}
|
|
12653
12720
|
}
|
|
12654
12721
|
|
|
12655
12722
|
// src/service/vendor.ts
|
|
12656
12723
|
async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
12724
|
+
const session = await mongoose24.startSession();
|
|
12657
12725
|
try {
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
if (!userVendor) {
|
|
12726
|
+
session.startTransaction();
|
|
12727
|
+
const user = await UserModel.findById(userId).select("vendor").lean().session(session);
|
|
12728
|
+
if (!user?.vendor) {
|
|
12729
|
+
console.warn(`[updateVendor] No vendor for userId=${userId}`);
|
|
12730
|
+
await session.abortTransaction();
|
|
12664
12731
|
return;
|
|
12665
12732
|
}
|
|
12666
|
-
const
|
|
12667
|
-
if (
|
|
12733
|
+
const vendor = await VendorModel.findById(user.vendor).lean().session(session);
|
|
12734
|
+
if (!vendor) {
|
|
12735
|
+
console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
|
|
12736
|
+
await session.abortTransaction();
|
|
12668
12737
|
return;
|
|
12669
12738
|
}
|
|
12670
12739
|
const vendorUpdateData = {};
|
|
12671
|
-
if (
|
|
12740
|
+
if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
|
|
12672
12741
|
vendorUpdateData.associates = [];
|
|
12673
12742
|
vendorUpdateData.availability = {
|
|
12674
12743
|
corporate: false,
|
|
@@ -12677,46 +12746,50 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
12677
12746
|
};
|
|
12678
12747
|
vendorUpdateData.products = {
|
|
12679
12748
|
active: false,
|
|
12680
|
-
productsList:
|
|
12749
|
+
productsList: vendor.products?.productsList ?? []
|
|
12681
12750
|
};
|
|
12682
12751
|
vendorUpdateData.calendar = {
|
|
12683
12752
|
active: false,
|
|
12684
|
-
calendarData:
|
|
12753
|
+
calendarData: vendor.calendar?.calendarData ?? []
|
|
12685
12754
|
};
|
|
12686
|
-
vendorUpdateData.images = (
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
source: img.source,
|
|
12690
|
-
title: img.title
|
|
12755
|
+
vendorUpdateData.images = (vendor.images ?? []).map((img, index) => ({
|
|
12756
|
+
...img,
|
|
12757
|
+
active: index < 6
|
|
12691
12758
|
}));
|
|
12692
12759
|
} else {
|
|
12693
|
-
vendorUpdateData.images = (
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
source: img.source,
|
|
12697
|
-
title: img.title
|
|
12760
|
+
vendorUpdateData.images = (vendor.images ?? []).map((img) => ({
|
|
12761
|
+
...img,
|
|
12762
|
+
active: true
|
|
12698
12763
|
}));
|
|
12699
12764
|
}
|
|
12700
|
-
await VendorModel.
|
|
12701
|
-
|
|
12702
|
-
{
|
|
12703
|
-
|
|
12704
|
-
},
|
|
12705
|
-
{ new: true }
|
|
12765
|
+
await VendorModel.updateOne(
|
|
12766
|
+
{ _id: vendor._id },
|
|
12767
|
+
{ $set: vendorUpdateData },
|
|
12768
|
+
{ session }
|
|
12706
12769
|
);
|
|
12707
|
-
|
|
12770
|
+
if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
|
|
12771
|
+
await removeAssociateFromResource({
|
|
12772
|
+
resourceId: vendor._id,
|
|
12773
|
+
resourceOwnerId: vendor.owner.userId,
|
|
12774
|
+
resourceType: EnumResourceType.VENDOR
|
|
12775
|
+
});
|
|
12776
|
+
}
|
|
12777
|
+
await session.commitTransaction();
|
|
12708
12778
|
} catch (error) {
|
|
12709
|
-
|
|
12779
|
+
await session.abortTransaction();
|
|
12780
|
+
console.error("[updateVendorBasedOnUserLicense] Failed:", error);
|
|
12781
|
+
} finally {
|
|
12782
|
+
session.endSession();
|
|
12710
12783
|
}
|
|
12711
12784
|
}
|
|
12712
12785
|
|
|
12713
12786
|
// src/service/objectIdToString.ts
|
|
12714
|
-
import
|
|
12787
|
+
import mongoose25 from "mongoose";
|
|
12715
12788
|
function convertObjectIdsToStrings(obj) {
|
|
12716
12789
|
if (obj === null || obj === void 0) {
|
|
12717
12790
|
return obj;
|
|
12718
12791
|
}
|
|
12719
|
-
if (obj instanceof
|
|
12792
|
+
if (obj instanceof mongoose25.Types.ObjectId) {
|
|
12720
12793
|
return obj.toString();
|
|
12721
12794
|
}
|
|
12722
12795
|
if (Array.isArray(obj)) {
|
|
@@ -12747,7 +12820,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
12747
12820
|
|
|
12748
12821
|
// src/types/index.ts
|
|
12749
12822
|
import express from "express";
|
|
12750
|
-
import
|
|
12823
|
+
import mongoose26 from "mongoose";
|
|
12751
12824
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
12752
12825
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
12753
12826
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -12770,7 +12843,6 @@ export {
|
|
|
12770
12843
|
GoogleImportedMarketModel,
|
|
12771
12844
|
NotificationModel,
|
|
12772
12845
|
OwnerTypeSchema,
|
|
12773
|
-
ParticipantSchema,
|
|
12774
12846
|
PartnerModel,
|
|
12775
12847
|
PostModel,
|
|
12776
12848
|
PushTokenModel,
|
|
@@ -12794,7 +12866,7 @@ export {
|
|
|
12794
12866
|
findEventOrImportedMarketById,
|
|
12795
12867
|
locationGeoSchema,
|
|
12796
12868
|
locationsSchema,
|
|
12797
|
-
|
|
12869
|
+
mongoose26 as mongoose,
|
|
12798
12870
|
refundPolicySchema,
|
|
12799
12871
|
relationDatesSchema,
|
|
12800
12872
|
resourceRelationsSchema,
|