@timardex/cluemart-shared 1.2.32 → 1.2.34
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/{ad-Cv1V8lgJ.d.ts → ad-BZylIpez.d.ts} +1 -1
- package/dist/{ad-IVwm5MLY.d.mts → ad-CiYcsJB7.d.mts} +1 -1
- package/dist/{auth-BCxQp_CF.d.ts → auth-CmaB99NK.d.ts} +1 -1
- package/dist/{auth-BczaOu28.d.mts → auth-DDtMJHZw.d.mts} +1 -1
- package/dist/formFields/index.cjs +0 -7
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +1 -1
- package/dist/formFields/index.d.ts +1 -1
- package/dist/formFields/index.mjs +0 -7
- package/dist/formFields/index.mjs.map +1 -1
- package/dist/{global-Bnr6l_NH.d.ts → global-DVYSZ6LR.d.ts} +4 -4
- package/dist/{global-_89-F0iL.d.mts → global-ExJZRDGR.d.mts} +4 -4
- package/dist/graphql/index.d.mts +2 -2
- package/dist/graphql/index.d.ts +2 -2
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.mjs +1 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.cjs +13 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -13
- package/dist/index.d.ts +6 -13
- package/dist/index.mjs +11 -45
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +3 -3
- package/dist/mongoose/index.d.ts +3 -3
- package/dist/mongoose/index.mjs +4 -4
- package/dist/mongoose/index.mjs.map +1 -1
- package/dist/service/index.cjs +17 -49
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +4 -11
- package/dist/service/index.d.ts +4 -11
- package/dist/service/index.mjs +10 -40
- package/dist/service/index.mjs.map +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mongoose/Ad.ts","../../src/mongoose/global.ts","../../src/mongoose/Relation.ts","../../src/mongoose/event/EventInfo.ts","../../src/mongoose/Chat.ts","../../src/mongoose/ResourceActivity.ts","../../src/mongoose/Testers.ts","../../src/mongoose/User.ts","../../src/mongoose/VerificationToken.ts","../../src/mongoose/vendor/Vendor.ts","../../src/mongoose/vendor/VendorInfo.ts","../../src/mongoose/event/Event.ts"],"sourcesContent":["import mongoose from \"mongoose\";\n\nimport { EnumResourceType } from \"src/enums\";\nimport {\n AdType,\n EnumAdShowOn,\n EnumAdStatus,\n EnumAdStyle,\n EnumAdType,\n} from \"src/types\";\n\nimport { SocialMediaTypeSchema } from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst schema = new MongooseSchema<AdType>(\n {\n active: { default: true, type: Boolean },\n adStyle: {\n default: EnumAdStyle.BLOOM,\n enum: Object.values(EnumAdStyle),\n required: true,\n type: String,\n },\n adType: {\n default: EnumAdType.SPONSORED,\n enum: Object.values(EnumAdType),\n required: true,\n type: String,\n },\n // TODO: similar to ViewSchema\n clicks: { default: 0, required: true, type: Number },\n clui: { required: false, type: String },\n end: { required: true, type: Date },\n // TODO: similar to ViewSchema\n impressions: { default: 0, required: true, type: Number },\n resourceCover: { required: true, type: String },\n resourceDescription: { required: true, type: String },\n resourceId: { required: true, type: String },\n resourceLogo: { required: false, type: String },\n resourceName: { required: true, type: String },\n resourceRegion: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n showOn: {\n default: EnumAdShowOn.FRONT_PAGE,\n enum: Object.values(EnumAdShowOn),\n required: true,\n type: String,\n },\n socialMedia: [SocialMediaTypeSchema],\n start: { required: true, type: Date },\n status: {\n default: EnumAdStatus.ACTIVE,\n enum: Object.values(EnumAdStatus),\n required: true,\n type: String,\n },\n targetRegion: { required: false, type: String },\n },\n {\n timestamps: true,\n },\n);\n\n// Compound index for background job queries\nschema.index({\n end: 1,\n start: 1,\n status: 1,\n});\n\nexport const AdModel =\n (mongoose.models.Ad as mongoose.Model<AdType>) ||\n mongoose.model<AdType>(\"Ad\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumResourceType, EnumUserLicence } from \"src/enums\";\nimport {\n Category,\n ObjectId,\n OwnerType,\n PartnerType,\n PosterUsageType,\n RelationDate,\n ResourceContactDetailsType,\n ResourceImageType,\n SocialMediaType,\n Subcategory,\n TermsAgreement,\n} from \"src/types\";\n\nimport { relationDatesSchema } from \"./Relation\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaOwnerType = Omit<OwnerType, \"userId\"> & {\n userId: ObjectId;\n};\n\nconst OwnerTypeSchema = new MongooseSchema<SchemaOwnerType>(\n {\n email: { required: true, type: String },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const SocialMediaTypeSchema = new MongooseSchema<SocialMediaType>(\n {\n link: { required: true, type: String },\n name: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field\n);\n\nexport const ResourceImageTypeSchema = new MongooseSchema<ResourceImageType>(\n {\n source: { required: false, type: String },\n title: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst SubCategorySchema = new MongooseSchema<Subcategory>(\n {\n id: { required: false, type: String },\n items: [\n {\n id: { required: false, type: String },\n name: { required: false, type: String },\n },\n ],\n name: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const CategorySchema = new MongooseSchema<Category>(\n {\n id: { required: true, type: String },\n name: { required: true, type: String },\n subcategories: [SubCategorySchema],\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst PosterUsageTypeSchema = new MongooseSchema<PosterUsageType>(\n {\n count: { default: 0, required: false, type: Number },\n month: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const partnersSchema = new MongooseSchema<PartnerType>(\n {\n email: { required: false, type: String },\n licence: {\n enum: Object.values(EnumUserLicence),\n required: false,\n type: String,\n },\n resourceId: {\n required: false,\n type: String,\n },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: false,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst ContactDetailsSchema = new MongooseSchema<ResourceContactDetailsType>(\n {\n email: { required: false, type: String },\n landlinePhone: { required: false, type: String },\n mobilePhone: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const termsAgreementSchema = new MongooseSchema<TermsAgreement>(\n {\n appBuildNumber: { required: true, type: String },\n appId: { required: true, type: String },\n appVersion: { required: true, type: String },\n brand: { required: true, type: String },\n deviceName: { required: true, type: String },\n installationId: { required: true, type: String },\n manufacturer: { required: true, type: String },\n modelName: { required: true, type: String },\n osName: { required: true, type: String },\n osVersion: { required: true, type: String },\n termVersion: { required: true, type: String },\n timestamp: { required: true, type: String },\n },\n { _id: false },\n);\n\nconst resourceRelationsSchema = new MongooseSchema<{\n relationId: ObjectId;\n relationDates: RelationDate[];\n}>(\n {\n relationDates: {\n default: [],\n required: false,\n type: [relationDatesSchema],\n },\n relationId: {\n ref: \"Relation\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false },\n);\n\nexport const baseResourceFields = {\n active: { default: false, required: true, type: Boolean },\n adIds: {\n ref: \"Ad\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n contactDetails: ContactDetailsSchema,\n cover: ResourceImageTypeSchema,\n deletedAt: { default: null, required: false, type: Date },\n description: { required: true, type: String },\n images: [ResourceImageTypeSchema],\n logo: ResourceImageTypeSchema,\n name: { required: true, type: String },\n owner: OwnerTypeSchema,\n partners: {\n required: false,\n type: [partnersSchema],\n },\n posterUsage: PosterUsageTypeSchema,\n promoCodes: { required: false, type: [String] },\n region: { required: true, type: String },\n relations: {\n default: [],\n required: false,\n type: [resourceRelationsSchema],\n },\n socialMedia: [SocialMediaTypeSchema],\n termsAgreement: termsAgreementSchema,\n};\n","import mongoose from \"mongoose\";\n\nimport {\n EnumInviteStatus,\n EnumRelationResource,\n EnumResourceType,\n} from \"src/enums\";\nimport { ObjectId, RelationDate, RelationType } from \"src/types\";\n\nimport { StallTypeSchema } from \"./event/EventInfo\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport const relationDatesSchema = new MongooseSchema<RelationDate>(\n {\n lastUpdateBy: {\n resourceId: { required: false, type: String },\n userEmail: { required: false, type: String },\n },\n paymentReference: { required: false, type: String },\n stallType: StallTypeSchema,\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n status: {\n enum: Object.values(EnumInviteStatus),\n required: false,\n type: String,\n },\n },\n { _id: false },\n);\n\nexport type SchemaRelationType = Omit<\n RelationType,\n \"chatId\" | \"eventId\" | \"vendorId\"\n> & {\n chatId: ObjectId;\n eventId: ObjectId;\n vendorId: ObjectId;\n};\n/**\n * This is the schema for the relation type.\n * It is used to define the structure of the relation type in the database.\n * The schema is used by Mongoose to create a model for the relation type.\n */\nexport const RelationTypeSchema = new MongooseSchema<SchemaRelationType>(\n {\n active: { default: true, required: true, type: Boolean },\n chatId: {\n ref: \"Chat\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n deletedAt: { default: null, required: false, type: Date },\n eventId: {\n ref: \"Event\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n lastUpdateBy: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n relationDates: [relationDatesSchema],\n relationType: {\n enum: Object.values(EnumRelationResource),\n required: true,\n type: String,\n },\n vendorId: {\n ref: \"Vendor\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nRelationTypeSchema.index({\n \"relationDates.startDate\": 1,\n \"relationDates.startTime\": 1,\n \"relationDates.status\": 1,\n});\n\n// --- IMPORTANT: bind custom model type ---\nexport const RelationModel =\n (mongoose.models.Relation as mongoose.Model<SchemaRelationType>) ||\n mongoose.model<SchemaRelationType>(\"Relation\", RelationTypeSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumPaymentMethod } from \"src/enums\";\nimport {\n DateTimeWithPriceType,\n EventInfoType,\n ObjectId,\n PaymentInfoType,\n Requirement,\n StallType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport const StallTypeSchema = new MongooseSchema<StallType>(\n {\n electricity: {\n price: { required: false, type: Number },\n selected: { required: false, type: Boolean },\n },\n label: { required: false, type: String },\n price: { required: false, type: Number },\n stallCapacity: { required: false, type: Number },\n },\n {\n _id: false, // Prevents Mongoose from creating an additional _id field for subdocuments\n },\n);\n\nconst dateTimeSchema = new MongooseSchema<DateTimeWithPriceType>(\n {\n endDate: { required: true, type: String },\n endTime: { required: true, type: String },\n stallTypes: [StallTypeSchema],\n startDate: { required: true, type: String },\n startTime: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst paymentInfoSchema = new MongooseSchema<PaymentInfoType>(\n {\n accountHolderName: { required: false, type: String },\n accountNumber: { required: false, type: String },\n link: { required: false, type: String },\n paymentMethod: {\n enum: Object.values(EnumPaymentMethod),\n required: true,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field\n);\n\nconst requirementsSchema = new MongooseSchema<Requirement>(\n {\n category: { required: true, type: String },\n label: { required: true, type: String },\n value: { required: true, type: Boolean },\n },\n {\n _id: false, // Prevents Mongoose from creating an additional _id field for\n },\n);\n\nexport type SchemaEventInfoType = Omit<EventInfoType, \"eventId\"> & {\n eventId: ObjectId;\n};\n\n/**\n * This is the schema for the event info type.\n * It is used to define the structure of the event info type in the database.\n * The schema is used by Mongoose to create a model for the event info type.\n */\nconst schema = new MongooseSchema<SchemaEventInfoType>(\n {\n applicationDeadlineHours: { required: true, type: Number },\n dateTime: [dateTimeSchema],\n eventId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n packInTime: { required: true, type: Number },\n paymentDueHours: { required: true, type: Number },\n paymentInfo: [paymentInfoSchema],\n requirements: [requirementsSchema],\n },\n { timestamps: true },\n);\n\nexport const EventInfoModel =\n (mongoose.models.EventInfo as mongoose.Model<SchemaEventInfoType>) ||\n mongoose.model<SchemaEventInfoType>(\"EventInfo\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumChatType } from \"src/enums\";\nimport {\n ChatMessageType,\n ChatType,\n ObjectId,\n ParticipantType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaChatMessageType = Omit<ChatMessageType, \"senderId\"> & {\n senderId: ObjectId;\n};\n\nexport type SchemaParticipantType = Omit<ParticipantType, \"userId\"> & {\n userId: ObjectId;\n};\n\nconst MessageSchema = new MongooseSchema<SchemaChatMessageType>(\n {\n content: { required: true, type: String },\n senderAvatar: { required: false, type: String },\n senderId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n senderName: { required: true, type: String },\n },\n { timestamps: true },\n);\n\nexport type SchemaChatType = Omit<\n ChatType,\n \"participants\" | \"messages\" | \"resourceInfo\"\n> & {\n participants: SchemaParticipantType[];\n messages: SchemaChatMessageType[];\n resourceInfo: { eventId: ObjectId; vendorId: ObjectId } | null;\n};\n\nexport const ParticipantSchema = new MongooseSchema<SchemaParticipantType>(\n {\n active: { default: true, required: true, type: Boolean },\n email: { required: true, type: String },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst ChatSchema = new MongooseSchema<SchemaChatType>(\n {\n active: { default: true, required: true, type: Boolean },\n chatName: { required: true, type: String },\n chatType: {\n enum: Object.values(EnumChatType),\n required: true,\n type: String,\n },\n deletedAt: { default: null, required: false, type: Date },\n messages: [MessageSchema],\n participants: [ParticipantSchema],\n resourceInfo: {\n eventId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n vendorId: {\n ref: \"Vendor\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n },\n {\n timestamps: true,\n },\n);\n\nexport const ChatModel =\n (mongoose.models.Chat as mongoose.Model<SchemaChatType>) ||\n mongoose.model<SchemaChatType>(\"Chat\", ChatSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumResourceType } from \"src/enums\";\nimport {\n EnumActivity,\n ResourceActivityEntry,\n ResourceActivityType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst ActivitySchema = new MongooseSchema<ResourceActivityEntry>(\n {\n activityType: {\n enum: Object.values(EnumActivity),\n required: true,\n type: String,\n },\n location: {\n coordinates: {\n required: false,\n type: [Number],\n },\n type: {\n default: \"Point\",\n enum: [\"Point\"],\n required: false,\n type: String,\n },\n },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n timestamp: { default: Date.now, type: Date },\n userAgent: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n userId: { required: false, type: String },\n },\n { _id: false },\n);\n\nconst schema = new MongooseSchema<ResourceActivityType>(\n {\n activity: { default: [], type: [ActivitySchema] },\n resourceId: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n },\n { timestamps: true },\n);\n\nschema.index({ resourceId: 1, resourceType: 1 }, { unique: true }); // one per entity\nschema.index({ \"views.location\": \"2dsphere\" });\n\nexport const ResourceActivityModel =\n (mongoose.models.ResourceActivity as mongoose.Model<ResourceActivityType>) ||\n mongoose.model<ResourceActivityType>(\"ResourceActivity\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumResourceType } from \"src/enums\";\nimport { TesterType } from \"src/types\";\n\nimport { CategorySchema } from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst TesterSchema = new MongooseSchema<TesterType>(\n {\n active: { default: false, required: true, type: Boolean },\n categories: [CategorySchema],\n companyName: { required: true, type: String },\n email: { required: true, type: String },\n firstName: { required: true, type: String },\n lastName: { required: true, type: String },\n osType: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n region: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n },\n {\n timestamps: true,\n },\n);\n\nexport const TesterModel =\n (mongoose.models.Tester as mongoose.Model<TesterType>) ||\n mongoose.model<TesterType>(\"Tester\", TesterSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumUserLicence, EnumUserRole } from \"src/enums\";\nimport { ObjectId, UserActivityEvent, UserType } from \"src/types\";\n\nimport {\n partnersSchema,\n ResourceImageTypeSchema,\n termsAgreementSchema,\n} from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaUserActivityEvent = Omit<UserActivityEvent, \"resourceId\"> & {\n resourceId: ObjectId;\n};\n\nexport type SchemaUserType = Omit<\n UserType,\n \"vendor\" | \"events\" | \"userActivity\" | \"_id\"\n> & {\n _id: ObjectId;\n vendor: ObjectId;\n events: ObjectId[];\n userActivity: {\n favourites: {\n events: ObjectId[];\n vendors: ObjectId[];\n };\n interested: {\n events: SchemaUserActivityEvent[];\n };\n going: {\n events: SchemaUserActivityEvent[];\n };\n present: {\n events: SchemaUserActivityEvent[];\n };\n };\n};\n\nconst userActivityEventSchema = new MongooseSchema<SchemaUserActivityEvent>(\n {\n resourceId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n },\n { _id: false },\n);\n\nconst userActivityFavouritesSchema = new MongooseSchema(\n {\n events: {\n ref: \"Event\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n vendors: {\n ref: \"Vendor\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n },\n { _id: false },\n);\n\n/**\n * This is the schema for the user type.\n * It is used to define the structure of the user type in the database.\n * The schema is used by Mongoose to create a model for the user type.\n */\nconst schema = new MongooseSchema<SchemaUserType>(\n {\n active: { default: false, required: true, type: Boolean },\n avatar: ResourceImageTypeSchema,\n deletedAt: { default: null, required: false, type: Date },\n email: { required: true, type: String },\n events: {\n ref: \"Event\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n firstName: { required: true, type: String },\n isTester: { default: false, required: false, type: Boolean },\n lastName: { required: true, type: String },\n licences: {\n enum: Object.values(EnumUserLicence),\n required: false,\n type: [String],\n },\n partners: {\n required: false,\n type: [partnersSchema],\n },\n password: { required: true, type: String },\n platform: {\n enum: Object.values(EnumOSPlatform),\n required: false,\n type: String,\n },\n preferredRegion: {\n required: true,\n type: String,\n },\n refreshToken: {\n required: false,\n type: String,\n },\n role: {\n default: EnumUserRole.CUSTOMER,\n enum: Object.values(EnumUserRole),\n required: true,\n type: String,\n },\n termsAgreement: termsAgreementSchema,\n userActivity: {\n favourites: {\n default: () => ({ events: [], vendors: [] }),\n type: userActivityFavouritesSchema,\n },\n going: {\n events: [userActivityEventSchema],\n },\n interested: {\n events: [userActivityEventSchema],\n },\n present: {\n events: [userActivityEventSchema],\n },\n },\n vendor: {\n ref: \"Vendor\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nschema.index({ \"partners.email\": 1 });\n\nexport const UserModel =\n (mongoose.models.User as mongoose.Model<SchemaUserType>) ||\n mongoose.model<SchemaUserType>(\"User\", schema);\n","import mongoose from \"mongoose\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport interface VerificationTokenType {\n email: string;\n verificationToken: string;\n createdAt: Date;\n}\n\nconst schema = new MongooseSchema<VerificationTokenType>(\n {\n createdAt: {\n default: Date.now,\n expires: 24 * 60 * 60, // 24 hours in seconds (MongoDB TTL expects seconds)\n required: true,\n type: Date,\n }, // Token expires after 1 day\n email: { required: true, type: String },\n verificationToken: { required: true, type: String },\n },\n { timestamps: true },\n);\n\nexport const VerificationTokenModel =\n (mongoose.models.VerificationToken as mongoose.Model<VerificationTokenType>) ||\n mongoose.model<VerificationTokenType>(\"VerificationToken\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumVendorType } from \"src/enums\";\nimport { ObjectId, VendorMenuType, VendorType } from \"src/types\";\n\nimport { baseResourceFields, CategorySchema, SchemaOwnerType } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst MenuTypeSchema = new MongooseSchema<VendorMenuType>(\n {\n description: { required: false, type: String },\n name: { required: false, type: String },\n price: { required: false, type: Number },\n productGroups: { required: false, type: [String] },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst LocationsSchema = new MongooseSchema<VendorType[\"locations\"]>(\n {\n dateTime: {\n endDate: { required: false, type: String },\n endTime: { required: false, type: String },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n },\n description: { required: false, type: String },\n location: {\n city: { required: false, type: String },\n coordinates: {\n required: false,\n type: [Number], // [longitude, latitude]\n },\n country: { required: false, type: String },\n fullAddress: { required: false, type: String },\n latitude: { required: false, type: Number },\n longitude: { required: false, type: Number },\n region: { required: false, type: String },\n type: { required: false, type: String }, // Mongoose GeoJSON type\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport type SchemaVendorType = Omit<\n VendorType,\n \"vendorInfoId\" | \"owner\" | \"adIds\"\n> & {\n adIds?: ObjectId[];\n owner: SchemaOwnerType;\n vendorInfoId: ObjectId;\n};\n\nconst schema = new MongooseSchema<SchemaVendorType>(\n {\n ...baseResourceFields, // Importing base resource fields from global.ts\n availability: {\n corporate: { default: false, required: false, type: Boolean },\n private: { default: false, required: false, type: Boolean },\n school: { default: false, required: false, type: Boolean },\n },\n categories: [CategorySchema],\n locations: [LocationsSchema],\n multiLocation: { required: true, type: Boolean },\n products: [MenuTypeSchema],\n vendorInfoId: {\n ref: \"VendorInfo\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n vendorType: {\n enum: Object.values(EnumVendorType),\n required: true,\n type: String,\n },\n },\n { timestamps: true },\n);\n\n// 🔹 Add indexes to speed up regex-based searches\nschema.index({ name: 1 });\nschema.index({ description: 1 });\nschema.index({ region: 1 });\nschema.index({ \"categories.name\": 1 });\nschema.index({ \"partners.email\": 1 });\n\nexport const VendorModel =\n (mongoose.models.Vendor as mongoose.Model<SchemaVendorType>) ||\n mongoose.model<SchemaVendorType>(\"Vendor\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumFoodFlavor } from \"src/enums\";\nimport { ObjectId, VendorAttributes, VendorInfoType } from \"src/types\";\n\nimport { ResourceImageTypeSchema } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaVendorInfoType = Omit<VendorInfoType, \"vendorId\"> & {\n vendorId: ObjectId;\n};\n\nconst AttributesSchema = new MongooseSchema<VendorAttributes>(\n {\n details: { required: false, type: String },\n isRequired: { default: false, required: true, type: Boolean },\n },\n { _id: false },\n);\n\nconst schema = new MongooseSchema<SchemaVendorInfoType>(\n {\n compliance: {\n foodBeverageLicense: { default: false, required: false, type: Boolean },\n liabilityInsurance: { default: false, required: false, type: Boolean },\n },\n documents: [ResourceImageTypeSchema],\n product: {\n foodFlavors: {\n enum: Object.values(EnumFoodFlavor),\n required: true,\n type: [String],\n },\n packaging: { required: true, type: [String] },\n priceRange: {\n max: { required: true, type: Number },\n min: { required: true, type: Number },\n },\n producedIn: { required: true, type: [String] },\n },\n requirements: {\n electricity: AttributesSchema,\n gazebo: AttributesSchema,\n table: AttributesSchema,\n },\n stallInfo: {\n size: {\n depth: { required: true, type: Number },\n width: { required: true, type: Number },\n },\n },\n vendorId: {\n ref: \"Vendor\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nexport const VendorInfoModel =\n (mongoose.models.VendorInfo as mongoose.Model<SchemaVendorInfoType>) ||\n mongoose.model<SchemaVendorInfoType>(\"VendorInfo\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumEventType } from \"src/enums\";\nimport { DateTimeType, EventType, LocationType, ObjectId } from \"src/types\";\n\nimport { baseResourceFields, SchemaOwnerType } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst locationsSchema = new MongooseSchema<LocationType>(\n {\n city: { required: true, type: String },\n coordinates: {\n required: true,\n type: [Number], // [longitude, latitude]\n },\n country: { required: true, type: String },\n fullAddress: { required: true, type: String },\n latitude: { required: true, type: Number },\n longitude: { required: true, type: Number },\n region: { required: true, type: String },\n type: {\n default: \"Point\",\n enum: [\"Point\"],\n required: true,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst dateTimeSchema = new MongooseSchema<DateTimeType>(\n {\n endDate: { required: true, type: String },\n endTime: { required: true, type: String },\n startDate: { required: true, type: String },\n startTime: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport type SchemaEventType = Omit<\n EventType,\n \"eventInfoId\" | \"owner\" | \"adIds\"\n> & {\n adIds?: ObjectId[];\n eventInfoId: ObjectId;\n owner: SchemaOwnerType;\n};\n\n/**\n * This is the schema for the event type.\n * It is used to define the structure of the event type in the database.\n * The schema is used by Mongoose to create a model for the event type.\n */\nconst schema = new MongooseSchema<SchemaEventType>(\n {\n ...baseResourceFields, // Importing base resource fields from global.ts\n dateTime: [dateTimeSchema],\n eventInfoId: {\n ref: \"EventInfo\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n eventType: {\n enum: Object.values(EnumEventType),\n required: true,\n type: String,\n },\n location: {\n required: true,\n type: locationsSchema,\n },\n nzbn: { required: true, type: String },\n provider: { required: false, type: String },\n rainOrShine: { required: true, type: Boolean },\n tags: { required: true, type: [String] },\n },\n { timestamps: true },\n);\n\n// 🔹 Add indexes to speed up regex-based searches\nschema.index({ name: 1 });\nschema.index({ description: 1 });\nschema.index({ region: 1 });\nschema.index({ location: \"2dsphere\" });\nschema.index({ tags: 1 });\nschema.index({ \"partners.email\": 1 });\n\nexport const EventModel =\n (mongoose.models.Event as mongoose.Model<SchemaEventType>) ||\n mongoose.model<SchemaEventType>(\"Event\", schema);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,eAAc;;;ACArB,OAAOC,eAAc;;;ACArB,OAAOC,eAAc;;;ACArB,OAAO,cAAc;AAYrB,IAAM,iBAAiB,SAAS;AAEzB,IAAM,kBAAkB,IAAI;AAAA,EACjC;AAAA,IACE,aAAa;AAAA,MACX,OAAO,EAAE,UAAU,OAAO,MAAM,OAAO;AAAA,MACvC,UAAU,EAAE,UAAU,OAAO,MAAM,QAAQ;AAAA,IAC7C;AAAA,IACA,OAAO,EAAE,UAAU,OAAO,MAAM,OAAO;AAAA,IACvC,OAAO,EAAE,UAAU,OAAO,MAAM,OAAO;AAAA,IACvC,eAAe,EAAE,UAAU,OAAO,MAAM,OAAO;AAAA,EACjD;AAAA,EACA;AAAA,IACE,KAAK;AAAA;AAAA,EACP;AACF;AAEA,IAAM,iBAAiB,IAAI;AAAA,EACzB;AAAA,IACE,SAAS,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACxC,SAAS,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACxC,YAAY,CAAC,eAAe;AAAA,IAC5B,WAAW,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IAC1C,WAAW,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,EAC5C;AAAA,EACA,EAAE,KAAK,MAAM;AAAA;AACf;AAEA,IAAM,oBAAoB,IAAI;AAAA,EAC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,MACT,MAAM,OAAO,OAAO,aAAa;AAAA,MACjC,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,MAAM,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACrC,UAAU,EAAE,UAAU,OAAO,MAAM,OAAO;AAAA,IAC1C,aAAa,EAAE,UAAU,MAAM,MAAM,QAAQ;AAAA,IAC7C,MAAM,EAAE,UAAU,MAAM,MAAM,CAAC,MAAM,EAAE;AAAA,EACzC;AAAA,EACA,EAAE,YAAY,KAAK;AACrB;AAGAE,QAAO,MAAM,EAAE,MAAM,EAAE,CAAC;AACxBA,QAAO,MAAM,EAAE,aAAa,EAAE,CAAC;AAC/BA,QAAO,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC1BA,QAAO,MAAM,EAAE,UAAU,WAAW,CAAC;AACrCA,QAAO,MAAM,EAAE,MAAM,EAAE,CAAC;AACxBA,QAAO,MAAM,EAAE,kBAAkB,EAAE,CAAC;AAE7B,IAAM,aACVF,WAAS,OAAO,SACjBA,WAAS,MAAuB,SAASE,OAAM;","names":["mongoose","mongoose","mongoose","MongooseSchema","mongoose","MongooseSchema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","schema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","dateTimeSchema","schema"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mongoose/Ad.ts","../../src/mongoose/global.ts","../../src/mongoose/Relation.ts","../../src/mongoose/event/EventInfo.ts","../../src/mongoose/Chat.ts","../../src/mongoose/ResourceActivity.ts","../../src/mongoose/Testers.ts","../../src/mongoose/User.ts","../../src/mongoose/VerificationToken.ts","../../src/mongoose/vendor/Vendor.ts","../../src/mongoose/vendor/VendorInfo.ts","../../src/mongoose/event/Event.ts"],"sourcesContent":["import mongoose from \"mongoose\";\n\nimport { EnumResourceType } from \"src/enums\";\nimport {\n AdType,\n EnumAdShowOn,\n EnumAdStatus,\n EnumAdStyle,\n EnumAdType,\n} from \"src/types\";\n\nimport { SocialMediaTypeSchema } from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst schema = new MongooseSchema<AdType>(\n {\n active: { default: true, type: Boolean },\n adStyle: {\n default: EnumAdStyle.BLOOM,\n enum: Object.values(EnumAdStyle),\n required: true,\n type: String,\n },\n adType: {\n default: EnumAdType.SPONSORED,\n enum: Object.values(EnumAdType),\n required: true,\n type: String,\n },\n // TODO: similar to ViewSchema\n clicks: { default: 0, required: true, type: Number },\n clui: { required: false, type: String },\n end: { required: true, type: Date },\n // TODO: similar to ViewSchema\n impressions: { default: 0, required: true, type: Number },\n resourceCover: { required: true, type: String },\n resourceDescription: { required: true, type: String },\n resourceId: { required: true, type: String },\n resourceLogo: { required: false, type: String },\n resourceName: { required: true, type: String },\n resourceRegion: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n showOn: {\n default: EnumAdShowOn.FRONT_PAGE,\n enum: Object.values(EnumAdShowOn),\n required: true,\n type: String,\n },\n socialMedia: [SocialMediaTypeSchema],\n start: { required: true, type: Date },\n status: {\n default: EnumAdStatus.ACTIVE,\n enum: Object.values(EnumAdStatus),\n required: true,\n type: String,\n },\n targetRegion: { required: false, type: String },\n },\n {\n timestamps: true,\n },\n);\n\n// Compound index for background job queries\nschema.index({\n end: 1,\n start: 1,\n status: 1,\n});\n\nexport const AdModel =\n (mongoose.models.Ad as mongoose.Model<AdType>) ||\n mongoose.model<AdType>(\"Ad\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumResourceType, EnumUserLicence } from \"src/enums\";\nimport {\n Category,\n ObjectId,\n OwnerType,\n PartnerType,\n PosterUsageType,\n RelationDate,\n ResourceContactDetailsType,\n ResourceImageType,\n SocialMediaType,\n Subcategory,\n TermsAgreement,\n} from \"src/types\";\n\nimport { relationDatesSchema } from \"./Relation\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaOwnerType = Omit<OwnerType, \"userId\"> & {\n userId: ObjectId;\n};\n\nconst OwnerTypeSchema = new MongooseSchema<SchemaOwnerType>(\n {\n email: { required: true, type: String },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const SocialMediaTypeSchema = new MongooseSchema<SocialMediaType>(\n {\n link: { required: true, type: String },\n name: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field\n);\n\nexport const ResourceImageTypeSchema = new MongooseSchema<ResourceImageType>(\n {\n source: { required: false, type: String },\n title: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst SubCategorySchema = new MongooseSchema<Subcategory>(\n {\n id: { required: false, type: String },\n items: [\n {\n id: { required: false, type: String },\n name: { required: false, type: String },\n },\n ],\n name: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const CategorySchema = new MongooseSchema<Category>(\n {\n id: { required: true, type: String },\n name: { required: true, type: String },\n subcategories: [SubCategorySchema],\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst PosterUsageTypeSchema = new MongooseSchema<PosterUsageType>(\n {\n count: { default: 0, required: false, type: Number },\n month: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const partnersSchema = new MongooseSchema<PartnerType>(\n {\n email: { required: false, type: String },\n licence: {\n enum: Object.values(EnumUserLicence),\n required: false,\n type: String,\n },\n resourceId: {\n required: false,\n type: String,\n },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: false,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst ContactDetailsSchema = new MongooseSchema<ResourceContactDetailsType>(\n {\n email: { required: false, type: String },\n landlinePhone: { required: false, type: String },\n mobilePhone: { required: false, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport const termsAgreementSchema = new MongooseSchema<TermsAgreement>(\n {\n appBuildNumber: { required: true, type: String },\n appId: { required: true, type: String },\n appVersion: { required: true, type: String },\n brand: { required: true, type: String },\n deviceName: { required: true, type: String },\n installationId: { required: true, type: String },\n manufacturer: { required: true, type: String },\n modelName: { required: true, type: String },\n osName: { required: true, type: String },\n osVersion: { required: true, type: String },\n termVersion: { required: true, type: String },\n timestamp: { required: true, type: String },\n },\n { _id: false },\n);\n\nconst resourceRelationsSchema = new MongooseSchema<{\n relationId: ObjectId;\n relationDates: RelationDate[];\n}>(\n {\n relationDates: {\n default: [],\n required: false,\n type: [relationDatesSchema],\n },\n relationId: {\n ref: \"Relation\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false },\n);\n\nexport const baseResourceFields = {\n active: { default: false, required: true, type: Boolean },\n adIds: {\n ref: \"Ad\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n contactDetails: ContactDetailsSchema,\n cover: ResourceImageTypeSchema,\n deletedAt: { default: null, required: false, type: Date },\n description: { required: true, type: String },\n images: [ResourceImageTypeSchema],\n logo: ResourceImageTypeSchema,\n name: { required: true, type: String },\n owner: OwnerTypeSchema,\n partners: {\n required: false,\n type: [partnersSchema],\n },\n posterUsage: PosterUsageTypeSchema,\n promoCodes: { required: false, type: [String] },\n region: { required: true, type: String },\n relations: {\n default: [],\n required: false,\n type: [resourceRelationsSchema],\n },\n socialMedia: [SocialMediaTypeSchema],\n termsAgreement: termsAgreementSchema,\n};\n","import mongoose from \"mongoose\";\n\nimport {\n EnumInviteStatus,\n EnumRelationResource,\n EnumResourceType,\n} from \"src/enums\";\nimport { ObjectId, RelationDate, RelationType } from \"src/types\";\n\nimport { StallTypeSchema } from \"./event/EventInfo\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport const relationDatesSchema = new MongooseSchema<RelationDate>(\n {\n lastUpdateBy: {\n resourceId: { required: false, type: String },\n userEmail: { required: false, type: String },\n },\n paymentReference: { required: false, type: String },\n stallType: StallTypeSchema,\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n status: {\n enum: Object.values(EnumInviteStatus),\n required: false,\n type: String,\n },\n },\n { _id: false },\n);\n\nexport type SchemaRelationType = Omit<\n RelationType,\n \"chatId\" | \"eventId\" | \"vendorId\"\n> & {\n chatId: ObjectId;\n eventId: ObjectId;\n vendorId: ObjectId;\n};\n/**\n * This is the schema for the relation type.\n * It is used to define the structure of the relation type in the database.\n * The schema is used by Mongoose to create a model for the relation type.\n */\nexport const RelationTypeSchema = new MongooseSchema<SchemaRelationType>(\n {\n active: { default: true, required: true, type: Boolean },\n chatId: {\n ref: \"Chat\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n deletedAt: { default: null, required: false, type: Date },\n eventId: {\n ref: \"Event\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n lastUpdateBy: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n relationDates: [relationDatesSchema],\n relationType: {\n enum: Object.values(EnumRelationResource),\n required: true,\n type: String,\n },\n vendorId: {\n ref: \"Vendor\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nRelationTypeSchema.index({\n \"relationDates.startDate\": 1,\n \"relationDates.startTime\": 1,\n \"relationDates.status\": 1,\n});\n\n// --- IMPORTANT: bind custom model type ---\nexport const RelationModel =\n (mongoose.models.Relation as mongoose.Model<SchemaRelationType>) ||\n mongoose.model<SchemaRelationType>(\"Relation\", RelationTypeSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumPaymentMethod } from \"src/enums\";\nimport {\n DateTimeWithPriceType,\n EventInfoType,\n ObjectId,\n PaymentInfoType,\n Requirement,\n StallType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport const StallTypeSchema = new MongooseSchema<StallType>(\n {\n electricity: {\n price: { required: false, type: Number },\n selected: { required: false, type: Boolean },\n },\n label: { required: false, type: String },\n price: { required: false, type: Number },\n stallCapacity: { required: false, type: Number },\n },\n {\n _id: false, // Prevents Mongoose from creating an additional _id field for subdocuments\n },\n);\n\nconst dateTimeSchema = new MongooseSchema<DateTimeWithPriceType>(\n {\n endDate: { required: true, type: String },\n endTime: { required: true, type: String },\n stallTypes: [StallTypeSchema],\n startDate: { required: true, type: String },\n startTime: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst paymentInfoSchema = new MongooseSchema<PaymentInfoType>(\n {\n accountHolderName: { required: false, type: String },\n accountNumber: { required: false, type: String },\n link: { required: false, type: String },\n paymentMethod: {\n enum: Object.values(EnumPaymentMethod),\n required: true,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field\n);\n\nconst requirementsSchema = new MongooseSchema<Requirement>(\n {\n category: { required: true, type: String },\n label: { required: true, type: String },\n value: { required: true, type: Boolean },\n },\n {\n _id: false, // Prevents Mongoose from creating an additional _id field for\n },\n);\n\nexport type SchemaEventInfoType = Omit<EventInfoType, \"eventId\"> & {\n eventId: ObjectId;\n};\n\n/**\n * This is the schema for the event info type.\n * It is used to define the structure of the event info type in the database.\n * The schema is used by Mongoose to create a model for the event info type.\n */\nconst schema = new MongooseSchema<SchemaEventInfoType>(\n {\n applicationDeadlineHours: { required: true, type: Number },\n dateTime: [dateTimeSchema],\n eventId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n packInTime: { required: true, type: Number },\n paymentDueHours: { required: true, type: Number },\n paymentInfo: [paymentInfoSchema],\n requirements: [requirementsSchema],\n },\n { timestamps: true },\n);\n\nexport const EventInfoModel =\n (mongoose.models.EventInfo as mongoose.Model<SchemaEventInfoType>) ||\n mongoose.model<SchemaEventInfoType>(\"EventInfo\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumChatType } from \"src/enums\";\nimport {\n ChatMessageType,\n ChatType,\n ObjectId,\n ParticipantType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaChatMessageType = Omit<ChatMessageType, \"senderId\"> & {\n senderId: ObjectId;\n};\n\nexport type SchemaParticipantType = Omit<ParticipantType, \"userId\"> & {\n userId: ObjectId;\n};\n\nconst MessageSchema = new MongooseSchema<SchemaChatMessageType>(\n {\n content: { required: true, type: String },\n senderAvatar: { required: false, type: String },\n senderId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n senderName: { required: true, type: String },\n },\n { timestamps: true },\n);\n\nexport type SchemaChatType = Omit<\n ChatType,\n \"participants\" | \"messages\" | \"resourceInfo\"\n> & {\n participants: SchemaParticipantType[];\n messages: SchemaChatMessageType[];\n resourceInfo: { eventId: ObjectId; vendorId: ObjectId } | null;\n};\n\nexport const ParticipantSchema = new MongooseSchema<SchemaParticipantType>(\n {\n active: { default: true, required: true, type: Boolean },\n email: { required: true, type: String },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst ChatSchema = new MongooseSchema<SchemaChatType>(\n {\n active: { default: true, required: true, type: Boolean },\n chatName: { required: true, type: String },\n chatType: {\n enum: Object.values(EnumChatType),\n required: true,\n type: String,\n },\n deletedAt: { default: null, required: false, type: Date },\n messages: [MessageSchema],\n participants: [ParticipantSchema],\n resourceInfo: {\n eventId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n vendorId: {\n ref: \"Vendor\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n },\n {\n timestamps: true,\n },\n);\n\nexport const ChatModel =\n (mongoose.models.Chat as mongoose.Model<SchemaChatType>) ||\n mongoose.model<SchemaChatType>(\"Chat\", ChatSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumResourceType } from \"src/enums\";\nimport {\n EnumActivity,\n ResourceActivityEntry,\n ResourceActivityType,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst ActivitySchema = new MongooseSchema<ResourceActivityEntry>(\n {\n activityType: {\n enum: Object.values(EnumActivity),\n required: true,\n type: String,\n },\n location: {\n coordinates: {\n required: false,\n type: [Number],\n },\n type: {\n default: \"Point\",\n enum: [\"Point\"],\n required: false,\n type: String,\n },\n },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n timestamp: { default: Date.now, type: Date },\n userAgent: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n userId: { required: false, type: String },\n },\n { _id: false },\n);\n\nconst schema = new MongooseSchema<ResourceActivityType>(\n {\n activity: { default: [], type: [ActivitySchema] },\n resourceId: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n },\n { timestamps: true },\n);\n\nschema.index({ resourceId: 1, resourceType: 1 }, { unique: true }); // one per entity\nschema.index({ \"views.location\": \"2dsphere\" });\n\nexport const ResourceActivityModel =\n (mongoose.models.ResourceActivity as mongoose.Model<ResourceActivityType>) ||\n mongoose.model<ResourceActivityType>(\"ResourceActivity\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumResourceType } from \"src/enums\";\nimport { TesterType } from \"src/types\";\n\nimport { CategorySchema } from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst TesterSchema = new MongooseSchema<TesterType>(\n {\n active: { default: false, required: true, type: Boolean },\n categories: [CategorySchema],\n companyName: { required: true, type: String },\n email: { required: true, type: String },\n firstName: { required: true, type: String },\n lastName: { required: true, type: String },\n osType: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n region: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumResourceType),\n required: true,\n type: String,\n },\n },\n {\n timestamps: true,\n },\n);\n\nexport const TesterModel =\n (mongoose.models.Tester as mongoose.Model<TesterType>) ||\n mongoose.model<TesterType>(\"Tester\", TesterSchema);\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform, EnumUserLicence, EnumUserRole } from \"src/enums\";\nimport { ObjectId, UserActivityEvent, UserType } from \"src/types\";\n\nimport {\n partnersSchema,\n ResourceImageTypeSchema,\n termsAgreementSchema,\n} from \"./global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaUserActivityEvent = Omit<UserActivityEvent, \"resourceId\"> & {\n resourceId: ObjectId;\n};\n\nexport type SchemaUserType = Omit<\n UserType,\n \"vendor\" | \"events\" | \"userActivity\" | \"_id\"\n> & {\n _id: ObjectId;\n vendor: ObjectId;\n events: ObjectId[];\n userActivity: {\n favourites: {\n events: ObjectId[];\n vendors: ObjectId[];\n };\n interested: {\n events: SchemaUserActivityEvent[];\n };\n going: {\n events: SchemaUserActivityEvent[];\n };\n present: {\n events: SchemaUserActivityEvent[];\n };\n };\n};\n\nconst userActivityEventSchema = new MongooseSchema<SchemaUserActivityEvent>(\n {\n resourceId: {\n ref: \"Event\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n },\n { _id: false },\n);\n\nconst userActivityFavouritesSchema = new MongooseSchema(\n {\n events: {\n ref: \"Event\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n vendors: {\n ref: \"Vendor\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n },\n { _id: false },\n);\n\n/**\n * This is the schema for the user type.\n * It is used to define the structure of the user type in the database.\n * The schema is used by Mongoose to create a model for the user type.\n */\nconst schema = new MongooseSchema<SchemaUserType>(\n {\n active: { default: false, required: true, type: Boolean },\n avatar: ResourceImageTypeSchema,\n deletedAt: { default: null, required: false, type: Date },\n email: { required: true, type: String },\n events: {\n ref: \"Event\",\n required: false,\n type: [mongoose.Schema.Types.ObjectId],\n },\n firstName: { required: true, type: String },\n isTester: { default: false, required: false, type: Boolean },\n lastName: { required: true, type: String },\n licences: {\n enum: Object.values(EnumUserLicence),\n required: false,\n type: [String],\n },\n partners: {\n required: false,\n type: [partnersSchema],\n },\n password: { required: true, type: String },\n platform: {\n enum: Object.values(EnumOSPlatform),\n required: false,\n type: String,\n },\n preferredRegion: {\n required: true,\n type: String,\n },\n refreshToken: {\n required: false,\n type: String,\n },\n role: {\n default: EnumUserRole.CUSTOMER,\n enum: Object.values(EnumUserRole),\n required: true,\n type: String,\n },\n termsAgreement: termsAgreementSchema,\n userActivity: {\n favourites: {\n default: () => ({ events: [], vendors: [] }),\n type: userActivityFavouritesSchema,\n },\n going: {\n events: [userActivityEventSchema],\n },\n interested: {\n events: [userActivityEventSchema],\n },\n present: {\n events: [userActivityEventSchema],\n },\n },\n vendor: {\n ref: \"Vendor\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nschema.index({ \"partners.email\": 1 });\n\nexport const UserModel =\n (mongoose.models.User as mongoose.Model<SchemaUserType>) ||\n mongoose.model<SchemaUserType>(\"User\", schema);\n","import mongoose from \"mongoose\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport interface VerificationTokenType {\n email: string;\n verificationToken: string;\n createdAt: Date;\n}\n\nconst schema = new MongooseSchema<VerificationTokenType>(\n {\n createdAt: {\n default: Date.now,\n expires: 24 * 60 * 60, // 24 hours in seconds (MongoDB TTL expects seconds)\n required: true,\n type: Date,\n }, // Token expires after 1 day\n email: { required: true, type: String },\n verificationToken: { required: true, type: String },\n },\n { timestamps: true },\n);\n\nexport const VerificationTokenModel =\n (mongoose.models\n .VerificationToken as mongoose.Model<VerificationTokenType>) ||\n mongoose.model<VerificationTokenType>(\"VerificationToken\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumVendorType } from \"src/enums\";\nimport { ObjectId, VendorMenuType, VendorType } from \"src/types\";\n\nimport { baseResourceFields, CategorySchema, SchemaOwnerType } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst MenuTypeSchema = new MongooseSchema<VendorMenuType>(\n {\n description: { required: false, type: String },\n name: { required: false, type: String },\n price: { required: false, type: Number },\n productGroups: { required: false, type: [String] },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst LocationsSchema = new MongooseSchema<VendorType[\"locations\"]>(\n {\n dateTime: {\n endDate: { required: false, type: String },\n endTime: { required: false, type: String },\n startDate: { required: false, type: String },\n startTime: { required: false, type: String },\n },\n description: { required: false, type: String },\n location: {\n city: { required: false, type: String },\n coordinates: {\n required: false,\n type: [Number], // [longitude, latitude]\n },\n country: { required: false, type: String },\n fullAddress: { required: false, type: String },\n latitude: { required: false, type: Number },\n longitude: { required: false, type: Number },\n region: { required: false, type: String },\n type: { required: false, type: String }, // Mongoose GeoJSON type\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport type SchemaVendorType = Omit<\n VendorType,\n \"vendorInfoId\" | \"owner\" | \"adIds\"\n> & {\n adIds?: ObjectId[];\n owner: SchemaOwnerType;\n vendorInfoId: ObjectId;\n};\n\nconst schema = new MongooseSchema<SchemaVendorType>(\n {\n ...baseResourceFields, // Importing base resource fields from global.ts\n availability: {\n corporate: { default: false, required: false, type: Boolean },\n private: { default: false, required: false, type: Boolean },\n school: { default: false, required: false, type: Boolean },\n },\n categories: [CategorySchema],\n locations: [LocationsSchema],\n multiLocation: { required: true, type: Boolean },\n products: [MenuTypeSchema],\n vendorInfoId: {\n ref: \"VendorInfo\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n vendorType: {\n enum: Object.values(EnumVendorType),\n required: true,\n type: String,\n },\n },\n { timestamps: true },\n);\n\n// 🔹 Add indexes to speed up regex-based searches\nschema.index({ name: 1 });\nschema.index({ description: 1 });\nschema.index({ region: 1 });\nschema.index({ \"categories.name\": 1 });\nschema.index({ \"partners.email\": 1 });\n\nexport const VendorModel =\n (mongoose.models.Vendor as mongoose.Model<SchemaVendorType>) ||\n mongoose.model<SchemaVendorType>(\"Vendor\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumFoodFlavor } from \"src/enums\";\nimport { ObjectId, VendorAttributes, VendorInfoType } from \"src/types\";\n\nimport { ResourceImageTypeSchema } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaVendorInfoType = Omit<VendorInfoType, \"vendorId\"> & {\n vendorId: ObjectId;\n};\n\nconst AttributesSchema = new MongooseSchema<VendorAttributes>(\n {\n details: { required: false, type: String },\n isRequired: { default: false, required: true, type: Boolean },\n },\n { _id: false },\n);\n\nconst schema = new MongooseSchema<SchemaVendorInfoType>(\n {\n compliance: {\n foodBeverageLicense: { default: false, required: false, type: Boolean },\n liabilityInsurance: { default: false, required: false, type: Boolean },\n },\n documents: [ResourceImageTypeSchema],\n product: {\n foodFlavors: {\n enum: Object.values(EnumFoodFlavor),\n required: true,\n type: [String],\n },\n packaging: { required: true, type: [String] },\n priceRange: {\n max: { required: true, type: Number },\n min: { required: true, type: Number },\n },\n producedIn: { required: true, type: [String] },\n },\n requirements: {\n electricity: AttributesSchema,\n gazebo: AttributesSchema,\n table: AttributesSchema,\n },\n stallInfo: {\n size: {\n depth: { required: true, type: Number },\n width: { required: true, type: Number },\n },\n },\n vendorId: {\n ref: \"Vendor\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\nexport const VendorInfoModel =\n (mongoose.models.VendorInfo as mongoose.Model<SchemaVendorInfoType>) ||\n mongoose.model<SchemaVendorInfoType>(\"VendorInfo\", schema);\n","import mongoose from \"mongoose\";\n\nimport { EnumEventType } from \"src/enums\";\nimport { DateTimeType, EventType, LocationType, ObjectId } from \"src/types\";\n\nimport { baseResourceFields, SchemaOwnerType } from \"../global\";\n\nconst MongooseSchema = mongoose.Schema;\n\nconst locationsSchema = new MongooseSchema<LocationType>(\n {\n city: { required: true, type: String },\n coordinates: {\n required: true,\n type: [Number], // [longitude, latitude]\n },\n country: { required: true, type: String },\n fullAddress: { required: true, type: String },\n latitude: { required: true, type: Number },\n longitude: { required: true, type: Number },\n region: { required: true, type: String },\n type: {\n default: \"Point\",\n enum: [\"Point\"],\n required: true,\n type: String,\n },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nconst dateTimeSchema = new MongooseSchema<DateTimeType>(\n {\n endDate: { required: true, type: String },\n endTime: { required: true, type: String },\n startDate: { required: true, type: String },\n startTime: { required: true, type: String },\n },\n { _id: false }, // Prevents Mongoose from creating an additional _id field for subdocuments\n);\n\nexport type SchemaEventType = Omit<\n EventType,\n \"eventInfoId\" | \"owner\" | \"adIds\"\n> & {\n adIds?: ObjectId[];\n eventInfoId: ObjectId;\n owner: SchemaOwnerType;\n};\n\n/**\n * This is the schema for the event type.\n * It is used to define the structure of the event type in the database.\n * The schema is used by Mongoose to create a model for the event type.\n */\nconst schema = new MongooseSchema<SchemaEventType>(\n {\n ...baseResourceFields, // Importing base resource fields from global.ts\n dateTime: [dateTimeSchema],\n eventInfoId: {\n ref: \"EventInfo\",\n required: false,\n type: mongoose.Schema.Types.ObjectId,\n },\n eventType: {\n enum: Object.values(EnumEventType),\n required: true,\n type: String,\n },\n location: {\n required: true,\n type: locationsSchema,\n },\n nzbn: { required: true, type: String },\n provider: { required: false, type: String },\n rainOrShine: { required: true, type: Boolean },\n tags: { required: true, type: [String] },\n },\n { timestamps: true },\n);\n\n// 🔹 Add indexes to speed up regex-based searches\nschema.index({ name: 1 });\nschema.index({ description: 1 });\nschema.index({ region: 1 });\nschema.index({ location: \"2dsphere\" });\nschema.index({ tags: 1 });\nschema.index({ \"partners.email\": 1 });\n\nexport const EventModel =\n (mongoose.models.Event as mongoose.Model<SchemaEventType>) ||\n mongoose.model<SchemaEventType>(\"Event\", schema);\n"],"mappings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EAAE,YAAY,KAAK;AACrB;AAGAE,QAAO,MAAM,EAAE,MAAM,EAAE,CAAC;AACxBA,QAAO,MAAM,EAAE,aAAa,EAAE,CAAC;AAC/BA,QAAO,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC1BA,QAAO,MAAM,EAAE,UAAU,WAAW,CAAC;AACrCA,QAAO,MAAM,EAAE,MAAM,EAAE,CAAC;AACxBA,QAAO,MAAM,EAAE,kBAAkB,EAAE,CAAC;AAE7B,IAAM,aACVF,WAAS,OAAO,SACjBA,WAAS,MAAuB,SAASE,OAAM;","names":["mongoose","mongoose","mongoose","MongooseSchema","mongoose","MongooseSchema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","schema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","schema","mongoose","MongooseSchema","mongoose","dateTimeSchema","schema"]}
|
package/dist/service/index.cjs
CHANGED
|
@@ -31,9 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var service_exports = {};
|
|
32
32
|
__export(service_exports, {
|
|
33
33
|
connectToDatabase: () => connectToDatabase,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sendPushNotification: () => sendPushNotification
|
|
34
|
+
saveNotificationsInDb: () => saveNotificationsInDb,
|
|
35
|
+
sendPushNotifications: () => sendPushNotifications
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(service_exports);
|
|
39
38
|
|
|
@@ -150,35 +149,8 @@ schema.index({ isRead: 1, userId: 1 });
|
|
|
150
149
|
schema.index({ createdAt: -1, userId: 1 });
|
|
151
150
|
var NotificationModel = import_mongoose2.default.models.Notification || import_mongoose2.default.model("Notification", schema);
|
|
152
151
|
|
|
153
|
-
// src/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// src/service/notificationService.ts
|
|
157
|
-
async function publishNotificationEvents(userId, context) {
|
|
158
|
-
try {
|
|
159
|
-
const userNotifications = await NotificationModel.find({
|
|
160
|
-
userId
|
|
161
|
-
}).sort({ createdAt: -1 });
|
|
162
|
-
const [total, unread] = await Promise.all([
|
|
163
|
-
NotificationModel.countDocuments({ userId }),
|
|
164
|
-
NotificationModel.countDocuments({ isRead: false, userId })
|
|
165
|
-
]);
|
|
166
|
-
context.pubsub.publish("GET_NOTIFICATIONS" /* GET_NOTIFICATIONS */, {
|
|
167
|
-
getNotifications: userNotifications,
|
|
168
|
-
getNotificationsUserId: userId
|
|
169
|
-
});
|
|
170
|
-
context.pubsub.publish("GET_NOTIFICATIONS_COUNT" /* GET_NOTIFICATIONS_COUNT */, {
|
|
171
|
-
getNotificationsCount: { total, unread, userId }
|
|
172
|
-
});
|
|
173
|
-
console.log(`Published notification events for user: ${String(userId)}`);
|
|
174
|
-
} catch (error) {
|
|
175
|
-
console.error(
|
|
176
|
-
`Failed to publish notification events for user ${String(userId)}:`,
|
|
177
|
-
error
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
async function createNotifications(payload, context) {
|
|
152
|
+
// src/service/saveNotificationsInDb.ts
|
|
153
|
+
async function saveNotificationsInDb(payload) {
|
|
182
154
|
const { data, message, title, type, userIds } = payload;
|
|
183
155
|
try {
|
|
184
156
|
const notifications = userIds.map((userId) => ({
|
|
@@ -189,27 +161,23 @@ async function createNotifications(payload, context) {
|
|
|
189
161
|
type,
|
|
190
162
|
userId
|
|
191
163
|
}));
|
|
192
|
-
|
|
164
|
+
await NotificationModel.insertMany(notifications);
|
|
193
165
|
console.log(
|
|
194
|
-
`Created ${
|
|
166
|
+
`Created ${notifications.length} notifications for ${userIds.length} users`
|
|
195
167
|
);
|
|
196
|
-
|
|
197
|
-
for (const userId of uniqueUserIds) {
|
|
198
|
-
await publishNotificationEvents(userId, context);
|
|
199
|
-
}
|
|
200
|
-
return savedNotifications;
|
|
168
|
+
return [...new Set(userIds)];
|
|
201
169
|
} catch (error) {
|
|
202
170
|
console.error("Failed to create notifications:", error);
|
|
203
171
|
return [];
|
|
204
172
|
}
|
|
205
173
|
}
|
|
206
174
|
|
|
207
|
-
// src/service/
|
|
175
|
+
// src/service/sendPushNotifications.ts
|
|
208
176
|
var import_expo_server_sdk = require("expo-server-sdk");
|
|
209
177
|
|
|
210
178
|
// src/mongoose/PushToken.ts
|
|
211
|
-
var
|
|
212
|
-
var MongooseSchema2 =
|
|
179
|
+
var import_mongoose3 = __toESM(require("mongoose"));
|
|
180
|
+
var MongooseSchema2 = import_mongoose3.default.Schema;
|
|
213
181
|
var schema2 = new MongooseSchema2(
|
|
214
182
|
{
|
|
215
183
|
platform: {
|
|
@@ -218,13 +186,13 @@ var schema2 = new MongooseSchema2(
|
|
|
218
186
|
type: String
|
|
219
187
|
},
|
|
220
188
|
token: { required: true, type: String },
|
|
221
|
-
userId: { required: true, type:
|
|
189
|
+
userId: { required: true, type: import_mongoose3.default.Schema.Types.ObjectId }
|
|
222
190
|
},
|
|
223
191
|
{ timestamps: true }
|
|
224
192
|
);
|
|
225
|
-
var PushTokenModel =
|
|
193
|
+
var PushTokenModel = import_mongoose3.default.models.PushToken || import_mongoose3.default.model("PushToken", schema2);
|
|
226
194
|
|
|
227
|
-
// src/service/
|
|
195
|
+
// src/service/sendPushNotifications.ts
|
|
228
196
|
var expo = new import_expo_server_sdk.Expo();
|
|
229
197
|
function extractTokensFromMessage(message) {
|
|
230
198
|
return Array.isArray(message.to) ? message.to : [message.to];
|
|
@@ -291,7 +259,7 @@ async function sendChunk(chunk, chunkIndex) {
|
|
|
291
259
|
return { failedTokens: [], successCount: 0 };
|
|
292
260
|
}
|
|
293
261
|
}
|
|
294
|
-
async function
|
|
262
|
+
async function sendPushNotifications({
|
|
295
263
|
data,
|
|
296
264
|
message,
|
|
297
265
|
title,
|
|
@@ -299,6 +267,7 @@ async function sendPushNotification({
|
|
|
299
267
|
}) {
|
|
300
268
|
const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });
|
|
301
269
|
const expoTokens = pushTokens.map((token) => token.token);
|
|
270
|
+
if (!data) return;
|
|
302
271
|
const { messages, invalidTokens } = createPushMessages({
|
|
303
272
|
data,
|
|
304
273
|
message,
|
|
@@ -333,8 +302,7 @@ async function sendPushNotification({
|
|
|
333
302
|
// Annotate the CommonJS export names for ESM import in node:
|
|
334
303
|
0 && (module.exports = {
|
|
335
304
|
connectToDatabase,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
sendPushNotification
|
|
305
|
+
saveNotificationsInDb,
|
|
306
|
+
sendPushNotifications
|
|
339
307
|
});
|
|
340
308
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/service/index.ts","../../src/service/database.ts","../../src/service/timezonePlugin.ts","../../src/mongoose/Notification.ts","../../src/enums/index.ts","../../src/types/global.ts","../../src/service/notificationService.ts","../../src/service/sendPushNotification.ts","../../src/mongoose/PushToken.ts"],"sourcesContent":["export * from \"./database\";\nexport * from \"./notificationService\";\nexport * from \"./sendPushNotification\";\n","import mongoose from \"mongoose\";\n\nimport { timezonePlugin } from \"./timezonePlugin\";\n\nmongoose.plugin(timezonePlugin); // applies to all schemas\n\n/**\n * Connect to MongoDB using Mongoose.\n * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).\n */\nexport const connectToDatabase = async ({\n appName,\n dbName,\n dbPassword,\n dbUser,\n mongodbUri,\n}: {\n appName: string;\n dbName: string;\n dbPassword: string;\n dbUser: string;\n mongodbUri: string;\n}) => {\n try {\n // Check if MONGODB_URI is provided (for local Docker MongoDB)\n const mongoUri = mongodbUri\n ? mongodbUri\n : // Fallback to MongoDB Atlas connection string\n `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`;\n\n await mongoose.connect(mongoUri);\n\n const connectionType = mongodbUri ? \"Local MongoDB\" : \"MongoDB Atlas\";\n console.log(\n `${connectionType} connected from server/src/service/database.ts`,\n );\n } catch (err) {\n console.error(\"Error connecting to MongoDB:\", err);\n throw err; // You can throw the error if you want to stop the server in case of connection failure\n }\n};\n","import dayjs from \"dayjs\";\nimport timezone from \"dayjs/plugin/timezone\";\nimport utc from \"dayjs/plugin/utc\";\nimport { Schema } from \"mongoose\";\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport function timezonePlugin(schema: Schema) {\n if (!schema.get(\"timestamps\")) return;\n\n const transform = (_doc: any, ret: any) => {\n if (ret.createdAt)\n ret.createdAt = dayjs(ret.createdAt).tz(\"Pacific/Auckland\").format(); // ISO with +13:00 or +12:00 offset\n if (ret.updatedAt)\n ret.updatedAt = dayjs(ret.updatedAt).tz(\"Pacific/Auckland\").format();\n return ret;\n };\n\n schema.set(\"toJSON\", { transform });\n schema.set(\"toObject\", { transform });\n}\n","import mongoose from \"mongoose\";\n\nimport { EnumNotificationResourceType, EnumNotificationType } from \"src/enums\";\nimport {\n CreateBulkNotificationInput,\n NotificationType,\n ObjectId,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaCreateBulkNotificationInput = Omit<\n CreateBulkNotificationInput,\n \"userIds\"\n> & {\n userIds: ObjectId[];\n};\n\nexport type SchemaNotificationType = Omit<NotificationType, \"userId\"> & {\n userId: ObjectId;\n};\n/**\n * Schema for storing in-app notifications\n * Each notification is tied to a specific user and can be marked as read/unread\n */\nconst schema = new MongooseSchema<SchemaNotificationType>(\n {\n data: {\n resourceId: { required: true, type: String },\n resourceName: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumNotificationResourceType),\n required: true,\n type: String,\n },\n },\n isRead: { default: false, index: true, required: true, type: Boolean },\n message: { required: true, type: String },\n title: { required: true, type: String },\n type: {\n default: EnumNotificationType.SYSTEM,\n enum: Object.values(EnumNotificationType),\n required: true,\n type: String,\n },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\n// Compound index for efficient queries\nschema.index({ isRead: 1, userId: 1 });\nschema.index({ createdAt: -1, userId: 1 });\n\nexport const NotificationModel =\n (mongoose.models.Notification as mongoose.Model<SchemaNotificationType>) ||\n mongoose.model<SchemaNotificationType>(\"Notification\", schema);\n","export enum EnumInviteStatus {\n ACCEPTED = \"Accepted\",\n COMPLETED = \"Completed\",\n EXPIRED = \"Expired\",\n NO_STATUS = \"No_Status\",\n PAID = \"Paid\",\n PENDING = \"Pending\",\n REJECTED = \"Rejected\",\n UNAVAILABLE = \"Unavailable\",\n WAITING = \"Waiting\",\n}\n\nexport enum EnumChatType {\n GROUP = \"group\",\n PRIVATE = \"private\",\n RELATION = \"relation\",\n}\n\nexport enum EnumPaymentMethod {\n CASH = \"cash\",\n EFTPOS = \"eftpos\",\n BANK_TRANSFER = \"bank_transfer\",\n PAYPAL = \"paypal\",\n STRIPE = \"stripe\",\n}\n\nexport enum EnumFoodFlavor {\n SALTY = \"Salty\",\n SAVOURY = \"Savoury\",\n SPICY = \"Spicy\",\n SWEET = \"Sweet\",\n}\n\nexport enum EnumResourceType {\n EVENT = \"event\",\n VENDOR = \"vendor\",\n}\n\nexport enum EnumEventType {\n EXPO = \"Expo\",\n FAIR = \"Fair\",\n FESTIVAL = \"Festival\",\n MARKET = \"Market\",\n}\n\nexport enum EnumVendorType {\n STALLHOLDER = \"Stallholder\",\n SHOP = \"Shop\",\n CHARITY = \"Charity\",\n}\n\nexport enum EnumOSPlatform {\n ANDROID = \"android\",\n IOS = \"ios\",\n WEB = \"web\",\n}\n\nexport enum EnumRelationResource {\n EVENT_INVITE_VENDOR = \"event_invite_vendor\",\n VENDOR_APPLICATION_TO_EVENT = \"vendor_application_to_event\",\n}\n\nexport enum EnumNotificationResourceType {\n ADDED_AS_PARTNER_EVENT = \"added_as_partner_event\",\n ADDED_AS_PARTNER_VENDOR = \"added_as_partner_vendor\",\n APPROVED_EVENT = \"approved_event\",\n APPROVED_VENDOR = \"approved_vendor\",\n CREATED_EVENT = \"created_event\",\n CREATED_VENDOR = \"created_vendor\",\n EVENT_INVITE_VENDOR = EnumRelationResource.EVENT_INVITE_VENDOR,\n EVENT_STARTING_SOON = \"event_starting_soon\",\n NEW_CHAT_MESSAGE = \"new_chat_message\",\n VENDOR_APPLICATION_TO_EVENT = EnumRelationResource.VENDOR_APPLICATION_TO_EVENT,\n}\n\nexport enum EnumNotificationType {\n EVENT = EnumResourceType.EVENT,\n VENDOR = EnumResourceType.VENDOR,\n RELATION = \"relation\",\n CHAT = \"chat\",\n SYSTEM = \"system\",\n}\n\nexport enum EnumRegions {\n Auckland = \"Auckland\",\n BayOfPlentyGisborne = \"Bay of Plenty & Gisborne\",\n Canterbury = \"Canterbury\",\n HawkesBay = \"Hawke's Bay\",\n ManawatuWanganui = \"Manawatu-Wanganui\",\n MarlboroughNelson = \"Marlborough & Nelson\",\n Northland = \"Northland\",\n SouthlandOtago = \"Southland & Otago\",\n Taranaki = \"Taranaki\",\n Waikato = \"Waikato\",\n Wellington = \"Wellington\",\n TasmanWestCoast = \"Tasman & West Coast\",\n}\n\nexport enum ImageTypeEnum {\n AVATAR = \"avatar\",\n COVER = \"cover\",\n IMAGE = \"image\",\n LOGO = \"logo\",\n}\n\nexport enum EnumUserLicence {\n PRO_EVENT = \"pro_event\",\n PRO_PLUS_EVENT = \"pro_plus_event\",\n PRO_PLUS_VENDOR = \"pro_plus_vendor\",\n PRO_VENDOR = \"pro_vendor\",\n STANDARD_EVENT = \"standard_event\",\n STANDARD_VENDOR = \"standard_vendor\",\n}\n\nexport enum EnumUserRole {\n ADMIN = \"admin\",\n CUSTOMER = \"customer\",\n MARKETING = \"marketing\",\n MODERATOR = \"moderator\",\n SUPPORT = \"support\",\n}\n\nexport enum EnumSocialMedia {\n FACEBOOK = \"facebook\",\n INSTAGRAM = \"instagram\",\n TIKTOK = \"tiktok\",\n TWITTER = \"twitter\",\n WEBSITE = \"website\",\n YOUTUBE = \"youtube\",\n}\n","import { Request } from \"express\";\nimport mongoose from \"mongoose\";\nimport {\n Control,\n FieldErrors,\n FieldValues,\n UseFormHandleSubmit,\n UseFormReset,\n UseFormSetValue,\n UseFormWatch,\n} from \"react-hook-form\";\n\nimport { SchemaChatType } from \"src/mongoose/Chat\";\nimport { SchemaNotificationType } from \"src/mongoose/Notification\";\n\nimport { EnumResourceType, EnumSocialMedia, EnumUserLicence } from \"../enums\";\n\nimport { EventType } from \"./event\";\nimport { NotificationCount } from \"./notification\";\nimport { RelationDate } from \"./relation\";\nimport { VendorType } from \"./vendor\";\n\nexport type Nullable<T> = {\n [K in keyof T]: T[K] | null | undefined;\n};\n\nexport type DeviceInfo = {\n appBuildNumber: string;\n appId: string;\n appVersion: string;\n brand: string;\n deviceName: string;\n installationId: string;\n manufacturer: string;\n modelName: string;\n osName: string;\n osVersion: string;\n timestamp: string;\n};\n\nexport type TermsAgreement = DeviceInfo & {\n termVersion: string;\n};\n\nexport type ResourceContactDetailsType = {\n email?: string | null;\n landlinePhone?: string | null;\n mobilePhone?: string | null;\n};\n\nexport type ResourceImageType = {\n source: string;\n title: string;\n};\n\nexport type SocialMediaType = {\n name?: EnumSocialMedia;\n link?: string;\n};\n\nexport type PartnerType = {\n email: string;\n resourceId: string;\n resourceType: EnumResourceType;\n licence: EnumUserLicence;\n};\n\nexport type OwnerType = {\n email: string;\n userId: string;\n};\n\nexport interface BaseResourceTypeFormData {\n _id?: string;\n active: boolean;\n contactDetails?: ResourceContactDetailsType | null;\n cover: ResourceImageType;\n coverUpload?: ResourceImageType | null;\n description: string;\n images?: ResourceImageType[] | null;\n imagesUpload?: ResourceImageType[] | null;\n logo?: ResourceImageType | null;\n logoUpload?: ResourceImageType | null;\n name: string;\n owner?: OwnerType | null;\n partners?: PartnerType[] | null;\n promoCodes?: string[] | null;\n region: string;\n socialMedia?: SocialMediaType[] | null;\n termsAgreement?: TermsAgreement | null;\n}\n\nexport type PosterUsageType = {\n month: string;\n count: number;\n};\n\nexport type BaseResourceType = Omit<\n BaseResourceTypeFormData,\n \"_id\" | \"coverUpload\" | \"imagesUpload\" | \"logoUpload\" | \"owner\"\n> & {\n _id: string;\n adIds?: string[] | null;\n createdAt: string;\n deletedAt: string | null;\n owner: OwnerType;\n posterUsage?: PosterUsageType | null;\n relations:\n | {\n relationId: string | null;\n relationDates: RelationDate[] | null;\n }[]\n | null;\n updatedAt: string;\n};\n\nexport type LocationType = {\n city: string;\n coordinates: number[]; // [longitude, latitude]\n country: string;\n fullAddress: string;\n latitude: number;\n longitude: number;\n region: string;\n type: \"Point\"; // Mongoose GeoJSON type\n};\n\nexport type DateTimeType = {\n endDate: string;\n endTime: string;\n startDate: string;\n startTime: string;\n};\n\nexport type Region = {\n latitude: number;\n latitudeDelta: number;\n longitude: number;\n longitudeDelta: number;\n};\n\nexport type GeocodeLocation = Pick<LocationType, \"latitude\" | \"longitude\">;\n\nexport type MapMultiLocation = {\n dateTime: DateTimeType | null;\n location: LocationType | null;\n resourceId?: string;\n resourceName?: string;\n resourceType?: EnumResourceType;\n};\n\nexport interface FormField {\n disabled?: boolean;\n helperText?: string;\n isTextArea?: boolean;\n keyboardType?:\n | \"default\"\n | \"email-address\"\n | \"number-pad\"\n | \"url\"\n | \"decimal-pad\"\n | \"phone-pad\";\n name: string;\n placeholder: string;\n secureTextEntry?: boolean;\n}\n\nexport interface FormDateField {\n dateMode: \"date\" | \"time\";\n helperText?: string;\n name: \"endDate\" | \"endTime\" | \"startDate\" | \"startTime\";\n placeholder: string;\n}\n\nexport interface SubcategoryItems {\n id: string;\n name: string;\n description?: string | null;\n}\n\nexport interface Subcategory {\n id: string;\n name: string;\n items?: SubcategoryItems[] | null;\n}\n\nexport interface Category {\n color?: string | null;\n description?: string | null;\n id: string;\n name: string;\n subcategories: Subcategory[];\n}\n\nexport type OptionItem = {\n value: string;\n label: string;\n};\n\nexport type ImageObjectType = {\n uri: string;\n type: string;\n name: string;\n};\n\nexport interface ResourceConnectionsType {\n events: EventType[] | null;\n vendors: VendorType[] | null;\n}\n\nexport interface CreateFormData<T extends FieldValues> {\n control: Control<T, any>;\n fields: T;\n formState: { errors: FieldErrors<T> };\n handleSubmit: UseFormHandleSubmit<T, any>;\n reset: UseFormReset<T>;\n setValue: UseFormSetValue<T>;\n watch: UseFormWatch<T>;\n}\n\nexport type ObjectId = mongoose.Schema.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: string;\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 user: AuthUser | null;\n pubsub: {\n publish: (\n eventName: EnumPubSubEvents,\n payload: SubscriptionPayload,\n ) => void;\n subscribe: (eventName: EnumPubSubEvents) => AsyncIterable<any>;\n };\n request: Request;\n response: Response;\n}\n\nexport { mongoose };\n","import {\n SchemaCreateBulkNotificationInput,\n SchemaNotificationType,\n NotificationModel,\n} from \"src/mongoose/Notification\";\nimport { EnumPubSubEvents, GraphQLContext, ObjectId } from \"src/types\";\n\n// Helper function to publish notification subscription events\nexport async function publishNotificationEvents(\n userId: ObjectId,\n context: GraphQLContext,\n) {\n try {\n // Get user's notifications for the subscription\n const userNotifications = await NotificationModel.find({\n userId,\n }).sort({ createdAt: -1 });\n\n // Get notification count\n const [total, unread] = await Promise.all([\n NotificationModel.countDocuments({ userId }),\n NotificationModel.countDocuments({ isRead: false, userId }),\n ]);\n\n // Publish both events\n context.pubsub.publish(EnumPubSubEvents.GET_NOTIFICATIONS, {\n getNotifications: userNotifications,\n getNotificationsUserId: userId,\n });\n\n context.pubsub.publish(EnumPubSubEvents.GET_NOTIFICATIONS_COUNT, {\n getNotificationsCount: { total, unread, userId },\n });\n\n console.log(`Published notification events for user: ${String(userId)}`);\n } catch (error) {\n console.error(\n `Failed to publish notification events for user ${String(userId)}:`,\n error,\n );\n }\n}\n\n/**\n * Create notifications in the database for multiple users\n * This is typically called when sending push notifications\n */\nexport async function createNotifications(\n payload: SchemaCreateBulkNotificationInput,\n context: GraphQLContext,\n): Promise<SchemaNotificationType[]> {\n const { data, message, title, type, userIds } = payload;\n try {\n const notifications = userIds.map((userId) => ({\n data,\n isRead: false,\n message,\n title,\n type,\n userId,\n }));\n\n // Save notifications to database\n const savedNotifications =\n await NotificationModel.insertMany(notifications);\n console.log(\n `Created ${savedNotifications.length} notifications for ${userIds.length} users`,\n );\n\n const uniqueUserIds = [...new Set(userIds)];\n for (const userId of uniqueUserIds) {\n await publishNotificationEvents(userId, context);\n }\n\n return savedNotifications;\n } catch (error) {\n console.error(\"Failed to create notifications:\", error);\n return [];\n //throw new Error(`Failed to create notifications: ${error}`);\n }\n}\n","import { Expo, ExpoPushMessage, ExpoPushTicket } from \"expo-server-sdk\";\n\nimport { PushTokenModel } from \"src/mongoose/PushToken\";\nimport { NotificationDataType, ObjectId } from \"src/types\";\n\nconst expo = new Expo();\n\n/**\n * Safely extract tokens from ExpoPushMessage handling both string and array cases\n */\nfunction extractTokensFromMessage(message: ExpoPushMessage): string[] {\n return Array.isArray(message.to) ? message.to : [message.to];\n}\n\ninterface CreatePushMessagesOptions {\n tokens: string[];\n message: string;\n title: string;\n data: NotificationDataType;\n}\n\n/**\n * Create push messages from valid tokens\n */\nfunction createPushMessages({\n tokens,\n message,\n title,\n data,\n}: CreatePushMessagesOptions): {\n messages: ExpoPushMessage[];\n invalidTokens: string[];\n} {\n const messages: ExpoPushMessage[] = [];\n const invalidTokens: string[] = [];\n\n for (const token of tokens) {\n if (!Expo.isExpoPushToken(token)) {\n invalidTokens.push(token);\n continue;\n }\n\n messages.push({\n body: message,\n data: { ...data },\n sound: \"default\",\n title,\n to: token,\n });\n }\n\n return { invalidTokens, messages };\n}\n\n/**\n * Process chunk results and extract failed tokens\n */\nfunction processChunkResults(\n tickets: ExpoPushTicket[],\n chunk: ExpoPushMessage[],\n): { successCount: number; failedTokens: string[] } {\n let successCount = 0;\n const failedTokens: string[] = [];\n\n for (const [ticketIndex, ticket] of tickets.entries()) {\n if (ticket.status === \"error\") {\n const message = chunk[ticketIndex];\n if (message) {\n const tokens = extractTokensFromMessage(message);\n if (ticket.details?.error === \"DeviceNotRegistered\") {\n failedTokens.push(...tokens);\n }\n console.log(\"Push notification error\", {\n error: ticket.details?.error,\n tokens,\n });\n }\n } else {\n successCount++;\n }\n }\n\n return { failedTokens, successCount };\n}\n\n/**\n * Send a single chunk of push notifications\n */\nasync function sendChunk(\n chunk: ExpoPushMessage[],\n chunkIndex: number,\n): Promise<{ successCount: number; failedTokens: string[] }> {\n try {\n const tickets = await expo.sendPushNotificationsAsync(chunk);\n const { successCount, failedTokens } = processChunkResults(tickets, chunk);\n\n console.log(\n `Chunk ${chunkIndex + 1}: Sent ${successCount}/${chunk.length} notifications successfully`,\n );\n\n return { failedTokens, successCount };\n } catch (error) {\n console.log(\"Error sending Expo push notification chunk\", {\n chunkIndex,\n chunkSize: chunk.length,\n error: error instanceof Error ? error.message : String(error),\n });\n return { failedTokens: [], successCount: 0 };\n }\n}\n\ninterface SendPushNotificationOptions {\n data: NotificationDataType;\n message: string;\n title: string;\n userIds: ObjectId[];\n}\n\nexport async function sendPushNotification({\n data,\n message,\n title,\n userIds,\n}: SendPushNotificationOptions) {\n const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });\n const expoTokens = pushTokens.map((token) => token.token);\n\n const { messages, invalidTokens } = createPushMessages({\n data,\n message,\n title,\n tokens: expoTokens,\n });\n\n // Log invalid tokens\n if (invalidTokens.length > 0) {\n console.log(`Found ${invalidTokens.length} invalid push tokens`);\n }\n\n if (messages.length === 0) {\n console.log(\"No valid messages to send after filtering tokens\");\n return;\n }\n\n // Send notifications in chunks\n const chunks = expo.chunkPushNotifications(messages);\n let totalSuccessCount = 0;\n const allFailedTokens: string[] = [];\n\n for (const [chunkIndex, chunk] of chunks.entries()) {\n const { successCount, failedTokens } = await sendChunk(\n chunk,\n chunkIndex + 1,\n );\n totalSuccessCount += successCount;\n allFailedTokens.push(...failedTokens);\n }\n\n // Log final results\n console.log(\n `Sent push notification to ${totalSuccessCount}/${messages.length} tokens across ${chunks.length} chunks`,\n );\n\n if (allFailedTokens.length > 0) {\n console.log(`Found ${allFailedTokens.length} failed push tokens`);\n }\n}\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform } from \"src/enums\";\nimport { ObjectId } from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\ntype PushTokenType = {\n _id: string;\n createdAt: Date;\n platform: EnumOSPlatform;\n token: string;\n updatedAt: Date;\n userId: string;\n};\n\nexport type SchemaPushTokenType = Omit<PushTokenType, \"userId\"> & {\n userId: ObjectId;\n};\n\n/**\n * This is the schema for the push token type.\n * It is used to define the structure of the push token type in the database.\n * The schema is used by Mongoose to create a model for the push token type.\n */\nconst schema = new MongooseSchema<SchemaPushTokenType>(\n {\n platform: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n token: { required: true, type: String },\n userId: { required: true, type: mongoose.Schema.Types.ObjectId },\n },\n { timestamps: true },\n);\n\nexport const PushTokenModel =\n (mongoose.models.PushToken as mongoose.Model<SchemaPushTokenType>) ||\n mongoose.model<SchemaPushTokenType>(\"PushToken\", schema);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAqB;;;ACArB,mBAAkB;AAClB,sBAAqB;AACrB,iBAAgB;AAGhB,aAAAA,QAAM,OAAO,WAAAC,OAAG;AA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AA,IACA,QAAQ;AAAA,EACV,CAAC;AAGD,MAAI,cAAc,SAAS,GAAG;AAC5B,YAAQ,IAAI,SAAS,cAAc,MAAM,sBAAsB;AAAA,EACjE;AAEA,MAAI,SAAS,WAAW,GAAG;AACzB,YAAQ,IAAI,kDAAkD;AAC9D;AAAA,EACF;AAGA,QAAM,SAAS,KAAK,uBAAuB,QAAQ;AACnD,MAAI,oBAAoB;AACxB,QAAM,kBAA4B,CAAC;AAEnC,aAAW,CAAC,YAAY,KAAK,KAAK,OAAO,QAAQ,GAAG;AAClD,UAAM,EAAE,cAAc,aAAa,IAAI,MAAM;AAAA,MAC3C;AAAA,MACA,aAAa;AAAA,IACf;AACA,yBAAqB;AACrB,oBAAgB,KAAK,GAAG,YAAY;AAAA,EACtC;AAGA,UAAQ;AAAA,IACN,6BAA6B,iBAAiB,IAAI,SAAS,MAAM,kBAAkB,OAAO,MAAM;AAAA,EAClG;AAEA,MAAI,gBAAgB,SAAS,GAAG;AAC9B,YAAQ,IAAI,SAAS,gBAAgB,MAAM,qBAAqB;AAAA,EAClE;AACF;","names":["dayjs","utc","timezone","schema","mongoose","import_mongoose","EnumOSPlatform","EnumNotificationResourceType","EnumNotificationType","mongoose","import_mongoose","import_mongoose","MongooseSchema","mongoose","schema"]}
|
|
1
|
+
{"version":3,"sources":["../../src/service/index.ts","../../src/service/database.ts","../../src/service/timezonePlugin.ts","../../src/mongoose/Notification.ts","../../src/enums/index.ts","../../src/service/saveNotificationsInDb.ts","../../src/service/sendPushNotifications.ts","../../src/mongoose/PushToken.ts"],"sourcesContent":["export * from \"./database\";\nexport * from \"./saveNotificationsInDb\";\nexport * from \"./sendPushNotifications\";\n","import mongoose from \"mongoose\";\n\nimport { timezonePlugin } from \"./timezonePlugin\";\n\nmongoose.plugin(timezonePlugin); // applies to all schemas\n\n/**\n * Connect to MongoDB using Mongoose.\n * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).\n */\nexport const connectToDatabase = async ({\n appName,\n dbName,\n dbPassword,\n dbUser,\n mongodbUri,\n}: {\n appName: string;\n dbName: string;\n dbPassword: string;\n dbUser: string;\n mongodbUri: string;\n}) => {\n try {\n // Check if MONGODB_URI is provided (for local Docker MongoDB)\n const mongoUri = mongodbUri\n ? mongodbUri\n : // Fallback to MongoDB Atlas connection string\n `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`;\n\n await mongoose.connect(mongoUri);\n\n const connectionType = mongodbUri ? \"Local MongoDB\" : \"MongoDB Atlas\";\n console.log(\n `${connectionType} connected from server/src/service/database.ts`,\n );\n } catch (err) {\n console.error(\"Error connecting to MongoDB:\", err);\n throw err; // You can throw the error if you want to stop the server in case of connection failure\n }\n};\n","import dayjs from \"dayjs\";\nimport timezone from \"dayjs/plugin/timezone\";\nimport utc from \"dayjs/plugin/utc\";\nimport { Schema } from \"mongoose\";\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport function timezonePlugin(schema: Schema) {\n if (!schema.get(\"timestamps\")) return;\n\n const transform = (_doc: any, ret: any) => {\n if (ret.createdAt)\n ret.createdAt = dayjs(ret.createdAt).tz(\"Pacific/Auckland\").format(); // ISO with +13:00 or +12:00 offset\n if (ret.updatedAt)\n ret.updatedAt = dayjs(ret.updatedAt).tz(\"Pacific/Auckland\").format();\n return ret;\n };\n\n schema.set(\"toJSON\", { transform });\n schema.set(\"toObject\", { transform });\n}\n","import mongoose from \"mongoose\";\n\nimport { EnumNotificationResourceType, EnumNotificationType } from \"src/enums\";\nimport {\n CreateBulkNotificationInput,\n NotificationType,\n ObjectId,\n} from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\nexport type SchemaCreateBulkNotificationInput = Omit<\n CreateBulkNotificationInput,\n \"userIds\"\n> & {\n userIds: ObjectId[];\n};\n\nexport type SchemaNotificationType = Omit<NotificationType, \"userId\"> & {\n userId: ObjectId;\n};\n/**\n * Schema for storing in-app notifications\n * Each notification is tied to a specific user and can be marked as read/unread\n */\nconst schema = new MongooseSchema<SchemaNotificationType>(\n {\n data: {\n resourceId: { required: true, type: String },\n resourceName: { required: true, type: String },\n resourceType: {\n enum: Object.values(EnumNotificationResourceType),\n required: true,\n type: String,\n },\n },\n isRead: { default: false, index: true, required: true, type: Boolean },\n message: { required: true, type: String },\n title: { required: true, type: String },\n type: {\n default: EnumNotificationType.SYSTEM,\n enum: Object.values(EnumNotificationType),\n required: true,\n type: String,\n },\n userId: {\n ref: \"User\",\n required: true,\n type: mongoose.Schema.Types.ObjectId,\n },\n },\n { timestamps: true },\n);\n\n// Compound index for efficient queries\nschema.index({ isRead: 1, userId: 1 });\nschema.index({ createdAt: -1, userId: 1 });\n\nexport const NotificationModel =\n (mongoose.models.Notification as mongoose.Model<SchemaNotificationType>) ||\n mongoose.model<SchemaNotificationType>(\"Notification\", schema);\n","export enum EnumInviteStatus {\n ACCEPTED = \"Accepted\",\n COMPLETED = \"Completed\",\n EXPIRED = \"Expired\",\n NO_STATUS = \"No_Status\",\n PAID = \"Paid\",\n PENDING = \"Pending\",\n REJECTED = \"Rejected\",\n UNAVAILABLE = \"Unavailable\",\n WAITING = \"Waiting\",\n}\n\nexport enum EnumChatType {\n GROUP = \"group\",\n PRIVATE = \"private\",\n RELATION = \"relation\",\n}\n\nexport enum EnumPaymentMethod {\n CASH = \"cash\",\n EFTPOS = \"eftpos\",\n BANK_TRANSFER = \"bank_transfer\",\n PAYPAL = \"paypal\",\n STRIPE = \"stripe\",\n}\n\nexport enum EnumFoodFlavor {\n SALTY = \"Salty\",\n SAVOURY = \"Savoury\",\n SPICY = \"Spicy\",\n SWEET = \"Sweet\",\n}\n\nexport enum EnumResourceType {\n EVENT = \"event\",\n VENDOR = \"vendor\",\n}\n\nexport enum EnumEventType {\n EXPO = \"Expo\",\n FAIR = \"Fair\",\n FESTIVAL = \"Festival\",\n MARKET = \"Market\",\n}\n\nexport enum EnumVendorType {\n STALLHOLDER = \"Stallholder\",\n SHOP = \"Shop\",\n CHARITY = \"Charity\",\n}\n\nexport enum EnumOSPlatform {\n ANDROID = \"android\",\n IOS = \"ios\",\n WEB = \"web\",\n}\n\nexport enum EnumRelationResource {\n EVENT_INVITE_VENDOR = \"event_invite_vendor\",\n VENDOR_APPLICATION_TO_EVENT = \"vendor_application_to_event\",\n}\n\nexport enum EnumNotificationResourceType {\n ADDED_AS_PARTNER_EVENT = \"added_as_partner_event\",\n ADDED_AS_PARTNER_VENDOR = \"added_as_partner_vendor\",\n APPROVED_EVENT = \"approved_event\",\n APPROVED_VENDOR = \"approved_vendor\",\n CREATED_EVENT = \"created_event\",\n CREATED_VENDOR = \"created_vendor\",\n EVENT_INVITE_VENDOR = EnumRelationResource.EVENT_INVITE_VENDOR,\n EVENT_STARTING_SOON = \"event_starting_soon\",\n NEW_CHAT_MESSAGE = \"new_chat_message\",\n VENDOR_APPLICATION_TO_EVENT = EnumRelationResource.VENDOR_APPLICATION_TO_EVENT,\n}\n\nexport enum EnumNotificationType {\n EVENT = EnumResourceType.EVENT,\n VENDOR = EnumResourceType.VENDOR,\n RELATION = \"relation\",\n CHAT = \"chat\",\n SYSTEM = \"system\",\n}\n\nexport enum EnumRegions {\n Auckland = \"Auckland\",\n BayOfPlentyGisborne = \"Bay of Plenty & Gisborne\",\n Canterbury = \"Canterbury\",\n HawkesBay = \"Hawke's Bay\",\n ManawatuWanganui = \"Manawatu-Wanganui\",\n MarlboroughNelson = \"Marlborough & Nelson\",\n Northland = \"Northland\",\n SouthlandOtago = \"Southland & Otago\",\n Taranaki = \"Taranaki\",\n Waikato = \"Waikato\",\n Wellington = \"Wellington\",\n TasmanWestCoast = \"Tasman & West Coast\",\n}\n\nexport enum ImageTypeEnum {\n AVATAR = \"avatar\",\n COVER = \"cover\",\n IMAGE = \"image\",\n LOGO = \"logo\",\n}\n\nexport enum EnumUserLicence {\n PRO_EVENT = \"pro_event\",\n PRO_PLUS_EVENT = \"pro_plus_event\",\n PRO_PLUS_VENDOR = \"pro_plus_vendor\",\n PRO_VENDOR = \"pro_vendor\",\n STANDARD_EVENT = \"standard_event\",\n STANDARD_VENDOR = \"standard_vendor\",\n}\n\nexport enum EnumUserRole {\n ADMIN = \"admin\",\n CUSTOMER = \"customer\",\n MARKETING = \"marketing\",\n MODERATOR = \"moderator\",\n SUPPORT = \"support\",\n}\n\nexport enum EnumSocialMedia {\n FACEBOOK = \"facebook\",\n INSTAGRAM = \"instagram\",\n TIKTOK = \"tiktok\",\n TWITTER = \"twitter\",\n WEBSITE = \"website\",\n YOUTUBE = \"youtube\",\n}\n","import {\n SchemaCreateBulkNotificationInput,\n NotificationModel,\n} from \"src/mongoose/Notification\";\nimport { ObjectId } from \"src/types\";\n\n/**\n * Create notifications in the database for multiple users\n * This is typically called when sending push notifications\n */\nexport async function saveNotificationsInDb(\n payload: SchemaCreateBulkNotificationInput,\n): Promise<ObjectId[]> {\n const { data, message, title, type, userIds } = payload;\n try {\n const notifications = userIds.map((userId) => ({\n data,\n isRead: false,\n message,\n title,\n type,\n userId,\n }));\n\n // Save notifications to database\n await NotificationModel.insertMany(notifications);\n console.log(\n `Created ${notifications.length} notifications for ${userIds.length} users`,\n );\n\n return [...new Set(userIds)];\n } catch (error) {\n console.error(\"Failed to create notifications:\", error);\n return [];\n //throw new Error(`Failed to create notifications: ${error}`);\n }\n}\n","import { Expo, ExpoPushMessage, ExpoPushTicket } from \"expo-server-sdk\";\n\nimport { SchemaCreateBulkNotificationInput } from \"src/mongoose/Notification\";\nimport { PushTokenModel } from \"src/mongoose/PushToken\";\nimport { NotificationDataType, ObjectId } from \"src/types\";\n\nconst expo = new Expo();\n\n/**\n * Safely extract tokens from ExpoPushMessage handling both string and array cases\n */\nfunction extractTokensFromMessage(message: ExpoPushMessage): string[] {\n return Array.isArray(message.to) ? message.to : [message.to];\n}\n\ninterface CreatePushMessagesOptions {\n tokens: string[];\n message: string;\n title: string;\n data: NotificationDataType;\n}\n\n/**\n * Create push messages from valid tokens\n */\nfunction createPushMessages({\n tokens,\n message,\n title,\n data,\n}: CreatePushMessagesOptions): {\n messages: ExpoPushMessage[];\n invalidTokens: string[];\n} {\n const messages: ExpoPushMessage[] = [];\n const invalidTokens: string[] = [];\n\n for (const token of tokens) {\n if (!Expo.isExpoPushToken(token)) {\n invalidTokens.push(token);\n continue;\n }\n\n messages.push({\n body: message,\n data: { ...data },\n sound: \"default\",\n title,\n to: token,\n });\n }\n\n return { invalidTokens, messages };\n}\n\n/**\n * Process chunk results and extract failed tokens\n */\nfunction processChunkResults(\n tickets: ExpoPushTicket[],\n chunk: ExpoPushMessage[],\n): { successCount: number; failedTokens: string[] } {\n let successCount = 0;\n const failedTokens: string[] = [];\n\n for (const [ticketIndex, ticket] of tickets.entries()) {\n if (ticket.status === \"error\") {\n const message = chunk[ticketIndex];\n if (message) {\n const tokens = extractTokensFromMessage(message);\n if (ticket.details?.error === \"DeviceNotRegistered\") {\n failedTokens.push(...tokens);\n }\n console.log(\"Push notification error\", {\n error: ticket.details?.error,\n tokens,\n });\n }\n } else {\n successCount++;\n }\n }\n\n return { failedTokens, successCount };\n}\n\n/**\n * Send a single chunk of push notifications\n */\nasync function sendChunk(\n chunk: ExpoPushMessage[],\n chunkIndex: number,\n): Promise<{ successCount: number; failedTokens: string[] }> {\n try {\n const tickets = await expo.sendPushNotificationsAsync(chunk);\n const { successCount, failedTokens } = processChunkResults(tickets, chunk);\n\n console.log(\n `Chunk ${chunkIndex + 1}: Sent ${successCount}/${chunk.length} notifications successfully`,\n );\n\n return { failedTokens, successCount };\n } catch (error) {\n console.log(\"Error sending Expo push notification chunk\", {\n chunkIndex,\n chunkSize: chunk.length,\n error: error instanceof Error ? error.message : String(error),\n });\n return { failedTokens: [], successCount: 0 };\n }\n}\n\nexport async function sendPushNotifications({\n data,\n message,\n title,\n userIds,\n}: SchemaCreateBulkNotificationInput) {\n const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });\n const expoTokens = pushTokens.map((token) => token.token);\n\n if (!data) return;\n\n const { messages, invalidTokens } = createPushMessages({\n data,\n message,\n title,\n tokens: expoTokens,\n });\n\n // Log invalid tokens\n if (invalidTokens.length > 0) {\n console.log(`Found ${invalidTokens.length} invalid push tokens`);\n }\n\n if (messages.length === 0) {\n console.log(\"No valid messages to send after filtering tokens\");\n return;\n }\n\n // Send notifications in chunks\n const chunks = expo.chunkPushNotifications(messages);\n let totalSuccessCount = 0;\n const allFailedTokens: string[] = [];\n\n for (const [chunkIndex, chunk] of chunks.entries()) {\n const { successCount, failedTokens } = await sendChunk(\n chunk,\n chunkIndex + 1,\n );\n totalSuccessCount += successCount;\n allFailedTokens.push(...failedTokens);\n }\n\n // Log final results\n console.log(\n `Sent push notification to ${totalSuccessCount}/${messages.length} tokens across ${chunks.length} chunks`,\n );\n\n if (allFailedTokens.length > 0) {\n console.log(`Found ${allFailedTokens.length} failed push tokens`);\n }\n}\n","import mongoose from \"mongoose\";\n\nimport { EnumOSPlatform } from \"src/enums\";\nimport { ObjectId } from \"src/types\";\n\nconst MongooseSchema = mongoose.Schema;\n\ntype PushTokenType = {\n _id: string;\n createdAt: Date;\n platform: EnumOSPlatform;\n token: string;\n updatedAt: Date;\n userId: string;\n};\n\nexport type SchemaPushTokenType = Omit<PushTokenType, \"userId\"> & {\n userId: ObjectId;\n};\n\n/**\n * This is the schema for the push token type.\n * It is used to define the structure of the push token type in the database.\n * The schema is used by Mongoose to create a model for the push token type.\n */\nconst schema = new MongooseSchema<SchemaPushTokenType>(\n {\n platform: {\n enum: Object.values(EnumOSPlatform),\n required: true,\n type: String,\n },\n token: { required: true, type: String },\n userId: { required: true, type: mongoose.Schema.Types.ObjectId },\n },\n { timestamps: true },\n);\n\nexport const PushTokenModel =\n (mongoose.models.PushToken as mongoose.Model<SchemaPushTokenType>) ||\n mongoose.model<SchemaPushTokenType>(\"PushToken\", schema);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAqB;;;ACArB,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","import_mongoose","EnumOSPlatform","EnumNotificationResourceType","EnumNotificationType","mongoose","import_mongoose","MongooseSchema","mongoose","schema"]}
|
package/dist/service/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as SchemaCreateBulkNotificationInput, q as ObjectId } from '../global-ExJZRDGR.mjs';
|
|
2
2
|
import 'express';
|
|
3
3
|
import 'mongoose';
|
|
4
4
|
import 'react-hook-form';
|
|
@@ -16,19 +16,12 @@ declare const connectToDatabase: ({ appName, dbName, dbPassword, dbUser, mongodb
|
|
|
16
16
|
mongodbUri: string;
|
|
17
17
|
}) => Promise<void>;
|
|
18
18
|
|
|
19
|
-
declare function publishNotificationEvents(userId: ObjectId, context: GraphQLContext): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Create notifications in the database for multiple users
|
|
22
21
|
* This is typically called when sending push notifications
|
|
23
22
|
*/
|
|
24
|
-
declare function
|
|
23
|
+
declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInput): Promise<ObjectId[]>;
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
data: NotificationDataType;
|
|
28
|
-
message: string;
|
|
29
|
-
title: string;
|
|
30
|
-
userIds: ObjectId[];
|
|
31
|
-
}
|
|
32
|
-
declare function sendPushNotification({ data, message, title, userIds, }: SendPushNotificationOptions): Promise<void>;
|
|
25
|
+
declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
|
|
33
26
|
|
|
34
|
-
export { connectToDatabase,
|
|
27
|
+
export { connectToDatabase, saveNotificationsInDb, sendPushNotifications };
|
package/dist/service/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as SchemaCreateBulkNotificationInput, q as ObjectId } from '../global-DVYSZ6LR.js';
|
|
2
2
|
import 'express';
|
|
3
3
|
import 'mongoose';
|
|
4
4
|
import 'react-hook-form';
|
|
@@ -16,19 +16,12 @@ declare const connectToDatabase: ({ appName, dbName, dbPassword, dbUser, mongodb
|
|
|
16
16
|
mongodbUri: string;
|
|
17
17
|
}) => Promise<void>;
|
|
18
18
|
|
|
19
|
-
declare function publishNotificationEvents(userId: ObjectId, context: GraphQLContext): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Create notifications in the database for multiple users
|
|
22
21
|
* This is typically called when sending push notifications
|
|
23
22
|
*/
|
|
24
|
-
declare function
|
|
23
|
+
declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInput): Promise<ObjectId[]>;
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
data: NotificationDataType;
|
|
28
|
-
message: string;
|
|
29
|
-
title: string;
|
|
30
|
-
userIds: ObjectId[];
|
|
31
|
-
}
|
|
32
|
-
declare function sendPushNotification({ data, message, title, userIds, }: SendPushNotificationOptions): Promise<void>;
|
|
25
|
+
declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
|
|
33
26
|
|
|
34
|
-
export { connectToDatabase,
|
|
27
|
+
export { connectToDatabase, saveNotificationsInDb, sendPushNotifications };
|