@osdk/client 0.20.0-beta.2 → 0.20.0-beta.4

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +47 -5
  2. package/build/browser/{chunk-Y6GMYWXB.js → chunk-3ZYIZQ7V.js} +348 -76
  3. package/build/browser/chunk-3ZYIZQ7V.js.map +1 -0
  4. package/build/browser/index.js +2 -2
  5. package/build/browser/public/unstable-do-not-use.js +10 -12
  6. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  7. package/build/cjs/{chunk-VG5EKGOO.cjs → chunk-4FXEPHWC.cjs} +348 -76
  8. package/build/cjs/chunk-4FXEPHWC.cjs.map +1 -0
  9. package/build/cjs/index.cjs +5 -5
  10. package/build/cjs/public/unstable-do-not-use.cjs +15 -17
  11. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  12. package/build/esm/Client.d.ts +3 -2
  13. package/build/esm/Client.d.ts.map +1 -1
  14. package/build/esm/MinimalClientContext.d.ts +8 -2
  15. package/build/esm/MinimalClientContext.d.ts.map +1 -1
  16. package/build/esm/{chunk-2XJ62QSF.js → chunk-MD6R46EZ.js} +348 -76
  17. package/build/esm/chunk-MD6R46EZ.js.map +1 -0
  18. package/build/esm/createClient.d.ts +2 -2
  19. package/build/esm/createClient.d.ts.map +1 -1
  20. package/build/esm/createMinimalClient.d.ts.map +1 -1
  21. package/build/esm/index.js +2 -2
  22. package/build/esm/object/Cache.d.ts +1 -1
  23. package/build/esm/object/Cache.d.ts.map +1 -1
  24. package/build/esm/object/SimpleCache.d.ts +1 -1
  25. package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
  26. package/build/esm/objectSet/createObjectSet.d.ts.map +1 -1
  27. package/build/esm/ontology/loadFullObjectMetadata.d.ts +1 -1
  28. package/build/esm/ontology/loadFullObjectMetadata.d.ts.map +1 -1
  29. package/build/esm/ontology/loadInterfaceDefinition.d.ts +1 -1
  30. package/build/esm/ontology/loadInterfaceDefinition.d.ts.map +1 -1
  31. package/build/esm/public/unstable-do-not-use.js +10 -12
  32. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  33. package/build/esm/queries/applyQuery.d.ts +6 -0
  34. package/build/esm/queries/applyQuery.d.ts.map +1 -0
  35. package/build/esm/queries/createQueryInvoker.d.ts +5 -0
  36. package/build/esm/queries/createQueryInvoker.d.ts.map +1 -0
  37. package/build/esm/queries/queries.test.d.ts +2 -0
  38. package/build/esm/queries/queries.test.d.ts.map +1 -0
  39. package/build/esm/util/isOsdkBaseObject.d.ts +3 -0
  40. package/build/esm/util/isOsdkBaseObject.d.ts.map +1 -0
  41. package/build/esm/util/isOsdkObject.d.ts +3 -0
  42. package/build/esm/util/isOsdkObject.d.ts.map +1 -0
  43. package/build/esm/util/toDataValue.d.ts.map +1 -1
  44. package/build/esm/util/toDataValueQueries.d.ts +10 -0
  45. package/build/esm/util/toDataValueQueries.d.ts.map +1 -0
  46. package/package.json +25 -18
  47. package/build/browser/chunk-Y6GMYWXB.js.map +0 -1
  48. package/build/cjs/chunk-VG5EKGOO.cjs.map +0 -1
  49. package/build/esm/chunk-2XJ62QSF.js.map +0 -1
@@ -12,14 +12,13 @@ var __export = (target, all) => {
12
12
  __defProp(target, name, { get: all[name], enumerable: true });
13
13
  };
14
14
 
15
- // ../internal.foundry.datasets/build/esm/chunk-CSAU5B4Q.js
15
+ // ../internal.foundry.datasets/build/esm/chunk-PZ5AY32C.js
16
16
  var __defProp2 = Object.defineProperty;
17
17
  var __export2 = (target, all) => {
18
- for (var name in all)
19
- __defProp2(target, name, {
20
- get: all[name],
21
- enumerable: true
22
- });
18
+ for (var name in all) __defProp2(target, name, {
19
+ get: all[name],
20
+ enumerable: true
21
+ });
23
22
  };
24
23
  async function foundryPlatformFetch(client, [httpMethodNum, origPath, flags, contentType, responseContentType], ...args) {
25
24
  const path = origPath.replace(/\{([^}]+)\}/g, () => encodeURIComponent(args.shift()));
@@ -77,7 +76,7 @@ async function apiFetch(clientCtx, method, endpointPath, data, queryArguments, h
77
76
  return response.blob();
78
77
  }
