@dremio/js-sdk 0.30.0 → 0.31.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.
Files changed (63) hide show
  1. package/dist/cloud/projects/Project.d.ts +30 -24
  2. package/dist/cloud/projects/Project.js +25 -1
  3. package/dist/cloud/projects/Project.js.map +1 -1
  4. package/dist/cloud/projects/ProjectsResource.d.ts +3 -1
  5. package/dist/cloud/projects/ProjectsResource.js +10 -3
  6. package/dist/cloud/projects/ProjectsResource.js.map +1 -1
  7. package/dist/cloud/projects/projectPropertiesCodec.d.ts +122 -0
  8. package/dist/cloud/projects/projectPropertiesCodec.js +88 -0
  9. package/dist/cloud/projects/projectPropertiesCodec.js.map +1 -0
  10. package/dist/common/ConflictResolver.d.ts +1 -0
  11. package/dist/common/ConflictResolver.js +17 -0
  12. package/dist/common/ConflictResolver.js.map +1 -0
  13. package/dist/common/HttpError.js +3 -1
  14. package/dist/common/HttpError.js.map +1 -1
  15. package/dist/common/safeParseResultToResult.d.ts +3 -0
  16. package/dist/common/safeParseResultToResult.js +24 -0
  17. package/dist/common/safeParseResultToResult.js.map +1 -0
  18. package/dist/enterprise/roles/Role.d.ts +4 -4
  19. package/dist/enterprise/roles/Role.js +2 -2
  20. package/dist/enterprise/roles/Role.js.map +1 -1
  21. package/dist/enterprise/roles/RoleReference.d.ts +10 -0
  22. package/dist/enterprise/roles/RoleReference.js +22 -0
  23. package/dist/enterprise/roles/RoleReference.js.map +1 -0
  24. package/dist/enterprise/roles/RolesResource.d.ts +2 -2
  25. package/dist/enterprise/roles/RolesResource.js +3 -3
  26. package/dist/enterprise/roles/RolesResource.js.map +1 -1
  27. package/dist/enterprise/scripts/EnterpriseScript.d.ts +26 -20
  28. package/dist/enterprise/scripts/EnterpriseScript.js +47 -14
  29. package/dist/enterprise/scripts/EnterpriseScript.js.map +1 -1
  30. package/dist/enterprise/scripts/EnterpriseScriptsResource.d.ts +4 -2
  31. package/dist/enterprise/scripts/EnterpriseScriptsResource.js +4 -2
  32. package/dist/enterprise/scripts/EnterpriseScriptsResource.js.map +1 -1
  33. package/dist/enterprise/scripts/enterpriseScriptPropertiesCodec.d.ts +32 -0
  34. package/dist/enterprise/scripts/enterpriseScriptPropertiesCodec.js +51 -0
  35. package/dist/enterprise/scripts/enterpriseScriptPropertiesCodec.js.map +1 -0
  36. package/dist/enterprise/users/EnterpriseUser.d.ts +40 -0
  37. package/dist/enterprise/users/EnterpriseUser.js +23 -0
  38. package/dist/enterprise/users/EnterpriseUser.js.map +1 -1
  39. package/dist/enterprise/users/EnterpriseUsersResource.d.ts +6 -0
  40. package/dist/enterprise/users/EnterpriseUsersResource.js +28 -1
  41. package/dist/enterprise/users/EnterpriseUsersResource.js.map +1 -1
  42. package/dist/oss/jobs/JobsResource.d.ts +41 -3
  43. package/dist/oss/jobs/JobsResource.js +1 -1
  44. package/dist/oss/jobs/JobsResource.js.map +1 -1
  45. package/dist/oss/jobs/listJobs.d.ts +82 -6
  46. package/dist/oss/jobs/listJobs.js +3 -24
  47. package/dist/oss/jobs/listJobs.js.map +1 -1
  48. package/dist/oss/scripts/Script.d.ts +33 -41
  49. package/dist/oss/scripts/Script.js +35 -42
  50. package/dist/oss/scripts/Script.js.map +1 -1
  51. package/dist/oss/scripts/ScriptLike.d.ts +16 -0
  52. package/dist/oss/scripts/ScriptLike.js +17 -0
  53. package/dist/oss/scripts/ScriptLike.js.map +1 -0
  54. package/dist/oss/scripts/ScriptsResource.d.ts +4 -2
  55. package/dist/oss/scripts/ScriptsResource.js +4 -2
  56. package/dist/oss/scripts/ScriptsResource.js.map +1 -1
  57. package/dist/oss/scripts/scriptPropertiesCodec.d.ts +29 -0
  58. package/dist/oss/scripts/scriptPropertiesCodec.js +78 -0
  59. package/dist/oss/scripts/scriptPropertiesCodec.js.map +1 -0
  60. package/package.json +1 -1
  61. package/dist/cloud/projects/utils.d.ts +0 -2
  62. package/dist/cloud/projects/utils.js +0 -37
  63. package/dist/cloud/projects/ut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AAG,CAAC,GAAG,EAAE,CAAC,SAAiB,CAAC,CAAC;IAClC,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\";\n\nexport class Role implements RoleProperties {\n readonly roleReference: RoleProperties[\"roleReference\"];\n readonly description: RoleProperties[\"description\"];\n readonly memberCount: RoleProperties[\"memberCount\"];\n readonly roles: RoleProperties[\"roles\"];\n\n readonly #config: SonarV3Config;\n\n constructor(properties: RoleProperties, config: SonarV3Config) {\n this.roleReference = properties.roleReference;\n\n this.description = properties.description;\n\n /**\n * Number of users and roles that are members of the role\n */\n this.memberCount = properties.memberCount;\n\n /**\n * Information about the roles to which the role belong\n */\n this.roles = properties.roles;\n\n this.#config = config;\n }\n\n update(properties: {\n name?: RoleReference[\"name\"];\n roles?: Role[\"roles\"];\n description?: Role[\"description\"];\n }) {\n return this.#config\n .sonarV3Request(`role/${this.roleReference.id}`, {\n body: JSON.stringify({\n description: properties.description ?? this.description,\n name: properties.name ?? this.roleReference.name,\n roles: properties.roles?.map((ref) => ref.id) || this.roles,\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() as Promise<RoleEntity>)\n .map((roleEntity) => Role.fromResource(roleEntity, this.#config));\n }\n\n static fromResource(properties: RoleEntity, config: SonarV3Config) {\n const { description, id, name, roles, type, ...rest } = properties;\n return new Role(\n {\n ...rest,\n description: description?.length ? description : null,\n roleReference: new RoleReference({ id, name, type }, config),\n roles: roles.map((roleReferenceEntity) => new RoleReference(roleReferenceEntity, config)),\n },\n config,\n );\n }\n}\n\nexport class RoleReference {\n readonly id: string;\n readonly name: string;\n\n /**\n * Origin of the role\n */\n readonly type: RoleEntity[\"type\"];\n\n readonly #config: SonarV3Config;\n\n constructor(\n properties: {\n id: RoleReference[\"id\"];\n name: RoleReference[\"name\"];\n type: RoleReference[\"type\"];\n },\n config: SonarV3Config,\n ) {\n this.id = properties.id;\n this.name = properties.name;\n this.type = properties.type;\n this.#config = config;\n }\n\n delete() {\n return this.#config\n .sonarV3Request(`role/${this.id}`, { keepalive: true, method: \"DELETE\" })\n .map(() => undefined as void);\n }\n}\n\nexport type RoleProperties = {\n readonly roleReference: RoleReference;\n readonly description: string | null;\n readonly memberCount: number;\n readonly roles: RoleReference[];\n};\n\nexport type RoleEntity = {\n id: string;\n name: string;\n type: \"INTERNAL\" | \"EXTERNAL\" | \"SYSTEM\";\n roles: RoleEntity[];\n memberCount: number;\n description: string;\n};\n"]}
