@osdk/api 0.0.10 → 0.0.11

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 (62) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/js/index.js +4 -14
  3. package/build/js/index.js.map +1 -1
  4. package/build/js/index.mjs +3 -6
  5. package/build/js/index.mjs.map +1 -1
  6. package/build/js/public/utils.js +0 -1
  7. package/build/js/public/utils.mjs +0 -1
  8. package/build/types/index.d.ts +3 -4
  9. package/build/types/ontology/index.d.ts +3 -3
  10. package/build/types/util/index.d.ts +0 -3
  11. package/package.json +2 -2
  12. package/build/js/chunk-4D6JZ4TL.js +0 -7
  13. package/build/js/chunk-4D6JZ4TL.js.map +0 -1
  14. package/build/js/chunk-BYTHMUUS.mjs +0 -9
  15. package/build/js/chunk-BYTHMUUS.mjs.map +0 -1
  16. package/build/js/chunk-EVOZ7UGO.js +0 -19
  17. package/build/js/chunk-EVOZ7UGO.js.map +0 -1
  18. package/build/js/chunk-XIJ2ZQRX.mjs +0 -5
  19. package/build/js/chunk-XIJ2ZQRX.mjs.map +0 -1
  20. package/build/js/public/objects.js +0 -17
  21. package/build/js/public/objects.js.map +0 -1
  22. package/build/js/public/objects.mjs +0 -4
  23. package/build/js/public/objects.mjs.map +0 -1
  24. package/build/types/client/Client.d.ts +0 -8
  25. package/build/types/client/ObjectSetCreator.d.ts +0 -15
  26. package/build/types/client/PageResult.d.ts +0 -5
  27. package/build/types/client/createCachedOntologyTransform.d.ts +0 -7
  28. package/build/types/client/createClient.d.ts +0 -3
  29. package/build/types/client/index.d.ts +0 -8
  30. package/build/types/client/internal/conversions/index.d.ts +0 -4
  31. package/build/types/client/internal/conversions/legacyToModernSingleAggregationResult.d.ts +0 -4
  32. package/build/types/client/internal/conversions/modernToLegacyAggregationClause.d.ts +0 -4
  33. package/build/types/client/internal/conversions/modernToLegacyGroupByClause.d.ts +0 -4
  34. package/build/types/client/internal/conversions/modernToLegacyWhereClause.d.ts +0 -4
  35. package/build/types/client/internal/net/V2_BASE.d.ts +0 -1
  36. package/build/types/client/internal/net/index.d.ts +0 -1
  37. package/build/types/client/internal/net/types.d.ts +0 -357
  38. package/build/types/client/object/aggregateOrThrow.d.ts +0 -5
  39. package/build/types/client/object/aggregateOrThrow.test.d.ts +0 -1
  40. package/build/types/client/object/convertWireToOsdkObjects.d.ts +0 -4
  41. package/build/types/client/object/fetchPageOrThrow.d.ts +0 -10
  42. package/build/types/client/object/index.d.ts +0 -2
  43. package/build/types/client/objectSet/LinkTypesFrom.d.ts +0 -2
  44. package/build/types/client/objectSet/ObjectSet.d.ts +0 -25
  45. package/build/types/client/objectSet/createObjectSet.d.ts +0 -5
  46. package/build/types/client/query/WhereClause.d.ts +0 -24
  47. package/build/types/client/query/aggregations/AggregatableKeys.d.ts +0 -4
  48. package/build/types/client/query/aggregations/AggregateOpts.d.ts +0 -7
  49. package/build/types/client/query/aggregations/AggregationResultsWithGroups.d.ts +0 -10
  50. package/build/types/client/query/aggregations/AggregationResultsWithoutGroups.d.ts +0 -10
  51. package/build/types/client/query/aggregations/AggregationsClause.d.ts +0 -8
  52. package/build/types/client/query/aggregations/AggregationsClause.test.d.ts +0 -42
  53. package/build/types/client/query/aggregations/AggregationsResults.d.ts +0 -5
  54. package/build/types/client/query/aggregations/AggregationsResults.test.d.ts +0 -1
  55. package/build/types/client/query/aggregations/GroupByClause.d.ts +0 -12
  56. package/build/types/client/query/aggregations/GroupByClause.test.d.ts +0 -21
  57. package/build/types/client/query/aggregations/GroupByMapper.d.ts +0 -4
  58. package/build/types/client/query/index.d.ts +0 -7
  59. package/build/types/public/objects.d.ts +0 -1
  60. package/build/types/util/ArrayElement.d.ts +0 -1
  61. package/build/types/util/NOOP.d.ts +0 -3
  62. package/build/types/util/StringArrayToUnion.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @osdk/api
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatability in @osdk/api"
8
+ - 848404c: Handle conflicts between object, action, and query names
9
+ - Updated dependencies [f3120fb]
10
+ - Updated dependencies [848404c]
11
+ - @osdk/gateway@0.0.4
12
+
3
13
  ## 0.0.10
4
14
 
5
15
  ### Patch Changes
package/build/js/index.js CHANGED
@@ -1,21 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkEVOZ7UGO_js = require('./chunk-EVOZ7UGO.js');
4
3
  var chunkSHYKLQMU_js = require('./chunk-SHYKLQMU.js');
5
- require('./chunk-4D6JZ4TL.js');
6
4
 
