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

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;
@@ -79,6 +93,8 @@ export declare enum MapLifecycle {
79
93
  deleted = "deleted"
80
94
  }
81
95
  export interface MapSummaryDto {
96
+ /** @pattern ^[a-z]{3}-[a-z]{4}-[a-z]{3}$ */
97
+ editorCode: string;
82
98
  id: string;
83
99
  name: string;
84
100
  lifecycle: MapLifecycle;
@@ -2160,6 +2176,11 @@ export interface MutationStatusDto {
2160
2176
  status: MutationStatus;
2161
2177
  result?: MapAcknowledgementDto;
2162
2178
  }
2179
+ export interface MapLinkDto {
2180
+ mapId: string;
2181
+ /** @pattern ^[a-z]{3}-[a-z]{4}-[a-z]{3}$ */
2182
+ editorCode: string;
2183
+ }
2163
2184
  export interface MapResponseDto {
2164
2185
  physical: PhysicalDocumentV1Dto;
2165
2186
  referencePresentation?: ReferencePresentationDto;
@@ -2346,33 +2367,40 @@ export declare enum ListMapsLifecycle {
2346
2367
  }
2347
2368
  import type { Configuration } from "./configuration.js";
2348
2369
  export declare class HealthClient {
2349
- private readonly fetchApi;
2350
- constructor(configuration: Configuration);
2351
- getLiveness(options?: RequestInit): Promise<HealthResponseDto>;
2370
+ private readonly configuration;
2371
+ private readonly basePath?;
2372
+ private readonly operations;
2373
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2374
+ getLiveness(options?: AxiosRequestConfig): Promise<AxiosResponse<HealthResponseDto>>;
2352
2375
  }
2353
2376
  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>;
2377
+ private readonly configuration;
2378
+ private readonly basePath?;
2379
+ private readonly operations;
2380
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2381
+ getIntegrationContext(options?: AxiosRequestConfig): Promise<AxiosResponse<AccountContextDto>>;
2382
+ startLogin(params: StartLoginParams, options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2383
+ completeLogin(options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2384
+ logoutProvider(options?: AxiosRequestConfig): Promise<AxiosResponse<unknown>>;
2385
+ getAuthoringSession(options?: AxiosRequestConfig): Promise<AxiosResponse<AuthoringSessionContextDto>>;
2386
+ revokeAuthoringSession(options?: AxiosRequestConfig): Promise<AxiosResponse<void>>;
2387
+ getEmbedContext(mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<EmbedContextDto>>;
2364
2388
  startLoginHref(params: StartLoginParams): string;
2365
2389
  logoutProviderHref(): string;
2366
2390
  }
2367
2391
  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>;
2392
+ private readonly configuration;
2393
+ private readonly basePath?;
2394
+ private readonly operations;
2395
+ constructor(configuration: Configuration, basePath?: string | undefined, axiosInstance?: AxiosInstance);
2396
+ listMaps(workspaceId: string, params?: ListMapsParams, options?: AxiosRequestConfig): Promise<AxiosResponse<MapListDto>>;
2397
+ createMap(workspaceId: string, createMapDto: CreateMapDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2398
+ getMutationStatus(workspaceId: string, operationId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MutationStatusDto>>;
2399
+ resolveMapLink(workspaceId: string, editorCode: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapLinkDto>>;
2400
+ getMapLink(workspaceId: string, mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapLinkDto>>;
2401
+ getMap(workspaceId: string, mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapResponseDto>>;
2402
+ saveMap(workspaceId: string, mapId: string, saveMapDto: SaveMapDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2403
+ changeMap(workspaceId: string, mapId: string, mapActionDto: MapActionDto, options?: AxiosRequestConfig): Promise<AxiosResponse<MapAcknowledgementDto>>;
2404
+ listMapRevisions(workspaceId: string, mapId: string, options?: AxiosRequestConfig): Promise<AxiosResponse<MapRevisionDto[]>>;
2405
+ getMapRevision(workspaceId: string, mapId: string, revision: number, options?: AxiosRequestConfig): Promise<AxiosResponse<MapContentDto>>;
2378
2406
  }
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,424 @@ 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);
123
+ }
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);
104
127
  }
105
- listMaps(workspaceId, params, options) {
106
- return listMaps(workspaceId, params, 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);
107
133
  }
108
- createMap(workspaceId, createMapDto, options) {
109
- return createMap(workspaceId, createMapDto, 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);
110
137
  }
111
- getMutationStatus(workspaceId, operationId, options) {
112
- return getMutationStatus(workspaceId, operationId, options, this.fetchApi);
138
+ async resolveMapLink(workspaceId, editorCode, options) {
139
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
140
+ return this.operations.resolveMapLink(workspaceId, editorCode, requestOptions);
113
141
  }
114
- getMap(workspaceId, mapId, options) {
115
- return getMap(workspaceId, mapId, options, this.fetchApi);
142
+ async getMapLink(workspaceId, mapId, options) {
143
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
144
+ return this.operations.getMapLink(workspaceId, mapId, requestOptions);
116
145
  }
117
- saveMap(workspaceId, mapId, saveMapDto, options) {
118
- return saveMap(workspaceId, mapId, saveMapDto, options, this.fetchApi);
146
+ async getMap(workspaceId, mapId, options) {
147
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
148
+ return this.operations.getMap(workspaceId, mapId, requestOptions);
119
149
  }
120
- changeMap(workspaceId, mapId, mapActionDto, options) {
121
- return changeMap(workspaceId, mapId, mapActionDto, options, this.fetchApi);
150
+ async saveMap(workspaceId, mapId, saveMapDto, options) {
151
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "PUT", saveMapDto);
152
+ return this.operations.saveMap(workspaceId, mapId, requestOptions.data instanceof ArrayBuffer
153
+ ? requestOptions.data
154
+ : saveMapDto, requestOptions);
122
155
  }
123
- listMapRevisions(workspaceId, mapId, options) {
124
- return listMapRevisions(workspaceId, mapId, options, this.fetchApi);
156
+ async changeMap(workspaceId, mapId, mapActionDto, options) {
157
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "POST", mapActionDto);
158
+ return this.operations.changeMap(workspaceId, mapId, requestOptions.data instanceof ArrayBuffer
159
+ ? requestOptions.data
160
+ : mapActionDto, requestOptions);
125
161
  }
126
- getMapRevision(workspaceId, mapId, revision, options) {
127
- return getMapRevision(workspaceId, mapId, revision, options, this.fetchApi);
162
+ async listMapRevisions(workspaceId, mapId, options) {
163
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
164
+ return this.operations.listMapRevisions(workspaceId, mapId, requestOptions);
165
+ }
166
+ async getMapRevision(workspaceId, mapId, revision, options) {
167
+ const requestOptions = await prepareRequestOptions(this.configuration, this.basePath, options, "GET");
168
+ return this.operations.getMapRevision(workspaceId, mapId, revision, requestOptions);
128
169
  }
129
170
  }
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;
171
+ const getSeatmapApi = (axiosInstance = axios) => {
172
+ const getLiveness = (options) => {
173
+ return axiosInstance.get(`/health`, options);
174
+ };
175
+ const getGetLivenessUrl = () => {
176
+ return axiosInstance
177
+ .create({
178
+ baseURL: "",
179
+ params: null,
180
+ })
181
+ .getUri({
182
+ url: `/health`,
183
+ baseURL: "",
184
+ });
185
+ };
186
+ const getIntegrationContext = (options) => {
187
+ return axiosInstance.get(`/auth/integration`, options);
188
+ };
189
+ const getGetIntegrationContextUrl = () => {
190
+ return axiosInstance
191
+ .create({
192
+ baseURL: "",
193
+ params: null,
194
+ })
195
+ .getUri({
196
+ url: `/auth/integration`,
197
+ baseURL: "",
198
+ });
199
+ };
200
+ const startLogin = (params, options) => {
201
+ return axiosInstance.get(`/auth/login`, {
202
+ ...options,
203
+ params: { ...params, ...options?.params },
204
+ });
205
+ };
206
+ const getStartLoginUrl = (params) => {
207
+ return axiosInstance
208
+ .create({
209
+ baseURL: "",
210
+ params: null,
211
+ })
212
+ .getUri({
213
+ url: `/auth/login`,
214
+ baseURL: "",
215
+ params,
216
+ });
217
+ };
218
+ const completeLogin = (options) => {
219
+ return axiosInstance.get(`/auth/callback`, options);
220
+ };
221
+ const getCompleteLoginUrl = () => {
222
+ return axiosInstance
223
+ .create({
224
+ baseURL: "",
225
+ params: null,
226
+ })
227
+ .getUri({
228
+ url: `/auth/callback`,
229
+ baseURL: "",
230
+ });
231
+ };
232
+ const logoutProvider = (options) => {
233
+ return axiosInstance.get(`/auth/logout/provider`, options);
234
+ };
235
+ const getLogoutProviderUrl = () => {
236
+ return axiosInstance
237
+ .create({
238
+ baseURL: "",
239
+ params: null,
240
+ })
241
+ .getUri({
242
+ url: `/auth/logout/provider`,
243
+ baseURL: "",
244
+ });
245
+ };
246
+ const getAuthoringSession = (options) => {
247
+ return axiosInstance.get(`/auth/authoring/session`, options);
248
+ };
249
+ const getGetAuthoringSessionUrl = () => {
250
+ return axiosInstance
251
+ .create({
252
+ baseURL: "",
253
+ params: null,
254
+ })
255
+ .getUri({
256
+ url: `/auth/authoring/session`,
257
+ baseURL: "",
258
+ });
259
+ };
260
+ const revokeAuthoringSession = (options) => {
261
+ return axiosInstance.delete(`/auth/authoring/session`, options);
262
+ };
263
+ const getRevokeAuthoringSessionUrl = () => {
264
+ return axiosInstance
265
+ .create({
266
+ baseURL: "",
267
+ params: null,
268
+ })
269
+ .getUri({
270
+ url: `/auth/authoring/session`,
271
+ baseURL: "",
272
+ });
273
+ };
274
+ const getEmbedContext = (mapId, options) => {
275
+ return axiosInstance.get(`/auth/embed/${encodeURIComponent(mapId)}`, options);
276
+ };
277
+ const getGetEmbedContextUrl = (mapId) => {
278
+ return axiosInstance
279
+ .create({
280
+ baseURL: "",
281
+ params: null,
282
+ })
283
+ .getUri({
284
+ url: `/auth/embed/${encodeURIComponent(mapId)}`,
285
+ baseURL: "",
286
+ });
287
+ };
288
+ const listMaps = (workspaceId, params, options) => {
289
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps`, {
290
+ ...options,
291
+ params: { ...params, ...options?.params },
292
+ });
293
+ };
294
+ const getListMapsUrl = (workspaceId, params) => {
295
+ return axiosInstance
296
+ .create({
297
+ baseURL: "",
298
+ params: null,
299
+ })
300
+ .getUri({
301
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps`,
302
+ baseURL: "",
303
+ params,
304
+ });
305
+ };
306
+ const createMap = (workspaceId, createMapDto, options) => {
307
+ return axiosInstance.post(`/workspaces/${encodeURIComponent(workspaceId)}/maps`, createMapDto, options);
308
+ };
309
+ const getCreateMapUrl = (workspaceId) => {
310
+ return axiosInstance
311
+ .create({
312
+ baseURL: "",
313
+ params: null,
314
+ })
315
+ .getUri({
316
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps`,
317
+ baseURL: "",
318
+ });
319
+ };
320
+ const getMutationStatus = (workspaceId, operationId, options) => {
321
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/operations/${encodeURIComponent(operationId)}`, options);
322
+ };
323
+ const getGetMutationStatusUrl = (workspaceId, operationId) => {
324
+ return axiosInstance
325
+ .create({
326
+ baseURL: "",
327
+ params: null,
328
+ })
329
+ .getUri({
330
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/operations/${encodeURIComponent(operationId)}`,
331
+ baseURL: "",
332
+ });
333
+ };
334
+ /**
335
+ * @summary Resolve a permanent map code within an authorized workspace
336
+ */
337
+ const resolveMapLink = (workspaceId, editorCode, options) => {
338
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/links/${encodeURIComponent(editorCode)}`, options);
339
+ };
340
+ const getResolveMapLinkUrl = (workspaceId, editorCode) => {
341
+ return axiosInstance
342
+ .create({
343
+ baseURL: "",
344
+ params: null,
345
+ })
346
+ .getUri({
347
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/links/${encodeURIComponent(editorCode)}`,
348
+ baseURL: "",
349
+ });
350
+ };
351
+ /**
352
+ * @summary Get a map's permanent editor link
353
+ */
354
+ const getMapLink = (workspaceId, mapId, options) => {
355
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/link`, options);
356
+ };
357
+ const getGetMapLinkUrl = (workspaceId, mapId) => {
358
+ return axiosInstance
359
+ .create({
360
+ baseURL: "",
361
+ params: null,
362
+ })
363
+ .getUri({
364
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/link`,
365
+ baseURL: "",
366
+ });
367
+ };
368
+ const getMap = (workspaceId, mapId, options) => {
369
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}`, options);
370
+ };
371
+ const getGetMapUrl = (workspaceId, mapId) => {
372
+ return axiosInstance
373
+ .create({
374
+ baseURL: "",
375
+ params: null,
376
+ })
377
+ .getUri({
378
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}`,
379
+ baseURL: "",
380
+ });
381
+ };
382
+ const saveMap = (workspaceId, mapId, saveMapDto, options) => {
383
+ return axiosInstance.put(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/draft`, saveMapDto, options);
384
+ };
385
+ const getSaveMapUrl = (workspaceId, mapId) => {
386
+ return axiosInstance
387
+ .create({
388
+ baseURL: "",
389
+ params: null,
390
+ })
391
+ .getUri({
392
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/draft`,
393
+ baseURL: "",
394
+ });
395
+ };
396
+ const changeMap = (workspaceId, mapId, mapActionDto, options) => {
397
+ return axiosInstance.post(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/actions`, mapActionDto, options);
398
+ };
399
+ const getChangeMapUrl = (workspaceId, mapId) => {
400
+ return axiosInstance
401
+ .create({
402
+ baseURL: "",
403
+ params: null,
404
+ })
405
+ .getUri({
406
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/actions`,
407
+ baseURL: "",
408
+ });
409
+ };
410
+ const listMapRevisions = (workspaceId, mapId, options) => {
411
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions`, options);
412
+ };
413
+ const getListMapRevisionsUrl = (workspaceId, mapId) => {
414
+ return axiosInstance
415
+ .create({
416
+ baseURL: "",
417
+ params: null,
418
+ })
419
+ .getUri({
420
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions`,
421
+ baseURL: "",
422
+ });
423
+ };
424
+ const getMapRevision = (workspaceId, mapId, revision, options) => {
425
+ return axiosInstance.get(`/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions/${encodeURIComponent(revision)}`, options);
426
+ };
427
+ const getGetMapRevisionUrl = (workspaceId, mapId, revision) => {
428
+ return axiosInstance
429
+ .create({
430
+ baseURL: "",
431
+ params: null,
432
+ })
433
+ .getUri({
434
+ url: `/workspaces/${encodeURIComponent(workspaceId)}/maps/${encodeURIComponent(mapId)}/revisions/${encodeURIComponent(revision)}`,
435
+ baseURL: "",
436
+ });
437
+ };
438
+ return {
439
+ getLiveness,
440
+ getIntegrationContext,
441
+ startLogin,
442
+ completeLogin,
443
+ logoutProvider,
444
+ getAuthoringSession,
445
+ revokeAuthoringSession,
446
+ getEmbedContext,
447
+ listMaps,
448
+ createMap,
449
+ getMutationStatus,
450
+ resolveMapLink,
451
+ getMapLink,
452
+ getMap,
453
+ saveMap,
454
+ changeMap,
455
+ listMapRevisions,
456
+ getMapRevision,
457
+ getGetLivenessUrl,
458
+ getGetIntegrationContextUrl,
459
+ getStartLoginUrl,
460
+ getCompleteLoginUrl,
461
+ getLogoutProviderUrl,
462
+ getGetAuthoringSessionUrl,
463
+ getRevokeAuthoringSessionUrl,
464
+ getGetEmbedContextUrl,
465
+ getListMapsUrl,
466
+ getCreateMapUrl,
467
+ getGetMutationStatusUrl,
468
+ getResolveMapLinkUrl,
469
+ getGetMapLinkUrl,
470
+ getGetMapUrl,
471
+ getSaveMapUrl,
472
+ getChangeMapUrl,
473
+ getListMapRevisionsUrl,
474
+ getGetMapRevisionUrl,
475
+ };
399
476
  };
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.6",
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
- }