@kikiutils/mongoose 7.0.2 → 7.0.3
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/_internals.d.ts +0 -1
- package/dist/_internals.d.ts.map +1 -1
- package/dist/_internals.js.map +1 -1
- package/dist/assertions.d.ts +0 -1
- package/dist/assertions.d.ts.map +1 -1
- package/dist/assertions.js.map +1 -1
- package/dist/builders.d.ts +0 -1
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js.map +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/helpers.d.ts +0 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/options.d.ts +0 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js.map +1 -1
- package/dist/plugins/assertions.d.ts +0 -1
- package/dist/plugins/assertions.d.ts.map +1 -1
- package/dist/plugins/assertions.js.map +1 -1
- package/dist/plugins/normalize.d.ts +0 -1
- package/dist/plugins/normalize.d.ts.map +1 -1
- package/dist/plugins/normalize.js.map +1 -1
- package/dist/schema-builders/base.d.ts +0 -1
- package/dist/schema-builders/base.d.ts.map +1 -1
- package/dist/schema-builders/base.js +1 -1
- package/dist/schema-builders/base.js.map +1 -1
- package/dist/schema-builders/boolean.d.ts +0 -1
- package/dist/schema-builders/boolean.d.ts.map +1 -1
- package/dist/schema-builders/boolean.js.map +1 -1
- package/dist/schema-builders/date.d.ts +0 -1
- package/dist/schema-builders/date.d.ts.map +1 -1
- package/dist/schema-builders/date.js.map +1 -1
- package/dist/schema-builders/decimal128.d.ts +1 -2
- package/dist/schema-builders/decimal128.d.ts.map +1 -1
- package/dist/schema-builders/decimal128.js +1 -1
- package/dist/schema-builders/decimal128.js.map +1 -1
- package/dist/schema-builders/number.d.ts +0 -1
- package/dist/schema-builders/number.d.ts.map +1 -1
- package/dist/schema-builders/number.js.map +1 -1
- package/dist/schema-builders/object-id.d.ts +0 -1
- package/dist/schema-builders/object-id.d.ts.map +1 -1
- package/dist/schema-builders/object-id.js.map +1 -1
- package/dist/schema-builders/ref.d.ts +0 -1
- package/dist/schema-builders/ref.d.ts.map +1 -1
- package/dist/schema-builders/ref.js.map +1 -1
- package/dist/schema-builders/string.d.ts +0 -1
- package/dist/schema-builders/string.d.ts.map +1 -1
- package/dist/schema-builders/string.js.map +1 -1
- package/dist/types/_internals.d.ts.map +1 -1
- package/dist/types/aggregate-paginate.d.ts +0 -1
- package/dist/types/aggregate-paginate.d.ts.map +1 -1
- package/dist/types/data.d.ts +0 -1
- package/dist/types/data.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options.d.ts +0 -1
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/paginate.d.ts +0 -1
- package/dist/types/paginate.d.ts.map +1 -1
- package/package.json +16 -20
- package/src/schema-builders/decimal128.ts +5 -2
package/dist/_internals.d.ts
CHANGED
package/dist/_internals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internals.d.ts","names":[],"sources":["../src/_internals.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"_internals.d.ts","names":[],"sources":["../src/_internals.ts"],"mappings":";;cAEa,uBAAuB"}
|
package/dist/_internals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internals.js","names":[],"sources":["../src/_internals.ts"],"sourcesContent":["import type { CustomMongooseOptions } from './types/options';\n\nexport const customMongooseOptions: CustomMongooseOptions = {};\n"],"mappings":";AAEA,MAAa,wBAA+C,
|
|
1
|
+
{"version":3,"file":"_internals.js","names":[],"sources":["../src/_internals.ts"],"sourcesContent":["import type { CustomMongooseOptions } from './types/options';\n\nexport const customMongooseOptions: CustomMongooseOptions = {};\n"],"mappings":";AAEA,MAAa,wBAA+C,CAAC"}
|
package/dist/assertions.d.ts
CHANGED
package/dist/assertions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","names":[],"sources":["../src/assertions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","names":[],"sources":["../src/assertions.ts"],"mappings":";;iBAKsB,4BAA4B,UAAU,UACxD,eAAe,QAAQ,MAAM,aAAa,KAC1C,iCAAyB"}
|
package/dist/assertions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","names":[],"sources":["../src/assertions.ts"],"sourcesContent":["import type {\n Document,\n mongo,\n} from 'mongoose';\n\nexport async function assertMongooseUpdateSuccess<T extends Document>(\n updatePromise: Promise<mongo.UpdateResult<T>>,\n expectedModifiedCount = 1,\n) {\n const updateResult = await updatePromise;\n if (!updateResult.acknowledged) throw new Error('Update was not acknowledged');\n if (updateResult.modifiedCount < expectedModifiedCount) {\n // eslint-disable-next-line style/max-len\n throw new Error(`Expected to modify at least ${expectedModifiedCount} document(s), but modified ${updateResult.modifiedCount}`);\n }\n}\n"],"mappings":";AAKA,eAAsB,4BAClB,eACA,wBAAwB,GAC1B;CACE,MAAM,eAAe,MAAM;
|
|
1
|
+
{"version":3,"file":"assertions.js","names":[],"sources":["../src/assertions.ts"],"sourcesContent":["import type {\n Document,\n mongo,\n} from 'mongoose';\n\nexport async function assertMongooseUpdateSuccess<T extends Document>(\n updatePromise: Promise<mongo.UpdateResult<T>>,\n expectedModifiedCount = 1,\n) {\n const updateResult = await updatePromise;\n if (!updateResult.acknowledged) throw new Error('Update was not acknowledged');\n if (updateResult.modifiedCount < expectedModifiedCount) {\n // eslint-disable-next-line style/max-len\n throw new Error(`Expected to modify at least ${expectedModifiedCount} document(s), but modified ${updateResult.modifiedCount}`);\n }\n}\n"],"mappings":";AAKA,eAAsB,4BAClB,eACA,wBAAwB,GAC1B;CACE,MAAM,eAAe,MAAM;CAC3B,IAAI,CAAC,aAAa,cAAc,MAAM,IAAI,MAAM,6BAA6B;CAC7E,IAAI,aAAa,gBAAgB,uBAE7B,MAAM,IAAI,MAAM,+BAA+B,sBAAsB,6BAA6B,aAAa,eAAe;AAEtI"}
|
package/dist/builders.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { BaseMongoosePaginateModel } from "./types/index.js";
|
|
|
3
3
|
import { BuildMongooseModelOptions } from "./types/options.js";
|
|
4
4
|
import { mongooseAssertionsPlugin } from "./plugins/assertions.js";
|
|
5
5
|
import { Model, Schema } from "mongoose";
|
|
6
|
-
|
|
7
6
|
//#region src/builders.d.ts
|
|
8
7
|
type DoNotRemoveOrUseThisType = typeof mongooseAssertionsPlugin;
|
|
9
8
|
declare function buildMongooseModel<DocType, Model extends BaseMongoosePaginateModel<DocType, InstanceMethodsAndOverrides, QueryHelpers>, InstanceMethodsAndOverrides = object, QueryHelpers = object>(collection: string, name: string, schema: Schema<DocType, Model, InstanceMethodsAndOverrides, QueryHelpers>, options?: BuildMongooseModelOptions): Model;
|
package/dist/builders.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","names":[],"sources":["../src/builders.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builders.d.ts","names":[],"sources":["../src/builders.ts"],"mappings":";;;;;;KAgBY,kCAAkC;iBAE9B,mBACZ,SACA,cAAc,0BAA0B,SAAS,6BAA6B,eAC9E,sCACA,uBAEA,oBACA,cACA,QAAQ,OAAO,SAAS,OAAO,6BAA6B,eAC5D,UAAU,4BACX;iBAoBa,gCACZ,SACA,gBAAc,MAAc,SAAS,cAAc,8BACnD,sCACA,uBAEA,QAAQ,OAAO,SAAS,SAAO,6BAA6B,eAC5D,qBACA,UAAU"}
|
package/dist/builders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","names":[],"sources":["../src/builders.ts"],"sourcesContent":["import mongoose from 'mongoose';\nimport type {\n Model as MongooseModel,\n Schema,\n} from 'mongoose';\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2';\nimport mongoosePaginate from 'mongoose-paginate-v2';\n\nimport { customMongooseOptions } from './_internals';\nimport { mongooseConnections } from './constants';\nimport { mongooseAssertionsPlugin } from './plugins/assertions';\nimport { mongooseNormalizePlugin } from './plugins/normalize';\nimport type { MongooseNormalizePluginOptions } from './plugins/normalize';\nimport type { BaseMongoosePaginateModel } from './types';\nimport type { BuildMongooseModelOptions } from './types/options';\n\nexport type DoNotRemoveOrUseThisType = typeof mongooseAssertionsPlugin;\n\nexport function buildMongooseModel<\n DocType,\n Model extends BaseMongoosePaginateModel<DocType, InstanceMethodsAndOverrides, QueryHelpers>,\n InstanceMethodsAndOverrides = object,\n QueryHelpers = object,\n>(\n collection: string,\n name: string,\n schema: Schema<DocType, Model, InstanceMethodsAndOverrides, QueryHelpers>,\n options?: BuildMongooseModelOptions,\n): Model {\n if (options?.enableNormalizePlugin !== false) {\n registerMongooseNormalizePlugin(schema, options?.normalizePluginRecursive, options?.normalizePluginOptions);\n }\n\n schema.plugin(mongooseAggregatePaginate);\n schema.plugin(mongooseAssertionsPlugin);\n schema.plugin(mongoosePaginate);\n schema.set('timestamps', options?.timestamps ?? schema.get('timestamps') ?? true);\n customMongooseOptions.beforeModelBuild?.(schema);\n const connection =\n options?.connection\n || (\n mongooseConnections.default ||= mongoose.createConnection(\n process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017',\n )\n );\n\n return connection.model<DocType, Model, QueryHelpers>(name, schema, collection);\n}\nexport function registerMongooseNormalizePlugin<\n DocType,\n Model extends MongooseModel<DocType, QueryHelpers, InstanceMethodsAndOverrides>,\n InstanceMethodsAndOverrides = object,\n QueryHelpers = object,\n>(\n schema: Schema<DocType, Model, InstanceMethodsAndOverrides, QueryHelpers>,\n recursive: boolean = true,\n options?: MongooseNormalizePluginOptions,\n) {\n schema.plugin(mongooseNormalizePlugin, options);\n if (recursive) {\n schema.childSchemas.forEach(({ schema }) => registerMongooseNormalizePlugin(schema, recursive, options));\n }\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,mBAMZ,YACA,MACA,QACA,SACK;
|
|
1
|
+
{"version":3,"file":"builders.js","names":[],"sources":["../src/builders.ts"],"sourcesContent":["import mongoose from 'mongoose';\nimport type {\n Model as MongooseModel,\n Schema,\n} from 'mongoose';\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2';\nimport mongoosePaginate from 'mongoose-paginate-v2';\n\nimport { customMongooseOptions } from './_internals';\nimport { mongooseConnections } from './constants';\nimport { mongooseAssertionsPlugin } from './plugins/assertions';\nimport { mongooseNormalizePlugin } from './plugins/normalize';\nimport type { MongooseNormalizePluginOptions } from './plugins/normalize';\nimport type { BaseMongoosePaginateModel } from './types';\nimport type { BuildMongooseModelOptions } from './types/options';\n\nexport type DoNotRemoveOrUseThisType = typeof mongooseAssertionsPlugin;\n\nexport function buildMongooseModel<\n DocType,\n Model extends BaseMongoosePaginateModel<DocType, InstanceMethodsAndOverrides, QueryHelpers>,\n InstanceMethodsAndOverrides = object,\n QueryHelpers = object,\n>(\n collection: string,\n name: string,\n schema: Schema<DocType, Model, InstanceMethodsAndOverrides, QueryHelpers>,\n options?: BuildMongooseModelOptions,\n): Model {\n if (options?.enableNormalizePlugin !== false) {\n registerMongooseNormalizePlugin(schema, options?.normalizePluginRecursive, options?.normalizePluginOptions);\n }\n\n schema.plugin(mongooseAggregatePaginate);\n schema.plugin(mongooseAssertionsPlugin);\n schema.plugin(mongoosePaginate);\n schema.set('timestamps', options?.timestamps ?? schema.get('timestamps') ?? true);\n customMongooseOptions.beforeModelBuild?.(schema);\n const connection =\n options?.connection\n || (\n mongooseConnections.default ||= mongoose.createConnection(\n process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017',\n )\n );\n\n return connection.model<DocType, Model, QueryHelpers>(name, schema, collection);\n}\nexport function registerMongooseNormalizePlugin<\n DocType,\n Model extends MongooseModel<DocType, QueryHelpers, InstanceMethodsAndOverrides>,\n InstanceMethodsAndOverrides = object,\n QueryHelpers = object,\n>(\n schema: Schema<DocType, Model, InstanceMethodsAndOverrides, QueryHelpers>,\n recursive: boolean = true,\n options?: MongooseNormalizePluginOptions,\n) {\n schema.plugin(mongooseNormalizePlugin, options);\n if (recursive) {\n schema.childSchemas.forEach(({ schema }) => registerMongooseNormalizePlugin(schema, recursive, options));\n }\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,mBAMZ,YACA,MACA,QACA,SACK;CACL,IAAI,SAAS,0BAA0B,OACnC,gCAAgC,QAAQ,SAAS,0BAA0B,SAAS,sBAAsB;CAG9G,OAAO,OAAO,yBAAyB;CACvC,OAAO,OAAO,wBAAwB;CACtC,OAAO,OAAO,gBAAgB;CAC9B,OAAO,IAAI,cAAc,SAAS,cAAc,OAAO,IAAI,YAAY,KAAK,IAAI;CAChF,sBAAsB,mBAAmB,MAAM;CAS/C,QAPI,SAAS,eAEL,oBAAoB,YAAY,SAAS,iBACrC,QAAQ,IAAI,eAAe,2BAC/B,GAAA,CAGU,MAAoC,MAAM,QAAQ,UAAU;AAClF;AACA,SAAgB,gCAMZ,QACA,YAAqB,MACrB,SACF;CACE,OAAO,OAAO,yBAAyB,OAAO;CAC9C,IAAI,WACA,OAAO,aAAa,SAAS,EAAE,aAAa,gCAAgC,QAAQ,WAAW,OAAO,CAAC;AAE/G"}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;cAEa,qBAAqB"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { MongooseConnections } from './types';\n\nexport const mongooseConnections: MongooseConnections = {};\n"],"mappings":";AAEA,MAAa,sBAA2C,
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { MongooseConnections } from './types';\n\nexport const mongooseConnections: MongooseConnections = {};\n"],"mappings":";AAEA,MAAa,sBAA2C,CAAC"}
|
package/dist/helpers.d.ts
CHANGED
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../src/helpers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../src/helpers.ts"],"mappings":";;iBAEgB,oBAAoB,aAAa,MAAM"}
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { Types } from 'mongoose';\n\nexport function toObjectIdHexString(id: string | Types.ObjectId) {\n return id instanceof Types.ObjectId ? id.toHexString() : id;\n}\n"],"mappings":";;AAEA,SAAgB,oBAAoB,IAA6B;
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { Types } from 'mongoose';\n\nexport function toObjectIdHexString(id: string | Types.ObjectId) {\n return id instanceof Types.ObjectId ? id.toHexString() : id;\n}\n"],"mappings":";;AAEA,SAAgB,oBAAoB,IAA6B;CAC7D,OAAO,cAAc,MAAM,WAAW,GAAG,YAAY,IAAI;AAC7D"}
|
package/dist/options.d.ts
CHANGED
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","names":[],"sources":["../src/options.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.ts","names":[],"sources":["../src/options.ts"],"mappings":";;iBAGgB,yBAAyB,gBAAgB,uBACrD,KAAK,GACL,OAAO,sBAAsB"}
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","names":[],"sources":["../src/options.ts"],"sourcesContent":["import { customMongooseOptions } from './_internals';\nimport type { CustomMongooseOptions } from './types/options';\n\nexport function setCustomMongooseOptions<K extends keyof CustomMongooseOptions>(\n key: K,\n value: CustomMongooseOptions[K],\n) {\n customMongooseOptions[key] = value;\n}\n"],"mappings":";;AAGA,SAAgB,yBACZ,KACA,OACF;
|
|
1
|
+
{"version":3,"file":"options.js","names":[],"sources":["../src/options.ts"],"sourcesContent":["import { customMongooseOptions } from './_internals';\nimport type { CustomMongooseOptions } from './types/options';\n\nexport function setCustomMongooseOptions<K extends keyof CustomMongooseOptions>(\n key: K,\n value: CustomMongooseOptions[K],\n) {\n customMongooseOptions[key] = value;\n}\n"],"mappings":";;AAGA,SAAgB,yBACZ,KACA,OACF;CACE,sBAAsB,OAAO;AACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","names":[],"sources":["../../src/plugins/assertions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","names":[],"sources":["../../src/plugins/assertions.ts"],"mappings":";;;YAac,SACN,IAAI,MAAM,UACV,qBACA,eACA,YAAY,qBAEZ;IAEA,sBACI,SACI,YAAY,SAAS,GAAG,eAAe,SAAS,WAAW,mBAC3D,+BACJ,iBAAiB,cACjB,mCACC;;YAGC,MACN,aAEA,oBAEA,uBAEA,gBAEA,wBAAwB,iBAAiB,aAAa,mBAAmB,WAAW,eAAe,YAEnG;IAEA,sBACI,QAAQ,YAAY,cACpB,QAAQ,YAAY,eAAe,+BACnC,WAAW,MAAM,gBAAgB,2BAA2B,sBAC5D,mCACC;;;iBAIG,yBAAyB,UAAU,QAAQ,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","names":[],"sources":["../../src/plugins/assertions.ts"],"sourcesContent":["import type {\n mongo,\n MongooseUpdateQueryOptions,\n QueryFilter,\n QueryOptions,\n Schema,\n UpdateQuery,\n UpdateWithAggregationPipeline,\n} from 'mongoose';\n\nimport { assertMongooseUpdateSuccess } from '../assertions';\n\ndeclare module 'mongoose' {\n interface Document<\n T = Types.ObjectId,\n TQueryHelpers = any,\n DocType = any,\n TVirtuals = Record<string, any>,\n // eslint-disable-next-line ts/no-empty-object-type\n TSchemaOptions = {},\n > {\n assertUpdateSuccess: (\n update?:\n | UpdateQuery<Document<T, TQueryHelpers, DocType, TVirtuals, TSchemaOptions>>\n | UpdateWithAggregationPipeline,\n options?: null | QueryOptions,\n expectedModifiedCount?: number,\n ) => Promise<void>;\n }\n\n interface Model<\n TRawDocType,\n // eslint-disable-next-line ts/no-empty-object-type\n TQueryHelpers = {},\n // eslint-disable-next-line ts/no-empty-object-type\n TInstanceMethods = {},\n // eslint-disable-next-line ts/no-empty-object-type\n TVirtuals = {},\n // eslint-disable-next-line unused-imports/no-unused-vars\n THydratedDocumentType = HydratedDocument<TRawDocType, TInstanceMethods & TVirtuals, TQueryHelpers, TVirtuals>,\n // eslint-disable-next-line unused-imports/no-unused-vars\n TSchema = any,\n > {\n assertUpdateSuccess: (\n filter: QueryFilter<TRawDocType>,\n update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,\n options?: (mongo.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null,\n expectedModifiedCount?: number,\n ) => Promise<void>;\n }\n}\n\nexport function mongooseAssertionsPlugin<S extends Schema>(schema: S) {\n schema.method(\n 'assertUpdateSuccess',\n function (\n update?: UpdateQuery<any> | UpdateWithAggregationPipeline,\n options?: null | QueryOptions,\n expectedModifiedCount?: number,\n ) {\n return assertMongooseUpdateSuccess(this.updateOne(update, options), expectedModifiedCount);\n },\n );\n\n schema.static(\n 'assertUpdateSuccess',\n function (\n filter: QueryFilter<any>,\n update: UpdateQuery<any> | UpdateWithAggregationPipeline,\n options?: (mongo.UpdateOptions & MongooseUpdateQueryOptions<any>) | null,\n expectedModifiedCount: number = 1,\n ) {\n return assertMongooseUpdateSuccess(\n expectedModifiedCount === 1\n ? this.updateOne(filter, update, options)\n : this.updateMany(filter, update, options),\n expectedModifiedCount,\n );\n },\n );\n}\n"],"mappings":";;AAoDA,SAAgB,yBAA2C,QAAW;
|
|
1
|
+
{"version":3,"file":"assertions.js","names":[],"sources":["../../src/plugins/assertions.ts"],"sourcesContent":["import type {\n mongo,\n MongooseUpdateQueryOptions,\n QueryFilter,\n QueryOptions,\n Schema,\n UpdateQuery,\n UpdateWithAggregationPipeline,\n} from 'mongoose';\n\nimport { assertMongooseUpdateSuccess } from '../assertions';\n\ndeclare module 'mongoose' {\n interface Document<\n T = Types.ObjectId,\n TQueryHelpers = any,\n DocType = any,\n TVirtuals = Record<string, any>,\n // eslint-disable-next-line ts/no-empty-object-type\n TSchemaOptions = {},\n > {\n assertUpdateSuccess: (\n update?:\n | UpdateQuery<Document<T, TQueryHelpers, DocType, TVirtuals, TSchemaOptions>>\n | UpdateWithAggregationPipeline,\n options?: null | QueryOptions,\n expectedModifiedCount?: number,\n ) => Promise<void>;\n }\n\n interface Model<\n TRawDocType,\n // eslint-disable-next-line ts/no-empty-object-type\n TQueryHelpers = {},\n // eslint-disable-next-line ts/no-empty-object-type\n TInstanceMethods = {},\n // eslint-disable-next-line ts/no-empty-object-type\n TVirtuals = {},\n // eslint-disable-next-line unused-imports/no-unused-vars\n THydratedDocumentType = HydratedDocument<TRawDocType, TInstanceMethods & TVirtuals, TQueryHelpers, TVirtuals>,\n // eslint-disable-next-line unused-imports/no-unused-vars\n TSchema = any,\n > {\n assertUpdateSuccess: (\n filter: QueryFilter<TRawDocType>,\n update: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,\n options?: (mongo.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null,\n expectedModifiedCount?: number,\n ) => Promise<void>;\n }\n}\n\nexport function mongooseAssertionsPlugin<S extends Schema>(schema: S) {\n schema.method(\n 'assertUpdateSuccess',\n function (\n update?: UpdateQuery<any> | UpdateWithAggregationPipeline,\n options?: null | QueryOptions,\n expectedModifiedCount?: number,\n ) {\n return assertMongooseUpdateSuccess(this.updateOne(update, options), expectedModifiedCount);\n },\n );\n\n schema.static(\n 'assertUpdateSuccess',\n function (\n filter: QueryFilter<any>,\n update: UpdateQuery<any> | UpdateWithAggregationPipeline,\n options?: (mongo.UpdateOptions & MongooseUpdateQueryOptions<any>) | null,\n expectedModifiedCount: number = 1,\n ) {\n return assertMongooseUpdateSuccess(\n expectedModifiedCount === 1\n ? this.updateOne(filter, update, options)\n : this.updateMany(filter, update, options),\n expectedModifiedCount,\n );\n },\n );\n}\n"],"mappings":";;AAoDA,SAAgB,yBAA2C,QAAW;CAClE,OAAO,OACH,uBACA,SACI,QACA,SACA,uBACF;EACE,OAAO,4BAA4B,KAAK,UAAU,QAAQ,OAAO,GAAG,qBAAqB;CAC7F,CACJ;CAEA,OAAO,OACH,uBACA,SACI,QACA,QACA,SACA,wBAAgC,GAClC;EACE,OAAO,4BACH,0BAA0B,IACpB,KAAK,UAAU,QAAQ,QAAQ,OAAO,IACtC,KAAK,WAAW,QAAQ,QAAQ,OAAO,GAC7C,qBACJ;CACJ,CACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","names":[],"sources":["../../src/plugins/normalize.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","names":[],"sources":["../../src/plugins/normalize.ts"],"mappings":";;UAQiB;;;;;;;EAOb;;;;;;EAOA;;;;;;;;;;;;;;;;iBAiBY,wBAAwB,UAAU,QAC9C,QAAQ,GACR,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","names":["getProp"],"sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import {\n get as getProp,\n set as setProp,\n unset as unsetProp,\n} from 'es-toolkit/compat';\nimport { Types } from 'mongoose';\nimport type { Schema } from 'mongoose';\n\nexport interface MongooseNormalizePluginOptions {\n /**\n * Whether to convert `_id` field to `id`.\n * If true, the `_id` field will be replaced with `id`.\n *\n * @default true\n */\n convertIdField?: boolean;\n\n /**\n * Whether to convert the `_id` field to a hex string if it's an ObjectId.\n *\n * @default true\n */\n toHexIdIfObjectId?: boolean;\n}\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(\n schema: S,\n pluginOptions?: MongooseNormalizePluginOptions,\n) {\n // Collect special paths (Decimal128 & private)\n const decimalPaths: string[] = [];\n const privatePaths: string[] = [];\n for (const [path, schemaType] of Object.entries(schema.paths)) {\n if (schemaType?.options?.private) privatePaths.push(path);\n else if (schemaType?.instance === 'Decimal128') decimalPaths.push(path);\n }\n\n // Get original toJSON configuration\n const toJson = schema.get('toJSON');\n const toJsonTransform = toJson?.transform;\n\n // Override toJSON with custom transform\n schema.set(\n 'toJSON',\n {\n ...toJson,\n transform(doc, ret, options) {\n // Copy object and remove __v\n const copiedRet = { ...ret };\n // @ts-expect-error Ignore this error\n delete copiedRet.__v;\n\n // Normalize _id (convert to hex and/or move to id)\n let _id = copiedRet._id;\n delete copiedRet._id;\n if (pluginOptions?.toHexIdIfObjectId !== false && _id instanceof Types.ObjectId) {\n _id = _id.toHexString();\n }\n\n if (_id !== undefined) {\n if (pluginOptions?.convertIdField !== false) copiedRet.id = _id;\n else copiedRet._id = _id;\n }\n\n // Remove private fields\n for (const path of privatePaths) unsetProp(copiedRet, path);\n\n // Convert Decimal128 fields to string\n for (const path of decimalPaths) {\n const value = getProp(copiedRet, path) as Types.Decimal128 | undefined;\n if (value) setProp(copiedRet, path, value.toString());\n }\n\n // Run original toJSON transform\n if (toJsonTransform && typeof toJsonTransform !== 'boolean') {\n return toJsonTransform(doc as any, copiedRet as any, options as any);\n }\n\n // Return normalized object\n return copiedRet;\n },\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACZ,QACA,eACF;CAEE,MAAM,eAAyB,
|
|
1
|
+
{"version":3,"file":"normalize.js","names":["getProp"],"sources":["../../src/plugins/normalize.ts"],"sourcesContent":["import {\n get as getProp,\n set as setProp,\n unset as unsetProp,\n} from 'es-toolkit/compat';\nimport { Types } from 'mongoose';\nimport type { Schema } from 'mongoose';\n\nexport interface MongooseNormalizePluginOptions {\n /**\n * Whether to convert `_id` field to `id`.\n * If true, the `_id` field will be replaced with `id`.\n *\n * @default true\n */\n convertIdField?: boolean;\n\n /**\n * Whether to convert the `_id` field to a hex string if it's an ObjectId.\n *\n * @default true\n */\n toHexIdIfObjectId?: boolean;\n}\n\n/**\n * Mongoose plugin to normalize the JSON output of documents.\n *\n * This plugin modifies the `toJSON` method of Mongoose schemas to:\n * - Add an `id` field equal to the string representation of `_id`\n * - Remove the `_id` field\n * - Exclude fields marked as `private` from the JSON output\n * - Convert `Decimal128` fields to strings\n * - Remove the `__v` version key\n *\n * @template S - The type of the schema.\n *\n * @param schema - The Mongoose schema to apply the plugin to.\n */\nexport function mongooseNormalizePlugin<S extends Schema>(\n schema: S,\n pluginOptions?: MongooseNormalizePluginOptions,\n) {\n // Collect special paths (Decimal128 & private)\n const decimalPaths: string[] = [];\n const privatePaths: string[] = [];\n for (const [path, schemaType] of Object.entries(schema.paths)) {\n if (schemaType?.options?.private) privatePaths.push(path);\n else if (schemaType?.instance === 'Decimal128') decimalPaths.push(path);\n }\n\n // Get original toJSON configuration\n const toJson = schema.get('toJSON');\n const toJsonTransform = toJson?.transform;\n\n // Override toJSON with custom transform\n schema.set(\n 'toJSON',\n {\n ...toJson,\n transform(doc, ret, options) {\n // Copy object and remove __v\n const copiedRet = { ...ret };\n // @ts-expect-error Ignore this error\n delete copiedRet.__v;\n\n // Normalize _id (convert to hex and/or move to id)\n let _id = copiedRet._id;\n delete copiedRet._id;\n if (pluginOptions?.toHexIdIfObjectId !== false && _id instanceof Types.ObjectId) {\n _id = _id.toHexString();\n }\n\n if (_id !== undefined) {\n if (pluginOptions?.convertIdField !== false) copiedRet.id = _id;\n else copiedRet._id = _id;\n }\n\n // Remove private fields\n for (const path of privatePaths) unsetProp(copiedRet, path);\n\n // Convert Decimal128 fields to string\n for (const path of decimalPaths) {\n const value = getProp(copiedRet, path) as Types.Decimal128 | undefined;\n if (value) setProp(copiedRet, path, value.toString());\n }\n\n // Run original toJSON transform\n if (toJsonTransform && typeof toJsonTransform !== 'boolean') {\n return toJsonTransform(doc as any, copiedRet as any, options as any);\n }\n\n // Return normalized object\n return copiedRet;\n },\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACZ,QACA,eACF;CAEE,MAAM,eAAyB,CAAC;CAChC,MAAM,eAAyB,CAAC;CAChC,KAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,OAAO,KAAK,GACxD,IAAI,YAAY,SAAS,SAAS,aAAa,KAAK,IAAI;MACnD,IAAI,YAAY,aAAa,cAAc,aAAa,KAAK,IAAI;CAI1E,MAAM,SAAS,OAAO,IAAI,QAAQ;CAClC,MAAM,kBAAkB,QAAQ;CAGhC,OAAO,IACH,UACA;EACI,GAAG;EACH,UAAU,KAAK,KAAK,SAAS;GAEzB,MAAM,YAAY,EAAE,GAAG,IAAI;GAE3B,OAAO,UAAU;GAGjB,IAAI,MAAM,UAAU;GACpB,OAAO,UAAU;GACjB,IAAI,eAAe,sBAAsB,SAAS,eAAe,MAAM,UACnE,MAAM,IAAI,YAAY;GAG1B,IAAI,QAAQ,KAAA,GACR,IAAI,eAAe,mBAAmB,OAAO,UAAU,KAAK;QACvD,UAAU,MAAM;GAIzB,KAAK,MAAM,QAAQ,cAAc,MAAU,WAAW,IAAI;GAG1D,KAAK,MAAM,QAAQ,cAAc;IAC7B,MAAM,QAAQA,IAAQ,WAAW,IAAI;IACrC,IAAI,OAAO,IAAQ,WAAW,MAAM,MAAM,SAAS,CAAC;GACxD;GAGA,IAAI,mBAAmB,OAAO,oBAAoB,WAC9C,OAAO,gBAAgB,KAAY,WAAkB,OAAc;GAIvE,OAAO;EACX;CACJ,CACJ;AACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
|
|
3
2
|
//#region src/schema-builders/base.d.ts
|
|
4
3
|
type BaseSchemaType = BooleanConstructor | DateConstructor | NumberConstructor | Schema.Types.ObjectId['constructor'] | StringConstructor;
|
|
5
4
|
declare function createBaseSchemaBuilderFactory<Builder = Readonly<Record<string, any>>>(type: BaseSchemaType): (schema?: Record<string, any>) => Builder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":[],"sources":["../../src/schema-builders/base.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../src/schema-builders/base.ts"],"mappings":";;KAEK,iBACD,qBACA,kBACA,oBACA,OAAO,MAAM,0BACb;iBAYY,+BAA+B,UAAU,SAAS,sBAAsB,MAAM,kBAClF,SAAQ,wBA2BP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../src/schema-builders/base.ts"],"sourcesContent":["import type { Schema } from 'mongoose';\n\ntype BaseSchemaType =\n | BooleanConstructor\n | DateConstructor\n | NumberConstructor\n | Schema.Types.ObjectId['constructor']\n | StringConstructor;\n\nconst isFunctionKeys = new Set([\n 'default',\n 'enum',\n 'index',\n 'max',\n 'maxlength',\n 'min',\n 'minlength',\n]);\n\nexport function createBaseSchemaBuilderFactory<Builder = Readonly<Record<string, any>>>(type: BaseSchemaType) {\n return (schema: Record<string, any> = {}) => {\n schema.type = type;\n return new Proxy(\n Object.freeze({}),\n {\n get(_, key, receiver) {\n if (typeof key === 'symbol') throw new Error('Cannot use symbol as a schema attribute');\n if (key in schema) throw new Error(`Duplicate schema attribute: ${key}`);\n if (isFunctionKeys.has(key)) {\n return (value: any) => {\n schema[key] = value;\n return receiver;\n };\n }\n\n if (key === 'nonRequired') return { ...schema };\n if (key === 'required') {\n return {\n ...schema,\n required: true,\n };\n }\n\n schema[key] = true;\n return receiver;\n },\n },\n ) as Builder;\n };\n}\n"],"mappings":";AASA,MAAM,
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/schema-builders/base.ts"],"sourcesContent":["import type { Schema } from 'mongoose';\n\ntype BaseSchemaType =\n | BooleanConstructor\n | DateConstructor\n | NumberConstructor\n | Schema.Types.ObjectId['constructor']\n | StringConstructor;\n\nconst isFunctionKeys = new Set([\n 'default',\n 'enum',\n 'index',\n 'max',\n 'maxlength',\n 'min',\n 'minlength',\n]);\n\nexport function createBaseSchemaBuilderFactory<Builder = Readonly<Record<string, any>>>(type: BaseSchemaType) {\n return (schema: Record<string, any> = {}) => {\n schema.type = type;\n return new Proxy(\n Object.freeze({}),\n {\n get(_, key, receiver) {\n if (typeof key === 'symbol') throw new Error('Cannot use symbol as a schema attribute');\n if (key in schema) throw new Error(`Duplicate schema attribute: ${key}`);\n if (isFunctionKeys.has(key)) {\n return (value: any) => {\n schema[key] = value;\n return receiver;\n };\n }\n\n if (key === 'nonRequired') return { ...schema };\n if (key === 'required') {\n return {\n ...schema,\n required: true,\n };\n }\n\n schema[key] = true;\n return receiver;\n },\n },\n ) as Builder;\n };\n}\n"],"mappings":";AASA,MAAM,iCAAiB,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,SAAgB,+BAAwE,MAAsB;CAC1G,QAAQ,SAA8B,CAAC,MAAM;EACzC,OAAO,OAAO;EACd,OAAO,IAAI,MACP,OAAO,OAAO,CAAC,CAAC,GAChB,EACI,IAAI,GAAG,KAAK,UAAU;GAClB,IAAI,OAAO,QAAQ,UAAU,MAAM,IAAI,MAAM,yCAAyC;GACtF,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,+BAA+B,KAAK;GACvE,IAAI,eAAe,IAAI,GAAG,GACtB,QAAQ,UAAe;IACnB,OAAO,OAAO;IACd,OAAO;GACX;GAGJ,IAAI,QAAQ,eAAe,OAAO,EAAE,GAAG,OAAO;GAC9C,IAAI,QAAQ,YACR,OAAO;IACH,GAAG;IACH,UAAU;GACd;GAGJ,OAAO,OAAO;GACd,OAAO;EACX,EACJ,CACJ;CACJ;AACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BooleanSchemaDefinition, DefaultType, IndexDirection, IndexOptions } from "mongoose";
|
|
2
2
|
import { Merge } from "type-fest";
|
|
3
|
-
|
|
4
3
|
//#region src/schema-builders/boolean.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<BooleanSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.d.ts","names":[],"sources":["../../src/schema-builders/boolean.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","names":[],"sources":["../../src/schema-builders/boolean.ts"],"mappings":";;;KAUK,oBACD,cAAc,WACd,kCACA,KACA,qBAAqB,OAAO,kBAC5B,wBAAwB;UAGlB;EACN,MAAM;;UAGO,qBACb,cAAc,YAAY,WAC1B;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,mBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;cAGnD,uBAAoB,SAAA,wBAAA,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","names":[],"sources":["../../src/schema-builders/boolean.ts"],"sourcesContent":["import type {\n BooleanSchemaDefinition,\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n BooleanSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: BooleanSchemaDefinition;\n}\n\nexport interface BooleanSchemaBuilder<\n Props extends BaseProps = BaseProps,\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends boolean,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const booleanSchemaBuilder = createBaseSchemaBuilderFactory<BooleanSchemaBuilder>(Boolean);\n"],"mappings":";;AA+CA,MAAa,uBAAuB,+BAAqD,
|
|
1
|
+
{"version":3,"file":"boolean.js","names":[],"sources":["../../src/schema-builders/boolean.ts"],"sourcesContent":["import type {\n BooleanSchemaDefinition,\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n BooleanSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: BooleanSchemaDefinition;\n}\n\nexport interface BooleanSchemaBuilder<\n Props extends BaseProps = BaseProps,\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends boolean,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const booleanSchemaBuilder = createBaseSchemaBuilderFactory<BooleanSchemaBuilder>(Boolean);\n"],"mappings":";;AA+CA,MAAa,uBAAuB,+BAAqD,OAAO"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readonlyable } from "../types/_internals.js";
|
|
2
2
|
import { DateSchemaDefinition, DefaultType, IndexDirection, IndexOptions } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
|
|
5
4
|
//#region src/schema-builders/date.d.ts
|
|
6
5
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<DateSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
7
6
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","names":[],"sources":["../../src/schema-builders/date.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.d.ts","names":[],"sources":["../../src/schema-builders/date.ts"],"mappings":";;;;KAYK,oBACD,cAAc,WACd,kCACA,KACA,kBAAkB,OAAO,kBACzB,wBAAwB;UAGlB;EACN,MAAM;;UAGO,kBACb;EAAgB,MAAM;;EAA2B,MAAM;GACvD;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,YACZ,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;cAGnD,oBAAiB,SAAA,wBAAA;EAtD6B,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","names":[],"sources":["../../src/schema-builders/date.ts"],"sourcesContent":["import type {\n DateSchemaDefinition,\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n DateSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: DateSchemaDefinition;\n}\n\nexport interface DateSchemaBuilder<\n Props extends { type: DateSchemaDefinition } = { type: DateSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends NativeDate,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends NativeDate,\n M extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends D | Readonlyable<[D, S]>,\n D extends NativeDate,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { max: T }>,\n ExtraOmitFields\n >;\n\n min: <\n T extends D | Readonlyable<[D, S]>,\n D extends NativeDate,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { min: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const dateSchemaBuilder = createBaseSchemaBuilderFactory<DateSchemaBuilder>(Date);\n"],"mappings":";;AA+EA,MAAa,oBAAoB,+BAAkD,
|
|
1
|
+
{"version":3,"file":"date.js","names":[],"sources":["../../src/schema-builders/date.ts"],"sourcesContent":["import type {\n DateSchemaDefinition,\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n DateSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: DateSchemaDefinition;\n}\n\nexport interface DateSchemaBuilder<\n Props extends { type: DateSchemaDefinition } = { type: DateSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends NativeDate,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends NativeDate,\n M extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends D | Readonlyable<[D, S]>,\n D extends NativeDate,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { max: T }>,\n ExtraOmitFields\n >;\n\n min: <\n T extends D | Readonlyable<[D, S]>,\n D extends NativeDate,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { min: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const dateSchemaBuilder = createBaseSchemaBuilderFactory<DateSchemaBuilder>(Date);\n"],"mappings":";;AA+EA,MAAa,oBAAoB,+BAAkD,IAAI"}
|
|
@@ -2,7 +2,6 @@ import { Readonlyable } from "../types/_internals.js";
|
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Schema, Types } from "mongoose";
|
|
3
3
|
import { Decimal } from "decimal.js";
|
|
4
4
|
import { Merge } from "type-fest";
|
|
5
|
-
|
|
6
5
|
//#region src/schema-builders/decimal128.d.ts
|
|
7
6
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
8
7
|
interface BaseProps {
|
|
@@ -71,7 +70,7 @@ interface ToStringGetterSchema {
|
|
|
71
70
|
interface ToStringSetterSchema {
|
|
72
71
|
set: (value?: {
|
|
73
72
|
toString: () => string;
|
|
74
|
-
}) => string;
|
|
73
|
+
}) => string | undefined;
|
|
75
74
|
}
|
|
76
75
|
declare function decimal128SchemaBuilder(): Decimal128SchemaBuilder;
|
|
77
76
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal128.d.ts","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"decimal128.d.ts","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"mappings":";;;;;KAcK,oBACD,cAAc,WACd,kCACA,KACA,wBAAwB,OAAO,kBAC/B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGb,wBACb;EAAgB,aAAa,OAAO,MAAM;;EAAiB,aAAa,OAAO,MAAM;GACrF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,YAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,UAAU,MAAM,YAChB,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;;;;;;;;;;;EAYzB,2BAA2B,iBAAiB,WAAW,QAAQ,aAAa,oBACxE,MAAM,OAAO,oDACgB;;;;;;;;;;EAYjC,mBAAmB,oBAAoB,MAAM,OAAO,6CAA6C;EACjG,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;UAGtD;EACN,MAAM,QAAQ,MAAM;;UAGd;EACN,MAAM;IAAU;;;iBAKJ,2BA4BP"}
|
|
@@ -9,7 +9,7 @@ function decimal128SchemaBuilder() {
|
|
|
9
9
|
return new Proxy(baseBuilder, { get(target, key, receiver) {
|
|
10
10
|
if (key === "setRoundAndToFixedSetter") return (places = 2, rounding = Decimal.ROUND_DOWN) => {
|
|
11
11
|
schema.set = (value) => {
|
|
12
|
-
if (value) return new Decimal(value.toString()).toFixed(places, rounding);
|
|
12
|
+
if (value !== void 0 && value !== null) return (Decimal.isDecimal(value) ? value : new Decimal(value.toString())).toFixed(places, rounding);
|
|
13
13
|
};
|
|
14
14
|
return receiver;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal128.js","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n Decimal128SchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\nexport interface Decimal128SchemaBuilder<\n Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.Decimal128,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Sets the rounding and toFixed behavior for Decimal128 fields.\n * This method allows specifying the number of decimal places and the rounding strategy to be used when\n * saving the field to the database.\n *\n * @param places - The number of decimal places to round to (default is 2).\n * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).\n *\n * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendSchemaBuilder<\n Merge<Props, ToStringSetterSchema>,\n 'setRoundAndToFixedSetter' | ExtraOmitFields\n >;\n\n /**\n * Sets the toString behavior for Decimal128 fields.\n * This method defines how the Decimal128 field should be converted to a string when processing or\n * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128\n * in the database.\n *\n * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string\n * when accessed in the application.\n */\n setToStringGetter: ExtendSchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nexport function decimal128SchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => {\n if (value)
|
|
1
|
+
{"version":3,"file":"decimal128.js","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n Decimal128SchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\nexport interface Decimal128SchemaBuilder<\n Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.Decimal128,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Sets the rounding and toFixed behavior for Decimal128 fields.\n * This method allows specifying the number of decimal places and the rounding strategy to be used when\n * saving the field to the database.\n *\n * @param places - The number of decimal places to round to (default is 2).\n * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).\n *\n * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendSchemaBuilder<\n Merge<Props, ToStringSetterSchema>,\n 'setRoundAndToFixedSetter' | ExtraOmitFields\n >;\n\n /**\n * Sets the toString behavior for Decimal128 fields.\n * This method defines how the Decimal128 field should be converted to a string when processing or\n * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128\n * in the database.\n *\n * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string\n * when accessed in the application.\n */\n setToStringGetter: ExtendSchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string | undefined;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nexport function decimal128SchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => {\n if (value !== undefined && value !== null) {\n const decimal = Decimal.isDecimal(value) ? value : new Decimal(value.toString());\n return decimal.toFixed(places, rounding);\n }\n };\n\n return receiver;\n };\n }\n\n if (key === 'setToStringGetter') {\n schema.get = (value?: Types.Decimal128) => value?.toString();\n return receiver;\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Decimal128SchemaBuilder;\n}\n"],"mappings":";;;;AAiGA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,UAAU;AAEjF,SAAgB,0BAA0B;CACtC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,4BACR,QAAQ,SAAiB,GAAG,WAA6B,QAAQ,eAAe;GAC5E,OAAO,OAAO,UAAuC;IACjD,IAAI,UAAU,KAAA,KAAa,UAAU,MAEjC,QADgB,QAAQ,UAAU,KAAK,IAAI,QAAQ,IAAI,QAAQ,MAAM,SAAS,CAAC,EAAA,CAChE,QAAQ,QAAQ,QAAQ;GAE/C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,qBAAqB;GAC7B,OAAO,OAAO,UAA6B,OAAO,SAAS;GAC3D,OAAO;EACX;EAEA,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readonlyable } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, NumberSchemaDefinition } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
|
|
5
4
|
//#region src/schema-builders/number.d.ts
|
|
6
5
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<NumberSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
7
6
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":";;;;KAYK,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,MAAM;;UAGO,oBACb;EAAgB,MAAM;;EAA6B,MAAM;GACzD;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;cAGnD,sBAAmB,SAAA,wBAAA;EAtD6B,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","names":[],"sources":["../../src/schema-builders/number.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n NumberSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n NumberSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: NumberSchemaDefinition;\n}\n\nexport interface NumberSchemaBuilder<\n Props extends { type: NumberSchemaDefinition } = { type: NumberSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<N | null>>\n | { [path: string]: N | null }\n | { message?: M; values: Readonlyable<Array<N | null>> },\n M extends string,\n N extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends N | Readonlyable<[N, S]>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { max: T }>,\n ExtraOmitFields\n >;\n\n min: <\n T extends N | Readonlyable<[N, S]>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { min: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const numberSchemaBuilder = createBaseSchemaBuilderFactory<NumberSchemaBuilder>(Number);\n"],"mappings":";;AA+EA,MAAa,sBAAsB,+BAAoD,
|
|
1
|
+
{"version":3,"file":"number.js","names":[],"sources":["../../src/schema-builders/number.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n NumberSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n NumberSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: NumberSchemaDefinition;\n}\n\nexport interface NumberSchemaBuilder<\n Props extends { type: NumberSchemaDefinition } = { type: NumberSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<N | null>>\n | { [path: string]: N | null }\n | { message?: M; values: Readonlyable<Array<N | null>> },\n M extends string,\n N extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends N | Readonlyable<[N, S]>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { max: T }>,\n ExtraOmitFields\n >;\n\n min: <\n T extends N | Readonlyable<[N, S]>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { min: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const numberSchemaBuilder = createBaseSchemaBuilderFactory<NumberSchemaBuilder>(Number);\n"],"mappings":";;AA+EA,MAAa,sBAAsB,+BAAoD,MAAM"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readonlyable } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Schema, Types } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
|
|
5
4
|
//#region src/schema-builders/object-id.d.ts
|
|
6
5
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<ObjectIdSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
7
6
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-id.d.ts","names":[],"sources":["../../src/schema-builders/object-id.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-id.d.ts","names":[],"sources":["../../src/schema-builders/object-id.ts"],"mappings":";;;;KAaK,oBACD,cAAc,WACd,kCACA,KACA,sBAAsB,OAAO,kBAC7B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGb,sBACb;EAAgB,aAAa,OAAO,MAAM;;EAAe,aAAa,OAAO,MAAM;GACnF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,kBACA,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;cAGnD,wBAAqB,SAAA,wBAAA;EApCiC,aAAO,OAAO,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-id.js","names":[],"sources":["../../src/schema-builders/object-id.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n ObjectIdSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface ObjectIdSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | O>>\n | { [path: string]: null | O }\n | { message?: M; values: Readonlyable<Array<null | O>> },\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const objectIdSchemaBuilder = createBaseSchemaBuilderFactory<ObjectIdSchemaBuilder>(Schema.Types.ObjectId);\n"],"mappings":";;;AA8DA,MAAa,wBAAwB,+BAAsD,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"object-id.js","names":[],"sources":["../../src/schema-builders/object-id.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n ObjectIdSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface ObjectIdSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | O>>\n | { [path: string]: null | O }\n | { message?: M; values: Readonlyable<Array<null | O>> },\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const objectIdSchemaBuilder = createBaseSchemaBuilderFactory<ObjectIdSchemaBuilder>(Schema.Types.ObjectId);\n"],"mappings":";;;AA8DA,MAAa,wBAAwB,+BAAsD,OAAO,MAAM,QAAQ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readonlyable } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Model, Schema, Types } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
|
|
5
4
|
//#region src/schema-builders/ref.d.ts
|
|
6
5
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<RefSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
7
6
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","names":[],"sources":["../../src/schema-builders/ref.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ref.d.ts","names":[],"sources":["../../src/schema-builders/ref.ts"],"mappings":";;;;KAcK,oBACD,cAAc,WACd,kCACA,KACA,iBAAiB,OAAO,kBACxB,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGb,iBACb;EAAgB,aAAa,OAAO,MAAM;;EAAe,aAAa,OAAO,MAAM;GACnF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,kBACA,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;iBAKhD,iBAAiB,YAAY,WAAW,aAAa,uBAAuB,qBACxF,KAAK,IAEiC;EAAmB,KAAK;EAAG,aAAa,OAAO,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","names":[],"sources":["../../src/schema-builders/ref.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Model,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n RefSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface RefSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | O>>\n | { [path: string]: null | O }\n | { message?: M; values: Readonlyable<Array<null | O>> },\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.ObjectId);\n\nexport function refSchemaBuilder<T extends ((this: any, doc: any) => Model<any> | string) | Model<any> | string>(\n ref: T,\n) {\n return baseBuilderFactory({ ref }) as RefSchemaBuilder<{ ref: T; type: typeof Schema.Types.ObjectId }>;\n}\n"],"mappings":";;;AA+DA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"ref.js","names":[],"sources":["../../src/schema-builders/ref.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Model,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n RefSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface RefSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | O>>\n | { [path: string]: null | O }\n | { message?: M; values: Readonlyable<Array<null | O>> },\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.ObjectId);\n\nexport function refSchemaBuilder<T extends ((this: any, doc: any) => Model<any> | string) | Model<any> | string>(\n ref: T,\n) {\n return baseBuilderFactory({ ref }) as RefSchemaBuilder<{ ref: T; type: typeof Schema.Types.ObjectId }>;\n}\n"],"mappings":";;;AA+DA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,QAAQ;AAE/E,SAAgB,iBACZ,KACF;CACE,OAAO,mBAAmB,EAAE,IAAI,CAAC;AACrC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readonlyable } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, StringSchemaDefinition } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
|
|
5
4
|
//#region src/schema-builders/string.d.ts
|
|
6
5
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
7
6
|
interface BaseProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","names":[],"sources":["../../src/schema-builders/string.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.d.ts","names":[],"sources":["../../src/schema-builders/string.ts"],"mappings":";;;;KAiBK,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,MAAM;;UAGA,SAAS;EACf;EACA;IAAY,SAAS;IAAG,YAAY;;;UAGvB,oBACb;EAAgB,MAAM;;EAA6B,MAAM;GACzD;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;;;;;;;;;;EAYJ,OAAO,0BAA0B,4BAA4B,UAAU,MAAM,oBACzE,MAAM,OAAO,SAAS,uBACJ;;;;;;;;;;EAYtB,OAAO,0BAA0B,4BAA4B,UAAU,MAAM,oBACzE,MAAM,OAAO,SAAS,uBACJ;;;;;;;;;EAWtB,SACI,UAAU,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;IAAG,WAAW;MACxC;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,YACI,UAAU,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;MAC1B;EAGJ,YACI,UAAU,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;MAC1B;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,MAAM,oBAAoB,MAAM;IAAS;MAAe;EACxD,MAAM,oBAAoB,MAAM;IAAS;MAAe;EACxD,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,WAAW,oBAAoB,MAAM;IAAS;MAAoB;;cAIhE;cACA;iBAEU,uBAyCP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import {\n isIPv4,\n isIPv6,\n} from 'node:net';\n\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n StringSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface IpSchema<T extends string> {\n trim: true;\n validate: { message: T; validator: (value: string) => boolean };\n}\n\nexport interface StringSchemaBuilder<\n Props extends { type: StringSchemaDefinition } = { type: StringSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | S>>\n | { [path: string]: null | S }\n | { message?: M; values: Readonlyable<Array<null | S>> },\n M extends string,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n /**\n * Adds IPv4 validation to the string schema.\n * Ensures the string is a valid IPv4 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard\n * IPv4 validation message.\n *\n * @returns A schema builder with IPv4 validation and the `trim` option enabled.\n */\n ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | ExtraOmitFields\n >;\n\n /**\n * Adds IPv6 validation to the string schema.\n * Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard\n * IPv6 validation message.\n *\n * @returns A schema builder with IPv6 validation and the `trim` option enabled.\n */\n ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | ExtraOmitFields\n >;\n\n /**\n * Sets both the maximum and minimum length of the string.\n * This method ensures the string length is exactly or within a specified range.\n *\n * @param value - A number representing the exact length or an array specifying [minimum, maximum] length.\n *\n * @returns A schema builder with both `maxlength` and `minlength` options applied.\n */\n length: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T; minlength: T }>,\n ExtraOmitFields\n >;\n\n lowercase: ExtendSchemaBuilder<Merge<Props, { lowercase: true }>, ExtraOmitFields>;\n maxlength: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T }>,\n ExtraOmitFields\n >;\n\n minlength: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { minlength: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n text: ExtendSchemaBuilder<Merge<Props, { text: true }>, ExtraOmitFields>;\n trim: ExtendSchemaBuilder<Merge<Props, { trim: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n uppercase: ExtendSchemaBuilder<Merge<Props, { uppercase: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(String);\nconst defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`';\nconst defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`';\n\nexport function stringSchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'ipv4') {\n return (message: string = defaultIpv4ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv4(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'ipv6') {\n return (message: string = defaultIpv6ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv6(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'length') {\n return (value: any) => {\n schema.maxlength = schema.minlength = value;\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as StringSchemaBuilder;\n}\n"],"mappings":";;;AA0IA,MAAM,qBAAqB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"string.js","names":[],"sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import {\n isIPv4,\n isIPv6,\n} from 'node:net';\n\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n StringSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface IpSchema<T extends string> {\n trim: true;\n validate: { message: T; validator: (value: string) => boolean };\n}\n\nexport interface StringSchemaBuilder<\n Props extends { type: StringSchemaDefinition } = { type: StringSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<null | S>>\n | { [path: string]: null | S }\n | { message?: M; values: Readonlyable<Array<null | S>> },\n M extends string,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n /**\n * Adds IPv4 validation to the string schema.\n * Ensures the string is a valid IPv4 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard\n * IPv4 validation message.\n *\n * @returns A schema builder with IPv4 validation and the `trim` option enabled.\n */\n ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | ExtraOmitFields\n >;\n\n /**\n * Adds IPv6 validation to the string schema.\n * Ensures the string is a valid IPv6 address and trims the input. The validation message can be customized.\n *\n * @param message - The custom error message to return if validation fails. Defaults to a standard\n * IPv6 validation message.\n *\n * @returns A schema builder with IPv6 validation and the `trim` option enabled.\n */\n ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | ExtraOmitFields\n >;\n\n /**\n * Sets both the maximum and minimum length of the string.\n * This method ensures the string length is exactly or within a specified range.\n *\n * @param value - A number representing the exact length or an array specifying [minimum, maximum] length.\n *\n * @returns A schema builder with both `maxlength` and `minlength` options applied.\n */\n length: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T; minlength: T }>,\n ExtraOmitFields\n >;\n\n lowercase: ExtendSchemaBuilder<Merge<Props, { lowercase: true }>, ExtraOmitFields>;\n maxlength: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T }>,\n ExtraOmitFields\n >;\n\n minlength: <\n T extends L | Readonlyable<[L, S]>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { minlength: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n text: ExtendSchemaBuilder<Merge<Props, { text: true }>, ExtraOmitFields>;\n trim: ExtendSchemaBuilder<Merge<Props, { trim: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n uppercase: ExtendSchemaBuilder<Merge<Props, { uppercase: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(String);\nconst defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`';\nconst defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`';\n\nexport function stringSchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'ipv4') {\n return (message: string = defaultIpv4ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv4(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'ipv6') {\n return (message: string = defaultIpv6ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv6(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'length') {\n return (value: any) => {\n schema.maxlength = schema.minlength = value;\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as StringSchemaBuilder;\n}\n"],"mappings":";;;AA0IA,MAAM,qBAAqB,+BAA+B,MAAM;AAChE,MAAM,6BAA6B;AACnC,MAAM,6BAA6B;AAEnC,SAAgB,sBAAsB;CAClC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,QACR,QAAQ,UAAkB,+BAA+B;GACrD,OAAO,OAAO;GACd,OAAO,WAAW;IACd;IACA,YAAY,UAAkB,OAAO,KAAK;GAC9C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,QACR,QAAQ,UAAkB,+BAA+B;GACrD,OAAO,OAAO;GACd,OAAO,WAAW;IACd;IACA,YAAY,UAAkB,OAAO,KAAK;GAC9C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,UACR,QAAQ,UAAe;GACnB,OAAO,YAAY,OAAO,YAAY;GACtC,OAAO;EACX;EAGJ,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internals.d.ts","names":[],"sources":["../../src/types/_internals.ts"],"mappings":";KAAY,
|
|
1
|
+
{"version":3,"file":"_internals.d.ts","names":[],"sources":["../../src/types/_internals.ts"],"mappings":";KAAY,aAAa,KAAK,SAAS,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate-paginate.d.ts","names":[],"sources":["../../src/types/aggregate-paginate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"aggregate-paginate.d.ts","names":[],"sources":["../../src/types/aggregate-paginate.ts"],"mappings":";;KAcK,+CAA+C;UAEnC,sBAAsB;EACnC,OAAO;EACP,cAAc;EACd,cAAc;EACd,QAAQ;EACR,OAAO;EACP,WAAW;EACX,OAAO;EACP,gBAAgB;EAChB,WAAW;EACX,YAAY;EACZ,aAAa;;UAGA,uBACb,YACA,uBACA,8CACM,MAAM,YAAY,cAAc;EACtC,oBAAoB,GAChB,QAAQ,UAAU,OAAO,4BACzB,UAAU,0BACV,YAAY,UAAU,QAAQ,wBAAwB,gBACrD,QAAQ,wBAAwB;;UAGxB;EACb;EACA;EACA,eAAe;EACf;EACA;EACA;;;;;;EAOA;EACA;EACA;;UAGa;;EAEb;;EAEA,QAAQ;;EAER;;EAEA;;EAEA,WAAW,wCAAwC;;EAEnD;;UAGa,wBAAwB;GACpC,gDAAgD;EACjD,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGa,EAAE,QAAQ"}
|
package/dist/types/data.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseMongooseDocType, SetFieldsToObjectId } from "./index.js";
|
|
2
2
|
import { SetFieldType } from "type-fest";
|
|
3
|
-
|
|
4
3
|
//#region src/types/data.d.ts
|
|
5
4
|
type BaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> = (CreatedAtField extends true ? {
|
|
6
5
|
createdAt: string;
|
package/dist/types/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","names":[],"sources":["../../src/types/data.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"data.d.ts","names":[],"sources":["../../src/types/data.ts"],"mappings":";;;KAOY,sBAAsB,uCAAuC,0CACpE;EAAgC;gBAChC;EAAgC;;EAC/B;;KAEM,0BACR,GACA,6BAA6B,WAC7B,mBAAmB,cAAc,GAAG,yBACpC,uCACA,yCACA,oBACA,oBAAoB,aAAa,GAAG,YAAY,OAAO,iBACvD,gBACA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { AggregatePaginateModel } from "./aggregate-paginate.js";
|
|
|
2
2
|
import { PaginateModel } from "./paginate.js";
|
|
3
3
|
import { Connection, HydratedDocument, QueryWithHelpers, Types } from "mongoose";
|
|
4
4
|
import { SetFieldType } from "type-fest";
|
|
5
|
-
|
|
6
5
|
//#region src/types/index.d.ts
|
|
7
6
|
type BaseMongooseDocType<T, CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> = (CreatedAtField extends true ? {
|
|
8
7
|
createdAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;KAWY,oBAAoB,GAAG,uCAAuC,0CACrE;EAAgC,WAAW;eAC5C,KAAK,wCACJ;EAAgC,WAAW;;KAEpC,0BAA0B,YAAY,sCAAsC,yBACpF,uBAAuB,YAAY,cAAc,+BACjD,yBAAyB,YAAY,6BAA6B,gBAClE,cAAc,YAAY,cAAc;KAEhC,sCAAsC,GAAG,gBAAgB,KAAK,KAAK,+BAA+B;KAClG,2BAA2B,KAAK,aAAa,MAAM;KACnD,0BACR,YACA,SACA,uBACA,wCACA,iBACI,gBACA,SACA,cACA,uBAEA;KAGI,yBACR,SACA,sCACA,yBACA,iBACA,SACA,6BACA;KAGQ,oCAAoC,GAAG,8CAA8C,KAC7F,+BAC4B;KAGpB,oBAAoB,GAAG,gBAAgB,KAAK,aAAa,GAAG,GAAG,MAAM;UAIhE,yBAAyB,YAAY,sCAAsC;UAE3E;EACb,UAAU"}
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MongooseNormalizePluginOptions } from "../plugins/normalize.js";
|
|
2
2
|
import { BaseMongoosePaginateModel } from "./index.js";
|
|
3
3
|
import { Connection, Schema, SchemaTimestampsConfig } from "mongoose";
|
|
4
|
-
|
|
5
4
|
//#region src/types/options.d.ts
|
|
6
5
|
interface BuildMongooseModelOptions {
|
|
7
6
|
connection?: Connection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","names":[],"sources":["../../src/types/options.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.ts","names":[],"sources":["../../src/types/options.ts"],"mappings":";;;;UAUiB;EACb,aAAa;EACb;EACA,yBAAyB;EACzB;EACA,uBAAuB;;UAGV;EACb,oBACI,SACA,cAAc,0BAA0B,SAAS,6BAA6B,eAC9E,sCACA,uBAEA,QAAQ,OACJ,SACA,OACA,6BACA"}
|
package/dist/types/paginate.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HydratedDocument, Model, PopulateOptions, QueryFilter, QueryOptions, Schema, mongo } from "mongoose";
|
|
2
|
-
|
|
3
2
|
//#region src/types/paginate.d.ts
|
|
4
3
|
type PaginateDocument<T, TMethods, TQueryHelpers, O extends PaginateOptions = object> = O['lean'] extends true ? PaginateDocumentLeanResult<T, O> : HydratedDocument<T, TMethods, TQueryHelpers>;
|
|
5
4
|
type PaginateDocumentLeanResult<T, O extends PaginateOptions> = O['leanWithId'] extends true ? T & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.d.ts","names":[],"sources":["../../src/types/paginate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"paginate.d.ts","names":[],"sources":["../../src/types/paginate.ts"],"mappings":";;KAUY,iBACR,GACA,UACA,eACA,UAAU,4BACV,yBACE,2BAA2B,GAAG,KAC9B,iBAAiB,GAAG,UAAU;KAE/B,2BAA2B,GAAG,UAAU,mBACzC,+BACM;EAAM;IACN,qCACI;GAAO;IACP;UAEG,qBAAqB;EAClC,OAAO;EACP,cAAc;EACd,cAAc;EACd,QAAQ;EACR,OAAO;EACP,WAAW;EACX,OAAO;EACP,gBAAgB;EAChB,WAAW;EACX,YAAY;EACZ,aAAa;;UAGA,cAAc,YAAY,uBAAuB,8CAA8C,MAC5G,YACA,cACA;EAEA;KACK,UAAU,iBACP,QAAQ,YAAY,aACpB,UAAU,GACV,YACI,UACA,QAAQ,eAAe,iBAAiB,YAAY,6BAA6B,cAAc,eAEpG,QAAQ,eAAe,iBAAiB,YAAY,6BAA6B,cAAc;KAEjG,WAAW,YAAY,UAAU,kBAAkB,iBAChD,QAAQ,YAAY,aACpB,UAAU,GACV,YACI,UACA,QAAQ,eAAe,iBAAiB,UAAU,6BAA6B,cAAc,eAElG,QAAQ,eAAe,iBAAiB,UAAU,6BAA6B,cAAc;KAE/F,WAAW,YACR,QAAQ,YAAY,aACpB,UAAU,iBACV,YACI,UACA,QAAQ,eACJ,iBAAiB,UAAU,6BAA6B,cAAc,6BAG/E,QACC,eAAe,iBAAiB,UAAU,6BAA6B,cAAc;;;UAKhF;EACb;EACA,YAAY,MAAM;EAClB,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;;;;;EAOA;EACA,WAAW,kBAAkB;EAC7B;EACA,OAAO;EACP;EACA;EACA,yBAAyB;EACzB;;UAGa;EACb;EACA;;UAGa,eAAe;GAC3B,gDAAgD;EACjD,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;EACA,WAAW,kBAAkB;;UAGhB;EACb;EACA,gBAAgB;EAChB,WAAW,kBAAkB;EAC7B,OAAO;EACP;;;YAKU,MACN,YACA,SACA,WAAW,sBACX,aAAa,SACb,mBACA,mBAAmB;IAEnB;OACK,UAAU,iBAAiB,UAAU,IAAI,QACtC,eAAe,iBAAiB,YAAY,kBAAkB,UAAU;OAG3E,WAAW,YAAY,UAAU,kBAAkB,iBAAiB,UAAU,IAAI,QAC/E,eAAe,iBAAiB,UAAU,kBAAkB,UAAU;OAGzE,WAAW,YAAY,UAAU,kBAAkB,QAChD,eAAe,iBAAiB,UAAU,kBAAkB,UAAU;;;;iBAMrE,EAAE,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/mongoose",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.3",
|
|
5
5
|
"description": "A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -76,29 +76,25 @@
|
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"decimal.js": "^10.6.0",
|
|
79
|
-
"es-toolkit": "^1.
|
|
80
|
-
"mongoose": "^9.
|
|
79
|
+
"es-toolkit": "^1.50.0",
|
|
80
|
+
"mongoose": "^9.9.0",
|
|
81
81
|
"mongoose-aggregate-paginate-v2": "^1.1.4",
|
|
82
|
-
"mongoose-paginate-v2": "^1.9.
|
|
83
|
-
"type-fest": "^5.
|
|
82
|
+
"mongoose-paginate-v2": "^1.9.5",
|
|
83
|
+
"type-fest": "^5.8.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@antfu/eslint-config": "^
|
|
87
|
-
"@kikiutils/eslint-config": "^9.
|
|
88
|
-
"@kikiutils/tsconfigs": "^
|
|
89
|
-
"@types/node": "^
|
|
90
|
-
"@vitest/coverage-v8": "^4.1.
|
|
86
|
+
"@antfu/eslint-config": "^9.2.0",
|
|
87
|
+
"@kikiutils/eslint-config": "^9.2.0",
|
|
88
|
+
"@kikiutils/tsconfigs": "^7.0.0",
|
|
89
|
+
"@types/node": "^26.1.2",
|
|
90
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
91
91
|
"changelogen": "^0.6.2",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
92
|
+
"eslint": "^10.8.0",
|
|
93
|
+
"knip": "^6.30.0",
|
|
94
|
+
"publint": "^0.3.22",
|
|
95
|
+
"tsdown": "^0.22.14",
|
|
95
96
|
"typescript": "^6.0.3",
|
|
96
|
-
"unplugin-unused": "^0.
|
|
97
|
-
"vitest": "^4.1.
|
|
98
|
-
},
|
|
99
|
-
"pnpm": {
|
|
100
|
-
"onlyBuiltDependencies": [
|
|
101
|
-
"esbuild"
|
|
102
|
-
]
|
|
97
|
+
"unplugin-unused": "^0.6.0",
|
|
98
|
+
"vitest": "^4.1.10"
|
|
103
99
|
}
|
|
104
100
|
}
|
|
@@ -92,7 +92,7 @@ interface ToStringGetterSchema {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
interface ToStringSetterSchema {
|
|
95
|
-
set: (value?: { toString: () => string }) => string;
|
|
95
|
+
set: (value?: { toString: () => string }) => string | undefined;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);
|
|
@@ -107,7 +107,10 @@ export function decimal128SchemaBuilder() {
|
|
|
107
107
|
if (key === 'setRoundAndToFixedSetter') {
|
|
108
108
|
return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {
|
|
109
109
|
schema.set = (value?: { toString: () => string }) => {
|
|
110
|
-
if (value
|
|
110
|
+
if (value !== undefined && value !== null) {
|
|
111
|
+
const decimal = Decimal.isDecimal(value) ? value : new Decimal(value.toString());
|
|
112
|
+
return decimal.toFixed(places, rounding);
|
|
113
|
+
}
|
|
111
114
|
};
|
|
112
115
|
|
|
113
116
|
return receiver;
|