@goatlab/fluent 0.7.38 → 0.7.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseConnector.d.ts +112 -0
- package/dist/BaseConnector.js +343 -0
- package/dist/BaseConnector.js.map +1 -0
- package/dist/Fluent.d.ts +11 -0
- package/dist/Fluent.js +27 -0
- package/dist/Fluent.js.map +1 -0
- package/dist/FluentConnectorInterface.d.ts +17 -0
- package/dist/FluentConnectorInterface.js +3 -0
- package/dist/FluentConnectorInterface.js.map +1 -0
- package/dist/FluentEntity.d.ts +7 -0
- package/dist/FluentEntity.js +29 -0
- package/dist/FluentEntity.js.map +1 -0
- package/dist/TypeOrmConnector/TypeOrmConnector.d.ts +123 -0
- package/dist/TypeOrmConnector/TypeOrmConnector.js +760 -0
- package/dist/TypeOrmConnector/TypeOrmConnector.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoBaseAggregations.d.ts +12 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoBaseAggregations.js +167 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoBaseAggregations.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoFindAggregatedQuery.d.ts +11 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoFindAggregatedQuery.js +52 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoFindAggregatedQuery.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoOrderBy.d.ts +4 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoOrderBy.js +20 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoOrderBy.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoSelect.d.ts +7 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoSelect.js +19 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoSelect.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoWhere.d.ts +11 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoWhere.js +173 -0
- package/dist/TypeOrmConnector/queryBuilder/mongodb/getMongoWhere.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getQueryBuilderWhere.d.ts +13 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getQueryBuilderWhere.js +207 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getQueryBuilderWhere.js.map +1 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getTypeOrmWhere.d.ts +11 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getTypeOrmWhere.js +214 -0
- package/dist/TypeOrmConnector/queryBuilder/sql/getTypeOrmWhere.js.map +1 -0
- package/dist/TypeOrmConnector/util/clearEmpties.d.ts +7 -0
- package/dist/TypeOrmConnector/util/clearEmpties.js +33 -0
- package/dist/TypeOrmConnector/util/clearEmpties.js.map +1 -0
- package/dist/TypeOrmConnector/util/extractConditions.d.ts +12 -0
- package/dist/TypeOrmConnector/util/extractConditions.js +89 -0
- package/dist/TypeOrmConnector/util/extractConditions.js.map +1 -0
- package/dist/TypeOrmConnector/util/extractInclude.d.ts +2 -0
- package/dist/TypeOrmConnector/util/extractInclude.js +26 -0
- package/dist/TypeOrmConnector/util/extractInclude.js.map +1 -0
- package/dist/TypeOrmConnector/util/extractMetadataFromKeys.d.ts +12 -0
- package/dist/TypeOrmConnector/util/extractMetadataFromKeys.js +49 -0
- package/dist/TypeOrmConnector/util/extractMetadataFromKeys.js.map +1 -0
- package/dist/TypeOrmConnector/util/extractOrderBy.d.ts +2 -0
- package/dist/TypeOrmConnector/util/extractOrderBy.js +24 -0
- package/dist/TypeOrmConnector/util/extractOrderBy.js.map +1 -0
- package/dist/TypeOrmConnector/util/getRelationsFromModelGenerator.d.ts +19 -0
- package/dist/TypeOrmConnector/util/getRelationsFromModelGenerator.js +27 -0
- package/dist/TypeOrmConnector/util/getRelationsFromModelGenerator.js.map +1 -0
- package/dist/TypeOrmConnector/util/getSelectedKeysFromRawSql.d.ts +6 -0
- package/dist/TypeOrmConnector/util/getSelectedKeysFromRawSql.js +29 -0
- package/dist/TypeOrmConnector/util/getSelectedKeysFromRawSql.js.map +1 -0
- package/dist/TypeOrmConnector/util/isAnyObject.d.ts +1 -0
- package/dist/TypeOrmConnector/util/isAnyObject.js +8 -0
- package/dist/TypeOrmConnector/util/isAnyObject.js.map +1 -0
- package/dist/TypeOrmConnector/util/nestQueryResults.d.ts +2 -0
- package/dist/TypeOrmConnector/util/nestQueryResults.js +38 -0
- package/dist/TypeOrmConnector/util/nestQueryResults.js.map +1 -0
- package/dist/core/Loopback/build-schema.d.ts +148 -0
- package/dist/core/Loopback/build-schema.js +443 -0
- package/dist/core/Loopback/build-schema.js.map +1 -0
- package/dist/core/Loopback/common-types.d.ts +96 -0
- package/dist/core/Loopback/common-types.js +24 -0
- package/dist/core/Loopback/common-types.js.map +1 -0
- package/dist/core/Loopback/json-to-schema.d.ts +41 -0
- package/dist/core/Loopback/json-to-schema.js +113 -0
- package/dist/core/Loopback/json-to-schema.js.map +1 -0
- package/dist/core/Loopback/metadata.d.ts +16 -0
- package/dist/core/Loopback/metadata.js +49 -0
- package/dist/core/Loopback/metadata.js.map +1 -0
- package/dist/core/Loopback/model.d.ts +233 -0
- package/dist/core/Loopback/model.js +387 -0
- package/dist/core/Loopback/model.js.map +1 -0
- package/dist/core/Loopback/query.d.ts +394 -0
- package/dist/core/Loopback/query.js +482 -0
- package/dist/core/Loopback/query.js.map +1 -0
- package/dist/core/Loopback/relation.types.d.ts +141 -0
- package/dist/core/Loopback/relation.types.js +18 -0
- package/dist/core/Loopback/relation.types.js.map +1 -0
- package/dist/core/Loopback/type-resolver.d.ts +42 -0
- package/dist/core/Loopback/type-resolver.js +60 -0
- package/dist/core/Loopback/type-resolver.js.map +1 -0
- package/dist/core/Loopback/type.d.ts +38 -0
- package/dist/core/Loopback/type.js +7 -0
- package/dist/core/Loopback/type.js.map +1 -0
- package/dist/core/Nestjs/applyDecorators.d.ts +10 -0
- package/dist/core/Nestjs/applyDecorators.js +26 -0
- package/dist/core/Nestjs/applyDecorators.js.map +1 -0
- package/dist/core/Nestjs/types/common.d.ts +16 -0
- package/dist/core/Nestjs/types/common.js +38 -0
- package/dist/core/Nestjs/types/common.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/api-hide-property.decorator.d.ts +1 -0
- package/dist/core/Nestjs/types/decorators/api-hide-property.decorator.js +8 -0
- package/dist/core/Nestjs/types/decorators/api-hide-property.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/api-property.decorator.d.ts +27 -0
- package/dist/core/Nestjs/types/decorators/api-property.decorator.js +66 -0
- package/dist/core/Nestjs/types/decorators/api-property.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/apply-is-optional.decorator.d.ts +5 -0
- package/dist/core/Nestjs/types/decorators/apply-is-optional.decorator.js +136 -0
- package/dist/core/Nestjs/types/decorators/apply-is-optional.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/args-type.decorator.d.ts +4 -0
- package/dist/core/Nestjs/types/decorators/args-type.decorator.js +24 -0
- package/dist/core/Nestjs/types/decorators/args-type.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/create-property.decorator.d.ts +2 -0
- package/dist/core/Nestjs/types/decorators/create-property.decorator.js +55 -0
- package/dist/core/Nestjs/types/decorators/create-property.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/directive.decorator.d.ts +4 -0
- package/dist/core/Nestjs/types/decorators/directive.decorator.js +39 -0
- package/dist/core/Nestjs/types/decorators/directive.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/extensions.decorator.d.ts +4 -0
- package/dist/core/Nestjs/types/decorators/extensions.decorator.js +28 -0
- package/dist/core/Nestjs/types/decorators/extensions.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/field.decorator.d.ts +48 -0
- package/dist/core/Nestjs/types/decorators/field.decorator.js +63 -0
- package/dist/core/Nestjs/types/decorators/field.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/input-type.decorator.d.ts +25 -0
- package/dist/core/Nestjs/types/decorators/input-type.decorator.js +29 -0
- package/dist/core/Nestjs/types/decorators/input-type.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/interface-type.decorator.d.ts +33 -0
- package/dist/core/Nestjs/types/decorators/interface-type.decorator.js +35 -0
- package/dist/core/Nestjs/types/decorators/interface-type.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/decorators/partial-type.helper.d.ts +3 -0
- package/dist/core/Nestjs/types/decorators/partial-type.helper.js +46 -0
- package/dist/core/Nestjs/types/decorators/partial-type.helper.js.map +1 -0
- package/dist/core/Nestjs/types/errors/cannot-determine-host-type.error.d.ts +3 -0
- package/dist/core/Nestjs/types/errors/cannot-determine-host-type.error.js +10 -0
- package/dist/core/Nestjs/types/errors/cannot-determine-host-type.error.js.map +1 -0
- package/dist/core/Nestjs/types/errors/directive-parsing.error.d.ts +3 -0
- package/dist/core/Nestjs/types/errors/directive-parsing.error.js +10 -0
- package/dist/core/Nestjs/types/errors/directive-parsing.error.js.map +1 -0
- package/dist/core/Nestjs/types/errors/unable-to-find-fields.error.d.ts +3 -0
- package/dist/core/Nestjs/types/errors/unable-to-find-fields.error.js +10 -0
- package/dist/core/Nestjs/types/errors/unable-to-find-fields.error.js.map +1 -0
- package/dist/core/Nestjs/types/errors/undefined-type.error.d.ts +3 -0
- package/dist/core/Nestjs/types/errors/undefined-type.error.js +11 -0
- package/dist/core/Nestjs/types/errors/undefined-type.error.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/add-class-type-metadata.util.d.ts +3 -0
- package/dist/core/Nestjs/types/interfaces/add-class-type-metadata.util.js +11 -0
- package/dist/core/Nestjs/types/interfaces/add-class-type-metadata.util.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/base-type-options.interface.d.ts +11 -0
- package/dist/core/Nestjs/types/interfaces/base-type-options.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/base-type-options.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/class-decorator-factory.interface.d.ts +5 -0
- package/dist/core/Nestjs/types/interfaces/class-decorator-factory.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/class-decorator-factory.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/complexity.interface.d.ts +11 -0
- package/dist/core/Nestjs/types/interfaces/complexity.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/complexity.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/field-middleware.interface.d.ts +15 -0
- package/dist/core/Nestjs/types/interfaces/field-middleware.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/field-middleware.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/open-api-spec.interface.d.ts +239 -0
- package/dist/core/Nestjs/types/interfaces/open-api-spec.interface.js +7 -0
- package/dist/core/Nestjs/types/interfaces/open-api-spec.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/resolve-type-fn.interface.d.ts +2 -0
- package/dist/core/Nestjs/types/interfaces/resolve-type-fn.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/resolve-type-fn.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/return-type-func.interface.d.ts +5 -0
- package/dist/core/Nestjs/types/interfaces/return-type-func.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/return-type-func.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/schema-object-metadata.interface.d.ts +9 -0
- package/dist/core/Nestjs/types/interfaces/schema-object-metadata.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/schema-object-metadata.interface.js.map +1 -0
- package/dist/core/Nestjs/types/interfaces/type-options.interface.d.ts +5 -0
- package/dist/core/Nestjs/types/interfaces/type-options.interface.js +3 -0
- package/dist/core/Nestjs/types/interfaces/type-options.interface.js.map +1 -0
- package/dist/core/Nestjs/types/lazy-metadata.storage.d.ts +15 -0
- package/dist/core/Nestjs/types/lazy-metadata.storage.js +68 -0
- package/dist/core/Nestjs/types/lazy-metadata.storage.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/class.metadata.d.ts +11 -0
- package/dist/core/Nestjs/types/metadata/class.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/class.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/directive.metadata.d.ts +8 -0
- package/dist/core/Nestjs/types/metadata/directive.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/directive.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/enum.metadata.d.ts +11 -0
- package/dist/core/Nestjs/types/metadata/enum.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/enum.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/extensions.metadata.d.ts +8 -0
- package/dist/core/Nestjs/types/metadata/extensions.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/extensions.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/index.d.ts +8 -0
- package/dist/core/Nestjs/types/metadata/index.js +12 -0
- package/dist/core/Nestjs/types/metadata/index.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/interface.metadata.d.ts +6 -0
- package/dist/core/Nestjs/types/metadata/interface.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/interface.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/object-type.metadata.d.ts +4 -0
- package/dist/core/Nestjs/types/metadata/object-type.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/object-type.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/param.metadata.d.ts +18 -0
- package/dist/core/Nestjs/types/metadata/param.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/param.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/property.metadata.d.ts +20 -0
- package/dist/core/Nestjs/types/metadata/property.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/property.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/resolver.metadata.d.ts +34 -0
- package/dist/core/Nestjs/types/metadata/resolver.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/resolver.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/metadata/union.metadata.d.ts +9 -0
- package/dist/core/Nestjs/types/metadata/union.metadata.js +3 -0
- package/dist/core/Nestjs/types/metadata/union.metadata.js.map +1 -0
- package/dist/core/Nestjs/types/object-type.decorator.d.ts +32 -0
- package/dist/core/Nestjs/types/object-type.decorator.js +33 -0
- package/dist/core/Nestjs/types/object-type.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/omit-type.d.ts +2 -0
- package/dist/core/Nestjs/types/omit-type.js +34 -0
- package/dist/core/Nestjs/types/omit-type.js.map +1 -0
- package/dist/core/Nestjs/types/reflection.utils.d.ts +15 -0
- package/dist/core/Nestjs/types/reflection.utils.js +65 -0
- package/dist/core/Nestjs/types/reflection.utils.js.map +1 -0
- package/dist/core/Nestjs/types/set-metadata.decorator.d.ts +20 -0
- package/dist/core/Nestjs/types/set-metadata.decorator.js +33 -0
- package/dist/core/Nestjs/types/set-metadata.decorator.js.map +1 -0
- package/dist/core/Nestjs/types/type-metadata.storage.d.ts +73 -0
- package/dist/core/Nestjs/types/type-metadata.storage.js +351 -0
- package/dist/core/Nestjs/types/type-metadata.storage.js.map +1 -0
- package/dist/core/Nestjs/types/utils/enum.utils.d.ts +3 -0
- package/dist/core/Nestjs/types/utils/enum.utils.js +31 -0
- package/dist/core/Nestjs/types/utils/enum.utils.js.map +1 -0
- package/dist/core/Nestjs/types/utils/get-fields-and-decorator.util.d.ts +13 -0
- package/dist/core/Nestjs/types/utils/get-fields-and-decorator.util.js +72 -0
- package/dist/core/Nestjs/types/utils/get-fields-and-decorator.util.js.map +1 -0
- package/dist/core/Nestjs/types/utils/mapped-types.utils.d.ts +2 -0
- package/dist/core/Nestjs/types/utils/mapped-types.utils.js +38 -0
- package/dist/core/Nestjs/types/utils/mapped-types.utils.js.map +1 -0
- package/dist/core/Nestjs/types/utils/model-properties-accessor.d.ts +6 -0
- package/dist/core/Nestjs/types/utils/model-properties-accessor.js +37 -0
- package/dist/core/Nestjs/types/utils/model-properties-accessor.js.map +1 -0
- package/dist/core/Nestjs/types/utils/type-helpers.utils.d.ts +2 -0
- package/dist/core/Nestjs/types/utils/type-helpers.utils.js +16 -0
- package/dist/core/Nestjs/types/utils/type-helpers.utils.js.map +1 -0
- package/dist/core/types.d.ts +23 -0
- package/dist/core/types.js +31 -0
- package/dist/core/types.js.map +1 -0
- package/dist/decorators.d.ts +92 -0
- package/dist/decorators.js +162 -0
- package/dist/decorators.js.map +1 -0
- package/dist/generatorDatasource.d.ts +2 -0
- package/dist/generatorDatasource.js +13 -0
- package/dist/generatorDatasource.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/loadRelations.d.ts +12 -0
- package/dist/loadRelations.js +139 -0
- package/dist/loadRelations.js.map +1 -0
- package/dist/outputKeys.d.ts +2 -0
- package/dist/outputKeys.js +18 -0
- package/dist/outputKeys.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -24
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Class } from './common-types';
|
|
2
|
+
/**
|
|
3
|
+
* A type resolver is a function that returns a class representing the type,
|
|
4
|
+
* typically a Model or Entity (e.g. Product).
|
|
5
|
+
*
|
|
6
|
+
* We use type resolvers to break require() loops when defining relations.
|
|
7
|
+
* The target model (class) is provided via a provider, thus deferring
|
|
8
|
+
* the actual reference to the class itself until later, when both sides
|
|
9
|
+
* of the relation are created as JavaScript classes.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam Type - The type we are resolving, for example `Entity` or `Product`.
|
|
12
|
+
* This parameter is required.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam StaticMembers - The static properties available on the
|
|
15
|
+
* type class. For example, all models have static `modelName` property.
|
|
16
|
+
* When `StaticMembers` are not provided, we default to static properties of
|
|
17
|
+
* a `Function` - `name`, `length`, `apply`, `call`, etc.
|
|
18
|
+
* Please note the value returned by the resolver is described as having
|
|
19
|
+
* arbitrary additional static properties (see how Class is defined).
|
|
20
|
+
*/
|
|
21
|
+
export type TypeResolver<Type extends Object, StaticMembers = Function> = () => Class<Type> & StaticMembers;
|
|
22
|
+
/**
|
|
23
|
+
* A function that checks whether a function is a TypeResolver or not.
|
|
24
|
+
* @param fn - The value to check.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isTypeResolver<T extends object>(fn: any): fn is TypeResolver<T>;
|
|
27
|
+
/**
|
|
28
|
+
* A boxed type for `null`
|
|
29
|
+
*/
|
|
30
|
+
export declare function Null(): null;
|
|
31
|
+
/**
|
|
32
|
+
* Check if the provided function is a built-in type provided by JavaScript
|
|
33
|
+
* and/or Node.js. E.g. `Number`, `Array`, `Buffer`, etc.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isBuiltinType(fn: Function): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a type value that may have been provided via TypeResolver.
|
|
38
|
+
* @param fn - A type class or a type provider.
|
|
39
|
+
* @returns The resolved type.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveType<T extends object>(fn: TypeResolver<T> | Class<T>): Class<T>;
|
|
42
|
+
export declare function resolveType<T>(fn: T): T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isTypeResolver = isTypeResolver;
|
|
8
|
+
exports.Null = Null;
|
|
9
|
+
exports.isBuiltinType = isBuiltinType;
|
|
10
|
+
exports.resolveType = resolveType;
|
|
11
|
+
/**
|
|
12
|
+
* A function that checks whether a function is a TypeResolver or not.
|
|
13
|
+
* @param fn - The value to check.
|
|
14
|
+
*/
|
|
15
|
+
function isTypeResolver(
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
fn) {
|
|
18
|
+
// 1. A type provider must be a function
|
|
19
|
+
if (typeof fn !== 'function')
|
|
20
|
+
return false;
|
|
21
|
+
// 2. A class constructor is not a type provider
|
|
22
|
+
if (/^class/.test(fn.toString()))
|
|
23
|
+
return false;
|
|
24
|
+
// 3. Built-in types like Date & Array are not type providers
|
|
25
|
+
if (isBuiltinType(fn))
|
|
26
|
+
return false;
|
|
27
|
+
// TODO(bajtos): support model classes defined via ES5 constructor function
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A boxed type for `null`
|
|
32
|
+
*/
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
34
|
+
function Null() {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if the provided function is a built-in type provided by JavaScript
|
|
39
|
+
* and/or Node.js. E.g. `Number`, `Array`, `Buffer`, etc.
|
|
40
|
+
*/
|
|
41
|
+
function isBuiltinType(fn) {
|
|
42
|
+
return (
|
|
43
|
+
// scalars
|
|
44
|
+
fn === Number ||
|
|
45
|
+
fn === Boolean ||
|
|
46
|
+
fn === String ||
|
|
47
|
+
// objects
|
|
48
|
+
fn === Object ||
|
|
49
|
+
fn === Array ||
|
|
50
|
+
fn === Date ||
|
|
51
|
+
fn === RegExp ||
|
|
52
|
+
fn === Buffer ||
|
|
53
|
+
fn === Null ||
|
|
54
|
+
// function as a type
|
|
55
|
+
fn === Function);
|
|
56
|
+
}
|
|
57
|
+
function resolveType(fn) {
|
|
58
|
+
return isTypeResolver(fn) ? fn() : fn;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=type-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-resolver.js","sourceRoot":"","sources":["../../../src/core/Loopback/type-resolver.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAgChE,wCAgBC;AAMD,oBAEC;AAMD,sCAgBC;AAcD,kCAEC;AAlED;;;GAGG;AACH,SAAgB,cAAc;AAC5B,8DAA8D;AAC9D,EAAO;IAEP,wCAAwC;IACxC,IAAI,OAAO,EAAE,KAAK,UAAU;QAAE,OAAO,KAAK,CAAA;IAE1C,gDAAgD;IAChD,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QAAE,OAAO,KAAK,CAAA;IAE9C,6DAA6D;IAC7D,IAAI,aAAa,CAAC,EAAE,CAAC;QAAE,OAAO,KAAK,CAAA;IAEnC,2EAA2E;IAE3E,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,gEAAgE;AAChE,SAAgB,IAAI;IAClB,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAAY;IACxC,OAAO;IACL,UAAU;IACV,EAAE,KAAK,MAAM;QACb,EAAE,KAAK,OAAO;QACd,EAAE,KAAK,MAAM;QACb,UAAU;QACV,EAAE,KAAK,MAAM;QACb,EAAE,KAAK,KAAK;QACZ,EAAE,KAAK,IAAI;QACX,EAAE,KAAK,MAAM;QACb,EAAE,KAAK,MAAM;QACb,EAAE,KAAK,IAAI;QACX,qBAAqB;QACrB,EAAE,KAAK,QAAQ,CAChB,CAAA;AACH,CAAC;AAcD,SAAgB,WAAW,CAAmB,EAA8B;IAC1E,OAAO,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typing system for LoopBack
|
|
3
|
+
*/
|
|
4
|
+
import { Options } from './common-types';
|
|
5
|
+
export interface Type<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the type
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Test if the given value is an instance of this type
|
|
12
|
+
* @param value - The value
|
|
13
|
+
*/
|
|
14
|
+
isInstance(value: any): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Generate the default value for this type
|
|
17
|
+
*/
|
|
18
|
+
defaultValue(): T | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the given value can be coerced into this type
|
|
21
|
+
* @param value - The value to to be coerced
|
|
22
|
+
* @returns A flag to indicate if the value can be coerced
|
|
23
|
+
*/
|
|
24
|
+
isCoercible(value: any, options?: Options): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Coerce the value into this type
|
|
27
|
+
* @param value - The value to be coerced
|
|
28
|
+
* @param options - Options for coercion
|
|
29
|
+
* @returns Coerced value of this type
|
|
30
|
+
*/
|
|
31
|
+
coerce(value: any, options?: Options): T | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Serialize a value into json
|
|
34
|
+
* @param value - The value of this type
|
|
35
|
+
* @param options - Options for serialization
|
|
36
|
+
*/
|
|
37
|
+
serialize(value: T | null | undefined, options?: Options): any;
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2017,2019. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/core/Loopback/type.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function that returns a new decorator that applies all decorators provided by param
|
|
3
|
+
*
|
|
4
|
+
* Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
|
|
5
|
+
*
|
|
6
|
+
* @param decorators one or more decorators (e.g., `ApplyGuard(...)`)
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyDecorators = applyDecorators;
|
|
4
|
+
/**
|
|
5
|
+
* Function that returns a new decorator that applies all decorators provided by param
|
|
6
|
+
*
|
|
7
|
+
* Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
|
|
8
|
+
*
|
|
9
|
+
* @param decorators one or more decorators (e.g., `ApplyGuard(...)`)
|
|
10
|
+
*
|
|
11
|
+
* @publicApi
|
|
12
|
+
*/
|
|
13
|
+
function applyDecorators(...decorators) {
|
|
14
|
+
return (target, propertyKey, descriptor) => {
|
|
15
|
+
for (const decorator of decorators) {
|
|
16
|
+
if (target instanceof Function && !descriptor) {
|
|
17
|
+
;
|
|
18
|
+
decorator(target);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
decorator(target, propertyKey, descriptor);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=applyDecorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyDecorators.js","sourceRoot":"","sources":["../../../src/core/Nestjs/applyDecorators.ts"],"names":[],"mappings":";;AASA,0CAoBC;AA7BD;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,GAAG,UAAuE;IAE1E,OAAO,CACL,MAA0B,EAC1B,WAA6B,EAC7B,UAAuC,EACvC,EAAE;QACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,MAAM,YAAY,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC9C,CAAC;gBAAC,SAA4B,CAAC,MAAM,CAAC,CAAA;gBACtC,SAAQ;YACV,CAAC;YACD,CAAC;YAAC,SAAiD,CACjD,MAAM,EACN,WAAY,EACZ,UAAW,CACZ,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const isString: (fn: any) => fn is string;
|
|
2
|
+
export declare enum ClassType {
|
|
3
|
+
ARGS = "args",
|
|
4
|
+
OBJECT = "objectType",
|
|
5
|
+
INPUT = "inputType",
|
|
6
|
+
INTERFACE = "interface"
|
|
7
|
+
}
|
|
8
|
+
export interface Type<T = any> extends Function {
|
|
9
|
+
new (...args: any[]): T;
|
|
10
|
+
}
|
|
11
|
+
export declare function flatten<T extends Array<unknown> = any>(arr: T): T extends Array<infer R> ? R : never;
|
|
12
|
+
export declare const isUndefined: (obj: any) => obj is undefined;
|
|
13
|
+
export declare const isFunction: (fn: any) => boolean;
|
|
14
|
+
export type TargetHost = Record<'target', Function>;
|
|
15
|
+
export declare function isTargetEqual<T extends TargetHost, U extends TargetHost>(a: T, b: U): boolean;
|
|
16
|
+
export declare function isThrowing(func: () => unknown): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFunction = exports.isUndefined = exports.ClassType = exports.isString = void 0;
|
|
4
|
+
exports.flatten = flatten;
|
|
5
|
+
exports.isTargetEqual = isTargetEqual;
|
|
6
|
+
exports.isThrowing = isThrowing;
|
|
7
|
+
const isString = (fn) => typeof fn === 'string';
|
|
8
|
+
exports.isString = isString;
|
|
9
|
+
var ClassType;
|
|
10
|
+
(function (ClassType) {
|
|
11
|
+
ClassType["ARGS"] = "args";
|
|
12
|
+
ClassType["OBJECT"] = "objectType";
|
|
13
|
+
ClassType["INPUT"] = "inputType";
|
|
14
|
+
ClassType["INTERFACE"] = "interface";
|
|
15
|
+
})(ClassType || (exports.ClassType = ClassType = {}));
|
|
16
|
+
function flatten(arr) {
|
|
17
|
+
const flat = [].concat(...arr);
|
|
18
|
+
return (flat.some(Array.isArray)
|
|
19
|
+
? flatten(flat)
|
|
20
|
+
: flat);
|
|
21
|
+
}
|
|
22
|
+
const isUndefined = (obj) => typeof obj === 'undefined';
|
|
23
|
+
exports.isUndefined = isUndefined;
|
|
24
|
+
const isFunction = (fn) => typeof fn === 'function';
|
|
25
|
+
exports.isFunction = isFunction;
|
|
26
|
+
function isTargetEqual(a, b) {
|
|
27
|
+
return a.target === b.target;
|
|
28
|
+
}
|
|
29
|
+
function isThrowing(func) {
|
|
30
|
+
try {
|
|
31
|
+
func();
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/core/Nestjs/types/common.ts"],"names":[],"mappings":";;;AAaA,0BAOC;AAQD,sCAKC;AAED,gCAOC;AA1CM,MAAM,QAAQ,GAAG,CAAC,EAAO,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAA;AAA5D,QAAA,QAAQ,YAAoD;AAEzE,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,kCAAqB,CAAA;IACrB,gCAAmB,CAAA;IACnB,oCAAuB,CAAA;AACzB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB;AAMD,SAAgB,OAAO,CACrB,GAAM;IAEN,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,GAAI,GAAW,CAAC,CAAA;IACvC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC9B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QACf,CAAC,CAAC,IAAI,CAAoD,CAAA;AAC9D,CAAC;AAEM,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAoB,EAAE,CACxD,OAAO,GAAG,KAAK,WAAW,CAAA;AADf,QAAA,WAAW,eACI;AAErB,MAAM,UAAU,GAAG,CAAC,EAAO,EAAW,EAAE,CAAC,OAAO,EAAE,KAAK,UAAU,CAAA;AAA3D,QAAA,UAAU,cAAiD;AAGxE,SAAgB,aAAa,CAC3B,CAAI,EACJ,CAAI;IAEJ,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAA;AAC9B,CAAC;AAED,SAAgB,UAAU,CAAC,IAAmB;IAC5C,IAAI,CAAC;QACH,IAAI,EAAE,CAAA;QACN,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiHideProperty(): PropertyDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiHideProperty = ApiHideProperty;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
5
|
+
function ApiHideProperty() {
|
|
6
|
+
return (target, propertyKey) => { };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=api-hide-property.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-hide-property.decorator.js","sourceRoot":"","sources":["../../../../../src/core/Nestjs/types/decorators/api-hide-property.decorator.ts"],"names":[],"mappings":";;AACA,0CAEC;AAHD,yDAAyD;AACzD,SAAgB,eAAe;IAC7B,OAAO,CAAC,MAA2B,EAAE,WAA4B,EAAE,EAAE,GAAE,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SchemaObjectMetadata } from '../interfaces/schema-object-metadata.interface';
|
|
2
|
+
export declare const DECORATORS_PREFIX = "swagger";
|
|
3
|
+
export declare const DECORATORS: {
|
|
4
|
+
API_OPERATION: string;
|
|
5
|
+
API_RESPONSE: string;
|
|
6
|
+
API_PRODUCES: string;
|
|
7
|
+
API_CONSUMES: string;
|
|
8
|
+
API_TAGS: string;
|
|
9
|
+
API_PARAMETERS: string;
|
|
10
|
+
API_HEADERS: string;
|
|
11
|
+
API_MODEL_PROPERTIES: string;
|
|
12
|
+
API_MODEL_PROPERTIES_ARRAY: string;
|
|
13
|
+
API_SECURITY: string;
|
|
14
|
+
API_EXCLUDE_ENDPOINT: string;
|
|
15
|
+
API_EXCLUDE_CONTROLLER: string;
|
|
16
|
+
API_EXTRA_MODELS: string;
|
|
17
|
+
API_EXTENSION: string;
|
|
18
|
+
};
|
|
19
|
+
export interface ApiPropertyOptions extends Omit<SchemaObjectMetadata, 'name' | 'enum'> {
|
|
20
|
+
name?: string;
|
|
21
|
+
enum?: any[] | Record<string, any>;
|
|
22
|
+
enumName?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function ApiProperty(options?: ApiPropertyOptions): PropertyDecorator;
|
|
25
|
+
export declare function createApiPropertyDecorator(options?: ApiPropertyOptions, overrideExisting?: boolean): PropertyDecorator;
|
|
26
|
+
export declare function ApiPropertyOptional(options?: ApiPropertyOptions): PropertyDecorator;
|
|
27
|
+
export declare function ApiResponseProperty(options?: Pick<ApiPropertyOptions, 'type' | 'example' | 'format' | 'enum' | 'deprecated'>): PropertyDecorator;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DECORATORS = exports.DECORATORS_PREFIX = void 0;
|
|
4
|
+
exports.ApiProperty = ApiProperty;
|
|
5
|
+
exports.createApiPropertyDecorator = createApiPropertyDecorator;
|
|
6
|
+
exports.ApiPropertyOptional = ApiPropertyOptional;
|
|
7
|
+
exports.ApiResponseProperty = ApiResponseProperty;
|
|
8
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
9
|
+
const create_property_decorator_1 = require("./create-property.decorator");
|
|
10
|
+
exports.DECORATORS_PREFIX = 'swagger';
|
|
11
|
+
exports.DECORATORS = {
|
|
12
|
+
API_OPERATION: `${exports.DECORATORS_PREFIX}/apiOperation`,
|
|
13
|
+
API_RESPONSE: `${exports.DECORATORS_PREFIX}/apiResponse`,
|
|
14
|
+
API_PRODUCES: `${exports.DECORATORS_PREFIX}/apiProduces`,
|
|
15
|
+
API_CONSUMES: `${exports.DECORATORS_PREFIX}/apiConsumes`,
|
|
16
|
+
API_TAGS: `${exports.DECORATORS_PREFIX}/apiUseTags`,
|
|
17
|
+
API_PARAMETERS: `${exports.DECORATORS_PREFIX}/apiParameters`,
|
|
18
|
+
API_HEADERS: `${exports.DECORATORS_PREFIX}/apiHeaders`,
|
|
19
|
+
API_MODEL_PROPERTIES: `${exports.DECORATORS_PREFIX}/apiModelProperties`,
|
|
20
|
+
API_MODEL_PROPERTIES_ARRAY: `${exports.DECORATORS_PREFIX}/apiModelPropertiesArray`,
|
|
21
|
+
API_SECURITY: `${exports.DECORATORS_PREFIX}/apiSecurity`,
|
|
22
|
+
API_EXCLUDE_ENDPOINT: `${exports.DECORATORS_PREFIX}/apiExcludeEndpoint`,
|
|
23
|
+
API_EXCLUDE_CONTROLLER: `${exports.DECORATORS_PREFIX}/apiExcludeController`,
|
|
24
|
+
API_EXTRA_MODELS: `${exports.DECORATORS_PREFIX}/apiExtraModels`,
|
|
25
|
+
API_EXTENSION: `${exports.DECORATORS_PREFIX}/apiExtension`
|
|
26
|
+
};
|
|
27
|
+
const isEnumArray = (obj) => obj.isArray && !!obj.enum;
|
|
28
|
+
function ApiProperty(options = {}) {
|
|
29
|
+
return createApiPropertyDecorator(options);
|
|
30
|
+
}
|
|
31
|
+
function createApiPropertyDecorator(options = {}, overrideExisting = true) {
|
|
32
|
+
const [type, isArray] = (0, create_property_decorator_1.getTypeIsArrayTuple)(options.type, options.isArray);
|
|
33
|
+
options = {
|
|
34
|
+
...options,
|
|
35
|
+
type,
|
|
36
|
+
isArray
|
|
37
|
+
};
|
|
38
|
+
if (isEnumArray(options)) {
|
|
39
|
+
options.type = 'array';
|
|
40
|
+
const enumValues = (0, enum_utils_1.getEnumValues)(options.enum);
|
|
41
|
+
options.items = {
|
|
42
|
+
type: (0, enum_utils_1.getEnumType)(enumValues),
|
|
43
|
+
enum: enumValues
|
|
44
|
+
};
|
|
45
|
+
delete options.enum;
|
|
46
|
+
}
|
|
47
|
+
else if (options.enum) {
|
|
48
|
+
const enumValues = (0, enum_utils_1.getEnumValues)(options.enum);
|
|
49
|
+
options.enum = enumValues;
|
|
50
|
+
options.type = (0, enum_utils_1.getEnumType)(enumValues);
|
|
51
|
+
}
|
|
52
|
+
return (0, create_property_decorator_1.createPropertyDecorator)(exports.DECORATORS.API_MODEL_PROPERTIES, options, overrideExisting);
|
|
53
|
+
}
|
|
54
|
+
function ApiPropertyOptional(options = {}) {
|
|
55
|
+
return ApiProperty({
|
|
56
|
+
...options,
|
|
57
|
+
required: false
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function ApiResponseProperty(options = {}) {
|
|
61
|
+
return ApiProperty({
|
|
62
|
+
readOnly: true,
|
|
63
|
+
...options
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=api-property.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-property.decorator.js","sourceRoot":"","sources":["../../../../../src/core/Nestjs/types/decorators/api-property.decorator.ts"],"names":[],"mappings":";;;AAmCA,kCAIC;AAED,gEAgCC;AAED,kDAOC;AAED,kDAUC;AA7FD,oDAAgE;AAChE,2EAGoC;AAEvB,QAAA,iBAAiB,GAAG,SAAS,CAAA;AAC7B,QAAA,UAAU,GAAG;IACxB,aAAa,EAAE,GAAG,yBAAiB,eAAe;IAClD,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,QAAQ,EAAE,GAAG,yBAAiB,aAAa;IAC3C,cAAc,EAAE,GAAG,yBAAiB,gBAAgB;IACpD,WAAW,EAAE,GAAG,yBAAiB,aAAa;IAC9C,oBAAoB,EAAE,GAAG,yBAAiB,qBAAqB;IAC/D,0BAA0B,EAAE,GAAG,yBAAiB,0BAA0B;IAC1E,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,oBAAoB,EAAE,GAAG,yBAAiB,qBAAqB;IAC/D,sBAAsB,EAAE,GAAG,yBAAiB,uBAAuB;IACnE,gBAAgB,EAAE,GAAG,yBAAiB,iBAAiB;IACvD,aAAa,EAAE,GAAG,yBAAiB,eAAe;CACnD,CAAA;AASD,MAAM,WAAW,GAAG,CAAC,GAAuB,EAAW,EAAE,CACvD,GAAG,CAAC,OAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAA;AAE5B,SAAgB,WAAW,CACzB,UAA8B,EAAE;IAEhC,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,SAAgB,0BAA0B,CACxC,UAA8B,EAAE,EAChC,gBAAgB,GAAG,IAAI;IAEvB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,+CAAmB,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAQ,CAAC,CAAA;IAC3E,OAAO,GAAG;QACR,GAAG,OAAO;QACV,IAAI;QACJ,OAAO;KACR,CAAA;IAED,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,OAAO,CAAA;QAEtB,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,OAAO,CAAC,IAAK,CAAC,CAAA;QAC/C,OAAO,CAAC,KAAK,GAAG;YACd,IAAI,EAAE,IAAA,wBAAW,EAAC,UAAU,CAAC;YAC7B,IAAI,EAAE,UAAU;SACjB,CAAA;QACD,OAAO,OAAO,CAAC,IAAI,CAAA;IACrB,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAE9C,OAAO,CAAC,IAAI,GAAG,UAAU,CAAA;QACzB,OAAO,CAAC,IAAI,GAAG,IAAA,wBAAW,EAAC,UAAU,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,IAAA,mDAAuB,EAC5B,kBAAU,CAAC,oBAAoB,EAC/B,OAAO,EACP,gBAAgB,CACjB,CAAA;AACH,CAAC;AAED,SAAgB,mBAAmB,CACjC,UAA8B,EAAE;IAEhC,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,mBAAmB,CACjC,UAGI,EAAE;IAEN,OAAO,WAAW,CAAC;QACjB,QAAQ,EAAE,IAAI;QACd,GAAG,OAAO;KACX,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Type } from '../common';
|
|
2
|
+
export declare function applyIsOptionalDecorator(targetClass: Function, propertyKey: string): void;
|
|
3
|
+
export declare function inheritValidationMetadata(parentClass: Type<any>, targetClass: Function, isPropertyInherited?: (key: string) => boolean): string[] | undefined;
|
|
4
|
+
export declare function inheritTransformationMetadata(parentClass: Type<any>, targetClass: Function, isPropertyInherited?: (key: string) => boolean): void;
|
|
5
|
+
export declare function inheritPropertyInitializers(target: Record<string, any>, sourceClass: Type<any>, isPropertyInherited?: (key: string) => boolean): void;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyIsOptionalDecorator = applyIsOptionalDecorator;
|
|
4
|
+
exports.inheritValidationMetadata = inheritValidationMetadata;
|
|
5
|
+
exports.inheritTransformationMetadata = inheritTransformationMetadata;
|
|
6
|
+
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
7
|
+
function applyIsOptionalDecorator(targetClass, propertyKey) {
|
|
8
|
+
if (!isClassValidatorAvailable()) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const classValidator = require('class-validator');
|
|
12
|
+
const decoratorFactory = classValidator.IsOptional();
|
|
13
|
+
decoratorFactory(targetClass.prototype, propertyKey);
|
|
14
|
+
}
|
|
15
|
+
function inheritValidationMetadata(parentClass, targetClass, isPropertyInherited) {
|
|
16
|
+
if (!isClassValidatorAvailable()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const classValidator = require('class-validator');
|
|
21
|
+
const metadataStorage = classValidator.getMetadataStorage
|
|
22
|
+
? classValidator.getMetadataStorage()
|
|
23
|
+
: classValidator.getFromContainer(classValidator.MetadataStorage);
|
|
24
|
+
const getTargetValidationMetadatasArgs = [parentClass, null, false, false];
|
|
25
|
+
const targetMetadata = metadataStorage.getTargetValidationMetadatas(...getTargetValidationMetadatasArgs);
|
|
26
|
+
return targetMetadata
|
|
27
|
+
.filter(({ propertyName }) => !isPropertyInherited || isPropertyInherited(propertyName))
|
|
28
|
+
.map(value => {
|
|
29
|
+
const originalType = Reflect.getMetadata('design:type', parentClass.prototype, value.propertyName);
|
|
30
|
+
if (originalType) {
|
|
31
|
+
Reflect.defineMetadata('design:type', originalType, targetClass.prototype, value.propertyName);
|
|
32
|
+
}
|
|
33
|
+
metadataStorage.addValidationMetadata({
|
|
34
|
+
...value,
|
|
35
|
+
target: targetClass
|
|
36
|
+
});
|
|
37
|
+
return value.propertyName;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error(`Validation ("class-validator") metadata cannot be inherited for "${parentClass.name}" class.`);
|
|
42
|
+
console.error(err);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function inheritTransformationMetadata(parentClass, targetClass, isPropertyInherited) {
|
|
46
|
+
if (!isClassTransformerAvailable()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const transformMetadataKeys = [
|
|
51
|
+
'_excludeMetadatas',
|
|
52
|
+
'_exposeMetadatas',
|
|
53
|
+
'_transformMetadatas',
|
|
54
|
+
'_typeMetadatas'
|
|
55
|
+
];
|
|
56
|
+
transformMetadataKeys.forEach(key => inheritTransformerMetadata(key, parentClass, targetClass, isPropertyInherited));
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error(`Transformer ("class-transformer") metadata cannot be inherited for "${parentClass.name}" class.`);
|
|
60
|
+
console.error(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function inheritTransformerMetadata(key, parentClass, targetClass, isPropertyInherited) {
|
|
64
|
+
let classTransformer;
|
|
65
|
+
try {
|
|
66
|
+
/** "class-transformer" >= v0.3.x */
|
|
67
|
+
classTransformer = require('class-transformer/cjs/storage');
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
/** "class-transformer" <= v0.3.x */
|
|
71
|
+
classTransformer = require('class-transformer/storage');
|
|
72
|
+
}
|
|
73
|
+
const metadataStorage /*: typeof import('class-transformer/types/storage').defaultMetadataStorage */ = classTransformer.defaultMetadataStorage;
|
|
74
|
+
while (parentClass && parentClass !== Object) {
|
|
75
|
+
if (metadataStorage[key].has(parentClass)) {
|
|
76
|
+
const metadataMap = metadataStorage[key];
|
|
77
|
+
const parentMetadata = metadataMap.get(parentClass);
|
|
78
|
+
const targetMetadataEntries = Array.from(parentMetadata.entries())
|
|
79
|
+
.filter(([key]) => !isPropertyInherited || isPropertyInherited(key))
|
|
80
|
+
.map(([key, metadata]) => {
|
|
81
|
+
if (Array.isArray(metadata)) {
|
|
82
|
+
// "_transformMetadatas" is an array of elements
|
|
83
|
+
const targetMetadata = metadata.map(item => ({
|
|
84
|
+
...item,
|
|
85
|
+
target: targetClass
|
|
86
|
+
}));
|
|
87
|
+
return [key, targetMetadata];
|
|
88
|
+
}
|
|
89
|
+
return [key, { ...metadata, target: targetClass }];
|
|
90
|
+
});
|
|
91
|
+
if (metadataMap.has(targetClass)) {
|
|
92
|
+
const existingRules = metadataMap.get(targetClass).entries();
|
|
93
|
+
metadataMap.set(targetClass, new Map([...existingRules, ...targetMetadataEntries]));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
metadataMap.set(targetClass, new Map(targetMetadataEntries));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
parentClass = Object.getPrototypeOf(parentClass);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function isClassValidatorAvailable() {
|
|
103
|
+
try {
|
|
104
|
+
require('class-validator');
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function isClassTransformerAvailable() {
|
|
112
|
+
try {
|
|
113
|
+
require('class-transformer');
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function inheritPropertyInitializers(target, sourceClass,
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
|
+
isPropertyInherited = (key) => true) {
|
|
123
|
+
try {
|
|
124
|
+
const tempInstance = new sourceClass();
|
|
125
|
+
const propertyNames = Object.getOwnPropertyNames(tempInstance);
|
|
126
|
+
propertyNames
|
|
127
|
+
.filter(propertyName => typeof tempInstance[propertyName] !== 'undefined' &&
|
|
128
|
+
typeof target[propertyName] === 'undefined')
|
|
129
|
+
.filter(propertyName => isPropertyInherited(propertyName))
|
|
130
|
+
.forEach(propertyName => {
|
|
131
|
+
target[propertyName] = tempInstance[propertyName];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch { }
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=apply-is-optional.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-is-optional.decorator.js","sourceRoot":"","sources":["../../../../../src/core/Nestjs/types/decorators/apply-is-optional.decorator.ts"],"names":[],"mappings":";;AAEA,4DAUC;AAED,8DAsDC;AAQD,sEA6BC;AA2ED,kEAqBC;AAvMD,SAAgB,wBAAwB,CACtC,WAAqB,EACrB,WAAmB;IAEnB,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC;QACjC,OAAM;IACR,CAAC;IACD,MAAM,cAAc,GAAqC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACnF,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,EAAE,CAAA;IACpD,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AACtD,CAAC;AAED,SAAgB,yBAAyB,CACvC,WAAsB,EACtB,WAAqB,EACrB,mBAA8C;IAE9C,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC;QACjC,OAAM;IACR,CAAC;IACD,IAAI,CAAC;QACH,MAAM,cAAc,GAAqC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QACnF,MAAM,eAAe,GACnB,cACD,CAAC,kBAAkB;YAClB,CAAC,CAAE,cAAsB,CAAC,kBAAkB,EAAE;YAC9C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC,cAAc,CAAC,eAAe,CAAC,CAAA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AAW,EAAE,EAAE,CAAC,IAAI;IAE3C,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAA;QACtC,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAA;QAE9D,aAAa;aACV,MAAM,CACL,YAAY,CAAC,EAAE,CACb,OAAO,YAAY,CAAC,YAAY,CAAC,KAAK,WAAW;YACjD,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,WAAW,CAC9C;aACA,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;aACzD,OAAO,CAAC,YAAY,CAAC,EAAE;YACtB,MAAM,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,CAAA;QACnD,CAAC,CAAC,CAAA;IACN,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArgsType = ArgsType;
|
|
4
|
+
const lazy_metadata_storage_1 = require("../lazy-metadata.storage");
|
|
5
|
+
const type_metadata_storage_1 = require("../type-metadata.storage");
|
|
6
|
+
const add_class_type_metadata_util_1 = require("../interfaces/add-class-type-metadata.util");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
/**
|
|
9
|
+
* Decorator that marks a class as a resolver arguments type.
|
|
10
|
+
*/
|
|
11
|
+
function ArgsType() {
|
|
12
|
+
return (target) => {
|
|
13
|
+
const metadata = {
|
|
14
|
+
name: target.name,
|
|
15
|
+
target
|
|
16
|
+
};
|
|
17
|
+
lazy_metadata_storage_1.LazyMetadataStorage.store(() => type_metadata_storage_1.TypeMetadataStorage.addArgsMetadata(metadata));
|
|
18
|
+
// This function must be called eagerly to allow resolvers
|
|
19
|
+
// accessing the "name" property
|
|
20
|
+
type_metadata_storage_1.TypeMetadataStorage.addArgsMetadata(metadata);
|
|
21
|
+
(0, add_class_type_metadata_util_1.addClassTypeMetadata)(target, common_1.ClassType.ARGS);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=args-type.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args-type.decorator.js","sourceRoot":"","sources":["../../../../../src/core/Nestjs/types/decorators/args-type.decorator.ts"],"names":[],"mappings":";;AAQA,4BAcC;AAtBD,oEAA8D;AAC9D,oEAA8D;AAC9D,6FAAiF;AACjF,sCAAqC;AAErC;;GAEG;AACH,SAAgB,QAAQ;IACtB,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,MAAM,QAAQ,GAAG;YACf,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM;SACP,CAAA;QACD,2CAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAC7B,2CAAmB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAC9C,CAAA;QACD,0DAA0D;QAC1D,gCAAgC;QAChC,2CAAmB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC7C,IAAA,mDAAoB,EAAC,MAAM,EAAE,kBAAS,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function createPropertyDecorator<T extends Record<string, any> = any>(metakey: string, metadata: T, overrideExisting?: boolean): PropertyDecorator;
|
|
2
|
+
export declare function getTypeIsArrayTuple(input: Function | [Function] | undefined | string | Record<string, any>, isArrayFlag: boolean): [Function | undefined, boolean];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPropertyDecorator = createPropertyDecorator;
|
|
4
|
+
exports.getTypeIsArrayTuple = getTypeIsArrayTuple;
|
|
5
|
+
const type_metadata_storage_1 = require("../type-metadata.storage");
|
|
6
|
+
const api_property_decorator_1 = require("./api-property.decorator");
|
|
7
|
+
const isUndefined = val => typeof val === 'undefined';
|
|
8
|
+
const OmitBy = (obj, check) => {
|
|
9
|
+
obj = { ...obj };
|
|
10
|
+
Object.entries(obj).forEach(([key, value]) => check(value) && delete obj[key]);
|
|
11
|
+
return obj;
|
|
12
|
+
};
|
|
13
|
+
function createPropertyDecorator(metakey, metadata, overrideExisting = true) {
|
|
14
|
+
return (target, propertyKey) => {
|
|
15
|
+
const properties = Reflect.getMetadata(api_property_decorator_1.DECORATORS.API_MODEL_PROPERTIES_ARRAY, target) || [];
|
|
16
|
+
const key = `:${propertyKey}`;
|
|
17
|
+
if (!properties.includes(key)) {
|
|
18
|
+
Reflect.defineMetadata(api_property_decorator_1.DECORATORS.API_MODEL_PROPERTIES_ARRAY, [...properties, `:${propertyKey}`], target);
|
|
19
|
+
}
|
|
20
|
+
const existingMetadata = Reflect.getMetadata(metakey, target, propertyKey);
|
|
21
|
+
if (existingMetadata) {
|
|
22
|
+
const newMetadata = OmitBy(metadata, isUndefined);
|
|
23
|
+
const metadataToSave = overrideExisting
|
|
24
|
+
? {
|
|
25
|
+
...existingMetadata,
|
|
26
|
+
...newMetadata
|
|
27
|
+
}
|
|
28
|
+
: {
|
|
29
|
+
...newMetadata,
|
|
30
|
+
...existingMetadata
|
|
31
|
+
};
|
|
32
|
+
Reflect.defineMetadata(metakey, metadataToSave, target, propertyKey);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const type = target?.constructor?.[type_metadata_storage_1.METADATA_FACTORY_NAME]?.()[propertyKey]?.type ??
|
|
36
|
+
Reflect.getMetadata('design:type', target, propertyKey);
|
|
37
|
+
Reflect.defineMetadata(metakey, {
|
|
38
|
+
type,
|
|
39
|
+
...OmitBy(metadata, isUndefined)
|
|
40
|
+
}, target, propertyKey);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getTypeIsArrayTuple(input, isArrayFlag) {
|
|
45
|
+
if (!input) {
|
|
46
|
+
return [input, isArrayFlag];
|
|
47
|
+
}
|
|
48
|
+
if (isArrayFlag) {
|
|
49
|
+
return [input, isArrayFlag];
|
|
50
|
+
}
|
|
51
|
+
const isInputArray = Array.isArray(input);
|
|
52
|
+
const type = isInputArray ? input[0] : input;
|
|
53
|
+
return [type, isInputArray];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=create-property.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-property.decorator.js","sourceRoot":"","sources":["../../../../../src/core/Nestjs/types/decorators/create-property.decorator.ts"],"names":[],"mappings":";;AAWA,0DA+CC;AAED,kDAaC;AAzED,oEAAgE;AAChE,qEAAqD;AAErD,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,CAAA;AAErD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;IAC5B,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAA;IAChB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9E,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,SAAgB,uBAAuB,CACrC,OAAe,EACf,QAAW,EACX,gBAAgB,GAAG,IAAI;IAEvB,OAAO,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;QAC7C,MAAM,UAAU,GACd,OAAO,CAAC,WAAW,CAAC,mCAAU,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QAE1E,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;QAC7B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,cAA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