@osdk/client 2.6.0-beta.4 → 2.6.0-beta.6

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 chunk7567LSZD_cjs = require('../chunk-7567LSZD.cjs');
3
+ var chunk3ZJESPX6_cjs = require('../chunk-3ZJESPX6.cjs');
4
4
  var chunkVNLY3YOJ_cjs = require('../chunk-VNLY3YOJ.cjs');
5
5
  require('../chunk-Q7SFCCGT.cjs');
6
6
  var trie = require('@wry/trie');
@@ -1803,6 +1803,13 @@ var ListQuery = class extends BaseListQuery {
1803
1803
  // Using base class minResultsToLoad instead of a private property
1804
1804
  #orderBy;
1805
1805
  #objectSet;
1806
+ #websocketSubscription = null;
1807
+ #subscriptionRefCounts = new RefCounts(process.env.NODE_ENV !== "production" ? 2e3 : 5e3, () => {
1808
+ if (this.#websocketSubscription) {
1809
+ this.#websocketSubscription.unsubscribe();
1810
+ this.#websocketSubscription = null;
1811
+ }
1812
+ });
1806
1813
  /**
1807
1814
  * Register changes to the cache specific to ListQuery
1808
1815
  */
@@ -1988,19 +1995,24 @@ var ListQuery = class extends BaseListQuery {
1988
1995
  methodName: "observeList"
1989
1996
  }).info("Subscribing from websocket");
1990
1997
  }
1991
- const websocketSubscription = this.#objectSet.subscribe({
1992
- onChange: this.onOswChange.bind(this),
1993
- onError: this.onOswError.bind(this),
1994
- onOutOfDate: this.onOswOutOfDate.bind(this),
1995
- onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
1996
- });
1998
+ if (!this.#websocketSubscription) {
1999
+ this.#websocketSubscription = this.#objectSet.subscribe({
2000
+ onChange: this.onOswChange.bind(this),
2001
+ onError: this.onOswError.bind(this),
2002
+ onOutOfDate: this.onOswOutOfDate.bind(this),
2003
+ onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
2004
+ });
2005
+ this.#subscriptionRefCounts.register("websocket");
2006
+ }
2007
+ this.#subscriptionRefCounts.retain("websocket");
1997
2008
  sub.add(() => {
1998
2009
  if (process.env.NODE_ENV !== "production") {
1999
2010
  logger?.child({
2000
2011
  methodName: "observeList"
2001
2012
  }).info("Unsubscribing from websocket");
2002
2013
  }
2003
- websocketSubscription.unsubscribe();
2014
+ this.#subscriptionRefCounts.release("websocket");
2015
+ this.#subscriptionRefCounts.gc();
2004
2016
  });
2005
2017
  }
2006
2018
  onOswSuccessfulSubscription() {
@@ -2115,7 +2127,7 @@ var InterfaceListQuery = class extends ListQuery {
2115
2127
  }
2116
2128
  extractRelevantObjects(changes) {
2117
2129
  const matchesApiName = ([, object]) => {
2118
- return this.apiName in object[chunk7567LSZD_cjs.ObjectDefRef].interfaceMap;
2130
+ return this.apiName in object[chunk3ZJESPX6_cjs.ObjectDefRef].interfaceMap;
2119
2131
  };
2120
2132
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
2121
2133
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
@@ -2136,7 +2148,7 @@ var InterfaceListQuery = class extends ListQuery {
2136
2148
  async function reloadDataAsFullObjects(client, data) {
2137
2149
  const groups = groupBy__default.default(data, (x) => x.$objectType);
2138
2150
  const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
2139
- const objectDef = objects[0][chunk7567LSZD_cjs.UnderlyingOsdkObject][chunk7567LSZD_cjs.ObjectDefRef];
2151
+ const objectDef = objects[0][chunk3ZJESPX6_cjs.UnderlyingOsdkObject][chunk3ZJESPX6_cjs.ObjectDefRef];
2140
2152
  const where = {
2141
2153
  [objectDef.primaryKeyApiName]: {
2142
2154
  $in: objects.map((x) => x.$primaryKey)
@@ -3182,10 +3194,10 @@ var Store = class {
3182
3194
 
3183
3195
  // src/observable/ObservableClient.ts
3184
3196
  function createObservableClient(client) {
3185
- const tweakedClient = chunk7567LSZD_cjs.createClientFromContext({
3197
+ const tweakedClient = chunk3ZJESPX6_cjs.createClientFromContext({
3186
3198
  ...client[chunkVNLY3YOJ_cjs.additionalContext],
3187
3199
  fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkVNLY3YOJ_cjs.additionalContext].fetch, (headers) => {
3188
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk7567LSZD_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
3200
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk3ZJESPX6_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
3189
3201
  return headers;
3190
3202
  })
3191
3203
  });
@@ -3228,7 +3240,7 @@ function getOsdkConfig(ontologyRid) {
3228
3240
 
3229
3241
  Object.defineProperty(exports, "createClientWithTransaction", {
3230
3242
  enumerable: true,
3231
- get: function () { return chunk7567LSZD_cjs.createClientWithTransaction; }
3243
+ get: function () { return chunk3ZJESPX6_cjs.createClientWithTransaction; }
3232
3244
  });
3233
3245
  Object.defineProperty(exports, "augment", {
3234
3246
  enumerable: true,