@dremio/js-sdk 0.47.0 → 0.49.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.
@@ -1,5 +1,5 @@
1
1
  import { AsyncResult } from "ts-results-es";
2
- import type { SonarV2Config, SonarV3Config, XHRConfig } from "../../common/Config.ts";
2
+ import type { SonarV2Config, SonarV3Config, V3Config, XHRConfig } from "../../common/Config.ts";
3
3
  import type { SignalParam } from "../../common/Params.ts";
4
4
  import { baseRetrieve, baseRetrieveByPath } from "../../enterprise/catalog/catalogRetrieve.js";
5
5
  import type { CatalogSearchParams } from "../../enterprise/catalog/catalogSearch/CatalogSearchParams.ts";
@@ -10,7 +10,7 @@ export declare class EnterpriseCatalogResource {
10
10
  #private;
11
11
  retrieve: ReturnType<typeof baseRetrieve>;
12
12
  retrieveByPath: ReturnType<typeof baseRetrieveByPath>;
13
- constructor(config: SonarV2Config & SonarV3Config & XHRConfig);
13
+ constructor(config: SonarV2Config & SonarV3Config & XHRConfig & V3Config);
14
14
  list(): {
15
15
  data(): AsyncGenerator<EnterpriseFunctionCatalogReference | EnterpriseHomeCatalogReference | EnterpriseSourceCatalogReference | EnterpriseSpaceCatalogReference, void, unknown>;
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseCatalogResource.js","sourceRoot":"","sources":["../../../src/cloud/catalog/EnterpriseCatalogResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,4DAA4D,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAC;AACpG,OAAO,EAAE,kCAAkC,EAAE,MAAM,iFAAiF,CAAC;AAOrI,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE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,CAAC;gBAC1D,IAAI,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;oBAC5B,MAAM,eAAe,CAAC,KAAK,CAAC;gBAC9B,CAAC;gBACD,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;gBACxC,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;gBACtB,IAAI,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;gBAC5C,OAAO,aAAa,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;oBACzC,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;oBACnF,IAAI,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC;wBAC3B,MAAM,cAAc,CAAC,KAAK,CAAC;oBAC7B,CAAC;oBACD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC;oBACtC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACrB,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,OAAO;SACR,CAAC;IACJ,CAAC;IAED,2BAA2B,CAAC,MAAe;QACzC,OAAO,8BAA8B,CACnC,kCAAkC,CAAC,MAAM,CAAC,EAC1C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,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 { AsyncResult } from \"ts-results-es\";\nimport type { SonarV2Config, SonarV3Config, XHRConfig } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { catalogReferenceFromProperties } from \"../../enterprise/catalog/catalogReferenceFromProperties.ts\";\nimport { baseRetrieve, baseRetrieveByPath } from \"../../enterprise/catalog/catalogRetrieve.js\";\nimport type { CatalogSearchParams } from \"../../enterprise/catalog/catalogSearch/CatalogSearchParams.ts\";\nimport { createCatalogSearch } from \"../../enterprise/catalog/catalogSearch/createCatalogSearch.js\";\nimport { catalogReferenceEntityToProperties } from \"../../oss/catalog/CatalogReferences/utils/catalogReferenceEntityToProperties.ts\";\nimport type {\n EnterpriseFunctionCatalogReference,\n EnterpriseHomeCatalogReference,\n EnterpriseSourceCatalogReference,\n EnterpriseSpaceCatalogReference,\n} from \"../interfaces.ts\";\nimport { FileUpload, uploadExtensionSchema } from \"./FileUpload.ts\";\nimport * as z from \"zod/mini\";\n\nexport class EnterpriseCatalogResource {\n #config: SonarV2Config & SonarV3Config & XHRConfig;\n #catalogSearch: ReturnType<typeof createCatalogSearch>;\n\n retrieve: ReturnType<typeof baseRetrieve>;\n retrieveByPath: ReturnType<typeof baseRetrieveByPath>;\n\n constructor(config: SonarV2Config & SonarV3Config & XHRConfig) {\n this.#config = config;\n this.retrieve = baseRetrieve(config);\n this.retrieveByPath = baseRetrieveByPath(config);\n this.#catalogSearch = createCatalogSearch(\n this.#config,\n this._catalogReferenceFromEntity.bind(this),\n );\n }\n\n list() {\n const getRoot = () =>\n this.#config\n .sonarV3Request(\"catalog\")\n .map((res) => res.json() as Promise<{ data: unknown[] }>)\n .map((response) =>\n response.data.map(\n (entity: unknown) =>\n catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n ) as\n | EnterpriseFunctionCatalogReference\n | EnterpriseHomeCatalogReference\n | EnterpriseSourceCatalogReference\n | EnterpriseSpaceCatalogReference,\n ),\n )\n .promise.then((result) => result.unwrap());\n return {\n async *data() {\n yield* await getRoot();\n },\n };\n }\n\n copyFromObjectStore({\n extension,\n path,\n sourceName,\n }: {\n extension: z.infer<typeof uploadExtensionSchema>;\n path: string[];\n sourceName: string;\n }) {\n return this.#config\n .sonarV3Request(`uploads/${sourceName}`, {\n body: JSON.stringify({\n extension,\n pathComponents: path,\n }),\n headers: {\n Accept: \"text/plain\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.text())\n .map((id) => new FileUpload(this.#config, id));\n }\n\n upload(fileStream: ReadableStream, extension: z.infer<typeof uploadExtensionSchema>) {\n return new AsyncResult(\n (async () => {\n const body = new FormData();\n body.set(\"file\", await new Response(fileStream).blob());\n body.set(\"extension\", extension);\n\n return this.#config\n .sonarV3Request(\"uploads\", {\n body,\n headers: {\n Accept: \"text/plain\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.text())\n .map((id) => new FileUpload(this.#config, id)).promise;\n })(),\n );\n }\n\n uploadXHR(\n file: Blob,\n extension: z.infer<typeof uploadExtensionSchema>,\n options: { onProgress?: (e: ProgressEvent<XMLHttpRequestEventTarget>) => void } = {},\n ) {\n const body = new FormData();\n body.set(\"file\", file);\n body.set(\"extension\", extension);\n return this.#config\n .xhr(\n \"POST\",\n this.#config.sonarV3URL(\"uploads\").toString(),\n { Accept: \"text/plain\" },\n body,\n (xhr) => {\n if (typeof options.onProgress === \"function\") {\n xhr.upload.addEventListener(\"progress\", options.onProgress);\n }\n },\n )\n .map((xhr) => {\n if (typeof options.onProgress === \"function\") {\n xhr.upload.removeEventListener(\"progress\", options.onProgress);\n }\n return new FileUpload(this.#config, xhr.responseText);\n });\n }\n\n search(params: CatalogSearchParams) {\n const getPage = ({ pageParam, signal }: { pageParam?: string } & SignalParam = {}) =>\n this.#catalogSearch(params, { pageParam, signal });\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n const firstPage = firstPageResult.value;\n yield* firstPage.data;\n let nextPageToken = firstPage.nextPageToken;\n while (nextPageToken && !signal?.aborted) {\n const nextPageResult = await getPage({ pageParam: nextPageToken, signal }).promise;\n if (nextPageResult.isErr()) {\n throw nextPageResult.error;\n }\n const nextPage = nextPageResult.value;\n yield* nextPage.data;\n nextPageToken = nextPage.nextPageToken;\n }\n },\n getPage,\n };\n }\n\n _catalogReferenceFromEntity(entity: unknown) {\n return catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"EnterpriseCatalogResource.js","sourceRoot":"","sources":["../../../src/cloud/catalog/EnterpriseCatalogResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,4DAA4D,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAC;AACpG,OAAO,EAAE,kCAAkC,EAAE,MAAM,iFAAiF,CAAC;AAOrI,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,OAAO,yBAAyB;IACpC,OAAO,CAA4C;IACnD,cAAc,CAAyC;IAEvD,QAAQ,CAAkC;IAC1C,cAAc,CAAwC;IAEtD,YAAY,MAA4D;QACtE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,mBAAmB,CACvC,IAAI,CAAC,OAAO,EACZ,IAAI,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F,IAAI,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC;wBAC3B,MAAM,cAAc,CAAC,KAAK,CAAC;oBAC7B,CAAC;oBACD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC;oBACtC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACrB,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,OAAO;SACR,CAAC;IACJ,CAAC;IAED,2BAA2B,CAAC,MAAe;QACzC,OAAO,8BAA8B,CACnC,kCAAkC,CAAC,MAAM,CAAC,EAC1C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,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 { AsyncResult } from \"ts-results-es\";\nimport type { SonarV2Config, SonarV3Config, V3Config, XHRConfig } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { catalogReferenceFromProperties } from \"../../enterprise/catalog/catalogReferenceFromProperties.ts\";\nimport { baseRetrieve, baseRetrieveByPath } from \"../../enterprise/catalog/catalogRetrieve.js\";\nimport type { CatalogSearchParams } from \"../../enterprise/catalog/catalogSearch/CatalogSearchParams.ts\";\nimport { createCatalogSearch } from \"../../enterprise/catalog/catalogSearch/createCatalogSearch.js\";\nimport { catalogReferenceEntityToProperties } from \"../../oss/catalog/CatalogReferences/utils/catalogReferenceEntityToProperties.ts\";\nimport type {\n EnterpriseFunctionCatalogReference,\n EnterpriseHomeCatalogReference,\n EnterpriseSourceCatalogReference,\n EnterpriseSpaceCatalogReference,\n} from \"../interfaces.ts\";\nimport { FileUpload, uploadExtensionSchema } from \"./FileUpload.ts\";\nimport * as z from \"zod/mini\";\n\nexport class EnterpriseCatalogResource {\n #config: SonarV2Config & SonarV3Config & XHRConfig;\n #catalogSearch: ReturnType<typeof createCatalogSearch>;\n\n retrieve: ReturnType<typeof baseRetrieve>;\n retrieveByPath: ReturnType<typeof baseRetrieveByPath>;\n\n constructor(config: SonarV2Config & SonarV3Config & XHRConfig & V3Config) {\n this.#config = config;\n this.retrieve = baseRetrieve(config);\n this.retrieveByPath = baseRetrieveByPath(config);\n this.#catalogSearch = createCatalogSearch(\n this.#config,\n this._catalogReferenceFromEntity.bind(this),\n );\n }\n\n list() {\n const getRoot = () =>\n this.#config\n .sonarV3Request(\"catalog\")\n .map((res) => res.json() as Promise<{ data: unknown[] }>)\n .map((response) =>\n response.data.map(\n (entity: unknown) =>\n catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n ) as\n | EnterpriseFunctionCatalogReference\n | EnterpriseHomeCatalogReference\n | EnterpriseSourceCatalogReference\n | EnterpriseSpaceCatalogReference,\n ),\n )\n .promise.then((result) => result.unwrap());\n return {\n async *data() {\n yield* await getRoot();\n },\n };\n }\n\n copyFromObjectStore({\n extension,\n path,\n sourceName,\n }: {\n extension: z.infer<typeof uploadExtensionSchema>;\n path: string[];\n sourceName: string;\n }) {\n return this.#config\n .sonarV3Request(`uploads/${sourceName}`, {\n body: JSON.stringify({\n extension,\n pathComponents: path,\n }),\n headers: {\n Accept: \"text/plain\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.text())\n .map((id) => new FileUpload(this.#config, id));\n }\n\n upload(fileStream: ReadableStream, extension: z.infer<typeof uploadExtensionSchema>) {\n return new AsyncResult(\n (async () => {\n const body = new FormData();\n body.set(\"file\", await new Response(fileStream).blob());\n body.set(\"extension\", extension);\n\n return this.#config\n .sonarV3Request(\"uploads\", {\n body,\n headers: {\n Accept: \"text/plain\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.text())\n .map((id) => new FileUpload(this.#config, id)).promise;\n })(),\n );\n }\n\n uploadXHR(\n file: Blob,\n extension: z.infer<typeof uploadExtensionSchema>,\n options: { onProgress?: (e: ProgressEvent<XMLHttpRequestEventTarget>) => void } = {},\n ) {\n const body = new FormData();\n body.set(\"file\", file);\n body.set(\"extension\", extension);\n return this.#config\n .xhr(\n \"POST\",\n this.#config.sonarV3URL(\"uploads\").toString(),\n { Accept: \"text/plain\" },\n body,\n (xhr) => {\n if (typeof options.onProgress === \"function\") {\n xhr.upload.addEventListener(\"progress\", options.onProgress);\n }\n },\n )\n .map((xhr) => {\n if (typeof options.onProgress === \"function\") {\n xhr.upload.removeEventListener(\"progress\", options.onProgress);\n }\n return new FileUpload(this.#config, xhr.responseText);\n });\n }\n\n search(params: CatalogSearchParams) {\n const getPage = ({ pageParam, signal }: { pageParam?: string } & SignalParam = {}) =>\n this.#catalogSearch(params, { pageParam, signal });\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n const firstPage = firstPageResult.value;\n yield* firstPage.data;\n let nextPageToken = firstPage.nextPageToken;\n while (nextPageToken && !signal?.aborted) {\n const nextPageResult = await getPage({ pageParam: nextPageToken, signal }).promise;\n if (nextPageResult.isErr()) {\n throw nextPageResult.error;\n }\n const nextPage = nextPageResult.value;\n yield* nextPage.data;\n nextPageToken = nextPage.nextPageToken;\n }\n },\n getPage,\n };\n }\n\n _catalogReferenceFromEntity(entity: unknown) {\n return catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n );\n }\n}\n"]}
@@ -12,6 +12,14 @@ type UpdateUserParams = {
12
12
  firstName?: string;
13
13
  lastName?: string;
14
14
  };
