openxiangda-devkit-core 2.4.2 → 2.5.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,6 +1,6 @@
1
1
  import { materializeApplicationModules } from './application-model.js';
2
2
  import { nativeFieldRequiresCreateInputV2 } from 'openxiangda-contracts/native-compiler';
3
- import { SCHEMA_VERSIONS, DATA_FIELD_TYPES, PLATFORM_EVENT_TYPES_V2, nativePlatformCapabilityCatalog, validateDataResource, validateWorkflowInstanceCommandPolicies, WORKFLOW_SUMMARY_MAX_FIELDS, WORKFLOW_SUMMARY_TEXT_LONG_MAX_BYTES, isWorkflowSummaryFieldType, } from 'openxiangda-contracts';
3
+ import { SCHEMA_VERSIONS, DATA_AUDIT_METADATA_FIELDS, DATA_FIELD_TYPES, PLATFORM_EVENT_TYPES_V2, nativePlatformCapabilityCatalog, validateDataResource, validateWorkflowInstanceCommandPolicies, WORKFLOW_SUMMARY_MAX_FIELDS, WORKFLOW_SUMMARY_TEXT_LONG_MAX_BYTES, isWorkflowSummaryFieldType, } from 'openxiangda-contracts';
4
4
  import { Ajv2020 } from 'ajv/dist/2020.js';
5
5
  import { CronExpressionParser } from 'cron-parser';
6
6
  import { fieldNullable, supportsGeneratedMutation, } from './field-codec.js';
@@ -3765,15 +3765,20 @@ export function materializeDataResource(appCode, declaration) {
3765
3765
  ...(declaration.detailRouteCode
3766
3766
  ? { detailRouteCode: { ...declaration.detailRouteCode } }
3767
3767
  : {}),
3768
- fieldPolicies: Object.fromEntries(declaration.fields.map(field => [
3769
- field.code,
3770
- {
3771
- read: access(field, 'read'),
3772
- create: access(field, 'create'),
3773
- update: access(field, 'update'),
3774
- ...(field.access?.mask ? { mask: field.access.mask } : {}),
3775
- },
3776
- ])),
3768
+ fieldPolicies: {
3769
+ ...Object.fromEntries(declaration.fields.map(field => [
3770
+ field.code,
3771
+ {
3772
+ read: access(field, 'read'),
3773
+ create: access(field, 'create'),
3774
+ update: access(field, 'update'),
3775
+ ...(field.access?.mask ? { mask: field.access.mask } : {}),
3776
+ },
3777
+ ])),
3778
+ ...(declaration.audit === undefined ? {} : Object.fromEntries(DATA_AUDIT_METADATA_FIELDS.map(code => [code, {
3779
+ read: declaration.audit.read === false ? [] : [...declaration.audit.read],
3780
+ }]))),
3781
+ },
3777
3782
  };
3778
3783
  }
3779
3784
  export function validateAppDeclaration(value) {
@@ -3796,6 +3801,7 @@ export function validateAppDeclaration(value) {
3796
3801
  'mobile',
3797
3802
  'dataPolicyCode',
3798
3803
  'detailRouteCode',
3804
+ 'audit',
3799
3805
  ]);
3800
3806
  const fieldKeys = new Set([
3801
3807
  'code',
@@ -3834,6 +3840,18 @@ export function validateAppDeclaration(value) {
3834
3840
  }
3835
3841
  }
3836
3842
  const fields = Array.isArray(resource.fields) ? resource.fields : [];
3843
+ let auditValid = true;
3844
+ if (resource.audit !== undefined) {
3845
+ const audit = object(resource.audit);
3846
+ const read = audit.read;
3847
+ if (!resource.audit || typeof resource.audit !== 'object' || Array.isArray(resource.audit) ||
3848
+ Object.keys(audit).some(key => key !== 'read') ||
3849
+ (read !== false && (!Array.isArray(read) || read.length < 1 || read.length > 20 ||
3850
+ read.some(value => typeof value !== 'string' || !value.trim()) || new Set(read).size !== read.length))) {
3851
+ auditValid = false;
3852
+ diagnostics.push(diagnostic('APP_CONFIG_DATA_AUDIT_READ_INVALID', 'audit.read 必须为 false 或不重复的非空 capability 数组(最多 20 项)', `${resourcePath}.audit`));
3853
+ }
3854
+ }
3837
3855
  const mutationOwner = string(resource.mutationOwner) || 'native';
3838
3856
  const generated = object(resource.generated);
3839
3857
  if (!['native', 'action', 'readonly', 'workflow'].includes(mutationOwner)) {
@@ -3859,7 +3877,7 @@ export function validateAppDeclaration(value) {
3859
3877
  return;
3860
3878
  }
3861
3879
  const declaredCodes = new Set();
3862
- let materializable = true;
3880
+ let materializable = auditValid;
3863
3881
  fields.forEach((rawField, fieldIndex) => {
3864
3882
  const field = object(rawField);
3865
3883
  const fieldPath = `${resourcePath}.fields[${fieldIndex}]`;