@dremio/js-sdk 0.9.0 → 0.11.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 (167) hide show
  1. package/dist/cloud/ai/AiResource.d.ts +3 -15
  2. package/dist/cloud/ai/AiResource.js +11 -14
  3. package/dist/cloud/ai/AiResource.js.map +1 -1
  4. package/dist/cloud/arctic/ArcticResource.d.ts +8 -7
  5. package/dist/cloud/arctic/ArcticResource.js +27 -20
  6. package/dist/cloud/arctic/ArcticResource.js.map +1 -1
  7. package/dist/cloud/engines/Engine.d.ts +2 -3
  8. package/dist/cloud/engines/Engine.js +5 -6
  9. package/dist/cloud/engines/Engine.js.map +1 -1
  10. package/dist/cloud/engines/EnginesResource.d.ts +8 -11
  11. package/dist/cloud/engines/EnginesResource.js +25 -23
  12. package/dist/cloud/engines/EnginesResource.js.map +1 -1
  13. package/dist/cloud/index.d.ts +33 -214
  14. package/dist/cloud/index.js +0 -1
  15. package/dist/cloud/index.js.map +1 -1
  16. package/dist/cloud/oauth/OAuthApplication.d.ts +1 -2
  17. package/dist/cloud/oauth/OAuthApplication.js +1 -3
  18. package/dist/cloud/oauth/OAuthApplication.js.map +1 -1
  19. package/dist/cloud/oauth/OAuthApplicationsResource.d.ts +9 -8
  20. package/dist/cloud/oauth/OAuthApplicationsResource.js +35 -31
  21. package/dist/cloud/oauth/OAuthApplicationsResource.js.map +1 -1
  22. package/dist/cloud/projects/Project.d.ts +4 -4
  23. package/dist/cloud/projects/Project.js +5 -5
  24. package/dist/cloud/projects/Project.js.map +1 -1
  25. package/dist/cloud/projects/ProjectsResource.d.ts +11 -13
  26. package/dist/cloud/projects/ProjectsResource.js +42 -30
  27. package/dist/cloud/projects/ProjectsResource.js.map +1 -1
  28. package/dist/cloud/resources.d.ts +39 -209
  29. package/dist/cloud/resources.js +9 -9
  30. package/dist/cloud/resources.js.map +1 -1
  31. package/dist/cloud/users/CloudUsersResource.d.ts +8 -11
  32. package/dist/cloud/users/CloudUsersResource.js +19 -18
  33. package/dist/cloud/users/CloudUsersResource.js.map +1 -1
  34. package/dist/common/Config.d.ts +4 -2
  35. package/dist/common/Config.js.map +1 -1
  36. package/dist/common/HttpError.d.ts +7 -13
  37. package/dist/common/HttpError.js +19 -34
  38. package/dist/common/HttpError.js.map +1 -1
  39. package/dist/common/Problem.d.ts +29 -34
  40. package/dist/common/Problem.js +47 -19
  41. package/dist/common/Problem.js.map +1 -1
  42. package/dist/common/Query.js +1 -2
  43. package/dist/common/Query.js.map +1 -1
  44. package/dist/common/createRequest.js +8 -33
  45. package/dist/common/createRequest.js.map +1 -1
  46. package/dist/common/problems.d.ts +11 -9
  47. package/dist/common/problems.js +18 -9
  48. package/dist/common/problems.js.map +1 -1
  49. package/dist/enterprise/catalog/CatalogObjects/index.d.ts +1 -2
  50. package/dist/enterprise/catalog/CatalogObjects/index.js.map +1 -1
  51. package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.d.ts +2 -3
  52. package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.js +3 -5
  53. package/dist/enterprise/catalog/CatalogReferences/retrieveCatalogGrants.js.map +1 -1
  54. package/dist/enterprise/catalog/EnterpriseCatalogResource.d.ts +9 -6
  55. package/dist/enterprise/catalog/EnterpriseCatalogResource.js +25 -19
  56. package/dist/enterprise/catalog/EnterpriseCatalogResource.js.map +1 -1
  57. package/dist/enterprise/catalog/catalogObjectFromEntity.js +0 -8
  58. package/dist/enterprise/catalog/catalogObjectFromEntity.js.map +1 -1
  59. package/dist/enterprise/catalog/catalogRetrieve.js +4 -0
  60. package/dist/enterprise/catalog/catalogRetrieve.js.map +1 -1
  61. package/dist/enterprise/credentials/exchangePat.d.ts +2 -4
  62. package/dist/enterprise/credentials/exchangePat.js +3 -3
  63. package/dist/enterprise/credentials/exchangePat.js.map +1 -1
  64. package/dist/enterprise/engines/Engine.d.ts +3 -5
  65. package/dist/enterprise/engines/Engine.js +7 -11
  66. package/dist/enterprise/engines/Engine.js.map +1 -1
  67. package/dist/enterprise/engines/EnginesResource.d.ts +2 -4
  68. package/dist/enterprise/engines/EnginesResource.js +4 -6
  69. package/dist/enterprise/engines/EnginesResource.js.map +1 -1
  70. package/dist/enterprise/index.d.ts +12 -45
  71. package/dist/enterprise/index.js +0 -1
  72. package/dist/enterprise/index.js.map +1 -1
  73. package/dist/enterprise/resources.d.ts +10 -36
  74. package/dist/enterprise/resources.js +5 -5
  75. package/dist/enterprise/resources.js.map +1 -1
  76. package/dist/enterprise/roles/RolesResource.d.ts +6 -5
  77. package/dist/enterprise/roles/RolesResource.js +16 -13
  78. package/dist/enterprise/roles/RolesResource.js.map +1 -1
  79. package/dist/enterprise/scripts/EnterpriseScript.d.ts +4 -14
  80. package/dist/enterprise/scripts/EnterpriseScript.js +4 -6
  81. package/dist/enterprise/scripts/EnterpriseScript.js.map +1 -1
  82. package/dist/enterprise/scripts/EnterpriseScriptsResource.d.ts +13 -7
  83. package/dist/enterprise/scripts/EnterpriseScriptsResource.js +24 -55
  84. package/dist/enterprise/scripts/EnterpriseScriptsResource.js.map +1 -1
  85. package/dist/enterprise/users/EnterpriseUser.d.ts +8 -5
  86. package/dist/enterprise/users/EnterpriseUser.js +3 -5
  87. package/dist/enterprise/users/EnterpriseUser.js.map +1 -1
  88. package/dist/enterprise/users/EnterpriseUsersResource.d.ts +9 -10
  89. package/dist/enterprise/users/EnterpriseUsersResource.js +20 -14
  90. package/dist/enterprise/users/EnterpriseUsersResource.js.map +1 -1
  91. package/dist/oss/catalog/CatalogObjects/index.d.ts +2 -3
  92. package/dist/oss/catalog/CatalogObjects/index.js.map +1 -1
  93. package/dist/oss/catalog/CatalogObjects/utils/catalogObjectFromEntity.d.ts +1 -2
  94. package/dist/oss/catalog/CatalogObjects/utils/catalogObjectFromEntity.js +0 -8
  95. package/dist/oss/catalog/CatalogObjects/utils/catalogObjectFromEntity.js.map +1 -1
  96. package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -1
  97. package/dist/oss/catalog/CatalogReferences/FolderCatalogReference.d.ts +1 -1
  98. package/dist/oss/catalog/CatalogReferences/HomeCatalogReference.d.ts +1 -1
  99. package/dist/oss/catalog/CatalogReferences/SourceCatalogReference.d.ts +1 -1
  100. package/dist/oss/catalog/CatalogReferences/SourceCatalogReference.js +4 -4
  101. package/dist/oss/catalog/CatalogReferences/SourceCatalogReference.js.map +1 -1
  102. package/dist/oss/catalog/CatalogReferences/SpaceCatalogReference.d.ts +1 -1
  103. package/dist/oss/catalog/CatalogReferences/utils/catalogChildren.js +1 -0
  104. package/dist/oss/catalog/CatalogReferences/utils/catalogChildren.js.map +1 -1
  105. package/dist/oss/catalog/CatalogReferences/utils/getTags.d.ts +1 -2
  106. package/dist/oss/catalog/CatalogReferences/utils/getTags.js +2 -4
  107. package/dist/oss/catalog/CatalogReferences/utils/getTags.js.map +1 -1
  108. package/dist/oss/catalog/CatalogReferences/utils/getWiki.d.ts +1 -2
  109. package/dist/oss/catalog/CatalogReferences/utils/getWiki.js +2 -4
  110. package/dist/oss/catalog/CatalogReferences/utils/getWiki.js.map +1 -1
  111. package/dist/oss/catalog/CatalogResource.d.ts +9 -6
  112. package/dist/oss/catalog/CatalogResource.js +25 -19
  113. package/dist/oss/catalog/CatalogResource.js.map +1 -1
  114. package/dist/oss/catalog/CatalogTags.d.ts +2 -6
  115. package/dist/oss/catalog/CatalogTags.js +8 -13
  116. package/dist/oss/catalog/CatalogTags.js.map +1 -1
  117. package/dist/oss/catalog/CatalogWiki.d.ts +2 -6
  118. package/dist/oss/catalog/CatalogWiki.js +8 -13
  119. package/dist/oss/catalog/CatalogWiki.js.map +1 -1
  120. package/dist/oss/catalog/VersionReference.d.ts +12 -12
  121. package/dist/oss/catalog/VersionReference.js +18 -3
  122. package/dist/oss/catalog/VersionReference.js.map +1 -1
  123. package/dist/oss/catalog/catalogErrors.d.ts +3 -14
  124. package/dist/oss/catalog/catalogErrors.js +9 -12
  125. package/dist/oss/catalog/catalogErrors.js.map +1 -1
  126. package/dist/oss/catalog/catalogRetrieve.d.ts +3 -2
  127. package/dist/oss/catalog/catalogRetrieve.js +6 -2
  128. package/dist/oss/catalog/catalogRetrieve.js.map +1 -1
  129. package/dist/oss/index.d.ts +8 -39
  130. package/dist/oss/index.js +0 -1
  131. package/dist/oss/index.js.map +1 -1
  132. package/dist/oss/interfaces.d.ts +2 -2
  133. package/dist/oss/interfaces.js +1 -0
  134. package/dist/oss/interfaces.js.map +1 -1
  135. package/dist/oss/jobs/Job.d.ts +5 -45
  136. package/dist/oss/jobs/Job.js +7 -27
  137. package/dist/oss/jobs/Job.js.map +1 -1
  138. package/dist/oss/jobs/JobsResource.d.ts +11 -8
  139. package/dist/oss/jobs/JobsResource.js +52 -46
  140. package/dist/oss/jobs/JobsResource.js.map +1 -1
  141. package/dist/oss/jobs/utils/jobEntityToProperties.d.ts +40 -0
  142. package/dist/oss/jobs/utils/jobEntityToProperties.js +34 -0
  143. package/dist/oss/jobs/utils/jobEntityToProperties.js.map +1 -0
  144. package/dist/oss/resources.d.ts +8 -36
  145. package/dist/oss/resources.js +4 -8
  146. package/dist/oss/resources.js.map +1 -1
  147. package/dist/oss/scripts/Script.d.ts +3 -22
  148. package/dist/oss/scripts/Script.js +12 -16
  149. package/dist/oss/scripts/Script.js.map +1 -1
  150. package/dist/oss/scripts/ScriptErrors.d.ts +6 -18
  151. package/dist/oss/scripts/ScriptErrors.js +10 -13
  152. package/dist/oss/scripts/ScriptErrors.js.map +1 -1
  153. package/dist/oss/scripts/ScriptsResource.d.ts +24 -7
  154. package/dist/oss/scripts/ScriptsResource.js +57 -51
  155. package/dist/oss/scripts/ScriptsResource.js.map +1 -1
  156. package/dist/oss/users/User.d.ts +9 -10
  157. package/dist/oss/users/User.js.map +1 -1
  158. package/dist/oss/users/UsersResource.d.ts +9 -10
  159. package/dist/oss/users/UsersResource.js +19 -13
  160. package/dist/oss/users/UsersResource.js.map +1 -1
  161. package/package.json +11 -13
  162. package/dist/cloud/projects/projectApiMethods.d.ts +0 -9
  163. package/dist/cloud/projects/projectApiMethods.js +0 -43
  164. package/dist/cloud/projects/projectApiMethods.js.map +0 -1
  165. package/dist/oss/catalog/CatalogObjects/VersionedDatasetCatalogObject.d.ts +0 -31
  166. package/dist/oss/catalog/CatalogObjects/VersionedDatasetCatalogObject.js +0 -58
  167. package/dist/oss/catalog/CatalogObjects/VersionedDatasetCatalogObject.js.map +0 -1
