openxiangda-devkit-core 2.0.0-alpha.93 → 2.0.0-alpha.95

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.
@@ -1725,11 +1725,57 @@ export function validateAppConfig(value) {
1725
1725
  if (subscription.platformAccess !== undefined) {
1726
1726
  const access = object(subscription.platformAccess);
1727
1727
  const notification = object(access.notification);
1728
- if (Object.keys(access).some(key => key !== 'notification') ||
1729
- access.notification === undefined ||
1730
- notification.mode !== 'business-standard' ||
1731
- Object.keys(notification).some(key => key !== 'mode')) {
1732
- diagnostics.push(diagnostic('APP_CONFIG_EVENT_PLATFORM_ACCESS_INVALID', '事件订阅 platformAccess 只能显式声明标准业务通知依赖', `${path}.platformAccess`));
1728
+ const copies = Array.isArray(access.managedFileCopies)
1729
+ ? access.managedFileCopies
1730
+ : [];
1731
+ let copiesInvalid = access.managedFileCopies !== undefined &&
1732
+ (copies.length === 0 || copies.length > 16);
1733
+ const copyKeys = new Set();
1734
+ for (const rawCopy of copies) {
1735
+ const copy = object(rawCopy);
1736
+ const sourceResourceCode = string(copy.sourceResourceCode);
1737
+ const targetResourceCode = string(copy.targetResourceCode);
1738
+ const sourceFields = Array.isArray(copy.sourceFieldCodes)
1739
+ ? copy.sourceFieldCodes.map(string)
1740
+ : [];
1741
+ const targetFields = Array.isArray(copy.targetFieldCodes)
1742
+ ? copy.targetFieldCodes.map(string)
1743
+ : [];
1744
+ const source = eventResourceFields.get(sourceResourceCode);
1745
+ const target = eventResourceFields.get(targetResourceCode);
1746
+ copiesInvalid ||=
1747
+ copy.mode !== 'copy' ||
1748
+ !source ||
1749
+ !target ||
1750
+ sourceFields.length === 0 ||
1751
+ targetFields.length === 0 ||
1752
+ sourceFields.length > 16 ||
1753
+ targetFields.length > 16 ||
1754
+ new Set(sourceFields).size !== sourceFields.length ||
1755
+ new Set(targetFields).size !== targetFields.length ||
1756
+ sourceFields.some(field => !['file', 'image'].includes(source?.get(field) || '')) ||
1757
+ targetFields.some(field => !['file', 'image'].includes(target?.get(field) || '')) ||
1758
+ sourceFields.length !== targetFields.length ||
1759
+ sourceFields.some((field, i) => source?.get(field) !== target?.get(targetFields[i] || '')) ||
1760
+ Object.keys(copy).some(key => ![
1761
+ 'mode',
1762
+ 'sourceResourceCode',
1763
+ 'sourceFieldCodes',
1764
+ 'targetResourceCode',
1765
+ 'targetFieldCodes',
1766
+ ].includes(key));
1767
+ const key = `${sourceResourceCode}:${sourceFields.join(',')}=>${targetResourceCode}:${targetFields.join(',')}`;
1768
+ if (copyKeys.has(key))
1769
+ copiesInvalid = true;
1770
+ copyKeys.add(key);
1771
+ }
1772
+ if (Object.keys(access).some(key => !['notification', 'managedFileCopies'].includes(key)) ||
1773
+ (access.notification !== undefined &&
1774
+ (notification.mode !== 'business-standard' ||
1775
+ Object.keys(notification).some(key => key !== 'mode'))) ||
1776
+ (access.notification === undefined && access.managedFileCopies === undefined) ||
1777
+ copiesInvalid) {
1778
+ diagnostics.push(diagnostic('APP_CONFIG_EVENT_PLATFORM_ACCESS_INVALID', '事件订阅 platformAccess 只能显式声明标准业务通知或有界托管文件复制依赖', `${path}.platformAccess`));
1733
1779
  }
1734
1780
  }
1735
1781
  const delivery = {
@@ -2243,6 +2289,7 @@ function validateBackendOperations(rawOperations, declaredResources, declaredWor
2243
2289
  const allowedAccessKeys = new Set([
2244
2290
  'directory',
2245
2291
  'managedFiles',
2292
+ 'managedFileCopies',
2246
2293
  'notification',
2247
2294
  'workflow',
2248
2295
  ]);
@@ -2297,6 +2344,51 @@ function validateBackendOperations(rawOperations, declaredResources, declaredWor
2297
2344
  resources.add(resourceCode);
2298
2345
  }
2299
2346
  }
2347
+ if (access.managedFileCopies !== undefined) {
2348
+ const copies = Array.isArray(access.managedFileCopies)
2349
+ ? access.managedFileCopies
2350
+ : [];
2351
+ invalid ||= copies.length === 0 || copies.length > 16;
2352
+ const copyKeys = new Set();
2353
+ for (const rawCopy of copies) {
2354
+ const copy = object(rawCopy);
2355
+ const sourceResourceCode = string(copy.sourceResourceCode);
2356
+ const targetResourceCode = string(copy.targetResourceCode);
2357
+ const sourceFields = Array.isArray(copy.sourceFieldCodes)
2358
+ ? copy.sourceFieldCodes.map(string)
2359
+ : [];
2360
+ const targetFields = Array.isArray(copy.targetFieldCodes)
2361
+ ? copy.targetFieldCodes.map(string)
2362
+ : [];
2363
+ const source = declaredResources.get(sourceResourceCode);
2364
+ const target = declaredResources.get(targetResourceCode);
2365
+ invalid ||=
2366
+ copy.mode !== 'copy' ||
2367
+ !source ||
2368
+ !target ||
2369
+ sourceFields.length === 0 ||
2370
+ targetFields.length === 0 ||
2371
+ sourceFields.length > 16 ||
2372
+ targetFields.length > 16 ||
2373
+ new Set(sourceFields).size !== sourceFields.length ||
2374
+ new Set(targetFields).size !== targetFields.length ||
2375
+ sourceFields.some(field => !['file', 'image'].includes(source?.get(field) || '')) ||
2376
+ targetFields.some(field => !['file', 'image'].includes(target?.get(field) || '')) ||
2377
+ sourceFields.length !== targetFields.length ||
2378
+ sourceFields.some((field, i) => source?.get(field) !== target?.get(targetFields[i] || '')) ||
2379
+ Object.keys(copy).some(key => ![
2380
+ 'mode',
2381
+ 'sourceResourceCode',
2382
+ 'sourceFieldCodes',
2383
+ 'targetResourceCode',
2384
+ 'targetFieldCodes',
2385
+ ].includes(key));
2386
+ const key = `${sourceResourceCode}:${sourceFields.join(',')}=>${targetResourceCode}:${targetFields.join(',')}`;
2387
+ if (copyKeys.has(key))
2388
+ invalid = true;
2389
+ copyKeys.add(key);
2390
+ }
2391
+ }
2300
2392
  if (access.notification !== undefined) {
2301
2393
  const notification = object(access.notification);
2302
2394
  invalid ||=
@@ -2316,7 +2408,7 @@ function validateBackendOperations(rawOperations, declaredResources, declaredWor
2316
2408
  Object.keys(workflow).some(key => key !== 'codes');
2317
2409
  }
2318
2410
  if (invalid) {
2319
- diagnostics.push(diagnostic('APP_CONFIG_BACKEND_OPERATION_PLATFORM_ACCESS_INVALID', 'operation.platformAccess 必须只声明有界的发起人目录、托管文件、标准通知或现有工作流依赖', `${path}.platformAccess`));
2411
+ diagnostics.push(diagnostic('APP_CONFIG_BACKEND_OPERATION_PLATFORM_ACCESS_INVALID', 'operation.platformAccess 必须只声明有界的发起人目录、托管文件、托管文件复制、标准通知或现有工作流依赖', `${path}.platformAccess`));
2320
2412
  }
2321
2413
  }
2322
2414
  if (operation.ai !== undefined) {