@seamapi/http 1.27.0 → 1.29.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/README.md CHANGED
@@ -174,8 +174,10 @@ A workspace ID must be provided when using this method
174
174
  and all requests will be scoped to that workspace.
175
175
 
176
176
  ```ts
177
- // Pass as an option to the constructor
177
+ // Set the `SEAM_PERSONAL_ACCESS_TOKEN` and `SEAM_WORKSPACE_ID` environment variables
178
+ const seam = new SeamHttp()
178
179
 
180
+ // Pass as an option to the constructor
179
181
  const seam = new SeamHttp({
180
182
  personalAccessToken: 'your-personal-access-token',
181
183
  workspaceId: 'your-workspace-id',
@@ -407,6 +409,9 @@ A Personal Access Token is scoped to a Seam Console user.
407
409
  Obtain one from the Seam Console.
408
410
 
409
411
  ```ts
412
+ // Set the `SEAM_PERSONAL_ACCESS_TOKEN` environment variable
413
+ const seam = new SeamHttpMultiWorkspace()
414
+
410
415
  // Pass as an option to the constructor
411
416
  const seam = new SeamHttpMultiWorkspace({
412
417
  personalAccessToken: 'your-personal-access-token',
package/dist/connect.cjs CHANGED
@@ -67,9 +67,17 @@ var getNormalizedOptions = (apiKeyOrOptions) => {
67
67
  };
68
68
  }
69
69
  const apiKey = "apiKey" in options ? options.apiKey : getApiKeyFromEnv(options);
70
+ const personalAccessToken = "personalAccessToken" in options ? options.personalAccessToken : getPersonalAccessTokenFromEnv(options);
71
+ const workspaceId = "workspaceId" in options ? options.workspaceId : getWorkspaceIdFromEnv();
72
+ if (apiKey != null && personalAccessToken != null && !("apiKey" in options) && !("personalAccessToken" in options)) {
73
+ throw new SeamHttpInvalidOptionsError(
74
+ "Both SEAM_API_KEY and SEAM_PERSONAL_ACCESS_TOKEN environment variables are defined. Please use only one authentication method."
75
+ );
76
+ }
70
77
  return {
71
78
  ...options,
72
79
  ...apiKey != null ? { apiKey } : {},
80
+ ...personalAccessToken != null && workspaceId != null ? { personalAccessToken, workspaceId } : {},
73
81
  ...requestOptions
74
82
  };
75
83
  };
@@ -85,6 +93,21 @@ var getApiKeyFromEnv = (options) => {
85
93
  }
86
94
  return globalThis.process?.env?.SEAM_API_KEY;
87
95
  };
96
+ var getPersonalAccessTokenFromEnv = (options) => {
97
+ if ("apiKey" in options && options.apiKey != null) {
98
+ return null;
99
+ }
100
+ if ("clientSessionToken" in options && options.clientSessionToken != null) {
101
+ return null;
102
+ }
103
+ if ("consoleSessionToken" in options && options.consoleSessionToken != null) {
104
+ return null;
105
+ }
106
+ return globalThis.process?.env?.["SEAM_PERSONAL_ACCESS_TOKEN"];
107
+ };
108
+ var getWorkspaceIdFromEnv = () => {
109
+ return globalThis.process?.env?.["SEAM_WORKSPACE_ID"];
110
+ };
88
111
  var getEndpointFromEnv = () => {
89
112
  if (globalThis.process?.env?.SEAM_API_URL != null) {
90
113
  console.warn(
@@ -1814,6 +1837,14 @@ var SeamHttpAcsEncoders = class _SeamHttpAcsEncoders {
1814
1837
  options
1815
1838
  });
1816
1839
  }
1840
+ get(body) {
1841
+ return new SeamHttpRequest(this, {
1842
+ pathname: "/acs/encoders/get",
1843
+ method: "post",
1844
+ body,
1845
+ responseKey: "acs_encoder"
1846
+ });
1847
+ }
1817
1848
  list(body) {
1818
1849
  return new SeamHttpRequest(this, {
1819
1850
  pathname: "/acs/encoders/list",
@@ -4997,7 +5028,7 @@ var SeamHttp = _SeamHttp;
4997
5028
 
4998
5029
  // src/lib/seam/connect/seam-http-multi-workspace.ts
4999
5030
  var SeamHttpMultiWorkspace = class _SeamHttpMultiWorkspace {
5000
- constructor(options) {
5031
+ constructor(options = {}) {
5001
5032
  const opts = parseOptions(options);
5002
5033
  this.client = "client" in opts ? opts.client : createClient(opts);
5003
5034
  this.defaults = limitToSeamHttpRequestOptions(opts);