@dremio/js-sdk 0.12.4 → 0.13.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/enterprise/users/EnterpriseUser.d.ts +4 -1
- package/dist/enterprise/users/EnterpriseUser.js +24 -2
- package/dist/enterprise/users/EnterpriseUser.js.map +1 -1
- package/dist/oss/index.d.ts +1 -0
- package/dist/oss/index.js +1 -0
- package/dist/oss/index.js.map +1 -1
- package/dist/oss/jobs/JobsResource.js +2 -2
- package/dist/oss/jobs/JobsResource.js.map +1 -1
- package/dist/oss/resources.d.ts +2 -2
- package/dist/oss/resources.js.map +1 -1
- package/dist/oss/users/User.d.ts +10 -1
- package/dist/oss/users/User.js +26 -1
- package/dist/oss/users/User.js.map +1 -1
- package/dist/oss/users/UsersResource.d.ts +2 -2
- package/dist/oss/users/UsersResource.js +3 -3
- package/dist/oss/users/UsersResource.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { V3Config } from "../../common/Config.ts";
|
|
2
2
|
import type { SignalParam } from "../../common/Params.ts";
|
|
3
|
-
import { User, type UserEntity } from "../../oss/users/User.ts";
|
|
3
|
+
import { User, type UserEntity, type UserPatchableProperties } from "../../oss/users/User.ts";
|
|
4
4
|
import type { RoleReference } from "../roles/Role.ts";
|
|
5
5
|
export declare class EnterpriseUser extends User {
|
|
6
6
|
#private;
|
|
7
7
|
roles: RoleReference[];
|
|
8
8
|
source: string;
|
|
9
9
|
constructor(properties: EnterpriseUserProperties, config: V3Config);
|
|
10
|
+
save(properties: EnterpriseUserPatchableProperties): import("ts-results-es").AsyncResult<EnterpriseUser, import("../index.ts").HttpError>;
|
|
10
11
|
tokens({ signal }?: SignalParam): Promise<import("ts-results-es").Result<{
|
|
11
12
|
createdAt: Date;
|
|
12
13
|
expiresAt: Date;
|
|
@@ -18,6 +19,7 @@ export type EnterpriseUserEntity = UserEntity & {
|
|
|
18
19
|
roles: RoleReference[];
|
|
19
20
|
source: string;
|
|
20
21
|
};
|
|
22
|
+
export type EnterpriseUserPatchableProperties = UserPatchableProperties & {};
|
|
21
23
|
export declare const enterpriseUserEntityToProperties: (entity: EnterpriseUserEntity) => {
|
|
22
24
|
roles: RoleReference[];
|
|
23
25
|
source: string;
|
|
@@ -26,6 +28,7 @@ export declare const enterpriseUserEntityToProperties: (entity: EnterpriseUserEn
|
|
|
26
28
|
givenName: string | null;
|
|
27
29
|
id: string;
|
|
28
30
|
status: "ACTIVE" | "INACTIVE";
|
|
31
|
+
tag: string;
|
|
29
32
|
username: string;
|
|
30
33
|
};
|
|
31
34
|
export type EnterpriseUserProperties = ReturnType<typeof enterpriseUserEntityToProperties>;
|
|
@@ -13,16 +13,38 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { User, userEntityToProperties } from "../../oss/users/User.js";
|
|
16
|
+
import { User, userEntityToProperties, } from "../../oss/users/User.js";
|
|
17
17
|
export class EnterpriseUser extends User {
|
|
18
18
|
#config;
|
|
19
|
+
#tag;
|
|
19
20
|
roles;
|
|
20
21
|
source;
|
|
21
22
|
constructor(properties, config) {
|
|
22
|
-
super(properties);
|
|
23
|
+
super(properties, config);
|
|
23
24
|
this.#config = config;
|
|
24
25
|
this.roles = properties.roles;
|
|
25
26
|
this.source = properties.source;
|
|
27
|
+
this.#tag = properties.tag;
|
|
28
|
+
}
|
|
29
|
+
save(properties) {
|
|
30
|
+
return this.#config
|
|
31
|
+
.v3Request(`user/${this.id}`, {
|
|
32
|
+
body: JSON.stringify({
|
|
33
|
+
firstName: properties.givenName ?? this.givenName,
|
|
34
|
+
id: this.id,
|
|
35
|
+
lastName: properties.familyName ?? this.familyName,
|
|
36
|
+
name: this.username,
|
|
37
|
+
tag: this.#tag,
|
|
38
|
+
}),
|
|
39
|
+
headers: {
|
|
40
|
+
Accept: "application/json",
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
},
|
|
43
|
+
keepalive: true,
|
|
44
|
+
method: "PUT",
|
|
45
|
+
})
|
|
46
|
+
.map((res) => res.json())
|
|
47
|
+
.map((entity) => new EnterpriseUser(enterpriseUserEntityToProperties(entity), this.#config));
|
|
26
48
|
}
|
|
27
49
|
tokens({ signal } = {}) {
|
|
28
50
|
return this.#config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnterpriseUser.js","sourceRoot":"","sources":["../../../src/enterprise/users/EnterpriseUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,
|
|
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;AAajC,MAAM,OAAO,cAAe,SAAQ,IAAI;IACtC,OAAO,CAAW;IAClB,IAAI,CAAwB;IAE5B,KAAK,CAAkB;IACvB,MAAM,CAAS;IAEf,YAAY,UAAoC,EAAE,MAAgB;QAChE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;IAC7B,CAAC;IAEQ,IAAI,CAAC,UAA6C;QACzD,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,QAAQ,IAAI,CAAC,EAAE,EAAE,EAAE;YAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS;gBACjD,EAAE,EAAE,IAAI,CAAC,EAAE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AAC;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 { 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\";\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;\n #tag: UserProperties[\"tag\"];\n\n roles: RoleReference[];\n source: string;\n\n constructor(properties: EnterpriseUserProperties, config: V3Config) {\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 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/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const Dremio: (config: Config) => {
|
|
|
12
12
|
request: import("../common/Config.ts").RequestFn;
|
|
13
13
|
sonarV2Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
|
|
14
14
|
sonarV3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
|
|
15
|
+
v3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
|
|
15
16
|
};
|
|
16
17
|
_sonarV2Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
|
|
17
18
|
_sonarV3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
|
package/dist/oss/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const getSonarResourceConfig = (config) => {
|
|
|
23
23
|
request,
|
|
24
24
|
sonarV2Request: (path, init) => request(`/apiv2/${path}`, init),
|
|
25
25
|
sonarV3Request: (path, init) => request(`/api/v3/${path}`, init),
|
|
26
|
+
v3Request: (path, init) => request(`/api/v3/${path}`, init),
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
export const Dremio = (config) => {
|
package/dist/oss/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oss/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/oss/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQ3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,EAAE;IAChD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO;QACP,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,IAAI,CAAC;QAC/D,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,EAAE,IAAI,CAAC;QAChE,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,EAAE,IAAI,CAAC;KACQ,CAAC;AACxE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,EAAE;IACvC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC3D,OAAO;QACL,GAAG,SAAS,CAAC,mBAAmB,CAAC;QACjC,QAAQ,EAAE,mBAAmB,CAAC,OAAO;QACrC,oBAAoB,EAAE,mBAAmB;QACzC,eAAe,EAAE,mBAAmB,CAAC,cAAc;QACnD,eAAe,EAAE,mBAAmB,CAAC,cAAc;KACpD,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,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 { createRequest } from \"../common/createRequest.ts\";\nimport type {\n Config,\n ResourceConfig,\n SonarV2Config,\n SonarV3Config,\n V3Config,\n} from \"../common/Config.ts\";\nimport { Resources } from \"./resources.ts\";\n\nconst getSonarResourceConfig = (config: Config) => {\n const request = createRequest(config);\n return {\n logger: config.logger,\n origin: config.origin,\n request,\n sonarV2Request: (path, init) => request(`/apiv2/${path}`, init),\n sonarV3Request: (path, init) => request(`/api/v3/${path}`, init),\n v3Request: (path, init) => request(`/api/v3/${path}`, init),\n } satisfies ResourceConfig & SonarV2Config & SonarV3Config & V3Config;\n};\n\nexport const Dremio = (config: Config) => {\n const sonarResourceConfig = getSonarResourceConfig(config);\n return {\n ...Resources(sonarResourceConfig),\n _request: sonarResourceConfig.request,\n _sonarResourceConfig: sonarResourceConfig,\n _sonarV2Request: sonarResourceConfig.sonarV2Request,\n _sonarV3Request: sonarResourceConfig.sonarV3Request,\n };\n};\n\nexport * from \"../common/sharedExports.ts\";\nexport * from \"./credentials/index.ts\";\nexport * from \"./interfaces.ts\";\n"]}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
import { Job } from "./Job.js";
|
|
17
17
|
import { Query } from "../../common/Query.js";
|
|
18
18
|
import { AsyncResult } from "ts-results-es";
|
|
19
|
-
import {
|
|
19
|
+
import { repeat, shareReplay, takeWhile, tap } from "rxjs";
|
|
20
20
|
import { fromAbortable } from "../../common/fromAbortable.js";
|
|
21
21
|
import { jobEntityToProperties } from "./utils/jobEntityToProperties.js";
|
|
22
22
|
import moize from "moize";
|
|
23
23
|
export class JobsResource {
|
|
24
24
|
#config;
|
|
25
|
-
#createJobObservable = (id) =>
|
|
25
|
+
#createJobObservable = (id) => fromAbortable(({ signal }) => this.retrieve(id, { signal })).pipe(repeat({ delay: 1000 }), takeWhile((jobResult) => jobResult.isOk() && !jobResult.value.settled, true));
|
|
26
26
|
/**
|
|
27
27
|
* Reuse the same observable every time the `observe` method is called.
|
|
28
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JobsResource.js","sourceRoot":"","sources":["../../../src/oss/jobs/JobsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"JobsResource.js","sourceRoot":"","sources":["../../../src/oss/jobs/JobsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAE,aA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,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9D,CAAC;CACF","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport { Job } from \"./Job.ts\";\nimport { Query } from \"../../common/Query.ts\";\nimport { AsyncResult } from \"ts-results-es\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { repeat, shareReplay, takeWhile, tap } from \"rxjs\";\nimport { fromAbortable } from \"../../common/fromAbortable.ts\";\nimport { jobEntityToProperties, type JobEntity } from \"./utils/jobEntityToProperties.ts\";\nimport moize from \"moize\";\n\nexport class JobsResource {\n #config: SonarV3Config;\n\n #createJobObservable = (id: string) =>\n fromAbortable(({ signal }) => this.retrieve(id, { signal })).pipe(\n repeat({ delay: 1000 }),\n takeWhile((jobResult) => jobResult.isOk() && !jobResult.value.settled, true),\n );\n\n /**\n * Reuse the same observable every time the `observe` method is called.\n */\n #jobObserverCache = moize.default(\n (id: string) =>\n this.#createJobObservable(id).pipe(\n tap({\n finalize: () => {\n this.#jobObserverCache.remove([id]);\n },\n }),\n /**\n * Reuse the same polling for multiple subscribers, buffering only the latest result.\n * Make sure to unsubscribe from the source to stop polling when there are no subscribers (refCount: true)\n */\n shareReplay({\n bufferSize: 1,\n refCount: true,\n }),\n ),\n {\n /**\n * Evict cached observables after 60s. We need some way to prevent a memory\n * leak for long-running SDK processes, and a maxAge of 60 seconds should be\n * enough to handle multiple subscribers attached programmatically to a job.\n * If it's not, then the worst case is that we'd make additional API calls.\n */\n maxAge: 60_000,\n maxSize: Infinity,\n },\n );\n\n constructor(config: SonarV3Config) {\n this.#config = config;\n }\n\n _jobFromEntity(id: string, entity: JobEntity): Job {\n return new Job(jobEntityToProperties(id, entity), this.#config, this.observe.bind(this));\n }\n\n create(query: Query) {\n return this.#config\n .sonarV3Request(`sql`, {\n body: JSON.stringify({\n context: query.context,\n sql: query.sql,\n }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((response) => response.json() as Promise<{ id: string }>)\n .map((response) => response.id).promise;\n }\n\n /**\n * A convenience method to combine job creation and retrieval\n */\n createAndRetrieve(query: Query) {\n return new AsyncResult(this.create(query)).andThen((jobId) => this.retrieve(jobId)).promise;\n }\n\n observe(id: string) {\n return this.#jobObserverCache(id);\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`job/${id}`, { signal })\n .map((res) => res.json() as Promise<JobEntity>)\n .map((entity) => this._jobFromEntity(id, entity)).promise;\n }\n}\n"]}
|
package/dist/oss/resources.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ResourceConfig, SonarV2Config, SonarV3Config } from "../common/Config.ts";
|
|
1
|
+
import type { ResourceConfig, SonarV2Config, SonarV3Config, V3Config } from "../common/Config.ts";
|
|
2
2
|
import { CatalogResource } from "./catalog/CatalogResource.ts";
|
|
3
3
|
import { JobsResource } from "./jobs/JobsResource.ts";
|
|
4
4
|
import { ScriptsResource } from "./scripts/ScriptsResource.ts";
|
|
5
5
|
import { UsersResource } from "./users/UsersResource.ts";
|
|
6
|
-
export declare const Resources: (config: ResourceConfig & SonarV2Config & SonarV3Config) => {
|
|
6
|
+
export declare const Resources: (config: ResourceConfig & SonarV2Config & SonarV3Config & V3Config) => {
|
|
7
7
|
catalog: CatalogResource;
|
|
8
8
|
jobs: JobsResource;
|
|
9
9
|
scripts: ScriptsResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/oss/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/oss/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAiE,EAAE,EAAE,CAAC,CAAC;IAC/F,OAAO,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,IAAI,YAAY,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC;CACjC,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, SonarV2Config, SonarV3Config, V3Config } from \"../common/Config.ts\";\nimport { CatalogResource } from \"./catalog/CatalogResource.ts\";\nimport { JobsResource } from \"./jobs/JobsResource.ts\";\nimport { ScriptsResource } from \"./scripts/ScriptsResource.ts\";\nimport { UsersResource } from \"./users/UsersResource.ts\";\n\nexport const Resources = (config: ResourceConfig & SonarV2Config & SonarV3Config & V3Config) => ({\n catalog: new CatalogResource(config),\n jobs: new JobsResource(config),\n scripts: new ScriptsResource(config),\n users: new UsersResource(config),\n});\n"]}
|
package/dist/oss/users/User.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import type { V3Config } from "../../common/Config.ts";
|
|
1
2
|
export declare class User {
|
|
3
|
+
#private;
|
|
2
4
|
readonly email: UserProperties["email"];
|
|
3
5
|
readonly id: UserProperties["id"];
|
|
4
6
|
readonly familyName: UserProperties["familyName"];
|
|
5
7
|
readonly givenName: UserProperties["givenName"];
|
|
6
8
|
readonly status: UserProperties["status"];
|
|
7
9
|
readonly username: UserProperties["username"];
|
|
8
|
-
constructor(properties: UserProperties);
|
|
10
|
+
constructor(properties: UserProperties, config: V3Config);
|
|
9
11
|
get displayName(): string;
|
|
10
12
|
get initials(): string;
|
|
13
|
+
save(properties: UserPatchableProperties): import("ts-results-es").AsyncResult<User, import("../index.ts").HttpError>;
|
|
11
14
|
}
|
|
12
15
|
export type UserEntity = {
|
|
13
16
|
active: boolean;
|
|
@@ -18,12 +21,18 @@ export type UserEntity = {
|
|
|
18
21
|
name: string;
|
|
19
22
|
tag: string;
|
|
20
23
|
};
|
|
24
|
+
export type UserPatchableProperties = Partial<{
|
|
25
|
+
email: UserEntity["email"];
|
|
26
|
+
givenName: UserEntity["firstName"];
|
|
27
|
+
familyName: UserEntity["lastName"];
|
|
28
|
+
}>;
|
|
21
29
|
export declare const userEntityToProperties: (entity: UserEntity) => {
|
|
22
30
|
email: string;
|
|
23
31
|
familyName: string | null;
|
|
24
32
|
givenName: string | null;
|
|
25
33
|
id: string;
|
|
26
34
|
status: "ACTIVE" | "INACTIVE";
|
|
35
|
+
tag: string;
|
|
27
36
|
username: string;
|
|
28
37
|
};
|
|
29
38
|
export type UserProperties = ReturnType<typeof userEntityToProperties>;
|
package/dist/oss/users/User.js
CHANGED
|
@@ -20,13 +20,17 @@ export class User {
|
|
|
20
20
|
givenName;
|
|
21
21
|
status;
|
|
22
22
|
username;
|
|
23
|
-
|
|
23
|
+
#tag;
|
|
24
|
+
#config;
|
|
25
|
+
constructor(properties, config) {
|
|
24
26
|
this.email = properties.email;
|
|
25
27
|
this.id = properties.id;
|
|
26
28
|
this.familyName = properties.familyName;
|
|
27
29
|
this.givenName = properties.givenName;
|
|
28
30
|
this.status = properties.status;
|
|
29
31
|
this.username = properties.username;
|
|
32
|
+
this.#tag = properties.tag;
|
|
33
|
+
this.#config = config;
|
|
30
34
|
}
|
|
31
35
|
get displayName() {
|
|
32
36
|
if (this.givenName || this.familyName) {
|
|
@@ -48,6 +52,26 @@ export class User {
|
|
|
48
52
|
}
|
|
49
53
|
return this.displayName.slice(0, 2);
|
|
50
54
|
}
|
|
55
|
+
save(properties) {
|
|
56
|
+
return this.#config
|
|
57
|
+
.v3Request(`user/${this.id}`, {
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
firstName: properties.givenName ?? this.givenName,
|
|
60
|
+
id: this.id,
|
|
61
|
+
lastName: properties.familyName ?? this.familyName,
|
|
62
|
+
name: this.username,
|
|
63
|
+
tag: this.#tag,
|
|
64
|
+
}),
|
|
65
|
+
headers: {
|
|
66
|
+
Accept: "application/json",
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
},
|
|
69
|
+
keepalive: true,
|
|
70
|
+
method: "PUT",
|
|
71
|
+
})
|
|
72
|
+
.map((res) => res.json())
|
|
73
|
+
.map((entity) => new User(userEntityToProperties(entity), this.#config));
|
|
74
|
+
}
|
|
51
75
|
}
|
|
52
76
|
export const userEntityToProperties = (entity) => ({
|
|
53
77
|
email: entity.email,
|
|
@@ -55,6 +79,7 @@ export const userEntityToProperties = (entity) => ({
|
|
|
55
79
|
givenName: entity.firstName || null,
|
|
56
80
|
id: entity.id,
|
|
57
81
|
status: entity.active ? "ACTIVE" : "INACTIVE",
|
|
82
|
+
tag: entity.tag,
|
|
58
83
|
username: entity.name,
|
|
59
84
|
});
|
|
60
85
|
//# sourceMappingURL=User.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/oss/users/User.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/oss/users/User.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,OAAO,IAAI;IACN,KAAK,CAA0B;IAC/B,EAAE,CAAuB;IACzB,UAAU,CAA+B;IACzC,SAAS,CAA8B;IACvC,MAAM,CAA2B;IACjC,QAAQ,CAA6B;IAErC,IAAI,CAAwB;IAC5B,OAAO,CAAW;IAE3B,YAAY,UAA0B,EAAE,MAAgB;QACtD,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QAEpC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI,WAAW;QACb,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACtC,OAA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AkB;aACnC;YACD,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACxB,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACzF,CAAC;CACF;AAkBD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAkB,EAAE,EAAE,CAAC,CAAC;IAC7D,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,UAAU,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;IACnC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;IACnC,EAAE,EAAE,MAAM,CAAC,EAAE;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,QAAkB,CAAC,CAAC,CAAE,UAAoB;IACnE,GAAG,EAAE,MAAM,CAAC,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC,IAAI;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 { V3Config } from \"../../common/Config.ts\";\n\nexport class User {\n readonly email: UserProperties[\"email\"];\n readonly id: UserProperties[\"id\"];\n readonly familyName: UserProperties[\"familyName\"];\n readonly givenName: UserProperties[\"givenName\"];\n readonly status: UserProperties[\"status\"];\n readonly username: UserProperties[\"username\"];\n\n readonly #tag: UserProperties[\"tag\"];\n readonly #config: V3Config;\n\n constructor(properties: UserProperties, config: V3Config) {\n this.email = properties.email;\n this.id = properties.id;\n this.familyName = properties.familyName;\n this.givenName = properties.givenName;\n this.status = properties.status;\n this.username = properties.username;\n\n this.#tag = properties.tag;\n this.#config = config;\n }\n\n get displayName(): string {\n if (this.givenName || this.familyName) {\n return [this.givenName, this.familyName].filter(Boolean).join(\" \");\n }\n\n if (this.username) {\n return this.username;\n }\n\n if (this.email) {\n return this.email;\n }\n\n return this.id;\n }\n\n get initials(): string {\n const givenNameTrimmed = this.givenName?.trim();\n const familyNameTrimmed = this.familyName?.trim();\n\n if (givenNameTrimmed && familyNameTrimmed) {\n return givenNameTrimmed.charAt(0) + familyNameTrimmed.charAt(0);\n }\n\n return this.displayName.slice(0, 2);\n }\n\n save(properties: UserPatchableProperties) {\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((entity: UserEntity) => new User(userEntityToProperties(entity), this.#config));\n }\n}\n\nexport type UserEntity = {\n active: boolean;\n email: string;\n firstName: string;\n id: string;\n lastName: string;\n name: string;\n tag: string;\n};\n\nexport type UserPatchableProperties = Partial<{\n email: UserEntity[\"email\"];\n givenName: UserEntity[\"firstName\"];\n familyName: UserEntity[\"lastName\"];\n}>;\n\nexport const userEntityToProperties = (entity: UserEntity) => ({\n email: entity.email,\n familyName: entity.lastName || null,\n givenName: entity.firstName || null,\n id: entity.id,\n status: entity.active ? (\"ACTIVE\" as const) : (\"INACTIVE\" as const),\n tag: entity.tag,\n username: entity.name,\n});\n\nexport type UserProperties = ReturnType<typeof userEntityToProperties>;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { User, type UserEntity } from "./User.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { V3Config } from "../../common/Config.ts";
|
|
3
3
|
import type { SignalParam } from "../../common/Params.ts";
|
|
4
4
|
export declare class UsersResource {
|
|
5
5
|
#private;
|
|
6
|
-
constructor(config:
|
|
6
|
+
constructor(config: V3Config);
|
|
7
7
|
_userFromEntity(entity: UserEntity): User;
|
|
8
8
|
retrieveById(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<User, import("../index.ts").HttpError>>;
|
|
9
9
|
retrieveByName(name: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<User, import("../index.ts").HttpError>>;
|
|
@@ -20,17 +20,17 @@ export class UsersResource {
|
|
|
20
20
|
this.#config = config;
|
|
21
21
|
}
|
|
22
22
|
_userFromEntity(entity) {
|
|
23
|
-
return new User(userEntityToProperties(entity));
|
|
23
|
+
return new User(userEntityToProperties(entity), this.#config);
|
|
24
24
|
}
|
|
25
25
|
retrieveById(id, { signal } = {}) {
|
|
26
26
|
return this.#config
|
|
27
|
-
.
|
|
27
|
+
.v3Request(`user/${id}`, { signal })
|
|
28
28
|
.map((response) => response.json())
|
|
29
29
|
.map((entity) => this._userFromEntity(entity)).promise;
|
|
30
30
|
}
|
|
31
31
|
retrieveByName(name, { signal } = {}) {
|
|
32
32
|
return this.#config
|
|
33
|
-
.
|
|
33
|
+
.v3Request(`user/by-name/${name}`, { signal })
|
|
34
34
|
.map((response) => response.json())
|
|
35
35
|
.map((entity) => this._userFromEntity(entity)).promise;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAW;IAElB,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,eAAe,CAAC,MAAkB;QAChC,OAAO,IAAI,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,YAAY,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QACnD,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aACnC,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,SAAS,CAAC,gBAAgB,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aAC7C,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 { V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport class UsersResource {\n #config: V3Config;\n\n constructor(config: V3Config) {\n this.#config = config;\n }\n\n _userFromEntity(entity: UserEntity) {\n return new User(userEntityToProperties(entity), this.#config);\n }\n\n retrieveById(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`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 .v3Request(`user/by-name/${name}`, { signal })\n .map((response) => response.json() as Promise<UserEntity>)\n .map((entity) => this._userFromEntity(entity)).promise;\n }\n}\n"]}
|