@tsed/mongoose 7.18.3-rc.1 → 7.18.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.
Files changed (107) hide show
  1. package/.eslintignore +13 -0
  2. package/.eslintrc.js +1 -0
  3. package/jest.config.js +9 -5
  4. package/lib/cjs/MongooseModule.js.map +1 -1
  5. package/lib/cjs/constants/constants.js.map +1 -1
  6. package/lib/cjs/decorators/auto.js.map +1 -1
  7. package/lib/cjs/decorators/discriminatorKey.js.map +1 -1
  8. package/lib/cjs/decorators/dynamicRef.js.map +1 -1
  9. package/lib/cjs/decorators/excludeIndexes.js.map +1 -1
  10. package/lib/cjs/decorators/expires.js.map +1 -1
  11. package/lib/cjs/decorators/immutable.js.map +1 -1
  12. package/lib/cjs/decorators/indexed.js.map +1 -1
  13. package/lib/cjs/decorators/lowercase.js.map +1 -1
  14. package/lib/cjs/decorators/model.js.map +1 -1
  15. package/lib/cjs/decorators/mongooseIndex.js.map +1 -1
  16. package/lib/cjs/decorators/mongooseIndexes.js.map +1 -1
  17. package/lib/cjs/decorators/mongoosePlugin.js.map +1 -1
  18. package/lib/cjs/decorators/numberDecimal.js.map +1 -1
  19. package/lib/cjs/decorators/objectID.js.map +1 -1
  20. package/lib/cjs/decorators/postHook.js.map +1 -1
  21. package/lib/cjs/decorators/preHook.js.map +1 -1
  22. package/lib/cjs/decorators/ref.js.map +1 -1
  23. package/lib/cjs/decorators/schema.js.map +1 -1
  24. package/lib/cjs/decorators/schemaIgnore.js.map +1 -1
  25. package/lib/cjs/decorators/select.js.map +1 -1
  26. package/lib/cjs/decorators/sparse.js.map +1 -1
  27. package/lib/cjs/decorators/text.js.map +1 -1
  28. package/lib/cjs/decorators/trim.js.map +1 -1
  29. package/lib/cjs/decorators/unique.js.map +1 -1
  30. package/lib/cjs/decorators/uppercase.js.map +1 -1
  31. package/lib/cjs/decorators/versionKey.js.map +1 -1
  32. package/lib/cjs/decorators/virtualRef.js.map +1 -1
  33. package/lib/cjs/index.js.map +1 -1
  34. package/lib/cjs/interfaces/MongooseConnectionOptions.js.map +1 -1
  35. package/lib/cjs/interfaces/MongooseDocument.js.map +1 -1
  36. package/lib/cjs/interfaces/MongooseModel.js.map +1 -1
  37. package/lib/cjs/interfaces/MongooseModelOptions.js.map +1 -1
  38. package/lib/cjs/interfaces/MongooseSchemaOptions.js.map +1 -1
  39. package/lib/cjs/interfaces/MongooseSchemaTypes.js.map +1 -1
  40. package/lib/cjs/interfaces/MongooseVirtualRefOptions.js.map +1 -1
  41. package/lib/cjs/interfaces/interfaces.js.map +1 -1
  42. package/lib/cjs/registries/MongooseModels.js.map +1 -1
  43. package/lib/cjs/services/MongooseConnections.js.map +1 -1
  44. package/lib/cjs/services/MongooseService.js.map +1 -1
  45. package/lib/cjs/utils/createModel.js.map +1 -1
  46. package/lib/cjs/utils/createSchema.js.map +1 -1
  47. package/lib/cjs/utils/resolveRefType.js.map +1 -1
  48. package/lib/cjs/utils/schemaOptions.js.map +1 -1
  49. package/lib/esm/MongooseModule.js.map +1 -1
  50. package/lib/esm/constants/constants.js.map +1 -1
  51. package/lib/esm/decorators/auto.js.map +1 -1
  52. package/lib/esm/decorators/discriminatorKey.js.map +1 -1
  53. package/lib/esm/decorators/dynamicRef.js.map +1 -1
  54. package/lib/esm/decorators/excludeIndexes.js.map +1 -1
  55. package/lib/esm/decorators/expires.js.map +1 -1
  56. package/lib/esm/decorators/immutable.js.map +1 -1
  57. package/lib/esm/decorators/indexed.js.map +1 -1
  58. package/lib/esm/decorators/lowercase.js.map +1 -1
  59. package/lib/esm/decorators/model.js.map +1 -1
  60. package/lib/esm/decorators/mongooseIndex.js.map +1 -1
  61. package/lib/esm/decorators/mongooseIndexes.js.map +1 -1
  62. package/lib/esm/decorators/mongoosePlugin.js.map +1 -1
  63. package/lib/esm/decorators/numberDecimal.js.map +1 -1
  64. package/lib/esm/decorators/objectID.js.map +1 -1
  65. package/lib/esm/decorators/postHook.js.map +1 -1
  66. package/lib/esm/decorators/preHook.js.map +1 -1
  67. package/lib/esm/decorators/ref.js.map +1 -1
  68. package/lib/esm/decorators/schema.js.map +1 -1
  69. package/lib/esm/decorators/schemaIgnore.js.map +1 -1
  70. package/lib/esm/decorators/select.js.map +1 -1
  71. package/lib/esm/decorators/sparse.js.map +1 -1
  72. package/lib/esm/decorators/text.js.map +1 -1
  73. package/lib/esm/decorators/trim.js.map +1 -1
  74. package/lib/esm/decorators/unique.js.map +1 -1
  75. package/lib/esm/decorators/uppercase.js.map +1 -1
  76. package/lib/esm/decorators/versionKey.js.map +1 -1
  77. package/lib/esm/decorators/virtualRef.js.map +1 -1
  78. package/lib/esm/index.js.map +1 -1
  79. package/lib/esm/interfaces/MongooseConnectionOptions.js.map +1 -1
  80. package/lib/esm/interfaces/MongooseDocument.js.map +1 -1
  81. package/lib/esm/interfaces/MongooseModel.js.map +1 -1
  82. package/lib/esm/interfaces/MongooseModelOptions.js.map +1 -1
  83. package/lib/esm/interfaces/MongooseSchemaOptions.js.map +1 -1
  84. package/lib/esm/interfaces/MongooseSchemaTypes.js.map +1 -1
  85. package/lib/esm/interfaces/MongooseVirtualRefOptions.js.map +1 -1
  86. package/lib/esm/interfaces/interfaces.js.map +1 -1
  87. package/lib/esm/registries/MongooseModels.js.map +1 -1
  88. package/lib/esm/services/MongooseConnections.js.map +1 -1
  89. package/lib/esm/services/MongooseService.js.map +1 -1
  90. package/lib/esm/utils/createModel.js.map +1 -1
  91. package/lib/esm/utils/createSchema.js.map +1 -1
  92. package/lib/esm/utils/resolveRefType.js.map +1 -1
  93. package/lib/esm/utils/schemaOptions.js.map +1 -1
  94. package/lib/tsconfig.esm.tsbuildinfo +1 -0
  95. package/lib/tsconfig.tsbuildinfo +1 -0
  96. package/lib/types/decorators/dynamicRef.d.ts +1 -1
  97. package/lib/types/decorators/numberDecimal.d.ts +1 -1
  98. package/lib/types/decorators/objectID.d.ts +1 -1
  99. package/lib/types/decorators/ref.d.ts +1 -1
  100. package/lib/types/decorators/virtualRef.d.ts +5 -2
  101. package/lib/types/interfaces/MongooseDocument.d.ts +1 -1
  102. package/lib/types/interfaces/MongooseModel.d.ts +2 -2
  103. package/lib/types/interfaces/MongooseSchemaOptions.d.ts +4 -4
  104. package/lib/types/services/MongooseConnections.d.ts +1 -1
  105. package/package.json +21 -20
  106. package/tsconfig.esm.json +45 -0
  107. package/tsconfig.compile.esm.json +0 -13
