@osdk/client 0.11.0 → 0.13.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/build/js/{chunk-LK4VDWCG.cjs → chunk-CKYBATFN.cjs} +253 -108
- package/build/js/chunk-CKYBATFN.cjs.map +1 -0
- package/build/js/{chunk-GOBQUVQZ.mjs → chunk-SNGUDELK.mjs} +250 -109
- package/build/js/chunk-SNGUDELK.mjs.map +1 -0
- package/build/js/index.cjs +82 -33
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +78 -30
- package/build/js/index.mjs.map +1 -1
- package/build/js/public/objects.cjs +3 -3
- package/build/js/public/objects.mjs +1 -1
- package/build/types/Client.d.ts +4 -4
- package/build/types/Definitions.d.ts +4 -5
- package/build/types/ObjectSetCreator.d.ts +2 -2
- package/build/types/OsdkObjectFrom.d.ts +17 -4
- package/build/types/actions/Actions.d.ts +5 -8
- package/build/types/createClient.d.ts +1 -1
- package/build/types/createMinimalClient.d.ts +1 -1
- package/build/types/definitions/LinkDefinitions.d.ts +2 -2
- package/build/types/generatedNoCheck/Ontology.d.ts +10 -7
- package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +2 -2
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +2 -2
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +12 -12
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +17 -17
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +12 -12
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +6 -6
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +6 -6
- package/build/types/generatedNoCheck/ontology/interfaces/FooInterface.d.ts +8 -0
- package/build/types/generatedNoCheck/ontology/interfaces.d.ts +1 -1
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +11 -4
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +4 -1
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +7 -4
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +4 -1
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +24 -21
- package/build/types/index.d.ts +1 -1
- package/build/types/mapping/DataValueMapping.d.ts +39 -0
- package/build/types/mapping/PropertyValueMapping.d.ts +47 -0
- package/build/types/object/Cache.d.ts +9 -2
- package/build/types/object/Cache.test.d.ts +10 -0
- package/build/types/object/aggregate.d.ts +4 -2
- package/build/types/object/convertWireToOsdkObjects.d.ts +17 -2
- package/build/types/object/fetchPage.d.ts +12 -3
- package/build/types/objectSet/ObjectSet.d.ts +13 -11
- package/build/types/objectSet/createObjectSet.d.ts +4 -2
- package/build/types/ontology/OntologyProvider.d.ts +12 -4
- package/build/types/ontology/{providers/StandardOntologyProvider.d.ts → StandardOntologyProvider.d.ts} +2 -1
- package/build/types/ontology/StandardOntologyProvider.test.d.ts +1 -0
- package/build/types/ontology/loadInterfaceDefinition.d.ts +3 -0
- package/build/types/query/WhereClause.d.ts +4 -3
- package/build/types/query/aggregations/AggregationsClause.d.ts +2 -2
- package/build/types/query/aggregations/AggregationsResults.d.ts +1 -1
- package/changelog/0.13.0/pr-101.v2.yml +5 -0
- package/changelog/0.13.0/pr-102.v2.yml +5 -0
- package/changelog/0.13.0/pr-104.v2.yml +5 -0
- package/changelog/0.13.0/pr-106.v2.yml +5 -0
- package/changelog/0.13.0/pr-107.v2.yml +5 -0
- package/changelog/0.13.0/pr-110.v2.yml +5 -0
- package/changelog/0.13.0/pr-111.v2.yml +5 -0
- package/changelog/0.13.0/pr-112.v2.yml +5 -0
- package/changelog/0.13.0/pr-116.v2.yml +5 -0
- package/changelog/0.13.0/pr-117.v2.yml +5 -0
- package/changelog/0.13.0/pr-120.v2.yml +5 -0
- package/changelog/0.13.0/pr-125.v2.yml +5 -0
- package/package.json +10 -7
- package/build/js/chunk-GOBQUVQZ.mjs.map +0 -1
- package/build/js/chunk-LK4VDWCG.cjs.map +0 -1
- /package/build/types/{ontology/providers/StandardOntologyProvider.test.d.ts → OsdkObjectFrom.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aggregateObjectSetV2, loadObjectSetV2, getObjectTypeV2 } from '@osdk/gateway/requests';
|
|
1
|
+
import { aggregateObjectSetV2, loadObjectSetV2, getObjectTypeV2, searchObjectsForInterface } from '@osdk/gateway/requests';
|
|
2
2
|
import { createOpenApiRequest, PalantirApiError } from '@osdk/shared.net';
|
|
3
3
|
import invariant2 from 'tiny-invariant';
|
|
4
4
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -303,6 +303,12 @@ function aggregationToCountResult(entry) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
+
|
|
307
|
+
// src/util/WireObjectSet.ts
|
|
308
|
+
var WIRE_OBJECT_SET_TYPES = /* @__PURE__ */ new Set(["base", "filter", "intersect", "reference", "searchAround", "static", "subtract", "union"]);
|
|
309
|
+
function isWireObjectSet(o) {
|
|
310
|
+
return o != null && typeof o === "object" && WIRE_OBJECT_SET_TYPES.has(o.type);
|
|
311
|
+
}
|
|
306
312
|
async function createTemporaryObjectSet(ctx, request) {
|
|
307
313
|
return conjureFetch(ctx, `/objectSets/temporary`, "POST", request);
|
|
308
314
|
}
|
|
@@ -784,8 +790,7 @@ async function convertFoundryToOsdkObjects(client, ctx, objects) {
|
|
|
784
790
|
}), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName], ["$apiName", propertyMapping?.apiName]]);
|
|
785
791
|
return convertedObject;
|
|
786
792
|
}));
|
|
787
|
-
await
|
|
788
|
-
return osdkObjects;
|
|
793
|
+
return await convertWireToOsdkObjects(client, osdkObjects, void 0);
|
|
789
794
|
}
|
|
790
795
|
var objectTypeMapping = /* @__PURE__ */ new WeakMap();
|
|
791
796
|
var objectApiNameToRid = /* @__PURE__ */ new Map();
|
|
@@ -840,25 +845,22 @@ async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
|
|
|
840
845
|
function isObjectTypeDefinition(def) {
|
|
841
846
|
return def.type === "object";
|
|
842
847
|
}
|
|
843
|
-
|
|
848
|
+
function isObjectSet(o) {
|
|
849
|
+
return o != null && typeof o === "object" && isWireObjectSet(objectSetDefinitions.get(o));
|
|
850
|
+
}
|
|
851
|
+
function getWireObjectSet(objectSet) {
|
|
852
|
+
return objectSetDefinitions.get(objectSet);
|
|
853
|
+
}
|
|
854
|
+
var objectSetDefinitions = /* @__PURE__ */ new WeakMap();
|
|
844
855
|
function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
845
856
|
type: "base",
|
|
846
857
|
objectType: objectType["apiName"]
|
|
847
858
|
}) {
|
|
848
859
|
const base = {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
aggregateOrThrow: (req) => {
|
|
854
|
-
return aggregate(clientCtx, objectType, objectSet, req);
|
|
855
|
-
},
|
|
856
|
-
fetchPage: async (args) => {
|
|
857
|
-
return fetchPage(clientCtx, objectType, args ?? {}, objectSet);
|
|
858
|
-
},
|
|
859
|
-
fetchPageOrThrow: async (args) => {
|
|
860
|
-
return fetchPage(clientCtx, objectType, args ?? {}, objectSet);
|
|
861
|
-
},
|
|
860
|
+
aggregate: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
861
|
+
aggregateOrThrow: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
862
|
+
fetchPage: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
863
|
+
fetchPageOrThrow: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
862
864
|
where: (clause) => {
|
|
863
865
|
return createObjectSet2(objectType, clientCtx, {
|
|
864
866
|
type: "filter",
|
|
@@ -872,19 +874,19 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
|
872
874
|
union: (...objectSets) => {
|
|
873
875
|
return createObjectSet2(objectType, clientCtx, {
|
|
874
876
|
type: "union",
|
|
875
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
877
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
876
878
|
});
|
|
877
879
|
},
|
|
878
880
|
intersect: (...objectSets) => {
|
|
879
881
|
return createObjectSet2(objectType, clientCtx, {
|
|
880
882
|
type: "intersect",
|
|
881
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
883
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
882
884
|
});
|
|
883
885
|
},
|
|
884
886
|
subtract: (...objectSets) => {
|
|
885
887
|
return createObjectSet2(objectType, clientCtx, {
|
|
886
888
|
type: "subtract",
|
|
887
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
889
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
888
890
|
});
|
|
889
891
|
},
|
|
890
892
|
subscribe(listener) {
|
|
@@ -897,48 +899,35 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
|
897
899
|
const result = await base.fetchPage({
|
|
898
900
|
nextPageToken
|
|
899
901
|
});
|
|
900
|
-
await
|
|
901
|
-
for (const obj of result.data) {
|
|
902
|
+
for (const obj of await convertWireToOsdkObjects(clientCtx, result.data, void 0)) {
|
|
902
903
|
yield obj;
|
|
903
904
|
}
|
|
904
905
|
} while (nextPageToken != null);
|
|
905
|
-
}
|
|
906
|
+
},
|
|
907
|
+
get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
908
|
+
const withPk = {
|
|
909
|
+
type: "filter",
|
|
910
|
+
objectSet,
|
|
911
|
+
where: {
|
|
912
|
+
type: "eq",
|
|
913
|
+
field: objectType.primaryKeyApiName,
|
|
914
|
+
value: primaryKey
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
return await fetchSingle(clientCtx, objectType, options, withPk);
|
|
918
|
+
} : void 0
|
|
906
919
|
};
|
|
907
920
|
function createSearchAround(link) {
|
|
908
921
|
return () => {
|
|
909
|
-
return
|
|
922
|
+
return createObjectSet2(objectType, clientCtx, {
|
|
910
923
|
type: "searchAround",
|
|
911
924
|
objectSet,
|
|
912
925
|
link
|
|
913
926
|
});
|
|
914
927
|
};
|
|
915
928
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
if (typeof p === "string" && p.startsWith(searchAroundPrefix)) {
|
|
919
|
-
return createSearchAround(p.substring(searchAroundPrefix.length));
|
|
920
|
-
}
|
|
921
|
-
return target[p];
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
function createBaseObjectSet(objectType, clientCtx, objectSet = {
|
|
926
|
-
type: "base",
|
|
927
|
-
objectType: objectType["apiName"]
|
|
928
|
-
}) {
|
|
929
|
-
return {
|
|
930
|
-
...createObjectSet2(objectType, clientCtx, objectSet),
|
|
931
|
-
get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
932
|
-
const withPk = {
|
|
933
|
-
type: "filter",
|
|
934
|
-
objectSet,
|
|
935
|
-
where: modernToLegacyWhereClause({
|
|
936
|
-
[objectType.primaryKeyApiName]: primaryKey
|
|
937
|
-
})
|
|
938
|
-
};
|
|
939
|
-
return await fetchSingle(clientCtx, objectType, options, withPk);
|
|
940
|
-
} : void 0
|
|
941
|
-
};
|
|
929
|
+
objectSetDefinitions.set(base, objectSet);
|
|
930
|
+
return base;
|
|
942
931
|
}
|
|
943
932
|
|
|
944
933
|
// src/object/Attachment.ts
|
|
@@ -972,48 +961,71 @@ function createCache(fn) {
|
|
|
972
961
|
cache.get(client).set(key, value);
|
|
973
962
|
return value;
|
|
974
963
|
}
|
|
975
|
-
|
|
976
|
-
get
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
function createAsyncCache(fn) {
|
|
981
|
-
const cache = createCache();
|
|
982
|
-
function getOrUndefined(client, key) {
|
|
983
|
-
return cache.get(client, key);
|
|
984
|
-
}
|
|
985
|
-
async function get(client, key) {
|
|
986
|
-
return cache.get(client, key) ?? set(client, key, fn(client, key));
|
|
987
|
-
}
|
|
988
|
-
async function set(client, k, v) {
|
|
989
|
-
return cache.set(client, k, await v);
|
|
964
|
+
function remove(client, key) {
|
|
965
|
+
if (cache.get(client) == null)
|
|
966
|
+
return false;
|
|
967
|
+
return cache.get(client).delete(key);
|
|
990
968
|
}
|
|
991
969
|
return {
|
|
992
970
|
get,
|
|
993
971
|
set,
|
|
994
|
-
|
|
972
|
+
remove
|
|
995
973
|
};
|
|
996
974
|
}
|
|
975
|
+
function createAsyncCache(fn, createCacheLocal = createCache) {
|
|
976
|
+
const cache = createCacheLocal();
|
|
977
|
+
const inProgress = createCacheLocal();
|
|
978
|
+
const ret = {
|
|
979
|
+
getOrUndefined: function getOrUndefined(client, key) {
|
|
980
|
+
return cache.get(client, key);
|
|
981
|
+
},
|
|
982
|
+
get: async function get(client, key) {
|
|
983
|
+
return cache.get(client, key) ?? inProgress.get(client, key) ?? ret.set(client, key, fn(client, key));
|
|
984
|
+
},
|
|
985
|
+
set: async function set(client, k, v) {
|
|
986
|
+
try {
|
|
987
|
+
const r = await inProgress.set(client, k, v);
|
|
988
|
+
cache.set(client, k, r);
|
|
989
|
+
inProgress.remove(client, k);
|
|
990
|
+
return r;
|
|
991
|
+
} catch (e) {
|
|
992
|
+
inProgress.remove(client, k);
|
|
993
|
+
throw e;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
return ret;
|
|
998
|
+
}
|
|
997
999
|
|
|
998
1000
|
// src/object/convertWireToOsdkObjects.ts
|
|
999
1001
|
var OriginClient = Symbol();
|
|
1002
|
+
var UnderlyingObject = Symbol();
|
|
1003
|
+
var InterfaceDefinitions = Symbol();
|
|
1000
1004
|
function createPrototype(objDef, client) {
|
|
1001
|
-
const
|
|
1002
|
-
Object.
|
|
1005
|
+
const interfaceProto = {};
|
|
1006
|
+
Object.defineProperties(interfaceProto, {
|
|
1007
|
+
$as: {
|
|
1008
|
+
value: $as,
|
|
1009
|
+
writable: false,
|
|
1010
|
+
configurable: false
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
const objectProto = {};
|
|
1014
|
+
Object.defineProperty(objectProto, "$link", {
|
|
1003
1015
|
get: function() {
|
|
1004
|
-
const primaryKey = this["
|
|
1016
|
+
const primaryKey = this["$primaryKey"];
|
|
1005
1017
|
return new Proxy({}, {
|
|
1006
1018
|
get(_target, p, _receiver) {
|
|
1007
1019
|
const linkDef = objDef.links[p];
|
|
1008
1020
|
if (linkDef == null) {
|
|
1009
1021
|
return;
|
|
1010
1022
|
}
|
|
1011
|
-
const objectSet =
|
|
1023
|
+
const objectSet = createObjectSet2(objDef, client).where({
|
|
1012
1024
|
[objDef.primaryKeyApiName]: primaryKey
|
|
1013
1025
|
}).pivotTo(p);
|
|
1014
1026
|
if (!linkDef.multiplicity) {
|
|
1015
1027
|
return {
|
|
1016
|
-
get: (options) => fetchSingle(client, objDef, options ?? {}, objectSet
|
|
1028
|
+
get: (options) => fetchSingle(client, objDef, options ?? {}, getWireObjectSet(objectSet))
|
|
1017
1029
|
};
|
|
1018
1030
|
} else {
|
|
1019
1031
|
return objectSet;
|
|
@@ -1024,7 +1036,46 @@ function createPrototype(objDef, client) {
|
|
|
1024
1036
|
enumerable: false,
|
|
1025
1037
|
configurable: false
|
|
1026
1038
|
});
|
|
1027
|
-
|
|
1039
|
+
function $as(newDef) {
|
|
1040
|
+
if (typeof newDef === "string") {
|
|
1041
|
+
if (newDef === objDef.apiName) {
|
|
1042
|
+
return this[UnderlyingObject];
|
|
1043
|
+
}
|
|
1044
|
+
const def = objDef[InterfaceDefinitions][newDef];
|
|
1045
|
+
if (!def) {
|
|
1046
|
+
throw new Error(`Object does not implement interface '${newDef}'.`);
|
|
1047
|
+
}
|
|
1048
|
+
newDef = def;
|
|
1049
|
+
} else if (newDef.apiName === objDef.apiName) {
|
|
1050
|
+
return this[UnderlyingObject];
|
|
1051
|
+
}
|
|
1052
|
+
!(newDef.type === "interface") ? process.env.NODE_ENV !== "production" ? invariant2(false) : invariant2(false) : void 0;
|
|
1053
|
+
const ret = {
|
|
1054
|
+
$apiName: newDef.apiName,
|
|
1055
|
+
$objectType: objDef.apiName,
|
|
1056
|
+
$primaryKey: this["$primaryKey"]
|
|
1057
|
+
};
|
|
1058
|
+
for (const p of Object.keys(newDef.properties)) {
|
|
1059
|
+
const value = this[objDef.spts[p]];
|
|
1060
|
+
Object.defineProperty(ret, p, {
|
|
1061
|
+
value,
|
|
1062
|
+
configurable: false,
|
|
1063
|
+
enumerable: value !== void 0
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
Object.defineProperty(ret, UnderlyingObject, {
|
|
1067
|
+
value: this,
|
|
1068
|
+
configurable: false,
|
|
1069
|
+
enumerable: false
|
|
1070
|
+
});
|
|
1071
|
+
Object.setPrototypeOf(ret, interfaceProto);
|
|
1072
|
+
return ret;
|
|
1073
|
+
}
|
|
1074
|
+
Object.defineProperty(objectProto, "$as", {
|
|
1075
|
+
value: $as,
|
|
1076
|
+
configurable: false
|
|
1077
|
+
});
|
|
1078
|
+
return objectProto;
|
|
1028
1079
|
}
|
|
1029
1080
|
function createConverter(objDef) {
|
|
1030
1081
|
const steps = [];
|
|
@@ -1055,7 +1106,58 @@ var protoConverterCache = createCache((client, objectDef) => {
|
|
|
1055
1106
|
converter
|
|
1056
1107
|
};
|
|
1057
1108
|
});
|
|
1058
|
-
async function
|
|
1109
|
+
async function convertWireToOsdkObjects(client, objects, interfaceApiName) {
|
|
1110
|
+
fixObjectPropertiesInline(objects);
|
|
1111
|
+
const localObjectCache = createLocalObjectCacheAndInitiatePreseed(objects, client);
|
|
1112
|
+
for (const obj of objects) {
|
|
1113
|
+
const objectDef = await localObjectCache.get(client, obj.$apiName);
|
|
1114
|
+
if (objectDef == null) {
|
|
1115
|
+
throw new Error(`Failed to find ontology definition for '${obj.$apiName}'`);
|
|
1116
|
+
}
|
|
1117
|
+
if (interfaceApiName !== void 0) {
|
|
1118
|
+
for (const [sptProp, regularProp] of Object.entries(objectDef.spts)) {
|
|
1119
|
+
if (sptProp in obj) {
|
|
1120
|
+
const value = obj[sptProp];
|
|
1121
|
+
delete obj[sptProp];
|
|
1122
|
+
if (value !== void 0) {
|
|
1123
|
+
obj[regularProp] = value;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
internalConvertObjectInPlace(objectDef, client, obj);
|
|
1129
|
+
}
|
|
1130
|
+
if (interfaceApiName) {
|
|
1131
|
+
return objects.map((o) => o.$as(interfaceApiName));
|
|
1132
|
+
} else {
|
|
1133
|
+
return objects;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
function createLocalObjectCacheAndInitiatePreseed(objects, client) {
|
|
1137
|
+
const localInterfaceCache = createAsyncCache((client2, apiName) => client2.ontology.provider.getInterfaceDefinition(apiName));
|
|
1138
|
+
const localObjectCache = createAsyncCache(async (client2, apiName) => {
|
|
1139
|
+
const objectDef = await client2.ontology.provider.getObjectDefinition(apiName);
|
|
1140
|
+
if (objectDef[InterfaceDefinitions] == null) {
|
|
1141
|
+
const interfaceDefs = Object.fromEntries((await Promise.all(objectDef.implements?.map((i) => localInterfaceCache.get(client2, i)) ?? [])).map((i) => [i.apiName, i]));
|
|
1142
|
+
Object.defineProperty(objectDef, InterfaceDefinitions, {
|
|
1143
|
+
value: interfaceDefs,
|
|
1144
|
+
enumerable: false,
|
|
1145
|
+
configurable: false,
|
|
1146
|
+
writable: false
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
return objectDef;
|
|
1150
|
+
});
|
|
1151
|
+
const uniqueApiNames = /* @__PURE__ */ new Set();
|
|
1152
|
+
for (const {
|
|
1153
|
+
$apiName
|
|
1154
|
+
} of objects) {
|
|
1155
|
+
uniqueApiNames.add($apiName);
|
|
1156
|
+
}
|
|
1157
|
+
Array.from(uniqueApiNames).map((n) => localObjectCache.get(client, n).then((a) => a.implements?.map((i) => localInterfaceCache.get(client, i))));
|
|
1158
|
+
return localObjectCache;
|
|
1159
|
+
}
|
|
1160
|
+
function fixObjectPropertiesInline(objs) {
|
|
1059
1161
|
for (const obj of objs) {
|
|
1060
1162
|
if (obj.__rid) {
|
|
1061
1163
|
obj.$rid = obj.__rid;
|
|
@@ -1075,45 +1177,73 @@ async function convertWireToOsdkObjectsInPlace(client, objs) {
|
|
|
1075
1177
|
});
|
|
1076
1178
|
}
|
|
1077
1179
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
Object.defineProperty(obj, OriginClient, {
|
|
1094
|
-
value: client,
|
|
1095
|
-
enumerable: false,
|
|
1096
|
-
configurable: false,
|
|
1097
|
-
writable: false
|
|
1098
|
-
});
|
|
1099
|
-
if (converter) {
|
|
1100
|
-
converter(obj);
|
|
1101
|
-
}
|
|
1180
|
+
}
|
|
1181
|
+
function internalConvertObjectInPlace(objectDef, client, obj) {
|
|
1182
|
+
const {
|
|
1183
|
+
proto,
|
|
1184
|
+
converter
|
|
1185
|
+
} = protoConverterCache.get(client, objectDef);
|
|
1186
|
+
Object.setPrototypeOf(obj, proto);
|
|
1187
|
+
Object.defineProperty(obj, OriginClient, {
|
|
1188
|
+
value: client,
|
|
1189
|
+
enumerable: false,
|
|
1190
|
+
configurable: false,
|
|
1191
|
+
writable: false
|
|
1192
|
+
});
|
|
1193
|
+
if (converter) {
|
|
1194
|
+
converter(obj);
|
|
1102
1195
|
}
|
|
1103
1196
|
}
|
|
1104
1197
|
|
|
1105
1198
|
// src/object/fetchPage.ts
|
|
1199
|
+
function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = void 0) {
|
|
1200
|
+
if (objectSet.type === "base") {
|
|
1201
|
+
if (objectSet.objectType !== expectedApiName) {
|
|
1202
|
+
throw new Error(`Expected objectSet.objectType to be ${expectedApiName}, but got ${objectSet.objectType}`);
|
|
1203
|
+
}
|
|
1204
|
+
return existingWhere;
|
|
1205
|
+
}
|
|
1206
|
+
if (objectSet.type === "filter") {
|
|
1207
|
+
return objectSetToSearchJsonV2(objectSet.objectSet, expectedApiName, existingWhere == null ? objectSet.where : {
|
|
1208
|
+
type: "and",
|
|
1209
|
+
value: [existingWhere, objectSet.where]
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
|
|
1213
|
+
}
|
|
1214
|
+
async function fetchInterfacePage(client, interfaceType, args, objectSet) {
|
|
1215
|
+
const result = await searchObjectsForInterface(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, interfaceType.apiName, applyFetchArgs(args, {
|
|
1216
|
+
augmentedProperties: {},
|
|
1217
|
+
augmentedSharedPropertyTypes: {},
|
|
1218
|
+
otherInterfaceTypes: [],
|
|
1219
|
+
selectedObjectTypes: [],
|
|
1220
|
+
selectedSharedPropertyTypes: args.select ?? [],
|
|
1221
|
+
where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)
|
|
1222
|
+
}), {
|
|
1223
|
+
preview: true
|
|
1224
|
+
});
|
|
1225
|
+
result.data = await convertWireToOsdkObjects(
|
|
1226
|
+
client,
|
|
1227
|
+
result.data,
|
|
1228
|
+
// drop readonly
|
|
1229
|
+
interfaceType.apiName
|
|
1230
|
+
);
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1233
|
+
async function fetchPageInternal(client, objectType, objectSet, args = {}) {
|
|
1234
|
+
if (objectType.type === "interface") {
|
|
1235
|
+
return await fetchInterfacePage(client, objectType, args, objectSet);
|
|
1236
|
+
} else {
|
|
1237
|
+
return await fetchObjectPage(client, objectType, args, objectSet);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1106
1240
|
async function fetchPage(client, objectType, args, objectSet = {
|
|
1107
1241
|
type: "base",
|
|
1108
1242
|
objectType: objectType["apiName"]
|
|
1109
1243
|
}) {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
select: args?.select ?? [],
|
|
1114
|
-
// FIXME?
|
|
1115
|
-
excludeRid: !args?.includeRid
|
|
1116
|
-
};
|
|
1244
|
+
return fetchPageInternal(client, objectType, objectSet, args);
|
|
1245
|
+
}
|
|
1246
|
+
function applyFetchArgs(args, body) {
|
|
1117
1247
|
if (args?.nextPageToken) {
|
|
1118
1248
|
body.pageToken = args.nextPageToken;
|
|
1119
1249
|
}
|
|
@@ -1128,11 +1258,22 @@ async function fetchPage(client, objectType, args, objectSet = {
|
|
|
1128
1258
|
}))
|
|
1129
1259
|
};
|
|
1130
1260
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1261
|
+
return body;
|
|
1262
|
+
}
|
|
1263
|
+
async function fetchObjectPage(client, objectType, args, objectSet) {
|
|
1264
|
+
const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, applyFetchArgs(args, {
|
|
1265
|
+
objectSet,
|
|
1266
|
+
// We have to do the following case because LoadObjectSetRequestV2 isnt readonly
|
|
1267
|
+
select: args?.select ?? [],
|
|
1268
|
+
// FIXME?
|
|
1269
|
+
excludeRid: !args?.includeRid
|
|
1270
|
+
}));
|
|
1271
|
+
return Promise.resolve({
|
|
1272
|
+
data: await convertWireToOsdkObjects(client, r.data, void 0),
|
|
1273
|
+
nextPageToken: r.nextPageToken
|
|
1274
|
+
});
|
|
1134
1275
|
}
|
|
1135
1276
|
|
|
1136
|
-
export { aggregate, createAsyncCache,
|
|
1277
|
+
export { aggregate, createAsyncCache, createObjectSet2 as createObjectSet, fetchPage, getWireObjectSet, isAttachment, isObjectSet, isWireObjectSet, loadAllOntologies, loadOntologyEntities, object_exports };
|
|
1137
1278
|
//# sourceMappingURL=out.js.map
|
|
1138
|
-
//# sourceMappingURL=chunk-
|
|
1279
|
+
//# sourceMappingURL=chunk-SNGUDELK.mjs.map
|