@gigadrive/sdk 0.7.5 → 0.7.7
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/index.js +2164 -2403
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2441 +1,2202 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
AiGatewayAudioResource: () => AiGatewayAudioResource,
|
|
34
|
-
AiGatewayBudgetsResource: () => AiGatewayBudgetsResource,
|
|
35
|
-
AiGatewayPoliciesResource: () => AiGatewayPoliciesResource,
|
|
36
|
-
AiGatewayResource: () => AiGatewayResource,
|
|
37
|
-
AiGatewayUsageResource: () => AiGatewayUsageResource,
|
|
38
|
-
AiGatewayVideosResource: () => AiGatewayVideosResource,
|
|
39
|
-
ApiError: () => ApiError,
|
|
40
|
-
ApiKeysResource: () => ApiKeysResource,
|
|
41
|
-
ApplicationEnvVarsResource: () => ApplicationEnvVarsResource,
|
|
42
|
-
ApplicationRequestsResource: () => ApplicationRequestsResource,
|
|
43
|
-
ApplicationStorageResource: () => ApplicationStorageResource,
|
|
44
|
-
ApplicationsResource: () => ApplicationsResource,
|
|
45
|
-
AuthenticationError: () => AuthenticationError,
|
|
46
|
-
DeploymentsResource: () => DeploymentsResource,
|
|
47
|
-
GigadriveClient: () => GigadriveClient,
|
|
48
|
-
GigadriveError: () => GigadriveError,
|
|
49
|
-
ImageOptimizationResource: () => ImageOptimizationResource,
|
|
50
|
-
OrganizationAiGatewayResource: () => OrganizationAiGatewayResource,
|
|
51
|
-
OrganizationEnvVarsResource: () => OrganizationEnvVarsResource,
|
|
52
|
-
OrganizationMembersResource: () => OrganizationMembersResource,
|
|
53
|
-
OrganizationProductsResource: () => OrganizationProductsResource,
|
|
54
|
-
OrganizationsResource: () => OrganizationsResource,
|
|
55
|
-
StickySessionsResource: () => StickySessionsResource,
|
|
56
|
-
StorageBucketsResource: () => StorageBucketsResource,
|
|
57
|
-
StorageObjectsResource: () => StorageObjectsResource,
|
|
58
|
-
StorageUploadSessionsResource: () => StorageUploadSessionsResource,
|
|
59
|
-
UploadError: () => UploadError,
|
|
60
|
-
UploadSessionExpiredError: () => UploadSessionExpiredError,
|
|
61
|
-
createManagedImageUrl: () => createManagedImageUrl,
|
|
62
|
-
paginate: () => paginate,
|
|
63
|
-
parseSSEStream: () => parseSSEStream
|
|
64
|
-
});
|
|
65
|
-
module.exports = __toCommonJS(src_exports);
|
|
66
|
-
|
|
67
|
-
// src/errors.ts
|
|
68
|
-
var GigadriveError = class extends Error {
|
|
69
|
-
constructor(message) {
|
|
70
|
-
super(message);
|
|
71
|
-
this.name = "GigadriveError";
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var AuthenticationError = class extends GigadriveError {
|
|
75
|
-
constructor(message) {
|
|
76
|
-
super(message);
|
|
77
|
-
this.name = "AuthenticationError";
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var ApiError = class extends GigadriveError {
|
|
81
|
-
/** The HTTP status code of the failed response (e.g. 404, 500). */
|
|
82
|
-
status;
|
|
83
|
-
/** An optional machine-readable error code from the API response body. */
|
|
84
|
-
code;
|
|
85
|
-
constructor(message, status, code) {
|
|
86
|
-
super(message);
|
|
87
|
-
this.name = "ApiError";
|
|
88
|
-
this.status = status;
|
|
89
|
-
this.code = code;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var UploadError = class extends GigadriveError {
|
|
93
|
-
/** The underlying error that caused the upload to fail, if any. */
|
|
94
|
-
cause;
|
|
95
|
-
constructor(message, cause) {
|
|
96
|
-
super(message);
|
|
97
|
-
this.name = "UploadError";
|
|
98
|
-
this.cause = cause;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var UploadSessionExpiredError = class extends UploadError {
|
|
102
|
-
constructor(message = "The upload session expired before the upload completed. Start a new upload to retry.", cause) {
|
|
103
|
-
super(message, cause);
|
|
104
|
-
this.name = "UploadSessionExpiredError";
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// src/auth/credential-provider.ts
|
|
109
|
-
var DEFAULT_SCOPE = "offline_access openid profile email";
|
|
110
|
-
var TOKEN_EXPIRY_MARGIN_SECONDS = 30;
|
|
111
|
-
var computeExpiresAt = (expiresInSeconds) => {
|
|
112
|
-
const ttl = expiresInSeconds ?? 3600;
|
|
113
|
-
const margin = Math.min(TOKEN_EXPIRY_MARGIN_SECONDS, ttl / 2);
|
|
114
|
-
return Date.now() + (ttl - margin) * 1e3;
|
|
115
|
-
};
|
|
116
|
-
var readEnv = (name) => {
|
|
117
|
-
if (typeof process === "undefined" || !process.env) return void 0;
|
|
118
|
-
return process.env[name];
|
|
119
|
-
};
|
|
120
|
-
var parseTokenResponse = (payload) => {
|
|
121
|
-
const data = payload;
|
|
122
|
-
if (typeof data.access_token !== "string" || data.access_token.length === 0) {
|
|
123
|
-
throw new AuthenticationError("Token endpoint returned no access_token");
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
access_token: data.access_token,
|
|
127
|
-
refresh_token: typeof data.refresh_token === "string" ? data.refresh_token : void 0,
|
|
128
|
-
expires_in: typeof data.expires_in === "number" ? data.expires_in : void 0
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
129
17
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
throw new AuthenticationError(`OIDC discovery failed: ${response.status} ${response.statusText}`);
|
|
136
|
-
}
|
|
137
|
-
return await response.json();
|
|
138
|
-
};
|
|
139
|
-
var base64UrlEncode = (buffer) => {
|
|
140
|
-
let binary = "";
|
|
141
|
-
for (let i = 0; i < buffer.byteLength; i++) {
|
|
142
|
-
binary += String.fromCharCode(buffer[i]);
|
|
143
|
-
}
|
|
144
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
145
|
-
};
|
|
146
|
-
var generatePkce = async () => {
|
|
147
|
-
const randomBytes = new Uint8Array(64);
|
|
148
|
-
crypto.getRandomValues(randomBytes);
|
|
149
|
-
const codeVerifier = base64UrlEncode(randomBytes);
|
|
150
|
-
const encoder = new TextEncoder();
|
|
151
|
-
const data = encoder.encode(codeVerifier);
|
|
152
|
-
const digest = await crypto.subtle.digest("SHA-256", data);
|
|
153
|
-
const codeChallenge = base64UrlEncode(new Uint8Array(digest));
|
|
154
|
-
return { codeVerifier, codeChallenge };
|
|
155
|
-
};
|
|
156
|
-
var generateState = () => {
|
|
157
|
-
const bytes = new Uint8Array(16);
|
|
158
|
-
crypto.getRandomValues(bytes);
|
|
159
|
-
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
160
|
-
};
|
|
161
|
-
var OAuth2ClientCredentialProvider = class {
|
|
162
|
-
constructor(clientId, clientSecret, tokenUrl, fetchFn) {
|
|
163
|
-
this.clientId = clientId;
|
|
164
|
-
this.clientSecret = clientSecret;
|
|
165
|
-
this.tokenUrl = tokenUrl;
|
|
166
|
-
this.fetchFn = fetchFn;
|
|
167
|
-
}
|
|
168
|
-
clientId;
|
|
169
|
-
clientSecret;
|
|
170
|
-
tokenUrl;
|
|
171
|
-
fetchFn;
|
|
172
|
-
type = "oauth2-client-credentials";
|
|
173
|
-
async getToken() {
|
|
174
|
-
const credentials = btoa(`${this.clientId}:${this.clientSecret}`);
|
|
175
|
-
const response = await this.fetchFn(this.tokenUrl, {
|
|
176
|
-
method: "POST",
|
|
177
|
-
headers: {
|
|
178
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
179
|
-
Authorization: `Basic ${credentials}`
|
|
180
|
-
},
|
|
181
|
-
body: new URLSearchParams({ grant_type: "client_credentials" }).toString()
|
|
182
|
-
});
|
|
183
|
-
if (!response.ok) {
|
|
184
|
-
const body = await response.text().catch(() => "");
|
|
185
|
-
throw new AuthenticationError(`OAuth2 token request failed (${response.status}): ${body}`);
|
|
186
|
-
}
|
|
187
|
-
const data = parseTokenResponse(await response.json());
|
|
188
|
-
return {
|
|
189
|
-
accessToken: data.access_token,
|
|
190
|
-
expiresAt: computeExpiresAt(data.expires_in)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
var OAuth2AuthorizationCodeProvider = class {
|
|
195
|
-
constructor(clientId, issuerUrl, redirectUri, onAuthorizationUrl, fetchFn, scope = DEFAULT_SCOPE) {
|
|
196
|
-
this.clientId = clientId;
|
|
197
|
-
this.issuerUrl = issuerUrl;
|
|
198
|
-
this.redirectUri = redirectUri;
|
|
199
|
-
this.onAuthorizationUrl = onAuthorizationUrl;
|
|
200
|
-
this.fetchFn = fetchFn;
|
|
201
|
-
this.scope = scope;
|
|
202
|
-
}
|
|
203
|
-
clientId;
|
|
204
|
-
issuerUrl;
|
|
205
|
-
redirectUri;
|
|
206
|
-
onAuthorizationUrl;
|
|
207
|
-
fetchFn;
|
|
208
|
-
scope;
|
|
209
|
-
type = "oauth2-authorization-code";
|
|
210
|
-
currentRefreshToken = null;
|
|
211
|
-
async getToken() {
|
|
212
|
-
const oidc = await discoverOidc(this.issuerUrl, this.fetchFn);
|
|
213
|
-
if (!oidc.token_endpoint) {
|
|
214
|
-
throw new AuthenticationError("OIDC discovery returned no token endpoint");
|
|
215
|
-
}
|
|
216
|
-
if (this.currentRefreshToken) {
|
|
217
|
-
const refreshed = await this.tryRefresh(oidc.token_endpoint, this.currentRefreshToken);
|
|
218
|
-
if (refreshed) return refreshed;
|
|
219
|
-
this.currentRefreshToken = null;
|
|
220
|
-
}
|
|
221
|
-
if (!oidc.authorization_endpoint) {
|
|
222
|
-
throw new AuthenticationError("OIDC discovery returned incomplete endpoints");
|
|
223
|
-
}
|
|
224
|
-
const { codeVerifier, codeChallenge } = await generatePkce();
|
|
225
|
-
const state = generateState();
|
|
226
|
-
const authUrl = new URL(oidc.authorization_endpoint);
|
|
227
|
-
authUrl.searchParams.set("client_id", this.clientId);
|
|
228
|
-
authUrl.searchParams.set("redirect_uri", this.redirectUri);
|
|
229
|
-
authUrl.searchParams.set("response_type", "code");
|
|
230
|
-
authUrl.searchParams.set("scope", this.scope);
|
|
231
|
-
authUrl.searchParams.set("code_challenge", codeChallenge);
|
|
232
|
-
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
233
|
-
authUrl.searchParams.set("state", state);
|
|
234
|
-
const result = await this.onAuthorizationUrl(authUrl.toString());
|
|
235
|
-
let code;
|
|
236
|
-
let returnedState = null;
|
|
237
|
-
try {
|
|
238
|
-
const callbackUrl = new URL(result);
|
|
239
|
-
code = callbackUrl.searchParams.get("code") ?? "";
|
|
240
|
-
returnedState = callbackUrl.searchParams.get("state");
|
|
241
|
-
const error = callbackUrl.searchParams.get("error");
|
|
242
|
-
if (error) {
|
|
243
|
-
const description = callbackUrl.searchParams.get("error_description") ?? error;
|
|
244
|
-
throw new AuthenticationError(`Authorization failed: ${description}`);
|
|
245
|
-
}
|
|
246
|
-
} catch (e) {
|
|
247
|
-
if (e instanceof AuthenticationError) throw e;
|
|
248
|
-
code = result;
|
|
249
|
-
}
|
|
250
|
-
if (!code) {
|
|
251
|
-
throw new AuthenticationError("No authorization code received");
|
|
252
|
-
}
|
|
253
|
-
if (returnedState !== null && returnedState !== state) {
|
|
254
|
-
throw new AuthenticationError("State mismatch \u2014 possible CSRF attack");
|
|
255
|
-
}
|
|
256
|
-
const response = await this.fetchFn(oidc.token_endpoint, {
|
|
257
|
-
method: "POST",
|
|
258
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
259
|
-
body: new URLSearchParams({
|
|
260
|
-
grant_type: "authorization_code",
|
|
261
|
-
client_id: this.clientId,
|
|
262
|
-
code,
|
|
263
|
-
redirect_uri: this.redirectUri,
|
|
264
|
-
code_verifier: codeVerifier
|
|
265
|
-
}).toString()
|
|
266
|
-
});
|
|
267
|
-
if (!response.ok) {
|
|
268
|
-
const body = await response.text().catch(() => "");
|
|
269
|
-
throw new AuthenticationError(`Token exchange failed (${response.status}): ${body}`);
|
|
270
|
-
}
|
|
271
|
-
const data = parseTokenResponse(await response.json());
|
|
272
|
-
this.currentRefreshToken = data.refresh_token ?? null;
|
|
273
|
-
return {
|
|
274
|
-
accessToken: data.access_token,
|
|
275
|
-
expiresAt: computeExpiresAt(data.expires_in),
|
|
276
|
-
refreshToken: data.refresh_token
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Try to exchange the stored refresh token for a new access token. Returns the
|
|
281
|
-
* token on success, `null` when the refresh token is definitively rejected
|
|
282
|
-
* (a 4xx — caller should re-authenticate), and throws on transient failures.
|
|
283
|
-
*/
|
|
284
|
-
async tryRefresh(tokenEndpoint, refreshToken) {
|
|
285
|
-
const response = await this.fetchFn(tokenEndpoint, {
|
|
286
|
-
method: "POST",
|
|
287
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
288
|
-
body: new URLSearchParams({
|
|
289
|
-
grant_type: "refresh_token",
|
|
290
|
-
client_id: this.clientId,
|
|
291
|
-
refresh_token: refreshToken
|
|
292
|
-
}).toString()
|
|
293
|
-
});
|
|
294
|
-
if (!response.ok) {
|
|
295
|
-
if (response.status >= 400 && response.status < 500) return null;
|
|
296
|
-
const body = await response.text().catch(() => "");
|
|
297
|
-
throw new AuthenticationError(`Token refresh failed (${response.status}): ${body}`);
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
298
23
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// ../../node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js
|
|
36
|
+
var require_requires_port = __commonJS({
|
|
37
|
+
"../../node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js"(exports, module) {
|
|
38
|
+
"use strict";
|
|
39
|
+
module.exports = function required(port, protocol) {
|
|
40
|
+
protocol = protocol.split(":")[0];
|
|
41
|
+
port = +port;
|
|
42
|
+
if (!port) return false;
|
|
43
|
+
switch (protocol) {
|
|
44
|
+
case "http":
|
|
45
|
+
case "ws":
|
|
46
|
+
return port !== 80;
|
|
47
|
+
case "https":
|
|
48
|
+
case "wss":
|
|
49
|
+
return port !== 443;
|
|
50
|
+
case "ftp":
|
|
51
|
+
return port !== 21;
|
|
52
|
+
case "gopher":
|
|
53
|
+
return port !== 70;
|
|
54
|
+
case "file":
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return port !== 0;
|
|
58
|
+
};
|
|
302
59
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
clientId;
|
|
318
|
-
issuerUrl;
|
|
319
|
-
fetchFn;
|
|
320
|
-
type = "oauth2-refresh-token";
|
|
321
|
-
currentRefreshToken;
|
|
322
|
-
async getToken() {
|
|
323
|
-
const oidc = await discoverOidc(this.issuerUrl, this.fetchFn);
|
|
324
|
-
if (!oidc.token_endpoint) {
|
|
325
|
-
throw new AuthenticationError("OIDC discovery returned no token endpoint");
|
|
326
|
-
}
|
|
327
|
-
const response = await this.fetchFn(oidc.token_endpoint, {
|
|
328
|
-
method: "POST",
|
|
329
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
330
|
-
body: new URLSearchParams({
|
|
331
|
-
grant_type: "refresh_token",
|
|
332
|
-
client_id: this.clientId,
|
|
333
|
-
refresh_token: this.currentRefreshToken
|
|
334
|
-
}).toString()
|
|
335
|
-
});
|
|
336
|
-
if (!response.ok) {
|
|
337
|
-
const body = await response.text().catch(() => "");
|
|
338
|
-
if (response.status === 400) {
|
|
339
|
-
throw new AuthenticationError("Refresh token is invalid or expired. Please re-authenticate.");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js
|
|
63
|
+
var require_querystringify = __commonJS({
|
|
64
|
+
"../../node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js"(exports) {
|
|
65
|
+
"use strict";
|
|
66
|
+
var has = Object.prototype.hasOwnProperty;
|
|
67
|
+
var undef;
|
|
68
|
+
function decode2(input) {
|
|
69
|
+
try {
|
|
70
|
+
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
340
74
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
75
|
+
function encode2(input) {
|
|
76
|
+
try {
|
|
77
|
+
return encodeURIComponent(input);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function querystring(query) {
|
|
83
|
+
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
84
|
+
while (part = parser.exec(query)) {
|
|
85
|
+
var key = decode2(part[1]), value = decode2(part[2]);
|
|
86
|
+
if (key === null || value === null || key in result) continue;
|
|
87
|
+
result[key] = value;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
function querystringify(obj, prefix) {
|
|
92
|
+
prefix = prefix || "";
|
|
93
|
+
var pairs = [], value, key;
|
|
94
|
+
if ("string" !== typeof prefix) prefix = "?";
|
|
95
|
+
for (key in obj) {
|
|
96
|
+
if (has.call(obj, key)) {
|
|
97
|
+
value = obj[key];
|
|
98
|
+
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
99
|
+
value = "";
|
|
100
|
+
}
|
|
101
|
+
key = encode2(key);
|
|
102
|
+
value = encode2(value);
|
|
103
|
+
if (key === null || value === null) continue;
|
|
104
|
+
pairs.push(key + "=" + value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return pairs.length ? prefix + pairs.join("&") : "";
|
|
108
|
+
}
|
|
109
|
+
exports.stringify = querystringify;
|
|
110
|
+
exports.parse = querystring;
|
|
346
111
|
}
|
|
347
|
-
|
|
348
|
-
accessToken: data.access_token,
|
|
349
|
-
expiresAt: computeExpiresAt(data.expires_in),
|
|
350
|
-
refreshToken: data.refresh_token ?? this.currentRefreshToken
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
var BearerTokenProvider = class {
|
|
355
|
-
constructor(token) {
|
|
356
|
-
this.token = token;
|
|
357
|
-
}
|
|
358
|
-
token;
|
|
359
|
-
type = "bearer";
|
|
360
|
-
getToken() {
|
|
361
|
-
return Promise.resolve({ accessToken: this.token, expiresAt: null });
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
var DEFAULT_IDP_ISSUER_URL = "https://idp.gigadrive.de";
|
|
365
|
-
var DEFAULT_BASE_URL = "https://api.gigadrive.network";
|
|
366
|
-
var resolveCredentialProvider = (config) => {
|
|
367
|
-
const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
368
|
-
const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL;
|
|
369
|
-
const idpIssuerUrl = config.idpIssuerUrl ?? readEnv("GIGADRIVE_IDP_ISSUER_URL") ?? DEFAULT_IDP_ISSUER_URL;
|
|
370
|
-
const tokenUrl = `${baseUrl}/oauth2/token`;
|
|
371
|
-
if (config.bearerToken) {
|
|
372
|
-
return new BearerTokenProvider(config.bearerToken);
|
|
373
|
-
}
|
|
374
|
-
if (config.clientId && config.clientSecret) {
|
|
375
|
-
return new OAuth2ClientCredentialProvider(config.clientId, config.clientSecret, tokenUrl, fetchFn);
|
|
376
|
-
}
|
|
377
|
-
if (config.refreshToken && config.clientId) {
|
|
378
|
-
return new OAuth2RefreshTokenProvider(config.clientId, config.refreshToken, idpIssuerUrl, fetchFn);
|
|
379
|
-
}
|
|
380
|
-
if (config.onAuthorizationUrl && config.clientId) {
|
|
381
|
-
const redirectUri = config.redirectUri ?? "urn:ietf:wg:oauth:2.0:oob";
|
|
382
|
-
const scope = config.scopes && config.scopes.length > 0 ? config.scopes.join(" ") : DEFAULT_SCOPE;
|
|
383
|
-
return new OAuth2AuthorizationCodeProvider(
|
|
384
|
-
config.clientId,
|
|
385
|
-
idpIssuerUrl,
|
|
386
|
-
redirectUri,
|
|
387
|
-
config.onAuthorizationUrl,
|
|
388
|
-
fetchFn,
|
|
389
|
-
scope
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
const envBearerToken = readEnv("GIGADRIVE_BEARER_TOKEN");
|
|
393
|
-
if (envBearerToken) {
|
|
394
|
-
return new BearerTokenProvider(envBearerToken);
|
|
395
|
-
}
|
|
396
|
-
const envClientId = readEnv("GIGADRIVE_CLIENT_ID");
|
|
397
|
-
const envClientSecret = readEnv("GIGADRIVE_CLIENT_SECRET");
|
|
398
|
-
if (envClientId && envClientSecret) {
|
|
399
|
-
return new OAuth2ClientCredentialProvider(envClientId, envClientSecret, tokenUrl, fetchFn);
|
|
400
|
-
}
|
|
401
|
-
const envRefreshToken = readEnv("GIGADRIVE_REFRESH_TOKEN");
|
|
402
|
-
if (envRefreshToken && envClientId) {
|
|
403
|
-
return new OAuth2RefreshTokenProvider(envClientId, envRefreshToken, idpIssuerUrl, fetchFn);
|
|
404
|
-
}
|
|
405
|
-
throw new AuthenticationError(
|
|
406
|
-
"No credentials provided. Set one of:\n - GIGADRIVE_BEARER_TOKEN\n - GIGADRIVE_CLIENT_ID + GIGADRIVE_CLIENT_SECRET\n - GIGADRIVE_REFRESH_TOKEN + GIGADRIVE_CLIENT_ID\nOr pass credentials directly to the GigadriveClient constructor."
|
|
407
|
-
);
|
|
408
|
-
};
|
|
112
|
+
});
|
|
409
113
|
|
|
410
|
-
//
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
114
|
+
// ../../node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js
|
|
115
|
+
var require_url_parse = __commonJS({
|
|
116
|
+
"../../node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js"(exports, module) {
|
|
117
|
+
"use strict";
|
|
118
|
+
var required = require_requires_port();
|
|
119
|
+
var qs = require_querystringify();
|
|
120
|
+
var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
|
121
|
+
var CRHTLF = /[\n\r\t]/g;
|
|
122
|
+
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
|
|
123
|
+
var port = /:\d+$/;
|
|
124
|
+
var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i;
|
|
125
|
+
var windowsDriveLetter = /^[a-zA-Z]:/;
|
|
126
|
+
function trimLeft(str) {
|
|
127
|
+
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
128
|
+
}
|
|
129
|
+
var rules = [
|
|
130
|
+
["#", "hash"],
|
|
131
|
+
// Extract from the back.
|
|
132
|
+
["?", "query"],
|
|
133
|
+
// Extract from the back.
|
|
134
|
+
function sanitize(address, url) {
|
|
135
|
+
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
136
|
+
},
|
|
137
|
+
["/", "pathname"],
|
|
138
|
+
// Extract from the back.
|
|
139
|
+
["@", "auth", 1],
|
|
140
|
+
// Extract from the front.
|
|
141
|
+
[NaN, "host", void 0, 1, 1],
|
|
142
|
+
// Set left over value.
|
|
143
|
+
[/:(\d*)$/, "port", void 0, 1],
|
|
144
|
+
// RegExp the back.
|
|
145
|
+
[NaN, "hostname", void 0, 1, 1]
|
|
146
|
+
// Set left over.
|
|
147
|
+
];
|
|
148
|
+
var ignore = { hash: 1, query: 1 };
|
|
149
|
+
function lolcation(loc) {
|
|
150
|
+
var globalVar;
|
|
151
|
+
if (typeof window !== "undefined") globalVar = window;
|
|
152
|
+
else if (typeof global !== "undefined") globalVar = global;
|
|
153
|
+
else if (typeof self !== "undefined") globalVar = self;
|
|
154
|
+
else globalVar = {};
|
|
155
|
+
var location = globalVar.location || {};
|
|
156
|
+
loc = loc || location;
|
|
157
|
+
var finaldestination = {}, type = typeof loc, key;
|
|
158
|
+
if ("blob:" === loc.protocol) {
|
|
159
|
+
finaldestination = new Url(unescape(loc.pathname), {});
|
|
160
|
+
} else if ("string" === type) {
|
|
161
|
+
finaldestination = new Url(loc, {});
|
|
162
|
+
for (key in ignore) delete finaldestination[key];
|
|
163
|
+
} else if ("object" === type) {
|
|
164
|
+
for (key in loc) {
|
|
165
|
+
if (key in ignore) continue;
|
|
166
|
+
finaldestination[key] = loc[key];
|
|
167
|
+
}
|
|
168
|
+
if (finaldestination.slashes === void 0) {
|
|
169
|
+
finaldestination.slashes = slashes.test(loc.href);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return finaldestination;
|
|
173
|
+
}
|
|
174
|
+
function isSpecial(scheme) {
|
|
175
|
+
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
176
|
+
}
|
|
177
|
+
function extractProtocol(address, location) {
|
|
178
|
+
address = trimLeft(address);
|
|
179
|
+
address = address.replace(CRHTLF, "");
|
|
180
|
+
location = location || {};
|
|
181
|
+
var match = protocolre.exec(address);
|
|
182
|
+
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
183
|
+
var forwardSlashes = !!match[2];
|
|
184
|
+
var otherSlashes = !!match[3];
|
|
185
|
+
var slashesCount = 0;
|
|
186
|
+
var rest;
|
|
187
|
+
if (forwardSlashes) {
|
|
188
|
+
if (otherSlashes) {
|
|
189
|
+
rest = match[2] + match[3] + match[4];
|
|
190
|
+
slashesCount = match[2].length + match[3].length;
|
|
191
|
+
} else {
|
|
192
|
+
rest = match[2] + match[4];
|
|
193
|
+
slashesCount = match[2].length;
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
if (otherSlashes) {
|
|
197
|
+
rest = match[3] + match[4];
|
|
198
|
+
slashesCount = match[3].length;
|
|
199
|
+
} else {
|
|
200
|
+
rest = match[4];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (protocol === "file:") {
|
|
204
|
+
if (slashesCount >= 2) {
|
|
205
|
+
rest = rest.slice(2);
|
|
206
|
+
}
|
|
207
|
+
} else if (isSpecial(protocol)) {
|
|
208
|
+
rest = match[4];
|
|
209
|
+
} else if (protocol) {
|
|
210
|
+
if (forwardSlashes) {
|
|
211
|
+
rest = rest.slice(2);
|
|
212
|
+
}
|
|
213
|
+
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
214
|
+
rest = match[4];
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
protocol,
|
|
218
|
+
slashes: forwardSlashes || isSpecial(protocol),
|
|
219
|
+
slashesCount,
|
|
220
|
+
rest
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function resolve2(relative, base) {
|
|
224
|
+
if (relative === "") return base;
|
|
225
|
+
var path2 = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path2.length, last = path2[i - 1], unshift = false, up = 0;
|
|
226
|
+
while (i--) {
|
|
227
|
+
if (path2[i] === ".") {
|
|
228
|
+
path2.splice(i, 1);
|
|
229
|
+
} else if (path2[i] === "..") {
|
|
230
|
+
path2.splice(i, 1);
|
|
231
|
+
up++;
|
|
232
|
+
} else if (up) {
|
|
233
|
+
if (i === 0) unshift = true;
|
|
234
|
+
path2.splice(i, 1);
|
|
235
|
+
up--;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (unshift) path2.unshift("");
|
|
239
|
+
if (last === "." || last === "..") path2.push("");
|
|
240
|
+
return path2.join("/");
|
|
241
|
+
}
|
|
242
|
+
function Url(address, location, parser) {
|
|
243
|
+
address = trimLeft(address);
|
|
244
|
+
address = address.replace(CRHTLF, "");
|
|
245
|
+
if (!(this instanceof Url)) {
|
|
246
|
+
return new Url(address, location, parser);
|
|
247
|
+
}
|
|
248
|
+
var relative, extracted, parse2, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
249
|
+
if ("object" !== type && "string" !== type) {
|
|
250
|
+
parser = location;
|
|
251
|
+
location = null;
|
|
252
|
+
}
|
|
253
|
+
if (parser && "function" !== typeof parser) parser = qs.parse;
|
|
254
|
+
location = lolcation(location);
|
|
255
|
+
extracted = extractProtocol(address || "", location);
|
|
256
|
+
relative = !extracted.protocol && !extracted.slashes;
|
|
257
|
+
url.slashes = extracted.slashes || relative && location.slashes;
|
|
258
|
+
url.protocol = extracted.protocol || location.protocol || "";
|
|
259
|
+
address = extracted.rest;
|
|
260
|
+
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
261
|
+
instructions[3] = [/(.*)/, "pathname"];
|
|
262
|
+
}
|
|
263
|
+
for (; i < instructions.length; i++) {
|
|
264
|
+
instruction = instructions[i];
|
|
265
|
+
if (typeof instruction === "function") {
|
|
266
|
+
address = instruction(address, url);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
parse2 = instruction[0];
|
|
270
|
+
key = instruction[1];
|
|
271
|
+
if (parse2 !== parse2) {
|
|
272
|
+
url[key] = address;
|
|
273
|
+
} else if ("string" === typeof parse2) {
|
|
274
|
+
index = parse2 === "@" ? address.lastIndexOf(parse2) : address.indexOf(parse2);
|
|
275
|
+
if (~index) {
|
|
276
|
+
if ("number" === typeof instruction[2]) {
|
|
277
|
+
url[key] = address.slice(0, index);
|
|
278
|
+
address = address.slice(index + instruction[2]);
|
|
279
|
+
} else {
|
|
280
|
+
url[key] = address.slice(index);
|
|
281
|
+
address = address.slice(0, index);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} else if (index = parse2.exec(address)) {
|
|
285
|
+
url[key] = index[1];
|
|
286
|
+
address = address.slice(0, index.index);
|
|
287
|
+
}
|
|
288
|
+
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
289
|
+
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
290
|
+
}
|
|
291
|
+
if (parser) url.query = parser(url.query);
|
|
292
|
+
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
293
|
+
url.pathname = resolve2(url.pathname, location.pathname);
|
|
294
|
+
}
|
|
295
|
+
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
296
|
+
url.pathname = "/" + url.pathname;
|
|
297
|
+
}
|
|
298
|
+
if (!required(url.port, url.protocol)) {
|
|
299
|
+
url.host = url.hostname;
|
|
300
|
+
url.port = "";
|
|
301
|
+
}
|
|
302
|
+
url.username = url.password = "";
|
|
303
|
+
if (url.auth) {
|
|
304
|
+
index = url.auth.indexOf(":");
|
|
305
|
+
if (~index) {
|
|
306
|
+
url.username = url.auth.slice(0, index);
|
|
307
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
308
|
+
url.password = url.auth.slice(index + 1);
|
|
309
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
310
|
+
} else {
|
|
311
|
+
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
312
|
+
}
|
|
313
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
314
|
+
}
|
|
315
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
316
|
+
url.href = url.toString();
|
|
317
|
+
}
|
|
318
|
+
function set(part, value, fn) {
|
|
319
|
+
var url = this;
|
|
320
|
+
switch (part) {
|
|
321
|
+
case "query":
|
|
322
|
+
if ("string" === typeof value && value.length) {
|
|
323
|
+
value = (fn || qs.parse)(value);
|
|
324
|
+
}
|
|
325
|
+
url[part] = value;
|
|
326
|
+
break;
|
|
327
|
+
case "port":
|
|
328
|
+
url[part] = value;
|
|
329
|
+
if (!required(value, url.protocol)) {
|
|
330
|
+
url.host = url.hostname;
|
|
331
|
+
url[part] = "";
|
|
332
|
+
} else if (value) {
|
|
333
|
+
url.host = url.hostname + ":" + value;
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
case "hostname":
|
|
337
|
+
url[part] = value;
|
|
338
|
+
if (url.port) value += ":" + url.port;
|
|
339
|
+
url.host = value;
|
|
340
|
+
break;
|
|
341
|
+
case "host":
|
|
342
|
+
url[part] = value;
|
|
343
|
+
if (port.test(value)) {
|
|
344
|
+
value = value.split(":");
|
|
345
|
+
url.port = value.pop();
|
|
346
|
+
url.hostname = value.join(":");
|
|
347
|
+
} else {
|
|
348
|
+
url.hostname = value;
|
|
349
|
+
url.port = "";
|
|
350
|
+
}
|
|
351
|
+
break;
|
|
352
|
+
case "protocol":
|
|
353
|
+
url.protocol = value.toLowerCase();
|
|
354
|
+
url.slashes = !fn;
|
|
355
|
+
break;
|
|
356
|
+
case "pathname":
|
|
357
|
+
case "hash":
|
|
358
|
+
if (value) {
|
|
359
|
+
var char = part === "pathname" ? "/" : "#";
|
|
360
|
+
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
361
|
+
} else {
|
|
362
|
+
url[part] = value;
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
case "username":
|
|
366
|
+
case "password":
|
|
367
|
+
url[part] = encodeURIComponent(value);
|
|
368
|
+
break;
|
|
369
|
+
case "auth":
|
|
370
|
+
var index = value.indexOf(":");
|
|
371
|
+
if (~index) {
|
|
372
|
+
url.username = value.slice(0, index);
|
|
373
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
374
|
+
url.password = value.slice(index + 1);
|
|
375
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
376
|
+
} else {
|
|
377
|
+
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
for (var i = 0; i < rules.length; i++) {
|
|
381
|
+
var ins = rules[i];
|
|
382
|
+
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
383
|
+
}
|
|
384
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
385
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
386
|
+
url.href = url.toString();
|
|
387
|
+
return url;
|
|
388
|
+
}
|
|
389
|
+
function toString(stringify) {
|
|
390
|
+
if (!stringify || "function" !== typeof stringify) stringify = qs.stringify;
|
|
391
|
+
var query, url = this, host = url.host, protocol = url.protocol;
|
|
392
|
+
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
|
|
393
|
+
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
394
|
+
if (url.username) {
|
|
395
|
+
result += url.username;
|
|
396
|
+
if (url.password) result += ":" + url.password;
|
|
397
|
+
result += "@";
|
|
398
|
+
} else if (url.password) {
|
|
399
|
+
result += ":" + url.password;
|
|
400
|
+
result += "@";
|
|
401
|
+
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
|
|
402
|
+
result += "@";
|
|
403
|
+
}
|
|
404
|
+
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
|
|
405
|
+
host += ":";
|
|
406
|
+
}
|
|
407
|
+
result += host + url.pathname;
|
|
408
|
+
query = "object" === typeof url.query ? stringify(url.query) : url.query;
|
|
409
|
+
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
|
|
410
|
+
if (url.hash) result += url.hash;
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
Url.prototype = { set, toString };
|
|
414
|
+
Url.extractProtocol = extractProtocol;
|
|
415
|
+
Url.location = lolcation;
|
|
416
|
+
Url.trimLeft = trimLeft;
|
|
417
|
+
Url.qs = qs;
|
|
418
|
+
module.exports = Url;
|
|
437
419
|
}
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Invalidates the cached token. The next `getToken()` call will trigger a refresh.
|
|
441
|
-
*/
|
|
442
|
-
invalidate() {
|
|
443
|
-
this.cachedToken = null;
|
|
444
|
-
this.expiresAt = null;
|
|
445
|
-
}
|
|
446
|
-
async refresh() {
|
|
447
|
-
const result = await this.provider.getToken();
|
|
448
|
-
this.cachedToken = result.accessToken;
|
|
449
|
-
this.expiresAt = result.expiresAt;
|
|
450
|
-
return result.accessToken;
|
|
451
|
-
}
|
|
452
|
-
};
|
|
420
|
+
});
|
|
453
421
|
|
|
454
|
-
//
|
|
455
|
-
var
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
tokenManager;
|
|
465
|
-
fetchFn;
|
|
466
|
-
/** @internal */
|
|
467
|
-
async get(path, options) {
|
|
468
|
-
return this.request("GET", path, options);
|
|
469
|
-
}
|
|
470
|
-
/** @internal */
|
|
471
|
-
async post(path, body, options) {
|
|
472
|
-
return this.request("POST", path, { body, ...options });
|
|
473
|
-
}
|
|
474
|
-
/** @internal */
|
|
475
|
-
async put(path, body, options) {
|
|
476
|
-
return this.request("PUT", path, { body, ...options });
|
|
477
|
-
}
|
|
478
|
-
/** @internal */
|
|
479
|
-
async patch(path, body, options) {
|
|
480
|
-
return this.request("PATCH", path, { body, ...options });
|
|
481
|
-
}
|
|
482
|
-
/** @internal */
|
|
483
|
-
async delete(path, options) {
|
|
484
|
-
return this.request("DELETE", path, options);
|
|
485
|
-
}
|
|
486
|
-
/** @internal */
|
|
487
|
-
async postRaw(path, body, headers) {
|
|
488
|
-
return this.request("POST", path, { body, headers });
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Make an authenticated request and return the raw `Response` without parsing
|
|
492
|
-
* the body. Used for streamed (SSE) and binary responses.
|
|
493
|
-
*
|
|
494
|
-
* @throws {@link ApiError} if the response status is not OK.
|
|
495
|
-
* @internal
|
|
496
|
-
*/
|
|
497
|
-
async requestStream(method, path, options) {
|
|
498
|
-
const response = await this.fetchWithAuth(method, path, options);
|
|
499
|
-
if (!response.ok) {
|
|
500
|
-
throw await this.toApiError(response);
|
|
501
|
-
}
|
|
502
|
-
return response;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Make a raw fetch request to an arbitrary URL (e.g. presigned upload URLs
|
|
506
|
-
* or resumable upload endpoints). No auth header is injected and the base URL
|
|
507
|
-
* is not prepended.
|
|
508
|
-
*
|
|
509
|
-
* @param url - The full URL to fetch.
|
|
510
|
-
* @param init - Standard `RequestInit` options.
|
|
511
|
-
* @returns The raw `Response` object.
|
|
512
|
-
* @throws {@link ApiError} if the response status is not OK.
|
|
513
|
-
*
|
|
514
|
-
* @internal
|
|
515
|
-
*/
|
|
516
|
-
async fetchRaw(url, init) {
|
|
517
|
-
const response = await this.fetchFn(url, init);
|
|
518
|
-
if (!response.ok) {
|
|
519
|
-
throw new ApiError(response.statusText, response.status);
|
|
422
|
+
// ../../node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js
|
|
423
|
+
var require_is_stream = __commonJS({
|
|
424
|
+
"../../node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js"(exports, module) {
|
|
425
|
+
"use strict";
|
|
426
|
+
var isStream2 = (stream) => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
|
|
427
|
+
isStream2.writable = (stream) => isStream2(stream) && stream.writable !== false && typeof stream._write === "function" && typeof stream._writableState === "object";
|
|
428
|
+
isStream2.readable = (stream) => isStream2(stream) && stream.readable !== false && typeof stream._read === "function" && typeof stream._readableState === "object";
|
|
429
|
+
isStream2.duplex = (stream) => isStream2.writable(stream) && isStream2.readable(stream);
|
|
430
|
+
isStream2.transform = (stream) => isStream2.duplex(stream) && typeof stream._transform === "function";
|
|
431
|
+
module.exports = isStream2;
|
|
520
432
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// ../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
|
|
436
|
+
var require_lodash = __commonJS({
|
|
437
|
+
"../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module) {
|
|
438
|
+
"use strict";
|
|
439
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
440
|
+
var NAN = 0 / 0;
|
|
441
|
+
var symbolTag = "[object Symbol]";
|
|
442
|
+
var reTrim = /^\s+|\s+$/g;
|
|
443
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
444
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
445
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
446
|
+
var freeParseInt = parseInt;
|
|
447
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
448
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
449
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
450
|
+
var objectProto = Object.prototype;
|
|
451
|
+
var objectToString = objectProto.toString;
|
|
452
|
+
var nativeMax = Math.max;
|
|
453
|
+
var nativeMin = Math.min;
|
|
454
|
+
var now = function() {
|
|
455
|
+
return root.Date.now();
|
|
456
|
+
};
|
|
457
|
+
function debounce(func, wait, options) {
|
|
458
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
459
|
+
if (typeof func != "function") {
|
|
460
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
461
|
+
}
|
|
462
|
+
wait = toNumber(wait) || 0;
|
|
463
|
+
if (isObject(options)) {
|
|
464
|
+
leading = !!options.leading;
|
|
465
|
+
maxing = "maxWait" in options;
|
|
466
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
467
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
468
|
+
}
|
|
469
|
+
function invokeFunc(time) {
|
|
470
|
+
var args = lastArgs, thisArg = lastThis;
|
|
471
|
+
lastArgs = lastThis = void 0;
|
|
472
|
+
lastInvokeTime = time;
|
|
473
|
+
result = func.apply(thisArg, args);
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
function leadingEdge(time) {
|
|
477
|
+
lastInvokeTime = time;
|
|
478
|
+
timerId = setTimeout(timerExpired, wait);
|
|
479
|
+
return leading ? invokeFunc(time) : result;
|
|
480
|
+
}
|
|
481
|
+
function remainingWait(time) {
|
|
482
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
|
|
483
|
+
return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
|
|
484
|
+
}
|
|
485
|
+
function shouldInvoke(time) {
|
|
486
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
|
487
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
488
|
+
}
|
|
489
|
+
function timerExpired() {
|
|
490
|
+
var time = now();
|
|
491
|
+
if (shouldInvoke(time)) {
|
|
492
|
+
return trailingEdge(time);
|
|
493
|
+
}
|
|
494
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
495
|
+
}
|
|
496
|
+
function trailingEdge(time) {
|
|
497
|
+
timerId = void 0;
|
|
498
|
+
if (trailing && lastArgs) {
|
|
499
|
+
return invokeFunc(time);
|
|
500
|
+
}
|
|
501
|
+
lastArgs = lastThis = void 0;
|
|
502
|
+
return result;
|
|
503
|
+
}
|
|
504
|
+
function cancel() {
|
|
505
|
+
if (timerId !== void 0) {
|
|
506
|
+
clearTimeout(timerId);
|
|
507
|
+
}
|
|
508
|
+
lastInvokeTime = 0;
|
|
509
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
510
|
+
}
|
|
511
|
+
function flush() {
|
|
512
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
513
|
+
}
|
|
514
|
+
function debounced() {
|
|
515
|
+
var time = now(), isInvoking = shouldInvoke(time);
|
|
516
|
+
lastArgs = arguments;
|
|
517
|
+
lastThis = this;
|
|
518
|
+
lastCallTime = time;
|
|
519
|
+
if (isInvoking) {
|
|
520
|
+
if (timerId === void 0) {
|
|
521
|
+
return leadingEdge(lastCallTime);
|
|
522
|
+
}
|
|
523
|
+
if (maxing) {
|
|
524
|
+
timerId = setTimeout(timerExpired, wait);
|
|
525
|
+
return invokeFunc(lastCallTime);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (timerId === void 0) {
|
|
529
|
+
timerId = setTimeout(timerExpired, wait);
|
|
530
|
+
}
|
|
531
|
+
return result;
|
|
543
532
|
}
|
|
533
|
+
debounced.cancel = cancel;
|
|
534
|
+
debounced.flush = flush;
|
|
535
|
+
return debounced;
|
|
544
536
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
537
|
+
function throttle2(func, wait, options) {
|
|
538
|
+
var leading = true, trailing = true;
|
|
539
|
+
if (typeof func != "function") {
|
|
540
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
541
|
+
}
|
|
542
|
+
if (isObject(options)) {
|
|
543
|
+
leading = "leading" in options ? !!options.leading : leading;
|
|
544
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
545
|
+
}
|
|
546
|
+
return debounce(func, wait, {
|
|
547
|
+
"leading": leading,
|
|
548
|
+
"maxWait": wait,
|
|
549
|
+
"trailing": trailing
|
|
550
|
+
});
|
|
556
551
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
async handleResponse(response) {
|
|
562
|
-
if (response.ok) {
|
|
563
|
-
if (response.status === 204) {
|
|
564
|
-
return void 0;
|
|
552
|
+
function isObject(value) {
|
|
553
|
+
var type = typeof value;
|
|
554
|
+
return !!value && (type == "object" || type == "function");
|
|
565
555
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return void 0;
|
|
556
|
+
function isObjectLike(value) {
|
|
557
|
+
return !!value && typeof value == "object";
|
|
569
558
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
throw await this.toApiError(response);
|
|
573
|
-
}
|
|
574
|
-
async toApiError(response) {
|
|
575
|
-
let message;
|
|
576
|
-
let code;
|
|
577
|
-
try {
|
|
578
|
-
const body = await response.json();
|
|
579
|
-
if (typeof body.error === "string") {
|
|
580
|
-
message = body.error;
|
|
581
|
-
} else if (body.error && typeof body.error === "object") {
|
|
582
|
-
message = body.error.message ?? response.statusText;
|
|
583
|
-
code = body.error.code;
|
|
584
|
-
} else {
|
|
585
|
-
message = response.statusText;
|
|
559
|
+
function isSymbol(value) {
|
|
560
|
+
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
586
561
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
562
|
+
function toNumber(value) {
|
|
563
|
+
if (typeof value == "number") {
|
|
564
|
+
return value;
|
|
565
|
+
}
|
|
566
|
+
if (isSymbol(value)) {
|
|
567
|
+
return NAN;
|
|
568
|
+
}
|
|
569
|
+
if (isObject(value)) {
|
|
570
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
571
|
+
value = isObject(other) ? other + "" : other;
|
|
572
|
+
}
|
|
573
|
+
if (typeof value != "string") {
|
|
574
|
+
return value === 0 ? value : +value;
|
|
575
|
+
}
|
|
576
|
+
value = value.replace(reTrim, "");
|
|
577
|
+
var isBinary = reIsBinary.test(value);
|
|
578
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
599
579
|
}
|
|
580
|
+
module.exports = throttle2;
|
|
600
581
|
}
|
|
601
|
-
|
|
602
|
-
return qs ? `${url}?${qs}` : url;
|
|
603
|
-
}
|
|
604
|
-
};
|
|
582
|
+
});
|
|
605
583
|
|
|
606
|
-
//
|
|
607
|
-
var
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
584
|
+
// ../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/bin/factories.js
|
|
585
|
+
var require_factories = __commonJS({
|
|
586
|
+
"../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/bin/factories.js"(exports) {
|
|
587
|
+
"use strict";
|
|
588
|
+
exports.expectReceive = function(properties, configuration, factory) {
|
|
589
|
+
var message;
|
|
590
|
+
factory.root(properties, configuration, factory);
|
|
591
|
+
message = this.message;
|
|
592
|
+
if (properties.hasOwnProperty("expected")) message += " Expected " + properties.expected + ".";
|
|
593
|
+
if (properties.hasOwnProperty("received")) message += " Received: " + properties.received + ".";
|
|
594
|
+
this.message = message;
|
|
595
|
+
};
|
|
596
|
+
exports.root = function(properties, configuration, factories) {
|
|
597
|
+
var _this = this;
|
|
598
|
+
var code;
|
|
599
|
+
var config = { stackLength: Error.stackTraceLimit, rootOnly: true };
|
|
600
|
+
var messageStr = "";
|
|
601
|
+
var originalStackLength = Error.stackTraceLimit;
|
|
602
|
+
var stack;
|
|
603
|
+
function updateStack() {
|
|
604
|
+
stack[0] = _this.toString();
|
|
605
|
+
_this.stack = stack.join("\n");
|
|
606
|
+
}
|
|
607
|
+
if (!configuration || typeof configuration !== "object") configuration = {};
|
|
608
|
+
if (configuration.hasOwnProperty("stackLength") && typeof configuration.stackLength === "number" && !isNaN(configuration.stackLength) && configuration.stackLength >= 0) config.stackLength = configuration.stackLength;
|
|
609
|
+
if (!configuration.hasOwnProperty("rootOnly")) config.rootOnly = configuration.rootOnly;
|
|
610
|
+
if (!config.rootOnly || this.CustomError.parent === Error) {
|
|
611
|
+
Object.keys(properties).forEach(function(key) {
|
|
612
|
+
switch (key) {
|
|
613
|
+
case "code":
|
|
614
|
+
code = properties.code || void 0;
|
|
615
|
+
break;
|
|
616
|
+
case "message":
|
|
617
|
+
messageStr = properties.message || "";
|
|
618
|
+
break;
|
|
619
|
+
default:
|
|
620
|
+
_this[key] = properties[key];
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
Error.stackTraceLimit = config.stackLength + 2;
|
|
624
|
+
stack = new Error().stack.split("\n");
|
|
625
|
+
stack.splice(0, 3);
|
|
626
|
+
stack.unshift("");
|
|
627
|
+
Error.stackTraceLimit = originalStackLength;
|
|
628
|
+
this.stack = stack.join("\n");
|
|
629
|
+
Object.defineProperty(this, "code", {
|
|
630
|
+
configurable: true,
|
|
631
|
+
enumerable: true,
|
|
632
|
+
get: function() {
|
|
633
|
+
return code;
|
|
634
|
+
},
|
|
635
|
+
set: function(value) {
|
|
636
|
+
code = value;
|
|
637
|
+
updateStack();
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
Object.defineProperty(this, "message", {
|
|
641
|
+
configurable: true,
|
|
642
|
+
enumerable: true,
|
|
643
|
+
get: function() {
|
|
644
|
+
return messageStr;
|
|
645
|
+
},
|
|
646
|
+
set: function(value) {
|
|
647
|
+
messageStr = value;
|
|
648
|
+
updateStack();
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
updateStack();
|
|
652
|
+
}
|
|
653
|
+
};
|
|
646
654
|
}
|
|
647
|
-
};
|
|
648
|
-
try {
|
|
649
|
-
for (; ; ) {
|
|
650
|
-
const { done, value } = await reader.read();
|
|
651
|
-
if (done) break;
|
|
652
|
-
buffer = (buffer + decoder.decode(value, { stream: true })).replace(/\r\n/g, "\n");
|
|
653
|
-
yield* drain(false);
|
|
654
|
-
}
|
|
655
|
-
yield* drain(true);
|
|
656
|
-
} finally {
|
|
657
|
-
await reader.cancel().catch(() => void 0);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
655
|
+
});
|
|
660
656
|
|
|
661
|
-
//
|
|
662
|
-
var
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
657
|
+
// ../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/bin/error.js
|
|
658
|
+
var require_error = __commonJS({
|
|
659
|
+
"../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/bin/error.js"(exports, module) {
|
|
660
|
+
"use strict";
|
|
661
|
+
module.exports = CustomError;
|
|
662
|
+
CustomError.factory = require_factories();
|
|
663
|
+
var Err = CustomError("CustomError");
|
|
664
|
+
Err.order = CustomError(Err, { message: "Arguments out of order.", code: "EOARG" });
|
|
665
|
+
function CustomError(name, parent, properties, factory) {
|
|
666
|
+
var construct;
|
|
667
|
+
var isRoot;
|
|
668
|
+
parent = findArg(arguments, 1, Error, isParentArg, [isPropertiesArg, isFactoryArg]);
|
|
669
|
+
properties = findArg(arguments, 2, {}, isPropertiesArg, [isFactoryArg]);
|
|
670
|
+
factory = findArg(arguments, 3, noop, isFactoryArg, []);
|
|
671
|
+
name = findArg(arguments, 0, parent === Error ? "Error" : parent.prototype.CustomError.name, isNameArg, [isParentArg, isPropertiesArg, isFactoryArg]);
|
|
672
|
+
isRoot = parent === Error;
|
|
673
|
+
if (isRoot && factory === noop) factory = CustomError.factory.root;
|
|
674
|
+
construct = function(message, configuration) {
|
|
675
|
+
var _this;
|
|
676
|
+
var ar;
|
|
677
|
+
var factories;
|
|
678
|
+
var i;
|
|
679
|
+
var item;
|
|
680
|
+
var props;
|
|
681
|
+
if (!(this instanceof construct)) return new construct(message, configuration);
|
|
682
|
+
delete this.constructor.name;
|
|
683
|
+
Object.defineProperty(this.constructor, "name", {
|
|
684
|
+
enumerable: false,
|
|
685
|
+
configurable: true,
|
|
686
|
+
value: name,
|
|
687
|
+
writable: false
|
|
688
|
+
});
|
|
689
|
+
if (typeof message === "string") message = { message };
|
|
690
|
+
if (!message) message = {};
|
|
691
|
+
ar = this.CustomError.chain.slice(0).reverse().map(function(value) {
|
|
692
|
+
return value.properties;
|
|
693
|
+
});
|
|
694
|
+
ar.push(message);
|
|
695
|
+
ar.unshift({});
|
|
696
|
+
props = Object.assign.apply(Object, ar);
|
|
697
|
+
_this = this;
|
|
698
|
+
factories = {};
|
|
699
|
+
Object.keys(CustomError.factory).forEach(function(key) {
|
|
700
|
+
factories[key] = function(props2, config) {
|
|
701
|
+
CustomError.factory[key].call(_this, props2, config, factories);
|
|
702
|
+
};
|
|
703
|
+
});
|
|
704
|
+
for (i = this.CustomError.chain.length - 1; i >= 0; i--) {
|
|
705
|
+
item = this.CustomError.chain[i];
|
|
706
|
+
if (item.factory !== noop) {
|
|
707
|
+
item.factory.call(this, props, configuration, factories);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
construct.prototype = Object.create(parent.prototype);
|
|
712
|
+
construct.prototype.constructor = construct;
|
|
713
|
+
construct.prototype.name = name;
|
|
714
|
+
construct.prototype.CustomError = {
|
|
715
|
+
chain: isRoot ? [] : parent.prototype.CustomError.chain.slice(0),
|
|
716
|
+
factory,
|
|
717
|
+
name,
|
|
718
|
+
parent,
|
|
719
|
+
properties
|
|
720
|
+
};
|
|
721
|
+
construct.prototype.CustomError.chain.unshift(construct.prototype.CustomError);
|
|
722
|
+
construct.prototype.toString = function() {
|
|
723
|
+
var result = this.CustomError.chain[this.CustomError.chain.length - 1].name;
|
|
724
|
+
if (this.code) result += " " + this.code;
|
|
725
|
+
if (this.message) result += ": " + this.message;
|
|
726
|
+
return result;
|
|
727
|
+
};
|
|
728
|
+
return construct;
|
|
729
|
+
}
|
|
730
|
+
function findArg(args, index, defaultValue, filter, antiFilters) {
|
|
731
|
+
var anti = -1;
|
|
732
|
+
var found = -1;
|
|
733
|
+
var i;
|
|
734
|
+
var j;
|
|
735
|
+
var len = index < args.length ? index : args.length;
|
|
736
|
+
var val;
|
|
737
|
+
for (i = 0; i <= len; i++) {
|
|
738
|
+
val = args[i];
|
|
739
|
+
if (anti === -1) {
|
|
740
|
+
for (j = 0; j < antiFilters.length; j++) {
|
|
741
|
+
if (antiFilters[j](val)) anti = i;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (found === -1 && filter(val)) {
|
|
745
|
+
found = i;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (found !== -1 && anti !== -1 && anti < found) throw new Err.order();
|
|
749
|
+
return found !== -1 ? args[found] : defaultValue;
|
|
750
|
+
}
|
|
751
|
+
function isFactoryArg(value) {
|
|
752
|
+
return typeof value === "function" && value !== Error && !value.prototype.CustomError;
|
|
753
|
+
}
|
|
754
|
+
function isNameArg(value) {
|
|
755
|
+
return typeof value === "string";
|
|
756
|
+
}
|
|
757
|
+
function isParentArg(value) {
|
|
758
|
+
return typeof value === "function" && (value === Error || value.prototype.CustomError);
|
|
759
|
+
}
|
|
760
|
+
function isPropertiesArg(value) {
|
|
761
|
+
return value && typeof value === "object";
|
|
762
|
+
}
|
|
763
|
+
function noop() {
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
});
|
|
668
767
|
|
|
669
|
-
//
|
|
670
|
-
var
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
};
|
|
676
|
-
var AiGatewayAudioResource = class extends BaseResource {
|
|
677
|
-
/**
|
|
678
|
-
* Synthesize speech from text. Returns the raw audio bytes.
|
|
679
|
-
*
|
|
680
|
-
* @returns The audio content as an `ArrayBuffer` (format per `response_format`).
|
|
681
|
-
*/
|
|
682
|
-
async speech(data, options) {
|
|
683
|
-
const response = await this.httpClient.requestStream("POST", `${BASE}/audio/speech`, {
|
|
684
|
-
body: data,
|
|
685
|
-
headers: options?.headers
|
|
686
|
-
});
|
|
687
|
-
return response.arrayBuffer();
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Transcribe an audio file to text. The file is sent as multipart form data.
|
|
691
|
-
*/
|
|
692
|
-
async transcriptions(data, options) {
|
|
693
|
-
const form = new FormData();
|
|
694
|
-
const { file, filename, ...rest } = data;
|
|
695
|
-
form.set("file", toBlob(file), filename ?? "audio");
|
|
696
|
-
for (const [key, value] of Object.entries(rest)) {
|
|
697
|
-
if (value === void 0 || value === null) continue;
|
|
698
|
-
form.set(key, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
699
|
-
}
|
|
700
|
-
return this.httpClient.postRaw(`${BASE}/audio/transcriptions`, form, options?.headers);
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
var AiGatewayVideosResource = class extends BaseResource {
|
|
704
|
-
/** Generate a video from a prompt. */
|
|
705
|
-
async generations(data, options) {
|
|
706
|
-
return this.httpClient.post(`${BASE}/videos`, data, { headers: options?.headers });
|
|
707
|
-
}
|
|
708
|
-
/** List the video models available through the gateway. */
|
|
709
|
-
async listModels() {
|
|
710
|
-
return this.httpClient.get(`${BASE}/videos/models`);
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
var AiGatewayResource = class extends BaseResource {
|
|
714
|
-
/** Text-to-speech and speech-to-text. */
|
|
715
|
-
audio;
|
|
716
|
-
/** Video generation. */
|
|
717
|
-
videos;
|
|
718
|
-
constructor(httpClient) {
|
|
719
|
-
super(httpClient);
|
|
720
|
-
this.audio = new AiGatewayAudioResource(httpClient);
|
|
721
|
-
this.videos = new AiGatewayVideosResource(httpClient);
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Create a chat completion using the OpenAI-compatible endpoint.
|
|
725
|
-
*
|
|
726
|
-
* @param data - The chat completion request (model, messages, options, provider routing).
|
|
727
|
-
* @param options - Custom headers (e.g. `X-Gigadrive-Application-Id`).
|
|
728
|
-
*/
|
|
729
|
-
async chatCompletions(data, options) {
|
|
730
|
-
return this.httpClient.post(`${BASE}/chat/completions`, { ...data, stream: false }, { headers: options?.headers });
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Like {@link chatCompletions}, but also returns the raw response and the
|
|
734
|
-
* gateway request-id / cost headers.
|
|
735
|
-
*/
|
|
736
|
-
async chatCompletionsWithResponse(data, options) {
|
|
737
|
-
const response = await this.httpClient.requestStream("POST", `${BASE}/chat/completions`, {
|
|
738
|
-
body: { ...data, stream: false },
|
|
739
|
-
headers: options?.headers
|
|
740
|
-
});
|
|
741
|
-
const body = await response.json();
|
|
742
|
-
const cost = response.headers.get("X-Gigadrive-Cost-Micros");
|
|
743
|
-
const costMicros = cost !== null ? Number(cost) : NaN;
|
|
744
|
-
return {
|
|
745
|
-
data: body,
|
|
746
|
-
response,
|
|
747
|
-
requestId: response.headers.get("X-Gigadrive-Request-Id") ?? void 0,
|
|
748
|
-
costMicros: Number.isFinite(costMicros) ? costMicros : void 0
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Stream a chat completion as Server-Sent Events. Yields each chunk as it
|
|
753
|
-
* arrives and ends when the gateway closes the stream.
|
|
754
|
-
*/
|
|
755
|
-
async *chatCompletionsStream(data, options) {
|
|
756
|
-
const response = await this.httpClient.requestStream("POST", `${BASE}/chat/completions`, {
|
|
757
|
-
body: { ...data, stream: true },
|
|
758
|
-
headers: options?.headers
|
|
759
|
-
});
|
|
760
|
-
yield* parseSSEStream(response);
|
|
761
|
-
}
|
|
762
|
-
/**
|
|
763
|
-
* Create a response using the Open Responses-compatible endpoint.
|
|
764
|
-
*/
|
|
765
|
-
async responses(data, options) {
|
|
766
|
-
return this.httpClient.post(`${BASE}/responses`, { ...data, stream: false }, { headers: options?.headers });
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Stream a response using the Open Responses-compatible endpoint.
|
|
770
|
-
*/
|
|
771
|
-
async *responsesStream(data, options) {
|
|
772
|
-
const response = await this.httpClient.requestStream("POST", `${BASE}/responses`, {
|
|
773
|
-
body: { ...data, stream: true },
|
|
774
|
-
headers: options?.headers
|
|
775
|
-
});
|
|
776
|
-
yield* parseSSEStream(response);
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* List all AI models available through the gateway.
|
|
780
|
-
*/
|
|
781
|
-
async listModels() {
|
|
782
|
-
return this.httpClient.get(`${BASE}/models`);
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Get details for a specific AI model by its ID.
|
|
786
|
-
*
|
|
787
|
-
* @param modelId - The model identifier (e.g. `"openai/gpt-4o"`).
|
|
788
|
-
*/
|
|
789
|
-
async getModel(modelId) {
|
|
790
|
-
return this.httpClient.get(`${BASE}/models/${encodeURIComponent(modelId)}`);
|
|
791
|
-
}
|
|
792
|
-
};
|
|
768
|
+
// ../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/index.js
|
|
769
|
+
var require_custom_error_instance = __commonJS({
|
|
770
|
+
"../../node_modules/.pnpm/custom-error-instance@2.1.1/node_modules/custom-error-instance/index.js"(exports, module) {
|
|
771
|
+
"use strict";
|
|
772
|
+
module.exports = require_error();
|
|
773
|
+
}
|
|
774
|
+
});
|
|
793
775
|
|
|
794
|
-
//
|
|
795
|
-
var
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
}
|
|
776
|
+
// ../../node_modules/.pnpm/lodash._basetostring@4.12.0/node_modules/lodash._basetostring/index.js
|
|
777
|
+
var require_lodash2 = __commonJS({
|
|
778
|
+
"../../node_modules/.pnpm/lodash._basetostring@4.12.0/node_modules/lodash._basetostring/index.js"(exports, module) {
|
|
779
|
+
"use strict";
|
|
780
|
+
var INFINITY = 1 / 0;
|
|
781
|
+
var symbolTag = "[object Symbol]";
|
|
782
|
+
var objectTypes = {
|
|
783
|
+
"function": true,
|
|
784
|
+
"object": true
|
|
785
|
+
};
|
|
786
|
+
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType ? exports : void 0;
|
|
787
|
+
var freeModule = objectTypes[typeof module] && module && !module.nodeType ? module : void 0;
|
|
788
|
+
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == "object" && global);
|
|
789
|
+
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
|
790
|
+
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
|
791
|
+
var thisGlobal = checkGlobal(objectTypes[typeof exports] && exports);
|
|
792
|
+
var root = freeGlobal || freeWindow !== (thisGlobal && thisGlobal.window) && freeWindow || freeSelf || thisGlobal || Function("return this")();
|
|
793
|
+
function checkGlobal(value) {
|
|
794
|
+
return value && value.Object === Object ? value : null;
|
|
795
|
+
}
|
|
796
|
+
var objectProto = Object.prototype;
|
|
797
|
+
var objectToString = objectProto.toString;
|
|
798
|
+
var Symbol2 = root.Symbol;
|
|
799
|
+
var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
|
|
800
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
801
|
+
function baseToString(value) {
|
|
802
|
+
if (typeof value == "string") {
|
|
803
|
+
return value;
|
|
804
|
+
}
|
|
805
|
+
if (isSymbol(value)) {
|
|
806
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
807
|
+
}
|
|
808
|
+
var result = value + "";
|
|
809
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
810
|
+
}
|
|
811
|
+
function isObjectLike(value) {
|
|
812
|
+
return !!value && typeof value == "object";
|
|
813
|
+
}
|
|
814
|
+
function isSymbol(value) {
|
|
815
|
+
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
816
|
+
}
|
|
817
|
+
module.exports = baseToString;
|
|
818
|
+
}
|
|
819
|
+
});
|
|
826
820
|
|
|
827
|
-
//
|
|
828
|
-
var
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
821
|
+
// ../../node_modules/.pnpm/lodash._stringtopath@4.8.0/node_modules/lodash._stringtopath/index.js
|
|
822
|
+
var require_lodash3 = __commonJS({
|
|
823
|
+
"../../node_modules/.pnpm/lodash._stringtopath@4.8.0/node_modules/lodash._stringtopath/index.js"(exports, module) {
|
|
824
|
+
"use strict";
|
|
825
|
+
var baseToString = require_lodash2();
|
|
826
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
827
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
828
|
+
var funcTag = "[object Function]";
|
|
829
|
+
var genTag = "[object GeneratorFunction]";
|
|
830
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
|
|
831
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
832
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
833
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
834
|
+
var objectTypes = {
|
|
835
|
+
"function": true,
|
|
836
|
+
"object": true
|
|
837
|
+
};
|
|
838
|
+
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType ? exports : void 0;
|
|
839
|
+
var freeModule = objectTypes[typeof module] && module && !module.nodeType ? module : void 0;
|
|
840
|
+
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == "object" && global);
|
|
841
|
+
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
|
842
|
+
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
|
843
|
+
var thisGlobal = checkGlobal(objectTypes[typeof exports] && exports);
|
|
844
|
+
var root = freeGlobal || freeWindow !== (thisGlobal && thisGlobal.window) && freeWindow || freeSelf || thisGlobal || Function("return this")();
|
|
845
|
+
function checkGlobal(value) {
|
|
846
|
+
return value && value.Object === Object ? value : null;
|
|
847
|
+
}
|
|
848
|
+
function isHostObject(value) {
|
|
849
|
+
var result = false;
|
|
850
|
+
if (value != null && typeof value.toString != "function") {
|
|
851
|
+
try {
|
|
852
|
+
result = !!(value + "");
|
|
853
|
+
} catch (e) {
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return result;
|
|
857
|
+
}
|
|
858
|
+
var arrayProto = Array.prototype;
|
|
859
|
+
var objectProto = Object.prototype;
|
|
860
|
+
var funcToString = Function.prototype.toString;
|
|
861
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
862
|
+
var objectToString = objectProto.toString;
|
|
863
|
+
var reIsNative = RegExp(
|
|
864
|
+
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
865
|
+
);
|
|
866
|
+
var splice = arrayProto.splice;
|
|
867
|
+
var Map2 = getNative(root, "Map");
|
|
868
|
+
var nativeCreate = getNative(Object, "create");
|
|
869
|
+
function Hash(entries) {
|
|
870
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
871
|
+
this.clear();
|
|
872
|
+
while (++index < length) {
|
|
873
|
+
var entry = entries[index];
|
|
874
|
+
this.set(entry[0], entry[1]);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function hashClear() {
|
|
878
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
879
|
+
}
|
|
880
|
+
function hashDelete(key) {
|
|
881
|
+
return this.has(key) && delete this.__data__[key];
|
|
882
|
+
}
|
|
883
|
+
function hashGet(key) {
|
|
884
|
+
var data = this.__data__;
|
|
885
|
+
if (nativeCreate) {
|
|
886
|
+
var result = data[key];
|
|
887
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
888
|
+
}
|
|
889
|
+
return hasOwnProperty.call(data, key) ? data[key] : void 0;
|
|
890
|
+
}
|
|
891
|
+
function hashHas(key) {
|
|
892
|
+
var data = this.__data__;
|
|
893
|
+
return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
894
|
+
}
|
|
895
|
+
function hashSet(key, value) {
|
|
896
|
+
var data = this.__data__;
|
|
897
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
898
|
+
return this;
|
|
899
|
+
}
|
|
900
|
+
Hash.prototype.clear = hashClear;
|
|
901
|
+
Hash.prototype["delete"] = hashDelete;
|
|
902
|
+
Hash.prototype.get = hashGet;
|
|
903
|
+
Hash.prototype.has = hashHas;
|
|
904
|
+
Hash.prototype.set = hashSet;
|
|
905
|
+
function ListCache(entries) {
|
|
906
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
907
|
+
this.clear();
|
|
908
|
+
while (++index < length) {
|
|
909
|
+
var entry = entries[index];
|
|
910
|
+
this.set(entry[0], entry[1]);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function listCacheClear() {
|
|
914
|
+
this.__data__ = [];
|
|
915
|
+
}
|
|
916
|
+
function listCacheDelete(key) {
|
|
917
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
918
|
+
if (index < 0) {
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
var lastIndex = data.length - 1;
|
|
922
|
+
if (index == lastIndex) {
|
|
923
|
+
data.pop();
|
|
924
|
+
} else {
|
|
925
|
+
splice.call(data, index, 1);
|
|
926
|
+
}
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
function listCacheGet(key) {
|
|
930
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
931
|
+
return index < 0 ? void 0 : data[index][1];
|
|
932
|
+
}
|
|
933
|
+
function listCacheHas(key) {
|
|
934
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
935
|
+
}
|
|
936
|
+
function listCacheSet(key, value) {
|
|
937
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
938
|
+
if (index < 0) {
|
|
939
|
+
data.push([key, value]);
|
|
940
|
+
} else {
|
|
941
|
+
data[index][1] = value;
|
|
942
|
+
}
|
|
943
|
+
return this;
|
|
944
|
+
}
|
|
945
|
+
ListCache.prototype.clear = listCacheClear;
|
|
946
|
+
ListCache.prototype["delete"] = listCacheDelete;
|
|
947
|
+
ListCache.prototype.get = listCacheGet;
|
|
948
|
+
ListCache.prototype.has = listCacheHas;
|
|
949
|
+
ListCache.prototype.set = listCacheSet;
|
|
950
|
+
function MapCache(entries) {
|
|
951
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
952
|
+
this.clear();
|
|
953
|
+
while (++index < length) {
|
|
954
|
+
var entry = entries[index];
|
|
955
|
+
this.set(entry[0], entry[1]);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
function mapCacheClear() {
|
|
959
|
+
this.__data__ = {
|
|
960
|
+
"hash": new Hash(),
|
|
961
|
+
"map": new (Map2 || ListCache)(),
|
|
962
|
+
"string": new Hash()
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function mapCacheDelete(key) {
|
|
966
|
+
return getMapData(this, key)["delete"](key);
|
|
967
|
+
}
|
|
968
|
+
function mapCacheGet(key) {
|
|
969
|
+
return getMapData(this, key).get(key);
|
|
970
|
+
}
|
|
971
|
+
function mapCacheHas(key) {
|
|
972
|
+
return getMapData(this, key).has(key);
|
|
973
|
+
}
|
|
974
|
+
function mapCacheSet(key, value) {
|
|
975
|
+
getMapData(this, key).set(key, value);
|
|
976
|
+
return this;
|
|
977
|
+
}
|
|
978
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
979
|
+
MapCache.prototype["delete"] = mapCacheDelete;
|
|
980
|
+
MapCache.prototype.get = mapCacheGet;
|
|
981
|
+
MapCache.prototype.has = mapCacheHas;
|
|
982
|
+
MapCache.prototype.set = mapCacheSet;
|
|
983
|
+
function assocIndexOf(array, key) {
|
|
984
|
+
var length = array.length;
|
|
985
|
+
while (length--) {
|
|
986
|
+
if (eq(array[length][0], key)) {
|
|
987
|
+
return length;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
return -1;
|
|
991
|
+
}
|
|
992
|
+
function getMapData(map, key) {
|
|
993
|
+
var data = map.__data__;
|
|
994
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
995
|
+
}
|
|
996
|
+
function getNative(object, key) {
|
|
997
|
+
var value = object[key];
|
|
998
|
+
return isNative(value) ? value : void 0;
|
|
999
|
+
}
|
|
1000
|
+
function isKeyable(value) {
|
|
1001
|
+
var type = typeof value;
|
|
1002
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
1003
|
+
}
|
|
1004
|
+
var stringToPath = memoize(function(string) {
|
|
1005
|
+
var result = [];
|
|
1006
|
+
toString(string).replace(rePropName, function(match, number, quote, string2) {
|
|
1007
|
+
result.push(quote ? string2.replace(reEscapeChar, "$1") : number || match);
|
|
1008
|
+
});
|
|
1009
|
+
return result;
|
|
1010
|
+
});
|
|
1011
|
+
function toSource(func) {
|
|
1012
|
+
if (func != null) {
|
|
1013
|
+
try {
|
|
1014
|
+
return funcToString.call(func);
|
|
1015
|
+
} catch (e) {
|
|
1016
|
+
}
|
|
1017
|
+
try {
|
|
1018
|
+
return func + "";
|
|
1019
|
+
} catch (e) {
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return "";
|
|
1023
|
+
}
|
|
1024
|
+
function memoize(func, resolver) {
|
|
1025
|
+
if (typeof func != "function" || resolver && typeof resolver != "function") {
|
|
1026
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
1027
|
+
}
|
|
1028
|
+
var memoized = function() {
|
|
1029
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
1030
|
+
if (cache.has(key)) {
|
|
1031
|
+
return cache.get(key);
|
|
1032
|
+
}
|
|
1033
|
+
var result = func.apply(this, args);
|
|
1034
|
+
memoized.cache = cache.set(key, result);
|
|
1035
|
+
return result;
|
|
1036
|
+
};
|
|
1037
|
+
memoized.cache = new (memoize.Cache || MapCache)();
|
|
1038
|
+
return memoized;
|
|
1039
|
+
}
|
|
1040
|
+
memoize.Cache = MapCache;
|
|
1041
|
+
function eq(value, other) {
|
|
1042
|
+
return value === other || value !== value && other !== other;
|
|
1043
|
+
}
|
|
1044
|
+
function isFunction(value) {
|
|
1045
|
+
var tag = isObject(value) ? objectToString.call(value) : "";
|
|
1046
|
+
return tag == funcTag || tag == genTag;
|
|
1047
|
+
}
|
|
1048
|
+
function isObject(value) {
|
|
1049
|
+
var type = typeof value;
|
|
1050
|
+
return !!value && (type == "object" || type == "function");
|
|
1051
|
+
}
|
|
1052
|
+
function isNative(value) {
|
|
1053
|
+
if (!isObject(value)) {
|
|
1054
|
+
return false;
|
|
1055
|
+
}
|
|
1056
|
+
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
|
|
1057
|
+
return pattern.test(toSource(value));
|
|
1058
|
+
}
|
|
1059
|
+
function toString(value) {
|
|
1060
|
+
return value == null ? "" : baseToString(value);
|
|
1061
|
+
}
|
|
1062
|
+
module.exports = stringToPath;
|
|
1063
|
+
}
|
|
994
1064
|
});
|
|
995
|
-
const checksums = { sha256: sha256.digest("hex") };
|
|
996
|
-
if (sha1) checksums.sha1 = sha1.digest("hex");
|
|
997
|
-
if (md5) checksums.md5 = md5.digest("hex");
|
|
998
|
-
return checksums;
|
|
999
|
-
};
|
|
1000
1065
|
|
|
1001
|
-
//
|
|
1002
|
-
var
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
var
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1066
|
+
// ../../node_modules/.pnpm/lodash._baseiteratee@4.7.0/node_modules/lodash._baseiteratee/index.js
|
|
1067
|
+
var require_lodash4 = __commonJS({
|
|
1068
|
+
"../../node_modules/.pnpm/lodash._baseiteratee@4.7.0/node_modules/lodash._baseiteratee/index.js"(exports, module) {
|
|
1069
|
+
"use strict";
|
|
1070
|
+
var stringToPath = require_lodash3();
|
|
1071
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1072
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
1073
|
+
var UNORDERED_COMPARE_FLAG = 1;
|
|
1074
|
+
var PARTIAL_COMPARE_FLAG = 2;
|
|
1075
|
+
var INFINITY = 1 / 0;
|
|
1076
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1077
|
+
var argsTag = "[object Arguments]";
|
|
1078
|
+
var arrayTag = "[object Array]";
|
|
1079
|
+
var boolTag = "[object Boolean]";
|
|
1080
|
+
var dateTag = "[object Date]";
|
|
1081
|
+
var errorTag = "[object Error]";
|
|
1082
|
+
var funcTag = "[object Function]";
|
|
1083
|
+
var genTag = "[object GeneratorFunction]";
|
|
1084
|
+
var mapTag = "[object Map]";
|
|
1085
|
+
var numberTag = "[object Number]";
|
|
1086
|
+
var objectTag = "[object Object]";
|
|
1087
|
+
var promiseTag = "[object Promise]";
|
|
1088
|
+
var regexpTag = "[object RegExp]";
|
|
1089
|
+
var setTag = "[object Set]";
|
|
1090
|
+
var stringTag = "[object String]";
|
|
1091
|
+
var symbolTag = "[object Symbol]";
|
|
1092
|
+
var weakMapTag = "[object WeakMap]";
|
|
1093
|
+
var arrayBufferTag = "[object ArrayBuffer]";
|
|
1094
|
+
var dataViewTag = "[object DataView]";
|
|
1095
|
+
var float32Tag = "[object Float32Array]";
|
|
1096
|
+
var float64Tag = "[object Float64Array]";
|
|
1097
|
+
var int8Tag = "[object Int8Array]";
|
|
1098
|
+
var int16Tag = "[object Int16Array]";
|
|
1099
|
+
var int32Tag = "[object Int32Array]";
|
|
1100
|
+
var uint8Tag = "[object Uint8Array]";
|
|
1101
|
+
var uint8ClampedTag = "[object Uint8ClampedArray]";
|
|
1102
|
+
var uint16Tag = "[object Uint16Array]";
|
|
1103
|
+
var uint32Tag = "[object Uint32Array]";
|
|
1104
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
1105
|
+
var reIsPlainProp = /^\w*$/;
|
|
1106
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1107
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1108
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
1109
|
+
var typedArrayTags = {};
|
|
1110
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
1111
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
|
1112
|
+
var objectTypes = {
|
|
1113
|
+
"function": true,
|
|
1114
|
+
"object": true
|
|
1115
|
+
};
|
|
1116
|
+
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType ? exports : void 0;
|
|
1117
|
+
var freeModule = objectTypes[typeof module] && module && !module.nodeType ? module : void 0;
|
|
1118
|
+
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == "object" && global);
|
|
1119
|
+
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
|
1120
|
+
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
|
1121
|
+
var thisGlobal = checkGlobal(objectTypes[typeof exports] && exports);
|
|
1122
|
+
var root = freeGlobal || freeWindow !== (thisGlobal && thisGlobal.window) && freeWindow || freeSelf || thisGlobal || Function("return this")();
|
|
1123
|
+
function arrayMap(array, iteratee) {
|
|
1124
|
+
var index = -1, length = array.length, result = Array(length);
|
|
1125
|
+
while (++index < length) {
|
|
1126
|
+
result[index] = iteratee(array[index], index, array);
|
|
1127
|
+
}
|
|
1128
|
+
return result;
|
|
1129
|
+
}
|
|
1130
|
+
function arraySome(array, predicate) {
|
|
1131
|
+
var index = -1, length = array.length;
|
|
1132
|
+
while (++index < length) {
|
|
1133
|
+
if (predicate(array[index], index, array)) {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
function baseTimes(n, iteratee) {
|
|
1140
|
+
var index = -1, result = Array(n);
|
|
1141
|
+
while (++index < n) {
|
|
1142
|
+
result[index] = iteratee(index);
|
|
1143
|
+
}
|
|
1144
|
+
return result;
|
|
1145
|
+
}
|
|
1146
|
+
function baseToPairs(object, props) {
|
|
1147
|
+
return arrayMap(props, function(key) {
|
|
1148
|
+
return [key, object[key]];
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
function checkGlobal(value) {
|
|
1152
|
+
return value && value.Object === Object ? value : null;
|
|
1153
|
+
}
|
|
1154
|
+
function isHostObject(value) {
|
|
1155
|
+
var result = false;
|
|
1156
|
+
if (value != null && typeof value.toString != "function") {
|
|
1157
|
+
try {
|
|
1158
|
+
result = !!(value + "");
|
|
1159
|
+
} catch (e) {
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return result;
|
|
1163
|
+
}
|
|
1164
|
+
function mapToArray(map) {
|
|
1165
|
+
var index = -1, result = Array(map.size);
|
|
1166
|
+
map.forEach(function(value, key) {
|
|
1167
|
+
result[++index] = [key, value];
|
|
1168
|
+
});
|
|
1169
|
+
return result;
|
|
1170
|
+
}
|
|
1171
|
+
function setToArray(set) {
|
|
1172
|
+
var index = -1, result = Array(set.size);
|
|
1173
|
+
set.forEach(function(value) {
|
|
1174
|
+
result[++index] = value;
|
|
1175
|
+
});
|
|
1176
|
+
return result;
|
|
1177
|
+
}
|
|
1178
|
+
function setToPairs(set) {
|
|
1179
|
+
var index = -1, result = Array(set.size);
|
|
1180
|
+
set.forEach(function(value) {
|
|
1181
|
+
result[++index] = [value, value];
|
|
1182
|
+
});
|
|
1183
|
+
return result;
|
|
1184
|
+
}
|
|
1185
|
+
var arrayProto = Array.prototype;
|
|
1186
|
+
var objectProto = Object.prototype;
|
|
1187
|
+
var funcToString = Function.prototype.toString;
|
|
1188
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1189
|
+
var objectToString = objectProto.toString;
|
|
1190
|
+
var reIsNative = RegExp(
|
|
1191
|
+
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
1192
|
+
);
|
|
1193
|
+
var Symbol2 = root.Symbol;
|
|
1194
|
+
var Uint8Array2 = root.Uint8Array;
|
|
1195
|
+
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
1196
|
+
var splice = arrayProto.splice;
|
|
1197
|
+
var nativeGetPrototype = Object.getPrototypeOf;
|
|
1198
|
+
var nativeKeys = Object.keys;
|
|
1199
|
+
var DataView = getNative(root, "DataView");
|
|
1200
|
+
var Map2 = getNative(root, "Map");
|
|
1201
|
+
var Promise2 = getNative(root, "Promise");
|
|
1202
|
+
var Set = getNative(root, "Set");
|
|
1203
|
+
var WeakMap = getNative(root, "WeakMap");
|
|
1204
|
+
var nativeCreate = getNative(Object, "create");
|
|
1205
|
+
var dataViewCtorString = toSource(DataView);
|
|
1206
|
+
var mapCtorString = toSource(Map2);
|
|
1207
|
+
var promiseCtorString = toSource(Promise2);
|
|
1208
|
+
var setCtorString = toSource(Set);
|
|
1209
|
+
var weakMapCtorString = toSource(WeakMap);
|
|
1210
|
+
var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
|
|
1211
|
+
var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1212
|
+
function Hash(entries) {
|
|
1213
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
1214
|
+
this.clear();
|
|
1215
|
+
while (++index < length) {
|
|
1216
|
+
var entry = entries[index];
|
|
1217
|
+
this.set(entry[0], entry[1]);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
function hashClear() {
|
|
1221
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
1222
|
+
}
|
|
1223
|
+
function hashDelete(key) {
|
|
1224
|
+
return this.has(key) && delete this.__data__[key];
|
|
1225
|
+
}
|
|
1226
|
+
function hashGet(key) {
|
|
1227
|
+
var data = this.__data__;
|
|
1228
|
+
if (nativeCreate) {
|
|
1229
|
+
var result = data[key];
|
|
1230
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
1231
|
+
}
|
|
1232
|
+
return hasOwnProperty.call(data, key) ? data[key] : void 0;
|
|
1233
|
+
}
|
|
1234
|
+
function hashHas(key) {
|
|
1235
|
+
var data = this.__data__;
|
|
1236
|
+
return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
1237
|
+
}
|
|
1238
|
+
function hashSet(key, value) {
|
|
1239
|
+
var data = this.__data__;
|
|
1240
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
1243
|
+
Hash.prototype.clear = hashClear;
|
|
1244
|
+
Hash.prototype["delete"] = hashDelete;
|
|
1245
|
+
Hash.prototype.get = hashGet;
|
|
1246
|
+
Hash.prototype.has = hashHas;
|
|
1247
|
+
Hash.prototype.set = hashSet;
|
|
1248
|
+
function ListCache(entries) {
|
|
1249
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
1250
|
+
this.clear();
|
|
1251
|
+
while (++index < length) {
|
|
1252
|
+
var entry = entries[index];
|
|
1253
|
+
this.set(entry[0], entry[1]);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
function listCacheClear() {
|
|
1257
|
+
this.__data__ = [];
|
|
1258
|
+
}
|
|
1259
|
+
function listCacheDelete(key) {
|
|
1260
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
1261
|
+
if (index < 0) {
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
var lastIndex = data.length - 1;
|
|
1265
|
+
if (index == lastIndex) {
|
|
1266
|
+
data.pop();
|
|
1267
|
+
} else {
|
|
1268
|
+
splice.call(data, index, 1);
|
|
1269
|
+
}
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
function listCacheGet(key) {
|
|
1273
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
1274
|
+
return index < 0 ? void 0 : data[index][1];
|
|
1275
|
+
}
|
|
1276
|
+
function listCacheHas(key) {
|
|
1277
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
1278
|
+
}
|
|
1279
|
+
function listCacheSet(key, value) {
|
|
1280
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
1281
|
+
if (index < 0) {
|
|
1282
|
+
data.push([key, value]);
|
|
1283
|
+
} else {
|
|
1284
|
+
data[index][1] = value;
|
|
1285
|
+
}
|
|
1286
|
+
return this;
|
|
1287
|
+
}
|
|
1288
|
+
ListCache.prototype.clear = listCacheClear;
|
|
1289
|
+
ListCache.prototype["delete"] = listCacheDelete;
|
|
1290
|
+
ListCache.prototype.get = listCacheGet;
|
|
1291
|
+
ListCache.prototype.has = listCacheHas;
|
|
1292
|
+
ListCache.prototype.set = listCacheSet;
|
|
1293
|
+
function MapCache(entries) {
|
|
1294
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
1295
|
+
this.clear();
|
|
1296
|
+
while (++index < length) {
|
|
1297
|
+
var entry = entries[index];
|
|
1298
|
+
this.set(entry[0], entry[1]);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function mapCacheClear() {
|
|
1302
|
+
this.__data__ = {
|
|
1303
|
+
"hash": new Hash(),
|
|
1304
|
+
"map": new (Map2 || ListCache)(),
|
|
1305
|
+
"string": new Hash()
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
function mapCacheDelete(key) {
|
|
1309
|
+
return getMapData(this, key)["delete"](key);
|
|
1310
|
+
}
|
|
1311
|
+
function mapCacheGet(key) {
|
|
1312
|
+
return getMapData(this, key).get(key);
|
|
1313
|
+
}
|
|
1314
|
+
function mapCacheHas(key) {
|
|
1315
|
+
return getMapData(this, key).has(key);
|
|
1316
|
+
}
|
|
1317
|
+
function mapCacheSet(key, value) {
|
|
1318
|
+
getMapData(this, key).set(key, value);
|
|
1319
|
+
return this;
|
|
1320
|
+
}
|
|
1321
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
1322
|
+
MapCache.prototype["delete"] = mapCacheDelete;
|
|
1323
|
+
MapCache.prototype.get = mapCacheGet;
|
|
1324
|
+
MapCache.prototype.has = mapCacheHas;
|
|
1325
|
+
MapCache.prototype.set = mapCacheSet;
|
|
1326
|
+
function SetCache(values) {
|
|
1327
|
+
var index = -1, length = values ? values.length : 0;
|
|
1328
|
+
this.__data__ = new MapCache();
|
|
1329
|
+
while (++index < length) {
|
|
1330
|
+
this.add(values[index]);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function setCacheAdd(value) {
|
|
1334
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1335
|
+
return this;
|
|
1336
|
+
}
|
|
1337
|
+
function setCacheHas(value) {
|
|
1338
|
+
return this.__data__.has(value);
|
|
1339
|
+
}
|
|
1340
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
1341
|
+
SetCache.prototype.has = setCacheHas;
|
|
1342
|
+
function Stack(entries) {
|
|
1343
|
+
this.__data__ = new ListCache(entries);
|
|
1344
|
+
}
|
|
1345
|
+
function stackClear() {
|
|
1346
|
+
this.__data__ = new ListCache();
|
|
1347
|
+
}
|
|
1348
|
+
function stackDelete(key) {
|
|
1349
|
+
return this.__data__["delete"](key);
|
|
1350
|
+
}
|
|
1351
|
+
function stackGet(key) {
|
|
1352
|
+
return this.__data__.get(key);
|
|
1353
|
+
}
|
|
1354
|
+
function stackHas(key) {
|
|
1355
|
+
return this.__data__.has(key);
|
|
1356
|
+
}
|
|
1357
|
+
function stackSet(key, value) {
|
|
1358
|
+
var cache = this.__data__;
|
|
1359
|
+
if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
|
|
1360
|
+
cache = this.__data__ = new MapCache(cache.__data__);
|
|
1361
|
+
}
|
|
1362
|
+
cache.set(key, value);
|
|
1363
|
+
return this;
|
|
1364
|
+
}
|
|
1365
|
+
Stack.prototype.clear = stackClear;
|
|
1366
|
+
Stack.prototype["delete"] = stackDelete;
|
|
1367
|
+
Stack.prototype.get = stackGet;
|
|
1368
|
+
Stack.prototype.has = stackHas;
|
|
1369
|
+
Stack.prototype.set = stackSet;
|
|
1370
|
+
function assocIndexOf(array, key) {
|
|
1371
|
+
var length = array.length;
|
|
1372
|
+
while (length--) {
|
|
1373
|
+
if (eq(array[length][0], key)) {
|
|
1374
|
+
return length;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
return -1;
|
|
1378
|
+
}
|
|
1379
|
+
function baseGet(object, path2) {
|
|
1380
|
+
path2 = isKey(path2, object) ? [path2] : castPath(path2);
|
|
1381
|
+
var index = 0, length = path2.length;
|
|
1382
|
+
while (object != null && index < length) {
|
|
1383
|
+
object = object[toKey(path2[index++])];
|
|
1384
|
+
}
|
|
1385
|
+
return index && index == length ? object : void 0;
|
|
1386
|
+
}
|
|
1387
|
+
function baseHas(object, key) {
|
|
1388
|
+
return hasOwnProperty.call(object, key) || typeof object == "object" && key in object && getPrototype(object) === null;
|
|
1389
|
+
}
|
|
1390
|
+
function baseHasIn(object, key) {
|
|
1391
|
+
return key in Object(object);
|
|
1392
|
+
}
|
|
1393
|
+
function baseIsEqual(value, other, customizer, bitmask, stack) {
|
|
1394
|
+
if (value === other) {
|
|
1395
|
+
return true;
|
|
1396
|
+
}
|
|
1397
|
+
if (value == null || other == null || !isObject(value) && !isObjectLike(other)) {
|
|
1398
|
+
return value !== value && other !== other;
|
|
1399
|
+
}
|
|
1400
|
+
return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
|
|
1401
|
+
}
|
|
1402
|
+
function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
|
1403
|
+
var objIsArr = isArray(object), othIsArr = isArray(other), objTag = arrayTag, othTag = arrayTag;
|
|
1404
|
+
if (!objIsArr) {
|
|
1405
|
+
objTag = getTag(object);
|
|
1406
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
1407
|
+
}
|
|
1408
|
+
if (!othIsArr) {
|
|
1409
|
+
othTag = getTag(other);
|
|
1410
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
1411
|
+
}
|
|
1412
|
+
var objIsObj = objTag == objectTag && !isHostObject(object), othIsObj = othTag == objectTag && !isHostObject(other), isSameTag = objTag == othTag;
|
|
1413
|
+
if (isSameTag && !objIsObj) {
|
|
1414
|
+
stack || (stack = new Stack());
|
|
1415
|
+
return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
|
1416
|
+
}
|
|
1417
|
+
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
|
1418
|
+
var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
|
|
1419
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1420
|
+
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1421
|
+
stack || (stack = new Stack());
|
|
1422
|
+
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
if (!isSameTag) {
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
stack || (stack = new Stack());
|
|
1429
|
+
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
|
1430
|
+
}
|
|
1431
|
+
function baseIsMatch(object, source, matchData, customizer) {
|
|
1432
|
+
var index = matchData.length, length = index, noCustomizer = !customizer;
|
|
1433
|
+
if (object == null) {
|
|
1434
|
+
return !length;
|
|
1435
|
+
}
|
|
1436
|
+
object = Object(object);
|
|
1437
|
+
while (index--) {
|
|
1438
|
+
var data = matchData[index];
|
|
1439
|
+
if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
while (++index < length) {
|
|
1444
|
+
data = matchData[index];
|
|
1445
|
+
var key = data[0], objValue = object[key], srcValue = data[1];
|
|
1446
|
+
if (noCustomizer && data[2]) {
|
|
1447
|
+
if (objValue === void 0 && !(key in object)) {
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1450
|
+
} else {
|
|
1451
|
+
var stack = new Stack();
|
|
1452
|
+
if (customizer) {
|
|
1453
|
+
var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
1454
|
+
}
|
|
1455
|
+
if (!(result === void 0 ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
return true;
|
|
1461
|
+
}
|
|
1462
|
+
function baseIteratee(value) {
|
|
1463
|
+
if (typeof value == "function") {
|
|
1464
|
+
return value;
|
|
1465
|
+
}
|
|
1466
|
+
if (value == null) {
|
|
1467
|
+
return identity;
|
|
1468
|
+
}
|
|
1469
|
+
if (typeof value == "object") {
|
|
1470
|
+
return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
|
|
1471
|
+
}
|
|
1472
|
+
return property(value);
|
|
1473
|
+
}
|
|
1474
|
+
function baseKeys(object) {
|
|
1475
|
+
return nativeKeys(Object(object));
|
|
1476
|
+
}
|
|
1477
|
+
function baseMatches(source) {
|
|
1478
|
+
var matchData = getMatchData(source);
|
|
1479
|
+
if (matchData.length == 1 && matchData[0][2]) {
|
|
1480
|
+
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
1481
|
+
}
|
|
1482
|
+
return function(object) {
|
|
1483
|
+
return object === source || baseIsMatch(object, source, matchData);
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function baseMatchesProperty(path2, srcValue) {
|
|
1487
|
+
if (isKey(path2) && isStrictComparable(srcValue)) {
|
|
1488
|
+
return matchesStrictComparable(toKey(path2), srcValue);
|
|
1489
|
+
}
|
|
1490
|
+
return function(object) {
|
|
1491
|
+
var objValue = get(object, path2);
|
|
1492
|
+
return objValue === void 0 && objValue === srcValue ? hasIn(object, path2) : baseIsEqual(srcValue, objValue, void 0, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
function baseProperty(key) {
|
|
1496
|
+
return function(object) {
|
|
1497
|
+
return object == null ? void 0 : object[key];
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function basePropertyDeep(path2) {
|
|
1501
|
+
return function(object) {
|
|
1502
|
+
return baseGet(object, path2);
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
function castPath(value) {
|
|
1506
|
+
return isArray(value) ? value : stringToPath(value);
|
|
1507
|
+
}
|
|
1508
|
+
function createToPairs(keysFunc) {
|
|
1509
|
+
return function(object) {
|
|
1510
|
+
var tag = getTag(object);
|
|
1511
|
+
if (tag == mapTag) {
|
|
1512
|
+
return mapToArray(object);
|
|
1513
|
+
}
|
|
1514
|
+
if (tag == setTag) {
|
|
1515
|
+
return setToPairs(object);
|
|
1516
|
+
}
|
|
1517
|
+
return baseToPairs(object, keysFunc(object));
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
|
1521
|
+
var isPartial = bitmask & PARTIAL_COMPARE_FLAG, arrLength = array.length, othLength = other.length;
|
|
1522
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
1523
|
+
return false;
|
|
1524
|
+
}
|
|
1525
|
+
var stacked = stack.get(array);
|
|
1526
|
+
if (stacked) {
|
|
1527
|
+
return stacked == other;
|
|
1528
|
+
}
|
|
1529
|
+
var index = -1, result = true, seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache() : void 0;
|
|
1530
|
+
stack.set(array, other);
|
|
1531
|
+
while (++index < arrLength) {
|
|
1532
|
+
var arrValue = array[index], othValue = other[index];
|
|
1533
|
+
if (customizer) {
|
|
1534
|
+
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
|
1535
|
+
}
|
|
1536
|
+
if (compared !== void 0) {
|
|
1537
|
+
if (compared) {
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
result = false;
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
if (seen) {
|
|
1544
|
+
if (!arraySome(other, function(othValue2, othIndex) {
|
|
1545
|
+
if (!seen.has(othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, customizer, bitmask, stack))) {
|
|
1546
|
+
return seen.add(othIndex);
|
|
1547
|
+
}
|
|
1548
|
+
})) {
|
|
1549
|
+
result = false;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
|
1553
|
+
result = false;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
stack["delete"](array);
|
|
1558
|
+
return result;
|
|
1559
|
+
}
|
|
1560
|
+
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
|
1561
|
+
switch (tag) {
|
|
1562
|
+
case dataViewTag:
|
|
1563
|
+
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
|
1564
|
+
return false;
|
|
1565
|
+
}
|
|
1566
|
+
object = object.buffer;
|
|
1567
|
+
other = other.buffer;
|
|
1568
|
+
case arrayBufferTag:
|
|
1569
|
+
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
return true;
|
|
1573
|
+
case boolTag:
|
|
1574
|
+
case dateTag:
|
|
1575
|
+
return +object == +other;
|
|
1576
|
+
case errorTag:
|
|
1577
|
+
return object.name == other.name && object.message == other.message;
|
|
1578
|
+
case numberTag:
|
|
1579
|
+
return object != +object ? other != +other : object == +other;
|
|
1580
|
+
case regexpTag:
|
|
1581
|
+
case stringTag:
|
|
1582
|
+
return object == other + "";
|
|
1583
|
+
case mapTag:
|
|
1584
|
+
var convert = mapToArray;
|
|
1585
|
+
case setTag:
|
|
1586
|
+
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
|
1587
|
+
convert || (convert = setToArray);
|
|
1588
|
+
if (object.size != other.size && !isPartial) {
|
|
1589
|
+
return false;
|
|
1590
|
+
}
|
|
1591
|
+
var stacked = stack.get(object);
|
|
1592
|
+
if (stacked) {
|
|
1593
|
+
return stacked == other;
|
|
1594
|
+
}
|
|
1595
|
+
bitmask |= UNORDERED_COMPARE_FLAG;
|
|
1596
|
+
stack.set(object, other);
|
|
1597
|
+
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
|
|
1598
|
+
case symbolTag:
|
|
1599
|
+
if (symbolValueOf) {
|
|
1600
|
+
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
|
1606
|
+
var isPartial = bitmask & PARTIAL_COMPARE_FLAG, objProps = keys(object), objLength = objProps.length, othProps = keys(other), othLength = othProps.length;
|
|
1607
|
+
if (objLength != othLength && !isPartial) {
|
|
1608
|
+
return false;
|
|
1609
|
+
}
|
|
1610
|
+
var index = objLength;
|
|
1611
|
+
while (index--) {
|
|
1612
|
+
var key = objProps[index];
|
|
1613
|
+
if (!(isPartial ? key in other : baseHas(other, key))) {
|
|
1614
|
+
return false;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
var stacked = stack.get(object);
|
|
1618
|
+
if (stacked) {
|
|
1619
|
+
return stacked == other;
|
|
1620
|
+
}
|
|
1621
|
+
var result = true;
|
|
1622
|
+
stack.set(object, other);
|
|
1623
|
+
var skipCtor = isPartial;
|
|
1624
|
+
while (++index < objLength) {
|
|
1625
|
+
key = objProps[index];
|
|
1626
|
+
var objValue = object[key], othValue = other[key];
|
|
1627
|
+
if (customizer) {
|
|
1628
|
+
var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
|
1629
|
+
}
|
|
1630
|
+
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
|
|
1631
|
+
result = false;
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
skipCtor || (skipCtor = key == "constructor");
|
|
1635
|
+
}
|
|
1636
|
+
if (result && !skipCtor) {
|
|
1637
|
+
var objCtor = object.constructor, othCtor = other.constructor;
|
|
1638
|
+
if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
|
|
1639
|
+
result = false;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
stack["delete"](object);
|
|
1643
|
+
return result;
|
|
1644
|
+
}
|
|
1645
|
+
var getLength = baseProperty("length");
|
|
1646
|
+
function getMapData(map, key) {
|
|
1647
|
+
var data = map.__data__;
|
|
1648
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
1649
|
+
}
|
|
1650
|
+
function getMatchData(object) {
|
|
1651
|
+
var result = toPairs(object), length = result.length;
|
|
1652
|
+
while (length--) {
|
|
1653
|
+
result[length][2] = isStrictComparable(result[length][1]);
|
|
1654
|
+
}
|
|
1655
|
+
return result;
|
|
1656
|
+
}
|
|
1657
|
+
function getNative(object, key) {
|
|
1658
|
+
var value = object[key];
|
|
1659
|
+
return isNative(value) ? value : void 0;
|
|
1660
|
+
}
|
|
1661
|
+
function getPrototype(value) {
|
|
1662
|
+
return nativeGetPrototype(Object(value));
|
|
1663
|
+
}
|
|
1664
|
+
function getTag(value) {
|
|
1665
|
+
return objectToString.call(value);
|
|
1666
|
+
}
|
|
1667
|
+
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
|
|
1668
|
+
getTag = function(value) {
|
|
1669
|
+
var result = objectToString.call(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : void 0;
|
|
1670
|
+
if (ctorString) {
|
|
1671
|
+
switch (ctorString) {
|
|
1672
|
+
case dataViewCtorString:
|
|
1673
|
+
return dataViewTag;
|
|
1674
|
+
case mapCtorString:
|
|
1675
|
+
return mapTag;
|
|
1676
|
+
case promiseCtorString:
|
|
1677
|
+
return promiseTag;
|
|
1678
|
+
case setCtorString:
|
|
1679
|
+
return setTag;
|
|
1680
|
+
case weakMapCtorString:
|
|
1681
|
+
return weakMapTag;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return result;
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
function hasPath(object, path2, hasFunc) {
|
|
1688
|
+
path2 = isKey(path2, object) ? [path2] : castPath(path2);
|
|
1689
|
+
var result, index = -1, length = path2.length;
|
|
1690
|
+
while (++index < length) {
|
|
1691
|
+
var key = toKey(path2[index]);
|
|
1692
|
+
if (!(result = object != null && hasFunc(object, key))) {
|
|
1693
|
+
break;
|
|
1694
|
+
}
|
|
1695
|
+
object = object[key];
|
|
1696
|
+
}
|
|
1697
|
+
if (result) {
|
|
1698
|
+
return result;
|
|
1699
|
+
}
|
|
1700
|
+
var length = object ? object.length : 0;
|
|
1701
|
+
return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isString(object) || isArguments(object));
|
|
1702
|
+
}
|
|
1703
|
+
function indexKeys(object) {
|
|
1704
|
+
var length = object ? object.length : void 0;
|
|
1705
|
+
if (isLength(length) && (isArray(object) || isString(object) || isArguments(object))) {
|
|
1706
|
+
return baseTimes(length, String);
|
|
1707
|
+
}
|
|
1708
|
+
return null;
|
|
1709
|
+
}
|
|
1710
|
+
function isIndex(value, length) {
|
|
1711
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
1712
|
+
return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
1713
|
+
}
|
|
1714
|
+
function isKey(value, object) {
|
|
1715
|
+
if (isArray(value)) {
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
var type = typeof value;
|
|
1719
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
|
|
1720
|
+
return true;
|
|
1721
|
+
}
|
|
1722
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
1723
|
+
}
|
|
1724
|
+
function isKeyable(value) {
|
|
1725
|
+
var type = typeof value;
|
|
1726
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
1727
|
+
}
|
|
1728
|
+
function isPrototype(value) {
|
|
1729
|
+
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
|
|
1730
|
+
return value === proto;
|
|
1731
|
+
}
|
|
1732
|
+
function isStrictComparable(value) {
|
|
1733
|
+
return value === value && !isObject(value);
|
|
1734
|
+
}
|
|
1735
|
+
function matchesStrictComparable(key, srcValue) {
|
|
1736
|
+
return function(object) {
|
|
1737
|
+
if (object == null) {
|
|
1738
|
+
return false;
|
|
1739
|
+
}
|
|
1740
|
+
return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
function toKey(value) {
|
|
1744
|
+
if (typeof value == "string" || isSymbol(value)) {
|
|
1745
|
+
return value;
|
|
1746
|
+
}
|
|
1747
|
+
var result = value + "";
|
|
1748
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
1749
|
+
}
|
|
1750
|
+
function toSource(func) {
|
|
1751
|
+
if (func != null) {
|
|
1752
|
+
try {
|
|
1753
|
+
return funcToString.call(func);
|
|
1754
|
+
} catch (e) {
|
|
1755
|
+
}
|
|
1756
|
+
try {
|
|
1757
|
+
return func + "";
|
|
1758
|
+
} catch (e) {
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return "";
|
|
1762
|
+
}
|
|
1763
|
+
function eq(value, other) {
|
|
1764
|
+
return value === other || value !== value && other !== other;
|
|
1765
|
+
}
|
|
1766
|
+
function isArguments(value) {
|
|
1767
|
+
return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag);
|
|
1768
|
+
}
|
|
1769
|
+
var isArray = Array.isArray;
|
|
1770
|
+
function isArrayLike(value) {
|
|
1771
|
+
return value != null && isLength(getLength(value)) && !isFunction(value);
|
|
1772
|
+
}
|
|
1773
|
+
function isArrayLikeObject(value) {
|
|
1774
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
1775
|
+
}
|
|
1776
|
+
function isFunction(value) {
|
|
1777
|
+
var tag = isObject(value) ? objectToString.call(value) : "";
|
|
1778
|
+
return tag == funcTag || tag == genTag;
|
|
1779
|
+
}
|
|
1780
|
+
function isLength(value) {
|
|
1781
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
1782
|
+
}
|
|
1783
|
+
function isObject(value) {
|
|
1784
|
+
var type = typeof value;
|
|
1785
|
+
return !!value && (type == "object" || type == "function");
|
|
1786
|
+
}
|
|
1787
|
+
function isObjectLike(value) {
|
|
1788
|
+
return !!value && typeof value == "object";
|
|
1789
|
+
}
|
|
1790
|
+
function isNative(value) {
|
|
1791
|
+
if (!isObject(value)) {
|
|
1792
|
+
return false;
|
|
1793
|
+
}
|
|
1794
|
+
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
|
|
1795
|
+
return pattern.test(toSource(value));
|
|
1796
|
+
}
|
|
1797
|
+
function isString(value) {
|
|
1798
|
+
return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
|
|
1799
|
+
}
|
|
1800
|
+
function isSymbol(value) {
|
|
1801
|
+
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
1802
|
+
}
|
|
1803
|
+
function isTypedArray(value) {
|
|
1804
|
+
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
|
1805
|
+
}
|
|
1806
|
+
function get(object, path2, defaultValue) {
|
|
1807
|
+
var result = object == null ? void 0 : baseGet(object, path2);
|
|
1808
|
+
return result === void 0 ? defaultValue : result;
|
|
1809
|
+
}
|
|
1810
|
+
function hasIn(object, path2) {
|
|
1811
|
+
return object != null && hasPath(object, path2, baseHasIn);
|
|
1812
|
+
}
|
|
1813
|
+
function keys(object) {
|
|
1814
|
+
var isProto = isPrototype(object);
|
|
1815
|
+
if (!(isProto || isArrayLike(object))) {
|
|
1816
|
+
return baseKeys(object);
|
|
1817
|
+
}
|
|
1818
|
+
var indexes = indexKeys(object), skipIndexes = !!indexes, result = indexes || [], length = result.length;
|
|
1819
|
+
for (var key in object) {
|
|
1820
|
+
if (baseHas(object, key) && !(skipIndexes && (key == "length" || isIndex(key, length))) && !(isProto && key == "constructor")) {
|
|
1821
|
+
result.push(key);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return result;
|
|
1825
|
+
}
|
|
1826
|
+
var toPairs = createToPairs(keys);
|
|
1827
|
+
function identity(value) {
|
|
1828
|
+
return value;
|
|
1829
|
+
}
|
|
1830
|
+
function property(path2) {
|
|
1831
|
+
return isKey(path2) ? baseProperty(toKey(path2)) : basePropertyDeep(path2);
|
|
1832
|
+
}
|
|
1833
|
+
module.exports = baseIteratee;
|
|
1127
1834
|
}
|
|
1128
|
-
return {
|
|
1129
|
-
tusFile: input.stream,
|
|
1130
|
-
size: input.contentLength,
|
|
1131
|
-
contentType,
|
|
1132
|
-
checksums: buildChecksums(input, input.checksumSha256 ?? ""),
|
|
1133
|
-
requiresFiniteChunkSize: true
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
throw new Error("No upload source provided. Pass one of: data, path, or stream.");
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
// src/upload/transport.ts
|
|
1140
|
-
var tus = __toESM(require("tus-js-client"));
|
|
1141
|
-
var DEFAULT_STREAM_CHUNK_SIZE = 50 * 1024 * 1024;
|
|
1142
|
-
var DEFAULT_RETRY_DELAYS = [0, 1e3, 3e3, 5e3];
|
|
1143
|
-
var createAbortError = () => {
|
|
1144
|
-
const error = new Error("The upload was aborted.");
|
|
1145
|
-
error.name = "AbortError";
|
|
1146
|
-
return error;
|
|
1147
|
-
};
|
|
1148
|
-
var tusUploadTransport = (params) => new Promise((resolve, reject) => {
|
|
1149
|
-
if (params.signal?.aborted) {
|
|
1150
|
-
reject(createAbortError());
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
let settled = false;
|
|
1154
|
-
const cleanup = () => {
|
|
1155
|
-
if (params.signal) params.signal.removeEventListener("abort", onAbort);
|
|
1156
|
-
};
|
|
1157
|
-
const finish = (fn) => {
|
|
1158
|
-
if (settled) return;
|
|
1159
|
-
settled = true;
|
|
1160
|
-
cleanup();
|
|
1161
|
-
fn();
|
|
1162
|
-
};
|
|
1163
|
-
const upload = new tus.Upload(params.data, {
|
|
1164
|
-
uploadUrl: params.uploadUrl,
|
|
1165
|
-
uploadSize: params.uploadSize,
|
|
1166
|
-
headers: params.headers,
|
|
1167
|
-
chunkSize: params.chunkSize ?? Infinity,
|
|
1168
|
-
retryDelays: params.retryDelays === void 0 ? DEFAULT_RETRY_DELAYS : params.retryDelays,
|
|
1169
|
-
storeFingerprintForResuming: params.resume ?? false,
|
|
1170
|
-
removeFingerprintOnSuccess: true,
|
|
1171
|
-
...params.urlStorage ? { urlStorage: params.urlStorage } : {},
|
|
1172
|
-
onProgress: params.onProgress ?? null,
|
|
1173
|
-
onError: (error) => finish(() => reject(error)),
|
|
1174
|
-
onSuccess: () => finish(() => resolve())
|
|
1175
1835
|
});
|
|
1176
|
-
const onAbort = () => {
|
|
1177
|
-
void upload.abort();
|
|
1178
|
-
finish(() => reject(createAbortError()));
|
|
1179
|
-
};
|
|
1180
|
-
if (params.signal) params.signal.addEventListener("abort", onAbort, { once: true });
|
|
1181
|
-
upload.start();
|
|
1182
|
-
});
|
|
1183
|
-
var runResolvedUpload = (transport, uploadUrl, resolved, options = {}, headers = { "Tus-Resumable": "1.0.0" }) => transport({
|
|
1184
|
-
data: resolved.tusFile,
|
|
1185
|
-
uploadUrl,
|
|
1186
|
-
uploadSize: resolved.size,
|
|
1187
|
-
headers,
|
|
1188
|
-
chunkSize: options.chunkSize ?? (resolved.requiresFiniteChunkSize ? DEFAULT_STREAM_CHUNK_SIZE : void 0),
|
|
1189
|
-
retryDelays: options.retryDelays,
|
|
1190
|
-
onProgress: options.onProgress,
|
|
1191
|
-
signal: options.signal,
|
|
1192
|
-
resume: options.resume,
|
|
1193
|
-
urlStorage: options.urlStorage
|
|
1194
|
-
});
|
|
1195
|
-
var tusStatus = (error) => {
|
|
1196
|
-
const response = error?.originalResponse;
|
|
1197
|
-
return response ? response.getStatus() : void 0;
|
|
1198
|
-
};
|
|
1199
|
-
var toUploadError = (error) => {
|
|
1200
|
-
if (error instanceof Error && error.name === "AbortError") throw error;
|
|
1201
|
-
const status = tusStatus(error);
|
|
1202
|
-
if (status === 401 || status === 403 || status === 410) {
|
|
1203
|
-
throw new UploadSessionExpiredError(void 0, error);
|
|
1204
|
-
}
|
|
1205
|
-
throw new UploadError(error instanceof Error ? error.message : "The upload failed.", error);
|
|
1206
|
-
};
|
|
1207
|
-
|
|
1208
|
-
// src/resources/storage-buckets.ts
|
|
1209
|
-
var StorageBucketsResource = class extends BaseResource {
|
|
1210
|
-
/**
|
|
1211
|
-
* List all storage buckets for an application.
|
|
1212
|
-
*
|
|
1213
|
-
* @param applicationId - The application ID (UUID).
|
|
1214
|
-
* @param query - Optional pagination parameters.
|
|
1215
|
-
* @returns A paginated list of storage buckets.
|
|
1216
|
-
*
|
|
1217
|
-
* @example
|
|
1218
|
-
* ```ts
|
|
1219
|
-
* const { items, total } = await client.applications.storage.buckets.list('app-id');
|
|
1220
|
-
* console.log(`${total} buckets found`);
|
|
1221
|
-
* ```
|
|
1222
|
-
*/
|
|
1223
|
-
async list(applicationId, query) {
|
|
1224
|
-
return this.httpClient.get(`/applications/${applicationId}/storage/buckets`, {
|
|
1225
|
-
query
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
/**
|
|
1229
|
-
* Create a new storage bucket.
|
|
1230
|
-
*
|
|
1231
|
-
* @param applicationId - The application ID (UUID).
|
|
1232
|
-
* @param data - Bucket name, environment, and optional slug/visibility.
|
|
1233
|
-
* @returns The newly created bucket.
|
|
1234
|
-
*
|
|
1235
|
-
* @example
|
|
1236
|
-
* ```ts
|
|
1237
|
-
* const bucket = await client.applications.storage.buckets.create('app-id', {
|
|
1238
|
-
* name: 'Assets',
|
|
1239
|
-
* environmentId: 'env-id',
|
|
1240
|
-
* visibility: 'public',
|
|
1241
|
-
* });
|
|
1242
|
-
* console.log(`Bucket CDN: https://${bucket.cdnHostname}`);
|
|
1243
|
-
* ```
|
|
1244
|
-
*/
|
|
1245
|
-
async create(applicationId, data) {
|
|
1246
|
-
return this.httpClient.post(`/applications/${applicationId}/storage/buckets`, data);
|
|
1247
|
-
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Get a storage bucket by ID.
|
|
1250
|
-
*
|
|
1251
|
-
* @param applicationId - The application ID (UUID).
|
|
1252
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1253
|
-
* @returns The bucket details.
|
|
1254
|
-
*
|
|
1255
|
-
* @example
|
|
1256
|
-
* ```ts
|
|
1257
|
-
* const bucket = await client.applications.storage.buckets.get('app-id', 'bucket-id');
|
|
1258
|
-
* console.log(`${bucket.name} (${bucket.visibility})`);
|
|
1259
|
-
* ```
|
|
1260
|
-
*/
|
|
1261
|
-
async get(applicationId, bucketId) {
|
|
1262
|
-
return this.httpClient.get(`/applications/${applicationId}/storage/buckets/${bucketId}`);
|
|
1263
|
-
}
|
|
1264
|
-
/**
|
|
1265
|
-
* Permanently delete a storage bucket and all its objects.
|
|
1266
|
-
*
|
|
1267
|
-
* @param applicationId - The application ID (UUID).
|
|
1268
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1269
|
-
*
|
|
1270
|
-
* @example
|
|
1271
|
-
* ```ts
|
|
1272
|
-
* await client.applications.storage.buckets.delete('app-id', 'bucket-id');
|
|
1273
|
-
* ```
|
|
1274
|
-
*/
|
|
1275
|
-
async delete(applicationId, bucketId) {
|
|
1276
|
-
return this.httpClient.delete(`/applications/${applicationId}/storage/buckets/${bucketId}`);
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
// src/resources/storage-objects.ts
|
|
1281
|
-
var StorageObjectsResource = class extends BaseResource {
|
|
1282
|
-
/**
|
|
1283
|
-
* List objects in a storage bucket, optionally filtered by key prefix and
|
|
1284
|
-
* grouped into virtual folders by a delimiter.
|
|
1285
|
-
*
|
|
1286
|
-
* @param applicationId - The application ID (UUID).
|
|
1287
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1288
|
-
* @param query - Optional prefix/delimiter/cursor/limit parameters.
|
|
1289
|
-
* @returns A page of objects plus any common (folder) prefixes and a `nextCursor`.
|
|
1290
|
-
*
|
|
1291
|
-
* @example
|
|
1292
|
-
* ```ts
|
|
1293
|
-
* // List the "images/" folder, one level deep
|
|
1294
|
-
* const { items, commonPrefixes, nextCursor } = await client.applications.storage.objects.list(
|
|
1295
|
-
* 'app-id', 'bucket-id', { prefix: 'images/', limit: 100 },
|
|
1296
|
-
* );
|
|
1297
|
-
* ```
|
|
1298
|
-
*/
|
|
1299
|
-
async list(applicationId, bucketId, query) {
|
|
1300
|
-
return this.httpClient.get(`/applications/${applicationId}/storage/buckets/${bucketId}/objects`, {
|
|
1301
|
-
query
|
|
1302
|
-
});
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Get metadata for a specific object by its object ID.
|
|
1306
|
-
*
|
|
1307
|
-
* @param applicationId - The application ID (UUID).
|
|
1308
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1309
|
-
* @param objectId - The object ID (UUID) — not the object key. Use {@link getByKey} to resolve a key.
|
|
1310
|
-
* @returns The object metadata.
|
|
1311
|
-
*
|
|
1312
|
-
* @example
|
|
1313
|
-
* ```ts
|
|
1314
|
-
* const obj = await client.applications.storage.objects.get('app-id', 'bucket-id', 'object-id');
|
|
1315
|
-
* console.log(`${obj.key}: ${obj.contentLength} bytes, type: ${obj.contentType}`);
|
|
1316
|
-
* ```
|
|
1317
|
-
*/
|
|
1318
|
-
async get(applicationId, bucketId, objectId) {
|
|
1319
|
-
return this.httpClient.get(`/applications/${applicationId}/storage/buckets/${bucketId}/objects/${objectId}`);
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Resolve an object by its key (path) instead of its ID. Convenience over
|
|
1323
|
-
* {@link list} — lists with the key as the prefix and returns the exact match,
|
|
1324
|
-
* paging through results until found, or `null` if no object with that key
|
|
1325
|
-
* exists. (The API has no get-by-key endpoint.)
|
|
1326
|
-
*
|
|
1327
|
-
* @param applicationId - The application ID (UUID).
|
|
1328
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1329
|
-
* @param key - The object key/path (e.g. `"images/photo.jpg"`).
|
|
1330
|
-
* @returns The matching object, or `null` if not found.
|
|
1331
|
-
*/
|
|
1332
|
-
async getByKey(applicationId, bucketId, key) {
|
|
1333
|
-
let cursor;
|
|
1334
|
-
do {
|
|
1335
|
-
const page = await this.list(applicationId, bucketId, { prefix: key, delimiter: "", cursor });
|
|
1336
|
-
const match = page.items.find((object) => object.key === key);
|
|
1337
|
-
if (match) return match;
|
|
1338
|
-
cursor = page.nextCursor;
|
|
1339
|
-
} while (cursor);
|
|
1340
|
-
return null;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Permanently delete an object from a storage bucket.
|
|
1344
|
-
*
|
|
1345
|
-
* @param applicationId - The application ID (UUID).
|
|
1346
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1347
|
-
* @param objectId - The object ID (UUID) — not the object key.
|
|
1348
|
-
*
|
|
1349
|
-
* @example
|
|
1350
|
-
* ```ts
|
|
1351
|
-
* await client.applications.storage.objects.delete('app-id', 'bucket-id', 'object-id');
|
|
1352
|
-
* ```
|
|
1353
|
-
*/
|
|
1354
|
-
async delete(applicationId, bucketId, objectId) {
|
|
1355
|
-
return this.httpClient.delete(`/applications/${applicationId}/storage/buckets/${bucketId}/objects/${objectId}`);
|
|
1356
|
-
}
|
|
1357
|
-
/**
|
|
1358
|
-
* Get an access URL for a storage object. For objects in public buckets,
|
|
1359
|
-
* returns a stable CDN URL. For private buckets, returns a time-limited
|
|
1360
|
-
* signed URL.
|
|
1361
|
-
*
|
|
1362
|
-
* @param applicationId - The application ID (UUID).
|
|
1363
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1364
|
-
* @param objectId - The object ID (UUID) — not the object key.
|
|
1365
|
-
* @param options - Optional `expiresInSeconds` for signed URLs (60–86400).
|
|
1366
|
-
* @returns The access URL and its type/expiry.
|
|
1367
|
-
*
|
|
1368
|
-
* @example
|
|
1369
|
-
* ```ts
|
|
1370
|
-
* const access = await client.applications.storage.objects.getAccessUrl('app-id', 'bucket-id', 'object-id', {
|
|
1371
|
-
* expiresInSeconds: 3600,
|
|
1372
|
-
* });
|
|
1373
|
-
* if (access.accessType === 'signed') {
|
|
1374
|
-
* console.log(`Signed URL expires at ${access.expiresAt}`);
|
|
1375
|
-
* }
|
|
1376
|
-
* console.log(`Download: ${access.url}`);
|
|
1377
|
-
* ```
|
|
1378
|
-
*/
|
|
1379
|
-
async getAccessUrl(applicationId, bucketId, objectId, options) {
|
|
1380
|
-
return this.httpClient.get(
|
|
1381
|
-
`/applications/${applicationId}/storage/buckets/${bucketId}/objects/${objectId}/access-url`,
|
|
1382
|
-
{ query: { expiresInSeconds: options?.expiresInSeconds } }
|
|
1383
|
-
);
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
1836
|
|
|
1387
|
-
//
|
|
1388
|
-
var
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
*/
|
|
1418
|
-
async create(applicationId, bucketId, data) {
|
|
1419
|
-
return this.httpClient.post(`/applications/${applicationId}/storage/buckets/${bucketId}/uploads`, data);
|
|
1420
|
-
}
|
|
1421
|
-
/**
|
|
1422
|
-
* Get an upload session by ID. Use this to track server-side processing after
|
|
1423
|
-
* an upload (poll until `state === 'completed'`).
|
|
1424
|
-
*
|
|
1425
|
-
* @param applicationId - The application ID (UUID).
|
|
1426
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1427
|
-
* @param sessionId - The upload session ID (UUID).
|
|
1428
|
-
* @returns The current session state.
|
|
1429
|
-
*/
|
|
1430
|
-
async get(applicationId, bucketId, sessionId) {
|
|
1431
|
-
return this.httpClient.get(`/applications/${applicationId}/storage/buckets/${bucketId}/uploads/${sessionId}`);
|
|
1432
|
-
}
|
|
1433
|
-
/**
|
|
1434
|
-
* Upload bytes directly to a pre-existing signed upload URL — for example, a
|
|
1435
|
-
* URL returned by {@link create} or handed to your client by a backend. Skips
|
|
1436
|
-
* session creation and checksum computation.
|
|
1437
|
-
*
|
|
1438
|
-
* @param url - A signed upload URL.
|
|
1439
|
-
* @param source - The bytes to upload.
|
|
1440
|
-
* @param options - Chunk size, retry config, progress, abort signal, resume,
|
|
1441
|
-
* and any required `headers` returned with the upload session.
|
|
1442
|
-
* @throws {@link UploadError} if the upload fails after all retries.
|
|
1443
|
-
*/
|
|
1444
|
-
async uploadToUrl(url, source, options) {
|
|
1445
|
-
const resolved = await resolveUploadSource({ key: "", ...source }, { hash: false });
|
|
1446
|
-
const headers = { "Tus-Resumable": "1.0.0", ...options?.headers };
|
|
1447
|
-
await runResolvedUpload(this.transport, url, resolved, options, headers).catch(toUploadError);
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Resume an interrupted upload to a previously issued signed upload URL. The
|
|
1451
|
-
* resumable protocol negotiates the current offset and continues from there.
|
|
1452
|
-
*
|
|
1453
|
-
* @param url - The signed upload URL from the original {@link create} call.
|
|
1454
|
-
* @param source - The full bytes to upload (the same content as the original).
|
|
1455
|
-
* @param options - Chunk size, retry config, progress, abort signal.
|
|
1456
|
-
*/
|
|
1457
|
-
async resumeFromUrl(url, source, options) {
|
|
1458
|
-
return this.uploadToUrl(url, source, { ...options, resume: true });
|
|
1459
|
-
}
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1462
|
-
// src/resources/application-storage.ts
|
|
1463
|
-
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1464
|
-
var ApplicationStorageResource = class {
|
|
1465
|
-
/** Create, list, get, and delete storage buckets. */
|
|
1466
|
-
buckets;
|
|
1467
|
-
/** List, get, delete objects, and generate access URLs. */
|
|
1468
|
-
objects;
|
|
1469
|
-
/** Low-level upload sessions and direct-to-URL byte uploads. */
|
|
1470
|
-
uploadSessions;
|
|
1471
|
-
transport;
|
|
1472
|
-
constructor(httpClient, transport = tusUploadTransport) {
|
|
1473
|
-
this.transport = transport;
|
|
1474
|
-
this.buckets = new StorageBucketsResource(httpClient);
|
|
1475
|
-
this.objects = new StorageObjectsResource(httpClient);
|
|
1476
|
-
this.uploadSessions = new StorageUploadSessionsResource(httpClient, transport);
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Upload a file to a storage bucket. Handles the full flow: computes the
|
|
1480
|
-
* required SHA-256 checksum, creates an upload session, uploads the bytes with
|
|
1481
|
-
* automatic retries (and optional progress/abort/resume), and returns the
|
|
1482
|
-
* public URL.
|
|
1483
|
-
*
|
|
1484
|
-
* Accepts browser `File`/`Blob`, Node `Buffer`/`Uint8Array`/`ArrayBuffer`, a
|
|
1485
|
-
* Node filesystem `path`, or a Node readable `stream` (with `contentLength`
|
|
1486
|
-
* and `checksumSha256`). The content type is inferred from `key` when omitted.
|
|
1487
|
-
*
|
|
1488
|
-
* @param input - What and where to upload, plus optional transfer options.
|
|
1489
|
-
* @returns The upload session and public object URL (and the finalized object when `waitForCompletion` is set).
|
|
1490
|
-
* @throws {@link UploadError} if the byte upload fails.
|
|
1491
|
-
* @throws {@link UploadSessionExpiredError} if the session expires mid-upload.
|
|
1492
|
-
*
|
|
1493
|
-
* @example
|
|
1494
|
-
* ```ts
|
|
1495
|
-
* const { session, url, object } = await client.applications.storage.upload({
|
|
1496
|
-
* applicationId, bucketId, key: 'reports/q1.pdf', path: './q1.pdf',
|
|
1497
|
-
* waitForCompletion: true,
|
|
1498
|
-
* });
|
|
1499
|
-
* console.log(object?.contentLength, 'bytes available at', url);
|
|
1500
|
-
* ```
|
|
1501
|
-
*/
|
|
1502
|
-
async upload(input) {
|
|
1503
|
-
const resolved = await resolveUploadSource({
|
|
1504
|
-
key: input.key,
|
|
1505
|
-
data: input.data,
|
|
1506
|
-
path: input.path,
|
|
1507
|
-
stream: input.stream,
|
|
1508
|
-
contentType: input.contentType,
|
|
1509
|
-
contentLength: input.contentLength,
|
|
1510
|
-
checksumSha256: input.checksumSha256,
|
|
1511
|
-
checksumSha1: input.checksumSha1,
|
|
1512
|
-
checksumMd5: input.checksumMd5
|
|
1513
|
-
});
|
|
1514
|
-
const { session, upload } = await this.uploadSessions.create(input.applicationId, input.bucketId, {
|
|
1515
|
-
key: input.key,
|
|
1516
|
-
contentLength: resolved.size,
|
|
1517
|
-
checksumSha256: resolved.checksums.sha256,
|
|
1518
|
-
contentType: resolved.contentType,
|
|
1519
|
-
checksumSha1: resolved.checksums.sha1,
|
|
1520
|
-
checksumMd5: resolved.checksums.md5
|
|
1521
|
-
});
|
|
1522
|
-
await runResolvedUpload(
|
|
1523
|
-
this.transport,
|
|
1524
|
-
upload.url,
|
|
1525
|
-
resolved,
|
|
1526
|
-
{
|
|
1527
|
-
chunkSize: input.chunkSize,
|
|
1528
|
-
retryDelays: input.retryDelays,
|
|
1529
|
-
onProgress: input.onProgress,
|
|
1530
|
-
signal: input.signal,
|
|
1531
|
-
resume: input.resume,
|
|
1532
|
-
urlStorage: input.urlStorage
|
|
1533
|
-
},
|
|
1534
|
-
// Forward any required headers the API issued with the session.
|
|
1535
|
-
{ "Tus-Resumable": "1.0.0", ...upload.headers }
|
|
1536
|
-
).catch(toUploadError);
|
|
1537
|
-
if (input.waitForCompletion) {
|
|
1538
|
-
const options = typeof input.waitForCompletion === "object" ? input.waitForCompletion : void 0;
|
|
1539
|
-
const completed = await this.waitForCompletion(input.applicationId, input.bucketId, session.id, options);
|
|
1540
|
-
const object = await this.objects.getByKey(input.applicationId, input.bucketId, input.key) ?? void 0;
|
|
1541
|
-
return { session: completed, url: upload.publicObjectUrl, object };
|
|
1542
|
-
}
|
|
1543
|
-
return { session, url: upload.publicObjectUrl };
|
|
1544
|
-
}
|
|
1545
|
-
/**
|
|
1546
|
-
* Upload many files concurrently. Each file is uploaded independently; a
|
|
1547
|
-
* failure for one file does not abort the others — inspect each item's
|
|
1548
|
-
* `error`/`result`.
|
|
1549
|
-
*
|
|
1550
|
-
* @param inputs - The files to upload.
|
|
1551
|
-
* @param options - Concurrency limit and an aggregated progress callback.
|
|
1552
|
-
* @returns One result per input, in the same order.
|
|
1553
|
-
*
|
|
1554
|
-
* @example
|
|
1555
|
-
* ```ts
|
|
1556
|
-
* const results = await client.applications.storage.uploadBatch(
|
|
1557
|
-
* files.map((f) => ({ applicationId, bucketId, key: `uploads/${f.name}`, data: f })),
|
|
1558
|
-
* { concurrency: 6, onProgress: (done, total) => console.log(`${done}/${total}`) },
|
|
1559
|
-
* );
|
|
1560
|
-
* const failed = results.filter((r) => r.error);
|
|
1561
|
-
* ```
|
|
1562
|
-
*/
|
|
1563
|
-
async uploadBatch(inputs, options) {
|
|
1564
|
-
const concurrency = Math.max(1, options?.concurrency ?? 4);
|
|
1565
|
-
const results = new Array(inputs.length);
|
|
1566
|
-
let completed = 0;
|
|
1567
|
-
let next = 0;
|
|
1568
|
-
const worker = async () => {
|
|
1569
|
-
for (; ; ) {
|
|
1570
|
-
const index = next++;
|
|
1571
|
-
if (index >= inputs.length) return;
|
|
1572
|
-
try {
|
|
1573
|
-
results[index] = { input: inputs[index], result: await this.upload(inputs[index]) };
|
|
1574
|
-
} catch (error) {
|
|
1575
|
-
results[index] = { input: inputs[index], error };
|
|
1837
|
+
// ../../node_modules/.pnpm/lodash._createset@4.0.3/node_modules/lodash._createset/index.js
|
|
1838
|
+
var require_lodash5 = __commonJS({
|
|
1839
|
+
"../../node_modules/.pnpm/lodash._createset@4.0.3/node_modules/lodash._createset/index.js"(exports, module) {
|
|
1840
|
+
"use strict";
|
|
1841
|
+
var INFINITY = 1 / 0;
|
|
1842
|
+
var funcTag = "[object Function]";
|
|
1843
|
+
var genTag = "[object GeneratorFunction]";
|
|
1844
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1845
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1846
|
+
var objectTypes = {
|
|
1847
|
+
"function": true,
|
|
1848
|
+
"object": true
|
|
1849
|
+
};
|
|
1850
|
+
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType ? exports : void 0;
|
|
1851
|
+
var freeModule = objectTypes[typeof module] && module && !module.nodeType ? module : void 0;
|
|
1852
|
+
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == "object" && global);
|
|
1853
|
+
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
|
1854
|
+
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
|
1855
|
+
var thisGlobal = checkGlobal(objectTypes[typeof exports] && exports);
|
|
1856
|
+
var root = freeGlobal || freeWindow !== (thisGlobal && thisGlobal.window) && freeWindow || freeSelf || thisGlobal || Function("return this")();
|
|
1857
|
+
function checkGlobal(value) {
|
|
1858
|
+
return value && value.Object === Object ? value : null;
|
|
1859
|
+
}
|
|
1860
|
+
function isHostObject(value) {
|
|
1861
|
+
var result = false;
|
|
1862
|
+
if (value != null && typeof value.toString != "function") {
|
|
1863
|
+
try {
|
|
1864
|
+
result = !!(value + "");
|
|
1865
|
+
} catch (e) {
|
|
1866
|
+
}
|
|
1576
1867
|
}
|
|
1577
|
-
|
|
1578
|
-
options?.onProgress?.(completed, inputs.length);
|
|
1868
|
+
return result;
|
|
1579
1869
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1870
|
+
function setToArray(set) {
|
|
1871
|
+
var index = -1, result = Array(set.size);
|
|
1872
|
+
set.forEach(function(value) {
|
|
1873
|
+
result[++index] = value;
|
|
1874
|
+
});
|
|
1875
|
+
return result;
|
|
1876
|
+
}
|
|
1877
|
+
var objectProto = Object.prototype;
|
|
1878
|
+
var funcToString = Function.prototype.toString;
|
|
1879
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1880
|
+
var objectToString = objectProto.toString;
|
|
1881
|
+
var reIsNative = RegExp(
|
|
1882
|
+
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
1883
|
+
);
|
|
1884
|
+
var Set = getNative(root, "Set");
|
|
1885
|
+
var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function(values) {
|
|
1886
|
+
return new Set(values);
|
|
1887
|
+
};
|
|
1888
|
+
function getNative(object, key) {
|
|
1889
|
+
var value = object[key];
|
|
1890
|
+
return isNative(value) ? value : void 0;
|
|
1891
|
+
}
|
|
1892
|
+
function toSource(func) {
|
|
1893
|
+
if (func != null) {
|
|
1894
|
+
try {
|
|
1895
|
+
return funcToString.call(func);
|
|
1896
|
+
} catch (e) {
|
|
1897
|
+
}
|
|
1898
|
+
try {
|
|
1899
|
+
return func + "";
|
|
1900
|
+
} catch (e) {
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return "";
|
|
1904
|
+
}
|
|
1905
|
+
function isFunction(value) {
|
|
1906
|
+
var tag = isObject(value) ? objectToString.call(value) : "";
|
|
1907
|
+
return tag == funcTag || tag == genTag;
|
|
1908
|
+
}
|
|
1909
|
+
function isObject(value) {
|
|
1910
|
+
var type = typeof value;
|
|
1911
|
+
return !!value && (type == "object" || type == "function");
|
|
1912
|
+
}
|
|
1913
|
+
function isNative(value) {
|
|
1914
|
+
if (!isObject(value)) {
|
|
1915
|
+
return false;
|
|
1916
|
+
}
|
|
1917
|
+
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
|
|
1918
|
+
return pattern.test(toSource(value));
|
|
1919
|
+
}
|
|
1920
|
+
function noop() {
|
|
1921
|
+
}
|
|
1922
|
+
module.exports = createSet;
|
|
1608
1923
|
}
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
// src/resources/applications.ts
|
|
1613
|
-
var ApplicationsResource = class extends BaseResource {
|
|
1614
|
-
/**
|
|
1615
|
-
* Manage environment variables scoped to an application.
|
|
1616
|
-
*
|
|
1617
|
-
* @example
|
|
1618
|
-
* ```ts
|
|
1619
|
-
* await client.applications.envVars.create('app-id', {
|
|
1620
|
-
* key: 'DATABASE_URL',
|
|
1621
|
-
* value: 'postgres://...',
|
|
1622
|
-
* sensitive: true,
|
|
1623
|
-
* });
|
|
1624
|
-
* ```
|
|
1625
|
-
*/
|
|
1626
|
-
envVars;
|
|
1627
|
-
/**
|
|
1628
|
-
* Manage storage buckets, objects, and file uploads for an application.
|
|
1629
|
-
*
|
|
1630
|
-
* @example
|
|
1631
|
-
* ```ts
|
|
1632
|
-
* // Upload a file
|
|
1633
|
-
* const { url } = await client.applications.storage.upload({
|
|
1634
|
-
* applicationId: 'app-id',
|
|
1635
|
-
* bucketId: 'bucket-id',
|
|
1636
|
-
* key: 'images/logo.png',
|
|
1637
|
-
* data: fileData,
|
|
1638
|
-
* });
|
|
1639
|
-
*
|
|
1640
|
-
* // List objects in a bucket
|
|
1641
|
-
* const { items } = await client.applications.storage.objects.list('app-id', 'bucket-id');
|
|
1642
|
-
* ```
|
|
1643
|
-
*/
|
|
1644
|
-
storage;
|
|
1645
|
-
/**
|
|
1646
|
-
* Read observed traffic (request logs) for an application.
|
|
1647
|
-
*
|
|
1648
|
-
* @example
|
|
1649
|
-
* ```ts
|
|
1650
|
-
* const { items } = await client.applications.requests.list('app-id', { statusFamily: 5 });
|
|
1651
|
-
* ```
|
|
1652
|
-
*/
|
|
1653
|
-
requests;
|
|
1654
|
-
constructor(...args) {
|
|
1655
|
-
super(...args);
|
|
1656
|
-
this.envVars = new ApplicationEnvVarsResource(this.httpClient);
|
|
1657
|
-
this.storage = new ApplicationStorageResource(this.httpClient);
|
|
1658
|
-
this.requests = new ApplicationRequestsResource(this.httpClient);
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* List applications the authenticated actor has access to.
|
|
1662
|
-
*
|
|
1663
|
-
* Requires the `network:applications:read` scope.
|
|
1664
|
-
*
|
|
1665
|
-
* @param query - Optional organization filter and pagination.
|
|
1666
|
-
* @returns A paginated list of applications.
|
|
1667
|
-
*
|
|
1668
|
-
* @example
|
|
1669
|
-
* ```ts
|
|
1670
|
-
* const { items, total } = await client.applications.list({ organizationId: 'org-id' });
|
|
1671
|
-
* console.log(`Found ${total} applications`);
|
|
1672
|
-
* ```
|
|
1673
|
-
*/
|
|
1674
|
-
async list(query) {
|
|
1675
|
-
return this.httpClient.get("/applications", {
|
|
1676
|
-
query
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* Creates an application with production and preview environments.
|
|
1681
|
-
*
|
|
1682
|
-
* Requires the `network:applications:write` scope and access to the owning
|
|
1683
|
-
* organization. Application-, deployment-, and function-scoped tokens cannot
|
|
1684
|
-
* create applications.
|
|
1685
|
-
*
|
|
1686
|
-
* @param input - Ownership, display name, and optional repository layout.
|
|
1687
|
-
* @returns The persisted application plus the default production environment
|
|
1688
|
-
* slug, ready for an immediate deployment request.
|
|
1689
|
-
*
|
|
1690
|
-
* @example
|
|
1691
|
-
* ```ts
|
|
1692
|
-
* const app = await client.applications.create({
|
|
1693
|
-
* organizationId: 'org-id',
|
|
1694
|
-
* name: 'Next.js Storefront',
|
|
1695
|
-
* });
|
|
1696
|
-
* console.log(app.id, app.defaultEnvironmentSlug);
|
|
1697
|
-
* ```
|
|
1698
|
-
*/
|
|
1699
|
-
async create(input) {
|
|
1700
|
-
return this.httpClient.post("/applications", input);
|
|
1701
|
-
}
|
|
1702
|
-
/**
|
|
1703
|
-
* List the `*.gigadrive.app` hostnames for an application (production alias
|
|
1704
|
-
* and per-branch aliases).
|
|
1705
|
-
*
|
|
1706
|
-
* @param applicationId - The application ID (UUID).
|
|
1707
|
-
* @returns The hostnames plus the production hostname `label`.
|
|
1708
|
-
*
|
|
1709
|
-
* @example
|
|
1710
|
-
* ```ts
|
|
1711
|
-
* const { items, label } = await client.applications.hostnames('app-id');
|
|
1712
|
-
* console.log(`Production: ${label}.gigadrive.app`);
|
|
1713
|
-
* ```
|
|
1714
|
-
*/
|
|
1715
|
-
async hostnames(applicationId) {
|
|
1716
|
-
return this.httpClient.get(`/applications/${applicationId}/hostnames`);
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Check whether a candidate production hostname label is allowed and globally
|
|
1720
|
-
* available before setting it with {@link setProductionHostname}.
|
|
1721
|
-
*
|
|
1722
|
-
* Requires the `network:applications:read` scope.
|
|
1723
|
-
*
|
|
1724
|
-
* @param applicationId - The application ID (UUID).
|
|
1725
|
-
* @param label - The candidate production hostname label (e.g. `"my-app"`).
|
|
1726
|
-
* @returns Whether the label is available, plus a `reason` when it is not.
|
|
1727
|
-
*
|
|
1728
|
-
* @example
|
|
1729
|
-
* ```ts
|
|
1730
|
-
* const { available, reason } = await client.applications.checkHostnameAvailability('app-id', 'my-app');
|
|
1731
|
-
* if (!available) console.log(`Unavailable: ${reason}`);
|
|
1732
|
-
* ```
|
|
1733
|
-
*/
|
|
1734
|
-
async checkHostnameAvailability(applicationId, label) {
|
|
1735
|
-
return this.httpClient.get(`/applications/${applicationId}/hostname/availability`, {
|
|
1736
|
-
query: { label }
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
/**
|
|
1740
|
-
* Set the application's production hostname. The production alias
|
|
1741
|
-
* `{label}.gigadrive.app` is re-pointed to the latest production deployment.
|
|
1742
|
-
*
|
|
1743
|
-
* Requires the `network:applications:write` scope. Deployment- and
|
|
1744
|
-
* function-scoped tokens cannot change the production hostname.
|
|
1745
|
-
*
|
|
1746
|
-
* @param applicationId - The application ID (UUID).
|
|
1747
|
-
* @param label - The production hostname label (e.g. `"my-app"`). It is
|
|
1748
|
-
* normalized (slugified) server-side.
|
|
1749
|
-
* @returns The saved label, the resulting hostname, and whether it is live yet.
|
|
1750
|
-
*
|
|
1751
|
-
* @example
|
|
1752
|
-
* ```ts
|
|
1753
|
-
* const { hostname, live } = await client.applications.setProductionHostname('app-id', 'my-app');
|
|
1754
|
-
* console.log(live ? `Live at ${hostname}` : `Reserved ${hostname} (deploy to go live)`);
|
|
1755
|
-
* ```
|
|
1756
|
-
*/
|
|
1757
|
-
async setProductionHostname(applicationId, label) {
|
|
1758
|
-
return this.httpClient.put(`/applications/${applicationId}/hostname`, { label });
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1924
|
+
});
|
|
1761
1925
|
|
|
1762
|
-
//
|
|
1763
|
-
var
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
async list(query) {
|
|
1782
|
-
return this.httpClient.get("/deployments", {
|
|
1783
|
-
query
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
/**
|
|
1787
|
-
* Get a deployment by ID, including its current status.
|
|
1788
|
-
*
|
|
1789
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1790
|
-
* @returns The deployment with its current status.
|
|
1791
|
-
*
|
|
1792
|
-
* @example
|
|
1793
|
-
* ```ts
|
|
1794
|
-
* const deployment = await client.deployments.get('deployment-id');
|
|
1795
|
-
* if (deployment.status === 'ACTIVE') {
|
|
1796
|
-
* console.log('Deployment is live!');
|
|
1797
|
-
* }
|
|
1798
|
-
* ```
|
|
1799
|
-
*/
|
|
1800
|
-
async get(deploymentId) {
|
|
1801
|
-
return this.httpClient.get(`/deployments/${deploymentId}`);
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Create a new deployment. The deployment starts in `"PENDING"` status,
|
|
1805
|
-
* waiting for artifact upload. Use the multipart upload methods
|
|
1806
|
-
* ({@link startUpload}, {@link getPresignedUrl}, {@link uploadPart},
|
|
1807
|
-
* {@link completeUpload}) to upload build artifacts.
|
|
1808
|
-
*
|
|
1809
|
-
* Requires the `network:deployments:trigger` scope.
|
|
1810
|
-
*
|
|
1811
|
-
* @param data - The application ID and optional git source.
|
|
1812
|
-
* @returns The newly created deployment.
|
|
1813
|
-
*
|
|
1814
|
-
* @example
|
|
1815
|
-
* ```ts
|
|
1816
|
-
* const deployment = await client.deployments.create({
|
|
1817
|
-
* applicationId: 'app-id',
|
|
1818
|
-
* });
|
|
1819
|
-
* console.log(`Created deployment ${deployment.id} (${deployment.status})`);
|
|
1820
|
-
* ```
|
|
1821
|
-
*/
|
|
1822
|
-
async create(data) {
|
|
1823
|
-
return this.httpClient.post("/deployments", data);
|
|
1824
|
-
}
|
|
1825
|
-
/**
|
|
1826
|
-
* Start a multipart upload for deployment artifacts. This initiates a new
|
|
1827
|
-
* multipart upload and returns an upload ID for subsequent part uploads.
|
|
1828
|
-
*
|
|
1829
|
-
* The deployment must be in `"PENDING"` status.
|
|
1830
|
-
*
|
|
1831
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1832
|
-
* @returns An object containing the `uploadId` for subsequent calls.
|
|
1833
|
-
*
|
|
1834
|
-
* @example
|
|
1835
|
-
* ```ts
|
|
1836
|
-
* const { uploadId } = await client.deployments.startUpload('deployment-id');
|
|
1837
|
-
* ```
|
|
1838
|
-
*/
|
|
1839
|
-
async startUpload(deploymentId) {
|
|
1840
|
-
return this.httpClient.post(`/deployments/${deploymentId}/upload/start`);
|
|
1841
|
-
}
|
|
1842
|
-
/**
|
|
1843
|
-
* Get a presigned URL for uploading a single part of a multipart upload.
|
|
1844
|
-
* The URL is temporary and should be used immediately with {@link uploadPart}.
|
|
1845
|
-
*
|
|
1846
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1847
|
-
* @param uploadId - The multipart upload ID from {@link startUpload}.
|
|
1848
|
-
* @param partNumber - The 1-based part number.
|
|
1849
|
-
* @returns An object containing the presigned `url` to PUT the part data to.
|
|
1850
|
-
*
|
|
1851
|
-
* @example
|
|
1852
|
-
* ```ts
|
|
1853
|
-
* const { url } = await client.deployments.getPresignedUrl(
|
|
1854
|
-
* 'deployment-id', uploadId, 1,
|
|
1855
|
-
* );
|
|
1856
|
-
* ```
|
|
1857
|
-
*/
|
|
1858
|
-
async getPresignedUrl(deploymentId, uploadId, partNumber) {
|
|
1859
|
-
if (!Number.isInteger(partNumber) || partNumber < 1) {
|
|
1860
|
-
throw new Error(`partNumber must be a positive integer, received ${partNumber}`);
|
|
1861
|
-
}
|
|
1862
|
-
return this.httpClient.post(`/deployments/${deploymentId}/upload/part`, { uploadId, partNumber });
|
|
1863
|
-
}
|
|
1864
|
-
/**
|
|
1865
|
-
* Upload a part to a presigned URL obtained from {@link getPresignedUrl}.
|
|
1866
|
-
* This sends the chunk data directly to the backend storage service, not
|
|
1867
|
-
* to the Gigadrive API. The returned `etag` is needed for
|
|
1868
|
-
* {@link completeUpload}.
|
|
1869
|
-
*
|
|
1870
|
-
* @param presignedUrl - The presigned URL from {@link getPresignedUrl}.
|
|
1871
|
-
* @param data - The chunk data to upload.
|
|
1872
|
-
* @param partNumber - The 1-based part number (used for error messages).
|
|
1873
|
-
* @returns The part number and ETag. Collect these for {@link completeUpload}.
|
|
1874
|
-
* @throws {@link ApiError} if the PUT request fails.
|
|
1875
|
-
* @throws Error if the storage provider does not return an ETag header.
|
|
1876
|
-
*
|
|
1877
|
-
* @example
|
|
1878
|
-
* ```ts
|
|
1879
|
-
* const chunk = fileBuffer.subarray(0, 10 * 1024 * 1024); // 10 MB
|
|
1880
|
-
* const part = await client.deployments.uploadPart(presignedUrl, chunk, 1);
|
|
1881
|
-
* // part = { partNumber: 1, etag: '"abc123..."' }
|
|
1882
|
-
* ```
|
|
1883
|
-
*/
|
|
1884
|
-
async uploadPart(presignedUrl, data, partNumber) {
|
|
1885
|
-
if (!Number.isInteger(partNumber) || partNumber < 1) {
|
|
1886
|
-
throw new Error(`partNumber must be a positive integer, received ${partNumber}`);
|
|
1887
|
-
}
|
|
1888
|
-
const response = await this.httpClient.fetchRaw(presignedUrl, {
|
|
1889
|
-
method: "PUT",
|
|
1890
|
-
headers: {
|
|
1891
|
-
// Deployment artifacts are always ZIP archives.
|
|
1892
|
-
"Content-Type": "application/zip",
|
|
1893
|
-
"Content-Length": String(data instanceof Blob ? data.size : data.byteLength)
|
|
1894
|
-
},
|
|
1895
|
-
body: data
|
|
1896
|
-
});
|
|
1897
|
-
const etag = response.headers.get("ETag");
|
|
1898
|
-
if (!etag) {
|
|
1899
|
-
throw new Error(`No ETag received for part ${partNumber}`);
|
|
1926
|
+
// ../../node_modules/.pnpm/lodash._root@3.0.1/node_modules/lodash._root/index.js
|
|
1927
|
+
var require_lodash6 = __commonJS({
|
|
1928
|
+
"../../node_modules/.pnpm/lodash._root@3.0.1/node_modules/lodash._root/index.js"(exports, module) {
|
|
1929
|
+
"use strict";
|
|
1930
|
+
var objectTypes = {
|
|
1931
|
+
"function": true,
|
|
1932
|
+
"object": true
|
|
1933
|
+
};
|
|
1934
|
+
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType ? exports : void 0;
|
|
1935
|
+
var freeModule = objectTypes[typeof module] && module && !module.nodeType ? module : void 0;
|
|
1936
|
+
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == "object" && global);
|
|
1937
|
+
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
|
1938
|
+
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
|
1939
|
+
var thisGlobal = checkGlobal(objectTypes[typeof exports] && exports);
|
|
1940
|
+
var root = freeGlobal || freeWindow !== (thisGlobal && thisGlobal.window) && freeWindow || freeSelf || thisGlobal || Function("return this")();
|
|
1941
|
+
function checkGlobal(value) {
|
|
1942
|
+
return value && value.Object === Object ? value : null;
|
|
1943
|
+
}
|
|
1944
|
+
module.exports = root;
|
|
1900
1945
|
}
|
|
1901
|
-
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* Complete a multipart upload after all parts have been uploaded via
|
|
1905
|
-
* {@link uploadPart}. This signals the storage provider to assemble the
|
|
1906
|
-
* parts into a single object and triggers the deployment build pipeline.
|
|
1907
|
-
*
|
|
1908
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1909
|
-
* @param uploadId - The multipart upload ID from {@link startUpload}.
|
|
1910
|
-
* @param parts - Array of `{ partNumber, etag }` from each {@link uploadPart} call.
|
|
1911
|
-
*
|
|
1912
|
-
* @example
|
|
1913
|
-
* ```ts
|
|
1914
|
-
* await client.deployments.completeUpload(deploymentId, uploadId, [
|
|
1915
|
-
* { partNumber: 1, etag: '"abc..."' },
|
|
1916
|
-
* { partNumber: 2, etag: '"def..."' },
|
|
1917
|
-
* ]);
|
|
1918
|
-
* ```
|
|
1919
|
-
*/
|
|
1920
|
-
async completeUpload(deploymentId, uploadId, parts) {
|
|
1921
|
-
return this.httpClient.post(`/deployments/${deploymentId}/upload/complete`, { uploadId, parts });
|
|
1922
|
-
}
|
|
1923
|
-
/**
|
|
1924
|
-
* Fetch deployment logs. Supports pagination and filtering by timestamp
|
|
1925
|
-
* for incremental log tailing.
|
|
1926
|
-
*
|
|
1927
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1928
|
-
* @param query - Optional pagination and filter parameters.
|
|
1929
|
-
* @returns A page of log entries with total count.
|
|
1930
|
-
*
|
|
1931
|
-
* @example
|
|
1932
|
-
* ```ts
|
|
1933
|
-
* // Get the first page of logs
|
|
1934
|
-
* const page = await client.deployments.getLogs('deployment-id', {
|
|
1935
|
-
* offset: 0,
|
|
1936
|
-
* limit: 100,
|
|
1937
|
-
* });
|
|
1938
|
-
*
|
|
1939
|
-
* for (const entry of page.items) {
|
|
1940
|
-
* const prefix = entry.type === 'ERROR' ? 'ERR' : entry.type === 'WARN' ? 'WRN' : 'INF';
|
|
1941
|
-
* console.log(`[${prefix}] ${entry.message}`);
|
|
1942
|
-
* }
|
|
1943
|
-
*
|
|
1944
|
-
* // Tail new logs since last fetch
|
|
1945
|
-
* const newLogs = await client.deployments.getLogs('deployment-id', {
|
|
1946
|
-
* 'createdAt[gt]': lastEntry.createdAt,
|
|
1947
|
-
* });
|
|
1948
|
-
* ```
|
|
1949
|
-
*/
|
|
1950
|
-
async getLogs(deploymentId, query) {
|
|
1951
|
-
return this.httpClient.get(`/deployments/${deploymentId}/logs`, {
|
|
1952
|
-
query
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* List the immutable `*.gigadrive.app` hostnames assigned to a deployment.
|
|
1957
|
-
*
|
|
1958
|
-
* @param deploymentId - The deployment ID (UUID).
|
|
1959
|
-
* @returns A paginated list of hostnames.
|
|
1960
|
-
*
|
|
1961
|
-
* @example
|
|
1962
|
-
* ```ts
|
|
1963
|
-
* const { items } = await client.deployments.getHostnames('deployment-id');
|
|
1964
|
-
* console.log(items.map((h) => h.hostname));
|
|
1965
|
-
* ```
|
|
1966
|
-
*/
|
|
1967
|
-
async getHostnames(deploymentId) {
|
|
1968
|
-
return this.httpClient.get(`/deployments/${deploymentId}/hostnames`);
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
|
-
|
|
1972
|
-
// src/resources/image-optimization.ts
|
|
1973
|
-
var createManagedImageUrl = (options) => {
|
|
1974
|
-
const inferredFilename = options.source.split("/").filter(Boolean).at(-1)?.split("?")[0] || "image.image";
|
|
1975
|
-
const filename = (options.filename ?? inferredFilename).replace(/[^A-Za-z0-9._-]/g, "_") || "image.image";
|
|
1976
|
-
const url = new URL(
|
|
1977
|
-
`/_gigadrive/image/${encodeURIComponent(options.source)}/${encodeURIComponent(filename)}`,
|
|
1978
|
-
options.origin
|
|
1979
|
-
);
|
|
1980
|
-
for (const [name, value] of Object.entries({
|
|
1981
|
-
width: options.width,
|
|
1982
|
-
height: options.height,
|
|
1983
|
-
quality: options.quality,
|
|
1984
|
-
format: options.format,
|
|
1985
|
-
fit: options.fit,
|
|
1986
|
-
variant: options.variant
|
|
1987
|
-
})) {
|
|
1988
|
-
if (value !== void 0) url.searchParams.set(name, String(value));
|
|
1989
|
-
}
|
|
1990
|
-
return url.toString();
|
|
1991
|
-
};
|
|
1992
|
-
var ImageOptimizationResource = class extends BaseResource {
|
|
1993
|
-
/** Create a managed image URL without making an API request. */
|
|
1994
|
-
url(options) {
|
|
1995
|
-
return createManagedImageUrl(options);
|
|
1996
|
-
}
|
|
1997
|
-
/** Inspect the immutable deployment policy and Bunny cache tags used for a source. */
|
|
1998
|
-
inspect(deploymentId, source) {
|
|
1999
|
-
return this.httpClient.get(`/deployments/${deploymentId}/image-cache`, {
|
|
2000
|
-
query: { source }
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
/** Purge all variants for one source, or every optimized image in the deployment when omitted. */
|
|
2004
|
-
purge(deploymentId, source) {
|
|
2005
|
-
return this.httpClient.delete(`/deployments/${deploymentId}/image-cache`, {
|
|
2006
|
-
query: { source }
|
|
2007
|
-
});
|
|
2008
|
-
}
|
|
2009
|
-
};
|
|
2010
|
-
|
|
2011
|
-
// src/resources/organization-ai-gateway.ts
|
|
2012
|
-
var AiGatewayUsageResource = class extends BaseResource {
|
|
2013
|
-
/** Get an aggregated usage summary with breakdowns by model, provider, and user. */
|
|
2014
|
-
async summary(organizationId, query) {
|
|
2015
|
-
return this.httpClient.get(`/organizations/${organizationId}/ai-gateway/usage/summary`, {
|
|
2016
|
-
query
|
|
2017
|
-
});
|
|
2018
|
-
}
|
|
2019
|
-
/** List request-level usage events. */
|
|
2020
|
-
async requests(organizationId, query) {
|
|
2021
|
-
return this.httpClient.get(`/organizations/${organizationId}/ai-gateway/usage/requests`, {
|
|
2022
|
-
query
|
|
2023
|
-
});
|
|
2024
|
-
}
|
|
2025
|
-
/** Export request-level usage events as CSV text. */
|
|
2026
|
-
async export(organizationId, query) {
|
|
2027
|
-
const response = await this.httpClient.requestStream(
|
|
2028
|
-
"GET",
|
|
2029
|
-
`/organizations/${organizationId}/ai-gateway/usage/export`,
|
|
2030
|
-
{ query }
|
|
2031
|
-
);
|
|
2032
|
-
return response.text();
|
|
2033
|
-
}
|
|
2034
|
-
};
|
|
2035
|
-
var AiGatewayBudgetsResource = class extends BaseResource {
|
|
2036
|
-
/** List all budgets for an organization. */
|
|
2037
|
-
async list(organizationId) {
|
|
2038
|
-
return this.httpClient.get(`/organizations/${organizationId}/ai-gateway/budgets`);
|
|
2039
|
-
}
|
|
2040
|
-
/**
|
|
2041
|
-
* Replace the organization's entire budget set. Pass an empty array to clear
|
|
2042
|
-
* all budgets.
|
|
2043
|
-
*/
|
|
2044
|
-
async replace(organizationId, budgets) {
|
|
2045
|
-
return this.httpClient.put(`/organizations/${organizationId}/ai-gateway/budgets`, { budgets });
|
|
2046
|
-
}
|
|
2047
|
-
};
|
|
2048
|
-
var AiGatewayPoliciesResource = class extends BaseResource {
|
|
2049
|
-
/**
|
|
2050
|
-
* Get the governance policy for an organization, or for a specific
|
|
2051
|
-
* application when `applicationId` is provided. Returns `null` if no policy is set.
|
|
2052
|
-
*/
|
|
2053
|
-
async get(organizationId, options) {
|
|
2054
|
-
const { policy } = await this.httpClient.get(
|
|
2055
|
-
`/organizations/${organizationId}/ai-gateway/policies`,
|
|
2056
|
-
{ query: { applicationId: options?.applicationId } }
|
|
2057
|
-
);
|
|
2058
|
-
return policy;
|
|
2059
|
-
}
|
|
2060
|
-
/** Create or update an AI Gateway policy. */
|
|
2061
|
-
async put(organizationId, data) {
|
|
2062
|
-
const { policy } = await this.httpClient.put(
|
|
2063
|
-
`/organizations/${organizationId}/ai-gateway/policies`,
|
|
2064
|
-
data
|
|
2065
|
-
);
|
|
2066
|
-
return policy;
|
|
2067
|
-
}
|
|
2068
|
-
};
|
|
2069
|
-
var OrganizationAiGatewayResource = class {
|
|
2070
|
-
/** Usage analytics (summary, request log, CSV export). */
|
|
2071
|
-
usage;
|
|
2072
|
-
/** Spend/usage budgets. */
|
|
2073
|
-
budgets;
|
|
2074
|
-
/** Model/provider governance policies. */
|
|
2075
|
-
policies;
|
|
2076
|
-
constructor(httpClient) {
|
|
2077
|
-
this.usage = new AiGatewayUsageResource(httpClient);
|
|
2078
|
-
this.budgets = new AiGatewayBudgetsResource(httpClient);
|
|
2079
|
-
this.policies = new AiGatewayPoliciesResource(httpClient);
|
|
2080
|
-
}
|
|
2081
|
-
};
|
|
2082
|
-
|
|
2083
|
-
// src/resources/organization-env-vars.ts
|
|
2084
|
-
var OrganizationEnvVarsResource = class extends BaseResource {
|
|
2085
|
-
/**
|
|
2086
|
-
* List all environment variables for an organization.
|
|
2087
|
-
*
|
|
2088
|
-
* @param organizationId - The organization ID (UUID).
|
|
2089
|
-
* @returns A paginated list of environment variables.
|
|
2090
|
-
*
|
|
2091
|
-
* @example
|
|
2092
|
-
* ```ts
|
|
2093
|
-
* const { items } = await client.organizations.envVars.list('org-id');
|
|
2094
|
-
* for (const v of items) {
|
|
2095
|
-
* console.log(`${v.key}=${v.sensitive ? '***' : v.value}`);
|
|
2096
|
-
* }
|
|
2097
|
-
* ```
|
|
2098
|
-
*/
|
|
2099
|
-
async list(organizationId, query) {
|
|
2100
|
-
return this.httpClient.get(`/organizations/${organizationId}/env-vars`, {
|
|
2101
|
-
query
|
|
2102
|
-
});
|
|
2103
|
-
}
|
|
2104
|
-
/**
|
|
2105
|
-
* Create a new environment variable for an organization.
|
|
2106
|
-
*
|
|
2107
|
-
* @param organizationId - The organization ID (UUID).
|
|
2108
|
-
* @param data - The variable key, value, and optional settings.
|
|
2109
|
-
* @returns The newly created environment variable.
|
|
2110
|
-
*
|
|
2111
|
-
* @example
|
|
2112
|
-
* ```ts
|
|
2113
|
-
* const envVar = await client.organizations.envVars.create('org-id', {
|
|
2114
|
-
* key: 'STRIPE_SECRET',
|
|
2115
|
-
* value: 'sk_live_...',
|
|
2116
|
-
* sensitive: true,
|
|
2117
|
-
* });
|
|
2118
|
-
* ```
|
|
2119
|
-
*/
|
|
2120
|
-
async create(organizationId, data) {
|
|
2121
|
-
return this.httpClient.post(`/organizations/${organizationId}/env-vars`, data);
|
|
2122
|
-
}
|
|
2123
|
-
/**
|
|
2124
|
-
* Update an existing environment variable. Only the fields you provide
|
|
2125
|
-
* will be changed; omitted fields are left unchanged.
|
|
2126
|
-
*
|
|
2127
|
-
* @param organizationId - The organization ID (UUID).
|
|
2128
|
-
* @param envVarId - The environment variable ID (UUID).
|
|
2129
|
-
* @param data - The fields to update.
|
|
2130
|
-
* @returns The updated environment variable.
|
|
2131
|
-
*
|
|
2132
|
-
* @example
|
|
2133
|
-
* ```ts
|
|
2134
|
-
* await client.organizations.envVars.update('org-id', 'var-id', {
|
|
2135
|
-
* value: 'new-value',
|
|
2136
|
-
* });
|
|
2137
|
-
* ```
|
|
2138
|
-
*/
|
|
2139
|
-
async update(organizationId, envVarId, data) {
|
|
2140
|
-
return this.httpClient.patch(`/organizations/${organizationId}/env-vars/${envVarId}`, data);
|
|
2141
|
-
}
|
|
2142
|
-
/**
|
|
2143
|
-
* Permanently delete an environment variable.
|
|
2144
|
-
*
|
|
2145
|
-
* @param organizationId - The organization ID (UUID).
|
|
2146
|
-
* @param envVarId - The environment variable ID (UUID).
|
|
2147
|
-
*
|
|
2148
|
-
* @example
|
|
2149
|
-
* ```ts
|
|
2150
|
-
* await client.organizations.envVars.delete('org-id', 'var-id');
|
|
2151
|
-
* ```
|
|
2152
|
-
*/
|
|
2153
|
-
async delete(organizationId, envVarId) {
|
|
2154
|
-
return this.httpClient.delete(`/organizations/${organizationId}/env-vars/${envVarId}`);
|
|
2155
|
-
}
|
|
2156
|
-
};
|
|
2157
|
-
|
|
2158
|
-
// src/resources/organization-members.ts
|
|
2159
|
-
var OrganizationMembersResource = class extends BaseResource {
|
|
2160
|
-
/**
|
|
2161
|
-
* List the users who belong to an organization.
|
|
2162
|
-
*
|
|
2163
|
-
* @param organizationId - Organization whose members should be listed.
|
|
2164
|
-
* @param query - Optional pagination.
|
|
2165
|
-
* @returns A paginated list of organization members.
|
|
2166
|
-
*
|
|
2167
|
-
* @example
|
|
2168
|
-
* ```ts
|
|
2169
|
-
* const { items, total } = await client.organizations.members.list('org-id');
|
|
2170
|
-
* console.log(`Found ${total} members`);
|
|
2171
|
-
* ```
|
|
2172
|
-
*/
|
|
2173
|
-
async list(organizationId, query) {
|
|
2174
|
-
return this.httpClient.get(`/organizations/${organizationId}/members`, {
|
|
2175
|
-
query
|
|
2176
|
-
});
|
|
2177
|
-
}
|
|
2178
|
-
};
|
|
2179
|
-
|
|
2180
|
-
// src/resources/organization-products.ts
|
|
2181
|
-
var OrganizationProductsResource = class extends BaseResource {
|
|
2182
|
-
/**
|
|
2183
|
-
* List effective product access for every organization-scoped product.
|
|
2184
|
-
*
|
|
2185
|
-
* @param organizationId - Organization whose product access should be listed.
|
|
2186
|
-
* @param query - Optional pagination.
|
|
2187
|
-
* @returns A paginated list of product access summaries.
|
|
2188
|
-
*
|
|
2189
|
-
* @example
|
|
2190
|
-
* ```ts
|
|
2191
|
-
* const { items } = await client.organizations.products.list('org-id');
|
|
2192
|
-
* for (const item of items) {
|
|
2193
|
-
* console.log(item.product.slug, item.hasAccess);
|
|
2194
|
-
* }
|
|
2195
|
-
* ```
|
|
2196
|
-
*/
|
|
2197
|
-
async list(organizationId, query) {
|
|
2198
|
-
return this.httpClient.get(`/organizations/${organizationId}/products`, {
|
|
2199
|
-
query
|
|
2200
|
-
});
|
|
2201
|
-
}
|
|
2202
|
-
/**
|
|
2203
|
-
* Get effective access for one organization-scoped product.
|
|
2204
|
-
*
|
|
2205
|
-
* @param organizationId - Organization to inspect.
|
|
2206
|
-
* @param product - Product slug from the product registry.
|
|
2207
|
-
* @returns Product access summary including entitlement and subscription state.
|
|
2208
|
-
*
|
|
2209
|
-
* @example
|
|
2210
|
-
* ```ts
|
|
2211
|
-
* const access = await client.organizations.products.get('org-id', 'office');
|
|
2212
|
-
* console.log(access.hasAccess, access.subscription?.plan);
|
|
2213
|
-
* ```
|
|
2214
|
-
*/
|
|
2215
|
-
async get(organizationId, product) {
|
|
2216
|
-
return this.httpClient.get(`/organizations/${organizationId}/products/${product}`);
|
|
2217
|
-
}
|
|
2218
|
-
/**
|
|
2219
|
-
* Check whether an organization currently has access to a product.
|
|
2220
|
-
*
|
|
2221
|
-
* @param organizationId - Organization to check.
|
|
2222
|
-
* @param product - Product slug from the product registry.
|
|
2223
|
-
* @returns Compact entitlement check result.
|
|
2224
|
-
*
|
|
2225
|
-
* @example
|
|
2226
|
-
* ```ts
|
|
2227
|
-
* const { hasAccess } = await client.organizations.products.checkEntitlement('org-id', 'network');
|
|
2228
|
-
* ```
|
|
2229
|
-
*/
|
|
2230
|
-
async checkEntitlement(organizationId, product) {
|
|
2231
|
-
return this.httpClient.get(`/organizations/${organizationId}/products/${product}/entitlement`);
|
|
2232
|
-
}
|
|
2233
|
-
};
|
|
2234
|
-
|
|
2235
|
-
// src/resources/organizations.ts
|
|
2236
|
-
var OrganizationsResource = class extends BaseResource {
|
|
2237
|
-
/**
|
|
2238
|
-
* Manage environment variables scoped to an organization.
|
|
2239
|
-
*
|
|
2240
|
-
* @example
|
|
2241
|
-
* ```ts
|
|
2242
|
-
* // List all env vars for an organization
|
|
2243
|
-
* const { items } = await client.organizations.envVars.list('org-id');
|
|
2244
|
-
*
|
|
2245
|
-
* // Create a new env var
|
|
2246
|
-
* await client.organizations.envVars.create('org-id', {
|
|
2247
|
-
* key: 'ANALYTICS_KEY',
|
|
2248
|
-
* value: 'ak_live_...',
|
|
2249
|
-
* sensitive: true,
|
|
2250
|
-
* });
|
|
2251
|
-
* ```
|
|
2252
|
-
*/
|
|
2253
|
-
envVars;
|
|
2254
|
-
/**
|
|
2255
|
-
* AI Gateway governance for an organization: usage analytics, budgets, and
|
|
2256
|
-
* model/provider policies.
|
|
2257
|
-
*
|
|
2258
|
-
* @example
|
|
2259
|
-
* ```ts
|
|
2260
|
-
* const usage = await client.organizations.aiGateway.usage.summary('org-id', { from: '2026-06-01' });
|
|
2261
|
-
* console.log(usage.summary.totalTokens);
|
|
2262
|
-
* ```
|
|
2263
|
-
*/
|
|
2264
|
-
aiGateway;
|
|
2265
|
-
/**
|
|
2266
|
-
* List organization members and membership roles.
|
|
2267
|
-
*
|
|
2268
|
-
* @example
|
|
2269
|
-
* ```ts
|
|
2270
|
-
* const { items } = await client.organizations.members.list('org-id');
|
|
2271
|
-
* ```
|
|
2272
|
-
*/
|
|
2273
|
-
members;
|
|
2274
|
-
/**
|
|
2275
|
-
* Inspect organization product entitlements. Read-only through the public
|
|
2276
|
-
* API — plan changes happen in Gigadrive product surfaces, not via the SDK.
|
|
2277
|
-
*
|
|
2278
|
-
* @example
|
|
2279
|
-
* ```ts
|
|
2280
|
-
* const check = await client.organizations.products.checkEntitlement('org-id', 'office');
|
|
2281
|
-
* ```
|
|
2282
|
-
*/
|
|
2283
|
-
products;
|
|
2284
|
-
constructor(...args) {
|
|
2285
|
-
super(...args);
|
|
2286
|
-
this.envVars = new OrganizationEnvVarsResource(this.httpClient);
|
|
2287
|
-
this.aiGateway = new OrganizationAiGatewayResource(this.httpClient);
|
|
2288
|
-
this.members = new OrganizationMembersResource(this.httpClient);
|
|
2289
|
-
this.products = new OrganizationProductsResource(this.httpClient);
|
|
2290
|
-
}
|
|
2291
|
-
/**
|
|
2292
|
-
* List organizations the authenticated actor has access to.
|
|
2293
|
-
*
|
|
2294
|
-
* @param query - Optional pagination.
|
|
2295
|
-
* @returns A paginated list of organizations.
|
|
2296
|
-
*
|
|
2297
|
-
* @example
|
|
2298
|
-
* ```ts
|
|
2299
|
-
* const { items, total } = await client.organizations.list();
|
|
2300
|
-
* console.log(`Found ${total} organizations`);
|
|
2301
|
-
* ```
|
|
2302
|
-
*/
|
|
2303
|
-
async list(query) {
|
|
2304
|
-
return this.httpClient.get("/organizations", {
|
|
2305
|
-
query
|
|
2306
|
-
});
|
|
2307
|
-
}
|
|
2308
|
-
/**
|
|
2309
|
-
* Get a single organization by ID.
|
|
2310
|
-
*
|
|
2311
|
-
* @param organizationId - Organization to retrieve.
|
|
2312
|
-
* @returns The organization.
|
|
2313
|
-
*
|
|
2314
|
-
* @example
|
|
2315
|
-
* ```ts
|
|
2316
|
-
* const org = await client.organizations.get('org-id');
|
|
2317
|
-
* console.log(org.name, org.slug);
|
|
2318
|
-
* ```
|
|
2319
|
-
*/
|
|
2320
|
-
async get(organizationId) {
|
|
2321
|
-
return this.httpClient.get(`/organizations/${organizationId}`);
|
|
2322
|
-
}
|
|
2323
|
-
/**
|
|
2324
|
-
* Create a new organization.
|
|
2325
|
-
*
|
|
2326
|
-
* Requires a user-backed token with the `platform:organizations:write` scope.
|
|
2327
|
-
* The authenticated user becomes the organization owner.
|
|
2328
|
-
*
|
|
2329
|
-
* @param input - Organization creation input.
|
|
2330
|
-
* @returns The created organization.
|
|
2331
|
-
*
|
|
2332
|
-
* @example
|
|
2333
|
-
* ```ts
|
|
2334
|
-
* const org = await client.organizations.create({ name: 'Acme Corp' });
|
|
2335
|
-
* console.log(org.id, org.slug);
|
|
2336
|
-
* ```
|
|
2337
|
-
*/
|
|
2338
|
-
async create(input) {
|
|
2339
|
-
return this.httpClient.post("/organizations", input);
|
|
2340
|
-
}
|
|
2341
|
-
};
|
|
2342
|
-
|
|
2343
|
-
// src/resources/sticky-sessions.ts
|
|
2344
|
-
var StickySessionsResource = class extends BaseResource {
|
|
2345
|
-
/**
|
|
2346
|
-
* Mints a signed URL for an opaque application key.
|
|
2347
|
-
*
|
|
2348
|
-
* Deployed Gigadrive workloads can call this with a zero-config
|
|
2349
|
-
* `GigadriveClient`; the platform injects `GIGADRIVE_CLIENT_ID` and
|
|
2350
|
-
* `GIGADRIVE_CLIENT_SECRET` using the SDK's existing credential chain.
|
|
2351
|
-
*/
|
|
2352
|
-
async createUrl(input) {
|
|
2353
|
-
return this.httpClient.post("/sticky-sessions/urls", {
|
|
2354
|
-
...input,
|
|
2355
|
-
method: input.method ?? "GET"
|
|
2356
|
-
});
|
|
2357
|
-
}
|
|
2358
|
-
};
|
|
2359
|
-
|
|
2360
|
-
// src/client.ts
|
|
2361
|
-
var DEFAULT_BASE_URL2 = "https://api.gigadrive.network";
|
|
2362
|
-
var GigadriveClient = class {
|
|
2363
|
-
/** Organization management (list, environment variables). */
|
|
2364
|
-
organizations;
|
|
2365
|
-
/** Application management (list, environment variables, storage). */
|
|
2366
|
-
applications;
|
|
2367
|
-
/** Deployment lifecycle (create, upload, status, logs). */
|
|
2368
|
-
deployments;
|
|
2369
|
-
/** AI Gateway — OpenAI-compatible chat completions and model listing. */
|
|
2370
|
-
aiGateway;
|
|
2371
|
-
/** Application-scoped API key management (create, list, revoke). */
|
|
2372
|
-
apiKeys;
|
|
2373
|
-
/** Signed URLs that keep related requests on one MicroVM instance. */
|
|
2374
|
-
stickySessions;
|
|
2375
|
-
/** Managed image optimization inspection and cache purge operations. */
|
|
2376
|
-
imageOptimization;
|
|
2377
|
-
constructor(config = {}) {
|
|
2378
|
-
const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL2;
|
|
2379
|
-
const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
2380
|
-
const credentialProvider = resolveCredentialProvider({ ...config, baseUrl, fetch: fetchFn });
|
|
2381
|
-
const tokenManager = new TokenManager(credentialProvider);
|
|
2382
|
-
const httpClient = new HttpClient(baseUrl, tokenManager, fetchFn);
|
|
2383
|
-
this.organizations = new OrganizationsResource(httpClient);
|
|
2384
|
-
this.applications = new ApplicationsResource(httpClient);
|
|
2385
|
-
this.deployments = new DeploymentsResource(httpClient);
|
|
2386
|
-
this.aiGateway = new AiGatewayResource(httpClient);
|
|
2387
|
-
this.apiKeys = new ApiKeysResource(httpClient);
|
|
2388
|
-
this.stickySessions = new StickySessionsResource(httpClient);
|
|
2389
|
-
this.imageOptimization = new ImageOptimizationResource(httpClient);
|
|
2390
|
-
}
|
|
2391
|
-
};
|
|
1946
|
+
});
|
|
2392
1947
|
|
|
2393
|
-
//
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
1948
|
+
// ../../node_modules/.pnpm/lodash._baseuniq@4.6.0/node_modules/lodash._baseuniq/index.js
|
|
1949
|
+
var require_lodash7 = __commonJS({
|
|
1950
|
+
"../../node_modules/.pnpm/lodash._baseuniq@4.6.0/node_modules/lodash._baseuniq/index.js"(exports, module) {
|
|
1951
|
+
"use strict";
|
|
1952
|
+
var createSet = require_lodash5();
|
|
1953
|
+
var root = require_lodash6();
|
|
1954
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1955
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
1956
|
+
var funcTag = "[object Function]";
|
|
1957
|
+
var genTag = "[object GeneratorFunction]";
|
|
1958
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1959
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1960
|
+
function arrayIncludes(array, value) {
|
|
1961
|
+
return !!array.length && baseIndexOf(array, value, 0) > -1;
|
|
1962
|
+
}
|
|
1963
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
1964
|
+
var index = -1, length = array.length;
|
|
1965
|
+
while (++index < length) {
|
|
1966
|
+
if (comparator(value, array[index])) {
|
|
1967
|
+
return true;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
function baseIndexOf(array, value, fromIndex) {
|
|
1973
|
+
if (value !== value) {
|
|
1974
|
+
return indexOfNaN(array, fromIndex);
|
|
1975
|
+
}
|
|
1976
|
+
var index = fromIndex - 1, length = array.length;
|
|
1977
|
+
while (++index < length) {
|
|
1978
|
+
if (array[index] === value) {
|
|
1979
|
+
return index;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
return -1;
|
|
1983
|
+
}
|
|
1984
|
+
function cacheHas(cache, key) {
|
|
1985
|
+
return cache.has(key);
|
|
1986
|
+
}
|
|
1987
|
+
function indexOfNaN(array, fromIndex, fromRight) {
|
|
1988
|
+
var length = array.length, index = fromIndex + (fromRight ? 0 : -1);
|
|
1989
|
+
while (fromRight ? index-- : ++index < length) {
|
|
1990
|
+
var other = array[index];
|
|
1991
|
+
if (other !== other) {
|
|
1992
|
+
return index;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return -1;
|
|
1996
|
+
}
|
|
1997
|
+
function isHostObject(value) {
|
|
1998
|
+
var result = false;
|
|
1999
|
+
if (value != null && typeof value.toString != "function") {
|
|
2000
|
+
try {
|
|
2001
|
+
result = !!(value + "");
|
|
2002
|
+
} catch (e) {
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
return result;
|
|
2006
|
+
}
|
|
2007
|
+
function setToArray(set) {
|
|
2008
|
+
var index = -1, result = Array(set.size);
|
|
2009
|
+
set.forEach(function(value) {
|
|
2010
|
+
result[++index] = value;
|
|
2011
|
+
});
|
|
2012
|
+
return result;
|
|
2013
|
+
}
|
|
2014
|
+
var arrayProto = Array.prototype;
|
|
2015
|
+
var objectProto = Object.prototype;
|
|
2016
|
+
var funcToString = Function.prototype.toString;
|
|
2017
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2018
|
+
var objectToString = objectProto.toString;
|
|
2019
|
+
var reIsNative = RegExp(
|
|
2020
|
+
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
2021
|
+
);
|
|
2022
|
+
var splice = arrayProto.splice;
|
|
2023
|
+
var Map2 = getNative(root, "Map");
|
|
2024
|
+
var nativeCreate = getNative(Object, "create");
|
|
2025
|
+
function Hash(entries) {
|
|
2026
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
2027
|
+
this.clear();
|
|
2028
|
+
while (++index < length) {
|
|
2029
|
+
var entry = entries[index];
|
|
2030
|
+
this.set(entry[0], entry[1]);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
function hashClear() {
|
|
2034
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
2035
|
+
}
|
|
2036
|
+
function hashDelete(key) {
|
|
2037
|
+
return this.has(key) && delete this.__data__[key];
|
|
2038
|
+
}
|
|
2039
|
+
function hashGet(key) {
|
|
2040
|
+
var data = this.__data__;
|
|
2041
|
+
if (nativeCreate) {
|
|
2042
|
+
var result = data[key];
|
|
2043
|
+
return result === HASH_UNDEFINED ? void 0 : result;
|
|
2044
|
+
}
|
|
2045
|
+
return hasOwnProperty.call(data, key) ? data[key] : void 0;
|
|
2046
|
+
}
|
|
2047
|
+
function hashHas(key) {
|
|
2048
|
+
var data = this.__data__;
|
|
2049
|
+
return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
2050
|
+
}
|
|
2051
|
+
function hashSet(key, value) {
|
|
2052
|
+
var data = this.__data__;
|
|
2053
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
2054
|
+
return this;
|
|
2055
|
+
}
|
|
2056
|
+
Hash.prototype.clear = hashClear;
|
|
2057
|
+
Hash.prototype["delete"] = hashDelete;
|
|
2058
|
+
Hash.prototype.get = hashGet;
|
|
2059
|
+
Hash.prototype.has = hashHas;
|
|
2060
|
+
Hash.prototype.set = hashSet;
|
|
2061
|
+
function ListCache(entries) {
|
|
2062
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
2063
|
+
this.clear();
|
|
2064
|
+
while (++index < length) {
|
|
2065
|
+
var entry = entries[index];
|
|
2066
|
+
this.set(entry[0], entry[1]);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function listCacheClear() {
|
|
2070
|
+
this.__data__ = [];
|
|
2071
|
+
}
|
|
2072
|
+
function listCacheDelete(key) {
|
|
2073
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2074
|
+
if (index < 0) {
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
var lastIndex = data.length - 1;
|
|
2078
|
+
if (index == lastIndex) {
|
|
2079
|
+
data.pop();
|
|
2080
|
+
} else {
|
|
2081
|
+
splice.call(data, index, 1);
|
|
2082
|
+
}
|
|
2083
|
+
return true;
|
|
2084
|
+
}
|
|
2085
|
+
function listCacheGet(key) {
|
|
2086
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2087
|
+
return index < 0 ? void 0 : data[index][1];
|
|
2088
|
+
}
|
|
2089
|
+
function listCacheHas(key) {
|
|
2090
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
2091
|
+
}
|
|
2092
|
+
function listCacheSet(key, value) {
|
|
2093
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2094
|
+
if (index < 0) {
|
|
2095
|
+
data.push([key, value]);
|
|
2096
|
+
} else {
|
|
2097
|
+
data[index][1] = value;
|
|
2098
|
+
}
|
|
2099
|
+
return this;
|
|
2100
|
+
}
|
|
2101
|
+
ListCache.prototype.clear = listCacheClear;
|
|
2102
|
+
ListCache.prototype["delete"] = listCacheDelete;
|
|
2103
|
+
ListCache.prototype.get = listCacheGet;
|
|
2104
|
+
ListCache.prototype.has = listCacheHas;
|
|
2105
|
+
ListCache.prototype.set = listCacheSet;
|
|
2106
|
+
function MapCache(entries) {
|
|
2107
|
+
var index = -1, length = entries ? entries.length : 0;
|
|
2108
|
+
this.clear();
|
|
2109
|
+
while (++index < length) {
|
|
2110
|
+
var entry = entries[index];
|
|
2111
|
+
this.set(entry[0], entry[1]);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
function mapCacheClear() {
|
|
2115
|
+
this.__data__ = {
|
|
2116
|
+
"hash": new Hash(),
|
|
2117
|
+
"map": new (Map2 || ListCache)(),
|
|
2118
|
+
"string": new Hash()
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
function mapCacheDelete(key) {
|
|
2122
|
+
return getMapData(this, key)["delete"](key);
|
|
2123
|
+
}
|
|
2124
|
+
function mapCacheGet(key) {
|
|
2125
|
+
return getMapData(this, key).get(key);
|
|
2126
|
+
}
|
|
2127
|
+
function mapCacheHas(key) {
|
|
2128
|
+
return getMapData(this, key).has(key);
|
|
2129
|
+
}
|
|
2130
|
+
function mapCacheSet(key, value) {
|
|
2131
|
+
getMapData(this, key).set(key, value);
|
|
2132
|
+
return this;
|
|
2133
|
+
}
|
|
2134
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
2135
|
+
MapCache.prototype["delete"] = mapCacheDelete;
|
|
2136
|
+
MapCache.prototype.get = mapCacheGet;
|
|
2137
|
+
MapCache.prototype.has = mapCacheHas;
|
|
2138
|
+
MapCache.prototype.set = mapCacheSet;
|
|
2139
|
+
function SetCache(values) {
|
|
2140
|
+
var index = -1, length = values ? values.length : 0;
|
|
2141
|
+
this.__data__ = new MapCache();
|
|
2142
|
+
while (++index < length) {
|
|
2143
|
+
this.add(values[index]);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function setCacheAdd(value) {
|
|
2147
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
2148
|
+
return this;
|
|
2149
|
+
}
|
|
2150
|
+
function setCacheHas(value) {
|
|
2151
|
+
return this.__data__.has(value);
|
|
2152
|
+
}
|
|
2153
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
2154
|
+
SetCache.prototype.has = setCacheHas;
|
|
2155
|
+
function assocIndexOf(array, key) {
|
|
2156
|
+
var length = array.length;
|
|
2157
|
+
while (length--) {
|
|
2158
|
+
if (eq(array[length][0], key)) {
|
|
2159
|
+
return length;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
return -1;
|
|
2163
|
+
}
|
|
2164
|
+
function baseUniq(array, iteratee, comparator) {
|
|
2165
|
+
var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
|
|
2166
|
+
if (comparator) {
|
|
2167
|
+
isCommon = false;
|
|
2168
|
+
includes = arrayIncludesWith;
|
|
2169
|
+
} else if (length >= LARGE_ARRAY_SIZE) {
|
|
2170
|
+
var set = iteratee ? null : createSet(array);
|
|
2171
|
+
if (set) {
|
|
2172
|
+
return setToArray(set);
|
|
2173
|
+
}
|
|
2174
|
+
isCommon = false;
|
|
2175
|
+
includes = cacheHas;
|
|
2176
|
+
seen = new SetCache();
|
|
2177
|
+
} else {
|
|
2178
|
+
seen = iteratee ? [] : result;
|
|
2179
|
+
}
|
|
2180
|
+
outer:
|
|
2181
|
+
while (++index < length) {
|
|
2182
|
+
var value = array[index], computed = iteratee ? iteratee(value) : value;
|
|
2183
|
+
value = comparator || value !== 0 ? value : 0;
|
|
2184
|
+
if (isCommon && computed === computed) {
|
|
2185
|
+
var seenIndex = seen.length;
|
|
2186
|
+
while (seenIndex--) {
|
|
2187
|
+
if (seen[seenIndex] === computed) {
|
|
2188
|
+
continue outer;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
if (iteratee) {
|
|
2192
|
+
seen.push(computed);
|
|
2193
|
+
}
|
|
2194
|
+
result.push(value);
|
|
2195
|
+
} else if (!includes(seen, computed, comparator)) {
|
|
2196
|
+
if (seen !== result) {
|
|
2197
|
+
seen.push(computed);
|
|
2198
|
+
}
|
|
2199
|
+
result.push(value);
|
|
2439
2200
|
}
|
|
2440
2201
|
}
|
|
2441
2202
|
return result;
|