@osdk/client 0.18.0 → 0.19.0-main-20240514141215

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 (54) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/build/js/{chunk-GN5YGVT6.mjs → chunk-J2HNG3FJ.browser.mjs} +41 -104
  3. package/build/js/chunk-J2HNG3FJ.browser.mjs.map +1 -0
  4. package/build/js/{chunk-EF3KTHUA.browser.mjs → chunk-JQJTRJPQ.mjs} +41 -104
  5. package/build/js/chunk-JQJTRJPQ.mjs.map +1 -0
  6. package/build/js/{chunk-S3VSFIJO.cjs → chunk-ZMFBNB2J.cjs} +39 -105
  7. package/build/js/chunk-ZMFBNB2J.cjs.map +1 -0
  8. package/build/js/index.browser.mjs +2 -2
  9. package/build/js/index.browser.mjs.map +1 -1
  10. package/build/js/index.cjs +7 -3
  11. package/build/js/index.cjs.map +1 -1
  12. package/build/js/index.mjs +2 -2
  13. package/build/js/index.mjs.map +1 -1
  14. package/build/js/public/unstable-do-not-use.browser.mjs +18 -7
  15. package/build/js/public/unstable-do-not-use.browser.mjs.map +1 -1
  16. package/build/js/public/unstable-do-not-use.cjs +25 -14
  17. package/build/js/public/unstable-do-not-use.cjs.map +1 -1
  18. package/build/js/public/unstable-do-not-use.mjs +18 -7
  19. package/build/js/public/unstable-do-not-use.mjs.map +1 -1
  20. package/build/types/Client.d.ts +4 -3
  21. package/build/types/Client.d.ts.map +1 -1
  22. package/build/types/MinimalClientContext.d.ts +2 -6
  23. package/build/types/MinimalClientContext.d.ts.map +1 -1
  24. package/build/types/OsdkObject.d.ts +1 -0
  25. package/build/types/OsdkObject.d.ts.map +1 -1
  26. package/build/types/OsdkObjectFrom.d.ts +2 -1
  27. package/build/types/OsdkObjectFrom.d.ts.map +1 -1
  28. package/build/types/UNSTABLE_createClient.d.ts.map +1 -1
  29. package/build/types/UnstableClient.d.ts +0 -1
  30. package/build/types/UnstableClient.d.ts.map +1 -1
  31. package/build/types/createClient.d.ts +2 -2
  32. package/build/types/createClient.d.ts.map +1 -1
  33. package/build/types/createMinimalClient.d.ts +4 -2
  34. package/build/types/createMinimalClient.d.ts.map +1 -1
  35. package/build/types/generatedNoCheck/OntologyMetadata.d.ts +1 -1
  36. package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +10 -0
  37. package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts.map +1 -1
  38. package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +2 -0
  39. package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts.map +1 -1
  40. package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +2 -0
  41. package/build/types/generatedNoCheck/ontology/objects/Office.d.ts.map +1 -1
  42. package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +2 -0
  43. package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts.map +1 -1
  44. package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +2 -0
  45. package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts.map +1 -1
  46. package/build/types/index.d.ts +1 -0
  47. package/build/types/index.d.ts.map +1 -1
  48. package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
  49. package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
  50. package/build/types/ontology/loadFullObjectMetadata.d.ts.map +1 -1
  51. package/package.json +12 -12
  52. package/build/js/chunk-EF3KTHUA.browser.mjs.map +0 -1
  53. package/build/js/chunk-GN5YGVT6.mjs.map +0 -1
  54. package/build/js/chunk-S3VSFIJO.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 0.19.0-main-20240514141215
4
+
5
+ ### Minor Changes
6
+
7
+ - c9f3214: Interfaces are now mapped as views
8
+
9
+ ### Patch Changes
10
+
11
+ - 978ecd5: Rexport PalantirApiError
12
+ - 978ecd5: Client is now usable for calling Platform SDK
13
+ - Updated dependencies [c9f3214]
14
+ - @osdk/api@1.8.0-main-20240514141215
15
+ - @osdk/generator-converters@0.5.1-main-20240514141215
16
+ - @osdk/shared.net@1.10.1-main-20240514141215
17
+
3
18
  ## 0.18.0
4
19
 
5
20
  ### Minor Changes
@@ -1,29 +1,28 @@
1
- import { omniFetch, createFetchHeaderMutator, PalantirApiError, createClientContext } from '@osdk/shared.net';
1
+ import { foundryPlatformFetch, createFetchHeaderMutator, PalantirApiError, createSharedClientContext, symbolClientContext } from '@osdk/shared.net';
2
2
  import invariant2 from 'tiny-invariant';
3
3
  import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
4
4
  import deepEqual from 'fast-deep-equal';
5
- import { conjureFetch } from 'conjure-lite';
6
5
 
7
6
  // ../internal.foundry/build/js/public/OntologiesV2_OntologyObjectSet.mjs
8
7
  var _loadObjectSetV2 = [1, "/v2/ontologies/{0}/objectSets/loadObjects", 3];
9
8
  function loadObjectSetV2($ctx, ...args) {
10
- return omniFetch($ctx, _loadObjectSetV2, ...args);
9
+ return foundryPlatformFetch($ctx, _loadObjectSetV2, ...args);
11
10
  }
12
11
  var _aggregateObjectSetV2 = [1, "/v2/ontologies/{0}/objectSets/aggregate", 3];
13
12
  function aggregateObjectSetV2($ctx, ...args) {
14
- return omniFetch($ctx, _aggregateObjectSetV2, ...args);
15
- }
16
- var _listInterfaceTypes = [0, "/v2/ontologies/{0}/interfaceTypes", 2];
17
- function listInterfaceTypes($ctx, ...args) {
18
- return omniFetch($ctx, _listInterfaceTypes, ...args);
13
+ return foundryPlatformFetch($ctx, _aggregateObjectSetV2, ...args);
19
14
  }
20
15
  var _getInterfaceType = [0, "/v2/ontologies/{0}/interfaceTypes/{1}", 2];
21
16
  function getInterfaceType($ctx, ...args) {
22
- return omniFetch($ctx, _getInterfaceType, ...args);
17
+ return foundryPlatformFetch($ctx, _getInterfaceType, ...args);
23
18
  }
24
19
  var _searchObjectsForInterface = [1, "/v2/ontologies/{0}/interfaces/{1}/search", 3];
25
20
  function searchObjectsForInterface($ctx, ...args) {
26
- return omniFetch($ctx, _searchObjectsForInterface, ...args);
21
+ return foundryPlatformFetch($ctx, _searchObjectsForInterface, ...args);
22
+ }
23
+ var _getObjectTypeFullMetadata = [0, "/v2/ontologies/{0}/objectTypes/{1}/fullMetadata", 2];
24
+ function getObjectTypeFullMetadata($ctx, ...args) {
25
+ return foundryPlatformFetch($ctx, _getObjectTypeFullMetadata, ...args);
27
26
  }
