@seamapi/http 2.18.0 → 2.20.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.
Files changed (44) hide show
  1. package/index.d.ts +5 -0
  2. package/index.js +5 -0
  3. package/index.js.map +1 -1
  4. package/lib/client.d.ts +12 -0
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js.map +1 -1
  8. package/lib/options.d.ts +105 -0
  9. package/lib/options.js +54 -0
  10. package/lib/options.js.map +1 -1
  11. package/lib/request-options.d.ts +13 -0
  12. package/lib/request-options.js +3 -0
  13. package/lib/request-options.js.map +1 -1
  14. package/lib/resolve-action-attempt.d.ts +47 -0
  15. package/lib/resolve-action-attempt.js +29 -0
  16. package/lib/resolve-action-attempt.js.map +1 -1
  17. package/lib/resources/device.d.ts +0 -12
  18. package/lib/resources/workspace.d.ts +2 -1
  19. package/lib/routes/workspaces/workspaces.d.ts +1 -1
  20. package/lib/seam-http-error.d.ts +34 -0
  21. package/lib/seam-http-error.js +34 -0
  22. package/lib/seam-http-error.js.map +1 -1
  23. package/lib/seam-http-request.d.ts +31 -0
  24. package/lib/seam-http-request.js +31 -0
  25. package/lib/seam-http-request.js.map +1 -1
  26. package/lib/seam-paginator.d.ts +28 -0
  27. package/lib/seam-paginator.js +25 -0
  28. package/lib/seam-paginator.js.map +1 -1
  29. package/lib/version.d.ts +1 -1
  30. package/lib/version.js +1 -1
  31. package/package.json +3 -2
  32. package/src/index.ts +5 -0
  33. package/src/lib/client.ts +14 -0
  34. package/src/lib/index.ts +3 -0
  35. package/src/lib/options.ts +105 -0
  36. package/src/lib/request-options.ts +13 -0
  37. package/src/lib/resolve-action-attempt.ts +48 -0
  38. package/src/lib/resources/device.ts +0 -12
  39. package/src/lib/resources/workspace.ts +2 -1
  40. package/src/lib/routes/workspaces/workspaces.ts +1 -1
  41. package/src/lib/seam-http-error.ts +38 -0
  42. package/src/lib/seam-http-request.ts +31 -0
  43. package/src/lib/seam-paginator.ts +28 -0
  44. package/src/lib/version.ts +1 -1
