@resolution/organizations-api-client 0.14.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 (75) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +110 -0
  3. package/lib/index.d.ts +39 -0
  4. package/lib/index.js +46 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/openapi/core/CommonHttpClient.d.ts +316 -0
  7. package/lib/openapi/core/CommonHttpClient.js +639 -0
  8. package/lib/openapi/core/CommonHttpClient.js.map +1 -0
  9. package/lib/openapi/core/CommonHttpService.d.ts +26 -0
  10. package/lib/openapi/core/CommonHttpService.js +40 -0
  11. package/lib/openapi/core/CommonHttpService.js.map +1 -0
  12. package/lib/openapi/core/CommonValidationSchemaStorage.d.ts +35 -0
  13. package/lib/openapi/core/CommonValidationSchemaStorage.js +63 -0
  14. package/lib/openapi/core/CommonValidationSchemaStorage.js.map +1 -0
  15. package/lib/openapi/organizations/BaseOrganizationsApiClient.d.ts +94 -0
  16. package/lib/openapi/organizations/BaseOrganizationsApiClient.js +127 -0
  17. package/lib/openapi/organizations/BaseOrganizationsApiClient.js.map +1 -0
  18. package/lib/openapi/organizations/models/common.d.ts +222 -0
  19. package/lib/openapi/organizations/models/common.js +66 -0
  20. package/lib/openapi/organizations/models/common.js.map +1 -0
  21. package/lib/openapi/organizations/models/directory.d.ts +151 -0
  22. package/lib/openapi/organizations/models/directory.js +58 -0
  23. package/lib/openapi/organizations/models/directory.js.map +1 -0
  24. package/lib/openapi/organizations/models/domains.d.ts +52 -0
  25. package/lib/openapi/organizations/models/domains.js +35 -0
  26. package/lib/openapi/organizations/models/domains.js.map +1 -0
  27. package/lib/openapi/organizations/models/events.d.ts +280 -0
  28. package/lib/openapi/organizations/models/events.js +129 -0
  29. package/lib/openapi/organizations/models/events.js.map +1 -0
  30. package/lib/openapi/organizations/models/groups.d.ts +297 -0
  31. package/lib/openapi/organizations/models/groups.js +114 -0
  32. package/lib/openapi/organizations/models/groups.js.map +1 -0
  33. package/lib/openapi/organizations/models/orgs.d.ts +52 -0
  34. package/lib/openapi/organizations/models/orgs.js +36 -0
  35. package/lib/openapi/organizations/models/orgs.js.map +1 -0
  36. package/lib/openapi/organizations/models/policies.d.ts +169 -0
  37. package/lib/openapi/organizations/models/policies.js +101 -0
  38. package/lib/openapi/organizations/models/policies.js.map +1 -0
  39. package/lib/openapi/organizations/models/users.d.ts +477 -0
  40. package/lib/openapi/organizations/models/users.js +178 -0
  41. package/lib/openapi/organizations/models/users.js.map +1 -0
  42. package/lib/openapi/organizations/models/workspaces.d.ts +200 -0
  43. package/lib/openapi/organizations/models/workspaces.js +106 -0
  44. package/lib/openapi/organizations/models/workspaces.js.map +1 -0
  45. package/lib/openapi/organizations/services/DirectoryService.d.ts +637 -0
  46. package/lib/openapi/organizations/services/DirectoryService.js +599 -0
  47. package/lib/openapi/organizations/services/DirectoryService.js.map +1 -0
  48. package/lib/openapi/organizations/services/DomainsService.d.ts +51 -0
  49. package/lib/openapi/organizations/services/DomainsService.js +89 -0
  50. package/lib/openapi/organizations/services/DomainsService.js.map +1 -0
  51. package/lib/openapi/organizations/services/EventsService.d.ts +142 -0
  52. package/lib/openapi/organizations/services/EventsService.js +187 -0
  53. package/lib/openapi/organizations/services/EventsService.js.map +1 -0
  54. package/lib/openapi/organizations/services/GroupsService.d.ts +268 -0
  55. package/lib/openapi/organizations/services/GroupsService.js +210 -0
  56. package/lib/openapi/organizations/services/GroupsService.js.map +1 -0
  57. package/lib/openapi/organizations/services/OrgsService.d.ts +38 -0
  58. package/lib/openapi/organizations/services/OrgsService.js +79 -0
  59. package/lib/openapi/organizations/services/OrgsService.js.map +1 -0
  60. package/lib/openapi/organizations/services/PoliciesService.d.ts +172 -0
  61. package/lib/openapi/organizations/services/PoliciesService.js +272 -0
  62. package/lib/openapi/organizations/services/PoliciesService.js.map +1 -0
  63. package/lib/openapi/organizations/services/UsersService.d.ts +310 -0
  64. package/lib/openapi/organizations/services/UsersService.js +214 -0
  65. package/lib/openapi/organizations/services/UsersService.js.map +1 -0
  66. package/lib/openapi/organizations/services/ValidateService.d.ts +25 -0
  67. package/lib/openapi/organizations/services/ValidateService.js +38 -0
  68. package/lib/openapi/organizations/services/ValidateService.js.map +1 -0
  69. package/lib/openapi/organizations/services/WorkspacesService.d.ts +78 -0
  70. package/lib/openapi/organizations/services/WorkspacesService.js +63 -0
  71. package/lib/openapi/organizations/services/WorkspacesService.js.map +1 -0
  72. package/lib/openapi/organizations/validationSchemaStorage.d.ts +3 -0
  73. package/lib/openapi/organizations/validationSchemaStorage.js +134 -0
  74. package/lib/openapi/organizations/validationSchemaStorage.js.map +1 -0
  75. package/package.json +47 -0