28
27
  function addUserAgent(client, withMetadata) {
29
28
  if (withMetadata.osdkMetadata) {
@@ -621,6 +620,9 @@ function createPrototype(objDef, client) {
621
620
  if (newDef === objDef.apiName) {
622
621
  return this[UnderlyingObject];
623
622
  }
623
+ if (objDef.interfaceMap?.[newDef] == null) {
624
+ throw new Error(`Object does not implement interface '${newDef}'.`);
625
+ }
624
626
  const def = objDef[InterfaceDefinitions][newDef];
625
627
  if (!def) {
626
628
  throw new Error(`Object does not implement interface '${newDef}'.`);
@@ -651,7 +653,7 @@ function createPrototype(objDef, client) {
651
653
  ...common
652
654
  },
653
655
  ...Object.fromEntries(Object.keys(newDef.properties).map((p) => {
654
- const value = underlying[objDef.spts[p]];
656
+ const value = underlying[objDef.interfaceMap[newDef.apiName][p]];
655
657
  return [p, {
656
658
  value,
657
659
  enumerable: value !== void 0
@@ -704,7 +706,16 @@ async function convertWireToOsdkObjects(client, objects, interfaceApiName, force
704
706
  throw new Error(`Failed to find ontology definition for '${obj.$apiName}'`);
705
707
  }
706
708
  if (interfaceApiName !== void 0) {
707
- for (const [sptProp, regularProp] of Object.entries(objectDef.spts)) {
709
+ if (objectDef.interfaceMap?.[interfaceApiName] == null) {
710
+ const warning = "Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.";
711
+ if (client.logger) {
712
+ client.logger.warn(warning);
713
+ } else {
714
+ console.error(`WARNING! ${warning}`);
715
+ }
716
+ throw new Error(warning);
717
+ }
718
+ for (const [sptProp, regularProp] of Object.entries(objectDef.interfaceMap[interfaceApiName])) {
708
719
  if (sptProp in obj) {
709
720
  const value = obj[sptProp];
710
721
  delete obj[sptProp];
@@ -896,7 +907,7 @@ var ActionValidationError = class extends Error {
896
907
  };
897
908
  var _applyActionV2 = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];
898
909
  function applyActionV2($ctx, ...args) {
899
- return omniFetch($ctx, _applyActionV2, ...args);
910
+ return foundryPlatformFetch($ctx, _applyActionV2, ...args);
900
911
  }
901
912
 
902
913
  // src/util/isOntologyObjectV2.ts
@@ -968,80 +979,12 @@ function createActionInvoker(client, action) {
968
979
  return applyAction(client, action, ...args);
969
980
  };
970
981
  }
971
- var _getObjectTypeV2 = [0, "/v2/ontologies/{0}/objectTypes/{1}"];
972
- function getObjectTypeV2($ctx, ...args) {
973
- return omniFetch($ctx, _getObjectTypeV2, ...args);
974
- }
975
- var _listOutgoingLinkTypesV2 = [0, "/v2/ontologies/{0}/objectTypes/{1}/outgoingLinkTypes", 2];
976
- function listOutgoingLinkTypesV2($ctx, ...args) {
977
- return omniFetch($ctx, _listOutgoingLinkTypesV2, ...args);
978
- }
979
- async function loadAllOntologies(ctx, request) {
980
- return conjureFetch(ctx, `/ontology/ontology/ontologies/load/all`, "POST", request);
981
- }
982
- async function loadOntologyEntities(ctx, request) {
983
- return conjureFetch(ctx, `/ontology/ontology/loadEntities`, "POST", request);
984
- }
985
-
986
- // src/ontology/loadFullObjectMetadata.ts
987
- async function loadAllOutgoingLinkTypes(client, objtype) {
988
- const linkTypes = [];
989
- let pageToken;
990
- do {
991
- const result = await listOutgoingLinkTypesV2(client, client.ontologyRid, objtype, {
992
- pageToken
993
- });
994
- pageToken = result.nextPageToken;
995
- linkTypes.push(...result.data);
996
- } while (pageToken != null);
997
- return linkTypes;
998
- }
999
- function makeConjureContext(client, servicePath) {
1000
- return {
1001
- baseUrl: client.stack,
1002
- servicePath,
1003
- fetchFn: client.fetch,
1004
- tokenProvider: async () => await client.tokenProvider()
1005
- };
1006
- }
1007
982
  async function loadFullObjectMetadata(client, objtype) {
1008
- const conjureCtx = makeConjureContext(client, "/ontology-metadata/api");
1009
- const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([getObjectTypeV2(client, client.ontologyRid, objtype), loadAllOutgoingLinkTypes(client, objtype), listInterfaceTypes(client, client.ontologyRid, {
1010
- pageSize: 200,
983
+ const full = await getObjectTypeFullMetadata(client, client.ontologyRid, objtype, {
1011
984
  preview: true
1012
- }), await loadAllOntologies(conjureCtx, {})]);
1013
- const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.ontologyRid, objectType.rid);
1014
- const full = {
1015
- implementsInterfaces: interfaceTypes.data.map((i) => i.apiName),
1016
- implementsInterfaces2: {},
1017
- // FIXME(interfaces)
1018
- linkTypes,
1019
- objectType,
1020
- sharedPropertyTypeMapping
1021
- };
985
+ });
1022
986
  return wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
1023
987
  }
1024
- async function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {
1025
- const ontologyVersion = ontologyMetadata.ontologies[ontologyRid].currentOntologyVersion;
1026
- const body = {
1027
- objectTypeVersions: {
1028
- [objectRid]: ontologyVersion
1029
- },
1030
- linkTypeVersions: {},
1031
- loadRedacted: false,
1032
- includeObjectTypesWithoutSearchableDatasources: true
1033
- };
1034
- const entities = await loadOntologyEntities(ctx, body);
1035
- const objectType = entities.objectTypes[objectRid];
1036
- !objectType ? process.env.NODE_ENV !== "production" ? invariant2(false, "object type should be loaded") : invariant2(false) : void 0;
1037
- const sptMap = {};
1038
- for (const property of Object.values(objectType.propertyTypes)) {
1039
- if (property.sharedPropertyTypeApiName && property.apiName) {
1040
- sptMap[property.sharedPropertyTypeApiName] = property.apiName;
1041
- }
1042
- }
1043
- return sptMap;
1044
- }
1045
988
  async function loadInterfaceDefinition(client, objtype) {
1046
989
  const r = await getInterfaceType(client, client.ontologyRid, objtype, {
1047
990
  preview: true
@@ -1089,40 +1032,34 @@ var createStandardOntologyProviderFactory = (client) => {
1089
1032
  };
1090
1033
 
1091
1034
  // src/util/UserAgent.ts
1092
- var USER_AGENT = `osdk-client/${"0.18.0"}`;
1035
+ var USER_AGENT = `osdk-client/${"0.19.0-main-20240514141215"}`;
1093
1036
 
1094
1037
  // src/createMinimalClient.ts
1095
- function createMinimalClient(metadata, stack, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
1038
+ function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {
1096
1039
  if (process?.env?.NODE_ENV !== "production") {
1097
1040
  try {
1098
- new URL(stack);
1041
+ new URL(baseUrl);
1099
1042
  } catch (e) {
1100
- const hint = !stack.startsWith("http://") || !stack.startsWith("https://") ? ". Did you forget to add 'http://' or 'https://'?" : "";
1101
- throw new Error(`Invalid stack URL: ${stack}${hint}`);
1043
+ const hint = !baseUrl.startsWith("http://") || !baseUrl.startsWith("https://") ? ". Did you forget to add 'http://' or 'https://'?" : "";
1044
+ throw new Error(`Invalid stack URL: ${baseUrl}${hint}`);
1102
1045
  }
1103
1046
  }
1104
- const clientCtx = {
1105
- ...createClientContext({
1106
- metadata: {
1107
- ...metadata,
1108
- userAgent: ""
1109
- // ontology specific user agent injected elsewhere
1110
- }
1111
- }, stack, tokenProvider, USER_AGENT, fetchFn),
1047
+ const minimalClient = {
1048
+ ...createSharedClientContext(baseUrl, tokenProvider, USER_AGENT, fetchFn),
1112
1049
  objectSetFactory,
1113
1050
  ontologyRid: metadata.ontologyRid,
1114
- ontologyProvider: void 0,
1115
1051
  logger: options.logger
1116
1052
  };
1117
- clientCtx.ontologyProvider = createStandardOntologyProviderFactory(options)(clientCtx);
1118
- return clientCtx;
1053
+ return Object.assign(minimalClient, {
1054
+ ontologyProvider: createStandardOntologyProviderFactory(options)(minimalClient)
1055
+ });
1119
1056
  }
1120
1057
 
1121
1058
  // src/createClient.ts
1122
- function createClientInternal(objectSetFactory, stack, ontologyRid, tokenProvider, options = void 0, fetchFn = fetch) {
1059
+ function createClientInternal(objectSetFactory, baseUrl, ontologyRid, tokenProvider, options = void 0, fetchFn = fetch) {
1123
1060
  const clientCtx = createMinimalClient({
1124
1061
  ontologyRid
1125
- }, stack, tokenProvider, options, fetchFn, objectSetFactory);
1062
+ }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);
1126
1063
  function clientFn(o) {
1127
1064
  if (o.type === "object" || o.type === "interface") {
1128
1065
  clientCtx.ontologyProvider.maybeSeed(o);
@@ -1135,7 +1072,7 @@ function createClientInternal(objectSetFactory, stack, ontologyRid, tokenProvide
1135
1072
  }
1136
1073
  }
1137
1074
  const client = Object.defineProperties(clientFn, {
1138
- ctx: {
1075
+ [symbolClientContext]: {
1139
1076
  value: clientCtx
1140
1077
  }
1141
1078
  });
@@ -1143,6 +1080,6 @@ function createClientInternal(objectSetFactory, stack, ontologyRid, tokenProvide
1143
1080
  }
1144
1081
  var createClient = createClientInternal.bind(void 0, createObjectSet);
1145
1082
 
1146
- export { ActionValidationError, augment, convertWireToOsdkObjects, createClient, createClientInternal, createObjectSet, getObjectTypeV2, loadAllOntologies, loadOntologyEntities };
1083
+ export { ActionValidationError, augment, convertWireToOsdkObjects, createClient, createClientInternal, createObjectSet };
1147
1084
  //# sourceMappingURL=out.js.map
1148
- //# sourceMappingURL=chunk-GN5YGVT6.mjs.map
1085
+ //# sourceMappingURL=chunk-J2HNG3FJ.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../internal.foundry/build/js/public/OntologiesV2_OntologyObjectSet.mjs","../../../internal.foundry/build/js/public/OntologiesV2_OntologyObjectV2.mjs","../../src/util/addUserAgent.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/query/aggregations/GroupByClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/query/WhereClause.ts","../../src/object/fetchSingle.ts","../../src/object/aggregate.ts","../../src/util/WireObjectSet.ts","../../src/objectSet/createObjectSet.ts","../../src/object/Attachment.ts","../../src/object/Cache.ts","../../src/object/fetchPage.ts","../../src/actions/ActionValidationError.ts","../../src/createClient.ts","../../../internal.foundry/build/js/public/OntologiesV2_Action.mjs","../../src/util/isOntologyObjectV2.ts","../../src/util/toDataValue.ts","../../src/actions/applyAction.ts","../../src/actions/createActionInvoker.ts","../../src/createMinimalClient.ts","../../src/ontology/StandardOntologyProvider.ts","../../../internal.foundry/build/js/public/OntologiesV2_OntologyV2.mjs","../../src/ontology/loadFullObjectMetadata.ts","../../src/ontology/loadInterfaceDefinition.ts","../../src/util/UserAgent.ts"],"names":["foundryPlatformFetch","invariant","client","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","wireObjectTypeFullMetadataToSdkObjectTypeDefinition"],"mappings":";AAAA,SAAS,4BAA4B;AAWrC,IAAI,mBAAmB,CAAC,GAAG,6CAA6C,CAAC;AACzE,SAAS,gBAAgB,SAAS,MAAM;AACtC,SAAO,qBAAqB,MAAM,kBAAkB,GAAG,IAAI;AAC7D;AACA,IAAI,wBAAwB,CAAC,GAAG,2CAA2C,CAAC;AAC5E,SAAS,qBAAqB,SAAS,MAAM;AAC3C,SAAO,qBAAqB,MAAM,uBAAuB,GAAG,IAAI;AAClE;;;AClBA,SAAS,wBAAAA,6BAA4B;AAuBrC,IAAI,sBAAsB,CAAC,GAAG,qCAAqC,CAAC;AACpE,SAAS,mBAAmB,SAAS,MAAM;AACzC,SAAOA,sBAAqB,MAAM,qBAAqB,GAAG,IAAI;AAChE;AACA,IAAI,oBAAoB,CAAC,GAAG,yCAAyC,CAAC;AACtE,SAAS,iBAAiB,SAAS,MAAM;AACvC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AAS;AAAA,IACtC,WAAW,EAAE,SAAS,UAAU;AAC9B,gBAAU,iBAAiB,UAAU,CAAC;AACtC,aAAO,oBAAoB,WAAW,CAAC;AAAA,IACzC,OAAO;AACL,YAAM,IAAI,MAAM,iBAAiB;AAAA,IACnC;AAAA,EACF;AACA,QAAM,SAAS,OAAO,iBAAiB,UAAU;AAAA,IAC/C,CAAC,mBAAmB,GAAG;AAAA,MACrB,OAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,SAAO;AACT;AACO,IAAM,eAAe,qBAAqB,KAAK,QAAW,eAAe","sourcesContent":["import { foundryPlatformFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_OntologyObjectSet.ts\nvar _createTemporaryObjectSetV2 = [1, \"/v2/ontologies/{0}/objectSets/createTemporary\", 1];\nfunction createTemporaryObjectSetV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _createTemporaryObjectSetV2, ...args);\n}\nvar _getObjectSetV2 = [0, \"/v2/ontologies/{0}/objectSets/{1}\"];\nfunction getObjectSetV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getObjectSetV2, ...args);\n}\nvar _loadObjectSetV2 = [1, \"/v2/ontologies/{0}/objectSets/loadObjects\", 3];\nfunction loadObjectSetV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _loadObjectSetV2, ...args);\n}\nvar _aggregateObjectSetV2 = [1, \"/v2/ontologies/{0}/objectSets/aggregate\", 3];\nfunction aggregateObjectSetV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _aggregateObjectSetV2, ...args);\n}\nexport { aggregateObjectSetV2, createTemporaryObjectSetV2, getObjectSetV2, loadObjectSetV2 };","import { foundryPlatformFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_OntologyObjectV2.ts\nvar _listObjectsV2 = [0, \"/v2/ontologies/{0}/objects/{1}\", 2];\nfunction listObjectsV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _listObjectsV2, ...args);\n}\nvar _getObjectV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}\", 2];\nfunction getObjectV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getObjectV2, ...args);\n}\nvar _countObjects = [1, \"/v2/ontologies/{0}/objects/{1}/count\", 2];\nfunction countObjects($ctx, ...args) {\n return foundryPlatformFetch($ctx, _countObjects, ...args);\n}\nvar _searchObjectsV2 = [1, \"/v2/ontologies/{0}/objects/{1}/search\", 3];\nfunction searchObjectsV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _searchObjectsV2, ...args);\n}\nvar _aggregateObjectsV2 = [1, \"/v2/ontologies/{0}/objects/{1}/aggregate\", 3];\nfunction aggregateObjectsV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _aggregateObjectsV2, ...args);\n}\nvar _listInterfaceTypes = [0, \"/v2/ontologies/{0}/interfaceTypes\", 2];\nfunction listInterfaceTypes($ctx, ...args) {\n return foundryPlatformFetch($ctx, _listInterfaceTypes, ...args);\n}\nvar _getInterfaceType = [0, \"/v2/ontologies/{0}/interfaceTypes/{1}\", 2];\nfunction getInterfaceType($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getInterfaceType, ...args);\n}\nvar _searchObjectsForInterface = [1, \"/v2/ontologies/{0}/interfaces/{1}/search\", 3];\nfunction searchObjectsForInterface($ctx, ...args) {\n return foundryPlatformFetch($ctx, _searchObjectsForInterface, ...args);\n}\nvar _aggregateObjectsForInterface = [1, \"/v2/ontologies/{0}/interfaces/{1}/aggregate\", 3];\nfunction aggregateObjectsForInterface($ctx, ...args) {\n return foundryPlatformFetch($ctx, _aggregateObjectsForInterface, ...args);\n}\nvar _listLinkedObjectsV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/links/{3}\", 2];\nfunction listLinkedObjectsV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _listLinkedObjectsV2, ...args);\n}\nvar _getLinkedObjectV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/links/{3}/{4}\", 2];\nfunction getLinkedObjectV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getLinkedObjectV2, ...args);\n}\nvar _getAttachmentsV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}\", 2];\nfunction getAttachmentsV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getAttachmentsV2, ...args);\n}\nvar _getAttachmentByRidV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}\", 2];\nfunction getAttachmentByRidV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getAttachmentByRidV2, ...args);\n}\nvar _getAttachmentContentV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/content\", 2,, \"*/*\"];\nfunction getAttachmentContentV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getAttachmentContentV2, ...args);\n}\nvar _getAttachmentContentByRidV2 = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}/content\", 2,, \"*/*\"];\nfunction getAttachmentContentByRidV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getAttachmentContentByRidV2, ...args);\n}\nvar _getFirstPoint = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/firstPoint\", 2];\nfunction getFirstPoint($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getFirstPoint, ...args);\n}\nvar _getLastPoint = [0, \"/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/lastPoint\", 2];\nfunction getLastPoint($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getLastPoint, ...args);\n}\nvar _streamPoints = [1, \"/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/streamPoints\", 3,, \"*/*\"];\nfunction streamPoints($ctx, ...args) {\n return foundryPlatformFetch($ctx, _streamPoints, ...args);\n}\nvar _getObjectTypeFullMetadata = [0, \"/v2/ontologies/{0}/objectTypes/{1}/fullMetadata\", 2];\nfunction getObjectTypeFullMetadata($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getObjectTypeFullMetadata, ...args);\n}\nexport { aggregateObjectsForInterface, aggregateObjectsV2, countObjects, getAttachmentByRidV2, getAttachmentContentByRidV2, getAttachmentContentV2, getAttachmentsV2, getFirstPoint, getInterfaceType, getLastPoint, getLinkedObjectV2, getObjectTypeFullMetadata, getObjectV2, listInterfaceTypes, listLinkedObjectsV2, listObjectsV2, searchObjectsForInterface, searchObjectsV2, streamPoints };","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createFetchHeaderMutator } from \"@osdk/shared.net\";\nexport function addUserAgent(client, withMetadata) {\n if (withMetadata.osdkMetadata) {\n return {\n ...client,\n fetch: createFetchHeaderMutator(client.fetch, headers => {\n headers.set(\"Fetch-User-Agent\", withMetadata.osdkMetadata.extraUserAgent);\n return headers;\n })\n };\n }\n return client;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { getWireObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { createAsyncCache, createCache } from \"./Cache.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"./fetchSingle.js\";\nconst OriginClient = Symbol();\nconst UnderlyingObject = Symbol();\nconst InterfaceDefinitions = Symbol();\nclass LinkFetcherProxyHandler {\n constructor(objDef, primaryKey, client) {\n this.objDef = objDef;\n this.primaryKey = primaryKey;\n this.client = client;\n }\n get(_target, p) {\n const linkDef = this.objDef.links[p];\n if (linkDef == null) {\n return;\n }\n const objectSet = this.client.objectSetFactory(this.objDef, this.client).where({\n [this.objDef.primaryKeyApiName]: this.primaryKey\n }).pivotTo(p);\n if (!linkDef.multiplicity) {\n return {\n /** @deprecated */\n get: options => fetchSingle(this.client, this.objDef, options ?? {}, getWireObjectSet(objectSet)),\n fetchOne: options => fetchSingle(this.client, this.objDef, options ?? {}, getWireObjectSet(objectSet)),\n fetchOneWithErrors: options => fetchSingleWithErrors(this.client, this.objDef, options ?? {}, getWireObjectSet(objectSet))\n };\n } else {\n return objectSet;\n }\n }\n ownKeys() {\n return Object.keys(this.objDef.links);\n }\n getOwnPropertyDescriptor(target, p) {\n return {\n enumerable: true,\n configurable: true,\n get: () => {\n return this.get(target, p);\n }\n };\n }\n}\nfunction createPrototype(objDef, client) {\n if (process.env.NODE_ENV !== \"production\") {\n !(objDef.type === \"object\") ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Expected object definition\") : invariant(false) : void 0;\n }\n const sharedPropertyDefs = {\n $as: {\n value: $as\n }\n };\n // we can get away with a single interface proto\n const interfaceProto = Object.defineProperties({}, sharedPropertyDefs);\n const objectProto = Object.defineProperties({}, {\n $link: {\n get: function () {\n return new Proxy({}, new LinkFetcherProxyHandler(objDef, this[\"$primaryKey\"], client));\n }\n },\n ...sharedPropertyDefs\n });\n\n // We use the exact same logic for both the interface rep and the underlying rep\n function $as(newDef) {\n if (typeof newDef === \"string\") {\n if (newDef === objDef.apiName) {\n return this[UnderlyingObject];\n }\n\n // this is sufficient to determine if we implement the interface\n if (objDef.interfaceMap?.[newDef] == null) {\n throw new Error(`Object does not implement interface '${newDef}'.`);\n }\n\n // We dont need this currently but we may need it when we have interface links so\n // we will keep it for now\n const def = objDef[InterfaceDefinitions][newDef];\n if (!def) {\n throw new Error(`Object does not implement interface '${newDef}'.`);\n }\n newDef = def;\n } else if (newDef.apiName === objDef.apiName) {\n return this[UnderlyingObject];\n }\n if (newDef.type !== \"interface\" && newDef.apiName !== this.$apiName) {\n throw new Error(`'${newDef.apiName}' is not an interface of '${this.$objectType}'.`);\n }\n const underlying = this[UnderlyingObject];\n const common = {\n enumerable: true,\n configurable: true\n };\n\n // if we use a proxy here instead we can probably pull off interfaces reflecting the underlying object even if its updated\n\n // we are defining every time because it creates properties in the exact same order\n // keeping the meta classes down to one per interface/objecttype pair\n return Object.create(interfaceProto, {\n $apiName: {\n value: newDef.apiName,\n ...common\n },\n $objectType: {\n value: objDef.apiName,\n ...common\n },\n $primaryKey: {\n value: this[\"$primaryKey\"],\n ...common\n },\n ...Object.fromEntries(Object.keys(newDef.properties).map(p => {\n const value = underlying[objDef.interfaceMap[newDef.apiName][p]];\n return [p, {\n value,\n enumerable: value !== undefined\n }];\n })),\n [UnderlyingObject]: {\n value: underlying\n }\n });\n }\n return objectProto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(objDef) {\n const steps = [];\n for (const [key, value] of Object.entries(objDef.properties)) {\n // attachments need a wrapper to provide functionality and to identify them at serialization time\n if (value.type === \"attachment\") {\n steps.push(o => {\n if (o[key] != null) {\n if (Array.isArray(o[key])) {\n o[key] = o[key].map(a => new Attachment(a.rid));\n } else {\n o[key] = new Attachment(o[key].rid);\n }\n }\n });\n }\n }\n return steps.length > 0 ? o => {\n for (const step of steps) {\n step(o);\n }\n } : undefined;\n}\nconst protoConverterCache = createCache((client, objectDef) => {\n const proto = createPrototype(objectDef, client);\n const converter = createConverter(objectDef);\n return [proto, converter];\n});\nconst isAfterFeb2024OrNewApis = false;\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false) {\n if (forceRemoveRid) {\n for (const obj of objects) {\n delete obj.__rid;\n }\n }\n fixObjectPropertiesInline(objects);\n\n /*\n We need to create a local cache for the life of this function.\n Because the user may have their global cache set to \"alwaysRevalidate\",\n we want to be able to avoid making N calls to load object/interface information.\n Our local cache will delegate to the global one but since it also caches,\n we can short circuit the `alwaysRevalidate` logic.\n This tradeoff is slightly less accurate than `alwaysRevalidate` but is close\n enough given we got back objects at T-3 and if the types are inconsistent for\n T-2 and T-1, then they are guarenteed wrong for T-3. No matter what\n the user will get a failure case here. So we avoid the extra work.\n */\n const localObjectCache = createLocalObjectCacheAndInitiatePreseed(objects, client);\n for (const obj of objects) {\n const objectDef = await localObjectCache.get(client, obj.$apiName);\n if (objectDef == null) {\n throw new Error(`Failed to find ontology definition for '${obj.$apiName}'`);\n }\n if (interfaceApiName !== undefined) {\n // API returns interface spt names but we cache by real values\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning = \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n for (const [sptProp, regularProp] of Object.entries(objectDef.interfaceMap[interfaceApiName])) {\n if (sptProp in obj) {\n const value = obj[sptProp];\n delete obj[sptProp];\n if (value !== undefined) {\n obj[regularProp] = value;\n }\n }\n }\n }\n internalConvertObjectInPlace(objectDef, client, obj);\n }\n if (interfaceApiName) {\n return objects.map(o => o.$as(interfaceApiName));\n } else {\n // we did the conversion so we can cast\n return objects;\n }\n}\nfunction createLocalObjectCacheAndInitiatePreseed(objects, client) {\n // local cache delegates to the global one\n const localInterfaceCache = createAsyncCache((client, apiName) => client.ontologyProvider.getInterfaceDefinition(apiName));\n const localObjectCache = createAsyncCache(async (client, apiName) => {\n // first delegate to the global cache\n const objectDef = await client.ontologyProvider.getObjectDefinition(apiName);\n\n // ensure we have all of the interfaces loaded\n const interfaceDefs = Object.fromEntries((await Promise.all(objectDef.implements?.map(i => localInterfaceCache.get(client, i)) ?? [])).map(i => [i.apiName, i]));\n\n // save interfaces for later if not the first time\n if (objectDef[InterfaceDefinitions] == null) {\n Object.defineProperty(objectDef, InterfaceDefinitions, {\n value: interfaceDefs,\n enumerable: false,\n configurable: false,\n writable: false\n });\n }\n return objectDef;\n });\n const uniqueApiNames = new Set();\n for (const {\n $apiName\n } of objects) {\n if (uniqueApiNames.has($apiName)) continue;\n uniqueApiNames.add($apiName);\n // preseed the object cache without blocking\n // N.B localObjectCache will preseed the interface cache\n localObjectCache.get(client, $apiName);\n }\n return localObjectCache;\n}\nfunction fixObjectPropertiesInline(objs) {\n for (const obj of objs) {\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName = obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.__apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey = obj.__primaryKey;\n\n // After Feb 2024 (unless we have new apis):\n if (isAfterFeb2024OrNewApis) {\n delete obj.__apiName;\n delete obj.__primaryKey;\n } else {\n // Hide these from things like `console.log` so that people\n // don't think to use them.\n Object.defineProperties(obj, {\n \"__apiName\": {\n enumerable: false\n },\n \"__primaryKey\": {\n enumerable: false\n }\n });\n }\n }\n}\nfunction internalConvertObjectInPlace(objectDef, client, obj) {\n const [proto, converter] = protoConverterCache.get(client, objectDef);\n Object.setPrototypeOf(obj, proto);\n Object.defineProperties(obj, {\n [OriginClient]: {\n value: client\n },\n [UnderlyingObject]: {\n value: obj\n }\n });\n if (converter) {\n converter(obj);\n }\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n if (parts[0] === \"count\") {\n return accumulator;\n }\n !(parts.length === 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (k === \"$count\") {\n if (v) return {\n type: \"count\",\n name: \"count\"\n };\n return [];\n } else if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DurationMapping = {\n \"sec\": \"SECONDS\",\n \"seconds\": \"SECONDS\",\n \"min\": \"MINUTES\",\n \"minute\": \"MINUTES\",\n \"minutes\": \"MINUTES\",\n \"hr\": \"HOURS\",\n \"hrs\": \"HOURS\",\n \"hour\": \"HOURS\",\n \"hours\": \"HOURS\",\n \"day\": \"DAYS\",\n \"days\": \"DAYS\",\n \"wk\": \"WEEKS\",\n \"week\": \"WEEKS\",\n \"weeks\": \"WEEKS\",\n \"mos\": \"MONTHS\",\n \"month\": \"MONTHS\",\n \"months\": \"MONTHS\",\n \"yr\": \"YEARS\",\n \"year\": \"YEARS\",\n \"years\": \"YEARS\",\n \"quarter\": \"QUARTERS\",\n \"quarters\": \"QUARTERS\"\n};","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DurationMapping } from \"../../query/aggregations/GroupByClause.js\";\nexport function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (\"exactWithLimit\" in type) {\n {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n }\n } else if (\"fixedWidth\" in type) {\n return [{\n type: \"fixedWidth\",\n field,\n fixedWidth: type.fixedWidth\n }];\n } else if (\"ranges\" in type) {\n return [{\n type: \"ranges\",\n field,\n ranges: type.ranges.map(range => convertRange(range))\n }];\n } else if (\"duration\" in type) {\n return [{\n type: \"duration\",\n field,\n value: type.duration[0],\n unit: DurationMapping[type.duration[1]]\n }];\n } else return [];\n });\n}\nfunction convertRange(range) {\n return {\n startValue: range[0],\n endValue: range[1]\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { DistanceUnitMapping } from \"../../query/WhereClause.js\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair)\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\" ? \"withinBoundingBox\" : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]]\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]]\n }\n }\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates\n }\n };\n}\nfunction handleWherePair([field, filter]) {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\" || typeof filter === \"boolean\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some(key => key.startsWith(\"$\"));\n !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple clauses isn't allowed\") : invariant(false) : void 0;\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);\n }\n const firstKey = keysOfFilter[0];\n !(filter[firstKey] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey]\n }\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n } else if (\"bbox\" in withinBody && !(\"type\" in withinBody)) {\n return makeGeoFilterBbox(field, withinBody.bbox, firstKey);\n } else if (\"distance\" in withinBody && \"of\" in withinBody) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.of) ? {\n type: \"Point\",\n coordinates: withinBody.of\n } : withinBody.of,\n distance: {\n value: withinBody.distance[0],\n unit: DistanceUnitMapping[withinBody.distance[1]]\n }\n }\n };\n } else {\n const coordinates = \"polygon\" in withinBody ? withinBody.polygon : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n } else if (\"bbox\" in intersectsBody && !(\"type\" in intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);\n } else {\n const coordinates = \"polygon\" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey]\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// We need to conditional here to force the union to be distributed\n\nexport const DistanceUnitMapping = {\n \"centimeter\": \"CENTIMETERS\",\n \"centimeters\": \"CENTIMETERS\",\n \"cm\": \"CENTIMETERS\",\n \"meter\": \"METERS\",\n \"meters\": \"METERS\",\n \"m\": \"METERS\",\n \"kilometer\": \"KILOMETERS\",\n \"kilometers\": \"KILOMETERS\",\n \"km\": \"KILOMETERS\",\n \"inch\": \"INCHES\",\n \"inches\": \"INCHES\",\n \"foot\": \"FEET\",\n \"feet\": \"FEET\",\n \"yard\": \"YARDS\",\n \"yards\": \"YARDS\",\n \"mile\": \"MILES\",\n \"miles\": \"MILES\",\n \"nautical_mile\": \"NAUTICAL_MILES\",\n \"nauticalMile\": \"NAUTICAL_MILES\",\n \"nautical miles\": \"NAUTICAL_MILES\"\n};\n\n// FIXME we need to represent all types","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PalantirApiError } from \"@osdk/shared.net\";\nimport { fetchPage } from \"./fetchPage.js\";\nexport async function fetchSingle(client, objectType, args, objectSet) {\n const result = await fetchPage(client, objectType, {\n ...args,\n pageSize: 1\n }, objectSet);\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\n}\nexport async function fetchSingleWithErrors(client, objectType, args, objectSet) {\n try {\n const result = await fetchSingle(client, objectType, args, objectSet);\n return {\n value: result\n };\n } catch (e) {\n if (e instanceof Error) {\n return {\n error: e\n };\n }\n return {\n error: e\n };\n }\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aggregateObjectSetV2 } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectSet\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nimport { addUserAgent } from \"../util/addUserAgent.js\";\n/** @deprecated use `aggregate` */\nexport async function aggregateOrThrow(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}, req) {\n return aggregate(clientCtx, objectType, objectSet, req);\n}\nexport async function aggregate(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n }\n const result = await aggregateObjectSetV2(addUserAgent(clientCtx, objectType), clientCtx.ontologyRid, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation\n });\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return {\n ...aggregationToCountResult(result.data[0]),\n ...legacyToModernSingleAggregationResult(result.data[0])\n };\n }\n const ret = result.data.map(entry => {\n return {\n $group: entry.group,\n ...aggregationToCountResult(entry),\n ...legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\n}\nfunction aggregationToCountResult(entry) {\n for (const aggregateResult of entry.metrics) {\n if (aggregateResult.name === \"count\") {\n return {\n $count: aggregateResult.value\n };\n }\n }\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst WIRE_OBJECT_SET_TYPES = new Set([\"base\", \"filter\", \"intersect\", \"reference\", \"searchAround\", \"static\", \"subtract\", \"union\"]);\nexport function isWireObjectSet(o) {\n return o != null && typeof o === \"object\" && WIRE_OBJECT_SET_TYPES.has(o.type);\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nimport { convertWireToOsdkObjects } from \"../object/convertWireToOsdkObjects.js\";\nimport { fetchPageInternal, fetchPageWithErrorsInternal } from \"../object/fetchPage.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../object/fetchSingle.js\";\nimport { aggregate } from \"../object/index.js\";\nimport { isWireObjectSet } from \"../util/WireObjectSet.js\";\nfunction isObjectTypeDefinition(def) {\n return def.type === \"object\";\n}\nexport function isObjectSet(o) {\n return o != null && typeof o === \"object\" && isWireObjectSet(objectSetDefinitions.get(o));\n}\n\n/** @internal */\nexport function getWireObjectSet(objectSet) {\n return objectSetDefinitions.get(objectSet);\n}\nconst objectSetDefinitions = new WeakMap();\nexport function createObjectSet(objectType, clientCtx, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}) {\n const base = {\n aggregate: aggregate.bind(globalThis, clientCtx, objectType, objectSet),\n fetchPage: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),\n fetchPageWithErrors: fetchPageWithErrorsInternal.bind(globalThis, clientCtx, objectType, objectSet),\n where: clause => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause)\n });\n },\n pivotTo: function (type) {\n return createSearchAround(type)();\n },\n union: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"union\",\n objectSets: [objectSet, ...objectSets.map(os => objectSetDefinitions.get(os))]\n });\n },\n intersect: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"intersect\",\n objectSets: [objectSet, ...objectSets.map(os => objectSetDefinitions.get(os))]\n });\n },\n subtract: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"subtract\",\n objectSets: [objectSet, ...objectSets.map(os => objectSetDefinitions.get(os))]\n });\n },\n asyncIter: async function* () {\n let nextPageToken = undefined;\n do {\n const result = await base.fetchPage({\n nextPageToken\n });\n for (const obj of await convertWireToOsdkObjects(clientCtx, result.data, undefined)) {\n yield obj;\n }\n } while (nextPageToken != null);\n },\n get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {\n const withPk = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objectType.primaryKeyApiName,\n value: primaryKey\n }\n };\n return await fetchSingle(clientCtx, objectType, options, withPk);\n } : undefined,\n fetchOne: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {\n const withPk = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objectType.primaryKeyApiName,\n value: primaryKey\n }\n };\n return await fetchSingle(clientCtx, objectType, options, withPk);\n } : undefined,\n fetchOneWithErrors: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {\n const withPk = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objectType.primaryKeyApiName,\n value: primaryKey\n }\n };\n return await fetchSingleWithErrors(clientCtx, objectType, options, withPk);\n } : undefined\n };\n function createSearchAround(link) {\n return () => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"searchAround\",\n objectSet,\n link\n });\n };\n }\n objectSetDefinitions.set(base, objectSet);\n return base;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class Attachment {\n constructor(rid) {\n this.rid = rid;\n }\n}\nexport function isAttachment(o) {\n return o instanceof Attachment;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A simple cache that can be used to store values for a given client.\n */\n\n/**\n * A simple async cache that can be used to store values for a given client.\n */\n\n/**\n * Create a new cache without a factory function.\n */\n\n/**\n * Create a new cache with a factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n */\n\nexport function createCache(fn) {\n // Given the way some consumers may use this, we may want to cache by\n // stack + ontologyApiName instead of the client object itself.\n const cache = new WeakMap();\n function get(client, key) {\n if (cache.get(client) == null) {\n cache.set(client, new Map());\n }\n let r = cache.get(client).get(key);\n if (r === undefined && fn !== undefined) {\n return set(client, key, fn(client, key));\n } else {\n return r;\n }\n }\n function set(client, key, value) {\n if (cache.get(client) == null) {\n cache.set(client, new Map());\n }\n cache.get(client).set(key, value);\n return value;\n }\n function remove(client, key) {\n if (cache.get(client) == null) return false;\n return cache.get(client).delete(key);\n }\n return {\n get,\n set,\n remove\n };\n}\n\n/**\n * Create a new cache with an async factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n * @returns\n */\nexport function createAsyncCache(fn, createCacheLocal = createCache) {\n const cache = createCacheLocal();\n const inProgress = createCacheLocal();\n const ret = {\n getOrUndefined: function getOrUndefined(client, key) {\n return cache.get(client, key);\n },\n get: async function get(client, key) {\n return cache.get(client, key) ?? inProgress.get(client, key) ?? ret.set(client, key, fn(client, key));\n },\n set: async function set(client, k, v) {\n // the `.set` happens first to prevent races.\n try {\n const r = await inProgress.set(client, k, v); // returns v\n\n cache.set(client, k, r);\n inProgress.remove(client, k);\n return r;\n } catch (e) {\n // we don't want to cache failures\n inProgress.remove(client, k);\n throw e;\n }\n }\n };\n return ret;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loadObjectSetV2 } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectSet\";\nimport { searchObjectsForInterface } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectV2\";\nimport { addUserAgent } from \"../util/addUserAgent.js\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport function augment(type, ...properties) {\n return {\n [type.apiName]: properties\n };\n}\n/** @internal */\nexport function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = undefined) {\n if (objectSet.type === \"base\") {\n if (objectSet.objectType !== expectedApiName) {\n throw new Error(`Expected objectSet.objectType to be ${expectedApiName}, but got ${objectSet.objectType}`);\n }\n return existingWhere;\n }\n if (objectSet.type === \"filter\") {\n return objectSetToSearchJsonV2(objectSet.objectSet, expectedApiName, existingWhere == null ? objectSet.where : {\n type: \"and\",\n value: [existingWhere, objectSet.where]\n });\n }\n throw new Error(`Unsupported objectSet type: ${objectSet.type}`);\n}\nasync function fetchInterfacePage(client, interfaceType, args, objectSet) {\n const result = await searchObjectsForInterface(addUserAgent(client, interfaceType), client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {\n augmentedProperties: args.augment ?? {},\n augmentedSharedPropertyTypes: {},\n otherInterfaceTypes: [],\n selectedObjectTypes: [],\n selectedSharedPropertyTypes: args.select ?? [],\n where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)\n }), {\n preview: true\n });\n result.data = await convertWireToOsdkObjects(client, result.data,\n // drop readonly\n interfaceType.apiName, !args.includeRid);\n return result;\n}\n\n/** @internal */\nexport async function fetchPageInternal(client, objectType, objectSet, args = {}) {\n if (objectType.type === \"interface\") {\n return await fetchInterfacePage(client, objectType, args, objectSet); // fixme\n } else {\n return await fetchObjectPage(client, objectType, args, objectSet); // fixme\n }\n}\n\n/** @internal */\nexport async function fetchPageWithErrorsInternal(client, objectType, objectSet, args = {}) {\n try {\n const result = await fetchPageInternal(client, objectType, objectSet, args);\n return {\n value: result\n };\n } catch (e) {\n if (e instanceof Error) {\n return {\n error: e\n };\n }\n return {\n error: e\n };\n }\n}\nexport async function fetchPage(client, objectType, args, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}) {\n return fetchPageInternal(client, objectType, objectSet, args);\n}\nexport async function fetchPageWithErrors(client, objectType, args, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}) {\n return fetchPageWithErrorsInternal(client, objectType, objectSet, args);\n}\nfunction applyFetchArgs(args, body) {\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n if (args?.orderBy != null) {\n body.orderBy = {\n fields: Object.entries(args.orderBy).map(([field, direction]) => ({\n field,\n direction\n }))\n };\n }\n return body;\n}\nexport async function fetchObjectPage(client, objectType, args, objectSet) {\n const r = await loadObjectSetV2(addUserAgent(client, objectType), client.ontologyRid, applyFetchArgs(args, {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [],\n // FIXME?\n excludeRid: !args?.includeRid\n }));\n return Promise.resolve({\n data: await convertWireToOsdkObjects(client, r.data, undefined),\n nextPageToken: r.nextPageToken\n });\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class ActionValidationError extends Error {\n constructor(validation) {\n super(\"Validation Error\");\n this.validation = validation;\n }\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { symbolClientContext } from \"@osdk/shared.net\";\nimport { createActionInvoker } from \"./actions/createActionInvoker.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nexport function createClientInternal(objectSetFactory,\n// first so i can bind\nbaseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {\n const clientCtx = createMinimalClient({\n ontologyRid\n }, baseUrl, tokenProvider, options, fetchFn, objectSetFactory);\n function clientFn(o) {\n if (o.type === \"object\" || o.type === \"interface\") {\n clientCtx.ontologyProvider.maybeSeed(o);\n return objectSetFactory(o, clientCtx);\n } else if (o.type === \"action\") {\n clientCtx.ontologyProvider.maybeSeed(o);\n return createActionInvoker(clientCtx, o);\n } else {\n throw new Error(\"not implemented\");\n }\n }\n const client = Object.defineProperties(clientFn, {\n [symbolClientContext]: {\n value: clientCtx\n }\n });\n return client;\n}\nexport const createClient = createClientInternal.bind(undefined, createObjectSet);","import { foundryPlatformFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_Action.ts\nvar _applyActionV2 = [1, \"/v2/ontologies/{0}/actions/{1}/apply\", 3];\nfunction applyActionV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _applyActionV2, ...args);\n}\nvar _applyActionBatchV2 = [1, \"/v2/ontologies/{0}/actions/{1}/applyBatch\", 3];\nfunction applyActionBatchV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _applyActionBatchV2, ...args);\n}\nvar _applyActionAsyncV2 = [1, \"/v2/ontologies/{0}/actions/{1}/applyAsync\", 3];\nfunction applyActionAsyncV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _applyActionAsyncV2, ...args);\n}\nexport { applyActionAsyncV2, applyActionBatchV2, applyActionV2 };","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function isOntologyObjectV2(o) {\n return o && typeof o === \"object\" && typeof o.__apiName === \"string\" && o.__primaryKey != null;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isAttachment } from \"../object/Attachment.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n */\nexport function toDataValue(value) {\n if (value == null) {\n // typeof null is 'object' so do this first\n return value;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n return Array.from(value, toDataValue);\n }\n\n // attachments just send the rid directly\n if (isAttachment(value)) {\n return value.rid;\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return toDataValue(value.__primaryKey);\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce((acc, [key, structValue]) => {\n acc[key] = toDataValue(structValue);\n return acc;\n }, {});\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp\n return value;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { applyActionV2 } from \"@osdk/internal.foundry/OntologiesV2_Action\";\nimport { addUserAgent } from \"../util/addUserAgent.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\n// cannot specify both validateOnly and returnEdits as true\n\nexport async function applyAction(client, action, parameters, options = {}) {\n const response = await applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {\n parameters: remapActionParams(parameters),\n options: {\n mode: options?.validateOnly ? \"VALIDATE_ONLY\" : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options?.returnEdits ? \"ALL\" : \"NONE\"\n }\n });\n if (options?.validateOnly) {\n return response.validation;\n }\n if (response.validation?.result === \"INVALID\") {\n throw new ActionValidationError(response.validation);\n }\n return options?.returnEdits ? response.edits : undefined;\n}\nfunction remapActionParams(params) {\n if (params == null) {\n return {};\n }\n const parameterMap = {};\n const remappedParams = Object.entries(params).reduce((acc, [key, value]) => {\n acc[key] = toDataValue(value);\n return acc;\n }, parameterMap);\n return remappedParams;\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { applyAction } from \"./applyAction.js\";\nexport function createActionInvoker(client, action) {\n return function (...args) {\n return applyAction(client, action, ...args);\n };\n}\nexport function createOldActionInvoker(client, ontology) {\n const proxy = new Proxy({}, {\n get: (_target, p, _receiver) => {\n if (typeof p === \"string\") {\n return createActionInvoker(client, ontology.actions[p]);\n }\n return undefined;\n },\n ownKeys(_target) {\n return Object.keys(ontology.actions);\n },\n getOwnPropertyDescriptor(_target, p) {\n if (typeof p === \"string\") {\n return {\n enumerable: ontology.actions[p] != null,\n configurable: true,\n value: proxy[p]\n };\n }\n }\n });\n return proxy;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createSharedClientContext } from \"@osdk/shared.net\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport { createStandardOntologyProviderFactory } from \"./ontology/StandardOntologyProvider.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\nexport function createMinimalClient(metadata, baseUrl, tokenProvider, options = {}, fetchFn = global.fetch, objectSetFactory = createObjectSet) {\n if (process?.env?.NODE_ENV !== \"production\") {\n try {\n new URL(baseUrl);\n } catch (e) {\n const hint = !baseUrl.startsWith(\"http://\") || !baseUrl.startsWith(\"https://\") ? \". Did you forget to add 'http://' or 'https://'?\" : \"\";\n throw new Error(`Invalid stack URL: ${baseUrl}${hint}`);\n }\n }\n const minimalClient = {\n ...createSharedClientContext(baseUrl, tokenProvider, USER_AGENT, fetchFn),\n objectSetFactory,\n ontologyRid: metadata.ontologyRid,\n logger: options.logger\n };\n return Object.assign(minimalClient, {\n ontologyProvider: createStandardOntologyProviderFactory(options)(minimalClient)\n });\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from \"@osdk/generator-converters\";\nimport { listInterfaceTypes } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectV2\";\nimport { getOntologyFullMetadata } from \"@osdk/internal.foundry/OntologiesV2_OntologyV2\";\nimport deepEqual from \"fast-deep-equal\";\nimport { createAsyncCache } from \"../object/Cache.js\";\nimport { loadFullObjectMetadata } from \"./loadFullObjectMetadata.js\";\nimport { loadInterfaceDefinition } from \"./loadInterfaceDefinition.js\";\nconst alwaysRevalidateDefault = false;\n\n// SLLLLLLOOOOOOOWWWW\nasync function fullOntologyLoad(client) {\n return await Promise.all([listInterfaceTypes(client, client.ontologyRid, {\n pageSize: 200,\n preview: true\n }), getOntologyFullMetadata(client, client.ontologyRid)]);\n}\nexport const USE_FULL_ONTOLOGY = false;\nexport const createStandardOntologyProviderFactory = client => {\n const alwaysRevalidate = client.alwaysRevalidate ?? alwaysRevalidateDefault;\n return client => {\n let fullCache;\n async function initLocalCache(client, skipCache) {\n if (skipCache) {\n return await fullOntologyLoad(client);\n }\n if (!fullCache) {\n fullCache = fullOntologyLoad(client);\n }\n return await fullCache;\n }\n async function loadObject(client, key, skipCache = false) {\n if (USE_FULL_ONTOLOGY) {\n const fullCacheLocal = await initLocalCache(client, skipCache);\n return {\n ...wireObjectTypeFullMetadataToSdkObjectTypeDefinition(fullCacheLocal[1].objectTypes[key], true),\n implements: fullCacheLocal[0].data.map(i => i.apiName)\n };\n } else {\n return await loadFullObjectMetadata(client, key);\n }\n }\n async function loadInterface(client, key, skipCache = false) {\n if (USE_FULL_ONTOLOGY) {\n const fullCacheLocal = await initLocalCache(client, skipCache);\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(fullCacheLocal[1].interfaceTypes[key], true);\n } else {\n return loadInterfaceDefinition(client, key);\n }\n }\n function makeGetter(fn) {\n const cache = createAsyncCache((client, key) => fn(client, key, false));\n return async apiName => {\n const n = alwaysRevalidate ? await fn(client, apiName, true) : await cache.get(client, apiName);\n if (alwaysRevalidate) {\n const og = cache.getOrUndefined(client, apiName);\n if (deepEqual(og, n)) {\n return og; // ! because we can be sure `n` would throw if it were undefined\n } else {\n return cache.set(client, apiName, n);\n }\n }\n return n;\n };\n }\n return {\n getObjectDefinition: makeGetter(loadObject),\n getInterfaceDefinition: makeGetter(loadInterface),\n maybeSeed(definition) {\n // not using this for now\n }\n };\n };\n};","import { foundryPlatformFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_OntologyV2.ts\nvar _listOntologiesV2 = [0, \"/v2/ontologies\"];\nfunction listOntologiesV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _listOntologiesV2, ...args);\n}\nvar _getOntologyV2 = [0, \"/v2/ontologies/{0}\"];\nfunction getOntologyV2($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getOntologyV2, ...args);\n}\nvar _getOntologyFullMetadata = [0, \"/v2/ontologies/{0}/fullMetadata\"];\nfunction getOntologyFullMetadata($ctx, ...args) {\n return foundryPlatformFetch($ctx, _getOntologyFullMetadata, ...args);\n}\nexport { getOntologyFullMetadata, getOntologyV2, listOntologiesV2 };","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from \"@osdk/generator-converters\";\nimport { getObjectTypeFullMetadata } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectV2\";\nexport async function loadFullObjectMetadata(client, objtype) {\n const full = await getObjectTypeFullMetadata(client, client.ontologyRid, objtype, {\n preview: true\n });\n return wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport { getInterfaceType } from \"@osdk/internal.foundry/OntologiesV2_OntologyObjectV2\";\nexport async function loadInterfaceDefinition(client, objtype) {\n const r = await getInterfaceType(client, client.ontologyRid, objtype, {\n preview: true\n });\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT = `osdk-client/${process.env.PACKAGE_VERSION}`;"]}