@arcadeai/design-system 1.5.1 → 1.7.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/{arcade-DSu1Vp41.js → arcade-DzMbb7xi.js} +512 -586
- package/dist/components/index.js +302 -300
- package/dist/components/ui/atoms/alert-dialog.d.ts +14 -0
- package/dist/components/ui/atoms/alert-dialog.js +248 -0
- package/dist/components/ui/atoms/command.js +1 -1
- package/dist/components/ui/atoms/dialog.js +1 -1
- package/dist/components/ui/atoms/icons/codesandbox.d.ts +3 -0
- package/dist/components/ui/atoms/icons/codesandbox.js +26 -0
- package/dist/components/ui/atoms/icons/index.d.ts +1 -0
- package/dist/components/ui/atoms/icons/index.js +182 -180
- package/dist/components/ui/atoms/index.js +285 -283
- package/dist/components/ui/atoms/sheet.js +1 -1
- package/dist/components/ui/index.js +302 -300
- package/dist/components/ui/molecules/toolkit-picker-trigger.js +29 -32
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-filter.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-search.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-selection.test.js +2 -2
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.d.ts +11 -3
- package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.js +141 -99
- package/dist/components/ui/organisms/toolkit-picker/index.d.ts +2 -0
- package/dist/components/ui/organisms/toolkit-picker/index.js +3 -2
- package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.d.ts +2 -0
- package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.js +247 -55
- package/dist/components/ui/organisms/toolkit-picker/toolkit-picker.test.js +2 -2
- package/dist/components/ui/utils/memo.test.js +1 -1
- package/dist/{index-BzU0xzeS.js → index-Dkey23PG.js} +3 -1
- package/dist/lib/arcade/arcade.js +3 -2
- package/dist/lib/arcade/arcade.test.js +2 -2
- package/dist/lib/utils.test.js +1 -1
- package/dist/main.js +313 -311
- package/dist/metadata/oauth-providers.js +9 -9
- package/dist/metadata/toolkits.js +383 -227
- package/dist/metadata/types.d.ts +2 -1
- package/dist/{react.esm-CFMQn0EI.js → react.esm-CAxz4dXo.js} +1 -1
- package/dist/{vi.bdSIJ99Y-CQ1FdEM8.js → vi.bdSIJ99Y-hyudrc3R.js} +3880 -3436
- package/dist/web-sgv-FK6q.js +84 -0
- package/package.json +2 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { k as _e, s as Qe, g as Ge, F as de, f as Je, a as Ye, b as Ze } from "./web-sgv-FK6q.js";
|
|
2
|
+
import { TOOLKIT_CATALOGUE as et } from "./metadata/toolkits.js";
|
|
3
|
+
import { r as he } from "./utils-Db4QWi-E.js";
|
|
4
|
+
const J = "RFC3986", Y = {
|
|
4
5
|
RFC1738: (t) => String(t).replace(/%20/g, "+"),
|
|
5
6
|
RFC3986: (t) => String(t)
|
|
6
|
-
},
|
|
7
|
+
}, tt = "RFC1738", nt = Array.isArray, _ = (() => {
|
|
7
8
|
const t = [];
|
|
8
9
|
for (let e = 0; e < 256; ++e)
|
|
9
10
|
t.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase());
|
|
10
11
|
return t;
|
|
11
|
-
})(),
|
|
12
|
+
})(), W = 1024, rt = (t, e, n, r, s) => {
|
|
12
13
|
if (t.length === 0)
|
|
13
14
|
return t;
|
|
14
15
|
let o = t;
|
|
15
|
-
if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)),
|
|
16
|
+
if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)), n === "iso-8859-1")
|
|
16
17
|
return escape(o).replace(/%u[0-9a-f]{4}/gi, function(l) {
|
|
17
18
|
return "%26%23" + parseInt(l.slice(2), 16) + "%3B";
|
|
18
19
|
});
|
|
19
20
|
let i = "";
|
|
20
|
-
for (let l = 0; l < o.length; l +=
|
|
21
|
-
const c = o.length >=
|
|
21
|
+
for (let l = 0; l < o.length; l += W) {
|
|
22
|
+
const c = o.length >= W ? o.slice(l, l + W) : o, u = [];
|
|
22
23
|
for (let p = 0; p < c.length; ++p) {
|
|
23
24
|
let a = c.charCodeAt(p);
|
|
24
25
|
if (a === 45 || // -
|
|
@@ -28,7 +29,7 @@ const Y = "RFC3986", Z = {
|
|
|
28
29
|
a >= 48 && a <= 57 || // 0-9
|
|
29
30
|
a >= 65 && a <= 90 || // a-z
|
|
30
31
|
a >= 97 && a <= 122 || // A-Z
|
|
31
|
-
s ===
|
|
32
|
+
s === tt && (a === 40 || a === 41)) {
|
|
32
33
|
u[u.length] = c.charAt(p);
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
@@ -50,19 +51,19 @@ const Y = "RFC3986", Z = {
|
|
|
50
51
|
}
|
|
51
52
|
return i;
|
|
52
53
|
};
|
|
53
|
-
function
|
|
54
|
+
function st(t) {
|
|
54
55
|
return !t || typeof t != "object" ? !1 : !!(t.constructor && t.constructor.isBuffer && t.constructor.isBuffer(t));
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function pe(t, e) {
|
|
57
58
|
if (nt(t)) {
|
|
58
|
-
const
|
|
59
|
-
for (let
|
|
60
|
-
|
|
61
|
-
return
|
|
59
|
+
const n = [];
|
|
60
|
+
for (let r = 0; r < t.length; r += 1)
|
|
61
|
+
n.push(e(t[r]));
|
|
62
|
+
return n;
|
|
62
63
|
}
|
|
63
64
|
return e(t);
|
|
64
65
|
}
|
|
65
|
-
const
|
|
66
|
+
const ot = Object.prototype.hasOwnProperty, Ae = {
|
|
66
67
|
brackets(t) {
|
|
67
68
|
return String(t) + "[]";
|
|
68
69
|
},
|
|
@@ -73,9 +74,9 @@ const it = Object.prototype.hasOwnProperty, Re = {
|
|
|
73
74
|
repeat(t) {
|
|
74
75
|
return String(t);
|
|
75
76
|
}
|
|
76
|
-
}, A = Array.isArray,
|
|
77
|
-
|
|
78
|
-
},
|
|
77
|
+
}, A = Array.isArray, it = Array.prototype.push, Se = function(t, e) {
|
|
78
|
+
it.apply(t, A(e) ? e : [e]);
|
|
79
|
+
}, at = Date.prototype.toISOString, y = {
|
|
79
80
|
addQueryPrefix: !1,
|
|
80
81
|
allowDots: !1,
|
|
81
82
|
allowEmptyArrays: !1,
|
|
@@ -85,103 +86,103 @@ const it = Object.prototype.hasOwnProperty, Re = {
|
|
|
85
86
|
delimiter: "&",
|
|
86
87
|
encode: !0,
|
|
87
88
|
encodeDotInKeys: !1,
|
|
88
|
-
encoder:
|
|
89
|
+
encoder: rt,
|
|
89
90
|
encodeValuesOnly: !1,
|
|
90
|
-
format:
|
|
91
|
-
formatter:
|
|
91
|
+
format: J,
|
|
92
|
+
formatter: Y[J],
|
|
92
93
|
/** @deprecated */
|
|
93
94
|
indices: !1,
|
|
94
95
|
serializeDate(t) {
|
|
95
|
-
return
|
|
96
|
+
return at.call(t);
|
|
96
97
|
},
|
|
97
98
|
skipNulls: !1,
|
|
98
99
|
strictNullHandling: !1
|
|
99
100
|
};
|
|
100
|
-
function
|
|
101
|
+
function ct(t) {
|
|
101
102
|
return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || typeof t == "symbol" || typeof t == "bigint";
|
|
102
103
|
}
|
|
103
|
-
const
|
|
104
|
-
function
|
|
105
|
-
let f = t,
|
|
106
|
-
for (; (
|
|
107
|
-
const g =
|
|
108
|
-
if (
|
|
109
|
-
if (g ===
|
|
104
|
+
const V = {};
|
|
105
|
+
function Re(t, e, n, r, s, o, i, l, c, u, p, a, h, m, b, E, S, z) {
|
|
106
|
+
let f = t, D = z, U = 0, ce = !1;
|
|
107
|
+
for (; (D = D.get(V)) !== void 0 && !ce; ) {
|
|
108
|
+
const g = D.get(t);
|
|
109
|
+
if (U += 1, typeof g < "u") {
|
|
110
|
+
if (g === U)
|
|
110
111
|
throw new RangeError("Cyclic object value");
|
|
111
|
-
|
|
112
|
+
ce = !0;
|
|
112
113
|
}
|
|
113
|
-
typeof
|
|
114
|
+
typeof D.get(V) > "u" && (U = 0);
|
|
114
115
|
}
|
|
115
|
-
if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) :
|
|
116
|
+
if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) : n === "comma" && A(f) && (f = pe(f, function(g) {
|
|
116
117
|
return g instanceof Date ? h?.(g) : g;
|
|
117
118
|
})), f === null) {
|
|
118
119
|
if (o)
|
|
119
120
|
return c && !E ? (
|
|
120
121
|
// @ts-expect-error
|
|
121
|
-
c(e, y.encoder,
|
|
122
|
+
c(e, y.encoder, S, "key", m)
|
|
122
123
|
) : e;
|
|
123
124
|
f = "";
|
|
124
125
|
}
|
|
125
|
-
if (
|
|
126
|
+
if (ct(f) || st(f)) {
|
|
126
127
|
if (c) {
|
|
127
|
-
const g = E ? e : c(e, y.encoder,
|
|
128
|
+
const g = E ? e : c(e, y.encoder, S, "key", m);
|
|
128
129
|
return [
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
b?.(g) + "=" + // @ts-expect-error
|
|
131
|
+
b?.(c(f, y.encoder, S, "value", m))
|
|
131
132
|
];
|
|
132
133
|
}
|
|
133
|
-
return [
|
|
134
|
+
return [b?.(e) + "=" + b?.(String(f))];
|
|
134
135
|
}
|
|
135
|
-
const
|
|
136
|
+
const X = [];
|
|
136
137
|
if (typeof f > "u")
|
|
137
|
-
return
|
|
138
|
+
return X;
|
|
138
139
|
let I;
|
|
139
|
-
if (
|
|
140
|
-
E && c && (f =
|
|
140
|
+
if (n === "comma" && A(f))
|
|
141
|
+
E && c && (f = pe(f, c)), I = [{ value: f.length > 0 ? f.join(",") || null : void 0 }];
|
|
141
142
|
else if (A(u))
|
|
142
143
|
I = u;
|
|
143
144
|
else {
|
|
144
145
|
const g = Object.keys(f);
|
|
145
146
|
I = p ? g.sort(p) : g;
|
|
146
147
|
}
|
|
147
|
-
const
|
|
148
|
+
const ue = l ? String(e).replace(/\./g, "%2E") : String(e), $ = r && A(f) && f.length === 1 ? ue + "[]" : ue;
|
|
148
149
|
if (s && A(f) && f.length === 0)
|
|
149
|
-
return
|
|
150
|
+
return $ + "[]";
|
|
150
151
|
for (let g = 0; g < I.length; ++g) {
|
|
151
|
-
const k = I[g],
|
|
152
|
+
const k = I[g], le = (
|
|
152
153
|
// @ts-ignore
|
|
153
154
|
typeof k == "object" && typeof k.value < "u" ? k.value : f[k]
|
|
154
155
|
);
|
|
155
|
-
if (i &&
|
|
156
|
+
if (i && le === null)
|
|
156
157
|
continue;
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
r,
|
|
158
|
+
const K = a && l ? k.replace(/\./g, "%2E") : k, Ve = A(f) ? typeof n == "function" ? n($, K) : $ : $ + (a ? "." + K : "[" + K + "]");
|
|
159
|
+
z.set(t, U);
|
|
160
|
+
const fe = /* @__PURE__ */ new WeakMap();
|
|
161
|
+
fe.set(V, z), Se(X, Re(
|
|
162
|
+
le,
|
|
163
|
+
Ve,
|
|
164
164
|
n,
|
|
165
|
+
r,
|
|
165
166
|
s,
|
|
166
167
|
o,
|
|
167
168
|
i,
|
|
168
169
|
l,
|
|
169
170
|
// @ts-ignore
|
|
170
|
-
|
|
171
|
+
n === "comma" && E && A(f) ? null : c,
|
|
171
172
|
u,
|
|
172
173
|
p,
|
|
173
174
|
a,
|
|
174
175
|
h,
|
|
175
176
|
m,
|
|
176
|
-
|
|
177
|
+
b,
|
|
177
178
|
E,
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
S,
|
|
180
|
+
fe
|
|
180
181
|
));
|
|
181
182
|
}
|
|
182
|
-
return
|
|
183
|
+
return X;
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
+
function ut(t = y) {
|
|
185
186
|
if (typeof t.allowEmptyArrays < "u" && typeof t.allowEmptyArrays != "boolean")
|
|
186
187
|
throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
|
|
187
188
|
if (typeof t.encodeDotInKeys < "u" && typeof t.encodeDotInKeys != "boolean")
|
|
@@ -191,17 +192,17 @@ function lt(t = y) {
|
|
|
191
192
|
const e = t.charset || y.charset;
|
|
192
193
|
if (typeof t.charset < "u" && t.charset !== "utf-8" && t.charset !== "iso-8859-1")
|
|
193
194
|
throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
|
|
194
|
-
let
|
|
195
|
+
let n = J;
|
|
195
196
|
if (typeof t.format < "u") {
|
|
196
|
-
if (!
|
|
197
|
+
if (!ot.call(Y, t.format))
|
|
197
198
|
throw new TypeError("Unknown format option provided.");
|
|
198
|
-
|
|
199
|
+
n = t.format;
|
|
199
200
|
}
|
|
200
|
-
const
|
|
201
|
+
const r = Y[n];
|
|
201
202
|
let s = y.filter;
|
|
202
203
|
(typeof t.filter == "function" || A(t.filter)) && (s = t.filter);
|
|
203
204
|
let o;
|
|
204
|
-
if (t.arrayFormat && t.arrayFormat in
|
|
205
|
+
if (t.arrayFormat && t.arrayFormat in Ae ? o = t.arrayFormat : "indices" in t ? o = t.indices ? "indices" : "repeat" : o = y.arrayFormat, "commaRoundTrip" in t && typeof t.commaRoundTrip != "boolean")
|
|
205
206
|
throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
|
|
206
207
|
const i = typeof t.allowDots > "u" ? t.encodeDotInKeys ? !0 : y.allowDots : !!t.allowDots;
|
|
207
208
|
return {
|
|
@@ -219,8 +220,8 @@ function lt(t = y) {
|
|
|
219
220
|
encoder: typeof t.encoder == "function" ? t.encoder : y.encoder,
|
|
220
221
|
encodeValuesOnly: typeof t.encodeValuesOnly == "boolean" ? t.encodeValuesOnly : y.encodeValuesOnly,
|
|
221
222
|
filter: s,
|
|
222
|
-
format:
|
|
223
|
-
formatter:
|
|
223
|
+
format: n,
|
|
224
|
+
formatter: r,
|
|
224
225
|
serializeDate: typeof t.serializeDate == "function" ? t.serializeDate : y.serializeDate,
|
|
225
226
|
skipNulls: typeof t.skipNulls == "boolean" ? t.skipNulls : y.skipNulls,
|
|
226
227
|
// @ts-ignore
|
|
@@ -228,249 +229,175 @@ function lt(t = y) {
|
|
|
228
229
|
strictNullHandling: typeof t.strictNullHandling == "boolean" ? t.strictNullHandling : y.strictNullHandling
|
|
229
230
|
};
|
|
230
231
|
}
|
|
231
|
-
function
|
|
232
|
-
let
|
|
233
|
-
const
|
|
232
|
+
function lt(t, e = {}) {
|
|
233
|
+
let n = t;
|
|
234
|
+
const r = ut(e);
|
|
234
235
|
let s, o;
|
|
235
|
-
typeof
|
|
236
|
+
typeof r.filter == "function" ? (o = r.filter, n = o("", n)) : A(r.filter) && (o = r.filter, s = o);
|
|
236
237
|
const i = [];
|
|
237
|
-
if (typeof
|
|
238
|
+
if (typeof n != "object" || n === null)
|
|
238
239
|
return "";
|
|
239
|
-
const l =
|
|
240
|
-
s || (s = Object.keys(
|
|
240
|
+
const l = Ae[r.arrayFormat], c = l === "comma" && r.commaRoundTrip;
|
|
241
|
+
s || (s = Object.keys(n)), r.sort && s.sort(r.sort);
|
|
241
242
|
const u = /* @__PURE__ */ new WeakMap();
|
|
242
243
|
for (let h = 0; h < s.length; ++h) {
|
|
243
244
|
const m = s[h];
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
r.skipNulls && n[m] === null || Se(i, Re(
|
|
246
|
+
n[m],
|
|
246
247
|
m,
|
|
247
248
|
// @ts-expect-error
|
|
248
249
|
l,
|
|
249
250
|
c,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
251
|
+
r.allowEmptyArrays,
|
|
252
|
+
r.strictNullHandling,
|
|
253
|
+
r.skipNulls,
|
|
254
|
+
r.encodeDotInKeys,
|
|
255
|
+
r.encode ? r.encoder : null,
|
|
256
|
+
r.filter,
|
|
257
|
+
r.sort,
|
|
258
|
+
r.allowDots,
|
|
259
|
+
r.serializeDate,
|
|
260
|
+
r.format,
|
|
261
|
+
r.formatter,
|
|
262
|
+
r.encodeValuesOnly,
|
|
263
|
+
r.charset,
|
|
263
264
|
u
|
|
264
265
|
));
|
|
265
266
|
}
|
|
266
|
-
const p = i.join(
|
|
267
|
-
let a =
|
|
268
|
-
return
|
|
267
|
+
const p = i.join(r.delimiter);
|
|
268
|
+
let a = r.addQueryPrefix === !0 ? "?" : "";
|
|
269
|
+
return r.charsetSentinel && (r.charset === "iso-8859-1" ? a += "utf8=%26%2310003%3B&" : a += "utf8=%E2%9C%93&"), p.length > 0 ? a + p : "";
|
|
269
270
|
}
|
|
270
271
|
const T = "1.9.1";
|
|
271
272
|
class P extends Error {
|
|
272
273
|
}
|
|
273
274
|
class w extends P {
|
|
274
|
-
constructor(e,
|
|
275
|
-
super(`${w.makeMessage(e,
|
|
275
|
+
constructor(e, n, r, s) {
|
|
276
|
+
super(`${w.makeMessage(e, n, r)}`), this.status = e, this.headers = s, this.error = n;
|
|
276
277
|
}
|
|
277
|
-
static makeMessage(e,
|
|
278
|
-
const s =
|
|
278
|
+
static makeMessage(e, n, r) {
|
|
279
|
+
const s = n?.message ? typeof n.message == "string" ? n.message : JSON.stringify(n.message) : n ? JSON.stringify(n) : r;
|
|
279
280
|
return e && s ? `${e} ${s}` : e ? `${e} status code (no body)` : s || "(no status code or body)";
|
|
280
281
|
}
|
|
281
|
-
static generate(e,
|
|
282
|
+
static generate(e, n, r, s) {
|
|
282
283
|
if (!e || !s)
|
|
283
|
-
return new
|
|
284
|
-
const o =
|
|
285
|
-
return e === 400 ? new
|
|
284
|
+
return new F({ message: r, cause: ee(n) });
|
|
285
|
+
const o = n;
|
|
286
|
+
return e === 400 ? new Pe(e, o, r, s) : e === 401 ? new ke(e, o, r, s) : e === 403 ? new Te(e, o, r, s) : e === 404 ? new Ce(e, o, r, s) : e === 409 ? new ve(e, o, r, s) : e === 422 ? new Ie(e, o, r, s) : e === 429 ? new Le(e, o, r, s) : e >= 500 ? new Oe(e, o, r, s) : new w(e, o, r, s);
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
|
-
class
|
|
289
|
+
class Z extends w {
|
|
289
290
|
constructor({ message: e } = {}) {
|
|
290
291
|
super(void 0, void 0, e || "Request was aborted.", void 0);
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
|
-
class
|
|
294
|
-
constructor({ message: e, cause:
|
|
295
|
-
super(void 0, void 0, e || "Connection error.", void 0),
|
|
294
|
+
class F extends w {
|
|
295
|
+
constructor({ message: e, cause: n }) {
|
|
296
|
+
super(void 0, void 0, e || "Connection error.", void 0), n && (this.cause = n);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
|
-
class
|
|
299
|
+
class Ee extends F {
|
|
299
300
|
constructor({ message: e } = {}) {
|
|
300
301
|
super({ message: e ?? "Request timed out." });
|
|
301
302
|
}
|
|
302
303
|
}
|
|
304
|
+
class Pe extends w {
|
|
305
|
+
}
|
|
303
306
|
class ke extends w {
|
|
304
307
|
}
|
|
305
308
|
class Te extends w {
|
|
306
309
|
}
|
|
307
|
-
class ve extends w {
|
|
308
|
-
}
|
|
309
310
|
class Ce extends w {
|
|
310
311
|
}
|
|
311
|
-
class
|
|
312
|
+
class ve extends w {
|
|
312
313
|
}
|
|
313
|
-
class
|
|
314
|
+
class Ie extends w {
|
|
314
315
|
}
|
|
315
316
|
class Le extends w {
|
|
316
317
|
}
|
|
317
318
|
class Oe extends w {
|
|
318
319
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (me)
|
|
322
|
-
throw new Error(`you must \`import '@arcadeai/arcadejs/shims/${t.kind}'\` before importing anything else from @arcadeai/arcadejs`);
|
|
323
|
-
if (D)
|
|
324
|
-
throw new Error(`can't \`import '@arcadeai/arcadejs/shims/${t.kind}'\` after \`import '@arcadeai/arcadejs/shims/${D}'\``);
|
|
325
|
-
me = e.auto, D = t.kind, Fe = t.fetch, t.Request, t.Response, t.Headers, t.FormData, t.Blob, te = t.File, t.ReadableStream, t.getMultipartRequestOptions, $e = t.getDefaultAgent, je = t.fileFromPath, t.isFsReadStream;
|
|
326
|
-
}
|
|
327
|
-
class dt {
|
|
328
|
-
constructor(e) {
|
|
329
|
-
this.body = e;
|
|
330
|
-
}
|
|
331
|
-
get [Symbol.toStringTag]() {
|
|
332
|
-
return "MultipartBody";
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function Be({ manuallyImported: t } = {}) {
|
|
336
|
-
const e = t ? "You may need to use polyfills" : "Add one of these imports before your first `import … from '@arcadeai/arcadejs'`:\n- `import '@arcadeai/arcadejs/shims/node'` (if you're running on Node)\n- `import '@arcadeai/arcadejs/shims/web'` (otherwise)\n";
|
|
337
|
-
let r, n, s, o;
|
|
338
|
-
try {
|
|
339
|
-
r = fetch, n = Request, s = Response, o = Headers;
|
|
340
|
-
} catch (i) {
|
|
341
|
-
throw new Error(`this environment is missing the following Web Fetch API type: ${i.message}. ${e}`);
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
kind: "web",
|
|
345
|
-
fetch: r,
|
|
346
|
-
Request: n,
|
|
347
|
-
Response: s,
|
|
348
|
-
Headers: o,
|
|
349
|
-
FormData: (
|
|
350
|
-
// @ts-ignore
|
|
351
|
-
typeof FormData < "u" ? FormData : class {
|
|
352
|
-
// @ts-ignore
|
|
353
|
-
constructor() {
|
|
354
|
-
throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${e}`);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
),
|
|
358
|
-
Blob: typeof Blob < "u" ? Blob : class {
|
|
359
|
-
constructor() {
|
|
360
|
-
throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${e}`);
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
File: (
|
|
364
|
-
// @ts-ignore
|
|
365
|
-
typeof File < "u" ? File : class {
|
|
366
|
-
// @ts-ignore
|
|
367
|
-
constructor() {
|
|
368
|
-
throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${e}`);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
),
|
|
372
|
-
ReadableStream: (
|
|
373
|
-
// @ts-ignore
|
|
374
|
-
typeof ReadableStream < "u" ? ReadableStream : class {
|
|
375
|
-
// @ts-ignore
|
|
376
|
-
constructor() {
|
|
377
|
-
throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${e}`);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
),
|
|
381
|
-
getMultipartRequestOptions: async (i, l) => ({
|
|
382
|
-
...l,
|
|
383
|
-
body: new dt(i)
|
|
384
|
-
}),
|
|
385
|
-
getDefaultAgent: (i) => {
|
|
386
|
-
},
|
|
387
|
-
fileFromPath: () => {
|
|
388
|
-
throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/ArcadeAI/arcade-js#file-uploads");
|
|
389
|
-
},
|
|
390
|
-
isFsReadStream: (i) => !1
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
const Me = () => {
|
|
394
|
-
D || Ue(Be(), { auto: !0 });
|
|
320
|
+
const De = () => {
|
|
321
|
+
_e || Qe(Ge(), { auto: !0 });
|
|
395
322
|
};
|
|
396
|
-
|
|
397
|
-
const
|
|
398
|
-
async function
|
|
399
|
-
if (t = await t,
|
|
323
|
+
De();
|
|
324
|
+
const ft = (t) => t != null && typeof t == "object" && typeof t.url == "string" && typeof t.blob == "function", dt = (t) => t != null && typeof t == "object" && typeof t.name == "string" && typeof t.lastModified == "number" && q(t), q = (t) => t != null && typeof t == "object" && typeof t.size == "number" && typeof t.type == "string" && typeof t.text == "function" && typeof t.slice == "function" && typeof t.arrayBuffer == "function";
|
|
325
|
+
async function ht(t, e, n) {
|
|
326
|
+
if (t = await t, dt(t))
|
|
400
327
|
return t;
|
|
401
|
-
if (
|
|
328
|
+
if (ft(t)) {
|
|
402
329
|
const s = await t.blob();
|
|
403
330
|
e || (e = new URL(t.url).pathname.split(/[\\/]/).pop() ?? "unknown_file");
|
|
404
|
-
const o =
|
|
405
|
-
return new
|
|
331
|
+
const o = q(s) ? [await s.arrayBuffer()] : [s];
|
|
332
|
+
return new de(o, e, n);
|
|
406
333
|
}
|
|
407
|
-
const
|
|
408
|
-
if (e || (e =
|
|
409
|
-
const s =
|
|
410
|
-
typeof s == "string" && (
|
|
334
|
+
const r = await pt(t);
|
|
335
|
+
if (e || (e = mt(t) ?? "unknown_file"), !n?.type) {
|
|
336
|
+
const s = r[0]?.type;
|
|
337
|
+
typeof s == "string" && (n = { ...n, type: s });
|
|
411
338
|
}
|
|
412
|
-
return new
|
|
339
|
+
return new de(r, e, n);
|
|
413
340
|
}
|
|
414
|
-
async function
|
|
341
|
+
async function pt(t) {
|
|
415
342
|
let e = [];
|
|
416
343
|
if (typeof t == "string" || ArrayBuffer.isView(t) || // includes Uint8Array, Buffer, etc.
|
|
417
344
|
t instanceof ArrayBuffer)
|
|
418
345
|
e.push(t);
|
|
419
|
-
else if (
|
|
346
|
+
else if (q(t))
|
|
420
347
|
e.push(await t.arrayBuffer());
|
|
421
|
-
else if (
|
|
422
|
-
for await (const
|
|
423
|
-
e.push(
|
|
348
|
+
else if (gt(t))
|
|
349
|
+
for await (const n of t)
|
|
350
|
+
e.push(n);
|
|
424
351
|
else
|
|
425
|
-
throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${
|
|
352
|
+
throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${yt(t)}`);
|
|
426
353
|
return e;
|
|
427
354
|
}
|
|
428
|
-
function
|
|
429
|
-
return `[${Object.getOwnPropertyNames(t).map((
|
|
355
|
+
function yt(t) {
|
|
356
|
+
return `[${Object.getOwnPropertyNames(t).map((n) => `"${n}"`).join(", ")}]`;
|
|
430
357
|
}
|
|
431
|
-
function
|
|
432
|
-
return
|
|
433
|
-
|
|
358
|
+
function mt(t) {
|
|
359
|
+
return Q(t.name) || Q(t.filename) || // For fs.ReadStream
|
|
360
|
+
Q(t.path)?.split(/[\\/]/).pop();
|
|
434
361
|
}
|
|
435
|
-
const
|
|
362
|
+
const Q = (t) => {
|
|
436
363
|
if (typeof t == "string")
|
|
437
364
|
return t;
|
|
438
365
|
if (typeof Buffer < "u" && t instanceof Buffer)
|
|
439
366
|
return String(t);
|
|
440
|
-
},
|
|
441
|
-
var
|
|
442
|
-
if (
|
|
443
|
-
if (
|
|
367
|
+
}, gt = (t) => t != null && typeof t == "object" && typeof t[Symbol.asyncIterator] == "function", ye = (t) => t && typeof t == "object" && t.body && t[Symbol.toStringTag] === "MultipartBody";
|
|
368
|
+
var Ue = function(t, e, n, r, s) {
|
|
369
|
+
if (r === "m") throw new TypeError("Private method is not writable");
|
|
370
|
+
if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
|
|
444
371
|
if (typeof e == "function" ? t !== e || !s : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
445
|
-
return
|
|
446
|
-
},
|
|
447
|
-
if (
|
|
448
|
-
if (typeof e == "function" ? t !== e || !
|
|
449
|
-
return
|
|
450
|
-
}, M,
|
|
451
|
-
|
|
452
|
-
async function
|
|
372
|
+
return r === "a" ? s.call(t, n) : s ? s.value = n : e.set(t, n), n;
|
|
373
|
+
}, $e = function(t, e, n, r) {
|
|
374
|
+
if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
|
|
375
|
+
if (typeof e == "function" ? t !== e || !r : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
376
|
+
return n === "m" ? r : n === "a" ? r.call(t) : r ? r.value : e.get(t);
|
|
377
|
+
}, M, j;
|
|
378
|
+
De();
|
|
379
|
+
async function je(t) {
|
|
453
380
|
const { response: e } = t;
|
|
454
381
|
if (e.status === 204)
|
|
455
382
|
return null;
|
|
456
383
|
if (t.options.__binaryResponse)
|
|
457
384
|
return e;
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
385
|
+
const r = e.headers.get("content-type")?.split(";")[0]?.trim();
|
|
386
|
+
if (r?.includes("application/json") || r?.endsWith("+json")) {
|
|
460
387
|
const i = await e.json();
|
|
461
388
|
return L("response", e.status, e.url, e.headers, i), i;
|
|
462
389
|
}
|
|
463
390
|
const o = await e.text();
|
|
464
391
|
return L("response", e.status, e.url, e.headers, o), o;
|
|
465
392
|
}
|
|
466
|
-
class
|
|
467
|
-
constructor(e,
|
|
468
|
-
super((
|
|
469
|
-
|
|
470
|
-
}), this.responsePromise = e, this.parseResponse =
|
|
393
|
+
class B extends Promise {
|
|
394
|
+
constructor(e, n = je) {
|
|
395
|
+
super((r) => {
|
|
396
|
+
r(null);
|
|
397
|
+
}), this.responsePromise = e, this.parseResponse = n;
|
|
471
398
|
}
|
|
472
399
|
_thenUnwrap(e) {
|
|
473
|
-
return new
|
|
400
|
+
return new B(this.responsePromise, async (n) => e(await this.parseResponse(n), n));
|
|
474
401
|
}
|
|
475
402
|
/**
|
|
476
403
|
* Gets the raw `Response` instance instead of parsing the response
|
|
@@ -502,14 +429,14 @@ class H extends Promise {
|
|
|
502
429
|
* - `import '@arcadeai/arcadejs/shims/web'` (otherwise)
|
|
503
430
|
*/
|
|
504
431
|
async withResponse() {
|
|
505
|
-
const [e,
|
|
506
|
-
return { data: e, response:
|
|
432
|
+
const [e, n] = await Promise.all([this.parse(), this.asResponse()]);
|
|
433
|
+
return { data: e, response: n };
|
|
507
434
|
}
|
|
508
435
|
parse() {
|
|
509
436
|
return this.parsedPromise || (this.parsedPromise = this.responsePromise.then(this.parseResponse)), this.parsedPromise;
|
|
510
437
|
}
|
|
511
|
-
then(e,
|
|
512
|
-
return this.parse().then(e,
|
|
438
|
+
then(e, n) {
|
|
439
|
+
return this.parse().then(e, n);
|
|
513
440
|
}
|
|
514
441
|
catch(e) {
|
|
515
442
|
return this.parse().catch(e);
|
|
@@ -518,17 +445,17 @@ class H extends Promise {
|
|
|
518
445
|
return this.parse().finally(e);
|
|
519
446
|
}
|
|
520
447
|
}
|
|
521
|
-
class
|
|
448
|
+
class wt {
|
|
522
449
|
constructor({
|
|
523
450
|
baseURL: e,
|
|
524
|
-
baseURLOverridden:
|
|
525
|
-
maxRetries:
|
|
451
|
+
baseURLOverridden: n,
|
|
452
|
+
maxRetries: r = 2,
|
|
526
453
|
timeout: s = 6e4,
|
|
527
454
|
// 1 minute
|
|
528
455
|
httpAgent: o,
|
|
529
456
|
fetch: i
|
|
530
457
|
}) {
|
|
531
|
-
M.set(this, void 0), this.baseURL = e,
|
|
458
|
+
M.set(this, void 0), this.baseURL = e, Ue(this, M, n, "f"), this.maxRetries = G("maxRetries", r), this.timeout = G("timeout", s), this.httpAgent = o, this.fetch = i ?? Je;
|
|
532
459
|
}
|
|
533
460
|
authHeaders(e) {
|
|
534
461
|
return {};
|
|
@@ -546,41 +473,41 @@ class xt {
|
|
|
546
473
|
Accept: "application/json",
|
|
547
474
|
...["head", "get"].includes(e.method) ? {} : { "Content-Type": "application/json" },
|
|
548
475
|
"User-Agent": this.getUserAgent(),
|
|
549
|
-
...
|
|
476
|
+
...Et(),
|
|
550
477
|
...this.authHeaders(e)
|
|
551
478
|
};
|
|
552
479
|
}
|
|
553
480
|
/**
|
|
554
481
|
* Override this to add your own headers validation:
|
|
555
482
|
*/
|
|
556
|
-
validateHeaders(e,
|
|
483
|
+
validateHeaders(e, n) {
|
|
557
484
|
}
|
|
558
485
|
defaultIdempotencyKey() {
|
|
559
|
-
return `stainless-node-retry-${
|
|
486
|
+
return `stainless-node-retry-${vt()}`;
|
|
560
487
|
}
|
|
561
|
-
get(e,
|
|
562
|
-
return this.methodRequest("get", e,
|
|
488
|
+
get(e, n) {
|
|
489
|
+
return this.methodRequest("get", e, n);
|
|
563
490
|
}
|
|
564
|
-
post(e,
|
|
565
|
-
return this.methodRequest("post", e,
|
|
491
|
+
post(e, n) {
|
|
492
|
+
return this.methodRequest("post", e, n);
|
|
566
493
|
}
|
|
567
|
-
patch(e,
|
|
568
|
-
return this.methodRequest("patch", e,
|
|
494
|
+
patch(e, n) {
|
|
495
|
+
return this.methodRequest("patch", e, n);
|
|
569
496
|
}
|
|
570
|
-
put(e,
|
|
571
|
-
return this.methodRequest("put", e,
|
|
497
|
+
put(e, n) {
|
|
498
|
+
return this.methodRequest("put", e, n);
|
|
572
499
|
}
|
|
573
|
-
delete(e,
|
|
574
|
-
return this.methodRequest("delete", e,
|
|
500
|
+
delete(e, n) {
|
|
501
|
+
return this.methodRequest("delete", e, n);
|
|
575
502
|
}
|
|
576
|
-
methodRequest(e,
|
|
577
|
-
return this.request(Promise.resolve(
|
|
578
|
-
const o = s &&
|
|
579
|
-
return { method: e, path:
|
|
503
|
+
methodRequest(e, n, r) {
|
|
504
|
+
return this.request(Promise.resolve(r).then(async (s) => {
|
|
505
|
+
const o = s && q(s?.body) ? new DataView(await s.body.arrayBuffer()) : s?.body instanceof DataView ? s.body : s?.body instanceof ArrayBuffer ? new DataView(s.body) : s && ArrayBuffer.isView(s?.body) ? new DataView(s.body.buffer) : s?.body;
|
|
506
|
+
return { method: e, path: n, ...s, body: o };
|
|
580
507
|
}));
|
|
581
508
|
}
|
|
582
|
-
getAPIList(e,
|
|
583
|
-
return this.requestAPIList(
|
|
509
|
+
getAPIList(e, n, r) {
|
|
510
|
+
return this.requestAPIList(n, { method: "get", path: e, ...r });
|
|
584
511
|
}
|
|
585
512
|
calculateContentLength(e) {
|
|
586
513
|
if (typeof e == "string") {
|
|
@@ -592,27 +519,27 @@ class xt {
|
|
|
592
519
|
return e.byteLength.toString();
|
|
593
520
|
return null;
|
|
594
521
|
}
|
|
595
|
-
async buildRequest(e, { retryCount:
|
|
596
|
-
const
|
|
597
|
-
"timeout" in
|
|
598
|
-
const h =
|
|
522
|
+
async buildRequest(e, { retryCount: n = 0 } = {}) {
|
|
523
|
+
const r = { ...e }, { method: s, path: o, query: i, defaultBaseURL: l, headers: c = {} } = r, u = ArrayBuffer.isView(r.body) || r.__binaryRequest && typeof r.body == "string" ? r.body : ye(r.body) ? r.body.body : r.body ? JSON.stringify(r.body, null, 2) : null, p = this.calculateContentLength(u), a = this.buildURL(o, i, l);
|
|
524
|
+
"timeout" in r && G("timeout", r.timeout), r.timeout = r.timeout ?? this.timeout;
|
|
525
|
+
const h = r.httpAgent ?? this.httpAgent ?? Ye(a), m = r.timeout + 1e3;
|
|
599
526
|
typeof h?.options?.timeout == "number" && m > (h.options.timeout ?? 0) && (h.options.timeout = m), this.idempotencyHeader && s !== "get" && (e.idempotencyKey || (e.idempotencyKey = this.defaultIdempotencyKey()), c[this.idempotencyHeader] = e.idempotencyKey);
|
|
600
|
-
const
|
|
527
|
+
const b = this.buildHeaders({ options: r, headers: c, contentLength: p, retryCount: n });
|
|
601
528
|
return { req: {
|
|
602
529
|
method: s,
|
|
603
530
|
...u && { body: u },
|
|
604
|
-
headers:
|
|
531
|
+
headers: b,
|
|
605
532
|
...h && { agent: h },
|
|
606
533
|
// @ts-ignore node-fetch uses a custom AbortSignal type that is
|
|
607
534
|
// not compatible with standard web types
|
|
608
|
-
signal:
|
|
609
|
-
}, url: a, timeout:
|
|
535
|
+
signal: r.signal ?? null
|
|
536
|
+
}, url: a, timeout: r.timeout };
|
|
610
537
|
}
|
|
611
|
-
buildHeaders({ options: e, headers:
|
|
538
|
+
buildHeaders({ options: e, headers: n, contentLength: r, retryCount: s }) {
|
|
612
539
|
const o = {};
|
|
613
|
-
|
|
540
|
+
r && (o["content-length"] = r);
|
|
614
541
|
const i = this.defaultHeaders(e);
|
|
615
|
-
return
|
|
542
|
+
return be(o, i), be(o, n), ye(e.body) && _e !== "node" && delete o["content-type"], N(i, "x-stainless-retry-count") === void 0 && N(n, "x-stainless-retry-count") === void 0 && (o["x-stainless-retry-count"] = String(s)), N(i, "x-stainless-timeout") === void 0 && N(n, "x-stainless-timeout") === void 0 && e.timeout && (o["x-stainless-timeout"] = String(Math.trunc(e.timeout / 1e3))), this.validateHeaders(o, n), o;
|
|
616
543
|
}
|
|
617
544
|
/**
|
|
618
545
|
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
@@ -625,65 +552,65 @@ class xt {
|
|
|
625
552
|
* This is useful for cases where you want to add certain headers based off of
|
|
626
553
|
* the request properties, e.g. `method` or `url`.
|
|
627
554
|
*/
|
|
628
|
-
async prepareRequest(e, { url:
|
|
555
|
+
async prepareRequest(e, { url: n, options: r }) {
|
|
629
556
|
}
|
|
630
557
|
parseHeaders(e) {
|
|
631
|
-
return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((
|
|
558
|
+
return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((n) => [...n])) : { ...e } : {};
|
|
632
559
|
}
|
|
633
|
-
makeStatusError(e,
|
|
634
|
-
return w.generate(e,
|
|
560
|
+
makeStatusError(e, n, r, s) {
|
|
561
|
+
return w.generate(e, n, r, s);
|
|
635
562
|
}
|
|
636
|
-
request(e,
|
|
637
|
-
return new
|
|
563
|
+
request(e, n = null) {
|
|
564
|
+
return new B(this.makeRequest(e, n));
|
|
638
565
|
}
|
|
639
|
-
async makeRequest(e,
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
const { req: o, url: i, timeout: l } = await this.buildRequest(
|
|
643
|
-
retryCount: s -
|
|
566
|
+
async makeRequest(e, n) {
|
|
567
|
+
const r = await e, s = r.maxRetries ?? this.maxRetries;
|
|
568
|
+
n == null && (n = s), await this.prepareOptions(r);
|
|
569
|
+
const { req: o, url: i, timeout: l } = await this.buildRequest(r, {
|
|
570
|
+
retryCount: s - n
|
|
644
571
|
});
|
|
645
|
-
if (await this.prepareRequest(o, { url: i, options:
|
|
646
|
-
throw new
|
|
647
|
-
const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(
|
|
572
|
+
if (await this.prepareRequest(o, { url: i, options: r }), L("request", i, r, o.headers), r.signal?.aborted)
|
|
573
|
+
throw new Z();
|
|
574
|
+
const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(ee);
|
|
648
575
|
if (u instanceof Error) {
|
|
649
|
-
if (
|
|
650
|
-
throw new
|
|
651
|
-
if (
|
|
652
|
-
return this.retryRequest(
|
|
653
|
-
throw u.name === "AbortError" ? new
|
|
576
|
+
if (r.signal?.aborted)
|
|
577
|
+
throw new Z();
|
|
578
|
+
if (n)
|
|
579
|
+
return this.retryRequest(r, n);
|
|
580
|
+
throw u.name === "AbortError" ? new Ee() : new F({ cause: u });
|
|
654
581
|
}
|
|
655
|
-
const p =
|
|
582
|
+
const p = _t(u.headers);
|
|
656
583
|
if (!u.ok) {
|
|
657
|
-
if (
|
|
658
|
-
const
|
|
659
|
-
return L(`response (error; ${
|
|
584
|
+
if (n && this.shouldRetry(u)) {
|
|
585
|
+
const S = `retrying, ${n} attempts remaining`;
|
|
586
|
+
return L(`response (error; ${S})`, u.status, i, p), this.retryRequest(r, n, p);
|
|
660
587
|
}
|
|
661
|
-
const a = await u.text().catch((
|
|
662
|
-
throw L(`response (error; ${
|
|
588
|
+
const a = await u.text().catch((S) => ee(S).message), h = Pt(a), m = h ? void 0 : a;
|
|
589
|
+
throw L(`response (error; ${n ? "(error; no more retries left)" : "(error; not retryable)"})`, u.status, i, p, m), this.makeStatusError(u.status, h, m, p);
|
|
663
590
|
}
|
|
664
|
-
return { response: u, options:
|
|
591
|
+
return { response: u, options: r, controller: c };
|
|
665
592
|
}
|
|
666
|
-
requestAPIList(e,
|
|
667
|
-
const
|
|
668
|
-
return new
|
|
593
|
+
requestAPIList(e, n) {
|
|
594
|
+
const r = this.makeRequest(n, null);
|
|
595
|
+
return new bt(this, r, e);
|
|
669
596
|
}
|
|
670
|
-
buildURL(e,
|
|
671
|
-
const s =
|
|
672
|
-
return
|
|
597
|
+
buildURL(e, n, r) {
|
|
598
|
+
const s = !$e(this, M, "f") && r || this.baseURL, o = Tt(e) ? new URL(e) : new URL(s + (s.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), i = this.defaultQuery();
|
|
599
|
+
return Ne(i) || (n = { ...i, ...n }), typeof n == "object" && n && !Array.isArray(n) && (o.search = this.stringifyQuery(n)), o.toString();
|
|
673
600
|
}
|
|
674
601
|
stringifyQuery(e) {
|
|
675
|
-
return Object.entries(e).filter(([
|
|
676
|
-
if (typeof
|
|
677
|
-
return `${encodeURIComponent(
|
|
678
|
-
if (
|
|
679
|
-
return `${encodeURIComponent(
|
|
680
|
-
throw new P(`Cannot stringify type ${typeof
|
|
602
|
+
return Object.entries(e).filter(([n, r]) => typeof r < "u").map(([n, r]) => {
|
|
603
|
+
if (typeof r == "string" || typeof r == "number" || typeof r == "boolean")
|
|
604
|
+
return `${encodeURIComponent(n)}=${encodeURIComponent(r)}`;
|
|
605
|
+
if (r === null)
|
|
606
|
+
return `${encodeURIComponent(n)}=`;
|
|
607
|
+
throw new P(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
681
608
|
}).join("&");
|
|
682
609
|
}
|
|
683
|
-
async fetchWithTimeout(e,
|
|
684
|
-
const { signal: o, ...i } =
|
|
610
|
+
async fetchWithTimeout(e, n, r, s) {
|
|
611
|
+
const { signal: o, ...i } = n || {};
|
|
685
612
|
o && o.addEventListener("abort", () => s.abort());
|
|
686
|
-
const l = setTimeout(() => s.abort(),
|
|
613
|
+
const l = setTimeout(() => s.abort(), r), c = {
|
|
687
614
|
signal: s.signal,
|
|
688
615
|
...i
|
|
689
616
|
};
|
|
@@ -693,29 +620,29 @@ class xt {
|
|
|
693
620
|
});
|
|
694
621
|
}
|
|
695
622
|
shouldRetry(e) {
|
|
696
|
-
const
|
|
697
|
-
return
|
|
623
|
+
const n = e.headers.get("x-should-retry");
|
|
624
|
+
return n === "true" ? !0 : n === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
|
|
698
625
|
}
|
|
699
|
-
async retryRequest(e,
|
|
626
|
+
async retryRequest(e, n, r) {
|
|
700
627
|
let s;
|
|
701
|
-
const o =
|
|
628
|
+
const o = r?.["retry-after-ms"];
|
|
702
629
|
if (o) {
|
|
703
630
|
const l = parseFloat(o);
|
|
704
631
|
Number.isNaN(l) || (s = l);
|
|
705
632
|
}
|
|
706
|
-
const i =
|
|
633
|
+
const i = r?.["retry-after"];
|
|
707
634
|
if (i && !s) {
|
|
708
635
|
const l = parseFloat(i);
|
|
709
636
|
Number.isNaN(l) ? s = Date.parse(i) - Date.now() : s = l * 1e3;
|
|
710
637
|
}
|
|
711
638
|
if (!(s && 0 <= s && s < 60 * 1e3)) {
|
|
712
639
|
const l = e.maxRetries ?? this.maxRetries;
|
|
713
|
-
s = this.calculateDefaultRetryTimeoutMillis(
|
|
640
|
+
s = this.calculateDefaultRetryTimeoutMillis(n, l);
|
|
714
641
|
}
|
|
715
|
-
return await
|
|
642
|
+
return await Ct(s), this.makeRequest(e, n - 1);
|
|
716
643
|
}
|
|
717
|
-
calculateDefaultRetryTimeoutMillis(e,
|
|
718
|
-
const o =
|
|
644
|
+
calculateDefaultRetryTimeoutMillis(e, n) {
|
|
645
|
+
const o = n - e, i = Math.min(0.5 * Math.pow(2, o), 8), l = 1 - Math.random() * 0.25;
|
|
719
646
|
return i * l * 1e3;
|
|
720
647
|
}
|
|
721
648
|
getUserAgent() {
|
|
@@ -723,9 +650,9 @@ class xt {
|
|
|
723
650
|
}
|
|
724
651
|
}
|
|
725
652
|
M = /* @__PURE__ */ new WeakMap();
|
|
726
|
-
class
|
|
727
|
-
constructor(e,
|
|
728
|
-
|
|
653
|
+
class xt {
|
|
654
|
+
constructor(e, n, r, s) {
|
|
655
|
+
j.set(this, void 0), Ue(this, j, e, "f"), this.options = s, this.response = n, this.body = r;
|
|
729
656
|
}
|
|
730
657
|
hasNextPage() {
|
|
731
658
|
return this.getPaginatedItems().length ? this.nextPageInfo() != null : !1;
|
|
@@ -734,31 +661,31 @@ class _t {
|
|
|
734
661
|
const e = this.nextPageInfo();
|
|
735
662
|
if (!e)
|
|
736
663
|
throw new P("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
|
|
737
|
-
const
|
|
738
|
-
if ("params" in e && typeof
|
|
739
|
-
|
|
664
|
+
const n = { ...this.options };
|
|
665
|
+
if ("params" in e && typeof n.query == "object")
|
|
666
|
+
n.query = { ...n.query, ...e.params };
|
|
740
667
|
else if ("url" in e) {
|
|
741
|
-
const
|
|
742
|
-
for (const [s, o] of
|
|
668
|
+
const r = [...Object.entries(n.query || {}), ...e.url.searchParams.entries()];
|
|
669
|
+
for (const [s, o] of r)
|
|
743
670
|
e.url.searchParams.set(s, o);
|
|
744
|
-
|
|
671
|
+
n.query = void 0, n.path = e.url.toString();
|
|
745
672
|
}
|
|
746
|
-
return await
|
|
673
|
+
return await $e(this, j, "f").requestAPIList(this.constructor, n);
|
|
747
674
|
}
|
|
748
675
|
async *iterPages() {
|
|
749
676
|
let e = this;
|
|
750
677
|
for (yield e; e.hasNextPage(); )
|
|
751
678
|
e = await e.getNextPage(), yield e;
|
|
752
679
|
}
|
|
753
|
-
async *[(
|
|
680
|
+
async *[(j = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
754
681
|
for await (const e of this.iterPages())
|
|
755
|
-
for (const
|
|
756
|
-
yield
|
|
682
|
+
for (const n of e.getPaginatedItems())
|
|
683
|
+
yield n;
|
|
757
684
|
}
|
|
758
685
|
}
|
|
759
|
-
class
|
|
760
|
-
constructor(e,
|
|
761
|
-
super(
|
|
686
|
+
class bt extends B {
|
|
687
|
+
constructor(e, n, r) {
|
|
688
|
+
super(n, async (s) => new r(e, s.response, await je(s), s.options));
|
|
762
689
|
}
|
|
763
690
|
/**
|
|
764
691
|
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
@@ -769,19 +696,19 @@ class At extends H {
|
|
|
769
696
|
*/
|
|
770
697
|
async *[Symbol.asyncIterator]() {
|
|
771
698
|
const e = await this;
|
|
772
|
-
for await (const
|
|
773
|
-
yield
|
|
699
|
+
for await (const n of e)
|
|
700
|
+
yield n;
|
|
774
701
|
}
|
|
775
702
|
}
|
|
776
|
-
const
|
|
703
|
+
const _t = (t) => new Proxy(Object.fromEntries(
|
|
777
704
|
// @ts-ignore
|
|
778
705
|
t.entries()
|
|
779
706
|
), {
|
|
780
|
-
get(e,
|
|
781
|
-
const
|
|
782
|
-
return e[
|
|
707
|
+
get(e, n) {
|
|
708
|
+
const r = n.toString();
|
|
709
|
+
return e[r.toLowerCase()] || e[r];
|
|
783
710
|
}
|
|
784
|
-
}),
|
|
711
|
+
}), At = {
|
|
785
712
|
method: !0,
|
|
786
713
|
path: !0,
|
|
787
714
|
query: !0,
|
|
@@ -796,13 +723,13 @@ const Rt = (t) => new Proxy(Object.fromEntries(
|
|
|
796
723
|
idempotencyKey: !0,
|
|
797
724
|
__binaryRequest: !0,
|
|
798
725
|
__binaryResponse: !0
|
|
799
|
-
},
|
|
726
|
+
}, R = (t) => typeof t == "object" && t !== null && !Ne(t) && Object.keys(t).every((e) => Me(At, e)), St = () => {
|
|
800
727
|
if (typeof Deno < "u" && Deno.build != null)
|
|
801
728
|
return {
|
|
802
729
|
"X-Stainless-Lang": "js",
|
|
803
730
|
"X-Stainless-Package-Version": T,
|
|
804
|
-
"X-Stainless-OS":
|
|
805
|
-
"X-Stainless-Arch":
|
|
731
|
+
"X-Stainless-OS": ge(Deno.build.os),
|
|
732
|
+
"X-Stainless-Arch": me(Deno.build.arch),
|
|
806
733
|
"X-Stainless-Runtime": "deno",
|
|
807
734
|
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
|
|
808
735
|
};
|
|
@@ -819,12 +746,12 @@ const Rt = (t) => new Proxy(Object.fromEntries(
|
|
|
819
746
|
return {
|
|
820
747
|
"X-Stainless-Lang": "js",
|
|
821
748
|
"X-Stainless-Package-Version": T,
|
|
822
|
-
"X-Stainless-OS":
|
|
823
|
-
"X-Stainless-Arch":
|
|
749
|
+
"X-Stainless-OS": ge(process.platform),
|
|
750
|
+
"X-Stainless-Arch": me(process.arch),
|
|
824
751
|
"X-Stainless-Runtime": "node",
|
|
825
752
|
"X-Stainless-Runtime-Version": process.version
|
|
826
753
|
};
|
|
827
|
-
const t =
|
|
754
|
+
const t = Rt();
|
|
828
755
|
return t ? {
|
|
829
756
|
"X-Stainless-Lang": "js",
|
|
830
757
|
"X-Stainless-Package-Version": T,
|
|
@@ -841,7 +768,7 @@ const Rt = (t) => new Proxy(Object.fromEntries(
|
|
|
841
768
|
"X-Stainless-Runtime-Version": "unknown"
|
|
842
769
|
};
|
|
843
770
|
};
|
|
844
|
-
function
|
|
771
|
+
function Rt() {
|
|
845
772
|
if (typeof navigator > "u" || !navigator)
|
|
846
773
|
return null;
|
|
847
774
|
const t = [
|
|
@@ -852,30 +779,30 @@ function Pt() {
|
|
|
852
779
|
{ key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
853
780
|
{ key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
|
|
854
781
|
];
|
|
855
|
-
for (const { key: e, pattern:
|
|
856
|
-
const
|
|
857
|
-
if (
|
|
858
|
-
const s =
|
|
782
|
+
for (const { key: e, pattern: n } of t) {
|
|
783
|
+
const r = n.exec(navigator.userAgent);
|
|
784
|
+
if (r) {
|
|
785
|
+
const s = r[1] || 0, o = r[2] || 0, i = r[3] || 0;
|
|
859
786
|
return { browser: e, version: `${s}.${o}.${i}` };
|
|
860
787
|
}
|
|
861
788
|
}
|
|
862
789
|
return null;
|
|
863
790
|
}
|
|
864
|
-
const
|
|
865
|
-
let
|
|
866
|
-
const
|
|
791
|
+
const me = (t) => t === "x32" ? "x32" : t === "x86_64" || t === "x64" ? "x64" : t === "arm" ? "arm" : t === "aarch64" || t === "arm64" ? "arm64" : t ? `other:${t}` : "unknown", ge = (t) => (t = t.toLowerCase(), t.includes("ios") ? "iOS" : t === "android" ? "Android" : t === "darwin" ? "MacOS" : t === "win32" ? "Windows" : t === "freebsd" ? "FreeBSD" : t === "openbsd" ? "OpenBSD" : t === "linux" ? "Linux" : t ? `Other:${t}` : "Unknown");
|
|
792
|
+
let we;
|
|
793
|
+
const Et = () => we ?? (we = St()), Pt = (t) => {
|
|
867
794
|
try {
|
|
868
795
|
return JSON.parse(t);
|
|
869
796
|
} catch {
|
|
870
797
|
return;
|
|
871
798
|
}
|
|
872
|
-
},
|
|
799
|
+
}, kt = /^[a-z][a-z0-9+.-]*:/i, Tt = (t) => kt.test(t), Ct = (t) => new Promise((e) => setTimeout(e, t)), G = (t, e) => {
|
|
873
800
|
if (typeof e != "number" || !Number.isInteger(e))
|
|
874
801
|
throw new P(`${t} must be an integer`);
|
|
875
802
|
if (e < 0)
|
|
876
803
|
throw new P(`${t} must be a positive integer`);
|
|
877
804
|
return e;
|
|
878
|
-
},
|
|
805
|
+
}, ee = (t) => {
|
|
879
806
|
if (t instanceof Error)
|
|
880
807
|
return t;
|
|
881
808
|
if (typeof t == "object" && t !== null)
|
|
@@ -884,56 +811,56 @@ const kt = () => xe ?? (xe = Et()), Tt = (t) => {
|
|
|
884
811
|
} catch {
|
|
885
812
|
}
|
|
886
813
|
return new Error(t);
|
|
887
|
-
},
|
|
814
|
+
}, xe = (t) => {
|
|
888
815
|
if (typeof process < "u")
|
|
889
816
|
return process.env?.[t]?.trim() ?? void 0;
|
|
890
817
|
if (typeof Deno < "u")
|
|
891
818
|
return Deno.env?.get?.(t)?.trim();
|
|
892
819
|
};
|
|
893
|
-
function
|
|
820
|
+
function Ne(t) {
|
|
894
821
|
if (!t)
|
|
895
822
|
return !0;
|
|
896
823
|
for (const e in t)
|
|
897
824
|
return !1;
|
|
898
825
|
return !0;
|
|
899
826
|
}
|
|
900
|
-
function
|
|
827
|
+
function Me(t, e) {
|
|
901
828
|
return Object.prototype.hasOwnProperty.call(t, e);
|
|
902
829
|
}
|
|
903
|
-
function
|
|
904
|
-
for (const
|
|
905
|
-
if (!
|
|
830
|
+
function be(t, e) {
|
|
831
|
+
for (const n in e) {
|
|
832
|
+
if (!Me(e, n))
|
|
906
833
|
continue;
|
|
907
|
-
const
|
|
908
|
-
if (!
|
|
834
|
+
const r = n.toLowerCase();
|
|
835
|
+
if (!r)
|
|
909
836
|
continue;
|
|
910
|
-
const s = e[
|
|
911
|
-
s === null ? delete t[
|
|
837
|
+
const s = e[n];
|
|
838
|
+
s === null ? delete t[r] : s !== void 0 && (t[r] = s);
|
|
912
839
|
}
|
|
913
840
|
}
|
|
914
841
|
function L(t, ...e) {
|
|
915
842
|
typeof process < "u" && process?.env?.DEBUG === "true" && console.log(`Arcade:DEBUG:${t}`, ...e);
|
|
916
843
|
}
|
|
917
|
-
const
|
|
844
|
+
const vt = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
918
845
|
const e = Math.random() * 16 | 0;
|
|
919
846
|
return (t === "x" ? e : e & 3 | 8).toString(16);
|
|
920
|
-
}),
|
|
921
|
-
const
|
|
922
|
-
if (
|
|
923
|
-
const
|
|
924
|
-
for (const s of [e,
|
|
847
|
+
}), It = (t) => typeof t?.get == "function", N = (t, e) => {
|
|
848
|
+
const n = e.toLowerCase();
|
|
849
|
+
if (It(t)) {
|
|
850
|
+
const r = e[0]?.toUpperCase() + e.substring(1).replace(/([^\w])(\w)/g, (s, o, i) => o + i.toUpperCase());
|
|
851
|
+
for (const s of [e, n, e.toUpperCase(), r]) {
|
|
925
852
|
const o = t.get(s);
|
|
926
853
|
if (o)
|
|
927
854
|
return o;
|
|
928
855
|
}
|
|
929
856
|
}
|
|
930
|
-
for (const [
|
|
931
|
-
if (
|
|
857
|
+
for (const [r, s] of Object.entries(t))
|
|
858
|
+
if (r.toLowerCase() === n)
|
|
932
859
|
return Array.isArray(s) ? (s.length <= 1 || console.warn(`Received ${s.length} entries for the ${e} header, using the first entry.`), s[0]) : s;
|
|
933
860
|
};
|
|
934
|
-
class O extends
|
|
935
|
-
constructor(e,
|
|
936
|
-
super(e,
|
|
861
|
+
class O extends xt {
|
|
862
|
+
constructor(e, n, r, s) {
|
|
863
|
+
super(e, n, r, s), this.items = r.items || [], this.total_count = r.total_count || 0, this.offset = r.offset || 0;
|
|
937
864
|
}
|
|
938
865
|
getPaginatedItems() {
|
|
939
866
|
return this.items ?? [];
|
|
@@ -945,28 +872,28 @@ class O extends _t {
|
|
|
945
872
|
return null;
|
|
946
873
|
if ("params" in e)
|
|
947
874
|
return e.params;
|
|
948
|
-
const
|
|
949
|
-
return Object.keys(
|
|
875
|
+
const n = Object.fromEntries(e.url.searchParams);
|
|
876
|
+
return Object.keys(n).length ? n : null;
|
|
950
877
|
}
|
|
951
878
|
nextPageInfo() {
|
|
952
879
|
const e = this.offset;
|
|
953
880
|
if (!e)
|
|
954
881
|
return null;
|
|
955
|
-
const
|
|
956
|
-
return s &&
|
|
882
|
+
const n = this.getPaginatedItems().length, r = e + n, s = this.total_count;
|
|
883
|
+
return s && r < s ? { params: { offset: r } } : null;
|
|
957
884
|
}
|
|
958
885
|
}
|
|
959
|
-
class
|
|
886
|
+
class x {
|
|
960
887
|
constructor(e) {
|
|
961
888
|
this._client = e;
|
|
962
889
|
}
|
|
963
890
|
}
|
|
964
|
-
class
|
|
891
|
+
class Fe extends x {
|
|
965
892
|
/**
|
|
966
893
|
* Create a new auth provider
|
|
967
894
|
*/
|
|
968
|
-
create(e,
|
|
969
|
-
return this._client.post("/v1/admin/auth_providers", { body: e, ...
|
|
895
|
+
create(e, n) {
|
|
896
|
+
return this._client.post("/v1/admin/auth_providers", { body: e, ...n });
|
|
970
897
|
}
|
|
971
898
|
/**
|
|
972
899
|
* List a page of auth providers that are available to the caller
|
|
@@ -977,23 +904,23 @@ class Ke extends b {
|
|
|
977
904
|
/**
|
|
978
905
|
* Delete a specific auth provider
|
|
979
906
|
*/
|
|
980
|
-
delete(e,
|
|
981
|
-
return this._client.delete(`/v1/admin/auth_providers/${e}`,
|
|
907
|
+
delete(e, n) {
|
|
908
|
+
return this._client.delete(`/v1/admin/auth_providers/${e}`, n);
|
|
982
909
|
}
|
|
983
910
|
/**
|
|
984
911
|
* Get the details of a specific auth provider
|
|
985
912
|
*/
|
|
986
|
-
get(e,
|
|
987
|
-
return this._client.get(`/v1/admin/auth_providers/${e}`,
|
|
913
|
+
get(e, n) {
|
|
914
|
+
return this._client.get(`/v1/admin/auth_providers/${e}`, n);
|
|
988
915
|
}
|
|
989
916
|
/**
|
|
990
917
|
* Patch an existing auth provider
|
|
991
918
|
*/
|
|
992
|
-
patch(e,
|
|
993
|
-
return this._client.patch(`/v1/admin/auth_providers/${e}`, { body:
|
|
919
|
+
patch(e, n, r) {
|
|
920
|
+
return this._client.patch(`/v1/admin/auth_providers/${e}`, { body: n, ...r });
|
|
994
921
|
}
|
|
995
922
|
}
|
|
996
|
-
class
|
|
923
|
+
class qe extends x {
|
|
997
924
|
/**
|
|
998
925
|
* List all secrets that are visible to the caller
|
|
999
926
|
*/
|
|
@@ -1003,49 +930,49 @@ class We extends b {
|
|
|
1003
930
|
/**
|
|
1004
931
|
* Delete a secret by its ID
|
|
1005
932
|
*/
|
|
1006
|
-
delete(e,
|
|
933
|
+
delete(e, n) {
|
|
1007
934
|
return this._client.delete(`/v1/admin/secrets/${e}`, {
|
|
1008
|
-
...
|
|
1009
|
-
headers: { Accept: "*/*", ...
|
|
935
|
+
...n,
|
|
936
|
+
headers: { Accept: "*/*", ...n?.headers }
|
|
1010
937
|
});
|
|
1011
938
|
}
|
|
1012
939
|
}
|
|
1013
|
-
class
|
|
1014
|
-
list(e = {},
|
|
1015
|
-
return
|
|
940
|
+
class te extends x {
|
|
941
|
+
list(e = {}, n) {
|
|
942
|
+
return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/admin/user_connections", ne, {
|
|
1016
943
|
query: e,
|
|
1017
|
-
...
|
|
944
|
+
...n
|
|
1018
945
|
});
|
|
1019
946
|
}
|
|
1020
947
|
/**
|
|
1021
948
|
* Delete a user/auth provider connection
|
|
1022
949
|
*/
|
|
1023
|
-
delete(e,
|
|
950
|
+
delete(e, n) {
|
|
1024
951
|
return this._client.delete(`/v1/admin/user_connections/${e}`, {
|
|
1025
|
-
...
|
|
1026
|
-
headers: { Accept: "*/*", ...
|
|
952
|
+
...n,
|
|
953
|
+
headers: { Accept: "*/*", ...n?.headers }
|
|
1027
954
|
});
|
|
1028
955
|
}
|
|
1029
956
|
}
|
|
1030
|
-
class
|
|
957
|
+
class ne extends O {
|
|
1031
958
|
}
|
|
1032
|
-
|
|
1033
|
-
class
|
|
959
|
+
te.UserConnectionResponsesOffsetPage = ne;
|
|
960
|
+
class C extends x {
|
|
1034
961
|
constructor() {
|
|
1035
|
-
super(...arguments), this.userConnections = new
|
|
962
|
+
super(...arguments), this.userConnections = new te(this._client), this.authProviders = new Fe(this._client), this.secrets = new qe(this._client);
|
|
1036
963
|
}
|
|
1037
964
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
class
|
|
965
|
+
C.UserConnections = te;
|
|
966
|
+
C.UserConnectionResponsesOffsetPage = ne;
|
|
967
|
+
C.AuthProviders = Fe;
|
|
968
|
+
C.Secrets = qe;
|
|
969
|
+
const Lt = 45;
|
|
970
|
+
class Ot extends Error {
|
|
1044
971
|
constructor(e) {
|
|
1045
972
|
super(e), this.name = "AuthorizationError";
|
|
1046
973
|
}
|
|
1047
974
|
}
|
|
1048
|
-
class
|
|
975
|
+
class Be extends x {
|
|
1049
976
|
/**
|
|
1050
977
|
* Starts the authorization process for a given provider and scopes.
|
|
1051
978
|
* @param userId - The user ID for which authorization is being requested
|
|
@@ -1060,9 +987,9 @@ class Ve extends b {
|
|
|
1060
987
|
* const authResponse = await client.auth.start("user@example.com", "github");
|
|
1061
988
|
* ```
|
|
1062
989
|
*/
|
|
1063
|
-
start(e,
|
|
1064
|
-
const { providerType: s = "oauth2", scopes: o = [] } =
|
|
1065
|
-
provider_id:
|
|
990
|
+
start(e, n, r = {}) {
|
|
991
|
+
const { providerType: s = "oauth2", scopes: o = [] } = r, i = {
|
|
992
|
+
provider_id: n,
|
|
1066
993
|
provider_type: s,
|
|
1067
994
|
oauth2: {
|
|
1068
995
|
scopes: o
|
|
@@ -1076,22 +1003,22 @@ class Ve extends b {
|
|
|
1076
1003
|
/**
|
|
1077
1004
|
* Starts the authorization process for given authorization requirements
|
|
1078
1005
|
*/
|
|
1079
|
-
authorize(e,
|
|
1080
|
-
return this._client.post("/v1/auth/authorize", { body: e, ...
|
|
1006
|
+
authorize(e, n) {
|
|
1007
|
+
return this._client.post("/v1/auth/authorize", { body: e, ...n });
|
|
1081
1008
|
}
|
|
1082
1009
|
/**
|
|
1083
1010
|
* Confirms a user's details during an authorization flow
|
|
1084
1011
|
*/
|
|
1085
|
-
confirmUser(e,
|
|
1086
|
-
return this._client.post("/v1/auth/confirm_user", { body: e, ...
|
|
1012
|
+
confirmUser(e, n) {
|
|
1013
|
+
return this._client.post("/v1/auth/confirm_user", { body: e, ...n });
|
|
1087
1014
|
}
|
|
1088
1015
|
/**
|
|
1089
1016
|
* Checks the status of an ongoing authorization process for a specific tool. If
|
|
1090
1017
|
* 'wait' param is present, does not respond until either the auth status becomes
|
|
1091
1018
|
* completed or the timeout is reached.
|
|
1092
1019
|
*/
|
|
1093
|
-
status(e,
|
|
1094
|
-
return this._client.get("/v1/auth/status", { query: e, ...
|
|
1020
|
+
status(e, n) {
|
|
1021
|
+
return this._client.get("/v1/auth/status", { query: e, ...n });
|
|
1095
1022
|
}
|
|
1096
1023
|
/**
|
|
1097
1024
|
* Waits for the authorization process to complete.
|
|
@@ -1113,37 +1040,37 @@ class Ve extends b {
|
|
|
1113
1040
|
* ```
|
|
1114
1041
|
*/
|
|
1115
1042
|
async waitForCompletion(e) {
|
|
1116
|
-
let
|
|
1043
|
+
let n, r;
|
|
1117
1044
|
if (typeof e == "string")
|
|
1118
|
-
|
|
1045
|
+
n = e, r = { status: "pending" };
|
|
1119
1046
|
else {
|
|
1120
1047
|
if (!e.id)
|
|
1121
|
-
throw new
|
|
1122
|
-
|
|
1048
|
+
throw new Ot("Authorization ID is required");
|
|
1049
|
+
n = e.id, r = e;
|
|
1123
1050
|
}
|
|
1124
|
-
for (;
|
|
1125
|
-
|
|
1126
|
-
id:
|
|
1127
|
-
wait:
|
|
1051
|
+
for (; r.status !== "completed"; )
|
|
1052
|
+
r = await this.status({
|
|
1053
|
+
id: n,
|
|
1054
|
+
wait: Lt
|
|
1128
1055
|
});
|
|
1129
|
-
return
|
|
1056
|
+
return r;
|
|
1130
1057
|
}
|
|
1131
1058
|
}
|
|
1132
|
-
class
|
|
1059
|
+
class He extends x {
|
|
1133
1060
|
/**
|
|
1134
1061
|
* Talk to different LLM Chat APIs via OpenAI's API
|
|
1135
1062
|
*/
|
|
1136
|
-
create(e,
|
|
1137
|
-
return this._client.post("/v1/chat/completions", { body: e, ...
|
|
1063
|
+
create(e, n) {
|
|
1064
|
+
return this._client.post("/v1/chat/completions", { body: e, ...n });
|
|
1138
1065
|
}
|
|
1139
1066
|
}
|
|
1140
|
-
class
|
|
1067
|
+
class re extends x {
|
|
1141
1068
|
constructor() {
|
|
1142
|
-
super(...arguments), this.completions = new
|
|
1069
|
+
super(...arguments), this.completions = new He(this._client);
|
|
1143
1070
|
}
|
|
1144
1071
|
}
|
|
1145
|
-
|
|
1146
|
-
class
|
|
1072
|
+
re.Completions = He;
|
|
1073
|
+
class ze extends x {
|
|
1147
1074
|
/**
|
|
1148
1075
|
* Engine Health
|
|
1149
1076
|
*/
|
|
@@ -1151,111 +1078,111 @@ class Ge extends b {
|
|
|
1151
1078
|
return this._client.get("/v1/health", e);
|
|
1152
1079
|
}
|
|
1153
1080
|
}
|
|
1154
|
-
class
|
|
1155
|
-
list(e = {},
|
|
1156
|
-
return
|
|
1081
|
+
class se extends x {
|
|
1082
|
+
list(e = {}, n) {
|
|
1083
|
+
return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/formatted_tools", oe, {
|
|
1157
1084
|
query: e,
|
|
1158
|
-
...
|
|
1085
|
+
...n
|
|
1159
1086
|
});
|
|
1160
1087
|
}
|
|
1161
|
-
get(e,
|
|
1162
|
-
return
|
|
1088
|
+
get(e, n = {}, r) {
|
|
1089
|
+
return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/formatted_tools/${e}`, { query: n, ...r });
|
|
1163
1090
|
}
|
|
1164
1091
|
}
|
|
1165
|
-
class
|
|
1092
|
+
class oe extends O {
|
|
1166
1093
|
}
|
|
1167
|
-
|
|
1168
|
-
class
|
|
1169
|
-
list(e = {},
|
|
1170
|
-
return
|
|
1094
|
+
se.FormattedListResponsesOffsetPage = oe;
|
|
1095
|
+
class Xe extends x {
|
|
1096
|
+
list(e = {}, n) {
|
|
1097
|
+
return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/scheduled_tools", Dt, { query: e, ...n });
|
|
1171
1098
|
}
|
|
1172
1099
|
/**
|
|
1173
1100
|
* Returns the details for a specific scheduled tool execution
|
|
1174
1101
|
*/
|
|
1175
|
-
get(e,
|
|
1176
|
-
return this._client.get(`/v1/scheduled_tools/${e}`,
|
|
1102
|
+
get(e, n) {
|
|
1103
|
+
return this._client.get(`/v1/scheduled_tools/${e}`, n);
|
|
1177
1104
|
}
|
|
1178
1105
|
}
|
|
1179
|
-
class
|
|
1106
|
+
class v extends x {
|
|
1180
1107
|
constructor() {
|
|
1181
|
-
super(...arguments), this.scheduled = new
|
|
1108
|
+
super(...arguments), this.scheduled = new Xe(this._client), this.formatted = new se(this._client);
|
|
1182
1109
|
}
|
|
1183
|
-
list(e = {},
|
|
1184
|
-
return
|
|
1110
|
+
list(e = {}, n) {
|
|
1111
|
+
return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/tools", H, { query: e, ...n });
|
|
1185
1112
|
}
|
|
1186
1113
|
/**
|
|
1187
1114
|
* Authorizes a user for a specific tool by name
|
|
1188
1115
|
*/
|
|
1189
|
-
authorize(e,
|
|
1190
|
-
return this._client.post("/v1/tools/authorize", { body: e, ...
|
|
1116
|
+
authorize(e, n) {
|
|
1117
|
+
return this._client.post("/v1/tools/authorize", { body: e, ...n });
|
|
1191
1118
|
}
|
|
1192
1119
|
/**
|
|
1193
1120
|
* Executes a tool by name and arguments
|
|
1194
1121
|
*/
|
|
1195
|
-
execute(e,
|
|
1196
|
-
return this._client.post("/v1/tools/execute", { body: e, ...
|
|
1122
|
+
execute(e, n) {
|
|
1123
|
+
return this._client.post("/v1/tools/execute", { body: e, ...n });
|
|
1197
1124
|
}
|
|
1198
|
-
get(e,
|
|
1199
|
-
return
|
|
1125
|
+
get(e, n = {}, r) {
|
|
1126
|
+
return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/tools/${e}`, { query: n, ...r });
|
|
1200
1127
|
}
|
|
1201
1128
|
}
|
|
1202
|
-
class
|
|
1129
|
+
class H extends O {
|
|
1203
1130
|
}
|
|
1204
|
-
class
|
|
1131
|
+
class Dt extends O {
|
|
1205
1132
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
class
|
|
1133
|
+
v.ToolDefinitionsOffsetPage = H;
|
|
1134
|
+
v.Scheduled = Xe;
|
|
1135
|
+
v.Formatted = se;
|
|
1136
|
+
v.FormattedListResponsesOffsetPage = oe;
|
|
1137
|
+
class ie extends x {
|
|
1211
1138
|
/**
|
|
1212
1139
|
* Create a worker
|
|
1213
1140
|
*/
|
|
1214
|
-
create(e,
|
|
1215
|
-
return this._client.post("/v1/workers", { body: e, ...
|
|
1141
|
+
create(e, n) {
|
|
1142
|
+
return this._client.post("/v1/workers", { body: e, ...n });
|
|
1216
1143
|
}
|
|
1217
1144
|
/**
|
|
1218
1145
|
* Update a worker
|
|
1219
1146
|
*/
|
|
1220
|
-
update(e,
|
|
1221
|
-
return this._client.patch(`/v1/workers/${e}`, { body:
|
|
1147
|
+
update(e, n, r) {
|
|
1148
|
+
return this._client.patch(`/v1/workers/${e}`, { body: n, ...r });
|
|
1222
1149
|
}
|
|
1223
|
-
list(e = {},
|
|
1224
|
-
return
|
|
1150
|
+
list(e = {}, n) {
|
|
1151
|
+
return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/workers", ae, { query: e, ...n });
|
|
1225
1152
|
}
|
|
1226
1153
|
/**
|
|
1227
1154
|
* Delete a worker
|
|
1228
1155
|
*/
|
|
1229
|
-
delete(e,
|
|
1156
|
+
delete(e, n) {
|
|
1230
1157
|
return this._client.delete(`/v1/workers/${e}`, {
|
|
1231
|
-
...
|
|
1232
|
-
headers: { Accept: "*/*", ...
|
|
1158
|
+
...n,
|
|
1159
|
+
headers: { Accept: "*/*", ...n?.headers }
|
|
1233
1160
|
});
|
|
1234
1161
|
}
|
|
1235
1162
|
/**
|
|
1236
1163
|
* Get a worker by ID
|
|
1237
1164
|
*/
|
|
1238
|
-
get(e,
|
|
1239
|
-
return this._client.get(`/v1/workers/${e}`,
|
|
1165
|
+
get(e, n) {
|
|
1166
|
+
return this._client.get(`/v1/workers/${e}`, n);
|
|
1240
1167
|
}
|
|
1241
1168
|
/**
|
|
1242
1169
|
* Get the health of a worker
|
|
1243
1170
|
*/
|
|
1244
|
-
health(e,
|
|
1245
|
-
return this._client.get(`/v1/workers/${e}/health`,
|
|
1171
|
+
health(e, n) {
|
|
1172
|
+
return this._client.get(`/v1/workers/${e}/health`, n);
|
|
1246
1173
|
}
|
|
1247
|
-
tools(e,
|
|
1248
|
-
return
|
|
1249
|
-
query:
|
|
1250
|
-
...
|
|
1174
|
+
tools(e, n = {}, r) {
|
|
1175
|
+
return R(n) ? this.tools(e, {}, n) : this._client.getAPIList(`/v1/workers/${e}/tools`, H, {
|
|
1176
|
+
query: n,
|
|
1177
|
+
...r
|
|
1251
1178
|
});
|
|
1252
1179
|
}
|
|
1253
1180
|
}
|
|
1254
|
-
class
|
|
1181
|
+
class ae extends O {
|
|
1255
1182
|
}
|
|
1256
|
-
|
|
1257
|
-
var
|
|
1258
|
-
class d extends
|
|
1183
|
+
ie.WorkerResponsesOffsetPage = ae;
|
|
1184
|
+
var Ke, We;
|
|
1185
|
+
class d extends wt {
|
|
1259
1186
|
/**
|
|
1260
1187
|
* API Client for interfacing with the Arcade API.
|
|
1261
1188
|
*
|
|
@@ -1268,12 +1195,12 @@ class d extends xt {
|
|
|
1268
1195
|
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
1269
1196
|
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
1270
1197
|
*/
|
|
1271
|
-
constructor({ baseURL: e =
|
|
1272
|
-
if (
|
|
1198
|
+
constructor({ baseURL: e = xe("ARCADE_BASE_URL"), apiKey: n = xe("ARCADE_API_KEY"), ...r } = {}) {
|
|
1199
|
+
if (n === void 0)
|
|
1273
1200
|
throw new P("The ARCADE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Arcade client with an apiKey option, like new Arcade({ apiKey: 'My API Key' }).");
|
|
1274
1201
|
const s = {
|
|
1275
|
-
apiKey:
|
|
1276
|
-
...
|
|
1202
|
+
apiKey: n,
|
|
1203
|
+
...r,
|
|
1277
1204
|
baseURL: e || "https://api.arcade.dev"
|
|
1278
1205
|
};
|
|
1279
1206
|
super({
|
|
@@ -1283,7 +1210,7 @@ class d extends xt {
|
|
|
1283
1210
|
httpAgent: s.httpAgent,
|
|
1284
1211
|
maxRetries: s.maxRetries,
|
|
1285
1212
|
fetch: s.fetch
|
|
1286
|
-
}),
|
|
1213
|
+
}), Ke.add(this), this.admin = new C(this), this.auth = new Be(this), this.health = new ze(this), this.chat = new re(this), this.tools = new v(this), this.workers = new ie(this), this._options = s, this.idempotencyHeader = "Idempotency-Key", this.apiKey = n;
|
|
1287
1214
|
}
|
|
1288
1215
|
defaultQuery() {
|
|
1289
1216
|
return this._options.defaultQuery;
|
|
@@ -1298,44 +1225,43 @@ class d extends xt {
|
|
|
1298
1225
|
return { Authorization: this.apiKey };
|
|
1299
1226
|
}
|
|
1300
1227
|
stringifyQuery(e) {
|
|
1301
|
-
return
|
|
1228
|
+
return lt(e, { arrayFormat: "comma" });
|
|
1302
1229
|
}
|
|
1303
1230
|
}
|
|
1304
|
-
|
|
1305
|
-
d.Arcade =
|
|
1231
|
+
We = d, Ke = /* @__PURE__ */ new WeakSet();
|
|
1232
|
+
d.Arcade = We;
|
|
1306
1233
|
d.DEFAULT_TIMEOUT = 6e4;
|
|
1307
1234
|
d.ArcadeError = P;
|
|
1308
1235
|
d.APIError = w;
|
|
1309
|
-
d.APIConnectionError =
|
|
1310
|
-
d.APIConnectionTimeoutError =
|
|
1311
|
-
d.APIUserAbortError =
|
|
1236
|
+
d.APIConnectionError = F;
|
|
1237
|
+
d.APIConnectionTimeoutError = Ee;
|
|
1238
|
+
d.APIUserAbortError = Z;
|
|
1312
1239
|
d.NotFoundError = Ce;
|
|
1313
|
-
d.ConflictError =
|
|
1240
|
+
d.ConflictError = ve;
|
|
1314
1241
|
d.RateLimitError = Le;
|
|
1315
|
-
d.BadRequestError =
|
|
1316
|
-
d.AuthenticationError =
|
|
1242
|
+
d.BadRequestError = Pe;
|
|
1243
|
+
d.AuthenticationError = ke;
|
|
1317
1244
|
d.InternalServerError = Oe;
|
|
1318
|
-
d.PermissionDeniedError =
|
|
1319
|
-
d.UnprocessableEntityError =
|
|
1320
|
-
d.toFile =
|
|
1321
|
-
d.fileFromPath =
|
|
1322
|
-
d.Admin =
|
|
1323
|
-
d.Auth =
|
|
1324
|
-
d.Health =
|
|
1325
|
-
d.Chat =
|
|
1326
|
-
d.Tools =
|
|
1327
|
-
d.ToolDefinitionsOffsetPage =
|
|
1328
|
-
d.Workers =
|
|
1329
|
-
d.WorkerResponsesOffsetPage =
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
class Kt {
|
|
1245
|
+
d.PermissionDeniedError = Te;
|
|
1246
|
+
d.UnprocessableEntityError = Ie;
|
|
1247
|
+
d.toFile = ht;
|
|
1248
|
+
d.fileFromPath = Ze;
|
|
1249
|
+
d.Admin = C;
|
|
1250
|
+
d.Auth = Be;
|
|
1251
|
+
d.Health = ze;
|
|
1252
|
+
d.Chat = re;
|
|
1253
|
+
d.Tools = v;
|
|
1254
|
+
d.ToolDefinitionsOffsetPage = H;
|
|
1255
|
+
d.Workers = ie;
|
|
1256
|
+
d.WorkerResponsesOffsetPage = ae;
|
|
1257
|
+
const Ut = /[._\-\s]+/, $t = /([a-z])([A-Z])/g, jt = /\s+/;
|
|
1258
|
+
class qt {
|
|
1333
1259
|
#e;
|
|
1334
1260
|
constructor(e) {
|
|
1335
|
-
const { accessToken:
|
|
1336
|
-
s && (c["Arcade-Client-Id"] = s), !l &&
|
|
1261
|
+
const { accessToken: n, apiKey: r, arcadeClientId: s, baseURL: o } = e, i = r ?? he("ARCADE_API_KEY"), l = !!i, c = {};
|
|
1262
|
+
s && (c["Arcade-Client-Id"] = s), !l && n && (c.Authorization = `Bearer ${n}`);
|
|
1337
1263
|
const u = {
|
|
1338
|
-
baseURL: o ??
|
|
1264
|
+
baseURL: o ?? he("ARCADE_BASE_URL"),
|
|
1339
1265
|
defaultHeaders: c,
|
|
1340
1266
|
apiKey: i ?? ""
|
|
1341
1267
|
};
|
|
@@ -1345,28 +1271,28 @@ class Kt {
|
|
|
1345
1271
|
return new d(e);
|
|
1346
1272
|
}
|
|
1347
1273
|
async getAllTools(e = {}) {
|
|
1348
|
-
const { limit:
|
|
1274
|
+
const { limit: n = 1e3, offset: r = 0, toolkit: s } = e;
|
|
1349
1275
|
return (await this.#e.tools.list({
|
|
1350
|
-
limit:
|
|
1351
|
-
offset:
|
|
1276
|
+
limit: n,
|
|
1277
|
+
offset: r,
|
|
1352
1278
|
toolkit: s
|
|
1353
1279
|
})).items;
|
|
1354
1280
|
}
|
|
1355
1281
|
async groupToolsBy(e) {
|
|
1356
|
-
const
|
|
1357
|
-
for (const s of
|
|
1282
|
+
const n = await this.getAllTools(), r = /* @__PURE__ */ new Map();
|
|
1283
|
+
for (const s of n) {
|
|
1358
1284
|
const o = s[e];
|
|
1359
|
-
typeof o == "string" &&
|
|
1285
|
+
typeof o == "string" && r.set(o, s);
|
|
1360
1286
|
}
|
|
1361
|
-
return
|
|
1287
|
+
return r;
|
|
1362
1288
|
}
|
|
1363
1289
|
async getToolkits() {
|
|
1364
|
-
const e = await this.getAllTools(),
|
|
1365
|
-
for (const
|
|
1366
|
-
const s =
|
|
1367
|
-
let o =
|
|
1290
|
+
const e = await this.getAllTools(), n = /* @__PURE__ */ new Map();
|
|
1291
|
+
for (const r of e) {
|
|
1292
|
+
const s = r.toolkit.name;
|
|
1293
|
+
let o = n.get(s);
|
|
1368
1294
|
o || (o = {
|
|
1369
|
-
...
|
|
1295
|
+
...r.toolkit,
|
|
1370
1296
|
tools: [],
|
|
1371
1297
|
requirements: {
|
|
1372
1298
|
met: !0,
|
|
@@ -1374,9 +1300,9 @@ class Kt {
|
|
|
1374
1300
|
authorization: [],
|
|
1375
1301
|
scopes: {}
|
|
1376
1302
|
}
|
|
1377
|
-
},
|
|
1303
|
+
}, n.set(s, o)), o.tools.push(r), r.requirements && this.applyToolRequirements(o, r.requirements);
|
|
1378
1304
|
}
|
|
1379
|
-
return
|
|
1305
|
+
return n;
|
|
1380
1306
|
}
|
|
1381
1307
|
async getToolsForToolkit(e) {
|
|
1382
1308
|
return (await this.#e.tools.list({
|
|
@@ -1384,81 +1310,81 @@ class Kt {
|
|
|
1384
1310
|
limit: 1e3
|
|
1385
1311
|
})).items;
|
|
1386
1312
|
}
|
|
1387
|
-
applyToolRequirements(e,
|
|
1388
|
-
if (!
|
|
1313
|
+
applyToolRequirements(e, n) {
|
|
1314
|
+
if (!n)
|
|
1389
1315
|
return;
|
|
1390
1316
|
e.requirements.secrets = this.mergeSecrets(
|
|
1391
|
-
|
|
1317
|
+
n.secrets ?? [],
|
|
1392
1318
|
e.requirements.secrets ?? []
|
|
1393
1319
|
), e.requirements.authorization = this.mergeAuthorizations(
|
|
1394
|
-
|
|
1320
|
+
n.authorization,
|
|
1395
1321
|
e.requirements.authorization ?? []
|
|
1396
1322
|
);
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1323
|
+
const r = n.authorization?.provider_id, s = n.authorization?.oauth2?.scopes ?? [];
|
|
1324
|
+
r && s.length && (e.requirements.scopes = this.mergeScopes(
|
|
1325
|
+
r,
|
|
1400
1326
|
s,
|
|
1401
1327
|
e.requirements.scopes ?? {}
|
|
1402
|
-
)), e.requirements.met = !!(e.requirements.met && (
|
|
1328
|
+
)), e.requirements.met = !!(e.requirements.met && (n.met ?? !0));
|
|
1403
1329
|
}
|
|
1404
|
-
mergeSecrets(e = [],
|
|
1330
|
+
mergeSecrets(e = [], n = []) {
|
|
1405
1331
|
if (e.length === 0)
|
|
1406
|
-
return
|
|
1407
|
-
const
|
|
1408
|
-
for (const s of
|
|
1409
|
-
|
|
1332
|
+
return n;
|
|
1333
|
+
const r = /* @__PURE__ */ new Map();
|
|
1334
|
+
for (const s of n)
|
|
1335
|
+
r.set(s.key, { ...s });
|
|
1410
1336
|
for (const s of e) {
|
|
1411
|
-
const o =
|
|
1337
|
+
const o = r.get(s.key);
|
|
1412
1338
|
if (!o) {
|
|
1413
|
-
|
|
1339
|
+
r.set(s.key, { ...s });
|
|
1414
1340
|
continue;
|
|
1415
1341
|
}
|
|
1416
1342
|
const i = !!(o.met || s.met), l = s.status_reason ?? o.status_reason;
|
|
1417
|
-
|
|
1343
|
+
r.set(s.key, { key: s.key, met: i, status_reason: l });
|
|
1418
1344
|
}
|
|
1419
|
-
return Array.from(
|
|
1345
|
+
return Array.from(r.values());
|
|
1420
1346
|
}
|
|
1421
|
-
mergeAuthorizations(e,
|
|
1347
|
+
mergeAuthorizations(e, n = []) {
|
|
1422
1348
|
if (!e?.provider_id)
|
|
1423
|
-
return
|
|
1424
|
-
const
|
|
1349
|
+
return n;
|
|
1350
|
+
const r = new Map(n.map((i) => [i.provider_id, { ...i }])), s = r.get(e.provider_id);
|
|
1425
1351
|
if (!s)
|
|
1426
|
-
return
|
|
1352
|
+
return r.set(e.provider_id, { ...e }), Array.from(r.values());
|
|
1427
1353
|
const o = new Set(s.oauth2?.scopes ?? []);
|
|
1428
1354
|
for (const i of e.oauth2?.scopes ?? [])
|
|
1429
1355
|
o.add(i);
|
|
1430
|
-
return
|
|
1356
|
+
return r.set(e.provider_id, {
|
|
1431
1357
|
...s,
|
|
1432
1358
|
oauth2: {
|
|
1433
1359
|
...s.oauth2 ?? {},
|
|
1434
1360
|
scopes: Array.from(o)
|
|
1435
1361
|
}
|
|
1436
|
-
}), Array.from(
|
|
1362
|
+
}), Array.from(r.values());
|
|
1437
1363
|
}
|
|
1438
|
-
mergeScopes(e,
|
|
1439
|
-
if (!e ||
|
|
1440
|
-
return
|
|
1441
|
-
const s = new Set(
|
|
1442
|
-
for (const o of
|
|
1364
|
+
mergeScopes(e, n = [], r = {}) {
|
|
1365
|
+
if (!e || n.length === 0)
|
|
1366
|
+
return r;
|
|
1367
|
+
const s = new Set(r[e] ?? []);
|
|
1368
|
+
for (const o of n)
|
|
1443
1369
|
s.add(o);
|
|
1444
|
-
return { ...
|
|
1370
|
+
return { ...r, [e]: Array.from(s) };
|
|
1445
1371
|
}
|
|
1446
1372
|
/**
|
|
1447
1373
|
* Pre-compute requirements summary for optimal UI performance.
|
|
1448
1374
|
* This eliminates the need for runtime transformation in UI components.
|
|
1449
1375
|
*/
|
|
1450
1376
|
computeRequirementsSummary(e) {
|
|
1451
|
-
const
|
|
1377
|
+
const n = e?.secrets?.length ? {
|
|
1452
1378
|
configured: e.secrets.filter((s) => s.met === !0).map((s) => s.key),
|
|
1453
1379
|
pending: e.secrets.filter((s) => s.met === !1).map((s) => s.key)
|
|
1454
|
-
} : void 0,
|
|
1380
|
+
} : void 0, r = e?.authorization?.length ? {
|
|
1455
1381
|
providers: e.authorization.filter((s) => s.provider_id || s.id).map((s) => ({
|
|
1456
1382
|
id: s.provider_id || s.id || "",
|
|
1457
1383
|
status: s.status,
|
|
1458
1384
|
scopes: s.oauth2?.scopes || []
|
|
1459
1385
|
}))
|
|
1460
1386
|
} : void 0;
|
|
1461
|
-
return { secrets:
|
|
1387
|
+
return { secrets: n, oauth: r };
|
|
1462
1388
|
}
|
|
1463
1389
|
/**
|
|
1464
1390
|
* Process raw toolkit data into an optimized collection with pre-computed search indices.
|
|
@@ -1470,7 +1396,7 @@ class Kt {
|
|
|
1470
1396
|
* - Toolkit/tool mapping for quick relationships
|
|
1471
1397
|
*/
|
|
1472
1398
|
async getProcessedToolkitCollection() {
|
|
1473
|
-
const e = await this.getToolkits(),
|
|
1399
|
+
const e = await this.getToolkits(), n = [], r = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = {
|
|
1474
1400
|
toolkitsByName: /* @__PURE__ */ new Map(),
|
|
1475
1401
|
toolsByName: /* @__PURE__ */ new Map()
|
|
1476
1402
|
};
|
|
@@ -1485,9 +1411,9 @@ class Kt {
|
|
|
1485
1411
|
...c,
|
|
1486
1412
|
searchableText: u,
|
|
1487
1413
|
requirementsSummary: p,
|
|
1488
|
-
metadata:
|
|
1414
|
+
metadata: et[c.name]
|
|
1489
1415
|
};
|
|
1490
|
-
|
|
1416
|
+
n.push(a), s.set(l, a), i.toolkitsByName.set(l.toLowerCase(), a);
|
|
1491
1417
|
for (const h of c.tools) {
|
|
1492
1418
|
const m = this.normalizeText([
|
|
1493
1419
|
h.name,
|
|
@@ -1495,19 +1421,19 @@ class Kt {
|
|
|
1495
1421
|
h.description ?? "",
|
|
1496
1422
|
c.name,
|
|
1497
1423
|
c.description ?? ""
|
|
1498
|
-
]),
|
|
1424
|
+
]), b = {
|
|
1499
1425
|
...h,
|
|
1500
1426
|
searchableText: m
|
|
1501
1427
|
};
|
|
1502
|
-
|
|
1428
|
+
r.push(b), o.set(h.fully_qualified_name, l), i.toolsByName.set(
|
|
1503
1429
|
h.fully_qualified_name.toLowerCase(),
|
|
1504
|
-
|
|
1430
|
+
b
|
|
1505
1431
|
);
|
|
1506
1432
|
}
|
|
1507
1433
|
}
|
|
1508
1434
|
return {
|
|
1509
|
-
toolkits:
|
|
1510
|
-
tools:
|
|
1435
|
+
toolkits: n,
|
|
1436
|
+
tools: r,
|
|
1511
1437
|
toolkitMap: s,
|
|
1512
1438
|
toolToToolkitMap: o,
|
|
1513
1439
|
searchIndex: i
|
|
@@ -1519,25 +1445,25 @@ class Kt {
|
|
|
1519
1445
|
* Handles camelCase, snake_case, kebab-case, and dot.notation.
|
|
1520
1446
|
*/
|
|
1521
1447
|
normalizeText(e) {
|
|
1522
|
-
const
|
|
1523
|
-
for (const
|
|
1524
|
-
if (!
|
|
1448
|
+
const n = /* @__PURE__ */ new Set();
|
|
1449
|
+
for (const r of e) {
|
|
1450
|
+
if (!r)
|
|
1525
1451
|
continue;
|
|
1526
|
-
const s =
|
|
1527
|
-
|
|
1528
|
-
const o =
|
|
1452
|
+
const s = r.toLowerCase();
|
|
1453
|
+
n.add(s);
|
|
1454
|
+
const o = r.split(Ut);
|
|
1529
1455
|
for (const i of o) {
|
|
1530
1456
|
if (i.length <= 1)
|
|
1531
1457
|
continue;
|
|
1532
|
-
const c = i.replace(
|
|
1458
|
+
const c = i.replace($t, "$1 $2").split(jt);
|
|
1533
1459
|
for (const u of c)
|
|
1534
|
-
u.length > 1 &&
|
|
1460
|
+
u.length > 1 && n.add(u.toLowerCase());
|
|
1535
1461
|
}
|
|
1536
1462
|
}
|
|
1537
|
-
return Array.from(
|
|
1463
|
+
return Array.from(n).join(" ");
|
|
1538
1464
|
}
|
|
1539
1465
|
}
|
|
1540
1466
|
export {
|
|
1541
|
-
|
|
1467
|
+
qt as A,
|
|
1542
1468
|
d as a
|
|
1543
1469
|
};
|