@mediamonks/canopy-cli 0.7.58 → 0.7.60
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/{ai-00f2Mgqh.mjs → ai-4Mr9FbLU.mjs} +2 -2
- package/dist/{api-fmc8CEMT.mjs → api-CpG-9WSe.mjs} +13 -1
- package/dist/{audience-ByM1jUH3.mjs → audience-BXXdvGC_.mjs} +3 -3
- package/dist/{browse-CxwKuka0.mjs → browse-BegddW9V.mjs} +2 -2
- package/dist/{calls-DsbRjCcy.mjs → calls-NFUccBaQ.mjs} +3 -3
- package/dist/cors-B90J32_O.mjs +129 -0
- package/dist/{db-BU-ni9fj.mjs → db-DIxujtt1.mjs} +13 -6
- package/dist/{deploy-k2DzsLxO.mjs → deploy-Bp5DMp_U.mjs} +4 -4
- package/dist/{dev-qp1VRNM_.mjs → dev-AkM6kLVb.mjs} +9 -9
- package/dist/dev-pj6lLjMR.mjs +2 -0
- package/dist/{dev-worker-7tqL9UFi.mjs → dev-worker-DEK8fOgz.mjs} +18 -1
- package/dist/docs/access-tokens.md +27 -0
- package/dist/docs/cli-cors.md +69 -0
- package/dist/docs/cli-dev.md +1 -1
- package/dist/docs/cli.md +6 -0
- package/dist/docs/data.md +18 -0
- package/dist/docs/index.json +5 -0
- package/dist/docs/migrations.md +22 -0
- package/dist/docs/platform-credentials.md +12 -11
- package/dist/docs/sdk-database.md +51 -0
- package/dist/{docs-ZBBQi3uK.mjs → docs-DH1bWRny.mjs} +4 -4
- package/dist/{egress-Bzn2VKDe.mjs → egress-Dwq-d6cB.mjs} +3 -3
- package/dist/{feedback-B0-6QTSh.mjs → feedback-Q0UhJ6gI.mjs} +4 -4
- package/dist/{files-CBbAtHIK.mjs → files-CUPtGcuZ.mjs} +3 -3
- package/dist/index.mjs +40 -39
- package/dist/{local-C1i2uhAf.mjs → local-CFxKguzg.mjs} +54 -19
- package/dist/{login-Baso-JE0.mjs → login-CP1fO_AH.mjs} +3 -3
- package/dist/{logs-c76jVOhb.mjs → logs-BwqG7lYU.mjs} +3 -3
- package/dist/{mcp-DmcjX8Kn.mjs → mcp-CmfLQ9Vo.mjs} +3 -3
- package/dist/{migrations-ChafLorm.mjs → migrations-DJrRnU7X.mjs} +2 -2
- package/dist/{open-Doat726T.mjs → open-5JLHiz_J.mjs} +2 -2
- package/dist/{package-BzvVsyRl.mjs → package-CJvO8vJf.mjs} +1 -1
- package/dist/{project-template-BnX47DpF.mjs → project-template-CsTOpPto.mjs} +3 -3
- package/dist/project-template-xNjGs9ty.mjs +2 -0
- package/dist/{projects-DOqpkUVT.mjs → projects-DCFn4zcq.mjs} +6 -6
- package/dist/{rename-RA_oYbRT.mjs → rename-OeOI97da.mjs} +3 -3
- package/dist/repo-BW7dDQZL.mjs +2 -0
- package/dist/{repo-DD3eK1P_.mjs → repo-CIEG53hP.mjs} +3 -3
- package/dist/{roles-tqf4sYDM.mjs → roles-2Pkqiwrx.mjs} +1 -1
- package/dist/{roles-BS8-Gvv-.mjs → roles-BCJWHeGq.mjs} +3 -3
- package/dist/{schedule-D8AQ8MVF.mjs → schedule-Cy-7IFy5.mjs} +3 -3
- package/dist/{secrets-Bi7BYCla.mjs → secrets-Cgte8mvq.mjs} +3 -3
- package/dist/{site-BcZ0LOvm.mjs → site-Bz-fEyKS.mjs} +1 -1
- package/dist/skill/canopy/SKILL.md +10 -0
- package/dist/{skill-k3HLr7rK.mjs → skill-CpnX4oLF.mjs} +2 -2
- package/dist/{src-DpjA-a59.mjs → src-Dlg7aeRj.mjs} +250 -23
- package/dist/{staging-BxG3Cffd.mjs → staging-D6-Ojy39.mjs} +3 -3
- package/dist/{token-bHdy_IoX.mjs → token-yAj7pF78.mjs} +3 -3
- package/dist/{ui-9f_lF2Ak.mjs → ui-BUeiY_zZ.mjs} +1 -1
- package/dist/{upgrade-DkjbsYNs.mjs → upgrade-KYHqugVq.mjs} +2 -2
- package/dist/{usage-DFs2TERV.mjs → usage-BXPm04tk.mjs} +3 -3
- package/dist/{versions-Cgw7sB3h.mjs → versions-C204ivt9.mjs} +3 -3
- package/package.json +1 -1
- package/dist/dev-BtacZ4HE.mjs +0 -2
- package/dist/project-template--mESzwea.mjs +0 -2
- package/dist/repo-DayXVvyj.mjs +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
2
|
-
import { i as reportErrors } from "./ui-
|
|
1
|
+
import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
|
|
2
|
+
import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/ai.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as tryReadCanopyJson, p as rewriteCanopyJsonSlug, r as siteConfig, t as projectDir } from "./site-
|
|
1
|
+
import { h as tryReadCanopyJson, p as rewriteCanopyJsonSlug, r as siteConfig, t as projectDir } from "./site-Bz-fEyKS.mjs";
|
|
2
2
|
//#region src/api.ts
|
|
3
3
|
/**
|
|
4
4
|
* Authenticated requests to the Canopy control plane. Credentials, in order:
|
|
@@ -226,6 +226,18 @@ const ERROR_COPY = {
|
|
|
226
226
|
why: "branches are full git refs, and the staging branch must differ from the live one",
|
|
227
227
|
fix: "Pass e.g. `--ref refs/heads/main --staging-ref refs/heads/develop`."
|
|
228
228
|
},
|
|
229
|
+
export_unsupported: {
|
|
230
|
+
why: "the database holds a table that exports and snapshots can't include",
|
|
231
|
+
fix: "The detail names the table. Remove it if you can, or report it with `canopy feedback report`."
|
|
232
|
+
},
|
|
233
|
+
snapshot_failed: {
|
|
234
|
+
why: "the platform could not export the database to take the snapshot",
|
|
235
|
+
fix: "Retry once. If it fails the same way, it isn't temporary: report it with `canopy feedback report` and include the request id."
|
|
236
|
+
},
|
|
237
|
+
export_failed: {
|
|
238
|
+
why: "the platform could not export the database",
|
|
239
|
+
fix: "Retry once. If it fails the same way, it isn't temporary: report it with `canopy feedback report` and include the request id."
|
|
240
|
+
},
|
|
229
241
|
version_expired: {
|
|
230
242
|
why: "version retention expired that version: its files are gone, so it can no longer be made live, staged, pinned or downloaded",
|
|
231
243
|
fix: "Pick a version that is still kept (`canopy versions` shows how many are), or rebuild it from source and deploy."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import { i as reportErrors } from "./ui-
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
//#region src/audience.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as tryResolveProject, r as siteConfig } from "./site-
|
|
2
|
-
import { a as apiRequest, t as ApiError } from "./api-
|
|
1
|
+
import { g as tryResolveProject, r as siteConfig } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, t as ApiError } from "./api-CpG-9WSe.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/browse.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as resolveProject, l as projectDirArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext } from "./api-
|
|
3
|
-
import { i as reportErrors, n as formatDateTime } from "./ui-
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BUeiY_zZ.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/calls.ts
|
|
6
6
|
/**
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { f as resolveProject, l as projectDirArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { i as reportErrors } from "./ui-BUeiY_zZ.mjs";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
//#region src/cors.ts
|
|
6
|
+
/**
|
|
7
|
+
* canopy cors — the project's allowed browser origins on `/api` (OpenSpec
|
|
8
|
+
* project-api-cors): the web apps on other addresses whose pages may call the
|
|
9
|
+
* project's `/api` with an access token. The gateway answers their CORS
|
|
10
|
+
* preflights from this list; everything else gets `cors_origin_not_allowed`.
|
|
11
|
+
* The same list is Settings → Access in the dashboard. Reading it is open to
|
|
12
|
+
* anyone who can open the project's settings; changing it is the owner's.
|
|
13
|
+
*/
|
|
14
|
+
/** What `canopy cors list` prints. */
|
|
15
|
+
function renderOrigins(view, slug) {
|
|
16
|
+
const origins = view.origins ?? [];
|
|
17
|
+
const lines = origins.length === 0 ? [`No browser origins may call ${slug}'s /api.`] : [`Browser origins that may call ${slug}'s /api with a token:`, ...origins.map((o) => ` ${o}`)];
|
|
18
|
+
if (!view.enabled) lines.push("", `Access tokens are off for ${slug}, so this list has no effect until the owner turns them on in Settings → Access.`);
|
|
19
|
+
return lines.join("\n");
|
|
20
|
+
}
|
|
21
|
+
/** The list after adding `origin` (the platform normalises and dedupes it). */
|
|
22
|
+
function addOrigin(origins, origin) {
|
|
23
|
+
return [...origins, origin.trim()];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The list after removing `origin`, matched the way the platform stores it
|
|
27
|
+
* (lowercase, no trailing slash, no default port), or null when it isn't listed.
|
|
28
|
+
*/
|
|
29
|
+
function removeOrigin(origins, origin) {
|
|
30
|
+
const wanted = comparable(origin);
|
|
31
|
+
const kept = origins.filter((o) => comparable(o) !== wanted);
|
|
32
|
+
return kept.length === origins.length ? null : kept;
|
|
33
|
+
}
|
|
34
|
+
function comparable(origin) {
|
|
35
|
+
return origin.trim().toLowerCase().replace(/\/$/, "").replace(/^(https:\/\/[^/]+):443$/, "$1").replace(/^(http:\/\/[^/]+):80$/, "$1");
|
|
36
|
+
}
|
|
37
|
+
const CORS_FIXES = {
|
|
38
|
+
owner_only: "Only the project owner can change the allowed origins — ask them to run this command, or to add it under Settings → Access.",
|
|
39
|
+
person_required: "Run this with your own sign-in (`canopy login`), not a project-scoped token such as an agent or deploy token.",
|
|
40
|
+
invalid_origin: "Use the app's origin: https:// plus its host, like https://app.example.com, or https://*.example.com for every site under one domain.",
|
|
41
|
+
not_found: "Check the project slug, or this site doesn't support allowed origins yet (update Canopy or try another --profile)."
|
|
42
|
+
};
|
|
43
|
+
async function load(slug) {
|
|
44
|
+
return withContext(apiRequest("GET", `/projects/${slug}/access-tokens`), {
|
|
45
|
+
action: `read the allowed origins of ${slug}`,
|
|
46
|
+
fixes: CORS_FIXES
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function save(slug, origins, context) {
|
|
50
|
+
return (await withContext(apiRequest("PUT", `/projects/${slug}/access-tokens/origins`, { origins }), {
|
|
51
|
+
...context,
|
|
52
|
+
fixes: CORS_FIXES
|
|
53
|
+
})).origins;
|
|
54
|
+
}
|
|
55
|
+
const corsCommand = defineCommand({
|
|
56
|
+
meta: {
|
|
57
|
+
name: "cors",
|
|
58
|
+
description: "Manage which web apps on other addresses may call the project's /api with a token"
|
|
59
|
+
},
|
|
60
|
+
subCommands: {
|
|
61
|
+
list: defineCommand({
|
|
62
|
+
meta: {
|
|
63
|
+
name: "list",
|
|
64
|
+
description: "List the browser origins allowed on the project's /api"
|
|
65
|
+
},
|
|
66
|
+
args: { ...projectDirArgs },
|
|
67
|
+
run: reportErrors("cors list", async ({ args }) => {
|
|
68
|
+
const { slug } = resolveProject(args);
|
|
69
|
+
console.log(renderOrigins(await load(slug), slug));
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
allow: defineCommand({
|
|
73
|
+
meta: {
|
|
74
|
+
name: "allow",
|
|
75
|
+
description: "Let a web app's pages call the project's /api with a token (e.g. https://app.example.com or https://*.figma.site)"
|
|
76
|
+
},
|
|
77
|
+
args: {
|
|
78
|
+
origin: {
|
|
79
|
+
type: "positional",
|
|
80
|
+
description: "The app's origin",
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
...projectDirArgs
|
|
84
|
+
},
|
|
85
|
+
run: reportErrors("cors allow", async ({ args }) => {
|
|
86
|
+
const { slug } = resolveProject(args);
|
|
87
|
+
const current = await load(slug);
|
|
88
|
+
const origins = await save(slug, addOrigin(current.origins ?? [], args.origin), { action: `allow ${args.origin} on ${slug}` });
|
|
89
|
+
console.log(`Allowed ${args.origin} on ${slug}'s /api — it takes effect within seconds.\n`);
|
|
90
|
+
console.log(renderOrigins({
|
|
91
|
+
...current,
|
|
92
|
+
origins
|
|
93
|
+
}, slug));
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
remove: defineCommand({
|
|
97
|
+
meta: {
|
|
98
|
+
name: "remove",
|
|
99
|
+
description: "Stop a web app's pages calling the project's /api"
|
|
100
|
+
},
|
|
101
|
+
args: {
|
|
102
|
+
origin: {
|
|
103
|
+
type: "positional",
|
|
104
|
+
description: "The origin to remove",
|
|
105
|
+
required: true
|
|
106
|
+
},
|
|
107
|
+
...projectDirArgs
|
|
108
|
+
},
|
|
109
|
+
run: reportErrors("cors remove", async ({ args }) => {
|
|
110
|
+
const { slug } = resolveProject(args);
|
|
111
|
+
const current = await load(slug);
|
|
112
|
+
const kept = removeOrigin(current.origins ?? [], args.origin);
|
|
113
|
+
if (kept === null) {
|
|
114
|
+
console.log(`${args.origin} is not allowed on ${slug}; nothing to remove.\n`);
|
|
115
|
+
console.log(renderOrigins(current, slug));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const origins = await save(slug, kept, { action: `remove ${args.origin} from ${slug}` });
|
|
119
|
+
console.log(`Removed ${args.origin} from ${slug}'s /api — it takes effect within seconds.\n`);
|
|
120
|
+
console.log(renderOrigins({
|
|
121
|
+
...current,
|
|
122
|
+
origins
|
|
123
|
+
}, slug));
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
//#endregion
|
|
129
|
+
export { corsCommand };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as resolveProject, u as projectFlagArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-
|
|
3
|
-
import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-
|
|
4
|
-
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-
|
|
1
|
+
import { f as resolveProject, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext, r as apiDataRequest } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { a as requireTty, i as reportErrors, o as spinner$1, s as unwrap, t as confirmTypedSlug } from "./ui-BUeiY_zZ.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-DJrRnU7X.mjs";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
7
7
|
import * as p from "@clack/prompts";
|
|
@@ -29,6 +29,10 @@ const stagingFlagArgs = { staging: {
|
|
|
29
29
|
} };
|
|
30
30
|
const channelOf = (args) => args.staging ? "staging" : "live";
|
|
31
31
|
const channelNote = (args) => args.staging ? " [staging]" : "";
|
|
32
|
+
/** The notes an export or snapshot came back with, one printable line each. */
|
|
33
|
+
function exportNoteLines(notes) {
|
|
34
|
+
return (notes ?? []).map((note) => `Note: ${note}`);
|
|
35
|
+
}
|
|
32
36
|
const formatSize = (bytes) => bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} kB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
33
37
|
const pullCommand = defineCommand({
|
|
34
38
|
meta: {
|
|
@@ -49,12 +53,13 @@ const pullCommand = defineCommand({
|
|
|
49
53
|
const spin = spinner$1();
|
|
50
54
|
spin.start(`Exporting ${slug}${channelNote(args)}…`);
|
|
51
55
|
try {
|
|
52
|
-
const { url } = await apiDataRequest("POST", "/db/export", slug, void 0, { channel: channelOf(args) });
|
|
56
|
+
const { url, notes } = await apiDataRequest("POST", "/db/export", slug, void 0, { channel: channelOf(args) });
|
|
53
57
|
const download = await fetch(url);
|
|
54
58
|
if (!download.ok) throw new Error(`Download failed (HTTP ${download.status}).`);
|
|
55
59
|
const sql = Buffer.from(await download.arrayBuffer());
|
|
56
60
|
writeFileSync(out, sql);
|
|
57
61
|
spin.stop(`Wrote ${out} (${formatSize(sql.byteLength)}).`);
|
|
62
|
+
for (const line of exportNoteLines(notes)) console.log(line);
|
|
58
63
|
} catch (err) {
|
|
59
64
|
spin.error("Export failed.");
|
|
60
65
|
throw err;
|
|
@@ -75,13 +80,15 @@ const snapshotCommand = defineCommand({
|
|
|
75
80
|
const spin = spinner$1();
|
|
76
81
|
spin.start(`Snapshotting ${slug}${channelNote(args)}…`);
|
|
77
82
|
let created;
|
|
83
|
+
let notes;
|
|
78
84
|
try {
|
|
79
|
-
({snapshot: created} = await apiDataRequest("POST", "/db/snapshots", slug, void 0, { channel: channelOf(args) }));
|
|
85
|
+
({snapshot: created, notes} = await apiDataRequest("POST", "/db/snapshots", slug, void 0, { channel: channelOf(args) }));
|
|
80
86
|
} catch (err) {
|
|
81
87
|
spin.error("Snapshot failed.");
|
|
82
88
|
throw err;
|
|
83
89
|
}
|
|
84
90
|
spin.stop(`Stored ${created.key} (${formatSize(created.size)}).`);
|
|
91
|
+
for (const line of exportNoteLines(notes)) console.log(line);
|
|
85
92
|
console.log(`Restore anytime with \`canopy db restore --snapshot ${created.key}\`.`);
|
|
86
93
|
})
|
|
87
94
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as projectUrl, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, m as stagingUrl, r as siteConfig, s as parseVersionArg, u as projectFlagArgs } from "./site-
|
|
2
|
-
import { a as apiRequest, d as githubActionsCredentials, i as apiDownload, l as currentSlug, m as withContext, p as onGithubActions, r as apiDataRequest, t as ApiError } from "./api-
|
|
3
|
-
import { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } from "./ui-
|
|
4
|
-
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-
|
|
1
|
+
import { d as projectUrl, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, m as stagingUrl, r as siteConfig, s as parseVersionArg, u as projectFlagArgs } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { a as apiRequest, d as githubActionsCredentials, i as apiDownload, l as currentSlug, m as withContext, p as onGithubActions, r as apiDataRequest, t as ApiError } from "./api-CpG-9WSe.mjs";
|
|
3
|
+
import { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } from "./ui-BUeiY_zZ.mjs";
|
|
4
|
+
import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-DJrRnU7X.mjs";
|
|
5
5
|
import { builtinModules } from "node:module";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-
|
|
2
|
-
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-
|
|
3
|
-
import { a as apiRequest, m as withContext, t as ApiError } from "./api-
|
|
4
|
-
import { i as reportErrors, n as formatDateTime } from "./ui-
|
|
5
|
-
import { r as readMigrationFiles } from "./migrations-
|
|
6
|
-
import { s as parseAppRoleFlag } from "./roles-
|
|
1
|
+
import { c as projectDialect, f as resolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-Bz-fEyKS.mjs";
|
|
2
|
+
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-Dlg7aeRj.mjs";
|
|
3
|
+
import { a as apiRequest, m as withContext, t as ApiError } from "./api-CpG-9WSe.mjs";
|
|
4
|
+
import { i as reportErrors, n as formatDateTime } from "./ui-BUeiY_zZ.mjs";
|
|
5
|
+
import { r as readMigrationFiles } from "./migrations-DJrRnU7X.mjs";
|
|
6
|
+
import { s as parseAppRoleFlag } from "./roles-BCJWHeGq.mjs";
|
|
7
7
|
import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { defineCommand } from "citty";
|
|
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
|
|
|
107
107
|
console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-
|
|
110
|
+
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-DEK8fOgz.mjs");
|
|
111
111
|
const secrets = readDevVars(flags.dir);
|
|
112
112
|
const email = siteConfig().email;
|
|
113
113
|
const found = await remoteUser?.() ?? (email ? {
|
|
@@ -326,7 +326,7 @@ async function devRemote(flags, slug) {
|
|
|
326
326
|
async function devLocal(flags, slug) {
|
|
327
327
|
let dump;
|
|
328
328
|
if (flags.pull) {
|
|
329
|
-
const { fetchProjectDump } = await import("./local-
|
|
329
|
+
const { fetchProjectDump } = await import("./local-CFxKguzg.mjs");
|
|
330
330
|
console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
|
|
331
331
|
dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
|
|
332
332
|
}
|
|
@@ -343,7 +343,7 @@ async function devLocal(flags, slug) {
|
|
|
343
343
|
}
|
|
344
344
|
const workerAttest = randomBytes(24).toString("base64url");
|
|
345
345
|
const devRoles = await resolveDevRoles(slug, flags.asRoles);
|
|
346
|
-
const { createSandbox } = await import("./local-
|
|
346
|
+
const { createSandbox } = await import("./local-CFxKguzg.mjs");
|
|
347
347
|
const sandbox = await createSandbox({
|
|
348
348
|
slug,
|
|
349
349
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as readPersonCaller, i as CALLER_HEADER, n as redactCanopyCredentials, o as readUser, r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-
|
|
1
|
+
import { a as readPersonCaller, i as CALLER_HEADER, n as redactCanopyCredentials, o as readUser, r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-Dlg7aeRj.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { relative, resolve, sep } from "node:path";
|
|
4
4
|
//#region src/dev-worker.ts
|
|
@@ -148,6 +148,23 @@ function createDevDb(canopyFetch, dialect) {
|
|
|
148
148
|
rows,
|
|
149
149
|
rowCount: rows.length
|
|
150
150
|
};
|
|
151
|
+
},
|
|
152
|
+
batch: async (statements) => {
|
|
153
|
+
const response = await canopyFetch("/data/v1/db/sql/batch", {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: { "content-type": "application/json" },
|
|
156
|
+
body: JSON.stringify({ statements })
|
|
157
|
+
});
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
const text = await response.text();
|
|
160
|
+
let detail = text.slice(0, 300);
|
|
161
|
+
try {
|
|
162
|
+
const body = JSON.parse(text);
|
|
163
|
+
detail = body.detail ?? body.error ?? detail;
|
|
164
|
+
} catch {}
|
|
165
|
+
throw new Error(`env.DB batch failed (HTTP ${response.status}): ${detail}`);
|
|
166
|
+
}
|
|
167
|
+
return (await response.json()).results;
|
|
151
168
|
}
|
|
152
169
|
};
|
|
153
170
|
}
|
|
@@ -84,6 +84,33 @@ A personal token keeps working as long as its person signs in to Canopy at
|
|
|
84
84
|
least once a month, in a browser or with `canopy login`. If someone only ever uses the plugin, the
|
|
85
85
|
`token_access_lost` answer tells them to sign in again.
|
|
86
86
|
|
|
87
|
+
## Calling from a web app
|
|
88
|
+
|
|
89
|
+
A web app on another address, like an app built in Figma Make, can call the
|
|
90
|
+
project's `/api` with a token too. The owner first allows the app's address,
|
|
91
|
+
with [`canopy cors allow`](https://docs.canopy.website/cli/cors) or under **Settings → Access → Allowed
|
|
92
|
+
browser origins**:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
canopy cors allow "https://*.figma.site"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then the app calls the project as usual:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
const res = await fetch("https://my-project.canopy.website/api/records", {
|
|
102
|
+
headers: { Authorization: `Bearer ${CANOPY_KEY}` },
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Canopy answers the browser's preflight check itself; your backend needs no
|
|
107
|
+
CORS code. An address that isn't listed gets `cors_origin_not_allowed`, and
|
|
108
|
+
the browser shows "blocked by CORS policy".
|
|
109
|
+
|
|
110
|
+
A token in a web page can be read by anyone who can open that page. Use a
|
|
111
|
+
project key limited to `GET` and to the paths the app needs, and treat
|
|
112
|
+
whatever it can reach as visible to the app's visitors.
|
|
113
|
+
|
|
87
114
|
## 4. Check it in your backend
|
|
88
115
|
|
|
89
116
|
Your backend sees who called on [`env.CALLER`](https://docs.canopy.website/sdk/auth#in-a-backend-worker),
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: canopy cors
|
|
3
|
+
description: Choose which web apps on other addresses may call your project's /api with an access token.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy cors` manages the project's **allowed browser origins**: the web apps
|
|
7
|
+
on other addresses whose pages may call the project's `/api` with an
|
|
8
|
+
[access token](https://docs.canopy.website/guides/access-tokens). An app built in Figma Make is the usual
|
|
9
|
+
case. Without an entry here, the browser blocks the call with a "blocked by
|
|
10
|
+
CORS policy" error.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
canopy cors list
|
|
16
|
+
canopy cors allow https://app.example.com
|
|
17
|
+
canopy cors allow "https://*.figma.site"
|
|
18
|
+
canopy cors remove https://app.example.com
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Arguments & flags
|
|
22
|
+
|
|
23
|
+
All subcommands resolve the project the usual way: `canopy.json` in the
|
|
24
|
+
target directory, or `--project <slug>` to override. They also honor the global
|
|
25
|
+
`--profile <site>` / `CANOPY_PROFILE`.
|
|
26
|
+
|
|
27
|
+
- `list`: print the allowed origins. It also says when access tokens are off,
|
|
28
|
+
because the list does nothing until they're on. Anyone who can open the
|
|
29
|
+
project's settings can run it.
|
|
30
|
+
- `allow <origin>`: add an origin. Owner only.
|
|
31
|
+
- `remove <origin>`: remove an origin. Owner only. Removing one that isn't
|
|
32
|
+
listed changes nothing.
|
|
33
|
+
|
|
34
|
+
An origin is the start of the app's address:
|
|
35
|
+
|
|
36
|
+
- `https://` plus the host, with a port if it uses one, like
|
|
37
|
+
`https://app.example.com`. No path.
|
|
38
|
+
- `https://*.example.com` allows every site one level under `example.com`,
|
|
39
|
+
like `https://abc.example.com`, but not `https://example.com` itself or
|
|
40
|
+
`https://a.b.example.com`. Quote it so your shell leaves the `*` alone.
|
|
41
|
+
- `http://localhost` and `http://127.0.0.1`, with any port, for trying an app
|
|
42
|
+
on your own machine.
|
|
43
|
+
|
|
44
|
+
`*` on its own is refused, and so is any other `http://` address. A project can
|
|
45
|
+
list up to 20 origins.
|
|
46
|
+
|
|
47
|
+
## How it works
|
|
48
|
+
|
|
49
|
+
The list lives on the platform, per project, and covers the live and staging
|
|
50
|
+
channels. Changes take effect within a few seconds, with no deploy. The same
|
|
51
|
+
list is under **Settings → Access** in the dashboard.
|
|
52
|
+
|
|
53
|
+
Canopy answers the browser's preflight check itself, so your backend never
|
|
54
|
+
needs CORS code. For a listed origin, it adds the CORS headers to every call
|
|
55
|
+
that carries a token, and replaces any your backend sets. If you are
|
|
56
|
+
debugging, send the preflight yourself to see why it was refused:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
curl -i -X OPTIONS https://my-project.canopy.website/api/health \
|
|
60
|
+
-H "Origin: https://abc.figma.site" \
|
|
61
|
+
-H "Access-Control-Request-Method: GET"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A refusal is `403` with `cors_origin_not_allowed` and a reason.
|
|
65
|
+
|
|
66
|
+
A token used from a web page can be read by anyone who can open that page.
|
|
67
|
+
Use a [project key](https://docs.canopy.website/guides/access-tokens#2-make-a-token) limited to `GET` and
|
|
68
|
+
to the paths the app needs. Treat whatever it can reach as visible to the
|
|
69
|
+
app's visitors.
|
package/dist/docs/cli-dev.md
CHANGED
|
@@ -40,7 +40,7 @@ With the lock in place, `--local` runs on an embedded SQLite engine instead —
|
|
|
40
40
|
|
|
41
41
|
**Your backend worker.** If `canopy.json` names a `worker` entry (the worker scaffold does), `canopy dev` serves it too: requests to `/api/*` go to your worker, everything else to the SPA — the same split the platform makes once you deploy. There's no build step; save the file and the next request runs the new code.
|
|
42
42
|
|
|
43
|
-
Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG`, and `env.CANOPY_CHANNEL` (`"staging"` with `--staging`, otherwise `"live"`). They all follow the mode you're in — live project data by default, your sandbox under `--local`. Three differences worth knowing: `env.CALLER` and `env.USER` are you (the account you logged in with), since there's no company login in front of a local server; there's no [access token](https://docs.canopy.website/guides/access-tokens) check, so `env.CALLER.token` is always `null` and `requireScope` lets every request through; and a write through `env.DB` reports no row count locally.
|
|
43
|
+
Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` (with [`batch()`](https://docs.canopy.website/sdk/database#in-your-worker), still all or nothing) and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG`, and `env.CANOPY_CHANNEL` (`"staging"` with `--staging`, otherwise `"live"`). They all follow the mode you're in — live project data by default, your sandbox under `--local`. Three differences worth knowing: `env.CALLER` and `env.USER` are you (the account you logged in with), since there's no company login in front of a local server; there's no [access token](https://docs.canopy.website/guides/access-tokens) check, so `env.CALLER.token` is always `null` and `requireScope` lets every request through; and a write through `env.DB.query()` reports no row count locally (`env.DB.batch()` does).
|
|
44
44
|
|
|
45
45
|
To tick a schedule by hand, post its name to the same path the platform uses:
|
|
46
46
|
|
package/dist/docs/cli.md
CHANGED
|
@@ -92,6 +92,12 @@ See `canopy docs ci` for wiring push-to-main deploys.
|
|
|
92
92
|
- `canopy calls allow <project>` — let a project call it (owner only).
|
|
93
93
|
- `canopy calls remove <project>` — stop it (owner only).
|
|
94
94
|
|
|
95
|
+
## Web apps calling the API (CORS)
|
|
96
|
+
|
|
97
|
+
- `canopy cors list`: web apps on other addresses allowed to call the project's `/api` with a token.
|
|
98
|
+
- `canopy cors allow <origin>`: allow one, like `https://app.example.com` or `"https://*.figma.site"` (owner only).
|
|
99
|
+
- `canopy cors remove <origin>`: stop it (owner only).
|
|
100
|
+
|
|
95
101
|
## Maintenance
|
|
96
102
|
|
|
97
103
|
- `canopy upgrade` — update the CLI to the latest version. `--version <v>` pins a
|
package/dist/docs/data.md
CHANGED
|
@@ -72,6 +72,24 @@ canopy db snapshots delete <key> # delete one for
|
|
|
72
72
|
The same settings are on the dashboard's Data tab. See
|
|
73
73
|
[`canopy db`](https://docs.canopy.website/cli/db#canopy-db-snapshots-settings) for every option.
|
|
74
74
|
|
|
75
|
+
### Your own full-text search tables
|
|
76
|
+
|
|
77
|
+
On sqlite, a project can create its own full-text search tables in a
|
|
78
|
+
[migration](https://docs.canopy.website/guides/migrations) (`CREATE VIRTUAL TABLE … USING fts5(…)`).
|
|
79
|
+
Dumps, snapshots and restores include them:
|
|
80
|
+
|
|
81
|
+
- A table that stores its own text comes back with all its rows.
|
|
82
|
+
- A table that indexes another of your tables (`content='posts'`) is rebuilt from
|
|
83
|
+
that table on restore.
|
|
84
|
+
- A **contentless** table (`content=''`) only keeps an index, which can't be
|
|
85
|
+
exported, so it comes back **empty**. `canopy db pull` and `canopy db snapshot`
|
|
86
|
+
print a note naming it. After a restore, rebuild it from your own data.
|
|
87
|
+
- Settings you changed with FTS5's configuration commands, such as a custom
|
|
88
|
+
`rank`, aren't carried over. Set them again after a restore.
|
|
89
|
+
|
|
90
|
+
Other kinds of virtual tables can't be exported; `canopy db snapshot` names the
|
|
91
|
+
table and stops (`export_unsupported`).
|
|
92
|
+
|
|
75
93
|
## Restore — destructive
|
|
76
94
|
|
|
77
95
|
> **Warning:** Restoring **replaces ALL project data**. Take a snapshot first — a snapshot taken seconds earlier
|
package/dist/docs/index.json
CHANGED
|
@@ -331,6 +331,11 @@
|
|
|
331
331
|
"title": "canopy calls",
|
|
332
332
|
"summary": "Manage which other projects may call this project's backend."
|
|
333
333
|
},
|
|
334
|
+
{
|
|
335
|
+
"slug": "cli-cors",
|
|
336
|
+
"title": "canopy cors",
|
|
337
|
+
"summary": "Choose which web apps on other addresses may call your project's /api with an access token."
|
|
338
|
+
},
|
|
334
339
|
{
|
|
335
340
|
"slug": "cli-secrets",
|
|
336
341
|
"title": "canopy secrets",
|
package/dist/docs/migrations.md
CHANGED
|
@@ -135,6 +135,28 @@ export default {
|
|
|
135
135
|
};
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
On a sqlite site the backend proxy can also take a second callback for
|
|
139
|
+
`db.batch([...])`. Hand it to [`env.DB.batch()`](https://docs.canopy.website/sdk/database#in-your-worker)
|
|
140
|
+
and Drizzle's batches run in one round trip, all or nothing:
|
|
141
|
+
|
|
142
|
+
```ts title="worker/index.ts"
|
|
143
|
+
const db = drizzle(
|
|
144
|
+
async (sql, params, method) => {
|
|
145
|
+
/* as above */
|
|
146
|
+
},
|
|
147
|
+
async (queries) => {
|
|
148
|
+
const results = await env.DB.batch(queries.map(({ sql, params }) => ({ sql, params })));
|
|
149
|
+
return results.map(({ rows }, i) => {
|
|
150
|
+
const values = rows.map((row) => Object.values(row));
|
|
151
|
+
return { rows: queries[i]?.method === "get" ? (values[0] ?? []) : values };
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Drizzle's `pg-proxy` driver has no batch callback; on a postgres site, call
|
|
158
|
+
`env.DB.batch()` directly with the SQL you need.
|
|
159
|
+
|
|
138
160
|
**In the browser (or anywhere the SDK runs)**, wrap `canopy.db.sql()` the same
|
|
139
161
|
way:
|
|
140
162
|
|
|
@@ -9,17 +9,18 @@ your browser needs a way in.
|
|
|
9
9
|
|
|
10
10
|
## Pick by job
|
|
11
11
|
|
|
12
|
-
| You want to… | Use
|
|
13
|
-
| ------------------------------------------------------------- |
|
|
14
|
-
| work with Canopy from your terminal | [`canopy login`](https://docs.canopy.website/cli/login)
|
|
15
|
-
| run your project locally against its real data | a dev token — [`canopy dev`](https://docs.canopy.website/cli/dev) makes one for you
|
|
16
|
-
| deploy from GitHub Actions | nothing: [link the repository](https://docs.canopy.website/guides/ci)
|
|
17
|
-
| deploy from any other CI | a deploy token — [`canopy token create`](https://docs.canopy.website/cli/token)
|
|
18
|
-
| let a CI job, script or service call your project's `/api` | a [project key](https://docs.canopy.website/guides/access-tokens)
|
|
19
|
-
| let a desktop app or plugin call your project's `/api` as you | a [personal token](https://docs.canopy.website/guides/access-tokens)
|
|
20
|
-
| let
|
|
21
|
-
| let
|
|
22
|
-
| let
|
|
12
|
+
| You want to… | Use | Lasts |
|
|
13
|
+
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
|
14
|
+
| work with Canopy from your terminal | [`canopy login`](https://docs.canopy.website/cli/login) | 30 days, or until you sign out |
|
|
15
|
+
| run your project locally against its real data | a dev token — [`canopy dev`](https://docs.canopy.website/cli/dev) makes one for you | 12 hours, or until you sign out |
|
|
16
|
+
| deploy from GitHub Actions | nothing: [link the repository](https://docs.canopy.website/guides/ci) | — |
|
|
17
|
+
| deploy from any other CI | a deploy token — [`canopy token create`](https://docs.canopy.website/cli/token) | until revoked, or 90 days without a deploy |
|
|
18
|
+
| let a CI job, script or service call your project's `/api` | a [project key](https://docs.canopy.website/guides/access-tokens) | until revoked or its date, or 90 days without a call |
|
|
19
|
+
| let a desktop app or plugin call your project's `/api` as you | a [personal token](https://docs.canopy.website/guides/access-tokens) | up to 90 days, while you keep signing in |
|
|
20
|
+
| let a web app on another address call your project's `/api` | a [project key](https://docs.canopy.website/guides/access-tokens#calling-from-a-web-app), plus [`canopy cors allow`](https://docs.canopy.website/cli/cors) | until revoked or its date, or 90 days without a call |
|
|
21
|
+
| let an AI agent work on your project | nothing: [`canopy mcp`](https://docs.canopy.website/cli/mcp) and [`canopy browse`](https://docs.canopy.website/cli/browse) do it | while your `canopy login` lasts |
|
|
22
|
+
| let another project's backend call yours | nothing: [`canopy calls allow`](https://docs.canopy.website/cli/calls) | — |
|
|
23
|
+
| let people outside Monks open your project | an [email invite](https://docs.canopy.website/guides/outside-sign-in) or the [client password](https://docs.canopy.website/platform/client-access) | — |
|
|
23
24
|
|
|
24
25
|
Your own backend never needs a credential either: the platform gives it one,
|
|
25
26
|
and the [SDK](https://docs.canopy.website/sdk) uses it for you.
|
|
@@ -122,6 +122,57 @@ per SDK instance, so calling it often is free.
|
|
|
122
122
|
> `db.sql()` only when you genuinely need SQL (aggregates, joins, bulk updates), and branch on
|
|
123
123
|
> `db.dialect()` whenever the syntax differs.
|
|
124
124
|
|
|
125
|
+
## In your worker
|
|
126
|
+
|
|
127
|
+
Your [backend](https://docs.canopy.website/developers/architecture) also gets the database directly, as
|
|
128
|
+
`env.DB`. It speaks the same SQL as `db.sql()` — your site's own dialect — and
|
|
129
|
+
has no connection string to manage:
|
|
130
|
+
|
|
131
|
+
```ts title="worker/index.ts"
|
|
132
|
+
// What env.DB looks like; declare it in your worker's Env type.
|
|
133
|
+
interface ProjectDb {
|
|
134
|
+
dialect: "sqlite" | "postgres";
|
|
135
|
+
query(
|
|
136
|
+
sql: string,
|
|
137
|
+
params?: unknown[],
|
|
138
|
+
): Promise<{ rows: Record<string, unknown>[]; rowCount: number | null }>;
|
|
139
|
+
batch(
|
|
140
|
+
statements: { sql: string; params?: unknown[] }[],
|
|
141
|
+
): Promise<{ rows: Record<string, unknown>[]; rowCount: number | null }[]>;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- **`dialect`** — `"sqlite"` or `"postgres"`, so your code can pick the right
|
|
146
|
+
placeholders (`?1` versus `$1`).
|
|
147
|
+
- **`query(sql, params?)`** — one statement. `rows` holds what it returned;
|
|
148
|
+
`rowCount` is the number of rows returned, or for a write the number of rows
|
|
149
|
+
it changed.
|
|
150
|
+
- **`batch(statements)`** — several statements in one call, each with its own
|
|
151
|
+
parameters. You get one `{ rows, rowCount }` back per statement, in order.
|
|
152
|
+
|
|
153
|
+
Every `query()` is a round trip to the database. When you write many rows — an
|
|
154
|
+
import, a sync — send them as a batch instead:
|
|
155
|
+
|
|
156
|
+
```ts title="worker/index.ts"
|
|
157
|
+
const insert = "INSERT INTO texts (key, value) VALUES (?1, ?2)";
|
|
158
|
+
for (let i = 0; i < texts.length; i += 500) {
|
|
159
|
+
await env.DB.batch(
|
|
160
|
+
texts.slice(i, i + 500).map((t) => ({ sql: insert, params: [t.key, t.value] })),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
A batch is **all or nothing**. If any statement fails, none of the batch's
|
|
166
|
+
changes are kept and the call throws with the database's own message. That
|
|
167
|
+
also makes a batch the way to change several tables together: `BEGIN` and
|
|
168
|
+
`COMMIT` through `query()` do not hold a transaction.
|
|
169
|
+
|
|
170
|
+
A batch holds at most 1,000 statements. Each statement keeps the database's
|
|
171
|
+
own limits, such as 100 bound parameters per statement on a SQLite site. A
|
|
172
|
+
statement cannot use an earlier one's result as a parameter; use a subquery or
|
|
173
|
+
`RETURNING` in SQL for that. `canopy dev` gives your worker the same `env.DB`,
|
|
174
|
+
batches included.
|
|
175
|
+
|
|
125
176
|
## Who can call this from the browser
|
|
126
177
|
|
|
127
178
|
Everything above works from a page as well as from your worker — that is the
|