package/.eslintignore ADDED
@@ -0,0 +1,13 @@
1
+ node_modules
2
+ docs
3
+ docs-references
4
+ lib
5
+ dist
6
+ coverage
7
+ .nyc_output
8
+ *-lock.json
9
+ *.lock
10
+ benchmarks.*
11
+ **/generated
12
+
13
+ **/*.js
package/.eslintrc.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("@tsed/eslint/node.js");
package/jest.config.js CHANGED
@@ -2,13 +2,17 @@
2
2
  // https://jestjs.io/docs/en/configuration.html
3
3
 
4
4
  module.exports = {
5
- ...require("@tsed/jest-config")(__dirname, "mongoose"),
5
+ ...require("@tsed/jest-config"),
6
+ roots: ["<rootDir>/src", "<rootDir>/test"],
7
+ moduleNameMapper: {
8
+ "@tsed/mongoose": "<rootDir>/src/index.ts"
9
+ },
6
10
  coverageThreshold: {
7
11
  global: {
8
- statements: 99.5,
9
- branches: 95.48,
10
- functions: 100,
11
- lines: 99.47
12
+ statements: 99.06,
13
+ branches: 95.43,
14
+ functions: 99,
15
+ lines: 99.06
12
16
  }
13
17
  }
14
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseModule.js","sourceRoot":"","sources":["../../src/MongooseModule.ts"],"names":[],"mappings":";;;;AAAA,iCAA+C;AAC/C,iCAA2C;AAC3C,wEAAoE;AACpE,gEAA2D;AAE3D;;GAEG;AAIH,IAAa,cAAc,GAA3B,MAAa,cAAc;IACL;IAA2D;IAA/E,YAAoB,eAAgC,EAA2B,QAAuB;QAAlF,oBAAe,GAAf,eAAe,CAAiB;QAA2B,aAAQ,GAAR,QAAQ,CAAe;QACpG,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,EAAE,QAAQ,EAAE;YACnB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,KAAyB,CAAC;IAEjC,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAhBY,cAAc;IAH1B,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAoB,CAAC;KAChC,CAAC;IAEuD,mBAAA,IAAA,kBAAa,GAAE,CAAA;6CAAjC,iCAAe;GADzC,cAAc,CAgB1B;AAhBY,wCAAc","sourcesContent":["import {Configuration, OnInit} from \"@tsed/di\";\nimport {Module, OnDestroy} from \"@tsed/di\";\nimport {MONGOOSE_CONNECTIONS} from \"./services/MongooseConnections\";\nimport {MongooseService} from \"./services/MongooseService\";\n\n/**\n * @ignore\n */\n@Module({\n imports: [MONGOOSE_CONNECTIONS]\n})\nexport class MongooseModule implements OnDestroy, OnInit {\n constructor(private mongooseService: MongooseService, @Configuration() private settings: Configuration) {\n // auto configure the cache manager when mongoose is used with @tsed/mongoose\n const cache = this.settings.get<any>(\"cache\");\n\n // istanbul ignore next\n if (cache?.mongoose) {\n cache.connection = this.mongooseService.get();\n }\n }\n\n $onInit(): void | Promise<any> {}\n\n $onDestroy(): Promise<any> | void {\n return this.mongooseService.closeConnections();\n }\n}\n"]}
1
+ {"version":3,"file":"MongooseModule.js","sourceRoot":"","sources":["../../src/MongooseModule.ts"],"names":[],"mappings":";;;;AAAA,iCAA+C;AAC/C,iCAA2C;AAC3C,wEAAoE;AACpE,gEAA2D;AAE3D;;GAEG;AAII,IAAM,cAAc,GAApB,MAAM,cAAc;IACL;IAA2D;IAA/E,YAAoB,eAAgC,EAA2B,QAAuB;QAAlF,oBAAe,GAAf,eAAe,CAAiB;QAA2B,aAAQ,GAAR,QAAQ,CAAe;QACpG,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,EAAE,QAAQ,EAAE;YACnB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,KAAyB,CAAC;IAEjC,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAhBY,cAAc;IAH1B,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAoB,CAAC;KAChC,CAAC;IAEuD,mBAAA,IAAA,kBAAa,GAAE,CAAA;6CAAjC,iCAAe;GADzC,cAAc,CAgB1B;AAhBY,wCAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,eAAe,GAAG,sBAAsB,CAAC;AACtD;;;GAGG;AACU,QAAA,uBAAuB,GAAG,8BAA8B,CAAC;AACtE;;;GAGG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AACpD;;;GAGG;AACU,QAAA,mBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA = \"tsed:mongoose:schema\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA_OPTIONS = \"tsed:mongoose:schema:options\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL = \"tsed:mongoose:model\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL_NAME = \"tsed:mongoose:model:name\";\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,eAAe,GAAG,sBAAsB,CAAC;AACtD;;;GAGG;AACU,QAAA,uBAAuB,GAAG,8BAA8B,CAAC;AACtE;;;GAGG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AACpD;;;GAGG;AACU,QAAA,mBAAmB,GAAG,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, uses Mongoose's default _id settings. Only allowed for ObjectIds\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} auto\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Auto(auto: boolean = true): PropertyDecorator {\n return MongooseSchema({auto} as any);\n}\n"]}
1
+ {"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA","sourcesContent":["export {DiscriminatorKey} from \"@tsed/schema\";\n"]}
1
+ {"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":";;;AAAA,qCAAyF;AACzF,yCAA4F;AAC5F,uCAAkD;AAClD,sDAAuD;AACvD,mDAAqF;AACrF,iEAA4D;AAE5D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,GAAoB;IACpD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,+BAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAW,CAAC,CAAC,IAAI,MAAM,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,UAAU,CAAC,OAAe,EAAE,GAAG,KAAkB;IAC/D,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAChB,IAAA,gBAAO,EAAC,0BAA0B,CAAC,EACnC,IAAA,oBAAW,EAAC,sBAAsB,CAAC,EACnC,IAAA,iBAAU,EAAC,2BAAe,EAAE;QAC1B,IAAI,EAAE,iBAAc,CAAC,KAAK,CAAC,QAAQ;QACnC,OAAO;KACR,CAAC,EACF,IAAA,2BAAa,EAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC3B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACnE,CAAC,CAAC,EACF,IAAA,yBAAW,EAAC,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,IAAA,uBAAS,EAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACjE,CAAC,CAAC,EACF,IAAA,cAAK,EAAC,IAAA,eAAM,GAAE,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,GAAG,KAAK,CAAC,CAC7E,CAAC;AACzB,CAAC;AAzBD,gCAyBC","sourcesContent":["import {classOf, isArrowFn, isString, StoreMerge, Type, useDecorators} from \"@tsed/core\";\nimport {Description, Example, JsonHookContext, OneOf, Property, string} from \"@tsed/schema\";\nimport {Schema as MongooseSchema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants/constants\";\nimport {deserialize, OnDeserialize, OnSerialize, serialize} from \"@tsed/json-mapper\";\nimport {MongooseModels} from \"../registries/MongooseModels\";\n\nfunction isRef(value: undefined | string | any) {\n return (value && value._bsontype) || isString(value);\n}\n\nfunction getType(refPath: string, ctx: JsonHookContext) {\n return (ctx?.self[refPath] && MongooseModels.get(ctx.self[refPath] as string)) || Object;\n}\n\n/**\n * Define a property as mongoose reference to other Model (decorated with @Model).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * class FooModel {\n *\n * @DynamicRef('type')\n * field: DynamicRef<OtherFooModel | OtherModel>\n *\n * @Enum(['OtherFooModel', 'OtherModel'])\n * type: string\n * }\n *\n * @Model()\n * class OtherFooModel {\n * }\n *\n * @Model()\n * class OtherModel {\n * }\n * ```\n *\n * @param refPath {String} the path to apply the correct model\n * @param types {Type} the classes to generate the correct json schema\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function DynamicRef(refPath: string, ...types: Type<any>[]): PropertyDecorator {\n return useDecorators(\n Property(Object),\n Example(\"5ce7ad3028890bd71749d477\"),\n Description(\"A reference ObjectID\"),\n StoreMerge(MONGOOSE_SCHEMA, {\n type: MongooseSchema.Types.ObjectId,\n refPath\n }),\n OnDeserialize((value, ctx) => {\n if (isRef(value)) {\n return value.toString();\n }\n\n return deserialize(value, {...ctx, type: getType(refPath, ctx)});\n }),\n OnSerialize((value: any, ctx) => {\n if (isRef(value)) {\n return value.toString();\n }\n\n return serialize(value, {...ctx, type: getType(refPath, ctx)});\n }),\n OneOf(string().example(\"5ce7ad3028890bd71749d477\").description(\"A reference ObjectID\"), ...types)\n ) as PropertyDecorator;\n}\n\nexport type DynamicRef<T> = T | string;\n"]}
1
+ {"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":";;;AAAA,qCAAyF;AACzF,yCAA4F;AAC5F,uCAAkD;AAClD,sDAAuD;AACvD,mDAAqF;AACrF,iEAA4D;AAE5D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,GAAoB;IACpD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,+BAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAW,CAAC,CAAC,IAAI,MAAM,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,UAAU,CAAC,OAAe,EAAE,GAAG,KAAkB;IAC/D,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,EAAC,MAAM,CAAC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C;AAFD,wCAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} excludeIndexes\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function ExcludeIndexes(excludeIndexes: boolean = true): PropertyDecorator {\n return MongooseSchema({excludeIndexes} as any);\n}\n"]}
1
+ {"version":3,"file":"excludeIndexes.js","sourceRoot":"","sources":["../../../src/decorators/excludeIndexes.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,cAAc,CAAC,iBAA0B,IAAI;IAC3D,OAAO,IAAA,uBAAc,EAAC,EAAC,cAAc,EAAQ,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,OAAO,CAAC,OAA+B;IACrD,OAAO,IAAA,uBAAc,EAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC;AAFD,0BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Defines a TTL index on this path. Only allowed for dates.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Expires('5d')\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} expires\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Expires(expires: number | string | Date): PropertyDecorator {\n return MongooseSchema({expires} as any);\n}\n"]}
1
+ {"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,OAAO,CAAC,OAA+B;IACrD,OAAO,IAAA,uBAAc,EAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC;AAFD,0BAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"immutable.js","sourceRoot":"","sources":["../../../src/decorators/immutable.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,SAAS,CAAC,YAA0D,IAAI;IACtF,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will\n * disallow changes to this path once the document is saved to the database for the first time. Read more\n * about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Immutable()\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} immutable\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Immutable(immutable: boolean | ((this: any, doc: any) => boolean) = true): PropertyDecorator {\n return MongooseSchema({immutable} as any);\n}\n"]}
1
+ {"version":3,"file":"immutable.js","sourceRoot":"","sources":["../../../src/decorators/immutable.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,SAAS,CAAC,YAA0D,IAAI;IACtF,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexed.js","sourceRoot":"","sources":["../../../src/decorators/indexed.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,OAAO,CAAC,QAAyC,IAAI;IACnE,OAAO,IAAA,uBAAc,EAAC,EAAC,KAAK,EAAQ,CAAC,CAAC;AACxC,CAAC;AAFD,0BAEC","sourcesContent":["import {IndexOptions} from \"mongoose\";\nimport {MongooseSchema} from \"./schema\";\n\n/**\n * Tell Mongoose whether to define an index for the property.\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Indexed()\n * field: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Indexed(index: IndexOptions | boolean | string = true): PropertyDecorator {\n return MongooseSchema({index} as any);\n}\n"]}
1
+ {"version":3,"file":"indexed.js","sourceRoot":"","sources":["../../../src/decorators/indexed.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,OAAO,CAAC,QAAyC,IAAI;IACnE,OAAO,IAAA,uBAAc,EAAC,EAAC,KAAK,EAAQ,CAAC,CAAC;AACxC,CAAC;AAFD,0BAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../src/decorators/lowercase.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Lowercase()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} lowercase\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Lowercase(lowercase: boolean = true): PropertyDecorator {\n return MongooseSchema({lowercase} as any);\n}\n"]}
1
+ {"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../src/decorators/lowercase.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,iCAA0C;AAC1C,yCAAgD;AAGhD,yEAAqE;AACrE,sDAAgE;AAChE,wDAAgD;AAChD,0DAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,IAAA,oBAAa,EAAC,CAAC,MAAW,EAAE,EAAE;QACnC,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,IAAA,2BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,OAAO,CAAC,kBAAkB,IAAI,IAAA,2BAAkB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,EAAE;YACR,UAAU;gBACR,OAAO,IAAA,wBAAS,EAAC,MAAM,EAAE,OAAc,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;QAEH,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,CAAC,0CAAoB,EAAE,KAAK,CAAC;YACnC,UAAU,CAAC,WAAiC,EAAE,MAAc;gBAC1D,IAAA,kCAAkB,EAAC,MAAM,EAAE,IAAA,6BAAa,EAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO,IAAA,yBAAW,EAChB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,eAAe,EACvB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CACpC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA/BD,sBA+BC","sourcesContent":["import {nameOf, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {DiscriminatorValue} from \"@tsed/schema\";\nimport {Schema} from \"mongoose\";\nimport {MongooseModelOptions} from \"../interfaces/MongooseModelOptions\";\nimport {MONGOOSE_CONNECTIONS} from \"../services/MongooseConnections\";\nimport {createModel, getModelToken} from \"../utils/createModel\";\nimport {getSchema} from \"../utils/createSchema\";\nimport {applySchemaOptions, schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with\n * `@Inject` annotation.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Property()\n * field: string;\n * }\n * ```\n *\n * Then inject the model into a service:\n *\n * ```typescript\n * class MyService {\n * constructor(@Inject(EventModel) eventModel: MongooseModel<EventModel>) {\n * eventModel.findById().exec();\n * }\n * }\n * ```\n *\n * ### Options\n *\n * - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.\n * - `name` (String): model name.\n * - `collection` (String): collection (optional, induced from model name).\n * - `skipInit` (Boolean): skipInit whether to skip initialization (defaults to false).\n *\n * @param {MongooseModelOptions} options\n * @returns {(target: any) => void}\n * @decorator\n * @mongoose\n * @class\n */\nexport function Model(options: MongooseModelOptions = {}) {\n return useDecorators((target: any) => {\n const {token, collectionName} = getModelToken(target, options);\n\n options.discriminatorValue && DiscriminatorValue(options.discriminatorValue)(target);\n\n registerProvider({\n provide: token,\n deps: [],\n useFactory() {\n return getSchema(target, options as any);\n }\n });\n\n registerProvider({\n provide: target,\n type: \"mongoose:model\",\n deps: [MONGOOSE_CONNECTIONS, token],\n useFactory(connections: MONGOOSE_CONNECTIONS, schema: Schema) {\n applySchemaOptions(schema, schemaOptions(target));\n return createModel(\n target,\n schema,\n collectionName,\n options.collection,\n options.overwriteModels,\n connections.get(options.connection)\n );\n }\n });\n });\n}\n"]}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,iCAA0C;AAC1C,yCAAgD;AAGhD,yEAAqE;AACrE,sDAAgE;AAChE,wDAAgD;AAChD,0DAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,IAAA,oBAAa,EAAC,CAAC,MAAW,EAAE,EAAE;QACnC,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,IAAA,2BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,OAAO,CAAC,kBAAkB,IAAI,IAAA,2BAAkB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,EAAE;YACR,UAAU;gBACR,OAAO,IAAA,wBAAS,EAAC,MAAM,EAAE,OAAc,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;QAEH,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,CAAC,0CAAoB,EAAE,KAAK,CAAC;YACnC,UAAU,CAAC,WAAiC,EAAE,MAAc;gBAC1D,IAAA,kCAAkB,EAAC,MAAM,EAAE,IAAA,6BAAa,EAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO,IAAA,yBAAW,EAChB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,eAAe,EACvB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CACpC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA/BD,sBA+BC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mongooseIndex.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndex.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,aAAa,CAAC,MAAc,EAAE,OAAa;IACzD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,sCAMC","sourcesContent":["import {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Calls schema.index() to define an index (most likely compound) for the schema.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * @MongooseIndex({first: 1, second: 1}, {unique: 1})\n * export class EventModel {\n *\n * @Property()\n * first: string;\n *\n * @Property()\n * second: string;\n *\n * }\n * ```\n *\n * @param fields\n * @param options\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongooseIndex(fields: object, options?: any): Function {\n return (target: any) => {\n schemaOptions(target, {\n indexes: [{fields, options}]\n });\n };\n}\n"]}
1
+ {"version":3,"file":"mongooseIndex.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndex.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,aAAa,CAAC,MAAc,EAAE,OAAa;IACzD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,sCAMC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mongooseIndexes.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndexes.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,eAAe,CAAC,OAA+C;IAC7E,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC;IACnC,CAAC,CAAC;AACJ,CAAC;AAJD,0CAIC","sourcesContent":["import {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Calls schema.index() to define multiple indexes (most likely compound) for the schema.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * @MongooseIndexes([{fields: {first: 1, second: 1}, options:{unique: 1}}, {fields: {first: 1, third: 1}, options:{unique: 1}}])\n * export class EventModel {\n *\n * @Property()\n * first: string;\n *\n * @Property()\n * second: string;\n *\n * @Property()\n * third: string;\n *\n * }\n * ```\n *\n * @param indexes - define multiple mongoose indexes\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongooseIndexes(indexes: Array<{fields: object; options?: any}>): Function {\n return (target: any) => {\n schemaOptions(target, {indexes});\n };\n}\n"]}
1
+ {"version":3,"file":"mongooseIndexes.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndexes.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,eAAe,CAAC,OAA+C;IAC7E,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC;IACnC,CAAC,CAAC;AACJ,CAAC;AAJD,0CAIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mongoosePlugin.js","sourceRoot":"","sources":["../../../src/decorators/mongoosePlugin.ts"],"names":[],"mappings":";;;AACA,0DAAqD;AAErD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,MAAwD,EAAE,OAAa;IACpG,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,wCAMC","sourcesContent":["import mongoose from \"mongoose\";\nimport {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n *\n * @param {(schema: \"mongoose\".Schema, options?: any) => void} plugin\n * @param options\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongoosePlugin(plugin: (schema: mongoose.Schema, options?: any) => void, options?: any): Function {\n return (target: any) => {\n schemaOptions(target, {\n plugins: [{plugin, options}]\n });\n };\n}\n"]}
1
+ {"version":3,"file":"mongoosePlugin.js","sourceRoot":"","sources":["../../../src/decorators/mongoosePlugin.ts"],"names":[],"mappings":";;;AACA,0DAAqD;AAErD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,MAAwD,EAAE,OAAa;IACpG,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,wCAMC"}
@@ -1 +1 @@
1
- {"version":3,"file":"numberDecimal.js","sourceRoot":"","sources":["../../../src/decorators/numberDecimal.ts"],"names":[],"mappings":";;;;AAAA,mCAAkD;AAClD,qCAAyE;AACzE,mDAA6D;AAC7D,yCAAuD;AACvD,uCAA4E;AAC5E,sDAAuD;AAGvD,IAAa,aAAa,GAA1B,MAAa,aAAa;IACxB,QAAQ,CAAC,GAAoB;QAC3B,OAAO,IAAA,eAAQ,EAAC,GAAG,CAAC,IAAI,IAAA,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,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC;IAEF,mDAAmD;IACnD,IAAA,yBAAW,EAAC,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QAC9B,OAAO,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AArCD,sCAqCC","sourcesContent":["import {Formats, FormatsMethods} from \"@tsed/ajv\";\nimport {isNumber, isString, StoreMerge, useDecorators} from \"@tsed/core\";\nimport {OnDeserialize, OnSerialize} from \"@tsed/json-mapper\";\nimport {Example, Format, Property} from \"@tsed/schema\";\nimport {Types, Schema as MongooseSchema, SchemaTypeOptions} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants/constants\";\n\n@Formats(\"decimal\", {type: \"number\"})\nexport class DecimalFormat implements FormatsMethods<string | number> {\n validate(num: string | number): boolean {\n return isString(num) || isNumber(num);\n }\n}\n\nfunction isDecimal(value: undefined | number | any) {\n return value && value._bsontype === \"Decimal128\";\n}\n\n/**\n * Tell Mongoose whether to define an Decimal128 property.\n * Will be serialized as `number` with format as `decimal`.\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class PriceModel {\n * @NumberDecimal()\n * price: Decimal128;\n * }\n * ```\n * Optionally using custom decimal type, such as `Big` from big.js\n * ```typescript\n * @Model()\n * export class PriceModel {\n * @NumberDecimal(Big)\n * price: Big;\n * }\n * ```\n * @param type Optional decimal type constructor\n * @decorator\n * @mongoose\n * @schema\n */\nexport function NumberDecimal(type?: any) {\n const schema: SchemaTypeOptions<Decimal128> = {\n type: MongooseSchema.Types.Decimal128\n };\n\n if (type) {\n // Define property getter to convert Decimal128 to custom type\n schema.get = (value) => {\n return isDecimal(value) ? new type(value) : value;\n };\n }\n\n return useDecorators(\n Property(Number),\n Format(\"decimal\"),\n Example(12.34),\n StoreMerge(MONGOOSE_SCHEMA, schema),\n\n // Deserialize number value from JSON to Decimal128\n OnDeserialize((value) => {\n if (value === undefined) {\n return undefined;\n }\n if (type) {\n return new type(value);\n }\n if (isString(value)) {\n return Types.Decimal128.fromString(value);\n }\n return Types.Decimal128.fromString(`${value}`);\n }),\n\n // Serialize decimal value to floating point number\n OnSerialize((value: any, ctx) => {\n return value && Number(value);\n })\n );\n}\n\nexport type Decimal128 = Types.Decimal128;\n"]}
1
+ {"version":3,"file":"numberDecimal.js","sourceRoot":"","sources":["../../../src/decorators/numberDecimal.ts"],"names":[],"mappings":";;;;AAAA,mCAAkD;AAClD,qCAAyE;AACzE,mDAA6D;AAC7D,yCAAuD;AACvD,uCAA4E;AAC5E,sDAAuD;AAGhD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,QAAQ,CAAC,GAAoB;QAC3B,OAAO,IAAA,eAAQ,EAAC,GAAG,CAAC,IAAI,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAJY,aAAa;IADzB,IAAA,aAAO,EAAC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;GACxB,aAAa,CAIzB;AAJY,sCAAa;AAM1B,SAAS,SAAS,CAAC,KAA+B;IAChD,OAAO,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,aAAa,CAAC,IAAU;IACtC,MAAM,MAAM,GAAkC;QAC5C,IAAI,EAAE,iBAAc,CAAC,KAAK,CAAC,UAAU;KACtC,CAAC;IAEF,IAAI,IAAI,EAAE;QACR,8DAA8D;QAC9D,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,EAAE,EAAE;YACrB,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACpD,CAAC,CAAC;KACH;IAED,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,EAAC,MAAM,CAAC,EA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AQ;QACpB,KAAK,EAAE,SAAS;KACjB,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,4BAYC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {Description, Example, Name, Pattern} from \"@tsed/schema\";\nimport {Types} from \"mongoose\";\nimport {Auto} from \"./auto\";\nimport {Schema} from \"./schema\";\n\n/**\n * Tell Mongoose whether to define an ObjectId property.\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ObjectId('id')\n * _id: string;\n * }\n * ```\n * @param name\n * @decorator\n * @mongoose\n * @schema\n */\nexport function ObjectID(name?: string) {\n return useDecorators(\n name && Name(name),\n Pattern(/^[0-9a-fA-F]{24}$/),\n Description(\"An ObjectID\"),\n Example(\"5ce7ad3028890bd71749d477\"),\n Auto(),\n Schema({\n type: Types.ObjectId,\n match: undefined\n })\n );\n}\n\nexport type ObjectID = Types.ObjectId;\n"]}
1
+ {"version":3,"file":"objectID.js","sourceRoot":"","sources":["../../../src/decorators/objectID.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,yCAAiE;AACjE,uCAA+B;AAC/B,iCAA4B;AAC5B,qCAAgC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,IAAA,oBAAa,EAClB,IAAI,IAAI,IAAA,aAAI,EAAC,IAAI,CAAC,EAClB,IAAA,gBAAO,EAAC,mBAAmB,CAAC,EAC5B,IAAA,oBAAW,EAAC,aAAa,CAAC,EAC1B,IAAA,gBAAO,EAAC,0BAA0B,CAAC,EACnC,IAAA,WAAI,GAAE,EACN,IAAA,eAAM,EAAC;QACL,IAAI,EAAE,gBAAK,CAAC,QAAQ;QACpB,KAAK,EAAE,SAAS;KACjB,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,4BAYC"}
@@ -1 +1 @@
1
- {"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,0DAAqD;AAgDrD,SAAgB,QAAQ,CAAU,MAAc,EAAE,GAAG,MAAa;IAChE,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,GAAwB,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,GAA0B,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,6BAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ;oBACE,MAAM;oBACN,EAAE;oBACF,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAQ,CAAC;AACZ,CAAC;AApBD,4BAoBC","sourcesContent":["import {decoratorTypeOf, DecoratorTypes, StaticMethodDecorator} from \"@tsed/core\";\nimport {MongooseHookOptions, MongoosePostHookCB} from \"../interfaces/MongooseSchemaOptions\";\nimport {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * We can simply attach a `@PostHook` decorator to your model class and\n * define the hook function like you normally would in Mongoose.\n *\n * ```typescript\n * import {Ignore, Required} from \"@tsed/common\";\n * import {PostHook, Model} from \"@tsed/mongoose\";\n *\n * @Model()\n * @PostHook(\"save\", (car: CarModel) => {\n * if (car.topSpeedInKmH > 300) {\n * console.log(car.model, 'is fast!');\n * }\n * })\n * export class CarModel {\n * @Ignore()\n * _id: string;\n *\n * @Required()\n * model: string;\n *\n * @Required()\n * isFast: boolean;\n *\n * // or Prehook on static method\n * @PostHook(\"save\")\n * static postSave(car: CarModel) {\n * if (car.topSpeedInKmH > 300) {\n * console.log(car.model, 'is fast!');\n * }\n * }\n * }\n * ```\n *\n * This will execute the post-save hook each time a `CarModel` document is saved.\n *\n * @param {string} method\n * @param fn\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function PostHook<T = any>(method: string, fn: MongoosePostHookCB<T>): ClassDecorator;\nexport function PostHook<T = any>(method: string, fn: MongoosePostHookCB<T>, options: MongooseHookOptions): ClassDecorator;\nexport function PostHook<T = any>(method: string, options: MongooseHookOptions): StaticMethodDecorator;\nexport function PostHook<T = any>(method: string, ...params: any[]): Function {\n return ((...args: any[]) => {\n let options: MongooseHookOptions = params[1];\n let fn: MongoosePostHookCB<T> = params[0];\n\n if (decoratorTypeOf(args) === DecoratorTypes.METHOD_STC) {\n options = params[0];\n fn = args[0][args[1]].bind(args[0]);\n }\n\n schemaOptions(args[0], {\n post: [\n {\n method,\n fn,\n options\n }\n ]\n });\n }) as any;\n}\n"]}
1
+ {"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,0DAAqD;AAgDrD,SAAgB,QAAQ,CAAU,MAAc,EAAE,GAAG,MAAa;IAChE,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,GAAwB,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,GAA0B,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,6BAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ;oBACE,MAAM;oBACN,EAAE;oBACF,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAQ,CAAC;AACZ,CAAC;AApBD,4BAoBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAE3D,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,SAAgB,OAAO,CAAU,MAAc,EAAE,EAA+C,EAAE,OAA6B;IAC7H,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,EAAyB,CAAC;YACpC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,6BAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,GAAG,EAAE;gBACH;oBACE,MAAM;oBACN,EAAE,EAAE,EAA0B;oBAC9B,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjBD,0BAiBC","sourcesContent":["import {decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {MongooseHookOptions, MongoosePreHookCB} from \"../interfaces/MongooseSchemaOptions\";\nimport {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n *\n * We can simply attach a `@PreHook` decorator to your model class and\n * define the hook function like you normally would in Mongoose.\n *\n * ```typescript\n * import {Ignore, Required} from \"@tsed/common\";\n * import {PreHook, Model} from \"@tsed/mongoose\";\n *\n * @Model()\n * @PreHook(\"save\", (car: CarModel, next) => {\n * if (car.model === 'Tesla') {\n * car.isFast = true;\n * }\n * next();\n *})\n * export class CarModel {\n *\n * @Ignore()\n * _id: string;\n *\n * @Required()\n * model: string;\n *\n * @Required()\n * isFast: boolean;\n *\n * // or Prehook on static method\n * @PreHook(\"save\")\n * static preSave(car: CarModel, next) {\n * if (car.model === 'Tesla') {\n * car.isFast = true;\n * }\n * next();\n * }\n * }\n * ```\n *\n * This will execute the pre-save hook each time a `CarModel` document is saved.\n *\n * @param {string} method\n * @param fn\n * @param options\n * @returns {Function}\n * @decorator\n * @class\n */\nexport function PreHook<T = any>(method: string, fn?: MongoosePreHookCB<T> | MongooseHookOptions, options?: MongooseHookOptions): Function {\n return (...args: any[]) => {\n if (decoratorTypeOf(args) === DecoratorTypes.METHOD_STC) {\n options = fn as MongooseHookOptions;\n fn = args[0][args[1]].bind(args[0]);\n }\n\n schemaOptions(args[0], {\n pre: [\n {\n method,\n fn: fn as MongoosePreHookCB<T>,\n options\n }\n ]\n });\n };\n}\n"]}
1
+ {"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAE3D,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,SAAgB,OAAO,CAAU,MAAc,EAAE,EAA+C,EAAE,OAA6B;IAC7H,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,EAAyB,CAAC;YACpC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,6BAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,GAAG,EAAE;gBACH;oBACE,MAAM;oBACN,EAAE,EAAE,EAA0B;oBAC9B,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL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AC,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,CAAC,EACzG,eAAe,CAAC,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,CACrC,CAAC;AACzB,CAAC;AArCD,kBAqCC","sourcesContent":["import {isArrowFn, isObject, isString, StoreMerge, Type, useDecorators} from \"@tsed/core\";\nimport {OnDeserialize, OnSerialize, serialize} from \"@tsed/json-mapper\";\nimport {ForwardGroups, JsonEntityFn, lazyRef, matchGroups, OneOf, Property, string} from \"@tsed/schema\";\nimport {Schema as MongooseSchema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants/constants\";\nimport {MongooseSchemaTypes} from \"../interfaces/MongooseSchemaTypes\";\nimport {MongooseModels} from \"../registries/MongooseModels\";\n\ninterface RefOptions {\n type?: MongooseSchemaTypes;\n populatedGroups?: string[];\n}\n\nfunction isRef(value: undefined | string | any) {\n return (value && value._bsontype) || isString(value);\n}\n\nfunction PopulateGroups(populatedGroups: string[]) {\n return useDecorators(\n ForwardGroups(true),\n JsonEntityFn((store) => {\n store.schema.$hooks.on(\"oneOf\", (obj: any[], givenGroups: string[]) => {\n if (matchGroups(populatedGroups, givenGroups)) {\n return obj.filter((x) => x.type === \"string\"); // keep the object id;\n } else {\n return obj.filter((x) => x.type !== \"string\"); // keep the ref definition\n }\n });\n })\n );\n}\n\n/**\n * Define a property as mongoose reference to other Model (decorated with @Model).\n *\n * ### Example\n *\n * ```typescript\n *\n * @Model()\n * class FooModel {\n *\n * @Ref(Foo2Model)\n * field: Ref<Foo2Model>\n *\n * @Ref(Foo2Model)\n * list: Ref<Foo2Model>[]\n * }\n *\n * @Model()\n * class Foo2Model {\n * }\n * ```\n *\n * @param model\n * @param options\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Ref(\n model: string | (() => Type) | any,\n options: RefOptions | MongooseSchemaTypes = MongooseSchemaTypes.OBJECT_ID\n): PropertyDecorator {\n if (!model) {\n throw new Error(\n \"A model is required on `@Ref(model)` decorator. Please give a model or wrap it inside an arrow function if you have a circular reference.\"\n );\n }\n\n const getType = () => (isString(model) ? MongooseModels.get(model) : isArrowFn(model) ? model() : model);\n const populatedGroups = (isObject(options) && options.populatedGroups) || [];\n\n return useDecorators(\n Property(Object),\n StoreMerge(MONGOOSE_SCHEMA, {\n type: MongooseSchema.Types[isObject(options) ? options.type || MongooseSchemaTypes.OBJECT_ID : options],\n ref: model\n }),\n OnDeserialize((value) => {\n if (isRef(value)) {\n return value.toString();\n }\n\n return value;\n }),\n OnSerialize((value: any, ctx) => {\n if (isRef(value)) {\n return value.toString();\n }\n const type = getType();\n\n return serialize(value, {...ctx, type});\n }),\n OneOf(string().example(\"5ce7ad3028890bd71749d477\").description(\"A reference ObjectID\"), lazyRef(getType)),\n populatedGroups.length && PopulateGroups(populatedGroups)\n ) as PropertyDecorator;\n}\n\nexport type Ref<T> = T | string;\n"]}
1
+ {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/decorators/ref.ts"],"names":[],"mappings":";;;AAAA,qCAA0F;AAC1F,mDAAwE;AACxE,yCAAwG;AACxG,uCAAkD;AAClD,sDAAuD;AACvD,2EAAsE;AACtE,iEAA4D;AAO5D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,cAAc,CAAC,eAAyB;IAC/C,OAAO,IAAA,oBAAa,EAClB,IAAA,sBAAa,EAAC,IAAI,CAAC,EACnB,IAAA,qBAAY,EAAC,CAAC,KAAK,EAAE,EAAE;QACrB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,WAAqB,EAAE,EAAE;YACpE,IAAI,IAAA,oBAAW,EAAC,eAAe,EAAE,WAAW,CAAC,EAAE;gBAC7C,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAA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EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAEvD,IAAA,qBAAgB,EAAC;oBACf,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,EAAE;oBACR,UAAU;wBACR,OAAO,IAAA,wBAAS,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAc,CAAC,CAAC;oBAClD,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAnBD,wBAmBC;AA4BD,SAAgB,cAAc,CAAC,UAA0D,EAAE;IACzF,OAAO,MAAM,CAAC,OAAc,CAAC,CAAC;AAChC,CAAC;AAFD,wCAEC","sourcesContent":["import {decoratorTypeOf, StoreMerge, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {Property} from \"@tsed/schema\";\nimport {SchemaTypeOptions} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants/constants\";\nimport {MongooseSchemaOptions} from \"../interfaces/MongooseSchemaOptions\";\nimport {getSchema, getSchemaToken} from \"../utils/createSchema\";\n\n/**\n * Define a class as a Mongoose Schema ready to be used to compose other schemes and models.\n *\n * ### Example\n *\n * ```typescript\n * @MongooseSchema()\n * export class EventSchema {\n * @Property()\n * field: string;\n * }\n * ```\n *\n * ### Options\n *\n * - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.\n *\n * @param {MongooseSchemaOptions | undefined} options\n * @returns {(target: any) => void}\n * @decorator\n * @mongoose\n * @property\n * @class\n */\nexport function Schema(options?: MongooseSchemaOptions): (target: any) => void;\nexport function Schema(definition: SchemaTypeOptions<any>): Function;\nexport function Schema(options: MongooseSchemaOptions | SchemaTypeOptions<any> = {}) {\n return (...parameters: any[]) => {\n switch (decoratorTypeOf(parameters)) {\n case \"property\":\n return useDecorators(Property(), StoreMerge(MONGOOSE_SCHEMA, options))(parameters[0], parameters[1], parameters[2]);\n\n case \"class\":\n const {token} = getSchemaToken(parameters[0], options);\n\n registerProvider({\n provide: token,\n deps: [],\n useFactory() {\n return getSchema(parameters[0], options as any);\n }\n });\n break;\n }\n };\n}\n\n/**\n * Define a class as a Mongoose Schema ready to be used to compose other schemes and models.\n *\n * ### Example\n *\n * ```typescript\n * @MongooseSchema()\n * export class EventSchema {\n * @Property()\n * field: string;\n * }\n * ```\n *\n * ### Options\n *\n * - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.\n *\n * @param {MongooseSchemaOptions | undefined} options\n * @returns {(target: any) => void}\n * @decorator\n * @mongoose\n * @property\n * @class\n */\nexport function MongooseSchema(options?: MongooseSchemaOptions): (target: any) => void;\nexport function MongooseSchema(definition: SchemaTypeOptions<any>): Function;\nexport function MongooseSchema(options: MongooseSchemaOptions | SchemaTypeOptions<any> = {}) {\n return Schema(options as any);\n}\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/decorators/schema.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AACtE,iCAA0C;AAC1C,yCAAsC;AAEtC,sDAAuD;AAEvD,wDAAgE;AA4BhE,SAAgB,MAAM,CAAC,UAA0D,EAAE;IACjF,OAAO,CAAC,GAAG,UAAiB,EAAE,EAAE;QAC9B,QAAQ,IAAA,sBAAe,EAAC,UAAU,CAAC,EAAE;YACnC,KAAK,UAAU;gBACb,OAAO,IAAA,oBAAa,EAAC,IAAA,iBAAQ,GAAE,EAAE,IAAA,iBAAU,EAAC,2BAAe,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAEtH,KAAK,OAAO;gBACV,MAAM,EAAC,KAAK,EAAC,GAAG,IAAA,6BAAc,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAEvD,IAAA,qBAAgB,EAAC;oBACf,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,EAAE;oBACR,UAAU;wBACR,OAAO,IAAA,wBAAS,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAc,CAAC,CAAC;oBAClD,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAnBD,wBAmBC;AA4BD,SAAgB,cAAc,CAAC,UAA0D,EAAE;IACzF,OAAO,MAAM,CAAC,OAAc,CAAC,CAAC;AAChC,CAAC;AAFD,wCAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaIgnore.js","sourceRoot":"","sources":["../../../src/decorators/schemaIgnore.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AAEH,SAAgB,YAAY;IAC1B,OAAO,IAAA,uBAAc,EAAC,EAAC,YAAY,EAAE,IAAI,EAAQ,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Do not apply this property to schema (create virtual property)\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * @SchemaIgnore()\n * @Property()\n * kind: string;\n *\n * ```\n *\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\n\nexport function SchemaIgnore(): Function {\n return MongooseSchema({schemaIgnore: true} as any);\n}\n"]}
1
+ {"version":3,"file":"schemaIgnore.js","sourceRoot":"","sources":["../../../src/decorators/schemaIgnore.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AAEH,SAAgB,YAAY;IAC1B,OAAO,IAAA,uBAAc,EAAC,EAAC,YAAY,EAAE,IAAI,EAAQ,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/decorators/select.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Tell Mongoose to set default select() behavior for this path.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Select()\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} select\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Select(select: boolean | any = true) {\n return MongooseSchema({select});\n}\n"]}
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/decorators/select.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sparse.js","sourceRoot":"","sources":["../../../src/decorators/sparse.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,MAAM,CAAC,SAA2B,IAAI;IACpD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAQ,CAAC,CAAC;AACzC,CAAC;AAFD,wBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will\n * disallow changes to this path once the document is saved to the database for the first time. Read more\n * about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Sparse()\n * field: string;\n * }\n * ```\n *\n * @param {boolean | number} sparse\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Sparse(sparse: boolean | number = true): PropertyDecorator {\n return MongooseSchema({sparse} as any);\n}\n"]}
1
+ {"version":3,"file":"sparse.js","sourceRoot":"","sources":["../../../src/decorators/sparse.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,MAAM,CAAC,SAA2B,IAAI;IACpD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAQ,CAAC,CAAC;AACzC,CAAC;AAFD,wBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/decorators/text.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,IAAI,CAAC,OAA+B,IAAI;IACtD,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose\n * will build a text index on this path.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Text()\n * field: string;\n * }\n * ```\n *\n * @param {boolean | number | any} text\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Text(text: boolean | number | any = true): PropertyDecorator {\n return MongooseSchema({text} as any);\n}\n"]}
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/decorators/text.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,IAAI,CAAC,OAA+B,IAAI;IACtD,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../src/decorators/trim.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;AACtC,CAAC;AAFD,oBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Tell Mongoose to make the property trimmable.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Trim()\n * name: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Trim() {\n return MongooseSchema({trim: true});\n}\n"]}
1
+ {"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../src/decorators/trim.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;AACtC,CAAC;AAFD,oBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unique.js","sourceRoot":"","sources":["../../../src/decorators/unique.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Tell Mongoose to ensure a unique index is created for this path.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Unique()\n * index: string;\n * }\n * ```\n *\n * @param {boolean | any} unique\n * @returns {Function}\n * @decorator\n * @mongoose\n */\nexport function Unique(unique: boolean | any = true) {\n return MongooseSchema({unique});\n}\n"]}
1
+ {"version":3,"file":"unique.js","sourceRoot":"","sources":["../../../src/decorators/unique.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../src/decorators/uppercase.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase().\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Uppercase()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} uppercase\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Uppercase(uppercase: boolean = true): PropertyDecorator {\n return MongooseSchema({uppercase} as any);\n}\n"]}
1
+ {"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../src/decorators/uppercase.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"versionKey.js","sourceRoot":"","sources":["../../../src/decorators/versionKey.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,sDAA+D;AAE/D,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,mCAAuB,EAAE,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAJD,gCAIC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {MONGOOSE_SCHEMA_OPTIONS} from \"../constants/constants\";\n\nexport function VersionKey(): PropertyDecorator {\n return (target: any, propertyKey: string) => {\n Store.from(target).merge(MONGOOSE_SCHEMA_OPTIONS, {versionKey: propertyKey});\n };\n}\n"]}
1
+ {"version":3,"file":"versionKey.js","sourceRoot":"","sources":["../../../src/decorators/versionKey.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,sDAA+D;AAE/D,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,mCAAuB,EAAE,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAJD,gCAIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtualRef.js","sourceRoot":"","sources":["../../../src/decorators/virtualRef.ts"],"names":[],"mappings":";;;AAAA,qCAAqF;AACrF,yCAAoD;AACpD,sDAA4E;AAE5E,iEAA4D;AAE5D,SAAS,MAAM,CAAC,IAAS;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IAErB,OAAO,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,+BAAmB,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,OAAO,CAAC,IAAS;IACxB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACrB,OAAO,CAAC,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,+BAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,+BAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,C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{CollectionOf, Property} from \"@tsed/schema\";\nimport {MONGOOSE_MODEL_NAME, MONGOOSE_SCHEMA} from \"../constants/constants\";\nimport {MongooseVirtualRefOptions} from \"../interfaces/MongooseVirtualRefOptions\";\nimport {MongooseModels} from \"../registries/MongooseModels\";\n\nfunction getRef(opts: any) {\n const ref = opts.ref;\n\n return isString(ref) ? ref : Store.from(ref).get(MONGOOSE_MODEL_NAME);\n}\n\nfunction getType(opts: any) {\n const ref = opts.ref;\n return !isString(ref) ? ref : MongooseModels.get(ref) || (() => MongooseModels.get(ref) || Object);\n}\n\nfunction getInitialOpts(options: string | MongooseVirtualRefOptions, foreignField?: string): any {\n return isPlainObject(options) ? options : {ref: options as any, foreignField};\n}\n\nfunction mapToSchema(opts: any) {\n const ref = getRef(opts);\n\n const schema: any = {\n ref,\n localField: opts.localField || \"_id\",\n foreignField: opts.foreignField,\n justOne: opts.justOne || false,\n count: opts.count || false,\n options: opts.options\n };\n\n return schema;\n}\n\n/**\n * Define a property as mongoose virtual reference to other Model (decorated with @Model).\n *\n * ::: warning\n * To avoid circular dependencies, do not use the virtual reference model in\n * anything except a type declaration. Using the virtual reference model will prevent\n * typescript transpiler from stripping away the import statement and cause a circular\n * import in node.\n * :::\n *\n * @param ref\n * @param foreignField\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function VirtualRef(ref: string, foreignField: string): Function;\nexport function VirtualRef(options: MongooseVirtualRefOptions): Function;\nexport function VirtualRef(options: string | MongooseVirtualRefOptions, foreignField?: string): Function;\nexport function VirtualRef(options: string | MongooseVirtualRefOptions, foreignField?: string): Function {\n const opts = getInitialOpts(options, foreignField);\n const schema = mapToSchema(opts);\n const type = getType(opts);\n\n return useDecorators(\n StoreMerge(MONGOOSE_SCHEMA, schema),\n schema.count ? Property(Number) : type && (schema.justOne ? Property(type) : CollectionOf(type))\n );\n}\n\nexport type VirtualRef<T> = T | null;\nexport type VirtualRefs<T> = T[];\n"]}
1
+ {"version":3,"file":"virtualRef.js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xC,sEAA4C;AAC5C,yEAA+C;AAC/C,qEAA2C;AAC3C,8DAAoC;AACpC,+DAAqC;AACrC,iEAAuC;AACvC,gEAAsC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./MongooseModule\";\nexport * from \"./constants/constants\";\nexport * from \"./decorators/auto\";\nexport * from \"./decorators/discriminatorKey\";\nexport * from \"./decorators/dynamicRef\";\nexport * from \"./decorators/excludeIndexes\";\nexport * from \"./decorators/expires\";\nexport * from \"./decorators/immutable\";\nexport * from \"./decorators/indexed\";\nexport * from \"./decorators/lowercase\";\nexport * from \"./decorators/model\";\nexport * from \"./decorators/mongooseIndex\";\nexport * from \"./decorators/mongooseIndexes\";\nexport * from \"./decorators/mongoosePlugin\";\nexport * from \"./decorators/numberDecimal\";\nexport * from \"./decorators/objectID\";\nexport * from \"./decorators/postHook\";\nexport * from \"./decorators/preHook\";\nexport * from \"./decorators/ref\";\nexport * from \"./decorators/schema\";\nexport * from \"./decorators/schemaIgnore\";\nexport * from \"./decorators/select\";\nexport * from \"./decorators/sparse\";\nexport * from \"./decorators/text\";\nexport * from \"./decorators/trim\";\nexport * from \"./decorators/unique\";\nexport * from \"./decorators/uppercase\";\nexport * from \"./decorators/versionKey\";\nexport * from \"./decorators/virtualRef\";\nexport * from \"./interfaces/MongooseConnectionOptions\";\nexport * from \"./interfaces/MongooseDocument\";\nexport * from \"./interfaces/MongooseModel\";\nexport * from \"./interfaces/MongooseModelOptions\";\nexport * from \"./interfaces/MongooseSchemaOptions\";\nexport * from \"./interfaces/MongooseSchemaTypes\";\nexport * from \"./interfaces/MongooseVirtualRefOptions\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./registries/MongooseModels\";\nexport * from \"./services/MongooseConnections\";\nexport * from \"./services/MongooseService\";\nexport * from \"./utils/createModel\";\nexport * from \"./utils/createSchema\";\nexport * from \"./utils/resolveRefType\";\nexport * from \"./utils/schemaOptions\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2DAAiC;AACjC,gEAAsC;AACtC,4DAAkC;AAClC,wEAA8C;AAC9C,kEAAwC;AACxC,sEAA4C;AAC5C,+DAAqC;AACrC,iEAAuC;AACvC,+DAAqC;AACrC,iEAAuC;AACvC,6DAAmC;AACnC,qEAA2C;AAC3C,uEAA6C;AAC7C,sEAA4C;AAC5C,qEAA2C;AAC3C,gEAAsC;AACtC,gEAAsC;AACtC,+DAAqC;AACrC,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,8DAAoC;AACpC,8DAAoC;AACpC,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,iEAAuC;AACvC,kEAAwC;AACxC,kEAAwC;AACxC,iFAAuD;AACvD,wEAA8C;AAC9C,qEAA2C;AAC3C,4EAAkD;AAClD,6EAAmD;AACnD,2EAAiD;AACjD,iFAAuD;AACvD,kEAAwC;AACxC,sEAA4C;AAC5C,yEAA+C;AAC/C,qEAA2C;AAC3C,8DAAoC;AACpC,+DAAqC;AACrC,iEAAuC;AACvC,gEAAsC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseConnectionOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseConnectionOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {ConnectOptions} from \"mongoose\";\n\nexport interface MongooseConnectionOptions {\n url: string;\n /**\n * The connection ID\n */\n id: string;\n connectionOptions?: ConnectOptions;\n}\n"]}
1
+ {"version":3,"file":"MongooseConnectionOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseConnectionOptions.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseDocument.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseDocument.ts"],"names":[],"mappings":"","sourcesContent":["import {Document} from \"mongoose\";\n\nexport type MongooseDocument<T> = T & Document;\n"]}
1
+ {"version":3,"file":"MongooseDocument.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseDocument.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseModel.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseModel.ts"],"names":[],"mappings":"","sourcesContent":["import {Document, Model} from \"mongoose\";\n\n// TODO since v5.11.5 Model require Document with id, See issue https://github.com/Automattic/mongoose/issues/9684\nexport type MongooseMergedDocument<T> = {[K in keyof T]: T[K]};\n\nexport interface MongooseDocumentMethods<T> {\n toClass(): T;\n}\n\nexport type MongooseModel<T> = Model<MongooseMergedDocument<Document & T & MongooseDocumentMethods<T>>>;\n"]}
1
+ {"version":3,"file":"MongooseModel.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseModel.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseModelOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseModelOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseSchemaOptions} from \"./MongooseSchemaOptions\";\nimport {CompileModelOptions} from \"mongoose\";\n\nexport interface MongooseModelOptions extends MongooseSchemaOptions {\n name?: string;\n connection?: string;\n collection?: string;\n overwriteModels?: boolean;\n /**\n * @deprecated Since 2022-11-30. Use @DiscriminatorValue instead\n */\n discriminatorValue?: string;\n}\n"]}
1
+ {"version":3,"file":"MongooseModelOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseModelOptions.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseSchemaOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseSchemaOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Schema, SchemaOptions} from \"mongoose\";\nimport {MongooseDocument} from \"./MongooseDocument\";\n\nexport type MongooseNextCB = (err?: Error) => void;\n\nexport interface MongooseHookOptions {\n document?: boolean;\n query?: boolean;\n parallel?: boolean;\n}\n\nexport type MongooseHookPromised<T = any> = (doc: T | MongooseDocument<T>) => Promise<void> | void;\n\nexport type MongoosePreHookCB<T = any> = ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | MongooseHookPromised;\n\nexport type MongoosePostHookCB<T = any> =\n | ((doc: T | MongooseDocument<T>, error: Error, next: MongooseNextCB) => void)\n | ((doc: T | MongooseDocument<T>, error: Error) => Promise<void> | void)\n | ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void)\n | MongooseHookPromised;\n\nexport interface MongoosePreHook<T = any> {\n method: string | RegExp;\n fn: MongoosePreHookCB<T>;\n options?: MongooseHookOptions;\n}\n\nexport interface MongoosePostHook<T = any> {\n method: string | RegExp;\n fn: MongoosePostHookCB<T>;\n options?: MongooseHookOptions;\n}\n\nexport interface MongoosePluginOptions {\n plugin: (schema: Schema, options?: any) => void;\n options?: Record<string, unknown>;\n}\n\nexport interface MongooseIndexOptions {\n fields: Record<any, any>;\n options?: Record<string, unknown>;\n}\n\nexport interface MongooseSchemaOptions {\n schemaOptions?: SchemaOptions;\n plugins?: MongoosePluginOptions[];\n indexes?: MongooseIndexOptions[];\n pre?: MongoosePreHook[];\n post?: MongoosePostHook[];\n}\n"]}
1
+ {"version":3,"file":"MongooseSchemaOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseSchemaOptions.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseSchemaTypes.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseSchemaTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,6CAAsB,CAAA;IACtB,wCAAiB,CAAA;IACjB,wCAAiB,CAAA;AACnB,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B","sourcesContent":["export enum MongooseSchemaTypes {\n OBJECT_ID = \"ObjectId\",\n STRING = \"String\",\n NUMBER = \"Number\"\n}\n"]}
1
+ {"version":3,"file":"MongooseSchemaTypes.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseSchemaTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,6CAAsB,CAAA;IACtB,wCAAiB,CAAA;IACjB,wCAAiB,CAAA;AACnB,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseVirtualRefOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseVirtualRefOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\n\nexport interface MongooseVirtualRefOptions {\n ref?: string | Type<any> | (() => Type<any>);\n foreignField?: string;\n localField?: string;\n justOne?: boolean;\n count?: boolean;\n options?: object;\n}\n"]}
1
+ {"version":3,"file":"MongooseVirtualRefOptions.js","sourceRoot":"","sources":["../../../src/interfaces/MongooseVirtualRefOptions.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseConnectionOptions} from \"./MongooseConnectionOptions\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n mongoose: Omit<MongooseConnectionOptions, \"id\"> | MongooseConnectionOptions[];\n }\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseModels.js","sourceRoot":"","sources":["../../../src/registries/MongooseModels.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAsB,IAAI,GAAG,EAAE,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\n\nexport const MongooseModels: Map<string, Type> = new Map();\n"]}
1
+ {"version":3,"file":"MongooseModels.js","sourceRoot":"","sources":["../../../src/registries/MongooseModels.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAsB,IAAI,GAAG,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version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B;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport {isArray} from \"@tsed/core\";\nimport {MongooseConnectionOptions} from \"../interfaces/MongooseConnectionOptions\";\nimport {MongooseService} from \"../services/MongooseService\";\n\n/**\n * @ignore\n */\n// tslint:disable-next-line:variable-name\nexport const MONGOOSE_CONNECTIONS = Symbol.for(\"MONGOOSE_CONNECTIONS\");\n/**\n * @ignore\n */\nexport type MONGOOSE_CONNECTIONS = MongooseService;\n\nfunction mapOptions(options: Omit<MongooseConnectionOptions, \"id\"> | MongooseConnectionOptions[]): MongooseConnectionOptions[] {\n if (!options) {\n return [];\n }\n\n if (!isArray(options)) {\n const {url, connectionOptions} = options || {};\n\n return [\n {\n id: \"default\",\n url,\n connectionOptions\n }\n ];\n }\n\n return (options as MongooseConnectionOptions[]).map((settings) => {\n return {\n ...settings,\n connectionOptions: settings.connectionOptions\n };\n });\n}\n\nregisterProvider({\n provide: MONGOOSE_CONNECTIONS,\n injectable: false,\n deps: [Configuration, MongooseService],\n async useAsyncFactory(configuration: Configuration, mongooseService: MongooseService) {\n const settings = mapOptions(configuration.get<MongooseConnectionOptions | MongooseConnectionOptions[]>(\"mongoose\"));\n let isDefault = true;\n\n for (const current of settings) {\n await mongooseService.connect(current.id, current.url, current.connectionOptions || {}, isDefault);\n\n isDefault = false;\n }\n\n return mongooseService;\n }\n});\n"]}
1
+ {"version":3,"file":"MongooseConnections.js","sourceRoot":"","sources":["../../../src/services/MongooseConnections.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AACzD,qCAAmC;AAEnC,iEAA4D;AAE5D;;GAEG;AACH,yCAAyC;AAC5B,QAAA,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAMvE,SAAS,UAAU,CAAC,OAA4E;IAC9F,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;IAED,IAAI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1B,OAAO,CAAC,IAAI,EAAE,CAAC;SAChB;IACH,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,EAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,EAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE;YACzD,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAC7B;IACH,CAAC;CACF,CAAA;AA5DC;IADC,IAAA,WAAM,GAAE;sCACD,eAAM;+CAAC;AALJ,eAAe;IAD3B,IAAA,eAAU,GAAE;GACA,eAAe,CAiE3B;AAjEY,0CAAe","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport Mongoose from \"mongoose\";\nimport {ConnectOptions} from \"mongoose\";\n\n// istanbul ignore next\nfunction asPromise(c: any) {\n return c && c.asPromise ? c.asPromise() : c;\n}\n\n@Injectable()\nexport class MongooseService {\n readonly connections: Map<string, Mongoose.Connection> = new Map();\n private defaultConnection: string = \"default\";\n\n @Inject()\n logger: Logger;\n\n /**\n *\n * @returns {Promise<\"mongoose\".Connection>}\n */\n async connect(id: string, url: string, connectionOptions: ConnectOptions, isDefault = false): Promise<any> {\n if (this.has(id)) {\n return await this.get(id)!;\n }\n\n this.logger.info(`Connect to mongo database: ${id}`);\n this.logger.debug(`Url: ${url}`);\n this.logger.debug(`options: ${JSON.stringify(connectionOptions)}`);\n\n try {\n const connection = await asPromise(Mongoose.createConnection(url, connectionOptions));\n this.connections.set(id, connection);\n\n if (id === \"default\" || isDefault) {\n this.defaultConnection = id;\n }\n\n return connection;\n } catch (er) {\n /* istanbul ignore next */\n this.logger.error({\n event: \"MONGO_CONNECTION_ERROR\",\n error_name: er.name,\n message: er.message,\n stack: er.stack\n });\n /* istanbul ignore next */\n process.exit();\n }\n }\n\n /**\n *\n * @returns {\"mongoose\".Connection}\n */\n get(id?: string): Mongoose.Connection | undefined {\n return this.connections.get(id || this.defaultConnection);\n }\n\n /**\n *\n * @param {string} id\n * @returns {boolean}\n */\n has(id?: string): boolean {\n return this.connections.has(id || this.defaultConnection);\n }\n\n async closeConnections() {\n for (const [id, connection] of this.connections.entries()) {\n await connection.close();\n this.connections.delete(id);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MongooseService.js","sourceRoot":"","sources":["../../../src/services/MongooseService.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,yCAAoC;AACpC,gEAAgC;AAGhC,uBAAuB;AACvB,SAAS,SAAS,CAAC,CAAM;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;IACjB,WAAW,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC3D,iBAAiB,GAAW,SAAS,CAAC;IAG9C,MAAM,CAAS;IAEf;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,GAAW,EAAE,iBAAiC,EAAE,SAAS,GAAG,KAAK;QACzF,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAChB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;SAC5B;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,C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;QAC3E,OAAO,aAAa,CAAC,cAAc,EAAE,CAAC,iBAAiB,CAAC,IAAI,aAAa,CAAC,aAAa,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;KACpH;IAED,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,EAAC,eAAe,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,MAAM,CAAC,GAAG,UAAU,IAAI,kBAAQ,CAAC;IAEjC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACtD,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,0BAAc,EAAE,KAAK,CAAC,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC;AAzBD,kCAyBC","sourcesContent":["import {nameOf, Store, Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"@tsed/schema\";\nimport mongoose, {Connection} from \"mongoose\";\nimport {MONGOOSE_MODEL, MONGOOSE_MODEL_NAME} from \"../constants/constants\";\nimport {MongooseModels} from \"../registries/MongooseModels\";\nimport {getSchemaToken} from \"./createSchema\";\n\nexport function getModelToken(target: Type<any>, options: any) {\n const {collectionName, token} = getSchemaToken(target, options);\n\n Store.from(target).set(MONGOOSE_MODEL_NAME, collectionName);\n MongooseModels.set(collectionName, target);\n\n return {token, collectionName};\n}\n\n/**\n * Create an instance of mongoose.model from a class.\n *\n * @param {Type<any>} target Class attached to the schema and model.\n * @param {\"mongoose\".Schema} schema Schema that will be attached to the model.\n * @param name model name\n * @param collection (optional, induced from model name)\n * @param overwriteModels\n * @param connection\n * @returns {Model<T extends Document>}\n */\nexport function createModel<T>(\n target: any,\n schema: mongoose.Schema,\n name: string = nameOf(target),\n collection?: string,\n overwriteModels?: boolean,\n connection?: Connection\n) {\n const entity = JsonEntityStore.from(target);\n\n if (entity.isDiscriminatorChild) {\n const discriminatorName = entity.discriminatorAncestor!.schema.discriminator().getDefaultValue(target)!;\n const ancestorModel = entity.discriminatorAncestor!.get(MONGOOSE_MODEL);\n\n // check if discriminator is already registered on model before creating it\n return ancestorModel.discriminators?.[discriminatorName] || ancestorModel.discriminator(discriminatorName, schema);\n }\n\n const opts = overwriteModels ? {overwriteModels} : undefined;\n const c = connection || mongoose;\n\n const model = c.model(name, schema, collection, opts);\n Store.from(target).set(MONGOOSE_MODEL, model);\n\n return model;\n}\n"]}
1
+ {"version":3,"file":"createModel.js","sourceRoot":"","sources":["../../../src/utils/createModel.ts"],"names":[],"mappings":";;;;AAAA,qCAA+C;AAC/C,yCAA6C;AAC7C,gEAA8C;AAC9C,sDAA2E;AAC3E,iEAA4D;AAC5D,iDAA8C;AAE9C,SAAgB,aAAa,CAAC,MAAiB,EAAE,OAAY;IAC3D,MAAM,EAAC,cAAc,EAAE,KAAK,EAAC,GAAG,IAAA,6BAAc,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhE,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,+BAAmB,EAAE,cAAc,CAAC,CAAC;IAC5D,+BAAc,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAE3C,OAAO,EAAC,KAAK,EAAE,cAAc,EAAC,CAAC;AACjC,CAAC;AAPD,sCAOC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CACzB,MAAW,EACX,MAAuB,EACvB,OAAe,IAAA,aAAM,EAAC,MAAM,CAAC,EAC7B,UAAmB,EACnB,eAAyB,EACzB,UAAuB;IAEvB,MAAM,MAAM,GAAG,wBAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE5C,IAAI,MAAM,CAAC,oBAAoB,EAAE;QAC/B,MAAM,iBAAiB,GAAG,MAAM,CAAC,qBAAsB,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,eAAe,CAAC,MAAM,CAAE,CAAC;QACxG,MAAM,aAAa,GAAG,MAAM,CAAC,qBA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AoB,CAAC,CAAC;SACpG;QAED,OAAO,EAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,iBAAiB,EAAoC,CAAC;KAC9E;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AArDD,0DAqDC","sourcesContent":["import {cleanObject, nameOf, Store, Type} from \"@tsed/core\";\nimport {deserialize, serialize} from \"@tsed/json-mapper\";\nimport {getProperties, JsonEntityStore} from \"@tsed/schema\";\nimport {pascalCase} from \"change-case\";\nimport mongoose, {Schema, SchemaDefinition, SchemaOptions, SchemaTypeOptions} from \"mongoose\";\nimport {MONGOOSE_SCHEMA, MONGOOSE_SCHEMA_OPTIONS} from \"../constants/constants\";\nimport {MongooseSchemaOptions} from \"../interfaces/MongooseSchemaOptions\";\nimport {MongooseVirtualRefOptions} from \"../interfaces/MongooseVirtualRefOptions\";\nimport {resolveRefType} from \"./resolveRefType\";\nimport {schemaOptions} from \"./schemaOptions\";\n\nexport interface MongooseSchemaMetadata {\n schema: SchemaDefinition;\n virtuals: Map<string, MongooseVirtualRefOptions>;\n}\n\n/**\n * @ignore\n */\nfunction setUpSchema({schema, virtuals}: MongooseSchemaMetadata, options?: SchemaOptions) {\n const mongooseSchema = new mongoose.Schema(schema, options);\n\n for (const [key, options] of virtuals.entries()) {\n mongooseSchema.virtual(key, options);\n }\n\n return mongooseSchema;\n}\n\n/**\n * @ignore\n */\nfunction isVirtualRef(target: Partial<MongooseVirtualRefOptions>): target is MongooseVirtualRefOptions {\n return !!(target.ref && target.localField && target.foreignField);\n}\n\nfunction hasVersionField(schema: mongoose.Schema, versionKey?: string | boolean) {\n // Check if versioning was disabled explicitly\n if (!versionKey) return false;\n\n // Check for alternative version field in schema\n return (versionKey as string) in schema.paths;\n}\n\nexport function createSchema(target: Type<any>, options: MongooseSchemaOptions = {}): mongoose.Schema {\n const entity = JsonEntityStore.from(target);\n const schemaOptionsFromStore = entity.store.get(MONGOOSE_SCHEMA_OPTIONS) || {};\n options.schemaOptions = {...options.schemaOptions, ...schemaOptionsFromStore};\n\n if (entity.schema.isDiscriminator) {\n options.schemaOptions!.discriminatorKey = entity.schema.discriminator().propertyName;\n }\n\n const schema = setUpSchema(buildMongooseSchema(target), options.schemaOptions);\n\n schemaOptions(target, options);\n\n const outputVersionKey = hasVersionField(schema, options.schemaOptions?.versionKey);\n\n schema.methods.toClass = function toClass() {\n return deserialize(\n this.toObject({\n virtuals: true,\n versionKey: outputVersionKey,\n flattenMaps: true\n }),\n {\n type: target,\n useAlias: false,\n additionalProperties: true,\n disabledUnsecureConstructor: false,\n groups: false\n }\n );\n };\n\n schema.methods.toJSON = function toJSON(options?: any) {\n return serialize((this as any).toClass(), options);\n };\n\n schema.loadClass(target);\n\n Store.from(target).set(MONGOOSE_SCHEMA, schema);\n\n return schema;\n}\n\n/**\n * Get a schema already created. If the schema doesn't exists in registry, it'll be created.\n * @param target\n * @param options\n */\nexport function getSchema(target: Type<any>, options: MongooseSchemaOptions = {}): Schema {\n const store = Store.from(target);\n\n if (!store.has(MONGOOSE_SCHEMA)) {\n createSchema(target, options);\n }\n\n return store.get(MONGOOSE_SCHEMA);\n}\n\nexport function getSchemaToken(target: Type<any>, options?: any) {\n const collectionName = options.name || nameOf(target);\n const token = Symbol.for(pascalCase(`${collectionName}Schema`));\n\n return {token, collectionName};\n}\n\n/**\n * @ignore\n */\nexport function buildMongooseSchema(target: any): MongooseSchemaMetadata {\n const properties = getProperties(target, {withIgnoredProps: true, mongoose: true, groups: false});\n const schema: MongooseSchemaMetadata = {schema: {}, virtuals: new Map()};\n\n properties.forEach((propertyMetadata, key) => {\n // Keeping the Mongoose Schema separate, so it can overwrite everything once schema has been built.\n const schemaTypeOptions: any = propertyMetadata.store.get(MONGOOSE_SCHEMA) || {};\n\n if (schemaTypeOptions.schemaIgnore || propertyMetadata.isDiscriminatorKey() || propertyMetadata.isGetterOnly()) {\n return;\n }\n\n if (schemaTypeOptions.ref) {\n schemaTypeOptions.ref = resolveRefType(schemaTypeOptions.ref as any);\n }\n\n if (isVirtualRef(schemaTypeOptions)) {\n schema.virtuals.set(key as string, schemaTypeOptions);\n\n return;\n }\n\n schema.schema[key as string] = createSchemaTypeOptions(propertyMetadata);\n });\n\n return schema;\n}\n\n/**\n * @ignore\n */\nexport function createSchemaTypeOptions<T = any>(propEntity: JsonEntityStore): SchemaTypeOptions<T> | SchemaTypeOptions<T>[] {\n const key = propEntity.propertyKey;\n const rawMongooseSchema = propEntity.store.get(MONGOOSE_SCHEMA) || {};\n\n let schemaTypeOptions: SchemaTypeOptions<T> = {\n required: propEntity.required\n ? function () {\n return propEntity.isRequired(this[key]);\n }\n : false\n };\n\n if (!propEntity.isClass) {\n const jsonSchema = propEntity.itemSchema.toJSON();\n const {minimum: min, maximum: max, minLength: minlength, maxLength: maxlength} = jsonSchema;\n\n let match: string | RegExp = jsonSchema.pattern;\n if (match) {\n match = new RegExp(match);\n }\n\n schemaTypeOptions = {\n ...schemaTypeOptions,\n type: propEntity.type,\n match: match as RegExp,\n min,\n max,\n minlength,\n maxlength,\n enum: jsonSchema[\"enum\"],\n default: jsonSchema[\"default\"]\n };\n } else if (!rawMongooseSchema.ref) {\n // References are handled by the final merge\n schemaTypeOptions = {...schemaTypeOptions, type: getSchema(propEntity.type) as any};\n }\n\n schemaTypeOptions = cleanObject({...schemaTypeOptions, ...rawMongooseSchema});\n\n if (propEntity.isCollection) {\n if (propEntity.isArray) {\n return [schemaTypeOptions];\n }\n // Can be a Map or a Set;\n // Mongoose implements only Map;\n if (propEntity.collectionType !== Map) {\n throw new Error(`Invalid collection type. ${nameOf(propEntity.collectionType)} is not supported.`);\n }\n\n return {type: Map, of: schemaTypeOptions} as unknown as SchemaTypeOptions<T>;\n }\n\n return schemaTypeOptions;\n}\n"]}
1
+ {"version":3,"file":"createSchema.js","sourceRoot":"","sources":["../../../src/utils/createSchema.ts"],"names":[],"mappings":";;;;AAAA,qCAA4D;AAC5D,mDAAyD;AACzD,yCAA4D;AAC5D,6CAAuC;AACvC,gEAA8F;AA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BAAiB,GAAG,EAAC,GAAG,iBAAiB,EAAE,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAQ,EAAC,CAAC;KACrF;IAED,iBAAiB,GAAG,IAAA,kBAAW,EAAC,EAAC,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IAE9E,IAAI,UAAU,CAAC,YAAY,EAAE;QAC3B,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,iBAAiB,CAAC,CAAC;SAC5B;QACD,yBAAyB;QACzB,gCAAgC;QAChC,IAAI,UAAU,CAAC,cAAc,KAAK,GAAG,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAA,aAAM,EAAC,UAAU,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;SACpG;QAED,OAAO,EAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,iBAAiB,EAAoC,CAAC;KAC9E;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AArDD,0DAqDC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRefType.js","sourceRoot":"","sources":["../../../src/utils/resolveRefType.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAClE,sDAA2D;AAE3D;;GAEG;AACH,SAAgB,cAAc,CAAC,IAA4C;IACzE,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QAClB,IAAI,GAAI,IAAY,EAAE,CAAC;KACxB;IAED,OAAO,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,+BAAmB,CAAC,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAVD,wCAUC","sourcesContent":["import {isClass, isString, nameOf, Store, Type} from \"@tsed/core\";\nimport {MONGOOSE_MODEL_NAME} from \"../constants/constants\";\n\n/**\n * @ignore\n */\nexport function resolveRefType(type: string | (() => Type<any>) | Type<any>): string {\n if (isString(type)) {\n return type;\n }\n\n if (!isClass(type)) {\n type = (type as any)();\n }\n\n return Store.from(type).get(MONGOOSE_MODEL_NAME) || nameOf(type);\n}\n"]}
1
+ {"version":3,"file":"resolveRefType.js","sourceRoot":"","sources":["../../../src/utils/resolveRefType.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAClE,sDAA2D;AAE3D;;GAEG;AACH,SAAgB,cAAc,CAAC,IAA4C;IACzE,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QAClB,IAAI,GAAI,IAAY,EAAE,CAAC;KACxB;IAED,OAAO,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,+BAAmB,CAAC,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAVD,wCAUC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,sDAA+D;AAU/D;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAW,EAAE,OAA+B;IACxE,MAAM,KAAK,GAAG,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAAC,EAAE;QACvC,KAAK,CAAC,GAAG,CAAC,mCAAuB,EAAE,EAAE,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,GAAG,CAAC,mCAAuB,EAAE,IAAA,gBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAA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,CAAC;YAED,MAAM,CAAC,GAAW,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAE,MAAM,CAAC,IAAY,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5E;AACH,CAAC;AAvBD,gDAuBC","sourcesContent":["import {deepMerge, Store} from \"@tsed/core\";\nimport {Schema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA_OPTIONS} from \"../constants/constants\";\nimport {\n MongooseHookPromised,\n MongooseNextCB,\n MongoosePostHook,\n MongoosePreHook,\n MongoosePreHookCB,\n MongooseSchemaOptions\n} from \"../interfaces/MongooseSchemaOptions\";\n\n/**\n * @ignore\n */\nexport function schemaOptions(target: any, options?: MongooseSchemaOptions) {\n const store = Store.from(target);\n\n if (!store.has(MONGOOSE_SCHEMA_OPTIONS)) {\n store.set(MONGOOSE_SCHEMA_OPTIONS, {});\n }\n\n if (options) {\n store.set(MONGOOSE_SCHEMA_OPTIONS, deepMerge(store.get(MONGOOSE_SCHEMA_OPTIONS), options));\n }\n\n return store.get(MONGOOSE_SCHEMA_OPTIONS);\n}\n\nfunction mapHookArgs(hook: MongoosePreHook | MongoosePostHook): [string | RegExp, Function] {\n return [hook.method, hook.options || hook.fn, hook.options ? hook.fn : undefined].filter(Boolean) as any;\n}\n\n/**\n * @ignore\n */\nexport function buildPreHook(fn: MongoosePreHookCB) {\n return fn.length === 1\n ? function () {\n return (fn as MongooseHookPromised)(this);\n }\n : function (next: MongooseNextCB) {\n return fn(this, next);\n };\n}\n\n/**\n * @ignore\n */\nexport function applySchemaOptions(schema: Schema, options: MongooseSchemaOptions) {\n if (options.plugins) {\n options.plugins.forEach((item) => schema.plugin(item.plugin, item.options));\n }\n\n if (options.indexes) {\n options.indexes.forEach((item) => schema.index(item.fields, item.options));\n }\n\n if (options.pre) {\n options.pre.forEach((item) => {\n item = {\n ...item,\n fn: buildPreHook(item.fn)\n };\n\n (schema.pre as any)(...mapHookArgs(item));\n });\n }\n\n if (options.post) {\n options.post.forEach((item) => (schema.post as any)(...mapHookArgs(item)));\n }\n}\n"]}
1
+ {"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,sDAA+D;AAU/D;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAW,EAAE,OAA+B;IACxE,MAAM,KAAK,GAAG,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAAC,EAAE;QACvC,KAAK,CAAC,GAAG,CAAC,mCAAuB,EAAE,EAAE,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,GAAG,CAAC,mCAAuB,EAAE,IAAA,gBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,mCAAuB,CAAC,CAAC;AAC5C,CAAC;AAZD,sCAYC;AAED,SAAS,WAAW,CAAC,IAAwC;IAC3D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAqB;IAChD,OAAO,EAAE,CAAC,MAAM,KAAK,CAAC;QACpB,CAAC,CAAC;YACE,OAAQ,EAA2B,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;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AU,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAY,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AAIH,IAAa,cAAc,GAA3B,MAAa,cAAc;IACL;IAA2D;IAA/E,YAAoB,eAAgC,EAA2B,QAAuB;QAAlF,oBAAe,GAAf,eAAe,CAAiB;QAA2B,aAAQ,GAAR,QAAQ,CAAe;QACpG,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,EAAE,QAAQ,EAAE;YACnB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,KAAyB,CAAC;IAEjC,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAhBY,cAAc;IAH1B,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,oBAAoB,CAAC;KAChC,CAAC;IAEuD,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GADzC,cAAc,CAgB1B;SAhBY,cAAc","sourcesContent":["import {Configuration, OnInit} from \"@tsed/di\";\nimport {Module, OnDestroy} from \"@tsed/di\";\nimport {MONGOOSE_CONNECTIONS} from \"./services/MongooseConnections\";\nimport {MongooseService} from \"./services/MongooseService\";\n\n/**\n * @ignore\n */\n@Module({\n imports: [MONGOOSE_CONNECTIONS]\n})\nexport class MongooseModule implements OnDestroy, OnInit {\n constructor(private mongooseService: MongooseService, @Configuration() private settings: Configuration) {\n // auto configure the cache manager when mongoose is used with @tsed/mongoose\n const cache = this.settings.get<any>(\"cache\");\n\n // istanbul ignore next\n if (cache?.mongoose) {\n cache.connection = this.mongooseService.get();\n }\n }\n\n $onInit(): void | Promise<any> {}\n\n $onDestroy(): Promise<any> | void {\n return this.mongooseService.closeConnections();\n }\n}\n"]}
1
+ {"version":3,"file":"MongooseModule.js","sourceRoot":"","sources":["../../src/MongooseModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAS,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAY,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AAII,IAAM,cAAc,GAApB,MAAM,cAAc;IACL;IAA2D;IAA/E,YAAoB,eAAgC,EAA2B,QAAuB;QAAlF,oBAAe,GAAf,eAAe,CAAiB;QAA2B,aAAQ,GAAR,QAAQ,CAAe;QACpG,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,EAAE,QAAQ,EAAE;YACnB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,KAAyB,CAAC;IAEjC,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAhBY,cAAc;IAH1B,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,oBAAoB,CAAC;KAChC,CAAC;IAEuD,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GADzC,cAAc,CAgB1B;SAhBY,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AACtE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA = \"tsed:mongoose:schema\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA_OPTIONS = \"tsed:mongoose:schema:options\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL = \"tsed:mongoose:model\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL_NAME = \"tsed:mongoose:model:name\";\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACtD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AACtE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACpD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,cAAc,CAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, uses Mongoose's default _id settings. Only allowed for ObjectIds\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} auto\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Auto(auto: boolean = true): PropertyDecorator {\n return MongooseSchema({auto} as any);\n}\n"]}
1
+ {"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,cAAc,CAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC","sourcesContent":["export {DiscriminatorKey} from \"@tsed/schema\";\n"]}
1
+ {"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,UAAU,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACzF,OAAO,EAAC,WAAW,EAAE,OAAO,EAAmB,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,UAAU,CAAC;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAE5D,SAAS,KAAK,CAA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AC,MAAM,EAAE,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,GAAG,KAAK,CAAC,CAC7E,CAAC;AACzB,CAAC","sourcesContent":["import {classOf, isArrowFn, isString, StoreMerge, Type, useDecorators} from \"@tsed/core\";\nimport {Description, Example, JsonHookContext, OneOf, Property, string} from \"@tsed/schema\";\nimport {Schema as MongooseSchema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants/constants\";\nimport {deserialize, OnDeserialize, OnSerialize, serialize} from \"@tsed/json-mapper\";\nimport {MongooseModels} from \"../registries/MongooseModels\";\n\nfunction isRef(value: undefined | string | any) {\n return (value && value._bsontype) || isString(value);\n}\n\nfunction getType(refPath: string, ctx: JsonHookContext) {\n return (ctx?.self[refPath] && MongooseModels.get(ctx.self[refPath] as string)) || Object;\n}\n\n/**\n * Define a property as mongoose reference to other Model (decorated with @Model).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * class FooModel {\n *\n * @DynamicRef('type')\n * field: DynamicRef<OtherFooModel | OtherModel>\n *\n * @Enum(['OtherFooModel', 'OtherModel'])\n * type: string\n * }\n *\n * @Model()\n * class OtherFooModel {\n * }\n *\n * @Model()\n * class OtherModel {\n * }\n * ```\n *\n * @param refPath {String} the path to apply the correct model\n * @param types {Type} the classes to generate the correct json schema\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function DynamicRef(refPath: string, ...types: Type<any>[]): PropertyDecorator {\n return useDecorators(\n Property(Object),\n Example(\"5ce7ad3028890bd71749d477\"),\n Description(\"A reference ObjectID\"),\n StoreMerge(MONGOOSE_SCHEMA, {\n type: MongooseSchema.Types.ObjectId,\n refPath\n }),\n OnDeserialize((value, ctx) => {\n if (isRef(value)) {\n return value.toString();\n }\n\n return deserialize(value, {...ctx, type: getType(refPath, ctx)});\n }),\n OnSerialize((value: any, ctx) => {\n if (isRef(value)) {\n return value.toString();\n }\n\n return serialize(value, {...ctx, type: getType(refPath, ctx)});\n }),\n OneOf(string().example(\"5ce7ad3028890bd71749d477\").description(\"A reference ObjectID\"), ...types)\n ) as PropertyDecorator;\n}\n\nexport type DynamicRef<T> = T | string;\n"]}
1
+ {"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,UAAU,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACzF,OAAO,EAAC,WAAW,EAAE,OAAO,EAAmB,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,UAAU,CAAC;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAE5D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,GAAoB;IACpD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAW,CAAC,CAAC,IAAI,MAAM,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,GAAG,KAAkB;IAC/D,OAAO,aAAa,CAClB,QAAQ,CAAC,MAAM,CAAC,EAChB,OAAO,CAAC,0BAA0B,CAAC,EACnC,WAAW,CAAC,sBAAsB,CAAC,EACnC,UAAU,CAAC,eAAe,EAAE;QAC1B,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,QAAQ;QACnC,OAAO;KACR,CAAC,EACF,aAAa,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC3B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,WAAW,CAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACnE,CAAC,CAAC,EACF,WAAW,CAAC,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,SAAS,CAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACjE,CAAC,CAAC,EACF,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,GAAG,KAAK,CAAC,CAC7E,CAAC;AACzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"excludeIndexes.js","sourceRoot":"","sources":["../../../src/decorators/excludeIndexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAAC,iBAA0B,IAAI;IAC3D,OAAO,cAAc,CAAC,EAAC,cAAc,EAAQ,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} excludeIndexes\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function ExcludeIndexes(excludeIndexes: boolean = true): PropertyDecorator {\n return MongooseSchema({excludeIndexes} as any);\n}\n"]}
1
+ {"version":3,"file":"excludeIndexes.js","sourceRoot":"","sources":["../../../src/decorators/excludeIndexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAAC,iBAA0B,IAAI;IAC3D,OAAO,cAAc,CAAC,EAAC,cAAc,EAAQ,CAAC,CAAC;AACjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,OAAO,CAAC,OAA+B;IACrD,OAAO,cAAc,CAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Defines a TTL index on this path. Only allowed for dates.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Expires('5d')\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} expires\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Expires(expires: number | string | Date): PropertyDecorator {\n return MongooseSchema({expires} as any);\n}\n"]}
1
+ {"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,OAAO,CAAC,OAA+B;IACrD,OAAO,cAAc,CAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC"}