@lyxa.ai/core 1.0.15-debug-0.12 → 1.0.15
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/libraries/mongo/models/admin-access-control.model.d.ts +2 -1
- package/dist/libraries/mongo/models/admin-access-control.model.js +2 -1
- package/dist/libraries/mongo/models/admin-access-control.model.js.map +1 -1
- package/dist/libraries/mongo/models/admin.model.d.ts +3 -4
- package/dist/libraries/mongo/models/admin.model.js +3 -19
- package/dist/libraries/mongo/models/admin.model.js.map +1 -1
- package/dist/libraries/mongo/models/index.d.ts +66 -65
- package/dist/libraries/mongo/models/index.js +7 -7
- package/dist/libraries/mongo/models/index.js.map +1 -1
- package/dist/libraries/mongo/plugins/soft-delete-plugin.d.ts +9 -10
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js +17 -17
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js.map +1 -1
- package/package.json +1 -1
- package/dist/libraries/trpc/middlewares/cors.d.ts +0 -12
- package/dist/libraries/trpc/middlewares/cors.js +0 -46
- package/dist/libraries/trpc/middlewares/cors.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
1
|
+
import { ReturnModelType, Ref } from '@typegoose/typegoose';
|
|
2
2
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
3
|
import { AdminRole } from '../../../utilities/enum';
|
|
4
4
|
import { Admin } from './admin.model';
|
|
@@ -8,3 +8,4 @@ export declare class AdminAccessControl extends TimeStamps {
|
|
|
8
8
|
admin: Ref<Admin>;
|
|
9
9
|
role: AdminRole;
|
|
10
10
|
}
|
|
11
|
+
export declare const AdminAccessControlModel: ReturnModelType<typeof AdminAccessControl>;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AdminAccessControl = void 0;
|
|
15
|
+
exports.AdminAccessControlModel = exports.AdminAccessControl = void 0;
|
|
16
16
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
17
17
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
18
18
|
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
@@ -51,4 +51,5 @@ exports.AdminAccessControl = AdminAccessControl = __decorate([
|
|
|
51
51
|
}),
|
|
52
52
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'adminAccessControls' } })
|
|
53
53
|
], AdminAccessControl);
|
|
54
|
+
exports.AdminAccessControlModel = (0, typegoose_1.getModelForClass)(AdminAccessControl);
|
|
54
55
|
//# sourceMappingURL=admin-access-control.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-access-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin-access-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAuG;AACvG,4EAAqE;AACrE,wDAA8B;AAC9B,kDAAoD;AACpD,+CAAsC;AAU/B,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,KAAK,CAAU;IAGf,QAAQ,CAAU;IAGlB,KAAK,CAAc;IAGnB,IAAI,CAAa;CACxB,CAAA;AAZY,gDAAkB;AAEvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;iDAC/B;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAK,EAAE,CAAC;;iDACjB;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,CAAC;;gDAChC;6BAXZ,kBAAkB;IAR9B,IAAA,eAAG,EAAqB,MAAM,EAAE,KAAK,WAAW,IAAI;QACpD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,QAAQ,GAAG,MAAM,kBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;GAC1D,kBAAkB,CAY9B","sourcesContent":["import { modelOptions, prop, getModelForClass, pre, ReturnModelType, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport bcrypt from 'bcryptjs';\r\nimport { AdminRole } from '../../../utilities/enum';\r\nimport { Admin } from './admin.model';\r\n\r\n@pre<AdminAccessControl>('save', async function (next) {\r\n\tif (this.isModified('password')) {\r\n\t\tconst salt = await bcrypt.genSalt(10);\r\n\t\tthis.password = await bcrypt.hash(this.password, salt);\r\n\t}\r\n\tnext();\r\n})\r\n@modelOptions({ schemaOptions: { collection: 'adminAccessControls' } })\r\nexport class AdminAccessControl extends TimeStamps {\r\n\t@prop({ required: true, type: String, unique: true })\r\n\tpublic email!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic password!: string;\r\n\r\n\t@prop({ required: true, ref: () => Admin })\r\n\tpublic admin!: Ref<Admin>;\r\n\r\n\t@prop({ required: true, type: String, enum: AdminRole })\r\n\tpublic role!: AdminRole;\r\n}\r\n\r\n\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,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;GAC1D,kBAAkB,CAY9B;AAEY,QAAA,uBAAuB,GACnC,IAAA,4BAAgB,EAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { modelOptions, prop, getModelForClass, pre, ReturnModelType, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport bcrypt from 'bcryptjs';\r\nimport { AdminRole } from '../../../utilities/enum';\r\nimport { Admin } from './admin.model';\r\n\r\n@pre<AdminAccessControl>('save', async function (next) {\r\n\tif (this.isModified('password')) {\r\n\t\tconst salt = await bcrypt.genSalt(10);\r\n\t\tthis.password = await bcrypt.hash(this.password, salt);\r\n\t}\r\n\tnext();\r\n})\r\n@modelOptions({ schemaOptions: { collection: 'adminAccessControls' } })\r\nexport class AdminAccessControl extends TimeStamps {\r\n\t@prop({ required: true, type: String, unique: true })\r\n\tpublic email!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic password!: string;\r\n\r\n\t@prop({ required: true, ref: () => Admin })\r\n\tpublic admin!: Ref<Admin>;\r\n\r\n\t@prop({ required: true, type: String, enum: AdminRole })\r\n\tpublic role!: AdminRole;\r\n}\r\n\r\nexport const AdminAccessControlModel: ReturnModelType<typeof AdminAccessControl> =\r\n\tgetModelForClass(AdminAccessControl);\r\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TimeStamps } from
|
|
3
|
-
import { AdminAccessControl } from "./admin-access-control.model";
|
|
1
|
+
import { ReturnModelType } from '@typegoose/typegoose';
|
|
2
|
+
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
4
3
|
export declare class Admin extends TimeStamps {
|
|
5
4
|
name: string;
|
|
6
5
|
profilePhoto?: string;
|
|
7
6
|
phoneNumber: string;
|
|
8
7
|
status?: string;
|
|
9
|
-
accessControl: Ref<AdminAccessControl>;
|
|
10
8
|
}
|
|
9
|
+
export declare const AdminModel: ReturnModelType<typeof Admin>;
|
|
@@ -9,17 +9,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Admin = void 0;
|
|
12
|
+
exports.AdminModel = exports.Admin = void 0;
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
|
-
const admin_access_control_model_1 = require("./admin-access-control.model");
|
|
17
16
|
let Admin = class Admin extends defaultClasses_1.TimeStamps {
|
|
18
17
|
name;
|
|
19
18
|
profilePhoto;
|
|
20
19
|
phoneNumber;
|
|
21
20
|
status;
|
|
22
|
-
accessControl;
|
|
23
21
|
};
|
|
24
22
|
exports.Admin = Admin;
|
|
25
23
|
__decorate([
|
|
@@ -38,22 +36,8 @@ __decorate([
|
|
|
38
36
|
(0, typegoose_1.prop)({ type: String, enum: enum_1.Status, default: enum_1.Status.ACTIVE }),
|
|
39
37
|
__metadata("design:type", String)
|
|
40
38
|
], Admin.prototype, "status", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, typegoose_1.prop)({
|
|
43
|
-
ref: () => admin_access_control_model_1.AdminAccessControl,
|
|
44
|
-
foreignField: "admin",
|
|
45
|
-
localField: "_id",
|
|
46
|
-
justOne: true,
|
|
47
|
-
}),
|
|
48
|
-
__metadata("design:type", Object)
|
|
49
|
-
], Admin.prototype, "accessControl", void 0);
|
|
50
39
|
exports.Admin = Admin = __decorate([
|
|
51
|
-
(0, typegoose_1.modelOptions)({
|
|
52
|
-
schemaOptions: {
|
|
53
|
-
collection: "admins",
|
|
54
|
-
toJSON: { virtuals: true },
|
|
55
|
-
toObject: { virtuals: true },
|
|
56
|
-
},
|
|
57
|
-
})
|
|
40
|
+
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'admins' } })
|
|
58
41
|
], Admin);
|
|
42
|
+
exports.AdminModel = (0, typegoose_1.getModelForClass)(Admin);
|
|
59
43
|
//# sourceMappingURL=admin.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"admin.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6F;AAC7F,4EAAqE;AACrE,kDAAiD;AAG1C,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,2BAAU;IAE7B,IAAI,CAAU;IAGd,YAAY,CAAU;IAGtB,WAAW,CAAU;IAGrB,MAAM,CAAU;CACvB,CAAA;AAZY,sBAAK;AAEV;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACM;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACX;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;qCACtC;gBAXX,KAAK;IADjB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC;GAC7C,KAAK,CAYjB;AAEY,QAAA,UAAU,GAAkC,IAAA,4BAAgB,EAAC,KAAK,CAAC,CAAC","sourcesContent":["import { modelOptions, prop, getModelForClass, ReturnModelType } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Status } from '../../../utilities/enum';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'admins' } })\r\nexport class Admin extends TimeStamps {\r\n\t@prop({ required: true, type: String })\r\n\tpublic name!: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic profilePhoto?: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic phoneNumber!: string;\r\n\r\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status?: string;\r\n}\r\n\r\nexport const AdminModel: ReturnModelType<typeof Admin> = getModelForClass(Admin);\r\n"]}
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
34
|
-
export * from
|
|
35
|
-
export * from
|
|
36
|
-
export * from
|
|
37
|
-
export * from
|
|
38
|
-
export * from
|
|
39
|
-
export * from
|
|
40
|
-
export * from
|
|
41
|
-
export * from
|
|
42
|
-
export * from
|
|
43
|
-
export * from
|
|
44
|
-
export * from
|
|
45
|
-
export * from
|
|
46
|
-
export * from
|
|
47
|
-
export * from
|
|
48
|
-
export * from
|
|
49
|
-
export * from
|
|
50
|
-
export * from
|
|
51
|
-
export * from
|
|
52
|
-
export * from
|
|
53
|
-
export * from
|
|
54
|
-
export * from
|
|
55
|
-
export * from
|
|
56
|
-
export * from
|
|
57
|
-
export * from
|
|
58
|
-
export * from
|
|
59
|
-
export * from
|
|
60
|
-
export * from
|
|
61
|
-
export * from
|
|
62
|
-
export * from
|
|
63
|
-
export * from
|
|
64
|
-
export * from
|
|
65
|
-
export * from
|
|
1
|
+
export * from './activity-log.model';
|
|
2
|
+
export * from './admin-access-control.model';
|
|
3
|
+
export * from './admin.model';
|
|
4
|
+
export * from './app-screen-setting.model';
|
|
5
|
+
export * from './attribute.model';
|
|
6
|
+
export * from './banner.model';
|
|
7
|
+
export * from './bob-finance.model';
|
|
8
|
+
export * from './brand.model';
|
|
9
|
+
export * from './category.model';
|
|
10
|
+
export * from './core-auth-identity.model';
|
|
11
|
+
export * from './core-user.model';
|
|
12
|
+
export * from './counter.model';
|
|
13
|
+
export * from './coupon.model';
|
|
14
|
+
export * from './deal-setting.model';
|
|
15
|
+
export * from './dish.model';
|
|
16
|
+
export * from './faq.model';
|
|
17
|
+
export * from './favourite.model';
|
|
18
|
+
export * from './featured-setting.model';
|
|
19
|
+
export * from './filter-container.model';
|
|
20
|
+
export * from './list-container.model';
|
|
21
|
+
export * from './loyalty-point-category.model';
|
|
22
|
+
export * from './loyalty-point-setting.model';
|
|
23
|
+
export * from './marketing.model';
|
|
24
|
+
export * from './meal-plan.model';
|
|
25
|
+
export * from './notification.model';
|
|
26
|
+
export * from './nutrition.model';
|
|
27
|
+
export * from './order.model';
|
|
28
|
+
export * from './parent.model';
|
|
29
|
+
export * from './payout.model';
|
|
30
|
+
export * from './product-marketing.model';
|
|
31
|
+
export * from './product.model';
|
|
32
|
+
export * from './punch-marketing-history.model';
|
|
33
|
+
export * from './rating-setting.model';
|
|
34
|
+
export * from './referral-setting.model';
|
|
35
|
+
export * from './request-area.model';
|
|
36
|
+
export * from './rider-review.model';
|
|
37
|
+
export * from './rider.model';
|
|
38
|
+
export * from './role.model';
|
|
39
|
+
export * from './setting.model';
|
|
40
|
+
export * from './shop-access-control.model';
|
|
41
|
+
export * from './shop-category.model';
|
|
42
|
+
export * from './shop-meal-plan.model';
|
|
43
|
+
export * from './shop-product.model';
|
|
44
|
+
export * from './shop-review.model';
|
|
45
|
+
export * from './shop.model';
|
|
46
|
+
export * from './subscription-setting.model';
|
|
47
|
+
export * from './subscription.model';
|
|
48
|
+
export * from './tag.model';
|
|
49
|
+
export * from './transaction.model';
|
|
50
|
+
export * from './zone.model';
|
|
51
|
+
export * from './providers/buy1-get1-marketing.model';
|
|
52
|
+
export * from './providers/core-apple-auth-identity.model';
|
|
53
|
+
export * from './providers/core-email-auth-identity.model';
|
|
54
|
+
export * from './providers/core-google-auth-identity.model';
|
|
55
|
+
export * from './providers/core-phone-auth-identity.model';
|
|
56
|
+
export * from './providers/custom-coupon.model';
|
|
57
|
+
export * from './providers/discount-marketing.model';
|
|
58
|
+
export * from './providers/featured-marketing.model';
|
|
59
|
+
export * from './providers/free-delivery-marketing.model';
|
|
60
|
+
export * from './providers/global-coupon.model';
|
|
61
|
+
export * from './providers/individual-store-coupon.model';
|
|
62
|
+
export * from './providers/individual-user-coupon.model';
|
|
63
|
+
export * from './providers/loyalty-point-marketing.model';
|
|
64
|
+
export * from './providers/punch-marketing.model';
|
|
65
|
+
export * from './providers/referral-code-coupon.model';
|
|
66
|
+
export * from './providers/referral-reward-coupon.model';
|
|
@@ -14,21 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AdminAccessControlModel = exports.AdminModel = void 0;
|
|
18
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
19
|
-
const admin_model_1 = require("./admin.model");
|
|
20
|
-
const admin_access_control_model_1 = require("./admin-access-control.model");
|
|
21
|
-
exports.AdminModel = (0, typegoose_1.getModelForClass)(admin_model_1.Admin);
|
|
22
|
-
exports.AdminAccessControlModel = (0, typegoose_1.getModelForClass)(admin_access_control_model_1.AdminAccessControl);
|
|
23
17
|
__exportStar(require("./activity-log.model"), exports);
|
|
24
|
-
__exportStar(require("./admin.model"), exports);
|
|
25
18
|
__exportStar(require("./admin-access-control.model"), exports);
|
|
19
|
+
__exportStar(require("./admin.model"), exports);
|
|
26
20
|
__exportStar(require("./app-screen-setting.model"), exports);
|
|
27
21
|
__exportStar(require("./attribute.model"), exports);
|
|
28
22
|
__exportStar(require("./banner.model"), exports);
|
|
29
23
|
__exportStar(require("./bob-finance.model"), exports);
|
|
30
24
|
__exportStar(require("./brand.model"), exports);
|
|
31
25
|
__exportStar(require("./category.model"), exports);
|
|
26
|
+
__exportStar(require("./core-auth-identity.model"), exports);
|
|
27
|
+
__exportStar(require("./core-user.model"), exports);
|
|
32
28
|
__exportStar(require("./counter.model"), exports);
|
|
33
29
|
__exportStar(require("./coupon.model"), exports);
|
|
34
30
|
__exportStar(require("./deal-setting.model"), exports);
|
|
@@ -69,6 +65,10 @@ __exportStar(require("./tag.model"), exports);
|
|
|
69
65
|
__exportStar(require("./transaction.model"), exports);
|
|
70
66
|
__exportStar(require("./zone.model"), exports);
|
|
71
67
|
__exportStar(require("./providers/buy1-get1-marketing.model"), exports);
|
|
68
|
+
__exportStar(require("./providers/core-apple-auth-identity.model"), exports);
|
|
69
|
+
__exportStar(require("./providers/core-email-auth-identity.model"), exports);
|
|
70
|
+
__exportStar(require("./providers/core-google-auth-identity.model"), exports);
|
|
71
|
+
__exportStar(require("./providers/core-phone-auth-identity.model"), exports);
|
|
72
72
|
__exportStar(require("./providers/custom-coupon.model"), exports);
|
|
73
73
|
__exportStar(require("./providers/discount-marketing.model"), exports);
|
|
74
74
|
__exportStar(require("./providers/featured-marketing.model"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/mongo/models/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/mongo/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,+DAA6C;AAC7C,gDAA8B;AAC9B,6DAA2C;AAC3C,oDAAkC;AAClC,iDAA+B;AAC/B,sDAAoC;AACpC,gDAA8B;AAC9B,mDAAiC;AACjC,6DAA2C;AAC3C,oDAAkC;AAClC,kDAAgC;AAChC,iDAA+B;AAC/B,uDAAqC;AACrC,+CAA6B;AAC7B,8CAA4B;AAC5B,oDAAkC;AAClC,2DAAyC;AACzC,2DAAyC;AACzC,yDAAuC;AACvC,iEAA+C;AAC/C,gEAA8C;AAC9C,oDAAkC;AAClC,oDAAkC;AAClC,uDAAqC;AACrC,oDAAkC;AAClC,gDAA8B;AAC9B,iDAA+B;AAC/B,iDAA+B;AAC/B,4DAA0C;AAC1C,kDAAgC;AAChC,kEAAgD;AAChD,yDAAuC;AACvC,2DAAyC;AACzC,uDAAqC;AACrC,uDAAqC;AACrC,gDAA8B;AAC9B,+CAA6B;AAC7B,kDAAgC;AAChC,8DAA4C;AAC5C,wDAAsC;AACtC,yDAAuC;AACvC,uDAAqC;AACrC,sDAAoC;AACpC,+CAA6B;AAC7B,+DAA6C;AAC7C,uDAAqC;AACrC,8CAA4B;AAC5B,sDAAoC;AACpC,+CAA6B;AAC7B,wEAAsD;AACtD,6EAA2D;AAC3D,6EAA2D;AAC3D,8EAA4D;AAC5D,6EAA2D;AAC3D,kEAAgD;AAChD,uEAAqD;AACrD,uEAAqD;AACrD,4EAA0D;AAC1D,kEAAgD;AAChD,4EAA0D;AAC1D,2EAAyD;AACzD,4EAA0D;AAC1D,oEAAkD;AAClD,yEAAuD;AACvD,2EAAyD","sourcesContent":["export * from './activity-log.model';\r\nexport * from './admin-access-control.model';\r\nexport * from './admin.model';\r\nexport * from './app-screen-setting.model';\r\nexport * from './attribute.model';\r\nexport * from './banner.model';\r\nexport * from './bob-finance.model';\r\nexport * from './brand.model';\r\nexport * from './category.model';\r\nexport * from './core-auth-identity.model';\r\nexport * from './core-user.model';\r\nexport * from './counter.model';\r\nexport * from './coupon.model';\r\nexport * from './deal-setting.model';\r\nexport * from './dish.model';\r\nexport * from './faq.model';\r\nexport * from './favourite.model';\r\nexport * from './featured-setting.model';\r\nexport * from './filter-container.model';\r\nexport * from './list-container.model';\r\nexport * from './loyalty-point-category.model';\r\nexport * from './loyalty-point-setting.model';\r\nexport * from './marketing.model';\r\nexport * from './meal-plan.model';\r\nexport * from './notification.model';\r\nexport * from './nutrition.model';\r\nexport * from './order.model';\r\nexport * from './parent.model';\r\nexport * from './payout.model';\r\nexport * from './product-marketing.model';\r\nexport * from './product.model';\r\nexport * from './punch-marketing-history.model';\r\nexport * from './rating-setting.model';\r\nexport * from './referral-setting.model';\r\nexport * from './request-area.model';\r\nexport * from './rider-review.model';\r\nexport * from './rider.model';\r\nexport * from './role.model';\r\nexport * from './setting.model';\r\nexport * from './shop-access-control.model';\r\nexport * from './shop-category.model';\r\nexport * from './shop-meal-plan.model';\r\nexport * from './shop-product.model';\r\nexport * from './shop-review.model';\r\nexport * from './shop.model';\r\nexport * from './subscription-setting.model';\r\nexport * from './subscription.model';\r\nexport * from './tag.model';\r\nexport * from './transaction.model';\r\nexport * from './zone.model';\r\nexport * from './providers/buy1-get1-marketing.model';\r\nexport * from './providers/core-apple-auth-identity.model';\r\nexport * from './providers/core-email-auth-identity.model';\r\nexport * from './providers/core-google-auth-identity.model';\r\nexport * from './providers/core-phone-auth-identity.model';\r\nexport * from './providers/custom-coupon.model';\r\nexport * from './providers/discount-marketing.model';\r\nexport * from './providers/featured-marketing.model';\r\nexport * from './providers/free-delivery-marketing.model';\r\nexport * from './providers/global-coupon.model';\r\nexport * from './providers/individual-store-coupon.model';\r\nexport * from './providers/individual-user-coupon.model';\r\nexport * from './providers/loyalty-point-marketing.model';\r\nexport * from './providers/punch-marketing.model';\r\nexport * from './providers/referral-code-coupon.model';\r\nexport * from './providers/referral-reward-coupon.model';\r\n\r\n"]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Schema, Model } from
|
|
2
|
-
import { ReturnModelType
|
|
3
|
-
import { AnyParamConstructor } from
|
|
4
|
-
import { FilterDTO } from "../../../utilities/validation";
|
|
1
|
+
import { Schema, Model } from 'mongoose';
|
|
2
|
+
import { ReturnModelType } from '@typegoose/typegoose';
|
|
3
|
+
import { AnyParamConstructor } from '@typegoose/typegoose/lib/types';
|
|
5
4
|
export interface SoftDeleteModel<T> extends Model<T> {
|
|
6
|
-
softDelete(
|
|
7
|
-
softDeleteMany(filter?:
|
|
8
|
-
restore(
|
|
9
|
-
restoreMany(filter?:
|
|
10
|
-
findWithDeleted(filter?:
|
|
11
|
-
findDeleted(filter?:
|
|
5
|
+
softDelete(id: string): Promise<any>;
|
|
6
|
+
softDeleteMany(filter?: any): Promise<any>;
|
|
7
|
+
restore(id: string): Promise<any>;
|
|
8
|
+
restoreMany(filter?: any): Promise<any>;
|
|
9
|
+
findWithDeleted(filter?: any): any;
|
|
10
|
+
findDeleted(filter?: any): any;
|
|
12
11
|
}
|
|
13
12
|
export declare class SoftDeleteBase {
|
|
14
13
|
deletedAt?: Date | null;
|
|
@@ -8,7 +8,7 @@ class SoftDeleteBase {
|
|
|
8
8
|
exports.SoftDeleteBase = SoftDeleteBase;
|
|
9
9
|
class SoftDelete {
|
|
10
10
|
static applyToSchema(schema) {
|
|
11
|
-
if (!schema.path(
|
|
11
|
+
if (!schema.path('deletedAt')) {
|
|
12
12
|
schema.add({
|
|
13
13
|
deletedAt: {
|
|
14
14
|
type: Date,
|
|
@@ -22,7 +22,7 @@ class SoftDelete {
|
|
|
22
22
|
this.addStaticMethods(schema);
|
|
23
23
|
}
|
|
24
24
|
static applyGlobally() {
|
|
25
|
-
const mongoose = require(
|
|
25
|
+
const mongoose = require('mongoose');
|
|
26
26
|
mongoose.plugin((schema) => this.applyToSchema(schema));
|
|
27
27
|
}
|
|
28
28
|
static createModel(modelClass) {
|
|
@@ -35,17 +35,17 @@ class SoftDelete {
|
|
|
35
35
|
this.where({ deletedAt: null });
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
schema.pre(
|
|
39
|
-
schema.pre(
|
|
40
|
-
schema.pre(
|
|
41
|
-
schema.pre(
|
|
42
|
-
schema.pre(
|
|
43
|
-
schema.pre(
|
|
44
|
-
schema.pre(
|
|
45
|
-
schema.pre(
|
|
46
|
-
schema.pre(
|
|
47
|
-
schema.statics.findById = function (
|
|
48
|
-
return this.findOne({ _id, deletedAt: null }, projection, options);
|
|
38
|
+
schema.pre('find', queryMiddleware);
|
|
39
|
+
schema.pre('findOne', queryMiddleware);
|
|
40
|
+
schema.pre('findOneAndUpdate', queryMiddleware);
|
|
41
|
+
schema.pre('findOneAndDelete', queryMiddleware);
|
|
42
|
+
schema.pre('findOneAndReplace', queryMiddleware);
|
|
43
|
+
schema.pre('updateOne', queryMiddleware);
|
|
44
|
+
schema.pre('updateMany', queryMiddleware);
|
|
45
|
+
schema.pre('count', queryMiddleware);
|
|
46
|
+
schema.pre('countDocuments', queryMiddleware);
|
|
47
|
+
schema.statics.findById = function (id, projection, options) {
|
|
48
|
+
return this.findOne({ _id: id, deletedAt: null }, projection, options);
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
static addInstanceMethods(schema) {
|
|
@@ -59,15 +59,15 @@ class SoftDelete {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
static addStaticMethods(schema) {
|
|
62
|
-
schema.statics.softDelete = async function (
|
|
63
|
-
const result = await this.updateOne({ _id }, { deletedAt: new Date() });
|
|
62
|
+
schema.statics.softDelete = async function (id) {
|
|
63
|
+
const result = await this.updateOne({ _id: id }, { deletedAt: new Date() });
|
|
64
64
|
return result.modifiedCount > 0;
|
|
65
65
|
};
|
|
66
66
|
schema.statics.softDeleteMany = function (filter = {}) {
|
|
67
67
|
return this.updateMany(filter, { deletedAt: new Date() });
|
|
68
68
|
};
|
|
69
|
-
schema.statics.restore = function (
|
|
70
|
-
return this.updateOne({ _id }, { deletedAt: null });
|
|
69
|
+
schema.statics.restore = function (id) {
|
|
70
|
+
return this.updateOne({ _id: id }, { deletedAt: null });
|
|
71
71
|
};
|
|
72
72
|
schema.statics.restoreMany = function (filter = {}) {
|
|
73
73
|
return this.updateMany(filter, { deletedAt: null });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAyE;AAkBzE,MAAa,cAAc;IACzB,SAAS,CAAe;CACzB;AAFD,wCAEC;AAKD,MAAa,UAAU;IAKd,MAAM,CAAC,aAAa,CAAC,MAAc;QAExC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC;gBACT,SAAS,EAAE;oBACT,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;QAGD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAKM,MAAM,CAAC,aAAa;QACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACrC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CA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,GAAG,EAAE;YACnD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,UAAS,MAAM,GAAG,EAAE;YAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC;CACF;AA3HD,gCA2HC;AAGM,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAA9E,QAAA,gBAAgB,oBAA8D;AACpF,MAAM,qBAAqB,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;AAA/D,QAAA,qBAAqB,yBAA0C;AACrE,MAAM,qBAAqB,GAAG,CACnC,UAAkC,EAC4B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\r\nimport { getModelForClass, ReturnModelType } from '@typegoose/typegoose';\r\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\r\n\r\n/**\r\n * Interface for models with soft delete capabilities\r\n */\r\nexport interface SoftDeleteModel<T> extends Model<T> {\r\n softDelete(id: string): Promise<any>;\r\n softDeleteMany(filter?: any): Promise<any>;\r\n restore(id: string): Promise<any>;\r\n restoreMany(filter?: any): Promise<any>;\r\n findWithDeleted(filter?: any): any;\r\n findDeleted(filter?: any): any;\r\n}\r\n\r\n/**\r\n * Base class for models with soft delete functionality\r\n */\r\nexport class SoftDeleteBase {\r\n deletedAt?: Date | null;\r\n}\r\n\r\n/**\r\n * SoftDelete class providing soft deletion functionality for mongoose models\r\n */\r\nexport class SoftDelete {\r\n /**\r\n * Apply soft delete plugin to a specific schema\r\n * @param schema Mongoose schema to enhance with soft delete functionality\r\n */\r\n public static applyToSchema(schema: Schema): void {\r\n // Add deletedAt field if it doesn't exist\r\n if (!schema.path('deletedAt')) {\r\n schema.add({\r\n deletedAt: {\r\n type: Date,\r\n default: null,\r\n index: true,\r\n },\r\n });\r\n }\r\n\r\n // Add schema middleware\r\n this.addQueryMiddleware(schema);\r\n \r\n // Add instance methods\r\n this.addInstanceMethods(schema);\r\n \r\n // Add static methods\r\n this.addStaticMethods(schema);\r\n }\r\n\r\n /**\r\n * Apply soft delete plugin globally to all mongoose schemas\r\n */\r\n public static applyGlobally(): void {\r\n const mongoose = require('mongoose');\r\n mongoose.plugin((schema: Schema) => this.applyToSchema(schema));\r\n }\r\n\r\n /**\r\n * Create a model with soft delete capabilities and proper TypeScript types\r\n * @param modelClass The class to create a model from\r\n * @returns A model with soft delete functionality\r\n */\r\n public static createModel<T extends SoftDeleteBase>(\r\n modelClass: AnyParamConstructor<T>\r\n ): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\r\n const model = getModelForClass(modelClass);\r\n return model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\r\n }\r\n\r\n /**\r\n * Add query middleware to filter out soft-deleted documents\r\n * @param schema Schema to add middleware to\r\n */\r\n private static addQueryMiddleware(schema: Schema): void {\r\n const queryMiddleware = function(this: Query<any, any>) {\r\n if (!this.getQuery().deletedAt) {\r\n this.where({ deletedAt: null });\r\n }\r\n };\r\n\r\n // Apply middleware to relevant query methods\r\n schema.pre('find', queryMiddleware);\r\n schema.pre('findOne', queryMiddleware);\r\n schema.pre('findOneAndUpdate', queryMiddleware);\r\n schema.pre('findOneAndDelete', queryMiddleware);\r\n schema.pre('findOneAndReplace', queryMiddleware);\r\n schema.pre('updateOne', queryMiddleware);\r\n schema.pre('updateMany', queryMiddleware);\r\n // TypeScript workaround for count hook\r\n (schema as any).pre('count', queryMiddleware);\r\n schema.pre('countDocuments', queryMiddleware);\r\n\r\n // Override findById to respect soft delete\r\n schema.statics.findById = function(id: any, projection?: any, options?: any) {\r\n return this.findOne({ _id: id, deletedAt: null }, projection, options);\r\n };\r\n }\r\n\r\n /**\r\n * Add instance methods for soft delete operations\r\n * @param schema Schema to add methods to\r\n */\r\n private static addInstanceMethods(schema: Schema): void {\r\n schema.methods.softDelete = function() {\r\n this.deletedAt = new Date();\r\n return this.save();\r\n };\r\n\r\n schema.methods.restore = function() {\r\n this.deletedAt = null;\r\n return this.save();\r\n };\r\n }\r\n\r\n /**\r\n * Add static methods for soft delete operations\r\n * @param schema Schema to add methods to\r\n */\r\n private static addStaticMethods(schema: Schema): void {\r\n schema.statics.softDelete = async function(id: string) {\r\n \r\n const result = await this.updateOne({ _id: id }, { deletedAt: new Date() });\r\n return result.modifiedCount > 0;\r\n };\r\n\r\n schema.statics.softDeleteMany = function(filter = {}) {\r\n return this.updateMany(filter, { deletedAt: new Date() });\r\n };\r\n\r\n schema.statics.restore = function(id: string) {\r\n return this.updateOne({ _id: id }, { deletedAt: null });\r\n };\r\n\r\n schema.statics.restoreMany = function(filter = {}) {\r\n return this.updateMany(filter, { deletedAt: null });\r\n };\r\n\r\n schema.statics.findWithDeleted = function(filter = {}) {\r\n return this.find(filter);\r\n };\r\n\r\n schema.statics.findDeleted = function(filter = {}) {\r\n return this.find({ ...filter, deletedAt: { $ne: null } });\r\n };\r\n }\r\n}\r\n\r\n// Export convenience functions with the same names as before for backward compatibility\r\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\r\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\r\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\r\n modelClass: AnyParamConstructor<T>\r\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);"]}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
-
interface CorsOptions {
|
|
3
|
-
origin?: string | string[];
|
|
4
|
-
methods?: string[];
|
|
5
|
-
allowedHeaders?: string[];
|
|
6
|
-
exposedHeaders?: string[];
|
|
7
|
-
credentials?: boolean;
|
|
8
|
-
maxAge?: number;
|
|
9
|
-
preflightContinue?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function corsMiddleware(options?: CorsOptions): (req: IncomingMessage, res: ServerResponse, next: () => void) => void;
|
|
12
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.corsMiddleware = corsMiddleware;
|
|
4
|
-
function corsMiddleware(options = {}) {
|
|
5
|
-
const config = {
|
|
6
|
-
origin: options.origin || '*',
|
|
7
|
-
methods: options.methods || ['GET, POST, OPTIONS'],
|
|
8
|
-
allowedHeaders: options.allowedHeaders || ['Content-Type', 'Authorization', 'X-Requested-With'],
|
|
9
|
-
exposedHeaders: options.exposedHeaders || ['Content-Range', 'X-Content-Range'],
|
|
10
|
-
credentials: options.credentials || false,
|
|
11
|
-
maxAge: options.maxAge || 86400,
|
|
12
|
-
preflightContinue: options.preflightContinue || false
|
|
13
|
-
};
|
|
14
|
-
const methodsString = Array.isArray(config.methods) ? config.methods.join(', ') : config.methods;
|
|
15
|
-
const allowedHeadersString = Array.isArray(config.allowedHeaders) ? config.allowedHeaders.join(', ') : config.allowedHeaders;
|
|
16
|
-
const exposedHeadersString = Array.isArray(config.exposedHeaders) ? config.exposedHeaders.join(', ') : config.exposedHeaders;
|
|
17
|
-
return (req, res, next) => {
|
|
18
|
-
try {
|
|
19
|
-
res.setHeader('Access-Control-Allow-Origin', config.origin);
|
|
20
|
-
if (config.origin !== 'none') {
|
|
21
|
-
res.setHeader('Access-Control-Allow-Methods', methodsString);
|
|
22
|
-
res.setHeader('Access-Control-Allow-Headers', allowedHeadersString);
|
|
23
|
-
if (exposedHeadersString) {
|
|
24
|
-
res.setHeader('Access-Control-Expose-Headers', exposedHeadersString);
|
|
25
|
-
}
|
|
26
|
-
if (config.credentials) {
|
|
27
|
-
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
28
|
-
}
|
|
29
|
-
if (config.maxAge) {
|
|
30
|
-
res.setHeader('Access-Control-Max-Age', config.maxAge.toString());
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (req.method === 'OPTIONS') {
|
|
34
|
-
res.writeHead(204);
|
|
35
|
-
res.end();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
next();
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error('CORS middleware error:', error);
|
|
42
|
-
next();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=cors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/cors.ts"],"names":[],"mappings":";;AAqBA,wCAyDC;AAzDD,SAAgB,cAAc,CAAC,UAAuB,EAAE;IAEtD,MAAM,MAAM,GAA0B;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG;QAC7B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,oBAAoB,CAAC;QAClD,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC,cAAc,EAAE,eAAe,EAAE,kBAAkB,CAAC;QAC/F,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC;QAC9E,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;QAC/B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,KAAK;KACtD,CAAC;IAGF,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,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AAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACnB,GAAG,CAAC,GAAG,EAAE,CAAC;gBACV,OAAO;YACT,CAAC;YAGD,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAE/C,IAAI,EAAE,CAAC;QACT,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'http';\r\n\r\n/**\r\n * Interface for CORS middleware options\r\n */\r\ninterface CorsOptions {\r\n origin?: string | string[];\r\n methods?: string[];\r\n allowedHeaders?: string[];\r\n exposedHeaders?: string[];\r\n credentials?: boolean;\r\n maxAge?: number;\r\n preflightContinue?: boolean;\r\n}\r\n\r\n/**\r\n * Creates a configurable CORS middleware for tRPC applications\r\n * \r\n * @param options Configuration options for CORS\r\n * @returns A middleware function for handling CORS\r\n */\r\nexport function corsMiddleware(options: CorsOptions = {}) {\r\n // Default configuration with sensible values\r\n const config: Required<CorsOptions> = {\r\n origin: options.origin || '*',\r\n methods: options.methods || ['GET, POST, OPTIONS'],\r\n allowedHeaders: options.allowedHeaders || ['Content-Type', 'Authorization', 'X-Requested-With'],\r\n exposedHeaders: options.exposedHeaders || ['Content-Range', 'X-Content-Range'],\r\n credentials: options.credentials || false,\r\n maxAge: options.maxAge || 86400, // 24 hours\r\n preflightContinue: options.preflightContinue || false\r\n };\r\n\r\n // Convert arrays to comma-separated strings for header values\r\n const methodsString = Array.isArray(config.methods) ? config.methods.join(', ') : config.methods;\r\n const allowedHeadersString = Array.isArray(config.allowedHeaders) ? config.allowedHeaders.join(', ') : config.allowedHeaders;\r\n const exposedHeadersString = Array.isArray(config.exposedHeaders) ? config.exposedHeaders.join(', ') : config.exposedHeaders;\r\n\r\n // Return the middleware function\r\n return (req: IncomingMessage, res: ServerResponse, next: () => void) => {\r\n try {\r\n // Always set the CORS headers\r\n res.setHeader('Access-Control-Allow-Origin', config.origin);\r\n \r\n // Only set other headers if origin is not blocking the request\r\n if (config.origin !== 'none') {\r\n res.setHeader('Access-Control-Allow-Methods', methodsString);\r\n res.setHeader('Access-Control-Allow-Headers', allowedHeadersString);\r\n \r\n if (exposedHeadersString) {\r\n res.setHeader('Access-Control-Expose-Headers', exposedHeadersString);\r\n }\r\n \r\n if (config.credentials) {\r\n res.setHeader('Access-Control-Allow-Credentials', 'true');\r\n }\r\n \r\n if (config.maxAge) {\r\n res.setHeader('Access-Control-Max-Age', config.maxAge.toString());\r\n }\r\n }\r\n\r\n // Handle OPTIONS preflight requests\r\n if (req.method === 'OPTIONS') {\r\n res.writeHead(204); // 204 No Content is more appropriate for preflight\r\n res.end();\r\n return;\r\n }\r\n\r\n // Move to the next middleware\r\n next();\r\n } catch (error) {\r\n // Handle any errors that might occur\r\n console.error('CORS middleware error:', error);\r\n // Call next without the error as it expects no arguments\r\n next();\r\n }\r\n };\r\n}"]}
|