@osdk/api 0.0.2 → 0.0.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 (70) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/js/chunk-I3UIWCJ4.js +17 -0
  3. package/build/js/chunk-I3UIWCJ4.js.map +1 -0
  4. package/build/js/chunk-II7ELH2S.mjs +8 -0
  5. package/build/js/chunk-II7ELH2S.mjs.map +1 -0
  6. package/build/js/index.js +20 -0
  7. package/build/js/index.js.map +1 -0
  8. package/build/js/index.mjs +9 -0
  9. package/build/js/index.mjs.map +1 -0
  10. package/build/js/public/objects.js +16 -0
  11. package/build/js/public/objects.js.map +1 -0
  12. package/build/js/public/objects.mjs +3 -0
  13. package/build/js/public/objects.mjs.map +1 -0
  14. package/build/types/client/Client.d.ts +8 -0
  15. package/build/types/client/ObjectSetCreator.d.ts +15 -0
  16. package/build/types/client/PageResult.d.ts +5 -0
  17. package/build/types/client/PalantirApiError.d.ts +9 -0
  18. package/build/types/client/ResultOrError.d.ts +11 -0
  19. package/build/types/client/ThinClient.d.ts +13 -0
  20. package/build/types/client/UnknownError.d.ts +5 -0
  21. package/build/types/client/createClient.d.ts +3 -0
  22. package/build/types/client/createThinClient.d.ts +6 -0
  23. package/build/types/client/index.d.ts +8 -0
  24. package/build/types/client/internal/conversions/index.d.ts +4 -0
  25. package/build/types/client/internal/conversions/legacyToModernSingleAggregationResult.d.ts +4 -0
  26. package/build/types/client/internal/conversions/modernToLegacyAggregationClause.d.ts +4 -0
  27. package/build/types/client/internal/conversions/modernToLegacyGroupByClause.d.ts +4 -0
  28. package/build/types/client/internal/conversions/modernToLegacyWhereClause.d.ts +4 -0
  29. package/build/types/client/internal/net/V2_BASE.d.ts +1 -0
  30. package/build/types/client/internal/net/createOpenApiRequest.d.ts +2 -0
  31. package/build/types/client/internal/net/createOpenApiRequest.test.d.ts +1 -0
  32. package/build/types/client/internal/net/index.d.ts +2 -0
  33. package/build/types/client/internal/net/types.d.ts +357 -0
  34. package/build/types/client/object/aggregateOrThrow.d.ts +5 -0
  35. package/build/types/client/object/aggregateOrThrow.test.d.ts +1 -0
  36. package/build/types/client/object/fetchPageOrThrow.d.ts +10 -0
  37. package/build/types/client/object/index.d.ts +2 -0
  38. package/build/types/client/objectSet/LinkTypesFrom.d.ts +2 -0
  39. package/build/types/client/objectSet/ObjectSet.d.ts +25 -0
  40. package/build/types/client/objectSet/createObjectSet.d.ts +5 -0
  41. package/build/types/client/query/WhereClause.d.ts +24 -0
  42. package/build/types/client/query/aggregations/AggregatableKeys.d.ts +4 -0
  43. package/build/types/client/query/aggregations/AggregateOpts.d.ts +7 -0
  44. package/build/types/client/query/aggregations/AggregationResultsWithGroups.d.ts +10 -0
  45. package/build/types/client/query/aggregations/AggregationResultsWithoutGroups.d.ts +10 -0
  46. package/build/types/client/query/aggregations/AggregationsClause.d.ts +8 -0
  47. package/build/types/client/query/aggregations/AggregationsClause.test.d.ts +36 -0
  48. package/build/types/client/query/aggregations/AggregationsResults.d.ts +5 -0
  49. package/build/types/client/query/aggregations/AggregationsResults.test.d.ts +1 -0
  50. package/build/types/client/query/aggregations/GroupByClause.d.ts +12 -0
  51. package/build/types/client/query/aggregations/GroupByClause.test.d.ts +18 -0
  52. package/build/types/client/query/aggregations/GroupByMapper.d.ts +4 -0
  53. package/build/types/client/query/index.d.ts +7 -0
  54. package/build/types/index.d.ts +6 -0
  55. package/build/types/ontology/Definition.d.ts +36 -0
  56. package/build/types/ontology/OntologyMetadata.d.ts +5 -0
  57. package/build/types/ontology/OsdkObject.d.ts +3 -0
  58. package/build/types/ontology/OsdkObjectFrom.d.ts +6 -0
  59. package/build/types/ontology/index.d.ts +4 -0
  60. package/build/types/public/objects.d.ts +1 -0
  61. package/build/types/util/ArrayElement.d.ts +1 -0
  62. package/build/types/util/FetchAsJson.d.ts +15 -0
  63. package/build/types/util/NOOP.d.ts +3 -0
  64. package/build/types/util/StringArrayToUnion.d.ts +1 -0
  65. package/build/types/util/createFetchHeaderMutator.d.ts +1 -0
  66. package/build/types/util/createFetchOrThrow.d.ts +9 -0
  67. package/build/types/util/createRetryingFetch.d.ts +2 -0
  68. package/build/types/util/index.d.ts +9 -0
  69. package/build/types/util/stringifyBody.d.ts +1 -0
  70. package/package.json +8 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @osdk/api
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8790640: Adds generated types, errors, and requests for public api endpoints
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 45fa1aa: Test changeset
14
+
3
15
  ## 0.0.2
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var a = require('tiny-invariant');
4
+ var requests = require('@osdk/gateway/requests');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var a__default = /*#__PURE__*/_interopDefault(a);
9
+
10
+ var E=Object.defineProperty;var $=(o,r)=>{for(var e in r)E(o,e,{get:r[e],enumerable:!0});};function g(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function y(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function m(o){return o?Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(o){if("$and"in o)return {type:"and",value:o.$and.map(p)};if("$or"in o)return {type:"or",value:o.$or.map(p)};if("$not"in o)return {type:"not",value:p(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"Defined key values are only allowed when they are not undefined."):a__default.default(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"WhereClause Filter with multiple properties isn't allowed"):a__default.default(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}function u(o,r,e="/api"){return async function(n,l,s,b,A,h,v){let d=new URL(`${e}${l}`,j(o));for(let[f,i]of Object.entries(b||{}))if(Array.isArray(i))for(let w of i)d.searchParams.append(f,w);else d.searchParams.append(f,i);let c=new Headers;return h!=null&&c.set("Content-Type",h),v!=null&&c.set("Accept",v),Object.entries(A||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());}),(await r(d.toString(),{body:JSON.stringify(s),method:n,headers:c})).json()}}function j(o){let r=/^https?:\/\//i,e="https://";return r.test(o)?o.replace(/^http:\/\//i,e):`${e}${o}`}async function N(o,r,e){let t={aggregation:y(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=m(e.groupBy)),e.where&&(t.where=p(e.where));let n=await requests.aggregateObjectsV2(u(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(s=>({group:s.group,values:g(s)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"no group by clause should mean only one data result"):a__default.default(!1)),g(n.data[0]))}async function T(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let l=await requests.loadObjectSetV2(u(o.stack,o.fetchJson),o.ontology.metadata.ontologyApiName,n);return {data:l.data.map(s=>({...s,__name:r})),nextPageToken:l.nextPageToken}}var D={};$(D,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
11
+
12
+ exports.a = p;
13
+ exports.b = N;
14
+ exports.c = T;
15
+ exports.d = D;
16
+ //# sourceMappingURL=out.js.map
17
+ //# sourceMappingURL=chunk-I3UIWCJ4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","createOpenApiRequest","basePath","fetchFn","contextPath","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","protocolRegex","httpsProtocol","aggregateObjectsV2","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAA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sBuC,EAAiBC,EAAYC,EAAYC,EAAK,CAClE,IAAMC,EAAO,CACX,YAAarC,EAAgCoC,EAAI,MAAM,EACvD,QAAS,CAAC,EACV,MAAO,MACT,EACIA,EAAI,UACNC,EAAK,QAAUhC,EAA4B+B,EAAI,OAAO,GAEpDA,EAAI,QACNC,EAAK,MAAQ5B,EAA0B2B,EAAI,KAAK,GAKlD,IAAME,EAAS,MAAMN,EAAmBnB,EAAqBqB,EAAW,MAAOA,EAAW,KAAK,EAAGA,EAAW,SAAS,SAAS,gBAAiBC,EAAYE,CAAI,EAChK,OAAKD,EAAI,QAIGE,EAAO,KAAK,IAAI1C,IACnB,CACL,MAAOA,EAAM,MACb,OAAQD,EAAsCC,CAAK,CACrD,EACD,GARG0C,EAAO,KAAK,SAAW,IAAK,QAAQ,IAAI,WAAa,aAAe5C,EAAU,GAAO,qDAAqD,EAAIA,EAAU,EAAK,GACxJC,EAAsC2C,EAAO,KAAK,CAAC,CAAC,EAU/D,CC/BA,OAAS,mBAAAC,MAAuB,yBAChC,eAAsBC,EAAiBC,EAAQN,EAAYO,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAR,CACF,EAAG,CACD,IAAME,EAAO,CACX,UAAAM,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRL,EAAK,UAAYK,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgB1B,EAAqB4B,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBJ,CAAI,EACpI,MAAO,CACL,KAAMO,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQV,CACV,EAAE,EACF,cAAeS,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAb,EAAA,qBAAAO","sourcesContent":["/*\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 !(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 (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 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 (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\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 invariant from \"tiny-invariant\";\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 const [field, filter] = parts[0];\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\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([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\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\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 default function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\") {\n return async function openApiRequest(method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {\n const url = new URL(`${contextPath}${endpointPath}`, withHttps(basePath));\n for (const [key, value] of Object.entries(queryArguments || {})) {\n if (Array.isArray(value)) {\n for (const item of value) {\n url.searchParams.append(key, item);\n }\n } else {\n url.searchParams.append(key, value);\n }\n }\n const headersInit = new Headers();\n if (requestMediaType != null) {\n headersInit.set(\"Content-Type\", requestMediaType);\n }\n if (responseMediaType != null) {\n headersInit.set(\"Accept\", responseMediaType);\n }\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const response = await fetchFn(url.toString(), {\n body: JSON.stringify(data),\n method: method,\n headers: headersInit\n });\n return response.json();\n };\n}\nfunction withHttps(url) {\n const protocolRegex = /^https?:\\/\\//i;\n const httpsProtocol = \"https://\";\n return protocolRegex.test(url) ? url.replace(/^http:\\/\\//i, httpsProtocol) : `${httpsProtocol}${url}`;\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { createOpenApiRequest } from \"#net\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, objectType, 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 // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(thinClient.stack, thinClient.fetch), thinClient.ontology.metadata.ontologyApiName, objectType, body);\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 legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\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 { createOpenApiRequest } from \"#net\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetchJson), client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\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 { aggregateOrThrow } from \"./aggregateOrThrow\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
@@ -0,0 +1,8 @@
1
+ import a from 'tiny-invariant';
2
+ import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
+
4
+ var E=Object.defineProperty;var $=(o,r)=>{for(var e in r)E(o,e,{get:r[e],enumerable:!0});};function g(o){return o.metrics.reduce((r,e)=>{let t=e.name.split(".");return t.length!=2&&(process.env.NODE_ENV!=="production"?a(!1,"assumed we were getting a `${key}.${type}`"):a(!1)),t[0]in r||(r[t[0]]={}),r[t[0]][t[1]]=e.value,r},{})}function y(o){return Object.entries(o).flatMap(([r,e])=>Array.isArray(e)?e.map(t=>({type:t,name:`${r}.${t}`,field:r})):[{type:e,name:`${r}.${e}`,field:r}])}function m(o){return o?Object.entries(o).flatMap(([r,e])=>e==="exact"?[{type:e,field:r}]:e.exactWithLimit?[{type:"exact",field:r,maxGroupCount:e.exactWithLimit}]:[]):[]}function p(o){if("$and"in o)return {type:"and",value:o.$and.map(p)};if("$or"in o)return {type:"or",value:o.$or.map(p)};if("$not"in o)return {type:"not",value:p(o.$not)};let r=Object.entries(o);if(r.length===1){let[e,t]=r[0];if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}}return {type:"and",value:Object.entries(o).map(([e,t])=>{if(t==null&&(process.env.NODE_ENV!=="production"?a(!1,"Defined key values are only allowed when they are not undefined."):a(!1)),typeof t=="string"||typeof t=="number")return {type:"eq",field:e,value:t};Object.keys(t).length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"WhereClause Filter with multiple properties isn't allowed"):a(!1));let n=Object.keys(t)[0];return t[n]==null&&(process.env.NODE_ENV!=="production"?a(!1):a(!1)),n==="ne"?{type:"not",value:{type:"eq",field:e,value:t[n]}}:{type:n,field:e,value:t[n]}})}}function u(o,r,e="/api"){return async function(n,l,s,b,A,h,v){let d=new URL(`${e}${l}`,j(o));for(let[f,i]of Object.entries(b||{}))if(Array.isArray(i))for(let w of i)d.searchParams.append(f,w);else d.searchParams.append(f,i);let c=new Headers;return h!=null&&c.set("Content-Type",h),v!=null&&c.set("Accept",v),Object.entries(A||{}).forEach(([f,i])=>{i!=null&&c.append(f,i.toString());}),(await r(d.toString(),{body:JSON.stringify(s),method:n,headers:c})).json()}}function j(o){let r=/^https?:\/\//i,e="https://";return r.test(o)?o.replace(/^http:\/\//i,e):`${e}${o}`}async function N(o,r,e){let t={aggregation:y(e.select),groupBy:[],where:void 0};e.groupBy&&(t.groupBy=m(e.groupBy)),e.where&&(t.where=p(e.where));let n=await aggregateObjectsV2(u(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,t);return e.groupBy?n.data.map(s=>({group:s.group,values:g(s)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a(!1,"no group by clause should mean only one data result"):a(!1)),g(n.data[0]))}async function T(o,r,e,t={type:"base",objectType:r}){let n={objectSet:t,select:e?.select??[]};e?.nextPageToken&&(n.pageToken=e.nextPageToken);let l=await loadObjectSetV2(u(o.stack,o.fetchJson),o.ontology.metadata.ontologyApiName,n);return {data:l.data.map(s=>({...s,__name:r})),nextPageToken:l.nextPageToken}}var D={};$(D,{aggregateOrThrow:()=>N,fetchPageOrThrow:()=>T});
5
+
6
+ export { p as a, N as b, T as c, D as d };
7
+ //# sourceMappingURL=out.js.map
8
+ //# sourceMappingURL=chunk-II7ELH2S.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/client/internal/conversions/modernToLegacyAggregationClause.ts","../../src/client/internal/conversions/modernToLegacyGroupByClause.ts","../../src/client/internal/conversions/modernToLegacyWhereClause.ts","../../src/client/internal/net/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../src/client/object/fetchPageOrThrow.ts","../../src/client/object/index.ts"],"names":["invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","createOpenApiRequest","basePath","fetchFn","contextPath","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","protocolRegex","httpsProtocol","aggregateObjectsV2","aggregateOrThrow","thinClient","objectType","req","body","result","loadObjectSetV2","fetchPageOrThrow","client","args","objectSet","r","d","object_exports","__export"],"mappings":"0FAgBA,OAAOA,MAAe,iBACf,SAASC,EAAsCC,EAAO,CAC3D,OAAOA,EAAM,QAAQ,OAAO,CAACC,EAAaC,IAAa,CACrD,IAAMC,EAAQD,EAAS,KAAK,MAAM,GAAG,EACrC,OAAEC,EAAM,QAAU,IAAK,QAAQ,IAAI,WAAa,aAAeL,EAAU,GAAO,4CAA4C,EAAIA,EAAU,EAAK,GACzIK,EAAM,CAAC,IAAKF,IAChBA,EAAYE,EAAM,CAAC,CAAC,EAAI,CAAC,GAE3BF,EAAYE,EAAM,CAAC,CAAC,EAAEA,EAAM,CAAC,CAAC,EAAID,EAAS,MACpCD,CACT,EAAG,CAAC,CAAC,CACP,CCXO,SAASG,EAAgCC,EAAQ,CACtD,OAAO,OAAO,QAAQA,CAAM,EAAE,QAAQ,CAAC,CAACC,EAAGC,CAAC,IACtC,MAAM,QAAQA,CAAC,EACVA,EAAE,IAAIC,IACJ,CACL,KAAMA,EACN,KAAM,GAAGF,CAAC,IAAIE,CAAE,GAChB,MAAOF,CACT,EACD,EAEM,CAAC,CACN,KAAMC,EAEN,KAAM,GAAGD,CAAC,IAAIC,CAAC,GACf,MAAOD,CACT,CAAC,CAEJ,CACH,CCnBO,SAASG,EAA4BC,EAAe,CACzD,OAAKA,EACE,OAAO,QAAQA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AYO,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAAR,CACF,EAAG,CACD,IAAME,EAAO,CACX,UAAAM,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACRL,EAAK,UAAYK,EAAK,eAExB,IAAME,EAAI,MAAML,EAAgB1B,EAAqB4B,EAAO,MAAOA,EAAO,SAAS,EAAGA,EAAO,SAAS,SAAS,gBAAiBJ,CAAI,EACpI,MAAO,CACL,KAAMO,EAAE,KAAK,IAAIC,IAAM,CACrB,GAAGA,EACH,OAAQV,CACV,EAAE,EACF,cAAeS,EAAE,aACnB,CACF,CCvCA,IAAAE,EAAA,GAAAC,EAAAD,EAAA,sBAAAb,EAAA,qBAAAO","sourcesContent":["/*\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 !(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 (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 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 (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\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 invariant from \"tiny-invariant\";\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 const [field, filter] = parts[0];\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\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([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\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\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 default function createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\") {\n return async function openApiRequest(method, endpointPath, data, queryArguments, headers, requestMediaType, responseMediaType) {\n const url = new URL(`${contextPath}${endpointPath}`, withHttps(basePath));\n for (const [key, value] of Object.entries(queryArguments || {})) {\n if (Array.isArray(value)) {\n for (const item of value) {\n url.searchParams.append(key, item);\n }\n } else {\n url.searchParams.append(key, value);\n }\n }\n const headersInit = new Headers();\n if (requestMediaType != null) {\n headersInit.set(\"Content-Type\", requestMediaType);\n }\n if (responseMediaType != null) {\n headersInit.set(\"Accept\", responseMediaType);\n }\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const response = await fetchFn(url.toString(), {\n body: JSON.stringify(data),\n method: method,\n headers: headersInit\n });\n return response.json();\n };\n}\nfunction withHttps(url) {\n const protocolRegex = /^https?:\\/\\//i;\n const httpsProtocol = \"https://\";\n return protocolRegex.test(url) ? url.replace(/^http:\\/\\//i, httpsProtocol) : `${httpsProtocol}${url}`;\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 { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"#client/converters\";\nimport { createOpenApiRequest } from \"#net\";\nimport { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nexport async function aggregateOrThrow(thinClient, objectType, 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 // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(thinClient.stack, thinClient.fetch), thinClient.ontology.metadata.ontologyApiName, objectType, body);\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 legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\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 { createOpenApiRequest } from \"#net\";\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetchJson), client.ontology.metadata.ontologyApiName, body);\n return {\n data: r.data.map(d => ({\n ...d,\n __name: objectType\n })),\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 { aggregateOrThrow } from \"./aggregateOrThrow\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow\";"]}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var chunkI3UIWCJ4_js = require('./chunk-I3UIWCJ4.js');
4
+ var b = require('fetch-retry');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var b__default = /*#__PURE__*/_interopDefault(b);
9
+
10
+ function u(r=fetch,e){return async function(t,o){return o?r(t,{...o,headers:await e(new Headers(o.headers))}):r(t,{headers:await e(new Headers)})}}var i=class extends Error{constructor(e,n,t,o,a,c){super(e),this.message=e,this.errorName=n,this.errorType=t,this.statusCode=o,this.errorInstanceId=a,this.parameters=c;}};var f=class extends i{constructor(e,n,t){super(e,n),this.originalError=t;}};function m(r=fetch){return async function(n,t){let o;try{o=await r(n,t);}catch(a){throw l(a,"A network error occured")}if(!o.ok){let a;try{a=await o.json();}catch(c){throw l(c,"A network error occured while reading response")}throw new i(a?.message??`Failed to fetch ${o.status} ${o.statusText}`,a?.errorName,a?.errorCode,o.status,a?.errorInstanceId,a?.parameters)}return o}}function l(r,e="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(e,"UNKNOWN")}var N=1e3,R=.5,I=3;function d(r){return b__default.default(r,{retryDelay(e){let n=N*2**e,t=n*R*(Math.random()*2-1);return n+t},retryOn(e,n,t){let o=t?.status??0;return !(o>=200&&o<300)&&j(n)&&e<I}})}function j(r){return !(r instanceof i&&r.statusCode!==k&&r.statusCode!==P)}var k=503,P=429;function y(r){return r!=null?JSON.stringify(r):void 0}function w(r=fetch){return r=u(r,e=>(e.set("Content-Type","application/json"),e)),async function(n,t){return (await r(n,{...t,body:y(t.body)})).json()}}function h(r,e,n,t=fetch){let o=u(d(m(t)),async a=>{let c=await n();return a.set("Authorization",`Bearer ${c}`),a.set("Fetch-User-Agent",r.metadata.userAgent),a});return {ontology:r,stack:e,fetch:o,fetchJson:w(o)}}var T="searchAround_";function p(r,e,n,t={type:"base",objectType:r}){let o={aggregate:c=>{throw "TODO"},aggregateOrThrow:async c=>chunkI3UIWCJ4_js.b(e,r,c),fetchPage:async c=>{throw "TODO"},fetchPageOrThrow:async c=>chunkI3UIWCJ4_js.c(e,r,c??{},t),asyncIter:()=>{throw ""},where:c=>p(r,e,n,{type:"filter",objectSet:t,where:chunkI3UIWCJ4_js.a(c)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(c,s){return a(c)().where(s?.$where??{})}};function a(c){return ()=>p(r,e,{},{type:"searchAround",objectSet:t,link:c})}return new Proxy(o,{get(c,s,g){return typeof s=="string"&&s.startsWith(T)?a(s.substring(T.length)):c[s]}})}function F(r){return new Proxy({},{get:(e,n,t)=>{if(typeof n=="string")return r.objectSet(n)}})}function C(r,e,n,t=fetch){let o=h(r,e,n,t),a=(s,g)=>p(s,o,g),c=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>F(c)}});return c}function E(r){return r.type==="ok"}
11
+
12
+ Object.defineProperty(exports, 'Objects', {
13
+ enumerable: true,
14
+ get: function () { return chunkI3UIWCJ4_js.d; }
15
+ });
16
+ exports.createClient = C;
17
+ exports.createThinClient = h;
18
+ exports.isOk = E;
19
+ //# sourceMappingURL=out.js.map
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/createFetchHeaderMutator.ts","../../src/client/PalantirApiError.ts","../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.ts","../../src/util/createRetryingFetch.ts","../../src/util/stringifyBody.ts","../../src/util/FetchAsJson.ts","../../src/client/createThinClient.ts","../../src/client/objectSet/createObjectSet.ts","../../src/client/ObjectSetCreator.ts","../../src/client/createClient.ts","../../src/client/ResultOrError.ts"],"names":["createFetchHeaderMutator","fetchFn","mutator","url","requestInit","PalantirApiError","message","errorName","errorType","statusCode","errorInstanceId","parameters","UnknownError","originalError","createFetchOrThrow","response","e","convertError","body","msgIfNotError","fetchRetry","INITIAL_DELAY","JITTER_FACTOR","MAX_RETRIES","createRetryingFetch","fetch","attempt","delay","jitter","error","status","isRetryable","SERVICE_UNAVAILABLE","TOO_MANY_REQUESTS","stringifyBody","createFetchAsJson","headers","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","token","searchAroundPrefix","createObjectSet","objectType","thinClient","opts","objectSet","base","req","aggregateOrThrow","args","fetchPageOrThrow","clause","modernToLegacyWhereClause","type","createSearchAround","link","target","p","receiver","createObjectSetCreator","client","createClient","objectSetFactory","isOk","result"],"mappings":"6DAgBO,SAASA,EAAyBC,EAAU,MAAOC,EAAS,CACjE,OAAO,eAAkCC,EAAKC,EAAa,CACzD,OAAKA,EAKEH,EAAQE,EAAK,CAClB,GAAGC,EACH,QAAS,MAAMF,EAAQ,IAAI,QAAQE,EAAY,OAAO,CAAC,CACzD,CAAC,EAPQH,EAAQE,EAAK,CAClB,QAAS,MAAMD,EAAQ,IAAI,OAAS,CACtC,CAAC,CAML,CACF,CCZO,IAAMG,EAAN,cAA+B,KAAM,CAC1C,YAAYC,EAASC,EAAWC,EAAWC,EAAYC,EAAiBC,EAAY,CAClF,MAAML,CAAO,EACb,KAAK,QAAUA,EACf,KAAK,UAAYC,EACjB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B,OAAOA,EAAO,OAAS,IACzB","sourcesContent":["/*\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 createFetchHeaderMutator(fetchFn = fetch, mutator) {\n return async function headerMutatedFetch(url, requestInit) {\n if (!requestInit) {\n return fetchFn(url, {\n headers: await mutator(new Headers())\n });\n }\n return fetchFn(url, {\n ...requestInit,\n headers: await mutator(new Headers(requestInit.headers))\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 class PalantirApiError extends Error {\n constructor(message, errorName, errorType, statusCode, errorInstanceId, parameters) {\n super(message);\n this.message = message;\n this.errorName = errorName;\n this.errorType = errorType;\n this.statusCode = statusCode;\n this.errorInstanceId = errorInstanceId;\n this.parameters = parameters;\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 { PalantirApiError } from \"./PalantirApiError\";\nexport class UnknownError extends PalantirApiError {\n constructor(message, errorType, originalError) {\n super(message, errorType);\n this.originalError = originalError;\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 { PalantirApiError } from \"../client/PalantirApiError\";\nimport { UnknownError } from \"../client/UnknownError\";\n\n/**\n * Wraps a fetch plugin so that all errors (including when statusCode is not in the 200s) are converted to either PalantirApiError or UnknownError.\n *\n * If the returned promise does not have an error state, you are free to immediately call `.json()` or equivalent.\n *\n * @param fetchFn\n * @returns\n */\nexport function createFetchOrThrow(fetchFn = fetch) {\n return async function fetchOrThrow(url, requestInit) {\n let response;\n try {\n response = await fetchFn(url, requestInit);\n } catch (e) {\n throw convertError(e, \"A network error occured\");\n }\n if (!response.ok) {\n let body;\n try {\n body = await response.json();\n } catch (e) {\n throw convertError(e, \"A network error occured while reading response\");\n }\n throw new PalantirApiError(body?.message ?? `Failed to fetch ${response.status} ${response.statusText}`, body?.errorName, body?.errorCode, response.status, body?.errorInstanceId, body?.parameters);\n }\n return response;\n };\n}\nfunction convertError(e, msgIfNotError = \"An unknown error occurred\") {\n if (e instanceof Error) {\n return new UnknownError(e.message, \"UNKNOWN\", e);\n }\n return new UnknownError(msgIfNotError, \"UNKNOWN\");\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 fetchRetry from \"fetch-retry\";\nimport { PalantirApiError } from \"../client/PalantirApiError\";\nconst INITIAL_DELAY = 1_000;\nconst JITTER_FACTOR = 0.5;\nconst MAX_RETRIES = 3;\nexport function createRetryingFetch(fetch) {\n return fetchRetry(fetch, {\n retryDelay(attempt) {\n const delay = INITIAL_DELAY * 2 ** attempt;\n const jitter = delay * JITTER_FACTOR * (Math.random() * 2 - 1);\n return delay + jitter;\n },\n retryOn(attempt, error, response) {\n const status = response?.status ?? 0;\n return !(status >= 200 && status < 300) && isRetryable(error) && attempt < MAX_RETRIES;\n }\n });\n}\nfunction isRetryable(e) {\n if (e instanceof PalantirApiError) {\n if (e.statusCode !== SERVICE_UNAVAILABLE && e.statusCode !== TOO_MANY_REQUESTS) {\n return false;\n }\n }\n return true; // I think this logic is flawed?\n}\n\nconst SERVICE_UNAVAILABLE = 503;\nconst TOO_MANY_REQUESTS = 429;","/*\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 stringifyBody(body) {\n return body != null ? JSON.stringify(body) : undefined;\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 { createFetchHeaderMutator } from \"./createFetchHeaderMutator\";\nimport { stringifyBody } from \"./stringifyBody\";\n\n/**\n * Fetches the given URL, converting the body to JSON, setting the Content-Type header to application/json,\n * and calling .json() on the response.\n */\n\n/**\n * Wraps a fetch function to set the Content-Type header to application/json, to handle JSON.stringify(),\n * and to parse the response as JSON.\n *\n * @param fetchFn The fetch function to wrap\n * @returns\n */\nexport function createFetchAsJson(fetchFn = fetch) {\n fetchFn = createFetchHeaderMutator(fetchFn, headers => {\n headers.set(\"Content-Type\", \"application/json\");\n return headers;\n });\n return async function fetchAsJson(url, requestInit) {\n return (await fetchFn(url, {\n ...requestInit,\n body: stringifyBody(requestInit.body)\n // TODO fix headers\n })).json();\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 { createFetchAsJson, createFetchHeaderMutator, createFetchOrThrow, createRetryingFetch } from \"#util\";\n/**\n * The goal of the thin client is to provide a way to tree shake as much as possible.\n */\n\nexport function createThinClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const retryingFetchWithAuthOrThrow = createFetchHeaderMutator(createRetryingFetch(createFetchOrThrow(fetchFn)), async headers => {\n const token = await tokenProvider();\n headers.set(\"Authorization\", `Bearer ${token}`);\n headers.set(\"Fetch-User-Agent\", ontology.metadata.userAgent);\n return headers;\n });\n return {\n ontology,\n stack,\n fetch: retryingFetchWithAuthOrThrow,\n fetchJson: createFetchAsJson(retryingFetchWithAuthOrThrow)\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 { modernToLegacyWhereClause } from \"#client/converters\";\nimport { aggregateOrThrow, fetchPageOrThrow } from \"../object\";\nconst searchAroundPrefix = \"searchAround_\";\nexport function createObjectSet(objectType, thinClient, opts, objectSet = {\n type: \"base\",\n objectType\n}) {\n const base = {\n aggregate: req => {\n throw \"TODO\";\n },\n aggregateOrThrow: async req => {\n return aggregateOrThrow(thinClient, objectType, req);\n },\n fetchPage: async args => {\n throw \"TODO\";\n },\n fetchPageOrThrow: async args => {\n return fetchPageOrThrow(thinClient, objectType, args ?? {}, objectSet);\n },\n asyncIter: () => {\n throw \"\";\n },\n where: clause => {\n return createObjectSet(objectType, thinClient, opts, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause)\n });\n },\n [Symbol.asyncIterator]: () => {\n throw \"\";\n },\n pivotTo: function (type, opts) {\n return createSearchAround(type)().where(opts?.$where ?? {});\n }\n };\n function createSearchAround(link) {\n return () => {\n return createObjectSet(objectType, thinClient, {}, {\n type: \"searchAround\",\n objectSet,\n link\n });\n };\n }\n return new Proxy(base, {\n get(target, p, receiver) {\n if (typeof p === \"string\" && p.startsWith(searchAroundPrefix)) {\n return createSearchAround(p.substring(searchAroundPrefix.length));\n }\n return target[p];\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\n/**\n * A type that creates an object set for each object in the ontology.\n */\n\n/**\n * Create a proxy for the object set creator.\n * @param client The client to use to create the object sets.\n * @returns A proxy for the object set creator.\n */\nexport function createObjectSetCreator(client) {\n return new Proxy({}, {\n get: (target, p, receiver) => {\n if (typeof p === \"string\") return client.objectSet(p);\n return undefined;\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 { createThinClient } from \"./createThinClient\";\nimport { createObjectSet } from \"./objectSet/createObjectSet\";\nimport { createObjectSetCreator } from \"./ObjectSetCreator\";\nexport function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const thinClient = createThinClient(ontology, stack, tokenProvider, fetchFn);\n const objectSetFactory = (type, opts) => createObjectSet(type, thinClient, opts);\n const client = Object.defineProperties({}, {\n objectSet: {\n get: () => objectSetFactory\n },\n objects: {\n get: () => createObjectSetCreator(client)\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\nexport function isOk(result) {\n return result.type === \"ok\";\n}"]}
@@ -0,0 +1,9 @@
1
+ import { b as b$1, c, a } from './chunk-II7ELH2S.mjs';
2
+ export { d as Objects } from './chunk-II7ELH2S.mjs';
3
+ import b from 'fetch-retry';
4
+
5
+ function u(r=fetch,e){return async function(t,o){return o?r(t,{...o,headers:await e(new Headers(o.headers))}):r(t,{headers:await e(new Headers)})}}var i=class extends Error{constructor(e,n,t,o,a,c){super(e),this.message=e,this.errorName=n,this.errorType=t,this.statusCode=o,this.errorInstanceId=a,this.parameters=c;}};var f=class extends i{constructor(e,n,t){super(e,n),this.originalError=t;}};function m(r=fetch){return async function(n,t){let o;try{o=await r(n,t);}catch(a){throw l(a,"A network error occured")}if(!o.ok){let a;try{a=await o.json();}catch(c){throw l(c,"A network error occured while reading response")}throw new i(a?.message??`Failed to fetch ${o.status} ${o.statusText}`,a?.errorName,a?.errorCode,o.status,a?.errorInstanceId,a?.parameters)}return o}}function l(r,e="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(e,"UNKNOWN")}var N=1e3,R=.5,I=3;function d(r){return b(r,{retryDelay(e){let n=N*2**e,t=n*R*(Math.random()*2-1);return n+t},retryOn(e,n,t){let o=t?.status??0;return !(o>=200&&o<300)&&j(n)&&e<I}})}function j(r){return !(r instanceof i&&r.statusCode!==k&&r.statusCode!==P)}var k=503,P=429;function y(r){return r!=null?JSON.stringify(r):void 0}function w(r=fetch){return r=u(r,e=>(e.set("Content-Type","application/json"),e)),async function(n,t){return (await r(n,{...t,body:y(t.body)})).json()}}function h(r,e,n,t=fetch){let o=u(d(m(t)),async a=>{let c=await n();return a.set("Authorization",`Bearer ${c}`),a.set("Fetch-User-Agent",r.metadata.userAgent),a});return {ontology:r,stack:e,fetch:o,fetchJson:w(o)}}var T="searchAround_";function p(r,e,n,t={type:"base",objectType:r}){let o={aggregate:c=>{throw "TODO"},aggregateOrThrow:async c=>b$1(e,r,c),fetchPage:async c=>{throw "TODO"},fetchPageOrThrow:async c$1=>c(e,r,c$1??{},t),asyncIter:()=>{throw ""},where:c=>p(r,e,n,{type:"filter",objectSet:t,where:a(c)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(c,s){return a$1(c)().where(s?.$where??{})}};function a$1(c){return ()=>p(r,e,{},{type:"searchAround",objectSet:t,link:c})}return new Proxy(o,{get(c,s,g){return typeof s=="string"&&s.startsWith(T)?a$1(s.substring(T.length)):c[s]}})}function F(r){return new Proxy({},{get:(e,n,t)=>{if(typeof n=="string")return r.objectSet(n)}})}function C(r,e,n,t=fetch){let o=h(r,e,n,t),a=(s,g)=>p(s,o,g),c=Object.defineProperties({},{objectSet:{get:()=>a},objects:{get:()=>F(c)}});return c}function E(r){return r.type==="ok"}
6
+
7
+ export { C as createClient, h as createThinClient, E as isOk };
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/createFetchHeaderMutator.ts","../../src/client/PalantirApiError.ts","../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.ts","../../src/util/createRetryingFetch.ts","../../src/util/stringifyBody.ts","../../src/util/FetchAsJson.ts","../../src/client/createThinClient.ts","../../src/client/objectSet/createObjectSet.ts","../../src/client/ObjectSetCreator.ts","../../src/client/createClient.ts","../../src/client/ResultOrError.ts"],"names":["createFetchHeaderMutator","fetchFn","mutator","url","requestInit","PalantirApiError","message","errorName","errorType","statusCode","errorInstanceId","parameters","UnknownError","originalError","createFetchOrThrow","response","e","convertError","body","msgIfNotError","fetchRetry","INITIAL_DELAY","JITTER_FACTOR","MAX_RETRIES","createRetryingFetch","fetch","attempt","delay","jitter","error","status","isRetryable","SERVICE_UNAVAILABLE","TOO_MANY_REQUESTS","stringifyBody","createFetchAsJson","headers","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","token","searchAroundPrefix","createObjectSet","objectType","thinClient","opts","objectSet","base","req","aggregateOrThrow","args","fetchPageOrThrow","clause","modernToLegacyWhereClause","type","createSearchAround","link","target","p","receiver","createObjectSetCreator","client","createClient","objectSetFactory","isOk","result"],"mappings":"8DAgBO,SAASA,EAAyBC,EAAU,MAAOC,EAAS,CACjE,OAAO,eAAkCC,EAAKC,EAAa,CACzD,OAAKA,EAKEH,EAAQE,EAAK,CAClB,GAAGC,EACH,QAAS,MAAMF,EAAQ,IAAI,QAAQE,EAAY,OAAO,CAAC,CACzD,CAAC,EAPQH,EAAQE,EAAK,CAClB,QAAS,MAAMD,EAAQ,IAAI,OAAS,CACtC,CAAC,CAML,CACF,CCZO,IAAMG,EAAN,cAA+B,KAAM,CAC1C,YAAYC,EAASC,EAAWC,EAAWC,EAAYC,EAAiBC,EAAY,CAClF,MAAML,CAAO,EACb,KAAK,QAAUA,EACf,KAAK,UAAYC,EACjB,KAAK,UAAYC,EACjB,KAAK,WAAaC,EAClB,KAAK,gBAAkBC,EACvB,KAAK,WAAaC,CACpB,CACF,ECTO,IAAMC,EAAN,cAA2BP,CAAiB,CACjD,YAAYC,EAASE,EAAWK,EAAe,CAC7C,MAAMP,EAASE,CAAS,EACxB,KAAK,cAAgBK,CACvB,CACF,ECKO,SAASC,EAAmBb,EAAU,MAAO,CAClD,OAAO,eAA4BE,EAAKC,EAAa,CACnD,IAAIW,EACJ,GAAI,CACFA,EAAW,MAAMd,EAAQE,EAAKC,CAAW,CAC3C,OAASY,EAAG,CACV,MAAMC,EAAaD,EAAG,yBAAyB,CACjD,CACA,GAAI,CAACD,EAAS,GAAI,CAChB,IAAIG,EACJ,GAAI,CACFA,EAAO,MAAMH,EAAS,KAAK,CAC7B,OAASC,EAAG,CACV,MAAMC,EAAaD,EAAG,gDAAgD,CACxE,CACA,MAAM,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AAM,UAAYA,EAAE,WAAWjB,CAAkB,EACnDc,EAAmBG,EAAE,UAAUjB,EAAmB,MAAM,CAAC,EAE3DgB,EAAOC,CAAC,CACjB,CACF,CAAC,CACH,CC7CO,SAASE,EAAuBC,EAAQ,CAC7C,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,IAAK,CAACJ,EAAQC,EAAGC,IAAa,CAC5B,GAAI,OAAOD,GAAM,SAAU,OAAOG,EAAO,UAAUH,CAAC,CAEtD,CACF,CAAC,CACH,CCbO,SAASI,EAAa1B,EAAUC,EAAOC,EAAevC,EAAU,MAAO,CAC5E,IAAM6C,EAAaT,EAAiBC,EAAUC,EAAOC,EAAevC,CAAO,EACrEgE,EAAmB,CAACT,EAAMT,IAASH,EAAgBY,EAAMV,EAAYC,CAAI,EACzEgB,EAAS,OAAO,iBAAiB,CAAC,EAAG,CACzC,UAAW,CACT,IAAK,IAAME,CACb,EACA,QAAS,CACP,IAAK,IAAMH,EAAuBC,CAAM,CAC1C,CACF,CAAC,EACD,OAAOA,CACT,CCfO,SAASG,EAAKC,EAAQ,CAC3B,OAAOA,EAAO,OAAS,IACzB","sourcesContent":["/*\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 createFetchHeaderMutator(fetchFn = fetch, mutator) {\n return async function headerMutatedFetch(url, requestInit) {\n if (!requestInit) {\n return fetchFn(url, {\n headers: await mutator(new Headers())\n });\n }\n return fetchFn(url, {\n ...requestInit,\n headers: await mutator(new Headers(requestInit.headers))\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 class PalantirApiError extends Error {\n constructor(message, errorName, errorType, statusCode, errorInstanceId, parameters) {\n super(message);\n this.message = message;\n this.errorName = errorName;\n this.errorType = errorType;\n this.statusCode = statusCode;\n this.errorInstanceId = errorInstanceId;\n this.parameters = parameters;\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 { PalantirApiError } from \"./PalantirApiError\";\nexport class UnknownError extends PalantirApiError {\n constructor(message, errorType, originalError) {\n super(message, errorType);\n this.originalError = originalError;\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 { PalantirApiError } from \"../client/PalantirApiError\";\nimport { UnknownError } from \"../client/UnknownError\";\n\n/**\n * Wraps a fetch plugin so that all errors (including when statusCode is not in the 200s) are converted to either PalantirApiError or UnknownError.\n *\n * If the returned promise does not have an error state, you are free to immediately call `.json()` or equivalent.\n *\n * @param fetchFn\n * @returns\n */\nexport function createFetchOrThrow(fetchFn = fetch) {\n return async function fetchOrThrow(url, requestInit) {\n let response;\n try {\n response = await fetchFn(url, requestInit);\n } catch (e) {\n throw convertError(e, \"A network error occured\");\n }\n if (!response.ok) {\n let body;\n try {\n body = await response.json();\n } catch (e) {\n throw convertError(e, \"A network error occured while reading response\");\n }\n throw new PalantirApiError(body?.message ?? `Failed to fetch ${response.status} ${response.statusText}`, body?.errorName, body?.errorCode, response.status, body?.errorInstanceId, body?.parameters);\n }\n return response;\n };\n}\nfunction convertError(e, msgIfNotError = \"An unknown error occurred\") {\n if (e instanceof Error) {\n return new UnknownError(e.message, \"UNKNOWN\", e);\n }\n return new UnknownError(msgIfNotError, \"UNKNOWN\");\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 fetchRetry from \"fetch-retry\";\nimport { PalantirApiError } from \"../client/PalantirApiError\";\nconst INITIAL_DELAY = 1_000;\nconst JITTER_FACTOR = 0.5;\nconst MAX_RETRIES = 3;\nexport function createRetryingFetch(fetch) {\n return fetchRetry(fetch, {\n retryDelay(attempt) {\n const delay = INITIAL_DELAY * 2 ** attempt;\n const jitter = delay * JITTER_FACTOR * (Math.random() * 2 - 1);\n return delay + jitter;\n },\n retryOn(attempt, error, response) {\n const status = response?.status ?? 0;\n return !(status >= 200 && status < 300) && isRetryable(error) && attempt < MAX_RETRIES;\n }\n });\n}\nfunction isRetryable(e) {\n if (e instanceof PalantirApiError) {\n if (e.statusCode !== SERVICE_UNAVAILABLE && e.statusCode !== TOO_MANY_REQUESTS) {\n return false;\n }\n }\n return true; // I think this logic is flawed?\n}\n\nconst SERVICE_UNAVAILABLE = 503;\nconst TOO_MANY_REQUESTS = 429;","/*\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 stringifyBody(body) {\n return body != null ? JSON.stringify(body) : undefined;\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 { createFetchHeaderMutator } from \"./createFetchHeaderMutator\";\nimport { stringifyBody } from \"./stringifyBody\";\n\n/**\n * Fetches the given URL, converting the body to JSON, setting the Content-Type header to application/json,\n * and calling .json() on the response.\n */\n\n/**\n * Wraps a fetch function to set the Content-Type header to application/json, to handle JSON.stringify(),\n * and to parse the response as JSON.\n *\n * @param fetchFn The fetch function to wrap\n * @returns\n */\nexport function createFetchAsJson(fetchFn = fetch) {\n fetchFn = createFetchHeaderMutator(fetchFn, headers => {\n headers.set(\"Content-Type\", \"application/json\");\n return headers;\n });\n return async function fetchAsJson(url, requestInit) {\n return (await fetchFn(url, {\n ...requestInit,\n body: stringifyBody(requestInit.body)\n // TODO fix headers\n })).json();\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 { createFetchAsJson, createFetchHeaderMutator, createFetchOrThrow, createRetryingFetch } from \"#util\";\n/**\n * The goal of the thin client is to provide a way to tree shake as much as possible.\n */\n\nexport function createThinClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const retryingFetchWithAuthOrThrow = createFetchHeaderMutator(createRetryingFetch(createFetchOrThrow(fetchFn)), async headers => {\n const token = await tokenProvider();\n headers.set(\"Authorization\", `Bearer ${token}`);\n headers.set(\"Fetch-User-Agent\", ontology.metadata.userAgent);\n return headers;\n });\n return {\n ontology,\n stack,\n fetch: retryingFetchWithAuthOrThrow,\n fetchJson: createFetchAsJson(retryingFetchWithAuthOrThrow)\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 { modernToLegacyWhereClause } from \"#client/converters\";\nimport { aggregateOrThrow, fetchPageOrThrow } from \"../object\";\nconst searchAroundPrefix = \"searchAround_\";\nexport function createObjectSet(objectType, thinClient, opts, objectSet = {\n type: \"base\",\n objectType\n}) {\n const base = {\n aggregate: req => {\n throw \"TODO\";\n },\n aggregateOrThrow: async req => {\n return aggregateOrThrow(thinClient, objectType, req);\n },\n fetchPage: async args => {\n throw \"TODO\";\n },\n fetchPageOrThrow: async args => {\n return fetchPageOrThrow(thinClient, objectType, args ?? {}, objectSet);\n },\n asyncIter: () => {\n throw \"\";\n },\n where: clause => {\n return createObjectSet(objectType, thinClient, opts, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause)\n });\n },\n [Symbol.asyncIterator]: () => {\n throw \"\";\n },\n pivotTo: function (type, opts) {\n return createSearchAround(type)().where(opts?.$where ?? {});\n }\n };\n function createSearchAround(link) {\n return () => {\n return createObjectSet(objectType, thinClient, {}, {\n type: \"searchAround\",\n objectSet,\n link\n });\n };\n }\n return new Proxy(base, {\n get(target, p, receiver) {\n if (typeof p === \"string\" && p.startsWith(searchAroundPrefix)) {\n return createSearchAround(p.substring(searchAroundPrefix.length));\n }\n return target[p];\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\n/**\n * A type that creates an object set for each object in the ontology.\n */\n\n/**\n * Create a proxy for the object set creator.\n * @param client The client to use to create the object sets.\n * @returns A proxy for the object set creator.\n */\nexport function createObjectSetCreator(client) {\n return new Proxy({}, {\n get: (target, p, receiver) => {\n if (typeof p === \"string\") return client.objectSet(p);\n return undefined;\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 { createThinClient } from \"./createThinClient\";\nimport { createObjectSet } from \"./objectSet/createObjectSet\";\nimport { createObjectSetCreator } from \"./ObjectSetCreator\";\nexport function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {\n const thinClient = createThinClient(ontology, stack, tokenProvider, fetchFn);\n const objectSetFactory = (type, opts) => createObjectSet(type, thinClient, opts);\n const client = Object.defineProperties({}, {\n objectSet: {\n get: () => objectSetFactory\n },\n objects: {\n get: () => createObjectSetCreator(client)\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\nexport function isOk(result) {\n return result.type === \"ok\";\n}"]}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkI3UIWCJ4_js = require('../chunk-I3UIWCJ4.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, 'aggregateOrThrow', {
8
+ enumerable: true,
9
+ get: function () { return chunkI3UIWCJ4_js.b; }
10
+ });
11
+ Object.defineProperty(exports, 'fetchPageOrThrow', {
12
+ enumerable: true,
13
+ get: function () { return chunkI3UIWCJ4_js.c; }
14
+ });
15
+ //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { b as aggregateOrThrow, c as fetchPageOrThrow } from '../chunk-II7ELH2S.mjs';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=objects.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
2
+ import type { ObjectSet, ObjectSetOptions } from "./objectSet/ObjectSet";
3
+ import type { ObjectSetCreator } from "./ObjectSetCreator";
4
+ export type ConcreteObjectType<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = O["objects"][K];
5
+ export interface Client<O extends OntologyDefinition<any>> {
6
+ objectSet: <const K extends ObjectTypesFrom<O>>(type: K, opts?: ObjectSetOptions<O, K>) => ObjectSet<O, K>;
7
+ objects: ObjectSetCreator<O>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
2
+ import type { Client } from "./Client";
3
+ import type { ObjectSet } from "./objectSet/ObjectSet";
4
+ /**
5
+ * A type that creates an object set for each object in the ontology.
6
+ */
7
+ export type ObjectSetCreator<D extends OntologyDefinition<any>> = {
8
+ [T in ObjectTypesFrom<D>]: ObjectSet<D, T>;
9
+ };
10
+ /**
11
+ * Create a proxy for the object set creator.
12
+ * @param client The client to use to create the object sets.
13
+ * @returns A proxy for the object set creator.
14
+ */
15
+ export declare function createObjectSetCreator<T extends Client<any>>(client: T): {};
@@ -0,0 +1,5 @@
1
+ import type { OsdkObject } from "#ontology";
2
+ export interface PageResult<T extends OsdkObject<any>> {
3
+ data: T[];
4
+ nextPageToken: string | undefined;
5
+ }
@@ -0,0 +1,9 @@
1
+ export declare class PalantirApiError extends Error implements PalantirApiError {
2
+ message: string;
3
+ errorName?: string;
4
+ errorType?: string;
5
+ statusCode?: number;
6
+ errorInstanceId?: string;
7
+ parameters?: any;
8
+ constructor(message: string, errorName?: string, errorType?: string, statusCode?: number, errorInstanceId?: string, parameters?: any);
9
+ }
@@ -0,0 +1,11 @@
1
+ export type ResultOrError<T extends object> = ({
2
+ type: "ok";
3
+ err?: never;
4
+ } & T) | {
5
+ type: "err";
6
+ data?: never;
7
+ err?: unknown;
8
+ };
9
+ export declare function isOk(result: ResultOrError<any>): result is {
10
+ type: "ok";
11
+ };
@@ -0,0 +1,13 @@
1
+ import type * as ontology from "#ontology";
2
+ import type { FetchAsJsonFn } from "#util";
3
+ export interface ThinClient<O extends ontology.OntologyDefinition<any>> {
4
+ ontology: O;
5
+ stack: string;
6
+ /**
7
+ * The fetch function to use for all requests.
8
+ *
9
+ * TODO: Document what is needed to get retry logic
10
+ */
11
+ fetch: typeof globalThis.fetch;
12
+ fetchJson: FetchAsJsonFn;
13
+ }
@@ -0,0 +1,5 @@
1
+ import { PalantirApiError } from "./PalantirApiError";
2
+ export declare class UnknownError extends PalantirApiError {
3
+ originalError: Error | undefined;
4
+ constructor(message: string, errorType: string, originalError?: Error);
5
+ }
@@ -0,0 +1,3 @@
1
+ import type { OntologyDefinition } from "#ontology";
2
+ import type { Client } from "./Client";
3
+ export declare function createClient<O extends OntologyDefinition<any>>(ontology: O, stack: string, tokenProvider: () => string, fetchFn?: typeof globalThis.fetch): Client<O>;
@@ -0,0 +1,6 @@
1
+ import type { OntologyDefinition } from "#ontology";
2
+ import type { ThinClient } from "./ThinClient";
3
+ /**
4
+ * The goal of the thin client is to provide a way to tree shake as much as possible.
5
+ */
6
+ export declare function createThinClient<T extends OntologyDefinition<any>>(ontology: T, stack: string, tokenProvider: () => string, fetchFn?: typeof globalThis.fetch): ThinClient<T>;
@@ -0,0 +1,8 @@
1
+ export type { Client } from "./Client";
2
+ export { createClient } from "./createClient";
3
+ export { createThinClient } from "./createThinClient";
4
+ export type { ObjectSet } from "./objectSet/ObjectSet";
5
+ export type { PageResult } from "./PageResult";
6
+ export { isOk } from "./ResultOrError";
7
+ export type { ResultOrError } from "./ResultOrError";
8
+ export type { ThinClient } from "./ThinClient";
@@ -0,0 +1,4 @@
1
+ export { legacyToModernSingleAggregationResult } from "./legacyToModernSingleAggregationResult";
2
+ export { modernToLegacyAggregationClause } from "./modernToLegacyAggregationClause";
3
+ export { modernToLegacyGroupByClause } from "./modernToLegacyGroupByClause";
4
+ export { modernToLegacyWhereClause } from "./modernToLegacyWhereClause";
@@ -0,0 +1,4 @@
1
+ import type { AggregationClause, AggregationResultsWithoutGroups } from "#client/query";
2
+ import type { Wire } from "#net";
3
+ import type { ArrayElement } from "#util";
4
+ export declare function legacyToModernSingleAggregationResult<AC extends AggregationClause<any, any>>(entry: ArrayElement<Wire.AggregateObjectsResponseV2["data"]>): AggregationResultsWithoutGroups<any, any, AC>;
@@ -0,0 +1,4 @@
1
+ import type { AggregationClause } from "#client/query";
2
+ import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
3
+ import type { Aggregation } from "@osdk/gateway/types";
4
+ export declare function modernToLegacyAggregationClause<T extends OntologyDefinition<any>, K extends ObjectTypesFrom<T>, AC extends AggregationClause<T, K>>(select: AC): Aggregation[];
@@ -0,0 +1,4 @@
1
+ import type { GroupByClause } from "#client/query";
2
+ import type { ObjectTypesFrom, OntologyDefinition } from "#ontology";
3
+ import type { AggregationGroupByV2 } from "@osdk/gateway/types";
4
+ export declare function modernToLegacyGroupByClause<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>>(groupByClause: GroupByClause<O, K> | undefined): AggregationGroupByV2[];
@@ -0,0 +1,4 @@
1
+ import type { WhereClause } from "#client/query";
2
+ import type { Wire } from "#net";
3
+ import type { ObjectDefinition } from "#ontology";
4
+ export declare function modernToLegacyWhereClause<T extends ObjectDefinition<any, any>>(whereClause: WhereClause<T>): Wire.SearchJsonQueryV2;
@@ -0,0 +1 @@
1
+ export declare const V2_BASE = "api/v2/ontologies";
@@ -0,0 +1,2 @@
1
+ import type { OpenApiRequest } from "@osdk/gateway/types";
2
+ export default function createOpenApiRequest<TExpectedResponse>(basePath: string, fetchFn: typeof fetch, contextPath?: string): OpenApiRequest<TExpectedResponse>;
@@ -0,0 +1,2 @@
1
+ export { default as createOpenApiRequest } from "./createOpenApiRequest";
2
+ export * as Wire from "./types";