@dremio/js-sdk 0.24.2 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,7 @@ export declare class Dremio {
37
37
  request: import("../common/Config.ts").RequestFn;
38
38
  sonarV2Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
39
39
  sonarV3Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
40
+ v2Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
40
41
  v3Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
41
42
  v4Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
42
43
  };
@@ -10,6 +10,7 @@ export declare const getResourceConfig: (config: Config) => (projectId?: string)
10
10
  request: import("../common/Config.ts").RequestFn;
11
11
  sonarV2Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
12
12
  sonarV3Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
13
+ v2Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
13
14
  v3Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
14
15
  v4Request: (path: string, init?: RequestInit) => import("ts-results-es").AsyncResult<Response, import("./index.ts").HttpError>;
15
16
  };
@@ -32,6 +32,7 @@ export const getResourceConfig = (config) => (projectId) => {
32
32
  }
33
33
  return request(`/v0/projects/${projectId}/${path}`, init);
34
34
  },
35
+ v2Request: (path, init) => request(new URL(`/ui/${path}`, config.origin.replace("api", "app")).toString(), init),
35
36
  v3Request: (path, init) => request(`/v0/${path}`, init),
36
37
  v4Request: (path, init) => request(`/v1/${path}`, init),
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,IAAI,CAAC;KACC,CAAC;AACnF,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\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 type {\n Config,\n ResourceConfig,\n SonarV2Config,\n SonarV3Config,\n V3Config,\n V4Config,\n} from \"../common/Config.ts\";\nimport { createRequest } from \"../common/createRequest.ts\";\n\nexport const getResourceConfig = (config: Config) => (projectId?: string) => {\n const request = createRequest(config);\n return {\n logger: config.logger,\n origin: config.origin,\n request,\n sonarV2Request: (path: string, init?: RequestInit) => {\n if (!projectId) {\n throw new Error(\"projectId is required\");\n }\n return request(\n new URL(\n `/ui/projects/${projectId}/${path}`,\n config.origin.replace(\"api\", \"app\"),\n ).toString(),\n init,\n );\n },\n sonarV3Request: (path: string, init?: RequestInit) => {\n if (!projectId) {\n throw new Error(\"projectId is required\");\n }\n return request(`/v0/projects/${projectId}/${path}`, init);\n },\n v3Request: (path: string, init?: RequestInit) => request(`/v0/${path}`, init),\n v4Request: (path: string, init?: RequestInit) => request(`/v1/${path}`, init),\n } satisfies ResourceConfig & SonarV2Config & SonarV3Config & V3Config & V4Config;\n};\n"]}
1
+ {"version":3,"file":"getResourceConfig.js","sourceRoot":"","sources":["../../src/cloud/getResourceConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,SAAkB,EAAE,EAAE;IAC1E,MAAM,OAAO,GAAG,aA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ation\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 type {\n Config,\n ResourceConfig,\n SonarV2Config,\n SonarV3Config,\n V2Config,\n V3Config,\n V4Config,\n} from \"../common/Config.ts\";\nimport { createRequest } from \"../common/createRequest.ts\";\n\nexport const getResourceConfig = (config: Config) => (projectId?: string) => {\n const request = createRequest(config);\n return {\n logger: config.logger,\n origin: config.origin,\n request,\n sonarV2Request: (path: string, init?: RequestInit) => {\n if (!projectId) {\n throw new Error(\"projectId is required\");\n }\n return request(\n new URL(\n `/ui/projects/${projectId}/${path}`,\n config.origin.replace(\"api\", \"app\"),\n ).toString(),\n init,\n );\n },\n sonarV3Request: (path: string, init?: RequestInit) => {\n if (!projectId) {\n throw new Error(\"projectId is required\");\n }\n return request(`/v0/projects/${projectId}/${path}`, init);\n },\n v2Request: (path: string, init?: RequestInit) =>\n request(new URL(`/ui/${path}`, config.origin.replace(\"api\", \"app\")).toString(), init),\n v3Request: (path: string, init?: RequestInit) => request(`/v0/${path}`, init),\n v4Request: (path: string, init?: RequestInit) => request(`/v1/${path}`, init),\n } satisfies ResourceConfig & SonarV2Config & SonarV3Config & V2Config & V3Config & V4Config;\n};\n"]}
@@ -60,6 +60,13 @@ export type SonarV3Config = {
60
60
  export type SonarV4Config = {
61
61
  sonarV4Request: RequestFn;
62
62
  };
63
+ /**
64
+ * @hidden
65
+ * @internal
66
+ */
67
+ export type V2Config = {
68
+ v2Request: RequestFn;
69
+ };
63
70
  /**
64
71
  * @hidden
65
72
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/common/Config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\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 type { AsyncResult } from \"ts-results-es\";\nimport type { CredentialProvider } from \"./CredentialProvider.ts\";\nimport type { HttpError } from \"./HttpError.ts\";\n\nexport type RequestFn = (input: string, init?: RequestInit) => AsyncResult<Response, HttpError>;\n\nexport type Config = {\n /**\n * Custom `fetch` provider\n * @default globalThis.fetch\n */\n fetch?: (input: string, init?: RequestInit) => Promise<Response>;\n\n /**\n * Dremio API base origin\n */\n origin: string;\n\n logger?: {\n debug: typeof console.debug;\n error: typeof console.error;\n info: typeof console.info;\n warn: typeof console.warn;\n };\n\n /**\n * Provides credentials to Dremio for all authenticated API requests.\n * Required unless using a custom `fetch` provider with its own credentials provision\n */\n credentials?: CredentialProvider;\n\n /**\n * Configure the maximum number of times to retry requests that failed due to a\n * temporary condition such as 429 or 503. Default is 10. Set to 0 to disable\n * automatic retry.\n */\n maxRetryCount?: number;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type ResourceConfig = {\n logger?: Config[\"logger\"];\n origin: Config[\"origin\"];\n request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV2Config = {\n sonarV2Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV3Config = {\n sonarV3Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV4Config = {\n sonarV4Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type V3Config = {\n v3Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type V4Config = {\n v4Request: RequestFn;\n};\n"]}
1
+ {"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/common/Config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\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 type { AsyncResult } from \"ts-results-es\";\nimport type { CredentialProvider } from \"./CredentialProvider.ts\";\nimport type { HttpError } from \"./HttpError.ts\";\n\nexport type RequestFn = (input: string, init?: RequestInit) => AsyncResult<Response, HttpError>;\n\nexport type Config = {\n /**\n * Custom `fetch` provider\n * @default globalThis.fetch\n */\n fetch?: (input: string, init?: RequestInit) => Promise<Response>;\n\n /**\n * Dremio API base origin\n */\n origin: string;\n\n logger?: {\n debug: typeof console.debug;\n error: typeof console.error;\n info: typeof console.info;\n warn: typeof console.warn;\n };\n\n /**\n * Provides credentials to Dremio for all authenticated API requests.\n * Required unless using a custom `fetch` provider with its own credentials provision\n */\n credentials?: CredentialProvider;\n\n /**\n * Configure the maximum number of times to retry requests that failed due to a\n * temporary condition such as 429 or 503. Default is 10. Set to 0 to disable\n * automatic retry.\n */\n maxRetryCount?: number;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type ResourceConfig = {\n logger?: Config[\"logger\"];\n origin: Config[\"origin\"];\n request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV2Config = {\n sonarV2Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV3Config = {\n sonarV3Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type SonarV4Config = {\n sonarV4Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type V2Config = {\n v2Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type V3Config = {\n v3Request: RequestFn;\n};\n\n/**\n * @hidden\n * @internal\n */\nexport type V4Config = {\n v4Request: RequestFn;\n};\n"]}
@@ -38,7 +38,12 @@ export class HttpError extends Error {
38
38
  }
