@sealant/api-contracts-next 0.40.0-next.878 → 0.40.0-next.880
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/dist/core-api/boat-accounts.d.ts +1147 -20
- package/dist/core-api/boat-accounts.js +108 -8
- package/dist/core-api/control-plane.d.ts +2847 -2247
- package/package.json +2 -2
|
@@ -43,6 +43,45 @@ const observedOr = (fields) => Schema.Union([
|
|
|
43
43
|
Schema.Struct({ observed: Schema.Literal(true), ...fields }),
|
|
44
44
|
boatKeyNotObservedSchema,
|
|
45
45
|
]);
|
|
46
|
+
/** A wallet a VM can bill: a person's own Boat account, or one of their Boat organizations. */
|
|
47
|
+
const boatWalletFields = {
|
|
48
|
+
kind: Schema.Literals(["personal", "organization"]),
|
|
49
|
+
organizationId: Schema.optional(Schema.String),
|
|
50
|
+
organizationName: Schema.optional(Schema.String),
|
|
51
|
+
role: Schema.optional(Schema.String),
|
|
52
|
+
};
|
|
53
|
+
export const boatWalletSchema = Schema.Struct(boatWalletFields);
|
|
54
|
+
/**
|
|
55
|
+
* One wallet the key's Boat account can bill (`GET /orgs`): its own (`personal`), or an
|
|
56
|
+
* organization it belongs to, with the account's role there. `active`: the account's active wallet,
|
|
57
|
+
* which an unpinned personal key bills. `id` is what a pin names: an organization's id, or
|
|
58
|
+
* `personal` for the account's own wallet.
|
|
59
|
+
*/
|
|
60
|
+
export const boatKeyWalletChoiceSchema = Schema.Struct({
|
|
61
|
+
id: Schema.String,
|
|
62
|
+
kind: Schema.Literals(["personal", "organization"]),
|
|
63
|
+
name: Schema.optional(Schema.String),
|
|
64
|
+
role: Schema.optional(Schema.String),
|
|
65
|
+
active: Schema.Boolean,
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Whether the account's requests name the wallet to bill. `pinned`: every request names
|
|
69
|
+
* `organization` (an organization's id or name, or `personal`), so the bill never follows the key's
|
|
70
|
+
* active wallet. `key-organization`: an organization's Boat key, which bills that organization and
|
|
71
|
+
* nothing else; there is nothing to choose. `active-wallet`: a personal key with no pin, which bills
|
|
72
|
+
* whichever wallet its Boat account has active, and that the person can change in Boat at any time
|
|
73
|
+
* (a stored account is in it only until sealant pins it, right after an upgrade);
|
|
74
|
+
* `walletChanged` says the wallet it bills now is not the one an earlier report saw (`from`), first
|
|
75
|
+
* seen at `observedAt`, and stays while the wallet stays.
|
|
76
|
+
*/
|
|
77
|
+
export const boatKeyBillingSchema = Schema.Union([
|
|
78
|
+
Schema.Struct({ mode: Schema.Literal("pinned"), organization: Schema.String }),
|
|
79
|
+
Schema.Struct({ mode: Schema.Literal("key-organization") }),
|
|
80
|
+
Schema.Struct({
|
|
81
|
+
mode: Schema.Literal("active-wallet"),
|
|
82
|
+
walletChanged: Schema.optional(Schema.Struct({ from: boatWalletSchema, observedAt: Schema.String })),
|
|
83
|
+
}),
|
|
84
|
+
]);
|
|
46
85
|
/**
|
|
47
86
|
* What sealant observed of a Boat key, from Boat's own answers, at `observedAt`. Each fact is
|
|
48
87
|
* `observed: true` with its value, or `observed: false` with the reason Boat did not show it.
|
|
@@ -66,12 +105,17 @@ export const boatKeyReportSchema = Schema.Struct({
|
|
|
66
105
|
/** A personal (account) key, or an organization's key. */
|
|
67
106
|
keyKind: observedOr({ kind: Schema.Literals(["personal", "organization"]) }),
|
|
68
107
|
/** Which wallet a VM started with the key bills (`GET /limits`). */
|
|
69
|
-
wallet: observedOr(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}),
|
|
108
|
+
wallet: observedOr(boatWalletFields),
|
|
109
|
+
/**
|
|
110
|
+
* The wallets the key's Boat account can bill (`GET /orgs`), the active one marked. Absent in
|
|
111
|
+
* reports made before sealant read them.
|
|
112
|
+
*/
|
|
113
|
+
wallets: Schema.optional(observedOr({ choices: Schema.Array(boatKeyWalletChoiceSchema) })),
|
|
114
|
+
/**
|
|
115
|
+
* Whether the account names the wallet it bills, or follows the key's active wallet. Absent in
|
|
116
|
+
* reports made before sealant said so.
|
|
117
|
+
*/
|
|
118
|
+
billing: Schema.optional(boatKeyBillingSchema),
|
|
75
119
|
/** The permissions sealant needs of every key, from the Boat calls it makes. */
|
|
76
120
|
requiredPermissions: Schema.Array(Schema.String),
|
|
77
121
|
/** The key's permissions (`GET /api-keys`), and which of the required ones it lacks. */
|
|
@@ -142,6 +186,21 @@ export const boatKeyProofSchema = Schema.Struct({
|
|
|
142
186
|
removalConfirmed: Schema.Boolean,
|
|
143
187
|
}),
|
|
144
188
|
});
|
|
189
|
+
/**
|
|
190
|
+
* What a key's account made in Boat before sealant recorded wallets, that sealant cannot reach: Boat
|
|
191
|
+
* has it in none of the wallets the key can bill (for a key without `account.read`, which cannot list
|
|
192
|
+
* them: not in the one it bills). It was since deleted in Boat, or is in an organization the key's
|
|
193
|
+
* account has left. sealant keeps it recorded, never uses or removes it, and waits on it for nothing;
|
|
194
|
+
* look for it in Boat, in each organization the key's account has been in.
|
|
195
|
+
*/
|
|
196
|
+
export const boatUnreachableSchema = Schema.Struct({
|
|
197
|
+
/** Saved images, by snapshot name (Saved snapshots in Boat). */
|
|
198
|
+
savedImages: Schema.Array(Schema.String),
|
|
199
|
+
/** Runs whose VM it was, by run id: each ended as gone, its VM in no wallet the key can bill. */
|
|
200
|
+
runs: Schema.optional(Schema.Array(Schema.String)),
|
|
201
|
+
/** Image builds, by publication id: abandoned, and built again in the wallet the key bills now. */
|
|
202
|
+
builds: Schema.optional(Schema.Array(Schema.String)),
|
|
203
|
+
});
|
|
145
204
|
export const boatAccountSchema = Schema.Struct({
|
|
146
205
|
boatAccountId: BoatAccountId,
|
|
147
206
|
label: NonEmptyString,
|
|
@@ -150,12 +209,19 @@ export const boatAccountSchema = Schema.Struct({
|
|
|
150
209
|
createdAt: Schema.String,
|
|
151
210
|
/** When its key was last replaced; null when it still has the key it was created with. */
|
|
152
211
|
keyRotatedAt: Schema.NullOr(Schema.String),
|
|
153
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* The wallet the account bills, named (`X-Boat-Org`) on every request it makes: an
|
|
214
|
+
* organization's id, or `personal`. Every personal key is pinned (to the wallet it billed when it
|
|
215
|
+
* was connected, unless the caller named another). Null: an organization's key, which has one
|
|
216
|
+
* wallet, or an account connected before sealant pinned accounts that the worker has not pinned yet.
|
|
217
|
+
*/
|
|
154
218
|
organization: Schema.optional(Schema.NullOr(Schema.String)),
|
|
155
219
|
/** The key's last report, with when it was observed; null until the key is checked. */
|
|
156
220
|
report: Schema.optional(Schema.NullOr(boatKeyReportSchema)),
|
|
157
221
|
/** The account's last full check (`prove`), kept beside its report; null until it is proven. */
|
|
158
222
|
lastProof: Schema.optional(Schema.NullOr(boatKeyProofSchema)),
|
|
223
|
+
/** What the account made in Boat that sealant cannot reach (`boatUnreachableSchema`). */
|
|
224
|
+
unreachable: Schema.optional(Schema.NullOr(boatUnreachableSchema)),
|
|
159
225
|
});
|
|
160
226
|
/**
|
|
161
227
|
* The install's own Boat key (`SEALANT_BOAT_API_KEY`), which workspaces run in when they name no
|
|
@@ -166,6 +232,8 @@ export const boatInstallKeySchema = Schema.Struct({
|
|
|
166
232
|
label: NonEmptyString,
|
|
167
233
|
/** The key's last report, with when it was observed; null until it is checked. */
|
|
168
234
|
report: Schema.NullOr(boatKeyReportSchema),
|
|
235
|
+
/** What the install's key made in Boat that sealant cannot reach (`boatUnreachableSchema`). */
|
|
236
|
+
unreachable: Schema.optional(Schema.NullOr(boatUnreachableSchema)),
|
|
169
237
|
});
|
|
170
238
|
export const createBoatAccountRequestSchema = Schema.Struct({
|
|
171
239
|
/** The caller's name for the account (an organization's name, say). At most 200 characters. */
|
|
@@ -178,6 +246,14 @@ export const createBoatAccountRequestSchema = Schema.Struct({
|
|
|
178
246
|
*/
|
|
179
247
|
organization: Schema.optional(NonEmptyString),
|
|
180
248
|
});
|
|
249
|
+
export const setBoatAccountOrganizationRequestSchema = Schema.Struct({
|
|
250
|
+
/**
|
|
251
|
+
* The wallet to bill from now on: an organization's id (or name) from the key report's
|
|
252
|
+
* `wallets`, or `personal` for the key's own Boat account. Only a personal key can be pointed at
|
|
253
|
+
* a wallet. Null is refused: a personal key's account is never unpinned.
|
|
254
|
+
*/
|
|
255
|
+
organization: Schema.NullOr(NonEmptyString),
|
|
256
|
+
});
|
|
181
257
|
export const rotateBoatAccountKeyRequestSchema = Schema.Struct({
|
|
182
258
|
/** The new Boat key, for the same Boat account: it must see every VM the account runs. */
|
|
183
259
|
apiKey: SecretString,
|
|
@@ -219,7 +295,12 @@ export class BoatAccountNotFoundError extends Schema.TaggedError()("BoatAccountN
|
|
|
219
295
|
* `boat-account-environment`: the install's own key (`default`) is set in its environment, not
|
|
220
296
|
* through this API. `boat-proof-running`: a full check of the account is running, or Boat may
|
|
221
297
|
* still hold what one made (the message names the VM and the snapshot): a second check, a key
|
|
222
|
-
* rotation and a
|
|
298
|
+
* rotation, a removal and a change of organization wait until sealant has deleted it.
|
|
299
|
+
* `boat-key-organization`: a change of organization for an organization's Boat key, which bills
|
|
300
|
+
* its own organization and nothing else. `boat-account-wallet-unresolved`: not answered any more
|
|
301
|
+
* (kept so a client that lists it still decodes): a change of organization, a rotation and a removal
|
|
302
|
+
* wait for nothing the account made, which each stay in their own wallet. A full check of an account
|
|
303
|
+
* sealant has not pinned yet (its key cannot show the wallet it bills) answers `boat-account-in-use`.
|
|
223
304
|
*/
|
|
224
305
|
export class BoatAccountConflictError extends Schema.TaggedError()("BoatAccountConflictError", {
|
|
225
306
|
message: Schema.String,
|
|
@@ -230,8 +311,11 @@ export class BoatAccountConflictError extends Schema.TaggedError()("BoatAccountC
|
|
|
230
311
|
"boat-account-changed",
|
|
231
312
|
"boat-account-environment",
|
|
232
313
|
"boat-proof-running",
|
|
314
|
+
"boat-key-organization",
|
|
315
|
+
"boat-account-wallet-unresolved",
|
|
233
316
|
]),
|
|
234
317
|
liveRuns: Schema.optional(Schema.Int),
|
|
318
|
+
unsettledRuns: Schema.optional(Schema.Int),
|
|
235
319
|
buildsInFlight: Schema.optional(Schema.Int),
|
|
236
320
|
unseen: Schema.optional(Schema.Int),
|
|
237
321
|
}, { httpApiStatus: 409 }) {
|
|
@@ -273,6 +357,22 @@ export const BoatAccountsGroup = HttpApiGroup.make("boatAccounts")
|
|
|
273
357
|
],
|
|
274
358
|
}))
|
|
275
359
|
.add(
|
|
360
|
+
// Points the account at another wallet, without its key. What it made stays recorded in the
|
|
361
|
+
// wallet it was made in; its saved images there are removed with requests that name it.
|
|
362
|
+
HttpApiEndpoint.put("setBoatAccountOrganization", "/:boatAccountId/organization", {
|
|
363
|
+
params: boatAccountRefParams,
|
|
364
|
+
payload: setBoatAccountOrganizationRequestSchema,
|
|
365
|
+
success: boatAccountSchema,
|
|
366
|
+
error: [
|
|
367
|
+
BoatAccountBadRequestError,
|
|
368
|
+
BoatAccountKeyRefusedError,
|
|
369
|
+
BoatAccountNotFoundError,
|
|
370
|
+
BoatAccountConflictError,
|
|
371
|
+
BoatAccountServiceUnavailableError,
|
|
372
|
+
BoatAccountInternalServerError,
|
|
373
|
+
],
|
|
374
|
+
}))
|
|
375
|
+
.add(
|
|
276
376
|
// The install's own key's last report (never the key).
|
|
277
377
|
HttpApiEndpoint.get("getBoatInstallKey", "/install-key", {
|
|
278
378
|
success: boatInstallKeySchema,
|