15
+ type PatchParentRolesParams = {
16
+ addRoles?: string[];
17
+ removeRoles?: string[];
18
+ };
19
+ type PatchParentRolesResponse = {
20
+ addedRoles?: string[];
21
+ removedRoles?: string[];
22
+ };
15
23
  export declare class UsersResource {
16
24
  #private;
17
25
  constructor(config: V3Config);
@@ -39,6 +47,7 @@ export declare class UsersResource {
39
47
  pageToken?: string;
40
48
  }, { signal }?: SignalParam): import("ts-results-es").AsyncResult<Response, import("../index.ts").HttpError>;
41
49
  addParentRole(userId: string, roleId: string, { signal }?: SignalParam): import("ts-results-es").AsyncResult<Response, import("../index.ts").HttpError>;
50
+ patchParentRoles(userId: string, params: PatchParentRolesParams, { signal }?: SignalParam): import("ts-results-es").AsyncResult<PatchParentRolesResponse, import("../index.ts").HttpError>;
42
51
  removeParentRole(userId: string, roleId: string, { signal }?: SignalParam): import("ts-results-es").AsyncResult<Response, import("../index.ts").HttpError>;
43
52
  }
44
53
  export {};
@@ -137,6 +137,19 @@ export class UsersResource {
137
137
  signal,
138
138
  });