79
78
 
80
- // ../internal.foundry.datasets/build/esm/chunk-YPYY5DPJ.js
79
+ // ../internal.foundry.datasets/build/esm/chunk-3STPFXHE.js
81
80
  var Branch_exports = {};
82
81
  __export2(Branch_exports, {
83
82
  createBranch: () => createBranch,
@@ -102,7 +101,7 @@ function deleteBranch($ctx, ...args) {
102
101
  return foundryPlatformFetch($ctx, _deleteBranch, ...args);
103
102
  }
104
103
 
105
- // ../internal.foundry.datasets/build/esm/chunk-Q6FZUZ4K.js
104
+ // ../internal.foundry.datasets/build/esm/chunk-5ZK5IVCS.js
106
105
  var Dataset_exports = {};
107
106
  __export2(Dataset_exports, {
108
107
  createDataset: () => createDataset,
@@ -137,7 +136,7 @@ function deleteSchema($ctx, ...args) {
137
136
  return foundryPlatformFetch($ctx, _deleteSchema, ...args);
138
137
  }
139
138
 
140
- // ../internal.foundry.datasets/build/esm/chunk-UJYKN4YN.js
139
+ // ../internal.foundry.datasets/build/esm/chunk-N55YZHZU.js
141
140
  var File_exports = {};
142
141
  __export2(File_exports, {
143
142
  deleteFile: () => deleteFile,
@@ -167,7 +166,7 @@ function getFileContent($ctx, ...args) {
167
166
  return foundryPlatformFetch($ctx, _getFileContent, ...args);
168
167
  }
169
168
 
170
- // ../internal.foundry.datasets/build/esm/chunk-5RKMNE66.js
169
+ // ../internal.foundry.datasets/build/esm/chunk-267TDC7H.js
171
170
  var Transaction_exports = {};
172
171
  __export2(Transaction_exports, {
173
172
  abortTransaction: () => abortTransaction,
@@ -192,14 +191,13 @@ function abortTransaction($ctx, ...args) {
192
191
  return foundryPlatformFetch($ctx, _abortTransaction, ...args);
193
192
  }
194
193
 
195
- // ../internal.foundry.models/build/esm/chunk-SJUC7YTI.js
194
+ // ../internal.foundry.models/build/esm/chunk-IOTKXOZ6.js
196
195
  var __defProp3 = Object.defineProperty;
197
196
  var __export3 = (target, all) => {
198
- for (var name in all)
199
- __defProp3(target, name, {
200
- get: all[name],
201
- enumerable: true
202
- });
197
+ for (var name in all) __defProp3(target, name, {
198
+ get: all[name],
199
+ enumerable: true
200
+ });
203
201
  };
204
202
  var LanguageModel_exports = {};
205
203
  __export3(LanguageModel_exports, {
@@ -231,17 +229,16 @@ __export(esm_exports, {
231
229
  QueryTypes: () => QueryType_exports
232
230
  });
233
231
 
234
- // ../internal.foundry.ontologies/build/esm/chunk-CSAU5B4Q.js
232
+ // ../internal.foundry.ontologies/build/esm/chunk-PZ5AY32C.js
235
233
  var __defProp4 = Object.defineProperty;
236
234
  var __export4 = (target, all) => {
237
- for (var name in all)
238
- __defProp4(target, name, {
239
- get: all[name],
240
- enumerable: true
241
- });
235
+ for (var name in all) __defProp4(target, name, {
236
+ get: all[name],
237
+ enumerable: true
238
+ });
242
239
  };
243
240
 
244
- // ../internal.foundry.ontologies/build/esm/chunk-UV55E7D4.js
241
+ // ../internal.foundry.ontologies/build/esm/chunk-LTUKKONO.js
245
242
  var ActionType_exports = {};
246
243
  __export4(ActionType_exports, {
247
244
  applyAction: () => applyAction,
@@ -281,7 +278,7 @@ function validateAction($ctx, ...args) {
281
278
  return foundryPlatformFetch($ctx, _validateAction, ...args);
282
279
  }
283
280
 
284
- // ../internal.foundry.ontologies/build/esm/chunk-KU7N4OS3.js
281
+ // ../internal.foundry.ontologies/build/esm/chunk-67IRYQ4I.js
285
282
  var Attachment_exports = {};
286
283
  __export4(Attachment_exports, {
287
284
  getAttachment: () => getAttachment,
@@ -301,7 +298,7 @@ function getAttachment($ctx, ...args) {
301
298
  return foundryPlatformFetch($ctx, _getAttachment, ...args);
302
299
  }
303
300
 
304
- // ../internal.foundry.ontologies/build/esm/chunk-K2FHVG2O.js
301
+ // ../internal.foundry.ontologies/build/esm/chunk-JDBI2K4S.js
305
302
  var ObjectType_exports = {};
306
303
  __export4(ObjectType_exports, {
307
304
  getObjectType: () => getObjectType,
@@ -326,7 +323,7 @@ function getOutgoingLinkType($ctx, ...args) {
326
323
  return foundryPlatformFetch($ctx, _getOutgoingLinkType, ...args);
327
324
  }
328
325
 
329
- // ../internal.foundry.ontologies/build/esm/chunk-LB4RYVNQ.js
326
+ // ../internal.foundry.ontologies/build/esm/chunk-6OWDPN5M.js
330
327
  var Ontology_exports = {};
331
328
  __export4(Ontology_exports, {
332
329
  getOntology: () => getOntology,
@@ -341,7 +338,7 @@ function getOntology($ctx, ...args) {
341
338
  return foundryPlatformFetch($ctx, _getOntology, ...args);
342
339
  }
343
340
 
344
- // ../internal.foundry.ontologies/build/esm/chunk-FANEAZUW.js
341
+ // ../internal.foundry.ontologies/build/esm/chunk-M2AD7ARN.js
345
342
  var OntologyObject_exports = {};
346
343
  __export4(OntologyObject_exports, {
347
344
  aggregateObjects: () => aggregateObjects,
@@ -376,7 +373,7 @@ function aggregateObjects($ctx, ...args) {
376
373
  return foundryPlatformFetch($ctx, _aggregateObjects, ...args);
377
374
  }
378
375
 
379
- // ../internal.foundry.ontologies/build/esm/chunk-CRDBJVD6.js
376
+ // ../internal.foundry.ontologies/build/esm/chunk-CBKBUZ63.js
380
377
  var QueryType_exports = {};
381
378
  __export4(QueryType_exports, {
382
379
  executeQuery: () => executeQuery,
@@ -408,17 +405,16 @@ __export(esm_exports2, {
408
405
  QueryTypes: () => QueryType_exports2
409
406
  });
410
407
 
411
- // ../internal.foundry.ontologiesv2/build/esm/chunk-CSAU5B4Q.js
408
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-PZ5AY32C.js
412
409
  var __defProp5 = Object.defineProperty;
413
410
  var __export5 = (target, all) => {
414
- for (var name in all)
415
- __defProp5(target, name, {
416
- get: all[name],
417
- enumerable: true
418
- });
411
+ for (var name in all) __defProp5(target, name, {
412
+ get: all[name],
413
+ enumerable: true
414
+ });
419
415
  };
420
416
 
421
- // ../internal.foundry.ontologiesv2/build/esm/chunk-UVEI3RO3.js
417
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-B5JRDCDE.js
422
418
  var Action_exports = {};
423
419
  __export5(Action_exports, {
424
420
  applyActionAsyncV2: () => applyActionAsyncV2,
@@ -438,7 +434,7 @@ function applyActionAsyncV2($ctx, ...args) {
438
434
  return foundryPlatformFetch($ctx, _applyActionAsyncV2, ...args);
439
435
  }
440
436
 
441
- // ../internal.foundry.ontologiesv2/build/esm/chunk-GCLYROAR.js
437
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-G4A4IJCI.js
442
438
  var ActionTypeV2_exports = {};
443
439
  __export5(ActionTypeV2_exports, {
444
440
  getActionTypeV2: () => getActionTypeV2,
@@ -453,7 +449,7 @@ function getActionTypeV2($ctx, ...args) {
453
449
  return foundryPlatformFetch($ctx, _getActionTypeV2, ...args);
454
450
  }
455
451
 
456
- // ../internal.foundry.ontologiesv2/build/esm/chunk-GUSJ3JXB.js
452
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-6LZM4EP4.js
457
453
  var ObjectTypeV2_exports = {};
458
454
  __export5(ObjectTypeV2_exports, {
459
455
  getObjectTypeV2: () => getObjectTypeV2,
@@ -478,7 +474,7 @@ function getOutgoingLinkTypeV2($ctx, ...args) {
478
474
  return foundryPlatformFetch($ctx, _getOutgoingLinkTypeV2, ...args);
479
475
  }
480
476
 
481
- // ../internal.foundry.ontologiesv2/build/esm/chunk-ADT7WVKJ.js
477
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-TJX6RHXS.js
482
478
  var OntologyObjectSet_exports = {};
483
479
  __export5(OntologyObjectSet_exports, {
484
480
  aggregateObjectSetV2: () => aggregateObjectSetV2,
@@ -503,7 +499,7 @@ function aggregateObjectSetV2($ctx, ...args) {
503
499
  return foundryPlatformFetch($ctx, _aggregateObjectSetV2, ...args);
504
500
  }
505
501
 
506
- // ../internal.foundry.ontologiesv2/build/esm/chunk-S2FR63YP.js
502
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-U2YDEYVP.js
507
503
  var OntologyObjectV2_exports = {};
508
504
  __export5(OntologyObjectV2_exports, {
509
505
  aggregateObjectsForInterface: () => aggregateObjectsForInterface,
@@ -603,7 +599,7 @@ function getObjectTypeFullMetadata($ctx, ...args) {
603
599
  return foundryPlatformFetch($ctx, _getObjectTypeFullMetadata, ...args);
604
600
  }
605
601
 
606
- // ../internal.foundry.ontologiesv2/build/esm/chunk-QZMDTH3J.js
602
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-5MBQRC34.js
607
603
  var OntologyV2_exports = {};
608
604
  __export5(OntologyV2_exports, {
609
605
  getOntologyFullMetadata: () => getOntologyFullMetadata,
@@ -623,7 +619,7 @@ function getOntologyFullMetadata($ctx, ...args) {
623
619
  return foundryPlatformFetch($ctx, _getOntologyFullMetadata, ...args);
624
620
  }
625
621
 
626
- // ../internal.foundry.ontologiesv2/build/esm/chunk-HLZX6UUL.js
622
+ // ../internal.foundry.ontologiesv2/build/esm/chunk-ASYINYCV.js
627
623
  var QueryType_exports2 = {};
628
624
  __export5(QueryType_exports2, {
629
625
  executeQueryV2: () => executeQueryV2,
@@ -672,10 +668,10 @@ function addUserAgent(client, withMetadata) {
672
668
  function createClientCache(fn) {
673
669
  const cache = /* @__PURE__ */ new WeakMap();
674
670
  function get(client, key) {
675
- if (cache.get(client) == null) {
676
- cache.set(client, /* @__PURE__ */ new Map());
671
+ if (cache.get(client.clientCacheKey) == null) {
672
+ cache.set(client.clientCacheKey, /* @__PURE__ */ new Map());
677
673
  }
678
- let r = cache.get(client).get(key);
674
+ let r = cache.get(client.clientCacheKey).get(key);
679
675
  if (r === void 0 && fn !== void 0) {
680
676
  return set(client, key, fn(client, key));
681
677
  } else {
@@ -683,16 +679,15 @@ function createClientCache(fn) {
683
679
  }
684
680
  }
685
681
  function set(client, key, value) {
686
- if (cache.get(client) == null) {
687
- cache.set(client, /* @__PURE__ */ new Map());
682
+ if (cache.get(client.clientCacheKey) == null) {
683
+ cache.set(client.clientCacheKey, /* @__PURE__ */ new Map());
688
684
  }
689
- cache.get(client).set(key, value);
685
+ cache.get(client.clientCacheKey).set(key, value);
690
686
  return value;
691
687
  }
692
688
  function remove(client, key) {
693
- if (cache.get(client) == null)
694
- return false;
695
- return cache.get(client).delete(key);
689
+ if (cache.get(client.clientCacheKey) == null) return false;
690
+ return cache.get(client.clientCacheKey).delete(key);
696
691
  }
697
692
  return {
698
693
  get,
@@ -797,8 +792,7 @@ function customInspect(_depth, options, localInspect) {
797
792
  let ret = `Osdk<${options.stylize(this[ObjectDefRef]?.apiName ?? this[InterfaceDefRef]?.apiName, "special")}> {
798
793
  `;
799
794
  for (const k of /* @__PURE__ */ new Set(["$apiName", "$objectType", "$primaryKey", ...Reflect.ownKeys(this)])) {
800
- if (typeof k === "symbol")
801
- continue;
795
+ if (typeof k === "symbol") continue;
802
796
  ret += ` ${options.stylize(k.toString(), "undefined")}: ${localInspect(this[k], newOptions)}
803
797
  `;
804
798
  }
@@ -905,8 +899,7 @@ function $asFactory(objDef) {
905
899
  }
906
900
  const underlying = this[UnderlyingOsdkObject];
907
901
  const existing = osdkObjectToInterfaceView.get(underlying).get(newDef.apiName);
908
- if (existing)
909
- return existing;
902
+ if (existing) return existing;
910
903
  const osdkInterface = createOsdkInterface(underlying, newDef);
911
904
  osdkObjectToInterfaceView.get(underlying).set(newDef.apiName, osdkInterface);
912
905
  return osdkInterface;
@@ -1074,8 +1067,7 @@ function modernToLegacyAggregationClause(select) {
1074
1067
  });
1075
1068
  }
1076
1069
  function modernToLegacyGroupByClause(groupByClause) {
1077
- if (!groupByClause)
1078
- return [];
1070
+ if (!groupByClause) return [];
1079
1071
  return Object.entries(groupByClause).flatMap(([field, type]) => {
1080
1072
  if (type === "exact") {
1081
1073
  return [{
@@ -1109,8 +1101,7 @@ function modernToLegacyGroupByClause(groupByClause) {
1109
1101
  value: type.$duration[0],
1110
1102
  unit: DurationMapping[type.$duration[1]]
1111
1103
  }];
1112
- } else
1113
- return [];
1104
+ } else return [];
1114
1105
  });
1115
1106
  }
1116
1107
  function convertRange(range) {
@@ -1136,7 +1127,7 @@ async function aggregate(clientCtx, objectType, objectSet = {
1136
1127
  if (req.$where) {
1137
1128
  body.where = modernToLegacyWhereClause(req.$where);
1138
1129
  }
1139
- const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(addUserAgent(clientCtx, objectType), clientCtx.ontologyRid, {
1130
+ const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(addUserAgent(clientCtx, objectType), await clientCtx.ontologyRid, {
1140
1131
  objectSet,
1141
1132
  groupBy: body.groupBy,
1142
1133
  aggregation: body.aggregation
@@ -1253,6 +1244,7 @@ function createObjectSet(objectType, clientCtx, objectSet = {
1253
1244
  const result = await base.fetchPage({
1254
1245
  $nextPageToken
1255
1246
  });
1247
+ $nextPageToken = result.nextPageToken;
1256
1248
  for (const obj of result.data) {
1257
1249
  yield obj;
1258
1250
  }
@@ -1380,8 +1372,7 @@ function createOsdkObject(client, objectDef, rawObj) {
1380
1372
  case UnderlyingOsdkObject:
1381
1373
  return receiver;
1382
1374
  }
1383
- if (p in target)
1384
- return target[p];
1375
+ if (p in target) return target[p];
1385
1376
  if (p in rawObj) {
1386
1377
  const rawValue = target[RawObject][p];
1387
1378
  const propDef = objectDef.properties[p];
@@ -1448,8 +1439,7 @@ async function convertWireToOsdkObjects(client, objects, interfaceApiName, force
1448
1439
  continue;
1449
1440
  }
1450
1441
  let osdkObject = createOsdkObject(client, objectDef, rawObj);
1451
- if (interfaceApiName)
1452
- osdkObject = osdkObject.$as(interfaceApiName);
1442
+ if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);
1453
1443
  ret.push(osdkObject);
1454
1444
  }
1455
1445
  client.logger?.debug(`END convertWireToOsdkObjects()`);
@@ -1542,7 +1532,7 @@ function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = voi
1542
1532
  throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
1543
1533
  }
1544
1534
  async function fetchInterfacePage(client, interfaceType, args, objectSet) {
1545
- const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(addUserAgent(client, interfaceType), client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
1535
+ const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(addUserAgent(client, interfaceType), await client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
1546
1536
  augmentedProperties: args.$augment ?? {},
1547
1537
  augmentedSharedPropertyTypes: {},
1548
1538
  otherInterfaceTypes: [],
@@ -1609,9 +1599,9 @@ function applyFetchArgs(args, body) {
1609
1599
  return body;
1610
1600
  }
1611
1601
  async function fetchObjectPage(client, objectType, args, objectSet) {
1612
- const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgent(client, objectType), client.ontologyRid, applyFetchArgs(args, {
1602
+ const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgent(client, objectType), await client.ontologyRid, applyFetchArgs(args, {
1613
1603
  objectSet,
1614
- // We have to do the following case because LoadObjectSetRequestV2 isnt readonly
1604
+ // We have to do the following case because LoadObjectSetRequestV2 isn't readonly
1615
1605
  select: args?.$select ?? [],
1616
1606
  // FIXME?
1617
1607
  excludeRid: !args?.$includeRid
@@ -1640,6 +1630,11 @@ function isOntologyObjectV2(o) {
1640
1630
  return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
1641
1631
  }
1642
1632
 
1633
+ // src/util/isOsdkObject.ts
1634
+ function isOsdkBaseObject(o) {
1635
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1636
+ }
1637
+
1643
1638
  // src/util/toDataValue.ts
1644
1639
  async function toDataValue(value, client) {
1645
1640
  if (value == null) {
@@ -1661,6 +1656,9 @@ async function toDataValue(value, client) {
1661
1656
  if (isOntologyObjectV2(value)) {
1662
1657
  return await toDataValue(value.__primaryKey, client);
1663
1658
  }
1659
+ if (isOsdkBaseObject(value)) {
1660
+ return await toDataValue(value.$primaryKey, client);
1661
+ }
1664
1662
  if (isWireObjectSet(value)) {
1665
1663
  return value;
1666
1664
  }
@@ -1680,7 +1678,7 @@ async function toDataValue(value, client) {
1680
1678
  // src/actions/applyAction.ts
1681
1679
  async function applyAction2(client, action, parameters, options = {}) {
1682
1680
  if (Array.isArray(parameters)) {
1683
- const response = await esm_exports2.Actions.applyActionBatchV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
1681
+ const response = await esm_exports2.Actions.applyActionBatchV2(addUserAgent(client, action), await client.ontologyRid, action.apiName, {
1684
1682
  requests: parameters ? await remapBatchActionParams(parameters, client) : [],
1685
1683
  options: {
1686
1684
  returnEdits: options?.$returnEdits ? "ALL" : "NONE"
@@ -1688,7 +1686,7 @@ async function applyAction2(client, action, parameters, options = {}) {
1688
1686
  });
1689
1687
  return options?.$returnEdits ? response.edits : void 0;
1690
1688
  } else {
1691
- const response = await esm_exports2.Actions.applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
1689
+ const response = await esm_exports2.Actions.applyActionV2(addUserAgent(client, action), await client.ontologyRid, action.apiName, {
1692
1690
  parameters: await remapActionParams(parameters, client),
1693
1691
  options: {
1694
1692
  mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
@@ -1722,19 +1720,19 @@ async function remapBatchActionParams(params, client) {
1722
1720
  }));
1723
1721
  return remappedParams;
1724
1722
  }
1725
- async function loadFullObjectMetadata(client, objtype) {
1726
- const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, client.ontologyRid, objtype, {
1723
+ async function loadFullObjectMetadata(client, objectType) {
1724
+ const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid, objectType, {
1727
1725
  preview: true
1728
1726
  });
1729
1727
  const ret = wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
1730
- client.logger?.debug(`END loadFullObjectMetadata(${objtype})`);
1728
+ client.logger?.debug(`END loadFullObjectMetadata(${objectType})`);
1731
1729
  return {
1732
1730
  ...ret,
1733
1731
  rid: full.objectType.rid
1734
1732
  };
1735
1733
  }
1736
- async function loadInterfaceDefinition(client, objtype) {
1737
- const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, client.ontologyRid, objtype, {
1734
+ async function loadInterfaceDefinition(client, objectType) {
1735
+ const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid, objectType, {
1738
1736
  preview: true
1739
1737
  });
1740
1738
  return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
@@ -1775,7 +1773,7 @@ var createStandardOntologyProviderFactory = (client) => {
1775
1773
  };
1776
1774
 
1777
1775
  // src/util/UserAgent.ts
1778
- var USER_AGENT = `osdk-client/${"0.20.0-beta.2"}`;
1776
+ var USER_AGENT = `osdk-client/${"0.20.0-beta.4"}`;
1779
1777
 
1780
1778
  // src/createMinimalClient.ts
1781
1779
  function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
@@ -1791,13 +1789,285 @@ function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fet
1791
1789
  ...createSharedClientContext(baseUrl, tokenProvider, USER_AGENT, fetchFn),
1792
1790
  objectSetFactory,
1793
1791
  ontologyRid: metadata.ontologyRid,
1794
- logger: options.logger
1792
+ logger: options.logger,
1793
+ clientCacheKey: {}
1795
1794
  };
1796
1795
  return Object.assign(minimalClient, {
1797
1796
  ontologyProvider: createStandardOntologyProviderFactory()(minimalClient)
1798
1797
  });
1799
1798
  }
1800
1799
 
1800
+ // src/util/isOsdkBaseObject.ts
1801
+ function isOsdkBaseObject2(o) {
1802
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1803
+ }
1804
+
1805
+ // src/util/toDataValueQueries.ts
1806
+ async function toDataValueQueries(value, client, desiredType) {
1807
+ if (value == null) {
1808
+ return value;
1809
+ }
1810
+ if (Array.isArray(value) && desiredType.multiplicity) {
1811
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType));
1812
+ return Promise.all(promiseArray);
1813
+ }
1814
+ switch (desiredType.type) {
1815
+ case "attachment": {
1816
+ if (isAttachmentUpload(value)) {
1817
+ const attachment = await esm_exports.Attachments.uploadAttachment(client, value, {
1818
+ filename: value.name
1819
+ }, {
1820
+ "Content-Length": value.size.toString(),
1821
+ "Content-Type": value.type
1822
+ });
1823
+ return attachment.rid;
1824
+ }
1825
+ return value;
1826
+ }
1827
+ case "twoDimensionalAggregation": {
1828
+ return {
1829
+ groups: value
1830
+ };
1831
+ }
1832
+ case "threeDimensionalAggregation": {
1833
+ return {
1834
+ groups: value
1835
+ };
1836
+ }
1837
+ case "set": {
1838
+ if (value instanceof Set) {
1839
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType["set"]));
1840
+ return Promise.all(promiseArray);
1841
+ }
1842
+ break;
1843
+ }
1844
+ case "object": {
1845
+ if (isOsdkBaseObject2(value)) {
1846
+ return value.$primaryKey;
1847
+ }
1848
+ break;
1849
+ }
1850
+ case "objectSet": {
1851
+ if (isWireObjectSet(value)) {
1852
+ return value;
1853
+ }
1854
+ if (isObjectSet(value)) {
1855
+ return getWireObjectSet(value);
1856
+ }
1857
+ break;
1858
+ }
1859
+ case "struct": {
1860
+ if (typeof value === "object") {
1861
+ const structMap = {};
1862
+ for (const [key, structValue] of Object.entries(value)) {
1863
+ structMap[key] = await toDataValueQueries(structValue, client, desiredType["struct"][key]);
1864
+ }
1865
+ return structMap;
1866
+ }
1867
+ }
1868
+ case "boolean":
1869
+ case "date":
1870
+ case "double":
1871
+ case "float":
1872
+ case "integer":
1873
+ case "long":
1874
+ case "string":
1875
+ case "timestamp":
1876
+ return value;
1877
+ }
1878
+ return value;
1879
+ }
1880
+
1881
+ // src/queries/applyQuery.ts
1882
+ async function applyQuery(client, query, params) {
1883
+ const response = await esm_exports2.QueryTypes.executeQueryV2(addUserAgent(client, query), await client.ontologyRid, query.apiName, {
1884
+ parameters: params ? await remapQueryParams(params, client, query.parameters) : {}
1885
+ });
1886
+ const objectOutputDefs = await getRequiredDefinitions(query.output, client);
1887
+ const remappedResponse = await remapQueryResponse(client, query.output, response.value, objectOutputDefs);
1888
+ return remappedResponse;
1889
+ }
1890
+ async function remapQueryParams(params, client, paramTypes) {
1891
+ const parameterMap = {};
1892
+ for (const [key, value] of Object.entries(params)) {
1893
+ parameterMap[key] = await toDataValueQueries(value, client, paramTypes[key]);
1894
+ }
1895
+ return parameterMap;
1896
+ }
1897
+ async function remapQueryResponse(client, responseDataType, responseValue, definitions) {
1898
+ if (responseValue == null) {
1899
+ if (responseDataType.nullable) {
1900
+ return void 0;
1901
+ } else {
1902
+ throw new Error("Got null response when nullable was not allowed");
1903
+ }
1904
+ }
1905
+ if (responseDataType.multiplicity != null && responseDataType.multiplicity !== false) {
1906
+ const withoutMultiplicity = {
1907
+ ...responseDataType,
1908
+ multiplicity: false
1909
+ };
1910
+ for (let i = 0; i < responseValue.length; i++) {
1911
+ responseValue[i] = await remapQueryResponse(responseValue[i], withoutMultiplicity, client, definitions);
1912
+ }
1913
+ return responseValue;
1914
+ }
1915
+ switch (responseDataType.type) {
1916
+ case "union": {
1917
+ throw new Error("Union return types are not yet supported");
1918
+ }
1919
+ case "set": {
1920
+ for (let i = 0; i < responseValue.length; i++) {
1921
+ responseValue[i] = await remapQueryResponse(responseValue[i], responseDataType.set, client, definitions);
1922
+ }
1923
+ return responseValue;
1924
+ }
1925
+ case "attachment": {
1926
+ return createAttachmentFromRid(client, responseValue);
1927
+ }
1928
+ case "object": {
1929
+ const def = definitions.get(responseDataType.object);
1930
+ if (!def) {
1931
+ throw new Error(`Missing definition for ${responseDataType.object}`);
1932
+ }
1933
+ return createQueryObjectResponse(responseValue, def);
1934
+ }
1935
+ case "objectSet": {
1936
+ const def = definitions.get(responseDataType.objectSet);
1937
+ if (!def) {
1938
+ throw new Error(`Missing definition for ${responseDataType.objectSet}`);
1939
+ }
1940
+ if (typeof responseValue === "string") {
1941
+ return createObjectSet(def, client, {
1942
+ type: "intersect",
1943
+ objectSets: [{
1944
+ type: "base",
1945
+ objectType: responseDataType.objectSet
1946
+ }, {
1947
+ type: "reference",
1948
+ reference: responseValue
1949
+ }]
1950
+ });
1951
+ }
1952
+ return createObjectSet(def, client, responseValue);
1953
+ }
1954
+ case "struct": {
1955
+ for (const [key, subtype] of Object.entries(responseDataType.struct)) {
1956
+ if (requiresConversion(subtype)) {
1957
+ responseValue[key] = await remapQueryResponse(responseValue[key], subtype, client, definitions);
1958
+ }
1959
+ }
1960
+ return responseValue;
1961
+ }
1962
+ case "twoDimensionalAggregation": {
1963
+ const result = [];
1964
+ for (const {
1965
+ key,
1966
+ value
1967
+ } of responseValue.groups) {
1968
+ result.push({
1969
+ key,
1970
+ value
1971
+ });
1972
+ }
1973
+ return result;
1974
+ }
1975
+ case "threeDimensionalAggregation": {
1976
+ const result = [];
1977
+ for (const {
1978
+ key,
1979
+ groups
1980
+ } of responseValue.groups) {
1981
+ const subResult = [];
1982
+ for (const {
1983
+ key: subKey,
1984
+ value
1985
+ } of groups) {
1986
+ subResult.push({
1987
+ key: subKey,
1988
+ value
1989
+ });
1990
+ }
1991
+ result.push({
1992
+ key,
1993
+ groups: subResult
1994
+ });
1995
+ }
1996
+ return result;
1997
+ }
1998
+ }
1999
+ return responseValue;
2000
+ }
2001
+ async function getRequiredDefinitions(dataType, client) {
2002
+ const result = /* @__PURE__ */ new Map();
2003
+ switch (dataType.type) {
2004
+ case "objectSet": {
2005
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.objectSet);
2006
+ result.set(dataType.objectSet, objectDef);
2007
+ break;
2008
+ }
2009
+ case "object": {
2010
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.object);
2011
+ result.set(dataType.object, objectDef);
2012
+ break;
2013
+ }
2014
+ case "set": {
2015
+ return getRequiredDefinitions(dataType.set, client);
2016
+ }
2017
+ case "struct": {
2018
+ for (const value of Object.values(dataType.struct)) {
2019
+ for (const [type, objectDef] of await getRequiredDefinitions(value, client)) {
2020
+ result.set(type, objectDef);
2021
+ }
2022
+ }
2023
+ break;
2024
+ }
2025
+ }
2026
+ return result;
2027
+ }
2028
+ function requiresConversion(dataType) {
2029
+ switch (dataType.type) {
2030
+ case "boolean":
2031
+ case "date":
2032
+ case "double":
2033
+ case "float":
2034
+ case "integer":
2035
+ case "long":
2036
+ case "object":
2037
+ case "string":
2038
+ case "timestamp":
2039
+ return false;
2040
+ case "union":
2041
+ return true;
2042
+ case "struct":
2043
+ return Object.values(dataType.struct).some(requiresConversion);
2044
+ case "set":
2045
+ return requiresConversion(dataType.set);
2046
+ case "attachment":
2047
+ case "objectSet":
2048
+ case "twoDimensionalAggregation":
2049
+ case "threeDimensionalAggregation":
2050
+ return true;
2051
+ default:
2052
+ return false;
2053
+ }
2054
+ }
2055
+ function createQueryObjectResponse(primaryKey, objectDef) {
2056
+ return {
2057
+ $apiName: objectDef.apiName,
2058
+ $title: void 0,
2059
+ $objectType: objectDef.apiName,
2060
+ $primaryKey: primaryKey
2061
+ };
2062
+ }
2063
+
2064
+ // src/queries/createQueryInvoker.ts
2065
+ function createQueryInvoker(client, query) {
2066
+ return function(...args) {
2067
+ return applyQuery(client, query, ...args);
2068
+ };
2069
+ }
2070
+
1801
2071
  // src/createClient.ts
1802
2072
  var ActionInvoker = class {
1803
2073
  constructor(clientCtx, actionDef) {
@@ -1815,6 +2085,8 @@ function createClientInternal(objectSetFactory, baseUrl, ontologyRid, tokenProvi
1815
2085
  } else if (o.type === "action") {
1816
2086
  clientCtx.ontologyProvider.maybeSeed(o);
1817
2087
  return new ActionInvoker(clientCtx, o);
2088
+ } else if (o.type === "query") {
2089
+ return createQueryInvoker(clientCtx, o);
1818
2090
  } else {
1819
2091
  throw new Error("not implemented");
1820
2092
  }
@@ -1830,4 +2102,4 @@ var createClient = createClientInternal.bind(void 0, createObjectSet);
1830
2102
 
1831
2103
  export { ActionValidationError, USER_AGENT, augment, convertWireToOsdkObjects, createAttachmentFromRid, createClient, createClientInternal, createObjectSet, createSimpleAsyncCache, esm_exports2 as esm_exports };
1832
2104
  //# sourceMappingURL=out.js.map
1833
- //# sourceMappingURL=chunk-2XJ62QSF.js.map
2105
+ //# sourceMappingURL=chunk-MD6R46EZ.js.map