@osdk/client 2.8.0-beta.26 → 2.8.0-beta.28

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 (110) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +1 -17
  3. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  4. package/build/browser/object/SimpleOsdkProperties.js.map +1 -1
  5. package/build/browser/observable/ObservableClient/MediaObservableTypes.js +2 -0
  6. package/build/browser/observable/ObservableClient/MediaObservableTypes.js.map +1 -0
  7. package/build/browser/observable/ObservableClient/MediaTypes.js +2 -0
  8. package/build/browser/observable/ObservableClient/MediaTypes.js.map +1 -0
  9. package/build/browser/observable/internal/Changes.js.map +1 -1
  10. package/build/browser/observable/internal/GenericCanonicalizer.js +72 -0
  11. package/build/browser/observable/internal/GenericCanonicalizer.js.map +1 -0
  12. package/build/browser/observable/internal/IntersectCanonicalizer.js +1 -1
  13. package/build/browser/observable/internal/IntersectCanonicalizer.js.map +1 -1
  14. package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
  15. package/build/browser/observable/internal/ListQueryView.js +21 -9
  16. package/build/browser/observable/internal/ListQueryView.js.map +1 -1
  17. package/build/browser/observable/internal/ObjectSetArrayCanonicalizer.js +34 -0
  18. package/build/browser/observable/internal/ObjectSetArrayCanonicalizer.js.map +1 -0
  19. package/build/browser/observable/internal/Store.js +26 -2
  20. package/build/browser/observable/internal/Store.js.map +1 -1
  21. package/build/browser/observable/internal/list/ListQuery.js +0 -9
  22. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  23. package/build/browser/observable/internal/media/BlobMemoryManager.js +116 -0
  24. package/build/browser/observable/internal/media/BlobMemoryManager.js.map +1 -0
  25. package/build/browser/observable/internal/media/MediaMetadataCacheKey.js +2 -0
  26. package/build/browser/observable/internal/media/MediaMetadataCacheKey.js.map +1 -0
  27. package/build/browser/observable/internal/media/MediaMetadataQuery.js +159 -0
  28. package/build/browser/observable/internal/media/MediaMetadataQuery.js.map +1 -0
  29. package/build/browser/observable/internal/media/getMediaCacheKey.js +28 -0
  30. package/build/browser/observable/internal/media/getMediaCacheKey.js.map +1 -0
  31. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  32. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +5 -4
  33. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  34. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +180 -27
  35. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  36. package/build/browser/util/UserAgent.js +2 -2
  37. package/build/cjs/{chunk-YKQ5QTEF.cjs → chunk-66XI45ES.cjs} +39 -39
  38. package/build/cjs/{chunk-YKQ5QTEF.cjs.map → chunk-66XI45ES.cjs.map} +1 -1
  39. package/build/cjs/{chunk-BWOPPEUP.cjs → chunk-SV4AIIV4.cjs} +2 -19
  40. package/build/cjs/chunk-SV4AIIV4.cjs.map +1 -0
  41. package/build/cjs/index.cjs +10 -10
  42. package/build/cjs/public/internal.cjs +8 -8
  43. package/build/cjs/public/unstable-do-not-use.cjs +353 -111
  44. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  45. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +1 -17
  46. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  47. package/build/esm/object/SimpleOsdkProperties.js.map +1 -1
  48. package/build/esm/observable/ObservableClient/MediaObservableTypes.js +2 -0
  49. package/build/esm/observable/ObservableClient/MediaObservableTypes.js.map +1 -0
  50. package/build/esm/observable/ObservableClient/MediaTypes.js +2 -0
  51. package/build/esm/observable/ObservableClient/MediaTypes.js.map +1 -0
  52. package/build/esm/observable/internal/Changes.js.map +1 -1
  53. package/build/esm/observable/internal/GenericCanonicalizer.js +72 -0
  54. package/build/esm/observable/internal/GenericCanonicalizer.js.map +1 -0
  55. package/build/esm/observable/internal/IntersectCanonicalizer.js +1 -1
  56. package/build/esm/observable/internal/IntersectCanonicalizer.js.map +1 -1
  57. package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
  58. package/build/esm/observable/internal/ListQueryView.js +21 -9
  59. package/build/esm/observable/internal/ListQueryView.js.map +1 -1
  60. package/build/esm/observable/internal/ObjectSetArrayCanonicalizer.js +34 -0
  61. package/build/esm/observable/internal/ObjectSetArrayCanonicalizer.js.map +1 -0
  62. package/build/esm/observable/internal/Store.js +26 -2
  63. package/build/esm/observable/internal/Store.js.map +1 -1
  64. package/build/esm/observable/internal/list/ListQuery.js +0 -9
  65. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  66. package/build/esm/observable/internal/media/BlobMemoryManager.js +116 -0
  67. package/build/esm/observable/internal/media/BlobMemoryManager.js.map +1 -0
  68. package/build/esm/observable/internal/media/MediaMetadataCacheKey.js +2 -0
  69. package/build/esm/observable/internal/media/MediaMetadataCacheKey.js.map +1 -0
  70. package/build/esm/observable/internal/media/MediaMetadataQuery.js +159 -0
  71. package/build/esm/observable/internal/media/MediaMetadataQuery.js.map +1 -0
  72. package/build/esm/observable/internal/media/getMediaCacheKey.js +28 -0
  73. package/build/esm/observable/internal/media/getMediaCacheKey.js.map +1 -0
  74. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  75. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +5 -4
  76. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  77. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +180 -27
  78. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  79. package/build/esm/util/UserAgent.js +2 -2
  80. package/build/types/observable/ObservableClient/MediaObservableTypes.d.ts +35 -0
  81. package/build/types/observable/ObservableClient/MediaObservableTypes.d.ts.map +1 -0
  82. package/build/types/observable/ObservableClient/MediaTypes.d.ts +1 -0
  83. package/build/types/observable/ObservableClient/MediaTypes.d.ts.map +1 -0
  84. package/build/types/observable/internal/Changes.d.ts +4 -3
  85. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  86. package/build/types/observable/internal/GenericCanonicalizer.d.ts +8 -0
  87. package/build/types/observable/internal/GenericCanonicalizer.d.ts.map +1 -0
  88. package/build/types/observable/internal/IntersectCanonicalizer.d.ts.map +1 -1
  89. package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
  90. package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
  91. package/build/types/observable/internal/ListQueryView.d.ts.map +1 -1
  92. package/build/types/observable/internal/ObjectSetArrayCanonicalizer.d.ts +7 -0
  93. package/build/types/observable/internal/ObjectSetArrayCanonicalizer.d.ts.map +1 -0
  94. package/build/types/observable/internal/Store.d.ts +4 -0
  95. package/build/types/observable/internal/Store.d.ts.map +1 -1
  96. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  97. package/build/types/observable/internal/media/BlobMemoryManager.d.ts +10 -0
  98. package/build/types/observable/internal/media/BlobMemoryManager.d.ts.map +1 -0
  99. package/build/types/observable/internal/media/MediaMetadataCacheKey.d.ts +4 -0
  100. package/build/types/observable/internal/media/MediaMetadataCacheKey.d.ts.map +1 -0
  101. package/build/types/observable/internal/media/MediaMetadataQuery.d.ts +23 -0
  102. package/build/types/observable/internal/media/MediaMetadataQuery.d.ts.map +1 -0
  103. package/build/types/observable/internal/media/getMediaCacheKey.d.ts +2 -0
  104. package/build/types/observable/internal/media/getMediaCacheKey.d.ts.map +1 -0
  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/ObjectSetQuery.d.ts +4 -1
  108. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  109. package/package.json +9 -9
  110. package/build/cjs/chunk-BWOPPEUP.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkYKQ5QTEF_cjs = require('../chunk-YKQ5QTEF.cjs');
