@acorex/platform 21.0.0-next.1 → 21.0.0-next.11

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.
Files changed (87) hide show
  1. package/auth/index.d.ts +235 -5
  2. package/common/index.d.ts +220 -218
  3. package/core/index.d.ts +370 -434
  4. package/fesm2022/acorex-platform-auth.mjs +200 -37
  5. package/fesm2022/acorex-platform-auth.mjs.map +1 -1
  6. package/fesm2022/{acorex-platform-common-common-settings.provider-zhqNP3xb.mjs → acorex-platform-common-common-settings.provider-O8usQ0VC.mjs} +4 -4
  7. package/fesm2022/{acorex-platform-common-common-settings.provider-zhqNP3xb.mjs.map → acorex-platform-common-common-settings.provider-O8usQ0VC.mjs.map} +1 -1
  8. package/fesm2022/acorex-platform-common.mjs +215 -198
  9. package/fesm2022/acorex-platform-common.mjs.map +1 -1
  10. package/fesm2022/acorex-platform-core.mjs +548 -585
  11. package/fesm2022/acorex-platform-core.mjs.map +1 -1
  12. package/fesm2022/acorex-platform-domain.mjs +16 -16
  13. package/fesm2022/acorex-platform-domain.mjs.map +1 -1
  14. package/fesm2022/acorex-platform-layout-builder.mjs +84 -37
  15. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  16. package/fesm2022/acorex-platform-layout-components.mjs +303 -195
  17. package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
  18. package/fesm2022/acorex-platform-layout-designer.mjs +72 -72
  19. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  20. package/fesm2022/acorex-platform-layout-entity.mjs +3528 -1698
  21. package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
  22. package/fesm2022/acorex-platform-layout-views.mjs +25 -17
  23. package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
  24. package/fesm2022/acorex-platform-layout-widget-core.mjs +190 -110
  25. package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -1
  26. package/fesm2022/{acorex-platform-layout-widgets-button-widget-designer.component-C3VoBb_b.mjs → acorex-platform-layout-widgets-button-widget-designer.component-D-NsRvRl.mjs} +4 -4
  27. package/fesm2022/{acorex-platform-layout-widgets-button-widget-designer.component-C3VoBb_b.mjs.map → acorex-platform-layout-widgets-button-widget-designer.component-D-NsRvRl.mjs.map} +1 -1
  28. package/fesm2022/{acorex-platform-layout-widgets-file-list-popup.component-CxrsI6Hn.mjs → acorex-platform-layout-widgets-file-list-popup.component-CCcKHSHj.mjs} +4 -4
  29. package/fesm2022/{acorex-platform-layout-widgets-file-list-popup.component-CxrsI6Hn.mjs.map → acorex-platform-layout-widgets-file-list-popup.component-CCcKHSHj.mjs.map} +1 -1
  30. package/fesm2022/{acorex-platform-layout-widgets-image-preview.popup-V31OpYah.mjs → acorex-platform-layout-widgets-image-preview.popup-IrT52Nh1.mjs} +4 -4
  31. package/fesm2022/{acorex-platform-layout-widgets-image-preview.popup-V31OpYah.mjs.map → acorex-platform-layout-widgets-image-preview.popup-IrT52Nh1.mjs.map} +1 -1
  32. package/fesm2022/{acorex-platform-layout-widgets-page-widget-designer.component-BtZMBxYp.mjs → acorex-platform-layout-widgets-page-widget-designer.component-DFbfh-OX.mjs} +4 -4
  33. package/fesm2022/{acorex-platform-layout-widgets-page-widget-designer.component-BtZMBxYp.mjs.map → acorex-platform-layout-widgets-page-widget-designer.component-DFbfh-OX.mjs.map} +1 -1
  34. package/fesm2022/acorex-platform-layout-widgets-repeater-widget-column.component-Dw6naXvq.mjs +111 -0
  35. package/fesm2022/acorex-platform-layout-widgets-repeater-widget-column.component-Dw6naXvq.mjs.map +1 -0
  36. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-Ck7-wpT2.mjs → acorex-platform-layout-widgets-tabular-data-edit-popup.component--4R3TUdJ.mjs} +4 -4
  37. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-Ck7-wpT2.mjs.map → acorex-platform-layout-widgets-tabular-data-edit-popup.component--4R3TUdJ.mjs.map} +1 -1
  38. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-y8vjUiVs.mjs → acorex-platform-layout-widgets-tabular-data-view-popup.component-BeVQuHFj.mjs} +4 -4
  39. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-y8vjUiVs.mjs.map → acorex-platform-layout-widgets-tabular-data-view-popup.component-BeVQuHFj.mjs.map} +1 -1
  40. package/fesm2022/{acorex-platform-layout-widgets-text-block-widget-designer.component-Df1BFkSa.mjs → acorex-platform-layout-widgets-text-block-widget-designer.component-CdQxqi0D.mjs} +4 -4
  41. package/fesm2022/{acorex-platform-layout-widgets-text-block-widget-designer.component-Df1BFkSa.mjs.map → acorex-platform-layout-widgets-text-block-widget-designer.component-CdQxqi0D.mjs.map} +1 -1
  42. package/fesm2022/acorex-platform-layout-widgets.mjs +2247 -1226
  43. package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -1
  44. package/fesm2022/acorex-platform-native.mjs +7 -7
  45. package/fesm2022/acorex-platform-native.mjs.map +1 -1
  46. package/fesm2022/acorex-platform-runtime.mjs +43 -43
  47. package/fesm2022/acorex-platform-runtime.mjs.map +1 -1
  48. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-VIGuU5M4.mjs → acorex-platform-themes-default-entity-master-create-view.component-D2ucwC3F.mjs} +4 -4
  49. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-VIGuU5M4.mjs.map → acorex-platform-themes-default-entity-master-create-view.component-D2ucwC3F.mjs.map} +1 -1
  50. package/fesm2022/{acorex-platform-themes-default-entity-master-list-view.component-DyDa_hyd.mjs → acorex-platform-themes-default-entity-master-list-view.component-CD4Q_UIG.mjs} +13 -13
  51. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-CD4Q_UIG.mjs.map +1 -0
  52. package/fesm2022/{acorex-platform-themes-default-entity-master-modify-view.component-Ua3ZA5hk.mjs → acorex-platform-themes-default-entity-master-modify-view.component-D5BYbUGK.mjs} +7 -8
  53. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-D5BYbUGK.mjs.map +1 -0
  54. package/fesm2022/{acorex-platform-themes-default-entity-master-single-view.component-eMBby9k4.mjs → acorex-platform-themes-default-entity-master-single-view.component-Cf4ei46_.mjs} +7 -7
  55. package/fesm2022/{acorex-platform-themes-default-entity-master-single-view.component-eMBby9k4.mjs.map → acorex-platform-themes-default-entity-master-single-view.component-Cf4ei46_.mjs.map} +1 -1
  56. package/fesm2022/{acorex-platform-themes-default-error-401.component-cfREo88K.mjs → acorex-platform-themes-default-error-401.component-DdMToZ9q.mjs} +4 -4
  57. package/fesm2022/{acorex-platform-themes-default-error-401.component-cfREo88K.mjs.map → acorex-platform-themes-default-error-401.component-DdMToZ9q.mjs.map} +1 -1
  58. package/fesm2022/{acorex-platform-themes-default-error-404.component-CdCV5ZoA.mjs → acorex-platform-themes-default-error-404.component-CKsa5aPE.mjs} +4 -4
  59. package/fesm2022/{acorex-platform-themes-default-error-404.component-CdCV5ZoA.mjs.map → acorex-platform-themes-default-error-404.component-CKsa5aPE.mjs.map} +1 -1
  60. package/fesm2022/{acorex-platform-themes-default-error-offline.component-E7SzBcAt.mjs → acorex-platform-themes-default-error-offline.component-1gxFTAuX.mjs} +4 -4
  61. package/fesm2022/{acorex-platform-themes-default-error-offline.component-E7SzBcAt.mjs.map → acorex-platform-themes-default-error-offline.component-1gxFTAuX.mjs.map} +1 -1
  62. package/fesm2022/acorex-platform-themes-default.mjs +39 -42
  63. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  64. package/fesm2022/{acorex-platform-themes-shared-icon-chooser-column.component-C0EpfU2k.mjs → acorex-platform-themes-shared-icon-chooser-column.component-Ds8eRMuV.mjs} +4 -4
  65. package/fesm2022/{acorex-platform-themes-shared-icon-chooser-column.component-C0EpfU2k.mjs.map → acorex-platform-themes-shared-icon-chooser-column.component-Ds8eRMuV.mjs.map} +1 -1
  66. package/fesm2022/{acorex-platform-themes-shared-icon-chooser-view.component-9W52W6Nu.mjs → acorex-platform-themes-shared-icon-chooser-view.component-Dv38sOzr.mjs} +4 -4
  67. package/fesm2022/{acorex-platform-themes-shared-icon-chooser-view.component-9W52W6Nu.mjs.map → acorex-platform-themes-shared-icon-chooser-view.component-Dv38sOzr.mjs.map} +1 -1
  68. package/fesm2022/{acorex-platform-themes-shared-theme-color-chooser-column.component-DTnfRy5f.mjs → acorex-platform-themes-shared-theme-color-chooser-column.component-DcO6P6OG.mjs} +11 -11
  69. package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-DcO6P6OG.mjs.map +1 -0
  70. package/fesm2022/{acorex-platform-themes-shared-theme-color-chooser-view.component-DY0JtT1v.mjs → acorex-platform-themes-shared-theme-color-chooser-view.component-B7T2qtaI.mjs} +4 -4
  71. package/fesm2022/{acorex-platform-themes-shared-theme-color-chooser-view.component-DY0JtT1v.mjs.map → acorex-platform-themes-shared-theme-color-chooser-view.component-B7T2qtaI.mjs.map} +1 -1
  72. package/fesm2022/acorex-platform-themes-shared.mjs +41 -41
  73. package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
  74. package/fesm2022/acorex-platform-workflow.mjs +1529 -1758
  75. package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
  76. package/layout/builder/index.d.ts +15 -3
  77. package/layout/components/index.d.ts +23 -6
  78. package/layout/entity/index.d.ts +438 -159
  79. package/layout/views/index.d.ts +16 -11
  80. package/layout/widget-core/index.d.ts +47 -10
  81. package/layout/widgets/index.d.ts +213 -42
  82. package/package.json +5 -5
  83. package/themes/default/index.d.ts +0 -1
  84. package/workflow/index.d.ts +1050 -1759
  85. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DyDa_hyd.mjs.map +0 -1
  86. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-Ua3ZA5hk.mjs.map +0 -1
  87. package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-DTnfRy5f.mjs.map +0 -1
@@ -2,12 +2,9 @@ import * as rxjs from 'rxjs';
2
2
  import { Observable } from 'rxjs';
3
3
  import * as i0 from '@angular/core';
4
4
  import { Type, ModuleWithProviders, Injector, InjectionToken } from '@angular/core';
5
- import { AXPCommand } from '@acorex/platform/runtime';
6
- import * as _acorex_platform_core from '@acorex/platform/core';
7
- import { AXPExecuteCommandResult, AXPValidationRules, AXPActionMenuItem } from '@acorex/platform/core';
8
- import { AXPWidgetTypesMap, AXPWidgetNode } from '@acorex/platform/layout/widget-core';
9
- import { AXStyleColorType } from '@acorex/cdk/common';
10
- import { AXPopupSizeType } from '@acorex/components/popup';
5
+ import { AXPValidationRules, AXPEntityOp, AXPCategoryEntity, AXPExpressionEvaluatorScope } from '@acorex/platform/core';
6
+ import { AXPWidgetTypesMap } from '@acorex/platform/layout/widget-core';
7
+ import { AXPCommand, AXPExecuteCommandResultPromise } from '@acorex/platform/runtime';
11
8
 
12
9
  declare class AXPWorkflowError extends Error {
13
10
  inner: Error | null;
@@ -117,7 +114,6 @@ interface AXPWorkflowModuleConfigs {
117
114
  };
118
115
  }
