@timardex/cluemart-server-shared 1.0.297 → 1.0.300

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.
@@ -1,10 +1,10 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
2
  import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType } from '@timardex/cluemart-shared';
3
3
  import mongoose__default from 'mongoose';
4
- import { O as ObjectId } from '../Chat-Bnqec74U.mjs';
5
- export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Bnqec74U.mjs';
6
- import { S as SchemaOwnerType } from '../Affiliate-DaZKnzMu.mjs';
7
- export { A as AffiliateModel, C as CategorySchema, d as ContactDetailsSchema, O as OwnerTypeSchema, m as RelationModel, k as RelationTypeSchema, R as ResourceImageTypeSchema, o as SchemaAffiliateResourceType, n as SchemaAffiliateReward, a as SchemaRelatedPostType, j as SchemaRelationType, b as SocialMediaTypeSchema, c as associatesSchema, h as baseResourceFields, e as dateTimeSchema, l as locationGeoSchema, f as locationsSchema, g as relatedPostSchema, i as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-DaZKnzMu.mjs';
4
+ import { O as ObjectId } from '../Chat-Wn7yfc3v.mjs';
5
+ export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.mjs';
6
+ import { S as SchemaOwnerType } from '../Affiliate-BxNv9k41.mjs';
7
+ export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-BxNv9k41.mjs';
8
8
  import '@timardex/cluemart-shared/types';
9
9
  import 'express';
10
10
 
@@ -62,7 +62,7 @@ declare const ResourceActivityModel: mongoose__default.Model<ResourceActivityTyp
62
62
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
63
63
  resourceId: ObjectId;
64
64
  };
65
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
65
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions"> & {
66
66
  _id: ObjectId;
67
67
  affiliate: ObjectId;
68
68
  events: ObjectId[];
@@ -87,7 +87,7 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
87
87
  };
88
88
  };
89
89
  };
90
- declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
90
+ declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions"> & {
91
91
  _id: ObjectId;
92
92
  affiliate: ObjectId;
93
93
  events: ObjectId[];
@@ -1,10 +1,10 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
2
  import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType } from '@timardex/cluemart-shared';
3
3
  import mongoose__default from 'mongoose';
4
- import { O as ObjectId } from '../Chat-Bnqec74U.js';
5
- export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Bnqec74U.js';
6
- import { S as SchemaOwnerType } from '../Affiliate-DGmeZnDs.js';
7
- export { A as AffiliateModel, C as CategorySchema, d as ContactDetailsSchema, O as OwnerTypeSchema, m as RelationModel, k as RelationTypeSchema, R as ResourceImageTypeSchema, o as SchemaAffiliateResourceType, n as SchemaAffiliateReward, a as SchemaRelatedPostType, j as SchemaRelationType, b as SocialMediaTypeSchema, c as associatesSchema, h as baseResourceFields, e as dateTimeSchema, l as locationGeoSchema, f as locationsSchema, g as relatedPostSchema, i as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-DGmeZnDs.js';
4
+ import { O as ObjectId } from '../Chat-Wn7yfc3v.js';
5
+ export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.js';
6
+ import { S as SchemaOwnerType } from '../Affiliate-DRuifOv4.js';
7
+ export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-DRuifOv4.js';
8
8
  import '@timardex/cluemart-shared/types';
9
9
  import 'express';
10
10
 
@@ -62,7 +62,7 @@ declare const ResourceActivityModel: mongoose__default.Model<ResourceActivityTyp
62
62
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
63
63
  resourceId: ObjectId;
64
64
  };
65
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
65
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions"> & {
66
66
  _id: ObjectId;
67
67
  affiliate: ObjectId;
68
68
  events: ObjectId[];
@@ -87,7 +87,7 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
87
87
  };
88
88
  };
89
89
  };
90
- declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
90
+ declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions"> & {
91
91
  _id: ObjectId;
92
92
  affiliate: ObjectId;
93
93
  events: ObjectId[];
