@osdk/client 2.6.0-beta.7 → 2.6.0-beta.9
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.
- package/CHANGELOG.md +24 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +13 -15
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +62 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/mediaUpload.js +1 -1
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/IntersectCanonicalizer.js +35 -0
- package/build/browser/observable/internal/IntersectCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +3 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/PivotCanonicalizer.js +33 -0
- package/build/browser/observable/internal/PivotCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/Store.js +14 -2
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/aggregation/AggregationCacheKey.js +22 -0
- package/build/browser/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
- package/build/browser/observable/internal/aggregation/AggregationQuery.js +77 -0
- package/build/browser/observable/internal/aggregation/AggregationQuery.js.map +1 -0
- package/build/browser/observable/internal/aggregation/AggregationsHelper.js +54 -0
- package/build/browser/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
- package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
- package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
- package/build/browser/observable/internal/links/LinksHelper.js +0 -3
- package/build/browser/observable/internal/links/LinksHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ListCacheKey.js +2 -0
- package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +12 -2
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListQueryOptions.js.map +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js +9 -3
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js +48 -9
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/browser/observable/internal/testUtils/invalidateList.js +6 -1
- package/build/browser/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/public/internal-node.js +18 -0
- package/build/browser/public/internal-node.js.map +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/toDataValue.js +3 -2
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +1 -1
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/chunk-6SCDLAU2.cjs +57 -0
- package/build/cjs/chunk-6SCDLAU2.cjs.map +1 -0
- package/build/cjs/{chunk-3LMKH6RS.cjs → chunk-DZE6IAUU.cjs} +145 -47
- package/build/cjs/chunk-DZE6IAUU.cjs.map +1 -0
- package/build/cjs/{chunk-4ZOXOCQX.cjs → chunk-S4JPAF56.cjs} +225 -67
- package/build/cjs/chunk-S4JPAF56.cjs.map +1 -0
- package/build/cjs/{delay-QK4T7RVX.cjs → delay-KIUUJ5NJ.cjs} +4 -3
- package/build/cjs/delay-KIUUJ5NJ.cjs.map +1 -0
- package/build/cjs/index.cjs +17 -9
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/internal-node.cjs +193767 -0
- package/build/cjs/public/internal-node.cjs.map +1 -0
- package/build/cjs/public/internal-node.d.cts +29 -0
- package/build/cjs/public/internal.cjs +16 -9
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +1050 -706
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +36 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +13 -15
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +62 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/mediaUpload.js +1 -1
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/IntersectCanonicalizer.js +35 -0
- package/build/esm/observable/internal/IntersectCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +3 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/PivotCanonicalizer.js +33 -0
- package/build/esm/observable/internal/PivotCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/Store.js +14 -2
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/aggregation/AggregationCacheKey.js +22 -0
- package/build/esm/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
- package/build/esm/observable/internal/aggregation/AggregationQuery.js +77 -0
- package/build/esm/observable/internal/aggregation/AggregationQuery.js.map +1 -0
- package/build/esm/observable/internal/aggregation/AggregationsHelper.js +54 -0
- package/build/esm/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
- package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
- package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
- package/build/esm/observable/internal/links/LinksHelper.js +0 -3
- package/build/esm/observable/internal/links/LinksHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ListCacheKey.js +2 -0
- package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +12 -2
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListQueryOptions.js.map +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js +9 -3
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js +48 -9
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/esm/observable/internal/testUtils/invalidateList.js +6 -1
- package/build/esm/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/public/internal-node.js +18 -0
- package/build/esm/public/internal-node.js.map +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/toDataValue.js +3 -2
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +1 -1
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +46 -1
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +4 -3
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/IntersectCanonicalizer.d.ts +18 -0
- package/build/types/observable/internal/IntersectCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/PivotCanonicalizer.d.ts +10 -0
- package/build/types/observable/internal/PivotCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/Store.d.ts +6 -0
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts +12 -0
- package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/AggregationQuery.d.ts +49 -0
- package/build/types/observable/internal/aggregation/AggregationQuery.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts +37 -0
- package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts.map +1 -0
- package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts +5 -0
- package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts.map +1 -0
- package/build/types/observable/internal/links/LinksHelper.d.ts +0 -4
- package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts +4 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts +4 -1
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQueryOptions.d.ts +9 -1
- package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts +5 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/public/internal-node.d.ts +2 -0
- package/build/types/public/internal-node.d.ts.map +1 -0
- package/build/types/public/unstable-do-not-use.d.ts +1 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/internal-node.d.ts +17 -0
- package/package.json +21 -11
- package/build/cjs/chunk-3LMKH6RS.cjs.map +0 -1
- package/build/cjs/chunk-4ZOXOCQX.cjs.map +0 -1
- package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
- package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
- package/build/cjs/delay-QK4T7RVX.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkS4JPAF56_cjs = require('../chunk-S4JPAF56.cjs');
|
|
4
|
+
var chunkDZE6IAUU_cjs = require('../chunk-DZE6IAUU.cjs');
|
|
5
|
+
var chunk6SCDLAU2_cjs = require('../chunk-6SCDLAU2.cjs');
|
|
6
6
|
var trie = require('@wry/trie');
|
|
7
7
|
var deepEqual = require('fast-deep-equal');
|
|
8
8
|
var invariant4 = require('tiny-invariant');
|
|
@@ -18,6 +18,17 @@ var deepEqual__default = /*#__PURE__*/_interopDefault(deepEqual);
|
|
|
18
18
|
var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
|
|
19
19
|
var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
|
|
20
20
|
|
|
21
|
+
// src/public/unstable-do-not-use.ts
|
|
22
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
23
|
+
|
|
24
|
+
// src/observable/computeObjectSetCacheKey.ts
|
|
25
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
26
|
+
|
|
27
|
+
// src/observable/internal/OrderByCanonicalizer.ts
|
|
28
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
29
|
+
|
|
30
|
+
// src/observable/internal/WeakRefTrie.ts
|
|
31
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
21
32
|
var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
|
|
22
33
|
var WeakRefTrie = class {
|
|
23
34
|
#finalizer = new FinalizationRegistry((orderBy) => {
|
|
@@ -70,6 +81,9 @@ var OrderByCanonicalizer = class {
|
|
|
70
81
|
return this.#trie.lookupArray(strings);
|
|
71
82
|
};
|
|
72
83
|
};
|
|
84
|
+
|
|
85
|
+
// src/observable/internal/WhereClauseCanonicalizer.ts
|
|
86
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
73
87
|
var WhereClauseCanonicalizer = class {
|
|
74
88
|
/**
|
|
75
89
|
* This is a shortcut cache for any WhereClause's that we have
|
|
@@ -139,7 +153,7 @@ var WhereClauseCanonicalizer = class {
|
|
|
139
153
|
var whereCanonicalizer = new WhereClauseCanonicalizer();
|
|
140
154
|
var orderByCanonicalizer = new OrderByCanonicalizer();
|
|
141
155
|
function computeObjectSetCacheKey(objectSet, options) {
|
|
142
|
-
const keyParts = ["objectSet",
|
|
156
|
+
const keyParts = ["objectSet", chunkDZE6IAUU_cjs.getWireObjectSet(objectSet)];
|
|
143
157
|
if (!options) {
|
|
144
158
|
return JSON.stringify(keyParts);
|
|
145
159
|
}
|
|
@@ -151,13 +165,13 @@ function computeObjectSetCacheKey(objectSet, options) {
|
|
|
151
165
|
keyParts.push("props", propKeys);
|
|
152
166
|
}
|
|
153
167
|
if (options.union && options.union.length > 0) {
|
|
154
|
-
keyParts.push("union", options.union.map((os) =>
|
|
168
|
+
keyParts.push("union", options.union.map((os) => chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
155
169
|
}
|
|
156
170
|
if (options.intersect && options.intersect.length > 0) {
|
|
157
|
-
keyParts.push("intersect", options.intersect.map((os) =>
|
|
171
|
+
keyParts.push("intersect", options.intersect.map((os) => chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
158
172
|
}
|
|
159
173
|
if (options.subtract && options.subtract.length > 0) {
|
|
160
|
-
keyParts.push("subtract", options.subtract.map((os) =>
|
|
174
|
+
keyParts.push("subtract", options.subtract.map((os) => chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
161
175
|
}
|
|
162
176
|
if (options.pivotTo) {
|
|
163
177
|
keyParts.push("pivotTo", options.pivotTo);
|
|
@@ -171,7 +185,14 @@ function computeObjectSetCacheKey(objectSet, options) {
|
|
|
171
185
|
return JSON.stringify(keyParts);
|
|
172
186
|
}
|
|
173
187
|
|
|
188
|
+
// src/observable/ObservableClient.ts
|
|
189
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
190
|
+
|
|
191
|
+
// src/observable/internal/ObservableClientImpl.ts
|
|
192
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
193
|
+
|
|
174
194
|
// src/observable/internal/UnsubscribableWrapper.ts
|
|
195
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
175
196
|
var UnsubscribableWrapper = class {
|
|
176
197
|
#subscription;
|
|
177
198
|
constructor(subscription) {
|
|
@@ -207,6 +228,9 @@ var ObservableClientImpl = class {
|
|
|
207
228
|
subFn
|
|
208
229
|
);
|
|
209
230
|
};
|
|
231
|
+
observeAggregation = (options, subFn) => {
|
|
232
|
+
return this.__experimentalStore.aggregations.observe(options, subFn);
|
|
233
|
+
};
|
|
210
234
|
observeLinks = (objects, linkName, options, subFn) => {
|
|
211
235
|
const objectsArray = Array.isArray(objects) ? objects : [objects];
|
|
212
236
|
const parentSub = new rxjs.Subscription();
|
|
@@ -252,11 +276,22 @@ var ObservableClientImpl = class {
|
|
|
252
276
|
}
|
|
253
277
|
};
|
|
254
278
|
|
|
279
|
+
// src/observable/internal/Store.ts
|
|
280
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
281
|
+
|
|
255
282
|
// src/observable/DebugFlags.ts
|
|
283
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
256
284
|
process.env.NODE_ENV !== "production" && false;
|
|
257
285
|
var DEBUG_CACHE_KEYS = process.env.NODE_ENV !== "production" && false;
|
|
258
286
|
|
|
287
|
+
// src/observable/internal/actions/ActionApplication.ts
|
|
288
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
289
|
+
|
|
290
|
+
// src/observable/internal/actions/OptimisticJob.ts
|
|
291
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
292
|
+
|
|
259
293
|
// src/observable/internal/OptimisticId.ts
|
|
294
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
260
295
|
function createOptimisticId() {
|
|
261
296
|
if (process.env.NODE_ENV !== "production") {
|
|
262
297
|
if (createOptimisticId.counter === void 0) {
|
|
@@ -316,7 +351,7 @@ var OptimisticJob = class {
|
|
|
316
351
|
return this;
|
|
317
352
|
},
|
|
318
353
|
createObject(type, pk, properties) {
|
|
319
|
-
const create = store.client[
|
|
354
|
+
const create = store.client[chunkDZE6IAUU_cjs.additionalContext].objectFactory2(store.client[chunkDZE6IAUU_cjs.additionalContext], [{
|
|
320
355
|
$primaryKey: pk,
|
|
321
356
|
$apiName: type.apiName,
|
|
322
357
|
$objectType: type.apiName,
|
|
@@ -383,7 +418,7 @@ var ActionApplication = class {
|
|
|
383
418
|
if (process.env.NODE_ENV !== "production") {
|
|
384
419
|
if (ACTION_DELAY > 0) {
|
|
385
420
|
logger?.debug("action done, pausing", actionResults);
|
|
386
|
-
const delay = (await import('../delay-
|
|
421
|
+
const delay = (await import('../delay-KIUUJ5NJ.cjs')).default;
|
|
387
422
|
await delay(ACTION_DELAY);
|
|
388
423
|
logger?.debug("action done, pausing done");
|
|
389
424
|
}
|
|
@@ -441,735 +476,950 @@ var ActionApplication = class {
|
|
|
441
476
|
};
|
|
442
477
|
};
|
|
443
478
|
|
|
444
|
-
// src/observable/internal/
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function DEBUG_ONLY__cacheKeysToString(x) {
|
|
453
|
-
if (process.env.NODE_ENV !== "production") {
|
|
454
|
-
return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
|
|
455
|
-
} else {
|
|
456
|
-
throw new Error("not implemented");
|
|
457
|
-
}
|
|
458
|
-
}
|
|
479
|
+
// src/observable/internal/aggregation/AggregationCacheKey.ts
|
|
480
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
481
|
+
var API_NAME_IDX = 1;
|
|
482
|
+
var WHERE_IDX = 2;
|
|
483
|
+
var RDP_IDX = 3;
|
|
484
|
+
var AGGREGATE_IDX = 4;
|
|
459
485
|
|
|
460
|
-
// src/observable/internal/
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
486
|
+
// src/observable/internal/aggregation/AggregationsHelper.ts
|
|
487
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
488
|
+
|
|
489
|
+
// src/observable/internal/AbstractHelper.ts
|
|
490
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
491
|
+
|
|
492
|
+
// src/observable/internal/QuerySubscription.ts
|
|
493
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
494
|
+
var subscriptionIdCounter = 0;
|
|
495
|
+
var QuerySubscription = class extends UnsubscribableWrapper {
|
|
496
|
+
/** @internal */
|
|
497
|
+
/** @internal */
|
|
498
|
+
/** @internal */
|
|
499
|
+
constructor(query, subscription) {
|
|
500
|
+
super(subscription);
|
|
501
|
+
this.query = query;
|
|
502
|
+
this.subscription = subscription;
|
|
503
|
+
this.subscriptionId = `sub_${++subscriptionIdCounter}`;
|
|
504
|
+
Object.defineProperties(this, {
|
|
505
|
+
query: {
|
|
506
|
+
enumerable: false
|
|
507
|
+
},
|
|
508
|
+
subscription: {
|
|
509
|
+
enumerable: false
|
|
510
|
+
},
|
|
511
|
+
subscriptionId: {
|
|
512
|
+
enumerable: false
|
|
513
|
+
}
|
|
514
|
+
});
|
|
482
515
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/observable/internal/AbstractHelper.ts
|
|
519
|
+
var AbstractHelper = class {
|
|
520
|
+
constructor(store, cacheKeys) {
|
|
521
|
+
this.store = store;
|
|
522
|
+
this.cacheKeys = cacheKeys;
|
|
491
523
|
}
|
|
492
|
-
|
|
493
|
-
|
|
524
|
+
observe(options, subFn) {
|
|
525
|
+
const query = this.getQuery(options);
|
|
526
|
+
return this._subscribe(query, options, subFn);
|
|
494
527
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
this.
|
|
501
|
-
|
|
528
|
+
_subscribe(query, options, subFn) {
|
|
529
|
+
this.store.cacheKeys.retain(query.cacheKey);
|
|
530
|
+
if (options.mode !== "offline") {
|
|
531
|
+
query.revalidate(options.mode === "force").catch((e) => {
|
|
532
|
+
subFn.error(e);
|
|
533
|
+
if (this.store.logger) {
|
|
534
|
+
this.store.logger.error("Unhandled error in observeObject", e);
|
|
535
|
+
} else {
|
|
536
|
+
throw e;
|
|
537
|
+
}
|
|
538
|
+
});
|
|
502
539
|
}
|
|
540
|
+
const sub = query.subscribe(subFn);
|
|
541
|
+
const querySub = new QuerySubscription(query, sub);
|
|
542
|
+
query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
|
|
543
|
+
sub.add(() => {
|
|
544
|
+
query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
|
|
545
|
+
this.store.cacheKeys.release(query.cacheKey);
|
|
546
|
+
});
|
|
547
|
+
return querySub;
|
|
503
548
|
}
|
|
504
549
|
};
|
|
505
550
|
|
|
506
|
-
// src/observable/internal/
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
#
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
#
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
this.#
|
|
527
|
-
this
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
551
|
+
// src/observable/internal/aggregation/ObjectAggregationQuery.ts
|
|
552
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
553
|
+
|
|
554
|
+
// src/observable/internal/aggregation/AggregationQuery.ts
|
|
555
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
556
|
+
|
|
557
|
+
// src/observable/internal/Query.ts
|
|
558
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
559
|
+
var Query = class {
|
|
560
|
+
retainCount = 0;
|
|
561
|
+
#connectable;
|
|
562
|
+
#subscription;
|
|
563
|
+
#subject;
|
|
564
|
+
#subscriptionDedupeIntervals = /* @__PURE__ */ new Map();
|
|
565
|
+
/** @internal */
|
|
566
|
+
constructor(store, observable, opts, cacheKey, logger) {
|
|
567
|
+
this.options = opts;
|
|
568
|
+
this.cacheKey = cacheKey;
|
|
569
|
+
this.store = store;
|
|
570
|
+
this.cacheKeys = store.cacheKeys;
|
|
571
|
+
this.#subject = observable;
|
|
572
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger : store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
573
|
+
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
574
|
+
}));
|
|
575
|
+
}
|
|
576
|
+
subscribe(observer) {
|
|
577
|
+
this.#connectable ??= this._createConnectable(this.#subject);
|
|
578
|
+
this.#subscription = this.#connectable.connect();
|
|
579
|
+
const sub = this.#connectable.subscribe({
|
|
580
|
+
next: (value) => {
|
|
581
|
+
if (observer.next) {
|
|
582
|
+
observer.next(value);
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
error: (err) => {
|
|
586
|
+
if (observer.error) {
|
|
587
|
+
observer.error(err);
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
complete: () => {
|
|
591
|
+
if (observer.complete) {
|
|
592
|
+
observer.complete();
|
|
593
|
+
}
|
|
536
594
|
}
|
|
537
595
|
});
|
|
596
|
+
return sub;
|
|
538
597
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
598
|
+
/**
|
|
599
|
+
* Register a subscription's dedupeInterval value
|
|
600
|
+
*/
|
|
601
|
+
registerSubscriptionDedupeInterval(subscriptionId, dedupeInterval) {
|
|
602
|
+
if (dedupeInterval != null && dedupeInterval > 0) {
|
|
603
|
+
this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);
|
|
543
604
|
}
|
|
544
|
-
const cacheKeyArgs = [type, ...normalizedArgs];
|
|
545
|
-
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
|
|
546
|
-
const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
547
|
-
this.#refCounts.register(cacheKey);
|
|
548
|
-
return cacheKey;
|
|
549
|
-
}
|
|
550
|
-
retain(cacheKey) {
|
|
551
|
-
this.#refCounts.retain(cacheKey);
|
|
552
605
|
}
|
|
553
|
-
|
|
554
|
-
|
|
606
|
+
/**
|
|
607
|
+
* Unregister a subscription's dedupeInterval value
|
|
608
|
+
*/
|
|
609
|
+
unregisterSubscriptionDedupeInterval(subscriptionId) {
|
|
610
|
+
this.#subscriptionDedupeIntervals.delete(subscriptionId);
|
|
555
611
|
}
|
|
556
|
-
|
|
557
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Get the minimum dedupeInterval from all active subscriptions
|
|
614
|
+
*/
|
|
615
|
+
getMinimumDedupeInterval() {
|
|
616
|
+
if (this.#subscriptionDedupeIntervals.size === 0) {
|
|
617
|
+
return this.options.dedupeInterval ?? 0;
|
|
618
|
+
}
|
|
619
|
+
return Math.min(...this.#subscriptionDedupeIntervals.values());
|
|
558
620
|
}
|
|
559
621
|
/**
|
|
560
|
-
*
|
|
561
|
-
*
|
|
622
|
+
* Causes the query to revalidate. This will cause the query to fetch
|
|
623
|
+
* the latest data from the server and update the store if it is deemed
|
|
624
|
+
* "stale" or if `force` is true.
|
|
625
|
+
*
|
|
626
|
+
* @param force
|
|
627
|
+
* @returns
|
|
562
628
|
*/
|
|
563
|
-
|
|
564
|
-
this
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
deleted = /* @__PURE__ */ new Set();
|
|
574
|
-
registerObject = (cacheKey, data, isNew) => {
|
|
575
|
-
this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
|
|
576
|
-
this[isNew ? "added" : "modified"].add(cacheKey);
|
|
577
|
-
};
|
|
578
|
-
deleteObject = (cacheKey) => {
|
|
579
|
-
this.deleted.add(cacheKey);
|
|
580
|
-
};
|
|
581
|
-
registerList = (key) => {
|
|
582
|
-
this.modified.add(key);
|
|
583
|
-
};
|
|
584
|
-
registerLink = (cacheKey) => {
|
|
585
|
-
this.modified.add(cacheKey);
|
|
586
|
-
};
|
|
587
|
-
deleteLink = (cacheKey) => {
|
|
588
|
-
this.deleted.add(cacheKey);
|
|
589
|
-
};
|
|
590
|
-
registerObjectSet = (key) => {
|
|
591
|
-
this.modified.add(key);
|
|
592
|
-
};
|
|
593
|
-
isEmpty() {
|
|
594
|
-
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
function createChangedObjects() {
|
|
598
|
-
return new Changes();
|
|
599
|
-
}
|
|
600
|
-
function DEBUG_ONLY__changesToString(changes) {
|
|
601
|
-
if (process.env.NODE_ENV !== "production") {
|
|
602
|
-
return JSON.stringify({
|
|
603
|
-
modifiedObjects: multimapHelper(changes.modifiedObjects),
|
|
604
|
-
addedObjects: multimapHelper(changes.addedObjects),
|
|
605
|
-
added: listHelper(changes.added),
|
|
606
|
-
modified: listHelper(changes.modified)
|
|
607
|
-
}, null, 2);
|
|
608
|
-
} else {
|
|
609
|
-
throw new Error("not implemented");
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
function listHelper(set) {
|
|
613
|
-
return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);
|
|
614
|
-
}
|
|
615
|
-
function multimapHelper(multimap) {
|
|
616
|
-
return Object.fromEntries(Array.from(multimap.associations()).map(([type, objects]) => {
|
|
617
|
-
return [type, objects.map((o) => o.$primaryKey)];
|
|
618
|
-
}));
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// src/observable/internal/createInitEntry.ts
|
|
622
|
-
function createInitEntry(cacheKey) {
|
|
623
|
-
return {
|
|
624
|
-
cacheKey,
|
|
625
|
-
status: "init",
|
|
626
|
-
value: void 0,
|
|
627
|
-
lastUpdated: 0
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// src/observable/internal/WeakMapWithEntries.ts
|
|
632
|
-
var WeakMapWithEntries = class {
|
|
633
|
-
#map = /* @__PURE__ */ new WeakMap();
|
|
634
|
-
#list = [];
|
|
635
|
-
#toClean = [];
|
|
636
|
-
#needsCleaning = false;
|
|
637
|
-
#registry = new FinalizationRegistry(() => {
|
|
638
|
-
this.#toClean.push(new WeakRef({}));
|
|
639
|
-
this.#needsCleaning = true;
|
|
640
|
-
});
|
|
641
|
-
constructor() {
|
|
642
|
-
const weakThis = new WeakRef(this);
|
|
643
|
-
const intervalId = setInterval(() => {
|
|
644
|
-
const self = weakThis.deref();
|
|
645
|
-
if (self) {
|
|
646
|
-
if (this.#needsCleaning) {
|
|
647
|
-
this.#clean();
|
|
648
|
-
}
|
|
649
|
-
} else {
|
|
650
|
-
clearInterval(intervalId);
|
|
629
|
+
async revalidate(force) {
|
|
630
|
+
const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
|
|
631
|
+
methodName: "revalidate"
|
|
632
|
+
}) : this.logger;
|
|
633
|
+
if (force) {
|
|
634
|
+
this.abortController?.abort();
|
|
635
|
+
}
|
|
636
|
+
if (this.pendingFetch) {
|
|
637
|
+
if (process.env.NODE_ENV !== "production") {
|
|
638
|
+
logger?.debug("Fetch is already pending, using it");
|
|
651
639
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
640
|
+
await this.pendingFetch;
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const minDedupeInterval = this.getMinimumDedupeInterval();
|
|
644
|
+
if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
|
|
645
|
+
if (process.env.NODE_ENV !== "production") {
|
|
646
|
+
logger?.debug("Within dupeInterval, aborting revalidate");
|
|
647
|
+
}
|
|
648
|
+
return Promise.resolve();
|
|
649
|
+
}
|
|
650
|
+
if (process.env.NODE_ENV !== "production") {
|
|
651
|
+
logger?.debug("Starting actual revalidate");
|
|
652
|
+
}
|
|
653
|
+
this.store.batch({}, (batch) => {
|
|
654
|
+
this.setStatus("loading", batch);
|
|
655
|
+
});
|
|
656
|
+
this._preFetch();
|
|
657
|
+
this.lastFetchStarted = Date.now();
|
|
658
|
+
if (process.env.NODE_ENV !== "production") {
|
|
659
|
+
logger?.debug("calling _fetchAndStore()");
|
|
660
|
+
}
|
|
661
|
+
this.pendingFetch = this._fetchAndStore().finally(() => {
|
|
662
|
+
logger?.debug("promise's finally for _fetchAndStore()");
|
|
663
|
+
this.pendingFetch = void 0;
|
|
664
|
+
});
|
|
665
|
+
await this.pendingFetch;
|
|
666
|
+
return;
|
|
666
667
|
}
|
|
667
|
-
|
|
668
|
-
return this.#map.has(key);
|
|
668
|
+
_preFetch() {
|
|
669
669
|
}
|
|
670
670
|
/**
|
|
671
|
-
*
|
|
672
|
-
*
|
|
671
|
+
* Sets the status of the query in the store (but does not store that in `changes`).
|
|
672
|
+
*
|
|
673
|
+
* @param status
|
|
674
|
+
* @param batch
|
|
675
|
+
* @returns
|
|
673
676
|
*/
|
|
674
|
-
|
|
675
|
-
if (
|
|
676
|
-
this
|
|
677
|
+
setStatus(status, batch) {
|
|
678
|
+
if (process.env.NODE_ENV !== "production") {
|
|
679
|
+
this.logger?.child({
|
|
680
|
+
methodName: "setStatus"
|
|
681
|
+
}).debug(`Attempting to set status to '${status}'`);
|
|
677
682
|
}
|
|
678
|
-
this
|
|
679
|
-
|
|
683
|
+
const existing = batch.read(this.cacheKey);
|
|
684
|
+
if (existing?.status === status) {
|
|
685
|
+
if (process.env.NODE_ENV !== "production") {
|
|
686
|
+
this.logger?.child({
|
|
687
|
+
methodName: "setStatus"
|
|
688
|
+
}).debug(`Status is already set to '${status}'; aborting`);
|
|
689
|
+
}
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
if (process.env.NODE_ENV !== "production") {
|
|
693
|
+
this.logger?.child({
|
|
694
|
+
methodName: "setStatus"
|
|
695
|
+
}).debug(`Writing status '${status}' to cache`);
|
|
696
|
+
}
|
|
697
|
+
batch.write(this.cacheKey, existing?.value, status);
|
|
680
698
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
699
|
+
dispose() {
|
|
700
|
+
if (this.abortController) {
|
|
701
|
+
this.abortController.abort();
|
|
702
|
+
}
|
|
703
|
+
this.#subscription?.unsubscribe();
|
|
704
|
+
this._dispose();
|
|
686
705
|
}
|
|
687
706
|
/**
|
|
688
|
-
*
|
|
707
|
+
* Per query type dispose functionality
|
|
689
708
|
*/
|
|
690
|
-
|
|
691
|
-
const self = this;
|
|
692
|
-
function* iter() {
|
|
693
|
-
for (const ref of self.#list) {
|
|
694
|
-
const key = ref.deref();
|
|
695
|
-
if (key !== void 0) {
|
|
696
|
-
yield [key, self.#map.get(key)];
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return iter();
|
|
709
|
+
_dispose() {
|
|
701
710
|
}
|
|
702
711
|
/**
|
|
703
|
-
*
|
|
712
|
+
* The purpose of this method is to provide a way for others to write
|
|
713
|
+
* directly into the store for this query.
|
|
714
|
+
*
|
|
715
|
+
* @param data
|
|
716
|
+
* @param status
|
|
717
|
+
* @param batch
|
|
704
718
|
*/
|
|
705
|
-
keys() {
|
|
706
|
-
const self = this;
|
|
707
|
-
function* iter() {
|
|
708
|
-
for (const ref of self.#list) {
|
|
709
|
-
const key = ref.deref();
|
|
710
|
-
if (key !== void 0) {
|
|
711
|
-
yield key;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
return iter();
|
|
716
|
-
}
|
|
717
719
|
/**
|
|
718
|
-
*
|
|
720
|
+
* @param changes
|
|
721
|
+
* @param optimisticId
|
|
722
|
+
* @returns If revalidation is needed, a promise that resolves after the
|
|
723
|
+
* revalidation is complete. Otherwise, undefined.
|
|
719
724
|
*/
|
|
720
|
-
values() {
|
|
721
|
-
const self = this;
|
|
722
|
-
function* iter() {
|
|
723
|
-
for (const ref of self.#list) {
|
|
724
|
-
const key = ref.deref();
|
|
725
|
-
if (key !== void 0) {
|
|
726
|
-
const value = self.#map.get(key);
|
|
727
|
-
if (value !== void 0) {
|
|
728
|
-
yield value;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
return iter();
|
|
734
|
-
}
|
|
735
725
|
};
|
|
736
726
|
|
|
737
|
-
// src/observable/internal/
|
|
738
|
-
var
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
this
|
|
744
|
-
this
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return this.#parent;
|
|
748
|
-
}
|
|
749
|
-
get layerId() {
|
|
750
|
-
return this.#layerId;
|
|
727
|
+
// src/observable/internal/aggregation/AggregationQuery.ts
|
|
728
|
+
var AggregationQuery = class extends Query {
|
|
729
|
+
constructor(store, subject, cacheKey, opts) {
|
|
730
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
731
|
+
msgPrefix: `AggregationQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
732
|
+
}) : void 0);
|
|
733
|
+
this.apiName = cacheKey.otherKeys[API_NAME_IDX];
|
|
734
|
+
this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];
|
|
735
|
+
this.rdpConfig = cacheKey.otherKeys[RDP_IDX];
|
|
736
|
+
this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];
|
|
751
737
|
}
|
|
752
|
-
|
|
753
|
-
return
|
|
738
|
+
_createConnectable(subject) {
|
|
739
|
+
return rxjs.connectable(subject.pipe(rxjs.map((x) => {
|
|
740
|
+
return {
|
|
741
|
+
status: x.status,
|
|
742
|
+
result: x.value,
|
|
743
|
+
lastUpdated: x.lastUpdated,
|
|
744
|
+
error: x.status === "error" ? new Error("Aggregation failed") : void 0
|
|
745
|
+
};
|
|
746
|
+
})), {
|
|
747
|
+
connector: () => new rxjs.BehaviorSubject({
|
|
748
|
+
status: "init",
|
|
749
|
+
result: void 0,
|
|
750
|
+
lastUpdated: 0
|
|
751
|
+
})
|
|
752
|
+
});
|
|
754
753
|
}
|
|
755
|
-
|
|
756
|
-
if (
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
754
|
+
async _fetchAndStore() {
|
|
755
|
+
if (process.env.NODE_ENV !== "production") {
|
|
756
|
+
this.logger?.child({
|
|
757
|
+
methodName: "_fetchAndStore"
|
|
758
|
+
}).debug("calling _fetchAndStore");
|
|
759
|
+
}
|
|
760
|
+
try {
|
|
761
|
+
const result = await this._fetchAggregation();
|
|
762
|
+
this.store.batch({}, (batch) => {
|
|
763
|
+
this.writeToStore(result, "loaded", batch);
|
|
764
|
+
});
|
|
765
|
+
} catch (err) {
|
|
766
|
+
this.store.batch({}, (batch) => {
|
|
767
|
+
this.writeToStore(void 0, "error", batch);
|
|
768
|
+
});
|
|
762
769
|
}
|
|
763
|
-
return this.#parent.removeLayer(layerId);
|
|
764
770
|
}
|
|
765
|
-
|
|
766
|
-
|
|
771
|
+
writeToStore(data, status, batch) {
|
|
772
|
+
batch.write(this.cacheKey, data, status);
|
|
773
|
+
batch.changes.modified.add(this.cacheKey);
|
|
774
|
+
return batch.read(this.cacheKey);
|
|
767
775
|
}
|
|
768
|
-
|
|
769
|
-
|
|
776
|
+
invalidateObjectType = (objectType, changes) => {
|
|
777
|
+
if (this.apiName === objectType) {
|
|
778
|
+
changes?.modified.add(this.cacheKey);
|
|
779
|
+
return this.revalidate(true);
|
|
780
|
+
}
|
|
781
|
+
return Promise.resolve();
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// src/observable/internal/aggregation/ObjectAggregationQuery.ts
|
|
786
|
+
var ObjectAggregationQuery = class extends AggregationQuery {
|
|
787
|
+
async _fetchAggregation() {
|
|
788
|
+
const type = this.cacheKey.otherKeys[API_NAME_IDX];
|
|
789
|
+
let objectSet = this.store.client({
|
|
790
|
+
type: "object",
|
|
791
|
+
apiName: type
|
|
792
|
+
});
|
|
793
|
+
if (this.rdpConfig) {
|
|
794
|
+
objectSet = objectSet.withProperties(this.rdpConfig);
|
|
795
|
+
}
|
|
796
|
+
objectSet = objectSet.where(this.canonicalWhere);
|
|
797
|
+
return await objectSet.aggregate(this.canonicalAggregate);
|
|
770
798
|
}
|
|
771
|
-
|
|
772
|
-
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// src/observable/internal/aggregation/AggregationsHelper.ts
|
|
802
|
+
var AggregationsHelper = class extends AbstractHelper {
|
|
803
|
+
constructor(store, cacheKeys, whereCanonicalizer2, rdpCanonicalizer) {
|
|
804
|
+
super(store, cacheKeys);
|
|
805
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
806
|
+
this.rdpCanonicalizer = rdpCanonicalizer;
|
|
773
807
|
}
|
|
774
|
-
|
|
775
|
-
|
|
808
|
+
observe(options, subFn) {
|
|
809
|
+
return super.observe(options, subFn);
|
|
776
810
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
811
|
+
getQuery(options) {
|
|
812
|
+
const {
|
|
813
|
+
type,
|
|
814
|
+
where,
|
|
815
|
+
withProperties,
|
|
816
|
+
aggregate
|
|
817
|
+
} = options;
|
|
818
|
+
const {
|
|
819
|
+
apiName
|
|
820
|
+
} = type;
|
|
821
|
+
const typeKind = "type" in type ? type.type : "interface";
|
|
822
|
+
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
823
|
+
const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
|
|
824
|
+
const canonAggregate = this.canonicalizeAggregate(aggregate);
|
|
825
|
+
const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, canonWhere, canonRdp, canonAggregate);
|
|
826
|
+
return this.store.queries.get(aggregationCacheKey, () => {
|
|
827
|
+
if (typeKind !== "object") {
|
|
828
|
+
throw new Error("Only ObjectTypeDefinition is currently supported for aggregations");
|
|
829
|
+
}
|
|
830
|
+
return new ObjectAggregationQuery(this.store, this.store.subjects.get(aggregationCacheKey), aggregationCacheKey, options);
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
canonicalizeAggregate(aggregate) {
|
|
834
|
+
return JSON.parse(JSON.stringify(aggregate));
|
|
789
835
|
}
|
|
790
|
-
peek = (cacheKey) => {
|
|
791
|
-
return this.#cacheKeyToSubject.get(cacheKey);
|
|
792
|
-
};
|
|
793
|
-
get = (cacheKey) => {
|
|
794
|
-
let subject = this.#cacheKeyToSubject.get(cacheKey);
|
|
795
|
-
if (!subject) {
|
|
796
|
-
const initialValue = this.#layers.top.get(cacheKey) ?? createInitEntry(cacheKey);
|
|
797
|
-
subject = new rxjs.BehaviorSubject({
|
|
798
|
-
...initialValue,
|
|
799
|
-
isOptimistic: initialValue.value !== this.#layers.truth.get(cacheKey)?.value
|
|
800
|
-
});
|
|
801
|
-
this.#cacheKeyToSubject.set(cacheKey, subject);
|
|
802
|
-
}
|
|
803
|
-
return subject;
|
|
804
|
-
};
|
|
805
|
-
delete = (cacheKey) => {
|
|
806
|
-
const subject = this.peek(cacheKey);
|
|
807
|
-
if (subject) {
|
|
808
|
-
subject.complete();
|
|
809
|
-
this.#cacheKeyToSubject.delete(cacheKey);
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
836
|
};
|
|
813
837
|
|
|
814
|
-
// src/observable/internal/
|
|
815
|
-
|
|
838
|
+
// src/observable/internal/CacheKey.ts
|
|
839
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
840
|
+
function DEBUG_ONLY__cacheKeyToString(x) {
|
|
841
|
+
if (process.env.NODE_ENV !== "production") {
|
|
842
|
+
return `${x.type}CacheKey<${x.otherKeys.map((xx) => JSON.stringify(xx)).join(", ")}>`.replaceAll('"', "'");
|
|
843
|
+
} else {
|
|
844
|
+
throw new Error("not implemented");
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
function DEBUG_ONLY__cacheKeysToString(x) {
|
|
848
|
+
if (process.env.NODE_ENV !== "production") {
|
|
849
|
+
return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
|
|
850
|
+
} else {
|
|
851
|
+
throw new Error("not implemented");
|
|
852
|
+
}
|
|
853
|
+
}
|
|
816
854
|
|
|
817
|
-
// src/observable/internal/
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
this.
|
|
829
|
-
|
|
830
|
-
layers: this
|
|
831
|
-
});
|
|
832
|
-
this.#onRevalidate = onRevalidate;
|
|
855
|
+
// src/observable/internal/CacheKeys.ts
|
|
856
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
857
|
+
|
|
858
|
+
// src/observable/internal/RefCounts.ts
|
|
859
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
860
|
+
var RefCounts = class {
|
|
861
|
+
refCounts = /* @__PURE__ */ new Map();
|
|
862
|
+
// keeps our objects around for some extended duration after they are no longer
|
|
863
|
+
// needed which is good for quick clicks across tabs.
|
|
864
|
+
gcMap = /* @__PURE__ */ new Map();
|
|
865
|
+
constructor(keepAlive, cleanup) {
|
|
866
|
+
this.keepAlive = keepAlive;
|
|
867
|
+
this.cleanup = cleanup;
|
|
833
868
|
}
|
|
834
|
-
|
|
835
|
-
|
|
869
|
+
register(key) {
|
|
870
|
+
if (!this.refCounts.has(key)) {
|
|
871
|
+
this.gcMap.set(key, Date.now() + this.keepAlive);
|
|
872
|
+
}
|
|
873
|
+
return key;
|
|
836
874
|
}
|
|
837
|
-
|
|
838
|
-
|
|
875
|
+
retain(key) {
|
|
876
|
+
const count = this.refCounts.get(key) ?? 0;
|
|
877
|
+
this.refCounts.set(key, count + 1);
|
|
878
|
+
if (this.gcMap.has(key)) {
|
|
879
|
+
this.gcMap.delete(key);
|
|
880
|
+
}
|
|
839
881
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
if (cacheKeys.has(k)) continue;
|
|
848
|
-
cacheKeys.set(k, v);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
currentLayer = currentLayer.parentLayer;
|
|
882
|
+
release(key) {
|
|
883
|
+
const count = this.refCounts.get(key);
|
|
884
|
+
if (count === void 0) ; else if (count === 1) {
|
|
885
|
+
this.refCounts.delete(key);
|
|
886
|
+
this.gcMap.set(key, Date.now() + this.keepAlive);
|
|
887
|
+
} else {
|
|
888
|
+
this.refCounts.set(key, count - 1);
|
|
852
889
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
890
|
+
}
|
|
891
|
+
has(key) {
|
|
892
|
+
return this.refCounts.has(key);
|
|
893
|
+
}
|
|
894
|
+
gc() {
|
|
895
|
+
const now = Date.now();
|
|
896
|
+
for (const [key, deathTime] of this.gcMap) {
|
|
897
|
+
if (deathTime < now) {
|
|
898
|
+
this.gcMap.delete(key);
|
|
899
|
+
this.cleanup(key);
|
|
862
900
|
}
|
|
863
901
|
}
|
|
864
902
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
});
|
|
874
|
-
const retVal = batchFn(batchContext);
|
|
875
|
-
this.#onRevalidate(changes, optimisticId).catch((e) => {
|
|
876
|
-
if (this.logger) {
|
|
877
|
-
this.logger.error("Unhandled error in batch", e);
|
|
878
|
-
} else {
|
|
879
|
-
console.error("Unhandled error in batch", e);
|
|
880
|
-
throw e;
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
return {
|
|
884
|
-
batchResult: batchContext,
|
|
885
|
-
retVal,
|
|
886
|
-
changes: batchContext.changes
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
// src/observable/internal/CacheKeys.ts
|
|
906
|
+
var CacheKeys = class {
|
|
907
|
+
#cacheKeys = new trie.Trie(false, (keys) => {
|
|
908
|
+
const cacheKey = {
|
|
909
|
+
type: keys[0],
|
|
910
|
+
otherKeys: keys.slice(1)
|
|
887
911
|
};
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
912
|
+
this.#onCreate?.(cacheKey);
|
|
913
|
+
return cacheKey;
|
|
914
|
+
});
|
|
915
|
+
#refCounts = new RefCounts(6e4, (k) => this.#cleanupCacheKey(k));
|
|
916
|
+
// we are currently only using this for debug logging and should just remove it in the future if that
|
|
917
|
+
// continues to be true
|
|
918
|
+
#finalizationRegistry;
|
|
919
|
+
#onCreate;
|
|
920
|
+
#onDestroy;
|
|
921
|
+
constructor({
|
|
922
|
+
onCreate,
|
|
923
|
+
onDestroy
|
|
892
924
|
}) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
write: (cacheKey, value, status) => {
|
|
904
|
-
const oldTopValue = this.#topLayer.get(cacheKey);
|
|
905
|
-
if (optimisticId) batchContext.createLayerIfNeeded();
|
|
906
|
-
const writeLayer = optimisticId ? this.#topLayer : this.#truthLayer;
|
|
907
|
-
const newValue = {
|
|
908
|
-
cacheKey,
|
|
909
|
-
value,
|
|
910
|
-
lastUpdated: Date.now(),
|
|
911
|
-
status
|
|
912
|
-
};
|
|
913
|
-
writeLayer.set(cacheKey, newValue);
|
|
914
|
-
const newTopValue = this.#topLayer.get(cacheKey);
|
|
915
|
-
if (oldTopValue !== newTopValue) {
|
|
916
|
-
this.subjects.get(cacheKey)?.next({
|
|
917
|
-
...newValue,
|
|
918
|
-
isOptimistic: newTopValue?.value !== this.#truthLayer.get(cacheKey)?.value
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
return newValue;
|
|
922
|
-
},
|
|
923
|
-
delete: (cacheKey, status) => {
|
|
924
|
-
return batchContext.write(cacheKey, tombstone, status);
|
|
925
|
-
},
|
|
926
|
-
read: (cacheKey) => {
|
|
927
|
-
return optimisticId ? this.#topLayer.get(cacheKey) : this.#truthLayer.get(cacheKey);
|
|
925
|
+
this.#onCreate = onCreate;
|
|
926
|
+
this.#onDestroy = onDestroy;
|
|
927
|
+
setInterval(() => {
|
|
928
|
+
this.#refCounts.gc();
|
|
929
|
+
}, 1e3);
|
|
930
|
+
this.#finalizationRegistry = new FinalizationRegistry((cleanupCallback) => {
|
|
931
|
+
try {
|
|
932
|
+
cleanupCallback();
|
|
933
|
+
} catch (e) {
|
|
934
|
+
console.error("Caught an error while running a finalization callback", e);
|
|
928
935
|
}
|
|
929
|
-
};
|
|
930
|
-
return batchContext;
|
|
936
|
+
});
|
|
931
937
|
}
|
|
938
|
+
get(type, ...args) {
|
|
939
|
+
const normalizedArgs = [...args];
|
|
940
|
+
while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
|
|
941
|
+
normalizedArgs.pop();
|
|
942
|
+
}
|
|
943
|
+
const cacheKeyArgs = [type, ...normalizedArgs];
|
|
944
|
+
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
|
|
945
|
+
const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
946
|
+
this.#refCounts.register(cacheKey);
|
|
947
|
+
return cacheKey;
|
|
948
|
+
}
|
|
949
|
+
retain(cacheKey) {
|
|
950
|
+
this.#refCounts.retain(cacheKey);
|
|
951
|
+
}
|
|
952
|
+
release(cacheKey) {
|
|
953
|
+
this.#refCounts.release(cacheKey);
|
|
954
|
+
}
|
|
955
|
+
#remove(cacheKey) {
|
|
956
|
+
this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Called after a key is no longer retained and the timeout has elapsed
|
|
960
|
+
* @param key
|
|
961
|
+
*/
|
|
962
|
+
#cleanupCacheKey = (key) => {
|
|
963
|
+
this.#onDestroy?.(key);
|
|
964
|
+
this.#remove(key);
|
|
965
|
+
};
|
|
932
966
|
};
|
|
933
967
|
|
|
934
|
-
// src/observable/internal/
|
|
935
|
-
|
|
936
|
-
var
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
this.
|
|
944
|
-
this
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
968
|
+
// src/observable/internal/Changes.ts
|
|
969
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
970
|
+
var Changes = class {
|
|
971
|
+
modifiedObjects = new mnemonist.MultiMap();
|
|
972
|
+
addedObjects = new mnemonist.MultiMap();
|
|
973
|
+
added = /* @__PURE__ */ new Set();
|
|
974
|
+
modified = /* @__PURE__ */ new Set();
|
|
975
|
+
deleted = /* @__PURE__ */ new Set();
|
|
976
|
+
registerObject = (cacheKey, data, isNew) => {
|
|
977
|
+
this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
|
|
978
|
+
this[isNew ? "added" : "modified"].add(cacheKey);
|
|
979
|
+
};
|
|
980
|
+
deleteObject = (cacheKey) => {
|
|
981
|
+
this.deleted.add(cacheKey);
|
|
982
|
+
};
|
|
983
|
+
registerList = (key) => {
|
|
984
|
+
this.modified.add(key);
|
|
985
|
+
};
|
|
986
|
+
registerLink = (cacheKey) => {
|
|
987
|
+
this.modified.add(cacheKey);
|
|
988
|
+
};
|
|
989
|
+
deleteLink = (cacheKey) => {
|
|
990
|
+
this.deleted.add(cacheKey);
|
|
991
|
+
};
|
|
992
|
+
registerObjectSet = (key) => {
|
|
993
|
+
this.modified.add(key);
|
|
994
|
+
};
|
|
995
|
+
isEmpty() {
|
|
996
|
+
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
|
|
956
997
|
}
|
|
957
998
|
};
|
|
999
|
+
function createChangedObjects() {
|
|
1000
|
+
return new Changes();
|
|
1001
|
+
}
|
|
1002
|
+
function DEBUG_ONLY__changesToString(changes) {
|
|
1003
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1004
|
+
return JSON.stringify({
|
|
1005
|
+
modifiedObjects: multimapHelper(changes.modifiedObjects),
|
|
1006
|
+
addedObjects: multimapHelper(changes.addedObjects),
|
|
1007
|
+
added: listHelper(changes.added),
|
|
1008
|
+
modified: listHelper(changes.modified)
|
|
1009
|
+
}, null, 2);
|
|
1010
|
+
} else {
|
|
1011
|
+
throw new Error("not implemented");
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function listHelper(set) {
|
|
1015
|
+
return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);
|
|
1016
|
+
}
|
|
1017
|
+
function multimapHelper(multimap) {
|
|
1018
|
+
return Object.fromEntries(Array.from(multimap.associations()).map(([type, objects]) => {
|
|
1019
|
+
return [type, objects.map((o) => o.$primaryKey)];
|
|
1020
|
+
}));
|
|
1021
|
+
}
|
|
958
1022
|
|
|
959
|
-
// src/observable/internal/
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1023
|
+
// src/observable/internal/IntersectCanonicalizer.ts
|
|
1024
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1025
|
+
|
|
1026
|
+
// src/observable/internal/Canonicalizer.ts
|
|
1027
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1028
|
+
var CachingCanonicalizer = class {
|
|
1029
|
+
/**
|
|
1030
|
+
* Cache for input object identity.
|
|
1031
|
+
*/
|
|
1032
|
+
inputCache = /* @__PURE__ */ new WeakMap();
|
|
1033
|
+
/**
|
|
1034
|
+
* Look up or create a canonical form for the given input.
|
|
1035
|
+
* This method handles the structural deduplication logic.
|
|
1036
|
+
*
|
|
1037
|
+
* @param input The input to canonicalize
|
|
1038
|
+
* @returns The canonical form
|
|
1039
|
+
*/
|
|
1040
|
+
canonicalize(input) {
|
|
1041
|
+
if (!input) {
|
|
1042
|
+
return void 0;
|
|
1043
|
+
}
|
|
1044
|
+
if (this.inputCache.has(input)) {
|
|
1045
|
+
return this.inputCache.get(input);
|
|
1046
|
+
}
|
|
1047
|
+
const canonical = this.lookupOrCreate(input);
|
|
1048
|
+
this.inputCache.set(input, canonical);
|
|
1049
|
+
return canonical;
|
|
964
1050
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
// src/observable/internal/IntersectCanonicalizer.ts
|
|
1054
|
+
var IntersectCanonicalizer = class extends CachingCanonicalizer {
|
|
1055
|
+
structuralCache = /* @__PURE__ */ new Map();
|
|
1056
|
+
constructor(whereCanonicalizer2) {
|
|
1057
|
+
super();
|
|
1058
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
968
1059
|
}
|
|
969
|
-
|
|
970
|
-
this.
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
} else {
|
|
977
|
-
throw e;
|
|
978
|
-
}
|
|
979
|
-
});
|
|
1060
|
+
lookupOrCreate(intersectWith) {
|
|
1061
|
+
const canonicalClauses = intersectWith.map((item) => this.whereCanonicalizer.canonicalize(item.where ?? {}));
|
|
1062
|
+
const structuralKey = canonicalClauses.map((clause) => JSON.stringify(clause)).join("||");
|
|
1063
|
+
let canonical = this.structuralCache.get(structuralKey);
|
|
1064
|
+
if (!canonical) {
|
|
1065
|
+
canonical = canonicalClauses;
|
|
1066
|
+
this.structuralCache.set(structuralKey, canonical);
|
|
980
1067
|
}
|
|
981
|
-
|
|
982
|
-
const querySub = new QuerySubscription(query, sub);
|
|
983
|
-
query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
|
|
984
|
-
sub.add(() => {
|
|
985
|
-
query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
|
|
986
|
-
this.store.cacheKeys.release(query.cacheKey);
|
|
987
|
-
});
|
|
988
|
-
return querySub;
|
|
1068
|
+
return canonical;
|
|
989
1069
|
}
|
|
990
1070
|
};
|
|
991
1071
|
|
|
992
|
-
// src/observable/internal/
|
|
993
|
-
|
|
994
|
-
|
|
1072
|
+
// src/observable/internal/Layers.ts
|
|
1073
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1074
|
+
|
|
1075
|
+
// src/observable/internal/createInitEntry.ts
|
|
1076
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1077
|
+
function createInitEntry(cacheKey) {
|
|
1078
|
+
return {
|
|
1079
|
+
cacheKey,
|
|
1080
|
+
status: "init",
|
|
1081
|
+
value: void 0,
|
|
1082
|
+
lastUpdated: 0
|
|
1083
|
+
};
|
|
995
1084
|
}
|
|
996
1085
|
|
|
997
|
-
// src/observable/internal/
|
|
998
|
-
|
|
999
|
-
var WHERE_IDX = 2;
|
|
1000
|
-
var ORDER_BY_IDX = 3;
|
|
1001
|
-
var RDP_IDX = 4;
|
|
1086
|
+
// src/observable/internal/Layer.ts
|
|
1087
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1002
1088
|
|
|
1003
|
-
// src/observable/internal/
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
#
|
|
1007
|
-
#
|
|
1008
|
-
#
|
|
1009
|
-
#
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
this
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
subscribe(observer) {
|
|
1022
|
-
this.#connectable ??= this._createConnectable(this.#subject);
|
|
1023
|
-
this.#subscription = this.#connectable.connect();
|
|
1024
|
-
const sub = this.#connectable.subscribe({
|
|
1025
|
-
next: (value) => {
|
|
1026
|
-
if (observer.next) {
|
|
1027
|
-
observer.next(value);
|
|
1028
|
-
}
|
|
1029
|
-
},
|
|
1030
|
-
error: (err) => {
|
|
1031
|
-
if (observer.error) {
|
|
1032
|
-
observer.error(err);
|
|
1033
|
-
}
|
|
1034
|
-
},
|
|
1035
|
-
complete: () => {
|
|
1036
|
-
if (observer.complete) {
|
|
1037
|
-
observer.complete();
|
|
1089
|
+
// src/observable/internal/WeakMapWithEntries.ts
|
|
1090
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1091
|
+
var WeakMapWithEntries = class {
|
|
1092
|
+
#map = /* @__PURE__ */ new WeakMap();
|
|
1093
|
+
#list = [];
|
|
1094
|
+
#toClean = [];
|
|
1095
|
+
#needsCleaning = false;
|
|
1096
|
+
#registry = new FinalizationRegistry(() => {
|
|
1097
|
+
this.#toClean.push(new WeakRef({}));
|
|
1098
|
+
this.#needsCleaning = true;
|
|
1099
|
+
});
|
|
1100
|
+
constructor() {
|
|
1101
|
+
const weakThis = new WeakRef(this);
|
|
1102
|
+
const intervalId = setInterval(() => {
|
|
1103
|
+
const self = weakThis.deref();
|
|
1104
|
+
if (self) {
|
|
1105
|
+
if (this.#needsCleaning) {
|
|
1106
|
+
this.#clean();
|
|
1038
1107
|
}
|
|
1108
|
+
} else {
|
|
1109
|
+
clearInterval(intervalId);
|
|
1039
1110
|
}
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1111
|
+
}, 1e3);
|
|
1112
|
+
}
|
|
1113
|
+
#clean() {
|
|
1114
|
+
this.#list = this.#list.filter((ref) => ref.deref() !== void 0);
|
|
1115
|
+
}
|
|
1116
|
+
// functions for WeakMap
|
|
1117
|
+
delete(key) {
|
|
1118
|
+
const ret = this.#map.delete(key);
|
|
1119
|
+
this.#toClean.push(new WeakRef(key));
|
|
1120
|
+
this.#needsCleaning = true;
|
|
1121
|
+
return ret;
|
|
1122
|
+
}
|
|
1123
|
+
get(key) {
|
|
1124
|
+
return this.#map.get(key);
|
|
1125
|
+
}
|
|
1126
|
+
has(key) {
|
|
1127
|
+
return this.#map.has(key);
|
|
1042
1128
|
}
|
|
1043
1129
|
/**
|
|
1044
|
-
*
|
|
1130
|
+
* Adds a new element with a specified key and value.
|
|
1131
|
+
* @param key Must be an object or symbol.
|
|
1045
1132
|
*/
|
|
1046
|
-
|
|
1047
|
-
if (
|
|
1048
|
-
this.#
|
|
1133
|
+
set(key, value) {
|
|
1134
|
+
if (!this.#map.has(key)) {
|
|
1135
|
+
this.#list.push(new WeakRef(key));
|
|
1049
1136
|
}
|
|
1137
|
+
this.#map.set(key, value);
|
|
1138
|
+
return this;
|
|
1139
|
+
}
|
|
1140
|
+
[Symbol.toStringTag] = "WeakMap";
|
|
1141
|
+
// functions for iterables
|
|
1142
|
+
/** Returns an iterable of entries in the map. */
|
|
1143
|
+
[Symbol.iterator]() {
|
|
1144
|
+
return this.entries();
|
|
1050
1145
|
}
|
|
1051
1146
|
/**
|
|
1052
|
-
*
|
|
1147
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
1053
1148
|
*/
|
|
1054
|
-
|
|
1055
|
-
this
|
|
1149
|
+
entries() {
|
|
1150
|
+
const self = this;
|
|
1151
|
+
function* iter() {
|
|
1152
|
+
for (const ref of self.#list) {
|
|
1153
|
+
const key = ref.deref();
|
|
1154
|
+
if (key !== void 0) {
|
|
1155
|
+
yield [key, self.#map.get(key)];
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
return iter();
|
|
1056
1160
|
}
|
|
1057
1161
|
/**
|
|
1058
|
-
*
|
|
1162
|
+
* Returns an iterable of keys in the map
|
|
1059
1163
|
*/
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1164
|
+
keys() {
|
|
1165
|
+
const self = this;
|
|
1166
|
+
function* iter() {
|
|
1167
|
+
for (const ref of self.#list) {
|
|
1168
|
+
const key = ref.deref();
|
|
1169
|
+
if (key !== void 0) {
|
|
1170
|
+
yield key;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1063
1173
|
}
|
|
1064
|
-
return
|
|
1174
|
+
return iter();
|
|
1065
1175
|
}
|
|
1066
1176
|
/**
|
|
1067
|
-
*
|
|
1068
|
-
* the latest data from the server and update the store if it is deemed
|
|
1069
|
-
* "stale" or if `force` is true.
|
|
1070
|
-
*
|
|
1071
|
-
* @param force
|
|
1072
|
-
* @returns
|
|
1177
|
+
* Returns an iterable of values in the map
|
|
1073
1178
|
*/
|
|
1074
|
-
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1179
|
+
values() {
|
|
1180
|
+
const self = this;
|
|
1181
|
+
function* iter() {
|
|
1182
|
+
for (const ref of self.#list) {
|
|
1183
|
+
const key = ref.deref();
|
|
1184
|
+
if (key !== void 0) {
|
|
1185
|
+
const value = self.#map.get(key);
|
|
1186
|
+
if (value !== void 0) {
|
|
1187
|
+
yield value;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1084
1190
|
}
|
|
1085
|
-
await this.pendingFetch;
|
|
1086
|
-
return;
|
|
1087
1191
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1192
|
+
return iter();
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
// src/observable/internal/Layer.ts
|
|
1197
|
+
var Layer = class _Layer {
|
|
1198
|
+
#parent;
|
|
1199
|
+
#cache = new WeakMapWithEntries();
|
|
1200
|
+
#layerId;
|
|
1201
|
+
constructor(parent, layerId) {
|
|
1202
|
+
this.#parent = parent;
|
|
1203
|
+
this.#layerId = layerId;
|
|
1204
|
+
}
|
|
1205
|
+
get parentLayer() {
|
|
1206
|
+
return this.#parent;
|
|
1207
|
+
}
|
|
1208
|
+
get layerId() {
|
|
1209
|
+
return this.#layerId;
|
|
1210
|
+
}
|
|
1211
|
+
addLayer(layerId) {
|
|
1212
|
+
return new _Layer(this, layerId);
|
|
1213
|
+
}
|
|
1214
|
+
removeLayer(layerId) {
|
|
1215
|
+
if (layerId == null || this.#parent == null) {
|
|
1216
|
+
return this;
|
|
1094
1217
|
}
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1218
|
+
if (this.#layerId !== layerId) {
|
|
1219
|
+
this.#parent = this.#parent.removeLayer(layerId);
|
|
1220
|
+
return this;
|
|
1097
1221
|
}
|
|
1098
|
-
this.
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
this.
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1222
|
+
return this.#parent.removeLayer(layerId);
|
|
1223
|
+
}
|
|
1224
|
+
entries() {
|
|
1225
|
+
return this.#cache.entries();
|
|
1226
|
+
}
|
|
1227
|
+
keys() {
|
|
1228
|
+
return this.#cache.keys();
|
|
1229
|
+
}
|
|
1230
|
+
get(cacheKey) {
|
|
1231
|
+
return this.#cache.get(cacheKey) ?? this.#parent?.get(cacheKey);
|
|
1232
|
+
}
|
|
1233
|
+
set(cacheKey, value) {
|
|
1234
|
+
this.#cache.set(cacheKey, value);
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// src/observable/internal/Subjects.ts
|
|
1239
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1240
|
+
var Subjects = class {
|
|
1241
|
+
#layers;
|
|
1242
|
+
// we can use a regular Map here because the refCounting will
|
|
1243
|
+
// handle cleanup.
|
|
1244
|
+
#cacheKeyToSubject = /* @__PURE__ */ new WeakMap();
|
|
1245
|
+
constructor({
|
|
1246
|
+
logger,
|
|
1247
|
+
layers
|
|
1248
|
+
}) {
|
|
1249
|
+
this.logger = logger;
|
|
1250
|
+
this.#layers = layers;
|
|
1251
|
+
}
|
|
1252
|
+
peek = (cacheKey) => {
|
|
1253
|
+
return this.#cacheKeyToSubject.get(cacheKey);
|
|
1254
|
+
};
|
|
1255
|
+
get = (cacheKey) => {
|
|
1256
|
+
let subject = this.#cacheKeyToSubject.get(cacheKey);
|
|
1257
|
+
if (!subject) {
|
|
1258
|
+
const initialValue = this.#layers.top.get(cacheKey) ?? createInitEntry(cacheKey);
|
|
1259
|
+
subject = new rxjs.BehaviorSubject({
|
|
1260
|
+
...initialValue,
|
|
1261
|
+
isOptimistic: initialValue.value !== this.#layers.truth.get(cacheKey)?.value
|
|
1262
|
+
});
|
|
1263
|
+
this.#cacheKeyToSubject.set(cacheKey, subject);
|
|
1264
|
+
}
|
|
1265
|
+
return subject;
|
|
1266
|
+
};
|
|
1267
|
+
delete = (cacheKey) => {
|
|
1268
|
+
const subject = this.peek(cacheKey);
|
|
1269
|
+
if (subject) {
|
|
1270
|
+
subject.complete();
|
|
1271
|
+
this.#cacheKeyToSubject.delete(cacheKey);
|
|
1105
1272
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1273
|
+
};
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
// src/observable/internal/tombstone.ts
|
|
1277
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1278
|
+
var tombstone = void 0;
|
|
1279
|
+
|
|
1280
|
+
// src/observable/internal/Layers.ts
|
|
1281
|
+
var Layers = class {
|
|
1282
|
+
#truthLayer = new Layer(void 0, void 0);
|
|
1283
|
+
#topLayer;
|
|
1284
|
+
#onRevalidate;
|
|
1285
|
+
constructor({
|
|
1286
|
+
logger,
|
|
1287
|
+
onRevalidate
|
|
1288
|
+
}) {
|
|
1289
|
+
this.logger = logger;
|
|
1290
|
+
this.#topLayer = this.#truthLayer;
|
|
1291
|
+
this.subjects = new Subjects({
|
|
1292
|
+
logger,
|
|
1293
|
+
layers: this
|
|
1109
1294
|
});
|
|
1110
|
-
|
|
1111
|
-
return;
|
|
1295
|
+
this.#onRevalidate = onRevalidate;
|
|
1112
1296
|
}
|
|
1113
|
-
|
|
1297
|
+
get top() {
|
|
1298
|
+
return this.#topLayer;
|
|
1114
1299
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
const existing = batch.read(this.cacheKey);
|
|
1129
|
-
if (existing?.status === status) {
|
|
1130
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1131
|
-
this.logger?.child({
|
|
1132
|
-
methodName: "setStatus"
|
|
1133
|
-
}).debug(`Status is already set to '${status}'; aborting`);
|
|
1300
|
+
get truth() {
|
|
1301
|
+
return this.#truthLayer;
|
|
1302
|
+
}
|
|
1303
|
+
remove(layerId) {
|
|
1304
|
+
!(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant4__default.default(false) : void 0;
|
|
1305
|
+
let currentLayer = this.#topLayer;
|
|
1306
|
+
const cacheKeys = /* @__PURE__ */ new Map();
|
|
1307
|
+
while (currentLayer != null && currentLayer.parentLayer != null) {
|
|
1308
|
+
if (currentLayer.layerId === layerId) {
|
|
1309
|
+
for (const [k, v] of currentLayer.entries()) {
|
|
1310
|
+
if (cacheKeys.has(k)) continue;
|
|
1311
|
+
cacheKeys.set(k, v);
|
|
1312
|
+
}
|
|
1134
1313
|
}
|
|
1135
|
-
|
|
1314
|
+
currentLayer = currentLayer.parentLayer;
|
|
1136
1315
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1316
|
+
this.#topLayer = this.#topLayer.removeLayer(layerId);
|
|
1317
|
+
for (const [k, oldEntry] of cacheKeys) {
|
|
1318
|
+
const currentEntry = this.#topLayer.get(k);
|
|
1319
|
+
if (oldEntry !== currentEntry) {
|
|
1320
|
+
const newEntry = currentEntry ?? createInitEntry(k);
|
|
1321
|
+
this.subjects.peek(k)?.next({
|
|
1322
|
+
...newEntry,
|
|
1323
|
+
isOptimistic: currentEntry?.value !== this.#truthLayer.get(k)?.value
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1141
1326
|
}
|
|
1142
|
-
batch.write(this.cacheKey, existing?.value, status);
|
|
1143
1327
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
this
|
|
1328
|
+
batch({
|
|
1329
|
+
optimisticId,
|
|
1330
|
+
changes
|
|
1331
|
+
}, batchFn) {
|
|
1332
|
+
!(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "optimistic must be undefined or not falsy") : invariant4__default.default(false) : void 0;
|
|
1333
|
+
const batchContext = this.#createBatchContext({
|
|
1334
|
+
optimisticId,
|
|
1335
|
+
changes
|
|
1336
|
+
});
|
|
1337
|
+
const retVal = batchFn(batchContext);
|
|
1338
|
+
this.#onRevalidate(changes, optimisticId).catch((e) => {
|
|
1339
|
+
if (this.logger) {
|
|
1340
|
+
this.logger.error("Unhandled error in batch", e);
|
|
1341
|
+
} else {
|
|
1342
|
+
console.error("Unhandled error in batch", e);
|
|
1343
|
+
throw e;
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
return {
|
|
1347
|
+
batchResult: batchContext,
|
|
1348
|
+
retVal,
|
|
1349
|
+
changes: batchContext.changes
|
|
1350
|
+
};
|
|
1150
1351
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1352
|
+
#createBatchContext({
|
|
1353
|
+
optimisticId,
|
|
1354
|
+
changes
|
|
1355
|
+
}) {
|
|
1356
|
+
let needsLayer = optimisticId !== void 0;
|
|
1357
|
+
const batchContext = {
|
|
1358
|
+
changes,
|
|
1359
|
+
createLayerIfNeeded: () => {
|
|
1360
|
+
if (needsLayer) {
|
|
1361
|
+
this.#topLayer = this.#topLayer.addLayer(optimisticId);
|
|
1362
|
+
needsLayer = false;
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
optimisticWrite: !!optimisticId,
|
|
1366
|
+
write: (cacheKey, value, status) => {
|
|
1367
|
+
const oldTopValue = this.#topLayer.get(cacheKey);
|
|
1368
|
+
if (optimisticId) batchContext.createLayerIfNeeded();
|
|
1369
|
+
const writeLayer = optimisticId ? this.#topLayer : this.#truthLayer;
|
|
1370
|
+
const newValue = {
|
|
1371
|
+
cacheKey,
|
|
1372
|
+
value,
|
|
1373
|
+
lastUpdated: Date.now(),
|
|
1374
|
+
status
|
|
1375
|
+
};
|
|
1376
|
+
writeLayer.set(cacheKey, newValue);
|
|
1377
|
+
const newTopValue = this.#topLayer.get(cacheKey);
|
|
1378
|
+
if (oldTopValue !== newTopValue) {
|
|
1379
|
+
this.subjects.get(cacheKey)?.next({
|
|
1380
|
+
...newValue,
|
|
1381
|
+
isOptimistic: newTopValue?.value !== this.#truthLayer.get(cacheKey)?.value
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
return newValue;
|
|
1385
|
+
},
|
|
1386
|
+
delete: (cacheKey, status) => {
|
|
1387
|
+
return batchContext.write(cacheKey, tombstone, status);
|
|
1388
|
+
},
|
|
1389
|
+
read: (cacheKey) => {
|
|
1390
|
+
return optimisticId ? this.#topLayer.get(cacheKey) : this.#truthLayer.get(cacheKey);
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
return batchContext;
|
|
1155
1394
|
}
|
|
1156
|
-
/**
|
|
1157
|
-
* The purpose of this method is to provide a way for others to write
|
|
1158
|
-
* directly into the store for this query.
|
|
1159
|
-
*
|
|
1160
|
-
* @param data
|
|
1161
|
-
* @param status
|
|
1162
|
-
* @param batch
|
|
1163
|
-
*/
|
|
1164
|
-
/**
|
|
1165
|
-
* @param changes
|
|
1166
|
-
* @param optimisticId
|
|
1167
|
-
* @returns If revalidation is needed, a promise that resolves after the
|
|
1168
|
-
* revalidation is complete. Otherwise, undefined.
|
|
1169
|
-
*/
|
|
1170
1395
|
};
|
|
1171
1396
|
|
|
1397
|
+
// src/observable/internal/links/LinksHelper.ts
|
|
1398
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1399
|
+
|
|
1400
|
+
// src/observable/internal/links/SpecificLinkQuery.ts
|
|
1401
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1402
|
+
|
|
1403
|
+
// src/observable/internal/base-list/BaseListQuery.ts
|
|
1404
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1405
|
+
|
|
1406
|
+
// src/observable/internal/isObjectInstance.ts
|
|
1407
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1408
|
+
function isObjectInstance(item) {
|
|
1409
|
+
return item != null && typeof item === "object" && "$primaryKey" in item;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/observable/internal/list/ListCacheKey.ts
|
|
1413
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1414
|
+
var API_NAME_IDX2 = 1;
|
|
1415
|
+
var WHERE_IDX2 = 2;
|
|
1416
|
+
var ORDER_BY_IDX = 3;
|
|
1417
|
+
var RDP_IDX2 = 4;
|
|
1418
|
+
var INTERSECT_IDX = 5;
|
|
1419
|
+
var PIVOT_IDX = 6;
|
|
1420
|
+
|
|
1172
1421
|
// src/observable/internal/sorting/SortingStrategy.ts
|
|
1422
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1173
1423
|
var NoOpSortingStrategy = class {
|
|
1174
1424
|
sortCacheKeys(objectCacheKeys, _batch) {
|
|
1175
1425
|
return objectCacheKeys;
|
|
@@ -1215,6 +1465,9 @@ function createOrderBySortFns(orderBy) {
|
|
|
1215
1465
|
};
|
|
1216
1466
|
});
|
|
1217
1467
|
}
|
|
1468
|
+
|
|
1469
|
+
// src/observable/internal/base-list/createCollectionConnectable.ts
|
|
1470
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1218
1471
|
function createCollectionConnectable(subject, subjects, createPayload) {
|
|
1219
1472
|
return rxjs.connectable(subject.pipe(rxjs.switchMap((listEntry) => {
|
|
1220
1473
|
const resolvedData = listEntry?.value?.data == null || listEntry.value.data.length === 0 ? rxjs.of([]) : rxjs.combineLatest(listEntry.value.data.map((cacheKey) => subjects.get(cacheKey).pipe(rxjs.map((objectEntry) => objectEntry?.value), rxjs.distinctUntilChanged())));
|
|
@@ -1236,6 +1489,7 @@ function createCollectionConnectable(subject, subjects, createPayload) {
|
|
|
1236
1489
|
}
|
|
1237
1490
|
|
|
1238
1491
|
// src/observable/internal/base-list/removeDuplicates.ts
|
|
1492
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1239
1493
|
function removeDuplicates(objectCacheKeys, batch) {
|
|
1240
1494
|
const visited = /* @__PURE__ */ new Set();
|
|
1241
1495
|
return objectCacheKeys.filter((key) => {
|
|
@@ -1259,7 +1513,7 @@ var BaseListQuery = class extends Query {
|
|
|
1259
1513
|
* Get RDP configuration from the cache key
|
|
1260
1514
|
*/
|
|
1261
1515
|
get rdpConfig() {
|
|
1262
|
-
return this.cacheKey.otherKeys[
|
|
1516
|
+
return this.cacheKey.otherKeys[RDP_IDX2];
|
|
1263
1517
|
}
|
|
1264
1518
|
// Collection-specific behavior is implemented by subclasses
|
|
1265
1519
|
/**
|
|
@@ -1722,7 +1976,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1722
1976
|
batch.changes.modified.add(this.cacheKey);
|
|
1723
1977
|
}
|
|
1724
1978
|
constructor(store, subject, cacheKey, opts) {
|
|
1725
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1979
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
1726
1980
|
msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1727
1981
|
}) : void 0);
|
|
1728
1982
|
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
@@ -1739,7 +1993,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1739
1993
|
type: "object",
|
|
1740
1994
|
apiName: this.#sourceApiName
|
|
1741
1995
|
};
|
|
1742
|
-
const sourceMetadata = await client[
|
|
1996
|
+
const sourceMetadata = await client[chunkDZE6IAUU_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1743
1997
|
const sourceQuery = client(sourceObjectDef).where({
|
|
1744
1998
|
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
1745
1999
|
});
|
|
@@ -1803,7 +2057,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1803
2057
|
return this.revalidate(true);
|
|
1804
2058
|
} else {
|
|
1805
2059
|
return (async () => {
|
|
1806
|
-
const sourceMetadata = await this.store.client[
|
|
2060
|
+
const sourceMetadata = await this.store.client[chunkDZE6IAUU_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1807
2061
|
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
1808
2062
|
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
1809
2063
|
const promise = this.revalidate(true);
|
|
@@ -1821,9 +2075,6 @@ var LinksHelper = class extends AbstractHelper {
|
|
|
1821
2075
|
this.whereCanonicalizer = whereCanonicalizer2;
|
|
1822
2076
|
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
1823
2077
|
}
|
|
1824
|
-
observe(options, subFn) {
|
|
1825
|
-
return super.observe(options, subFn);
|
|
1826
|
-
}
|
|
1827
2078
|
getQuery(options) {
|
|
1828
2079
|
const {
|
|
1829
2080
|
apiName
|
|
@@ -1836,6 +2087,21 @@ var LinksHelper = class extends AbstractHelper {
|
|
|
1836
2087
|
});
|
|
1837
2088
|
}
|
|
1838
2089
|
};
|
|
2090
|
+
|
|
2091
|
+
// src/observable/internal/list/ListsHelper.ts
|
|
2092
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2093
|
+
|
|
2094
|
+
// src/observable/internal/list/InterfaceListQuery.ts
|
|
2095
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2096
|
+
|
|
2097
|
+
// src/observable/internal/list/ListQuery.ts
|
|
2098
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2099
|
+
|
|
2100
|
+
// src/observable/internal/objectMatchesWhereClause.ts
|
|
2101
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2102
|
+
|
|
2103
|
+
// src/observable/internal/evaluateFilter.ts
|
|
2104
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
1839
2105
|
function evaluateFilter(f, realValue, expected, strict) {
|
|
1840
2106
|
switch (f) {
|
|
1841
2107
|
case "$eq":
|
|
@@ -1933,6 +2199,8 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1933
2199
|
#whereClause;
|
|
1934
2200
|
// Using base class minResultsToLoad instead of a private property
|
|
1935
2201
|
#orderBy;
|
|
2202
|
+
#intersectWith;
|
|
2203
|
+
#pivotInfo;
|
|
1936
2204
|
#objectSet;
|
|
1937
2205
|
/**
|
|
1938
2206
|
* Register changes to the cache specific to ListQuery
|
|
@@ -1941,12 +2209,14 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1941
2209
|
batch.changes.registerList(this.cacheKey);
|
|
1942
2210
|
}
|
|
1943
2211
|
constructor(store, subject, apiName, cacheKey, opts) {
|
|
1944
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
2212
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
1945
2213
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1946
2214
|
}) : void 0);
|
|
1947
2215
|
this.apiName = apiName;
|
|
1948
|
-
this.#whereClause = cacheKey.otherKeys[
|
|
2216
|
+
this.#whereClause = cacheKey.otherKeys[WHERE_IDX2];
|
|
1949
2217
|
this.#orderBy = cacheKey.otherKeys[ORDER_BY_IDX];
|
|
2218
|
+
this.#intersectWith = cacheKey.otherKeys[INTERSECT_IDX];
|
|
2219
|
+
this.#pivotInfo = cacheKey.otherKeys[PIVOT_IDX];
|
|
1950
2220
|
this.#objectSet = this.createObjectSet(store);
|
|
1951
2221
|
this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
|
|
1952
2222
|
this.minResultsToLoad = 0;
|
|
@@ -1954,6 +2224,12 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1954
2224
|
get canonicalWhere() {
|
|
1955
2225
|
return this.#whereClause;
|
|
1956
2226
|
}
|
|
2227
|
+
get canonicalIntersectWith() {
|
|
2228
|
+
return this.#intersectWith;
|
|
2229
|
+
}
|
|
2230
|
+
get canonicalPivotInfo() {
|
|
2231
|
+
return this.#pivotInfo;
|
|
2232
|
+
}
|
|
1957
2233
|
/**
|
|
1958
2234
|
* Create the ObjectSet for this query.
|
|
1959
2235
|
*/
|
|
@@ -2179,7 +2455,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
2179
2455
|
// src/observable/internal/list/InterfaceListQuery.ts
|
|
2180
2456
|
var InterfaceListQuery = class extends ListQuery {
|
|
2181
2457
|
createObjectSet(store) {
|
|
2182
|
-
const rdpConfig = this.cacheKey.otherKeys[
|
|
2458
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
|
|
2183
2459
|
const type = "interface";
|
|
2184
2460
|
const objectTypeDef = {
|
|
2185
2461
|
type,
|
|
@@ -2207,7 +2483,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
2207
2483
|
}
|
|
2208
2484
|
extractRelevantObjects(changes) {
|
|
2209
2485
|
const matchesApiName = ([, object]) => {
|
|
2210
|
-
return this.apiName in object[
|
|
2486
|
+
return this.apiName in object[chunkS4JPAF56_cjs.ObjectDefRef].interfaceMap;
|
|
2211
2487
|
};
|
|
2212
2488
|
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
2213
2489
|
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
@@ -2228,7 +2504,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
2228
2504
|
async function reloadDataAsFullObjects(client, data) {
|
|
2229
2505
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
2230
2506
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
2231
|
-
const objectDef = objects[0][
|
|
2507
|
+
const objectDef = objects[0][chunkS4JPAF56_cjs.UnderlyingOsdkObject][chunkS4JPAF56_cjs.ObjectDefRef];
|
|
2232
2508
|
const where = {
|
|
2233
2509
|
[objectDef.primaryKeyApiName]: {
|
|
2234
2510
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -2245,19 +2521,59 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
2245
2521
|
}
|
|
2246
2522
|
|
|
2247
2523
|
// src/observable/internal/list/ObjectListQuery.ts
|
|
2524
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2248
2525
|
var ObjectListQuery = class extends ListQuery {
|
|
2249
2526
|
createObjectSet(store) {
|
|
2250
|
-
const rdpConfig = this.cacheKey.otherKeys[
|
|
2251
|
-
|
|
2252
|
-
|
|
2527
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
|
|
2528
|
+
const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];
|
|
2529
|
+
const pivotInfo = this.cacheKey.otherKeys[PIVOT_IDX];
|
|
2530
|
+
if (pivotInfo != null) {
|
|
2531
|
+
const sourceSet = store.client({
|
|
2253
2532
|
type: "object",
|
|
2254
|
-
apiName:
|
|
2255
|
-
})
|
|
2533
|
+
apiName: pivotInfo.sourceType
|
|
2534
|
+
});
|
|
2535
|
+
let objectSet2 = sourceSet.pivotTo(pivotInfo.linkName);
|
|
2536
|
+
if (rdpConfig != null) {
|
|
2537
|
+
objectSet2 = objectSet2.withProperties(rdpConfig);
|
|
2538
|
+
}
|
|
2539
|
+
objectSet2 = objectSet2.where(this.canonicalWhere);
|
|
2540
|
+
if (intersectWith != null && intersectWith.length > 0) {
|
|
2541
|
+
const intersectSets = intersectWith.map((whereClause) => {
|
|
2542
|
+
let intersectSet = store.client({
|
|
2543
|
+
type: "object",
|
|
2544
|
+
apiName: pivotInfo.targetType
|
|
2545
|
+
});
|
|
2546
|
+
if (rdpConfig != null) {
|
|
2547
|
+
intersectSet = intersectSet.withProperties(rdpConfig);
|
|
2548
|
+
}
|
|
2549
|
+
return intersectSet.where(whereClause);
|
|
2550
|
+
});
|
|
2551
|
+
objectSet2 = objectSet2.intersect(...intersectSets);
|
|
2552
|
+
}
|
|
2553
|
+
return objectSet2;
|
|
2256
2554
|
}
|
|
2257
|
-
|
|
2555
|
+
let objectSet = store.client({
|
|
2258
2556
|
type: "object",
|
|
2259
2557
|
apiName: this.apiName
|
|
2260
|
-
})
|
|
2558
|
+
});
|
|
2559
|
+
if (rdpConfig != null) {
|
|
2560
|
+
objectSet = objectSet.withProperties(rdpConfig);
|
|
2561
|
+
}
|
|
2562
|
+
objectSet = objectSet.where(this.canonicalWhere);
|
|
2563
|
+
if (intersectWith != null && intersectWith.length > 0) {
|
|
2564
|
+
const intersectSets = intersectWith.map((whereClause) => {
|
|
2565
|
+
let intersectSet = store.client({
|
|
2566
|
+
type: "object",
|
|
2567
|
+
apiName: this.apiName
|
|
2568
|
+
});
|
|
2569
|
+
if (rdpConfig != null) {
|
|
2570
|
+
intersectSet = intersectSet.withProperties(rdpConfig);
|
|
2571
|
+
}
|
|
2572
|
+
return intersectSet.where(whereClause);
|
|
2573
|
+
});
|
|
2574
|
+
objectSet = objectSet.intersect(...intersectSets);
|
|
2575
|
+
}
|
|
2576
|
+
return objectSet;
|
|
2261
2577
|
}
|
|
2262
2578
|
async revalidateObjectType(apiName) {
|
|
2263
2579
|
if (this.apiName === apiName) {
|
|
@@ -2273,12 +2589,12 @@ var ObjectListQuery = class extends ListQuery {
|
|
|
2273
2589
|
extractRelevantObjects(changes) {
|
|
2274
2590
|
return {
|
|
2275
2591
|
added: {
|
|
2276
|
-
all: changes.addedObjects.get(this.cacheKey.otherKeys[
|
|
2592
|
+
all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX2]) ?? [],
|
|
2277
2593
|
strictMatches: /* @__PURE__ */ new Set(),
|
|
2278
2594
|
sortaMatches: /* @__PURE__ */ new Set()
|
|
2279
2595
|
},
|
|
2280
2596
|
modified: {
|
|
2281
|
-
all: changes.modifiedObjects.get(this.cacheKey.otherKeys[
|
|
2597
|
+
all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX2]) ?? [],
|
|
2282
2598
|
strictMatches: /* @__PURE__ */ new Set(),
|
|
2283
2599
|
sortaMatches: /* @__PURE__ */ new Set()
|
|
2284
2600
|
}
|
|
@@ -2288,11 +2604,13 @@ var ObjectListQuery = class extends ListQuery {
|
|
|
2288
2604
|
|
|
2289
2605
|
// src/observable/internal/list/ListsHelper.ts
|
|
2290
2606
|
var ListsHelper = class extends AbstractHelper {
|
|
2291
|
-
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer) {
|
|
2607
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer, intersectCanonicalizer, pivotCanonicalizer) {
|
|
2292
2608
|
super(store, cacheKeys);
|
|
2293
2609
|
this.whereCanonicalizer = whereCanonicalizer2;
|
|
2294
2610
|
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
2295
2611
|
this.rdpCanonicalizer = rdpCanonicalizer;
|
|
2612
|
+
this.intersectCanonicalizer = intersectCanonicalizer;
|
|
2613
|
+
this.pivotCanonicalizer = pivotCanonicalizer;
|
|
2296
2614
|
}
|
|
2297
2615
|
observe(options, subFn) {
|
|
2298
2616
|
const ret = super.observe(options, subFn);
|
|
@@ -2306,7 +2624,9 @@ var ListsHelper = class extends AbstractHelper {
|
|
|
2306
2624
|
type: typeDefinition,
|
|
2307
2625
|
where,
|
|
2308
2626
|
orderBy,
|
|
2309
|
-
withProperties
|
|
2627
|
+
withProperties,
|
|
2628
|
+
intersectWith,
|
|
2629
|
+
pivotTo
|
|
2310
2630
|
} = options;
|
|
2311
2631
|
const {
|
|
2312
2632
|
apiName,
|
|
@@ -2315,7 +2635,9 @@ var ListsHelper = class extends AbstractHelper {
|
|
|
2315
2635
|
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
2316
2636
|
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
2317
2637
|
const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
|
|
2318
|
-
const
|
|
2638
|
+
const canonIntersect = intersectWith && intersectWith.length > 0 ? this.intersectCanonicalizer.canonicalize(intersectWith) : void 0;
|
|
2639
|
+
const canonPivot = pivotTo ? this.pivotCanonicalizer.canonicalize(apiName, pivotTo) : void 0;
|
|
2640
|
+
const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy, canonRdp, canonIntersect, canonPivot);
|
|
2319
2641
|
return this.store.queries.get(listCacheKey, () => {
|
|
2320
2642
|
const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
|
|
2321
2643
|
return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, listCacheKey, options);
|
|
@@ -2324,10 +2646,15 @@ var ListsHelper = class extends AbstractHelper {
|
|
|
2324
2646
|
};
|
|
2325
2647
|
|
|
2326
2648
|
// src/observable/internal/object/ObjectCacheKey.ts
|
|
2327
|
-
|
|
2649
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2650
|
+
var API_NAME_IDX3 = 0;
|
|
2328
2651
|
var RDP_CONFIG_IDX = 2;
|
|
2329
2652
|
|
|
2653
|
+
// src/observable/internal/object/ObjectCacheKeyRegistry.ts
|
|
2654
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2655
|
+
|
|
2330
2656
|
// src/observable/internal/utils/rdpFieldOperations.ts
|
|
2657
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2331
2658
|
function extractRdpFieldNames(rdpConfig) {
|
|
2332
2659
|
if (!rdpConfig) {
|
|
2333
2660
|
return /* @__PURE__ */ new Set();
|
|
@@ -2494,7 +2821,17 @@ var ObjectCacheKeyRegistry = class {
|
|
|
2494
2821
|
}
|
|
2495
2822
|
};
|
|
2496
2823
|
|
|
2824
|
+
// src/observable/internal/object/ObjectsHelper.ts
|
|
2825
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2826
|
+
|
|
2827
|
+
// src/observable/internal/object/ObjectQuery.ts
|
|
2828
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2829
|
+
|
|
2830
|
+
// src/observable/internal/BulkObjectLoader.ts
|
|
2831
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2832
|
+
|
|
2497
2833
|
// ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
|
|
2834
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2498
2835
|
function pDefer() {
|
|
2499
2836
|
const deferred = {};
|
|
2500
2837
|
deferred.promise = new Promise((resolve, reject) => {
|
|
@@ -2520,7 +2857,7 @@ var BulkObjectLoader = class {
|
|
|
2520
2857
|
#maxEntries;
|
|
2521
2858
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
2522
2859
|
this.#client = client;
|
|
2523
|
-
this.#logger = client[
|
|
2860
|
+
this.#logger = client[chunkDZE6IAUU_cjs.additionalContext].logger;
|
|
2524
2861
|
this.#maxWait = maxWait;
|
|
2525
2862
|
this.#maxEntries = maxEntries;
|
|
2526
2863
|
}
|
|
@@ -2588,7 +2925,7 @@ var ObjectQuery = class extends Query {
|
|
|
2588
2925
|
#apiName;
|
|
2589
2926
|
#pk;
|
|
2590
2927
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
2591
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
2928
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
2592
2929
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2593
2930
|
}) : void 0);
|
|
2594
2931
|
this.#apiName = type;
|
|
@@ -2725,14 +3062,18 @@ var ObjectsHelper = class extends AbstractHelper {
|
|
|
2725
3062
|
}
|
|
2726
3063
|
};
|
|
2727
3064
|
|
|
3065
|
+
// src/observable/internal/objectset/ObjectSetHelper.ts
|
|
3066
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
3067
|
+
|
|
2728
3068
|
// src/observable/internal/objectset/ObjectSetQuery.ts
|
|
3069
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2729
3070
|
var ObjectSetQuery = class extends BaseListQuery {
|
|
2730
3071
|
#baseObjectSetWire;
|
|
2731
3072
|
#operations;
|
|
2732
3073
|
#composedObjectSet;
|
|
2733
3074
|
#objectTypes;
|
|
2734
3075
|
constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
|
|
2735
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
3076
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
2736
3077
|
msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2737
3078
|
}) : void 0);
|
|
2738
3079
|
this.#baseObjectSetWire = baseObjectSetWire;
|
|
@@ -2775,7 +3116,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2775
3116
|
}
|
|
2776
3117
|
if (opts.union) {
|
|
2777
3118
|
for (const os of opts.union) {
|
|
2778
|
-
const wire =
|
|
3119
|
+
const wire = chunkDZE6IAUU_cjs.getWireObjectSet(os);
|
|
2779
3120
|
if (wire.type) {
|
|
2780
3121
|
types.add(wire.type);
|
|
2781
3122
|
}
|
|
@@ -2783,7 +3124,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2783
3124
|
}
|
|
2784
3125
|
if (opts.intersect) {
|
|
2785
3126
|
for (const os of opts.intersect) {
|
|
2786
|
-
const wire =
|
|
3127
|
+
const wire = chunkDZE6IAUU_cjs.getWireObjectSet(os);
|
|
2787
3128
|
if (wire.type) {
|
|
2788
3129
|
types.add(wire.type);
|
|
2789
3130
|
}
|
|
@@ -2791,7 +3132,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2791
3132
|
}
|
|
2792
3133
|
if (opts.subtract) {
|
|
2793
3134
|
for (const os of opts.subtract) {
|
|
2794
|
-
const wire =
|
|
3135
|
+
const wire = chunkDZE6IAUU_cjs.getWireObjectSet(os);
|
|
2795
3136
|
if (wire.type) {
|
|
2796
3137
|
types.add(wire.type);
|
|
2797
3138
|
}
|
|
@@ -2872,7 +3213,7 @@ var ObjectSetHelper = class extends AbstractHelper {
|
|
|
2872
3213
|
const {
|
|
2873
3214
|
baseObjectSet
|
|
2874
3215
|
} = options;
|
|
2875
|
-
const baseObjectSetWire = JSON.stringify(
|
|
3216
|
+
const baseObjectSetWire = JSON.stringify(chunkDZE6IAUU_cjs.getWireObjectSet(baseObjectSet));
|
|
2876
3217
|
const operations = this.buildCanonicalizedOperations(options);
|
|
2877
3218
|
const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
|
|
2878
3219
|
return this.store.queries.get(objectSetCacheKey, () => {
|
|
@@ -2888,13 +3229,13 @@ var ObjectSetHelper = class extends AbstractHelper {
|
|
|
2888
3229
|
operations.withProperties = Object.keys(options.withProperties).sort();
|
|
2889
3230
|
}
|
|
2890
3231
|
if (options.union && options.union.length > 0) {
|
|
2891
|
-
operations.union = options.union.map((os) => JSON.stringify(
|
|
3232
|
+
operations.union = options.union.map((os) => JSON.stringify(chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
2892
3233
|
}
|
|
2893
3234
|
if (options.intersect && options.intersect.length > 0) {
|
|
2894
|
-
operations.intersect = options.intersect.map((os) => JSON.stringify(
|
|
3235
|
+
operations.intersect = options.intersect.map((os) => JSON.stringify(chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
2895
3236
|
}
|
|
2896
3237
|
if (options.subtract && options.subtract.length > 0) {
|
|
2897
|
-
operations.subtract = options.subtract.map((os) => JSON.stringify(
|
|
3238
|
+
operations.subtract = options.subtract.map((os) => JSON.stringify(chunkDZE6IAUU_cjs.getWireObjectSet(os)));
|
|
2898
3239
|
}
|
|
2899
3240
|
if (options.pivotTo) {
|
|
2900
3241
|
operations.pivotTo = options.pivotTo;
|
|
@@ -2909,7 +3250,27 @@ var ObjectSetHelper = class extends AbstractHelper {
|
|
|
2909
3250
|
}
|
|
2910
3251
|
};
|
|
2911
3252
|
|
|
3253
|
+
// src/observable/internal/PivotCanonicalizer.ts
|
|
3254
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
3255
|
+
var PivotCanonicalizer = class {
|
|
3256
|
+
#cache = /* @__PURE__ */ new Map();
|
|
3257
|
+
canonicalize(sourceType, linkName) {
|
|
3258
|
+
const key = `${sourceType}::${linkName}`;
|
|
3259
|
+
let canonical = this.#cache.get(key);
|
|
3260
|
+
if (!canonical) {
|
|
3261
|
+
canonical = {
|
|
3262
|
+
sourceType,
|
|
3263
|
+
linkName,
|
|
3264
|
+
targetType: "<targetType>"
|
|
3265
|
+
};
|
|
3266
|
+
this.#cache.set(key, canonical);
|
|
3267
|
+
}
|
|
3268
|
+
return canonical;
|
|
3269
|
+
}
|
|
3270
|
+
};
|
|
3271
|
+
|
|
2912
3272
|
// src/observable/internal/Queries.ts
|
|
3273
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2913
3274
|
var Queries = class {
|
|
2914
3275
|
// we can use a regular Map here because the refCounting will
|
|
2915
3276
|
// handle cleanup.
|
|
@@ -2934,33 +3295,8 @@ var Queries = class {
|
|
|
2934
3295
|
}
|
|
2935
3296
|
};
|
|
2936
3297
|
|
|
2937
|
-
// src/observable/internal/Canonicalizer.ts
|
|
2938
|
-
var CachingCanonicalizer = class {
|
|
2939
|
-
/**
|
|
2940
|
-
* Cache for input object identity.
|
|
2941
|
-
*/
|
|
2942
|
-
inputCache = /* @__PURE__ */ new WeakMap();
|
|
2943
|
-
/**
|
|
2944
|
-
* Look up or create a canonical form for the given input.
|
|
2945
|
-
* This method handles the structural deduplication logic.
|
|
2946
|
-
*
|
|
2947
|
-
* @param input The input to canonicalize
|
|
2948
|
-
* @returns The canonical form
|
|
2949
|
-
*/
|
|
2950
|
-
canonicalize(input) {
|
|
2951
|
-
if (!input) {
|
|
2952
|
-
return void 0;
|
|
2953
|
-
}
|
|
2954
|
-
if (this.inputCache.has(input)) {
|
|
2955
|
-
return this.inputCache.get(input);
|
|
2956
|
-
}
|
|
2957
|
-
const canonical = this.lookupOrCreate(input);
|
|
2958
|
-
this.inputCache.set(input, canonical);
|
|
2959
|
-
return canonical;
|
|
2960
|
-
}
|
|
2961
|
-
};
|
|
2962
|
-
|
|
2963
3298
|
// src/observable/internal/RdpCanonicalizer.ts
|
|
3299
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
2964
3300
|
var RdpCanonicalizer = class extends CachingCanonicalizer {
|
|
2965
3301
|
structuralCache = /* @__PURE__ */ new Map();
|
|
2966
3302
|
lookupOrCreate(rdp) {
|
|
@@ -2971,7 +3307,7 @@ var RdpCanonicalizer = class extends CachingCanonicalizer {
|
|
|
2971
3307
|
apiName: "__rdp_canonicalizer_holder__"
|
|
2972
3308
|
};
|
|
2973
3309
|
for (const [key, rdpFunction] of Object.entries(rdp)) {
|
|
2974
|
-
const builder =
|
|
3310
|
+
const builder = chunkDZE6IAUU_cjs.createWithPropertiesObjectSet(
|
|
2975
3311
|
objectTypeHolder,
|
|
2976
3312
|
{
|
|
2977
3313
|
type: "methodInput"
|
|
@@ -3010,6 +3346,8 @@ var Store = class {
|
|
|
3010
3346
|
whereCanonicalizer = new WhereClauseCanonicalizer();
|
|
3011
3347
|
orderByCanonicalizer = new OrderByCanonicalizer();
|
|
3012
3348
|
rdpCanonicalizer = new RdpCanonicalizer();
|
|
3349
|
+
intersectCanonicalizer = new IntersectCanonicalizer(this.whereCanonicalizer);
|
|
3350
|
+
pivotCanonicalizer = new PivotCanonicalizer();
|
|
3013
3351
|
/** @internal */
|
|
3014
3352
|
queries = new Queries();
|
|
3015
3353
|
objectCacheKeyRegistry = new ObjectCacheKeyRegistry();
|
|
@@ -3020,14 +3358,15 @@ var Store = class {
|
|
|
3020
3358
|
subjects = this.layers.subjects;
|
|
3021
3359
|
// these are hopefully temporary
|
|
3022
3360
|
constructor(client) {
|
|
3023
|
-
this.logger = client[
|
|
3361
|
+
this.logger = client[chunkDZE6IAUU_cjs.additionalContext].logger?.child({}, {
|
|
3024
3362
|
msgPrefix: "Store"
|
|
3025
3363
|
});
|
|
3026
3364
|
this.client = client;
|
|
3027
3365
|
this.cacheKeys = new CacheKeys({
|
|
3028
3366
|
onDestroy: this.#cleanupCacheKey
|
|
3029
3367
|
});
|
|
3030
|
-
this.
|
|
3368
|
+
this.aggregations = new AggregationsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.rdpCanonicalizer);
|
|
3369
|
+
this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer, this.pivotCanonicalizer);
|
|
3031
3370
|
this.objects = new ObjectsHelper(this, this.cacheKeys);
|
|
3032
3371
|
this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
3033
3372
|
this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
@@ -3182,13 +3521,15 @@ var Store = class {
|
|
|
3182
3521
|
* Extracts RDP configuration from a cache key if present.
|
|
3183
3522
|
*
|
|
3184
3523
|
* @param cacheKey - The cache key to check
|
|
3185
|
-
* @returns The RDP configuration, or undefined
|
|
3524
|
+
* @returns The RDP configuration, null, or undefined
|
|
3186
3525
|
*/
|
|
3187
3526
|
#getQueryRdpConfig(cacheKey) {
|
|
3188
3527
|
if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
|
|
3189
3528
|
if (cacheKey.type === "object") {
|
|
3190
3529
|
return cacheKey.otherKeys[RDP_CONFIG_IDX];
|
|
3191
3530
|
} else if (cacheKey.type === "list") {
|
|
3531
|
+
return cacheKey.otherKeys[RDP_IDX2];
|
|
3532
|
+
} else if (cacheKey.type === "aggregation") {
|
|
3192
3533
|
return cacheKey.otherKeys[RDP_IDX];
|
|
3193
3534
|
}
|
|
3194
3535
|
}
|
|
@@ -3203,8 +3544,10 @@ var Store = class {
|
|
|
3203
3544
|
#getQueryObjectType(cacheKey) {
|
|
3204
3545
|
if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
|
|
3205
3546
|
if (cacheKey.type === "object") {
|
|
3206
|
-
return cacheKey.otherKeys[
|
|
3547
|
+
return cacheKey.otherKeys[API_NAME_IDX3];
|
|
3207
3548
|
} else if (cacheKey.type === "list") {
|
|
3549
|
+
return cacheKey.otherKeys[API_NAME_IDX2];
|
|
3550
|
+
} else if (cacheKey.type === "aggregation") {
|
|
3208
3551
|
return cacheKey.otherKeys[API_NAME_IDX];
|
|
3209
3552
|
}
|
|
3210
3553
|
}
|
|
@@ -3281,10 +3624,10 @@ var Store = class {
|
|
|
3281
3624
|
|
|
3282
3625
|
// src/observable/ObservableClient.ts
|
|
3283
3626
|
function createObservableClient(client) {
|
|
3284
|
-
const tweakedClient =
|
|
3285
|
-
...client[
|
|
3286
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
3287
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
3627
|
+
const tweakedClient = chunkS4JPAF56_cjs.createClientFromContext({
|
|
3628
|
+
...client[chunkDZE6IAUU_cjs.additionalContext],
|
|
3629
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkDZE6IAUU_cjs.additionalContext].fetch, (headers) => {
|
|
3630
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkS4JPAF56_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
3288
3631
|
return headers;
|
|
3289
3632
|
})
|
|
3290
3633
|
});
|
|
@@ -3292,6 +3635,7 @@ function createObservableClient(client) {
|
|
|
3292
3635
|
}
|
|
3293
3636
|
|
|
3294
3637
|
// src/public-utils/osdkConfig.ts
|
|
3638
|
+
chunk6SCDLAU2_cjs.init_cjs_shims();
|
|
3295
3639
|
function getMetaTagContent(name) {
|
|
3296
3640
|
const element = document.querySelector(`meta[name="${name}"]`);
|
|
3297
3641
|
const val = element ? element.getAttribute("content") : null;
|
|
@@ -3327,11 +3671,11 @@ function getOsdkConfig(ontologyRid) {
|
|
|
3327
3671
|
|
|
3328
3672
|
Object.defineProperty(exports, "createClientWithTransaction", {
|
|
3329
3673
|
enumerable: true,
|
|
3330
|
-
get: function () { return
|
|
3674
|
+
get: function () { return chunkS4JPAF56_cjs.createClientWithTransaction; }
|
|
3331
3675
|
});
|
|
3332
3676
|
Object.defineProperty(exports, "augment", {
|
|
3333
3677
|
enumerable: true,
|
|
3334
|
-
get: function () { return
|
|
3678
|
+
get: function () { return chunkDZE6IAUU_cjs.augment; }
|
|
3335
3679
|
});
|
|
3336
3680
|
exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
|
|
3337
3681
|
exports.createObservableClient = createObservableClient;
|