@dremio/js-sdk 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloud/ai/AiResource.d.ts +3 -15
- package/dist/cloud/ai/AiResource.js +11 -14
- package/dist/cloud/ai/AiResource.js.map +1 -1
- package/dist/cloud/arctic/ArcticResource.d.ts +1 -2
- package/dist/cloud/arctic/ArcticResource.js +5 -7
- package/dist/cloud/arctic/ArcticResource.js.map +1 -1
- package/dist/cloud/engines/Engine.d.ts +2 -3
- package/dist/cloud/engines/Engine.js +5 -6
- package/dist/cloud/engines/Engine.js.map +1 -1
- package/dist/cloud/engines/EnginesResource.d.ts +1 -1
- package/dist/cloud/engines/EnginesResource.js +5 -5
- package/dist/cloud/engines/EnginesResource.js.map +1 -1
- package/dist/cloud/index.d.ts +3 -5
- package/dist/cloud/index.js +0 -1
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/oauth/OAuthApplication.d.ts +1 -2
- package/dist/cloud/oauth/OAuthApplication.js +1 -3
- package/dist/cloud/oauth/OAuthApplication.js.map +1 -1
- package/dist/cloud/oauth/OAuthApplicationsResource.d.ts +2 -3
- package/dist/cloud/oauth/OAuthApplicationsResource.js +8 -11
- package/dist/cloud/oauth/OAuthApplicationsResource.js.map +1 -1
- package/dist/cloud/projects/Project.d.ts +2 -2
- package/dist/cloud/projects/ProjectsResource.d.ts +3 -4
- package/dist/cloud/projects/ProjectsResource.js +8 -17
- package/dist/cloud/projects/ProjectsResource.js.map +1 -1
- package/dist/cloud/users/CloudUsersResource.d.ts +2 -3
- package/dist/cloud/users/CloudUsersResource.js +4 -7
- package/dist/cloud/users/CloudUsersResource.js.map +1 -1
- package/dist/common/Config.d.ts +4 -2
- package/dist/common/Config.js.map +1 -1
- package/dist/common/HttpError.d.ts +7 -13
- package/dist/common/HttpError.js +19 -36
- package/dist/common/HttpError.js.map +1 -1
- package/dist/common/Problem.d.ts +29 -34
- package/dist/common/Problem.js +47 -19
- package/dist/common/Problem.js.map +1 -1
- package/dist/common/createRequest.js +8 -33
- package/dist/common/createRequest.js.map +1 -1
- package/dist/common/problems.d.ts +11 -9
- package/dist/common/problems.js +18 -9
- package/dist/common/problems.js.map +1 -1
- package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.d.ts +2 -3
- package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.js +3 -5
- package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.js.map +1 -1
- package/dist/enterprise/catalog/EnterpriseCatalogResource.js +3 -2
- package/dist/enterprise/catalog/EnterpriseCatalogResource.js.map +1 -1
- package/dist/enterprise/catalog/catalogRetrieve.js +4 -0
- package/dist/enterprise/catalog/catalogRetrieve.js.map +1 -1
- package/dist/enterprise/credentials/exchangePat.d.ts +2 -4
- package/dist/enterprise/credentials/exchangePat.js +3 -3
- package/dist/enterprise/credentials/exchangePat.js.map +1 -1
- package/dist/enterprise/engines/Engine.d.ts +3 -5
- package/dist/enterprise/engines/Engine.js +7 -11
- package/dist/enterprise/engines/Engine.js.map +1 -1
- package/dist/enterprise/engines/EnginesResource.d.ts +1 -3
- package/dist/enterprise/engines/EnginesResource.js +5 -7
- package/dist/enterprise/engines/EnginesResource.js.map +1 -1
- package/dist/enterprise/index.d.ts +7 -9
- package/dist/enterprise/index.js +0 -1
- package/dist/enterprise/index.js.map +1 -1
- package/dist/enterprise/roles/RolesResource.d.ts +2 -3
- package/dist/enterprise/roles/RolesResource.js +4 -7
- package/dist/enterprise/roles/RolesResource.js.map +1 -1
- package/dist/enterprise/scripts/EnterpriseScript.d.ts +3 -13
- package/dist/enterprise/scripts/EnterpriseScript.js +4 -6
- package/dist/enterprise/scripts/EnterpriseScript.js.map +1 -1
- package/dist/enterprise/scripts/EnterpriseScriptsResource.d.ts +6 -2
- package/dist/enterprise/scripts/EnterpriseScriptsResource.js +1 -1
- package/dist/enterprise/scripts/EnterpriseScriptsResource.js.map +1 -1
- package/dist/enterprise/users/EnterpriseUser.d.ts +2 -3
- package/dist/enterprise/users/EnterpriseUser.js +3 -5
- package/dist/enterprise/users/EnterpriseUser.js.map +1 -1
- package/dist/enterprise/users/EnterpriseUsersResource.d.ts +2 -3
- package/dist/enterprise/users/EnterpriseUsersResource.js +4 -7
- package/dist/enterprise/users/EnterpriseUsersResource.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -1
- package/dist/oss/catalog/CatalogReferences/FolderCatalogReference.d.ts +1 -1
- package/dist/oss/catalog/CatalogReferences/HomeCatalogReference.d.ts +1 -1
- package/dist/oss/catalog/CatalogReferences/SourceCatalogReference.d.ts +1 -1
- package/dist/oss/catalog/CatalogReferences/SpaceCatalogReference.d.ts +1 -1
- package/dist/oss/catalog/CatalogReferences/utils/catalogChildren.js +1 -0
- package/dist/oss/catalog/CatalogReferences/utils/catalogChildren.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/utils/getTags.d.ts +1 -2
- package/dist/oss/catalog/CatalogReferences/utils/getTags.js +2 -4
- package/dist/oss/catalog/CatalogReferences/utils/getTags.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/utils/getWiki.d.ts +1 -2
- package/dist/oss/catalog/CatalogReferences/utils/getWiki.js +2 -4
- package/dist/oss/catalog/CatalogReferences/utils/getWiki.js.map +1 -1
- package/dist/oss/catalog/CatalogResource.js +1 -0
- package/dist/oss/catalog/CatalogResource.js.map +1 -1
- package/dist/oss/catalog/CatalogTags.d.ts +2 -6
- package/dist/oss/catalog/CatalogTags.js +8 -13
- package/dist/oss/catalog/CatalogTags.js.map +1 -1
- package/dist/oss/catalog/CatalogWiki.d.ts +2 -6
- package/dist/oss/catalog/CatalogWiki.js +8 -13
- package/dist/oss/catalog/CatalogWiki.js.map +1 -1
- package/dist/oss/catalog/catalogErrors.d.ts +3 -14
- package/dist/oss/catalog/catalogErrors.js +9 -12
- package/dist/oss/catalog/catalogErrors.js.map +1 -1
- package/dist/oss/catalog/catalogRetrieve.d.ts +3 -2
- package/dist/oss/catalog/catalogRetrieve.js +6 -2
- package/dist/oss/catalog/catalogRetrieve.js.map +1 -1
- package/dist/oss/index.d.ts +4 -7
- package/dist/oss/index.js +0 -1
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/jobs/Job.d.ts +3 -3
- package/dist/oss/jobs/Job.js +7 -9
- package/dist/oss/jobs/Job.js.map +1 -1
- package/dist/oss/jobs/JobsResource.d.ts +4 -5
- package/dist/oss/jobs/JobsResource.js +5 -7
- package/dist/oss/jobs/JobsResource.js.map +1 -1
- package/dist/oss/scripts/Script.d.ts +3 -22
- package/dist/oss/scripts/Script.js +12 -16
- package/dist/oss/scripts/Script.js.map +1 -1
- package/dist/oss/scripts/ScriptErrors.d.ts +6 -18
- package/dist/oss/scripts/ScriptErrors.js +10 -13
- package/dist/oss/scripts/ScriptErrors.js.map +1 -1
- package/dist/oss/scripts/ScriptsResource.d.ts +14 -6
- package/dist/oss/scripts/ScriptsResource.js +19 -21
- package/dist/oss/scripts/ScriptsResource.js.map +1 -1
- package/dist/oss/users/UsersResource.d.ts +2 -3
- package/dist/oss/users/UsersResource.js +4 -7
- package/dist/oss/users/UsersResource.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
import { Problem, ValidationProblem } from "../../common/Problem.js";
|
|
17
|
+
export const scriptNotFoundError = (id) => new Problem({
|
|
17
18
|
meta: {
|
|
18
19
|
provided: {
|
|
19
20
|
id,
|
|
@@ -22,16 +23,12 @@ export const scriptNotFoundError = (id) => ({
|
|
|
22
23
|
title: "The script could not be found or you do not have permission to view it",
|
|
23
24
|
type: "https://api.dremio.dev/problems/scripts/not-found",
|
|
24
25
|
});
|
|
25
|
-
export const duplicateScriptNameError = (name) => (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
],
|
|
34
|
-
title: "There was a problem validating the content of the request",
|
|
35
|
-
type: "https://api.dremio.dev/problems/validation-problem",
|
|
36
|
-
});
|
|
26
|
+
export const duplicateScriptNameError = (name) => new ValidationProblem([
|
|
27
|
+
{
|
|
28
|
+
detail: "A script with this name already exists",
|
|
29
|
+
pointer: "#/name",
|
|
30
|
+
type: "https://api.dremio.dev/problems/validation/field-conflict",
|
|
31
|
+
value: name,
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
37
34
|
//# sourceMappingURL=ScriptErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptErrors.js","sourceRoot":"","sources":["../../../src/oss/scripts/ScriptErrors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"ScriptErrors.js","sourceRoot":"","sources":["../../../src/oss/scripts/ScriptErrors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAU,EAAE,EAAE,CAChD,IAAI,OAAO,CAAC;IACV,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,EAAE;SACH;KACF;IACD,KAAK,EAAE,wEAAwE;IAC/E,IAAI,EAAE,mDAAmD;CAC1D,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE,CACvD,IAAI,iBAAiB,CAAC;IACpB;QACE,MAAM,EAAE,wCAAwC;QAChD,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,2DAA2D;QACjE,KAAK,EAAE,IAAI;KACZ;CACF,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 { Problem, ValidationProblem } from \"../../common/Problem.js\";\n\nexport const scriptNotFoundError = (id: string) =>\n new Problem({\n meta: {\n provided: {\n id,\n },\n },\n title: \"The script could not be found or you do not have permission to view it\",\n type: \"https://api.dremio.dev/problems/scripts/not-found\",\n });\n\nexport const duplicateScriptNameError = (name: string) =>\n new ValidationProblem([\n {\n detail: \"A script with this name already exists\",\n pointer: \"#/name\",\n type: \"https://api.dremio.dev/problems/validation/field-conflict\",\n value: name,\n },\n ]);\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ResourceConfig, SonarV3Config } from "../../common/Config.ts";
|
|
2
2
|
import { Script, type ScriptEntity } from "./Script.ts";
|
|
3
|
-
import { Ok, Err } from "ts-results-es";
|
|
4
3
|
import type { Query } from "../../common/Query.ts";
|
|
5
4
|
import type { SignalParam } from "../../common/Params.ts";
|
|
5
|
+
import { Problem } from "../../common/Problem.ts";
|
|
6
6
|
export declare class ScriptsResource {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(config: ResourceConfig & SonarV3Config);
|
|
@@ -10,15 +10,23 @@ export declare class ScriptsResource {
|
|
|
10
10
|
list(): {
|
|
11
11
|
data({ signal }?: SignalParam): AsyncGenerator<Script, void, unknown>;
|
|
12
12
|
};
|
|
13
|
-
retrieve(id: string, { signal }?: SignalParam): Promise<
|
|
13
|
+
retrieve(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<Script, import("../index.ts").HttpError | Problem<"https://api.dremio.dev/problems/scripts/not-found", {
|
|
14
|
+
provided: {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
}>>>;
|
|
14
18
|
store(properties: {
|
|
15
19
|
name: string;
|
|
16
20
|
query: Query;
|
|
17
|
-
}): Promise<
|
|
21
|
+
}): Promise<import("ts-results-es").Result<Script, import("../../common/Problem.ts").ValidationProblem | import("../index.ts").HttpError>>;
|
|
18
22
|
}
|
|
19
|
-
export declare const listScripts: <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) => ({ signal }?: SignalParam) => Promise<S[]
|
|
20
|
-
export declare const retrieveScript: <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) => (id: string, { signal }?: SignalParam) => Promise<
|
|
23
|
+
export declare const listScripts: <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) => ({ signal }?: SignalParam) => Promise<import("ts-results-es").Result<S[], import("../index.ts").HttpError>>;
|
|
24
|
+
export declare const retrieveScript: <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) => (id: string, { signal }?: SignalParam) => Promise<import("ts-results-es").Result<S, import("../index.ts").HttpError | Problem<"https://api.dremio.dev/problems/scripts/not-found", {
|
|
25
|
+
provided: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
}>>>;
|
|
21
29
|
export declare const storeScript: <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) => (properties: {
|
|
22
30
|
name: string;
|
|
23
31
|
query: Query;
|
|
24
|
-
}) => Promise<
|
|
32
|
+
}) => Promise<import("ts-results-es").Result<S, import("../../common/Problem.ts").ValidationProblem | import("../index.ts").HttpError>>;
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Script, scriptEntityToProperties } from "./Script.js";
|
|
17
|
-
import { Ok, Err } from "ts-results-es";
|
|
18
|
-
import { HttpError } from "../../common/HttpError.js";
|
|
19
|
-
import { isProblem } from "../../common/Problem.js";
|
|
20
17
|
import { duplicateScriptNameError, scriptNotFoundError } from "./ScriptErrors.js";
|
|
18
|
+
import { Problem } from "../../common/Problem.js";
|
|
21
19
|
export class ScriptsResource {
|
|
22
20
|
#config;
|
|
23
21
|
constructor(config) {
|
|
@@ -30,7 +28,7 @@ export class ScriptsResource {
|
|
|
30
28
|
const l = listScripts(this.#config, this._scriptFromEntity.bind(this));
|
|
31
29
|
return {
|
|
32
30
|
async *data({ signal } = {}) {
|
|
33
|
-
yield* await l({ signal });
|
|
31
|
+
yield* (await l({ signal })).unwrap();
|
|
34
32
|
},
|
|
35
33
|
};
|
|
36
34
|
}
|
|
@@ -42,17 +40,17 @@ export class ScriptsResource {
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
export const listScripts = ({ sonarV3Request }, _scriptFromEntity) => ({ signal } = {}) => sonarV3Request("scripts?maxResults=1000", { signal })
|
|
45
|
-
.
|
|
46
|
-
.
|
|
43
|
+
.map((response) => response.json())
|
|
44
|
+
.map((response) => response.data.map((entity) => _scriptFromEntity(entity))).promise;
|
|
47
45
|
export const retrieveScript = ({ sonarV3Request }, _scriptFromEntity) => (id, { signal } = {}) => sonarV3Request(`scripts/${id}`, { signal })
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
.
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
46
|
+
.map((response) => response.json())
|
|
47
|
+
.map((entity) => _scriptFromEntity(entity))
|
|
48
|
+
.mapErr((err) => {
|
|
49
|
+
if (err.status === 404) {
|
|
50
|
+
return scriptNotFoundError(id);
|
|
53
51
|
}
|
|
54
|
-
return
|
|
55
|
-
});
|
|
52
|
+
return err;
|
|
53
|
+
}).promise;
|
|
56
54
|
export const storeScript = ({ sonarV3Request }, _scriptFromEntity) => (properties) => {
|
|
57
55
|
const { query, ...rest } = properties;
|
|
58
56
|
return sonarV3Request("scripts", {
|
|
@@ -67,14 +65,14 @@ export const storeScript = ({ sonarV3Request }, _scriptFromEntity) => (propertie
|
|
|
67
65
|
keepalive: true,
|
|
68
66
|
method: "POST",
|
|
69
67
|
})
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
.map((response) => response.json())
|
|
69
|
+
.map((entity) => _scriptFromEntity(entity))
|
|
70
|
+
.mapErr((err) => {
|
|
71
|
+
if (err.body instanceof Problem &&
|
|
72
|
+
err.body.detail?.includes("Cannot reuse the same script name")) {
|
|
73
|
+
return duplicateScriptNameError(properties.name);
|
|
76
74
|
}
|
|
77
|
-
return
|
|
78
|
-
});
|
|
75
|
+
return err;
|
|
76
|
+
}).promise;
|
|
79
77
|
};
|
|
80
78
|
//# sourceMappingURL=ScriptsResource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptsResource.js","sourceRoot":"","sources":["../../../src/oss/scripts/ScriptsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ScriptsResource.js","sourceRoot":"","sources":["../../../src/oss/scripts/ScriptsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAqB,MAAM,aAAa,CAAC;AAGlF,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,OAAO,eAAe;IAC1B,OAAO,CAAiC;IAExC,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;IAED,IAAI;QACF,MAAM,CAAC,GAAG,WAAW,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G,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,mCAAmC,CAAC,EAC9D,CAAC;YACD,OAAO,wBAAwB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC,OAAO,CAAC;AACf,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 { ResourceConfig, SonarV3Config } from \"../../common/Config.ts\";\nimport { Script, scriptEntityToProperties, type ScriptEntity } from \"./Script.ts\";\nimport type { Query } from \"../../common/Query.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { duplicateScriptNameError, scriptNotFoundError } from \"./ScriptErrors.ts\";\nimport { Problem } from \"../../common/Problem.ts\";\n\nexport class ScriptsResource {\n #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n _scriptFromEntity(entity: ScriptEntity) {\n return new Script(scriptEntityToProperties(entity), this.#config);\n }\n\n list() {\n const l = listScripts(this.#config, this._scriptFromEntity.bind(this));\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await l({ signal })).unwrap();\n },\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return retrieveScript(this.#config, this._scriptFromEntity.bind(this))(id, { signal });\n }\n\n store(properties: { name: string; query: Query }) {\n return storeScript(this.#config, this._scriptFromEntity.bind(this))(properties);\n }\n}\n\nexport const listScripts =\n <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) =>\n ({ signal }: SignalParam = {}) =>\n sonarV3Request(\"scripts?maxResults=1000\", { signal })\n .map((response) => response.json() as Promise<{ data: E[] }>)\n .map((response) => response.data.map((entity) => _scriptFromEntity(entity))).promise;\n\nexport const retrieveScript =\n <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) =>\n (id: string, { signal }: SignalParam = {}) =>\n sonarV3Request(`scripts/${id}`, { signal })\n .map((response) => response.json() as Promise<E>)\n .map((entity) => _scriptFromEntity(entity))\n .mapErr((err) => {\n if (err.status === 404) {\n return scriptNotFoundError(id);\n }\n return err;\n }).promise;\n\nexport const storeScript =\n <E, S>({ sonarV3Request }: SonarV3Config, _scriptFromEntity: (entity: E) => S) =>\n (properties: { name: string; query: Query }) => {\n const { query, ...rest } = properties;\n return sonarV3Request(\"scripts\", {\n body: JSON.stringify({\n ...rest,\n content: query.sql,\n context: query.context,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((response) => response.json() as Promise<E>)\n .map((entity) => _scriptFromEntity(entity))\n .mapErr((err) => {\n if (\n err.body instanceof Problem &&\n err.body.detail?.includes(\"Cannot reuse the same script name\")\n ) {\n return duplicateScriptNameError(properties.name);\n }\n\n return err;\n }).promise;\n };\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Err, Ok } from "ts-results-es";
|
|
2
1
|
import { User, type UserEntity } from "./User.ts";
|
|
3
2
|
import type { SonarV3Config } from "../../common/Config.ts";
|
|
4
3
|
import type { SignalParam } from "../../common/Params.ts";
|
|
@@ -6,6 +5,6 @@ export declare class UsersResource {
|
|
|
6
5
|
#private;
|
|
7
6
|
constructor(config: SonarV3Config);
|
|
8
7
|
_userFromEntity(entity: UserEntity): User;
|
|
9
|
-
retrieveById(id: string, { signal }?: SignalParam): Promise<
|
|
10
|
-
retrieveByName(name: string, { signal }?: SignalParam): Promise<
|
|
8
|
+
retrieveById(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<User, import("../index.ts").HttpError>>;
|
|
9
|
+
retrieveByName(name: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<User, import("../index.ts").HttpError>>;
|
|
11
10
|
}
|
|
@@ -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 { Err, Ok } from "ts-results-es";
|
|
17
16
|
import { User, userEntityToProperties } from "./User.js";
|
|
18
17
|
export class UsersResource {
|
|
19
18
|
#config;
|
|
@@ -26,16 +25,14 @@ export class UsersResource {
|
|
|
26
25
|
retrieveById(id, { signal } = {}) {
|
|
27
26
|
return this.#config
|
|
28
27
|
.sonarV3Request(`user/${id}`, { signal })
|
|
29
|
-
.
|
|
30
|
-
.
|
|
31
|
-
.catch((e) => Err(e));
|
|
28
|
+
.map((response) => response.json())
|
|
29
|
+
.map((entity) => this._userFromEntity(entity)).promise;
|
|
32
30
|
}
|
|
33
31
|
retrieveByName(name, { signal } = {}) {
|
|
34
32
|
return this.#config
|
|
35
33
|
.sonarV3Request(`user/by-name/${name}`, { signal })
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.catch((e) => Err(e));
|
|
34
|
+
.map((response) => response.json())
|
|
35
|
+
.map((entity) => this._userFromEntity(entity)).promise;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
//# sourceMappingURL=UsersResource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersResource.js","sourceRoot":"","sources":["../../../src/oss/users/UsersResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"UsersResource.js","sourceRoot":"","sources":["../../../src/oss/users/UsersResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAmB,MAAM,WAAW,CAAC;AAI1E,MAAM,OAAO,aAAa;IACxB,OAAO,CAAgB;IAEvB,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,OAAO,IAAI,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,YAAY,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QACnD,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aACxC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAyB,CAAC;aACzD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3D,CAAC;IAED,cAAc,CAAC,IAAY,EAAE,EAAE,MAAM,KAAkB,EAAE;QACvD,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,gBAAgB,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aAClD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAyB,CAAC;aACzD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3D,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 { User, userEntityToProperties, type UserEntity } from \"./User.ts\";\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport class UsersResource {\n #config: SonarV3Config;\n\n constructor(config: SonarV3Config) {\n this.#config = config;\n }\n\n _userFromEntity(entity: UserEntity) {\n return new User(userEntityToProperties(entity));\n }\n\n retrieveById(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`user/${id}`, { signal })\n .map((response) => response.json() as Promise<UserEntity>)\n .map((entity) => this._userFromEntity(entity)).promise;\n }\n\n retrieveByName(name: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`user/by-name/${name}`, { signal })\n .map((response) => response.json() as Promise<UserEntity>)\n .map((entity) => this._userFromEntity(entity)).promise;\n }\n}\n"]}
|