@acorex/platform 0.0.0-ACOREX
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/README.md +7 -0
- package/auth/README.md +3 -0
- package/common/README.md +3 -0
- package/core/README.md +4 -0
- package/fesm2022/acorex-platform-auth.mjs +1362 -0
- package/fesm2022/acorex-platform-auth.mjs.map +1 -0
- package/fesm2022/acorex-platform-common-common-settings.provider-G9XcXXOG.mjs +127 -0
- package/fesm2022/acorex-platform-common-common-settings.provider-G9XcXXOG.mjs.map +1 -0
- package/fesm2022/acorex-platform-common.mjs +4601 -0
- package/fesm2022/acorex-platform-common.mjs.map +1 -0
- package/fesm2022/acorex-platform-core.mjs +4374 -0
- package/fesm2022/acorex-platform-core.mjs.map +1 -0
- package/fesm2022/acorex-platform-domain.mjs +3234 -0
- package/fesm2022/acorex-platform-domain.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-builder.mjs +2847 -0
- package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-components-binding-expression-editor-popup.component-CXEdvDTf.mjs +121 -0
- package/fesm2022/acorex-platform-layout-components-binding-expression-editor-popup.component-CXEdvDTf.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-components.mjs +8583 -0
- package/fesm2022/acorex-platform-layout-components.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-designer.mjs +2474 -0
- package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-entity.mjs +19150 -0
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-views.mjs +1468 -0
- package/fesm2022/acorex-platform-layout-views.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widget-core.mjs +2950 -0
- package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-button-widget-designer.component-Dy7jF-oD.mjs +72 -0
- package/fesm2022/acorex-platform-layout-widgets-button-widget-designer.component-Dy7jF-oD.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-file-list-popup.component-9uCkMxcc.mjs +158 -0
- package/fesm2022/acorex-platform-layout-widgets-file-list-popup.component-9uCkMxcc.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-image-preview.popup-C_EPAvCU.mjs +29 -0
- package/fesm2022/acorex-platform-layout-widgets-image-preview.popup-C_EPAvCU.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-page-widget-designer.component-D10yO28c.mjs +172 -0
- package/fesm2022/acorex-platform-layout-widgets-page-widget-designer.component-D10yO28c.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-repeater-widget-column.component-BGQqY5Mw.mjs +111 -0
- package/fesm2022/acorex-platform-layout-widgets-repeater-widget-column.component-BGQqY5Mw.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-edit-popup.component-DmzNTYiS.mjs +274 -0
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-edit-popup.component-DmzNTYiS.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-view-popup.component-BNG_588B.mjs +64 -0
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-view-popup.component-BNG_588B.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets-text-block-widget-designer.component-Vo4fWHtX.mjs +34 -0
- package/fesm2022/acorex-platform-layout-widgets-text-block-widget-designer.component-Vo4fWHtX.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-widgets.mjs +29791 -0
- package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -0
- package/fesm2022/acorex-platform-native.mjs +155 -0
- package/fesm2022/acorex-platform-native.mjs.map +1 -0
- package/fesm2022/acorex-platform-runtime-catalog-command-definition.mjs +20 -0
- package/fesm2022/acorex-platform-runtime-catalog-command-definition.mjs.map +1 -0
- package/fesm2022/acorex-platform-runtime-catalog-query-definition.mjs +20 -0
- package/fesm2022/acorex-platform-runtime-catalog-query-definition.mjs.map +1 -0
- package/fesm2022/acorex-platform-runtime.mjs +899 -0
- package/fesm2022/acorex-platform-runtime.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-Cvvr4HnL.mjs +160 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-Cvvr4HnL.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-TYoLN1Jq.mjs +120 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-TYoLN1Jq.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-C2z5Lq9y.mjs +237 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-C2z5Lq9y.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs +31 -0
- package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs +25 -0
- package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-error-offline.component-DR6G8gPC.mjs +19 -0
- package/fesm2022/acorex-platform-themes-default-error-offline.component-DR6G8gPC.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default.mjs +2589 -0
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-column.component-CqkWJYdv.mjs +55 -0
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-column.component-CqkWJYdv.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-BOTuLdWN.mjs +57 -0
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-BOTuLdWN.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-settings.provider-DSs1o1M6.mjs +168 -0
- package/fesm2022/acorex-platform-themes-shared-settings.provider-DSs1o1M6.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-CHfrTtol.mjs +65 -0
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-CHfrTtol.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-view.component-BSmvnUVq.mjs +64 -0
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-view.component-BSmvnUVq.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared.mjs +2125 -0
- package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -0
- package/fesm2022/acorex-platform-workflow.mjs +2501 -0
- package/fesm2022/acorex-platform-workflow.mjs.map +1 -0
- package/fesm2022/acorex-platform.mjs +6 -0
- package/fesm2022/acorex-platform.mjs.map +1 -0
- package/layout/builder/README.md +1578 -0
- package/layout/components/README.md +3 -0
- package/layout/designer/README.md +4 -0
- package/layout/entity/README.md +4 -0
- package/layout/views/README.md +3 -0
- package/layout/widget-core/README.md +4 -0
- package/layout/widgets/README.md +3 -0
- package/native/README.md +4 -0
- package/package.json +103 -0
- package/runtime/README.md +3 -0
- package/themes/default/README.md +3 -0
- package/themes/shared/README.md +3 -0
- package/types/acorex-platform-auth.d.ts +680 -0
- package/types/acorex-platform-common.d.ts +2926 -0
- package/types/acorex-platform-core.d.ts +2896 -0
- package/types/acorex-platform-domain.d.ts +2353 -0
- package/types/acorex-platform-layout-builder.d.ts +926 -0
- package/types/acorex-platform-layout-components.d.ts +2903 -0
- package/types/acorex-platform-layout-designer.d.ts +422 -0
- package/types/acorex-platform-layout-entity.d.ts +3189 -0
- package/types/acorex-platform-layout-views.d.ts +667 -0
- package/types/acorex-platform-layout-widget-core.d.ts +1086 -0
- package/types/acorex-platform-layout-widgets.d.ts +5478 -0
- package/types/acorex-platform-native.d.ts +28 -0
- package/types/acorex-platform-runtime-catalog-command-definition.d.ts +137 -0
- package/types/acorex-platform-runtime-catalog-query-definition.d.ts +125 -0
- package/types/acorex-platform-runtime.d.ts +470 -0
- package/types/acorex-platform-themes-default.d.ts +573 -0
- package/types/acorex-platform-themes-shared.d.ts +170 -0
- package/types/acorex-platform-workflow.d.ts +1806 -0
- package/types/acorex-platform.d.ts +2 -0
- package/workflow/README.md +4 -0
|
@@ -0,0 +1,899 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, Injectable, InjectionToken, EnvironmentInjector, runInInjectionContext, makeEnvironmentProviders, input, ElementRef, effect, Directive, isDevMode, NgModule } from '@angular/core';
|
|
3
|
+
import { AXPBroadcastEventService, AXPDistributedEventListenerService } from '@acorex/platform/core';
|
|
4
|
+
import { castArray } from 'lodash-es';
|
|
5
|
+
|
|
6
|
+
//#region ---- defineCommand ----
|
|
7
|
+
/**
|
|
8
|
+
* Typed identity helper for command metadata sidecars.
|
|
9
|
+
*/
|
|
10
|
+
function defineCommand(definition) {
|
|
11
|
+
return definition;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Build-time command metadata only. Safe under Node (e.g. generate-runtime-catalog) without loading the command executor stack.
|
|
17
|
+
* Sidecars should import `defineCommand` from here or from `@acorex/platform/runtime/catalog-command-definition`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Shared build-time metadata shapes for command and query catalog definitions.
|
|
22
|
+
* Lives under `shared/` so secondary ng-packagr entries under `commands/` or `queries/` share a common `src/lib` compilation root.
|
|
23
|
+
*/
|
|
24
|
+
//#endregion
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Build-time command metadata for AXPCommand implementations.
|
|
28
|
+
* `inputs` / `outputs` are schema rows (same family as entity optionDefinitions).
|
|
29
|
+
* Validation entries: only `rule` name and optional `options` (no title/message on rules).
|
|
30
|
+
* Do not import from Angular templates; sidecars may import `defineCommand` from `@acorex/platform/runtime`.
|
|
31
|
+
*
|
|
32
|
+
* Query metadata (fetch-only, no outcomes) is defined in `../queries/query-definition.types.ts` with `defineQuery`.
|
|
33
|
+
*/
|
|
34
|
+
//#endregion
|
|
35
|
+
|
|
36
|
+
//#region ---- Imports ----
|
|
37
|
+
//#endregion
|
|
38
|
+
const COMMAND_EXECUTION_EVENT_KEY = '@commands:execution';
|
|
39
|
+
class AXPCommandEventsService {
|
|
40
|
+
constructor() {
|
|
41
|
+
//#region ---- Services & Dependencies ----
|
|
42
|
+
this.broadcast = inject(AXPBroadcastEventService);
|
|
43
|
+
this.distributedEvents = inject(AXPDistributedEventListenerService, { optional: true });
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ---- Public API ----
|
|
47
|
+
listen(handler) {
|
|
48
|
+
const subscription = this.broadcast
|
|
49
|
+
.listen(COMMAND_EXECUTION_EVENT_KEY)
|
|
50
|
+
.subscribe(({ data }) => handler(data));
|
|
51
|
+
return () => subscription.unsubscribe();
|
|
52
|
+
}
|
|
53
|
+
async emit(event) {
|
|
54
|
+
this.broadcast.publish(COMMAND_EXECUTION_EVENT_KEY, event);
|
|
55
|
+
await this.distributedEvents?.dispatch(COMMAND_EXECUTION_EVENT_KEY, event);
|
|
56
|
+
}
|
|
57
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandEventsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
58
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandEventsService, providedIn: 'root' }); }
|
|
59
|
+
}
|
|
60
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandEventsService, decorators: [{
|
|
61
|
+
type: Injectable,
|
|
62
|
+
args: [{ providedIn: 'root' }]
|
|
63
|
+
}] });
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region ---- Middleware Composition ----
|
|
67
|
+
/**
|
|
68
|
+
* Creates a composed handler by chaining the provided command middlewares.
|
|
69
|
+
*/
|
|
70
|
+
function composeCommandMiddlewares(middlewares) {
|
|
71
|
+
return (handler) => {
|
|
72
|
+
let composed = handler;
|
|
73
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
74
|
+
const mw = middlewares[i];
|
|
75
|
+
const next = composed;
|
|
76
|
+
composed = (input) => mw(input, next);
|
|
77
|
+
}
|
|
78
|
+
return composed;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
|
|
83
|
+
class AXPCommandRegistry {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.registry = new Map();
|
|
86
|
+
this.middlewares = [];
|
|
87
|
+
}
|
|
88
|
+
register(key, loader) {
|
|
89
|
+
this.registry.set(key, loader);
|
|
90
|
+
}
|
|
91
|
+
unregister(key) {
|
|
92
|
+
return this.registry.delete(key);
|
|
93
|
+
}
|
|
94
|
+
use(middleware) {
|
|
95
|
+
this.middlewares.push(middleware);
|
|
96
|
+
}
|
|
97
|
+
exists(key) {
|
|
98
|
+
return this.registry.has(key);
|
|
99
|
+
}
|
|
100
|
+
getLoader(key) {
|
|
101
|
+
return this.registry.get(key);
|
|
102
|
+
}
|
|
103
|
+
getMiddlewares() {
|
|
104
|
+
return [...this.middlewares];
|
|
105
|
+
}
|
|
106
|
+
getRegisteredKeys() {
|
|
107
|
+
return Array.from(this.registry.keys());
|
|
108
|
+
}
|
|
109
|
+
clear() {
|
|
110
|
+
this.registry.clear();
|
|
111
|
+
this.middlewares.length = 0;
|
|
112
|
+
}
|
|
113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
114
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandRegistry, providedIn: 'root' }); }
|
|
115
|
+
}
|
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandRegistry, decorators: [{
|
|
117
|
+
type: Injectable,
|
|
118
|
+
args: [{ providedIn: 'root' }]
|
|
119
|
+
}] });
|
|
120
|
+
|
|
121
|
+
// plugins/command.extension.token.ts
|
|
122
|
+
const AXP_COMMAND_EXTENSION = new InjectionToken('AXP_COMMAND_EXTENSION');
|
|
123
|
+
|
|
124
|
+
class AXPCommandExecutor {
|
|
125
|
+
constructor() {
|
|
126
|
+
this.injector = inject(EnvironmentInjector);
|
|
127
|
+
this.registry = inject(AXPCommandRegistry);
|
|
128
|
+
this.extensions = inject(AXP_COMMAND_EXTENSION, { optional: true });
|
|
129
|
+
this.commandEvents = inject(AXPCommandEventsService);
|
|
130
|
+
}
|
|
131
|
+
async execute(key, input) {
|
|
132
|
+
const loader = this.registry.getLoader(key);
|
|
133
|
+
if (!loader) {
|
|
134
|
+
throw new Error(`Command '${key}' is not registered`);
|
|
135
|
+
}
|
|
136
|
+
const command = await loader();
|
|
137
|
+
const handler = (i) => command.execute(i);
|
|
138
|
+
const pluginMiddlewares = this.getPluginMiddlewares(key);
|
|
139
|
+
const globalMiddlewares = this.registry.getMiddlewares();
|
|
140
|
+
const wrappedMiddlewares = [
|
|
141
|
+
...globalMiddlewares,
|
|
142
|
+
...pluginMiddlewares,
|
|
143
|
+
].map(middleware => {
|
|
144
|
+
return (input, next) => runInInjectionContext(this.injector, () => middleware(input, next));
|
|
145
|
+
});
|
|
146
|
+
const composed = composeCommandMiddlewares(wrappedMiddlewares)(handler);
|
|
147
|
+
const beforeEvent = {
|
|
148
|
+
stage: 'before',
|
|
149
|
+
key,
|
|
150
|
+
input,
|
|
151
|
+
};
|
|
152
|
+
await this.commandEvents.emit(beforeEvent);
|
|
153
|
+
try {
|
|
154
|
+
const result = await composed(input);
|
|
155
|
+
const afterEvent = {
|
|
156
|
+
stage: 'after',
|
|
157
|
+
key,
|
|
158
|
+
input,
|
|
159
|
+
success: true,
|
|
160
|
+
result,
|
|
161
|
+
};
|
|
162
|
+
await this.commandEvents.emit(afterEvent);
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const afterEvent = {
|
|
167
|
+
stage: 'after',
|
|
168
|
+
key,
|
|
169
|
+
input,
|
|
170
|
+
success: false,
|
|
171
|
+
error,
|
|
172
|
+
};
|
|
173
|
+
await this.commandEvents.emit(afterEvent);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getPluginMiddlewares(key) {
|
|
178
|
+
return this.extensions
|
|
179
|
+
?.filter(ext => ext.target instanceof RegExp ? ext.target.test(key) : ext.target === key)
|
|
180
|
+
.map(ext => ext.middleware) ?? [];
|
|
181
|
+
}
|
|
182
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandExecutor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
183
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandExecutor, providedIn: 'root' }); }
|
|
184
|
+
}
|
|
185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandExecutor, decorators: [{
|
|
186
|
+
type: Injectable,
|
|
187
|
+
args: [{ providedIn: 'root' }]
|
|
188
|
+
}] });
|
|
189
|
+
|
|
190
|
+
class AXPCommandService {
|
|
191
|
+
constructor() {
|
|
192
|
+
this.registry = inject(AXPCommandRegistry);
|
|
193
|
+
this.executor = inject(AXPCommandExecutor);
|
|
194
|
+
}
|
|
195
|
+
// Registry methods
|
|
196
|
+
register(key, loader) {
|
|
197
|
+
this.registry.register(key, loader);
|
|
198
|
+
}
|
|
199
|
+
unregister(key) {
|
|
200
|
+
return this.registry.unregister(key);
|
|
201
|
+
}
|
|
202
|
+
use(middleware) {
|
|
203
|
+
this.registry.use(middleware);
|
|
204
|
+
}
|
|
205
|
+
exists(key) {
|
|
206
|
+
return this.registry.exists(key);
|
|
207
|
+
}
|
|
208
|
+
getRegisteredKeys() {
|
|
209
|
+
return this.registry.getRegisteredKeys();
|
|
210
|
+
}
|
|
211
|
+
clear() {
|
|
212
|
+
this.registry.clear();
|
|
213
|
+
}
|
|
214
|
+
// Executor methods
|
|
215
|
+
async execute(key, input) {
|
|
216
|
+
return this.executor.execute(key, input);
|
|
217
|
+
}
|
|
218
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
219
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandService, providedIn: 'root' }); }
|
|
220
|
+
}
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPCommandService, decorators: [{
|
|
222
|
+
type: Injectable,
|
|
223
|
+
args: [{ providedIn: 'root' }]
|
|
224
|
+
}] });
|
|
225
|
+
|
|
226
|
+
const AXP_COMMAND_MIDDLEWARE_SETUP = new InjectionToken('AXP_COMMAND_MIDDLEWARE_SETUP');
|
|
227
|
+
function provideCommandMiddleware(entries) {
|
|
228
|
+
const global = [];
|
|
229
|
+
const extensions = [];
|
|
230
|
+
for (const entry of entries) {
|
|
231
|
+
if (typeof entry === 'function') {
|
|
232
|
+
global.push(entry);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
extensions.push(entry);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return makeEnvironmentProviders([
|
|
239
|
+
// Plugin middleware entries
|
|
240
|
+
...extensions.map(ext => ({
|
|
241
|
+
provide: AXP_COMMAND_EXTENSION,
|
|
242
|
+
useValue: ext,
|
|
243
|
+
multi: true
|
|
244
|
+
})),
|
|
245
|
+
// Global middleware setup (triggered via this token)
|
|
246
|
+
{
|
|
247
|
+
provide: AXP_COMMAND_MIDDLEWARE_SETUP,
|
|
248
|
+
useFactory: () => {
|
|
249
|
+
const registry = inject(AXPCommandRegistry);
|
|
250
|
+
for (const mw of global) {
|
|
251
|
+
registry.use(mw);
|
|
252
|
+
}
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const AXP_COMMAND_SETUP = new InjectionToken('AXP_COMMAND_SETUP');
|
|
260
|
+
function provideCommandSetups(entries) {
|
|
261
|
+
return makeEnvironmentProviders([
|
|
262
|
+
{
|
|
263
|
+
provide: AXP_COMMAND_SETUP,
|
|
264
|
+
useFactory: () => {
|
|
265
|
+
const registry = inject(AXPCommandRegistry);
|
|
266
|
+
const injector = inject(EnvironmentInjector);
|
|
267
|
+
for (const entry of entries) {
|
|
268
|
+
registry.register(entry.key, async () => {
|
|
269
|
+
const CommandType = await entry.command();
|
|
270
|
+
// Try to get from DI first, if fails create new instance
|
|
271
|
+
try {
|
|
272
|
+
return injector.get(CommandType);
|
|
273
|
+
}
|
|
274
|
+
catch (e) {
|
|
275
|
+
// If not in DI (e.g., for activities), create new instance
|
|
276
|
+
return runInInjectionContext(injector, () => new CommandType());
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return true;
|
|
281
|
+
},
|
|
282
|
+
multi: true
|
|
283
|
+
}
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
function provideCommand(key, loader) {
|
|
287
|
+
return provideCommandSetups([
|
|
288
|
+
{
|
|
289
|
+
key,
|
|
290
|
+
command: loader
|
|
291
|
+
}
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//#region ---- defineQuery ----
|
|
296
|
+
/**
|
|
297
|
+
* Typed identity helper for query metadata sidecars.
|
|
298
|
+
*/
|
|
299
|
+
function defineQuery(definition) {
|
|
300
|
+
return definition;
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Build-time query metadata only. Safe under Node (e.g. generate-runtime-catalog) without loading the query executor stack.
|
|
306
|
+
* Sidecars should import `defineQuery` from here or from `@acorex/platform/runtime/catalog-query-definition`.
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
// queries/query.registry.ts
|
|
310
|
+
class AXPQueryRegistry {
|
|
311
|
+
constructor() {
|
|
312
|
+
this.registry = new Map();
|
|
313
|
+
this.middlewares = [];
|
|
314
|
+
}
|
|
315
|
+
register(key, loader) {
|
|
316
|
+
this.registry.set(key, loader);
|
|
317
|
+
}
|
|
318
|
+
unregister(key) {
|
|
319
|
+
return this.registry.delete(key);
|
|
320
|
+
}
|
|
321
|
+
use(middleware) {
|
|
322
|
+
this.middlewares.push(middleware);
|
|
323
|
+
}
|
|
324
|
+
exists(key) {
|
|
325
|
+
return this.registry.has(key);
|
|
326
|
+
}
|
|
327
|
+
getLoader(key) {
|
|
328
|
+
return this.registry.get(key);
|
|
329
|
+
}
|
|
330
|
+
getMiddlewares() {
|
|
331
|
+
return [...this.middlewares];
|
|
332
|
+
}
|
|
333
|
+
getRegisteredKeys() {
|
|
334
|
+
return Array.from(this.registry.keys());
|
|
335
|
+
}
|
|
336
|
+
clear() {
|
|
337
|
+
this.registry.clear();
|
|
338
|
+
this.middlewares.length = 0;
|
|
339
|
+
}
|
|
340
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
341
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryRegistry, providedIn: 'root' }); }
|
|
342
|
+
}
|
|
343
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryRegistry, decorators: [{
|
|
344
|
+
type: Injectable,
|
|
345
|
+
args: [{ providedIn: 'root' }]
|
|
346
|
+
}] });
|
|
347
|
+
|
|
348
|
+
// plugins/query.extension.token.ts
|
|
349
|
+
const AXP_QUERY_EXTENSION = new InjectionToken('AXP_QUERY_EXTENSION');
|
|
350
|
+
|
|
351
|
+
const AXP_QUERY_MIDDLEWARE_SETUP = new InjectionToken('AXP_QUERY_MIDDLEWARE_SETUP');
|
|
352
|
+
function provideQueryMiddleware(entries) {
|
|
353
|
+
const global = [];
|
|
354
|
+
const extensions = [];
|
|
355
|
+
for (const entry of entries) {
|
|
356
|
+
if (typeof entry === 'function') {
|
|
357
|
+
global.push(entry);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
extensions.push(entry);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return makeEnvironmentProviders([
|
|
364
|
+
// Plugin middleware entries
|
|
365
|
+
...extensions.map(ext => ({
|
|
366
|
+
provide: AXP_QUERY_EXTENSION,
|
|
367
|
+
useValue: ext,
|
|
368
|
+
multi: true
|
|
369
|
+
})),
|
|
370
|
+
// Global middleware setup (triggered via this token)
|
|
371
|
+
{
|
|
372
|
+
provide: AXP_QUERY_MIDDLEWARE_SETUP,
|
|
373
|
+
useFactory: () => {
|
|
374
|
+
const registry = inject(AXPQueryRegistry);
|
|
375
|
+
for (const mw of global) {
|
|
376
|
+
registry.use(mw);
|
|
377
|
+
}
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
]);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const AXP_QUERY_SETUP = new InjectionToken('AXP_QUERY_SETUP');
|
|
385
|
+
function provideQuerySetups(entries) {
|
|
386
|
+
return makeEnvironmentProviders([
|
|
387
|
+
{
|
|
388
|
+
provide: AXP_QUERY_SETUP,
|
|
389
|
+
useFactory: () => {
|
|
390
|
+
const registry = inject(AXPQueryRegistry);
|
|
391
|
+
const injector = inject(EnvironmentInjector);
|
|
392
|
+
for (const entry of entries) {
|
|
393
|
+
registry.register(entry.key, async () => {
|
|
394
|
+
const CommandType = await entry.loader();
|
|
395
|
+
return injector.get(CommandType);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return true;
|
|
399
|
+
},
|
|
400
|
+
multi: true
|
|
401
|
+
}
|
|
402
|
+
]);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Build-time query metadata for AXPQuery implementations.
|
|
407
|
+
* Mirrors command metadata shape except there are no `outcomes` (queries only `fetch`).
|
|
408
|
+
* `inputs` / `outputs` are schema rows (same family as entity optionDefinitions).
|
|
409
|
+
*/
|
|
410
|
+
//#endregion
|
|
411
|
+
|
|
412
|
+
function composeQueryMiddlewares(middlewares) {
|
|
413
|
+
return (handler) => {
|
|
414
|
+
let composed = handler;
|
|
415
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
416
|
+
const mw = middlewares[i];
|
|
417
|
+
const next = composed;
|
|
418
|
+
composed = (input) => mw(input, next);
|
|
419
|
+
}
|
|
420
|
+
return composed;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
class AXPQueryExecutor {
|
|
425
|
+
constructor() {
|
|
426
|
+
this.injector = inject(EnvironmentInjector);
|
|
427
|
+
this.registry = inject(AXPQueryRegistry);
|
|
428
|
+
this.extensions = inject(AXP_QUERY_EXTENSION, { optional: true });
|
|
429
|
+
}
|
|
430
|
+
async fetch(key, input) {
|
|
431
|
+
const loader = this.registry.getLoader(key);
|
|
432
|
+
if (!loader) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
const query = await loader();
|
|
436
|
+
const handler = (i) => query.fetch(i);
|
|
437
|
+
const pluginMiddlewares = this.getPluginMiddlewares(key);
|
|
438
|
+
const globalMiddlewares = this.registry.getMiddlewares();
|
|
439
|
+
const wrappedMiddlewares = [...globalMiddlewares, ...pluginMiddlewares].map(middleware => {
|
|
440
|
+
return (input, next) => runInInjectionContext(this.injector, () => middleware(input, next));
|
|
441
|
+
});
|
|
442
|
+
const composed = composeQueryMiddlewares(wrappedMiddlewares)(handler);
|
|
443
|
+
return composed(input);
|
|
444
|
+
}
|
|
445
|
+
getPluginMiddlewares(key) {
|
|
446
|
+
return this.extensions
|
|
447
|
+
?.filter(ext => ext.target instanceof RegExp ? ext.target.test(key) : ext.target === key)
|
|
448
|
+
.map(ext => ext.middleware) ?? [];
|
|
449
|
+
}
|
|
450
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryExecutor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
451
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryExecutor, providedIn: 'root' }); }
|
|
452
|
+
}
|
|
453
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryExecutor, decorators: [{
|
|
454
|
+
type: Injectable,
|
|
455
|
+
args: [{ providedIn: 'root' }]
|
|
456
|
+
}] });
|
|
457
|
+
|
|
458
|
+
class AXPQueryService {
|
|
459
|
+
constructor() {
|
|
460
|
+
this.registry = inject(AXPQueryRegistry);
|
|
461
|
+
this.executor = inject(AXPQueryExecutor);
|
|
462
|
+
}
|
|
463
|
+
// Registry methods
|
|
464
|
+
register(key, loader) {
|
|
465
|
+
this.registry.register(key, loader);
|
|
466
|
+
}
|
|
467
|
+
unregister(key) {
|
|
468
|
+
return this.registry.unregister(key);
|
|
469
|
+
}
|
|
470
|
+
use(middleware) {
|
|
471
|
+
this.registry.use(middleware);
|
|
472
|
+
}
|
|
473
|
+
exists(key) {
|
|
474
|
+
return this.registry.exists(key);
|
|
475
|
+
}
|
|
476
|
+
getRegisteredKeys() {
|
|
477
|
+
return this.registry.getRegisteredKeys();
|
|
478
|
+
}
|
|
479
|
+
clear() {
|
|
480
|
+
this.registry.clear();
|
|
481
|
+
}
|
|
482
|
+
// Executor methods
|
|
483
|
+
async fetch(key, input) {
|
|
484
|
+
return this.executor.fetch(key, input);
|
|
485
|
+
}
|
|
486
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
487
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryService, providedIn: 'root' }); }
|
|
488
|
+
}
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPQueryService, decorators: [{
|
|
490
|
+
type: Injectable,
|
|
491
|
+
args: [{ providedIn: 'root' }]
|
|
492
|
+
}] });
|
|
493
|
+
|
|
494
|
+
function composeViewMiddlewares(middlewares) {
|
|
495
|
+
return (handler) => {
|
|
496
|
+
let composed = handler;
|
|
497
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
498
|
+
const mw = middlewares[i];
|
|
499
|
+
const next = composed;
|
|
500
|
+
composed = (input) => mw(input, next);
|
|
501
|
+
}
|
|
502
|
+
return composed;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
class AXPViewRegistry {
|
|
507
|
+
constructor() {
|
|
508
|
+
this.registry = new Map();
|
|
509
|
+
this.middlewares = [];
|
|
510
|
+
}
|
|
511
|
+
register(key, loader) {
|
|
512
|
+
this.registry.set(key, loader);
|
|
513
|
+
}
|
|
514
|
+
unregister(key) {
|
|
515
|
+
return this.registry.delete(key);
|
|
516
|
+
}
|
|
517
|
+
use(middleware) {
|
|
518
|
+
this.middlewares.push(middleware);
|
|
519
|
+
}
|
|
520
|
+
exists(key) {
|
|
521
|
+
return this.registry.has(key);
|
|
522
|
+
}
|
|
523
|
+
getLoader(key) {
|
|
524
|
+
return this.registry.get(key);
|
|
525
|
+
}
|
|
526
|
+
getMiddlewares() {
|
|
527
|
+
return [...this.middlewares];
|
|
528
|
+
}
|
|
529
|
+
getRegisteredKeys() {
|
|
530
|
+
return Array.from(this.registry.keys());
|
|
531
|
+
}
|
|
532
|
+
clear() {
|
|
533
|
+
this.registry.clear();
|
|
534
|
+
this.middlewares.length = 0;
|
|
535
|
+
}
|
|
536
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
537
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewRegistry, providedIn: 'root' }); }
|
|
538
|
+
}
|
|
539
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewRegistry, decorators: [{
|
|
540
|
+
type: Injectable,
|
|
541
|
+
args: [{ providedIn: 'root' }]
|
|
542
|
+
}] });
|
|
543
|
+
|
|
544
|
+
const AXP_VIEW_EXTENSION = new InjectionToken('AXP_VIEW_EXTENSION');
|
|
545
|
+
|
|
546
|
+
class AXPViewExecutor {
|
|
547
|
+
constructor() {
|
|
548
|
+
this.injector = inject(EnvironmentInjector);
|
|
549
|
+
this.registry = inject(AXPViewRegistry);
|
|
550
|
+
this.extensions = inject(AXP_VIEW_EXTENSION, { optional: true });
|
|
551
|
+
}
|
|
552
|
+
async provide(key, input) {
|
|
553
|
+
const loader = this.registry.getLoader(key);
|
|
554
|
+
if (!loader) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
const provider = await loader();
|
|
558
|
+
const handler = (i) => provider.provide(i);
|
|
559
|
+
const pluginMiddlewares = this.getPluginMiddlewares(key);
|
|
560
|
+
const globalMiddlewares = this.registry.getMiddlewares();
|
|
561
|
+
const wrappedMiddlewares = [...globalMiddlewares, ...pluginMiddlewares].map(middleware => {
|
|
562
|
+
return (input, next) => runInInjectionContext(this.injector, () => middleware(input, next));
|
|
563
|
+
});
|
|
564
|
+
const composed = composeViewMiddlewares(wrappedMiddlewares)(handler);
|
|
565
|
+
return composed(input);
|
|
566
|
+
}
|
|
567
|
+
getPluginMiddlewares(key) {
|
|
568
|
+
return this.extensions
|
|
569
|
+
?.filter(ext => ext.target instanceof RegExp ? ext.target.test(key) : ext.target === key)
|
|
570
|
+
.map(ext => ext.middleware) ?? [];
|
|
571
|
+
}
|
|
572
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewExecutor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
573
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewExecutor, providedIn: 'root' }); }
|
|
574
|
+
}
|
|
575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewExecutor, decorators: [{
|
|
576
|
+
type: Injectable,
|
|
577
|
+
args: [{ providedIn: 'root' }]
|
|
578
|
+
}] });
|
|
579
|
+
|
|
580
|
+
class AXPViewService {
|
|
581
|
+
constructor() {
|
|
582
|
+
this.registry = inject(AXPViewRegistry);
|
|
583
|
+
this.executor = inject(AXPViewExecutor);
|
|
584
|
+
}
|
|
585
|
+
//#region ---- Registry Methods ----
|
|
586
|
+
register(key, loader) {
|
|
587
|
+
this.registry.register(key, loader);
|
|
588
|
+
}
|
|
589
|
+
unregister(key) {
|
|
590
|
+
return this.registry.unregister(key);
|
|
591
|
+
}
|
|
592
|
+
use(middleware) {
|
|
593
|
+
this.registry.use(middleware);
|
|
594
|
+
}
|
|
595
|
+
exists(key) {
|
|
596
|
+
return this.registry.exists(key);
|
|
597
|
+
}
|
|
598
|
+
getRegisteredKeys() {
|
|
599
|
+
return this.registry.getRegisteredKeys();
|
|
600
|
+
}
|
|
601
|
+
clear() {
|
|
602
|
+
this.registry.clear();
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region ---- Executor Methods ----
|
|
606
|
+
async provide(key, input) {
|
|
607
|
+
return this.executor.provide(key, input);
|
|
608
|
+
}
|
|
609
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
610
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewService, providedIn: 'root' }); }
|
|
611
|
+
}
|
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPViewService, decorators: [{
|
|
613
|
+
type: Injectable,
|
|
614
|
+
args: [{ providedIn: 'root' }]
|
|
615
|
+
}] });
|
|
616
|
+
|
|
617
|
+
const AXP_VIEW_SETUP = new InjectionToken('AXP_VIEW_SETUP');
|
|
618
|
+
function provideViewSetups(providers) {
|
|
619
|
+
return makeEnvironmentProviders([
|
|
620
|
+
...providers,
|
|
621
|
+
{
|
|
622
|
+
provide: AXP_VIEW_SETUP,
|
|
623
|
+
useFactory: () => {
|
|
624
|
+
const registry = inject(AXPViewRegistry);
|
|
625
|
+
// Setup will be handled by the provided registration functions
|
|
626
|
+
return;
|
|
627
|
+
},
|
|
628
|
+
multi: true
|
|
629
|
+
}
|
|
630
|
+
]);
|
|
631
|
+
}
|
|
632
|
+
function provideViewSetup(key, loader) {
|
|
633
|
+
return {
|
|
634
|
+
provide: AXP_VIEW_SETUP,
|
|
635
|
+
useFactory: () => {
|
|
636
|
+
const registry = inject(AXPViewRegistry);
|
|
637
|
+
registry.register(key, loader);
|
|
638
|
+
return;
|
|
639
|
+
},
|
|
640
|
+
multi: true
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function composePolicyEngineMiddlewares(middlewares) {
|
|
645
|
+
return (handler) => {
|
|
646
|
+
let composed = handler;
|
|
647
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
648
|
+
const mw = middlewares[i];
|
|
649
|
+
const next = composed;
|
|
650
|
+
composed = (context) => mw(context, next);
|
|
651
|
+
}
|
|
652
|
+
return composed;
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
class AXPPolicyEngineContext {
|
|
657
|
+
constructor(options) {
|
|
658
|
+
this._visible = true;
|
|
659
|
+
this._enabled = true;
|
|
660
|
+
this._id = options.id;
|
|
661
|
+
this._sender = options.sender;
|
|
662
|
+
}
|
|
663
|
+
get sender() {
|
|
664
|
+
return this._sender;
|
|
665
|
+
}
|
|
666
|
+
get id() {
|
|
667
|
+
return this._id;
|
|
668
|
+
}
|
|
669
|
+
get visible() {
|
|
670
|
+
return this._visible;
|
|
671
|
+
}
|
|
672
|
+
get enabled() {
|
|
673
|
+
return this._enabled;
|
|
674
|
+
}
|
|
675
|
+
setVisible(visible) {
|
|
676
|
+
this._visible = visible;
|
|
677
|
+
return this;
|
|
678
|
+
}
|
|
679
|
+
setEnabled(enabled) {
|
|
680
|
+
this._enabled = enabled;
|
|
681
|
+
return this;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// plugins/command.extension.token.ts
|
|
686
|
+
const AXP_POLICY_EXTENSION = new InjectionToken('AXP_POLICY_EXTENSION');
|
|
687
|
+
|
|
688
|
+
class AXPPolicyEngineRegistry {
|
|
689
|
+
constructor() {
|
|
690
|
+
this.registry = new Map();
|
|
691
|
+
this.middlewares = [];
|
|
692
|
+
this.extensions = inject(AXP_POLICY_EXTENSION, { optional: true });
|
|
693
|
+
this.injector = inject(EnvironmentInjector);
|
|
694
|
+
}
|
|
695
|
+
use(mw) {
|
|
696
|
+
this.middlewares.push(mw);
|
|
697
|
+
}
|
|
698
|
+
exists(key) {
|
|
699
|
+
return this.registry.has(key);
|
|
700
|
+
}
|
|
701
|
+
getPolicies() {
|
|
702
|
+
return Array.from(this.registry.keys());
|
|
703
|
+
}
|
|
704
|
+
register(key, loader) {
|
|
705
|
+
this.registry.set(key, loader);
|
|
706
|
+
}
|
|
707
|
+
getPluginMiddlewares(key) {
|
|
708
|
+
return this.extensions
|
|
709
|
+
?.filter(ext => ext.key === key)
|
|
710
|
+
.map(ext => ext.middleware) ?? [];
|
|
711
|
+
}
|
|
712
|
+
async execute(policy, instance) {
|
|
713
|
+
const loader = this.registry.get(policy);
|
|
714
|
+
if (!loader) {
|
|
715
|
+
throw new Error(`${policy} not implemented`);
|
|
716
|
+
}
|
|
717
|
+
const context = new AXPPolicyEngineContext(instance);
|
|
718
|
+
const applier = await loader();
|
|
719
|
+
const handler = (i) => applier.apply(i);
|
|
720
|
+
const pluginMws = this.getPluginMiddlewares(policy);
|
|
721
|
+
const wrappedMws = [...this.middlewares, ...pluginMws].map(mw => {
|
|
722
|
+
return (input, next) => runInInjectionContext(this.injector, () => mw(input, next));
|
|
723
|
+
});
|
|
724
|
+
const composed = composePolicyEngineMiddlewares(wrappedMws)(handler);
|
|
725
|
+
await composed(context);
|
|
726
|
+
return context;
|
|
727
|
+
}
|
|
728
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
729
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineRegistry, providedIn: 'root' }); }
|
|
730
|
+
}
|
|
731
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineRegistry, decorators: [{
|
|
732
|
+
type: Injectable,
|
|
733
|
+
args: [{ providedIn: 'root' }]
|
|
734
|
+
}] });
|
|
735
|
+
|
|
736
|
+
class AXPPolicyEngineService {
|
|
737
|
+
constructor() {
|
|
738
|
+
this.registry = inject(AXPPolicyEngineRegistry);
|
|
739
|
+
}
|
|
740
|
+
async apply(options) {
|
|
741
|
+
const allPolicies = this.registry.getPolicies().filter(p => (options.policies?.length ?? 0) == 0 || options.policies?.includes(p));
|
|
742
|
+
await Promise.all(allPolicies.map(async (policy) => {
|
|
743
|
+
const context = await this.registry.execute(policy, options);
|
|
744
|
+
return context;
|
|
745
|
+
}));
|
|
746
|
+
//
|
|
747
|
+
// if (instance instanceof HTMLElement) {
|
|
748
|
+
// if (context.visible === false) {
|
|
749
|
+
// instance.style.display = 'none';
|
|
750
|
+
// } else {
|
|
751
|
+
// instance.style.display = '';
|
|
752
|
+
// }
|
|
753
|
+
// }
|
|
754
|
+
// //
|
|
755
|
+
// if (instance instanceof MXBaseComponent) {
|
|
756
|
+
// if (context.visible === false) {
|
|
757
|
+
// instance.getHostElement().style.display = 'none';
|
|
758
|
+
// } else {
|
|
759
|
+
// instance.getHostElement().style.display = '';
|
|
760
|
+
// }
|
|
761
|
+
// }
|
|
762
|
+
// // Handle disabled state for interactive components
|
|
763
|
+
// if (instance instanceof MXInteractiveComponent) {
|
|
764
|
+
// if (context.enabled === false) {
|
|
765
|
+
// instance.disabled = true;
|
|
766
|
+
// } else {
|
|
767
|
+
// instance.disabled = false;
|
|
768
|
+
// }
|
|
769
|
+
// }
|
|
770
|
+
// // TODO: Handle object properties
|
|
771
|
+
// if (instance instanceof Object) {
|
|
772
|
+
// if (context.visible === false) {
|
|
773
|
+
// set(instance, 'visible', false);
|
|
774
|
+
// }
|
|
775
|
+
// if (context.enabled === false) {
|
|
776
|
+
// set(instance, 'disabled', true);
|
|
777
|
+
// }
|
|
778
|
+
// }
|
|
779
|
+
}
|
|
780
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
781
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineService, providedIn: 'root' }); }
|
|
782
|
+
}
|
|
783
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineService, decorators: [{
|
|
784
|
+
type: Injectable,
|
|
785
|
+
args: [{
|
|
786
|
+
providedIn: 'root'
|
|
787
|
+
}]
|
|
788
|
+
}] });
|
|
789
|
+
|
|
790
|
+
class AXPPolicyEngineDirective {
|
|
791
|
+
constructor() {
|
|
792
|
+
this.policy = input.required({ ...(ngDevMode ? { debugName: "policy" } : /* istanbul ignore next */ {}), alias: 'axp-apply-policy' });
|
|
793
|
+
this.service = inject(AXPPolicyEngineService);
|
|
794
|
+
this.elementRef = inject((ElementRef));
|
|
795
|
+
this.#eff = effect(async () => {
|
|
796
|
+
const policy = this.policy();
|
|
797
|
+
if (!policy) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
await this.service.apply({
|
|
801
|
+
id: this.elementRef.nativeElement.id,
|
|
802
|
+
policies: castArray(policy),
|
|
803
|
+
sender: this.elementRef.nativeElement
|
|
804
|
+
});
|
|
805
|
+
}, ...(ngDevMode ? [{ debugName: "#eff" }] : /* istanbul ignore next */ []));
|
|
806
|
+
}
|
|
807
|
+
#eff;
|
|
808
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
809
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: AXPPolicyEngineDirective, isStandalone: true, selector: "[axp-apply-policy]", inputs: { policy: { classPropertyName: "policy", publicName: "axp-apply-policy", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
810
|
+
}
|
|
811
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPPolicyEngineDirective, decorators: [{
|
|
812
|
+
type: Directive,
|
|
813
|
+
args: [{
|
|
814
|
+
selector: '[axp-apply-policy]',
|
|
815
|
+
standalone: true
|
|
816
|
+
}]
|
|
817
|
+
}], propDecorators: { policy: [{ type: i0.Input, args: [{ isSignal: true, alias: "axp-apply-policy", required: true }] }] } });
|
|
818
|
+
|
|
819
|
+
const AXP_POLICY_ENGINE_MIDDLEWARE_SETUP = new InjectionToken('AXP_POLICY_ENGINE_MIDDLEWARE_SETUP');
|
|
820
|
+
function providePolicySetups(entries) {
|
|
821
|
+
return makeEnvironmentProviders([
|
|
822
|
+
{
|
|
823
|
+
provide: AXP_POLICY_ENGINE_MIDDLEWARE_SETUP,
|
|
824
|
+
useFactory: () => {
|
|
825
|
+
const registry = inject(AXPPolicyEngineRegistry);
|
|
826
|
+
const injector = inject(EnvironmentInjector);
|
|
827
|
+
for (const entry of entries) {
|
|
828
|
+
registry.register(entry.key, async () => {
|
|
829
|
+
const PolicyType = await entry.policy();
|
|
830
|
+
return injector.get(PolicyType);
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
return true;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
]);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
const AXP_VIEW_MIDDLEWARE_SETUP = new InjectionToken('AXP_VIEW_MIDDLEWARE_SETUP');
|
|
840
|
+
function provideViewMiddleware(middlewares) {
|
|
841
|
+
return makeEnvironmentProviders([
|
|
842
|
+
{
|
|
843
|
+
provide: AXP_VIEW_MIDDLEWARE_SETUP,
|
|
844
|
+
useFactory: () => {
|
|
845
|
+
const registry = inject(AXPViewRegistry);
|
|
846
|
+
middlewares.forEach(middleware => registry.use(middleware));
|
|
847
|
+
return;
|
|
848
|
+
},
|
|
849
|
+
multi: true
|
|
850
|
+
}
|
|
851
|
+
]);
|
|
852
|
+
}
|
|
853
|
+
function provideViewMiddlewareSetup(middleware) {
|
|
854
|
+
return {
|
|
855
|
+
provide: AXP_VIEW_MIDDLEWARE_SETUP,
|
|
856
|
+
useFactory: () => {
|
|
857
|
+
const registry = inject(AXPViewRegistry);
|
|
858
|
+
registry.use(middleware);
|
|
859
|
+
return;
|
|
860
|
+
},
|
|
861
|
+
multi: true
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
class AXPRuntimeModule {
|
|
866
|
+
constructor() {
|
|
867
|
+
this._commandSetup = inject(AXP_COMMAND_SETUP, { optional: true });
|
|
868
|
+
this._commandMiddlewareSetup = inject(AXP_COMMAND_MIDDLEWARE_SETUP, { optional: true });
|
|
869
|
+
this._querySetup = inject(AXP_QUERY_SETUP, { optional: true });
|
|
870
|
+
this._queryMiddlewareSetup = inject(AXP_QUERY_MIDDLEWARE_SETUP, { optional: true });
|
|
871
|
+
this._viewSetup = inject(AXP_VIEW_SETUP, { optional: true });
|
|
872
|
+
this._viewMiddlewareSetup = inject(AXP_VIEW_MIDDLEWARE_SETUP, { optional: true });
|
|
873
|
+
this._policyEngineSetup = inject(AXP_POLICY_ENGINE_MIDDLEWARE_SETUP, { optional: true });
|
|
874
|
+
if (isDevMode() && false) {
|
|
875
|
+
console.log('[AXPRuntimeModule] Command Setup:', this._commandSetup);
|
|
876
|
+
console.log('[AXPRuntimeModule] Command Middleware Setup:', this._commandMiddlewareSetup);
|
|
877
|
+
console.log('[AXPRuntimeModule] Query Setup:', this._querySetup);
|
|
878
|
+
console.log('[AXPRuntimeModule] Query Middleware Setup:', this._queryMiddlewareSetup);
|
|
879
|
+
console.log('[AXPRuntimeModule] View Setup:', this._viewSetup);
|
|
880
|
+
console.log('[AXPRuntimeModule] View Middleware Setup:', this._viewMiddlewareSetup);
|
|
881
|
+
console.log('[AXPRuntimeModule] Policy Engine Setup:', this._policyEngineSetup);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPRuntimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
885
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: AXPRuntimeModule }); }
|
|
886
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPRuntimeModule }); }
|
|
887
|
+
}
|
|
888
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPRuntimeModule, decorators: [{
|
|
889
|
+
type: NgModule
|
|
890
|
+
}], ctorParameters: () => [] });
|
|
891
|
+
|
|
892
|
+
// Commands
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Generated bundle index. Do not edit.
|
|
896
|
+
*/
|
|
897
|
+
|
|
898
|
+
export { AXPCommandEventsService, AXPCommandExecutor, AXPCommandRegistry, AXPCommandService, AXPPolicyEngineContext, AXPPolicyEngineDirective, AXPPolicyEngineRegistry, AXPPolicyEngineService, AXPQueryExecutor, AXPQueryRegistry, AXPQueryService, AXPRuntimeModule, AXPViewExecutor, AXPViewRegistry, AXPViewService, AXP_COMMAND_EXTENSION, AXP_COMMAND_MIDDLEWARE_SETUP, AXP_COMMAND_SETUP, AXP_POLICY_ENGINE_MIDDLEWARE_SETUP, AXP_POLICY_EXTENSION, AXP_QUERY_EXTENSION, AXP_QUERY_MIDDLEWARE_SETUP, AXP_QUERY_SETUP, AXP_VIEW_EXTENSION, AXP_VIEW_SETUP, composeCommandMiddlewares, composePolicyEngineMiddlewares, composeQueryMiddlewares, composeViewMiddlewares, defineCommand, defineQuery, provideCommand, provideCommandMiddleware, provideCommandSetups, providePolicySetups, provideQueryMiddleware, provideQuerySetups, provideViewSetup, provideViewSetups };
|
|
899
|
+
//# sourceMappingURL=acorex-platform-runtime.mjs.map
|