@osdk/api 0.0.17 → 1.0.0

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/js/index.cjs +4 -0
  3. package/build/js/index.mjs +0 -4
  4. package/build/js/index.mjs.map +1 -1
  5. package/build/types/index.d.ts +5 -6
  6. package/build/types/ontology/InterfaceDefinition.d.ts +12 -0
  7. package/build/types/ontology/ObjectTypeDefinition.d.ts +29 -0
  8. package/build/types/ontology/OntologyDefinition.d.ts +20 -0
  9. package/build/types/ontology/QueryDefinition.d.ts +22 -32
  10. package/build/types/ontology/WirePropertyTypes.d.ts +19 -0
  11. package/build/types/ontology/index.d.ts +5 -2
  12. package/package.json +5 -4
  13. package/build/js/chunk-BZ6L26S2.mjs +0 -7
  14. package/build/js/chunk-BZ6L26S2.mjs.map +0 -1
  15. package/build/js/chunk-SHYKLQMU.js +0 -15
  16. package/build/js/chunk-SHYKLQMU.js.map +0 -1
  17. package/build/js/index.js +0 -11
  18. package/build/js/index.js.map +0 -1
  19. package/build/js/public/utils.js +0 -16
  20. package/build/js/public/utils.mjs +0 -3
  21. package/build/js/public/utils.mjs.map +0 -1
  22. package/build/types/client/PalantirApiError.d.ts +0 -9
  23. package/build/types/client/ResultOrError.d.ts +0 -11
  24. package/build/types/client/ThinClient.d.ts +0 -13
  25. package/build/types/client/UnknownError.d.ts +0 -5
  26. package/build/types/client/createOpenApiRequest.d.ts +0 -2
  27. package/build/types/client/createThinClient.d.ts +0 -6
  28. package/build/types/ontology/Definition.d.ts +0 -72
  29. package/build/types/ontology/OsdkObjectFrom.d.ts +0 -14
  30. package/build/types/public/utils.d.ts +0 -2
  31. package/build/types/util/FetchAsJson.d.ts +0 -15
  32. package/build/types/util/createFetchHeaderMutator.d.ts +0 -1
  33. package/build/types/util/createFetchOrThrow.d.ts +0 -9
  34. package/build/types/util/createRetryingFetch.d.ts +0 -2
  35. package/build/types/util/index.d.ts +0 -6
  36. package/build/types/util/stringifyBody.d.ts +0 -1
  37. /package/build/js/{public/utils.js.map → index.cjs.map} +0 -0
  38. /package/build/types/{client/createOpenApiRequest.test.d.ts → junk.test.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @osdk/api
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - bfd4d9a: Stable 1.0 version
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [bfd4d9a]
12
+ - @osdk/gateway@1.0.0
13
+ - @osdk/shared.net@1.0.0
14
+
3
15
  ## 0.0.17
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=out.js.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,3 @@
1
- import { a, c, b } from './chunk-BZ6L26S2.mjs';
2
1
 
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
-
5
- export { j as createOpenApiRequest, J as createThinClient, R as isOk };
6
2
  //# sourceMappingURL=out.js.map
7
3
  //# 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":"uDAgBO,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,CAAC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5B,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
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,7 +1,6 @@
1
- export { createOpenApiRequest } from "./client/createOpenApiRequest";
2
- export { createThinClient } from "./client/createThinClient";
3
- export { isOk, type ResultOrError } from "./client/ResultOrError";
4
- export type { ThinClient } from "./client/ThinClient";
5
- export type { LinkDefinitionFrom, LinkKeysFrom, LinkTargetTypeFrom, ObjectDefinition, ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyDefinition, PropertyDefinitionFrom, PropertyDefinitionsFrom, PropertyKeysFrom, ValidPropertyTypes, } from "./ontology/Definition";
6
1
  export type { ActionDefinition, ActionModifiedEntity, ActionParameterDefinition, ValidActionParameterTypes, } from "./ontology/ActionDefinition";
7
- export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./ontology/QueryDefinition";
2
+ export type { InterfaceDefinition, InterfaceDefinitionFrom, InterfaceKeysFrom, InterfacePropertyDefinitionFrom, InterfacePropertyDefinitionsFrom, InterfacePropertyKeysFrom, } from "./ontology/InterfaceDefinition";
3
+ export type { ObjectTypeDefinition, ObjectTypeDefinitionFrom, ObjectTypeKeysFrom, ObjectTypeLinkDefinition, ObjectTypeLinkDefinitionFrom, ObjectTypeLinkKeysFrom, ObjectTypeLinkTargetTypeFrom, ObjectTypePropertyDefinition, ObjectTypePropertyDefinitionFrom, ObjectTypePropertyDefinitionsFrom, ObjectTypePropertyKeysFrom, } from "./ontology/ObjectTypeDefinition";
4
+ export type { OntologyDefinition } from "./ontology/OntologyDefinition";
5
+ export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, PrimitiveDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, WireQueryDataTypes, } from "./ontology/QueryDefinition";
6
+ export type { WirePropertyTypes } from "./ontology/WirePropertyTypes";
@@ -0,0 +1,12 @@
1
+ import type { ObjectTypePropertyDefinition } from "./ObjectTypeDefinition";
2
+ import type { OntologyDefinition } from "./OntologyDefinition";
3
+ export type InterfaceDefinitionFrom<O extends OntologyDefinition<any>, K extends InterfaceKeysFrom<O>> = O["interfaces"] extends {} ? O["interfaces"][K] : never;
4
+ export type InterfaceKeysFrom<O extends OntologyDefinition<string>> = keyof O["interfaces"];
5
+ export type InterfacePropertyKeysFrom<O extends OntologyDefinition<any>, K extends InterfaceKeysFrom<O>> = keyof InterfaceDefinitionFrom<O, K>["properties"];
6
+ export type InterfacePropertyDefinitionsFrom<O extends OntologyDefinition<any>, K extends InterfaceKeysFrom<O>> = InterfaceDefinitionFrom<O, K>["properties"];
7
+ export type InterfacePropertyDefinitionFrom<O extends OntologyDefinition<any>, K extends InterfaceKeysFrom<O>, P extends InterfacePropertyKeysFrom<O, K>> = InterfacePropertyDefinitionsFrom<O, K>[P];
8
+ export interface InterfaceDefinition<K extends string, _L extends string> {
9
+ apiName: K;
10
+ description?: string;
11
+ properties: Record<string, ObjectTypePropertyDefinition>;
12
+ }
@@ -0,0 +1,29 @@
1
+ import type { OntologyDefinition } from "./OntologyDefinition";
2
+ import type { WirePropertyTypes } from "./WirePropertyTypes";
3
+ export type ObjectTypeDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>> = O["objects"][K];
4
+ export type ObjectTypeKeysFrom<O extends OntologyDefinition<string>> = keyof O["objects"];
5
+ export type ObjectTypePropertyKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>> = keyof ObjectTypeDefinitionFrom<O, K>["properties"];
6
+ export type ObjectTypePropertyDefinitionsFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>> = ObjectTypeDefinitionFrom<O, K>["properties"];
7
+ export type ObjectTypePropertyDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>, P extends ObjectTypePropertyKeysFrom<O, K>> = ObjectTypePropertyDefinitionsFrom<O, K>[P];
8
+ export interface ObjectTypeDefinition<K extends string, L extends string> {
9
+ apiName: K;
10
+ description?: string;
11
+ primaryKeyType: keyof WirePropertyTypes;
12
+ properties: Record<string, ObjectTypePropertyDefinition>;
13
+ links: Record<string, ObjectTypeLinkDefinition<L>>;
14
+ }
15
+ export type ObjectTypeLinkKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>> = keyof ObjectTypeDefinitionFrom<O, K>["links"];
16
+ export interface ObjectTypeLinkDefinition<K extends string> {
17
+ targetType: K;
18
+ multiplicity: boolean;
19
+ }
20
+ export type ObjectTypeLinkDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>, L extends ObjectTypeLinkKeysFrom<O, K>> = ObjectTypeDefinitionFrom<O, K>["links"][L];
21
+ export type ObjectTypeLinkTargetTypeFrom<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>, L extends ObjectTypeLinkKeysFrom<O, K>> = ObjectTypeLinkDefinitionFrom<O, K, L>["targetType"];
22
+ export interface ObjectTypePropertyDefinition {
23
+ readonly?: boolean;
24
+ displayName?: string;
25
+ description?: string;
26
+ type: keyof WirePropertyTypes;
27
+ multiplicity?: boolean;
28
+ nullable?: boolean;
29
+ }
@@ -0,0 +1,20 @@
1
+ import type { ActionDefinition } from "./ActionDefinition";
2
+ import type { InterfaceDefinition } from "./InterfaceDefinition";
3
+ import type { ObjectTypeDefinition } from "./ObjectTypeDefinition";
4
+ import type { OntologyMetadata } from "./OntologyMetadata";
5
+ import type { QueryDefinition } from "./QueryDefinition";
6
+ export interface OntologyDefinition<K extends string, A extends string = any, Q extends string = any, I extends string = any> {
7
+ metadata: OntologyMetadata;
8
+ objects: {
9
+ [KK in K]: ObjectTypeDefinition<KK, K>;
10
+ };
11
+ actions: {
12
+ [AA in A]: ActionDefinition<AA, K>;
13
+ };
14
+ queries: {
15
+ [QQ in Q]: QueryDefinition<QQ, K>;
16
+ };
17
+ interfaces?: {
18
+ [II in I]: InterfaceDefinition<II, K>;
19
+ };
20
+ }
@@ -2,22 +2,20 @@ export interface QueryDefinition<Q extends string, K extends string> {
2
2
  apiName: Q;
3
3
  description?: string;
4
4
  displayName?: string;
5
- rid: string;
6
5
  version: string;
7
6
  parameters: Record<string, QueryParameterDefinition<K>>;
8
7
  output: QueryDataTypeDefinition<K>;
9
8
  }
