@tsed/mongoose 8.33.0 → 8.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/decorators/dynamicRef.js +3 -3
- package/lib/esm/decorators/model.js +4 -4
- package/lib/esm/decorators/numberDecimal.js +3 -3
- package/lib/esm/decorators/objectID.js +2 -2
- package/lib/esm/decorators/postHook.js +1 -1
- package/lib/esm/decorators/preHook.js +1 -1
- package/lib/esm/decorators/ref.js +5 -5
- package/lib/esm/decorators/schema.js +4 -4
- package/lib/esm/decorators/versionKey.js +1 -1
- package/lib/esm/decorators/virtualRef.js +1 -1
- package/lib/esm/services/MongooseConnections.js +1 -1
- package/lib/esm/utils/createModel.js +4 -4
- package/lib/esm/utils/createSchema.js +5 -5
- package/lib/esm/utils/resolveRefType.js +1 -1
- package/lib/esm/utils/schemaOptions.js +1 -1
- package/lib/types/decorators/schema.d.ts +1 -1
- package/lib/types/services/MongooseService.d.ts +1 -1
- package/lib/types/utils/createSchema.d.ts +1 -1
- package/lib/types/utils/schemaOptions.d.ts +1 -1
- package/package.json +14 -15
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isString, StoreMerge, useDecorators } from "@tsed/core";
|
|
2
|
-
import { deserialize, OnDeserialize, OnSerialize, serialize } from "@tsed/json-mapper";
|
|
3
1
|
import { Description, Example, OneOf, Property, string } from "@tsed/schema";
|
|
4
|
-
import {
|
|
2
|
+
import { OnDeserialize, OnSerialize, deserialize, serialize } from "@tsed/json-mapper";
|
|
3
|
+
import { StoreMerge, isString, useDecorators } from "@tsed/core";
|
|
5
4
|
import { MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
6
5
|
import { MongooseModels } from "../registries/MongooseModels.js";
|
|
6
|
+
import { Schema as MongooseSchema } from "mongoose";
|
|
7
7
|
function isRef(value) {
|
|
8
8
|
return (value && value._bsontype) || isString(value);
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { injectable } from "@tsed/di";
|
|
3
|
-
import { MONGOOSE_CONNECTIONS } from "../services/MongooseConnections.js";
|
|
1
|
+
import { applySchemaOptions, schemaOptions } from "../utils/schemaOptions.js";
|
|
4
2
|
import { createModel, getModelToken } from "../utils/createModel.js";
|
|
3
|
+
import { MONGOOSE_CONNECTIONS } from "../services/MongooseConnections.js";
|
|
5
4
|
import { getSchema } from "../utils/createSchema.js";
|
|
6
|
-
import {
|
|
5
|
+
import { injectable } from "@tsed/di";
|
|
6
|
+
import { useDecorators } from "@tsed/core";
|
|
7
7
|
/**
|
|
8
8
|
* Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with
|
|
9
9
|
* `@Inject` annotation.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { Formats } from "@tsed/ajv";
|
|
3
|
-
import { isNumber, isString, StoreMerge, useDecorators } from "@tsed/core";
|
|
4
|
-
import { OnDeserialize, OnSerialize } from "@tsed/json-mapper";
|
|
5
2
|
import { Example, Format, Property } from "@tsed/schema";
|
|
3
|
+
import { Formats } from "@tsed/ajv";
|
|
6
4
|
import { Schema as MongooseSchema, Types } from "mongoose";
|
|
5
|
+
import { OnDeserialize, OnSerialize } from "@tsed/json-mapper";
|
|
6
|
+
import { StoreMerge, isNumber, isString, useDecorators } from "@tsed/core";
|
|
7
7
|
import { MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
8
8
|
let DecimalFormat = class DecimalFormat {
|
|
9
9
|
validate(num) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useDecorators } from "@tsed/core";
|
|
2
1
|
import { Description, Example, Name, Pattern } from "@tsed/schema";
|
|
3
|
-
import { Types } from "mongoose";
|
|
4
2
|
import { Auto } from "./auto.js";
|
|
5
3
|
import { Schema } from "./schema.js";
|
|
4
|
+
import { Types } from "mongoose";
|
|
5
|
+
import { useDecorators } from "@tsed/core";
|
|
6
6
|
/**
|
|
7
7
|
* Tell Mongoose whether to define an ObjectId property.
|
|
8
8
|
* ### Example
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Schema as MongooseSchema } from "mongoose";
|
|
1
|
+
import { ForwardGroups, JsonEntityFn, OneOf, Property, lazyRef, matchGroups, string } from "@tsed/schema";
|
|
2
|
+
import { OnDeserialize, OnSerialize, deserialize, serialize } from "@tsed/json-mapper";
|
|
3
|
+
import { StoreMerge, isArrowFn, isCollection, isObject, isObjectID, isString, useDecorators } from "@tsed/core";
|
|
5
4
|
import { MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
6
|
-
import { MongooseSchemaTypes } from "../interfaces/MongooseSchemaTypes.js";
|
|
7
5
|
import { MongooseModels } from "../registries/MongooseModels.js";
|
|
6
|
+
import { Schema as MongooseSchema } from "mongoose";
|
|
7
|
+
import { MongooseSchemaTypes } from "../interfaces/MongooseSchemaTypes.js";
|
|
8
8
|
function isRef(value) {
|
|
9
9
|
return isObjectID(value) || isString(value);
|
|
10
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { injectable } from "@tsed/di";
|
|
3
|
-
import { Property } from "@tsed/schema";
|
|
4
|
-
import { MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
1
|
+
import { StoreMerge, decoratorTypeOf, useDecorators } from "@tsed/core";
|
|
5
2
|
import { getSchema, getSchemaToken } from "../utils/createSchema.js";
|
|
3
|
+
import { MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
4
|
+
import { Property } from "@tsed/schema";
|
|
5
|
+
import { injectable } from "@tsed/di";
|
|
6
6
|
export function Schema(options = {}) {
|
|
7
7
|
return (...parameters) => {
|
|
8
8
|
switch (decoratorTypeOf(parameters)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Store } from "@tsed/core";
|
|
2
1
|
import { MONGOOSE_SCHEMA_OPTIONS } from "../constants/constants.js";
|
|
2
|
+
import { Store } from "@tsed/core";
|
|
3
3
|
export function VersionKey() {
|
|
4
4
|
return (target, propertyKey) => {
|
|
5
5
|
Store.from(target).merge(MONGOOSE_SCHEMA_OPTIONS, { versionKey: propertyKey });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isPlainObject, isString, Store, StoreMerge, useDecorators } from "@tsed/core";
|
|
2
1
|
import { CollectionOf, Property } from "@tsed/schema";
|
|
3
2
|
import { MONGOOSE_MODEL_NAME, MONGOOSE_SCHEMA } from "../constants/constants.js";
|
|
3
|
+
import { Store, StoreMerge, isPlainObject, isString, useDecorators } from "@tsed/core";
|
|
4
4
|
import { MongooseModels } from "../registries/MongooseModels.js";
|
|
5
5
|
function getRef(opts) {
|
|
6
6
|
const ref = opts.ref;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import mongoose from "mongoose";
|
|
1
|
+
import { s } from "@tsed/schema";
|
|
4
2
|
import { MONGOOSE_MODEL, MONGOOSE_MODEL_NAME } from "../constants/constants.js";
|
|
3
|
+
import { Store, nameOf } from "@tsed/core";
|
|
4
|
+
import mongoose from "mongoose";
|
|
5
5
|
import { MongooseModels } from "../registries/MongooseModels.js";
|
|
6
6
|
import { getSchemaToken } from "./createSchema.js";
|
|
7
7
|
export function getModelToken(target, options) {
|
|
@@ -22,7 +22,7 @@ export function getModelToken(target, options) {
|
|
|
22
22
|
* @returns {Model<T extends Document>}
|
|
23
23
|
*/
|
|
24
24
|
export function createModel(target, schema, name = nameOf(target), collection, overwriteModels, connection) {
|
|
25
|
-
const entity =
|
|
25
|
+
const entity = s.store(target);
|
|
26
26
|
if (entity.isDiscriminatorChild) {
|
|
27
27
|
const discriminatorName = entity.discriminatorAncestor.schema.discriminator().getDefaultValue(target);
|
|
28
28
|
const ancestorModel = entity.discriminatorAncestor.get(MONGOOSE_MODEL);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getProperties, s } from "@tsed/schema";
|
|
2
|
+
import { MONGOOSE_SCHEMA, MONGOOSE_SCHEMA_OPTIONS } from "../constants/constants.js";
|
|
3
|
+
import { Store, classOf, cleanObject, isClassObject, nameOf } from "@tsed/core";
|
|
2
4
|
import { deserialize, serialize } from "@tsed/json-mapper";
|
|
3
|
-
import { getProperties, JsonEntityStore } from "@tsed/schema";
|
|
4
|
-
import { pascalCase } from "change-case";
|
|
5
5
|
import mongoose from "mongoose";
|
|
6
|
-
import {
|
|
6
|
+
import { pascalCase } from "change-case";
|
|
7
7
|
import { resolveRefType } from "./resolveRefType.js";
|
|
8
8
|
import { schemaOptions } from "./schemaOptions.js";
|
|
9
9
|
/**
|
|
@@ -30,7 +30,7 @@ function hasVersionField(schema, versionKey) {
|
|
|
30
30
|
return versionKey in schema.paths;
|
|
31
31
|
}
|
|
32
32
|
export function createSchema(target, options = {}) {
|
|
33
|
-
const entity =
|
|
33
|
+
const entity = s.store(target);
|
|
34
34
|
const schemaOptionsFromStore = entity.store.get(MONGOOSE_SCHEMA_OPTIONS) || {};
|
|
35
35
|
options.schemaOptions = { ...options.schemaOptions, ...schemaOptionsFromStore };
|
|
36
36
|
if (entity.schema.isDiscriminator) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SchemaTypeOptions } from "mongoose";
|
|
2
1
|
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
|
+
import { SchemaTypeOptions } from "mongoose";
|
|
3
3
|
/**
|
|
4
4
|
* Define a class as a Mongoose Schema ready to be used to compose other schemes and models.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ConnectOptions } from "mongoose";
|
|
1
2
|
import { Logger } from "@tsed/logger";
|
|
2
3
|
import Mongoose from "mongoose";
|
|
3
|
-
import { ConnectOptions } from "mongoose";
|
|
4
4
|
export declare class MongooseService {
|
|
5
5
|
readonly connections: Map<string, Mongoose.Connection>;
|
|
6
6
|
private defaultConnection;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
1
|
import { JsonEntityStore } from "@tsed/schema";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
3
|
import mongoose, { Schema, SchemaDefinition, SchemaDefinitionProperty } from "mongoose";
|
|
4
4
|
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
5
5
|
import { MongooseVirtualRefOptions } from "../interfaces/MongooseVirtualRefOptions.js";
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
|
+
"version": "8.35.0",
|
|
3
4
|
"description": "Mongoose package for Ts.ED framework",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"version": "8.33.0",
|
|
6
5
|
"keywords": [
|
|
7
|
-
"tsed",
|
|
8
|
-
"mongoose",
|
|
9
|
-
"typescript",
|
|
10
6
|
"decorators",
|
|
11
|
-
"
|
|
7
|
+
"mongoose",
|
|
8
|
+
"orm",
|
|
9
|
+
"tsed",
|
|
10
|
+
"typescript"
|
|
12
11
|
],
|
|
13
12
|
"source": "./src/index.ts",
|
|
13
|
+
"type": "module",
|
|
14
14
|
"main": "./lib/esm/index.js",
|
|
15
15
|
"module": "./lib/esm/index.js",
|
|
16
16
|
"typings": "./lib/types/index.d.ts",
|
|
@@ -34,16 +34,15 @@
|
|
|
34
34
|
"tslib": ">=2.7.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tsed/ajv": "8.
|
|
38
|
-
"@tsed/barrels": "8.
|
|
39
|
-
"@tsed/core": "8.
|
|
40
|
-
"@tsed/di": "8.
|
|
41
|
-
"@tsed/json-mapper": "8.
|
|
37
|
+
"@tsed/ajv": "8.35.0",
|
|
38
|
+
"@tsed/barrels": "8.35.0",
|
|
39
|
+
"@tsed/core": "8.35.0",
|
|
40
|
+
"@tsed/di": "8.35.0",
|
|
41
|
+
"@tsed/json-mapper": "8.35.0",
|
|
42
42
|
"@tsed/logger": "^8.0.0",
|
|
43
|
-
"@tsed/schema": "8.
|
|
44
|
-
"@tsed/testcontainers-mongo": "8.
|
|
45
|
-
"@tsed/typescript": "8.
|
|
46
|
-
"eslint": "9.12.0",
|
|
43
|
+
"@tsed/schema": "8.35.0",
|
|
44
|
+
"@tsed/testcontainers-mongo": "8.35.0",
|
|
45
|
+
"@tsed/typescript": "8.35.0",
|
|
47
46
|
"mongoose": "8.9.5",
|
|
48
47
|
"typescript": "6.0.2",
|
|
49
48
|
"vitest": "4.1.4"
|