@osdk/client 2.6.0-beta.3 → 2.6.0-beta.5
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 +28 -0
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +2 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/extractNamespace.js +22 -0
- package/build/browser/internal/conversions/extractNamespace.js.map +1 -0
- package/build/browser/internal/conversions/fullyQualifyPropName.js +26 -0
- package/build/browser/internal/conversions/fullyQualifyPropName.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterBbox.js +41 -0
- package/build/browser/internal/conversions/makeGeoFilterBbox.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterIntersects.js +29 -0
- package/build/browser/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterPolygon.js +30 -0
- package/build/browser/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
- package/build/browser/internal/conversions/makeGeoFilterWithin.js +48 -0
- package/build/browser/internal/conversions/makeGeoFilterWithin.js.map +1 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +30 -99
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +139 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/fetchPage.js +1 -1
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +17 -0
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.js +12 -4
- package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.test.js +48 -0
- package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +9 -3
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/Canonicalizer.js +51 -0
- package/build/browser/observable/internal/Canonicalizer.js.map +1 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OrderByCanonicalizer.js +1 -4
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/RdpCanonicalizer.js +66 -0
- package/build/browser/observable/internal/RdpCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/RdpCanonicalizer.test.js +68 -0
- package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -0
- package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -1
- package/build/browser/observable/internal/Store.js +160 -6
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/actions/ActionApplication.js +1 -1
- package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/actions/OptimisticJob.js +3 -3
- package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js +12 -3
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js +0 -5
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
- package/build/browser/observable/internal/evaluateFilter.js +61 -0
- package/build/browser/observable/internal/evaluateFilter.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +33 -1
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/InterfaceListQuery.js +8 -3
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListCacheKey.js +22 -1
- package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +39 -24
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js +12 -8
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js +10 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectCacheKey.js +20 -1
- package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
- package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectQuery.js +10 -58
- package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectsHelper.js +65 -5
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.js +3 -37
- package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +3 -2
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/observable/internal/utils/rdpFieldOperations.js +83 -0
- package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -0
- package/build/browser/util/UserAgent.js +2 -2
- package/build/cjs/{chunk-BRYZR53E.cjs → chunk-OSI7NG7T.cjs} +54 -54
- package/build/cjs/{chunk-BRYZR53E.cjs.map → chunk-OSI7NG7T.cjs.map} +1 -1
- package/build/cjs/{chunk-6L3MX4LH.cjs → chunk-VNLY3YOJ.cjs} +241 -196
- package/build/cjs/chunk-VNLY3YOJ.cjs.map +1 -0
- package/build/cjs/index.cjs +8 -8
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +652 -215
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +6 -5
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +2 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/extractNamespace.js +22 -0
- package/build/esm/internal/conversions/extractNamespace.js.map +1 -0
- package/build/esm/internal/conversions/fullyQualifyPropName.js +26 -0
- package/build/esm/internal/conversions/fullyQualifyPropName.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterBbox.js +41 -0
- package/build/esm/internal/conversions/makeGeoFilterBbox.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterIntersects.js +29 -0
- package/build/esm/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterPolygon.js +30 -0
- package/build/esm/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
- package/build/esm/internal/conversions/makeGeoFilterWithin.js +48 -0
- package/build/esm/internal/conversions/makeGeoFilterWithin.js.map +1 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +30 -99
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +139 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/fetchPage.js +1 -1
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +17 -0
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.js +12 -4
- package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.test.js +48 -0
- package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +9 -3
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/Canonicalizer.js +51 -0
- package/build/esm/observable/internal/Canonicalizer.js.map +1 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OrderByCanonicalizer.js +1 -4
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/RdpCanonicalizer.js +66 -0
- package/build/esm/observable/internal/RdpCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/RdpCanonicalizer.test.js +68 -0
- package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -0
- package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -1
- package/build/esm/observable/internal/Store.js +160 -6
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/actions/ActionApplication.js +1 -1
- package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/actions/OptimisticJob.js +3 -3
- package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js +12 -3
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js +0 -5
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
- package/build/esm/observable/internal/evaluateFilter.js +61 -0
- package/build/esm/observable/internal/evaluateFilter.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +33 -1
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/InterfaceListQuery.js +8 -3
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListCacheKey.js +22 -1
- package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +39 -24
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js +12 -8
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js +10 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectCacheKey.js +20 -1
- package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
- package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectQuery.js +10 -58
- package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectsHelper.js +65 -5
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.js +3 -37
- package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +3 -2
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/observable/internal/utils/rdpFieldOperations.js +83 -0
- package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -0
- package/build/esm/util/UserAgent.js +2 -2
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/internal/conversions/extractNamespace.d.ts +1 -0
- package/build/types/internal/conversions/extractNamespace.d.ts.map +1 -0
- package/build/types/internal/conversions/fullyQualifyPropName.d.ts +2 -0
- package/build/types/internal/conversions/fullyQualifyPropName.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterBbox.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterBbox.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts.map +1 -0
- package/build/types/internal/conversions/makeGeoFilterWithin.d.ts +3 -0
- package/build/types/internal/conversions/makeGeoFilterWithin.d.ts.map +1 -0
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +15 -5
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Canonicalizer.d.ts +37 -0
- package/build/types/observable/internal/Canonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/RdpCanonicalizer.d.ts +8 -0
- package/build/types/observable/internal/RdpCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/RdpCanonicalizer.test.d.ts +1 -0
- package/build/types/observable/internal/RdpCanonicalizer.test.d.ts.map +1 -0
- package/build/types/observable/internal/SimpleWhereClause.d.ts +6 -2
- package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +4 -0
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +5 -2
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts +6 -0
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts +1 -23
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -1
- package/build/types/observable/internal/evaluateFilter.d.ts +6 -0
- package/build/types/observable/internal/evaluateFilter.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +5 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts +7 -1
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts +7 -7
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts +3 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts +6 -1
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts +60 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts +1 -0
- package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectQuery.d.ts +1 -1
- package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts +15 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/observable/internal/utils/rdpFieldOperations.d.ts +5 -0
- package/build/types/observable/internal/utils/rdpFieldOperations.d.ts.map +1 -0
- package/package.json +6 -6
- package/build/cjs/chunk-6L3MX4LH.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkOSI7NG7T_cjs = require('../chunk-OSI7NG7T.cjs');
|
|
4
|
+
var chunkVNLY3YOJ_cjs = require('../chunk-VNLY3YOJ.cjs');
|
|
5
5
|
require('../chunk-Q7SFCCGT.cjs');
|
|
6
6
|
var trie = require('@wry/trie');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var deepEqual = require('fast-deep-equal');
|
|
8
|
+
var invariant4 = require('tiny-invariant');
|
|
9
9
|
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
10
10
|
var rxjs = require('rxjs');
|
|
11
11
|
var mnemonist = require('mnemonist');
|
|
@@ -14,8 +14,8 @@ 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 deepEqual__default = /*#__PURE__*/_interopDefault(deepEqual);
|
|
18
|
+
var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
|
|
19
19
|
var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
|
|
20
20
|
|
|
21
21
|
var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
|
|
@@ -62,10 +62,7 @@ var OrderByCanonicalizer = class {
|
|
|
62
62
|
}
|
|
63
63
|
return result;
|
|
64
64
|
}, []);
|
|
65
|
-
|
|
66
|
-
if (process.env.NODE_ENV !== "production") {
|
|
67
|
-
data = Object.freeze(data);
|
|
68
|
-
}
|
|
65
|
+
const data = Object.fromEntries(pairs);
|
|
69
66
|
return data;
|
|
70
67
|
});
|
|
71
68
|
canonicalize = (orderBy) => {
|
|
@@ -105,7 +102,7 @@ var WhereClauseCanonicalizer = class {
|
|
|
105
102
|
options: []
|
|
106
103
|
};
|
|
107
104
|
this.#existingOptions.set(cacheKey, lookupEntry);
|
|
108
|
-
const canon = lookupEntry.options.find((ref) =>
|
|
105
|
+
const canon = lookupEntry.options.find((ref) => deepEqual__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
|
|
109
106
|
if (canon === calculatedCanon) {
|
|
110
107
|
lookupEntry.options.push(new WeakRef(canon));
|
|
111
108
|
}
|
|
@@ -115,8 +112,8 @@ var WhereClauseCanonicalizer = class {
|
|
|
115
112
|
#toCanon = (where, set = /* @__PURE__ */ new Set()) => {
|
|
116
113
|
if ("$and" in where) {
|
|
117
114
|
if (process.env.NODE_ENV !== "production") {
|
|
118
|
-
!Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ?
|
|
119
|
-
!(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
115
|
+
!Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $and to be an array") : invariant4__default.default(false) : void 0;
|
|
116
|
+
!(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $and to be present") : invariant4__default.default(false) : void 0;
|
|
120
117
|
}
|
|
121
118
|
if (where.$and.length === 0) {
|
|
122
119
|
return {};
|
|
@@ -130,7 +127,7 @@ var WhereClauseCanonicalizer = class {
|
|
|
130
127
|
if (k === "$and" || k === "$or") {
|
|
131
128
|
return [k, v.map((x) => this.#toCanon(x, set))];
|
|
132
129
|
}
|
|
133
|
-
if (k !== "$not" && typeof v === "object" && "$eq" in v) {
|
|
130
|
+
if (k !== "$not" && typeof v === "object" && v != null && "$eq" in v) {
|
|
134
131
|
return [k, v["$eq"]];
|
|
135
132
|
}
|
|
136
133
|
return [k, v];
|
|
@@ -142,7 +139,7 @@ var WhereClauseCanonicalizer = class {
|
|
|
142
139
|
var whereCanonicalizer = new WhereClauseCanonicalizer();
|
|
143
140
|
var orderByCanonicalizer = new OrderByCanonicalizer();
|
|
144
141
|
function computeObjectSetCacheKey(objectSet, options) {
|
|
145
|
-
const keyParts = ["objectSet",
|
|
142
|
+
const keyParts = ["objectSet", chunkVNLY3YOJ_cjs.getWireObjectSet(objectSet)];
|
|
146
143
|
if (!options) {
|
|
147
144
|
return JSON.stringify(keyParts);
|
|
148
145
|
}
|
|
@@ -154,13 +151,13 @@ function computeObjectSetCacheKey(objectSet, options) {
|
|
|
154
151
|
keyParts.push("props", propKeys);
|
|
155
152
|
}
|
|
156
153
|
if (options.union && options.union.length > 0) {
|
|
157
|
-
keyParts.push("union", options.union.map((os) =>
|
|
154
|
+
keyParts.push("union", options.union.map((os) => chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
158
155
|
}
|
|
159
156
|
if (options.intersect && options.intersect.length > 0) {
|
|
160
|
-
keyParts.push("intersect", options.intersect.map((os) =>
|
|
157
|
+
keyParts.push("intersect", options.intersect.map((os) => chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
161
158
|
}
|
|
162
159
|
if (options.subtract && options.subtract.length > 0) {
|
|
163
|
-
keyParts.push("subtract", options.subtract.map((os) =>
|
|
160
|
+
keyParts.push("subtract", options.subtract.map((os) => chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
164
161
|
}
|
|
165
162
|
if (options.pivotTo) {
|
|
166
163
|
keyParts.push("pivotTo", options.pivotTo);
|
|
@@ -292,7 +289,7 @@ var OptimisticJob = class {
|
|
|
292
289
|
store.objects.getQuery({
|
|
293
290
|
apiName: obj.value.$objectType,
|
|
294
291
|
pk: obj.value.$primaryKey
|
|
295
|
-
}).writeToStore(obj.value, "loading", batch);
|
|
292
|
+
}, void 0).writeToStore(obj.value, "loading", batch);
|
|
296
293
|
} else {
|
|
297
294
|
throw obj;
|
|
298
295
|
}
|
|
@@ -301,13 +298,13 @@ var OptimisticJob = class {
|
|
|
301
298
|
store.objects.getQuery({
|
|
302
299
|
apiName: obj.$objectType,
|
|
303
300
|
pk: obj.$primaryKey
|
|
304
|
-
}).writeToStore(obj, "loading", batch);
|
|
301
|
+
}, void 0).writeToStore(obj, "loading", batch);
|
|
305
302
|
}
|
|
306
303
|
for (const obj of deletedObjects) {
|
|
307
304
|
store.objects.getQuery({
|
|
308
305
|
apiName: obj.$objectType,
|
|
309
306
|
pk: obj.$primaryKey
|
|
310
|
-
}).deleteFromStore("loading", batch);
|
|
307
|
+
}, void 0).deleteFromStore("loading", batch);
|
|
311
308
|
}
|
|
312
309
|
});
|
|
313
310
|
return batchResult.changes;
|
|
@@ -319,7 +316,7 @@ var OptimisticJob = class {
|
|
|
319
316
|
return this;
|
|
320
317
|
},
|
|
321
318
|
createObject(type, pk, properties) {
|
|
322
|
-
const create = store.client[
|
|
319
|
+
const create = store.client[chunkVNLY3YOJ_cjs.additionalContext].objectFactory2(store.client[chunkVNLY3YOJ_cjs.additionalContext], [{
|
|
323
320
|
$primaryKey: pk,
|
|
324
321
|
$apiName: type.apiName,
|
|
325
322
|
$objectType: type.apiName,
|
|
@@ -421,7 +418,13 @@ var ActionApplication = class {
|
|
|
421
418
|
objectType,
|
|
422
419
|
primaryKey
|
|
423
420
|
} of deletedObjects ?? []) {
|
|
424
|
-
const cacheKey = this.store.cacheKeys.get(
|
|
421
|
+
const cacheKey = this.store.cacheKeys.get(
|
|
422
|
+
"object",
|
|
423
|
+
objectType,
|
|
424
|
+
primaryKey,
|
|
425
|
+
/* rdpConfig */
|
|
426
|
+
void 0
|
|
427
|
+
);
|
|
425
428
|
this.store.queries.peek(cacheKey)?.deleteFromStore(
|
|
426
429
|
"loaded",
|
|
427
430
|
// this is probably not the best value to use
|
|
@@ -438,6 +441,22 @@ var ActionApplication = class {
|
|
|
438
441
|
};
|
|
439
442
|
};
|
|
440
443
|
|
|
444
|
+
// src/observable/internal/CacheKey.ts
|
|
445
|
+
function DEBUG_ONLY__cacheKeyToString(x) {
|
|
446
|
+
if (process.env.NODE_ENV !== "production") {
|
|
447
|
+
return `${x.type}CacheKey<${x.otherKeys.map((xx) => JSON.stringify(xx)).join(", ")}>`.replaceAll('"', "'");
|
|
448
|
+
} else {
|
|
449
|
+
throw new Error("not implemented");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function DEBUG_ONLY__cacheKeysToString(x) {
|
|
453
|
+
if (process.env.NODE_ENV !== "production") {
|
|
454
|
+
return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
|
|
455
|
+
} else {
|
|
456
|
+
throw new Error("not implemented");
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
441
460
|
// src/observable/internal/RefCounts.ts
|
|
442
461
|
var RefCounts = class {
|
|
443
462
|
refCounts = /* @__PURE__ */ new Map();
|
|
@@ -518,7 +537,11 @@ var CacheKeys = class {
|
|
|
518
537
|
});
|
|
519
538
|
}
|
|
520
539
|
get(type, ...args) {
|
|
521
|
-
const
|
|
540
|
+
const normalizedArgs = [...args];
|
|
541
|
+
while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
|
|
542
|
+
normalizedArgs.pop();
|
|
543
|
+
}
|
|
544
|
+
const cacheKeyArgs = [type, ...normalizedArgs];
|
|
522
545
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
|
|
523
546
|
const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
524
547
|
this.#refCounts.register(cacheKey);
|
|
@@ -542,24 +565,6 @@ var CacheKeys = class {
|
|
|
542
565
|
this.#remove(key);
|
|
543
566
|
};
|
|
544
567
|
};
|
|
545
|
-
|
|
546
|
-
// src/observable/internal/CacheKey.ts
|
|
547
|
-
function DEBUG_ONLY__cacheKeyToString(x) {
|
|
548
|
-
if (process.env.NODE_ENV !== "production") {
|
|
549
|
-
return `${x.type}CacheKey<${x.otherKeys.map((xx) => JSON.stringify(xx)).join(", ")}>`.replaceAll('"', "'");
|
|
550
|
-
} else {
|
|
551
|
-
throw new Error("not implemented");
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function DEBUG_ONLY__cacheKeysToString(x) {
|
|
555
|
-
if (process.env.NODE_ENV !== "production") {
|
|
556
|
-
return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
|
|
557
|
-
} else {
|
|
558
|
-
throw new Error("not implemented");
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// src/observable/internal/Changes.ts
|
|
563
568
|
var Changes = class {
|
|
564
569
|
modifiedObjects = new mnemonist.MultiMap();
|
|
565
570
|
addedObjects = new mnemonist.MultiMap();
|
|
@@ -833,7 +838,7 @@ var Layers = class {
|
|
|
833
838
|
return this.#truthLayer;
|
|
834
839
|
}
|
|
835
840
|
remove(layerId) {
|
|
836
|
-
!(layerId != null) ? process.env.NODE_ENV !== "production" ?
|
|
841
|
+
!(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant4__default.default(false) : void 0;
|
|
837
842
|
let currentLayer = this.#topLayer;
|
|
838
843
|
const cacheKeys = /* @__PURE__ */ new Map();
|
|
839
844
|
while (currentLayer != null && currentLayer.parentLayer != null) {
|
|
@@ -861,7 +866,7 @@ var Layers = class {
|
|
|
861
866
|
optimisticId,
|
|
862
867
|
changes
|
|
863
868
|
}, batchFn) {
|
|
864
|
-
!(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ?
|
|
869
|
+
!(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "optimistic must be undefined or not falsy") : invariant4__default.default(false) : void 0;
|
|
865
870
|
const batchContext = this.#createBatchContext({
|
|
866
871
|
optimisticId,
|
|
867
872
|
changes
|
|
@@ -989,6 +994,12 @@ function isObjectInstance(item) {
|
|
|
989
994
|
return item != null && typeof item === "object" && "$primaryKey" in item;
|
|
990
995
|
}
|
|
991
996
|
|
|
997
|
+
// src/observable/internal/list/ListCacheKey.ts
|
|
998
|
+
var API_NAME_IDX = 1;
|
|
999
|
+
var WHERE_IDX = 2;
|
|
1000
|
+
var ORDER_BY_IDX = 3;
|
|
1001
|
+
var RDP_IDX = 4;
|
|
1002
|
+
|
|
992
1003
|
// src/observable/internal/Query.ts
|
|
993
1004
|
var Query = class {
|
|
994
1005
|
retainCount = 0;
|
|
@@ -1003,7 +1014,7 @@ var Query = class {
|
|
|
1003
1014
|
this.store = store;
|
|
1004
1015
|
this.cacheKeys = store.cacheKeys;
|
|
1005
1016
|
this.#subject = observable;
|
|
1006
|
-
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[
|
|
1017
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkVNLY3YOJ_cjs.additionalContext].logger : store.client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
1007
1018
|
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
1008
1019
|
}));
|
|
1009
1020
|
}
|
|
@@ -1244,6 +1255,12 @@ var BaseListQuery = class extends Query {
|
|
|
1244
1255
|
* @protected
|
|
1245
1256
|
*/
|
|
1246
1257
|
sortingStrategy = new NoOpSortingStrategy();
|
|
1258
|
+
/**
|
|
1259
|
+
* Get RDP configuration from the cache key
|
|
1260
|
+
*/
|
|
1261
|
+
get rdpConfig() {
|
|
1262
|
+
return this.cacheKey.otherKeys[RDP_IDX];
|
|
1263
|
+
}
|
|
1247
1264
|
// Collection-specific behavior is implemented by subclasses
|
|
1248
1265
|
/**
|
|
1249
1266
|
* Token for the next page of results
|
|
@@ -1276,7 +1293,7 @@ var BaseListQuery = class extends Query {
|
|
|
1276
1293
|
if (items.length === 0) {
|
|
1277
1294
|
objectCacheKeys = [];
|
|
1278
1295
|
} else if (isObjectInstance(items[0])) {
|
|
1279
|
-
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
|
|
1296
|
+
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch, this.rdpConfig);
|
|
1280
1297
|
} else {
|
|
1281
1298
|
objectCacheKeys = items;
|
|
1282
1299
|
}
|
|
@@ -1295,7 +1312,7 @@ var BaseListQuery = class extends Query {
|
|
|
1295
1312
|
*/
|
|
1296
1313
|
writeToStore(data, status, batch) {
|
|
1297
1314
|
const entry = batch.read(this.cacheKey);
|
|
1298
|
-
if (entry &&
|
|
1315
|
+
if (entry && deepEqual__default.default(data, entry.value)) {
|
|
1299
1316
|
if (entry.status === status) {
|
|
1300
1317
|
if (process.env.NODE_ENV !== "production") {
|
|
1301
1318
|
this.logger?.child({
|
|
@@ -1480,7 +1497,8 @@ var BaseListQuery = class extends Query {
|
|
|
1480
1497
|
} = this.store.batch({}, (batch) => {
|
|
1481
1498
|
const append = this.nextPageToken != null;
|
|
1482
1499
|
const finalStatus = result.nextPageToken ? status : "loaded";
|
|
1483
|
-
|
|
1500
|
+
const objectKeys = this.store.objects.storeOsdkInstances(result.data, batch, this.rdpConfig);
|
|
1501
|
+
return this._updateList(objectKeys, finalStatus, batch, append);
|
|
1484
1502
|
});
|
|
1485
1503
|
return retVal;
|
|
1486
1504
|
} catch (error) {
|
|
@@ -1549,7 +1567,7 @@ var BaseListQuery = class extends Query {
|
|
|
1549
1567
|
if (items.length === 0) {
|
|
1550
1568
|
objectCacheKeys = [];
|
|
1551
1569
|
} else if (isObjectInstance(items[0])) {
|
|
1552
|
-
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
|
|
1570
|
+
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch, this.rdpConfig);
|
|
1553
1571
|
} else {
|
|
1554
1572
|
objectCacheKeys = items;
|
|
1555
1573
|
}
|
|
@@ -1576,7 +1594,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1576
1594
|
batch.changes.modified.add(this.cacheKey);
|
|
1577
1595
|
}
|
|
1578
1596
|
constructor(store, subject, cacheKey, opts) {
|
|
1579
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1597
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
1580
1598
|
msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1581
1599
|
}) : void 0);
|
|
1582
1600
|
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
@@ -1593,7 +1611,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1593
1611
|
type: "object",
|
|
1594
1612
|
apiName: this.#sourceApiName
|
|
1595
1613
|
};
|
|
1596
|
-
const sourceMetadata = await client[
|
|
1614
|
+
const sourceMetadata = await client[chunkVNLY3YOJ_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1597
1615
|
const sourceQuery = client(sourceObjectDef).where({
|
|
1598
1616
|
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
1599
1617
|
});
|
|
@@ -1620,7 +1638,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1620
1638
|
*/
|
|
1621
1639
|
deleteFromStore(status, batch) {
|
|
1622
1640
|
const entry = batch.read(this.cacheKey);
|
|
1623
|
-
if (entry &&
|
|
1641
|
+
if (entry && deepEqual__default.default(tombstone, entry.value)) {
|
|
1624
1642
|
if (process.env.NODE_ENV !== "production") {
|
|
1625
1643
|
this.logger?.child({
|
|
1626
1644
|
methodName: "deleteFromStore"
|
|
@@ -1657,7 +1675,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1657
1675
|
return this.revalidate(true);
|
|
1658
1676
|
} else {
|
|
1659
1677
|
return (async () => {
|
|
1660
|
-
const sourceMetadata = await this.store.client[
|
|
1678
|
+
const sourceMetadata = await this.store.client[chunkVNLY3YOJ_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1661
1679
|
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
1662
1680
|
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
1663
1681
|
const promise = this.revalidate(true);
|
|
@@ -1687,11 +1705,47 @@ var LinksHelper = class extends AbstractHelper {
|
|
|
1687
1705
|
});
|
|
1688
1706
|
}
|
|
1689
1707
|
};
|
|
1708
|
+
function evaluateFilter(f, realValue, expected, strict) {
|
|
1709
|
+
switch (f) {
|
|
1710
|
+
case "$eq":
|
|
1711
|
+
return realValue === expected;
|
|
1712
|
+
case "$gt":
|
|
1713
|
+
return realValue > expected;
|
|
1714
|
+
case "$lt":
|
|
1715
|
+
return realValue < expected;
|
|
1716
|
+
case "$gte":
|
|
1717
|
+
return realValue >= expected;
|
|
1718
|
+
case "$lte":
|
|
1719
|
+
return realValue <= expected;
|
|
1720
|
+
case "$ne":
|
|
1721
|
+
return realValue !== expected;
|
|
1722
|
+
case "$in":
|
|
1723
|
+
return expected.$in.includes(realValue);
|
|
1724
|
+
case "$isNull":
|
|
1725
|
+
return realValue == null;
|
|
1726
|
+
case "$startsWith":
|
|
1727
|
+
return realValue.startsWith(expected);
|
|
1728
|
+
case "$contains":
|
|
1729
|
+
case "$containsAllTerms":
|
|
1730
|
+
case "$containsAllTermsInOrder":
|
|
1731
|
+
case "$containsAnyTerm":
|
|
1732
|
+
case "$intersects":
|
|
1733
|
+
case "$within":
|
|
1734
|
+
return !strict;
|
|
1735
|
+
default:
|
|
1736
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1737
|
+
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Unknown where filter ${f}`) : invariant4__default.default(false) ;
|
|
1738
|
+
}
|
|
1739
|
+
return !strict;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
// src/observable/internal/objectMatchesWhereClause.ts
|
|
1690
1744
|
function is$and(whereClause) {
|
|
1691
1745
|
if (process.env.NODE_ENV !== "production") {
|
|
1692
1746
|
if ("$and" in whereClause) {
|
|
1693
|
-
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ?
|
|
1694
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1747
|
+
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $and to be an array") : invariant4__default.default(false) : void 0;
|
|
1748
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $and to be present") : invariant4__default.default(false) : void 0;
|
|
1695
1749
|
}
|
|
1696
1750
|
}
|
|
1697
1751
|
return "$and" in whereClause;
|
|
@@ -1699,8 +1753,8 @@ function is$and(whereClause) {
|
|
|
1699
1753
|
function is$or(whereClause) {
|
|
1700
1754
|
if (process.env.NODE_ENV !== "production") {
|
|
1701
1755
|
if ("$or" in whereClause) {
|
|
1702
|
-
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ?
|
|
1703
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1756
|
+
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $or to be an array") : invariant4__default.default(false) : void 0;
|
|
1757
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $or to be present") : invariant4__default.default(false) : void 0;
|
|
1704
1758
|
}
|
|
1705
1759
|
}
|
|
1706
1760
|
return "$or" in whereClause;
|
|
@@ -1708,13 +1762,13 @@ function is$or(whereClause) {
|
|
|
1708
1762
|
function is$not(whereClause) {
|
|
1709
1763
|
if (process.env.NODE_ENV !== "production") {
|
|
1710
1764
|
if ("$not" in whereClause) {
|
|
1711
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ?
|
|
1765
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $not to be present") : invariant4__default.default(false) : void 0;
|
|
1712
1766
|
}
|
|
1713
1767
|
}
|
|
1714
1768
|
return "$not" in whereClause;
|
|
1715
1769
|
}
|
|
1716
1770
|
function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
1717
|
-
if (
|
|
1771
|
+
if (deepEqual__default.default({}, whereClause)) {
|
|
1718
1772
|
return true;
|
|
1719
1773
|
}
|
|
1720
1774
|
if (is$and(whereClause)) {
|
|
@@ -1727,42 +1781,11 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
|
1727
1781
|
return !objectSortaMatchesWhereClause(o, whereClause.$not, strict);
|
|
1728
1782
|
}
|
|
1729
1783
|
return Object.entries(whereClause).every(([key, filter]) => {
|
|
1730
|
-
if (typeof filter === "object") {
|
|
1784
|
+
if (typeof filter === "object" && filter != null) {
|
|
1731
1785
|
const realValue = o[key];
|
|
1732
1786
|
const [f] = Object.keys(filter);
|
|
1733
1787
|
const expected = filter[f];
|
|
1734
|
-
|
|
1735
|
-
case "$eq":
|
|
1736
|
-
return realValue === expected;
|
|
1737
|
-
case "$gt":
|
|
1738
|
-
return realValue > expected;
|
|
1739
|
-
case "$lt":
|
|
1740
|
-
return realValue < expected;
|
|
1741
|
-
case "$gte":
|
|
1742
|
-
return realValue >= expected;
|
|
1743
|
-
case "$lte":
|
|
1744
|
-
return realValue <= expected;
|
|
1745
|
-
case "$ne":
|
|
1746
|
-
return realValue !== expected;
|
|
1747
|
-
case "$in":
|
|
1748
|
-
return expected.$in.includes(realValue);
|
|
1749
|
-
case "$isNull":
|
|
1750
|
-
return realValue == null;
|
|
1751
|
-
case "$startsWith":
|
|
1752
|
-
return realValue.startsWith(expected);
|
|
1753
|
-
case "$contains":
|
|
1754
|
-
case "$containsAllTerms":
|
|
1755
|
-
case "$containsAllTermsInOrder":
|
|
1756
|
-
case "$containsAnyTerm":
|
|
1757
|
-
case "$intersects":
|
|
1758
|
-
case "$within":
|
|
1759
|
-
return !strict;
|
|
1760
|
-
default:
|
|
1761
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1762
|
-
process.env.NODE_ENV !== "production" ? invariant3__default.default(false, `Unknown where filter ${f}`) : invariant3__default.default(false) ;
|
|
1763
|
-
}
|
|
1764
|
-
return !strict;
|
|
1765
|
-
}
|
|
1788
|
+
return evaluateFilter(f, realValue, expected, strict);
|
|
1766
1789
|
}
|
|
1767
1790
|
if (key in o) {
|
|
1768
1791
|
if (o[key] === filter) {
|
|
@@ -1774,26 +1797,32 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
|
1774
1797
|
}
|
|
1775
1798
|
|
|
1776
1799
|
// src/observable/internal/list/ListQuery.ts
|
|
1777
|
-
var API_NAME_IDX = 1;
|
|
1778
1800
|
var ListQuery = class extends BaseListQuery {
|
|
1779
1801
|
// pageSize?: number; // this is the internal page size. we need to track this properly
|
|
1780
1802
|
#whereClause;
|
|
1781
1803
|
// Using base class minResultsToLoad instead of a private property
|
|
1782
1804
|
#orderBy;
|
|
1783
1805
|
#objectSet;
|
|
1806
|
+
#websocketSubscription = null;
|
|
1807
|
+
#subscriptionRefCounts = new RefCounts(process.env.NODE_ENV !== "production" ? 2e3 : 5e3, () => {
|
|
1808
|
+
if (this.#websocketSubscription) {
|
|
1809
|
+
this.#websocketSubscription.unsubscribe();
|
|
1810
|
+
this.#websocketSubscription = null;
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1784
1813
|
/**
|
|
1785
1814
|
* Register changes to the cache specific to ListQuery
|
|
1786
1815
|
*/
|
|
1787
1816
|
registerCacheChanges(batch) {
|
|
1788
1817
|
batch.changes.registerList(this.cacheKey);
|
|
1789
1818
|
}
|
|
1790
|
-
constructor(store, subject, apiName,
|
|
1791
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1819
|
+
constructor(store, subject, apiName, cacheKey, opts) {
|
|
1820
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
1792
1821
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1793
1822
|
}) : void 0);
|
|
1794
1823
|
this.apiName = apiName;
|
|
1795
|
-
this.#whereClause =
|
|
1796
|
-
this.#orderBy =
|
|
1824
|
+
this.#whereClause = cacheKey.otherKeys[WHERE_IDX];
|
|
1825
|
+
this.#orderBy = cacheKey.otherKeys[ORDER_BY_IDX];
|
|
1797
1826
|
this.#objectSet = this.createObjectSet(store);
|
|
1798
1827
|
this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
|
|
1799
1828
|
this.minResultsToLoad = 0;
|
|
@@ -1849,7 +1878,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1849
1878
|
* Postprocess fetched data.
|
|
1850
1879
|
*/
|
|
1851
1880
|
invalidateObjectType = async (objectType, changes) => {
|
|
1852
|
-
if (this.
|
|
1881
|
+
if (this.apiName === objectType) {
|
|
1853
1882
|
changes?.modified.add(this.cacheKey);
|
|
1854
1883
|
return this.revalidate(true);
|
|
1855
1884
|
}
|
|
@@ -1891,7 +1920,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1891
1920
|
const toRemove = new Set(changes.deleted);
|
|
1892
1921
|
for (const obj of relevantObjects.modified.all) {
|
|
1893
1922
|
if (relevantObjects.modified.strictMatches.has(obj)) {
|
|
1894
|
-
const objectCacheKey = this.
|
|
1923
|
+
const objectCacheKey = this.getObjectCacheKey(obj);
|
|
1895
1924
|
if (!existingList.has(objectCacheKey)) {
|
|
1896
1925
|
toAdd.add(obj);
|
|
1897
1926
|
}
|
|
@@ -1899,7 +1928,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1899
1928
|
} else if (batch.optimisticWrite) {
|
|
1900
1929
|
continue;
|
|
1901
1930
|
} else {
|
|
1902
|
-
const existingObjectCacheKey = this.
|
|
1931
|
+
const existingObjectCacheKey = this.getObjectCacheKey(obj);
|
|
1903
1932
|
toRemove.add(existingObjectCacheKey);
|
|
1904
1933
|
if (relevantObjects.modified.sortaMatches.has(obj)) {
|
|
1905
1934
|
needsRevalidation = true;
|
|
@@ -1911,7 +1940,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1911
1940
|
newList.push(key);
|
|
1912
1941
|
}
|
|
1913
1942
|
for (const obj of toAdd) {
|
|
1914
|
-
newList.push(this.
|
|
1943
|
+
newList.push(this.getObjectCacheKey(obj));
|
|
1915
1944
|
}
|
|
1916
1945
|
this._updateList(
|
|
1917
1946
|
newList,
|
|
@@ -1966,19 +1995,24 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1966
1995
|
methodName: "observeList"
|
|
1967
1996
|
}).info("Subscribing from websocket");
|
|
1968
1997
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1998
|
+
if (!this.#websocketSubscription) {
|
|
1999
|
+
this.#websocketSubscription = this.#objectSet.subscribe({
|
|
2000
|
+
onChange: this.onOswChange.bind(this),
|
|
2001
|
+
onError: this.onOswError.bind(this),
|
|
2002
|
+
onOutOfDate: this.onOswOutOfDate.bind(this),
|
|
2003
|
+
onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
|
|
2004
|
+
});
|
|
2005
|
+
this.#subscriptionRefCounts.register("websocket");
|
|
2006
|
+
}
|
|
2007
|
+
this.#subscriptionRefCounts.retain("websocket");
|
|
1975
2008
|
sub.add(() => {
|
|
1976
2009
|
if (process.env.NODE_ENV !== "production") {
|
|
1977
2010
|
logger?.child({
|
|
1978
2011
|
methodName: "observeList"
|
|
1979
2012
|
}).info("Unsubscribing from websocket");
|
|
1980
2013
|
}
|
|
1981
|
-
|
|
2014
|
+
this.#subscriptionRefCounts.release("websocket");
|
|
2015
|
+
this.#subscriptionRefCounts.gc();
|
|
1982
2016
|
});
|
|
1983
2017
|
}
|
|
1984
2018
|
onOswSuccessfulSubscription() {
|
|
@@ -2017,7 +2051,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
2017
2051
|
if (state === "ADDED_OR_UPDATED") {
|
|
2018
2052
|
const object = objOrIface.$apiName !== objOrIface.$objectType ? objOrIface.$as(objOrIface.$objectType) : objOrIface;
|
|
2019
2053
|
this.store.batch({}, (batch) => {
|
|
2020
|
-
this.store.objects.storeOsdkInstances([object], batch);
|
|
2054
|
+
this.store.objects.storeOsdkInstances([object], batch, this.rdpConfig);
|
|
2021
2055
|
});
|
|
2022
2056
|
} else if (state === "REMOVED") {
|
|
2023
2057
|
this.onOswRemoved(objOrIface, logger);
|
|
@@ -2026,9 +2060,9 @@ var ListQuery = class extends BaseListQuery {
|
|
|
2026
2060
|
onOswRemoved(objOrIface, logger) {
|
|
2027
2061
|
this.store.batch({}, (batch) => {
|
|
2028
2062
|
const existing = batch.read(this.cacheKey);
|
|
2029
|
-
!existing ? process.env.NODE_ENV !== "production" ?
|
|
2063
|
+
!existing ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "the truth value for our list should exist as we already subscribed") : invariant4__default.default(false) : void 0;
|
|
2030
2064
|
if (existing.status === "loaded") {
|
|
2031
|
-
const objectCacheKey = this.
|
|
2065
|
+
const objectCacheKey = this.getObjectCacheKey(objOrIface);
|
|
2032
2066
|
const newObjects = existing.value?.data.filter((o) => o !== objectCacheKey);
|
|
2033
2067
|
if (newObjects?.length !== existing.value?.data.length) {
|
|
2034
2068
|
batch.changes.registerList(this.cacheKey);
|
|
@@ -2053,15 +2087,28 @@ var ListQuery = class extends BaseListQuery {
|
|
|
2053
2087
|
});
|
|
2054
2088
|
});
|
|
2055
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Get cache key for object.
|
|
2092
|
+
*/
|
|
2093
|
+
getObjectCacheKey(obj) {
|
|
2094
|
+
const pk = obj.$primaryKey;
|
|
2095
|
+
return this.cacheKeys.get("object", obj.$objectType, pk, this.rdpConfig ?? void 0);
|
|
2096
|
+
}
|
|
2056
2097
|
};
|
|
2057
2098
|
|
|
2058
2099
|
// src/observable/internal/list/InterfaceListQuery.ts
|
|
2059
2100
|
var InterfaceListQuery = class extends ListQuery {
|
|
2060
2101
|
createObjectSet(store) {
|
|
2061
|
-
|
|
2062
|
-
|
|
2102
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];
|
|
2103
|
+
const type = "interface";
|
|
2104
|
+
const objectTypeDef = {
|
|
2105
|
+
type,
|
|
2063
2106
|
apiName: this.apiName
|
|
2064
|
-
}
|
|
2107
|
+
};
|
|
2108
|
+
if (rdpConfig != null) {
|
|
2109
|
+
return store.client(objectTypeDef).withProperties(rdpConfig).where(this.canonicalWhere);
|
|
2110
|
+
}
|
|
2111
|
+
return store.client(objectTypeDef).where(this.canonicalWhere);
|
|
2065
2112
|
}
|
|
2066
2113
|
async revalidateObjectType(apiName) {
|
|
2067
2114
|
const objectMetadata = await this.store.client.fetchMetadata({
|
|
@@ -2080,7 +2127,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
2080
2127
|
}
|
|
2081
2128
|
extractRelevantObjects(changes) {
|
|
2082
2129
|
const matchesApiName = ([, object]) => {
|
|
2083
|
-
return this.apiName in object[
|
|
2130
|
+
return this.apiName in object[chunkOSI7NG7T_cjs.ObjectDefRef].interfaceMap;
|
|
2084
2131
|
};
|
|
2085
2132
|
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
2086
2133
|
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
|
|
@@ -2101,7 +2148,7 @@ var InterfaceListQuery = class extends ListQuery {
|
|
|
2101
2148
|
async function reloadDataAsFullObjects(client, data) {
|
|
2102
2149
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
2103
2150
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
2104
|
-
const objectDef = objects[0][
|
|
2151
|
+
const objectDef = objects[0][chunkOSI7NG7T_cjs.UnderlyingOsdkObject][chunkOSI7NG7T_cjs.ObjectDefRef];
|
|
2105
2152
|
const where = {
|
|
2106
2153
|
[objectDef.primaryKeyApiName]: {
|
|
2107
2154
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -2111,7 +2158,7 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
2111
2158
|
return [apiName, Object.fromEntries(result.data.map((x) => [x.$primaryKey, x]))];
|
|
2112
2159
|
})));
|
|
2113
2160
|
data = data.map((obj) => {
|
|
2114
|
-
!objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ?
|
|
2161
|
+
!objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant4__default.default(false) : void 0;
|
|
2115
2162
|
return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
|
|
2116
2163
|
});
|
|
2117
2164
|
return data;
|
|
@@ -2120,6 +2167,13 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
2120
2167
|
// src/observable/internal/list/ObjectListQuery.ts
|
|
2121
2168
|
var ObjectListQuery = class extends ListQuery {
|
|
2122
2169
|
createObjectSet(store) {
|
|
2170
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];
|
|
2171
|
+
if (rdpConfig != null) {
|
|
2172
|
+
return store.client({
|
|
2173
|
+
type: "object",
|
|
2174
|
+
apiName: this.apiName
|
|
2175
|
+
}).withProperties(rdpConfig).where(this.canonicalWhere);
|
|
2176
|
+
}
|
|
2123
2177
|
return store.client({
|
|
2124
2178
|
type: "object",
|
|
2125
2179
|
apiName: this.apiName
|
|
@@ -2154,10 +2208,11 @@ var ObjectListQuery = class extends ListQuery {
|
|
|
2154
2208
|
|
|
2155
2209
|
// src/observable/internal/list/ListsHelper.ts
|
|
2156
2210
|
var ListsHelper = class extends AbstractHelper {
|
|
2157
|
-
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
|
|
2211
|
+
constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer) {
|
|
2158
2212
|
super(store, cacheKeys);
|
|
2159
2213
|
this.whereCanonicalizer = whereCanonicalizer2;
|
|
2160
2214
|
this.orderByCanonicalizer = orderByCanonicalizer2;
|
|
2215
|
+
this.rdpCanonicalizer = rdpCanonicalizer;
|
|
2161
2216
|
}
|
|
2162
2217
|
observe(options, subFn) {
|
|
2163
2218
|
const ret = super.observe(options, subFn);
|
|
@@ -2168,23 +2223,197 @@ var ListsHelper = class extends AbstractHelper {
|
|
|
2168
2223
|
}
|
|
2169
2224
|
getQuery(options) {
|
|
2170
2225
|
const {
|
|
2171
|
-
type:
|
|
2172
|
-
apiName,
|
|
2173
|
-
type
|
|
2174
|
-
},
|
|
2226
|
+
type: typeDefinition,
|
|
2175
2227
|
where,
|
|
2176
|
-
orderBy
|
|
2228
|
+
orderBy,
|
|
2229
|
+
withProperties
|
|
2177
2230
|
} = options;
|
|
2231
|
+
const {
|
|
2232
|
+
apiName,
|
|
2233
|
+
type
|
|
2234
|
+
} = typeDefinition;
|
|
2178
2235
|
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
2179
2236
|
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
2180
|
-
const
|
|
2237
|
+
const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
|
|
2238
|
+
const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy, canonRdp);
|
|
2181
2239
|
return this.store.queries.get(listCacheKey, () => {
|
|
2182
2240
|
const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
|
|
2183
|
-
return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName,
|
|
2241
|
+
return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, listCacheKey, options);
|
|
2184
2242
|
});
|
|
2185
2243
|
}
|
|
2186
2244
|
};
|
|
2187
2245
|
|
|
2246
|
+
// src/observable/internal/object/ObjectCacheKey.ts
|
|
2247
|
+
var API_NAME_IDX2 = 0;
|
|
2248
|
+
var RDP_CONFIG_IDX = 2;
|
|
2249
|
+
|
|
2250
|
+
// src/observable/internal/utils/rdpFieldOperations.ts
|
|
2251
|
+
function extractRdpFieldNames(rdpConfig) {
|
|
2252
|
+
if (!rdpConfig) {
|
|
2253
|
+
return /* @__PURE__ */ new Set();
|
|
2254
|
+
}
|
|
2255
|
+
return new Set(Object.keys(rdpConfig));
|
|
2256
|
+
}
|
|
2257
|
+
function deleteField(obj, field) {
|
|
2258
|
+
const mutableObj = obj;
|
|
2259
|
+
delete mutableObj[field];
|
|
2260
|
+
}
|
|
2261
|
+
function setField(obj, field, value) {
|
|
2262
|
+
const mutableObj = obj;
|
|
2263
|
+
mutableObj[field] = value;
|
|
2264
|
+
}
|
|
2265
|
+
function stripRdpFields(value, rdpFields) {
|
|
2266
|
+
if (rdpFields.size === 0) {
|
|
2267
|
+
return value;
|
|
2268
|
+
}
|
|
2269
|
+
const result = {
|
|
2270
|
+
...value
|
|
2271
|
+
};
|
|
2272
|
+
for (const field of rdpFields) {
|
|
2273
|
+
deleteField(result, field);
|
|
2274
|
+
}
|
|
2275
|
+
return result;
|
|
2276
|
+
}
|
|
2277
|
+
function isSuperset(superset, subset) {
|
|
2278
|
+
for (const field of subset) {
|
|
2279
|
+
if (!superset.has(field)) {
|
|
2280
|
+
return false;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
return true;
|
|
2284
|
+
}
|
|
2285
|
+
function filterToFields(value, allowedFields) {
|
|
2286
|
+
const result = {
|
|
2287
|
+
...value
|
|
2288
|
+
};
|
|
2289
|
+
const allFields = Object.keys(result);
|
|
2290
|
+
for (const field of allFields) {
|
|
2291
|
+
if (!allowedFields.has(field)) {
|
|
2292
|
+
deleteField(result, field);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
return result;
|
|
2296
|
+
}
|
|
2297
|
+
function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue) {
|
|
2298
|
+
if (targetRdpFields.size === 0) {
|
|
2299
|
+
return stripRdpFields(sourceValue, sourceRdpFields);
|
|
2300
|
+
}
|
|
2301
|
+
if (isSuperset(sourceRdpFields, targetRdpFields)) {
|
|
2302
|
+
if (sourceRdpFields.size === targetRdpFields.size) {
|
|
2303
|
+
return sourceValue;
|
|
2304
|
+
}
|
|
2305
|
+
return filterToFields(sourceValue, targetRdpFields);
|
|
2306
|
+
}
|
|
2307
|
+
const merged = {
|
|
2308
|
+
...sourceValue
|
|
2309
|
+
};
|
|
2310
|
+
if (targetCurrentValue) {
|
|
2311
|
+
const targetAsRecord = targetCurrentValue;
|
|
2312
|
+
for (const field of targetRdpFields) {
|
|
2313
|
+
if (!sourceRdpFields.has(field) && field in targetCurrentValue) {
|
|
2314
|
+
setField(merged, field, targetAsRecord[field]);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
return merged;
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
// src/observable/internal/object/ObjectCacheKeyRegistry.ts
|
|
2322
|
+
var ObjectCacheKeyRegistry = class {
|
|
2323
|
+
/**
|
|
2324
|
+
* Map from base key (apiName:primaryKey) to all related cache key variants and metadata
|
|
2325
|
+
*/
|
|
2326
|
+
baseToVariants = /* @__PURE__ */ new Map();
|
|
2327
|
+
/**
|
|
2328
|
+
* Metadata for each cache key (apiName, primaryKey, rdpConfig)
|
|
2329
|
+
*/
|
|
2330
|
+
keyMetadata = /* @__PURE__ */ new WeakMap();
|
|
2331
|
+
/**
|
|
2332
|
+
* Register a cache key variant for an object
|
|
2333
|
+
*/
|
|
2334
|
+
register(cacheKey, apiName, primaryKey, rdpConfig) {
|
|
2335
|
+
const baseKey = this.makeBaseKey(apiName, primaryKey);
|
|
2336
|
+
const primaryKeyStr = String(primaryKey);
|
|
2337
|
+
this.keyMetadata.set(cacheKey, {
|
|
2338
|
+
apiName,
|
|
2339
|
+
primaryKey: primaryKeyStr,
|
|
2340
|
+
rdpConfig,
|
|
2341
|
+
rdpFieldSet: rdpConfig ? extractRdpFieldNames(rdpConfig) : void 0
|
|
2342
|
+
});
|
|
2343
|
+
let entry = this.baseToVariants.get(baseKey);
|
|
2344
|
+
if (!entry) {
|
|
2345
|
+
entry = {
|
|
2346
|
+
variants: /* @__PURE__ */ new Set(),
|
|
2347
|
+
apiName,
|
|
2348
|
+
primaryKey: primaryKeyStr
|
|
2349
|
+
};
|
|
2350
|
+
this.baseToVariants.set(baseKey, entry);
|
|
2351
|
+
}
|
|
2352
|
+
entry.variants.add(cacheKey);
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Get all variant cache keys for a specific object
|
|
2356
|
+
*/
|
|
2357
|
+
getVariants(apiName, primaryKey) {
|
|
2358
|
+
const baseKey = this.makeBaseKey(apiName, primaryKey);
|
|
2359
|
+
const entry = this.baseToVariants.get(baseKey);
|
|
2360
|
+
return new Set(entry?.variants ?? []);
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Unregister a cache key when it's being cleaned up
|
|
2364
|
+
*/
|
|
2365
|
+
unregister(cacheKey) {
|
|
2366
|
+
const metadata = this.keyMetadata.get(cacheKey);
|
|
2367
|
+
if (!metadata) return;
|
|
2368
|
+
const baseKey = this.makeBaseKey(metadata.apiName, metadata.primaryKey);
|
|
2369
|
+
const entry = this.baseToVariants.get(baseKey);
|
|
2370
|
+
if (entry) {
|
|
2371
|
+
entry.variants.delete(cacheKey);
|
|
2372
|
+
if (entry.variants.size === 0) {
|
|
2373
|
+
this.baseToVariants.delete(baseKey);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
this.keyMetadata.delete(cacheKey);
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Get metadata for a cache key
|
|
2380
|
+
*/
|
|
2381
|
+
getMetadata(cacheKey) {
|
|
2382
|
+
return this.keyMetadata.get(cacheKey);
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Get the count of variants for a specific object
|
|
2386
|
+
*/
|
|
2387
|
+
getVariantCount(apiName, primaryKey) {
|
|
2388
|
+
const baseKey = this.makeBaseKey(apiName, primaryKey);
|
|
2389
|
+
return this.baseToVariants.get(baseKey)?.variants.size ?? 0;
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Generate a base key from apiName and primaryKey
|
|
2393
|
+
*/
|
|
2394
|
+
makeBaseKey(apiName, primaryKey) {
|
|
2395
|
+
return `${apiName}:${primaryKey}`;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Check if a cache key has RDP configuration
|
|
2399
|
+
*/
|
|
2400
|
+
hasRdpConfig(cacheKey) {
|
|
2401
|
+
return this.keyMetadata.get(cacheKey)?.rdpConfig != null;
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Get the RDP configuration for a cache key
|
|
2405
|
+
*/
|
|
2406
|
+
getRdpConfig(cacheKey) {
|
|
2407
|
+
return this.keyMetadata.get(cacheKey)?.rdpConfig;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Get the cached RDP field set for a cache key
|
|
2411
|
+
*/
|
|
2412
|
+
getRdpFieldSet(cacheKey) {
|
|
2413
|
+
return this.keyMetadata.get(cacheKey)?.rdpFieldSet ?? /* @__PURE__ */ new Set();
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2188
2417
|
// ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
|
|
2189
2418
|
function pDefer() {
|
|
2190
2419
|
const deferred = {};
|
|
@@ -2211,7 +2440,7 @@ var BulkObjectLoader = class {
|
|
|
2211
2440
|
#maxEntries;
|
|
2212
2441
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
2213
2442
|
this.#client = client;
|
|
2214
|
-
this.#logger = client[
|
|
2443
|
+
this.#logger = client[chunkVNLY3YOJ_cjs.additionalContext].logger;
|
|
2215
2444
|
this.#maxWait = maxWait;
|
|
2216
2445
|
this.#maxEntries = maxEntries;
|
|
2217
2446
|
}
|
|
@@ -2246,13 +2475,18 @@ var BulkObjectLoader = class {
|
|
|
2246
2475
|
};
|
|
2247
2476
|
const objMetadata = await this.#client.fetchMetadata(miniDef);
|
|
2248
2477
|
const pks = arr.map((x) => x.primaryKey);
|
|
2249
|
-
const {
|
|
2250
|
-
|
|
2251
|
-
|
|
2478
|
+
const whereClause = pks.length === 1 ? {
|
|
2479
|
+
[objMetadata.primaryKeyApiName]: {
|
|
2480
|
+
$eq: pks[0]
|
|
2481
|
+
}
|
|
2482
|
+
} : {
|
|
2252
2483
|
[objMetadata.primaryKeyApiName]: {
|
|
2253
2484
|
$in: pks
|
|
2254
2485
|
}
|
|
2255
|
-
}
|
|
2486
|
+
};
|
|
2487
|
+
const {
|
|
2488
|
+
data
|
|
2489
|
+
} = await this.#client(miniDef).where(whereClause).fetchPage({
|
|
2256
2490
|
$pageSize: pks.length
|
|
2257
2491
|
});
|
|
2258
2492
|
for (const {
|
|
@@ -2274,7 +2508,7 @@ var ObjectQuery = class extends Query {
|
|
|
2274
2508
|
#apiName;
|
|
2275
2509
|
#pk;
|
|
2276
2510
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
2277
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
2511
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
2278
2512
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2279
2513
|
}) : void 0);
|
|
2280
2514
|
this.#apiName = type;
|
|
@@ -2309,62 +2543,17 @@ var ObjectQuery = class extends Query {
|
|
|
2309
2543
|
});
|
|
2310
2544
|
}
|
|
2311
2545
|
writeToStore(data, status, batch) {
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
methodName: "writeToStore"
|
|
2318
|
-
}).debug(`Object was deep equal and status unchanged (${status}), skipping update`);
|
|
2319
|
-
}
|
|
2320
|
-
return entry;
|
|
2321
|
-
}
|
|
2322
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2323
|
-
this.logger?.child({
|
|
2324
|
-
methodName: "writeToStore"
|
|
2325
|
-
}).debug(`Object was deep equal, just setting status (old status: ${entry.status}, new status: ${status})`);
|
|
2326
|
-
}
|
|
2327
|
-
return batch.write(this.cacheKey, entry.value, status);
|
|
2328
|
-
}
|
|
2329
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2330
|
-
this.logger?.child({
|
|
2331
|
-
methodName: "writeToStore"
|
|
2332
|
-
}).debug(JSON.stringify({
|
|
2333
|
-
status
|
|
2334
|
-
}), data);
|
|
2335
|
-
}
|
|
2336
|
-
const ret = batch.write(this.cacheKey, data, status);
|
|
2337
|
-
batch.changes.registerObject(
|
|
2338
|
-
this.cacheKey,
|
|
2339
|
-
data,
|
|
2340
|
-
/* isNew */
|
|
2341
|
-
!entry
|
|
2342
|
-
);
|
|
2343
|
-
return ret;
|
|
2546
|
+
batch.read(this.cacheKey);
|
|
2547
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_CONFIG_IDX];
|
|
2548
|
+
this.store.objectCacheKeyRegistry.register(this.cacheKey, this.#apiName, this.#pk, rdpConfig);
|
|
2549
|
+
this.store.objects.propagateWrite(this.cacheKey, data, status, batch);
|
|
2550
|
+
return batch.read(this.cacheKey);
|
|
2344
2551
|
}
|
|
2345
2552
|
deleteFromStore(status, batch) {
|
|
2346
|
-
const
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
methodName: "deleteFromStore"
|
|
2351
|
-
}).debug(`Object was deep equal, just setting status`);
|
|
2352
|
-
}
|
|
2353
|
-
return batch.write(this.cacheKey, entry.value, status);
|
|
2354
|
-
}
|
|
2355
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2356
|
-
this.logger?.child({
|
|
2357
|
-
methodName: "deleteFromStore"
|
|
2358
|
-
}).debug(JSON.stringify({
|
|
2359
|
-
status
|
|
2360
|
-
}));
|
|
2361
|
-
}
|
|
2362
|
-
if (!entry || !entry.value) {
|
|
2363
|
-
return;
|
|
2364
|
-
}
|
|
2365
|
-
const ret = batch.delete(this.cacheKey, status);
|
|
2366
|
-
batch.changes.deleteObject(this.cacheKey);
|
|
2367
|
-
return ret;
|
|
2553
|
+
const rdpConfig = this.cacheKey.otherKeys[RDP_CONFIG_IDX];
|
|
2554
|
+
this.store.objectCacheKeyRegistry.register(this.cacheKey, this.#apiName, this.#pk, rdpConfig);
|
|
2555
|
+
this.store.objects.propagateWrite(this.cacheKey, tombstone, status, batch);
|
|
2556
|
+
return batch.read(this.cacheKey);
|
|
2368
2557
|
}
|
|
2369
2558
|
invalidateObjectType = (objectType, changes) => {
|
|
2370
2559
|
if (this.#apiName === objectType) {
|
|
@@ -2380,26 +2569,79 @@ var ObjectsHelper = class extends AbstractHelper {
|
|
|
2380
2569
|
observe(options, subFn) {
|
|
2381
2570
|
return super.observe(options, subFn);
|
|
2382
2571
|
}
|
|
2383
|
-
getQuery(options) {
|
|
2572
|
+
getQuery(options, rdpConfig) {
|
|
2384
2573
|
const apiName = typeof options.apiName === "string" ? options.apiName : options.apiName.apiName;
|
|
2385
2574
|
const {
|
|
2386
2575
|
pk
|
|
2387
2576
|
} = options;
|
|
2388
|
-
const objectCacheKey = this.cacheKeys.get("object", apiName, pk);
|
|
2577
|
+
const objectCacheKey = this.cacheKeys.get("object", apiName, pk, rdpConfig ?? void 0);
|
|
2389
2578
|
return this.store.queries.get(objectCacheKey, () => new ObjectQuery(this.store, this.store.subjects.get(objectCacheKey), apiName, pk, objectCacheKey, {
|
|
2390
2579
|
dedupeInterval: 0
|
|
2391
2580
|
}));
|
|
2392
2581
|
}
|
|
2393
2582
|
/**
|
|
2394
2583
|
* Internal helper method for writing objects to the store and returning their
|
|
2395
|
-
* object keys
|
|
2584
|
+
* object keys. For list queries with RDPs, the rdpConfig is included in the
|
|
2585
|
+
* cache key to ensure proper data isolation.
|
|
2396
2586
|
* @internal
|
|
2397
2587
|
*/
|
|
2398
|
-
storeOsdkInstances(values, batch) {
|
|
2588
|
+
storeOsdkInstances(values, batch, rdpConfig) {
|
|
2399
2589
|
return values.map((v) => this.getQuery({
|
|
2400
2590
|
apiName: v.$apiName,
|
|
2401
2591
|
pk: v.$primaryKey
|
|
2402
|
-
}).writeToStore(v, "loaded", batch).cacheKey);
|
|
2592
|
+
}, rdpConfig).writeToStore(v, "loaded", batch).cacheKey);
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Write an object to cache and propagate to all related cache keys
|
|
2596
|
+
* @internal
|
|
2597
|
+
*/
|
|
2598
|
+
propagateWrite(sourceCacheKey, value, status, batch) {
|
|
2599
|
+
const existing = batch.read(sourceCacheKey);
|
|
2600
|
+
const dataChanged = !existing || existing.value === void 0 || value === tombstone || !deepEqual__default.default(existing.value, value);
|
|
2601
|
+
const statusChanged = !existing || existing.status !== status;
|
|
2602
|
+
if (!dataChanged && !statusChanged) {
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
const valueToWrite = !dataChanged && existing ? existing.value : value;
|
|
2606
|
+
batch.write(sourceCacheKey, valueToWrite, status);
|
|
2607
|
+
if (value !== tombstone) {
|
|
2608
|
+
batch.changes.registerObject(sourceCacheKey, value, !existing);
|
|
2609
|
+
}
|
|
2610
|
+
const metadata = this.store.objectCacheKeyRegistry.getMetadata(sourceCacheKey);
|
|
2611
|
+
const relatedKeys = metadata ? this.store.objectCacheKeyRegistry.getVariants(metadata.apiName, metadata.primaryKey) : /* @__PURE__ */ new Set([sourceCacheKey]);
|
|
2612
|
+
for (const targetKey of relatedKeys) {
|
|
2613
|
+
if (targetKey === sourceCacheKey || !this.isKeyActive(targetKey)) {
|
|
2614
|
+
continue;
|
|
2615
|
+
}
|
|
2616
|
+
if (value === tombstone) {
|
|
2617
|
+
batch.write(targetKey, tombstone, status);
|
|
2618
|
+
continue;
|
|
2619
|
+
}
|
|
2620
|
+
const targetCurrentValue = batch.read(targetKey)?.value;
|
|
2621
|
+
const merged = this.mergeForTarget(value, targetCurrentValue && this.isObjectHolder(targetCurrentValue) ? targetCurrentValue : void 0, sourceCacheKey, targetKey);
|
|
2622
|
+
batch.write(targetKey, merged, status);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
* Check if a cache key is actively observed
|
|
2627
|
+
*/
|
|
2628
|
+
isKeyActive(key) {
|
|
2629
|
+
const subject = this.store.subjects.peek(key);
|
|
2630
|
+
return subject?.observed === true;
|
|
2631
|
+
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Type guard to check if a value is an ObjectHolder
|
|
2634
|
+
*/
|
|
2635
|
+
isObjectHolder(value) {
|
|
2636
|
+
return value != null && typeof value === "object" && "$apiName" in value && "$primaryKey" in value;
|
|
2637
|
+
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Merge object data for a specific target cache key, preserving RDP fields
|
|
2640
|
+
*/
|
|
2641
|
+
mergeForTarget(sourceValue, targetCurrentValue, sourceCacheKey, targetCacheKey) {
|
|
2642
|
+
const sourceRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(sourceCacheKey);
|
|
2643
|
+
const targetRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(targetCacheKey);
|
|
2644
|
+
return mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue);
|
|
2403
2645
|
}
|
|
2404
2646
|
};
|
|
2405
2647
|
|
|
@@ -2410,7 +2652,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2410
2652
|
#composedObjectSet;
|
|
2411
2653
|
#objectTypes;
|
|
2412
2654
|
constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
|
|
2413
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
2655
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
2414
2656
|
msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
2415
2657
|
}) : void 0);
|
|
2416
2658
|
this.#baseObjectSetWire = baseObjectSetWire;
|
|
@@ -2453,7 +2695,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2453
2695
|
}
|
|
2454
2696
|
if (opts.union) {
|
|
2455
2697
|
for (const os of opts.union) {
|
|
2456
|
-
const wire =
|
|
2698
|
+
const wire = chunkVNLY3YOJ_cjs.getWireObjectSet(os);
|
|
2457
2699
|
if (wire.type) {
|
|
2458
2700
|
types.add(wire.type);
|
|
2459
2701
|
}
|
|
@@ -2461,7 +2703,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2461
2703
|
}
|
|
2462
2704
|
if (opts.intersect) {
|
|
2463
2705
|
for (const os of opts.intersect) {
|
|
2464
|
-
const wire =
|
|
2706
|
+
const wire = chunkVNLY3YOJ_cjs.getWireObjectSet(os);
|
|
2465
2707
|
if (wire.type) {
|
|
2466
2708
|
types.add(wire.type);
|
|
2467
2709
|
}
|
|
@@ -2469,7 +2711,7 @@ var ObjectSetQuery = class extends BaseListQuery {
|
|
|
2469
2711
|
}
|
|
2470
2712
|
if (opts.subtract) {
|
|
2471
2713
|
for (const os of opts.subtract) {
|
|
2472
|
-
const wire =
|
|
2714
|
+
const wire = chunkVNLY3YOJ_cjs.getWireObjectSet(os);
|
|
2473
2715
|
if (wire.type) {
|
|
2474
2716
|
types.add(wire.type);
|
|
2475
2717
|
}
|
|
@@ -2543,7 +2785,7 @@ var ObjectSetHelper = class extends AbstractHelper {
|
|
|
2543
2785
|
const {
|
|
2544
2786
|
baseObjectSet
|
|
2545
2787
|
} = options;
|
|
2546
|
-
const baseObjectSetWire = JSON.stringify(
|
|
2788
|
+
const baseObjectSetWire = JSON.stringify(chunkVNLY3YOJ_cjs.getWireObjectSet(baseObjectSet));
|
|
2547
2789
|
const operations = this.buildCanonicalizedOperations(options);
|
|
2548
2790
|
const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
|
|
2549
2791
|
return this.store.queries.get(objectSetCacheKey, () => {
|
|
@@ -2559,13 +2801,13 @@ var ObjectSetHelper = class extends AbstractHelper {
|
|
|
2559
2801
|
operations.withProperties = Object.keys(options.withProperties).sort();
|
|
2560
2802
|
}
|
|
2561
2803
|
if (options.union && options.union.length > 0) {
|
|
2562
|
-
operations.union = options.union.map((os) => JSON.stringify(
|
|
2804
|
+
operations.union = options.union.map((os) => JSON.stringify(chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
2563
2805
|
}
|
|
2564
2806
|
if (options.intersect && options.intersect.length > 0) {
|
|
2565
|
-
operations.intersect = options.intersect.map((os) => JSON.stringify(
|
|
2807
|
+
operations.intersect = options.intersect.map((os) => JSON.stringify(chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
2566
2808
|
}
|
|
2567
2809
|
if (options.subtract && options.subtract.length > 0) {
|
|
2568
|
-
operations.subtract = options.subtract.map((os) => JSON.stringify(
|
|
2810
|
+
operations.subtract = options.subtract.map((os) => JSON.stringify(chunkVNLY3YOJ_cjs.getWireObjectSet(os)));
|
|
2569
2811
|
}
|
|
2570
2812
|
if (options.pivotTo) {
|
|
2571
2813
|
operations.pivotTo = options.pivotTo;
|
|
@@ -2605,12 +2847,85 @@ var Queries = class {
|
|
|
2605
2847
|
}
|
|
2606
2848
|
};
|
|
2607
2849
|
|
|
2850
|
+
// src/observable/internal/Canonicalizer.ts
|
|
2851
|
+
var CachingCanonicalizer = class {
|
|
2852
|
+
/**
|
|
2853
|
+
* Cache for input object identity.
|
|
2854
|
+
*/
|
|
2855
|
+
inputCache = /* @__PURE__ */ new WeakMap();
|
|
2856
|
+
/**
|
|
2857
|
+
* Look up or create a canonical form for the given input.
|
|
2858
|
+
* This method handles the structural deduplication logic.
|
|
2859
|
+
*
|
|
2860
|
+
* @param input The input to canonicalize
|
|
2861
|
+
* @returns The canonical form
|
|
2862
|
+
*/
|
|
2863
|
+
canonicalize(input) {
|
|
2864
|
+
if (!input) {
|
|
2865
|
+
return void 0;
|
|
2866
|
+
}
|
|
2867
|
+
if (this.inputCache.has(input)) {
|
|
2868
|
+
return this.inputCache.get(input);
|
|
2869
|
+
}
|
|
2870
|
+
const canonical = this.lookupOrCreate(input);
|
|
2871
|
+
this.inputCache.set(input, canonical);
|
|
2872
|
+
return canonical;
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
|
|
2876
|
+
// src/observable/internal/RdpCanonicalizer.ts
|
|
2877
|
+
var RdpCanonicalizer = class extends CachingCanonicalizer {
|
|
2878
|
+
structuralCache = /* @__PURE__ */ new Map();
|
|
2879
|
+
lookupOrCreate(rdp) {
|
|
2880
|
+
const definitionMap = /* @__PURE__ */ new Map();
|
|
2881
|
+
const computedProperties = {};
|
|
2882
|
+
const objectTypeHolder = {
|
|
2883
|
+
type: "object",
|
|
2884
|
+
apiName: "__rdp_canonicalizer_holder__"
|
|
2885
|
+
};
|
|
2886
|
+
for (const [key, rdpFunction] of Object.entries(rdp)) {
|
|
2887
|
+
const builder = chunkVNLY3YOJ_cjs.createWithPropertiesObjectSet(
|
|
2888
|
+
objectTypeHolder,
|
|
2889
|
+
{
|
|
2890
|
+
type: "methodInput"
|
|
2891
|
+
},
|
|
2892
|
+
definitionMap,
|
|
2893
|
+
/* fromBaseObjectSet */
|
|
2894
|
+
true
|
|
2895
|
+
);
|
|
2896
|
+
const result = rdpFunction(builder);
|
|
2897
|
+
const definition = definitionMap.get(result);
|
|
2898
|
+
if (definition) {
|
|
2899
|
+
computedProperties[key] = definition;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
const sortedKeys = Object.keys(computedProperties).sort();
|
|
2903
|
+
const sortedDefinitions = {};
|
|
2904
|
+
for (const key of sortedKeys) {
|
|
2905
|
+
sortedDefinitions[key] = computedProperties[key];
|
|
2906
|
+
}
|
|
2907
|
+
const definitionsKey = JSON.stringify(sortedDefinitions);
|
|
2908
|
+
let canonical = this.structuralCache.get(definitionsKey);
|
|
2909
|
+
if (!canonical) {
|
|
2910
|
+
const sortedRdp = {};
|
|
2911
|
+
for (const key of Object.keys(rdp).sort()) {
|
|
2912
|
+
sortedRdp[key] = rdp[key];
|
|
2913
|
+
}
|
|
2914
|
+
canonical = sortedRdp;
|
|
2915
|
+
this.structuralCache.set(definitionsKey, canonical);
|
|
2916
|
+
}
|
|
2917
|
+
return canonical;
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
|
|
2608
2921
|
// src/observable/internal/Store.ts
|
|
2609
2922
|
var Store = class {
|
|
2610
2923
|
whereCanonicalizer = new WhereClauseCanonicalizer();
|
|
2611
2924
|
orderByCanonicalizer = new OrderByCanonicalizer();
|
|
2925
|
+
rdpCanonicalizer = new RdpCanonicalizer();
|
|
2612
2926
|
/** @internal */
|
|
2613
2927
|
queries = new Queries();
|
|
2928
|
+
objectCacheKeyRegistry = new ObjectCacheKeyRegistry();
|
|
2614
2929
|
layers = new Layers({
|
|
2615
2930
|
logger: this.logger,
|
|
2616
2931
|
onRevalidate: this.#maybeRevalidateQueries.bind(this)
|
|
@@ -2618,14 +2933,14 @@ var Store = class {
|
|
|
2618
2933
|
subjects = this.layers.subjects;
|
|
2619
2934
|
// these are hopefully temporary
|
|
2620
2935
|
constructor(client) {
|
|
2621
|
-
this.logger = client[
|
|
2936
|
+
this.logger = client[chunkVNLY3YOJ_cjs.additionalContext].logger?.child({}, {
|
|
2622
2937
|
msgPrefix: "Store"
|
|
2623
2938
|
});
|
|
2624
2939
|
this.client = client;
|
|
2625
2940
|
this.cacheKeys = new CacheKeys({
|
|
2626
2941
|
onDestroy: this.#cleanupCacheKey
|
|
2627
2942
|
});
|
|
2628
|
-
this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2943
|
+
this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer);
|
|
2629
2944
|
this.objects = new ObjectsHelper(this, this.cacheKeys);
|
|
2630
2945
|
this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
2631
2946
|
this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
@@ -2637,7 +2952,7 @@ var Store = class {
|
|
|
2637
2952
|
#cleanupCacheKey = (key) => {
|
|
2638
2953
|
const subject = this.subjects.peek(key);
|
|
2639
2954
|
if (process.env.NODE_ENV !== "production") {
|
|
2640
|
-
!subject ? process.env.NODE_ENV !== "production" ?
|
|
2955
|
+
!subject ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false) : invariant4__default.default(false) : void 0;
|
|
2641
2956
|
}
|
|
2642
2957
|
this.subjects.delete(key);
|
|
2643
2958
|
this.queries.delete(key);
|
|
@@ -2668,13 +2983,28 @@ var Store = class {
|
|
|
2668
2983
|
if (typeof apiName !== "string") {
|
|
2669
2984
|
apiName = apiName.apiName;
|
|
2670
2985
|
}
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2986
|
+
const variants = this.objectCacheKeyRegistry.getVariants(apiName, pk);
|
|
2987
|
+
const promises = [];
|
|
2988
|
+
if (variants.size === 0) {
|
|
2989
|
+
promises.push(this.objects.getQuery({
|
|
2990
|
+
apiName,
|
|
2991
|
+
pk
|
|
2992
|
+
}, void 0).revalidate(
|
|
2993
|
+
/* force */
|
|
2994
|
+
true
|
|
2995
|
+
));
|
|
2996
|
+
} else {
|
|
2997
|
+
for (const key of variants) {
|
|
2998
|
+
const query = this.queries.peek(key);
|
|
2999
|
+
if (query) {
|
|
3000
|
+
promises.push(query.revalidate(
|
|
3001
|
+
/* force */
|
|
3002
|
+
true
|
|
3003
|
+
));
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
return Promise.allSettled(promises);
|
|
2678
3008
|
}
|
|
2679
3009
|
async #maybeRevalidateQueries(changes, optimisticId) {
|
|
2680
3010
|
const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
|
|
@@ -2694,7 +3024,17 @@ var Store = class {
|
|
|
2694
3024
|
try {
|
|
2695
3025
|
const promises = [];
|
|
2696
3026
|
for (const cacheKey of this.queries.keys()) {
|
|
2697
|
-
const
|
|
3027
|
+
const query = this.queries.peek(cacheKey);
|
|
3028
|
+
if (!query?.maybeUpdateAndRevalidate) {
|
|
3029
|
+
continue;
|
|
3030
|
+
}
|
|
3031
|
+
if (!this.#shouldPropagateToQuery({
|
|
3032
|
+
cacheKey,
|
|
3033
|
+
maybeUpdateAndRevalidate: query.maybeUpdateAndRevalidate
|
|
3034
|
+
}, changes, optimisticId)) {
|
|
3035
|
+
continue;
|
|
3036
|
+
}
|
|
3037
|
+
const promise = query.maybeUpdateAndRevalidate(changes, optimisticId);
|
|
2698
3038
|
if (promise) promises.push(promise);
|
|
2699
3039
|
}
|
|
2700
3040
|
await Promise.all(promises);
|
|
@@ -2704,6 +3044,103 @@ var Store = class {
|
|
|
2704
3044
|
}
|
|
2705
3045
|
}
|
|
2706
3046
|
}
|
|
3047
|
+
/**
|
|
3048
|
+
* Determines whether changes should propagate to a specific query.
|
|
3049
|
+
* Prevents unnecessary observable pipeline execution for cross-propagation.
|
|
3050
|
+
*
|
|
3051
|
+
* @param query - The query to check
|
|
3052
|
+
* @param changes - The changes that occurred
|
|
3053
|
+
* @param optimisticId - Optional optimistic update ID
|
|
3054
|
+
* @returns true if the query should be notified of these changes
|
|
3055
|
+
*/
|
|
3056
|
+
#shouldPropagateToQuery(query, changes, optimisticId) {
|
|
3057
|
+
if (optimisticId) {
|
|
3058
|
+
return true;
|
|
3059
|
+
}
|
|
3060
|
+
if (changes.modified.has(query.cacheKey)) {
|
|
3061
|
+
return true;
|
|
3062
|
+
}
|
|
3063
|
+
if (this.#shouldPropagateForObjectTypeChanges(query.cacheKey, changes)) {
|
|
3064
|
+
return true;
|
|
3065
|
+
}
|
|
3066
|
+
const queryRdpConfig = this.#getQueryRdpConfig(query.cacheKey);
|
|
3067
|
+
return queryRdpConfig != null;
|
|
3068
|
+
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Checks if changes to an object type should propagate to a query.
|
|
3071
|
+
* This ensures queries receive updates when objects of their type are added/modified.
|
|
3072
|
+
*
|
|
3073
|
+
* @param cacheKey - The cache key of the query
|
|
3074
|
+
* @param changes - The changes that occurred
|
|
3075
|
+
* @returns true if the query should be notified based on object type changes
|
|
3076
|
+
*/
|
|
3077
|
+
#shouldPropagateForObjectTypeChanges(cacheKey, changes) {
|
|
3078
|
+
const queryObjectType = this.#getQueryObjectType(cacheKey);
|
|
3079
|
+
if (!queryObjectType) {
|
|
3080
|
+
return false;
|
|
3081
|
+
}
|
|
3082
|
+
const affected = this.#changesAffectObjectType(changes, queryObjectType);
|
|
3083
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3084
|
+
this.logger?.child({
|
|
3085
|
+
methodName: "shouldPropagateToQuery"
|
|
3086
|
+
}).debug(`Query type: ${queryObjectType}, affected: ${affected}`, {
|
|
3087
|
+
queryKey: DEBUG_ONLY__cacheKeyToString(cacheKey),
|
|
3088
|
+
addedCount: changes.addedObjects.get(queryObjectType)?.length ?? 0,
|
|
3089
|
+
modifiedCount: changes.modifiedObjects.get(queryObjectType)?.length ?? 0
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
return affected;
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* Extracts RDP configuration from a cache key if present.
|
|
3096
|
+
*
|
|
3097
|
+
* @param cacheKey - The cache key to check
|
|
3098
|
+
* @returns The RDP configuration, or undefined if not present
|
|
3099
|
+
*/
|
|
3100
|
+
#getQueryRdpConfig(cacheKey) {
|
|
3101
|
+
if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
|
|
3102
|
+
if (cacheKey.type === "object") {
|
|
3103
|
+
return cacheKey.otherKeys[RDP_CONFIG_IDX];
|
|
3104
|
+
} else if (cacheKey.type === "list") {
|
|
3105
|
+
return cacheKey.otherKeys[RDP_IDX];
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
return void 0;
|
|
3109
|
+
}
|
|
3110
|
+
/**
|
|
3111
|
+
* Extracts the object type (apiName) from a cache key.
|
|
3112
|
+
*
|
|
3113
|
+
* @param cacheKey - The cache key to check
|
|
3114
|
+
* @returns The object type/apiName, or undefined if not applicable
|
|
3115
|
+
*/
|
|
3116
|
+
#getQueryObjectType(cacheKey) {
|
|
3117
|
+
if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
|
|
3118
|
+
if (cacheKey.type === "object") {
|
|
3119
|
+
return cacheKey.otherKeys[API_NAME_IDX2];
|
|
3120
|
+
} else if (cacheKey.type === "list") {
|
|
3121
|
+
return cacheKey.otherKeys[API_NAME_IDX];
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
return void 0;
|
|
3125
|
+
}
|
|
3126
|
+
/**
|
|
3127
|
+
* Checks if changes affect a specific object type.
|
|
3128
|
+
*
|
|
3129
|
+
* @param changes - The changes to check
|
|
3130
|
+
* @param objectType - The object type to check for
|
|
3131
|
+
* @returns true if the changes include added or modified objects of this type
|
|
3132
|
+
*/
|
|
3133
|
+
#changesAffectObjectType(changes, objectType) {
|
|
3134
|
+
const addedForType = changes.addedObjects.get(objectType);
|
|
3135
|
+
if (addedForType && addedForType.length > 0) {
|
|
3136
|
+
return true;
|
|
3137
|
+
}
|
|
3138
|
+
const modifiedForType = changes.modifiedObjects.get(objectType);
|
|
3139
|
+
if (modifiedForType && modifiedForType.length > 0) {
|
|
3140
|
+
return true;
|
|
3141
|
+
}
|
|
3142
|
+
return false;
|
|
3143
|
+
}
|
|
2707
3144
|
/**
|
|
2708
3145
|
* Invalidates all cache entries for a specific object type.
|
|
2709
3146
|
* This will revalidate:
|
|
@@ -2757,10 +3194,10 @@ var Store = class {
|
|
|
2757
3194
|
|
|
2758
3195
|
// src/observable/ObservableClient.ts
|
|
2759
3196
|
function createObservableClient(client) {
|
|
2760
|
-
const tweakedClient =
|
|
2761
|
-
...client[
|
|
2762
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
2763
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
3197
|
+
const tweakedClient = chunkOSI7NG7T_cjs.createClientFromContext({
|
|
3198
|
+
...client[chunkVNLY3YOJ_cjs.additionalContext],
|
|
3199
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkVNLY3YOJ_cjs.additionalContext].fetch, (headers) => {
|
|
3200
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkOSI7NG7T_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
2764
3201
|
return headers;
|
|
2765
3202
|
})
|
|
2766
3203
|
});
|
|
@@ -2803,11 +3240,11 @@ function getOsdkConfig(ontologyRid) {
|
|
|
2803
3240
|
|
|
2804
3241
|
Object.defineProperty(exports, "createClientWithTransaction", {
|
|
2805
3242
|
enumerable: true,
|
|
2806
|
-
get: function () { return
|
|
3243
|
+
get: function () { return chunkOSI7NG7T_cjs.createClientWithTransaction; }
|
|
2807
3244
|
});
|
|
2808
3245
|
Object.defineProperty(exports, "augment", {
|
|
2809
3246
|
enumerable: true,
|
|
2810
|
-
get: function () { return
|
|
3247
|
+
get: function () { return chunkVNLY3YOJ_cjs.augment; }
|
|
2811
3248
|
});
|
|
2812
3249
|
exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
|
|
2813
3250
|
exports.createObservableClient = createObservableClient;
|