@mediamonks/canopy-cli 0.7.47 → 0.7.49
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/calls-DhkVJ32C.mjs +101 -0
- package/dist/{dev-BmKeIdMi.mjs → dev-BLjgtBpg.mjs} +7 -5
- package/dist/dev-BhfzaNja.mjs +2 -0
- package/dist/{dev-worker-CcYwQjxz.mjs → dev-worker-BP-HGHYb.mjs} +1 -1
- package/dist/docs/calling-projects.md +103 -0
- package/dist/docs/cli-calls.md +42 -0
- package/dist/docs/cli.md +6 -0
- package/dist/docs/index.json +22 -2
- package/dist/docs/platform-members-and-access.md +3 -1
- package/dist/docs/roles.md +4 -0
- package/dist/docs/sdk-auth.md +4 -0
- package/dist/docs/sdk-members.md +79 -0
- package/dist/docs/sdk-projects.md +76 -0
- package/dist/docs/sdk.md +4 -3
- package/dist/{docs-D5gmZRJk.mjs → docs-DjKdWQkK.mjs} +1 -1
- package/dist/{feedback-C6kiYRro.mjs → feedback-DYWJ-g39.mjs} +1 -1
- package/dist/index.mjs +8 -7
- package/dist/{local-C9Bi9f3y.mjs → local-zQRuHCl2.mjs} +2 -2
- package/dist/{mcp-DuCxfb85.mjs → mcp-ByQm8vmX.mjs} +1 -1
- package/dist/{package-BksVeJZB.mjs → package-JIon4dQ6.mjs} +1 -1
- package/dist/{skill-Bz39NhTN.mjs → skill-E31hpdtT.mjs} +1 -1
- package/dist/{src-8vxOBOxW.mjs → src-DzU89gZN.mjs} +57 -18
- package/dist/{upgrade-BjDaghNf.mjs → upgrade-iGfgX5fx.mjs} +1 -1
- package/package.json +2 -2
- package/dist/dev-BvVlq9np.mjs +0 -2
|
@@ -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-zQRuHCl2.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-zQRuHCl2.mjs");
|
|
346
346
|
const sandbox = await createSandbox({
|
|
347
347
|
slug,
|
|
348
348
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -385,7 +385,9 @@ 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,
|
|
390
|
+
"/_api/data/v1/members": remoteEntry
|
|
389
391
|
},
|
|
390
392
|
"/_api": {
|
|
391
393
|
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,103 @@
|
|
|
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. All the options are in
|
|
25
|
+
[`canopy calls`](https://docs.canopy.website/cli/calls).
|
|
26
|
+
|
|
27
|
+
One allow covers both channels of each project and every path under `/api`.
|
|
28
|
+
It also covers every visitor of the calling project and its scheduled runs,
|
|
29
|
+
so your backend decides what each caller may see (step 3).
|
|
30
|
+
|
|
31
|
+
A project can always call itself without being allowed.
|
|
32
|
+
|
|
33
|
+
## 2. Make the call
|
|
34
|
+
|
|
35
|
+
In the calling project's backend:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { createCanopy } from "@mediamonks/canopy";
|
|
39
|
+
|
|
40
|
+
const canopy = createCanopy({ fetch: env.CANOPY.fetch.bind(env.CANOPY) });
|
|
41
|
+
|
|
42
|
+
const res = await canopy.projects.fetch("asset-library", "/api/assets?tag=summer");
|
|
43
|
+
if (!res.ok) throw new Error(`asset-library said ${res.status}`);
|
|
44
|
+
const assets = await res.json();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
[`projects.fetch`](https://docs.canopy.website/sdk/projects) works like `fetch`: pass a method, headers
|
|
48
|
+
and a body as usual. It calls the live channel unless you pass `{ channel: "staging" }`.
|
|
49
|
+
The other project needs no entry on your [outbound hosts](https://docs.canopy.website/platform/egress).
|
|
50
|
+
|
|
51
|
+
You get the other project's response back as it is. When Canopy refuses the
|
|
52
|
+
call, you get a JSON error instead:
|
|
53
|
+
|
|
54
|
+
| Error | What happened |
|
|
55
|
+
| --------------------- | ----------------------------------------------------------------- |
|
|
56
|
+
| `call_not_granted` | That project hasn't allowed yours, or there is no such project. |
|
|
57
|
+
| `invalid_call_path` | The path isn't under `/api`. Calls never reach a project's pages. |
|
|
58
|
+
| `call_depth_exceeded` | Projects called each other more than four times in a row. |
|
|
59
|
+
| `no_backend` | That project has no backend on that channel. |
|
|
60
|
+
|
|
61
|
+
Calls only work from backend code, and from `canopy dev`, where they go to the
|
|
62
|
+
deployed project as your project.
|
|
63
|
+
|
|
64
|
+
## 3. See who called
|
|
65
|
+
|
|
66
|
+
In the project being called, `env.CALLER` tells you a call came from another
|
|
67
|
+
project:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import type { CanopyCaller, CanopyProjectCaller } from "@mediamonks/canopy";
|
|
71
|
+
|
|
72
|
+
app.get("/api/assets", (c) => {
|
|
73
|
+
const caller = c.env.CALLER as CanopyCaller | CanopyProjectCaller | null;
|
|
74
|
+
if (caller?.kind === "project") {
|
|
75
|
+
// caller.project: "campaign-site", caller.channel: "live"
|
|
76
|
+
// caller.actingFor: the visitor behind the call, or null for a scheduled run
|
|
77
|
+
}
|
|
78
|
+
// …
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- `project` and `name` are the calling project; `channel` is which of its
|
|
83
|
+
channels called.
|
|
84
|
+
- `actingFor` is the person whose visit caused the call, with their
|
|
85
|
+
[app roles](https://docs.canopy.website/guides/roles) on _your_ project. They don't need to be a member
|
|
86
|
+
of it. It is `null` when nobody was behind the call, such as a scheduled run.
|
|
87
|
+
- `env.USER` is `null` on these calls, and your backend's own `canopy.db` and
|
|
88
|
+
other calls act as your project. Every field is listed in
|
|
89
|
+
[Projects](https://docs.canopy.website/sdk/projects#on-the-other-side).
|
|
90
|
+
|
|
91
|
+
If your project calls another one while handling a call, that next project
|
|
92
|
+
sees your project, acting for nobody.
|
|
93
|
+
|
|
94
|
+
## Taking it back
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
canopy calls remove campaign-site
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Or remove it on the Backend tab. See [`canopy calls`](https://docs.canopy.website/cli/calls).
|
|
101
|
+
|
|
102
|
+
New calls are refused within a few seconds. A call that had already started
|
|
103
|
+
may still finish within five minutes.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: canopy calls
|
|
3
|
+
description: Manage which other projects may call this project's backend.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy calls` manages which other projects may call this project's `/api`
|
|
7
|
+
from their backend with [`canopy.projects.fetch`](https://docs.canopy.website/sdk/projects). See
|
|
8
|
+
[Calling another project](https://docs.canopy.website/guides/calling-projects) for the whole flow.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
canopy calls list
|
|
14
|
+
canopy calls allow campaign-site
|
|
15
|
+
canopy calls remove campaign-site
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Arguments & flags
|
|
19
|
+
|
|
20
|
+
All subcommands resolve the project the usual way — `canopy.json` in the
|
|
21
|
+
target directory, or `--project <slug>` to override — and honor the global
|
|
22
|
+
`--profile <site>` / `CANOPY_PROFILE`.
|
|
23
|
+
|
|
24
|
+
- `list` — the projects allowed to call this one, with their owner and who
|
|
25
|
+
allowed them when.
|
|
26
|
+
- `allow <project>` — let that project's backend call this one, by its slug.
|
|
27
|
+
Only the project owner (or a platform admin) can do this.
|
|
28
|
+
- `remove <project>` — stop it. New calls are refused within a few seconds; a
|
|
29
|
+
call already under way may finish within five minutes. Owner only, like
|
|
30
|
+
`allow`.
|
|
31
|
+
|
|
32
|
+
Owners, managers and editors can run `list`.
|
|
33
|
+
|
|
34
|
+
## How it works
|
|
35
|
+
|
|
36
|
+
One allow covers both channels of each project and every path under `/api`.
|
|
37
|
+
It also covers every visitor of the calling project and its scheduled runs,
|
|
38
|
+
so this project's backend decides what each caller may do: it sees them as
|
|
39
|
+
`env.CALLER.kind === "project"`, with the visitor behind the call in
|
|
40
|
+
`actingFor`. A project can always call itself without being allowed.
|
|
41
|
+
|
|
42
|
+
The same list is on the project's Backend tab, under **Incoming calls**.
|
package/dist/docs/cli.md
CHANGED
|
@@ -82,6 +82,12 @@ See `canopy docs ci` for wiring push-to-main deploys.
|
|
|
82
82
|
- `canopy egress allow <host>` — allow a hostname (or `"*.sub.wildcard"`).
|
|
83
83
|
- `canopy egress remove <host>` — remove an entry.
|
|
84
84
|
|
|
85
|
+
## Calls from other projects
|
|
86
|
+
|
|
87
|
+
- `canopy calls list` — projects allowed to call this project's backend.
|
|
88
|
+
- `canopy calls allow <project>` — let a project call it (owner only).
|
|
89
|
+
- `canopy calls remove <project>` — stop it (owner only).
|
|
90
|
+
|
|
85
91
|
## Maintenance
|
|
86
92
|
|
|
87
93
|
- `canopy upgrade` — update the CLI to the latest version. `--version <v>` pins a
|
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",
|
|
@@ -301,6 +306,11 @@
|
|
|
301
306
|
"title": "canopy egress",
|
|
302
307
|
"summary": "Manage which outbound hosts the project's backend worker may fetch."
|
|
303
308
|
},
|
|
309
|
+
{
|
|
310
|
+
"slug": "cli-calls",
|
|
311
|
+
"title": "canopy calls",
|
|
312
|
+
"summary": "Manage which other projects may call this project's backend."
|
|
313
|
+
},
|
|
304
314
|
{
|
|
305
315
|
"slug": "cli-secrets",
|
|
306
316
|
"title": "canopy secrets",
|
|
@@ -381,12 +391,12 @@
|
|
|
381
391
|
{
|
|
382
392
|
"key": "sdk",
|
|
383
393
|
"title": "SDK reference",
|
|
384
|
-
"description": "The typed client your project code uses — auth, data, files, AI, email, notify, realtime, services.",
|
|
394
|
+
"description": "The typed client your project code uses — auth, data, files, AI, email, notify, realtime, project calls, members, services.",
|
|
385
395
|
"topics": [
|
|
386
396
|
{
|
|
387
397
|
"slug": "sdk",
|
|
388
398
|
"title": "Using the SDK",
|
|
389
|
-
"summary": "One typed client for auth, data, files, AI, email, notify, realtime, and services — no keys, no connection strings, the platform authenticates for you."
|
|
399
|
+
"summary": "One typed client for auth, data, files, AI, email, notify, realtime, project calls, members, and services — no keys, no connection strings, the platform authenticates for you."
|
|
390
400
|
},
|
|
391
401
|
{
|
|
392
402
|
"slug": "sdk-auth",
|
|
@@ -423,6 +433,16 @@
|
|
|
423
433
|
"title": "Realtime",
|
|
424
434
|
"summary": "Live updates between the people using your app — subscribe to a topic, publish to it, no backend needed."
|
|
425
435
|
},
|
|
436
|
+
{
|
|
437
|
+
"slug": "sdk-projects",
|
|
438
|
+
"title": "Projects",
|
|
439
|
+
"summary": "Call another project's backend API from your backend, with no keys to manage."
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"slug": "sdk-members",
|
|
443
|
+
"title": "Members",
|
|
444
|
+
"summary": "List who is on your project, with their app roles, from your backend — including people who haven't opened the app yet."
|
|
445
|
+
},
|
|
426
446
|
{
|
|
427
447
|
"slug": "sdk-mcp",
|
|
428
448
|
"title": "Agent tools (MCP)",
|
|
@@ -81,7 +81,9 @@ App roles cover that without a table of emails in your code.
|
|
|
81
81
|
Under **Settings → Access → App roles**, create the roles your app needs. Each
|
|
82
82
|
has a name and a slug, like `approver`. Then give members their roles from the
|
|
83
83
|
Members card. Your app reads them as `roles` on the signed-in user, from
|
|
84
|
-
[`auth.user()`](https://docs.canopy.website/sdk/auth) or `env.CALLER` in a backend worker.
|
|
84
|
+
[`auth.user()`](https://docs.canopy.website/sdk/auth) or `env.CALLER` in a backend worker. To list
|
|
85
|
+
everyone on the project with their roles, your backend calls
|
|
86
|
+
[`members.list()`](https://docs.canopy.website/sdk/members).
|
|
85
87
|
|
|
86
88
|
One role is always the **default**. Everyone who can open the app has it,
|
|
87
89
|
client-password visitors included, so you don't have to hand it out. The first
|
package/dist/docs/roles.md
CHANGED
|
@@ -58,6 +58,10 @@ user.roles; // ["user", "approver"]
|
|
|
58
58
|
In a backend worker, `env.CALLER.roles` holds the same list without a round
|
|
59
59
|
trip, and so does `env.USER.roles` for a signed-in Monk.
|
|
60
60
|
|
|
61
|
+
To list everyone who has a role, including people who haven't opened the app
|
|
62
|
+
yet, call [`canopy.members.list({ appRole })`](https://docs.canopy.website/sdk/members) from your
|
|
63
|
+
backend.
|
|
64
|
+
|
|
61
65
|
## Check roles where it counts
|
|
62
66
|
|
|
63
67
|
A check that only runs in the browser hides buttons. It doesn't protect
|
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.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Members
|
|
3
|
+
description: List who is on your project, with their app roles, from your backend — including people who haven't opened the app yet.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy.members` gives your backend the project's roster: the owner, every
|
|
7
|
+
member, and everyone invited who hasn't signed in yet, each with their
|
|
8
|
+
[app roles](https://docs.canopy.website/guides/roles). Use it for a "People" page, a picker of
|
|
9
|
+
approvers, or a weekly email to everyone with the `qa` role.
|
|
10
|
+
|
|
11
|
+
Backend code only. A page that calls it straight from the browser is
|
|
12
|
+
refused, even for the owner. Your backend route decides what of the list to
|
|
13
|
+
send to whoever is asking.
|
|
14
|
+
|
|
15
|
+
## members.list(options?)
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createCanopy } from "@mediamonks/canopy";
|
|
19
|
+
|
|
20
|
+
const canopy = createCanopy({ fetch: env.CANOPY.fetch.bind(env.CANOPY) });
|
|
21
|
+
|
|
22
|
+
// Everyone on the project.
|
|
23
|
+
const people = await canopy.members.list();
|
|
24
|
+
|
|
25
|
+
// Only the people with the `qa` role, invites included.
|
|
26
|
+
const qa = await canopy.members.list({ appRole: "qa" });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Options:**
|
|
30
|
+
|
|
31
|
+
- `appRole` — optional. Only people whose roles include this slug. A slug
|
|
32
|
+
your project doesn't have gives an empty list.
|
|
33
|
+
|
|
34
|
+
**Returns** an array of `ProjectMember`, the owner first, then members by
|
|
35
|
+
name, then invites:
|
|
36
|
+
|
|
37
|
+
| Field | Meaning |
|
|
38
|
+
| ---------- | --------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `id` | Their Canopy user id, the same as `env.CALLER.id` on their requests. `null` for someone still invited. |
|
|
40
|
+
| `email` | The email they sign in with. |
|
|
41
|
+
| `name` | Their name. Empty for someone still invited. |
|
|
42
|
+
| `appRoles` | Their app roles: the project's default role first, then the ones given to them. The same as `env.CALLER.roles`. |
|
|
43
|
+
| `pending` | `true` for someone invited who hasn't signed in to Canopy yet. |
|
|
44
|
+
|
|
45
|
+
The list has no Canopy roles (owner, manager, editor, viewer). Those decide
|
|
46
|
+
who manages the project in Canopy; app roles are the ones your app uses.
|
|
47
|
+
|
|
48
|
+
## Link your own data to people
|
|
49
|
+
|
|
50
|
+
Store the `id`, not the email, next to your own data (a region, a team, a
|
|
51
|
+
desk). It's what `env.CALLER.id` gives you when that person makes a
|
|
52
|
+
request, so you can find their row without a lookup.
|
|
53
|
+
|
|
54
|
+
Someone still invited has no id yet. Key their row by email until they sign
|
|
55
|
+
in; from then on their entry has an id, and you can switch that one row
|
|
56
|
+
over.
|
|
57
|
+
|
|
58
|
+
## A list to show, not a permission check
|
|
59
|
+
|
|
60
|
+
The list can be a few seconds behind: a role change, a new invite or a
|
|
61
|
+
removed member shows up within a few seconds. To decide what the person
|
|
62
|
+
making a request may do, check `env.CALLER.roles`, as in
|
|
63
|
+
[Check roles where it counts](https://docs.canopy.website/guides/roles#check-roles-where-it-counts).
|
|
64
|
+
|
|
65
|
+
## Errors
|
|
66
|
+
|
|
67
|
+
| Status | Error | What happened |
|
|
68
|
+
| ------ | -------------- | ---------------------------------------------------------------------------------------- |
|
|
69
|
+
| 403 | `backend_only` | The call came from a browser page, or from a credential that isn't your backend. |
|
|
70
|
+
| 403 | `members_only` | Your backend forwarded a request from someone who isn't on a collaborators-only project. |
|
|
71
|
+
|
|
72
|
+
## Good to know
|
|
73
|
+
|
|
74
|
+
- The live and staging channels list the same people: the roster belongs to
|
|
75
|
+
the project, not to a channel.
|
|
76
|
+
- In [`canopy dev`](https://docs.canopy.website/cli/dev) the list is your deployed project's real
|
|
77
|
+
roster. Nothing you do locally changes it.
|
|
78
|
+
- To change the roster, use the dashboard or
|
|
79
|
+
[`canopy members`](https://docs.canopy.website/cli/members).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Projects
|
|
3
|
+
description: Call another project's backend API from your backend, with no keys to manage.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy.projects` lets your project's backend call another project's `/api`.
|
|
7
|
+
The other project's owner allows yours first; after that, Canopy proves who
|
|
8
|
+
is calling on every call, so your code holds no key or token. The walkthrough
|
|
9
|
+
is in [Calling another project](https://docs.canopy.website/guides/calling-projects).
|
|
10
|
+
|
|
11
|
+
Backend code only: a call is made as your project, so it doesn't work from a
|
|
12
|
+
browser.
|
|
13
|
+
|
|
14
|
+
## projects.fetch(project, path, init?)
|
|
15
|
+
|
|
16
|
+
Works like `fetch`, aimed at another project:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { createCanopy } from "@mediamonks/canopy";
|
|
20
|
+
|
|
21
|
+
const canopy = createCanopy({ fetch: env.CANOPY.fetch.bind(env.CANOPY) });
|
|
22
|
+
|
|
23
|
+
const res = await canopy.projects.fetch("asset-library", "/api/assets?tag=summer");
|
|
24
|
+
if (!res.ok) throw new Error(`asset-library said ${res.status}`);
|
|
25
|
+
const assets = await res.json();
|
|
26
|
+
|
|
27
|
+
// Any method, headers and body; the staging channel when you need it.
|
|
28
|
+
await canopy.projects.fetch("asset-library", "/api/assets", {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: { "content-type": "application/json" },
|
|
31
|
+
body: JSON.stringify({ name: "hero.jpg" }),
|
|
32
|
+
channel: "staging",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Arguments:**
|
|
37
|
+
|
|
38
|
+
- `project` — the other project's slug.
|
|
39
|
+
- `path` — a path under its `/api`, with a query string if you need one.
|
|
40
|
+
Anything else is refused before it is sent.
|
|
41
|
+
- `init` — optional. The usual fetch options (`method`, `headers`, `body`, …)
|
|
42
|
+
plus `channel`: `"live"` (the default) or `"staging"`.
|
|
43
|
+
|
|
44
|
+
**Returns** a `Response`: the other project's answer as it is. It doesn't
|
|
45
|
+
throw on an error status, so check `res.ok` like any fetch.
|
|
46
|
+
|
|
47
|
+
When Canopy refuses the call, the response is a JSON error instead:
|
|
48
|
+
|
|
49
|
+
| Status | Error | What happened |
|
|
50
|
+
| ------ | --------------------- | --------------------------------------------------------------- |
|
|
51
|
+
| 400 | `invalid_call_path` | The path isn't under `/api`. |
|
|
52
|
+
| 403 | `call_not_granted` | That project hasn't allowed yours, or there is no such project. |
|
|
53
|
+
| 404 | `no_backend` | That project has no backend on that channel. |
|
|
54
|
+
| 508 | `call_depth_exceeded` | Projects called each other more than four times in a row. |
|
|
55
|
+
| 503 | `calls_unavailable` | This site can't make project calls. |
|
|
56
|
+
|
|
57
|
+
Calls don't go through your [outbound hosts](https://docs.canopy.website/platform/egress), so the other
|
|
58
|
+
project needs no entry there. In [`canopy dev`](https://docs.canopy.website/cli/dev) they go to the
|
|
59
|
+
deployed project, as your project.
|
|
60
|
+
|
|
61
|
+
## On the other side
|
|
62
|
+
|
|
63
|
+
The project you call sees the call in its backend as `env.CALLER`, typed
|
|
64
|
+
`CanopyProjectCaller`:
|
|
65
|
+
|
|
66
|
+
| Field | Meaning |
|
|
67
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `kind` | `"project"`. |
|
|
69
|
+
| `id` | The calling project's id. It stays the same if the project is renamed. |
|
|
70
|
+
| `project` | The calling project's current slug. |
|
|
71
|
+
| `channel` | Which of its channels called: `"live"` or `"staging"`. |
|
|
72
|
+
| `name` | The calling project's name. |
|
|
73
|
+
| `actingFor` | The visitor whose request caused the call, with their [app roles](https://docs.canopy.website/guides/roles) on the called project; `null` for a scheduled run. |
|
|
74
|
+
|
|
75
|
+
`env.USER` is `null` on these calls. See [Auth](https://docs.canopy.website/sdk/auth) for the other
|
|
76
|
+
kinds of caller.
|
package/dist/docs/sdk.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Using the SDK
|
|
3
|
-
description: One typed client for auth, data, files, AI, email, notify, realtime, and services — no keys, no connection strings, the platform authenticates for you.
|
|
3
|
+
description: One typed client for auth, data, files, AI, email, notify, realtime, project calls, members, and services — no keys, no connection strings, the platform authenticates for you.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
`@mediamonks/canopy` is a thin, typed client over the platform's project API.
|
|
7
7
|
One `createCanopy()` call gives you its modules — `auth`, `db`, `blob`, `ai`,
|
|
8
|
-
`email`, `notify`, `realtime`, `google`, `slack`, and `services` — and that is the entire surface. There are no API keys,
|
|
8
|
+
`email`, `notify`, `realtime`, `projects`, `members`, `google`, `slack`, and `services` — and that is the entire surface. There are no API keys,
|
|
9
9
|
connection strings, or environment variables to manage: every call rides the
|
|
10
10
|
session the platform already established before your code ran.
|
|
11
11
|
|
|
@@ -36,7 +36,8 @@ import { createCanopy } from "@mediamonks/canopy";
|
|
|
36
36
|
|
|
37
37
|
const canopy = createCanopy();
|
|
38
38
|
// canopy.auth, canopy.db, canopy.blob, canopy.ai, canopy.email, canopy.notify,
|
|
39
|
-
// canopy.realtime, canopy.
|
|
39
|
+
// canopy.realtime, canopy.projects, canopy.members, canopy.google, canopy.slack,
|
|
40
|
+
// canopy.services
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
| Option | Type | Default | What it does |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-JIon4dQ6.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-JIon4dQ6.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-JIon4dQ6.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-BhfzaNja.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,21 +79,22 @@ 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-DYWJ-g39.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-DjKdWQkK.mjs").then((m) => m.docsCommand),
|
|
94
|
+
skill: () => import("./skill-E31hpdtT.mjs").then((m) => m.skillCommand),
|
|
95
|
+
upgrade: () => import("./upgrade-iGfgX5fx.mjs").then((m) => m.upgradeCommand),
|
|
95
96
|
logs: () => import("./logs-dZMPTJLu.mjs").then((m) => m.logsCommand),
|
|
96
|
-
mcp: () => import("./mcp-
|
|
97
|
+
mcp: () => import("./mcp-ByQm8vmX.mjs").then((m) => m.mcpCommand),
|
|
97
98
|
repo: () => import("./repo-C7AXDtFZ.mjs").then((m) => m.repoCommand),
|
|
98
99
|
template: () => import("./project-template-Dw11151p.mjs").then((m) => m.templateCommand),
|
|
99
100
|
audience: () => import("./audience-B68YZBGy.mjs").then((m) => m.audienceCommand)
|
|
@@ -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-BLjgtBpg.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-JIon4dQ6.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-JIon4dQ6.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-E31hpdtT.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.49",
|
|
4
4
|
"description": "Canopy CLI — create, develop and deploy Canopy projects.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"canopy": "./dist/index.mjs"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"esbuild": "^0.28.1",
|
|
23
23
|
"hono": "^4.8.0",
|
|
24
24
|
"vite-server": "npm:vite@^7",
|
|
25
|
-
"@mediamonks/canopy": "0.0.
|
|
25
|
+
"@mediamonks/canopy": "0.0.15",
|
|
26
26
|
"@mediamonks/canopy-data-plane": "0.0.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
package/dist/dev-BvVlq9np.mjs
DELETED