@osdk/client 2.8.0-beta.4 → 2.8.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/build/browser/observable/internal/AbstractHelper.js +37 -2
  3. package/build/browser/observable/internal/AbstractHelper.js.map +1 -1
  4. package/build/browser/observable/internal/AbstractHelper.test.js +114 -0
  5. package/build/browser/observable/internal/AbstractHelper.test.js.map +1 -0
  6. package/build/browser/observable/internal/CacheKeys.js +19 -8
  7. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  8. package/build/browser/observable/internal/ListQueryView.js +8 -3
  9. package/build/browser/observable/internal/ListQueryView.js.map +1 -1
  10. package/build/browser/observable/internal/ObservableClientImpl.js +104 -17
  11. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  12. package/build/browser/observable/internal/RdpCanonicalizer.test.js +23 -7
  13. package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  14. package/build/browser/observable/internal/Store.js +18 -1
  15. package/build/browser/observable/internal/Store.js.map +1 -1
  16. package/build/browser/observable/internal/Store.test.js +184 -0
  17. package/build/browser/observable/internal/Store.test.js.map +1 -1
  18. package/build/browser/observable/internal/actions/ActionApplication.js +7 -4
  19. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  20. package/build/browser/observable/internal/base-list/BaseListQuery.js +5 -6
  21. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  22. package/build/browser/observable/internal/list/ListQuery.test.js +154 -0
  23. package/build/browser/observable/internal/list/ListQuery.test.js.map +1 -1
  24. package/build/browser/observable/internal/list/ObjectListQuery.js +15 -4
  25. package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
  26. package/build/browser/observable/internal/object/ObjectsHelper.js +9 -2
  27. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  28. package/build/browser/observable/internal/object/ObjectsHelper.test.js +200 -0
  29. package/build/browser/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  30. package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  31. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +3 -2
  32. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  33. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  34. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  35. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +3 -0
  36. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  37. package/build/browser/observable/internal/utils/rdpFieldOperations.js +7 -2
  38. package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  39. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  40. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  41. package/build/browser/util/UserAgent.js +2 -2
  42. package/build/cjs/{chunk-RKC3366I.cjs → chunk-HCG4XO6Z.cjs} +4 -4
  43. package/build/cjs/{chunk-RKC3366I.cjs.map → chunk-HCG4XO6Z.cjs.map} +1 -1
  44. package/build/cjs/index.cjs +7 -7
  45. package/build/cjs/public/unstable-do-not-use.cjs +231 -74
  46. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  47. package/build/esm/observable/internal/AbstractHelper.js +37 -2
  48. package/build/esm/observable/internal/AbstractHelper.js.map +1 -1
  49. package/build/esm/observable/internal/AbstractHelper.test.js +114 -0
  50. package/build/esm/observable/internal/AbstractHelper.test.js.map +1 -0
  51. package/build/esm/observable/internal/CacheKeys.js +19 -8
  52. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  53. package/build/esm/observable/internal/ListQueryView.js +8 -3
  54. package/build/esm/observable/internal/ListQueryView.js.map +1 -1
  55. package/build/esm/observable/internal/ObservableClientImpl.js +104 -17
  56. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  57. package/build/esm/observable/internal/RdpCanonicalizer.test.js +23 -7
  58. package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  59. package/build/esm/observable/internal/Store.js +18 -1
  60. package/build/esm/observable/internal/Store.js.map +1 -1
  61. package/build/esm/observable/internal/Store.test.js +184 -0
  62. package/build/esm/observable/internal/Store.test.js.map +1 -1
  63. package/build/esm/observable/internal/actions/ActionApplication.js +7 -4
  64. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  65. package/build/esm/observable/internal/base-list/BaseListQuery.js +5 -6
  66. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  67. package/build/esm/observable/internal/list/ListQuery.test.js +154 -0
  68. package/build/esm/observable/internal/list/ListQuery.test.js.map +1 -1
  69. package/build/esm/observable/internal/list/ObjectListQuery.js +15 -4
  70. package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
  71. package/build/esm/observable/internal/object/ObjectsHelper.js +9 -2
  72. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  73. package/build/esm/observable/internal/object/ObjectsHelper.test.js +200 -0
  74. package/build/esm/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  75. package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  76. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +3 -2
  77. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  78. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  79. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  80. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +3 -0
  81. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  82. package/build/esm/observable/internal/utils/rdpFieldOperations.js +7 -2
  83. package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  84. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  85. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  86. package/build/esm/util/UserAgent.js +2 -2
  87. package/build/types/observable/internal/AbstractHelper.d.ts.map +1 -1
  88. package/build/types/observable/internal/AbstractHelper.test.d.ts +1 -0
  89. package/build/types/observable/internal/AbstractHelper.test.d.ts.map +1 -0
  90. package/build/types/observable/internal/CacheKeys.d.ts +5 -0
  91. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  92. package/build/types/observable/internal/ListQueryView.d.ts.map +1 -1
  93. package/build/types/observable/internal/Store.d.ts.map +1 -1
  94. package/build/types/observable/internal/Store.test.d.ts.map +1 -1
  95. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  96. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +1 -0
  97. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  98. package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
  99. package/build/types/observable/internal/object/ObjectsHelper.d.ts +5 -1
  100. package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
  101. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts +1 -0
  102. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts.map +1 -0
  103. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +2 -1
  104. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -1
  105. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +3 -1
  106. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
  107. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts +1 -0
  108. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts.map +1 -0
  109. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -0
  110. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  111. package/package.json +7 -6
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRKC3366I_cjs = require('./chunk-RKC3366I.cjs');
3
+ var chunkHCG4XO6Z_cjs = require('./chunk-HCG4XO6Z.cjs');
4
4
  require('./chunk-O22QYBFF.cjs');
