@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
  }
@@ -902,8 +896,7 @@ function $asFactory(objDef) {
902
896
  }
903
897
  const underlying = this[UnderlyingOsdkObject];
904
898
  const existing = osdkObjectToInterfaceView.get(underlying).get(newDef.apiName);
905
- if (existing)
906
- return existing;
899
+ if (existing) return existing;
907
900
  const osdkInterface = createOsdkInterface(underlying, newDef);
908
901
  osdkObjectToInterfaceView.get(underlying).set(newDef.apiName, osdkInterface);
909
902
  return osdkInterface;
@@ -1071,8 +1064,7 @@ function modernToLegacyAggregationClause(select) {
1071
1064
  });
1072
1065
  }
1073
1066
  function modernToLegacyGroupByClause(groupByClause) {
1074
- if (!groupByClause)
1075
- return [];
1067
+ if (!groupByClause) return [];
1076
1068
  return Object.entries(groupByClause).flatMap(([field, type]) => {
1077
1069
  if (type === "exact") {
1078
1070
  return [{
@@ -1106,8 +1098,7 @@ function modernToLegacyGroupByClause(groupByClause) {
1106
1098
  value: type.$duration[0],
1107
1099
  unit: DurationMapping[type.$duration[1]]
1108
1100
  }];
1109
- } else
1110
- return [];
1101
+ } else return [];
1111
1102
  });
1112
1103
  }