@@ -1,5 +1,4 @@
1
1
  import type { Config } from "../common/Config.ts";
2
- import { Resources } from "./resources.ts";
3
2
  export declare const Dremio: (config: Config) => {
4
3
  _request: import("../common/Config.ts").RequestFn;
5
4
  _sonarResourceConfig: {
@@ -11,53 +10,21 @@ export declare const Dremio: (config: Config) => {
11
10
  } | undefined;
12
11
  origin: string;
13
12
  request: import("../common/Config.ts").RequestFn;
14
- sonarV2Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
15
- sonarV3Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
16
- sonarV4Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
17
- v3Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
18
- };
19
- _sonarV2Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
20
- _sonarV3Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
21
- _sonarV4Request: (path: string, init: RequestInit | undefined) => Promise<Response>;
22
- catalog: {
23
- _catalogReferenceFromEntity: (entity: unknown) => import("./interfaces.ts").EnterpriseCatalogReference;
24
- list: () => {
25
- data(): AsyncGenerator<import("./interfaces.ts").EnterpriseFunctionCatalogReference | import("./interfaces.ts").EnterpriseHomeCatalogReference | import("./interfaces.ts").EnterpriseSourceCatalogReference | import("./interfaces.ts").EnterpriseSpaceCatalogReference, void, unknown>;
26
- };
27
- retrieve: (key: string) => Promise<import("ts-results-es").Result<import("./interfaces.ts").EnterpriseCatalogObject, unknown>>;
28
- retrieveByPath: (key: string[]) => Promise<import("ts-results-es").Result<import("./interfaces.ts").EnterpriseCatalogObject, unknown>>;
13
+ sonarV2Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
14
+ sonarV3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
15
+ sonarV4Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
16
+ v3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
29
17
  };
18
+ _sonarV2Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
19
+ _sonarV3Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
20
+ _sonarV4Request: (path: string, init: RequestInit | undefined) => import("ts-results-es").AsyncResult<Response, import("../common/HttpError.ts").HttpError>;
21
+ catalog: import("./catalog/EnterpriseCatalogResource.ts").EnterpriseCatalogResource;
30
22
  engines: import("./engines/EnginesResource.ts").EnginesResource;
31
- jobs: {
32
- create: (query: import("../common/Query.ts").Query) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<string>>;
33
- createAndRetrieve: (query: import("../common/Query.ts").Query) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Job, unknown>>;
34
- observe: (id: string) => import("rxjs").Observable<import("../oss/jobs/Job.ts").JobResult>;
35
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("../oss/jobs/Job.ts").JobResult>;
36
- };
37
- roles: {
38
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Role, unknown>>;
39
- retrieveByName: (name: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Role, unknown>>;
40
- };
41
- scripts: {
42
- list(): {
43
- data({ signal }?: import("../common/Params.ts").SignalParam): AsyncGenerator<import("./interfaces.ts").EnterpriseScript, void, unknown>;
44
- };
45
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseScript>>;
46
- store: (properties: {
47
- name: string;
48
- query: import("../common/Query.ts").Query;
49
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseScript>>;
50
- };
51
- users: {
52
- retrieveById: (id: string, { signal }?: {
53
- signal?: AbortSignal;
54
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseUser>>;
55
- retrieveByName: (name: string, { signal }?: {
56
- signal?: AbortSignal;
57
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseUser>>;
58
- };
23
+ jobs: import("../oss/jobs/JobsResource.ts").JobsResource;
24
+ roles: import("./roles/RolesResource.ts").RolesResource;
25
+ scripts: import("./scripts/EnterpriseScriptsResource.ts").EnterpriseScriptsResource;
26
+ users: import("./users/EnterpriseUsersResource.ts").EnterpriseUsersResource;
59
27
  };
60
28
  export * from "../common/sharedExports.ts";
61
29
  export * from "./credentials/index.ts";
62
30
  export * from "./interfaces.ts";
63
- export { Resources as _Resources };
@@ -41,5 +41,4 @@ export const Dremio = (config) => {
41
41
  export * from "../common/sharedExports.js";
42
42
  export * from "./credentials/index.js";
43
43
  export * from "./interfaces.js";
44
- export { Resources as _Resources };
45
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enterprise/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAS3D,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,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;KACwB,CAAC;AACxF,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;QACnD,eAAe,EAAE,mBAAmB,CAAC,cAAc;KACpD,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,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 SonarV4Config,\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 sonarV4Request: (path, init) => request(`/api/v4/${path}`, init),\n v3Request: (path, init) => request(`/api/v3/${path}`, init),\n } satisfies ResourceConfig & SonarV2Config & SonarV3Config & SonarV4Config & 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 _sonarV4Request: sonarResourceConfig.sonarV4Request,\n };\n};\n\nexport * from \"../common/sharedExports.ts\";\nexport * from \"./credentials/index.ts\";\nexport * from \"./interfaces.ts\";\nexport { Resources as _Resources };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enterprise/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAS3D,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,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;KACwB,CAAC;AACxF,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;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 SonarV4Config,\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 sonarV4Request: (path, init) => request(`/api/v4/${path}`, init),\n v3Request: (path, init) => request(`/api/v3/${path}`, init),\n } satisfies ResourceConfig & SonarV2Config & SonarV3Config & SonarV4Config & 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 _sonarV4Request: sonarResourceConfig.sonarV4Request,\n };\n};\n\nexport * from \"../common/sharedExports.ts\";\nexport * from \"./credentials/index.ts\";\nexport * from \"./interfaces.ts\";\n"]}
@@ -1,45 +1,19 @@
1
1
  import type { ResourceConfig, SonarV2Config, SonarV3Config, SonarV4Config, V3Config } from "../common/Config.ts";
2
+ import { JobsResource } from "../oss/jobs/JobsResource.ts";
3
+ import { EnterpriseCatalogResource } from "./catalog/EnterpriseCatalogResource.ts";
4
+ import { RolesResource } from "./roles/RolesResource.ts";
5
+ import { EnterpriseScriptsResource } from "./scripts/EnterpriseScriptsResource.ts";
6
+ import { EnterpriseUsersResource } from "./users/EnterpriseUsersResource.ts";
2
7
  import { EnginesResource } from "./engines/EnginesResource.ts";
3
8
  /**
4
9
  * @internal
5
10
  * @hidden
6
11
  */
7
12
  export declare const Resources: (config: ResourceConfig & SonarV2Config & SonarV3Config & SonarV4Config & V3Config) => {
8
- catalog: {
9
- _catalogReferenceFromEntity: (entity: unknown) => import("./interfaces.ts").EnterpriseCatalogReference;
10
- list: () => {
11
- data(): AsyncGenerator<import("./interfaces.ts").EnterpriseFunctionCatalogReference | import("./interfaces.ts").EnterpriseHomeCatalogReference | import("./interfaces.ts").EnterpriseSourceCatalogReference | import("./interfaces.ts").EnterpriseSpaceCatalogReference, void, unknown>;
12
- };
13
- retrieve: (key: string) => Promise<import("ts-results-es").Result<import("./interfaces.ts").EnterpriseCatalogObject, unknown>>;
14
- retrieveByPath: (key: string[]) => Promise<import("ts-results-es").Result<import("./interfaces.ts").EnterpriseCatalogObject, unknown>>;
15
- };
13
+ catalog: EnterpriseCatalogResource;
16
14
  engines: EnginesResource;
17
- jobs: {
18
- create: (query: import("./index.ts").Query) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<string>>;
19
- createAndRetrieve: (query: import("./index.ts").Query) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Job, unknown>>;
20
- observe: (id: string) => import("rxjs").Observable<import("../oss/jobs/Job.ts").JobResult>;
21
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("../oss/jobs/Job.ts").JobResult>;
22
- };
23
- roles: {
24
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Role, unknown>>;
25
- retrieveByName: (name: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Result<import("./interfaces.ts").Role, unknown>>;
26
- };
27
- scripts: {
28
- list(): {
29
- data({ signal }?: import("../common/Params.ts").SignalParam): AsyncGenerator<import("./interfaces.ts").EnterpriseScript, void, unknown>;
30
- };
31
- retrieve: (id: string, { signal }?: import("../common/Params.ts").SignalParam) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseScript>>;
32
- store: (properties: {
33
- name: string;
34
- query: import("./index.ts").Query;
35
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseScript>>;
36
- };
37
- users: {
38
- retrieveById: (id: string, { signal }?: {
39
- signal?: AbortSignal;
40
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseUser>>;
41
- retrieveByName: (name: string, { signal }?: {
42
- signal?: AbortSignal;
43
- }) => Promise<import("ts-results-es").Err<unknown> | import("ts-results-es").Ok<import("./interfaces.ts").EnterpriseUser>>;
44
- };
15
+ jobs: JobsResource;
16
+ roles: RolesResource;
17
+ scripts: EnterpriseScriptsResource;
18
+ users: EnterpriseUsersResource;
45
19
  };
@@ -26,11 +26,11 @@ import { EnginesResource } from "./engines/EnginesResource.js";
26
26
  */
27
27
  export const Resources = (config) => ({
28
28
  ...CommunityResources(config),
29
- catalog: EnterpriseCatalogResource(config),
29
+ catalog: new EnterpriseCatalogResource(config),
30
30
  engines: new EnginesResource(config),
31
- jobs: JobsResource(config),
32
- roles: RolesResource(config),
33
- scripts: EnterpriseScriptsResource(config),
34
- users: EnterpriseUsersResource(config),
31
+ jobs: new JobsResource(config),
32
+ roles: new RolesResource(config),
33
+ scripts: new EnterpriseScriptsResource(config),
34
+ users: new EnterpriseUsersResource(config),
35
35
  });
36
36
  //# sourceMappingURL=resources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/enterprise/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAiF,EACjF,EAAE,CAAC,CAAC;IACJ,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;IAC1B,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC;CACvC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ResourceConfig,\n SonarV2Config,\n SonarV3Config,\n SonarV4Config,\n V3Config,\n} from \"../common/Config.ts\";\nimport { JobsResource } from \"../oss/jobs/JobsResource.ts\";\nimport { Resources as CommunityResources } from \"../oss/resources.ts\";\nimport { EnterpriseCatalogResource } from \"./catalog/EnterpriseCatalogResource.ts\";\nimport { RolesResource } from \"./roles/RolesResource.ts\";\nimport { EnterpriseScriptsResource } from \"./scripts/EnterpriseScriptsResource.ts\";\nimport { EnterpriseUsersResource } from \"./users/EnterpriseUsersResource.ts\";\nimport { EnginesResource } from \"./engines/EnginesResource.ts\";\n\n/**\n * @internal\n * @hidden\n */\nexport const Resources = (\n config: ResourceConfig & SonarV2Config & SonarV3Config & SonarV4Config & V3Config,\n) => ({\n ...CommunityResources(config),\n catalog: EnterpriseCatalogResource(config),\n engines: new EnginesResource(config),\n jobs: JobsResource(config),\n roles: RolesResource(config),\n scripts: EnterpriseScriptsResource(config),\n users: EnterpriseUsersResource(config),\n});\n"]}
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/enterprise/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAiF,EACjF,EAAE,CAAC,CAAC;IACJ,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,IAAI,yBAAyB,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,IAAI,YAAY,CAAC,MAAM,CAAC;IAC9B,KAAK,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,IAAI,yBAAyB,CAAC,MAAM,CAAC;IAC9C,KAAK,EAAE,IAAI,uBAAuB,CAAC,MAAM,CAAC;CAC3C,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 {\n ResourceConfig,\n SonarV2Config,\n SonarV3Config,\n SonarV4Config,\n V3Config,\n} from \"../common/Config.ts\";\nimport { JobsResource } from \"../oss/jobs/JobsResource.ts\";\nimport { Resources as CommunityResources } from \"../oss/resources.ts\";\nimport { EnterpriseCatalogResource } from \"./catalog/EnterpriseCatalogResource.ts\";\nimport { RolesResource } from \"./roles/RolesResource.ts\";\nimport { EnterpriseScriptsResource } from \"./scripts/EnterpriseScriptsResource.ts\";\nimport { EnterpriseUsersResource } from \"./users/EnterpriseUsersResource.ts\";\nimport { EnginesResource } from \"./engines/EnginesResource.ts\";\n\n/**\n * @internal\n * @hidden\n */\nexport const Resources = (\n config: ResourceConfig & SonarV2Config & SonarV3Config & SonarV4Config & V3Config,\n) => ({\n ...CommunityResources(config),\n catalog: new EnterpriseCatalogResource(config),\n engines: new EnginesResource(config),\n jobs: new JobsResource(config),\n roles: new RolesResource(config),\n scripts: new EnterpriseScriptsResource(config),\n users: new EnterpriseUsersResource(config),\n});\n"]}
@@ -1,8 +1,9 @@
1
- import { type Result } from "ts-results-es";
2
1
  import type { SonarV3Config } from "../../common/Config.ts";
3
2
  import { Role } from "./Role.ts";
4
3
  import type { SignalParam } from "../../common/Params.ts";
5
- export declare const RolesResource: (config: SonarV3Config) => {
6
- retrieve: (id: string, { signal }?: SignalParam) => Promise<Result<Role, unknown>>;
7
- retrieveByName: (name: string, { signal }?: SignalParam) => Promise<Result<Role, unknown>>;
8
- };
4
+ export declare class RolesResource {
5
+ #private;
6
+ constructor(config: SonarV3Config);
7
+ retrieve(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<Role, import("../index.ts").HttpError>>;
8
+ retrieveByName(name: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<Role, import("../index.ts").HttpError>>;
9
+ }
@@ -13,20 +13,23 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Err, Ok } from "ts-results-es";
17
16
  import { Role } from "./Role.js";
18
- export const RolesResource = (config) => {
19
- return {
20
- retrieve: (id, { signal } = {}) => config
17
+ export class RolesResource {
18
+ #config;
19
+ constructor(config) {
20
+ this.#config = config;
21
+ }
22
+ retrieve(id, { signal } = {}) {
23
+ return this.#config
21
24
  .sonarV3Request(`role/${id}`, { signal })
22
- .then((res) => res.json())
23
- .then((properties) => Ok(Role.fromResource(properties)))
24
- .catch((e) => Err(e)),
25
- retrieveByName: (name, { signal } = {}) => config
25
+ .map((res) => res.json())
26
+ .map((properties) => Role.fromResource(properties)).promise;
27
+ }
28
+ retrieveByName(name, { signal } = {}) {
29
+ return this.#config
26
30
  .sonarV3Request(`role/by-name/${name}`, { signal })
27
- .then((res) => res.json())
28
- .then((properties) => Ok(Role.fromResource(properties)))
29
- .catch((e) => Err(e)),
30
- };
31
- };
31
+ .map((res) => res.json())
32
+ .map((properties) => Role.fromResource(properties)).promise;
33
+ }
34
+ }
32
35
  //# sourceMappingURL=RolesResource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RolesResource.js","sourceRoot":"","sources":["../../../src/enterprise/roles/RolesResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAE,EAAE;IACrD,OAAO;QACL,QAAQ,EAAE,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE,EAAkC,EAAE,CACrF,MAAM;aACH,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aACxC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACzB,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;aACvD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,cAAc,EAAE,CAAC,IAAY,EAAE,EAAE,MAAM,KAAkB,EAAE,EAAkC,EAAE,CAC7F,MAAM;aACH,cAAc,CAAC,gBAAgB,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;aAClD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACzB,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;aACvD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAC1B,CAAC;AACJ,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 { Err, Ok, type Result } from \"ts-results-es\";\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport { Role } from \"./Role.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\n\nexport const RolesResource = (config: SonarV3Config) => {\n return {\n retrieve: (id: string, { signal }: SignalParam = {}): Promise<Result<Role, unknown>> =>\n config\n .sonarV3Request(`role/${id}`, { signal })\n .then((res) => res.json())\n .then((properties) => Ok(Role.fromResource(properties)))\n .catch((e) => Err(e)),\n retrieveByName: (name: string, { signal }: SignalParam = {}): Promise<Result<Role, unknown>> =>\n config\n .sonarV3Request(`role/by-name/${name}`, { signal })\n .then((res) => res.json())\n .then((properties) => Ok(Role.fromResource(properties)))\n .catch((e) => Err(e)),\n };\n};\n"]}
1
+ {"version":3,"file":"RolesResource.js","sourceRoot":"","sources":["../../../src/enterprise/roles/RolesResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,OAAO,aAAa;IACxB,OAAO,CAAgB;IAEvB,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC/C,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,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,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,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,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,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 } 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 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)).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)).promise;\n }\n}\n"]}
@@ -2,34 +2,24 @@ import type { SonarV3Config } from "../../common/Config.ts";
2
2
  import type { RoleGrantee, UserGrantee } from "../Grantee.ts";
3
3
  import type { Ownable } from "../Ownable.ts";
4
4
  import { Script, type ScriptEntity, type ScriptPatchableProperties } from "../../oss/scripts/Script.ts";
5
- import { Err, Ok } from "ts-results-es";
6
5
  import type { SignalParam } from "../../common/Params.ts";
7
6
  export declare class EnterpriseScript extends Script implements Ownable {
8
7
  #private;
9
8
  readonly owner: UserGrantee;
10
9
  constructor(properties: EnterpriseScriptProperties, config: SonarV3Config);
11
- grants({ signal }?: SignalParam): Promise<Err<unknown> | Ok<({
10
+ grants({ signal }?: SignalParam): Promise<import("ts-results-es").Result<({
12
11
  grantee: RoleGrantee;
13
12
  privileges: Set<ScriptPrivileges>;
14
13
  } | {
15
14
  grantee: UserGrantee;
16
15
  privileges: Set<ScriptPrivileges>;
17
- })[]>>;
16
+ })[], import("../index.ts").HttpError>>;
18
17
  save(properties: ScriptPatchableProperties & {
19
18
  owner?: UserGrantee;
20
- }): Promise<Err<{
21
- readonly errors: [{
22
- readonly detail: "A script with this name already exists";
23
- readonly pointer: "#/name";
24
- readonly type: "https://api.dremio.dev/problems/validation/field-conflict";
25
- readonly value: string;
26
- }];
27
- readonly title: "There was a problem validating the content of the request";
28
- readonly type: "https://api.dremio.dev/problems/validation-problem";
29
- }> | Err<import("../index.ts").Problem> | Ok<EnterpriseScript>>;
19
+ }): Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").ValidationProblem | import("../index.ts").HttpError>>;
30
20
  }
31
21
  export type EnterpriseScriptProperties = ReturnType<typeof enterpriseScriptEntityToProperties>;
32
- type EnterpriseScriptEntity = ScriptEntity & {
22
+ export type EnterpriseScriptEntity = ScriptEntity & {
33
23
  owner?: string;
34
24
  };
35
25
  export declare const enterpriseScriptEntityToProperties: (entity: EnterpriseScriptEntity) => {
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { createScriptPatchedFields, saveScript, Script, scriptEntityToProperties, } from "../../oss/scripts/Script.js";
17
- import { Err, Ok, Result } from "ts-results-es";
18
17
  export class EnterpriseScript extends Script {
19
18
  owner;
20
19
  #config;
@@ -26,8 +25,8 @@ export class EnterpriseScript extends Script {
26
25
  grants({ signal } = {}) {
27
26
  return this.#config
28
27
  .sonarV3Request(`scripts/${this.id}/grants`, { signal })
29
- .then((res) => res.json())
30
- .then((entity) => Ok([
28
+ .map((res) => res.json())
29
+ .map((entity) => [
31
30
  ...entity.roles.map((grant) => ({
32
31
  grantee: {
33
32
  id: grant.granteeId,
@@ -42,14 +41,13 @@ export class EnterpriseScript extends Script {
42
41
  },
43
42
  privileges: new Set(grant.privileges),
44
43
  })),
45
- ]))
46
- .catch((e) => Err(e));
44
+ ]).promise;
47
45
  }
48
46
  async save(properties) {
49
47
  return saveScript(this.id, this.#config)({
50
48
  ...createScriptPatchedFields(properties),
51
49
  ...(properties.owner && { owner: properties.owner.id }),
52
- }).then((result) => result.map((value) => new EnterpriseScript(enterpriseScriptEntityToProperties(value), this.#config)));
50
+ }).map((value) => new EnterpriseScript(enterpriseScriptEntityToProperties(value), this.#config)).promise;
53
51
  }
54
52
  }
55
53
  export const enterpriseScriptEntityToProperties = (entity) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseScript.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,MAAM,EACN,wBAAwB,GAGzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IACjC,KAAK,CAAc;IAC5B,OAAO,CAAgB;IAEvB,YAAY,UAAsC,EAAE,MAAqB;QACvE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,EAAE,MAAM,KAAkB,EAAE;QACjC,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC;aACvD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;aACzB,IAAI,CACH,CAAC,MAGA,EAAE,EAAE,CACH,EAAE,CA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,EAAE,EAAE,MAAM,CAAC,KAAe;QAC1B,IAAI,EAAE,MAAM;KACwB;CACvC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport type { RoleGrantee, UserGrantee } from \"../Grantee.ts\";\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\";\nimport { Err, Ok, Result } from \"ts-results-es\";\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 .then((res) => res.json())\n .then(\n (entity: {\n roles: { granteeId: string; privileges: ScriptPrivileges[] }[];\n users: { granteeId: string; privileges: ScriptPrivileges[] }[];\n }) =>\n Ok([\n ...entity.roles.map((grant) => ({\n grantee: {\n id: grant.granteeId,\n type: \"ROLE\",\n } satisfies RoleGrantee as RoleGrantee,\n privileges: new Set(grant.privileges),\n })),\n ...entity.users.map((grant) => ({\n grantee: {\n id: grant.granteeId,\n type: \"USER\",\n } satisfies UserGrantee as UserGrantee,\n privileges: new Set(grant.privileges),\n })),\n ]),\n )\n .catch((e: unknown) => Err(e));\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 }).then((result) =>\n result.map(\n (value: EnterpriseScriptEntity) =>\n new EnterpriseScript(enterpriseScriptEntityToProperties(value), this.#config),\n ),\n );\n }\n}\n\nexport type EnterpriseScriptProperties = ReturnType<typeof enterpriseScriptEntityToProperties>;\n\ntype EnterpriseScriptEntity = ScriptEntity & { owner?: string };\n\nexport const enterpriseScriptEntityToProperties = (entity: EnterpriseScriptEntity) => ({\n ...scriptEntityToProperties(entity),\n owner: {\n id: entity.owner as string,\n type: \"USER\",\n } satisfies UserGrantee as UserGrantee,\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;AAKH,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;IAEvB,YAAY,UAAsC,EAAE,MAAqB;QACvE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,EAAE,MAAM,KAAkB,EAAE;QACjC,OAAO,IAAI,CAAC,OAAO;aAChB,cAAc,CAAC,WAAW,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC;aACvD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,G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EAAE,MAAM;KACwB;CACvC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport type { RoleGrantee, UserGrantee } from \"../Grantee.ts\";\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: {\n id: grant.granteeId,\n type: \"ROLE\",\n } satisfies RoleGrantee as RoleGrantee,\n privileges: new Set(grant.privileges),\n })),\n ...entity.users.map((grant) => ({\n grantee: {\n id: grant.granteeId,\n type: \"USER\",\n } satisfies UserGrantee as UserGrantee,\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: {\n id: entity.owner as string,\n type: \"USER\",\n } satisfies UserGrantee as UserGrantee,\n});\n\ntype ScriptPrivileges = \"DELETE\" | \"MANAGE_GRANTS\" | \"MODIFY\" | \"VIEW\";\n"]}
@@ -1,15 +1,21 @@
1
1
  import type { ResourceConfig, SonarV3Config } from "../../common/Config.ts";
2
- import { EnterpriseScript } from "./EnterpriseScript.ts";
3
- import { Ok, Err } from "ts-results-es";
4
2
  import type { Query } from "../../common/Query.ts";
5
3
  import type { SignalParam } from "../../common/Params.ts";
6
- export declare const EnterpriseScriptsResource: (config: ResourceConfig & SonarV3Config) => {
4
+ import { EnterpriseScript, type EnterpriseScriptEntity } from "./EnterpriseScript.ts";
5
+ export declare class EnterpriseScriptsResource {
6
+ #private;
7
+ constructor(config: ResourceConfig & SonarV3Config);
8
+ _scriptFromEntity(entity: EnterpriseScriptEntity): EnterpriseScript;
7
9
  list(): {
8
10
  data({ signal }?: SignalParam): AsyncGenerator<EnterpriseScript, void, unknown>;
9
11
  };
10
- retrieve: (id: string, { signal }?: SignalParam) => Promise<Err<unknown> | Ok<EnterpriseScript>>;
11
- store: (properties: {
12
+ retrieve(id: string, { signal }?: SignalParam): Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").HttpError | import("../index.ts").Problem<"https://api.dremio.dev/problems/scripts/not-found", {
13
+ provided: {
14
+ id: string;
15
+ };
16
+ }>>>;
17
+ store(properties: {
12
18
  name: string;
13
19
  query: Query;
14
- }) => Promise<Err<unknown> | Ok<EnterpriseScript>>;
15
- };
20
+ }): Promise<import("ts-results-es").Result<EnterpriseScript, import("../index.ts").ValidationProblem | import("../index.ts").HttpError>>;
21
+ }
@@ -13,60 +13,29 @@
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";
17
- import { Ok, Err } from "ts-results-es";
18
- import { HttpError } from "../../common/HttpError.js";
19
- import { isProblem } from "../../common/Problem.js";
20
- import { duplicateScriptNameError, scriptNotFoundError } from "../../oss/scripts/ScriptErrors.js";
21
- export const EnterpriseScriptsResource = (config) => {
22
- const retrieve = (id, { signal } = {}) => config
23
- .sonarV3Request(`scripts/${id}`, { signal })
24
- .then((res) => res.json())
25
- .then((entity) => Ok(new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config)))
26
- .catch((e) => {
27
- if (e instanceof HttpError && e.status === 404) {
28
- return Err(scriptNotFoundError(id));
29
- }
30
- return Err(e);
31
- });
32
- const store = (properties) => {
33
- const { query, ...rest } = properties;
34
- return config
35
- .sonarV3Request("scripts", {
36
- body: JSON.stringify({
37
- ...rest,
38
- content: query.sql,
39
- context: query.context,
40
- }),
41
- headers: {
42
- "Content-Type": "application/json",
16
+ import { EnterpriseScript, enterpriseScriptEntityToProperties, } from "./EnterpriseScript.js";
17
+ import { listScripts, retrieveScript, storeScript } from "../../oss/scripts/ScriptsResource.js";
18
+ export class EnterpriseScriptsResource {
19
+ #config;
20
+ constructor(config) {
21
+ this.#config = config;
22
+ }
23
+ _scriptFromEntity(entity) {
24
+ return new EnterpriseScript(enterpriseScriptEntityToProperties(entity), this.#config);
25
+ }
26
+ list() {
27
+ const l = listScripts(this.#config, this._scriptFromEntity.bind(this));
28
+ return {
29
+ async *data({ signal } = {}) {
30
+ yield* (await l({ signal })).unwrap();
43
31
  },
44
- keepalive: true,
45
- method: "POST",
46
- })
47
- .then((res) => res.json())
48
- .then((entity) => Ok(new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config)))
49
- .catch((e) => {
50
- if (e instanceof HttpError && isProblem(e.body)) {
51
- if (e.body.detail?.includes("Cannot reuse the same script name"))
52
- return Err(duplicateScriptNameError(properties.name));
53
- }
54
- return Err(e);
55
- });
56
- };
57
- return {
58
- list() {
59
- return {
60
- async *data({ signal } = {}) {
61
- yield* await config
62
- .sonarV3Request("scripts?maxResults=1000", { signal })
63
- .then((res) => res.json())
64
- .then((response) => response.data.map((entity) => new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config)));
65
- },
66
- };
67
- },
68
- retrieve,
69
- store,
70
- };
71
- };
32
+ };
33
+ }
34
+ retrieve(id, { signal } = {}) {
35
+ return retrieveScript(this.#config, this._scriptFromEntity.bind(this))(id, { signal });
36
+ }
37
+ store(properties) {
38
+ return storeScript(this.#config, this._scriptFromEntity.bind(this))(properties);
39
+ }
40
+ }
72
41
  //# sourceMappingURL=EnterpriseScriptsResource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseScriptsResource.js","sourceRoot":"","sources":["../../../src/enterprise/scripts/EnterpriseScriptsResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,gBAAgB,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAElG,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAsC,EAAE,EAAE;IAClF,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE,EAAE,EAAE,CAC5D,MAAM;SACH,cAAc,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,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CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,mCAAmC,CAAC;oBAC9D,OAAO,GAAG,CAAC,wBAAwB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;YACF,OAAO;gBACL,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAkB,EAAE;oBACtC,KAAK,CAAC,CAAC,MAAM,MAAM;yBAChB,cAAc,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,CAAC;yBACrD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;yBACzB,IAAI,CACH,CAAC,QAAQ,EAAE,EAAE,CACX,QAAQ,CAAC,IAAI,CAAC,GAAG,CACf,CAAC,MAAW,EAAE,EAAE,CACd,IAAI,gBAAgB,CAAC,kCAAkC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CACrD,CAC1B,CAAC;gBACN,CAAC;aACF,CAAC;QACJ,CAAC;QACD,QAAQ;QACR,KAAK;KACN,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ResourceConfig, SonarV3Config } from \"../../common/Config.ts\";\nimport { EnterpriseScript, enterpriseScriptEntityToProperties } from \"./EnterpriseScript.ts\";\nimport { Ok, Err } from \"ts-results-es\";\nimport { HttpError } from \"../../common/HttpError.ts\";\nimport { isProblem } from \"../../common/Problem.ts\";\nimport type { Query } from \"../../common/Query.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { duplicateScriptNameError, scriptNotFoundError } from \"../../oss/scripts/ScriptErrors.ts\";\n\nexport const EnterpriseScriptsResource = (config: ResourceConfig & SonarV3Config) => {\n const retrieve = (id: string, { signal }: SignalParam = {}) =>\n config\n .sonarV3Request(`scripts/${id}`, { signal })\n .then((res) => res.json())\n .then((entity) =>\n Ok(new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config)),\n )\n .catch((e: unknown) => {\n if (e instanceof HttpError && e.status === 404) {\n return Err(scriptNotFoundError(id));\n }\n return Err(e);\n });\n\n const store = (properties: { name: string; query: Query }) => {\n const { query, ...rest } = properties;\n return config\n .sonarV3Request(\"scripts\", {\n body: JSON.stringify({\n ...rest,\n content: query.sql,\n context: query.context,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .then((res) => res.json())\n .then((entity) =>\n Ok(new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config)),\n )\n .catch((e: unknown) => {\n if (e instanceof HttpError && isProblem(e.body)) {\n if (e.body.detail?.includes(\"Cannot reuse the same script name\"))\n return Err(duplicateScriptNameError(properties.name));\n }\n return Err(e);\n });\n };\n\n return {\n list() {\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* await config\n .sonarV3Request(\"scripts?maxResults=1000\", { signal })\n .then((res) => res.json())\n .then(\n (response) =>\n response.data.map(\n (entity: any) =>\n new EnterpriseScript(enterpriseScriptEntityToProperties(entity), config),\n ) as EnterpriseScript[],\n );\n },\n };\n },\n retrieve,\n store,\n };\n};\n"]}
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,21 +1,24 @@
1
- import { Err, Ok } from "ts-results-es";
2
1
  import type { V3Config } from "../../common/Config.ts";
3
2
  import type { SignalParam } from "../../common/Params.ts";
4
- import { User } from "../../oss/users/User.ts";
3
+ import { User, type UserEntity } from "../../oss/users/User.ts";
5
4
  import type { RoleReference } from "../roles/Role.ts";
6
5
  export declare class EnterpriseUser extends User {
7
6
  #private;
8
7
  roles: RoleReference[];
9
8
  source: string;
10
9
  constructor(properties: EnterpriseUserProperties, config: V3Config);
11
- tokens({ signal }?: SignalParam): Promise<Err<any> | Ok<{
10
+ tokens({ signal }?: SignalParam): Promise<import("ts-results-es").Result<{
12
11
  createdAt: Date;
13
12
  expiresAt: Date;
14
13
  id: string;
15
14
  label: string;
16
- }[]>>;
15
+ }[], import("../index.ts").HttpError>>;
17
16
  }
18
- export declare const enterpriseUserEntityToProperties: (entity: any) => {
17
+ export type EnterpriseUserEntity = UserEntity & {
18
+ roles: RoleReference[];
19
+ source: string;
20
+ };
21
+ export declare const enterpriseUserEntityToProperties: (entity: EnterpriseUserEntity) => {
19
22
  roles: RoleReference[];
20
23
  source: string;
21
24
  email: string;
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Err, Ok } from "ts-results-es";
17
16
  import { User, userEntityToProperties } from "../../oss/users/User.js";
18
17
  export class EnterpriseUser extends User {
19
18
  #config;
@@ -31,14 +30,13 @@ export class EnterpriseUser extends User {
31
30
  headers: { Accept: "application/json" },
32
31
  signal,
33
32
  })
34
- .then((res) => res.json())
35
- .then((response) => Ok(response.data.map((token) => ({
33
+ .map((res) => res.json())
34
+ .map((response) => response.data.map((token) => ({
36
35
  createdAt: new Date(token.createdAt),
37
36
  expiresAt: new Date(token.expiresAt),
38
37
  id: token.tid,
39
38
  label: token.label,
40
- }))))
41
- .catch((e) => Err(e));
39
+ }))).promise;
42
40
  }
43
41
  }
44
42
  export const enterpriseUserEntityToProperties = (entity) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseUser.js","sourceRoot":"","sources":["../../../src/enterprise/users/EnterpriseUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAavE,MAAM,OAAO,cAAe,SAAQ,IAAI;IACtC,OAAO,CAAW;IAElB,KAAK,CAAkB;IACvB,MA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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 { Err, Ok } from \"ts-results-es\";\nimport type { V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { User, userEntityToProperties } 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\n roles: RoleReference[];\n source: string;\n\n constructor(properties: EnterpriseUserProperties, config: V3Config) {\n super(properties);\n this.#config = config;\n this.roles = properties.roles;\n this.source = properties.source;\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 .then((res) => res.json() as Promise<UserTokensResponse>)\n .then((response) =>\n Ok(\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 ),\n )\n .catch((e) => Err(e));\n }\n}\n\nexport const enterpriseUserEntityToProperties = (entity: any) => ({\n ...userEntityToProperties(entity),\n roles: entity.roles as RoleReference[],\n source: entity.source as string,\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,EAAE,IAAI,EAAE,sBAAsB,EAAmB,MAAM,yBA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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 { User, userEntityToProperties, type UserEntity } 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\n roles: RoleReference[];\n source: string;\n\n constructor(properties: EnterpriseUserProperties, config: V3Config) {\n super(properties);\n this.#config = config;\n this.roles = properties.roles;\n this.source = properties.source;\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 const enterpriseUserEntityToProperties = (entity: EnterpriseUserEntity) => ({\n ...userEntityToProperties(entity),\n roles: entity.roles,\n source: entity.source,\n});\n\nexport type EnterpriseUserProperties = ReturnType<typeof enterpriseUserEntityToProperties>;\n"]}