@timardex/cluemart-server-shared 1.0.149 → 1.0.151
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-QVELNUI7.mjs} +106 -15
- package/dist/chunk-QVELNUI7.mjs.map +1 -0
- package/dist/index.cjs +213 -53
- 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 +213 -52
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +104 -15
- 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 +209 -47
- 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
|
|
@@ -9967,6 +9968,41 @@ var DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT = gql`
|
|
|
9967
9968
|
}
|
|
9968
9969
|
${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
|
|
9969
9970
|
`;
|
|
9971
|
+
var MINI_QUIZ_QUESTION_FIELDS_FRAGMENT = gql`
|
|
9972
|
+
fragment MiniQuizQuestionFields on MiniQuizQuestionType {
|
|
9973
|
+
answers {
|
|
9974
|
+
answer
|
|
9975
|
+
correct
|
|
9976
|
+
}
|
|
9977
|
+
question
|
|
9978
|
+
}
|
|
9979
|
+
`;
|
|
9980
|
+
var MINI_QUIZ_BASE_GAME_FIELDS_FRAGMENT = gql`
|
|
9981
|
+
fragment MiniQuizBaseGameFields on MiniQuizBaseGameType {
|
|
9982
|
+
gameDate {
|
|
9983
|
+
...GameDateFields
|
|
9984
|
+
}
|
|
9985
|
+
questions {
|
|
9986
|
+
...MiniQuizQuestionFields
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9989
|
+
${GAME_DATE_FIELDS_FRAGMENT}
|
|
9990
|
+
${MINI_QUIZ_QUESTION_FIELDS_FRAGMENT}
|
|
9991
|
+
`;
|
|
9992
|
+
var MINI_QUIZ_GAME_DATA_FIELDS_FRAGMENT = gql`
|
|
9993
|
+
fragment MiniQuizGameDataFields on MiniQuizGameDataType {
|
|
9994
|
+
gameFields {
|
|
9995
|
+
...MiniQuizBaseGameFields
|
|
9996
|
+
}
|
|
9997
|
+
quizInfo {
|
|
9998
|
+
...MiniQuizQuestionFields
|
|
9999
|
+
}
|
|
10000
|
+
points
|
|
10001
|
+
streak
|
|
10002
|
+
}
|
|
10003
|
+
${MINI_QUIZ_BASE_GAME_FIELDS_FRAGMENT}
|
|
10004
|
+
${MINI_QUIZ_QUESTION_FIELDS_FRAGMENT}
|
|
10005
|
+
`;
|
|
9970
10006
|
var GAME_HISTORY_FIELDS_FRAGMENT = gql`
|
|
9971
10007
|
fragment GameHistoryFields on GameHistoryType {
|
|
9972
10008
|
createdAt
|
|
@@ -9984,8 +10020,12 @@ var GAME_DATA_FIELDS_FRAGMENT = gql`
|
|
|
9984
10020
|
dailyClue {
|
|
9985
10021
|
...DailyClueGameDataFields
|
|
9986
10022
|
}
|
|
10023
|
+
miniQuiz {
|
|
10024
|
+
...MiniQuizGameDataFields
|
|
10025
|
+
}
|
|
9987
10026
|
}
|
|
9988
10027
|
${DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT}
|
|
10028
|
+
${MINI_QUIZ_GAME_DATA_FIELDS_FRAGMENT}
|
|
9989
10029
|
`;
|
|
9990
10030
|
var GAME_FIELDS_FRAGMENT = gql`
|
|
9991
10031
|
fragment GameFields on GameType {
|
|
@@ -10059,8 +10099,12 @@ var BASE_GAME_FIELDS_FRAGMENT = gql`
|
|
|
10059
10099
|
dailyClue {
|
|
10060
10100
|
...DailyClueBaseGameFields
|
|
10061
10101
|
}
|
|
10102
|
+
miniQuiz {
|
|
10103
|
+
...MiniQuizBaseGameFields
|
|
10104
|
+
}
|
|
10062
10105
|
}
|
|
10063
10106
|
${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
|
|
10107
|
+
${MINI_QUIZ_BASE_GAME_FIELDS_FRAGMENT}
|
|
10064
10108
|
`;
|
|
10065
10109
|
var POST_CONTENT_DATA_FIELDS_FRAGMENT = gql`
|
|
10066
10110
|
fragment PostContentDataFields on PostContentData {
|
|
@@ -11057,6 +11101,7 @@ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
|
|
|
11057
11101
|
})(EnumGameStatus || {});
|
|
11058
11102
|
var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
|
|
11059
11103
|
EnumGameType2["DAILY_CLUE"] = "dailyClue";
|
|
11104
|
+
EnumGameType2["MINI_QUIZ"] = "miniQuiz";
|
|
11060
11105
|
return EnumGameType2;
|
|
11061
11106
|
})(EnumGameType || {});
|
|
11062
11107
|
|
|
@@ -11183,6 +11228,7 @@ var MessageSchema = new MongooseSchema2(
|
|
|
11183
11228
|
var ParticipantSchema = new MongooseSchema2(
|
|
11184
11229
|
{
|
|
11185
11230
|
active: { default: true, required: true, type: Boolean },
|
|
11231
|
+
isAssociate: { default: null, required: false, type: Boolean },
|
|
11186
11232
|
userAvatar: { required: false, type: String },
|
|
11187
11233
|
userEmail: { required: true, type: String },
|
|
11188
11234
|
userId: {
|
|
@@ -12301,6 +12347,9 @@ var AppSettingSchema = new MongooseSchema18(
|
|
|
12301
12347
|
var AppSettingModel = mongoose18.models.AppSetting || mongoose18.model("AppSetting", AppSettingSchema);
|
|
12302
12348
|
|
|
12303
12349
|
// src/mongoose/game/Game.ts
|
|
12350
|
+
import mongoose22 from "mongoose";
|
|
12351
|
+
|
|
12352
|
+
// src/mongoose/game/DailyClue.ts
|
|
12304
12353
|
import mongoose20 from "mongoose";
|
|
12305
12354
|
|
|
12306
12355
|
// src/mongoose/game/utils.ts
|
|
@@ -12313,7 +12362,10 @@ var schemaGameDate = new MongooseSchema19(
|
|
|
12313
12362
|
},
|
|
12314
12363
|
{ _id: false }
|
|
12315
12364
|
);
|
|
12316
|
-
|
|
12365
|
+
|
|
12366
|
+
// src/mongoose/game/DailyClue.ts
|
|
12367
|
+
var MongooseSchema20 = mongoose20.Schema;
|
|
12368
|
+
var schemaLetters = new MongooseSchema20(
|
|
12317
12369
|
{
|
|
12318
12370
|
collected: { required: false, type: [String] },
|
|
12319
12371
|
solutionShuffled: { required: true, type: [String] }
|
|
@@ -12321,14 +12373,14 @@ var schemaLetters = new MongooseSchema19(
|
|
|
12321
12373
|
},
|
|
12322
12374
|
{ _id: false }
|
|
12323
12375
|
);
|
|
12324
|
-
var schemaDailyClueBaseGame = new
|
|
12376
|
+
var schemaDailyClueBaseGame = new MongooseSchema20(
|
|
12325
12377
|
{
|
|
12326
12378
|
gameDate: { required: true, type: schemaGameDate },
|
|
12327
12379
|
gameSolution: { required: true, type: String }
|
|
12328
12380
|
},
|
|
12329
12381
|
{ _id: false }
|
|
12330
12382
|
);
|
|
12331
|
-
var schemaDailyClueGameData = new
|
|
12383
|
+
var schemaDailyClueGameData = new MongooseSchema20(
|
|
12332
12384
|
{
|
|
12333
12385
|
gameFields: { required: true, type: schemaDailyClueBaseGame },
|
|
12334
12386
|
lastFoundDate: { default: null, required: false, type: Date },
|
|
@@ -12342,10 +12394,49 @@ var schemaDailyClueGameData = new MongooseSchema19(
|
|
|
12342
12394
|
{ _id: false }
|
|
12343
12395
|
);
|
|
12344
12396
|
|
|
12397
|
+
// src/mongoose/game/MiniQuiz.ts
|
|
12398
|
+
import mongoose21 from "mongoose";
|
|
12399
|
+
var MongooseSchema21 = mongoose21.Schema;
|
|
12400
|
+
var schemaMiniQuizAnswers = new MongooseSchema21(
|
|
12401
|
+
{
|
|
12402
|
+
answer: { required: true, type: String },
|
|
12403
|
+
correct: { required: true, type: Boolean }
|
|
12404
|
+
},
|
|
12405
|
+
{ _id: false }
|
|
12406
|
+
);
|
|
12407
|
+
var schemaMiniQuizQuestions = new MongooseSchema21(
|
|
12408
|
+
{
|
|
12409
|
+
answers: { required: true, type: [schemaMiniQuizAnswers] },
|
|
12410
|
+
question: { required: true, type: String }
|
|
12411
|
+
},
|
|
12412
|
+
{ _id: false }
|
|
12413
|
+
);
|
|
12414
|
+
var schemaMiniQuizBaseGame = new MongooseSchema21(
|
|
12415
|
+
{
|
|
12416
|
+
gameDate: { required: true, type: Date },
|
|
12417
|
+
questions: { required: true, type: [schemaMiniQuizQuestions] }
|
|
12418
|
+
},
|
|
12419
|
+
{ _id: false }
|
|
12420
|
+
);
|
|
12421
|
+
var schemaMiniQuizGameData = new MongooseSchema21(
|
|
12422
|
+
{
|
|
12423
|
+
gameFields: { required: true, type: schemaMiniQuizBaseGame },
|
|
12424
|
+
points: { default: 0, required: true, type: Number },
|
|
12425
|
+
quizInfo: {
|
|
12426
|
+
default: null,
|
|
12427
|
+
required: false,
|
|
12428
|
+
type: [schemaMiniQuizQuestions]
|
|
12429
|
+
},
|
|
12430
|
+
streak: { default: 0, required: true, type: Number }
|
|
12431
|
+
},
|
|
12432
|
+
{ _id: false }
|
|
12433
|
+
);
|
|
12434
|
+
|
|
12345
12435
|
// src/mongoose/game/Game.ts
|
|
12346
|
-
var
|
|
12436
|
+
var MongooseSchema22 = mongoose22.Schema;
|
|
12347
12437
|
var gameDataSchemas = {
|
|
12348
|
-
[EnumGameType.DAILY_CLUE]: schemaDailyClueGameData
|
|
12438
|
+
[EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
12439
|
+
[EnumGameType.MINI_QUIZ]: schemaMiniQuizGameData
|
|
12349
12440
|
};
|
|
12350
12441
|
var gameDataDefinition = Object.fromEntries(
|
|
12351
12442
|
Object.entries(gameDataSchemas).map(([key, schema16]) => [
|
|
@@ -12353,7 +12444,7 @@ var gameDataDefinition = Object.fromEntries(
|
|
|
12353
12444
|
{ default: null, required: false, type: schema16 }
|
|
12354
12445
|
])
|
|
12355
12446
|
);
|
|
12356
|
-
var gameHistorySchema = new
|
|
12447
|
+
var gameHistorySchema = new MongooseSchema22(
|
|
12357
12448
|
{
|
|
12358
12449
|
createdAt: { required: true, type: Date },
|
|
12359
12450
|
gameDate: { required: true, type: schemaGameDate },
|
|
@@ -12371,7 +12462,7 @@ var gameHistorySchema = new MongooseSchema20(
|
|
|
12371
12462
|
},
|
|
12372
12463
|
{ _id: false }
|
|
12373
12464
|
);
|
|
12374
|
-
var gameTypeSchema = new
|
|
12465
|
+
var gameTypeSchema = new MongooseSchema22(
|
|
12375
12466
|
{
|
|
12376
12467
|
active: { default: true, required: true, type: Boolean },
|
|
12377
12468
|
gameData: gameDataDefinition,
|
|
@@ -12384,7 +12475,7 @@ var gameTypeSchema = new MongooseSchema20(
|
|
|
12384
12475
|
},
|
|
12385
12476
|
{ timestamps: true }
|
|
12386
12477
|
);
|
|
12387
|
-
var schema14 = new
|
|
12478
|
+
var schema14 = new MongooseSchema22(
|
|
12388
12479
|
{
|
|
12389
12480
|
active: { default: false, required: true, type: Boolean },
|
|
12390
12481
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -12397,12 +12488,12 @@ var schema14 = new MongooseSchema20(
|
|
|
12397
12488
|
},
|
|
12398
12489
|
{ timestamps: true }
|
|
12399
12490
|
);
|
|
12400
|
-
var GameModel =
|
|
12491
|
+
var GameModel = mongoose22.models.Game || mongoose22.model("Game", schema14);
|
|
12401
12492
|
|
|
12402
12493
|
// src/mongoose/School.ts
|
|
12403
|
-
import
|
|
12404
|
-
var
|
|
12405
|
-
var schema15 = new
|
|
12494
|
+
import mongoose23 from "mongoose";
|
|
12495
|
+
var MongooseSchema23 = mongoose23.Schema;
|
|
12496
|
+
var schema15 = new MongooseSchema23(
|
|
12406
12497
|
{
|
|
12407
12498
|
// New schools are active by default
|
|
12408
12499
|
active: { default: true, required: true, type: Boolean },
|
|
@@ -12427,10 +12518,10 @@ var schema15 = new MongooseSchema21(
|
|
|
12427
12518
|
},
|
|
12428
12519
|
{ timestamps: true }
|
|
12429
12520
|
);
|
|
12430
|
-
var SchoolModel =
|
|
12521
|
+
var SchoolModel = mongoose23.models.School || mongoose23.model("School", schema15);
|
|
12431
12522
|
|
|
12432
12523
|
// src/service/database.ts
|
|
12433
|
-
import
|
|
12524
|
+
import mongoose24 from "mongoose";
|
|
12434
12525
|
var connectToDatabase = async ({
|
|
12435
12526
|
appName,
|
|
12436
12527
|
dbName,
|
|
@@ -12443,7 +12534,7 @@ var connectToDatabase = async ({
|
|
|
12443
12534
|
// Fallback to MongoDB Atlas connection string
|
|
12444
12535
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
12445
12536
|
);
|
|
12446
|
-
await
|
|
12537
|
+
await mongoose24.connect(mongoUri);
|
|
12447
12538
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
12448
12539
|
console.log(
|
|
12449
12540
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -12621,10 +12712,44 @@ async function updateAdStatuses() {
|
|
|
12621
12712
|
);
|
|
12622
12713
|
}
|
|
12623
12714
|
|
|
12715
|
+
// src/service/vendor.ts
|
|
12716
|
+
import mongoose26 from "mongoose";
|
|
12717
|
+
|
|
12624
12718
|
// src/service/associate.ts
|
|
12625
|
-
|
|
12719
|
+
import mongoose25 from "mongoose";
|
|
12720
|
+
async function removeAssociateFromResource({
|
|
12721
|
+
resourceId,
|
|
12722
|
+
resourceOwnerId,
|
|
12723
|
+
resourceType
|
|
12724
|
+
}) {
|
|
12626
12725
|
const normalizedResourceId = resourceId.toString();
|
|
12726
|
+
const normalizedOwnerId = typeof resourceOwnerId === "string" ? new mongoose25.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
|
|
12727
|
+
const session = await mongoose25.startSession();
|
|
12627
12728
|
try {
|
|
12729
|
+
session.startTransaction();
|
|
12730
|
+
const usersWithAssociates = await UserModel.find(
|
|
12731
|
+
{
|
|
12732
|
+
associates: {
|
|
12733
|
+
$elemMatch: {
|
|
12734
|
+
resourceId: normalizedResourceId,
|
|
12735
|
+
resourceType
|
|
12736
|
+
}
|
|
12737
|
+
}
|
|
12738
|
+
},
|
|
12739
|
+
{
|
|
12740
|
+
associates: 1
|
|
12741
|
+
// Only fetch associates field for efficiency
|
|
12742
|
+
}
|
|
12743
|
+
).lean().session(session);
|
|
12744
|
+
const associateEmails = usersWithAssociates.flatMap(
|
|
12745
|
+
(user) => (user.associates ?? []).filter(
|
|
12746
|
+
(assoc) => assoc.resourceId === normalizedResourceId && assoc.resourceType === resourceType
|
|
12747
|
+
).map((assoc) => assoc.email)
|
|
12748
|
+
);
|
|
12749
|
+
if (associateEmails.length === 0) {
|
|
12750
|
+
await session.commitTransaction();
|
|
12751
|
+
return;
|
|
12752
|
+
}
|
|
12628
12753
|
await UserModel.updateMany(
|
|
12629
12754
|
{
|
|
12630
12755
|
associates: {
|
|
@@ -12641,34 +12766,67 @@ async function removeAssociateFromResource(resourceId, resourceType) {
|
|
|
12641
12766
|
resourceType
|
|
12642
12767
|
}
|
|
12643
12768
|
}
|
|
12769
|
+
},
|
|
12770
|
+
{ session }
|
|
12771
|
+
);
|
|
12772
|
+
await ChatModel.updateMany(
|
|
12773
|
+
{
|
|
12774
|
+
active: true,
|
|
12775
|
+
chatType: EnumChatType.RELATION,
|
|
12776
|
+
deletedAt: null,
|
|
12777
|
+
participants: {
|
|
12778
|
+
$elemMatch: {
|
|
12779
|
+
userId: normalizedOwnerId
|
|
12780
|
+
}
|
|
12781
|
+
}
|
|
12782
|
+
},
|
|
12783
|
+
{
|
|
12784
|
+
$set: {
|
|
12785
|
+
"participants.$[assoc].active": false
|
|
12786
|
+
}
|
|
12787
|
+
},
|
|
12788
|
+
{
|
|
12789
|
+
arrayFilters: [
|
|
12790
|
+
{
|
|
12791
|
+
"assoc.isAssociate": true,
|
|
12792
|
+
"assoc.userEmail": { $in: associateEmails }
|
|
12793
|
+
}
|
|
12794
|
+
],
|
|
12795
|
+
session
|
|
12644
12796
|
}
|
|
12645
|
-
)
|
|
12797
|
+
);
|
|
12798
|
+
await session.commitTransaction();
|
|
12646
12799
|
} catch (error) {
|
|
12800
|
+
await session.abortTransaction();
|
|
12647
12801
|
console.error(
|
|
12648
|
-
`[removeAssociateFromResource] Failed
|
|
12802
|
+
`[removeAssociateFromResource] Failed for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
|
|
12649
12803
|
error
|
|
12650
12804
|
);
|
|
12651
12805
|
throw error;
|
|
12806
|
+
} finally {
|
|
12807
|
+
session.endSession();
|
|
12652
12808
|
}
|
|
12653
12809
|
}
|
|
12654
12810
|
|
|
12655
12811
|
// src/service/vendor.ts
|
|
12656
12812
|
async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
12813
|
+
const session = await mongoose26.startSession();
|
|
12657
12814
|
try {
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
if (!userVendor) {
|
|
12815
|
+
session.startTransaction();
|
|
12816
|
+
const user = await UserModel.findById(userId).select("vendor").lean().session(session);
|
|
12817
|
+
if (!user?.vendor) {
|
|
12818
|
+
console.warn(`[updateVendor] No vendor for userId=${userId}`);
|
|
12819
|
+
await session.abortTransaction();
|
|
12664
12820
|
return;
|
|
12665
12821
|
}
|
|
12666
|
-
const
|
|
12667
|
-
if (
|
|
12822
|
+
const vendor = await VendorModel.findById(user.vendor).lean().session(session);
|
|
12823
|
+
if (!vendor) {
|
|
12824
|
+
console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
|
|
12825
|
+
await session.abortTransaction();
|
|
12668
12826
|
return;
|
|
12669
12827
|
}
|
|
12670
12828
|
const vendorUpdateData = {};
|
|
12671
|
-
if (
|
|
12829
|
+
if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
|
|
12672
12830
|
vendorUpdateData.associates = [];
|
|
12673
12831
|
vendorUpdateData.availability = {
|
|
12674
12832
|
corporate: false,
|
|
@@ -12677,46 +12835,50 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
12677
12835
|
};
|
|
12678
12836
|
vendorUpdateData.products = {
|
|
12679
12837
|
active: false,
|
|
12680
|
-
productsList:
|
|
12838
|
+
productsList: vendor.products?.productsList ?? []
|
|
12681
12839
|
};
|
|
12682
12840
|
vendorUpdateData.calendar = {
|
|
12683
12841
|
active: false,
|
|
12684
|
-
calendarData:
|
|
12842
|
+
calendarData: vendor.calendar?.calendarData ?? []
|
|
12685
12843
|
};
|
|
12686
|
-
vendorUpdateData.images = (
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
source: img.source,
|
|
12690
|
-
title: img.title
|
|
12844
|
+
vendorUpdateData.images = (vendor.images ?? []).map((img, index) => ({
|
|
12845
|
+
...img,
|
|
12846
|
+
active: index < 6
|
|
12691
12847
|
}));
|
|
12692
12848
|
} else {
|
|
12693
|
-
vendorUpdateData.images = (
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
source: img.source,
|
|
12697
|
-
title: img.title
|
|
12849
|
+
vendorUpdateData.images = (vendor.images ?? []).map((img) => ({
|
|
12850
|
+
...img,
|
|
12851
|
+
active: true
|
|
12698
12852
|
}));
|
|
12699
12853
|
}
|
|
12700
|
-
await VendorModel.
|
|
12701
|
-
|
|
12702
|
-
{
|
|
12703
|
-
|
|
12704
|
-
},
|
|
12705
|
-
{ new: true }
|
|
12854
|
+
await VendorModel.updateOne(
|
|
12855
|
+
{ _id: vendor._id },
|
|
12856
|
+
{ $set: vendorUpdateData },
|
|
12857
|
+
{ session }
|
|
12706
12858
|
);
|
|
12707
|
-
|
|
12859
|
+
if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
|
|
12860
|
+
await removeAssociateFromResource({
|
|
12861
|
+
resourceId: vendor._id,
|
|
12862
|
+
resourceOwnerId: vendor.owner.userId,
|
|
12863
|
+
resourceType: EnumResourceType.VENDOR
|
|
12864
|
+
});
|
|
12865
|
+
}
|
|
12866
|
+
await session.commitTransaction();
|
|
12708
12867
|
} catch (error) {
|
|
12709
|
-
|
|
12868
|
+
await session.abortTransaction();
|
|
12869
|
+
console.error("[updateVendorBasedOnUserLicense] Failed:", error);
|
|
12870
|
+
} finally {
|
|
12871
|
+
session.endSession();
|
|
12710
12872
|
}
|
|
12711
12873
|
}
|
|
12712
12874
|
|
|
12713
12875
|
// src/service/objectIdToString.ts
|
|
12714
|
-
import
|
|
12876
|
+
import mongoose27 from "mongoose";
|
|
12715
12877
|
function convertObjectIdsToStrings(obj) {
|
|
12716
12878
|
if (obj === null || obj === void 0) {
|
|
12717
12879
|
return obj;
|
|
12718
12880
|
}
|
|
12719
|
-
if (obj instanceof
|
|
12881
|
+
if (obj instanceof mongoose27.Types.ObjectId) {
|
|
12720
12882
|
return obj.toString();
|
|
12721
12883
|
}
|
|
12722
12884
|
if (Array.isArray(obj)) {
|
|
@@ -12747,7 +12909,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
12747
12909
|
|
|
12748
12910
|
// src/types/index.ts
|
|
12749
12911
|
import express from "express";
|
|
12750
|
-
import
|
|
12912
|
+
import mongoose28 from "mongoose";
|
|
12751
12913
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
12752
12914
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
12753
12915
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -12770,7 +12932,6 @@ export {
|
|
|
12770
12932
|
GoogleImportedMarketModel,
|
|
12771
12933
|
NotificationModel,
|
|
12772
12934
|
OwnerTypeSchema,
|
|
12773
|
-
ParticipantSchema,
|
|
12774
12935
|
PartnerModel,
|
|
12775
12936
|
PostModel,
|
|
12776
12937
|
PushTokenModel,
|
|
@@ -12794,7 +12955,7 @@ export {
|
|
|
12794
12955
|
findEventOrImportedMarketById,
|
|
12795
12956
|
locationGeoSchema,
|
|
12796
12957
|
locationsSchema,
|
|
12797
|
-
|
|
12958
|
+
mongoose28 as mongoose,
|
|
12798
12959
|
refundPolicySchema,
|
|
12799
12960
|
relationDatesSchema,
|
|
12800
12961
|
resourceRelationsSchema,
|