@osdk/api 0.0.16 → 0.0.17

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @osdk/api
2
2
 
3
+ ## 0.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - ed78694: Fixes imports from older module resolution
8
+ - Updated dependencies [ed78694]
9
+ - @osdk/gateway@0.0.10
10
+
3
11
  ## 0.0.16
4
12
 
5
13
  ### Patch Changes
package/build/js/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  var chunkSHYKLQMU_js = require('./chunk-SHYKLQMU.js');
4
4
 
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"}
5
+ function j(t,r,o="/api",c){return async function(e,a,O,F,T,b,l){let m=new URL(`${o}${a}`,E(t));for(let[u,i]of Object.entries(F||{}))if(i!=null)if(Array.isArray(i))for(let N of i)m.searchParams.append(u,N);else m.searchParams.append(u,i);let p=new Headers;p.set("Content-Type",b??"application/json"),p.set("Accept",l??"application/json"),Object.entries(T||{}).forEach(([u,i])=>{i!=null&&p.append(u,i.toString());});let k=B(O),w=await r(m.toString(),{body:k,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 E(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(a){throw x(a,"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 J(t,r,o,c=fetch){if(r.length===0)throw new Error("stack cannot be empty");let n=chunkSHYKLQMU_js.a(chunkSHYKLQMU_js.c(d(c)),async e=>{let a=await o();return e.set("Authorization",`Bearer ${a}`),e.set("Fetch-User-Agent",t.metadata.userAgent),e});return {ontology:t,stack:r,fetch:n,fetchJson:A(n)}}function R(t){return t.type==="ok"}
6
6
 
7
7
  exports.createOpenApiRequest = j;
8
- exports.createThinClient = R;
9
- exports.isOk = $;
8
+ exports.createThinClient = J;
9
+ exports.isOk = R;
10
10
  //# sourceMappingURL=out.js.map
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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,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["/*\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
+ {"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":"sDAgBO,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,aAAgB,WAAW,KACzCA,EAEF,KAAK,U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QU,EAAK,CACzB,GAAGiB,EACH,KAAMI,EAAcJ,EAAY,IAAI,CAEtC,CAAC,GAAG,KAAK,CACX,CACF,CCtBO,SAASO,EAAiBC,EAAUC,EAAOC,EAAerC,EAAU,MAAO,CAChF,GAAIoC,EAAM,SAAW,EACnB,MAAM,IAAI,MAAM,uBAAuB,EAEzC,IAAME,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,CCrBO,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 if (stack.length === 0) {\n throw new Error(\"stack cannot be empty\");\n }\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,7 @@
1
1
  import { a, c, b } from './chunk-BZ6L26S2.mjs';
2
2
 
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"}
3
+ function j(t,r,o="/api",c){return async function(e,a,O,F,T,b,l){let m=new URL(`${o}${a}`,E(t));for(let[u,i]of Object.entries(F||{}))if(i!=null)if(Array.isArray(i))for(let N of i)m.searchParams.append(u,N);else m.searchParams.append(u,i);let p=new Headers;p.set("Content-Type",b??"application/json"),p.set("Accept",l??"application/json"),Object.entries(T||{}).forEach(([u,i])=>{i!=null&&p.append(u,i.toString());});let k=B(O),w=await r(m.toString(),{body:k,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 E(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(a){throw x(a,"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 J(t,r,o,c$1=fetch){if(r.length===0)throw new Error("stack cannot be empty");let n=a(c(d(c$1)),async e=>{let a=await o();return e.set("Authorization",`Bearer ${a}`),e.set("Fetch-User-Agent",t.metadata.userAgent),e});return {ontology:t,stack:r,fetch:n,fetchJson:A(n)}}function R(t){return t.type==="ok"}
4
4
 
5
- export { j as createOpenApiRequest, R as createThinClient, $ as isOk };
5
+ export { j as createOpenApiRequest, J as createThinClient, R as isOk };
6
6
  //# sourceMappingURL=out.js.map
7
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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,OAAOE,EAAKE,CAAI,OAGnCJ,EAAI,aAAa,OAAOE,EAAKC,CAAK,EAGtC,IAAME,EAAc,IAAI,QACxBA,EAAY,IAAI,eAAgBP,G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AS,MAAM,IAAIA,EAAS,UAAU,GAAIF,GAAM,UAAWA,GAAM,UAAWE,EAAS,OAAQF,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
+ {"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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F,GAAIoC,EAAM,SAAW,EACnB,MAAM,IAAI,MAAM,uBAAuB,EAEzC,IAAME,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,CCrBO,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 if (stack.length === 0) {\n throw new Error(\"stack cannot be empty\");\n }\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}"]}
@@ -2,7 +2,6 @@ export { createOpenApiRequest } from "./client/createOpenApiRequest";
2
2
  export { createThinClient } from "./client/createThinClient";
3
3
  export { isOk, type ResultOrError } from "./client/ResultOrError";
4
4
  export type { ThinClient } from "./client/ThinClient";
5
- export type { OsdkObject, OsdkObjectFrom } from "./ontology";
6
5
  export type { LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./ontology/Definition";
7
6
  export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ValidActionParameterTypes, } from "./ontology/ActionDefinition";
8
7
  export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./ontology/QueryDefinition";
@@ -1,4 +1,4 @@
1
- import type GeoJSON from "geojson";
1
+ import type * as GeoJSON from "geojson";
2
2
  import type { ActionDefinition } from "./ActionDefinition";
3
3
  import type { OntologyMetadata } from "./OntologyMetadata";
4
4
  import type { QueryDefinition } from "./QueryDefinition";
@@ -1,6 +1,4 @@
1
1
  export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ObjectActionDataType, ObjectSetActionDataType, ValidActionParameterTypes, ValidBaseActionParameterTypes, } from "./ActionDefinition";
2
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
- export type { OsdkObject } from "./OsdkObject";
5
- export type { OsdkObjectFrom } from "./OsdkObjectFrom";
6
4
  export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./QueryDefinition";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/api",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
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.9"
23
+ "@osdk/gateway": "0.0.10"
24
24
  },
25
25
  "devDependencies": {
26
26
  "ts-expect": "^1.3.0",
@@ -34,8 +34,11 @@
34
34
  "build/types",
35
35
  "build/js",
36
36
  "CHANGELOG.md",
37
- "package.json"
37
+ "package.json",
38
+ "*.d.ts"
38
39
  ],
40
+ "main": "./build/js/index.js",
41
+ "module": "./build/js/index.mjs",
39
42
  "types": "./build/types/index.d.ts",
40
43
  "scripts": {
41
44
  "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",