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