@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
|
@@ -310,6 +310,12 @@ function aggregationToCountResult(entry) {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
|
|
314
|
+
// src/util/WireObjectSet.ts
|
|
315
|
+
var WIRE_OBJECT_SET_TYPES = /* @__PURE__ */ new Set(["base", "filter", "intersect", "reference", "searchAround", "static", "subtract", "union"]);
|
|
316
|
+
function isWireObjectSet(o) {
|
|
317
|
+
return o != null && typeof o === "object" && WIRE_OBJECT_SET_TYPES.has(o.type);
|
|
318
|
+
}
|
|
313
319
|
async function createTemporaryObjectSet(ctx, request) {
|
|
314
320
|
return conjureLite.conjureFetch(ctx, `/objectSets/temporary`, "POST", request);
|
|
315
321
|
}
|
|
@@ -791,8 +797,7 @@ async function convertFoundryToOsdkObjects(client, ctx, objects) {
|
|
|
791
797
|
}), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName], ["$apiName", propertyMapping?.apiName]]);
|
|
792
798
|
return convertedObject;
|
|
793
799
|
}));
|
|
794
|
-
await
|
|
795
|
-
return osdkObjects;
|
|
800
|
+
return await convertWireToOsdkObjects(client, osdkObjects, void 0);
|
|
796
801
|
}
|
|
797
802
|
var objectTypeMapping = /* @__PURE__ */ new WeakMap();
|
|
798
803
|
var objectApiNameToRid = /* @__PURE__ */ new Map();
|
|
@@ -847,25 +852,22 @@ async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
|
|
|
847
852
|
function isObjectTypeDefinition(def) {
|
|
848
853
|
return def.type === "object";
|
|
849
854
|
}
|
|
850
|
-
|
|
855
|
+
function isObjectSet(o) {
|
|
856
|
+
return o != null && typeof o === "object" && isWireObjectSet(objectSetDefinitions.get(o));
|
|
857
|
+
}
|
|
858
|
+
function getWireObjectSet(objectSet) {
|
|
859
|
+
return objectSetDefinitions.get(objectSet);
|
|
860
|
+
}
|
|
861
|
+
var objectSetDefinitions = /* @__PURE__ */ new WeakMap();
|
|
851
862
|
function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
852
863
|
type: "base",
|
|
853
864
|
objectType: objectType["apiName"]
|
|
854
865
|
}) {
|
|
855
866
|
const base = {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
aggregateOrThrow: (req) => {
|
|
861
|
-
return aggregate(clientCtx, objectType, objectSet, req);
|
|
862
|
-
},
|
|
863
|
-
fetchPage: async (args) => {
|
|
864
|
-
return fetchPage(clientCtx, objectType, args ?? {}, objectSet);
|
|
865
|
-
},
|
|
866
|
-
fetchPageOrThrow: async (args) => {
|
|
867
|
-
return fetchPage(clientCtx, objectType, args ?? {}, objectSet);
|
|
868
|
-
},
|
|
867
|
+
aggregate: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
868
|
+
aggregateOrThrow: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
869
|
+
fetchPage: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
870
|
+
fetchPageOrThrow: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
869
871
|
where: (clause) => {
|
|
870
872
|
return createObjectSet2(objectType, clientCtx, {
|
|
871
873
|
type: "filter",
|
|
@@ -879,19 +881,19 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
|
879
881
|
union: (...objectSets) => {
|
|
880
882
|
return createObjectSet2(objectType, clientCtx, {
|
|
881
883
|
type: "union",
|
|
882
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
884
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
883
885
|
});
|
|
884
886
|
},
|
|
885
887
|
intersect: (...objectSets) => {
|
|
886
888
|
return createObjectSet2(objectType, clientCtx, {
|
|
887
889
|
type: "intersect",
|
|
888
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
890
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
889
891
|
});
|
|
890
892
|
},
|
|
891
893
|
subtract: (...objectSets) => {
|
|
892
894
|
return createObjectSet2(objectType, clientCtx, {
|
|
893
895
|
type: "subtract",
|
|
894
|
-
objectSets: [objectSet, ...objectSets.map((os) => os
|
|
896
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
895
897
|
});
|
|
896
898
|
},
|
|
897
899
|
subscribe(listener) {
|
|
@@ -904,48 +906,35 @@ function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
|
904
906
|
const result = await base.fetchPage({
|
|
905
907
|
nextPageToken
|
|
906
908
|
});
|
|
907
|
-
await
|
|
908
|
-
for (const obj of result.data) {
|
|
909
|
+
for (const obj of await convertWireToOsdkObjects(clientCtx, result.data, void 0)) {
|
|
909
910
|
yield obj;
|
|
910
911
|
}
|
|
911
912
|
} while (nextPageToken != null);
|
|
912
|
-
}
|
|
913
|
+
},
|
|
914
|
+
get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
915
|
+
const withPk = {
|
|
916
|
+
type: "filter",
|
|
917
|
+
objectSet,
|
|
918
|
+
where: {
|
|
919
|
+
type: "eq",
|
|
920
|
+
field: objectType.primaryKeyApiName,
|
|
921
|
+
value: primaryKey
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
return await fetchSingle(clientCtx, objectType, options, withPk);
|
|
925
|
+
} : void 0
|
|
913
926
|
};
|
|
914
927
|
function createSearchAround(link) {
|
|
915
928
|
return () => {
|
|
916
|
-
return
|
|
929
|
+
return createObjectSet2(objectType, clientCtx, {
|
|
917
930
|
type: "searchAround",
|
|
918
931
|
objectSet,
|
|
919
932
|
link
|
|
920
933
|
});
|
|
921
934
|
};
|
|
922
935
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
if (typeof p === "string" && p.startsWith(searchAroundPrefix)) {
|
|
926
|
-
return createSearchAround(p.substring(searchAroundPrefix.length));
|
|
927
|
-
}
|
|
928
|
-
return target[p];
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
function createBaseObjectSet(objectType, clientCtx, objectSet = {
|
|
933
|
-
type: "base",
|
|
934
|
-
objectType: objectType["apiName"]
|
|
935
|
-
}) {
|
|
936
|
-
return {
|
|
937
|
-
...createObjectSet2(objectType, clientCtx, objectSet),
|
|
938
|
-
get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
939
|
-
const withPk = {
|
|
940
|
-
type: "filter",
|
|
941
|
-
objectSet,
|
|
942
|
-
where: modernToLegacyWhereClause({
|
|
943
|
-
[objectType.primaryKeyApiName]: primaryKey
|
|
944
|
-
})
|
|
945
|
-
};
|
|
946
|
-
return await fetchSingle(clientCtx, objectType, options, withPk);
|
|
947
|
-
} : void 0
|
|
948
|
-
};
|
|
936
|
+
objectSetDefinitions.set(base, objectSet);
|
|
937
|
+
return base;
|
|
949
938
|
}
|
|
950
939
|
|
|
951
940
|
// src/object/Attachment.ts
|
|
@@ -979,48 +968,71 @@ function createCache(fn) {
|
|
|
979
968
|
cache.get(client).set(key, value);
|
|
980
969
|
return value;
|
|
981
970
|
}
|
|
982
|
-
|
|
983
|
-
get
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
function createAsyncCache(fn) {
|
|
988
|
-
const cache = createCache();
|
|
989
|
-
function getOrUndefined(client, key) {
|
|
990
|
-
return cache.get(client, key);
|
|
991
|
-
}
|
|
992
|
-
async function get(client, key) {
|
|
993
|
-
return cache.get(client, key) ?? set(client, key, fn(client, key));
|
|
994
|
-
}
|
|
995
|
-
async function set(client, k, v) {
|
|
996
|
-
return cache.set(client, k, await v);
|
|
971
|
+
function remove(client, key) {
|
|
972
|
+
if (cache.get(client) == null)
|
|
973
|
+
return false;
|
|
974
|
+
return cache.get(client).delete(key);
|
|
997
975
|
}
|
|
998
976
|
return {
|
|
999
977
|
get,
|
|
1000
978
|
set,
|
|
1001
|
-
|
|
979
|
+
remove
|
|
1002
980
|
};
|
|
1003
981
|
}
|
|
982
|
+
function createAsyncCache(fn, createCacheLocal = createCache) {
|
|
983
|
+
const cache = createCacheLocal();
|
|
984
|
+
const inProgress = createCacheLocal();
|
|
985
|
+
const ret = {
|
|
986
|
+
getOrUndefined: function getOrUndefined(client, key) {
|
|
987
|
+
return cache.get(client, key);
|
|
988
|
+
},
|
|
989
|
+
get: async function get(client, key) {
|
|
990
|
+
return cache.get(client, key) ?? inProgress.get(client, key) ?? ret.set(client, key, fn(client, key));
|
|
991
|
+
},
|
|
992
|
+
set: async function set(client, k, v) {
|
|
993
|
+
try {
|
|
994
|
+
const r = await inProgress.set(client, k, v);
|
|
995
|
+
cache.set(client, k, r);
|
|
996
|
+
inProgress.remove(client, k);
|
|
997
|
+
return r;
|
|
998
|
+
} catch (e) {
|
|
999
|
+
inProgress.remove(client, k);
|
|
1000
|
+
throw e;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
return ret;
|
|
1005
|
+
}
|
|
1004
1006
|
|
|
1005
1007
|
// src/object/convertWireToOsdkObjects.ts
|
|
1006
1008
|
var OriginClient = Symbol();
|
|
1009
|
+
var UnderlyingObject = Symbol();
|
|
1010
|
+
var InterfaceDefinitions = Symbol();
|
|
1007
1011
|
function createPrototype(objDef, client) {
|
|
1008
|
-
const
|
|
1009
|
-
Object.
|
|
1012
|
+
const interfaceProto = {};
|
|
1013
|
+
Object.defineProperties(interfaceProto, {
|
|
1014
|
+
$as: {
|
|
1015
|
+
value: $as,
|
|
1016
|
+
writable: false,
|
|
1017
|
+
configurable: false
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
const objectProto = {};
|
|
1021
|
+
Object.defineProperty(objectProto, "$link", {
|
|
1010
1022
|
get: function() {
|
|
1011
|
-
const primaryKey = this["
|
|
1023
|
+
const primaryKey = this["$primaryKey"];
|
|
1012
1024
|
return new Proxy({}, {
|
|
1013
1025
|
get(_target, p, _receiver) {
|
|
1014
1026
|
const linkDef = objDef.links[p];
|
|
1015
1027
|
if (linkDef == null) {
|
|
1016
1028
|
return;
|
|
1017
1029
|
}
|
|
1018
|
-
const objectSet =
|
|
1030
|
+
const objectSet = createObjectSet2(objDef, client).where({
|
|
1019
1031
|
[objDef.primaryKeyApiName]: primaryKey
|
|
1020
1032
|
}).pivotTo(p);
|
|
1021
1033
|
if (!linkDef.multiplicity) {
|
|
1022
1034
|
return {
|
|
1023
|
-
get: (options) => fetchSingle(client, objDef, options ?? {}, objectSet
|
|
1035
|
+
get: (options) => fetchSingle(client, objDef, options ?? {}, getWireObjectSet(objectSet))
|
|
1024
1036
|
};
|
|
1025
1037
|
} else {
|
|
1026
1038
|
return objectSet;
|
|
@@ -1031,7 +1043,46 @@ function createPrototype(objDef, client) {
|
|
|
1031
1043
|
enumerable: false,
|
|
1032
1044
|
configurable: false
|
|
1033
1045
|
});
|
|
1034
|
-
|
|
1046
|
+
function $as(newDef) {
|
|
1047
|
+
if (typeof newDef === "string") {
|
|
1048
|
+
if (newDef === objDef.apiName) {
|
|
1049
|
+
return this[UnderlyingObject];
|
|
1050
|
+
}
|
|
1051
|
+
const def = objDef[InterfaceDefinitions][newDef];
|
|
1052
|
+
if (!def) {
|
|
1053
|
+
throw new Error(`Object does not implement interface '${newDef}'.`);
|
|
1054
|
+
}
|
|
1055
|
+
newDef = def;
|
|
1056
|
+
} else if (newDef.apiName === objDef.apiName) {
|
|
1057
|
+
return this[UnderlyingObject];
|
|
1058
|
+
}
|
|
1059
|
+
!(newDef.type === "interface") ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : void 0;
|
|
1060
|
+
const ret = {
|
|
1061
|
+
$apiName: newDef.apiName,
|
|
1062
|
+
$objectType: objDef.apiName,
|
|
1063
|
+
$primaryKey: this["$primaryKey"]
|
|
1064
|
+
};
|
|
1065
|
+
for (const p of Object.keys(newDef.properties)) {
|
|
1066
|
+
const value = this[objDef.spts[p]];
|
|
1067
|
+
Object.defineProperty(ret, p, {
|
|
1068
|
+
value,
|
|
1069
|
+
configurable: false,
|
|
1070
|
+
enumerable: value !== void 0
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
Object.defineProperty(ret, UnderlyingObject, {
|
|
1074
|
+
value: this,
|
|
1075
|
+
configurable: false,
|
|
1076
|
+
enumerable: false
|
|
1077
|
+
});
|
|
1078
|
+
Object.setPrototypeOf(ret, interfaceProto);
|
|
1079
|
+
return ret;
|
|
1080
|
+
}
|
|
1081
|
+
Object.defineProperty(objectProto, "$as", {
|
|
1082
|
+
value: $as,
|
|
1083
|
+
configurable: false
|
|
1084
|
+
});
|
|
1085
|
+
return objectProto;
|
|
1035
1086
|
}
|
|
1036
1087
|
function createConverter(objDef) {
|
|
1037
1088
|
const steps = [];
|
|
@@ -1062,7 +1113,58 @@ var protoConverterCache = createCache((client, objectDef) => {
|
|
|
1062
1113
|
converter
|
|
1063
1114
|
};
|
|
1064
1115
|
});
|
|
1065
|
-
async function
|
|
1116
|
+
async function convertWireToOsdkObjects(client, objects, interfaceApiName) {
|
|
1117
|
+
fixObjectPropertiesInline(objects);
|
|
1118
|
+
const localObjectCache = createLocalObjectCacheAndInitiatePreseed(objects, client);
|
|
1119
|
+
for (const obj of objects) {
|
|
1120
|
+
const objectDef = await localObjectCache.get(client, obj.$apiName);
|
|
1121
|
+
if (objectDef == null) {
|
|
1122
|
+
throw new Error(`Failed to find ontology definition for '${obj.$apiName}'`);
|
|
1123
|
+
}
|
|
1124
|
+
if (interfaceApiName !== void 0) {
|
|
1125
|
+
for (const [sptProp, regularProp] of Object.entries(objectDef.spts)) {
|
|
1126
|
+
if (sptProp in obj) {
|
|
1127
|
+
const value = obj[sptProp];
|
|
1128
|
+
delete obj[sptProp];
|
|
1129
|
+
if (value !== void 0) {
|
|
1130
|
+
obj[regularProp] = value;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
internalConvertObjectInPlace(objectDef, client, obj);
|
|
1136
|
+
}
|
|
1137
|
+
if (interfaceApiName) {
|
|
1138
|
+
return objects.map((o) => o.$as(interfaceApiName));
|
|
1139
|
+
} else {
|
|
1140
|
+
return objects;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
function createLocalObjectCacheAndInitiatePreseed(objects, client) {
|
|
1144
|
+
const localInterfaceCache = createAsyncCache((client2, apiName) => client2.ontology.provider.getInterfaceDefinition(apiName));
|
|
1145
|
+
const localObjectCache = createAsyncCache(async (client2, apiName) => {
|
|
1146
|
+
const objectDef = await client2.ontology.provider.getObjectDefinition(apiName);
|
|
1147
|
+
if (objectDef[InterfaceDefinitions] == null) {
|
|
1148
|
+
const interfaceDefs = Object.fromEntries((await Promise.all(objectDef.implements?.map((i) => localInterfaceCache.get(client2, i)) ?? [])).map((i) => [i.apiName, i]));
|
|
1149
|
+
Object.defineProperty(objectDef, InterfaceDefinitions, {
|
|
1150
|
+
value: interfaceDefs,
|
|
1151
|
+
enumerable: false,
|
|
1152
|
+
configurable: false,
|
|
1153
|
+
writable: false
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
return objectDef;
|
|
1157
|
+
});
|
|
1158
|
+
const uniqueApiNames = /* @__PURE__ */ new Set();
|
|
1159
|
+
for (const {
|
|
1160
|
+
$apiName
|
|
1161
|
+
} of objects) {
|
|
1162
|
+
uniqueApiNames.add($apiName);
|
|
1163
|
+
}
|
|
1164
|
+
Array.from(uniqueApiNames).map((n) => localObjectCache.get(client, n).then((a) => a.implements?.map((i) => localInterfaceCache.get(client, i))));
|
|
1165
|
+
return localObjectCache;
|
|
1166
|
+
}
|
|
1167
|
+
function fixObjectPropertiesInline(objs) {
|
|
1066
1168
|
for (const obj of objs) {
|
|
1067
1169
|
if (obj.__rid) {
|
|
1068
1170
|
obj.$rid = obj.__rid;
|
|
@@ -1082,45 +1184,73 @@ async function convertWireToOsdkObjectsInPlace(client, objs) {
|
|
|
1082
1184
|
});
|
|
1083
1185
|
}
|
|
1084
1186
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
Object.defineProperty(obj, OriginClient, {
|
|
1101
|
-
value: client,
|
|
1102
|
-
enumerable: false,
|
|
1103
|
-
configurable: false,
|
|
1104
|
-
writable: false
|
|
1105
|
-
});
|
|
1106
|
-
if (converter) {
|
|
1107
|
-
converter(obj);
|
|
1108
|
-
}
|
|
1187
|
+
}
|
|
1188
|
+
function internalConvertObjectInPlace(objectDef, client, obj) {
|
|
1189
|
+
const {
|
|
1190
|
+
proto,
|
|
1191
|
+
converter
|
|
1192
|
+
} = protoConverterCache.get(client, objectDef);
|
|
1193
|
+
Object.setPrototypeOf(obj, proto);
|
|
1194
|
+
Object.defineProperty(obj, OriginClient, {
|
|
1195
|
+
value: client,
|
|
1196
|
+
enumerable: false,
|
|
1197
|
+
configurable: false,
|
|
1198
|
+
writable: false
|
|
1199
|
+
});
|
|
1200
|
+
if (converter) {
|
|
1201
|
+
converter(obj);
|
|
1109
1202
|
}
|
|
1110
1203
|
}
|
|
1111
1204
|
|
|
1112
1205
|
// src/object/fetchPage.ts
|
|
1206
|
+
function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = void 0) {
|
|
1207
|
+
if (objectSet.type === "base") {
|
|
1208
|
+
if (objectSet.objectType !== expectedApiName) {
|
|
1209
|
+
throw new Error(`Expected objectSet.objectType to be ${expectedApiName}, but got ${objectSet.objectType}`);
|
|
1210
|
+
}
|
|
1211
|
+
return existingWhere;
|
|
1212
|
+
}
|
|
1213
|
+
if (objectSet.type === "filter") {
|
|
1214
|
+
return objectSetToSearchJsonV2(objectSet.objectSet, expectedApiName, existingWhere == null ? objectSet.where : {
|
|
1215
|
+
type: "and",
|
|
1216
|
+
value: [existingWhere, objectSet.where]
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
|
|
1220
|
+
}
|
|
1221
|
+
async function fetchInterfacePage(client, interfaceType, args, objectSet) {
|
|
1222
|
+
const result = await requests.searchObjectsForInterface(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, interfaceType.apiName, applyFetchArgs(args, {
|
|
1223
|
+
augmentedProperties: {},
|
|
1224
|
+
augmentedSharedPropertyTypes: {},
|
|
1225
|
+
otherInterfaceTypes: [],
|
|
1226
|
+
selectedObjectTypes: [],
|
|
1227
|
+
selectedSharedPropertyTypes: args.select ?? [],
|
|
1228
|
+
where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)
|
|
1229
|
+
}), {
|
|
1230
|
+
preview: true
|
|
1231
|
+
});
|
|
1232
|
+
result.data = await convertWireToOsdkObjects(
|
|
1233
|
+
client,
|
|
1234
|
+
result.data,
|
|
1235
|
+
// drop readonly
|
|
1236
|
+
interfaceType.apiName
|
|
1237
|
+
);
|
|
1238
|
+
return result;
|
|
1239
|
+
}
|
|
1240
|
+
async function fetchPageInternal(client, objectType, objectSet, args = {}) {
|
|
1241
|
+
if (objectType.type === "interface") {
|
|
1242
|
+
return await fetchInterfacePage(client, objectType, args, objectSet);
|
|
1243
|
+
} else {
|
|
1244
|
+
return await fetchObjectPage(client, objectType, args, objectSet);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1113
1247
|
async function fetchPage(client, objectType, args, objectSet = {
|
|
1114
1248
|
type: "base",
|
|
1115
1249
|
objectType: objectType["apiName"]
|
|
1116
1250
|
}) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
select: args?.select ?? [],
|
|
1121
|
-
// FIXME?
|
|
1122
|
-
excludeRid: !args?.includeRid
|
|
1123
|
-
};
|
|
1251
|
+
return fetchPageInternal(client, objectType, objectSet, args);
|
|
1252
|
+
}
|
|
1253
|
+
function applyFetchArgs(args, body) {
|
|
1124
1254
|
if (args?.nextPageToken) {
|
|
1125
1255
|
body.pageToken = args.nextPageToken;
|
|
1126
1256
|
}
|
|
@@ -1135,17 +1265,32 @@ async function fetchPage(client, objectType, args, objectSet = {
|
|
|
1135
1265
|
}))
|
|
1136
1266
|
};
|
|
1137
1267
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1268
|
+
return body;
|
|
1269
|
+
}
|
|
1270
|
+
async function fetchObjectPage(client, objectType, args, objectSet) {
|
|
1271
|
+
const r = await requests.loadObjectSetV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, applyFetchArgs(args, {
|
|
1272
|
+
objectSet,
|
|
1273
|
+
// We have to do the following case because LoadObjectSetRequestV2 isnt readonly
|
|
1274
|
+
select: args?.select ?? [],
|
|
1275
|
+
// FIXME?
|
|
1276
|
+
excludeRid: !args?.includeRid
|
|
1277
|
+
}));
|
|
1278
|
+
return Promise.resolve({
|
|
1279
|
+
data: await convertWireToOsdkObjects(client, r.data, void 0),
|
|
1280
|
+
nextPageToken: r.nextPageToken
|
|
1281
|
+
});
|
|
1141
1282
|
}
|
|
1142
1283
|
|
|
1143
1284
|
exports.aggregate = aggregate;
|
|
1144
1285
|
exports.createAsyncCache = createAsyncCache;
|
|
1145
|
-
exports.createBaseObjectSet = createBaseObjectSet;
|
|
1146
1286
|
exports.createObjectSet = createObjectSet2;
|
|
1147
1287
|
exports.fetchPage = fetchPage;
|
|
1288
|
+
exports.getWireObjectSet = getWireObjectSet;
|
|
1148
1289
|
exports.isAttachment = isAttachment;
|
|
1290
|
+
exports.isObjectSet = isObjectSet;
|
|
1291
|
+
exports.isWireObjectSet = isWireObjectSet;
|
|
1292
|
+
exports.loadAllOntologies = loadAllOntologies;
|
|
1293
|
+
exports.loadOntologyEntities = loadOntologyEntities;
|
|
1149
1294
|
exports.object_exports = object_exports;
|
|
1150
1295
|
//# sourceMappingURL=out.js.map
|
|
1151
|
-
//# sourceMappingURL=chunk-
|
|
1296
|
+
//# sourceMappingURL=chunk-CKYBATFN.cjs.map
|