openxiangda-contracts 2.9.0 → 2.11.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.
@@ -69,6 +69,7 @@ export interface NativeEventCapturePlanV2 {
69
69
  authorizationFields: string[];
70
70
  captureFields: string[];
71
71
  digest: string;
72
+ capturedEventTypes?: string[];
72
73
  }
73
74
  /**
74
75
  * Compiles the immutable data-event capture closure. The result deliberately
@@ -79,6 +80,7 @@ export declare function compileNativeEventCapturePlansV2(input: {
79
80
  resources: JsonObject[];
80
81
  dataPolicies: JsonObject[];
81
82
  subscriptions: JsonObject[];
83
+ capturePolicies?: JsonObject[];
82
84
  }): NativeEventCapturePlanV2[];
83
85
  export {};
84
86
  //# sourceMappingURL=compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/native-compiler/compiler.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,kCAAkC,IAAI,uCAAuC,EACnF,MAAM,aAAa,CAAC;AAwBrB,QAAA,MAAM,iBAAiB,mDAAmD,CAAC;AAC3E,QAAA,MAAM,yBAAyB,YAA2C,CAAC;AAgF3E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;EAc7B,CAAC;AACZ,eAAO,MAAM,mBAAmB,6HAItB,CAAC;AACX,eAAO,MAAM,uBAAuB,u/CAkC1B,CAAC;AAGX,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEtC,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAC1C,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,6BAA6B,CAAC,CAAC,GAAG,UAAU;IA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AS,EAAE,UAAU,EAAE,CAAC;IACxB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;CAChC,GAAG,wBAAwB,EAAE,CA4J7B"}
@@ -1,3 +1,4 @@
1
+ import { compileNativeEventAction } from './event-action.js';
1
2
  import { projectNativeDataResourceViewV2 } from './data-surface.js';
2
3
  import { hasDataAuditReadPolicy, isDataAuditMetadataField } from './data-audit-access.js';
3
4
  import { validateWorkflowInstanceCommandPolicies } from './workflow-instance-policy.js';
@@ -206,6 +207,7 @@ export function compileNativeApplicationConfiguration(input) {
206
207
  resources: config.data.resources,
207
208
  dataPolicies: config.authz.dataPolicies,
208
209
  subscriptions: expectedContract.eventConsumers,
210
+ capturePolicies: config.events.capturePolicies,
209
211
  }),
210
212
  },
211
213
  workflows: {
@@ -397,6 +399,12 @@ export function compileRequiredPlatformCapabilitiesV3(config) {
397
399
  },
398
400
  ]
399
401
  : []),
402
+ ...(config.events.subscriptions.some((item) => item.execution)
403
+ ? [{ code: 'events.native-data-actions', declaration: config.events.subscriptions.filter((item) => item.execution) }]
404
+ : []),
405
+ ...(config.events.capturePolicies?.length
406
+ ? [{ code: 'events.capture-policy', declaration: config.events.capturePolicies }]
407
+ : []),
400
408
  ...(usesEvents
401
409
  ? [
402
410
  { code: 'events-v2', declaration: config.events },
@@ -493,6 +501,21 @@ export function compileRequiredPlatformCapabilitiesV3(config) {
493
501
  * selected at runtime by that same revision tuple.
494
502
  */
