@cadenza.io/service 2.17.25 → 2.17.27

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.
@@ -766,6 +766,38 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
766
766
  }
767
767
  return nextQueryData;
768
768
  }
769
+ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResult) {
770
+ if (!rawResult || typeof rawResult !== "object") {
771
+ return rawResult;
772
+ }
773
+ const result = { ...rawResult };
774
+ const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
775
+ const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
776
+ if (resolvedData !== void 0 && result.data === void 0) {
777
+ result.data = resolvedData;
778
+ }
779
+ if (resolvedData !== void 0 && (normalizedQueryData.data === void 0 || normalizedQueryData.data === null)) {
780
+ normalizedQueryData.data = resolvedData;
781
+ }
782
+ result.queryData = normalizedQueryData;
783
+ if (tableName === "service") {
784
+ const resolvedServiceName = String(
785
+ result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ctx.__serviceName ?? ""
786
+ ).trim();
787
+ if (resolvedServiceName) {
788
+ result.__serviceName = resolvedServiceName;
789
+ }
790
+ }
791
+ if (tableName === "service_instance" || tableName === "service_instance_transport") {
792
+ const resolvedUuid = String(
793
+ result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
794
+ ).trim();
795
+ if (resolvedUuid) {
796
+ result.uuid = resolvedUuid;
797
+ }
798
+ }
799
+ return result;
800
+ }
769
801
  function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
770
802
  const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
771
803
  tableName,
@@ -789,14 +821,26 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
789
821
  );
790
822
  }
791
823
  const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
792
- return targetTask.taskFunction(
793
- {
794
- ...ctx,
795
- queryData: nextQueryData
796
- },
797
- emit,
798
- inquire,
799
- progressCallback
824
+ const delegationContext = ensureDelegationContextMetadata({
825
+ ...ctx,
826
+ queryData: nextQueryData
827
+ });
828
+ delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
829
+ delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
830
+ return Promise.resolve(
831
+ targetTask.taskFunction(
832
+ delegationContext,
833
+ emit,
834
+ inquire,
835
+ progressCallback
836
+ )
837
+ ).then(
838
+ (result) => normalizeServiceRegistryInsertResult(
839
+ tableName,
840
+ ctx,
841
+ nextQueryData,
842
+ result
843
+ )
800
844
  );
801
845
  },
802
846
  `Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
@@ -5926,7 +5970,22 @@ function getJoinedContextValue(ctx, key) {
5926
5970
  return void 0;
5927
5971
  }
5928
5972
  function didSyncInsertSucceed(ctx) {
5929
- return !ctx.errored && ctx.__success !== false;
5973
+ if (ctx.errored || ctx.__success === false) {
5974
+ return false;
5975
+ }
5976
+ const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
5977
+ if (!inquiryMeta) {
5978
+ return true;
5979
+ }
5980
+ const eligibleResponders = Number(inquiryMeta.eligibleResponders);
5981
+ if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
5982
+ return false;
5983
+ }
5984
+ const responded = Number(inquiryMeta.responded);
5985
+ if (Number.isFinite(responded) && responded === 0) {
5986
+ return false;
5987
+ }
5988
+ return true;
5930
5989
  }
5931
5990
  function buildSyncInsertQueryData(ctx, queryData = {}) {
5932
5991
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
@@ -7050,6 +7109,11 @@ var GraphSyncController = class _GraphSyncController {
7050
7109
  { __syncing: true },
7051
7110
  18e4
7052
7111
  );
7112
+ CadenzaService.schedule(
7113
+ "meta.sync_controller.sync_tick",
7114
+ { __syncing: true },
7115
+ 250
7116
+ );
7053
7117
  CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
7054
7118
  }
7055
7119
  }
@@ -7450,20 +7514,28 @@ var CadenzaService = class {
7450
7514
  return false;
7451
7515
  });
7452
7516
  if (responders.length === 0) {
7517
+ const inquiryMeta = {
7518
+ inquiry,
7519
+ isMetaInquiry,
7520
+ totalResponders: allResponders.length,
7521
+ eligibleResponders: 0,
7522
+ filteredOutResponders: allResponders.length,
7523
+ responded: 0,
7524
+ failed: 0,
7525
+ timedOut: 0,
7526
+ pending: 0,
7527
+ durationMs: 0,
7528
+ responders: []
7529
+ };
7530
+ if (options.requireComplete) {
7531
+ throw {
7532
+ __inquiryMeta: inquiryMeta,
7533
+ __error: `Inquiry '${inquiry}' had no eligible responders`,
7534
+ errored: true
7535
+ };
7536
+ }
7453
7537
  return {
7454
- __inquiryMeta: {
7455
- inquiry,
7456
- isMetaInquiry,
7457
- totalResponders: allResponders.length,
7458
- eligibleResponders: 0,
7459
- filteredOutResponders: allResponders.length,
7460
- responded: 0,
7461
- failed: 0,
7462
- timedOut: 0,
7463
- pending: 0,
7464
- durationMs: 0,
7465
- responders: []
7466
- }
7538
+ __inquiryMeta: inquiryMeta
7467
7539
  };
7468
7540
  }
7469
7541
  responders.sort(this.compareInquiryResponders.bind(this));