@seatmap-fyi/api-client 0.0.0-stage → 0.1.0-alpha.1
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.
- package/dist/configuration.d.ts +9 -0
- package/dist/configuration.js +8 -0
- package/dist/errors/api-error.d.ts +5 -0
- package/dist/errors/api-error.js +10 -0
- package/dist/generated.d.ts +2375 -0
- package/dist/generated.js +391 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/transport.d.ts +2 -0
- package/dist/transport.js +26 -0
- package/package.json +20 -4
- package/README.md +0 -3
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
export var Capability;
|
|
2
|
+
(function (Capability) {
|
|
3
|
+
Capability["MAPS_READ"] = "maps:read";
|
|
4
|
+
Capability["MAPS_WRITE"] = "maps:write";
|
|
5
|
+
Capability["MAPS_PUBLISH"] = "maps:publish";
|
|
6
|
+
Capability["COMMERCE_WRITE"] = "commerce:write";
|
|
7
|
+
Capability["ACCESS_ADMIN"] = "access:admin";
|
|
8
|
+
Capability["MAP_VIEW"] = "map:view";
|
|
9
|
+
})(Capability || (Capability = {}));
|
|
10
|
+
export var AccountContextDtoKind;
|
|
11
|
+
(function (AccountContextDtoKind) {
|
|
12
|
+
AccountContextDtoKind["integration"] = "integration";
|
|
13
|
+
AccountContextDtoKind["authoring"] = "authoring";
|
|
14
|
+
})(AccountContextDtoKind || (AccountContextDtoKind = {}));
|
|
15
|
+
export var EmbedContextDtoKind;
|
|
16
|
+
(function (EmbedContextDtoKind) {
|
|
17
|
+
EmbedContextDtoKind["embed"] = "embed";
|
|
18
|
+
})(EmbedContextDtoKind || (EmbedContextDtoKind = {}));
|
|
19
|
+
export var EmbedContextDtoCapabilitiesItem;
|
|
20
|
+
(function (EmbedContextDtoCapabilitiesItem) {
|
|
21
|
+
EmbedContextDtoCapabilitiesItem["map:view"] = "map:view";
|
|
22
|
+
})(EmbedContextDtoCapabilitiesItem || (EmbedContextDtoCapabilitiesItem = {}));
|
|
23
|
+
export var MapLifecycle;
|
|
24
|
+
(function (MapLifecycle) {
|
|
25
|
+
MapLifecycle["active"] = "active";
|
|
26
|
+
MapLifecycle["archived"] = "archived";
|
|
27
|
+
MapLifecycle["trashed"] = "trashed";
|
|
28
|
+
MapLifecycle["deleted"] = "deleted";
|
|
29
|
+
})(MapLifecycle || (MapLifecycle = {}));
|
|
30
|
+
export var MutationStatus;
|
|
31
|
+
(function (MutationStatus) {
|
|
32
|
+
MutationStatus["completed"] = "completed";
|
|
33
|
+
MutationStatus["notCurrentlyKnown"] = "notCurrentlyKnown";
|
|
34
|
+
})(MutationStatus || (MutationStatus = {}));
|
|
35
|
+
export var MapOperation;
|
|
36
|
+
(function (MapOperation) {
|
|
37
|
+
MapOperation["create"] = "create";
|
|
38
|
+
MapOperation["adopt"] = "adopt";
|
|
39
|
+
MapOperation["save"] = "save";
|
|
40
|
+
MapOperation["rename"] = "rename";
|
|
41
|
+
MapOperation["copy"] = "copy";
|
|
42
|
+
MapOperation["archive"] = "archive";
|
|
43
|
+
MapOperation["restore"] = "restore";
|
|
44
|
+
MapOperation["trash"] = "trash";
|
|
45
|
+
MapOperation["restoreTrash"] = "restoreTrash";
|
|
46
|
+
MapOperation["restoreRevision"] = "restoreRevision";
|
|
47
|
+
})(MapOperation || (MapOperation = {}));
|
|
48
|
+
export var ListMapsLifecycle;
|
|
49
|
+
(function (ListMapsLifecycle) {
|
|
50
|
+
ListMapsLifecycle["active"] = "active";
|
|
51
|
+
ListMapsLifecycle["archived"] = "archived";
|
|
52
|
+
ListMapsLifecycle["trashed"] = "trashed";
|
|
53
|
+
ListMapsLifecycle["deleted"] = "deleted";
|
|
54
|
+
})(ListMapsLifecycle || (ListMapsLifecycle = {}));
|
|
55
|
+
import { createApiFetcher } from "./transport.js";
|
|
56
|
+
export class HealthClient {
|
|
57
|
+
fetchApi;
|
|
58
|
+
constructor(configuration) {
|
|
59
|
+
this.fetchApi = createApiFetcher(configuration);
|
|
60
|
+
}
|
|
61
|
+
getLiveness(options) {
|
|
62
|
+
return getLiveness(options, this.fetchApi);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export class AuthenticationClient {
|
|
66
|
+
fetchApi;
|
|
67
|
+
constructor(configuration) {
|
|
68
|
+
this.fetchApi = createApiFetcher(configuration);
|
|
69
|
+
}
|
|
70
|
+
getIntegrationContext(options) {
|
|
71
|
+
return getIntegrationContext(options, this.fetchApi);
|
|
72
|
+
}
|
|
73
|
+
startLogin(params, options) {
|
|
74
|
+
return startLogin(params, options, this.fetchApi);
|
|
75
|
+
}
|
|
76
|
+
completeLogin(options) {
|
|
77
|
+
return completeLogin(options, this.fetchApi);
|
|
78
|
+
}
|
|
79
|
+
logoutProvider(options) {
|
|
80
|
+
return logoutProvider(options, this.fetchApi);
|
|
81
|
+
}
|
|
82
|
+
getAuthoringSession(options) {
|
|
83
|
+
return getAuthoringSession(options, this.fetchApi);
|
|
84
|
+
}
|
|
85
|
+
revokeAuthoringSession(options) {
|
|
86
|
+
return revokeAuthoringSession(options, this.fetchApi);
|
|
87
|
+
}
|
|
88
|
+
getEmbedContext(mapId, options) {
|
|
89
|
+
return getEmbedContext(mapId, options, this.fetchApi);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class MapsClient {
|
|
93
|
+
fetchApi;
|
|
94
|
+
constructor(configuration) {
|
|
95
|
+
this.fetchApi = createApiFetcher(configuration);
|
|
96
|
+
}
|
|
97
|
+
listMaps(workspaceId, params, options) {
|
|
98
|
+
return listMaps(workspaceId, params, options, this.fetchApi);
|
|
99
|
+
}
|
|
100
|
+
createMap(workspaceId, createMapDto, options) {
|
|
101
|
+
return createMap(workspaceId, createMapDto, options, this.fetchApi);
|
|
102
|
+
}
|
|
103
|
+
getMutationStatus(workspaceId, operationId, options) {
|
|
104
|
+
return getMutationStatus(workspaceId, operationId, options, this.fetchApi);
|
|
105
|
+
}
|
|
106
|
+
getMap(workspaceId, mapId, options) {
|
|
107
|
+
return getMap(workspaceId, mapId, options, this.fetchApi);
|
|
108
|
+
}
|
|
109
|
+
saveMap(workspaceId, mapId, saveMapDto, options) {
|
|
110
|
+
return saveMap(workspaceId, mapId, saveMapDto, options, this.fetchApi);
|
|
111
|
+
}
|
|
112
|
+
changeMap(workspaceId, mapId, mapActionDto, options) {
|
|
113
|
+
return changeMap(workspaceId, mapId, mapActionDto, options, this.fetchApi);
|
|
114
|
+
}
|
|
115
|
+
listMapRevisions(workspaceId, mapId, options) {
|
|
116
|
+
return listMapRevisions(workspaceId, mapId, options, this.fetchApi);
|
|
117
|
+
}
|
|
118
|
+
getMapRevision(workspaceId, mapId, revision, options) {
|
|
119
|
+
return getMapRevision(workspaceId, mapId, revision, options, this.fetchApi);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const getGetLivenessUrl = () => {
|
|
123
|
+
return `/health/live`;
|
|
124
|
+
};
|
|
125
|
+
const getLiveness = async (options, fetchFn) => {
|
|
126
|
+
const res = await (fetchFn ?? fetch)(getGetLivenessUrl(), {
|
|
127
|
+
...options,
|
|
128
|
+
method: "GET",
|
|
129
|
+
});
|
|
130
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
131
|
+
const data = body ? JSON.parse(body) : {};
|
|
132
|
+
return data;
|
|
133
|
+
};
|
|
134
|
+
const getGetIntegrationContextUrl = () => {
|
|
135
|
+
return `/v1/auth/integration`;
|
|
136
|
+
};
|
|
137
|
+
const getIntegrationContext = async (options, fetchFn) => {
|
|
138
|
+
const res = await (fetchFn ?? fetch)(getGetIntegrationContextUrl(), {
|
|
139
|
+
...options,
|
|
140
|
+
method: "GET",
|
|
141
|
+
});
|
|
142
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
143
|
+
const data = body ? JSON.parse(body) : {};
|
|
144
|
+
return data;
|
|
145
|
+
};
|
|
146
|
+
const getStartLoginUrl = (params) => {
|
|
147
|
+
const normalizedParams = new URLSearchParams();
|
|
148
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
149
|
+
if (value !== undefined) {
|
|
150
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const stringifiedParams = normalizedParams.toString();
|
|
154
|
+
return stringifiedParams.length > 0
|
|
155
|
+
? `/v1/auth/login?${stringifiedParams}`
|
|
156
|
+
: `/v1/auth/login`;
|
|
157
|
+
};
|
|
158
|
+
const startLogin = async (params, options, fetchFn) => {
|
|
159
|
+
const res = await (fetchFn ?? fetch)(getStartLoginUrl(params), {
|
|
160
|
+
...options,
|
|
161
|
+
method: "GET",
|
|
162
|
+
});
|
|
163
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
164
|
+
const data = body ? JSON.parse(body) : {};
|
|
165
|
+
return data;
|
|
166
|
+
};
|
|
167
|
+
const getCompleteLoginUrl = () => {
|
|
168
|
+
return `/v1/auth/callback`;
|
|
169
|
+
};
|
|
170
|
+
const completeLogin = async (options, fetchFn) => {
|
|
171
|
+
const res = await (fetchFn ?? fetch)(getCompleteLoginUrl(), {
|
|
172
|
+
...options,
|
|
173
|
+
method: "GET",
|
|
174
|
+
});
|
|
175
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
176
|
+
const data = body ? JSON.parse(body) : {};
|
|
177
|
+
return data;
|
|
178
|
+
};
|
|
179
|
+
const getLogoutProviderUrl = () => {
|
|
180
|
+
return `/v1/auth/logout/provider`;
|
|
181
|
+
};
|
|
182
|
+
const logoutProvider = async (options, fetchFn) => {
|
|
183
|
+
const res = await (fetchFn ?? fetch)(getLogoutProviderUrl(), {
|
|
184
|
+
...options,
|
|
185
|
+
method: "GET",
|
|
186
|
+
});
|
|
187
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
188
|
+
const data = body ? JSON.parse(body) : {};
|
|
189
|
+
return data;
|
|
190
|
+
};
|
|
191
|
+
const getGetAuthoringSessionUrl = () => {
|
|
192
|
+
return `/v1/auth/authoring/session`;
|
|
193
|
+
};
|
|
194
|
+
const getAuthoringSession = async (options, fetchFn) => {
|
|
195
|
+
const res = await (fetchFn ?? fetch)(getGetAuthoringSessionUrl(), {
|
|
196
|
+
...options,
|
|
197
|
+
method: "GET",
|
|
198
|
+
});
|
|
199
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
200
|
+
const data = body ? JSON.parse(body) : {};
|
|
201
|
+
return data;
|
|
202
|
+
};
|
|
203
|
+
const getRevokeAuthoringSessionUrl = () => {
|
|
204
|
+
return `/v1/auth/authoring/session`;
|
|
205
|
+
};
|
|
206
|
+
const revokeAuthoringSession = async (options, fetchFn) => {
|
|
207
|
+
const res = await (fetchFn ?? fetch)(getRevokeAuthoringSessionUrl(), {
|
|
208
|
+
...options,
|
|
209
|
+
method: "DELETE",
|
|
210
|
+
});
|
|
211
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
212
|
+
const data = body ? JSON.parse(body) : undefined;
|
|
213
|
+
return data;
|
|
214
|
+
};
|
|
215
|
+
const getGetEmbedContextUrl = (mapId) => {
|
|
216
|
+
return `/v1/auth/embed/${encodeURIComponent(String(mapId))}`;
|
|
217
|
+
};
|
|
218
|
+
const getEmbedContext = async (mapId, options, fetchFn) => {
|
|
219
|
+
const res = await (fetchFn ?? fetch)(getGetEmbedContextUrl(mapId), {
|
|
220
|
+
...options,
|
|
221
|
+
method: "GET",
|
|
222
|
+
});
|
|
223
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
224
|
+
const data = body ? JSON.parse(body) : {};
|
|
225
|
+
return data;
|
|
226
|
+
};
|
|
227
|
+
const getListMapsUrl = (workspaceId, params) => {
|
|
228
|
+
const normalizedParams = new URLSearchParams();
|
|
229
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
230
|
+
if (value !== undefined) {
|
|
231
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const stringifiedParams = normalizedParams.toString();
|
|
235
|
+
return stringifiedParams.length > 0
|
|
236
|
+
? `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps?${stringifiedParams}`
|
|
237
|
+
: `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps`;
|
|
238
|
+
};
|
|
239
|
+
const listMaps = async (workspaceId, params, options, fetchFn) => {
|
|
240
|
+
const res = await (fetchFn ?? fetch)(getListMapsUrl(workspaceId, params), {
|
|
241
|
+
...options,
|
|
242
|
+
method: "GET",
|
|
243
|
+
});
|
|
244
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
245
|
+
const data = body ? JSON.parse(body) : {};
|
|
246
|
+
return data;
|
|
247
|
+
};
|
|
248
|
+
const getCreateMapUrl = (workspaceId) => {
|
|
249
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps`;
|
|
250
|
+
};
|
|
251
|
+
const createMap = async (workspaceId, createMapDto, options, fetchFn) => {
|
|
252
|
+
const getHeaders = (h) => {
|
|
253
|
+
if (!h)
|
|
254
|
+
return {};
|
|
255
|
+
if (h instanceof Headers)
|
|
256
|
+
return Object.fromEntries(h.entries());
|
|
257
|
+
if (Symbol.iterator in h) {
|
|
258
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
259
|
+
}
|
|
260
|
+
const headers = {};
|
|
261
|
+
for (const [name, value] of Object.entries(h)) {
|
|
262
|
+
if (value !== undefined)
|
|
263
|
+
headers[name] = value;
|
|
264
|
+
}
|
|
265
|
+
return headers;
|
|
266
|
+
};
|
|
267
|
+
const res = await (fetchFn ?? fetch)(getCreateMapUrl(workspaceId), {
|
|
268
|
+
...options,
|
|
269
|
+
method: "POST",
|
|
270
|
+
headers: {
|
|
271
|
+
"Content-Type": "application/json",
|
|
272
|
+
...getHeaders(options?.headers),
|
|
273
|
+
},
|
|
274
|
+
body: JSON.stringify(createMapDto),
|
|
275
|
+
});
|
|
276
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
277
|
+
const data = body ? JSON.parse(body) : {};
|
|
278
|
+
return data;
|
|
279
|
+
};
|
|
280
|
+
const getGetMutationStatusUrl = (workspaceId, operationId) => {
|
|
281
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/operations/${encodeURIComponent(String(operationId))}`;
|
|
282
|
+
};
|
|
283
|
+
const getMutationStatus = async (workspaceId, operationId, options, fetchFn) => {
|
|
284
|
+
const res = await (fetchFn ?? fetch)(getGetMutationStatusUrl(workspaceId, operationId), {
|
|
285
|
+
...options,
|
|
286
|
+
method: "GET",
|
|
287
|
+
});
|
|
288
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
289
|
+
const data = body ? JSON.parse(body) : {};
|
|
290
|
+
return data;
|
|
291
|
+
};
|
|
292
|
+
const getGetMapUrl = (workspaceId, mapId) => {
|
|
293
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}`;
|
|
294
|
+
};
|
|
295
|
+
const getMap = async (workspaceId, mapId, options, fetchFn) => {
|
|
296
|
+
const res = await (fetchFn ?? fetch)(getGetMapUrl(workspaceId, mapId), {
|
|
297
|
+
...options,
|
|
298
|
+
method: "GET",
|
|
299
|
+
});
|
|
300
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
301
|
+
const data = body ? JSON.parse(body) : {};
|
|
302
|
+
return data;
|
|
303
|
+
};
|
|
304
|
+
const getSaveMapUrl = (workspaceId, mapId) => {
|
|
305
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/draft`;
|
|
306
|
+
};
|
|
307
|
+
const saveMap = async (workspaceId, mapId, saveMapDto, options, fetchFn) => {
|
|
308
|
+
const getHeaders = (h) => {
|
|
309
|
+
if (!h)
|
|
310
|
+
return {};
|
|
311
|
+
if (h instanceof Headers)
|
|
312
|
+
return Object.fromEntries(h.entries());
|
|
313
|
+
if (Symbol.iterator in h) {
|
|
314
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
315
|
+
}
|
|
316
|
+
const headers = {};
|
|
317
|
+
for (const [name, value] of Object.entries(h)) {
|
|
318
|
+
if (value !== undefined)
|
|
319
|
+
headers[name] = value;
|
|
320
|
+
}
|
|
321
|
+
return headers;
|
|
322
|
+
};
|
|
323
|
+
const res = await (fetchFn ?? fetch)(getSaveMapUrl(workspaceId, mapId), {
|
|
324
|
+
...options,
|
|
325
|
+
method: "PUT",
|
|
326
|
+
headers: {
|
|
327
|
+
"Content-Type": "application/json",
|
|
328
|
+
...getHeaders(options?.headers),
|
|
329
|
+
},
|
|
330
|
+
body: JSON.stringify(saveMapDto),
|
|
331
|
+
});
|
|
332
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
333
|
+
const data = body ? JSON.parse(body) : {};
|
|
334
|
+
return data;
|
|
335
|
+
};
|
|
336
|
+
const getChangeMapUrl = (workspaceId, mapId) => {
|
|
337
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/actions`;
|
|
338
|
+
};
|
|
339
|
+
const changeMap = async (workspaceId, mapId, mapActionDto, options, fetchFn) => {
|
|
340
|
+
const getHeaders = (h) => {
|
|
341
|
+
if (!h)
|
|
342
|
+
return {};
|
|
343
|
+
if (h instanceof Headers)
|
|
344
|
+
return Object.fromEntries(h.entries());
|
|
345
|
+
if (Symbol.iterator in h) {
|
|
346
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
347
|
+
}
|
|
348
|
+
const headers = {};
|
|
349
|
+
for (const [name, value] of Object.entries(h)) {
|
|
350
|
+
if (value !== undefined)
|
|
351
|
+
headers[name] = value;
|
|
352
|
+
}
|
|
353
|
+
return headers;
|
|
354
|
+
};
|
|
355
|
+
const res = await (fetchFn ?? fetch)(getChangeMapUrl(workspaceId, mapId), {
|
|
356
|
+
...options,
|
|
357
|
+
method: "POST",
|
|
358
|
+
headers: {
|
|
359
|
+
"Content-Type": "application/json",
|
|
360
|
+
...getHeaders(options?.headers),
|
|
361
|
+
},
|
|
362
|
+
body: JSON.stringify(mapActionDto),
|
|
363
|
+
});
|
|
364
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
365
|
+
const data = body ? JSON.parse(body) : {};
|
|
366
|
+
return data;
|
|
367
|
+
};
|
|
368
|
+
const getListMapRevisionsUrl = (workspaceId, mapId) => {
|
|
369
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/revisions`;
|
|
370
|
+
};
|
|
371
|
+
const listMapRevisions = async (workspaceId, mapId, options, fetchFn) => {
|
|
372
|
+
const res = await (fetchFn ?? fetch)(getListMapRevisionsUrl(workspaceId, mapId), {
|
|
373
|
+
...options,
|
|
374
|
+
method: "GET",
|
|
375
|
+
});
|
|
376
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
377
|
+
const data = body ? JSON.parse(body) : {};
|
|
378
|
+
return data;
|
|
379
|
+
};
|
|
380
|
+
const getGetMapRevisionUrl = (workspaceId, mapId, revision) => {
|
|
381
|
+
return `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps/${encodeURIComponent(String(mapId))}/revisions/${encodeURIComponent(String(revision))}`;
|
|
382
|
+
};
|
|
383
|
+
const getMapRevision = async (workspaceId, mapId, revision, options, fetchFn) => {
|
|
384
|
+
const res = await (fetchFn ?? fetch)(getGetMapRevisionUrl(workspaceId, mapId, revision), {
|
|
385
|
+
...options,
|
|
386
|
+
method: "GET",
|
|
387
|
+
});
|
|
388
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
389
|
+
const data = body ? JSON.parse(body) : {};
|
|
390
|
+
return data;
|
|
391
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ApiError } from "./errors/api-error.js";
|
|
2
|
+
export function createApiFetcher(configuration) {
|
|
3
|
+
const baseUrl = new URL(configuration.basePath);
|
|
4
|
+
return async (input, options) => {
|
|
5
|
+
const requestOptions = options?.headers === undefined
|
|
6
|
+
? options
|
|
7
|
+
: { ...options, headers: normalizeHeaders(options.headers) };
|
|
8
|
+
const response = await configuration.fetchApi(typeof input === "string" ? new URL(input, baseUrl) : input, requestOptions);
|
|
9
|
+
if (!response.ok && response.status !== 304) {
|
|
10
|
+
throw new ApiError(response);
|
|
11
|
+
}
|
|
12
|
+
return response;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function normalizeHeaders(source) {
|
|
16
|
+
if (source instanceof Headers) {
|
|
17
|
+
return source;
|
|
18
|
+
}
|
|
19
|
+
const entries = Array.isArray(source) ? source : Object.entries(source);
|
|
20
|
+
const headers = new Headers();
|
|
21
|
+
// Native Headers construction combines differently cased duplicates instead of replacing them.
|
|
22
|
+
for (const [name, value] of entries) {
|
|
23
|
+
headers.set(name, value);
|
|
24
|
+
}
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatmap-fyi/api-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\" && tsc -p tsconfig.json"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/README.md
DELETED