seam 1.232.0 → 1.232.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.
Files changed (2) hide show
  1. package/README.md +204 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -53,12 +53,18 @@ Instead, it builds on a core set of Seam modules:
53
53
  - [Advanced Usage](#advanced-usage)
54
54
  - [Additional Options](#additional-options)
55
55
  - [Setting the endpoint](#setting-the-endpoint)
56
+ - [Setting the request timeout](#setting-the-request-timeout)
56
57
  - [Configuring the Axios Client](#configuring-the-axios-client)
57
58
  - [Using the Axios Client](#using-the-axios-client)
58
59
  - [Overriding the Client](#overriding-the-client)
59
60
  - [Alternative endpoint path interface](#alternative-endpoint-path-interface)
60
61
  - [Inspecting the Request](#inspecting-the-request)
61
62
  - [Command Line Interface](#command-line-interface)
63
+ - [Output](#output)
64
+ - [Pagination](#pagination-1)
65
+ - [JSON](#json)
66
+ - [Selecting an endpoint and a workspace](#selecting-an-endpoint-and-a-workspace)
67
+ - [Environment variables](#environment-variables)
62
68
  - [Receiving Webhooks](#receiving-webhooks)
63
69
  - [Development and Testing](#development-and-testing)
64
70
  - [Quickstart](#quickstart)
@@ -468,6 +474,7 @@ the constructor takes some advanced options that affect behavior.
468
474
  const seam = new Seam({
469
475
  apiKey: 'your-api-key',
470
476
  endpoint: 'https://example.com',
477
+ timeout: 30000,
471
478
  axiosOptions: {},
472
479
  axiosRetryOptions: {},
473
480
  })
@@ -479,6 +486,7 @@ these options may be passed in as the last argument.
479
486
  ```ts
480
487
  const seam = Seam.fromApiKey('some-api-key', {
481
488
  endpoint: 'https://example.com',
489
+ timeout: 30000,
482
490
  axiosOptions: {},
483
491
  axiosRetryOptions: {},
484
492
  })
@@ -492,6 +500,22 @@ This option corresponds to the Axios `baseURL` setting.
492
500
 
493
501
  Either pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variable.
494
502
 
503
+ #### Setting the request timeout
504
+
505
+ Requests time out after 30 seconds by default.
506
+ Pass the `timeout` option, in milliseconds, to override this:
507
+
508
+ ```ts
509
+ const seam = new Seam({
510
+ apiKey: 'your-api-key',
511
+ timeout: 60000,
512
+ })
513
+ ```
514
+
515
+ Set `timeout` to `0` to disable the timeout entirely.
516
+ A request that times out rejects with an Axios `ETIMEDOUT` error,
517
+ and is retried according to the retry options.
518
+
495
519
  #### Configuring the Axios Client
496
520
 
497
521
  The Axios client and retry behavior may be configured with custom initiation options
@@ -552,9 +576,19 @@ const devices = await request.execute()
552
576
 
553
577
  ### Command Line Interface
554
578
 
555
- Every `seam` command is interactive and will prompt you for any missing
556
- required properties with helpful suggestions. To avoid automatic behavior,
557
- pass `-y`.
579
+ Every `seam` command makes its request as soon as every required property is
580
+ given. When something is missing, the CLI prompts you for it with helpful
581
+ suggestions.
582
+
583
+ Pass `--interactive` (or `-i`) to always be prompted to review and edit
584
+ properties before the request is made. The prompt is prefilled with whatever
585
+ you passed as arguments, so this is the way to add optional properties, or to
586
+ check a request before making it.
587
+
588
+ For scripts and CI, pass `--non-interactive` (or `-y`) to never be prompted.
589
+ The command must then be complete: if the command itself is ambiguous, or any
590
+ required property is missing, the CLI exits with an error naming what is
591
+ missing instead of asking for it.
558
592
 
559
593
  To take a project from zero to a working Seam integration, run the
560
594
  [Seam Wizard] from the project's root:
@@ -581,7 +615,19 @@ seam connect-webviews create
581
615
  # List devices in your workspace
582
616
  seam devices list
583
617
 
584
- MY_DOOR=$(seam devices get --name "Front Door" --id-only)
618
+ # Review and edit filters before listing devices
619
+ seam devices list --interactive
620
+
621
+ # List devices, failing instead of prompting
622
+ seam devices list --non-interactive
623
+
624
+ # Fails with: Missing required parameter for /locks/unlock_door: --device-id
625
+ seam locks unlock-door --non-interactive
626
+
627
+ # Fails with: Unknown parameter for /devices/list: --limitt
628
+ seam devices list --limitt 5
629
+
630
+ MY_DOOR=$(seam devices get --name "Front Door" | jq -r '.device.device_id')
585
631
 
586
632
  # Unlock a lock
587
633
  seam locks unlock-door --device-id $MY_DOOR
@@ -593,6 +639,160 @@ seam access-codes create --code "1234" --name "My Code"
593
639
  seam access-codes list --device-id $MY_DOOR
594
640
  ```
595
641
 
642
+ ### Output
643
+
644
+ Only the response is written to stdout, so any command may be piped or
645
+ redirected. Prompts, progress, and other information are written to stderr.
646
+
647
+ The response is trimmed to the response key and pagination: no other top level
648
+ fields are reported.
649
+
650
+ ```bash
651
+ # The response, and nothing else, ends up in the file
652
+ seam devices list > devices.json
653
+
654
+ # Prompts and progress still show up in the terminal
655
+ seam devices list | jq '.devices[].device_id'
656
+ ```
657
+
658
+ ### Pagination
659
+
660
+ Every command that paginates accepts `--page-cursor` to select a page of
661
+ results, alongside `--limit` for the size of that page. Each response reports
662
+ its `pagination`, whose `next_page_cursor` is the cursor for the page after it.
663
+
664
+ ```bash
665
+ # The first page, and the cursor for the next one
666
+ seam devices list --limit 2 | jq '.pagination.next_page_cursor'
667
+
668
+ # The page after it
669
+ seam devices list --limit 2 --page-cursor "$CURSOR"
670
+ ```
671
+
672
+ A cursor is opaque: pass it back exactly as it was reported, and do not build
673
+ one yourself. Run `seam <command> --help` to see whether a command paginates.
674
+
675
+ ### JSON
676
+
677
+ Request params may be piped or redirected in as a JSON object. Params given as
678
+ arguments win over params read from stdin.
679
+
680
+ An argument the command does not accept is an error, so a typo is reported
681
+ rather than sent. Params read from stdin are passed through as given, so
682
+ anything the API itself accepts may be sent that way.
683
+
684
+ ```bash
685
+ # Read params from a file
686
+ seam locks unlock-door < params.json
687
+
688
+ # Or from another program
689
+ echo '{"device_id": "'"$MY_DOOR"'"}' | seam locks unlock-door
690
+
691
+ # --device-id wins over any device_id in params.json
692
+ seam devices list --limit 5 < params.json
693
+ ```
694
+
695
+ Pass `--json` to write the response as JSON. It is enabled automatically
696
+ whenever stdout is not a terminal, so piping and redirecting produce JSON
697
+ without passing anything. Pass `--no-json` to opt out and get the pretty
698
+ format instead.
699
+
700
+ ```bash
701
+ # Both write JSON
702
+ seam devices list --json
703
+ seam devices list | jq
704
+
705
+ # Pretty printed, even though it is piped
706
+ seam devices list --no-json | less
707
+ ```
708
+
709
+ Without a terminal to prompt on, the CLI behaves as though
710
+ `--non-interactive` was given: rather than waiting for an answer nobody can
711
+ give, it exits with an error naming what is missing.
712
+
713
+ ```bash
714
+ $ echo '{}' | seam locks unlock-door
715
+ Missing required parameter for /locks/unlock_door: --device-id
716
+ ```
717
+
718
+ An error exits non-zero. A request that fails reports its `error` on stdout,
719
+ so it can be inspected from a pipe; anything else is written to stderr only.
720
+
721
+ ### Selecting an endpoint and a workspace
722
+
723
+ Two settings say where commands go, and one command each stores them:
724
+
725
+ ```bash
726
+ # Every later command runs against this endpoint
727
+ seam select endpoint https://connect.getseam.com
728
+
729
+ # ...and this workspace
730
+ seam select workspace $MY_WORKSPACE
731
+ ```
732
+
733
+ Run either without a value to pick one interactively.
734
+
735
+ To send a single command somewhere else, pass `--endpoint` or
736
+ `--workspace-id` to that command. They override what is selected for that one
737
+ invocation and store nothing:
738
+
739
+ ```bash
740
+ # List devices in another workspace, without switching to it
741
+ seam devices list --workspace-id $OTHER_WORKSPACE
742
+
743
+ # Run one command against a local Seam Connect instance
744
+ seam devices list --endpoint http://localhost:3020
745
+
746
+ # Log in to another endpoint: the token is stored for that endpoint,
747
+ # and the selected one is left alone
748
+ seam login --endpoint http://localhost:3020 --token $LOCAL_KEY
749
+ ```
750
+
751
+ Because the two flags never store anything, they are refused on the commands
752
+ that do: `seam select endpoint --endpoint <url>` is an error, and the value
753
+ belongs after the command instead.
754
+
755
+ ### Environment variables
756
+
757
+ Everything `seam login`, `seam select workspace`, and `seam select endpoint`
758
+ store may be given in the environment instead:
759
+
760
+ - `SEAM_CLI_TOKEN`: a Personal Access Token or API Key,
761
+ - `SEAM_CLI_WORKSPACE_ID`: the workspace requests are made against,
762
+ - `SEAM_CLI_ENDPOINT`: the Seam API endpoint requests are made to.
763
+
764
+ Any of them, all of them, or none of them may be set. Each one wins over the
765
+ corresponding stored value and is in turn overridden by `--endpoint` or
766
+ `--workspace-id`, which makes them useful for CI or for working against
767
+ another workspace for a whole shell.
768
+
769
+ ```bash
770
+ # One command against another workspace
771
+ SEAM_CLI_WORKSPACE_ID=$OTHER_WORKSPACE seam devices list
772
+
773
+ # No login needed: authenticate from the environment
774
+ export SEAM_CLI_TOKEN=$SEAM_API_KEY
775
+ seam devices list
776
+
777
+ # Work against a local Seam Connect instance
778
+ SEAM_CLI_ENDPOINT=http://localhost:3020 seam devices list
779
+ ```
780
+
781
+ An API Key is scoped to a single workspace, so it needs no workspace id. A
782
+ Personal Access Token works across workspaces, so it needs one from
783
+ `--workspace-id`, `SEAM_CLI_WORKSPACE_ID`, or `seam select workspace`.
784
+
785
+ The command that would store an overridden value fails rather than storing
786
+ something the environment ignores: `seam login` and `seam logout` while
787
+ `SEAM_CLI_TOKEN` is set, `seam select workspace` while
788
+ `SEAM_CLI_WORKSPACE_ID` is set, and `seam select endpoint` while
789
+ `SEAM_CLI_ENDPOINT` is set. Unset the variable to use those commands.
790
+
791
+ ```bash
792
+ $ SEAM_CLI_TOKEN=$SEAM_API_KEY seam login
793
+ Cannot log in while SEAM_CLI_TOKEN is set: it overrides what would be stored. Unset SEAM_CLI_TOKEN to log in.
794
+ ```
795
+
596
796
  ### Receiving Webhooks
597
797
 
598
798
  The Seam API implements webhooks using [Svix](https://www.svix.com).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seam",
3
- "version": "1.232.0",
3
+ "version": "1.232.1",
4
4
  "description": "JavaScript SDK for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",