@@ -1,7 +1,20 @@
1
+ /**
2
+ * Error thrown when the Seam API returns an error response.
3
+ */
1
4
  export class SeamHttpApiError extends Error {
5
+ /**
6
+ * Error type returned by the Seam API, e.g., `invalid_input`.
7
+ */
2
8
  code;
3
9
  statusCode;
10
+ /**
11
+ * Unique identifier of the request that failed.
12
+ * Provide this to Seam support when reporting an issue.
13
+ */
4
14
  requestId;
15
+ /**
16
+ * Additional error-specific data returned by the Seam API, if any.
17
+ */
5
18
  data;
6
19
  constructor(error, statusCode, requestId) {
7
20
  const { type, message, data } = error;
@@ -14,9 +27,15 @@ export class SeamHttpApiError extends Error {
14
27
  this.data = data;
15
28
  }
16
29
  }
30
+ /**
31
+ * Returns true if the error is a {@link SeamHttpApiError}.
32
+ */
17
33
  export const isSeamHttpApiError = (error) => {
18
34
  return error instanceof SeamHttpApiError;
19
35
  };
36
+ /**
37
+ * Error thrown when the Seam API returns a 401 Unauthorized error response.
38
+ */
20
39
  export class SeamHttpUnauthorizedError extends SeamHttpApiError {
21
40
  code;
22
41
  statusCode;
@@ -30,9 +49,15 @@ export class SeamHttpUnauthorizedError extends SeamHttpApiError {
30
49
  this.requestId = requestId;
31
50
  }
32
51
  }
52
+ /**
53
+ * Returns true if the error is a {@link SeamHttpUnauthorizedError}.
54
+ */
33
55
  export const isSeamHttpUnauthorizedError = (error) => {
34
56
  return error instanceof SeamHttpUnauthorizedError;
35
57
  };
58
+ /**
59
+ * Error thrown when the Seam API returns an `invalid_input` error response.
60
+ */
36
61
  export class SeamHttpInvalidInputError extends SeamHttpApiError {
37
62
  code;
38
63
  #validationErrors;
@@ -42,10 +67,19 @@ export class SeamHttpInvalidInputError extends SeamHttpApiError {
42
67
  this.code = 'invalid_input';
43
68
  this.#validationErrors = error.validation_errors ?? {};
44
69
  }
70
+ /**
71
+ * Returns the validation error messages for the request parameter,
72
+ * or an empty array if the parameter had no validation errors.
73
+ *
74
+ * @param paramName - Name of the request parameter.
75
+ */
45
76
  getValidationErrorMessages(paramName) {
46
77
  return this.#validationErrors[paramName]?._errors ?? [];
47
78
  }
48
79
  }
80
+ /**
81
+ * Returns true if the error is a {@link SeamHttpInvalidInputError}.
82
+ */
49
83
  export const isSeamHttpInvalidInputError = (error) => {
50
84
  return error instanceof SeamHttpInvalidInputError;
51
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"seam-http-error.js","sourceRoot":"","sources":["../src/lib/seam-http-error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,IAAI,CAAQ;IACZ,UAAU,CAAQ;IAClB,SAAS,CAAQ;IACjB,IAAI,CAAU;IAEd,YAAY,KAAe,EAAE,UAAkB,EAAE,SAAiB;QAChE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;QACrC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,IAAI,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAc,EACa,EAAE;IAC7B,OAAO,KAAK,YAAY,gBAAgB,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,OAAO,yBAA0B,SAAQ,gBAAgB;IACpD,IAAI,CAAgB;IACpB,UAAU,CAAK;IAExB,YAAY,SAAiB;QAC3B,MAAM,IAAI,GAAG,cAAc,CAAA;QAC3B,MAAM,MAAM,GAAG,GAAG,CAAA;QAClB,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE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gBAAgB;IACpD,IAAI,CAAiB;IAErB,iBAAiB,CAA4C;IAEtE,YAAY,KAAe,EAAE,UAAkB,EAAE,SAAiB;QAChE,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAA;IACxD,CAAC;IAED;;;;;OAKG;IACH,0BAA0B,CAAC,SAAiB;QAC1C,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO,IAAI,EAAE,CAAA;IACzD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,KAAc,EACsB,EAAE;IACtC,OAAO,KAAK,YAAY,yBAAyB,CAAA;AACnD,CAAC,CAAA"}
@@ -19,18 +19,49 @@ interface SeamHttpRequestConfig<TResponseKey> {
19
19
  readonly hasRequiredParameters?: boolean;
20
20
  readonly requiredParameterNames?: readonly string[];
21
21
  }
22
+ /**
23
+ * A lazy request to the Seam API.
24
+ *
25
+ * Creating a SeamHttpRequest does not send anything over the network.
26
+ * The request is sent once `execute` is called,
27
+ * or when the request is awaited like a Promise,
28
+ * e.g., with `await`, `then`, `catch`, or `finally`.
29
+ * When the response contains an action attempt,
30
+ * awaiting the request also waits for the action attempt to resolve
31
+ * according to the `waitForActionAttempt` option.
32
+ *
33
+ * Before sending, the request may be inspected
34
+ * with `url`, `pathname`, `method`, `params`, and `body`.
35
+ */
22
36
  export declare class SeamHttpRequest<const TResponse, const TResponseKey extends keyof TResponse | undefined> implements Promise<TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined> {
23
37
  #private;
24
38
  readonly [Symbol.toStringTag]: string;
25
39
  constructor(parent: SeamHttpRequestParent, config: SeamHttpRequestConfig<TResponseKey>);
40
+ /**
41
+ * The key of the API response object containing the response data,
42
+ * or undefined if the endpoint returns an empty response.
43
+ */
26
44
  get responseKey(): TResponseKey;
27
45
  get hasPagination(): boolean;
46
+ /**
47
+ * The full request URL including any serialized query parameters.
48
+ */
28
49
  get url(): URL;
29
50
  get pathname(): string;
30
51
  get method(): Method;
31
52
  get params(): undefined | Record<string, unknown>;
32
53
  get body(): unknown;
54
+ /**
55
+ * Sends the request and returns the response data.
56
+ * If the response contains an action attempt,
57
+ * waits for the action attempt to resolve
58
+ * according to the `waitForActionAttempt` option.
59
+ */
33
60
  execute(): Promise<TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined>;
61
+ /**
62
+ * Sends the request and returns the entire response body
63
+ * without waiting for any action attempt to resolve.
64
+ */
34
65
  fetchResponse(): Promise<TResponse>;
35
66
  then<TResult1 = TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined, TResult2 = never>(onfulfilled?: ((value: TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
36
67
  catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null | undefined): Promise<(TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined) | TResult>;
@@ -1,6 +1,20 @@
1
1
  import { assertValidRequestParameters } from './request-parameters.js';
2
2
  import { resolveActionAttempt, } from './resolve-action-attempt.js';
3
3
  import { serializeUrlSearchParams } from './url-search-params-serializer.js';
4
+ /**
5
+ * A lazy request to the Seam API.
6
+ *
7
+ * Creating a SeamHttpRequest does not send anything over the network.
8
+ * The request is sent once `execute` is called,
9
+ * or when the request is awaited like a Promise,
10
+ * e.g., with `await`, `then`, `catch`, or `finally`.
11
+ * When the response contains an action attempt,
12
+ * awaiting the request also waits for the action attempt to resolve
13
+ * according to the `waitForActionAttempt` option.
14
+ *
15
+ * Before sending, the request may be inspected
16
+ * with `url`, `pathname`, `method`, `params`, and `body`.
17
+ */
4
18
  export class SeamHttpRequest {
5
19
  [Symbol.toStringTag] = 'SeamHttpRequest';
6
20
  #parent;
@@ -9,12 +23,19 @@ export class SeamHttpRequest {
9
23
  this.#parent = parent;
10
24
  this.#config = config;
11
25
  }
26
+ /**
27
+ * The key of the API response object containing the response data,
28
+ * or undefined if the endpoint returns an empty response.
29
+ */
12
30
  get responseKey() {
13
31
  return this.#config.responseKey;
14
32
  }
15
33
  get hasPagination() {
16
34
  return this.#config.hasPagination ?? false;
17
35
  }
36
+ /**
37
+ * The full request URL including any serialized query parameters.
38
+ */
18
39
  get url() {
19
40
  const { client } = this.#parent;
20
41
  const serializer = typeof client.defaults.paramsSerializer === 'function'
@@ -40,6 +61,12 @@ export class SeamHttpRequest {
40
61
  get body() {
41
62
  return this.#config.body;
42
63
  }
64
+ /**
65
+ * Sends the request and returns the response data.
66
+ * If the response contains an action attempt,
67
+ * waits for the action attempt to resolve
68
+ * according to the `waitForActionAttempt` option.
69
+ */
43
70
  async execute() {
44
71
  const response = await this.fetchResponse();
45
72
  if (this.responseKey === undefined) {
@@ -59,6 +86,10 @@ export class SeamHttpRequest {
59
86
  }
60
87
  return data;
61
88
  }
89
+ /**
90
+ * Sends the request and returns the entire response body
91
+ * without waiting for any action attempt to resolve.
92
+ */
62
93
  async fetchResponse() {
63
94
  assertValidRequestParameters(this.#config.parameters, this.pathname, this.#config.hasRequiredParameters ?? false, this.#config.requiredParameterNames ?? []);
64
95
  const { client } = this.#parent;
@@ -1 +1 @@
1
- {"version":3,"file":"seam-http-request.js","sourceRoot":"","sources":["../src/lib/seam-http-request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAEL,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAqB5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AAM,IAAI,KAAK,CACb,8BAA8B,KAAK,+BAA+B,CACnE,CAAA;AACH,CAAC,CAAA;AAED,2DAA2D;AAC3D,kDAAkD;AAClD,MAAM,WAAW,GAAG,CAAC,KAAa,EAAW,EAAE;IAC7C,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA"}
@@ -6,6 +6,9 @@ interface SeamPaginatorParent {
6
6
  readonly defaults: Required<SeamHttpRequestOptions>;
7
7
  }
8
8
  declare const $brand: unique symbol;
9
+ /**
10
+ * Opaque cursor identifying a page of results returned by the Seam API.
11
+ */
9
12
  export type SeamPageCursor = string & {
10
13
  [$brand]: 'SeamPageCursor';
11
14
  };
@@ -14,16 +17,41 @@ interface Pagination {
14
17
  readonly nextPageCursor: SeamPageCursor | null;
15
18
  readonly nextPageUrl: string | null;
16
19
  }
20
+ /**
21
+ * Iterates over paginated results from Seam API list endpoints.
22
+ *
23
+ * Create a SeamPaginator with the client's `createPaginator` method.
24
+ * Fetch pages manually with `firstPage` and `nextPage`,
25
+ * iterate over pages with `for await`,
26
+ * iterate over items across all pages with `flatten`,
27
+ * or collect every item into a single array with `flattenToArray`.
28
+ */
17
29
  export declare class SeamPaginator<const TResponse, const TResponseKey extends keyof TResponse> implements AsyncIterable<EnsureReadonlyArray<TResponse[TResponseKey]>> {
18
30
  #private;
19
31
  constructor(parent: SeamPaginatorParent, request: SeamHttpRequest<TResponse, TResponseKey>);
32
+ /**
33
+ * Fetches the first page of results along with the pagination state.
34
+ */
20
35
  firstPage(): Promise<[
21
36
  EnsureReadonlyArray<TResponse[TResponseKey]>,
22
37
  Pagination
23
38
  ]>;
39
+ /**
40
+ * Fetches the next page of results
41
+ * using the nextPageCursor returned with a previous page.
42
+ */
24
43
  nextPage(nextPageCursor: Pagination['nextPageCursor']): Promise<[EnsureReadonlyArray<TResponse[TResponseKey]>, Pagination]>;
44
+ /**
45
+ * Fetches every page and returns all items in a single array.
46
+ */
25
47
  flattenToArray(): Promise<EnsureReadonlyArray<TResponse[TResponseKey]>>;
48
+ /**
49
+ * Yields each item across all pages, fetching the next page as needed.
50
+ */
26
51
  flatten(): AsyncGenerator<EnsureReadonlyArray<TResponse[TResponseKey]>>;
52
+ /**
53
+ * Yields each page of items, fetching the next page as needed.
54
+ */
27
55
  [Symbol.asyncIterator](): AsyncGenerator<EnsureReadonlyArray<TResponse[TResponseKey]>>;
28
56
  }
29
57
  type EnsureReadonlyArray<T> = T extends readonly any[] ? T : never;
@@ -1,4 +1,13 @@
1
1
  import { SeamHttpRequest } from './seam-http-request.js';
2
+ /**
3
+ * Iterates over paginated results from Seam API list endpoints.
4
+ *
5
+ * Create a SeamPaginator with the client's `createPaginator` method.
6
+ * Fetch pages manually with `firstPage` and `nextPage`,
7
+ * iterate over pages with `for await`,
8
+ * iterate over items across all pages with `flatten`,
9
+ * or collect every item into a single array with `flattenToArray`.
10
+ */
2
11
  export class SeamPaginator {
3
12
  #request;
4
13
  #parent;
@@ -9,9 +18,16 @@ export class SeamPaginator {
9
18
  this.#parent = parent;
10
19
  this.#request = request;
11
20
  }
21
+ /**
22
+ * Fetches the first page of results along with the pagination state.
23
+ */
12
24
  async firstPage() {
13
25
  return await this.#fetch();
14
26
  }
27
+ /**
28
+ * Fetches the next page of results
29
+ * using the nextPageCursor returned with a previous page.
30
+ */
15
31
  async nextPage(nextPageCursor) {
16
32
  if (nextPageCursor == null) {
17
33
  throw new Error('Cannot get the next page with a null nextPageCursor');
@@ -54,6 +70,9 @@ export class SeamPaginator {
54
70
  pagination,
55
71
  ];
56
72
  }
73
+ /**
74
+ * Fetches every page and returns all items in a single array.
75
+ */
57
76
  async flattenToArray() {
58
77
  const items = [];
59
78
  let [current, pagination] = await this.firstPage();
@@ -65,6 +84,9 @@ export class SeamPaginator {
65
84
  }
66
85
  return items;
67
86
  }
87
+ /**
88
+ * Yields each item across all pages, fetching the next page as needed.
89
+ */
68
90
  async *flatten() {
69
91
  let [current, pagination] = await this.firstPage();
70
92
  for (const item of current) {
@@ -78,6 +100,9 @@ export class SeamPaginator {
78
100
  }
79
101
  }
80
102
  }
103
+ /**
104
+ * Yields each page of items, fetching the next page as needed.
105
+ */
81
106
  async *[Symbol.asyncIterator]() {
82
107
  let [current, pagination] = await this.firstPage();
83
108
  yield current;
@@ -1 +1 @@
1
- {"version":3,"file":"seam-paginator.js","sourceRoot":"","sources":["../src/lib/seam-paginator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAiBxD,MAAM,OAAO,aAAa;IAIf,QAAQ,CAA0C;IAClD,OAAO,CAAqB;IAErC,YACE,MAA2B,EAC3B,OAAiD;QAEjD,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,OAAO,OAAO,CAAC,QAAQ,uCAAuC,CAC/D,CAAA;QACH,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,SAAS;QAGb,OAAO,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,cAA4C;QAE5C,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACxE,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CACV,cAA6C;QAE7C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAA;QAE7C,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA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AA;YACvE,MAAM,OAAO,CAAA;QACf,CAAC;IACH,CAAC;CACF"}
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiJavascriptHttpVersion = "2.18.0";
1
+ declare const seamapiJavascriptHttpVersion = "2.20.0";
2
2
  export default seamapiJavascriptHttpVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '2.18.0';
1
+ const seamapiJavascriptHttpVersion = '2.20.0';
2
2
  export default seamapiJavascriptHttpVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/http",
3
- "version": "2.18.0",
3
+ "version": "2.20.0",
4
4
  "description": "JavaScript HTTP client for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -87,7 +87,7 @@
87
87
  "@seamapi/blueprint": "^1.8.0",
88
88
  "@seamapi/fake-seam-connect": "^2.0.4",
89
89
  "@seamapi/smith": "^1.1.0",
90
- "@seamapi/types": "1.1028.0",
90
+ "@seamapi/types": "1.1030.0",
91
91
  "@types/jsonwebtoken": "^9.0.6",
92
92
  "@types/node": "^24.10.9",
93
93
  "ava": "^8.0.1",
@@ -97,6 +97,7 @@
97
97
  "eslint": "^9.31.0",
98
98
  "eslint-import-resolver-typescript": "^4.4.5",
99
99
  "eslint-plugin-import": "^2.32.0",
100
+ "eslint-plugin-jsdoc": "^64.1.0",
100
101
  "eslint-plugin-simple-import-sort": "^12.1.1",
101
102
  "eslint-plugin-unused-imports": "^4.1.4",
102
103
  "execa": "^10.0.0",
package/src/index.ts CHANGED
@@ -1 +1,6 @@
1
+ /**
2
+ * JavaScript HTTP client for the Seam API written in TypeScript.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  export * from './lib/index.js'
package/src/lib/client.ts CHANGED
@@ -13,8 +13,22 @@ export type Client = AxiosInstance
13
13
  export const defaultTimeout = 30_000
14
14
 
15
15
  export interface ClientOptions {
16
+ /**
17
+ * Request timeout in milliseconds, applied per attempt.
18
+ * Set to 0 to disable the timeout. Defaults to 30 seconds.
19
+ */
16
20
  timeout?: number
21
+
22
+ /**
23
+ * Options passed to the underlying Axios client.
24
+ */
17
25
  axiosOptions?: AxiosRequestConfig
26
+
27
+ /**
28
+ * Options passed to axios-retry,
29
+ * which retries idempotent requests that fail
30
+ * because of a transport error, timeout, or HTTP 429 response.
31
+ */
18
32
  axiosRetryOptions?: AxiosRetryConfig
19
33
  }
20
34
 
package/src/lib/index.ts CHANGED
@@ -3,12 +3,15 @@ export * from './error-interceptor.js'
3
3
  export * from './openapi.js'
4
4
  export * from './options.js'
5
5
  export {
6
+ type FailedActionAttempt,
6
7
  isSeamActionAttemptError,
7
8
  isSeamActionAttemptFailedError,
8
9
  isSeamActionAttemptTimeoutError,
10
+ type ResolveActionAttemptOptions,
9
11
  SeamActionAttemptError,
10
12
  SeamActionAttemptFailedError,
11
13
  SeamActionAttemptTimeoutError,
14
+ type SucceededActionAttempt,
12
15
  } from './resolve-action-attempt.js'
13
16
  export * from './resources/index.js'
14
17
  export * from './routes/index.js'
@@ -6,12 +6,19 @@ import {
6
6
 
7
7
  export type { SeamHttpRequestOptions } from './request-options.js'
8
8
 
9
+ /**
10
+ * Options for creating a SeamHttpWithoutWorkspace client,
11
+ * which is not scoped to a single workspace.
12
+ */
9
13
  export type SeamHttpWithoutWorkspaceOptions =
10
14
  | SeamHttpWithoutWorkspaceOptionsFromEnv
11
15
  | SeamHttpWithoutWorkspaceOptionsWithClient
12
16
  | SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken
13
17
  | SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken
14
18
 
19
+ /**
20
+ * Options for creating a SeamHttp client.
21
+ */
15
22
  export type SeamHttpOptions =
16
23
  | SeamHttpOptionsFromEnv
17
24
  | SeamHttpOptionsWithClient
@@ -21,28 +28,62 @@ export type SeamHttpOptions =
21
28
  | SeamHttpOptionsWithPersonalAccessToken
22
29
 
23
30
  interface SeamHttpCommonOptions extends ClientOptions, SeamHttpRequestOptions {
31
+ /**
32
+ * The Seam API endpoint, e.g., `https://connect.getseam.com`.
33
+ * Defaults to the SEAM_ENDPOINT or SEAM_API_URL environment variable, if set.
34
+ */
24
35
  endpoint?: string
25
36
  }
26
37
 
38
+ /**
39
+ * Options for creating a SeamHttp client with `SeamHttp.fromPublishableKey`.
40
+ */
27
41
  export interface SeamHttpFromPublishableKeyOptions extends SeamHttpCommonOptions {}
28
42
 
43
+ /**
44
+ * Options for creating a SeamHttp client that reads its configuration
45
+ * from the environment, e.g., the SEAM_API_KEY environment variable.
46
+ */
29
47
  export interface SeamHttpOptionsFromEnv extends SeamHttpCommonOptions {}
30
48
 
49
+ /**
50
+ * Options for creating a SeamHttpWithoutWorkspace client that reads
51
+ * its configuration from the environment,
52
+ * e.g., the SEAM_PERSONAL_ACCESS_TOKEN environment variable.
53
+ */
31
54
  export interface SeamHttpWithoutWorkspaceOptionsFromEnv extends SeamHttpCommonOptions {}
32
55
 
56
+ /**
57
+ * Options for creating a SeamHttpWithoutWorkspace client from an existing client.
58
+ */
33
59
  export interface SeamHttpWithoutWorkspaceOptionsWithClient extends SeamHttpCommonOptions {
34
60
  client: Client
35
61
  }
36
62
 
63
+ /**
64
+ * Returns true if the options include a client.
65
+ *
66
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
67
+ * is used with any other option.
68
+ */
37
69
  export const isSeamHttpWithoutWorkspaceOptionsWithClient = (
38
70
  options: SeamHttpOptions,
39
71
  ): options is SeamHttpWithoutWorkspaceOptionsWithClient =>
40
72
  isSeamHttpOptionsWithClient(options)
41
73
 
74
+ /**
75
+ * Options for creating a SeamHttp client from an existing client.
76
+ */
42
77
  export interface SeamHttpOptionsWithClient extends SeamHttpRequestOptions {
43
78
  client: Client
44
79
  }
45
80
 
81
+ /**
82
+ * Returns true if the options include a client.
83
+ *
84
+ * @throws {@link SeamHttpInvalidOptionsError} if the client option
85
+ * is used with any other option.
86
+ */
46
87
  export const isSeamHttpOptionsWithClient = (
47
88
  options: SeamHttpOptions,
48
89
  ): options is SeamHttpOptionsWithClient => {
@@ -61,10 +102,19 @@ export const isSeamHttpOptionsWithClient = (
61
102
  return true
62
103
  }
63
104
 
105
+ /**
106
+ * Options for creating a SeamHttp client authenticated with an API key.
107
+ */
64
108
  export interface SeamHttpOptionsWithApiKey extends SeamHttpCommonOptions {
65
109
  apiKey: string
66
110
  }
67
111
 
112
+ /**
113
+ * Returns true if the options include an apiKey.
114
+ *
115
+ * @throws {@link SeamHttpInvalidOptionsError} if the apiKey option
116
+ * is used with another authentication option.
117
+ */
68
118
  export const isSeamHttpOptionsWithApiKey = (
69
119
  options: SeamHttpOptions,
70
120
  ): options is SeamHttpOptionsWithApiKey => {
@@ -92,10 +142,19 @@ export const isSeamHttpOptionsWithApiKey = (
92
142
  return true
93
143
  }
94
144
 
145
+ /**
146
+ * Options for creating a SeamHttp client authenticated with a client session token.
147
+ */
95
148
  export interface SeamHttpOptionsWithClientSessionToken extends SeamHttpCommonOptions {
96
149
  clientSessionToken: string
97
150
  }
98
151
 
152
+ /**
153
+ * Returns true if the options include a clientSessionToken.
154
+ *
155
+ * @throws {@link SeamHttpInvalidOptionsError} if the clientSessionToken option
156
+ * is used with another authentication option.
157
+ */
99
158
  export const isSeamHttpOptionsWithClientSessionToken = (
100
159
  options: SeamHttpOptions,
101
160
  ): options is SeamHttpOptionsWithClientSessionToken => {
@@ -123,10 +182,20 @@ export const isSeamHttpOptionsWithClientSessionToken = (
123
182
  return true
124
183
  }
125
184
 
185
+ /**
186
+ * Options for creating a SeamHttpWithoutWorkspace client
187
+ * authenticated with a console session token.
188
+ */
126
189
  export interface SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken extends SeamHttpCommonOptions {
127
190
  consoleSessionToken: string
128
191
  }
129
192
 
193
+ /**
194
+ * Returns true if the options include a consoleSessionToken.
195
+ *
196
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
197
+ * is used with another authentication option.
198
+ */
130
199
  export const isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken = (
131
200
  options: SeamHttpOptions,
132
201
  ): options is SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken => {
@@ -154,11 +223,21 @@ export const isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken = (
154
223
  return true
155
224
  }
156
225
 
226
+ /**
227
+ * Options for creating a SeamHttp client
228
+ * authenticated with a console session token and scoped to a workspace.
229
+ */
157
230
  export interface SeamHttpOptionsWithConsoleSessionToken extends SeamHttpCommonOptions {
158
231
  consoleSessionToken: string
159
232
  workspaceId: string
160
233
  }
161
234
 
235
+ /**
236
+ * Returns true if the options include a consoleSessionToken and a workspaceId.
237
+ *
238
+ * @throws {@link SeamHttpInvalidOptionsError} if the consoleSessionToken option
239
+ * is used with another authentication option or without the workspaceId option.
240
+ */
162
241
  export const isSeamHttpOptionsWithConsoleSessionToken = (
163
242
  options: SeamHttpOptions,
164
243
  ): options is SeamHttpOptionsWithConsoleSessionToken => {
@@ -175,10 +254,20 @@ export const isSeamHttpOptionsWithConsoleSessionToken = (
175
254
  return true
176
255
  }
177
256
 
257
+ /**
258
+ * Options for creating a SeamHttpWithoutWorkspace client
259
+ * authenticated with a personal access token.
260
+ */
178
261
  export interface SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken extends SeamHttpCommonOptions {
179
262
  personalAccessToken: string
180
263
  }
181
264
 
265
+ /**
266
+ * Returns true if the options include a personalAccessToken.
267
+ *
268
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
269
+ * is used with another authentication option.
270
+ */
182
271
  export const isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken = (
183
272
  options: SeamHttpOptions,
184
273
  ): options is SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken => {
@@ -206,11 +295,21 @@ export const isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken = (
206
295
  return true
207
296
  }
208
297
 
298
+ /**
299
+ * Options for creating a SeamHttp client
300
+ * authenticated with a personal access token and scoped to a workspace.
301
+ */
209
302
  export interface SeamHttpOptionsWithPersonalAccessToken extends SeamHttpCommonOptions {
210
303
  personalAccessToken: string
211
304
  workspaceId: string
212
305
  }
213
306
 
307
+ /**
308
+ * Returns true if the options include a personalAccessToken and a workspaceId.
309
+ *
310
+ * @throws {@link SeamHttpInvalidOptionsError} if the personalAccessToken option
311
+ * is used with another authentication option or without the workspaceId option.
312
+ */
214
313
  export const isSeamHttpOptionsWithPersonalAccessToken = (
215
314
  options: SeamHttpOptions,
216
315
  ): options is SeamHttpOptionsWithPersonalAccessToken => {
@@ -227,6 +326,9 @@ export const isSeamHttpOptionsWithPersonalAccessToken = (
227
326
  return true
228
327
  }
229
328
 
329
+ /**
330
+ * Error thrown when a SeamHttp client is created with invalid options.
331
+ */
230
332
  export class SeamHttpInvalidOptionsError extends Error {
231
333
  constructor(message: string) {
232
334
  super(`SeamHttp received invalid options: ${message}`)
@@ -234,6 +336,9 @@ export class SeamHttpInvalidOptionsError extends Error {
234
336
  }
235
337
  }
236
338
 
339
+ /**
340
+ * Error thrown when a SeamHttpWithoutWorkspace client is created with invalid options.
341
+ */
237
342
  export class SeamHttpWithoutWorkspaceInvalidOptionsError extends Error {
238
343
  constructor(message: string) {
239
344
  super(`SeamHttpWithoutWorkspace received invalid options: ${message}`)