@wandu/nestjs-schemas
Advanced tools
Comparing version 10.2.0 to 10.3.0
@@ -140,5 +140,7 @@ /// <reference types="mongoose/types/aggregate" /> | ||
toObject: boolean; | ||
projection: any; | ||
projection: { | ||
[field: string]: any; | ||
}; | ||
}; | ||
get model(): TModel; | ||
} |
@@ -6,5 +6,11 @@ export declare class MetadataService { | ||
check(customSchemas?: string[]): void; | ||
getProjection(schema: Function | string): any; | ||
getFullProjection(schema: Function | string): any; | ||
_getProjection(schema: Function | string, onlyTopLevel?: boolean, parents?: string[], value?: 1 | 'type'): any; | ||
getProjection(schema: Function | string): { | ||
[field: string]: any; | ||
}; | ||
getFullProjection(schema: Function | string): { | ||
[field: string]: any; | ||
}; | ||
_getProjection(schema: Function | string, onlyTopLevel?: boolean, parents?: string[], value?: 1 | 'type'): { | ||
[field: string]: any; | ||
}; | ||
getSchemas(): Map<string, import("./types").SchemaDef>; | ||
@@ -11,0 +17,0 @@ getSchema(schema: string | Function | Object): import("./types").SchemaDef | undefined; |
@@ -66,26 +66,21 @@ "use strict"; | ||
var _a, _b; | ||
let schemaKey = typeof schema === 'string' ? schema : schema.name; | ||
schemaKey += onlyTopLevel ? '_top_' + value : '_full_' + value; | ||
if (!this._cacheProjections.has(schemaKey)) { | ||
let projection = {}; | ||
const schemaMetadata = this.getSchema(schema); | ||
if (schemaMetadata !== undefined) { | ||
for (const [property, propDef] of schemaMetadata.props.entries()) { | ||
if (((_a = propDef.options.transformer) === null || _a === void 0 ? void 0 : _a.expose) || !((_b = propDef.options.transformer) === null || _b === void 0 ? void 0 : _b.exclude)) { | ||
const subschemaProjection = this._getProjection(propDef.type.type, onlyTopLevel, [...parents, property], value); | ||
if (onlyTopLevel || | ||
!subschemaProjection || | ||
(typeof subschemaProjection === 'object' && !Object.keys(subschemaProjection).length)) { | ||
const key = [...parents, property].join('.'); | ||
projection[key] = value === 1 ? 1 : propDef.type.type; | ||
} | ||
else { | ||
projection = Object.assign(Object.assign({}, projection), subschemaProjection); | ||
} | ||
let projection = {}; | ||
const schemaMetadata = this.getSchema(schema); | ||
if (schemaMetadata !== undefined) { | ||
for (const [property, propDef] of schemaMetadata.props.entries()) { | ||
if (((_a = propDef.options.transformer) === null || _a === void 0 ? void 0 : _a.expose) || !((_b = propDef.options.transformer) === null || _b === void 0 ? void 0 : _b.exclude)) { | ||
const subschemaProjection = this._getProjection(propDef.type.type, onlyTopLevel, [...parents, property], value); | ||
if (onlyTopLevel || | ||
!subschemaProjection || | ||
(typeof subschemaProjection === 'object' && !Object.keys(subschemaProjection).length)) { | ||
const key = [...parents, property].join('.'); | ||
projection[key] = value === 1 ? 1 : propDef.type.type; | ||
} | ||
else { | ||
projection = Object.assign(Object.assign({}, projection), subschemaProjection); | ||
} | ||
} | ||
this._cacheProjections.set(schemaKey, projection); | ||
} | ||
} | ||
return this._cacheProjections.get(schemaKey); | ||
return projection; | ||
} | ||
@@ -92,0 +87,0 @@ getSchemas() { |
{ | ||
"name": "@wandu/nestjs-schemas", | ||
"version": "10.2.0", | ||
"version": "10.3.0", | ||
"description": "Schemas library for NestJS", | ||
@@ -5,0 +5,0 @@ "main": "dist/libs/nestjs-schemas/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4921
242219