@osdk/client 2.5.0-beta.8 → 2.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/createMinimalClient.js +2 -1
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +4 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +5 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +77 -29
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +35 -1
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +11 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ObjectSetPayload.js +2 -0
- package/build/browser/observable/ObjectSetPayload.js.map +1 -0
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/computeObjectSetCacheKey.js +64 -0
- package/build/browser/observable/computeObjectSetCacheKey.js.map +1 -0
- package/build/browser/observable/internal/Changes.js +3 -0
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +17 -0
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/Query.js +18 -1
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/Store.invalidation.test.js +165 -0
- package/build/browser/observable/internal/Store.invalidation.test.js.map +1 -1
- package/build/browser/observable/internal/Store.js +23 -0
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/browser/observable/internal/list/ListQuery.js +33 -108
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListsHelper.js +4 -2
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/browser/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
- package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js +69 -0
- package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +151 -0
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
- package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
- package/build/browser/observable/internal/testUtils.js +2 -1
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/queries/applyQuery.js +5 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/exponentialBackoff.js +51 -0
- package/build/browser/util/exponentialBackoff.js.map +1 -0
- package/build/browser/util/exponentialBackoff.test.js +81 -0
- package/build/browser/util/exponentialBackoff.test.js.map +1 -0
- package/build/browser/util/extractObjectOrInterfaceType.js +5 -1
- package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/cjs/{chunk-XCZOFC4A.cjs → chunk-BP7BR5FZ.cjs} +61 -59
- package/build/cjs/chunk-BP7BR5FZ.cjs.map +1 -0
- package/build/cjs/{chunk-5KDG5ZET.cjs → chunk-DCEFUXFS.cjs} +341 -229
- package/build/cjs/chunk-DCEFUXFS.cjs.map +1 -0
- package/build/cjs/index.cjs +11 -7
- package/build/cjs/index.d.cts +8 -1
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +536 -240
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +78 -6
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/createMinimalClient.js +2 -1
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/definitions/LinkDefinitions.test.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +4 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +5 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +77 -29
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +35 -1
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +11 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ObjectSetPayload.js +2 -0
- package/build/esm/observable/ObjectSetPayload.js.map +1 -0
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/computeObjectSetCacheKey.js +64 -0
- package/build/esm/observable/computeObjectSetCacheKey.js.map +1 -0
- package/build/esm/observable/internal/Changes.js +3 -0
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +17 -0
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/Query.js +18 -1
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/Store.invalidation.test.js +165 -0
- package/build/esm/observable/internal/Store.invalidation.test.js.map +1 -1
- package/build/esm/observable/internal/Store.js +23 -0
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/esm/observable/internal/list/ListQuery.js +33 -108
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListsHelper.js +4 -2
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
- package/build/esm/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js +2 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
- package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js +69 -0
- package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +151 -0
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
- package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
- package/build/esm/observable/internal/testUtils.js +2 -1
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.js +5 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/exponentialBackoff.js +51 -0
- package/build/esm/util/exponentialBackoff.js.map +1 -0
- package/build/esm/util/exponentialBackoff.test.js +81 -0
- package/build/esm/util/exponentialBackoff.test.js.map +1 -0
- package/build/esm/util/extractObjectOrInterfaceType.js +5 -1
- package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.test.js +21 -2
- package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -0
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/observable/ObjectSetPayload.d.ts +5 -0
- package/build/types/observable/ObjectSetPayload.d.ts.map +1 -0
- package/build/types/observable/ObservableClient.d.ts +54 -1
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/computeObjectSetCacheKey.d.ts +16 -0
- package/build/types/observable/computeObjectSetCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/Changes.d.ts +5 -3
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
- package/build/types/observable/internal/Query.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +5 -1
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQuery.d.ts +37 -6
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts +1 -1
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
- package/build/types/observable/internal/list/ObjectListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +16 -0
- package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +19 -0
- package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +34 -0
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +18 -0
- package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +2 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/build/types/util/exponentialBackoff.d.ts +14 -0
- package/build/types/util/exponentialBackoff.d.ts.map +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts.map +1 -0
- package/package.json +11 -11
- package/build/cjs/chunk-5KDG5ZET.cjs.map +0 -1
- package/build/cjs/chunk-XCZOFC4A.cjs.map +0 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
|
|
4
4
|
var shared_net_errors = require('@osdk/shared.net.errors');
|
|
5
|
-
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
6
|
-
var invariant5 = require('tiny-invariant');
|
|
7
5
|
var api = require('@osdk/api');
|
|
6
|
+
var invariant5 = require('tiny-invariant');
|
|
7
|
+
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
8
8
|
var WebSocket = require('isomorphic-ws');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -337,6 +337,187 @@ var _streamValues = [1, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/strea
|
|
|
337
337
|
function streamValues($ctx, ...args) {
|
|
338
338
|
return foundryPlatformFetch($ctx, _streamValues, ...args);
|
|
339
339
|
}
|
|
340
|
+
function extractNamespace(fqApiName) {
|
|
341
|
+
const last = fqApiName.lastIndexOf(".");
|
|
342
|
+
if (last === -1) return [void 0, fqApiName];
|
|
343
|
+
return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
|
|
344
|
+
}
|
|
345
|
+
function modernToLegacyWhereClause(whereClause, objectOrInterface) {
|
|
346
|
+
if ("$and" in whereClause) {
|
|
347
|
+
return {
|
|
348
|
+
type: "and",
|
|
349
|
+
value: whereClause.$and.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
350
|
+
};
|
|
351
|
+
} else if ("$or" in whereClause) {
|
|
352
|
+
return {
|
|
353
|
+
type: "or",
|
|
354
|
+
value: whereClause.$or.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
355
|
+
};
|
|
356
|
+
} else if ("$not" in whereClause) {
|
|
357
|
+
return {
|
|
358
|
+
type: "not",
|
|
359
|
+
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
const parts = Object.entries(whereClause);
|
|
363
|
+
if (parts.length === 1) {
|
|
364
|
+
return handleWherePair(parts[0], objectOrInterface);
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
type: "and",
|
|
368
|
+
value: parts.map((v) => handleWherePair(v, objectOrInterface))
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function makeGeoFilterBbox(bbox, filterType, propertyIdentifier, field) {
|
|
372
|
+
return {
|
|
373
|
+
type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
|
|
374
|
+
/**
|
|
375
|
+
* This is a bit ugly, but did this so that propertyIdentifier only shows up in the return object if its defined,
|
|
376
|
+
* this makes it so we don't need to go update our entire test bed either to include a field which may change in near future.
|
|
377
|
+
* Once we solidify that this is the way forward, I can remove field and clean this up
|
|
378
|
+
*/
|
|
379
|
+
...propertyIdentifier != null && {
|
|
380
|
+
propertyIdentifier
|
|
381
|
+
},
|
|
382
|
+
field,
|
|
383
|
+
value: {
|
|
384
|
+
topLeft: {
|
|
385
|
+
type: "Point",
|
|
386
|
+
coordinates: [bbox[0], bbox[3]]
|
|
387
|
+
},
|
|
388
|
+
bottomRight: {
|
|
389
|
+
type: "Point",
|
|
390
|
+
coordinates: [bbox[2], bbox[1]]
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function makeGeoFilterPolygon(coordinates, filterType, propertyIdentifier, field) {
|
|
396
|
+
return {
|
|
397
|
+
type: filterType,
|
|
398
|
+
...propertyIdentifier != null && {
|
|
399
|
+
propertyIdentifier
|
|
400
|
+
},
|
|
401
|
+
field,
|
|
402
|
+
value: {
|
|
403
|
+
type: "Polygon",
|
|
404
|
+
coordinates
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function handleWherePair([fieldName, filter], objectOrInterface, structFieldSelector) {
|
|
409
|
+
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Defined key values are only allowed when they are not undefined.") : invariant5__default.default(false) : void 0;
|
|
410
|
+
const propertyIdentifier = structFieldSelector != null ? {
|
|
411
|
+
type: "structField",
|
|
412
|
+
...structFieldSelector,
|
|
413
|
+
propertyApiName: fullyQualifyPropName(structFieldSelector.propertyApiName, objectOrInterface)
|
|
414
|
+
} : void 0;
|
|
415
|
+
const field = structFieldSelector == null ? fullyQualifyPropName(fieldName, objectOrInterface) : void 0;
|
|
416
|
+
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
417
|
+
return {
|
|
418
|
+
type: "eq",
|
|
419
|
+
...propertyIdentifier != null && {
|
|
420
|
+
propertyIdentifier
|
|
421
|
+
},
|
|
422
|
+
field,
|
|
423
|
+
value: filter
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const keysOfFilter = Object.keys(filter);
|
|
427
|
+
const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
|
|
428
|
+
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.") : invariant5__default.default(false) : void 0;
|
|
429
|
+
if (!hasDollarSign) {
|
|
430
|
+
const structFilter = Object.entries(filter);
|
|
431
|
+
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant5__default.default(false) : void 0;
|
|
432
|
+
const structFieldApiName = keysOfFilter[0];
|
|
433
|
+
return handleWherePair(Object.entries(filter)[0], objectOrInterface, {
|
|
434
|
+
propertyApiName: fieldName,
|
|
435
|
+
structFieldApiName
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const firstKey = keysOfFilter[0];
|
|
439
|
+
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
|
|
440
|
+
if (firstKey === "$ne") {
|
|
441
|
+
return {
|
|
442
|
+
type: "not",
|
|
443
|
+
value: {
|
|
444
|
+
type: "eq",
|
|
445
|
+
...propertyIdentifier != null && {
|
|
446
|
+
propertyIdentifier
|
|
447
|
+
},
|
|
448
|
+
field,
|
|
449
|
+
value: filter[firstKey]
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
if (firstKey === "$within") {
|
|
454
|
+
const withinBody = filter[firstKey];
|
|
455
|
+
if (Array.isArray(withinBody)) {
|
|
456
|
+
return makeGeoFilterBbox(withinBody, firstKey, propertyIdentifier, field);
|
|
457
|
+
} else if ("$bbox" in withinBody && withinBody.$bbox != null) {
|
|
458
|
+
return makeGeoFilterBbox(withinBody.$bbox, firstKey, propertyIdentifier, field);
|
|
459
|
+
} else if ("$distance" in withinBody && "$of" in withinBody && withinBody.$distance != null && withinBody.$of != null) {
|
|
460
|
+
return {
|
|
461
|
+
type: "withinDistanceOf",
|
|
462
|
+
...propertyIdentifier != null && {
|
|
463
|
+
propertyIdentifier
|
|
464
|
+
},
|
|
465
|
+
field,
|
|
466
|
+
value: {
|
|
467
|
+
center: Array.isArray(withinBody.$of) ? {
|
|
468
|
+
type: "Point",
|
|
469
|
+
coordinates: withinBody.$of
|
|
470
|
+
} : withinBody.$of,
|
|
471
|
+
distance: {
|
|
472
|
+
value: withinBody.$distance[0],
|
|
473
|
+
unit: api.DistanceUnitMapping[withinBody.$distance[1]]
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
} else {
|
|
478
|
+
const coordinates = "$polygon" in withinBody ? withinBody.$polygon : withinBody.coordinates;
|
|
479
|
+
return makeGeoFilterPolygon(coordinates, "withinPolygon", propertyIdentifier, fieldName);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (firstKey === "$intersects") {
|
|
483
|
+
const intersectsBody = filter[firstKey];
|
|
484
|
+
if (Array.isArray(intersectsBody)) {
|
|
485
|
+
return makeGeoFilterBbox(intersectsBody, firstKey, propertyIdentifier, field);
|
|
486
|
+
} else if ("$bbox" in intersectsBody && intersectsBody.$bbox != null) {
|
|
487
|
+
return makeGeoFilterBbox(intersectsBody.$bbox, firstKey, propertyIdentifier, field);
|
|
488
|
+
} else {
|
|
489
|
+
const coordinates = "$polygon" in intersectsBody ? intersectsBody.$polygon : intersectsBody.coordinates;
|
|
490
|
+
return makeGeoFilterPolygon(coordinates, "intersectsPolygon", propertyIdentifier, field);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (firstKey === "$containsAllTerms" || firstKey === "$containsAnyTerm") {
|
|
494
|
+
return {
|
|
495
|
+
type: firstKey.substring(1),
|
|
496
|
+
...propertyIdentifier != null && {
|
|
497
|
+
propertyIdentifier
|
|
498
|
+
},
|
|
499
|
+
field,
|
|
500
|
+
value: typeof filter[firstKey] === "string" ? filter[firstKey] : filter[firstKey]["term"],
|
|
501
|
+
fuzzy: typeof filter[firstKey] === "string" ? false : filter[firstKey]["fuzzySearch"] ?? false
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
type: firstKey.substring(1),
|
|
506
|
+
...propertyIdentifier != null && {
|
|
507
|
+
propertyIdentifier
|
|
508
|
+
},
|
|
509
|
+
field,
|
|
510
|
+
value: filter[firstKey]
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function fullyQualifyPropName(fieldName, objectOrInterface) {
|
|
514
|
+
if (objectOrInterface.type === "interface") {
|
|
515
|
+
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
516
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(fieldName);
|
|
517
|
+
return fieldApiNamespace == null && objApiNamespace != null ? `${objApiNamespace}.${fieldShortName}` : fieldName;
|
|
518
|
+
}
|
|
519
|
+
return fieldName;
|
|
520
|
+
}
|
|
340
521
|
var addUserAgentAndRequestContextHeaders = (client, withMetadata) => ({
|
|
341
522
|
...client,
|
|
342
523
|
fetch: shared_net_fetch.createFetchHeaderMutator(client.fetch, (headers) => {
|
|
@@ -382,9 +563,13 @@ async function extractObjectOrInterfaceType(clientCtx, objectSet) {
|
|
|
382
563
|
};
|
|
383
564
|
case "filter":
|
|
384
565
|
case "asBaseObjectTypes":
|
|
385
|
-
case "asType":
|
|
386
566
|
case "nearestNeighbors":
|
|
387
567
|
return extractObjectOrInterfaceType(clientCtx, objectSet.objectSet);
|
|
568
|
+
case "asType":
|
|
569
|
+
return {
|
|
570
|
+
type: clientCtx.asTypeInterfaceOrObjectMapping[objectSet.entityType],
|
|
571
|
+
apiName: objectSet.entityType
|
|
572
|
+
};
|
|
388
573
|
case "intersect": {
|
|
389
574
|
const objectSets2 = objectSet.objectSets;
|
|
390
575
|
const objectSetTypes2 = await Promise.all(objectSets2.map((os) => extractObjectOrInterfaceType(clientCtx, os)));
|
|
@@ -599,9 +784,7 @@ function resolveInterfaceObjectSet(objectSet, interfaceTypeApiName, args) {
|
|
|
599
784
|
} : objectSet;
|
|
600
785
|
}
|
|
601
786
|
async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
602
|
-
const
|
|
603
|
-
osdkMetadata: void 0
|
|
604
|
-
}), await client.ontologyRid, applyFetchArgs(args, {
|
|
787
|
+
const requestBody = await applyFetchArgs(args, {
|
|
605
788
|
objectSet: {
|
|
606
789
|
type: "static",
|
|
607
790
|
objects: rids
|
|
@@ -609,7 +792,13 @@ async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
|
609
792
|
select: args?.$select ?? [],
|
|
610
793
|
excludeRid: !args?.$includeRid,
|
|
611
794
|
snapshot: useSnapshot
|
|
612
|
-
}
|
|
795
|
+
}, client, {
|
|
796
|
+
type: "object",
|
|
797
|
+
apiName: ""
|
|
798
|
+
});
|
|
799
|
+
const result = await OntologyObjectSet_exports.loadMultipleObjectTypes(addUserAgentAndRequestContextHeaders(client, {
|
|
800
|
+
osdkMetadata: void 0
|
|
801
|
+
}), await client.ontologyRid, requestBody, {
|
|
613
802
|
preview: true
|
|
614
803
|
});
|
|
615
804
|
return Promise.resolve({
|
|
@@ -620,14 +809,20 @@ async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
|
620
809
|
}
|
|
621
810
|
async function fetchInterfacePage(client, interfaceType, args, objectSet, useSnapshot = false) {
|
|
622
811
|
if (args.$__UNSTABLE_useOldInterfaceApis) {
|
|
623
|
-
const
|
|
812
|
+
const baseRequestBody = {
|
|
624
813
|
augmentedProperties: {},
|
|
625
814
|
augmentedSharedPropertyTypes: {},
|
|
626
815
|
otherInterfaceTypes: [],
|
|
627
816
|
selectedObjectTypes: [],
|
|
628
|
-
selectedSharedPropertyTypes: args.$select
|
|
817
|
+
selectedSharedPropertyTypes: args.$select ? [...args.$select] : [],
|
|
629
818
|
where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)
|
|
630
|
-
}
|
|
819
|
+
};
|
|
820
|
+
const requestBody2 = await applyFetchArgs(args, baseRequestBody, client, interfaceType);
|
|
821
|
+
if (requestBody2.selectedSharedPropertyTypes.length > 0) {
|
|
822
|
+
const remapped = remapPropertyNames(interfaceType, requestBody2.selectedSharedPropertyTypes);
|
|
823
|
+
requestBody2.selectedSharedPropertyTypes = Array.from(remapped);
|
|
824
|
+
}
|
|
825
|
+
const result2 = await OntologyInterface_exports.search(addUserAgentAndRequestContextHeaders(client, interfaceType), await client.ontologyRid, interfaceType.apiName, requestBody2, {
|
|
631
826
|
preview: true
|
|
632
827
|
});
|
|
633
828
|
result2.data = await client.objectFactory(
|
|
@@ -640,18 +835,20 @@ async function fetchInterfacePage(client, interfaceType, args, objectSet, useSna
|
|
|
640
835
|
);
|
|
641
836
|
return result2;
|
|
642
837
|
}
|
|
643
|
-
const
|
|
644
|
-
const
|
|
838
|
+
const extractedInterfaceTypeApiName = (await extractObjectOrInterfaceType(client, objectSet))?.apiName ?? interfaceType.apiName;
|
|
839
|
+
const resolvedInterfaceObjectSet = resolveInterfaceObjectSet(objectSet, extractedInterfaceTypeApiName, args);
|
|
840
|
+
const requestBody = await buildAndRemapRequestBody(args, {
|
|
645
841
|
objectSet: resolvedInterfaceObjectSet,
|
|
646
|
-
select: args?.$select
|
|
842
|
+
select: args?.$select ? [...args.$select] : [],
|
|
647
843
|
excludeRid: !args?.$includeRid,
|
|
648
844
|
snapshot: useSnapshot
|
|
649
|
-
}
|
|
845
|
+
}, client, interfaceType);
|
|
846
|
+
const result = await OntologyObjectSet_exports.loadMultipleObjectTypes(addUserAgentAndRequestContextHeaders(client, interfaceType), await client.ontologyRid, requestBody, {
|
|
650
847
|
preview: true,
|
|
651
848
|
branch: client.branch
|
|
652
849
|
});
|
|
653
850
|
return Promise.resolve({
|
|
654
|
-
data: await client.objectFactory2(client, result.data,
|
|
851
|
+
data: await client.objectFactory2(client, result.data, extractedInterfaceTypeApiName, {}, !args.$includeRid, args.$select, false, result.interfaceToObjectTypeMappings),
|
|
655
852
|
nextPageToken: result.nextPageToken,
|
|
656
853
|
totalCount: result.totalCount
|
|
657
854
|
});
|
|
@@ -683,7 +880,31 @@ async function fetchPageWithErrorsInternal(client, objectType, objectSet, args =
|
|
|
683
880
|
async function fetchPage(client, objectType, args, objectSet = resolveBaseObjectSetType(objectType)) {
|
|
684
881
|
return fetchPageInternal(client, objectType, objectSet, args);
|
|
685
882
|
}
|
|
686
|
-
function
|
|
883
|
+
async function buildAndRemapRequestBody(args, baseBody, client, objectType) {
|
|
884
|
+
const requestBody = await applyFetchArgs(args, baseBody, client, objectType);
|
|
885
|
+
if (requestBody.select != null && requestBody.select.length > 0) {
|
|
886
|
+
const remapped = remapPropertyNames(objectType, requestBody.select);
|
|
887
|
+
return {
|
|
888
|
+
...requestBody,
|
|
889
|
+
select: remapped
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
return requestBody;
|
|
893
|
+
}
|
|
894
|
+
function remapPropertyNames(objectOrInterface, propertyNames) {
|
|
895
|
+
if (objectOrInterface == null) {
|
|
896
|
+
return propertyNames;
|
|
897
|
+
}
|
|
898
|
+
if (objectOrInterface.type === "interface") {
|
|
899
|
+
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
900
|
+
return propertyNames.map((name) => {
|
|
901
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(name);
|
|
902
|
+
return fieldApiNamespace == null && objApiNamespace != null ? `${objApiNamespace}.${fieldShortName}` : name;
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
return propertyNames;
|
|
906
|
+
}
|
|
907
|
+
async function applyFetchArgs(args, body, _client, objectType) {
|
|
687
908
|
if (args?.$nextPageToken) {
|
|
688
909
|
body.pageToken = args.$nextPageToken;
|
|
689
910
|
}
|
|
@@ -692,28 +913,35 @@ function applyFetchArgs(args, body) {
|
|
|
692
913
|
}
|
|
693
914
|
const orderBy = args?.$orderBy;
|
|
694
915
|
if (orderBy) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
916
|
+
if (orderBy === "relevance") {
|
|
917
|
+
body.orderBy = {
|
|
918
|
+
orderType: "relevance",
|
|
919
|
+
fields: []
|
|
920
|
+
};
|
|
921
|
+
} else {
|
|
922
|
+
const orderByEntries = Object.entries(orderBy);
|
|
923
|
+
const fieldNames = orderByEntries.map(([field]) => field);
|
|
924
|
+
const remappedFields = remapPropertyNames(objectType, fieldNames);
|
|
925
|
+
body.orderBy = {
|
|
926
|
+
fields: orderByEntries.map(([, direction], index) => ({
|
|
927
|
+
field: remappedFields[index],
|
|
928
|
+
direction
|
|
929
|
+
}))
|
|
930
|
+
};
|
|
931
|
+
}
|
|
704
932
|
}
|
|
705
933
|
return body;
|
|
706
934
|
}
|
|
707
935
|
async function fetchObjectPage(client, objectType, args, objectSet, useSnapshot = false) {
|
|
708
|
-
void client.ontologyProvider.getObjectDefinition(objectType.apiName)
|
|
709
|
-
|
|
936
|
+
void client.ontologyProvider.getObjectDefinition(objectType.apiName).catch(() => {
|
|
937
|
+
});
|
|
938
|
+
const requestBody = await buildAndRemapRequestBody(args, {
|
|
710
939
|
objectSet,
|
|
711
|
-
|
|
712
|
-
select: args?.$select ?? [],
|
|
713
|
-
// FIXME?
|
|
940
|
+
select: args?.$select ? [...args.$select] : [],
|
|
714
941
|
excludeRid: !args?.$includeRid,
|
|
715
942
|
snapshot: useSnapshot
|
|
716
|
-
}
|
|
943
|
+
}, client, objectType);
|
|
944
|
+
const r = await OntologyObjectSet_exports.load(addUserAgentAndRequestContextHeaders(client, objectType), await client.ontologyRid, requestBody, {
|
|
717
945
|
branch: client.branch
|
|
718
946
|
});
|
|
719
947
|
return Promise.resolve({
|
|
@@ -839,187 +1067,6 @@ async function fetchSingleWithErrors(client, objectType, args, objectSet) {
|
|
|
839
1067
|
};
|
|
840
1068
|
}
|
|
841
1069
|
}
|
|
842
|
-
function extractNamespace(fqApiName) {
|
|
843
|
-
const last = fqApiName.lastIndexOf(".");
|
|
844
|
-
if (last === -1) return [void 0, fqApiName];
|
|
845
|
-
return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
|
|
846
|
-
}
|
|
847
|
-
function modernToLegacyWhereClause(whereClause, objectOrInterface) {
|
|
848
|
-
if ("$and" in whereClause) {
|
|
849
|
-
return {
|
|
850
|
-
type: "and",
|
|
851
|
-
value: whereClause.$and.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
852
|
-
};
|
|
853
|
-
} else if ("$or" in whereClause) {
|
|
854
|
-
return {
|
|
855
|
-
type: "or",
|
|
856
|
-
value: whereClause.$or.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
857
|
-
};
|
|
858
|
-
} else if ("$not" in whereClause) {
|
|
859
|
-
return {
|
|
860
|
-
type: "not",
|
|
861
|
-
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
const parts = Object.entries(whereClause);
|
|
865
|
-
if (parts.length === 1) {
|
|
866
|
-
return handleWherePair(parts[0], objectOrInterface);
|
|
867
|
-
}
|
|
868
|
-
return {
|
|
869
|
-
type: "and",
|
|
870
|
-
value: parts.map((v) => handleWherePair(v, objectOrInterface))
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
function makeGeoFilterBbox(bbox, filterType, propertyIdentifier, field) {
|
|
874
|
-
return {
|
|
875
|
-
type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
|
|
876
|
-
/**
|
|
877
|
-
* This is a bit ugly, but did this so that propertyIdentifier only shows up in the return object if its defined,
|
|
878
|
-
* this makes it so we don't need to go update our entire test bed either to include a field which may change in near future.
|
|
879
|
-
* Once we solidify that this is the way forward, I can remove field and clean this up
|
|
880
|
-
*/
|
|
881
|
-
...propertyIdentifier != null && {
|
|
882
|
-
propertyIdentifier
|
|
883
|
-
},
|
|
884
|
-
field,
|
|
885
|
-
value: {
|
|
886
|
-
topLeft: {
|
|
887
|
-
type: "Point",
|
|
888
|
-
coordinates: [bbox[0], bbox[3]]
|
|
889
|
-
},
|
|
890
|
-
bottomRight: {
|
|
891
|
-
type: "Point",
|
|
892
|
-
coordinates: [bbox[2], bbox[1]]
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
function makeGeoFilterPolygon(coordinates, filterType, propertyIdentifier, field) {
|
|
898
|
-
return {
|
|
899
|
-
type: filterType,
|
|
900
|
-
...propertyIdentifier != null && {
|
|
901
|
-
propertyIdentifier
|
|
902
|
-
},
|
|
903
|
-
field,
|
|
904
|
-
value: {
|
|
905
|
-
type: "Polygon",
|
|
906
|
-
coordinates
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
function handleWherePair([fieldName, filter], objectOrInterface, structFieldSelector) {
|
|
911
|
-
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Defined key values are only allowed when they are not undefined.") : invariant5__default.default(false) : void 0;
|
|
912
|
-
const propertyIdentifier = structFieldSelector != null ? {
|
|
913
|
-
type: "structField",
|
|
914
|
-
...structFieldSelector,
|
|
915
|
-
propertyApiName: fullyQualifyPropName(structFieldSelector.propertyApiName, objectOrInterface)
|
|
916
|
-
} : void 0;
|
|
917
|
-
const field = structFieldSelector == null ? fullyQualifyPropName(fieldName, objectOrInterface) : void 0;
|
|
918
|
-
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
919
|
-
return {
|
|
920
|
-
type: "eq",
|
|
921
|
-
...propertyIdentifier != null && {
|
|
922
|
-
propertyIdentifier
|
|
923
|
-
},
|
|
924
|
-
field,
|
|
925
|
-
value: filter
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
const keysOfFilter = Object.keys(filter);
|
|
929
|
-
const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
|
|
930
|
-
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.") : invariant5__default.default(false) : void 0;
|
|
931
|
-
if (!hasDollarSign) {
|
|
932
|
-
const structFilter = Object.entries(filter);
|
|
933
|
-
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant5__default.default(false) : void 0;
|
|
934
|
-
const structFieldApiName = keysOfFilter[0];
|
|
935
|
-
return handleWherePair(Object.entries(filter)[0], objectOrInterface, {
|
|
936
|
-
propertyApiName: fieldName,
|
|
937
|
-
structFieldApiName
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
const firstKey = keysOfFilter[0];
|
|
941
|
-
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
|
|
942
|
-
if (firstKey === "$ne") {
|
|
943
|
-
return {
|
|
944
|
-
type: "not",
|
|
945
|
-
value: {
|
|
946
|
-
type: "eq",
|
|
947
|
-
...propertyIdentifier != null && {
|
|
948
|
-
propertyIdentifier
|
|
949
|
-
},
|
|
950
|
-
field,
|
|
951
|
-
value: filter[firstKey]
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
}
|
|
955
|
-
if (firstKey === "$within") {
|
|
956
|
-
const withinBody = filter[firstKey];
|
|
957
|
-
if (Array.isArray(withinBody)) {
|
|
958
|
-
return makeGeoFilterBbox(withinBody, firstKey, propertyIdentifier, field);
|
|
959
|
-
} else if ("$bbox" in withinBody && withinBody.$bbox != null) {
|
|
960
|
-
return makeGeoFilterBbox(withinBody.$bbox, firstKey, propertyIdentifier, field);
|
|
961
|
-
} else if ("$distance" in withinBody && "$of" in withinBody && withinBody.$distance != null && withinBody.$of != null) {
|
|
962
|
-
return {
|
|
963
|
-
type: "withinDistanceOf",
|
|
964
|
-
...propertyIdentifier != null && {
|
|
965
|
-
propertyIdentifier
|
|
966
|
-
},
|
|
967
|
-
field,
|
|
968
|
-
value: {
|
|
969
|
-
center: Array.isArray(withinBody.$of) ? {
|
|
970
|
-
type: "Point",
|
|
971
|
-
coordinates: withinBody.$of
|
|
972
|
-
} : withinBody.$of,
|
|
973
|
-
distance: {
|
|
974
|
-
value: withinBody.$distance[0],
|
|
975
|
-
unit: api.DistanceUnitMapping[withinBody.$distance[1]]
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
} else {
|
|
980
|
-
const coordinates = "$polygon" in withinBody ? withinBody.$polygon : withinBody.coordinates;
|
|
981
|
-
return makeGeoFilterPolygon(coordinates, "withinPolygon", propertyIdentifier, fieldName);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
if (firstKey === "$intersects") {
|
|
985
|
-
const intersectsBody = filter[firstKey];
|
|
986
|
-
if (Array.isArray(intersectsBody)) {
|
|
987
|
-
return makeGeoFilterBbox(intersectsBody, firstKey, propertyIdentifier, field);
|
|
988
|
-
} else if ("$bbox" in intersectsBody && intersectsBody.$bbox != null) {
|
|
989
|
-
return makeGeoFilterBbox(intersectsBody.$bbox, firstKey, propertyIdentifier, field);
|
|
990
|
-
} else {
|
|
991
|
-
const coordinates = "$polygon" in intersectsBody ? intersectsBody.$polygon : intersectsBody.coordinates;
|
|
992
|
-
return makeGeoFilterPolygon(coordinates, "intersectsPolygon", propertyIdentifier, field);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
if (firstKey === "$containsAllTerms" || firstKey === "$containsAnyTerm") {
|
|
996
|
-
return {
|
|
997
|
-
type: firstKey.substring(1),
|
|
998
|
-
...propertyIdentifier != null && {
|
|
999
|
-
propertyIdentifier
|
|
1000
|
-
},
|
|
1001
|
-
field,
|
|
1002
|
-
value: typeof filter[firstKey] === "string" ? filter[firstKey] : filter[firstKey]["term"],
|
|
1003
|
-
fuzzy: typeof filter[firstKey] === "string" ? false : filter[firstKey]["fuzzySearch"] ?? false
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
return {
|
|
1007
|
-
type: firstKey.substring(1),
|
|
1008
|
-
...propertyIdentifier != null && {
|
|
1009
|
-
propertyIdentifier
|
|
1010
|
-
},
|
|
1011
|
-
field,
|
|
1012
|
-
value: filter[firstKey]
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
function fullyQualifyPropName(fieldName, objectOrInterface) {
|
|
1016
|
-
if (objectOrInterface.type === "interface") {
|
|
1017
|
-
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
1018
|
-
const [fieldApiNamespace, fieldShortName] = extractNamespace(fieldName);
|
|
1019
|
-
return fieldApiNamespace == null && objApiNamespace != null ? `${objApiNamespace}.${fieldShortName}` : fieldName;
|
|
1020
|
-
}
|
|
1021
|
-
return fieldName;
|
|
1022
|
-
}
|
|
1023
1070
|
function derivedPropertyDefinitionFactory(wireDefinition, definitionMap) {
|
|
1024
1071
|
const definition = {
|
|
1025
1072
|
abs() {
|
|
@@ -1351,7 +1398,50 @@ var WIRE_OBJECT_SET_TYPES = /* @__PURE__ */ new Set(["base", "filter", "intersec
|
|
|
1351
1398
|
function isWireObjectSet(o) {
|
|
1352
1399
|
return o != null && typeof o === "object" && WIRE_OBJECT_SET_TYPES.has(o.type);
|
|
1353
1400
|
}
|
|
1401
|
+
|
|
1402
|
+
// src/util/exponentialBackoff.ts
|
|
1403
|
+
var DEFAULT_OPTIONS = {
|
|
1404
|
+
initialDelayMs: 1e3,
|
|
1405
|
+
maxDelayMs: 6e4,
|
|
1406
|
+
multiplier: 2,
|
|
1407
|
+
jitterFactor: 0.3
|
|
1408
|
+
};
|
|
1409
|
+
var ExponentialBackoff = class {
|
|
1410
|
+
attempt = 0;
|
|
1411
|
+
constructor(options = {}) {
|
|
1412
|
+
this.options = {
|
|
1413
|
+
...DEFAULT_OPTIONS,
|
|
1414
|
+
...options
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
calculateDelay() {
|
|
1418
|
+
const {
|
|
1419
|
+
initialDelayMs,
|
|
1420
|
+
maxDelayMs,
|
|
1421
|
+
multiplier,
|
|
1422
|
+
jitterFactor
|
|
1423
|
+
} = this.options;
|
|
1424
|
+
const baseDelay = Math.min(initialDelayMs * Math.pow(multiplier, this.attempt), maxDelayMs);
|
|
1425
|
+
const jitter = baseDelay * jitterFactor * (Math.random() * 2 - 1);
|
|
1426
|
+
const delayWithJitter = Math.max(0, baseDelay + jitter);
|
|
1427
|
+
this.attempt++;
|
|
1428
|
+
return Math.round(delayWithJitter);
|
|
1429
|
+
}
|
|
1430
|
+
reset() {
|
|
1431
|
+
this.attempt = 0;
|
|
1432
|
+
}
|
|
1433
|
+
getAttempt() {
|
|
1434
|
+
return this.attempt;
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
// src/objectSet/ObjectSetListenerWebsocket.ts
|
|
1354
1439
|
var MINIMUM_RECONNECT_DELAY_MS = 5 * 1e3;
|
|
1440
|
+
var EXPONENTIAL_BACKOFF_INITIAL_DELAY_MS = 1e3;
|
|
1441
|
+
var EXPONENTIAL_BACKOFF_MAX_DELAY_MS = 6e4;
|
|
1442
|
+
var EXPONENTIAL_BACKOFF_MULTIPLIER = 2;
|
|
1443
|
+
var EXPONENTIAL_BACKOFF_JITTER_FACTOR = 0.3;
|
|
1444
|
+
var WEBSOCKET_IDLE_DISCONNECT_DELAY_MS = 15e3;
|
|
1355
1445
|
function doNothing() {
|
|
1356
1446
|
}
|
|
1357
1447
|
function fillOutListener({
|
|
@@ -1387,6 +1477,8 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1387
1477
|
#ws;
|
|
1388
1478
|
#lastWsConnect = 0;
|
|
1389
1479
|
#client;
|
|
1480
|
+
#backoff;
|
|
1481
|
+
#isFirstConnection = true;
|
|
1390
1482
|
#logger;
|
|
1391
1483
|
/**
|
|
1392
1484
|
* map of requestId to all active subscriptions at the time of the request
|
|
@@ -1405,6 +1497,12 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1405
1497
|
} = {}) {
|
|
1406
1498
|
this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;
|
|
1407
1499
|
this.#client = client;
|
|
1500
|
+
this.#backoff = new ExponentialBackoff({
|
|
1501
|
+
initialDelayMs: EXPONENTIAL_BACKOFF_INITIAL_DELAY_MS,
|
|
1502
|
+
maxDelayMs: EXPONENTIAL_BACKOFF_MAX_DELAY_MS,
|
|
1503
|
+
multiplier: EXPONENTIAL_BACKOFF_MULTIPLIER,
|
|
1504
|
+
jitterFactor: EXPONENTIAL_BACKOFF_JITTER_FACTOR
|
|
1505
|
+
});
|
|
1408
1506
|
this.#logger = client.logger?.child({}, {
|
|
1409
1507
|
msgPrefix: "<OSW> "
|
|
1410
1508
|
});
|
|
@@ -1505,16 +1603,12 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1505
1603
|
if (this.#maybeDisconnectTimeout) {
|
|
1506
1604
|
clearTimeout(this.#maybeDisconnectTimeout);
|
|
1507
1605
|
}
|
|
1508
|
-
this.#maybeDisconnectTimeout = setTimeout(
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
},
|
|
1515
|
-
15e3
|
|
1516
|
-
/* ms */
|
|
1517
|
-
);
|
|
1606
|
+
this.#maybeDisconnectTimeout = setTimeout(() => {
|
|
1607
|
+
this.#maybeDisconnectTimeout = void 0;
|
|
1608
|
+
if (this.#subscriptions.size === 0) {
|
|
1609
|
+
this.#cycleWebsocket();
|
|
1610
|
+
}
|
|
1611
|
+
}, WEBSOCKET_IDLE_DISCONNECT_DELAY_MS);
|
|
1518
1612
|
}
|
|
1519
1613
|
async #ensureWebsocket() {
|
|
1520
1614
|
if (this.#ws == null) {
|
|
@@ -1525,10 +1619,16 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1525
1619
|
const url = constructWebsocketUrl(baseUrl, await this.#client.ontologyRid);
|
|
1526
1620
|
const token = await tokenProvider();
|
|
1527
1621
|
if (this.#ws == null) {
|
|
1528
|
-
|
|
1529
|
-
|
|
1622
|
+
if (!this.#isFirstConnection) {
|
|
1623
|
+
const delay = this.#backoff.calculateDelay();
|
|
1624
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1625
|
+
this.#logger?.debug({
|
|
1626
|
+
delay,
|
|
1627
|
+
attempt: this.#backoff.getAttempt()
|
|
1628
|
+
}, "Waiting before reconnect");
|
|
1629
|
+
}
|
|
1530
1630
|
await new Promise((resolve) => {
|
|
1531
|
-
setTimeout(resolve,
|
|
1631
|
+
setTimeout(resolve, delay);
|
|
1532
1632
|
});
|
|
1533
1633
|
}
|
|
1534
1634
|
this.#lastWsConnect = Date.now();
|
|
@@ -1556,7 +1656,7 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1556
1656
|
}
|
|
1557
1657
|
function error(evt) {
|
|
1558
1658
|
cleanup();
|
|
1559
|
-
reject(evt);
|
|
1659
|
+
reject(new Error(String(evt)));
|
|
1560
1660
|
}
|
|
1561
1661
|
ws.addEventListener("open", open);
|
|
1562
1662
|
ws.addEventListener("error", error);
|
|
@@ -1566,10 +1666,12 @@ var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
|
1566
1666
|
}
|
|
1567
1667
|
}
|
|
1568
1668
|
#onOpen = () => {
|
|
1669
|
+
this.#isFirstConnection = false;
|
|
1670
|
+
this.#backoff.reset();
|
|
1569
1671
|
this.#sendSubscribeMessage();
|
|
1570
1672
|
};
|
|
1571
1673
|
#onMessage = async (message) => {
|
|
1572
|
-
const data = JSON.parse(message.data
|
|
1674
|
+
const data = JSON.parse(String(message.data));
|
|
1573
1675
|
if (process.env.NODE_ENV !== "production") {
|
|
1574
1676
|
this.#logger?.debug({
|
|
1575
1677
|
payload: data
|
|
@@ -1890,6 +1992,16 @@ function createObjectSet(objectType, clientCtx, objectSet = resolveBaseObjectSet
|
|
|
1890
1992
|
objectSet
|
|
1891
1993
|
});
|
|
1892
1994
|
},
|
|
1995
|
+
asType: (objectTypeDef) => {
|
|
1996
|
+
const existingMapping = clientCtx.asTypeInterfaceOrObjectMapping[objectTypeDef.apiName];
|
|
1997
|
+
!(!existingMapping || existingMapping === objectTypeDef.type) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `${objectTypeDef.apiName} was previously used as an ${existingMapping}, but now used as a ${objectTypeDef.type}.`) : invariant5__default.default(false) : void 0;
|
|
1998
|
+
clientCtx.asTypeInterfaceOrObjectMapping[objectTypeDef.apiName] = objectTypeDef.type;
|
|
1999
|
+
return clientCtx.objectSetFactory(objectTypeDef, clientCtx, {
|
|
2000
|
+
type: "asType",
|
|
2001
|
+
objectSet,
|
|
2002
|
+
entityType: objectTypeDef.apiName
|
|
2003
|
+
});
|
|
2004
|
+
},
|
|
1893
2005
|
$objectSetInternals: {
|
|
1894
2006
|
def: objectType
|
|
1895
2007
|
}
|
|
@@ -1956,5 +2068,5 @@ exports.hydrateAttachmentFromRidInternal = hydrateAttachmentFromRidInternal;
|
|
|
1956
2068
|
exports.isObjectSet = isObjectSet;
|
|
1957
2069
|
exports.isWireObjectSet = isWireObjectSet;
|
|
1958
2070
|
exports.symbolClientContext = symbolClientContext;
|
|
1959
|
-
//# sourceMappingURL=chunk-
|
|
1960
|
-
//# sourceMappingURL=chunk-
|
|
2071
|
+
//# sourceMappingURL=chunk-DCEFUXFS.cjs.map
|
|
2072
|
+
//# sourceMappingURL=chunk-DCEFUXFS.cjs.map
|