5
5
  var chunkLDTMSHUZ_cjs = require('./chunk-LDTMSHUZ.cjs');
6
6
  var api = require('@osdk/api');
@@ -18,7 +18,7 @@ chunkLDTMSHUZ_cjs.init_cjs_shims();
18
18
  // src/createPlatformClient.ts
19
19
  chunkLDTMSHUZ_cjs.init_cjs_shims();
20
20
  function createPlatformClient(baseUrl, tokenProvider, options = void 0, fetchFn = fetch) {
21
- return shared_client_impl.createSharedClientContext(baseUrl, tokenProvider, chunkRKC3366I_cjs.USER_AGENT, fetchFn);
21
+ return shared_client_impl.createSharedClientContext(baseUrl, tokenProvider, chunkHCG4XO6Z_cjs.USER_AGENT, fetchFn);
22
22
  }
23
23
 
24
24
  // src/util/datetimeConverters.ts
@@ -45,23 +45,23 @@ var extractDateFromIsoString = (dateTime) => {
45
45
 
46
46
  Object.defineProperty(exports, "ActionValidationError", {
47
47
  enumerable: true,
48
- get: function () { return chunkRKC3366I_cjs.ActionValidationError; }
48
+ get: function () { return chunkHCG4XO6Z_cjs.ActionValidationError; }
49
49
  });
50
50
  Object.defineProperty(exports, "createAttachmentUpload", {
51
51
  enumerable: true,
52
- get: function () { return chunkRKC3366I_cjs.createAttachmentUpload; }
52
+ get: function () { return chunkHCG4XO6Z_cjs.createAttachmentUpload; }
53
53
  });
54
54
  Object.defineProperty(exports, "createClient", {
55
55
  enumerable: true,
56
- get: function () { return chunkRKC3366I_cjs.createClient; }
56
+ get: function () { return chunkHCG4XO6Z_cjs.createClient; }
57
57
  });
58
58
  Object.defineProperty(exports, "createObjectSpecifierFromPrimaryKey", {
59
59
  enumerable: true,
60
- get: function () { return chunkRKC3366I_cjs.createObjectSpecifierFromPrimaryKey; }
60
+ get: function () { return chunkHCG4XO6Z_cjs.createObjectSpecifierFromPrimaryKey; }
61
61
  });
62
62
  Object.defineProperty(exports, "extractPrimaryKeyFromObjectSpecifier", {
63
63
  enumerable: true,
64
- get: function () { return chunkRKC3366I_cjs.extractPrimaryKeyFromObjectSpecifier; }
64
+ get: function () { return chunkHCG4XO6Z_cjs.extractPrimaryKeyFromObjectSpecifier; }
65
65
  });
66
66
  Object.defineProperty(exports, "isOk", {
67
67
  enumerable: true,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRKC3366I_cjs = require('../chunk-RKC3366I.cjs');
3
+ var chunkHCG4XO6Z_cjs = require('../chunk-HCG4XO6Z.cjs');
4
4
  var chunkO22QYBFF_cjs = require('../chunk-O22QYBFF.cjs');
5
5
  var chunkLDTMSHUZ_cjs = require('../chunk-LDTMSHUZ.cjs');
6
6
  var trie = require('@wry/trie');
@@ -257,24 +257,8 @@ var ObservableClientImpl = class {
257
257
  };
258
258
  observeLinks = (objects, linkName, options, subFn) => {
259
259
  const objectsArray = Array.isArray(objects) ? objects : [objects];
260
- const parentSub = new rxjs.Subscription();
261
- for (const obj of objectsArray) {
262
- const querySubscription = this.__experimentalStore.links.observe(
263
- {
264
- ...options,
265
- srcType: {
266
- type: "object",
267
- apiName: obj.$objectType ?? obj.$apiName
268
- },
269
- linkName,
270
- pk: obj.$primaryKey
271
- },
272
- // cast to cross typed to untyped barrier
273
- subFn
274
- );
275
- parentSub.add(querySubscription);
276
- }
277
- return new UnsubscribableWrapper(parentSub);
260
+ const observer = subFn;
261
+ return objectsArray.length <= 1 ? observeSingleLink(this.__experimentalStore, objectsArray, linkName, options, observer) : observeMultiLinks(this.__experimentalStore, objectsArray, linkName, options, observer);
278
262
  };
279
263
  observeObjectSet(baseObjectSet, options, subFn) {
280
264
  return this.__experimentalStore.objectSets.observe(
@@ -305,6 +289,110 @@ var ObservableClientImpl = class {
305
289
  return this.__experimentalStore.whereCanonicalizer.canonicalize(where);
306
290
  }
307
291
  };
292
+ function observeSingleLink(store, objectsArray, linkName, options, observer) {
293
+ if (objectsArray.length === 0) {
294
+ observer.next({
295
+ resolvedList: [],
296
+ isOptimistic: false,
297
+ lastUpdated: 0,
298
+ fetchMore: () => Promise.resolve(),
299
+ hasMore: false,
300
+ status: "loaded",
301
+ totalCount: "0"
302
+ });
303
+ return new UnsubscribableWrapper(new rxjs.Subscription());
304
+ }
305
+ const parentSub = new rxjs.Subscription();
306
+ for (const obj of objectsArray) {
307
+ parentSub.add(store.links.observe({
308
+ ...options,
309
+ srcType: {
310
+ type: "object",
311
+ apiName: obj.$objectType ?? obj.$apiName
312
+ },
313
+ linkName,
314
+ pk: obj.$primaryKey
315
+ }, observer));
316
+ }
317
+ return new UnsubscribableWrapper(parentSub);
318
+ }
319
+ function observeMultiLinks(store, objectsArray, linkName, options, observer) {
320
+ const parentSub = new rxjs.Subscription();
321
+ const totalExpected = objectsArray.length;
322
+ const perObjectResults = /* @__PURE__ */ new Map();
323
+ let errored = false;
324
+ function mergeAndEmit() {
325
+ if (errored) {
326
+ return;
327
+ }
328
+ const seen = /* @__PURE__ */ new Map();
329
+ const fetchMores = [];
330
+ let latestUpdated = 0;
331
+ let hasMore = false;
332
+ let isOptimistic = false;
333
+ for (const payload of perObjectResults.values()) {
334
+ for (const obj of payload.resolvedList) {
335
+ seen.set(`${obj.$objectType}:${obj.$primaryKey}`, obj);
336
+ }
337
+ if (payload.lastUpdated > latestUpdated) {
338
+ latestUpdated = payload.lastUpdated;
339
+ }
340
+ if (payload.isOptimistic) {
341
+ isOptimistic = true;
342
+ }
343
+ if (payload.hasMore) {
344
+ hasMore = true;
345
+ fetchMores.push(payload.fetchMore);
346
+ }
347
+ }
348
+ const payloads = [...perObjectResults.values()];
349
+ const loading = perObjectResults.size < totalExpected || payloads.some((p) => p.status === "init" || p.status === "loading");
350
+ observer.next({
351
+ resolvedList: Array.from(seen.values()),
352
+ isOptimistic,
353
+ lastUpdated: latestUpdated,
354
+ fetchMore: hasMore ? () => Promise.all(fetchMores.map((fn) => fn())).then(() => {
355
+ }) : () => Promise.resolve(),
356
+ hasMore,
357
+ status: loading ? "loading" : payloads.some((p) => p.status === "error") ? "error" : "loaded",
358
+ ...!hasMore ? {
359
+ totalCount: String(seen.size)
360
+ } : {}
361
+ });
362
+ }
363
+ for (const obj of objectsArray) {
364
+ const objKey = `${obj.$objectType ?? obj.$apiName}:${obj.$primaryKey}`;
365
+ parentSub.add(store.links.observe({
366
+ ...options,
367
+ srcType: {
368
+ type: "object",
369
+ apiName: obj.$objectType ?? obj.$apiName
370
+ },
371
+ linkName,
372
+ pk: obj.$primaryKey
373
+ }, {
374
+ next: (payload) => {
375
+ if (errored) {
376
+ return;
377
+ }
378
+ perObjectResults.set(objKey, payload);
379
+ mergeAndEmit();
380
+ },
381
+ error: (err) => {
382
+ if (errored) {
383
+ return;
384
+ }
385
+ errored = true;
386
+ parentSub.unsubscribe();
387
+ observer.error(err);
388
+ },
389
+ // store link queries are long-lived and do not complete
390
+ complete: () => {
391
+ }
392
+ }));
393
+ }
394
+ return new UnsubscribableWrapper(parentSub);
395
+ }
308
396
 
309
397
  // src/observable/internal/Store.ts
310
398
  chunkLDTMSHUZ_cjs.init_cjs_shims();
@@ -487,18 +575,13 @@ var ActionApplication = class {
487
575
  objectType,
488
576
  primaryKey
489
577
  } of deletedObjects ?? []) {
490
- const cacheKey = this.store.cacheKeys.get(
491
- "object",
492
- objectType,
493
- primaryKey,
494
- /* rdpConfig */
495
- void 0
496
- );
497
- this.store.queries.peek(cacheKey)?.deleteFromStore(
498
- "loaded",
499
- // this is probably not the best value to use
500
- batch
501
- );
578
+ for (const cacheKey of this.store.objectCacheKeyRegistry.getVariants(objectType, primaryKey)) {
579
+ this.store.queries.peek(cacheKey)?.deleteFromStore(
580
+ "loaded",
581
+ // this is probably not the best value to use
582
+ batch
583
+ );
584
+ }
502
585
  }
503
586
  });
504
587
  await Promise.all(promisesToWait);
@@ -531,6 +614,7 @@ var ListQueryView = class {
531
614
  #viewLimit;
532
615
  #pageSize;
533
616
  #viewId;
617
+ #hasAutoFetch;
534
618
  #fetchMore;
535
619
  #pendingFetchMore;
536
620
  #lastPayload;
@@ -539,8 +623,8 @@ var ListQueryView = class {
539
623
  this.#query = query;
540
624
  this.#pageSize = pageSize;
541
625
  this.#viewId = `view_${++viewIdCounter}`;
542
- const hasAutoFetch = autoFetchMore === true || typeof autoFetchMore === "number" && autoFetchMore > 0;
543
- this.#viewLimit = hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;
626
+ this.#hasAutoFetch = autoFetchMore === true || typeof autoFetchMore === "number" && autoFetchMore > 0;
627
+ this.#viewLimit = this.#hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;
544
628
  this.#fetchMore = this.#createFetchMore();
545
629
  query.registerFetchPageSize(this.#viewId, pageSize);
546
630
  }
@@ -550,6 +634,9 @@ var ListQueryView = class {
550
634
  next: (payload) => {
551
635
  this.#lastPayload = payload;
552
636
  observer.next?.(this.#transformPayload(payload));
637
+ if (!this.#hasAutoFetch && payload.status === "loaded" && payload.resolvedList.length < this.#viewLimit && this.#query.hasMorePages()) {
638
+ void this.#query.fetchMore();
639
+ }
553
640
  },
554
641
  error: (err) => observer.error?.(err),
555
642
  complete: () => observer.complete?.()
@@ -572,7 +659,8 @@ var ListQueryView = class {
572
659
  ...payload,
573
660
  resolvedList: payload.resolvedList.slice(0, this.#viewLimit),
574
661
  hasMore: this.#viewLimit < loadedCount || payload.hasMore,
575
- fetchMore: this.#fetchMore
662
+ fetchMore: this.#fetchMore,
663
+ status: loadedCount >= this.#viewLimit && payload.status === "loading" ? "loaded" : payload.status
576
664
  };
577
665
  }
578
666
  #createFetchMore() {
@@ -635,7 +723,16 @@ var AbstractHelper = class {
635
723
  return this._subscribe(query, options, subFn);
636
724
  }
637
725
  _subscribe(query, options, subFn) {
638
- this.store.cacheKeys.retain(query.cacheKey);
726
+ const pendingCleanupCount = this.store.pendingCleanup.get(query.cacheKey) ?? 0;
727
+ if (pendingCleanupCount > 0) {
728
+ if (pendingCleanupCount === 1) {
729
+ this.store.pendingCleanup.delete(query.cacheKey);
730
+ } else {
731
+ this.store.pendingCleanup.set(query.cacheKey, pendingCleanupCount - 1);
732
+ }
733
+ } else {
734
+ this.store.cacheKeys.retain(query.cacheKey);
735
+ }
639
736
  if (options.mode !== "offline") {
640
737
  query.revalidate(options.mode === "force").catch((e) => {
641
738
  subFn.error(e);
@@ -653,7 +750,18 @@ var AbstractHelper = class {
653
750
  query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
654
751
  sub.add(() => {
655
752
  query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
656
- this.store.cacheKeys.release(query.cacheKey);
753
+ this.store.pendingCleanup.set(query.cacheKey, (this.store.pendingCleanup.get(query.cacheKey) ?? 0) + 1);
754
+ queueMicrotask(() => {
755
+ const currentPending = this.store.pendingCleanup.get(query.cacheKey) ?? 0;
756
+ if (currentPending > 0) {
757
+ if (currentPending === 1) {
758
+ this.store.pendingCleanup.delete(query.cacheKey);
759
+ } else {
760
+ this.store.pendingCleanup.set(query.cacheKey, currentPending - 1);
761
+ }
762
+ this.store.cacheKeys.release(query.cacheKey);
763
+ }
764
+ });
657
765
  });
658
766
  return querySub;
659
767
  }
@@ -1049,16 +1157,26 @@ var CacheKeys = class {
1049
1157
  });
1050
1158
  }
1051
1159
  get(type, ...args) {
1052
- const normalizedArgs = [...args];
1053
- while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
1054
- normalizedArgs.pop();
1055
- }
1056
- const cacheKeyArgs = [type, ...normalizedArgs];
1160
+ const cacheKeyArgs = this.#normalizeArgs(type, args);
1057
1161
  if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
1058
1162
  const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
1059
1163
  this.#refCounts.register(cacheKey);
1060
1164
  return cacheKey;
1061
1165
  }
1166
+ /**
1167
+ * Look up an existing cache key without creating or registering it.
1168
+ * Returns undefined if the key does not exist in the trie.
1169
+ */
1170
+ peek(type, ...args) {
1171
+ return this.#cacheKeys.peekArray(this.#normalizeArgs(type, args));
1172
+ }
1173
+ #normalizeArgs(type, args) {
1174
+ const normalizedArgs = [...args];
1175
+ while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
1176
+ normalizedArgs.pop();
1177
+ }
1178
+ return [type, ...normalizedArgs];
1179
+ }
1062
1180
  retain(cacheKey) {
1063
1181
  this.#refCounts.retain(cacheKey);
1064
1182
  }
@@ -1211,7 +1329,7 @@ var FunctionParamsCanonicalizer = class {
1211
1329
  path.push("$:map_end");
1212
1330
  return arr;
1213
1331
  }
1214
- if (chunkRKC3366I_cjs.isObjectSpecifiersObject(value)) {
1332
+ if (chunkHCG4XO6Z_cjs.isObjectSpecifiersObject(value)) {
1215
1333
  const objectType = value.$objectType ?? value.$apiName;
1216
1334
  path.push("$:osdk", objectType, value.$primaryKey);
1217
1335
  return {
@@ -1340,7 +1458,7 @@ var FunctionQuery = class extends Query {
1340
1458
  }).debug("calling _fetchAndStore");
1341
1459
  }
1342
1460
  try {
1343
- const result = await chunkRKC3366I_cjs.applyQuery(this.store.client[chunkO22QYBFF_cjs.additionalContext], this.#queryDef, this.#params);
1461
+ const result = await chunkHCG4XO6Z_cjs.applyQuery(this.store.client[chunkO22QYBFF_cjs.additionalContext], this.#queryDef, this.#params);
1344
1462
  const executedAt = Date.now();
1345
1463
  this.store.batch({}, (batch) => {
1346
1464
  this.writeToStore({
@@ -2145,11 +2263,9 @@ var BaseListQuery = class extends Query {
2145
2263
  return this.pendingPageFetch;
2146
2264
  }
2147
2265
  if (this.pendingFetch) {
2148
- this.pendingPageFetch = (async () => {
2149
- await this.pendingFetch;
2150
- await this.fetchMore();
2151
- })().finally(() => {
2266
+ this.pendingPageFetch = this.pendingFetch.then(() => {
2152
2267
  this.pendingPageFetch = void 0;
2268
+ return this.fetchMore();
2153
2269
  });
2154
2270
  return this.pendingPageFetch;
2155
2271
  }
@@ -2483,8 +2599,9 @@ var BaseListQuery = class extends Query {
2483
2599
  }).debug("Removing object", object);
2484
2600
  }
2485
2601
  this.store.batch({}, (batch) => {
2486
- const objectCacheKey = this.store.cacheKeys.get("object", object.$objectType ?? object.$apiName, object.$primaryKey);
2487
- batch.delete(objectCacheKey, "loaded");
2602
+ for (const objectCacheKey of this.store.objectCacheKeyRegistry.getVariants(object.$objectType ?? object.$apiName, object.$primaryKey)) {
2603
+ batch.delete(objectCacheKey, "loaded");
2604
+ }
2488
2605
  });
2489
2606
  }
2490
2607
  };
@@ -3206,7 +3323,7 @@ var InterfaceListQuery = class extends ListQuery {
3206
3323
  }
3207
3324
  extractRelevantObjects(changes) {
3208
3325
  const matchesApiName = ([, object]) => {
3209
- return this.apiName in object[chunkRKC3366I_cjs.ObjectDefRef].interfaceMap;
3326
+ return this.apiName in object[chunkHCG4XO6Z_cjs.ObjectDefRef].interfaceMap;
3210
3327
  };
3211
3328
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
3212
3329
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
@@ -3265,10 +3382,21 @@ var ObjectListQuery = class extends ListQuery {
3265
3382
  apiName: this.apiName
3266
3383
  };
3267
3384
  if (pivotInfo != null) {
3268
- let sourceSet = store.client({
3269
- type: "object",
3270
- apiName: pivotInfo.sourceType
3271
- });
3385
+ let sourceSet;
3386
+ if (rids != null) {
3387
+ sourceSet = clientCtx.objectSetFactory({
3388
+ type: "object",
3389
+ apiName: pivotInfo.sourceType
3390
+ }, clientCtx, {
3391
+ type: "static",
3392
+ objects: [...rids]
3393
+ });
3394
+ } else {
3395
+ sourceSet = store.client({
3396
+ type: "object",
3397
+ apiName: pivotInfo.sourceType
3398
+ });
3399
+ }
3272
3400
  sourceSet = sourceSet.where(this.canonicalWhere);
3273
3401
  let objectSet2 = sourceSet.pivotTo(pivotInfo.linkName);
3274
3402
  if (rdpConfig != null) {
@@ -3410,8 +3538,8 @@ function stripRdpFields(value, rdpFields) {
3410
3538
  if (rdpFields.size === 0) {
3411
3539
  return value;
3412
3540
  }
3413
- const underlying = value[chunkRKC3366I_cjs.UnderlyingOsdkObject];
3414
- const objectDef = value[chunkRKC3366I_cjs.ObjectDefRef];
3541
+ const underlying = value[chunkHCG4XO6Z_cjs.UnderlyingOsdkObject];
3542
+ const objectDef = value[chunkHCG4XO6Z_cjs.ObjectDefRef];
3415
3543
  const newProps = {
3416
3544
  $apiName: underlying.$apiName,
3417
3545
  $objectType: underlying.$objectType,
@@ -3424,7 +3552,7 @@ function stripRdpFields(value, rdpFields) {
3424
3552
  newProps[key] = underlying[key];
3425
3553
  }
3426
3554
  }
3427
- return chunkRKC3366I_cjs.createOsdkObject(value[chunkRKC3366I_cjs.ClientRef], objectDef, newProps);
3555
+ return chunkHCG4XO6Z_cjs.createOsdkObject(value[chunkHCG4XO6Z_cjs.ClientRef], objectDef, newProps);
3428
3556
  }
3429
3557
  function isSuperset(superset, subset) {
3430
3558
  for (const field of subset) {
@@ -3435,8 +3563,8 @@ function isSuperset(superset, subset) {
3435
3563
  return true;
3436
3564
  }
3437
3565
  function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3438
- const underlying = value[chunkRKC3366I_cjs.UnderlyingOsdkObject];
3439
- const objectDef = value[chunkRKC3366I_cjs.ObjectDefRef];
3566
+ const underlying = value[chunkHCG4XO6Z_cjs.UnderlyingOsdkObject];
3567
+ const objectDef = value[chunkHCG4XO6Z_cjs.ObjectDefRef];
3440
3568
  const newProps = {
3441
3569
  $apiName: underlying.$apiName,
3442
3570
  $objectType: underlying.$objectType,
@@ -3452,7 +3580,7 @@ function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3452
3580
  }
3453
3581
  }
3454
3582
  }
3455
- return chunkRKC3366I_cjs.createOsdkObject(value[chunkRKC3366I_cjs.ClientRef], objectDef, newProps);
3583
+ return chunkHCG4XO6Z_cjs.createOsdkObject(value[chunkHCG4XO6Z_cjs.ClientRef], objectDef, newProps);
3456
3584
  }
3457
3585
  function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue) {
3458
3586
  if (targetRdpFields.size === 0) {
@@ -3464,8 +3592,8 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3464
3592
  }
3465
3593
  return filterToRdpFields(sourceValue, targetRdpFields, sourceRdpFields);
3466
3594
  }
3467
- const sourceUnderlying = sourceValue[chunkRKC3366I_cjs.UnderlyingOsdkObject];
3468
- const objectDef = sourceValue[chunkRKC3366I_cjs.ObjectDefRef];
3595
+ const sourceUnderlying = sourceValue[chunkHCG4XO6Z_cjs.UnderlyingOsdkObject];
3596
+ const objectDef = sourceValue[chunkHCG4XO6Z_cjs.ObjectDefRef];
3469
3597
  const newProps = {
3470
3598
  $apiName: sourceUnderlying.$apiName,
3471
3599
  $objectType: sourceUnderlying.$objectType,
@@ -3479,14 +3607,16 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3479
3607
  }
3480
3608
  }
3481
3609
  if (targetCurrentValue) {
3482
- const targetUnderlying = targetCurrentValue[chunkRKC3366I_cjs.UnderlyingOsdkObject];
3610
+ const targetUnderlying = targetCurrentValue[chunkHCG4XO6Z_cjs.UnderlyingOsdkObject];
3483
3611
  for (const field of targetRdpFields) {
3484
- if (!sourceRdpFields.has(field) && field in targetUnderlying) {
3485
- newProps[field] = targetUnderlying[field];
3612
+ if (field in targetUnderlying) {
3613
+ if (!sourceRdpFields.has(field) || newProps[field] === void 0) {
3614
+ newProps[field] = targetUnderlying[field];
3615
+ }
3486
3616
  }
3487
3617
  }
3488
3618
  }
3489
- return chunkRKC3366I_cjs.createOsdkObject(sourceValue[chunkRKC3366I_cjs.ClientRef], objectDef, newProps);
3619
+ return chunkHCG4XO6Z_cjs.createOsdkObject(sourceValue[chunkHCG4XO6Z_cjs.ClientRef], objectDef, newProps);
3490
3620
  }
3491
3621
 
3492
3622
  // src/observable/internal/object/ObjectCacheKeyRegistry.ts
@@ -3818,11 +3948,18 @@ var ObjectsHelper = class extends AbstractHelper {
3818
3948
  }
3819
3949
  }
3820
3950
  /**
3821
- * Check if a cache key is actively observed
3951
+ * Check if a cache key is actively observed or pending cleanup.
3952
+ * During React unmount-remount cycles, a key may be momentarily
3953
+ * unobserved while its cleanup is deferred to a microtask.
3954
+ * We still propagate to such keys to prevent stale data when
3955
+ * the subscription is re-established.
3822
3956
  */
3823
3957
  isKeyActive(key) {
3824
3958
  const subject = this.store.subjects.peek(key);
3825
- return subject?.observed === true;
3959
+ if (subject?.observed === true) {
3960
+ return true;
3961
+ }
3962
+ return (this.store.pendingCleanup.get(key) ?? 0) > 0;
3826
3963
  }
3827
3964
  /**
3828
3965
  * Type guard to check if a value is an ObjectHolder
@@ -3866,6 +4003,9 @@ var ObjectSetQuery = class extends BaseListQuery {
3866
4003
  this.minResultsToLoad = opts.pageSize || 0;
3867
4004
  }
3868
4005
  }
4006
+ get rdpConfig() {
4007
+ return this.#operations.withProperties ?? null;
4008
+ }
3869
4009
  #composeObjectSet(opts) {
3870
4010
  let result = opts.baseObjectSet;
3871
4011
  if (opts.withProperties) {
@@ -3988,10 +4128,11 @@ var ObjectSetQuery = class extends BaseListQuery {
3988
4128
 
3989
4129
  // src/observable/internal/objectset/ObjectSetHelper.ts
3990
4130
  var ObjectSetHelper = class extends AbstractHelper {
3991
- constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
4131
+ constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer) {
3992
4132
  super(store, cacheKeys);
3993
4133
  this.whereCanonicalizer = whereCanonicalizer2;
3994
4134
  this.orderByCanonicalizer = orderByCanonicalizer2;
4135
+ this.rdpCanonicalizer = rdpCanonicalizer;
3995
4136
  }
3996
4137
  observe(options, subFn) {
3997
4138
  const ret = super.observe(options, subFn);
@@ -4017,7 +4158,7 @@ var ObjectSetHelper = class extends AbstractHelper {
4017
4158
  operations.where = this.whereCanonicalizer.canonicalize(options.where);
4018
4159
  }
4019
4160
  if (options.withProperties) {
4020
- operations.withProperties = Object.keys(options.withProperties).sort();
4161
+ operations.withProperties = this.rdpCanonicalizer.canonicalize(options.withProperties);
4021
4162
  }
4022
4163
  if (options.union && options.union.length > 0) {
4023
4164
  operations.union = options.union.map((os) => JSON.stringify(chunkO22QYBFF_cjs.getWireObjectSet(os)));
@@ -4158,6 +4299,17 @@ var Store = class {
4158
4299
  ridListCanonicalizer = new RidListCanonicalizer();
4159
4300
  /** @internal */
4160
4301
  queries = new Queries();
4302
+ /**
4303
+ * Tracks cache keys with deferred cleanup. During React unmount-remount
4304
+ * cycles, a subscription may be cleaned up and immediately re-created.
4305
+ * By deferring cleanup to a microtask, we prevent propagateWrite from
4306
+ * skipping keys that are momentarily between subscriptions.
4307
+ *
4308
+ * The value is a count (not a boolean) so multiple unsubscribes within the
4309
+ * same tick schedule the correct number of releases.
4310
+ * @internal
4311
+ */
4312
+ pendingCleanup = /* @__PURE__ */ new Map();
4161
4313
  objectCacheKeyRegistry = new ObjectCacheKeyRegistry();
4162
4314
  layers = new Layers({
4163
4315
  logger: this.logger,
@@ -4178,7 +4330,7 @@ var Store = class {
4178
4330
  this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer, this.pivotCanonicalizer, this.ridListCanonicalizer);
4179
4331
  this.objects = new ObjectsHelper(this, this.cacheKeys);
4180
4332
  this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
4181
- this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
4333
+ this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer);
4182
4334
  }
4183
4335
  /**
4184
4336
  * Called after a key is no longer retained and the timeout has elapsed
@@ -4340,6 +4492,11 @@ var Store = class {
4340
4492
  return cacheKey.otherKeys[RDP_IDX2];
4341
4493
  } else if (cacheKey.type === "aggregation") {
4342
4494
  return cacheKey.otherKeys[RDP_IDX];
4495
+ } else if (cacheKey.type === "objectSet") {
4496
+ const query = this.queries.peek(cacheKey);
4497
+ if (query) {
4498
+ return query.rdpConfig;
4499
+ }
4343
4500
  }
4344
4501
  }
4345
4502
  return void 0;
@@ -4439,10 +4596,10 @@ var Store = class {
4439
4596
 
4440
4597
  // src/observable/ObservableClient.ts
4441
4598
  function createObservableClient(client) {
4442
- const tweakedClient = chunkRKC3366I_cjs.createClientFromContext({
4599
+ const tweakedClient = chunkHCG4XO6Z_cjs.createClientFromContext({
4443
4600
  ...client[chunkO22QYBFF_cjs.additionalContext],
4444
4601
  fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkO22QYBFF_cjs.additionalContext].fetch, (headers) => {
4445
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkRKC3366I_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
4602
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkHCG4XO6Z_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
4446
4603
  return headers;
4447
4604
  })
4448
4605
  });
@@ -4486,7 +4643,7 @@ function getOsdkConfig(ontologyRid) {
4486
4643
 
4487
4644
  Object.defineProperty(exports, "createClientWithTransaction", {
4488
4645
  enumerable: true,
4489
- get: function () { return chunkRKC3366I_cjs.createClientWithTransaction; }
4646
+ get: function () { return chunkHCG4XO6Z_cjs.createClientWithTransaction; }
4490
4647
  });
4491
4648
  Object.defineProperty(exports, "augment", {
4492
4649
  enumerable: true,