@acorex-platform/module-platform-management-client 0.0.38 → 0.0.46
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/fesm2022/{acorex-platform-module-platform-management-client-acorex-platform-module-platform-management-client-BGVhn6wv.mjs → acorex-platform-module-platform-management-client-acorex-platform-module-platform-management-client-YuJijjKh.mjs} +465 -101
- package/fesm2022/acorex-platform-module-platform-management-client-acorex-platform-module-platform-management-client-YuJijjKh.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-command-definition.mjs +20 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-command-definition.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-entity-access-policy.mjs +20 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-entity-access-policy.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-entity-definition.mjs +1499 -30
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-entity-definition.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-module-definition.mjs +396 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-module-definition.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-plugin-definition.mjs +20 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-plugin-definition.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-query-definition.mjs +49 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-query-definition.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-token.mjs +20 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-token.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-widget.mjs +20 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entities-widget.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-acorex-platform-module-platform-management-client-contracts-entity-catalog-BOwC5Ns9.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-acorex-platform-module-platform-management-client-contracts-entity-catalog-HWczTPH2.mjs} +15 -8
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-acorex-platform-module-platform-management-client-contracts-entity-catalog-HWczTPH2.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-command-definition.entity-CdvQlwAk.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-command-definition.entity-C3B1_QMs.mjs} +16 -2
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-command-definition.entity-C3B1_QMs.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-access-policy.entity-Dye4aSKE.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-access-policy.entity-BPkJloHy.mjs} +16 -2
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-access-policy.entity-BPkJloHy.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-definition.entity-BL1I9pmK.mjs +1621 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-definition.entity-BL1I9pmK.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-module-definition.entity-Cknl0vbc.mjs +299 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-module-definition.entity-Cknl0vbc.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-plugin-definition.entity-CwU5hMjI.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-plugin-definition.entity-BxABTl8L.mjs} +16 -2
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-plugin-definition.entity-BxABTl8L.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-query-definition.entity-DGK684Q1.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-query-definition.entity-Cv6HVQOU.mjs} +45 -3
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-query-definition.entity-Cv6HVQOU.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-token.entity-DI_k6-ha.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-token.entity-BV8iSuoK.mjs} +16 -2
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-token.entity-BV8iSuoK.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-contracts-entity-catalog-widget.entity-C18msniH.mjs → acorex-platform-module-platform-management-client-contracts-entity-catalog-widget.entity-BYH6SIqU.mjs} +16 -2
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-widget.entity-BYH6SIqU.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog.mjs +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts.mjs +1664 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query-contract.util-D_af2BUi.mjs +586 -0
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query-contract.util-D_af2BUi.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-create-user-query.command-9Ku7C1BC.mjs → acorex-platform-module-platform-management-client-create-user-query.command-Bh49QHkl.mjs} +374 -324
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query.command-Bh49QHkl.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-entity-definition-form-page.component-BgBWob9p.mjs +329 -0
- package/fesm2022/acorex-platform-module-platform-management-client-entity-definition-form-page.component-BgBWob9p.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-entity-definition-form-page.provider-hLzgoJu3.mjs +23 -0
- package/fesm2022/acorex-platform-module-platform-management-client-entity-definition-form-page.provider-hLzgoJu3.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-list-registered-entities.query-CZM6JQou.mjs +197 -0
- package/fesm2022/acorex-platform-module-platform-management-client-list-registered-entities.query-CZM6JQou.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-local-entities.mjs +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-local-entities.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-platform-management-client-menu-list.component-uF5w1c7t.mjs → acorex-platform-module-platform-management-client-menu-list.component-iMEnFPEY.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-platform-management-client-menu-list.component-uF5w1c7t.mjs.map → acorex-platform-module-platform-management-client-menu-list.component-iMEnFPEY.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-column.component-COfOzMGh.mjs +45 -0
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-column.component-COfOzMGh.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-edit.component-BW2pBOeg.mjs +166 -0
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-edit.component-BW2pBOeg.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-view.component-DD9ETjFD.mjs +45 -0
- package/fesm2022/acorex-platform-module-platform-management-client-query-contract-widget-view.component-DD9ETjFD.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-column.component-B0g6dweQ.mjs → acorex-platform-module-platform-management-client-rest-api-generator-widget-column.component-DRkE2a7n.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-column.component-B0g6dweQ.mjs.map → acorex-platform-module-platform-management-client-rest-api-generator-widget-column.component-DRkE2a7n.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-edit.component-A0v5MWRU.mjs → acorex-platform-module-platform-management-client-rest-api-generator-widget-edit.component-CXI6fJi3.mjs} +2 -3
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-edit.component-A0v5MWRU.mjs.map → acorex-platform-module-platform-management-client-rest-api-generator-widget-edit.component-CXI6fJi3.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-view.component-RR5zcsnI.mjs → acorex-platform-module-platform-management-client-rest-api-generator-widget-view.component-C3iHgoC2.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-platform-management-client-rest-api-generator-widget-view.component-RR5zcsnI.mjs.map → acorex-platform-module-platform-management-client-rest-api-generator-widget-view.component-C3iHgoC2.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-platform-management-client-run-user-query.command-BzNa3B48.mjs +144 -0
- package/fesm2022/acorex-platform-module-platform-management-client-run-user-query.command-BzNa3B48.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-platform-management-client.mjs +1 -1
- package/package.json +7 -3
- package/types/acorex-platform-module-platform-management-client-contracts-entities-module-definition.d.ts +5 -0
- package/types/acorex-platform-module-platform-management-client-contracts.d.ts +225 -5
- package/types/acorex-platform-module-platform-management-client.d.ts +35 -3
- package/fesm2022/acorex-platform-module-platform-management-client-acorex-platform-module-platform-management-client-BGVhn6wv.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-acorex-platform-module-platform-management-client-contracts-entity-catalog-BOwC5Ns9.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-command-definition.entity-CdvQlwAk.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-access-policy.entity-Dye4aSKE.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-definition.entity-CcJ58vfr.mjs +0 -158
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-entity-definition.entity-CcJ58vfr.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-plugin-definition.entity-CwU5hMjI.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-query-definition.entity-DGK684Q1.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-token.entity-DI_k6-ha.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-contracts-entity-catalog-widget.entity-C18msniH.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query.command-9Ku7C1BC.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query.types-DdygAori.mjs +0 -71
- package/fesm2022/acorex-platform-module-platform-management-client-create-user-query.types-DdygAori.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-platform-management-client-list-registered-entities.query-DjStd3a8.mjs +0 -136
- package/fesm2022/acorex-platform-module-platform-management-client-list-registered-entities.query-DjStd3a8.mjs.map +0 -1
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import { AXP_QUERY_DEFAULT_COLLECTION_PAGING } from '@acorex-platform/framework-shared/runtime';
|
|
2
|
+
import { parsePropertyExposeEntries } from '@acorex-platform/framework-shared/entity';
|
|
3
|
+
|
|
4
|
+
//#region ----- Imports -----
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region ----- Constants -----
|
|
7
|
+
const LOOKUP_WIDGET_TYPES = new Set(['lookup-editor', 'select-editor']);
|
|
8
|
+
const USER_QUERY_RELATED_DEPTH = 3;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region ----- Public API -----
|
|
11
|
+
function isNumericUserQueryField(item) {
|
|
12
|
+
return String(item.dataType ?? '').toLowerCase() === 'number';
|
|
13
|
+
}
|
|
14
|
+
function numericUserQueryFields(fields) {
|
|
15
|
+
return fields.filter(isNumericUserQueryField);
|
|
16
|
+
}
|
|
17
|
+
function parseEntityFullName(fullName) {
|
|
18
|
+
const trimmed = fullName.trim();
|
|
19
|
+
const separator = trimmed.indexOf('.');
|
|
20
|
+
if (separator <= 0 || separator === trimmed.length - 1) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
module: trimmed.slice(0, separator),
|
|
25
|
+
name: trimmed.slice(separator + 1),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function resolvePickedEntityFullName(value) {
|
|
29
|
+
if (typeof value === 'string') {
|
|
30
|
+
return value.trim();
|
|
31
|
+
}
|
|
32
|
+
if (value == null || typeof value !== 'object') {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
const record = value;
|
|
36
|
+
const id = typeof record['id'] === 'string' ? record['id'].trim() : '';
|
|
37
|
+
if (id.includes('.')) {
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
40
|
+
const moduleName = typeof record['module_id'] === 'string' ? record['module_id'].trim() : '';
|
|
41
|
+
const name = typeof record['name'] === 'string' ? record['name'].trim() : '';
|
|
42
|
+
if (moduleName && name) {
|
|
43
|
+
return `${moduleName}.${name}`;
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
function collectUserQueryEntityFieldGroups(entity, relatedByName) {
|
|
48
|
+
return collectGroups(entity, relatedByName, '', new Set());
|
|
49
|
+
}
|
|
50
|
+
function flattenEntityFieldGroups(groups) {
|
|
51
|
+
const result = [];
|
|
52
|
+
const walk = (group) => {
|
|
53
|
+
result.push(group);
|
|
54
|
+
for (const child of group.children ?? []) {
|
|
55
|
+
walk(child);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
for (const group of groups) {
|
|
59
|
+
walk(group);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
function defaultSelectedFieldGroups(groups) {
|
|
64
|
+
const selected = {};
|
|
65
|
+
for (const group of flattenEntityFieldGroups(groups)) {
|
|
66
|
+
selected[group.id] = [];
|
|
67
|
+
}
|
|
68
|
+
for (const group of groups) {
|
|
69
|
+
if (group.kind !== 'relation') {
|
|
70
|
+
selected[group.id] = group.items.map((item) => item.path);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return selected;
|
|
74
|
+
}
|
|
75
|
+
function collectSelectedFieldGroupPaths(fieldGroups, groups) {
|
|
76
|
+
const paths = [];
|
|
77
|
+
const walk = (group) => {
|
|
78
|
+
paths.push(...normalizeSelectedFieldPaths(fieldGroups?.[group.id]));
|
|
79
|
+
for (const child of group.children ?? []) {
|
|
80
|
+
walk(child);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
for (const group of groups) {
|
|
84
|
+
walk(group);
|
|
85
|
+
}
|
|
86
|
+
return paths;
|
|
87
|
+
}
|
|
88
|
+
function withRequiredIdField(paths) {
|
|
89
|
+
const unique = [];
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
for (const path of paths) {
|
|
92
|
+
const trimmed = path.trim();
|
|
93
|
+
if (!trimmed || seen.has(trimmed)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
seen.add(trimmed);
|
|
97
|
+
unique.push(trimmed);
|
|
98
|
+
}
|
|
99
|
+
if (!seen.has('id')) {
|
|
100
|
+
unique.unshift('id');
|
|
101
|
+
}
|
|
102
|
+
return unique;
|
|
103
|
+
}
|
|
104
|
+
function normalizeSelectedFieldPaths(value) {
|
|
105
|
+
if (!Array.isArray(value)) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
const paths = [];
|
|
109
|
+
for (const item of value) {
|
|
110
|
+
if (typeof item === 'string') {
|
|
111
|
+
paths.push(item);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (item != null && typeof item === 'object') {
|
|
115
|
+
const path = item.path;
|
|
116
|
+
if (typeof path === 'string') {
|
|
117
|
+
paths.push(path);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return paths;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ----- Group collection -----
|
|
125
|
+
function collectGroups(entity, relatedByName, pathPrefix, ancestry) {
|
|
126
|
+
const groups = [];
|
|
127
|
+
const { host, lookups } = collectHostAndLookups(entity, pathPrefix);
|
|
128
|
+
if (host.items.length) {
|
|
129
|
+
groups.push(host);
|
|
130
|
+
}
|
|
131
|
+
groups.push(...lookups);
|
|
132
|
+
const hostFullName = `${entity.module}.${entity.name}`;
|
|
133
|
+
const nextAncestry = new Set(ancestry);
|
|
134
|
+
nextAncestry.add(hostFullName);
|
|
135
|
+
for (const related of entity.relatedEntities ?? []) {
|
|
136
|
+
const group = collectRelatedGroup(related, relatedByName, pathPrefix, nextAncestry);
|
|
137
|
+
if (group) {
|
|
138
|
+
groups.push(group);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return groups;
|
|
142
|
+
}
|
|
143
|
+
function collectHostAndLookups(entity, pathPrefix, allowedNames) {
|
|
144
|
+
const hostItems = [];
|
|
145
|
+
const lookups = [];
|
|
146
|
+
for (const property of entity?.properties ?? []) {
|
|
147
|
+
const name = property.name?.trim();
|
|
148
|
+
if (!name || name.toLowerCase() === 'id') {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (allowedNames && !allowedNames.has(name)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (isLookupProperty(property)) {
|
|
155
|
+
const lookupGroup = collectLookupGroup(property, pathPrefix);
|
|
156
|
+
if (lookupGroup) {
|
|
157
|
+
lookups.push(lookupGroup);
|
|
158
|
+
}
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
hostItems.push({
|
|
162
|
+
path: joinPath(pathPrefix, name),
|
|
163
|
+
title: property.title,
|
|
164
|
+
fallback: name,
|
|
165
|
+
filterWidget: resolveFilterWidget(property),
|
|
166
|
+
dataType: String(property.schema?.dataType ?? ''),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
host: {
|
|
171
|
+
id: pathPrefix ? `rel_${sanitizeGroupId(pathPrefix)}_fields` : 'host',
|
|
172
|
+
kind: pathPrefix ? 'relation' : 'host',
|
|
173
|
+
title: '',
|
|
174
|
+
fallback: 'fields',
|
|
175
|
+
items: hostItems,
|
|
176
|
+
},
|
|
177
|
+
lookups,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function collectLookupGroup(property, pathPrefix) {
|
|
181
|
+
const name = property.name?.trim();
|
|
182
|
+
if (!name) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const items = [
|
|
186
|
+
{
|
|
187
|
+
path: joinPath(pathPrefix, name),
|
|
188
|
+
title: property.title,
|
|
189
|
+
fallback: name,
|
|
190
|
+
filterWidget: 'lookup-filter',
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
const opts = property.schema?.interface?.options;
|
|
194
|
+
for (const entry of parsePropertyExposeEntries(opts)) {
|
|
195
|
+
const target = entry.target.trim();
|
|
196
|
+
if (!target || target === name) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
items.push({
|
|
200
|
+
path: joinPath(pathPrefix, target),
|
|
201
|
+
title: entry.source,
|
|
202
|
+
fallback: entry.source.trim() || target,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
id: `lookup_${sanitizeGroupId(joinPath(pathPrefix, name))}`,
|
|
207
|
+
kind: 'lookup',
|
|
208
|
+
title: property.title,
|
|
209
|
+
fallback: name,
|
|
210
|
+
items,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function collectRelatedGroup(related, relatedByName, pathPrefix, ancestry) {
|
|
214
|
+
if (related.hidden === true) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
const entityName = related.entity?.trim();
|
|
218
|
+
if (!entityName || ancestry.has(entityName)) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const relatedEntity = relatedByName.get(entityName);
|
|
222
|
+
const dataPath = related.persistence?.dataPath?.trim() || entityName.split('.').pop() || entityName;
|
|
223
|
+
const pathRoot = joinPath(pathPrefix, dataPath);
|
|
224
|
+
const allowed = resolveAllowedPropertyNames(related, relatedEntity);
|
|
225
|
+
const { host, lookups } = collectHostAndLookups(relatedEntity, pathRoot, allowed);
|
|
226
|
+
const childAncestry = new Set(ancestry);
|
|
227
|
+
childAncestry.add(entityName);
|
|
228
|
+
const children = [...lookups];
|
|
229
|
+
for (const nested of relatedEntity?.relatedEntities ?? []) {
|
|
230
|
+
const child = collectRelatedGroup(nested, relatedByName, pathRoot, childAncestry);
|
|
231
|
+
if (child) {
|
|
232
|
+
children.push(child);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (!host.items.length && !children.length) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
id: `rel_${sanitizeGroupId(pathRoot)}`,
|
|
240
|
+
kind: 'relation',
|
|
241
|
+
title: related.title,
|
|
242
|
+
fallback: entityName,
|
|
243
|
+
items: host.items,
|
|
244
|
+
children: children.length ? children : undefined,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function resolveAllowedPropertyNames(related, relatedEntity) {
|
|
248
|
+
const excluded = new Set((related.excludeProperties ?? [])
|
|
249
|
+
.filter((name) => typeof name === 'string')
|
|
250
|
+
.map((name) => name.trim())
|
|
251
|
+
.filter(Boolean));
|
|
252
|
+
const fromConfig = Array.isArray(related.properties)
|
|
253
|
+
? related.properties.filter((name) => typeof name === 'string' && name.trim().length > 0)
|
|
254
|
+
: [];
|
|
255
|
+
if (fromConfig.length) {
|
|
256
|
+
return new Set(fromConfig.map((name) => name.trim()).filter((name) => name.toLowerCase() !== 'id' && !excluded.has(name)));
|
|
257
|
+
}
|
|
258
|
+
if (!excluded.size) {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
const names = (relatedEntity?.properties ?? [])
|
|
262
|
+
.map((property) => property.name?.trim() ?? '')
|
|
263
|
+
.filter((name) => name && name.toLowerCase() !== 'id' && !excluded.has(name));
|
|
264
|
+
return new Set(names);
|
|
265
|
+
}
|
|
266
|
+
function resolveFilterWidget(property) {
|
|
267
|
+
const widgetType = typeof property.schema?.interface?.type === 'string' ? property.schema.interface.type : '';
|
|
268
|
+
if (LOOKUP_WIDGET_TYPES.has(widgetType)) {
|
|
269
|
+
return 'lookup-filter';
|
|
270
|
+
}
|
|
271
|
+
const dataType = String(property.schema?.dataType ?? '').toLowerCase();
|
|
272
|
+
const widget = widgetType.toLowerCase();
|
|
273
|
+
if (dataType === 'number' || widget.includes('number')) {
|
|
274
|
+
return 'number-filter';
|
|
275
|
+
}
|
|
276
|
+
if (dataType === 'boolean' || widget.includes('check') || widget.includes('toggle')) {
|
|
277
|
+
return 'boolean-filter';
|
|
278
|
+
}
|
|
279
|
+
if (dataType === 'date' || widget.includes('date')) {
|
|
280
|
+
return 'datetime-filter';
|
|
281
|
+
}
|
|
282
|
+
return 'string-filter';
|
|
283
|
+
}
|
|
284
|
+
function isLookupProperty(property) {
|
|
285
|
+
const iface = property.schema?.interface;
|
|
286
|
+
const opts = iface?.options;
|
|
287
|
+
const lookupEntity = typeof opts?.['entity'] === 'string' ? String(opts['entity']).trim() : '';
|
|
288
|
+
if (!lookupEntity) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
const widgetType = typeof iface?.type === 'string' ? iface.type : '';
|
|
292
|
+
if (LOOKUP_WIDGET_TYPES.has(widgetType)) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
return /(Ids|IDs|Id|ID)$/i.test(property.name);
|
|
296
|
+
}
|
|
297
|
+
function joinPath(prefix, segment) {
|
|
298
|
+
return prefix ? `${prefix}.${segment}` : segment;
|
|
299
|
+
}
|
|
300
|
+
function sanitizeGroupId(value) {
|
|
301
|
+
return value.replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_|_$/g, '');
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
|
|
305
|
+
//#region ----- Imports -----
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region ----- Constants -----
|
|
308
|
+
const TEXT_FIELD_PREFERENCE = ['title', 'name', 'displayName', 'code'];
|
|
309
|
+
const FIELD_INTERFACE = { name: 'text-editor' };
|
|
310
|
+
const VALUE_REDUCERS = ['count', 'sum', 'min', 'max', 'avg'];
|
|
311
|
+
const DEFAULT_USER_QUERY_MEASURE = {
|
|
312
|
+
reducer: 'count',
|
|
313
|
+
alias: 'value',
|
|
314
|
+
};
|
|
315
|
+
const DEFAULT_USER_QUERY_PAGING = {
|
|
316
|
+
enabled: true,
|
|
317
|
+
definition: { ...AXP_QUERY_DEFAULT_COLLECTION_PAGING },
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region ----- Public API -----
|
|
321
|
+
function suggestedUserQueryName(entityFullName) {
|
|
322
|
+
const trimmed = entityFullName.trim();
|
|
323
|
+
return trimmed ? `UserQuery:${trimmed}` : '';
|
|
324
|
+
}
|
|
325
|
+
function flattenEntityFieldItems(groups) {
|
|
326
|
+
const items = [];
|
|
327
|
+
const walk = (group) => {
|
|
328
|
+
items.push(...group.items);
|
|
329
|
+
for (const child of group.children ?? []) {
|
|
330
|
+
walk(child);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
for (const group of groups) {
|
|
334
|
+
walk(group);
|
|
335
|
+
}
|
|
336
|
+
return items;
|
|
337
|
+
}
|
|
338
|
+
function selectedFieldPathsFromGroups(fieldGroups) {
|
|
339
|
+
if (!fieldGroups) {
|
|
340
|
+
return withRequiredIdField([]);
|
|
341
|
+
}
|
|
342
|
+
const paths = [];
|
|
343
|
+
for (const value of Object.values(fieldGroups)) {
|
|
344
|
+
paths.push(...normalizeSelectedFieldPaths(value));
|
|
345
|
+
}
|
|
346
|
+
return withRequiredIdField(paths);
|
|
347
|
+
}
|
|
348
|
+
function resolveAvailableContractFields(allFields, selectedPaths) {
|
|
349
|
+
const ordered = withRequiredIdField(selectedPaths);
|
|
350
|
+
const byPath = new Map(allFields.map((field) => [field.path, field]));
|
|
351
|
+
return ordered.map((path) => byPath.get(path) ?? { path, text: path });
|
|
352
|
+
}
|
|
353
|
+
function defaultContractBinding(fields) {
|
|
354
|
+
const paths = fields.map((field) => field.path);
|
|
355
|
+
const valueField = paths.includes('id') ? 'id' : (paths[0] ?? 'id');
|
|
356
|
+
const preferred = TEXT_FIELD_PREFERENCE.find((name) => paths.includes(name) && name !== valueField);
|
|
357
|
+
const textField = preferred ?? paths.find((path) => path !== valueField) ?? valueField;
|
|
358
|
+
return { valueField, textField };
|
|
359
|
+
}
|
|
360
|
+
function toFilterDefinitions(fields) {
|
|
361
|
+
return fields.map((field) => ({
|
|
362
|
+
name: field.path,
|
|
363
|
+
title: field.text || field.path,
|
|
364
|
+
source: 'field',
|
|
365
|
+
field: field.path,
|
|
366
|
+
interface: FIELD_INTERFACE,
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
function toSortDefinitions(fields) {
|
|
370
|
+
return fields.map((field) => ({
|
|
371
|
+
name: field.path,
|
|
372
|
+
title: field.text || field.path,
|
|
373
|
+
source: 'field',
|
|
374
|
+
field: field.path,
|
|
375
|
+
directions: ['asc', 'desc'],
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
function toColumnDefinitions(fields) {
|
|
379
|
+
return fields.map((field) => ({
|
|
380
|
+
name: field.path,
|
|
381
|
+
title: field.text || field.path,
|
|
382
|
+
interface: FIELD_INTERFACE,
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
function toFilterSection(fields) {
|
|
386
|
+
if (fields.length === 0) {
|
|
387
|
+
return { enabled: false };
|
|
388
|
+
}
|
|
389
|
+
return { enabled: true, definition: toFilterDefinitions(fields) };
|
|
390
|
+
}
|
|
391
|
+
function toSortSection(fields) {
|
|
392
|
+
if (fields.length === 0) {
|
|
393
|
+
return { enabled: false };
|
|
394
|
+
}
|
|
395
|
+
return { enabled: true, definition: toSortDefinitions(fields) };
|
|
396
|
+
}
|
|
397
|
+
function pathsFromFilterSection(section) {
|
|
398
|
+
if (!section?.enabled) {
|
|
399
|
+
return [];
|
|
400
|
+
}
|
|
401
|
+
return section.definition.map((item) => item.field ?? item.name).filter((path) => path.trim().length > 0);
|
|
402
|
+
}
|
|
403
|
+
function pathsFromSortSection(section) {
|
|
404
|
+
if (!section?.enabled) {
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
return section.definition.map((item) => item.field ?? item.name).filter((path) => path.trim().length > 0);
|
|
408
|
+
}
|
|
409
|
+
function createDefaultContractCapabilities(available) {
|
|
410
|
+
return {
|
|
411
|
+
filter: { enabled: false },
|
|
412
|
+
sort: toSortSection(available),
|
|
413
|
+
paging: { enabled: true, definition: { ...AXP_QUERY_DEFAULT_COLLECTION_PAGING } },
|
|
414
|
+
binding: defaultContractBinding(available),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function normalizeUserQueryKind(value) {
|
|
418
|
+
return value === 'value' || value === 'object' || value === 'collection' ? value : 'collection';
|
|
419
|
+
}
|
|
420
|
+
function normalizeUserQueryValueType(value) {
|
|
421
|
+
return value === 'string' ||
|
|
422
|
+
value === 'number' ||
|
|
423
|
+
value === 'boolean' ||
|
|
424
|
+
value === 'date' ||
|
|
425
|
+
value === 'datetime' ||
|
|
426
|
+
value === 'json'
|
|
427
|
+
? value
|
|
428
|
+
: 'string';
|
|
429
|
+
}
|
|
430
|
+
function isCollectionQueryKind(value) {
|
|
431
|
+
return normalizeUserQueryKind(value) === 'collection';
|
|
432
|
+
}
|
|
433
|
+
function isValueQueryKind(value) {
|
|
434
|
+
return normalizeUserQueryKind(value) === 'value';
|
|
435
|
+
}
|
|
436
|
+
function normalizeUserQueryMeasure(value, available) {
|
|
437
|
+
const record = value != null && typeof value === 'object' ? value : {};
|
|
438
|
+
const reducer = VALUE_REDUCERS.includes(record['reducer'])
|
|
439
|
+
? record['reducer']
|
|
440
|
+
: 'count';
|
|
441
|
+
if (reducer === 'count') {
|
|
442
|
+
return { reducer: 'count', alias: 'value' };
|
|
443
|
+
}
|
|
444
|
+
const numeric = available.filter(isNumericUserQueryField);
|
|
445
|
+
const field = typeof record['field'] === 'string' ? record['field'].trim() : '';
|
|
446
|
+
const availableSet = new Set(numeric.map((item) => item.path));
|
|
447
|
+
const resolved = availableSet.has(field) ? field : (numeric[0]?.path ?? '');
|
|
448
|
+
return { reducer, field: resolved, alias: 'value' };
|
|
449
|
+
}
|
|
450
|
+
function createDefaultEntityContract(entityName, available) {
|
|
451
|
+
return {
|
|
452
|
+
name: suggestedUserQueryName(entityName),
|
|
453
|
+
catalogTitle: entityName,
|
|
454
|
+
description: '',
|
|
455
|
+
kind: 'collection',
|
|
456
|
+
executionMode: 'backend',
|
|
457
|
+
columns: toColumnDefinitions(available),
|
|
458
|
+
capabilities: createDefaultContractCapabilities(available),
|
|
459
|
+
valueType: 'number',
|
|
460
|
+
measure: { ...DEFAULT_USER_QUERY_MEASURE },
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function reconcileContractCapabilities(current, available, previousAvailablePaths = []) {
|
|
464
|
+
const defaults = createDefaultContractCapabilities(available);
|
|
465
|
+
if (!current) {
|
|
466
|
+
return defaults;
|
|
467
|
+
}
|
|
468
|
+
const availableByPath = new Map(available.map((field) => [field.path, field]));
|
|
469
|
+
const availablePaths = available.map((field) => field.path);
|
|
470
|
+
const availableSet = new Set(availablePaths);
|
|
471
|
+
const wasFilterAll = samePathSet(pathsFromFilterSection(current.filter), previousAvailablePaths);
|
|
472
|
+
const wasSortAll = samePathSet(pathsFromSortSection(current.sort), previousAvailablePaths);
|
|
473
|
+
const filterPaths = wasFilterAll
|
|
474
|
+
? availablePaths
|
|
475
|
+
: pathsFromFilterSection(current.filter).filter((path) => availableSet.has(path));
|
|
476
|
+
const sortPaths = wasSortAll
|
|
477
|
+
? availablePaths
|
|
478
|
+
: pathsFromSortSection(current.sort).filter((path) => availableSet.has(path));
|
|
479
|
+
const binding = reconcileBinding(current.binding, availableSet, defaults.binding);
|
|
480
|
+
return {
|
|
481
|
+
filter: toFilterSection(filterPaths.map((path) => availableByPath.get(path) ?? { path, text: path })),
|
|
482
|
+
sort: toSortSection(sortPaths.map((path) => availableByPath.get(path) ?? { path, text: path })),
|
|
483
|
+
paging: current.paging?.enabled
|
|
484
|
+
? {
|
|
485
|
+
enabled: true,
|
|
486
|
+
definition: { ...AXP_QUERY_DEFAULT_COLLECTION_PAGING, ...(current.paging.definition ?? {}) },
|
|
487
|
+
}
|
|
488
|
+
: { enabled: false },
|
|
489
|
+
binding,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function assembleEntityQueryContract(identity, capabilities, selectedFields) {
|
|
493
|
+
const kind = normalizeUserQueryKind(identity.kind);
|
|
494
|
+
const nextCapabilities = capabilitiesForKind(kind, capabilities, selectedFields);
|
|
495
|
+
const contract = {
|
|
496
|
+
name: identity.name?.trim() ?? '',
|
|
497
|
+
catalogTitle: identity.catalogTitle?.trim() ?? '',
|
|
498
|
+
description: identity.description?.trim() || undefined,
|
|
499
|
+
kind,
|
|
500
|
+
executionMode: 'backend',
|
|
501
|
+
capabilities: nextCapabilities,
|
|
502
|
+
};
|
|
503
|
+
if (kind === 'value') {
|
|
504
|
+
return {
|
|
505
|
+
...contract,
|
|
506
|
+
valueType: identity.valueType ? normalizeUserQueryValueType(identity.valueType) : 'number',
|
|
507
|
+
measure: normalizeUserQueryMeasure(identity.measure, selectedFields),
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
...contract,
|
|
512
|
+
columns: toColumnDefinitions(selectedFields),
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function validateEntityQueryContract(contract, available) {
|
|
516
|
+
if (!contract?.name?.trim()) {
|
|
517
|
+
return 'name';
|
|
518
|
+
}
|
|
519
|
+
if (!contract.catalogTitle?.trim()) {
|
|
520
|
+
return 'title';
|
|
521
|
+
}
|
|
522
|
+
if (isValueQueryKind(contract.kind)) {
|
|
523
|
+
const measure = normalizeUserQueryMeasure(contract.measure, available);
|
|
524
|
+
if (measure.reducer !== 'count' && !measure.field) {
|
|
525
|
+
return 'measure';
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
if (!isCollectionQueryKind(contract.kind)) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
const paths = new Set(available.map((field) => field.path));
|
|
533
|
+
const binding = contract.capabilities?.binding;
|
|
534
|
+
if (!binding?.valueField || !binding.textField) {
|
|
535
|
+
return 'binding';
|
|
536
|
+
}
|
|
537
|
+
if (!paths.has(binding.valueField) || !paths.has(binding.textField)) {
|
|
538
|
+
return 'binding';
|
|
539
|
+
}
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
function formatContractCapabilitiesSummary(capabilities) {
|
|
543
|
+
if (!capabilities) {
|
|
544
|
+
return '';
|
|
545
|
+
}
|
|
546
|
+
const filterCount = pathsFromFilterSection(capabilities.filter).length;
|
|
547
|
+
const sortCount = pathsFromSortSection(capabilities.sort).length;
|
|
548
|
+
const paging = capabilities.paging?.enabled ? 'on' : 'off';
|
|
549
|
+
const binding = capabilities.binding
|
|
550
|
+
? `${capabilities.binding.valueField}/${capabilities.binding.textField}`
|
|
551
|
+
: '';
|
|
552
|
+
return `filter ${filterCount}, sort ${sortCount}, paging ${paging}${binding ? `, ${binding}` : ''}`;
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region ----- Helpers -----
|
|
556
|
+
function samePathSet(left, right) {
|
|
557
|
+
if (left.length !== right.length) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
const set = new Set(left);
|
|
561
|
+
return right.every((path) => set.has(path));
|
|
562
|
+
}
|
|
563
|
+
function reconcileBinding(current, availableSet, fallback) {
|
|
564
|
+
if (!current) {
|
|
565
|
+
return fallback;
|
|
566
|
+
}
|
|
567
|
+
const valueField = availableSet.has(current.valueField) ? current.valueField : fallback.valueField;
|
|
568
|
+
const textField = availableSet.has(current.textField) ? current.textField : fallback.textField;
|
|
569
|
+
return { valueField, textField };
|
|
570
|
+
}
|
|
571
|
+
function capabilitiesForKind(kind, current, available) {
|
|
572
|
+
const full = current ?? createDefaultContractCapabilities(available);
|
|
573
|
+
if (kind === 'collection') {
|
|
574
|
+
return full;
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
filter: full.filter,
|
|
578
|
+
sort: { enabled: false },
|
|
579
|
+
paging: { enabled: false },
|
|
580
|
+
binding: full.binding,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
584
|
+
|
|
585
|
+
export { DEFAULT_USER_QUERY_PAGING as D, USER_QUERY_RELATED_DEPTH as U, resolveAvailableContractFields as a, assembleEntityQueryContract as b, collectSelectedFieldGroupPaths as c, collectUserQueryEntityFieldGroups as d, defaultSelectedFieldGroups as e, flattenEntityFieldItems as f, numericUserQueryFields as g, createDefaultEntityContract as h, pathsFromFilterSection as i, pathsFromSortSection as j, isCollectionQueryKind as k, reconcileContractCapabilities as l, toSortSection as m, normalizeUserQueryMeasure as n, createDefaultContractCapabilities as o, parseEntityFullName as p, formatContractCapabilitiesSummary as q, resolvePickedEntityFullName as r, selectedFieldPathsFromGroups as s, toFilterSection as t, validateEntityQueryContract as v, withRequiredIdField as w };
|
|
586
|
+
//# sourceMappingURL=acorex-platform-module-platform-management-client-create-user-query-contract.util-D_af2BUi.mjs.map
|