openxiangda-devkit-core 2.29.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,3 +1,5 @@
1
+ import { parseNativeUniqueKeys } from 'openxiangda-contracts';
2
+ import { validateManagedConcurrency } from 'openxiangda-contracts/native-compiler';
1
3
  import { normalizeDecimalReservationEventDeclaration, decimalReservationEventContext } from 'openxiangda-contracts';
2
4
  import { materializeApplicationModules } from './application-model.js';
3
5
  import { nativeFieldRequiresCreateInputV2 } from 'openxiangda-contracts/native-compiler';
@@ -451,6 +453,7 @@ export const openXiangdaAppConfigSchema = {
451
453
  required: ['resources'],
452
454
  properties: {
453
455
  resources: { type: 'array', maxItems: 100, items: { type: 'object' } },
456
+ concurrency: { type: 'object' },
454
457
  subjectReadSurfaces: {
455
458
  type: 'array',
456
459
  maxItems: 50,
@@ -1063,7 +1066,7 @@ export function validateAppConfig(value) {
1063
1066
  : []) {
1064
1067
  const resource = object(rawResource);
1065
1068
  const mutationOwner = string(object(resource.surface).mutationOwner) || 'native';
1066
- if (mutationOwner === 'native')
1069
+ if (['native', 'queued-command'].includes(mutationOwner))
1067
1070
  continue;
1068
1071
  for (const operation of ['create', 'update', 'delete']) {
1069
1072
  const capability = string(object(resource.capabilities)[operation]);
@@ -2497,6 +2500,13 @@ export function validateAppConfig(value) {
2497
2500
  }
2498
2501
  });
2499
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
+ }
2500
2510
  return diagnostics;
2501
2511
  }
2502
2512
  function validatePerspectives(rawPerspectives, rawRoles, diagnostics) {
@@ -4472,6 +4482,7 @@ export function materializeDataResource(appCode, declaration) {
4472
4482
  },
4473
4483
  mobile: declaration.mobile || { enabled: true },
4474
4484
  };
4485
+ const uniqueKeys = parseNativeUniqueKeys(declaration.uniqueKeys, fields, '/uniqueKeys');
4475
4486
  return {
4476
4487
  schemaVersion: SCHEMA_VERSIONS.dataResource,
4477
4488
  appCode,
@@ -4480,6 +4491,7 @@ export function materializeDataResource(appCode, declaration) {
4480
4491
  schema: { fields },
4481
4492
  ...(declaration.invariants ? { invariants: declaration.invariants } : {}),
4482
4493
  ...(declaration.decimalReservationLifecycle !== undefined ? { decimalReservationLifecycle: declaration.decimalReservationLifecycle } : {}),
4494
+ ...(uniqueKeys !== undefined ? { uniqueKeys } : {}),
4483
4495
  surface,
4484
4496
  capabilities,
4485
4497
  ...(declaration.dataPolicyCode
@@ -4520,6 +4532,7 @@ export function validateAppDeclaration(value) {
4520
4532
  'fields',
4521
4533
  'invariants',
4522
4534
  'decimalReservationLifecycle',
4535
+ 'uniqueKeys',
4523
4536
  'list',
4524
4537
  'form',
4525
4538
  'detail',
@@ -4592,7 +4605,7 @@ export function validateAppDeclaration(value) {
4592
4605
  }
4593
4606
  const mutationOwner = string(resource.mutationOwner) || 'native';
4594
4607
  const generated = object(resource.generated);
4595
- if (!['native', 'action', 'readonly', 'workflow'].includes(mutationOwner)) {
4608
+ if (!['native', 'action', 'readonly', 'workflow', 'queued-command'].includes(mutationOwner)) {
4596
4609
  diagnostics.push(diagnostic('APP_CONFIG_DATA_RESOURCE_MUTATION_OWNER_INVALID', 'mutationOwner 必须是 native、action、readonly 或 workflow', `${resourcePath}.mutationOwner`));
4597
4610
  }
4598
4611
  for (const key of Object.keys(generated)) {
@@ -4847,6 +4860,7 @@ export function defineOpenXiangdaApp(declaration) {
4847
4860
  ...(modules || declaration.data ? {
4848
4861
  data: {
4849
4862
  resources: [...(declaration.data?.resources || []), ...projected.resources],
4863
+ ...(declaration.data?.concurrency ? { concurrency: declaration.data.concurrency } : {}),
4850
4864
  ...(declaration.data?.subjectReadSurfaces
4851
4865
  ? { subjectReadSurfaces: declaration.data.subjectReadSurfaces }
4852
4866
  : {}),
@@ -4880,6 +4894,7 @@ export function defineOpenXiangdaApp(declaration) {
4880
4894
  ...(data
4881
4895
  ? {
4882
4896
  data: {
4897
+ ...(data.concurrency ? { concurrency: data.concurrency } : {}),
4883
4898
  resources: data.resources.map(resource => materializeDataResource(normalizedDeclaration.app.code, resource)),
4884
4899
  ...(data.subjectReadSurfaces
4885
4900
  ? { subjectReadSurfaces: data.subjectReadSurfaces }