@seatmap-fyi/api-client 0.1.0-alpha.4 → 0.1.0-alpha.5

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,16 +1,12 @@
1
+ import type { AxiosRequestConfig } from "axios";
1
2
  export interface ConfigurationParameters {
2
- readonly basePath: string;
3
- readonly fetchApi?: typeof globalThis.fetch;
4
- readonly credentials?: RequestCredentials;
3
+ readonly basePath?: string | undefined;
4
+ readonly baseOptions?: AxiosRequestConfig;
5
5
  readonly compressRequests?: boolean;
6
- readonly mapError?: (cause: unknown) => Promise<Error>;
7
6
  }
8
7
  export declare class Configuration {
9
- readonly basePath: string;
10
- readonly fetchApi: typeof globalThis.fetch;
11
- readonly credentials: RequestCredentials | undefined;
8
+ readonly basePath: string | undefined;
9
+ readonly baseOptions: AxiosRequestConfig | undefined;
12
10
  readonly compressRequests: boolean;
13
- readonly mapError: ConfigurationParameters["mapError"];
14
- csrfToken: string | undefined;
15
- constructor(parameters: ConfigurationParameters);
11
+ constructor(parameters?: ConfigurationParameters);
16
12
  }
@@ -1,15 +1,10 @@
1
1
  export class Configuration {
2
2
  basePath;
3
- fetchApi;
4
- credentials;
3
+ baseOptions;
5
4
  compressRequests;
6
- mapError;
7
- csrfToken;
8
- constructor(parameters) {
5
+ constructor(parameters = {}) {
9
6
  this.basePath = parameters.basePath;
10
- this.fetchApi = parameters.fetchApi ?? globalThis.fetch;
11
- this.credentials = parameters.credentials;
7
+ this.baseOptions = parameters.baseOptions;
12
8
  this.compressRequests = parameters.compressRequests ?? false;
13
- this.mapError = parameters.mapError;
14
9
  }
15
10
  }
@@ -1,8 +1,23 @@
1
+ import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
1
2
  export interface DocumentErrorIssueDto {
2
3
  code: string;
3
4
  message: string;
4
5
  }
5
- export interface HttpErrorDto {
6
+ export interface HttpErrorDataDto {
7
+ /**
8
+ * Request-validation messages.
9
+ * @maxItems 50
10
+ */
11
+ errors?: string[];
12
+ /** HTTP error category, independent of domain code. */
13
+ errorName: string;
14
+ /** Exception type; development only. */
15
+ error?: string;
16
+ /**
17
+ * Bounded exception stack trace; development only.
18
+ * @maxLength 16384
19
+ */
20
+ stackTrace?: string;
6
21
  /**
7
22
  * Rate-limit retry delay in seconds; also returned in Retry-After.
8
23
  * @minimum 1
@@ -13,16 +28,15 @@ export interface HttpErrorDto {
13
28
  * @maxItems 50
14
29
  */
15
30
  issues?: DocumentErrorIssueDto[];
16
- /** Stable operation-owned failure code. */
17
- code?: string;
18
- /**
19
- * @minimum 400
20
- * @maximum 599
21
- */
22
- statusCode: number;
23
- message: string | string[];
24
- /** Framework client-error description; absent on contained server faults. */
25
- error?: string;
31
+ }
32
+ export interface HttpErrorDto {
33
+ /** Stable domain code, or HTTP category such as InternalServerError. */
34
+ code: string;
35
+ /** @maxLength 4096 */
36
+ message: string;
37
+ data: HttpErrorDataDto;
38
+ /** Server-generated request ID for log correlation. */
39
+ traceId: string;
26
40
  }
27
41
  export interface HealthResponseDto {
28
42
  status: string;
@@ -2346,33 +2360,38 @@ export declare enum ListMapsLifecycle {
2346
2360
  }
2347
2361
  import type { Configuration } from "./configuration.js";
2348
2362
  export declare class HealthClient {
2349
- private readonly fetchApi;
2350
- constructor(configuration: Configuration);
2351
- getLiveness(options?: RequestInit): Promise<HealthResponseDto>;
2363
+ private readonly configuration;
2364
+ private readonly basePath?;
2365
+ private readonly operations;
2366
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2367
+ getLiveness(options?: AxiosRequestConfig): Promise<AxiosResponse<HealthResponseDto>>;
2352
2368
  }
2353
2369
  export declare class AuthenticationClient {
2354
- private readonly fetchApi;
2355
- private readonly basePath;
2356
- constructor(configuration: Configuration);
2357
- getIntegrationContext(options?: RequestInit): Promise<AccountContextDto>;
2358
- startLogin(params: StartLoginParams, options?: RequestInit): Promise<unknown>;
2359
- completeLogin(options?: RequestInit): Promise<unknown>;
2360
- logoutProvider(options?: RequestInit): Promise<unknown>;
2361
- getAuthoringSession(options?: RequestInit): Promise<AuthoringSessionContextDto>;
2362
- revokeAuthoringSession(options?: RequestInit): Promise<void>;
2363
- getEmbedContext(mapId: string, options?: RequestInit): Promise<EmbedContextDto>;
2370
+ private readonly configuration;
2371
+ private readonly basePath?;
2372
+ private readonly operations;
2373
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2374
+ getIntegrationContext(options?: AxiosRequestConfig): Promise<AxiosResponse<AccountContextDto>>;
2375
+ startLogin(params: StartLoginParams, options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2376
+ completeLogin(options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2377
+ logoutProvider(options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2378
+ getAuthoringSession(options?: AxiosRequestConfig): Promise<AxiosResponse<AuthoringSessionContextDto>>;
2379
+ revokeAuthoringSession(options?: AxiosRequestConfig): Promise<AxiosResponse<void>>;
2380
+ getEmbedContext(mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<EmbedContextDto>>;
2364
2381
  startLoginHref(params: StartLoginParams): string;
2365
2382
  logoutProviderHref(): string;
2366
2383
  }
2367
2384
  export declare class MapsClient {
2368
- private readonly fetchApi;
2369
- constructor(configuration: Configuration);
2370
- listMaps(workspaceId: string, params?: ListMapsParams, options?: RequestInit): Promise<MapListDto>;
2371
- createMap(workspaceId: string, createMapDto: CreateMapDto, options?: RequestInit): Promise<MapAcknowledgementDto>;
2372
- getMutationStatus(workspaceId: string, operationId: string, options?: RequestInit): Promise<MutationStatusDto>;
2373
- getMap(workspaceId: string, mapId: string, options?: RequestInit): Promise<MapResponseDto>;
2374
- saveMap(workspaceId: string, mapId: string, saveMapDto: SaveMapDto, options?: RequestInit): Promise<MapAcknowledgementDto>;
2375
- changeMap(workspaceId: string, mapId: string, mapActionDto: MapActionDto, options?: RequestInit): Promise<MapAcknowledgementDto>;
2376
- listMapRevisions(workspaceId: string, mapId: string, options?: RequestInit): Promise<MapRevisionDto[]>;
2377
- getMapRevision(workspaceId: string, mapId: string, revision: number, options?: RequestInit): Promise<MapContentDto>;
2385
+ private readonly configuration;
2386
+ private readonly basePath?;
2387
+ private readonly operations;
2388
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2389
+ listMaps(workspaceId: string, params?: ListMapsParams, options?: AxiosRequestConfig): Promise<AxiosResponse<MapListDto>>;
2390
+ createMap(workspaceId: string, createMapDto: CreateMapDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2391
+ getMutationStatus(workspaceId: string, operationId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MutationStatusDto>>;
2392
+ getMap(workspaceId: string, mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapResponseDto>>;
2393
+ saveMap(workspaceId: string, mapId: string, saveMapDto: SaveMapDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2394
+ changeMap(workspaceId: string, mapId: string, mapActionDto: MapActionDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2395
+ listMapRevisions(workspaceId: string, mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapRevisionDto[]>>;
2396
+ getMapRevision(workspaceId: string, mapId: string, revision: number, options?: AxiosRequestConfig): Promise<AxiosResponse<MapContentDto>>;
2378
2397
  }
package/dist/generated.js CHANGED
@@ -1,3 +1,4 @@
1
+ import axios from "axios";
1
2
  export var Capability;
2
3
  (function (Capability) {
3
4
  Capability["MAPS_READ"] = "maps:read";
@@ -52,348 +53,378 @@ export var ListMapsLifecycle;
52
53
  ListMapsLifecycle["trashed"] = "trashed";
53
54
  ListMapsLifecycle["deleted"] = "deleted";
54
55
  })(ListMapsLifecycle || (ListMapsLifecycle = {}));
55
- import { createApiFetcher } from "./transport.js";
56
+ import { prepareRequestOptions } from "./transport.js";
56
57
  export class HealthClient {
57
- fetchApi;
58
- constructor(configuration) {
59
- this.fetchApi = createApiFetcher(configuration);
58
+ configuration;
59
+ basePath;
60
+ operations;
61
+ constructor(configuration, basePath, axiosInstance = axios) {
62
+ this.configuration = configuration;
63
+ this.basePath = basePath;
64
+ this.operations = getSeatmapApi(axiosInstance);
60
65
  }
61
- getLiveness(options) {
62
- return getLiveness(options, this.fetchApi);
66
+ async getLiveness(options) {
67
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
68
+ return this.operations.getLiveness(requestOptions);
63
69
  }
64
70
  }
65
71
  export class AuthenticationClient {
66
- fetchApi;
72
+ configuration;
67
73
  basePath;
68
- constructor(configuration) {
69
- this.basePath = configuration.basePath;
70
- this.fetchApi = createApiFetcher(configuration);
74
+ operations;
75
+ constructor(configuration, basePath, axiosInstance = axios) {
76
+ this.configuration = configuration;
77
+ this.basePath = basePath;
78
+ this.operations = getSeatmapApi(axiosInstance);
71
79
  }
72
- getIntegrationContext(options) {
73
- return getIntegrationContext(options, this.fetchApi);
80
+ async getIntegrationContext(options) {
81
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
82
+ return this.operations.getIntegrationContext(requestOptions);
74
83
  }
75
- startLogin(params, options) {
76
- return startLogin(params, options, this.fetchApi);
84
+ async startLogin(params, options) {
85
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
86
+ return this.operations.startLogin(params, requestOptions);
77
87
  }
78
- completeLogin(options) {
79
- return completeLogin(options, this.fetchApi);
88
+ async completeLogin(options) {
89
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
90
+ return this.operations.completeLogin(requestOptions);
80
91
  }
81
- logoutProvider(options) {
82
- return logoutProvider(options, this.fetchApi);
92
+ async logoutProvider(options) {
93
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
94
+ return this.operations.logoutProvider(requestOptions);
83
95
  }
84
- getAuthoringSession(options) {
85
- return getAuthoringSession(options, this.fetchApi);
96
+ async getAuthoringSession(options) {
97
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
98
+ return this.operations.getAuthoringSession(requestOptions);
86
99
  }
87
- revokeAuthoringSession(options) {
88
- return revokeAuthoringSession(options, this.fetchApi);
100
+ async revokeAuthoringSession(options) {
101
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "DELETE");
102
+ return this.operations.revokeAuthoringSession(requestOptions);
89
103
  }
90
- getEmbedContext(mapId, options) {
91
- return getEmbedContext(mapId, options, this.fetchApi);
104
+ async getEmbedContext(mapId, options) {
105
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
106
+ return this.operations.getEmbedContext(mapId, requestOptions);
92
107
  }
93
108
  startLoginHref(params) {
94
- return new URL(getStartLoginUrl(params), this.basePath).href;
109
+ return new URL(this.operations.getStartLoginUrl(params), this.basePath ?? this.configuration.basePath).href;
95
110
  }
96
111
  logoutProviderHref() {
97
- return new URL(getLogoutProviderUrl(), this.basePath).href;
112
+ return new URL(this.operations.getLogoutProviderUrl(), this.basePath ?? this.configuration.basePath).href;
98
113
  }
99
114
  }
100
115
  export class MapsClient {
101
- fetchApi;
102
- constructor(configuration) {
103
- this.fetchApi = createApiFetcher(configuration);
116
+ configuration;
117
+ basePath;
118
+ operations;
119
+ constructor(configuration, basePath, axiosInstance = axios) {
120
+ this.configuration = configuration;
121
+ this.basePath = basePath;
122
+ this.operations = getSeatmapApi(axiosInstance);
104
123
  }
105
- listMaps(workspaceId, params, options) {
106
- return listMaps(workspaceId, params, options, this.fetchApi);
124
+ async listMaps(workspaceId, params, options) {
125
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
126
+ return this.operations.listMaps(workspaceId, params, requestOptions);
107
127
  }
108
- createMap(workspaceId, createMapDto, options) {
109
- return createMap(workspaceId, createMapDto, options, this.fetchApi);
128
+ async createMap(workspaceId, createMapDto, options) {
129
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "POST", createMapDto);
130
+ return this.operations.createMap(workspaceId, requestOptions.data instanceof ArrayBuffer
131
+ ? requestOptions.data
132
+ : createMapDto, requestOptions);
110
133
  }
111
- getMutationStatus(workspaceId, operationId, options) {
112
- return getMutationStatus(workspaceId, operationId, options, this.fetchApi);
134
+ async getMutationStatus(workspaceId, operationId, options) {
135
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
136
+ return this.operations.getMutationStatus(workspaceId, operationId, requestOptions);
113
137
  }
114
- getMap(workspaceId, mapId, options) {
115
- return getMap(workspaceId, mapId, options, this.fetchApi);
138
+ async getMap(workspaceId, mapId, options) {
139
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
140
+ return this.operations.getMap(workspaceId, mapId, requestOptions);
116
141
  }
117
- saveMap(workspaceId, mapId, saveMapDto, options) {
118
- return saveMap(workspaceId, mapId, saveMapDto, options, this.fetchApi);
142
+ async saveMap(workspaceId, mapId, saveMapDto, options) {
143
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "PUT", saveMapDto);
144
+ return this.operations.saveMap(workspaceId, mapId, requestOptions.data instanceof ArrayBuffer
145
+ ? requestOptions.data
146
+ : saveMapDto, requestOptions);
119
147
  }
120
- changeMap(workspaceId, mapId, mapActionDto, options) {
121
- return changeMap(workspaceId, mapId, mapActionDto, options, this.fetchApi);
148
+ async changeMap(workspaceId, mapId, mapActionDto, options) {
149
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "POST", mapActionDto);
150
+ return this.operations.changeMap(workspaceId, mapId, requestOptions.data instanceof ArrayBuffer
151
+ ? requestOptions.data
152
+ : mapActionDto, requestOptions);
122
153
  }
123
- listMapRevisions(workspaceId, mapId, options) {
124
- return listMapRevisions(workspaceId, mapId, options, this.fetchApi);
154
+ async listMapRevisions(workspaceId, mapId, options) {
155
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
156
+ return this.operations.listMapRevisions(workspaceId, mapId, requestOptions);
125
157
  }
126
- getMapRevision(workspaceId, mapId, revision, options) {
127
- return getMapRevision(workspaceId, mapId, revision, options, this.fetchApi);
158
+ async getMapRevision(workspaceId, mapId, revision, options) {
159
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
160
+ return this.operations.getMapRevision(workspaceId, mapId, revision, requestOptions);
128
161
  }
129
162
  }
130
- const getGetLivenessUrl = () => {
131
- return `/health/live`;
132
- };
133
- const getLiveness = async (options, fetchFn) => {
134
- const res = await (fetchFn ?? fetch)(getGetLivenessUrl(), {
135
- ...options,
136
- method: "GET",
137
- });
138
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
139
- const data = body ? JSON.parse(body) : {};
140
- return data;
141
- };
142
- const getGetIntegrationContextUrl = () => {
143
- return `/auth/integration`;
144
- };
145
- const getIntegrationContext = async (options, fetchFn) => {
146
- const res = await (fetchFn ?? fetch)(getGetIntegrationContextUrl(), {
147
- ...options,
148
- method: "GET",
149
- });
150
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
151
- const data = body ? JSON.parse(body) : {};
152
- return data;
153
- };
154
- const getStartLoginUrl = (params) => {
155
- const normalizedParams = new URLSearchParams();
156
- Object.entries(params || {}).forEach(([key, value]) => {
157
- if (value !== undefined) {
158
- normalizedParams.append(key, value === null ? "null" : String(value));
159
- }
160
- });
161
- const stringifiedParams = normalizedParams.toString();
162
- return stringifiedParams.length > 0
163
- ? `/auth/login?${stringifiedParams}`
164
- : `/auth/login`;
165
- };
166
- const startLogin = async (params, options, fetchFn) => {
167
- const res = await (fetchFn ?? fetch)(getStartLoginUrl(params), {
168
- ...options,
169
- method: "GET",
170
- });
171
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
172
- const data = body ? JSON.parse(body) : {};
173
- return data;
174
- };
175
- const getCompleteLoginUrl = () => {
176
- return `/auth/callback`;
177
- };
178
- const completeLogin = async (options, fetchFn) => {
179
- const res = await (fetchFn ?? fetch)(getCompleteLoginUrl(), {
180
- ...options,
181
- method: "GET",
182
- });
183
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
184
- const data = body ? JSON.parse(body) : {};
185
- return data;
186
- };
187
- const getLogoutProviderUrl = () => {
188
- return `/auth/logout/provider`;
189
- };
190
- const logoutProvider = async (options, fetchFn) => {
191
- const res = await (fetchFn ?? fetch)(getLogoutProviderUrl(), {
192
- ...options,
193
- method: "GET",
194
- });
195
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
196
- const data = body ? JSON.parse(body) : {};
197
- return data;
198
- };
199
- const getGetAuthoringSessionUrl = () => {
200
- return `/auth/authoring/session`;
201
- };
202
- const getAuthoringSession = async (options, fetchFn) => {
203
- const res = await (fetchFn ?? fetch)(getGetAuthoringSessionUrl(), {
204
- ...options,
205
- method: "GET",
206
- });
207
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
208
- const data = body ? JSON.parse(body) : {};
209
- return data;
210
- };
211
- const getRevokeAuthoringSessionUrl = () => {
212
- return `/auth/authoring/session`;
213
- };
214
- const revokeAuthoringSession = async (options, fetchFn) => {
215
- const res = await (fetchFn ?? fetch)(getRevokeAuthoringSessionUrl(), {
216
- ...options,
217
- method: "DELETE",
218
- });
219
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
220
- const data = body ? JSON.parse(body) : undefined;
221
- return data;
222
- };
223
- const getGetEmbedContextUrl = (mapId) => {
224
- return `/auth/embed/${encodeURIComponent(String(mapId))}`;
225
- };
226
- const getEmbedContext = async (mapId, options, fetchFn) => {
227
- const res = await (fetchFn ?? fetch)(getGetEmbedContextUrl(mapId), {
228
- ...options,
229
- method: "GET",
230
- });
231
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
232
- const data = body ? JSON.parse(body) : {};
233
- return data;
234
- };
235
- const getListMapsUrl = (workspaceId, params) => {
236
- const normalizedParams = new URLSearchParams();
237
- Object.entries(params || {}).forEach(([key, value]) => {
238
- if (value !== undefined) {
239
- normalizedParams.append(key, value === null ? "null" : String(value));
240
- }
241
- });
242
- const stringifiedParams = normalizedParams.toString();
243
- return stringifiedParams.length > 0
244
- ? `/workspaces/${encodeURIComponent(String(workspaceId))}/maps?${stringifiedParams}`
245
- : `/workspaces/${encodeURIComponent(String(workspaceId))}/maps`;
246
- };
247
- const listMaps = async (workspaceId, params, options, fetchFn) => {
248
- const res = await (fetchFn ?? fetch)(getListMapsUrl(workspaceId, params), {
249
- ...options,
250
- method: "GET",
251
- });
252
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
253
- const data = body ? JSON.parse(body) : {};
254
- return data;
255
- };
256
- const getCreateMapUrl = (workspaceId) => {
257
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps`;
258
- };
259
- const createMap = async (workspaceId, createMapDto, options, fetchFn) => {
260
- const getHeaders = (h) => {
261
- if (!h)
262
- return {};
263
- if (h instanceof Headers)
264
- return Object.fromEntries(h.entries());
265
- if (Symbol.iterator in h) {
266
- return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
267
- }
268
- const headers = {};
269
- for (const [name, value] of Object.entries(h)) {
270
- if (value !== undefined)
271
- headers[name] = value;
272
- }
273
- return headers;
274
- };
275
- const res = await (fetchFn ?? fetch)(getCreateMapUrl(workspaceId), {
276
- ...options,
277
- method: "POST",
278
- headers: {
279
- "Content-Type": "application/json",
280
- ...getHeaders(options?.headers),
281
- },
282
- body: JSON.stringify(createMapDto),
283
- });
284
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
285
- const data = body ? JSON.parse(body) : {};
286
- return data;
287
- };
288
- const getGetMutationStatusUrl = (workspaceId, operationId) => {
289
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/operations/${encodeURIComponent(String(operationId))}`;
290
- };
291
- const getMutationStatus = async (workspaceId, operationId, options, fetchFn) => {
292
- const res = await (fetchFn ?? fetch)(getGetMutationStatusUrl(workspaceId, operationId), {
293
- ...options,
294
- method: "GET",
295
- });
296
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
297
- const data = body ? JSON.parse(body) : {};
298
- return data;
299
- };
300
- const getGetMapUrl = (workspaceId, mapId) => {
301
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}`;
302
- };
303
- const getMap = async (workspaceId, mapId, options, fetchFn) => {
304
- const res = await (fetchFn ?? fetch)(getGetMapUrl(workspaceId, mapId), {
305
- ...options,
306
- method: "GET",
307
- });
308
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
309
- const data = body ? JSON.parse(body) : {};
310
- return data;
311
- };
312
- const getSaveMapUrl = (workspaceId, mapId) => {
313
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/draft`;
314
- };
315
- const saveMap = async (workspaceId, mapId, saveMapDto, options, fetchFn) => {
316
- const getHeaders = (h) => {
317
- if (!h)
318
- return {};
319
- if (h instanceof Headers)
320
- return Object.fromEntries(h.entries());
321
- if (Symbol.iterator in h) {
322
- return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
323
- }
324
- const headers = {};
325
- for (const [name, value] of Object.entries(h)) {
326
- if (value !== undefined)
327
- headers[name] = value;
328
- }
329
- return headers;
330
- };
331
- const res = await (fetchFn ?? fetch)(getSaveMapUrl(workspaceId, mapId), {
332
- ...options,
333
- method: "PUT",
334
- headers: {
335
- "Content-Type": "application/json",
336
- ...getHeaders(options?.headers),
337
- },
338
- body: JSON.stringify(saveMapDto),
339
- });
340
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
341
- const data = body ? JSON.parse(body) : {};
342
- return data;
343
- };
344
- const getChangeMapUrl = (workspaceId, mapId) => {
345
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/actions`;
346
- };
347
- const changeMap = async (workspaceId, mapId, mapActionDto, options, fetchFn) => {
348
- const getHeaders = (h) => {
349
- if (!h)
350
- return {};
351
- if (h instanceof Headers)
352
- return Object.fromEntries(h.entries());
353
- if (Symbol.iterator in h) {
354
- return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
355
- }
356
- const headers = {};
357
- for (const [name, value] of Object.entries(h)) {
358
- if (value !== undefined)
359
- headers[name] = value;
360
- }
361
- return headers;
362
- };
363
- const res = await (fetchFn ?? fetch)(getChangeMapUrl(workspaceId, mapId), {
364
- ...options,
365
- method: "POST",
366
- headers: {
367
- "Content-Type": "application/json",
368
- ...getHeaders(options?.headers),
369
- },
370
- body: JSON.stringify(mapActionDto),
371
- });
372
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
373
- const data = body ? JSON.parse(body) : {};
374
- return data;
375
- };
376
- const getListMapRevisionsUrl = (workspaceId, mapId) => {
377
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/revisions`;
378
- };
379
- const listMapRevisions = async (workspaceId, mapId, options, fetchFn) => {
380
- const res = await (fetchFn ?? fetch)(getListMapRevisionsUrl(workspaceId, mapId), {
381
- ...options,
382
- method: "GET",
383
- });
384
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
385
- const data = body ? JSON.parse(body) : {};
386
- return data;
387
- };
388
- const getGetMapRevisionUrl = (workspaceId, mapId, revision) => {
389
- return `/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/revisions/${encodeURIComponent(String(revision))}`;
390
- };
391
- const getMapRevision = async (workspaceId, mapId, revision, options, fetchFn) => {
392
- const res = await (fetchFn ?? fetch)(getGetMapRevisionUrl(workspaceId, mapId, revision), {
393
- ...options,
394
- method: "GET",
395
- });
396
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
397
- const data = body ? JSON.parse(body) : {};
398
- return data;
163
+ const getSeatmapApi = (axiosInstance = axios) => {
164
+ const getLiveness = (options) => {
165
+ return axiosInstance.get(`/health`, options);
166
+ };
167
+ const getGetLivenessUrl = () => {
168
+ return axiosInstance
169
+ .create({
170
+ baseURL: "",
171
+ params: null,
172
+ })
173
+ .getUri({
174
+ url: `/health`,
175
+ baseURL: "",
176
+ });
177
+ };
178
+ const getIntegrationContext = (options) => {
179
+ return axiosInstance.get(`/auth/integration`, options);
180
+ };
181
+ const getGetIntegrationContextUrl = () => {
182
+ return axiosInstance
183
+ .create({
184
+ baseURL: "",
185
+ params: null,
186
+ })
187
+ .getUri({
188
+ url: `/auth/integration`,
189
+ baseURL: "",
190
+ });
191
+ };
192
+ const startLogin = (params, options) => {
193
+ return axiosInstance.get(`/auth/login`, {
194
+ ...options,
195
+ params: { ...params, ...options?.params },
196
+ });
197
+ };
198
+ const getStartLoginUrl = (params) => {
199
+ return axiosInstance
200
+ .create({
201
+ baseURL: "",
202
+ params: null,
203
+ })
204
+ .getUri({
205
+ url: `/auth/login`,
206
+ baseURL: "",
207
+ params,
208
+ });
209
+ };
210
+ const completeLogin = (options) => {
211
+ return axiosInstance.get(`/auth/callback`, options);
212
+ };
213
+ const getCompleteLoginUrl = () => {
214
+ return axiosInstance
215
+ .create({
216
+ baseURL: "",
217
+ params: null,
218
+ })
219
+ .getUri({
220
+ url: `/auth/callback`,
221
+ baseURL: "",
222
+ });
223
+ };
224
+ const logoutProvider = (options) => {
225
+ return axiosInstance.get(`/auth/logout/provider`, options);
226
+ };
227
+ const getLogoutProviderUrl = () => {
228
+ return axiosInstance
229
+ .create({
230
+ baseURL: "",
231
+ params: null,
232
+ })
233
+ .getUri({
234
+ url: `/auth/logout/provider`,
235
+ baseURL: "",
236
+ });
237
+ };
238
+ const getAuthoringSession = (options) => {
239
+ return axiosInstance.get(`/auth/authoring/session`, options);
240
+ };
241
+ const getGetAuthoringSessionUrl = () => {
242
+ return axiosInstance
243
+ .create({
244
+ baseURL: "",
245
+ params: null,
246
+ })
247
+ .getUri({
248
+ url: `/auth/authoring/session`,
249
+ baseURL: "",
250
+ });
251
+ };
252
+ const revokeAuthoringSession = (options) => {
253
+ return axiosInstance.delete(`/auth/authoring/session`, options);
254
+ };
255
+ const getRevokeAuthoringSessionUrl = () => {
256
+ return axiosInstance
257
+ .create({
258
+ baseURL: "",
259
+ params: null,
260
+ })
261
+ .getUri({
262
+ url: `/auth/authoring/session`,
263
+ baseURL: "",
264
+ });
265
+ };
266
+ const getEmbedContext = (mapId, options) => {
267
+ return axiosInstance.get(`/auth/embed/${encodeURIComponent(mapId)}`, options);
268
+ };
269
+ const getGetEmbedContextUrl = (mapId) => {
270
+ return axiosInstance
271
+ .create({
272
+ baseURL: "",
273
+ params: null,
274
+ })
275
+ .getUri({
276
+ url: `/auth/embed/${encodeURIComponent(mapId)}`,
277
+ baseURL: "",
278
+ });
279
+ };
280
+ const listMaps = (workspaceId, params, options) => {
281
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps`, {
282
+ ...options,
283
+ params: { ...params, ...options?.params },
284
+ });
285
+ };
286
+ const getListMapsUrl = (workspaceId, params) => {
287
+ return axiosInstance
288
+ .create({
289
+ baseURL: "",
290
+ params: null,
291
+ })
292
+ .getUri({
293
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps`,
294
+ baseURL: "",
295
+ params,
296
+ });
297
+ };
298
+ const createMap = (workspaceId, createMapDto, options) => {
299
+ return axiosInstance.post(`/workspaces/${encodeURIComponent(workspaceId)}/maps`, createMapDto, options);
300
+ };
301
+ const getCreateMapUrl = (workspaceId) => {
302
+ return axiosInstance
303
+ .create({
304
+ baseURL: "",
305
+ params: null,
306
+ })
307
+ .getUri({
308
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps`,
309
+ baseURL: "",
310
+ });
311
+ };
312
+ const getMutationStatus = (workspaceId, operationId, options) => {
313
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/operations/${encodeURIComponent(operationId)}`, options);
314
+ };
315
+ const getGetMutationStatusUrl = (workspaceId, operationId) => {
316
+ return axiosInstance
317
+ .create({
318
+ baseURL: "",
319
+ params: null,
320
+ })
321
+ .getUri({
322
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/operations/${encodeURIComponent(operationId)}`,
323
+ baseURL: "",
324
+ });
325
+ };
326
+ const getMap = (workspaceId, mapId, options) => {
327
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}`, options);
328
+ };
329
+ const getGetMapUrl = (workspaceId, mapId) => {
330
+ return axiosInstance
331
+ .create({
332
+ baseURL: "",
333
+ params: null,
334
+ })
335
+ .getUri({
336
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}`,
337
+ baseURL: "",
338
+ });
339
+ };
340
+ const saveMap = (workspaceId, mapId, saveMapDto, options) => {
341
+ return axiosInstance.put(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/draft`, saveMapDto, options);
342
+ };
343
+ const getSaveMapUrl = (workspaceId, mapId) => {
344
+ return axiosInstance
345
+ .create({
346
+ baseURL: "",
347
+ params: null,
348
+ })
349
+ .getUri({
350
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/draft`,
351
+ baseURL: "",
352
+ });
353
+ };
354
+ const changeMap = (workspaceId, mapId, mapActionDto, options) => {
355
+ return axiosInstance.post(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/actions`, mapActionDto, options);
356
+ };
357
+ const getChangeMapUrl = (workspaceId, mapId) => {
358
+ return axiosInstance
359
+ .create({
360
+ baseURL: "",
361
+ params: null,
362
+ })
363
+ .getUri({
364
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/actions`,
365
+ baseURL: "",
366
+ });
367
+ };
368
+ const listMapRevisions = (workspaceId, mapId, options) => {
369
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions`, options);
370
+ };
371
+ const getListMapRevisionsUrl = (workspaceId, mapId) => {
372
+ return axiosInstance
373
+ .create({
374
+ baseURL: "",
375
+ params: null,
376
+ })
377
+ .getUri({
378
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions`,
379
+ baseURL: "",
380
+ });
381
+ };
382
+ const getMapRevision = (workspaceId, mapId, revision, options) => {
383
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions/${encodeURIComponent(revision)}`, options);
384
+ };
385
+ const getGetMapRevisionUrl = (workspaceId, mapId, revision) => {
386
+ return axiosInstance
387
+ .create({
388
+ baseURL: "",
389
+ params: null,
390
+ })
391
+ .getUri({
392
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions/${encodeURIComponent(revision)}`,
393
+ baseURL: "",
394
+ });
395
+ };
396
+ return {
397
+ getLiveness,
398
+ getIntegrationContext,
399
+ startLogin,
400
+ completeLogin,
401
+ logoutProvider,
402
+ getAuthoringSession,
403
+ revokeAuthoringSession,
404
+ getEmbedContext,
405
+ listMaps,
406
+ createMap,
407
+ getMutationStatus,
408
+ getMap,
409
+ saveMap,
410
+ changeMap,
411
+ listMapRevisions,
412
+ getMapRevision,
413
+ getGetLivenessUrl,
414
+ getGetIntegrationContextUrl,
415
+ getStartLoginUrl,
416
+ getCompleteLoginUrl,
417
+ getLogoutProviderUrl,
418
+ getGetAuthoringSessionUrl,
419
+ getRevokeAuthoringSessionUrl,
420
+ getGetEmbedContextUrl,
421
+ getListMapsUrl,
422
+ getCreateMapUrl,
423
+ getGetMutationStatusUrl,
424
+ getGetMapUrl,
425
+ getSaveMapUrl,
426
+ getChangeMapUrl,
427
+ getListMapRevisionsUrl,
428
+ getGetMapRevisionUrl,
429
+ };
399
430
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./generated.js";
2
2
  export { Configuration, type ConfigurationParameters, } from "./configuration.js";
3
- export { ApiError } from "./errors/api-error.js";
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./generated.js";
2
2
  export { Configuration, } from "./configuration.js";
3
- export { ApiError } from "./errors/api-error.js";
@@ -1,2 +1,3 @@
1
+ import type { AxiosRequestConfig } from "axios";
1
2
  import type { Configuration } from "./configuration.js";
2
- export declare function createApiFetcher(configuration: Configuration): typeof globalThis.fetch;
3
+ export declare function prepareRequestOptions(configuration: Configuration, basePath: string | undefined, options: AxiosRequestConfig | undefined, method: string, body?: unknown): Promise<AxiosRequestConfig<unknown>>;
package/dist/transport.js CHANGED
@@ -1,70 +1,31 @@
1
- import { ApiError } from "./errors/api-error.js";
1
+ import { mergeConfig } from "axios";
2
2
  const clientContract = "1";
3
3
  const requestCompressionThreshold = 64 * 1024;
4
- export function createApiFetcher(configuration) {
5
- const baseUrl = new URL(configuration.basePath);
6
- return async (input, options) => {
7
- const request = input instanceof Request ? input : undefined;
8
- const headers = normalizeHeaders(options?.headers ?? request?.headers ?? {});
9
- const method = (options?.method ?? request?.method ?? "GET").toUpperCase();
10
- if (!["GET", "HEAD", "OPTIONS"].includes(method)) {
11
- headers.set("X-Seatmap-Contract", clientContract);
12
- if (configuration.csrfToken) {
13
- headers.set("X-CSRF-Token", configuration.csrfToken);
14
- }
15
- }
16
- let body = options?.body;
17
- if (configuration.compressRequests &&
18
- typeof body === "string" &&
19
- body.length >= requestCompressionThreshold &&
20
- !headers.has("Content-Encoding") &&
21
- typeof CompressionStream !== "undefined") {
22
- body = await new Response(new Blob([body]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer();
23
- headers.set("Content-Encoding", "gzip");
24
- }
25
- try {
26
- const response = await configuration.fetchApi(typeof input === "string" ? new URL(input, baseUrl) : input, {
27
- ...options,
28
- ...(body !== undefined ? { body } : {}),
29
- headers,
30
- ...(configuration.credentials
31
- ? { credentials: configuration.credentials }
32
- : {}),
33
- });
34
- if (response.status === 401) {
35
- configuration.csrfToken = undefined;
36
- }
37
- if (!response.ok && response.status !== 304) {
38
- throw new ApiError(response);
39
- }
40
- return response;
41
- }
42
- catch (cause) {
43
- if (cause instanceof Error && cause.name === "AbortError") {
44
- throw cause;
45
- }
46
- if (configuration.mapError) {
47
- throw await configuration.mapError(cause);
48
- }
49
- throw cause;
50
- }
51
- };
52
- }
53
- function normalizeHeaders(source) {
54
- let entries;
55
- if (source instanceof Headers) {
56
- entries = source.entries();
4
+ export async function prepareRequestOptions(configuration, basePath, options, method, body) {
5
+ const prepared = mergeConfig(configuration.baseOptions ?? {}, options ?? {});
6
+ const headers = { ...prepared.headers };
7
+ if (!["GET", "HEAD", "OPTIONS"].includes(method)) {
8
+ headers["X-Seatmap-Contract"] = clientContract;
9
+ }
10
+ const configuredBasePath = basePath ?? configuration.basePath;
11
+ if (configuredBasePath !== undefined) {
12
+ prepared.baseURL = configuredBasePath;
57
13
  }
58
- else if (Array.isArray(source)) {
59
- entries = source;
14
+ prepared.headers = headers;
15
+ if (prepared.validateStatus === undefined) {
16
+ prepared.validateStatus = (status) => (status >= 200 && status < 300) || status === 304;
60
17
  }
61
- else {
62
- entries = Object.entries(source);
18
+ if (!configuration.compressRequests ||
19
+ body === undefined ||
20
+ Object.keys(headers).some((name) => name.toLowerCase() === "content-encoding")) {
21
+ return prepared;
63
22
  }
64
- const headers = new Headers();
65
- // Caller headers replace differently cased generated defaults instead of being combined.
66
- for (const [name, value] of entries) {
67
- headers.set(name, value);
23
+ const serialized = JSON.stringify(options?.data ?? body);
24
+ if (serialized.length < requestCompressionThreshold ||
25
+ typeof CompressionStream === "undefined") {
26
+ return prepared;
68
27
  }
69
- return headers;
28
+ prepared.data = await new Response(new Blob([serialized]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer();
29
+ headers["Content-Encoding"] = "gzip";
30
+ return prepared;
70
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatmap-fyi/api-client",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -18,5 +18,8 @@
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "axios": "1.20.0"
21
24
  }
22
25
  }
@@ -1,5 +0,0 @@
1
- export declare class ApiError extends Error {
2
- readonly status: number;
3
- readonly response: Response;
4
- constructor(response: Response);
5
- }
@@ -1,10 +0,0 @@
1
- export class ApiError extends Error {
2
- status;
3
- response;
4
- constructor(response) {
5
- super(`API request failed with HTTP ${response.status}.`);
6
- this.name = "ApiError";
7
- this.status = response.status;
8
- this.response = response;
9
- }
10
- }