@@ -28,7 +28,6 @@ import {
28
28
  VendorInfoModel,
29
29
  VendorModel,
30
30
  VerificationTokenModel,
31
- associatesSchema,
32
31
  baseResourceFields,
33
32
  dateTimeSchema,
34
33
  locationGeoSchema,
@@ -40,7 +39,7 @@ import {
40
39
  socialShareResourceSchema,
41
40
  termsAgreementSchema,
42
41
  userLicenseSchema
43
- } from "../chunk-NBJNO6FV.mjs";
42
+ } from "../chunk-6WS5FH7A.mjs";
44
43
  export {
45
44
  APP_SETTINGS_ID,
46
45
  AdModel,
@@ -71,7 +70,6 @@ export {
71
70
  VendorInfoModel,
72
71
  VendorModel,
73
72
  VerificationTokenModel,
74
- associatesSchema,
75
73
  baseResourceFields,
76
74
  dateTimeSchema,
77
75
  locationGeoSchema,
@@ -3336,9 +3336,6 @@ var EnumRelationResource = /* @__PURE__ */ ((EnumRelationResource22) => {
3336
3336
  return EnumRelationResource22;
3337
3337
  })(EnumRelationResource || {});
3338
3338
  var EnumNotificationResourceType = /* @__PURE__ */ ((EnumNotificationResourceType22) => {
3339
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_EVENT"] = "added_as_associate_event";
3340
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_PARTNER"] = "added_as_associate_partner";
3341
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_VENDOR"] = "added_as_associate_vendor";
3342
3339
  EnumNotificationResourceType22["APPROVED_AFFILIATE"] = "approved_affiliate";
3343
3340
  EnumNotificationResourceType22["AFFILIATE_REWARD_RECEIVED"] = "affiliate_reward_received";
3344
3341
  EnumNotificationResourceType22["APPROVED_EVENT"] = "approved_event";
@@ -3410,13 +3407,13 @@ var EnumUserLicence = /* @__PURE__ */ ((EnumUserLicence22) => {
3410
3407
  })(EnumUserLicence || {});
3411
3408
  var EnumUserRole = /* @__PURE__ */ ((EnumUserRole22) => {
3412
3409
  EnumUserRole22["ADMIN"] = "admin";
3413
- EnumUserRole22["SUPER_ADMIN"] = "super_admin";
3414
- EnumUserRole22["CUSTOMER"] = "customer";
3415
- EnumUserRole22["MARKETING"] = "marketing";
3416
- EnumUserRole22["MODERATOR"] = "moderator";
3417
- EnumUserRole22["SUPPORT"] = "support";
3418
3410
  EnumUserRole22["AFFILIATE"] = "affiliate";
3411
+ EnumUserRole22["CUSTOMER"] = "customer";
3412
+ EnumUserRole22["EVENT"] = "event";
3413
+ EnumUserRole22["PARTNER"] = "partner";
3419
3414
  EnumUserRole22["SCHOOL"] = "school";
3415
+ EnumUserRole22["SUPER_ADMIN"] = "super_admin";
3416
+ EnumUserRole22["VENDOR"] = "vendor";
3420
3417
  return EnumUserRole22;
3421
3418
  })(EnumUserRole || {});
3422
3419
  var EnumEventDateStatus = /* @__PURE__ */ ((EnumEventDateStatus22) => {
@@ -5002,17 +4999,6 @@ var LICENCE_FIELDS_FRAGMENT = gql`
5002
4999
  prevLicenceType
5003
5000
  }
5004
5001
  `;
5005
- var ASSOCIATES_FIELDS_FRAGMENT = gql`
5006
- fragment AssociatesFields on AssociateType {
5007
- email
5008
- resourceId
5009
- resourceType
5010
- licence {
5011
- ...LicenceFields
5012
- }
5013
- }
5014
- ${LICENCE_FIELDS_FRAGMENT}
5015
- `;
5016
5002
  var TERMS_AGREEMENT_FIELDS_FRAGMENT = gql`
5017
5003
  fragment TermsAgreementFields on TermsAgreementType {
5018
5004
  appBuildNumber
@@ -5103,9 +5089,6 @@ var USER_FIELDS_FRAGMENT = gql`
5103
5089
  fragment UserFields on UserType {
5104
5090
  _id
5105
5091
  active
5106
- associates {
5107
- ...AssociatesFields
5108
- }
5109
5092
  affiliate
5110
5093
  avatar {
5111
5094
  ...ResourceImageFields
@@ -5128,8 +5111,9 @@ var USER_FIELDS_FRAGMENT = gql`
5128
5111
  overallPoints
5129
5112
  platform
5130
5113
  preferredRegion
5114
+ permissions
5131
5115
  promoCodes
5132
- role
5116
+ roles
5133
5117
  redeemedRewards {
5134
5118
  ...RedeemedRewardFields
5135
5119
  }
@@ -5144,7 +5128,6 @@ var USER_FIELDS_FRAGMENT = gql`
5144
5128
  updatedAt
5145
5129
  }
5146
5130
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5147
- ${ASSOCIATES_FIELDS_FRAGMENT}
5148
5131
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5149
5132
  ${USER_ACTIVITY_FIELDS_FRAGMENT}
5150
5133
  ${LICENCE_FIELDS_FRAGMENT}
@@ -5290,9 +5273,6 @@ var EVENT = gql`
5290
5273
  fragment EventFields on EventType {
5291
5274
  _id
5292
5275
  active
5293
- associates {
5294
- ...AssociatesFields
5295
- }
5296
5276
  adIds
5297
5277
  approvedAt
5298
5278
  cover {
@@ -5365,7 +5345,6 @@ var EVENT = gql`
5365
5345
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5366
5346
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5367
5347
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5368
- ${ASSOCIATES_FIELDS_FRAGMENT}
5369
5348
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5370
5349
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5371
5350
  ${RELATION_DATES_FRAGMENT}
@@ -5478,9 +5457,6 @@ var VENDOR = gql`
5478
5457
  fragment VendorFields on VendorType {
5479
5458
  _id
5480
5459
  active
5481
- associates {
5482
- ...AssociatesFields
5483
- }
5484
5460
  adIds
5485
5461
  approvedAt
5486
5462
  availability {
@@ -5571,7 +5547,6 @@ var VENDOR = gql`
5571
5547
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5572
5548
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5573
5549
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5574
- ${ASSOCIATES_FIELDS_FRAGMENT}
5575
5550
  ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5576
5551
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5577
5552
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
@@ -5724,9 +5699,6 @@ var PARTNER = gql`
5724
5699
  fragment PartnerFields on PartnerType {
5725
5700
  _id
5726
5701
  active
5727
- associates {
5728
- ...AssociatesFields
5729
- }
5730
5702
  adIds
5731
5703
  approvedAt
5732
5704
  cover {
@@ -5777,7 +5749,6 @@ var PARTNER = gql`
5777
5749
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5778
5750
  ${LOCATION_FIELDS_FRAGMENT}
5779
5751
  ${OWNER_FIELDS_FRAGMENT}
5780
- ${ASSOCIATES_FIELDS_FRAGMENT}
5781
5752
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5782
5753
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5783
5754
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
@@ -6224,7 +6195,6 @@ var CHAT_MESSAGE_FIELDS_FRAGMENT = gql`
6224
6195
  var CHAT_PARTICIPANT = gql`
6225
6196
  fragment ChatParticipantFields on ChatParticipantType {
6226
6197
  active
6227
- isAssociate
6228
6198
  userAvatar
6229
6199
  userEmail
6230
6200
  userId
@@ -7702,7 +7672,6 @@ var MessageSchema = new MongooseSchema2(
7702
7672
  var ParticipantSchema = new MongooseSchema2(
7703
7673
  {
7704
7674
  active: { default: true, required: true, type: Boolean },
7705
- isAssociate: { default: null, required: false, type: Boolean },
7706
7675
  userAvatar: { required: false, type: String },
7707
7676
  userEmail: { required: true, type: String },
7708
7677
  userId: {
@@ -8027,26 +7996,6 @@ var userLicenseSchema = new MongooseSchema6(
8027
7996
  },
8028
7997
  { _id: false, timestamps: false }
8029
7998
  );
8030
- var associatesSchema = new MongooseSchema6(
8031
- {
8032
- email: { required: true, type: String },
8033
- licence: {
8034
- required: true,
8035
- type: userLicenseSchema
8036
- },
8037
- resourceId: {
8038
- required: true,
8039
- type: String
8040
- },
8041
- resourceType: {
8042
- enum: Object.values(EnumResourceType),
8043
- required: true,
8044
- type: String
8045
- }
8046
- },
8047
- { _id: false }
8048
- // Prevents Mongoose from creating an additional _id field for subdocuments
8049
- );
8050
7999
  var ContactDetailsSchema = new MongooseSchema6(
8051
8000
  {
8052
8001
  email: { required: false, type: String },
@@ -8162,10 +8111,6 @@ var baseResourceFields = {
8162
8111
  type: [import_mongoose6.default.Schema.Types.ObjectId]
8163
8112
  },
8164
8113
  approvedAt: { default: null, required: false, type: Date },
8165
- associates: {
8166
- required: false,
8167
- type: [associatesSchema]
8168
- },
8169
8114
  contactDetails: { required: false, type: ContactDetailsSchema },
8170
8115
  cover: {
8171
8116
  required: true,
@@ -8309,7 +8254,7 @@ schema4.index({ isRead: 1, userId: 1 });
8309
8254
  schema4.index({ createdAt: -1, userId: 1 });
8310
8255
  var NotificationModel = import_mongoose8.default.models.Notification || import_mongoose8.default.model("Notification", schema4);
8311
8256
 
8312
- // node_modules/@timardex/cluemart-shared/dist/chunk-D33VEY7Q.mjs
8257
+ // node_modules/@timardex/cluemart-shared/dist/chunk-X3OLM35T.mjs
8313
8258
  var EnumOSPlatform2 = /* @__PURE__ */ ((EnumOSPlatform22) => {
8314
8259
  EnumOSPlatform22["ANDROID"] = "android";
8315
8260
  EnumOSPlatform22["IOS"] = "ios";
@@ -8470,10 +8415,6 @@ var schema7 = new MongooseSchema11(
8470
8415
  required: false,
8471
8416
  type: import_mongoose11.default.Schema.Types.ObjectId
8472
8417
  },
8473
- associates: {
8474
- required: false,
8475
- type: [associatesSchema]
8476
- },
8477
8418
  avatar: {
8478
8419
  required: false,
8479
8420
  type: ResourceImageTypeSchema
@@ -8534,11 +8475,11 @@ var schema7 = new MongooseSchema11(
8534
8475
  required: false,
8535
8476
  type: String
8536
8477
  },
8537
- role: {
8538
- default: EnumUserRole.CUSTOMER,
8478
+ roles: {
8479
+ default: [EnumUserRole.CUSTOMER],
8539
8480
  enum: Object.values(EnumUserRole),
8540
8481
  required: true,
8541
- type: String
8482
+ type: [String]
8542
8483
  },
8543
8484
  school: {
8544
8485
  ref: "School",
@@ -8573,7 +8514,6 @@ var schema7 = new MongooseSchema11(
8573
8514
  },
8574
8515
  { strict: false, timestamps: true }
8575
8516
  );
8576
- schema7.index({ "associates.email": 1 });
8577
8517
  schema7.index({ "licences.expiryDate": 1 });
8578
8518
  schema7.index({ "licences.licenceType": 1 });
8579
8519
  var UserModel = import_mongoose11.default.models.User || import_mongoose11.default.model("User", schema7);
@@ -8691,7 +8631,6 @@ schema9.index({ name: 1 });
8691
8631
  schema9.index({ description: 1 });
8692
8632
  schema9.index({ region: 1 });
8693
8633
  schema9.index({ "categories.name": 1 });
8694
- schema9.index({ "associates.email": 1 });
8695
8634
  schema9.index({ slug: 1 });
8696
8635
  var VendorModel = import_mongoose13.default.models.Vendor || import_mongoose13.default.model("Vendor", schema9);
8697
8636
 
@@ -8830,7 +8769,6 @@ schema12.index({ description: 1 });
8830
8769
  schema12.index({ region: 1 });
8831
8770
  schema12.index({ "location.geo": "2dsphere" });
8832
8771
  schema12.index({ tags: 1 });
8833
- schema12.index({ "associates.email": 1 });
8834
8772
  schema12.index({ deletedAt: 1 });
8835
8773
  schema12.index({ "dateTime.dateStatus": 1 });
8836
8774
  schema12.index({ slug: 1 });
@@ -8859,7 +8797,6 @@ schema13.index({ name: 1 });
8859
8797
  schema13.index({ description: 1 });
8860
8798
  schema13.index({ region: 1 });
8861
8799
  schema13.index({ "location.geo": "2dsphere" });
8862
- schema13.index({ "associates.email": 1 });
8863
8800
  schema13.index({ slug: 1 });
8864
8801
  var PartnerModel = import_mongoose17.default.models.Partner || import_mongoose17.default.model("Partner", schema13);
8865
8802
 
@@ -9801,112 +9738,6 @@ async function updateAdStatuses() {
9801
9738
  );
9802
9739
  }
9803
9740
 
9804
- // src/service/associate.ts
9805
- var import_mongoose32 = __toESM(require("mongoose"));
9806
- function normalizeObjectId(id) {
9807
- return typeof id === "string" ? new import_mongoose32.default.Types.ObjectId(id) : id;
9808
- }
9809
- async function getAssociateEmailsForResource({
9810
- normalizedResourceId,
9811
- resourceType
9812
- }) {
9813
- const usersWithAssociates = await UserModel.find(
9814
- {
9815
- associates: {
9816
- $elemMatch: {
9817
- resourceId: normalizedResourceId,
9818
- resourceType
9819
- }
9820
- }
9821
- },
9822
- {
9823
- associates: 1
9824
- }
9825
- ).lean();
9826
- return [
9827
- ...new Set(
9828
- usersWithAssociates.flatMap(
9829
- (user) => (user.associates ?? []).filter(
9830
- (associate) => associate.resourceId === normalizedResourceId && associate.resourceType === resourceType
9831
- ).map((associate) => associate.email)
9832
- )
9833
- )
9834
- ];
9835
- }
9836
- async function pullAssociatesFromUsers({
9837
- normalizedResourceId,
9838
- resourceType
9839
- }) {
9840
- await UserModel.updateMany(
9841
- {
9842
- associates: {
9843
- $elemMatch: {
9844
- resourceId: normalizedResourceId,
9845
- resourceType
9846
- }
9847
- }
9848
- },
9849
- {
9850
- $pull: {
9851
- associates: {
9852
- resourceId: normalizedResourceId,
9853
- resourceType
9854
- }
9855
- }
9856
- }
9857
- );
9858
- }
9859
- async function pullAssociateParticipantsFromChats(resourceOwnerId, associateEmails) {
9860
- await ChatModel.updateMany(
9861
- {
9862
- active: true,
9863
- chatType: EnumChatType.RELATION,
9864
- deletedAt: null,
9865
- participants: {
9866
- $elemMatch: {
9867
- userId: resourceOwnerId
9868
- }
9869
- }
9870
- },
9871
- {
9872
- $pull: {
9873
- participants: {
9874
- isAssociate: true,
9875
- userEmail: {
9876
- $in: associateEmails
9877
- }
9878
- }
9879
- }
9880
- }
9881
- );
9882
- }
9883
- async function removeAssociateFromResource({
9884
- resourceId,
9885
- resourceOwnerId,
9886
- resourceType
9887
- }) {
9888
- try {
9889
- const scope = {
9890
- normalizedResourceId: resourceId.toString(),
9891
- resourceType
9892
- };
9893
- const associateEmails = await getAssociateEmailsForResource(scope);
9894
- if (associateEmails.length === 0) {
9895
- return;
9896
- }
9897
- await pullAssociatesFromUsers(scope);
9898
- await pullAssociateParticipantsFromChats(
9899
- normalizeObjectId(resourceOwnerId),
9900
- associateEmails
9901
- );
9902
- } catch (error) {
9903
- console.error(
9904
- `[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,
9905
- error
9906
- );
9907
- }
9908
- }
9909
-
9910
9741
  // src/service/vendor.ts
9911
9742
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
9912
9743
  try {
@@ -9923,7 +9754,6 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9923
9754
  const updateData = {};
9924
9755
  const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;
9925
9756
  if (isStandardVendor) {
9926
- updateData.associates = [];
9927
9757
  updateData.availability = {
9928
9758
  corporate: false,
9929
9759
  private: false,
@@ -9943,25 +9773,18 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9943
9773
  active: isStandardVendor ? index < 6 : true
9944
9774
  }));
9945
9775
  await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
9946
- if (isStandardVendor) {
9947
- await removeAssociateFromResource({
9948
- resourceId: vendor._id,
9949
- resourceOwnerId: vendor.owner.userId,
9950
- resourceType: EnumResourceType.VENDOR
9951
- });
9952
- }
9953
9776
  } catch (error) {
9954
9777
  console.error("[updateVendorBasedOnUserLicense] Failed:", error);
9955
9778
  }
9956
9779
  }
9957
9780
 
9958
9781
  // src/service/objectIdToString.ts
9959
- var import_mongoose35 = __toESM(require("mongoose"));
9782
+ var import_mongoose33 = __toESM(require("mongoose"));
9960
9783
  function convertObjectIdsToStrings(obj) {
9961
9784
  if (obj === null || obj === void 0) {
9962
9785
  return obj;
9963
9786
  }
9964
- if (obj instanceof import_mongoose35.default.Types.ObjectId) {
9787
+ if (obj instanceof import_mongoose33.default.Types.ObjectId) {
9965
9788
  return obj.toString();
9966
9789
  }
9967
9790
  if (obj instanceof Date) {