@goatlab/fluent 0.6.3 → 0.6.6
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/core/dtos/pagination.dto.d.ts +2 -2
- package/dist/core/dtos/pagination.dto.js +18 -18
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/package.json +2 -2
- package/dist/BaseConnector.d.ts +0 -79
- package/dist/BaseConnector.js +0 -361
- package/dist/Fluent.d.ts +0 -26
- package/dist/Fluent.js +0 -52
- package/dist/TypeOrmConnector/TypeOrmConnector.js +0 -509
- package/dist/TypeOrmConnector/TypeOrmMongoConnector._bypass.js +0 -52
- package/dist/TypeOrmConnector/TypeOrmMysqlConnector._bypass.js +0 -55
- package/dist/TypeOrmConnector/TypeOrmSqliteConnector.spec.d.ts +0 -1
- package/dist/TypeOrmConnector/TypeOrmSqliteConnector.spec.js +0 -47
- package/dist/TypeOrmConnector/test/advanced/advancedTestSuite.d.ts +0 -1
- package/dist/TypeOrmConnector/test/advanced/advancedTestSuite.js +0 -114
- package/dist/TypeOrmConnector/test/advanced/typeOrm.entity.d.ts +0 -16
- package/dist/TypeOrmConnector/test/advanced/typeOrm.entity.js +0 -57
- package/dist/TypeOrmConnector/test/advanced/typeOrm.repository.js +0 -11
- package/dist/TypeOrmConnector/test/basic/basicTestSuite.d.ts +0 -1
- package/dist/TypeOrmConnector/test/basic/basicTestSuite.js +0 -45
- package/dist/TypeOrmConnector/test/basic/goat.dto.d.ts +0 -8
- package/dist/TypeOrmConnector/test/basic/goat.dto.js +0 -18
- package/dist/TypeOrmConnector/test/basic/goat.entity.d.ts +0 -10
- package/dist/TypeOrmConnector/test/basic/goat.entity.js +0 -42
- package/dist/TypeOrmConnector/test/basic/goat.repository.js +0 -11
- package/dist/TypeOrmConnector/test/flock.d.ts +0 -4
- package/dist/TypeOrmConnector/test/flock.js +0 -25
- package/dist/TypeOrmConnector/test/relations/car/car.dto.d.ts +0 -5
- package/dist/TypeOrmConnector/test/relations/car/car.dto.js +0 -12
- package/dist/TypeOrmConnector/test/relations/car/car.entity.d.ts +0 -7
- package/dist/TypeOrmConnector/test/relations/car/car.entity.js +0 -32
- package/dist/TypeOrmConnector/test/relations/car/car.repositoryTypeOrm.js +0 -13
- package/dist/TypeOrmConnector/test/relations/relationsTestsSuite.d.ts +0 -1
- package/dist/TypeOrmConnector/test/relations/relationsTestsSuite.js +0 -93
- package/dist/TypeOrmConnector/test/relations/roles/role.dto.d.ts +0 -5
- package/dist/TypeOrmConnector/test/relations/roles/role.dto.js +0 -12
- package/dist/TypeOrmConnector/test/relations/roles/roles.entity.d.ts +0 -6
- package/dist/TypeOrmConnector/test/relations/roles/roles.entity.js +0 -29
- package/dist/TypeOrmConnector/test/relations/roles/roles.repositoryTypeOrm.js +0 -14
- package/dist/TypeOrmConnector/test/relations/roles/roles_user.dto.d.ts +0 -5
- package/dist/TypeOrmConnector/test/relations/roles/roles_user.dto.js +0 -12
- package/dist/TypeOrmConnector/test/relations/roles/roles_user.entity.d.ts +0 -5
- package/dist/TypeOrmConnector/test/relations/roles/roles_user.entity.js +0 -23
- package/dist/TypeOrmConnector/test/relations/roles/roles_users.repositoryTypeOrm.js +0 -11
- package/dist/TypeOrmConnector/test/relations/user/user.dto.d.ts +0 -5
- package/dist/TypeOrmConnector/test/relations/user/user.dto.js +0 -12
- package/dist/TypeOrmConnector/test/relations/user/user.entity.d.ts +0 -14
- package/dist/TypeOrmConnector/test/relations/user/user.entity.js +0 -56
- package/dist/TypeOrmConnector/test/relations/user/user.repositoryTypeOrm.js +0 -16
- package/dist/core/Loopback/build-schema.d.ts +0 -31
- package/dist/core/Loopback/build-schema.js +0 -335
- package/dist/core/Loopback/common-types.d.ts +0 -36
- package/dist/core/Loopback/common-types.js +0 -13
- package/dist/core/Loopback/json-to-schema.d.ts +0 -6
- package/dist/core/Loopback/json-to-schema.js +0 -96
- package/dist/core/Loopback/metadata.d.ts +0 -9
- package/dist/core/Loopback/metadata.js +0 -28
- package/dist/core/Loopback/model.d.ts +0 -87
- package/dist/core/Loopback/model.js +0 -244
- package/dist/core/Loopback/query.d.ts +0 -97
- package/dist/core/Loopback/query.js +0 -290
- package/dist/core/Loopback/relation.types.d.ts +0 -45
- package/dist/core/Loopback/relation.types.js +0 -13
- package/dist/core/Loopback/type-resolver.d.ts +0 -7
- package/dist/core/Loopback/type-resolver.js +0 -34
- package/dist/core/Loopback/type.d.ts +0 -9
- package/dist/core/Loopback/type.js +0 -2
- package/dist/core/Nestjs/applyDecorators.d.ts +0 -1
- package/dist/core/Nestjs/applyDecorators.js +0 -17
- package/dist/core/Nestjs/types/common.d.ts +0 -16
- package/dist/core/Nestjs/types/common.js +0 -35
- package/dist/core/Nestjs/types/decorators/api-hide-property.decorator.d.ts +0 -1
- package/dist/core/Nestjs/types/decorators/api-hide-property.decorator.js +0 -7
- package/dist/core/Nestjs/types/decorators/api-property.decorator.d.ts +0 -27
- package/dist/core/Nestjs/types/decorators/api-property.decorator.js +0 -65
- package/dist/core/Nestjs/types/decorators/apply-is-optional.decorator.d.ts +0 -5
- package/dist/core/Nestjs/types/decorators/apply-is-optional.decorator.js +0 -131
- package/dist/core/Nestjs/types/decorators/args-type.decorator.d.ts +0 -1
- package/dist/core/Nestjs/types/decorators/args-type.decorator.js +0 -19
- package/dist/core/Nestjs/types/decorators/create-property.decorator.d.ts +0 -2
- package/dist/core/Nestjs/types/decorators/create-property.decorator.js +0 -50
- package/dist/core/Nestjs/types/decorators/directive.decorator.d.ts +0 -1
- package/dist/core/Nestjs/types/decorators/directive.decorator.js +0 -36
- package/dist/core/Nestjs/types/decorators/extensions.decorator.d.ts +0 -1
- package/dist/core/Nestjs/types/decorators/extensions.decorator.js +0 -25
- package/dist/core/Nestjs/types/decorators/field.decorator.d.ts +0 -15
- package/dist/core/Nestjs/types/decorators/field.decorator.js +0 -56
- package/dist/core/Nestjs/types/decorators/input-type.decorator.d.ts +0 -7
- package/dist/core/Nestjs/types/decorators/input-type.decorator.js +0 -23
- package/dist/core/Nestjs/types/decorators/interface-type.decorator.d.ts +0 -9
- package/dist/core/Nestjs/types/decorators/interface-type.decorator.js +0 -27
- package/dist/core/Nestjs/types/decorators/partial-type.helper.d.ts +0 -3
- package/dist/core/Nestjs/types/decorators/partial-type.helper.js +0 -42
- package/dist/core/Nestjs/types/errors/cannot-determine-host-type.error.d.ts +0 -3
- package/dist/core/Nestjs/types/errors/cannot-determine-host-type.error.js +0 -9
- package/dist/core/Nestjs/types/errors/directive-parsing.error.d.ts +0 -3
- package/dist/core/Nestjs/types/errors/directive-parsing.error.js +0 -9
- package/dist/core/Nestjs/types/errors/unable-to-find-fields.error.d.ts +0 -3
- package/dist/core/Nestjs/types/errors/unable-to-find-fields.error.js +0 -9
- package/dist/core/Nestjs/types/errors/undefined-type.error.d.ts +0 -3
- package/dist/core/Nestjs/types/errors/undefined-type.error.js +0 -10
- package/dist/core/Nestjs/types/interfaces/add-class-type-metadata.util.d.ts +0 -3
- package/dist/core/Nestjs/types/interfaces/add-class-type-metadata.util.js +0 -10
- package/dist/core/Nestjs/types/interfaces/base-type-options.interface.d.ts +0 -5
- package/dist/core/Nestjs/types/interfaces/base-type-options.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/class-decorator-factory.interface.d.ts +0 -5
- package/dist/core/Nestjs/types/interfaces/class-decorator-factory.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/complexity.interface.d.ts +0 -11
- package/dist/core/Nestjs/types/interfaces/complexity.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/field-middleware.interface.d.ts +0 -15
- package/dist/core/Nestjs/types/interfaces/field-middleware.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/open-api-spec.interface.d.ts +0 -235
- package/dist/core/Nestjs/types/interfaces/open-api-spec.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/resolve-type-fn.interface.d.ts +0 -2
- package/dist/core/Nestjs/types/interfaces/resolve-type-fn.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/return-type-func.interface.d.ts +0 -5
- package/dist/core/Nestjs/types/interfaces/return-type-func.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/schema-object-metadata.interface.d.ts +0 -9
- package/dist/core/Nestjs/types/interfaces/schema-object-metadata.interface.js +0 -2
- package/dist/core/Nestjs/types/interfaces/type-options.interface.d.ts +0 -5
- package/dist/core/Nestjs/types/interfaces/type-options.interface.js +0 -2
- package/dist/core/Nestjs/types/lazy-metadata.storage.d.ts +0 -15
- package/dist/core/Nestjs/types/lazy-metadata.storage.js +0 -67
- package/dist/core/Nestjs/types/metadata/class.metadata.d.ts +0 -11
- package/dist/core/Nestjs/types/metadata/class.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/directive.metadata.d.ts +0 -8
- package/dist/core/Nestjs/types/metadata/directive.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/enum.metadata.d.ts +0 -11
- package/dist/core/Nestjs/types/metadata/enum.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/extensions.metadata.d.ts +0 -8
- package/dist/core/Nestjs/types/metadata/extensions.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/index.d.ts +0 -8
- package/dist/core/Nestjs/types/metadata/index.js +0 -11
- package/dist/core/Nestjs/types/metadata/interface.metadata.d.ts +0 -6
- package/dist/core/Nestjs/types/metadata/interface.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/object-type.metadata.d.ts +0 -4
- package/dist/core/Nestjs/types/metadata/object-type.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/param.metadata.d.ts +0 -18
- package/dist/core/Nestjs/types/metadata/param.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/property.metadata.d.ts +0 -20
- package/dist/core/Nestjs/types/metadata/property.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/resolver.metadata.d.ts +0 -34
- package/dist/core/Nestjs/types/metadata/resolver.metadata.js +0 -2
- package/dist/core/Nestjs/types/metadata/union.metadata.d.ts +0 -9
- package/dist/core/Nestjs/types/metadata/union.metadata.js +0 -2
- package/dist/core/Nestjs/types/object-type.decorator.d.ts +0 -8
- package/dist/core/Nestjs/types/object-type.decorator.js +0 -25
- package/dist/core/Nestjs/types/omit-type.d.ts +0 -2
- package/dist/core/Nestjs/types/omit-type.js +0 -30
- package/dist/core/Nestjs/types/reflection.utils.d.ts +0 -15
- package/dist/core/Nestjs/types/reflection.utils.js +0 -58
- package/dist/core/Nestjs/types/set-metadata.decorator.d.ts +0 -4
- package/dist/core/Nestjs/types/set-metadata.decorator.js +0 -16
- package/dist/core/Nestjs/types/type-metadata.storage.d.ts +0 -69
- package/dist/core/Nestjs/types/type-metadata.storage.js +0 -342
- package/dist/core/Nestjs/types/utils/enum.utils.d.ts +0 -3
- package/dist/core/Nestjs/types/utils/enum.utils.js +0 -29
- package/dist/core/Nestjs/types/utils/get-fields-and-decorator.util.d.ts +0 -13
- package/dist/core/Nestjs/types/utils/get-fields-and-decorator.util.js +0 -72
- package/dist/core/Nestjs/types/utils/mapped-types.utils.d.ts +0 -2
- package/dist/core/Nestjs/types/utils/mapped-types.utils.js +0 -38
- package/dist/core/Nestjs/types/utils/model-properties-accessor.d.ts +0 -6
- package/dist/core/Nestjs/types/utils/model-properties-accessor.js +0 -36
- package/dist/core/Nestjs/types/utils/type-helpers.utils.d.ts +0 -2
- package/dist/core/Nestjs/types/utils/type-helpers.utils.js +0 -16
- package/dist/core/database/createConnection.d.ts +0 -30
- package/dist/core/database/createConnection.js +0 -43
- package/dist/core/database/decorators.d.ts +0 -43
- package/dist/core/database/decorators.js +0 -98
- package/dist/core/dtos/access.dto.d.ts +0 -4
- package/dist/core/dtos/access.dto.js +0 -21
- package/dist/core/types.d.ts +0 -23
- package/dist/core/types.js +0 -29
- package/dist/generatorDatasource.d.ts +0 -2
- package/dist/generatorDatasource.js +0 -12
- package/dist/loadRelations.js +0 -92
- package/dist/outputKeys.d.ts +0 -2
- package/dist/outputKeys.js +0 -17
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -85
- package/dist/types.js +0 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class PaginationMeta {
|
|
2
2
|
itemCount: number;
|
|
3
3
|
totalItems: number;
|
|
4
4
|
itemsPerPage: number;
|
|
5
5
|
totalPages: number;
|
|
6
6
|
currentPage: number;
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class PaginationLinks {
|
|
9
9
|
first?: string;
|
|
10
10
|
previous?: string;
|
|
11
11
|
next?: string;
|
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PaginationLinks = exports.PaginationMeta = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
let
|
|
6
|
+
let PaginationMeta = class PaginationMeta {
|
|
7
7
|
};
|
|
8
8
|
tslib_1.__decorate([
|
|
9
9
|
(0, types_1.Column)('number'),
|
|
10
10
|
(0, types_1.ApiProperty)(),
|
|
11
11
|
tslib_1.__metadata("design:type", Number)
|
|
12
|
-
],
|
|
12
|
+
], PaginationMeta.prototype, "itemCount", void 0);
|
|
13
13
|
tslib_1.__decorate([
|
|
14
14
|
(0, types_1.Column)('number'),
|
|
15
15
|
(0, types_1.ApiProperty)(),
|
|
16
16
|
tslib_1.__metadata("design:type", Number)
|
|
17
|
-
],
|
|
17
|
+
], PaginationMeta.prototype, "totalItems", void 0);
|
|
18
18
|
tslib_1.__decorate([
|
|
19
19
|
(0, types_1.Column)('number'),
|
|
20
20
|
(0, types_1.ApiProperty)(),
|
|
21
21
|
tslib_1.__metadata("design:type", Number)
|
|
22
|
-
],
|
|
22
|
+
], PaginationMeta.prototype, "itemsPerPage", void 0);
|
|
23
23
|
tslib_1.__decorate([
|
|
24
24
|
(0, types_1.Column)('number'),
|
|
25
25
|
(0, types_1.ApiProperty)(),
|
|
26
26
|
tslib_1.__metadata("design:type", Number)
|
|
27
|
-
],
|
|
27
|
+
], PaginationMeta.prototype, "totalPages", void 0);
|
|
28
28
|
tslib_1.__decorate([
|
|
29
29
|
(0, types_1.Column)('number'),
|
|
30
30
|
(0, types_1.ApiProperty)(),
|
|
31
31
|
tslib_1.__metadata("design:type", Number)
|
|
32
|
-
],
|
|
33
|
-
|
|
32
|
+
], PaginationMeta.prototype, "currentPage", void 0);
|
|
33
|
+
PaginationMeta = tslib_1.__decorate([
|
|
34
34
|
(0, types_1.InputType)()
|
|
35
|
-
],
|
|
36
|
-
exports.
|
|
37
|
-
let
|
|
35
|
+
], PaginationMeta);
|
|
36
|
+
exports.PaginationMeta = PaginationMeta;
|
|
37
|
+
let PaginationLinks = class PaginationLinks {
|
|
38
38
|
};
|
|
39
39
|
tslib_1.__decorate([
|
|
40
40
|
(0, types_1.Column)('text'),
|
|
41
41
|
(0, types_1.ApiProperty)(),
|
|
42
42
|
tslib_1.__metadata("design:type", String)
|
|
43
|
-
],
|
|
43
|
+
], PaginationLinks.prototype, "first", void 0);
|
|
44
44
|
tslib_1.__decorate([
|
|
45
45
|
(0, types_1.Column)('text'),
|
|
46
46
|
(0, types_1.ApiProperty)(),
|
|
47
47
|
tslib_1.__metadata("design:type", String)
|
|
48
|
-
],
|
|
48
|
+
], PaginationLinks.prototype, "previous", void 0);
|
|
49
49
|
tslib_1.__decorate([
|
|
50
50
|
(0, types_1.Column)('text'),
|
|
51
51
|
(0, types_1.ApiProperty)(),
|
|
52
52
|
tslib_1.__metadata("design:type", String)
|
|
53
|
-
],
|
|
53
|
+
], PaginationLinks.prototype, "next", void 0);
|
|
54
54
|
tslib_1.__decorate([
|
|
55
55
|
(0, types_1.Column)('text'),
|
|
56
56
|
(0, types_1.ApiProperty)(),
|
|
57
57
|
tslib_1.__metadata("design:type", String)
|
|
58
|
-
],
|
|
59
|
-
|
|
58
|
+
], PaginationLinks.prototype, "last", void 0);
|
|
59
|
+
PaginationLinks = tslib_1.__decorate([
|
|
60
60
|
(0, types_1.InputType)()
|
|
61
|
-
],
|
|
62
|
-
exports.
|
|
61
|
+
], PaginationLinks);
|
|
62
|
+
exports.PaginationLinks = PaginationLinks;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ import type { SchemaObject } from './core/types';
|
|
|
11
11
|
import { createConnection } from './core/database/createConnection';
|
|
12
12
|
import { TypeOrmConnector } from './TypeOrmConnector/TypeOrmConnector';
|
|
13
13
|
import { loadRelations } from './loadRelations';
|
|
14
|
-
|
|
14
|
+
import { PaginationLinks, PaginationMeta } from './core/dtos/pagination.dto';
|
|
15
|
+
export { BaseConnector, Collection, createConnection, Decorators, Fluent, getOutputKeys, modelGeneratorDataSource, ApiProperty, ApiHideProperty, OmitType, InputType, PartialType, Column, getModelSchemaRef, ObjectType, HideField, TypeOrmConnector, loadRelations, PaginationLinks, PaginationMeta };
|
|
15
16
|
export type { BaseDaoExtendedAttributes, BaseDataElement, DaoOutput, Deleted, Filter, FluentConnectorInterface, LogicOperator, PaginatedData, Paginator, Paths, Primitives, PrimitivesArray, Sure, WhereClause, SchemaObject };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadRelations = exports.TypeOrmConnector = exports.HideField = exports.ObjectType = exports.getModelSchemaRef = exports.Column = exports.PartialType = exports.InputType = exports.OmitType = exports.ApiHideProperty = exports.ApiProperty = exports.modelGeneratorDataSource = exports.getOutputKeys = exports.Fluent = exports.Decorators = exports.createConnection = exports.Collection = exports.BaseConnector = void 0;
|
|
3
|
+
exports.PaginationMeta = exports.PaginationLinks = exports.loadRelations = exports.TypeOrmConnector = exports.HideField = exports.ObjectType = exports.getModelSchemaRef = exports.Column = exports.PartialType = exports.InputType = exports.OmitType = exports.ApiHideProperty = exports.ApiProperty = exports.modelGeneratorDataSource = exports.getOutputKeys = exports.Fluent = exports.Decorators = exports.createConnection = exports.Collection = exports.BaseConnector = void 0;
|
|
4
4
|
const BaseConnector_1 = require("./BaseConnector");
|
|
5
5
|
Object.defineProperty(exports, "BaseConnector", { enumerable: true, get: function () { return BaseConnector_1.BaseConnector; } });
|
|
6
6
|
const js_utils_1 = require("@goatlab/js-utils");
|
|
@@ -29,3 +29,6 @@ const TypeOrmConnector_1 = require("./TypeOrmConnector/TypeOrmConnector");
|
|
|
29
29
|
Object.defineProperty(exports, "TypeOrmConnector", { enumerable: true, get: function () { return TypeOrmConnector_1.TypeOrmConnector; } });
|
|
30
30
|
const loadRelations_1 = require("./loadRelations");
|
|
31
31
|
Object.defineProperty(exports, "loadRelations", { enumerable: true, get: function () { return loadRelations_1.loadRelations; } });
|
|
32
|
+
const pagination_dto_1 = require("./core/dtos/pagination.dto");
|
|
33
|
+
Object.defineProperty(exports, "PaginationLinks", { enumerable: true, get: function () { return pagination_dto_1.PaginationLinks; } });
|
|
34
|
+
Object.defineProperty(exports, "PaginationMeta", { enumerable: true, get: function () { return pagination_dto_1.PaginationMeta; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goatlab/fluent",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "Readable query Interface & API generator for TS and Node",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rimraf dist",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://docs.goatlab.io",
|
|
65
65
|
"main": "dist/index.js",
|
|
66
|
-
"types": "dist
|
|
66
|
+
"types": "dist/index.d.ts",
|
|
67
67
|
"files": [
|
|
68
68
|
"dist"
|
|
69
69
|
],
|
package/dist/BaseConnector.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { TypedPathWrapper } from 'typed-path';
|
|
2
|
-
import { Filter, DaoOutput, BaseDaoExtendedAttributes, LogicOperator, Primitives, PrimitivesArray } from './types';
|
|
3
|
-
import { Collection } from '@goatlab/js-utils';
|
|
4
|
-
export interface FluentConnectorInterface<InputDTO, OutputDTO> {
|
|
5
|
-
get(): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
6
|
-
all(filter: Filter): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
7
|
-
findById(id: string): Promise<DaoOutput<InputDTO, OutputDTO>>;
|
|
8
|
-
find(filter: Filter): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
9
|
-
deleteById(id: string): Promise<string>;
|
|
10
|
-
updateById(id: string, data: InputDTO): Promise<DaoOutput<InputDTO, OutputDTO>>;
|
|
11
|
-
insert(data: InputDTO): Promise<DaoOutput<InputDTO, OutputDTO>>;
|
|
12
|
-
insertMany(data: InputDTO[]): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class BaseConnector<ModelDTO, InputDTO, OutputDTO> {
|
|
15
|
-
_keys: TypedPathWrapper<ModelDTO & InputDTO & OutputDTO, Record<never, never> & {
|
|
16
|
-
$path: (path: import("typed-path").TypedPathKey[]) => string;
|
|
17
|
-
$raw: (path: import("typed-path").TypedPathKey[]) => string[];
|
|
18
|
-
$rawPath: (path: import("typed-path").TypedPathKey[]) => import("typed-path").TypedPathKey[];
|
|
19
|
-
toString: (path: import("typed-path").TypedPathKey[]) => () => string;
|
|
20
|
-
valueOf: (path: import("typed-path").TypedPathKey[]) => () => string;
|
|
21
|
-
[Symbol.toStringTag]: (path: import("typed-path").TypedPathKey[]) => string;
|
|
22
|
-
}>;
|
|
23
|
-
protected outputKeys: string[];
|
|
24
|
-
protected chainReference: any[];
|
|
25
|
-
protected whereArray: any[];
|
|
26
|
-
protected orWhereArray: any[];
|
|
27
|
-
protected selectArray: any[];
|
|
28
|
-
protected forceSelectArray: any[];
|
|
29
|
-
protected orderByArray: any[];
|
|
30
|
-
protected limitNumber: number;
|
|
31
|
-
protected offsetNumber: number;
|
|
32
|
-
protected populateArray: any[];
|
|
33
|
-
protected chunk: any;
|
|
34
|
-
protected pullSize: any;
|
|
35
|
-
protected ownerId: any;
|
|
36
|
-
protected paginator: any;
|
|
37
|
-
protected rawQuery: any;
|
|
38
|
-
protected getFirst: boolean;
|
|
39
|
-
protected relations: any;
|
|
40
|
-
protected loadModels: boolean;
|
|
41
|
-
protected relationQuery: any;
|
|
42
|
-
protected modelRelations: any;
|
|
43
|
-
isMongoDB: boolean;
|
|
44
|
-
protected getExtendedCreateAttributes: () => BaseDaoExtendedAttributes;
|
|
45
|
-
constructor();
|
|
46
|
-
get(): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
47
|
-
insertMany(data: InputDTO[]): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
48
|
-
owner(user: string): this;
|
|
49
|
-
own(user: string): this;
|
|
50
|
-
first(): Promise<DaoOutput<InputDTO, OutputDTO> | null>;
|
|
51
|
-
collect(): Promise<Collection<DaoOutput<InputDTO, OutputDTO>>>;
|
|
52
|
-
select(...columns: TypedPathWrapper<Primitives, Primitives>[]): this;
|
|
53
|
-
forceSelect(...columns: TypedPathWrapper<Primitives, Primitives>[]): this;
|
|
54
|
-
offset(offset: number): this;
|
|
55
|
-
populate(...relations: any[]): this;
|
|
56
|
-
skip(offset: number): this;
|
|
57
|
-
where(path: TypedPathWrapper<Primitives, Primitives>, operator: LogicOperator, value: Primitives | PrimitivesArray): this;
|
|
58
|
-
andWhere(path: TypedPathWrapper<Primitives, Primitives>, operator: LogicOperator, value: Primitives | Primitives[]): this;
|
|
59
|
-
orWhere(path: TypedPathWrapper<Primitives, Primitives>, operator: LogicOperator, value: Primitives): this;
|
|
60
|
-
limit(limit: number): this;
|
|
61
|
-
take(limit: number): this;
|
|
62
|
-
pluck(path: TypedPathWrapper<Primitives, Primitives>): Promise<string[]>;
|
|
63
|
-
orderBy(path: TypedPathWrapper<Primitives, Primitives>, order?: 'asc' | 'desc', orderType?: 'string' | 'number' | 'date'): this;
|
|
64
|
-
protected jsApplySelect(data: any): any[];
|
|
65
|
-
protected jsApplyOrderBy(data: any): any[];
|
|
66
|
-
protected reset(): void;
|
|
67
|
-
load(): Promise<this>;
|
|
68
|
-
loadFirst(): Promise<this>;
|
|
69
|
-
getLoadedData(): DaoOutput<InputDTO, OutputDTO>[] | DaoOutput<InputDTO, OutputDTO>;
|
|
70
|
-
with(entities: any): this;
|
|
71
|
-
attach(data: InputDTO): Promise<DaoOutput<InputDTO, OutputDTO>[]>;
|
|
72
|
-
associate(id: string): any;
|
|
73
|
-
protected hasMany<T>(Repository: any, relationName: string): T;
|
|
74
|
-
protected hasOne(): void;
|
|
75
|
-
protected belongsTo<T>(Repository: any, relationName: string): T;
|
|
76
|
-
protected belongsToMany<T, R>(Repository: any, Pivot: any, relationName: string): T;
|
|
77
|
-
protected hasManyThrough(): void;
|
|
78
|
-
private prepareInput;
|
|
79
|
-
}
|
package/dist/BaseConnector.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseConnector = void 0;
|
|
4
|
-
const typed_path_1 = require("typed-path");
|
|
5
|
-
const dates_1 = require("@goatlab/dates");
|
|
6
|
-
const js_utils_1 = require("@goatlab/js-utils");
|
|
7
|
-
class BaseConnector {
|
|
8
|
-
constructor() {
|
|
9
|
-
this._keys = (0, typed_path_1.typedPath)();
|
|
10
|
-
this.chainReference = [];
|
|
11
|
-
this.whereArray = [];
|
|
12
|
-
this.orWhereArray = [];
|
|
13
|
-
this.selectArray = [];
|
|
14
|
-
this.forceSelectArray = [];
|
|
15
|
-
this.orderByArray = [];
|
|
16
|
-
this.limitNumber = 0;
|
|
17
|
-
this.offsetNumber = 0;
|
|
18
|
-
this.populateArray = [];
|
|
19
|
-
this.chunk = null;
|
|
20
|
-
this.pullSize = null;
|
|
21
|
-
this.ownerId = undefined;
|
|
22
|
-
this.paginator = undefined;
|
|
23
|
-
this.rawQuery = undefined;
|
|
24
|
-
this.getFirst = false;
|
|
25
|
-
this.relations = undefined;
|
|
26
|
-
this.loadModels = false;
|
|
27
|
-
this.getExtendedCreateAttributes = () => {
|
|
28
|
-
const date = dates_1.Dates.currentIsoString();
|
|
29
|
-
return {
|
|
30
|
-
id: `${js_utils_1.Ids.objectIdString()}_local`,
|
|
31
|
-
updated: date,
|
|
32
|
-
created: date,
|
|
33
|
-
roles: []
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
this.chainReference = [];
|
|
37
|
-
this.whereArray = [];
|
|
38
|
-
this.orWhereArray = [];
|
|
39
|
-
this.selectArray = [];
|
|
40
|
-
this.forceSelectArray = [];
|
|
41
|
-
this.orderByArray = [];
|
|
42
|
-
this.limitNumber = undefined;
|
|
43
|
-
this.offsetNumber = undefined;
|
|
44
|
-
this.populateArray = [];
|
|
45
|
-
this.chunk = null;
|
|
46
|
-
this.pullSize = null;
|
|
47
|
-
this.ownerId = undefined;
|
|
48
|
-
this.paginator = undefined;
|
|
49
|
-
this.rawQuery = undefined;
|
|
50
|
-
this.outputKeys = [];
|
|
51
|
-
this.getFirst = false;
|
|
52
|
-
}
|
|
53
|
-
async get() {
|
|
54
|
-
throw new Error('get() method not implemented');
|
|
55
|
-
}
|
|
56
|
-
async insertMany(data) {
|
|
57
|
-
throw new Error('get() method not implemented');
|
|
58
|
-
}
|
|
59
|
-
owner(user) {
|
|
60
|
-
this.chainReference.push({ method: 'owner', args: user });
|
|
61
|
-
this.ownerId = user;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
own(user) {
|
|
65
|
-
return this.owner(user);
|
|
66
|
-
}
|
|
67
|
-
async first() {
|
|
68
|
-
this.limit(1);
|
|
69
|
-
const data = await this.get();
|
|
70
|
-
if (!data[0]) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return data[0];
|
|
74
|
-
}
|
|
75
|
-
async collect() {
|
|
76
|
-
const data = await this.get();
|
|
77
|
-
if (!Array.isArray(data)) {
|
|
78
|
-
throw new Error('Collect method only accepts arrays of data');
|
|
79
|
-
}
|
|
80
|
-
return new js_utils_1.Collection(data);
|
|
81
|
-
}
|
|
82
|
-
select(...columns) {
|
|
83
|
-
columns = this.prepareInput(columns);
|
|
84
|
-
this.chainReference.push({ method: 'select', args: columns });
|
|
85
|
-
this.selectArray = this.selectArray
|
|
86
|
-
.concat(columns)
|
|
87
|
-
.filter((elem, pos, arr) => arr.indexOf(elem) === pos);
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
forceSelect(...columns) {
|
|
91
|
-
if (typeof module === 'undefined' || !module.exports) {
|
|
92
|
-
throw new Error('forceSelect cant be used in frontend');
|
|
93
|
-
}
|
|
94
|
-
columns = this.prepareInput(columns);
|
|
95
|
-
this.chainReference.push({ method: 'forceSelect', args: columns });
|
|
96
|
-
this.forceSelectArray = this.forceSelectArray
|
|
97
|
-
.concat(columns)
|
|
98
|
-
.filter((elem, pos, arr) => arr.indexOf(elem) === pos);
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
offset(offset) {
|
|
102
|
-
this.chainReference.push({ method: 'offset', args: offset });
|
|
103
|
-
this.offsetNumber = offset;
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
populate(...relations) {
|
|
107
|
-
this.chainReference.push({ method: 'relations', args: relations });
|
|
108
|
-
this.populateArray = relations;
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
skip(offset) {
|
|
112
|
-
return this.offset(offset);
|
|
113
|
-
}
|
|
114
|
-
where(path, operator, value) {
|
|
115
|
-
const stringPath = path.toString();
|
|
116
|
-
const chainedWhere = [stringPath, operator, value];
|
|
117
|
-
this.chainReference.push({ method: 'where', chainedWhere });
|
|
118
|
-
this.whereArray = [];
|
|
119
|
-
this.whereArray.push(chainedWhere);
|
|
120
|
-
return this;
|
|
121
|
-
}
|
|
122
|
-
andWhere(path, operator, value) {
|
|
123
|
-
const stringPath = path.toString();
|
|
124
|
-
const chainedWhere = [stringPath, operator, value];
|
|
125
|
-
this.chainReference.push({ method: 'andWhere', chainedWhere });
|
|
126
|
-
this.whereArray.push(chainedWhere);
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
orWhere(path, operator, value) {
|
|
130
|
-
const stringPath = path.toString();
|
|
131
|
-
const chainedWhere = [stringPath, operator, value];
|
|
132
|
-
this.chainReference.push({ method: 'orWhere', chainedWhere });
|
|
133
|
-
this.orWhereArray.push(chainedWhere);
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
limit(limit) {
|
|
137
|
-
this.chainReference.push({ method: 'limit', args: limit });
|
|
138
|
-
this.limitNumber = limit;
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
take(limit) {
|
|
142
|
-
return this.limit(limit);
|
|
143
|
-
}
|
|
144
|
-
async pluck(path) {
|
|
145
|
-
const stringPath = path.toString();
|
|
146
|
-
this.chainReference.push({ method: 'pluck', args: stringPath });
|
|
147
|
-
const data = await this.get();
|
|
148
|
-
const result = data.map(e => {
|
|
149
|
-
const extracted = js_utils_1.Objects.getFromPath(e, String(stringPath), undefined);
|
|
150
|
-
if (typeof extracted.value !== 'undefined') {
|
|
151
|
-
return extracted.value;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
orderBy(path, order = 'desc', orderType = 'string') {
|
|
157
|
-
const stringPath = path.toString();
|
|
158
|
-
const orderB = [stringPath, order, orderType];
|
|
159
|
-
this.chainReference.push({ method: 'orderBy', orderB });
|
|
160
|
-
this.orderByArray = orderB;
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
jsApplySelect(data) {
|
|
164
|
-
const _data = Array.isArray(data) ? [...data] : [data];
|
|
165
|
-
if (this.selectArray.length <= 0 && this.outputKeys.length <= 0) {
|
|
166
|
-
return _data;
|
|
167
|
-
}
|
|
168
|
-
const iterationArray = this.outputKeys.length === 0 && this.selectArray.length > 0
|
|
169
|
-
? this.selectArray
|
|
170
|
-
: [...this.outputKeys, ...this.forceSelectArray];
|
|
171
|
-
const compareArray = this.outputKeys.length === 0 && this.selectArray.length > 0
|
|
172
|
-
? [...this.outputKeys, ...this.forceSelectArray]
|
|
173
|
-
: this.selectArray;
|
|
174
|
-
return _data.map(element => {
|
|
175
|
-
const newElement = {};
|
|
176
|
-
iterationArray.forEach(attribute => {
|
|
177
|
-
if (compareArray.length > 0 && !compareArray.includes(attribute)) {
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
const extract = js_utils_1.Objects.getFromPath(element, attribute, undefined);
|
|
181
|
-
let value = js_utils_1.Objects.get(() => extract.value, undefined);
|
|
182
|
-
if (typeof value !== 'undefined' && value !== null) {
|
|
183
|
-
if (typeof value === 'object' &&
|
|
184
|
-
value.hasOwnProperty('data') &&
|
|
185
|
-
value.data.hasOwnProperty('name')) {
|
|
186
|
-
newElement[extract.label] = value.data.name;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
if (typeof value === 'object' && js_utils_1.Ids.isValidObjectID(value)) {
|
|
190
|
-
value = js_utils_1.Ids.objectIdString(value);
|
|
191
|
-
}
|
|
192
|
-
newElement[extract.label] = value;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
return js_utils_1.Objects.nest(newElement);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
jsApplyOrderBy(data) {
|
|
200
|
-
let _data = [...data];
|
|
201
|
-
if (this.orderByArray.length === 0) {
|
|
202
|
-
return _data;
|
|
203
|
-
}
|
|
204
|
-
const field = this.orderByArray[0];
|
|
205
|
-
if (this.selectArray.length > 0 &&
|
|
206
|
-
(field.includes('.') || field.includes('['))) {
|
|
207
|
-
throw new Error(`Cannot orderBy nested attribute "${field}" when using Select. You must rename the attribute`);
|
|
208
|
-
}
|
|
209
|
-
const order = this.orderByArray[1];
|
|
210
|
-
let type = this.orderByArray[2];
|
|
211
|
-
if (!type) {
|
|
212
|
-
type = 'string';
|
|
213
|
-
}
|
|
214
|
-
_data = _data.sort((a, b) => {
|
|
215
|
-
const A = js_utils_1.Objects.getFromPath(a, field, undefined).value;
|
|
216
|
-
const B = js_utils_1.Objects.getFromPath(b, field, undefined).value;
|
|
217
|
-
if (typeof A === 'undefined' || typeof B === 'undefined') {
|
|
218
|
-
throw new Error(`Cannot order by property "${field}" not all values have this property`);
|
|
219
|
-
}
|
|
220
|
-
if (type.includes('string') || type.includes('number')) {
|
|
221
|
-
if (order === 'asc') {
|
|
222
|
-
return A > B ? 1 : A < B ? -1 : 0;
|
|
223
|
-
}
|
|
224
|
-
return A > B ? -1 : A < B ? 1 : 0;
|
|
225
|
-
}
|
|
226
|
-
if (type.includes('date')) {
|
|
227
|
-
if (order === 'asc') {
|
|
228
|
-
return new Date(A).getTime() - new Date(B).getTime();
|
|
229
|
-
}
|
|
230
|
-
return new Date(B).getTime() - new Date(A).getTime();
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
return _data;
|
|
234
|
-
}
|
|
235
|
-
reset() {
|
|
236
|
-
this.chainReference = [];
|
|
237
|
-
this.whereArray = [];
|
|
238
|
-
this.orWhereArray = [];
|
|
239
|
-
this.selectArray = [];
|
|
240
|
-
this.forceSelectArray = [];
|
|
241
|
-
this.orderByArray = [];
|
|
242
|
-
this.limitNumber = undefined;
|
|
243
|
-
this.offsetNumber = undefined;
|
|
244
|
-
this.populateArray = [];
|
|
245
|
-
this.chunk = null;
|
|
246
|
-
this.pullSize = null;
|
|
247
|
-
this.ownerId = undefined;
|
|
248
|
-
this.paginator = undefined;
|
|
249
|
-
this.rawQuery = undefined;
|
|
250
|
-
this.getFirst = false;
|
|
251
|
-
this.relations = undefined;
|
|
252
|
-
this.loadModels = false;
|
|
253
|
-
this.relationQuery = undefined;
|
|
254
|
-
}
|
|
255
|
-
async load() {
|
|
256
|
-
const result = await this.get();
|
|
257
|
-
this.relationQuery = {
|
|
258
|
-
data: result,
|
|
259
|
-
relations: this.modelRelations
|
|
260
|
-
};
|
|
261
|
-
return this;
|
|
262
|
-
}
|
|
263
|
-
async loadFirst() {
|
|
264
|
-
const result = await this.first();
|
|
265
|
-
this.relationQuery = {
|
|
266
|
-
data: result,
|
|
267
|
-
relations: this.modelRelations
|
|
268
|
-
};
|
|
269
|
-
return this;
|
|
270
|
-
}
|
|
271
|
-
getLoadedData() {
|
|
272
|
-
return this.relationQuery.data;
|
|
273
|
-
}
|
|
274
|
-
with(entities) {
|
|
275
|
-
this.relations = entities;
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
async attach(data) {
|
|
279
|
-
if (!this.relationQuery.relation || !this.relationQuery.data) {
|
|
280
|
-
throw new Error('Attached can only be called as a related model');
|
|
281
|
-
}
|
|
282
|
-
if (this.relationQuery && this.relationQuery.data) {
|
|
283
|
-
const D = Array.isArray(this.relationQuery.data)
|
|
284
|
-
? this.relationQuery.data
|
|
285
|
-
: [this.relationQuery.data];
|
|
286
|
-
const relatedData = D.map(d => ({
|
|
287
|
-
[this.relationQuery.relation.inverseSidePropertyPath]: this.isMongoDB
|
|
288
|
-
? js_utils_1.Ids.objectID(d.id)
|
|
289
|
-
: d.id,
|
|
290
|
-
...data
|
|
291
|
-
}));
|
|
292
|
-
return this.insertMany(relatedData);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
associate(id) {
|
|
296
|
-
if (!this.relationQuery.relation || !this.relationQuery.data) {
|
|
297
|
-
throw new Error('Attached can only be called as a related model');
|
|
298
|
-
}
|
|
299
|
-
if (this.relationQuery && this.relationQuery.data) {
|
|
300
|
-
const D = Array.isArray(this.relationQuery.data)
|
|
301
|
-
? this.relationQuery.data
|
|
302
|
-
: [this.relationQuery.data];
|
|
303
|
-
const relatedData = D.map(d => ({
|
|
304
|
-
[this.relationQuery.relation.joinColumns[0].propertyName]: this
|
|
305
|
-
.isMongoDB
|
|
306
|
-
? js_utils_1.Ids.objectID(d.id)
|
|
307
|
-
: d.id,
|
|
308
|
-
[this.relationQuery.relation.inverseJoinColumns[0].propertyName]: this
|
|
309
|
-
.isMongoDB
|
|
310
|
-
? js_utils_1.Ids.objectID(id)
|
|
311
|
-
: id
|
|
312
|
-
}));
|
|
313
|
-
return this.relationQuery.pivot.insertMany(relatedData);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
hasMany(Repository, relationName) {
|
|
317
|
-
if (this.relationQuery) {
|
|
318
|
-
this.relationQuery.relation = this.relationQuery.relations[relationName];
|
|
319
|
-
}
|
|
320
|
-
const newClass = new Repository(this.relationQuery);
|
|
321
|
-
this.reset();
|
|
322
|
-
return newClass;
|
|
323
|
-
}
|
|
324
|
-
hasOne() {
|
|
325
|
-
throw new Error('Method not implemented');
|
|
326
|
-
}
|
|
327
|
-
belongsTo(Repository, relationName) {
|
|
328
|
-
if (this.relationQuery) {
|
|
329
|
-
this.relationQuery.relation = this.relationQuery.relations[relationName];
|
|
330
|
-
}
|
|
331
|
-
const newClass = new Repository(this.relationQuery);
|
|
332
|
-
this.reset();
|
|
333
|
-
return newClass;
|
|
334
|
-
}
|
|
335
|
-
belongsToMany(Repository, Pivot, relationName) {
|
|
336
|
-
this.relationQuery = !this.relationQuery
|
|
337
|
-
? { pivot: new Pivot(this.relationQuery) }
|
|
338
|
-
: {
|
|
339
|
-
...this.relationQuery,
|
|
340
|
-
...{
|
|
341
|
-
pivot: new Pivot(this.relationQuery),
|
|
342
|
-
relation: this.relationQuery.relations[relationName]
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
const newClass = new Repository(this.relationQuery);
|
|
346
|
-
this.reset();
|
|
347
|
-
return newClass;
|
|
348
|
-
}
|
|
349
|
-
hasManyThrough() {
|
|
350
|
-
throw new Error('Method not implemented');
|
|
351
|
-
}
|
|
352
|
-
prepareInput(columns) {
|
|
353
|
-
let cols = [];
|
|
354
|
-
columns.forEach(col => {
|
|
355
|
-
cols = cols.concat(col.toString().trim());
|
|
356
|
-
});
|
|
357
|
-
cols.filter((elem, pos, arr) => arr.indexOf(elem) === pos);
|
|
358
|
-
return cols;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
exports.BaseConnector = BaseConnector;
|
package/dist/Fluent.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm';
|
|
2
|
-
import { BaseDataElement, Primitives } from './types';
|
|
3
|
-
import { Collection } from '@goatlab/js-utils';
|
|
4
|
-
interface _FLUENT_ {
|
|
5
|
-
models?: {
|
|
6
|
-
[key: string]: boolean;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
declare global {
|
|
10
|
-
interface Window {
|
|
11
|
-
_FLUENT_: _FLUENT_;
|
|
12
|
-
}
|
|
13
|
-
namespace NodeJS {
|
|
14
|
-
interface Global {
|
|
15
|
-
_FLUENT_: _FLUENT_;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export declare class Fluent {
|
|
20
|
-
private static registerModel;
|
|
21
|
-
static model<T = BaseDataElement>(name: string): any;
|
|
22
|
-
static collect<T = BaseDataElement | Primitives>(data: T[]): Collection<T>;
|
|
23
|
-
static getConfig(): _FLUENT_;
|
|
24
|
-
static models(Entities: any[]): Promise<DataSource>;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
package/dist/Fluent.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Fluent = void 0;
|
|
4
|
-
const typed_path_1 = require("typed-path");
|
|
5
|
-
const js_utils_1 = require("@goatlab/js-utils");
|
|
6
|
-
const generatorDatasource_1 = require("./generatorDatasource");
|
|
7
|
-
if (typeof window !== 'undefined' && window && !window._FLUENT_) {
|
|
8
|
-
window._FLUENT_ = {
|
|
9
|
-
models: {}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
if (global && !global._FLUENT_) {
|
|
13
|
-
global._FLUENT_ = {
|
|
14
|
-
models: {}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
class Fluent {
|
|
18
|
-
static registerModel(name) {
|
|
19
|
-
if (!name || name === 'baseModel') {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (typeof window !== 'undefined') {
|
|
23
|
-
window._FLUENT_.models[name] = true;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
global._FLUENT_.models[name] = true;
|
|
27
|
-
}
|
|
28
|
-
static model(name) {
|
|
29
|
-
this.registerModel(name);
|
|
30
|
-
return (0, typed_path_1.typedPath)();
|
|
31
|
-
}
|
|
32
|
-
static collect(data) {
|
|
33
|
-
return new js_utils_1.Collection(data);
|
|
34
|
-
}
|
|
35
|
-
static getConfig() {
|
|
36
|
-
if (typeof window !== 'undefined' && window) {
|
|
37
|
-
return window._FLUENT_;
|
|
38
|
-
}
|
|
39
|
-
if (typeof global !== 'undefined' && global) {
|
|
40
|
-
return global._FLUENT_;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
static async models(Entities) {
|
|
44
|
-
generatorDatasource_1.modelGeneratorDataSource.setOptions({ entities: Entities });
|
|
45
|
-
if (generatorDatasource_1.modelGeneratorDataSource.isInitialized) {
|
|
46
|
-
return generatorDatasource_1.modelGeneratorDataSource;
|
|
47
|
-
}
|
|
48
|
-
await generatorDatasource_1.modelGeneratorDataSource.initialize();
|
|
49
|
-
return generatorDatasource_1.modelGeneratorDataSource;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.Fluent = Fluent;
|