7
- var f=class extends chunkSHYKLQMU_js.b{constructor(t,c,n){super(t,c),this.originalError=n;}};function g(r=fetch){return async function(c,n){let a;try{a=await r(c,n);}catch(o){throw A(o,"A network error occured")}if(!a.ok){let o;try{o=await a.json();}catch(e){throw A(e,"A network error occured while reading response")}throw new chunkSHYKLQMU_js.b(o?.message??`Failed to fetch ${a.status} ${a.statusText}`,o?.errorName,o?.errorCode,a.status,o?.errorInstanceId,o?.parameters)}return a}}function A(r,t="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(t,"UNKNOWN")}function w(r){return r!=null?JSON.stringify(r):void 0}function y(r=fetch){return r=chunkSHYKLQMU_js.a(r,t=>(t.set("Content-Type","application/json"),t)),async function(c,n){return (await r(c,{...n,body:w(n.body)})).json()}}function h(r,t,c,n=fetch){let a=chunkSHYKLQMU_js.a(chunkSHYKLQMU_js.c(g(n)),async o=>{let e=await c();return o.set("Authorization",`Bearer ${e}`),o.set("Fetch-User-Agent",r.metadata.userAgent),o});return {ontology:r,stack:t,fetch:a,fetchJson:y(a)}}var T="searchAround_";function p(r,t,c,n={type:"base",objectType:r}){let a={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>chunkEVOZ7UGO_js.c(t,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>chunkEVOZ7UGO_js.d(t,r,e??{},n),asyncIter:()=>{throw ""},where:e=>p(r,t,c,{type:"filter",objectSet:n,where:chunkEVOZ7UGO_js.a(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,i){return o(e)().where(i?.$where??{})}};function o(e){return ()=>p(r,t,{},{type:"searchAround",objectSet:n,link:e})}return new Proxy(a,{get(e,i,O){return typeof i=="string"&&i.startsWith(T)?o(i.substring(T.length)):e[i]}})}function F(r){return new Proxy({},{get:(t,c,n)=>{if(typeof c=="string")return r.objectSet(c)}})}function b(r,t,c,n=fetch){let a=h(r,t,c,n),o=(i,O)=>p(i,a,O),e=Object.defineProperties({},{objectSet:{get:()=>o},objects:{get:()=>F(e)}});return e}function C(r){return r.type==="ok"}
5
+ function j(t,r,o="/api",c){return async function(e,s,O,F,T,k,l){let m=new URL(`${o}${s}`,J(t));for(let[u,i]of Object.entries(F||{}))if(i!=null)if(Array.isArray(i))for(let b of i)m.searchParams.append(u,b);else m.searchParams.append(u,i);let p=new Headers;p.set("Content-Type",k??"application/json"),p.set("Accept",l??"application/json"),Object.entries(T||{}).forEach(([u,i])=>{i!=null&&p.append(u,i.toString());});let N=B(O),w=await r(m.toString(),{body:N,method:e,headers:p});return l&&l==="*/*"?c?w.body:w.blob():w.json()}}function B(t){return t==null||globalThis.Blob&&t instanceof globalThis.Blob?t:JSON.stringify(t)}function J(t){let r=/^https?:\/\//i,o="https://";return r.test(t)?t.replace(/^http:\/\//i,o):`${o}${t}`}var f=class extends chunkSHYKLQMU_js.b{constructor(r,o,c){super(r,o),this.originalError=c;}};function d(t=fetch){return async function(o,c){let n;try{n=await t(o,c);}catch(e){throw x(e,"A network error occured")}if(!n.ok){let e;try{e=await n.json();}catch(s){throw x(s,"A network error occured while reading response")}throw new chunkSHYKLQMU_js.b(e?.message??`Failed to fetch ${n.status} ${n.statusText}`,e?.errorName,e?.errorCode,n.status,e?.errorInstanceId,e?.parameters)}return n}}function x(t,r="An unknown error occurred"){return t instanceof Error?new f(t.message,"UNKNOWN",t):new f(r,"UNKNOWN")}function g(t){return t!=null?JSON.stringify(t):void 0}function A(t=fetch){return t=chunkSHYKLQMU_js.a(t,r=>(r.set("Content-Type","application/json"),r)),async function(o,c){return (await t(o,{...c,body:g(c.body)})).json()}}function R(t,r,o,c=fetch){let n=chunkSHYKLQMU_js.a(chunkSHYKLQMU_js.c(d(c)),async e=>{let s=await o();return e.set("Authorization",`Bearer ${s}`),e.set("Fetch-User-Agent",t.metadata.userAgent),e});return {ontology:t,stack:r,fetch:n,fetchJson:A(n)}}function $(t){return t.type==="ok"}
8
6
 
9
- Object.defineProperty(exports, 'Objects', {
10
- enumerable: true,
11
- get: function () { return chunkEVOZ7UGO_js.e; }
12
- });
13
- Object.defineProperty(exports, 'createOpenApiRequest', {
14
- enumerable: true,
15
- get: function () { return chunkEVOZ7UGO_js.b; }
16
- });
17
- exports.createClient = b;
18
- exports.createThinClient = h;
19
- exports.isOk = C;
7
+ exports.createOpenApiRequest = j;
8
+ exports.createThinClient = R;
9
+ exports.isOk = $;
20
10
  //# sourceMappingURL=out.js.map
21
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.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":["UnknownError","PalantirApiError","message","errorType","originalError","createFetchOrThrow","fetchFn","url","requestInit","response","e","convertError","body","msgIfNotError","stringifyBody","createFetchAsJson","createFetchHeaderMutator","headers","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","createRetryingFetch","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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DgB,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,EAAa3B,EAAUC,EAAOC,EAAef,EAAU,MAAO,CAC5E,IAAMsB,EAAaV,EAAiBC,EAAUC,EAAOC,EAAef,CAAO,EACrEyC,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\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\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 \"../internal/conversions\";\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}"]}
1
+ {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.ts","../../src/util/stringifyBody.ts","../../src/util/FetchAsJson.ts","../../src/client/createThinClient.ts","../../src/client/ResultOrError.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","UnknownError","PalantirApiError","message","errorType","originalError","createFetchOrThrow","requestInit","convertError","e","msgIfNotError","stringifyBody","createFetchAsJson","createFetchHeaderMutator","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","createRetryingFetch","token","isOk","result"],"mappings":"iDAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAIO,GAAS,KAGb,GAAI,MAAM,QAAQA,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACxBA,EAAY,IAAI,eAAgBP,GAAoB,kBAAkB,EACtEO,EAAY,IAAI,SAAUN,GAAqB,kBAAkB,EACjE,OAAO,QAAQ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F,GAAM,gBAAiBA,GAAM,UAAU,CACrM,CACA,OAAOE,CACT,CACF,CACA,SAASU,EAAaC,EAAGC,EAAgB,4BAA6B,CACpE,OAAID,aAAa,MACR,IAAIR,EAAaQ,EAAE,QAAS,UAAWA,CAAC,EAE1C,IAAIR,EAAaS,EAAe,SAAS,CAClD,CCpCO,SAASC,EAAcf,EAAM,CAClC,OAAOA,GAAQ,KAAO,KAAK,UAAUA,CAAI,EAAI,MAC/C,CCaO,SAASgB,EAAkBhC,EAAU,MAAO,CACjD,OAAAA,EAAUiC,EAAyBjC,EAASO,IAC1CA,EAAQ,IAAI,eAAgB,kBAAkB,EACvCA,EACR,EACM,eAA2BG,EAAKiB,EAAa,CAClD,OAAQ,MAAM3B,EAAQU,EAAK,CACzB,GAAGiB,EACH,KAAMI,EAAcJ,EAAY,IAAI,CAEtC,CAAC,GAAG,KAAK,CACX,CACF,CCtBO,SAASO,EAAiBC,EAAUC,EAAOC,EAAerC,EAAU,MAAO,CAChF,IAAMsC,EAA+BL,EAAyBM,EAAoBb,EAAmB1B,CAAO,CAAC,EAAG,MAAMO,GAAW,CAC/H,IAAMiC,EAAQ,MAAMH,EAAc,EAClC,OAAA9B,EAAQ,IAAI,gBAAiB,UAAUiC,CAAK,EAAE,EAC9CjC,EAAQ,IAAI,mBAAoB4B,EAAS,SAAS,SAAS,EACpD5B,CACT,CAAC,EACD,MAAO,CACL,SAAA4B,EACA,MAAAC,EACA,MAAOE,EACP,UAAWN,EAAkBM,CAA4B,CAC3D,CACF,CClBO,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 createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { 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\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\nexport function isOk(result) {\n return result.type === \"ok\";\n}"]}
@@ -1,10 +1,7 @@
1
- import { c as c$1, d, a as a$1 } from './chunk-BYTHMUUS.mjs';
2
- export { e as Objects, b as createOpenApiRequest } from './chunk-BYTHMUUS.mjs';
3
- import { a, c, b as b$1 } from './chunk-BZ6L26S2.mjs';
4
- import './chunk-XIJ2ZQRX.mjs';
1
+ import { a, c, b } from './chunk-BZ6L26S2.mjs';
5
2
 
6
- var f=class extends b$1{constructor(t,c,n){super(t,c),this.originalError=n;}};function g(r=fetch){return async function(c,n){let a;try{a=await r(c,n);}catch(o){throw A(o,"A network error occured")}if(!a.ok){let o;try{o=await a.json();}catch(e){throw A(e,"A network error occured while reading response")}throw new b$1(o?.message??`Failed to fetch ${a.status} ${a.statusText}`,o?.errorName,o?.errorCode,a.status,o?.errorInstanceId,o?.parameters)}return a}}function A(r,t="An unknown error occurred"){return r instanceof Error?new f(r.message,"UNKNOWN",r):new f(t,"UNKNOWN")}function w(r){return r!=null?JSON.stringify(r):void 0}function y(r=fetch){return r=a(r,t=>(t.set("Content-Type","application/json"),t)),async function(c,n){return (await r(c,{...n,body:w(n.body)})).json()}}function h(r,t,c$1,n=fetch){let a$1=a(c(g(n)),async o=>{let e=await c$1();return o.set("Authorization",`Bearer ${e}`),o.set("Fetch-User-Agent",r.metadata.userAgent),o});return {ontology:r,stack:t,fetch:a$1,fetchJson:y(a$1)}}var T="searchAround_";function p(r,t,c,n={type:"base",objectType:r}){let a={aggregate:e=>{throw "TODO"},aggregateOrThrow:async e=>c$1(t,r,e),fetchPage:async e=>{throw "TODO"},fetchPageOrThrow:async e=>d(t,r,e??{},n),asyncIter:()=>{throw ""},where:e=>p(r,t,c,{type:"filter",objectSet:n,where:a$1(e)}),[Symbol.asyncIterator]:()=>{throw ""},pivotTo:function(e,i){return o(e)().where(i?.$where??{})}};function o(e){return ()=>p(r,t,{},{type:"searchAround",objectSet:n,link:e})}return new Proxy(a,{get(e,i,O){return typeof i=="string"&&i.startsWith(T)?o(i.substring(T.length)):e[i]}})}function F(r){return new Proxy({},{get:(t,c,n)=>{if(typeof c=="string")return r.objectSet(c)}})}function b(r,t,c,n=fetch){let a=h(r,t,c,n),o=(i,O)=>p(i,a,O),e=Object.defineProperties({},{objectSet:{get:()=>o},objects:{get:()=>F(e)}});return e}function C(r){return r.type==="ok"}
3
+ function j(t,r,o="/api",c){return async function(e,s,O,F,T,k,l){let m=new URL(`${o}${s}`,J(t));for(let[u,i]of Object.entries(F||{}))if(i!=null)if(Array.isArray(i))for(let b of i)m.searchParams.append(u,b);else m.searchParams.append(u,i);let p=new Headers;p.set("Content-Type",k??"application/json"),p.set("Accept",l??"application/json"),Object.entries(T||{}).forEach(([u,i])=>{i!=null&&p.append(u,i.toString());});let N=B(O),w=await r(m.toString(),{body:N,method:e,headers:p});return l&&l==="*/*"?c?w.body:w.blob():w.json()}}function B(t){return t==null||globalThis.Blob&&t instanceof globalThis.Blob?t:JSON.stringify(t)}function J(t){let r=/^https?:\/\//i,o="https://";return r.test(t)?t.replace(/^http:\/\//i,o):`${o}${t}`}var f=class extends b{constructor(r,o,c){super(r,o),this.originalError=c;}};function d(t=fetch){return async function(o,c){let n;try{n=await t(o,c);}catch(e){throw x(e,"A network error occured")}if(!n.ok){let e;try{e=await n.json();}catch(s){throw x(s,"A network error occured while reading response")}throw new b(e?.message??`Failed to fetch ${n.status} ${n.statusText}`,e?.errorName,e?.errorCode,n.status,e?.errorInstanceId,e?.parameters)}return n}}function x(t,r="An unknown error occurred"){return t instanceof Error?new f(t.message,"UNKNOWN",t):new f(r,"UNKNOWN")}function g(t){return t!=null?JSON.stringify(t):void 0}function A(t=fetch){return t=a(t,r=>(r.set("Content-Type","application/json"),r)),async function(o,c){return (await t(o,{...c,body:g(c.body)})).json()}}function R(t,r,o,c$1=fetch){let n=a(c(d(c$1)),async e=>{let s=await o();return e.set("Authorization",`Bearer ${s}`),e.set("Fetch-User-Agent",t.metadata.userAgent),e});return {ontology:t,stack:r,fetch:n,fetchJson:A(n)}}function $(t){return t.type==="ok"}
7
4
 
8
- export { b as createClient, h as createThinClient, C as isOk };
5
+ export { j as createOpenApiRequest, R as createThinClient, $ as isOk };
9
6
  //# sourceMappingURL=out.js.map
10
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.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":["UnknownError","PalantirApiError","message","errorType","originalError","createFetchOrThrow","fetchFn","url","requestInit","response","e","convertError","body","msgIfNotError","stringifyBody","createFetchAsJson","createFetchHeaderMutator","headers","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","createRetryingFetch","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":"yJAiBO,IAAMA,EAAN,cAA2BC,CAAiB,CACjD,YAAYC,EAASC,EAAWC,EAAe,CAC7C,MAAMF,EAASC,CAAS,EACxB,KAAK,cAAgBC,CACvB,CACF,ECKO,SAASC,EAAmBC,EAAU,MAAO,CAClD,OAAO,eAA4BC,EAAKC,EAAa,CACnD,IAAIC,EACJ,GAAI,CACFA,EAAW,MAAMH,EAAQC,EAAKC,CAAW,CAC3C,OAASE,EAAG,CACV,MAAMC,EAAaD,EAAG,yBAAyB,CACjD,CACA,GAAI,CAACD,EAAS,GAAI,CAChB,IAAIG,EACJ,GAAI,CACFA,EAAO,MAAMH,EAAS,KAAK,CAC7B,OAAS,EAAG,CACV,MAAME,EAAa,EAAG,gDAAgD,CACxE,CACA,MAAM,IAAIV,EAAiBW,GAAM,SAAW,mBAAmBH,EAAS,MAAM,IAAIA,EAAS,UAAU,GAAIG,GAAM,UAAWA,GAAM,UAAWH,EAAS,OAAQG,GAAM,gBAAiBA,GAAM,UAAU,CACrM,CACA,OAAOH,CACT,CACF,CACA,SAASE,EAAaD,EAAGG,EAAgB,4BAA6B,CACpE,OAAIH,aAAa,MACR,IAAIV,EAAaU,EAAE,QAAS,UAAWA,CAAC,EAE1C,IAAIV,EAAaa,EAAe,SAAS,CAClD,CCpCO,SAASC,EAAcF,EAAM,CAClC,OAAOA,GAAQ,KAAO,KAAK,UAAUA,CAAI,EAAI,MAC/C,CCaO,SAASG,EAAkBT,EAAU,MAAO,CACjD,OAAAA,EAAUU,EAAyBV,EAASW,IAC1CA,EAAQ,IAAI,eAAgB,kBAAkB,EACvCA,EACR,EACM,eAA2BV,EAAKC,EAAa,CAClD,OAAQ,MAAMF,E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F,CAAC,CAEL,CACA,OAAO,IAAI,MAAMT,EAAM,CACrB,IAAIU,EAAQC,EAAGC,EAAU,CACvB,OAAI,OAAOD,GAAM,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,EAAa3B,EAAUC,EAAOC,EAAef,EAAU,MAAO,CAC5E,IAAMsB,EAAaV,EAAiBC,EAAUC,EAAOC,EAAef,CAAO,EACrEyC,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\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\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 \"../internal/conversions\";\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}"]}
1
+ {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/UnknownError.ts","../../src/util/createFetchOrThrow.ts","../../src/util/stringifyBody.ts","../../src/util/FetchAsJson.ts","../../src/client/createThinClient.ts","../../src/client/ResultOrError.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","UnknownError","PalantirApiError","message","errorType","originalError","createFetchOrThrow","requestInit","convertError","e","msgIfNotError","stringifyBody","createFetchAsJson","createFetchHeaderMutator","createThinClient","ontology","stack","tokenProvider","retryingFetchWithAuthOrThrow","createRetryingFetch","token","isOk","result"],"mappings":"kDAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAIO,GAAS,KAGb,GAAI,MAAM,QAAQA,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAA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served.\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 createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { 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\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\nexport function isOk(result) {\n return result.type === \"ok\";\n}"]}
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkSHYKLQMU_js = require('../chunk-SHYKLQMU.js');
4
- require('../chunk-4D6JZ4TL.js');
5
4
 
6
5
 
7
6
 
@@ -1,4 +1,3 @@
1
1
  export { a as createFetchHeaderMutator, c as createRetryingFetch } from '../chunk-BZ6L26S2.mjs';
2
- import '../chunk-XIJ2ZQRX.mjs';
3
2
  //# sourceMappingURL=out.js.map
4
3
  //# sourceMappingURL=utils.mjs.map
@@ -1,9 +1,8 @@
1
- export { createClient, createThinClient, isOk } from "./client";
2
- export type { Client, ObjectSet, ResultOrError, ThinClient } from "./client";
3
1
  export { createOpenApiRequest } from "./client/createOpenApiRequest";
4
- export type { WhereClause } from "./client/query";
2
+ export { createThinClient } from "./client/createThinClient";
3
+ export { isOk, type ResultOrError } from "./client/ResultOrError";
4
+ export type { ThinClient } from "./client/ThinClient";
5
5
  export type { OsdkObject, OsdkObjectFrom } from "./ontology";
6
- export * as Objects from "./client/object";
7
6
  export type { LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./ontology/Definition";
8
7
  export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ValidActionParameterTypes, } from "./ontology/ActionDefinition";
9
8
  export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./ontology/QueryDefinition";
@@ -1,6 +1,6 @@
1
- export type * from "./ActionDefinition";
2
- export type * from "./Definition";
1
+ export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ObjectActionDataType, ObjectSetActionDataType, ValidActionParameterTypes, ValidBaseActionParameterTypes, } from "./ActionDefinition";
2
+ export type { LinkDefinition, LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectLink, OsdkObjectPropertyType, OsdkObjectRawPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./Definition";
3
3
  export type { OntologyMetadata } from "./OntologyMetadata";
4
4
  export type { OsdkObject } from "./OsdkObject";
5
5
  export type { OsdkObjectFrom } from "./OsdkObjectFrom";
6
- export type * from "./QueryDefinition";
6
+ export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./QueryDefinition";
@@ -1,9 +1,6 @@
1
- export type { ArrayElement } from "./ArrayElement";
2
1
  export { createFetchHeaderMutator } from "./createFetchHeaderMutator";
3
2
  export { createFetchOrThrow } from "./createFetchOrThrow";
4
3
  export { createRetryingFetch } from "./createRetryingFetch";
5
4
  export { createFetchAsJson } from "./FetchAsJson";
6
5
  export type { FetchAsJsonFn } from "./FetchAsJson";
7
- export type { NOOP } from "./NOOP";
8
- export type { StringArrayToUnion } from "./StringArrayToUnion";
9
6
  export { stringifyBody } from "./stringifyBody";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/api",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -20,7 +20,7 @@
20
20
  "@types/geojson": "^7946.0.13",
21
21
  "fetch-retry": "^5.0.6",
22
22
  "tiny-invariant": "^1.3.1",
23
- "@osdk/gateway": "0.0.3"
23
+ "@osdk/gateway": "0.0.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "ts-expect": "^1.3.0",
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
4
-
5
- exports.a = e;
6
- //# sourceMappingURL=out.js.map
7
- //# sourceMappingURL=chunk-4D6JZ4TL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,9 +0,0 @@
1
- import { a } from './chunk-XIJ2ZQRX.mjs';
2
- import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
3
- import a$1 from 'tiny-invariant';
4
-
5
- function f(o,r,t="/api",e){return async function(s,p,N,A,E,$,d){let y=new URL(`${t}${p}`,B(o));for(let[l,i]of Object.entries(A||{}))if(i!=null)if(Array.isArray(i))for(let D of i)y.searchParams.append(l,D);else y.searchParams.append(l,i);let u=new Headers;u.set("Content-Type",$??"application/json"),u.set("Accept",d??"application/json"),Object.entries(E||{}).forEach(([l,i])=>{i!=null&&u.append(l,i.toString());});let k=P(N),m=await r(y.toString(),{body:k,method:s,headers:u});return d&&d==="*/*"?e?m.body:m.blob():m.json()}}function P(o){return o==null||globalThis.Blob&&o instanceof globalThis.Blob?o:JSON.stringify(o)}function B(o){let r=/^https?:\/\//i,t="https://";return r.test(o)?o.replace(/^http:\/\//i,t):`${t}${o}`}function g(o){return o.metrics.reduce((r,t)=>{let e=t.name.split(".");return e.length!=2&&(process.env.NODE_ENV!=="production"?a$1(!1,"assumed we were getting a `${key}.${type}`"):a$1(!1)),e[0]in r||(r[e[0]]={}),r[e[0]][e[1]]=t.value,r},{})}function h(o){return Object.entries(o).flatMap(([r,t])=>Array.isArray(t)?t.map(e=>({type:e,name:`${r}.${e}`,field:r})):[{type:t,name:`${r}.${t}`,field:r}])}function O(o){return o?Object.entries(o).flatMap(([r,t])=>t==="exact"?[{type:t,field:r}]:t.exactWithLimit?[{type:"exact",field:r,maxGroupCount:t.exactWithLimit}]:[]):[]}function c(o){if("$and"in o)return {type:"and",value:o.$and.map(c)};if("$or"in o)return {type:"or",value:o.$or.map(c)};if("$not"in o)return {type:"not",value:c(o.$not)};let r=Object.entries(o);if(r.length===1){let[t,e]=r[0];if(e==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!1)),typeof e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}}return {type:"and",value:Object.entries(o).map(([t,e])=>{if(e==null&&(process.env.NODE_ENV!=="production"?a$1(!1,"Defined key values are only allowed when they are not undefined."):a$1(!1)),typeof e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"WhereClause Filter with multiple properties isn't allowed"):a$1(!1));let n=Object.keys(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a$1(!1):a$1(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}})}}async function x(o,r,t){let e={aggregation:h(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=O(t.groupBy)),t.where&&(e.where=c(t.where));let n=await aggregateObjectsV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(p=>({group:p.group,values:g(p)})):(n.data.length!==1&&(process.env.NODE_ENV!=="production"?a$1(!1,"no group by clause should mean only one data result"):a$1(!1)),g(n.data[0]))}function T(o){let r=new Map;return (t,e)=>{let n=t.objects[e],s=r.get(n);return s==null&&(s=o(t,e),r.set(n,s)),s}}var R=T(V);function V(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function j(o,r,t){let e=R(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function w(o,r,t,e={type:"base",objectType:r}){let n={objectSet:e,select:t?.select??[]};t?.nextPageToken&&(n.pageToken=t.nextPageToken);let s=await loadObjectSetV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return j(o,r,s.data),s}var S={};a(S,{aggregateOrThrow:()=>x,fetchPageOrThrow:()=>w});
6
-
7
- export { c as a, f as b, x as c, w as d, S as e };
8
- //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-BYTHMUUS.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/createCachedOntologyTransform.ts","../../src/client/object/convertWireToOsdkObjects.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"yCAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,I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C,EAIf,cAAO,eAAeA,EAAO,SAAU,CACrC,MAAOnB,EACP,WAAY,GACZ,aAAc,GACd,SAAU,EACZ,CAAC,EACMmB,CACT,CACO,SAASC,EAAyBC,EAAQC,EAASC,EAAM,CAC9D,IAAMJ,EAAQH,EAAaK,EAAO,SAAUC,CAAO,EACnD,QAAWE,KAAOD,EAChB,OAAO,eAAeC,EAAKL,CAAK,EAgClC,OAAOI,CACT,CFjDA,eAAsBE,EAAiBJ,EAAQd,EAAYmB,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAApB,CACF,EAAG,CACD,IAAM3B,EAAO,CACX,UAAA+C,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACR9C,EAAK,UAAY8C,EAAK,eAExB,IAAME,EAAI,MAAMlB,EAAgBhD,EAAqB2D,EAAO,MAAOA,EAAO,KAAK,EAAGA,EAAO,SAAS,SAAS,gBAAiBzC,CAAI,EAChI,OAAAwC,EAAyBC,EAAQd,EAAYqB,EAAE,IAAI,EAI5CA,CACT,CGtCA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAxB,EAAA,qBAAAoB","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 createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 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\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects\";\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.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, objectType, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\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 * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\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 { createCachedOntologyTransform } from \"../createCachedOntologyTransform\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\nexport function convertWireToOsdkObjects(client, apiName, objs) {\n const proto = getPrototype(client.ontology, apiName);\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n\n // Saving this code in case we want to come back to temporal. For now its not worth the\n // risk and we can stick to string until we know what we want.\n // ====================================================================================================\n // FIXME\n // Im not going for performance for now, just something usable by beta users\n // Also not married to the $raw\n // obj[\"$raw\"] = {};\n\n // for (\n // const [key, def] of Object.entries(\n // client.ontology.objects[apiName].properties,\n // )\n // ) {\n // if (!(key in obj)) continue;\n // obj[\"$raw\"][key] = obj[key];\n\n // if (def.type === \"timestamp\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.Instant.from(value);\n // }\n // } else if (def.type === \"datetime\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.PlainDateTime.from(value);\n // }\n // }\n // }\n }\n\n return objs;\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\";"]}
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk4D6JZ4TL_js = require('./chunk-4D6JZ4TL.js');
4
- var requests = require('@osdk/gateway/requests');
5
- var a = require('tiny-invariant');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var a__default = /*#__PURE__*/_interopDefault(a);
10
-
11
- function f(o,r,t="/api",e){return async function(s,p,N,A,E,$,d){let y=new URL(`${t}${p}`,B(o));for(let[l,i]of Object.entries(A||{}))if(i!=null)if(Array.isArray(i))for(let D of i)y.searchParams.append(l,D);else y.searchParams.append(l,i);let u=new Headers;u.set("Content-Type",$??"application/json"),u.set("Accept",d??"application/json"),Object.entries(E||{}).forEach(([l,i])=>{i!=null&&u.append(l,i.toString());});let k=P(N),m=await r(y.toString(),{body:k,method:s,headers:u});return d&&d==="*/*"?e?m.body:m.blob():m.json()}}function P(o){return o==null||globalThis.Blob&&o instanceof globalThis.Blob?o:JSON.stringify(o)}function B(o){let r=/^https?:\/\//i,t="https://";return r.test(o)?o.replace(/^http:\/\//i,t):`${t}${o}`}function g(o){return o.metrics.reduce((r,t)=>{let e=t.name.split(".");return e.length!=2&&(process.env.NODE_ENV!=="production"?a__default.default(!1,"assumed we were getting a `${key}.${type}`"):a__default.default(!1)),e[0]in r||(r[e[0]]={}),r[e[0]][e[1]]=t.value,r},{})}function h(o){return Object.entries(o).flatMap(([r,t])=>Array.isArray(t)?t.map(e=>({type:e,name:`${r}.${e}`,field:r})):[{type:t,name:`${r}.${t}`,field:r}])}function O(o){return o?Object.entries(o).flatMap(([r,t])=>t==="exact"?[{type:t,field:r}]:t.exactWithLimit?[{type:"exact",field:r,maxGroupCount:t.exactWithLimit}]:[]):[]}function c(o){if("$and"in o)return {type:"and",value:o.$and.map(c)};if("$or"in o)return {type:"or",value:o.$or.map(c)};if("$not"in o)return {type:"not",value:c(o.$not)};let r=Object.entries(o);if(r.length===1){let[t,e]=r[0];if(e==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 e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).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(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}}return {type:"and",value:Object.entries(o).map(([t,e])=>{if(e==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 e=="string"||typeof e=="number")return {type:"eq",field:t,value:e};Object.keys(e).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(e)[0];return e[n]==null&&(process.env.NODE_ENV!=="production"?a__default.default(!1):a__default.default(!1)),n==="ne"?{type:"not",value:{type:"eq",field:t,value:e[n]}}:{type:n,field:t,value:e[n]}})}}async function x(o,r,t){let e={aggregation:h(t.select),groupBy:[],where:void 0};t.groupBy&&(e.groupBy=O(t.groupBy)),t.where&&(e.where=c(t.where));let n=await requests.aggregateObjectsV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,r,e);return t.groupBy?n.data.map(p=>({group:p.group,values:g(p)})):(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]))}function T(o){let r=new Map;return (t,e)=>{let n=t.objects[e],s=r.get(n);return s==null&&(s=o(t,e),r.set(n,s)),s}}var R=T(V);function V(o,r){o.objects[r];let e={};return Object.defineProperty(e,"__name",{value:r,enumerable:!1,configurable:!1,writable:!1}),e}function j(o,r,t){let e=R(o.ontology,r);for(let n of t)Object.setPrototypeOf(n,e);return t}async function w(o,r,t,e={type:"base",objectType:r}){let n={objectSet:e,select:t?.select??[]};t?.nextPageToken&&(n.pageToken=t.nextPageToken);let s=await requests.loadObjectSetV2(f(o.stack,o.fetch),o.ontology.metadata.ontologyApiName,n);return j(o,r,s.data),s}var S={};chunk4D6JZ4TL_js.a(S,{aggregateOrThrow:()=>x,fetchPageOrThrow:()=>w});
12
-
13
- exports.a = c;
14
- exports.b = f;
15
- exports.c = x;
16
- exports.d = w;
17
- exports.e = S;
18
- //# sourceMappingURL=out.js.map
19
- //# sourceMappingURL=chunk-EVOZ7UGO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/client/createOpenApiRequest.ts","../../src/client/object/aggregateOrThrow.ts","../../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/object/fetchPageOrThrow.ts","../../src/client/createCachedOntologyTransform.ts","../../src/client/object/convertWireToOsdkObjects.ts","../../src/client/object/index.ts"],"names":["createOpenApiRequest","basePath","fetchFn","contextPath","asReadableStream","method","endpointPath","data","queryArguments","headers","requestMediaType","responseMediaType","url","withHttps","key","value","item","headersInit","body","getBody","response","protocolRegex","httpsProtocol","aggregateObjectsV2","invariant","legacyToModernSingleAggregationResult","entry","accumulator","curValue","parts","modernToLegacyAggregationClause","select","k","v","v2","modernToLegacyGroupByClause","groupByClause","field","type","modernToLegacyWhereClause","whereClause","filter","q","aggregateOrThrow","thinClient","objectType","req","result","loadObjectSetV2","createCachedOntologyTransform","creator","cache","ontology","objectDefinition","getPrototype","createPrototype","objDef","proto","convertWireToOsdkObjects","client","apiName","objs","obj","fetchPageOrThrow","args","objectSet","r","object_exports","__export"],"mappings":"wCAgBO,SAASA,EAAqBC,EAAUC,EAASC,EAAc,OAAQC,EAAkB,CAC9F,OAAO,eAA8BC,EAAQC,EAAcC,EAAMC,EAAgBC,EAASC,EAAkBC,EAAmB,CAC7H,IAAMC,EAAM,IAAI,IAAI,GAAGT,CAAW,GAAGG,CAAY,GAAIO,EAAUZ,CAAQ,CAAC,EACxE,OAAW,CAACa,EAAKC,CAAK,IAAK,OAAO,QAAQP,GAAkB,CAAC,CAAC,EAC5D,GAAIO,GAAS,KAGb,GAAI,MAAM,QAAQA,CAAK,EACrB,QAAWC,KAAQD,EACjBH,EAAI,aAAa,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACxBA,EAAY,IAAI,eAAgBP,GAAoB,kBAAkB,EACtEO,EAAY,IAAI,SAAUN,GAAqB,kBAAkB,EACjE,OAAO,QAAQF,GAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAACK,EAAKC,CAAK,IAAM,CAClDA,GAAS,MACXE,EAAY,OAAOH,EAAKC,EAAM,SAAS,CAAC,CAE5C,CAAC,EACD,IAAMG,EAAOC,EAAQZ,CAAI,EACnBa,EAAW,MAAMlB,EAAQU,EAAI,SAAS,EAAG,CAC7C,KAAAM,EACA,OAAQb,EACR,QAASY,CACX,CAAC,EACD,OAAIN,GAAqBA,IAAsB,MACzCP,EACKgB,EAAS,KAEXA,EAAS,KAAK,EAEhBA,EAAS,KAAK,CACvB,CACF,CACA,SAASD,EAAQD,EAAM,CAIrB,OAHIA,GAAQ,MAGR,WAAW,MAAQA,aAAg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EAA8BC,EAAS,CAGrD,IAAMC,EAAQ,IAAI,IAClB,MAAO,CAACC,EAAUd,IAAS,CACzB,IAAMe,EAAmBD,EAAS,QAAQd,CAAI,EAC1CS,EAASI,EAAM,IAAIE,CAAgB,EACvC,OAAIN,GAAU,OACZA,EAASG,EAAQE,EAAUd,CAAI,EAC/Ba,EAAM,IAAIE,EAAkBN,CAAM,GAE7BA,CACT,CACF,CCjBA,IAAMO,EAAeL,EAA8BM,CAAe,EAClE,SAASA,EAAgBH,EAAUd,EAAM,CACvC,IAAMkB,EAASJ,EAAS,QAAQd,CAAI,EAC9BmB,EAAQ,CAAC,EAIf,cAAO,eAAeA,EAAO,SAAU,CACrC,MAAOnB,EACP,WAAY,GACZ,aAAc,GACd,SAAU,EACZ,CAAC,EACMmB,CACT,CACO,SAASC,EAAyBC,EAAQC,EAASC,EAAM,CAC9D,IAAMJ,EAAQH,EAAaK,EAAO,SAAUC,CAAO,EACnD,QAAWE,KAAOD,EAChB,OAAO,eAAeC,EAAKL,CAAK,EAgClC,OAAOI,CACT,CFjDA,eAAsBE,EAAiBJ,EAAQd,EAAYmB,EAAMC,EAAY,CAC3E,KAAM,OACN,WAAApB,CACF,EAAG,CACD,IAAM3B,EAAO,CACX,UAAA+C,EAEA,OAAQD,GAAM,QAAU,CAAC,CAC3B,EAEIA,GAAM,gBACR9C,EAAK,UAAY8C,EAAK,eAExB,IAAME,EAAI,MAAMlB,EAAgBhD,EAAqB2D,EAAO,MAAOA,EAAO,KAAK,EAAGA,EAAO,SAAS,SAAS,gBAAiBzC,CAAI,EAChI,OAAAwC,EAAyBC,EAAQd,EAAYqB,EAAE,IAAI,EAI5CA,CACT,CGtCA,IAAAC,EAAA,GAAAC,EAAAD,EAAA,sBAAAxB,EAAA,qBAAAoB","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 createOpenApiRequest(basePath, fetchFn, contextPath = \"/api\", asReadableStream) {\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 (value == null) {\n continue;\n }\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 headersInit.set(\"Content-Type\", requestMediaType ?? \"application/json\");\n headersInit.set(\"Accept\", responseMediaType ?? \"application/json\");\n Object.entries(headers || {}).forEach(([key, value]) => {\n if (value != null) {\n headersInit.append(key, value.toString());\n }\n });\n const body = getBody(data);\n const response = await fetchFn(url.toString(), {\n body,\n method: method,\n headers: headersInit\n });\n if (responseMediaType && responseMediaType === \"*/*\") {\n if (asReadableStream) {\n return response.body;\n }\n return response.blob();\n }\n return response.json();\n };\n}\nfunction getBody(body) {\n if (body == null) {\n return body;\n }\n if (globalThis.Blob && body instanceof globalThis.Blob) {\n return body;\n }\n return JSON.stringify(body);\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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport invariant from \"tiny-invariant\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions\";\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 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\nimport { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"../createOpenApiRequest\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects\";\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.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, objectType, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\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 * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\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 { createCachedOntologyTransform } from \"../createCachedOntologyTransform\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\nexport function convertWireToOsdkObjects(client, apiName, objs) {\n const proto = getPrototype(client.ontology, apiName);\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n\n // Saving this code in case we want to come back to temporal. For now its not worth the\n // risk and we can stick to string until we know what we want.\n // ====================================================================================================\n // FIXME\n // Im not going for performance for now, just something usable by beta users\n // Also not married to the $raw\n // obj[\"$raw\"] = {};\n\n // for (\n // const [key, def] of Object.entries(\n // client.ontology.objects[apiName].properties,\n // )\n // ) {\n // if (!(key in obj)) continue;\n // obj[\"$raw\"][key] = obj[key];\n\n // if (def.type === \"timestamp\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.Instant.from(value);\n // }\n // } else if (def.type === \"datetime\") {\n // const value = obj[key] as string | undefined;\n // if (value !== undefined) {\n // obj[key] = Temporal.PlainDateTime.from(value);\n // }\n // }\n // }\n }\n\n return objs;\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\";"]}
@@ -1,5 +0,0 @@
1
- var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});};
2
-
3
- export { e as a };
4
- //# sourceMappingURL=out.js.map
5
- //# sourceMappingURL=chunk-XIJ2ZQRX.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkEVOZ7UGO_js = require('../chunk-EVOZ7UGO.js');
4
- require('../chunk-4D6JZ4TL.js');
5
-
6
-
7
-
8
- Object.defineProperty(exports, 'aggregateOrThrow', {
9
- enumerable: true,
10
- get: function () { return chunkEVOZ7UGO_js.c; }
11
- });
12
- Object.defineProperty(exports, 'fetchPageOrThrow', {
13
- enumerable: true,
14
- get: function () { return chunkEVOZ7UGO_js.d; }
15
- });
16
- //# sourceMappingURL=out.js.map
17
- //# sourceMappingURL=objects.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- export { c as aggregateOrThrow, d as fetchPageOrThrow } from '../chunk-BYTHMUUS.mjs';
2
- import '../chunk-XIJ2ZQRX.mjs';
3
- //# sourceMappingURL=out.js.map
4
- //# sourceMappingURL=objects.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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): {};
@@ -1,5 +0,0 @@
1
- import type { OsdkObject } from "../ontology";
2
- export interface PageResult<T extends OsdkObject<any>> {
3
- data: T[];
4
- nextPageToken: string | undefined;
5
- }
@@ -1,7 +0,0 @@
1
- import type { ObjectTypesFrom, OntologyDefinition } from "../ontology";
2
- /**
3
- * Creates a getter function that caches based on the ontology.objects[type] value
4
- *
5
- * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching
6
- */
7
- export declare function createCachedOntologyTransform<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, T>(creator: (ontology: O, type: K) => T): (ontology: O, type: K) => T;
@@ -1,3 +0,0 @@
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: () => Promise<string> | string, fetchFn?: typeof globalThis.fetch): Client<O>;
@@ -1,8 +0,0 @@
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";