495
503
  export function compileNativeEventCapturePlansV2(input) {
504
+ const capturePolicies = new Map();
505
+ const resources = new Set(input.resources.map(resource => String(resource.code)));
506
+ for (const [index, raw] of boundedArray(input.capturePolicies === undefined ? [] : input.capturePolicies, '/capturePlan/capturePolicies', 100).entries()) {
507
+ const pointer = `/capturePlan/capturePolicies/${index}`;
508
+ const policy = object(raw, pointer);
509
+ exactKeys(policy, ['resourceCode', 'mode'], pointer);
510
+ const code = resourceCode(policy.resourceCode, `${pointer}/resourceCode`);
511
+ if (!resources.has(code))
512
+ fail('NATIVE_EVENT_CAPTURE_RESOURCE_NOT_FOUND', pointer, { resourceCode: code });
513
+ if (capturePolicies.has(code))
514
+ fail('NATIVE_EVENT_CAPTURE_POLICY_DUPLICATE', pointer, { resourceCode: code });
515
+ if (policy.mode !== 'all' && policy.mode !== 'subscribed')
516
+ fail('NATIVE_EVENT_CAPTURE_MODE_INVALID', `${pointer}/mode`);
517
+ capturePolicies.set(code, policy.mode);
518
+ }
496
519
  const policies = new Map(input.dataPolicies.map((raw, index) => {
497
520
  const policy = object(raw, `/capturePlan/dataPolicies/${index}`);
498
521
  return [String(policy.code), policy];
@@ -528,6 +551,7 @@ export function compileNativeEventCapturePlansV2(input) {
528
551
  }
529
552
  const filterFields = new Set();
530
553
  const projectionFields = new Set();
554
+ const capturedEventTypes = new Set();
531
555
  for (const [subscriptionIndex, subscription] of subscriptions.entries()) {
532
556
  const eventTypes = boundedArray(subscription.eventTypes, `/capturePlan/subscriptions/${subscriptionIndex}/eventTypes`, 20).map(String);
533
557
  if (!eventTypes.some(type => type.startsWith('openxiangda.data.'))) {
@@ -540,6 +564,10 @@ export function compileNativeEventCapturePlansV2(input) {
540
564
  if (selectedResources.length && !selectedResources.includes(code)) {
541
565
  continue;
542
566
  }
567
+ for (const type of eventTypes) {
568
+ if (DATA_EVENT_TYPES_V2.includes(type))
569
+ capturedEventTypes.add(type);
570
+ }
543
571
  for (const field of eventCaptureFilterFieldsV2(filter, `/capturePlan/subscriptions/${subscriptionIndex}/filter`)) {
544
572
  filterFields.add(field);
545
573
  }
@@ -577,6 +605,9 @@ export function compileNativeEventCapturePlansV2(input) {
577
605
  }
578
606
  const plan = {
579
607
  resourceCode: code,
608
+ ...(capturePolicies.get(code) === 'subscribed'
609
+ ? { capturedEventTypes: [...capturedEventTypes].sort() }
610
+ : {}),
580
611
  filterFields: [...filterFields].sort(),
581
612
  projectionFields: [...projectionFields].sort(),
582
613
  authorizationFields: [...authorizationFields].sort(),
@@ -676,7 +707,7 @@ function validateConfigurationEnvelope(config, appCode) {
676
707
  boundedArray(data.resourceDetailRoutes, '/config/data/resourceDetailRoutes', 100);
677
708
  }
678
709
  const events = object(config.events, '/config/events');
679
- exactKeys(events, ['schemas', 'subscriptions', 'timers', 'dateTriggers'], '/config/events');
710
+ exactKeys(events, ['schemas', 'subscriptions', 'timers', 'dateTriggers'], '/config/events', ['capturePolicies']);
680
711
  boundedArray(events.schemas, '/config/events/schemas', 100);
681
712
  boundedArray(events.subscriptions, '/config/events/subscriptions', 100);
682
713
  boundedArray(events.timers, '/config/events/timers', 100);
@@ -811,6 +842,7 @@ function compileExpectedContract(config, configDigest, generatorVersion) {
811
842
  fail('NATIVE_EVENT_TYPE_NOT_REGISTERED', `${pointer}/eventTypes/${eventIndex}`, { eventType });
812
843
  }
813
844
  });
845
+ const nativeAction = compileNativeEventAction(subscription, config.data.resources, pointer);
814
846
  const delivery = validateEventDeliveryPolicy(subscription.delivery, eventTypes, `${pointer}/delivery`);
815
847
  const platformAccess = validateEventSubscriptionPlatformAccess(subscription.platformAccess, `${pointer}/platformAccess`, eventResourceFields);
816
848
  return {
@@ -818,7 +850,8 @@ function compileExpectedContract(config, configDigest, generatorVersion) {
818
850
  endpointPath: absolutePath(subscription.endpointPath, `${pointer}/endpointPath`),
819
851
  eventTypes,
820
852
  filter: object(subscription.filter, `${pointer}/filter`),
821
- payload: object(subscription.payload, `${pointer}/payload`),
853
+ payload: nativeAction?.payload || object(subscription.payload, `${pointer}/payload`),
854
+ ...(nativeAction ? { execution: nativeAction.execution } : {}),
822
855
  ...(platformAccess ? { platformAccess } : {}),
823
856
  delivery,
824
857
  };
@@ -886,7 +919,7 @@ function compileExpectedContract(config, configDigest, generatorVersion) {
886
919
  eventHandlerManifest: {
887
920
  schemaVersion: EVENT_HANDLER_MANIFEST_SCHEMA,
888
921
  appCode: config.appCode,
889
- handlers: eventConsumers.map(consumer => ({
922
+ handlers: eventConsumers.filter(consumer => !consumer.execution).map(consumer => ({
890
923
  code: consumer.code,
891
924
  endpointPath: consumer.endpointPath,
892
925
  eventTypes: consumer.eventTypes,