139
139
  }
140
+ patchParentRoles(userId, params, { signal } = {}) {
141
+ return this.#config
142
+ .v3Request(`users/${userId}/parent-roles`, {
143
+ body: JSON.stringify(params),
144
+ headers: {
145
+ Accept: "application/json",
146
+ "Content-Type": "application/json",
147
+ },
148
+ method: "PATCH",
149
+ signal,
150
+ })
151
+ .map((res) => res.json());
152
+ }
140
153
  removeParentRole(userId, roleId, { signal } = {}) {
141
154
  return this.#config.v3Request(`users/${userId}/parent-roles/${roleId}`, {
142
155
  method: "DELETE",
@@ -1 +1 @@
1
- {"version":3,"file":"UsersResource.js","sourceRoot":"","sources":["../../../src/cloud/users/UsersResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAoBjC,MAAM,O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,EAAE,EAAE,MAAM,EAAE,CAAC;YACpC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,MAAM;YACd,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,MAAM,iBAAiB,MAAM,EAAE,EAAE;YACtE,MAAM,EAAE,QAAQ;YAChB,MAAM;SACP,CAAC,CAAC;IACL,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 * as z from \"zod/mini\";\nimport type { V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { userPropertiesCodec } from \"./userPropertiesCodec.js\";\nimport { User } from \"./User.ts\";\nimport type { identityTypeSchema } from \"./userPropertiesCodec.js\";\n\ntype PaginatedUserListResponse = {\n data: z.input<typeof userPropertiesCodec>[];\n nextPageToken?: string;\n totalResults: number;\n};\n\ntype CreateUserParams = {\n name: string;\n identityType?: z.output<typeof identityTypeSchema>;\n description?: string;\n};\n\ntype UpdateUserParams = {\n firstName?: string;\n lastName?: string;\n};\n\nexport class UsersResource {\n #config: V3Config;\n\n constructor(config: V3Config) {\n this.#config = config;\n }\n\n list(params?: { filter?: string; maxResults?: number; orderBy?: string }) {\n const buildQuery = (extra?: { pageToken?: string }) => {\n const query = new URLSearchParams();\n if (params?.filter) query.set(\"filter\", params.filter);\n if (params?.maxResults) query.set(\"maxResults\", String(params.maxResults));\n if (params?.orderBy) query.set(\"orderBy\", params.orderBy);\n if (extra?.pageToken) query.set(\"pageToken\", extra.pageToken);\n return query;\n };\n\n const getPage = ({ pageToken, signal }: { pageToken?: string } & SignalParam = {}) =>\n this.#config\n .v3Request(`users?${buildQuery({ pageToken })}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<PaginatedUserListResponse>)\n .map((page) => ({\n ...page,\n data: page.data.map(\n (entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)),\n ),\n }));\n\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n let currentPage = firstPageResult.value;\n yield* currentPage.data;\n while (currentPage.nextPageToken) {\n currentPage = await getPage({\n pageToken: currentPage.nextPageToken,\n signal,\n }).promise.then((result) => result.unwrap());\n yield* currentPage.data;\n }\n },\n getPage,\n };\n }\n\n create(params: CreateUserParams, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(\"users\", {\n body: JSON.stringify(params),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n retrieveById(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/${id}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n retrieveByName(name: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/names/${name}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n update(id: string, params: UpdateUserParams, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/${id}`, {\n body: JSON.stringify(params),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"PUT\",\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n delete(id: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${id}`, {\n method: \"DELETE\",\n signal,\n });\n }\n\n listParentRoles(\n userId: string,\n params?: { maxResults?: number; pageToken?: string },\n { signal }: SignalParam = {},\n ) {\n const query = new URLSearchParams();\n if (params?.maxResults) query.set(\"maxResults\", String(params.maxResults));\n if (params?.pageToken) query.set(\"pageToken\", params.pageToken);\n\n return this.#config.v3Request(`users/${userId}/parent-roles?${query}`, {\n headers: { Accept: \"application/json\" },\n signal,\n });\n }\n\n addParentRole(userId: string, roleId: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${userId}/parent-roles`, {\n body: JSON.stringify({ id: roleId }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n });\n }\n\n removeParentRole(userId: string, roleId: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${userId}/parent-roles/${roleId}`, {\n method: \"DELETE\",\n signal,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"UsersResource.js","sourceRoot":"","sources":["../../../src/cloud/users/UsersResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA8BjC,MAAM,OAAO,aAAa;IACxB,OAAO,CAAW;IAElB,YAAY,MAAgB;QAC1B,IA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AM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,MAAM;YACd,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,MAA8B,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC3F,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,SAAS,MAAM,eAAe,EAAE;YACzC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC5B,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,OAAO;YACf,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAuC,CAAC,CAAC;IACnE,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,MAAM,iBAAiB,MAAM,EAAE,EAAE;YACtE,MAAM,EAAE,QAAQ;YAChB,MAAM;SACP,CAAC,CAAC;IACL,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 * as z from \"zod/mini\";\nimport type { V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { userPropertiesCodec } from \"./userPropertiesCodec.js\";\nimport { User } from \"./User.ts\";\nimport type { identityTypeSchema } from \"./userPropertiesCodec.js\";\n\ntype PaginatedUserListResponse = {\n data: z.input<typeof userPropertiesCodec>[];\n nextPageToken?: string;\n totalResults: number;\n};\n\ntype CreateUserParams = {\n name: string;\n identityType?: z.output<typeof identityTypeSchema>;\n description?: string;\n};\n\ntype UpdateUserParams = {\n firstName?: string;\n lastName?: string;\n};\n\ntype PatchParentRolesParams = {\n addRoles?: string[];\n removeRoles?: string[];\n};\n\ntype PatchParentRolesResponse = {\n addedRoles?: string[];\n removedRoles?: string[];\n};\n\nexport class UsersResource {\n #config: V3Config;\n\n constructor(config: V3Config) {\n this.#config = config;\n }\n\n list(params?: { filter?: string; maxResults?: number; orderBy?: string }) {\n const buildQuery = (extra?: { pageToken?: string }) => {\n const query = new URLSearchParams();\n if (params?.filter) query.set(\"filter\", params.filter);\n if (params?.maxResults) query.set(\"maxResults\", String(params.maxResults));\n if (params?.orderBy) query.set(\"orderBy\", params.orderBy);\n if (extra?.pageToken) query.set(\"pageToken\", extra.pageToken);\n return query;\n };\n\n const getPage = ({ pageToken, signal }: { pageToken?: string } & SignalParam = {}) =>\n this.#config\n .v3Request(`users?${buildQuery({ pageToken })}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<PaginatedUserListResponse>)\n .map((page) => ({\n ...page,\n data: page.data.map(\n (entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)),\n ),\n }));\n\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n let currentPage = firstPageResult.value;\n yield* currentPage.data;\n while (currentPage.nextPageToken) {\n currentPage = await getPage({\n pageToken: currentPage.nextPageToken,\n signal,\n }).promise.then((result) => result.unwrap());\n yield* currentPage.data;\n }\n },\n getPage,\n };\n }\n\n create(params: CreateUserParams, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(\"users\", {\n body: JSON.stringify(params),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n retrieveById(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/${id}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n retrieveByName(name: string, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/names/${name}`, {\n headers: { Accept: \"application/json\" },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n update(id: string, params: UpdateUserParams, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/${id}`, {\n body: JSON.stringify(params),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"PUT\",\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof userPropertiesCodec>>)\n .map((entity) => new User(this.#config, z.decode(userPropertiesCodec, entity)));\n }\n\n delete(id: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${id}`, {\n method: \"DELETE\",\n signal,\n });\n }\n\n listParentRoles(\n userId: string,\n params?: { maxResults?: number; pageToken?: string },\n { signal }: SignalParam = {},\n ) {\n const query = new URLSearchParams();\n if (params?.maxResults) query.set(\"maxResults\", String(params.maxResults));\n if (params?.pageToken) query.set(\"pageToken\", params.pageToken);\n\n return this.#config.v3Request(`users/${userId}/parent-roles?${query}`, {\n headers: { Accept: \"application/json\" },\n signal,\n });\n }\n\n addParentRole(userId: string, roleId: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${userId}/parent-roles`, {\n body: JSON.stringify({ id: roleId }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n });\n }\n\n patchParentRoles(userId: string, params: PatchParentRolesParams, { signal }: SignalParam = {}) {\n return this.#config\n .v3Request(`users/${userId}/parent-roles`, {\n body: JSON.stringify(params),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"PATCH\",\n signal,\n })\n .map((res) => res.json() as Promise<PatchParentRolesResponse>);\n }\n\n removeParentRole(userId: string, roleId: string, { signal }: SignalParam = {}) {\n return this.#config.v3Request(`users/${userId}/parent-roles/${roleId}`, {\n method: \"DELETE\",\n signal,\n });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { SonarV3Config } from "../../common/Config.ts";
1
+ import type { SonarV3Config, V3Config } from "../../common/Config.ts";
2
2
  import type { SignalParam } from "../../common/Params.ts";
3
3
  import type { EnterpriseFunctionCatalogReference, EnterpriseHomeCatalogReference, EnterpriseSourceCatalogReference, EnterpriseSpaceCatalogReference } from "./CatalogReferences/index.ts";
4
4
  import { baseRetrieve, baseRetrieveByPath } from "./catalogRetrieve.ts";
@@ -7,7 +7,7 @@ export declare class EnterpriseCatalogResource {
7
7
  #private;
8
8
  retrieve: ReturnType<typeof baseRetrieve>;
9
9
  retrieveByPath: ReturnType<typeof baseRetrieveByPath>;
10
- constructor(config: SonarV3Config);
10
+ constructor(config: SonarV3Config & V3Config);
11
11
  list(): {
12
12
  data(): AsyncGenerator<EnterpriseFunctionCatalogReference | EnterpriseHomeCatalogReference | EnterpriseSourceCatalogReference | EnterpriseSpaceCatalogReference, void, unknown>;
13
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EnterpriseCatalogResource.js","sourceRoot":"","sources":["../../../src/enterprise/catalog/EnterpriseCatalogResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,kCAAkC,EAAE,MAAM,iFAAiF,CAAC;AACrI,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAOrF,OAAO,EAAE,YAAY,EAA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you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { catalogReferenceEntityToProperties } from \"../../oss/catalog/CatalogReferences/utils/catalogReferenceEntityToProperties.ts\";\nimport { catalogReferenceFromProperties } from \"./catalogReferenceFromProperties.ts\";\nimport type {\n EnterpriseFunctionCatalogReference,\n EnterpriseHomeCatalogReference,\n EnterpriseSourceCatalogReference,\n EnterpriseSpaceCatalogReference,\n} from \"./CatalogReferences/index.ts\";\nimport { baseRetrieve, baseRetrieveByPath } from \"./catalogRetrieve.ts\";\nimport type { CatalogSearchParams } from \"./catalogSearch/CatalogSearchParams.ts\";\nimport { createCatalogSearch } from \"./catalogSearch/createCatalogSearch.ts\";\n\nexport class EnterpriseCatalogResource {\n #config: SonarV3Config;\n #catalogSearch: ReturnType<typeof createCatalogSearch>;\n\n retrieve: ReturnType<typeof baseRetrieve>;\n retrieveByPath: ReturnType<typeof baseRetrieveByPath>;\n\n constructor(config: SonarV3Config) {\n this.#config = config;\n this.retrieve = baseRetrieve(config);\n this.retrieveByPath = baseRetrieveByPath(config);\n this.#catalogSearch = createCatalogSearch(\n this.#config,\n this._catalogReferenceFromEntity.bind(this),\n );\n }\n\n list() {\n const getRoot = () =>\n this.#config\n .sonarV3Request(\"catalog\")\n .map((res) => res.json() as Promise<{ data: unknown[] }>)\n .map((response) =>\n response.data.map(\n (entity: unknown) =>\n catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n ) as\n | EnterpriseFunctionCatalogReference\n | EnterpriseHomeCatalogReference\n | EnterpriseSourceCatalogReference\n | EnterpriseSpaceCatalogReference,\n ),\n )\n .promise.then((result) => result.unwrap());\n return {\n async *data() {\n yield* await getRoot();\n },\n };\n }\n\n search(params: CatalogSearchParams) {\n const getPage = ({ pageParam, signal }: { pageParam?: string } & SignalParam = {}) =>\n this.#catalogSearch(params, { pageParam, signal });\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n const firstPage = firstPageResult.value;\n yield* firstPage.data;\n let nextPageToken = firstPage.nextPageToken;\n while (nextPageToken && !signal?.aborted) {\n const nextPageResult = await getPage({ pageParam: nextPageToken, signal }).promise;\n if (nextPageResult.isErr()) {\n throw nextPageResult.error;\n }\n const nextPage = nextPageResult.value;\n yield* nextPage.data;\n nextPageToken = nextPage.nextPageToken;\n }\n },\n getPage,\n };\n }\n\n _catalogReferenceFromEntity(entity: unknown) {\n return catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"EnterpriseCatalogResource.js","sourceRoot":"","sources":["../../../src/enterprise/catalog/EnterpriseCatalogResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,kCAAkC,EAAE,MAAM,iFAAiF,CAAC;AACrI,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAOrF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,OAAO,yBAAyB;IACpC,OAAO,CAAgB;IACvB,cAAc,CAAyC;IAEvD,QAAQ,CAAkC;IAC1C,cAAc,CAAwC;IAEtD,YAAY,MAAgC;QAC1C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,C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AC5B,MAAM,eAAe,CAAC,KAAK,CAAC;gBAC9B,CAAC;gBACD,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;gBACxC,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;gBACtB,IAAI,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;gBAC5C,OAAO,aAAa,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;oBACzC,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;oBACnF,IAAI,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC;wBAC3B,MAAM,cAAc,CAAC,KAAK,CAAC;oBAC7B,CAAC;oBACD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC;oBACtC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACrB,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,OAAO;SACR,CAAC;IACJ,CAAC;IAED,2BAA2B,CAAC,MAAe;QACzC,OAAO,8BAA8B,CACnC,kCAAkC,CAAC,MAAM,CAAC,EAC1C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,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, V3Config } from \"../../common/Config.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { catalogReferenceEntityToProperties } from \"../../oss/catalog/CatalogReferences/utils/catalogReferenceEntityToProperties.ts\";\nimport { catalogReferenceFromProperties } from \"./catalogReferenceFromProperties.ts\";\nimport type {\n EnterpriseFunctionCatalogReference,\n EnterpriseHomeCatalogReference,\n EnterpriseSourceCatalogReference,\n EnterpriseSpaceCatalogReference,\n} from \"./CatalogReferences/index.ts\";\nimport { baseRetrieve, baseRetrieveByPath } from \"./catalogRetrieve.ts\";\nimport type { CatalogSearchParams } from \"./catalogSearch/CatalogSearchParams.ts\";\nimport { createCatalogSearch } from \"./catalogSearch/createCatalogSearch.ts\";\n\nexport class EnterpriseCatalogResource {\n #config: SonarV3Config;\n #catalogSearch: ReturnType<typeof createCatalogSearch>;\n\n retrieve: ReturnType<typeof baseRetrieve>;\n retrieveByPath: ReturnType<typeof baseRetrieveByPath>;\n\n constructor(config: SonarV3Config & V3Config) {\n this.#config = config;\n this.retrieve = baseRetrieve(config);\n this.retrieveByPath = baseRetrieveByPath(config);\n this.#catalogSearch = createCatalogSearch(\n this.#config,\n this._catalogReferenceFromEntity.bind(this),\n );\n }\n\n list() {\n const getRoot = () =>\n this.#config\n .sonarV3Request(\"catalog\")\n .map((res) => res.json() as Promise<{ data: unknown[] }>)\n .map((response) =>\n response.data.map(\n (entity: unknown) =>\n catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n ) as\n | EnterpriseFunctionCatalogReference\n | EnterpriseHomeCatalogReference\n | EnterpriseSourceCatalogReference\n | EnterpriseSpaceCatalogReference,\n ),\n )\n .promise.then((result) => result.unwrap());\n return {\n async *data() {\n yield* await getRoot();\n },\n };\n }\n\n search(params: CatalogSearchParams) {\n const getPage = ({ pageParam, signal }: { pageParam?: string } & SignalParam = {}) =>\n this.#catalogSearch(params, { pageParam, signal });\n return {\n async *data({ signal }: SignalParam = {}) {\n const firstPageResult = await getPage({ signal }).promise;\n if (firstPageResult.isErr()) {\n throw firstPageResult.error;\n }\n const firstPage = firstPageResult.value;\n yield* firstPage.data;\n let nextPageToken = firstPage.nextPageToken;\n while (nextPageToken && !signal?.aborted) {\n const nextPageResult = await getPage({ pageParam: nextPageToken, signal }).promise;\n if (nextPageResult.isErr()) {\n throw nextPageResult.error;\n }\n const nextPage = nextPageResult.value;\n yield* nextPage.data;\n nextPageToken = nextPage.nextPageToken;\n }\n },\n getPage,\n };\n }\n\n _catalogReferenceFromEntity(entity: unknown) {\n return catalogReferenceFromProperties(\n catalogReferenceEntityToProperties(entity),\n this.#config,\n this.retrieveByPath,\n );\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type Result } from "ts-results-es";
2
- import type { SonarV3Config } from "../../common/Config.ts";
2
+ import type { SonarV3Config, V3Config } from "../../common/Config.ts";
3
3
  import type { EnterpriseCatalogObject } from "./CatalogObjects/index.ts";
4
- export declare const baseRetrieve: (config: SonarV3Config) => (key: string) => Promise<Result<EnterpriseCatalogObject, unknown>>;
5
- export declare const baseRetrieveByPath: (config: SonarV3Config) => (key: string[]) => Promise<Result<EnterpriseCatalogObject, unknown>>;
4
+ export declare const baseRetrieve: (config: SonarV3Config & V3Config) => (key: string) => Promise<Result<EnterpriseCatalogObject, unknown>>;
5
+ export declare const baseRetrieveByPath: (config: SonarV3Config & V3Config) => (key: string[]) => Promise<Result<EnterpriseCatalogObject, unknown>>;
@@ -18,106 +18,126 @@ import { Err, Ok } from "ts-results-es";
18
18
  import { catalogObjectFromEntity } from "./catalogObjectFromEntity.js";
19
19
  import { HttpError } from "../../common/HttpError.js";
20
20
  import { unableToRetrieveProblem } from "../../oss/catalog/catalogErrors.js";
21
- export const baseRetrieve = (config) => batch(async (ids) => {
22
- const results = new Map();
23
- if (ids.size === 1) {
24
- const id = Array.from(ids).at(0);
25
- return config
26
- .sonarV3Request(`catalog/${id}?maxChildren=0`)
21
+ import { retrieveEnvironment } from "../../oss/retrieveEnvironment.js";
22
+ // Cache by config reference to avoid redundant environment fetches.
23
+ const versionPromiseCache = new WeakMap();
24
+ const getVersionPromise = (config) => {
25
+ if (!versionPromiseCache.has(config)) {
26
+ versionPromiseCache.set(config, retrieveEnvironment(config)
27
27
  .promise.then((result) => result.unwrap())
28
- .then((res) => res.json())
29
- .then((response) => {
30
- results.set(id, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)));
31
- return results;
28
+ .then((env) => env.version)
29
+ .catch(() => ({ major: 26 })));
30
+ }
31
+ return versionPromiseCache.get(config);
32
+ };
33
+ export const baseRetrieve = (config) => {
34
+ const versionPromise = getVersionPromise(config);
35
+ return batch(async (ids) => {
36
+ const results = new Map();
37
+ const maxChildren = (await versionPromise).major < 26 ? 1 : 0;
38
+ if (ids.size === 1) {
39
+ const id = Array.from(ids).at(0);
40
+ return config
41
+ .sonarV3Request(`catalog/${id}?maxChildren=${maxChildren}`)
42
+ .promise.then((result) => result.unwrap())
43
+ .then((res) => res.json())
44
+ .then((response) => {
45
+ results.set(id, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)));
46
+ return results;
47
+ })
48
+ .catch((e) => {
49
+ if (e instanceof HttpError && e.body?.detail) {
50
+ results.set(id, Err(unableToRetrieveProblem(e.body.detail)));
51
+ }
52
+ else {
53
+ results.set(id, Err(unableToRetrieveProblem()));
54
+ }
55
+ return results;
56
+ });
57
+ }
58
+ const idsArray = Array.from(ids);
59
+ const chunks = [];
60
+ while (idsArray.length > 0) {
61
+ chunks.push(idsArray.splice(0, Math.min(50, idsArray.length)));
62
+ }
63
+ const catalogItems = await Promise.all(chunks.map((chunk) => config
64
+ .sonarV3Request(`catalog/by-ids?maxChildren=${maxChildren}`, {
65
+ body: JSON.stringify(chunk),
66
+ headers: { "Content-Type": "application/json" },
67
+ method: "POST",
32
68
  })
33
- .catch((e) => {
34
- if (e instanceof HttpError && e.body?.detail) {
35
- results.set(id, Err(unableToRetrieveProblem(e.body.detail)));
36
- }
37
- else {
69
+ .promise.then((result) => result.unwrap())
70
+ .then((res) => res.json())
71
+ .then((response) => response.data))).then((chunks) => chunks.flat());
72
+ for (const catalogItem of catalogItems) {
73
+ results.set(catalogItem.id, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem)));
74
+ }
75
+ for (const id of ids) {
76
+ if (!results.has(id)) {
38
77
  results.set(id, Err(unableToRetrieveProblem()));
39
78
  }
40
- return results;
41
- });
42
- }
43
- const idsArray = Array.from(ids);
44
- const chunks = [];
45
- while (idsArray.length > 0) {
46
- chunks.push(idsArray.splice(0, Math.min(50, idsArray.length)));
47
- }
48
- const catalogItems = await Promise.all(chunks.map((chunk) => config
49
- .sonarV3Request(`catalog/by-ids?maxChildren=0`, {
50
- body: JSON.stringify(chunk),
51
- headers: { "Content-Type": "application/json" },
52
- method: "POST",
53
- })
54
- .promise.then((result) => result.unwrap())
55
- .then((res) => res.json())
56
- .then((response) => response.data))).then((chunks) => chunks.flat());
57
- for (const catalogItem of catalogItems) {
58
- results.set(catalogItem.id, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem)));
59
- }
60
- for (const id of ids) {
61
- if (!results.has(id)) {
62
- results.set(id, Err(unableToRetrieveProblem()));
63
79
  }
64
- }
65
- return results;
66
- });
67
- export const baseRetrieveByPath = (config) => batch(async (paths) => {
68
- const results = new Map();
69
- // Because the key is a reference type (array), we need to store the
70
- // original path reference
71
- const originalKeyRef = new Map();
72
- for (const key of paths) {
73
- originalKeyRef.set(JSON.stringify(key), key);
74
- }
75
- if (paths.size === 1) {
76
- const path = Array.from(paths).at(0);
77
- return config
78
- .sonarV3Request(`catalog/by-path/${path.map(encodeURIComponent).join("/")}?maxChildren=0`)
80
+ return results;
81
+ });
82
+ };
83
+ export const baseRetrieveByPath = (config) => {
84
+ const versionPromise = getVersionPromise(config);
85
+ return batch(async (paths) => {
86
+ const results = new Map();
87
+ const maxChildren = (await versionPromise).major < 26 ? 1 : 0;
88
+ // Because the key is a reference type (array), we need to store the
89
+ // original path reference
90
+ const originalKeyRef = new Map();
91
+ for (const key of paths) {
92
+ originalKeyRef.set(JSON.stringify(key), key);
93
+ }
94
+ if (paths.size === 1) {
95
+ const path = Array.from(paths).at(0);
96
+ return config
97
+ .sonarV3Request(`catalog/by-path/${path.map(encodeURIComponent).join("/")}?maxChildren=${maxChildren}`)
98
+ .promise.then((result) => result.unwrap())
99
+ .then((res) => res.json())
100
+ .then((response) => {
101
+ results.set(path, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)));
102
+ return results;
103
+ })
104
+ .catch((e) => {
105
+ if (e instanceof HttpError && e.body?.detail) {
106
+ results.set(path, Err(unableToRetrieveProblem(e.body.detail)));
107
+ }
108
+ else {
109
+ results.set(path, Err(unableToRetrieveProblem()));
110
+ }
111
+ return results;
112
+ });
113
+ }
114
+ const pathsArray = Array.from(paths);
115
+ const chunks = [];
116
+ while (pathsArray.length > 0) {
117
+ chunks.push(pathsArray.splice(0, Math.min(50, pathsArray.length)));
118
+ }
119
+ const catalogItems = await Promise.all(chunks.map((chunk) => config
120
+ .sonarV3Request(`catalog/by-paths?maxChildren=${maxChildren}`, {
121
+ body: JSON.stringify(chunk),
122
+ headers: { "Content-Type": "application/json" },
123
+ method: "POST",
124
+ })
79
125
  .promise.then((result) => result.unwrap())
80
126
  .then((res) => res.json())
81
- .then((response) => {
82
- results.set(path, Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)));
83
- return results;
84
- })
85
- .catch((e) => {
86
- if (e instanceof HttpError && e.body?.detail) {
87
- results.set(path, Err(unableToRetrieveProblem(e.body.detail)));
127
+ .then((response) => response.data))).then((chunks) => chunks.flat());
128
+ for (const catalogItem of catalogItems) {
129
+ const resolved = catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem);
130
+ const originalKey = originalKeyRef.get(JSON.stringify(resolved.path));
131
+ if (originalKey) {
132
+ results.set(originalKey, Ok(resolved));
88
133
  }
89
- else {
134
+ }
135
+ for (const path of paths) {
136
+ if (!results.has(path)) {
90
137
  results.set(path, Err(unableToRetrieveProblem()));
91
138
  }
92
- return results;
93
- });
94
- }
95
- const pathsArray = Array.from(paths);
96
- const chunks = [];
97
- while (pathsArray.length > 0) {
98
- chunks.push(pathsArray.splice(0, Math.min(50, pathsArray.length)));
99
- }
100
- const catalogItems = await Promise.all(chunks.map((chunk) => config
101
- .sonarV3Request(`catalog/by-paths?maxChildren=0`, {
102
- body: JSON.stringify(chunk),
103
- headers: { "Content-Type": "application/json" },
104
- method: "POST",
105
- })
106
- .promise.then((result) => result.unwrap())
107
- .then((res) => res.json())
108
- .then((response) => response.data))).then((chunks) => chunks.flat());
109
- for (const catalogItem of catalogItems) {
110
- const resolved = catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem);
111
- const originalKey = originalKeyRef.get(JSON.stringify(resolved.path));
112
- if (originalKey) {
113
- results.set(originalKey, Ok(resolved));
114
139
  }
115
- }
116
- for (const path of paths) {
117
- if (!results.has(path)) {
118
- results.set(path, Err(unableToRetrieveProblem()));
119
- }
120
- }
121
- return results;
122
- });
140
+ return results;
141
+ });
142
+ };
123
143
  //# sourceMappingURL=catalogRetrieve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalogRetrieve.js","sourceRoot":"","sources":["../../../src/enterprise/catalog/catalogRetrieve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAqB,EAAE,EAAE,CACpD,KAAK,CAAC,KAAK,EAAE,GAAgB,EAAE,EAAE;IAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoD,CAAC;IAE5E,IAA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AY,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAC1F,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,QAAQ,CAAQ,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,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 { batch } from \"../../common/batch.ts\";\nimport { Err, Ok, type Result } from \"ts-results-es\";\nimport type { SonarV3Config } from \"../../common/Config.ts\";\nimport { catalogObjectFromEntity } from \"./catalogObjectFromEntity.ts\";\nimport { HttpError } from \"../../common/HttpError.ts\";\nimport type { EnterpriseCatalogObject } from \"./CatalogObjects/index.ts\";\nimport { unableToRetrieveProblem } from \"../../oss/catalog/catalogErrors.ts\";\n\nexport const baseRetrieve = (config: SonarV3Config) =>\n batch(async (ids: Set<string>) => {\n const results = new Map<string, Result<EnterpriseCatalogObject, unknown>>();\n\n if (ids.size === 1) {\n const id = Array.from(ids).at(0)!;\n return config\n .sonarV3Request(`catalog/${id}?maxChildren=0`)\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => {\n results.set(\n id,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response) as any),\n );\n return results;\n })\n .catch((e) => {\n if (e instanceof HttpError && (e.body as any)?.detail) {\n results.set(id, Err(unableToRetrieveProblem((e.body as any).detail)));\n } else {\n results.set(id, Err(unableToRetrieveProblem()));\n }\n\n return results;\n });\n }\n\n const idsArray = Array.from(ids);\n const chunks = [];\n\n while (idsArray.length > 0) {\n chunks.push(idsArray.splice(0, Math.min(50, idsArray.length)));\n }\n\n const catalogItems = await Promise.all(\n chunks.map((chunk) =>\n config\n .sonarV3Request(`catalog/by-ids?maxChildren=0`, {\n body: JSON.stringify(chunk),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n })\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => response.data),\n ),\n ).then((chunks) => chunks.flat());\n\n for (const catalogItem of catalogItems) {\n results.set(\n catalogItem.id,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem) as any),\n );\n }\n\n for (const id of ids) {\n if (!results.has(id)) {\n results.set(id, Err(unableToRetrieveProblem()));\n }\n }\n\n return results;\n });\n\nexport const baseRetrieveByPath = (config: SonarV3Config) =>\n batch(async (paths: Set<string[]>) => {\n const results = new Map<string[], Result<EnterpriseCatalogObject, unknown>>();\n\n // Because the key is a reference type (array), we need to store the\n // original path reference\n const originalKeyRef = new Map<string, string[]>();\n for (const key of paths) {\n originalKeyRef.set(JSON.stringify(key), key);\n }\n\n if (paths.size === 1) {\n const path = Array.from(paths).at(0)!;\n return config\n .sonarV3Request(`catalog/by-path/${path.map(encodeURIComponent).join(\"/\")}?maxChildren=0`)\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => {\n results.set(\n path,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)) as any,\n );\n return results;\n })\n .catch((e) => {\n if (e instanceof HttpError && (e.body as any)?.detail) {\n results.set(path, Err(unableToRetrieveProblem((e.body as any).detail)));\n } else {\n results.set(path, Err(unableToRetrieveProblem()));\n }\n return results;\n });\n }\n\n const pathsArray = Array.from(paths);\n const chunks = [];\n\n while (pathsArray.length > 0) {\n chunks.push(pathsArray.splice(0, Math.min(50, pathsArray.length)));\n }\n\n const catalogItems = await Promise.all(\n chunks.map((chunk) =>\n config\n .sonarV3Request(`catalog/by-paths?maxChildren=0`, {\n body: JSON.stringify(chunk),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n })\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => response.data),\n ),\n ).then((chunks) => chunks.flat());\n\n for (const catalogItem of catalogItems) {\n const resolved = catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem);\n const originalKey = originalKeyRef.get(JSON.stringify(resolved.path));\n if (originalKey) {\n results.set(originalKey, Ok(resolved) as any);\n }\n }\n\n for (const path of paths) {\n if (!results.has(path)) {\n results.set(path, Err(unableToRetrieveProblem()));\n }\n }\n\n return results;\n });\n"]}
