@osdk/client 2.5.0-beta.6 → 2.5.0-beta.7

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
  'use strict';
2
2
 
3
- var chunk4GWXMQZE_cjs = require('./chunk-4GWXMQZE.cjs');
3
+ var chunkBY2PQEYA_cjs = require('./chunk-BY2PQEYA.cjs');
4
4
  require('./chunk-5KDG5ZET.cjs');
5
5
  require('./chunk-Q7SFCCGT.cjs');
6
6
  var api = require('@osdk/api');
@@ -13,7 +13,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
13
  var invariant__default = /*#__PURE__*/_interopDefault(invariant);
14
14
 
15
15
  function createPlatformClient(baseUrl, tokenProvider, options = void 0, fetchFn = fetch) {
16
- return shared_client_impl.createSharedClientContext(baseUrl, tokenProvider, chunk4GWXMQZE_cjs.USER_AGENT, fetchFn);
16
+ return shared_client_impl.createSharedClientContext(baseUrl, tokenProvider, chunkBY2PQEYA_cjs.USER_AGENT, fetchFn);
17
17
  }
18
18
  var isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/;
19
19
  var extractDate = (dateTime) => {
@@ -37,19 +37,19 @@ var extractDateFromIsoString = (dateTime) => {
37
37
 
38
38
  Object.defineProperty(exports, "ActionValidationError", {
39
39
  enumerable: true,
40
- get: function () { return chunk4GWXMQZE_cjs.ActionValidationError; }
40
+ get: function () { return chunkBY2PQEYA_cjs.ActionValidationError; }
41
41
  });
42
42
  Object.defineProperty(exports, "createAttachmentUpload", {
43
43
  enumerable: true,
44
- get: function () { return chunk4GWXMQZE_cjs.createAttachmentUpload; }
44
+ get: function () { return chunkBY2PQEYA_cjs.createAttachmentUpload; }
45
45
  });
46
46
  Object.defineProperty(exports, "createClient", {
47
47
  enumerable: true,
48
- get: function () { return chunk4GWXMQZE_cjs.createClient; }
48
+ get: function () { return chunkBY2PQEYA_cjs.createClient; }
49
49
  });
50
50
  Object.defineProperty(exports, "createObjectSpecifierFromPrimaryKey", {
51
51
  enumerable: true,
52
- get: function () { return chunk4GWXMQZE_cjs.createObjectSpecifierFromPrimaryKey; }
52
+ get: function () { return chunkBY2PQEYA_cjs.createObjectSpecifierFromPrimaryKey; }
53
53
  });
54
54
  Object.defineProperty(exports, "NULL_VALUE", {
55
55
  enumerable: true,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk4GWXMQZE_cjs = require('../chunk-4GWXMQZE.cjs');
3
+ var chunkBY2PQEYA_cjs = require('../chunk-BY2PQEYA.cjs');
4
4
  var chunk5KDG5ZET_cjs = require('../chunk-5KDG5ZET.cjs');
5
5
  require('../chunk-Q7SFCCGT.cjs');
6
6
  var shared_net_fetch = require('@osdk/shared.net.fetch');
@@ -749,19 +749,25 @@ var Layers = class {
749
749
  };
750
750
 
751
751
  // src/observable/internal/QuerySubscription.ts
752
+ var subscriptionIdCounter = 0;
752
753
  var QuerySubscription = class extends UnsubscribableWrapper {
754
+ /** @internal */
753
755
  /** @internal */
754
756
  /** @internal */
755
757
  constructor(query, subscription) {
756
758
  super(subscription);
757
759
  this.query = query;
758
760
  this.subscription = subscription;
761
+ this.subscriptionId = `sub_${++subscriptionIdCounter}`;
759
762
  Object.defineProperties(this, {
760
763
  query: {
761
764
  enumerable: false
762
765
  },
763
766
  subscription: {
764
767
  enumerable: false
768
+ },
769
+ subscriptionId: {
770
+ enumerable: false
765
771
  }
766
772
  });
767
773
  }
@@ -790,10 +796,13 @@ var AbstractHelper = class {
790
796
  });
791
797
  }
792
798
  const sub = query.subscribe(subFn);
799
+ const querySub = new QuerySubscription(query, sub);
800
+ query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
793
801
  sub.add(() => {
802
+ query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
794
803
  this.store.cacheKeys.release(query.cacheKey);
795
804
  });
796
- return new QuerySubscription(query, sub);
805
+ return querySub;
797
806
  }
798
807
  };
799
808
 
@@ -808,6 +817,7 @@ var Query = class {
808
817
  #connectable;
809
818
  #subscription;
810
819
  #subject;
820
+ #subscriptionDedupeIntervals = /* @__PURE__ */ new Map();
811
821
  /** @internal */
812
822
  constructor(store, observable, opts, cacheKey, logger) {
813
823
  this.options = opts;
@@ -824,6 +834,29 @@ var Query = class {
824
834
  this.#subscription = this.#connectable.connect();
825
835
  return this.#connectable.subscribe(observer);
826
836
  }
837
+ /**
838
+ * Register a subscription's dedupeInterval value
839
+ */
840
+ registerSubscriptionDedupeInterval(subscriptionId, dedupeInterval) {
841
+ if (dedupeInterval != null && dedupeInterval > 0) {
842
+ this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);
843
+ }
844
+ }
845
+ /**
846
+ * Unregister a subscription's dedupeInterval value
847
+ */
848
+ unregisterSubscriptionDedupeInterval(subscriptionId) {
849
+ this.#subscriptionDedupeIntervals.delete(subscriptionId);
850
+ }
851
+ /**
852
+ * Get the minimum dedupeInterval from all active subscriptions
853
+ */
854
+ getMinimumDedupeInterval() {
855
+ if (this.#subscriptionDedupeIntervals.size === 0) {
856
+ return this.options.dedupeInterval ?? 0;
857
+ }
858
+ return Math.min(...this.#subscriptionDedupeIntervals.values());
859
+ }
827
860
  /**
828
861
  * Causes the query to revalidate. This will cause the query to fetch
829
862
  * the latest data from the server and update the store if it is deemed
@@ -846,7 +879,8 @@ var Query = class {
846
879
  await this.pendingFetch;
847
880
  return;
848
881
  }
849
- if ((this.options.dedupeInterval ?? 0) > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < (this.options.dedupeInterval ?? 0)) {
882
+ const minDedupeInterval = this.getMinimumDedupeInterval();
883
+ if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
850
884
  if (process.env.NODE_ENV !== "production") {
851
885
  logger?.debug("Within dupeInterval, aborting revalidate");
852
886
  }
@@ -1754,7 +1788,7 @@ var ListQuery = class extends BaseListQuery {
1754
1788
  }
1755
1789
  #extractRelevantObjectsForTypeInterface(changes) {
1756
1790
  const matchesApiName = ([, object]) => {
1757
- return this.#apiName in object[chunk4GWXMQZE_cjs.ObjectDefRef].interfaceMap;
1791
+ return this.#apiName in object[chunkBY2PQEYA_cjs.ObjectDefRef].interfaceMap;
1758
1792
  };
1759
1793
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
1760
1794
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
@@ -1885,7 +1919,7 @@ var ListQuery = class extends BaseListQuery {
1885
1919
  async function reloadDataAsFullObjects(client, data) {
1886
1920
  const groups = groupBy__default.default(data, (x) => x.$objectType);
1887
1921
  const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
1888
- const objectDef = objects[0][chunk4GWXMQZE_cjs.UnderlyingOsdkObject][chunk4GWXMQZE_cjs.ObjectDefRef];
1922
+ const objectDef = objects[0][chunkBY2PQEYA_cjs.UnderlyingOsdkObject][chunkBY2PQEYA_cjs.ObjectDefRef];
1889
1923
  const where = {
1890
1924
  [objectDef.primaryKeyApiName]: {
1891
1925
  $in: objects.map((x) => x.$primaryKey)
@@ -2428,10 +2462,10 @@ var Store = class {
2428
2462
 
2429
2463
  // src/observable/ObservableClient.ts
2430
2464
  function createObservableClient(client) {
2431
- const tweakedClient = chunk4GWXMQZE_cjs.createClientFromContext({
2465
+ const tweakedClient = chunkBY2PQEYA_cjs.createClientFromContext({
2432
2466
  ...client[chunk5KDG5ZET_cjs.additionalContext],
2433
2467
  fetch: shared_net_fetch.createFetchHeaderMutator(client[chunk5KDG5ZET_cjs.additionalContext].fetch, (headers) => {
2434
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk4GWXMQZE_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
2468
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkBY2PQEYA_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
2435
2469
  return headers;
2436
2470
  })
2437
2471
  });
@@ -2474,7 +2508,7 @@ function getOsdkConfig(ontologyRid) {
2474
2508
 
2475
2509
  Object.defineProperty(exports, "createClientWithTransaction", {
2476
2510
  enumerable: true,
2477
- get: function () { return chunk4GWXMQZE_cjs.createClientWithTransaction; }
2511
+ get: function () { return chunkBY2PQEYA_cjs.createClientWithTransaction; }
2478
2512
  });
2479
2513
  Object.defineProperty(exports, "augment", {
2480
2514
  enumerable: true,