@dremio/js-sdk 0.5.1 → 0.6.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.
@@ -1,29 +1,18 @@
1
1
  import type { SonarV3Config } from "../../common/Config.ts";
2
- import { type Result } from "ts-results-es";
2
+ import { Err, Ok, type Result } from "ts-results-es";
3
3
  import { Temporal } from "temporal-polyfill";
4
+ import type { HttpError } from "../../common/HttpError.ts";
4
5
  export declare class Engine {
5
6
  #private;
6
7
  readonly id: EngineEntity["id"];
7
8
  readonly name: EngineEntity["name"];
8
9
  readonly spec: {
9
10
  c3StorageSize: EngineEntity["spec"]["c3StorageSize"];
10
- executorPodMetadata: {
11
- annotations: EngineEntity["spec"]["executorPodMetadata"]["annotations"];
12
- labels: EngineEntity["spec"]["executorPodMetadata"]["labels"];
13
- nodeSelectors: EngineEntity["spec"]["executorPodMetadata"]["nodeSelectors"];
14
- tolerations: {
15
- key: EngineEntity["spec"]["executorPodMetadata"]["tolerations"][number]["key"];
16
- operator: EngineEntity["spec"]["executorPodMetadata"]["tolerations"][number]["operator"];
17
- effect: EngineEntity["spec"]["executorPodMetadata"]["tolerations"][number]["effect"];
18
- tolerationDuration: Temporal.Duration;
19
- value?: EngineEntity["spec"]["executorPodMetadata"]["tolerations"][number]["value"];
20
- }[];
21
- idleTimeout?: Temporal.Duration;
22
- resourceAllocationOffset: EngineEntity["spec"]["executorPodMetadata"]["resourceAllocationOffset"];
23
- size: EngineEntity["spec"]["executorPodMetadata"]["size"];
24
- spillStorageSize: EngineEntity["spec"]["executorPodMetadata"]["spillStorageSize"];
25
- targetCpuCapacity: EngineEntity["spec"]["executorPodMetadata"]["targetCpuCapacity"];
26
- };
11
+ size: EngineEntity["spec"]["size"];
12
+ spillStorageSize: EngineEntity["spec"]["spillStorageSize"];
13
+ targetCpuCapacity: EngineEntity["spec"]["targetCpuCapacity"];
14
+ resourceAllocationOffset: EngineEntity["spec"]["resourceAllocationOffset"];
15
+ idleTimeout?: Temporal.Duration;
27
16
  };
28
17
  readonly status: Omit<EngineEntity["status"], "message"> & {
29
18
  message: string | null;
@@ -32,29 +21,21 @@ export declare class Engine {
32
21
  get settled(): boolean;
33
22
  start(): Promise<Result<Engine, unknown>>;
34
23
  stop(): Promise<Result<Engine, unknown>>;
24
+ update(params: Partial<{
25
+ name: Engine["name"];
26
+ spec: Partial<Engine["spec"]>;
27
+ }>): Promise<Err<HttpError> | Ok<Engine>>;
35
28
  }
36
29
  export type EngineEntity = {
37
30
  id: string;
38
31
  name: string;
39
32
  spec: {
40
33
  c3StorageSize: string;
41
- executorPodMetadata: {
42
- labels: Record<string, string>;
43
- annotations: Record<string, string>;
44
- nodeSelectors: Record<string, string>;
45
- tolerations: {
46
- key: string;
47
- operator: "Exists" | "Equal";
48
- effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute";
49
- tolerationSeconds: number;
50
- value?: number;
51
- }[];
52
- idleTimeout?: string;
53
- resourceAllocationOffset: string;
54
- size: "2XSmall" | "XSmall" | "Small" | "Medium" | "Large" | "XLarge" | "2XLarge";
55
- spillStorageSize: string;
56
- targetCpuCapacity: string;
57
- };
34
+ idleTimeout?: string;
35
+ spillStorageSize: string;
36
+ targetCpuCapacity: string;
37
+ resourceAllocationOffset: string;
38
+ size: "2XSmall" | "XSmall" | "Small" | "Medium" | "Large" | "XLarge" | "2XLarge";
58
39
  };
59
40
  status: {
60
41
  message: string;
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import parseMilliseconds from "parse-ms";
17
16
  import { Err, Ok } from "ts-results-es";
18
17
  import { Temporal } from "temporal-polyfill";
19
18
  export class Engine {
@@ -22,23 +21,15 @@ export class Engine {
22
21
  spec;
23
22
  status;
24
23
  #config;
25
- // eslint-disable-next-line no-unused-private-class-members
26
24
  #tag;
27
25
  constructor(entity, config) {
28
26
  this.id = entity.id;
29
27
  this.name = entity.name;
30
28
  this.spec = {
31
29
  ...entity.spec,
32
- executorPodMetadata: {
33
- ...entity.spec.executorPodMetadata,
34
- idleTimeout: entity.spec.executorPodMetadata.idleTimeout
35
- ? Temporal.Duration.from(entity.spec.executorPodMetadata.idleTimeout)
36
- : undefined,
37
- tolerations: entity.spec.executorPodMetadata.tolerations.map(({ tolerationSeconds, ...toleration }) => ({
38
- ...toleration,
39
- tolerationDuration: Temporal.Duration.from(parseMilliseconds(tolerationSeconds * 1000)),
40
- })),
41
- },
30
+ idleTimeout: entity.spec.idleTimeout
31
+ ? Temporal.Duration.from(entity.spec.idleTimeout)
32
+ : undefined,
42
33
  };
43
34
  this.status = {
44
35
  ...entity.status,
@@ -72,5 +63,28 @@ export class Engine {
72
63
  .then((entity) => Ok(new Engine(entity, this.#config)))
73
64
  .catch((e) => Err(e));
74
65
  }
66
+ async update(params) {
67
+ const updateOptions = {
68
+ name: params.name || this.name,
69
+ spec: {
70
+ ...this.spec,
71
+ ...params.spec,
72
+ },
73
+ version: this.#tag,
74
+ };
75
+ return this.#config
76
+ .sonarV3Request(`engines/${this.id}`, {
77
+ body: JSON.stringify(updateOptions),
78
+ headers: {
79
+ Accept: "application/json",
80
+ "Content-Type": "application/json",
81
+ },
82
+ keepalive: true,
83
+ method: "PUT",
84
+ })
85
+ .then((res) => res.json())
86
+ .then((entity) => Ok(new Engine(entity, this.#config)))
87
+ .catch((e) => Err(e));
88
+ }
75
89
  }
76
90
  //# sourceMappingURL=Engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Engine.js","sourceRoot":"","sources":["../../../src/enterprise/engines/Engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,iBAAiB,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,OAAO,MAAM;IACD,EAAE,CAAqB;IACvB,IAAI,CAAuB;IA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KAAK,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC;IAC9E,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,IAAI,CAAC,EAAE,QAAQ,EAAE;YAC1C,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;YACvC,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA2B,CAAC;aAClD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACtD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,IAAI,CAAC,EAAE,OAAO,EAAE;YACzC,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;YACvC,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA2B,CAAC;aAClD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACtD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;CACF","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 parseMilliseconds from \"parse-ms\";\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport { Err, Ok, type Result } from \"ts-results-es\";\nimport { Temporal } from \"temporal-polyfill\";\n\nexport class Engine {\n public readonly id: EngineEntity[\"id\"];\n public readonly name: EngineEntity[\"name\"];\n public readonly spec: {\n c3StorageSize: EngineEntity[\"spec\"][\"c3StorageSize\"];\n executorPodMetadata: {\n annotations: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"annotations\"];\n labels: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"labels\"];\n nodeSelectors: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"nodeSelectors\"];\n tolerations: {\n key: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"tolerations\"][number][\"key\"];\n operator: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"tolerations\"][number][\"operator\"];\n effect: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"tolerations\"][number][\"effect\"];\n tolerationDuration: Temporal.Duration;\n value?: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"tolerations\"][number][\"value\"];\n }[];\n idleTimeout?: Temporal.Duration;\n resourceAllocationOffset: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"resourceAllocationOffset\"];\n size: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"size\"];\n spillStorageSize: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"spillStorageSize\"];\n targetCpuCapacity: EngineEntity[\"spec\"][\"executorPodMetadata\"][\"targetCpuCapacity\"];\n };\n };\n public readonly status: Omit<EngineEntity[\"status\"], \"message\"> & {\n message: string | null;\n };\n\n readonly #config: SonarV3Config;\n\n // eslint-disable-next-line no-unused-private-class-members\n readonly #tag: string;\n\n constructor(entity: EngineEntity, config: SonarV3Config) {\n this.id = entity.id;\n this.name = entity.name;\n this.spec = {\n ...entity.spec,\n executorPodMetadata: {\n ...entity.spec.executorPodMetadata,\n idleTimeout: entity.spec.executorPodMetadata.idleTimeout\n ? Temporal.Duration.from(entity.spec.executorPodMetadata.idleTimeout)\n : undefined,\n tolerations: entity.spec.executorPodMetadata.tolerations.map(\n ({ tolerationSeconds, ...toleration }) => ({\n ...toleration,\n tolerationDuration: Temporal.Duration.from(parseMilliseconds(tolerationSeconds * 1000)),\n }),\n ),\n },\n };\n this.status = {\n ...entity.status,\n message: entity.status.message?.length ? entity.status.message : null,\n };\n this.#tag = entity.version;\n this.#config = config;\n }\n\n get settled() {\n return this.status.state !== \"STARTING\" && this.status.state !== \"STOPPING\";\n }\n\n start(): Promise<Result<Engine, unknown>> {\n return this.#config\n .sonarV3Request(`engines/${this.id}/start`, {\n headers: { Accept: \"application/json\" },\n keepalive: true,\n method: \"PUT\",\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: unknown) => Err(e));\n }\n\n stop(): Promise<Result<Engine, unknown>> {\n return this.#config\n .sonarV3Request(`engines/${this.id}/stop`, {\n headers: { Accept: \"application/json\" },\n keepalive: true,\n method: \"PUT\",\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: unknown) => Err(e));\n }\n}\n\nexport type EngineEntity = {\n id: string;\n name: string;\n spec: {\n c3StorageSize: string;\n executorPodMetadata: {\n labels: Record<string, string>;\n annotations: Record<string, string>;\n nodeSelectors: Record<string, string>;\n tolerations: {\n key: string;\n operator: \"Exists\" | \"Equal\";\n effect: \"NoSchedule\" | \"PreferNoSchedule\" | \"NoExecute\";\n tolerationSeconds: number;\n value?: number;\n }[];\n idleTimeout?: string;\n resourceAllocationOffset: string;\n size: \"2XSmall\" | \"XSmall\" | \"Small\" | \"Medium\" | \"Large\" | \"XLarge\" | \"2XLarge\";\n spillStorageSize: string;\n targetCpuCapacity: string;\n };\n };\n status: {\n message: string;\n replicas: {\n id: string;\n executors: {\n cpu: number;\n memory: number;\n name: string;\n status: string;\n }[];\n }[];\n runningExecutors: number;\n runningReplicas: number;\n startingExecutors: number;\n startingReplicas: number;\n state: \"STARTING\" | \"RUNNING\" | \"STOPPING\" | \"STOPPED\" | \"WARNING\" | \"FAILED\";\n stoppingExecutors: number;\n stoppingReplicas: number;\n };\n version: string;\n};\n"]}
1
+ {"version":3,"file":"Engine.js","sourceRoot":"","sources":["../../../src/enterprise/engines/Engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,MAAM,OAAO,MAAM;IACD,EAAE,CAAqB;IACvB,IAAI,CAAuB;IAC3B,IAAI,CAOlB;IACc,MAAM,CAEpB;IAEO,OAAO,CAAgB;IAEvB,IAAI,CAAS;IAEtB,YAAY,MAAoB,EAAE,MAAqB;QACrD,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG;YACV,GAAG,MAAM,CAAC,IAAI;YACd,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW;gBAClC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;gBACjD,CAAC,CAAC,SAAS;SACd,CAAC;QACF,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,MAAM,CAAC,MAAM;YAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,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AG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,MAGE;QAEF,MAAM,aAAa,GAAG;YACpB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;YAC9B,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,GAAG,MAAM,CAAC,IAAI;aACf;YACD,OAAO,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,IAAI,CAAC,EAAE,EAAE,EAAE;YACpC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;YACnC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA2B,CAAC;aAClD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACtD,KAAK,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;CACF","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 { SonarV3Config } from \"../../common/Config.ts\";\nimport { Err, Ok, type Result } from \"ts-results-es\";\nimport { Temporal } from \"temporal-polyfill\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\n\nexport class Engine {\n public readonly id: EngineEntity[\"id\"];\n public readonly name: EngineEntity[\"name\"];\n public readonly spec: {\n c3StorageSize: EngineEntity[\"spec\"][\"c3StorageSize\"];\n size: EngineEntity[\"spec\"][\"size\"];\n spillStorageSize: EngineEntity[\"spec\"][\"spillStorageSize\"];\n targetCpuCapacity: EngineEntity[\"spec\"][\"targetCpuCapacity\"];\n resourceAllocationOffset: EngineEntity[\"spec\"][\"resourceAllocationOffset\"];\n idleTimeout?: Temporal.Duration;\n };\n public readonly status: Omit<EngineEntity[\"status\"], \"message\"> & {\n message: string | null;\n };\n\n readonly #config: SonarV3Config;\n\n readonly #tag: string;\n\n constructor(entity: EngineEntity, config: SonarV3Config) {\n this.id = entity.id;\n this.name = entity.name;\n this.spec = {\n ...entity.spec,\n idleTimeout: entity.spec.idleTimeout\n ? Temporal.Duration.from(entity.spec.idleTimeout)\n : undefined,\n };\n this.status = {\n ...entity.status,\n message: entity.status.message?.length ? entity.status.message : null,\n };\n this.#tag = entity.version;\n this.#config = config;\n }\n\n get settled() {\n return this.status.state !== \"STARTING\" && this.status.state !== \"STOPPING\";\n }\n\n start(): Promise<Result<Engine, unknown>> {\n return this.#config\n .sonarV3Request(`engines/${this.id}/start`, {\n headers: { Accept: \"application/json\" },\n keepalive: true,\n method: \"PUT\",\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: unknown) => Err(e));\n }\n\n stop(): Promise<Result<Engine, unknown>> {\n return this.#config\n .sonarV3Request(`engines/${this.id}/stop`, {\n headers: { Accept: \"application/json\" },\n keepalive: true,\n method: \"PUT\",\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: unknown) => Err(e));\n }\n\n async update(\n params: Partial<{\n name: Engine[\"name\"];\n spec: Partial<Engine[\"spec\"]>;\n }>,\n ) {\n const updateOptions = {\n name: params.name || this.name,\n spec: {\n ...this.spec,\n ...params.spec,\n },\n version: this.#tag,\n };\n return this.#config\n .sonarV3Request(`engines/${this.id}`, {\n body: JSON.stringify(updateOptions),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"PUT\",\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: HttpError) => Err(e));\n }\n}\n\nexport type EngineEntity = {\n id: string;\n name: string;\n spec: {\n c3StorageSize: string;\n idleTimeout?: string;\n spillStorageSize: string;\n targetCpuCapacity: string;\n resourceAllocationOffset: string;\n size: \"2XSmall\" | \"XSmall\" | \"Small\" | \"Medium\" | \"Large\" | \"XLarge\" | \"2XLarge\";\n };\n status: {\n message: string;\n replicas: {\n id: string;\n executors: {\n cpu: number;\n memory: number;\n name: string;\n status: string;\n }[];\n }[];\n runningExecutors: number;\n runningReplicas: number;\n startingExecutors: number;\n startingReplicas: number;\n state: \"STARTING\" | \"RUNNING\" | \"STOPPING\" | \"STOPPED\" | \"WARNING\" | \"FAILED\";\n stoppingExecutors: number;\n stoppingReplicas: number;\n };\n version: string;\n};\n"]}
@@ -1,10 +1,13 @@
1
+ import { Err, Ok } from "ts-results-es";
1
2
  import type { ResourceConfig, SonarV3Config } from "../../common/Config.ts";
2
3
  import type { SignalParam } from "../../common/Params.ts";
3
4
  import { Engine } from "./Engine.ts";
5
+ import type { HttpError } from "../../common/HttpError.ts";
4
6
  export declare class EnginesResource {
5
7
  #private;
6
8
  constructor(config: ResourceConfig & SonarV3Config);
7
9
  list(): {
8
10
  data({ signal }?: SignalParam): AsyncGenerator<Engine, void, unknown>;
9
11
  };
12
+ retrieve(id: string, { signal }?: SignalParam): Promise<Err<HttpError> | Ok<Engine>>;
10
13
  }
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { Err, Ok } from "ts-results-es";
16
17
  import { Engine } from "./Engine.js";
17
18
  export class EnginesResource {
18
19
  #config;
@@ -30,5 +31,15 @@ export class EnginesResource {
30
31
  },
31
32
  };
32
33
  }
34
+ retrieve(id, { signal } = {}) {
35
+ return this.#config
36
+ .sonarV3Request(`engines/${id}`, {
37
+ headers: { Accept: "application/json" },
38
+ signal,
39
+ })
40
+ .then((res) => res.json())
41
+ .then((entity) => Ok(new Engine(entity, this.#config)))
42
+ .catch((e) => Err(e));
43
+ }
33
44
  }
34
45
  //# sourceMappingURL=EnginesResource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnginesResource.js","sourceRoot":"","sources":["../../../src/enterprise/engines/EnginesResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,MAAM,OAAO,eAAe;IACjB,OAAO,CAAiC;IAEjD,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI;QACF,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,KAAkB,EAAE,EAAE,EAAE,CAC/C,IAAI,CAAC,OAAO;aACT,cAAc,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC;aAC9E,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAuC,CAAC;aAC9D,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO;YACL,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAkB,EAAE;gBACtC,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACnC,CAAC;SACF,CAAC;IACJ,CAAC;CACF","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 { ResourceConfig, SonarV3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { Engine, type EngineEntity } from \"./Engine.ts\";\n\nexport class EnginesResource {\n readonly #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n list() {\n const getPage = ({ signal }: SignalParam = {}) =>\n this.#config\n .sonarV3Request(\"engines\", { headers: { Accept: \"application/json\" }, signal })\n .then((res) => res.json() as Promise<{ data: EngineEntity[] }>)\n .then((res) => res.data.map((entity) => new Engine(entity, this.#config)));\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* await getPage({ signal });\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"EnginesResource.js","sourceRoot":"","sources":["../../../src/enterprise/engines/EnginesResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAGxD,MAAM,OAAO,eAAe;IACjB,OAAO,CAAiC;IAEjD,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI;QACF,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,KAAkB,EAAE,EAAE,EAAE,CAC/C,IAAI,CAAC,OAAO;aACT,cAAc,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC;aAC9E,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAuC,CAAC;aAC9D,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO;YACL,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAkB,EAAE;gBACtC,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACnC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC/C,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,EAAE,EAAE,EAAE;YAC/B,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;YACvC,MAAM;SACP,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA2B,CAAC;aAClD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACtD,KAAK,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;CACF","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 { Err, Ok } from \"ts-results-es\";\nimport type { ResourceConfig, SonarV3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { Engine, type EngineEntity } from \"./Engine.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\n\nexport class EnginesResource {\n readonly #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n list() {\n const getPage = ({ signal }: SignalParam = {}) =>\n this.#config\n .sonarV3Request(\"engines\", { headers: { Accept: \"application/json\" }, signal })\n .then((res) => res.json() as Promise<{ data: EngineEntity[] }>)\n .then((res) => res.data.map((entity) => new Engine(entity, this.#config)));\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* await getPage({ signal });\n },\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`engines/${id}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .then((res) => res.json() as Promise<EngineEntity>)\n .then((entity) => Ok(new Engine(entity, this.#config)))\n .catch((e: HttpError) => Err(e));\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dremio/js-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "JavaScript library for the Dremio API",
5
5
  "keywords": [
6
6
  "dremio",