4
- var chunkBWOPPEUP_cjs = require('../chunk-BWOPPEUP.cjs');
3
+ var chunk66XI45ES_cjs = require('../chunk-66XI45ES.cjs');
4
+ var chunkSV4AIIV4_cjs = require('../chunk-SV4AIIV4.cjs');
5
5
  require('../chunk-GSVXEVM4.cjs');
6
6
  require('../chunk-D26YLHTV.cjs');
7
7
  require('../chunk-YJG67XL4.cjs');
@@ -139,7 +139,7 @@ var WhereClauseCanonicalizer = class {
139
139
  var whereCanonicalizer = new WhereClauseCanonicalizer();
140
140
  var orderByCanonicalizer = new OrderByCanonicalizer();
141
141
  function computeObjectSetCacheKey(objectSet, options) {
142
- const keyParts = ["objectSet", chunkBWOPPEUP_cjs.getWireObjectSet(objectSet)];
142
+ const keyParts = ["objectSet", chunkSV4AIIV4_cjs.getWireObjectSet(objectSet)];
143
143
  if (!options) {
144
144
  return JSON.stringify(keyParts);
145
145
  }
@@ -151,13 +151,13 @@ function computeObjectSetCacheKey(objectSet, options) {
151
151
  keyParts.push("props", propKeys);
152
152
  }
153
153
  if (options.union && options.union.length > 0) {
154
- keyParts.push("union", options.union.map((os) => chunkBWOPPEUP_cjs.getWireObjectSet(os)));
154
+ keyParts.push("union", options.union.map((os) => chunkSV4AIIV4_cjs.getWireObjectSet(os)));
155
155
  }
156
156
  if (options.intersect && options.intersect.length > 0) {
157
- keyParts.push("intersect", options.intersect.map((os) => chunkBWOPPEUP_cjs.getWireObjectSet(os)));
157
+ keyParts.push("intersect", options.intersect.map((os) => chunkSV4AIIV4_cjs.getWireObjectSet(os)));
158
158
  }
159
159
  if (options.subtract && options.subtract.length > 0) {
160
- keyParts.push("subtract", options.subtract.map((os) => chunkBWOPPEUP_cjs.getWireObjectSet(os)));
160
+ keyParts.push("subtract", options.subtract.map((os) => chunkSV4AIIV4_cjs.getWireObjectSet(os)));
161
161
  }
162
162
  if (options.pivotTo) {
163
163
  keyParts.push("pivotTo", options.pivotTo);
@@ -221,8 +221,8 @@ var ObservableClientImpl = class {
221
221
  const instances = [];
222
222
  const objectSetWires = [];
223
223
  for (const item of options.dependsOnObjects ?? []) {
224
- if (chunkBWOPPEUP_cjs.isObjectSet(item)) {
225
- objectSetWires.push(chunkBWOPPEUP_cjs.getWireObjectSet(item));
224
+ if (chunkSV4AIIV4_cjs.isObjectSet(item)) {
225
+ objectSetWires.push(chunkSV4AIIV4_cjs.getWireObjectSet(item));
226
226
  } else {
227
227
  instances.push({
228
228
  $apiName: item.$objectType ?? item.$apiName,
@@ -230,7 +230,7 @@ var ObservableClientImpl = class {
230
230
  });
231
231
  }
232
232
  }
233
- const objectSetTypesPromise = objectSetWires.length > 0 ? Promise.all(objectSetWires.map((wire) => chunkBWOPPEUP_cjs.extractObjectOrInterfaceType(this.__experimentalStore.client[chunkBWOPPEUP_cjs.additionalContext], wire))).then((types) => types.filter((t) => t != null).map((t) => t.apiName)) : void 0;
233
+ const objectSetTypesPromise = objectSetWires.length > 0 ? Promise.all(objectSetWires.map((wire) => chunkSV4AIIV4_cjs.extractObjectOrInterfaceType(this.__experimentalStore.client[chunkSV4AIIV4_cjs.additionalContext], wire))).then((types) => types.filter((t) => t != null).map((t) => t.apiName)) : void 0;
234
234
  return this.__experimentalStore.functions.observe({
235
235
  ...options,
236
236
  queryDef,
@@ -459,7 +459,7 @@ var OptimisticJob = class {
459
459
  return this;
460
460
  },
461
461
  createObject(type, pk, properties) {
462
- const create = store.client[chunkBWOPPEUP_cjs.additionalContext].objectFactory2(store.client[chunkBWOPPEUP_cjs.additionalContext], [{
462
+ const create = store.client[chunkSV4AIIV4_cjs.additionalContext].objectFactory2(store.client[chunkSV4AIIV4_cjs.additionalContext], [{
463
463
  $primaryKey: pk,
464
464
  $apiName: type.apiName,
465
465
  $objectType: type.apiName,
@@ -597,7 +597,7 @@ var ListQueryView = class {
597
597
  #viewLimit;
598
598
  #pageSize;
599
599
  #viewId;
600
- #hasAutoFetch;
600
+ #autoFetchMinimum;
601
601
  #fetchMore;
602
602
  #pendingFetchMore;
603
603
  #lastPayload;
@@ -606,8 +606,8 @@ var ListQueryView = class {
606
606
  this.#query = query;
607
607
  this.#pageSize = pageSize;
608
608
  this.#viewId = `view_${++viewIdCounter}`;
609
- this.#hasAutoFetch = autoFetchMore === true || typeof autoFetchMore === "number" && autoFetchMore > 0;
610
- this.#viewLimit = this.#hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;
609
+ this.#autoFetchMinimum = autoFetchMore === true ? Number.MAX_SAFE_INTEGER : typeof autoFetchMore === "number" && autoFetchMore > 0 ? autoFetchMore : 0;
610
+ this.#viewLimit = this.#autoFetchMinimum > 0 ? Number.MAX_SAFE_INTEGER : pageSize;
611
611
  this.#fetchMore = this.#createFetchMore();
612
612
  query.registerFetchPageSize(this.#viewId, pageSize);
613
613
  }
@@ -616,8 +616,10 @@ var ListQueryView = class {
616
616
  const sub = this.#query.subscribe({
617
617
  next: (payload) => {
618
618
  this.#lastPayload = payload;
619
- observer.next?.(this.#transformPayload(payload));
620
- if (!this.#hasAutoFetch && payload.status === "loaded" && (payload.resolvedList?.length ?? 0) < this.#viewLimit && this.#query.hasMorePages()) {
619
+ this.#observer?.next?.(this.#transformPayload(payload));
620
+ const loadedCount = payload.resolvedList?.length ?? 0;
621
+ const fetchThreshold = this.#autoFetchMinimum > 0 ? this.#autoFetchMinimum : this.#viewLimit;
622
+ if (payload.status === "loaded" && this.#query.hasMorePages() && loadedCount < fetchThreshold) {
621
623
  void this.#query.fetchMore();
622
624
  }
623
625
  },
@@ -639,12 +641,19 @@ var ListQueryView = class {
639
641
  #transformPayload(payload) {
640
642
  const resolvedList = payload.resolvedList;
641
643
  const loadedCount = resolvedList?.length ?? 0;
644
+ let status = payload.status;
645
+ if (this.#autoFetchMinimum > 0 && status === "loaded" && this.#query.hasMorePages() && loadedCount < this.#autoFetchMinimum) {
646
+ status = "loading";
647
+ }
648
+ if (loadedCount >= this.#viewLimit && status === "loading") {
649
+ status = "loaded";
650
+ }
642
651
  return {
643
652
  ...payload,
644
653
  resolvedList: resolvedList?.slice(0, this.#viewLimit),
645
654
  hasMore: this.#viewLimit < loadedCount || payload.hasMore,
646
655
  fetchMore: this.#fetchMore,
647
- status: loadedCount >= this.#viewLimit && payload.status === "loading" ? "loaded" : payload.status
656
+ status
648
657
  };
649
658
  }
650
659
  #createFetchMore() {
@@ -917,7 +926,7 @@ var Query = class {
917
926
  this.store = store;
918
927
  this.cacheKeys = store.cacheKeys;
919
928
  this.#subject = observable;
920
- this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger : store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
929
+ this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger : store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
921
930
  msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
922
931
  }));
923
932
  }
@@ -1079,7 +1088,7 @@ var AggregationQuery = class extends Query {
1079
1088
  #invalidationTypes;
1080
1089
  #invalidationTypesPromise;
1081
1090
  constructor(store, subject, cacheKey, opts) {
1082
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
1091
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
1083
1092
  msgPrefix: `AggregationQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
1084
1093
  }) : void 0);
1085
1094
  this.apiName = cacheKey.otherKeys[API_NAME_IDX];
@@ -1097,7 +1106,7 @@ var AggregationQuery = class extends Query {
1097
1106
  try {
1098
1107
  const {
1099
1108
  invalidationSet
1100
- } = await getObjectTypesThatInvalidate(this.store.client[chunkBWOPPEUP_cjs.additionalContext], wireObjectSet);
1109
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkSV4AIIV4_cjs.additionalContext], wireObjectSet);
1101
1110
  return /* @__PURE__ */ new Set([this.apiName, ...invalidationSet]);
1102
1111
  } catch (error) {
1103
1112
  this.store.logger?.error("Failed to compute invalidation types for aggregation, falling back to base type only", error);
@@ -1168,7 +1177,7 @@ var ObjectAggregationQuery = class extends AggregationQuery {
1168
1177
  };
1169
1178
  let objectSet;
1170
1179
  if (this.parsedWireObjectSet) {
1171
- objectSet = chunkBWOPPEUP_cjs.createObjectSet(objectTypeDef, this.store.client[chunkBWOPPEUP_cjs.additionalContext], this.parsedWireObjectSet);
1180
+ objectSet = chunkSV4AIIV4_cjs.createObjectSet(objectTypeDef, this.store.client[chunkSV4AIIV4_cjs.additionalContext], this.parsedWireObjectSet);
1172
1181
  } else {
1173
1182
  objectSet = this.store.client(objectTypeDef);
1174
1183
  }
@@ -1210,7 +1219,7 @@ var AggregationsHelper = class extends AbstractHelper {
1210
1219
  return this.getOrCreateQuery(options, void 0);
1211
1220
  }
1212
1221
  getQueryWithObjectSet(options) {
1213
- const serializedObjectSet = JSON.stringify(chunkBWOPPEUP_cjs.getWireObjectSet(options.objectSet));
1222
+ const serializedObjectSet = JSON.stringify(chunkSV4AIIV4_cjs.getWireObjectSet(options.objectSet));
1214
1223
  return this.getOrCreateQuery(options, serializedObjectSet);
1215
1224
  }
1216
1225
  getOrCreateQuery(options, serializedObjectSet) {
@@ -1533,7 +1542,7 @@ var FunctionParamsCanonicalizer = class {
1533
1542
  path.push("$:map_end");
1534
1543
  return arr;
1535
1544
  }
1536
- if (chunkYKQ5QTEF_cjs.isObjectSpecifiersObject(value)) {
1545
+ if (chunk66XI45ES_cjs.isObjectSpecifiersObject(value)) {
1537
1546
  const objectType = value.$objectType ?? value.$apiName;
1538
1547
  path.push("$:osdk", objectType, value.$primaryKey);
1539
1548
  return {
@@ -1541,8 +1550,8 @@ var FunctionParamsCanonicalizer = class {
1541
1550
  $primaryKey: value.$primaryKey
1542
1551
  };
1543
1552
  }
1544
- if (chunkBWOPPEUP_cjs.isObjectSet(value)) {
1545
- const wire = chunkBWOPPEUP_cjs.getWireObjectSet(value);
1553
+ if (chunkSV4AIIV4_cjs.isObjectSet(value)) {
1554
+ const wire = chunkSV4AIIV4_cjs.getWireObjectSet(value);
1546
1555
  path.push("$:objectset", wire);
1547
1556
  return wire;
1548
1557
  }
@@ -1602,7 +1611,7 @@ var FunctionQuery = class extends Query {
1602
1611
  #dependsOnObjects;
1603
1612
  #queryDef;
1604
1613
  constructor(store, subject, queryDef, params, cacheKey, opts, objectSetTypesPromise) {
1605
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
1614
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
1606
1615
  msgPrefix: `FunctionQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
1607
1616
  }) : void 0);
1608
1617
  this.#apiName = queryDef.apiName;
@@ -1659,7 +1668,7 @@ var FunctionQuery = class extends Query {
1659
1668
  }).debug("calling _fetchAndStore");
1660
1669
  }
1661
1670
  try {
1662
- const result = await chunkYKQ5QTEF_cjs.applyQuery(this.store.client[chunkBWOPPEUP_cjs.additionalContext], this.#queryDef, this.#params);
1671
+ const result = await chunk66XI45ES_cjs.applyQuery(this.store.client[chunkSV4AIIV4_cjs.additionalContext], this.#queryDef, this.#params);
1663
1672
  const executedAt = Date.now();
1664
1673
  this.store.batch({}, (batch) => {
1665
1674
  this.writeToStore({
@@ -1824,6 +1833,56 @@ var CachingCanonicalizer = class {
1824
1833
  }
1825
1834
  };
1826
1835
 
1836
+ // src/observable/internal/GenericCanonicalizer.ts
1837
+ var MAX_FINGERPRINT_DEPTH = 5;
1838
+ var GenericCanonicalizer = class extends CachingCanonicalizer {
1839
+ #trie = new trie.Trie();
1840
+ #existingValues = /* @__PURE__ */ new Map();
1841
+ canonicalize(input) {
1842
+ return super.canonicalize(input);
1843
+ }
1844
+ lookupOrCreate(input) {
1845
+ const structuralKey = this.#collectSortedKeys(input);
1846
+ const cacheKey = this.#trie.lookupArray(structuralKey);
1847
+ const entry = this.#existingValues.get(cacheKey) ?? {
1848
+ values: []
1849
+ };
1850
+ this.#existingValues.set(cacheKey, entry);
1851
+ for (let i = entry.values.length - 1; i >= 0; i--) {
1852
+ const existing = entry.values[i].deref();
1853
+ if (!existing) {
1854
+ entry.values.splice(i, 1);
1855
+ continue;
1856
+ }
1857
+ if (deepEqual__default.default(existing, input)) {
1858
+ return existing;
1859
+ }
1860
+ }
1861
+ const canonical = input;
1862
+ entry.values.push(new WeakRef(canonical));
1863
+ return canonical;
1864
+ }
1865
+ #collectSortedKeys(obj, depth = 0) {
1866
+ if (depth > MAX_FINGERPRINT_DEPTH || !obj || typeof obj !== "object") {
1867
+ return [];
1868
+ }
1869
+ if (Array.isArray(obj)) {
1870
+ const result2 = ["[]", String(obj.length)];
1871
+ for (const item of obj) {
1872
+ result2.push(...this.#collectSortedKeys(item, depth + 1));
1873
+ }
1874
+ return result2;
1875
+ }
1876
+ const record = obj;
1877
+ const result = [];
1878
+ for (const key of Object.keys(record).sort()) {
1879
+ result.push(key);
1880
+ result.push(...this.#collectSortedKeys(record[key], depth + 1));
1881
+ }
1882
+ return result;
1883
+ }
1884
+ };
1885
+
1827
1886
  // src/observable/internal/IntersectCanonicalizer.ts
1828
1887
  var IntersectCanonicalizer = class extends CachingCanonicalizer {
1829
1888
  structuralCache = /* @__PURE__ */ new Map();
@@ -1833,7 +1892,7 @@ var IntersectCanonicalizer = class extends CachingCanonicalizer {
1833
1892
  }
1834
1893
  lookupOrCreate(intersectWith) {
1835
1894
  const canonicalClauses = intersectWith.map((item) => this.whereCanonicalizer.canonicalize(item.where ?? {}));
1836
- const structuralKey = canonicalClauses.map((clause) => JSON.stringify(clause)).join("||");
1895
+ const structuralKey = canonicalClauses.map((clause) => JSON.stringify(clause)).sort().join("||");
1837
1896
  let canonical = this.structuralCache.get(structuralKey);
1838
1897
  if (!canonical) {
1839
1898
  canonical = canonicalClauses;
@@ -2823,7 +2882,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
2823
2882
  batch.changes.modified.add(this.cacheKey);
2824
2883
  }
2825
2884
  constructor(store, subject, cacheKey, opts) {
2826
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
2885
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
2827
2886
  msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
2828
2887
  }) : void 0);
2829
2888
  [this.#sourceApiName, this.#sourceTypeKind, this.#sourceUnderlyingObjectType, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
@@ -2837,7 +2896,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
2837
2896
  */
2838
2897
  async fetchPageData(signal) {
2839
2898
  const client = this.store.client;
2840
- const ontologyProvider = client[chunkBWOPPEUP_cjs.additionalContext].ontologyProvider;
2899
+ const ontologyProvider = client[chunkSV4AIIV4_cjs.additionalContext].ontologyProvider;
2841
2900
  const isInterface = this.#sourceTypeKind === "interface";
2842
2901
  if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {
2843
2902
  let targetTypeApiName;
@@ -2948,7 +3007,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
2948
3007
  }
2949
3008
  return (async () => {
2950
3009
  try {
2951
- const ontologyProvider = this.store.client[chunkBWOPPEUP_cjs.additionalContext].ontologyProvider;
3010
+ const ontologyProvider = this.store.client[chunkSV4AIIV4_cjs.additionalContext].ontologyProvider;
2952
3011
  if (this.#sourceTypeKind === "interface") {
2953
3012
  const objectMetadata = await ontologyProvider.getObjectDefinition(objectType);
2954
3013
  if (this.#sourceApiName in objectMetadata.interfaceMap) {
@@ -3110,7 +3169,6 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
3110
3169
  var ListQuery = class extends BaseListQuery {
3111
3170
  // pageSize?: number; // this is the internal page size. we need to track this properly
3112
3171
  #whereClause;
3113
- // Using base class minResultsToLoad instead of a private property
3114
3172
  #orderBy;
3115
3173
  #select;
3116
3174
  #intersectWith;
@@ -3124,7 +3182,7 @@ var ListQuery = class extends BaseListQuery {
3124
3182
  batch.changes.registerList(this.cacheKey);
3125
3183
  }
3126
3184
  constructor(store, subject, apiName, cacheKey, opts) {
3127
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
3185
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
3128
3186
  msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
3129
3187
  }) : void 0);
3130
3188
  this.apiName = apiName;
@@ -3137,13 +3195,6 @@ var ListQuery = class extends BaseListQuery {
3137
3195
  if (!this.#pivotInfo) {
3138
3196
  this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
3139
3197
  }
3140
- if (opts.autoFetchMore === true) {
3141
- this.minResultsToLoad = Number.MAX_SAFE_INTEGER;
3142
- } else if (typeof opts.autoFetchMore === "number") {
3143
- this.minResultsToLoad = Math.max(0, opts.autoFetchMore);
3144
- } else {
3145
- this.minResultsToLoad = 0;
3146
- }
3147
3198
  }
3148
3199
  get canonicalWhere() {
3149
3200
  return this.#whereClause;
@@ -3167,10 +3218,10 @@ var ListQuery = class extends BaseListQuery {
3167
3218
  async fetchPageData(signal) {
3168
3219
  const needsResultType = Object.keys(this.#orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy) || this.#pivotInfo != null && this.#intersectWith != null && this.#intersectWith.length > 0 && !this.#pivotIntersectApplied;
3169
3220
  if (needsResultType) {
3170
- const wireObjectSet = chunkBWOPPEUP_cjs.getWireObjectSet(this.#objectSet);
3221
+ const wireObjectSet = chunkSV4AIIV4_cjs.getWireObjectSet(this.#objectSet);
3171
3222
  const {
3172
3223
  resultType
3173
- } = await getObjectTypesThatInvalidate(this.store.client[chunkBWOPPEUP_cjs.additionalContext], wireObjectSet);
3224
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkSV4AIIV4_cjs.additionalContext], wireObjectSet);
3174
3225
  if (Object.keys(this.#orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy)) {
3175
3226
  this.sortingStrategy = new OrderBySortingStrategy(resultType.apiName, this.#orderBy);
3176
3227
  }
@@ -3445,7 +3496,7 @@ var InterfaceListQuery = class extends ListQuery {
3445
3496
  type,
3446
3497
  apiName: this.apiName
3447
3498
  };
3448
- const clientCtx = store.client[chunkBWOPPEUP_cjs.additionalContext];
3499
+ const clientCtx = store.client[chunkSV4AIIV4_cjs.additionalContext];
3449
3500
  let objectSet;
3450
3501
  if (rids != null) {
3451
3502
  objectSet = clientCtx.objectSetFactory(objectTypeDef, clientCtx, {
@@ -3488,7 +3539,7 @@ var InterfaceListQuery = class extends ListQuery {
3488
3539
  }
3489
3540
  extractRelevantObjects(changes) {
3490
3541
  const matchesApiName = ([, object]) => {
3491
- return this.apiName in object[chunkYKQ5QTEF_cjs.ObjectDefRef].interfaceMap;
3542
+ return this.apiName in object[chunk66XI45ES_cjs.ObjectDefRef].interfaceMap;
3492
3543
  };
3493
3544
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
3494
3545
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
@@ -3507,7 +3558,7 @@ var InterfaceListQuery = class extends ListQuery {
3507
3558
  }
3508
3559
  };
3509
3560
  function createSourceSetForPivot(store, pivotInfo, rids) {
3510
- const clientCtx = store.client[chunkBWOPPEUP_cjs.additionalContext];
3561
+ const clientCtx = store.client[chunkSV4AIIV4_cjs.additionalContext];
3511
3562
  if (rids != null) {
3512
3563
  return clientCtx.objectSetFactory({
3513
3564
  type: "object",
@@ -3562,7 +3613,7 @@ var ObjectListQuery = class extends ListQuery {
3562
3613
  const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX2];
3563
3614
  const pivotInfo = this.cacheKey.otherKeys[PIVOT_IDX];
3564
3615
  const rids = this.cacheKey.otherKeys[RIDS_IDX];
3565
- const clientCtx = store.client[chunkBWOPPEUP_cjs.additionalContext];
3616
+ const clientCtx = store.client[chunkSV4AIIV4_cjs.additionalContext];
3566
3617
  const typeDefinition = {
3567
3618
  type: "object",
3568
3619
  apiName: this.apiName
@@ -3708,8 +3759,8 @@ function stripRdpFields(value, rdpFields) {
3708
3759
  if (rdpFields.size === 0) {
3709
3760
  return value;
3710
3761
  }
3711
- const underlying = value[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3712
- const objectDef = value[chunkYKQ5QTEF_cjs.ObjectDefRef];
3762
+ const underlying = value[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3763
+ const objectDef = value[chunk66XI45ES_cjs.ObjectDefRef];
3713
3764
  const newProps = {
3714
3765
  $apiName: underlying.$apiName,
3715
3766
  $objectType: underlying.$objectType,
@@ -3722,7 +3773,7 @@ function stripRdpFields(value, rdpFields) {
3722
3773
  newProps[key] = underlying[key];
3723
3774
  }
3724
3775
  }
3725
- return chunkYKQ5QTEF_cjs.createOsdkObject(value[chunkYKQ5QTEF_cjs.ClientRef], objectDef, newProps);
3776
+ return chunk66XI45ES_cjs.createOsdkObject(value[chunk66XI45ES_cjs.ClientRef], objectDef, newProps);
3726
3777
  }
3727
3778
  function isSuperset(superset, subset) {
3728
3779
  for (const field of subset) {
@@ -3733,8 +3784,8 @@ function isSuperset(superset, subset) {
3733
3784
  return true;
3734
3785
  }
3735
3786
  function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3736
- const underlying = value[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3737
- const objectDef = value[chunkYKQ5QTEF_cjs.ObjectDefRef];
3787
+ const underlying = value[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3788
+ const objectDef = value[chunk66XI45ES_cjs.ObjectDefRef];
3738
3789
  const newProps = {
3739
3790
  $apiName: underlying.$apiName,
3740
3791
  $objectType: underlying.$objectType,
@@ -3750,12 +3801,12 @@ function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3750
3801
  }
3751
3802
  }
3752
3803
  }
3753
- return chunkYKQ5QTEF_cjs.createOsdkObject(value[chunkYKQ5QTEF_cjs.ClientRef], objectDef, newProps);
3804
+ return chunk66XI45ES_cjs.createOsdkObject(value[chunk66XI45ES_cjs.ClientRef], objectDef, newProps);
3754
3805
  }
3755
3806
  function mergeSelectFields(sourceValue, selectFields, existingValue) {
3756
- const sourceUnderlying = sourceValue[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3757
- const existingUnderlying = existingValue[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3758
- const objectDef = sourceValue[chunkYKQ5QTEF_cjs.ObjectDefRef];
3807
+ const sourceUnderlying = sourceValue[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3808
+ const existingUnderlying = existingValue[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3809
+ const objectDef = sourceValue[chunk66XI45ES_cjs.ObjectDefRef];
3759
3810
  const newProps = {
3760
3811
  $apiName: sourceUnderlying.$apiName,
3761
3812
  $objectType: sourceUnderlying.$objectType,
@@ -3773,7 +3824,7 @@ function mergeSelectFields(sourceValue, selectFields, existingValue) {
3773
3824
  newProps[key] = sourceUnderlying[key];
3774
3825
  }
3775
3826
  }
3776
- return chunkYKQ5QTEF_cjs.createOsdkObject(sourceValue[chunkYKQ5QTEF_cjs.ClientRef], objectDef, newProps);
3827
+ return chunk66XI45ES_cjs.createOsdkObject(sourceValue[chunk66XI45ES_cjs.ClientRef], objectDef, newProps);
3777
3828
  }
3778
3829
  function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue) {
3779
3830
  if (targetRdpFields.size === 0) {
@@ -3785,8 +3836,8 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3785
3836
  }
3786
3837
  return filterToRdpFields(sourceValue, targetRdpFields, sourceRdpFields);
3787
3838
  }
3788
- const sourceUnderlying = sourceValue[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3789
- const objectDef = sourceValue[chunkYKQ5QTEF_cjs.ObjectDefRef];
3839
+ const sourceUnderlying = sourceValue[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3840
+ const objectDef = sourceValue[chunk66XI45ES_cjs.ObjectDefRef];
3790
3841
  const newProps = {
3791
3842
  $apiName: sourceUnderlying.$apiName,
3792
3843
  $objectType: sourceUnderlying.$objectType,
@@ -3800,7 +3851,7 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3800
3851
  }
3801
3852
  }
3802
3853
  if (targetCurrentValue) {
3803
- const targetUnderlying = targetCurrentValue[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
3854
+ const targetUnderlying = targetCurrentValue[chunk66XI45ES_cjs.UnderlyingOsdkObject];
3804
3855
  for (const field of targetRdpFields) {
3805
3856
  if (field in targetUnderlying) {
3806
3857
  if (!sourceRdpFields.has(field) || newProps[field] === void 0) {
@@ -3809,7 +3860,7 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3809
3860
  }
3810
3861
  }
3811
3862
  }
3812
- return chunkYKQ5QTEF_cjs.createOsdkObject(sourceValue[chunkYKQ5QTEF_cjs.ClientRef], objectDef, newProps);
3863
+ return chunk66XI45ES_cjs.createOsdkObject(sourceValue[chunk66XI45ES_cjs.ClientRef], objectDef, newProps);
3813
3864
  }
3814
3865
 
3815
3866
  // src/observable/internal/object/ObjectCacheKeyRegistry.ts
@@ -3964,7 +4015,7 @@ var BulkObjectLoader = class {
3964
4015
  #maxEntries;
3965
4016
  constructor(client, maxWait = 25, maxEntries = 100) {
3966
4017
  this.#client = client;
3967
- this.#logger = client[chunkBWOPPEUP_cjs.additionalContext].logger;
4018
+ this.#logger = client[chunkSV4AIIV4_cjs.additionalContext].logger;
3968
4019
  this.#maxWait = maxWait;
3969
4020
  this.#maxEntries = maxEntries;
3970
4021
  }
@@ -4114,7 +4165,7 @@ var ObjectQuery = class extends Query {
4114
4165
  #loadPropertySecurityMetadata;
4115
4166
  #implementingTypes;
4116
4167
  constructor(store, subject, type, pk, cacheKey, opts, defType = "object", select, loadPropertySecurityMetadata) {
4117
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
4168
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
4118
4169
  msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
4119
4170
  }) : void 0);
4120
4171
  this.#apiName = type;
@@ -4216,7 +4267,7 @@ var ObjectsHelper = class extends AbstractHelper {
4216
4267
  select,
4217
4268
  $loadPropertySecurityMetadata
4218
4269
  } = options;
4219
- const defType = chunkYKQ5QTEF_cjs.getDefType(options.apiName);
4270
+ const defType = chunk66XI45ES_cjs.getDefType(options.apiName);
4220
4271
  const objectCacheKey = this.cacheKeys.get("object", apiName, pk, rdpConfig ?? void 0);
4221
4272
  return this.store.queries.get(objectCacheKey, () => new ObjectQuery(this.store, this.store.subjects.get(objectCacheKey), apiName, pk, objectCacheKey, {
4222
4273
  dedupeInterval: 0
@@ -4254,7 +4305,7 @@ var ObjectsHelper = class extends AbstractHelper {
4254
4305
  if (valueToWrite !== tombstone && existing?.value && this.isObjectHolder(existing.value)) {
4255
4306
  const expectedRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(sourceCacheKey);
4256
4307
  if (expectedRdpFields.size > 0) {
4257
- const underlying = valueToWrite[chunkYKQ5QTEF_cjs.UnderlyingOsdkObject];
4308
+ const underlying = valueToWrite[chunk66XI45ES_cjs.UnderlyingOsdkObject];
4258
4309
  const actualRdpFields = /* @__PURE__ */ new Set();
4259
4310
  for (const field of expectedRdpFields) {
4260
4311
  if (underlying && field in underlying) {
@@ -4316,19 +4367,24 @@ var ObjectsHelper = class extends AbstractHelper {
4316
4367
  };
4317
4368
 
4318
4369
  // src/observable/internal/objectset/ObjectSetQuery.ts
4319
- var ObjectSetQuery = class extends BaseListQuery {
4370
+ var ObjectSetQuery = class _ObjectSetQuery extends BaseListQuery {
4320
4371
  #baseObjectSetWire;
4321
4372
  #operations;
4322
4373
  #composedObjectSet;
4323
4374
  #objectTypes;
4375
+ #requiresServerEvaluation;
4376
+ #resultTypeApiName;
4324
4377
  constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
4325
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
4378
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
4326
4379
  msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
4327
4380
  }) : void 0);
4328
4381
  this.#baseObjectSetWire = baseObjectSetWire;
4329
4382
  this.#operations = operations;
4330
4383
  this.#composedObjectSet = this.#composeObjectSet(opts);
4331
- this.#objectTypes = this.#extractObjectTypes(opts);
4384
+ const baseWire = JSON.parse(baseObjectSetWire);
4385
+ this.#objectTypes = this.#extractObjectTypes(baseWire, opts);
4386
+ this.#requiresServerEvaluation = !!(operations.pivotTo || operations.union && operations.union.length > 0 || operations.intersect && operations.intersect.length > 0 || operations.subtract && operations.subtract.length > 0);
4387
+ this.#resultTypeApiName = _ObjectSetQuery.#extractTypeFromWireObjectSet(baseWire) ?? "";
4332
4388
  if (opts.autoFetchMore === true) {
4333
4389
  this.minResultsToLoad = Number.MAX_SAFE_INTEGER;
4334
4390
  } else if (typeof opts.autoFetchMore === "number") {
@@ -4337,6 +4393,9 @@ var ObjectSetQuery = class extends BaseListQuery {
4337
4393
  this.minResultsToLoad = opts.pageSize || 0;
4338
4394
  }
4339
4395
  }
4396
+ get objectTypes() {
4397
+ return this.#objectTypes;
4398
+ }
4340
4399
  get rdpConfig() {
4341
4400
  return this.#operations.withProperties ?? null;
4342
4401
  }
@@ -4368,37 +4427,36 @@ var ObjectSetQuery = class extends BaseListQuery {
4368
4427
  }
4369
4428
  return result;
4370
4429
  }
4371
- #extractObjectTypes(opts) {
4430
+ #extractObjectTypes(baseWire, opts) {
4372
4431
  const types = /* @__PURE__ */ new Set();
4373
- const baseWire = JSON.parse(this.#baseObjectSetWire);
4374
- if (baseWire.type) {
4375
- types.add(baseWire.type);
4376
- }
4377
- if (opts.union) {
4378
- for (const os of opts.union) {
4379
- const wire = chunkBWOPPEUP_cjs.getWireObjectSet(os);
4380
- if (wire.type) {
4381
- types.add(wire.type);
4382
- }
4383
- }
4432
+ const baseTypeName = _ObjectSetQuery.#extractTypeFromWireObjectSet(baseWire);
4433
+ if (baseTypeName) {
4434
+ types.add(baseTypeName);
4384
4435
  }
4385
- if (opts.intersect) {
4386
- for (const os of opts.intersect) {
4387
- const wire = chunkBWOPPEUP_cjs.getWireObjectSet(os);
4388
- if (wire.type) {
4389
- types.add(wire.type);
4390
- }
4391
- }
4436
+ _ObjectSetQuery.#addTypesFromObjectSets(opts.union, types);
4437
+ _ObjectSetQuery.#addTypesFromObjectSets(opts.intersect, types);
4438
+ _ObjectSetQuery.#addTypesFromObjectSets(opts.subtract, types);
4439
+ return types;
4440
+ }
4441
+ static #addTypesFromObjectSets(sets, types) {
4442
+ if (!sets) {
4443
+ return;
4392
4444
  }
4393
- if (opts.subtract) {
4394
- for (const os of opts.subtract) {
4395
- const wire = chunkBWOPPEUP_cjs.getWireObjectSet(os);
4396
- if (wire.type) {
4397
- types.add(wire.type);
4398
- }
4445
+ for (const os of sets) {
4446
+ const typeName = _ObjectSetQuery.#extractTypeFromWireObjectSet(chunkSV4AIIV4_cjs.getWireObjectSet(os));
4447
+ if (typeName) {
4448
+ types.add(typeName);
4399
4449
  }
4400
4450
  }
4401
- return types;
4451
+ }
4452
+ static #extractTypeFromWireObjectSet(wire) {
4453
+ if (wire.type === "base") {
4454
+ return wire.objectType;
4455
+ }
4456
+ if (wire.type === "interfaceBase") {
4457
+ return wire.interfaceType;
4458
+ }
4459
+ return void 0;
4402
4460
  }
4403
4461
  /**
4404
4462
  * Register changes to the cache specific to ObjectSetQuery
@@ -4412,10 +4470,10 @@ var ObjectSetQuery = class extends BaseListQuery {
4412
4470
  */
4413
4471
  async fetchPageData(signal) {
4414
4472
  if (this.#operations.orderBy && Object.keys(this.#operations.orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy)) {
4415
- const wireObjectSet = chunkBWOPPEUP_cjs.getWireObjectSet(this.#composedObjectSet);
4473
+ const wireObjectSet = chunkSV4AIIV4_cjs.getWireObjectSet(this.#composedObjectSet);
4416
4474
  const {
4417
4475
  resultType
4418
- } = await getObjectTypesThatInvalidate(this.store.client[chunkBWOPPEUP_cjs.additionalContext], wireObjectSet);
4476
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkSV4AIIV4_cjs.additionalContext], wireObjectSet);
4419
4477
  this.sortingStrategy = new OrderBySortingStrategy(resultType.apiName, this.#operations.orderBy);
4420
4478
  }
4421
4479
  const resp = await this.#composedObjectSet.fetchPage({
@@ -4451,6 +4509,119 @@ var ObjectSetQuery = class extends BaseListQuery {
4451
4509
  registerStreamUpdates(sub) {
4452
4510
  this.createWebsocketSubscription(this.#composedObjectSet, sub, "observeObjectSet");
4453
4511
  }
4512
+ maybeUpdateAndRevalidate = (changes, optimisticId) => {
4513
+ if (process.env.NODE_ENV !== "production") {
4514
+ this.logger?.child({
4515
+ methodName: "maybeUpdateAndRevalidate"
4516
+ }).debug(DEBUG_ONLY__changesToString(changes));
4517
+ this.logger?.child({
4518
+ methodName: "maybeUpdateAndRevalidate"
4519
+ }).debug(`Already in changes? ${changes.modified.has(this.cacheKey)}`);
4520
+ }
4521
+ if (changes.modified.has(this.cacheKey)) {
4522
+ return;
4523
+ }
4524
+ changes.modified.add(this.cacheKey);
4525
+ try {
4526
+ if (this.#requiresServerEvaluation) {
4527
+ return this.#handleServerRevalidation(changes);
4528
+ }
4529
+ return this.#handleLocalUpdate(changes, optimisticId);
4530
+ } finally {
4531
+ if (process.env.NODE_ENV !== "production") {
4532
+ this.logger?.child({
4533
+ methodName: "maybeUpdateAndRevalidate"
4534
+ }).debug("in finally");
4535
+ }
4536
+ }
4537
+ };
4538
+ #handleServerRevalidation(changes) {
4539
+ for (const objectType of this.#objectTypes) {
4540
+ const added = changes.addedObjects.get(objectType);
4541
+ const modified = changes.modifiedObjects.get(objectType);
4542
+ if (added && added.length > 0 || modified && modified.length > 0) {
4543
+ return this.revalidate(true);
4544
+ }
4545
+ }
4546
+ for (const deletedKey of changes.deleted) {
4547
+ if (deletedKey.type === "object" && this.#objectTypes.has(deletedKey.otherKeys[API_NAME_IDX3])) {
4548
+ return this.revalidate(true);
4549
+ }
4550
+ }
4551
+ return void 0;
4552
+ }
4553
+ #getRelevantChanges(changes) {
4554
+ const resultApiName = this.#resultTypeApiName;
4555
+ const addedObjects = changes.addedObjects.get(resultApiName) ?? [];
4556
+ const modifiedObjects = changes.modifiedObjects.get(resultApiName) ?? [];
4557
+ let hasRelevantDeletions = false;
4558
+ for (const key of changes.deleted) {
4559
+ if (key.type === "object" && key.otherKeys[API_NAME_IDX3] === resultApiName) {
4560
+ hasRelevantDeletions = true;
4561
+ break;
4562
+ }
4563
+ }
4564
+ if (addedObjects.length === 0 && modifiedObjects.length === 0 && !hasRelevantDeletions) {
4565
+ return void 0;
4566
+ }
4567
+ return {
4568
+ addedObjects,
4569
+ modifiedObjects
4570
+ };
4571
+ }
4572
+ #handleLocalUpdate(changes, optimisticId) {
4573
+ const whereClause = this.#operations.where;
4574
+ const effectiveWhere = whereClause ?? this.store.whereCanonicalizer.canonicalize({
4575
+ $and: []
4576
+ });
4577
+ const relevant = this.#getRelevantChanges(changes);
4578
+ if (!relevant) {
4579
+ return void 0;
4580
+ }
4581
+ const addedMatches = this.#classifyByWhereMatch(relevant.addedObjects, effectiveWhere);
4582
+ const modifiedMatches = this.#classifyByWhereMatch(relevant.modifiedObjects, effectiveWhere);
4583
+ const status = optimisticId || addedMatches.uncertain.size > 0 || modifiedMatches.uncertain.size > 0 ? "loading" : "loaded";
4584
+ const {
4585
+ retVal: needsRevalidation
4586
+ } = this.store.batch({
4587
+ optimisticId,
4588
+ changes
4589
+ }, (batch) => {
4590
+ const existingKeys = new Set(batch.read(this.cacheKey)?.value?.data);
4591
+ const {
4592
+ newList,
4593
+ needsRevalidation: needsRevalidation2
4594
+ } = reconcileListChanges(existingKeys, addedMatches.definite, relevant.modifiedObjects, modifiedMatches, changes.deleted, batch.optimisticWrite, (obj) => this.#getObjectCacheKey(obj));
4595
+ const existingTotalCount = batch.read(this.cacheKey)?.value?.totalCount;
4596
+ this._updateList(newList, status, batch, {
4597
+ type: "clientOrdered"
4598
+ }, existingTotalCount);
4599
+ return needsRevalidation2;
4600
+ });
4601
+ if (needsRevalidation) {
4602
+ return this.revalidate(true);
4603
+ }
4604
+ return void 0;
4605
+ }
4606
+ #classifyByWhereMatch(objects, whereClause) {
4607
+ const definite = /* @__PURE__ */ new Set();
4608
+ const uncertain = /* @__PURE__ */ new Set();
4609
+ for (const obj of objects) {
4610
+ if (objectSortaMatchesWhereClause(obj, whereClause, true)) {
4611
+ definite.add(obj);
4612
+ } else if (objectSortaMatchesWhereClause(obj, whereClause, false)) {
4613
+ uncertain.add(obj);
4614
+ }
4615
+ }
4616
+ return {
4617
+ definite,
4618
+ uncertain
4619
+ };
4620
+ }
4621
+ #getObjectCacheKey(obj) {
4622
+ const pk = obj.$primaryKey;
4623
+ return this.cacheKeys.get("object", obj.$objectType, pk, this.rdpConfig ?? void 0);
4624
+ }
4454
4625
  invalidateObjectType = async (objectType, changes) => {
4455
4626
  if (this.#objectTypes.has(objectType)) {
4456
4627
  changes?.modified.add(this.cacheKey);
@@ -4471,15 +4642,46 @@ var ObjectSetQuery = class extends BaseListQuery {
4471
4642
  };
4472
4643
  }
4473
4644
  };
4645
+ function reconcileListChanges(existingKeys, addedDefiniteMatches, modifiedObjects, modifiedMatches, deleted, isOptimistic, getObjectCacheKey) {
4646
+ const objectsToInsert = new Set(addedDefiniteMatches);
4647
+ const keysToRemove = new Set(deleted);
4648
+ let needsRevalidation = false;
4649
+ for (const obj of modifiedObjects) {
4650
+ if (modifiedMatches.definite.has(obj)) {
4651
+ if (!existingKeys.has(getObjectCacheKey(obj))) {
4652
+ objectsToInsert.add(obj);
4653
+ }
4654
+ } else if (!isOptimistic) {
4655
+ keysToRemove.add(getObjectCacheKey(obj));
4656
+ if (modifiedMatches.uncertain.has(obj)) {
4657
+ needsRevalidation = true;
4658
+ }
4659
+ }
4660
+ }
4661
+ const newList = [];
4662
+ for (const key of existingKeys) {
4663
+ if (!keysToRemove.has(key)) {
4664
+ newList.push(key);
4665
+ }
4666
+ }
4667
+ for (const obj of objectsToInsert) {
4668
+ newList.push(getObjectCacheKey(obj));
4669
+ }
4670
+ return {
4671
+ newList,
4672
+ needsRevalidation
4673
+ };
4674
+ }
4474
4675
 
4475
4676
  // src/observable/internal/objectset/ObjectSetHelper.ts
4476
4677
  var ObjectSetHelper = class extends AbstractHelper {
4477
- constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer, selectCanonicalizer) {
4678
+ constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer, selectCanonicalizer, objectSetArrayCanonicalizer) {
4478
4679
  super(store, cacheKeys);
4479
4680
  this.whereCanonicalizer = whereCanonicalizer2;
4480
4681
  this.orderByCanonicalizer = orderByCanonicalizer2;
4481
4682
  this.rdpCanonicalizer = rdpCanonicalizer;
4482
4683
  this.selectCanonicalizer = selectCanonicalizer;
4684
+ this.objectSetArrayCanonicalizer = objectSetArrayCanonicalizer;
4483
4685
  }
4484
4686
  observe(options, subFn) {
4485
4687
  const ret = super.observe(options, subFn);
@@ -4492,7 +4694,7 @@ var ObjectSetHelper = class extends AbstractHelper {
4492
4694
  const {
4493
4695
  baseObjectSet
4494
4696
  } = options;
4495
- const baseObjectSetWire = JSON.stringify(chunkBWOPPEUP_cjs.getWireObjectSet(baseObjectSet));
4697
+ const baseObjectSetWire = JSON.stringify(chunkSV4AIIV4_cjs.getWireObjectSet(baseObjectSet));
4496
4698
  const operations = this.buildCanonicalizedOperations(options);
4497
4699
  const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
4498
4700
  return this.store.queries.get(objectSetCacheKey, () => {
@@ -4508,13 +4710,13 @@ var ObjectSetHelper = class extends AbstractHelper {
4508
4710
  operations.withProperties = this.rdpCanonicalizer.canonicalize(options.withProperties);
4509
4711
  }
4510
4712
  if (options.union && options.union.length > 0) {
4511
- operations.union = options.union.map((os) => JSON.stringify(chunkBWOPPEUP_cjs.getWireObjectSet(os)));
4713
+ operations.union = this.objectSetArrayCanonicalizer.canonicalizeUnion(options.union.map((os) => JSON.stringify(chunkSV4AIIV4_cjs.getWireObjectSet(os))));
4512
4714
  }
4513
4715
  if (options.intersect && options.intersect.length > 0) {
4514
- operations.intersect = options.intersect.map((os) => JSON.stringify(chunkBWOPPEUP_cjs.getWireObjectSet(os)));
4716
+ operations.intersect = this.objectSetArrayCanonicalizer.canonicalizeIntersect(options.intersect.map((os) => JSON.stringify(chunkSV4AIIV4_cjs.getWireObjectSet(os))));
4515
4717
  }
4516
4718
  if (options.subtract && options.subtract.length > 0) {
4517
- operations.subtract = options.subtract.map((os) => JSON.stringify(chunkBWOPPEUP_cjs.getWireObjectSet(os)));
4719
+ operations.subtract = this.objectSetArrayCanonicalizer.canonicalizeSubtract(options.subtract.map((os) => JSON.stringify(chunkSV4AIIV4_cjs.getWireObjectSet(os))));
4518
4720
  }
4519
4721
  if (options.pivotTo) {
4520
4722
  operations.pivotTo = options.pivotTo;
@@ -4535,6 +4737,24 @@ var ObjectSetHelper = class extends AbstractHelper {
4535
4737
  }
4536
4738
  };
4537
4739
 
4740
+ // src/observable/internal/ObjectSetArrayCanonicalizer.ts
4741
+ var ObjectSetArrayCanonicalizer = class {
4742
+ #unionTrie = new WeakRefTrie();
4743
+ #intersectTrie = new WeakRefTrie();
4744
+ #subtractTrie = new WeakRefTrie();
4745
+ canonicalizeUnion(items) {
4746
+ const sorted = [...items].sort();
4747
+ return this.#unionTrie.lookupArray(sorted);
4748
+ }
4749
+ canonicalizeIntersect(items) {
4750
+ const sorted = [...items].sort();
4751
+ return this.#intersectTrie.lookupArray(sorted);
4752
+ }
4753
+ canonicalizeSubtract(items) {
4754
+ return this.#subtractTrie.lookupArray(items);
4755
+ }
4756
+ };
4757
+
4538
4758
  // src/observable/internal/PivotCanonicalizer.ts
4539
4759
  var PivotCanonicalizer = class {
4540
4760
  #cache = /* @__PURE__ */ new Map();
@@ -4589,7 +4809,7 @@ var RdpCanonicalizer = class extends CachingCanonicalizer {
4589
4809
  apiName: "__rdp_canonicalizer_holder__"
4590
4810
  };
4591
4811
  for (const [key, rdpFunction] of Object.entries(rdp)) {
4592
- const builder = chunkBWOPPEUP_cjs.createWithPropertiesObjectSet(
4812
+ const builder = chunkSV4AIIV4_cjs.createWithPropertiesObjectSet(
4593
4813
  objectTypeHolder,
4594
4814
  {
4595
4815
  type: "methodInput"
@@ -4662,6 +4882,8 @@ var Store = class {
4662
4882
  pivotCanonicalizer = new PivotCanonicalizer();
4663
4883
  ridListCanonicalizer = new RidListCanonicalizer();
4664
4884
  selectCanonicalizer = new SelectCanonicalizer();
4885
+ objectSetArrayCanonicalizer = new ObjectSetArrayCanonicalizer();
4886
+ genericCanonicalizer = new GenericCanonicalizer();
4665
4887
  /** @internal */
4666
4888
  queries = new Queries();
4667
4889
  /**
@@ -4683,7 +4905,7 @@ var Store = class {
4683
4905
  subjects = this.layers.subjects;
4684
4906
  // these are hopefully temporary
4685
4907
  constructor(client) {
4686
- this.logger = client[chunkBWOPPEUP_cjs.additionalContext].logger?.child({}, {
4908
+ this.logger = client[chunkSV4AIIV4_cjs.additionalContext].logger?.child({}, {
4687
4909
  msgPrefix: "Store"
4688
4910
  });
4689
4911
  this.client = client;
@@ -4695,7 +4917,7 @@ var Store = class {
4695
4917
  this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer, this.pivotCanonicalizer, this.ridListCanonicalizer, this.selectCanonicalizer);
4696
4918
  this.objects = new ObjectsHelper(this, this.cacheKeys);
4697
4919
  this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.selectCanonicalizer);
4698
- this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.selectCanonicalizer);
4920
+ this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.selectCanonicalizer, this.objectSetArrayCanonicalizer);
4699
4921
  }
4700
4922
  /**
4701
4923
  * Called after a key is no longer retained and the timeout has elapsed
@@ -4827,6 +5049,17 @@ var Store = class {
4827
5049
  * @returns true if the query should be notified based on object type changes
4828
5050
  */
4829
5051
  #shouldPropagateForObjectTypeChanges(cacheKey, changes) {
5052
+ if (cacheKey.type === "objectSet") {
5053
+ const query = this.queries.peek(cacheKey);
5054
+ if (query) {
5055
+ for (const objectType of query.objectTypes) {
5056
+ if (this.#changesAffectObjectType(changes, objectType)) {
5057
+ return true;
5058
+ }
5059
+ }
5060
+ }
5061
+ return false;
5062
+ }
4830
5063
  const queryObjectType = this.#getQueryObjectType(cacheKey);
4831
5064
  if (!queryObjectType) {
4832
5065
  return false;
@@ -4862,6 +5095,8 @@ var Store = class {
4862
5095
  if (query) {
4863
5096
  return query.rdpConfig;
4864
5097
  }
5098
+ } else if (cacheKey.type === "mediaMetadata") {
5099
+ return void 0;
4865
5100
  }
4866
5101
  }
4867
5102
  return void 0;
@@ -4880,6 +5115,8 @@ var Store = class {
4880
5115
  return cacheKey.otherKeys[API_NAME_IDX2];
4881
5116
  } else if (cacheKey.type === "aggregation") {
4882
5117
  return cacheKey.otherKeys[API_NAME_IDX];
5118
+ } else if (cacheKey.type === "mediaMetadata") {
5119
+ return cacheKey.otherKeys[0];
4883
5120
  }
4884
5121
  }
4885
5122
  return void 0;
@@ -4900,6 +5137,11 @@ var Store = class {
4900
5137
  if (modifiedForType && modifiedForType.length > 0) {
4901
5138
  return true;
4902
5139
  }
5140
+ for (const deletedKey of changes.deleted) {
5141
+ if (deletedKey.type === "object" && deletedKey.otherKeys[API_NAME_IDX3] === objectType) {
5142
+ return true;
5143
+ }
5144
+ }
4903
5145
  return false;
4904
5146
  }
4905
5147
  /**
@@ -4924,7 +5166,7 @@ var Store = class {
4924
5166
  }
4925
5167
  const promises = [];
4926
5168
  for (const cacheKey of this.layers.truth.keys()) {
4927
- if (changes && changes.modified.has(cacheKey)) {
5169
+ if (cacheKey.type !== "mediaMetadata" && changes && changes.modified.has(cacheKey)) {
4928
5170
  continue;
4929
5171
  }
4930
5172
  const query = this.queries.peek(cacheKey);
@@ -4961,10 +5203,10 @@ var Store = class {
4961
5203
 
4962
5204
  // src/observable/ObservableClient.ts
4963
5205
  function createObservableClient(client) {
4964
- const tweakedClient = chunkYKQ5QTEF_cjs.createClientFromContext({
4965
- ...client[chunkBWOPPEUP_cjs.additionalContext],
4966
- fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkBWOPPEUP_cjs.additionalContext].fetch, (headers) => {
4967
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkYKQ5QTEF_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
5206
+ const tweakedClient = chunk66XI45ES_cjs.createClientFromContext({
5207
+ ...client[chunkSV4AIIV4_cjs.additionalContext],
5208
+ fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkSV4AIIV4_cjs.additionalContext].fetch, (headers) => {
5209
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk66XI45ES_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
4968
5210
  return headers;
4969
5211
  })
4970
5212
  });
@@ -5007,19 +5249,19 @@ function getOsdkConfig(ontologyRid) {
5007
5249
 
5008
5250
  Object.defineProperty(exports, "createClientWithTransaction", {
5009
5251
  enumerable: true,
5010
- get: function () { return chunkYKQ5QTEF_cjs.createClientWithTransaction; }
5252
+ get: function () { return chunk66XI45ES_cjs.createClientWithTransaction; }
5011
5253
  });
5012
5254
  Object.defineProperty(exports, "augment", {
5013
5255
  enumerable: true,
5014
- get: function () { return chunkBWOPPEUP_cjs.augment; }
5256
+ get: function () { return chunkSV4AIIV4_cjs.augment; }
5015
5257
  });
5016
5258
  Object.defineProperty(exports, "getWireObjectSet", {
5017
5259
  enumerable: true,
5018
- get: function () { return chunkBWOPPEUP_cjs.getWireObjectSet; }
5260
+ get: function () { return chunkSV4AIIV4_cjs.getWireObjectSet; }
5019
5261
  });
5020
5262
  Object.defineProperty(exports, "isObjectSet", {
5021
5263
  enumerable: true,
5022
- get: function () { return chunkBWOPPEUP_cjs.isObjectSet; }
5264
+ get: function () { return chunkSV4AIIV4_cjs.isObjectSet; }
5023
5265
  });
5024
5266
  exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
5025
5267
  exports.createObservableClient = createObservableClient;