119
116
  declare class AXPWorkflowModule {
120
- private _commandSetup;
121
117
  static forRoot(config?: AXPWorkflowModuleConfigs): ModuleWithProviders<AXPWorkflowModule>;
122
118
  static forChild(config?: AXPWorkflowModuleConfigs): ModuleWithProviders<AXPWorkflowModule>;
123
119
  /**
@@ -151,2293 +147,1588 @@ declare class AXPWorkflowService {
151
147
  static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowService>;
152
148
  }
153
149
 
154
- /**
155
- * Base entity with versioning support.
156
- */
157
- interface AXPVersionedEntity {
158
- version: number;
159
- isLatest: boolean;
160
- isPublished: boolean;
161
- }
162
- /**
163
- * Workflow definition stored in database.
164
- * This is the stored format that matches Elsa backend structure.
165
- */
166
- interface AXPStoredWorkflowDefinition extends AXPVersionedEntity {
150
+ interface AXPWorkflowDefinition {
151
+ schemaVersion: "acorex-platform-workflow/v1";
152
+ name: string;
153
+ title?: string | null;
154
+ description?: string | null;
155
+ variables?: AXPVariableDefinition[];
156
+ inputs?: AXPWorkflowInputDescriptor[];
157
+ outputs?: AXPWorkflowOutputDescriptor[];
158
+ graph: AXPWorkflowGraph;
159
+ customProperties?: Record<string, any>;
160
+ /** engine specific (Elsa, ...) */
161
+ extensions?: AXPWorkflowExtensions;
167
162
  /**
168
- * Unique ID of this workflow definition version.
163
+ * Workflow bindings configuration.
164
+ * Defines which entities and events should trigger this workflow.
169
165
  */
166
+ bindings?: AXPWorkflowBinding[];
167
+ }
168
+ interface AXPWorkflowGraph {
169
+ startActivityId: string;
170
+ activities: AXPWorkflowActivityInstance[];
171
+ connections: AXPConnection[];
172
+ /** purely designer */
173
+ designer?: {
174
+ nodes?: Record<string, {
175
+ x: number;
176
+ y: number;
177
+ nodeId?: string;
178
+ }>;
179
+ edges?: Array<{
180
+ from: string;
181
+ to: string;
182
+ vertices?: Array<{
183
+ x: number;
184
+ y: number;
185
+ }>;
186
+ }>;
187
+ };
188
+ }
189
+ interface AXPWorkflowActivityInstance {
170
190
  id: string;
191
+ nodeId?: string;
171
192
  /**
172
- * Unique workflow name (same across all versions).
173
- * This is the primary identifier (replaces definitionId).
193
+ * Activity name - references AXPActivityDefinition.name
194
+ * Used to lookup activity definition for metadata (executionMode, title, etc.)
174
195
  */
175
196
  name: string;
176
197
  /**
177
- * Tenant ID (nullable).
198
+ * Input values for this activity instance.
199
+ * Key-value pairs where keys match input descriptor names from AXPActivityDefinition.inputs
200
+ * Example: { "message": "Hello", "duration": 5000 }
178
201
  */
179
- tenantId?: string | null;
202
+ inputs?: Record<string, any>;
203
+ metadata?: Record<string, any>;
204
+ customProperties?: Record<string, any>;
205
+ /** engine-specific override */
206
+ extensions?: Record<string, any>;
207
+ }
208
+ interface AXPConnection {
209
+ source: {
210
+ activtyName: string;
211
+ port?: string | null;
212
+ };
213
+ target: {
214
+ activtyName: string;
215
+ port?: string | null;
216
+ };
217
+ vertices?: Array<{
218
+ x: number;
219
+ y: number;
220
+ }>;
221
+ }
222
+ interface AXPVariableDefinition {
223
+ name: string;
224
+ type: string;
225
+ isArray?: boolean;
226
+ value?: any;
227
+ storageDriverType?: string | null;
228
+ }
229
+ interface AXPWorkflowPropertyWidget {
230
+ type: AXPWidgetTypesMap[keyof AXPWidgetTypesMap] | string;
231
+ options?: Record<string, any>;
232
+ }
233
+ interface AXPWorkflowInputDescriptor {
234
+ name: string;
235
+ title: string;
236
+ description?: string;
237
+ schema: {
238
+ dataType: string;
239
+ isArray?: boolean;
240
+ nullable?: boolean;
241
+ readonly?: boolean;
242
+ hidden?: boolean | string;
243
+ defaultValue?: any | string | ((context: any | null) => any);
244
+ interface: AXPWorkflowPropertyWidget;
245
+ };
246
+ validations?: AXPValidationRules;
247
+ }
248
+ interface AXPWorkflowOutputDescriptor {
249
+ name: string;
250
+ title: string;
251
+ description?: string;
180
252
  /**
181
- * Description of what the workflow does.
182
- */
183
- description?: string | null;
253
+ * Optional: where this output comes from in your context/memory.
254
+ * Example: "$.result.orderId" or "vars.orderId"
255
+ */
256
+ path?: string;
257
+ metadata?: Record<string, any>;
258
+ schema: {
259
+ isArray?: boolean;
260
+ dataType: string;
261
+ };
262
+ }
263
+ /**
264
+ * Engine-specific extension bag for a workflow.
265
+ * Keep ALL engine-only fields here (Elsa, StepFunctions adapter, etc).
266
+ */
267
+ interface AXPWorkflowExtensions {
184
268
  /**
185
- * Creation timestamp (ISO date-time).
269
+ * Elsa-specific extensions (optional).
186
270
  */
187
- createdAt: string;
271
+ elsa?: AXPElsaWorkflowExtensions;
188
272
  /**
189
- * Version of the tool that produced this definition (e.g. "3.2.0.0").
273
+ * Other engines (future-proof).
274
+ * Example: stepFunctions, logicApps, temporal, ...
190
275
  */
191
- toolVersion?: string | null;
276
+ [engine: string]: any;
277
+ }
278
+ /**
279
+ * Elsa-only fields (Optional).
280
+ * Put strategy/tool/schema/raw payload here to keep Core model global.
281
+ */
282
+ interface AXPElsaWorkflowExtensions {
192
283
  /**
193
- * Materializer name for deserialization.
284
+ * Elsa schema URL (if you want to round-trip exact docs).
285
+ * Example: "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json"
194
286
  */
287
+ schema?: string;
288
+ toolVersion?: string;
195
289
  materializerName?: string;
196
290
  /**
197
- * JSON data (for simple workflows).
291
+ * Elsa strategy/options (engine-level concerns).
198
292
  */
199
- stringData?: string;
293
+ options?: {
294
+ activationStrategyType?: string | null;
295
+ incidentStrategyType?: string | null;
296
+ commitStrategyName?: string | null;
297
+ autoUpdateConsumingWorkflows?: boolean;
298
+ usableAsActivity?: boolean | null;
299
+ activityCategory?: string | null;
300
+ };
200
301
  /**
201
- * Binary data (for complex workflows).
302
+ * If you want lossless Elsa round-trip, keep the raw Elsa definition here.
202
303
  */
203
- binaryData?: Uint8Array;
304
+ rawDefinition?: any;
204
305
  }
205
306
  /**
206
- * Variable definition.
207
- * Matches VariableDefinition from workflow definition schema.
307
+ * Workflow binding configuration.
308
+ * Defines which entities and events should trigger a workflow.
208
309
  */
209
- interface AXPVariableDefinition {
210
- /**
211
- * Variable ID.
212
- */
213
- id?: string;
310
+ interface AXPWorkflowBinding {
214
311
  /**
215
- * Variable name.
216
- */
217
- name: string;
218
- /**
219
- * Type name (e.g., "String", "Int32", "Boolean").
312
+ * Entity types this workflow applies to (e.g., ['ContentManagement.Promotion', 'ContentManagement.Article'])
313
+ * Empty array means applies to all entities with workflow plugin enabled.
220
314
  */
221
- typeName: string;
315
+ entityTypes: string[];
222
316
  /**
223
- * Whether this is an array type.
317
+ * Event types that trigger this workflow (e.g., ['create', 'update'])
318
+ * Uses AXPEntityOp directly (create, update, delete, etc.)
224
319
  */
225
- isArray?: boolean;
320
+ eventTypes: AXPEntityOp[];
226
321
  /**
227
- * Variable value (as string expression or literal).
322
+ * Whether this binding is enabled
228
323
  */
229
- value?: string | null;
324
+ enabled: boolean;
230
325
  /**
231
- * Storage driver type name (for custom storage).
326
+ * Optional conditions for when to trigger (future enhancement)
232
327
  */
233
- storageDriverTypeName?: string | null;
328
+ conditions?: any;
234
329
  }
330
+
331
+ /**
332
+ * Workflow status.
333
+ */
334
+ type AXPWorkflowStatus = 'Running' | 'Finished';
335
+ /**
336
+ * Workflow sub-status.
337
+ */
338
+ type AXPWorkflowSubStatus = 'Pending' | 'Executing' | 'Suspended' | 'Finished' | 'Cancelled' | 'Faulted';
235
339
  /**
236
- * Workflow input definition.
237
- * Matches WorkflowInputDefinition from workflow definition schema.
340
+ * Activity status.
341
+ */
342
+ type AXPActivityStatus = 'Running' | 'Completed' | 'Canceled' | 'Faulted';
343
+ /**
344
+ * Exception state.
238
345
  */
239
- interface AXPWorkflowInputDefinition {
346
+ interface AXPExceptionState {
240
347
  /**
241
- * Input type (e.g., "String", "Int32", "Object").
348
+ * Exception type name.
242
349
  */
243
350
  type: string;
244
351
  /**
245
- * Input name.
246
- */
247
- name: string;
248
- /**
249
- * Display name.
250
- */
251
- displayName?: string;
252
- /**
253
- * Description.
254
- */
255
- description?: string;
256
- /**
257
- * Category for grouping.
352
+ * Exception message.
258
353
  */
259
- category?: string;
354
+ message: string;
260
355
  /**
261
- * UI hint (widget type).
356
+ * Stack trace (nullable).
262
357
  */
263
- uiHint?: string;
358
+ stackTrace?: string | null;
264
359
  /**
265
- * Storage driver type (for custom storage).
360
+ * Inner exception (nullable).
266
361
  */
267
- storageDriverType?: string | null;
362
+ innerException?: AXPExceptionState | null;
268
363
  }
269
364
  /**
270
- * Workflow output definition.
271
- * Matches WorkflowOutputDefinition from workflow definition schema.
365
+ * Activity incident.
272
366
  */
273
- interface AXPWorkflowOutputDefinition {
274
- /**
275
- * Output type (e.g., "String", "Int32", "Object").
276
- */
277
- type: string;
367
+ interface AXPActivityIncident {
278
368
  /**
279
- * Output name.
369
+ * Activity ID that caused the incident.
280
370
  */
281
- name: string;
371
+ activityId: string;
282
372
  /**
283
- * Display name.
373
+ * Activity node ID.
284
374
  */
285
- displayName?: string;
375
+ activityNodeId: string;
286
376
  /**
287
- * Description.
377
+ * Activity type.
288
378
  */
289
- description?: string;
379
+ activityType: string;
290
380
  /**
291
- * Category for grouping.
381
+ * Incident message.
292
382
  */
293
- category?: string;
294
- }
295
- /**
296
- * Expression.
297
- * Used for dynamic values in activities.
298
- */
299
- interface AXPExpression {
383
+ message: string;
300
384
  /**
301
- * Expression type (e.g., "Literal", "JavaScript", "Liquid").
385
+ * Exception (nullable).
302
386
  */
303
- type: string;
387
+ exception?: AXPExceptionState | null;
304
388
  /**
305
- * Expression value.
389
+ * Timestamp (ISO date-time).
306
390
  */
307
- value?: any;
391
+ timestamp: string;
308
392
  }
309
393
  /**
310
- * Input value wrapper.
311
- * Wraps an expression with type information.
394
+ * Workflow fault state.
312
395
  */
313
- interface AXPInputValue {
396
+ interface AXPWorkflowFaultState {
314
397
  /**
315
- * Type name.
398
+ * Exception (nullable).
316
399
  */
317
- typeName: string;
400
+ exception?: AXPExceptionState | null;
401
+ /**
402
+ * Fault message.
403
+ */
404
+ message: string;
318
405
  /**
319
- * Expression (or null).
406
+ * Faulted activity ID (nullable).
320
407
  */
321
- expression?: AXPExpression | null;
408
+ faultedActivityId?: string | null;
322
409
  }
323
410
  /**
324
- * Output value wrapper.
325
- * References memory location.
411
+ * Bookmark.
326
412
  */
327
- interface AXPOutputValue {
413
+ interface AXPBookmark {
328
414
  /**
329
- * Type name.
415
+ * Bookmark ID.
330
416
  */
331
- typeName: string;
417
+ id: string;
332
418
  /**
333
- * Memory reference (or null).
419
+ * Bookmark name.
334
420
  */
335
- memoryReference?: {
336
- id: string;
337
- } | null;
338
- }
339
- /**
340
- * Position (for visual layout).
341
- */
342
- interface AXPPosition {
343
- x: number;
344
- y: number;
345
- }
346
- /**
347
- * Endpoint (connection point).
348
- */
349
- interface AXPEndpoint {
421
+ name: string;
350
422
  /**
351
- * Activity ID.
423
+ * Bookmark hash.
352
424
  */
353
- activity: string;
425
+ hash: string;
354
426
  /**
355
- * Port name (nullable).
427
+ * Bookmark payload (nullable).
356
428
  */
357
- port?: string | null;
358
- }
359
- /**
360
- * Connection between activities.
361
- */
362
- interface AXPConnection {
429
+ payload?: any | null;
363
430
  /**
364
- * Source endpoint.
431
+ * Activity node ID.
365
432
  */
366
- source: AXPEndpoint;
433
+ activityNodeId: string;
367
434
  /**
368
- * Target endpoint.
435
+ * Activity instance ID.
369
436
  */
370
- target: AXPEndpoint;
437
+ activityInstanceId: string;
371
438
  /**
372
- * Connection vertices (for curved paths).
439
+ * Auto burn flag.
373
440
  */
374
- vertices?: AXPPosition[];
375
- }
376
- /**
377
- * Variable model (for flowchart variables).
378
- */
379
- interface AXPVariableModel {
380
- id: string;
381
- name: string;
382
- typeName: string;
383
- value?: string | null;
384
- storageDriverTypeName?: string | null;
385
- }
386
- /**
387
- * Metadata (designer annotations).
388
- */
389
- interface AXPMetadata {
390
- [key: string]: any;
391
- }
392
- /**
393
- * Custom properties (free-form bag).
394
- */
395
- interface AXPCustomProperties {
441
+ autoBurn?: boolean;
396
442
  /**
397
- * Connections that reference non-existent activities.
443
+ * Callback method name (nullable).
398
444
  */
399
- notFoundConnections?: AXPConnection[];
445
+ callbackMethodName?: string | null;
400
446
  /**
401
- * Additional custom properties.
447
+ * Metadata (nullable).
402
448
  */
403
- [key: string]: any;
449
+ metadata?: Record<string, string> | null;
404
450
  }
405
451
  /**
406
- * Base activity (workflow definition format).
407
- * Matches Activity from workflow definition schema.
408
- * Note: This is the workflow definition format, not the frontend Activity class.
452
+ * Completion callback state.
409
453
  */
410
- interface AXPActivity {
454
+ interface AXPCompletionCallbackState {
411
455
  /**
412
- * Activity ID.
456
+ * Owner activity instance ID.
413
457
  */
414
- id: string;
458
+ ownerInstanceId: string;
415
459
  /**
416
- * Node ID (for visual designer).
460
+ * Child activity node ID.
417
461
  */
418
- nodeId: string;
462
+ childNodeId: string;
419
463
  /**
420
- * Activity name.
464
+ * Method name (nullable).
421
465
  */
422
- name?: string | null;
466
+ methodName?: string | null;
467
+ }
468
+ /**
469
+ * Variable (for activity context).
470
+ */
471
+ interface AXPActivityVariable {
423
472
  /**
424
- * Activity type (e.g., "workflow-activity:write-line", "workflow-activity:if").
473
+ * Variable ID.
425
474
  */
426
- type: string;
475
+ id: string;
427
476
  /**
428
- * Activity version.
477
+ * Variable name.
429
478
  */
430
- version: number;
479
+ name: string;
431
480
  /**
432
- * Execution mode for this activity instance.
433
- * Determines where this activity should be executed:
434
- * - 'frontend': Execute in browser (UI activities like dialogs, toasts, navigation)
435
- * - 'backend': Execute in backend (business logic, database operations, API calls)
436
- * - 'both': Execute in both frontend and backend (hybrid activities)
437
- *
438
- * If not specified, falls back to ActivityDescriptor's executionMode.
439
- * This allows per-instance override of the default execution mode.
440
- *
441
- * @example
442
- * ```json
443
- * {
444
- * "id": "show-dialog",
445
- * "type": "workflow-activity:show-dialog",
446
- * "executionMode": "frontend"
447
- * }
448
- * ```
481
+ * Type name.
449
482
  */
450
- executionMode?: 'frontend' | 'backend' | 'both';
483
+ typeName: string;
451
484
  /**
452
- * Custom properties.
485
+ * Is array flag.
453
486
  */
454
- customProperties?: AXPCustomProperties;
487
+ isArray?: boolean;
455
488
  /**
456
- * Metadata (designer annotations).
489
+ * Variable value (nullable).
457
490
  */
458
- metadata?: AXPMetadata;
491
+ value?: any | null;
459
492
  /**
460
- * Additional type-specific properties.
493
+ * Storage driver type name (nullable).
461
494
  */
462
- [key: string]: any;
495
+ storageDriverTypeName?: string | null;
463
496
  }
464
497
  /**
465
- * Flowchart activity (workflow definition format).
466
- * This is the root activity that contains all other activities.
498
+ * Activity execution context state.
467
499
  */
468
- interface AXPFlowchart extends AXPActivity {
500
+ interface AXPActivityExecutionContextState {
469
501
  /**
470
- * Type must be "workflow-activity:flowchart".
502
+ * Context ID (activity instance ID).
471
503
  */
472
- type: "workflow-activity:flowchart";
504
+ id: string;
473
505
  /**
474
- * Activities in this flowchart.
506
+ * Parent context ID (nullable).
475
507
  */
476
- activities: AXPActivity[];
508
+ parentContextId?: string | null;
477
509
  /**
478
- * Variables in this flowchart.
510
+ * Scheduled activity node ID.
479
511
  */
480
- variables?: AXPVariableModel[];
512
+ scheduledActivityNodeId: string;
481
513
  /**
482
- * Connections between activities.
514
+ * Owner activity node ID (nullable).
483
515
  */
484
- connections: AXPConnection[];
485
- }
486
- /**
487
- * Simplified workflow definition for JSON files.
488
- * This is what developers write - system fields are added automatically.
489
- */
490
- interface AXPWorkflowDefinitionJson {
516
+ ownerActivityNodeId?: string | null;
491
517
  /**
492
- * Unique workflow name (used as key/identifier).
493
- * This is the only required field for identification.
494
- * Similar to entity system where 'name' is the unique key.
518
+ * Properties bag.
495
519
  */
496
- name: string;
520
+ properties: Record<string, any>;
497
521
  /**
498
- * Display title (human-readable name shown in UI).
499
- * Similar to entity system where 'title' is the display name.
522
+ * Activity state (evaluated properties) (nullable).
500
523
  */
501
- title?: string | null;
524
+ activityState?: Record<string, any> | null;
502
525
  /**
503
- * Description.
526
+ * Dynamic variables.
504
527
  */
505
- description?: string | null;
528
+ dynamicVariables: AXPActivityVariable[];
506
529
  /**
507
- * Workflow variables.
530
+ * Activity status.
508
531
  */
509
- variables?: AXPVariableDefinition[];
532
+ status: AXPActivityStatus;
510
533
  /**
511
- * Workflow inputs.
534
+ * Is executing flag.
512
535
  */
513
- inputs?: AXPWorkflowInputDefinition[];
536
+ isExecuting: boolean;
514
537
  /**
515
- * Workflow outputs.
538
+ * Fault count.
516
539
  */
517
- outputs?: AXPWorkflowOutputDefinition[];
540
+ faultCount: number;
518
541
  /**
519
- * Workflow outcomes.
542
+ * Started at timestamp (ISO date-time).
520
543
  */
521
- outcomes?: string[];
544
+ startedAt: string;
522
545
  /**
523
- * Custom properties.
546
+ * Completed at timestamp (ISO date-time, nullable).
524
547
  */
525
- customProperties?: AXPCustomProperties;
548
+ completedAt?: string | null;
526
549
  /**
527
- * Workflow options.
528
- */
529
- options?: AXPWorkflowOptions;
530
- /**
531
- * Root activity (Flowchart).
550
+ * Tag (nullable).
532
551
  */
533
- root: AXPFlowchart;
552
+ tag?: any | null;
534
553
  }
535
554
  /**
536
- * Complete workflow definition (v3.0.0 format).
537
- * This is the core workflow definition without system fields.
538
- * System fields ($schema, tenantId, createdAt, toolVersion, isPublished, id, version, isLatest, isReadonly, isSystem)
539
- * are managed by the entity system and stored in entity model.
555
+ * Workflow state (internal execution state).
540
556
  */
541
- interface AXPWorkflowDefinition {
557
+ interface AXPWorkflowState {
542
558
  /**
543
- * Unique workflow name (used as key/identifier, same across all versions).
544
- * This is the primary identifier for the workflow.
559
+ * State ID.
545
560
  */
546
- name: string;
561
+ id: string;
547
562
  /**
548
- * Display title (human-readable name shown in UI).
563
+ * Workflow definition ID.
549
564
  */
550
- title?: string | null;
565
+ definitionId: string;
551
566
  /**
552
- * Description.
567
+ * Workflow definition version.
553
568
  */
554
- description?: string | null;
569
+ definitionVersion: number;
555
570
  /**
556
- * Workflow variables.
571
+ * Correlation ID (nullable).
557
572
  */
558
- variables?: AXPVariableDefinition[];
573
+ correlationId?: string | null;
559
574
  /**
560
- * Workflow inputs.
575
+ * Workflow status.
561
576
  */
562
- inputs?: AXPWorkflowInputDefinition[];
577
+ status: AXPWorkflowStatus;
563
578
  /**
564
- * Workflow outputs.
579
+ * Workflow sub-status.
565
580
  */
566
- outputs?: AXPWorkflowOutputDefinition[];
581
+ subStatus: AXPWorkflowSubStatus;
567
582
  /**
568
- * Workflow outcomes.
583
+ * Bookmarks.
569
584
  */
570
- outcomes?: string[];
585
+ bookmarks: AXPBookmark[];
571
586
  /**
572
- * Custom properties.
587
+ * Incidents.
573
588
  */
574
- customProperties?: AXPCustomProperties;
589
+ incidents: AXPActivityIncident[];
575
590
  /**
576
- * Workflow options.
591
+ * Fault (nullable).
577
592
  */
578
- options?: AXPWorkflowOptions;
593
+ fault?: AXPWorkflowFaultState | null;
579
594
  /**
580
- * @deprecated Use options.usableAsActivity instead.
595
+ * Completion callbacks.
581
596
  */
582
- usableAsActivity?: boolean | null;
597
+ completionCallbacks: AXPCompletionCallbackState[];
583
598
  /**
584
- * Root activity (Flowchart).
599
+ * Activity execution contexts.
585
600
  */
586
- root: AXPFlowchart;
587
- }
588
- /**
589
- * Workflow configuration options.
590
- */
591
- interface AXPWorkflowOptions {
601
+ activityExecutionContexts: AXPActivityExecutionContextState[];
592
602
  /**
593
- * Activation strategy type.
603
+ * Input data.
594
604
  */
595
- activationStrategyType?: string | null;
605
+ input: Record<string, any>;
596
606
  /**
597
- * Whether workflow can be used as an activity.
607
+ * Output data.
598
608
  */
599
- usableAsActivity?: boolean | null;
609
+ output: Record<string, any>;
600
610
  /**
601
- * Auto-update consuming workflows.
611
+ * Properties bag.
602
612
  */
603
- autoUpdateConsumingWorkflows?: boolean;
613
+ properties: Record<string, any>;
604
614
  /**
605
- * Activity category (if usable as activity).
615
+ * Created at timestamp (ISO date-time).
606
616
  */
607
- activityCategory?: string | null;
617
+ createdAt: string;
608
618
  /**
609
- * Incident strategy type.
619
+ * Updated at timestamp (ISO date-time).
610
620
  */
611
- incidentStrategyType?: string | null;
621
+ updatedAt: string;
612
622
  /**
613
- * Commit strategy name.
623
+ * Finished at timestamp (ISO date-time, nullable).
614
624
  */
615
- commitStrategyName?: string | null;
625
+ finishedAt?: string | null;
616
626
  }
617
-
618
627
  /**
619
- * Workflow definition loader interface.
620
- * Implement this to provide workflow definitions from various sources (JSON files, database, etc.).
628
+ * Workflow instance (stored in database).
629
+ * This matches the Elsa Workflow Instance schema for backend compatibility.
621
630
  */
622
- interface AXPWorkflowDefinitionLoader {
631
+ interface AXPWorkflowInstance {
623
632
  /**
624
- * Get workflow definition by name (unique key).
625
- * @param name - The workflow name (unique key)
626
- * @returns Workflow definition or null if not found
633
+ * Schema reference.
627
634
  */
628
- get(name: string): Promise<AXPWorkflowDefinition | null>;
635
+ $schema?: string;
629
636
  /**
630
- * Get all available workflow names.
631
- * Used for preloading and discovery.
632
- * @returns Array of workflow names
637
+ * Unique instance ID.
633
638
  */
634
- getAllNames?(): Promise<string[]>;
635
- }
636
- /**
637
- * Workflow definition preloader interface.
638
- * Implement this to provide a list of workflow definitions that should be preloaded.
639
- */
640
- interface AXPWorkflowDefinitionPreloader {
639
+ id: string;
641
640
  /**
642
- * Get list of workflow definition IDs to preload.
643
- * @returns Array of definition IDs
641
+ * Workflow definition ID.
644
642
  */
645
- preload(): string[];
646
- }
647
- /**
648
- * Injection token for workflow definition loaders.
649
- * Multiple loaders can be provided (multi: true).
650
- */
651
- declare const AXP_WORKFLOW_DEFINITION_LOADER: InjectionToken<AXPWorkflowDefinitionLoader>;
652
- /**
653
- * Resolver service for workflow definitions.
654
- * Aggregates all registered loaders and resolves workflow definitions.
655
- */
656
- declare class AXPWorkflowDefinitionResolver {
657
- private loaders;
643
+ definitionId: string;
658
644
  /**
659
- * Get workflow definition by name (unique key).
660
- * Tries all registered loaders until one returns a definition.
661
- * @param name - The workflow name (unique key)
662
- * @returns Workflow definition or null if not found
645
+ * Workflow definition version ID.
663
646
  */
664
- get(name: string): Promise<AXPWorkflowDefinition | null>;
647
+ definitionVersionId: string;
665
648
  /**
666
- * Get all available workflow names from all loaders.
667
- * @returns Array of unique workflow names
649
+ * Workflow definition version number.
668
650
  */
669
- getAllNames(): Promise<string[]>;
670
- static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowDefinitionResolver, never>;
671
- static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowDefinitionResolver>;
672
- }
673
-
674
- /**
675
- * Registry service for workflow definitions.
676
- * Caches loaded definitions and provides change notifications.
677
- */
678
- declare class AXPWorkflowDefinitionRegistryService {
679
- private resolver;
680
- private cache;
681
- private onChanged;
651
+ version: number;
682
652
  /**
683
- * Observable for workflow definition changes.
653
+ * Parent workflow instance ID (nullable, for child workflows).
684
654
  */
685
- get onChanged$(): rxjs.Observable<{
686
- name: string;
687
- action: "registered" | "updated" | "removed";
688
- }>;
655
+ parentWorkflowInstanceId?: string | null;
656
+ /**
657
+ * Workflow state (internal execution state).
658
+ */
659
+ workflowState: AXPWorkflowState;
660
+ /**
661
+ * Workflow status.
662
+ */
663
+ status: AXPWorkflowStatus;
689
664
  /**
690
- * Get workflow definition by name (unique key).
691
- * Uses cache if available, otherwise loads from resolver.
692
- * @param name - The workflow name (unique key)
693
- * @returns Workflow definition or null if not found
665
+ * Workflow sub-status.
694
666
  */
695
- get(name: string): Promise<AXPWorkflowDefinition | null>;
667
+ subStatus: AXPWorkflowSubStatus;
696
668
  /**
697
- * Register a workflow definition in the cache.
698
- * @param definition - The workflow definition to register
669
+ * Correlation ID (nullable).
699
670
  */
700
- register(definition: AXPWorkflowDefinition): void;
671
+ correlationId?: string | null;
701
672
  /**
702
- * Update a workflow definition in the cache.
703
- * @param definition - The updated workflow definition
673
+ * Instance name (nullable).
704
674
  */
705
- update(definition: AXPWorkflowDefinition): void;
675
+ name?: string | null;
706
676
  /**
707
- * Remove a workflow definition from the cache.
708
- * @param name - The workflow name to remove
677
+ * Incident count.
709
678
  */
710
- remove(name: string): void;
679
+ incidentCount: number;
711
680
  /**
712
- * Clear all cached workflow definitions.
681
+ * Created at timestamp (ISO date-time).
713
682
  */
714
- clear(): void;
683
+ createdAt: string;
715
684
  /**
716
- * Check if a workflow definition is cached.
717
- * @param definitionId - The workflow definition ID
718
- * @returns True if cached, false otherwise
685
+ * Updated at timestamp (ISO date-time).
719
686
  */
720
- has(definitionId: string): boolean;
687
+ updatedAt: string;
721
688
  /**
722
- * Get all cached workflow definition IDs.
723
- * @returns Array of definition IDs (only those that have been loaded)
689
+ * Finished at timestamp (ISO date-time, nullable).
724
690
  */
725
- getAllIds(): string[];
726
- static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowDefinitionRegistryService, never>;
727
- static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowDefinitionRegistryService>;
691
+ finishedAt?: string | null;
728
692
  }
729
693
 
730
694
  /**
731
- * Workflow status.
732
- */
733
- type AXPWorkflowStatus = 'Running' | 'Finished';
734
- /**
735
- * Workflow sub-status.
736
- */
737
- type AXPWorkflowSubStatus = 'Pending' | 'Executing' | 'Suspended' | 'Finished' | 'Cancelled' | 'Faulted';
738
- /**
739
- * Activity status.
695
+ * Activity Category - Extends AXPCategoryEntity for consistency and performance
696
+ *
697
+ * Inherited properties from AXPCategoryEntity:
698
+ * - id: string - Unique identifier
699
+ * - title: string - Display name
700
+ * - description?: string - Category description
701
+ * - parentId?: string - Parent category ID
702
+ * - childrenCount: number - Direct child categories count (enables lazy loading)
703
+ * - itemsCount?: number - Direct activities count
704
+ * - totalChildrenCount?: number - Total nested categories (optional, for analytics)
705
+ * - totalItemsCount?: number - Total activities in tree (optional, for analytics)
740
706
  */
741
- type AXPActivityStatus = 'Running' | 'Completed' | 'Canceled' | 'Faulted';
707
+ interface AXPActivityCategory extends AXPCategoryEntity {
708
+ }
742
709
  /**
743
- * Exception state.
710
+ * Activity Definition - Metadata for UI and tooling.
711
+ * Contains all metadata needed for displaying activities in toolbox and designer.
712
+ * The `name` property is used as the command key for execution.
744
713
  */
745
- interface AXPExceptionState {
714
+ interface AXPActivityDefinition {
746
715
  /**
747
- * Exception type name.
716
+ * Activity name - used as command key for execution.
717
+ * This is the unique identifier for the activity.
718
+ */
719
+ name: string;
720
+ /**
721
+ * Activity type (e.g., "workflow-activity:check-permission").
748
722
  */
749
723
  type: string;
750
724
  /**
751
- * Exception message.
725
+ * Display name for UI.
752
726
  */
753
- message: string;
727
+ title?: string;
754
728
  /**
755
- * Stack trace (nullable).
729
+ * Description of what the activity does.
756
730
  */
757
- stackTrace?: string | null;
731
+ description?: string;
758
732
  /**
759
- * Inner exception (nullable).
733
+ * Category for grouping in toolbox.
760
734
  */
761
- innerException?: AXPExceptionState | null;
762
- }
763
- /**
764
- * Activity incident.
765
- */
766
- interface AXPActivityIncident {
735
+ category?: string;
767
736
  /**
768
- * Activity ID that caused the incident.
737
+ * Icon name or class.
769
738
  */
770
- activityId: string;
739
+ icon?: string;
771
740
  /**
772
- * Activity node ID.
741
+ * Where this activity should be executed.
742
+ * - 'frontend': Execute in browser (UI activities, console, events)
743
+ * - 'backend': Execute in backend (business logic, API calls)
744
+ * - 'both': Execute in both frontend and backend (hybrid activities)
745
+ *
746
+ * Default: 'frontend'
773
747
  */
774
- activityNodeId: string;
748
+ executionMode?: 'frontend' | 'backend' | 'both';
775
749
  /**
776
- * Activity type.
750
+ * Input descriptors.
777
751
  */
778
- activityType: string;
752
+ inputs?: AXPWorkflowInputDescriptor[];
779
753
  /**
780
- * Incident message.
754
+ * Output descriptors.
781
755
  */
782
- message: string;
756
+ outputs?: AXPWorkflowOutputDescriptor[];
783
757
  /**
784
- * Exception (nullable).
758
+ * Static outcomes (exit points).
759
+ * Example: ['Done', 'Success', 'Failed']
785
760
  */
786
- exception?: AXPExceptionState | null;
761
+ outcomes?: string[];
787
762
  /**
788
- * Timestamp (ISO date-time).
763
+ * Whether this activity is browsable in the toolbox.
764
+ * Default: true
789
765
  */
790
- timestamp: string;
766
+ isBrowsable?: boolean;
767
+ /**
768
+ * Whether this activity is a container (can have children).
769
+ * Default: false
770
+ */
771
+ isContainer?: boolean;
791
772
  }
792
773
  /**
793
- * Workflow fault state.
774
+ * Activity - Command with specific TResult structure.
775
+ * Extends AXPCommand with a fixed TResult that includes output and outcomes.
776
+ * No additional properties beyond AXPCommand - pure command interface.
794
777
  */
795
- interface AXPWorkflowFaultState {
778
+ interface AXPActivity<TInput = any, TOutput = any> extends AXPCommand<TInput, {
779
+ output: TOutput;
780
+ outcomes: Record<string, any>;
781
+ }> {
796
782
  /**
797
- * Exception (nullable).
783
+ * Execute the activity as a command.
784
+ * @param input - Activity input data
785
+ * @returns Promise with output and outcomes
798
786
  */
799
- exception?: AXPExceptionState | null;
787
+ execute(input: TInput): AXPExecuteCommandResultPromise<{
788
+ output: TOutput;
789
+ outcomes: Record<string, any>;
790
+ }>;
791
+ }
792
+
793
+ type AXPActivityProviderToken = AXPActivityProvider | Promise<AXPActivityProvider>;
794
+ declare const AXP_ACTIVITY_PROVIDER: InjectionToken<AXPActivityProviderToken[]>;
795
+ interface AXPActivityProvider {
800
796
  /**
801
- * Fault message.
797
+ * Get list of activity definitions for a category.
798
+ * @param categoryId - Category ID to filter activities
799
+ * @returns Promise of activity definitions array
802
800
  */
803
- message: string;
801
+ getList(categoryId: string): Promise<AXPActivityDefinition[]>;
804
802
  /**
805
- * Faulted activity ID (nullable).
803
+ * Get activity definition by name (unique identifier).
804
+ * The name is used as the command key for execution.
805
+ * @param name - Activity name (unique identifier and command key)
806
+ * @returns Promise of activity definition or undefined if not found
806
807
  */
807
- faultedActivityId?: string | null;
808
+ getById(name: string): Promise<AXPActivityDefinition | undefined>;
809
+ }
810
+ type AXPActivityCategoryProviderToken = AXPActivityCategoryProvider | Promise<AXPActivityCategoryProvider>;
811
+ declare const AXP_ACTIVITY_CATEGORY_PROVIDER: InjectionToken<AXPActivityCategoryProviderToken[]>;
812
+ interface AXPActivityCategoryProvider {
813
+ getList(parentId?: string): Promise<AXPActivityCategory[]>;
814
+ getById(id: string): Promise<AXPActivityCategory | undefined>;
808
815
  }
816
+
809
817
  /**
810
- * Bookmark.
811
- */
812
- interface AXPBookmark {
813
- /**
814
- * Bookmark ID.
818
+ * Optimized Activity Definition Service
819
+ *
820
+ * Manages activity definitions (metadata) for UI and tooling.
821
+ * Similar to AXPReportDefinitionService - only handles metadata, not execution.
822
+ *
823
+ * Performance optimizations:
824
+ * 1. Uses childrenCount to determine if category has children (no query needed)
825
+ * 2. Uses itemsCount to determine if category has activities (no query needed)
826
+ * 3. Aggressive caching prevents duplicate API calls
827
+ * 4. Single pending request per resource prevents race conditions
828
+ * 5. Lazy loading - only loads data when needed
829
+ */
830
+ declare class AXPActivityDefinitionService {
831
+ private readonly categoryProviders;
832
+ private readonly activityProviders;
833
+ /** Cache for categories by id - O(1) lookup */
834
+ private categoriesById;
835
+ /** Cache for categories by parentId - O(1) lookup */
836
+ private categoriesByParentId;
837
+ /** Cache for activity definitions by categoryId - O(1) lookup */
838
+ private activitiesByCategory;
839
+ /** Cache for individual activity definitions by name - O(1) lookup */
840
+ private activitiesByName;
841
+ /** Track which provider index owns each category (by category ID) */
842
+ private categoryOwnership;
843
+ /** Pending API requests to prevent duplicate calls */
844
+ private pendingCategoriesRequests;
845
+ private pendingActivitiesRequests;
846
+ private pendingActivityRequests;
847
+ /**
848
+ * Get categories by parentId with aggressive caching
849
+ *
850
+ * Optimization: Returns cached result immediately if available,
851
+ * preventing unnecessary API calls during navigation
852
+ *
853
+ * @param parentId - Parent category ID (undefined = root categories)
854
+ * @returns Array of categories with count metadata (childrenCount, itemsCount)
815
855
  */
816
- id: string;
856
+ getCategories(parentId?: string): Promise<AXPActivityCategory[]>;
817
857
  /**
818
- * Bookmark name.
858
+ * Get single category by ID with O(1) lookup
859
+ *
860
+ * Optimization: Uses Map for instant retrieval, falls back to
861
+ * searching cache, then providers if not found
819
862
  */
820
- name: string;
863
+ getCategoryById(categoryId: string): Promise<AXPActivityCategory | undefined>;
821
864
  /**
822
- * Bookmark hash.
865
+ * Get category path from root to specified category
866
+ *
867
+ * Optimization: Builds path using cached categories only
823
868
  */
824
- hash: string;
869
+ getCategoriesPathById(categoryId: string): Promise<AXPActivityCategory[]>;
825
870
  /**
826
- * Bookmark payload (nullable).
871
+ * Get activity definitions for a category with smart caching
872
+ *
873
+ * Optimization: Checks itemsCount before querying
874
+ * - If itemsCount = 0, returns empty array (no API call)
875
+ * - If itemsCount > 0, loads and caches activity definitions
876
+ * - Returns cached result on subsequent calls
877
+ *
878
+ * @param categoryId - Category ID to get activity definitions from
879
+ * @returns Array of activity definitions
827
880
  */
828
- payload?: any | null;
881
+ getActivitiesByCategoryId(categoryId: string): Promise<AXPActivityDefinition[]>;
829
882
  /**
830
- * Activity node ID.
883
+ * Get single activity definition by name with O(1) lookup
884
+ *
885
+ * Optimization: Uses Map for instant retrieval
886
+ *
887
+ * @param name - Activity name (unique identifier and command key)
888
+ * @returns Activity definition or undefined if not found
831
889
  */
832
- activityNodeId: string;
890
+ getActivityByName(name: string): Promise<AXPActivityDefinition | undefined>;
833
891
  /**
834
- * Activity instance ID.
892
+ * Get category ID containing a specific activity definition
893
+ *
894
+ * Optimization: Searches cache first, loads on-demand if needed
835
895
  */
836
- activityInstanceId: string;
896
+ getCategoryIdByActivityName(activityName: string): Promise<string | undefined>;
837
897
  /**
838
- * Auto burn flag.
898
+ * Get category path for an activity
839
899
  */
840
- autoBurn?: boolean;
900
+ getCategoriesPathByActivityName(activityName: string): Promise<AXPActivityCategory[]>;
841
901
  /**
842
- * Callback method name (nullable).
902
+ * Load categories from providers and cache results
903
+ *
904
+ * Optimization: Tracks provider ownership to avoid unnecessary API calls
905
+ * - For root (parentId = undefined): Query ALL providers
906
+ * - For children: Only query the provider that owns the parent
843
907
  */
844
- callbackMethodName?: string | null;
908
+ private loadCategoriesFromProviders;
845
909
  /**
846
- * Metadata (nullable).
910
+ * Get the provider index that owns a specific category
911
+ *
912
+ * @returns Array with provider index, or null if ownership unknown (query all)
847
913
  */
848
- metadata?: Record<string, string> | null;
849
- }
850
- /**
851
- * Completion callback state.
852
- */
853
- interface AXPCompletionCallbackState {
914
+ private getProviderIndexForCategory;
854
915
  /**
855
- * Owner activity instance ID.
916
+ * Load activity definitions from providers and cache results
917
+ *
918
+ * Optimization: Only queries the provider that owns the category
919
+ * Uses provider INDEX to match category provider with activity provider
856
920
  */
857
- ownerInstanceId: string;
921
+ private loadActivitiesFromProviders;
858
922
  /**
859
- * Child activity node ID.
923
+ * Load single activity definition from providers and cache result
860
924
  */
861
- childNodeId: string;
925
+ private loadActivityFromProviders;
862
926
  /**
863
- * Method name (nullable).
927
+ * Breadth-first search through category hierarchy
864
928
  */
865
- methodName?: string | null;
866
- }
867
- /**
868
- * Variable (for activity context).
869
- */
870
- interface AXPActivityVariable {
929
+ private searchCategoryInHierarchy;
871
930
  /**
872
- * Variable ID.
931
+ * Check if category has children (uses cached count)
873
932
  */
874
- id: string;
933
+ categoryHasChildren(categoryId: string): boolean;
875
934
  /**
876
- * Variable name.
935
+ * Check if category has activities (uses cached count)
877
936
  */
878
- name: string;
937
+ categoryHasActivities(categoryId: string): boolean;
879
938
  /**
880
- * Type name.
939
+ * Clear all caches
881
940
  */
882
- typeName: string;
941
+ clearAllCache(): void;
883
942
  /**
884
- * Is array flag.
943
+ * Clear categories cache only
885
944
  */
886
- isArray?: boolean;
945
+ clearCategoriesCache(): void;
887
946
  /**
888
- * Variable value (nullable).
947
+ * Clear activities cache only
889
948
  */
890
- value?: any | null;
891
- /**
892
- * Storage driver type name (nullable).
893
- */
894
- storageDriverTypeName?: string | null;
949
+ clearActivitiesCache(): void;
950
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPActivityDefinitionService, never>;
951
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPActivityDefinitionService>;
895
952
  }
953
+
896
954
  /**
897
- * Activity execution context state.
955
+ * Represents a workflow task that needs to be executed.
956
+ * Inspired by Temporal's Activity Tasks and Camunda's External Tasks.
898
957
  */
899
- interface AXPActivityExecutionContextState {
900
- /**
901
- * Context ID (activity instance ID).
902
- */
903
- id: string;
904
- /**
905
- * Parent context ID (nullable).
906
- */
907
- parentContextId?: string | null;
908
- /**
909
- * Scheduled activity node ID.
910
- */
911
- scheduledActivityNodeId: string;
912
- /**
913
- * Owner activity node ID (nullable).
914
- */
915
- ownerActivityNodeId?: string | null;
916
- /**
917
- * Properties bag.
918
- */
919
- properties: Record<string, any>;
920
- /**
921
- * Activity state (evaluated properties) (nullable).
922
- */
923
- activityState?: Record<string, any> | null;
958
+ interface AXPWorkflowTask {
924
959
  /**
925
- * Dynamic variables.
960
+ * Unique token for this task (used for completion/security).
926
961
  */
927
- dynamicVariables: AXPActivityVariable[];
962
+ taskToken: string;
928
963
  /**
929
- * Activity status.
964
+ * Activity ID from workflow definition.
930
965
  */
931
- status: AXPActivityStatus;
966
+ activityId: string;
932
967
  /**
933
- * Is executing flag.
968
+ * Activity type (e.g., 'workflow-activity:show-toast').
934
969
  */
935
- isExecuting: boolean;
970
+ activityType: string;
936
971
  /**
937
- * Fault count.
972
+ * Human-readable activity name.
938
973
  */
939
- faultCount: number;
974
+ activityName?: string;
940
975
  /**
941
- * Started at timestamp (ISO date-time).
976
+ * Where this task should be executed.
977
+ * - 'frontend': Execute in browser (UI activities, console, events)
978
+ * - 'backend': Execute in backend (business logic, API calls)
979
+ * - 'both': Execute in both frontend and backend (hybrid activities)
942
980
  */
943
- startedAt: string;
981
+ executionMode: 'frontend' | 'backend' | 'both';
944
982
  /**
945
- * Completed at timestamp (ISO date-time, nullable).
983
+ * Input data for the activity (for frontend activities).
946
984
  */
947
- completedAt?: string | null;
985
+ input?: Record<string, any>;
948
986
  /**
949
- * Tag (nullable).
987
+ * Configuration for the activity (for frontend activities).
950
988
  */
951
- tag?: any | null;
989
+ config?: Record<string, any>;
952
990
  }
953
991
  /**
954
- * Workflow state (internal execution state).
992
+ * Request to start a workflow instance.
955
993
  */
956
- interface AXPWorkflowState {
957
- /**
958
- * State ID.
959
- */
960
- id: string;
961
- /**
962
- * Workflow definition ID.
963
- */
964
- definitionId: string;
965
- /**
966
- * Workflow definition version.
967
- */
968
- definitionVersion: number;
969
- /**
970
- * Correlation ID (nullable).
971
- */
972
- correlationId?: string | null;
994
+ interface AXPStartWorkflowRequest {
973
995
  /**
974
- * Workflow status.
975
- */
976
- status: AXPWorkflowStatus;
977
- /**
978
- * Workflow sub-status.
979
- */
980
- subStatus: AXPWorkflowSubStatus;
981
- /**
982
- * Bookmarks.
983
- */
984
- bookmarks: AXPBookmark[];
985
- /**
986
- * Incidents.
987
- */
988
- incidents: AXPActivityIncident[];
989
- /**
990
- * Fault (nullable).
991
- */
992
- fault?: AXPWorkflowFaultState | null;
993
- /**
994
- * Completion callbacks.
995
- */
996
- completionCallbacks: AXPCompletionCallbackState[];
997
- /**
998
- * Activity execution contexts.
996
+ * Workflow ID to execute.
999
997
  */
1000
- activityExecutionContexts: AXPActivityExecutionContextState[];
998
+ workflowId: string;
1001
999
  /**
1002
- * Input data.
1000
+ * Initial input data for workflow.
1003
1001
  */
1004
1002
  input: Record<string, any>;
1005
- /**
1006
- * Output data.
1007
- */
1008
- output: Record<string, any>;
1009
- /**
1010
- * Properties bag.
1011
- */
1012
- properties: Record<string, any>;
1013
- /**
1014
- * Created at timestamp (ISO date-time).
1015
- */
1016
- createdAt: string;
1017
- /**
1018
- * Updated at timestamp (ISO date-time).
1019
- */
1020
- updatedAt: string;
1021
- /**
1022
- * Finished at timestamp (ISO date-time, nullable).
1023
- */
1024
- finishedAt?: string | null;
1025
1003
  }
1026
1004
  /**
1027
- * Workflow instance (stored in database).
1028
- * This matches the Elsa Workflow Instance schema for backend compatibility.
1005
+ * Response after starting workflow instance.
1029
1006
  */
1030
- interface AXPWorkflowInstance {
1031
- /**
1032
- * Schema reference.
1033
- */
1034
- $schema?: string;
1035
- /**
1036
- * Unique instance ID.
1037
- */
1038
- id: string;
1039
- /**
1040
- * Workflow definition ID.
1041
- */
1042
- definitionId: string;
1043
- /**
1044
- * Workflow definition version ID.
1045
- */
1046
- definitionVersionId: string;
1047
- /**
1048
- * Workflow definition version number.
1049
- */
1050
- version: number;
1051
- /**
1052
- * Parent workflow instance ID (nullable, for child workflows).
1053
- */
1054
- parentWorkflowInstanceId?: string | null;
1055
- /**
1056
- * Workflow state (internal execution state).
1057
- */
1058
- workflowState: AXPWorkflowState;
1059
- /**
1060
- * Workflow status.
1061
- */
1062
- status: AXPWorkflowStatus;
1063
- /**
1064
- * Workflow sub-status.
1065
- */
1066
- subStatus: AXPWorkflowSubStatus;
1007
+ interface AXPStartWorkflowResponse {
1067
1008
  /**
1068
- * Correlation ID (nullable).
1009
+ * Unique instance ID for this workflow run.
1069
1010
  */
1070
- correlationId?: string | null;
1011
+ instanceId: string;
1071
1012
  /**
1072
- * Instance name (nullable).
1073
- */
1074
- name?: string | null;
1075
- /**
1076
- * Incident count.
1077
- */
1078
- incidentCount: number;
1079
- /**
1080
- * Created at timestamp (ISO date-time).
1081
- */
1082
- createdAt: string;
1083
- /**
1084
- * Updated at timestamp (ISO date-time).
1013
+ * Current workflow state.
1085
1014
  */
1086
- updatedAt: string;
1015
+ state: AXPWorkflowInstanceState;
1087
1016
  /**
1088
- * Finished at timestamp (ISO date-time, nullable).
1017
+ * First task to execute (determined by backend).
1018
+ * Client should execute this task based on executionMode.
1089
1019
  */
1090
- finishedAt?: string | null;
1091
- }
1092
-
1093
- interface ActivityPropertyWidget {
1094
- type: AXPWidgetTypesMap[keyof AXPWidgetTypesMap] | string;
1095
- options?: Record<string, any>;
1020
+ pendingTask?: AXPWorkflowTask | null;
1096
1021
  }
1097
1022
  /**
1098
- * Simple activity interface - just a command with outcomes.
1099
- * All activities are AXPCommand for unified execution through Command Bus.
1023
+ * Request to resume a suspended workflow.
1100
1024
  */
1101
- interface IActivity<TInput = any, TOutput = any> extends AXPCommand<TInput, {
1102
- output: TOutput;
1103
- outcomes: Record<string, any>;
1104
- }> {
1025
+ interface AXPResumeWorkflowRequest {
1105
1026
  /**
1106
- * Activity type name.
1107
- * Example: "WriteLine", "ShowDialog", "CreateUserCommand"
1027
+ * Instance ID.
1108
1028
  */
1109
- type: string;
1029
+ instanceId: string;
1110
1030
  /**
1111
- * Display name for UI.
1031
+ * Step ID that was waiting for user input.
1112
1032
  */
1113
- name?: string;
1033
+ stepId: string;
1114
1034
  /**
1115
- * Execute the activity as a command.
1116
- * @param input - Activity input data
1117
- * @returns Promise with output and outcomes
1035
+ * Secure task token issued with the pending task.
1036
+ * Backend validates and resolves the step using this token.
1118
1037
  */
1119
- execute(input: TInput): Promise<AXPExecuteCommandResult<{
1120
- output: TOutput;
1121
- outcomes: Record<string, any>;
1122
- }>>;
1123
- }
1124
- /**
1125
- * Base abstract class for activities.
1126
- * Extend this to create custom activities.
1127
- */
1128
- declare abstract class Activity<TInput = any, TOutput = any> implements IActivity<TInput, TOutput> {
1129
- type: string;
1130
- name?: string;
1131
- constructor(type: string, name?: string);
1038
+ taskToken: string;
1132
1039
  /**
1133
- * Execute the activity as a command.
1134
- * Override this method in subclasses to implement activity logic.
1040
+ * User action outcome (e.g., 'Confirmed', 'Cancelled').
1135
1041
  */
1136
- abstract execute(input: TInput): Promise<AXPExecuteCommandResult<{
1137
- output: TOutput;
1138
- outcomes: Record<string, any>;
1139
- }>>;
1042
+ outcome: string;
1140
1043
  /**
1141
- * Helper method that returns Done outcome by default.
1044
+ * Optional user input data.
1142
1045
  */
1143
- protected createResult(output: TOutput, outcome?: string): AXPExecuteCommandResult<{
1144
- output: TOutput;
1145
- outcomes: Record<string, any>;
1146
- }>;
1046
+ userInput?: any;
1147
1047
  }
1148
1048
  /**
1149
- * Activity descriptor - metadata about an activity type.
1049
+ * Response after resuming workflow.
1150
1050
  */
1151
- interface ActivityDescriptor {
1152
- /**
1153
- * Activity type name.
1154
- */
1155
- type: string;
1156
- /**
1157
- * Display name for UI.
1158
- */
1159
- displayName: string;
1160
- /**
1161
- * Description of what the activity does.
1162
- */
1163
- description?: string;
1164
- /**
1165
- * Category for grouping in toolbox.
1166
- */
1167
- category: string;
1168
- /**
1169
- * Icon name or class.
1170
- */
1171
- icon?: string;
1172
- /**
1173
- * Where this activity should be executed.
1174
- * - 'frontend': Execute in browser (UI activities, console, events)
1175
- * - 'backend': Execute in backend (business logic, API calls)
1176
- * - 'both': Execute in both frontend and backend (hybrid activities)
1177
- *
1178
- * Default: 'frontend'
1179
- */
1180
- executionMode?: 'frontend' | 'backend' | 'both';
1051
+ interface AXPResumeWorkflowResponse {
1181
1052
  /**
1182
- * Input descriptors.
1183
- */
1184
- inputs: InputDescriptor[];
1185
- /**
1186
- * Output descriptors.
1053
+ * Activity execution output.
1187
1054
  */
1188
- outputs: OutputDescriptor[];
1055
+ output: any;
1189
1056
  /**
1190
- * Static outcomes (exit points).
1191
- * Example: ['Done', 'Success', 'Failed']
1057
+ * Activity execution outcomes.
1192
1058
  */
1193
- outcomes?: string[];
1059
+ outcomes: Record<string, any>;
1194
1060
  /**
1195
- * Whether this activity is browsable in the toolbox.
1196
- * Default: true
1061
+ * Next task to execute (if any).
1197
1062
  */
1198
- isBrowsable?: boolean;
1063
+ nextTask?: AXPWorkflowTask | null;
1199
1064
  /**
1200
- * Whether this activity is a container (can have children).
1201
- * Default: false
1065
+ * Updated workflow state.
1202
1066
  */
1203
- isContainer?: boolean;
1204
- }
1205
- /**
1206
- * Input property descriptor.
1207
- * Similar to AXPEntityProperty structure.
1208
- */
1209
- interface InputDescriptor {
1210
- name: string;
1211
- title: string;
1212
- description?: string;
1213
- schema: {
1214
- dataType: string;
1215
- nullable?: boolean;
1216
- readonly?: boolean;
1217
- hidden?: boolean | string;
1218
- defaultValue?: any | string | ((context: any | null) => any);
1219
- interface?: ActivityPropertyWidget;
1220
- };
1221
- validations?: AXPValidationRules;
1067
+ state: AXPWorkflowInstanceState;
1222
1068
  }
1223
1069
  /**
1224
- * Output property descriptor.
1070
+ * Request to get workflow instance state.
1225
1071
  */
1226
- interface OutputDescriptor {
1227
- name: string;
1228
- title: string;
1229
- description?: string;
1230
- schema: {
1231
- dataType: string;
1232
- };
1072
+ interface AXPGetWorkflowStateRequest {
1073
+ /**
1074
+ * Instance ID.
1075
+ */
1076
+ instanceId: string;
1233
1077
  }
1234
1078
  /**
1235
- * Activity registry for registering and creating activities.
1079
+ * Workflow instance state (managed by backend, cached in client).
1236
1080
  */
1237
- declare class ActivityRegistry {
1238
- private registry;
1239
- private descriptors;
1081
+ interface AXPWorkflowInstanceState {
1240
1082
  /**
1241
- * Register an activity type.
1083
+ * Unique instance ID.
1242
1084
  */
1243
- register(type: string, factory: () => IActivity, descriptor: ActivityDescriptor): void;
1085
+ instanceId: string;
1244
1086
  /**
1245
- * Create an activity instance.
1087
+ * Workflow ID.
1246
1088
  */
1247
- create(type: string): IActivity;
1089
+ workflowId: string;
1248
1090
  /**
1249
- * Get activity descriptor.
1091
+ * Current instance status.
1250
1092
  */
1251
- getDescriptor(type: string): ActivityDescriptor | undefined;
1093
+ status: 'running' | 'completed' | 'suspended' | 'error';
1252
1094
  /**
1253
- * Get all registered types.
1095
+ * Current step ID (if suspended or running).
1254
1096
  */
1255
- getTypes(): string[];
1097
+ currentStepId?: string;
1256
1098
  /**
1257
- * Get all descriptors.
1099
+ * Workflow variables (state).
1258
1100
  */
1259
- getAllDescriptors(): ActivityDescriptor[];
1101
+ variables: Record<string, any>;
1260
1102
  /**
1261
- * Get descriptors by category.
1103
+ * Initial input data.
1262
1104
  */
1263
- getDescriptorsByCategory(category: string): ActivityDescriptor[];
1264
- }
1265
-
1266
- interface ActivityCategoryDescriptor {
1267
- name: string;
1268
- displayName: string;
1269
- description?: string;
1270
- icon?: string;
1271
- color?: string;
1272
- order?: number;
1273
- isVisible?: boolean;
1274
- tags?: string[];
1275
- }
1276
- interface AXPActivityCategoryProviderContext {
1277
- registerCategories(categories: ActivityCategoryDescriptor[]): void;
1278
- }
1279
- interface AXPActivityCategoryProvider {
1280
- provide(context: AXPActivityCategoryProviderContext): Promise<void> | void;
1281
- }
1282
- /**
1283
- * Injection token for activity category providers.
1284
- */
1285
- declare const AXP_ACTIVITY_CATEGORY_PROVIDER: InjectionToken<AXPActivityCategoryProvider[]>;
1286
- declare class AXPActivityCategoryProviderService {
1287
- private parent?;
1288
- private providers;
1289
- private categories;
1290
- private isInitialized;
1291
- constructor(parent?: AXPActivityCategoryProviderService | undefined, providers?: AXPActivityCategoryProvider[]);
1292
- private initialize;
1293
- getAllCategories(): ActivityCategoryDescriptor[];
1294
- getCategory(name: string): ActivityCategoryDescriptor | undefined;
1295
- static ɵfac: i0.ɵɵFactoryDeclaration<AXPActivityCategoryProviderService, [{ optional: true; skipSelf: true; }, { optional: true; }]>;
1296
- static ɵprov: i0.ɵɵInjectableDeclaration<AXPActivityCategoryProviderService>;
1297
- }
1298
-
1299
- /**
1300
- * Context for registering activities in a provider.
1301
- */
1302
- interface AXPActivityProviderContext {
1105
+ input: Record<string, any>;
1303
1106
  /**
1304
- * Register an activity with its descriptor.
1107
+ * Final output data (if completed).
1305
1108
  */
1306
- registerActivity(config: {
1307
- key: string;
1308
- descriptor: ActivityDescriptor;
1309
- }): void;
1310
- }
1311
- /**
1312
- * Interface for activity providers.
1313
- * Modules implement this to register their activities.
1314
- */
1315
- interface AXPActivityProvider {
1109
+ output?: Record<string, any>;
1316
1110
  /**
1317
- * Provide activities to the system.
1111
+ * Last update timestamp.
1318
1112
  */
1319
- provide(context: AXPActivityProviderContext): Promise<void> | void;
1320
- }
1321
- /**
1322
- * Injection token for activity providers.
1323
- */
1324
- declare const AXP_ACTIVITY_PROVIDER: InjectionToken<AXPActivityProvider[]>;
1325
- /**
1326
- * Category definition for activity categorization.
1327
- */
1328
- interface ActivityCategory {
1329
- name: string;
1330
- displayName: string;
1331
- description?: string;
1332
- icon?: string;
1333
- color?: string;
1334
- order?: number;
1335
- isVisible?: boolean;
1336
- tags?: string[];
1113
+ lastUpdated: Date;
1337
1114
  }
1115
+
1338
1116
  /**
1339
- * Activity Provider Service.
1340
- * Collects all activity providers and manages activity registration.
1117
+ * Interface for workflow engine operations.
1341
1118
  */
1342
- declare class AXPActivityProviderService {
1343
- private activityDescriptors;
1344
- private categories;
1345
- private providers;
1346
- private categoryProviders;
1347
- private initialized;
1348
- private readonly commandService;
1349
- private readonly commandRegistry;
1350
- /**
1351
- * Register an activity provider.
1352
- */
1353
- registerProvider(provider: AXPActivityProvider): void;
1119
+ interface AXPWorkflowEngine {
1354
1120
  /**
1355
- * Register a category provider.
1356
- */
1357
- registerCategoryProvider(provider: AXPActivityCategoryProvider): void;
1358
- /**
1359
- * Initialize all providers.
1360
- */
1361
- initialize(): Promise<void>;
1362
- /**
1363
- * Get activity descriptor by key.
1364
- */
1365
- getDescriptor(key: string): ActivityDescriptor | undefined;
1366
- /**
1367
- * Get all activity descriptors.
1368
- */
1369
- getAllDescriptors(): ActivityDescriptor[];
1370
- /**
1371
- * Get descriptors by category.
1121
+ * Start a new workflow instance.
1122
+ *
1123
+ * Creates a new workflow instance in backend and returns instance ID.
1124
+ *
1125
+ * @param request - Start workflow request
1126
+ * @returns Response with instanceId and initial state
1127
+ *
1372
1128
  */
1373
- getDescriptorsByCategory(category: string): ActivityDescriptor[];
1129
+ start(request: AXPStartWorkflowRequest): Promise<AXPStartWorkflowResponse>;
1374
1130
  /**
1375
- * Get all categories.
1131
+ * Resume a suspended workflow instance.
1132
+ *
1133
+ * Resumes workflow instance after user interaction (e.g., after show-dialog).
1134
+ *
1135
+ * @param request - Resume workflow request
1136
+ * @returns Resume response with next step and updated state
1137
+ *
1376
1138
  */
1377
- getCategories(): ActivityCategory[];
1139
+ resume(request: AXPResumeWorkflowRequest): Promise<AXPResumeWorkflowResponse>;
1378
1140
  /**
1379
- * Create an activity instance by key using AXPCommandService.
1141
+ * Get current workflow instance state.
1142
+ *
1143
+ * Retrieves current state of a workflow instance from backend.
1144
+ *
1145
+ * @param request - Get state request
1146
+ * @returns Current workflow instance state
1147
+ *
1380
1148
  */
1381
- createActivity(key: string): Promise<IActivity | null>;
1382
- private initializeProvider;
1383
- private initializeCategoryProvider;
1384
- static ɵfac: i0.ɵɵFactoryDeclaration<AXPActivityProviderService, never>;
1385
- static ɵprov: i0.ɵɵInjectableDeclaration<AXPActivityProviderService>;
1149
+ getState(request: AXPGetWorkflowStateRequest): Promise<AXPWorkflowInstanceState>;
1386
1150
  }
1387
-
1388
1151
  /**
1389
- * Types and interfaces for Workflow Execution Service.
1152
+ * Injection token for workflow engine.
1153
+ * Default implementation is AXPWorkflowLocalEngine.
1390
1154
  */
1155
+ declare const AXP_WORKFLOW_ENGINE: InjectionToken<AXPWorkflowEngine>;
1391
1156
 
1392
1157
  /**
1393
- * Represents a workflow task that needs to be executed.
1394
- * Inspired by Temporal's Activity Tasks and Camunda's External Tasks.
1158
+ * Result of executing a workflow activity.
1395
1159
  */
1396
- interface AXPWorkflowTask {
1397
- /**
1398
- * Unique token for this task (used for completion/security).
1399
- */
1400
- taskToken: string;
1401
- /**
1402
- * Activity ID from workflow definition.
1403
- */
1404
- activityId: string;
1405
- /**
1406
- * Activity type (e.g., 'workflow-activity:show-toast').
1407
- */
1408
- activityType: string;
1409
- /**
1410
- * Human-readable activity name.
1411
- */
1412
- activityName?: string;
1160
+ interface ActivityExecutionResult {
1413
1161
  /**
1414
- * Where this task should be executed.
1415
- * - 'frontend': Execute in browser (UI activities, console, events)
1416
- * - 'backend': Execute in backend (business logic, API calls)
1417
- * - 'both': Execute in both frontend and backend (hybrid activities)
1418
- */
1419
- executionMode: 'frontend' | 'backend' | 'both';
1420
- /**
1421
- * Input data for the activity (for frontend activities).
1162
+ * Activity execution output.
1422
1163
  */
1423
- input?: Record<string, any>;
1164
+ output: any;
1424
1165
  /**
1425
- * Configuration for the activity (for frontend activities).
1166
+ * Activity execution outcome (e.g., 'Done', 'Confirmed', 'Cancelled', 'Failed').
1426
1167
  */
1427
- config?: Record<string, any>;
1168
+ outcome: string;
1428
1169
  }
1429
1170
  /**
1430
- * Request to start a workflow execution.
1171
+ * Activity Executor Service
1172
+ *
1173
+ * Service for executing workflow activities via CommandBus.
1174
+ * Automatically evaluates expressions in activity inputs before execution.
1175
+ *
1176
+ * @example
1177
+ * ```typescript
1178
+ * const executor = inject(ActivityExecutor);
1179
+ *
1180
+ * // Execute activity with task and workflow state (expressions will be evaluated)
1181
+ * const result = await executor.execute(task, workflowState, activityOutputs);
1182
+ * ```
1431
1183
  */
1432
- interface AXPStartWorkflowExecutionRequest {
1433
- /**
1434
- * Workflow ID to execute.
1435
- */
1436
- workflowId: string;
1184
+ declare class ActivityExecutor {
1185
+ private readonly commandService;
1186
+ private readonly expressionEvaluator;
1187
+ private readonly expressionScopeService;
1437
1188
  /**
1438
- * Initial input data for workflow.
1189
+ * Execute a workflow activity with expression evaluation.
1190
+ *
1191
+ * Evaluates expressions in activity inputs using workflow state,
1192
+ * then executes the activity via CommandBus.
1193
+ *
1194
+ * @param task - Workflow task containing activity information
1195
+ * @param workflowState - Current workflow instance state (for expression evaluation)
1196
+ * @param activityOutputs - Map of previous activity outputs (for expression evaluation)
1197
+ * @returns Execution result with output and outcome
1439
1198
  */
1440
- input: Record<string, any>;
1199
+ execute(task: AXPWorkflowTask, workflowState?: AXPWorkflowInstanceState, activityOutputs?: Map<string, any> | Record<string, any>): Promise<ActivityExecutionResult>;
1200
+ static ɵfac: i0.ɵɵFactoryDeclaration<ActivityExecutor, never>;
1201
+ static ɵprov: i0.ɵɵInjectableDeclaration<ActivityExecutor>;
1441
1202
  }
1203
+
1442
1204
  /**
1443
- * Response after starting workflow execution.
1205
+ * Result of starting a workflow.
1444
1206
  */
1445
- interface AXPStartWorkflowExecutionResponse {
1207
+ interface WorkflowStartResult {
1446
1208
  /**
1447
- * Unique execution ID for this workflow run.
1448
- */
1449
- executionId: string;
1450
- /**
1451
- * Current workflow state.
1452
- */
1453
- state: AXPWorkflowExecutionState;
1454
- /**
1455
- * First task to execute (determined by backend).
1456
- * Client should execute this task based on executionMode.
1209
+ * Whether the operation succeeded.
1457
1210
  */
1458
- pendingTask?: AXPWorkflowTask | null;
1459
- }
1460
- /**
1461
- * Request to resume a suspended workflow.
1462
- */
1463
- interface AXPResumeWorkflowExecutionRequest {
1211
+ success: boolean;
1464
1212
  /**
1465
- * Execution ID.
1213
+ * Workflow instance ID.
1466
1214
  */
1467
- executionId: string;
1215
+ instanceId?: string;
1468
1216
  /**
1469
- * Step ID that was waiting for user input.
1217
+ * Initial workflow state.
1470
1218
  */
1471
- stepId: string;
1219
+ state?: AXPWorkflowInstanceState;
1472
1220
  /**
1473
- * Secure task token issued with the pending task.
1474
- * Backend validates and resolves the step using this token.
1221
+ * First task to execute (if any).
1475
1222
  */
1476
- taskToken: string;
1223
+ nextTask?: AXPWorkflowTask | null;
1477
1224
  /**
1478
- * User action outcome (e.g., 'Confirmed', 'Cancelled').
1225
+ * Workflow output (if completed immediately).
1479
1226
  */
1480
- outcome: string;
1227
+ output?: any;
1481
1228
  /**
1482
- * Optional user input data.
1229
+ * Error message (if failed).
1483
1230
  */
1484
- userInput?: any;
1231
+ error?: string;
1485
1232
  }
1486
1233
  /**
1487
- * Response after resuming workflow.
1234
+ * Result of completing a task.
1488
1235
  */
1489
- interface AXPResumeWorkflowExecutionResponse {
1236
+ interface WorkflowCompleteResult {
1490
1237
  /**
1491
- * Activity execution output.
1238
+ * Whether the operation succeeded.
1492
1239
  */
1493
- output: any;
1494
- /**
1495
- * Activity execution outcomes.
1496
- */
1497
- outcomes: Record<string, any>;
1240
+ success: boolean;
1498
1241
  /**
1499
- * Next task to execute (if any).
1242
+ * Workflow instance ID.
1500
1243
  */
1501
- nextTask?: AXPWorkflowTask | null;
1244
+ instanceId: string;
1502
1245
  /**
1503
1246
  * Updated workflow state.
1504
1247
  */
1505
- state: AXPWorkflowExecutionState;
1506
- }
1507
- /**
1508
- * Request to get workflow execution state.
1509
- */
1510
- interface AXPGetWorkflowExecutionStateRequest {
1248
+ state?: AXPWorkflowInstanceState;
1511
1249
  /**
1512
- * Execution ID.
1250
+ * Next task to execute (if any).
1513
1251
  */
1514
- executionId: string;
1515
- }
1516
- /**
1517
- * Request to get workflow definition.
1518
- */
1519
- interface AXPGetWorkflowDefinitionRequest {
1252
+ nextTask?: AXPWorkflowTask | null;
1520
1253
  /**
1521
- * Workflow ID or definition ID.
1254
+ * Workflow output (if completed).
1522
1255
  */
1523
- workflowId: string;
1524
- }
1525
- /**
1526
- * Response with workflow definition.
1527
- */
1528
- interface AXPGetWorkflowDefinitionResponse {
1256
+ output?: any;
1529
1257
  /**
1530
- * Workflow definition.
1258
+ * Error message (if failed).
1531
1259
  */
1532
- workflow: AXPWorkflowDefinition;
1260
+ error?: string;
1533
1261
  }
1534
1262
  /**
1535
- * Workflow execution state (managed by backend, cached in client).
1263
+ * Result of resuming a workflow.
1536
1264
  */
1537
- interface AXPWorkflowExecutionState {
1265
+ interface WorkflowResumeResult {
1538
1266
  /**
1539
- * Unique execution ID.
1540
- */
1541
- executionId: string;
1542
- /**
1543
- * Workflow ID.
1267
+ * Whether the operation succeeded.
1544
1268
  */
1545
- workflowId: string;
1546
- /**
1547
- * Current execution status.
1548
- */
1549
- status: 'running' | 'completed' | 'suspended' | 'error';
1550
- /**
1551
- * Current step ID (if suspended or running).
1552
- */
1553
- currentStepId?: string;
1269
+ success: boolean;
1554
1270
  /**
1555
- * Workflow variables (state).
1271
+ * Workflow instance ID.
1556
1272
  */
1557
- variables: Record<string, any>;
1273
+ instanceId: string;
1558
1274
  /**
1559
- * Initial input data.
1275
+ * Updated workflow state.
1560
1276
  */
1561
- input: Record<string, any>;
1277
+ state?: AXPWorkflowInstanceState;
1562
1278
  /**
1563
- * Final output data (if completed).
1279
+ * Next task to execute (if any).
1564
1280
  */
1565
- output?: Record<string, any>;
1281
+ nextTask?: AXPWorkflowTask | null;
1566
1282
  /**
1567
- * Last update timestamp.
1283
+ * Workflow output (if completed).
1568
1284
  */
1569
- lastUpdated: Date;
1570
- }
1571
-
1572
- /**
1573
- * Workflow execution result.
1574
- */
1575
- interface WorkflowExecutionResult {
1576
- success: boolean;
1577
1285
  output?: any;
1286
+ /**
1287
+ * Error message (if failed).
1288
+ */
1578
1289
  error?: string;
1579
- nextTask?: AXPWorkflowTask | null;
1580
- executionId?: string;
1581
- state?: AXPWorkflowExecutionState;
1582
1290
  }
1583
1291
  /**
1584
- * Production Workflow Coordinator.
1292
+ * Workflow Manager - Facade for workflow lifecycle orchestration.
1585
1293
  *
1586
- * Separates frontend/backend execution:
1587
- * - Frontend activities: Execute with AXPCommand in browser
1588
- * - Backend activities: Execute via API calls to backend
1589
- * - State caching: Caches workflow state in client for performance
1294
+ * This service is the ONLY interface the frontend uses to interact with workflows.
1295
+ * It follows Clean Architecture principles and does NOT contain execution or business logic.
1590
1296
  *
1297
+ * Responsibilities:
1298
+ * - Orchestrate workflow lifecycle (start, execute, complete, resume)
1299
+ * - Delegate execution to ActivityExecutor
1300
+ * - Cache workflow state in memory
1301
+ * - Expose a stable API for UI
1302
+ *
1303
+ * Rules:
1304
+ * - No HTTP calls (delegates to AXPWorkflowEngine)
1305
+ * - No CommandBus / Command execution (delegates to ActivityExecutor)
1306
+ * - No workflow branching logic (backend decides)
1307
+ * - No business validation (backend validates)
1308
+ * - No backend assumptions (uses abstract runtime service)
1591
1309
  */
1592
- declare class WorkflowCoordinator {
1593
- private readonly workflowExecutionService;
1594
- private readonly commandService;
1310
+ declare class AXPWorkflowManager {
1311
+ private readonly workflowEngine;
1312
+ private readonly activityExecutor;
1595
1313
  /**
1596
1314
  * Cache workflow states in memory for quick access.
1597
- * Key: executionId
1598
- * Value: AXPWorkflowExecutionState
1315
+ * Key: instanceId
1316
+ * Value: AXPWorkflowInstanceState
1599
1317
  */
1600
1318
  private stateCache;
1601
1319
  /**
1602
- * Start workflow execution in backend.
1320
+ * Cache TTL in milliseconds (5 minutes).
1321
+ */
1322
+ private readonly CACHE_TTL;
1323
+ /**
1324
+ * Start a new workflow instance.
1603
1325
  *
1326
+ * Creates a new workflow instance in backend and returns instance ID.
1604
1327
  * Backend decides what to do: returns pendingTask or indicates completion.
1605
- * Frontend only calls API - no business logic here.
1606
1328
  *
1607
- * @param workflowId - Workflow ID
1608
- * @param input - Initial input data
1609
- * @returns Execution result with pendingTask (if any)
1329
+ * @param workflowId - Workflow ID to start
1330
+ * @param input - Initial input data (optional)
1331
+ * @returns Start result with instanceId, state, and nextTask
1610
1332
  *
1611
1333
  * @example
1612
1334
  * ```typescript
1613
- * const result = await coordinator.startWorkflow('my-workflow', { userId: '123' });
1335
+ * const result = await workflowManager.start('my-workflow', { userId: '123' });
1614
1336
  *
1615
- * if (result.pendingTask) {
1616
- * // Execute task if frontend, or wait for backend to complete
1617
- * if (result.pendingTask.executionMode === 'frontend') {
1618
- * await coordinator.executeTask(result.pendingTask);
1619
- * await coordinator.completeTask(result.executionId, result.pendingTask, outcome, output);
1337
+ * if (result.success && result.nextTask) {
1338
+ * // Execute task if frontend
1339
+ * if (result.nextTask.executionMode === 'frontend') {
1340
+ * const execResult = await workflowManager.execute(result.nextTask);
1341
+ * await workflowManager.complete(result.instanceId!, result.nextTask, execResult.outcome, execResult.output);
1620
1342
  * }
1621
1343
  * }
1622
1344
  * ```
1623
1345
  */
1624
- startWorkflow(workflowId: string, input?: Record<string, any>): Promise<WorkflowExecutionResult>;
1346
+ start(workflowId: string, input?: Record<string, any>): Promise<WorkflowStartResult>;
1625
1347
  /**
1626
- * Execute a frontend task using AXPCommand.
1348
+ * Execute a frontend task.
1627
1349
  *
1628
- * Only executes if task.executionMode is 'frontend' or 'both'.
1629
- * Backend tasks are handled automatically by backend.
1350
+ * Delegates to ActivityExecutor for actual execution.
1351
+ * Only executes tasks with executionMode 'frontend' or 'both'.
1352
+ *
1353
+ * Provides workflow state to executor for expression evaluation.
1630
1354
  *
1631
1355
  * @param task - Task to execute
1632
1356
  * @returns Execution result with output and outcome
1357
+ *
1358
+ * @throws Error if task is not a frontend task
1633
1359
  */
1634
- executeTask(task: AXPWorkflowTask): Promise<{
1635
- output: any;
1636
- outcome: string;
1637
- }>;
1360
+ execute(task: AXPWorkflowTask): Promise<ActivityExecutionResult>;
1638
1361
  /**
1639
1362
  * Complete a task and get next task from backend.
1640
1363
  *
1641
1364
  * Sends task result to backend API.
1642
1365
  * Backend decides: next task, fail, or complete workflow.
1643
1366
  *
1644
- * @param executionId - Execution ID
1367
+ * @param instanceId - Workflow instance ID
1645
1368
  * @param task - Completed task
1646
1369
  * @param outcome - Task outcome (e.g., 'Done', 'Confirmed', 'Cancelled')
1647
- * @param output - Task output/result
1648
- * @returns Next task from backend (if any)
1649
- */
1650
- completeTask(executionId: string, task: AXPWorkflowTask, outcome: string, output?: any): Promise<WorkflowExecutionResult>;
1651
- /**
1652
- * Execute workflow by ID (backward compatibility).
1653
- *
1654
- * @deprecated Use startWorkflow + executeTask + completeTask pattern instead.
1655
- * This method is kept for backward compatibility but will be removed.
1370
+ * @param output - Task output/result (optional)
1371
+ * @returns Complete result with next task (if any)
1656
1372
  */
1657
- executeWorkflowById(workflowId: string, input?: Record<string, any>): Promise<WorkflowExecutionResult>;
1373
+ complete(instanceId: string, task: AXPWorkflowTask, outcome: string, output?: any): Promise<WorkflowCompleteResult>;
1658
1374
  /**
1659
1375
  * Resume a suspended workflow (e.g., after user interaction).
1660
1376
  *
1661
1377
  * Backend determines nextStep based on outcome and outcomeConnections.
1662
- * Client only provides executionId, stepId, outcome, and optional userInput.
1378
+ * Client only provides instanceId, stepId, outcome, and optional userInput.
1663
1379
  *
1664
- * @param executionId - Workflow execution ID
1380
+ * @param instanceId - Workflow instance ID
1665
1381
  * @param stepId - Step ID that was waiting for user input
1666
1382
  * @param outcome - User action outcome (e.g., 'Confirmed', 'Cancelled', 'Submitted')
1667
1383
  * @param userInput - Optional user input data
1384
+ * @param taskToken - Secure task token (required for secure resumption)
1385
+ * @returns Resume result with next task (if any)
1668
1386
  */
1669
- resumeWorkflow(executionId: string, stepId: string, outcome: string, userInput?: any, taskToken?: string): Promise<WorkflowExecutionResult>;
1387
+ resume(instanceId: string, stepId: string, outcome: string, userInput?: any, taskToken?: string): Promise<WorkflowResumeResult>;
1670
1388
  /**
1671
- * Get workflow execution state (from cache or backend).
1672
- */
1673
- getWorkflowState(executionId: string): Promise<AXPWorkflowExecutionState | null>;
1674
- /**
1675
- * Execute a frontend activity using CommandBus.
1389
+ * Get workflow instance state.
1676
1390
  *
1677
- * Frontend activities are executed in the browser using AXPCommandService.
1678
- * Activities can also be executed in both frontend and backend (hybrid mode).
1391
+ * Retrieves state from cache (if valid) or from backend.
1679
1392
  *
1680
- * @param task - Frontend task to execute
1681
- * @returns Execution result with output and outcome
1682
- */
1683
- private executeFrontendActivity;
1684
- /**
1685
- * Start workflow execution in backend.
1686
- * Backend returns executionId, initial state, and first task to execute.
1393
+ * @param instanceId - Workflow instance ID
1394
+ * @returns Workflow instance state or null if not found
1687
1395
  */
1688
- private startWorkflowExecution;
1689
- static ɵfac: i0.ɵɵFactoryDeclaration<WorkflowCoordinator, never>;
1690
- static ɵprov: i0.ɵɵInjectableDeclaration<WorkflowCoordinator>;
1396
+ getState(instanceId: string): Promise<AXPWorkflowInstanceState | null>;
1397
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowManager, never>;
1398
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowManager>;
1691
1399
  }
1692
1400
 
1693
1401
  /**
1694
- * Abstract service for workflow execution operations.
1695
- *
1696
- * This service handles communication with backend for workflow execution.
1402
+ * Local engine implementation that manages workflow progression and state.
1697
1403
  *
1698
- * Implementation should be provided in connectivity layer:
1699
- * - Mock implementation: @acorex/connectivity/mock
1700
- * - API implementation: @acorex/connectivity/api
1701
- *
1702
- * @example
1703
- * ```typescript
1704
- * // In connectivity/mock
1705
- * @Injectable()
1706
- * export class AXCWorkflowExecutionService implements AXPWorkflowExecutionService {
1707
- * async startExecution(request: AXPStartWorkflowExecutionRequest): Promise<AXPStartWorkflowExecutionResponse> {
1708
- * // Mock implementation
1709
- * }
1710
- * }
1404
+ * This engine:
1405
+ * - Returns frontend/both activities as pendingTask (does NOT execute them)
1406
+ * - Skips backend activities (does not error, continues execution)
1407
+ * - Maintains workflow state in memory
1408
+ * - Does not require backend API calls
1711
1409
  *
1712
- * // In connectivity/api
1713
- * @Injectable()
1714
- * export class AXCWorkflowExecutionService implements AXPWorkflowExecutionService {
1715
- * constructor(private http: HttpClient) {}
1410
+ * Execution of frontend tasks is handled by AXPWorkflowManager via ActivityExecutor.
1411
+ * This engine only manages workflow progression and state storage.
1716
1412
  *
1717
- * async startExecution(request: AXPStartWorkflowExecutionRequest): Promise<AXPStartWorkflowExecutionResponse> {
1718
- * return firstValueFrom(
1719
- * this.http.post<AXPStartWorkflowExecutionResponse>(
1720
- * `${this.config.baseUrl}/api/workflows/${request.workflowId}/start`,
1721
- * { input: request.input }
1722
- * )
1723
- * );
1724
- * }
1725
- * }
1726
- * ```
1413
+ * This is the DEFAULT engine provider. Applications can override it with
1414
+ * an API-based engine implementation.
1727
1415
  */
1728
- declare abstract class AXPWorkflowExecutionService {
1416
+ declare class AXPWorkflowLocalEngine implements AXPWorkflowEngine {
1417
+ private readonly activityDefinitionService;
1418
+ private readonly workflowProviders;
1729
1419
  /**
1730
- * Start a new workflow execution.
1731
- *
1732
- * Creates a new workflow execution instance in backend and returns execution ID.
1733
- *
1734
- * @param request - Start execution request
1735
- * @returns Execution response with executionId and initial state
1736
- *
1737
- * @example
1738
- * ```typescript
1739
- * const response = await workflowExecutionService.startExecution({
1740
- * workflowId: 'my-workflow',
1741
- * input: { userId: '123', action: 'create' }
1742
- * });
1743
- *
1744
- * console.log('Execution ID:', response.executionId);
1745
- * console.log('Initial State:', response.state);
1746
- * ```
1420
+ * In-memory storage for workflow instances.
1421
+ * Key: instanceId
1422
+ * Value: LocalWorkflowState
1747
1423
  */
1748
- abstract startExecution(request: AXPStartWorkflowExecutionRequest): Promise<AXPStartWorkflowExecutionResponse>;
1424
+ private instances;
1749
1425
  /**
1750
- * Resume a suspended workflow execution.
1751
- *
1752
- * Resumes workflow execution after user interaction (e.g., after show-dialog).
1753
- *
1754
- * @param request - Resume execution request
1755
- * @returns Resume response with next step and updated state
1756
- *
1757
- * @example
1758
- * ```typescript
1759
- * const response = await workflowExecutionService.resumeExecution({
1760
- * executionId: 'exec-123',
1761
- * stepId: 'step-dialog-1',
1762
- * taskToken: 'sec-task-token',
1763
- * outcome: 'Confirmed',
1764
- * userInput: { confirmed: true }
1765
- * });
1766
- *
1767
- * console.log('Next Step:', response.nextStep);
1768
- * console.log('Updated State:', response.state);
1769
- * ```
1426
+ * Task token storage for secure resume operations.
1427
+ * Key: taskToken
1428
+ * Value: { instanceId, activityId }
1770
1429
  */
1771
- abstract resumeExecution(request: AXPResumeWorkflowExecutionRequest): Promise<AXPResumeWorkflowExecutionResponse>;
1430
+ private taskTokens;
1772
1431
  /**
1773
- * Get current workflow execution state.
1774
- *
1775
- * Retrieves current state of a workflow execution from backend.
1776
- *
1777
- * @param request - Get state request
1778
- * @returns Current workflow execution state
1432
+ * Start a new workflow instance.
1779
1433
  *
1780
- * @example
1781
- * ```typescript
1782
- * const state = await workflowExecutionService.getExecutionState({
1783
- * executionId: 'exec-123'
1784
- * });
1785
- *
1786
- * console.log('Status:', state.status);
1787
- * console.log('Variables:', state.variables);
1788
- * ```
1434
+ * Creates an in-memory workflow instance and progresses it.
1435
+ * Frontend/both activities are returned as pendingTask for external execution.
1436
+ * Backend activities are skipped.
1789
1437
  */
1790
- abstract getExecutionState(request: AXPGetWorkflowExecutionStateRequest): Promise<AXPWorkflowExecutionState>;
1438
+ start(request: AXPStartWorkflowRequest): Promise<AXPStartWorkflowResponse>;
1791
1439
  /**
1792
- * Get workflow definition by ID.
1440
+ * Resume a suspended workflow instance.
1793
1441
  *
1794
- * Retrieves workflow definition from backend.
1795
- *
1796
- * @param request - Get workflow definition request
1797
- * @returns Workflow definition in executable format
1442
+ * Validates task token, applies externally executed result,
1443
+ * and continues progressing workflow steps.
1444
+ */
1445
+ resume(request: AXPResumeWorkflowRequest): Promise<AXPResumeWorkflowResponse>;
1446
+ /**
1447
+ * Get current workflow instance state.
1448
+ */
1449
+ getState(request: AXPGetWorkflowStateRequest): Promise<AXPWorkflowInstanceState>;
1450
+ /**
1451
+ * Get workflow definition from available providers.
1452
+ */
1453
+ private getDefinition;
1454
+ /**
1455
+ * Progress workflow steps starting from the current position.
1798
1456
  *
1799
- * @example
1800
- * ```typescript
1801
- * const response = await workflowExecutionService.getWorkflowDefinition({
1802
- * workflowId: 'my-workflow'
1803
- * });
1457
+ * For frontend/both activities: returns task immediately (suspends workflow).
1458
+ * For backend activities: skips and continues.
1804
1459
  *
1805
- * console.log('Workflow:', response.workflow);
1806
- * ```
1460
+ * Returns the next pending task (if frontend activity found) or null (if completed).
1461
+ */
1462
+ private executeWorkflowSteps;
1463
+ /**
1464
+ * Get next activity ID based on connections and outcomes.
1807
1465
  */
1808
- abstract getWorkflowDefinition(request: AXPGetWorkflowDefinitionRequest): Promise<AXPGetWorkflowDefinitionResponse>;
1809
- static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowExecutionService, never>;
1810
- static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowExecutionService>;
1466
+ private getNextActivityId;
1467
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowLocalEngine, never>;
1468
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowLocalEngine>;
1811
1469
  }
1812
1470
 
1813
1471
  /**
1814
- * WriteLine Activity - Simple console logging activity.
1815
- *
1816
- * Usage:
1817
- * ```typescript
1818
- * const activity = new WriteLine();
1819
- * await activity.execute({ text: 'Hello World' });
1820
- * ```
1472
+ * Workflow expression evaluation context.
1473
+ * Contains workflow state data needed for expression evaluation.
1821
1474
  */
1822
- declare class WriteLine extends Activity<{
1823
- text?: string;
1824
- }, void> {
1825
- constructor();
1826
- execute(input: {
1827
- text?: string;
1828
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
1829
- output: void;
1830
- outcomes: Record<string, any>;
1831
- }>>;
1475
+ interface WorkflowExpressionContext {
1476
+ /** Workflow input values */
1477
+ inputs: Record<string, any>;
1478
+ /** Workflow state variables */
1479
+ variables: Record<string, any>;
1480
+ /** Previous activity outputs (activityId -> output) */
1481
+ outputs: Record<string, any>;
1832
1482
  }
1833
-
1834
1483
  /**
1835
- * Sequence Activity - Executes activities in sequential order.
1484
+ * Workflow Expression Scope Service
1836
1485
  *
1837
- * Usage:
1838
- * ```typescript
1839
- * const sequence = new Sequence();
1840
- * sequence.activities = [activity1, activity2, activity3];
1841
- * await sequence.execute({});
1842
- * ```
1843
- */
1844
- declare class Sequence extends Activity<{}, void> {
1845
- /**
1846
- * Activities to execute in sequence.
1847
- */
1848
- activities: IActivity[];
1849
- constructor();
1850
- execute(input: {}): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
1851
- output: void;
1852
- outcomes: Record<string, any>;
1853
- }>>;
1854
- }
1855
-
1856
- /**
1857
- * Show Confirm Dialog Activity - Displays confirmation dialog to user.
1486
+ * Shared service for building expression evaluation scope from workflow data.
1487
+ * Used by both Local Engine and Mock Runtime to manage workflow data (inputs, variables, outputs).
1488
+ *
1489
+ * Responsibilities:
1490
+ * - Build expression evaluation scope from workflow state
1491
+ * - Provide context.eval() function for accessing workflow data
1492
+ * - Manage workflow data structure (inputs, variables, outputs)
1858
1493
  *
1859
- * Has two outcomes:
1860
- * - 'Confirmed': User clicked confirm/yes
1861
- * - 'Cancelled': User clicked cancel/no
1494
+ * This service does NOT:
1495
+ * - Execute activities
1496
+ * - Evaluate expressions (delegates to AXPExpressionEvaluatorService)
1497
+ * - Manage workflow state (handled by runtime)
1862
1498
  *
1863
- * Usage:
1499
+ * @example
1864
1500
  * ```typescript
1865
- * const dialog = new ShowConfirmDialog();
1866
- * await dialog.execute({
1867
- * title: 'Confirm Delete',
1868
- * message: 'Are you sure?',
1869
- * color: 'danger'
1501
+ * const scopeService = inject(WorkflowExpressionScopeService);
1502
+ *
1503
+ * // Build scope from workflow state
1504
+ * const scope = scopeService.buildScope({
1505
+ * inputs: state.input || {},
1506
+ * variables: state.variables || {},
1507
+ * outputs: activityOutputs
1870
1508
  * });
1509
+ *
1510
+ * // Or build from state directly
1511
+ * const scope = scopeService.buildScopeFromState(state, activityOutputs);
1871
1512
  * ```
1872
1513
  */
1873
- declare class ShowConfirmDialog extends Activity<{
1874
- title?: string;
1875
- message?: string;
1876
- color?: AXStyleColorType;
1877
- defaultAction?: 'confirm' | 'cancel';
1878
- align?: 'horizontal' | 'vertical';
1879
- backdrop?: boolean;
1880
- }, {
1881
- result: boolean;
1882
- action: string;
1883
- }> {
1884
- private readonly dialogService;
1885
- private readonly translationService;
1886
- constructor();
1887
- execute(input: {
1888
- title?: string;
1889
- message?: string;
1890
- color?: AXStyleColorType;
1891
- defaultAction?: 'confirm' | 'cancel';
1892
- align?: 'horizontal' | 'vertical';
1893
- backdrop?: boolean;
1894
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
1895
- output: {
1896
- result: boolean;
1897
- action: string;
1898
- };
1899
- outcomes: Record<string, any>;
1900
- }>>;
1514
+ declare class WorkflowExpressionScopeService {
1515
+ /**
1516
+ * Build expression evaluation scope for workflow activities.
1517
+ *
1518
+ * Provides workflow-specific data (inputs, variables, outputs) and context.eval() function.
1519
+ * Other data (session, current user, etc.) are provided by expression evaluator scope providers.
1520
+ *
1521
+ * Scope includes:
1522
+ * - inputs: Workflow input values (accessible as inputs.propertyName)
1523
+ * - variables: Workflow state variables (accessible as variables.propertyName or vars.propertyName)
1524
+ * - outputs: Previous activity outputs (accessible as outputs.activityId)
1525
+ * - context.eval(path): Function to access nested properties from workflow data
1526
+ *
1527
+ * Expressions can use:
1528
+ * - {{inputs.userName}} - Direct access to workflow input
1529
+ * - {{variables.someVar}} or {{vars.someVar}} - Direct access to workflow variable
1530
+ * - {{outputs.activityId.property}} - Direct access to previous activity output
1531
+ * - {{context.eval("inputs.userName")}} - Access via context.eval (supports nested paths)
1532
+ * - {{context.eval("variables.someVar")}} - Access variables via context.eval
1533
+ * - {{context.eval("outputs.activityId.property")}} - Access outputs via context.eval
1534
+ * - {{session.currentUser().name}} - Access current user via expression evaluator scope providers
1535
+ *
1536
+ * The context.eval() function provides a unified way to access all workflow data,
1537
+ * similar to how entity-detail-list uses context.eval() to access parent data.
1538
+ *
1539
+ * @param context - Workflow expression context containing inputs, variables, and outputs
1540
+ * @returns Expression evaluator scope with workflow data and context.eval() function
1541
+ */
1542
+ buildScope(context: WorkflowExpressionContext): AXPExpressionEvaluatorScope;
1543
+ /**
1544
+ * Build expression evaluation scope from workflow instance state.
1545
+ *
1546
+ * Convenience method that extracts data from AXPWorkflowInstanceState.
1547
+ *
1548
+ * @param state - Workflow instance state
1549
+ * @param activityOutputs - Map of activity outputs (activityId -> output)
1550
+ * @returns Expression evaluator scope with workflow data and context.eval() function
1551
+ */
1552
+ buildScopeFromState(state: AXPWorkflowInstanceState, activityOutputs?: Map<string, any> | Record<string, any>): AXPExpressionEvaluatorScope;
1553
+ static ɵfac: i0.ɵɵFactoryDeclaration<WorkflowExpressionScopeService, never>;
1554
+ static ɵprov: i0.ɵɵInjectableDeclaration<WorkflowExpressionScopeService>;
1901
1555
  }
1902
1556
 
1903
1557
  /**
1904
- * Show Alert Dialog Activity - Displays alert dialog to user.
1905
- *
1906
- * Has one outcome:
1907
- * - 'Done': User clicked OK
1558
+ * Workflow Category - Extends AXPCategoryEntity for consistency and performance
1908
1559
  *
1909
- * Usage:
1910
- * ```typescript
1911
- * const dialog = new ShowAlertDialog();
1912
- * await dialog.execute({
1913
- * title: 'Alert',
1914
- * message: 'This is an alert',
1915
- * color: 'info'
1916
- * });
1917
- * ```
1560
+ * Inherited properties from AXPCategoryEntity:
1561
+ * - id: string - Unique identifier
1562
+ * - title: string - Display name
1563
+ * - description?: string - Category description
1564
+ * - parentId?: string - Parent category ID
1565
+ * - childrenCount: number - Direct child categories count (enables lazy loading)
1566
+ * - itemsCount?: number - Direct workflows count
1567
+ * - totalChildrenCount?: number - Total nested categories (optional, for analytics)
1568
+ * - totalItemsCount?: number - Total workflows in tree (optional, for analytics)
1918
1569
  */
1919
- declare class ShowAlertDialog extends Activity<{
1920
- title?: string;
1921
- message?: string;
1922
- color?: AXStyleColorType;
1923
- }, {
1924
- result: boolean;
1925
- action: string;
1926
- }> {
1927
- private readonly dialogService;
1928
- private readonly translationService;
1929
- constructor();
1930
- execute(input: {
1931
- title?: string;
1932
- message?: string;
1933
- color?: AXStyleColorType;
1934
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
1935
- output: {
1936
- result: boolean;
1937
- action: string;
1938
- };
1939
- outcomes: Record<string, any>;
1940
- }>>;
1570
+ interface AXPWorkflowCategory extends AXPCategoryEntity {
1571
+ }
1572
+ type AXPWorkflowProviderToken = AXPWorkflowProvider | Promise<AXPWorkflowProvider>;
1573
+ declare const AXP_WORKFLOW_PROVIDER: InjectionToken<AXPWorkflowProviderToken[]>;
1574
+ interface AXPWorkflowProvider {
1575
+ /**
1576
+ * Get list of workflow definitions for a category.
1577
+ * @param categoryId - Category ID to filter workflows
1578
+ * @returns Promise of workflow definition array
1579
+ */
1580
+ getList(categoryId: string): Promise<AXPWorkflowDefinition[]>;
1581
+ /**
1582
+ * Get full workflow definition by name (unique identifier).
1583
+ * Used by workflow engines for execution and UI for metadata.
1584
+ * @param name - Workflow name (unique identifier)
1585
+ * @returns Promise of full workflow definition or null if not found
1586
+ */
1587
+ getByName(name: string): Promise<AXPWorkflowDefinition | null>;
1588
+ }
1589
+ type AXPWorkflowCategoryProviderToken = AXPWorkflowCategoryProvider | Promise<AXPWorkflowCategoryProvider>;
1590
+ declare const AXP_WORKFLOW_CATEGORY_PROVIDER: InjectionToken<AXPWorkflowCategoryProviderToken[]>;
1591
+ interface AXPWorkflowCategoryProvider {
1592
+ getList(parentId?: string): Promise<AXPWorkflowCategory[]>;
1593
+ getById(id: string): Promise<AXPWorkflowCategory | undefined>;
1941
1594
  }
1942
1595
 
1943
1596
  /**
1944
- * Show Dialog Layout Builder Activity - Displays dialog using Layout Builder.
1945
- *
1946
- * This activity allows you to create custom dialogs using the Layout Builder API.
1947
- * It accepts JSON-serializable content (AXPWidgetNode) and actions configuration.
1948
- *
1949
- * The content can be created using Layout Builder and then converted to JSON:
1950
- * ```typescript
1951
- * const builder = layoutBuilderService.create();
1952
- * builder.flex(flex => {
1953
- * flex.setDirection('column')
1954
- * .formField('First Name', field => {
1955
- * field.path('firstName');
1956
- * field.textBox({ placeholder: 'Enter first name' });
1957
- * });
1958
- * });
1959
- * const contentNode = builder.build();
1960
- * ```
1597
+ * Optimized Workflow Definition Service
1961
1598
  *
1962
- * Usage in Workflow:
1963
- * ```typescript
1964
- * const dialog = new ShowDialogLayoutBuilder();
1965
- * await dialog.execute({
1966
- * title: 'User Information',
1967
- * size: 'md',
1968
- * context: { firstName: '', lastName: '' },
1969
- * content: {
1970
- * type: 'flex-layout',
1971
- * mode: 'edit',
1972
- * options: {
1973
- * flexDirection: 'column',
1974
- * gap: '16px'
1975
- * },
1976
- * children: [
1977
- * {
1978
- * type: 'form-field',
1979
- * mode: 'edit',
1980
- * options: {
1981
- * label: 'First Name',
1982
- * showLabel: true
1983
- * },
1984
- * children: [{
1985
- * type: 'text-editor',
1986
- * path: 'firstName',
1987
- * options: {
1988
- * placeholder: 'Enter first name'
1989
- * }
1990
- * }]
1991
- * }
1992
- * ]
1993
- * },
1994
- * actions: {
1995
- * cancel: '@general:actions.cancel.title',
1996
- * submit: '@general:actions.submit.title',
1997
- * custom: [{
1998
- * title: 'Save Draft',
1999
- * icon: 'fa-save',
2000
- * color: 'secondary',
2001
- * command: { name: 'save-draft' }
2002
- * }]
2003
- * }
2004
- * });
2005
- * ```
1599
+ * Manages workflow definitions (metadata) for UI and tooling.
1600
+ * Similar to AXPActivityDefinitionService - only handles metadata, not execution.
2006
1601
  *
2007
- * Usage in JSON Workflow Definition:
2008
- * ```json
2009
- * {
2010
- * "type": "ShowDialogLayoutBuilder",
2011
- * "properties": {
2012
- * "title": "User Information",
2013
- * "size": "md",
2014
- * "context": { "firstName": "", "lastName": "" },
2015
- * "content": {
2016
- * "type": "flex-layout",
2017
- * "mode": "edit",
2018
- * "options": {
2019
- * "flexDirection": "column",
2020
- * "gap": "16px"
2021
- * },
2022
- * "children": [
2023
- * {
2024
- * "type": "form-field",
2025
- * "mode": "edit",
2026
- * "options": {
2027
- * "label": "First Name",
2028
- * "showLabel": true
2029
- * },
2030
- * "children": [{
2031
- * "type": "text-editor",
2032
- * "path": "firstName",
2033
- * "options": {
2034
- * "placeholder": "Enter first name"
2035
- * }
2036
- * }]
2037
- * }
2038
- * ]
2039
- * },
2040
- * "actions": {
2041
- * "cancel": "@general:actions.cancel.title",
2042
- * "submit": "@general:actions.submit.title"
2043
- * }
2044
- * }
2045
- * }
2046
- * ```
2047
- */
2048
- declare class ShowDialogLayoutBuilder extends Activity<{
1602
+ * Performance optimizations:
1603
+ * 1. Uses childrenCount to determine if category has children (no query needed)
1604
+ * 2. Uses itemsCount to determine if category has workflows (no query needed)
1605
+ * 3. Aggressive caching prevents duplicate API calls
1606
+ * 4. Single pending request per resource prevents race conditions
1607
+ * 5. Lazy loading - only loads data when needed
1608
+ */
1609
+ declare class AXPWorkflowDefinitionService {
1610
+ private readonly categoryProviders;
1611
+ private readonly workflowProviders;
1612
+ /** Cache for categories by id - O(1) lookup */
1613
+ private categoriesById;
1614
+ /** Cache for categories by parentId - O(1) lookup */
1615
+ private categoriesByParentId;
1616
+ /** Cache for workflow definitions by categoryId - O(1) lookup */
1617
+ private workflowsByCategory;
1618
+ /** Cache for individual workflow definitions by name - O(1) lookup */
1619
+ private workflowsByName;
1620
+ /** Track which provider index owns each category (by category ID) */
1621
+ private categoryOwnership;
1622
+ /** Pending API requests to prevent duplicate calls */
1623
+ private pendingCategoriesRequests;
1624
+ private pendingWorkflowsRequests;
1625
+ private pendingWorkflowRequests;
1626
+ /**
1627
+ * Get categories by parentId with aggressive caching
1628
+ *
1629
+ * Optimization: Returns cached result immediately if available,
1630
+ * preventing unnecessary API calls during navigation
1631
+ *
1632
+ * @param parentId - Parent category ID (undefined = root categories)
1633
+ * @returns Array of categories with count metadata (childrenCount, itemsCount)
1634
+ */
1635
+ getCategories(parentId?: string): Promise<AXPWorkflowCategory[]>;
1636
+ /**
1637
+ * Get single category by ID with O(1) lookup
1638
+ *
1639
+ * Optimization: Uses Map for instant retrieval, falls back to
1640
+ * searching cache, then providers if not found
1641
+ */
1642
+ getCategoryById(categoryId: string): Promise<AXPWorkflowCategory | undefined>;
2049
1643
  /**
2050
- * Dialog title
1644
+ * Get category path from root to specified category
1645
+ *
1646
+ * Optimization: Builds path using cached categories only
2051
1647
  */
2052
- title?: string;
1648
+ getCategoriesPathById(categoryId: string): Promise<AXPWorkflowCategory[]>;
2053
1649
  /**
2054
- * Dialog size
1650
+ * Get workflow definitions for a category with smart caching
1651
+ *
1652
+ * Optimization: Checks itemsCount before querying
1653
+ * - If itemsCount = 0, returns empty array (no API call)
1654
+ * - If itemsCount > 0, loads and caches workflow definitions
1655
+ * - Returns cached result on subsequent calls
1656
+ *
1657
+ * @param categoryId - Category ID to get workflow definitions from
1658
+ * @returns Array of workflow definitions
2055
1659
  */
2056
- size?: AXPopupSizeType;
1660
+ getWorkflowsByCategoryId(categoryId: string): Promise<AXPWorkflowDefinition[]>;
2057
1661
  /**
2058
- * Initial dialog context/data
1662
+ * Get single workflow definition by name with O(1) lookup
1663
+ *
1664
+ * Optimization: Uses Map for instant retrieval
1665
+ *
1666
+ * @param name - Workflow name (unique identifier)
1667
+ * @returns Workflow definition or undefined if not found
2059
1668
  */
2060
- context?: Record<string, any>;
1669
+ getWorkflowByName(name: string): Promise<AXPWorkflowDefinition | undefined>;
2061
1670
  /**
2062
- * Show close button
1671
+ * Get category ID containing a specific workflow definition
1672
+ *
1673
+ * Optimization: Searches cache first, loads on-demand if needed
2063
1674
  */
2064
- closeButton?: boolean;
1675
+ getCategoryIdByWorkflowName(workflowName: string): Promise<string | undefined>;
2065
1676
  /**
2066
- * Dialog message (optional, shown above content)
1677
+ * Get category path for a workflow
2067
1678
  */
2068
- message?: string;
1679
+ getCategoriesPathByWorkflowName(workflowName: string): Promise<AXPWorkflowCategory[]>;
2069
1680
  /**
2070
- * Dialog content as AXPWidgetNode (JSON-serializable)
2071
- * This can be created using Layout Builder and then converted to JSON.
1681
+ * Load categories from providers and cache results
1682
+ *
1683
+ * Optimization: Tracks provider ownership to avoid unnecessary API calls
1684
+ * - For root (parentId = undefined): Query ALL providers
1685
+ * - For children: Only query the provider that owns the parent
2072
1686
  */
2073
- content?: AXPWidgetNode;
1687
+ private loadCategoriesFromProviders;
2074
1688
  /**
2075
- * Dialog actions configuration (JSON-serializable)
1689
+ * Get the provider index that owns a specific category
1690
+ *
1691
+ * @returns Array with provider index, or null if ownership unknown (query all)
2076
1692
  */
2077
- actions?: {
2078
- /**
2079
- * Cancel button text (optional)
2080
- */
2081
- cancel?: string;
2082
- /**
2083
- * Submit button text (optional)
2084
- */
2085
- submit?: string;
2086
- /**
2087
- * Custom actions array (optional)
2088
- */
2089
- custom?: AXPActionMenuItem[];
2090
- };
2091
- }, {
1693
+ private getProviderIndexForCategory;
2092
1694
  /**
2093
- * Dialog context/data after user interaction
1695
+ * Load workflow definitions from providers and cache results
1696
+ *
1697
+ * Optimization: Only queries the provider that owns the category
1698
+ * Uses provider INDEX to match category provider with workflow provider
2094
1699
  */
2095
- context: Record<string, any>;
1700
+ private loadWorkflowsFromProviders;
2096
1701
  /**
2097
- * Action that user clicked (e.g., 'submit', 'cancel', or custom action name)
1702
+ * Load single workflow definition from providers and cache result
2098
1703
  */
2099
- action: string;
1704
+ private loadWorkflowFromProviders;
2100
1705
  /**
2101
- * Whether user cancelled the dialog
1706
+ * Breadth-first search through category hierarchy
2102
1707
  */
2103
- cancelled: boolean;
1708
+ private searchCategoryInHierarchy;
2104
1709
  /**
2105
- * Whether user confirmed/submitted the dialog
1710
+ * Check if category has children (uses cached count)
2106
1711
  */
2107
- confirmed: boolean;
2108
- }> {
2109
- private readonly layoutBuilder;
2110
- constructor();
2111
- execute(input: {
2112
- title?: string;
2113
- size?: AXPopupSizeType;
2114
- context?: Record<string, any>;
2115
- closeButton?: boolean;
2116
- message?: string;
2117
- content?: AXPWidgetNode;
2118
- actions?: {
2119
- cancel?: string;
2120
- submit?: string;
2121
- custom?: AXPActionMenuItem[];
2122
- };
2123
- }): Promise<AXPExecuteCommandResult<{
2124
- output: {
2125
- context: Record<string, any>;
2126
- action: string;
2127
- cancelled: boolean;
2128
- confirmed: boolean;
2129
- };
2130
- outcomes: Record<string, any>;
2131
- }>>;
2132
- }
2133
-
2134
- /**
2135
- * Show Toast Activity - Displays toast notification to user.
2136
- *
2137
- * Usage:
2138
- * ```typescript
2139
- * const toast = new ShowToast();
2140
- * await toast.execute({
2141
- * color: 'success',
2142
- * title: 'Success',
2143
- * message: 'Operation completed successfully!'
2144
- * });
2145
- * ```
2146
- */
2147
- declare class ShowToast extends Activity<{
2148
- color?: AXStyleColorType;
2149
- title?: string;
2150
- message?: string;
2151
- duration?: number;
2152
- }, void> {
2153
- private readonly toastService;
2154
- private readonly translationService;
2155
- constructor();
2156
- execute(input: {
2157
- color?: AXStyleColorType;
2158
- title?: string;
2159
- message?: string;
2160
- duration?: number;
2161
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2162
- output: void;
2163
- outcomes: Record<string, any>;
2164
- }>>;
2165
- }
2166
-
2167
- /**
2168
- * Navigate Activity - Navigates to different pages/routes.
2169
- *
2170
- * Usage:
2171
- * ```typescript
2172
- * const navigate = new Navigate();
2173
- * await navigate.execute({
2174
- * mode: 'route',
2175
- * route: '/users',
2176
- * params: { id: '123' }
2177
- * });
2178
- * ```
2179
- */
2180
- declare class Navigate extends Activity<{
2181
- mode?: 'route' | 'entity-details' | 'entity-list' | 'external';
2182
- route?: string;
2183
- params?: Record<string, any>;
2184
- queryParams?: Record<string, any>;
2185
- entity?: string;
2186
- entityId?: string;
2187
- url?: string;
2188
- }, void> {
2189
- private readonly router;
2190
- constructor();
2191
- execute(input: {
2192
- mode?: 'route' | 'entity-details' | 'entity-list' | 'external';
2193
- route?: string;
2194
- params?: Record<string, any>;
2195
- queryParams?: Record<string, any>;
2196
- entity?: string;
2197
- entityId?: string;
2198
- url?: string;
2199
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2200
- output: void;
2201
- outcomes: Record<string, any>;
2202
- }>>;
2203
- }
2204
-
2205
- /**
2206
- * Set Variable Activity - Sets a variable value in workflow context.
2207
- *
2208
- * Usage:
2209
- * ```typescript
2210
- * const setVar = new SetVariable();
2211
- * await setVar.execute({
2212
- * variableName: 'userId',
2213
- * value: '12345'
2214
- * });
2215
- * ```
2216
- */
2217
- declare class SetVariable extends Activity<{
2218
- variableName: string;
2219
- value: any;
2220
- }, void> {
2221
- constructor();
2222
- execute(input: {
2223
- variableName: string;
2224
- value: any;
2225
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2226
- output: void;
2227
- outcomes: Record<string, any>;
2228
- }>>;
2229
- }
2230
-
2231
- /**
2232
- * Dispatch Event Activity - Dispatches an event to the system.
2233
- *
2234
- * Usage:
2235
- * ```typescript
2236
- * const dispatch = new DispatchEvent();
2237
- * await dispatch.execute({
2238
- * eventName: 'user-created',
2239
- * eventData: { userId: '123', name: 'John' }
2240
- * });
2241
- * ```
2242
- */
2243
- declare class DispatchEvent extends Activity<{
2244
- eventName: string;
2245
- eventData?: any;
2246
- }, void> {
2247
- constructor();
2248
- execute(input: {
2249
- eventName: string;
2250
- eventData?: any;
2251
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2252
- output: void;
2253
- outcomes: Record<string, any>;
2254
- }>>;
2255
- }
2256
-
2257
- /**
2258
- * If Activity - Conditional execution based on a condition.
2259
- *
2260
- * Usage:
2261
- * ```typescript
2262
- * const ifActivity = new If();
2263
- * ifActivity.condition = '{{user.isAdmin}}';
2264
- * ifActivity.thenActivities = [activity1, activity2];
2265
- * ifActivity.elseActivities = [activity3];
2266
- * ```
2267
- */
2268
- declare class If extends Activity<{
2269
- condition: string | boolean;
2270
- thenActivities?: IActivity[];
2271
- elseActivities?: IActivity[];
2272
- }, any> {
2273
- constructor();
2274
- execute(input: {
2275
- condition: string | boolean;
2276
- thenActivities?: IActivity[];
2277
- elseActivities?: IActivity[];
2278
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2279
- output: any;
2280
- outcomes: Record<string, any>;
2281
- }>>;
2282
- private evaluateCondition;
2283
- }
2284
-
2285
- /**
2286
- * While Activity - Loop execution while condition is true.
2287
- *
2288
- * Usage:
2289
- * ```typescript
2290
- * const whileActivity = new While();
2291
- * whileActivity.condition = '{{counter < 10}}';
2292
- * whileActivity.activities = [incrementActivity, logActivity];
2293
- * ```
2294
- */
2295
- declare class While extends Activity<{
2296
- condition: string | boolean;
2297
- activities?: IActivity[];
2298
- maxIterations?: number;
2299
- }, any> {
2300
- constructor();
2301
- execute(input: {
2302
- condition: string | boolean;
2303
- activities?: IActivity[];
2304
- maxIterations?: number;
2305
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2306
- output: any;
2307
- outcomes: Record<string, any>;
2308
- }>>;
2309
- private evaluateCondition;
2310
- }
2311
-
2312
- /**
2313
- * ForEach Activity - Iterates over a collection of items.
2314
- *
2315
- * Usage:
2316
- * ```typescript
2317
- * const forEach = new ForEach();
2318
- * await forEach.execute({
2319
- * items: ['item1', 'item2', 'item3'],
2320
- * activities: [processItemActivity]
2321
- * });
2322
- * ```
2323
- */
2324
- declare class ForEach extends Activity<{
2325
- items: any[];
2326
- activities?: IActivity[];
2327
- itemVariableName?: string;
2328
- indexVariableName?: string;
2329
- }, any> {
2330
- constructor();
2331
- execute(input: {
2332
- items: any[];
2333
- activities?: IActivity[];
2334
- itemVariableName?: string;
2335
- indexVariableName?: string;
2336
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2337
- output: any;
2338
- outcomes: Record<string, any>;
2339
- }>>;
2340
- }
2341
-
2342
- /**
2343
- * Execute Command Activity - Executes a command through Command Bus.
2344
- *
2345
- * Usage:
2346
- * ```typescript
2347
- * const executeCmd = new ExecuteCommand();
2348
- * await executeCmd.execute({
2349
- * commandKey: 'UserManagement.CreateUser',
2350
- * input: { name: 'John', email: 'john@example.com' }
2351
- * });
2352
- * ```
2353
- */
2354
- declare class ExecuteCommand extends Activity<{
2355
- commandKey: string;
2356
- input?: any;
2357
- }, any> {
2358
- private readonly commandService;
2359
- constructor();
2360
- execute(input: {
2361
- commandKey: string;
2362
- input?: any;
2363
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2364
- output: any;
2365
- outcomes: Record<string, any>;
2366
- }>>;
2367
- }
2368
-
2369
- /**
2370
- * Execute Query Activity - Executes a query through Query Bus.
2371
- *
2372
- * Usage:
2373
- * ```typescript
2374
- * const executeQuery = new ExecuteQuery();
2375
- * await executeQuery.execute({
2376
- * queryKey: 'UserManagement.GetUsers',
2377
- * input: { page: 1, pageSize: 10 }
2378
- * });
2379
- * ```
2380
- */
2381
- declare class ExecuteQuery extends Activity<{
2382
- queryKey: string;
2383
- input?: any;
2384
- }, any> {
2385
- private readonly queryService;
2386
- constructor();
2387
- execute(input: {
2388
- queryKey: string;
2389
- input?: any;
2390
- }): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2391
- output: any;
2392
- outcomes: Record<string, any>;
2393
- }>>;
2394
- }
2395
-
2396
- /**
2397
- * Start Activity - Marks the start point of a workflow.
2398
- *
2399
- * This is a visual marker activity that doesn't perform any actual work.
2400
- * It's used in workflow designers to clearly indicate where a workflow begins.
2401
- *
2402
- * Usage:
2403
- * ```typescript
2404
- * const start = new StartActivity();
2405
- * await start.execute({});
2406
- * ```
2407
- */
2408
- declare class StartActivity extends Activity<Record<string, never>, void> {
2409
- constructor();
2410
- execute(input: Record<string, never>): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2411
- output: void;
2412
- outcomes: Record<string, any>;
2413
- }>>;
2414
- }
2415
-
2416
- /**
2417
- * End Activity - Marks the end point of a workflow.
2418
- *
2419
- * This is a visual marker activity that terminates the workflow execution.
2420
- * When this activity is reached, the workflow completes successfully.
2421
- *
2422
- * Usage:
2423
- * ```typescript
2424
- * const end = new EndActivity();
2425
- * await end.execute({});
2426
- * ```
2427
- */
2428
- declare class EndActivity extends Activity<Record<string, never>, void> {
2429
- constructor();
2430
- execute(input: Record<string, never>): Promise<_acorex_platform_core.AXPExecuteCommandResult<{
2431
- output: void;
2432
- outcomes: Record<string, any>;
2433
- }>>;
1712
+ categoryHasChildren(categoryId: string): boolean;
1713
+ /**
1714
+ * Check if category has workflows (uses cached count)
1715
+ */
1716
+ categoryHasWorkflows(categoryId: string): boolean;
1717
+ /**
1718
+ * Clear all caches
1719
+ */
1720
+ clearAllCache(): void;
1721
+ /**
1722
+ * Clear categories cache only
1723
+ */
1724
+ clearCategoriesCache(): void;
1725
+ /**
1726
+ * Clear workflows cache only
1727
+ */
1728
+ clearWorkflowsCache(): void;
1729
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPWorkflowDefinitionService, never>;
1730
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPWorkflowDefinitionService>;
2434
1731
  }
2435
1732
 
2436
- /**
2437
- * Command setups for all built-in workflow activities.
2438
- * Registers activities as AXPCommand instances.
2439
- */
2440
- declare const provideWorkflowActivityCommands: () => i0.EnvironmentProviders;
2441
-
2442
- export { AXPActivityCategoryProviderService, AXPActivityProviderService, AXPWorkflowAction, AXPWorkflowContext, AXPWorkflowDefinitionRegistryService, AXPWorkflowDefinitionResolver, AXPWorkflowError, AXPWorkflowEventService, AXPWorkflowExecutionService, AXPWorkflowFunction, AXPWorkflowModule, AXPWorkflowRegistryService, AXPWorkflowService, AXP_ACTIVITY_CATEGORY_PROVIDER, AXP_ACTIVITY_PROVIDER, AXP_WORKFLOW_DEFINITION_LOADER, Activity, ActivityRegistry, DispatchEvent, EndActivity, ExecuteCommand, ExecuteQuery, ForEach, If, Navigate, Sequence, SetVariable, ShowAlertDialog, ShowConfirmDialog, ShowDialogLayoutBuilder, ShowToast, StartActivity, While, WorkflowCoordinator, WriteLine, createWorkFlowEvent, ofType, provideWorkflowActivityCommands };
2443
- export type { AXPActivity, AXPActivityCategoryProvider, AXPActivityCategoryProviderContext, AXPActivityExecutionContextState, AXPActivityIncident, AXPActivityProvider, AXPActivityProviderContext, AXPActivityStatus, AXPActivityVariable, AXPBookmark, AXPCompletionCallbackState, AXPConnection, AXPCustomProperties, AXPEndpoint, AXPExceptionState, AXPExpression, AXPFlowchart, AXPGetWorkflowDefinitionRequest, AXPGetWorkflowDefinitionResponse, AXPGetWorkflowExecutionStateRequest, AXPInputValue, AXPMetadata, AXPOutputValue, AXPPosition, AXPResumeWorkflowExecutionRequest, AXPResumeWorkflowExecutionResponse, AXPStartWorkflowExecutionRequest, AXPStartWorkflowExecutionResponse, AXPStoredWorkflowDefinition, AXPVariableDefinition, AXPVariableModel, AXPVersionedEntity, AXPWorkflow, AXPWorkflowActionInput, AXPWorkflowCondition, AXPWorkflowConditionType, AXPWorkflowDefinition, AXPWorkflowDefinitionJson, AXPWorkflowDefinitionLoader, AXPWorkflowDefinitionPreloader, AXPWorkflowEvent, AXPWorkflowExecutionState, AXPWorkflowFaultState, AXPWorkflowInputDefinition, AXPWorkflowInstance, AXPWorkflowModuleConfigs, AXPWorkflowNextStep, AXPWorkflowOptions, AXPWorkflowOutputDefinition, AXPWorkflowState, AXPWorkflowStatus, AXPWorkflowStep, AXPWorkflowSubStatus, AXPWorkflowTask, ActivityCategory, ActivityCategoryDescriptor, ActivityDescriptor, ActivityPropertyWidget, IActivity, InputDescriptor, OutputDescriptor, WorkflowExecutionResult };
1733
+ export { AXPActivityDefinitionService, AXPWorkflowAction, AXPWorkflowContext, AXPWorkflowDefinitionService, AXPWorkflowError, AXPWorkflowEventService, AXPWorkflowFunction, AXPWorkflowLocalEngine, AXPWorkflowManager, AXPWorkflowModule, AXPWorkflowRegistryService, AXPWorkflowService, AXP_ACTIVITY_CATEGORY_PROVIDER, AXP_ACTIVITY_PROVIDER, AXP_WORKFLOW_CATEGORY_PROVIDER, AXP_WORKFLOW_ENGINE, AXP_WORKFLOW_PROVIDER, ActivityExecutor, WorkflowExpressionScopeService, createWorkFlowEvent, ofType };
1734
+ export type { AXPActivity, AXPActivityCategory, AXPActivityCategoryProvider, AXPActivityCategoryProviderToken, AXPActivityDefinition, AXPActivityExecutionContextState, AXPActivityIncident, AXPActivityProvider, AXPActivityProviderToken, AXPActivityStatus, AXPActivityVariable, AXPBookmark, AXPCompletionCallbackState, AXPConnection, AXPElsaWorkflowExtensions, AXPExceptionState, AXPGetWorkflowStateRequest, AXPResumeWorkflowRequest, AXPResumeWorkflowResponse, AXPStartWorkflowRequest, AXPStartWorkflowResponse, AXPVariableDefinition, AXPWorkflow, AXPWorkflowActionInput, AXPWorkflowActivityInstance, AXPWorkflowBinding, AXPWorkflowCategory, AXPWorkflowCategoryProvider, AXPWorkflowCategoryProviderToken, AXPWorkflowCondition, AXPWorkflowConditionType, AXPWorkflowDefinition, AXPWorkflowEngine, AXPWorkflowEvent, AXPWorkflowExtensions, AXPWorkflowFaultState, AXPWorkflowGraph, AXPWorkflowInputDescriptor, AXPWorkflowInstance, AXPWorkflowInstanceState, AXPWorkflowModuleConfigs, AXPWorkflowNextStep, AXPWorkflowOutputDescriptor, AXPWorkflowProvider, AXPWorkflowProviderToken, AXPWorkflowState, AXPWorkflowStatus, AXPWorkflowStep, AXPWorkflowSubStatus, AXPWorkflowTask, ActivityExecutionResult, WorkflowCompleteResult, WorkflowExpressionContext, WorkflowResumeResult, WorkflowStartResult };