@rockster/core 0.0.2 → 0.0.4
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/access/access.module.d.ts +11 -0
- package/access/access.module.js +60 -0
- package/access/access.module.js.map +1 -0
- package/access/controllers/controllers.d.ts +6 -0
- package/access/controllers/controllers.js +16 -0
- package/access/controllers/controllers.js.map +1 -0
- package/access/controllers/scope-group-user.controller.d.ts +13 -0
- package/access/controllers/scope-group-user.controller.js +84 -0
- package/access/controllers/scope-group-user.controller.js.map +1 -0
- package/access/controllers/scope-group.controller.d.ts +19 -0
- package/access/controllers/scope-group.controller.js +123 -0
- package/access/controllers/scope-group.controller.js.map +1 -0
- package/access/controllers/scope-key.controller.d.ts +7 -0
- package/access/controllers/scope-key.controller.js +45 -0
- package/access/controllers/scope-key.controller.js.map +1 -0
- package/access/controllers/scope-owner.controller.d.ts +8 -0
- package/access/controllers/scope-owner.controller.js +66 -0
- package/access/controllers/scope-owner.controller.js.map +1 -0
- package/access/controllers/scope-user.controller.d.ts +14 -0
- package/access/controllers/scope-user.controller.js +95 -0
- package/access/controllers/scope-user.controller.js.map +1 -0
- package/access/entities/entities.d.ts +6 -0
- package/access/entities/entities.js +18 -0
- package/access/entities/entities.js.map +1 -0
- package/access/entities/index.d.ts +5 -0
- package/access/entities/index.js +22 -0
- package/access/entities/index.js.map +1 -0
- package/access/entities/scope-access.d.ts +9 -0
- package/access/entities/scope-access.js +58 -0
- package/access/entities/scope-access.js.map +1 -0
- package/access/entities/scope-group-user.d.ts +7 -0
- package/access/entities/scope-group-user.js +47 -0
- package/access/entities/scope-group-user.js.map +1 -0
- package/access/entities/scope-group.d.ts +9 -0
- package/access/entities/scope-group.js +56 -0
- package/access/entities/scope-group.js.map +1 -0
- package/access/entities/scope-key.d.ts +5 -0
- package/access/entities/scope-key.js +35 -0
- package/access/entities/scope-key.js.map +1 -0
- package/access/entities/scope-owner.d.ts +7 -0
- package/access/entities/scope-owner.js +45 -0
- package/access/entities/scope-owner.js.map +1 -0
- package/access/env.d.ts +10 -0
- package/access/env.js +10 -0
- package/access/env.js.map +1 -0
- package/access/functions/get-context-id-service.d.ts +1 -0
- package/access/functions/get-context-id-service.js +8 -0
- package/access/functions/get-context-id-service.js.map +1 -0
- package/access/functions/get-is-owner.d.ts +1 -0
- package/access/functions/get-is-owner.js +8 -0
- package/access/functions/get-is-owner.js.map +1 -0
- package/access/functions/get-user-keys.d.ts +2 -0
- package/access/functions/get-user-keys.js +10 -0
- package/access/functions/get-user-keys.js.map +1 -0
- package/access/functions/index.d.ts +3 -0
- package/access/functions/index.js +20 -0
- package/access/functions/index.js.map +1 -0
- package/access/functions/register-scope.d.ts +8 -0
- package/access/functions/register-scope.js +82 -0
- package/access/functions/register-scope.js.map +1 -0
- package/access/index.d.ts +5 -0
- package/access/index.js +22 -0
- package/access/index.js.map +1 -0
- package/access/interfaces/index.d.ts +2 -0
- package/access/interfaces/index.js +19 -0
- package/access/interfaces/index.js.map +1 -0
- package/access/interfaces/scope-service-registry.d.ts +6 -0
- package/access/interfaces/scope-service-registry.js +3 -0
- package/access/interfaces/scope-service-registry.js.map +1 -0
- package/access/interfaces/scope-service.d.ts +12 -0
- package/access/interfaces/scope-service.js +3 -0
- package/access/interfaces/scope-service.js.map +1 -0
- package/access/models/scope-context.d.ts +4 -0
- package/access/models/scope-context.js +27 -0
- package/access/models/scope-context.js.map +1 -0
- package/access/models/scope-keys-update.d.ts +7 -0
- package/access/models/scope-keys-update.js +38 -0
- package/access/models/scope-keys-update.js.map +1 -0
- package/access/models/scope-owner.d.ts +5 -0
- package/access/models/scope-owner.js +32 -0
- package/access/models/scope-owner.js.map +1 -0
- package/access/models/scope-user-mapped.d.ts +8 -0
- package/access/models/scope-user-mapped.js +42 -0
- package/access/models/scope-user-mapped.js.map +1 -0
- package/access/models/scope-user.d.ts +9 -0
- package/access/models/scope-user.js +49 -0
- package/access/models/scope-user.js.map +1 -0
- package/access/queries/scope-group-user.query.d.ts +1 -0
- package/access/queries/scope-group-user.query.js +26 -0
- package/access/queries/scope-group-user.query.js.map +1 -0
- package/access/queries/scope-group.query.d.ts +1 -0
- package/access/queries/scope-group.query.js +12 -0
- package/access/queries/scope-group.query.js.map +1 -0
- package/access/services/index.d.ts +6 -0
- package/access/services/index.js +23 -0
- package/access/services/index.js.map +1 -0
- package/access/services/scope-access.service.d.ts +11 -0
- package/access/services/scope-access.service.js +87 -0
- package/access/services/scope-access.service.js.map +1 -0
- package/access/services/scope-group-user.service.d.ts +8 -0
- package/access/services/scope-group-user.service.js +49 -0
- package/access/services/scope-group-user.service.js.map +1 -0
- package/access/services/scope-group.service.d.ts +7 -0
- package/access/services/scope-group.service.js +38 -0
- package/access/services/scope-group.service.js.map +1 -0
- package/access/services/scope-key.service.d.ts +9 -0
- package/access/services/scope-key.service.js +52 -0
- package/access/services/scope-key.service.js.map +1 -0
- package/access/services/scope-owner.service.d.ts +7 -0
- package/access/services/scope-owner.service.js +35 -0
- package/access/services/scope-owner.service.js.map +1 -0
- package/access/services/scope-service.d.ts +10 -0
- package/access/services/scope-service.js +52 -0
- package/access/services/scope-service.js.map +1 -0
- package/command/functions/execute-post.js +5 -7
- package/command/functions/execute-post.js.map +1 -1
- package/command/services/post-action-builder.js +2 -0
- package/command/services/post-action-builder.js.map +1 -1
- package/command/services/remove-action-builder.js +2 -0
- package/command/services/remove-action-builder.js.map +1 -1
- package/common/entities/base-entity.js +2 -0
- package/common/entities/base-entity.js.map +1 -1
- package/common/interfaces/enum/object-type.d.ts +2 -1
- package/common/interfaces/enum/object-type.js +1 -0
- package/common/interfaces/enum/object-type.js.map +1 -1
- package/controllers/constants/controller-transaction.d.ts +2 -0
- package/controllers/constants/controller-transaction.js +6 -0
- package/controllers/constants/controller-transaction.js.map +1 -0
- package/controllers/controller.controller.d.ts +1 -1
- package/controllers/controller.controller.js +4 -4
- package/controllers/controller.controller.js.map +1 -1
- package/controllers/decorators/controller.decorator.js +8 -0
- package/controllers/decorators/controller.decorator.js.map +1 -1
- package/controllers/decorators/index.d.ts +1 -0
- package/controllers/decorators/index.js +1 -0
- package/controllers/decorators/index.js.map +1 -1
- package/controllers/decorators/transaction.decorator.d.ts +7 -0
- package/controllers/decorators/transaction.decorator.js +23 -0
- package/controllers/decorators/transaction.decorator.js.map +1 -0
- package/controllers/interfaces/controller-object.d.ts +1 -0
- package/controllers/interfaces/controller-options.d.ts +1 -0
- package/controllers/interfaces/controller-property.d.ts +3 -0
- package/controllers/services/default-action-builder.js +32 -0
- package/controllers/services/default-action-builder.js.map +1 -1
- package/core/core.controller.d.ts +1 -0
- package/core/core.controller.js +9 -1
- package/core/core.controller.js.map +1 -1
- package/core/functions/create-interceptor.js +2 -2
- package/core/functions/create-interceptor.js.map +1 -1
- package/core/functions/resolve-action-transactional.d.ts +3 -0
- package/core/functions/resolve-action-transactional.js +10 -0
- package/core/functions/resolve-action-transactional.js.map +1 -0
- package/core/interfaces/action-def.d.ts +2 -5
- package/core/interfaces/action-handle.d.ts +5 -0
- package/core/interfaces/action-handle.js +3 -0
- package/core/interfaces/action-handle.js.map +1 -0
- package/core/interfaces/core-options.d.ts +1 -0
- package/core/interfaces/interceptor.d.ts +1 -1
- package/core/interfaces/object.d.ts +3 -2
- package/core/interfaces/request-context.d.ts +2 -2
- package/core/services/request-executor.d.ts +8 -0
- package/core/services/request-executor.js +88 -0
- package/core/services/request-executor.js.map +1 -1
- package/core/services/request-router.js +3 -3
- package/core/services/request-router.js.map +1 -1
- package/database/decorators/entity.decorator.d.ts +3 -1
- package/database/decorators/entity.decorator.js +14 -5
- package/database/decorators/entity.decorator.js.map +1 -1
- package/database/decorators/external-column.decorator.d.ts +17 -0
- package/database/decorators/external-column.decorator.js +30 -0
- package/database/decorators/external-column.decorator.js.map +1 -0
- package/database/decorators/index.d.ts +1 -0
- package/database/decorators/index.js +1 -0
- package/database/decorators/index.js.map +1 -1
- package/database/decorators/relation.decorator.d.ts +2 -2
- package/database/decorators/relation.decorator.js.map +1 -1
- package/database/extensions/select-query-builder.d.ts +1 -5
- package/database/extensions/select-query-builder.js.map +1 -1
- package/database/functions/find-relation.d.ts +2 -1
- package/database/functions/find-relation.js +3 -3
- package/database/functions/find-relation.js.map +1 -1
- package/database/functions/generate-entity-id.d.ts +2 -0
- package/database/functions/{generate-id.js → generate-entity-id.js} +3 -3
- package/database/functions/generate-entity-id.js.map +1 -0
- package/database/functions/get-relations.d.ts +1 -1
- package/database/functions/use-protector.js +1 -1
- package/database/functions/use-protector.js.map +1 -1
- package/database/functions/use-transaction.d.ts +1 -0
- package/database/functions/use-transaction.js +2 -6
- package/database/functions/use-transaction.js.map +1 -1
- package/database/interfaces/entity-dto-object.d.ts +7 -0
- package/database/interfaces/entity-dto-object.js +3 -0
- package/database/interfaces/entity-dto-object.js.map +1 -0
- package/database/interfaces/entity-property.d.ts +12 -0
- package/database/interfaces/path.d.ts +6 -2
- package/database/interfaces/virtual-select.d.ts +4 -0
- package/database/interfaces/virtual-select.js +3 -0
- package/database/interfaces/virtual-select.js.map +1 -0
- package/database/services/protect-builder.d.ts +3 -2
- package/database/services/protect-builder.js +2 -2
- package/database/services/protect-builder.js.map +1 -1
- package/database/services/repository.service.d.ts +1 -1
- package/database/services/repository.service.js +3 -6
- package/database/services/repository.service.js.map +1 -1
- package/docs/queries/docs-controller-action.query.d.ts +1 -1
- package/docs/queries/docs-controller.query.d.ts +1 -1
- package/docs/queries/docs-model.query.d.ts +1 -1
- package/docs/queries/docs-model.query.js +1 -1
- package/docs/queries/docs-model.query.js.map +1 -1
- package/docs/queries/docs-version.query.d.ts +1 -1
- package/docs/services/docs-version.service.js +6 -3
- package/docs/services/docs-version.service.js.map +1 -1
- package/forms/queries/form.query.d.ts +1 -1
- package/forms/queries/property.query.d.ts +1 -1
- package/global.js +1 -1
- package/global.js.map +1 -1
- package/http/http.controller.d.ts +2 -0
- package/http/http.controller.js +3 -2
- package/http/http.controller.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +2 -6
- package/index.js.map +1 -1
- package/jobs/jobs.controller.js +2 -0
- package/jobs/jobs.controller.js.map +1 -1
- package/package.json +7 -6
- package/query/functions/add-join.js +8 -5
- package/query/functions/add-join.js.map +1 -1
- package/query/functions/collect-external-column-owners.d.ts +10 -0
- package/query/functions/collect-external-column-owners.js +100 -0
- package/query/functions/collect-external-column-owners.js.map +1 -0
- package/query/functions/create-query-builder.js +47 -18
- package/query/functions/create-query-builder.js.map +1 -1
- package/query/functions/create-query-cache-hash.d.ts +16 -0
- package/query/functions/create-query-cache-hash.js +70 -0
- package/query/functions/create-query-cache-hash.js.map +1 -0
- package/query/functions/create-query.d.ts +8 -3
- package/query/functions/create-query.js +12 -9
- package/query/functions/create-query.js.map +1 -1
- package/query/functions/describe-query-filter.js +3 -2
- package/query/functions/describe-query-filter.js.map +1 -1
- package/query/functions/execute-query.js +55 -9
- package/query/functions/execute-query.js.map +1 -1
- package/query/functions/expand-select-with-external-dependencies.d.ts +9 -0
- package/query/functions/expand-select-with-external-dependencies.js +34 -0
- package/query/functions/expand-select-with-external-dependencies.js.map +1 -0
- package/query/functions/external-column-owner-path.d.ts +5 -0
- package/query/functions/external-column-owner-path.js +18 -0
- package/query/functions/external-column-owner-path.js.map +1 -0
- package/query/functions/get-entity-object-class.d.ts +2 -0
- package/query/functions/get-entity-object-class.js +12 -0
- package/query/functions/get-entity-object-class.js.map +1 -0
- package/query/functions/get-native-select.js +3 -0
- package/query/functions/get-native-select.js.map +1 -1
- package/query/functions/load-properties.d.ts +20 -2
- package/query/functions/load-properties.js +119 -37
- package/query/functions/load-properties.js.map +1 -1
- package/query/functions/map-query-property-to-column-name.js +1 -1
- package/query/functions/map-query-property-to-column-name.js.map +1 -1
- package/query/functions/query-structure-cache.d.ts +24 -0
- package/query/functions/query-structure-cache.js +66 -0
- package/query/functions/query-structure-cache.js.map +1 -0
- package/query/interfaces/query.d.ts +44 -1
- package/query/services/query-action-builder.d.ts +4 -1
- package/query/services/query-action-builder.js +32 -12
- package/query/services/query-action-builder.js.map +1 -1
- package/security/env.js.map +1 -1
- package/security/requests/security.request.js +1 -1
- package/security/requests/security.request.js.map +1 -1
- package/tasks/decorators/task.decorator.js +3 -2
- package/tasks/decorators/task.decorator.js.map +1 -1
- package/tasks/functions/{create-task-message-receptor.d.ts → create-task-message-post.d.ts} +1 -1
- package/tasks/functions/{create-task-message-receptor.js → create-task-message-post.js} +8 -3
- package/tasks/functions/create-task-message-post.js.map +1 -0
- package/tasks/interfaces/task-object.d.ts +2 -2
- package/tasks/interfaces/task-post-intercept.d.ts +1 -8
- package/tasks/interfaces/task-runner.d.ts +2 -1
- package/tasks/interfaces/task-settings.d.ts +2 -0
- package/tasks/services/task-runner.service.js +5 -3
- package/tasks/services/task-runner.service.js.map +1 -1
- package/translations/controllers/translation.controller.js +12 -9
- package/translations/controllers/translation.controller.js.map +1 -1
- package/translations/functions/create-translation-values.js +2 -5
- package/translations/functions/create-translation-values.js.map +1 -1
- package/translations/migrations/1723760669185-CreateTranslationTables.js +3 -3
- package/translations/migrations/1723760669185-CreateTranslationTables.js.map +1 -1
- package/translations/queries/translation-config.query.d.ts +1 -1
- package/translations/queries/translation-values.query.d.ts +1 -1
- package/translations/queries/translation-values.query.js +1 -1
- package/translations/queries/translation-values.query.js.map +1 -1
- package/translations/translations.controller.d.ts +1 -1
- package/translations/translations.controller.js +4 -4
- package/translations/translations.controller.js.map +1 -1
- package/database/functions/generate-id.d.ts +0 -2
- package/database/functions/generate-id.js.map +0 -1
- package/tasks/functions/create-task-message-receptor.js.map +0 -1
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeQuery = void 0;
|
|
4
|
+
const class_injector_1 = require("@rockster/class-injector");
|
|
4
5
|
const create_query_builder_1 = require("./create-query-builder");
|
|
5
6
|
const class_pipe_1 = require("@rockster/class-pipe");
|
|
6
7
|
const logger_1 = require("@rockster/logger");
|
|
7
8
|
const global_1 = require("../../global");
|
|
9
|
+
const collect_external_column_owners_1 = require("./collect-external-column-owners");
|
|
10
|
+
const expand_select_with_external_dependencies_1 = require("./expand-select-with-external-dependencies");
|
|
8
11
|
const executeQuery = async ({ content: queryContent, intercept, preFilter }) => {
|
|
9
12
|
const logger = new logger_1.Logger('ExecuteQuery');
|
|
10
13
|
const query = queryContent.query;
|
|
11
|
-
const
|
|
14
|
+
const object = core
|
|
15
|
+
.storage
|
|
16
|
+
.findObject(queryContent.target);
|
|
17
|
+
const effectiveSelect = (0, expand_select_with_external_dependencies_1.expandSelectWithExternalDependencies)(object.properties, query.select, logger);
|
|
18
|
+
const queryForBuilder = {
|
|
19
|
+
...queryContent,
|
|
20
|
+
query: { ...queryContent.query, select: effectiveSelect },
|
|
21
|
+
};
|
|
22
|
+
const queryBuilder = await (0, create_query_builder_1.createQueryBuilder)(queryForBuilder, intercept);
|
|
12
23
|
let page = queryContent.query.page;
|
|
13
24
|
let getWhere = 'where';
|
|
14
25
|
let filtered = 0;
|
|
15
26
|
let total;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
if (queryBuilder.expressionMap.wheres.length > 0) {
|
|
28
|
+
getWhere = 'andWhere';
|
|
29
|
+
}
|
|
19
30
|
if (preFilter) {
|
|
20
|
-
queryBuilder
|
|
31
|
+
queryBuilder[getWhere](preFilter);
|
|
21
32
|
getWhere = 'andWhere';
|
|
22
33
|
}
|
|
23
34
|
if (page) {
|
|
@@ -32,21 +43,56 @@ const executeQuery = async ({ content: queryContent, intercept, preFilter }) =>
|
|
|
32
43
|
if (query.orderBy) {
|
|
33
44
|
query.orderBy.forEach((orderBy, i) => {
|
|
34
45
|
const direction = orderBy.direction.toUpperCase();
|
|
35
|
-
|
|
46
|
+
const nativeField = queryForBuilder.nativeSelectAsMap.get(orderBy.property);
|
|
47
|
+
queryBuilder.addOrderBy(nativeField, direction);
|
|
36
48
|
});
|
|
37
49
|
}
|
|
38
|
-
queryBuilder.select(
|
|
50
|
+
queryBuilder.select(queryForBuilder.nativeSelectAsArry);
|
|
39
51
|
queryBuilder.getVirtualSelect().forEach((virtualSelect) => {
|
|
40
52
|
queryBuilder.addSelect(virtualSelect.selection, virtualSelect.alias);
|
|
41
53
|
});
|
|
42
54
|
logger.debug(queryBuilder.getSql());
|
|
43
|
-
|
|
55
|
+
let items = await queryBuilder.getMany();
|
|
56
|
+
const externalSelectPaths = query.select.filter((path) => object.properties[path]?.isExternal);
|
|
57
|
+
if (externalSelectPaths.length > 0) {
|
|
58
|
+
const pathsByResolver = new Map();
|
|
59
|
+
for (const path of externalSelectPaths) {
|
|
60
|
+
const ResolverClass = object.properties[path]
|
|
61
|
+
?.externalResolver;
|
|
62
|
+
if (!ResolverClass) {
|
|
63
|
+
logger.warn(`External column "${path}" has no resolver; set @ExternalColumn(() => YourResolverClass) on the entity property.`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const list = pathsByResolver.get(ResolverClass) ?? [];
|
|
67
|
+
list.push(path);
|
|
68
|
+
pathsByResolver.set(ResolverClass, list);
|
|
69
|
+
}
|
|
70
|
+
for (const [ResolverClass, pathsForResolver] of pathsByResolver) {
|
|
71
|
+
const owners = (0, collect_external_column_owners_1.collectExternalColumnOwners)(items, pathsForResolver, queryForBuilder.rootAlias ?? "", object.properties);
|
|
72
|
+
if (owners.length === 0) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const instance = await (0, class_injector_1.createInstance)(ResolverClass);
|
|
76
|
+
if (typeof instance?.resolve !== "function") {
|
|
77
|
+
logger.warn(`${ResolverClass.name} must implement resolve(payload, context) for external columns.`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const resolvedRoots = await instance.resolve({
|
|
81
|
+
roots: items,
|
|
82
|
+
externalSelectPaths: pathsForResolver,
|
|
83
|
+
owners,
|
|
84
|
+
}, queryContent);
|
|
85
|
+
if (Array.isArray(resolvedRoots)) {
|
|
86
|
+
items = resolvedRoots;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
44
90
|
const data = await Promise.all(items.map((item) => {
|
|
45
91
|
return (0, class_pipe_1.transform)({
|
|
46
92
|
target: object.rootPath.target(),
|
|
47
93
|
values: item,
|
|
48
94
|
select: query.select,
|
|
49
|
-
fullPath: `${
|
|
95
|
+
fullPath: `${queryForBuilder.rootAlias}.`,
|
|
50
96
|
groups: [global_1.actionGroups.query]
|
|
51
97
|
});
|
|
52
98
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-query.js","sourceRoot":"./","sources":["query/functions/execute-query.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;
|
|
1
|
+
{"version":3,"file":"execute-query.js","sourceRoot":"./","sources":["query/functions/execute-query.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE1D,iEAA4D;AAG5D,qDAAiD;AACjD,6CAA0C;AAQ1C,yCAA4C;AAC5C,qFAA+E;AAC/E,yGAAkG;AAY3F,MAAM,YAAY,GAAG,KAAK,EAAU,EACxC,OAAO,EAAE,YAAY,EACrB,SAAS,EACT,SAAS,EACkB,EAAE,EAAE;IAE/B,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,cAAc,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI;SACf,OAAO;SACP,UAAU,CAAC,YAAY,CAAC,MAAM,CACP,CAAC;IAC5B,MAAM,eAAe,GAAG,IAAA,+EAAoC,EACzD,MAAM,CAAC,UAAU,EACjB,KAAK,CAAC,MAAM,EACZ,MAAM,CACR,CAAC;IACF,MAAM,eAAe,GAA0B;QAC5C,GAAG,YAAY;QACf,KAAK,EAAE,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE;KAC3D,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,yCAAkB,EAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAE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CAAC,KAAK;YACP,CAAC,CAAC,SAAS;QACd,QAAQ,EAAE,KAAK,CAAC,MAAM;YACnB,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,SAAS;QACd,IAAI,EAAE,IAAI;KACK,CAAC;AACtB,CAAC,CAAA;AAvJY,QAAA,YAAY,gBAuJxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Dictionary } from "@rockster/common";
|
|
2
|
+
import type { Logger } from "@rockster/logger";
|
|
3
|
+
import type { QueryProperty } from "../interfaces/query";
|
|
4
|
+
/**
|
|
5
|
+
* Adds DB query paths listed on external columns' `externalDependencyQueryPaths` when those paths are selected.
|
|
6
|
+
* Runs to a fixpoint so chained requirements are included. Used only for SQL/joins; keep the original
|
|
7
|
+
* `query.select` for `transform` so dependency fields are not exposed unless the client asked for them.
|
|
8
|
+
*/
|
|
9
|
+
export declare function expandSelectWithExternalDependencies(properties: Dictionary<QueryProperty>, select: string[], logger?: Logger): string[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expandSelectWithExternalDependencies = expandSelectWithExternalDependencies;
|
|
4
|
+
/**
|
|
5
|
+
* Adds DB query paths listed on external columns' `externalDependencyQueryPaths` when those paths are selected.
|
|
6
|
+
* Runs to a fixpoint so chained requirements are included. Used only for SQL/joins; keep the original
|
|
7
|
+
* `query.select` for `transform` so dependency fields are not exposed unless the client asked for them.
|
|
8
|
+
*/
|
|
9
|
+
function expandSelectWithExternalDependencies(properties, select, logger) {
|
|
10
|
+
const set = new Set(select);
|
|
11
|
+
let changed = true;
|
|
12
|
+
while (changed) {
|
|
13
|
+
changed = false;
|
|
14
|
+
for (const path of [...set]) {
|
|
15
|
+
const deps = properties[path]?.externalDependencyQueryPaths;
|
|
16
|
+
if (!deps?.length) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
for (const dep of deps) {
|
|
20
|
+
if (set.has(dep)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (!properties[dep]) {
|
|
24
|
+
logger?.warn(`External column dependency "${dep}" (for selected "${path}") is not a registered query path`);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
set.add(dep);
|
|
28
|
+
changed = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return [...set];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=expand-select-with-external-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand-select-with-external-dependencies.js","sourceRoot":"./","sources":["query/functions/expand-select-with-external-dependencies.ts"],"names":[],"mappings":";;AASA,oFA8BC;AAnCD;;;;GAIG;AACH,SAAgB,oCAAoC,CACjD,UAAqC,EACrC,MAAgB,EAChB,MAAe;IAEf,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OAAO,OAAO,EAAE,CAAC;QACd,OAAO,GAAG,KAAK,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,4BAA4B,CAAC;YAC5D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;gBACjB,SAAS;YACZ,CAAC;YACD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACtB,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChB,SAAS;gBACZ,CAAC;gBACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpB,MAAM,EAAE,IAAI,CACT,+BAA+B,GAAG,oBAAoB,IAAI,mCAAmC,CAC/F,CAAC;oBACF,SAAS;gBACZ,CAAC;gBACD,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;YAClB,CAAC;QACJ,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segments to walk from each root query row to the object that owns an external column.
|
|
3
|
+
* Empty when the owner is the root entity row (e.g. root-level `status`).
|
|
4
|
+
*/
|
|
5
|
+
export declare function toExternalOwnerWalkSegments(ownerFullPath: string, rootAlias: string): string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toExternalOwnerWalkSegments = toExternalOwnerWalkSegments;
|
|
4
|
+
/**
|
|
5
|
+
* Segments to walk from each root query row to the object that owns an external column.
|
|
6
|
+
* Empty when the owner is the root entity row (e.g. root-level `status`).
|
|
7
|
+
*/
|
|
8
|
+
function toExternalOwnerWalkSegments(ownerFullPath, rootAlias) {
|
|
9
|
+
if (ownerFullPath === rootAlias) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const prefix = `${rootAlias}.`;
|
|
13
|
+
if (ownerFullPath.startsWith(prefix)) {
|
|
14
|
+
return ownerFullPath.slice(prefix.length).split(".").filter(Boolean);
|
|
15
|
+
}
|
|
16
|
+
return ownerFullPath.split(".").filter(Boolean);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=external-column-owner-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-column-owner-path.js","sourceRoot":"./","sources":["query/functions/external-column-owner-path.ts"],"names":[],"mappings":";;AAIA,kEAYC;AAhBD;;;GAGG;AACH,SAAgB,2BAA2B,CACxC,aAAqB,EACrB,SAAiB;IAEjB,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACb,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,SAAS,GAAG,CAAC;IAC/B,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntityObjectClass = void 0;
|
|
4
|
+
const object_type_1 = require("../../common/interfaces/enum/object-type");
|
|
5
|
+
const getEntityObjectClass = (target) => {
|
|
6
|
+
const object = core.storage.findObject(target);
|
|
7
|
+
return object?.type === object_type_1.ObjectType.entityDto
|
|
8
|
+
? object.entity()
|
|
9
|
+
: object?.objectClass;
|
|
10
|
+
};
|
|
11
|
+
exports.getEntityObjectClass = getEntityObjectClass;
|
|
12
|
+
//# sourceMappingURL=get-entity-object-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entity-object-class.js","sourceRoot":"./","sources":["query/functions/get-entity-object-class.ts"],"names":[],"mappings":";;;AACA,0EAAsE;AAE/D,MAAM,oBAAoB,GAAG,CAAC,MAAoB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,MAAM,EAAE,IAAI,KAAK,wBAAU,CAAC,SAAS;QACzC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;QACjB,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC;AAC5B,CAAC,CAAA;AALY,QAAA,oBAAoB,wBAKhC"}
|
|
@@ -7,6 +7,9 @@ const getNativeSelect = (target, select) => {
|
|
|
7
7
|
const mapper = new Map();
|
|
8
8
|
const arry = [];
|
|
9
9
|
select.forEach(item => {
|
|
10
|
+
const queryProperty = queryObject.properties[item];
|
|
11
|
+
if (queryProperty?.isExternal)
|
|
12
|
+
return;
|
|
10
13
|
const columnName = (0, map_query_property_to_column_name_1.mapQueryPropertyToColumnName)(queryObject, item);
|
|
11
14
|
arry.pushIfNotExists(columnName);
|
|
12
15
|
mapper.set(item, columnName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-native-select.js","sourceRoot":"./","sources":["query/functions/get-native-select.ts"],"names":[],"mappings":";;;AAGA,2FAAmF;AAE5E,MAAM,eAAe,GAAG,CAC5B,MAAoB,EACpB,MAAgB,EACjB,EAAE;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAA6B,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,IAAI,GAAG,EAAc,CAAC;IAC5B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,UAAU,GAAG,IAAA,gEAA4B,EAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"get-native-select.js","sourceRoot":"./","sources":["query/functions/get-native-select.ts"],"names":[],"mappings":";;;AAGA,2FAAmF;AAE5E,MAAM,eAAe,GAAG,CAC5B,MAAoB,EACpB,MAAgB,EACjB,EAAE;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAA6B,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,IAAI,GAAG,EAAc,CAAC;IAC5B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,aAAa,EAAE,UAAU;YAAE,OAAO;QACtC,MAAM,UAAU,GAAG,IAAA,gEAA4B,EAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC,CAAA;AAfY,QAAA,eAAe,mBAe3B"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Dictionary, Instantiable } from "@rockster/common";
|
|
2
2
|
import { Paths } from "../../database/interfaces/path";
|
|
3
3
|
import { QueryPath, QueryProperty, QueryPropertyType, QueryRelationConfig } from "../interfaces/query";
|
|
4
|
+
/** When traversing an object/relation property marked @ExternalColumn, descendants inherit its resolver. */
|
|
5
|
+
export type ExternalSubtreeContext = {
|
|
6
|
+
resolver: Instantiable;
|
|
7
|
+
/** Full query path to the entity row that owns `columnKey`. */
|
|
8
|
+
ownerFullPath: string;
|
|
9
|
+
columnKey: string;
|
|
10
|
+
/** Full query paths for DB columns required alongside this external column (selectDependencies). */
|
|
11
|
+
dependencyQueryPaths: string[];
|
|
12
|
+
};
|
|
4
13
|
export type LoadPropertiesArgs = {
|
|
5
14
|
type: QueryPropertyType;
|
|
6
15
|
target: Instantiable;
|
|
@@ -14,6 +23,15 @@ export type LoadPropertiesArgs = {
|
|
|
14
23
|
secure?: boolean;
|
|
15
24
|
initializedObjects?: string[];
|
|
16
25
|
rootEntity: Instantiable;
|
|
17
|
-
|
|
26
|
+
rootOrRelationPath?: string;
|
|
27
|
+
isRelation?: boolean;
|
|
28
|
+
/** Root query alias (first path segment); used for external owner walk segments. */
|
|
29
|
+
rootAlias: string;
|
|
30
|
+
externalSubtree?: ExternalSubtreeContext;
|
|
31
|
+
/**
|
|
32
|
+
* SQL table aliases used by {@link joinOne}/{@link joinMany} across the whole query tree.
|
|
33
|
+
* Root initializes this (includes the root alias); duplicate join `alias` values throw.
|
|
34
|
+
*/
|
|
35
|
+
usedJoinSqlAliases?: Set<string>;
|
|
18
36
|
};
|
|
19
|
-
export declare const loadProperties: ({ type, target, alias, entityAlias, properties, parent, paths, relation, fullPath, secure, initializedObjects, rootEntity,
|
|
37
|
+
export declare const loadProperties: ({ type, target, alias, entityAlias, properties, parent, paths, relation, fullPath, secure, initializedObjects, rootEntity, rootOrRelationPath, rootAlias, externalSubtree, usedJoinSqlAliases: usedJoinSqlAliasesArg }: LoadPropertiesArgs) => void;
|
|
@@ -4,44 +4,83 @@ exports.loadProperties = void 0;
|
|
|
4
4
|
const class_pipe_1 = require("@rockster/class-pipe");
|
|
5
5
|
const object_type_1 = require("../../common/interfaces/enum/object-type");
|
|
6
6
|
const get_id_property_1 = require("../../database/functions/get-id-property");
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const get_entity_object_class_1 = require("./get-entity-object-class");
|
|
8
|
+
const external_column_owner_path_1 = require("./external-column-owner-path");
|
|
9
|
+
function resolveExternalColumnClass(ep, entityLabel, propertyKey) {
|
|
10
|
+
const Resolver = ep.getExternalResolver?.();
|
|
11
|
+
if (!Resolver) {
|
|
12
|
+
throw new Error(`External column "${propertyKey}" on ${entityLabel} must use ExternalColumn(() => ResolverClass); the callback returned nothing`);
|
|
13
|
+
}
|
|
14
|
+
return Resolver;
|
|
15
|
+
}
|
|
16
|
+
const loadProperties = ({ type, target, alias, entityAlias, properties, parent, paths, relation, fullPath = '', secure, initializedObjects = [], rootEntity, rootOrRelationPath, rootAlias, externalSubtree, usedJoinSqlAliases: usedJoinSqlAliasesArg }) => {
|
|
17
|
+
const usedJoinSqlAliases = usedJoinSqlAliasesArg ??
|
|
18
|
+
(type === "root"
|
|
19
|
+
? new Set([entityAlias ?? alias])
|
|
20
|
+
: (() => {
|
|
21
|
+
throw new Error("loadProperties: join alias registry missing; this is an internal error");
|
|
22
|
+
})());
|
|
9
23
|
const currentPath = fullPath ? `${fullPath}.${alias}` : alias;
|
|
10
|
-
;
|
|
11
24
|
const initializedObjectKey = `${currentPath}:${target.name}`;
|
|
25
|
+
const targetObjectClass = (0, get_entity_object_class_1.getEntityObjectClass)(target);
|
|
26
|
+
const entityOwnerLabel = targetObjectClass?.name
|
|
27
|
+
?? (typeof target?.name === 'string'
|
|
28
|
+
? target.name
|
|
29
|
+
: 'Entity');
|
|
12
30
|
if (initializedObjects.includes(initializedObjectKey))
|
|
13
31
|
return;
|
|
14
32
|
initializedObjects.push(initializedObjectKey);
|
|
15
|
-
const targetProperties = (0, class_pipe_1.getExposeProperties)(target)
|
|
16
|
-
targetProperties
|
|
17
|
-
.filter((property) => {
|
|
33
|
+
const targetProperties = (0, class_pipe_1.getExposeProperties)(target).filter((property) => {
|
|
18
34
|
if (property.subtype) {
|
|
19
35
|
const object = core.storage.findObject(property.subtype);
|
|
20
|
-
const isEntity = object?.type === object_type_1.ObjectType.entity;
|
|
36
|
+
const isEntity = object?.type === object_type_1.ObjectType.entity || object?.type === object_type_1.ObjectType.entityDto;
|
|
21
37
|
return !isEntity;
|
|
22
38
|
}
|
|
23
39
|
return true;
|
|
24
|
-
})
|
|
25
|
-
|
|
40
|
+
});
|
|
41
|
+
for (const targetProperty of targetProperties) {
|
|
26
42
|
const propertyKey = targetProperty.propertyKey;
|
|
27
43
|
const globalPath = `${currentPath}.${propertyKey}`;
|
|
28
44
|
let columnName;
|
|
29
|
-
const entityProperty =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
const entityProperty = targetObjectClass
|
|
46
|
+
? core
|
|
47
|
+
.storage
|
|
48
|
+
.getProperties(targetObjectClass)
|
|
49
|
+
.find((property) => {
|
|
50
|
+
return property.propertyKey === propertyKey;
|
|
51
|
+
})
|
|
52
|
+
: undefined;
|
|
33
53
|
if (entityProperty) {
|
|
34
54
|
columnName = entityProperty.columnName;
|
|
35
55
|
}
|
|
36
|
-
if (type === 'root' && !entityProperty)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
if (type === 'root' && !entityProperty)
|
|
57
|
+
continue;
|
|
58
|
+
const subtype = targetProperty.type === class_pipe_1.PropertyType.object && targetProperty.subtype;
|
|
59
|
+
const multitype = targetProperty.ifChecks?.length > 0;
|
|
60
|
+
const hasIfChecks = targetProperty.ifChecks?.length > 0;
|
|
61
|
+
const objectTypes = subtype || multitype
|
|
62
|
+
? hasIfChecks
|
|
43
63
|
? targetProperty.ifChecks.map((ifCheck) => ifCheck.type)
|
|
44
|
-
: [targetProperty.subtype]
|
|
64
|
+
: [targetProperty.subtype].filter(Boolean)
|
|
65
|
+
: [];
|
|
66
|
+
/**
|
|
67
|
+
* @IsIn(enum) can surface as `object` + enum subtype; that is not an @Entity graph.
|
|
68
|
+
* External columns like that must register a single leaf, not recurse into the enum.
|
|
69
|
+
* Real external objects (Person entity, etc.) still recurse when subtype resolves in storage.
|
|
70
|
+
*/
|
|
71
|
+
const shouldRecurseEmbedded = (subtype || multitype) &&
|
|
72
|
+
(!entityProperty?.isExternal ||
|
|
73
|
+
objectTypes.some((ot) => !!(0, get_entity_object_class_1.getEntityObjectClass)(ot)));
|
|
74
|
+
if (shouldRecurseEmbedded) {
|
|
75
|
+
const anchorDepPaths = (entityProperty?.externalSelectDependencies ?? []).map((d) => `${currentPath}.${d}`);
|
|
76
|
+
const nextSubtree = entityProperty?.isExternal
|
|
77
|
+
? {
|
|
78
|
+
resolver: resolveExternalColumnClass(entityProperty, entityOwnerLabel, propertyKey),
|
|
79
|
+
ownerFullPath: currentPath,
|
|
80
|
+
columnKey: propertyKey,
|
|
81
|
+
dependencyQueryPaths: anchorDepPaths,
|
|
82
|
+
}
|
|
83
|
+
: externalSubtree;
|
|
45
84
|
objectTypes.forEach((objectType) => {
|
|
46
85
|
(0, exports.loadProperties)({
|
|
47
86
|
type: 'embedded',
|
|
@@ -52,20 +91,45 @@ const loadProperties = ({ type, target, alias, entityAlias, properties, parent,
|
|
|
52
91
|
initializedObjects,
|
|
53
92
|
entityAlias: entityAlias,
|
|
54
93
|
rootEntity,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
rootAlias,
|
|
95
|
+
usedJoinSqlAliases,
|
|
96
|
+
externalSubtree: nextSubtree,
|
|
58
97
|
parent: {
|
|
59
98
|
alias,
|
|
60
99
|
target,
|
|
61
100
|
type,
|
|
62
101
|
parent,
|
|
63
102
|
entityAlias
|
|
64
|
-
}
|
|
103
|
+
},
|
|
104
|
+
rootOrRelationPath: type === "embedded"
|
|
105
|
+
? rootOrRelationPath
|
|
106
|
+
: `${entityAlias}.${targetProperty.propertyKey}`
|
|
65
107
|
});
|
|
66
108
|
});
|
|
67
109
|
}
|
|
68
110
|
else {
|
|
111
|
+
const directExternal = !!entityProperty?.isExternal;
|
|
112
|
+
const inheritedExternal = !!externalSubtree;
|
|
113
|
+
const isExternal = directExternal || inheritedExternal;
|
|
114
|
+
const resolver = directExternal && entityProperty
|
|
115
|
+
? resolveExternalColumnClass(entityProperty, entityOwnerLabel, propertyKey)
|
|
116
|
+
: externalSubtree?.resolver;
|
|
117
|
+
const ownerFullPath = directExternal
|
|
118
|
+
? currentPath
|
|
119
|
+
: externalSubtree?.ownerFullPath ?? currentPath;
|
|
120
|
+
const externalColumnKey = directExternal
|
|
121
|
+
? propertyKey
|
|
122
|
+
: externalSubtree?.columnKey ?? propertyKey;
|
|
123
|
+
const externalDependencyQueryPaths = isExternal
|
|
124
|
+
? [
|
|
125
|
+
...new Set([
|
|
126
|
+
...(externalSubtree?.dependencyQueryPaths ?? []),
|
|
127
|
+
...(directExternal && entityProperty
|
|
128
|
+
? (entityProperty.externalSelectDependencies ?? []).map((d) => `${currentPath}.${d}`)
|
|
129
|
+
: []),
|
|
130
|
+
]),
|
|
131
|
+
]
|
|
132
|
+
: undefined;
|
|
69
133
|
properties[globalPath] = {
|
|
70
134
|
path: {
|
|
71
135
|
target,
|
|
@@ -75,54 +139,73 @@ const loadProperties = ({ type, target, alias, entityAlias, properties, parent,
|
|
|
75
139
|
parent,
|
|
76
140
|
secure,
|
|
77
141
|
entityAlias,
|
|
78
|
-
|
|
142
|
+
rootOrRelationPath
|
|
79
143
|
},
|
|
80
144
|
isUUID: targetProperty.type === class_pipe_1.PropertyType.string
|
|
81
145
|
&& targetProperty.validatorsConfigs?.some((cfg) => cfg.type === 'isUUID') || false,
|
|
82
146
|
columnName,
|
|
83
147
|
isArray: !!targetProperty.isArray,
|
|
84
148
|
isJson: type === 'embedded',
|
|
149
|
+
isExternal,
|
|
150
|
+
externalResolver: resolver,
|
|
151
|
+
externalOwnerWalkSegments: isExternal
|
|
152
|
+
? (0, external_column_owner_path_1.toExternalOwnerWalkSegments)(ownerFullPath, rootAlias)
|
|
153
|
+
: undefined,
|
|
154
|
+
externalColumnKey: isExternal ? externalColumnKey : undefined,
|
|
155
|
+
externalDependencyQueryPaths,
|
|
85
156
|
fullPath: globalPath,
|
|
86
157
|
name: propertyKey,
|
|
87
158
|
type: targetProperty.type
|
|
88
159
|
};
|
|
89
160
|
}
|
|
90
|
-
}
|
|
161
|
+
}
|
|
91
162
|
if (paths) {
|
|
92
163
|
const idProperty = (0, get_id_property_1.getIdProperty)(target);
|
|
93
164
|
const pathKeys = Object.keys(paths);
|
|
94
165
|
for (const pathProperty of pathKeys) {
|
|
95
166
|
const path = paths[pathProperty];
|
|
167
|
+
const pathObjectClass = (0, get_entity_object_class_1.getEntityObjectClass)(path.target());
|
|
96
168
|
const linkProperty = (path.type === 'indirect'
|
|
97
|
-
? core.storage.getProperties(
|
|
98
|
-
: core.storage.getProperties(
|
|
169
|
+
? core.storage.getProperties(pathObjectClass).find((p) => p.isRelation && p.getRelationType() === targetObjectClass)
|
|
170
|
+
: core.storage.getProperties(targetObjectClass).find((p) => p.isRelation && p.getRelationType() === pathObjectClass));
|
|
99
171
|
if (!linkProperty && !path.condition) {
|
|
100
|
-
const line1 = `Unable to find linkProperty to ${path.alias}:${
|
|
172
|
+
const line1 = `Unable to find linkProperty to ${path.alias}:${pathObjectClass?.name} into query:${target.name}`;
|
|
101
173
|
const line2 = `Use @Relation(() => <target>) to define`;
|
|
102
174
|
throw new Error(`${line1}\n${line2}`);
|
|
103
175
|
}
|
|
104
|
-
const
|
|
176
|
+
const joinSqlAlias = path.alias;
|
|
177
|
+
if (usedJoinSqlAliases.has(joinSqlAlias)) {
|
|
178
|
+
throw new Error(`Duplicate query join SQL alias "${joinSqlAlias}" (paths key "${pathProperty}" under "${currentPath}"). ` +
|
|
179
|
+
`Each joinOne/joinMany must use a globally unique alias in this query (e.g. routerDataCenter vs serverDataCenter).`);
|
|
180
|
+
}
|
|
181
|
+
usedJoinSqlAliases.add(joinSqlAlias);
|
|
182
|
+
const targetIdProperty = (0, get_id_property_1.getIdProperty)(pathObjectClass);
|
|
183
|
+
const joinEntityAlias = joinSqlAlias;
|
|
105
184
|
const condition = path.condition ?? (() => {
|
|
106
185
|
const linkName = path.linkProperty || linkProperty.columnName;
|
|
107
186
|
return path.type === "direct"
|
|
108
|
-
? `"${entityAlias}"."${linkName}" = "${
|
|
109
|
-
: `"${entityAlias}"."${idProperty.columnName}" = "${
|
|
187
|
+
? `"${entityAlias}"."${linkName}" = "${joinEntityAlias}"."${targetIdProperty.columnName}"`
|
|
188
|
+
: `"${entityAlias}"."${idProperty.columnName}" = "${joinEntityAlias}"."${linkName}"`;
|
|
110
189
|
})();
|
|
111
190
|
(0, exports.loadProperties)({
|
|
112
191
|
alias: pathProperty,
|
|
113
|
-
entityAlias:
|
|
192
|
+
entityAlias: joinEntityAlias,
|
|
114
193
|
properties,
|
|
115
194
|
target: path.target(),
|
|
116
195
|
type: "relation",
|
|
117
196
|
paths: path.paths,
|
|
118
197
|
secure: path.secure,
|
|
119
198
|
rootEntity,
|
|
199
|
+
fullPath: currentPath,
|
|
200
|
+
initializedObjects,
|
|
201
|
+
rootAlias,
|
|
202
|
+
usedJoinSqlAliases,
|
|
203
|
+
externalSubtree,
|
|
120
204
|
relation: {
|
|
121
205
|
type: path.type,
|
|
122
206
|
mapTo: `${alias}.${pathProperty}`,
|
|
123
207
|
condition,
|
|
124
208
|
},
|
|
125
|
-
fullPath: currentPath,
|
|
126
209
|
parent: {
|
|
127
210
|
alias,
|
|
128
211
|
target,
|
|
@@ -130,8 +213,7 @@ const loadProperties = ({ type, target, alias, entityAlias, properties, parent,
|
|
|
130
213
|
relation,
|
|
131
214
|
parent,
|
|
132
215
|
entityAlias
|
|
133
|
-
}
|
|
134
|
-
initializedObjects
|
|
216
|
+
}
|
|
135
217
|
});
|
|
136
218
|
}
|
|
137
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-properties.js","sourceRoot":"./","sources":["query/functions/load-properties.ts"],"names":[],"mappings":";;;AAAA,qDAAyE;AAWzE,0EAAsE;AACtE,8EAAyE;
|
|
1
|
+
{"version":3,"file":"load-properties.js","sourceRoot":"./","sources":["query/functions/load-properties.ts"],"names":[],"mappings":";;;AAAA,qDAAyE;AAWzE,0EAAsE;AACtE,8EAAyE;AACzE,uEAAiE;AACjE,6EAA2E;AAY3E,SAAS,0BAA0B,CAChC,EAAiC,EACjC,WAAmB,EACnB,WAAmB;IAEnB,MAAM,QAAQ,GAAG,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACZ,oBAAoB,WAAW,QAAQ,WAAW,8EAA8E,CAClI,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AACnB,CAAC;AA2BM,MAAM,cAAc,GAAG,CAAC,EAC5B,IAAI,EACJ,MAAM,EACN,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,EAAE,EACb,MAAM,EACN,kBAAkB,GAAG,EAAE,EACvB,UAAU,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gBACZ,KAAK,EAAE,YAAY;gBACnB,WAAW,EAAE,eAAe;gBAC5B,UAAU;gBACV,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;gBACrB,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,UAAU;gBACV,QAAQ,EAAE,WAAW;gBACrB,kBAAkB;gBAClB,SAAS;gBACT,kBAAkB;gBAClB,eAAe;gBACf,QAAQ,EAAE;oBACP,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,GAAG,KAAK,IAAI,YAAY,EAAE;oBACjC,SAAS;iBACX;gBACD,MAAM,EAAE;oBACL,KAAK;oBACL,MAAM;oBACN,IAAI;oBACJ,QAAQ;oBACR,MAAM;oBACN,WAAW;iBACb;aACH,CAAC,CAAC;QACN,CAAC;IACJ,CAAC;AACJ,CAAC,CAAC;AAzQW,QAAA,cAAc,kBAyQzB"}
|
|
@@ -9,7 +9,7 @@ const mapQueryPropertyToColumnName = (queryObject, item) => {
|
|
|
9
9
|
case "root":
|
|
10
10
|
return `${queryProperty.path.entityAlias}.${queryProperty.name}`;
|
|
11
11
|
case "embedded":
|
|
12
|
-
return queryProperty.path.
|
|
12
|
+
return queryProperty.path.rootOrRelationPath;
|
|
13
13
|
default:
|
|
14
14
|
throw new Error(`${item} not found on query`);
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-query-property-to-column-name.js","sourceRoot":"./","sources":["query/functions/map-query-property-to-column-name.ts"],"names":[],"mappings":";;;AAGO,MAAM,4BAA4B,GAAG,CAAC,WAAqC,EAAE,IAAY,EAAE,EAAE;IAEjG,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC;IAC/C,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE5C,
|
|
1
|
+
{"version":3,"file":"map-query-property-to-column-name.js","sourceRoot":"./","sources":["query/functions/map-query-property-to-column-name.ts"],"names":[],"mappings":";;;AAGO,MAAM,4BAA4B,GAAG,CAAC,WAAqC,EAAE,IAAY,EAAE,EAAE;IAEjG,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC;IAC/C,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE5C,QAAQ,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,KAAK,UAAU,CAAC;QAChB,KAAK,MAAM;YACR,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,WAAW,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;QACpE,KAAK,UAAU;YACZ,OAAO,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAChD;YACG,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAC;IACpD,CAAC;AACJ,CAAC,CAAA;AAdY,QAAA,4BAA4B,gCAcxC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QueryPath } from '../interfaces/query';
|
|
2
|
+
/**
|
|
3
|
+
* Returns cached native select (asArry, asMap) for the given structure hash, or undefined.
|
|
4
|
+
* Caller receives copies so cache entries are never mutated.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCachedNativeSelect(structureHash: string): {
|
|
7
|
+
asArry: string[];
|
|
8
|
+
asMap: Map<string, string>;
|
|
9
|
+
} | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Stores native select result for the given structure hash.
|
|
12
|
+
* Evicts oldest entry when at MAX_ENTRIES (LRU).
|
|
13
|
+
*/
|
|
14
|
+
export declare function setCachedNativeSelect(structureHash: string, asArry: string[], asMap: Map<string, string>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns cached join plan (array of QueryPath) for the given join structure hash.
|
|
17
|
+
* Paths are applied to a fresh QB each request – we never cache the QB or EntityManager.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCachedJoinPlan(joinStructureHash: string): QueryPath[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Stores join plan (order of paths to apply) for the given join structure hash.
|
|
22
|
+
* Evicts oldest entry when at MAX_ENTRIES (LRU).
|
|
23
|
+
*/
|
|
24
|
+
export declare function setCachedJoinPlan(joinStructureHash: string, paths: QueryPath[]): void;
|