gipity 1.1.41 → 1.1.43
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/commands/brand.js +4 -4
- package/dist/commands/email.js +3 -3
- package/dist/commands/key.js +12 -13
- package/dist/commands/load.js +44 -2
- package/dist/commands/notify.js +19 -20
- package/dist/commands/save.js +19 -4
- package/dist/commands/secrets.js +5 -5
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/project.js +9 -0
- package/dist/index.js +163 -122
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9401,9 +9401,9 @@ async function publicRequest(method, path5, body, extraHeaders, timeoutMs = REQU
|
|
|
9401
9401
|
function publicPost(path5, body, extraHeaders) {
|
|
9402
9402
|
return publicRequest("POST", path5, body, extraHeaders);
|
|
9403
9403
|
}
|
|
9404
|
-
async function mintAppToken(
|
|
9404
|
+
async function mintAppToken(projectGuid) {
|
|
9405
9405
|
try {
|
|
9406
|
-
const minted = await publicPost("/api/token", { app:
|
|
9406
|
+
const minted = await publicPost("/api/token", { app: projectGuid });
|
|
9407
9407
|
return { "X-App-Token": minted.data.token };
|
|
9408
9408
|
} catch {
|
|
9409
9409
|
return void 0;
|
|
@@ -34850,7 +34850,7 @@ var UploadConflictError = class extends Error {
|
|
|
34850
34850
|
currentServerVersion;
|
|
34851
34851
|
path;
|
|
34852
34852
|
};
|
|
34853
|
-
async function uploadOneFile(
|
|
34853
|
+
async function uploadOneFile(projectGuid, localPath, virtualPath, opts = {}) {
|
|
34854
34854
|
const { sha256: sha2562, size } = await hashFile(localPath);
|
|
34855
34855
|
const mime = opts.mime ?? guessMime(virtualPath);
|
|
34856
34856
|
const initBody = { path: virtualPath, size, sha256: sha2562, mime };
|
|
@@ -34860,7 +34860,7 @@ async function uploadOneFile(projectGuid2, localPath, virtualPath, opts = {}) {
|
|
|
34860
34860
|
let init;
|
|
34861
34861
|
try {
|
|
34862
34862
|
init = await post(
|
|
34863
|
-
`/projects/${
|
|
34863
|
+
`/projects/${projectGuid}/files/upload-init`,
|
|
34864
34864
|
initBody
|
|
34865
34865
|
);
|
|
34866
34866
|
} catch (err) {
|
|
@@ -34882,7 +34882,7 @@ async function uploadOneFile(projectGuid2, localPath, virtualPath, opts = {}) {
|
|
|
34882
34882
|
}
|
|
34883
34883
|
let comp;
|
|
34884
34884
|
try {
|
|
34885
|
-
comp = await post(`/projects/${
|
|
34885
|
+
comp = await post(`/projects/${projectGuid}/files/upload-complete`, completeBody);
|
|
34886
34886
|
} catch (err) {
|
|
34887
34887
|
if (err instanceof ApiError && err.statusCode === 409) {
|
|
34888
34888
|
const current = typeof err.data?.current_server_version === "number" ? err.data.current_server_version : null;
|
|
@@ -34964,16 +34964,16 @@ async function transferToS3(localPath, size, mime, data, opts = {}) {
|
|
|
34964
34964
|
completed.sort((a, b7) => a.part_number - b7.part_number);
|
|
34965
34965
|
return { parts: completed };
|
|
34966
34966
|
}
|
|
34967
|
-
async function uploadInitBatch(
|
|
34967
|
+
async function uploadInitBatch(projectGuid, files) {
|
|
34968
34968
|
const res = await post(
|
|
34969
|
-
`/projects/${
|
|
34969
|
+
`/projects/${projectGuid}/files/upload-init-batch`,
|
|
34970
34970
|
{ files }
|
|
34971
34971
|
);
|
|
34972
34972
|
return res.data.results;
|
|
34973
34973
|
}
|
|
34974
|
-
async function uploadCompleteBatch(
|
|
34974
|
+
async function uploadCompleteBatch(projectGuid, items) {
|
|
34975
34975
|
const res = await post(
|
|
34976
|
-
`/projects/${
|
|
34976
|
+
`/projects/${projectGuid}/files/upload-complete-batch`,
|
|
34977
34977
|
{ items }
|
|
34978
34978
|
);
|
|
34979
34979
|
return res.data.results;
|
|
@@ -35074,23 +35074,23 @@ async function acquireLock(progress) {
|
|
|
35074
35074
|
}
|
|
35075
35075
|
}
|
|
35076
35076
|
}
|
|
35077
|
-
function readBaseline(
|
|
35077
|
+
function readBaseline(projectGuid) {
|
|
35078
35078
|
const path5 = syncStatePath();
|
|
35079
|
-
if (!existsSync8(path5)) return { projectGuid
|
|
35079
|
+
if (!existsSync8(path5)) return { projectGuid, files: {}, lastFullSync: null };
|
|
35080
35080
|
try {
|
|
35081
35081
|
const parsed = JSON.parse(readFileSync8(path5, "utf-8"));
|
|
35082
|
-
if (parsed.projectGuid !==
|
|
35083
|
-
return { projectGuid
|
|
35082
|
+
if (parsed.projectGuid !== projectGuid) {
|
|
35083
|
+
return { projectGuid, files: {}, lastFullSync: null };
|
|
35084
35084
|
}
|
|
35085
35085
|
return {
|
|
35086
|
-
projectGuid
|
|
35086
|
+
projectGuid,
|
|
35087
35087
|
files: parsed.files ?? {},
|
|
35088
35088
|
lastFullSync: parsed.lastFullSync ?? null,
|
|
35089
35089
|
...parsed.deletesSkippedStreak ? { deletesSkippedStreak: parsed.deletesSkippedStreak } : {},
|
|
35090
35090
|
...parsed.appUploads?.length ? { appUploads: parsed.appUploads } : {}
|
|
35091
35091
|
};
|
|
35092
35092
|
} catch {
|
|
35093
|
-
return { projectGuid
|
|
35093
|
+
return { projectGuid, files: {}, lastFullSync: null };
|
|
35094
35094
|
}
|
|
35095
35095
|
}
|
|
35096
35096
|
function writeBaseline(b7) {
|
|
@@ -35191,8 +35191,8 @@ function resolveInRoot(root, relPath) {
|
|
|
35191
35191
|
}
|
|
35192
35192
|
return full;
|
|
35193
35193
|
}
|
|
35194
|
-
async function fetchRemote(
|
|
35195
|
-
const res = await get(`/projects/${
|
|
35194
|
+
async function fetchRemote(projectGuid) {
|
|
35195
|
+
const res = await get(`/projects/${projectGuid}/files/tree`);
|
|
35196
35196
|
const out = /* @__PURE__ */ new Map();
|
|
35197
35197
|
const appUploads = new Set((res.appUploads ?? []).map(normalizeTreePath));
|
|
35198
35198
|
for (const f of res.data) {
|
|
@@ -35254,14 +35254,14 @@ function extractTarToMap(stream, idleMs, onBytes, keep) {
|
|
|
35254
35254
|
stream.pipe(extract3);
|
|
35255
35255
|
});
|
|
35256
35256
|
}
|
|
35257
|
-
async function downloadAll(
|
|
35258
|
-
const stream = await downloadStream(`/projects/${
|
|
35257
|
+
async function downloadAll(projectGuid, onBytes) {
|
|
35258
|
+
const stream = await downloadStream(`/projects/${projectGuid}/files/tree?content=tar`);
|
|
35259
35259
|
return extractTarToMap(stream, DOWNLOAD_IDLE_MS, onBytes);
|
|
35260
35260
|
}
|
|
35261
|
-
async function fetchOneOutcome(
|
|
35261
|
+
async function fetchOneOutcome(projectGuid, path5, expectedSha) {
|
|
35262
35262
|
try {
|
|
35263
35263
|
const stream = await downloadStream(
|
|
35264
|
-
`/projects/${
|
|
35264
|
+
`/projects/${projectGuid}/files/tree?content=tar&path=${encodeURIComponent(path5)}`
|
|
35265
35265
|
);
|
|
35266
35266
|
const want = normalizeTreePath(path5);
|
|
35267
35267
|
const files = await extractTarToMap(stream, DOWNLOAD_IDLE_MS, void 0, (p) => p === want);
|
|
@@ -35277,8 +35277,8 @@ async function fetchOneOutcome(projectGuid2, path5, expectedSha) {
|
|
|
35277
35277
|
return { kind: "transient" };
|
|
35278
35278
|
}
|
|
35279
35279
|
}
|
|
35280
|
-
async function fetchOne(
|
|
35281
|
-
const out = await fetchOneOutcome(
|
|
35280
|
+
async function fetchOne(projectGuid, path5, expectedSha) {
|
|
35281
|
+
const out = await fetchOneOutcome(projectGuid, path5, expectedSha);
|
|
35282
35282
|
return out.kind === "ok" ? out.buf : null;
|
|
35283
35283
|
}
|
|
35284
35284
|
function classifyLocal(info2, base) {
|
|
@@ -35547,14 +35547,14 @@ async function sync(opts = {}) {
|
|
|
35547
35547
|
releaseLock();
|
|
35548
35548
|
}
|
|
35549
35549
|
}
|
|
35550
|
-
async function syncInner(
|
|
35551
|
-
const config = { projectGuid
|
|
35550
|
+
async function syncInner(projectGuid, root, ignore2, opts, interactive) {
|
|
35551
|
+
const config = { projectGuid, ignore: ignore2 };
|
|
35552
35552
|
const p = opts.progress;
|
|
35553
|
-
const baseline = readBaseline(
|
|
35553
|
+
const baseline = readBaseline(projectGuid);
|
|
35554
35554
|
p?.phase("Scanning local files...");
|
|
35555
35555
|
const local = walkLocal(root, ignore2, baseline.files);
|
|
35556
35556
|
p?.phase("Checking Gipity for changes...");
|
|
35557
|
-
const { files: remote, appUploads } = await fetchRemote(
|
|
35557
|
+
const { files: remote, appUploads } = await fetchRemote(projectGuid);
|
|
35558
35558
|
const appUploadsLeftLocal = [];
|
|
35559
35559
|
const knownUploads = /* @__PURE__ */ new Set([...appUploads, ...(baseline.appUploads ?? []).filter((p7) => local.has(p7))]);
|
|
35560
35560
|
for (const path5 of knownUploads) {
|
|
@@ -36422,6 +36422,14 @@ function parseDuration(raw, unit) {
|
|
|
36422
36422
|
return { value, hadSuffix: true };
|
|
36423
36423
|
}
|
|
36424
36424
|
|
|
36425
|
+
// src/helpers/project.ts
|
|
36426
|
+
init_config();
|
|
36427
|
+
var PROJECT_OPTION = ["--project <guid-or-slug>", "Target a specific project instead of cwd / Home"];
|
|
36428
|
+
async function projectGuidFor(opts) {
|
|
36429
|
+
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
36430
|
+
return config.projectGuid;
|
|
36431
|
+
}
|
|
36432
|
+
|
|
36425
36433
|
// src/commands/token.ts
|
|
36426
36434
|
var tokenCommand = new Command("token").description("Manage API tokens").addHelpText("after", `
|
|
36427
36435
|
Long-lived agent API tokens (gip_at_*) for headless agents and CI - they drive
|
|
@@ -36475,7 +36483,6 @@ tokenCommand.command("revoke <short_guid>").alias("rm").description("Revoke an a
|
|
|
36475
36483
|
|
|
36476
36484
|
// src/commands/key.ts
|
|
36477
36485
|
init_api();
|
|
36478
|
-
init_config();
|
|
36479
36486
|
init_colors();
|
|
36480
36487
|
var keyCommand = new Command("key").description("Manage project API keys for scripts and agents (X-Api-Key)").addHelpText("after", `
|
|
36481
36488
|
Give a script, cron, or agent write access to your app without a login:
|
|
@@ -36524,6 +36531,7 @@ function scopesFromFlags(opts) {
|
|
|
36524
36531
|
}
|
|
36525
36532
|
}
|
|
36526
36533
|
if (opts.files !== void 0) scopes.files = opts.files;
|
|
36534
|
+
if (opts.approvals !== void 0) scopes.approvals = opts.approvals;
|
|
36527
36535
|
if (opts.ip !== void 0) {
|
|
36528
36536
|
const ips = splitList(opts.ip);
|
|
36529
36537
|
if (!ips.length) throw new Error("--ip needs at least one address or CIDR range");
|
|
@@ -36537,15 +36545,11 @@ function describeScopes(scopes) {
|
|
|
36537
36545
|
if (scopes.functions) parts.push(`fn: ${scopes.functions.join(",")}`);
|
|
36538
36546
|
if (scopes.tables) parts.push(`tables: ${Object.entries(scopes.tables).map(([t, a]) => `${t}:${a}`).join(",")}`);
|
|
36539
36547
|
if (scopes.files) parts.push(`files: ${scopes.files}`);
|
|
36548
|
+
if (scopes.approvals) parts.push(`approvals: ${scopes.approvals}`);
|
|
36540
36549
|
if (scopes.ip) parts.push(`ip: ${scopes.ip.join(",")}`);
|
|
36541
36550
|
return parts.join(" ");
|
|
36542
36551
|
}
|
|
36543
|
-
|
|
36544
|
-
async function projectGuid(opts) {
|
|
36545
|
-
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
36546
|
-
return config.projectGuid;
|
|
36547
|
-
}
|
|
36548
|
-
keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option("--functions <names>", "Scope: only these functions (comma-separated)").option("--tables <list>", "Scope: only these Records tables, e.g. commands:write,logs:read").addOption(new Option("--files <access>", "Scope: app files access").choices(["read", "write"])).option("--ip <list>", "Scope: only from these IPs / CIDR ranges (comma-separated)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
|
|
36552
|
+
keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option("--functions <names>", "Scope: only these functions (comma-separated)").option("--tables <list>", "Scope: only these Records tables, e.g. commands:write,logs:read").addOption(new Option("--files <access>", "Scope: app files access").choices(["read", "write"])).addOption(new Option("--approvals <access>", "Scope: read and consume passkey approvals").choices(["read"])).option("--ip <list>", "Scope: only from these IPs / CIDR ranges (comma-separated)").option(...PROJECT_OPTION).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
|
|
36549
36553
|
const body = { name, role: opts.role };
|
|
36550
36554
|
const scopes = scopesFromFlags(opts);
|
|
36551
36555
|
if (scopes) body.scopes = scopes;
|
|
@@ -36555,7 +36559,7 @@ keyCommand.command("create <name>").description("Mint a project API key (shown o
|
|
|
36555
36559
|
body.expires_in_days = days;
|
|
36556
36560
|
}
|
|
36557
36561
|
const res = await post(
|
|
36558
|
-
`/projects/${await
|
|
36562
|
+
`/projects/${await projectGuidFor(opts)}/api-keys`,
|
|
36559
36563
|
body
|
|
36560
36564
|
);
|
|
36561
36565
|
const k7 = res.data;
|
|
@@ -36575,8 +36579,8 @@ keyCommand.command("create <name>").description("Mint a project API key (shown o
|
|
|
36575
36579
|
console.log("");
|
|
36576
36580
|
console.log(warning("Copy it now - it will not be shown again."));
|
|
36577
36581
|
}));
|
|
36578
|
-
keyCommand.command("list").alias("ls").description("List this project's API keys (values are never shown again)").option(...
|
|
36579
|
-
const res = await get(`/projects/${await
|
|
36582
|
+
keyCommand.command("list").alias("ls").description("List this project's API keys (values are never shown again)").option(...PROJECT_OPTION).option("--json", "Output as JSON").action((opts) => run("List", async () => {
|
|
36583
|
+
const res = await get(`/projects/${await projectGuidFor(opts)}/api-keys`);
|
|
36580
36584
|
printList(
|
|
36581
36585
|
res.data,
|
|
36582
36586
|
opts,
|
|
@@ -36584,8 +36588,8 @@ keyCommand.command("list").alias("ls").description("List this project's API keys
|
|
|
36584
36588
|
(k7) => `${bold(k7.short_guid)} ${k7.name} ${muted(`${k7.role} ${describeScopes(k7.scopes)} ${k7.prefix}... last used ${fmtDate2(k7.last_used_at)} expires ${fmtDate2(k7.expires_at)}`)}`
|
|
36585
36589
|
);
|
|
36586
36590
|
}));
|
|
36587
|
-
keyCommand.command("revoke <short_guid>").alias("rm").description("Revoke a project API key (instant, irreversible)").option(...
|
|
36588
|
-
await del(`/projects/${await
|
|
36591
|
+
keyCommand.command("revoke <short_guid>").alias("rm").description("Revoke a project API key (instant, irreversible)").option(...PROJECT_OPTION).option("--json", "Output as JSON").action((shortGuid, opts) => run("Revoke", async () => {
|
|
36592
|
+
await del(`/projects/${await projectGuidFor(opts)}/api-keys/${encodeURIComponent(shortGuid)}`);
|
|
36589
36593
|
if (opts.json) {
|
|
36590
36594
|
console.log(JSON.stringify({ short_guid: shortGuid, revoked: true }));
|
|
36591
36595
|
return;
|
|
@@ -37776,26 +37780,26 @@ init_config();
|
|
|
37776
37780
|
|
|
37777
37781
|
// src/db-checkpoint.ts
|
|
37778
37782
|
init_api();
|
|
37779
|
-
async function resolveDatabase(
|
|
37783
|
+
async function resolveDatabase(projectGuid, explicit) {
|
|
37780
37784
|
if (explicit) return explicit;
|
|
37781
|
-
const res = await get(`/projects/${
|
|
37785
|
+
const res = await get(`/projects/${projectGuid}/databases`);
|
|
37782
37786
|
return res.data.length > 0 ? res.data[0].friendlyName : null;
|
|
37783
37787
|
}
|
|
37784
|
-
async function checkpoint(
|
|
37788
|
+
async function checkpoint(projectGuid, database, action, keep) {
|
|
37785
37789
|
const res = await post(
|
|
37786
|
-
`/projects/${
|
|
37790
|
+
`/projects/${projectGuid}/db/checkpoint`,
|
|
37787
37791
|
{ database, action, ...keep ? { keep } : {} }
|
|
37788
37792
|
);
|
|
37789
37793
|
return res.data;
|
|
37790
37794
|
}
|
|
37791
|
-
function createCheckpoint(
|
|
37792
|
-
return checkpoint(
|
|
37795
|
+
function createCheckpoint(projectGuid, database) {
|
|
37796
|
+
return checkpoint(projectGuid, database, "create");
|
|
37793
37797
|
}
|
|
37794
|
-
function restoreCheckpoint(
|
|
37795
|
-
return checkpoint(
|
|
37798
|
+
function restoreCheckpoint(projectGuid, database, opts = {}) {
|
|
37799
|
+
return checkpoint(projectGuid, database, "restore", opts.keep);
|
|
37796
37800
|
}
|
|
37797
|
-
function dropCheckpoint(
|
|
37798
|
-
return checkpoint(
|
|
37801
|
+
function dropCheckpoint(projectGuid, database) {
|
|
37802
|
+
return checkpoint(projectGuid, database, "drop");
|
|
37799
37803
|
}
|
|
37800
37804
|
|
|
37801
37805
|
// src/page-fixtures.ts
|
|
@@ -37840,13 +37844,13 @@ Nothing named "${basename4(localPath)}" under ${root} either. Generate a frame w
|
|
|
37840
37844
|
`${flag} ${localPath}: no such file. Looked for ${abs} (relative paths resolve against the current directory, ${process.cwd()}).${found}`
|
|
37841
37845
|
);
|
|
37842
37846
|
}
|
|
37843
|
-
async function uploadPublicFixture(
|
|
37847
|
+
async function uploadPublicFixture(projectGuid, localPath, flag = "--fixture") {
|
|
37844
37848
|
assertLocalAsset(flag, localPath);
|
|
37845
37849
|
const name = basename4(localPath);
|
|
37846
37850
|
const size = statSync5(localPath).size;
|
|
37847
37851
|
const contentType = guessMime(localPath);
|
|
37848
37852
|
const init = await post(
|
|
37849
|
-
`/api/${
|
|
37853
|
+
`/api/${projectGuid}/uploads/init`,
|
|
37850
37854
|
{ filename: name, content_type: contentType, size, public: true }
|
|
37851
37855
|
);
|
|
37852
37856
|
if (init.data.method !== "PUT" || !init.data.url) {
|
|
@@ -37861,13 +37865,13 @@ async function uploadPublicFixture(projectGuid2, localPath, flag = "--fixture")
|
|
|
37861
37865
|
throw new Error(`upload of fixture "${name}" failed: ${res.status} ${res.statusText}`);
|
|
37862
37866
|
}
|
|
37863
37867
|
const done = await post(
|
|
37864
|
-
`/api/${
|
|
37868
|
+
`/api/${projectGuid}/uploads/complete`,
|
|
37865
37869
|
{ upload_guid: init.data.upload_guid }
|
|
37866
37870
|
);
|
|
37867
37871
|
return { guid: done.data.guid, url: done.data.url, name, localPath };
|
|
37868
37872
|
}
|
|
37869
|
-
async function deleteFixture(
|
|
37870
|
-
await del(`/api/${
|
|
37873
|
+
async function deleteFixture(projectGuid, guid) {
|
|
37874
|
+
await del(`/api/${projectGuid}/uploads/${guid}`);
|
|
37871
37875
|
}
|
|
37872
37876
|
var CAMERA_EXTS = [".png", ".jpg", ".jpeg", ".webp", ".mp4", ".webm", ".y4m", ".mjpeg"];
|
|
37873
37877
|
function assertCameraFile(localPath) {
|
|
@@ -37880,9 +37884,9 @@ A still image is played as a looping single-frame feed, which is what a gesture/
|
|
|
37880
37884
|
No frame to hand? Generate one: gipity generate image "a hand making a closed fist, palm to camera, plain background"`
|
|
37881
37885
|
);
|
|
37882
37886
|
}
|
|
37883
|
-
async function uploadCameraFeed(
|
|
37887
|
+
async function uploadCameraFeed(projectGuid, localPath) {
|
|
37884
37888
|
assertCameraFile(localPath);
|
|
37885
|
-
return uploadPublicFixture(
|
|
37889
|
+
return uploadPublicFixture(projectGuid, localPath, "--camera");
|
|
37886
37890
|
}
|
|
37887
37891
|
|
|
37888
37892
|
// src/commands/page-eval.ts
|
|
@@ -38190,7 +38194,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38190
38194
|
const fixturePaths = opts.fixture ?? [];
|
|
38191
38195
|
const hosted = [];
|
|
38192
38196
|
let camera;
|
|
38193
|
-
let
|
|
38197
|
+
let projectGuid;
|
|
38194
38198
|
let sentExpr = expr;
|
|
38195
38199
|
let sentSteps = steps;
|
|
38196
38200
|
if (opts.camera) assertCameraFile(opts.camera);
|
|
@@ -38198,7 +38202,7 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38198
38202
|
try {
|
|
38199
38203
|
if (opts.restoreDb) {
|
|
38200
38204
|
const { config } = await resolveProjectContext({});
|
|
38201
|
-
|
|
38205
|
+
projectGuid = config.projectGuid;
|
|
38202
38206
|
const database = await resolveDatabase(config.projectGuid);
|
|
38203
38207
|
if (!database) {
|
|
38204
38208
|
console.error(muted("--restore-db: this project has no database - nothing to roll back."));
|
|
@@ -38210,17 +38214,17 @@ var pageEvalCommand = new Command("eval").description("Evaluate JS in a real bro
|
|
|
38210
38214
|
}
|
|
38211
38215
|
if (fixturePaths.length || opts.camera) {
|
|
38212
38216
|
const { config } = await resolveProjectContext({});
|
|
38213
|
-
|
|
38217
|
+
projectGuid = config.projectGuid;
|
|
38214
38218
|
}
|
|
38215
38219
|
const hostStart = Date.now();
|
|
38216
38220
|
if (opts.camera) {
|
|
38217
38221
|
console.log(muted(`Hosting camera feed ${opts.camera}...`));
|
|
38218
|
-
camera = await uploadCameraFeed(
|
|
38222
|
+
camera = await uploadCameraFeed(projectGuid, opts.camera);
|
|
38219
38223
|
}
|
|
38220
38224
|
if (fixturePaths.length) {
|
|
38221
38225
|
for (const p of fixturePaths) {
|
|
38222
38226
|
console.log(muted(`Hosting fixture ${p}...`));
|
|
38223
|
-
hosted.push(await uploadPublicFixture(
|
|
38227
|
+
hosted.push(await uploadPublicFixture(projectGuid, p));
|
|
38224
38228
|
}
|
|
38225
38229
|
const map = {};
|
|
38226
38230
|
for (const h of hosted) map[h.name] = h.url;
|
|
@@ -38357,7 +38361,7 @@ ${bold("After reload")} ${muted("(page reloaded in place: storage preserved)")}`
|
|
|
38357
38361
|
}
|
|
38358
38362
|
for (const h of [...hosted, ...camera ? [camera] : []]) {
|
|
38359
38363
|
try {
|
|
38360
|
-
await deleteFixture(
|
|
38364
|
+
await deleteFixture(projectGuid, h.guid);
|
|
38361
38365
|
} catch (err) {
|
|
38362
38366
|
console.error(warning(`\u26A0 Could not auto-delete fixture "${h.name}" (${h.guid}): still hosted at ${h.url}: ${err.message}`));
|
|
38363
38367
|
}
|
|
@@ -38684,14 +38688,14 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
|
|
|
38684
38688
|
const ts2 = timestampSlug();
|
|
38685
38689
|
const shotName = (vp2) => defaultFilename(slug, ts2, vp2 && userSpecifiedViewports ? dimSuffix(vp2) : void 0);
|
|
38686
38690
|
const names = userSpecifiedViewports ? customViewports.map(shotName) : [shotName()];
|
|
38687
|
-
const
|
|
38691
|
+
const projectGuid = getConfig()?.projectGuid;
|
|
38688
38692
|
const outputArg = opts.output ?? OUTPUT_ALIAS_FLAGS.map((f) => opts[f.slice(2)]).find(Boolean);
|
|
38689
38693
|
let camera;
|
|
38690
38694
|
if (opts.camera) {
|
|
38691
38695
|
assertCameraFile(opts.camera);
|
|
38692
|
-
if (!
|
|
38696
|
+
if (!projectGuid) throw new Error("--camera needs a linked project (the frame is hosted for the browser to fetch): run `gipity link` first.");
|
|
38693
38697
|
console.log(muted(`Hosting camera feed ${opts.camera}...`));
|
|
38694
|
-
camera = await uploadCameraFeed(
|
|
38698
|
+
camera = await uploadCameraFeed(projectGuid, opts.camera);
|
|
38695
38699
|
}
|
|
38696
38700
|
const preCapture = [
|
|
38697
38701
|
opts.waitFor ? buildWaitForGate(opts.waitFor, waitForTimeoutMs) : "",
|
|
@@ -38721,7 +38725,7 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
|
|
|
38721
38725
|
} finally {
|
|
38722
38726
|
if (camera) {
|
|
38723
38727
|
try {
|
|
38724
|
-
await deleteFixture(
|
|
38728
|
+
await deleteFixture(projectGuid, camera.guid);
|
|
38725
38729
|
} catch (err) {
|
|
38726
38730
|
console.error(warning(`\u26A0 Could not auto-delete camera feed "${camera.name}" (${camera.guid}): still hosted at ${camera.url}: ${err.message}`));
|
|
38727
38731
|
}
|
|
@@ -39192,9 +39196,9 @@ function pageAccessLabel(mode) {
|
|
|
39192
39196
|
}
|
|
39193
39197
|
|
|
39194
39198
|
// src/commands/status.ts
|
|
39195
|
-
async function probePageAccess(
|
|
39199
|
+
async function probePageAccess(projectGuid) {
|
|
39196
39200
|
const timeout = new Promise((res) => setTimeout(() => res(null), 5e3).unref?.());
|
|
39197
|
-
const call = get(`/projects/${
|
|
39201
|
+
const call = get(`/projects/${projectGuid}`).then(
|
|
39198
39202
|
(res) => res.data?.page_access ?? null,
|
|
39199
39203
|
() => null
|
|
39200
39204
|
);
|
|
@@ -39666,10 +39670,10 @@ dbCommand.command("list").description("List databases").option("--all", "List da
|
|
|
39666
39670
|
grouped.get(key).push(db2);
|
|
39667
39671
|
}
|
|
39668
39672
|
let first = true;
|
|
39669
|
-
for (const [
|
|
39673
|
+
for (const [projectGuid, dbs] of grouped) {
|
|
39670
39674
|
if (!first) console.log("");
|
|
39671
39675
|
first = false;
|
|
39672
|
-
const label2 = dbs[0].projectSlug || dbs[0].projectName ||
|
|
39676
|
+
const label2 = dbs[0].projectSlug || dbs[0].projectName || projectGuid;
|
|
39673
39677
|
console.log(label2);
|
|
39674
39678
|
for (const db2 of dbs) {
|
|
39675
39679
|
console.log(`${db2.friendlyName}`);
|
|
@@ -41900,10 +41904,10 @@ function reportSyncResult(result) {
|
|
|
41900
41904
|
console.log(` ${muted("Nothing was deleted. Re-run `gipity sync` to finish the pull.")}`);
|
|
41901
41905
|
}
|
|
41902
41906
|
}
|
|
41903
|
-
async function fetchProjectStats(
|
|
41904
|
-
if (
|
|
41907
|
+
async function fetchProjectStats(projectGuid, cwd) {
|
|
41908
|
+
if (projectGuid) {
|
|
41905
41909
|
try {
|
|
41906
|
-
const res = await get(`/projects/${encodeURIComponent(
|
|
41910
|
+
const res = await get(`/projects/${encodeURIComponent(projectGuid)}/files/stats`);
|
|
41907
41911
|
const d = res.data;
|
|
41908
41912
|
const topLevelNames = d.top_level.map((e) => e.type === "directory" ? `${e.name}/` : e.name);
|
|
41909
41913
|
return {
|
|
@@ -43126,7 +43130,7 @@ Examples:
|
|
|
43126
43130
|
|
|
43127
43131
|
Assets are generated server-side into src/images/ (+ src/manifest.webmanifest)
|
|
43128
43132
|
and are versioned like any other file - rollback restores previous ones.`);
|
|
43129
|
-
brandCommand.command("show", { isDefault: true }).description("Show the stored brand and the resolved render spec").option(
|
|
43133
|
+
brandCommand.command("show", { isDefault: true }).description("Show the stored brand and the resolved render spec").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Brand", async () => {
|
|
43130
43134
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
43131
43135
|
const res = await get(`/projects/${config.projectGuid}/brand`);
|
|
43132
43136
|
if (opts.json) {
|
|
@@ -43138,7 +43142,7 @@ brandCommand.command("show", { isDefault: true }).description("Show the stored b
|
|
|
43138
43142
|
Assets: ${(res.data.assets ?? []).join(", ")}`));
|
|
43139
43143
|
console.log(muted(`Change it: gipity brand set --emoji \u{1F3A8} | --glyph A | --color "#RRGGBB" | --tagline "..."`));
|
|
43140
43144
|
}));
|
|
43141
|
-
brandCommand.command("set").description("Change brand fields and regenerate all assets").option("--emoji <emoji>", "Emoji glyph for the icon + share card (e.g. \u{1F98D})").option("--glyph <char>", "Letter/digit glyph (alias of --emoji, any single character)").option("--color <hex>", "Accent color, #RRGGBB").option("--name <name>", "Display name override (og/share title stays the page title)").option("--tagline <text>", "One-line subtitle on the share card (max 120 chars)").option("--fix-head", "Also splice the share/SEO head block into src/index.html (for apps installed before templates shipped it)").option("--no-regenerate", "Store the fields without re-rendering assets").option(
|
|
43145
|
+
brandCommand.command("set").description("Change brand fields and regenerate all assets").option("--emoji <emoji>", "Emoji glyph for the icon + share card (e.g. \u{1F98D})").option("--glyph <char>", "Letter/digit glyph (alias of --emoji, any single character)").option("--color <hex>", "Accent color, #RRGGBB").option("--name <name>", "Display name override (og/share title stays the page title)").option("--tagline <text>", "One-line subtitle on the share card (max 120 chars)").option("--fix-head", "Also splice the share/SEO head block into src/index.html (for apps installed before templates shipped it)").option("--no-regenerate", "Store the fields without re-rendering assets").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Brand", async () => {
|
|
43142
43146
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
43143
43147
|
const body = {};
|
|
43144
43148
|
const glyph = opts.emoji ?? opts.glyph;
|
|
@@ -43162,7 +43166,7 @@ brandCommand.command("set").description("Change brand fields and regenerate all
|
|
|
43162
43166
|
printBrand(res.data);
|
|
43163
43167
|
reportFiles(res.data.files ?? []);
|
|
43164
43168
|
}));
|
|
43165
|
-
brandCommand.command("apply").description("Re-render all brand assets from the stored brand (no field changes)").option("--fix-head", "Also splice the share/SEO head block into src/index.html (for apps installed before templates shipped it)").option(
|
|
43169
|
+
brandCommand.command("apply").description("Re-render all brand assets from the stored brand (no field changes)").option("--fix-head", "Also splice the share/SEO head block into src/index.html (for apps installed before templates shipped it)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Brand", async () => {
|
|
43166
43170
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
43167
43171
|
const body = opts.fixHead ? { fix_head: true } : {};
|
|
43168
43172
|
const res = await post(`/projects/${config.projectGuid}/brand`, body);
|
|
@@ -43251,9 +43255,10 @@ function dispositionFilename(headers) {
|
|
|
43251
43255
|
const m = /filename="([^"]+)"/.exec(headers.get("content-disposition") ?? "");
|
|
43252
43256
|
return m ? m[1] : null;
|
|
43253
43257
|
}
|
|
43254
|
-
var saveCommand = new Command("save").description("Save this app as a portable .gip bundle").argument("[output]", "Output .gip path, or a directory to write <slug>.gip into (default: ./<slug>.gip)").option("--json", "Output as JSON").addHelpText("after", "\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.").action((output, opts) => run("Save", async () => {
|
|
43258
|
+
var saveCommand = new Command("save").description("Save this app as a portable .gip bundle").argument("[output]", "Output .gip path, or a directory to write <slug>.gip into (default: ./<slug>.gip)").option("--with-data", "Also save every table's rows from the app's database (owner only)").option("--json", "Output as JSON").addHelpText("after", "\nRestore anywhere with `gipity load <file>.gip` - it always creates a NEW project.\nWith --with-data, load also builds the database from the migrations and loads the rows.").action((output, opts) => run("Save", async () => {
|
|
43255
43259
|
const config = requireConfig2();
|
|
43256
|
-
const
|
|
43260
|
+
const query = opts.withData ? "?with_data=1" : "";
|
|
43261
|
+
const doExport = () => downloadWithHeaders(`/projects/${config.projectGuid}/export${query}`);
|
|
43257
43262
|
const { buffer, headers } = opts.json ? await doExport() : await withSpinner("Exporting...", doExport, { done: null });
|
|
43258
43263
|
const filename = dispositionFilename(headers) ?? `${config.projectSlug}.gip`;
|
|
43259
43264
|
let dest = path2.resolve(output ?? filename);
|
|
@@ -43265,13 +43270,15 @@ var saveCommand = new Command("save").description("Save this app as a portable .
|
|
|
43265
43270
|
const sha2562 = createHash4("sha256").update(buffer).digest("hex");
|
|
43266
43271
|
const skipped = Number(headers.get("x-gip-skipped") ?? 0);
|
|
43267
43272
|
const entries = zipEntryCount(buffer);
|
|
43273
|
+
const data = opts.withData ? { tables: Number(headers.get("x-gip-data-tables") ?? 0), rows: Number(headers.get("x-gip-data-rows") ?? 0) } : null;
|
|
43268
43274
|
if (opts.json) {
|
|
43269
43275
|
console.log(JSON.stringify({
|
|
43270
43276
|
path: dest,
|
|
43271
43277
|
bytes: buffer.length,
|
|
43272
43278
|
sha256: sha2562,
|
|
43273
43279
|
...entries !== null ? { entries } : {},
|
|
43274
|
-
skipped
|
|
43280
|
+
skipped,
|
|
43281
|
+
...data ? { data } : {}
|
|
43275
43282
|
}));
|
|
43276
43283
|
return;
|
|
43277
43284
|
}
|
|
@@ -43279,12 +43286,17 @@ var saveCommand = new Command("save").description("Save this app as a portable .
|
|
|
43279
43286
|
console.log(` Path: ${dest}`);
|
|
43280
43287
|
console.log(` Size: ${formatBytes(buffer.length)}`);
|
|
43281
43288
|
if (entries !== null) console.log(` Entries: ${entries} (including the bundle manifest)`);
|
|
43289
|
+
if (data) console.log(` Data: ${data.rows} row(s) from ${data.tables} table(s)`);
|
|
43282
43290
|
console.log(` SHA-256: ${sha2562}`);
|
|
43283
43291
|
if (skipped > 0) {
|
|
43284
43292
|
console.log("");
|
|
43285
43293
|
console.warn(warning(`${skipped} file(s) were skipped (unreadable or over 100 MB) - this bundle is partial.`));
|
|
43286
43294
|
console.warn(warning("Large assets belong in Gipity Storage, not in a code bundle."));
|
|
43287
43295
|
}
|
|
43296
|
+
if (data) {
|
|
43297
|
+
console.log("");
|
|
43298
|
+
console.warn(warning("This bundle holds the app's data. Share it only with people allowed to see that data."));
|
|
43299
|
+
}
|
|
43288
43300
|
console.log("");
|
|
43289
43301
|
console.log(muted("Restore anywhere with `gipity load " + path2.basename(dest) + "` (creates a new project)."));
|
|
43290
43302
|
}));
|
|
@@ -43348,6 +43360,11 @@ function printManifest(m) {
|
|
|
43348
43360
|
}
|
|
43349
43361
|
}
|
|
43350
43362
|
}
|
|
43363
|
+
function printTableCounts(databases) {
|
|
43364
|
+
const rows = databases.flatMap((db2) => db2.tables.map((t) => ({ name: `${db2.database}.${t.table}`, rows: t.rows })));
|
|
43365
|
+
const width = Math.max(0, ...rows.map((r) => r.name.length));
|
|
43366
|
+
for (const r of rows) console.log(` ${r.name.padEnd(width)} ${muted(`${r.rows} row(s)`)}`);
|
|
43367
|
+
}
|
|
43351
43368
|
function printInspect(d, source) {
|
|
43352
43369
|
if (d.meta) {
|
|
43353
43370
|
console.log(bold(d.meta.name));
|
|
@@ -43362,9 +43379,17 @@ function printInspect(d, source) {
|
|
|
43362
43379
|
console.log("");
|
|
43363
43380
|
printManifest(d.manifest);
|
|
43364
43381
|
console.log("");
|
|
43382
|
+
if (d.data) {
|
|
43383
|
+
const tables = d.data.databases.reduce((n, db2) => n + db2.tables.length, 0);
|
|
43384
|
+
console.log(bold(`Data: ${d.data.rows} row(s) in ${tables} table(s), ${formatBytes(d.data.bytes)}`));
|
|
43385
|
+
printTableCounts(d.data.databases);
|
|
43386
|
+
} else {
|
|
43387
|
+
console.log(muted("Data: none (code, migrations and seeds only)"));
|
|
43388
|
+
}
|
|
43389
|
+
console.log("");
|
|
43365
43390
|
console.log(muted("Load it with `gipity load " + source + "` - always creates a NEW project."));
|
|
43366
43391
|
}
|
|
43367
|
-
var loadCommand = new Command("load").description("Create a new app from a .gip bundle or a GitHub repo").argument("<source>", "A .gip file (from `gipity save`), github:owner/repo[/sub/path][@ref], or a github.com URL").option("--name <name>", "Name for the new project (default: the source's saved name)").option("--inspect", "Peek inside the source - contents, deploy phases, function permissions - without creating anything").option("--json", "Output as JSON").addHelpText("after", "\nLoad always creates a NEW project - it never merges into an existing one.\nGitHub sources need a one-time `gipity github connect` (re-run it to grant more repos).").action((source, opts) => run("Load", async () => {
|
|
43392
|
+
var loadCommand = new Command("load").description("Create a new app from a .gip bundle or a GitHub repo").argument("<source>", "A .gip file (from `gipity save`), github:owner/repo[/sub/path][@ref], or a github.com URL").option("--name <name>", "Name for the new project (default: the source's saved name)").option("--inspect", "Peek inside the source - contents, deploy phases, function permissions, saved data - without creating anything").option("--json", "Output as JSON").addHelpText("after", "\nLoad always creates a NEW project - it never merges into an existing one.\nGitHub sources need a one-time `gipity github connect` (re-run it to grant more repos).").action((source, opts) => run("Load", async () => {
|
|
43368
43393
|
const github = isGithubSource(source);
|
|
43369
43394
|
if (!github && /^https?:\/\//i.test(source)) {
|
|
43370
43395
|
throw new Error("Only GitHub URLs are supported for now - pass github:owner/repo, a github.com URL, or a local .gip file.");
|
|
@@ -43428,8 +43453,10 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
|
|
|
43428
43453
|
written: data.written,
|
|
43429
43454
|
failed: data.failed,
|
|
43430
43455
|
partial,
|
|
43431
|
-
applied
|
|
43456
|
+
applied,
|
|
43457
|
+
...data.data ? { data: data.data } : {}
|
|
43432
43458
|
}));
|
|
43459
|
+
if (data.data && !data.data.loaded) process.exitCode = 1;
|
|
43433
43460
|
return;
|
|
43434
43461
|
}
|
|
43435
43462
|
console.log(success(`Created "${project.name}" (${project.slug}) from ${sourceLabel}`));
|
|
@@ -43442,8 +43469,23 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
|
|
|
43442
43469
|
for (const f of data.failed ?? []) console.warn(warning(` ! ${f.path}: ${f.error}`));
|
|
43443
43470
|
console.warn(warning("The project was still created and linked; the files above are missing from it."));
|
|
43444
43471
|
}
|
|
43472
|
+
if (data.data?.loaded) {
|
|
43473
|
+
console.log("");
|
|
43474
|
+
console.log(success(`Loaded ${data.data.rows} row(s) into the app's database:`));
|
|
43475
|
+
printTableCounts(data.data.databases);
|
|
43476
|
+
} else if (data.data) {
|
|
43477
|
+
console.log("");
|
|
43478
|
+
console.warn(warning(`The bundle's rows were not loaded: ${data.data.error}`));
|
|
43479
|
+
console.warn(warning("The project was still created and linked, with an empty database. Delete it with `gipity project delete` and load again once the problem is fixed."));
|
|
43480
|
+
process.exitCode = 1;
|
|
43481
|
+
}
|
|
43445
43482
|
console.log("");
|
|
43446
|
-
|
|
43483
|
+
if (data.data?.loaded) {
|
|
43484
|
+
console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy prod")}`);
|
|
43485
|
+
console.log(muted("The rows are in the prod database. `gipity env create dev --data` gives you a dev copy with them."));
|
|
43486
|
+
} else {
|
|
43487
|
+
console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy dev")}`);
|
|
43488
|
+
}
|
|
43447
43489
|
}));
|
|
43448
43490
|
|
|
43449
43491
|
// src/commands/logs.ts
|
|
@@ -44360,11 +44402,11 @@ ${error(`error: ${log3.error_message}`)}`;
|
|
|
44360
44402
|
return line;
|
|
44361
44403
|
});
|
|
44362
44404
|
}));
|
|
44363
|
-
async function callAnon(
|
|
44405
|
+
async function callAnon(projectGuid, name, body) {
|
|
44364
44406
|
return publicPost(
|
|
44365
|
-
`/api/${
|
|
44407
|
+
`/api/${projectGuid}/fn/${encodeURIComponent(name)}`,
|
|
44366
44408
|
body,
|
|
44367
|
-
await mintAppToken(
|
|
44409
|
+
await mintAppToken(projectGuid)
|
|
44368
44410
|
);
|
|
44369
44411
|
}
|
|
44370
44412
|
fnCommand.command("call <name> [body]").description("Call a function").option("-d, --data <json>", "JSON request body: inline JSON, @file to read a file, or @- / - for stdin").option("--file <field=@path>", "Attach a file as { data, media_type } under <field> (the vision/media service shape), repeatable, e.g. --file image=@receipt.png", (v7, acc) => (acc || []).concat(v7)).option("--anon", "Call as an anonymous visitor (the public path a signed-out user hits) instead of as your signed-in account").option("--field <path>", "Print only this field of the result (dot path, e.g. items.0.short_guid)").option("--json", "Output as JSON").action((name, bodyArg, opts) => run("Call", async () => {
|
|
@@ -44500,7 +44542,7 @@ async function scopeQuery(opts) {
|
|
|
44500
44542
|
return `scope=project&app_guid=${config.projectGuid}`;
|
|
44501
44543
|
}
|
|
44502
44544
|
var secretsCommand = new Command("secrets").description("Manage app secrets").addHelpText("after", '\nEncrypted API keys and tokens for your app, read in functions via secrets.get("NAME").\nValues are write-only: no command prints a stored value back.');
|
|
44503
|
-
secretsCommand.command("list").alias("ls").description("List secret names (never values). Project secrets by default; --account for account-wide").option("--account", "Account-wide secrets shared across all your projects").option(
|
|
44545
|
+
secretsCommand.command("list").alias("ls").description("List secret names (never values). Project secrets by default; --account for account-wide").option("--account", "Account-wide secrets shared across all your projects").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Secrets", async () => {
|
|
44504
44546
|
const res = await get(`/secrets?${await scopeQuery(opts)}`);
|
|
44505
44547
|
if (opts.json) {
|
|
44506
44548
|
console.log(JSON.stringify(res.data));
|
|
@@ -44517,7 +44559,7 @@ secretsCommand.command("list").alias("ls").description("List secret names (never
|
|
|
44517
44559
|
console.log(` ${s.name} ${masked} ${muted(`updated ${new Date(s.updated_at).toLocaleDateString()}`)}`);
|
|
44518
44560
|
}
|
|
44519
44561
|
}));
|
|
44520
|
-
secretsCommand.command("get <name>").description("Secret values are write-only: confirms the secret exists, never prints its value").option("--account", "Look in account-wide secrets").option(
|
|
44562
|
+
secretsCommand.command("get <name>").description("Secret values are write-only: confirms the secret exists, never prints its value").option("--account", "Look in account-wide secrets").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((name, opts) => run("Secrets", async () => {
|
|
44521
44563
|
const res = await get(`/secrets?${await scopeQuery(opts)}`);
|
|
44522
44564
|
const scope = opts.account ? "account-wide" : "project";
|
|
44523
44565
|
const found = res.data.find((s) => s.name === name);
|
|
@@ -44527,7 +44569,7 @@ secretsCommand.command("get <name>").description("Secret values are write-only:
|
|
|
44527
44569
|
`secret values are write-only and are never shown. '${name}' exists${ends}; only a deployed function can read it, with secrets.get('${name}'). To hand a value to another service too, generate it yourself, keep it, then store it: TOK=$(openssl rand -hex 24); gipity secrets set ${name} "$TOK"; echo "$TOK". Setting it again replaces the live value.`
|
|
44528
44570
|
);
|
|
44529
44571
|
}));
|
|
44530
|
-
secretsCommand.command("set <name> <value>").description("Create or update a secret (UPPER_SNAKE_CASE name). Encrypted at rest; never echoed back").option("--account", "Store account-wide (shared across all your projects)").option(
|
|
44572
|
+
secretsCommand.command("set <name> <value>").description("Create or update a secret (UPPER_SNAKE_CASE name). Encrypted at rest; never echoed back").option("--account", "Store account-wide (shared across all your projects)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((name, value, opts) => run("Secrets", async () => {
|
|
44531
44573
|
const res = await put(`/secrets?${await scopeQuery(opts)}`, { name, value });
|
|
44532
44574
|
if (opts.json) {
|
|
44533
44575
|
console.log(JSON.stringify(res.data));
|
|
@@ -44536,7 +44578,7 @@ secretsCommand.command("set <name> <value>").description("Create or update a sec
|
|
|
44536
44578
|
const scope = opts.account ? "account-wide" : "project";
|
|
44537
44579
|
console.log(success(`\u2713 Secret '${res.data.name}' saved (encrypted, ${scope}). Read it in a function with secrets.get('${res.data.name}').`));
|
|
44538
44580
|
}));
|
|
44539
|
-
secretsCommand.command("rm <name>").alias("delete").description("Delete a secret").option("--account", "Delete from account-wide secrets").option(
|
|
44581
|
+
secretsCommand.command("rm <name>").alias("delete").description("Delete a secret").option("--account", "Delete from account-wide secrets").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((name, opts) => run("Secrets", async () => {
|
|
44540
44582
|
const res = await del(`/secrets/${encodeURIComponent(name)}?${await scopeQuery(opts)}`);
|
|
44541
44583
|
if (opts.json) {
|
|
44542
44584
|
console.log(JSON.stringify(res.data));
|
|
@@ -44548,17 +44590,16 @@ secretsCommand.command("rm <name>").alias("delete").description("Delete a secret
|
|
|
44548
44590
|
|
|
44549
44591
|
// src/commands/notify.ts
|
|
44550
44592
|
init_api();
|
|
44551
|
-
init_config();
|
|
44552
44593
|
init_colors();
|
|
44553
44594
|
import { readFileSync as readFileSync22 } from "fs";
|
|
44554
44595
|
var notifyCommand = new Command("notify").description("Push notifications (web and native iOS)").addHelpText("after", "\nGipity Notify: send a test notification, inspect subscriptions, or set up iOS push (notify apns).");
|
|
44555
|
-
notifyCommand.command("test").description("Send a test push notification (web and iOS devices) to a user or everyone").option("--to <who>", "Recipient: a user guid, comma-separated guids, or 'all'", "all").option("--title <text>", "Notification title", "Test notification").option("--body <text>", "Notification body", "Hello from Gipity Notify \u{1F44B}").option("--url <url>", "URL to open when the notification is clicked").option(
|
|
44556
|
-
const
|
|
44596
|
+
notifyCommand.command("test").description("Send a test push notification (web and iOS devices) to a user or everyone").option("--to <who>", "Recipient: a user guid, comma-separated guids, or 'all'", "all").option("--title <text>", "Notification title", "Test notification").option("--body <text>", "Notification body", "Hello from Gipity Notify \u{1F44B}").option("--url <url>", "URL to open when the notification is clicked").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44597
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44557
44598
|
const to2 = opts.to === "all" ? "all" : opts.to.includes(",") ? opts.to.split(",").map((s) => s.trim()) : opts.to;
|
|
44558
44599
|
const notification = { title: opts.title, body: opts.body };
|
|
44559
44600
|
if (opts.url) notification.url = opts.url;
|
|
44560
44601
|
const res = await post(
|
|
44561
|
-
`/api/${
|
|
44602
|
+
`/api/${projectGuid}/services/notify/send`,
|
|
44562
44603
|
{ to: to2, notification }
|
|
44563
44604
|
);
|
|
44564
44605
|
if (opts.json) {
|
|
@@ -44582,10 +44623,10 @@ notifyCommand.command("test").description("Send a test push notification (web an
|
|
|
44582
44623
|
}
|
|
44583
44624
|
}
|
|
44584
44625
|
}));
|
|
44585
|
-
notifyCommand.command("subs").description("Show how many push subscriptions this app has, per user").option(
|
|
44586
|
-
const
|
|
44626
|
+
notifyCommand.command("subs").description("Show how many push subscriptions this app has, per user").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44627
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44587
44628
|
const res = await get(
|
|
44588
|
-
`/api/${
|
|
44629
|
+
`/api/${projectGuid}/services/notify/subs`
|
|
44589
44630
|
);
|
|
44590
44631
|
if (opts.json) {
|
|
44591
44632
|
console.log(JSON.stringify(res.data));
|
|
@@ -44598,10 +44639,10 @@ notifyCommand.command("subs").description("Show how many push subscriptions this
|
|
|
44598
44639
|
console.log(` ${r.user_guid} ${muted(`${r.count} device${r.count === 1 ? "" : "s"}${split}`)}`);
|
|
44599
44640
|
}
|
|
44600
44641
|
}));
|
|
44601
|
-
notifyCommand.command("rm").description("Remove a user's push subscriptions and iOS devices (e.g. on account deletion)").requiredOption("--user <guid>", "User guid whose subscriptions to remove").option(
|
|
44602
|
-
const
|
|
44642
|
+
notifyCommand.command("rm").description("Remove a user's push subscriptions and iOS devices (e.g. on account deletion)").requiredOption("--user <guid>", "User guid whose subscriptions to remove").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44643
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44603
44644
|
const res = await post(
|
|
44604
|
-
`/api/${
|
|
44645
|
+
`/api/${projectGuid}/services/notify/remove`,
|
|
44605
44646
|
{ user_guid: opts.user }
|
|
44606
44647
|
);
|
|
44607
44648
|
if (opts.json) {
|
|
@@ -44630,15 +44671,15 @@ AuthKey_<KEYID>.p8 file, then:
|
|
|
44630
44671
|
|
|
44631
44672
|
The key is stored encrypted and never shown again. Your app registers each
|
|
44632
44673
|
device with POST /api/<app-guid>/notify/devices; notify() then reaches it.`);
|
|
44633
|
-
apnsCommand.command("set").description("Store the APNs key for this app (all environments use it)").requiredOption("--team-id <id>", "Your 10-character Apple Team ID").requiredOption("--key-id <id>", "The 10-character Key ID of the APNs key").requiredOption("--p8 <file>", "Path to the AuthKey_<KEYID>.p8 file").requiredOption("--bundle-id <id>", "Your app bundle id, e.g. com.example.myapp").option("--sandbox", "Devices that register without an environment use the sandbox (development builds)").option(
|
|
44634
|
-
const
|
|
44674
|
+
apnsCommand.command("set").description("Store the APNs key for this app (all environments use it)").requiredOption("--team-id <id>", "Your 10-character Apple Team ID").requiredOption("--key-id <id>", "The 10-character Key ID of the APNs key").requiredOption("--p8 <file>", "Path to the AuthKey_<KEYID>.p8 file").requiredOption("--bundle-id <id>", "Your app bundle id, e.g. com.example.myapp").option("--sandbox", "Devices that register without an environment use the sandbox (development builds)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44675
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44635
44676
|
let p8;
|
|
44636
44677
|
try {
|
|
44637
44678
|
p8 = readFileSync22(opts.p8, "utf-8");
|
|
44638
44679
|
} catch {
|
|
44639
44680
|
throw new Error(`Can't read ${opts.p8}. Pass the path to the AuthKey_<KEYID>.p8 file from Apple.`);
|
|
44640
44681
|
}
|
|
44641
|
-
const res = await put(`/api/${
|
|
44682
|
+
const res = await put(`/api/${projectGuid}/services/notify/apns`, {
|
|
44642
44683
|
team_id: opts.teamId,
|
|
44643
44684
|
key_id: opts.keyId,
|
|
44644
44685
|
bundle_id: opts.bundleId,
|
|
@@ -44652,18 +44693,18 @@ apnsCommand.command("set").description("Store the APNs key for this app (all env
|
|
|
44652
44693
|
console.log(success("\u2713 iOS push is set up."));
|
|
44653
44694
|
printApns(res.data);
|
|
44654
44695
|
}));
|
|
44655
|
-
apnsCommand.command("show").description("Show the APNs setup for this app (never the key itself)").option(
|
|
44656
|
-
const
|
|
44657
|
-
const res = await get(`/api/${
|
|
44696
|
+
apnsCommand.command("show").description("Show the APNs setup for this app (never the key itself)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44697
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44698
|
+
const res = await get(`/api/${projectGuid}/services/notify/apns`);
|
|
44658
44699
|
if (opts.json) {
|
|
44659
44700
|
console.log(JSON.stringify(res.data));
|
|
44660
44701
|
return;
|
|
44661
44702
|
}
|
|
44662
44703
|
printApns(res.data);
|
|
44663
44704
|
}));
|
|
44664
|
-
apnsCommand.command("rm").description("Remove the APNs key (iOS devices stop receiving notifications)").option(
|
|
44665
|
-
const
|
|
44666
|
-
const res = await del(`/api/${
|
|
44705
|
+
apnsCommand.command("rm").description("Remove the APNs key (iOS devices stop receiving notifications)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Notify", async () => {
|
|
44706
|
+
const projectGuid = await projectGuidFor(opts);
|
|
44707
|
+
const res = await del(`/api/${projectGuid}/services/notify/apns`);
|
|
44667
44708
|
if (opts.json) {
|
|
44668
44709
|
console.log(JSON.stringify(res.data));
|
|
44669
44710
|
return;
|
|
@@ -45261,7 +45302,7 @@ init_api();
|
|
|
45261
45302
|
init_config();
|
|
45262
45303
|
init_colors();
|
|
45263
45304
|
var emailCommand = new Command("email").description("Test and inspect a deployed app's email() sends");
|
|
45264
|
-
emailCommand.command("test").description("Send a test email through your app's email() path (owner-billed)").argument("<to>", "Recipient address, or 'owner' for the app owner's own account email").option("--subject <text>", "Subject", "Test email from Gipity").option("--text <text>", "Body text", "This is a test email sent through your app's email() service. \u2709\uFE0F").option("--reply-to <email>", "Reply-To address").option("--from-name <name>", "Sender display name (address stays gipity@gipity.ai)").option(
|
|
45305
|
+
emailCommand.command("test").description("Send a test email through your app's email() path (owner-billed)").argument("<to>", "Recipient address, or 'owner' for the app owner's own account email").option("--subject <text>", "Subject", "Test email from Gipity").option("--text <text>", "Body text", "This is a test email sent through your app's email() service. \u2709\uFE0F").option("--reply-to <email>", "Reply-To address").option("--from-name <name>", "Sender display name (address stays gipity@gipity.ai)").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((to2, opts) => run("Email", async () => {
|
|
45265
45306
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
45266
45307
|
const payload = { to: to2, subject: opts.subject, text: opts.text };
|
|
45267
45308
|
if (opts.replyTo) payload.replyTo = opts.replyTo;
|
|
@@ -45281,7 +45322,7 @@ emailCommand.command("test").description("Send a test email through your app's e
|
|
|
45281
45322
|
console.log(muted(` ${r.to} - ${r.status}${r.reason ? `: ${r.reason}` : ""}`));
|
|
45282
45323
|
}
|
|
45283
45324
|
}));
|
|
45284
|
-
emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").addOption(new Option("--range <range>", "Time range").choices(["1h", "24h", "7d", "30d", "1y"]).default("7d")).option("--limit <n>", "Max rows", "50").option(
|
|
45325
|
+
emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").addOption(new Option("--range <range>", "Time range").choices(["1h", "24h", "7d", "30d", "1y"]).default("7d")).option("--limit <n>", "Max rows", "50").option(...PROJECT_OPTION).option("--json", "Output raw JSON").action((opts) => run("Email", async () => {
|
|
45285
45326
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
45286
45327
|
const res = await get(
|
|
45287
45328
|
`/account/logs/credits?operations=email_send,email_skip&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`
|
|
@@ -45360,12 +45401,12 @@ function statusText(g) {
|
|
|
45360
45401
|
return "expired: it waited too long in the queue (not charged)";
|
|
45361
45402
|
}
|
|
45362
45403
|
}
|
|
45363
|
-
async function submitGenerations(
|
|
45364
|
-
const res = await post(gensPath(
|
|
45404
|
+
async function submitGenerations(projectGuid, body) {
|
|
45405
|
+
const res = await post(gensPath(projectGuid), body);
|
|
45365
45406
|
return res.data;
|
|
45366
45407
|
}
|
|
45367
|
-
async function fetchGenerations(
|
|
45368
|
-
const res = await get(`${gensPath(
|
|
45408
|
+
async function fetchGenerations(projectGuid, ids) {
|
|
45409
|
+
const res = await get(`${gensPath(projectGuid)}?ids=${ids.map(encodeURIComponent).join(",")}`);
|
|
45369
45410
|
return res.data;
|
|
45370
45411
|
}
|
|
45371
45412
|
function combinedText(gens) {
|
|
@@ -45374,7 +45415,7 @@ function combinedText(gens) {
|
|
|
45374
45415
|
const live = gens.find((g) => !TERMINAL.has(g.status));
|
|
45375
45416
|
return `${done}/${gens.length} finished${live ? `; ${statusText(live)}` : ""}`;
|
|
45376
45417
|
}
|
|
45377
|
-
async function waitForGenerations(
|
|
45418
|
+
async function waitForGenerations(projectGuid, initial, opts = {}) {
|
|
45378
45419
|
const ids = initial.map((g) => g.id);
|
|
45379
45420
|
const tty = !!process.stdout.isTTY && !opts.json;
|
|
45380
45421
|
const say = (line) => opts.json ? console.error(line) : console.log(line);
|
|
@@ -45406,7 +45447,7 @@ async function waitForGenerations(projectGuid2, initial, opts = {}) {
|
|
|
45406
45447
|
while (!gens.every((g) => TERMINAL.has(g.status))) {
|
|
45407
45448
|
await sleepUnlessInterrupted(pollMs(), () => interrupted);
|
|
45408
45449
|
if (interrupted) break;
|
|
45409
|
-
gens = await fetchGenerations(
|
|
45450
|
+
gens = await fetchGenerations(projectGuid, ids);
|
|
45410
45451
|
draw(combinedText(gens));
|
|
45411
45452
|
}
|
|
45412
45453
|
} finally {
|
|
@@ -45416,7 +45457,7 @@ async function waitForGenerations(projectGuid2, initial, opts = {}) {
|
|
|
45416
45457
|
if (interrupted) {
|
|
45417
45458
|
const open = gens.filter((g) => !TERMINAL.has(g.status)).map((g) => g.id);
|
|
45418
45459
|
if (process.stdin.isTTY && await confirm(`Cancel ${open.length === 1 ? "the generation" : `${open.length} generations`}? No leaves ${open.length === 1 ? "it" : "them"} queued`, { default: "no", headless: "no" })) {
|
|
45419
|
-
for (const id2 of open) await post(`${gensPath(
|
|
45460
|
+
for (const id2 of open) await post(`${gensPath(projectGuid)}/${encodeURIComponent(id2)}/cancel`);
|
|
45420
45461
|
console.log(muted(`Cancelled ${open.join(" ")} (not charged).`));
|
|
45421
45462
|
} else {
|
|
45422
45463
|
console.error(muted(`Left queued. Check later with: gipity generate status ${open.join(" ")}`));
|
|
@@ -45773,13 +45814,13 @@ function numberedPath(base, i, n) {
|
|
|
45773
45814
|
const slash = Math.max(base.lastIndexOf("/"), base.lastIndexOf("\\"));
|
|
45774
45815
|
return dot > slash ? `${base.slice(0, dot)}-${i + 1}${base.slice(dot)}` : `${base}-${i + 1}`;
|
|
45775
45816
|
}
|
|
45776
|
-
async function generateQueued(
|
|
45817
|
+
async function generateQueued(projectGuid, prompt2, opts) {
|
|
45777
45818
|
if (opts.input) throw new Error("--input editing is not available on queued generations; drop --input or pick a cloud model.");
|
|
45778
45819
|
if (!opts.model || !String(opts.model).startsWith("gipity-")) {
|
|
45779
45820
|
throw new Error("--no-wait is for Gipity GPU models (--model gipity-...; see `gipity generate models`). Cloud models render right away: drop --no-wait.");
|
|
45780
45821
|
}
|
|
45781
45822
|
const started = Date.now();
|
|
45782
|
-
const submitted = await submitGenerations(
|
|
45823
|
+
const submitted = await submitGenerations(projectGuid, {
|
|
45783
45824
|
model: opts.model,
|
|
45784
45825
|
prompt: prompt2,
|
|
45785
45826
|
avoid: opts.avoid,
|
|
@@ -45801,7 +45842,7 @@ async function generateQueued(projectGuid2, prompt2, opts) {
|
|
|
45801
45842
|
return;
|
|
45802
45843
|
}
|
|
45803
45844
|
if (!opts.json) console.log(muted(`Queued ${submitted.length === 1 ? submitted[0].id : submitted.map((g) => g.id).join(", ")} on ${opts.model}`));
|
|
45804
|
-
const done = await waitForGenerations(
|
|
45845
|
+
const done = await waitForGenerations(projectGuid, submitted, { json: !!opts.json });
|
|
45805
45846
|
const elapsed = (Date.now() - started) / 1e3;
|
|
45806
45847
|
const saved = [];
|
|
45807
45848
|
for (let i = 0; i < done.length; i++) {
|
|
@@ -46609,7 +46650,7 @@ function undeployedFunctionsFromFailures(results) {
|
|
|
46609
46650
|
return [...names];
|
|
46610
46651
|
}
|
|
46611
46652
|
var LONG_RUN_MS = 6e4;
|
|
46612
|
-
async function pollTestStatus(
|
|
46653
|
+
async function pollTestStatus(projectGuid, runGuid, opts) {
|
|
46613
46654
|
const startTime = Date.now();
|
|
46614
46655
|
const getPollInterval = () => {
|
|
46615
46656
|
const elapsed = Date.now() - startTime;
|
|
@@ -46631,7 +46672,7 @@ async function pollTestStatus(projectGuid2, runGuid, opts) {
|
|
|
46631
46672
|
if (Date.now() - startTime > POLL_HARD_CAP_MS) {
|
|
46632
46673
|
throw new Error(`Test run ${runGuid} still not finished after ${Math.round(POLL_HARD_CAP_MS / 6e4)} minutes - giving up on the poll. Check it later with \`gipity test status ${runGuid}\` or re-run.`);
|
|
46633
46674
|
}
|
|
46634
|
-
const res = await get(`/projects/${
|
|
46675
|
+
const res = await get(`/projects/${projectGuid}/test/status/${runGuid}`);
|
|
46635
46676
|
const data = res.data;
|
|
46636
46677
|
if (!opts.json && data.results.length > lastResultCount) {
|
|
46637
46678
|
const newResults = data.results.slice(lastResultCount);
|