@dremio/js-sdk 0.24.1 → 0.24.3

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.
@@ -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,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAClB,CAAC;aAAM,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAA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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,CAAC,YAAY,CAAC,CAAC;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,KAA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F,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"]}
@@ -1,7 +1,8 @@
1
1
  import { Observable } from "rxjs";
2
2
  import { type EventSourceMessage } from "eventsource-parser/stream";
3
+ import type { SignalParam } from "./Params.ts";
3
4
  /**
4
5
  * Takes an instance of `Response` that will resolve to a `text/event-stream` and maps it
5
6
  * into an observable that emits for each event as it arrives
6
7
  */
7
- export declare const fromTextEventStream: (response: Promise<Response>) => Observable<EventSourceMessage>;
8
+ export declare const fromTextEventStream: (input: ({ signal }: SignalParam) => Promise<Response>) => Observable<EventSourceMessage>;
@@ -20,14 +20,14 @@ import { HttpError } from "./HttpError.js";
20
20
  * Takes an instance of `Response` that will resolve to a `text/event-stream` and maps it
21
21
  * into an observable that emits for each event as it arrives
22
22
  */
23
- export const fromTextEventStream = (response) => new Observable((subscriber) => {
23
+ export const fromTextEventStream = (input) => new Observable((subscriber) => {
24
24
  /**
25
25
  * Create an internal AbortController so that the response stream
26
26
  * can be canceled early if the subscriber unsubscribes early
27
27
  */
28
28
  const controller = new AbortController();
29
29
  const { signal } = controller;
30
- response
30
+ input({ signal })
31
31
  .then(async (response) => {
32
32
  if (!response.ok) {
33
33
  throw await HttpError.fromResponse(response);
@@ -1 +1 @@
1
- {"version":3,"file":"fromTextEventStream.js","sourceRoot":"","sources":["../../src/common/fromTextEventStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAA2B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,SAAS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AC,OAAO,EAAE,CAAC;gBACnB,MAAM;YACR,CAAC;YAED,IAAI,IAAI,EAAE,CAAC;gBACT,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACtB,MAAM;YACR,CAAC;YAED,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;QACpB,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,EAAE;QACV,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC,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 { Observable } from \"rxjs\";\nimport { type EventSourceMessage, EventSourceParserStream } from \"eventsource-parser/stream\";\nimport { HttpError } from \"./HttpError.ts\";\n\n/**\n * Takes an instance of `Response` that will resolve to a `text/event-stream` and maps it\n * into an observable that emits for each event as it arrives\n */\nexport const fromTextEventStream = (response: Promise<Response>) =>\n new Observable<EventSourceMessage>((subscriber) => {\n /**\n * Create an internal AbortController so that the response stream\n * can be canceled early if the subscriber unsubscribes early\n */\n const controller = new AbortController();\n const { signal } = controller;\n\n response\n .then(async (response) => {\n if (!response.ok) {\n throw await HttpError.fromResponse(response);\n }\n\n /**\n * Even though the correct Content-Type header isn't strictly required,\n * it's indicates either a client mistake or server implementation bug\n */\n if (response.headers.get(\"Content-Type\") !== \"text/event-stream\") {\n throw new Error(\n `Expected response type to be text/event-stream. Received ${response.headers.get(\"Content-Type\")}.`,\n );\n }\n\n /**\n * Response body should never be undefined for a text/event-stream\n */\n if (!response.body) {\n throw new Error(`Response body was undefined`);\n }\n\n /**\n * Pipe the raw byte stream through a text decoder, and then\n * through a parser that extracts individual SSE events\n */\n return response.body\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new EventSourceParserStream());\n })\n .then(async (readableStream) => {\n const reader = readableStream.getReader();\n\n /**\n * Check if the observable has been unsubscribed before reading\n * each chunk\n */\n while (!signal.aborted) {\n const { done, value } = await reader.read();\n\n /**\n * Check again after reading a chunk if the observable\n * has been unsubscribed to avoid calling .next() or\n * .complete() unnecessarily on the observable\n */\n if (signal.aborted) {\n break;\n }\n\n if (done) {\n subscriber.complete();\n break;\n }\n\n subscriber.next(value);\n }\n\n /**\n * Always call .cancel() on the reader even if the while loop\n * was exited due to stream completion in order to indicate it\n * can be fully cleaned up\n */\n await reader.cancel();\n })\n .catch((e: unknown) => {\n subscriber.error(e);\n });\n\n return () => {\n controller.abort();\n };\n });\n"]}
1
+ {"version":3,"file":"fromTextEventStream.js","sourceRoot":"","sources":["../../src/common/fromTextEventStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAA2B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAqD,EAAE,EAAE,CAC3F,IAAI,UAAU,CAAqB,CAAC,UAAU,EAAE,EAAE;IAChD;;;OAGG;IACH,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAE9B,KAAK,CAAC,EAAE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C,CAAC;SACD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;QACpB,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,EAAE;QACV,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC,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 { Observable } from \"rxjs\";\nimport { type EventSourceMessage, EventSourceParserStream } from \"eventsource-parser/stream\";\nimport { HttpError } from \"./HttpError.ts\";\nimport type { SignalParam } from \"./Params.ts\";\n\n/**\n * Takes an instance of `Response` that will resolve to a `text/event-stream` and maps it\n * into an observable that emits for each event as it arrives\n */\nexport const fromTextEventStream = (input: ({ signal }: SignalParam) => Promise<Response>) =>\n new Observable<EventSourceMessage>((subscriber) => {\n /**\n * Create an internal AbortController so that the response stream\n * can be canceled early if the subscriber unsubscribes early\n */\n const controller = new AbortController();\n const { signal } = controller;\n\n input({ signal })\n .then(async (response) => {\n if (!response.ok) {\n throw await HttpError.fromResponse(response);\n }\n\n /**\n * Even though the correct Content-Type header isn't strictly required,\n * it's indicates either a client mistake or server implementation bug\n */\n if (response.headers.get(\"Content-Type\") !== \"text/event-stream\") {\n throw new Error(\n `Expected response type to be text/event-stream. Received ${response.headers.get(\"Content-Type\")}.`,\n );\n }\n\n /**\n * Response body should never be undefined for a text/event-stream\n */\n if (!response.body) {\n throw new Error(`Response body was undefined`);\n }\n\n /**\n * Pipe the raw byte stream through a text decoder, and then\n * through a parser that extracts individual SSE events\n */\n return response.body\n .pipeThrough(new TextDecoderStream())\n .pipeThrough(new EventSourceParserStream());\n })\n .then(async (readableStream) => {\n const reader = readableStream.getReader();\n\n /**\n * Check if the observable has been unsubscribed before reading\n * each chunk\n */\n while (!signal.aborted) {\n const { done, value } = await reader.read();\n\n /**\n * Check again after reading a chunk if the observable\n * has been unsubscribed to avoid calling .next() or\n * .complete() unnecessarily on the observable\n */\n if (signal.aborted) {\n break;\n }\n\n if (done) {\n subscriber.complete();\n break;\n }\n\n subscriber.next(value);\n }\n\n /**\n * Always call .cancel() on the reader even if the while loop\n * was exited due to stream completion in order to indicate it\n * can be fully cleaned up\n */\n await reader.cancel();\n })\n .catch((e: unknown) => {\n subscriber.error(e);\n });\n\n return () => {\n controller.abort();\n };\n });\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.24.1",
3
+ "version": "0.24.3",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",