@timardex/cluemart-server-shared 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-XNN5GVG3.mjs +62 -0
- package/dist/chunk-XNN5GVG3.mjs.map +1 -0
- package/dist/index.cjs +1144 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +485 -0
- package/dist/index.d.ts +485 -0
- package/dist/index.mjs +1119 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mongoose/index.cjs +959 -0
- package/dist/mongoose/index.cjs.map +1 -0
- package/dist/mongoose/index.d.mts +451 -0
- package/dist/mongoose/index.d.ts +451 -0
- package/dist/mongoose/index.mjs +885 -0
- package/dist/mongoose/index.mjs.map +1 -0
- package/dist/service/index.cjs +279 -0
- package/dist/service/index.cjs.map +1 -0
- package/dist/service/index.d.mts +25 -0
- package/dist/service/index.d.ts +25 -0
- package/dist/service/index.mjs +189 -0
- package/dist/service/index.mjs.map +1 -0
- package/dist/types-DWXC8az-.d.mts +20 -0
- package/dist/types-DWXC8az-.d.ts +20 -0
- package/package.json +62 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/mongoose/Notification.ts
|
|
2
|
+
import {
|
|
3
|
+
EnumNotificationResourceType,
|
|
4
|
+
EnumNotificationType
|
|
5
|
+
} from "@timardex/cluemart-shared";
|
|
6
|
+
import mongoose from "mongoose";
|
|
7
|
+
var MongooseSchema = mongoose.Schema;
|
|
8
|
+
var schema = new MongooseSchema(
|
|
9
|
+
{
|
|
10
|
+
data: {
|
|
11
|
+
resourceId: { required: true, type: String },
|
|
12
|
+
resourceName: { required: true, type: String },
|
|
13
|
+
resourceType: {
|
|
14
|
+
enum: Object.values(EnumNotificationResourceType),
|
|
15
|
+
required: true,
|
|
16
|
+
type: String
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
isRead: { default: false, index: true, required: true, type: Boolean },
|
|
20
|
+
message: { required: true, type: String },
|
|
21
|
+
title: { required: true, type: String },
|
|
22
|
+
type: {
|
|
23
|
+
default: EnumNotificationType.SYSTEM,
|
|
24
|
+
enum: Object.values(EnumNotificationType),
|
|
25
|
+
required: true,
|
|
26
|
+
type: String
|
|
27
|
+
},
|
|
28
|
+
userId: {
|
|
29
|
+
ref: "User",
|
|
30
|
+
required: true,
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{ timestamps: true }
|
|
35
|
+
);
|
|
36
|
+
schema.index({ isRead: 1, userId: 1 });
|
|
37
|
+
schema.index({ createdAt: -1, userId: 1 });
|
|
38
|
+
var NotificationModel = mongoose.models.Notification || mongoose.model("Notification", schema);
|
|
39
|
+
|
|
40
|
+
// src/mongoose/PushToken.ts
|
|
41
|
+
import { EnumOSPlatform } from "@timardex/cluemart-shared/enums";
|
|
42
|
+
import mongoose2 from "mongoose";
|
|
43
|
+
var MongooseSchema2 = mongoose2.Schema;
|
|
44
|
+
var schema2 = new MongooseSchema2(
|
|
45
|
+
{
|
|
46
|
+
platform: {
|
|
47
|
+
enum: Object.values(EnumOSPlatform),
|
|
48
|
+
required: true,
|
|
49
|
+
type: String
|
|
50
|
+
},
|
|
51
|
+
token: { required: true, type: String },
|
|
52
|
+
userId: { required: true, type: mongoose2.Schema.Types.ObjectId }
|
|
53
|
+
},
|
|
54
|
+
{ timestamps: true }
|
|
55
|
+
);
|
|
56
|
+
var PushTokenModel = mongoose2.models.PushToken || mongoose2.model("PushToken", schema2);
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
NotificationModel,
|
|
60
|
+
PushTokenModel
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=chunk-XNN5GVG3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mongoose/Notification.ts","../src/mongoose/PushToken.ts"],"sourcesContent":["import {\n CreateBulkNotificationInput,\n NotificationType,\n EnumNotificationResourceType,\n EnumNotificationType,\n} from \"@timardex/cluemart-shared\";\nimport mongoose from \"mongoose\";\n\nimport { ObjectId } 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","import { EnumOSPlatform } from \"@timardex/cluemart-shared/enums\";\nimport mongoose from \"mongoose\";\n\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,EAGE;AAAA,EACA;AAAA,OACK;AACP,OAAO,cAAc;AAIrB,IAAM,iBAAiB,SAAS;AAgBhC,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,MACJ,YAAY,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,MAC3C,cAAc,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,MAC7C,cAAc;AAAA,QACZ,MAAM,OAAO,OAAO,4BAA4B;AAAA,QAChD,UAAU;AAAA,QACV,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,QAAQ,EAAE,SAAS,OAAO,OAAO,MAAM,UAAU,MAAM,MAAM,QAAQ;AAAA,IACrE,SAAS,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACxC,OAAO,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACtC,MAAM;AAAA,MACJ,SAAS,qBAAqB;AAAA,MAC9B,MAAM,OAAO,OAAO,oBAAoB;AAAA,MACxC,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,MACV,MAAM,SAAS,OAAO,MAAM;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,EAAE,YAAY,KAAK;AACrB;AAGA,OAAO,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;AACrC,OAAO,MAAM,EAAE,WAAW,IAAI,QAAQ,EAAE,CAAC;AAElC,IAAM,oBACV,SAAS,OAAO,gBACjB,SAAS,MAA8B,gBAAgB,MAAM;;;AC7D/D,SAAS,sBAAsB;AAC/B,OAAOA,eAAc;AAIrB,IAAMC,kBAAiBD,UAAS;AAoBhC,IAAME,UAAS,IAAID;AAAA,EACjB;AAAA,IACE,UAAU;AAAA,MACR,MAAM,OAAO,OAAO,cAAc;AAAA,MAClC,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,IACA,OAAO,EAAE,UAAU,MAAM,MAAM,OAAO;AAAA,IACtC,QAAQ,EAAE,UAAU,MAAM,MAAMD,UAAS,OAAO,MAAM,SAAS;AAAA,EACjE;AAAA,EACA,EAAE,YAAY,KAAK;AACrB;AAEO,IAAM,iBACVA,UAAS,OAAO,aACjBA,UAAS,MAA2B,aAAaE,OAAM;","names":["mongoose","MongooseSchema","schema"]}
|