package/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025 resolution Reichert Network Solutions GmbH
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # Atlassian Organizations API Client
2
+
3
+ TypeScript/JavaScript client for the Atlassian Organizations API, generated from the Atlassian OpenAPI schema.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @resolution/organizations-api-client
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ yarn add @resolution/organizations-api-client
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```typescript
20
+ import { OrganizationsApiClient } from '@resolution/organizations-api-client';
21
+
22
+ // Initialize the client with your API key
23
+ const organizationsClient = new OrganizationsApiClient({
24
+ apiKey: 'your-api-key-here'
25
+ });
26
+
27
+ // Example: Get organizations
28
+ async function getOrganizations() {
29
+ try {
30
+ const response = await organizationsClient.orgs.getOrgs();
31
+ console.log('Organizations:', response.data);
32
+ } catch (error) {
33
+ console.error('Error fetching organizations:', error);
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Authentication
39
+
40
+ This client only supports API key authentication. You need to provide an API key when initializing the client:
41
+
42
+ ```typescript
43
+ const client = new OrganizationsApiClient({
44
+ apiKey: 'your-api-key-here'
45
+ });
46
+ ```
47
+
48
+ ## Available Services
49
+
50
+ The client provides access to the following services:
51
+
52
+ - `directory` - Directory management
53
+ - `domains` - Domain management
54
+ - `events` - Event management
55
+ - `groups` - Group management
56
+ - `orgs` - Organization management
57
+ - `policies` - Policy management
58
+ - `users` - User management
59
+ - `validate` - Validation
60
+ - `workspaces` - Workspace management
61
+
62
+ ## Error Handling
63
+
64
+ The client uses the `ApiError` class for error handling:
65
+
66
+ ```typescript
67
+ import { OrganizationsApiClient, ApiError } from '@resolution/organizations-api-client';
68
+
69
+ const organizationsClient = new OrganizationsApiClient({
70
+ apiKey: 'your-api-key-here'
71
+ });
72
+
73
+ try {
74
+ await organizationsClient.orgs.getOrgs();
75
+ } catch (error) {
76
+ if (error instanceof ApiError) {
77
+ console.error('API Error:', error.message);
78
+ console.error('Status:', error.statusCode);
79
+ console.error('Details:', error.details);
80
+ } else {
81
+ console.error('Unknown error:', error);
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## Advanced Configuration
87
+
88
+ You can customize client behavior with additional options:
89
+
90
+ ```typescript
91
+ const client = new OrganizationsApiClient({
92
+ apiKey: 'your-api-key-here',
93
+ // Custom validation error handler
94
+ handleValidationError: (error) => {
95
+ console.error('Validation error:', error);
96
+ },
97
+ // Custom deprecation warning logger
98
+ logDeprecationWarning: ({ operationName, path, method }) => {
99
+ console.warn(`Deprecated operation used: ${operationName} (${method} ${path})`);
100
+ },
101
+ // Custom retry logic
102
+ shouldRetryOnError: (error, attemptNumber) => {
103
+ return attemptNumber < 3 && (error.statusCode === 429 || error.statusCode >= 500);
104
+ }
105
+ });
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
package/lib/index.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { ApiError, retryOnNetworkAndInternalErrors } from "@resolution/atlassian-api-common";
2
+ import type { CommonHttpClientFetchRequest } from "api-typescript-generator/openapi-client";
3
+ import { BaseOrganizationsApiClient } from "./openapi/organizations/BaseOrganizationsApiClient";
4
+ export * from "./openapi/organizations/BaseOrganizationsApiClient";
5
+ export { ApiError, retryOnNetworkAndInternalErrors };
6
+ /**
7
+ * The Organizations REST API Client.
8
+ */
9
+ export interface OrganizationsApiClientOptions {
10
+ /**
11
+ * API key for authentication.
12
+ */
13
+ apiKey: string;
14
+ /**
15
+ * Custom validation error handler.
16
+ */
17
+ handleValidationError?(error: Error): void;
18
+ /**
19
+ * Custom deprecation warning logger.
20
+ */
21
+ logDeprecationWarning?(params: {
22
+ /**
23
+ * Either operation method name in case if it's not part of the service, or service name and operation method
24
+ * name separated by a dot.
25
+ *
26
+ * Examples: `users.getUserById`, `getSystemConfig`
27
+ */
28
+ operationName: string;
29
+ path: string;
30
+ method: CommonHttpClientFetchRequest["method"];
31
+ }): void;
32
+ /**
33
+ * Determine whether to retry the request on error.
34
+ */
35
+ shouldRetryOnError?: (error: ApiError, attemptNumber: number) => Promise<boolean> | boolean;
36
+ }
37
+ export declare class OrganizationsApiClient extends BaseOrganizationsApiClient {
38
+ constructor({ apiKey, shouldRetryOnError, ...otherProps }: OrganizationsApiClientOptions);
39
+ }
package/lib/index.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.OrganizationsApiClient = exports.retryOnNetworkAndInternalErrors = exports.ApiError = void 0;
29
+ const atlassian_api_common_1 = require("@resolution/atlassian-api-common");
30
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return atlassian_api_common_1.ApiError; } });
31
+ Object.defineProperty(exports, "retryOnNetworkAndInternalErrors", { enumerable: true, get: function () { return atlassian_api_common_1.retryOnNetworkAndInternalErrors; } });
32
+ const BaseOrganizationsApiClient_1 = require("./openapi/organizations/BaseOrganizationsApiClient");
33
+ const validationSchemaStorage_1 = require("./openapi/organizations/validationSchemaStorage");
34
+ __exportStar(require("./openapi/organizations/BaseOrganizationsApiClient"), exports);
35
+ validationSchemaStorage_1.validationSchemaStorage.setErrorClass(atlassian_api_common_1.ApiError);
36
+ const BASE_PATH = "/admin";
37
+ class OrganizationsApiClient extends BaseOrganizationsApiClient_1.BaseOrganizationsApiClient {
38
+ constructor(_a) {
39
+ var { apiKey, shouldRetryOnError } = _a, otherProps = __rest(_a, ["apiKey", "shouldRetryOnError"]);
40
+ super(Object.assign({ baseUrl: "https://api.atlassian.com", headers: {
41
+ Authorization: `Bearer ${apiKey}`,
42
+ }, formatHttpErrorMessage: atlassian_api_common_1.formatHttpErrorMessage, errorClass: atlassian_api_common_1.ApiError, preprocessRequest: (request) => Promise.resolve(Object.assign(Object.assign({}, request), { path: BASE_PATH + request.path })), shouldRetryOnError: shouldRetryOnError }, otherProps));
43
+ }
44
+ }
45
+ exports.OrganizationsApiClient = OrganizationsApiClient;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAI0C;AASjC,yFAZP,+BAAQ,OAYO;AAAE,gHAVjB,sDAA+B,OAUiB;AALlD,mGAAgG;AAChG,6FAA0F;AAE1F,qFAAmE;AAInE,iDAAuB,CAAC,aAAa,CAAC,+BAAQ,CAAC,CAAC;AAqChD,MAAM,SAAS,GAAG,QAAQ,CAAC;AAE3B,MAAa,sBAAuB,SAAQ,uDAA0B;IACpE,YAAY,EAIoB;YAJpB,EACV,MAAM,EACN,kBAAkB,OAEY,EAD3B,UAAU,cAHH,gCAIX,CADc;QAEb,KAAK,iBACH,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,EAAE;aAClC,EACD,sBAAsB,EAAtB,6CAAsB,EACtB,UAAU,EAAE,+BAAQ,EACpB,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE,CAC7B,OAAO,CAAC,OAAO,iCACV,OAAO,KACV,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,IAC9B,EACJ,kBAAkB,EAChB,kBAAmE,IAClE,UAAU,EACb,CAAC;IACL,CAAC;CACF;AAvBD,wDAuBC"}
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Options for the common HTTP client.
3
+ */
4
+ export interface CommonHttpClientOptions {
5
+ /**
6
+ * Base URL for the API. Endpoints are relative to this URL.
7
+ */
8
+ baseUrl: string;
9
+ /**
10
+ * Error class to be thrown when an error occurs.
11
+ */
12
+ errorClass: {
13
+ new (url: URL, request: CommonHttpClientFetchRequest | undefined, response: CommonHttpClientFetchResponse | undefined, options: CommonHttpClientOptions | undefined, message: string): Error;
14
+ };
15
+ /**
16
+ * Class name of the API client.
17
+ */
18
+ apiClientClassName: string;
19
+ /**
20
+ * Default headers to be sent with each request.
21
+ */
22
+ headers?: CommonHttpClientRequestHeaders;
23
+ /**
24
+ * Preprocess the request before sending it.
25
+ */
26
+ preprocessRequest?: (request: CommonHttpClientRequest) => Promise<CommonHttpClientRequest>;
27
+ /**
28
+ * Preprocess the response before returning it.
29
+ */
30
+ preprocessFetchResponse?: (response: CommonHttpClientFetchResponse, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
31
+ /**
32
+ * Fetch function. Default is window.fetch-based implementation.
33
+ */
34
+ fetch?: (url: URL, request: CommonHttpClientFetchRequest) => Promise<CommonHttpClientFetchResponse>;
35
+ /**
36
+ * Type of the response body for binary responses.
37
+ */
38
+ binaryResponseType: 'blob' | 'readableStream';
39
+ /**
40
+ * Format the HTTP error message.
41
+ */
42
+ formatHttpErrorMessage?: (response: CommonHttpClientFetchResponse, request: CommonHttpClientFetchRequest) => string;
43
+ /**
44
+ * Custom validation error handling. Can be used to log errors.
45
+ */
46
+ handleValidationError?: (error: Error) => void;
47
+ /**
48
+ * Deprecated operations. Used to warn about deprecated operations.
49
+ */
50
+ deprecatedOperations?: {
51
+ [methodAndPath: string]: string;
52
+ };
53
+ /**
54
+ * Log a deprecation warning.
55
+ */
56
+ logDeprecationWarning?(params: {
57
+ /**
58
+ * Either operation method name in case if it's not part of the service, or service name and operation method
59
+ * name separated by a dot.
60
+ *
61
+ * Examples: `users.getUserById`, `getSystemConfig`
62
+ */
63
+ operationName: string;
64
+ path: string;
65
+ method: CommonHttpClientFetchRequest['method'];
66
+ }): void;
67
+ /**
68
+ * Determine whether to retry on error.
69
+ */
70
+ shouldRetryOnError?: (error: Error, attemptNumber: number) => boolean | Promise<boolean>;
71
+ }
72
+ /**
73
+ * Request headers as used by the fetch function.
74
+ */
75
+ export interface CommonHttpClientFetchRequestHeaders {
76
+ [headerName: string]: string;
77
+ }
78
+ /**
79
+ * A forgiving version of the request headers. Undefined and null values are allowed.
80
+ */
81
+ export interface CommonHttpClientRequestHeaders {
82
+ [headerName: string]: string | undefined | null;
83
+ }
84
+ /**
85
+ * Request prepared for the fetch function.
86
+ */
87
+ export interface CommonHttpClientFetchRequest {
88
+ /**
89
+ * HTTP Method.
90
+ */
91
+ method: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'PATCH';
92
+ /**
93
+ * Request headers.
94
+ */
95
+ headers: CommonHttpClientFetchRequestHeaders;
96
+ /**
97
+ * Request body.
98
+ */
99
+ body?: BodyInit;
100
+ /**
101
+ * Cache mode.
102
+ */
103
+ cache: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
104
+ /**
105
+ * Credentials mode.
106
+ */
107
+ credentials: 'include' | 'omit' | 'same-origin';
108
+ /**
109
+ * Redirect mode.
110
+ */
111
+ redirect: 'error' | 'follow' | 'manual';
112
+ /**
113
+ * Custom request properties. Can be used to pass metadata to the fetch function.
114
+ */
115
+ customRequestProps?: Record<string, unknown>;
116
+ }
117
+ /**
118
+ * Parameter serialization style.
119
+ */
120
+ export type CommonHttpClientRequestParameterSerializeStyle = 'simple' | 'label' | 'matrix' | 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
121
+ /**
122
+ * Information about how to serialize a request parameter.
123
+ */
124
+ export interface CommonHttpClientRequestParameterSerializeInfo {
125
+ /**
126
+ * Serialization style.
127
+ */
128
+ style?: CommonHttpClientRequestParameterSerializeStyle;
129
+ /**
130
+ * Serialization explode.
131
+ */
132
+ explode?: boolean;
133
+ }
134
+ /**
135
+ * Request parameter location.
136
+ */
137
+ export type CommonHttpClientRequestParameterLocation = 'path' | 'query' | 'header' | 'cookie';
138
+ /**
139
+ * Request parameters.
140
+ */
141
+ export type CommonHttpClientRequestParameters = {
142
+ [K in CommonHttpClientRequestParameterLocation]?: Record<string, CommonHttpClientRequestParameterSerializeInfo>;
143
+ };
144
+ /**
145
+ * Request in terms of OpenAPI.
146
+ */
147
+ export type CommonHttpClientRequest = Omit<CommonHttpClientFetchRequest, 'body' | 'headers' | 'cache' | 'credentials' | 'redirect'> & {
148
+ /**
149
+ * Path to the resource.
150
+ */
151
+ path: string;
152
+ /**
153
+ * Path parameters, i.e. {id}.
154
+ */
155
+ pathParams?: Record<string, unknown>;
156
+ /**
157
+ * Query parameters.
158
+ */
159
+ query?: Record<string, unknown>;
160
+ /**
161
+ * Request body.
162
+ */
163
+ body?: unknown;
164
+ /**
165
+ * Request headers.
166
+ */
167
+ headers?: CommonHttpClientRequestHeaders;
168
+ /**
169
+ * Request parameters serialization information.
170
+ */
171
+ parameters?: CommonHttpClientRequestParameters;
172
+ } & Partial<Pick<CommonHttpClientFetchRequest, 'cache' | 'credentials' | 'redirect'>>;
173
+ /**
174
+ * Response of the fetch function.
175
+ */
176
+ export interface CommonHttpClientFetchResponse {
177
+ /**
178
+ * HTTP status code.
179
+ */
180
+ status: number;
181
+ /**
182
+ * HTTP status code explanation.
183
+ */
184
+ statusText: string;
185
+ /**
186
+ * Response body.
187
+ */
188
+ body: CommonHttpClientFetchResponseBody;
189
+ /**
190
+ * Whether the request was successful. True for 2xx status codes.
191
+ */
192
+ ok: boolean;
193
+ /**
194
+ * The final URL of the request (after redirects).
195
+ */
196
+ url: string;
197
+ /**
198
+ * Response headers.
199
+ */
200
+ headers: CommonHttpClientResponseHeaders;
201
+ /**
202
+ * Custom request properties. Can be used to pass metadata outside the fetch function.
203
+ */
204
+ customRequestProps?: Record<string, unknown>;
205
+ }
206
+ export type CommonHttpClientResponseHeaders = Record<string, string> & {
207
+ 'set-cookie'?: string[];
208
+ };
209
+ export type CommonHttpClientFetchResponseBody = {
210
+ type: 'json';
211
+ data: unknown;
212
+ } | {
213
+ type: 'blob';
214
+ data: Blob;
215
+ } | {
216
+ type: 'readableStream';
217
+ data: ReadableStream<Uint8Array>;
218
+ };
219
+ export interface CommonHttpClientResponse<T> {
220
+ status: number;
221
+ mediaType?: string;
222
+ body: T;
223
+ response: CommonHttpClientFetchResponse;
224
+ }
225
+ /** Error thrown by the common HTTP client. */
226
+ export declare class CommonHttpClientError extends Error {
227
+ /** URL of the request. */
228
+ readonly url: URL;
229
+ /**
230
+ * Request that caused the error. Can be undefined in case of failure during
231
+ * request building phase.
232
+ */
233
+ readonly request: CommonHttpClientFetchRequest | undefined;
234
+ /** Response that caused the error. Can be undefined in case of network failure. */
235
+ readonly response: CommonHttpClientFetchResponse | undefined;
236
+ /** Options of the common HTTP client. */
237
+ readonly options: CommonHttpClientOptions | undefined;
238
+ constructor(url: URL, request: CommonHttpClientFetchRequest | undefined, response: CommonHttpClientFetchResponse | undefined, options: CommonHttpClientOptions | undefined, message: string);
239
+ }
240
+ /**
241
+ * `extends unknown` is a trick to split the union into individual types.
242
+ */
243
+ type ResponseByMediaType<T extends CommonHttpClientResponse<unknown>, K extends string> = T extends unknown ? ((a: T) => void) extends (a: {
244
+ mediaType: K;
245
+ status: infer _Status;
246
+ body: infer _Body;
247
+ response: CommonHttpClientFetchResponse;
248
+ }) => void ? T : never : never;
249
+ export declare function checkReponseMediaType<T extends CommonHttpClientResponse<unknown>, K extends string>(response: T, mediaType: K): response is ResponseByMediaType<T, K> extends never ? ResponseByMediaType<T, '*/*'> : ResponseByMediaType<T, K>;
250
+ export declare function isJsonMediaType(mediaType: string): boolean;
251
+ type AsCreatedResponseFunction<KCreated extends string, KOther extends string> = <T extends CommonHttpClientResponse<unknown>>(response: T) => ({
252
+ [K in KCreated]: Extract<T, {
253
+ status: 201;
254
+ }>['body'];
255
+ } & {
256
+ created: true;
257
+ }) | ({
258
+ [K in KOther]: Extract<T, {
259
+ status: 200;
260
+ }>['body'];
261
+ } & {
262
+ created: false;
263
+ });
264
+ export declare function asCreatedResponse<KCreated extends string>(keyCreated: KCreated): AsCreatedResponseFunction<KCreated, KCreated>;
265
+ export declare function asCreatedResponse<KCreated extends string, KOther extends string>(keyCreated: KCreated, keyOther: KOther): AsCreatedResponseFunction<KCreated, KOther>;
266
+ export declare const getBody: <T>({ body }: CommonHttpClientResponse<T>) => T;
267
+ export declare const castResponse: <T extends Omit<CommonHttpClientResponse<unknown>, "response">>() => (response: CommonHttpClientResponse<unknown>) => WithResponse<T>;
268
+ export declare const discardResult: () => void;
269
+ export type WithResponse<T> = T & {
270
+ response: CommonHttpClientFetchResponse;
271
+ };
272
+ export declare function createClientWithServices<TOptions, TClient extends {
273
+ getClient(): CommonHttpClient;
274
+ }, TServices extends Record<string, {
275
+ new (client: CommonHttpClient): unknown;
276
+ }>>(this: {
277
+ new (options?: TOptions): TClient;
278
+ }, services: TServices, options?: TOptions): TClient & {
279
+ [K in keyof TServices as K extends string ? Uncapitalize<K extends `${infer TName}Service` ? TName : K> : K]: InstanceType<TServices[K]>;
280
+ };
281
+ /** Common HTTP client. Configurable for different environments. */
282
+ export declare class CommonHttpClient {
283
+ protected options: CommonHttpClientOptions;
284
+ constructor(options: CommonHttpClientOptions);
285
+ /** Configure the client. */
286
+ setOptions(options: CommonHttpClientOptions): void;
287
+ /** Get the current configuration. */
288
+ getOptions(): CommonHttpClientOptions;
289
+ /** Logs a deprecation warning if the operation is deprecated. */
290
+ protected logDeprecationWarningIfNecessary(params: {
291
+ path: string;
292
+ method: CommonHttpClientFetchRequest['method'];
293
+ }): void;
294
+ /** Turns an object with query params into a URLSearchParams object. */
295
+ protected getSearchParams(params: Record<string, unknown>, parameters: Record<string, CommonHttpClientRequestParameterSerializeInfo>): URLSearchParams;
296
+ /** Build the URL path from the request by applying path params. */
297
+ protected buildUrlPath(request: CommonHttpClientRequest, parameters: Record<string, CommonHttpClientRequestParameterSerializeInfo>): string;
298
+ /** Build the full URL from the request. */
299
+ protected buildUrl(request: CommonHttpClientRequest): URL;
300
+ /** Default fetch implementation. */
301
+ protected fetch(url: URL, request: CommonHttpClientFetchRequest): Promise<CommonHttpClientFetchResponse>;
302
+ /** Perform a request. */
303
+ request(request: CommonHttpClientRequest): Promise<CommonHttpClientFetchResponse>;
304
+ /** Post-process the response. */
305
+ responseHandler(distribution: {
306
+ [statusCode: string]: {
307
+ [mediaType: string]: CommonHttpClientFetchResponseBody['type'];
308
+ };
309
+ }): (response: CommonHttpClientFetchResponse) => Promise<CommonHttpClientResponse<unknown>>;
310
+ validation<D>(validator: (data: D) => D): (data: D) => D;
311
+ /** Remove undefined and null values from headers. */
312
+ private cleanupHeaders;
313
+ protected getRequestBody(request: CommonHttpClientRequest): BodyInit | undefined;
314
+ protected preprocessRequest(request: CommonHttpClientRequest): Promise<CommonHttpClientRequest>;
315
+ }
316
+ export {};