@acorex/connectivity 21.0.0-next.10 โ†’ 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.
@@ -6,6 +6,7 @@ import { AXPDataGenerator, AXPIconLogoConfig, AXPModuleManifestRegistry, AXPActi
6
6
  import { AXPEntityStorageService, AXP_DATA_SEEDER_TOKEN, AXP_ENTITY_STORAGE_BACKEND, AXPEntityService, AXMEntityCrudServiceImpl, AXPEntityDefinitionRegistryService, AXPMiddlewareAbortError, AXP_ENTITY_STORAGE_MIDDLEWARE, eventDispatchMiddleware, AXPDataSeederService } from '@acorex/platform/layout/entity';
7
7
  import * as i0 from '@angular/core';
8
8
  import { inject, Injectable, NgModule, Injector, runInInjectionContext, signal, Component } from '@angular/core';
9
+ import { AXMAssetManagementFeatureKeys, RootConfig as RootConfig$2, AXMAssetStatus } from '@acorex/modules/asset-management';
9
10
  import { AXMAssessmentManagementFeatureKeys, RootConfig as RootConfig$1, AXMAssessmentManagementPermissionKeys } from '@acorex/modules/assessment-management';
10
11
  import { AXPCommonFeatureKeys, AXPWidgetsList } from '@acorex/modules/common';
11
12
  import { AXMDataManagementFeatureKeys, AXMPermissionsKeys as AXMPermissionsKeys$2, RootConfig as RootConfig$c, AXMMetaDataDefinitionService, META_DATA_SELECTOR_FIELD, AXMQueryServiceImpl, AXMQueryService } from '@acorex/modules/data-management';
@@ -13,12 +14,11 @@ import { AXPHumanCapitalManagementFeatureKeys, AXMPermissionsKeys as AXMPermissi
13
14
  import { AXPSystemStatusType, AXPAppVersionService, AXPSystemStatuses, AXPFileStorageStatus, AXPFileStorageService, AXVChangeType as AXVChangeType$1, AXP_SEARCH_PROVIDER, AXPLockService, AXPVersioningService } from '@acorex/platform/common';
14
15
  import { RootConfig, AXMPermissionsKeys, AXMApplicationService, AXMEditionService } from '@acorex/modules/application-management';
15
16
  import { provideQuerySetups, AXPCommandService, provideCommandSetups, AXPQueryService, AXPRuntimeModule } from '@acorex/platform/runtime';
16
- import { RootConfig as RootConfig$2, AXMAssetStatus } from '@acorex/modules/asset-management';
17
17
  import { RootConfig as RootConfig$3 } from '@acorex/modules/locale-management';
18
18
  import { AXMPermissionsKeys as AXMPermissionsKeys$1, AXMSubscriptionManagementSubscriptionEntityService, AXMSubscriptionManagementSubscriptionPlanItemEntityService, RootConfig as RootConfig$t } from '@acorex/modules/subscription-management';
19
19
  import { AXPSecurityManagementPermissionKeys, RootConfig as RootConfig$5, AXMUsersEntityService, AXMPolicyService } from '@acorex/modules/security-management';
20
20
  import { AXMTenantManagementPermissionsKeys, AXMTenantService, AXMTenantManagementTenantUserEntityService, RootConfig as RootConfig$w } from '@acorex/modules/tenant-management';
21
- import { AXMPermissionsKeys as AXMPermissionsKeys$3, AXMDistributionInteractionServiceImpl, AXMDistributionServiceImpl, AXMDocumentService, AXMDistributionInteractionService, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMReviewService, AXMDocumentTypeServiceImpl, RootConfig as RootConfig$d, AXMReviewServiceImpl, AXMFolderService, AXMDistributionService, AXPDocumentManagementService } from '@acorex/modules/document-management';
21
+ import { AXMPermissionsKeys as AXMPermissionsKeys$3, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMReviewService, AXMDocumentTypeServiceImpl, RootConfig as RootConfig$d, AXMReviewServiceImpl, AXMDocumentService, AXMFolderService, AXPDocumentManagementService } from '@acorex/modules/document-management';
22
22
  import { AXMSettingsManagementPermissionKeys } from '@acorex/modules/settings-management';
23
23
  import { RootConfig as RootConfig$6 } from '@acorex/modules/business-core';
24
24
  import { RootConfig as RootConfig$7 } from '@acorex/modules/calendar-management';
@@ -58,7 +58,7 @@ import { CommonModule } from '@angular/common';
58
58
  import { RootConfig as RootConfig$h } from '@acorex/modules/learning-management';
59
59
  import { RootConfig as RootConfig$i } from '@acorex/modules/location-management';
60
60
  import { RootConfig as RootConfig$j } from '@acorex/modules/measurement-core';
61
- import { RootConfig as RootConfig$k } from '@acorex/modules/meeting-management';
61
+ import { RootConfig as RootConfig$k, AXMMeetingStatusProvider } from '@acorex/modules/meeting-management';
62
62
  import { RootConfig as RootConfig$m, AXMOrgChartNodeType } from '@acorex/modules/organization-management';
63
63
  import { RootConfig as RootConfig$n } from '@acorex/modules/person-management';
64
64
  import { RootConfig as RootConfig$o } from '@acorex/modules/platform-management';
@@ -272,6 +272,7 @@ const APPLICATION_TREE = [
272
272
  title: 'Basic',
273
273
  description: 'Basic safety incident tracking and reporting capabilities.',
274
274
  featureKeys: [
275
+ 'AssetManagement',
275
276
  'DataManagement',
276
277
  'HumanCapitalManagement',
277
278
  'OrganizationManagement',
@@ -288,6 +289,9 @@ const APPLICATION_TREE = [
288
289
  AXPHumanCapitalManagementFeatureKeys.LeaveManagement,
289
290
  AXMAssessmentManagementFeatureKeys.QuestionnaireManagement,
290
291
  AXMDataManagementFeatureKeys.MetaDataDefinitions,
292
+ AXMAssetManagementFeatureKeys.AssetManagement,
293
+ AXMAssetManagementFeatureKeys.MaintenanceScheduling,
294
+ AXMAssetManagementFeatureKeys.InspectionWorkflow,
291
295
  ],
292
296
  },
293
297
  {
@@ -11657,6 +11661,13 @@ const workflowDefinitionMock = [
11657
11661
  },
11658
11662
  },
11659
11663
  },
11664
+ bindings: [
11665
+ {
11666
+ entityTypes: ['ContentManagement.Promotion'],
11667
+ eventTypes: ['create'],
11668
+ enabled: true,
11669
+ },
11670
+ ],
11660
11671
  },
11661
11672
  ];
