@openupstream/sdk 0.1.1 → 0.3.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 +13 -3
- package/dist/index.d.ts +83 -4
- package/dist/index.js +201 -9
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +154 -1
- package/dist/internal.js +89 -0
- package/dist/internal.js.map +1 -1
- package/dist/model.d.ts +377 -11
- package/dist/model.js +62 -2
- package/dist/model.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,15 +16,25 @@ if (project.ok) {
|
|
|
16
16
|
}
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
The API is at `https://openupstream.com/api` (`baseUrl` for another
|
|
20
|
+
installation: `https://<its platform domain>/api`). In a browser on the
|
|
21
|
+
dashboard's origin, which is the API's too, the client takes `{ baseUrl:
|
|
22
|
+
'/api', session: 'cookie' }` in place of a token: the browser then sends
|
|
23
|
+
madAuth's session cookie with every call (ARCHITECTURE.md, decisions 116
|
|
24
|
+
and 120).
|
|
25
|
+
|
|
19
26
|
Every call returns `{ ok: true, value }` or `{ ok: false, error: { status, message } }`
|
|
20
|
-
(status 0: the API was not reached); nothing throws.
|
|
27
|
+
(status 0: the API was not reached); nothing throws. For a refused request
|
|
28
|
+
`message` also names each field the API objected to, e.g. `invalid request
|
|
29
|
+
(name: a DNS label: lowercase letters, digits and hyphens)`. `src/internal.ts` holds
|
|
21
30
|
the contract between the control plane and its internal callers (the
|
|
22
31
|
operators and the billing service), not for customers.
|
|
23
32
|
|
|
24
33
|
## Releasing
|
|
25
34
|
|
|
26
|
-
Raise `version` in `package.json` (and `SDK_VERSION` in `src/index.ts
|
|
27
|
-
|
|
35
|
+
Raise `version` in `package.json` (and `SDK_VERSION` in `src/index.ts`,
|
|
36
|
+
and the range of `@openupstream/sdk` in the other workspaces when the
|
|
37
|
+
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
38
|
may. The workflow `.github/workflows/sdk-release.yml` waits in the
|
|
29
39
|
Environment `npm-release` until a maintainer approves the run on GitHub,
|
|
30
40
|
then checks that the tag names the version, builds, tests and publishes
|
package/dist/index.d.ts
CHANGED
|
@@ -7,15 +7,29 @@
|
|
|
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.3.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
|
+
/** The API is under `/api` of the platform's host (ARCHITECTURE.md, decision 120). */
|
|
15
|
+
export declare const DEFAULT_API_URL = "https://openupstream.com/api";
|
|
14
16
|
export interface ClientOptions {
|
|
15
17
|
baseUrl?: string;
|
|
16
|
-
/** A madAuth session token, or one of the user's madAuth API keys (`madauth_…`). */
|
|
18
|
+
/** A madAuth session token, an access token of `oup`, or one of the user's madAuth API keys (`madauth_…`). */
|
|
17
19
|
token: string;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* In a browser on the dashboard's origin, which is the API's too: no token,
|
|
23
|
+
* the browser sends madAuth's session cookie along. `baseUrl` can be a path
|
|
24
|
+
* there, e.g. `/api`. To another origin the browser sends no cookie, and
|
|
25
|
+
* the API answers 401.
|
|
26
|
+
*/
|
|
27
|
+
export interface CookieSessionOptions {
|
|
28
|
+
baseUrl?: string;
|
|
29
|
+
session: 'cookie';
|
|
30
|
+
}
|
|
31
|
+
/** Where the CLI signs in; asked before there is a token. 404 when the platform has no CLI client. */
|
|
32
|
+
export declare function cliLogin(baseUrl?: string): Promise<ApiResult<CliLogin>>;
|
|
19
33
|
/** What went wrong, as the API said it: the HTTP status and its message. 0: the API was not reached. */
|
|
20
34
|
export interface ApiError {
|
|
21
35
|
readonly status: number;
|
|
@@ -31,10 +45,11 @@ export type ApiResult<T> = {
|
|
|
31
45
|
export declare class OpenUpstreamClient {
|
|
32
46
|
#private;
|
|
33
47
|
readonly baseUrl: string;
|
|
34
|
-
constructor(options: ClientOptions);
|
|
48
|
+
constructor(options: ClientOptions | CookieSessionOptions);
|
|
35
49
|
health(): Promise<{
|
|
36
50
|
ok: boolean;
|
|
37
51
|
}>;
|
|
52
|
+
cliLogin(): Promise<ApiResult<CliLogin>>;
|
|
38
53
|
/** The Accounts the caller is a Member of. */
|
|
39
54
|
listAccounts(): Promise<ApiResult<Account[]>>;
|
|
40
55
|
/** A new Account, with the caller as its first Member. */
|
|
@@ -47,6 +62,70 @@ export declare class OpenUpstreamClient {
|
|
|
47
62
|
listDatabases(projectId: Id): Promise<ApiResult<DatabaseDetails[]>>;
|
|
48
63
|
createDatabase(projectId: Id, input: DatabaseInput): Promise<ApiResult<DatabaseDetails>>;
|
|
49
64
|
getDatabase(projectId: Id, databaseId: Id): Promise<ApiResult<DatabaseDetails>>;
|
|
65
|
+
/** Resizes the Database; the operator applies it within one pass (`resizing` until then). */
|
|
66
|
+
updateDatabase(projectId: Id, databaseId: Id, patch: DatabasePatch): Promise<ApiResult<DatabaseDetails>>;
|
|
50
67
|
/** Deletes the Database at once; its backups are kept for the retention window. */
|
|
51
68
|
deleteDatabase(projectId: Id, databaseId: Id): Promise<ApiResult<void>>;
|
|
69
|
+
listBuckets(projectId: Id): Promise<ApiResult<Bucket[]>>;
|
|
70
|
+
/** A new Bucket with its own key; usable as soon as this returns. */
|
|
71
|
+
createBucket(projectId: Id, input: BucketInput): Promise<ApiResult<BucketDetails>>;
|
|
72
|
+
getBucket(projectId: Id, bucketId: Id): Promise<ApiResult<BucketDetails>>;
|
|
73
|
+
/** Deletes the Bucket and every object in it; there is no retention window. */
|
|
74
|
+
deleteBucket(projectId: Id, bucketId: Id): Promise<ApiResult<void>>;
|
|
75
|
+
/** The Project's Domains; every Project has its default Domain. */
|
|
76
|
+
listDomains(projectId: Id): Promise<ApiResult<Domain[]>>;
|
|
77
|
+
/** Claims a custom domain; publish its TXT record, then call verifyDomain. */
|
|
78
|
+
createDomain(projectId: Id, input: CustomDomainInput): Promise<ApiResult<Domain>>;
|
|
79
|
+
/** Looks up the custom domain's TXT record now; once found, the Domain is verified and its Routes are served. */
|
|
80
|
+
verifyDomain(projectId: Id, domainId: Id): Promise<ApiResult<Domain>>;
|
|
81
|
+
/** Deletes a custom domain and its Routes; the default Domain cannot be deleted. */
|
|
82
|
+
deleteDomain(projectId: Id, domainId: Id): Promise<ApiResult<void>>;
|
|
83
|
+
listRoutes(projectId: Id, domainId: Id): Promise<ApiResult<Route[]>>;
|
|
84
|
+
/** Serves a Bucket below a path prefix of the Domain, within one operator pass. */
|
|
85
|
+
createRoute(projectId: Id, domainId: Id, input: RouteInput): Promise<ApiResult<Route>>;
|
|
86
|
+
deleteRoute(projectId: Id, domainId: Id, routeId: Id): Promise<ApiResult<void>>;
|
|
87
|
+
listServices(projectId: Id): Promise<ApiResult<ServiceDetails[]>>;
|
|
88
|
+
/** Resolves the image's tag to a digest now and deploys it pinned; running within one operator pass. */
|
|
89
|
+
createService(projectId: Id, input: ServiceInput): Promise<ApiResult<ServiceDetails>>;
|
|
90
|
+
getService(projectId: Id, serviceId: Id): Promise<ApiResult<ServiceDetails>>;
|
|
91
|
+
/** Changes the Service; a new image or new registry credentials resolve the tag again. */
|
|
92
|
+
updateService(projectId: Id, serviceId: Id, patch: ServicePatch): Promise<ApiResult<ServiceDetails>>;
|
|
93
|
+
/** Resolves the Service's tag again and deploys what it points at now. */
|
|
94
|
+
deployService(projectId: Id, serviceId: Id): Promise<ApiResult<ServiceDetails>>;
|
|
95
|
+
/** Deletes the Service; refused while a Route serves it. */
|
|
96
|
+
deleteService(projectId: Id, serviceId: Id): Promise<ApiResult<void>>;
|
|
97
|
+
listJobs(projectId: Id): Promise<ApiResult<JobDetails[]>>;
|
|
98
|
+
/** Resolves the image's tag to a digest now; the Job is ready to run within one operator pass. */
|
|
99
|
+
createJob(projectId: Id, input: JobInput): Promise<ApiResult<JobDetails>>;
|
|
100
|
+
getJob(projectId: Id, jobId: Id): Promise<ApiResult<JobDetails>>;
|
|
101
|
+
/** Changes the Job; a new image or new registry credentials resolve the tag again. */
|
|
102
|
+
updateJob(projectId: Id, jobId: Id, patch: JobPatch): Promise<ApiResult<JobDetails>>;
|
|
103
|
+
/** Resolves the Job's tag again; later runs start what it points at now. */
|
|
104
|
+
deployJob(projectId: Id, jobId: Id): Promise<ApiResult<JobDetails>>;
|
|
105
|
+
/** Deletes the Job; its runs, running ones included, are stopped and removed. */
|
|
106
|
+
deleteJob(projectId: Id, jobId: Id): Promise<ApiResult<void>>;
|
|
107
|
+
/** Starts a One-off job from the Job's current template; 409 while the Job is still deploying. */
|
|
108
|
+
startJobRun(projectId: Id, jobId: Id, input?: JobRunInput): Promise<ApiResult<JobRun>>;
|
|
109
|
+
/** The Job's runs, newest first, scheduled and started alike. */
|
|
110
|
+
listJobRuns(projectId: Id, jobId: Id): Promise<ApiResult<JobRun[]>>;
|
|
111
|
+
getJobRun(projectId: Id, jobId: Id, runId: string): Promise<ApiResult<JobRun>>;
|
|
112
|
+
/** Stops the run if it is still going, and removes it. */
|
|
113
|
+
deleteJobRun(projectId: Id, jobId: Id, runId: string): Promise<ApiResult<void>>;
|
|
114
|
+
/** The Service's output from all its replicas, as a stream of entries; `signal` ends it early. */
|
|
115
|
+
serviceLogs(projectId: Id, serviceId: Id, query?: LogQuery, signal?: AbortSignal): Promise<ApiResult<AsyncIterable<LogEntry>>>;
|
|
116
|
+
/** A run's output, as a stream of entries; `signal` ends it early. */
|
|
117
|
+
jobRunLogs(projectId: Id, jobId: Id, runId: string, query?: LogQuery, signal?: AbortSignal): Promise<ApiResult<AsyncIterable<LogEntry>>>;
|
|
118
|
+
/** The Project's Secrets, names only: a value is never returned. */
|
|
119
|
+
listSecrets(projectId: Id): Promise<ApiResult<Secret[]>>;
|
|
120
|
+
/** Creates the Secret or replaces its value; the Project's Services get it in their environment. */
|
|
121
|
+
putSecret(projectId: Id, input: SecretInput): Promise<ApiResult<Secret>>;
|
|
122
|
+
deleteSecret(projectId: Id, name: string): Promise<ApiResult<void>>;
|
|
52
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* The API's `error`, followed by what its `issues` say about each field
|
|
126
|
+
* (a 400's `{error: 'invalid request', issues: [{path, message}]}`), so
|
|
127
|
+
* the caller learns what to change; the HTTP status text without either.
|
|
128
|
+
*/
|
|
129
|
+
export declare function errorMessage(body: unknown, statusText: string): string;
|
|
130
|
+
/** The JSON values of a body of NDJSON, one per non-empty line. */
|
|
131
|
+
export declare function ndjsonLines<T>(body: ReadableStream<Uint8Array>): AsyncIterable<T>;
|
package/dist/index.js
CHANGED
|
@@ -7,20 +7,30 @@
|
|
|
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.3.0';
|
|
11
11
|
export * from './model.js';
|
|
12
12
|
export * from './internal.js';
|
|
13
|
+
/** The API is under `/api` of the platform's host (ARCHITECTURE.md, decision 120). */
|
|
14
|
+
export const DEFAULT_API_URL = 'https://openupstream.com/api';
|
|
15
|
+
/** Where the CLI signs in; asked before there is a token. 404 when the platform has no CLI client. */
|
|
16
|
+
export async function cliLogin(baseUrl = DEFAULT_API_URL) {
|
|
17
|
+
return new OpenUpstreamClient({ baseUrl, token: '' }).cliLogin();
|
|
18
|
+
}
|
|
13
19
|
export class OpenUpstreamClient {
|
|
14
20
|
baseUrl;
|
|
15
|
-
|
|
21
|
+
/** The credential of every request: the token as a header, or the browser's cookie. */
|
|
22
|
+
#auth;
|
|
16
23
|
constructor(options) {
|
|
17
|
-
this.baseUrl = options.baseUrl ??
|
|
18
|
-
this.#
|
|
24
|
+
this.baseUrl = options.baseUrl ?? DEFAULT_API_URL;
|
|
25
|
+
this.#auth = 'token' in options ? { headers: { authorization: `Bearer ${options.token}` } } : { headers: {}, credentials: 'same-origin' };
|
|
19
26
|
}
|
|
20
27
|
async health() {
|
|
21
28
|
const res = await fetch(`${this.baseUrl}/v1/health`);
|
|
22
29
|
return { ok: res.ok };
|
|
23
30
|
}
|
|
31
|
+
cliLogin() {
|
|
32
|
+
return this.#call('GET', '/v1/login');
|
|
33
|
+
}
|
|
24
34
|
/** The Accounts the caller is a Member of. */
|
|
25
35
|
listAccounts() {
|
|
26
36
|
return this.#call('GET', '/v1/accounts');
|
|
@@ -51,15 +61,161 @@ export class OpenUpstreamClient {
|
|
|
51
61
|
getDatabase(projectId, databaseId) {
|
|
52
62
|
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`);
|
|
53
63
|
}
|
|
64
|
+
/** Resizes the Database; the operator applies it within one pass (`resizing` until then). */
|
|
65
|
+
updateDatabase(projectId, databaseId, patch) {
|
|
66
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`, patch);
|
|
67
|
+
}
|
|
54
68
|
/** Deletes the Database at once; its backups are kept for the retention window. */
|
|
55
69
|
deleteDatabase(projectId, databaseId) {
|
|
56
70
|
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/databases/${encodeURIComponent(databaseId)}`);
|
|
57
71
|
}
|
|
72
|
+
listBuckets(projectId) {
|
|
73
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/buckets`);
|
|
74
|
+
}
|
|
75
|
+
/** A new Bucket with its own key; usable as soon as this returns. */
|
|
76
|
+
createBucket(projectId, input) {
|
|
77
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/buckets`, input);
|
|
78
|
+
}
|
|
79
|
+
getBucket(projectId, bucketId) {
|
|
80
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/buckets/${encodeURIComponent(bucketId)}`);
|
|
81
|
+
}
|
|
82
|
+
/** Deletes the Bucket and every object in it; there is no retention window. */
|
|
83
|
+
deleteBucket(projectId, bucketId) {
|
|
84
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/buckets/${encodeURIComponent(bucketId)}`);
|
|
85
|
+
}
|
|
86
|
+
/** The Project's Domains; every Project has its default Domain. */
|
|
87
|
+
listDomains(projectId) {
|
|
88
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/domains`);
|
|
89
|
+
}
|
|
90
|
+
/** Claims a custom domain; publish its TXT record, then call verifyDomain. */
|
|
91
|
+
createDomain(projectId, input) {
|
|
92
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains`, input);
|
|
93
|
+
}
|
|
94
|
+
/** Looks up the custom domain's TXT record now; once found, the Domain is verified and its Routes are served. */
|
|
95
|
+
verifyDomain(projectId, domainId) {
|
|
96
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/verify`);
|
|
97
|
+
}
|
|
98
|
+
/** Deletes a custom domain and its Routes; the default Domain cannot be deleted. */
|
|
99
|
+
deleteDomain(projectId, domainId) {
|
|
100
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}`);
|
|
101
|
+
}
|
|
102
|
+
listRoutes(projectId, domainId) {
|
|
103
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes`);
|
|
104
|
+
}
|
|
105
|
+
/** Serves a Bucket below a path prefix of the Domain, within one operator pass. */
|
|
106
|
+
createRoute(projectId, domainId, input) {
|
|
107
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes`, input);
|
|
108
|
+
}
|
|
109
|
+
deleteRoute(projectId, domainId, routeId) {
|
|
110
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/domains/${encodeURIComponent(domainId)}/routes/${encodeURIComponent(routeId)}`);
|
|
111
|
+
}
|
|
112
|
+
listServices(projectId) {
|
|
113
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/services`);
|
|
114
|
+
}
|
|
115
|
+
/** Resolves the image's tag to a digest now and deploys it pinned; running within one operator pass. */
|
|
116
|
+
createService(projectId, input) {
|
|
117
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/services`, input);
|
|
118
|
+
}
|
|
119
|
+
getService(projectId, serviceId) {
|
|
120
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`);
|
|
121
|
+
}
|
|
122
|
+
/** Changes the Service; a new image or new registry credentials resolve the tag again. */
|
|
123
|
+
updateService(projectId, serviceId, patch) {
|
|
124
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`, patch);
|
|
125
|
+
}
|
|
126
|
+
/** Resolves the Service's tag again and deploys what it points at now. */
|
|
127
|
+
deployService(projectId, serviceId) {
|
|
128
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}/deploy`);
|
|
129
|
+
}
|
|
130
|
+
/** Deletes the Service; refused while a Route serves it. */
|
|
131
|
+
deleteService(projectId, serviceId) {
|
|
132
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`);
|
|
133
|
+
}
|
|
134
|
+
listJobs(projectId) {
|
|
135
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs`);
|
|
136
|
+
}
|
|
137
|
+
/** Resolves the image's tag to a digest now; the Job is ready to run within one operator pass. */
|
|
138
|
+
createJob(projectId, input) {
|
|
139
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs`, input);
|
|
140
|
+
}
|
|
141
|
+
getJob(projectId, jobId) {
|
|
142
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`);
|
|
143
|
+
}
|
|
144
|
+
/** Changes the Job; a new image or new registry credentials resolve the tag again. */
|
|
145
|
+
updateJob(projectId, jobId, patch) {
|
|
146
|
+
return this.#call('PATCH', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`, patch);
|
|
147
|
+
}
|
|
148
|
+
/** Resolves the Job's tag again; later runs start what it points at now. */
|
|
149
|
+
deployJob(projectId, jobId) {
|
|
150
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/deploy`);
|
|
151
|
+
}
|
|
152
|
+
/** Deletes the Job; its runs, running ones included, are stopped and removed. */
|
|
153
|
+
deleteJob(projectId, jobId) {
|
|
154
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}`);
|
|
155
|
+
}
|
|
156
|
+
/** Starts a One-off job from the Job's current template; 409 while the Job is still deploying. */
|
|
157
|
+
startJobRun(projectId, jobId, input = {}) {
|
|
158
|
+
return this.#call('POST', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs`, input);
|
|
159
|
+
}
|
|
160
|
+
/** The Job's runs, newest first, scheduled and started alike. */
|
|
161
|
+
listJobRuns(projectId, jobId) {
|
|
162
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs`);
|
|
163
|
+
}
|
|
164
|
+
getJobRun(projectId, jobId, runId) {
|
|
165
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}`);
|
|
166
|
+
}
|
|
167
|
+
/** Stops the run if it is still going, and removes it. */
|
|
168
|
+
deleteJobRun(projectId, jobId, runId) {
|
|
169
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}`);
|
|
170
|
+
}
|
|
171
|
+
/** The Service's output from all its replicas, as a stream of entries; `signal` ends it early. */
|
|
172
|
+
serviceLogs(projectId, serviceId, query = {}, signal) {
|
|
173
|
+
return this.#stream(`/v1/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}/logs${logSearch(query)}`, signal);
|
|
174
|
+
}
|
|
175
|
+
/** A run's output, as a stream of entries; `signal` ends it early. */
|
|
176
|
+
jobRunLogs(projectId, jobId, runId, query = {}, signal) {
|
|
177
|
+
return this.#stream(`/v1/projects/${encodeURIComponent(projectId)}/jobs/${encodeURIComponent(jobId)}/runs/${encodeURIComponent(runId)}/logs${logSearch(query)}`, signal);
|
|
178
|
+
}
|
|
179
|
+
/** The Project's Secrets, names only: a value is never returned. */
|
|
180
|
+
listSecrets(projectId) {
|
|
181
|
+
return this.#call('GET', `/v1/projects/${encodeURIComponent(projectId)}/secrets`);
|
|
182
|
+
}
|
|
183
|
+
/** Creates the Secret or replaces its value; the Project's Services get it in their environment. */
|
|
184
|
+
putSecret(projectId, input) {
|
|
185
|
+
return this.#call('PUT', `/v1/projects/${encodeURIComponent(projectId)}/secrets/${encodeURIComponent(input.name)}`, {
|
|
186
|
+
value: input.value,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
deleteSecret(projectId, name) {
|
|
190
|
+
return this.#call('DELETE', `/v1/projects/${encodeURIComponent(projectId)}/secrets/${encodeURIComponent(name)}`);
|
|
191
|
+
}
|
|
192
|
+
/** A GET whose answer is NDJSON, one entry per line, read as it arrives. */
|
|
193
|
+
async #stream(path, signal) {
|
|
194
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
195
|
+
...this.#auth,
|
|
196
|
+
...(signal === undefined ? {} : { signal }),
|
|
197
|
+
}).then((value) => ({ ok: true, value }), (error) => ({ ok: false, error: { status: 0, message: error instanceof Error ? error.message : String(error) } }));
|
|
198
|
+
if (!response.ok) {
|
|
199
|
+
return response;
|
|
200
|
+
}
|
|
201
|
+
const isNdjson = response.value.headers.get('content-type')?.includes('application/x-ndjson') ?? false;
|
|
202
|
+
if (response.value.ok && isNdjson && response.value.body !== null) {
|
|
203
|
+
return { ok: true, value: ndjsonLines(response.value.body) };
|
|
204
|
+
}
|
|
205
|
+
const parsed = await response.value.json().catch(() => undefined);
|
|
206
|
+
const message = typeof parsed === 'object' && parsed !== null && 'error' in parsed && typeof parsed.error === 'string'
|
|
207
|
+
? parsed.error
|
|
208
|
+
: response.value.ok
|
|
209
|
+
? 'the API did not answer with a log stream'
|
|
210
|
+
: response.value.statusText;
|
|
211
|
+
return { ok: false, error: { status: response.value.ok ? 0 : response.value.status, message } };
|
|
212
|
+
}
|
|
58
213
|
async #call(method, path, body) {
|
|
59
214
|
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
60
215
|
method,
|
|
216
|
+
...this.#auth,
|
|
61
217
|
headers: {
|
|
62
|
-
|
|
218
|
+
...this.#auth.headers,
|
|
63
219
|
...(body === undefined ? {} : { 'content-type': 'application/json' }),
|
|
64
220
|
},
|
|
65
221
|
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
@@ -73,10 +229,46 @@ export class OpenUpstreamClient {
|
|
|
73
229
|
if (response.value.ok) {
|
|
74
230
|
return { ok: true, value: parsed };
|
|
75
231
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
232
|
+
return { ok: false, error: { status: response.value.status, message: errorMessage(parsed, response.value.statusText) } };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The API's `error`, followed by what its `issues` say about each field
|
|
237
|
+
* (a 400's `{error: 'invalid request', issues: [{path, message}]}`), so
|
|
238
|
+
* the caller learns what to change; the HTTP status text without either.
|
|
239
|
+
*/
|
|
240
|
+
export function errorMessage(body, statusText) {
|
|
241
|
+
if (typeof body !== 'object' || body === null || !('error' in body) || typeof body.error !== 'string') {
|
|
242
|
+
return statusText;
|
|
243
|
+
}
|
|
244
|
+
const issues = 'issues' in body && Array.isArray(body.issues) ? body.issues : [];
|
|
245
|
+
const details = issues.flatMap((issue) => typeof issue === 'object' && issue !== null && 'message' in issue && typeof issue.message === 'string'
|
|
246
|
+
? ['path' in issue && typeof issue.path === 'string' && issue.path !== '' ? `${issue.path}: ${issue.message}` : issue.message]
|
|
247
|
+
: []);
|
|
248
|
+
return details.length === 0 ? body.error : `${body.error} (${details.join('; ')})`;
|
|
249
|
+
}
|
|
250
|
+
const logSearch = (query) => {
|
|
251
|
+
const params = new URLSearchParams({
|
|
252
|
+
...(query.tail === undefined ? {} : { tail: String(query.tail) }),
|
|
253
|
+
...(query.follow === true ? { follow: 'true' } : {}),
|
|
254
|
+
}).toString();
|
|
255
|
+
return params === '' ? '' : `?${params}`;
|
|
256
|
+
};
|
|
257
|
+
/** The JSON values of a body of NDJSON, one per non-empty line. */
|
|
258
|
+
export async function* ndjsonLines(body) {
|
|
259
|
+
const decoder = new TextDecoder();
|
|
260
|
+
let pending = '';
|
|
261
|
+
for await (const chunk of body) {
|
|
262
|
+
pending += decoder.decode(chunk, { stream: true });
|
|
263
|
+
const lines = pending.split('\n');
|
|
264
|
+
pending = lines.pop() ?? '';
|
|
265
|
+
for (const line of lines.filter((candidate) => candidate.trim() !== '')) {
|
|
266
|
+
yield JSON.parse(line);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const last = pending + decoder.decode();
|
|
270
|
+
if (last.trim() !== '') {
|
|
271
|
+
yield JSON.parse(last);
|
|
80
272
|
}
|
|
81
273
|
}
|
|
82
274
|
//# sourceMappingURL=index.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ACtE,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, ResourceKind, Route, Service, Site, UsageUnit } 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,133 @@ 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
|
+
/** An Account's usage of one month: `${INTERNAL_ACCOUNTS_PATH}/{id}/usage?month=YYYY-MM`, for the billing service. */
|
|
67
|
+
export declare const internalUsagePath: (accountId: Id, month: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* An Account's usage summed per Project, Resource and unit over one
|
|
70
|
+
* calendar month (UTC), as the billing service rates it (decision 114).
|
|
71
|
+
* Quantities are in the unit's own terms: seconds, GB-hours, GB.
|
|
72
|
+
*/
|
|
73
|
+
export interface AccountUsage {
|
|
74
|
+
readonly accountId: Id;
|
|
75
|
+
/** `YYYY-MM`. */
|
|
76
|
+
readonly month: string;
|
|
77
|
+
/** Hours of the month in its days; the month is complete for billing once `meteredHours` reaches it. */
|
|
78
|
+
readonly hours: number;
|
|
79
|
+
/** Hours of the month the metering pass has recorded. */
|
|
80
|
+
readonly meteredHours: number;
|
|
81
|
+
readonly usage: readonly {
|
|
82
|
+
readonly projectId: Id;
|
|
83
|
+
readonly resource: {
|
|
84
|
+
readonly kind: ResourceKind;
|
|
85
|
+
readonly id: Id;
|
|
86
|
+
};
|
|
87
|
+
readonly unit: UsageUnit;
|
|
88
|
+
readonly quantity: number;
|
|
89
|
+
}[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The Traefik IngressRoute that serves one Resource under one Domain, in its
|
|
93
|
+
* Project's namespace (decision 114): `domain-<id>-bucket-<id>` or
|
|
94
|
+
* `domain-<id>-svc-<id>`. Traefik names each rule's metrics after it, so
|
|
95
|
+
* metering reads the Resource from them.
|
|
96
|
+
*/
|
|
97
|
+
export declare const ingressRouteName: (domainId: Id, resource: {
|
|
98
|
+
readonly kind: "bucket" | "service";
|
|
99
|
+
readonly id: Id;
|
|
100
|
+
}) => string;
|
|
101
|
+
/** A Route as the Routes operator needs it: the Bucket by name, or the Service with its port. */
|
|
102
|
+
export type RoutedPath = Pick<Route, 'id' | 'pathPrefix'> & ({
|
|
103
|
+
readonly kind: 'bucket';
|
|
104
|
+
readonly bucketId: Id;
|
|
105
|
+
readonly bucketName: string;
|
|
106
|
+
readonly spaFallback: boolean;
|
|
107
|
+
} | {
|
|
108
|
+
readonly kind: 'service';
|
|
109
|
+
readonly serviceId: Id;
|
|
110
|
+
readonly port: number;
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* One Domain as the Routes operator needs it: where it lives, its hostname,
|
|
114
|
+
* and its Routes with what each one serves.
|
|
115
|
+
*/
|
|
116
|
+
export interface DomainRouting {
|
|
117
|
+
readonly projectId: Id;
|
|
118
|
+
/** For the namespace's labels, which the Databases operator sets too. */
|
|
119
|
+
readonly projectName: string;
|
|
120
|
+
readonly domainId: Id;
|
|
121
|
+
readonly hostname: string;
|
|
122
|
+
/** A default Domain uses the customer domain's wildcard certificate; a custom one gets its own. */
|
|
123
|
+
readonly kind: Domain['kind'];
|
|
124
|
+
readonly routes: readonly RoutedPath[];
|
|
125
|
+
}
|
|
34
126
|
export interface AccountRecord extends Account {
|
|
35
127
|
readonly members: readonly Pick<Member, 'authSubject' | 'email'>[];
|
|
36
128
|
}
|
|
129
|
+
/** One Service as the Services operator needs it. */
|
|
130
|
+
export interface ServiceRow {
|
|
131
|
+
readonly project: Project;
|
|
132
|
+
readonly service: Pick<Service, 'id' | 'name' | 'image' | 'imageDigest' | 'replicas' | 'memoryMb' | 'cpuMillicores' | 'port'>;
|
|
133
|
+
/** What the Deployment runs: `<registry>/<repository>@<digest>`. */
|
|
134
|
+
readonly pinnedImage: string;
|
|
135
|
+
/** Where a single replica runs: the Service's homeSite, else the Project's oldest Database's, else `hetzner-fsn1`. */
|
|
136
|
+
readonly site: Site;
|
|
137
|
+
/**
|
|
138
|
+
* The version of the Project's Secrets in its Kubernetes Secret: it
|
|
139
|
+
* changes once the control plane has written new values there, never
|
|
140
|
+
* before. The operator puts it on the pod template, so a change rolls the
|
|
141
|
+
* Service and its pods read the new values.
|
|
142
|
+
*/
|
|
143
|
+
readonly secretsVersion: string;
|
|
144
|
+
/** The Project's live Databases, oldest first: the Service gets a DATABASE_URL for each (decision 97). */
|
|
145
|
+
readonly databases: readonly RowDatabase[];
|
|
146
|
+
}
|
|
147
|
+
/** A Database as a Service's or Job's row names it. */
|
|
148
|
+
export type RowDatabase = Pick<Database, 'id' | 'name'>;
|
|
149
|
+
/** On a Service's Deployment and a Job's CronJob: the spec version it was applied from (serviceSpecVersion, jobSpecVersion). */
|
|
150
|
+
export declare const SPEC_VERSION_ANNOTATION = "openupstream.io/spec-version";
|
|
151
|
+
/**
|
|
152
|
+
* Everything of a Service's row that its Deployment is rendered from. The
|
|
153
|
+
* Services operator writes it on the Deployment; the control plane reports
|
|
154
|
+
* `deploying` until the Deployment carries the version its row asks for,
|
|
155
|
+
* so a change is not `running` before it has been applied and rolled out.
|
|
156
|
+
*/
|
|
157
|
+
export declare const serviceSpecVersion: (row: Pick<ServiceRow, "service" | "pinnedImage" | "site" | "secretsVersion" | "databases">) => string;
|
|
158
|
+
/** One Job as the Jobs operator needs it. */
|
|
159
|
+
export interface JobRow {
|
|
160
|
+
readonly project: Project;
|
|
161
|
+
readonly job: Pick<Job, 'id' | 'name' | 'image' | 'imageDigest' | 'command' | 'args' | 'memoryMb' | 'cpuMillicores' | 'timeoutSeconds' | 'schedule' | 'timeZone'>;
|
|
162
|
+
/** What its runs start: `<registry>/<repository>@<digest>`. */
|
|
163
|
+
readonly pinnedImage: string;
|
|
164
|
+
/** Where its runs go: the Job's homeSite, else the Project's oldest Database's, else `hetzner-fsn1`. */
|
|
165
|
+
readonly site: Site;
|
|
166
|
+
/** The Project's live Databases, oldest first: its runs get a DATABASE_URL for each (decision 97). */
|
|
167
|
+
readonly databases: readonly RowDatabase[];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Everything of a Job's row that its CronJob is rendered from. The Jobs
|
|
171
|
+
* operator writes it on the CronJob; until the CronJob carries the version
|
|
172
|
+
* the row asks for, the Job is `deploying` and no run starts from the old
|
|
173
|
+
* template. The Secrets are not part of it: a run's pod reads them when it
|
|
174
|
+
* starts, so nothing needs to change when they do.
|
|
175
|
+
*/
|
|
176
|
+
export declare const jobSpecVersion: (row: Pick<JobRow, "job" | "pinnedImage" | "site" | "databases">) => string;
|
|
37
177
|
export interface DatabaseRow {
|
|
38
178
|
readonly project: Project;
|
|
39
179
|
readonly database: Database;
|
|
180
|
+
/**
|
|
181
|
+
* A restored Database whose Cluster has not had a ready instance yet:
|
|
182
|
+
* the operator renders its recovery bootstrap from `database.restoredFrom`
|
|
183
|
+
* (decision 108). Once finished, its Cluster is rendered like any other,
|
|
184
|
+
* so it no longer depends on the source's ObjectStore.
|
|
185
|
+
*/
|
|
186
|
+
readonly restoring?: boolean;
|
|
40
187
|
}
|
|
41
188
|
/**
|
|
42
189
|
* The platform's own Account, Project and Databases: the control plane's
|
|
@@ -64,6 +211,8 @@ export declare const PLATFORM: {
|
|
|
64
211
|
readonly homeSite: "hetzner-fsn1";
|
|
65
212
|
readonly memoryMb: 512;
|
|
66
213
|
readonly storageGb: 5;
|
|
214
|
+
readonly autoGrow: true;
|
|
215
|
+
readonly maxStorageGb: null;
|
|
67
216
|
readonly createdAt: "2026-10-17T00:00:00Z";
|
|
68
217
|
};
|
|
69
218
|
readonly authDatabase: {
|
|
@@ -73,6 +222,8 @@ export declare const PLATFORM: {
|
|
|
73
222
|
readonly homeSite: "hetzner-fsn1";
|
|
74
223
|
readonly memoryMb: 512;
|
|
75
224
|
readonly storageGb: 2;
|
|
225
|
+
readonly autoGrow: true;
|
|
226
|
+
readonly maxStorageGb: null;
|
|
76
227
|
readonly createdAt: "2026-10-17T00:00:00Z";
|
|
77
228
|
};
|
|
78
229
|
/** The billing service's state; seeded only where a billing service runs (BILLING_CALLERS). */
|
|
@@ -83,6 +234,8 @@ export declare const PLATFORM: {
|
|
|
83
234
|
readonly homeSite: "hetzner-fsn1";
|
|
84
235
|
readonly memoryMb: 512;
|
|
85
236
|
readonly storageGb: 2;
|
|
237
|
+
readonly autoGrow: true;
|
|
238
|
+
readonly maxStorageGb: null;
|
|
86
239
|
readonly createdAt: "2026-10-20T00:00:00Z";
|
|
87
240
|
};
|
|
88
241
|
};
|