1
+ {"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../src/enterprise/roles/Role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,OAAO,IAAI;IACN,aAAa,CAAkC;IAC/C,WAAW,CAAgC;IAC3C,WAAW,CAAgC;IAC3C,KAAK,CAA0B;IAE/B,OAAO,CAAW;IAE3B,YAAY,UAA0B,EAAE,MAAgB;QACtD,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;QAE9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAE1C;;WAEG;QACH,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAE1C;;WAEG;QACH,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAE9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,UAIN;QACC,OAAO,IAAI,CAAC,OAA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,EAAE,MAAM,CAAC,CAAC;SAC1F,EACD,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IACf,EAAE,CAAS;IACX,IAAI,CAAS;IAEtB;;OAEG;IACM,IAAI,CAAqB;IAEzB,OAAO,CAAW;IAE3B,YACE,UAIC,EACD,MAAgB;QAEhB,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,QAAQ,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;aACnE,GAAG,CAAC,GAAG,EAAE,CAAC,SAAiB,CAAC,CAAC;IAClC,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 { V3Config } from \"../../common/Config.ts\";\n\nexport class Role implements RoleProperties {\n readonly roleReference: RoleProperties[\"roleReference\"];\n readonly description: RoleProperties[\"description\"];\n readonly memberCount: RoleProperties[\"memberCount\"];\n readonly roles: RoleProperties[\"roles\"];\n\n readonly #config: V3Config;\n\n constructor(properties: RoleProperties, config: V3Config) {\n this.roleReference = properties.roleReference;\n\n this.description = properties.description;\n\n /**\n * Number of users and roles that are members of the role\n */\n this.memberCount = properties.memberCount;\n\n /**\n * Information about the roles to which the role belong\n */\n this.roles = properties.roles;\n\n this.#config = config;\n }\n\n update(properties: {\n name?: RoleReference[\"name\"];\n roles?: Role[\"roles\"];\n description?: Role[\"description\"];\n }) {\n return this.#config\n .v3Request(`role/${this.roleReference.id}`, {\n body: JSON.stringify({\n description: properties.description ?? this.description,\n name: properties.name ?? this.roleReference.name,\n roles: properties.roles?.map((ref) => ref.id) || this.roles,\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() as Promise<RoleEntity>)\n .map((roleEntity) => Role.fromResource(roleEntity, this.#config));\n }\n\n static fromResource(properties: RoleEntity, config: V3Config) {\n const { description, id, name, roles, type, ...rest } = properties;\n return new Role(\n {\n ...rest,\n description: description?.length ? description : null,\n roleReference: new RoleReference({ id, name, type }, config),\n roles: roles.map((roleReferenceEntity) => new RoleReference(roleReferenceEntity, config)),\n },\n config,\n );\n }\n}\n\nexport class RoleReference {\n readonly id: string;\n readonly name: string;\n\n /**\n * Origin of the role\n */\n readonly type: RoleEntity[\"type\"];\n\n readonly #config: V3Config;\n\n constructor(\n properties: {\n id: RoleReference[\"id\"];\n name: RoleReference[\"name\"];\n type: RoleReference[\"type\"];\n },\n config: V3Config,\n ) {\n this.id = properties.id;\n this.name = properties.name;\n this.type = properties.type;\n this.#config = config;\n }\n\n delete() {\n return this.#config\n .v3Request(`role/${this.id}`, { keepalive: true, method: \"DELETE\" })\n .map(() => undefined as void);\n }\n}\n\nexport type RoleProperties = {\n readonly roleReference: RoleReference;\n readonly description: string | null;\n readonly memberCount: number;\n readonly roles: RoleReference[];\n};\n\nexport type RoleEntity = {\n id: string;\n name: string;\n type: \"INTERNAL\" | \"EXTERNAL\" | \"SYSTEM\";\n roles: RoleEntity[];\n memberCount: number;\n description: string;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ import * as z from "zod/mini";
2
+ export declare const roleReferenceSchema: z.ZodMiniObject<{
3
+ id: z.ZodMiniString<string>;
4
+ name: z.ZodMiniString<string>;
5
+ type: z.ZodMiniEnum<{
6
+ INTERNAL: "INTERNAL";
7
+ EXTERNAL: "EXTERNAL";
8
+ SYSTEM: "SYSTEM";
9
+ }>;
10
+ }, z.core.$strip>;
@@ -0,0 +1,22 @@
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 * as z from "zod/mini";
17
+ export const roleReferenceSchema = z.object({
18
+ id: z.string(),
19
+ name: z.string(),
20
+ type: z.enum(["INTERNAL", "EXTERNAL", "SYSTEM"]),
21
+ });
22
+ //# sourceMappingURL=RoleReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoleReference.js","sourceRoot":"","sources":["../../../src/enterprise/roles/RoleReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;CACjD,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 * as z from \"zod/mini\";\n\nexport const roleReferenceSchema = z.object({\n id: z.string(),\n name: z.string(),\n type: z.enum([\"INTERNAL\", \"EXTERNAL\", \"SYSTEM\"]),\n});\n"]}
@@ -1,9 +1,9 @@
1
- import type { SonarV3Config } from "../../common/Config.ts";
1
+ import type { V3Config } from "../../common/Config.ts";
2
2
  import { Role } from "./Role.ts";
3
3
  import type { SignalParam } from "../../common/Params.ts";
4
4
  export declare class RolesResource {
5
5
  #private;
6
- constructor(config: SonarV3Config);
6
+ constructor(config: V3Config);
7
7
  list(): {
8
8
  data(): AsyncGenerator<Role, void, unknown>;
9
9
  getPage: ({ signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
@@ -21,7 +21,7 @@ export class RolesResource {
21
21
  }
22
22
  list() {
23
23
  const getPage = ({ signal } = {}) => this.#config
24
- .sonarV3Request("role", {
24
+ .v3Request("role", {
25
25
  headers: {
26
26
  Accept: "application/json",
27
27
  },
@@ -45,13 +45,13 @@ export class RolesResource {
45
45
  }
46
46
  retrieve(id, { signal } = {}) {
47
47
  return this.#config
48
- .sonarV3Request(`role/${id}`, { signal })
48
+ .v3Request(`role/${id}`, { signal })
49
49
  .map((res) => res.json())
50
50
  .map((properties) => Role.fromResource(properties, this.#config)).promise;
51
51
  }
52
52
  retrieveByName(name, { signal } = {}) {
53
53
  return this.#config
54
- .sonarV3Request(`role/by-name/${name}`, { signal })
54
+ .v3Request(`role/by-name/${name}`, { signal })
55
55
  .map((res) => res.json())
56
56
  .map((properties) => Role.fromResource(properties, this.#config)).promise;
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Roles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AE,MAAM,EAAE,CAAC;aACxC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACxB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,CAAC;IAED,cAAc,CAAC,IAAY,EAAE,EAAE,MAAM,KAAkB,EAAE;QACvD,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,gBAAgB,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aAClD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACxB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,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 { Role, type RoleEntity } from \"./Role.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport class RolesResource {\n #config: SonarV3Config;\n\n constructor(config: SonarV3Config) {\n this.#config = config;\n }\n\n list() {\n const getPage = ({ signal }: SignalParam = {}) =>\n this.#config\n .sonarV3Request(\"role\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) =>\n res.json() as Promise<{\n data: RoleEntity[];\n totalResults: number;\n }>,\n )\n .map((response) => {\n return {\n ...response,\n data: response.data.map((entity) => Role.fromResource(entity, this.#config)),\n };\n });\n return {\n async *data() {\n yield* await getPage()\n .map((v) => v.data)\n .promise.then((result) => result.unwrap());\n },\n getPage,\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`role/${id}`, { signal })\n .map((res) => res.json())\n .map((properties) => Role.fromResource(properties, this.#config)).promise;\n }\n\n retrieveByName(name: string, { signal }: SignalParam = {}) {\n return this.#config\n .sonarV3Request(`role/by-name/${name}`, { signal })\n .map((res) => res.json())\n .map((properties) => Role.fromResource(properties, this.#config)).promise;\n }\n}\n"]}
1
+ {"version":3,"file":"RolesResource.js","sourceRoot":"","sources":["../../../src/enterprise/roles/RolesResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,IAAI,EAAmB,MAAM,WAAW,CAAC;AAGlD,MAAM,OAAO,aAAa;IACxB,OAAO,CAAW;IAElB,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI;QACF,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,KAAkB,EAAE,EAAE,EAAE,CAC/C,IAAI,CAAC,OAAO;aACT,SAAS,CAAC,MAAM,EAAE;YACjB,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM;SACP,CAAC;aACD,GAAG,CACF,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,IAAI,EAGN,CACL;aACA,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,OAAO;gBACL,GAAG,QAAQ;gBACX,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;aAC7E,CAAC;QACJ,CAAC,CAAC,CAAC;QACP,OAAO;YACL,KAAK,CAAC,CAAC,IAAI;gBACT,KAAK,CAAC,CAAC,MAAM,OAAO,EAAE;qBACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;qBAClB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO;SACR,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC/C,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aACnC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACxB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,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,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACxB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,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 { V3Config } from \"../../common/Config.ts\";\nimport { Role, type RoleEntity } from \"./Role.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport class RolesResource {\n #config: V3Config;\n\n constructor(config: V3Config) {\n this.#config = config;\n }\n\n list() {\n const getPage = ({ signal }: SignalParam = {}) =>\n this.#config\n .v3Request(\"role\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) =>\n res.json() as Promise<{\n data: RoleEntity[];\n totalResults: number;\n }>,\n )\n .map((response) => {\n return {\n ...response,\n data: response.data.map((entity) => Role.fromResource(entity, this.#config)),\n };\n });\n return {\n async *data() {\n yield* await getPage()\n .map((v) => v.data)\n .promise.then((result) => result.unwrap());\n },\n getPage,\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`role/${id}`, { signal })\n .map((res) => res.json())\n .map((properties) => Role.fromResource(properties, this.#config)).promise;\n }\n\n retrieveByName(name: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`role/by-name/${name}`, { signal })\n .map((res) => res.json())\n .map((properties) => Role.fromResource(properties, this.#config)).promise;\n }\n}\n"]}
@@ -1,33 +1,39 @@
1
1
  import type { SonarV3Config } from "../../common/Config.ts";
2
2
  import { RoleGrantee, UserGrantee } from "../Grantee.js";
3
3
  import type { Ownable } from "../Ownable.ts";
4
- import { Script, type ScriptEntity, type ScriptPatchableProperties } from "../../oss/scripts/Script.ts";
5
4
  import type { SignalParam } from "../../common/Params.ts";
6
- export declare class EnterpriseScript extends Script implements Ownable {
5
+ import type { ScriptLike } from "../../oss/scripts/ScriptLike.ts";
6
+ import type { Temporal } from "temporal-polyfill";
7
+ import type { Query } from "../../common/Query.ts";
8
+ import * as z from "zod/mini";
9
+ import { enterpriseScriptPropertiesCodec, enterpriseScriptUpdateCodec } from "./enterpriseScriptPropertiesCodec.ts";
10
+ import type { Err } from "ts-results-es";
11
+ export declare class EnterpriseScript implements Ownable, ScriptLike {
7
12
  #private;
13
+ readonly createdAt: Temporal.Instant;
14
+ readonly createdBy: string;
15
+ readonly id: string;
16
+ readonly modifiedAt: Temporal.Instant;
17
+ readonly modifiedBy: string;
18
+ readonly name: string;
8
19
  readonly owner: UserGrantee;
9
- constructor(properties: EnterpriseScriptProperties, config: SonarV3Config);
20
+ readonly query: Query;
21
+ constructor(properties: z.output<typeof enterpriseScriptPropertiesCodec>, config: SonarV3Config);
10
22
  grants({ signal }?: SignalParam): Promise<import("ts-results-es").Result<{
11
23
  grantee: RoleGrantee;
12
24
  privileges: Set<ScriptPrivileges>;
13
25
  }[], import("../index.ts").HttpError>>;
14
- save(properties: ScriptPatchableProperties & {
15
- owner?: UserGrantee;
16
- }): Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").ValidationProblem | import("../index.ts").HttpError>>;
26
+ delete(): Promise<import("ts-results-es").Result<void, import("../index.ts").HttpError>>;
27
+ save(properties: z.output<typeof enterpriseScriptUpdateCodec>): Promise<Err<z.core.$ZodError<z.ZodMiniCodec<z.ZodMiniObject<{
28
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
29
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
30
+ context: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
31
+ owner: z.ZodMiniOptional<z.ZodMiniString<string>>;
32
+ }, z.core.$strip>, z.ZodMiniObject<{
33
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
34
+ query: z.ZodMiniOptional<z.ZodMiniCustom<Query, Query>>;
35
+ owner: z.ZodMiniOptional<z.ZodMiniCustom<UserGrantee, UserGrantee>>;
36
+ }, z.core.$strip>>>>> | Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").ValidationProblem | import("../index.ts").HttpError>>;
17
37
  }
18
- export type EnterpriseScriptProperties = ReturnType<typeof enterpriseScriptEntityToProperties>;
19
- export type EnterpriseScriptEntity = ScriptEntity & {
20
- owner?: string;
21
- };
22
- export declare const enterpriseScriptEntityToProperties: (entity: EnterpriseScriptEntity) => {
23
- owner: UserGrantee;
24
- createdAt: import("temporal-polyfill").Temporal.Instant;
25
- createdBy: string;
26
- id: string;
27
- modifiedAt: import("temporal-polyfill").Temporal.Instant;
28
- modifiedBy: string;
29
- name: string;
30
- query: import("../index.ts").Query;
31
- };
32
38
  type ScriptPrivileges = "DELETE" | "MANAGE_GRANTS" | "MODIFY" | "VIEW";
33
39
  export {};
@@ -14,14 +14,30 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { RoleGrantee, UserGrantee } from "../Grantee.js";
17
- import { createScriptPatchedFields, saveScript, Script, scriptEntityToProperties, } from "../../oss/scripts/Script.js";
18
- export class EnterpriseScript extends Script {
19
- owner;
17
+ import * as z from "zod/mini";
18
+ import { enterpriseScriptPropertiesCodec, enterpriseScriptUpdateCodec, } from "./enterpriseScriptPropertiesCodec.js";
19
+ import { mapScriptErrors } from "../../oss/scripts/Script.js";
20
+ import { safeParseResultToResult } from "../../common/safeParseResultToResult.js";
21
+ export class EnterpriseScript {
20
22
  #config;
23
+ createdAt;
24
+ createdBy;
25
+ id;
26
+ modifiedAt;
27
+ modifiedBy;
28
+ name;
29
+ owner;
30
+ query;
21
31
  constructor(properties, config) {
22
- super(properties, config);
23
- this.owner = properties.owner;
24
32
  this.#config = config;
33
+ this.createdAt = properties.createdAt;
34
+ this.createdBy = properties.createdBy;
35
+ this.id = properties.id;
36
+ this.modifiedAt = properties.modifiedAt;
37
+ this.modifiedBy = properties.modifiedBy;
38
+ this.name = properties.name;
39
+ this.owner = properties.owner;
40
+ this.query = properties.query;
25
41
  }
26
42
  grants({ signal } = {}) {
27
43
  return this.#config
@@ -38,15 +54,32 @@ export class EnterpriseScript extends Script {
38
54
  })),
39
55
  ]).promise;
40
56
  }
41
- async save(properties) {
42
- return saveScript(this.id, this.#config)({
43
- ...createScriptPatchedFields(properties),
44
- ...(properties.owner && { owner: properties.owner.id }),
45
- }).map((value) => new EnterpriseScript(enterpriseScriptEntityToProperties(value), this.#config)).promise;
57
+ delete() {
58
+ return this.#config
59
+ .sonarV3Request(`scripts/${this.id}`, {
60
+ keepalive: true,
61
+ method: "DELETE",
62
+ })
63
+ .map(() => undefined).promise;
64
+ }
65
+ save(properties) {
66
+ const safeEncodedProperties = z.safeEncode(enterpriseScriptUpdateCodec, properties);
67
+ if (!safeEncodedProperties.success) {
68
+ return Promise.resolve(safeParseResultToResult(safeEncodedProperties));
69
+ }
70
+ return this.#config
71
+ .sonarV3Request(`scripts/${this.id}`, {
72
+ body: JSON.stringify(safeEncodedProperties.data),
73
+ headers: {
74
+ Accept: "application/json",
75
+ "Content-Type": "application/json",
76
+ },
77
+ keepalive: true,
78
+ method: "PATCH",
79
+ })
80
+ .map((response) => response.json())
81
+ .map((entity) => new EnterpriseScript(z.decode(enterpriseScriptPropertiesCodec, entity), this.#config))
82
+ .mapErr((err) => mapScriptErrors(safeEncodedProperties.data, err)).promise;
46
83
  }
47
84
  }
48
- export const enterpriseScriptEntityToProperties = (entity) => ({
49
- ...scriptEntityToProperties(entity),
50
- owner: new UserGrantee(entity.owner),
51
- });
52
85
  //# sourceMappingURL=EnterpriseScript.js.map
@@ -1 +1 @@
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,gBAAiB,SAAQ,MAAM;IACjC,KAAK,CAAc;IAC5B,OAAO,CAAgB;I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G,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
+ {"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;AAMzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAGlF,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAgB;IACvB,SAAS,CAAmB;IAC5B,SAAS,CAAS;IAClB,EAAE,CAAS;IACX,UAAU,CAAmB;IAC7B,UAAU,CAAS;IACnB,IAAI,CAAS;IACb,KAAK,CAAc;IACnB,K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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 { RoleGrantee, UserGrantee } from \"../Grantee.js\";\nimport type { Ownable } from \"../Ownable.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport type { ScriptLike } from \"../../oss/scripts/ScriptLike.ts\";\nimport type { Temporal } from \"temporal-polyfill\";\nimport type { Query } from \"../../common/Query.ts\";\nimport * as z from \"zod/mini\";\nimport {\n enterpriseScriptPropertiesCodec,\n enterpriseScriptUpdateCodec,\n} from \"./enterpriseScriptPropertiesCodec.ts\";\nimport { mapScriptErrors } from \"../../oss/scripts/Script.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport type { Err } from \"ts-results-es\";\n\nexport class EnterpriseScript implements Ownable, ScriptLike {\n readonly #config: SonarV3Config;\n readonly createdAt: Temporal.Instant;\n readonly createdBy: string;\n readonly id: string;\n readonly modifiedAt: Temporal.Instant;\n readonly modifiedBy: string;\n readonly name: string;\n readonly owner: UserGrantee;\n readonly query: Query;\n\n constructor(properties: z.output<typeof enterpriseScriptPropertiesCodec>, config: SonarV3Config) {\n this.#config = config;\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 this.query = properties.query;\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 delete() {\n return this.#config\n .sonarV3Request(`scripts/${this.id}`, {\n keepalive: true,\n method: \"DELETE\",\n })\n .map(() => undefined as void).promise;\n }\n\n save(properties: z.output<typeof enterpriseScriptUpdateCodec>) {\n const safeEncodedProperties = z.safeEncode(enterpriseScriptUpdateCodec, properties);\n if (!safeEncodedProperties.success) {\n return Promise.resolve(\n safeParseResultToResult(safeEncodedProperties) as Err<\n z.core.util.SafeParseError<typeof enterpriseScriptUpdateCodec>[\"error\"]\n >,\n );\n }\n return this.#config\n .sonarV3Request(`scripts/${this.id}`, {\n body: JSON.stringify(safeEncodedProperties.data),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"PATCH\",\n })\n .map(\n (response) => response.json() as Promise<z.input<typeof enterpriseScriptPropertiesCodec>>,\n )\n .map(\n (entity) =>\n new EnterpriseScript(z.decode(enterpriseScriptPropertiesCodec, entity), this.#config),\n )\n .mapErr((err) => mapScriptErrors(safeEncodedProperties.data, err)).promise;\n }\n}\n\ntype ScriptPrivileges = \"DELETE\" | \"MANAGE_GRANTS\" | \"MODIFY\" | \"VIEW\";\n"]}
@@ -1,11 +1,13 @@
1
1
  import type { ResourceConfig, SonarV3Config } from "../../common/Config.ts";
2
2
  import type { Query } from "../../common/Query.ts";
3
3
  import type { SignalParam } from "../../common/Params.ts";
4
- import { EnterpriseScript, type EnterpriseScriptEntity } from "./EnterpriseScript.ts";
4
+ import { EnterpriseScript } from "./EnterpriseScript.ts";
5
+ import { enterpriseScriptPropertiesCodec } from "./enterpriseScriptPropertiesCodec.ts";
6
+ import * as z from "zod/mini";
5
7
  export declare class EnterpriseScriptsResource {
6
8
  #private;
7
9
  constructor(config: ResourceConfig & SonarV3Config);
8
- _scriptFromEntity(entity: EnterpriseScriptEntity): EnterpriseScript;
10
+ _scriptFromEntity(entity: z.input<typeof enterpriseScriptPropertiesCodec>): EnterpriseScript;
9
11
  list(): {
10
12
  data({ signal }?: SignalParam): AsyncGenerator<EnterpriseScript, void, unknown>;
11
13
  };
@@ -13,15 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { EnterpriseScript, enterpriseScriptEntityToProperties, } from "./EnterpriseScript.js";
16
+ import { EnterpriseScript } from "./EnterpriseScript.js";
17
17
  import { listScripts, retrieveScript, storeScript } from "../../oss/scripts/ScriptsResource.js";
18
+ import { enterpriseScriptPropertiesCodec } from "./enterpriseScriptPropertiesCodec.js";
19
+ import * as z from "zod/mini";
18
20
  export class EnterpriseScriptsResource {
19
21
  #config;
20
22
  constructor(config) {
21
23
  this.#config = config;
22
24
  }
23
25
  _scriptFromEntity(entity) {
24
- return new EnterpriseScript(enterpriseScriptEntityToProperties(entity), this.#config);
26
+ return new EnterpriseScript(z.decode(enterpriseScriptPropertiesCodec, entity), this.#config);
25
27
  }
26
28
  list() {
27
29
  const l = listScripts(this.#config, this._scriptFromEntity.bind(this));
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseScriptsResource.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScriptsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EACL,gBAAgB,EAChB,kCAAkC,GAEnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEhG,MAAM,OAAO,yBAAyB;IACpC,OAAO,CAAiC;IAExC,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,MAA8B;QAC9C,OAAO,IAAI,gBAAgB,CAAC,kCAAkC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACxF,CAAC;IAED,IAAI;QACF,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,OAAO;YACL,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAkB,EAAE;gBACtC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACxC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC/C,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAA0C;QAC9C,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAClF,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 { Query } from \"../../common/Query.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport {\n EnterpriseScript,\n enterpriseScriptEntityToProperties,\n type EnterpriseScriptEntity,\n} from \"./EnterpriseScript.ts\";\nimport { listScripts, retrieveScript, storeScript } from \"../../oss/scripts/ScriptsResource.ts\";\n\nexport class EnterpriseScriptsResource {\n #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n _scriptFromEntity(entity: EnterpriseScriptEntity) {\n return new EnterpriseScript(enterpriseScriptEntityToProperties(entity), this.#config);\n }\n\n list() {\n const l = listScripts(this.#config, this._scriptFromEntity.bind(this));\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await l({ signal })).unwrap();\n },\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return retrieveScript(this.#config, this._scriptFromEntity.bind(this))(id, { signal });\n }\n\n store(properties: { name: string; query: Query }) {\n return storeScript(this.#config, this._scriptFromEntity.bind(this))(properties);\n }\n}\n"]}
1
+ {"version":3,"file":"EnterpriseScriptsResource.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScriptsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,MAAM,OAAO,yBAAyB;IACpC,OAAO,CAAiC;IAExC,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,MAAuD;QACvE,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,+BAA+B,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/F,CAAC;IAED,IAAI;QACF,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,OAAO;YACL,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAkB,EAAE;gBACtC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACxC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC/C,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAA0C;QAC9C,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAClF,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 { Query } from \"../../common/Query.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { EnterpriseScript } from \"./EnterpriseScript.ts\";\nimport { listScripts, retrieveScript, storeScript } from \"../../oss/scripts/ScriptsResource.ts\";\nimport { enterpriseScriptPropertiesCodec } from \"./enterpriseScriptPropertiesCodec.ts\";\nimport * as z from \"zod/mini\";\nexport class EnterpriseScriptsResource {\n #config: ResourceConfig & SonarV3Config;\n\n constructor(config: ResourceConfig & SonarV3Config) {\n this.#config = config;\n }\n\n _scriptFromEntity(entity: z.input<typeof enterpriseScriptPropertiesCodec>) {\n return new EnterpriseScript(z.decode(enterpriseScriptPropertiesCodec, entity), this.#config);\n }\n\n list() {\n const l = listScripts(this.#config, this._scriptFromEntity.bind(this));\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await l({ signal })).unwrap();\n },\n };\n }\n\n retrieve(id: string, { signal }: SignalParam = {}) {\n return retrieveScript(this.#config, this._scriptFromEntity.bind(this))(id, { signal });\n }\n\n store(properties: { name: string; query: Query }) {\n return storeScript(this.#config, this._scriptFromEntity.bind(this))(properties);\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import * as z from "zod/mini";
2
+ import { UserGrantee } from "../Grantee.ts";
3
+ export declare const enterpriseScriptPropertiesCodec: z.ZodMiniCodec<z.ZodMiniObject<{
4
+ content: z.ZodMiniString<string>;
5
+ context: z.ZodMiniArray<z.ZodMiniString<string>>;
6
+ createdAt: z.ZodMiniString<string>;
7
+ createdBy: z.ZodMiniString<string>;
8
+ id: z.ZodMiniString<string>;
9
+ modifiedAt: z.ZodMiniString<string>;
10
+ modifiedBy: z.ZodMiniString<string>;
11
+ name: z.ZodMiniString<string>;
12
+ owner: z.ZodMiniString<string>;
13
+ }, z.core.$strip>, z.ZodMiniObject<{
14
+ name: z.ZodMiniString<string>;
15
+ id: z.ZodMiniString<string>;
16
+ createdBy: z.ZodMiniString<string>;
17
+ modifiedBy: z.ZodMiniString<string>;
18
+ createdAt: z.ZodMiniCustom<import("temporal-polyfill").Temporal.Instant, import("temporal-polyfill").Temporal.Instant>;
19
+ modifiedAt: z.ZodMiniCustom<import("temporal-polyfill").Temporal.Instant, import("temporal-polyfill").Temporal.Instant>;
20
+ query: z.ZodMiniCustom<import("../index.ts").Query, import("../index.ts").Query>;
21
+ owner: z.ZodMiniCustom<UserGrantee, UserGrantee>;
22
+ }, z.core.$strip>>;
23
+ export declare const enterpriseScriptUpdateCodec: z.ZodMiniCodec<z.ZodMiniObject<{
24
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
25
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
26
+ context: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
27
+ owner: z.ZodMiniOptional<z.ZodMiniString<string>>;
28
+ }, z.core.$strip>, z.ZodMiniObject<{
29
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
30
+ query: z.ZodMiniOptional<z.ZodMiniCustom<import("../index.ts").Query, import("../index.ts").Query>>;
31
+ owner: z.ZodMiniOptional<z.ZodMiniCustom<UserGrantee, UserGrantee>>;
32
+ }, z.core.$strip>>;
@@ -0,0 +1,51 @@
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 * as z from "zod/mini";
17
+ import { scriptPropertiesCodec, scriptUpdateCodec, } from "../../oss/scripts/scriptPropertiesCodec.js";
18
+ import { UserGrantee } from "../Grantee.js";
19
+ export const enterpriseScriptPropertiesCodec = z.codec(z.extend(scriptPropertiesCodec.def.in, { owner: z.string() }), z.extend(scriptPropertiesCodec.def.out, {
20
+ owner: z.instanceof(UserGrantee),
21
+ }), {
22
+ decode(v) {
23
+ return {
24
+ ...z.decode(scriptPropertiesCodec, v),
25
+ owner: new UserGrantee(v.owner),
26
+ };
27
+ },
28
+ encode(v) {
29
+ return {
30
+ ...z.encode(scriptPropertiesCodec, v),
31
+ owner: v.owner.id,
32
+ };
33
+ },
34
+ });
35
+ export const enterpriseScriptUpdateCodec = z.codec(z.extend(scriptUpdateCodec.def.in, { owner: z.optional(z.string()) }), z.extend(scriptUpdateCodec.def.out, { owner: z.optional(z.instanceof(UserGrantee)) }), {
36
+ decode(v) {
37
+ return {
38
+ ...z.decode(scriptUpdateCodec, v),
39
+ ...(v.owner && {
40
+ owner: new UserGrantee(v.owner),
41
+ }),
42
+ };
43
+ },
44
+ encode(v) {
45
+ return {
46
+ ...z.encode(scriptUpdateCodec, v),
47
+ ...(v.owner && { owner: v.owner.id }),
48
+ };
49
+ },
50
+ });
51
+ //# sourceMappingURL=enterpriseScriptPropertiesCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enterpriseScriptPropertiesCodec.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/enterpriseScriptPropertiesCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACpD,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAC7D,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,EAAE;IACtC,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;CACjC,CAAC,EACF;IACE,MAAM,CAAC,CAAC;QACN,OAAO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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 * as z from \"zod/mini\";\nimport {\n scriptPropertiesCodec,\n scriptUpdateCodec,\n} from \"../../oss/scripts/scriptPropertiesCodec.ts\";\nimport { UserGrantee } from \"../Grantee.ts\";\n\nexport const enterpriseScriptPropertiesCodec = z.codec(\n z.extend(scriptPropertiesCodec.def.in, { owner: z.string() }),\n z.extend(scriptPropertiesCodec.def.out, {\n owner: z.instanceof(UserGrantee),\n }),\n {\n decode(v) {\n return {\n ...z.decode(scriptPropertiesCodec, v),\n owner: new UserGrantee(v.owner),\n };\n },\n encode(v) {\n return {\n ...z.encode(scriptPropertiesCodec, v),\n owner: v.owner.id,\n };\n },\n },\n);\n\nexport const enterpriseScriptUpdateCodec = z.codec(\n z.extend(scriptUpdateCodec.def.in, { owner: z.optional(z.string()) }),\n z.extend(scriptUpdateCodec.def.out, { owner: z.optional(z.instanceof(UserGrantee)) }),\n {\n decode(v) {\n return {\n ...z.decode(scriptUpdateCodec, v),\n ...(v.owner && {\n owner: new UserGrantee(v.owner),\n }),\n };\n },\n encode(v) {\n return {\n ...z.encode(scriptUpdateCodec, v),\n ...(v.owner && { owner: v.owner.id }),\n };\n },\n },\n);\n"]}
@@ -2,6 +2,46 @@ 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";
5
+ import * as z from "zod/mini";
6
+ export declare const userCodec: z.ZodMiniCodec<z.ZodMiniObject<{
7
+ active: z.ZodMiniBoolean<boolean>;
8
+ id: z.ZodMiniString<string>;
9
+ identityType: z.ZodMiniLiteral<"REGULAR_USER">;
10
+ name: z.ZodMiniString<string>;
11
+ roles: z.ZodMiniArray<z.ZodMiniObject<{
12
+ id: z.ZodMiniString<string>;
13
+ name: z.ZodMiniString<string>;
14
+ type: z.ZodMiniEnum<{
15
+ INTERNAL: "INTERNAL";
16
+ EXTERNAL: "EXTERNAL";
17
+ SYSTEM: "SYSTEM";
18
+ }>;
19
+ }, z.core.$strip>>;
20
+ source: z.ZodMiniEnum<{
21
+ internal: "internal";
22
+ external: "external";
23
+ }>;
24
+ tag: z.ZodMiniString<string>;
25
+ }, z.core.$strip>, z.ZodMiniObject<{
26
+ id: z.ZodMiniString<string>;
27
+ tag: z.ZodMiniString<string>;
28
+ roles: z.ZodMiniArray<z.ZodMiniObject<{
29
+ id: z.ZodMiniString<string>;
30
+ name: z.ZodMiniString<string>;
31
+ type: z.ZodMiniEnum<{
32
+ INTERNAL: "INTERNAL";
33
+ EXTERNAL: "EXTERNAL";
34
+ SYSTEM: "SYSTEM";
35
+ }>;
36
+ }, z.core.$strip>>;
37
+ active: z.ZodMiniBoolean<boolean>;
38
+ identityType: z.ZodMiniLiteral<"REGULAR_USER">;
39
+ source: z.ZodMiniEnum<{
40
+ internal: "internal";
41
+ external: "external";
42
+ }>;
43
+ name: z.ZodMiniString<string>;
44
+ }, z.core.$strip>>;
5
45
  export declare class EnterpriseUser extends User {
6
46
  #private;
7
47
  roles: RoleReference[];
@@ -16,6 +16,29 @@
16
16
  import { User, userEntityToProperties, } from "../../oss/users/User.js";
17
17
  import { createRetrieveGrants } from "../grants/createRetrieveGrants.js";
18
18
  import { UserGrantee } from "../Grantee.js";
19
+ import * as z from "zod/mini";
20
+ import { roleReferenceSchema } from "../roles/RoleReference.js";
21
+ const userInSchema = z.object({
22
+ active: z.boolean(),
23
+ id: z.string(),
24
+ identityType: z.literal("REGULAR_USER"),
25
+ name: z.string(),
26
+ roles: z.array(roleReferenceSchema),
27
+ source: z.enum(["internal", "external"]),
28
+ tag: z.string(),
29
+ });
30
+ export const userCodec = z.codec(userInSchema, z.extend(z.omit(userInSchema, {
31
+ name: true,
32
+ }), {
33
+ name: z.string().check(z.trim(), z.minLength(1)),
34
+ }), {
35
+ decode(v) {
36
+ return v;
37
+ },
38
+ encode(v) {
39
+ return v;
40
+ },
41
+ });
19
42
  export class EnterpriseUser extends User {
20
43
  #config;
21
44
  #tag;
@@ -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;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,MAAM,OAAO,cAAe,SAAQ,IAAI;IACtC,OAAO,CAA2B;IAClC,IAAI,CAAwB;IAE5B,KAAK,CAAkB;IACvB,MAAM,CAAS;IAEf,YAAY,UAAoC,EAAE,MAAgC;QAChF,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,C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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"]}
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,mCAAmC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,C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AC,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\";\nimport * as z from \"zod/mini\";\nimport { roleReferenceSchema } from \"../roles/RoleReference.ts\";\n\ntype UserTokensResponse = {\n data: {\n tid: string;\n uid: string;\n label: string;\n createdAt: string;\n expiresAt: string;\n }[];\n};\n\nconst userInSchema = z.object({\n active: z.boolean(),\n id: z.string(),\n identityType: z.literal(\"REGULAR_USER\"),\n name: z.string(),\n roles: z.array(roleReferenceSchema),\n source: z.enum([\"internal\", \"external\"]),\n tag: z.string(),\n});\n\nexport const userCodec = z.codec(\n userInSchema,\n z.extend(\n z.omit(userInSchema, {\n name: true,\n }),\n {\n name: z.string().check(z.trim(), z.minLength(1)),\n },\n ),\n {\n decode(v) {\n return v;\n },\n encode(v) {\n return v;\n },\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"]}
@@ -4,6 +4,12 @@ import type { SignalParam } from "../../common/Params.ts";
4
4
  export declare class EnterpriseUsersResource {
5
5
  #private;
6
6
  constructor(config: SonarV3Config & V3Config);
7
+ list(): {
8
+ data({ signal }?: SignalParam): AsyncGenerator<EnterpriseUser, void, unknown>;
9
+ getPage: ({ signal }?: SignalParam) => import("ts-results-es").AsyncResult<{
10
+ data: EnterpriseUser[];
11
+ }, import("../index.ts").HttpError>;
12
+ };
7
13
  _userFromEntity(entity: EnterpriseUserEntity): EnterpriseUser;
8
14
  retrieveById(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<EnterpriseUser, import("../index.ts").HttpError>>;
9
15
  retrieveByName(name: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<EnterpriseUser, import("../index.ts").HttpError>>;