openxiangda-devkit-core 2.30.0 → 2.31.0

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.
@@ -1,4 +1,5 @@
1
1
  import { parseNativeUniqueKeys } from 'openxiangda-contracts';
2
+ import { validateManagedConcurrency } from 'openxiangda-contracts/native-compiler';
2
3
  import { normalizeDecimalReservationEventDeclaration, decimalReservationEventContext } from 'openxiangda-contracts';
3
4
  import { materializeApplicationModules } from './application-model.js';
4
5
  import { nativeFieldRequiresCreateInputV2 } from 'openxiangda-contracts/native-compiler';
@@ -452,6 +453,7 @@ export const openXiangdaAppConfigSchema = {
452
453
  required: ['resources'],
453
454
  properties: {
454
455
  resources: { type: 'array', maxItems: 100, items: { type: 'object' } },
456
+ concurrency: { type: 'object' },
455
457
  subjectReadSurfaces: {
456
458
  type: 'array',
457
459
  maxItems: 50,
@@ -1064,7 +1066,7 @@ export function validateAppConfig(value) {
1064
1066
  : []) {
1065
1067
  const resource = object(rawResource);
1066
1068
  const mutationOwner = string(object(resource.surface).mutationOwner) || 'native';
1067
- if (mutationOwner === 'native')
1069
+ if (['native', 'queued-command'].includes(mutationOwner))
1068
1070
  continue;
1069
1071
  for (const operation of ['create', 'update', 'delete']) {
1070
1072
  const capability = string(object(resource.capabilities)[operation]);
@@ -2498,6 +2500,13 @@ export function validateAppConfig(value) {
2498
2500
  }
2499
2501
  });
2500
2502
  }
2503
+ try {
2504
+ const concurrencyConfig = value;
2505
+ validateManagedConcurrency(concurrencyConfig.data?.concurrency, concurrencyConfig.data?.resources || [], concurrencyConfig.authz?.capabilities || []);
2506
+ }
2507
+ catch (error) {
2508
+ diagnostics.push(diagnostic('NATIVE_MANAGED_CONCURRENCY_INVALID', error.message, error.pointer || 'data.concurrency'));
2509
+ }
2501
2510
  return diagnostics;
2502
2511
  }
2503
2512
  function validatePerspectives(rawPerspectives, rawRoles, diagnostics) {
@@ -4596,7 +4605,7 @@ export function validateAppDeclaration(value) {
4596
4605
  }
4597
4606
  const mutationOwner = string(resource.mutationOwner) || 'native';
4598
4607
  const generated = object(resource.generated);
4599
- if (!['native', 'action', 'readonly', 'workflow'].includes(mutationOwner)) {
4608
+ if (!['native', 'action', 'readonly', 'workflow', 'queued-command'].includes(mutationOwner)) {
4600
4609
  diagnostics.push(diagnostic('APP_CONFIG_DATA_RESOURCE_MUTATION_OWNER_INVALID', 'mutationOwner 必须是 native、action、readonly 或 workflow', `${resourcePath}.mutationOwner`));
4601
4610
  }
4602
4611
  for (const key of Object.keys(generated)) {
@@ -4851,6 +4860,7 @@ export function defineOpenXiangdaApp(declaration) {
4851
4860
  ...(modules || declaration.data ? {
4852
4861
  data: {
4853
4862
  resources: [...(declaration.data?.resources || []), ...projected.resources],
4863
+ ...(declaration.data?.concurrency ? { concurrency: declaration.data.concurrency } : {}),
4854
4864
  ...(declaration.data?.subjectReadSurfaces
4855
4865
  ? { subjectReadSurfaces: declaration.data.subjectReadSurfaces }
4856
4866
  : {}),
@@ -4884,6 +4894,7 @@ export function defineOpenXiangdaApp(declaration) {
4884
4894
  ...(data
4885
4895
  ? {
4886
4896
  data: {
4897
+ ...(data.concurrency ? { concurrency: data.concurrency } : {}),
4887
4898
  resources: data.resources.map(resource => materializeDataResource(normalizedDeclaration.app.code, resource)),
4888
4899
  ...(data.subjectReadSurfaces
4889
4900
  ? { subjectReadSurfaces: data.subjectReadSurfaces }