@osdk/client 2.5.0-beta.3 → 2.5.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 +29 -4
- package/build/browser/index.js +2 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/object/Cache.test.js +1 -1
- package/build/browser/object/Cache.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js +1 -0
- package/build/browser/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +6 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js +20 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +2 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- 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/OrderByCanonicalizer.js +1 -37
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/Store.js +1 -1
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +1 -1
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/WeakRefTrie.js +61 -0
- package/build/browser/observable/internal/WeakRefTrie.js.map +1 -0
- package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -0
- package/build/browser/observable/internal/{OptimisticJob.js → actions/OptimisticJob.js} +2 -2
- package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -0
- package/build/browser/observable/internal/base-list/BaseCollectionQuery.js.map +1 -0
- package/build/browser/observable/internal/base-list/BaseListQuery.js +414 -0
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -0
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -0
- package/build/{esm/observable/internal → browser/observable/internal/base-list}/createCollectionConnectable.test.js +1 -1
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -0
- package/build/browser/observable/internal/base-list/removeDuplicates.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/browser/observable/internal/links/SpecificLinkQuery.js +1 -1
- package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/browser/observable/internal/{ListCacheKey.js.map → list/ListCacheKey.js.map} +1 -1
- package/build/browser/observable/internal/{ListQuery.js → list/ListQuery.js} +7 -416
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -0
- package/build/browser/observable/internal/list/ListQueryOptions.js +2 -0
- package/build/browser/observable/internal/list/ListQueryOptions.js.map +1 -0
- package/build/browser/observable/internal/list/ListsHelper.js +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/object/ObjectCacheKey.js +2 -0
- package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -0
- package/build/browser/observable/internal/{ObjectQuery.js → object/ObjectQuery.js} +4 -20
- package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectsHelper.js +15 -1
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/browser/observable/internal/sorting/SortingStrategy.js.map +1 -1
- package/build/browser/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +1 -2
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/queries/applyQuery.js +1 -1
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/extractObjectOrInterfaceType.js +9 -1
- package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.test.js +2 -2
- package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/cjs/{chunk-BL56QBYG.cjs → chunk-ELAA4C2C.cjs} +29 -17
- package/build/cjs/chunk-ELAA4C2C.cjs.map +1 -0
- package/build/cjs/{chunk-AOGMSVFN.cjs → chunk-KCMGIMVC.cjs} +91 -69
- package/build/cjs/chunk-KCMGIMVC.cjs.map +1 -0
- package/build/cjs/index.cjs +7 -7
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +568 -572
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/esm/index.js +2 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/object/Cache.test.js +1 -1
- package/build/esm/object/Cache.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js +1 -0
- package/build/esm/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +6 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js +20 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +2 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- 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/OrderByCanonicalizer.js +1 -37
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/Store.js +1 -1
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +1 -1
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/WeakRefTrie.js +61 -0
- package/build/esm/observable/internal/WeakRefTrie.js.map +1 -0
- package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -0
- package/build/esm/observable/internal/{OptimisticJob.js → actions/OptimisticJob.js} +2 -2
- package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -0
- package/build/esm/observable/internal/base-list/BaseCollectionQuery.js.map +1 -0
- package/build/esm/observable/internal/base-list/BaseListQuery.js +414 -0
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -0
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -0
- package/build/{browser/observable/internal → esm/observable/internal/base-list}/createCollectionConnectable.test.js +1 -1
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -0
- package/build/esm/observable/internal/base-list/removeDuplicates.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
- package/build/esm/observable/internal/links/SpecificLinkQuery.js +1 -1
- package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/esm/observable/internal/{ListCacheKey.js.map → list/ListCacheKey.js.map} +1 -1
- package/build/esm/observable/internal/{ListQuery.js → list/ListQuery.js} +7 -416
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -0
- package/build/esm/observable/internal/list/ListQueryOptions.js +2 -0
- package/build/esm/observable/internal/list/ListQueryOptions.js.map +1 -0
- package/build/esm/observable/internal/list/ListsHelper.js +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/object/ObjectCacheKey.js +2 -0
- package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -0
- package/build/esm/observable/internal/{ObjectQuery.js → object/ObjectQuery.js} +4 -20
- package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectsHelper.js +15 -1
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
- package/build/esm/observable/internal/sorting/SortingStrategy.js.map +1 -1
- package/build/esm/observable/internal/testUtils/invalidateList.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +1 -2
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/queries/applyQuery.js +1 -1
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/extractObjectOrInterfaceType.js +9 -1
- package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.test.js +2 -2
- package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +2 -2
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts +2 -2
- package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts +0 -7
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/WeakRefTrie.d.ts +13 -0
- package/build/types/observable/internal/WeakRefTrie.d.ts.map +1 -0
- package/build/types/observable/internal/{ActionApplication.d.ts → actions/ActionApplication.d.ts} +2 -2
- package/build/types/observable/internal/{ActionApplication.d.ts.map → actions/ActionApplication.d.ts.map} +1 -1
- package/build/types/observable/internal/{OptimisticJob.d.ts → actions/OptimisticJob.d.ts} +4 -4
- package/build/types/observable/internal/actions/OptimisticJob.d.ts.map +1 -0
- package/build/types/observable/internal/{BaseCollectionQuery.d.ts → base-list/BaseCollectionQuery.d.ts} +4 -4
- package/build/types/observable/internal/base-list/BaseCollectionQuery.d.ts.map +1 -0
- package/build/types/observable/internal/{ListQuery.d.ts → base-list/BaseListQuery.d.ts} +8 -91
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/{createCollectionConnectable.d.ts → base-list/createCollectionConnectable.d.ts} +3 -3
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/createCollectionConnectable.test.d.ts.map +1 -0
- package/build/types/observable/internal/{removeDuplicates.d.ts → base-list/removeDuplicates.d.ts} +2 -2
- package/build/types/observable/internal/base-list/removeDuplicates.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +1 -1
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts +1 -1
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -1
- package/build/types/observable/internal/{ListCacheKey.d.ts → list/ListCacheKey.d.ts} +4 -4
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQuery.d.ts +73 -0
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQueryOptions.d.ts +4 -0
- package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListsHelper.d.ts +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts +5 -0
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/{ObjectQuery.d.ts → object/ObjectQuery.d.ts} +8 -10
- package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectsHelper.d.ts +1 -1
- package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/sorting/SortingStrategy.d.ts +1 -1
- package/build/types/observable/internal/sorting/SortingStrategy.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/package.json +23 -23
- package/build/browser/observable/internal/ActionApplication.js.map +0 -1
- package/build/browser/observable/internal/BaseCollectionQuery.js.map +0 -1
- package/build/browser/observable/internal/ListQuery.js.map +0 -1
- package/build/browser/observable/internal/ObjectQuery.js.map +0 -1
- package/build/browser/observable/internal/OptimisticJob.js.map +0 -1
- package/build/browser/observable/internal/createCollectionConnectable.js.map +0 -1
- package/build/browser/observable/internal/createCollectionConnectable.test.js.map +0 -1
- package/build/browser/observable/internal/removeDuplicates.js.map +0 -1
- package/build/cjs/chunk-AOGMSVFN.cjs.map +0 -1
- package/build/cjs/chunk-BL56QBYG.cjs.map +0 -1
- package/build/esm/observable/internal/ActionApplication.js.map +0 -1
- package/build/esm/observable/internal/BaseCollectionQuery.js.map +0 -1
- package/build/esm/observable/internal/ListQuery.js.map +0 -1
- package/build/esm/observable/internal/ObjectQuery.js.map +0 -1
- package/build/esm/observable/internal/OptimisticJob.js.map +0 -1
- package/build/esm/observable/internal/createCollectionConnectable.js.map +0 -1
- package/build/esm/observable/internal/createCollectionConnectable.test.js.map +0 -1
- package/build/esm/observable/internal/removeDuplicates.js.map +0 -1
- package/build/types/observable/internal/BaseCollectionQuery.d.ts.map +0 -1
- package/build/types/observable/internal/ListCacheKey.d.ts.map +0 -1
- package/build/types/observable/internal/ListQuery.d.ts.map +0 -1
- package/build/types/observable/internal/ObjectQuery.d.ts.map +0 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +0 -1
- package/build/types/observable/internal/createCollectionConnectable.d.ts.map +0 -1
- package/build/types/observable/internal/createCollectionConnectable.test.d.ts.map +0 -1
- package/build/types/observable/internal/removeDuplicates.d.ts.map +0 -1
- /package/build/browser/observable/internal/{ActionApplication.js → actions/ActionApplication.js} +0 -0
- /package/build/browser/observable/internal/{BaseCollectionQuery.js → base-list/BaseCollectionQuery.js} +0 -0
- /package/build/browser/observable/internal/{createCollectionConnectable.js → base-list/createCollectionConnectable.js} +0 -0
- /package/build/browser/observable/internal/{removeDuplicates.js → base-list/removeDuplicates.js} +0 -0
- /package/build/browser/observable/internal/{ListCacheKey.js → list/ListCacheKey.js} +0 -0
- /package/build/esm/observable/internal/{ActionApplication.js → actions/ActionApplication.js} +0 -0
- /package/build/esm/observable/internal/{BaseCollectionQuery.js → base-list/BaseCollectionQuery.js} +0 -0
- /package/build/esm/observable/internal/{createCollectionConnectable.js → base-list/createCollectionConnectable.js} +0 -0
- /package/build/esm/observable/internal/{removeDuplicates.js → base-list/removeDuplicates.js} +0 -0
- /package/build/esm/observable/internal/{ListCacheKey.js → list/ListCacheKey.js} +0 -0
- /package/build/types/observable/internal/{createCollectionConnectable.test.d.ts → base-list/createCollectionConnectable.test.d.ts} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkKCMGIMVC_cjs = require('../chunk-KCMGIMVC.cjs');
|
|
4
|
+
var chunkELAA4C2C_cjs = require('../chunk-ELAA4C2C.cjs');
|
|
5
5
|
require('../chunk-Q7SFCCGT.cjs');
|
|
6
6
|
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
8
|
var invariant2 = require('tiny-invariant');
|
|
9
9
|
var trie = require('@wry/trie');
|
|
10
10
|
var mnemonist = require('mnemonist');
|
|
11
|
-
var
|
|
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
17
|
var invariant2__default = /*#__PURE__*/_interopDefault(invariant2);
|
|
18
|
-
var
|
|
18
|
+
var deepEqual4__default = /*#__PURE__*/_interopDefault(deepEqual4);
|
|
19
19
|
var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
|
|
20
20
|
|
|
21
21
|
// src/observable/internal/UnsubscribableWrapper.ts
|
|
@@ -95,7 +95,7 @@ function createOptimisticId() {
|
|
|
95
95
|
return /* @__PURE__ */ Object.create(null);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// src/observable/internal/OptimisticJob.ts
|
|
98
|
+
// src/observable/internal/actions/OptimisticJob.ts
|
|
99
99
|
var OptimisticJob = class {
|
|
100
100
|
#result;
|
|
101
101
|
constructor(store, optimisticId) {
|
|
@@ -142,7 +142,7 @@ var OptimisticJob = class {
|
|
|
142
142
|
return this;
|
|
143
143
|
},
|
|
144
144
|
createObject(type, pk, properties) {
|
|
145
|
-
const create = store.client[
|
|
145
|
+
const create = store.client[chunkELAA4C2C_cjs.additionalContext].objectFactory2(store.client[chunkELAA4C2C_cjs.additionalContext], [{
|
|
146
146
|
$primaryKey: pk,
|
|
147
147
|
$apiName: type.apiName,
|
|
148
148
|
$objectType: type.apiName,
|
|
@@ -178,7 +178,7 @@ function runOptimisticJob(store, optimisticUpdate) {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
// src/observable/internal/ActionApplication.ts
|
|
181
|
+
// src/observable/internal/actions/ActionApplication.ts
|
|
182
182
|
var ACTION_DELAY = process.env.NODE_ENV === "production" ? 0 : 1e3;
|
|
183
183
|
var ActionApplication = class {
|
|
184
184
|
constructor(store) {
|
|
@@ -571,199 +571,11 @@ var AbstractHelper = class {
|
|
|
571
571
|
return new QuerySubscription(query, sub);
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
|
-
function createCollectionConnectable(subject, store, createPayload) {
|
|
575
|
-
return rxjs.connectable(subject.pipe(rxjs.switchMap((listEntry) => {
|
|
576
|
-
const resolvedData = listEntry?.value?.data == null || listEntry.value.data.length === 0 ? rxjs.of([]) : rxjs.combineLatest(listEntry.value.data.map((cacheKey) => store.getSubject(cacheKey).pipe(rxjs.map((objectEntry) => objectEntry?.value), rxjs.distinctUntilChanged())));
|
|
577
|
-
return rxjs.scheduled(rxjs.combineLatest({
|
|
578
|
-
resolvedData,
|
|
579
|
-
isOptimistic: rxjs.of(listEntry.isOptimistic),
|
|
580
|
-
status: rxjs.of(listEntry.status),
|
|
581
|
-
lastUpdated: rxjs.of(listEntry.lastUpdated)
|
|
582
|
-
}).pipe(rxjs.map((params) => createPayload({
|
|
583
|
-
resolvedData: Array.isArray(params.resolvedData) ? params.resolvedData : [],
|
|
584
|
-
isOptimistic: params.isOptimistic,
|
|
585
|
-
status: params.status,
|
|
586
|
-
lastUpdated: params.lastUpdated
|
|
587
|
-
}))), rxjs.asapScheduler);
|
|
588
|
-
})), {
|
|
589
|
-
resetOnDisconnect: false,
|
|
590
|
-
connector: () => new rxjs.ReplaySubject(1)
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
574
|
|
|
594
575
|
// src/observable/internal/isObjectInstance.ts
|
|
595
576
|
function isObjectInstance(item) {
|
|
596
577
|
return item != null && typeof item === "object" && "$primaryKey" in item;
|
|
597
578
|
}
|
|
598
|
-
function is$and(whereClause) {
|
|
599
|
-
if (process.env.NODE_ENV !== "production") {
|
|
600
|
-
if ("$and" in whereClause) {
|
|
601
|
-
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : void 0;
|
|
602
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : void 0;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
return "$and" in whereClause;
|
|
606
|
-
}
|
|
607
|
-
function is$or(whereClause) {
|
|
608
|
-
if (process.env.NODE_ENV !== "production") {
|
|
609
|
-
if ("$or" in whereClause) {
|
|
610
|
-
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $or to be an array") : invariant2__default.default(false) : void 0;
|
|
611
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $or to be present") : invariant2__default.default(false) : void 0;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
return "$or" in whereClause;
|
|
615
|
-
}
|
|
616
|
-
function is$not(whereClause) {
|
|
617
|
-
if (process.env.NODE_ENV !== "production") {
|
|
618
|
-
if ("$not" in whereClause) {
|
|
619
|
-
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $not to be present") : invariant2__default.default(false) : void 0;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return "$not" in whereClause;
|
|
623
|
-
}
|
|
624
|
-
function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
625
|
-
if (deepEqual2__default.default({}, whereClause)) {
|
|
626
|
-
return true;
|
|
627
|
-
}
|
|
628
|
-
if (is$and(whereClause)) {
|
|
629
|
-
return whereClause.$and.every((w) => objectSortaMatchesWhereClause(o, w, strict));
|
|
630
|
-
}
|
|
631
|
-
if (is$or(whereClause)) {
|
|
632
|
-
return whereClause.$or.some((w) => objectSortaMatchesWhereClause(o, w, strict));
|
|
633
|
-
}
|
|
634
|
-
if (is$not(whereClause)) {
|
|
635
|
-
return !objectSortaMatchesWhereClause(o, whereClause.$not, strict);
|
|
636
|
-
}
|
|
637
|
-
return Object.entries(whereClause).every(([key, filter]) => {
|
|
638
|
-
if (typeof filter === "object") {
|
|
639
|
-
const realValue = o[key];
|
|
640
|
-
const [f] = Object.keys(filter);
|
|
641
|
-
const expected = filter[f];
|
|
642
|
-
switch (f) {
|
|
643
|
-
case "$eq":
|
|
644
|
-
return realValue === expected;
|
|
645
|
-
case "$gt":
|
|
646
|
-
return realValue > expected;
|
|
647
|
-
case "$lt":
|
|
648
|
-
return realValue < expected;
|
|
649
|
-
case "$gte":
|
|
650
|
-
return realValue >= expected;
|
|
651
|
-
case "$lte":
|
|
652
|
-
return realValue <= expected;
|
|
653
|
-
case "$ne":
|
|
654
|
-
return realValue !== expected;
|
|
655
|
-
case "$in":
|
|
656
|
-
return expected.$in.includes(realValue);
|
|
657
|
-
case "$isNull":
|
|
658
|
-
return realValue == null;
|
|
659
|
-
case "$startsWith":
|
|
660
|
-
return realValue.startsWith(expected);
|
|
661
|
-
case "$contains":
|
|
662
|
-
case "$containsAllTerms":
|
|
663
|
-
case "$containsAllTermsInOrder":
|
|
664
|
-
case "$containsAnyTerm":
|
|
665
|
-
case "$intersects":
|
|
666
|
-
case "$within":
|
|
667
|
-
return !strict;
|
|
668
|
-
default:
|
|
669
|
-
if (process.env.NODE_ENV !== "production") {
|
|
670
|
-
process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Unknown where filter ${f}`) : invariant2__default.default(false) ;
|
|
671
|
-
}
|
|
672
|
-
return !strict;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
if (key in o) {
|
|
676
|
-
if (o[key] === filter) {
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
return false;
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
|
|
685
|
-
function pDefer() {
|
|
686
|
-
const deferred = {};
|
|
687
|
-
deferred.promise = new Promise((resolve, reject) => {
|
|
688
|
-
deferred.resolve = resolve;
|
|
689
|
-
deferred.reject = reject;
|
|
690
|
-
});
|
|
691
|
-
return deferred;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
// src/observable/internal/BulkObjectLoader.ts
|
|
695
|
-
var weakCache = new mnemonist.DefaultWeakMap((c) => new BulkObjectLoader(c));
|
|
696
|
-
function getBulkObjectLoader(client) {
|
|
697
|
-
return weakCache.get(client);
|
|
698
|
-
}
|
|
699
|
-
var BulkObjectLoader = class {
|
|
700
|
-
#client;
|
|
701
|
-
#m = new mnemonist.DefaultMap(() => ({
|
|
702
|
-
data: [],
|
|
703
|
-
timer: void 0
|
|
704
|
-
}));
|
|
705
|
-
#logger;
|
|
706
|
-
#maxWait;
|
|
707
|
-
#maxEntries;
|
|
708
|
-
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
709
|
-
this.#client = client;
|
|
710
|
-
this.#logger = client[chunkBL56QBYG_cjs.additionalContext].logger;
|
|
711
|
-
this.#maxWait = maxWait;
|
|
712
|
-
this.#maxEntries = maxEntries;
|
|
713
|
-
}
|
|
714
|
-
async fetch(apiName, primaryKey) {
|
|
715
|
-
const deferred = pDefer();
|
|
716
|
-
const entry = this.#m.get(apiName);
|
|
717
|
-
entry.data.push({
|
|
718
|
-
primaryKey,
|
|
719
|
-
deferred
|
|
720
|
-
});
|
|
721
|
-
if (!entry.timer) {
|
|
722
|
-
entry.timer = setTimeout(() => {
|
|
723
|
-
this.#loadObjects(apiName, entry.data);
|
|
724
|
-
}, this.#maxWait);
|
|
725
|
-
}
|
|
726
|
-
if (entry.data.length >= this.#maxEntries) {
|
|
727
|
-
clearTimeout(entry.timer);
|
|
728
|
-
this.#loadObjects(apiName, entry.data);
|
|
729
|
-
}
|
|
730
|
-
return await deferred.promise;
|
|
731
|
-
}
|
|
732
|
-
#loadObjects(apiName, arr) {
|
|
733
|
-
this.#m.delete(apiName);
|
|
734
|
-
this.#reallyLoadObjects(apiName, arr).catch((e) => {
|
|
735
|
-
this.#logger?.error("Unhandled exception", e);
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
async #reallyLoadObjects(apiName, arr) {
|
|
739
|
-
const miniDef = {
|
|
740
|
-
type: "object",
|
|
741
|
-
apiName
|
|
742
|
-
};
|
|
743
|
-
const objMetadata = await this.#client.fetchMetadata(miniDef);
|
|
744
|
-
const pks = arr.map((x) => x.primaryKey);
|
|
745
|
-
const {
|
|
746
|
-
data
|
|
747
|
-
} = await this.#client(miniDef).where({
|
|
748
|
-
[objMetadata.primaryKeyApiName]: {
|
|
749
|
-
$in: pks
|
|
750
|
-
}
|
|
751
|
-
}).fetchPage({
|
|
752
|
-
$pageSize: pks.length
|
|
753
|
-
});
|
|
754
|
-
for (const {
|
|
755
|
-
primaryKey,
|
|
756
|
-
deferred
|
|
757
|
-
} of arr) {
|
|
758
|
-
const object = data.find((x) => x.$primaryKey === primaryKey);
|
|
759
|
-
if (object) {
|
|
760
|
-
deferred.resolve(object);
|
|
761
|
-
} else {
|
|
762
|
-
deferred.reject(new shared_net_errors.PalantirApiError(`Object not found: ${primaryKey}`));
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
579
|
|
|
768
580
|
// src/observable/internal/Query.ts
|
|
769
581
|
var Query = class {
|
|
@@ -777,7 +589,7 @@ var Query = class {
|
|
|
777
589
|
this.cacheKey = cacheKey;
|
|
778
590
|
this.store = store;
|
|
779
591
|
this.#subject = observable;
|
|
780
|
-
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[
|
|
592
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkELAA4C2C_cjs.additionalContext].logger : store.client[chunkELAA4C2C_cjs.additionalContext].logger?.child({}, {
|
|
781
593
|
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
782
594
|
}));
|
|
783
595
|
}
|
|
@@ -891,157 +703,27 @@ var Query = class {
|
|
|
891
703
|
*/
|
|
892
704
|
};
|
|
893
705
|
|
|
894
|
-
// src/observable/internal/
|
|
895
|
-
var
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
var ObjectQuery = class extends Query {
|
|
899
|
-
#apiName;
|
|
900
|
-
#pk;
|
|
901
|
-
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
902
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkBL56QBYG_cjs.additionalContext].logger?.child({}, {
|
|
903
|
-
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
904
|
-
}) : void 0);
|
|
905
|
-
this.#apiName = type;
|
|
906
|
-
this.#pk = pk;
|
|
706
|
+
// src/observable/internal/sorting/SortingStrategy.ts
|
|
707
|
+
var NoOpSortingStrategy = class {
|
|
708
|
+
sortCacheKeys(objectCacheKeys, _batch) {
|
|
709
|
+
return objectCacheKeys;
|
|
907
710
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
isOptimistic: x.isOptimistic
|
|
915
|
-
};
|
|
916
|
-
})), {
|
|
917
|
-
connector: () => new rxjs.BehaviorSubject({
|
|
918
|
-
status: "init",
|
|
919
|
-
object: void 0,
|
|
920
|
-
lastUpdated: 0,
|
|
921
|
-
isOptimistic: false
|
|
922
|
-
})
|
|
923
|
-
});
|
|
711
|
+
};
|
|
712
|
+
var OrderBySortingStrategy = class {
|
|
713
|
+
constructor(apiName, orderBy) {
|
|
714
|
+
this.apiName = apiName;
|
|
715
|
+
this.orderBy = orderBy;
|
|
716
|
+
this.sortFns = createOrderBySortFns(orderBy);
|
|
924
717
|
}
|
|
925
|
-
|
|
926
|
-
if (
|
|
927
|
-
|
|
928
|
-
methodName: "_fetchAndStore"
|
|
929
|
-
}).debug("calling _fetchAndStore");
|
|
718
|
+
sortCacheKeys(objectCacheKeys, batch) {
|
|
719
|
+
if (Object.keys(this.orderBy).length === 0) {
|
|
720
|
+
return objectCacheKeys;
|
|
930
721
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
writeToStore(data, status, batch) {
|
|
937
|
-
const entry = batch.read(this.cacheKey);
|
|
938
|
-
if (entry && deepEqual2__default.default(data, entry.value)) {
|
|
939
|
-
if (entry.status === status) {
|
|
940
|
-
if (process.env.NODE_ENV !== "production") {
|
|
941
|
-
this.logger?.child({
|
|
942
|
-
methodName: "writeToStore"
|
|
943
|
-
}).debug(`Object was deep equal and status unchanged (${status}), skipping update`);
|
|
944
|
-
}
|
|
945
|
-
return entry;
|
|
946
|
-
}
|
|
947
|
-
if (process.env.NODE_ENV !== "production") {
|
|
948
|
-
this.logger?.child({
|
|
949
|
-
methodName: "writeToStore"
|
|
950
|
-
}).debug(`Object was deep equal, just setting status (old status: ${entry.status}, new status: ${status})`);
|
|
951
|
-
}
|
|
952
|
-
return batch.write(this.cacheKey, entry.value, status);
|
|
953
|
-
}
|
|
954
|
-
if (process.env.NODE_ENV !== "production") {
|
|
955
|
-
this.logger?.child({
|
|
956
|
-
methodName: "writeToStore"
|
|
957
|
-
}).debug(JSON.stringify({
|
|
958
|
-
status
|
|
959
|
-
}), data);
|
|
960
|
-
}
|
|
961
|
-
const ret = batch.write(this.cacheKey, data, status);
|
|
962
|
-
batch.changes.registerObject(
|
|
963
|
-
this.cacheKey,
|
|
964
|
-
data,
|
|
965
|
-
/* isNew */
|
|
966
|
-
!entry
|
|
967
|
-
);
|
|
968
|
-
return ret;
|
|
969
|
-
}
|
|
970
|
-
deleteFromStore(status, batch) {
|
|
971
|
-
const entry = batch.read(this.cacheKey);
|
|
972
|
-
if (entry && deepEqual2__default.default(tombstone, entry.value)) {
|
|
973
|
-
if (process.env.NODE_ENV !== "production") {
|
|
974
|
-
this.logger?.child({
|
|
975
|
-
methodName: "deleteFromStore"
|
|
976
|
-
}).debug(`Object was deep equal, just setting status`);
|
|
977
|
-
}
|
|
978
|
-
return batch.write(this.cacheKey, entry.value, status);
|
|
979
|
-
}
|
|
980
|
-
if (process.env.NODE_ENV !== "production") {
|
|
981
|
-
this.logger?.child({
|
|
982
|
-
methodName: "deleteFromStore"
|
|
983
|
-
}).debug(JSON.stringify({
|
|
984
|
-
status
|
|
985
|
-
}));
|
|
986
|
-
}
|
|
987
|
-
if (!entry || !entry.value) {
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
const ret = batch.delete(this.cacheKey, status);
|
|
991
|
-
batch.changes.deleteObject(this.cacheKey);
|
|
992
|
-
return ret;
|
|
993
|
-
}
|
|
994
|
-
invalidateObjectType = (objectType, changes) => {
|
|
995
|
-
if (this.#apiName === objectType) {
|
|
996
|
-
changes?.modified.add(this.cacheKey);
|
|
997
|
-
return this.revalidate(true);
|
|
998
|
-
}
|
|
999
|
-
return Promise.resolve();
|
|
1000
|
-
};
|
|
1001
|
-
};
|
|
1002
|
-
function storeOsdkInstances(store, values, batch) {
|
|
1003
|
-
return values.map((v) => {
|
|
1004
|
-
return store.objects.getQuery({
|
|
1005
|
-
apiName: v.$apiName,
|
|
1006
|
-
pk: v.$primaryKey
|
|
1007
|
-
}).writeToStore(v, "loaded", batch).cacheKey;
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// src/observable/internal/removeDuplicates.ts
|
|
1012
|
-
function removeDuplicates(objectCacheKeys, batch) {
|
|
1013
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1014
|
-
return objectCacheKeys.filter((key) => {
|
|
1015
|
-
batch.read(key);
|
|
1016
|
-
if (visited.has(key)) {
|
|
1017
|
-
return false;
|
|
1018
|
-
}
|
|
1019
|
-
visited.add(key);
|
|
1020
|
-
return true;
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
// src/observable/internal/sorting/SortingStrategy.ts
|
|
1025
|
-
var NoOpSortingStrategy = class {
|
|
1026
|
-
sortCacheKeys(objectCacheKeys, _batch) {
|
|
1027
|
-
return objectCacheKeys;
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
var OrderBySortingStrategy = class {
|
|
1031
|
-
constructor(apiName, orderBy) {
|
|
1032
|
-
this.apiName = apiName;
|
|
1033
|
-
this.orderBy = orderBy;
|
|
1034
|
-
this.sortFns = createOrderBySortFns(orderBy);
|
|
1035
|
-
}
|
|
1036
|
-
sortCacheKeys(objectCacheKeys, batch) {
|
|
1037
|
-
if (Object.keys(this.orderBy).length === 0) {
|
|
1038
|
-
return objectCacheKeys;
|
|
1039
|
-
}
|
|
1040
|
-
return objectCacheKeys.sort((a, b) => {
|
|
1041
|
-
for (const sortFn of this.sortFns) {
|
|
1042
|
-
const ret = sortFn(batch.read(a)?.value?.$as(this.apiName), batch.read(b)?.value?.$as(this.apiName));
|
|
1043
|
-
if (ret !== 0) {
|
|
1044
|
-
return ret;
|
|
722
|
+
return objectCacheKeys.sort((a, b) => {
|
|
723
|
+
for (const sortFn of this.sortFns) {
|
|
724
|
+
const ret = sortFn(batch.read(a)?.value?.$as(this.apiName), batch.read(b)?.value?.$as(this.apiName));
|
|
725
|
+
if (ret !== 0) {
|
|
726
|
+
return ret;
|
|
1045
727
|
}
|
|
1046
728
|
}
|
|
1047
729
|
return 0;
|
|
@@ -1067,9 +749,40 @@ function createOrderBySortFns(orderBy) {
|
|
|
1067
749
|
};
|
|
1068
750
|
});
|
|
1069
751
|
}
|
|
752
|
+
function createCollectionConnectable(subject, store, createPayload) {
|
|
753
|
+
return rxjs.connectable(subject.pipe(rxjs.switchMap((listEntry) => {
|
|
754
|
+
const resolvedData = listEntry?.value?.data == null || listEntry.value.data.length === 0 ? rxjs.of([]) : rxjs.combineLatest(listEntry.value.data.map((cacheKey) => store.getSubject(cacheKey).pipe(rxjs.map((objectEntry) => objectEntry?.value), rxjs.distinctUntilChanged())));
|
|
755
|
+
return rxjs.scheduled(rxjs.combineLatest({
|
|
756
|
+
resolvedData,
|
|
757
|
+
isOptimistic: rxjs.of(listEntry.isOptimistic),
|
|
758
|
+
status: rxjs.of(listEntry.status),
|
|
759
|
+
lastUpdated: rxjs.of(listEntry.lastUpdated)
|
|
760
|
+
}).pipe(rxjs.map((params) => createPayload({
|
|
761
|
+
resolvedData: Array.isArray(params.resolvedData) ? params.resolvedData : [],
|
|
762
|
+
isOptimistic: params.isOptimistic,
|
|
763
|
+
status: params.status,
|
|
764
|
+
lastUpdated: params.lastUpdated
|
|
765
|
+
}))), rxjs.asapScheduler);
|
|
766
|
+
})), {
|
|
767
|
+
resetOnDisconnect: false,
|
|
768
|
+
connector: () => new rxjs.ReplaySubject(1)
|
|
769
|
+
});
|
|
770
|
+
}
|
|
1070
771
|
|
|
1071
|
-
// src/observable/internal/
|
|
1072
|
-
|
|
772
|
+
// src/observable/internal/base-list/removeDuplicates.ts
|
|
773
|
+
function removeDuplicates(objectCacheKeys, batch) {
|
|
774
|
+
const visited = /* @__PURE__ */ new Set();
|
|
775
|
+
return objectCacheKeys.filter((key) => {
|
|
776
|
+
batch.read(key);
|
|
777
|
+
if (visited.has(key)) {
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
visited.add(key);
|
|
781
|
+
return true;
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/observable/internal/base-list/BaseListQuery.ts
|
|
1073
786
|
var BaseListQuery = class extends Query {
|
|
1074
787
|
/**
|
|
1075
788
|
* The sorting strategy to use for this collection
|
|
@@ -1109,7 +822,7 @@ var BaseListQuery = class extends Query {
|
|
|
1109
822
|
if (items.length === 0) {
|
|
1110
823
|
objectCacheKeys = [];
|
|
1111
824
|
} else if (isObjectInstance(items[0])) {
|
|
1112
|
-
objectCacheKeys = this.
|
|
825
|
+
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
|
|
1113
826
|
} else {
|
|
1114
827
|
objectCacheKeys = items;
|
|
1115
828
|
}
|
|
@@ -1128,7 +841,7 @@ var BaseListQuery = class extends Query {
|
|
|
1128
841
|
*/
|
|
1129
842
|
writeToStore(data, status, batch) {
|
|
1130
843
|
const entry = batch.read(this.cacheKey);
|
|
1131
|
-
if (entry &&
|
|
844
|
+
if (entry && deepEqual4__default.default(data, entry.value)) {
|
|
1132
845
|
if (entry.status === status) {
|
|
1133
846
|
if (process.env.NODE_ENV !== "production") {
|
|
1134
847
|
this.logger?.child({
|
|
@@ -1157,17 +870,6 @@ var BaseListQuery = class extends Query {
|
|
|
1157
870
|
* Register changes to the cache based on the specific collection type
|
|
1158
871
|
* Implemented by subclasses to handle specific change registration
|
|
1159
872
|
*/
|
|
1160
|
-
/**
|
|
1161
|
-
* Common method to store objects in the cache and return their cache keys
|
|
1162
|
-
* Used by collection queries when storing object references
|
|
1163
|
-
*
|
|
1164
|
-
* @param objects Array of objects to store
|
|
1165
|
-
* @param batch The batch context to use
|
|
1166
|
-
* @returns Array of cache keys for the stored objects
|
|
1167
|
-
*/
|
|
1168
|
-
storeObjects(objects, batch) {
|
|
1169
|
-
return objects.length > 0 ? storeOsdkInstances(this.store, objects, batch) : [];
|
|
1170
|
-
}
|
|
1171
873
|
/**
|
|
1172
874
|
* Common method for managing object reference counting and appending results
|
|
1173
875
|
* Used by collection queries when updating object references
|
|
@@ -1325,7 +1027,7 @@ var BaseListQuery = class extends Query {
|
|
|
1325
1027
|
} = this.store.batch({}, (batch) => {
|
|
1326
1028
|
const append = this.nextPageToken != null;
|
|
1327
1029
|
const finalStatus = result.nextPageToken ? status : "loaded";
|
|
1328
|
-
return this._updateList(this.
|
|
1030
|
+
return this._updateList(this.store.objects.storeOsdkInstances(result.data, batch), finalStatus, batch, append);
|
|
1329
1031
|
});
|
|
1330
1032
|
return retVal;
|
|
1331
1033
|
} catch (error) {
|
|
@@ -1394,7 +1096,7 @@ var BaseListQuery = class extends Query {
|
|
|
1394
1096
|
if (items.length === 0) {
|
|
1395
1097
|
objectCacheKeys = [];
|
|
1396
1098
|
} else if (isObjectInstance(items[0])) {
|
|
1397
|
-
objectCacheKeys = this.
|
|
1099
|
+
objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
|
|
1398
1100
|
} else {
|
|
1399
1101
|
objectCacheKeys = items;
|
|
1400
1102
|
}
|
|
@@ -1406,108 +1108,325 @@ var BaseListQuery = class extends Query {
|
|
|
1406
1108
|
}, options.status, batch);
|
|
1407
1109
|
}
|
|
1408
1110
|
};
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1111
|
+
|
|
1112
|
+
// src/observable/internal/tombstone.ts
|
|
1113
|
+
var tombstone = void 0;
|
|
1114
|
+
|
|
1115
|
+
// src/observable/internal/links/SpecificLinkQuery.ts
|
|
1116
|
+
var SpecificLinkQuery = class extends BaseListQuery {
|
|
1117
|
+
#sourceApiName;
|
|
1118
|
+
#sourcePk;
|
|
1119
|
+
#linkName;
|
|
1413
1120
|
#whereClause;
|
|
1414
|
-
// Using base class minResultsToLoad instead of a private property
|
|
1415
1121
|
#orderBy;
|
|
1416
|
-
#objectSet;
|
|
1417
1122
|
/**
|
|
1418
|
-
* Register changes to the cache specific to
|
|
1123
|
+
* Register changes to the cache specific to SpecificLinkQuery
|
|
1419
1124
|
*/
|
|
1420
1125
|
registerCacheChanges(batch) {
|
|
1421
|
-
batch.changes.
|
|
1126
|
+
batch.changes.modified.add(this.cacheKey);
|
|
1422
1127
|
}
|
|
1423
|
-
constructor(store, subject,
|
|
1424
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
1425
|
-
msgPrefix: `
|
|
1128
|
+
constructor(store, subject, cacheKey, opts) {
|
|
1129
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkELAA4C2C_cjs.additionalContext].logger?.child({}, {
|
|
1130
|
+
msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1426
1131
|
}) : void 0);
|
|
1427
|
-
this.#
|
|
1428
|
-
this
|
|
1429
|
-
this.#whereClause = whereClause;
|
|
1430
|
-
this.#orderBy = orderBy;
|
|
1431
|
-
this.#objectSet = store.client({
|
|
1432
|
-
type: this.#type,
|
|
1433
|
-
apiName: this.#apiName
|
|
1434
|
-
}).where(this.#whereClause);
|
|
1435
|
-
this.sortingStrategy = new OrderBySortingStrategy(this.#apiName, this.#orderBy);
|
|
1436
|
-
this.minResultsToLoad = 0;
|
|
1437
|
-
}
|
|
1438
|
-
get canonicalWhere() {
|
|
1439
|
-
return this.#whereClause;
|
|
1132
|
+
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
1133
|
+
this.sortingStrategy = new OrderBySortingStrategy(this.#linkName, this.#orderBy);
|
|
1440
1134
|
}
|
|
1135
|
+
// _fetchAndStore is now implemented in BaseCollectionQuery
|
|
1441
1136
|
/**
|
|
1442
|
-
* Implements fetchPageData from BaseCollectionQuery template method
|
|
1443
|
-
* Fetches a page of
|
|
1137
|
+
* Implements fetchPageData from the BaseCollectionQuery template method pattern
|
|
1138
|
+
* Fetches a page of linked objects
|
|
1444
1139
|
*/
|
|
1445
1140
|
async fetchPageData(signal) {
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1141
|
+
const client = this.store.client;
|
|
1142
|
+
const sourceObjectDef = {
|
|
1143
|
+
type: "object",
|
|
1144
|
+
apiName: this.#sourceApiName
|
|
1145
|
+
};
|
|
1146
|
+
const sourceMetadata = await client[chunkELAA4C2C_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1147
|
+
const sourceQuery = client(sourceObjectDef).where({
|
|
1148
|
+
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
1454
1149
|
});
|
|
1150
|
+
const linkQuery = sourceQuery.pivotTo(this.#linkName);
|
|
1455
1151
|
if (signal?.aborted) {
|
|
1456
1152
|
throw new Error("Aborted");
|
|
1457
1153
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
fetchedData = await reloadDataAsFullObjects(this.store.client, fetchedData);
|
|
1462
|
-
}
|
|
1463
|
-
return {
|
|
1464
|
-
...resp,
|
|
1465
|
-
data: fetchedData
|
|
1154
|
+
const queryParams = {
|
|
1155
|
+
$pageSize: this.options.pageSize || 100,
|
|
1156
|
+
$nextPageToken: this.nextPageToken
|
|
1466
1157
|
};
|
|
1158
|
+
if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {
|
|
1159
|
+
queryParams.$orderBy = this.#orderBy;
|
|
1160
|
+
}
|
|
1161
|
+
if (this.#whereClause && Object.keys(this.#whereClause).length > 0) {
|
|
1162
|
+
queryParams.$where = this.#whereClause;
|
|
1163
|
+
}
|
|
1164
|
+
const response = await linkQuery.fetchPage(queryParams);
|
|
1165
|
+
this.nextPageToken = response.nextPageToken;
|
|
1166
|
+
return response;
|
|
1467
1167
|
}
|
|
1468
1168
|
/**
|
|
1469
|
-
*
|
|
1470
|
-
*/
|
|
1471
|
-
handleFetchError(error, _status, batch) {
|
|
1472
|
-
this.logger?.error("error", error);
|
|
1473
|
-
this.store.getSubject(this.cacheKey).error(error);
|
|
1474
|
-
return this.writeToStore({
|
|
1475
|
-
data: []
|
|
1476
|
-
}, "error", batch);
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Will revalidate the list if its query is affected by invalidating the
|
|
1480
|
-
* apiName of the object type passed in.
|
|
1481
|
-
*
|
|
1482
|
-
* @param apiName to invalidate
|
|
1483
|
-
* @returns
|
|
1169
|
+
* Removes a link query from the store
|
|
1484
1170
|
*/
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
);
|
|
1492
|
-
return;
|
|
1493
|
-
} else {
|
|
1494
|
-
return;
|
|
1171
|
+
deleteFromStore(status, batch) {
|
|
1172
|
+
const entry = batch.read(this.cacheKey);
|
|
1173
|
+
if (entry && deepEqual4__default.default(tombstone, entry.value)) {
|
|
1174
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1175
|
+
this.logger?.child({
|
|
1176
|
+
methodName: "deleteFromStore"
|
|
1177
|
+
}).debug(`Links were already deleted, just setting status`);
|
|
1495
1178
|
}
|
|
1179
|
+
return batch.write(this.cacheKey, entry.value, status);
|
|
1496
1180
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
);
|
|
1181
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1182
|
+
this.logger?.child({
|
|
1183
|
+
methodName: "deleteFromStore"
|
|
1184
|
+
}).debug(JSON.stringify({
|
|
1185
|
+
status
|
|
1186
|
+
}));
|
|
1187
|
+
}
|
|
1188
|
+
if (!entry || !entry.value) {
|
|
1506
1189
|
return;
|
|
1507
1190
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1191
|
+
const ret = batch.delete(this.cacheKey, status);
|
|
1192
|
+
batch.changes.deleted.add(this.cacheKey);
|
|
1193
|
+
return ret;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Implements Query.maybeUpdateAndRevalidate to handle cache invalidation
|
|
1197
|
+
*/
|
|
1198
|
+
maybeUpdateAndRevalidate = async (changes, _optimisticId) => {
|
|
1199
|
+
if (changes.modified.has(this.cacheKey)) {
|
|
1200
|
+
return this.revalidate(true);
|
|
1201
|
+
}
|
|
1202
|
+
return Promise.resolve();
|
|
1203
|
+
};
|
|
1204
|
+
invalidateObjectType = (objectType, changes) => {
|
|
1205
|
+
if (this.#sourceApiName === objectType) {
|
|
1206
|
+
changes?.modified.add(this.cacheKey);
|
|
1207
|
+
return this.revalidate(true);
|
|
1208
|
+
} else {
|
|
1209
|
+
return (async () => {
|
|
1210
|
+
const sourceMetadata = await this.store.client[chunkELAA4C2C_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1211
|
+
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
1212
|
+
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
1213
|
+
const promise = this.revalidate(true);
|
|
1214
|
+
changes?.modified.add(this.cacheKey);
|
|
1215
|
+
return promise;
|
|
1216
|
+
})();
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
// src/observable/internal/links/LinksHelper.ts
|
|
1222
|
+
var LinksHelper = class extends AbstractHelper {
|
|
1223
|
+
constructor(store, whereCanonicalizer, orderByCanonicalizer) {
|
|
1224
|
+
super(store);
|
|
1225
|
+
this.whereCanonicalizer = whereCanonicalizer;
|
|
1226
|
+
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
1227
|
+
}
|
|
1228
|
+
getQuery(options) {
|
|
1229
|
+
const {
|
|
1230
|
+
apiName
|
|
1231
|
+
} = options.srcType;
|
|
1232
|
+
const canonWhere = this.whereCanonicalizer.canonicalize(options.where ?? {});
|
|
1233
|
+
const canonOrderBy = this.orderByCanonicalizer.canonicalize(options.orderBy ?? {});
|
|
1234
|
+
const linkCacheKey = this.store.getCacheKey("specificLink", apiName, options.pk, options.linkName, canonWhere, canonOrderBy);
|
|
1235
|
+
return this.store.getQuery(linkCacheKey, () => {
|
|
1236
|
+
return new SpecificLinkQuery(this.store, this.store.getSubject(linkCacheKey), linkCacheKey, options);
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
function is$and(whereClause) {
|
|
1241
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1242
|
+
if ("$and" in whereClause) {
|
|
1243
|
+
!Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : void 0;
|
|
1244
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : void 0;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return "$and" in whereClause;
|
|
1248
|
+
}
|
|
1249
|
+
function is$or(whereClause) {
|
|
1250
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1251
|
+
if ("$or" in whereClause) {
|
|
1252
|
+
!Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $or to be an array") : invariant2__default.default(false) : void 0;
|
|
1253
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $or to be present") : invariant2__default.default(false) : void 0;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return "$or" in whereClause;
|
|
1257
|
+
}
|
|
1258
|
+
function is$not(whereClause) {
|
|
1259
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1260
|
+
if ("$not" in whereClause) {
|
|
1261
|
+
!(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $not to be present") : invariant2__default.default(false) : void 0;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return "$not" in whereClause;
|
|
1265
|
+
}
|
|
1266
|
+
function objectSortaMatchesWhereClause(o, whereClause, strict) {
|
|
1267
|
+
if (deepEqual4__default.default({}, whereClause)) {
|
|
1268
|
+
return true;
|
|
1269
|
+
}
|
|
1270
|
+
if (is$and(whereClause)) {
|
|
1271
|
+
return whereClause.$and.every((w) => objectSortaMatchesWhereClause(o, w, strict));
|
|
1272
|
+
}
|
|
1273
|
+
if (is$or(whereClause)) {
|
|
1274
|
+
return whereClause.$or.some((w) => objectSortaMatchesWhereClause(o, w, strict));
|
|
1275
|
+
}
|
|
1276
|
+
if (is$not(whereClause)) {
|
|
1277
|
+
return !objectSortaMatchesWhereClause(o, whereClause.$not, strict);
|
|
1278
|
+
}
|
|
1279
|
+
return Object.entries(whereClause).every(([key, filter]) => {
|
|
1280
|
+
if (typeof filter === "object") {
|
|
1281
|
+
const realValue = o[key];
|
|
1282
|
+
const [f] = Object.keys(filter);
|
|
1283
|
+
const expected = filter[f];
|
|
1284
|
+
switch (f) {
|
|
1285
|
+
case "$eq":
|
|
1286
|
+
return realValue === expected;
|
|
1287
|
+
case "$gt":
|
|
1288
|
+
return realValue > expected;
|
|
1289
|
+
case "$lt":
|
|
1290
|
+
return realValue < expected;
|
|
1291
|
+
case "$gte":
|
|
1292
|
+
return realValue >= expected;
|
|
1293
|
+
case "$lte":
|
|
1294
|
+
return realValue <= expected;
|
|
1295
|
+
case "$ne":
|
|
1296
|
+
return realValue !== expected;
|
|
1297
|
+
case "$in":
|
|
1298
|
+
return expected.$in.includes(realValue);
|
|
1299
|
+
case "$isNull":
|
|
1300
|
+
return realValue == null;
|
|
1301
|
+
case "$startsWith":
|
|
1302
|
+
return realValue.startsWith(expected);
|
|
1303
|
+
case "$contains":
|
|
1304
|
+
case "$containsAllTerms":
|
|
1305
|
+
case "$containsAllTermsInOrder":
|
|
1306
|
+
case "$containsAnyTerm":
|
|
1307
|
+
case "$intersects":
|
|
1308
|
+
case "$within":
|
|
1309
|
+
return !strict;
|
|
1310
|
+
default:
|
|
1311
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1312
|
+
process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Unknown where filter ${f}`) : invariant2__default.default(false) ;
|
|
1313
|
+
}
|
|
1314
|
+
return !strict;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
if (key in o) {
|
|
1318
|
+
if (o[key] === filter) {
|
|
1319
|
+
return true;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return false;
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// src/observable/internal/list/ListQuery.ts
|
|
1327
|
+
var API_NAME_IDX = 1;
|
|
1328
|
+
var ListQuery = class extends BaseListQuery {
|
|
1329
|
+
// pageSize?: number; // this is the internal page size. we need to track this properly
|
|
1330
|
+
#type;
|
|
1331
|
+
#apiName;
|
|
1332
|
+
#whereClause;
|
|
1333
|
+
// Using base class minResultsToLoad instead of a private property
|
|
1334
|
+
#orderBy;
|
|
1335
|
+
#objectSet;
|
|
1336
|
+
/**
|
|
1337
|
+
* Register changes to the cache specific to ListQuery
|
|
1338
|
+
*/
|
|
1339
|
+
registerCacheChanges(batch) {
|
|
1340
|
+
batch.changes.registerList(this.cacheKey);
|
|
1341
|
+
}
|
|
1342
|
+
constructor(store, subject, apiType, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
1343
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkELAA4C2C_cjs.additionalContext].logger?.child({}, {
|
|
1344
|
+
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1345
|
+
}) : void 0);
|
|
1346
|
+
this.#type = apiType;
|
|
1347
|
+
this.#apiName = apiName;
|
|
1348
|
+
this.#whereClause = whereClause;
|
|
1349
|
+
this.#orderBy = orderBy;
|
|
1350
|
+
this.#objectSet = store.client({
|
|
1351
|
+
type: this.#type,
|
|
1352
|
+
apiName: this.#apiName
|
|
1353
|
+
}).where(this.#whereClause);
|
|
1354
|
+
this.sortingStrategy = new OrderBySortingStrategy(this.#apiName, this.#orderBy);
|
|
1355
|
+
this.minResultsToLoad = 0;
|
|
1356
|
+
}
|
|
1357
|
+
get canonicalWhere() {
|
|
1358
|
+
return this.#whereClause;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Implements fetchPageData from BaseCollectionQuery template method
|
|
1362
|
+
* Fetches a page of data
|
|
1363
|
+
*/
|
|
1364
|
+
async fetchPageData(signal) {
|
|
1365
|
+
const resp = await this.#objectSet.fetchPage({
|
|
1366
|
+
$nextPageToken: this.nextPageToken,
|
|
1367
|
+
$pageSize: this.options.pageSize,
|
|
1368
|
+
// For now this keeps the shared test code from falling apart
|
|
1369
|
+
// but shouldn't be needed ideally
|
|
1370
|
+
...Object.keys(this.#orderBy).length > 0 ? {
|
|
1371
|
+
$orderBy: this.#orderBy
|
|
1372
|
+
} : {}
|
|
1373
|
+
});
|
|
1374
|
+
if (signal?.aborted) {
|
|
1375
|
+
throw new Error("Aborted");
|
|
1376
|
+
}
|
|
1377
|
+
this.nextPageToken = resp.nextPageToken;
|
|
1378
|
+
let fetchedData = resp.data;
|
|
1379
|
+
if (this.#type === "interface") {
|
|
1380
|
+
fetchedData = await reloadDataAsFullObjects(this.store.client, fetchedData);
|
|
1381
|
+
}
|
|
1382
|
+
return {
|
|
1383
|
+
...resp,
|
|
1384
|
+
data: fetchedData
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Handle fetch errors by setting appropriate error state and notifying subscribers
|
|
1389
|
+
*/
|
|
1390
|
+
handleFetchError(error, _status, batch) {
|
|
1391
|
+
this.logger?.error("error", error);
|
|
1392
|
+
this.store.getSubject(this.cacheKey).error(error);
|
|
1393
|
+
return this.writeToStore({
|
|
1394
|
+
data: []
|
|
1395
|
+
}, "error", batch);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Will revalidate the list if its query is affected by invalidating the
|
|
1399
|
+
* apiName of the object type passed in.
|
|
1400
|
+
*
|
|
1401
|
+
* @param apiName to invalidate
|
|
1402
|
+
* @returns
|
|
1403
|
+
*/
|
|
1404
|
+
revalidateObjectType = async (apiName) => {
|
|
1405
|
+
if (this.#type === "object") {
|
|
1406
|
+
if (this.#apiName === apiName) {
|
|
1407
|
+
await this.revalidate(
|
|
1408
|
+
/* force */
|
|
1409
|
+
true
|
|
1410
|
+
);
|
|
1411
|
+
return;
|
|
1412
|
+
} else {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
const objectMetadata = await this.store.client.fetchMetadata({
|
|
1417
|
+
type: "object",
|
|
1418
|
+
apiName
|
|
1419
|
+
});
|
|
1420
|
+
if (this.#apiName in objectMetadata.interfaceMap) {
|
|
1421
|
+
await this.revalidate(
|
|
1422
|
+
/* force */
|
|
1423
|
+
true
|
|
1424
|
+
);
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
invalidateObjectType = async (objectType, changes) => {
|
|
1429
|
+
if (this.cacheKey.otherKeys[1] === objectType) {
|
|
1511
1430
|
changes?.modified.add(this.cacheKey);
|
|
1512
1431
|
return this.revalidate(true);
|
|
1513
1432
|
}
|
|
@@ -1614,7 +1533,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1614
1533
|
}
|
|
1615
1534
|
#extractRelevantObjectsForTypeInterface(changes) {
|
|
1616
1535
|
const matchesApiName = ([, object]) => {
|
|
1617
|
-
return this.#apiName in object[
|
|
1536
|
+
return this.#apiName in object[chunkKCMGIMVC_cjs.ObjectDefRef].interfaceMap;
|
|
1618
1537
|
};
|
|
1619
1538
|
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
1620
1539
|
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
@@ -1705,7 +1624,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1705
1624
|
if (state === "ADDED_OR_UPDATED") {
|
|
1706
1625
|
const object = objOrIface.$apiName !== objOrIface.$objectType ? objOrIface.$as(objOrIface.$objectType) : objOrIface;
|
|
1707
1626
|
this.store.batch({}, (batch) => {
|
|
1708
|
-
this.
|
|
1627
|
+
this.store.objects.storeOsdkInstances([object], batch);
|
|
1709
1628
|
});
|
|
1710
1629
|
} else if (state === "REMOVED") {
|
|
1711
1630
|
this.#onOswRemoved(objOrIface, logger);
|
|
@@ -1745,7 +1664,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1745
1664
|
async function reloadDataAsFullObjects(client, data) {
|
|
1746
1665
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
1747
1666
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
1748
|
-
const objectDef = objects[0][
|
|
1667
|
+
const objectDef = objects[0][chunkKCMGIMVC_cjs.UnderlyingOsdkObject][chunkKCMGIMVC_cjs.ObjectDefRef];
|
|
1749
1668
|
const where = {
|
|
1750
1669
|
[objectDef.primaryKeyApiName]: {
|
|
1751
1670
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -1761,69 +1680,202 @@ async function reloadDataAsFullObjects(client, data) {
|
|
|
1761
1680
|
return data;
|
|
1762
1681
|
}
|
|
1763
1682
|
|
|
1764
|
-
// src/observable/internal/
|
|
1765
|
-
var
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
#orderBy;
|
|
1771
|
-
/**
|
|
1772
|
-
* Register changes to the cache specific to SpecificLinkQuery
|
|
1773
|
-
*/
|
|
1774
|
-
registerCacheChanges(batch) {
|
|
1775
|
-
batch.changes.modified.add(this.cacheKey);
|
|
1683
|
+
// src/observable/internal/list/ListsHelper.ts
|
|
1684
|
+
var ListsHelper = class extends AbstractHelper {
|
|
1685
|
+
constructor(store, whereCanonicalizer, orderByCanonicalizer) {
|
|
1686
|
+
super(store);
|
|
1687
|
+
this.whereCanonicalizer = whereCanonicalizer;
|
|
1688
|
+
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
1776
1689
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1690
|
+
observe(options, subFn) {
|
|
1691
|
+
const ret = super.observe(options, subFn);
|
|
1692
|
+
if (options.streamUpdates) {
|
|
1693
|
+
ret.query.registerStreamUpdates(ret.subscription);
|
|
1694
|
+
}
|
|
1695
|
+
return ret;
|
|
1783
1696
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1697
|
+
getQuery(options) {
|
|
1698
|
+
const {
|
|
1699
|
+
type: {
|
|
1700
|
+
apiName,
|
|
1701
|
+
type
|
|
1702
|
+
},
|
|
1703
|
+
where,
|
|
1704
|
+
orderBy
|
|
1705
|
+
} = options;
|
|
1706
|
+
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
1707
|
+
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
1708
|
+
const listCacheKey = this.store.getCacheKey("list", type, apiName, canonWhere, canonOrderBy);
|
|
1709
|
+
return this.store.getQuery(listCacheKey, () => {
|
|
1710
|
+
return new ListQuery(this.store, this.store.getSubject(listCacheKey), type, apiName, canonWhere, canonOrderBy, listCacheKey, options);
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
// ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
|
|
1716
|
+
function pDefer() {
|
|
1717
|
+
const deferred = {};
|
|
1718
|
+
deferred.promise = new Promise((resolve, reject) => {
|
|
1719
|
+
deferred.resolve = resolve;
|
|
1720
|
+
deferred.reject = reject;
|
|
1721
|
+
});
|
|
1722
|
+
return deferred;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// src/observable/internal/BulkObjectLoader.ts
|
|
1726
|
+
var weakCache = new mnemonist.DefaultWeakMap((c) => new BulkObjectLoader(c));
|
|
1727
|
+
function getBulkObjectLoader(client) {
|
|
1728
|
+
return weakCache.get(client);
|
|
1729
|
+
}
|
|
1730
|
+
var BulkObjectLoader = class {
|
|
1731
|
+
#client;
|
|
1732
|
+
#m = new mnemonist.DefaultMap(() => ({
|
|
1733
|
+
data: [],
|
|
1734
|
+
timer: void 0
|
|
1735
|
+
}));
|
|
1736
|
+
#logger;
|
|
1737
|
+
#maxWait;
|
|
1738
|
+
#maxEntries;
|
|
1739
|
+
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
1740
|
+
this.#client = client;
|
|
1741
|
+
this.#logger = client[chunkELAA4C2C_cjs.additionalContext].logger;
|
|
1742
|
+
this.#maxWait = maxWait;
|
|
1743
|
+
this.#maxEntries = maxEntries;
|
|
1744
|
+
}
|
|
1745
|
+
async fetch(apiName, primaryKey) {
|
|
1746
|
+
const deferred = pDefer();
|
|
1747
|
+
const entry = this.#m.get(apiName);
|
|
1748
|
+
entry.data.push({
|
|
1749
|
+
primaryKey,
|
|
1750
|
+
deferred
|
|
1751
|
+
});
|
|
1752
|
+
if (!entry.timer) {
|
|
1753
|
+
entry.timer = setTimeout(() => {
|
|
1754
|
+
this.#loadObjects(apiName, entry.data);
|
|
1755
|
+
}, this.#maxWait);
|
|
1756
|
+
}
|
|
1757
|
+
if (entry.data.length >= this.#maxEntries) {
|
|
1758
|
+
clearTimeout(entry.timer);
|
|
1759
|
+
this.#loadObjects(apiName, entry.data);
|
|
1760
|
+
}
|
|
1761
|
+
return await deferred.promise;
|
|
1762
|
+
}
|
|
1763
|
+
#loadObjects(apiName, arr) {
|
|
1764
|
+
this.#m.delete(apiName);
|
|
1765
|
+
this.#reallyLoadObjects(apiName, arr).catch((e) => {
|
|
1766
|
+
this.#logger?.error("Unhandled exception", e);
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
async #reallyLoadObjects(apiName, arr) {
|
|
1770
|
+
const miniDef = {
|
|
1792
1771
|
type: "object",
|
|
1793
|
-
apiName
|
|
1772
|
+
apiName
|
|
1794
1773
|
};
|
|
1795
|
-
const
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1774
|
+
const objMetadata = await this.#client.fetchMetadata(miniDef);
|
|
1775
|
+
const pks = arr.map((x) => x.primaryKey);
|
|
1776
|
+
const {
|
|
1777
|
+
data
|
|
1778
|
+
} = await this.#client(miniDef).where({
|
|
1779
|
+
[objMetadata.primaryKeyApiName]: {
|
|
1780
|
+
$in: pks
|
|
1781
|
+
}
|
|
1782
|
+
}).fetchPage({
|
|
1783
|
+
$pageSize: pks.length
|
|
1798
1784
|
});
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
|
|
1785
|
+
for (const {
|
|
1786
|
+
primaryKey,
|
|
1787
|
+
deferred
|
|
1788
|
+
} of arr) {
|
|
1789
|
+
const object = data.find((x) => x.$primaryKey === primaryKey);
|
|
1790
|
+
if (object) {
|
|
1791
|
+
deferred.resolve(object);
|
|
1792
|
+
} else {
|
|
1793
|
+
deferred.reject(new shared_net_errors.PalantirApiError(`Object not found: ${primaryKey}`));
|
|
1794
|
+
}
|
|
1802
1795
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
// src/observable/internal/object/ObjectQuery.ts
|
|
1800
|
+
var ObjectQuery = class extends Query {
|
|
1801
|
+
#apiName;
|
|
1802
|
+
#pk;
|
|
1803
|
+
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
1804
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkELAA4C2C_cjs.additionalContext].logger?.child({}, {
|
|
1805
|
+
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
1806
|
+
}) : void 0);
|
|
1807
|
+
this.#apiName = type;
|
|
1808
|
+
this.#pk = pk;
|
|
1809
|
+
}
|
|
1810
|
+
_createConnectable(subject) {
|
|
1811
|
+
return rxjs.connectable(subject.pipe(rxjs.map((x) => {
|
|
1812
|
+
return {
|
|
1813
|
+
status: x.status,
|
|
1814
|
+
object: x.value,
|
|
1815
|
+
lastUpdated: x.lastUpdated,
|
|
1816
|
+
isOptimistic: x.isOptimistic
|
|
1817
|
+
};
|
|
1818
|
+
})), {
|
|
1819
|
+
connector: () => new rxjs.BehaviorSubject({
|
|
1820
|
+
status: "init",
|
|
1821
|
+
object: void 0,
|
|
1822
|
+
lastUpdated: 0,
|
|
1823
|
+
isOptimistic: false
|
|
1824
|
+
})
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
async _fetchAndStore() {
|
|
1828
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1829
|
+
this.logger?.child({
|
|
1830
|
+
methodName: "_fetchAndStore"
|
|
1831
|
+
}).debug("calling _fetchAndStore");
|
|
1809
1832
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1833
|
+
const obj = await getBulkObjectLoader(this.store.client).fetch(this.#apiName, this.#pk);
|
|
1834
|
+
this.store.batch({}, (batch) => {
|
|
1835
|
+
this.writeToStore(obj, "loaded", batch);
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
writeToStore(data, status, batch) {
|
|
1839
|
+
const entry = batch.read(this.cacheKey);
|
|
1840
|
+
if (entry && deepEqual4__default.default(data, entry.value)) {
|
|
1841
|
+
if (entry.status === status) {
|
|
1842
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1843
|
+
this.logger?.child({
|
|
1844
|
+
methodName: "writeToStore"
|
|
1845
|
+
}).debug(`Object was deep equal and status unchanged (${status}), skipping update`);
|
|
1846
|
+
}
|
|
1847
|
+
return entry;
|
|
1848
|
+
}
|
|
1849
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1850
|
+
this.logger?.child({
|
|
1851
|
+
methodName: "writeToStore"
|
|
1852
|
+
}).debug(`Object was deep equal, just setting status (old status: ${entry.status}, new status: ${status})`);
|
|
1853
|
+
}
|
|
1854
|
+
return batch.write(this.cacheKey, entry.value, status);
|
|
1812
1855
|
}
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1856
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1857
|
+
this.logger?.child({
|
|
1858
|
+
methodName: "writeToStore"
|
|
1859
|
+
}).debug(JSON.stringify({
|
|
1860
|
+
status
|
|
1861
|
+
}), data);
|
|
1862
|
+
}
|
|
1863
|
+
const ret = batch.write(this.cacheKey, data, status);
|
|
1864
|
+
batch.changes.registerObject(
|
|
1865
|
+
this.cacheKey,
|
|
1866
|
+
data,
|
|
1867
|
+
/* isNew */
|
|
1868
|
+
!entry
|
|
1869
|
+
);
|
|
1870
|
+
return ret;
|
|
1816
1871
|
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Removes a link query from the store
|
|
1819
|
-
*/
|
|
1820
1872
|
deleteFromStore(status, batch) {
|
|
1821
1873
|
const entry = batch.read(this.cacheKey);
|
|
1822
|
-
if (entry &&
|
|
1874
|
+
if (entry && deepEqual4__default.default(tombstone, entry.value)) {
|
|
1823
1875
|
if (process.env.NODE_ENV !== "production") {
|
|
1824
1876
|
this.logger?.child({
|
|
1825
1877
|
methodName: "deleteFromStore"
|
|
1826
|
-
}).debug(`
|
|
1878
|
+
}).debug(`Object was deep equal, just setting status`);
|
|
1827
1879
|
}
|
|
1828
1880
|
return batch.write(this.cacheKey, entry.value, status);
|
|
1829
1881
|
}
|
|
@@ -1838,87 +1890,18 @@ var SpecificLinkQuery = class extends BaseListQuery {
|
|
|
1838
1890
|
return;
|
|
1839
1891
|
}
|
|
1840
1892
|
const ret = batch.delete(this.cacheKey, status);
|
|
1841
|
-
batch.changes.
|
|
1893
|
+
batch.changes.deleteObject(this.cacheKey);
|
|
1842
1894
|
return ret;
|
|
1843
1895
|
}
|
|
1844
|
-
/**
|
|
1845
|
-
* Implements Query.maybeUpdateAndRevalidate to handle cache invalidation
|
|
1846
|
-
*/
|
|
1847
|
-
maybeUpdateAndRevalidate = async (changes, _optimisticId) => {
|
|
1848
|
-
if (changes.modified.has(this.cacheKey)) {
|
|
1849
|
-
return this.revalidate(true);
|
|
1850
|
-
}
|
|
1851
|
-
return Promise.resolve();
|
|
1852
|
-
};
|
|
1853
1896
|
invalidateObjectType = (objectType, changes) => {
|
|
1854
|
-
if (this.#
|
|
1897
|
+
if (this.#apiName === objectType) {
|
|
1855
1898
|
changes?.modified.add(this.cacheKey);
|
|
1856
1899
|
return this.revalidate(true);
|
|
1857
|
-
} else {
|
|
1858
|
-
return (async () => {
|
|
1859
|
-
const sourceMetadata = await this.store.client[chunkBL56QBYG_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
1860
|
-
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
1861
|
-
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
1862
|
-
const promise = this.revalidate(true);
|
|
1863
|
-
changes?.modified.add(this.cacheKey);
|
|
1864
|
-
return promise;
|
|
1865
|
-
})();
|
|
1866
1900
|
}
|
|
1901
|
+
return Promise.resolve();
|
|
1867
1902
|
};
|
|
1868
1903
|
};
|
|
1869
1904
|
|
|
1870
|
-
// src/observable/internal/links/LinksHelper.ts
|
|
1871
|
-
var LinksHelper = class extends AbstractHelper {
|
|
1872
|
-
constructor(store, whereCanonicalizer, orderByCanonicalizer) {
|
|
1873
|
-
super(store);
|
|
1874
|
-
this.whereCanonicalizer = whereCanonicalizer;
|
|
1875
|
-
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
1876
|
-
}
|
|
1877
|
-
getQuery(options) {
|
|
1878
|
-
const {
|
|
1879
|
-
apiName
|
|
1880
|
-
} = options.srcType;
|
|
1881
|
-
const canonWhere = this.whereCanonicalizer.canonicalize(options.where ?? {});
|
|
1882
|
-
const canonOrderBy = this.orderByCanonicalizer.canonicalize(options.orderBy ?? {});
|
|
1883
|
-
const linkCacheKey = this.store.getCacheKey("specificLink", apiName, options.pk, options.linkName, canonWhere, canonOrderBy);
|
|
1884
|
-
return this.store.getQuery(linkCacheKey, () => {
|
|
1885
|
-
return new SpecificLinkQuery(this.store, this.store.getSubject(linkCacheKey), linkCacheKey, options);
|
|
1886
|
-
});
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
|
|
1890
|
-
// src/observable/internal/list/ListsHelper.ts
|
|
1891
|
-
var ListsHelper = class extends AbstractHelper {
|
|
1892
|
-
constructor(store, whereCanonicalizer, orderByCanonicalizer) {
|
|
1893
|
-
super(store);
|
|
1894
|
-
this.whereCanonicalizer = whereCanonicalizer;
|
|
1895
|
-
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
1896
|
-
}
|
|
1897
|
-
observe(options, subFn) {
|
|
1898
|
-
const ret = super.observe(options, subFn);
|
|
1899
|
-
if (options.streamUpdates) {
|
|
1900
|
-
ret.query.registerStreamUpdates(ret.subscription);
|
|
1901
|
-
}
|
|
1902
|
-
return ret;
|
|
1903
|
-
}
|
|
1904
|
-
getQuery(options) {
|
|
1905
|
-
const {
|
|
1906
|
-
type: {
|
|
1907
|
-
apiName,
|
|
1908
|
-
type
|
|
1909
|
-
},
|
|
1910
|
-
where,
|
|
1911
|
-
orderBy
|
|
1912
|
-
} = options;
|
|
1913
|
-
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
1914
|
-
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
1915
|
-
const listCacheKey = this.store.getCacheKey("list", type, apiName, canonWhere, canonOrderBy);
|
|
1916
|
-
return this.store.getQuery(listCacheKey, () => {
|
|
1917
|
-
return new ListQuery(this.store, this.store.getSubject(listCacheKey), type, apiName, canonWhere, canonOrderBy, listCacheKey, options);
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
};
|
|
1921
|
-
|
|
1922
1905
|
// src/observable/internal/object/ObjectsHelper.ts
|
|
1923
1906
|
var ObjectsHelper = class extends AbstractHelper {
|
|
1924
1907
|
observe(options, subFn) {
|
|
@@ -1934,6 +1917,17 @@ var ObjectsHelper = class extends AbstractHelper {
|
|
|
1934
1917
|
dedupeInterval: 0
|
|
1935
1918
|
}));
|
|
1936
1919
|
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Internal helper method for writing objects to the store and returning their
|
|
1922
|
+
* object keys
|
|
1923
|
+
* @internal
|
|
1924
|
+
*/
|
|
1925
|
+
storeOsdkInstances(values, batch) {
|
|
1926
|
+
return values.map((v) => this.getQuery({
|
|
1927
|
+
apiName: v.$apiName,
|
|
1928
|
+
pk: v.$primaryKey
|
|
1929
|
+
}).writeToStore(v, "loaded", batch).cacheKey);
|
|
1930
|
+
}
|
|
1937
1931
|
};
|
|
1938
1932
|
var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
|
|
1939
1933
|
var WeakRefTrie = class {
|
|
@@ -1969,6 +1963,8 @@ var WeakRefTrie = class {
|
|
|
1969
1963
|
return this.#trie.removeArray(array)?.deref();
|
|
1970
1964
|
}
|
|
1971
1965
|
};
|
|
1966
|
+
|
|
1967
|
+
// src/observable/internal/OrderByCanonicalizer.ts
|
|
1972
1968
|
var OrderByCanonicalizer = class {
|
|
1973
1969
|
#trie = new WeakRefTrie((array) => {
|
|
1974
1970
|
const pairs = array.reduce(function(result, _, index, array2) {
|
|
@@ -2066,7 +2062,7 @@ var WhereClauseCanonicalizer = class {
|
|
|
2066
2062
|
options: []
|
|
2067
2063
|
};
|
|
2068
2064
|
this.#existingOptions.set(cacheKey, lookupEntry);
|
|
2069
|
-
const canon = lookupEntry.options.find((ref) =>
|
|
2065
|
+
const canon = lookupEntry.options.find((ref) => deepEqual4__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
|
|
2070
2066
|
if (canon === calculatedCanon) {
|
|
2071
2067
|
lookupEntry.options.push(new WeakRef(canon));
|
|
2072
2068
|
}
|
|
@@ -2126,7 +2122,7 @@ var Store = class {
|
|
|
2126
2122
|
// these are hopefully temporary
|
|
2127
2123
|
constructor(client) {
|
|
2128
2124
|
this.client = client;
|
|
2129
|
-
this.logger = client[
|
|
2125
|
+
this.logger = client[chunkELAA4C2C_cjs.additionalContext].logger?.child({}, {
|
|
2130
2126
|
msgPrefix: "Store"
|
|
2131
2127
|
});
|
|
2132
2128
|
this.lists = new ListsHelper(this, this.whereCanonicalizer, this.orderByCanonicalizer);
|
|
@@ -2372,10 +2368,10 @@ var Store = class {
|
|
|
2372
2368
|
|
|
2373
2369
|
// src/observable/ObservableClient.ts
|
|
2374
2370
|
function createObservableClient(client) {
|
|
2375
|
-
const tweakedClient =
|
|
2376
|
-
...client[
|
|
2377
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
2378
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
2371
|
+
const tweakedClient = chunkKCMGIMVC_cjs.createClientFromContext({
|
|
2372
|
+
...client[chunkELAA4C2C_cjs.additionalContext],
|
|
2373
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkELAA4C2C_cjs.additionalContext].fetch, (headers) => {
|
|
2374
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkKCMGIMVC_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
2379
2375
|
return headers;
|
|
2380
2376
|
})
|
|
2381
2377
|
});
|
|
@@ -2418,11 +2414,11 @@ function getOsdkConfig(ontologyRid) {
|
|
|
2418
2414
|
|
|
2419
2415
|
Object.defineProperty(exports, "createClientWithTransaction", {
|
|
2420
2416
|
enumerable: true,
|
|
2421
|
-
get: function () { return
|
|
2417
|
+
get: function () { return chunkKCMGIMVC_cjs.createClientWithTransaction; }
|
|
2422
2418
|
});
|
|
2423
2419
|
Object.defineProperty(exports, "augment", {
|
|
2424
2420
|
enumerable: true,
|
|
2425
|
-
get: function () { return
|
|
2421
|
+
get: function () { return chunkELAA4C2C_cjs.augment; }
|
|
2426
2422
|
});
|
|
2427
2423
|
exports.createObservableClient = createObservableClient;
|
|
2428
2424
|
exports.getMetaTagContent = getMetaTagContent;
|