@openupstream/sdk 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.d.ts +65 -3
- package/dist/index.js +179 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +120 -1
- package/dist/internal.js +82 -0
- package/dist/internal.js.map +1 -1
- package/dist/model.d.ts +376 -10
- package/dist/model.js +61 -1
- package/dist/model.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,8 +23,9 @@ operators and the billing service), not for customers.
|
|
|
23
23
|
|
|
24
24
|
## Releasing
|
|
25
25
|
|
|
26
|
-
Raise `version` in `package.json` (and `SDK_VERSION` in `src/index.ts
|
|
27
|
-
|
|
26
|
+
Raise `version` in `package.json` (and `SDK_VERSION` in `src/index.ts`,
|
|
27
|
+
and the range of `@openupstream/sdk` in the other workspaces when the
|
|
28
|
+
minor version changes: `^0.1.0` does not match `0.2.0`), merge, then tag that commit `sdk-v<version>` and push the tag; only admins
|
|
28
29
|
may. The workflow `.github/workflows/sdk-release.yml` waits in the
|
|
29
30
|
Environment `npm-release` until a maintainer approves the run on GitHub,
|
|
30
31
|
then checks that the tag names the version, builds, tests and publishes
|
package/dist/index.d.ts
CHANGED
|
@@ -7,15 +7,18 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The API surface is defined here first and implemented in control-plane/.
|
|
9
9
|
*/
|
|
10
|
-
export declare const SDK_VERSION = "0.
|
|
10
|
+
export declare const SDK_VERSION = "0.2.0";
|
|
11
11
|
export * from './model.js';
|
|
12
12
|
export * from './internal.js';
|
|
13
|
-
import type { Account, AccountInput, DatabaseDetails, DatabaseInput, Id, Project, ProjectInput } from './model.js';
|
|
13
|
+
import type { Account, AccountInput, Bucket, BucketDetails, BucketInput, CliLogin, CustomDomainInput, DatabaseDetails, DatabaseInput, DatabasePatch, Domain, Id, JobDetails, JobInput, JobPatch, JobRun, JobRunInput, LogEntry, LogQuery, Project, ProjectInput, Route, RouteInput, Secret, SecretInput, ServiceDetails, ServiceInput, ServicePatch } from './model.js';
|
|
14
|
+
export declare const DEFAULT_API_URL = "https://api.openupstream.com";
|
|
14
15
|
export interface ClientOptions {
|
|
15
16
|
baseUrl?: string;
|
|
16
|
-
/** A madAuth session token, or one of the user's madAuth API keys (`madauth_…`). */
|
|
17
|
+
/** A madAuth session token, an access token of `oup`, or one of the user's madAuth API keys (`madauth_…`). */
|
|
17
18
|
token: string;
|
|
18
19
|
}
|
|
20
|
+
/** Where the CLI signs in; asked before there is a token. 404 when the platform has no CLI client. */
|
|
21
|
+
export declare function cliLogin(baseUrl?: string): Promise<ApiResult<CliLogin>>;
|
|
19
22
|
/** What went wrong, as the API said it: the HTTP status and its message. 0: the API was not reached. */
|
|
20
23
|
export interface ApiError {
|
|
21
24
|
readonly status: number;
|
|
@@ -35,6 +38,7 @@ export declare class OpenUpstreamClient {
|
|
|
35
38
|
health(): Promise<{
|
|
36
39
|
ok: boolean;
|
|
37
40
|
}>;
|
|
41
|
+
cliLogin(): Promise<ApiResult<CliLogin>>;
|
|
38
42
|
/** The Accounts the caller is a Member of. */
|
|
39
43
|
listAccounts(): Promise<ApiResult<Account[]>>;
|
|
40
44
|
/** A new Account, with the caller as its first Member. */
|
|
@@ -47,6 +51,64 @@ export declare class OpenUpstreamClient {
|
|
|
47
51
|
listDatabases(projectId: Id): Promise<ApiResult<DatabaseDetails[]>>;
|
|
48
52
|
createDatabase(projectId: Id, input: DatabaseInput): Promise<ApiResult<DatabaseDetails>>;
|
|
49
53
|
getDatabase(projectId: Id, databaseId: Id): Promise<ApiResult<DatabaseDetails>>;
|
|
54
|
+
/** Resizes the Database; the operator applies it within one pass (`resizing` until then). */
|
|
55
|
+
updateDatabase(projectId: Id, databaseId: Id, patch: DatabasePatch): Promise<ApiResult<DatabaseDetails>>;
|
|
50
56
|
/** Deletes the Database at once; its backups are kept for the retention window. */
|
|
51
57
|
deleteDatabase(projectId: Id, databaseId: Id): Promise<ApiResult<void>>;
|
|
58
|
+
listBuckets(projectId: Id): Promise<ApiResult<Bucket[]>>;
|
|
59
|
+
/** A new Bucket with its own key; usable as soon as this returns. */
|
|
60
|
+
createBucket(projectId: Id, input: BucketInput): Promise<ApiResult<BucketDetails>>;
|
|
61
|
+
getBucket(projectId: Id, bucketId: Id): Promise<ApiResult<BucketDetails>>;
|
|
62
|
+
/** Deletes the Bucket and every object in it; there is no retention window. */
|
|
63
|
+
deleteBucket(projectId: Id, bucketId: Id): Promise<ApiResult<void>>;
|
|
64
|
+
/** The Project's Domains; every Project has its default Domain. */
|
|
65
|
+
listDomains(projectId: Id): Promise<ApiResult<Domain[]>>;
|
|
66
|
+
/** Claims a custom domain; publish its TXT record, then call verifyDomain. */
|
|
67
|
+
createDomain(projectId: Id, input: CustomDomainInput): Promise<ApiResult<Domain>>;
|
|
68
|
+
/** Looks up the custom domain's TXT record now; once found, the Domain is verified and its Routes are served. */
|
|
69
|
+
verifyDomain(projectId: Id, domainId: Id): Promise<ApiResult<Domain>>;
|
|
70
|
+
/** Deletes a custom domain and its Routes; the default Domain cannot be deleted. */
|
|
71
|
+
deleteDomain(projectId: Id, domainId: Id): Promise<ApiResult<void>>;
|
|
72
|
+
listRoutes(projectId: Id, domainId: Id): Promise<ApiResult<Route[]>>;
|
|
73
|
+
/** Serves a Bucket below a path prefix of the Domain, within one operator pass. */
|
|
74
|
+
createRoute(projectId: Id, domainId: Id, input: RouteInput): Promise<ApiResult<Route>>;
|
|
75
|
+
deleteRoute(projectId: Id, domainId: Id, routeId: Id): Promise<ApiResult<void>>;
|
|
76
|
+
listServices(projectId: Id): Promise<ApiResult<ServiceDetails[]>>;
|
|
77
|
+
/** Resolves the image's tag to a digest now and deploys it pinned; running within one operator pass. */
|
|
78
|
+
createService(projectId: Id, input: ServiceInput): Promise<ApiResult<ServiceDetails>>;
|
|
79
|
+
getService(projectId: Id, serviceId: Id): Promise<ApiResult<ServiceDetails>>;
|
|
80
|
+
/** Changes the Service; a new image or new registry credentials resolve the tag again. */
|
|
81
|
+
updateService(projectId: Id, serviceId: Id, patch: ServicePatch): Promise<ApiResult<ServiceDetails>>;
|
|
82
|
+
/** Resolves the Service's tag again and deploys what it points at now. */
|
|
83
|
+
deployService(projectId: Id, serviceId: Id): Promise<ApiResult<ServiceDetails>>;
|
|
84
|
+
/** Deletes the Service; refused while a Route serves it. */
|
|
85
|
+
deleteService(projectId: Id, serviceId: Id): Promise<ApiResult<void>>;
|
|
86
|
+
listJobs(projectId: Id): Promise<ApiResult<JobDetails[]>>;
|
|
87
|
+
/** Resolves the image's tag to a digest now; the Job is ready to run within one operator pass. */
|
|
88
|
+
createJob(projectId: Id, input: JobInput): Promise<ApiResult<JobDetails>>;
|
|
89
|
+
getJob(projectId: Id, jobId: Id): Promise<ApiResult<JobDetails>>;
|
|
90
|
+
/** Changes the Job; a new image or new registry credentials resolve the tag again. */
|
|
91
|
+
updateJob(projectId: Id, jobId: Id, patch: JobPatch): Promise<ApiResult<JobDetails>>;
|
|
92
|
+
/** Resolves the Job's tag again; later runs start what it points at now. */
|
|
93
|
+
deployJob(projectId: Id, jobId: Id): Promise<ApiResult<JobDetails>>;
|
|
94
|
+
/** Deletes the Job; its runs, running ones included, are stopped and removed. */
|
|
95
|
+
deleteJob(projectId: Id, jobId: Id): Promise<ApiResult<void>>;
|
|
96
|
+
/** Starts a One-off job from the Job's current template; 409 while the Job is still deploying. */
|
|
97
|
+
startJobRun(projectId: Id, jobId: Id, input?: JobRunInput): Promise<ApiResult<JobRun>>;
|
|
98
|
+
/** The Job's runs, newest first, scheduled and started alike. */
|
|
99
|
+
listJobRuns(projectId: Id, jobId: Id): Promise<ApiResult<JobRun[]>>;
|
|
100
|
+
getJobRun(projectId: Id, jobId: Id, runId: string): Promise<ApiResult<JobRun>>;
|
|
101
|
+
/** Stops the run if it is still going, and removes it. */
|
|
102
|
+
deleteJobRun(projectId: Id, jobId: Id, runId: string): Promise<ApiResult<void>>;
|
|
103
|
+
/** The Service's output from all its replicas, as a stream of entries; `signal` ends it early. */
|
|
104
|
+
serviceLogs(projectId: Id, serviceId: Id, query?: LogQuery, signal?: AbortSignal): Promise<ApiResult<AsyncIterable<LogEntry>>>;
|
|
105
|
+
/** A run's output, as a stream of entries; `signal` ends it early. */
|
|
106
|
+
jobRunLogs(projectId: Id, jobId: Id, runId: string, query?: LogQuery, signal?: AbortSignal): Promise<ApiResult<AsyncIterable<LogEntry>>>;
|
|
107
|
+
/** The Project's Secrets, names only: a value is never returned. */
|
|
108
|
+
listSecrets(projectId: Id): Promise<ApiResult<Secret[]>>;
|
|
109
|
+
/** Creates the Secret or replaces its value; the Project's Services get it in their environment. */
|
|
110
|
+
putSecret(projectId: Id, input: SecretInput): Promise<ApiResult<Secret>>;
|
|
111
|
+
deleteSecret(projectId: Id, name: string): Promise<ApiResult<void>>;
|
|
52
112
|
}
|
|
113
|
+
/** The JSON values of a body of NDJSON, one per non-empty line. */
|
|
114
|
+
export declare function ndjsonLines<T>(body: ReadableStream<Uint8Array>): AsyncIterable<T>;
|
package/dist/index.js
CHANGED
|
@@ -7,20 +7,28 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The API surface is defined here first and implemented in control-plane/.
|
|
9
9
|
*/
|
|
10
|
-
export const SDK_VERSION = '0.
|
|
10
|
+
export const SDK_VERSION = '0.2.0';
|
|
11
11
|
export * from './model.js';
|
|
12
12
|
export * from './internal.js';
|
|
13
|
+
export const DEFAULT_API_URL = 'https://api.openupstream.com';
|
|
14
|
+
/** Where the CLI signs in; asked before there is a token. 404 when the platform has no CLI client. */
|
|
15
|
+
export async function cliLogin(baseUrl = DEFAULT_API_URL) {
|
|
16
|
+
return new OpenUpstreamClient({ baseUrl, token: '' }).cliLogin();
|
|
17
|
+
}
|
|
13
18
|
export class OpenUpstreamClient {
|
|
14
19
|
baseUrl;
|
|
15
20
|
#token;
|
|
16
21
|
constructor(options) {
|
|
17
|
-
this.baseUrl = options.baseUrl ??
|
|
22
|
+
this.baseUrl = options.baseUrl ?? DEFAULT_API_URL;
|
|
18
23
|
this.#token = options.token;
|
|
19
24
|
}
|
|
20
25
|
async health() {
|
|
21
26
|
const res = await fetch(`${this.baseUrl}/v1/health`);
|
|
22
27
|
return { ok: res.ok };
|
|
23
28
|
}
|
|
29
|
+
cliLogin() {
|
|
30
|
+
return this.#call('GET', '/v1/login');
|
|
31
|
+
}
|
|
24
32
|
/** The Accounts the caller is a Member of. */
|
|
25
33
|
listAccounts() {
|
|
26
34
|
return this.#call('GET', '/v1/accounts');
|
|
@@ -51,10 +59,155 @@ export class OpenUpstreamClient {
|
|
|
51
59
|
getDatabase(projectId, databaseId) {
|
|
52
60
|
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`);
|
|
53
61
|
}
|
|
62
|
+
/** Resizes the Database; the operator applies it within one pass (`resizing` until then). */
|
|
63
|
+
updateDatabase(projectId, databaseId, patch) {
|
|
64
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`, patch);
|
|
65
|
+
}
|
|
54
66
|
/** Deletes the Database at once; its backups are kept for the retention window. */
|
|
55
67
|
deleteDatabase(projectId, databaseId) {
|
|
56
68
|
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`);
|
|
57
69
|
}
|
|
70
|
+
listBuckets(projectId) {
|
|
71
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/buckets`);
|
|
72
|
+
}
|
|
73
|
+
/** A new Bucket with its own key; usable as soon as this returns. */
|
|
74
|
+
createBucket(projectId, input) {
|
|
75
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/buckets`, input);
|
|
76
|
+
}
|
|
77
|
+
getBucket(projectId, bucketId) {
|
|
78
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/buckets/${encodeURIComponent(bucketId)}`);
|
|
79
|
+
}
|
|
80
|
+
/** Deletes the Bucket and every object in it; there is no retention window. */
|
|
81
|
+
deleteBucket(projectId, bucketId) {
|
|
82
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/buckets/${encodeURIComponent(bucketId)}`);
|
|
83
|
+
}
|
|
84
|
+
/** The Project's Domains; every Project has its default Domain. */
|
|
85
|
+
listDomains(projectId) {
|
|
86
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/domains`);
|
|
87
|
+
}
|
|
88
|
+
/** Claims a custom domain; publish its TXT record, then call verifyDomain. */
|
|
89
|
+
createDomain(projectId, input) {
|
|
90
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains`, input);
|
|
91
|
+
}
|
|
92
|
+
/** Looks up the custom domain's TXT record now; once found, the Domain is verified and its Routes are served. */
|
|
93
|
+
verifyDomain(projectId, domainId) {
|
|
94
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/verify`);
|
|
95
|
+
}
|
|
96
|
+
/** Deletes a custom domain and its Routes; the default Domain cannot be deleted. */
|
|
97
|
+
deleteDomain(projectId, domainId) {
|
|
98
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}`);
|
|
99
|
+
}
|
|
100
|
+
listRoutes(projectId, domainId) {
|
|
101
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes`);
|
|
102
|
+
}
|
|
103
|
+
/** Serves a Bucket below a path prefix of the Domain, within one operator pass. */
|
|
104
|
+
createRoute(projectId, domainId, input) {
|
|
105
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes`, input);
|
|
106
|
+
}
|
|
107
|
+
deleteRoute(projectId, domainId, routeId) {
|
|
108
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes/${encodeURIComponent(routeId)}`);
|
|
109
|
+
}
|
|
110
|
+
listServices(projectId) {
|
|
111
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/services`);
|
|
112
|
+
}
|
|
113
|
+
/** Resolves the image's tag to a digest now and deploys it pinned; running within one operator pass. */
|
|
114
|
+
createService(projectId, input) {
|
|
115
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/services`, input);
|
|
116
|
+
}
|
|
117
|
+
getService(projectId, serviceId) {
|
|
118
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`);
|
|
119
|
+
}
|
|
120
|
+
/** Changes the Service; a new image or new registry credentials resolve the tag again. */
|
|
121
|
+
updateService(projectId, serviceId, patch) {
|
|
122
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`, patch);
|
|
123
|
+
}
|
|
124
|
+
/** Resolves the Service's tag again and deploys what it points at now. */
|
|
125
|
+
deployService(projectId, serviceId) {
|
|
126
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}/deploy`);
|
|
127
|
+
}
|
|
128
|
+
/** Deletes the Service; refused while a Route serves it. */
|
|
129
|
+
deleteService(projectId, serviceId) {
|
|
130
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`);
|
|
131
|
+
}
|
|
132
|
+
listJobs(projectId) {
|
|
133
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs`);
|
|
134
|
+
}
|
|
135
|
+
/** Resolves the image's tag to a digest now; the Job is ready to run within one operator pass. */
|
|
136
|
+
createJob(projectId, input) {
|
|
137
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs`, input);
|
|
138
|
+
}
|
|
139
|
+
getJob(projectId, jobId) {
|
|
140
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`);
|
|
141
|
+
}
|
|
142
|
+
/** Changes the Job; a new image or new registry credentials resolve the tag again. */
|
|
143
|
+
updateJob(projectId, jobId, patch) {
|
|
144
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`, patch);
|
|
145
|
+
}
|
|
146
|
+
/** Resolves the Job's tag again; later runs start what it points at now. */
|
|
147
|
+
deployJob(projectId, jobId) {
|
|
148
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/deploy`);
|
|
149
|
+
}
|
|
150
|
+
/** Deletes the Job; its runs, running ones included, are stopped and removed. */
|
|
151
|
+
deleteJob(projectId, jobId) {
|
|
152
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`);
|
|
153
|
+
}
|
|
154
|
+
/** Starts a One-off job from the Job's current template; 409 while the Job is still deploying. */
|
|
155
|
+
startJobRun(projectId, jobId, input = {}) {
|
|
156
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs`, input);
|
|
157
|
+
}
|
|
158
|
+
/** The Job's runs, newest first, scheduled and started alike. */
|
|
159
|
+
listJobRuns(projectId, jobId) {
|
|
160
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs`);
|
|
161
|
+
}
|
|
162
|
+
getJobRun(projectId, jobId, runId) {
|
|
163
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}`);
|
|
164
|
+
}
|
|
165
|
+
/** Stops the run if it is still going, and removes it. */
|
|
166
|
+
deleteJobRun(projectId, jobId, runId) {
|
|
167
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}`);
|
|
168
|
+
}
|
|
169
|
+
/** The Service's output from all its replicas, as a stream of entries; `signal` ends it early. */
|
|
170
|
+
serviceLogs(projectId, serviceId, query = {}, signal) {
|
|
171
|
+
return this.#stream(`/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}/logs${logSearch(query)}`, signal);
|
|
172
|
+
}
|
|
173
|
+
/** A run's output, as a stream of entries; `signal` ends it early. */
|
|
174
|
+
jobRunLogs(projectId, jobId, runId, query = {}, signal) {
|
|
175
|
+
return this.#stream(`/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}/logs${logSearch(query)}`, signal);
|
|
176
|
+
}
|
|
177
|
+
/** The Project's Secrets, names only: a value is never returned. */
|
|
178
|
+
listSecrets(projectId) {
|
|
179
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/secrets`);
|
|
180
|
+
}
|
|
181
|
+
/** Creates the Secret or replaces its value; the Project's Services get it in their environment. */
|
|
182
|
+
putSecret(projectId, input) {
|
|
183
|
+
return this.#call('PUT', `/v1/projects/${encodeURIComponent(projectId)}/secrets/${encodeURIComponent(input.name)}`, {
|
|
184
|
+
value: input.value,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
deleteSecret(projectId, name) {
|
|
188
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/secrets/${encodeURIComponent(name)}`);
|
|
189
|
+
}
|
|
190
|
+
/** A GET whose answer is NDJSON, one entry per line, read as it arrives. */
|
|
191
|
+
async #stream(path, signal) {
|
|
192
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
193
|
+
headers: { authorization: `Bearer ${this.#token}` },
|
|
194
|
+
...(signal === undefined ? {} : { signal }),
|
|
195
|
+
}).then((value) => ({ ok: true, value }), (error) => ({ ok: false, error: { status: 0, message: error instanceof Error ? error.message : String(error) } }));
|
|
196
|
+
if (!response.ok) {
|
|
197
|
+
return response;
|
|
198
|
+
}
|
|
199
|
+
const isNdjson = response.value.headers.get('content-type')?.includes('application/x-ndjson') ?? false;
|
|
200
|
+
if (response.value.ok && isNdjson && response.value.body !== null) {
|
|
201
|
+
return { ok: true, value: ndjsonLines(response.value.body) };
|
|
202
|
+
}
|
|
203
|
+
const parsed = await response.value.json().catch(() => undefined);
|
|
204
|
+
const message = typeof parsed === 'object' && parsed !== null && 'error' in parsed && typeof parsed.error === 'string'
|
|
205
|
+
? parsed.error
|
|
206
|
+
: response.value.ok
|
|
207
|
+
? 'the API did not answer with a log stream'
|
|
208
|
+
: response.value.statusText;
|
|
209
|
+
return { ok: false, error: { status: response.value.ok ? 0 : response.value.status, message } };
|
|
210
|
+
}
|
|
58
211
|
async #call(method, path, body) {
|
|
59
212
|
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
60
213
|
method,
|
|
@@ -79,4 +232,28 @@ export class OpenUpstreamClient {
|
|
|
79
232
|
return { ok: false, error: { status: response.value.status, message } };
|
|
80
233
|
}
|
|
81
234
|
}
|
|
235
|
+
const logSearch = (query) => {
|
|
236
|
+
const params = new URLSearchParams({
|
|
237
|
+
...(query.tail === undefined ? {} : { tail: String(query.tail) }),
|
|
238
|
+
...(query.follow === true ? { follow: 'true' } : {}),
|
|
239
|
+
}).toString();
|
|
240
|
+
return params === '' ? '' : `?${params}`;
|
|
241
|
+
};
|
|
242
|
+
/** The JSON values of a body of NDJSON, one per non-empty line. */
|
|
243
|
+
export async function* ndjsonLines(body) {
|
|
244
|
+
const decoder = new TextDecoder();
|
|
245
|
+
let pending = '';
|
|
246
|
+
for await (const chunk of body) {
|
|
247
|
+
pending += decoder.decode(chunk, { stream: true });
|
|
248
|
+
const lines = pending.split('\n');
|
|
249
|
+
pending = lines.pop() ?? '';
|
|
250
|
+
for (const line of lines.filter((candidate) => candidate.trim() !== '')) {
|
|
251
|
+
yield JSON.parse(line);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const last = pending + decoder.decode();
|
|
255
|
+
if (last.trim() !== '') {
|
|
256
|
+
yield JSON.parse(last);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
82
259
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAiB9B,MAAM,OAAO,kBAAkB;IAClB,OAAO,CAAS;IAChB,MAAM,CAAS;IAExB,YAAY,OAAsB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,8BAA8B,CAAC;QACjE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;QACrD,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,8CAA8C;IAC9C,YAAY;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED,0DAA0D;IAC1D,aAAa,CAAC,KAAmB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,YAAY;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED,aAAa,CAAC,KAAmB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,C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EAAE,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACtE,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;QAChC,CAAC;IACL,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACxC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAChC,CAAC;AACL,CAAC"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* public API: it is served on its own port, never routed by ingress, and
|
|
5
5
|
* callers authenticate with their Kubernetes ServiceAccount token.
|
|
6
6
|
*/
|
|
7
|
-
import type { Account, Database, Id, Member, Project } from './model.js';
|
|
7
|
+
import type { Account, Database, DatabaseConnection, Domain, Id, Job, Member, Project, Route, Service, Site } from './model.js';
|
|
8
8
|
/**
|
|
9
9
|
* Kubernetes names, by id (ARCHITECTURE.md, decision 42): the operators
|
|
10
10
|
* create these objects, the control plane reads and deletes them.
|
|
@@ -14,6 +14,32 @@ export declare const projectNamespace: (projectId: Id) => string;
|
|
|
14
14
|
export declare const clusterName: (database: Pick<Database, "id">) => string;
|
|
15
15
|
/** Cannot share the Cluster's name, nor `<cluster>-rw`, which the Cluster's own Service takes. */
|
|
16
16
|
export declare const poolerName: (database: Pick<Database, "id">) => string;
|
|
17
|
+
/** The Secret CloudNativePG keeps the Database's `app` user in, with its generated `password`. */
|
|
18
|
+
export declare const databaseAppSecret: (database: Pick<Database, "id">) => string;
|
|
19
|
+
/** Where the Project's Services and Jobs reach the Database: its Pooler, inside the cluster. */
|
|
20
|
+
export declare const databaseConnection: (database: Pick<Database, "id" | "projectId">) => DatabaseConnection;
|
|
21
|
+
/**
|
|
22
|
+
* The Kubernetes Secret in a Project's namespace that holds all its Secrets'
|
|
23
|
+
* values; the control plane writes it, Services and Jobs read it with `envFrom`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PROJECT_SECRETS = "project-secrets";
|
|
26
|
+
/**
|
|
27
|
+
* The `kubernetes.io/dockerconfigjson` Secret in a Project's namespace with
|
|
28
|
+
* the registry credentials of all its Services and Jobs, each under its
|
|
29
|
+
* image's repository; the control plane writes it, every Service and Job
|
|
30
|
+
* names it in `imagePullSecrets`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const PROJECT_REGISTRY_AUTH = "project-registry-auth";
|
|
33
|
+
/** The Service's Deployment and Kubernetes Service, in its Project's namespace. */
|
|
34
|
+
export declare const serviceObjectName: (service: Pick<Service, "id">) => string;
|
|
35
|
+
/** The Job's CronJob, in its Project's namespace; its runs are Kubernetes Jobs named after it. */
|
|
36
|
+
export declare const jobObjectName: (job: Pick<Job, "id">) => string;
|
|
37
|
+
/** On a Service's Deployment and its pods: the Service's id, by which the control plane finds the pods for its logs. */
|
|
38
|
+
export declare const SERVICE_ID_LABEL = "openupstream.io/service-id";
|
|
39
|
+
/** On a Job's CronJob and its runs: the Job's id, by which the control plane lists the runs. */
|
|
40
|
+
export declare const JOB_ID_LABEL = "openupstream.io/job-id";
|
|
41
|
+
/** On a run the control plane started (a One-off job): `api`. Scheduled runs do not have it. */
|
|
42
|
+
export declare const RUN_TRIGGER_LABEL = "openupstream.io/trigger";
|
|
17
43
|
/** The folder under the backup bucket that holds one Database's base backups and WAL. */
|
|
18
44
|
export declare const backupPrefix: (projectId: Id, databaseId: Id) => string;
|
|
19
45
|
/** Ids are lowercase UUIDs, as Postgres prints them; usable in DNS names. */
|
|
@@ -31,12 +57,99 @@ export declare const INTERNAL_DATABASES_PATH = "/internal/v1/databases";
|
|
|
31
57
|
* DNS label.
|
|
32
58
|
*/
|
|
33
59
|
export declare const INTERNAL_ACCOUNTS_PATH = "/internal/v1/accounts";
|
|
60
|
+
/** `GET` lists every Domain that has Routes, with its Routes, for the Routes operator. */
|
|
61
|
+
export declare const INTERNAL_ROUTES_PATH = "/internal/v1/routes";
|
|
62
|
+
/** `GET` lists every Service with its Project, for the Services operator. */
|
|
63
|
+
export declare const INTERNAL_SERVICES_PATH = "/internal/v1/services";
|
|
64
|
+
/** `GET` lists every Job with its Project, for the Jobs operator. */
|
|
65
|
+
export declare const INTERNAL_JOBS_PATH = "/internal/v1/jobs";
|
|
66
|
+
/** The Traefik IngressRoute that serves one Domain, in its Project's namespace. */
|
|
67
|
+
export declare const ingressRouteName: (domainId: Id) => string;
|
|
68
|
+
/** A Route as the Routes operator needs it: the Bucket by name, or the Service with its port. */
|
|
69
|
+
export type RoutedPath = Pick<Route, 'id' | 'pathPrefix'> & ({
|
|
70
|
+
readonly kind: 'bucket';
|
|
71
|
+
readonly bucketName: string;
|
|
72
|
+
readonly spaFallback: boolean;
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: 'service';
|
|
75
|
+
readonly serviceId: Id;
|
|
76
|
+
readonly port: number;
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* One Domain as the Routes operator needs it: where it lives, its hostname,
|
|
80
|
+
* and its Routes with what each one serves.
|
|
81
|
+
*/
|
|
82
|
+
export interface DomainRouting {
|
|
83
|
+
readonly projectId: Id;
|
|
84
|
+
/** For the namespace's labels, which the Databases operator sets too. */
|
|
85
|
+
readonly projectName: string;
|
|
86
|
+
readonly domainId: Id;
|
|
87
|
+
readonly hostname: string;
|
|
88
|
+
/** A default Domain uses the customer domain's wildcard certificate; a custom one gets its own. */
|
|
89
|
+
readonly kind: Domain['kind'];
|
|
90
|
+
readonly routes: readonly RoutedPath[];
|
|
91
|
+
}
|
|
34
92
|
export interface AccountRecord extends Account {
|
|
35
93
|
readonly members: readonly Pick<Member, 'authSubject' | 'email'>[];
|
|
36
94
|
}
|
|
95
|
+
/** One Service as the Services operator needs it. */
|
|
96
|
+
export interface ServiceRow {
|
|
97
|
+
readonly project: Project;
|
|
98
|
+
readonly service: Pick<Service, 'id' | 'name' | 'image' | 'imageDigest' | 'replicas' | 'memoryMb' | 'cpuMillicores' | 'port'>;
|
|
99
|
+
/** What the Deployment runs: `<registry>/<repository>@<digest>`. */
|
|
100
|
+
readonly pinnedImage: string;
|
|
101
|
+
/** Where a single replica runs: the Service's homeSite, else the Project's oldest Database's, else `hetzner-fsn1`. */
|
|
102
|
+
readonly site: Site;
|
|
103
|
+
/**
|
|
104
|
+
* The version of the Project's Secrets in its Kubernetes Secret: it
|
|
105
|
+
* changes once the control plane has written new values there, never
|
|
106
|
+
* before. The operator puts it on the pod template, so a change rolls the
|
|
107
|
+
* Service and its pods read the new values.
|
|
108
|
+
*/
|
|
109
|
+
readonly secretsVersion: string;
|
|
110
|
+
/** The Project's live Databases, oldest first: the Service gets a DATABASE_URL for each (decision 97). */
|
|
111
|
+
readonly databases: readonly RowDatabase[];
|
|
112
|
+
}
|
|
113
|
+
/** A Database as a Service's or Job's row names it. */
|
|
114
|
+
export type RowDatabase = Pick<Database, 'id' | 'name'>;
|
|
115
|
+
/** On a Service's Deployment and a Job's CronJob: the spec version it was applied from (serviceSpecVersion, jobSpecVersion). */
|
|
116
|
+
export declare const SPEC_VERSION_ANNOTATION = "openupstream.io/spec-version";
|
|
117
|
+
/**
|
|
118
|
+
* Everything of a Service's row that its Deployment is rendered from. The
|
|
119
|
+
* Services operator writes it on the Deployment; the control plane reports
|
|
120
|
+
* `deploying` until the Deployment carries the version its row asks for,
|
|
121
|
+
* so a change is not `running` before it has been applied and rolled out.
|
|
122
|
+
*/
|
|
123
|
+
export declare const serviceSpecVersion: (row: Pick<ServiceRow, "service" | "pinnedImage" | "site" | "secretsVersion" | "databases">) => string;
|
|
124
|
+
/** One Job as the Jobs operator needs it. */
|
|
125
|
+
export interface JobRow {
|
|
126
|
+
readonly project: Project;
|
|
127
|
+
readonly job: Pick<Job, 'id' | 'name' | 'image' | 'imageDigest' | 'command' | 'args' | 'memoryMb' | 'cpuMillicores' | 'timeoutSeconds' | 'schedule' | 'timeZone'>;
|
|
128
|
+
/** What its runs start: `<registry>/<repository>@<digest>`. */
|
|
129
|
+
readonly pinnedImage: string;
|
|
130
|
+
/** Where its runs go: the Job's homeSite, else the Project's oldest Database's, else `hetzner-fsn1`. */
|
|
131
|
+
readonly site: Site;
|
|
132
|
+
/** The Project's live Databases, oldest first: its runs get a DATABASE_URL for each (decision 97). */
|
|
133
|
+
readonly databases: readonly RowDatabase[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Everything of a Job's row that its CronJob is rendered from. The Jobs
|
|
137
|
+
* operator writes it on the CronJob; until the CronJob carries the version
|
|
138
|
+
* the row asks for, the Job is `deploying` and no run starts from the old
|
|
139
|
+
* template. The Secrets are not part of it: a run's pod reads them when it
|
|
140
|
+
* starts, so nothing needs to change when they do.
|
|
141
|
+
*/
|
|
142
|
+
export declare const jobSpecVersion: (row: Pick<JobRow, "job" | "pinnedImage" | "site" | "databases">) => string;
|
|
37
143
|
export interface DatabaseRow {
|
|
38
144
|
readonly project: Project;
|
|
39
145
|
readonly database: Database;
|
|
146
|
+
/**
|
|
147
|
+
* A restored Database whose Cluster has not had a ready instance yet:
|
|
148
|
+
* the operator renders its recovery bootstrap from `database.restoredFrom`
|
|
149
|
+
* (decision 108). Once finished, its Cluster is rendered like any other,
|
|
150
|
+
* so it no longer depends on the source's ObjectStore.
|
|
151
|
+
*/
|
|
152
|
+
readonly restoring?: boolean;
|
|
40
153
|
}
|
|
41
154
|
/**
|
|
42
155
|
* The platform's own Account, Project and Databases: the control plane's
|
|
@@ -64,6 +177,8 @@ export declare const PLATFORM: {
|
|
|
64
177
|
readonly homeSite: "hetzner-fsn1";
|
|
65
178
|
readonly memoryMb: 512;
|
|
66
179
|
readonly storageGb: 5;
|
|
180
|
+
readonly autoGrow: true;
|
|
181
|
+
readonly maxStorageGb: null;
|
|
67
182
|
readonly createdAt: "2026-10-17T00:00:00Z";
|
|
68
183
|
};
|
|
69
184
|
readonly authDatabase: {
|
|
@@ -73,6 +188,8 @@ export declare const PLATFORM: {
|
|
|
73
188
|
readonly homeSite: "hetzner-fsn1";
|
|
74
189
|
readonly memoryMb: 512;
|
|
75
190
|
readonly storageGb: 2;
|
|
191
|
+
readonly autoGrow: true;
|
|
192
|
+
readonly maxStorageGb: null;
|
|
76
193
|
readonly createdAt: "2026-10-17T00:00:00Z";
|
|
77
194
|
};
|
|
78
195
|
/** The billing service's state; seeded only where a billing service runs (BILLING_CALLERS). */
|
|
@@ -83,6 +200,8 @@ export declare const PLATFORM: {
|
|
|
83
200
|
readonly homeSite: "hetzner-fsn1";
|
|
84
201
|
readonly memoryMb: 512;
|
|
85
202
|
readonly storageGb: 2;
|
|
203
|
+
readonly autoGrow: true;
|
|
204
|
+
readonly maxStorageGb: null;
|
|
86
205
|
readonly createdAt: "2026-10-20T00:00:00Z";
|
|
87
206
|
};
|
|
88
207
|
};
|
package/dist/internal.js
CHANGED
|
@@ -7,6 +7,37 @@ export const projectNamespace = (projectId) => `project-${projectId}`;
|
|
|
7
7
|
export const clusterName = (database) => `db-${database.id}`;
|
|
8
8
|
/** Cannot share the Cluster's name, nor `<cluster>-rw`, which the Cluster's own Service takes. */
|
|
9
9
|
export const poolerName = (database) => `${clusterName(database)}-pooler`;
|
|
10
|
+
/** The Secret CloudNativePG keeps the Database's `app` user in, with its generated `password`. */
|
|
11
|
+
export const databaseAppSecret = (database) => `${clusterName(database)}-app`;
|
|
12
|
+
/** Where the Project's Services and Jobs reach the Database: its Pooler, inside the cluster. */
|
|
13
|
+
export const databaseConnection = (database) => ({
|
|
14
|
+
host: `${poolerName(database)}.${projectNamespace(database.projectId)}.svc.cluster.local`,
|
|
15
|
+
port: 5432,
|
|
16
|
+
database: 'app',
|
|
17
|
+
user: 'app',
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The Kubernetes Secret in a Project's namespace that holds all its Secrets'
|
|
21
|
+
* values; the control plane writes it, Services and Jobs read it with `envFrom`.
|
|
22
|
+
*/
|
|
23
|
+
export const PROJECT_SECRETS = 'project-secrets';
|
|
24
|
+
/**
|
|
25
|
+
* The `kubernetes.io/dockerconfigjson` Secret in a Project's namespace with
|
|
26
|
+
* the registry credentials of all its Services and Jobs, each under its
|
|
27
|
+
* image's repository; the control plane writes it, every Service and Job
|
|
28
|
+
* names it in `imagePullSecrets`.
|
|
29
|
+
*/
|
|
30
|
+
export const PROJECT_REGISTRY_AUTH = 'project-registry-auth';
|
|
31
|
+
/** The Service's Deployment and Kubernetes Service, in its Project's namespace. */
|
|
32
|
+
export const serviceObjectName = (service) => `svc-${service.id}`;
|
|
33
|
+
/** The Job's CronJob, in its Project's namespace; its runs are Kubernetes Jobs named after it. */
|
|
34
|
+
export const jobObjectName = (job) => `job-${job.id}`;
|
|
35
|
+
/** On a Service's Deployment and its pods: the Service's id, by which the control plane finds the pods for its logs. */
|
|
36
|
+
export const SERVICE_ID_LABEL = 'openupstream.io/service-id';
|
|
37
|
+
/** On a Job's CronJob and its runs: the Job's id, by which the control plane lists the runs. */
|
|
38
|
+
export const JOB_ID_LABEL = 'openupstream.io/job-id';
|
|
39
|
+
/** On a run the control plane started (a One-off job): `api`. Scheduled runs do not have it. */
|
|
40
|
+
export const RUN_TRIGGER_LABEL = 'openupstream.io/trigger';
|
|
10
41
|
/** The folder under the backup bucket that holds one Database's base backups and WAL. */
|
|
11
42
|
export const backupPrefix = (projectId, databaseId) => `${projectNamespace(projectId)}/${clusterName({ id: databaseId })}/`;
|
|
12
43
|
/** Ids are lowercase UUIDs, as Postgres prints them; usable in DNS names. */
|
|
@@ -24,6 +55,51 @@ export const INTERNAL_DATABASES_PATH = '/internal/v1/databases';
|
|
|
24
55
|
* DNS label.
|
|
25
56
|
*/
|
|
26
57
|
export const INTERNAL_ACCOUNTS_PATH = '/internal/v1/accounts';
|
|
58
|
+
/** `GET` lists every Domain that has Routes, with its Routes, for the Routes operator. */
|
|
59
|
+
export const INTERNAL_ROUTES_PATH = '/internal/v1/routes';
|
|
60
|
+
/** `GET` lists every Service with its Project, for the Services operator. */
|
|
61
|
+
export const INTERNAL_SERVICES_PATH = '/internal/v1/services';
|
|
62
|
+
/** `GET` lists every Job with its Project, for the Jobs operator. */
|
|
63
|
+
export const INTERNAL_JOBS_PATH = '/internal/v1/jobs';
|
|
64
|
+
/** The Traefik IngressRoute that serves one Domain, in its Project's namespace. */
|
|
65
|
+
export const ingressRouteName = (domainId) => `domain-${domainId}`;
|
|
66
|
+
/** On a Service's Deployment and a Job's CronJob: the spec version it was applied from (serviceSpecVersion, jobSpecVersion). */
|
|
67
|
+
export const SPEC_VERSION_ANNOTATION = 'openupstream.io/spec-version';
|
|
68
|
+
/**
|
|
69
|
+
* Everything of a Service's row that its Deployment is rendered from. The
|
|
70
|
+
* Services operator writes it on the Deployment; the control plane reports
|
|
71
|
+
* `deploying` until the Deployment carries the version its row asks for,
|
|
72
|
+
* so a change is not `running` before it has been applied and rolled out.
|
|
73
|
+
*/
|
|
74
|
+
export const serviceSpecVersion = (row) => [
|
|
75
|
+
row.pinnedImage,
|
|
76
|
+
row.service.replicas,
|
|
77
|
+
row.service.memoryMb,
|
|
78
|
+
row.service.cpuMillicores,
|
|
79
|
+
row.service.port,
|
|
80
|
+
row.site,
|
|
81
|
+
row.secretsVersion,
|
|
82
|
+
...row.databases.map((database) => `${database.id}=${database.name}`),
|
|
83
|
+
].join('|');
|
|
84
|
+
/**
|
|
85
|
+
* Everything of a Job's row that its CronJob is rendered from. The Jobs
|
|
86
|
+
* operator writes it on the CronJob; until the CronJob carries the version
|
|
87
|
+
* the row asks for, the Job is `deploying` and no run starts from the old
|
|
88
|
+
* template. The Secrets are not part of it: a run's pod reads them when it
|
|
89
|
+
* starts, so nothing needs to change when they do.
|
|
90
|
+
*/
|
|
91
|
+
export const jobSpecVersion = (row) => JSON.stringify([
|
|
92
|
+
row.pinnedImage,
|
|
93
|
+
row.job.command,
|
|
94
|
+
row.job.args,
|
|
95
|
+
row.job.memoryMb,
|
|
96
|
+
row.job.cpuMillicores,
|
|
97
|
+
row.job.timeoutSeconds,
|
|
98
|
+
row.job.schedule,
|
|
99
|
+
row.job.timeZone,
|
|
100
|
+
row.site,
|
|
101
|
+
row.databases,
|
|
102
|
+
]);
|
|
27
103
|
/**
|
|
28
104
|
* The platform's own Account, Project and Databases: the control plane's
|
|
29
105
|
* state (`database`) and madAuth's users (`authDatabase`). The bootstrap
|
|
@@ -50,6 +126,8 @@ export const PLATFORM = {
|
|
|
50
126
|
homeSite: 'hetzner-fsn1',
|
|
51
127
|
memoryMb: 512,
|
|
52
128
|
storageGb: 5,
|
|
129
|
+
autoGrow: true,
|
|
130
|
+
maxStorageGb: null,
|
|
53
131
|
createdAt: '2026-10-17T00:00:00Z',
|
|
54
132
|
},
|
|
55
133
|
authDatabase: {
|
|
@@ -59,6 +137,8 @@ export const PLATFORM = {
|
|
|
59
137
|
homeSite: 'hetzner-fsn1',
|
|
60
138
|
memoryMb: 512,
|
|
61
139
|
storageGb: 2,
|
|
140
|
+
autoGrow: true,
|
|
141
|
+
maxStorageGb: null,
|
|
62
142
|
createdAt: '2026-10-17T00:00:00Z',
|
|
63
143
|
},
|
|
64
144
|
/** The billing service's state; seeded only where a billing service runs (BILLING_CALLERS). */
|
|
@@ -69,6 +149,8 @@ export const PLATFORM = {
|
|
|
69
149
|
homeSite: 'hetzner-fsn1',
|
|
70
150
|
memoryMb: 512,
|
|
71
151
|
storageGb: 2,
|
|
152
|
+
autoGrow: true,
|
|
153
|
+
maxStorageGb: null,
|
|
72
154
|
createdAt: '2026-10-20T00:00:00Z',
|
|
73
155
|
},
|
|
74
156
|
};
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAa,EAAU,EAAE,CAAC,WAAW,SAAS,EAAE,CAAC;AAElF,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAC;AAE3F,kGAAkG;AAClG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;AAExG,yFAAyF;AACzF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAa,EAAE,UAAc,EAAU,EAAE,CAClE,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;AAEzE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,IAAI,GAAG,gEAAgE,CAAC;AAErF,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAE7D,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE,mDAAmD;AACnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAa,EAAU,EAAE,CAAC,WAAW,SAAS,EAAE,CAAC;AAElF,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAA8B,EAAU,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAC;AAE3F,kG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EAAE,IAAI;QAClB,SAAS,EAAE,sBAAsB;KACpC;IACD,+FAA+F;IAC/F,eAAe,EAAE;QACb,EAAE,EAAE,sCAAsC;QAC1C,SAAS,EAAE,sCAAsC;QACjD,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,cAAc;QACxB,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,sBAAsB;KACpC;CAOJ,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAA2B;IACjD,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC1D,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAY,EAAE;CACjE,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export type Id = string;
|
|
8
8
|
export type Timestamp = string;
|
|
9
|
-
/** Compute Sites, where Databases and
|
|
9
|
+
/** Compute Sites, where Databases, Services and Jobs run. Both are in Germany. */
|
|
10
10
|
export declare const COMPUTE_SITES: readonly ["hetzner-fsn1", "ovh-lim"];
|
|
11
11
|
export type Site = (typeof COMPUTE_SITES)[number];
|
|
12
12
|
/** The customer: pays, receives one invoice, owns Projects. */
|
|
@@ -48,7 +48,25 @@ export interface Database {
|
|
|
48
48
|
homeSite: Site;
|
|
49
49
|
memoryMb: number;
|
|
50
50
|
storageGb: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether storage grows by itself (decision 111): by half once a volume
|
|
53
|
+
* is 90% used, up to maxStorageGb. False: only resizing grows it.
|
|
54
|
+
*/
|
|
55
|
+
autoGrow: boolean;
|
|
56
|
+
/** How far auto-grow may take storageGb; null: no limit but the nodes' free space. */
|
|
57
|
+
maxStorageGb: number | null;
|
|
51
58
|
createdAt: Timestamp;
|
|
59
|
+
/** Set when the Database started as a copy of another one. */
|
|
60
|
+
restoredFrom?: DatabaseRestore;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Where a restored Database's data comes from (decision 108): another
|
|
64
|
+
* Database of the same Project, live or deleted within the backup retention
|
|
65
|
+
* window, at `targetTime`; without it, the latest point its backups reach.
|
|
66
|
+
*/
|
|
67
|
+
export interface DatabaseRestore {
|
|
68
|
+
databaseId: Id;
|
|
69
|
+
targetTime?: Timestamp;
|
|
52
70
|
}
|
|
53
71
|
/** Creates an Account; the caller becomes its first Member. */
|
|
54
72
|
export interface AccountInput {
|
|
@@ -68,25 +86,48 @@ export interface ProjectInput {
|
|
|
68
86
|
accountId: Id;
|
|
69
87
|
name: string;
|
|
70
88
|
}
|
|
71
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Creates a Database; homeSite defaults to `hetzner-fsn1`. With
|
|
91
|
+
* `restoreFrom`, it starts as a copy of that Database instead of empty.
|
|
92
|
+
*/
|
|
72
93
|
export interface DatabaseInput {
|
|
73
94
|
name: string;
|
|
74
95
|
homeSite?: Site;
|
|
75
96
|
memoryMb: number;
|
|
76
97
|
storageGb: number;
|
|
98
|
+
/** Default true. */
|
|
99
|
+
autoGrow?: boolean;
|
|
100
|
+
/** Default null: no limit. At least storageGb. */
|
|
101
|
+
maxStorageGb?: number | null;
|
|
102
|
+
restoreFrom?: DatabaseRestore;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resizes a Database (decision 110). Storage only grows: a volume cannot
|
|
106
|
+
* shrink. A new memory size restarts the instances one after the other,
|
|
107
|
+
* the standby first, then a switchover (writes pause for seconds).
|
|
108
|
+
*/
|
|
109
|
+
export interface DatabasePatch {
|
|
110
|
+
memoryMb?: number;
|
|
111
|
+
storageGb?: number;
|
|
112
|
+
autoGrow?: boolean;
|
|
113
|
+
/** null removes the limit. */
|
|
114
|
+
maxStorageGb?: number | null;
|
|
77
115
|
}
|
|
78
116
|
/**
|
|
79
117
|
* - `provisioning`: being created, or not yet seen by the operator
|
|
118
|
+
* - `resizing`: its Cluster does not have the size the Database asks for yet
|
|
80
119
|
* - `ready`: both instances healthy
|
|
81
120
|
* - `degraded`: running, but not every instance is healthy (e.g. during a
|
|
82
121
|
* failover)
|
|
83
122
|
* - `unknown`: the platform could not check just now
|
|
84
123
|
*/
|
|
85
|
-
export type DatabaseState = 'provisioning' | 'ready' | 'degraded' | 'unknown';
|
|
124
|
+
export type DatabaseState = 'provisioning' | 'resizing' | 'ready' | 'degraded' | 'unknown';
|
|
86
125
|
/**
|
|
87
|
-
* Where the Project's Services reach the Database: through its
|
|
88
|
-
* (transaction pooling), inside the cluster only. The password is
|
|
89
|
-
* returned;
|
|
126
|
+
* Where the Project's Services and Jobs reach the Database: through its
|
|
127
|
+
* PgBouncer (transaction pooling), inside the cluster only. The password is
|
|
128
|
+
* never returned; every Service and Job of the Project gets the whole URL as
|
|
129
|
+
* `DATABASE_URL_<NAME>` (the name upper-cased, `-` as `_`), and the oldest
|
|
130
|
+
* Database's also as `DATABASE_URL` (decision 97).
|
|
90
131
|
*/
|
|
91
132
|
export interface DatabaseConnection {
|
|
92
133
|
host: string;
|
|
@@ -99,6 +140,11 @@ export interface DatabaseDetails extends Database {
|
|
|
99
140
|
state: DatabaseState;
|
|
100
141
|
connection: DatabaseConnection;
|
|
101
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* A Bucket's name: a hostname label of 3 to 63 lowercase letters, digits
|
|
145
|
+
* and hyphens, neither starting nor ending with a hyphen.
|
|
146
|
+
*/
|
|
147
|
+
export declare const BUCKET_NAME: RegExp;
|
|
102
148
|
export interface Bucket {
|
|
103
149
|
id: Id;
|
|
104
150
|
projectId: Id;
|
|
@@ -106,6 +152,55 @@ export interface Bucket {
|
|
|
106
152
|
name: string;
|
|
107
153
|
createdAt: Timestamp;
|
|
108
154
|
}
|
|
155
|
+
/** Creates a Bucket; the name must not be taken in any Project. */
|
|
156
|
+
export interface BucketInput {
|
|
157
|
+
name: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* How to reach a Bucket with any S3 client: virtual-hosted style only, at
|
|
161
|
+
* `endpoint` (the Bucket's own hostname), with the Bucket's key. The key
|
|
162
|
+
* reads and writes this Bucket and no other.
|
|
163
|
+
*/
|
|
164
|
+
export interface BucketAccess {
|
|
165
|
+
/** `https://<name>.s3.<customer domain>`. */
|
|
166
|
+
endpoint: string;
|
|
167
|
+
/** What S3 clients sign requests with; Garage accepts only this one. */
|
|
168
|
+
region: string;
|
|
169
|
+
accessKeyId: string;
|
|
170
|
+
/** Left out for an API key with only `openupstream:read`: the key itself may write. */
|
|
171
|
+
secretAccessKey?: string;
|
|
172
|
+
}
|
|
173
|
+
/** A Bucket as the API returns it. The list leaves out `access`. */
|
|
174
|
+
export interface BucketDetails extends Bucket {
|
|
175
|
+
access: BucketAccess;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A container image from any registry, as given: `nginx:1.27`,
|
|
179
|
+
* `ghcr.io/acme/api:v3`, `registry.example.com:5000/team/app@sha256:…`.
|
|
180
|
+
* A reference without a tag means `latest`.
|
|
181
|
+
*/
|
|
182
|
+
export declare const IMAGE_REFERENCE_MAX_LENGTH = 512;
|
|
183
|
+
/**
|
|
184
|
+
* Credentials for a private registry: write-only, stored encrypted with the
|
|
185
|
+
* Project's Secrets and never returned. The registry is the image's.
|
|
186
|
+
*/
|
|
187
|
+
export interface RegistryAuth {
|
|
188
|
+
username: string;
|
|
189
|
+
password: string;
|
|
190
|
+
}
|
|
191
|
+
/** Limits of a Service, checked by the API. */
|
|
192
|
+
export declare const SERVICE_LIMITS: {
|
|
193
|
+
readonly maxReplicas: 10;
|
|
194
|
+
readonly minMemoryMb: 64;
|
|
195
|
+
readonly maxMemoryMb: 16384;
|
|
196
|
+
readonly minCpuMillicores: 50;
|
|
197
|
+
readonly maxCpuMillicores: 8000;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* A container, always on, 1..N replicas (ARCHITECTURE.md, "Containers"):
|
|
201
|
+
* an HTTP server, or a worker without a port. Its image is pinned to a
|
|
202
|
+
* digest whenever it is deployed.
|
|
203
|
+
*/
|
|
109
204
|
export interface Service {
|
|
110
205
|
id: Id;
|
|
111
206
|
projectId: Id;
|
|
@@ -113,15 +208,244 @@ export interface Service {
|
|
|
113
208
|
name: string;
|
|
114
209
|
/** The image reference as given, from any registry. */
|
|
115
210
|
image: string;
|
|
116
|
-
/** `sha256:…`,
|
|
117
|
-
imageDigest: string
|
|
211
|
+
/** `sha256:…`, the digest the tag resolved to when the Service was last deployed. */
|
|
212
|
+
imageDigest: string;
|
|
213
|
+
/** When the tag was last resolved: at creation, on a change of image, and on every deploy. */
|
|
214
|
+
deployedAt: Timestamp;
|
|
118
215
|
replicas: number;
|
|
119
216
|
memoryMb: number;
|
|
120
217
|
cpuMillicores: number;
|
|
121
|
-
/**
|
|
122
|
-
|
|
218
|
+
/**
|
|
219
|
+
* The HTTP port the container listens on; null: a worker, which no Route
|
|
220
|
+
* can serve, gets no in-cluster address and counts as ready once it runs
|
|
221
|
+
* (decision 98).
|
|
222
|
+
*/
|
|
223
|
+
port: number | null;
|
|
224
|
+
/**
|
|
225
|
+
* Where a single replica runs; null: the Home site of the Project's oldest
|
|
226
|
+
* Database, or `hetzner-fsn1`. Two or more replicas run in both Sites.
|
|
227
|
+
*/
|
|
228
|
+
homeSite: Site | null;
|
|
229
|
+
/** Whether the image is pulled with registry credentials. */
|
|
230
|
+
registryAuth: boolean;
|
|
231
|
+
createdAt: Timestamp;
|
|
232
|
+
}
|
|
233
|
+
/** Creates a Service; the tag is resolved to a digest while the request waits. */
|
|
234
|
+
export interface ServiceInput {
|
|
235
|
+
name: string;
|
|
236
|
+
image: string;
|
|
237
|
+
/** Left out: a worker without a port. */
|
|
238
|
+
port?: number;
|
|
239
|
+
/** Default 1. */
|
|
240
|
+
replicas?: number;
|
|
241
|
+
memoryMb: number;
|
|
242
|
+
cpuMillicores: number;
|
|
243
|
+
homeSite?: Site;
|
|
244
|
+
registryAuth?: RegistryAuth;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Changes a Service. A new `image` or `registryAuth` resolves the tag again;
|
|
248
|
+
* `registryAuth: null` removes the credentials, `homeSite: null` the choice,
|
|
249
|
+
* `port: null` the port (refused while a Route serves the Service).
|
|
250
|
+
*/
|
|
251
|
+
export interface ServicePatch {
|
|
252
|
+
image?: string;
|
|
253
|
+
port?: number | null;
|
|
254
|
+
replicas?: number;
|
|
255
|
+
memoryMb?: number;
|
|
256
|
+
cpuMillicores?: number;
|
|
257
|
+
homeSite?: Site | null;
|
|
258
|
+
registryAuth?: RegistryAuth | null;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Read live from its Deployment: `deploying` until the first replica is
|
|
262
|
+
* up and while a new version rolls out, `running` with every replica
|
|
263
|
+
* available, `degraded` with some, `unknown` when Kubernetes cannot be asked.
|
|
264
|
+
*/
|
|
265
|
+
export type ServiceState = 'deploying' | 'running' | 'degraded' | 'unknown';
|
|
266
|
+
/** A Service as the API returns it. */
|
|
267
|
+
export interface ServiceDetails extends Service {
|
|
268
|
+
state: ServiceState;
|
|
269
|
+
}
|
|
270
|
+
/** Limits of a Job, checked by the API; memory and CPU as for a Service. */
|
|
271
|
+
export declare const JOB_LIMITS: {
|
|
272
|
+
readonly minMemoryMb: 64;
|
|
273
|
+
readonly maxMemoryMb: 16384;
|
|
274
|
+
readonly minCpuMillicores: 50;
|
|
275
|
+
readonly maxCpuMillicores: 8000;
|
|
276
|
+
readonly defaultTimeoutSeconds: 3600;
|
|
277
|
+
readonly maxTimeoutSeconds: 86400;
|
|
278
|
+
/** Entries of `command` and of `args`, and their bytes (UTF-8) together, which go into a Kubernetes annotation. */
|
|
279
|
+
readonly maxArgs: 256;
|
|
280
|
+
readonly maxArgsTotalBytes: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* A container image run to completion (ARCHITECTURE.md, "Containers"): a
|
|
284
|
+
* Cron job when it has a `schedule`, and started as a One-off job through
|
|
285
|
+
* the API whether or not it has one. Its image is pinned to a digest
|
|
286
|
+
* whenever it is deployed; every run starts that digest.
|
|
287
|
+
*/
|
|
288
|
+
export interface Job {
|
|
289
|
+
id: Id;
|
|
290
|
+
projectId: Id;
|
|
291
|
+
/** DNS label, unique within the Project. */
|
|
292
|
+
name: string;
|
|
293
|
+
/** The image reference as given, from any registry. */
|
|
294
|
+
image: string;
|
|
295
|
+
/** `sha256:…`, the digest the tag resolved to when the Job was last deployed. */
|
|
296
|
+
imageDigest: string;
|
|
297
|
+
/** When the tag was last resolved: at creation, on a change of image, and on every deploy. */
|
|
298
|
+
deployedAt: Timestamp;
|
|
299
|
+
/** Replaces the image's entrypoint; null: the image's. */
|
|
300
|
+
command: string[] | null;
|
|
301
|
+
/** Replaces the image's command (its CMD); null: the image's. A run may replace it again. */
|
|
302
|
+
args: string[] | null;
|
|
303
|
+
memoryMb: number;
|
|
304
|
+
cpuMillicores: number;
|
|
305
|
+
/** A run still going after this long is stopped and failed. */
|
|
306
|
+
timeoutSeconds: number;
|
|
307
|
+
/**
|
|
308
|
+
* Five-field cron expression (`*\/15 * * * *`) or `@hourly`, `@daily`,
|
|
309
|
+
* `@weekly`, `@monthly`, `@yearly`; null: started only through the API.
|
|
310
|
+
* A run that is due while the previous one still runs is skipped.
|
|
311
|
+
*/
|
|
312
|
+
schedule: string | null;
|
|
313
|
+
/** IANA time zone the schedule is read in, e.g. `Europe/Berlin`; null: UTC. */
|
|
314
|
+
timeZone: string | null;
|
|
315
|
+
/** Where its runs go; null: the Home site of the Project's oldest Database, or `hetzner-fsn1`. */
|
|
316
|
+
homeSite: Site | null;
|
|
317
|
+
/** Whether the image is pulled with registry credentials. */
|
|
318
|
+
registryAuth: boolean;
|
|
123
319
|
createdAt: Timestamp;
|
|
124
320
|
}
|
|
321
|
+
/** Creates a Job; the tag is resolved to a digest while the request waits. */
|
|
322
|
+
export interface JobInput {
|
|
323
|
+
name: string;
|
|
324
|
+
image: string;
|
|
325
|
+
command?: string[];
|
|
326
|
+
args?: string[];
|
|
327
|
+
memoryMb: number;
|
|
328
|
+
cpuMillicores: number;
|
|
329
|
+
/** Default JOB_LIMITS.defaultTimeoutSeconds. */
|
|
330
|
+
timeoutSeconds?: number;
|
|
331
|
+
schedule?: string;
|
|
332
|
+
timeZone?: string;
|
|
333
|
+
homeSite?: Site;
|
|
334
|
+
registryAuth?: RegistryAuth;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Changes a Job. A new `image` or `registryAuth` resolves the tag again;
|
|
338
|
+
* null removes a `command`, `args`, `schedule`, `timeZone`, `homeSite` or
|
|
339
|
+
* the registry credentials.
|
|
340
|
+
*/
|
|
341
|
+
export interface JobPatch {
|
|
342
|
+
image?: string;
|
|
343
|
+
command?: string[] | null;
|
|
344
|
+
args?: string[] | null;
|
|
345
|
+
memoryMb?: number;
|
|
346
|
+
cpuMillicores?: number;
|
|
347
|
+
timeoutSeconds?: number;
|
|
348
|
+
schedule?: string | null;
|
|
349
|
+
timeZone?: string | null;
|
|
350
|
+
homeSite?: Site | null;
|
|
351
|
+
registryAuth?: RegistryAuth | null;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Read live from its CronJob: `deploying` until the Jobs operator has
|
|
355
|
+
* applied the Job as it is now, `ready` once it has (runs can start),
|
|
356
|
+
* `unknown` when Kubernetes cannot be asked.
|
|
357
|
+
*/
|
|
358
|
+
export type JobState = 'deploying' | 'ready' | 'unknown';
|
|
359
|
+
/** A Job as the API returns it. */
|
|
360
|
+
export interface JobDetails extends Job {
|
|
361
|
+
state: JobState;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Read live from its Kubernetes Job: `pending` until its container runs
|
|
365
|
+
* (e.g. while the image is pulled), `running`, then `succeeded` (exit 0) or
|
|
366
|
+
* `failed` (another exit code, or stopped at the timeout).
|
|
367
|
+
*/
|
|
368
|
+
export type JobRunState = 'pending' | 'running' | 'succeeded' | 'failed';
|
|
369
|
+
/**
|
|
370
|
+
* One run of a Job, scheduled or started through the API. Kept for 24 hours
|
|
371
|
+
* after it finished; a Cron job keeps at most its last 3 successful and 3
|
|
372
|
+
* failed scheduled runs.
|
|
373
|
+
*/
|
|
374
|
+
export interface JobRun {
|
|
375
|
+
/** Unique within the Project; the name of its Kubernetes Job. */
|
|
376
|
+
id: string;
|
|
377
|
+
jobId: Id;
|
|
378
|
+
/** `schedule` for a Cron job's run, `api` for a One-off job. */
|
|
379
|
+
trigger: 'schedule' | 'api';
|
|
380
|
+
state: JobRunState;
|
|
381
|
+
/**
|
|
382
|
+
* Why it failed, as Kubernetes says: `BackoffLimitExceeded` (it exited
|
|
383
|
+
* with an error), `DeadlineExceeded` (stopped at the timeout); null
|
|
384
|
+
* otherwise.
|
|
385
|
+
*/
|
|
386
|
+
reason: string | null;
|
|
387
|
+
createdAt: Timestamp;
|
|
388
|
+
startedAt: Timestamp | null;
|
|
389
|
+
finishedAt: Timestamp | null;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Starts a One-off job. `args` replaces the Job's args for this run; `env`
|
|
393
|
+
* adds variables to it, over Secrets of the same name. Together with the
|
|
394
|
+
* Job's command and args at most JOB_LIMITS.maxArgsTotalBytes.
|
|
395
|
+
*/
|
|
396
|
+
export interface JobRunInput {
|
|
397
|
+
args?: string[];
|
|
398
|
+
env?: Record<string, string>;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* One line of a Service's or a run's output, as the log stream sends it
|
|
402
|
+
* (ARCHITECTURE.md, "Observability and customer logs"): a live tail only,
|
|
403
|
+
* nothing is retained (decision 21).
|
|
404
|
+
*/
|
|
405
|
+
export interface LogEntry {
|
|
406
|
+
/** The pod (replica or run) it came from. */
|
|
407
|
+
pod: string;
|
|
408
|
+
/** The Site the pod runs in; null when Kubernetes does not say. */
|
|
409
|
+
site: Site | null;
|
|
410
|
+
/** When the container wrote it, as Kubernetes recorded it (RFC 3339, nanoseconds). */
|
|
411
|
+
time: string;
|
|
412
|
+
/** The line, without its line break. */
|
|
413
|
+
line: string;
|
|
414
|
+
/** From the container before its last restart (a crash): what it wrote before it died. */
|
|
415
|
+
previous: boolean;
|
|
416
|
+
}
|
|
417
|
+
/** Limits of the log stream, checked by the API. */
|
|
418
|
+
export declare const LOG_LIMITS: {
|
|
419
|
+
/** Lines per container sent first, when `tail` is not given. */
|
|
420
|
+
readonly defaultTailLines: 100;
|
|
421
|
+
readonly maxTailLines: 10000;
|
|
422
|
+
/** A followed stream ends after this long; the client asks again to go on. */
|
|
423
|
+
readonly maxFollowSeconds: 3600;
|
|
424
|
+
/** Followed streams open at once per Account, on one control-plane replica; more answer 429. */
|
|
425
|
+
readonly maxFollowsPerAccount: 10;
|
|
426
|
+
/** A followed stream sends an empty line this often, so a client and the proxies between see it is alive. */
|
|
427
|
+
readonly heartbeatSeconds: 30;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* What to read: `tail` lines per container first; with `follow`, then new
|
|
431
|
+
* lines as they are written, also from replicas that start while it runs,
|
|
432
|
+
* until LOG_LIMITS.maxFollowSeconds have passed or every pod is gone.
|
|
433
|
+
* `tail` 0 sends only what is written from now on. Empty lines in the
|
|
434
|
+
* stream are heartbeats, not entries.
|
|
435
|
+
*/
|
|
436
|
+
export interface LogQuery {
|
|
437
|
+
tail?: number;
|
|
438
|
+
follow?: boolean;
|
|
439
|
+
}
|
|
440
|
+
/** A Secret's name is an environment variable name (the schema checks the same). */
|
|
441
|
+
export declare const SECRET_NAME: RegExp;
|
|
442
|
+
/**
|
|
443
|
+
* At most this many bytes (UTF-8) per value, and all of a Project's values
|
|
444
|
+
* together at most SECRETS_MAX_TOTAL_BYTES: they go into one Kubernetes
|
|
445
|
+
* Secret (1 MiB at most) and into every container's environment.
|
|
446
|
+
*/
|
|
447
|
+
export declare const SECRET_VALUE_MAX_BYTES: number;
|
|
448
|
+
export declare const SECRETS_MAX_TOTAL_BYTES: number;
|
|
125
449
|
/**
|
|
126
450
|
* A Secret's value is write-only: the API accepts it and hands it to the
|
|
127
451
|
* Project's Services and jobs as an environment variable, but never returns it.
|
|
@@ -138,6 +462,14 @@ export interface SecretInput {
|
|
|
138
462
|
name: string;
|
|
139
463
|
value: string;
|
|
140
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Where `oup login` signs in (`GET /v1/login`, no token needed): madAuth's
|
|
467
|
+
* issuer and the CLI's client ID there, for the device authorization grant.
|
|
468
|
+
*/
|
|
469
|
+
export interface CliLogin {
|
|
470
|
+
issuer: string;
|
|
471
|
+
clientId: string;
|
|
472
|
+
}
|
|
141
473
|
/** The TXT record that proves an Account owns a custom domain. */
|
|
142
474
|
export interface TxtRecord {
|
|
143
475
|
name: string;
|
|
@@ -172,6 +504,24 @@ export interface CustomDomain extends DomainBase {
|
|
|
172
504
|
export type Domain = DefaultDomain | CustomDomain;
|
|
173
505
|
/** Where the TXT ownership proof for `hostname` has to be published. */
|
|
174
506
|
export declare function txtRecordName(hostname: string): string;
|
|
507
|
+
/**
|
|
508
|
+
* A custom domain's hostname: lowercase labels of letters, digits and
|
|
509
|
+
* hyphens, at least two of them, at most 253 characters (the schema checks
|
|
510
|
+
* the same).
|
|
511
|
+
*/
|
|
512
|
+
export declare const HOSTNAME: RegExp;
|
|
513
|
+
/**
|
|
514
|
+
* Claims a custom domain for a Project. It is routed once its TXT record
|
|
515
|
+
* (`verification.txtRecord`) is published and verified; point the hostname
|
|
516
|
+
* at `ingress.<customer domain>` with a CNAME for traffic and its
|
|
517
|
+
* certificate, before adding the first Route: its certificate is requested
|
|
518
|
+
* then, and a failed attempt is retried only after an hour.
|
|
519
|
+
*/
|
|
520
|
+
export interface CustomDomainInput {
|
|
521
|
+
hostname: string;
|
|
522
|
+
}
|
|
523
|
+
/** A Route's path prefix: `/` or `/segment[/segment…]`, no trailing slash (the schema checks the same). */
|
|
524
|
+
export declare const PATH_PREFIX: RegExp;
|
|
175
525
|
export type RouteTarget = {
|
|
176
526
|
kind: 'bucket';
|
|
177
527
|
bucketId: Id;
|
|
@@ -192,6 +542,22 @@ export interface Route {
|
|
|
192
542
|
target: RouteTarget;
|
|
193
543
|
createdAt: Timestamp;
|
|
194
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Creates a Route to a Bucket or a Service of the same Project. For a
|
|
547
|
+
* Bucket the prefix is stripped: `/docs/a.html` on the Route `/docs` serves
|
|
548
|
+
* the object `a.html`. With `spaFallback`, a path with no object serves
|
|
549
|
+
* `index.html` with status 200; every Route to one Bucket has the same
|
|
550
|
+
* `spaFallback`. A Service gets the path unchanged.
|
|
551
|
+
*/
|
|
552
|
+
export type RouteInput = {
|
|
553
|
+
pathPrefix: string;
|
|
554
|
+
bucketId: Id;
|
|
555
|
+
spaFallback?: boolean;
|
|
556
|
+
} | {
|
|
557
|
+
pathPrefix: string;
|
|
558
|
+
/** The Service gets the request with its path as it came, prefix included. */
|
|
559
|
+
serviceId: Id;
|
|
560
|
+
};
|
|
195
561
|
export declare const RESOURCE_KINDS: readonly ["database", "bucket", "service"];
|
|
196
562
|
export type ResourceKind = (typeof RESOURCE_KINDS)[number];
|
|
197
563
|
export declare const USAGE_UNITS: readonly ["cpu_seconds", "memory_gb_hours", "storage_gb_hours", "egress_gb"];
|
package/dist/model.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Ids are UUIDs, timestamps RFC 3339 strings.
|
|
6
6
|
*/
|
|
7
|
-
/** Compute Sites, where Databases and
|
|
7
|
+
/** Compute Sites, where Databases, Services and Jobs run. Both are in Germany. */
|
|
8
8
|
export const COMPUTE_SITES = ['hetzner-fsn1', 'ovh-lim'];
|
|
9
9
|
/** Postgres always runs with at least this much memory. */
|
|
10
10
|
export const DATABASE_MIN_MEMORY_MB = 256;
|
|
@@ -17,10 +17,70 @@ export const API_KEY_SCOPES = {
|
|
|
17
17
|
read: 'openupstream:read',
|
|
18
18
|
write: 'openupstream:write',
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* A Bucket's name: a hostname label of 3 to 63 lowercase letters, digits
|
|
22
|
+
* and hyphens, neither starting nor ending with a hyphen.
|
|
23
|
+
*/
|
|
24
|
+
export const BUCKET_NAME = /^[a-z0-9]([a-z0-9-]{1,61}[a-z0-9])$/;
|
|
25
|
+
/**
|
|
26
|
+
* A container image from any registry, as given: `nginx:1.27`,
|
|
27
|
+
* `ghcr.io/acme/api:v3`, `registry.example.com:5000/team/app@sha256:…`.
|
|
28
|
+
* A reference without a tag means `latest`.
|
|
29
|
+
*/
|
|
30
|
+
export const IMAGE_REFERENCE_MAX_LENGTH = 512;
|
|
31
|
+
/** Limits of a Service, checked by the API. */
|
|
32
|
+
export const SERVICE_LIMITS = {
|
|
33
|
+
maxReplicas: 10,
|
|
34
|
+
minMemoryMb: 64,
|
|
35
|
+
maxMemoryMb: 16384,
|
|
36
|
+
minCpuMillicores: 50,
|
|
37
|
+
maxCpuMillicores: 8000,
|
|
38
|
+
};
|
|
39
|
+
/** Limits of a Job, checked by the API; memory and CPU as for a Service. */
|
|
40
|
+
export const JOB_LIMITS = {
|
|
41
|
+
minMemoryMb: SERVICE_LIMITS.minMemoryMb,
|
|
42
|
+
maxMemoryMb: SERVICE_LIMITS.maxMemoryMb,
|
|
43
|
+
minCpuMillicores: SERVICE_LIMITS.minCpuMillicores,
|
|
44
|
+
maxCpuMillicores: SERVICE_LIMITS.maxCpuMillicores,
|
|
45
|
+
defaultTimeoutSeconds: 3600,
|
|
46
|
+
maxTimeoutSeconds: 86400,
|
|
47
|
+
/** Entries of `command` and of `args`, and their bytes (UTF-8) together, which go into a Kubernetes annotation. */
|
|
48
|
+
maxArgs: 256,
|
|
49
|
+
maxArgsTotalBytes: 16 * 1024,
|
|
50
|
+
};
|
|
51
|
+
/** Limits of the log stream, checked by the API. */
|
|
52
|
+
export const LOG_LIMITS = {
|
|
53
|
+
/** Lines per container sent first, when `tail` is not given. */
|
|
54
|
+
defaultTailLines: 100,
|
|
55
|
+
maxTailLines: 10_000,
|
|
56
|
+
/** A followed stream ends after this long; the client asks again to go on. */
|
|
57
|
+
maxFollowSeconds: 3600,
|
|
58
|
+
/** Followed streams open at once per Account, on one control-plane replica; more answer 429. */
|
|
59
|
+
maxFollowsPerAccount: 10,
|
|
60
|
+
/** A followed stream sends an empty line this often, so a client and the proxies between see it is alive. */
|
|
61
|
+
heartbeatSeconds: 30,
|
|
62
|
+
};
|
|
63
|
+
/** A Secret's name is an environment variable name (the schema checks the same). */
|
|
64
|
+
export const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
|
|
65
|
+
/**
|
|
66
|
+
* At most this many bytes (UTF-8) per value, and all of a Project's values
|
|
67
|
+
* together at most SECRETS_MAX_TOTAL_BYTES: they go into one Kubernetes
|
|
68
|
+
* Secret (1 MiB at most) and into every container's environment.
|
|
69
|
+
*/
|
|
70
|
+
export const SECRET_VALUE_MAX_BYTES = 64 * 1024;
|
|
71
|
+
export const SECRETS_MAX_TOTAL_BYTES = 512 * 1024;
|
|
20
72
|
/** Where the TXT ownership proof for `hostname` has to be published. */
|
|
21
73
|
export function txtRecordName(hostname) {
|
|
22
74
|
return `_openupstream.${hostname}`;
|
|
23
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A custom domain's hostname: lowercase labels of letters, digits and
|
|
78
|
+
* hyphens, at least two of them, at most 253 characters (the schema checks
|
|
79
|
+
* the same).
|
|
80
|
+
*/
|
|
81
|
+
export const HOSTNAME = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
82
|
+
/** A Route's path prefix: `/` or `/segment[/segment…]`, no trailing slash (the schema checks the same). */
|
|
83
|
+
export const PATH_PREFIX = /^(\/|(\/[A-Za-z0-9._~-]+)+)$/;
|
|
24
84
|
export const RESOURCE_KINDS = ['database', 'bucket', 'service'];
|
|
25
85
|
export const USAGE_UNITS = ['cpu_seconds', 'memory_gb_hours', 'storage_gb_hours', 'egress_gb'];
|
|
26
86
|
//# sourceMappingURL=model.js.map
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,SAAS,CAAU,CAAC;AAkClE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAsC1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,oBAAoB;CACrB,CAAC;AAmEX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAmCjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAW9C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,EAAE;IACpB,gBAAgB,EAAE,IAAI;CAChB,CAAC;AA8EX,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,WAAW,EAAE,cAAc,CAAC,WAAW;IACvC,WAAW,EAAE,cAAc,CAAC,WAAW;IACvC,gBAAgB,EAAE,cAAc,CAAC,gBAAgB;IACjD,gBAAgB,EAAE,cAAc,CAAC,gBAAgB;IACjD,qBAAqB,EAAE,IAAI;IAC3B,iBAAiB,EAAE,KAAK;IACxB,mHAAmH;IACnH,OAAO,EAAE,GAAG;IACZ,iBAAiB,EAAE,EAAE,GAAG,IAAI;CACtB,CAAC;AAkJX,oDAAoD;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,gEAAgE;IAChE,gBAAgB,EAAE,GAAG;IACrB,YAAY,EAAE,MAAM;IACpB,8EAA8E;IAC9E,gBAAgB,EAAE,IAAI;IACtB,gGAAgG;IAChG,oBAAoB,EAAE,EAAE;IACxB,6GAA6G;IAC7G,gBAAgB,EAAE,EAAE;CACd,CAAC;AAcX,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AA+DlD,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC1C,OAAO,iBAAiB,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,uFAAuF,CAAC;AAahH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAsC1D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAGzE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,CAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openupstream/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript client for the openupstream API",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "node --test --import tsx 'src/**/*.test.ts'"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^24.0.0",
|
|
35
35
|
"tsx": "^4.19.0",
|
|
36
36
|
"typescript": "^5.7.0"
|
|
37
37
|
}
|