palbase 0.0.0-stage → 0.1.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/LICENSE +27 -0
- package/README.md +2 -2
- package/dist/ai/index.js +17 -0
- package/dist/backend/engine.js +2 -0
- package/dist/backend/env.js +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/stack.js +1 -0
- package/dist/backend/test.js +2 -0
- package/dist/chunks/3OGEBGYZ.js +20 -0
- package/dist/chunks/3VASGTIN.js +2 -0
- package/dist/chunks/3XT4L2XV.js +2 -0
- package/dist/chunks/45J7YXRB.js +2 -0
- package/dist/chunks/6FWCNTAM.js +2 -0
- package/dist/chunks/DAOLIUNZ.js +2 -0
- package/dist/chunks/E5Q4VTW4.js +2 -0
- package/dist/chunks/HKJU2FKE.js +2 -0
- package/dist/chunks/IKVOXHEE.js +2 -0
- package/dist/chunks/JAWWIVZH.js +2 -0
- package/dist/chunks/LYEFPLJZ.js +4 -0
- package/dist/chunks/QXUMLO7O.js +13 -0
- package/dist/chunks/UAY56IQR.js +6 -0
- package/dist/cli.js +815 -0
- package/dist/refuse/ai.js +2 -0
- package/dist/refuse/backend.js +2 -0
- package/dist/refuse/server.js +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/testing.js +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/palbe.js +2 -0
- package/dist/web/vite.js +3 -0
- package/package.json +107 -4
- package/types/ai/src/ai.d.ts +178 -0
- package/types/ai/src/index.d.ts +5 -0
- package/types/ai/src/partial.d.ts +1 -0
- package/types/ai/src/schema.d.ts +47 -0
- package/types/backend/src/bootstrap.d.ts +72 -0
- package/types/backend/src/cache.d.ts +32 -0
- package/types/backend/src/container.d.ts +49 -0
- package/types/backend/src/database.d.ts +148 -0
- package/types/backend/src/db-env.d.ts +4 -0
- package/types/backend/src/decorators.d.ts +293 -0
- package/types/backend/src/engine-db.d.ts +24 -0
- package/types/backend/src/engine-exports.d.ts +3 -0
- package/types/backend/src/engine.d.ts +124 -0
- package/types/backend/src/env.d.ts +27 -0
- package/types/backend/src/errors.d.ts +70 -0
- package/types/backend/src/i18n.d.ts +21 -0
- package/types/backend/src/index.d.ts +23 -0
- package/types/backend/src/openapi.d.ts +73 -0
- package/types/backend/src/platform-calls.d.ts +41 -0
- package/types/backend/src/requests.d.ts +81 -0
- package/types/backend/src/rooms.d.ts +168 -0
- package/types/backend/src/router.d.ts +22 -0
- package/types/backend/src/runtime.d.ts +56 -0
- package/types/backend/src/services.d.ts +262 -0
- package/types/backend/src/stack.d.ts +20 -0
- package/types/backend/src/strings-files.d.ts +3 -0
- package/types/backend/src/testing/index.d.ts +3 -0
- package/types/backend/src/testing/unit.d.ts +66 -0
- package/types/backend/src/upload.d.ts +125 -0
- package/types/backend/src/webhooks.d.ts +113 -0
- package/types/internal/src/event.d.ts +9 -0
- package/types/internal/src/modules/ai.d.ts +678 -0
- package/types/internal/src/modules/analytics.d.ts +1414 -0
- package/types/internal/src/modules/auth.d.ts +5660 -0
- package/types/internal/src/modules/cache.d.ts +158 -0
- package/types/internal/src/modules/events.d.ts +19 -0
- package/types/internal/src/modules/flags.d.ts +957 -0
- package/types/internal/src/modules/index.d.ts +13 -0
- package/types/internal/src/modules/machines.d.ts +1584 -0
- package/types/internal/src/modules/notify.d.ts +1450 -0
- package/types/internal/src/modules/purchases.d.ts +2944 -0
- package/types/internal/src/modules/realtime.d.ts +326 -0
- package/types/internal/src/modules/secrets.d.ts +275 -0
- package/types/internal/src/modules/storage.d.ts +691 -0
- package/types/internal/src/modules/stores.d.ts +1516 -0
- package/types/internal/src/retry.d.ts +14 -0
- package/types/internal/src/transport.d.ts +106 -0
- package/types/server/src/auth/dpop.d.ts +47 -0
- package/types/server/src/auth/jwt.d.ts +115 -0
- package/types/server/src/index.d.ts +9 -0
- package/types/server/src/pages.d.ts +4 -0
- package/types/server/src/purchases.d.ts +51 -0
- package/types/server/src/secrets-env.d.ts +22 -0
- package/types/server/src/server.d.ts +40 -0
- package/types/server/src/testing.d.ts +91 -0
- package/types/server/src/webhooks.d.ts +72 -0
- package/types/web/src/analytics.d.ts +87 -0
- package/types/web/src/auth.d.ts +155 -0
- package/types/web/src/backend-error.d.ts +38 -0
- package/types/web/src/backend-names.d.ts +25 -0
- package/types/web/src/backends.d.ts +84 -0
- package/types/web/src/client.d.ts +51 -0
- package/types/web/src/index.d.ts +11 -0
- package/types/web/src/palbe.d.ts +2 -0
- package/types/web/src/purchases.d.ts +73 -0
- package/types/web/src/rooms.d.ts +61 -0
- package/types/web/src/session.d.ts +91 -0
- package/types/web/src/socket.d.ts +87 -0
- package/types/web/src/vite.d.ts +49 -0
|
@@ -0,0 +1,1584 @@
|
|
|
1
|
+
import { type Reply, type Transport } from '../transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* One build of a machine: one commit of its branch, built once however often it is pushed.
|
|
4
|
+
*/
|
|
5
|
+
export type Build = {
|
|
6
|
+
id: string;
|
|
7
|
+
commit: string;
|
|
8
|
+
/**
|
|
9
|
+
* The commit's message, its first 1000 bytes.
|
|
10
|
+
*/
|
|
11
|
+
message: string;
|
|
12
|
+
/**
|
|
13
|
+
* waiting_checks: its machine builds a commit once its checks have passed (`deploy_after_checks`), and `reason` says what it waits for — several builds of a machine wait at once, each for its own commit's checks; queued; building; testing: released to its machine, its tests (`test_command`) running against it before it takes traffic — they fail and it fails (`reason` names the tests), the machine running what it ran; waiting_config: built, waiting for what its .env.example names (`missing_env`) — it rolls out once the machine has it; succeeded: built and rolled out (or a newer build already had); failed (`reason`); cancelled: a newer commit was built (its checks passed first, or its machine does not wait for them), the head of the machine's branch was asked for (a deploy, or a change of source, leaves the builds waiting for other commits' checks behind), or the machine was deleted (`reason`); skipped: its commit's checks did not pass, none was reported, named ones were cancelled before they ran or not reported, or they did not end in time (`reason`) — nothing of it was built.
|
|
14
|
+
*/
|
|
15
|
+
state: "building" | "cancelled" | "failed" | "queued" | "skipped" | "succeeded" | "testing" | "waiting_checks" | "waiting_config";
|
|
16
|
+
reason?: string;
|
|
17
|
+
/**
|
|
18
|
+
* What the build's .env.example names that the machine's env and secrets do not hold.
|
|
19
|
+
*/
|
|
20
|
+
missing_env: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The machine runs this build, or rolls out to it.
|
|
23
|
+
*/
|
|
24
|
+
running: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The machine may return to this build (POST /machines/{name}/rollback): it succeeded and its image is kept — a machine keeps the images of ten of its builds that succeeded, the one it runs among them.
|
|
27
|
+
*/
|
|
28
|
+
returnable: boolean;
|
|
29
|
+
created_at: string;
|
|
30
|
+
started_at?: string;
|
|
31
|
+
finished_at?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A page of a machine's builds, newest first.
|
|
35
|
+
*/
|
|
36
|
+
export type BuildPage = {
|
|
37
|
+
builds: Build[];
|
|
38
|
+
/**
|
|
39
|
+
* The cursor of the next page; absent on the last page.
|
|
40
|
+
*/
|
|
41
|
+
next_cursor?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The build a machine runs, or rolls out to.
|
|
45
|
+
*/
|
|
46
|
+
export type BuildRef = {
|
|
47
|
+
id: string;
|
|
48
|
+
commit: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Where the project's owner goes to connect GitHub. GitHub asks who they are and comes back to the platform, which shows them the accounts Palbase Cloud is installed on that they can push to — and where to install it on another — and connects the one they choose once they write the project's ref.
|
|
52
|
+
*/
|
|
53
|
+
export type Connect = {
|
|
54
|
+
url: string;
|
|
55
|
+
expires_at: string;
|
|
56
|
+
/**
|
|
57
|
+
* The App's OAuth client id: public, every link to GitHub's sign-in names it. A device with no browser (the CLI) signs its user in to the App with it by GitHub's device flow and links an installation with the token (POST /machines/github/installations).
|
|
58
|
+
*/
|
|
59
|
+
client_id: string;
|
|
60
|
+
};
|
|
61
|
+
export type ErrorResponse = {
|
|
62
|
+
/**
|
|
63
|
+
* Machine-readable error code (snake_case)
|
|
64
|
+
*/
|
|
65
|
+
error: string;
|
|
66
|
+
/**
|
|
67
|
+
* Human-readable explanation
|
|
68
|
+
*/
|
|
69
|
+
error_description: string;
|
|
70
|
+
/**
|
|
71
|
+
* Correlation ID for log/audit lookup
|
|
72
|
+
*/
|
|
73
|
+
request_id: string;
|
|
74
|
+
/**
|
|
75
|
+
* Seconds to wait before retrying; present on a refusal that ends with time.
|
|
76
|
+
*/
|
|
77
|
+
retry_after?: number;
|
|
78
|
+
/**
|
|
79
|
+
* HTTP status code (mirrors the response status)
|
|
80
|
+
*/
|
|
81
|
+
status: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* One of the project's installations of Palbase Cloud, the platform's GitHub App.
|
|
85
|
+
*/
|
|
86
|
+
export type Installation = {
|
|
87
|
+
installation_id: number;
|
|
88
|
+
/**
|
|
89
|
+
* The GitHub account it is installed on.
|
|
90
|
+
*/
|
|
91
|
+
account: string;
|
|
92
|
+
/**
|
|
93
|
+
* The GitHub user who connected it: the project reaches the repositories of it that user could push to when they connected it.
|
|
94
|
+
*/
|
|
95
|
+
linked_by: string;
|
|
96
|
+
created_at: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Connects an installation the user reaches — a CLI's way, with the user's own GitHub token for Palbase Cloud (its device flow). The token proves the user may reach the installation and is kept nowhere.
|
|
100
|
+
*/
|
|
101
|
+
export type InstallationLink = {
|
|
102
|
+
installation_id: number;
|
|
103
|
+
user_token: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* The project's installations.
|
|
107
|
+
*/
|
|
108
|
+
export type InstallationList = {
|
|
109
|
+
installations: Installation[];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* A project's machine: what was asked for, and what runs.
|
|
113
|
+
*/
|
|
114
|
+
export type Machine = {
|
|
115
|
+
created_at: string;
|
|
116
|
+
/**
|
|
117
|
+
* The machine's name; `backend` is the project's backend.
|
|
118
|
+
*/
|
|
119
|
+
name: string;
|
|
120
|
+
/**
|
|
121
|
+
* The TCP port the machine listens on; requests to its address are sent there. The machine also finds it in PORT. A change of it rolls out as any change does: while both versions serve, each is sent requests at its own port.
|
|
122
|
+
*/
|
|
123
|
+
port: number;
|
|
124
|
+
/**
|
|
125
|
+
* The version the machine runs; it equals `version` once a change has rolled out. A change of how it runs (not a new build, which the machine returns from to the build it served) whose version did not come up within the 5 minutes a rollout has, while the one before served, is given up on: the machine runs the one before, which serves on, sleeps when idle and is what a request wakes, until its next change rolls out a new version (`state_reason` says why). 0 before it has run.
|
|
126
|
+
*/
|
|
127
|
+
running_version: number;
|
|
128
|
+
/**
|
|
129
|
+
* The machine's size. A shared size has a fraction of a CPU as its ceiling and is put to sleep when it is idle; a dedicated size has whole CPUs of its own and never sleeps. shared-256: 0.2 vCPU, 256 MiB; shared-512: 0.5 vCPU, 512 MiB; shared-1024: 1 vCPU, 1024 MiB; dedicated-1x: 1 vCPU, 2048 MiB; dedicated-2x: 2 vCPU, 4096 MiB.
|
|
130
|
+
*/
|
|
131
|
+
size: "dedicated-1x" | "dedicated-2x" | "shared-1024" | "shared-256" | "shared-512";
|
|
132
|
+
/**
|
|
133
|
+
* building: no build of it runs yet (its first is on its way — waiting for its commit's checks too — or failed: `state_reason`); starting: on its way up; awake: answering; asleep: idle, and woken by the next request to its address; failed: it cannot start, or its first build failed or was skipped (`state_reason` says why).
|
|
134
|
+
*/
|
|
135
|
+
state: "asleep" | "awake" | "building" | "failed" | "starting";
|
|
136
|
+
/**
|
|
137
|
+
* Why the machine has failed, or why a new version is not up — its image could not be pulled, it could not be started, its process keeps exiting or ran out of its memory, it does not answer 2xx at its health path (it is started again each time it has not in the 90 s it has), nothing answers on its port (past 90 s) — or that a version did not come up and the one before runs; absent otherwise.
|
|
138
|
+
*/
|
|
139
|
+
state_reason?: string;
|
|
140
|
+
updated_at: string;
|
|
141
|
+
/**
|
|
142
|
+
* Where the machine answers: the project's own address for `backend`, <name>-<ref> under the app domain for any other.
|
|
143
|
+
*/
|
|
144
|
+
url: string;
|
|
145
|
+
/**
|
|
146
|
+
* Counts the changes asked for, from 1.
|
|
147
|
+
*/
|
|
148
|
+
version: number;
|
|
149
|
+
/**
|
|
150
|
+
* What the machine is started with in its environment, besides what the platform sets: PORT, PALBASE_URL (its project's address), PALBASE_PROJECT_ID, PALBASE_REPLICAS and, given a database, PALBASE_DB_URL and PALBASE_DB_CONNECTIONS.
|
|
151
|
+
*/
|
|
152
|
+
env: {
|
|
153
|
+
[key: string]: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The project's secret environment the machine is started with; absent when none.
|
|
157
|
+
*/
|
|
158
|
+
secrets?: "production" | "development";
|
|
159
|
+
source: Source;
|
|
160
|
+
build?: BuildRef;
|
|
161
|
+
/**
|
|
162
|
+
* A build of the branch's head is asked for — opened, pushed to, deployed, its source changed — and not queued yet: the platform asks GitHub for the head first. Once false, the machine's newest build is the one asked for, or, when the branch was not found, `state` and `state_reason` say so.
|
|
163
|
+
*/
|
|
164
|
+
build_requested: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Where the machine says it is well, as asked of it (MachineCreate.health_path); absent when its build says.
|
|
167
|
+
*/
|
|
168
|
+
health_path?: string;
|
|
169
|
+
/**
|
|
170
|
+
* How many copies of the machine run while it is awake, each on a node of its own: a request is sent to one of them, a copy or a node that goes leaves the others serving, and the cluster takes one of them away at a time at most. Every copy is of the machine's size and counts as such against the project's limits and its machine time (a minute in which the number changed is counted at the most it was). What a copy keeps in its own memory or on its own disk the others do not see — a session, a counter, a cache, a timer: a machine with more than one keeps those where every copy reaches them. The machine finds the number in PALBASE_REPLICAS. A long-lived connection (a WebSocket) stays with the copy that took it.
|
|
171
|
+
*/
|
|
172
|
+
replicas: number;
|
|
173
|
+
database?: MachineDatabase;
|
|
174
|
+
/**
|
|
175
|
+
* Whether a push waits for its commit's checks before it is built; absent when it does not. A push is built only once its commit's checks on GitHub have passed, as Render's "After CI Checks Pass": those `deploy_checks` names, or else every check run reported on the commit for the machine's branch (GitHub Actions' jobs, and any other app's checks; Palbase's own left out) has ended in success, neutral or skipped, and every GitHub Actions workflow run of it has ended — taken as ended 30 s after the last ended, and no sooner than 30 s after the push's build was made. Until then the build waits (`waiting_checks`, its `reason` naming what it waits for), and the machine runs what it ran; a newer push waits beside it, for its own. The machine moves to the newest commit whose checks passed, never back: the first to pass is built and leaves the older builds behind, waiting or under way, so an older commit whose checks pass after it is not built. A check that ended otherwise (failure, cancelled, timed_out, action_required, stale), no check reported in 10 minutes, or checks not ended in 3 hours (6 hours for named ones), and the build is `skipped` (`reason`); a check run again that passes later does not build it — the next push to the branch is built then, whatever it changed. Commit statuses are not read.
|
|
176
|
+
*/
|
|
177
|
+
deploy_after_checks?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* The check runs a push waits for (`deploy_after_checks`) instead of every check, by their names as GitHub shows them — a GitHub Actions job's name, e.g. `unit` — from the app `deploy_checks_app` names, on the commit's suites for the machine's branch (a run of the same commit from a tag or another branch does not count, nor another app's run of that name): each is to be reported, to end and to succeed (success or neutral: a named check skipped did not run) — every run of that name, when two workflows name a job alike. While a suite of that app is open on the branch, with runs or not yet, the push waits. No other check is waited for or looked at. A named check that ends otherwise, or that the app's suites on the branch all ended without (cancelled before they ran), and the build is `skipped` at once (`reason`); one not reported in 6 hours, too. 20 names at most, each 1 to 200 characters with no space around it, named once. Absent: every check is waited for.
|
|
180
|
+
*/
|
|
181
|
+
deploy_checks?: string[];
|
|
182
|
+
/**
|
|
183
|
+
* The app named checks (`deploy_checks`) are taken from, by its GitHub App slug — as a required check's expected source is: another app's run of a named check counts for nothing.
|
|
184
|
+
*/
|
|
185
|
+
deploy_checks_app?: string;
|
|
186
|
+
/**
|
|
187
|
+
* What each new build of the machine runs before it takes traffic (Render's pre-deploy command, a CI's test step): once its database's migration has started, the new version comes up beside the one that serves — its own env, secrets and database — and its image runs this command in a shell (so the image has one) against it: `PALBASE_TEST_BASE_URL` is where it answers, `PALBASE_TEST_AUTH_URL` the project's auth. The tests reach what the machine reaches — its database, the project's modules — so they write as it does. They end other than 0 and the build fails, its `reason` naming the tests that failed: the version never takes traffic, the machine runs what it ran, and the migration is taken back. `bun test`, `npm test`. A build is tested as the machine says when it is released. Absent, a build rolls out once built.
|
|
188
|
+
*/
|
|
189
|
+
test_command?: string;
|
|
190
|
+
/**
|
|
191
|
+
* The project's test users each test run makes for its tests to act as — `PALBASE_TEST_IDENTITIES` names them, each with its access token (`api.signInAs("alice")`) — and deletes once the run has ended, however it ended. Each a name, once whatever its case: letters, digits, `_` and `-`, 64 at most.
|
|
192
|
+
*/
|
|
193
|
+
test_users?: string[];
|
|
194
|
+
/**
|
|
195
|
+
* Where an app that is not a palbase/backend one serves its contract (OpenAPI), read once a build's version alone serves the machine. Absent for a palbase/backend app, whose build writes it.
|
|
196
|
+
*/
|
|
197
|
+
openapi_path?: string;
|
|
198
|
+
/**
|
|
199
|
+
* The SHA-256 (hex) of the contract the build the machine serves from says it answers (GET /machines/{name}/openapi): a client generated from it is current while the two are the same. Absent while the contract has not been read, or when the app serves none.
|
|
200
|
+
*/
|
|
201
|
+
contract_digest?: string;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* A machine to open.
|
|
205
|
+
*/
|
|
206
|
+
export type MachineCreate = {
|
|
207
|
+
/**
|
|
208
|
+
* The machine's name; `backend`, the project's backend, when left out. Not `github`.
|
|
209
|
+
*/
|
|
210
|
+
name?: string;
|
|
211
|
+
/**
|
|
212
|
+
* The TCP port the machine listens on; requests to its address are sent there. The machine also finds it in PORT. A change of it rolls out as any change does: while both versions serve, each is sent requests at its own port.
|
|
213
|
+
*/
|
|
214
|
+
port?: number;
|
|
215
|
+
/**
|
|
216
|
+
* The machine's size. A shared size has a fraction of a CPU as its ceiling and is put to sleep when it is idle; a dedicated size has whole CPUs of its own and never sleeps. shared-256: 0.2 vCPU, 256 MiB; shared-512: 0.5 vCPU, 512 MiB; shared-1024: 1 vCPU, 1024 MiB; dedicated-1x: 1 vCPU, 2048 MiB; dedicated-2x: 2 vCPU, 4096 MiB.
|
|
217
|
+
*/
|
|
218
|
+
size: "dedicated-1x" | "dedicated-2x" | "shared-1024" | "shared-256" | "shared-512";
|
|
219
|
+
/**
|
|
220
|
+
* What the machine is started with in its environment, besides what the platform sets: PORT (where it listens), PALBASE_URL (its project's address, https://<ref>.<domain>), PALBASE_PROJECT_ID, PALBASE_REPLICAS (how many copies of it run) and, given a database, PALBASE_DB_URL and PALBASE_DB_CONNECTIONS (how many connections to it a copy may hold). PORT is refused here; the others, given here or among the machine's secrets, give way to the platform's. Names are environment variable names; 100 variables and 64 KiB at most. Keep secrets in the project's secrets and start the machine with them (`secrets`).
|
|
221
|
+
*/
|
|
222
|
+
env?: {
|
|
223
|
+
[key: string]: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* The project's secret environment the machine is started with: each of its secrets is in the machine's environment by name. A name in `env` wins over the same secret. When a secret of it changes, the machine rolls out with the new value beside the version that serves. Empty: none.
|
|
227
|
+
*/
|
|
228
|
+
secrets?: "" | "production" | "development";
|
|
229
|
+
source: Source;
|
|
230
|
+
/**
|
|
231
|
+
* Where the machine says it is well, as asked of it: a path from the root on its port (200 characters at most, no query) that answers 2xx while it serves. While it starts it has 90 s to answer there; once it serves, one that stops answering there for about 6 s is started again. Empty, its build says: a Palbase backend's (palbase/backend) is /_palbase/health; a machine that says nowhere is asked only whether it listens on its port.
|
|
232
|
+
*/
|
|
233
|
+
health_path?: string;
|
|
234
|
+
/**
|
|
235
|
+
* How many copies of the machine run while it is awake, each on a node of its own: a request is sent to one of them, a copy or a node that goes leaves the others serving, and the cluster takes one of them away at a time at most. Every copy is of the machine's size and counts as such against the project's limits and its machine time (a minute in which the number changed is counted at the most it was). What a copy keeps in its own memory or on its own disk the others do not see — a session, a counter, a cache, a timer: a machine with more than one keeps those where every copy reaches them. The machine finds the number in PALBASE_REPLICAS. A long-lived connection (a WebSocket) stays with the copy that took it. One when left out.
|
|
236
|
+
*/
|
|
237
|
+
replicas?: number;
|
|
238
|
+
database?: MachineDatabase;
|
|
239
|
+
/**
|
|
240
|
+
* A push is built only once its commit's checks on GitHub have passed, as Render's "After CI Checks Pass": those `deploy_checks` names, or else every check run reported on the commit for the machine's branch (GitHub Actions' jobs, and any other app's checks; Palbase's own left out) has ended in success, neutral or skipped, and every GitHub Actions workflow run of it has ended — taken as ended 30 s after the last ended, and no sooner than 30 s after the push's build was made. Until then the build waits (`waiting_checks`, its `reason` naming what it waits for), and the machine runs what it ran; a newer push waits beside it, for its own. The machine moves to the newest commit whose checks passed, never back: the first to pass is built and leaves the older builds behind, waiting or under way, so an older commit whose checks pass after it is not built. A check that ended otherwise (failure, cancelled, timed_out, action_required, stale), no check reported in 10 minutes, or checks not ended in 3 hours (6 hours for named ones), and the build is `skipped` (`reason`); a check run again that passes later does not build it — the next push to the branch is built then, whatever it changed. Commit statuses are not read. False: every push is built at once.
|
|
241
|
+
*/
|
|
242
|
+
deploy_after_checks?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* The check runs a push waits for (`deploy_after_checks`) instead of every check, by their names as GitHub shows them — a GitHub Actions job's name, e.g. `unit` — from the app `deploy_checks_app` names, on the commit's suites for the machine's branch (a run of the same commit from a tag or another branch does not count, nor another app's run of that name): each is to be reported, to end and to succeed (success or neutral: a named check skipped did not run) — every run of that name, when two workflows name a job alike. While a suite of that app is open on the branch, with runs or not yet, the push waits. No other check is waited for or looked at. A named check that ends otherwise, or that the app's suites on the branch all ended without (cancelled before they ran), and the build is `skipped` at once (`reason`); one not reported in 6 hours, too. 20 names at most, each 1 to 200 characters with no space around it, named once. Empty: every check is waited for.
|
|
245
|
+
*/
|
|
246
|
+
deploy_checks?: string[];
|
|
247
|
+
/**
|
|
248
|
+
* The app named checks (`deploy_checks`) are taken from, by its GitHub App slug — as a required check's expected source is: another app's run of a named check counts for nothing. Empty or left out: github-actions.
|
|
249
|
+
*/
|
|
250
|
+
deploy_checks_app?: string;
|
|
251
|
+
/**
|
|
252
|
+
* What each new build of the machine runs before it takes traffic (Render's pre-deploy command, a CI's test step): once its database's migration has started, the new version comes up beside the one that serves — its own env, secrets and database — and its image runs this command in a shell (so the image has one) against it: `PALBASE_TEST_BASE_URL` is where it answers, `PALBASE_TEST_AUTH_URL` the project's auth. The tests reach what the machine reaches — its database, the project's modules — so they write as it does. They end other than 0 and the build fails, its `reason` naming the tests that failed: the version never takes traffic, the machine runs what it ran, and the migration is taken back. `bun test`, `npm test`. A build is tested as the machine says when it is released. Absent, a build rolls out once built.
|
|
253
|
+
*/
|
|
254
|
+
test_command?: string;
|
|
255
|
+
/**
|
|
256
|
+
* The project's test users each test run makes for its tests to act as — `PALBASE_TEST_IDENTITIES` names them, each with its access token (`api.signInAs("alice")`) — and deletes once the run has ended, however it ended. Each a name, once whatever its case: letters, digits, `_` and `-`, 64 at most.
|
|
257
|
+
*/
|
|
258
|
+
test_users?: string[];
|
|
259
|
+
/**
|
|
260
|
+
* Where the machine's app serves its contract when it is not a palbase/backend app. Empty (the default) for a palbase/backend app.
|
|
261
|
+
*/
|
|
262
|
+
openapi_path?: string;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* A page of a project's machines, by name.
|
|
266
|
+
*/
|
|
267
|
+
export type MachinePage = {
|
|
268
|
+
machines: Machine[];
|
|
269
|
+
/**
|
|
270
|
+
* The cursor of the next page; absent on the last page.
|
|
271
|
+
*/
|
|
272
|
+
next_cursor?: string;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* The OpenAPI document a machine's app serves of itself, as it served it: a JSON object of the app's own.
|
|
276
|
+
*/
|
|
277
|
+
export type MachineContract = {
|
|
278
|
+
[key: string]: unknown;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* What to change; a field left out stays as it is. A new source is built, and rolls out once its build is up; a new size, port, env or secrets rolls out beside what serves.
|
|
282
|
+
*/
|
|
283
|
+
export type MachineUpdate = {
|
|
284
|
+
/**
|
|
285
|
+
* The TCP port the machine listens on; requests to its address are sent there. The machine also finds it in PORT. A change of it rolls out as any change does: while both versions serve, each is sent requests at its own port.
|
|
286
|
+
*/
|
|
287
|
+
port?: number;
|
|
288
|
+
/**
|
|
289
|
+
* The machine's size. A shared size has a fraction of a CPU as its ceiling and is put to sleep when it is idle; a dedicated size has whole CPUs of its own and never sleeps. shared-256: 0.2 vCPU, 256 MiB; shared-512: 0.5 vCPU, 512 MiB; shared-1024: 1 vCPU, 1024 MiB; dedicated-1x: 1 vCPU, 2048 MiB; dedicated-2x: 2 vCPU, 4096 MiB.
|
|
290
|
+
*/
|
|
291
|
+
size?: "dedicated-1x" | "dedicated-2x" | "shared-1024" | "shared-256" | "shared-512";
|
|
292
|
+
/**
|
|
293
|
+
* Replaces the machine's environment whole, besides PORT. Names are environment variable names; 100 variables and 64 KiB at most. Keep secrets in the project's secrets and start the machine with them (`secrets`).
|
|
294
|
+
*/
|
|
295
|
+
env?: {
|
|
296
|
+
[key: string]: string;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* The project's secret environment the machine is started with; empty for none.
|
|
300
|
+
*/
|
|
301
|
+
secrets?: "" | "production" | "development";
|
|
302
|
+
source?: Source;
|
|
303
|
+
/**
|
|
304
|
+
* A new health path: the machine rolls out with it. Empty lets its build say.
|
|
305
|
+
*/
|
|
306
|
+
health_path?: string;
|
|
307
|
+
/**
|
|
308
|
+
* How many copies of the machine run from now on: the machine rolls out as a new version with that many, beside what serves.
|
|
309
|
+
*/
|
|
310
|
+
replicas?: number;
|
|
311
|
+
database?: MachineDatabase;
|
|
312
|
+
/**
|
|
313
|
+
* Whether a push waits for its commit's checks from now on; no version is rolled out for it. The newest build waiting for its checks when it is turned off is built at once, and the older ones are left behind. A push is built only once its commit's checks on GitHub have passed, as Render's "After CI Checks Pass": those `deploy_checks` names, or else every check run reported on the commit for the machine's branch (GitHub Actions' jobs, and any other app's checks; Palbase's own left out) has ended in success, neutral or skipped, and every GitHub Actions workflow run of it has ended — taken as ended 30 s after the last ended, and no sooner than 30 s after the push's build was made. Until then the build waits (`waiting_checks`, its `reason` naming what it waits for), and the machine runs what it ran; a newer push waits beside it, for its own. The machine moves to the newest commit whose checks passed, never back: the first to pass is built and leaves the older builds behind, waiting or under way, so an older commit whose checks pass after it is not built. A check that ended otherwise (failure, cancelled, timed_out, action_required, stale), no check reported in 10 minutes, or checks not ended in 3 hours (6 hours for named ones), and the build is `skipped` (`reason`); a check run again that passes later does not build it — the next push to the branch is built then, whatever it changed. Commit statuses are not read.
|
|
314
|
+
*/
|
|
315
|
+
deploy_after_checks?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* The check runs a push waits for (`deploy_after_checks`) instead of every check, by their names as GitHub shows them — a GitHub Actions job's name, e.g. `unit` — from the app `deploy_checks_app` names, on the commit's suites for the machine's branch (a run of the same commit from a tag or another branch does not count, nor another app's run of that name): each is to be reported, to end and to succeed (success or neutral: a named check skipped did not run) — every run of that name, when two workflows name a job alike. While a suite of that app is open on the branch, with runs or not yet, the push waits. No other check is waited for or looked at. A named check that ends otherwise, or that the app's suites on the branch all ended without (cancelled before they ran), and the build is `skipped` at once (`reason`); one not reported in 6 hours, too. 20 names at most, each 1 to 200 characters with no space around it, named once. Replaces the names whole; empty waits for every check again. No version is rolled out for it.
|
|
318
|
+
*/
|
|
319
|
+
deploy_checks?: string[];
|
|
320
|
+
/**
|
|
321
|
+
* The app named checks (`deploy_checks`) are taken from, by its GitHub App slug — as a required check's expected source is: another app's run of a named check counts for nothing. No version is rolled out for it.
|
|
322
|
+
*/
|
|
323
|
+
deploy_checks_app?: string;
|
|
324
|
+
/**
|
|
325
|
+
* What each new build of the machine runs before it takes traffic (Render's pre-deploy command, a CI's test step): once its database's migration has started, the new version comes up beside the one that serves — its own env, secrets and database — and its image runs this command in a shell (so the image has one) against it: `PALBASE_TEST_BASE_URL` is where it answers, `PALBASE_TEST_AUTH_URL` the project's auth. The tests reach what the machine reaches — its database, the project's modules — so they write as it does. They end other than 0 and the build fails, its `reason` naming the tests that failed: the version never takes traffic, the machine runs what it ran, and the migration is taken back. `bun test`, `npm test`. A build is tested as the machine says when it is released. Absent, a build rolls out once built. An empty string runs none from now on.
|
|
326
|
+
*/
|
|
327
|
+
test_command?: string;
|
|
328
|
+
/**
|
|
329
|
+
* The project's test users each test run makes for its tests to act as — `PALBASE_TEST_IDENTITIES` names them, each with its access token (`api.signInAs("alice")`) — and deletes once the run has ended, however it ended. Each a name, once whatever its case: letters, digits, `_` and `-`, 64 at most.
|
|
330
|
+
*/
|
|
331
|
+
test_users?: string[];
|
|
332
|
+
/**
|
|
333
|
+
* Where the machine's app serves its contract from now on: nothing that runs changes, and the contract of the build it serves from is read again. Empty for a palbase/backend app.
|
|
334
|
+
*/
|
|
335
|
+
openapi_path?: string;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* A repository a machine may be built from.
|
|
339
|
+
*/
|
|
340
|
+
export type RepositoryEntry = {
|
|
341
|
+
repository: string;
|
|
342
|
+
installation_id: number;
|
|
343
|
+
private: boolean;
|
|
344
|
+
default_branch: string;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Every repository the project's installations reach.
|
|
348
|
+
*/
|
|
349
|
+
export type RepositoryList = {
|
|
350
|
+
repositories: RepositoryEntry[];
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* One of the machine's builds that succeeded.
|
|
354
|
+
*/
|
|
355
|
+
export type Rollback = {
|
|
356
|
+
build: string;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Where a machine is built from: a branch of a GitHub repository one of the project's installations of Palbase Cloud reaches (GET /machines/github/repositories), and a directory of it. A push to the branch is built — the directory's Dockerfile, or, without one, what Railpack detects (Node, Go, Python, …) — and rolled out when it changes a file in what the build is given: its context (`context`, else `path`), matched by whole directory names, case-sensitively; a push that changes nothing there leaves the machine as it runs, and does not count against the project's builds for the day. A machine built from the repository's root is built by every push. When what GitHub names of a push may not be all it changed — a forced push, a branch's first push, a push of 2048 commits or more, a commit naming no files (an empty commit among them) or 3000 or more — every machine built from the branch is built.
|
|
360
|
+
*/
|
|
361
|
+
export type Source = {
|
|
362
|
+
/**
|
|
363
|
+
* The repository's full name: owner/name.
|
|
364
|
+
*/
|
|
365
|
+
repository: string;
|
|
366
|
+
/**
|
|
367
|
+
* The branch whose pushes are built and rolled out: those that change what the machine is built from.
|
|
368
|
+
*/
|
|
369
|
+
branch: string;
|
|
370
|
+
/**
|
|
371
|
+
* The directory the machine is built from, relative to the repository's root; the root when left out. Its Dockerfile, when it has one, its package.json and its .env.example are read here.
|
|
372
|
+
*/
|
|
373
|
+
path?: string;
|
|
374
|
+
/**
|
|
375
|
+
* What the build is given as its context, when that is not `path` itself: a directory above `path`, or `.` for the repository's root. An app of a workspace (a monorepo) that needs its sibling packages is built with them in reach: its Dockerfile, in `path`, copies from the context; without a Dockerfile, Railpack plans the context. Left out, the context is `path`.
|
|
376
|
+
*/
|
|
377
|
+
context?: string;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* A project's database: what was asked for, and what runs.
|
|
381
|
+
*/
|
|
382
|
+
export type Database = {
|
|
383
|
+
/**
|
|
384
|
+
* The database's name.
|
|
385
|
+
*/
|
|
386
|
+
name: string;
|
|
387
|
+
/**
|
|
388
|
+
* Where it answers: <name>-<ref>.<the databases' domain>.
|
|
389
|
+
*/
|
|
390
|
+
host: string;
|
|
391
|
+
/**
|
|
392
|
+
* Its port straight to Postgres.
|
|
393
|
+
*/
|
|
394
|
+
port: number;
|
|
395
|
+
/**
|
|
396
|
+
* Its port through PgBouncer (transaction pooling): for clients that open a connection for each request.
|
|
397
|
+
*/
|
|
398
|
+
pooled_port: number;
|
|
399
|
+
/**
|
|
400
|
+
* The database's size. free: 0.25 vCPU, 512 MiB, 1 GB, put to sleep when idle (woken by the next connection in about 10 s), awake 400 hours a month at most, archived after a week asleep (its next connection brings it back from its backup); hobby: 0.25 vCPU, 512 MiB, 5 GB, put to sleep when idle, no monthly limit; shared-1g: 1 GiB, up to 1 vCPU, 10 GB; shared-2g: 2 GiB, up to 2 vCPU, 25 GB; shared-4g: 4 GiB, up to 2 vCPU, 50 GB; dedicated-1x: 1 vCPU of its own, 4 GiB, 25 GB; dedicated-2x: 2 vCPU of its own, 8 GiB, 50 GB. The shared and dedicated sizes never sleep and live on a Premium SSD v2 disk of their own; free and hobby on the platform's SAN. A database past its size's storage turns read-only. What a project's machines and databases reserve between them is held to its limit: a size that does not fit is refused (409 `machines_over_limit`).
|
|
401
|
+
*/
|
|
402
|
+
size: "dedicated-1x" | "dedicated-2x" | "free" | "hobby" | "shared-1g" | "shared-2g" | "shared-4g";
|
|
403
|
+
/**
|
|
404
|
+
* Where its data lives, as its size says: san, the platform's SAN; premium, a Premium SSD v2 disk of its own.
|
|
405
|
+
*/
|
|
406
|
+
disk: "premium" | "san";
|
|
407
|
+
/**
|
|
408
|
+
* Who may connect, as addresses or CIDRs (203.0.113.7, 203.0.113.0/24), 50 at most; anyone with the password when empty.
|
|
409
|
+
*/
|
|
410
|
+
allow: string[];
|
|
411
|
+
/**
|
|
412
|
+
* How many days the database's backups are kept: it can be brought back to any moment of them. 1 to 35.
|
|
413
|
+
*/
|
|
414
|
+
backup_days: number;
|
|
415
|
+
/**
|
|
416
|
+
* starting: on its way up; awake: answering; asleep: idle, woken by the next connection; archived: asleep for a week, its next connection brings it back from its backup; restoring: being brought back to a moment of its backups; resizing: moving to its size (`size`, the one asked for) through an instance of that size beside the one that serves — it serves on; its sessions on the direct port end once, as its primary moves to the new instance, and so does a transaction under way at that moment; new logins and transactions wait a few seconds for it; failed: it cannot start (`state_reason` says why) — a restore could not bring it back, even to the latest moment of its backups; another restore may be asked for.
|
|
417
|
+
*/
|
|
418
|
+
state: "archived" | "asleep" | "awake" | "failed" | "resizing" | "restoring" | "starting";
|
|
419
|
+
/**
|
|
420
|
+
* Why it is in its state, when that needs saying.
|
|
421
|
+
*/
|
|
422
|
+
state_reason?: string;
|
|
423
|
+
/**
|
|
424
|
+
* When it was deleted; it may be taken back until `purge_after`.
|
|
425
|
+
*/
|
|
426
|
+
deleted_at?: string;
|
|
427
|
+
/**
|
|
428
|
+
* When a deleted database, its volume and its backups are gone for good.
|
|
429
|
+
*/
|
|
430
|
+
purge_after?: string;
|
|
431
|
+
created_at: string;
|
|
432
|
+
updated_at: string;
|
|
433
|
+
/**
|
|
434
|
+
* How long it has run this month, in hours.
|
|
435
|
+
*/
|
|
436
|
+
awake_hours?: number;
|
|
437
|
+
/**
|
|
438
|
+
* How long its size lets it run in a month, in hours: past it, it sleeps until the month ends, and a client is told so. Absent for a size with no such limit.
|
|
439
|
+
*/
|
|
440
|
+
awake_hours_limit?: number;
|
|
441
|
+
/**
|
|
442
|
+
* How much it held when last measured — every database in it summed, the ones its owner made too — measured while it is awake. Absent before its first measure.
|
|
443
|
+
*/
|
|
444
|
+
used_bytes?: number;
|
|
445
|
+
/**
|
|
446
|
+
* The most its size holds. Past it, it is read-only.
|
|
447
|
+
*/
|
|
448
|
+
quota_bytes: number;
|
|
449
|
+
/**
|
|
450
|
+
* It holds its quota: a transaction takes no writes unless it asks to — BEGIN READ WRITE, to make room with DROP, TRUNCATE, or DELETE and then VACUUM FULL (a DELETE alone frees no room) — and it reads on. Once it holds less than 95% of its quota it takes writes again, within a minute.
|
|
451
|
+
*/
|
|
452
|
+
read_only: boolean;
|
|
453
|
+
/**
|
|
454
|
+
* A change of its passwords (POST …/password) has not reached the database yet: the new password works once this is false, a few seconds after. A client that hands the new password on waits for it.
|
|
455
|
+
*/
|
|
456
|
+
password_changing: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* What it has read from and written to its disk this month: its SAN volume's traffic, counted every minute from its node's device. Absent for a size on a premium disk, whose traffic is not counted.
|
|
459
|
+
*/
|
|
460
|
+
traffic_bytes?: number;
|
|
461
|
+
/**
|
|
462
|
+
* How much its size lets it read from and write to its disk in a month: past it, it sleeps until the month ends, and a client is told so. Absent for a size with no such limit.
|
|
463
|
+
*/
|
|
464
|
+
traffic_limit_bytes?: number;
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* A page of a project's databases, by name.
|
|
468
|
+
*/
|
|
469
|
+
export type DatabasePage = {
|
|
470
|
+
databases: Database[];
|
|
471
|
+
/**
|
|
472
|
+
* The cursor of the next page; absent on the last page.
|
|
473
|
+
*/
|
|
474
|
+
next_cursor?: string;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* A database to open.
|
|
478
|
+
*/
|
|
479
|
+
export type DatabaseCreate = {
|
|
480
|
+
/**
|
|
481
|
+
* The database's name; `main` when left out.
|
|
482
|
+
*/
|
|
483
|
+
name?: string;
|
|
484
|
+
/**
|
|
485
|
+
* The database's size; `free` when left out. free: 0.25 vCPU, 512 MiB, 1 GB, put to sleep when idle (woken by the next connection in about 10 s), awake 400 hours a month at most, archived after a week asleep (its next connection brings it back from its backup); hobby: 0.25 vCPU, 512 MiB, 5 GB, put to sleep when idle, no monthly limit; shared-1g: 1 GiB, up to 1 vCPU, 10 GB; shared-2g: 2 GiB, up to 2 vCPU, 25 GB; shared-4g: 4 GiB, up to 2 vCPU, 50 GB; dedicated-1x: 1 vCPU of its own, 4 GiB, 25 GB; dedicated-2x: 2 vCPU of its own, 8 GiB, 50 GB. The shared and dedicated sizes never sleep and live on a Premium SSD v2 disk of their own; free and hobby on the platform's SAN. A database past its size's storage turns read-only. What a project's machines and databases reserve between them is held to its limit: a size that does not fit is refused (409 `machines_over_limit`).
|
|
486
|
+
*/
|
|
487
|
+
size?: "dedicated-1x" | "dedicated-2x" | "free" | "hobby" | "shared-1g" | "shared-2g" | "shared-4g";
|
|
488
|
+
/**
|
|
489
|
+
* Who may connect, as addresses or CIDRs (203.0.113.7, 203.0.113.0/24), 50 at most; anyone with the password when empty.
|
|
490
|
+
*/
|
|
491
|
+
allow?: string[];
|
|
492
|
+
/**
|
|
493
|
+
* How many days the database's backups are kept: it can be brought back to any moment of them. 1 to 35.
|
|
494
|
+
*/
|
|
495
|
+
backup_days?: number;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* A change to a database; a field left out stays as it is.
|
|
499
|
+
*/
|
|
500
|
+
export type DatabaseUpdate = {
|
|
501
|
+
/**
|
|
502
|
+
* Who may connect, as addresses or CIDRs (203.0.113.7, 203.0.113.0/24), 50 at most; anyone with the password when empty.
|
|
503
|
+
*/
|
|
504
|
+
allow?: string[];
|
|
505
|
+
/**
|
|
506
|
+
* How many days the database's backups are kept: it can be brought back to any moment of them. 1 to 35.
|
|
507
|
+
*/
|
|
508
|
+
backup_days?: number;
|
|
509
|
+
/**
|
|
510
|
+
* The database's size (see `Database.size`); one that is paid for is open to the platform's own project and those named for it alone, as it is opened (403 `size_not_available`). One of the same machine and disk and no larger volume — hobby to free — changes in place. Any other moves through an instance of the new size beside the one that serves, made where the new size lives (a disk of its own, or a SAN volume of its own), which then takes over: the database serves on meanwhile (`state` resizing); its sessions on the direct port end once, when its primary moves, and new logins and transactions wait a few seconds for it. One asleep is woken for its move — its awake hours or disk traffic spent or not, when the size it moves to has no such limit; to one whose it has spent, it sleeps — and the move's time counts against none of them. One down for want of room, moved to a size of a larger volume, is given that room first, in place, and moves once it serves. A move that has not come to its switchover within two hours, and a second for every 10 MB the database holds, is let go: the database stays its size, and `state_reason` says why until its size is changed again — as is one whose primary went down three times before it came to its switchover. One whose primary moves where the move did not ask is stopped, both its instances kept (`state_reason`); onto its instance of the new size, ready — as a node drained moves it — it has come to its switchover. One whose instance of the new size does not take over within five minutes of its switchover says so in `state_reason`, and moves on once it does. Its disk never shrinks. While it moves it serves with the connections of the one of the two sizes that takes fewer; the machines given it are rolled out to their share of the new size's — at once when it takes fewer, once it has moved when it takes more. A size smaller than what it holds is refused (409 `database_too_large`), as is one of a smaller quota while what it holds is not measured yet (409 `database_not_measured`, Retry-After), and so is one the project's limit has no room for (409 `machines_over_limit`), a second free database (409 `free_database_taken`), or one whose connections are too few for the copies the machines given it run (409 `database_connections_short`).
|
|
511
|
+
*/
|
|
512
|
+
size?: "dedicated-1x" | "dedicated-2x" | "free" | "hobby" | "shared-1g" | "shared-2g" | "shared-4g";
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* Whose password is made new.
|
|
516
|
+
*/
|
|
517
|
+
export type PasswordChange = {
|
|
518
|
+
/**
|
|
519
|
+
* owner: the database's owner; app: the application's login, the one the machines given the database are started with.
|
|
520
|
+
*/
|
|
521
|
+
role: "app" | "owner";
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* One role's way in, ready to paste, with its password — in its URLs too — when the answer is the one that made it: a login whose password was made earlier carries no password, and [YOUR-PASSWORD] where it would be in its URLs.
|
|
525
|
+
*/
|
|
526
|
+
export type DatabaseLogin = {
|
|
527
|
+
/**
|
|
528
|
+
* The role's user name.
|
|
529
|
+
*/
|
|
530
|
+
user: string;
|
|
531
|
+
/**
|
|
532
|
+
* Its password, in the answer that made it alone: the answer that opened the database holds both logins', the one that made a password new holds that one. No answer holds it again.
|
|
533
|
+
*/
|
|
534
|
+
password?: string;
|
|
535
|
+
/**
|
|
536
|
+
* A URL straight to Postgres, TLS checked (sslmode=verify-full).
|
|
537
|
+
*/
|
|
538
|
+
url: string;
|
|
539
|
+
/**
|
|
540
|
+
* A URL through PgBouncer (transaction pooling): a session's SET, LISTEN and advisory locks do not hold there.
|
|
541
|
+
*/
|
|
542
|
+
pooled_url: string;
|
|
543
|
+
/**
|
|
544
|
+
* The user to connect as from a client that sends no TLS server name (libpq before 14, some drivers): the database it means rides on the user.
|
|
545
|
+
*/
|
|
546
|
+
user_for_clients_without_sni: string;
|
|
547
|
+
/**
|
|
548
|
+
* A psql command that connects.
|
|
549
|
+
*/
|
|
550
|
+
psql: string;
|
|
551
|
+
/**
|
|
552
|
+
* A JDBC URL.
|
|
553
|
+
*/
|
|
554
|
+
jdbc: string;
|
|
555
|
+
/**
|
|
556
|
+
* The two lines of a Prisma schema's env: the pooled URL for queries (DATABASE_URL), the direct one for migrations (DIRECT_URL).
|
|
557
|
+
*/
|
|
558
|
+
prisma_env: string;
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* How to connect to a database, with the passwords just made.
|
|
562
|
+
*/
|
|
563
|
+
export type DatabaseCredentials = {
|
|
564
|
+
/**
|
|
565
|
+
* Where it answers.
|
|
566
|
+
*/
|
|
567
|
+
host: string;
|
|
568
|
+
/**
|
|
569
|
+
* Its port straight to Postgres.
|
|
570
|
+
*/
|
|
571
|
+
port: number;
|
|
572
|
+
/**
|
|
573
|
+
* Its port through PgBouncer.
|
|
574
|
+
*/
|
|
575
|
+
pooled_port: number;
|
|
576
|
+
/**
|
|
577
|
+
* The Postgres database to connect to.
|
|
578
|
+
*/
|
|
579
|
+
database: string;
|
|
580
|
+
owner: DatabaseLogin;
|
|
581
|
+
app: DatabaseLogin;
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* A job the machine's program says it runs on a schedule. The platform calls it when it is due — POST /_palbase/jobs/<name> on the machine's own port, with {"job","run_id","scheduled_at","attempt"}, signed as a webhook is (Palbase-Signature) with the key in the machine's PALBASE_PLATFORM_SECRET — waking the machine for it; of a machine's copies one is called. A program says its jobs at GET /_palbase/jobs (asked once each version comes up); nothing from outside reaches /_palbase/ on a machine. One run of a job at a time: a job due again while its last run is not over is skipped. A 2xx answer is done, 404 is no such job in this version, anything else — or no answer within its timeout — is an attempt that failed, made again after 10 s, 20 s, … five minutes at most.
|
|
585
|
+
*/
|
|
586
|
+
export type Job = {
|
|
587
|
+
name: string;
|
|
588
|
+
/**
|
|
589
|
+
* Five fields, as cron's: minute hour day-of-month month day-of-week, in UTC.
|
|
590
|
+
*/
|
|
591
|
+
schedule: string;
|
|
592
|
+
/**
|
|
593
|
+
* How long an attempt has, in seconds.
|
|
594
|
+
*/
|
|
595
|
+
timeout: number;
|
|
596
|
+
/**
|
|
597
|
+
* How many more attempts a run has after its first fails.
|
|
598
|
+
*/
|
|
599
|
+
retries: number;
|
|
600
|
+
/**
|
|
601
|
+
* When it is next due.
|
|
602
|
+
*/
|
|
603
|
+
next_at: string;
|
|
604
|
+
last_run?: JobRun;
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* One run of a job: the same run (id, the program's run_id) through every attempt it took.
|
|
608
|
+
*/
|
|
609
|
+
export type JobRun = {
|
|
610
|
+
id: string;
|
|
611
|
+
/**
|
|
612
|
+
* When it was due.
|
|
613
|
+
*/
|
|
614
|
+
scheduled_at: string;
|
|
615
|
+
/**
|
|
616
|
+
* running: an attempt is with the machine; waiting: its last attempt failed and another is due; succeeded; failed: no attempt left; skipped: not run — its last run was not over, or the machine's version has no such job (reason).
|
|
617
|
+
*/
|
|
618
|
+
state: "running" | "waiting" | "succeeded" | "failed" | "skipped";
|
|
619
|
+
attempt: number;
|
|
620
|
+
/**
|
|
621
|
+
* Why an attempt failed, or why the run was skipped.
|
|
622
|
+
*/
|
|
623
|
+
reason?: string;
|
|
624
|
+
started_at: string;
|
|
625
|
+
finished_at?: string;
|
|
626
|
+
};
|
|
627
|
+
/**
|
|
628
|
+
* A machine's jobs, as its running version said them, by name.
|
|
629
|
+
*/
|
|
630
|
+
export type JobList = {
|
|
631
|
+
jobs: Job[];
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* A job's latest runs (50 at most), newest first; runs are kept for 7 days.
|
|
635
|
+
*/
|
|
636
|
+
export type JobRunList = {
|
|
637
|
+
runs: JobRun[];
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* One line a machine wrote — a line of the NDJSON answer of GET /machines/{name}/logs.
|
|
641
|
+
*/
|
|
642
|
+
export type MachineLogLine = {
|
|
643
|
+
/**
|
|
644
|
+
* When it was written, to the nanosecond.
|
|
645
|
+
*/
|
|
646
|
+
ts: string;
|
|
647
|
+
/**
|
|
648
|
+
* Tells two lines apart, and the same line read twice the same; ids sort as the lines do.
|
|
649
|
+
*/
|
|
650
|
+
id: string;
|
|
651
|
+
stream: "stdout" | "stderr";
|
|
652
|
+
/**
|
|
653
|
+
* The copy of the machine (or its migration run) that wrote it.
|
|
654
|
+
*/
|
|
655
|
+
pod: string;
|
|
656
|
+
/**
|
|
657
|
+
* The version of the machine the pod ran.
|
|
658
|
+
*/
|
|
659
|
+
generation: number;
|
|
660
|
+
/**
|
|
661
|
+
* The machine itself, or a migration run of it.
|
|
662
|
+
*/
|
|
663
|
+
source: "machine" | "migration";
|
|
664
|
+
line: string;
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* What a machine used, bucket by bucket, oldest first. A bucket none of whose minutes was measured is no row.
|
|
668
|
+
*/
|
|
669
|
+
export type MachineMetrics = {
|
|
670
|
+
/**
|
|
671
|
+
* What a row covers: the one asked for, or the window's own.
|
|
672
|
+
*/
|
|
673
|
+
bucket: "minute" | "hour" | "day";
|
|
674
|
+
limits: MachineLimits;
|
|
675
|
+
rows: MachineUsage[];
|
|
676
|
+
};
|
|
677
|
+
/**
|
|
678
|
+
* What the machine's size gives each copy now, and how many copies it runs while awake.
|
|
679
|
+
*/
|
|
680
|
+
export type MachineLimits = {
|
|
681
|
+
/**
|
|
682
|
+
* A copy's CPU ceiling, in millicores.
|
|
683
|
+
*/
|
|
684
|
+
cpu_millicores: number;
|
|
685
|
+
/**
|
|
686
|
+
* A copy's memory, in bytes.
|
|
687
|
+
*/
|
|
688
|
+
memory_bytes: number;
|
|
689
|
+
/**
|
|
690
|
+
* How many copies it runs while it is awake.
|
|
691
|
+
*/
|
|
692
|
+
replicas: number;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* One bucket of what a machine used. Every field is a gauge.
|
|
696
|
+
*/
|
|
697
|
+
export type MachineUsage = {
|
|
698
|
+
/**
|
|
699
|
+
* When the bucket begins, in Unix milliseconds (UTC).
|
|
700
|
+
*/
|
|
701
|
+
bucket_ms: number;
|
|
702
|
+
/**
|
|
703
|
+
* How many minutes were measured in the bucket.
|
|
704
|
+
*/
|
|
705
|
+
samples: number;
|
|
706
|
+
/**
|
|
707
|
+
* CPU, summed over its copies: the average of the minutes measured.
|
|
708
|
+
*/
|
|
709
|
+
cpu_avg_millicores: number;
|
|
710
|
+
/**
|
|
711
|
+
* CPU, summed over its copies: the most of a minute measured.
|
|
712
|
+
*/
|
|
713
|
+
cpu_max_millicores: number;
|
|
714
|
+
/**
|
|
715
|
+
* Memory (the working set), summed over its copies: the average of the minutes measured.
|
|
716
|
+
*/
|
|
717
|
+
memory_avg_bytes: number;
|
|
718
|
+
/**
|
|
719
|
+
* Memory (the working set), summed over its copies: the most of a minute measured.
|
|
720
|
+
*/
|
|
721
|
+
memory_max_bytes: number;
|
|
722
|
+
/**
|
|
723
|
+
* The most copies that ran in a minute measured.
|
|
724
|
+
*/
|
|
725
|
+
replicas_max: number;
|
|
726
|
+
/**
|
|
727
|
+
* The most CPU one copy used in a minute measured: what limits.cpu_millicores holds it to.
|
|
728
|
+
*/
|
|
729
|
+
cpu_replica_max_millicores: number;
|
|
730
|
+
/**
|
|
731
|
+
* The most memory one copy used in a minute measured: what limits.memory_bytes holds it to.
|
|
732
|
+
*/
|
|
733
|
+
memory_replica_max_bytes: number;
|
|
734
|
+
};
|
|
735
|
+
/**
|
|
736
|
+
* A database's usage, bucket by bucket, oldest first. A bucket in which nothing was counted or measured is no row.
|
|
737
|
+
*/
|
|
738
|
+
export type DatabaseMetrics = {
|
|
739
|
+
/**
|
|
740
|
+
* What a row covers: the one asked for, or the window's own.
|
|
741
|
+
*/
|
|
742
|
+
bucket: "hour" | "day";
|
|
743
|
+
limits: DatabaseLimits;
|
|
744
|
+
rows: DatabaseUsage[];
|
|
745
|
+
};
|
|
746
|
+
/**
|
|
747
|
+
* What the database's size holds at most, and the connections it takes.
|
|
748
|
+
*/
|
|
749
|
+
export type DatabaseLimits = {
|
|
750
|
+
/**
|
|
751
|
+
* The most it holds (its quota): past it, it is read-only.
|
|
752
|
+
*/
|
|
753
|
+
size_bytes: number;
|
|
754
|
+
/**
|
|
755
|
+
* The connections it takes (Postgres' max_connections).
|
|
756
|
+
*/
|
|
757
|
+
connections: number;
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* One bucket of a database's usage.
|
|
761
|
+
*/
|
|
762
|
+
export type DatabaseUsage = {
|
|
763
|
+
/**
|
|
764
|
+
* When the bucket begins, in Unix milliseconds (UTC).
|
|
765
|
+
*/
|
|
766
|
+
bucket_ms: number;
|
|
767
|
+
/**
|
|
768
|
+
* A gauge: what it held as last measured in the bucket. Absent when it was not measured in it (it slept).
|
|
769
|
+
*/
|
|
770
|
+
size_bytes?: number;
|
|
771
|
+
/**
|
|
772
|
+
* A counter: what of its disk traffic — its own, its archive's padding taken off — was counted in the bucket. Absent for a database of a size on a premium disk, whose traffic is not counted.
|
|
773
|
+
*/
|
|
774
|
+
traffic_bytes?: number;
|
|
775
|
+
/**
|
|
776
|
+
* A counter: how much of its awake time was counted in the bucket, in seconds.
|
|
777
|
+
*/
|
|
778
|
+
awake_seconds: number;
|
|
779
|
+
/**
|
|
780
|
+
* A gauge: the most of its clients' connections to Postgres seen in the bucket. Absent when none was seen (it slept).
|
|
781
|
+
*/
|
|
782
|
+
connections_max?: number;
|
|
783
|
+
};
|
|
784
|
+
/**
|
|
785
|
+
* The database a machine is given: the machine is started with where it answers (PALBASE_DB_URL), by the application's login, and with how many connections to it a copy may hold (PALBASE_DB_CONNECTIONS) — a share of what the database's size allows, the copies of every machine given it counted twice (a new version comes up beside the one that serves) and a migration run's share apart. Copies those would not serve are refused (409 `database_connections_short`); the other machines given it roll out to their new share. A change gives it whole: `migrations` left out is false.
|
|
786
|
+
*/
|
|
787
|
+
export type MachineDatabase = {
|
|
788
|
+
/**
|
|
789
|
+
* The name of one of the project's databases; "" (with no migrations) gives the machine none.
|
|
790
|
+
*/
|
|
791
|
+
name: string;
|
|
792
|
+
/**
|
|
793
|
+
* The machine's releases run their migrations against the database before they serve (a Palbase backend's); they are run as the database's owner. A database's migrations are one machine's: a second machine asking for them is refused (409 `database_migrated_elsewhere`).
|
|
794
|
+
*/
|
|
795
|
+
migrations?: boolean;
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* When to bring the database back to.
|
|
799
|
+
*/
|
|
800
|
+
export type DatabaseRestore = {
|
|
801
|
+
/**
|
|
802
|
+
* The moment, as an RFC 3339 time.
|
|
803
|
+
*/
|
|
804
|
+
to: string;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* One role's way in, ready to paste, without its password: [YOUR-PASSWORD] stands where it would be in its URLs.
|
|
808
|
+
*/
|
|
809
|
+
export type DatabaseRoleConnection = {
|
|
810
|
+
/**
|
|
811
|
+
* The role's user name.
|
|
812
|
+
*/
|
|
813
|
+
user: string;
|
|
814
|
+
/**
|
|
815
|
+
* A URL straight to Postgres, TLS checked (sslmode=verify-full), [YOUR-PASSWORD] in its password's place.
|
|
816
|
+
*/
|
|
817
|
+
url: string;
|
|
818
|
+
/**
|
|
819
|
+
* A URL through PgBouncer (transaction pooling): a session's SET, LISTEN and advisory locks do not hold there.
|
|
820
|
+
*/
|
|
821
|
+
pooled_url: string;
|
|
822
|
+
/**
|
|
823
|
+
* The user to connect as from a client that sends no TLS server name (libpq before 14, some drivers): the database it means rides on the user.
|
|
824
|
+
*/
|
|
825
|
+
user_for_clients_without_sni: string;
|
|
826
|
+
/**
|
|
827
|
+
* A psql command that connects.
|
|
828
|
+
*/
|
|
829
|
+
psql: string;
|
|
830
|
+
/**
|
|
831
|
+
* A JDBC URL.
|
|
832
|
+
*/
|
|
833
|
+
jdbc: string;
|
|
834
|
+
/**
|
|
835
|
+
* The two lines of a Prisma schema's env: the pooled URL for queries (DATABASE_URL), the direct one for migrations (DIRECT_URL).
|
|
836
|
+
*/
|
|
837
|
+
prisma_env: string;
|
|
838
|
+
};
|
|
839
|
+
/**
|
|
840
|
+
* How to connect to a database, without its passwords — they are shown once, when they are made: [YOUR-PASSWORD] stands in their place.
|
|
841
|
+
*/
|
|
842
|
+
export type DatabaseConnection = {
|
|
843
|
+
/**
|
|
844
|
+
* Where it answers.
|
|
845
|
+
*/
|
|
846
|
+
host: string;
|
|
847
|
+
/**
|
|
848
|
+
* Its port straight to Postgres.
|
|
849
|
+
*/
|
|
850
|
+
port: number;
|
|
851
|
+
/**
|
|
852
|
+
* Its port through PgBouncer.
|
|
853
|
+
*/
|
|
854
|
+
pooled_port: number;
|
|
855
|
+
/**
|
|
856
|
+
* The Postgres database to connect to.
|
|
857
|
+
*/
|
|
858
|
+
database: string;
|
|
859
|
+
owner: DatabaseRoleConnection;
|
|
860
|
+
app: DatabaseRoleConnection;
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* A database just opened, with its credentials: the one answer that holds both its passwords.
|
|
864
|
+
*/
|
|
865
|
+
export type DatabaseCreated = {
|
|
866
|
+
/**
|
|
867
|
+
* The database's name.
|
|
868
|
+
*/
|
|
869
|
+
name: string;
|
|
870
|
+
/**
|
|
871
|
+
* Where it answers: <name>-<ref>.<the databases' domain>.
|
|
872
|
+
*/
|
|
873
|
+
host: string;
|
|
874
|
+
/**
|
|
875
|
+
* Its port straight to Postgres.
|
|
876
|
+
*/
|
|
877
|
+
port: number;
|
|
878
|
+
/**
|
|
879
|
+
* Its port through PgBouncer (transaction pooling): for clients that open a connection for each request.
|
|
880
|
+
*/
|
|
881
|
+
pooled_port: number;
|
|
882
|
+
/**
|
|
883
|
+
* The database's size. free: 0.25 vCPU, 512 MiB, 1 GB, put to sleep when idle (woken by the next connection in about 10 s), awake 400 hours a month at most, archived after a week asleep (its next connection brings it back from its backup); hobby: 0.25 vCPU, 512 MiB, 5 GB, put to sleep when idle, no monthly limit; shared-1g: 1 GiB, up to 1 vCPU, 10 GB; shared-2g: 2 GiB, up to 2 vCPU, 25 GB; shared-4g: 4 GiB, up to 2 vCPU, 50 GB; dedicated-1x: 1 vCPU of its own, 4 GiB, 25 GB; dedicated-2x: 2 vCPU of its own, 8 GiB, 50 GB. The shared and dedicated sizes never sleep and live on a Premium SSD v2 disk of their own; free and hobby on the platform's SAN. A database past its size's storage turns read-only. What a project's machines and databases reserve between them is held to its limit: a size that does not fit is refused (409 `machines_over_limit`).
|
|
884
|
+
*/
|
|
885
|
+
size: "dedicated-1x" | "dedicated-2x" | "free" | "hobby" | "shared-1g" | "shared-2g" | "shared-4g";
|
|
886
|
+
/**
|
|
887
|
+
* Where its data lives, as its size says: san, the platform's SAN; premium, a Premium SSD v2 disk of its own.
|
|
888
|
+
*/
|
|
889
|
+
disk: "premium" | "san";
|
|
890
|
+
/**
|
|
891
|
+
* Who may connect, as addresses or CIDRs (203.0.113.7, 203.0.113.0/24), 50 at most; anyone with the password when empty.
|
|
892
|
+
*/
|
|
893
|
+
allow: string[];
|
|
894
|
+
/**
|
|
895
|
+
* How many days the database's backups are kept: it can be brought back to any moment of them. 1 to 35.
|
|
896
|
+
*/
|
|
897
|
+
backup_days: number;
|
|
898
|
+
/**
|
|
899
|
+
* starting: on its way up; awake: answering; asleep: idle, woken by the next connection; archived: asleep for a week, its next connection brings it back from its backup; restoring: being brought back to a moment of its backups; failed: it cannot start (`state_reason` says why) — a restore could not bring it back, even to the latest moment of its backups; another restore may be asked for.
|
|
900
|
+
*/
|
|
901
|
+
state: "archived" | "asleep" | "awake" | "failed" | "restoring" | "starting";
|
|
902
|
+
/**
|
|
903
|
+
* Why it is in its state, when that needs saying.
|
|
904
|
+
*/
|
|
905
|
+
state_reason?: string;
|
|
906
|
+
/**
|
|
907
|
+
* When it was deleted; it may be taken back until `purge_after`.
|
|
908
|
+
*/
|
|
909
|
+
deleted_at?: string;
|
|
910
|
+
/**
|
|
911
|
+
* When a deleted database, its volume and its backups are gone for good.
|
|
912
|
+
*/
|
|
913
|
+
purge_after?: string;
|
|
914
|
+
created_at: string;
|
|
915
|
+
updated_at: string;
|
|
916
|
+
/**
|
|
917
|
+
* How long it has run this month, in hours.
|
|
918
|
+
*/
|
|
919
|
+
awake_hours?: number;
|
|
920
|
+
/**
|
|
921
|
+
* How long its size lets it run in a month, in hours: past it, it sleeps until the month ends, and a client is told so. Absent for a size with no such limit.
|
|
922
|
+
*/
|
|
923
|
+
awake_hours_limit?: number;
|
|
924
|
+
/**
|
|
925
|
+
* How much it held when last measured — every database in it summed, the ones its owner made too — measured while it is awake. Absent before its first measure.
|
|
926
|
+
*/
|
|
927
|
+
used_bytes?: number;
|
|
928
|
+
/**
|
|
929
|
+
* The most its size holds. Past it, it is read-only.
|
|
930
|
+
*/
|
|
931
|
+
quota_bytes: number;
|
|
932
|
+
/**
|
|
933
|
+
* It holds its quota: a transaction takes no writes unless it asks to — BEGIN READ WRITE, to make room with DROP, TRUNCATE, or DELETE and then VACUUM FULL (a DELETE alone frees no room) — and it reads on. Once it holds less than 95% of its quota it takes writes again, within a minute.
|
|
934
|
+
*/
|
|
935
|
+
read_only: boolean;
|
|
936
|
+
/**
|
|
937
|
+
* A change of its passwords (POST …/password) has not reached the database yet: the new password works once this is false, a few seconds after. A client that hands the new password on waits for it.
|
|
938
|
+
*/
|
|
939
|
+
password_changing: boolean;
|
|
940
|
+
/**
|
|
941
|
+
* What it has read from and written to its disk this month: its SAN volume's traffic, counted every minute from its node's device. Absent for a size on a premium disk, whose traffic is not counted.
|
|
942
|
+
*/
|
|
943
|
+
traffic_bytes?: number;
|
|
944
|
+
/**
|
|
945
|
+
* How much its size lets it read from and write to its disk in a month: past it, it sleeps until the month ends, and a client is told so. Absent for a size with no such limit.
|
|
946
|
+
*/
|
|
947
|
+
traffic_limit_bytes?: number;
|
|
948
|
+
credentials: DatabaseCredentials;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* A database's tables, by schema then name.
|
|
952
|
+
*/
|
|
953
|
+
export type DatabaseSchema = {
|
|
954
|
+
tables: DatabaseTable[];
|
|
955
|
+
};
|
|
956
|
+
/**
|
|
957
|
+
* A table of a database.
|
|
958
|
+
*/
|
|
959
|
+
export type DatabaseTable = {
|
|
960
|
+
/**
|
|
961
|
+
* The table's name: bare in public, schema.table in any other schema.
|
|
962
|
+
*/
|
|
963
|
+
name: string;
|
|
964
|
+
/**
|
|
965
|
+
* Row-level security is on for it.
|
|
966
|
+
*/
|
|
967
|
+
rls: boolean;
|
|
968
|
+
/**
|
|
969
|
+
* Its columns, in its order.
|
|
970
|
+
*/
|
|
971
|
+
columns: DatabaseColumn[];
|
|
972
|
+
};
|
|
973
|
+
/**
|
|
974
|
+
* A column of a table.
|
|
975
|
+
*/
|
|
976
|
+
export type DatabaseColumn = {
|
|
977
|
+
name: string;
|
|
978
|
+
/**
|
|
979
|
+
* Its type as Postgres writes it (format_type): varchar(40), timestamp with time zone, integer[].
|
|
980
|
+
*/
|
|
981
|
+
type: string;
|
|
982
|
+
/**
|
|
983
|
+
* It takes NULL.
|
|
984
|
+
*/
|
|
985
|
+
nullable: boolean;
|
|
986
|
+
/**
|
|
987
|
+
* It is of the table's primary key.
|
|
988
|
+
*/
|
|
989
|
+
primary_key: boolean;
|
|
990
|
+
/**
|
|
991
|
+
* The column a foreign key of it points at, as table.column (its table named as a table is: schema.table.column outside public). Absent when none does.
|
|
992
|
+
*/
|
|
993
|
+
references?: string;
|
|
994
|
+
};
|
|
995
|
+
/**
|
|
996
|
+
* A statement for the console.
|
|
997
|
+
*/
|
|
998
|
+
export type DatabaseQuery = {
|
|
999
|
+
/**
|
|
1000
|
+
* One statement, 64 KiB at most.
|
|
1001
|
+
*/
|
|
1002
|
+
sql: string;
|
|
1003
|
+
/**
|
|
1004
|
+
* How many of its rows to answer, 1 to 1000; a value outside that range is refused.
|
|
1005
|
+
*/
|
|
1006
|
+
limit?: number;
|
|
1007
|
+
};
|
|
1008
|
+
/**
|
|
1009
|
+
* What a statement answered.
|
|
1010
|
+
*/
|
|
1011
|
+
export type DatabaseQueryResult = {
|
|
1012
|
+
/**
|
|
1013
|
+
* Its columns' names, in order; two may share a name.
|
|
1014
|
+
*/
|
|
1015
|
+
columns: string[];
|
|
1016
|
+
/**
|
|
1017
|
+
* Its rows, each an array of its values in the columns' order.
|
|
1018
|
+
*/
|
|
1019
|
+
rows: unknown[][];
|
|
1020
|
+
/**
|
|
1021
|
+
* How many rows are in rows.
|
|
1022
|
+
*/
|
|
1023
|
+
row_count: number;
|
|
1024
|
+
/**
|
|
1025
|
+
* The statement answered more rows than limit.
|
|
1026
|
+
*/
|
|
1027
|
+
truncated: boolean;
|
|
1028
|
+
/**
|
|
1029
|
+
* How long the statement took, in milliseconds.
|
|
1030
|
+
*/
|
|
1031
|
+
duration_ms: number;
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* A statement Postgres refused: the error envelope, with its SQLSTATE.
|
|
1035
|
+
*/
|
|
1036
|
+
export type DatabaseQueryError = {
|
|
1037
|
+
/**
|
|
1038
|
+
* Machine-readable error code (snake_case)
|
|
1039
|
+
*/
|
|
1040
|
+
error: string;
|
|
1041
|
+
/**
|
|
1042
|
+
* Postgres' message
|
|
1043
|
+
*/
|
|
1044
|
+
error_description: string;
|
|
1045
|
+
/**
|
|
1046
|
+
* Correlation ID for log/audit lookup
|
|
1047
|
+
*/
|
|
1048
|
+
request_id: string;
|
|
1049
|
+
/**
|
|
1050
|
+
* Seconds to wait before retrying; present on a refusal that ends with time.
|
|
1051
|
+
*/
|
|
1052
|
+
retry_after?: number;
|
|
1053
|
+
/**
|
|
1054
|
+
* HTTP status code (mirrors the response status)
|
|
1055
|
+
*/
|
|
1056
|
+
status: number;
|
|
1057
|
+
/**
|
|
1058
|
+
* The SQLSTATE Postgres refused it with (25006: a write in the read-only transaction; 42601: a syntax error, or more than one statement; 57014: out of time).
|
|
1059
|
+
*/
|
|
1060
|
+
sqlstate: string;
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* A statement refused: by Postgres, or as it was asked.
|
|
1064
|
+
*/
|
|
1065
|
+
export type DatabaseQueryRefusal = ErrorResponse | DatabaseQueryError;
|
|
1066
|
+
export type MachineSize = {
|
|
1067
|
+
/**
|
|
1068
|
+
* The size's name, as `size` names it.
|
|
1069
|
+
*/
|
|
1070
|
+
name: string;
|
|
1071
|
+
/**
|
|
1072
|
+
* shared: a fraction of a CPU as its ceiling, put to sleep when idle; dedicated: whole CPUs of its own, never asleep.
|
|
1073
|
+
*/
|
|
1074
|
+
class: "shared" | "dedicated";
|
|
1075
|
+
/**
|
|
1076
|
+
* Its CPU ceiling, in CPUs.
|
|
1077
|
+
*/
|
|
1078
|
+
vcpu: number;
|
|
1079
|
+
/**
|
|
1080
|
+
* Its memory, its own in either class.
|
|
1081
|
+
*/
|
|
1082
|
+
memory_mib: number;
|
|
1083
|
+
/**
|
|
1084
|
+
* How much it may write to its own disk.
|
|
1085
|
+
*/
|
|
1086
|
+
disk_mib: number;
|
|
1087
|
+
/**
|
|
1088
|
+
* An idle machine of this size is put to sleep, and woken by its next request.
|
|
1089
|
+
*/
|
|
1090
|
+
sleeps: boolean;
|
|
1091
|
+
/**
|
|
1092
|
+
* A size open to every project; the others are paid for.
|
|
1093
|
+
*/
|
|
1094
|
+
free: boolean;
|
|
1095
|
+
/**
|
|
1096
|
+
* This project may open one of this size now (for a machine: open one, or move one to it).
|
|
1097
|
+
*/
|
|
1098
|
+
available: boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* Why the size is not open to this project; absent when it is.
|
|
1101
|
+
*/
|
|
1102
|
+
reason?: string;
|
|
1103
|
+
};
|
|
1104
|
+
export type MachineSizeList = {
|
|
1105
|
+
/**
|
|
1106
|
+
* Every machine size, smallest first.
|
|
1107
|
+
*/
|
|
1108
|
+
sizes: MachineSize[];
|
|
1109
|
+
};
|
|
1110
|
+
export type MachineNetwork = {
|
|
1111
|
+
/**
|
|
1112
|
+
* Where a machine's connections to the internet leave from: ranges (CIDR, such as 203.0.113.8/29) or addresses. An allowlist names each whole range: a connection may leave from any address in it.
|
|
1113
|
+
*/
|
|
1114
|
+
outbound_ips: string[];
|
|
1115
|
+
/**
|
|
1116
|
+
* Every Palbase machine, of every project, leaves from these addresses: an allowlist of them does not tell projects apart.
|
|
1117
|
+
*/
|
|
1118
|
+
shared: boolean;
|
|
1119
|
+
};
|
|
1120
|
+
export type DatabaseSize = {
|
|
1121
|
+
/**
|
|
1122
|
+
* The size's name, as `size` names it.
|
|
1123
|
+
*/
|
|
1124
|
+
name: string;
|
|
1125
|
+
/**
|
|
1126
|
+
* Its CPU ceiling, in CPUs.
|
|
1127
|
+
*/
|
|
1128
|
+
vcpu: number;
|
|
1129
|
+
/**
|
|
1130
|
+
* Its memory.
|
|
1131
|
+
*/
|
|
1132
|
+
memory_mib: number;
|
|
1133
|
+
/**
|
|
1134
|
+
* The most it may hold; past it it turns read-only.
|
|
1135
|
+
*/
|
|
1136
|
+
storage_bytes: number;
|
|
1137
|
+
/**
|
|
1138
|
+
* An idle database of this size is put to sleep, and woken by its next connection.
|
|
1139
|
+
*/
|
|
1140
|
+
sleeps: boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* How long it may be awake in a month; absent for no limit. Past it it sleeps until the month ends.
|
|
1143
|
+
*/
|
|
1144
|
+
awake_hours_per_month?: number;
|
|
1145
|
+
/**
|
|
1146
|
+
* How much it may read from and write to its disk in a month; absent for no limit.
|
|
1147
|
+
*/
|
|
1148
|
+
traffic_bytes_per_month?: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* A week asleep, its volume is taken back and its next connection brings it back from its backup.
|
|
1151
|
+
*/
|
|
1152
|
+
archives: boolean;
|
|
1153
|
+
/**
|
|
1154
|
+
* A size counted against the project's free databases; the others are paid for.
|
|
1155
|
+
*/
|
|
1156
|
+
free: boolean;
|
|
1157
|
+
/**
|
|
1158
|
+
* This project may open one of this size now (for a machine: open one, or move one to it).
|
|
1159
|
+
*/
|
|
1160
|
+
available: boolean;
|
|
1161
|
+
/**
|
|
1162
|
+
* Why the size is not open to this project; absent when it is.
|
|
1163
|
+
*/
|
|
1164
|
+
reason?: string;
|
|
1165
|
+
};
|
|
1166
|
+
export type DatabaseSizeList = {
|
|
1167
|
+
/**
|
|
1168
|
+
* Every database size, the ones that sleep first.
|
|
1169
|
+
*/
|
|
1170
|
+
sizes: DatabaseSize[];
|
|
1171
|
+
};
|
|
1172
|
+
/** Palbase Machines */
|
|
1173
|
+
export declare function client(t: Transport): {
|
|
1174
|
+
/**
|
|
1175
|
+
* List machines
|
|
1176
|
+
*
|
|
1177
|
+
* Lists the project's machines, by name.
|
|
1178
|
+
*/
|
|
1179
|
+
listMachines(input?: {
|
|
1180
|
+
query?: {
|
|
1181
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
1182
|
+
cursor?: string;
|
|
1183
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1184
|
+
signal?: AbortSignal;
|
|
1185
|
+
}): Promise<Reply<200, MachinePage>>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Open a machine
|
|
1188
|
+
*
|
|
1189
|
+
* Opens a machine, built from a branch of a repository one of the project's installations of Palbase Cloud reaches: the branch's head is built at once, and every push to it after that changes what the machine is built from (its source's context, else its path). With `deploy_after_checks` a push is built once its commit's checks have passed. The answer's state is `building`; the machine answers at its `url` once its first build is up. A project has 5 machines at most; a name is one machine's. Emits `machine.created`. A machine may be given one of the project's databases (`database`): it is started with where the database answers, a database that is not the project's is refused (400 `database_not_found`), and so are its migrations while another machine runs them (409 `database_migrated_elsewhere`).
|
|
1190
|
+
*/
|
|
1191
|
+
createMachine(input: {
|
|
1192
|
+
body: MachineCreate; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1193
|
+
signal?: AbortSignal;
|
|
1194
|
+
}): Promise<Reply<201, Machine>>;
|
|
1195
|
+
/**
|
|
1196
|
+
* List machine sizes
|
|
1197
|
+
*
|
|
1198
|
+
* Every machine size, smallest first: what a machine of it is given, whether it sleeps when idle, and whether this project may open or move a machine to it now. A size that is not open says why (`reason`): a size that is paid for is open to a project that may pay. The list is the module's, not the client's: a client offers what this answers.
|
|
1199
|
+
*/
|
|
1200
|
+
listMachineSizes(input?: {
|
|
1201
|
+
signal?: AbortSignal;
|
|
1202
|
+
}): Promise<Reply<200, MachineSizeList>>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Get where machines reach the internet from
|
|
1205
|
+
*
|
|
1206
|
+
* The addresses a machine's connections to the internet leave from: what a provider's allowlist names (a bank's, a payment or SMS provider's). They are shared: every Palbase machine, of every project, leaves from them — an allowlist of them says "from Palbase", not "from this project", so a provider still knows a project by its own credentials. They stay the same as the platform changes; a change of them is announced before it is made.
|
|
1207
|
+
*/
|
|
1208
|
+
getMachineNetwork(input?: {
|
|
1209
|
+
signal?: AbortSignal;
|
|
1210
|
+
}): Promise<Reply<200, MachineNetwork>>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Connect GitHub
|
|
1213
|
+
*
|
|
1214
|
+
* Answers where the project's owner installs Palbase Cloud on the GitHub account whose repositories machines are built from. Back from GitHub, the user is shown the account and the repositories of it they can push to, and connects them to the project by writing its ref. The link holds 15 minutes.
|
|
1215
|
+
*/
|
|
1216
|
+
connectGitHub(input?: {
|
|
1217
|
+
signal?: AbortSignal;
|
|
1218
|
+
}): Promise<Reply<200, Connect>>;
|
|
1219
|
+
/**
|
|
1220
|
+
* List installations
|
|
1221
|
+
*
|
|
1222
|
+
* The project's installations of Palbase Cloud.
|
|
1223
|
+
*/
|
|
1224
|
+
listInstallations(input?: {
|
|
1225
|
+
signal?: AbortSignal;
|
|
1226
|
+
}): Promise<Reply<200, InstallationList>>;
|
|
1227
|
+
/**
|
|
1228
|
+
* Connect an installation
|
|
1229
|
+
*
|
|
1230
|
+
* Connects an installation of Palbase Cloud the user reaches, with the user's own GitHub token for the App (a CLI's device flow): the project reaches the repositories of it that user can push to — connected again, what they can push to now. Refused when GitHub says the user cannot reach it, or push to any repository of it. The user taking their authorization of the App back on GitHub disconnects what they connected.
|
|
1231
|
+
*/
|
|
1232
|
+
linkInstallation(input: {
|
|
1233
|
+
body: InstallationLink; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1234
|
+
signal?: AbortSignal;
|
|
1235
|
+
}): Promise<Reply<201, Installation>>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Disconnect an installation
|
|
1238
|
+
*
|
|
1239
|
+
* Disconnects one of the project's installations; refused while a machine is built from it.
|
|
1240
|
+
*/
|
|
1241
|
+
unlinkInstallation(input: {
|
|
1242
|
+
path: {
|
|
1243
|
+
installation: number;
|
|
1244
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1245
|
+
signal?: AbortSignal;
|
|
1246
|
+
}): Promise<Reply<204, undefined>>;
|
|
1247
|
+
/**
|
|
1248
|
+
* List repositories
|
|
1249
|
+
*
|
|
1250
|
+
* Every repository the project's installations reach — of each, those the user who connected it could reach: what a machine may be built from.
|
|
1251
|
+
*/
|
|
1252
|
+
listRepositories(input?: {
|
|
1253
|
+
signal?: AbortSignal;
|
|
1254
|
+
}): Promise<Reply<200, RepositoryList>>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Read a machine
|
|
1257
|
+
*
|
|
1258
|
+
* Reads one machine: what was asked for, and what runs.
|
|
1259
|
+
*/
|
|
1260
|
+
getMachine(input: {
|
|
1261
|
+
path: {
|
|
1262
|
+
name: string;
|
|
1263
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1264
|
+
signal?: AbortSignal;
|
|
1265
|
+
}): Promise<Reply<200, Machine>>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Delete a machine
|
|
1268
|
+
*
|
|
1269
|
+
* Takes the machine away: its address stops answering, and its name is free at once. Emits `machine.deleted`.
|
|
1270
|
+
*/
|
|
1271
|
+
deleteMachine(input: {
|
|
1272
|
+
path: {
|
|
1273
|
+
name: string;
|
|
1274
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1275
|
+
signal?: AbortSignal;
|
|
1276
|
+
}): Promise<Reply<204, undefined>>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Change a machine
|
|
1279
|
+
*
|
|
1280
|
+
* Changes the machine's source, size, port, env, secrets or whether a push waits for its commit's checks (`deploy_after_checks`) and for which (`deploy_checks`, `deploy_checks_app`). A new size, port, env or secrets rolls out beside the version that serves; a new source is built, and rolls out once its build is up. Emits `machine.updated`. A machine may be given one of the project's databases (`database`): it is started with where the database answers, a database that is not the project's is refused (400 `database_not_found`), and so are its migrations while another machine runs them (409 `database_migrated_elsewhere`).
|
|
1281
|
+
*/
|
|
1282
|
+
updateMachine(input: {
|
|
1283
|
+
path: {
|
|
1284
|
+
name: string;
|
|
1285
|
+
};
|
|
1286
|
+
headers?: {
|
|
1287
|
+
"If-Match"?: string;
|
|
1288
|
+
};
|
|
1289
|
+
body: MachineUpdate; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1290
|
+
signal?: AbortSignal;
|
|
1291
|
+
}): Promise<Reply<200, Machine>>;
|
|
1292
|
+
/**
|
|
1293
|
+
* List a machine's builds
|
|
1294
|
+
*
|
|
1295
|
+
* A machine's builds, newest first: every commit of its branch built for it, and what became of each.
|
|
1296
|
+
*/
|
|
1297
|
+
listBuilds(input: {
|
|
1298
|
+
path: {
|
|
1299
|
+
name: string;
|
|
1300
|
+
};
|
|
1301
|
+
query?: {
|
|
1302
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
1303
|
+
cursor?: string;
|
|
1304
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1305
|
+
signal?: AbortSignal;
|
|
1306
|
+
}): Promise<Reply<200, BuildPage>>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Build and roll out the branch's head
|
|
1309
|
+
*
|
|
1310
|
+
* Asks for a build of the head of the machine's branch now (a manual deploy): the build is queued, and rolled out beside the version serving once it succeeds. A head built before is built again — its build failed on something passing, or what it pulls in changed. Asked again before the build starts, it is that one build. The machine's `build_requested` is true until the build is queued; its newest build is then the one asked for. The project's builds a day hold for it as for a push.
|
|
1311
|
+
*/
|
|
1312
|
+
deployMachine(input: {
|
|
1313
|
+
path: {
|
|
1314
|
+
name: string;
|
|
1315
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1316
|
+
signal?: AbortSignal;
|
|
1317
|
+
}): Promise<Reply<202, Machine>>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Read a build
|
|
1320
|
+
*
|
|
1321
|
+
* One build of the machine.
|
|
1322
|
+
*/
|
|
1323
|
+
getBuild(input: {
|
|
1324
|
+
path: {
|
|
1325
|
+
name: string; /** The build's id. */
|
|
1326
|
+
build: string;
|
|
1327
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1328
|
+
signal?: AbortSignal;
|
|
1329
|
+
}): Promise<Reply<200, Build>>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Read a build's log
|
|
1332
|
+
*
|
|
1333
|
+
* The build's log, its last MiB: where a failure is. There once the build has started (log_not_ready before, while it waits for its checks too); a build that ended before it ran has none (no_log).
|
|
1334
|
+
*/
|
|
1335
|
+
getBuildLog(input: {
|
|
1336
|
+
path: {
|
|
1337
|
+
name: string; /** The build's id. */
|
|
1338
|
+
build: string;
|
|
1339
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1340
|
+
signal?: AbortSignal;
|
|
1341
|
+
}): Promise<Reply<200, Response>>;
|
|
1342
|
+
/**
|
|
1343
|
+
* Return to a build
|
|
1344
|
+
*
|
|
1345
|
+
* Returns the machine to one of its builds that succeeded: a new version, rolled out beside the one that serves. The only change of what a machine runs not made by a push. Emits `machine.updated`.
|
|
1346
|
+
*/
|
|
1347
|
+
rollbackMachine(input: {
|
|
1348
|
+
path: {
|
|
1349
|
+
name: string;
|
|
1350
|
+
};
|
|
1351
|
+
body: Rollback; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1352
|
+
signal?: AbortSignal;
|
|
1353
|
+
}): Promise<Reply<200, Machine>>;
|
|
1354
|
+
/**
|
|
1355
|
+
* List the databases
|
|
1356
|
+
*
|
|
1357
|
+
* Lists the project's databases by name, deleted ones that may still be taken back among them.
|
|
1358
|
+
*/
|
|
1359
|
+
listDatabases(input?: {
|
|
1360
|
+
query?: {
|
|
1361
|
+
limit?: number; /** The next_cursor of the previous page. Opaque; omit it for the first page. */
|
|
1362
|
+
cursor?: string;
|
|
1363
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1364
|
+
signal?: AbortSignal;
|
|
1365
|
+
}): Promise<Reply<200, DatabasePage>>;
|
|
1366
|
+
/**
|
|
1367
|
+
* Open a database
|
|
1368
|
+
*
|
|
1369
|
+
* Opens a database: its volume is made and it starts; it answers once its state is awake. The answer holds its owner's and its application's passwords, shown this once: no answer holds them again (a new one is made with POST /databases/{name}/password). A project has one database of a free size at a time. A size that is paid for is not open yet — none is charged for — but to the platform's own project and those named for it: another project is refused (403 `size_not_available`). Emits `database.created`.
|
|
1370
|
+
*/
|
|
1371
|
+
createDatabase(input: {
|
|
1372
|
+
body: DatabaseCreate; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1373
|
+
signal?: AbortSignal;
|
|
1374
|
+
}): Promise<Reply<201, DatabaseCreated>>;
|
|
1375
|
+
/**
|
|
1376
|
+
* List database sizes
|
|
1377
|
+
*
|
|
1378
|
+
* Every database size, the ones that sleep first: what a database of it is given and may hold, its monthly limits, and whether this project may open one of it now. A size that is not open says why (`reason`): a size that is paid for is open to a project that may pay, and the free size to a project that has not its free databases already (a deleted one counting until it is purged).
|
|
1379
|
+
*/
|
|
1380
|
+
listDatabaseSizes(input?: {
|
|
1381
|
+
signal?: AbortSignal;
|
|
1382
|
+
}): Promise<Reply<200, DatabaseSizeList>>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Read a database
|
|
1385
|
+
*
|
|
1386
|
+
* Reads one database: what was asked for, and what runs.
|
|
1387
|
+
*/
|
|
1388
|
+
getDatabase(input: {
|
|
1389
|
+
path: {
|
|
1390
|
+
name: string;
|
|
1391
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1392
|
+
signal?: AbortSignal;
|
|
1393
|
+
}): Promise<Reply<200, Database>>;
|
|
1394
|
+
/**
|
|
1395
|
+
* Delete a database
|
|
1396
|
+
*
|
|
1397
|
+
* Takes the database away: it stops answering at once. Its volume and backups are kept for 7 days, and it may be taken back until then (POST …/undelete), or purged at once (POST …/purge); its name stays taken until it is purged. A database a machine is given is refused (409 `database_in_use`): give the machine another or none first; so is one moving to another size (409 `database_resizing`): it can be deleted once it has moved, or its move is let go. Emits `database.deleted`.
|
|
1398
|
+
*/
|
|
1399
|
+
deleteDatabase(input: {
|
|
1400
|
+
path: {
|
|
1401
|
+
name: string;
|
|
1402
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1403
|
+
signal?: AbortSignal;
|
|
1404
|
+
}): Promise<Reply<204, undefined>>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Change a database
|
|
1407
|
+
*
|
|
1408
|
+
* Changes who may connect to the database, how long its backups are kept, and its size. A change of size is answered at once (202), the database as it moves to it; the others with the database as changed (200). Emits `database.updated`.
|
|
1409
|
+
*/
|
|
1410
|
+
updateDatabase(input: {
|
|
1411
|
+
path: {
|
|
1412
|
+
name: string;
|
|
1413
|
+
};
|
|
1414
|
+
body: DatabaseUpdate; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1415
|
+
signal?: AbortSignal;
|
|
1416
|
+
}): Promise<Reply<200, Database> | Reply<202, Database>>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Take a database back
|
|
1419
|
+
*
|
|
1420
|
+
* Takes a deleted database back within 7 days of its deletion: it starts again with the data it had. Emits `database.undeleted`.
|
|
1421
|
+
*/
|
|
1422
|
+
undeleteDatabase(input: {
|
|
1423
|
+
path: {
|
|
1424
|
+
name: string;
|
|
1425
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1426
|
+
signal?: AbortSignal;
|
|
1427
|
+
}): Promise<Reply<200, Database>>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Purge a deleted database
|
|
1430
|
+
*
|
|
1431
|
+
* Takes a deleted database away for good now, instead of at the end of its 7 days: it no longer counts toward the project's databases at once, and its volume and its backups are removed — it cannot be taken back. Its name is free once it has gone. A database not deleted is refused (409 `database_not_deleted`); one purged already is purged (204). Emits `database.purged`.
|
|
1432
|
+
*/
|
|
1433
|
+
purgeDatabase(input: {
|
|
1434
|
+
path: {
|
|
1435
|
+
name: string;
|
|
1436
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1437
|
+
signal?: AbortSignal;
|
|
1438
|
+
}): Promise<Reply<204, undefined>>;
|
|
1439
|
+
/**
|
|
1440
|
+
* How to connect to a database
|
|
1441
|
+
*
|
|
1442
|
+
* Answers how to connect to the database without its passwords — they are shown once, when they are made: ready-made URLs (direct and pooled), a psql command, a JDBC URL and the lines of a Prisma schema's env, for its owner and for the application's login, with [YOUR-PASSWORD] where the password goes.
|
|
1443
|
+
*/
|
|
1444
|
+
getDatabaseCredentials(input: {
|
|
1445
|
+
path: {
|
|
1446
|
+
name: string;
|
|
1447
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1448
|
+
signal?: AbortSignal;
|
|
1449
|
+
}): Promise<Reply<200, DatabaseConnection>>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Make a password new
|
|
1452
|
+
*
|
|
1453
|
+
* Makes the owner's or the application's password new and answers the credentials with it, shown this once — the other login carries no password, [YOUR-PASSWORD] in its URLs; the new password works once the database has taken it, a few seconds after. The application's is set on its second login, and the machines given the database move to it with none of their connections refused; the old login keeps working until the next change — to shut out a leaked application password, make it new twice. A change waits for the one before it to reach the database (409 `password_change_pending`, with Retry-After), as does the first while the database starts. Emits `database.password_changed`.
|
|
1454
|
+
*/
|
|
1455
|
+
changeDatabasePassword(input: {
|
|
1456
|
+
path: {
|
|
1457
|
+
name: string;
|
|
1458
|
+
};
|
|
1459
|
+
body: PasswordChange; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1460
|
+
signal?: AbortSignal;
|
|
1461
|
+
}): Promise<Reply<200, DatabaseCredentials>>;
|
|
1462
|
+
/**
|
|
1463
|
+
* List a machine's jobs
|
|
1464
|
+
*
|
|
1465
|
+
* The jobs the machine's running version says it runs on a schedule, each with when it is next due and its latest run.
|
|
1466
|
+
*/
|
|
1467
|
+
listJobs(input: {
|
|
1468
|
+
path: {
|
|
1469
|
+
name: string;
|
|
1470
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1471
|
+
signal?: AbortSignal;
|
|
1472
|
+
}): Promise<Reply<200, JobList>>;
|
|
1473
|
+
/**
|
|
1474
|
+
* List a job's runs
|
|
1475
|
+
*
|
|
1476
|
+
* A job's latest runs, newest first, with the attempts each took and why one failed or was skipped.
|
|
1477
|
+
*/
|
|
1478
|
+
listJobRuns(input: {
|
|
1479
|
+
path: {
|
|
1480
|
+
name: string; /** The job's name. */
|
|
1481
|
+
job: string;
|
|
1482
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1483
|
+
signal?: AbortSignal;
|
|
1484
|
+
}): Promise<Reply<200, JobRunList>>;
|
|
1485
|
+
/**
|
|
1486
|
+
* Read what a machine wrote
|
|
1487
|
+
*
|
|
1488
|
+
* What the machine's copies and its migration runs wrote to stdout and stderr, oldest first — or newest first with order=desc — as NDJSON: one MachineLogLine a line; with q, those lines alone that hold its text. Lines are kept for 7 days, from every version of the machine — one that did not come up too. A machine's lines are kept up to 1200 a minute; past it the rest of that minute is not. With follow=true the answer is held open (5 minutes at most, and until the machine is deleted; a project holds 5 followed reads open at once, a sixth is 429 too_many_follows) and what the machine writes next follows as it comes; a caller whose connection ends goes on with since= the time of the last line it had — a line may then come twice, and its id says so. A newest-first read pages back the same way: until= the time of the last line it had, which is inclusive in that order.
|
|
1489
|
+
*/
|
|
1490
|
+
readMachineLogs(input: {
|
|
1491
|
+
path: {
|
|
1492
|
+
name: string;
|
|
1493
|
+
};
|
|
1494
|
+
query?: {
|
|
1495
|
+
since?: string; /** Until when: exclusive, and with order=desc inclusive, so that a newest-first read goes on from the time of the last line it had; now when left out. Not with follow. */
|
|
1496
|
+
until?: string; /** How many lines at most (a followed read: before it follows). */
|
|
1497
|
+
lines?: number; /** Hold the answer open and send what the machine writes next. */
|
|
1498
|
+
follow?: boolean; /** asc: oldest first. desc: newest first — the newest lines of the window, up to lines of them. Not with follow. */
|
|
1499
|
+
order?: "asc" | "desc"; /** Only the lines that hold this text, in any case. It is the text itself, no pattern: % and _ are themselves, and so is a backslash. 256 characters at most. A followed read follows those lines alone. */
|
|
1500
|
+
q?: string;
|
|
1501
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1502
|
+
signal?: AbortSignal;
|
|
1503
|
+
}): Promise<Reply<200, Response>>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Read what a machine used over time
|
|
1506
|
+
*
|
|
1507
|
+
* What the machine used, bucket by bucket, oldest first — what Studio's charts draw. Once a minute the module reads its pods' usage from the cluster's metrics server — CPU averaged over the minute the server read it, memory (the working set) as it was then — and keeps it summed over the machine's copies, at the minute it was read. A minute nobody measured — the machine slept, or a pod had only just started — is in no bucket, and a bucket none of whose minutes was measured is no row: nothing is filled in, carried across a gap or made up when read. Every field of a row is a gauge: `samples` is how many minutes were measured in the bucket; `cpu_avg_millicores` and `memory_avg_bytes` are their average, and `cpu_max_millicores` and `memory_max_bytes` their most, summed over the copies that ran; `replicas_max` is the most copies that ran in a minute (one more than the machine has while a new version comes up beside the one that serves); `cpu_replica_max_millicores` and `memory_replica_max_bytes` are the most one copy used — what `limits` holds a copy to. `limits` is what the machine's size gives a copy now — a shared size wakes with a whole CPU (1000m) and is brought down to its own once it answers — and how many copies it runs while awake. Kept: a machine's minutes 48 hours, its hours 30 days; what is older is deleted, and a deleted machine's is deleted within the hour after it has gone. Buckets are UTC: minute, hour, day.
|
|
1508
|
+
*/
|
|
1509
|
+
getMachineMetrics(input: {
|
|
1510
|
+
path: {
|
|
1511
|
+
name: string;
|
|
1512
|
+
};
|
|
1513
|
+
query?: {
|
|
1514
|
+
window_seconds?: number; /** What a row covers. minute reaches 172800 seconds (48 hours) back at most (400 `invalid_bucket` past it). When left out: minute for a window of 6 hours or less, hour up to 7 days, day beyond. */
|
|
1515
|
+
bucket?: "minute" | "hour" | "day";
|
|
1516
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1517
|
+
signal?: AbortSignal;
|
|
1518
|
+
}): Promise<Reply<200, MachineMetrics>>;
|
|
1519
|
+
/**
|
|
1520
|
+
* Read a machine's API contract
|
|
1521
|
+
*
|
|
1522
|
+
* The contract (OpenAPI) of the build the machine serves from, kept with the build so it is answered without waking the machine and two versions never mix. A palbase/backend app's is written as its build ends: the build's image is run once — the machine neither woken nor changed, the run given none of its secrets — and its app reads its source for what each route answers and throws, and writes the contract; until it has, the answer is 503 `contract_pending` with Retry-After, and a build whose app wrote none is 422 `contract_refused`, saying why (a route its source does not type, a source that does not compile, a palbase/backend older than contracts written at build time). Another app's is read where the machine's openapi_path says, once that build's version alone answered at the machine's address — never while an older one still answered beside it — asked on the platform's own channel, signed with the machine's PALBASE_PLATFORM_SECRET; until it has been read it is asked live: a sleeping machine is woken for it, the call held a few seconds (503 `machine_waking` with Retry-After past that); a machine with no build up yet answers none (503 `machine_building`). A machine whose app is neither has no contract (404 `not_a_palbase_backend`). The answer carries its SHA-256 (ETag, Palbase-Contract-Digest; the machine's contract_digest): If-None-Match with it answers 304. A contract asked live is read up to 2 MiB (502 `contract_too_large` past it) and must be a JSON object (502 `contract_unreadable`); an app that cannot be asked — its connection ends, it answers late or answers another status — is 503 `machine_unreachable`. A project whose machine time is used up wakes nothing (429 `quota_exceeded`).
|
|
1523
|
+
*/
|
|
1524
|
+
getMachineContract(input: {
|
|
1525
|
+
path: {
|
|
1526
|
+
name: string;
|
|
1527
|
+
};
|
|
1528
|
+
headers?: {
|
|
1529
|
+
"If-None-Match"?: string;
|
|
1530
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1531
|
+
signal?: AbortSignal;
|
|
1532
|
+
}): Promise<Reply<200, MachineContract> | Reply<304, undefined>>;
|
|
1533
|
+
/**
|
|
1534
|
+
* Bring a database back to a moment
|
|
1535
|
+
*
|
|
1536
|
+
* Brings the database back to a moment of its backups: one since it was opened — or last brought back — within its backup days, and not of the last two minutes (its WAL is archived once a minute). It is down meanwhile, its clients told it is being restored; it starts again with the data it held at that moment, its logins' passwords as they are now. Before it goes down, a commit is written on it and archived, so any moment it was quiet at is reached too — a database asleep is woken for it, unless it has slept since before the moment (then nothing was written since, and it is brought back to the latest moment of its backups); brought back, it is awake. A restore whose recovery fails is made again to the latest moment of its backups — nothing it held is lost — and says so in `state_reason`; one whose archive does not take its last WAL within minutes leaves the database as it was. One restore at a time: another is asked for once the last has ended, or failed (`failed`: not even to its latest moment). Emits `database.restoring`, and `database.restore_failed` when it does not bring the database back to its moment.
|
|
1537
|
+
*/
|
|
1538
|
+
restoreDatabase(input: {
|
|
1539
|
+
path: {
|
|
1540
|
+
name: string;
|
|
1541
|
+
};
|
|
1542
|
+
body: DatabaseRestore; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1543
|
+
signal?: AbortSignal;
|
|
1544
|
+
}): Promise<Reply<202, Database>>;
|
|
1545
|
+
/**
|
|
1546
|
+
* Read a database's tables
|
|
1547
|
+
*
|
|
1548
|
+
* Answers the database's tables, as Studio's console shows them: every ordinary and partitioned table outside Postgres' own schemas and the framework's (palgres), by schema then name — a table in public named bare, any other schema.table — with its columns in order: type as Postgres writes it, whether it takes NULL, whether it is of the primary key, and the column a foreign key of it points at. Read as the database's owner, in a transaction that takes no writes. A sleeping database is woken, the call held a few seconds for it (503 `database_waking` with Retry-After past that); one being brought back to a moment, or that cannot start, is refused (409). A database runs a few of the console's calls at once (429 `too_many_queries` past them).
|
|
1549
|
+
*/
|
|
1550
|
+
getDatabaseSchema(input: {
|
|
1551
|
+
path: {
|
|
1552
|
+
name: string;
|
|
1553
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1554
|
+
signal?: AbortSignal;
|
|
1555
|
+
}): Promise<Reply<200, DatabaseSchema>>;
|
|
1556
|
+
/**
|
|
1557
|
+
* Read a database's usage over time
|
|
1558
|
+
*
|
|
1559
|
+
* A database's usage, bucket by bucket, oldest first — what Studio's charts draw — kept by the hour and summed into days. `traffic_bytes` and `awake_seconds` are counters: what of the month's disk traffic (its own, its archive's padding taken off, as the database's `traffic_bytes` is) and of its awake time the meter counted in the bucket. They are counted at each minute's turn, into the hour of the minute that ended (what the meter counted in a month's last minute is in no hour: the month's count begins again before it is counted); a bucket with no row counted none. `size_bytes` and `connections_max` are gauges, absent when nothing was measured in the bucket: what the database held as last measured in it — it is measured while it is awake, never while it sleeps — and the most of its clients' connections to Postgres seen, every 15 seconds while it is awake: of every role but the platform's own, directly or through its pools. `limits` is what its size holds at most (`size_bytes`: past it, it turns read-only) and the connections it takes (Postgres' max_connections). Its history begins at the first minute the module counted it. Kept 90 days; what is older is deleted, and a purged database's within the hour after it was purged. A deleted database is read until it is purged, as it is at GET /databases/{name}. Buckets are UTC: hour, day.
|
|
1560
|
+
*/
|
|
1561
|
+
getDatabaseMetrics(input: {
|
|
1562
|
+
path: {
|
|
1563
|
+
name: string;
|
|
1564
|
+
};
|
|
1565
|
+
query?: {
|
|
1566
|
+
window_seconds?: number; /** What a row covers. When left out: hour for a window of 7 days or less, day beyond. */
|
|
1567
|
+
bucket?: "hour" | "day";
|
|
1568
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1569
|
+
signal?: AbortSignal;
|
|
1570
|
+
}): Promise<Reply<200, DatabaseMetrics>>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Run a statement against a database
|
|
1573
|
+
*
|
|
1574
|
+
* Runs one statement against the database and answers its columns and its first rows, as Studio's console shows them: in a transaction that takes no writes — Postgres refuses one (400 `query_failed`, sqlstate 25006) — always rolled back, as the database's owner, sent as one statement of the extended protocol (two are refused: 42601), within 15 s (57014) and 5 s for a lock (55P03). A statement Postgres refuses is answered 400 `query_failed` with its message and SQLSTATE. Each value as JSON: numbers, booleans and null as such, a timestamp in RFC 3339, numeric as a string, bytea as \x and its hex, json and jsonb as the JSON they hold, an array as an array, anything else its text form. A sleeping database is woken, the call held a few seconds for it (503 `database_waking` with Retry-After past that); one being brought back to a moment, or that cannot start, is refused (409). A database runs a few of the console's calls at once (429 `too_many_queries` past them).
|
|
1575
|
+
*/
|
|
1576
|
+
queryDatabase(input: {
|
|
1577
|
+
path: {
|
|
1578
|
+
name: string;
|
|
1579
|
+
};
|
|
1580
|
+
body: DatabaseQuery; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
1581
|
+
signal?: AbortSignal;
|
|
1582
|
+
}): Promise<Reply<200, DatabaseQueryResult>>;
|
|
1583
|
+
};
|
|
1584
|
+
export type Client = ReturnType<typeof client>;
|