@osdk/client 2.5.0-beta.8 → 2.6.0-beta.1
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 +86 -0
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/createMinimalClient.js +2 -1
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +4 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +5 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +77 -29
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +35 -1
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +11 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ObjectSetPayload.js +2 -0
- package/build/browser/observable/ObjectSetPayload.js.map +1 -0
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/computeObjectSetCacheKey.js +64 -0
- package/build/browser/observable/computeObjectSetCacheKey.js.map +1 -0
- package/build/browser/observable/internal/Changes.js +3 -0
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +17 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/Query.js +18 -1
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/Store.invalidation.test.js +165 -0
- package/build/browser/observable/internal/Store.invalidation.test.js.map +1 -1
- package/build/browser/observable/internal/Store.js +23 -0
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/browser/observable/internal/list/ListQuery.js +33 -108
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js +4 -2
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
- package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js +69 -0
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +151 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
- package/build/browser/observable/internal/testUtils.js +2 -1
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/queries/applyQuery.js +5 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/exponentialBackoff.js +51 -0
- package/build/browser/util/exponentialBackoff.js.map +1 -0
- package/build/browser/util/exponentialBackoff.test.js +81 -0
- package/build/browser/util/exponentialBackoff.test.js.map +1 -0
- package/build/browser/util/extractObjectOrInterfaceType.js +5 -1
- package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/cjs/{chunk-XCZOFC4A.cjs → chunk-BP7BR5FZ.cjs} +61 -59
- package/build/cjs/chunk-BP7BR5FZ.cjs.map +1 -0
- package/build/cjs/{chunk-5KDG5ZET.cjs → chunk-DCEFUXFS.cjs} +341 -229
- package/build/cjs/chunk-DCEFUXFS.cjs.map +1 -0
- package/build/cjs/index.cjs +11 -7
- package/build/cjs/index.d.cts +8 -1
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +536 -240
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +78 -6
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/createMinimalClient.js +2 -1
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +4 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +5 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +77 -29
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +35 -1
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +11 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ObjectSetPayload.js +2 -0
- package/build/esm/observable/ObjectSetPayload.js.map +1 -0
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/computeObjectSetCacheKey.js +64 -0
- package/build/esm/observable/computeObjectSetCacheKey.js.map +1 -0
- package/build/esm/observable/internal/Changes.js +3 -0
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +17 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/Query.js +18 -1
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/Store.invalidation.test.js +165 -0
- package/build/esm/observable/internal/Store.invalidation.test.js.map +1 -1
- package/build/esm/observable/internal/Store.js +23 -0
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/esm/observable/internal/list/ListQuery.js +33 -108
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js +4 -2
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
- package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js +69 -0
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +151 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
- package/build/esm/observable/internal/testUtils.js +2 -1
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.js +5 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/exponentialBackoff.js +51 -0
- package/build/esm/util/exponentialBackoff.js.map +1 -0
- package/build/esm/util/exponentialBackoff.test.js +81 -0
- package/build/esm/util/exponentialBackoff.test.js.map +1 -0
- package/build/esm/util/extractObjectOrInterfaceType.js +5 -1
- package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -0
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/observable/ObjectSetPayload.d.ts +5 -0
- package/build/types/observable/ObjectSetPayload.d.ts.map +1 -0
- package/build/types/observable/ObservableClient.d.ts +54 -1
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/computeObjectSetCacheKey.d.ts +16 -0
- package/build/types/observable/computeObjectSetCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/Changes.d.ts +5 -3
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- 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/Query.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +5 -1
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQuery.d.ts +37 -6
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ObjectListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +16 -0
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +19 -0
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +34 -0
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +18 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +2 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/build/types/util/exponentialBackoff.d.ts +14 -0
- package/build/types/util/exponentialBackoff.d.ts.map +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts.map +1 -0
- package/package.json +11 -11
- package/build/cjs/chunk-5KDG5ZET.cjs.map +0 -1
- package/build/cjs/chunk-XCZOFC4A.cjs.map +0 -1
|
@@ -1,23 +1,179 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkBP7BR5FZ_cjs = require('../chunk-BP7BR5FZ.cjs');
|
|
4
|
+
var chunkDCEFUXFS_cjs = require('../chunk-DCEFUXFS.cjs');
|
|
5
5
|
require('../chunk-Q7SFCCGT.cjs');
|
|
6
|
+
var trie = require('@wry/trie');
|
|
7
|
+
var deepEqual5 = require('fast-deep-equal');
|
|
8
|
+
var invariant3 = require('tiny-invariant');
|
|
6
9
|
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
7
10
|
var rxjs = require('rxjs');
|
|
8
|
-
var invariant2 = require('tiny-invariant');
|
|
9
|
-
var trie = require('@wry/trie');
|
|
10
11
|
var mnemonist = require('mnemonist');
|
|
11
|
-
var deepEqual4 = require('fast-deep-equal');
|
|
12
12
|
var groupBy = require('object.groupby');
|
|
13
13
|
var shared_net_errors = require('@osdk/shared.net.errors');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var deepEqual5__default = /*#__PURE__*/_interopDefault(deepEqual5);
|
|
18
|
+
var invariant3__default = /*#__PURE__*/_interopDefault(invariant3);
|
|
19
19
|
var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
|
|
20
20
|
|
|
21
|
+
var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
|
|
22
|
+
var WeakRefTrie = class {
|
|
23
|
+
#finalizer = new FinalizationRegistry((orderBy) => {
|
|
24
|
+
this.#trie.removeArray(Object.entries(orderBy).flat());
|
|
25
|
+
});
|
|
26
|
+
#trie;
|
|
27
|
+
constructor(makeData = defaultMakeData) {
|
|
28
|
+
this.#trie = new trie.Trie(false, (array) => {
|
|
29
|
+
const data = makeData(array);
|
|
30
|
+
this.#finalizer.register(data, array);
|
|
31
|
+
return new WeakRef(data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
lookupArray(array) {
|
|
35
|
+
const maybe = this.#trie.lookupArray(array);
|
|
36
|
+
let ret = maybe.deref();
|
|
37
|
+
if (maybe && !ret) {
|
|
38
|
+
this.#trie.removeArray(array);
|
|
39
|
+
ret = this.#trie.lookupArray(array).deref();
|
|
40
|
+
}
|
|
41
|
+
return ret;
|
|
42
|
+
}
|
|
43
|
+
peekArray(array) {
|
|
44
|
+
const maybe = this.#trie.peekArray(array);
|
|
45
|
+
const ret = maybe?.deref();
|
|
46
|
+
if (maybe && !ret) {
|
|
47
|
+
this.#trie.removeArray(array);
|
|
48
|
+
}
|
|
49
|
+
return ret;
|
|
50
|
+
}
|
|
51
|
+
removeArray(array) {
|
|
52
|
+
return this.#trie.removeArray(array)?.deref();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/observable/internal/OrderByCanonicalizer.ts
|
|
57
|
+
var OrderByCanonicalizer = class {
|
|
58
|
+
#trie = new WeakRefTrie((array) => {
|
|
59
|
+
const pairs = array.reduce(function(result, _, index, array2) {
|
|
60
|
+
if (index % 2 === 0 && array2[index] != null) {
|
|
61
|
+
result.push(array2.slice(index, index + 2));
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}, []);
|
|
65
|
+
let data = Object.fromEntries(pairs);
|
|
66
|
+
if (process.env.NODE_ENV !== "production") {
|
|
67
|
+
data = Object.freeze(data);
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
});
|
|
71
|
+
canonicalize = (orderBy) => {
|
|
72
|
+
const strings = Object.entries(orderBy).flat();
|
|
73
|
+
return this.#trie.lookupArray(strings);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var WhereClauseCanonicalizer = class {
|
|
77
|
+
/**
|
|
78
|
+
* This is a shortcut cache for any WhereClause's that we have
|
|
79
|
+
* seen and already canonicalized. The theory behind this
|
|
80
|
+
* is that well behaving React applications will either `useMemo`
|
|
81
|
+
* their where clause, or store it in state or pass it through as
|
|
82
|
+
* props such that we are likely to get the same WhereClause
|
|
83
|
+
* object multiple times and we can skip unnecessary work.
|
|
84
|
+
*/
|
|
85
|
+
#cache = /* @__PURE__ */ new WeakMap();
|
|
86
|
+
/**
|
|
87
|
+
* This is a trie that stores the sorted collapsed keys of a where clause to
|
|
88
|
+
* the cache key for canonicalized options. In theory this keeps the number of
|
|
89
|
+
* deepEqual comparisons down to a minimum but its probably overkill.
|
|
90
|
+
*/
|
|
91
|
+
#trie = new trie.Trie();
|
|
92
|
+
/**
|
|
93
|
+
* This is a cache from the cacheKey provided by `this.#trie` to the potential
|
|
94
|
+
* canonicalized options.
|
|
95
|
+
*/
|
|
96
|
+
#existingOptions = /* @__PURE__ */ new Map();
|
|
97
|
+
canonicalize(where) {
|
|
98
|
+
if (this.#cache.has(where)) {
|
|
99
|
+
return this.#cache.get(where);
|
|
100
|
+
}
|
|
101
|
+
const keysSet = /* @__PURE__ */ new Set();
|
|
102
|
+
const calculatedCanon = this.#toCanon(where, keysSet);
|
|
103
|
+
const cacheKey = this.#trie.lookupArray(Array.from(keysSet).sort());
|
|
104
|
+
const lookupEntry = this.#existingOptions.get(cacheKey) ?? {
|
|
105
|
+
options: []
|
|
106
|
+
};
|
|
107
|
+
this.#existingOptions.set(cacheKey, lookupEntry);
|
|
108
|
+
const canon = lookupEntry.options.find((ref) => deepEqual5__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
|
|
109
|
+
if (canon === calculatedCanon) {
|
|
110
|
+
lookupEntry.options.push(new WeakRef(canon));
|
|
111
|
+
}
|
|
112
|
+
this.#cache.set(where, canon);
|
|
113
|
+
return canon;
|
|
114
|
+
}
|
|
115
|
+
#toCanon = (where, set = /* @__PURE__ */ new Set()) => {
|
|
116
|
+
if ("$and" in where) {
|
|
117
|
+
if (process.env.NODE_ENV !== "production") {
|
|
118
|
+
!Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $and to be an array") : invariant3__default.default(false) : void 0;
|
|
119
|
+
!(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $and to be present") : invariant3__default.default(false) : void 0;
|
|
120
|
+
}
|
|
121
|
+
if (where.$and.length === 0) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
if (where.$and.length === 1) {
|
|
125
|
+
return this.#toCanon(where.$and[0], set);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return Object.fromEntries(Object.entries(where).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => {
|
|
129
|
+
set.add(k);
|
|
130
|
+
if (k === "$and" || k === "$or") {
|
|
131
|
+
return [k, v.map((x) => this.#toCanon(x, set))];
|
|
132
|
+
}
|
|
133
|
+
if (k !== "$not" && typeof v === "object" && "$eq" in v) {
|
|
134
|
+
return [k, v["$eq"]];
|
|
135
|
+
}
|
|
136
|
+
return [k, v];
|
|
137
|
+
}));
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/observable/computeObjectSetCacheKey.ts
|
|
142
|
+
var whereCanonicalizer = new WhereClauseCanonicalizer();
|
|
143
|
+
var orderByCanonicalizer = new OrderByCanonicalizer();
|
|
144
|
+
function computeObjectSetCacheKey(objectSet, options) {
|
|
145
|
+
const keyParts = ["objectSet", chunkDCEFUXFS_cjs.getWireObjectSet(objectSet)];
|
|
146
|
+
if (!options) {
|
|
147
|
+
return JSON.stringify(keyParts);
|
|
148
|
+
}
|
|
149
|
+
if (options.where) {
|
|
150
|
+
keyParts.push("where", whereCanonicalizer.canonicalize(options.where));
|
|
151
|
+
}
|
|
152
|
+
if (options.withProperties) {
|
|
153
|
+
const propKeys = Object.keys(options.withProperties).sort();
|
|
154
|
+
keyParts.push("props", propKeys);
|
|
155
|
+
}
|
|
156
|
+
if (options.union && options.union.length > 0) {
|
|
157
|
+
keyParts.push("union", options.union.map((os) => chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
158
|
+
}
|
|
159
|
+
if (options.intersect && options.intersect.length > 0) {
|
|
160
|
+
keyParts.push("intersect", options.intersect.map((os) => chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
161
|
+
}
|
|
162
|
+
if (options.subtract && options.subtract.length > 0) {
|
|
163
|
+
keyParts.push("subtract", options.subtract.map((os) => chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
164
|
+
}
|
|
165
|
+
if (options.pivotTo) {
|
|
166
|
+
keyParts.push("pivotTo", options.pivotTo);
|
|
167
|
+
}
|
|
168
|
+
if (options.orderBy) {
|
|
169
|
+
keyParts.push("orderBy", orderByCanonicalizer.canonicalize(options.orderBy));
|
|
170
|
+
}
|
|
171
|
+
if (options.pageSize) {
|
|
172
|
+
keyParts.push("pageSize", options.pageSize);
|
|
173
|
+
}
|
|
174
|
+
return JSON.stringify(keyParts);
|
|
175
|
+
}
|
|
176
|
+
|
|
21
177
|
// src/observable/internal/UnsubscribableWrapper.ts
|
|
22
178
|
var UnsubscribableWrapper = class {
|
|
23
179
|
#subscription;
|
|
@@ -75,6 +231,25 @@ var ObservableClientImpl = class {
|
|
|
75
231
|
}
|
|
76
232
|
return new UnsubscribableWrapper(parentSub);
|
|
77
233
|
};
|
|
234
|
+
observeObjectSet(baseObjectSet, options, subFn) {
|
|
235
|
+
return this.__experimentalStore.objectSets.observe(
|
|
236
|
+
{
|
|
237
|
+
baseObjectSet,
|
|
238
|
+
...options
|
|
239
|
+
},
|
|
240
|
+
// cast to cross typed to untyped barrier
|
|
241
|
+
subFn
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
invalidateAll() {
|
|
245
|
+
return this.__experimentalStore.invalidateAll();
|
|
246
|
+
}
|
|
247
|
+
invalidateObjects(objects) {
|
|
248
|
+
return this.__experimentalStore.invalidateObjects(objects);
|
|
249
|
+
}
|
|
250
|
+
invalidateObjectType(type) {
|
|
251
|
+
return this.__experimentalStore.invalidateObjectType(type, void 0);
|
|
252
|
+
}
|
|
78
253
|
canonicalizeWhereClause(where) {
|
|
79
254
|
return this.__experimentalStore.whereCanonicalizer.canonicalize(where);
|
|
80
255
|
}
|
|
@@ -144,7 +319,7 @@ var OptimisticJob = class {
|
|
|
144
319
|
return this;
|
|
145
320
|
},
|
|
146
321
|
createObject(type, pk, properties) {
|
|
147
|
-
const create = store.client[
|
|
322
|
+
const create = store.client[chunkDCEFUXFS_cjs.additionalContext].objectFactory2(store.client[chunkDCEFUXFS_cjs.additionalContext], [{
|
|
148
323
|
$primaryKey: pk,
|
|
149
324
|
$apiName: type.apiName,
|
|
150
325
|
$objectType: type.apiName,
|
|
@@ -407,6 +582,9 @@ var Changes = class {
|
|
|
407
582
|
deleteLink = (cacheKey) => {
|
|
408
583
|
this.deleted.add(cacheKey);
|
|
409
584
|
};
|
|
585
|
+
registerObjectSet = (key) => {
|
|
586
|
+
this.modified.add(key);
|
|
587
|
+
};
|
|
410
588
|
isEmpty() {
|
|
411
589
|
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
|
|
412
590
|
}
|
|
@@ -655,7 +833,7 @@ var Layers = class {
|
|
|
655
833
|
return this.#truthLayer;
|
|
656
834
|
}
|
|
657
835
|
remove(layerId) {
|
|
658
|
-
!(layerId != null) ? process.env.NODE_ENV !== "production" ?
|
|
836
|
+
!(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant3__default.default(false) : void 0;
|
|
659
837
|
let currentLayer = this.#topLayer;
|
|
660
838
|
const cacheKeys = /* @__PURE__ */ new Map();
|
|
661
839
|
while (currentLayer != null && currentLayer.parentLayer != null) {
|
|
@@ -683,7 +861,7 @@ var Layers = class {
|
|
|
683
861
|
optimisticId,
|
|
684
862
|
changes
|
|
685
863
|
}, batchFn) {
|
|
686
|
-
!(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ?
|
|
864
|
+
!(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "optimistic must be undefined or not falsy") : invariant3__default.default(false) : void 0;
|
|
687
865
|
const batchContext = this.#createBatchContext({
|
|
688
866
|
optimisticId,
|
|
689
867
|
changes
|
|
@@ -825,14 +1003,31 @@ var Query = class {
|
|
|
825
1003
|
this.store = store;
|
|
826
1004
|
this.cacheKeys = store.cacheKeys;
|
|
827
1005
|
this.#subject = observable;
|
|
828
|
-
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[
|
|
1006
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkDCEFUXFS_cjs.additionalContext].logger : store.client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
829
1007
|
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
830
1008
|
}));
|
|
831
1009
|
}
|
|
832
1010
|
subscribe(observer) {
|
|
833
1011
|
this.#connectable ??= this._createConnectable(this.#subject);
|
|
834
1012
|
this.#subscription = this.#connectable.connect();
|
|
835
|
-
|
|
1013
|
+
const sub = this.#connectable.subscribe({
|
|
1014
|
+
next: (value) => {
|
|
1015
|
+
if (observer.next) {
|
|
1016
|
+
observer.next(value);
|
|
1017
|
+
}
|
|
1018
|
+
},
|
|
1019
|
+
error: (err) => {
|
|
1020
|
+
if (observer.error) {
|
|
1021
|
+
observer.error(err);
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
complete: () => {
|
|
1025
|
+
if (observer.complete) {
|
|
1026
|
+
observer.complete();
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
return sub;
|
|
836
1031
|
}
|
|
837
1032
|
/**
|
|
838
1033
|
* Register a subscription's dedupeInterval value
|
|
@@ -1100,7 +1295,7 @@ var BaseListQuery = class extends Query {
|
|
|
1100
1295
|
*/
|
|
1101
1296
|
writeToStore(data, status, batch) {
|
|
1102
1297
|
const entry = batch.read(this.cacheKey);
|
|
1103
|
-
if (entry &&
|
|
1298
|
+
if (entry && deepEqual5__default.default(data, entry.value)) {
|
|
1104
1299
|
if (entry.status === status) {
|
|
1105
1300
|
if (process.env.NODE_ENV !== "production") {
|
|
1106
1301
|
this.logger?.child({
|
|
@@ -1381,7 +1576,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1381
1576
|
batch.changes.modified.add(this.cacheKey);
|
|
1382
1577
|
}
|
|
1383
1578
|
constructor(store, subject, cacheKey, opts) {
|
|
1384
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1579
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
1385
1580
|
msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1386
1581
|
}) : void 0);
|
|
1387
1582
|
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
@@ -1398,7 +1593,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1398
1593
|
type: "object",
|
|
1399
1594
|
apiName: this.#sourceApiName
|
|
1400
1595
|
};
|
|
1401
|
-
const sourceMetadata = await client[
|
|
1596
|
+
const sourceMetadata = await client[chunkDCEFUXFS_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1402
1597
|
const sourceQuery = client(sourceObjectDef).where({
|
|
1403
1598
|
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
1404
1599
|
});
|
|
@@ -1425,7 +1620,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1425
1620
|
*/
|
|
1426
1621
|
deleteFromStore(status, batch) {
|
|
1427
1622
|
const entry = batch.read(this.cacheKey);
|
|
1428
|
-
if (entry &&
|
|
1623
|
+
if (entry && deepEqual5__default.default(tombstone, entry.value)) {
|
|
1429
1624
|
if (process.env.NODE_ENV !== "production") {
|
|
1430
1625
|
this.logger?.child({
|
|
1431
1626
|
methodName: "deleteFromStore"
|
|
@@ -1462,7 +1657,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1462
1657
|
return this.revalidate(true);
|
|
1463
1658
|
} else {
|
|
1464
1659
|
return (async () => {
|
|
1465
|
-
const sourceMetadata = await this.store.client[
|
|
1660
|
+
const sourceMetadata = await this.store.client[chunkDCEFUXFS_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1466
1661
|
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
1467
1662
|
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
1468
1663
|
const promise = this.revalidate(true);
|
|
@@ -1475,10 +1670,10 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1475
1670
|
|
|
1476
1671
|
// src/observable/internal/links/LinksHelper.ts
|
|
1477
1672
|
var LinksHelper = class extends AbstractHelper {
|
|
1478
|
-
constructor(store, cacheKeys,
|
|
1673
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
|
|
1479
1674
|
super(store, cacheKeys);
|
|
1480
|
-
this.whereCanonicalizer =
|
|
1481
|
-
this.orderByCanonicalizer =
|
|
1675
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
1676
|
+
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
1482
1677
|
}
|
|
1483
1678
|
getQuery(options) {
|
|
1484
1679
|
const {
|
|
@@ -1495,8 +1690,8 @@ var LinksHelper = class extends AbstractHelper {
|
|
|
1495
1690
|
function is$and(whereClause) {
|
|
1496
1691
|
if (process.env.NODE_ENV !== "production") {
|
|
1497
1692
|
if ("$and" in whereClause) {
|
|
1498
|
-
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ?
|
|
1499
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1693
|
+
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $and to be an array") : invariant3__default.default(false) : void 0;
|
|
1694
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $and to be present") : invariant3__default.default(false) : void 0;
|
|
1500
1695
|
}
|
|
1501
1696
|
}
|
|
1502
1697
|
return "$and" in whereClause;
|
|
@@ -1504,8 +1699,8 @@ function is$and(whereClause) {
|
|
|
1504
1699
|
function is$or(whereClause) {
|
|
1505
1700
|
if (process.env.NODE_ENV !== "production") {
|
|
1506
1701
|
if ("$or" in whereClause) {
|
|
1507
|
-
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ?
|
|
1508
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1702
|
+
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $or to be an array") : invariant3__default.default(false) : void 0;
|
|
1703
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $or to be present") : invariant3__default.default(false) : void 0;
|
|
1509
1704
|
}
|
|
1510
1705
|
}
|
|
1511
1706
|
return "$or" in whereClause;
|
|
@@ -1513,13 +1708,13 @@ function is$or(whereClause) {
|
|
|
1513
1708
|
function is$not(whereClause) {
|
|
1514
1709
|
if (process.env.NODE_ENV !== "production") {
|
|
1515
1710
|
if ("$not" in whereClause) {
|
|
1516
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1711
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $not to be present") : invariant3__default.default(false) : void 0;
|
|
1517
1712
|
}
|
|
1518
1713
|
}
|
|
1519
1714
|
return "$not" in whereClause;
|
|
1520
1715
|
}
|
|
1521
1716
|
function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
1522
|
-
if (
|
|
1717
|
+
if (deepEqual5__default.default({}, whereClause)) {
|
|
1523
1718
|
return true;
|
|
1524
1719
|
}
|
|
1525
1720
|
if (is$and(whereClause)) {
|
|
@@ -1564,7 +1759,7 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
|
1564
1759
|
return !strict;
|
|
1565
1760
|
default:
|
|
1566
1761
|
if (process.env.NODE_ENV !== "production") {
|
|
1567
|
-
process.env.NODE_ENV !== "production" ?
|
|
1762
|
+
process.env.NODE_ENV !== "production" ? invariant3__default.default(false, `Unknown where filter ${f}`) : invariant3__default.default(false) ;
|
|
1568
1763
|
}
|
|
1569
1764
|
return !strict;
|
|
1570
1765
|
}
|
|
@@ -1582,8 +1777,6 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
|
1582
1777
|
var API_NAME_IDX = 1;
|
|
1583
1778
|
var ListQuery = class extends BaseListQuery {
|
|
1584
1779
|
// pageSize?: number; // this is the internal page size. we need to track this properly
|
|
1585
|
-
#type;
|
|
1586
|
-
#apiName;
|
|
1587
1780
|
#whereClause;
|
|
1588
1781
|
// Using base class minResultsToLoad instead of a private property
|
|
1589
1782
|
#orderBy;
|
|
@@ -1594,24 +1787,23 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1594
1787
|
registerCacheChanges(batch) {
|
|
1595
1788
|
batch.changes.registerList(this.cacheKey);
|
|
1596
1789
|
}
|
|
1597
|
-
constructor(store, subject,
|
|
1598
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1790
|
+
constructor(store, subject, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
1791
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
1599
1792
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1600
1793
|
}) : void 0);
|
|
1601
|
-
this
|
|
1602
|
-
this.#apiName = apiName;
|
|
1794
|
+
this.apiName = apiName;
|
|
1603
1795
|
this.#whereClause = whereClause;
|
|
1604
1796
|
this.#orderBy = orderBy;
|
|
1605
|
-
this.#objectSet =
|
|
1606
|
-
|
|
1607
|
-
apiName: this.#apiName
|
|
1608
|
-
}).where(this.#whereClause);
|
|
1609
|
-
this.sortingStrategy = new OrderBySortingStrategy(this.#apiName, this.#orderBy);
|
|
1797
|
+
this.#objectSet = this.createObjectSet(store);
|
|
1798
|
+
this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
|
|
1610
1799
|
this.minResultsToLoad = 0;
|
|
1611
1800
|
}
|
|
1612
1801
|
get canonicalWhere() {
|
|
1613
1802
|
return this.#whereClause;
|
|
1614
1803
|
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Create the ObjectSet for this query.
|
|
1806
|
+
*/
|
|
1615
1807
|
/**
|
|
1616
1808
|
* Implements fetchPageData from BaseCollectionQuery template method
|
|
1617
1809
|
* Fetches a page of data
|
|
@@ -1630,10 +1822,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1630
1822
|
throw new Error("Aborted");
|
|
1631
1823
|
}
|
|
1632
1824
|
this.nextPageToken = resp.nextPageToken;
|
|
1633
|
-
|
|
1634
|
-
if (this.#type === "interface") {
|
|
1635
|
-
fetchedData = await reloadDataAsFullObjects(this.store.client, fetchedData);
|
|
1636
|
-
}
|
|
1825
|
+
const fetchedData = await this.postProcessFetchedData(resp.data);
|
|
1637
1826
|
return {
|
|
1638
1827
|
...resp,
|
|
1639
1828
|
data: fetchedData
|
|
@@ -1656,30 +1845,9 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1656
1845
|
* @param apiName to invalidate
|
|
1657
1846
|
* @returns
|
|
1658
1847
|
*/
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
await this.revalidate(
|
|
1663
|
-
/* force */
|
|
1664
|
-
true
|
|
1665
|
-
);
|
|
1666
|
-
return;
|
|
1667
|
-
} else {
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
const objectMetadata = await this.store.client.fetchMetadata({
|
|
1672
|
-
type: "object",
|
|
1673
|
-
apiName
|
|
1674
|
-
});
|
|
1675
|
-
if (this.#apiName in objectMetadata.interfaceMap) {
|
|
1676
|
-
await this.revalidate(
|
|
1677
|
-
/* force */
|
|
1678
|
-
true
|
|
1679
|
-
);
|
|
1680
|
-
return;
|
|
1681
|
-
}
|
|
1682
|
-
};
|
|
1848
|
+
/**
|
|
1849
|
+
* Postprocess fetched data.
|
|
1850
|
+
*/
|
|
1683
1851
|
invalidateObjectType = async (objectType, changes) => {
|
|
1684
1852
|
if (this.cacheKey.otherKeys[1] === objectType) {
|
|
1685
1853
|
changes?.modified.add(this.cacheKey);
|
|
@@ -1707,7 +1875,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1707
1875
|
if (changes.modified.has(this.cacheKey)) return;
|
|
1708
1876
|
changes.modified.add(this.cacheKey);
|
|
1709
1877
|
try {
|
|
1710
|
-
const relevantObjects = this.
|
|
1878
|
+
const relevantObjects = this._extractAndCategorizeRelevantObjects(changes);
|
|
1711
1879
|
const status = optimisticId || relevantObjects.added.sortaMatches.size > 0 || relevantObjects.modified.sortaMatches.size > 0 ? "loading" : "loaded";
|
|
1712
1880
|
const newList = [];
|
|
1713
1881
|
let needsRevalidation = false;
|
|
@@ -1774,8 +1942,8 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1774
1942
|
}
|
|
1775
1943
|
return false;
|
|
1776
1944
|
}
|
|
1777
|
-
|
|
1778
|
-
const relevantObjects = this
|
|
1945
|
+
_extractAndCategorizeRelevantObjects(changes) {
|
|
1946
|
+
const relevantObjects = this.extractRelevantObjects(changes);
|
|
1779
1947
|
for (const group of Object.values(relevantObjects)) {
|
|
1780
1948
|
for (const obj of group.all ?? []) {
|
|
1781
1949
|
const matchType = this.#matchType(obj);
|
|
@@ -1786,39 +1954,9 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1786
1954
|
}
|
|
1787
1955
|
return relevantObjects;
|
|
1788
1956
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
};
|
|
1793
|
-
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
1794
|
-
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
1795
|
-
return {
|
|
1796
|
-
added: {
|
|
1797
|
-
all: added,
|
|
1798
|
-
strictMatches: /* @__PURE__ */ new Set(),
|
|
1799
|
-
sortaMatches: /* @__PURE__ */ new Set()
|
|
1800
|
-
},
|
|
1801
|
-
modified: {
|
|
1802
|
-
all: modified,
|
|
1803
|
-
strictMatches: /* @__PURE__ */ new Set(),
|
|
1804
|
-
sortaMatches: /* @__PURE__ */ new Set()
|
|
1805
|
-
}
|
|
1806
|
-
};
|
|
1807
|
-
}
|
|
1808
|
-
#extractRelevantObjectsForTypeObject(changes) {
|
|
1809
|
-
return {
|
|
1810
|
-
added: {
|
|
1811
|
-
all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
1812
|
-
strictMatches: /* @__PURE__ */ new Set(),
|
|
1813
|
-
sortaMatches: /* @__PURE__ */ new Set()
|
|
1814
|
-
},
|
|
1815
|
-
modified: {
|
|
1816
|
-
all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
1817
|
-
strictMatches: /* @__PURE__ */ new Set(),
|
|
1818
|
-
sortaMatches: /* @__PURE__ */ new Set()
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Extract relevant objects for this query type.
|
|
1959
|
+
*/
|
|
1822
1960
|
registerStreamUpdates(sub) {
|
|
1823
1961
|
const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
|
|
1824
1962
|
methodName: "registerStreamUpdates"
|
|
@@ -1829,10 +1967,10 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1829
1967
|
}).info("Subscribing from websocket");
|
|
1830
1968
|
}
|
|
1831
1969
|
const websocketSubscription = this.#objectSet.subscribe({
|
|
1832
|
-
onChange: this
|
|
1833
|
-
onError: this
|
|
1834
|
-
onOutOfDate: this
|
|
1835
|
-
onSuccessfulSubscription: this
|
|
1970
|
+
onChange: this.onOswChange.bind(this),
|
|
1971
|
+
onError: this.onOswError.bind(this),
|
|
1972
|
+
onOutOfDate: this.onOswOutOfDate.bind(this),
|
|
1973
|
+
onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
|
|
1836
1974
|
});
|
|
1837
1975
|
sub.add(() => {
|
|
1838
1976
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -1843,28 +1981,28 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1843
1981
|
websocketSubscription.unsubscribe();
|
|
1844
1982
|
});
|
|
1845
1983
|
}
|
|
1846
|
-
|
|
1984
|
+
onOswSuccessfulSubscription() {
|
|
1847
1985
|
if (process.env.NODE_ENV !== "production") {
|
|
1848
1986
|
this.logger?.child({
|
|
1849
1987
|
methodName: "onSuccessfulSubscription"
|
|
1850
1988
|
}).debug("");
|
|
1851
1989
|
}
|
|
1852
1990
|
}
|
|
1853
|
-
|
|
1991
|
+
onOswOutOfDate() {
|
|
1854
1992
|
if (process.env.NODE_ENV !== "production") {
|
|
1855
1993
|
this.logger?.child({
|
|
1856
1994
|
methodName: "onOutOfDate"
|
|
1857
1995
|
}).debug("");
|
|
1858
1996
|
}
|
|
1859
1997
|
}
|
|
1860
|
-
|
|
1998
|
+
onOswError(errors) {
|
|
1861
1999
|
if (this.logger) {
|
|
1862
2000
|
this.logger?.child({
|
|
1863
2001
|
methodName: "onError"
|
|
1864
2002
|
}).error("subscription errors", errors);
|
|
1865
2003
|
}
|
|
1866
2004
|
}
|
|
1867
|
-
|
|
2005
|
+
onOswChange({
|
|
1868
2006
|
object: objOrIface,
|
|
1869
2007
|
state
|
|
1870
2008
|
}) {
|
|
@@ -1882,13 +2020,13 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1882
2020
|
this.store.objects.storeOsdkInstances([object], batch);
|
|
1883
2021
|
});
|
|
1884
2022
|
} else if (state === "REMOVED") {
|
|
1885
|
-
this
|
|
2023
|
+
this.onOswRemoved(objOrIface, logger);
|
|
1886
2024
|
}
|
|
1887
2025
|
}
|
|
1888
|
-
|
|
2026
|
+
onOswRemoved(objOrIface, logger) {
|
|
1889
2027
|
this.store.batch({}, (batch) => {
|
|
1890
2028
|
const existing = batch.read(this.cacheKey);
|
|
1891
|
-
!existing ? process.env.NODE_ENV !== "production" ?
|
|
2029
|
+
!existing ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "the truth value for our list should exist as we already subscribed") : invariant3__default.default(false) : void 0;
|
|
1892
2030
|
if (existing.status === "loaded") {
|
|
1893
2031
|
const objectCacheKey = this.cacheKeys.get("object", objOrIface.$objectType, objOrIface.$primaryKey);
|
|
1894
2032
|
const newObjects = existing.value?.data.filter((o) => o !== objectCacheKey);
|
|
@@ -1916,10 +2054,54 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1916
2054
|
});
|
|
1917
2055
|
}
|
|
1918
2056
|
};
|
|
2057
|
+
|
|
2058
|
+
// src/observable/internal/list/InterfaceListQuery.ts
|
|
2059
|
+
var InterfaceListQuery = class extends ListQuery {
|
|
2060
|
+
createObjectSet(store) {
|
|
2061
|
+
return store.client({
|
|
2062
|
+
type: "interface",
|
|
2063
|
+
apiName: this.apiName
|
|
2064
|
+
}).where(this.canonicalWhere);
|
|
2065
|
+
}
|
|
2066
|
+
async revalidateObjectType(apiName) {
|
|
2067
|
+
const objectMetadata = await this.store.client.fetchMetadata({
|
|
2068
|
+
type: "object",
|
|
2069
|
+
apiName
|
|
2070
|
+
});
|
|
2071
|
+
if (this.apiName in objectMetadata.interfaceMap) {
|
|
2072
|
+
await this.revalidate(
|
|
2073
|
+
/* force */
|
|
2074
|
+
true
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
async postProcessFetchedData(data) {
|
|
2079
|
+
return reloadDataAsFullObjects(this.store.client, data);
|
|
2080
|
+
}
|
|
2081
|
+
extractRelevantObjects(changes) {
|
|
2082
|
+
const matchesApiName = ([, object]) => {
|
|
2083
|
+
return this.apiName in object[chunkBP7BR5FZ_cjs.ObjectDefRef].interfaceMap;
|
|
2084
|
+
};
|
|
2085
|
+
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
2086
|
+
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
2087
|
+
return {
|
|
2088
|
+
added: {
|
|
2089
|
+
all: added,
|
|
2090
|
+
strictMatches: /* @__PURE__ */ new Set(),
|
|
2091
|
+
sortaMatches: /* @__PURE__ */ new Set()
|
|
2092
|
+
},
|
|
2093
|
+
modified: {
|
|
2094
|
+
all: modified,
|
|
2095
|
+
strictMatches: /* @__PURE__ */ new Set(),
|
|
2096
|
+
sortaMatches: /* @__PURE__ */ new Set()
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
1919
2101
|
async function reloadDataAsFullObjects(client, data) {
|
|
1920
2102
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
1921
2103
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
1922
|
-
const objectDef = objects[0][
|
|
2104
|
+
const objectDef = objects[0][chunkBP7BR5FZ_cjs.UnderlyingOsdkObject][chunkBP7BR5FZ_cjs.ObjectDefRef];
|
|
1923
2105
|
const where = {
|
|
1924
2106
|
[objectDef.primaryKeyApiName]: {
|
|
1925
2107
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -1929,18 +2111,53 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
1929
2111
|
return [apiName, Object.fromEntries(result.data.map((x) => [x.$primaryKey, x]))];
|
|
1930
2112
|
})));
|
|
1931
2113
|
data = data.map((obj) => {
|
|
1932
|
-
!objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ?
|
|
2114
|
+
!objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant3__default.default(false) : void 0;
|
|
1933
2115
|
return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
|
|
1934
2116
|
});
|
|
1935
2117
|
return data;
|
|
1936
2118
|
}
|
|
1937
2119
|
|
|
2120
|
+
// src/observable/internal/list/ObjectListQuery.ts
|
|
2121
|
+
var ObjectListQuery = class extends ListQuery {
|
|
2122
|
+
createObjectSet(store) {
|
|
2123
|
+
return store.client({
|
|
2124
|
+
type: "object",
|
|
2125
|
+
apiName: this.apiName
|
|
2126
|
+
}).where(this.canonicalWhere);
|
|
2127
|
+
}
|
|
2128
|
+
async revalidateObjectType(apiName) {
|
|
2129
|
+
if (this.apiName === apiName) {
|
|
2130
|
+
await this.revalidate(
|
|
2131
|
+
/* force */
|
|
2132
|
+
true
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
postProcessFetchedData(data) {
|
|
2137
|
+
return Promise.resolve(data);
|
|
2138
|
+
}
|
|
2139
|
+
extractRelevantObjects(changes) {
|
|
2140
|
+
return {
|
|
2141
|
+
added: {
|
|
2142
|
+
all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
2143
|
+
strictMatches: /* @__PURE__ */ new Set(),
|
|
2144
|
+
sortaMatches: /* @__PURE__ */ new Set()
|
|
2145
|
+
},
|
|
2146
|
+
modified: {
|
|
2147
|
+
all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
2148
|
+
strictMatches: /* @__PURE__ */ new Set(),
|
|
2149
|
+
sortaMatches: /* @__PURE__ */ new Set()
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
|
|
1938
2155
|
// src/observable/internal/list/ListsHelper.ts
|
|
1939
2156
|
var ListsHelper = class extends AbstractHelper {
|
|
1940
|
-
constructor(store, cacheKeys,
|
|
2157
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
|
|
1941
2158
|
super(store, cacheKeys);
|
|
1942
|
-
this.whereCanonicalizer =
|
|
1943
|
-
this.orderByCanonicalizer =
|
|
2159
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
2160
|
+
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
1944
2161
|
}
|
|
1945
2162
|
observe(options, subFn) {
|
|
1946
2163
|
const ret = super.observe(options, subFn);
|
|
@@ -1962,7 +2179,8 @@ var ListsHelper = class extends AbstractHelper {
|
|
|
1962
2179
|
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
1963
2180
|
const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy);
|
|
1964
2181
|
return this.store.queries.get(listCacheKey, () => {
|
|
1965
|
-
|
|
2182
|
+
const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
|
|
2183
|
+
return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, canonWhere, canonOrderBy, listCacheKey, options);
|
|
1966
2184
|
});
|
|
1967
2185
|
}
|
|
1968
2186
|
};
|
|
@@ -1993,7 +2211,7 @@ var BulkObjectLoader = class {
|
|
|
1993
2211
|
#maxEntries;
|
|
1994
2212
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
1995
2213
|
this.#client = client;
|
|
1996
|
-
this.#logger = client[
|
|
2214
|
+
this.#logger = client[chunkDCEFUXFS_cjs.additionalContext].logger;
|
|
1997
2215
|
this.#maxWait = maxWait;
|
|
1998
2216
|
this.#maxEntries = maxEntries;
|
|
1999
2217
|
}
|
|
@@ -2056,7 +2274,7 @@ var ObjectQuery = class extends Query {
|
|
|
2056
2274
|
#apiName;
|
|
2057
2275
|
#pk;
|
|
2058
2276
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
2059
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
2277
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
2060
2278
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2061
2279
|
}) : void 0);
|
|
2062
2280
|
this.#apiName = type;
|
|
@@ -2092,7 +2310,7 @@ var ObjectQuery = class extends Query {
|
|
|
2092
2310
|
}
|
|
2093
2311
|
writeToStore(data, status, batch) {
|
|
2094
2312
|
const entry = batch.read(this.cacheKey);
|
|
2095
|
-
if (entry &&
|
|
2313
|
+
if (entry && deepEqual5__default.default(data, entry.value)) {
|
|
2096
2314
|
if (entry.status === status) {
|
|
2097
2315
|
if (process.env.NODE_ENV !== "production") {
|
|
2098
2316
|
this.logger?.child({
|
|
@@ -2126,7 +2344,7 @@ var ObjectQuery = class extends Query {
|
|
|
2126
2344
|
}
|
|
2127
2345
|
deleteFromStore(status, batch) {
|
|
2128
2346
|
const entry = batch.read(this.cacheKey);
|
|
2129
|
-
if (entry &&
|
|
2347
|
+
if (entry && deepEqual5__default.default(tombstone, entry.value)) {
|
|
2130
2348
|
if (process.env.NODE_ENV !== "production") {
|
|
2131
2349
|
this.logger?.child({
|
|
2132
2350
|
methodName: "deleteFromStore"
|
|
@@ -2184,60 +2402,182 @@ var ObjectsHelper = class extends AbstractHelper {
|
|
|
2184
2402
|
}).writeToStore(v, "loaded", batch).cacheKey);
|
|
2185
2403
|
}
|
|
2186
2404
|
};
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
#
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2405
|
+
|
|
2406
|
+
// src/observable/internal/objectset/ObjectSetQuery.ts
|
|
2407
|
+
var ObjectSetQuery = class extends BaseListQuery {
|
|
2408
|
+
#baseObjectSetWire;
|
|
2409
|
+
#operations;
|
|
2410
|
+
#composedObjectSet;
|
|
2411
|
+
#objectTypes;
|
|
2412
|
+
constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
|
|
2413
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
2414
|
+
msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2415
|
+
}) : void 0);
|
|
2416
|
+
this.#baseObjectSetWire = baseObjectSetWire;
|
|
2417
|
+
this.#operations = operations;
|
|
2418
|
+
this.#composedObjectSet = this.#composeObjectSet(opts);
|
|
2419
|
+
this.#objectTypes = this.#extractObjectTypes(opts);
|
|
2420
|
+
if (operations.orderBy && Object.keys(operations.orderBy).length > 0) {
|
|
2421
|
+
const firstType = Array.from(this.#objectTypes)[0];
|
|
2422
|
+
this.sortingStrategy = new OrderBySortingStrategy(firstType, operations.orderBy);
|
|
2423
|
+
}
|
|
2424
|
+
this.minResultsToLoad = opts.pageSize || 0;
|
|
2199
2425
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
this.#trie.removeArray(array);
|
|
2205
|
-
ret = this.#trie.lookupArray(array).deref();
|
|
2426
|
+
#composeObjectSet(opts) {
|
|
2427
|
+
let result = opts.baseObjectSet;
|
|
2428
|
+
if (opts.withProperties) {
|
|
2429
|
+
result = result.withProperties(opts.withProperties);
|
|
2206
2430
|
}
|
|
2207
|
-
|
|
2431
|
+
if (opts.where) {
|
|
2432
|
+
result = result.where(opts.where);
|
|
2433
|
+
}
|
|
2434
|
+
if (opts.union && opts.union.length > 0) {
|
|
2435
|
+
result = result.union(...opts.union);
|
|
2436
|
+
}
|
|
2437
|
+
if (opts.intersect && opts.intersect.length > 0) {
|
|
2438
|
+
result = result.intersect(...opts.intersect);
|
|
2439
|
+
}
|
|
2440
|
+
if (opts.subtract && opts.subtract.length > 0) {
|
|
2441
|
+
result = result.subtract(...opts.subtract);
|
|
2442
|
+
}
|
|
2443
|
+
if (opts.pivotTo) {
|
|
2444
|
+
result = result.pivotTo(opts.pivotTo);
|
|
2445
|
+
}
|
|
2446
|
+
return result;
|
|
2208
2447
|
}
|
|
2209
|
-
|
|
2210
|
-
const
|
|
2211
|
-
const
|
|
2212
|
-
if (
|
|
2213
|
-
|
|
2448
|
+
#extractObjectTypes(opts) {
|
|
2449
|
+
const types = /* @__PURE__ */ new Set();
|
|
2450
|
+
const baseWire = JSON.parse(this.#baseObjectSetWire);
|
|
2451
|
+
if (baseWire.type) {
|
|
2452
|
+
types.add(baseWire.type);
|
|
2453
|
+
}
|
|
2454
|
+
if (opts.union) {
|
|
2455
|
+
for (const os of opts.union) {
|
|
2456
|
+
const wire = chunkDCEFUXFS_cjs.getWireObjectSet(os);
|
|
2457
|
+
if (wire.type) {
|
|
2458
|
+
types.add(wire.type);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2214
2461
|
}
|
|
2215
|
-
|
|
2462
|
+
if (opts.intersect) {
|
|
2463
|
+
for (const os of opts.intersect) {
|
|
2464
|
+
const wire = chunkDCEFUXFS_cjs.getWireObjectSet(os);
|
|
2465
|
+
if (wire.type) {
|
|
2466
|
+
types.add(wire.type);
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
if (opts.subtract) {
|
|
2471
|
+
for (const os of opts.subtract) {
|
|
2472
|
+
const wire = chunkDCEFUXFS_cjs.getWireObjectSet(os);
|
|
2473
|
+
if (wire.type) {
|
|
2474
|
+
types.add(wire.type);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return types;
|
|
2216
2479
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2480
|
+
/**
|
|
2481
|
+
* Register changes to the cache specific to ObjectSetQuery
|
|
2482
|
+
*/
|
|
2483
|
+
registerCacheChanges(batch) {
|
|
2484
|
+
batch.changes.registerObjectSet(this.cacheKey);
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Implements fetchPageData from BaseListQuery template method
|
|
2488
|
+
* Fetches a page of data from the composed ObjectSet
|
|
2489
|
+
*/
|
|
2490
|
+
async fetchPageData(signal) {
|
|
2491
|
+
const resp = await this.#composedObjectSet.fetchPage({
|
|
2492
|
+
$nextPageToken: this.nextPageToken,
|
|
2493
|
+
$pageSize: this.options.pageSize,
|
|
2494
|
+
// OrderBy is already applied in the composed ObjectSet
|
|
2495
|
+
...this.#operations.orderBy && Object.keys(this.#operations.orderBy).length > 0 ? {
|
|
2496
|
+
$orderBy: this.#operations.orderBy
|
|
2497
|
+
} : {}
|
|
2498
|
+
});
|
|
2499
|
+
if (signal?.aborted) {
|
|
2500
|
+
throw new Error("Aborted");
|
|
2501
|
+
}
|
|
2502
|
+
this.nextPageToken = resp.nextPageToken;
|
|
2503
|
+
return resp;
|
|
2504
|
+
}
|
|
2505
|
+
handleFetchError(error, _status, batch) {
|
|
2506
|
+
this.logger?.error("error", error);
|
|
2507
|
+
this.store.subjects.get(this.cacheKey).error(error);
|
|
2508
|
+
return this.writeToStore({
|
|
2509
|
+
data: []
|
|
2510
|
+
}, "error", batch);
|
|
2511
|
+
}
|
|
2512
|
+
invalidateObjectType = async (objectType, changes) => {
|
|
2513
|
+
if (this.#objectTypes.has(objectType)) {
|
|
2514
|
+
changes?.modified.add(this.cacheKey);
|
|
2515
|
+
return this.revalidate(true);
|
|
2516
|
+
}
|
|
2517
|
+
return Promise.resolve();
|
|
2518
|
+
};
|
|
2519
|
+
createPayload(params) {
|
|
2520
|
+
return {
|
|
2521
|
+
resolvedList: params.resolvedData,
|
|
2522
|
+
isOptimistic: params.isOptimistic,
|
|
2523
|
+
fetchMore: this.fetchMore,
|
|
2524
|
+
hasMore: this.nextPageToken != null,
|
|
2525
|
+
status: params.status,
|
|
2526
|
+
lastUpdated: params.lastUpdated,
|
|
2527
|
+
objectSet: this.#composedObjectSet
|
|
2528
|
+
};
|
|
2219
2529
|
}
|
|
2220
2530
|
};
|
|
2221
2531
|
|
|
2222
|
-
// src/observable/internal/
|
|
2223
|
-
var
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2532
|
+
// src/observable/internal/objectset/ObjectSetHelper.ts
|
|
2533
|
+
var ObjectSetHelper = class extends AbstractHelper {
|
|
2534
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
|
|
2535
|
+
super(store, cacheKeys);
|
|
2536
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
2537
|
+
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
2538
|
+
}
|
|
2539
|
+
observe(options, subFn) {
|
|
2540
|
+
return super.observe(options, subFn);
|
|
2541
|
+
}
|
|
2542
|
+
getQuery(options) {
|
|
2543
|
+
const {
|
|
2544
|
+
baseObjectSet
|
|
2545
|
+
} = options;
|
|
2546
|
+
const baseObjectSetWire = JSON.stringify(chunkDCEFUXFS_cjs.getWireObjectSet(baseObjectSet));
|
|
2547
|
+
const operations = this.buildCanonicalizedOperations(options);
|
|
2548
|
+
const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
|
|
2549
|
+
return this.store.queries.get(objectSetCacheKey, () => {
|
|
2550
|
+
return new ObjectSetQuery(this.store, this.store.subjects.get(objectSetCacheKey), baseObjectSetWire, operations, objectSetCacheKey, options);
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
buildCanonicalizedOperations(options) {
|
|
2554
|
+
const operations = {};
|
|
2555
|
+
if (options.where) {
|
|
2556
|
+
operations.where = this.whereCanonicalizer.canonicalize(options.where);
|
|
2234
2557
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2558
|
+
if (options.withProperties) {
|
|
2559
|
+
operations.withProperties = Object.keys(options.withProperties).sort();
|
|
2560
|
+
}
|
|
2561
|
+
if (options.union && options.union.length > 0) {
|
|
2562
|
+
operations.union = options.union.map((os) => JSON.stringify(chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
2563
|
+
}
|
|
2564
|
+
if (options.intersect && options.intersect.length > 0) {
|
|
2565
|
+
operations.intersect = options.intersect.map((os) => JSON.stringify(chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
2566
|
+
}
|
|
2567
|
+
if (options.subtract && options.subtract.length > 0) {
|
|
2568
|
+
operations.subtract = options.subtract.map((os) => JSON.stringify(chunkDCEFUXFS_cjs.getWireObjectSet(os)));
|
|
2569
|
+
}
|
|
2570
|
+
if (options.pivotTo) {
|
|
2571
|
+
operations.pivotTo = options.pivotTo;
|
|
2572
|
+
}
|
|
2573
|
+
if (options.orderBy) {
|
|
2574
|
+
operations.orderBy = this.orderByCanonicalizer.canonicalize(options.orderBy);
|
|
2575
|
+
}
|
|
2576
|
+
if (options.pageSize) {
|
|
2577
|
+
operations.pageSize = options.pageSize;
|
|
2578
|
+
}
|
|
2579
|
+
return operations;
|
|
2580
|
+
}
|
|
2241
2581
|
};
|
|
2242
2582
|
|
|
2243
2583
|
// src/observable/internal/Queries.ts
|
|
@@ -2264,70 +2604,6 @@ var Queries = class {
|
|
|
2264
2604
|
this.map.delete(cacheKey);
|
|
2265
2605
|
}
|
|
2266
2606
|
};
|
|
2267
|
-
var WhereClauseCanonicalizer = class {
|
|
2268
|
-
/**
|
|
2269
|
-
* This is a shortcut cache for any WhereClause's that we have
|
|
2270
|
-
* seen and already canonicalized. The theory behind this
|
|
2271
|
-
* is that well behaving React applications will either `useMemo`
|
|
2272
|
-
* their where clause, or store it in state or pass it through as
|
|
2273
|
-
* props such that we are likely to get the same WhereClause
|
|
2274
|
-
* object multiple times and we can skip unnecessary work.
|
|
2275
|
-
*/
|
|
2276
|
-
#cache = /* @__PURE__ */ new WeakMap();
|
|
2277
|
-
/**
|
|
2278
|
-
* This is a trie that stores the sorted collapsed keys of a where clause to
|
|
2279
|
-
* the cache key for canonicalized options. In theory this keeps the number of
|
|
2280
|
-
* deepEqual comparisons down to a minimum but its probably overkill.
|
|
2281
|
-
*/
|
|
2282
|
-
#trie = new trie.Trie();
|
|
2283
|
-
/**
|
|
2284
|
-
* This is a cache from the cacheKey provided by `this.#trie` to the potential
|
|
2285
|
-
* canonicalized options.
|
|
2286
|
-
*/
|
|
2287
|
-
#existingOptions = /* @__PURE__ */ new Map();
|
|
2288
|
-
canonicalize(where) {
|
|
2289
|
-
if (this.#cache.has(where)) {
|
|
2290
|
-
return this.#cache.get(where);
|
|
2291
|
-
}
|
|
2292
|
-
const keysSet = /* @__PURE__ */ new Set();
|
|
2293
|
-
const calculatedCanon = this.#toCanon(where, keysSet);
|
|
2294
|
-
const cacheKey = this.#trie.lookupArray(Array.from(keysSet).sort());
|
|
2295
|
-
const lookupEntry = this.#existingOptions.get(cacheKey) ?? {
|
|
2296
|
-
options: []
|
|
2297
|
-
};
|
|
2298
|
-
this.#existingOptions.set(cacheKey, lookupEntry);
|
|
2299
|
-
const canon = lookupEntry.options.find((ref) => deepEqual4__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
|
|
2300
|
-
if (canon === calculatedCanon) {
|
|
2301
|
-
lookupEntry.options.push(new WeakRef(canon));
|
|
2302
|
-
}
|
|
2303
|
-
this.#cache.set(where, canon);
|
|
2304
|
-
return canon;
|
|
2305
|
-
}
|
|
2306
|
-
#toCanon = (where, set = /* @__PURE__ */ new Set()) => {
|
|
2307
|
-
if ("$and" in where) {
|
|
2308
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2309
|
-
!Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : void 0;
|
|
2310
|
-
!(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : void 0;
|
|
2311
|
-
}
|
|
2312
|
-
if (where.$and.length === 0) {
|
|
2313
|
-
return {};
|
|
2314
|
-
}
|
|
2315
|
-
if (where.$and.length === 1) {
|
|
2316
|
-
return this.#toCanon(where.$and[0], set);
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
return Object.fromEntries(Object.entries(where).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => {
|
|
2320
|
-
set.add(k);
|
|
2321
|
-
if (k === "$and" || k === "$or") {
|
|
2322
|
-
return [k, v.map((x) => this.#toCanon(x, set))];
|
|
2323
|
-
}
|
|
2324
|
-
if (k !== "$not" && typeof v === "object" && "$eq" in v) {
|
|
2325
|
-
return [k, v["$eq"]];
|
|
2326
|
-
}
|
|
2327
|
-
return [k, v];
|
|
2328
|
-
}));
|
|
2329
|
-
};
|
|
2330
|
-
};
|
|
2331
2607
|
|
|
2332
2608
|
// src/observable/internal/Store.ts
|
|
2333
2609
|
var Store = class {
|
|
@@ -2342,7 +2618,7 @@ var Store = class {
|
|
|
2342
2618
|
subjects = this.layers.subjects;
|
|
2343
2619
|
// these are hopefully temporary
|
|
2344
2620
|
constructor(client) {
|
|
2345
|
-
this.logger = client[
|
|
2621
|
+
this.logger = client[chunkDCEFUXFS_cjs.additionalContext].logger?.child({}, {
|
|
2346
2622
|
msgPrefix: "Store"
|
|
2347
2623
|
});
|
|
2348
2624
|
this.client = client;
|
|
@@ -2352,6 +2628,7 @@ var Store = class {
|
|
|
2352
2628
|
this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2353
2629
|
this.objects = new ObjectsHelper(this, this.cacheKeys);
|
|
2354
2630
|
this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2631
|
+
this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2355
2632
|
}
|
|
2356
2633
|
/**
|
|
2357
2634
|
* Called after a key is no longer retained and the timeout has elapsed
|
|
@@ -2360,7 +2637,7 @@ var Store = class {
|
|
|
2360
2637
|
#cleanupCacheKey = (key) => {
|
|
2361
2638
|
const subject = this.subjects.peek(key);
|
|
2362
2639
|
if (process.env.NODE_ENV !== "production") {
|
|
2363
|
-
!subject ? process.env.NODE_ENV !== "production" ?
|
|
2640
|
+
!subject ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false) : invariant3__default.default(false) : void 0;
|
|
2364
2641
|
}
|
|
2365
2642
|
this.subjects.delete(key);
|
|
2366
2643
|
this.queries.delete(key);
|
|
@@ -2458,14 +2735,32 @@ var Store = class {
|
|
|
2458
2735
|
}
|
|
2459
2736
|
return Promise.allSettled(promises).then(() => void 0);
|
|
2460
2737
|
}
|
|
2738
|
+
async invalidateAll() {
|
|
2739
|
+
const promises = [];
|
|
2740
|
+
for (const cacheKey of this.queries.keys()) {
|
|
2741
|
+
const query = this.queries.peek(cacheKey);
|
|
2742
|
+
if (query) {
|
|
2743
|
+
promises.push(query.revalidate(true));
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
return Promise.allSettled(promises).then(() => void 0);
|
|
2747
|
+
}
|
|
2748
|
+
async invalidateObjects(objects) {
|
|
2749
|
+
const objectsArray = Array.isArray(objects) ? objects : [objects];
|
|
2750
|
+
const promises = [];
|
|
2751
|
+
for (const obj of objectsArray) {
|
|
2752
|
+
promises.push(this.invalidateObject(obj.$objectType, obj.$primaryKey));
|
|
2753
|
+
}
|
|
2754
|
+
return Promise.allSettled(promises).then(() => void 0);
|
|
2755
|
+
}
|
|
2461
2756
|
};
|
|
2462
2757
|
|
|
2463
2758
|
// src/observable/ObservableClient.ts
|
|
2464
2759
|
function createObservableClient(client) {
|
|
2465
|
-
const tweakedClient =
|
|
2466
|
-
...client[
|
|
2467
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
2468
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
2760
|
+
const tweakedClient = chunkBP7BR5FZ_cjs.createClientFromContext({
|
|
2761
|
+
...client[chunkDCEFUXFS_cjs.additionalContext],
|
|
2762
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkDCEFUXFS_cjs.additionalContext].fetch, (headers) => {
|
|
2763
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkBP7BR5FZ_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
2469
2764
|
return headers;
|
|
2470
2765
|
})
|
|
2471
2766
|
});
|
|
@@ -2508,12 +2803,13 @@ function getOsdkConfig(ontologyRid) {
|
|
|
2508
2803
|
|
|
2509
2804
|
Object.defineProperty(exports, "createClientWithTransaction", {
|
|
2510
2805
|
enumerable: true,
|
|
2511
|
-
get: function () { return
|
|
2806
|
+
get: function () { return chunkBP7BR5FZ_cjs.createClientWithTransaction; }
|
|
2512
2807
|
});
|
|
2513
2808
|
Object.defineProperty(exports, "augment", {
|
|
2514
2809
|
enumerable: true,
|
|
2515
|
-
get: function () { return
|
|
2810
|
+
get: function () { return chunkDCEFUXFS_cjs.augment; }
|
|
2516
2811
|
});
|
|
2812
|
+
exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
|
|
2517
2813
|
exports.createObservableClient = createObservableClient;
|
|
2518
2814
|
exports.getMetaTagContent = getMetaTagContent;
|
|
2519
2815
|
exports.getOsdkConfig = getOsdkConfig;
|