run402 1.63.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/lib/allowance.mjs +20 -25
- package/lib/auth.mjs +7 -16
- package/lib/billing.mjs +12 -10
- package/lib/blob.mjs +30 -54
- package/lib/contracts.mjs +11 -19
- package/lib/deploy-v2.mjs +4 -1
- package/lib/functions.mjs +65 -17
- package/lib/init.mjs +12 -19
- package/lib/projects.mjs +157 -48
- package/lib/status.mjs +8 -15
- package/package.json +1 -1
- package/sdk/dist/kernel.d.ts +6 -0
- package/sdk/dist/kernel.d.ts.map +1 -1
- package/sdk/dist/kernel.js +5 -1
- package/sdk/dist/kernel.js.map +1 -1
- package/sdk/dist/namespaces/billing.d.ts +10 -5
- package/sdk/dist/namespaces/billing.d.ts.map +1 -1
- package/sdk/dist/namespaces/billing.js +23 -9
- package/sdk/dist/namespaces/billing.js.map +1 -1
- package/sdk/dist/namespaces/blobs.d.ts +16 -1
- package/sdk/dist/namespaces/blobs.d.ts.map +1 -1
- package/sdk/dist/namespaces/blobs.js +61 -25
- package/sdk/dist/namespaces/blobs.js.map +1 -1
- package/sdk/dist/namespaces/blobs.types.d.ts +41 -0
- package/sdk/dist/namespaces/blobs.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.d.ts +2 -1
- package/sdk/dist/namespaces/functions.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.js +19 -7
- package/sdk/dist/namespaces/functions.js.map +1 -1
- package/sdk/dist/namespaces/functions.types.d.ts +12 -2
- package/sdk/dist/namespaces/functions.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/projects.d.ts +14 -3
- package/sdk/dist/namespaces/projects.d.ts.map +1 -1
- package/sdk/dist/namespaces/projects.js +95 -5
- package/sdk/dist/namespaces/projects.js.map +1 -1
- package/sdk/dist/namespaces/projects.types.d.ts +39 -0
- package/sdk/dist/namespaces/projects.types.d.ts.map +1 -1
- package/sdk/dist/scoped.d.ts +10 -3
- package/sdk/dist/scoped.d.ts.map +1 -1
- package/sdk/dist/scoped.js +20 -2
- package/sdk/dist/scoped.js.map +1 -1
package/lib/projects.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
|
-
import {
|
|
2
|
+
import { loadKeyStore, API, allowanceAuthHeaders, resolveProjectId, getActiveProjectId } from "./config.mjs";
|
|
3
3
|
import { getSdk } from "./sdk.mjs";
|
|
4
4
|
import { reportSdkError, fail, parseFlagJson } from "./sdk-errors.mjs";
|
|
5
5
|
import { assertKnownFlags, failBadProjectId, flagValue, hasHelp, normalizeArgv, positionalArgs, resolvePositionalProject, validateRegularFile } from "./argparse.mjs";
|
|
@@ -23,6 +23,8 @@ Subcommands:
|
|
|
23
23
|
schema [id] Inspect the database schema
|
|
24
24
|
apply-expose [id] <manifest_json> Apply a declarative authorization manifest
|
|
25
25
|
apply-expose [id] --file <path> Apply a manifest from a JSON file
|
|
26
|
+
validate-expose [id] <manifest_json> Validate an authorization manifest without applying it
|
|
27
|
+
validate-expose [id] --file <path> Validate a manifest file without mutating the project
|
|
26
28
|
get-expose [id] Get the current authorization manifest
|
|
27
29
|
delete [id] --confirm Immediately and irreversibly delete a project (cascade purge) and remove from local state. Requires --confirm.
|
|
28
30
|
pin [id] Pin a project (admin only; uses admin allowance wallet)
|
|
@@ -43,6 +45,7 @@ Examples:
|
|
|
43
45
|
run402 projects usage prj_abc123
|
|
44
46
|
run402 projects costs prj_abc123 --window 30d
|
|
45
47
|
run402 projects schema prj_abc123
|
|
48
|
+
run402 projects validate-expose prj_abc123 --file manifest.json
|
|
46
49
|
run402 projects apply-expose prj_abc123 --file manifest.json
|
|
47
50
|
run402 projects get-expose prj_abc123
|
|
48
51
|
run402 projects keys prj_abc123
|
|
@@ -68,6 +71,9 @@ Notes:
|
|
|
68
71
|
row), public_read_write_UNRESTRICTED (fully open; requires
|
|
69
72
|
"i_understand_this_is_unrestricted": true on the entry), custom (provide
|
|
70
73
|
custom_sql with CREATE POLICY statements).
|
|
74
|
+
- 'validate-expose' checks the same auth/expose manifest shape without
|
|
75
|
+
applying it. Optional migration SQL is used only for reference checks; it is
|
|
76
|
+
not executed as a PostgreSQL dry run.
|
|
71
77
|
`;
|
|
72
78
|
|
|
73
79
|
const SUB_HELP = {
|
|
@@ -135,6 +141,35 @@ Examples:
|
|
|
135
141
|
run402 projects costs prj_abc123
|
|
136
142
|
RUN402_ADMIN_COOKIE='run402_admin=...' run402 projects costs prj_abc123
|
|
137
143
|
RUN402_ADMIN_COOKIE='run402_admin=...' run402 projects costs --window 7d
|
|
144
|
+
`,
|
|
145
|
+
"validate-expose": `run402 projects validate-expose — Validate an authorization manifest without applying it
|
|
146
|
+
|
|
147
|
+
Usage:
|
|
148
|
+
run402 projects validate-expose [id] <manifest_json> [options]
|
|
149
|
+
run402 projects validate-expose [id] --file <path> [options]
|
|
150
|
+
cat manifest.json | run402 projects validate-expose [id] [options]
|
|
151
|
+
|
|
152
|
+
Arguments:
|
|
153
|
+
[id] Optional project ID. When omitted, the active project is
|
|
154
|
+
used if one is set; otherwise validation is projectless.
|
|
155
|
+
<manifest_json> Inline auth/expose manifest JSON.
|
|
156
|
+
|
|
157
|
+
Options:
|
|
158
|
+
--file <path> Read the auth/expose manifest from a JSON file
|
|
159
|
+
--migration-file <path> Read migration SQL for reference checks only
|
|
160
|
+
--migration-sql <sql> Inline migration SQL for reference checks only
|
|
161
|
+
|
|
162
|
+
Notes:
|
|
163
|
+
- This validates the auth/expose manifest used by manifest.json,
|
|
164
|
+
database.expose, and apply-expose. It does not validate deploy manifests.
|
|
165
|
+
- Migration SQL is parsed as context for references; it is not executed.
|
|
166
|
+
- Validation findings are returned in JSON with hasErrors and do not make the
|
|
167
|
+
command fail. Usage, file, auth, and network errors still exit non-zero.
|
|
168
|
+
|
|
169
|
+
Examples:
|
|
170
|
+
run402 projects validate-expose --file manifest.json
|
|
171
|
+
run402 projects validate-expose prj_abc123 --file manifest.json --migration-file setup.sql
|
|
172
|
+
run402 projects validate-expose '{"version":"1","tables":[]}'
|
|
138
173
|
`,
|
|
139
174
|
};
|
|
140
175
|
|
|
@@ -212,7 +247,6 @@ async function applyExpose(projectId, args = []) {
|
|
|
212
247
|
else if (!inline && !args[i].startsWith("--")) { inline = args[i]; }
|
|
213
248
|
}
|
|
214
249
|
if (file) validateRegularFile(file, "--file");
|
|
215
|
-
const p = findProject(projectId);
|
|
216
250
|
const raw = file ? readFileSync(file, "utf-8") : inline;
|
|
217
251
|
if (!raw) {
|
|
218
252
|
fail({
|
|
@@ -230,24 +264,101 @@ async function applyExpose(projectId, args = []) {
|
|
|
230
264
|
details: { parse_error: err.message },
|
|
231
265
|
});
|
|
232
266
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
267
|
+
try {
|
|
268
|
+
const data = await getSdk().projects.applyExpose(projectId, manifest);
|
|
269
|
+
console.log(JSON.stringify(data, null, 2));
|
|
270
|
+
} catch (err) {
|
|
271
|
+
reportSdkError(err);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function validateExpose(args = []) {
|
|
276
|
+
let projectId = null;
|
|
277
|
+
let file = null;
|
|
278
|
+
let inline = null;
|
|
279
|
+
let migrationFile = null;
|
|
280
|
+
let migrationSql = null;
|
|
281
|
+
for (let i = 0; i < args.length; i++) {
|
|
282
|
+
const arg = args[i];
|
|
283
|
+
if (arg === "--file") {
|
|
284
|
+
if (args[i + 1] === undefined) {
|
|
285
|
+
fail({ code: "BAD_FLAG", message: "--file requires a value", details: { flag: "--file" } });
|
|
286
|
+
}
|
|
287
|
+
file = args[++i];
|
|
288
|
+
}
|
|
289
|
+
else if (arg === "--migration-file") {
|
|
290
|
+
if (args[i + 1] === undefined) {
|
|
291
|
+
fail({ code: "BAD_FLAG", message: "--migration-file requires a value", details: { flag: "--migration-file" } });
|
|
292
|
+
}
|
|
293
|
+
migrationFile = args[++i];
|
|
294
|
+
}
|
|
295
|
+
else if (arg === "--migration-sql") {
|
|
296
|
+
if (args[i + 1] === undefined) {
|
|
297
|
+
fail({ code: "BAD_FLAG", message: "--migration-sql requires a value", details: { flag: "--migration-sql" } });
|
|
298
|
+
}
|
|
299
|
+
migrationSql = args[++i];
|
|
300
|
+
}
|
|
301
|
+
else if (!projectId && typeof arg === "string" && arg.startsWith("prj_")) { projectId = arg; }
|
|
302
|
+
else if (!inline && typeof arg === "string" && !arg.startsWith("--")) { inline = arg; }
|
|
303
|
+
else if (typeof arg === "string" && !arg.startsWith("--")) {
|
|
304
|
+
fail({
|
|
305
|
+
code: "BAD_USAGE",
|
|
306
|
+
message: `Unexpected extra argument: ${arg}`,
|
|
307
|
+
hint: "run402 projects validate-expose [id] <manifest_json>",
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (file && inline) {
|
|
312
|
+
fail({
|
|
313
|
+
code: "BAD_USAGE",
|
|
314
|
+
message: "Provide either inline manifest JSON or --file <path>, not both.",
|
|
315
|
+
hint: "run402 projects validate-expose [id] --file manifest.json",
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (migrationFile && migrationSql !== null) {
|
|
319
|
+
fail({
|
|
320
|
+
code: "BAD_USAGE",
|
|
321
|
+
message: "Provide either --migration-file or --migration-sql, not both.",
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (file) validateRegularFile(file, "--file");
|
|
325
|
+
if (migrationFile) validateRegularFile(migrationFile, "--migration-file");
|
|
326
|
+
|
|
327
|
+
let raw = file ? readFileSync(file, "utf-8") : inline;
|
|
328
|
+
if (!raw && process.stdin && process.stdin.isTTY === false) {
|
|
329
|
+
raw = readFileSync(0, "utf-8");
|
|
330
|
+
}
|
|
331
|
+
if (!raw) {
|
|
332
|
+
fail({
|
|
333
|
+
code: "BAD_USAGE",
|
|
334
|
+
message: "Missing manifest.",
|
|
335
|
+
hint: "Provide inline JSON, pipe JSON to stdin, or use --file <path>",
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const activeProjectId = getActiveProjectId();
|
|
340
|
+
const project = projectId || activeProjectId || undefined;
|
|
341
|
+
if (!project) allowanceAuthHeaders("/projects/v1/expose/validate");
|
|
342
|
+
const migration = migrationFile ? readFileSync(migrationFile, "utf-8") : migrationSql;
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
const data = await getSdk().projects.validateExpose(raw, {
|
|
346
|
+
...(project ? { project } : {}),
|
|
347
|
+
...(migration !== null && migration !== undefined ? { migrationSql: migration } : {}),
|
|
348
|
+
});
|
|
349
|
+
console.log(JSON.stringify({ status: "ok", ...data }, null, 2));
|
|
350
|
+
} catch (err) {
|
|
351
|
+
reportSdkError(err);
|
|
352
|
+
}
|
|
241
353
|
}
|
|
242
354
|
|
|
243
355
|
async function getExpose(projectId) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
console.log(JSON.stringify(data, null, 2));
|
|
356
|
+
try {
|
|
357
|
+
const data = await getSdk().projects.getExpose(projectId);
|
|
358
|
+
console.log(JSON.stringify(data, null, 2));
|
|
359
|
+
} catch (err) {
|
|
360
|
+
reportSdkError(err);
|
|
361
|
+
}
|
|
251
362
|
}
|
|
252
363
|
|
|
253
364
|
async function list() {
|
|
@@ -292,7 +403,6 @@ async function sqlCmd(projectId, args = []) {
|
|
|
292
403
|
else if (!query && !args[i].startsWith("--")) { query = args[i]; }
|
|
293
404
|
}
|
|
294
405
|
if (file) validateRegularFile(file, "--file");
|
|
295
|
-
const p = findProject(projectId);
|
|
296
406
|
const sql = file ? readFileSync(file, "utf-8") : query;
|
|
297
407
|
if (!sql) {
|
|
298
408
|
fail({
|
|
@@ -311,13 +421,12 @@ async function sqlCmd(projectId, args = []) {
|
|
|
311
421
|
});
|
|
312
422
|
}
|
|
313
423
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
console.log(JSON.stringify(data, null, 2));
|
|
424
|
+
try {
|
|
425
|
+
const data = await getSdk().projects.sql(projectId, sql, params);
|
|
426
|
+
console.log(JSON.stringify(data, null, 2));
|
|
427
|
+
} catch (err) {
|
|
428
|
+
reportSdkError(err);
|
|
429
|
+
}
|
|
321
430
|
}
|
|
322
431
|
|
|
323
432
|
async function rest(projectId, table, queryParams) {
|
|
@@ -328,11 +437,12 @@ async function rest(projectId, table, queryParams) {
|
|
|
328
437
|
hint: "Run 'run402 projects schema <id>' to list tables.",
|
|
329
438
|
});
|
|
330
439
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
440
|
+
try {
|
|
441
|
+
const data = await getSdk().projects.rest(projectId, table, queryParams);
|
|
442
|
+
console.log(JSON.stringify(data, null, 2));
|
|
443
|
+
} catch (err) {
|
|
444
|
+
reportSdkError(err);
|
|
445
|
+
}
|
|
336
446
|
}
|
|
337
447
|
|
|
338
448
|
async function usage(projectId) {
|
|
@@ -420,15 +530,12 @@ async function promoteUser(projectId, email) {
|
|
|
420
530
|
hint: "run402 projects promote-user <project_id> <email>",
|
|
421
531
|
});
|
|
422
532
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
const data = await res.json();
|
|
430
|
-
if (!res.ok) { console.error(JSON.stringify({ status: "error", http: res.status, ...data })); process.exit(1); }
|
|
431
|
-
console.log(JSON.stringify(data, null, 2));
|
|
533
|
+
try {
|
|
534
|
+
await getSdk().projects.promoteUser(projectId, email);
|
|
535
|
+
console.log(JSON.stringify({ status: "ok", email }));
|
|
536
|
+
} catch (err) {
|
|
537
|
+
reportSdkError(err);
|
|
538
|
+
}
|
|
432
539
|
}
|
|
433
540
|
|
|
434
541
|
async function demoteUser(projectId, email) {
|
|
@@ -439,15 +546,12 @@ async function demoteUser(projectId, email) {
|
|
|
439
546
|
hint: "run402 projects demote-user <project_id> <email>",
|
|
440
547
|
});
|
|
441
548
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
const data = await res.json();
|
|
449
|
-
if (!res.ok) { console.error(JSON.stringify({ status: "error", http: res.status, ...data })); process.exit(1); }
|
|
450
|
-
console.log(JSON.stringify(data, null, 2));
|
|
549
|
+
try {
|
|
550
|
+
await getSdk().projects.demoteUser(projectId, email);
|
|
551
|
+
console.log(JSON.stringify({ status: "ok", email }));
|
|
552
|
+
} catch (err) {
|
|
553
|
+
reportSdkError(err);
|
|
554
|
+
}
|
|
451
555
|
}
|
|
452
556
|
|
|
453
557
|
async function deleteProject(projectId, args = []) {
|
|
@@ -474,6 +578,10 @@ const FLAGS_BY_SUB = {
|
|
|
474
578
|
sql: { known: ["--file", "--params"], values: ["--file", "--params"] },
|
|
475
579
|
costs: { known: ["--window"], values: ["--window"] },
|
|
476
580
|
"apply-expose": { known: ["--file"], values: ["--file"] },
|
|
581
|
+
"validate-expose": {
|
|
582
|
+
known: ["--file", "--migration-file", "--migration-sql"],
|
|
583
|
+
values: ["--file", "--migration-file", "--migration-sql"],
|
|
584
|
+
},
|
|
477
585
|
delete: { known: ["--confirm"], values: [] },
|
|
478
586
|
};
|
|
479
587
|
|
|
@@ -506,6 +614,7 @@ export async function run(sub, args) {
|
|
|
506
614
|
case "costs": { const { projectId, rest } = resolvePositionalProject(args, { rejectBareFirst: true, valueFlags: FLAGS_BY_SUB.costs.values }); await costs(projectId, rest); break; }
|
|
507
615
|
case "schema": { const { projectId } = resolvePositionalProject(args, { rejectBareFirst: true }); await schema(projectId); break; }
|
|
508
616
|
case "apply-expose": { const { projectId, rest } = resolvePositionalProject(args, { maxBarePositionals: 1, valueFlags: FLAGS_BY_SUB["apply-expose"].values, rejectBareFirstWhenFlagPresent: ["--file"] }); await applyExpose(projectId, rest); break; }
|
|
617
|
+
case "validate-expose": await validateExpose(args); break;
|
|
509
618
|
case "get-expose": { const { projectId } = resolvePositionalProject(args, { rejectBareFirst: true }); await getExpose(projectId); break; }
|
|
510
619
|
case "delete": { const { projectId, rest } = resolvePositionalProject(args, { rejectBareFirst: true }); await deleteProject(projectId, rest); break; }
|
|
511
620
|
case "pin": { const { projectId } = resolvePositionalProject(args, { rejectBareFirst: true }); await pin(projectId); break; }
|
package/lib/status.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readAllowance, loadKeyStore, getActiveProjectId
|
|
2
|
-
import {
|
|
1
|
+
import { readAllowance, loadKeyStore, getActiveProjectId } from "./config.mjs";
|
|
2
|
+
import { getSdk } from "./sdk.mjs";
|
|
3
3
|
import { assertKnownFlags, hasHelp, normalizeArgv } from "./argparse.mjs";
|
|
4
4
|
|
|
5
5
|
const HELP = `run402 status — Show full account state in one shot
|
|
@@ -86,23 +86,16 @@ export async function run(args = []) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const wallet = allowance.address.toLowerCase();
|
|
89
|
-
const authHeaders = getAllowanceAuthHeaders("/tiers/v1/status");
|
|
90
89
|
const rail = allowance.rail || "x402";
|
|
91
90
|
|
|
92
91
|
// Parallel API calls: tier + billing balance + server-side projects + on-chain wallet balance
|
|
93
|
-
const [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
fetch(`${API}/billing/v1/accounts/${wallet}`).catch(() => null),
|
|
98
|
-
fetch(`${API}/wallets/v1/${wallet}/projects`).catch(() => null),
|
|
92
|
+
const [tier, billing, remote, walletBalance] = await Promise.all([
|
|
93
|
+
getSdk().tier.status().catch(() => null),
|
|
94
|
+
getSdk().billing.checkBalance(wallet).catch(() => null),
|
|
95
|
+
getSdk().projects.list(wallet).catch(() => null),
|
|
99
96
|
readWalletBalanceUsdMicros(rail, allowance.address),
|
|
100
97
|
]);
|
|
101
98
|
|
|
102
|
-
const tier = tierRes?.ok ? await tierRes.json() : null;
|
|
103
|
-
const billing = balanceRes?.ok ? await balanceRes.json() : null;
|
|
104
|
-
const remote = projectsRes?.ok ? await projectsRes.json() : null;
|
|
105
|
-
|
|
106
99
|
// Local keystore
|
|
107
100
|
const store = loadKeyStore();
|
|
108
101
|
const activeId = getActiveProjectId();
|
|
@@ -125,8 +118,8 @@ export async function run(args = []) {
|
|
|
125
118
|
// two unambiguous fields:
|
|
126
119
|
// - billing: credits held by Run402 (available + held), null if no account
|
|
127
120
|
// - wallet_balance_usd_micros: on-chain USDC/pathUSD, null if RPC fails
|
|
128
|
-
billing: billing && billing.exists
|
|
129
|
-
? { available_usd_micros: billing.available_usd_micros, held_usd_micros: billing.held_usd_micros }
|
|
121
|
+
billing: billing && billing.exists !== false
|
|
122
|
+
? { available_usd_micros: billing.available_usd_micros, held_usd_micros: billing.held_usd_micros ?? 0 }
|
|
130
123
|
: null,
|
|
131
124
|
wallet_balance_usd_micros: walletBalance,
|
|
132
125
|
projects,
|
package/package.json
CHANGED
package/sdk/dist/kernel.d.ts
CHANGED
|
@@ -27,11 +27,16 @@ export interface RequestOptions {
|
|
|
27
27
|
/** Short verb phrase attached to thrown errors (e.g. "provisioning project"). */
|
|
28
28
|
context: string;
|
|
29
29
|
}
|
|
30
|
+
export interface ResponseEnvelope<T = unknown> {
|
|
31
|
+
status: number;
|
|
32
|
+
body: T;
|
|
33
|
+
}
|
|
30
34
|
/** Internal client surface passed to each namespace. */
|
|
31
35
|
export interface Client {
|
|
32
36
|
/** API base URL, e.g. `https://api.run402.com`. Exposed for namespaces that need to compute derived URLs (e.g. REST endpoints). */
|
|
33
37
|
readonly apiBase: string;
|
|
34
38
|
request<T>(path: string, opts: RequestOptions): Promise<T>;
|
|
39
|
+
requestWithResponse<T>(path: string, opts: RequestOptions): Promise<ResponseEnvelope<T>>;
|
|
35
40
|
getProject(id: string): Promise<ProjectKeys | null>;
|
|
36
41
|
/** The underlying credentials provider. Namespaces use this to access optional methods (saveProject, setActiveProject, ...). */
|
|
37
42
|
readonly credentials: CredentialsProvider;
|
|
@@ -43,5 +48,6 @@ export interface Client {
|
|
|
43
48
|
readonly fetch: typeof globalThis.fetch;
|
|
44
49
|
}
|
|
45
50
|
export declare function request<T>(kernel: KernelConfig, path: string, opts: RequestOptions): Promise<T>;
|
|
51
|
+
export declare function requestWithResponse<T>(kernel: KernelConfig, path: string, opts: RequestOptions): Promise<ResponseEnvelope<T>>;
|
|
46
52
|
export declare function buildClient(kernel: KernelConfig): Client;
|
|
47
53
|
//# sourceMappingURL=kernel.d.ts.map
|
package/sdk/dist/kernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wDAAwD;AACxD,MAAM,WAAW,MAAM;IACrB,mIAAmI;IACnI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,CAAC,EAAE,IAAI,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;IACrB,mIAAmI;IACnI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpD,gIAAgI;IAChI,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACzC;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC7B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CA0E9B;AAWD,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAUxD"}
|
package/sdk/dist/kernel.js
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { ApiError, NetworkError, PaymentRequired, Unauthorized, } from "./errors.js";
|
|
14
14
|
export async function request(kernel, path, opts) {
|
|
15
|
+
return (await requestWithResponse(kernel, path, opts)).body;
|
|
16
|
+
}
|
|
17
|
+
export async function requestWithResponse(kernel, path, opts) {
|
|
15
18
|
const { apiBase, fetch, credentials } = kernel;
|
|
16
19
|
const { method = "GET", headers = {}, body, rawBody, withAuth = true, context } = opts;
|
|
17
20
|
const url = `${apiBase}${path}`;
|
|
@@ -55,7 +58,7 @@ export async function request(kernel, path, opts) {
|
|
|
55
58
|
resBody = await res.text();
|
|
56
59
|
}
|
|
57
60
|
if (res.ok)
|
|
58
|
-
return resBody;
|
|
61
|
+
return { status: res.status, body: resBody };
|
|
59
62
|
if (res.status === 402) {
|
|
60
63
|
throw new PaymentRequired(`${displayMessage(resBody, "Payment required")} while ${context}`, 402, resBody, context);
|
|
61
64
|
}
|
|
@@ -78,6 +81,7 @@ export function buildClient(kernel) {
|
|
|
78
81
|
return {
|
|
79
82
|
apiBase: kernel.apiBase,
|
|
80
83
|
request: (path, opts) => request(kernel, path, opts),
|
|
84
|
+
requestWithResponse: (path, opts) => requestWithResponse(kernel, path, opts),
|
|
81
85
|
getProject: (id) => kernel.credentials.getProject(id),
|
|
82
86
|
credentials: kernel.credentials,
|
|
83
87
|
fetch: kernel.fetch,
|
package/sdk/dist/kernel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AA2CrB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAoB,EACpB,IAAY,EACZ,IAAoB;IAEpB,OAAO,CAAC,MAAM,mBAAmB,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAoB,EACpB,IA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|
}
|
|
48
|
+
export type BillingAccountIdentifier = string;
|
|
48
49
|
export interface AutoRechargeOptions {
|
|
49
50
|
billingAccountId: string;
|
|
50
51
|
enabled: boolean;
|
|
@@ -52,14 +53,18 @@ export interface AutoRechargeOptions {
|
|
|
52
53
|
}
|
|
53
54
|
export declare class Billing {
|
|
54
55
|
private readonly client;
|
|
55
|
-
readonly balance: (
|
|
56
|
+
readonly balance: (identifier: BillingAccountIdentifier) => Promise<BillingBalance>;
|
|
56
57
|
readonly createEmail: (email: string) => Promise<EmailBillingAccount>;
|
|
57
58
|
readonly autoRecharge: (opts: AutoRechargeOptions) => Promise<void>;
|
|
58
59
|
constructor(client: Client);
|
|
59
|
-
/** Check a
|
|
60
|
-
checkBalance(
|
|
61
|
-
/**
|
|
62
|
-
|
|
60
|
+
/** Check a billing account by wallet or email identifier. Public, no auth. */
|
|
61
|
+
checkBalance(identifier: BillingAccountIdentifier): Promise<BillingBalance>;
|
|
62
|
+
/** Check a billing account by wallet or email identifier. Public, no auth. */
|
|
63
|
+
getAccount(identifier: BillingAccountIdentifier): Promise<BillingBalance>;
|
|
64
|
+
/** Fetch billing history by wallet or email identifier. */
|
|
65
|
+
history(identifier: BillingAccountIdentifier, limit?: number): Promise<BillingHistoryResult>;
|
|
66
|
+
/** Fetch billing history by wallet or email identifier. */
|
|
67
|
+
getHistory(identifier: BillingAccountIdentifier, limit?: number): Promise<BillingHistoryResult>;
|
|
63
68
|
/** Create a Stripe checkout URL to fund a wallet's billing balance. */
|
|
64
69
|
createCheckout(wallet: string, amountUsdMicros: number): Promise<CreateCheckoutResult>;
|
|
65
70
|
/** Create an email-only (no-wallet) billing account. Sends a verification email. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAA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,CAAC,oBAAoB,CAAC;IAWrG,uEAAuE;IACjE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAS5F,oFAAoF;IAC9E,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IASrE,yFAAyF;IACnF,UAAU,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzE,wEAAwE;IAClE,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmB9F,2CAA2C;IACrC,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBhF,+CAA+C;IACzC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAchE"}
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* account by wallet address or email.
|
|
5
5
|
*/
|
|
6
6
|
import { LocalError } from "../errors.js";
|
|
7
|
+
function encodeBillingIdentifier(identifier) {
|
|
8
|
+
const normalized = /^0x/i.test(identifier)
|
|
9
|
+
? identifier.toLowerCase()
|
|
10
|
+
: identifier;
|
|
11
|
+
return encodeURIComponent(normalized);
|
|
12
|
+
}
|
|
7
13
|
export class Billing {
|
|
8
14
|
client;
|
|
9
15
|
balance;
|
|
@@ -15,20 +21,28 @@ export class Billing {
|
|
|
15
21
|
this.createEmail = this.createEmailAccount.bind(this);
|
|
16
22
|
this.autoRecharge = this.setAutoRecharge.bind(this);
|
|
17
23
|
}
|
|
18
|
-
/** Check a
|
|
19
|
-
async checkBalance(
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
/** Check a billing account by wallet or email identifier. Public, no auth. */
|
|
25
|
+
async checkBalance(identifier) {
|
|
26
|
+
return this.getAccount(identifier);
|
|
27
|
+
}
|
|
28
|
+
/** Check a billing account by wallet or email identifier. Public, no auth. */
|
|
29
|
+
async getAccount(identifier) {
|
|
30
|
+
const encoded = encodeBillingIdentifier(identifier);
|
|
31
|
+
return this.client.request(`/billing/v1/accounts/${encoded}`, {
|
|
22
32
|
context: "checking balance",
|
|
23
33
|
withAuth: false,
|
|
24
34
|
});
|
|
25
35
|
}
|
|
26
|
-
/** Fetch billing history
|
|
27
|
-
async history(
|
|
28
|
-
|
|
36
|
+
/** Fetch billing history by wallet or email identifier. */
|
|
37
|
+
async history(identifier, limit) {
|
|
38
|
+
return this.getHistory(identifier, limit);
|
|
39
|
+
}
|
|
40
|
+
/** Fetch billing history by wallet or email identifier. */
|
|
41
|
+
async getHistory(identifier, limit) {
|
|
42
|
+
const encoded = encodeBillingIdentifier(identifier);
|
|
29
43
|
const path = limit
|
|
30
|
-
? `/billing/v1/accounts/${
|
|
31
|
-
: `/billing/v1/accounts/${
|
|
44
|
+
? `/billing/v1/accounts/${encoded}/history?limit=${encodeURIComponent(String(limit))}`
|
|
45
|
+
: `/billing/v1/accounts/${encoded}/history`;
|
|
32
46
|
return this.client.request(path, {
|
|
33
47
|
context: "fetching billing history",
|
|
34
48
|
withAuth: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/namespaces/billing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAyD1C,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QACxC,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE;QAC1B,CAAC,CAAC,UAAU,C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AAM,EAAE,MAAM;YACd,IAAI;YACJ,OAAO,EAAE,uBAAuB;YAChC,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* configured fetch still flows through any wrappers (e.g. test mocks).
|
|
8
8
|
*/
|
|
9
9
|
import type { Client } from "../kernel.js";
|
|
10
|
-
import type { BlobDiagnoseEnvelope, BlobLsOptions, BlobLsResult, BlobPutOptions, BlobPutResult, BlobPutSource, BlobSignOptions, BlobSignResult, BlobWaitFreshOptions, BlobWaitFreshResult } from "./blobs.types.js";
|
|
10
|
+
import type { BlobDiagnoseEnvelope, BlobLsOptions, BlobLsResult, BlobPutOptions, BlobPutResult, BlobPutSource, BlobSignOptions, BlobSignResult, BlobUploadCompleteOptions, BlobUploadCompleteResult, BlobUploadInitOptions, BlobUploadInitResult, BlobUploadStatusResult, BlobWaitFreshOptions, BlobWaitFreshResult } from "./blobs.types.js";
|
|
11
11
|
export declare class Blobs {
|
|
12
12
|
private readonly client;
|
|
13
13
|
constructor(client: Client);
|
|
@@ -22,6 +22,21 @@ export declare class Blobs {
|
|
|
22
22
|
* @throws {ProjectNotFound} if `projectId` is not in the provider.
|
|
23
23
|
*/
|
|
24
24
|
put(projectId: string, key: string, source: BlobPutSource, opts?: BlobPutOptions): Promise<BlobPutResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize a low-level upload session. This is the gateway half of
|
|
27
|
+
* `blobs.put`, exposed for CLI-style resumable streaming uploaders that need
|
|
28
|
+
* to manage local files, part concurrency, and cached session state.
|
|
29
|
+
*/
|
|
30
|
+
initUploadSession(projectId: string, opts: BlobUploadInitOptions): Promise<BlobUploadInitResult>;
|
|
31
|
+
/** Fetch a low-level upload session's current status for resumable uploads. */
|
|
32
|
+
getUploadSession(projectId: string, uploadId: string): Promise<BlobUploadStatusResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Complete a low-level upload session and return the same AssetRef shape as
|
|
35
|
+
* `blobs.put`. Single PUT sessions may omit `parts`.
|
|
36
|
+
*/
|
|
37
|
+
completeUploadSession(projectId: string, uploadId: string, opts?: BlobUploadCompleteOptions, extra?: {
|
|
38
|
+
contentType?: string;
|
|
39
|
+
}): Promise<BlobUploadCompleteResult>;
|
|
25
40
|
/**
|
|
26
41
|
* Diagnose a public blob URL. Returns a JSON envelope describing the live
|
|
27
42
|
* CDN state (expected vs observed SHA, cache headers, recent invalidation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../src/namespaces/blobs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAGV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../src/namespaces/blobs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAGV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAgO1B,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C;;;;;;;;;OASG;IACG,GAAG,CACP,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE,cA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