@samebase/alchemy-convex 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -67
- package/lib/{IdentityHub-CDG7GXm6.js → IdentityBroker-BqA_2V3_.js} +113 -106
- package/lib/IdentityBroker-BqA_2V3_.js.map +1 -0
- package/lib/{IdentityHub.d.ts → IdentityBroker.d.ts} +35 -32
- package/lib/IdentityBroker.d.ts.map +1 -0
- package/lib/IdentityBroker.js +1 -0
- package/lib/cli.js +4 -2
- package/lib/cli.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/{IdentityHub.ts → IdentityBroker.ts} +197 -178
- package/src/Providers.ts +10 -4
- package/src/StackComment.ts +9 -2
- package/lib/IdentityHub-CDG7GXm6.js.map +0 -1
- package/lib/IdentityHub.d.ts.map +0 -1
- package/lib/IdentityHub.js +0 -1
|
@@ -8,20 +8,22 @@ import * as Provider from "alchemy/Provider";
|
|
|
8
8
|
import { Random } from "alchemy/Random";
|
|
9
9
|
import * as Output from "alchemy/Output";
|
|
10
10
|
import { State } from "alchemy/State";
|
|
11
|
-
//#region src/
|
|
11
|
+
//#region src/IdentityBroker.d.ts
|
|
12
|
+
/** The client ID and the client secret of a deployment without a broker client. */
|
|
13
|
+
export declare const DISABLED = "broker-disabled";
|
|
12
14
|
/**
|
|
13
15
|
* The app's default name: the stack's path below `owner/repo`, or `app` for a stack named after
|
|
14
16
|
* the repository. Undefined for a stack whose name is not `owner/repo` or `owner/repo/<path>`.
|
|
15
17
|
*/
|
|
16
18
|
export declare const defaultApp: (stackName: string) => string | undefined;
|
|
17
19
|
/**
|
|
18
|
-
* An identity
|
|
20
|
+
* An identity broker of @samebase/identity-broker, such as Samebase's public broker:
|
|
19
21
|
* `{ issuer: "https://id.samebase.com" }`.
|
|
20
22
|
*/
|
|
21
|
-
export interface
|
|
23
|
+
export interface BrokerEndpoint {
|
|
22
24
|
/**
|
|
23
|
-
* The
|
|
24
|
-
* a GitHub token whose audience is the issuer, so no other
|
|
25
|
+
* The broker's issuer, such as `https://auth.example.com`. The run asks at `<issuer>/register`,
|
|
26
|
+
* with a GitHub token whose audience is the issuer, so no other broker can use that token.
|
|
25
27
|
*/
|
|
26
28
|
readonly issuer: string;
|
|
27
29
|
}
|
|
@@ -32,18 +34,18 @@ interface CommonProps {
|
|
|
32
34
|
* repository. A changed name registers a new client under the new name.
|
|
33
35
|
*/
|
|
34
36
|
readonly app?: string;
|
|
35
|
-
/** The
|
|
36
|
-
readonly
|
|
37
|
+
/** The broker to register at. A changed broker registers a new client there; the old one stays. */
|
|
38
|
+
readonly broker: BrokerEndpoint;
|
|
37
39
|
/**
|
|
38
|
-
* The connectors the client signs in through, by their names on the
|
|
39
|
-
* `["google", "github"]`: at least one, each of `[a-z0-9-]{1,64}`. The
|
|
40
|
-
* not offer, or does not allow this repository, and the log then names the allowed ones. The
|
|
41
|
-
* is recorded on the client for good: a changed set registers a new client.
|
|
40
|
+
* The connectors the client signs in through, by their names on the broker, such as
|
|
41
|
+
* `["google", "github"]`: at least one, each of `[a-z0-9-]{1,64}`. The broker refuses a name it
|
|
42
|
+
* does not offer, or does not allow this repository, and the log then names the allowed ones. The
|
|
43
|
+
* set is recorded on the client for good: a changed set registers a new client.
|
|
42
44
|
*/
|
|
43
45
|
readonly connectors: readonly string[];
|
|
44
46
|
/**
|
|
45
47
|
* The return addresses of this deployment, one to eight, such as
|
|
46
|
-
* `[`${site.siteUrl}/auth/
|
|
48
|
+
* `[`${site.siteUrl}/auth/broker/callback`]`: each an https URL whose origin serves
|
|
47
49
|
* `/samebase-verification.json` with the numeric GitHub id of this repository,
|
|
48
50
|
* `{ "repository": "123" }`. They can come from a resource that this run creates. A development
|
|
49
51
|
* client can also have http on a loopback host, which needs no file. Every request of the client
|
|
@@ -51,21 +53,22 @@ interface CommonProps {
|
|
|
51
53
|
* client.
|
|
52
54
|
*/
|
|
53
55
|
readonly redirectUris: string[];
|
|
54
|
-
/** Recorded on the
|
|
56
|
+
/** Recorded on the broker's client, such as the commit. The broker records "unknown" without it. */
|
|
55
57
|
readonly softwareVersion?: string;
|
|
56
58
|
/**
|
|
57
|
-
* The run fails unless the
|
|
58
|
-
* does not answer a registration or a renewal, and when it suspended the client.
|
|
59
|
-
* a run gives the off values or keeps the saved client, so the app deploys
|
|
60
|
-
* sign-in is the product. A failed run saves nothing, so the next run asks
|
|
59
|
+
* The run fails unless the broker confirms the client in this run: it fails when the broker
|
|
60
|
+
* refuses or does not answer a registration or a renewal, and when it suspended the client.
|
|
61
|
+
* Without it, such a run gives the off values or keeps the saved client, so the app deploys
|
|
62
|
+
* anyway. Set it where sign-in is the product. A failed run saves nothing, so the next run asks
|
|
63
|
+
* the broker again.
|
|
61
64
|
*/
|
|
62
65
|
readonly required?: boolean;
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
68
|
* A production or preview client asks with the GitHub OIDC token of the run. A development client
|
|
66
|
-
* asks with the app's initial access token, which `
|
|
67
|
-
* A client of any type with `key` asks with that key, a key of a
|
|
68
|
-
* `
|
|
69
|
+
* asks with the app's initial access token, which `IdentityBroker.Client.read` gives from stage
|
|
70
|
+
* `prod`. A client of any type with `key` asks with that key, a key of a broker on the stack layer,
|
|
71
|
+
* such as `IdentityBroker.registrationKey` gives.
|
|
69
72
|
*/
|
|
70
73
|
export type ClientProps = (CommonProps & {
|
|
71
74
|
readonly deploymentType: "production" | "preview";
|
|
@@ -80,7 +83,7 @@ export type ClientProps = (CommonProps & {
|
|
|
80
83
|
readonly deploymentType: "production" | "preview" | "development";
|
|
81
84
|
/**
|
|
82
85
|
* The Bearer of `POST /register`. Undefined, as before the stage that makes the key ever
|
|
83
|
-
* ran: the client gets the off values, or the run fails when `required`. The
|
|
86
|
+
* ran: the client gets the off values, or the run fails when `required`. The broker decides
|
|
84
87
|
* whether this key may register a production client.
|
|
85
88
|
*/
|
|
86
89
|
readonly key: Redacted.Redacted<string> | undefined;
|
|
@@ -89,16 +92,16 @@ export type ClientProps = (CommonProps & {
|
|
|
89
92
|
declare const Attributes: Schema.Struct<{
|
|
90
93
|
/** `off`: no client, and the values below are the off values. */
|
|
91
94
|
readonly status: Schema.Literals<readonly ["on", "off", "suspended"]>;
|
|
92
|
-
/** The issuer of the
|
|
95
|
+
/** The issuer of the broker, which the deployment names to sign in. */
|
|
93
96
|
readonly issuer: Schema.String;
|
|
94
97
|
readonly clientId: Schema.String;
|
|
95
98
|
/** Returned only at registration. */
|
|
96
99
|
readonly clientSecret: Schema.Redacted<Schema.String>;
|
|
97
|
-
/** Returned only at registration. It reads and deletes this client on the
|
|
100
|
+
/** Returned only at registration. It reads and deletes this client on the broker, and nothing else. */
|
|
98
101
|
readonly registrationAccessToken: Schema.Redacted<Schema.String>;
|
|
99
102
|
readonly registrationClientUri: Schema.String;
|
|
100
103
|
readonly deploymentType: Schema.Literals<readonly ["production", "preview", "development"]>;
|
|
101
|
-
/** The app's name on the
|
|
104
|
+
/** The app's name on the broker, as sent. Empty for the off values. */
|
|
102
105
|
readonly app: Schema.String;
|
|
103
106
|
/** The return addresses the client serves, sorted, each once. Empty for the off values. */
|
|
104
107
|
readonly redirectUris: Schema.$Array<Schema.String>;
|
|
@@ -114,22 +117,22 @@ declare const Attributes: Schema.Struct<{
|
|
|
114
117
|
}>;
|
|
115
118
|
/**
|
|
116
119
|
* The attributes keep the real values of a suspended client, so that an unblock needs no new client.
|
|
117
|
-
* `
|
|
120
|
+
* `IdentityBroker.Client.variables` gives the values that the app gets.
|
|
118
121
|
*/
|
|
119
122
|
export interface ClientAttributes extends Schema.Schema.Type<typeof Attributes> {}
|
|
120
123
|
/**
|
|
121
|
-
* A key of a
|
|
122
|
-
* `
|
|
123
|
-
* can make several. In `options.stage`, the stage that deploys the
|
|
124
|
+
* A key of a broker on the stack layer, as a redacted Output, for the broker's secret binding and
|
|
125
|
+
* for `IdentityBroker.Client`'s `key`. `id` is the key's resource id, the author's name for it, so a
|
|
126
|
+
* stack can make several. In `options.stage`, the stage that deploys the broker, the key is an
|
|
124
127
|
* `Alchemy.Random` at the stack's root, made once and kept in state; the stack's providers need
|
|
125
128
|
* Random's provider (`Convex.providers()` and `Cloudflare.providers()` hold one). Every other stage
|
|
126
|
-
* reads that row from the state store, as `
|
|
127
|
-
* key; before the
|
|
129
|
+
* reads that row from the state store, as `IdentityBroker.Client.read` does, so it never creates the
|
|
130
|
+
* key; before the broker's stage ran, there is no row and no key (`undefined`).
|
|
128
131
|
*/
|
|
129
132
|
export declare const registrationKey: (id: string, options: {
|
|
130
133
|
readonly stage: string;
|
|
131
134
|
}) => Effect.Effect<Output.Output<Redacted.Redacted<string> | undefined, any>, never, Stack | Provider.Provider<Random>>;
|
|
132
|
-
export type Client = Resource<"
|
|
135
|
+
export type Client = Resource<"IdentityBroker.Client", ClientProps, ClientAttributes, never, Providers>;
|
|
133
136
|
export declare const Client: import("alchemy").ResourceClassWithMethods<Client, {
|
|
134
137
|
readonly read: (id: string, options: {
|
|
135
138
|
readonly stage: string;
|
|
@@ -156,4 +159,4 @@ export declare const Client: import("alchemy").ResourceClassWithMethods<Client,
|
|
|
156
159
|
export declare const ClientProvider: () => import("effect/Layer").Layer<Provider.Provider<Client>, never, Stack>;
|
|
157
160
|
//#endregion
|
|
158
161
|
export {};
|
|
159
|
-
//# sourceMappingURL=
|
|
162
|
+
//# sourceMappingURL=IdentityBroker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityBroker.d.ts","names":[],"sources":["../src/IdentityBroker.ts"],"mappings":";;;;;;;;;;;;qBAgEa;;;;;qBAiBA,aAAc;;;;;iBAYV;;;;;WAKN;;UAGD;;;;;;WAMC;;WAEA,QAAQ;;;;;;;WAOR;;;;;;;;;;WAUA;;WAEA;;;;;;;;WAQA;;;;;;;;YASC,eACP;WACU;WACA;WACA;MAEV;WACU;;WAEA,oBAAoB,SAAS;WAC7B;MAEV;WACU;;;;;;WAMA,KAAK,SAAS;WACd;;cAKT,YAAU,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BC,yBAAyB,OAAO,OAAO,YAAY;;;;;;;;;;qBAoevD,kBAAmB,YAAY;WAAoB;MAAe,OAAA,OAAA,OAAA,OAAA,SAAA,2CAAA,QAAA,SAAA,SAAA;YAkDnE,SAAS,kCAEnB,aACA,yBAEA;qBAEW,0BAAM,yBAAA;WAjGD,OAAA,YAAM;aAAsB;QAAe,OAAA;;;;;;;;;;;;;;WA2ElC,YAAA,QAAA,WAAM,OAAA;;;;;;qBA6BpB,6CAAc,MAAA,SAAA,SAAA,gBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as Client, n as ClientProvider, r as DISABLED, i as defaultApp, a as registrationKey } from "./IdentityBroker-BqA_2V3_.js";
|
package/lib/cli.js
CHANGED
|
@@ -88,8 +88,9 @@ const boxName = ({ name, resourceType, rows: [first] }) => {
|
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
A box of the tree: its name with the labels of its line as code, its type and schedule, and its link
|
|
91
|
-
on the next line unless the link is the stage address. Below it, in a list: the boxes that it uses,
|
|
92
|
-
|
|
91
|
+
on the next line unless the link is the stage address. Below it, in a list: the boxes that it uses,
|
|
92
|
+
its bindings that name no box, the rows folded into it, and the boxes that share a resource with it.
|
|
93
|
+
A repeated box has only its name.
|
|
93
94
|
*/
|
|
94
95
|
const treeNode = (node, address) => {
|
|
95
96
|
const { box, labels, repeated } = node;
|
|
@@ -98,6 +99,7 @@ const treeNode = (node, address) => {
|
|
|
98
99
|
const linkLine = box.link === null || box.link === address ? "" : `<br><sub>${link(box.link, hostOf(box.link))}</sub>`;
|
|
99
100
|
const below = [
|
|
100
101
|
...node.children.map((child) => treeNode(child, address)),
|
|
102
|
+
...box.bindings.filter((binding) => binding.box === null).map((binding) => `<code>${escapeHtml(binding.name)}</code> <sub>${escapeHtml([binding.kind, binding.target].filter((part) => part !== null).join(", "))}</sub>`),
|
|
101
103
|
...box.folded.map((row) => `<sub>${escapeHtml(`${row.logicalId}, ${resourceTypeUI(row.resourceType).name}`)}</sub>`),
|
|
102
104
|
...node.shared.map((text) => `<sub>${escapeHtml(text)}</sub>`)
|
|
103
105
|
];
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/StackComment.ts","../src/cli.ts"],"sourcesContent":["// The command `alchemy-convex stack-comment`: one comment on a pull request with the stacks of the\n// repository, read from the state store after the deploys.\n//\n// A stack sees only itself, so a comment that a stack declares cannot show the other stacks of the\n// repository. This command runs as a step after them and reads each stack of the repository that\n// has the stage `pr-<number>`: by the repository id of the stage's run record, or, for a stage\n// without a version 2 record, by the name `owner/name` or `owner/name/<folder>`. A stack without\n// that stage has no card. A run replaces the whole body, so the last run shows the newest state.\n//\n// The rows of a card are the boxes of `stageDiagram` from `@samebase/alchemy-kit/stack`, the model\n// of Samebase's stack diagram. Alchemy state holds secrets in clear text, and that model keeps no\n// secret of a row.\n//\n// GitHub keeps a fixed set of HTML in a comment and removes `style` and `class`, so every choice of\n// the markup is a fact about the sanitizer or the CSS of github.com:\n// - A table has `display: block` and `width: max-content`, so a `width` on it does nothing. The\n// spacer, a floated image one pixel high in a block of its own, gives every card one width, and\n// it shrinks on a narrow page.\n// - The CSS colors the even rows of a group, so each row has its own `tbody`.\n// - An HTML block ends at a blank line, so a table has none and is not indented.\n// - A bare image links to its raw file, and one link around an image and text underlines the space\n// between them, so the icon and the name are two links to one place.\n// - An image with `height` gets a gray background, so each icon is square and has only `width`.\n// - `align=\"middle\"` is `-webkit-baseline-middle` in Chrome, which is below the text.\n// `align=\"absmiddle\"` is the CSS value `middle`.\nimport { State } from \"alchemy/State\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport { RUN_RECORD_KEY, runRecord } from \"@samebase/alchemy-kit/run-record\";\nimport {\n boxSubtitle,\n stageDiagram,\n stageTree,\n type DiagramBox,\n type StageDiagram,\n type StageTreeNode,\n} from \"@samebase/alchemy-kit/stack\";\nimport { resourceTypeUI } from \"@samebase/alchemy-kit/ui\";\n\n/** The first text of the comment, which finds it again. */\nconst MARKER = \"<!-- samebase-stacks -->\";\n\n/** GitHub does not proxy this host, so a new icon needs no purge of its image cache. */\nconst ICONS =\n \"https://raw.githubusercontent.com/samebase/samebase/main/packages/alchemy-convex/assets/stack-comment\";\n\nconst GITHUB_API = \"https://api.github.com\";\n\n/** The fields of the run record that a card shows. */\nconst StageOutput = Schema.Struct({\n [RUN_RECORD_KEY]: Schema.Struct({\n headCommit: Schema.String,\n runUrl: Schema.NullOr(Schema.String),\n recordedAt: Schema.String,\n }),\n});\n\n/** The part of a stage output that says which repository deployed it. */\nconst RepositoryOfOutput = Schema.Struct({\n [RUN_RECORD_KEY]: Schema.Struct({\n version: Schema.Literal(2),\n repositoryId: Schema.String,\n stackFile: Schema.String,\n }),\n});\n\nexport interface StackCard {\n readonly name: string;\n /** The folder of the stack file in the repository, \"\" at the root. */\n readonly folder: string;\n readonly stage: string;\n readonly diagram: StageDiagram;\n readonly run: typeof StageOutput.Type | null;\n}\n\nexport class StackCommentError extends Schema.TaggedError<StackCommentError>()(\n \"StackCommentError\",\n { reason: Schema.String },\n) {\n override get message() {\n return `The stack comment cannot be updated: ${this.reason}`;\n }\n}\n\n/**\n * The cards of the stacks of the repository that have `stage`, in name order. A stage with a version\n * 2 record belongs to the repository of its `repositoryId`, under any stack name; any other stage\n * belongs to the stacks named `repository` or `repository/<folder>`.\n */\nexport const readStackCards = ({\n repository,\n repositoryId,\n stage,\n}: {\n repository: string;\n repositoryId: string;\n stage: string;\n}) =>\n Effect.gen(function* () {\n const state = yield* yield* State;\n const cards: StackCard[] = [];\n for (const name of yield* state.listStacks()) {\n if (!(yield* state.listStages(name)).includes(stage)) {\n continue;\n }\n const request = { stack: name, stage };\n const output = yield* state.getOutput(request);\n const underName = name === repository || name.startsWith(`${repository}/`);\n const record = Option.map(\n Schema.decodeUnknownOption(RepositoryOfOutput)(output),\n (decoded) => decoded[RUN_RECORD_KEY],\n );\n if (Option.isSome(record) ? record.value.repositoryId !== repositoryId : !underName) {\n continue;\n }\n const rows = yield* Effect.forEach(yield* state.list(request), (fqn) =>\n state.get({ ...request, fqn }).pipe(Effect.map((row) => ({ fqn, state: row }))),\n );\n cards.push({\n name,\n folder:\n underName || Option.isNone(record)\n ? name.slice(repository.length + 1)\n : record.value.stackFile.split(\"/\").slice(0, -1).join(\"/\"),\n stage,\n diagram: stageDiagram(rows),\n run: Schema.is(StageOutput)(output) ? output : null,\n });\n }\n return cards;\n });\n\nconst escapeHtml = (text: string) =>\n text\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\");\n\nconst link = (href: string, text: string) => `<a href=\"${escapeHtml(href)}\">${text}</a>`;\n\nconst hostOf = (url: string) => escapeHtml(new URL(url).host);\n\n/** The icon file of a resource type, in `ICONS`. A box of any other type has no icon. */\nconst ICON_FILES = new Map([\n [\"Convex.Deployment\", \"convex\"],\n [\"Cloudflare.Worker\", \"worker\"],\n [\"Cloudflare.R2.Bucket\", \"r2\"],\n]);\n\n/** The name of a box, as a link to its dashboard page when it has one. */\nconst boxName = ({ name, resourceType, rows: [first] }: DiagramBox) => {\n const icon = ICON_FILES.get(resourceType);\n const image =\n icon === undefined\n ? null\n : `<img src=\"${ICONS}/${icon}.svg\" width=\"16\" align=\"absmiddle\" alt=\"\">`;\n const text = escapeHtml(name);\n const href = first.dashboard?.href;\n if (href === undefined) {\n return image === null ? text : `${image} ${text}`;\n }\n return image === null ? link(href, text) : `${link(href, image)} ${link(href, text)}`;\n};\n\n/**\nA box of the tree: its name with the labels of its line as code, its type and schedule, and its link\non the next line unless the link is the stage address. Below it, in a list: the boxes that it uses, the rows folded into it, and\nthe boxes that share a resource with it. A repeated box has only its name.\n*/\nconst treeNode = (node: StageTreeNode, address: string | null): string => {\n const { box, labels, repeated } = node;\n const title = `${boxName(box)}${labels.map((label) => ` <code>${escapeHtml(label)}</code>`).join(\"\")}`;\n if (repeated) {\n return title;\n }\n const linkLine =\n box.link === null || box.link === address\n ? \"\"\n : `<br><sub>${link(box.link, hostOf(box.link))}</sub>`;\n const below = [\n ...node.children.map((child) => treeNode(child, address)),\n ...box.folded.map(\n (row) =>\n `<sub>${escapeHtml(`${row.logicalId}, ${resourceTypeUI(row.resourceType).name}`)}</sub>`,\n ),\n ...node.shared.map((text) => `<sub>${escapeHtml(text)}</sub>`),\n ];\n const list =\n below.length === 0 ? \"\" : `<ul>${below.map((item) => `<li>${item}</li>`).join(\"\")}</ul>`;\n return `${title} <sub>${escapeHtml(boxSubtitle(box))}</sub>${linkLine}${list}`;\n};\n\n/** Where a stage serves: its Convex app, else the first box with a link. */\nconst addressOf = ({ boxes }: StageDiagram) =>\n (boxes.find((box) => box.resourceType === \"Convex.Deployment\") ?? boxes.find((box) => box.link))\n ?.link ?? null;\n\nconst runLine = ({ run }: StackCard) => {\n if (run === null) {\n return \"\";\n }\n const { headCommit, recordedAt, runUrl } = run[RUN_RECORD_KEY];\n const commit = escapeHtml(headCommit.slice(0, 7));\n const time = `${recordedAt.slice(0, 16).replace(\"T\", \" \")} UTC`;\n return `<br><sub>${runUrl === null ? commit : link(runUrl, commit)} ${escapeHtml(time)}</sub>`;\n};\n\nconst SPACER = `<div><img src=\"${ICONS}/spacer.svg\" width=\"460\" align=\"left\" alt=\"\"></div>`;\n\n/** `alone`: the one card of the repository. A card at the root then has no folder, as on the repository page. */\nconst renderCard = (card: StackCard, alone: boolean) => {\n const { folder } = card;\n const heading = [\n folder === \"\" && alone ? \"\" : `<b>${escapeHtml(folder || \"/\")}</b> `,\n `<sub>${escapeHtml(card.stage)}</sub>`,\n ].join(\"\");\n const address = addressOf(card.diagram);\n const addressLine = address === null ? \"\" : `<br>${link(address, hostOf(address))}`;\n const rows = stageTree(card.diagram)\n .map((node) => `<tbody><tr><td>${treeNode(node, address)}</td></tr></tbody>`)\n .join(\"\\n\");\n return `<table>\n<tbody><tr><td>${SPACER}${heading}${addressLine}${runLine(card)}</td></tr></tbody>\n${rows}\n</table>`;\n};\n\nexport const renderStackComment = (cards: readonly StackCard[]) => `${MARKER}\n${cards.map((card) => renderCard(card, cards.length === 1)).join(\"\\n\\n\")}\n`;\n\nconst Comments = Schema.Array(Schema.Struct({ id: Schema.Number, body: Schema.String }));\nconst SavedComment = Schema.Struct({ html_url: Schema.String });\n\nconst github = (token: string, path: string, init: { method: string; body?: string }) =>\n Effect.tryPromise({\n try: async (): Promise<unknown> => {\n const response = await fetch(`${GITHUB_API}${path}`, {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n });\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n return await response.json();\n },\n catch: (error) =>\n new StackCommentError({\n reason: `GitHub ${init.method} ${path} failed (${error instanceof Error ? error.message : String(error)})`,\n }),\n });\n\nconst decode =\n <S extends Schema.Codec<unknown, unknown>>(schema: S, what: string) =>\n (value: unknown) =>\n Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.mapError(() => new StackCommentError({ reason: `GitHub gave a bad ${what}` })),\n );\n\nconst findComment = (token: string, path: string) =>\n Effect.gen(function* () {\n for (let page = 1; ; page += 1) {\n const comments = yield* github(token, `${path}?per_page=100&page=${page}`, {\n method: \"GET\",\n }).pipe(Effect.flatMap(decode(Comments, \"comment list\")));\n const comment = comments.find(({ body }) => body.startsWith(MARKER));\n if (comment !== undefined || comments.length < 100) {\n return comment;\n }\n }\n });\n\n/** Replaces the body of the comment of this command, or posts it on the first run, and gives its URL. */\nexport const saveStackComment = (args: {\n readonly token: string;\n readonly repository: string;\n readonly pullRequest: number;\n readonly body: string;\n}) =>\n Effect.gen(function* () {\n const { body, pullRequest, repository, token } = args;\n const comments = `/repos/${repository}/issues/${pullRequest}/comments`;\n const comment = yield* findComment(token, comments);\n const reply = yield* comment === undefined\n ? github(token, comments, { method: \"POST\", body: JSON.stringify({ body }) })\n : github(token, `/repos/${repository}/issues/comments/${comment.id}`, {\n method: \"PATCH\",\n body: JSON.stringify({ body }),\n });\n const saved = yield* decode(SavedComment, \"comment\")(reply);\n return saved.html_url;\n });\n\n/** The step of a workflow: the run record names the repository and the pull request of the run. */\nexport const updateStackComment = Effect.gen(function* () {\n const {\n pullRequest,\n repositoryId,\n repositoryName: repository,\n } = yield* runRecord({ cwd: process.cwd(), env: process.env });\n if (pullRequest === null) {\n return yield* new StackCommentError({ reason: \"this run has no pull request\" });\n }\n const token = process.env[\"GITHUB_TOKEN\"];\n if (token === undefined || token === \"\") {\n return yield* new StackCommentError({ reason: \"GITHUB_TOKEN is not set\" });\n }\n const cards = yield* readStackCards({ repository, repositoryId, stage: `pr-${pullRequest}` });\n return yield* saveStackComment({\n token,\n repository,\n pullRequest,\n body: renderStackComment(cards),\n });\n});\n","#!/usr/bin/env node\n// The command of the package:\n//\n// alchemy-convex stack-comment\n//\n// stack-comment runs as a step of a pull request workflow after the deploys, and keeps one comment\n// with the stacks of the repository: see src/StackComment.ts. It needs GITHUB_TOKEN, and reads the\n// store of the team of CONVEX_ACCESS_TOKEN or of the Convex CLI login.\nimport { parseArgs } from \"node:util\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { updateStackComment } from \"./StackComment.ts\";\nimport { state } from \"./State.ts\";\n\nconst { positionals } = parseArgs({ allowPositionals: true, options: {} });\nconst USAGE = `Usage:\n alchemy-convex stack-comment`;\n\nconst stackComment = updateStackComment.pipe(\n Effect.tap((url) => Effect.sync(() => console.log(url))),\n Effect.provide(state().pipe(Layer.provide(NodeServices.layer))),\n);\n\nif (positionals.join(\" \") !== \"stack-comment\") {\n console.error(USAGE);\n process.exit(1);\n}\n\nawait Effect.runPromise(stackComment).catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;AAyCA,MAAM,SAAS;;AAGf,MAAM,QACJ;AAEF,MAAM,aAAa;;AAGnB,MAAM,cAAc,OAAO,OAAO,GAC/B,iBAAiB,OAAO,OAAO;CAC9B,YAAY,OAAO;CACnB,QAAQ,OAAO,OAAO,OAAO,MAAM;CACnC,YAAY,OAAO;AACrB,CAAC,EACH,CAAC;;AAGD,MAAM,qBAAqB,OAAO,OAAO,GACtC,iBAAiB,OAAO,OAAO;CAC9B,SAAS,OAAO,QAAQ,CAAC;CACzB,cAAc,OAAO;CACrB,WAAW,OAAO;AACpB,CAAC,EACH,CAAC;AAWD,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAC5E,qBACA,EAAE,QAAQ,OAAO,OAAO,CAC1B,CAAC,CAAC;CACA,IAAa,UAAU;EACrB,OAAO,wCAAwC,KAAK;CACtD;AACF;;;;;;AAOA,MAAa,kBAAkB,EAC7B,YACA,cACA,YAMA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,OAAO;CAC5B,MAAM,QAAqB,CAAC;CAC5B,KAAK,MAAM,QAAQ,OAAO,MAAM,WAAW,GAAG;EAC5C,IAAI,EAAE,OAAO,MAAM,WAAW,IAAI,EAAA,CAAG,SAAS,KAAK,GACjD;EAEF,MAAM,UAAU;GAAE,OAAO;GAAM;EAAM;EACrC,MAAM,SAAS,OAAO,MAAM,UAAU,OAAO;EAC7C,MAAM,YAAY,SAAS,cAAc,KAAK,WAAW,GAAG,WAAW,EAAE;EACzE,MAAM,SAAS,OAAO,IACpB,OAAO,oBAAoB,kBAAkB,CAAC,CAAC,MAAM,IACpD,YAAY,QAAQ,eACvB;EACA,IAAI,OAAO,OAAO,MAAM,IAAI,OAAO,MAAM,iBAAiB,eAAe,CAAC,WACxE;EAEF,MAAM,OAAO,OAAO,OAAO,QA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qB,OAAO,IAAI,aAAa;CACxD,MAAM,EACJ,aACA,cACA,gBAAgB,eACd,OAAO,UAAU;EAAE,KAAK,QAAQ,IAAI;EAAG,KAAK,QAAQ;CAAI,CAAC;CAC7D,IAAI,gBAAgB,MAClB,OAAO,OAAO,IAAI,kBAAkB,EAAE,QAAQ,+BAA+B,CAAC;CAEhF,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,UAAU,KAAA,KAAa,UAAU,IACnC,OAAO,OAAO,IAAI,kBAAkB,EAAE,QAAQ,0BAA0B,CAAC;CAE3E,MAAM,QAAQ,OAAO,eAAe;EAAE;EAAY;EAAc,OAAO,MAAM;CAAc,CAAC;CAC5F,OAAO,OAAO,iBAAiB;EAC7B;EACA;EACA;EACA,MAAM,mBAAmB,KAAK;CAChC,CAAC;AACH,CAAC;;;AClTD,MAAM,EAAE,gBAAgB,UAAU;CAAE,kBAAkB;CAAM,SAAS,CAAC;AAAE,CAAC;AACzE,MAAM,QAAQ;;AAGd,MAAM,eAAe,mBAAmB,KACtC,OAAO,KAAK,QAAQ,OAAO,WAAW,QAAQ,IAAI,GAAG,CAAC,CAAC,GACvD,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,MAAM,QAAQ,aAAa,KAAK,CAAC,CAAC,CAChE;AAEA,IAAI,YAAY,KAAK,GAAG,MAAM,iBAAiB;CAC7C,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,OAAO,WAAW,YAAY,CAAC,CAAC,OAAO,UAAmB;CAC9D,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/StackComment.ts","../src/cli.ts"],"sourcesContent":["// The command `alchemy-convex stack-comment`: one comment on a pull request with the stacks of the\n// repository, read from the state store after the deploys.\n//\n// A stack sees only itself, so a comment that a stack declares cannot show the other stacks of the\n// repository. This command runs as a step after them and reads each stack of the repository that\n// has the stage `pr-<number>`: by the repository id of the stage's run record, or, for a stage\n// without a version 2 record, by the name `owner/name` or `owner/name/<folder>`. A stack without\n// that stage has no card. A run replaces the whole body, so the last run shows the newest state.\n//\n// The rows of a card are the boxes of `stageDiagram` from `@samebase/alchemy-kit/stack`, the model\n// of Samebase's stack diagram. Alchemy state holds secrets in clear text, and that model keeps no\n// secret of a row.\n//\n// GitHub keeps a fixed set of HTML in a comment and removes `style` and `class`, so every choice of\n// the markup is a fact about the sanitizer or the CSS of github.com:\n// - A table has `display: block` and `width: max-content`, so a `width` on it does nothing. The\n// spacer, a floated image one pixel high in a block of its own, gives every card one width, and\n// it shrinks on a narrow page.\n// - The CSS colors the even rows of a group, so each row has its own `tbody`.\n// - An HTML block ends at a blank line, so a table has none and is not indented.\n// - A bare image links to its raw file, and one link around an image and text underlines the space\n// between them, so the icon and the name are two links to one place.\n// - An image with `height` gets a gray background, so each icon is square and has only `width`.\n// - `align=\"middle\"` is `-webkit-baseline-middle` in Chrome, which is below the text.\n// `align=\"absmiddle\"` is the CSS value `middle`.\nimport { State } from \"alchemy/State\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport { RUN_RECORD_KEY, runRecord } from \"@samebase/alchemy-kit/run-record\";\nimport {\n boxSubtitle,\n stageDiagram,\n stageTree,\n type DiagramBox,\n type StageDiagram,\n type StageTreeNode,\n} from \"@samebase/alchemy-kit/stack\";\nimport { resourceTypeUI } from \"@samebase/alchemy-kit/ui\";\n\n/** The first text of the comment, which finds it again. */\nconst MARKER = \"<!-- samebase-stacks -->\";\n\n/** GitHub does not proxy this host, so a new icon needs no purge of its image cache. */\nconst ICONS =\n \"https://raw.githubusercontent.com/samebase/samebase/main/packages/alchemy-convex/assets/stack-comment\";\n\nconst GITHUB_API = \"https://api.github.com\";\n\n/** The fields of the run record that a card shows. */\nconst StageOutput = Schema.Struct({\n [RUN_RECORD_KEY]: Schema.Struct({\n headCommit: Schema.String,\n runUrl: Schema.NullOr(Schema.String),\n recordedAt: Schema.String,\n }),\n});\n\n/** The part of a stage output that says which repository deployed it. */\nconst RepositoryOfOutput = Schema.Struct({\n [RUN_RECORD_KEY]: Schema.Struct({\n version: Schema.Literal(2),\n repositoryId: Schema.String,\n stackFile: Schema.String,\n }),\n});\n\nexport interface StackCard {\n readonly name: string;\n /** The folder of the stack file in the repository, \"\" at the root. */\n readonly folder: string;\n readonly stage: string;\n readonly diagram: StageDiagram;\n readonly run: typeof StageOutput.Type | null;\n}\n\nexport class StackCommentError extends Schema.TaggedError<StackCommentError>()(\n \"StackCommentError\",\n { reason: Schema.String },\n) {\n override get message() {\n return `The stack comment cannot be updated: ${this.reason}`;\n }\n}\n\n/**\n * The cards of the stacks of the repository that have `stage`, in name order. A stage with a version\n * 2 record belongs to the repository of its `repositoryId`, under any stack name; any other stage\n * belongs to the stacks named `repository` or `repository/<folder>`.\n */\nexport const readStackCards = ({\n repository,\n repositoryId,\n stage,\n}: {\n repository: string;\n repositoryId: string;\n stage: string;\n}) =>\n Effect.gen(function* () {\n const state = yield* yield* State;\n const cards: StackCard[] = [];\n for (const name of yield* state.listStacks()) {\n if (!(yield* state.listStages(name)).includes(stage)) {\n continue;\n }\n const request = { stack: name, stage };\n const output = yield* state.getOutput(request);\n const underName = name === repository || name.startsWith(`${repository}/`);\n const record = Option.map(\n Schema.decodeUnknownOption(RepositoryOfOutput)(output),\n (decoded) => decoded[RUN_RECORD_KEY],\n );\n if (Option.isSome(record) ? record.value.repositoryId !== repositoryId : !underName) {\n continue;\n }\n const rows = yield* Effect.forEach(yield* state.list(request), (fqn) =>\n state.get({ ...request, fqn }).pipe(Effect.map((row) => ({ fqn, state: row }))),\n );\n cards.push({\n name,\n folder:\n underName || Option.isNone(record)\n ? name.slice(repository.length + 1)\n : record.value.stackFile.split(\"/\").slice(0, -1).join(\"/\"),\n stage,\n diagram: stageDiagram(rows),\n run: Schema.is(StageOutput)(output) ? output : null,\n });\n }\n return cards;\n });\n\nconst escapeHtml = (text: string) =>\n text\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\");\n\nconst link = (href: string, text: string) => `<a href=\"${escapeHtml(href)}\">${text}</a>`;\n\nconst hostOf = (url: string) => escapeHtml(new URL(url).host);\n\n/** The icon file of a resource type, in `ICONS`. A box of any other type has no icon. */\nconst ICON_FILES = new Map([\n [\"Convex.Deployment\", \"convex\"],\n [\"Cloudflare.Worker\", \"worker\"],\n [\"Cloudflare.R2.Bucket\", \"r2\"],\n]);\n\n/** The name of a box, as a link to its dashboard page when it has one. */\nconst boxName = ({ name, resourceType, rows: [first] }: DiagramBox) => {\n const icon = ICON_FILES.get(resourceType);\n const image =\n icon === undefined\n ? null\n : `<img src=\"${ICONS}/${icon}.svg\" width=\"16\" align=\"absmiddle\" alt=\"\">`;\n const text = escapeHtml(name);\n const href = first.dashboard?.href;\n if (href === undefined) {\n return image === null ? text : `${image} ${text}`;\n }\n return image === null ? link(href, text) : `${link(href, image)} ${link(href, text)}`;\n};\n\n/**\nA box of the tree: its name with the labels of its line as code, its type and schedule, and its link\non the next line unless the link is the stage address. Below it, in a list: the boxes that it uses,\nits bindings that name no box, the rows folded into it, and the boxes that share a resource with it.\nA repeated box has only its name.\n*/\nconst treeNode = (node: StageTreeNode, address: string | null): string => {\n const { box, labels, repeated } = node;\n const title = `${boxName(box)}${labels.map((label) => ` <code>${escapeHtml(label)}</code>`).join(\"\")}`;\n if (repeated) {\n return title;\n }\n const linkLine =\n box.link === null || box.link === address\n ? \"\"\n : `<br><sub>${link(box.link, hostOf(box.link))}</sub>`;\n const below = [\n ...node.children.map((child) => treeNode(child, address)),\n ...box.bindings\n .filter((binding) => binding.box === null)\n .map(\n (binding) =>\n `<code>${escapeHtml(binding.name)}</code> <sub>${escapeHtml([binding.kind, binding.target].filter((part) => part !== null).join(\", \"))}</sub>`,\n ),\n ...box.folded.map(\n (row) =>\n `<sub>${escapeHtml(`${row.logicalId}, ${resourceTypeUI(row.resourceType).name}`)}</sub>`,\n ),\n ...node.shared.map((text) => `<sub>${escapeHtml(text)}</sub>`),\n ];\n const list =\n below.length === 0 ? \"\" : `<ul>${below.map((item) => `<li>${item}</li>`).join(\"\")}</ul>`;\n return `${title} <sub>${escapeHtml(boxSubtitle(box))}</sub>${linkLine}${list}`;\n};\n\n/** Where a stage serves: its Convex app, else the first box with a link. */\nconst addressOf = ({ boxes }: StageDiagram) =>\n (boxes.find((box) => box.resourceType === \"Convex.Deployment\") ?? boxes.find((box) => box.link))\n ?.link ?? null;\n\nconst runLine = ({ run }: StackCard) => {\n if (run === null) {\n return \"\";\n }\n const { headCommit, recordedAt, runUrl } = run[RUN_RECORD_KEY];\n const commit = escapeHtml(headCommit.slice(0, 7));\n const time = `${recordedAt.slice(0, 16).replace(\"T\", \" \")} UTC`;\n return `<br><sub>${runUrl === null ? commit : link(runUrl, commit)} ${escapeHtml(time)}</sub>`;\n};\n\nconst SPACER = `<div><img src=\"${ICONS}/spacer.svg\" width=\"460\" align=\"left\" alt=\"\"></div>`;\n\n/** `alone`: the one card of the repository. A card at the root then has no folder, as on the repository page. */\nconst renderCard = (card: StackCard, alone: boolean) => {\n const { folder } = card;\n const heading = [\n folder === \"\" && alone ? \"\" : `<b>${escapeHtml(folder || \"/\")}</b> `,\n `<sub>${escapeHtml(card.stage)}</sub>`,\n ].join(\"\");\n const address = addressOf(card.diagram);\n const addressLine = address === null ? \"\" : `<br>${link(address, hostOf(address))}`;\n const rows = stageTree(card.diagram)\n .map((node) => `<tbody><tr><td>${treeNode(node, address)}</td></tr></tbody>`)\n .join(\"\\n\");\n return `<table>\n<tbody><tr><td>${SPACER}${heading}${addressLine}${runLine(card)}</td></tr></tbody>\n${rows}\n</table>`;\n};\n\nexport const renderStackComment = (cards: readonly StackCard[]) => `${MARKER}\n${cards.map((card) => renderCard(card, cards.length === 1)).join(\"\\n\\n\")}\n`;\n\nconst Comments = Schema.Array(Schema.Struct({ id: Schema.Number, body: Schema.String }));\nconst SavedComment = Schema.Struct({ html_url: Schema.String });\n\nconst github = (token: string, path: string, init: { method: string; body?: string }) =>\n Effect.tryPromise({\n try: async (): Promise<unknown> => {\n const response = await fetch(`${GITHUB_API}${path}`, {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n });\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n return await response.json();\n },\n catch: (error) =>\n new StackCommentError({\n reason: `GitHub ${init.method} ${path} failed (${error instanceof Error ? error.message : String(error)})`,\n }),\n });\n\nconst decode =\n <S extends Schema.Codec<unknown, unknown>>(schema: S, what: string) =>\n (value: unknown) =>\n Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.mapError(() => new StackCommentError({ reason: `GitHub gave a bad ${what}` })),\n );\n\nconst findComment = (token: string, path: string) =>\n Effect.gen(function* () {\n for (let page = 1; ; page += 1) {\n const comments = yield* github(token, `${path}?per_page=100&page=${page}`, {\n method: \"GET\",\n }).pipe(Effect.flatMap(decode(Comments, \"comment list\")));\n const comment = comments.find(({ body }) => body.startsWith(MARKER));\n if (comment !== undefined || comments.length < 100) {\n return comment;\n }\n }\n });\n\n/** Replaces the body of the comment of this command, or posts it on the first run, and gives its URL. */\nexport const saveStackComment = (args: {\n readonly token: string;\n readonly repository: string;\n readonly pullRequest: number;\n readonly body: string;\n}) =>\n Effect.gen(function* () {\n const { body, pullRequest, repository, token } = args;\n const comments = `/repos/${repository}/issues/${pullRequest}/comments`;\n const comment = yield* findComment(token, comments);\n const reply = yield* comment === undefined\n ? github(token, comments, { method: \"POST\", body: JSON.stringify({ body }) })\n : github(token, `/repos/${repository}/issues/comments/${comment.id}`, {\n method: \"PATCH\",\n body: JSON.stringify({ body }),\n });\n const saved = yield* decode(SavedComment, \"comment\")(reply);\n return saved.html_url;\n });\n\n/** The step of a workflow: the run record names the repository and the pull request of the run. */\nexport const updateStackComment = Effect.gen(function* () {\n const {\n pullRequest,\n repositoryId,\n repositoryName: repository,\n } = yield* runRecord({ cwd: process.cwd(), env: process.env });\n if (pullRequest === null) {\n return yield* new StackCommentError({ reason: \"this run has no pull request\" });\n }\n const token = process.env[\"GITHUB_TOKEN\"];\n if (token === undefined || token === \"\") {\n return yield* new StackCommentError({ reason: \"GITHUB_TOKEN is not set\" });\n }\n const cards = yield* readStackCards({ repository, repositoryId, stage: `pr-${pullRequest}` });\n return yield* saveStackComment({\n token,\n repository,\n pullRequest,\n body: renderStackComment(cards),\n });\n});\n","#!/usr/bin/env node\n// The command of the package:\n//\n// alchemy-convex stack-comment\n//\n// stack-comment runs as a step of a pull request workflow after the deploys, and keeps one comment\n// with the stacks of the repository: see src/StackComment.ts. It needs GITHUB_TOKEN, and reads the\n// store of the team of CONVEX_ACCESS_TOKEN or of the Convex CLI login.\nimport { parseArgs } from \"node:util\";\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { updateStackComment } from \"./StackComment.ts\";\nimport { state } from \"./State.ts\";\n\nconst { positionals } = parseArgs({ allowPositionals: true, options: {} });\nconst USAGE = `Usage:\n alchemy-convex stack-comment`;\n\nconst stackComment = updateStackComment.pipe(\n Effect.tap((url) => Effect.sync(() => console.log(url))),\n Effect.provide(state().pipe(Layer.provide(NodeServices.layer))),\n);\n\nif (positionals.join(\" \") !== \"stack-comment\") {\n console.error(USAGE);\n process.exit(1);\n}\n\nawait Effect.runPromise(stackComment).catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;AAyCA,MAAM,SAAS;;AAGf,MAAM,QACJ;AAEF,MAAM,aAAa;;AAGnB,MAAM,cAAc,OAAO,OAAO,GAC/B,iBAAiB,OAAO,OAA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AAa,qBAAqB,OAAO,IAAI,aAAa;CACxD,MAAM,EACJ,aACA,cACA,gBAAgB,eACd,OAAO,UAAU;EAAE,KAAK,QAAQ,IAAI;EAAG,KAAK,QAAQ;CAAI,CAAC;CAC7D,IAAI,gBAAgB,MAClB,OAAO,OAAO,IAAI,kBAAkB,EAAE,QAAQ,+BAA+B,CAAC;CAEhF,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,UAAU,KAAA,KAAa,UAAU,IACnC,OAAO,OAAO,IAAI,kBAAkB,EAAE,QAAQ,0BAA0B,CAAC;CAE3E,MAAM,QAAQ,OAAO,eAAe;EAAE;EAAY;EAAc,OAAO,MAAM;CAAc,CAAC;CAC5F,OAAO,OAAO,iBAAiB;EAC7B;EACA;EACA;EACA,MAAM,mBAAmB,KAAK;CAChC,CAAC;AACH,CAAC;;;ACzTD,MAAM,EAAE,gBAAgB,UAAU;CAAE,kBAAkB;CAAM,SAAS,CAAC;AAAE,CAAC;AACzE,MAAM,QAAQ;;AAGd,MAAM,eAAe,mBAAmB,KACtC,OAAO,KAAK,QAAQ,OAAO,WAAW,QAAQ,IAAI,GAAG,CAAC,CAAC,GACvD,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,MAAM,QAAQ,aAAa,KAAK,CAAC,CAAC,CAChE;AAEA,IAAI,YAAY,KAAK,GAAG,MAAM,iBAAiB;CAC7C,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,OAAO,WAAW,YAAY,CAAC,CAAC,OAAO,UAAmB;CAC9D,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as Credentials, C as parseDeployOutput, D as ManagementApiLive, E as ManagementApi, M as DEPLOY_KEY_ENV, N as fromConfig, O as readLocalDeployment, P as fromValues, S as VariablesOwnedBySomeoneElse, T as ConvexApiError, _ as CodePushFailed, a as Project, b as EnvironmentNeedsDeployKey, c as ProjectProvider, d as AmbiguousDeployment, f as Deployment, g as ProductionDeploymentNotFound, h as DeploymentResource, i as CreatedProjectNotFound, j as CredentialsError, k as ACCESS_TOKEN_ENV, l as ProjectTeamChange, m as DeploymentProvider, n as state, o as ProjectDeploymentChange, p as DeploymentIdentityChange, r as AmbiguousProject, s as ProjectNotFound, t as STORE_PROJECT_NAME, u as AbsoluteRootDir, v as ConvexAppNotFound, w as push, x as PushTargetMismatch, y as ConvexCliNotFound } from "./State-Bp7iSx8T.js";
|
|
2
|
-
import { n as ClientProvider, t as Client } from "./
|
|
2
|
+
import { n as ClientProvider, t as Client } from "./IdentityBroker-BqA_2V3_.js";
|
|
3
3
|
import { toPath } from "alchemy/FQN";
|
|
4
4
|
import { Stack } from "alchemy/Stack";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["IdentityHub.Client","IdentityHub.ClientProvider"],"sources":["../src/Component.ts","../src/LocalDeployment.ts","../src/Providers.ts"],"sourcesContent":["import { toPath } from \"alchemy/FQN\";\nimport type { NamespaceNode } from \"alchemy/Namespace\";\nimport { Stack } from \"alchemy/Stack\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport type { Deployment } from \"./Deployment.ts\";\n\n/** A component's resources occupy this namespace in the deployment's Alchemy stack and stage. */\nexport interface ComponentBinding {\n readonly type: \"component\";\n readonly path: string;\n readonly namespace: readonly string[];\n}\n\n/**\n * Associate a native namespace with an installed component. `component` is the\n * installed name from the app's `convex.config.ts`; a nested install joins the\n * names with slashes, such as `\"workspace/mail\"`. An undefined namespace\n * associates the stack root. This records display metadata; it does not install\n * the component, set its environment, or change removal policies.\n */\nexport const bindComponent = (options: {\n deployment: Deployment;\n component: string;\n namespace: NamespaceNode | undefined;\n}) =>\n Effect.gen(function* () {\n if (options.component === \"\") {\n return yield* Effect.die(new Error(\"The component name is empty.\"));\n }\n const namespace = toPath(options.namespace);\n const sid = `convex.component:${JSON.stringify(namespace)}`;\n const stack = yield* Stack;\n const previous = stack.bindings[options.deployment.FQN]?.find((binding) => binding.sid === sid);\n // Alchemy keeps the last binding with a given sid. Reject conflicting owners before that happens.\n if (previous !== undefined) {\n const existing = Schema.decodeUnknownSync(Schema.Struct({ path: Schema.String }))(\n previous.data,\n );\n if (existing.path !== options.component) {\n return yield* Effect.die(\n new Error(\n `Alchemy namespace ${JSON.stringify(namespace)} is already bound to ${existing.path}.`,\n ),\n );\n }\n return;\n }\n yield* options.deployment.bind(sid, {\n type: \"component\",\n path: options.component,\n namespace,\n });\n });\n","// Convex.LocalDeployment: the logged-in local deployment of one folder, which\n// `npx convex deployment create <team>:<project>:local --select` makes and `npx convex dev` runs on\n// this machine. Each folder, such as each git worktree, has its own, with its own data.\n//\n// The resource writes its `env` and nothing else. The running `convex dev` owns the backend and\n// pushes the functions, so the development stage runs after `convex dev` has started, and the\n// first push of a new local deployment takes the variables that the project's default variables\n// for development gave it. The resource reads the deployment from\n// `.convex/local/default/config.json`, where the Convex CLI keeps its name, ports, and admin key,\n// and writes with that admin key through the same call as for a cloud deployment.\n//\n// A destroy changes nothing: the folder's deployment and its variables stay with the folder.\nimport { Resource } from \"alchemy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport * as Effect from \"effect/Effect\";\nimport * as ChildProcessSpawner from \"effect/process/ChildProcessSpawner\";\nimport * as Schema from \"effect/Schema\";\nimport { readLocalDeployment } from \"./ManagementApi.ts\";\nimport type { Providers } from \"./Providers.ts\";\nimport { type EnvValue, push } from \"./Push.ts\";\n\n/** The folder has no logged-in local deployment. */\nexport class LocalDeploymentNotFound extends Schema.TaggedError<LocalDeploymentNotFound>()(\n \"LocalDeploymentNotFound\",\n { rootDir: Schema.String },\n) {\n override get message() {\n return `Convex.LocalDeployment: ${this.rootDir} has no logged-in local deployment. Run \\`npx convex deployment create <team>:<project>:local --select\\` there, then \\`npx convex dev\\`.`;\n }\n}\n\n/**\n * The folder's logged-in local deployment, read when the stack's program runs, so that a client\n * can take its `siteUrl`. Fails with `LocalDeploymentNotFound` when the folder has none.\n */\nconst of = (rootDir = \".\") => {\n const info = readLocalDeployment(rootDir);\n if (info === undefined) throw new LocalDeploymentNotFound({ rootDir });\n return { name: info.name, url: info.url, siteUrl: info.siteUrl };\n};\n\nexport interface LocalDeploymentProps {\n /** The folder of the Convex app, where `.convex/local/default` is. The working directory without it. */\n readonly rootDir?: string;\n /** The variables of the deployment. A name that leaves `env` is removed. */\n readonly env: Readonly<Record<string, EnvValue>>;\n}\n\nexport interface LocalDeploymentAttributes {\n readonly name: string;\n readonly url: string;\n readonly siteUrl: string;\n /** The names that this resource set, so a name that leaves `env` is removed. */\n readonly envNames: readonly string[];\n}\n\nexport type LocalDeployment = Resource<\n \"Convex.LocalDeployment\",\n LocalDeploymentProps,\n LocalDeploymentAttributes,\n never,\n Providers\n>;\nexport const LocalDeployment = Resource<LocalDeployment>(\"Convex.LocalDeployment\")({ of });\n\nexport const LocalDeploymentProvider = () =>\n Provider.effect(\n LocalDeployment,\n Effect.gen(function* () {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n return {\n // Always an update: the variables are read and only changed values are written.\n diff: ({ news }) =>\n Effect.succeed(isResolved(news) ? ({ action: \"update\" } as const) : undefined),\n\n read: ({ output }) => Effect.succeed(output),\n\n reconcile: Effect.fn(function* ({ news, output }) {\n const rootDir = news.rootDir ?? \".\";\n const info = readLocalDeployment(rootDir);\n if (info === undefined) return yield* new LocalDeploymentNotFound({ rootDir });\n // Without `source`, a push only sets the variables and removes the names that left `env`.\n yield* push(spawner, info.adminKey, {\n deployment: info.name,\n url: info.url,\n rootDir,\n source: undefined,\n env: news.env,\n previousEnvNames: output?.name === info.name ? output.envNames : [],\n adopt: true,\n previewName: undefined,\n });\n return {\n name: info.name,\n url: info.url,\n siteUrl: info.siteUrl,\n envNames: Object.keys(news.env).sort(),\n };\n }),\n\n delete: () => Effect.void,\n };\n }),\n );\n","// The provider collection users merge into a stack:\n// providers: Layer.mergeAll(Cloudflare.providers(), Convex.providers())\nimport * as Provider from \"alchemy/Provider\";\nimport { Random, RandomProvider } from \"alchemy/Random\";\nimport * as Layer from \"effect/Layer\";\nimport { type Credentials, fromConfig } from \"./Credentials.ts\";\nimport { DeploymentProvider, DeploymentResource } from \"./Deployment.ts\";\nimport * as IdentityHub from \"./IdentityHub.ts\";\nimport { LocalDeployment, LocalDeploymentProvider } from \"./LocalDeployment.ts\";\nimport { ManagementApiLive } from \"./ManagementApi.ts\";\nimport { Project, ProjectProvider } from \"./Project.ts\";\n\nexport class Providers extends Provider.ProviderCollection<Providers>()(\"Convex\") {}\n\n/**\n * The Convex resource providers. Pass a credentials layer to override the\n * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login, and\n * `CONVEX_DEPLOY_KEY`).\n */\nexport const providers = (credentials: Layer.Layer<Credentials> = fromConfig()) =>\n Layer.effect(\n Providers,\n // Random's provider serves `IdentityHub.registrationKey` in a stack with no other collection\n // that holds one; with Cloudflare's too, the first found serves it, and both are the same.\n Provider.collection([Project, DeploymentResource, LocalDeployment, IdentityHub.Client, Random]),\n ).pipe(\n Layer.provide(\n Layer.mergeAll(\n ProjectProvider(),\n DeploymentProvider(),\n LocalDeploymentProvider(),\n IdentityHub.ClientProvider(),\n RandomProvider(),\n ),\n ),\n Layer.provide(ManagementApiLive()),\n Layer.provide(credentials),\n Layer.orDie,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,iBAAiB,YAK5B,OAAO,IAAI,aAAa;CACtB,IAAI,QAAQ,cAAc,IACxB,OAAO,OAAO,OAAO,oBAAI,IAAI,MAAM,8BAA8B,CAAC;CAEpE,MAAM,YAAY,OAAO,QAAQ,SAAS;CAC1C,MAAM,MAAM,oBAAoB,KA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ChD,MAAM,UAAU,KAAK,WAAW;GAChC,MAAM,OAAO,oBAAoB,OAAO;GACxC,IAAI,SAAS,KAAA,GAAW,OAAO,OAAO,IAAI,wBAAwB,EAAE,QAAQ,CAAC;GAE7E,OAAO,KAAK,SAAS,KAAK,UAAU;IAClC,YAAY,KAAK;IACjB,KAAK,KAAK;IACV;IACA,QAAQ,KAAA;IACR,KAAK,KAAK;IACV,kBAAkB,QAAQ,SAAS,KAAK,OAAO,OAAO,WAAW,CAAC;IAClE,OAAO;IACP,aAAa,KAAA;GACf,CAAC;GACD,OAAO;IACL,MAAM,KAAK;IACX,KAAK,KAAK;IACV,SAAS,KAAK;IACd,UAAU,OAAO,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK;GACvC;EACF,CAAC;EAED,cAAc,OAAO;CACvB;AACF,CAAC,CACH;;;AC5FF,IAAa,YAAb,cAA+B,SAAS,mBAA8B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;;;;;;AAOnF,MAAa,aAAa,cAAwC,WAAW,MAC3E,MAAM,OACJ,WAGA,SAAS,WAAW;CAAC;CAAS;CAAoB;CAAiBA;CAAoB;AAAM,CAAC,CAChG,CAAC,CAAC,KACA,MAAM,QACJ,MAAM,SACJ,gBAAgB,GAChB,mBAAmB,GACnB,wBAAwB,GACxBC,eAA2B,GAC3B,eAAe,CACjB,CACF,GACA,MAAM,QAAQ,kBAAkB,CAAC,GACjC,MAAM,QAAQ,WAAW,GACzB,MAAM,KACR"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["IdentityBroker.Client","IdentityBroker.ClientProvider"],"sources":["../src/Component.ts","../src/LocalDeployment.ts","../src/Providers.ts"],"sourcesContent":["import { toPath } from \"alchemy/FQN\";\nimport type { NamespaceNode } from \"alchemy/Namespace\";\nimport { Stack } from \"alchemy/Stack\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport type { Deployment } from \"./Deployment.ts\";\n\n/** A component's resources occupy this namespace in the deployment's Alchemy stack and stage. */\nexport interface ComponentBinding {\n readonly type: \"component\";\n readonly path: string;\n readonly namespace: readonly string[];\n}\n\n/**\n * Associate a native namespace with an installed component. `component` is the\n * installed name from the app's `convex.config.ts`; a nested install joins the\n * names with slashes, such as `\"workspace/mail\"`. An undefined namespace\n * associates the stack root. This records display metadata; it does not install\n * the component, set its environment, or change removal policies.\n */\nexport const bindComponent = (options: {\n deployment: Deployment;\n component: string;\n namespace: NamespaceNode | undefined;\n}) =>\n Effect.gen(function* () {\n if (options.component === \"\") {\n return yield* Effect.die(new Error(\"The component name is empty.\"));\n }\n const namespace = toPath(options.namespace);\n const sid = `convex.component:${JSON.stringify(namespace)}`;\n const stack = yield* Stack;\n const previous = stack.bindings[options.deployment.FQN]?.find((binding) => binding.sid === sid);\n // Alchemy keeps the last binding with a given sid. Reject conflicting owners before that happens.\n if (previous !== undefined) {\n const existing = Schema.decodeUnknownSync(Schema.Struct({ path: Schema.String }))(\n previous.data,\n );\n if (existing.path !== options.component) {\n return yield* Effect.die(\n new Error(\n `Alchemy namespace ${JSON.stringify(namespace)} is already bound to ${existing.path}.`,\n ),\n );\n }\n return;\n }\n yield* options.deployment.bind(sid, {\n type: \"component\",\n path: options.component,\n namespace,\n });\n });\n","// Convex.LocalDeployment: the logged-in local deployment of one folder, which\n// `npx convex deployment create <team>:<project>:local --select` makes and `npx convex dev` runs on\n// this machine. Each folder, such as each git worktree, has its own, with its own data.\n//\n// The resource writes its `env` and nothing else. The running `convex dev` owns the backend and\n// pushes the functions, so the development stage runs after `convex dev` has started, and the\n// first push of a new local deployment takes the variables that the project's default variables\n// for development gave it. The resource reads the deployment from\n// `.convex/local/default/config.json`, where the Convex CLI keeps its name, ports, and admin key,\n// and writes with that admin key through the same call as for a cloud deployment.\n//\n// A destroy changes nothing: the folder's deployment and its variables stay with the folder.\nimport { Resource } from \"alchemy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport * as Effect from \"effect/Effect\";\nimport * as ChildProcessSpawner from \"effect/process/ChildProcessSpawner\";\nimport * as Schema from \"effect/Schema\";\nimport { readLocalDeployment } from \"./ManagementApi.ts\";\nimport type { Providers } from \"./Providers.ts\";\nimport { type EnvValue, push } from \"./Push.ts\";\n\n/** The folder has no logged-in local deployment. */\nexport class LocalDeploymentNotFound extends Schema.TaggedError<LocalDeploymentNotFound>()(\n \"LocalDeploymentNotFound\",\n { rootDir: Schema.String },\n) {\n override get message() {\n return `Convex.LocalDeployment: ${this.rootDir} has no logged-in local deployment. Run \\`npx convex deployment create <team>:<project>:local --select\\` there, then \\`npx convex dev\\`.`;\n }\n}\n\n/**\n * The folder's logged-in local deployment, read when the stack's program runs, so that a client\n * can take its `siteUrl`. Fails with `LocalDeploymentNotFound` when the folder has none.\n */\nconst of = (rootDir = \".\") => {\n const info = readLocalDeployment(rootDir);\n if (info === undefined) throw new LocalDeploymentNotFound({ rootDir });\n return { name: info.name, url: info.url, siteUrl: info.siteUrl };\n};\n\nexport interface LocalDeploymentProps {\n /** The folder of the Convex app, where `.convex/local/default` is. The working directory without it. */\n readonly rootDir?: string;\n /** The variables of the deployment. A name that leaves `env` is removed. */\n readonly env: Readonly<Record<string, EnvValue>>;\n}\n\nexport interface LocalDeploymentAttributes {\n readonly name: string;\n readonly url: string;\n readonly siteUrl: string;\n /** The names that this resource set, so a name that leaves `env` is removed. */\n readonly envNames: readonly string[];\n}\n\nexport type LocalDeployment = Resource<\n \"Convex.LocalDeployment\",\n LocalDeploymentProps,\n LocalDeploymentAttributes,\n never,\n Providers\n>;\nexport const LocalDeployment = Resource<LocalDeployment>(\"Convex.LocalDeployment\")({ of });\n\nexport const LocalDeploymentProvider = () =>\n Provider.effect(\n LocalDeployment,\n Effect.gen(function* () {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n return {\n // Always an update: the variables are read and only changed values are written.\n diff: ({ news }) =>\n Effect.succeed(isResolved(news) ? ({ action: \"update\" } as const) : undefined),\n\n read: ({ output }) => Effect.succeed(output),\n\n reconcile: Effect.fn(function* ({ news, output }) {\n const rootDir = news.rootDir ?? \".\";\n const info = readLocalDeployment(rootDir);\n if (info === undefined) return yield* new LocalDeploymentNotFound({ rootDir });\n // Without `source`, a push only sets the variables and removes the names that left `env`.\n yield* push(spawner, info.adminKey, {\n deployment: info.name,\n url: info.url,\n rootDir,\n source: undefined,\n env: news.env,\n previousEnvNames: output?.name === info.name ? output.envNames : [],\n adopt: true,\n previewName: undefined,\n });\n return {\n name: info.name,\n url: info.url,\n siteUrl: info.siteUrl,\n envNames: Object.keys(news.env).sort(),\n };\n }),\n\n delete: () => Effect.void,\n };\n }),\n );\n","// The provider collection users merge into a stack:\n// providers: Layer.mergeAll(Cloudflare.providers(), Convex.providers())\nimport * as Provider from \"alchemy/Provider\";\nimport { Random, RandomProvider } from \"alchemy/Random\";\nimport * as Layer from \"effect/Layer\";\nimport { type Credentials, fromConfig } from \"./Credentials.ts\";\nimport { DeploymentProvider, DeploymentResource } from \"./Deployment.ts\";\nimport * as IdentityBroker from \"./IdentityBroker.ts\";\nimport { LocalDeployment, LocalDeploymentProvider } from \"./LocalDeployment.ts\";\nimport { ManagementApiLive } from \"./ManagementApi.ts\";\nimport { Project, ProjectProvider } from \"./Project.ts\";\n\nexport class Providers extends Provider.ProviderCollection<Providers>()(\"Convex\") {}\n\n/**\n * The Convex resource providers. Pass a credentials layer to override the\n * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login, and\n * `CONVEX_DEPLOY_KEY`).\n */\nexport const providers = (credentials: Layer.Layer<Credentials> = fromConfig()) =>\n Layer.effect(\n Providers,\n // Random's provider serves `IdentityBroker.registrationKey` in a stack with no other collection\n // that holds one; with Cloudflare's too, the first found serves it, and both are the same.\n Provider.collection([\n Project,\n DeploymentResource,\n LocalDeployment,\n IdentityBroker.Client,\n Random,\n ]),\n ).pipe(\n Layer.provide(\n Layer.mergeAll(\n ProjectProvider(),\n DeploymentProvider(),\n LocalDeploymentProvider(),\n IdentityB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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samebase/alchemy-convex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "The Convex plane for Alchemy v2: projects, deployments, environment variables, and the push of the functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alchemy",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"types": "./lib/index.d.ts",
|
|
37
37
|
"import": "./lib/index.js"
|
|
38
38
|
},
|
|
39
|
-
"./identity-
|
|
40
|
-
"types": "./lib/
|
|
41
|
-
"import": "./lib/
|
|
39
|
+
"./identity-broker": {
|
|
40
|
+
"types": "./lib/IdentityBroker.d.ts",
|
|
41
|
+
"import": "./lib/IdentityBroker.js"
|
|
42
42
|
},
|
|
43
43
|
"./sealed-secret": {
|
|
44
44
|
"types": "./lib/sealedSecret.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@convex-dev/platform": "0.1.11",
|
|
53
|
-
"@samebase/alchemy-kit": "^0.
|
|
53
|
+
"@samebase/alchemy-kit": "^0.7.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@alchemy.run/cloudflare": "2.0.0-beta.87",
|