1
+ {"version":3,"file":"catalogRetrieve.js","sourceRoot":"","sources":["../../../src/enterprise/catalog/catalogRetrieve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAA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,CAAC;QAElC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;YAC1F,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YACtE,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,QAAQ,CAAQ,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,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 { batch } from \"../../common/batch.ts\";\nimport { Err, Ok, type Result } from \"ts-results-es\";\nimport type { SonarV3Config, V3Config } from \"../../common/Config.ts\";\nimport { catalogObjectFromEntity } from \"./catalogObjectFromEntity.ts\";\nimport { HttpError } from \"../../common/HttpError.ts\";\nimport type { EnterpriseCatalogObject } from \"./CatalogObjects/index.ts\";\nimport { unableToRetrieveProblem } from \"../../oss/catalog/catalogErrors.ts\";\nimport { retrieveEnvironment } from \"../../oss/retrieveEnvironment.ts\";\nimport type { SemVer } from \"semver\";\n\n// Cache by config reference to avoid redundant environment fetches.\nconst versionPromiseCache = new WeakMap<object, Promise<SemVer>>();\n\nconst getVersionPromise = (config: SonarV3Config & V3Config): Promise<SemVer> => {\n if (!versionPromiseCache.has(config)) {\n versionPromiseCache.set(\n config,\n retrieveEnvironment(config)\n .promise.then((result) => result.unwrap())\n .then((env) => env.version)\n .catch(() => ({ major: 26 }) as SemVer),\n );\n }\n return versionPromiseCache.get(config)!;\n};\n\nexport const baseRetrieve = (config: SonarV3Config & V3Config) => {\n const versionPromise = getVersionPromise(config);\n\n return batch(async (ids: Set<string>) => {\n const results = new Map<string, Result<EnterpriseCatalogObject, unknown>>();\n\n const maxChildren = (await versionPromise).major < 26 ? 1 : 0;\n\n if (ids.size === 1) {\n const id = Array.from(ids).at(0)!;\n return config\n .sonarV3Request(`catalog/${id}?maxChildren=${maxChildren}`)\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => {\n results.set(\n id,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response) as any),\n );\n return results;\n })\n .catch((e) => {\n if (e instanceof HttpError && (e.body as any)?.detail) {\n results.set(id, Err(unableToRetrieveProblem((e.body as any).detail)));\n } else {\n results.set(id, Err(unableToRetrieveProblem()));\n }\n\n return results;\n });\n }\n\n const idsArray = Array.from(ids);\n const chunks = [];\n\n while (idsArray.length > 0) {\n chunks.push(idsArray.splice(0, Math.min(50, idsArray.length)));\n }\n\n const catalogItems = await Promise.all(\n chunks.map((chunk) =>\n config\n .sonarV3Request(`catalog/by-ids?maxChildren=${maxChildren}`, {\n body: JSON.stringify(chunk),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n })\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => response.data),\n ),\n ).then((chunks) => chunks.flat());\n\n for (const catalogItem of catalogItems) {\n results.set(\n catalogItem.id,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem) as any),\n );\n }\n\n for (const id of ids) {\n if (!results.has(id)) {\n results.set(id, Err(unableToRetrieveProblem()));\n }\n }\n\n return results;\n });\n};\n\nexport const baseRetrieveByPath = (config: SonarV3Config & V3Config) => {\n const versionPromise = getVersionPromise(config);\n\n return batch(async (paths: Set<string[]>) => {\n const results = new Map<string[], Result<EnterpriseCatalogObject, unknown>>();\n\n const maxChildren = (await versionPromise).major < 26 ? 1 : 0;\n\n // Because the key is a reference type (array), we need to store the\n // original path reference\n const originalKeyRef = new Map<string, string[]>();\n for (const key of paths) {\n originalKeyRef.set(JSON.stringify(key), key);\n }\n\n if (paths.size === 1) {\n const path = Array.from(paths).at(0)!;\n return config\n .sonarV3Request(\n `catalog/by-path/${path.map(encodeURIComponent).join(\"/\")}?maxChildren=${maxChildren}`,\n )\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => {\n results.set(\n path,\n Ok(catalogObjectFromEntity(config, baseRetrieveByPath(config))(response)) as any,\n );\n return results;\n })\n .catch((e) => {\n if (e instanceof HttpError && (e.body as any)?.detail) {\n results.set(path, Err(unableToRetrieveProblem((e.body as any).detail)));\n } else {\n results.set(path, Err(unableToRetrieveProblem()));\n }\n return results;\n });\n }\n\n const pathsArray = Array.from(paths);\n const chunks = [];\n\n while (pathsArray.length > 0) {\n chunks.push(pathsArray.splice(0, Math.min(50, pathsArray.length)));\n }\n\n const catalogItems = await Promise.all(\n chunks.map((chunk) =>\n config\n .sonarV3Request(`catalog/by-paths?maxChildren=${maxChildren}`, {\n body: JSON.stringify(chunk),\n headers: { \"Content-Type\": \"application/json\" },\n method: \"POST\",\n })\n .promise.then((result) => result.unwrap())\n .then((res) => res.json())\n .then((response) => response.data),\n ),\n ).then((chunks) => chunks.flat());\n\n for (const catalogItem of catalogItems) {\n const resolved = catalogObjectFromEntity(config, baseRetrieveByPath(config))(catalogItem);\n const originalKey = originalKeyRef.get(JSON.stringify(resolved.path));\n if (originalKey) {\n results.set(originalKey, Ok(resolved) as any);\n }\n }\n\n for (const path of paths) {\n if (!results.has(path)) {\n results.set(path, Err(unableToRetrieveProblem()));\n }\n }\n\n return results;\n });\n};\n"]}