@roundtable-bb/sdk 0.1.28 → 0.1.33
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 +1 -1
- package/dist/generated/client.js +135 -237
- package/dist/index.d.ts +242 -177
- package/dist/index.js +1 -1
- package/dist/request.js +25 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { RoundtableClient } from './generated/client.js';
|
package/dist/request.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
export async function request(opts, method, path, options) {
|
|
2
2
|
const routeAuth = options?.routeAuth;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (
|
|
3
|
+
const authMethod = options?.authMethod;
|
|
4
|
+
let token;
|
|
5
|
+
let useCredentials = false;
|
|
6
|
+
if (authMethod) {
|
|
7
|
+
if (authMethod === 'apiKey') {
|
|
8
|
+
if (!opts.apiKey)
|
|
9
|
+
throw new Error('authMethod: apiKey is not configured');
|
|
10
|
+
token = opts.apiKey;
|
|
11
|
+
}
|
|
12
|
+
else if (authMethod === 'tenantToken') {
|
|
13
|
+
if (!opts.tenantToken)
|
|
14
|
+
throw new Error('authMethod: tenantToken is not configured');
|
|
15
|
+
token = opts.tenantToken;
|
|
16
|
+
}
|
|
17
|
+
else if (authMethod === 'betterAuth') {
|
|
8
18
|
useCredentials = true;
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
}
|
|
21
|
+
else if (routeAuth) {
|
|
22
|
+
if (opts.apiKey && routeAuth.acceptsApiKey) {
|
|
23
|
+
token = opts.apiKey;
|
|
24
|
+
}
|
|
25
|
+
else if (opts.tenantToken && routeAuth.acceptsTenantJwt) {
|
|
26
|
+
token = opts.tenantToken;
|
|
13
27
|
}
|
|
14
|
-
|
|
15
|
-
else if (!opts.token && routeAuth.acceptsBetterAuth) {
|
|
28
|
+
else if (routeAuth.acceptsBetterAuth) {
|
|
16
29
|
useCredentials = true;
|
|
17
30
|
}
|
|
18
|
-
// Otherwise: make request without auth (backend will respond 401/403 if needed)
|
|
19
31
|
}
|
|
20
32
|
const url = new URL(`${opts.baseURL}${path}`);
|
|
21
33
|
if (options?.query) {
|
|
@@ -28,12 +40,8 @@ export async function request(opts, method, path, options) {
|
|
|
28
40
|
method,
|
|
29
41
|
credentials: useCredentials ? 'include' : undefined,
|
|
30
42
|
headers: {
|
|
31
|
-
...(options?.body !== undefined
|
|
32
|
-
|
|
33
|
-
: {}),
|
|
34
|
-
...(opts.token && !useCredentials
|
|
35
|
-
? { Authorization: `Bearer ${opts.token}` }
|
|
36
|
-
: {}),
|
|
43
|
+
...(options?.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
44
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
37
45
|
},
|
|
38
46
|
body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
39
47
|
});
|