10
- export interface QueryParameterDefinition<K extends string> {
9
+ export type QueryParameterDefinition<K extends string> = {
11
10
  description?: string;
12
- dataType: QueryDataTypeDefinition<K>;
13
- }
14
- export interface QueryDataTypeDefinition<K extends string> {
15
- type: QueryDataType<K>;
11
+ } & QueryDataTypeDefinition<K>;
12
+ export type QueryDataTypeDefinition<K extends string> = PrimitiveDataType | ObjectQueryDataType<K> | ObjectSetQueryDataType<K> | SetQueryDataType<K> | UnionQueryDataType<K> | StructQueryDataType<K> | TwoDimensionalAggregationDataType | ThreeDimensionalAggregationDataType;
13
+ export type BaseQueryDataTypeDefinition<T extends string> = {
16
14
  multiplicity?: boolean;
17
15
  nullable?: boolean;
18
- }
19
- export type QueryDataType<K extends string> = keyof ValidBaseQueryDataTypes | ObjectQueryDataType<K> | ObjectSetQueryDataType<K> | SetQueryDataType<K> | UnionQueryDataType<K> | StructQueryDataType<K> | TwoDimensionalAggregationDataType | ThreeDimensionalAggregationDataType;
20
- export interface ValidBaseQueryDataTypes {
16
+ type: T;
17
+ };
18
+ export interface WireQueryDataTypes {
21
19
  double: number;
22
20
  float: number;
23
21
  integer: number;
@@ -28,45 +26,37 @@ export interface ValidBaseQueryDataTypes {
28
26
  timestamp: Date;
29
27
  attachment: any;
30
28
  }
31
- export interface ObjectQueryDataType<K extends string> {
32
- type: "object";
29
+ export type PrimitiveDataType<Q extends keyof WireQueryDataTypes = keyof WireQueryDataTypes> = BaseQueryDataTypeDefinition<Q>;
30
+ export interface ObjectQueryDataType<K extends string> extends BaseQueryDataTypeDefinition<"object"> {
33
31
  object: K;
34
32
  }
35
- export interface ObjectSetQueryDataType<K extends string> {
36
- type: "objectSet";
33
+ export interface ObjectSetQueryDataType<K extends string> extends BaseQueryDataTypeDefinition<"objectSet"> {
37
34
  objectSet: K;
38
35
  }
39
- export interface SetQueryDataType<K extends string> {
40
- type: "set";
36
+ export interface SetQueryDataType<K extends string> extends BaseQueryDataTypeDefinition<"set"> {
41
37
  set: QueryDataTypeDefinition<K>;
42
38
  }
43
- export interface UnionQueryDataType<K extends string> {
44
- type: "union";
39
+ export interface UnionQueryDataType<K extends string> extends BaseQueryDataTypeDefinition<"union"> {
45
40
  union: ReadonlyArray<QueryDataTypeDefinition<K>>;
46
41
  }
47
- export interface StructQueryDataType<K extends string> {
48
- type: "struct";
42
+ export interface StructQueryDataType<K extends string> extends BaseQueryDataTypeDefinition<"struct"> {
49
43
  struct: Record<string, QueryDataTypeDefinition<K>>;
50
44
  }
51
- export interface TwoDimensionalAggregationDataType {
52
- type: "twoDimensionalAggregation";
45
+ export interface TwoDimensionalAggregationDataType extends BaseQueryDataTypeDefinition<"twoDimensionalAggregation"> {
53
46
  twoDimensionalAggregation: TwoDimensionalQueryAggregationDefinition;
54
47
  }
55
- export interface ThreeDimensionalAggregationDataType {
56
- type: "threeDimensionalAggregation";
48
+ export interface ThreeDimensionalAggregationDataType extends BaseQueryDataTypeDefinition<"threeDimensionalAggregation"> {
57
49
  threeDimensionalAggregation: ThreeDimensionalQueryAggregationDefinition;
58
50
  }
59
- export type AggregationKeyDataType = SimpleAggregationKeyDataType | RangeAggregationKeyDataType;
60
- export interface SimpleAggregationKeyDataType {
51
+ export type AggregationKeyDataType<V = any> = SimpleAggregationKeyDataType<V> | RangeAggregationKeyDataType<V>;
52
+ export interface SimpleAggregationKeyDataType<V = any> {
61
53
  keyType: "boolean" | "string";
54
+ valueType: V;
62
55
  }
63
- export interface RangeAggregationKeyDataType {
56
+ export interface RangeAggregationKeyDataType<V = any> {
64
57
  keyType: "range";
65
58
  keySubtype: "date" | "double" | "integer" | "timestamp";
59
+ valueType: V;
66
60
  }
67
- export type TwoDimensionalQueryAggregationDefinition = AggregationKeyDataType & {
68
- valueType: "date" | "double" | "timestamp";
69
- };
70
- export type ThreeDimensionalQueryAggregationDefinition = AggregationKeyDataType & {
71
- valueType: TwoDimensionalQueryAggregationDefinition;
72
- };
61
+ export type TwoDimensionalQueryAggregationDefinition = AggregationKeyDataType<"date" | "double" | "timestamp">;
62
+ export type ThreeDimensionalQueryAggregationDefinition = AggregationKeyDataType<TwoDimensionalQueryAggregationDefinition>;
@@ -0,0 +1,19 @@
1
+ import type * as GeoJSON from "geojson";
2
+ export interface WirePropertyTypes {
3
+ string: string;
4
+ datetime: string;
5
+ double: number;
6
+ boolean: boolean;
7
+ integer: number;
8
+ timestamp: string;
9
+ short: number;
10
+ long: number;
11
+ float: number;
12
+ decimal: number;
13
+ byte: number;
14
+ numericTimeseries: any;
15
+ stringTimeseries: any;
16
+ attachment: any;
17
+ geopoint: GeoJSON.Point;
18
+ geoshape: GeoJSON.Geometry;
19
+ }
@@ -1,4 +1,7 @@
1
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";
2
+ export type { InterfaceDefinition, InterfaceDefinitionFrom, InterfaceKeysFrom, InterfacePropertyDefinitionFrom, InterfacePropertyDefinitionsFrom, InterfacePropertyKeysFrom, } from "./InterfaceDefinition";
3
+ export type { ObjectTypeDefinition, ObjectTypeDefinitionFrom, ObjectTypeKeysFrom as ObjectTypeKeysFrom, ObjectTypeLinkDefinition, ObjectTypeLinkDefinitionFrom, ObjectTypeLinkKeysFrom, ObjectTypeLinkTargetTypeFrom, ObjectTypePropertyDefinition, ObjectTypePropertyDefinitionFrom, ObjectTypePropertyDefinitionsFrom, ObjectTypePropertyKeysFrom, } from "./ObjectTypeDefinition";
4
+ export type { OntologyDefinition } from "./OntologyDefinition";
3
5
  export type { OntologyMetadata } from "./OntologyMetadata";
4
- export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, ValidBaseQueryDataTypes, } from "./QueryDefinition";
6
+ export type { AggregationKeyDataType, ObjectQueryDataType, ObjectSetQueryDataType, QueryDataTypeDefinition, QueryDefinition, QueryParameterDefinition, RangeAggregationKeyDataType, SetQueryDataType, SimpleAggregationKeyDataType, StructQueryDataType, ThreeDimensionalAggregationDataType, ThreeDimensionalQueryAggregationDefinition, TwoDimensionalAggregationDataType, TwoDimensionalQueryAggregationDefinition, UnionQueryDataType, WireQueryDataTypes, } from "./QueryDefinition";
7
+ export type { WirePropertyTypes } from "./WirePropertyTypes";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/api",
3
- "version": "0.0.17",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -8,19 +8,20 @@
8
8
  ".": {
9
9
  "types": "./build/types/index.d.ts",
10
10
  "import": "./build/js/index.mjs",
11
- "require": "./build/js/index.js"
11
+ "require": "./build/js/index.cjs"
12
12
  },
13
13
  "./*": {
14
14
  "types": "./build/types/public/*.d.ts",
15
15
  "import": "./build/js/public/*.mjs",
16
- "require": "./build/js/public/*.js"
16
+ "require": "./build/js/public/*.cjs"
17
17
  }
18
18
  },
19
19
  "dependencies": {
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.10"
23
+ "@osdk/gateway": "1.0.0",
24
+ "@osdk/shared.net": "1.0.0"
24
25
  },
25
26
  "devDependencies": {
26
27
  "ts-expect": "^1.3.0",
@@ -1,7 +0,0 @@
1
- import i from 'fetch-retry';
2
-
3
- function R(t=fetch,e){return async function(r,s){return s?t(r,{...s,headers:await e(new Headers(s.headers))}):t(r,{headers:await e(new Headers)})}}var a=class extends Error{constructor(e,n,r,s,o,c){super(e),this.message=e,this.errorName=n,this.errorType=r,this.statusCode=s,this.errorInstanceId=o,this.parameters=c;}};var u=1e3,d=.5,h=3;function _(t){return i(t,{retryDelay(e){let n=u*2**e,r=n*d*(Math.random()*2-1);return n+r},retryOn(e,n,r){let s=r?.status??0;return !(s>=200&&s<300)&&f(n)&&e<h}})}function f(t){return !(t instanceof a&&t.statusCode!==E&&t.statusCode!==y)}var E=503,y=429;
4
-
5
- export { R as a, a as b, _ as c };
6
- //# sourceMappingURL=out.js.map
7
- //# sourceMappingURL=chunk-BZ6L26S2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/createFetchHeaderMutator.ts","../../src/util/createRetryingFetch.ts","../../src/client/PalantirApiError.ts"],"names":["createFetchHeaderMutator","fetchFn","mutator","url","requestInit","fetchRetry","PalantirApiError","message","errorName","errorType","statusCode","errorInstanceId","parameters","INITIAL_DELAY","JITTER_FACTOR","MAX_RETRIES","createRetryingFetch","fetch","attempt","delay","jitter","error","response","status","isRetryable","e","SERVICE_UNAVAILABLE","TOO_MANY_REQUESTS"],"mappings":"AAgBO,SAASA,EAAyBC,EAAU,MAAOC,EAAS,CACjE,OAAO,eAAkCC,EAAKC,EAAa,CACzD,OAAKA,EAKEH,EAAQE,EAAK,CAClB,GAAGC,EACH,QAAS,MAAMF,EAAQ,IAAI,QAAQE,EAAY,OAAO,CAAC,CACzD,CAAC,EAPQH,EAAQE,EAAK,CAClB,QAAS,MAAMD,EAAQ,IAAI,OAAS,CACtC,CAAC,CAML,CACF,CCZA,OAAOG,MAAgB,cCAhB,IAAMC,EAAN,cAA+B,KAAM,CAC1C,YAAYC,EAASC,EAAWC,EAAWC,EAAYC,EAAiBC,EAAY,CAClF,MAAML,CAAO,EACb,KAAK,QAAUA,EACf,KAAK,UAAYC,EACjB,KAAK,UAAYC,EACjB,KAAK,WAAaC,EAClB,KAAK,gBAAkBC,EACvB,KAAK,WAAaC,CACpB,CACF,EDRA,IAAMC,EAAgB,IAChBC,EAAgB,GAChBC,EAAc,EACb,SAASC,EAAoBC,EAAO,CACzC,OAAOZ,EAAWY,EAAO,CACvB,WAAWC,EAAS,CAClB,IAAMC,EAAQN,EAAgB,GAAKK,EAC7BE,EAASD,EAAQL,GAAiB,KAAK,OAAO,EAAI,EAAI,GAC5D,OAAOK,EAAQC,CACjB,EACA,QAAQF,EAASG,EAAOC,EAAU,CAChC,IAAMC,EAASD,GAAU,QAAU,EACnC,MAAO,EAAEC,GAAU,KAAOA,EAAS,MAAQC,EAAYH,CAAK,GAAKH,EAAUH,CAC7E,CACF,CAAC,CACH,CACA,SAASS,EAAYC,EAAG,CACtB,MAAI,EAAAA,aAAanB,GACXmB,EAAE,aAAeC,GAAuBD,EAAE,aAAeE,EAKjE,CAEA,IAAMD,EAAsB,IACtBC,EAAoB","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function createFetchHeaderMutator(fetchFn = fetch, mutator) {\n return async function headerMutatedFetch(url, requestInit) {\n if (!requestInit) {\n return fetchFn(url, {\n headers: await mutator(new Headers())\n });\n }\n return fetchFn(url, {\n ...requestInit,\n headers: await mutator(new Headers(requestInit.headers))\n });\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetchRetry from \"fetch-retry\";\nimport { PalantirApiError } from \"../client/PalantirApiError\";\nconst INITIAL_DELAY = 1_000;\nconst JITTER_FACTOR = 0.5;\nconst MAX_RETRIES = 3;\nexport function createRetryingFetch(fetch) {\n return fetchRetry(fetch, {\n retryDelay(attempt) {\n const delay = INITIAL_DELAY * 2 ** attempt;\n const jitter = delay * JITTER_FACTOR * (Math.random() * 2 - 1);\n return delay + jitter;\n },\n retryOn(attempt, error, response) {\n const status = response?.status ?? 0;\n return !(status >= 200 && status < 300) && isRetryable(error) && attempt < MAX_RETRIES;\n }\n });\n}\nfunction isRetryable(e) {\n if (e instanceof PalantirApiError) {\n if (e.statusCode !== SERVICE_UNAVAILABLE && e.statusCode !== TOO_MANY_REQUESTS) {\n return false;\n }\n }\n return true; // I think this logic is flawed?\n}\n\nconst SERVICE_UNAVAILABLE = 503;\nconst TOO_MANY_REQUESTS = 429;","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class PalantirApiError extends Error {\n constructor(message, errorName, errorType, statusCode, errorInstanceId, parameters) {\n super(message);\n this.message = message;\n this.errorName = errorName;\n this.errorType = errorType;\n this.statusCode = statusCode;\n this.errorInstanceId = errorInstanceId;\n this.parameters = parameters;\n }\n}"]}
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var i = require('fetch-retry');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var i__default = /*#__PURE__*/_interopDefault(i);
8
-
9
- function R(t=fetch,e){return async function(r,s){return s?t(r,{...s,headers:await e(new Headers(s.headers))}):t(r,{headers:await e(new Headers)})}}var a=class extends Error{constructor(e,n,r,s,o,c){super(e),this.message=e,this.errorName=n,this.errorType=r,this.statusCode=s,this.errorInstanceId=o,this.parameters=c;}};var u=1e3,d=.5,h=3;function _(t){return i__default.default(t,{retryDelay(e){let n=u*2**e,r=n*d*(Math.random()*2-1);return n+r},retryOn(e,n,r){let s=r?.status??0;return !(s>=200&&s<300)&&f(n)&&e<h}})}function f(t){return !(t instanceof a&&t.statusCode!==E&&t.statusCode!==y)}var E=503,y=429;
10
-
11
- exports.a = R;
12
- exports.b = a;
13
- exports.c = _;
14
- //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-SHYKLQMU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/createFetchHeaderMutator.ts","../../src/util/createRetryingFetch.ts","../../src/client/PalantirApiError.ts"],"names":["createFetchHeaderMutator","fetchFn","mutator","url","requestInit","fetchRetry","PalantirApiError","message","errorName","errorType","statusCode","errorInstanceId","parameters","INITIAL_DELAY","JITTER_FACTOR","MAX_RETRIES","createRetryingFetch","fetch","attempt","delay","jitter","error","response","status","isRetryable","e","SERVICE_UNAVAILABLE","TOO_MANY_REQUESTS"],"mappings":"AAgBO,SAASA,EAAyBC,EAAU,MAAOC,EAAS,CACjE,OAAO,eAAkCC,EAAKC,EAAa,CACzD,OAAKA,EAKEH,EAAQE,EAAK,CAClB,GAAGC,EACH,QAAS,MAAMF,EAAQ,IAAI,QAAQE,EAAY,OAAO,CAAC,CACzD,CAAC,EAPQH,EAAQE,EAAK,CAClB,QAAS,MAAMD,EAAQ,IAAI,OAAS,CACtC,CAAC,CAML,CACF,CCZA,OAAOG,MAAgB,cCAhB,IAAMC,EAAN,cAA+B,KAAM,CAC1C,YAAYC,EAASC,EAAWC,EAAWC,EAAYC,EAAiBC,EAAY,CAClF,MAAML,CAAO,EACb,KAAK,QAAUA,EACf,KAAK,UAAYC,EACjB,KAAK,UAAYC,EACjB,KAAK,WAAaC,EAClB,KAAK,gBAAkBC,EACvB,KAAK,WAAaC,CACpB,CACF,EDRA,IAAMC,EAAgB,IAChBC,EAAgB,GAChBC,EAAc,EACb,SAASC,EAAoBC,EAAO,CACzC,OAAOZ,EAAWY,EAAO,CACvB,WAAWC,EAAS,CAClB,IAAMC,EAAQN,EAAgB,GAAKK,EAC7BE,EAASD,EAAQL,GAAiB,KAAK,OAAO,EAAI,EAAI,GAC5D,OAAOK,EAAQC,CACjB,EACA,QAAQF,EAASG,EAAOC,EAAU,CAChC,IAAMC,EAASD,GAAU,QAAU,EACnC,MAAO,EAAEC,GAAU,KAAOA,EAAS,MAAQC,EAAYH,CAAK,GAAKH,EAAUH,CAC7E,CACF,CAAC,CACH,CACA,SAASS,EAAYC,EAAG,CACtB,MAAI,EAAAA,aAAanB,GACXmB,EAAE,aAAeC,GAAuBD,EAAE,aAAeE,EAKjE,CAEA,IAAMD,EAAsB,IACtBC,EAAoB","sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function createFetchHeaderMutator(fetchFn = fetch, mutator) {\n return async function headerMutatedFetch(url, requestInit) {\n if (!requestInit) {\n return fetchFn(url, {\n headers: await mutator(new Headers())\n });\n }\n return fetchFn(url, {\n ...requestInit,\n headers: await mutator(new Headers(requestInit.headers))\n });\n };\n}","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetchRetry from \"fetch-retry\";\nimport { PalantirApiError } from \"../client/PalantirApiError\";\nconst INITIAL_DELAY = 1_000;\nconst JITTER_FACTOR = 0.5;\nconst MAX_RETRIES = 3;\nexport function createRetryingFetch(fetch) {\n return fetchRetry(fetch, {\n retryDelay(attempt) {\n const delay = INITIAL_DELAY * 2 ** attempt;\n const jitter = delay * JITTER_FACTOR * (Math.random() * 2 - 1);\n return delay + jitter;\n },\n retryOn(attempt, error, response) {\n const status = response?.status ?? 0;\n return !(status >= 200 && status < 300) && isRetryable(error) && attempt < MAX_RETRIES;\n }\n });\n}\nfunction isRetryable(e) {\n if (e instanceof PalantirApiError) {\n if (e.statusCode !== SERVICE_UNAVAILABLE && e.statusCode !== TOO_MANY_REQUESTS) {\n return false;\n }\n }\n return true; // I think this logic is flawed?\n}\n\nconst SERVICE_UNAVAILABLE = 503;\nconst TOO_MANY_REQUESTS = 429;","/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class PalantirApiError extends Error {\n constructor(message, errorName, errorType, statusCode, errorInstanceId, parameters) {\n super(message);\n this.message = message;\n this.errorName = errorName;\n this.errorType = errorType;\n this.statusCode = statusCode;\n this.errorInstanceId = errorInstanceId;\n this.parameters = parameters;\n }\n}"]}
package/build/js/index.js DELETED
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkSHYKLQMU_js = require('./chunk-SHYKLQMU.js');
4
-
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
-
7
- exports.createOpenApiRequest = j;
8
- exports.createThinClient = J;
9
- exports.isOk = R;
10
- //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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","retryingFetch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C,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,16 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkSHYKLQMU_js = require('../chunk-SHYKLQMU.js');
4
-
5
-
6
-
7
- Object.defineProperty(exports, 'createFetchHeaderMutator', {
8
- enumerable: true,
9
- get: function () { return chunkSHYKLQMU_js.a; }
10
- });
11
- Object.defineProperty(exports, 'createRetryingFetch', {
12
- enumerable: true,
13
- get: function () { return chunkSHYKLQMU_js.c; }
14
- });
15
- //# sourceMappingURL=out.js.map
16
- //# sourceMappingURL=utils.js.map
@@ -1,3 +0,0 @@
1
- export { a as createFetchHeaderMutator, c as createRetryingFetch } from '../chunk-BZ6L26S2.mjs';
2
- //# sourceMappingURL=out.js.map
3
- //# sourceMappingURL=utils.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- export declare class PalantirApiError extends Error implements PalantirApiError {
2
- message: string;
3
- errorName?: string;
4
- errorType?: string;
5
- statusCode?: number;
6
- errorInstanceId?: string;
7
- parameters?: any;
8
- constructor(message: string, errorName?: string, errorType?: string, statusCode?: number, errorInstanceId?: string, parameters?: any);
9
- }
@@ -1,11 +0,0 @@
1
- export type ResultOrError<T extends object> = ({
2
- type: "ok";
3
- err?: never;
4
- } & T) | {
5
- type: "err";
6
- data?: never;
7
- err?: unknown;
8
- };
9
- export declare function isOk(result: ResultOrError<any>): result is {
10
- type: "ok";
11
- };
@@ -1,13 +0,0 @@
1
- import type * as ontology from "../ontology";
2
- import type { FetchAsJsonFn } from "../util";
3
- export interface ThinClient<O extends ontology.OntologyDefinition<any>> {
4
- ontology: O;
5
- stack: string;
6
- /**
7
- * The fetch function to use for all requests.
8
- *
9
- * TODO: Document what is needed to get retry logic
10
- */
11
- fetch: typeof globalThis.fetch;
12
- fetchJson: FetchAsJsonFn;
13
- }
@@ -1,5 +0,0 @@
1
- import { PalantirApiError } from "./PalantirApiError";
2
- export declare class UnknownError extends PalantirApiError {
3
- originalError: Error | undefined;
4
- constructor(message: string, errorType: string, originalError?: Error);
5
- }
@@ -1,2 +0,0 @@
1
- import type { OpenApiRequest } from "@osdk/gateway/types";
2
- export declare function createOpenApiRequest<TExpectedResponse, AsReadableStream extends boolean = false>(basePath: string, fetchFn: typeof fetch, contextPath?: string, asReadableStream?: AsReadableStream): OpenApiRequest<AsReadableStream extends true ? ReadableStream<Uint8Array> : Exclude<TExpectedResponse, ReadableStream<Uint8Array>>>;
@@ -1,6 +0,0 @@
1
- import type { OntologyDefinition } from "../ontology";
2
- import type { ThinClient } from "./ThinClient";
3
- /**
4
- * The goal of the thin client is to provide a way to tree shake as much as possible.
5
- */
6
- export declare function createThinClient<T extends OntologyDefinition<any>>(ontology: T, stack: string, tokenProvider: () => Promise<string> | string, fetchFn?: typeof globalThis.fetch): ThinClient<T>;
@@ -1,72 +0,0 @@
1
- import type * as GeoJSON from "geojson";
2
- import type { ActionDefinition } from "./ActionDefinition";
3
- import type { OntologyMetadata } from "./OntologyMetadata";
4
- import type { QueryDefinition } from "./QueryDefinition";
5
- export type ObjectInfoFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = O["objects"][K];
6
- export type ObjectTypesFrom<O extends OntologyDefinition<string>> = keyof O["objects"];
7
- export type PropertyKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof ObjectInfoFrom<O, K>["properties"];
8
- export type PropertyDefinitionsFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = ObjectInfoFrom<O, K>["properties"];
9
- export type PropertyDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, P extends PropertyKeysFrom<O, K>> = PropertyDefinitionsFrom<O, K>[P];
10
- export interface OntologyDefinition<K extends string, A extends string = any, Q extends string = any> {
11
- metadata: OntologyMetadata;
12
- objects: {
13
- [KK in K]: ObjectDefinition<KK, K>;
14
- };
15
- actions: {
16
- [AA in A]: ActionDefinition<AA, K>;
17
- };
18
- queries: {
19
- [QQ in Q]: QueryDefinition<QQ, K>;
20
- };
21
- }
22
- export interface ObjectDefinition<K extends string, L extends string> {
23
- apiName: K;
24
- description?: string;
25
- primaryKeyType: keyof ValidPropertyTypes;
26
- properties: Record<string, PropertyDefinition>;
27
- links: Record<string, LinkDefinition<L>>;
28
- }
29
- export type LinkKeysFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>> = keyof ObjectInfoFrom<O, K>["links"];
30
- export interface LinkDefinition<K extends string> {
31
- targetType: K;
32
- multiplicity: boolean;
33
- }
34
- export type LinkDefinitionFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends LinkKeysFrom<O, K>> = ObjectInfoFrom<O, K>["links"][L];
35
- export type LinkTargetTypeFrom<O extends OntologyDefinition<any>, K extends ObjectTypesFrom<O>, L extends LinkKeysFrom<O, K>> = LinkDefinitionFrom<O, K, L>["targetType"];
36
- export interface PropertyDefinition {
37
- readonly?: boolean;
38
- displayName?: string;
39
- description?: string;
40
- type: keyof ValidPropertyTypes;
41
- multiplicity?: boolean;
42
- nullable?: boolean;
43
- }
44
- export interface ValidPropertyTypes {
45
- string: string;
46
- datetime: string;
47
- double: number;
48
- boolean: boolean;
49
- integer: number;
50
- timestamp: string;
51
- short: number;
52
- long: number;
53
- float: number;
54
- decimal: number;
55
- byte: number;
56
- numericTimeseries: any;
57
- stringTimeseries: any;
58
- attachment: any;
59
- geopoint: GeoJSON.Point;
60
- geoshape: GeoJSON.Geometry;
61
- }
62
- type MaybeArray<T extends {
63
- multiplicity?: boolean | undefined;
64
- }, U> = T["multiplicity"] extends true ? Array<U> : U;
65
- type MaybeNullable<T extends PropertyDefinition, U> = T["nullable"] extends true ? U | undefined : U;
66
- type Raw<T> = T extends Array<any> ? T[0] : T;
67
- type Converted<T> = T extends Array<any> ? T[1] : T;
68
- export type OsdkObjectPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, Converted<ValidPropertyTypes[T["type"]]>>>;
69
- export type OsdkObjectRawPropertyType<T extends PropertyDefinition> = MaybeNullable<T, MaybeArray<T, Raw<ValidPropertyTypes[T["type"]]>>>;
70
- export type OsdkObjectLink<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = MaybeArray<T, OsdkObjectLink_Inner<K, O, T>>;
71
- type OsdkObjectLink_Inner<K extends string, O extends OntologyDefinition<K>, T extends LinkDefinition<any>> = T["targetType"] extends keyof O["objects"] ? O["objects"][T["targetType"]] : never;
72
- export {};
@@ -1,14 +0,0 @@
1
- import type { ObjectInfoFrom, ObjectTypesFrom, OntologyDefinition, OsdkObjectPropertyType, PropertyKeysFrom } from "./Definition";
2
- export type OsdkObjectFrom<T_ObjectTypeKey extends ObjectTypesFrom<T_Ontology>, T_Ontology extends OntologyDefinition<any>, T_PropertyKeys extends PropertyKeysFrom<T_Ontology, T_ObjectTypeKey> = PropertyKeysFrom<T_Ontology, T_ObjectTypeKey>> = {
3
- [P in T_PropertyKeys]: OsdkObjectPropertyType<ObjectInfoFrom<T_Ontology, T_ObjectTypeKey>["properties"][P]>;
4
- } & {
5
- /**@deprecated Use __apiName */
6
- __name: T_ObjectTypeKey;
7
- __apiName: T_ObjectTypeKey;
8
- __primaryKey: ObjectInfoFrom<T_Ontology, T_ObjectTypeKey>["primaryKeyType"];
9
- /**
10
- * Future versions will require explicitly asking for this field. For now we are marking
11
- * as always optional to avoid breaking changes.
12
- */
13
- __rid?: string;
14
- };
@@ -1,2 +0,0 @@
1
- export { createFetchHeaderMutator } from "../util/createFetchHeaderMutator.js";
2
- export { createRetryingFetch } from "../util/createRetryingFetch.js";
@@ -1,15 +0,0 @@
1
- /**
2
- * Fetches the given URL, converting the body to JSON, setting the Content-Type header to application/json,
3
- * and calling .json() on the response.
4
- */
5
- export type FetchAsJsonFn = (url: URL, requestInit: Omit<RequestInit, "body"> & {
6
- body?: object | undefined;
7
- }) => Promise<any>;
8
- /**
9
- * Wraps a fetch function to set the Content-Type header to application/json, to handle JSON.stringify(),
10
- * and to parse the response as JSON.
11
- *
12
- * @param fetchFn The fetch function to wrap
13
- * @returns
14
- */
15
- export declare function createFetchAsJson(fetchFn?: typeof fetch): FetchAsJsonFn;
@@ -1 +0,0 @@
1
- export declare function createFetchHeaderMutator(fetchFn: typeof fetch | undefined, mutator: (headers: Headers) => Promise<Headers> | Headers): typeof fetch;
@@ -1,9 +0,0 @@
1
- /**
2
- * Wraps a fetch plugin so that all errors (including when statusCode is not in the 200s) are converted to either PalantirApiError or UnknownError.
3
- *
4
- * If the returned promise does not have an error state, you are free to immediately call `.json()` or equivalent.
5
- *
6
- * @param fetchFn
7
- * @returns
8
- */
9
- export declare function createFetchOrThrow(fetchFn?: typeof fetch): (url: RequestInfo | URL, requestInit?: RequestInit) => Promise<Response>;
@@ -1,2 +0,0 @@
1
- /// <reference types="fetch-retry" />
2
- export declare function createRetryingFetch(fetch: typeof globalThis.fetch): (input: RequestInfo | URL, init?: import("fetch-retry").RequestInitWithRetry | undefined) => Promise<Response>;
@@ -1,6 +0,0 @@
1
- export { createFetchHeaderMutator } from "./createFetchHeaderMutator";
2
- export { createFetchOrThrow } from "./createFetchOrThrow";
3
- export { createRetryingFetch } from "./createRetryingFetch";
4
- export { createFetchAsJson } from "./FetchAsJson";
5
- export type { FetchAsJsonFn } from "./FetchAsJson";
6
- export { stringifyBody } from "./stringifyBody";
@@ -1 +0,0 @@
1
- export declare function stringifyBody(body: object | undefined): BodyInit | null | undefined;
File without changes