@cadenza.io/service 2.17.25 → 2.17.26

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.
@@ -715,6 +715,38 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
715
715
  }
716
716
  return nextQueryData;
717
717
  }
718
+ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResult) {
719
+ if (!rawResult || typeof rawResult !== "object") {
720
+ return rawResult;
721
+ }
722
+ const result = { ...rawResult };
723
+ const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
724
+ const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
725
+ if (resolvedData !== void 0 && result.data === void 0) {
726
+ result.data = resolvedData;
727
+ }
728
+ if (resolvedData !== void 0 && (normalizedQueryData.data === void 0 || normalizedQueryData.data === null)) {
729
+ normalizedQueryData.data = resolvedData;
730
+ }
731
+ result.queryData = normalizedQueryData;
732
+ if (tableName === "service") {
733
+ const resolvedServiceName = String(
734
+ result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ctx.__serviceName ?? ""
735
+ ).trim();
736
+ if (resolvedServiceName) {
737
+ result.__serviceName = resolvedServiceName;
738
+ }
739
+ }
740
+ if (tableName === "service_instance" || tableName === "service_instance_transport") {
741
+ const resolvedUuid = String(
742
+ result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
743
+ ).trim();
744
+ if (resolvedUuid) {
745
+ result.uuid = resolvedUuid;
746
+ }
747
+ }
748
+ return result;
749
+ }
718
750
  function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {}) {
719
751
  const remoteInsertTask = CadenzaService.createCadenzaDBInsertTask(
720
752
  tableName,
@@ -738,14 +770,26 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
738
770
  );
739
771
  }
740
772
  const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
741
- return targetTask.taskFunction(
742
- {
743
- ...ctx,
744
- queryData: nextQueryData
745
- },
746
- emit,
747
- inquire,
748
- progressCallback
773
+ const delegationContext = ensureDelegationContextMetadata({
774
+ ...ctx,
775
+ queryData: nextQueryData
776
+ });
777
+ delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
778
+ delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
779
+ return Promise.resolve(
780
+ targetTask.taskFunction(
781
+ delegationContext,
782
+ emit,
783
+ inquire,
784
+ progressCallback
785
+ )
786
+ ).then(
787
+ (result) => normalizeServiceRegistryInsertResult(
788
+ tableName,
789
+ ctx,
790
+ nextQueryData,
791
+ result
792
+ )
749
793
  );
750
794
  },
751
795
  `Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
@@ -5875,7 +5919,22 @@ function getJoinedContextValue(ctx, key) {
5875
5919
  return void 0;
5876
5920
  }
5877
5921
  function didSyncInsertSucceed(ctx) {
5878
- return !ctx.errored && ctx.__success !== false;
5922
+ if (ctx.errored || ctx.__success === false) {
5923
+ return false;
5924
+ }
5925
+ const inquiryMeta = ctx.__inquiryMeta && typeof ctx.__inquiryMeta === "object" ? ctx.__inquiryMeta : null;
5926
+ if (!inquiryMeta) {
5927
+ return true;
5928
+ }
5929
+ const eligibleResponders = Number(inquiryMeta.eligibleResponders);
5930
+ if (Number.isFinite(eligibleResponders) && eligibleResponders === 0) {
5931
+ return false;
5932
+ }
5933
+ const responded = Number(inquiryMeta.responded);
5934
+ if (Number.isFinite(responded) && responded === 0) {
5935
+ return false;
5936
+ }
5937
+ return true;
5879
5938
  }
5880
5939
  function buildSyncInsertQueryData(ctx, queryData = {}) {
5881
5940
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
@@ -6999,6 +7058,11 @@ var GraphSyncController = class _GraphSyncController {
6999
7058
  { __syncing: true },
7000
7059
  18e4
7001
7060
  );
7061
+ CadenzaService.schedule(
7062
+ "meta.sync_controller.sync_tick",
7063
+ { __syncing: true },
7064
+ 250
7065
+ );
7002
7066
  CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
7003
7067
  }
7004
7068
  }
@@ -7399,20 +7463,28 @@ var CadenzaService = class {
7399
7463
  return false;
7400
7464
  });
7401
7465
  if (responders.length === 0) {
7466
+ const inquiryMeta = {
7467
+ inquiry,
7468
+ isMetaInquiry,
7469
+ totalResponders: allResponders.length,
7470
+ eligibleResponders: 0,
7471
+ filteredOutResponders: allResponders.length,
7472
+ responded: 0,
7473
+ failed: 0,
7474
+ timedOut: 0,
7475
+ pending: 0,
7476
+ durationMs: 0,
7477
+ responders: []
7478
+ };
7479
+ if (options.requireComplete) {
7480
+ throw {
7481
+ __inquiryMeta: inquiryMeta,
7482
+ __error: `Inquiry '${inquiry}' had no eligible responders`,
7483
+ errored: true
7484
+ };
7485
+ }
7402
7486
  return {
7403
- __inquiryMeta: {
7404
- inquiry,
7405
- isMetaInquiry,
7406
- totalResponders: allResponders.length,
7407
- eligibleResponders: 0,
7408
- filteredOutResponders: allResponders.length,
7409
- responded: 0,
7410
- failed: 0,
7411
- timedOut: 0,
7412
- pending: 0,
7413
- durationMs: 0,
7414
- responders: []
7415
- }
7487
+ __inquiryMeta: inquiryMeta
7416
7488
  };
7417
7489
  }
7418
7490
  responders.sort(this.compareInquiryResponders.bind(this));