@mediamonks/canopy-cli 0.7.46 → 0.7.48
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/audience-B68YZBGy.mjs +121 -0
- package/dist/calls-DhkVJ32C.mjs +101 -0
- package/dist/{dev-BmKeIdMi.mjs → dev-BE48xClT.mjs} +6 -5
- package/dist/{dev-worker-CcYwQjxz.mjs → dev-worker-BP-HGHYb.mjs} +1 -1
- package/dist/dev-z2KvqkF9.mjs +2 -0
- package/dist/docs/calling-projects.md +99 -0
- package/dist/docs/cli-audience.md +47 -0
- package/dist/docs/index.json +10 -0
- package/dist/docs/platform-members-and-access.md +20 -0
- package/dist/docs/sdk-auth.md +4 -0
- package/dist/{docs-CtMrMpt1.mjs → docs-BZquSJej.mjs} +1 -1
- package/dist/{feedback-BXhbxyXI.mjs → feedback-CAM-DJH9.mjs} +1 -1
- package/dist/index.mjs +10 -8
- package/dist/{local-C9Bi9f3y.mjs → local-DRcoiNcy.mjs} +2 -2
- package/dist/{mcp-CGmWkGN8.mjs → mcp-q9wWZ2yk.mjs} +1 -1
- package/dist/{package-BdNHq8QV.mjs → package-Df9caKjj.mjs} +1 -1
- package/dist/{skill-vzcCD1b4.mjs → skill-BtL5ANQO.mjs} +1 -1
- package/dist/{src-8vxOBOxW.mjs → src-DzU89gZN.mjs} +57 -18
- package/dist/{upgrade-8_pFNTo5.mjs → upgrade-DrEk3nqk.mjs} +1 -1
- package/package.json +3 -3
- package/dist/dev-BvVlq9np.mjs +0 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { c as projectDirArgs, d as resolveProject, l as projectFlagArgs } from "./site-BL5Ik-yj.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-DmJrIsE7.mjs";
|
|
3
|
+
import { r as reportErrors } from "./ui-26ETk1n8.mjs";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
import * as p from "@clack/prompts";
|
|
6
|
+
//#region src/audience.ts
|
|
7
|
+
/**
|
|
8
|
+
* Project audience (OpenSpec change project-audience): `canopy audience
|
|
9
|
+
* show|set|draft|ready`. Who a project is for and whether it's still a draft
|
|
10
|
+
* are labels on the dashboard's project list, stored on the platform (never
|
|
11
|
+
* in canopy.json) and set through the project update route.
|
|
12
|
+
*/
|
|
13
|
+
const KINDS = [
|
|
14
|
+
"everyone",
|
|
15
|
+
"personal",
|
|
16
|
+
"client",
|
|
17
|
+
"department"
|
|
18
|
+
];
|
|
19
|
+
const NAME_MAX = 40;
|
|
20
|
+
/** `set <kind> [name]` → the update body, or a sentence saying what's wrong. */
|
|
21
|
+
function parseAudience(kind, name) {
|
|
22
|
+
const k = kind.trim().toLowerCase();
|
|
23
|
+
if (!KINDS.includes(k)) return `"${kind}" is not an audience. Use everyone, personal, client <name> or department <name>.`;
|
|
24
|
+
if (k === "client" || k === "department") {
|
|
25
|
+
const n = name?.trim() ?? "";
|
|
26
|
+
if (!n) return `Name the ${k}: canopy audience set ${k} "<name>"`;
|
|
27
|
+
if (n.length > NAME_MAX) return `Keep the ${k} name to ${NAME_MAX} characters.`;
|
|
28
|
+
return {
|
|
29
|
+
kind: k,
|
|
30
|
+
name: n
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (name?.trim()) return `${k === "everyone" ? "Everyone" : "Personal"} takes no name.`;
|
|
34
|
+
return { kind: k };
|
|
35
|
+
}
|
|
36
|
+
/** One line for people: who it's for, and whether it's a draft. */
|
|
37
|
+
function describeAudience(project) {
|
|
38
|
+
const a = project.audience ?? null;
|
|
39
|
+
const who = a === null ? "is for everyone" : a.kind === "personal" ? "is a personal project" : `is for the ${a.name} ${a.kind === "client" ? "client team" : "department"}`;
|
|
40
|
+
return `${project.slug} ${who}${project.draft ? ", and is still a draft" : ""}.`;
|
|
41
|
+
}
|
|
42
|
+
const FIXES = { invalid_audience: "Use everyone, personal, client <name> or department <name> (names up to 40 characters)." };
|
|
43
|
+
function update(slug, body) {
|
|
44
|
+
return withContext(apiRequest("PATCH", `/projects/${slug}`, body).then((r) => r.project), {
|
|
45
|
+
action: `update ${slug}`,
|
|
46
|
+
fixes: FIXES
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const audienceCommand = defineCommand({
|
|
50
|
+
meta: {
|
|
51
|
+
name: "audience",
|
|
52
|
+
description: "Who the project is for, and whether it's a draft (show, set, draft, ready)"
|
|
53
|
+
},
|
|
54
|
+
subCommands: {
|
|
55
|
+
show: defineCommand({
|
|
56
|
+
meta: {
|
|
57
|
+
name: "show",
|
|
58
|
+
description: "Show who the project is for and whether it's a draft"
|
|
59
|
+
},
|
|
60
|
+
args: { ...projectDirArgs },
|
|
61
|
+
run: reportErrors("audience show", async ({ args }) => {
|
|
62
|
+
const { slug } = resolveProject(args);
|
|
63
|
+
const { project } = await withContext(apiRequest("GET", `/projects/${slug}`), { action: `read ${slug}` });
|
|
64
|
+
console.log(describeAudience(project));
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
set: defineCommand({
|
|
68
|
+
meta: {
|
|
69
|
+
name: "set",
|
|
70
|
+
description: "Say who it's for: everyone, personal, client <name> or department <name>"
|
|
71
|
+
},
|
|
72
|
+
args: {
|
|
73
|
+
kind: {
|
|
74
|
+
type: "positional",
|
|
75
|
+
description: "everyone | personal | client | department",
|
|
76
|
+
required: true
|
|
77
|
+
},
|
|
78
|
+
name: {
|
|
79
|
+
type: "positional",
|
|
80
|
+
description: "The client team or department (client and department only)",
|
|
81
|
+
required: false
|
|
82
|
+
},
|
|
83
|
+
...projectFlagArgs
|
|
84
|
+
},
|
|
85
|
+
run: reportErrors("audience set", async ({ args }) => {
|
|
86
|
+
const audience = parseAudience(args.kind, args.name);
|
|
87
|
+
if (typeof audience === "string") {
|
|
88
|
+
console.error(audience);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
const { slug } = resolveProject({ project: args.project });
|
|
92
|
+
p.log.success(describeAudience(await update(slug, { audience })));
|
|
93
|
+
p.log.info("It's a label on the project list; who can open the project is unchanged.");
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
draft: defineCommand({
|
|
97
|
+
meta: {
|
|
98
|
+
name: "draft",
|
|
99
|
+
description: "Mark it as not ready yet (greyed out on the list)"
|
|
100
|
+
},
|
|
101
|
+
args: { ...projectDirArgs },
|
|
102
|
+
run: reportErrors("audience draft", async ({ args }) => {
|
|
103
|
+
const { slug } = resolveProject(args);
|
|
104
|
+
p.log.success(describeAudience(await update(slug, { draft: true })));
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
ready: defineCommand({
|
|
108
|
+
meta: {
|
|
109
|
+
name: "ready",
|
|
110
|
+
description: "Mark it as ready (no longer a draft)"
|
|
111
|
+
},
|
|
112
|
+
args: { ...projectDirArgs },
|
|
113
|
+
run: reportErrors("audience ready", async ({ args }) => {
|
|
114
|
+
const { slug } = resolveProject(args);
|
|
115
|
+
p.log.success(describeAudience(await update(slug, { draft: false })));
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
//#endregion
|
|
121
|
+
export { audienceCommand };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { c as projectDirArgs, d as resolveProject } from "./site-BL5Ik-yj.mjs";
|
|
2
|
+
import { a as apiRequest, m as withContext } from "./api-DmJrIsE7.mjs";
|
|
3
|
+
import { r as reportErrors, t as formatDateTime } from "./ui-26ETk1n8.mjs";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
//#region src/calls.ts
|
|
6
|
+
/**
|
|
7
|
+
* canopy calls — which other projects may call this project's backend
|
|
8
|
+
* (OpenSpec project-calls). A granted project's backend reaches this one's
|
|
9
|
+
* `/api` with `canopy.projects.fetch`, for every visitor and scheduled run it
|
|
10
|
+
* has; this project's own code then sees it as `env.CALLER.kind === "project"`
|
|
11
|
+
* and decides what it may do. Only the owner (or a platform admin) changes the
|
|
12
|
+
* list; owners, managers and editors can read it.
|
|
13
|
+
*/
|
|
14
|
+
const FIXES = {
|
|
15
|
+
owner_only: "Only the project owner can decide which projects may call its backend — ask them to run this command or change it in the dashboard.",
|
|
16
|
+
unknown_project: "No project with that slug on this site (see `canopy projects`).",
|
|
17
|
+
invalid_caller: "A project can always call itself; it needs no grant."
|
|
18
|
+
};
|
|
19
|
+
function printGrants(grants, slug) {
|
|
20
|
+
if (grants.length === 0) {
|
|
21
|
+
console.log(`No other project may call ${slug}'s backend.`);
|
|
22
|
+
console.log("Allow one with `canopy calls allow <project>`.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log(`Projects that may call ${slug}'s backend:`);
|
|
26
|
+
for (const g of grants) {
|
|
27
|
+
const owner = g.owner ? `, owned by ${g.owner.name || g.owner.email}` : "";
|
|
28
|
+
const by = g.created_by ? ` by ${g.created_by.name}` : "";
|
|
29
|
+
console.log(` ${g.caller} (${g.name}${owner}) — allowed${by} ${formatDateTime(g.created_at)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const callsCommand = defineCommand({
|
|
33
|
+
meta: {
|
|
34
|
+
name: "calls",
|
|
35
|
+
description: "Manage which other projects may call this project's backend"
|
|
36
|
+
},
|
|
37
|
+
subCommands: {
|
|
38
|
+
list: defineCommand({
|
|
39
|
+
meta: {
|
|
40
|
+
name: "list",
|
|
41
|
+
description: "List the projects allowed to call this backend"
|
|
42
|
+
},
|
|
43
|
+
args: { ...projectDirArgs },
|
|
44
|
+
run: reportErrors("calls list", async ({ args }) => {
|
|
45
|
+
const { slug } = resolveProject(args);
|
|
46
|
+
const { grants } = await apiRequest("GET", `/projects/${slug}/calls`);
|
|
47
|
+
printGrants(grants, slug);
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
allow: defineCommand({
|
|
51
|
+
meta: {
|
|
52
|
+
name: "allow",
|
|
53
|
+
description: "Let another project's backend call this project's /api (owner only)"
|
|
54
|
+
},
|
|
55
|
+
args: {
|
|
56
|
+
caller: {
|
|
57
|
+
type: "positional",
|
|
58
|
+
description: "The calling project's slug",
|
|
59
|
+
required: true
|
|
60
|
+
},
|
|
61
|
+
...projectDirArgs
|
|
62
|
+
},
|
|
63
|
+
run: reportErrors("calls allow", async ({ args }) => {
|
|
64
|
+
const { slug } = resolveProject(args);
|
|
65
|
+
const { caller } = await withContext(apiRequest("PUT", `/projects/${slug}/calls/${encodeURIComponent(args.caller)}`), {
|
|
66
|
+
action: `allow ${args.caller} to call ${slug}`,
|
|
67
|
+
fixes: FIXES
|
|
68
|
+
});
|
|
69
|
+
console.log(`${caller} may now call ${slug}'s backend, for any of its visitors and schedules.`);
|
|
70
|
+
console.log(`Your code sees those calls as env.CALLER.kind === "project" and decides what each may do.`);
|
|
71
|
+
})
|
|
72
|
+
}),
|
|
73
|
+
remove: defineCommand({
|
|
74
|
+
meta: {
|
|
75
|
+
name: "remove",
|
|
76
|
+
description: "Stop another project from calling this backend (owner only)"
|
|
77
|
+
},
|
|
78
|
+
args: {
|
|
79
|
+
caller: {
|
|
80
|
+
type: "positional",
|
|
81
|
+
description: "The calling project's slug",
|
|
82
|
+
required: true
|
|
83
|
+
},
|
|
84
|
+
...projectDirArgs
|
|
85
|
+
},
|
|
86
|
+
run: reportErrors("calls remove", async ({ args }) => {
|
|
87
|
+
const { slug } = resolveProject(args);
|
|
88
|
+
const { caller } = await withContext(apiRequest("DELETE", `/projects/${slug}/calls/${encodeURIComponent(args.caller)}`), {
|
|
89
|
+
action: `stop ${args.caller} calling ${slug}`,
|
|
90
|
+
fixes: {
|
|
91
|
+
...FIXES,
|
|
92
|
+
not_found: `${args.caller} was not allowed to call ${slug}.`
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
console.log(`${caller} can no longer call ${slug}'s backend. A call already under way may finish within five minutes.`);
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//#endregion
|
|
101
|
+
export { callsCommand };
|
|
@@ -2,7 +2,7 @@ import { c as projectDirArgs, d as resolveProject, m as tryReadCanopyJson, r as
|
|
|
2
2
|
import { a as apiRequest, m as withContext, t as ApiError } from "./api-DmJrIsE7.mjs";
|
|
3
3
|
import { r as reportErrors, t as formatDateTime } from "./ui-26ETk1n8.mjs";
|
|
4
4
|
import { r as readMigrationFiles } from "./migrations-BReMlGWP.mjs";
|
|
5
|
-
import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-
|
|
5
|
+
import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER } from "./src-DzU89gZN.mjs";
|
|
6
6
|
import { a as parseAppRoleFlag } from "./roles-S2D9Id0W.mjs";
|
|
7
7
|
import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
@@ -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-BP-HGHYb.mjs");
|
|
111
111
|
const secrets = readDevVars(flags.dir);
|
|
112
112
|
const email = siteConfig().email;
|
|
113
113
|
const found = await remoteUser?.() ?? (email ? {
|
|
@@ -325,7 +325,7 @@ async function devRemote(flags, slug) {
|
|
|
325
325
|
async function devLocal(flags, slug) {
|
|
326
326
|
let dump;
|
|
327
327
|
if (flags.pull) {
|
|
328
|
-
const { fetchProjectDump } = await import("./local-
|
|
328
|
+
const { fetchProjectDump } = await import("./local-DRcoiNcy.mjs");
|
|
329
329
|
console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
|
|
330
330
|
dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
|
|
331
331
|
}
|
|
@@ -342,7 +342,7 @@ async function devLocal(flags, slug) {
|
|
|
342
342
|
}
|
|
343
343
|
const workerAttest = randomBytes(24).toString("base64url");
|
|
344
344
|
const devRoles = await resolveDevRoles(slug, flags.asRoles);
|
|
345
|
-
const { createSandbox } = await import("./local-
|
|
345
|
+
const { createSandbox } = await import("./local-DRcoiNcy.mjs");
|
|
346
346
|
const sandbox = await createSandbox({
|
|
347
347
|
slug,
|
|
348
348
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -385,7 +385,8 @@ async function devLocal(flags, slug) {
|
|
|
385
385
|
...remoteEntry && {
|
|
386
386
|
"/_api/data/v1/ai": remoteEntry,
|
|
387
387
|
"/_api/data/v1/services": remoteEntry,
|
|
388
|
-
"/_api/data/v1/google": remoteEntry
|
|
388
|
+
"/_api/data/v1/google": remoteEntry,
|
|
389
|
+
"/_api/data/v1/calls": remoteEntry
|
|
389
390
|
},
|
|
390
391
|
"/_api": {
|
|
391
392
|
target: `http://127.0.0.1:${apiAddress.port}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-
|
|
1
|
+
import { i as stampWorkerHeaders, n as WORKER_ATTEST_HEADER, r as redactCanopyCredentials, t as CALLER_HEADER } from "./src-DzU89gZN.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { relative, resolve, sep } from "node:path";
|
|
4
4
|
//#region src/dev-worker.ts
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Calling another project
|
|
3
|
+
description: Let one project's backend call another project's API, and tell who is calling.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Sometimes two projects belong together without being one project: an asset
|
|
7
|
+
library that several campaign sites read from, or a shared service that a few
|
|
8
|
+
tools use. One project's backend can call another project's API. The owner of
|
|
9
|
+
the project being called decides who may, and its code sees who did.
|
|
10
|
+
|
|
11
|
+
There are no keys or tokens to manage. Canopy proves who is calling on every
|
|
12
|
+
call.
|
|
13
|
+
|
|
14
|
+
## 1. Allow the calling project
|
|
15
|
+
|
|
16
|
+
In the project that will be called (say `asset-library`), its owner allows
|
|
17
|
+
the project that will call it:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
canopy calls allow campaign-site
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or use **Incoming calls** on the project's Backend tab. Only the owner can
|
|
24
|
+
change this list; managers and editors can see it.
|
|
25
|
+
|
|
26
|
+
One allow covers both channels of each project and every path under `/api`.
|
|
27
|
+
It also covers every visitor of the calling project and its scheduled runs,
|
|
28
|
+
so your backend decides what each caller may see (step 3).
|
|
29
|
+
|
|
30
|
+
A project can always call itself without being allowed.
|
|
31
|
+
|
|
32
|
+
## 2. Make the call
|
|
33
|
+
|
|
34
|
+
In the calling project's backend:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { createCanopy } from "@mediamonks/canopy";
|
|
38
|
+
|
|
39
|
+
const canopy = createCanopy({ fetch: env.CANOPY.fetch.bind(env.CANOPY) });
|
|
40
|
+
|
|
41
|
+
const res = await canopy.projects.fetch("asset-library", "/api/assets?tag=summer");
|
|
42
|
+
if (!res.ok) throw new Error(`asset-library said ${res.status}`);
|
|
43
|
+
const assets = await res.json();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`projects.fetch` works like `fetch`: pass a method, headers and a body as
|
|
47
|
+
usual. It calls the live channel unless you pass `{ channel: "staging" }`.
|
|
48
|
+
The other project needs no entry on your [outbound hosts](https://docs.canopy.website/platform/egress).
|
|
49
|
+
|
|
50
|
+
You get the other project's response back as it is. When Canopy refuses the
|
|
51
|
+
call, you get a JSON error instead:
|
|
52
|
+
|
|
53
|
+
| Error | What happened |
|
|
54
|
+
| --------------------- | ----------------------------------------------------------------- |
|
|
55
|
+
| `call_not_granted` | That project hasn't allowed yours, or there is no such project. |
|
|
56
|
+
| `invalid_call_path` | The path isn't under `/api`. Calls never reach a project's pages. |
|
|
57
|
+
| `call_depth_exceeded` | Projects called each other more than four times in a row. |
|
|
58
|
+
| `no_backend` | That project has no backend on that channel. |
|
|
59
|
+
|
|
60
|
+
Calls only work from backend code, and from `canopy dev`, where they go to the
|
|
61
|
+
deployed project as your project.
|
|
62
|
+
|
|
63
|
+
## 3. See who called
|
|
64
|
+
|
|
65
|
+
In the project being called, `env.CALLER` tells you a call came from another
|
|
66
|
+
project:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import type { CanopyCaller, CanopyProjectCaller } from "@mediamonks/canopy";
|
|
70
|
+
|
|
71
|
+
app.get("/api/assets", (c) => {
|
|
72
|
+
const caller = c.env.CALLER as CanopyCaller | CanopyProjectCaller | null;
|
|
73
|
+
if (caller?.kind === "project") {
|
|
74
|
+
// caller.project: "campaign-site", caller.channel: "live"
|
|
75
|
+
// caller.actingFor: the visitor behind the call, or null for a scheduled run
|
|
76
|
+
}
|
|
77
|
+
// …
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- `project` and `name` are the calling project; `channel` is which of its
|
|
82
|
+
channels called.
|
|
83
|
+
- `actingFor` is the person whose visit caused the call, with their
|
|
84
|
+
[app roles](https://docs.canopy.website/guides/roles) on _your_ project. They don't need to be a member
|
|
85
|
+
of it. It is `null` when nobody was behind the call, such as a scheduled run.
|
|
86
|
+
- `env.USER` is `null` on these calls, and your backend's own `canopy.db` and
|
|
87
|
+
other calls act as your project.
|
|
88
|
+
|
|
89
|
+
If your project calls another one while handling a call, that next project
|
|
90
|
+
sees your project, acting for nobody.
|
|
91
|
+
|
|
92
|
+
## Taking it back
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
canopy calls remove campaign-site
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
New calls are refused within a few seconds. A call that had already started
|
|
99
|
+
may still finish within five minutes.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: canopy audience
|
|
3
|
+
description: Say who a project is for and whether it's still a draft.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy audience` sets the labels people see on the dashboard's project list:
|
|
7
|
+
who the project was made for, and whether it's still a draft. They never
|
|
8
|
+
change who can open the project. Read
|
|
9
|
+
[Saying who it's for](https://docs.canopy.website/platform/members-and-access#saying-who-its-for).
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
canopy audience show
|
|
15
|
+
canopy audience set <everyone|personal>
|
|
16
|
+
canopy audience set <client|department> <name>
|
|
17
|
+
canopy audience draft
|
|
18
|
+
canopy audience ready
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Arguments & flags
|
|
22
|
+
|
|
23
|
+
Each subcommand works on the project in the current folder (`canopy.json`),
|
|
24
|
+
or the one you name with `--project <slug>`. All of them honour the global
|
|
25
|
+
`--profile <site>` / `CANOPY_PROFILE`. Owners, managers and editors can change
|
|
26
|
+
them.
|
|
27
|
+
|
|
28
|
+
- `show` — who the project is for, and whether it's a draft.
|
|
29
|
+
- `set <kind> [name]` — `everyone` (the default), `personal`, or `client` /
|
|
30
|
+
`department` with a name of up to 40 characters. Quote names with spaces.
|
|
31
|
+
- `draft` — mark it as not ready yet. It shows greyed out on the project list
|
|
32
|
+
but stays listed and usable.
|
|
33
|
+
- `ready` — it's no longer a draft.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
canopy audience set client "Uniqlo"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Marks the project as made for the Uniqlo client team.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
canopy audience draft --project retro-board
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Marks `retro-board` as a draft without being in its folder.
|
package/dist/docs/index.json
CHANGED
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
"title": "Roles and permissions",
|
|
58
58
|
"summary": "Give people different powers inside your app with app roles, and check them where it counts."
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
"slug": "calling-projects",
|
|
62
|
+
"title": "Calling another project",
|
|
63
|
+
"summary": "Let one project's backend call another project's API, and tell who is calling."
|
|
64
|
+
},
|
|
60
65
|
{
|
|
61
66
|
"slug": "data",
|
|
62
67
|
"title": "Working with project data",
|
|
@@ -246,6 +251,11 @@
|
|
|
246
251
|
"title": "canopy rename",
|
|
247
252
|
"summary": "Change a project's slug — its address — and update canopy.json."
|
|
248
253
|
},
|
|
254
|
+
{
|
|
255
|
+
"slug": "cli-audience",
|
|
256
|
+
"title": "canopy audience",
|
|
257
|
+
"summary": "Say who a project is for and whether it's still a draft."
|
|
258
|
+
},
|
|
249
259
|
{
|
|
250
260
|
"slug": "cli-dev",
|
|
251
261
|
"title": "canopy dev",
|
|
@@ -113,6 +113,26 @@ Turning it off again is the same toggle.
|
|
|
113
113
|
> **Note:** Members-only gates the **live app**. Management pages (settings, data, deploys) are always for the
|
|
114
114
|
> owner, managers and editors only, whatever this toggle says.
|
|
115
115
|
|
|
116
|
+
## Saying who it's for
|
|
117
|
+
|
|
118
|
+
Not every project is meant for everyone who scrolls past it. In **Settings →
|
|
119
|
+
Audience** you can say who it was made for:
|
|
120
|
+
|
|
121
|
+
- **Everyone**, the default. Nothing extra shows on the project list.
|
|
122
|
+
- **Just me**, for a personal tool or experiment.
|
|
123
|
+
- **A client team** or **a department**, with its name (up to 40 characters).
|
|
124
|
+
|
|
125
|
+
Other people see the audience as a small badge next to **Visit** on the
|
|
126
|
+
project list, and personal projects sort below the ones meant for everyone.
|
|
127
|
+
Every Monk can read the name, the same as the project's name and description.
|
|
128
|
+
|
|
129
|
+
Turn on **Still a draft** while it isn't ready. The project shows greyed out
|
|
130
|
+
and sorts lower, but it stays listed and anyone who could open it still can.
|
|
131
|
+
|
|
132
|
+
Both are labels only. They never change who can open the project; that's
|
|
133
|
+
what members-only and the client password are for. From the CLI, use
|
|
134
|
+
[`canopy audience`](https://docs.canopy.website/cli/audience).
|
|
135
|
+
|
|
116
136
|
## Platform admins and the Admin page
|
|
117
137
|
|
|
118
138
|
Platform admins get an extra **Admin** page in the dashboard. Its **Users**
|
package/dist/docs/sdk-auth.md
CHANGED
|
@@ -64,6 +64,10 @@ app.get("/api/me", (c) => {
|
|
|
64
64
|
run. `env.USER` is the Monk-only form: the signed-in Monk, or `null` for a
|
|
65
65
|
client-password visitor.
|
|
66
66
|
|
|
67
|
+
When another project's backend calls yours, `env.CALLER.kind` is `"project"`
|
|
68
|
+
and it names that project and the visitor it acts for. See
|
|
69
|
+
[Calling another project](https://docs.canopy.website/guides/calling-projects).
|
|
70
|
+
|
|
67
71
|
A client-password visitor has no email address and is named `"Client"`. Its
|
|
68
72
|
`id` changes with every password unlock, so don't key data on it that has to
|
|
69
73
|
last.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-Df9caKjj.mjs";
|
|
2
2
|
import { r as siteConfig } from "./site-BL5Ik-yj.mjs";
|
|
3
3
|
import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
|
|
4
4
|
import { n as agentHeaders } from "./api-DmJrIsE7.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-Df9caKjj.mjs";
|
|
2
2
|
import { c as projectDirArgs, d as resolveProject, h as tryResolveProject, m as tryReadCanopyJson, r as siteConfig } from "./site-BL5Ik-yj.mjs";
|
|
3
3
|
import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-DmJrIsE7.mjs";
|
|
4
4
|
import { r as reportErrors, t as formatDateTime } from "./ui-26ETk1n8.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-Df9caKjj.mjs";
|
|
3
3
|
import { i as siteHeaderLine, n as setInvocationProfile } from "./site-BL5Ik-yj.mjs";
|
|
4
4
|
import { a as notifyOfUpdate, o as runRefresh } from "./version-check-CcsA1QjI.mjs";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
|
@@ -71,7 +71,7 @@ const main = defineCommand({
|
|
|
71
71
|
projects: () => import("./projects-CnU3194_.mjs").then((m) => m.projectsCommand),
|
|
72
72
|
delete: () => import("./projects-CnU3194_.mjs").then((m) => m.deleteCommand),
|
|
73
73
|
rename: () => import("./rename-BWvERJgA.mjs").then((m) => m.renameCommand),
|
|
74
|
-
dev: () => import("./dev-
|
|
74
|
+
dev: () => import("./dev-z2KvqkF9.mjs").then((m) => m.devCommand),
|
|
75
75
|
deploy: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.deployCommand),
|
|
76
76
|
promote: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.promoteCommand),
|
|
77
77
|
staging: () => import("./staging-Dn8kH9cK.mjs").then((m) => m.stagingCommand),
|
|
@@ -79,23 +79,25 @@ const main = defineCommand({
|
|
|
79
79
|
download: () => import("./deploy-BnRQusjJ.mjs").then((m) => m.downloadCommand),
|
|
80
80
|
token: () => import("./token-DMCj88A-.mjs").then((m) => m.tokenCommand),
|
|
81
81
|
egress: () => import("./egress-BM4EpLBh.mjs").then((m) => m.egressCommand),
|
|
82
|
+
calls: () => import("./calls-DhkVJ32C.mjs").then((m) => m.callsCommand),
|
|
82
83
|
secrets: () => import("./secrets-BIn2RPoe.mjs").then((m) => m.secretsCommand),
|
|
83
84
|
roles: () => import("./roles-CrYf_8wk.mjs").then((m) => m.rolesCommand),
|
|
84
85
|
members: () => import("./roles-CrYf_8wk.mjs").then((m) => m.membersCommand),
|
|
85
86
|
schedule: () => import("./schedule-DvHSSzfR.mjs").then((m) => m.scheduleCommand),
|
|
86
|
-
feedback: () => import("./feedback-
|
|
87
|
+
feedback: () => import("./feedback-CAM-DJH9.mjs").then((m) => m.feedbackCommand),
|
|
87
88
|
db: () => import("./db-DpCMc0uz.mjs").then((m) => m.dbCommand),
|
|
88
89
|
usage: () => import("./usage-Bpz5B1N1.mjs").then((m) => m.usageCommand),
|
|
89
90
|
ai: () => import("./ai-CWPQiUft.mjs").then((m) => m.aiCommand),
|
|
90
91
|
open: () => import("./open-DcQSdfx5.mjs").then((m) => m.openCommand),
|
|
91
92
|
browse: () => import("./browse-BPLWhoFI.mjs").then((m) => m.browseCommand),
|
|
92
|
-
docs: () => import("./docs-
|
|
93
|
-
skill: () => import("./skill-
|
|
94
|
-
upgrade: () => import("./upgrade-
|
|
93
|
+
docs: () => import("./docs-BZquSJej.mjs").then((m) => m.docsCommand),
|
|
94
|
+
skill: () => import("./skill-BtL5ANQO.mjs").then((m) => m.skillCommand),
|
|
95
|
+
upgrade: () => import("./upgrade-DrEk3nqk.mjs").then((m) => m.upgradeCommand),
|
|
95
96
|
logs: () => import("./logs-dZMPTJLu.mjs").then((m) => m.logsCommand),
|
|
96
|
-
mcp: () => import("./mcp-
|
|
97
|
+
mcp: () => import("./mcp-q9wWZ2yk.mjs").then((m) => m.mcpCommand),
|
|
97
98
|
repo: () => import("./repo-C7AXDtFZ.mjs").then((m) => m.repoCommand),
|
|
98
|
-
template: () => import("./project-template-Dw11151p.mjs").then((m) => m.templateCommand)
|
|
99
|
+
template: () => import("./project-template-Dw11151p.mjs").then((m) => m.templateCommand),
|
|
100
|
+
audience: () => import("./audience-B68YZBGy.mjs").then((m) => m.audienceCommand)
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
const quiet = process.argv[2] === "mcp" && process.argv[3] === "serve" || process.argv[2] === "repo" && process.argv[3] === "credential";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as apiDataRequest } from "./api-DmJrIsE7.mjs";
|
|
2
|
-
import { a as realtimeRouter, c as META_COLUMNS, l as blobRouter, n as WORKER_ATTEST_HEADER, o as dbRouter, s as hasPrivateNames } from "./src-
|
|
3
|
-
import { a as rewriteApiPath } from "./dev-
|
|
2
|
+
import { a as realtimeRouter, c as META_COLUMNS, l as blobRouter, n as WORKER_ATTEST_HEADER, o as dbRouter, s as hasPrivateNames } from "./src-DzU89gZN.mjs";
|
|
3
|
+
import { a as rewriteApiPath } from "./dev-BE48xClT.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join, relative, sep } from "node:path";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-Df9caKjj.mjs";
|
|
2
2
|
import { h as tryResolveProject, p as stagingUrl, r as siteConfig, u as projectUrl } from "./site-BL5Ik-yj.mjs";
|
|
3
3
|
import { a as apiRequest, f as noticeRenamesOnly, l as currentSlug, t as ApiError } from "./api-DmJrIsE7.mjs";
|
|
4
4
|
import { t as liveDevServer } from "./dev-server-file-Dk9pk4AR.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-Df9caKjj.mjs";
|
|
2
2
|
import { r as reportErrors } from "./ui-26ETk1n8.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
@@ -835,23 +835,6 @@ function realtimeRouter(config) {
|
|
|
835
835
|
}
|
|
836
836
|
//#endregion
|
|
837
837
|
//#region ../data-plane/src/worker-request.ts
|
|
838
|
-
/**
|
|
839
|
-
* How a project's backend addresses the platform — the one definition.
|
|
840
|
-
*
|
|
841
|
-
* Three hosts run project workers and each builds this request itself: the
|
|
842
|
-
* Workers-for-Platforms shim (packages/data-plane/src/worker-shim.ts), the Node
|
|
843
|
-
* runtime (apps/project-runtime/src/canopy-fetch.ts), and `canopy dev`
|
|
844
|
-
* (packages/cli/src/dev-worker.ts). They had three copies of the header
|
|
845
|
-
* shaping, and the two that hold a worker token had two copies of the
|
|
846
|
-
* credential rule — which is exactly how the Google project grant came to
|
|
847
|
-
* work on one target and not the other.
|
|
848
|
-
*
|
|
849
|
-
* The shim cannot import this: it ships as a standalone module uploaded
|
|
850
|
-
* beside the user bundle, so it may only import `./bundle.mjs`. It keeps a
|
|
851
|
-
* transcription, and `wfp-shim.test.ts` runs it against the table in
|
|
852
|
-
* `worker-request.cases.ts` alongside this implementation, so the two cannot
|
|
853
|
-
* drift silently.
|
|
854
|
-
*/
|
|
855
838
|
/** Gateway-stamped identity, for the worker's own `env.USER` / `env.CALLER` — never relayed. */
|
|
856
839
|
const IDENTITY_STAMP_HEADERS = [
|
|
857
840
|
"x-canopy-user-sub",
|
|
@@ -861,7 +844,15 @@ const IDENTITY_STAMP_HEADERS = [
|
|
|
861
844
|
"x-canopy-identity-id",
|
|
862
845
|
"x-canopy-identity-email",
|
|
863
846
|
"x-canopy-identity-name",
|
|
864
|
-
"x-canopy-identity-roles"
|
|
847
|
+
"x-canopy-identity-roles",
|
|
848
|
+
"x-canopy-identity-project",
|
|
849
|
+
"x-canopy-identity-channel",
|
|
850
|
+
"x-canopy-acting-kind",
|
|
851
|
+
"x-canopy-acting-id",
|
|
852
|
+
"x-canopy-acting-email",
|
|
853
|
+
"x-canopy-acting-name",
|
|
854
|
+
"x-canopy-acting-agent",
|
|
855
|
+
"x-canopy-acting-roles"
|
|
865
856
|
];
|
|
866
857
|
/**
|
|
867
858
|
* Header carrying the project's worker token as runtime-origin proof (docs/35).
|
|
@@ -962,6 +953,14 @@ const IDENTITY_STAMP_HEADERS = [
|
|
|
962
953
|
"x-canopy-identity-email",
|
|
963
954
|
"x-canopy-identity-name",
|
|
964
955
|
"x-canopy-identity-roles",
|
|
956
|
+
"x-canopy-identity-project",
|
|
957
|
+
"x-canopy-identity-channel",
|
|
958
|
+
"x-canopy-acting-kind",
|
|
959
|
+
"x-canopy-acting-id",
|
|
960
|
+
"x-canopy-acting-email",
|
|
961
|
+
"x-canopy-acting-name",
|
|
962
|
+
"x-canopy-acting-agent",
|
|
963
|
+
"x-canopy-acting-roles",
|
|
965
964
|
];
|
|
966
965
|
|
|
967
966
|
// App roles (project-roles) — transcribed from rolesFromHeaders in
|
|
@@ -991,9 +990,45 @@ function userFromHeaders(headers) {
|
|
|
991
990
|
// env.CALLER (worker-caller-identity) — transcribed from
|
|
992
991
|
// project-runtime/src/user.ts: everyone the wall let through, client-password
|
|
993
992
|
// visitors included, from headers older shims never read.
|
|
993
|
+
// A call from another project (project-calls) — transcribed from
|
|
994
|
+
// projectCallerFromHeaders in project-runtime/src/user.ts.
|
|
995
|
+
function projectCallerFromHeaders(headers, id) {
|
|
996
|
+
const project = (headers.get("x-canopy-identity-project") || "").trim();
|
|
997
|
+
const channel = (headers.get("x-canopy-identity-channel") || "").trim();
|
|
998
|
+
if (!project || (channel !== "live" && channel !== "staging")) return null;
|
|
999
|
+
const actingKind = (headers.get("x-canopy-acting-kind") || "").trim();
|
|
1000
|
+
const actingId = (headers.get("x-canopy-acting-id") || "").trim();
|
|
1001
|
+
const actingFor =
|
|
1002
|
+
(actingKind === "monk" || actingKind === "external") && actingId
|
|
1003
|
+
? {
|
|
1004
|
+
kind: actingKind,
|
|
1005
|
+
id: actingId,
|
|
1006
|
+
email: (headers.get("x-canopy-acting-email") || "").trim(),
|
|
1007
|
+
name: (headers.get("x-canopy-acting-name") || "").trim(),
|
|
1008
|
+
agent: headers.get("x-canopy-acting-agent") === "1",
|
|
1009
|
+
roles: (headers.get("x-canopy-acting-roles") || "")
|
|
1010
|
+
.split(",")
|
|
1011
|
+
.map((r) => r.trim())
|
|
1012
|
+
.filter(Boolean),
|
|
1013
|
+
}
|
|
1014
|
+
: null;
|
|
1015
|
+
return {
|
|
1016
|
+
kind: "project",
|
|
1017
|
+
id,
|
|
1018
|
+
project,
|
|
1019
|
+
channel,
|
|
1020
|
+
name: (headers.get("x-canopy-identity-name") || "").trim() || project,
|
|
1021
|
+
email: "",
|
|
1022
|
+
agent: false,
|
|
1023
|
+
roles: [],
|
|
1024
|
+
actingFor,
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
|
|
994
1028
|
function callerFromHeaders(headers) {
|
|
995
1029
|
const kind = (headers.get("x-canopy-identity-kind") || "").trim();
|
|
996
1030
|
const id = (headers.get("x-canopy-identity-id") || "").trim();
|
|
1031
|
+
if (kind === "project" && id) return projectCallerFromHeaders(headers, id);
|
|
997
1032
|
if ((kind !== "monk" && kind !== "external") || !id) return null;
|
|
998
1033
|
const roles = rolesFromHeaders(headers);
|
|
999
1034
|
return {
|
|
@@ -1130,6 +1165,10 @@ function createCanopyFetch(apiUrl, inboundHeaders, upstream) {
|
|
|
1130
1165
|
const traceparent = inboundHeaders.get("traceparent");
|
|
1131
1166
|
if (traceparent) headers.set("traceparent", traceparent);
|
|
1132
1167
|
else headers.delete("traceparent");
|
|
1168
|
+
// Call depth (project-calls): from the request that woke the worker only.
|
|
1169
|
+
const callDepth = inboundHeaders.get("x-canopy-call-depth");
|
|
1170
|
+
if (callDepth) headers.set("x-canopy-call-depth", callDepth);
|
|
1171
|
+
else headers.delete("x-canopy-call-depth");
|
|
1133
1172
|
|
|
1134
1173
|
const method = (input instanceof Request ? input.method : init && init.method) || "GET";
|
|
1135
1174
|
const body = input instanceof Request ? input.body : init && init.body;
|
|
@@ -112,7 +112,7 @@ const upgradeCommand = defineCommand({
|
|
|
112
112
|
const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
|
|
113
113
|
const command = pmCommand(pm);
|
|
114
114
|
const cmd = installArgs(pm, spec);
|
|
115
|
-
const { skillInstalled } = await import("./skill-
|
|
115
|
+
const { skillInstalled } = await import("./skill-BtL5ANQO.mjs");
|
|
116
116
|
const { homedir } = await import("node:os");
|
|
117
117
|
const refreshGlobal = skillInstalled(homedir());
|
|
118
118
|
const refreshRepo = process.cwd() !== homedir() && skillInstalled(process.cwd());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediamonks/canopy-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.48",
|
|
4
4
|
"description": "Canopy CLI — create, develop and deploy Canopy projects.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"canopy": "./dist/index.mjs"
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"esbuild": "^0.28.1",
|
|
23
23
|
"hono": "^4.8.0",
|
|
24
24
|
"vite-server": "npm:vite@^7",
|
|
25
|
-
"@mediamonks/canopy": "0.0.
|
|
26
|
-
"@mediamonks/canopy
|
|
25
|
+
"@mediamonks/canopy-data-plane": "0.0.4",
|
|
26
|
+
"@mediamonks/canopy": "0.0.14"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.1",
|
package/dist/dev-BvVlq9np.mjs
DELETED