11662
11673
  /**
@@ -12824,6 +12835,48 @@ class AXCWorkflowEngine {
12824
12835
  };
12825
12836
  await this.db.bookmarks.add(bookmark, bookmark.id);
12826
12837
  console.log(`[AXCWorkflowEngine] ๐Ÿ“Œ Created bookmark: ${bookmarkId} for activity ${activityId}`);
12838
+ // Create work item from bookmark
12839
+ try {
12840
+ // Get workflow instance to get workflow name
12841
+ const instance = await this.db.instances.get(instanceId);
12842
+ if (!instance) {
12843
+ console.warn(`[AXCWorkflowEngine] โš ๏ธ Instance ${instanceId} not found, skipping work item creation`);
12844
+ return;
12845
+ }
12846
+ // Get workflow definition to get workflow title
12847
+ const workflowDef = await this.getDefinition(instance.definitionId || instance.name || '');
12848
+ const workflowTitle = workflowDef?.title || instance.name || 'Workflow';
12849
+ // Get activity definition for title
12850
+ const activityDef = await this.activityDefinitionService.getActivityByName(payload.activityType || payload.activityName);
12851
+ const activityTitle = activityDef?.title || payload.activityName || activityId;
12852
+ // Create a meaningful title
12853
+ const workItemTitle = `${workflowTitle} - ${activityTitle}`;
12854
+ // Create work item
12855
+ const workItem = {
12856
+ id: AXPDataGenerator.uuid(),
12857
+ instanceId: instanceId,
12858
+ bookmarkId: bookmarkId,
12859
+ activityNodeId: activityId,
12860
+ activityName: payload.activityName || payload.activityType || activityId,
12861
+ title: workItemTitle,
12862
+ description: `Action required for ${workflowTitle}: ${activityTitle}`,
12863
+ kind: 'HumanTask',
12864
+ status: 'Pending',
12865
+ priority: 'Normal',
12866
+ assignedUserId: null, // Will be assigned later
12867
+ correlationId: instance.correlationId || null,
12868
+ entityRefId: instance.entityRefId || null,
12869
+ entityRefType: instance.entityRefType || null,
12870
+ createdAt: now,
12871
+ updatedAt: now,
12872
+ };
12873
+ await this.entityStorageService.insertOne('WorkflowManagement.WorkItem', workItem);
12874
+ console.log(`[AXCWorkflowEngine] โœ… Created work item: ${workItem.id} for bookmark ${bookmarkId} with title: ${workItemTitle}`);
12875
+ }
12876
+ catch (error) {
12877
+ console.error(`[AXCWorkflowEngine] โŒ Failed to create work item for bookmark ${bookmarkId}:`, error);
12878
+ // Don't fail bookmark creation if work item creation fails
12879
+ }
12827
12880
  }
12828
12881
  /**
12829
12882
  * Consume (mark as consumed) a bookmark for a workflow instance.
@@ -18375,307 +18428,6 @@ i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
18375
18428
  }]
18376
18429
  }] });
18377
18430
 
18378
- class AXCDistributionInteractionMockService extends AXMDistributionInteractionServiceImpl {
18379
- constructor() {
18380
- super(...arguments);
18381
- //#region ---- Services & Dependencies ----
18382
- this.usersService = inject(AXMUsersEntityService);
18383
- this.sessionService = inject(AXPSessionService);
18384
- }
18385
- //#endregion
18386
- async query(request) {
18387
- // Raw mode: return ungrouped interaction items (used for bulk aggregation)
18388
- if (request?.params?.raw === true) {
18389
- const rawRes = await super.query({
18390
- filter: request.filter,
18391
- sort: request.sort,
18392
- params: request.params,
18393
- take: 100000,
18394
- skip: 0,
18395
- });
18396
- const total = rawRes.items.length;
18397
- const skip = request?.skip ?? 0;
18398
- const take = request?.take ?? total;
18399
- const pagedItems = rawRes.items.slice(skip, skip + take);
18400
- return {
18401
- items: pagedItems,
18402
- total,
18403
- };
18404
- }
18405
- const items = (await super.query({
18406
- filter: request.filter,
18407
- sort: request.sort,
18408
- params: request.params,
18409
- take: 100000,
18410
- skip: 0,
18411
- })).items;
18412
- // Extract documentDistributionId from request filter
18413
- let documentDistributionId;
18414
- if (request.filter && typeof request.filter === 'object') {
18415
- if (request.filter.filters && request.filter.filters.length > 0 && request.filter.filters[0].field === 'documentDistributionId') {
18416
- documentDistributionId = request.filter.filters[0].value;
18417
- }
18418
- }
18419
- // Get the distribution record to access assignedTo property using storage service to avoid circular calls
18420
- if (documentDistributionId) {
18421
- try {
18422
- // Use storage service directly to get distribution record
18423
- const distribution = await this.storageService.getOne('DocumentManagement.Distribution', documentDistributionId);
18424
- if (distribution && distribution.assignedTo && Array.isArray(distribution.assignedTo)) {
18425
- // Get all assigned user IDs
18426
- const assignedUserIds = distribution.assignedTo.map((user) => user.id || user);
18427
- // Get existing interaction user IDs (from created.user.id)
18428
- const existingUserIds = new Set(items
18429
- .map((item) => item?.created?.user?.id)
18430
- .filter((id) => !!id));
18431
- // Find users who are assigned but don't have interaction records
18432
- const missingUserIds = assignedUserIds.filter((userId) => !existingUserIds.has(userId));
18433
- // Create missing interaction records
18434
- for (const userId of missingUserIds) {
18435
- let fullName = 'Unknown';
18436
- try {
18437
- const userRes = await this.usersService.query({
18438
- skip: 0,
18439
- take: 1,
18440
- filter: { field: 'id', operator: { type: 'equal' }, value: userId },
18441
- });
18442
- const u = userRes.items?.[0];
18443
- if (u) {
18444
- const candidate = `${u.firstName ?? ''} ${u.lastName ?? ''}`.trim();
18445
- fullName = candidate || u.username || u.title || u.name || fullName;
18446
- }
18447
- }
18448
- catch { }
18449
- const missingRecord = {
18450
- id: `missing-${documentDistributionId}-${userId}`,
18451
- documentDistributionId: documentDistributionId,
18452
- auditInfo: {
18453
- created: { at: new Date(), by: { id: userId, type: 'user', fullName } },
18454
- updated: { at: new Date(), by: { id: userId, type: 'user', fullName } },
18455
- },
18456
- action: 'Fake', // Default action, but with false flags
18457
- };
18458
- // Add the missing record to the items array
18459
- items.push(missingRecord);
18460
- }
18461
- }
18462
- }
18463
- catch (error) {
18464
- }
18465
- }
18466
- // Group items by creator user id
18467
- const groupedItems = this.groupItemsByCreatedBy(items);
18468
- // Collect distinct user IDs from grouped items
18469
- const userIds = Array.from(new Set(groupedItems.map((g) => g.createdBy).filter((id) => !!id)));
18470
- // Fetch users by IDs (in operator)
18471
- let usersMap = new Map();
18472
- if (userIds.length > 0) {
18473
- try {
18474
- const usersRes = await this.usersService.query({
18475
- skip: 0,
18476
- take: userIds.length,
18477
- filter: {
18478
- field: 'id',
18479
- operator: { type: 'in' },
18480
- value: userIds,
18481
- },
18482
- });
18483
- usersMap = new Map(usersRes.items.map((u) => [
18484
- u.id,
18485
- {
18486
- id: u.id,
18487
- name: u.username,
18488
- title: `${u.firstName} ${u.lastName}`,
18489
- },
18490
- ]));
18491
- }
18492
- catch {
18493
- // If fetching users fails, continue without enrichment
18494
- usersMap = new Map();
18495
- }
18496
- }
18497
- // Convert grouped items back to the expected format with user enrichment
18498
- const enrichedItems = groupedItems.map((summary) => ({
18499
- id: summary.id,
18500
- createdBy: summary.createdBy,
18501
- hasViewed: summary.hasViewed,
18502
- lastViewDate: summary.lastViewDate,
18503
- hasSigned: summary.hasSigned,
18504
- lastSignDate: summary.lastSignDate,
18505
- totalInteractions: summary.totalInteractions,
18506
- user: usersMap.get(summary.createdBy) ?? {
18507
- id: this.sessionService?.user?.id ?? '',
18508
- name: this.sessionService?.user?.name ?? '',
18509
- title: this.sessionService?.user?.title ?? '',
18510
- },
18511
- }));
18512
- // Apply pagination using request.skip and request.take
18513
- const total = enrichedItems.length;
18514
- const skip = request?.skip ?? 0;
18515
- const take = request?.take ?? total;
18516
- const pagedItems = enrichedItems.slice(skip, skip + take);
18517
- return {
18518
- items: pagedItems,
18519
- total,
18520
- };
18521
- }
18522
- /**
18523
- * Groups distribution interaction items by createdBy and creates a summary
18524
- */
18525
- groupItemsByCreatedBy(items) {
18526
- console.log(items);
18527
- const groupedMap = new Map();
18528
- for (const item of items) {
18529
- const createdBy = item?.created?.user?.id || 'unknown';
18530
- if (!groupedMap.has(createdBy)) {
18531
- // Initialize summary for new createdBy
18532
- groupedMap.set(createdBy, {
18533
- id: createdBy, // Use createdBy as the ID for the summary
18534
- createdBy: createdBy,
18535
- hasViewed: false,
18536
- lastViewDate: undefined,
18537
- hasSigned: false,
18538
- lastSignDate: undefined,
18539
- totalInteractions: 0,
18540
- });
18541
- }
18542
- const summary = groupedMap.get(createdBy);
18543
- summary.totalInteractions++;
18544
- // Check for view actions
18545
- if (item.action === 'Viewed') {
18546
- summary.hasViewed = true;
18547
- // Update last view date if this is more recent
18548
- if (!summary.lastViewDate || item.actionTime && item.actionTime > summary.lastViewDate) {
18549
- summary.lastViewDate = item.actionTime;
18550
- }
18551
- }
18552
- // Check for sign actions
18553
- if (item.action === 'Signed') {
18554
- summary.hasSigned = true;
18555
- // Update last sign date if this is more recent
18556
- if (!summary.lastSignDate || item.actionTime && item.actionTime > summary.lastSignDate) {
18557
- summary.lastSignDate = item.actionTime;
18558
- }
18559
- }
18560
- }
18561
- return Array.from(groupedMap.values());
18562
- }
18563
- static { this.ษตfac = i0.ษตษตngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionInteractionMockService, deps: null, target: i0.ษตษตFactoryTarget.Injectable }); }
18564
- static { this.ษตprov = i0.ษตษตngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionInteractionMockService }); }
18565
- }
18566
- i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionInteractionMockService, decorators: [{
18567
- type: Injectable
18568
- }] });
18569
-
18570
- class AXCDistributionMockService extends AXMDistributionServiceImpl {
18571
- constructor() {
18572
- super(...arguments);
18573
- //#region ---- Services & Dependencies ----
18574
- this.documentService = inject(AXMDocumentService);
18575
- this.distributionInteractionService = inject(AXMDistributionInteractionService);
18576
- }
18577
- //#endregion
18578
- async query(request) {
18579
- // Fetch all related distribution interactions once if distributionId filter is not provided
18580
- // We will use this to compute view/sign counts and status per distribution
18581
- // Get the list of distributions from parent service
18582
- const result = await super.query(request);
18583
- if (result && result.items && result.items.length > 0) {
18584
- // Prefetch all interactions once and group by distribution id
18585
- let allInteractions = [];
18586
- try {
18587
- const allRes = await this.distributionInteractionService.query({
18588
- skip: 0,
18589
- take: 100000,
18590
- params: { raw: true },
18591
- });
18592
- allInteractions = allRes.items || [];
18593
- }
18594
- catch {
18595
- allInteractions = [];
18596
- }
18597
- const interactionsByDistribution = new Map();
18598
- for (const it of allInteractions) {
18599
- const key = it?.documentDistributionId;
18600
- if (!key)
18601
- continue;
18602
- if (!interactionsByDistribution.has(key)) {
18603
- interactionsByDistribution.set(key, []);
18604
- }
18605
- interactionsByDistribution.get(key).push(it);
18606
- }
18607
- // Populate document field for each distribution
18608
- for (const distribution of result.items) {
18609
- if (distribution.documentId) {
18610
- try {
18611
- // Fetch the associated document
18612
- const document = await this.documentService.getOne(distribution.documentId);
18613
- if (document) {
18614
- // Populate the document field (assuming it should contain the document title/name)
18615
- distribution.document = document;
18616
- }
18617
- }
18618
- catch (error) {
18619
- // Continue without the document data if fetch fails
18620
- }
18621
- }
18622
- // Compute interactions summary for this distribution using prefetched interactions
18623
- try {
18624
- const interactions = interactionsByDistribution.get(distribution.id) || [];
18625
- const viewers = new Set();
18626
- const signers = new Set();
18627
- for (const it of interactions) {
18628
- const createdBy = it?.createdBy;
18629
- if (!createdBy)
18630
- continue;
18631
- if (it.action === 'Viewed')
18632
- viewers.add(createdBy);
18633
- if (it.action === 'Signed')
18634
- signers.add(createdBy);
18635
- }
18636
- distribution.viewedCount = `${viewers.size}/${distribution.assignedTo.length}`;
18637
- distribution.signedCount = `${signers.size}/${distribution.assignedTo.length}`;
18638
- const assignedCount = Array.isArray(distribution.assignedTo)
18639
- ? distribution.assignedTo.length
18640
- : distribution.assignedTo
18641
- ? 1
18642
- : 0;
18643
- distribution.status = assignedCount > 0 && signers.size === assignedCount ? 'done' : 'in-progress';
18644
- }
18645
- catch (error) {
18646
- distribution.viewedCount = distribution.viewedCount ?? `${0}/${distribution.assignedTo.length}`;
18647
- distribution.signedCount = distribution.signedCount ?? `${0}/${distribution.assignedTo.length}`;
18648
- distribution.status = distribution.status ?? 'in-progress';
18649
- }
18650
- }
18651
- }
18652
- return result;
18653
- }
18654
- async getOne(id) {
18655
- // Get the distribution record from parent service
18656
- const distribution = await super.getOne(id);
18657
- if (distribution && distribution.documentId) {
18658
- try {
18659
- // Fetch the associated document
18660
- const document = await this.documentService.getOne(distribution.documentId);
18661
- if (document) {
18662
- // Populate the document field (assuming it should contain the document title/name)
18663
- distribution.document = document;
18664
- }
18665
- }
18666
- catch (error) {
18667
- // Continue without the document data if fetch fails
18668
- }
18669
- }
18670
- return distribution;
18671
- }
18672
- static { this.ษตfac = i0.ษตษตngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionMockService, deps: null, target: i0.ษตษตFactoryTarget.Injectable }); }
18673
- static { this.ษตprov = i0.ษตษตngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionMockService }); }
18674
- }
18675
- i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDistributionMockService, decorators: [{
18676
- type: Injectable
18677
- }] });
18678
-
18679
18431
  class AXCFolderMockService extends AXMFolderServiceImpl {
18680
18432
  async updateParentFolders(folder) {
18681
18433
  if (folder.parentId) {
@@ -18926,7 +18678,6 @@ class AXMFileMockService extends AXMDocumentServiceImpl {
18926
18678
  ],
18927
18679
  },
18928
18680
  });