39
39
  else if (isProblem(body)) {
40
40
  super(body.title);
41
- this.body = body;
41
+ if (isValidationProblem(body)) {
42
+ this.body = new ValidationProblem(body.errors);
43
+ }
44
+ else {
45
+ this.body = new Problem(body);
46
+ }
42
47
  }
43
48
  else if (typeof body === "string") {
44
49
  super(body);
@@ -1 +1 @@
1
- {"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../../src/common/HttpError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,mBAAmB,GAAG,KAAK,EAAE,GAAa,EAAE,EAAE;IAClD,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAqB,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACf,IAAI,CAAoD;IAEjE,YAAY,MAAc,EAAE,IAAa;QACvC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YACjC,KAAK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IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AAEhF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAa,EAA6B,EAAE,CAC9E,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,oDAAoD,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\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 { Problem, ValidationProblem } from \"./Problem.ts\";\nimport { RateLimitError } from \"./problems.ts\";\n\nconst extractResponseBody = async (res: Response) => {\n if (res.headers.get(\"content-type\")?.includes(\"application/json\")) {\n return (await res.json()) as Promise<unknown>;\n } else {\n return await res.text();\n }\n};\n\nexport class HttpError extends Error {\n readonly status: number;\n readonly body: ApiV1Error | Problem | ValidationProblem | string;\n\n constructor(status: number, body: unknown) {\n if (status === 429) {\n const err = new RateLimitError();\n super(err.title);\n this.body = err;\n } else if (isApiV1Error(body)) {\n super(body.errorMessage);\n this.body = body;\n } else if (isProblem(body)) {\n super(body.title);\n this.body = body;\n } else if (typeof body === \"string\") {\n super(body);\n this.body = body;\n } else {\n super(\"An unexpected error occurred\");\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n this.body = body as any;\n }\n\n this.status = status;\n }\n\n static async fromResponse(res: Response) {\n return new HttpError(res.status, await extractResponseBody(res));\n }\n}\n\nexport const tokenInvalidError = new Problem({\n title:\n \"The provided authentication token was rejected because it was invalid or may have expired.\",\n type: \"https://api.dremio.dev/problems/auth/token-invalid\",\n});\n\ntype ApiV1Error = {\n errorMessage: string;\n moreInfo?: string;\n};\n\nconst isApiV1Error = (body: unknown): body is ApiV1Error =>\n typeof body === \"object\" && Object.prototype.hasOwnProperty.call(body, \"errorMessage\");\n\nexport const isProblem = (body: unknown): body is Problem =>\n body != null && typeof body === \"object\" && \"type\" in body && \"title\" in body;\n\nexport const isValidationProblem = (body: unknown): body is ValidationProblem =>\n isProblem(body) && body.title === \"https://api.dremio.dev/problems/validation-problem\";\n"]}
1
+ {"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../../src/common/HttpError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,mBAAmB,GAAG,KAAK,EAAE,GAAa,EAAE,EAAE;IAClD,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAqB,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACf,IAAI,CAAoD;IAEjE,YAAY,MAAc,EAAE,IAAa;QACvC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YACjC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAClB,CAAC;aAAM,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,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C,IAAa,EAAmB,EAAE,CAC1D,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AAEhF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAa,EAA6B,EAAE,CAC9E,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,oDAAoD,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\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 { Problem, ValidationProblem } from \"./Problem.ts\";\nimport { RateLimitError } from \"./problems.ts\";\n\nconst extractResponseBody = async (res: Response) => {\n if (res.headers.get(\"content-type\")?.includes(\"application/json\")) {\n return (await res.json()) as Promise<unknown>;\n } else {\n return await res.text();\n }\n};\n\nexport class HttpError extends Error {\n readonly status: number;\n readonly body: ApiV1Error | Problem | ValidationProblem | string;\n\n constructor(status: number, body: unknown) {\n if (status === 429) {\n const err = new RateLimitError();\n super(err.title);\n this.body = err;\n } else if (isApiV1Error(body)) {\n super(body.errorMessage);\n this.body = body;\n } else if (isProblem(body)) {\n super(body.title);\n if (isValidationProblem(body)) {\n this.body = new ValidationProblem(body.errors);\n } else {\n this.body = new Problem(body);\n }\n } else if (typeof body === \"string\") {\n super(body);\n this.body = body;\n } else {\n super(\"An unexpected error occurred\");\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n this.body = body as any;\n }\n\n this.status = status;\n }\n\n static async fromResponse(res: Response) {\n return new HttpError(res.status, await extractResponseBody(res));\n }\n}\n\nexport const tokenInvalidError = new Problem({\n title:\n \"The provided authentication token was rejected because it was invalid or may have expired.\",\n type: \"https://api.dremio.dev/problems/auth/token-invalid\",\n});\n\ntype ApiV1Error = {\n errorMessage: string;\n moreInfo?: string;\n};\n\nconst isApiV1Error = (body: unknown): body is ApiV1Error =>\n typeof body === \"object\" && Object.prototype.hasOwnProperty.call(body, \"errorMessage\");\n\nexport const isProblem = (body: unknown): body is Problem =>\n body != null && typeof body === \"object\" && \"type\" in body && \"title\" in body;\n\nexport const isValidationProblem = (body: unknown): body is ValidationProblem =>\n isProblem(body) && body.title === \"https://api.dremio.dev/problems/validation-problem\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.24.2",
3
+ "version": "0.24.4",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",