@dremio/js-sdk 0.21.0 → 0.23.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.
- package/dist/cloud/arctic/ArcticCatalog.d.ts +1 -1
- package/dist/cloud/arctic/ArcticCatalog.js +2 -4
- package/dist/cloud/arctic/ArcticCatalog.js.map +1 -1
- package/dist/cloud/interfaces.d.ts +1 -0
- package/dist/cloud/interfaces.js +1 -0
- package/dist/cloud/interfaces.js.map +1 -1
- package/dist/enterprise/Dremio.d.ts +5 -0
- package/dist/enterprise/Dremio.js +6 -0
- package/dist/enterprise/Dremio.js.map +1 -1
- package/dist/enterprise/Grantee.d.ts +8 -8
- package/dist/enterprise/Grantee.js +12 -1
- package/dist/enterprise/Grantee.js.map +1 -1
- package/dist/enterprise/grants/Grant.d.ts +13 -0
- package/dist/enterprise/grants/Grant.js +29 -0
- package/dist/enterprise/grants/Grant.js.map +1 -0
- package/dist/enterprise/grants/GrantsResource.d.ts +8 -0
- package/dist/enterprise/grants/GrantsResource.js +26 -0
- package/dist/enterprise/grants/GrantsResource.js.map +1 -0
- package/dist/enterprise/grants/createRetrieveGrants.d.ts +5 -0
- package/dist/enterprise/grants/createRetrieveGrants.js +39 -0
- package/dist/enterprise/grants/createRetrieveGrants.js.map +1 -0
- package/dist/enterprise/interfaces.d.ts +1 -0
- package/dist/enterprise/interfaces.js +1 -0
- package/dist/enterprise/interfaces.js.map +1 -1
- package/dist/enterprise/scripts/EnterpriseScript.d.ts +3 -6
- package/dist/enterprise/scripts/EnterpriseScript.js +4 -12
- package/dist/enterprise/scripts/EnterpriseScript.js.map +1 -1
- package/dist/enterprise/users/EnterpriseUser.d.ts +3 -2
- package/dist/enterprise/users/EnterpriseUser.js +5 -0
- package/dist/enterprise/users/EnterpriseUser.js.map +1 -1
- package/dist/oss/jobs/Job.d.ts +5 -4
- package/dist/oss/jobs/Job.js +6 -5
- package/dist/oss/jobs/Job.js.map +1 -1
- package/dist/oss/jobs/utils/JSONValue.d.ts +3 -0
- package/dist/oss/jobs/utils/JSONValue.js +17 -0
- package/dist/oss/jobs/utils/JSONValue.js.map +1 -0
- package/dist/oss/jobs/utils/JobResultsResponse.d.ts +2 -1
- package/dist/oss/jobs/utils/JobResultsResponse.js.map +1 -1
- package/dist/oss/jobs/utils/mapRowData.d.ts +4 -0
- package/dist/oss/jobs/utils/mapRowData.js +10 -2
- package/dist/oss/jobs/utils/mapRowData.js.map +1 -1
- package/dist/oss/jobs/utils/mapRowsToColumns.d.ts +2 -1
- package/dist/oss/jobs/utils/mapRowsToColumns.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UserGrantee } from "../../enterprise/Grantee.js";
|
|
2
2
|
export declare class ArcticCatalog implements ArcticCatalogProperties {
|
|
3
3
|
readonly createdAt: ArcticCatalogProperties["createdAt"];
|
|
4
4
|
readonly createdBy: ArcticCatalogProperties["createdBy"];
|
|
@@ -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 { UserGrantee } from "../../enterprise/Grantee.js";
|
|
16
17
|
export class ArcticCatalog {
|
|
17
18
|
createdAt;
|
|
18
19
|
createdBy;
|
|
@@ -38,9 +39,6 @@ export const arcticCatalogEntityToProperties = (entity) => ({
|
|
|
38
39
|
modifiedAt: new Date(entity.modifiedAt),
|
|
39
40
|
modifiedBy: entity.modifiedBy,
|
|
40
41
|
name: entity.name,
|
|
41
|
-
owner:
|
|
42
|
-
id: entity.ownerId,
|
|
43
|
-
type: "USER",
|
|
44
|
-
},
|
|
42
|
+
owner: new UserGrantee(entity.ownerId),
|
|
45
43
|
});
|
|
46
44
|
//# sourceMappingURL=ArcticCatalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArcticCatalog.js","sourceRoot":"","sources":["../../../src/cloud/arctic/ArcticCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"ArcticCatalog.js","sourceRoot":"","sources":["../../../src/cloud/arctic/ArcticCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,OAAO,aAAa;IACf,SAAS,CAAuC;IAChD,SAAS,CAAuC;IAChD,EAAE,CAAgC;IAClC,UAAU,CAAwC;IAClD,UAAU,CAAwC;IAClD,IAAI,CAAkC;IACtC,KAAK,CAAmC;IAEjD,YAAY,UAAmC;QAC7C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAChC,CAAC;CACF;AAiBD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,MAA2B,EAAE,EAAE,CAAC,CAAC;IAC/E,SAAS,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC,SAAS;IAC3B,EAAE,EAAE,MAAM,CAAC,EAAE;IACb,UAAU,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC,UAAU;IAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,KAAK,EAAE,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;CACvC,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 { UserGrantee } from \"../../enterprise/Grantee.js\";\n\nexport class ArcticCatalog implements ArcticCatalogProperties {\n readonly createdAt: ArcticCatalogProperties[\"createdAt\"];\n readonly createdBy: ArcticCatalogProperties[\"createdBy\"];\n readonly id: ArcticCatalogProperties[\"id\"];\n readonly modifiedAt: ArcticCatalogProperties[\"modifiedAt\"];\n readonly modifiedBy: ArcticCatalogProperties[\"modifiedBy\"];\n readonly name: ArcticCatalogProperties[\"name\"];\n readonly owner: ArcticCatalogProperties[\"owner\"];\n\n constructor(properties: ArcticCatalogProperties) {\n this.createdAt = properties.createdAt;\n this.createdBy = properties.createdBy;\n this.id = properties.id;\n this.modifiedAt = properties.modifiedAt;\n this.modifiedBy = properties.modifiedBy;\n this.name = properties.name;\n this.owner = properties.owner;\n }\n}\n\nexport type ArcticCatalogEntity = {\n id: string;\n name: string;\n ownerId: string;\n ownerName: string;\n createdBy: string;\n modifiedBy: string;\n createdAt: string;\n modifiedAt: string;\n state: \"ACTIVE\" | \"INACTIVE\";\n nessieEndpoint: string;\n};\n\ntype ArcticCatalogProperties = ReturnType<typeof arcticCatalogEntityToProperties>;\n\nexport const arcticCatalogEntityToProperties = (entity: ArcticCatalogEntity) => ({\n createdAt: new Date(entity.createdAt),\n createdBy: entity.createdBy,\n id: entity.id,\n modifiedAt: new Date(entity.modifiedAt),\n modifiedBy: entity.modifiedBy,\n name: entity.name,\n owner: new UserGrantee(entity.ownerId),\n});\n"]}
|
|
@@ -14,3 +14,4 @@ export type { Job, JobResultsSchema, Reflection, EnterpriseScript, ReflectionSum
|
|
|
14
14
|
export * from "../enterprise/catalog/CatalogObjects/index.ts";
|
|
15
15
|
export * from "../enterprise/catalog/CatalogReferences/index.ts";
|
|
16
16
|
export * from "../enterprise/catalog/catalogSearch/CatalogSearchResult.ts";
|
|
17
|
+
export * from "../enterprise/grants/Grant.ts";
|
package/dist/cloud/interfaces.js
CHANGED
|
@@ -16,4 +16,5 @@
|
|
|
16
16
|
export * from "../enterprise/catalog/CatalogObjects/index.js";
|
|
17
17
|
export * from "../enterprise/catalog/CatalogReferences/index.js";
|
|
18
18
|
export * from "../enterprise/catalog/catalogSearch/CatalogSearchResult.js";
|
|
19
|
+
export * from "../enterprise/grants/Grant.js";
|
|
19
20
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/cloud/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,4DAA4D,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 { ArcticCatalog } from \"./arctic/ArcticCatalog.ts\";\nimport type { CloudUser } from \"./users/CloudUser.ts\";\nimport type { Engine } from \"./engines/Engine.ts\";\nimport type { Project } from \"./projects/Project.ts\";\nimport type { Organization } from \"./organizations/Organization.ts\";\nimport type { Job, Reflection } from \"../oss/interfaces.ts\";\nimport type { EnterpriseScript } from \"../enterprise/scripts/EnterpriseScript.ts\";\nimport type { ReflectionSummary } from \"../enterprise/reflections/ReflectionSummary.ts\";\nimport type { Role } from \"../enterprise/roles/Role.ts\";\nimport type {\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n} from \"../oss/catalog/VersionReference.ts\";\nimport type { JobResultsSchema } from \"../oss/jobs/utils/JobResultsResponse.ts\";\n\nexport type { ArcticCatalog, CloudUser, Engine, Project };\nexport type {\n Job,\n JobResultsSchema,\n Reflection,\n EnterpriseScript,\n ReflectionSummary,\n Role,\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n Organization,\n};\nexport * from \"../enterprise/catalog/CatalogObjects/index.ts\";\nexport * from \"../enterprise/catalog/CatalogReferences/index.ts\";\nexport * from \"../enterprise/catalog/catalogSearch/CatalogSearchResult.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/cloud/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,+BAA+B,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 { ArcticCatalog } from \"./arctic/ArcticCatalog.ts\";\nimport type { CloudUser } from \"./users/CloudUser.ts\";\nimport type { Engine } from \"./engines/Engine.ts\";\nimport type { Project } from \"./projects/Project.ts\";\nimport type { Organization } from \"./organizations/Organization.ts\";\nimport type { Job, Reflection } from \"../oss/interfaces.ts\";\nimport type { EnterpriseScript } from \"../enterprise/scripts/EnterpriseScript.ts\";\nimport type { ReflectionSummary } from \"../enterprise/reflections/ReflectionSummary.ts\";\nimport type { Role } from \"../enterprise/roles/Role.ts\";\nimport type {\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n} from \"../oss/catalog/VersionReference.ts\";\nimport type { JobResultsSchema } from \"../oss/jobs/utils/JobResultsResponse.ts\";\n\nexport type { ArcticCatalog, CloudUser, Engine, Project };\nexport type {\n Job,\n JobResultsSchema,\n Reflection,\n EnterpriseScript,\n ReflectionSummary,\n Role,\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n Organization,\n};\nexport * from \"../enterprise/catalog/CatalogObjects/index.ts\";\nexport * from \"../enterprise/catalog/CatalogReferences/index.ts\";\nexport * from \"../enterprise/catalog/catalogSearch/CatalogSearchResult.ts\";\nexport * from \"../enterprise/grants/Grant.ts\";\n"]}
|
|
@@ -6,11 +6,16 @@ import { SqlResource } from "../oss/sql/SqlResource.js";
|
|
|
6
6
|
import { EnterpriseUsersResource } from "./users/EnterpriseUsersResource.js";
|
|
7
7
|
import { EnginesResource } from "./engines/EnginesResource.js";
|
|
8
8
|
import { RolesResource } from "./roles/RolesResource.js";
|
|
9
|
+
import { GrantsResource } from "./grants/GrantsResource.ts";
|
|
9
10
|
export declare class Dremio {
|
|
10
11
|
#private;
|
|
11
12
|
readonly catalog: EnterpriseCatalogResource;
|
|
12
13
|
readonly engines: EnginesResource;
|
|
13
14
|
readonly jobs: JobsResource;
|
|
15
|
+
/**
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
readonly _grants: GrantsResource;
|
|
14
19
|
readonly roles: RolesResource;
|
|
15
20
|
readonly scripts: EnterpriseScriptsResource;
|
|
16
21
|
readonly sql: SqlResource;
|
|
@@ -21,10 +21,15 @@ import { EnterpriseUsersResource } from "./users/EnterpriseUsersResource.js";
|
|
|
21
21
|
import { EnginesResource } from "./engines/EnginesResource.js";
|
|
22
22
|
import { RolesResource } from "./roles/RolesResource.js";
|
|
23
23
|
import { getResourceConfig } from "../oss/getResourceConfig.js";
|
|
24
|
+
import { GrantsResource } from "./grants/GrantsResource.js";
|
|
24
25
|
export class Dremio {
|
|
25
26
|
catalog;
|
|
26
27
|
engines;
|
|
27
28
|
jobs;
|
|
29
|
+
/**
|
|
30
|
+
* @experimental
|
|
31
|
+
*/
|
|
32
|
+
_grants;
|
|
28
33
|
roles;
|
|
29
34
|
scripts;
|
|
30
35
|
sql;
|
|
@@ -35,6 +40,7 @@ export class Dremio {
|
|
|
35
40
|
this.catalog = new EnterpriseCatalogResource(this.#resourceConfig);
|
|
36
41
|
this.engines = new EnginesResource(this.#resourceConfig);
|
|
37
42
|
this.jobs = new JobsResource(this.#resourceConfig);
|
|
43
|
+
this._grants = new GrantsResource(this.#resourceConfig);
|
|
38
44
|
this.roles = new RolesResource(this.#resourceConfig);
|
|
39
45
|
this.scripts = new EnterpriseScriptsResource(this.#resourceConfig);
|
|
40
46
|
this.sql = new SqlResource(this.#resourceConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dremio.js","sourceRoot":"","sources":["../../src/enterprise/Dremio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,i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CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnE,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,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 { Config } from \"../common/Config.ts\";\nimport { EnterpriseCatalogResource } from \"./catalog/EnterpriseCatalogResource.js\";\nimport { JobsResource } from \"../oss/jobs/JobsResource.js\";\nimport { EnterpriseScriptsResource } from \"./scripts/EnterpriseScriptsResource.js\";\nimport { SqlResource } from \"../oss/sql/SqlResource.js\";\nimport { EnterpriseUsersResource } from \"./users/EnterpriseUsersResource.js\";\nimport { EnginesResource } from \"./engines/EnginesResource.js\";\nimport { RolesResource } from \"./roles/RolesResource.js\";\nimport { getResourceConfig } from \"../oss/getResourceConfig.ts\";\nimport { GrantsResource } from \"./grants/GrantsResource.ts\";\n\nexport class Dremio {\n readonly catalog: EnterpriseCatalogResource;\n readonly engines: EnginesResource;\n readonly jobs: JobsResource;\n\n /**\n * @experimental\n */\n readonly _grants: GrantsResource;\n readonly roles: RolesResource;\n readonly scripts: EnterpriseScriptsResource;\n readonly sql: SqlResource;\n readonly users: EnterpriseUsersResource;\n readonly #resourceConfig: ReturnType<typeof getResourceConfig>;\n\n constructor(config: Config) {\n this.#resourceConfig = getResourceConfig(config);\n this.catalog = new EnterpriseCatalogResource(this.#resourceConfig);\n this.engines = new EnginesResource(this.#resourceConfig);\n this.jobs = new JobsResource(this.#resourceConfig);\n this._grants = new GrantsResource(this.#resourceConfig);\n this.roles = new RolesResource(this.#resourceConfig);\n this.scripts = new EnterpriseScriptsResource(this.#resourceConfig);\n this.sql = new SqlResource(this.#resourceConfig);\n this.users = new EnterpriseUsersResource(this.#resourceConfig);\n }\n\n get _resourceConfig() {\n return this.#resourceConfig;\n }\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
id: string;
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export
|
|
6
|
-
id: string;
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
export declare class RoleGrantee {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
constructor(id: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class UserGrantee {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
constructor(id: string);
|
|
8
|
+
}
|
|
9
9
|
export type Grantee = RoleGrantee | UserGrantee;
|
|
@@ -13,5 +13,16 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export {
|
|
16
|
+
export class RoleGrantee {
|
|
17
|
+
id;
|
|
18
|
+
constructor(id) {
|
|
19
|
+
this.id = id;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class UserGrantee {
|
|
23
|
+
id;
|
|
24
|
+
constructor(id) {
|
|
25
|
+
this.id = id;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
17
28
|
//# sourceMappingURL=Grantee.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grantee.js","sourceRoot":"","sources":["../../src/enterprise/Grantee.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\nexport
|
|
1
|
+
{"version":3,"file":"Grantee.js","sourceRoot":"","sources":["../../src/enterprise/Grantee.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,OAAO,WAAW;IACb,EAAE,CAAS;IAEpB,YAAY,EAAU;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AAED,MAAM,OAAO,WAAW;IACb,EAAE,CAAS;IAEpB,YAAY,EAAU;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,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\nexport class RoleGrantee {\n readonly id: string;\n\n constructor(id: string) {\n this.id = id;\n }\n}\n\nexport class UserGrantee {\n readonly id: string;\n\n constructor(id: string) {\n this.id = id;\n }\n}\n\nexport type Grantee = RoleGrantee | UserGrantee;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Grantee } from "../Grantee.ts";
|
|
2
|
+
export declare class Grant {
|
|
3
|
+
#private;
|
|
4
|
+
readonly grantee: Grantee;
|
|
5
|
+
readonly privileges: Set<string>;
|
|
6
|
+
readonly type: string;
|
|
7
|
+
constructor(properties: {
|
|
8
|
+
grantee: Grant["grantee"];
|
|
9
|
+
privileges: Grant["privileges"];
|
|
10
|
+
type: Grant["type"];
|
|
11
|
+
tag: string;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export class Grant {
|
|
17
|
+
grantee;
|
|
18
|
+
privileges;
|
|
19
|
+
type;
|
|
20
|
+
// eslint-disable-next-line no-unused-private-class-members
|
|
21
|
+
#tag;
|
|
22
|
+
constructor(properties) {
|
|
23
|
+
this.grantee = properties.grantee;
|
|
24
|
+
this.privileges = properties.privileges;
|
|
25
|
+
this.type = properties.type;
|
|
26
|
+
this.#tag = properties.tag;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Grant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Grant.js","sourceRoot":"","sources":["../../../src/enterprise/grants/Grant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,OAAO,KAAK;IACP,OAAO,CAAU;IACjB,UAAU,CAAc;IACxB,IAAI,CAAS;IACtB,2DAA2D;IAClD,IAAI,CAAS;IAEtB,YAAY,UAKX;QACC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;IAC7B,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 { Grantee } from \"../Grantee.ts\";\n\nexport class Grant {\n readonly grantee: Grantee;\n readonly privileges: Set<string>;\n readonly type: string;\n // eslint-disable-next-line no-unused-private-class-members\n readonly #tag: string;\n\n constructor(properties: {\n grantee: Grant[\"grantee\"];\n privileges: Grant[\"privileges\"];\n type: Grant[\"type\"];\n tag: string;\n }) {\n this.grantee = properties.grantee;\n this.privileges = properties.privileges;\n this.type = properties.type;\n this.#tag = properties.tag;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResourceConfig, SonarV3Config } from "../../common/Config.ts";
|
|
2
|
+
import type { SignalParam } from "../../common/Params.ts";
|
|
3
|
+
import type { Grantee } from "../Grantee.ts";
|
|
4
|
+
export declare class GrantsResource {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: ResourceConfig & SonarV3Config);
|
|
7
|
+
retrieve(grantee: Grantee, { signal }?: SignalParam): import("ts-results-es").AsyncResult<import("./Grant.ts").Grant[], import("../index.ts").HttpError>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { createRetrieveGrants } from "./createRetrieveGrants.js";
|
|
17
|
+
export class GrantsResource {
|
|
18
|
+
#config;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.#config = config;
|
|
21
|
+
}
|
|
22
|
+
retrieve(grantee, { signal } = {}) {
|
|
23
|
+
return createRetrieveGrants(this.#config)(grantee, { signal });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=GrantsResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrantsResource.js","sourceRoot":"","sources":["../../../src/enterprise/grants/GrantsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,cAAc;IAChB,OAAO,CAAiC;IAEjD,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,QAAQ,CAAC,OAAgB,EAAE,EAAE,MAAM,KAAkB,EAAE;QACrD,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,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 type { Grantee } from \"../Grantee.ts\";\nimport { createRetrieveGrants } from \"./createRetrieveGrants.ts\";\n\nexport class GrantsResource {\n readonly #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n retrieve(grantee: Grantee, { signal }: SignalParam = {}) {\n return createRetrieveGrants(this.#config)(grantee, { signal });\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SonarV3Config } from "../../common/Config.ts";
|
|
2
|
+
import type { SignalParam } from "../../common/Params.ts";
|
|
3
|
+
import { type Grantee } from "../Grantee.ts";
|
|
4
|
+
import { Grant } from "./Grant.ts";
|
|
5
|
+
export declare function createRetrieveGrants(config: SonarV3Config): (grantee: Grantee, { signal }?: SignalParam) => import("ts-results-es").AsyncResult<Grant[], import("../index.ts").HttpError>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { RoleGrantee, UserGrantee } from "../Grantee.js";
|
|
17
|
+
import { Grant } from "./Grant.js";
|
|
18
|
+
export function createRetrieveGrants(config) {
|
|
19
|
+
return function retrieveGrants(grantee, { signal } = {}) {
|
|
20
|
+
return config
|
|
21
|
+
.sonarV3Request(`grant/${getRoleType(grantee)}/${grantee.id}`, {
|
|
22
|
+
headers: {
|
|
23
|
+
Accept: "application/json",
|
|
24
|
+
},
|
|
25
|
+
signal,
|
|
26
|
+
})
|
|
27
|
+
.map((res) => res.json())
|
|
28
|
+
.map((response) => response.grants.map((entity) => new Grant({
|
|
29
|
+
grantee: entity.granteeType === "ROLE"
|
|
30
|
+
? new RoleGrantee(entity.id)
|
|
31
|
+
: new UserGrantee(entity.id),
|
|
32
|
+
privileges: new Set(entity.privileges),
|
|
33
|
+
tag: entity.tag,
|
|
34
|
+
type: entity.type,
|
|
35
|
+
})));
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const getRoleType = (grantee) => (grantee instanceof UserGrantee ? "user" : "role");
|
|
39
|
+
//# sourceMappingURL=createRetrieveGrants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRetrieveGrants.js","sourceRoot":"","sources":["../../../src/enterprise/grants/createRetrieveGrants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,OAAO,SAAS,cAAc,CAAC,OAAgB,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC3E,OAAO,MAAM;aACV,cAAc,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE;YAC7D,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAwC,CAAC;aAC9D,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,QAAQ,CAAC,MAAM,CAAC,GAAG,CACjB,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,KAAK,CAAC;YACR,OAAO,EACL,MAAM,CAAC,WAAW,KAAK,MAAM;gBAC3B,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5B,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,UAAU,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;YACtC,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CACL,CACF,CAAC;IACN,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,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 { SonarV3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { RoleGrantee, UserGrantee, type Grantee } from \"../Grantee.ts\";\nimport { Grant } from \"./Grant.ts\";\n\nexport function createRetrieveGrants(config: SonarV3Config) {\n return function retrieveGrants(grantee: Grantee, { signal }: SignalParam = {}) {\n return config\n .sonarV3Request(`grant/${getRoleType(grantee)}/${grantee.id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<{ grants: GrantEntity[] }>)\n .map((response) =>\n response.grants.map(\n (entity) =>\n new Grant({\n grantee:\n entity.granteeType === \"ROLE\"\n ? new RoleGrantee(entity.id)\n : new UserGrantee(entity.id),\n privileges: new Set(entity.privileges),\n tag: entity.tag,\n type: entity.type,\n }),\n ),\n );\n };\n}\n\nconst getRoleType = (grantee: Grantee) => (grantee instanceof UserGrantee ? \"user\" : \"role\");\n\ntype GrantEntity = {\n privileges: string[];\n granteeType: \"USER\" | \"ROLE\";\n id: string;\n tag: string;\n type: string;\n};\n"]}
|
|
@@ -14,3 +14,4 @@ export * from "./Ownable.ts";
|
|
|
14
14
|
export * from "./Grantee.ts";
|
|
15
15
|
export type { Engine, EnterpriseCatalogObject, EnterpriseCatalogReference, EnterpriseScript, EnterpriseUser, Job, JobResultsSchema, Reflection, ReflectionSummary, Role, BranchHeadVersionReference, BareCommitVersionReference, TagVersionReference, VersionReference, };
|
|
16
16
|
export * from "./catalog/catalogSearch/CatalogSearchResult.ts";
|
|
17
|
+
export * from "./grants/Grant.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/enterprise/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAiB7B,cAAc,gDAAgD,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 { Engine } from \"./engines/Engine.ts\";\nimport type { Job, Reflection } from \"../oss/interfaces.ts\";\nimport type { EnterpriseCatalogObject } from \"./catalog/CatalogObjects/index.ts\";\nimport type { EnterpriseCatalogReference } from \"./catalog/CatalogReferences/index.ts\";\nimport type { EnterpriseScript } from \"./scripts/EnterpriseScript.ts\";\nimport type { EnterpriseUser } from \"./users/EnterpriseUser.ts\";\nimport type { ReflectionSummary } from \"./reflections/ReflectionSummary.ts\";\nimport type { Role } from \"./roles/Role.ts\";\nimport type {\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n} from \"../oss/catalog/VersionReference.ts\";\nimport type { JobResultsSchema } from \"../oss/jobs/utils/JobResultsResponse.ts\";\nexport * from \"./catalog/CatalogObjects/index.ts\";\nexport * from \"./catalog/CatalogReferences/index.ts\";\nexport * from \"./Ownable.ts\";\nexport * from \"./Grantee.ts\";\nexport type {\n Engine,\n EnterpriseCatalogObject,\n EnterpriseCatalogReference,\n EnterpriseScript,\n EnterpriseUser,\n Job,\n JobResultsSchema,\n Reflection,\n ReflectionSummary,\n Role,\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n};\nexport * from \"./catalog/catalogSearch/CatalogSearchResult.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/enterprise/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAiB7B,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mBAAmB,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 { Engine } from \"./engines/Engine.ts\";\nimport type { Job, Reflection } from \"../oss/interfaces.ts\";\nimport type { EnterpriseCatalogObject } from \"./catalog/CatalogObjects/index.ts\";\nimport type { EnterpriseCatalogReference } from \"./catalog/CatalogReferences/index.ts\";\nimport type { EnterpriseScript } from \"./scripts/EnterpriseScript.ts\";\nimport type { EnterpriseUser } from \"./users/EnterpriseUser.ts\";\nimport type { ReflectionSummary } from \"./reflections/ReflectionSummary.ts\";\nimport type { Role } from \"./roles/Role.ts\";\nimport type {\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n} from \"../oss/catalog/VersionReference.ts\";\nimport type { JobResultsSchema } from \"../oss/jobs/utils/JobResultsResponse.ts\";\nexport * from \"./catalog/CatalogObjects/index.ts\";\nexport * from \"./catalog/CatalogReferences/index.ts\";\nexport * from \"./Ownable.ts\";\nexport * from \"./Grantee.ts\";\nexport type {\n Engine,\n EnterpriseCatalogObject,\n EnterpriseCatalogReference,\n EnterpriseScript,\n EnterpriseUser,\n Job,\n JobResultsSchema,\n Reflection,\n ReflectionSummary,\n Role,\n BranchHeadVersionReference,\n BareCommitVersionReference,\n TagVersionReference,\n VersionReference,\n};\nexport * from \"./catalog/catalogSearch/CatalogSearchResult.ts\";\nexport * from \"./grants/Grant.ts\";\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SonarV3Config } from "../../common/Config.ts";
|
|
2
|
-
import
|
|
2
|
+
import { RoleGrantee, UserGrantee } from "../Grantee.js";
|
|
3
3
|
import type { Ownable } from "../Ownable.ts";
|
|
4
4
|
import { Script, type ScriptEntity, type ScriptPatchableProperties } from "../../oss/scripts/Script.ts";
|
|
5
5
|
import type { SignalParam } from "../../common/Params.ts";
|
|
@@ -7,13 +7,10 @@ export declare class EnterpriseScript extends Script implements Ownable {
|
|
|
7
7
|
#private;
|
|
8
8
|
readonly owner: UserGrantee;
|
|
9
9
|
constructor(properties: EnterpriseScriptProperties, config: SonarV3Config);
|
|
10
|
-
grants({ signal }?: SignalParam): Promise<import("ts-results-es").Result<
|
|
10
|
+
grants({ signal }?: SignalParam): Promise<import("ts-results-es").Result<{
|
|
11
11
|
grantee: RoleGrantee;
|
|
12
12
|
privileges: Set<ScriptPrivileges>;
|
|
13
|
-
}
|
|
14
|
-
grantee: UserGrantee;
|
|
15
|
-
privileges: Set<ScriptPrivileges>;
|
|
16
|
-
})[], import("../index.ts").HttpError>>;
|
|
13
|
+
}[], import("../index.ts").HttpError>>;
|
|
17
14
|
save(properties: ScriptPatchableProperties & {
|
|
18
15
|
owner?: UserGrantee;
|
|
19
16
|
}): Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").ValidationProblem | import("../index.ts").HttpError>>;
|
|
@@ -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 { RoleGrantee, UserGrantee } from "../Grantee.js";
|
|
16
17
|
import { createScriptPatchedFields, saveScript, Script, scriptEntityToProperties, } from "../../oss/scripts/Script.js";
|
|
17
18
|
export class EnterpriseScript extends Script {
|
|
18
19
|
owner;
|
|
@@ -28,17 +29,11 @@ export class EnterpriseScript extends Script {
|
|
|
28
29
|
.map((res) => res.json())
|
|
29
30
|
.map((entity) => [
|
|
30
31
|
...entity.roles.map((grant) => ({
|
|
31
|
-
grantee:
|
|
32
|
-
id: grant.granteeId,
|
|
33
|
-
type: "ROLE",
|
|
34
|
-
},
|
|
32
|
+
grantee: new RoleGrantee(grant.granteeId),
|
|
35
33
|
privileges: new Set(grant.privileges),
|
|
36
34
|
})),
|
|
37
35
|
...entity.users.map((grant) => ({
|
|
38
|
-
grantee:
|
|
39
|
-
id: grant.granteeId,
|
|
40
|
-
type: "USER",
|
|
41
|
-
},
|
|
36
|
+
grantee: new UserGrantee(grant.granteeId),
|
|
42
37
|
privileges: new Set(grant.privileges),
|
|
43
38
|
})),
|
|
44
39
|
]).promise;
|
|
@@ -52,9 +47,6 @@ export class EnterpriseScript extends Script {
|
|
|
52
47
|
}
|
|
53
48
|
export const enterpriseScriptEntityToProperties = (entity) => ({
|
|
54
49
|
...scriptEntityToProperties(entity),
|
|
55
|
-
owner:
|
|
56
|
-
id: entity.owner,
|
|
57
|
-
type: "USER",
|
|
58
|
-
},
|
|
50
|
+
owner: new UserGrantee(entity.owner),
|
|
59
51
|
});
|
|
60
52
|
//# sourceMappingURL=EnterpriseScript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnterpriseScript.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"EnterpriseScript.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,MAAM,EACN,wBAAwB,GAGzB,MAAM,6BAA6B,CAAC;AAIrC,MAAM,OAAO,g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U,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;SACxD,CAAC,CAAC,GAAG,CACJ,CAAC,KAA6B,EAAE,EAAE,CAChC,IAAI,gBAAgB,CAAC,kCAAkC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAChF,CAAC,OAAO,CAAC;IACZ,CAAC;CACF;AAMD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,MAA8B,EAAE,EAAE,CAAC,CAAC;IACrF,GAAG,wBAAwB,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,IAAI,WAAW,CAAC,MAAM,CAAC,KAAe,CAAC;CAC/C,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 { SonarV3Config } from \"../../common/Config.ts\";\nimport { RoleGrantee, UserGrantee } from \"../Grantee.js\";\nimport type { Ownable } from \"../Ownable.ts\";\nimport {\n createScriptPatchedFields,\n saveScript,\n Script,\n scriptEntityToProperties,\n type ScriptEntity,\n type ScriptPatchableProperties,\n} from \"../../oss/scripts/Script.ts\";\n\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport class EnterpriseScript extends Script implements Ownable {\n readonly owner: UserGrantee;\n #config: SonarV3Config;\n\n constructor(properties: EnterpriseScriptProperties, config: SonarV3Config) {\n super(properties, config);\n this.owner = properties.owner;\n this.#config = config;\n }\n\n grants({ signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`scripts/${this.id}/grants`, { signal })\n .map((res) => res.json())\n .map(\n (entity: {\n roles: { granteeId: string; privileges: ScriptPrivileges[] }[];\n users: { granteeId: string; privileges: ScriptPrivileges[] }[];\n }) => [\n ...entity.roles.map((grant) => ({\n grantee: new RoleGrantee(grant.granteeId),\n privileges: new Set(grant.privileges),\n })),\n ...entity.users.map((grant) => ({\n grantee: new UserGrantee(grant.granteeId),\n privileges: new Set(grant.privileges),\n })),\n ],\n ).promise;\n }\n\n override async save(properties: ScriptPatchableProperties & { owner?: UserGrantee }) {\n return saveScript(\n this.id,\n this.#config,\n )({\n ...createScriptPatchedFields(properties),\n ...(properties.owner && { owner: properties.owner.id }),\n }).map(\n (value: EnterpriseScriptEntity) =>\n new EnterpriseScript(enterpriseScriptEntityToProperties(value), this.#config),\n ).promise;\n }\n}\n\nexport type EnterpriseScriptProperties = ReturnType<typeof enterpriseScriptEntityToProperties>;\n\nexport type EnterpriseScriptEntity = ScriptEntity & { owner?: string };\n\nexport const enterpriseScriptEntityToProperties = (entity: EnterpriseScriptEntity) => ({\n ...scriptEntityToProperties(entity),\n owner: new UserGrantee(entity.owner as string),\n});\n\ntype ScriptPrivileges = \"DELETE\" | \"MANAGE_GRANTS\" | \"MODIFY\" | \"VIEW\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { V3Config } from "../../common/Config.ts";
|
|
1
|
+
import type { SonarV3Config, V3Config } from "../../common/Config.ts";
|
|
2
2
|
import type { SignalParam } from "../../common/Params.ts";
|
|
3
3
|
import { User, type UserEntity, type UserPatchableProperties } from "../../oss/users/User.ts";
|
|
4
4
|
import type { RoleReference } from "../roles/Role.ts";
|
|
@@ -6,8 +6,9 @@ export declare class EnterpriseUser extends User {
|
|
|
6
6
|
#private;
|
|
7
7
|
roles: RoleReference[];
|
|
8
8
|
source: string;
|
|
9
|
-
constructor(properties: EnterpriseUserProperties, config: V3Config);
|
|
9
|
+
constructor(properties: EnterpriseUserProperties, config: V3Config & SonarV3Config);
|
|
10
10
|
save(properties: EnterpriseUserPatchableProperties): import("ts-results-es").AsyncResult<EnterpriseUser, import("../index.ts").HttpError>;
|
|
11
|
+
grants({ signal }?: SignalParam): import("ts-results-es").AsyncResult<import("../interfaces.ts").Grant[], import("../index.ts").HttpError>;
|
|
11
12
|
tokens({ signal }?: SignalParam): Promise<import("ts-results-es").Result<{
|
|
12
13
|
createdAt: Date;
|
|
13
14
|
expiresAt: Date;
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { User, userEntityToProperties, } from "../../oss/users/User.js";
|
|
17
|
+
import { createRetrieveGrants } from "../grants/createRetrieveGrants.js";
|
|
18
|
+
import { UserGrantee } from "../Grantee.js";
|
|
17
19
|
export class EnterpriseUser extends User {
|
|
18
20
|
#config;
|
|
19
21
|
#tag;
|
|
@@ -46,6 +48,9 @@ export class EnterpriseUser extends User {
|
|
|
46
48
|
.map((res) => res.json())
|
|
47
49
|
.map((entity) => new EnterpriseUser(enterpriseUserEntityToProperties(entity), this.#config));
|
|
48
50
|
}
|
|
51
|
+
grants({ signal } = {}) {
|
|
52
|
+
return createRetrieveGrants(this.#config)(new UserGrantee(this.id), { signal });
|
|
53
|
+
}
|
|
49
54
|
tokens({ signal } = {}) {
|
|
50
55
|
return this.#config
|
|
51
56
|
.v3Request(`user/${this.id}/token`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnterpriseUser.js","sourceRoot":"","sources":["../../../src/enterprise/users/EnterpriseUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EACL,IAAI,EACJ,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"EnterpriseUser.js","sourceRoot":"","sources":["../../../src/enterprise/users/EnterpriseUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EACL,IAAI,EACJ,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAA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AC;IAED,MAAM,CAAC,EAAE,MAAM,KAAkB,EAAE;QACjC,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,CAAC,EAAE,MAAM,KAAkB,EAAE;QACjC,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,QAAQ,IAAI,CAAC,EAAE,QAAQ,EAAE;YAClC,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;YACvC,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAiC,CAAC;aACvD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC5B,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YACpC,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YACpC,EAAE,EAAE,KAAK,CAAC,GAAG;YACb,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,CACJ,CAAC,OAAO,CAAC;IACd,CAAC;CACF;AASD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,MAA4B,EAAE,EAAE,CAAC,CAAC;IACjF,GAAG,sBAAsB,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,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 { SonarV3Config, V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport {\n User,\n userEntityToProperties,\n type UserEntity,\n type UserPatchableProperties,\n type UserProperties,\n} from \"../../oss/users/User.ts\";\nimport type { RoleReference } from \"../roles/Role.ts\";\nimport { createRetrieveGrants } from \"../grants/createRetrieveGrants.ts\";\nimport { UserGrantee } from \"../Grantee.ts\";\n\ntype UserTokensResponse = {\n data: {\n tid: string;\n uid: string;\n label: string;\n createdAt: string;\n expiresAt: string;\n }[];\n};\n\nexport class EnterpriseUser extends User {\n #config: V3Config & SonarV3Config;\n #tag: UserProperties[\"tag\"];\n\n roles: RoleReference[];\n source: string;\n\n constructor(properties: EnterpriseUserProperties, config: V3Config & SonarV3Config) {\n super(properties, config);\n this.#config = config;\n this.roles = properties.roles;\n this.source = properties.source;\n this.#tag = properties.tag;\n }\n\n override save(properties: EnterpriseUserPatchableProperties) {\n return this.#config\n .v3Request(`user/${this.id}`, {\n body: JSON.stringify({\n firstName: properties.givenName ?? this.givenName,\n id: this.id,\n lastName: properties.familyName ?? this.familyName,\n name: this.username,\n tag: this.#tag,\n }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"PUT\",\n })\n .map((res) => res.json())\n .map(\n (entity: EnterpriseUserEntity) =>\n new EnterpriseUser(enterpriseUserEntityToProperties(entity), this.#config),\n );\n }\n\n grants({ signal }: SignalParam = {}) {\n return createRetrieveGrants(this.#config)(new UserGrantee(this.id), { signal });\n }\n\n tokens({ signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`user/${this.id}/token`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<UserTokensResponse>)\n .map((response) =>\n response.data.map((token) => ({\n createdAt: new Date(token.createdAt),\n expiresAt: new Date(token.expiresAt),\n id: token.tid,\n label: token.label,\n })),\n ).promise;\n }\n}\n\nexport type EnterpriseUserEntity = UserEntity & {\n roles: RoleReference[];\n source: string;\n};\n\nexport type EnterpriseUserPatchableProperties = UserPatchableProperties & {};\n\nexport const enterpriseUserEntityToProperties = (entity: EnterpriseUserEntity) => ({\n ...userEntityToProperties(entity),\n roles: entity.roles,\n source: entity.source,\n});\n\nexport type EnterpriseUserProperties = ReturnType<typeof enterpriseUserEntityToProperties>;\n"]}
|
package/dist/oss/jobs/Job.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SonarV3Config } from "../../common/Config.ts";
|
|
2
2
|
import { Err, Ok, Result } from "ts-results-es";
|
|
3
3
|
import { type Observable } from "rxjs";
|
|
4
|
+
import { type MappedFieldValue } from "./utils/mapRowData.ts";
|
|
4
5
|
import type { SignalParam } from "../../common/Params.ts";
|
|
5
6
|
import type { JobProperties } from "./utils/jobEntityToProperties.ts";
|
|
6
7
|
import type { HttpError } from "../../common/HttpError.ts";
|
|
@@ -22,14 +23,14 @@ export declare class Job {
|
|
|
22
23
|
constructor(properties: JobProperties, config: SonarV3Config, observe: (id: string) => Observable<Result<Job, HttpError>>);
|
|
23
24
|
get settled(): boolean;
|
|
24
25
|
get results(): {
|
|
25
|
-
jsonBatches: <T extends Record<string,
|
|
26
|
+
jsonBatches: <T extends Record<string, MappedFieldValue> = Record<string, string | number | bigint | boolean | import("temporal-polyfill").Temporal.PlainDateTime | import("temporal-polyfill").Temporal.PlainDate | import("temporal-polyfill").Temporal.PlainTime | null>>(args?: {
|
|
26
27
|
limit?: number;
|
|
27
28
|
offset?: number;
|
|
28
29
|
}, { signal }?: SignalParam) => AsyncGenerator<{
|
|
29
|
-
readonly columns: Record<
|
|
30
|
+
readonly columns: Record<string, unknown[] | Float64Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Int32Array<ArrayBuffer>>;
|
|
30
31
|
readonly rows: T[];
|
|
31
32
|
readonly schema: {
|
|
32
|
-
fields: import("./utils/JobResultsResponse.ts").JobResultsSchema<Extract<keyof T, string>>;
|
|
33
|
+
readonly fields: import("./utils/JobResultsResponse.ts").JobResultsSchema<Extract<keyof T, string>>;
|
|
33
34
|
};
|
|
34
35
|
readonly totalRows: number;
|
|
35
36
|
}, void, unknown>;
|
|
@@ -37,7 +38,7 @@ export declare class Job {
|
|
|
37
38
|
schema: import("./utils/JobResultsResponse.ts").JobResultsSchema<string>;
|
|
38
39
|
totalRows: number;
|
|
39
40
|
}, HttpError>>;
|
|
40
|
-
slice: <T extends Record<string,
|
|
41
|
+
slice: <T extends Record<string, MappedFieldValue> = Record<string, string | number | bigint | boolean | import("temporal-polyfill").Temporal.PlainDateTime | import("temporal-polyfill").Temporal.PlainDate | import("temporal-polyfill").Temporal.PlainTime | null>>(start?: number, end?: number, { signal }?: SignalParam) => Promise<Ok<T[]> | Err<unknown>>;
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* @returns A `Job` instance once it's reached a settled state
|
package/dist/oss/jobs/Job.js
CHANGED
|
@@ -105,18 +105,19 @@ export class Job {
|
|
|
105
105
|
const batch_size = Math.min(MAX_BATCH_SIZE, stopAfterOffset - offset);
|
|
106
106
|
const batch = (await this.#config
|
|
107
107
|
.sonarV3Request(`job/${this.id}/results?offset=${offset}&limit=${batch_size}`, { signal })
|
|
108
|
-
.map((res) => res.json())
|
|
108
|
+
.map((res) => res.json())
|
|
109
|
+
.promise).unwrap();
|
|
109
110
|
offset += batch.rows.length;
|
|
110
111
|
hasMore = batch.rows.length === batch_size;
|
|
111
112
|
if (batch.rows.length) {
|
|
112
|
-
const
|
|
113
|
-
mapRowData(batch.rows,
|
|
113
|
+
const batchT = batch;
|
|
114
|
+
mapRowData(batch.rows, batchT.schema);
|
|
114
115
|
yield {
|
|
115
116
|
get columns() {
|
|
116
117
|
return mapRowsToColumns(batch);
|
|
117
118
|
},
|
|
118
|
-
rows:
|
|
119
|
-
schema,
|
|
119
|
+
rows: batchT.rows,
|
|
120
|
+
schema: { fields: batchT.schema },
|
|
120
121
|
totalRows: batch.rowCount,
|
|
121
122
|
};
|
|
122
123
|
}
|
package/dist/oss/jobs/Job.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Job.js","sourceRoot":"","sources":["../../../src/oss/jobs/Job.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAmB,MAAM,MAAM,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKnD,MAAM,OAAO,GAAG;IACL,YAAY,CAAgC;IAC5C,kBAAkB,CAAsC;IACxD,YAAY,CAAU;IACtB,OAAO,CAA2B;IAClC,EAAE,CAAsB;IACxB,OAAO,CAA2B;IAClC,SAAS,CAA6B;IACtC,yBAAyB,CAA6C;IACtE,2BAA2B,CAA+C;IAC1E,QAAQ,CAA4B;IACpC,SAAS,CAA6B;IACtC,KAAK,CAAyB;IAEvB,QAAQ,CAAkB;IAC1C,OAAO,CAAgB;IAEvB,YACE,UAAyB,EACzB,MAAqB,EACrB,OAA2D;QAE3D,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS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,CAAC,QAAQ;SAC7B,CAAC,CAAC,CAAC,OAAO,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,MAAM,CACV,QAAgB,CAAC,EACjB,MAAc,QAAQ,EACtB,EAAE,MAAM,KAAkB,EAAE;QAE5B,IAAI,CAAC;YACH,MAAM,IAAI,GAAQ,EAAE,CAAC;YACrB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CACzC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EACrC,EAAE,MAAM,EAAE,CACX,EAAE,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,SAAS,EAAE;YACvC,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,MAAM;SACf,CAAC;aACD,GAAG,CAAC,GAAG,EAAE,CAAC,SAAiB,CAAC,CAAC,OAAO,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,cAAc,GAAG,GAAG,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 { SonarV3Config } from \"../../common/Config.ts\";\nimport { Err, Ok, Result } from \"ts-results-es\";\nimport { lastValueFrom, map, of, switchMap, type Observable } from \"rxjs\";\nimport type { JobResultsResponse } from \"./utils/JobResultsResponse.ts\";\nimport { mapRowsToColumns } from \"./utils/mapRowsToColumns.ts\";\nimport { mapRowData } from \"./utils/mapRowData.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport type { JobProperties } from \"./utils/jobEntityToProperties.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\n\nexport class Job {\n readonly acceleration: JobProperties[\"acceleration\"];\n readonly cancellationReason: JobProperties[\"cancellationReason\"];\n readonly errorMessage?: string;\n readonly endedAt: JobProperties[\"endedAt\"];\n readonly id: JobProperties[\"id\"];\n readonly problem: JobProperties[\"problem\"];\n readonly queryType: JobProperties[\"queryType\"];\n readonly resourceSchedulingEndedAt: JobProperties[\"resourceSchedulingEndedAt\"];\n readonly resourceSchedulingStartedAt: JobProperties[\"resourceSchedulingStartedAt\"];\n readonly rowCount: JobProperties[\"rowCount\"];\n readonly startedAt: JobProperties[\"startedAt\"];\n readonly state: JobProperties[\"state\"];\n\n public readonly observer: Observable<Job>;\n #config: SonarV3Config;\n\n constructor(\n properties: JobProperties,\n config: SonarV3Config,\n observe: (id: string) => Observable<Result<Job, HttpError>>,\n ) {\n this.acceleration = properties.acceleration;\n this.cancellationReason = properties.cancellationReason;\n this.endedAt = properties.endedAt;\n this.id = properties.id;\n this.problem = properties.problem;\n this.queryType = properties.queryType;\n this.resourceSchedulingEndedAt = properties.resourceSchedulingEndedAt;\n this.resourceSchedulingStartedAt = properties.resourceSchedulingStartedAt;\n this.rowCount = properties.rowCount;\n this.startedAt = properties.startedAt;\n this.state = properties.state;\n this.#config = config;\n this.observer = of(this).pipe(\n switchMap((job) => {\n if (!job.settled) {\n return observe(this.id).pipe(\n map((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n );\n } else {\n return of(job);\n }\n }),\n );\n\n if (properties.errorMessage) {\n this.errorMessage = properties.errorMessage;\n }\n }\n\n get settled() {\n return (\n this.state === \"COMPLETED\" ||\n this.state === \"FAILED\" ||\n this.state === \"INVALID_STATE\" ||\n this.state === \"CANCELED\"\n );\n }\n\n get results() {\n return {\n jsonBatches: this.#jsonBatches.bind(this),\n metadata: this.#metadata.bind(this),\n slice: this.#slice.bind(this),\n };\n }\n\n /**\n * @returns A `Job` instance once it's reached a settled state\n */\n retrieveSettled() {\n return lastValueFrom(this.observer);\n }\n\n async *#jsonBatches<T extends Record<string, unknown> = Record<string, unknown>>(\n args: { limit?: number; offset?: number } = {},\n { signal }: SignalParam = {},\n ) {\n if (typeof args.limit === \"number\" && args.limit < 0) {\n throw new Error(\"Limit cannot be negative\");\n }\n\n if (typeof args.offset === \"number\" && args.offset < 0) {\n throw new Error(\"Offset cannot be negative\");\n }\n\n // Wait for job to enter a settled state before attempting to fetch batches\n if (!this.settled) {\n await this.retrieveSettled();\n }\n\n const limitArg = args.limit ?? Infinity;\n const offsetArg = args.offset || 0;\n\n // Tracks whether there are more rows available from the job results endpoint\n let hasMore = true;\n\n // Tracks the currently requested offset. If the offset arg is provided, start from there instead of 0.\n let offset = offsetArg;\n\n // Keeps track of the total number of rows that need to be loaded\n const stopAfterOffset = limitArg + offsetArg;\n\n while (hasMore && offset < stopAfterOffset) {\n // Make batch_size dynamic to allow for requesting a smaller final page\n const batch_size = Math.min(MAX_BATCH_SIZE, stopAfterOffset - offset);\n\n const batch = (\n await this.#config\n .sonarV3Request(`job/${this.id}/results?offset=${offset}&limit=${batch_size}`, { signal })\n .map((res) => res.json() as Promise<JobResultsResponse<T>>).promise\n ).unwrap();\n\n offset += batch.rows.length;\n hasMore = batch.rows.length === batch_size;\n\n if (batch.rows.length) {\n const schema = { fields: batch.schema };\n mapRowData(batch.rows, batch.schema);\n yield {\n get columns() {\n return mapRowsToColumns(batch);\n },\n rows: batch.rows,\n schema,\n totalRows: batch.rowCount,\n } as const;\n }\n }\n }\n\n async #metadata({ signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`job/${this.id}/results?offset=0&limit=0`, { signal })\n .map((res) => res.json() as Promise<JobResultsResponse>)\n .map((response) => ({\n schema: response.schema,\n totalRows: response.rowCount,\n })).promise;\n }\n\n async #slice<T extends Record<string, unknown> = Record<string, unknown>>(\n start: number = 0,\n end: number = Infinity,\n { signal }: SignalParam = {},\n ) {\n try {\n const rows: T[] = [];\n for await (const batch of this.#jsonBatches<T>(\n { limit: end - start, offset: start },\n { signal },\n )) {\n rows.push(...batch.rows);\n }\n return Ok(rows);\n } catch (e: unknown) {\n return Err(e);\n }\n }\n\n cancel() {\n return this.#config\n .sonarV3Request(`job/${this.id}/cancel`, {\n keepalive: true,\n method: \"POST\",\n })\n .map(() => undefined as void).promise;\n }\n}\n\nconst MAX_BATCH_SIZE = 500;\n"]}
|
|
1
|
+
{"version":3,"file":"Job.js","sourceRoot":"","sources":["../../../src/oss/jobs/Job.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAmB,MAAM,MAAM,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAyB,MAAM,uBAAuB,CAAC;AAM1E,MAAM,OAAO,GAAG;IACL,YAAY,CAAgC;IAC5C,kBAAkB,CAAsC;IACxD,YAAY,CAAU;IACtB,OAAO,CAA2B;IAClC,EAAE,CAAsB;IACxB,OAAO,CAA2B;IAClC,SAAS,CAA6B;IACtC,yBAAyB,CAA6C;IACtE,2BAA2B,CAA+C;IAC1E,QAAQ,CAA4B;IACpC,SAAS,CAA6B;IACtC,KAAK,CAAyB;IAEvB,QAAQ,CAAkB;IAC1C,OAAO,CAAgB;IAEvB,YACE,UAAyB,EACzB,MAAqB,EACrB,OAA2D;QAE3D,I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yright (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, Result } from \"ts-results-es\";\nimport { lastValueFrom, map, of, switchMap, type Observable } from \"rxjs\";\nimport type { JobResultsResponse } from \"./utils/JobResultsResponse.ts\";\nimport { mapRowsToColumns } from \"./utils/mapRowsToColumns.ts\";\nimport { mapRowData, type MappedFieldValue } from \"./utils/mapRowData.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport type { JobProperties } from \"./utils/jobEntityToProperties.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport type { JSONValue } from \"./utils/JSONValue.ts\";\n\nexport class Job {\n readonly acceleration: JobProperties[\"acceleration\"];\n readonly cancellationReason: JobProperties[\"cancellationReason\"];\n readonly errorMessage?: string;\n readonly endedAt: JobProperties[\"endedAt\"];\n readonly id: JobProperties[\"id\"];\n readonly problem: JobProperties[\"problem\"];\n readonly queryType: JobProperties[\"queryType\"];\n readonly resourceSchedulingEndedAt: JobProperties[\"resourceSchedulingEndedAt\"];\n readonly resourceSchedulingStartedAt: JobProperties[\"resourceSchedulingStartedAt\"];\n readonly rowCount: JobProperties[\"rowCount\"];\n readonly startedAt: JobProperties[\"startedAt\"];\n readonly state: JobProperties[\"state\"];\n\n public readonly observer: Observable<Job>;\n #config: SonarV3Config;\n\n constructor(\n properties: JobProperties,\n config: SonarV3Config,\n observe: (id: string) => Observable<Result<Job, HttpError>>,\n ) {\n this.acceleration = properties.acceleration;\n this.cancellationReason = properties.cancellationReason;\n this.endedAt = properties.endedAt;\n this.id = properties.id;\n this.problem = properties.problem;\n this.queryType = properties.queryType;\n this.resourceSchedulingEndedAt = properties.resourceSchedulingEndedAt;\n this.resourceSchedulingStartedAt = properties.resourceSchedulingStartedAt;\n this.rowCount = properties.rowCount;\n this.startedAt = properties.startedAt;\n this.state = properties.state;\n this.#config = config;\n this.observer = of(this).pipe(\n switchMap((job) => {\n if (!job.settled) {\n return observe(this.id).pipe(\n map((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n }),\n );\n } else {\n return of(job);\n }\n }),\n );\n\n if (properties.errorMessage) {\n this.errorMessage = properties.errorMessage;\n }\n }\n\n get settled() {\n return (\n this.state === \"COMPLETED\" ||\n this.state === \"FAILED\" ||\n this.state === \"INVALID_STATE\" ||\n this.state === \"CANCELED\"\n );\n }\n\n get results() {\n return {\n jsonBatches: this.#jsonBatches.bind(this),\n metadata: this.#metadata.bind(this),\n slice: this.#slice.bind(this),\n };\n }\n\n /**\n * @returns A `Job` instance once it's reached a settled state\n */\n retrieveSettled() {\n return lastValueFrom(this.observer);\n }\n\n async *#jsonBatches<\n T extends Record<string, MappedFieldValue> = Record<string, MappedFieldValue>,\n >(args: { limit?: number; offset?: number } = {}, { signal }: SignalParam = {}) {\n if (typeof args.limit === \"number\" && args.limit < 0) {\n throw new Error(\"Limit cannot be negative\");\n }\n\n if (typeof args.offset === \"number\" && args.offset < 0) {\n throw new Error(\"Offset cannot be negative\");\n }\n\n // Wait for job to enter a settled state before attempting to fetch batches\n if (!this.settled) {\n await this.retrieveSettled();\n }\n\n const limitArg = args.limit ?? Infinity;\n const offsetArg = args.offset || 0;\n\n // Tracks whether there are more rows available from the job results endpoint\n let hasMore = true;\n\n // Tracks the currently requested offset. If the offset arg is provided, start from there instead of 0.\n let offset = offsetArg;\n\n // Keeps track of the total number of rows that need to be loaded\n const stopAfterOffset = limitArg + offsetArg;\n\n while (hasMore && offset < stopAfterOffset) {\n // Make batch_size dynamic to allow for requesting a smaller final page\n const batch_size = Math.min(MAX_BATCH_SIZE, stopAfterOffset - offset);\n\n const batch = (\n await this.#config\n .sonarV3Request(`job/${this.id}/results?offset=${offset}&limit=${batch_size}`, { signal })\n .map((res) => res.json() as Promise<JobResultsResponse<Record<string, JSONValue>>>)\n .promise\n ).unwrap();\n\n offset += batch.rows.length;\n hasMore = batch.rows.length === batch_size;\n\n if (batch.rows.length) {\n const batchT = batch as unknown as JobResultsResponse<T>;\n mapRowData(batch.rows, batchT.schema);\n yield {\n get columns() {\n return mapRowsToColumns(batch);\n },\n rows: batchT.rows,\n schema: { fields: batchT.schema },\n totalRows: batch.rowCount,\n } as const;\n }\n }\n }\n\n async #metadata({ signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`job/${this.id}/results?offset=0&limit=0`, { signal })\n .map((res) => res.json() as Promise<JobResultsResponse>)\n .map((response) => ({\n schema: response.schema,\n totalRows: response.rowCount,\n })).promise;\n }\n\n async #slice<T extends Record<string, MappedFieldValue> = Record<string, MappedFieldValue>>(\n start: number = 0,\n end: number = Infinity,\n { signal }: SignalParam = {},\n ) {\n try {\n const rows: T[] = [];\n for await (const batch of this.#jsonBatches<T>(\n { limit: end - start, offset: start },\n { signal },\n )) {\n rows.push(...batch.rows);\n }\n return Ok(rows);\n } catch (e: unknown) {\n return Err(e);\n }\n }\n\n cancel() {\n return this.#config\n .sonarV3Request(`job/${this.id}/cancel`, {\n keepalive: true,\n method: \"POST\",\n })\n .map(() => undefined as void).promise;\n }\n}\n\nconst MAX_BATCH_SIZE = 500;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025 Dremio Corporation
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=JSONValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONValue.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/JSONValue.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\nexport type JSONValue =\n | string\n | number\n | boolean\n | null\n | JSONValue[]\n | { [key: string]: JSONValue };\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSONValue } from "./JSONValue.ts";
|
|
1
2
|
type VarcharType = {
|
|
2
3
|
name: "VARCHAR";
|
|
3
4
|
};
|
|
@@ -77,7 +78,7 @@ export type JobResultsSchema<TName extends string = string> = {
|
|
|
77
78
|
name: TName;
|
|
78
79
|
type: SimpleTypes | ComplexTypes;
|
|
79
80
|
}[];
|
|
80
|
-
export type JobResultsResponse<T extends Record<string, unknown> = Record<string,
|
|
81
|
+
export type JobResultsResponse<T extends Record<string, unknown> = Record<string, JSONValue>> = {
|
|
81
82
|
rowCount: number;
|
|
82
83
|
rows: T[];
|
|
83
84
|
schema: JobResultsSchema<Extract<keyof T, string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobResultsResponse.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/JobResultsResponse.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\ntype VarcharType = {\n name: \"VARCHAR\";\n};\n\ntype TextType = {\n name: \"TEXT\";\n};\n\ntype BinaryType = {\n name: \"BINARY\";\n};\n\ntype VarbinaryType = {\n name: \"VARBINARY\";\n};\n\ntype FloatType = {\n name: \"FLOAT\";\n};\n\ntype DecimalType = {\n name: \"DECIMAL\";\n};\n\ntype IntegerType = {\n name: \"INTEGER\";\n};\n\ntype MixedType = {\n name: \"MIXED\";\n};\n\ntype UnionType = {\n name: \"UNION\";\n};\n\ntype DateType = {\n name: \"DATE\";\n};\n\ntype TimeType = {\n name: \"TIME\";\n};\n\ntype DatetimeType = {\n name: \"DATETIME\";\n};\n\ntype MapType = {\n name: \"MAP\";\n};\n\ntype GeoType = {\n name: \"GEO\";\n};\n\ntype OtherType = {\n name: \"OTHER\";\n};\n\ntype AnyType = {\n name: \"ANY\";\n};\n\ntype DoubleType = {\n name: \"DOUBLE\";\n};\n\ntype BigintType = {\n name: \"BIGINT\";\n};\n\ntype BooleanType = {\n name: \"BOOLEAN\";\n};\n\ntype TimestampType = {\n name: \"TIMESTAMP\";\n};\n\ntype SimpleTypes =\n | VarcharType\n | DoubleType\n | BigintType\n | BooleanType\n | TimestampType\n | TextType\n | BinaryType\n | VarbinaryType\n | FloatType\n | DecimalType\n | IntegerType\n | MixedType\n | UnionType\n | DateType\n | TimeType\n | DatetimeType\n | MapType\n | GeoType\n | OtherType\n | AnyType;\n\ntype ListType = {\n name: \"LIST\";\n subSchema: {\n type: SimpleTypes | ComplexTypes;\n }[];\n};\n\ntype StructType = {\n name: \"STRUCT\";\n subSchema: {\n name: string;\n type: SimpleTypes | ComplexTypes;\n }[];\n};\n\ntype ComplexTypes = ListType | StructType;\n\nexport type JobResultsSchema<TName extends string = string> = {\n name: TName;\n type: SimpleTypes | ComplexTypes;\n}[];\n\nexport type JobResultsResponse<T extends Record<string, unknown> = Record<string,
|
|
1
|
+
{"version":3,"file":"JobResultsResponse.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/JobResultsResponse.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 { JSONValue } from \"./JSONValue.ts\";\n\ntype VarcharType = {\n name: \"VARCHAR\";\n};\n\ntype TextType = {\n name: \"TEXT\";\n};\n\ntype BinaryType = {\n name: \"BINARY\";\n};\n\ntype VarbinaryType = {\n name: \"VARBINARY\";\n};\n\ntype FloatType = {\n name: \"FLOAT\";\n};\n\ntype DecimalType = {\n name: \"DECIMAL\";\n};\n\ntype IntegerType = {\n name: \"INTEGER\";\n};\n\ntype MixedType = {\n name: \"MIXED\";\n};\n\ntype UnionType = {\n name: \"UNION\";\n};\n\ntype DateType = {\n name: \"DATE\";\n};\n\ntype TimeType = {\n name: \"TIME\";\n};\n\ntype DatetimeType = {\n name: \"DATETIME\";\n};\n\ntype MapType = {\n name: \"MAP\";\n};\n\ntype GeoType = {\n name: \"GEO\";\n};\n\ntype OtherType = {\n name: \"OTHER\";\n};\n\ntype AnyType = {\n name: \"ANY\";\n};\n\ntype DoubleType = {\n name: \"DOUBLE\";\n};\n\ntype BigintType = {\n name: \"BIGINT\";\n};\n\ntype BooleanType = {\n name: \"BOOLEAN\";\n};\n\ntype TimestampType = {\n name: \"TIMESTAMP\";\n};\n\ntype SimpleTypes =\n | VarcharType\n | DoubleType\n | BigintType\n | BooleanType\n | TimestampType\n | TextType\n | BinaryType\n | VarbinaryType\n | FloatType\n | DecimalType\n | IntegerType\n | MixedType\n | UnionType\n | DateType\n | TimeType\n | DatetimeType\n | MapType\n | GeoType\n | OtherType\n | AnyType;\n\ntype ListType = {\n name: \"LIST\";\n subSchema: {\n type: SimpleTypes | ComplexTypes;\n }[];\n};\n\ntype StructType = {\n name: \"STRUCT\";\n subSchema: {\n name: string;\n type: SimpleTypes | ComplexTypes;\n }[];\n};\n\ntype ComplexTypes = ListType | StructType;\n\nexport type JobResultsSchema<TName extends string = string> = {\n name: TName;\n type: SimpleTypes | ComplexTypes;\n}[];\n\nexport type JobResultsResponse<T extends Record<string, unknown> = Record<string, JSONValue>> = {\n rowCount: number;\n rows: T[];\n schema: JobResultsSchema<Extract<keyof T, string>>;\n};\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { JobResultsResponse } from "./JobResultsResponse.ts";
|
|
2
|
+
import { Temporal } from "temporal-polyfill";
|
|
3
|
+
declare const mapFieldValue: (fieldType: JobResultsResponse["schema"][number]["type"]["name"], fieldValue: unknown) => string | number | bigint | boolean | Temporal.PlainDateTime | Temporal.PlainDate | Temporal.PlainTime | null;
|
|
4
|
+
export type MappedFieldValue = ReturnType<typeof mapFieldValue>;
|
|
2
5
|
export declare const createRowTypeMapper: (schema: JobResultsResponse["schema"]) => (row: Record<string, unknown>) => void;
|
|
3
6
|
export declare const mapRowData: (rows: JobResultsResponse["rows"], schema: JobResultsResponse["schema"]) => void;
|
|
7
|
+
export {};
|
|
@@ -13,13 +13,21 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { Temporal } from "temporal-polyfill";
|
|
16
17
|
const mapFieldValue = (fieldType, fieldValue) => {
|
|
17
|
-
if (fieldValue === null) {
|
|
18
|
+
if (fieldValue === null || fieldValue === undefined) {
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
20
21
|
switch (fieldType) {
|
|
21
22
|
case "TIMESTAMP":
|
|
22
|
-
|
|
23
|
+
// Example: 2000-01-01 17:30:50.123
|
|
24
|
+
return Temporal.PlainDateTime.from(fieldValue.replace(" ", "T"));
|
|
25
|
+
case "DATE":
|
|
26
|
+
// Example: 2000-01-01
|
|
27
|
+
return Temporal.PlainDate.from(fieldValue);
|
|
28
|
+
case "TIME":
|
|
29
|
+
// Example: 17:30:50.235
|
|
30
|
+
return Temporal.PlainTime.from(fieldValue);
|
|
23
31
|
case "BIGINT":
|
|
24
32
|
return BigInt(fieldValue);
|
|
25
33
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapRowData.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/mapRowData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"mapRowData.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/mapRowData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,aAAa,GAAG,CACpB,SAA+D,EAC/D,UAAmB,EACnB,EAAE;IACF,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,WAAW;YACd,mCAA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CAAC;IACjB,CAAC;AACH,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 { JobResultsResponse } from \"./JobResultsResponse.ts\";\nimport { Temporal } from \"temporal-polyfill\";\n\nconst mapFieldValue = (\n fieldType: JobResultsResponse[\"schema\"][number][\"type\"][\"name\"],\n fieldValue: unknown,\n) => {\n if (fieldValue === null || fieldValue === undefined) {\n return null;\n }\n switch (fieldType) {\n case \"TIMESTAMP\":\n // Example: 2000-01-01 17:30:50.123\n return Temporal.PlainDateTime.from((fieldValue as string).replace(\" \", \"T\"));\n case \"DATE\":\n // Example: 2000-01-01\n return Temporal.PlainDate.from(fieldValue as string);\n case \"TIME\":\n // Example: 17:30:50.235\n return Temporal.PlainTime.from(fieldValue as string);\n case \"BIGINT\":\n return BigInt(fieldValue as string | number);\n default:\n return fieldValue as string | number | boolean;\n }\n};\n\nexport type MappedFieldValue = ReturnType<typeof mapFieldValue>;\n\nexport const createRowTypeMapper = (schema: JobResultsResponse[\"schema\"]) => {\n const fieldTypes = schema.reduce((accum, field) => {\n accum.set(field.name, field.type.name);\n return accum;\n }, new Map<string, JobResultsResponse[\"schema\"][number][\"type\"][\"name\"]>());\n\n return (row: Record<string, unknown>) => {\n for (const property in row) {\n row[property] = mapFieldValue(fieldTypes.get(property)!, row[property]);\n }\n };\n};\n\nexport const mapRowData = (\n rows: JobResultsResponse[\"rows\"],\n schema: JobResultsResponse[\"schema\"],\n): void => {\n const rowMapper = createRowTypeMapper(schema);\n\n for (const row of rows) {\n rowMapper(row);\n }\n};\n"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { JobResultsResponse } from "./JobResultsResponse.ts";
|
|
2
|
-
|
|
2
|
+
import type { JSONValue } from "./JSONValue.ts";
|
|
3
|
+
export declare const mapRowsToColumns: <T extends Record<string, JSONValue>>(jobResults: JobResultsResponse<T>) => Record<Extract<keyof T, string>, unknown[] | Float64Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Int32Array<ArrayBuffer>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapRowsToColumns.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/mapRowsToColumns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"mapRowsToColumns.js","sourceRoot":"","sources":["../../../../src/oss/jobs/utils/mapRowsToColumns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAIjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAAiC,EACjC,EAAE;IACF,MAAM,SAAS,GAAG,4BAA4B,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1F,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACrD,KAAK,MAAM,UAAU,IAAI,GAAG,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YAClC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,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 { createColumnRecordFromSchema } from \"./createColumnRecordFromSchema.ts\";\nimport type { JobResultsResponse } from \"./JobResultsResponse.ts\";\nimport type { JSONValue } from \"./JSONValue.ts\";\n\nexport const mapRowsToColumns = <T extends Record<string, JSONValue>>(\n jobResults: JobResultsResponse<T>,\n) => {\n const columnMap = createColumnRecordFromSchema(jobResults.schema, jobResults.rows.length);\n\n for (const [index, row] of jobResults.rows.entries()) {\n for (const columnName in row) {\n const col = columnMap[columnName];\n col[index] = row[columnName];\n }\n }\n\n return columnMap;\n};\n"]}
|