@ticketlayer/backstage 1.1.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BackstageClient = exports.SDK_CLIENT_HEADER = exports.API_DATED_VERSION = exports.BackstageAPIError = void 0;
4
4
  const version_1 = require("./version");
5
5
  class BackstageAPIError extends Error {
6
- constructor(message, code, statusCode) {
6
+ constructor(message, code, statusCode, details = {}) {
7
7
  super(message);
8
8
  this.name = 'BackstageAPIError';
9
9
  this.code = code;
10
10
  this.statusCode = statusCode;
11
+ this.moreInfo = details.moreInfo;
12
+ this.requestId = details.requestId;
11
13
  }
12
14
  isPermissionDenied() {
13
15
  return this.code === 'PERMISSION_DENIED';
@@ -546,6 +548,14 @@ class BackstageClient {
546
548
  params.append('venueId', String(options.venueId));
547
549
  if (options?.accountId !== undefined)
548
550
  params.append('accountId', String(options.accountId));
551
+ if (options?.updatedSince !== undefined)
552
+ params.append('updatedSince', String(options.updatedSince));
553
+ if (options?.cursor !== undefined)
554
+ params.append('cursor', String(options.cursor));
555
+ if (options?.include !== undefined)
556
+ params.append('include', String(options.include));
557
+ if (options?.visibility !== undefined)
558
+ params.append('visibility', String(options.visibility));
549
559
  if (options?.expand !== undefined)
550
560
  params.append('expand', String(options.expand));
551
561
  if (options?.page !== undefined)
@@ -561,6 +571,8 @@ class BackstageClient {
561
571
  },
562
572
  get: async (id, options) => {
563
573
  const params = new URLSearchParams();
574
+ if (options?.include !== undefined)
575
+ params.append('include', String(options.include));
564
576
  if (options?.expand !== undefined)
565
577
  params.append('expand', String(options.expand));
566
578
  const queryString = params.toString();
@@ -568,7 +580,7 @@ class BackstageClient {
568
580
  const response = await this.request(requestPath, {
569
581
  method: 'GET'
570
582
  });
571
- return response.event;
583
+ return response;
572
584
  },
573
585
  update: async (id, request) => {
574
586
  const response = await this.request(`/events/${id}`, {
@@ -1181,6 +1193,13 @@ class BackstageClient {
1181
1193
  });
1182
1194
  return response;
1183
1195
  },
1196
+ match: async (request) => {
1197
+ const response = await this.request(`/customers/match`, {
1198
+ method: 'POST',
1199
+ body: JSON.stringify(request)
1200
+ });
1201
+ return response.match;
1202
+ },
1184
1203
  get: async (customerId) => {
1185
1204
  const response = await this.request(`/customers/${customerId}`, {
1186
1205
  method: 'GET'
@@ -1420,7 +1439,7 @@ class BackstageClient {
1420
1439
  method: 'POST',
1421
1440
  body: JSON.stringify(request)
1422
1441
  });
1423
- return response;
1442
+ return response.commandId;
1424
1443
  }
1425
1444
  };
1426
1445
  this.payments = {
@@ -1507,13 +1526,13 @@ class BackstageClient {
1507
1526
  const response = await this.request(requestPath, {
1508
1527
  method: 'GET'
1509
1528
  });
1510
- return response;
1529
+ return response.status;
1511
1530
  },
1512
1531
  createTicketlayerPayOnboardingSession: async () => {
1513
1532
  const response = await this.request(`/payment-providers/ticketlayer-pay/onboarding-session`, {
1514
1533
  method: 'POST'
1515
1534
  });
1516
- return response;
1535
+ return response.session;
1517
1536
  },
1518
1537
  createTicketlayerPayOnboardingLink: async (request) => {
1519
1538
  const response = await this.request(`/payment-providers/ticketlayer-pay/onboarding-link`, {
@@ -1533,13 +1552,13 @@ class BackstageClient {
1533
1552
  const response = await this.request(`/payment-providers/stripe-connect`, {
1534
1553
  method: 'GET'
1535
1554
  });
1536
- return response;
1555
+ return response.provider;
1537
1556
  },
1538
1557
  listAccounts: async (providerId) => {
1539
1558
  const response = await this.request(`/payment-providers/${providerId}/accounts`, {
1540
1559
  method: 'GET'
1541
1560
  });
1542
- return response;
1561
+ return response.accounts;
1543
1562
  },
1544
1563
  getAccount: async (providerId, accountId, options) => {
1545
1564
  const params = new URLSearchParams();
@@ -1550,20 +1569,20 @@ class BackstageClient {
1550
1569
  const response = await this.request(requestPath, {
1551
1570
  method: 'GET'
1552
1571
  });
1553
- return response;
1572
+ return response.account;
1554
1573
  },
1555
1574
  setAccountMode: async (providerId, accountId, request) => {
1556
1575
  const response = await this.request(`/payment-providers/${providerId}/accounts/${accountId}`, {
1557
1576
  method: 'PUT',
1558
1577
  body: JSON.stringify(request)
1559
1578
  });
1560
- return response;
1579
+ return response.account;
1561
1580
  },
1562
1581
  createAccountOnboardingSession: async (providerId, accountId) => {
1563
1582
  const response = await this.request(`/payment-providers/${providerId}/accounts/${accountId}/onboarding-session`, {
1564
1583
  method: 'POST'
1565
1584
  });
1566
- return response;
1585
+ return response.session;
1567
1586
  },
1568
1587
  createAccountOnboardingLink: async (providerId, accountId, request) => {
1569
1588
  const response = await this.request(`/payment-providers/${providerId}/accounts/${accountId}/onboarding-link`, {
@@ -1674,6 +1693,13 @@ class BackstageClient {
1674
1693
  });
1675
1694
  return response.listings;
1676
1695
  },
1696
+ update: async (listingId, request) => {
1697
+ const response = await this.request(`/sales-channels/${channelId}/listings/${listingId}`, {
1698
+ method: 'PATCH',
1699
+ body: JSON.stringify(request)
1700
+ });
1701
+ return response.listing;
1702
+ },
1677
1703
  delete: async (listingId) => {
1678
1704
  const response = await this.request(`/sales-channels/${channelId}/listings/${listingId}`, {
1679
1705
  method: 'DELETE'
@@ -1681,39 +1707,25 @@ class BackstageClient {
1681
1707
  return response.deleted;
1682
1708
  }
1683
1709
  },
1684
- carts: {
1685
- create: async (request) => {
1686
- const response = await this.request(`/sales-channels/${channelId}/carts`, {
1687
- method: 'POST',
1688
- body: JSON.stringify(request)
1689
- });
1690
- return response;
1691
- },
1692
- get: async (cartId) => {
1693
- const response = await this.request(`/sales-channels/${channelId}/carts/${cartId}`, {
1710
+ channelaccess: {
1711
+ list: async () => {
1712
+ const response = await this.request(`/sales-channels/${channelId}/access`, {
1694
1713
  method: 'GET'
1695
1714
  });
1696
- return response;
1715
+ return response.access;
1697
1716
  },
1698
- addItem: async (cartId, request) => {
1699
- const response = await this.request(`/sales-channels/${channelId}/carts/${cartId}/items`, {
1717
+ grant: async (request) => {
1718
+ const response = await this.request(`/sales-channels/${channelId}/access`, {
1700
1719
  method: 'POST',
1701
1720
  body: JSON.stringify(request)
1702
1721
  });
1703
- return response;
1722
+ return response.access;
1704
1723
  },
1705
- removeItem: async (cartId, itemId) => {
1706
- const response = await this.request(`/sales-channels/${channelId}/carts/${cartId}/items/${itemId}`, {
1724
+ revoke: async (accessId) => {
1725
+ const response = await this.request(`/sales-channels/${channelId}/access/${accessId}`, {
1707
1726
  method: 'DELETE'
1708
1727
  });
1709
- return response;
1710
- },
1711
- checkout: async (cartId, request) => {
1712
- const response = await this.request(`/sales-channels/${channelId}/carts/${cartId}/checkout`, {
1713
- method: 'POST',
1714
- body: JSON.stringify(request)
1715
- });
1716
- return response;
1728
+ return response.deleted;
1717
1729
  }
1718
1730
  }
1719
1731
  }), {
@@ -1749,19 +1761,48 @@ class BackstageClient {
1749
1761
  });
1750
1762
  return response.deleted;
1751
1763
  },
1752
- getCatalogue: async (channelId) => {
1753
- const response = await this.request(`/sales-channels/${channelId}/catalogue`, {
1764
+ mySalesChannels: async () => {
1765
+ const response = await this.request(`/my/sales-channels`, {
1754
1766
  method: 'GET'
1755
1767
  });
1756
1768
  return response;
1769
+ }
1770
+ });
1771
+ this.carts = {
1772
+ create: async (request) => {
1773
+ const response = await this.request(`/cart`, {
1774
+ method: 'POST',
1775
+ body: JSON.stringify(request)
1776
+ });
1777
+ return response;
1757
1778
  },
1758
- getCatalogueEvent: async (channelId, eventId) => {
1759
- const response = await this.request(`/sales-channels/${channelId}/catalogue/events/${eventId}`, {
1779
+ get: async (cartId) => {
1780
+ const response = await this.request(`/cart/${cartId}`, {
1760
1781
  method: 'GET'
1761
1782
  });
1762
- return response.event;
1783
+ return response;
1784
+ },
1785
+ addItem: async (cartId, request) => {
1786
+ const response = await this.request(`/cart/${cartId}/items`, {
1787
+ method: 'POST',
1788
+ body: JSON.stringify(request)
1789
+ });
1790
+ return response;
1791
+ },
1792
+ removeItem: async (cartId, itemId) => {
1793
+ const response = await this.request(`/cart/${cartId}/items/${itemId}`, {
1794
+ method: 'DELETE'
1795
+ });
1796
+ return response;
1797
+ },
1798
+ checkout: async (cartId, request) => {
1799
+ const response = await this.request(`/cart/${cartId}/checkout`, {
1800
+ method: 'POST',
1801
+ body: JSON.stringify(request)
1802
+ });
1803
+ return response;
1763
1804
  }
1764
- });
1805
+ };
1765
1806
  this.presaleCodes = {
1766
1807
  create: async (request) => {
1767
1808
  const response = await this.request(`/presale-codes`, {
@@ -1915,39 +1956,39 @@ class BackstageClient {
1915
1956
  method: 'POST',
1916
1957
  body: JSON.stringify(request)
1917
1958
  });
1918
- return response;
1959
+ return response.scanConfig;
1919
1960
  },
1920
1961
  list: async () => {
1921
1962
  const response = await this.request(`/scan-configs`, {
1922
1963
  method: 'GET'
1923
1964
  });
1924
- return response;
1965
+ return response.scanConfigs;
1925
1966
  },
1926
1967
  get: async (configId) => {
1927
1968
  const response = await this.request(`/scan-configs/${configId}`, {
1928
1969
  method: 'GET'
1929
1970
  });
1930
- return response;
1971
+ return response.scanConfig;
1931
1972
  },
1932
1973
  update: async (configId, request) => {
1933
1974
  const response = await this.request(`/scan-configs/${configId}`, {
1934
1975
  method: 'PATCH',
1935
1976
  body: JSON.stringify(request)
1936
1977
  });
1937
- return response;
1978
+ return response.scanConfig;
1938
1979
  },
1939
1980
  delete: async (configId) => {
1940
1981
  const response = await this.request(`/scan-configs/${configId}`, {
1941
1982
  method: 'DELETE'
1942
1983
  });
1943
- return response;
1984
+ return response.deleted;
1944
1985
  },
1945
1986
  setDevices: async (configId, request) => {
1946
1987
  const response = await this.request(`/scan-configs/${configId}/devices`, {
1947
1988
  method: 'PUT',
1948
1989
  body: JSON.stringify(request)
1949
1990
  });
1950
- return response;
1991
+ return response.deviceIds;
1951
1992
  }
1952
1993
  };
1953
1994
  this.scan = {
@@ -1955,7 +1996,7 @@ class BackstageClient {
1955
1996
  const response = await this.request(`/scan/config`, {
1956
1997
  method: 'GET'
1957
1998
  });
1958
- return response;
1999
+ return response.scanConfig;
1959
2000
  },
1960
2001
  manifest: async (options) => {
1961
2002
  const params = new URLSearchParams();
@@ -1973,7 +2014,7 @@ class BackstageClient {
1973
2014
  method: 'POST',
1974
2015
  body: JSON.stringify(request)
1975
2016
  });
1976
- return response;
2017
+ return response.results;
1977
2018
  }
1978
2019
  };
1979
2020
  this.scans = {
@@ -1998,14 +2039,14 @@ class BackstageClient {
1998
2039
  const response = await this.request(requestPath, {
1999
2040
  method: 'GET'
2000
2041
  });
2001
- return response;
2042
+ return response.scans;
2002
2043
  },
2003
2044
  reverse: async (redemptionId, request) => {
2004
2045
  const response = await this.request(`/redemptions/${redemptionId}/reverse`, {
2005
2046
  method: 'POST',
2006
2047
  body: JSON.stringify(request)
2007
2048
  });
2008
- return response;
2049
+ return response.redemption;
2009
2050
  }
2010
2051
  };
2011
2052
  this.assets = {
@@ -2081,7 +2122,7 @@ class BackstageClient {
2081
2122
  method: 'POST',
2082
2123
  body: JSON.stringify(request)
2083
2124
  });
2084
- return response;
2125
+ return response.status;
2085
2126
  }
2086
2127
  };
2087
2128
  this.deviceAuth = {
@@ -2118,7 +2159,7 @@ class BackstageClient {
2118
2159
  method: 'PUT',
2119
2160
  body: JSON.stringify(request)
2120
2161
  });
2121
- return response;
2162
+ return response.peripherals;
2122
2163
  },
2123
2164
  fetchCommands: async (options) => {
2124
2165
  const params = new URLSearchParams();
@@ -2129,28 +2170,28 @@ class BackstageClient {
2129
2170
  const response = await this.request(requestPath, {
2130
2171
  method: 'GET'
2131
2172
  });
2132
- return response;
2173
+ return response.commands;
2133
2174
  },
2134
2175
  reportProgress: async (commandId, request) => {
2135
2176
  const response = await this.request(`/devices/me/commands/${commandId}/progress`, {
2136
2177
  method: 'POST',
2137
2178
  body: JSON.stringify(request)
2138
2179
  });
2139
- return response;
2180
+ return response.ok;
2140
2181
  },
2141
2182
  reportResult: async (commandId, request) => {
2142
2183
  const response = await this.request(`/devices/me/commands/${commandId}/result`, {
2143
2184
  method: 'POST',
2144
2185
  body: JSON.stringify(request)
2145
2186
  });
2146
- return response;
2187
+ return response.status;
2147
2188
  },
2148
2189
  ingestEvents: async (request) => {
2149
2190
  const response = await this.request(`/devices/me/events`, {
2150
2191
  method: 'POST',
2151
2192
  body: JSON.stringify(request)
2152
2193
  });
2153
- return response;
2194
+ return response.results;
2154
2195
  },
2155
2196
  getCertificate: async () => {
2156
2197
  const response = await this.request(`/devices/me/certificate`, {
@@ -2164,7 +2205,7 @@ class BackstageClient {
2164
2205
  const response = await this.request(`/devices/printers`, {
2165
2206
  method: 'GET'
2166
2207
  });
2167
- return response;
2208
+ return response.printers;
2168
2209
  },
2169
2210
  mediaCatalog: async () => {
2170
2211
  const response = await this.request(`/devices/media-catalog`, {
@@ -2176,7 +2217,7 @@ class BackstageClient {
2176
2217
  const response = await this.request(`/devices/commands/${commandId}`, {
2177
2218
  method: 'GET'
2178
2219
  });
2179
- return response;
2220
+ return response.command;
2180
2221
  },
2181
2222
  list: async (options) => {
2182
2223
  const params = new URLSearchParams();
@@ -2195,39 +2236,39 @@ class BackstageClient {
2195
2236
  const response = await this.request(requestPath, {
2196
2237
  method: 'GET'
2197
2238
  });
2198
- return response;
2239
+ return response.devices;
2199
2240
  },
2200
2241
  get: async (deviceId) => {
2201
2242
  const response = await this.request(`/devices/${deviceId}`, {
2202
2243
  method: 'GET'
2203
2244
  });
2204
- return response;
2245
+ return response.device;
2205
2246
  },
2206
2247
  update: async (deviceId, request) => {
2207
2248
  const response = await this.request(`/devices/${deviceId}`, {
2208
2249
  method: 'PATCH',
2209
2250
  body: JSON.stringify(request)
2210
2251
  });
2211
- return response;
2252
+ return response.device;
2212
2253
  },
2213
2254
  delete: async (deviceId) => {
2214
2255
  const response = await this.request(`/devices/${deviceId}`, {
2215
2256
  method: 'DELETE'
2216
2257
  });
2217
- return response;
2258
+ return response.deleted;
2218
2259
  },
2219
2260
  revoke: async (deviceId) => {
2220
2261
  const response = await this.request(`/devices/${deviceId}/revoke`, {
2221
2262
  method: 'POST'
2222
2263
  });
2223
- return response;
2264
+ return response.device;
2224
2265
  },
2225
2266
  assignRoles: async (deviceId, request) => {
2226
2267
  const response = await this.request(`/devices/${deviceId}/roles`, {
2227
2268
  method: 'PUT',
2228
2269
  body: JSON.stringify(request)
2229
2270
  });
2230
- return response;
2271
+ return response.roles;
2231
2272
  },
2232
2273
  rotateCredential: async (deviceId, request) => {
2233
2274
  const response = await this.request(`/devices/${deviceId}/credentials/rotate`, {
@@ -2241,19 +2282,19 @@ class BackstageClient {
2241
2282
  method: 'POST',
2242
2283
  body: JSON.stringify(request)
2243
2284
  });
2244
- return response;
2285
+ return response.command;
2245
2286
  },
2246
2287
  listCommands: async (deviceId) => {
2247
2288
  const response = await this.request(`/devices/${deviceId}/commands`, {
2248
2289
  method: 'GET'
2249
2290
  });
2250
- return response;
2291
+ return response.commands;
2251
2292
  },
2252
2293
  listEvents: async (deviceId) => {
2253
2294
  const response = await this.request(`/devices/${deviceId}/events`, {
2254
2295
  method: 'GET'
2255
2296
  });
2256
- return response;
2297
+ return response.events;
2257
2298
  },
2258
2299
  mintLocalToken: async (deviceId, request) => {
2259
2300
  const response = await this.request(`/devices/${deviceId}/local-tokens`, {
@@ -2269,32 +2310,32 @@ class BackstageClient {
2269
2310
  method: 'POST',
2270
2311
  body: JSON.stringify(request)
2271
2312
  });
2272
- return response;
2313
+ return response.location;
2273
2314
  },
2274
2315
  list: async () => {
2275
2316
  const response = await this.request(`/locations`, {
2276
2317
  method: 'GET'
2277
2318
  });
2278
- return response;
2319
+ return response.locations;
2279
2320
  },
2280
2321
  get: async (locationId) => {
2281
2322
  const response = await this.request(`/locations/${locationId}`, {
2282
2323
  method: 'GET'
2283
2324
  });
2284
- return response;
2325
+ return response.location;
2285
2326
  },
2286
2327
  update: async (locationId, request) => {
2287
2328
  const response = await this.request(`/locations/${locationId}`, {
2288
2329
  method: 'PATCH',
2289
2330
  body: JSON.stringify(request)
2290
2331
  });
2291
- return response;
2332
+ return response.location;
2292
2333
  },
2293
2334
  delete: async (locationId) => {
2294
2335
  const response = await this.request(`/locations/${locationId}`, {
2295
2336
  method: 'DELETE'
2296
2337
  });
2297
- return response;
2338
+ return response.deleted;
2298
2339
  }
2299
2340
  };
2300
2341
  this.reports = {
@@ -2465,26 +2506,26 @@ class BackstageClient {
2465
2506
  const response = await this.request(requestPath, {
2466
2507
  method: 'GET'
2467
2508
  });
2468
- return response;
2509
+ return response.endpoints;
2469
2510
  },
2470
2511
  get: async (endpointId) => {
2471
2512
  const response = await this.request(`/webhook-endpoints/${endpointId}`, {
2472
2513
  method: 'GET'
2473
2514
  });
2474
- return response;
2515
+ return response.endpoint;
2475
2516
  },
2476
2517
  update: async (endpointId, request) => {
2477
2518
  const response = await this.request(`/webhook-endpoints/${endpointId}`, {
2478
2519
  method: 'PATCH',
2479
2520
  body: JSON.stringify(request)
2480
2521
  });
2481
- return response;
2522
+ return response.endpoint;
2482
2523
  },
2483
2524
  delete: async (endpointId) => {
2484
2525
  const response = await this.request(`/webhook-endpoints/${endpointId}`, {
2485
2526
  method: 'DELETE'
2486
2527
  });
2487
- return response;
2528
+ return response.deleted;
2488
2529
  },
2489
2530
  test: async (endpointId) => {
2490
2531
  const response = await this.request(`/webhook-endpoints/${endpointId}/test`, {
@@ -2505,19 +2546,19 @@ class BackstageClient {
2505
2546
  const response = await this.request(requestPath, {
2506
2547
  method: 'GET'
2507
2548
  });
2508
- return response;
2549
+ return response.deliveries;
2509
2550
  },
2510
2551
  get: async (deliveryId) => {
2511
2552
  const response = await this.request(`/webhook-deliveries/${deliveryId}`, {
2512
2553
  method: 'GET'
2513
2554
  });
2514
- return response;
2555
+ return response.delivery;
2515
2556
  },
2516
2557
  listInbound: async () => {
2517
2558
  const response = await this.request(`/webhook-inbound`, {
2518
2559
  method: 'GET'
2519
2560
  });
2520
- return response;
2561
+ return response.events;
2521
2562
  }
2522
2563
  };
2523
2564
  this.webhookEventTypes = {
@@ -2525,7 +2566,7 @@ class BackstageClient {
2525
2566
  const response = await this.request(`/webhook-event-types`, {
2526
2567
  method: 'GET'
2527
2568
  });
2528
- return response;
2569
+ return response.eventTypes;
2529
2570
  }
2530
2571
  };
2531
2572
  this.integrations = {
@@ -2539,19 +2580,19 @@ class BackstageClient {
2539
2580
  const response = await this.request(`/integrations/connected-apps`, {
2540
2581
  method: 'GET'
2541
2582
  });
2542
- return response;
2583
+ return response.connectedApps;
2543
2584
  },
2544
2585
  get: async (id) => {
2545
2586
  const response = await this.request(`/integrations/${id}`, {
2546
2587
  method: 'GET'
2547
2588
  });
2548
- return response;
2589
+ return response.integration;
2549
2590
  },
2550
2591
  revokeConnection: async (id) => {
2551
2592
  const response = await this.request(`/integrations/${id}/connection`, {
2552
2593
  method: 'DELETE'
2553
2594
  });
2554
- return response;
2595
+ return response.revoked;
2555
2596
  }
2556
2597
  };
2557
2598
  this.clientVersions = {
@@ -2610,178 +2651,6 @@ class BackstageClient {
2610
2651
  return response;
2611
2652
  }
2612
2653
  };
2613
- this.sales = {
2614
- resolveChannel: async (options) => {
2615
- const params = new URLSearchParams();
2616
- if (options?.domain !== undefined)
2617
- params.append('domain', String(options.domain));
2618
- if (options?.key !== undefined)
2619
- params.append('key', String(options.key));
2620
- const queryString = params.toString();
2621
- const requestPath = queryString ? `/sales/channel?${queryString}` : `/sales/channel`;
2622
- const response = await this.request(requestPath, {
2623
- method: 'GET'
2624
- });
2625
- return response;
2626
- },
2627
- get: async (eventId) => {
2628
- const response = await this.request(`/sales/events/${eventId}`, {
2629
- method: 'GET'
2630
- });
2631
- return response.event;
2632
- },
2633
- getTheme: async () => {
2634
- const response = await this.request(`/sales/theme`, {
2635
- method: 'GET'
2636
- });
2637
- return response.theme;
2638
- }
2639
- };
2640
- this.salesCustomerAuth = {
2641
- magicLink: async (request) => {
2642
- const response = await this.request(`/sales/customer-auth/magic-link`, {
2643
- method: 'POST',
2644
- body: JSON.stringify(request)
2645
- });
2646
- return response.sent;
2647
- }
2648
- };
2649
- this.salesCustomerTokens = {
2650
- create: async (request) => {
2651
- const response = await this.request(`/sales/customer-tokens`, {
2652
- method: 'POST',
2653
- body: JSON.stringify(request)
2654
- });
2655
- return response;
2656
- },
2657
- refresh: async () => {
2658
- const response = await this.request(`/sales/customer-tokens/refresh`, {
2659
- method: 'POST'
2660
- });
2661
- return response;
2662
- }
2663
- };
2664
- this.salesListings = {
2665
- list: async () => {
2666
- const response = await this.request(`/sales/listings`, {
2667
- method: 'GET'
2668
- });
2669
- return response;
2670
- }
2671
- };
2672
- this.salesCarts = {
2673
- create: async (request) => {
2674
- const response = await this.request(`/sales/carts`, {
2675
- method: 'POST',
2676
- body: JSON.stringify(request)
2677
- });
2678
- return response.cart;
2679
- },
2680
- get: async (cartId) => {
2681
- const response = await this.request(`/sales/carts/${cartId}`, {
2682
- method: 'GET'
2683
- });
2684
- return response.cart;
2685
- },
2686
- addItem: async (cartId, request) => {
2687
- const response = await this.request(`/sales/carts/${cartId}/items`, {
2688
- method: 'POST',
2689
- body: JSON.stringify(request)
2690
- });
2691
- return response.cart;
2692
- },
2693
- removeItem: async (cartId, itemId) => {
2694
- const response = await this.request(`/sales/carts/${cartId}/items/${itemId}`, {
2695
- method: 'DELETE'
2696
- });
2697
- return response.cart;
2698
- },
2699
- checkout: async (cartId, request) => {
2700
- const response = await this.request(`/sales/carts/${cartId}/checkout`, {
2701
- method: 'POST',
2702
- body: JSON.stringify(request)
2703
- });
2704
- return response;
2705
- }
2706
- };
2707
- this.salesMyOrders = {
2708
- list: async () => {
2709
- const response = await this.request(`/sales/my-orders`, {
2710
- method: 'GET'
2711
- });
2712
- return response.orders;
2713
- }
2714
- };
2715
- this.salesOrders = {
2716
- get: async (orderId) => {
2717
- const response = await this.request(`/sales/orders/${orderId}`, {
2718
- method: 'GET'
2719
- });
2720
- return response.order;
2721
- },
2722
- ticketPdf: async (orderId, passId) => {
2723
- const response = await this.request(`/sales/orders/${orderId}/passes/${passId}/ticket.pdf`, {
2724
- method: 'GET'
2725
- });
2726
- return response;
2727
- }
2728
- };
2729
- this.salesOrderPayments = {
2730
- create: async (orderId, request) => {
2731
- const response = await this.request(`/sales/orders/${orderId}/payments`, {
2732
- method: 'POST',
2733
- body: JSON.stringify(request)
2734
- });
2735
- return response.payment;
2736
- },
2737
- confirmSandbox: async (orderId, paymentId, request) => {
2738
- const response = await this.request(`/sales/orders/${orderId}/payments/${paymentId}/sandbox/confirm`, {
2739
- method: 'POST',
2740
- body: JSON.stringify(request)
2741
- });
2742
- return response.confirmation;
2743
- }
2744
- };
2745
- this.salesRefundRequests = {
2746
- create: async (orderId, request) => {
2747
- const response = await this.request(`/sales/orders/${orderId}/refund-requests`, {
2748
- method: 'POST',
2749
- body: JSON.stringify(request)
2750
- });
2751
- return response.request;
2752
- }
2753
- };
2754
- this.salesCustomers = {
2755
- create: async (request) => {
2756
- const response = await this.request(`/sales/customers`, {
2757
- method: 'POST',
2758
- body: JSON.stringify(request)
2759
- });
2760
- return response.customer;
2761
- },
2762
- get: async (customerId) => {
2763
- const response = await this.request(`/sales/customers/${customerId}`, {
2764
- method: 'GET'
2765
- });
2766
- return response.customer;
2767
- },
2768
- update: async (customerId, request) => {
2769
- const response = await this.request(`/sales/customers/${customerId}`, {
2770
- method: 'PATCH',
2771
- body: JSON.stringify(request)
2772
- });
2773
- return response.customer;
2774
- }
2775
- };
2776
- this.salesPresaleCodes = {
2777
- redeem: async (request) => {
2778
- const response = await this.request(`/sales/presale-codes/redeem`, {
2779
- method: 'POST',
2780
- body: JSON.stringify(request)
2781
- });
2782
- return response;
2783
- }
2784
- };
2785
2654
  this.baseUrl = config.baseUrl.replace(/\/$/, '');
2786
2655
  this.authMode = config.authMode || 'bearer';
2787
2656
  this.accessToken = config.accessToken;
@@ -2990,14 +2859,19 @@ class BackstageClient {
2990
2859
  error: { message: response.statusText, code: 'HTTP_ERROR' },
2991
2860
  }));
2992
2861
  const errorInfo = errorBody.error || errorBody;
2993
- const message = typeof errorInfo === 'object' && errorInfo !== null
2862
+ const isEnvelope = typeof errorInfo === 'object' && errorInfo !== null;
2863
+ const message = isEnvelope
2994
2864
  ? (errorInfo.message || 'Request failed')
2995
2865
  : String(errorInfo || 'Request failed');
2996
- const code = typeof errorInfo === 'object' && errorInfo !== null
2866
+ const code = isEnvelope
2997
2867
  ? (errorInfo.code || 'UNKNOWN_ERROR')
2998
2868
  : 'UNKNOWN_ERROR';
2999
- const error = new BackstageAPIError(message, code, response.status);
3000
- this.debugLog('error', options.method || 'GET', versionedPath, { status: response.status, code, message });
2869
+ const moreInfo = isEnvelope && typeof errorInfo.moreInfo === 'string' ? errorInfo.moreInfo : undefined;
2870
+ const requestId = (typeof errorBody.metadata?.requestId === 'string' ? errorBody.metadata.requestId : undefined) ??
2871
+ response.headers.get('x-request-id') ??
2872
+ undefined;
2873
+ const error = new BackstageAPIError(message, code, response.status, { moreInfo, requestId });
2874
+ this.debugLog('error', options.method || 'GET', versionedPath, { status: response.status, code, message, requestId });
3001
2875
  throw error;
3002
2876
  }
3003
2877
  const json = await response.json();