@osdk/client 2.5.0-beta.7 → 2.5.0-beta.9
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 +22 -0
- package/build/browser/object/fetchPage.js +71 -25
- 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/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/util/UserAgent.js +2 -2
- package/build/cjs/{chunk-BY2PQEYA.cjs → chunk-HCCGD2AP.cjs} +54 -54
- package/build/cjs/{chunk-BY2PQEYA.cjs.map → chunk-HCCGD2AP.cjs.map} +1 -1
- package/build/cjs/{chunk-5KDG5ZET.cjs → chunk-MKL3HEQ5.cjs} +251 -210
- package/build/cjs/chunk-MKL3HEQ5.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 +126 -103
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/esm/object/fetchPage.js +71 -25
- 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/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/util/UserAgent.js +2 -2
- 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/package.json +7 -7
- package/build/cjs/chunk-5KDG5ZET.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) => {
|
|
@@ -599,9 +780,7 @@ function resolveInterfaceObjectSet(objectSet, interfaceTypeApiName, args) {
|
|
|
599
780
|
} : objectSet;
|
|
600
781
|
}
|
|
601
782
|
async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
602
|
-
const
|
|
603
|
-
osdkMetadata: void 0
|
|
604
|
-
}), await client.ontologyRid, applyFetchArgs(args, {
|
|
783
|
+
const requestBody = await applyFetchArgs(args, {
|
|
605
784
|
objectSet: {
|
|
606
785
|
type: "static",
|
|
607
786
|
objects: rids
|
|
@@ -609,7 +788,13 @@ async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
|
609
788
|
select: args?.$select ?? [],
|
|
610
789
|
excludeRid: !args?.$includeRid,
|
|
611
790
|
snapshot: useSnapshot
|
|
612
|
-
}
|
|
791
|
+
}, client, {
|
|
792
|
+
type: "object",
|
|
793
|
+
apiName: ""
|
|
794
|
+
});
|
|
795
|
+
const result = await OntologyObjectSet_exports.loadMultipleObjectTypes(addUserAgentAndRequestContextHeaders(client, {
|
|
796
|
+
osdkMetadata: void 0
|
|
797
|
+
}), await client.ontologyRid, requestBody, {
|
|
613
798
|
preview: true
|
|
614
799
|
});
|
|
615
800
|
return Promise.resolve({
|
|
@@ -620,14 +805,20 @@ async function fetchStaticRidPage(client, rids, args, useSnapshot = false) {
|
|
|
620
805
|
}
|
|
621
806
|
async function fetchInterfacePage(client, interfaceType, args, objectSet, useSnapshot = false) {
|
|
622
807
|
if (args.$__UNSTABLE_useOldInterfaceApis) {
|
|
623
|
-
const
|
|
808
|
+
const baseRequestBody = {
|
|
624
809
|
augmentedProperties: {},
|
|
625
810
|
augmentedSharedPropertyTypes: {},
|
|
626
811
|
otherInterfaceTypes: [],
|
|
627
812
|
selectedObjectTypes: [],
|
|
628
|
-
selectedSharedPropertyTypes: args.$select
|
|
813
|
+
selectedSharedPropertyTypes: args.$select ? [...args.$select] : [],
|
|
629
814
|
where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)
|
|
630
|
-
}
|
|
815
|
+
};
|
|
816
|
+
const requestBody2 = await applyFetchArgs(args, baseRequestBody, client, interfaceType);
|
|
817
|
+
if (requestBody2.selectedSharedPropertyTypes.length > 0) {
|
|
818
|
+
const remapped = remapPropertyNames(interfaceType, requestBody2.selectedSharedPropertyTypes);
|
|
819
|
+
requestBody2.selectedSharedPropertyTypes = Array.from(remapped);
|
|
820
|
+
}
|
|
821
|
+
const result2 = await OntologyInterface_exports.search(addUserAgentAndRequestContextHeaders(client, interfaceType), await client.ontologyRid, interfaceType.apiName, requestBody2, {
|
|
631
822
|
preview: true
|
|
632
823
|
});
|
|
633
824
|
result2.data = await client.objectFactory(
|
|
@@ -641,12 +832,13 @@ async function fetchInterfacePage(client, interfaceType, args, objectSet, useSna
|
|
|
641
832
|
return result2;
|
|
642
833
|
}
|
|
643
834
|
const resolvedInterfaceObjectSet = resolveInterfaceObjectSet(objectSet, interfaceType.apiName, args);
|
|
644
|
-
const
|
|
835
|
+
const requestBody = await buildAndRemapRequestBody(args, {
|
|
645
836
|
objectSet: resolvedInterfaceObjectSet,
|
|
646
|
-
select: args?.$select
|
|
837
|
+
select: args?.$select ? [...args.$select] : [],
|
|
647
838
|
excludeRid: !args?.$includeRid,
|
|
648
839
|
snapshot: useSnapshot
|
|
649
|
-
}
|
|
840
|
+
}, client, interfaceType);
|
|
841
|
+
const result = await OntologyObjectSet_exports.loadMultipleObjectTypes(addUserAgentAndRequestContextHeaders(client, interfaceType), await client.ontologyRid, requestBody, {
|
|
650
842
|
preview: true,
|
|
651
843
|
branch: client.branch
|
|
652
844
|
});
|
|
@@ -683,7 +875,31 @@ async function fetchPageWithErrorsInternal(client, objectType, objectSet, args =
|
|
|
683
875
|
async function fetchPage(client, objectType, args, objectSet = resolveBaseObjectSetType(objectType)) {
|
|
684
876
|
return fetchPageInternal(client, objectType, objectSet, args);
|
|
685
877
|
}
|
|
686
|
-
function
|
|
878
|
+
async function buildAndRemapRequestBody(args, baseBody, client, objectType) {
|
|
879
|
+
const requestBody = await applyFetchArgs(args, baseBody, client, objectType);
|
|
880
|
+
if (requestBody.select != null && requestBody.select.length > 0) {
|
|
881
|
+
const remapped = remapPropertyNames(objectType, requestBody.select);
|
|
882
|
+
return {
|
|
883
|
+
...requestBody,
|
|
884
|
+
select: remapped
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
return requestBody;
|
|
888
|
+
}
|
|
889
|
+
function remapPropertyNames(objectOrInterface, propertyNames) {
|
|
890
|
+
if (objectOrInterface == null) {
|
|
891
|
+
return propertyNames;
|
|
892
|
+
}
|
|
893
|
+
if (objectOrInterface.type === "interface") {
|
|
894
|
+
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
895
|
+
return propertyNames.map((name) => {
|
|
896
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(name);
|
|
897
|
+
return fieldApiNamespace == null && objApiNamespace != null ? `${objApiNamespace}.${fieldShortName}` : name;
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
return propertyNames;
|
|
901
|
+
}
|
|
902
|
+
async function applyFetchArgs(args, body, _client, objectType) {
|
|
687
903
|
if (args?.$nextPageToken) {
|
|
688
904
|
body.pageToken = args.$nextPageToken;
|
|
689
905
|
}
|
|
@@ -692,28 +908,34 @@ function applyFetchArgs(args, body) {
|
|
|
692
908
|
}
|
|
693
909
|
const orderBy = args?.$orderBy;
|
|
694
910
|
if (orderBy) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
911
|
+
if (orderBy === "relevance") {
|
|
912
|
+
body.orderBy = {
|
|
913
|
+
orderType: "relevance",
|
|
914
|
+
fields: []
|
|
915
|
+
};
|
|
916
|
+
} else {
|
|
917
|
+
const orderByEntries = Object.entries(orderBy);
|
|
918
|
+
const fieldNames = orderByEntries.map(([field]) => field);
|
|
919
|
+
const remappedFields = remapPropertyNames(objectType, fieldNames);
|
|
920
|
+
body.orderBy = {
|
|
921
|
+
fields: orderByEntries.map(([, direction], index) => ({
|
|
922
|
+
field: remappedFields[index],
|
|
923
|
+
direction
|
|
924
|
+
}))
|
|
925
|
+
};
|
|
926
|
+
}
|
|
704
927
|
}
|
|
705
928
|
return body;
|
|
706
929
|
}
|
|
707
930
|
async function fetchObjectPage(client, objectType, args, objectSet, useSnapshot = false) {
|
|
708
931
|
void client.ontologyProvider.getObjectDefinition(objectType.apiName);
|
|
709
|
-
const
|
|
932
|
+
const requestBody = await buildAndRemapRequestBody(args, {
|
|
710
933
|
objectSet,
|
|
711
|
-
|
|
712
|
-
select: args?.$select ?? [],
|
|
713
|
-
// FIXME?
|
|
934
|
+
select: args?.$select ? [...args.$select] : [],
|
|
714
935
|
excludeRid: !args?.$includeRid,
|
|
715
936
|
snapshot: useSnapshot
|
|
716
|
-
}
|
|
937
|
+
}, client, objectType);
|
|
938
|
+
const r = await OntologyObjectSet_exports.load(addUserAgentAndRequestContextHeaders(client, objectType), await client.ontologyRid, requestBody, {
|
|
717
939
|
branch: client.branch
|
|
718
940
|
});
|
|
719
941
|
return Promise.resolve({
|
|
@@ -839,187 +1061,6 @@ async function fetchSingleWithErrors(client, objectType, args, objectSet) {
|
|
|
839
1061
|
};
|
|
840
1062
|
}
|
|
841
1063
|
}
|
|
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
1064
|
function derivedPropertyDefinitionFactory(wireDefinition, definitionMap) {
|
|
1024
1065
|
const definition = {
|
|
1025
1066
|
abs() {
|
|
@@ -1956,5 +1997,5 @@ exports.hydrateAttachmentFromRidInternal = hydrateAttachmentFromRidInternal;
|
|
|
1956
1997
|
exports.isObjectSet = isObjectSet;
|
|
1957
1998
|
exports.isWireObjectSet = isWireObjectSet;
|
|
1958
1999
|
exports.symbolClientContext = symbolClientContext;
|
|
1959
|
-
//# sourceMappingURL=chunk-
|
|
1960
|
-
//# sourceMappingURL=chunk-
|
|
2000
|
+
//# sourceMappingURL=chunk-MKL3HEQ5.cjs.map
|
|
2001
|
+
//# sourceMappingURL=chunk-MKL3HEQ5.cjs.map
|