@lyxa.ai/core 1.1.76 → 1.1.78
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/product.model.js +4 -0
- package/dist/libraries/mongo/models/product.model.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +2 -78
- package/dist/types/utilities/validation/global-validation.d.ts +14 -38
- package/dist/utilities/id-generator.d.ts +4 -0
- package/dist/utilities/id-generator.js +79 -9
- package/dist/utilities/id-generator.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +2 -78
- package/dist/utilities/validation/global-validation.d.ts +14 -38
- package/package.json +1 -1
|
@@ -213,4 +213,8 @@ exports.Product = Product = __decorate([
|
|
|
213
213
|
}),
|
|
214
214
|
(0, typegoose_1.plugin)(normalize_field_plugin_1.normalizeFieldPlugin, { field: 'name' })
|
|
215
215
|
], Product);
|
|
216
|
+
_1.ProductModel.schema.pre('insertMany', async function (next, docs) {
|
|
217
|
+
await (0, id_generator_1.assignIdsToDocuments)(_1.CounterModel, enum_1.CounterType.ITEM, docs, 'productId');
|
|
218
|
+
next();
|
|
219
|
+
});
|
|
216
220
|
//# sourceMappingURL=product.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmF;AACnF,4EAAqE;AACrE,kDAOiC;AACjC,gFAAsE;AACtE,6CAAoC;AACpC,4EAAkE;AAClE,wEAA8D;AAC9D,+DAAqD;AACrD,wBAAiE;AACjE,0EAA2E;AAE3E,8EAAyE;AACzE,kEAA6D;AAC7D,0EAAgE;AA2BzD,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,2BAAU;IAE/B,SAAS,CAAS;IAGlB,IAAI,C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,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IACzG,IAAA,iBAAK,EAAC,EAAE,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC9E,IAAA,eAAG,EAAU,MAAM,EAAE,KAAK,WAAW,IAAI;QAEzC,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,eAAY,EAAE;YACtD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;SAC/B,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAU,MAAM,EAAE,KAAK;QAC1B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,GAAG,MAAM,IAAA,yBAAU,EAAC,eAAY,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;IACF,CAAC,CAAC;IACD,IAAA,kBAAM,EAAC,6CAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;GACnC,OAAO,CAsGnB","sourcesContent":["import { Index, modelOptions, plugin, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tProductType,\n\tItemType,\n\tProductDietaryType,\n\tStatus,\n\tPriceOption,\n\tCounterType,\n} from '../../../utilities/enum';\nimport { ProductNutrition } from './embedded/product-nutrition.model';\nimport { Shop } from './shop.model';\nimport { PriceBreakdown } from './embedded/price-breakdown.model';\nimport { AttributeMap } from './embedded/attribute-map.model';\nimport { ShopCategory } from './shop-category.model';\nimport { CounterModel, ProductMarketing, ProductModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { normalizeFieldPlugin } from '../plugins/normalize-field.plugin';\nimport { generateId } from '../../../utilities/id-generator';\nimport { PreparingTime } from './embedded/preparing-time.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'products', toJSON: { virtuals: true }, toObject: { virtuals: true } },\n})\n@Index(\n\t{ nameNormalized: 1, shop: 1, shopCategory: 1 },\n\t{ unique: true, partialFilterExpression: { deletedAt: null } }\n)\n@Index({ shop: 1, shopCategory: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ shop: 1, isStockEnabled: 1, stockQuantity: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ nameNormalized: 1 }, { partialFilterExpression: { deletedAt: null } })\n@pre<Product>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ProductModel, {\n\t\tshop: this.shop,\n\t\tshopCategory: this.shopCategory,\n\t});\n\n\tnext();\n})\n@pre<Product>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.productId = await generateId(CounterModel, CounterType.ITEM);\n\t}\n})\n@plugin(normalizeFieldPlugin, { field: 'name' })\nexport class Product extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic productId: string;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String, trim: true, maxlength: 100 })\n\tpublic name!: string;\n\n\t@prop({ type: String, trim: true, lowercase: true, select: false })\n\tpublic nameNormalized?: string;\n\n\t@prop({ type: String, trim: true, maxlength: 50 })\n\tpublic barcode?: string;\n\n\t@prop({ required: true, ref: () => ShopCategory })\n\tpublic shopCategory!: Ref<ShopCategory>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic description?: string;\n\n\t@prop({ type: [AttributeMap], default: [] })\n\tpublic attributeMaps?: AttributeMap[];\n\n\t@prop({ ref: () => Product, default: [] })\n\tpublic addons?: Ref<Product>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNutritionEnabled?: boolean;\n\n\t@prop({ type: Number, min: 0 })\n\tpublic nutritionPackSize?: number;\n\n\t@prop({ type: String })\n\tpublic nutritionPackSizeUnit?: string;\n\n\t@prop({ type: [ProductNutrition], default: [] })\n\tpublic nutritions?: ProductNutrition[];\n\n\t@prop({ type: [String], enum: ProductDietaryType, default: [] })\n\tpublic dietaryTypes?: ProductDietaryType[];\n\n\t@prop({ type: Number, min: -9999, max: 9999 })\n\tpublic storedTemperature?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number, max: 999999999 }) // isStockEnabled: true and stockQuantity < 1 means out of stock\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLargeItem?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPreOrderEnabled?: boolean;\n\n\t// this field needed when pre-order enabled\n\t@prop({ type: PreparingTime })\n\tpublic preparingTime?: PreparingTime;\n\n\t@prop({ type: Number, min: 0, max: 999999999 }) // 0 means, it is disable\n\tpublic orderQuantityLimit?: number;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'product',\n\t\tlocalField: '_id',\n\t\tjustOne: true,\n\t})\n\tpublic productMarketing: Ref<ProductMarketing>; // Virtual reference to ProductMarket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,kBAAW,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAC9E,IAAI,EAAE,CAAC;AACR,CAAC,CAAC,CAAC","sourcesContent":["import { Index, modelOptions, plugin, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tProductType,\n\tItemType,\n\tProductDietaryType,\n\tStatus,\n\tPriceOption,\n\tCounterType,\n} from '../../../utilities/enum';\nimport { ProductNutrition } from './embedded/product-nutrition.model';\nimport { Shop } from './shop.model';\nimport { PriceBreakdown } from './embedded/price-breakdown.model';\nimport { AttributeMap } from './embedded/attribute-map.model';\nimport { ShopCategory } from './shop-category.model';\nimport { CounterModel, ProductMarketing, ProductModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { normalizeFieldPlugin } from '../plugins/normalize-field.plugin';\nimport { assignIdsToDocuments, generateId } from '../../../utilities/id-generator';\nimport { PreparingTime } from './embedded/preparing-time.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'products', toJSON: { virtuals: true }, toObject: { virtuals: true } },\n})\n@Index(\n\t{ nameNormalized: 1, shop: 1, shopCategory: 1 },\n\t{ unique: true, partialFilterExpression: { deletedAt: null } }\n)\n@Index({ shop: 1, shopCategory: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ shop: 1, isStockEnabled: 1, stockQuantity: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ nameNormalized: 1 }, { partialFilterExpression: { deletedAt: null } })\n@pre<Product>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ProductModel, {\n\t\tshop: this.shop,\n\t\tshopCategory: this.shopCategory,\n\t});\n\n\tnext();\n})\n@pre<Product>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.productId = await generateId(CounterModel, CounterType.ITEM);\n\t}\n})\n@plugin(normalizeFieldPlugin, { field: 'name' })\nexport class Product extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic productId: string;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String, trim: true, maxlength: 100 })\n\tpublic name!: string;\n\n\t@prop({ type: String, trim: true, lowercase: true, select: false })\n\tpublic nameNormalized?: string;\n\n\t@prop({ type: String, trim: true, maxlength: 50 })\n\tpublic barcode?: string;\n\n\t@prop({ required: true, ref: () => ShopCategory })\n\tpublic shopCategory!: Ref<ShopCategory>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic description?: string;\n\n\t@prop({ type: [AttributeMap], default: [] })\n\tpublic attributeMaps?: AttributeMap[];\n\n\t@prop({ ref: () => Product, default: [] })\n\tpublic addons?: Ref<Product>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNutritionEnabled?: boolean;\n\n\t@prop({ type: Number, min: 0 })\n\tpublic nutritionPackSize?: number;\n\n\t@prop({ type: String })\n\tpublic nutritionPackSizeUnit?: string;\n\n\t@prop({ type: [ProductNutrition], default: [] })\n\tpublic nutritions?: ProductNutrition[];\n\n\t@prop({ type: [String], enum: ProductDietaryType, default: [] })\n\tpublic dietaryTypes?: ProductDietaryType[];\n\n\t@prop({ type: Number, min: -9999, max: 9999 })\n\tpublic storedTemperature?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number, max: 999999999 }) // isStockEnabled: true and stockQuantity < 1 means out of stock\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLargeItem?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPreOrderEnabled?: boolean;\n\n\t// this field needed when pre-order enabled\n\t@prop({ type: PreparingTime })\n\tpublic preparingTime?: PreparingTime;\n\n\t@prop({ type: Number, min: 0, max: 999999999 }) // 0 means, it is disable\n\tpublic orderQuantityLimit?: number;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'product',\n\t\tlocalField: '_id',\n\t\tjustOne: true,\n\t})\n\tpublic productMarketing: Ref<ProductMarketing>; // Virtual reference to ProductMarketing\n}\n\nProductModel.schema.pre('insertMany', async function (next, docs: Product[]) {\n\t// Generate all IDs at once (ATOMIC)\n\tawait assignIdsToDocuments(CounterModel, CounterType.ITEM, docs, 'productId');\n\tnext();\n});\n"]}
|
|
@@ -32,7 +32,7 @@ export declare class User extends TimeStamps {
|
|
|
32
32
|
isPhoneVerified?: boolean;
|
|
33
33
|
onlineStatus?: OnlineStatus;
|
|
34
34
|
fcmTokens?: string[];
|
|
35
|
-
static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject> & Omit<User & {
|
|
35
|
+
static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject, {}> & Omit<User & {
|
|
36
36
|
_id: import("mongoose").Types.ObjectId;
|
|
37
37
|
} & {
|
|
38
38
|
__v: number;
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -646,7 +646,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
646
646
|
totalPages: number;
|
|
647
647
|
} | undefined;
|
|
648
648
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
649
|
-
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.
|
|
649
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
|
|
650
650
|
success: z.ZodBoolean;
|
|
651
651
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
652
652
|
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
@@ -684,83 +684,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
684
684
|
totalPages: number;
|
|
685
685
|
} | undefined;
|
|
686
686
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
687
|
-
}
|
|
688
|
-
success: z.ZodBoolean;
|
|
689
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
690
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
691
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
692
|
-
page: z.ZodNumber;
|
|
693
|
-
size: z.ZodNumber;
|
|
694
|
-
totalElements: z.ZodNumber;
|
|
695
|
-
totalPages: z.ZodNumber;
|
|
696
|
-
}, "strip", z.ZodTypeAny, {
|
|
697
|
-
size: number;
|
|
698
|
-
page: number;
|
|
699
|
-
totalElements: number;
|
|
700
|
-
totalPages: number;
|
|
701
|
-
}, {
|
|
702
|
-
size: number;
|
|
703
|
-
page: number;
|
|
704
|
-
totalElements: number;
|
|
705
|
-
totalPages: number;
|
|
706
|
-
}>>;
|
|
707
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
708
|
-
}, "strip", z.ZodTypeAny, {
|
|
709
|
-
documents: T[];
|
|
710
|
-
metadata?: {
|
|
711
|
-
size: number;
|
|
712
|
-
page: number;
|
|
713
|
-
totalElements: number;
|
|
714
|
-
totalPages: number;
|
|
715
|
-
} | undefined;
|
|
716
|
-
}, {
|
|
717
|
-
documents: T[];
|
|
718
|
-
metadata?: {
|
|
719
|
-
size: number;
|
|
720
|
-
page: number;
|
|
721
|
-
totalElements: number;
|
|
722
|
-
totalPages: number;
|
|
723
|
-
} | undefined;
|
|
724
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
725
|
-
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
|
|
726
|
-
success: z.ZodBoolean;
|
|
727
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
728
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
729
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
730
|
-
page: z.ZodNumber;
|
|
731
|
-
size: z.ZodNumber;
|
|
732
|
-
totalElements: z.ZodNumber;
|
|
733
|
-
totalPages: z.ZodNumber;
|
|
734
|
-
}, "strip", z.ZodTypeAny, {
|
|
735
|
-
size: number;
|
|
736
|
-
page: number;
|
|
737
|
-
totalElements: number;
|
|
738
|
-
totalPages: number;
|
|
739
|
-
}, {
|
|
740
|
-
size: number;
|
|
741
|
-
page: number;
|
|
742
|
-
totalElements: number;
|
|
743
|
-
totalPages: number;
|
|
744
|
-
}>>;
|
|
745
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
746
|
-
}, "strip", z.ZodTypeAny, {
|
|
747
|
-
documents: T[];
|
|
748
|
-
metadata?: {
|
|
749
|
-
size: number;
|
|
750
|
-
page: number;
|
|
751
|
-
totalElements: number;
|
|
752
|
-
totalPages: number;
|
|
753
|
-
} | undefined;
|
|
754
|
-
}, {
|
|
755
|
-
documents: T[];
|
|
756
|
-
metadata?: {
|
|
757
|
-
size: number;
|
|
758
|
-
page: number;
|
|
759
|
-
totalElements: number;
|
|
760
|
-
totalPages: number;
|
|
761
|
-
} | undefined;
|
|
762
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
763
|
-
}>[k_1]; } : never>;
|
|
687
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
764
688
|
export type PaginatedDTO<T> = {
|
|
765
689
|
metadata: DTO<typeof metadataSchema>;
|
|
766
690
|
documents: T[];
|
|
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
76
76
|
private baseSchema;
|
|
77
77
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
78
78
|
private createBaseSchema;
|
|
79
|
-
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
79
|
+
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
80
80
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
81
81
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
82
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
82
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
83
83
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
84
|
-
}>[k]>; } : never,
|
|
84
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
85
85
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
86
|
-
}> extends infer
|
|
87
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
88
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
89
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
90
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
91
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
92
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
86
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
93
87
|
getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
94
88
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
95
89
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
96
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
97
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
98
|
-
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
99
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
100
|
-
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
101
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
102
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
90
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
103
91
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
104
|
-
}> extends infer
|
|
92
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
105
93
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
106
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
94
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
107
95
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
108
96
|
}, "strict", z.ZodTypeAny, {
|
|
109
97
|
[x: string]: any;
|
|
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
126
114
|
[x: string]: any;
|
|
127
115
|
}>;
|
|
128
116
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
129
|
-
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
117
|
+
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
130
118
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
131
119
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
132
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
120
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
133
121
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
134
|
-
}>[k_2]>; } : never,
|
|
122
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
135
123
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
136
|
-
}> extends infer
|
|
137
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
138
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
139
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
140
|
-
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
141
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
142
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
124
|
+
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
143
125
|
IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
144
126
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
145
127
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
146
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
147
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
148
|
-
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
149
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
150
|
-
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
151
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
152
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
128
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
153
129
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
154
|
-
}> extends infer
|
|
130
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
155
131
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
156
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
132
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
157
133
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
158
134
|
}, "strict", z.ZodTypeAny, {
|
|
159
135
|
[x: string]: any;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { CounterType } from './enum';
|
|
2
2
|
export declare function generateId(CounterModel: any, counterType: CounterType): Promise<string>;
|
|
3
|
+
export declare function generateBulkIds(CounterModel: any, counterType: CounterType, count: number): Promise<string[]>;
|
|
4
|
+
export declare function ensureUniqueId(CounterModel: any, counterType: CounterType, currentId?: string): Promise<string>;
|
|
5
|
+
export declare function assignBulkIds(CounterModel: any, counterType: CounterType, documents: any[], idFieldName?: string): Promise<void>;
|
|
6
|
+
export declare function assignIdsToDocuments(CounterModel: any, counterType: CounterType, documents: any[], idFieldName: string): Promise<void>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateId = generateId;
|
|
4
|
+
exports.generateBulkIds = generateBulkIds;
|
|
5
|
+
exports.ensureUniqueId = ensureUniqueId;
|
|
6
|
+
exports.assignBulkIds = assignBulkIds;
|
|
7
|
+
exports.assignIdsToDocuments = assignIdsToDocuments;
|
|
4
8
|
const enum_1 = require("./enum");
|
|
5
9
|
function incrementLetters(letters) {
|
|
6
10
|
const chars = letters.split('');
|
|
@@ -8,7 +12,6 @@ function incrementLetters(letters) {
|
|
|
8
12
|
for (let i = chars.length - 1; i >= 0 && carry; i--) {
|
|
9
13
|
if (chars[i] === 'Z') {
|
|
10
14
|
chars[i] = 'A';
|
|
11
|
-
carry = true;
|
|
12
15
|
}
|
|
13
16
|
else {
|
|
14
17
|
chars[i] = String.fromCharCode(chars[i].charCodeAt(0) + 1);
|
|
@@ -66,22 +69,89 @@ function getPrefixForType(counterType) {
|
|
|
66
69
|
[enum_1.CounterType.SHOP]: 'S',
|
|
67
70
|
[enum_1.CounterType.ITEM]: 'I',
|
|
68
71
|
[enum_1.CounterType.TRANSACTION]: 'T',
|
|
72
|
+
[enum_1.CounterType.ORDER]: 'O',
|
|
73
|
+
[enum_1.CounterType.CRM_NUMBER]: 'C',
|
|
74
|
+
[enum_1.CounterType.PAYOUT]: 'Y',
|
|
75
|
+
[enum_1.CounterType.TICKET]: 'K',
|
|
69
76
|
};
|
|
70
77
|
return prefixMap[counterType] || 'X';
|
|
71
78
|
}
|
|
72
79
|
async function generateId(CounterModel, counterType) {
|
|
73
80
|
const prefix = getPrefixForType(counterType);
|
|
74
81
|
const initialCore = 'A0001';
|
|
75
|
-
|
|
76
|
-
$setOnInsert: { core: initialCore },
|
|
77
|
-
}, {
|
|
82
|
+
const result = await CounterModel.findOneAndUpdate({ counterType }, { $setOnInsert: { core: initialCore } }, {
|
|
78
83
|
upsert: true,
|
|
79
|
-
new:
|
|
84
|
+
new: false,
|
|
80
85
|
setDefaultsOnInsert: true,
|
|
81
86
|
}).lean();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
if (!result) {
|
|
88
|
+
await CounterModel.findOneAndUpdate({ counterType }, { $set: { core: getNextCore(initialCore) } }).lean();
|
|
89
|
+
return `${prefix}${initialCore}`;
|
|
90
|
+
}
|
|
91
|
+
const currentCore = result.core;
|
|
92
|
+
const nextCore = getNextCore(currentCore);
|
|
93
|
+
const updated = await CounterModel.findOneAndUpdate({ counterType, core: currentCore }, { $set: { core: nextCore } }, { new: false }).lean();
|
|
94
|
+
if (!updated) {
|
|
95
|
+
return generateId(CounterModel, counterType);
|
|
96
|
+
}
|
|
97
|
+
return `${prefix}${currentCore}`;
|
|
98
|
+
}
|
|
99
|
+
async function generateBulkIds(CounterModel, counterType, count) {
|
|
100
|
+
if (count <= 0)
|
|
101
|
+
return [];
|
|
102
|
+
const prefix = getPrefixForType(counterType);
|
|
103
|
+
const initialCore = 'A0001';
|
|
104
|
+
const result = await CounterModel.findOneAndUpdate({ counterType }, { $setOnInsert: { core: initialCore } }, {
|
|
105
|
+
upsert: true,
|
|
106
|
+
new: false,
|
|
107
|
+
setDefaultsOnInsert: true,
|
|
108
|
+
}).lean();
|
|
109
|
+
let startCore;
|
|
110
|
+
if (!result) {
|
|
111
|
+
startCore = initialCore;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
startCore = result.core;
|
|
115
|
+
}
|
|
116
|
+
const ids = [];
|
|
117
|
+
let currentCore = startCore;
|
|
118
|
+
for (let i = 0; i < count; i++) {
|
|
119
|
+
ids.push(`${prefix}${currentCore}`);
|
|
120
|
+
currentCore = getNextCore(currentCore);
|
|
121
|
+
}
|
|
122
|
+
const updated = await CounterModel.findOneAndUpdate({ counterType, core: startCore }, { $set: { core: currentCore } }, { new: false }).lean();
|
|
123
|
+
if (!updated && result) {
|
|
124
|
+
return generateBulkIds(CounterModel, counterType, count);
|
|
125
|
+
}
|
|
126
|
+
return ids;
|
|
127
|
+
}
|
|
128
|
+
async function ensureUniqueId(CounterModel, counterType, currentId) {
|
|
129
|
+
if (currentId)
|
|
130
|
+
return currentId;
|
|
131
|
+
return generateId(CounterModel, counterType);
|
|
132
|
+
}
|
|
133
|
+
async function assignBulkIds(CounterModel, counterType, documents, idFieldName = 'productId') {
|
|
134
|
+
const docsNeedingIds = documents.filter(doc => !doc[idFieldName]);
|
|
135
|
+
if (docsNeedingIds.length === 0)
|
|
136
|
+
return;
|
|
137
|
+
const ids = await generateBulkIds(CounterModel, counterType, docsNeedingIds.length);
|
|
138
|
+
let idIndex = 0;
|
|
139
|
+
for (const doc of documents) {
|
|
140
|
+
if (!doc[idFieldName]) {
|
|
141
|
+
doc[idFieldName] = ids[idIndex++];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function assignIdsToDocuments(CounterModel, counterType, documents, idFieldName) {
|
|
146
|
+
const docsNeedingIds = documents.filter(doc => !doc[idFieldName]);
|
|
147
|
+
if (docsNeedingIds.length === 0)
|
|
148
|
+
return;
|
|
149
|
+
const ids = await generateBulkIds(CounterModel, counterType, docsNeedingIds.length);
|
|
150
|
+
let idIndex = 0;
|
|
151
|
+
for (const doc of documents) {
|
|
152
|
+
if (!doc[idFieldName]) {
|
|
153
|
+
doc[idFieldName] = ids[idIndex++];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
86
156
|
}
|
|
87
157
|
//# sourceMappingURL=id-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-generator.js","sourceRoot":"/","sources":["utilities/id-generator.ts"],"names":[],"mappings":";;AAqHA,gCAyBC;AA9ID,iCAAqC;AAGrC,SAAS,gBAAgB,CAAC,OAAe;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,IAAI,KAAK,GAAG,IAAI,CAAC;IAGjB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACf,KAAK,GAAG,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3D,KAAK,GAAG,KAAK,CAAC;QACf,CAAC;IACF,CAAC;IAGD,IAAI,KAAK,EAAE,CAAC;QACX,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC;AAMD,SAAS,WAAW,CAAC,IAAY;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAGhC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,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AE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAG1G,OAAO,GAAG,MAAM,GAAG,WAAW,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { CounterType } from './enum';\n\n\nfunction incrementLetters(letters: string): string {\n\tconst chars = letters.split('');\n\tlet carry = true;\n\n\t// Increment from right to left\n\tfor (let i = chars.length - 1; i >= 0 && carry; i--) {\n\t\tif (chars[i] === 'Z') {\n\t\t\tchars[i] = 'A';\n\t\t\tcarry = true; // Carry continues\n\t\t} else {\n\t\t\tchars[i] = String.fromCharCode(chars[i].charCodeAt(0) + 1);\n\t\t\tcarry = false;\n\t\t}\n\t}\n\n\t// If still carrying (e.g., 'Z' or 'ZZZ'), add a new letter 'A'\n\tif (carry) {\n\t\treturn 'A' + chars.join('');\n\t}\n\n\treturn chars.join('');\n}\n\n/**\n * Get the next core value following your leveling rules.\n * Example: A0001 → ... → Z9999 → AA001 → ... → ZZZZZ → A00001\n */\nfunction getNextCore(core: string): string {\n\tconst totalLength = core.length;\n\n\t// Parse as letters + optional numbers\n\tconst match = core.match(/^([A-Z]+)(\\d*)$/);\n\tif (!match) throw new Error(`Invalid core format: ${core}`);\n\n\tlet letters = match[1];\n\tlet numbers = match[2];\n\n\t// --- SCENARIO 1: All Letters (e.g., AAAAA or ZZZZZ) ---\n\tif (numbers === '') {\n\t\t// If it's the max combination for this length (e.g., ZZZZZ)\n\t\tif (letters === 'Z'.repeat(totalLength)) {\n\t\t\t// FIX: ZZZZZ (Length 5) → A00001 (Length 6).\n\t\t\t// Need (CurrentLength - 1) zeros before the final '1'.\n\t\t\t// totalLength is 5, so we need 4 zeros.\n\t\t\treturn 'A' + '0'.repeat(totalLength - 1) + '1';\n\t\t}\n\n\t\t// Otherwise, it's just an all-letter increment (e.g., AAAAA → AAAAB)\n\t\treturn incrementLetters(letters);\n\t}\n\n\t// --- SCENARIO 2: Letters + Numbers (e.g., A0001) ---\n\n\tlet numValue = parseInt(numbers, 10);\n\tconst numLength = numbers.length;\n\t// const maxNum = parseInt('9'.repeat(numLength), 10);\n\tconst maxNum = Math.pow(10, numLength) - 1;\n\n\t// 1. Increment number first\n\tnumValue++;\n\n\t// 2. If number overflows, reset and increment letters\n\tif (numValue > maxNum) {\n\t\tnumValue = 1;\n\n\t\tconst oldLettersLength = letters.length;\n\t\tletters = incrementLetters(letters);\n\t\tconst newLettersLength = letters.length;\n\n\t\t// Check if the letter increment caused the letter length to expand (e.g., Z → AA)\n\t\tif (newLettersLength > oldLettersLength) {\n\t\t\t// The number of available digits must decrease to maintain total length\n\t\t\tconst letterExpansion = newLettersLength - oldLettersLength;\n\t\t\tconst newNumLength = numLength - letterExpansion;\n\n\t\t\t// If the number of digits is reduced to 0 or less (e.g., ZZZZ9 → AAAAA)\n\t\t\tif (newNumLength <= 0) {\n\t\t\t\tif (newLettersLength === totalLength) {\n\t\t\t\t\treturn letters; // Return the all-letter core (e.g., AAAAA)\n\t\t\t\t}\n\n\t\t\t\tif (newLettersLength > totalLength) {\n\t\t\t\t\treturn 'A'.repeat(totalLength);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If new number length is positive, pad the number (which is currently 1)\n\t\t\treturn letters + '1'.padStart(newNumLength, '0');\n\t\t}\n\t}\n\n\t// 3. Normal increment (A0001 → A0002) or letter carry-over without expansion (AA999 → AB001)\n\treturn letters + numValue.toString().padStart(numLength, '0');\n}\n\n// ----------------------------------------------------------------------\n\n/**\n * Get prefix for a counter type (Robust version)\n */\nfunction getPrefixForType(counterType: CounterType): string {\n\tconst prefixMap: Record<string, string> = {\n\t\t[CounterType.USER]: 'U',\n\t\t[CounterType.RIDER]: 'R',\n\t\t[CounterType.PARENT]: 'P',\n\t\t[CounterType.SHOP]: 'S',\n\t\t[CounterType.ITEM]: 'I',\n\t\t[CounterType.TRANSACTION]: 'T',\n\t};\n\t// Ensure a string is always returned\n\treturn prefixMap[counterType] || 'X';\n}\n\n\nexport async function generateId(CounterModel: any, counterType: CounterType): Promise<string> {\n\tconst prefix = getPrefixForType(counterType);\n\tconst initialCore = 'A0001';\n\n\t// 1. Fetch the current state OR initialize it.\n\tlet currentDoc = await CounterModel.findOneAndUpdate(\n\t\t{ counterType },\n\t\t{\n\t\t\t$setOnInsert: { core: initialCore },\n\t\t},\n\t\t{\n\t\t\tupsert: true,\n\t\t\tnew: true, // Returns the current DB state after potential insertion\n\t\t\tsetDefaultsOnInsert: true,\n\t\t}\n\t).lean();\n\n\tconst coreToIssue = currentDoc.core;\n\tconst nextCore = getNextCore(coreToIssue);\n\n\t// 2. Unconditionally update the counter to the next value.\n\tawait CounterModel.findOneAndUpdate({ counterType }, { $set: { core: nextCore } }, { new: false }).lean();\n\n\t// 3. Return the ID based on the value read in Step 1.\n\treturn `${prefix}${coreToIssue}`;\n}\n\n// ----------------------------------------------------------------------\n\n"]}
|
|
1
|
+
{"version":3,"file":"id-generator.js","sourceRoot":"/","sources":["utilities/id-generator.ts"],"names":[],"mappings":";;AAkGA,gCAsCC;AAMD,0CAoDC;AAMD,wCAUC;AAMD,sCAqBC;AAMD,oDAqBC;AAxQD,iCAAqC;AAErC,SAAS,gBAAgB,CAAC,OAAe;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,IAAI,KAAK,GAAG,IAAI,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChB,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC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,MAAM,CAAC,CAAC;IAGpF,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { CounterType } from './enum';\n\nfunction incrementLetters(letters: string): string {\n\tconst chars = letters.split('');\n\tlet carry = true;\n\n\tfor (let i = chars.length - 1; i >= 0 && carry; i--) {\n\t\tif (chars[i] === 'Z') {\n\t\t\tchars[i] = 'A';\n\t\t} else {\n\t\t\tchars[i] = String.fromCharCode(chars[i].charCodeAt(0) + 1);\n\t\t\tcarry = false;\n\t\t}\n\t}\n\n\tif (carry) {\n\t\treturn 'A' + chars.join('');\n\t}\n\n\treturn chars.join('');\n}\n\n/**\n * Get the next core value following your leveling rules.\n * Example: A0001 → ... → Z9999 → AA001 → ... → ZZZZZ → A00001\n */\nfunction getNextCore(core: string): string {\n\tconst totalLength = core.length;\n\n\tconst match = core.match(/^([A-Z]+)(\\d*)$/);\n\tif (!match) throw new Error(`Invalid core format: ${core}`);\n\n\tlet letters = match[1];\n\tlet numbers = match[2];\n\n\t// SCENARIO 1: All Letters (e.g., AAAAA or ZZZZZ)\n\tif (numbers === '') {\n\t\tif (letters === 'Z'.repeat(totalLength)) {\n\t\t\treturn 'A' + '0'.repeat(totalLength - 1) + '1';\n\t\t}\n\t\treturn incrementLetters(letters);\n\t}\n\n\t// SCENARIO 2: Letters + Numbers\n\tlet numValue = parseInt(numbers, 10);\n\tconst numLength = numbers.length;\n\tconst maxNum = Math.pow(10, numLength) - 1;\n\n\tnumValue++;\n\n\tif (numValue > maxNum) {\n\t\tnumValue = 1;\n\t\tconst oldLettersLength = letters.length;\n\t\tletters = incrementLetters(letters);\n\t\tconst newLettersLength = letters.length;\n\n\t\tif (newLettersLength > oldLettersLength) {\n\t\t\tconst letterExpansion = newLettersLength - oldLettersLength;\n\t\t\tconst newNumLength = numLength - letterExpansion;\n\n\t\t\tif (newNumLength <= 0) {\n\t\t\t\tif (newLettersLength === totalLength) {\n\t\t\t\t\treturn letters;\n\t\t\t\t}\n\t\t\t\tif (newLettersLength > totalLength) {\n\t\t\t\t\treturn 'A'.repeat(totalLength);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn letters + '1'.padStart(newNumLength, '0');\n\t\t}\n\t}\n\n\treturn letters + numValue.toString().padStart(numLength, '0');\n}\n\n/**\n * Get prefix for a counter type\n */\nfunction getPrefixForType(counterType: CounterType): string {\n\tconst prefixMap: Record<string, string> = {\n\t\t[CounterType.USER]: 'U',\n\t\t[CounterType.RIDER]: 'R',\n\t\t[CounterType.PARENT]: 'P',\n\t\t[CounterType.SHOP]: 'S',\n\t\t[CounterType.ITEM]: 'I',\n\t\t[CounterType.TRANSACTION]: 'T',\n\t\t[CounterType.ORDER]: 'O',\n\t\t[CounterType.CRM_NUMBER]: 'C',\n\t\t[CounterType.PAYOUT]: 'Y',\n\t\t[CounterType.TICKET]: 'K',\n\t};\n\treturn prefixMap[counterType] || 'X';\n}\n\n/**\n * Generate a single unique ID (ATOMIC operation)\n */\nexport async function generateId(CounterModel: any, counterType: CounterType): Promise<string> {\n\tconst prefix = getPrefixForType(counterType);\n\tconst initialCore = 'A0001';\n\n\t// ATOMIC operation: findOneAndUpdate with $setOnInsert\n\tconst result = await CounterModel.findOneAndUpdate(\n\t\t{ counterType },\n\t\t{ $setOnInsert: { core: initialCore } },\n\t\t{\n\t\t\tupsert: true,\n\t\t\tnew: false, // Return OLD document (before increment)\n\t\t\tsetDefaultsOnInsert: true,\n\t\t}\n\t).lean();\n\n\t// If this is first time, result will be null (document was just created)\n\tif (!result) {\n\t\t// Document was just created with initialCore, so we need to increment it\n\t\tawait CounterModel.findOneAndUpdate({ counterType }, { $set: { core: getNextCore(initialCore) } }).lean();\n\t\treturn `${prefix}${initialCore}`;\n\t}\n\n\tconst currentCore = result.core;\n\tconst nextCore = getNextCore(currentCore);\n\n\t// ATOMIC increment with retry logic\n\tconst updated = await CounterModel.findOneAndUpdate(\n\t\t{ counterType, core: currentCore },\n\t\t{ $set: { core: nextCore } },\n\t\t{ new: false }\n\t).lean();\n\n\t// If update failed (race condition), retry\n\tif (!updated) {\n\t\treturn generateId(CounterModel, counterType);\n\t}\n\n\treturn `${prefix}${currentCore}`;\n}\n\n/**\n * Generate multiple unique IDs in BULK (for insertMany scenarios)\n * This reserves a range of IDs atomically to prevent duplicates\n */\nexport async function generateBulkIds(\n\tCounterModel: any,\n\tcounterType: CounterType,\n\tcount: number\n): Promise<string[]> {\n\tif (count <= 0) return [];\n\n\tconst prefix = getPrefixForType(counterType);\n\tconst initialCore = 'A0001';\n\n\t// ATOMIC operation: Reserve 'count' IDs at once\n\tconst result = await CounterModel.findOneAndUpdate(\n\t\t{ counterType },\n\t\t{ $setOnInsert: { core: initialCore } },\n\t\t{\n\t\t\tupsert: true,\n\t\t\tnew: false, // Return OLD document\n\t\t\tsetDefaultsOnInsert: true,\n\t\t}\n\t).lean();\n\n\tlet startCore: string;\n\n\tif (!result) {\n\t\t// First time initialization\n\t\tstartCore = initialCore;\n\t} else {\n\t\tstartCore = result.core;\n\t}\n\n\t// Generate the sequence of cores\n\tconst ids: string[] = [];\n\tlet currentCore = startCore;\n\n\tfor (let i = 0; i < count; i++) {\n\t\tids.push(`${prefix}${currentCore}`);\n\t\tcurrentCore = getNextCore(currentCore);\n\t}\n\n\t// Update the counter to the final core value ATOMICALLY\n\tconst updated = await CounterModel.findOneAndUpdate(\n\t\t{ counterType, core: startCore },\n\t\t{ $set: { core: currentCore } },\n\t\t{ new: false }\n\t).lean();\n\n\t// If update failed (race condition), retry the entire operation\n\tif (!updated && result) {\n\t\treturn generateBulkIds(CounterModel, counterType, count);\n\t}\n\n\treturn ids;\n}\n\n/**\n * Helper function to use in pre-save hooks\n * Safe for both single saves and bulk operations\n */\nexport async function ensureUniqueId(\n\tCounterModel: any,\n\tcounterType: CounterType,\n\tcurrentId?: string\n): Promise<string> {\n\t// If ID already exists, return it (for updates)\n\tif (currentId) return currentId;\n\n\t// Generate new ID\n\treturn generateId(CounterModel, counterType);\n}\n\n/**\n * Assign unique IDs to documents before insertMany\n * Use this in pre('insertMany') hooks\n */\nexport async function assignBulkIds(\n\tCounterModel: any,\n\tcounterType: CounterType,\n\tdocuments: any[],\n\tidFieldName: string = 'productId'\n): Promise<void> {\n\t// Count how many documents need IDs\n\tconst docsNeedingIds = documents.filter(doc => !doc[idFieldName]);\n\n\tif (docsNeedingIds.length === 0) return;\n\n\t// Generate bulk IDs\n\tconst ids = await generateBulkIds(CounterModel, counterType, docsNeedingIds.length);\n\n\t// Assign IDs to documents that need them\n\tlet idIndex = 0;\n\tfor (const doc of documents) {\n\t\tif (!doc[idFieldName]) {\n\t\t\tdoc[idFieldName] = ids[idIndex++];\n\t\t}\n\t}\n}\n\n/**\n * Assign IDs to documents before bulk insert\n * Call this in insertMany hooks\n */\nexport async function assignIdsToDocuments(\n\tCounterModel: any,\n\tcounterType: CounterType,\n\tdocuments: any[],\n\tidFieldName: string\n): Promise<void> {\n\t// Count documents that need IDs\n\tconst docsNeedingIds = documents.filter(doc => !doc[idFieldName]);\n\n\tif (docsNeedingIds.length === 0) return;\n\n\t// Generate all IDs at once (ATOMIC)\n\tconst ids = await generateBulkIds(CounterModel, counterType, docsNeedingIds.length);\n\n\t// Assign IDs to documents\n\tlet idIndex = 0;\n\tfor (const doc of documents) {\n\t\tif (!doc[idFieldName]) {\n\t\t\tdoc[idFieldName] = ids[idIndex++];\n\t\t}\n\t}\n}\n"]}
|
|
@@ -646,7 +646,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
646
646
|
totalPages: number;
|
|
647
647
|
} | undefined;
|
|
648
648
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
649
|
-
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.
|
|
649
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
|
|
650
650
|
success: z.ZodBoolean;
|
|
651
651
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
652
652
|
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
@@ -684,83 +684,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
684
684
|
totalPages: number;
|
|
685
685
|
} | undefined;
|
|
686
686
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
687
|
-
}
|
|
688
|
-
success: z.ZodBoolean;
|
|
689
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
690
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
691
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
692
|
-
page: z.ZodNumber;
|
|
693
|
-
size: z.ZodNumber;
|
|
694
|
-
totalElements: z.ZodNumber;
|
|
695
|
-
totalPages: z.ZodNumber;
|
|
696
|
-
}, "strip", z.ZodTypeAny, {
|
|
697
|
-
page: number;
|
|
698
|
-
size: number;
|
|
699
|
-
totalElements: number;
|
|
700
|
-
totalPages: number;
|
|
701
|
-
}, {
|
|
702
|
-
page: number;
|
|
703
|
-
size: number;
|
|
704
|
-
totalElements: number;
|
|
705
|
-
totalPages: number;
|
|
706
|
-
}>>;
|
|
707
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
708
|
-
}, "strip", z.ZodTypeAny, {
|
|
709
|
-
documents: T[];
|
|
710
|
-
metadata?: {
|
|
711
|
-
page: number;
|
|
712
|
-
size: number;
|
|
713
|
-
totalElements: number;
|
|
714
|
-
totalPages: number;
|
|
715
|
-
} | undefined;
|
|
716
|
-
}, {
|
|
717
|
-
documents: T[];
|
|
718
|
-
metadata?: {
|
|
719
|
-
page: number;
|
|
720
|
-
size: number;
|
|
721
|
-
totalElements: number;
|
|
722
|
-
totalPages: number;
|
|
723
|
-
} | undefined;
|
|
724
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
725
|
-
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
|
|
726
|
-
success: z.ZodBoolean;
|
|
727
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
728
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
729
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
730
|
-
page: z.ZodNumber;
|
|
731
|
-
size: z.ZodNumber;
|
|
732
|
-
totalElements: z.ZodNumber;
|
|
733
|
-
totalPages: z.ZodNumber;
|
|
734
|
-
}, "strip", z.ZodTypeAny, {
|
|
735
|
-
page: number;
|
|
736
|
-
size: number;
|
|
737
|
-
totalElements: number;
|
|
738
|
-
totalPages: number;
|
|
739
|
-
}, {
|
|
740
|
-
page: number;
|
|
741
|
-
size: number;
|
|
742
|
-
totalElements: number;
|
|
743
|
-
totalPages: number;
|
|
744
|
-
}>>;
|
|
745
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
746
|
-
}, "strip", z.ZodTypeAny, {
|
|
747
|
-
documents: T[];
|
|
748
|
-
metadata?: {
|
|
749
|
-
page: number;
|
|
750
|
-
size: number;
|
|
751
|
-
totalElements: number;
|
|
752
|
-
totalPages: number;
|
|
753
|
-
} | undefined;
|
|
754
|
-
}, {
|
|
755
|
-
documents: T[];
|
|
756
|
-
metadata?: {
|
|
757
|
-
page: number;
|
|
758
|
-
size: number;
|
|
759
|
-
totalElements: number;
|
|
760
|
-
totalPages: number;
|
|
761
|
-
} | undefined;
|
|
762
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
763
|
-
}>[k_1]; } : never>;
|
|
687
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
764
688
|
export type PaginatedDTO<T> = {
|
|
765
689
|
metadata: DTO<typeof metadataSchema>;
|
|
766
690
|
documents: T[];
|
|
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
76
76
|
private baseSchema;
|
|
77
77
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
78
78
|
private createBaseSchema;
|
|
79
|
-
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
79
|
+
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
80
80
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
81
81
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
82
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
82
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
83
83
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
84
|
-
}>[k]>; } : never,
|
|
84
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
85
85
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
86
|
-
}> extends infer
|
|
87
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
88
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
89
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
90
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
91
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
92
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
86
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
93
87
|
getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
94
88
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
95
89
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
96
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
97
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
98
|
-
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
99
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
100
|
-
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
101
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
102
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
90
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
103
91
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
104
|
-
}> extends infer
|
|
92
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
105
93
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
106
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
94
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
107
95
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
108
96
|
}, "strict", z.ZodTypeAny, {
|
|
109
97
|
[x: string]: any;
|
|
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
126
114
|
[x: string]: any;
|
|
127
115
|
}>;
|
|
128
116
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
129
|
-
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
117
|
+
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
130
118
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
131
119
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
132
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
120
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
133
121
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
134
|
-
}>[k_2]>; } : never,
|
|
122
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
135
123
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
136
|
-
}> extends infer
|
|
137
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
138
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
139
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
140
|
-
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
141
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
142
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
124
|
+
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
143
125
|
IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
144
126
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
145
127
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
146
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
147
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
148
|
-
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
149
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
150
|
-
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
151
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
152
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
128
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
153
129
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
154
|
-
}> extends infer
|
|
130
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
155
131
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
156
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
132
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
157
133
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
158
134
|
}, "strict", z.ZodTypeAny, {
|
|
159
135
|
[x: string]: any;
|