@seatmap-fyi/api-client 0.0.0-stage → 0.1.0-alpha.2

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.
@@ -0,0 +1,399 @@
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
+ basePath;
68
+ constructor(configuration) {
69
+ this.basePath = configuration.basePath;
70
+ this.fetchApi = createApiFetcher(configuration);
71
+ }
72
+ getIntegrationContext(options) {
73
+ return getIntegrationContext(options, this.fetchApi);
74
+ }
75
+ startLogin(params, options) {
76
+ return startLogin(params, options, this.fetchApi);
77
+ }
78
+ completeLogin(options) {
79
+ return completeLogin(options, this.fetchApi);
80
+ }
81
+ logoutProvider(options) {
82
+ return logoutProvider(options, this.fetchApi);
83
+ }
84
+ getAuthoringSession(options) {
85
+ return getAuthoringSession(options, this.fetchApi);
86
+ }
87
+ revokeAuthoringSession(options) {
88
+ return revokeAuthoringSession(options, this.fetchApi);
89
+ }
90
+ getEmbedContext(mapId, options) {
91
+ return getEmbedContext(mapId, options, this.fetchApi);
92
+ }
93
+ startLoginHref(params) {
94
+ return new URL(getStartLoginUrl(params), this.basePath).href;
95
+ }
96
+ logoutProviderHref() {
97
+ return new URL(getLogoutProviderUrl(), this.basePath).href;
98
+ }
99
+ }
100
+ export class MapsClient {
101
+ fetchApi;
102
+ constructor(configuration) {
103
+ this.fetchApi = createApiFetcher(configuration);
104
+ }
105
+ listMaps(workspaceId, params, options) {
106
+ return listMaps(workspaceId, params, options, this.fetchApi);
107
+ }
108
+ createMap(workspaceId, createMapDto, options) {
109
+ return createMap(workspaceId, createMapDto, options, this.fetchApi);
110
+ }
111
+ getMutationStatus(workspaceId, operationId, options) {
112
+ return getMutationStatus(workspaceId, operationId, options, this.fetchApi);
113
+ }
114
+ getMap(workspaceId, mapId, options) {
115
+ return getMap(workspaceId, mapId, options, this.fetchApi);
116
+ }
117
+ saveMap(workspaceId, mapId, saveMapDto, options) {
118
+ return saveMap(workspaceId, mapId, saveMapDto, options, this.fetchApi);
119
+ }
120
+ changeMap(workspaceId, mapId, mapActionDto, options) {
121
+ return changeMap(workspaceId, mapId, mapActionDto, options, this.fetchApi);
122
+ }
123
+ listMapRevisions(workspaceId, mapId, options) {
124
+ return listMapRevisions(workspaceId, mapId, options, this.fetchApi);
125
+ }
126
+ getMapRevision(workspaceId, mapId, revision, options) {
127
+ return getMapRevision(workspaceId, mapId, revision, options, this.fetchApi);
128
+ }
129
+ }
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 `/v1/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
+ ? `/v1/auth/login?${stringifiedParams}`
164
+ : `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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
+ ? `/v1/workspaces/${encodeURIComponent(String(workspaceId))}/maps?${stringifiedParams}`
245
+ : `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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 `/v1/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;
399
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./generated.js";
2
+ export { Configuration, type ConfigurationParameters, } from "./configuration.js";
3
+ export { ApiError } from "./errors/api-error.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./generated.js";
2
+ export { Configuration, } from "./configuration.js";
3
+ export { ApiError } from "./errors/api-error.js";
@@ -0,0 +1,2 @@
1
+ import type { Configuration } from "./configuration.js";
2
+ export declare function createApiFetcher(configuration: Configuration): typeof globalThis.fetch;
@@ -0,0 +1,71 @@
1
+ import { ApiError } from "./errors/api-error.js";
2
+ const requestCompressionThreshold = 64 * 1024;
3
+ export function createApiFetcher(configuration) {
4
+ const baseUrl = new URL(configuration.basePath);
5
+ return async (input, options) => {
6
+ const request = input instanceof Request ? input : undefined;
7
+ const headers = normalizeHeaders(options?.headers ?? request?.headers ?? {});
8
+ const method = (options?.method ?? request?.method ?? "GET").toUpperCase();
9
+ if (!["GET", "HEAD", "OPTIONS"].includes(method)) {
10
+ if (configuration.contract) {
11
+ headers.set("X-Seatmap-Contract", configuration.contract);
12
+ }
13
+ if (configuration.csrfToken) {
14
+ headers.set("X-CSRF-Token", configuration.csrfToken);
15
+ }
16
+ }
17
+ let body = options?.body;
18
+ if (configuration.compressRequests &&
19
+ typeof body === "string" &&
20
+ body.length >= requestCompressionThreshold &&
21
+ !headers.has("Content-Encoding") &&
22
+ typeof CompressionStream !== "undefined") {
23
+ body = await new Response(new Blob([body]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer();
24
+ headers.set("Content-Encoding", "gzip");
25
+ }
26
+ try {
27
+ const response = await configuration.fetchApi(typeof input === "string" ? new URL(input, baseUrl) : input, {
28
+ ...options,
29
+ ...(body !== undefined ? { body } : {}),
30
+ headers,
31
+ ...(configuration.credentials
32
+ ? { credentials: configuration.credentials }
33
+ : {}),
34
+ });
35
+ if (response.status === 401) {
36
+ configuration.csrfToken = undefined;
37
+ }
38
+ if (!response.ok && response.status !== 304) {
39
+ throw new ApiError(response);
40
+ }
41
+ return response;
42
+ }
43
+ catch (cause) {
44
+ if (cause instanceof Error && cause.name === "AbortError") {
45
+ throw cause;
46
+ }
47
+ if (configuration.mapError) {
48
+ throw await configuration.mapError(cause);
49
+ }
50
+ throw cause;
51
+ }
52
+ };
53
+ }
54
+ function normalizeHeaders(source) {
55
+ let entries;
56
+ if (source instanceof Headers) {
57
+ entries = source.entries();
58
+ }
59
+ else if (Array.isArray(source)) {
60
+ entries = source;
61
+ }
62
+ else {
63
+ entries = Object.entries(source);
64
+ }
65
+ const headers = new Headers();
66
+ // Caller headers replace differently cased generated defaults instead of being combined.
67
+ for (const [name, value] of entries) {
68
+ headers.set(name, value);
69
+ }
70
+ return headers;
71
+ }
package/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "@seatmap-fyi/api-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.2",
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
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.