@lyxa.ai/core 1.0.342 → 1.0.343
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/finance-settlement.model.d.ts +1 -0
- package/dist/libraries/mongo/models/finance-settlement.model.js +12 -1
- package/dist/libraries/mongo/models/finance-settlement.model.js.map +1 -1
- package/dist/libraries/mongo/utilities/uniqueIdHooks.d.ts +1 -1
- package/dist/libraries/mongo/utilities/uniqueIdHooks.js +2 -2
- package/dist/libraries/mongo/utilities/uniqueIdHooks.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { User } from './user.model';
|
|
|
8
8
|
import { Admin } from './admin.model';
|
|
9
9
|
import { Parent } from './parent.model';
|
|
10
10
|
export declare class FinanceSettlement extends TimeStamps {
|
|
11
|
+
settlementId: string;
|
|
11
12
|
accountType: AccountType;
|
|
12
13
|
order?: Ref<Order>;
|
|
13
14
|
parent?: Ref<Parent>;
|
|
@@ -19,7 +19,10 @@ const enum_1 = require("../../../utilities/enum");
|
|
|
19
19
|
const user_model_1 = require("./user.model");
|
|
20
20
|
const admin_model_1 = require("./admin.model");
|
|
21
21
|
const parent_model_1 = require("./parent.model");
|
|
22
|
+
const uniqueIdHooks_1 = require("../utilities/uniqueIdHooks");
|
|
23
|
+
const _1 = require(".");
|
|
22
24
|
let FinanceSettlement = class FinanceSettlement extends defaultClasses_1.TimeStamps {
|
|
25
|
+
settlementId;
|
|
23
26
|
accountType;
|
|
24
27
|
order;
|
|
25
28
|
parent;
|
|
@@ -39,6 +42,10 @@ let FinanceSettlement = class FinanceSettlement extends defaultClasses_1.TimeSta
|
|
|
39
42
|
adminNote;
|
|
40
43
|
};
|
|
41
44
|
exports.FinanceSettlement = FinanceSettlement;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typegoose_1.prop)({ type: String, unique: true, index: true }),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], FinanceSettlement.prototype, "settlementId", void 0);
|
|
42
49
|
__decorate([
|
|
43
50
|
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.AccountType }),
|
|
44
51
|
__metadata("design:type", String)
|
|
@@ -110,6 +117,10 @@ __decorate([
|
|
|
110
117
|
exports.FinanceSettlement = FinanceSettlement = __decorate([
|
|
111
118
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'financeSettlements' } }),
|
|
112
119
|
(0, typegoose_1.index)({ settlementType: 1, createdAt: -1 }),
|
|
113
|
-
(0, typegoose_1.index)({ accountType: 1, settlementType: 1, createdAt: -1 })
|
|
120
|
+
(0, typegoose_1.index)({ accountType: 1, settlementType: 1, createdAt: -1 }),
|
|
121
|
+
(0, typegoose_1.pre)('save', async function (next) {
|
|
122
|
+
await uniqueIdHooks_1.handlePreSaveForUniqueId.call(this, _1.FinanceSettlementModel, 'settlementId', 10);
|
|
123
|
+
next();
|
|
124
|
+
})
|
|
114
125
|
], FinanceSettlement);
|
|
115
126
|
//# sourceMappingURL=finance-settlement.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance-settlement.model.js","sourceRoot":"/","sources":["libraries/mongo/models/finance-settlement.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"finance-settlement.model.js","sourceRoot":"/","sources":["libraries/mongo/models/finance-settlement.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,+CAAsC;AACtC,6CAAoC;AACpC,+CAAsC;AACtC,kDAAgF;AAChF,6CAAoC;AACpC,+CAAsC;AACtC,iDAAwC;AACxC,8DAAsE;AACtE,wBAA2C;AAWpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,2BAAU;IAEzC,YAAY,CAAS;IAGrB,WAAW,CAAe;IAG1B,KAAK,CAAc;IAGnB,MAAM,CAAe;IAGrB,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BAAK,EAAC,EAAE,WAAW,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3D,IAAA,eAAG,EAAoB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEnD,MAAM,wCAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,yBAAsB,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;QAEtF,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,iBAAiB,CAsD7B","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Order } from './order.model';\nimport { Shop } from './shop.model';\nimport { Rider } from './rider.model';\nimport { AccountType, ItemType, SettlementType } from '../../../utilities/enum';\nimport { User } from './user.model';\nimport { Admin } from './admin.model';\nimport { Parent } from './parent.model';\nimport { handlePreSaveForUniqueId } from '../utilities/uniqueIdHooks';\nimport { FinanceSettlementModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'financeSettlements' } })\n@index({ settlementType: 1, createdAt: -1 })\n@index({ accountType: 1, settlementType: 1, createdAt: -1 })\n@pre<FinanceSettlement>('save', async function (next) {\n\t// Generate unique id if not exists\n\tawait handlePreSaveForUniqueId.call(this, FinanceSettlementModel, 'settlementId', 10);\n\n\tnext();\n})\nexport class FinanceSettlement extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic settlementId: string;\n\n\t@prop({ required: true, type: String, enum: AccountType })\n\tpublic accountType!: AccountType;\n\n\t@prop({ ref: () => Order, index: true })\n\tpublic order?: Ref<Order>;\n\n\t@prop({ ref: () => Parent, index: true })\n\tpublic parent?: Ref<Parent>;\n\n\t@prop({ ref: () => Shop, index: true })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ type: String, enum: ItemType, index: true })\n\tpublic itemType?: ItemType;\n\n\t@prop({ ref: () => Rider, index: true })\n\tpublic rider?: Ref<Rider>;\n\n\t@prop({ ref: () => User, index: true })\n\tpublic user?: Ref<User>;\n\n\t@prop({ required: true, type: String, enum: SettlementType })\n\tpublic settlementType!: SettlementType;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amountFromItems?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmountFromItems?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amountFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmountFromDelivery?: number;\n\n\t@prop({ type: String })\n\tpublic paymentIntentId?: string;\n\n\t@prop({ ref: () => Admin })\n\tpublic settleBy?: Ref<Admin>;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic adminNote?: string;\n}\n"]}
|
|
@@ -2,5 +2,5 @@ import { Document } from 'mongoose';
|
|
|
2
2
|
interface BaseDoc extends Document {
|
|
3
3
|
[field: string]: any;
|
|
4
4
|
}
|
|
5
|
-
export declare function handlePreSaveForUniqueId<T extends BaseDoc>(this: T, Model: any, field: string): Promise<void>;
|
|
5
|
+
export declare function handlePreSaveForUniqueId<T extends BaseDoc>(this: T, Model: any, field: string, length?: number): Promise<void>;
|
|
6
6
|
export {};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handlePreSaveForUniqueId = handlePreSaveForUniqueId;
|
|
4
4
|
const nanoid_1 = require("nanoid");
|
|
5
|
-
|
|
6
|
-
async function handlePreSaveForUniqueId(Model, field) {
|
|
5
|
+
async function handlePreSaveForUniqueId(Model, field, length = 6) {
|
|
7
6
|
if (this[field])
|
|
8
7
|
return;
|
|
8
|
+
const nanoid = (0, nanoid_1.customAlphabet)('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', length);
|
|
9
9
|
let uniqueId = null;
|
|
10
10
|
let exists = true;
|
|
11
11
|
while (exists) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueIdHooks.js","sourceRoot":"/","sources":["libraries/mongo/utilities/uniqueIdHooks.ts"],"names":[],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"uniqueIdHooks.js","sourceRoot":"/","sources":["libraries/mongo/utilities/uniqueIdHooks.ts"],"names":[],"mappings":";;AAiBA,4DAuBC;AAxCD,mCAAwC;AAiBjC,KAAK,UAAU,wBAAwB,CAE7C,KAAU,EACV,KAAa,EACb,MAAM,GAAG,CAAC;IAGV,IAAI,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO;IAGxB,MAAM,MAAM,GAAG,IAAA,uBAAc,EAAC,gEAAgE,EAAE,MAAM,CAAC,CAAC;IAExG,IAAI,QAAQ,GAAkB,IAAI,CAAC;IACnC,IAAI,MAAM,GAAG,IAAI,CAAC;IAGlB,OAAO,MAAM,EAAE,CAAC;QACf,QAAQ,GAAG,MAAM,EAAE,CAAC;QACpB,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAoB,CAAC,CAAC,CAAC;IAC1E,CAAC;IAGD,IAAI,CAAC,GAAG,CAAC,KAAe,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { customAlphabet } from 'nanoid';\nimport { Document, FilterQuery } from 'mongoose';\n\n// Nanoid generator: 6-character alphanumeric\n// const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 6);\n\ninterface BaseDoc extends Document {\n\t[field: string]: any; // allow dynamic field access\n}\n\n/**\n * Pre-save hook handler to ensure a unique ID for a given field\n *\n * @param this Current document being saved\n * @param Model The Mongoose model\n * @param field The field that should have a unique ID\n */\nexport async function handlePreSaveForUniqueId<T extends BaseDoc>(\n\tthis: T,\n\tModel: any,\n\tfield: string,\n\tlength = 6\n): Promise<void> {\n\t// Skip if already has a value\n\tif (this[field]) return;\n\n\t// Prepare generator dynamically\n\tconst nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', length);\n\n\tlet uniqueId: string | null = null;\n\tlet exists = true;\n\n\t// Keep generating until unique\n\twhile (exists) {\n\t\tuniqueId = nanoid();\n\t\texists = !!(await Model.exists({ [field]: uniqueId } as FilterQuery<T>));\n\t}\n\n\t// Assign the unique ID to the field\n\tthis.set(field as string, uniqueId);\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED