@osdk/client 2.5.0-beta.9 → 2.5.0
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 +132 -0
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/actions/applyAction.js +0 -4
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +1 -2
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createMinimalClient.js +1 -2
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +0 -17
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.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/aggregate.js +0 -2
- package/build/browser/object/aggregate.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 +5 -7
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/mediaUpload.js +0 -3
- package/build/browser/object/mediaUpload.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.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/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/ontology/loadActionMetadata.js +1 -3
- package/build/browser/ontology/loadActionMetadata.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +1 -2
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadInterfaceMetadata.js +1 -2
- package/build/browser/ontology/loadInterfaceMetadata.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/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- 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/toDataValue.js +1 -15
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +2 -42
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-MKL3HEQ5.cjs → chunk-KODTFRP3.cjs} +105 -71
- package/build/cjs/chunk-KODTFRP3.cjs.map +1 -0
- package/build/cjs/{chunk-HCCGD2AP.cjs → chunk-UMET26AF.cjs} +68 -91
- package/build/cjs/chunk-UMET26AF.cjs.map +1 -0
- package/build/cjs/{createClient-mOlFts15.d.cts → createClient-BJo8T7Js.d.cts} +0 -1
- package/build/cjs/index.cjs +7 -11
- package/build/cjs/index.d.cts +2 -2
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +429 -156
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +79 -7
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/actions/applyAction.js +0 -4
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +1 -2
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createMinimalClient.js +1 -2
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +0 -17
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.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/aggregate.js +0 -2
- package/build/esm/object/aggregate.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 +5 -7
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/mediaUpload.js +0 -3
- package/build/esm/object/mediaUpload.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.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/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/ontology/loadActionMetadata.js +1 -3
- package/build/esm/ontology/loadActionMetadata.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +1 -2
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadInterfaceMetadata.js +1 -2
- package/build/esm/ontology/loadInterfaceMetadata.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/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- 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/toDataValue.js +1 -15
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +2 -42
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/MinimalClientContext.d.ts +0 -1
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +0 -1
- package/build/types/createClient.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/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/mediaUpload.d.ts +1 -2
- package/build/types/object/mediaUpload.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/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/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/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-HCCGD2AP.cjs.map +0 -1
- package/build/cjs/chunk-MKL3HEQ5.cjs.map +0 -1
|
@@ -1,23 +1,179 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUMET26AF_cjs = require('../chunk-UMET26AF.cjs');
|
|
4
|
+
var chunkKODTFRP3_cjs = require('../chunk-KODTFRP3.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", chunkKODTFRP3_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) => chunkKODTFRP3_cjs.getWireObjectSet(os)));
|
|
158
|
+
}
|
|
159
|
+
if (options.intersect && options.intersect.length > 0) {
|
|
160
|
+
keyParts.push("intersect", options.intersect.map((os) => chunkKODTFRP3_cjs.getWireObjectSet(os)));
|
|
161
|
+
}
|
|
162
|
+
if (options.subtract && options.subtract.length > 0) {
|
|
163
|
+
keyParts.push("subtract", options.subtract.map((os) => chunkKODTFRP3_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[chunkKODTFRP3_cjs.additionalContext].objectFactory2(store.client[chunkKODTFRP3_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[chunkKODTFRP3_cjs.additionalContext].logger : store.client[chunkKODTFRP3_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[chunkKODTFRP3_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[chunkKODTFRP3_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[chunkKODTFRP3_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
|
}
|
|
@@ -1593,7 +1788,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1593
1788
|
batch.changes.registerList(this.cacheKey);
|
|
1594
1789
|
}
|
|
1595
1790
|
constructor(store, subject, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
1596
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1791
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkKODTFRP3_cjs.additionalContext].logger?.child({}, {
|
|
1597
1792
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1598
1793
|
}) : void 0);
|
|
1599
1794
|
this.apiName = apiName;
|
|
@@ -1831,7 +2026,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1831
2026
|
onOswRemoved(objOrIface, logger) {
|
|
1832
2027
|
this.store.batch({}, (batch) => {
|
|
1833
2028
|
const existing = batch.read(this.cacheKey);
|
|
1834
|
-
!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;
|
|
1835
2030
|
if (existing.status === "loaded") {
|
|
1836
2031
|
const objectCacheKey = this.cacheKeys.get("object", objOrIface.$objectType, objOrIface.$primaryKey);
|
|
1837
2032
|
const newObjects = existing.value?.data.filter((o) => o !== objectCacheKey);
|
|
@@ -1885,7 +2080,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
1885
2080
|
}
|
|
1886
2081
|
extractRelevantObjects(changes) {
|
|
1887
2082
|
const matchesApiName = ([, object]) => {
|
|
1888
|
-
return this.apiName in object[
|
|
2083
|
+
return this.apiName in object[chunkUMET26AF_cjs.ObjectDefRef].interfaceMap;
|
|
1889
2084
|
};
|
|
1890
2085
|
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
1891
2086
|
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
@@ -1906,7 +2101,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
1906
2101
|
async function reloadDataAsFullObjects(client, data) {
|
|
1907
2102
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
1908
2103
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
1909
|
-
const objectDef = objects[0][
|
|
2104
|
+
const objectDef = objects[0][chunkUMET26AF_cjs.UnderlyingOsdkObject][chunkUMET26AF_cjs.ObjectDefRef];
|
|
1910
2105
|
const where = {
|
|
1911
2106
|
[objectDef.primaryKeyApiName]: {
|
|
1912
2107
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -1916,7 +2111,7 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
1916
2111
|
return [apiName, Object.fromEntries(result.data.map((x) => [x.$primaryKey, x]))];
|
|
1917
2112
|
})));
|
|
1918
2113
|
data = data.map((obj) => {
|
|
1919
|
-
!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;
|
|
1920
2115
|
return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
|
|
1921
2116
|
});
|
|
1922
2117
|
return data;
|
|
@@ -1959,10 +2154,10 @@ var ObjectListQuery = class extends ListQuery {
|
|
|
1959
2154
|
|
|
1960
2155
|
// src/observable/internal/list/ListsHelper.ts
|
|
1961
2156
|
var ListsHelper = class extends AbstractHelper {
|
|
1962
|
-
constructor(store, cacheKeys,
|
|
2157
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
|
|
1963
2158
|
super(store, cacheKeys);
|
|
1964
|
-
this.whereCanonicalizer =
|
|
1965
|
-
this.orderByCanonicalizer =
|
|
2159
|
+
this.whereCanonicalizer = whereCanonicalizer2;
|
|
2160
|
+
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
1966
2161
|
}
|
|
1967
2162
|
observe(options, subFn) {
|
|
1968
2163
|
const ret = super.observe(options, subFn);
|
|
@@ -2016,7 +2211,7 @@ var BulkObjectLoader = class {
|
|
|
2016
2211
|
#maxEntries;
|
|
2017
2212
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
2018
2213
|
this.#client = client;
|
|
2019
|
-
this.#logger = client[
|
|
2214
|
+
this.#logger = client[chunkKODTFRP3_cjs.additionalContext].logger;
|
|
2020
2215
|
this.#maxWait = maxWait;
|
|
2021
2216
|
this.#maxEntries = maxEntries;
|
|
2022
2217
|
}
|
|
@@ -2079,7 +2274,7 @@ var ObjectQuery = class extends Query {
|
|
|
2079
2274
|
#apiName;
|
|
2080
2275
|
#pk;
|
|
2081
2276
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
2082
|
-
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[chunkKODTFRP3_cjs.additionalContext].logger?.child({}, {
|
|
2083
2278
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2084
2279
|
}) : void 0);
|
|
2085
2280
|
this.#apiName = type;
|
|
@@ -2115,7 +2310,7 @@ var ObjectQuery = class extends Query {
|
|
|
2115
2310
|
}
|
|
2116
2311
|
writeToStore(data, status, batch) {
|
|
2117
2312
|
const entry = batch.read(this.cacheKey);
|
|
2118
|
-
if (entry &&
|
|
2313
|
+
if (entry && deepEqual5__default.default(data, entry.value)) {
|
|
2119
2314
|
if (entry.status === status) {
|
|
2120
2315
|
if (process.env.NODE_ENV !== "production") {
|
|
2121
2316
|
this.logger?.child({
|
|
@@ -2149,7 +2344,7 @@ var ObjectQuery = class extends Query {
|
|
|
2149
2344
|
}
|
|
2150
2345
|
deleteFromStore(status, batch) {
|
|
2151
2346
|
const entry = batch.read(this.cacheKey);
|
|
2152
|
-
if (entry &&
|
|
2347
|
+
if (entry && deepEqual5__default.default(tombstone, entry.value)) {
|
|
2153
2348
|
if (process.env.NODE_ENV !== "production") {
|
|
2154
2349
|
this.logger?.child({
|
|
2155
2350
|
methodName: "deleteFromStore"
|
|
@@ -2207,60 +2402,182 @@ var ObjectsHelper = class extends AbstractHelper {
|
|
|
2207
2402
|
}).writeToStore(v, "loaded", batch).cacheKey);
|
|
2208
2403
|
}
|
|
2209
2404
|
};
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
#
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
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[chunkKODTFRP3_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;
|
|
2222
2425
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
this.#trie.removeArray(array);
|
|
2228
|
-
ret = this.#trie.lookupArray(array).deref();
|
|
2426
|
+
#composeObjectSet(opts) {
|
|
2427
|
+
let result = opts.baseObjectSet;
|
|
2428
|
+
if (opts.withProperties) {
|
|
2429
|
+
result = result.withProperties(opts.withProperties);
|
|
2229
2430
|
}
|
|
2230
|
-
|
|
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;
|
|
2231
2447
|
}
|
|
2232
|
-
|
|
2233
|
-
const
|
|
2234
|
-
const
|
|
2235
|
-
if (
|
|
2236
|
-
|
|
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 = chunkKODTFRP3_cjs.getWireObjectSet(os);
|
|
2457
|
+
if (wire.type) {
|
|
2458
|
+
types.add(wire.type);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2237
2461
|
}
|
|
2238
|
-
|
|
2462
|
+
if (opts.intersect) {
|
|
2463
|
+
for (const os of opts.intersect) {
|
|
2464
|
+
const wire = chunkKODTFRP3_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 = chunkKODTFRP3_cjs.getWireObjectSet(os);
|
|
2473
|
+
if (wire.type) {
|
|
2474
|
+
types.add(wire.type);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return types;
|
|
2239
2479
|
}
|
|
2240
|
-
|
|
2241
|
-
|
|
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
|
+
};
|
|
2242
2529
|
}
|
|
2243
2530
|
};
|
|
2244
2531
|
|
|
2245
|
-
// src/observable/internal/
|
|
2246
|
-
var
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
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(chunkKODTFRP3_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);
|
|
2257
2557
|
}
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
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(chunkKODTFRP3_cjs.getWireObjectSet(os)));
|
|
2563
|
+
}
|
|
2564
|
+
if (options.intersect && options.intersect.length > 0) {
|
|
2565
|
+
operations.intersect = options.intersect.map((os) => JSON.stringify(chunkKODTFRP3_cjs.getWireObjectSet(os)));
|
|
2566
|
+
}
|
|
2567
|
+
if (options.subtract && options.subtract.length > 0) {
|
|
2568
|
+
operations.subtract = options.subtract.map((os) => JSON.stringify(chunkKODTFRP3_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
|
+
}
|
|
2264
2581
|
};
|
|
2265
2582
|
|
|
2266
2583
|
// src/observable/internal/Queries.ts
|
|
@@ -2287,70 +2604,6 @@ var Queries = class {
|
|
|
2287
2604
|
this.map.delete(cacheKey);
|
|
2288
2605
|
}
|
|
2289
2606
|
};
|
|
2290
|
-
var WhereClauseCanonicalizer = class {
|
|
2291
|
-
/**
|
|
2292
|
-
* This is a shortcut cache for any WhereClause's that we have
|
|
2293
|
-
* seen and already canonicalized. The theory behind this
|
|
2294
|
-
* is that well behaving React applications will either `useMemo`
|
|
2295
|
-
* their where clause, or store it in state or pass it through as
|
|
2296
|
-
* props such that we are likely to get the same WhereClause
|
|
2297
|
-
* object multiple times and we can skip unnecessary work.
|
|
2298
|
-
*/
|
|
2299
|
-
#cache = /* @__PURE__ */ new WeakMap();
|
|
2300
|
-
/**
|
|
2301
|
-
* This is a trie that stores the sorted collapsed keys of a where clause to
|
|
2302
|
-
* the cache key for canonicalized options. In theory this keeps the number of
|
|
2303
|
-
* deepEqual comparisons down to a minimum but its probably overkill.
|
|
2304
|
-
*/
|
|
2305
|
-
#trie = new trie.Trie();
|
|
2306
|
-
/**
|
|
2307
|
-
* This is a cache from the cacheKey provided by `this.#trie` to the potential
|
|
2308
|
-
* canonicalized options.
|
|
2309
|
-
*/
|
|
2310
|
-
#existingOptions = /* @__PURE__ */ new Map();
|
|
2311
|
-
canonicalize(where) {
|
|
2312
|
-
if (this.#cache.has(where)) {
|
|
2313
|
-
return this.#cache.get(where);
|
|
2314
|
-
}
|
|
2315
|
-
const keysSet = /* @__PURE__ */ new Set();
|
|
2316
|
-
const calculatedCanon = this.#toCanon(where, keysSet);
|
|
2317
|
-
const cacheKey = this.#trie.lookupArray(Array.from(keysSet).sort());
|
|
2318
|
-
const lookupEntry = this.#existingOptions.get(cacheKey) ?? {
|
|
2319
|
-
options: []
|
|
2320
|
-
};
|
|
2321
|
-
this.#existingOptions.set(cacheKey, lookupEntry);
|
|
2322
|
-
const canon = lookupEntry.options.find((ref) => deepEqual4__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
|
|
2323
|
-
if (canon === calculatedCanon) {
|
|
2324
|
-
lookupEntry.options.push(new WeakRef(canon));
|
|
2325
|
-
}
|
|
2326
|
-
this.#cache.set(where, canon);
|
|
2327
|
-
return canon;
|
|
2328
|
-
}
|
|
2329
|
-
#toCanon = (where, set = /* @__PURE__ */ new Set()) => {
|
|
2330
|
-
if ("$and" in where) {
|
|
2331
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2332
|
-
!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;
|
|
2333
|
-
!(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;
|
|
2334
|
-
}
|
|
2335
|
-
if (where.$and.length === 0) {
|
|
2336
|
-
return {};
|
|
2337
|
-
}
|
|
2338
|
-
if (where.$and.length === 1) {
|
|
2339
|
-
return this.#toCanon(where.$and[0], set);
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
return Object.fromEntries(Object.entries(where).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => {
|
|
2343
|
-
set.add(k);
|
|
2344
|
-
if (k === "$and" || k === "$or") {
|
|
2345
|
-
return [k, v.map((x) => this.#toCanon(x, set))];
|
|
2346
|
-
}
|
|
2347
|
-
if (k !== "$not" && typeof v === "object" && "$eq" in v) {
|
|
2348
|
-
return [k, v["$eq"]];
|
|
2349
|
-
}
|
|
2350
|
-
return [k, v];
|
|
2351
|
-
}));
|
|
2352
|
-
};
|
|
2353
|
-
};
|
|
2354
2607
|
|
|
2355
2608
|
// src/observable/internal/Store.ts
|
|
2356
2609
|
var Store = class {
|
|
@@ -2365,7 +2618,7 @@ var Store = class {
|
|
|
2365
2618
|
subjects = this.layers.subjects;
|
|
2366
2619
|
// these are hopefully temporary
|
|
2367
2620
|
constructor(client) {
|
|
2368
|
-
this.logger = client[
|
|
2621
|
+
this.logger = client[chunkKODTFRP3_cjs.additionalContext].logger?.child({}, {
|
|
2369
2622
|
msgPrefix: "Store"
|
|
2370
2623
|
});
|
|
2371
2624
|
this.client = client;
|
|
@@ -2375,6 +2628,7 @@ var Store = class {
|
|
|
2375
2628
|
this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2376
2629
|
this.objects = new ObjectsHelper(this, this.cacheKeys);
|
|
2377
2630
|
this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2631
|
+
this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2378
2632
|
}
|
|
2379
2633
|
/**
|
|
2380
2634
|
* Called after a key is no longer retained and the timeout has elapsed
|
|
@@ -2383,7 +2637,7 @@ var Store = class {
|
|
|
2383
2637
|
#cleanupCacheKey = (key) => {
|
|
2384
2638
|
const subject = this.subjects.peek(key);
|
|
2385
2639
|
if (process.env.NODE_ENV !== "production") {
|
|
2386
|
-
!subject ? process.env.NODE_ENV !== "production" ?
|
|
2640
|
+
!subject ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false) : invariant3__default.default(false) : void 0;
|
|
2387
2641
|
}
|
|
2388
2642
|
this.subjects.delete(key);
|
|
2389
2643
|
this.queries.delete(key);
|
|
@@ -2481,14 +2735,32 @@ var Store = class {
|
|
|
2481
2735
|
}
|
|
2482
2736
|
return Promise.allSettled(promises).then(() => void 0);
|
|
2483
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
|
+
}
|
|
2484
2756
|
};
|
|
2485
2757
|
|
|
2486
2758
|
// src/observable/ObservableClient.ts
|
|
2487
2759
|
function createObservableClient(client) {
|
|
2488
|
-
const tweakedClient =
|
|
2489
|
-
...client[
|
|
2490
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
2491
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
2760
|
+
const tweakedClient = chunkUMET26AF_cjs.createClientFromContext({
|
|
2761
|
+
...client[chunkKODTFRP3_cjs.additionalContext],
|
|
2762
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkKODTFRP3_cjs.additionalContext].fetch, (headers) => {
|
|
2763
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkUMET26AF_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
2492
2764
|
return headers;
|
|
2493
2765
|
})
|
|
2494
2766
|
});
|
|
@@ -2531,12 +2803,13 @@ function getOsdkConfig(ontologyRid) {
|
|
|
2531
2803
|
|
|
2532
2804
|
Object.defineProperty(exports, "createClientWithTransaction", {
|
|
2533
2805
|
enumerable: true,
|
|
2534
|
-
get: function () { return
|
|
2806
|
+
get: function () { return chunkUMET26AF_cjs.createClientWithTransaction; }
|
|
2535
2807
|
});
|
|
2536
2808
|
Object.defineProperty(exports, "augment", {
|
|
2537
2809
|
enumerable: true,
|
|
2538
|
-
get: function () { return
|
|
2810
|
+
get: function () { return chunkKODTFRP3_cjs.augment; }
|
|
2539
2811
|
});
|
|
2812
|
+
exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
|
|
2540
2813
|
exports.createObservableClient = createObservableClient;
|
|
2541
2814
|
exports.getMetaTagContent = getMetaTagContent;
|
|
2542
2815
|
exports.getOsdkConfig = getOsdkConfig;
|