18929
- item.documentReview = reviewResult.items[0];
18930
18681
  }
18931
18682
  }
18932
18683
  catch (error) {
@@ -19105,7 +18856,6 @@ const DOCUMENT_TYPES = [
19105
18856
  enableVersioning: true,
19106
18857
  enableExpiration: false,
19107
18858
  requiresReview: true,
19108
- requiresDistribution: false,
19109
18859
  metaDataList: [
19110
18860
  {
19111
18861
  id: AXPDataGenerator.uuid(),
@@ -19159,7 +18909,6 @@ const DOCUMENT_TYPES = [
19159
18909
  enableVersioning: false,
19160
18910
  enableExpiration: false,
19161
18911
  requiresReview: false,
19162
- requiresDistribution: false,
19163
18912
  control: { isSystem: true },
19164
18913
  metaDataList: [],
19165
18914
  type: {
@@ -19181,7 +18930,6 @@ const DOCUMENT_TYPES = [
19181
18930
  enableVersioning: true,
19182
18931
  enableExpiration: true,
19183
18932
  requiresReview: true,
19184
- requiresDistribution: true,
19185
18933
  metaDataList: [
19186
18934
  {
19187
18935
  id: AXPDataGenerator.uuid(),
@@ -19839,13 +19587,11 @@ class AXCDocumentManagementMockModule {
19839
19587
  { provide: AXP_DATA_SEEDER_TOKEN, useClass: AXCDocumentTypeDataSeeder, multi: true },
19840
19588
  { provide: AXMFolderService, useClass: AXCFolderMockService },
19841
19589
  { provide: AXMDocumentService, useClass: AXMFileMockService },
19842
- { provide: AXMDistributionService, useClass: AXCDistributionMockService },
19843
19590
  { provide: AXMReviewService, useClass: AXCReviewMockService },
19844
19591
  {
19845
19592
  provide: AXPDocumentManagementService,
19846
19593
  useClass: AXCDocumentManagementService,
19847
19594
  },
19848
- { provide: AXMDistributionInteractionService, useClass: AXCDistributionInteractionMockService },
19849
19595
  ] }); }
19850
19596
  }
19851
19597
  i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXCDocumentManagementMockModule, decorators: [{
@@ -19859,13 +19605,11 @@ i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
19859
19605
  { provide: AXP_DATA_SEEDER_TOKEN, useClass: AXCDocumentTypeDataSeeder, multi: true },
19860
19606
  { provide: AXMFolderService, useClass: AXCFolderMockService },
19861
19607
  { provide: AXMDocumentService, useClass: AXMFileMockService },
19862
- { provide: AXMDistributionService, useClass: AXCDistributionMockService },
19863
19608
  { provide: AXMReviewService, useClass: AXCReviewMockService },
19864
19609
  {
19865
19610
  provide: AXPDocumentManagementService,
19866
19611
  useClass: AXCDocumentManagementService,
19867
19612
  },
19868
- { provide: AXMDistributionInteractionService, useClass: AXCDistributionInteractionMockService },
19869
19613
  ],
19870
19614
  }]
19871
19615
  }] });