1113
1104
  function convertRange(range) {
@@ -1133,7 +1124,7 @@ async function aggregate(clientCtx, objectType, objectSet = {
1133
1124
  if (req.$where) {
1134
1125
  body.where = modernToLegacyWhereClause(req.$where);
1135
1126
  }
1136
- const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(addUserAgent(clientCtx, objectType), clientCtx.ontologyRid, {
1127
+ const result = await esm_exports2.OntologyObjectSets.aggregateObjectSetV2(addUserAgent(clientCtx, objectType), await clientCtx.ontologyRid, {
1137
1128
  objectSet,
1138
1129
  groupBy: body.groupBy,
1139
1130
  aggregation: body.aggregation
@@ -1250,6 +1241,7 @@ function createObjectSet(objectType, clientCtx, objectSet = {
1250
1241
  const result = await base.fetchPage({
1251
1242
  $nextPageToken
1252
1243
  });
1244
+ $nextPageToken = result.nextPageToken;
1253
1245
  for (const obj of result.data) {
1254
1246
  yield obj;
1255
1247
  }
@@ -1377,8 +1369,7 @@ function createOsdkObject(client, objectDef, rawObj) {
1377
1369
  case UnderlyingOsdkObject:
1378
1370
  return receiver;
1379
1371
  }
1380
- if (p in target)
1381
- return target[p];
1372
+ if (p in target) return target[p];
1382
1373
  if (p in rawObj) {
1383
1374
  const rawValue = target[RawObject][p];
1384
1375
  const propDef = objectDef.properties[p];
@@ -1445,8 +1436,7 @@ async function convertWireToOsdkObjects(client, objects, interfaceApiName, force
1445
1436
  continue;
1446
1437
  }
1447
1438
  let osdkObject = createOsdkObject(client, objectDef, rawObj);
1448
- if (interfaceApiName)
1449
- osdkObject = osdkObject.$as(interfaceApiName);
1439
+ if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);
1450
1440
  ret.push(osdkObject);
1451
1441
  }
1452
1442
  client.logger?.debug(`END convertWireToOsdkObjects()`);
@@ -1539,7 +1529,7 @@ function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = voi
1539
1529
  throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
1540
1530
  }
1541
1531
  async function fetchInterfacePage(client, interfaceType, args, objectSet) {
1542
- const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(addUserAgent(client, interfaceType), client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
1532
+ const result = await esm_exports2.OntologyObjectsV2.searchObjectsForInterface(addUserAgent(client, interfaceType), await client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
1543
1533
  augmentedProperties: args.$augment ?? {},
1544
1534
  augmentedSharedPropertyTypes: {},
1545
1535
  otherInterfaceTypes: [],
@@ -1606,9 +1596,9 @@ function applyFetchArgs(args, body) {
1606
1596
  return body;
1607
1597
  }
1608
1598
  async function fetchObjectPage(client, objectType, args, objectSet) {
1609
- const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgent(client, objectType), client.ontologyRid, applyFetchArgs(args, {
1599
+ const r = await esm_exports2.OntologyObjectSets.loadObjectSetV2(addUserAgent(client, objectType), await client.ontologyRid, applyFetchArgs(args, {
1610
1600
  objectSet,
1611
- // We have to do the following case because LoadObjectSetRequestV2 isnt readonly
1601
+ // We have to do the following case because LoadObjectSetRequestV2 isn't readonly
1612
1602
  select: args?.$select ?? [],
1613
1603
  // FIXME?
1614
1604
  excludeRid: !args?.$includeRid
@@ -1637,6 +1627,11 @@ function isOntologyObjectV2(o) {
1637
1627
  return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
1638
1628
  }
1639
1629
 
1630
+ // src/util/isOsdkObject.ts
1631
+ function isOsdkBaseObject(o) {
1632
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1633
+ }
1634
+
1640
1635
  // src/util/toDataValue.ts
1641
1636
  async function toDataValue(value, client) {
1642
1637
  if (value == null) {
@@ -1658,6 +1653,9 @@ async function toDataValue(value, client) {
1658
1653
  if (isOntologyObjectV2(value)) {
1659
1654
  return await toDataValue(value.__primaryKey, client);
1660
1655
  }
1656
+ if (isOsdkBaseObject(value)) {
1657
+ return await toDataValue(value.$primaryKey, client);
1658
+ }
1661
1659
  if (isWireObjectSet(value)) {
1662
1660
  return value;
1663
1661
  }
@@ -1677,7 +1675,7 @@ async function toDataValue(value, client) {
1677
1675
  // src/actions/applyAction.ts
1678
1676
  async function applyAction2(client, action, parameters, options = {}) {
1679
1677
  if (Array.isArray(parameters)) {
1680
- const response = await esm_exports2.Actions.applyActionBatchV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
1678
+ const response = await esm_exports2.Actions.applyActionBatchV2(addUserAgent(client, action), await client.ontologyRid, action.apiName, {
1681
1679
  requests: parameters ? await remapBatchActionParams(parameters, client) : [],
1682
1680
  options: {
1683
1681
  returnEdits: options?.$returnEdits ? "ALL" : "NONE"
@@ -1685,7 +1683,7 @@ async function applyAction2(client, action, parameters, options = {}) {
1685
1683
  });
1686
1684
  return options?.$returnEdits ? response.edits : void 0;
1687
1685
  } else {
1688
- const response = await esm_exports2.Actions.applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
1686
+ const response = await esm_exports2.Actions.applyActionV2(addUserAgent(client, action), await client.ontologyRid, action.apiName, {
1689
1687
  parameters: await remapActionParams(parameters, client),
1690
1688
  options: {
1691
1689
  mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
@@ -1719,19 +1717,19 @@ async function remapBatchActionParams(params, client) {
1719
1717
  }));
1720
1718
  return remappedParams;
1721
1719
  }
1722
- async function loadFullObjectMetadata(client, objtype) {
1723
- const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, client.ontologyRid, objtype, {
1720
+ async function loadFullObjectMetadata(client, objectType) {
1721
+ const full = await esm_exports2.OntologyObjectsV2.getObjectTypeFullMetadata(client, await client.ontologyRid, objectType, {
1724
1722
  preview: true
1725
1723
  });
1726
1724
  const ret = wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
1727
- client.logger?.debug(`END loadFullObjectMetadata(${objtype})`);
1725
+ client.logger?.debug(`END loadFullObjectMetadata(${objectType})`);
1728
1726
  return {
1729
1727
  ...ret,
1730
1728
  rid: full.objectType.rid
1731
1729
  };
1732
1730
  }
1733
- async function loadInterfaceDefinition(client, objtype) {
1734
- const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, client.ontologyRid, objtype, {
1731
+ async function loadInterfaceDefinition(client, objectType) {
1732
+ const r = await esm_exports2.OntologyObjectsV2.getInterfaceType(client, await client.ontologyRid, objectType, {
1735
1733
  preview: true
1736
1734
  });
1737
1735
  return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
@@ -1772,7 +1770,7 @@ var createStandardOntologyProviderFactory = (client) => {
1772
1770
  };
1773
1771
 
1774
1772
  // src/util/UserAgent.ts
1775
- var USER_AGENT = `osdk-client/${"0.20.0-beta.2"}`;
1773
+ var USER_AGENT = `osdk-client/${"0.20.0-beta.4"}`;
1776
1774
 
1777
1775
  // src/createMinimalClient.ts
1778
1776
  function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
@@ -1788,13 +1786,285 @@ function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fet
1788
1786
  ...createSharedClientContext(baseUrl, tokenProvider, USER_AGENT, fetchFn),
1789
1787
  objectSetFactory,
1790
1788
  ontologyRid: metadata.ontologyRid,
1791
- logger: options.logger
1789
+ logger: options.logger,
1790
+ clientCacheKey: {}
1792
1791
  };
1793
1792
  return Object.assign(minimalClient, {
1794
1793
  ontologyProvider: createStandardOntologyProviderFactory()(minimalClient)
1795
1794
  });
1796
1795
  }
1797
1796
 
1797
+ // src/util/isOsdkBaseObject.ts
1798
+ function isOsdkBaseObject2(o) {
1799
+ return o && typeof o === "object" && typeof o.$apiName === "string" && o.$primaryKey != null;
1800
+ }
1801
+
1802
+ // src/util/toDataValueQueries.ts
1803
+ async function toDataValueQueries(value, client, desiredType) {
1804
+ if (value == null) {
1805
+ return value;
1806
+ }
1807
+ if (Array.isArray(value) && desiredType.multiplicity) {
1808
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType));
1809
+ return Promise.all(promiseArray);
1810
+ }
1811
+ switch (desiredType.type) {
1812
+ case "attachment": {
1813
+ if (isAttachmentUpload(value)) {
1814
+ const attachment = await esm_exports.Attachments.uploadAttachment(client, value, {
1815
+ filename: value.name
1816
+ }, {
1817
+ "Content-Length": value.size.toString(),
1818
+ "Content-Type": value.type
1819
+ });
1820
+ return attachment.rid;
1821
+ }
1822
+ return value;
1823
+ }
1824
+ case "twoDimensionalAggregation": {
1825
+ return {
1826
+ groups: value
1827
+ };
1828
+ }
1829
+ case "threeDimensionalAggregation": {
1830
+ return {
1831
+ groups: value
1832
+ };
1833
+ }
1834
+ case "set": {
1835
+ if (value instanceof Set) {
1836
+ const promiseArray = Array.from(value, async (innerValue) => await toDataValueQueries(innerValue, client, desiredType["set"]));
1837
+ return Promise.all(promiseArray);
1838
+ }
1839
+ break;
1840
+ }
1841
+ case "object": {
1842
+ if (isOsdkBaseObject2(value)) {
1843
+ return value.$primaryKey;
1844
+ }
1845
+ break;
1846
+ }
1847
+ case "objectSet": {
1848
+ if (isWireObjectSet(value)) {
1849
+ return value;
1850
+ }
1851
+ if (isObjectSet(value)) {
1852
+ return getWireObjectSet(value);
1853
+ }
1854
+ break;
1855
+ }
1856
+ case "struct": {
1857
+ if (typeof value === "object") {
1858
+ const structMap = {};
1859
+ for (const [key, structValue] of Object.entries(value)) {
1860
+ structMap[key] = await toDataValueQueries(structValue, client, desiredType["struct"][key]);
1861
+ }
1862
+ return structMap;
1863
+ }
1864
+ }
1865
+ case "boolean":
1866
+ case "date":
1867
+ case "double":
1868
+ case "float":
1869
+ case "integer":
1870
+ case "long":
1871
+ case "string":
1872
+ case "timestamp":
1873
+ return value;
1874
+ }
1875
+ return value;
1876
+ }
1877
+
1878
+ // src/queries/applyQuery.ts
1879
+ async function applyQuery(client, query, params) {
1880
+ const response = await esm_exports2.QueryTypes.executeQueryV2(addUserAgent(client, query), await client.ontologyRid, query.apiName, {
1881
+ parameters: params ? await remapQueryParams(params, client, query.parameters) : {}
1882
+ });
1883
+ const objectOutputDefs = await getRequiredDefinitions(query.output, client);
1884
+ const remappedResponse = await remapQueryResponse(client, query.output, response.value, objectOutputDefs);
1885
+ return remappedResponse;
1886
+ }
1887
+ async function remapQueryParams(params, client, paramTypes) {
1888
+ const parameterMap = {};
1889
+ for (const [key, value] of Object.entries(params)) {
1890
+ parameterMap[key] = await toDataValueQueries(value, client, paramTypes[key]);
1891
+ }
1892
+ return parameterMap;
1893
+ }
1894
+ async function remapQueryResponse(client, responseDataType, responseValue, definitions) {
1895
+ if (responseValue == null) {
1896
+ if (responseDataType.nullable) {
1897
+ return void 0;
1898
+ } else {
1899
+ throw new Error("Got null response when nullable was not allowed");
1900
+ }
1901
+ }
1902
+ if (responseDataType.multiplicity != null && responseDataType.multiplicity !== false) {
1903
+ const withoutMultiplicity = {
1904
+ ...responseDataType,
1905
+ multiplicity: false
1906
+ };
1907
+ for (let i = 0; i < responseValue.length; i++) {
1908
+ responseValue[i] = await remapQueryResponse(responseValue[i], withoutMultiplicity, client, definitions);
1909
+ }
1910
+ return responseValue;
1911
+ }
1912
+ switch (responseDataType.type) {
1913
+ case "union": {
1914
+ throw new Error("Union return types are not yet supported");
1915
+ }
1916
+ case "set": {
1917
+ for (let i = 0; i < responseValue.length; i++) {
1918
+ responseValue[i] = await remapQueryResponse(responseValue[i], responseDataType.set, client, definitions);
1919
+ }
1920
+ return responseValue;
1921
+ }
1922
+ case "attachment": {
1923
+ return createAttachmentFromRid(client, responseValue);
1924
+ }
1925
+ case "object": {
1926
+ const def = definitions.get(responseDataType.object);
1927
+ if (!def) {
1928
+ throw new Error(`Missing definition for ${responseDataType.object}`);
1929
+ }
1930
+ return createQueryObjectResponse(responseValue, def);
1931
+ }
1932
+ case "objectSet": {
1933
+ const def = definitions.get(responseDataType.objectSet);
1934
+ if (!def) {
1935
+ throw new Error(`Missing definition for ${responseDataType.objectSet}`);
1936
+ }
1937
+ if (typeof responseValue === "string") {
1938
+ return createObjectSet(def, client, {
1939
+ type: "intersect",
1940
+ objectSets: [{
1941
+ type: "base",
1942
+ objectType: responseDataType.objectSet
1943
+ }, {
1944
+ type: "reference",
1945
+ reference: responseValue
1946
+ }]
1947
+ });
1948
+ }
1949
+ return createObjectSet(def, client, responseValue);
1950
+ }
1951
+ case "struct": {
1952
+ for (const [key, subtype] of Object.entries(responseDataType.struct)) {
1953
+ if (requiresConversion(subtype)) {
1954
+ responseValue[key] = await remapQueryResponse(responseValue[key], subtype, client, definitions);
1955
+ }
1956
+ }
1957
+ return responseValue;
1958
+ }
1959
+ case "twoDimensionalAggregation": {
1960
+ const result = [];
1961
+ for (const {
1962
+ key,
1963
+ value
1964
+ } of responseValue.groups) {
1965
+ result.push({
1966
+ key,
1967
+ value
1968
+ });
1969
+ }
1970
+ return result;
1971
+ }
1972
+ case "threeDimensionalAggregation": {
1973
+ const result = [];
1974
+ for (const {
1975
+ key,
1976
+ groups
1977
+ } of responseValue.groups) {
1978
+ const subResult = [];
1979
+ for (const {
1980
+ key: subKey,
1981
+ value
1982
+ } of groups) {
1983
+ subResult.push({
1984
+ key: subKey,
1985
+ value
1986
+ });
1987
+ }
1988
+ result.push({
1989
+ key,
1990
+ groups: subResult
1991
+ });
1992
+ }
1993
+ return result;
1994
+ }
1995
+ }
1996
+ return responseValue;
1997
+ }
1998
+ async function getRequiredDefinitions(dataType, client) {
1999
+ const result = /* @__PURE__ */ new Map();
2000
+ switch (dataType.type) {
2001
+ case "objectSet": {
2002
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.objectSet);
2003
+ result.set(dataType.objectSet, objectDef);
2004
+ break;
2005
+ }
2006
+ case "object": {
2007
+ const objectDef = await client.ontologyProvider.getObjectDefinition(dataType.object);
2008
+ result.set(dataType.object, objectDef);
2009
+ break;
2010
+ }
2011
+ case "set": {
2012
+ return getRequiredDefinitions(dataType.set, client);
2013
+ }
2014
+ case "struct": {
2015
+ for (const value of Object.values(dataType.struct)) {
2016
+ for (const [type, objectDef] of await getRequiredDefinitions(value, client)) {
2017
+ result.set(type, objectDef);
2018
+ }
2019
+ }
2020
+ break;
2021
+ }
2022
+ }
2023
+ return result;
2024
+ }
2025
+ function requiresConversion(dataType) {
2026
+ switch (dataType.type) {
2027
+ case "boolean":
2028
+ case "date":
2029
+ case "double":
2030
+ case "float":
2031
+ case "integer":
2032
+ case "long":
2033
+ case "object":
2034
+ case "string":
2035
+ case "timestamp":
2036
+ return false;
2037
+ case "union":
2038
+ return true;
2039
+ case "struct":
2040
+ return Object.values(dataType.struct).some(requiresConversion);
2041
+ case "set":
2042
+ return requiresConversion(dataType.set);
2043
+ case "attachment":
2044
+ case "objectSet":
2045
+ case "twoDimensionalAggregation":
2046
+ case "threeDimensionalAggregation":
2047
+ return true;
2048
+ default:
2049
+ return false;
2050
+ }
2051
+ }
2052
+ function createQueryObjectResponse(primaryKey, objectDef) {
2053
+ return {
2054
+ $apiName: objectDef.apiName,
2055
+ $title: void 0,
2056
+ $objectType: objectDef.apiName,
2057
+ $primaryKey: primaryKey
2058
+ };
2059
+ }
2060
+
2061
+ // src/queries/createQueryInvoker.ts
2062
+ function createQueryInvoker(client, query) {
2063
+ return function(...args) {
2064
+ return applyQuery(client, query, ...args);
2065
+ };
2066
+ }
2067
+
1798
2068
  // src/createClient.ts
1799
2069
  var ActionInvoker = class {
1800
2070
  constructor(clientCtx, actionDef) {
@@ -1812,6 +2082,8 @@ function createClientInternal(objectSetFactory, baseUrl, ontologyRid, tokenProvi
1812
2082
  } else if (o.type === "action") {
1813
2083
  clientCtx.ontologyProvider.maybeSeed(o);
1814
2084
  return new ActionInvoker(clientCtx, o);
2085
+ } else if (o.type === "query") {
2086
+ return createQueryInvoker(clientCtx, o);
1815
2087
  } else {
1816
2088
  throw new Error("not implemented");
1817
2089
  }
@@ -1827,4 +2099,4 @@ var createClient = createClientInternal.bind(void 0, createObjectSet);
1827
2099
 
1828
2100
  export { ActionValidationError, USER_AGENT, augment, convertWireToOsdkObjects, createAttachmentFromRid, createClient, createClientInternal, createObjectSet, createSimpleAsyncCache, esm_exports2 as esm_exports };
1829
2101
  //# sourceMappingURL=out.js.map
1830
- //# sourceMappingURL=chunk-Y6GMYWXB.js.map
2102
+ //# sourceMappingURL=chunk-3ZYIZQ7V.js.map