@osdk/client 0.20.0-beta.3 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -5
- package/build/{esm/chunk-JRG5V55N.js → browser/chunk-T5DZREKX.js} +557 -112
- package/build/browser/chunk-T5DZREKX.js.map +1 -0
- package/build/browser/index.js +4 -8
- package/build/browser/index.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +2 -2
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/cjs/{chunk-EP4KLU3N.cjs → chunk-VW7XYOFL.cjs} +556 -110
- package/build/cjs/chunk-VW7XYOFL.cjs.map +1 -0
- package/build/cjs/index.cjs +14 -11
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/esm/Client.d.ts +3 -2
- package/build/esm/Client.d.ts.map +1 -1
- package/build/esm/MinimalClientContext.d.ts +4 -0
- package/build/esm/MinimalClientContext.d.ts.map +1 -1
- package/build/esm/__unstable/UnstableClient.d.ts +1 -1
- package/build/esm/__unstable/UnstableClient.d.ts.map +1 -1
- package/build/esm/actions/applyAction.d.ts.map +1 -1
- package/build/{browser/chunk-M3BF5ESV.js → esm/chunk-T5DZREKX.js} +557 -109
- package/build/esm/chunk-T5DZREKX.js.map +1 -0
- package/build/esm/createClient.d.ts.map +1 -1
- package/build/esm/createMinimalClient.d.ts.map +1 -1
- package/build/esm/createPlatformClient.d.ts +4 -1
- package/build/esm/createPlatformClient.d.ts.map +1 -1
- package/build/esm/createTimeseriesProperty.d.ts +4 -0
- package/build/esm/createTimeseriesProperty.d.ts.map +1 -0
- package/build/esm/index.d.ts +6 -4
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +4 -8
- package/build/esm/index.js.map +1 -1
- package/build/esm/object/Cache.d.ts +1 -1
- package/build/esm/object/SimpleCache.d.ts +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/esm/object/fetchPage.d.ts.map +1 -1
- package/build/esm/object/timeseries.test.d.ts +2 -0
- package/build/esm/object/timeseries.test.d.ts.map +1 -0
- package/build/esm/objectSet/createObjectSet.d.ts.map +1 -1
- package/build/esm/ontology/OntologyProvider.d.ts +1 -1
- package/build/esm/ontology/OntologyProvider.d.ts.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.d.ts +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.d.ts.map +1 -1
- package/build/esm/ontology/loadInterfaceDefinition.d.ts +1 -1
- package/build/esm/ontology/loadInterfaceDefinition.d.ts.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +2 -2
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.d.ts +6 -0
- package/build/esm/queries/applyQuery.d.ts.map +1 -0
- package/build/esm/queries/createQueryInvoker.d.ts +5 -0
- package/build/esm/queries/createQueryInvoker.d.ts.map +1 -0
- package/build/esm/queries/queries.test.d.ts +2 -0
- package/build/esm/queries/queries.test.d.ts.map +1 -0
- package/build/esm/util/addUserAgentAndRequestContextHeaders.d.ts +4 -0
- package/build/esm/util/addUserAgentAndRequestContextHeaders.d.ts.map +1 -0
- package/build/esm/util/augmentRequestContext.d.ts +32 -0
- package/build/esm/util/augmentRequestContext.d.ts.map +1 -0
- package/build/esm/util/isOsdkBaseObject.d.ts +3 -0
- package/build/esm/util/isOsdkBaseObject.d.ts.map +1 -0
- package/build/esm/util/isOsdkObject.d.ts +3 -0
- package/build/esm/util/isOsdkObject.d.ts.map +1 -0
- package/build/esm/util/streamutils.d.ts +3 -0
- package/build/esm/util/streamutils.d.ts.map +1 -0
- package/build/esm/util/toDataValue.d.ts.map +1 -1
- package/build/esm/util/toDataValueQueries.d.ts +10 -0
- package/build/esm/util/toDataValueQueries.d.ts.map +1 -0
- package/package.json +22 -15
- package/build/browser/chunk-M3BF5ESV.js.map +0 -1
- package/build/cjs/chunk-EP4KLU3N.cjs.map +0 -1
- package/build/esm/chunk-JRG5V55N.js.map +0 -1
- package/build/esm/util/addUserAgent.d.ts +0 -4
- package/build/esm/util/addUserAgent.d.ts.map +0 -1
|
@@ -18,6 +18,14 @@ var __export = (target, all) => {
|
|
|
18
18
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// src/actions/ActionValidationError.ts
|
|
22
|
+
var ActionValidationError = class extends Error {
|
|
23
|
+
constructor(validation) {
|
|
24
|
+
super("Validation Error");
|
|
25
|
+
this.validation = validation;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
21
29
|
// ../internal.foundry.datasets/build/esm/chunk-PZ5AY32C.js
|
|
22
30
|
var __defProp2 = Object.defineProperty;
|
|
23
31
|
var __export2 = (target, all) => {
|
|
@@ -404,6 +412,7 @@ var esm_exports2 = {};
|
|
|
404
412
|
__export(esm_exports2, {
|
|
405
413
|
ActionTypesV2: () => ActionTypeV2_exports,
|
|
406
414
|
Actions: () => Action_exports,
|
|
415
|
+
Attachments: () => Attachment_exports2,
|
|
407
416
|
ObjectTypesV2: () => ObjectTypeV2_exports,
|
|
408
417
|
OntologiesV2: () => OntologyV2_exports,
|
|
409
418
|
OntologyObjectSets: () => OntologyObjectSet_exports,
|
|
@@ -420,6 +429,26 @@ var __export5 = (target, all) => {
|
|
|
420
429
|
});
|
|
421
430
|
};
|
|
422
431
|
|
|
432
|
+
// ../internal.foundry.ontologiesv2/build/esm/chunk-ASYINYCV.js
|
|
433
|
+
var QueryType_exports2 = {};
|
|
434
|
+
__export5(QueryType_exports2, {
|
|
435
|
+
executeQueryV2: () => executeQueryV2,
|
|
436
|
+
getQueryTypeV2: () => getQueryTypeV2,
|
|
437
|
+
listQueryTypesV2: () => listQueryTypesV2
|
|
438
|
+
});
|
|
439
|
+
var _listQueryTypesV2 = [0, "/v2/ontologies/{0}/queryTypes", 2];
|
|
440
|
+
function listQueryTypesV2($ctx, ...args) {
|
|
441
|
+
return foundryPlatformFetch($ctx, _listQueryTypesV2, ...args);
|
|
442
|
+
}
|
|
443
|
+
var _getQueryTypeV2 = [0, "/v2/ontologies/{0}/queryTypes/{1}"];
|
|
444
|
+
function getQueryTypeV2($ctx, ...args) {
|
|
445
|
+
return foundryPlatformFetch($ctx, _getQueryTypeV2, ...args);
|
|
446
|
+
}
|
|
447
|
+
var _executeQueryV2 = [1, "/v2/ontologies/{0}/queries/{1}/execute", 3];
|
|
448
|
+
function executeQueryV2($ctx, ...args) {
|
|
449
|
+
return foundryPlatformFetch($ctx, _executeQueryV2, ...args);
|
|
450
|
+
}
|
|
451
|
+
|
|
423
452
|
// ../internal.foundry.ontologiesv2/build/esm/chunk-B5JRDCDE.js
|
|
424
453
|
var Action_exports = {};
|
|
425
454
|
__export5(Action_exports, {
|
|
@@ -455,6 +484,26 @@ function getActionTypeV2($ctx, ...args) {
|
|
|
455
484
|
return foundryPlatformFetch($ctx, _getActionTypeV2, ...args);
|
|
456
485
|
}
|
|
457
486
|
|
|
487
|
+
// ../internal.foundry.ontologiesv2/build/esm/chunk-YGTQQ5D7.js
|
|
488
|
+
var Attachment_exports2 = {};
|
|
489
|
+
__export5(Attachment_exports2, {
|
|
490
|
+
getAttachmentContentV2: () => getAttachmentContentV2,
|
|
491
|
+
getAttachmentV2: () => getAttachmentV2,
|
|
492
|
+
uploadAttachmentV2: () => uploadAttachmentV2
|
|
493
|
+
});
|
|
494
|
+
var _uploadAttachmentV2 = [1, "/v2/ontologies/attachments/upload", 7, "*/*"];
|
|
495
|
+
function uploadAttachmentV2($ctx, ...args) {
|
|
496
|
+
return foundryPlatformFetch($ctx, _uploadAttachmentV2, ...args);
|
|
497
|
+
}
|
|
498
|
+
var _getAttachmentContentV2 = [0, "/v2/ontologies/attachments/{0}/content", , , "*/*"];
|
|
499
|
+
function getAttachmentContentV2($ctx, ...args) {
|
|
500
|
+
return foundryPlatformFetch($ctx, _getAttachmentContentV2, ...args);
|
|
501
|
+
}
|
|
502
|
+
var _getAttachmentV2 = [0, "/v2/ontologies/attachments/{0}"];
|
|
503
|
+
function getAttachmentV2($ctx, ...args) {
|
|
504
|
+
return foundryPlatformFetch($ctx, _getAttachmentV2, ...args);
|
|
505
|
+
}
|
|
506
|
+
|
|
458
507
|
// ../internal.foundry.ontologiesv2/build/esm/chunk-6LZM4EP4.js
|
|
459
508
|
var ObjectTypeV2_exports = {};
|
|
460
509
|
__export5(ObjectTypeV2_exports, {
|
|
@@ -505,16 +554,15 @@ function aggregateObjectSetV2($ctx, ...args) {
|
|
|
505
554
|
return foundryPlatformFetch($ctx, _aggregateObjectSetV2, ...args);
|
|
506
555
|
}
|
|
507
556
|
|
|
508
|
-
// ../internal.foundry.ontologiesv2/build/esm/chunk-
|
|
557
|
+
// ../internal.foundry.ontologiesv2/build/esm/chunk-KYMDEQ65.js
|
|
509
558
|
var OntologyObjectV2_exports = {};
|
|
510
559
|
__export5(OntologyObjectV2_exports, {
|
|
511
560
|
aggregateObjectsForInterface: () => aggregateObjectsForInterface,
|
|
512
561
|
aggregateObjectsV2: () => aggregateObjectsV2,
|
|
513
562
|
countObjects: () => countObjects,
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
getAttachmentsV2: () => getAttachmentsV2,
|
|
563
|
+
getAttachmentPropertyByRidV2: () => getAttachmentPropertyByRidV2,
|
|
564
|
+
getAttachmentPropertyContentByRidV2: () => getAttachmentPropertyContentByRidV2,
|
|
565
|
+
getAttachmentPropertyContentV2: () => getAttachmentPropertyContentV2,
|
|
518
566
|
getFirstPoint: () => getFirstPoint,
|
|
519
567
|
getInterfaceType: () => getInterfaceType,
|
|
520
568
|
getLastPoint: () => getLastPoint,
|
|
@@ -524,6 +572,7 @@ __export5(OntologyObjectV2_exports, {
|
|
|
524
572
|
listInterfaceTypes: () => listInterfaceTypes,
|
|
525
573
|
listLinkedObjectsV2: () => listLinkedObjectsV2,
|
|
526
574
|
listObjectsV2: () => listObjectsV2,
|
|
575
|
+
listPropertyAttachments: () => listPropertyAttachments,
|
|
527
576
|
searchObjectsForInterface: () => searchObjectsForInterface,
|
|
528
577
|
searchObjectsV2: () => searchObjectsV2,
|
|
529
578
|
streamPoints: () => streamPoints
|
|
@@ -572,21 +621,21 @@ var _getLinkedObjectV2 = [0, "/v2/ontologies/{0}/objects/{1}/{2}/links/{3}/{4}",
|
|
|
572
621
|
function getLinkedObjectV2($ctx, ...args) {
|
|
573
622
|
return foundryPlatformFetch($ctx, _getLinkedObjectV2, ...args);
|
|
574
623
|
}
|
|
575
|
-
var
|
|
576
|
-
function
|
|
577
|
-
return foundryPlatformFetch($ctx,
|
|
624
|
+
var _listPropertyAttachments = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}", 2];
|
|
625
|
+
function listPropertyAttachments($ctx, ...args) {
|
|
626
|
+
return foundryPlatformFetch($ctx, _listPropertyAttachments, ...args);
|
|
578
627
|
}
|
|
579
|
-
var
|
|
580
|
-
function
|
|
581
|
-
return foundryPlatformFetch($ctx,
|
|
628
|
+
var _getAttachmentPropertyByRidV2 = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}", 2];
|
|
629
|
+
function getAttachmentPropertyByRidV2($ctx, ...args) {
|
|
630
|
+
return foundryPlatformFetch($ctx, _getAttachmentPropertyByRidV2, ...args);
|
|
582
631
|
}
|
|
583
|
-
var
|
|
584
|
-
function
|
|
585
|
-
return foundryPlatformFetch($ctx,
|
|
632
|
+
var _getAttachmentPropertyContentV2 = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/content", 2, , "*/*"];
|
|
633
|
+
function getAttachmentPropertyContentV2($ctx, ...args) {
|
|
634
|
+
return foundryPlatformFetch($ctx, _getAttachmentPropertyContentV2, ...args);
|
|
586
635
|
}
|
|
587
|
-
var
|
|
588
|
-
function
|
|
589
|
-
return foundryPlatformFetch($ctx,
|
|
636
|
+
var _getAttachmentPropertyContentByRidV2 = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}/content", 2, , "*/*"];
|
|
637
|
+
function getAttachmentPropertyContentByRidV2($ctx, ...args) {
|
|
638
|
+
return foundryPlatformFetch($ctx, _getAttachmentPropertyContentByRidV2, ...args);
|
|
590
639
|
}
|
|
591
640
|
var _getFirstPoint = [0, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/firstPoint", 2];
|
|
592
641
|
function getFirstPoint($ctx, ...args) {
|
|
@@ -625,26 +674,6 @@ function getOntologyFullMetadata($ctx, ...args) {
|
|
|
625
674
|
return foundryPlatformFetch($ctx, _getOntologyFullMetadata, ...args);
|
|
626
675
|
}
|
|
627
676
|
|
|
628
|
-
// ../internal.foundry.ontologiesv2/build/esm/chunk-ASYINYCV.js
|
|
629
|
-
var QueryType_exports2 = {};
|
|
630
|
-
__export5(QueryType_exports2, {
|
|
631
|
-
executeQueryV2: () => executeQueryV2,
|
|
632
|
-
getQueryTypeV2: () => getQueryTypeV2,
|
|
633
|
-
listQueryTypesV2: () => listQueryTypesV2
|
|
634
|
-
});
|
|
635
|
-
var _listQueryTypesV2 = [0, "/v2/ontologies/{0}/queryTypes", 2];
|
|
636
|
-
function listQueryTypesV2($ctx, ...args) {
|
|
637
|
-
return foundryPlatformFetch($ctx, _listQueryTypesV2, ...args);
|
|
638
|
-
}
|
|
639
|
-
var _getQueryTypeV2 = [0, "/v2/ontologies/{0}/queryTypes/{1}"];
|
|
640
|
-
function getQueryTypeV2($ctx, ...args) {
|
|
641
|
-
return foundryPlatformFetch($ctx, _getQueryTypeV2, ...args);
|
|
642
|
-
}
|
|
643
|
-
var _executeQueryV2 = [1, "/v2/ontologies/{0}/queries/{1}/execute", 3];
|
|
644
|
-
function executeQueryV2($ctx, ...args) {
|
|
645
|
-
return foundryPlatformFetch($ctx, _executeQueryV2, ...args);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
677
|
// src/createAttachmentFromRid.ts
|
|
649
678
|
function createAttachmentFromRid(client, rid) {
|
|
650
679
|
return {
|
|
@@ -657,17 +686,165 @@ function createAttachmentFromRid(client, rid) {
|
|
|
657
686
|
}
|
|
658
687
|
};
|
|
659
688
|
}
|
|
660
|
-
|
|
661
|
-
|
|
689
|
+
|
|
690
|
+
// src/object/AttachmentUpload.ts
|
|
691
|
+
function isAttachmentUpload(o) {
|
|
692
|
+
return o instanceof Blob && "name" in o;
|
|
693
|
+
}
|
|
694
|
+
function createAttachmentUpload(data, name) {
|
|
695
|
+
const attachmentUpload = Object.create(data, {
|
|
696
|
+
name: {
|
|
697
|
+
value: name
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
return attachmentUpload;
|
|
701
|
+
}
|
|
702
|
+
var addUserAgentAndRequestContextHeaders = (client, withMetadata) => ({
|
|
703
|
+
...client,
|
|
704
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client.fetch, (headers) => {
|
|
705
|
+
headers.set("X-OSDK-Request-Context", JSON.stringify(client.requestContext));
|
|
706
|
+
if (withMetadata.osdkMetadata) {
|
|
707
|
+
headers.set("Fetch-User-Agent", withMetadata.osdkMetadata.extraUserAgent);
|
|
708
|
+
}
|
|
709
|
+
return headers;
|
|
710
|
+
})
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
// src/util/streamutils.ts
|
|
714
|
+
var START_TOKEN = new Uint8Array([123, 34, 100, 97, 116, 97, 34, 58, 91]);
|
|
715
|
+
var OBJECT_OPEN_CHAR_CODE = 123;
|
|
716
|
+
var OBJECT_CLOSE_CHAR_CODE = 125;
|
|
717
|
+
async function* parseStreamedResponse(asyncIterable) {
|
|
718
|
+
const utf8decoder = new TextDecoder("utf-8");
|
|
719
|
+
let parsedStart = false;
|
|
720
|
+
let prevChunks = [];
|
|
721
|
+
let openBracesCount = 0;
|
|
722
|
+
for await (let chunk of asyncIterable) {
|
|
723
|
+
let i = 0;
|
|
724
|
+
if (!parsedStart) {
|
|
725
|
+
parsedStart = true;
|
|
726
|
+
if (startsWith(chunk, START_TOKEN)) {
|
|
727
|
+
i = START_TOKEN.length;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
for (; i < chunk.length; i++) {
|
|
731
|
+
while (openBracesCount === 0 && chunk[i] !== OBJECT_OPEN_CHAR_CODE && i < chunk.length) {
|
|
732
|
+
i++;
|
|
733
|
+
}
|
|
734
|
+
let j = i;
|
|
735
|
+
for (; j < chunk.length; j++) {
|
|
736
|
+
const c = chunk[j];
|
|
737
|
+
if (c === OBJECT_OPEN_CHAR_CODE) {
|
|
738
|
+
openBracesCount++;
|
|
739
|
+
} else if (c === OBJECT_CLOSE_CHAR_CODE) {
|
|
740
|
+
openBracesCount--;
|
|
741
|
+
if (0 === openBracesCount) {
|
|
742
|
+
yield combineAndParse(utf8decoder, prevChunks, chunk.subarray(i, j + 1));
|
|
743
|
+
prevChunks = [];
|
|
744
|
+
i = j;
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (j === chunk.length) {
|
|
750
|
+
prevChunks.push(chunk.subarray(i));
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function startsWith(a, b) {
|
|
757
|
+
if (a.length < b.length) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
for (let i = 0; i < b.length; i++) {
|
|
761
|
+
if (a[i] !== b[i]) {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
function combineAndParse(utf8decoder, prev, curr) {
|
|
768
|
+
let str = "";
|
|
769
|
+
for (const chunk of prev) {
|
|
770
|
+
str += utf8decoder.decode(chunk, {
|
|
771
|
+
stream: true
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
str += utf8decoder.decode(curr);
|
|
775
|
+
return JSON.parse(str);
|
|
776
|
+
}
|
|
777
|
+
async function* iterateReadableStream(readableStream) {
|
|
778
|
+
let res = await readableStream.read();
|
|
779
|
+
while (!res.done) {
|
|
780
|
+
yield res.value;
|
|
781
|
+
res = await readableStream.read();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/createTimeseriesProperty.ts
|
|
786
|
+
function createTimeseriesProperty(client, objectApiName, primaryKey, propertyName) {
|
|
787
|
+
return {
|
|
788
|
+
async getFirstPoint() {
|
|
789
|
+
return esm_exports2.OntologyObjectsV2.getFirstPoint(client, await client.ontologyRid, objectApiName, primaryKey, propertyName);
|
|
790
|
+
},
|
|
791
|
+
async getLastPoint() {
|
|
792
|
+
return esm_exports2.OntologyObjectsV2.getLastPoint(client, await client.ontologyRid, objectApiName, primaryKey, propertyName);
|
|
793
|
+
},
|
|
794
|
+
async getAllPoints(query) {
|
|
795
|
+
return getAllTimeSeriesPoints(client, objectApiName, primaryKey, propertyName, query);
|
|
796
|
+
},
|
|
797
|
+
asyncIterPoints(query) {
|
|
798
|
+
return iterateTimeSeriesPoints(client, objectApiName, primaryKey, propertyName, query);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
async function getAllTimeSeriesPoints(client, objectApiName, primaryKey, propertyName, body) {
|
|
803
|
+
const allPoints = [];
|
|
804
|
+
for await (const point of iterateTimeSeriesPoints(client, objectApiName, primaryKey, propertyName, body)) {
|
|
805
|
+
allPoints.push({
|
|
806
|
+
time: point.time,
|
|
807
|
+
value: point.value
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return allPoints;
|
|
811
|
+
}
|
|
812
|
+
async function* iterateTimeSeriesPoints(client, objectApiName, primaryKey, propertyName, body) {
|
|
813
|
+
new TextDecoder("utf-8");
|
|
814
|
+
const streamPointsIterator = await esm_exports2.OntologyObjectsV2.streamPoints(client, await client.ontologyRid, objectApiName, primaryKey, propertyName, body ? {
|
|
815
|
+
range: getTimeRange(body)
|
|
816
|
+
} : {});
|
|
817
|
+
const reader = streamPointsIterator.stream().getReader();
|
|
818
|
+
for await (const point of parseStreamedResponse(iterateReadableStream(reader))) {
|
|
819
|
+
yield {
|
|
820
|
+
time: point.time,
|
|
821
|
+
value: point.value
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
function getTimeRange(body) {
|
|
826
|
+
if ("$startTime" in body || "$endTime" in body) {
|
|
662
827
|
return {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
return headers;
|
|
667
|
-
})
|
|
828
|
+
type: "absolute",
|
|
829
|
+
startTime: body.$startTime,
|
|
830
|
+
endTime: body.$endTime
|
|
668
831
|
};
|
|
669
832
|
}
|
|
670
|
-
return
|
|
833
|
+
return body.$before ? {
|
|
834
|
+
type: "relative",
|
|
835
|
+
startTime: {
|
|
836
|
+
when: "BEFORE",
|
|
837
|
+
value: body.$before,
|
|
838
|
+
unit: client_api.TimeseriesDurationMapping[body.$unit]
|
|
839
|
+
}
|
|
840
|
+
} : {
|
|
841
|
+
type: "relative",
|
|
842
|
+
endTime: {
|
|
843
|
+
when: "AFTER",
|
|
844
|
+
value: body.$after,
|
|
845
|
+
unit: client_api.TimeseriesDurationMapping[body.$unit]
|
|
846
|
+
}
|
|
847
|
+
};
|
|
671
848
|
}
|
|
672
849
|
|
|
673
850
|
// src/object/Cache.ts
|
|
@@ -784,34 +961,6 @@ var InterfaceDefRef = Symbol(process.env.MODE !== "production" ? "InterfaceDefin
|
|
|
784
961
|
var RawObject = Symbol(process.env.MODE !== "production" ? "RawObject" : void 0);
|
|
785
962
|
var ClientRef = Symbol(process.env.MODE !== "production" ? "ClientRef" : void 0);
|
|
786
963
|
|
|
787
|
-
// src/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.ts
|
|
788
|
-
var OsdkCustomInspectPrototype = Object.create(null, {
|
|
789
|
-
[Symbol.for("nodejs.util.inspect.custom")]: {
|
|
790
|
-
value: customInspect
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
function customInspect(_depth, options, localInspect) {
|
|
794
|
-
const newOptions = {
|
|
795
|
-
...options,
|
|
796
|
-
depth: options.depth == null ? null : options.depth - 1
|
|
797
|
-
};
|
|
798
|
-
let ret = `Osdk<${options.stylize(this[ObjectDefRef]?.apiName ?? this[InterfaceDefRef]?.apiName, "special")}> {
|
|
799
|
-
`;
|
|
800
|
-
for (const k of /* @__PURE__ */ new Set(["$apiName", "$objectType", "$primaryKey", ...Reflect.ownKeys(this)])) {
|
|
801
|
-
if (typeof k === "symbol") continue;
|
|
802
|
-
ret += ` ${options.stylize(k.toString(), "undefined")}: ${localInspect(this[k], newOptions)}
|
|
803
|
-
`;
|
|
804
|
-
}
|
|
805
|
-
if (this[UnderlyingOsdkObject] !== this) {
|
|
806
|
-
ret += "\n";
|
|
807
|
-
ret += ` ${options.stylize("$as", "special")}: ${localInspect(this[UnderlyingOsdkObject], newOptions).replace(/\n/g, `
|
|
808
|
-
`)}`;
|
|
809
|
-
ret += "\n";
|
|
810
|
-
}
|
|
811
|
-
ret += "}";
|
|
812
|
-
return ret;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
964
|
// src/object/convertWireToOsdkObjects/createOsdkInterface.ts
|
|
816
965
|
var handlerCache = createSimpleCache(/* @__PURE__ */ new WeakMap(), createInterfaceProxyHandler);
|
|
817
966
|
function createOsdkInterface(underlying, interfaceDef) {
|
|
@@ -819,9 +968,6 @@ function createOsdkInterface(underlying, interfaceDef) {
|
|
|
819
968
|
[UnderlyingOsdkObject]: underlying,
|
|
820
969
|
[InterfaceDefRef]: interfaceDef
|
|
821
970
|
};
|
|
822
|
-
{
|
|
823
|
-
Object.setPrototypeOf(interfaceHolder, OsdkCustomInspectPrototype);
|
|
824
|
-
}
|
|
825
971
|
const handler = handlerCache.get(interfaceDef);
|
|
826
972
|
const proxy = new Proxy(
|
|
827
973
|
interfaceHolder,
|
|
@@ -1133,7 +1279,7 @@ async function aggregate(clientCtx, objectType, objectSet = {
|
|
|
1133
1279
|
if (req.$where) {
|
|
1134
1280
|
body.where = modernToLegacyWhereClause(req.$where);
|
|
1135
1281
|
}
|
|
1136
|
-
const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(
|
|
1282
|
+
const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {
|
|
1137
1283
|
objectSet,
|
|
1138
1284
|
groupBy: body.groupBy,
|
|
1139
1285
|
aggregation: body.aggregation
|
|
@@ -1191,6 +1337,15 @@ async function fetchSingleWithErrors(client, objectType, args, objectSet) {
|
|
|
1191
1337
|
}
|
|
1192
1338
|
}
|
|
1193
1339
|
|
|
1340
|
+
// src/util/augmentRequestContext.ts
|
|
1341
|
+
var augmentRequestContext = (client, augment2) => ({
|
|
1342
|
+
...client,
|
|
1343
|
+
requestContext: {
|
|
1344
|
+
...client.requestContext,
|
|
1345
|
+
...augment2(client.requestContext)
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
|
|
1194
1349
|
// src/util/WireObjectSet.ts
|
|
1195
1350
|
var WIRE_OBJECT_SET_TYPES = /* @__PURE__ */ new Set(["base", "filter", "intersect", "reference", "searchAround", "static", "subtract", "union"]);
|
|
1196
1351
|
function isWireObjectSet(o) {
|
|
@@ -1213,9 +1368,15 @@ function createObjectSet(objectType, clientCtx, objectSet = {
|
|
|
1213
1368
|
objectType: objectType["apiName"]
|
|
1214
1369
|
}) {
|
|
1215
1370
|
const base = {
|
|
1216
|
-
aggregate: aggregate.bind(globalThis, clientCtx,
|
|
1217
|
-
|
|
1218
|
-
|
|
1371
|
+
aggregate: aggregate.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
|
|
1372
|
+
finalMethodCall: "aggregate"
|
|
1373
|
+
})), objectType, objectSet),
|
|
1374
|
+
fetchPage: fetchPageInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
|
|
1375
|
+
finalMethodCall: "fetchPage"
|
|
1376
|
+
})), objectType, objectSet),
|
|
1377
|
+
fetchPageWithErrors: fetchPageWithErrorsInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
|
|
1378
|
+
finalMethodCall: "fetchPageWithErrors"
|
|
1379
|
+
})), objectType, objectSet),
|
|
1219
1380
|
where: (clause) => {
|
|
1220
1381
|
return clientCtx.objectSetFactory(objectType, clientCtx, {
|
|
1221
1382
|
type: "filter",
|
|
@@ -1247,9 +1408,12 @@ function createObjectSet(objectType, clientCtx, objectSet = {
|
|
|
1247
1408
|
asyncIter: async function* () {
|
|
1248
1409
|
let $nextPageToken = void 0;
|
|
1249
1410
|
do {
|
|
1250
|
-
const result = await
|
|
1411
|
+
const result = await fetchPageInternal(augmentRequestContext(clientCtx, (_) => ({
|
|
1412
|
+
finalMethodCall: "asyncIter"
|
|
1413
|
+
})), objectType, objectSet, {
|
|
1251
1414
|
$nextPageToken
|
|
1252
1415
|
});
|
|
1416
|
+
$nextPageToken = result.nextPageToken;
|
|
1253
1417
|
for (const obj of result.data) {
|
|
1254
1418
|
yield obj;
|
|
1255
1419
|
}
|
|
@@ -1265,7 +1429,9 @@ function createObjectSet(objectType, clientCtx, objectSet = {
|
|
|
1265
1429
|
value: primaryKey
|
|
1266
1430
|
}
|
|
1267
1431
|
};
|
|
1268
|
-
return await fetchSingle(clientCtx,
|
|
1432
|
+
return await fetchSingle(augmentRequestContext(clientCtx, (_) => ({
|
|
1433
|
+
finalMethodCall: "fetchOne"
|
|
1434
|
+
})), objectType, options, withPk);
|
|
1269
1435
|
} : void 0,
|
|
1270
1436
|
fetchOneWithErrors: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
1271
1437
|
const withPk = {
|
|
@@ -1277,7 +1443,9 @@ function createObjectSet(objectType, clientCtx, objectSet = {
|
|
|
1277
1443
|
value: primaryKey
|
|
1278
1444
|
}
|
|
1279
1445
|
};
|
|
1280
|
-
return await fetchSingleWithErrors(clientCtx,
|
|
1446
|
+
return await fetchSingleWithErrors(augmentRequestContext(clientCtx, (_) => ({
|
|
1447
|
+
finalMethodCall: "fetchOneWithErrors"
|
|
1448
|
+
})), objectType, options, withPk);
|
|
1281
1449
|
} : void 0
|
|
1282
1450
|
};
|
|
1283
1451
|
function createSearchAround(link) {
|
|
@@ -1337,7 +1505,7 @@ var DollarLinkProxyHandler = {
|
|
|
1337
1505
|
|
|
1338
1506
|
// src/object/convertWireToOsdkObjects/createOsdkObject.ts
|
|
1339
1507
|
var objectPrototypeCache = createClientCache(function(client, objectDef) {
|
|
1340
|
-
return Object.create(
|
|
1508
|
+
return Object.create(null, {
|
|
1341
1509
|
[ObjectDefRef]: {
|
|
1342
1510
|
value: objectDef
|
|
1343
1511
|
},
|
|
@@ -1388,6 +1556,9 @@ function createOsdkObject(client, objectDef, rawObj) {
|
|
|
1388
1556
|
}
|
|
1389
1557
|
return createAttachmentFromRid(client, rawValue.rid);
|
|
1390
1558
|
}
|
|
1559
|
+
if (propDef.type === "numericTimeseries" || propDef.type === "stringTimeseries") {
|
|
1560
|
+
return createTimeseriesProperty(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);
|
|
1561
|
+
}
|
|
1391
1562
|
}
|
|
1392
1563
|
return rawValue;
|
|
1393
1564
|
}
|
|
@@ -1537,7 +1708,7 @@ function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = voi
|
|
|
1537
1708
|
throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
|
|
1538
1709
|
}
|
|
1539
1710
|
async function fetchInterfacePage(client, interfaceType, args, objectSet) {
|
|
1540
|
-
const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(
|
|
1711
|
+
const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(addUserAgentAndRequestContextHeaders(client, interfaceType), await client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
|
|
1541
1712
|
augmentedProperties: args.$augment ?? {},
|
|
1542
1713
|
augmentedSharedPropertyTypes: {},
|
|
1543
1714
|
otherInterfaceTypes: [],
|
|
@@ -1604,9 +1775,9 @@ function applyFetchArgs(args, body) {
|
|
|
1604
1775
|
return body;
|
|
1605
1776
|
}
|
|
1606
1777
|
async function fetchObjectPage(client, objectType, args, objectSet) {
|
|
1607
|
-
const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(
|
|
1778
|
+
const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgentAndRequestContextHeaders(client, objectType), await client.ontologyRid, applyFetchArgs(args, {
|
|
1608
1779
|
objectSet,
|
|
1609
|
-
// We have to do the following case because LoadObjectSetRequestV2
|
|
1780
|
+
// We have to do the following case because LoadObjectSetRequestV2 isn't readonly
|
|
1610
1781
|
select: args?.$select ?? [],
|
|
1611
1782
|
// FIXME?
|
|
1612
1783
|
excludeRid: !args?.$includeRid
|
|
@@ -1617,24 +1788,16 @@ async function fetchObjectPage(client, objectType, args, objectSet) {
|
|
|
1617
1788
|
});
|
|
1618
1789
|
}
|
|
1619
1790
|
|
|
1620
|
-
// src/actions/ActionValidationError.ts
|
|
1621
|
-
var ActionValidationError = class extends Error {
|
|
1622
|
-
constructor(validation) {
|
|
1623
|
-
super("Validation Error");
|
|
1624
|
-
this.validation = validation;
|
|
1625
|
-
}
|
|
1626
|
-
};
|
|
1627
|
-
|
|
1628
|
-
// src/object/AttachmentUpload.ts
|
|
1629
|
-
function isAttachmentUpload(o) {
|
|
1630
|
-
return o instanceof Blob && "name" in o;
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
1791
|
// src/util/isOntologyObjectV2.ts
|
|
1634
1792
|
function isOntologyObjectV2(o) {
|
|
1635
1793
|
return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
|
|
1636
1794
|
}
|
|
1637
1795
|
|
|
1796
|
+
// src/util/isOsdkObject.ts
|
|
1797
|
+
function isOsdkBaseObject(o) {
|
|
1798
|
+
return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1638
1801
|
// src/util/toDataValue.ts
|
|
1639
1802
|
async function toDataValue(value, client) {
|
|
1640
1803
|
if (value == null) {
|
|
@@ -1656,6 +1819,9 @@ async function toDataValue(value, client) {
|
|
|
1656
1819
|
if (isOntologyObjectV2(value)) {
|
|
1657
1820
|
return await toDataValue(value.__primaryKey, client);
|
|
1658
1821
|
}
|
|
1822
|
+
if (isOsdkBaseObject(value)) {
|
|
1823
|
+
return await toDataValue(value.$primaryKey, client);
|
|
1824
|
+
}
|
|
1659
1825
|
if (isWireObjectSet(value)) {
|
|
1660
1826
|
return value;
|
|
1661
1827
|
}
|
|
@@ -1674,8 +1840,11 @@ async function toDataValue(value, client) {
|
|
|
1674
1840
|
|
|
1675
1841
|
// src/actions/applyAction.ts
|
|
1676
1842
|
async function applyAction2(client, action, parameters, options = {}) {
|
|
1843
|
+
const clientWithHeaders = addUserAgentAndRequestContextHeaders(augmentRequestContext(client, (_) => ({
|
|
1844
|
+
finalMethodCall: "applyAction"
|
|
1845
|
+
})), action);
|
|
1677
1846
|
if (Array.isArray(parameters)) {
|
|
1678
|
-
const response = await esm_exports2.Actions.applyActionBatchV2(
|
|
1847
|
+
const response = await esm_exports2.Actions.applyActionBatchV2(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
1679
1848
|
requests: parameters ? await remapBatchActionParams(parameters, client) : [],
|
|
1680
1849
|
options: {
|
|
1681
1850
|
returnEdits: options?.$returnEdits ? "ALL" : "NONE"
|
|
@@ -1683,7 +1852,7 @@ async function applyAction2(client, action, parameters, options = {}) {
|
|
|
1683
1852
|
});
|
|
1684
1853
|
return options?.$returnEdits ? response.edits : void 0;
|
|
1685
1854
|
} else {
|
|
1686
|
-
const response = await esm_exports2.Actions.applyActionV2(
|
|
1855
|
+
const response = await esm_exports2.Actions.applyActionV2(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
1687
1856
|
parameters: await remapActionParams(parameters, client),
|
|
1688
1857
|
options: {
|
|
1689
1858
|
mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
|
|
@@ -1717,19 +1886,19 @@ async function remapBatchActionParams(params, client) {
|
|
|
1717
1886
|
}));
|
|
1718
1887
|
return remappedParams;
|
|
1719
1888
|
}
|
|
1720
|
-
async function loadFullObjectMetadata(client,
|
|
1721
|
-
const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid,
|
|
1889
|
+
async function loadFullObjectMetadata(client, objectType) {
|
|
1890
|
+
const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid, objectType, {
|
|
1722
1891
|
preview: true
|
|
1723
1892
|
});
|
|
1724
1893
|
const ret = generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
|
|
1725
|
-
client.logger?.debug(`END loadFullObjectMetadata(${
|
|
1894
|
+
client.logger?.debug(`END loadFullObjectMetadata(${objectType})`);
|
|
1726
1895
|
return {
|
|
1727
1896
|
...ret,
|
|
1728
1897
|
rid: full.objectType.rid
|
|
1729
1898
|
};
|
|
1730
1899
|
}
|
|
1731
|
-
async function loadInterfaceDefinition(client,
|
|
1732
|
-
const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid,
|
|
1900
|
+
async function loadInterfaceDefinition(client, objectType) {
|
|
1901
|
+
const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid, objectType, {
|
|
1733
1902
|
preview: true
|
|
1734
1903
|
});
|
|
1735
1904
|
return generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
|
|
@@ -1770,7 +1939,7 @@ var createStandardOntologyProviderFactory = (client) => {
|
|
|
1770
1939
|
};
|
|
1771
1940
|
|
|
1772
1941
|
// src/util/UserAgent.ts
|
|
1773
|
-
var USER_AGENT = `osdk-client/${"0.20.0
|
|
1942
|
+
var USER_AGENT = `osdk-client/${"0.20.0"}`;
|
|
1774
1943
|
|
|
1775
1944
|
// src/createMinimalClient.ts
|
|
1776
1945
|
function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
|
|
@@ -1787,13 +1956,287 @@ function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fet
|
|
|
1787
1956
|
objectSetFactory,
|
|
1788
1957
|
ontologyRid: metadata.ontologyRid,
|
|
1789
1958
|
logger: options.logger,
|
|
1790
|
-
clientCacheKey: {}
|
|
1959
|
+
clientCacheKey: {},
|
|
1960
|
+
requestContext: {}
|
|
1791
1961
|
};
|
|
1792
1962
|
return Object.assign(minimalClient, {
|
|
1793
1963
|
ontologyProvider: createStandardOntologyProviderFactory()(minimalClient)
|
|
1794
1964
|
});
|
|
1795
1965
|
}
|
|
1796
1966
|
|
|
1967
|
+
// src/util/isOsdkBaseObject.ts
|
|
1968
|
+
function isOsdkBaseObject2(o) {
|
|
1969
|
+
return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// src/util/toDataValueQueries.ts
|
|
1973
|
+
async function toDataValueQueries(value, client, desiredType) {
|
|
1974
|
+
if (value == null) {
|
|
1975
|
+
return value;
|
|
1976
|
+
}
|
|
1977
|
+
if (Array.isArray(value) && desiredType.multiplicity) {
|
|
1978
|
+
const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType));
|
|
1979
|
+
return Promise.all(promiseArray);
|
|
1980
|
+
}
|
|
1981
|
+
switch (desiredType.type) {
|
|
1982
|
+
case "attachment": {
|
|
1983
|
+
if (isAttachmentUpload(value)) {
|
|
1984
|
+
const attachment = await esm_exports.Attachments.uploadAttachment(client, value, {
|
|
1985
|
+
filename: value.name
|
|
1986
|
+
}, {
|
|
1987
|
+
"Content-Length": value.size.toString(),
|
|
1988
|
+
"Content-Type": value.type
|
|
1989
|
+
});
|
|
1990
|
+
return attachment.rid;
|
|
1991
|
+
}
|
|
1992
|
+
return value;
|
|
1993
|
+
}
|
|
1994
|
+
case "twoDimensionalAggregation": {
|
|
1995
|
+
return {
|
|
1996
|
+
groups: value
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
case "threeDimensionalAggregation": {
|
|
2000
|
+
return {
|
|
2001
|
+
groups: value
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
case "set": {
|
|
2005
|
+
if (value instanceof Set) {
|
|
2006
|
+
const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType["set"]));
|
|
2007
|
+
return Promise.all(promiseArray);
|
|
2008
|
+
}
|
|
2009
|
+
break;
|
|
2010
|
+
}
|
|
2011
|
+
case "object": {
|
|
2012
|
+
if (isOsdkBaseObject2(value)) {
|
|
2013
|
+
return value.$primaryKey;
|
|
2014
|
+
}
|
|
2015
|
+
break;
|
|
2016
|
+
}
|
|
2017
|
+
case "objectSet": {
|
|
2018
|
+
if (isWireObjectSet(value)) {
|
|
2019
|
+
return value;
|
|
2020
|
+
}
|
|
2021
|
+
if (isObjectSet(value)) {
|
|
2022
|
+
return getWireObjectSet(value);
|
|
2023
|
+
}
|
|
2024
|
+
break;
|
|
2025
|
+
}
|
|
2026
|
+
case "struct": {
|
|
2027
|
+
if (typeof value === "object") {
|
|
2028
|
+
const structMap = {};
|
|
2029
|
+
for (const [key, structValue] of Object.entries(value)) {
|
|
2030
|
+
structMap[key] = await toDataValueQueries(structValue, client, desiredType["struct"][key]);
|
|
2031
|
+
}
|
|
2032
|
+
return structMap;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
case "boolean":
|
|
2036
|
+
case "date":
|
|
2037
|
+
case "double":
|
|
2038
|
+
case "float":
|
|
2039
|
+
case "integer":
|
|
2040
|
+
case "long":
|
|
2041
|
+
case "string":
|
|
2042
|
+
case "timestamp":
|
|
2043
|
+
return value;
|
|
2044
|
+
}
|
|
2045
|
+
return value;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
// src/queries/applyQuery.ts
|
|
2049
|
+
async function applyQuery(client, query, params) {
|
|
2050
|
+
const response = await esm_exports2.QueryTypes.executeQueryV2(addUserAgentAndRequestContextHeaders(augmentRequestContext(client, (_) => ({
|
|
2051
|
+
finalMethodCall: "applyQuery"
|
|
2052
|
+
})), query), await client.ontologyRid, query.apiName, {
|
|
2053
|
+
parameters: params ? await remapQueryParams(params, client, query.parameters) : {}
|
|
2054
|
+
});
|
|
2055
|
+
const objectOutputDefs = await getRequiredDefinitions(query.output, client);
|
|
2056
|
+
const remappedResponse = await remapQueryResponse(client, query.output, response.value, objectOutputDefs);
|
|
2057
|
+
return remappedResponse;
|
|
2058
|
+
}
|
|
2059
|
+
async function remapQueryParams(params, client, paramTypes) {
|
|
2060
|
+
const parameterMap = {};
|
|
2061
|
+
for (const [key, value] of Object.entries(params)) {
|
|
2062
|
+
parameterMap[key] = await toDataValueQueries(value, client, paramTypes[key]);
|
|
2063
|
+
}
|
|
2064
|
+
return parameterMap;
|
|
2065
|
+
}
|
|
2066
|
+
async function remapQueryResponse(client, responseDataType, responseValue, definitions) {
|
|
2067
|
+
if (responseValue == null) {
|
|
2068
|
+
if (responseDataType.nullable) {
|
|
2069
|
+
return void 0;
|
|
2070
|
+
} else {
|
|
2071
|
+
throw new Error("Got null response when nullable was not allowed");
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
if (responseDataType.multiplicity != null && responseDataType.multiplicity !== false) {
|
|
2075
|
+
const withoutMultiplicity = {
|
|
2076
|
+
...responseDataType,
|
|
2077
|
+
multiplicity: false
|
|
2078
|
+
};
|
|
2079
|
+
for (let i = 0; i < responseValue.length; i++) {
|
|
2080
|
+
responseValue[i] = await remapQueryResponse(responseValue[i], withoutMultiplicity, client, definitions);
|
|
2081
|
+
}
|
|
2082
|
+
return responseValue;
|
|
2083
|
+
}
|
|
2084
|
+
switch (responseDataType.type) {
|
|
2085
|
+
case "union": {
|
|
2086
|
+
throw new Error("Union return types are not yet supported");
|
|
2087
|
+
}
|
|
2088
|
+
case "set": {
|
|
2089
|
+
for (let i = 0; i < responseValue.length; i++) {
|
|
2090
|
+
responseValue[i] = await remapQueryResponse(responseValue[i], responseDataType.set, client, definitions);
|
|
2091
|
+
}
|
|
2092
|
+
return responseValue;
|
|
2093
|
+
}
|
|
2094
|
+
case "attachment": {
|
|
2095
|
+
return createAttachmentFromRid(client, responseValue);
|
|
2096
|
+
}
|
|
2097
|
+
case "object": {
|
|
2098
|
+
const def = definitions.get(responseDataType.object);
|
|
2099
|
+
if (!def) {
|
|
2100
|
+
throw new Error(`Missing definition for ${responseDataType.object}`);
|
|
2101
|
+
}
|
|
2102
|
+
return createQueryObjectResponse(responseValue, def);
|
|
2103
|
+
}
|
|
2104
|
+
case "objectSet": {
|
|
2105
|
+
const def = definitions.get(responseDataType.objectSet);
|
|
2106
|
+
if (!def) {
|
|
2107
|
+
throw new Error(`Missing definition for ${responseDataType.objectSet}`);
|
|
2108
|
+
}
|
|
2109
|
+
if (typeof responseValue === "string") {
|
|
2110
|
+
return createObjectSet(def, client, {
|
|
2111
|
+
type: "intersect",
|
|
2112
|
+
objectSets: [{
|
|
2113
|
+
type: "base",
|
|
2114
|
+
objectType: responseDataType.objectSet
|
|
2115
|
+
}, {
|
|
2116
|
+
type: "reference",
|
|
2117
|
+
reference: responseValue
|
|
2118
|
+
}]
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return createObjectSet(def, client, responseValue);
|
|
2122
|
+
}
|
|
2123
|
+
case "struct": {
|
|
2124
|
+
for (const [key, subtype] of Object.entries(responseDataType.struct)) {
|
|
2125
|
+
if (requiresConversion(subtype)) {
|
|
2126
|
+
responseValue[key] = await remapQueryResponse(responseValue[key], subtype, client, definitions);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
return responseValue;
|
|
2130
|
+
}
|
|
2131
|
+
case "twoDimensionalAggregation": {
|
|
2132
|
+
const result = [];
|
|
2133
|
+
for (const {
|
|
2134
|
+
key,
|
|
2135
|
+
value
|
|
2136
|
+
} of responseValue.groups) {
|
|
2137
|
+
result.push({
|
|
2138
|
+
key,
|
|
2139
|
+
value
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
return result;
|
|
2143
|
+
}
|
|
2144
|
+
case "threeDimensionalAggregation": {
|
|
2145
|
+
const result = [];
|
|
2146
|
+
for (const {
|
|
2147
|
+
key,
|
|
2148
|
+
groups
|
|
2149
|
+
} of responseValue.groups) {
|
|
2150
|
+
const subResult = [];
|
|
2151
|
+
for (const {
|
|
2152
|
+
key: subKey,
|
|
2153
|
+
value
|
|
2154
|
+
} of groups) {
|
|
2155
|
+
subResult.push({
|
|
2156
|
+
key: subKey,
|
|
2157
|
+
value
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
result.push({
|
|
2161
|
+
key,
|
|
2162
|
+
groups: subResult
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2165
|
+
return result;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
return responseValue;
|
|
2169
|
+
}
|
|
2170
|
+
async function getRequiredDefinitions(dataType, client) {
|
|
2171
|
+
const result = /* @__PURE__ */ new Map();
|
|
2172
|
+
switch (dataType.type) {
|
|
2173
|
+
case "objectSet": {
|
|
2174
|
+
const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.objectSet);
|
|
2175
|
+
result.set(dataType.objectSet, objectDef);
|
|
2176
|
+
break;
|
|
2177
|
+
}
|
|
2178
|
+
case "object": {
|
|
2179
|
+
const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.object);
|
|
2180
|
+
result.set(dataType.object, objectDef);
|
|
2181
|
+
break;
|
|
2182
|
+
}
|
|
2183
|
+
case "set": {
|
|
2184
|
+
return getRequiredDefinitions(dataType.set, client);
|
|
2185
|
+
}
|
|
2186
|
+
case "struct": {
|
|
2187
|
+
for (const value of Object.values(dataType.struct)) {
|
|
2188
|
+
for (const [type, objectDef] of await getRequiredDefinitions(value, client)) {
|
|
2189
|
+
result.set(type, objectDef);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
break;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
return result;
|
|
2196
|
+
}
|
|
2197
|
+
function requiresConversion(dataType) {
|
|
2198
|
+
switch (dataType.type) {
|
|
2199
|
+
case "boolean":
|
|
2200
|
+
case "date":
|
|
2201
|
+
case "double":
|
|
2202
|
+
case "float":
|
|
2203
|
+
case "integer":
|
|
2204
|
+
case "long":
|
|
2205
|
+
case "object":
|
|
2206
|
+
case "string":
|
|
2207
|
+
case "timestamp":
|
|
2208
|
+
return false;
|
|
2209
|
+
case "union":
|
|
2210
|
+
return true;
|
|
2211
|
+
case "struct":
|
|
2212
|
+
return Object.values(dataType.struct).some(requiresConversion);
|
|
2213
|
+
case "set":
|
|
2214
|
+
return requiresConversion(dataType.set);
|
|
2215
|
+
case "attachment":
|
|
2216
|
+
case "objectSet":
|
|
2217
|
+
case "twoDimensionalAggregation":
|
|
2218
|
+
case "threeDimensionalAggregation":
|
|
2219
|
+
return true;
|
|
2220
|
+
default:
|
|
2221
|
+
return false;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
function createQueryObjectResponse(primaryKey, objectDef) {
|
|
2225
|
+
return {
|
|
2226
|
+
$apiName: objectDef.apiName,
|
|
2227
|
+
$title: void 0,
|
|
2228
|
+
$objectType: objectDef.apiName,
|
|
2229
|
+
$primaryKey: primaryKey
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
// src/queries/createQueryInvoker.ts
|
|
2234
|
+
function createQueryInvoker(client, query) {
|
|
2235
|
+
return function(...args) {
|
|
2236
|
+
return applyQuery(client, query, ...args);
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
|
|
1797
2240
|
// src/createClient.ts
|
|
1798
2241
|
var ActionInvoker = class {
|
|
1799
2242
|
constructor(clientCtx, actionDef) {
|
|
@@ -1811,6 +2254,8 @@ function createClientInternal(objectSetFactory, baseUrl, ontologyRid, tokenProvi
|
|
|
1811
2254
|
} else if (o.type === "action") {
|
|
1812
2255
|
clientCtx.ontologyProvider.maybeSeed(o);
|
|
1813
2256
|
return new ActionInvoker(clientCtx, o);
|
|
2257
|
+
} else if (o.type === "query") {
|
|
2258
|
+
return createQueryInvoker(clientCtx, o);
|
|
1814
2259
|
} else {
|
|
1815
2260
|
throw new Error("not implemented");
|
|
1816
2261
|
}
|
|
@@ -1829,10 +2274,11 @@ exports.USER_AGENT = USER_AGENT;
|
|
|
1829
2274
|
exports.augment = augment;
|
|
1830
2275
|
exports.convertWireToOsdkObjects = convertWireToOsdkObjects;
|
|
1831
2276
|
exports.createAttachmentFromRid = createAttachmentFromRid;
|
|
2277
|
+
exports.createAttachmentUpload = createAttachmentUpload;
|
|
1832
2278
|
exports.createClient = createClient;
|
|
1833
2279
|
exports.createClientInternal = createClientInternal;
|
|
1834
2280
|
exports.createObjectSet = createObjectSet;
|
|
1835
2281
|
exports.createSimpleAsyncCache = createSimpleAsyncCache;
|
|
1836
2282
|
exports.esm_exports = esm_exports2;
|
|
1837
2283
|
//# sourceMappingURL=out.js.map
|
|
1838
|
-
//# sourceMappingURL=chunk-
|
|
2284
|
+
//# sourceMappingURL=chunk-VW7XYOFL.cjs.map
|