@iterate-com/cloud 0.0.0 → 0.1.0-main.20261106T154720Z-ce800a3
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/LICENSE +202 -0
- package/README.md +93 -0
- package/dist/api-B9RGHZ6w.d.mts +149 -0
- package/dist/api.d.mts +2 -0
- package/dist/api.mjs +416 -0
- package/dist/config-5MFPZT_A.d.mts +67 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +73 -0
- package/dist/durable-object-BM27_ak3.d.mts +1036 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +660 -0
- package/dist/records-BQhLMgQ8.d.mts +459 -0
- package/dist/records.d.mts +2 -0
- package/dist/records.mjs +248 -0
- package/dist/usingCtx-DMdzU0lI.mjs +874 -0
- package/dist/views.d.mts +43 -0
- package/dist/views.mjs +132 -0
- package/dist/wizard.d.mts +101 -0
- package/dist/wizard.mjs +221 -0
- package/dist/worker.d.mts +22 -0
- package/dist/worker.mjs +344 -0
- package/package.json +58 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @iterate-com/cloud
|
|
2
|
+
|
|
3
|
+
Iterate Cloud as a package a project installs: a person signs in through the OS, connects a
|
|
4
|
+
Cloudflare account, and gets a deployment of iterate's platform (`core/os`) in that account, which
|
|
5
|
+
the Cloud deploys and updates. The project that installs it is the Cloud's origin and its backend;
|
|
6
|
+
its pages are [packages/cloud-app](../cloud-app/README.md), a Worker with no state.
|
|
7
|
+
|
|
8
|
+
Everything the Cloud knows is a context with a processor ([src/contract.ts](src/contract.ts)):
|
|
9
|
+
|
|
10
|
+
- **`/people/<sub>`** ([src/person.ts](src/person.ts)): a person's sign-ins, their Cloudflare
|
|
11
|
+
connections and their deployments.
|
|
12
|
+
- **`/deployments/<id>`** ([src/deployment.ts](src/deployment.ts)): the record and the config, the
|
|
13
|
+
creation (the deployment's own sandbox, then its first deploy), and each run as a saga: its named
|
|
14
|
+
steps with each one's newest text lines, and Alchemy's resources as its typed events report them
|
|
15
|
+
([src/alchemy.ts](src/alchemy.ts)).
|
|
16
|
+
- **`/toolchain`** ([src/toolchain.ts](src/toolchain.ts)): iterate/core installed and built once,
|
|
17
|
+
saved as the snapshot every deployment's sandbox starts from.
|
|
18
|
+
|
|
19
|
+
The sandbox work is [src/runs.ts](src/runs.ts) and [src/image.ts](src/image.ts): the same deploy
|
|
20
|
+
program a laptop runs, as two steps (`pnpm build`, then `pnpm alchemy deploy --yes --log-format
|
|
21
|
+
json`, whose JSON records the run reads), with the Cloudflare grant as an egress placeholder that no
|
|
22
|
+
code reads. A deployment's three inputs are its config ([src/config.ts](src/config.ts)), its account,
|
|
23
|
+
and the grant.
|
|
24
|
+
|
|
25
|
+
The project's config worker serves the Cloud ([src/worker.ts](src/worker.ts)): its own sign-in
|
|
26
|
+
through the OS ([src/sign-in.ts](src/sign-in.ts)), a capnweb API at `/rpc` for the signed-in
|
|
27
|
+
person ([src/api.ts](src/api.ts)), the return of a Cloudflare connect, and the pages, fetched
|
|
28
|
+
through to the Cloud app. The page's wizard is a state machine here ([src/wizard.ts](src/wizard.ts)),
|
|
29
|
+
and what it shows of a deployment is [src/views.ts](src/views.ts).
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// the installing project's config: cloud.ts re-exports the facets, worker.ts serves the Cloud
|
|
33
|
+
export { CloudDeploymentFacet, CloudPersonFacet, CloudToolchainFacet } from "@iterate-com/cloud";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## What the installing project needs
|
|
37
|
+
|
|
38
|
+
- **`/secrets/cloud-cloudflare-client`**, `{ clientSecret }` pinned to `https://dash.cloudflare.com`:
|
|
39
|
+
the secret of the Cloud's Cloudflare OAuth client, whose id the config passes in. Only the
|
|
40
|
+
platform reads it, at a connect's code exchange and at each refresh. The client lists the
|
|
41
|
+
platform's callback, `<platform origin>/.secrets/oauth/callback`, as a redirect URI.
|
|
42
|
+
- **`/secrets/cloud-image-source`**, `{ username, password }` pinned to
|
|
43
|
+
`https://registry.cloudflare.com`, `username` public: a pull credential of the registry that holds
|
|
44
|
+
`iterate-dev-image`, which that account's API mints
|
|
45
|
+
(`POST /accounts/<account>/containers/registries/registry.cloudflare.com/credentials`,
|
|
46
|
+
`{"permissions":["pull"],"expiration_minutes":…}`). It expires; a run that must copy the image
|
|
47
|
+
then fails and names it. A Cloud whose toolchain names no image needs none.
|
|
48
|
+
- **The toolchain**, prepared once and again for each new core, with one event:
|
|
49
|
+
`itx.cd("/toolchain").append({ type: "cloud/toolchain-requested", payload: {} })`.
|
|
50
|
+
Its deployments get no sandbox image: a run's image step says it is skipped, and their sandboxes
|
|
51
|
+
start Cloudflare's managed image.
|
|
52
|
+
- **The sandbox image, optional**: the same event with
|
|
53
|
+
`payload: { image: { account, secret, digest } }` makes each plan and deploy put
|
|
54
|
+
`iterate-dev-image` into the customer's account first ([src/image.ts](src/image.ts)). The digest
|
|
55
|
+
is `iterate-dev-image`'s under the source account in iterate's `scripts/os/images.lock.json`, at
|
|
56
|
+
the commit core's main was copied from (its `GitOrigin-RevId`). The project needs no GitHub
|
|
57
|
+
connection: the image step reads no repository. **The copy does not work yet for an account that
|
|
58
|
+
lacks the image**: crane uploads each layer through the project's egress, which gives a request
|
|
59
|
+
50 seconds, and the image's large layers take longer (`504 … sent no answer within 50 s`).
|
|
60
|
+
- Nothing by hand for the sandboxes: each preparation writes two rules on its own context,
|
|
61
|
+
`itx.fetch` and `itx.sandboxes` to the root's ([src/runs.ts](src/runs.ts) `withProjectRoots`). A
|
|
62
|
+
sandbox's requests are answered by its context's `itx.fetch`, and its start from the toolchain
|
|
63
|
+
finds that sandbox through its context's `itx.sandboxes`; a context beneath the root has neither.
|
|
64
|
+
|
|
65
|
+
The Cloud runs at the root of a host (prd: `cloud.iterate.app`) or under a base path, as a
|
|
66
|
+
project is served under paths ingress (`<platform>/projects/cloud`): the config worker reads the
|
|
67
|
+
path from `x-iterate-base-path` and every address it names carries it, and the pages follow
|
|
68
|
+
`@iterate-com/ui/apps/base-path`.
|
|
69
|
+
|
|
70
|
+
## The playground
|
|
71
|
+
|
|
72
|
+
`cloud-dev` (`osEnvs["cloud-dev"]` in iterate/private's `envs.ts`) is a standing core/os on the dev
|
|
73
|
+
account, at https://cloud-dev-os.iterate-dev-preview.workers.dev, whose `cloud` project serves the
|
|
74
|
+
Cloud at `/projects/cloud`, with the dev account's pages Worker (`cloudAppEnvs.preview`). A core
|
|
75
|
+
change goes there with one command, and the same deployment keeps its data:
|
|
76
|
+
`doppler run --project os --config preview -- pnpm os deploy --env cloud-dev`.
|
|
77
|
+
|
|
78
|
+
## The spec
|
|
79
|
+
|
|
80
|
+
`test/playwright/cloud/install.spec.ts` walks a new person through the whole Cloud, from the first
|
|
81
|
+
page to an agent's answer in a project of the iterate it deployed into the dev account, and always
|
|
82
|
+
destroys that deployment again, checking that the Worker and the Artifacts namespace are gone. Cloudflare's consent is the one step a robot cannot take: it stores what the
|
|
83
|
+
consent would have stored. Against the playground:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
caffeinate -dimu doppler run --project os --config preview -- env WORKER_BASE_URL=https://cloud-dev-os.iterate-dev-preview.workers.dev CLOUD_BASE_URL=https://cloud-dev-os.iterate-dev-preview.workers.dev/projects/cloud pnpm spec --project cloud
|
|
87
|
+
caffeinate -dimu doppler run --project os --config preview -- env VIDEO_MODE=1 WORKER_BASE_URL=https://cloud-dev-os.iterate-dev-preview.workers.dev CLOUD_BASE_URL=https://cloud-dev-os.iterate-dev-preview.workers.dev/projects/cloud pnpm spec --project cloud
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Without `CLOUD_BASE_URL` it skips.
|
|
91
|
+
|
|
92
|
+
Published per commit on pkg.pr.new (`.github/workflows/pkg-pr-new.yml`). `pnpm test` runs the
|
|
93
|
+
processors over an in-memory stream and the wizard over fakes.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { c as DeploymentRecord, f as PersonState, l as DeploymentState, x as RunStep } from "./records-BQhLMgQ8.mjs";
|
|
2
|
+
import { i as WatchTarget } from "./durable-object-BM27_ak3.mjs";
|
|
3
|
+
import { RpcTarget } from "cloudflare:workers";
|
|
4
|
+
import { IterateContextApi } from "iterate/api";
|
|
5
|
+
//#region src/sign-in.d.ts
|
|
6
|
+
/** The person, as the issuer's userinfo names them: `sub` is their OS user id. */
|
|
7
|
+
type Person = {
|
|
8
|
+
sub: string;
|
|
9
|
+
email: string;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/api.d.ts
|
|
13
|
+
/** What a Cloud API serves from: the person the session names, the config worker's scope, its
|
|
14
|
+
* `waitUntil`, and the Cloud's Cloudflare OAuth client. */
|
|
15
|
+
type ApiDeps = {
|
|
16
|
+
person: Person;
|
|
17
|
+
/** The path the Cloud is served under on its origin, "" at a host's root (worker.ts). */
|
|
18
|
+
basePath: string;
|
|
19
|
+
getItx: () => IterateContextApi & Disposable;
|
|
20
|
+
waitUntil: (work: Promise<unknown>) => void;
|
|
21
|
+
cloudflare: CloudflareClient;
|
|
22
|
+
};
|
|
23
|
+
/** The Cloud's own Cloudflare OAuth client: its id, public, and the project secret that holds its
|
|
24
|
+
* secret, `{ clientSecret }`, which only the platform reads, at the code exchange and each refresh. */
|
|
25
|
+
type CloudflareClient = {
|
|
26
|
+
clientId: string;
|
|
27
|
+
secret: string;
|
|
28
|
+
};
|
|
29
|
+
declare class CloudApi extends RpcTarget {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(deps: ApiDeps);
|
|
32
|
+
whoami(): {
|
|
33
|
+
sub: string;
|
|
34
|
+
email: string;
|
|
35
|
+
};
|
|
36
|
+
/** The person's own context, live: their connections and deployments. */
|
|
37
|
+
get person(): LiveContext;
|
|
38
|
+
get deployments(): Deployments;
|
|
39
|
+
/** Begin a Cloudflare connect: the platform's start link, which the browser opens to reach
|
|
40
|
+
* Cloudflare's consent. Cloudflare returns to the platform's callback, which stores the tokens in
|
|
41
|
+
* the connection's secret and sends the browser to `/connected` here (worker.ts). The attempt is
|
|
42
|
+
* this person's alone (`completedByUserId`): the callback completes it only in a browser signed
|
|
43
|
+
* in at the OS as them, whether or not they are a member of this project. */
|
|
44
|
+
connectCloudflare(): Promise<{
|
|
45
|
+
url: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
/** A context the person owns, live: the seed (`liveSnapshot`) and the deltas (`subscribe`) of its
|
|
49
|
+
* processor, as iterate/client `connectLiveState` reads them. */
|
|
50
|
+
declare class LiveContext extends RpcTarget {
|
|
51
|
+
#private;
|
|
52
|
+
protected readonly deps: ApiDeps;
|
|
53
|
+
protected readonly path: string;
|
|
54
|
+
constructor(deps: ApiDeps, path: string, slug: string);
|
|
55
|
+
liveSnapshot(): Promise<{
|
|
56
|
+
rev: number;
|
|
57
|
+
state: PersonState | DeploymentState;
|
|
58
|
+
}>;
|
|
59
|
+
/** Follow the processor's live state: `target` gets every batch of its deltas until the handle
|
|
60
|
+
* is disposed or the socket closes. Only the live-state type: `name` and `consumes` are ignored
|
|
61
|
+
* (the facet names its watch). */
|
|
62
|
+
subscribe(input: {
|
|
63
|
+
target: WatchTarget;
|
|
64
|
+
name?: string;
|
|
65
|
+
consumes?: string[];
|
|
66
|
+
}): Promise<Subscription>;
|
|
67
|
+
}
|
|
68
|
+
/** What `subscribe` answers: disposing it, or the socket closing, ends the facet's watch. */
|
|
69
|
+
declare class Subscription extends RpcTarget {
|
|
70
|
+
#private;
|
|
71
|
+
constructor(end: () => void);
|
|
72
|
+
[Symbol.dispose](): void;
|
|
73
|
+
}
|
|
74
|
+
declare class Deployments extends RpcTarget {
|
|
75
|
+
#private;
|
|
76
|
+
constructor(deps: ApiDeps);
|
|
77
|
+
/** Request a deployment into one of the accounts a connected connection reaches. `request` is
|
|
78
|
+
* the page's own random id for this creation: the deployment's id is derived from it, so a
|
|
79
|
+
* retried request (a reload, a lost answer) is the same deployment. The person's listing is
|
|
80
|
+
* appended first, then the deployment's own request, both keyed by the id: a creation that
|
|
81
|
+
* stops between the two is listed, its context empty, and `requestCreation` finishes it. Of
|
|
82
|
+
* two that overlap with one name, only the first the person's log lists goes on. */
|
|
83
|
+
create(input: {
|
|
84
|
+
request: string;
|
|
85
|
+
connection: string;
|
|
86
|
+
accountId: string;
|
|
87
|
+
name: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
id: string;
|
|
90
|
+
}>;
|
|
91
|
+
/** Whether `name` is free for a new deployment in the account, as `create` checks it: no
|
|
92
|
+
* deployment of the person's has it there, and the account has no Worker of that name. A name in
|
|
93
|
+
* use is never taken over: a deploy of an existing stack would replace that deployment's
|
|
94
|
+
* encryption key and orphan every secret it sealed. */
|
|
95
|
+
checkName(input: {
|
|
96
|
+
connection: string;
|
|
97
|
+
accountId: string;
|
|
98
|
+
name: string;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
status: "taken";
|
|
101
|
+
message: string;
|
|
102
|
+
} | {
|
|
103
|
+
status: "free";
|
|
104
|
+
message: string;
|
|
105
|
+
} | {
|
|
106
|
+
status: "unknown";
|
|
107
|
+
message: string;
|
|
108
|
+
}>;
|
|
109
|
+
/** One of the person's deployments; any other id is refused. */
|
|
110
|
+
get(id: string): Promise<Deployment>;
|
|
111
|
+
}
|
|
112
|
+
declare class Deployment extends LiveContext {
|
|
113
|
+
#private;
|
|
114
|
+
constructor(deps: ApiDeps, record: DeploymentRecord);
|
|
115
|
+
/** Finish a creation that stopped before the deployment's own request (`create` says when). */
|
|
116
|
+
requestCreation(): Promise<void>;
|
|
117
|
+
/** Prepare the sandbox again after a preparation failed. */
|
|
118
|
+
prepareAgain(): Promise<void>;
|
|
119
|
+
/** Ask for a run. Its answer is on the deployment's state: open, or refused while another runs. */
|
|
120
|
+
requestRun(kind: string): Promise<{
|
|
121
|
+
requestOffset: number;
|
|
122
|
+
}>;
|
|
123
|
+
/** The text lines one step of a run printed, at most its first 1,000, from the run's
|
|
124
|
+
* `cloud/output-printed` events; the state keeps only each step's newest. */
|
|
125
|
+
readOutput(requestOffset: number, step: RunStep): Promise<{
|
|
126
|
+
lines: string[];
|
|
127
|
+
}>;
|
|
128
|
+
/** The password minted for the owner's sign-in to the deployed Worker (config.ts), from the
|
|
129
|
+
* deployment's full state: the one secret the Cloud shows, to the owner alone. */
|
|
130
|
+
signInPassword(): Promise<string | null>;
|
|
131
|
+
}
|
|
132
|
+
/** The Cloudflare accounts a connection's token reaches, as Cloudflare's API lists them. The
|
|
133
|
+
* placeholder rides in the header; egress swaps the token in. */
|
|
134
|
+
declare function accountsOf(connection: string): Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
name: string;
|
|
137
|
+
}[]>;
|
|
138
|
+
/** The facet spec of one of the package's processors, loaded from the project's published config,
|
|
139
|
+
* whose top-level `cloud.ts` re-exports the package (a processor row names a top-level module).
|
|
140
|
+
* `consumes` is its contract's: the platform delivers the processor no other type. */
|
|
141
|
+
declare const facetSpecOf: (className: string, consumes: readonly string[]) => {
|
|
142
|
+
className: string;
|
|
143
|
+
mainModule: string;
|
|
144
|
+
source: ["itx", ["cd", string], "config"];
|
|
145
|
+
consumes: string[];
|
|
146
|
+
};
|
|
147
|
+
declare const personPathOf: (sub: string) => string;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { facetSpecOf as a, accountsOf as i, CloudApi as n, personPathOf as o, CloudflareClient as r, ApiDeps as t };
|
package/dist/api.d.mts
ADDED