@@ -34838,6 +34582,11 @@ const meetingIds = {
34838
34582
  projectReview1: AXPDataGenerator.uuid()
34839
34583
  };
34840
34584
  //#endregion
34585
+ //#region ---- Meeting Status Definitions ----
34586
+ // Use status provider to get status definitions
34587
+ const meetingStatusProvider = new AXMMeetingStatusProvider();
34588
+ const MEETING_STATUS_DEFINITIONS = meetingStatusProvider.statuses;
34589
+ //#endregion
34841
34590
  const meetingMock = [
34842
34591
  //#region ---- Daily Standups ----
34843
34592
  {
@@ -34845,12 +34594,14 @@ const meetingMock = [
34845
34594
  title: 'Development Team Daily Standup',
34846
34595
  meetingNotes: 'Daily sync for the development team. Discuss yesterday\'s progress, today\'s plans, and any blockers.',
34847
34596
  meetingType: {
34848
- id: meetingTypeMock[0].id,
34849
- title: meetingTypeMock[0].title
34597
+ id: meetingTypeMock[5].id,
34598
+ title: meetingTypeMock[5].title
34850
34599
  },
34851
34600
  meetingProviderType: 'OnSite',
34852
34601
  isRecorded: false,
34853
- mettingStatus: 'Completed',
34602
+ setInGoogleCalendar: true,
34603
+ meetingStatusId: MEETING_STATUS_DEFINITIONS[0].name,
34604
+ meetingStatus: { id: MEETING_STATUS_DEFINITIONS[0].name, title: MEETING_STATUS_DEFINITIONS[0].title },
34854
34605
  isFullysignedOff: true,
34855
34606
  meetingLocationId: {
34856
34607
  id: locationMock[0].id,
@@ -34869,7 +34620,9 @@ const meetingMock = [
34869
34620
  joinUrl: 'https://zoom.us/j/1234567890',
34870
34621
  hostUrl: 'https://zoom.us/j/1234567890?role=1',
34871
34622
  isRecorded: true,
34872
- mettingStatus: 'In Progress',
34623
+ setInGoogleCalendar: false,
34624
+ meetingStatusId: MEETING_STATUS_DEFINITIONS[1].name,
34625
+ meetingStatus: { id: MEETING_STATUS_DEFINITIONS[1].name, title: MEETING_STATUS_DEFINITIONS[1].title },
34873
34626
  isFullysignedOff: false,
34874
34627
  },
34875
34628
  //#endregion
@@ -34886,7 +34639,9 @@ const meetingMock = [
34886
34639
  joinUrl: 'https://meet.google.com/abc-defg-hij',
34887
34640
  hostUrl: 'https://meet.google.com/abc-defg-hij?hs=1',
34888
34641
  isRecorded: true,
34889
- mettingStatus: 'Scheduled',
34642
+ setInGoogleCalendar: true,
34643
+ meetingStatusId: MEETING_STATUS_DEFINITIONS[2].name,
34644
+ meetingStatus: { id: MEETING_STATUS_DEFINITIONS[2].name, title: MEETING_STATUS_DEFINITIONS[2].title },
34890
34645
  isFullysignedOff: false,
34891
34646
  meetingLocationId: {
34892
34647
  id: locationMock[2].id,
@@ -34894,6 +34649,29 @@ const meetingMock = [
34894
34649
  }
34895
34650
  },
34896
34651
  //#endregion
34652
+ //#region ---- Published Meetings ----
34653
+ {
34654
+ id: AXPDataGenerator.uuid(),
34655
+ title: 'Monthly All-Hands Meeting',
34656
+ meetingNotes: 'Company-wide monthly meeting to discuss company updates, achievements, and upcoming initiatives. All employees are invited to attend.',
34657
+ meetingType: {
34658
+ id: meetingTypeMock[6].id,
34659
+ title: meetingTypeMock[6].title
34660
+ },
34661
+ meetingProviderType: 'Online',
34662
+ joinUrl: 'https://teams.microsoft.com/l/meetup-join/19:meeting_abc123',
34663
+ hostUrl: 'https://teams.microsoft.com/l/meetup-join/19:meeting_abc123?role=1',
34664
+ isRecorded: true,
34665
+ setInGoogleCalendar: true,
34666
+ meetingStatusId: MEETING_STATUS_DEFINITIONS[5].name,
34667
+ meetingStatus: { id: MEETING_STATUS_DEFINITIONS[5].name, title: MEETING_STATUS_DEFINITIONS[5].title },
34668
+ isFullysignedOff: false,
34669
+ meetingLocationId: {
34670
+ id: locationMock[0].id,
34671
+ title: locationMock[0].title
34672
+ }
34673
+ },
34674
+ //#endregion
34897
34675
  ];
34898
34676
 
34899
34677
  class AXMMeetingDataSeeder {
@@ -34950,7 +34728,7 @@ const meetingRoleTypeMock = [
34950
34728
  },
34951
34729
  {
34952
34730
  id: AXPDataGenerator.uuid(),
34953
- title: 'Observer',
34731
+ title: 'Attendie',
34954
34732
  meetingParticipantId: participantIds.participant5,
34955
34733
  },
34956
34734
  // {
@@ -35003,60 +34781,71 @@ const meetingRoleTypeMock = [
35003
34781
  // },
35004
34782
  ];
35005
34783
 
34784
+ //#region ---- Participant Status Definitions ----
34785
+ const PARTICIPANT_STATUS_DEFINITIONS = [
34786
+ { name: 'absent', title: 'Absent' },
34787
+ { name: 'present', title: 'Present' },
34788
+ { name: 'accept', title: 'Accept' },
34789
+ { name: 'decline', title: 'Decline' },
34790
+ ];
34791
+ //#endregion
35006
34792
  const meetingParticipantMock = [
35007
34793
  //#region ---- Daily Standup 1 Participants ----
35008
34794
  // Organizer - Sarah Johnson (Project Manager)
35009
34795
  {
35010
34796
  id: participantIds.participant1,
35011
34797
  meetingId: meetingIds.dailyStandup1,
35012
- userId: {
35013
- id: mockUsers[0].id,
35014
- title: mockUsers[0].displayName
34798
+ employeeId: {
34799
+ id: personMock[0].id,
34800
+ title: personMock[0].displayName,
35015
34801
  },
35016
34802
  jointime: new Date('2024-01-15T09:00:00'),
35017
34803
  leaveTime: new Date('2024-01-15T09:15:00'),
35018
34804
  duration: 15, // minutes
35019
34805
  signOffAt: new Date('2024-01-15T09:15:00'),
35020
- participantStatus: 'Present',
34806
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[1].name,
34807
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[1].name, title: PARTICIPANT_STATUS_DEFINITIONS[1].title },
35021
34808
  meetingRoleTypeIds: {
35022
34809
  id: meetingRoleTypeMock[0].id,
35023
- title: meetingRoleTypeMock[0].title
34810
+ title: meetingRoleTypeMock[0].title,
35024
34811
  },
35025
34812
  },
35026
34813
  // Co-Host - Mike Chen (Senior Developer)
35027
34814
  {
35028
34815
  id: participantIds.participant2,
35029
34816
  meetingId: meetingIds.dailyStandup1,
35030
- userId: {
35031
- id: mockUsers[1].id,
35032
- title: mockUsers[1].displayName
34817
+ employeeId: {
34818
+ id: personMock[1].id,
34819
+ title: personMock[1].displayName,
35033
34820
  },
35034
34821
  jointime: new Date('2024-01-15T09:01:00'),
35035
34822
  leaveTime: new Date('2024-01-15T09:15:00'),
35036
34823
  duration: 14, // minutes
35037
34824
  signOffAt: new Date('2024-01-15T09:15:00'),
35038
- participantStatus: 'Present',
34825
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[2].name,
34826
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[2].name, title: PARTICIPANT_STATUS_DEFINITIONS[2].title },
35039
34827
  meetingRoleTypeIds: {
35040
34828
  id: meetingRoleTypeMock[1].id,
35041
- title: meetingRoleTypeMock[1].title
34829
+ title: meetingRoleTypeMock[1].title,
35042
34830
  },
35043
34831
  },
35044
34832
  // Participant - Emily Rodriguez (Designer)
35045
34833
  {
35046
34834
  id: participantIds.participant3,
35047
34835
  meetingId: meetingIds.dailyStandup1,
35048
- userId: {
35049
- id: mockUsers[2].id,
35050
- title: mockUsers[2].displayName
34836
+ employeeId: {
34837
+ id: personMock[2].id,
34838
+ title: personMock[2].displayName,
35051
34839
  },
35052
34840
  jointime: new Date('2024-01-15T09:02:00'),
35053
34841
  leaveTime: new Date('2024-01-15T09:14:00'),
35054
34842
  duration: 12, // minutes
35055
34843
  signOffAt: new Date('2024-01-15T09:14:00'),
35056
- participantStatus: 'Present',
34844
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[1].name,
34845
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[1].name, title: PARTICIPANT_STATUS_DEFINITIONS[1].title },
35057
34846
  meetingRoleTypeIds: {
35058
34847
  id: meetingRoleTypeMock[2].id,
35059
- title: meetingRoleTypeMock[2].title
34848
+ title: meetingRoleTypeMock[2].title,
35060
34849
  },
35061
34850
  },
35062
34851
  //#endregion
@@ -35065,36 +34854,38 @@ const meetingParticipantMock = [
35065
34854
  {
35066
34855
  id: participantIds.participant4,
35067
34856
  meetingId: meetingIds.dailyStandup2,
35068
- userId: {
35069
- id: mockUsers[3].id,
35070
- title: mockUsers[3].displayName
34857
+ employeeId: {
34858
+ id: personMock[3].id,
34859
+ title: personMock[3].displayName,
35071
34860
  },
35072
34861
  jointime: new Date('2024-01-16T10:00:00'),
35073
34862
  leaveTime: null, // Still in meeting
35074
34863
  duration: 0, // Still ongoing
35075
34864
  signOffAt: null,
35076
- participantStatus: 'Present',
34865
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[1].name,
34866
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[1].name, title: PARTICIPANT_STATUS_DEFINITIONS[1].title },
35077
34867
  meetingRoleTypeIds: {
35078
34868
  id: meetingRoleTypeMock[3].id,
35079
- title: meetingRoleTypeMock[3].title
34869
+ title: meetingRoleTypeMock[3].title,
35080
34870
  },
35081
34871
  },
35082
34872
  // Observer - Lisa Wang (HR Director)
35083
34873
  {
35084
34874
  id: participantIds.participant5,
35085
34875
  meetingId: meetingIds.dailyStandup2,
35086
- userId: {
35087
- id: mockUsers[4].id,
35088
- title: mockUsers[4].displayName
34876
+ employeeId: {
34877
+ id: personMock[4].id,
34878
+ title: personMock[4].displayName,
35089
34879
  },
35090
34880
  jointime: new Date('2024-01-16T10:01:00'),
35091
34881
  leaveTime: null, // Still in meeting
35092
34882
  duration: 0, // Still ongoing
35093
34883
  signOffAt: null,
35094
- participantStatus: 'Present',
34884
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[1].name,
34885
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[1].name, title: PARTICIPANT_STATUS_DEFINITIONS[1].title },
35095
34886
  meetingRoleTypeIds: {
35096
34887
  id: meetingRoleTypeMock[4].id,
35097
- title: meetingRoleTypeMock[4].title
34888
+ title: meetingRoleTypeMock[4].title,
35098
34889
  },
35099
34890
  },
35100
34891
  //#endregion
@@ -35103,75 +34894,79 @@ const meetingParticipantMock = [
35103
34894
  {
35104
34895
  id: participantIds.participant6,
35105
34896
  meetingId: meetingIds.projectReview1,
35106
- userId: {
35107
- id: mockUsers[5].id,
35108
- title: mockUsers[5].displayName
34897
+ employeeId: {
34898
+ id: personMock[5].id,
34899
+ title: personMock[5].displayName,
35109
34900
  },
35110
34901
  jointime: new Date('2024-01-18T14:00:00'),
35111
34902
  leaveTime: new Date('2024-01-18T15:30:00'),
35112
34903
  duration: 90, // minutes
35113
34904
  signOffAt: new Date('2024-01-18T15:30:00'),
35114
- participantStatus: 'Left',
34905
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[0].name,
34906
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[0].name, title: PARTICIPANT_STATUS_DEFINITIONS[0].title },
35115
34907
  meetingRoleTypeIds: {
35116
34908
  id: meetingRoleTypeMock[5].id,
35117
- title: meetingRoleTypeMock[5].title
34909
+ title: meetingRoleTypeMock[5].title,
35118
34910
  },
35119
34911
  },
35120
34912
  // Co-Host - Alice Smith (Product Manager)
35121
34913
  {
35122
34914
  id: participantIds.participant7,
35123
34915
  meetingId: meetingIds.projectReview1,
35124
- userId: {
35125
- id: mockUsers[6].id,
35126
- title: mockUsers[6].displayName
34916
+ employeeId: {
34917
+ id: personMock[6].id,
34918
+ title: personMock[6].displayName,
35127
34919
  },
35128
34920
  jointime: new Date('2024-01-18T14:00:00'),
35129
34921
  leaveTime: new Date('2024-01-18T15:30:00'),
35130
34922
  duration: 90, // minutes
35131
34923
  signOffAt: new Date('2024-01-18T15:30:00'),
35132
- participantStatus: 'Left',
34924
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[0].name,
34925
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[0].name, title: PARTICIPANT_STATUS_DEFINITIONS[0].title },
35133
34926
  meetingRoleTypeIds: {
35134
34927
  id: meetingRoleTypeMock[4].id,
35135
- title: meetingRoleTypeMock[4].title
34928
+ title: meetingRoleTypeMock[4].title,
35136
34929
  },
35137
34930
  },
35138
34931
  // Participant - Emily Rodriguez (Designer)
35139
34932
  {
35140
34933
  id: participantIds.participant8,
35141
34934
  meetingId: meetingIds.projectReview1,
35142
- userId: {
35143
- id: mockUsers[7].id,
35144
- title: mockUsers[7].displayName
34935
+ employeeId: {
34936
+ id: personMock[7].id,
34937
+ title: personMock[7].displayName,
35145
34938
  },
35146
34939
  jointime: new Date('2024-01-18T14:02:00'),
35147
34940
  leaveTime: new Date('2024-01-18T15:28:00'),
35148
34941
  duration: 86, // minutes
35149
34942
  signOffAt: new Date('2024-01-18T15:28:00'),
35150
- participantStatus: 'Left',
34943
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[0].name,
34944
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[0].name, title: PARTICIPANT_STATUS_DEFINITIONS[0].title },
35151
34945
  meetingRoleTypeIds: {
35152
34946
  id: meetingRoleTypeMock[5].id,
35153
- title: meetingRoleTypeMock[5].title
34947
+ title: meetingRoleTypeMock[5].title,
35154
34948
  },
35155
34949
  },
35156
34950
  // Observer - Lisa Wang (HR Director)
35157
34951
  {
35158
34952
  id: participantIds.participant9,
35159
34953
  meetingId: meetingIds.projectReview1,
35160
- userId: {
35161
- id: mockUsers[8].id,
35162
- title: mockUsers[8].displayName
34954
+ employeeId: {
34955
+ id: personMock[8].id,
34956
+ title: personMock[8].displayName,
35163
34957
  },
35164
34958
  jointime: new Date('2024-01-18T14:15:00'),
35165
34959
  leaveTime: new Date('2024-01-18T15:30:00'),
35166
34960
  duration: 75, // minutes
35167
34961
  signOffAt: new Date('2024-01-18T15:30:00'),
35168
- participantStatus: 'Left',
34962
+ participantStatusId: PARTICIPANT_STATUS_DEFINITIONS[0].name,
34963
+ participantStatus: { id: PARTICIPANT_STATUS_DEFINITIONS[0].name, title: PARTICIPANT_STATUS_DEFINITIONS[0].title },
35169
34964
  meetingRoleTypeIds: {
35170
34965
  id: meetingRoleTypeMock[3].id,
35171
- title: meetingRoleTypeMock[3].title
34966
+ title: meetingRoleTypeMock[3].title,
35172
34967
  },
35173
34968
  },
35174
- //#endregion
34969
+ //#endregion
35175
34970
  ];
35176
34971
 
35177
34972
  class AXMMeetingParticipantDataSeeder {
@@ -48493,6 +48288,9 @@ i0.ษตษตngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
48493
48288
  type: Injectable
48494
48289
  }], ctorParameters: () => [] });
48495
48290
 
48291
+ /**
48292
+ * Mock workflow definition entities for the entity list.
48293
+ */
48496
48294
  /**
48497
48295
  * Mock workflow definition entities for the entity list.
48498
48296
  */
@@ -48522,6 +48320,8 @@ const workflowDefinitionEntityMock = workflowDefinitionMock.map((def) => {
48522
48320
  graph: def.graph,
48523
48321
  customProperties: def.customProperties || {},
48524
48322
  extensions: def.extensions || {},
48323
+ // Bindings for workflow trigger (from def.bindings)
48324
+ bindings: def.bindings,
48525
48325
  };
48526
48326
  });
48527
48327
 
@@ -50143,41 +49943,54 @@ const workflowTriggerMiddleware = {
50143
49943
  const workflowManager = inject(AXPWorkflowManager);
50144
49944
  const storageService = inject(AXPEntityStorageService);
50145
49945
  const workflowDefinitionService = inject(AXPWorkflowDefinitionService);
49946
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ” Starting workflow trigger check for ${ctx.entityName}:${ctx.op}`);
49947
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“ Context details:`, {
49948
+ entityName: ctx.entityName,
49949
+ op: ctx.op,
49950
+ hasData: !!ctx.data,
49951
+ dataKeys: ctx.data ? Object.keys(ctx.data) : [],
49952
+ });
50146
49953
  // Execute next middleware first to ensure record is persisted
50147
49954
  await next();
50148
49955
  // Only proceed if record was persisted successfully
50149
49956
  if (!ctx.result) {
49957
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ No result from ${ctx.op} operation, skipping workflow trigger`);
50150
49958
  return;
50151
49959
  }
49960
+ const recordId = ctx.result;
49961
+ console.log(`[WorkflowTriggerMiddleware] โœ… Record persisted: ${ctx.entityName}:${recordId}`);
50152
49962
  try {
50153
49963
  // Get entity definition
50154
49964
  const [moduleName, entityName] = ctx.entityName.split('.');
49965
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“‹ Resolving entity definition: ${moduleName}.${entityName}`);
50155
49966
  const entityDef = await entityRegistry.resolve(moduleName, entityName);
50156
49967
  if (!entityDef) {
49968
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ Entity definition not found for ${ctx.entityName}`);
50157
49969
  return;
50158
49970
  }
49971
+ console.log(`[WorkflowTriggerMiddleware] โœ… Entity definition found, checking plugins...`);
50159
49972
  // Check if entity has WORKFLOW plugin enabled (workflow-capable check)
50160
49973
  const hasWorkflowPlugin = (entityDef.plugins ?? []).some((p) => p.name === 'workflow');
49974
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ”Œ Workflow plugin check: ${hasWorkflowPlugin ? 'โœ… Enabled' : 'โŒ Not enabled'}`);
50161
49975
  if (!hasWorkflowPlugin) {
50162
49976
  // Entity is not workflow-capable, skip
49977
+ console.log(`[WorkflowTriggerMiddleware] โญ๏ธ Entity ${ctx.entityName} is not workflow-capable, skipping`);
50163
49978
  return;
50164
49979
  }
50165
49980
  // Use operation directly as event type
50166
49981
  const eventType = ctx.op;
50167
- // Get the record ID
50168
- const recordId = ctx.result;
50169
- if (!recordId) {
50170
- console.warn(`[WorkflowTriggerMiddleware] No record ID returned from ${ctx.op} operation`);
50171
- return;
50172
- }
49982
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“Œ Event type: ${eventType}`);
50173
49983
  // Get all workflow definitions from providers (using workflow definition service)
50174
49984
  // We need to get all categories first, then get workflows for each category
50175
49985
  const allWorkflowDefinitions = [];
49986
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“š Fetching workflow definitions from providers...`);
50176
49987
  // Get root categories
50177
49988
  const rootCategories = await workflowDefinitionService.getCategories();
49989
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“ Found ${rootCategories.length} root categories`);
50178
49990
  // Recursively get workflows from all categories
50179
49991
  const getAllWorkflowsFromCategory = async (categoryId) => {
50180
49992
  const workflows = await workflowDefinitionService.getWorkflowsByCategoryId(categoryId);
49993
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“„ Category ${categoryId}: ${workflows.length} workflows`);
50181
49994
  allWorkflowDefinitions.push(...workflows);
50182
49995
  // Get child categories and recurse
50183
49996
  const childCategories = await workflowDefinitionService.getCategories(categoryId);
@@ -50189,12 +50002,10 @@ const workflowTriggerMiddleware = {
50189
50002
  for (const category of rootCategories) {
50190
50003
  await getAllWorkflowsFromCategory(category.id);
50191
50004
  }
50192
- if (allWorkflowDefinitions.length === 0) {
50193
- // No workflows found, nothing to trigger
50194
- return;
50195
- }
50005
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“š Total workflows from providers: ${allWorkflowDefinitions.length}`);
50196
50006
  // Get metadata (id, isPublished, isLatest, bindings) from storage service for each workflow
50197
50007
  // Query all workflow definitions from storage to get metadata
50008
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ’พ Querying workflow definitions from storage...`);
50198
50009
  const workflowMetadata = await storageService.query('WorkflowManagement.WorkflowDefinition', {
50199
50010
  filter: {
50200
50011
  field: 'isPublished',
@@ -50204,38 +50015,82 @@ const workflowTriggerMiddleware = {
50204
50015
  skip: 0,
50205
50016
  take: 1000,
50206
50017
  });
50207
- if (!workflowMetadata.items || workflowMetadata.items.length === 0) {
50208
- // No published workflows, nothing to trigger
50018
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ’พ Published workflows in storage: ${workflowMetadata.items?.length || 0}`);
50019
+ // If no workflows from providers, try to get them from storage
50020
+ if (allWorkflowDefinitions.length === 0) {
50021
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ No workflows found from providers, checking storage...`);
50022
+ if (!workflowMetadata.items || workflowMetadata.items.length === 0) {
50023
+ // No published workflows, nothing to trigger
50024
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ No published workflows in storage either`);
50025
+ return;
50026
+ }
50027
+ // Convert storage items to workflow definitions
50028
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“ฆ Converting ${workflowMetadata.items.length} workflows from storage to definitions...`);
50029
+ for (const item of workflowMetadata.items) {
50030
+ // Convert storage entity to workflow definition format
50031
+ const workflowDef = {
50032
+ schemaVersion: item.schemaVersion,
50033
+ name: item.name,
50034
+ title: item.title,
50035
+ description: item.description,
50036
+ variables: item.variables || [],
50037
+ inputs: item.inputs || [],
50038
+ outputs: item.outputs || [],
50039
+ graph: item.graph,
50040
+ customProperties: item.customProperties || {},
50041
+ extensions: item.extensions || {},
50042
+ bindings: item.bindings || [],
50043
+ };
50044
+ allWorkflowDefinitions.push(workflowDef);
50045
+ }
50046
+ console.log(`[WorkflowTriggerMiddleware] โœ… Loaded ${allWorkflowDefinitions.length} workflows from storage`);
50047
+ }
50048
+ // If still no workflows found, nothing to trigger
50049
+ if (allWorkflowDefinitions.length === 0) {
50050
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ No workflows found from providers or storage`);
50209
50051
  return;
50210
50052
  }
50211
50053
  // Merge workflow definitions from providers with metadata from storage
50212
50054
  const publishedWorkflows = [];
50055
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ”— Merging workflow definitions with metadata...`);
50213
50056
  for (const workflowDef of allWorkflowDefinitions) {
50214
50057
  // Find matching metadata by workflow name
50215
- const metadata = workflowMetadata.items.find((m) => m.name === workflowDef.name);
50058
+ const metadata = workflowMetadata.items?.find((m) => m.name === workflowDef.name);
50059
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ” Checking workflow '${workflowDef.name}': metadata found=${!!metadata}, isPublished=${metadata?.isPublished}`);
50216
50060
  if (metadata && metadata.isPublished === true) {
50217
- // Parse bindings if it's a JSON string (from CodeEditor widget)
50061
+ // Parse bindings: prefer metadata.bindings, fallback to workflowDef.bindings
50218
50062
  let bindings = [];
50063
+ // First try metadata.bindings (from entity storage)
50219
50064
  if (metadata.bindings) {
50065
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“‹ Metadata has bindings (type: ${typeof metadata.bindings})`);
50220
50066
  if (typeof metadata.bindings === 'string') {
50221
50067
  try {
50222
50068
  bindings = JSON.parse(metadata.bindings);
50069
+ console.log(`[WorkflowTriggerMiddleware] โœ… Parsed bindings from JSON:`, bindings);
50223
50070
  }
50224
50071
  catch (error) {
50225
- console.warn(`[WorkflowTriggerMiddleware] Failed to parse bindings for workflow '${workflowDef.name}':`, error);
50226
- continue;
50072
+ console.warn(`[WorkflowTriggerMiddleware] โŒ Failed to parse bindings for workflow '${workflowDef.name}':`, error);
50073
+ // Fall through to use workflowDef.bindings
50227
50074
  }
50228
50075
  }
50229
50076
  else if (Array.isArray(metadata.bindings)) {
50230
50077
  bindings = metadata.bindings;
50078
+ console.log(`[WorkflowTriggerMiddleware] โœ… Using bindings from metadata array:`, bindings);
50231
50079
  }
50232
50080
  }
50081
+ // Fallback to workflowDef.bindings if metadata doesn't have bindings
50082
+ if (bindings.length === 0 && workflowDef.bindings && workflowDef.bindings.length > 0) {
50083
+ bindings = workflowDef.bindings;
50084
+ console.log(`[WorkflowTriggerMiddleware] โœ… Using bindings from workflow definition:`, bindings);
50085
+ }
50086
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“Œ Final bindings for '${workflowDef.name}':`, bindings);
50233
50087
  publishedWorkflows.push({
50234
50088
  ...workflowDef,
50235
50089
  bindings,
50236
50090
  });
50237
50091
  }
50238
50092
  }
50093
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“š Total published workflows with bindings: ${publishedWorkflows.length}`);
50239
50094
  if (publishedWorkflows.length === 0) {
50240
50095
  // No published workflows with matching definitions, nothing to trigger
50241
50096
  return;
@@ -50268,10 +50123,11 @@ const workflowTriggerMiddleware = {
50268
50123
  }
50269
50124
  if (matchingWorkflows.length === 0) {
50270
50125
  // No matching bindings found
50271
- console.log(`[WorkflowTriggerMiddleware] No matching workflow bindings for ${ctx.entityName}:${recordId} on ${eventType}`);
50126
+ console.log(`[WorkflowTriggerMiddleware] โš ๏ธ No matching workflow bindings for ${ctx.entityName}:${recordId} on ${eventType}`);
50127
+ console.log(`[WorkflowTriggerMiddleware] ๐Ÿ“‹ Available workflows:`, publishedWorkflows.map(w => ({ name: w.name, bindings: w.bindings })));
50272
50128
  return;
50273
50129
  }
50274
- console.log(`[WorkflowTriggerMiddleware] Found ${matchingWorkflows.length} matching workflow(s) for ${ctx.entityName}:${recordId} on ${eventType}`);
50130
+ console.log(`[WorkflowTriggerMiddleware] โœ… Found ${matchingWorkflows.length} matching workflow(s) for ${ctx.entityName}:${recordId} on ${eventType}`);
50275
50131
  // Start workflow instances for each matching binding
50276
50132
  for (const { workflow, binding } of matchingWorkflows) {
50277
50133
  try {
@@ -50316,6 +50172,21 @@ const workflowTriggerMiddleware = {
50316
50172
  recordData, // Include record data if available
50317
50173
  correlationId, // Pass correlationId in input so workflow engine can use it
50318
50174
  };
50175
+ //TODO: Remove this once we have a proper signature workflow
50176
+ // For signature workflows, add default signers if not provided
50177
+ if (workflow.name === 'entity-signature-workflow' && !workflowInput.signers) {
50178
+ // Get default users for signing (first 2 users as default signers)
50179
+ try {
50180
+ const usersResult = await storageService.query('SecurityManagement.User', { skip: 0, take: 10 });
50181
+ if (usersResult.items && usersResult.items.length > 0) {
50182
+ workflowInput.signers = usersResult.items.slice(0, 2).map((user) => user.id);
50183
+ console.log(`[WorkflowTriggerMiddleware] Added default signers for signature workflow:`, workflowInput.signers);
50184
+ }
50185
+ }
50186
+ catch (error) {
50187
+ console.warn(`[WorkflowTriggerMiddleware] Could not load default signers:`, error);
50188
+ }
50189
+ }
50319
50190
  console.log(`[WorkflowTriggerMiddleware] ๐Ÿš€ Starting workflow '${workflow.name}' for ${ctx.entityName}:${recordId} on ${eventType}`, {
50320
50191
  correlationId,
50321
50192
  workflowName: workflow.name,