@seamapi/http 0.23.0 → 0.24.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/connect.cjs CHANGED
@@ -2265,6 +2265,92 @@ var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
2265
2265
  }
2266
2266
  };
2267
2267
 
2268
+ // src/lib/seam/connect/routes/devices-simulate.ts
2269
+ var SeamHttpDevicesSimulate = class _SeamHttpDevicesSimulate {
2270
+ constructor(apiKeyOrOptions = {}) {
2271
+ const options = parseOptions(apiKeyOrOptions);
2272
+ this.client = "client" in options ? options.client : createClient(options);
2273
+ this.defaults = limitToSeamHttpRequestOptions(options);
2274
+ }
2275
+ static fromClient(client, options = {}) {
2276
+ const constructorOptions = { ...options, client };
2277
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
2278
+ throw new SeamHttpInvalidOptionsError("Missing client");
2279
+ }
2280
+ return new _SeamHttpDevicesSimulate(constructorOptions);
2281
+ }
2282
+ static fromApiKey(apiKey, options = {}) {
2283
+ const constructorOptions = { ...options, apiKey };
2284
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
2285
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
2286
+ }
2287
+ return new _SeamHttpDevicesSimulate(constructorOptions);
2288
+ }
2289
+ static fromClientSessionToken(clientSessionToken, options = {}) {
2290
+ const constructorOptions = { ...options, clientSessionToken };
2291
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
2292
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
2293
+ }
2294
+ return new _SeamHttpDevicesSimulate(constructorOptions);
2295
+ }
2296
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
2297
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
2298
+ const clientOptions = parseOptions({ ...options, publishableKey });
2299
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
2300
+ throw new SeamHttpInvalidOptionsError(
2301
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
2302
+ );
2303
+ }
2304
+ const client = createClient(clientOptions);
2305
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
2306
+ const { token } = await clientSessions.getOrCreate({
2307
+ user_identifier_key: userIdentifierKey
2308
+ });
2309
+ return _SeamHttpDevicesSimulate.fromClientSessionToken(token, options);
2310
+ }
2311
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
2312
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
2313
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
2314
+ throw new SeamHttpInvalidOptionsError(
2315
+ "Missing consoleSessionToken or workspaceId"
2316
+ );
2317
+ }
2318
+ return new _SeamHttpDevicesSimulate(constructorOptions);
2319
+ }
2320
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
2321
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
2322
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
2323
+ throw new SeamHttpInvalidOptionsError(
2324
+ "Missing personalAccessToken or workspaceId"
2325
+ );
2326
+ }
2327
+ return new _SeamHttpDevicesSimulate(constructorOptions);
2328
+ }
2329
+ async updateClientSessionToken(clientSessionToken) {
2330
+ const { headers } = this.client.defaults;
2331
+ const authHeaders = getAuthHeadersForClientSessionToken({
2332
+ clientSessionToken
2333
+ });
2334
+ for (const key of Object.keys(authHeaders)) {
2335
+ if (headers[key] == null) {
2336
+ throw new Error(
2337
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
2338
+ );
2339
+ }
2340
+ }
2341
+ this.client.defaults.headers = { ...headers, ...authHeaders };
2342
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
2343
+ await clientSessions.get();
2344
+ }
2345
+ async remove(body) {
2346
+ await this.client.request({
2347
+ url: "/devices/simulate/remove",
2348
+ method: "post",
2349
+ data: body
2350
+ });
2351
+ }
2352
+ };
2353
+
2268
2354
  // src/lib/seam/connect/routes/devices-unmanaged.ts
2269
2355
  var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
2270
2356
  constructor(apiKeyOrOptions = {}) {
@@ -2447,6 +2533,9 @@ var SeamHttpDevices = class _SeamHttpDevices {
2447
2533
  get unmanaged() {
2448
2534
  return SeamHttpDevicesUnmanaged.fromClient(this.client, this.defaults);
2449
2535
  }
2536
+ get simulate() {
2537
+ return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults);
2538
+ }
2450
2539
  async delete(body) {
2451
2540
  await this.client.request({
2452
2541
  url: "/devices/delete",
@@ -4244,6 +4333,7 @@ exports.SeamHttpClientSessions = SeamHttpClientSessions;
4244
4333
  exports.SeamHttpConnectWebviews = SeamHttpConnectWebviews;
4245
4334
  exports.SeamHttpConnectedAccounts = SeamHttpConnectedAccounts;
4246
4335
  exports.SeamHttpDevices = SeamHttpDevices;
4336
+ exports.SeamHttpDevicesSimulate = SeamHttpDevicesSimulate;
4247
4337
  exports.SeamHttpDevicesUnmanaged = SeamHttpDevicesUnmanaged;
4248
4338
  exports.SeamHttpEvents = SeamHttpEvents;
4249
4339
  exports.SeamHttpInvalidInputError = SeamHttpInvalidInputError;