@sealant/api-contracts-next 0.40.0-next.788 → 0.40.0-next.789
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/control-plane.d.ts +990 -961
- package/dist/core-api/resource-domains.d.ts +19 -4
- package/dist/core-api/resource-domains.js +15 -3
- package/dist/core-api/resource-instances.d.ts +82 -8
- package/dist/core-api/resource-instances.js +46 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resource domains:
|
|
2
|
+
* Resource domains: application-owned project, organization or installation resources.
|
|
3
3
|
*
|
|
4
4
|
* An application (Mend) keeps one domain per project for the things the project owns rather than
|
|
5
|
-
* any one person: its services, volumes and network.
|
|
6
|
-
*
|
|
5
|
+
* any one person: its services, volumes and network. Organization and installation domains run
|
|
6
|
+
* caller-only services. A domain outlives every person and never runs a harness. Its id (`rdm:<uuid>`) can never
|
|
7
7
|
* name a person: every person field of this API is a `PersonId`, which refuses it.
|
|
8
8
|
*
|
|
9
9
|
* `ensureResourceDomain` is idempotent on `key`, `<application>:<name>` (Mend:
|
|
@@ -103,20 +103,32 @@ export declare const setResourceDomainBudgetRequestSchema: Schema.Struct<{
|
|
|
103
103
|
readonly storageBytes: Schema.Int;
|
|
104
104
|
}>;
|
|
105
105
|
export type SetResourceDomainBudgetRequest = typeof setResourceDomainBudgetRequestSchema.Type;
|
|
106
|
+
/** Application ownership of a scope; the application key identifies the owner. */
|
|
107
|
+
export declare const resourceDomainOwnerKindSchema: Schema.Literals<readonly ["project", "organization", "instance"]>;
|
|
108
|
+
export type ResourceDomainOwnerKind = typeof resourceDomainOwnerKindSchema.Type;
|
|
109
|
+
declare const ResourceDomainOwnerDiffersError_base: Schema.Class<ResourceDomainOwnerDiffersError, Schema.TaggedStruct<"ResourceDomainOwnerDiffersError", {
|
|
110
|
+
readonly message: Schema.String;
|
|
111
|
+
}>, import("effect/Cause").YieldableError>;
|
|
112
|
+
/** Ensuring a key cannot change its owner kind. */
|
|
113
|
+
export declare class ResourceDomainOwnerDiffersError extends ResourceDomainOwnerDiffersError_base {
|
|
114
|
+
}
|
|
106
115
|
export declare const resourceDomainSchema: Schema.Struct<{
|
|
107
116
|
readonly resourceDomainId: Schema.String;
|
|
117
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
108
118
|
readonly key: Schema.String;
|
|
109
119
|
readonly createdAt: Schema.String;
|
|
110
120
|
}>;
|
|
111
121
|
export type ResourceDomainWire = typeof resourceDomainSchema.Type;
|
|
112
122
|
export declare const ensureResourceDomainRequestSchema: Schema.Struct<{
|
|
113
123
|
readonly key: Schema.String;
|
|
124
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
114
125
|
/** The budget a new domain starts with; none starts it at zero. */
|
|
115
126
|
readonly budget: Schema.optional<Schema.Struct<Record<"cpuMillicores" | "memoryBytes" | "storageBytes", Schema.Int>>>;
|
|
116
127
|
}>;
|
|
117
128
|
export type EnsureResourceDomainRequest = typeof ensureResourceDomainRequestSchema.Type;
|
|
118
129
|
export declare const ensureResourceDomainResponseSchema: Schema.Struct<{
|
|
119
130
|
readonly resourceDomainId: Schema.String;
|
|
131
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
120
132
|
readonly key: Schema.String;
|
|
121
133
|
readonly createdAt: Schema.String;
|
|
122
134
|
/** True when this call created the domain. */
|
|
@@ -214,18 +226,21 @@ export declare class ResourceDomainInternalServerError extends ResourceDomainInt
|
|
|
214
226
|
}
|
|
215
227
|
export declare const ResourceDomainsGroup: HttpApiGroup.HttpApiGroup<"resourceDomains", HttpApiEndpoint.HttpApiEndpoint<"ensureResourceDomain", "POST", "/", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
216
228
|
readonly key: Schema.String;
|
|
229
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
217
230
|
/** The budget a new domain starts with; none starts it at zero. */
|
|
218
231
|
readonly budget: Schema.optional<Schema.Struct<Record<"cpuMillicores" | "memoryBytes" | "storageBytes", Schema.Int>>>;
|
|
219
232
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
220
233
|
readonly resourceDomainId: Schema.String;
|
|
234
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
221
235
|
readonly key: Schema.String;
|
|
222
236
|
readonly createdAt: Schema.String;
|
|
223
237
|
/** True when this call created the domain. */
|
|
224
238
|
readonly created: Schema.Boolean;
|
|
225
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainBudgetDiffersError | typeof ResourceDomainInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getResourceDomain", "GET", "/:resourceDomainId", Schema.toCodecStringTree<Schema.Struct<{
|
|
239
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainOwnerDiffersError | typeof ResourceDomainForbiddenError | typeof ResourceDomainBudgetDiffersError | typeof ResourceDomainInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getResourceDomain", "GET", "/:resourceDomainId", Schema.toCodecStringTree<Schema.Struct<{
|
|
226
240
|
readonly resourceDomainId: Schema.String;
|
|
227
241
|
}>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
228
242
|
readonly resourceDomainId: Schema.String;
|
|
243
|
+
readonly ownerKind: Schema.optional<Schema.Literals<readonly ["project", "organization", "instance"]>>;
|
|
229
244
|
readonly key: Schema.String;
|
|
230
245
|
readonly createdAt: Schema.String;
|
|
231
246
|
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getResourceDomainBudget", "GET", "/:resourceDomainId/budget", Schema.toCodecStringTree<Schema.Struct<{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resource domains:
|
|
2
|
+
* Resource domains: application-owned project, organization or installation resources.
|
|
3
3
|
*
|
|
4
4
|
* An application (Mend) keeps one domain per project for the things the project owns rather than
|
|
5
|
-
* any one person: its services, volumes and network.
|
|
6
|
-
*
|
|
5
|
+
* any one person: its services, volumes and network. Organization and installation domains run
|
|
6
|
+
* caller-only services. A domain outlives every person and never runs a harness. Its id (`rdm:<uuid>`) can never
|
|
7
7
|
* name a person: every person field of this API is a `PersonId`, which refuses it.
|
|
8
8
|
*
|
|
9
9
|
* `ensureResourceDomain` is idempotent on `key`, `<application>:<name>` (Mend:
|
|
@@ -85,13 +85,24 @@ export const setResourceDomainBudgetRequestSchema = Schema.Struct({
|
|
|
85
85
|
/** The revision this change replaces: the one the caller last read. */
|
|
86
86
|
revision: BudgetRevision,
|
|
87
87
|
});
|
|
88
|
+
/** Application ownership of a scope; the application key identifies the owner. */
|
|
89
|
+
export const resourceDomainOwnerKindSchema = Schema.Literals([
|
|
90
|
+
"project",
|
|
91
|
+
"organization",
|
|
92
|
+
"instance",
|
|
93
|
+
]);
|
|
94
|
+
/** Ensuring a key cannot change its owner kind. */
|
|
95
|
+
export class ResourceDomainOwnerDiffersError extends Schema.TaggedError()("ResourceDomainOwnerDiffersError", { message: Schema.String }, { httpApiStatus: 409 }) {
|
|
96
|
+
}
|
|
88
97
|
export const resourceDomainSchema = Schema.Struct({
|
|
89
98
|
resourceDomainId: ResourceDomainId,
|
|
99
|
+
ownerKind: Schema.optional(resourceDomainOwnerKindSchema),
|
|
90
100
|
key: ResourceDomainKey,
|
|
91
101
|
createdAt: Schema.String,
|
|
92
102
|
});
|
|
93
103
|
export const ensureResourceDomainRequestSchema = Schema.Struct({
|
|
94
104
|
key: ResourceDomainKey,
|
|
105
|
+
ownerKind: Schema.optional(resourceDomainOwnerKindSchema),
|
|
95
106
|
/** The budget a new domain starts with; none starts it at zero. */
|
|
96
107
|
budget: Schema.optional(resourceDomainBudgetLimitsSchema),
|
|
97
108
|
});
|
|
@@ -166,6 +177,7 @@ export const ResourceDomainsGroup = HttpApiGroup.make("resourceDomains")
|
|
|
166
177
|
error: [
|
|
167
178
|
ResourceDomainForbiddenError,
|
|
168
179
|
ResourceDomainBudgetDiffersError,
|
|
180
|
+
ResourceDomainOwnerDiffersError,
|
|
169
181
|
ResourceDomainInternalServerError,
|
|
170
182
|
],
|
|
171
183
|
}))
|
|
@@ -30,6 +30,8 @@ export type ResourcePinnedImage = typeof ResourcePinnedImage.Type;
|
|
|
30
30
|
export declare const resourceInstanceVolumeSchema: Schema.Struct<{
|
|
31
31
|
readonly name: Schema.String;
|
|
32
32
|
readonly mountPath: Schema.String;
|
|
33
|
+
/** Storage reserved in the scope budget; required for caller instances. */
|
|
34
|
+
readonly storageBytes: Schema.optional<Schema.Int>;
|
|
33
35
|
}>;
|
|
34
36
|
export type ResourceInstanceVolume = typeof resourceInstanceVolumeSchema.Type;
|
|
35
37
|
export declare const resourceInstanceReadySchema: Schema.Union<readonly [Schema.Struct<{
|
|
@@ -43,8 +45,24 @@ export declare const resourceInstanceReadySchema: Schema.Union<readonly [Schema.
|
|
|
43
45
|
export type ResourceInstanceReady = typeof resourceInstanceReadySchema.Type;
|
|
44
46
|
/** Ten days: the longest an instance may wait unreached before Core stops it. */
|
|
45
47
|
export declare const RESOURCE_INSTANCE_MAX_IDLE_SECONDS = 864000;
|
|
48
|
+
/** A configured caller receives the service and exposes one private callback port. */
|
|
49
|
+
export declare const resourceCallerReachSchema: Schema.Struct<{
|
|
50
|
+
readonly kind: Schema.Literal<"caller">;
|
|
51
|
+
readonly caller: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
52
|
+
readonly port: Schema.Int;
|
|
53
|
+
readonly callbackPort: Schema.Int;
|
|
54
|
+
}>;
|
|
55
|
+
export type ResourceCallerReach = typeof resourceCallerReachSchema.Type;
|
|
56
|
+
/** Write-only process env. Core seals it before persistence and never returns or records it. */
|
|
57
|
+
export declare const resourceInstanceSecretEnvSchema: Schema.$Record<Schema.String, Schema.String>;
|
|
46
58
|
/** What an instance runs. Excess keys are refused; see the header for what has no field. */
|
|
47
59
|
export declare const resourceInstanceSpecSchema: Schema.Struct<{
|
|
60
|
+
readonly reach: Schema.optional<Schema.Struct<{
|
|
61
|
+
readonly kind: Schema.Literal<"caller">;
|
|
62
|
+
readonly caller: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
63
|
+
readonly port: Schema.Int;
|
|
64
|
+
readonly callbackPort: Schema.Int;
|
|
65
|
+
}>>;
|
|
48
66
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
49
67
|
/** Null: every workspace linked to the domain reaches it. Set: only links with this key. */
|
|
50
68
|
readonly worktreeKey: Schema.NullOr<Schema.brand<Schema.String, "ResourceWorktreeKey">>;
|
|
@@ -56,6 +74,8 @@ export declare const resourceInstanceSpecSchema: Schema.Struct<{
|
|
|
56
74
|
readonly volumes: Schema.$Array<Schema.Struct<{
|
|
57
75
|
readonly name: Schema.String;
|
|
58
76
|
readonly mountPath: Schema.String;
|
|
77
|
+
/** Storage reserved in the scope budget; required for caller instances. */
|
|
78
|
+
readonly storageBytes: Schema.optional<Schema.Int>;
|
|
59
79
|
}>>;
|
|
60
80
|
readonly limits: Schema.Struct<{
|
|
61
81
|
readonly cpuMillicores: Schema.Int;
|
|
@@ -70,7 +90,7 @@ export declare const resourceInstanceSpecSchema: Schema.Struct<{
|
|
|
70
90
|
readonly user: Schema.NullOr<Schema.String>;
|
|
71
91
|
}>]>;
|
|
72
92
|
/** Seconds with no live linked executor reaching it before Core stops it. */
|
|
73
|
-
readonly idleStopAfterSeconds: Schema.Int
|
|
93
|
+
readonly idleStopAfterSeconds: Schema.NullOr<Schema.Int>;
|
|
74
94
|
}>;
|
|
75
95
|
export type ResourceInstanceSpec = typeof resourceInstanceSpecSchema.Type;
|
|
76
96
|
export declare const resourceInstanceStopReasonSchema: Schema.Union<readonly [Schema.Struct<{
|
|
@@ -143,6 +163,7 @@ export declare const upResourceInstanceRequestSchema: Schema.Struct<{
|
|
|
143
163
|
readonly spec: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
144
164
|
/** `use`: a launch or a wake, which leaves a person's stop standing. `person`: a person's Start. */
|
|
145
165
|
readonly cause: Schema.Literals<readonly ["use", "person"]>;
|
|
166
|
+
readonly secretEnv: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
146
167
|
}>;
|
|
147
168
|
export type UpResourceInstanceRequest = typeof upResourceInstanceRequestSchema.Type;
|
|
148
169
|
export declare const stopResourceInstanceRequestSchema: Schema.Struct<{
|
|
@@ -151,6 +172,12 @@ export declare const stopResourceInstanceRequestSchema: Schema.Struct<{
|
|
|
151
172
|
}>;
|
|
152
173
|
export type StopResourceInstanceRequest = typeof stopResourceInstanceRequestSchema.Type;
|
|
153
174
|
export declare const resourceInstanceSchema: Schema.Struct<{
|
|
175
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
176
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
177
|
+
readonly host: Schema.String;
|
|
178
|
+
readonly port: Schema.Int;
|
|
179
|
+
readonly callbackHost: Schema.String;
|
|
180
|
+
}>>;
|
|
154
181
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
155
182
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
156
183
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -292,6 +319,22 @@ declare const ResourceWorkspaceLinkedElsewhereError_base: Schema.Class<ResourceW
|
|
|
292
319
|
/** A workspace links to one domain; it is linked to `resourceDomainId`. */
|
|
293
320
|
export declare class ResourceWorkspaceLinkedElsewhereError extends ResourceWorkspaceLinkedElsewhereError_base {
|
|
294
321
|
}
|
|
322
|
+
declare const ResourceInstanceBusyError_base: Schema.Class<ResourceInstanceBusyError, Schema.TaggedStruct<"ResourceInstanceBusyError", {
|
|
323
|
+
readonly message: Schema.String;
|
|
324
|
+
}>, import("effect/Cause").YieldableError>;
|
|
325
|
+
/** Another lifecycle operation holds the instance. Retry after it finishes. */
|
|
326
|
+
export declare class ResourceInstanceBusyError extends ResourceInstanceBusyError_base {
|
|
327
|
+
}
|
|
328
|
+
declare const ResourceInstanceBudgetError_base: Schema.Class<ResourceInstanceBudgetError, Schema.TaggedStruct<"ResourceInstanceBudgetError", {
|
|
329
|
+
readonly message: Schema.String;
|
|
330
|
+
}>, import("effect/Cause").YieldableError>;
|
|
331
|
+
/** A scope budget refuses an increase; existing work and retained data remain. */
|
|
332
|
+
export declare class ResourceInstanceBudgetError extends ResourceInstanceBudgetError_base {
|
|
333
|
+
}
|
|
334
|
+
/** A stopped, retained volume can be downloaded as a tar stream. */
|
|
335
|
+
export declare const RESOURCE_INSTANCE_BACKUP: {
|
|
336
|
+
readonly path: "/v1/resource-domains/:resourceDomainId/instances/:key/volumes/:volume/backup";
|
|
337
|
+
};
|
|
295
338
|
export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resourceInstances", HttpApiEndpoint.HttpApiEndpoint<"archiveResourceDomain", "POST", "/:resourceDomainId/archive", Schema.toCodecStringTree<Schema.Struct<{
|
|
296
339
|
readonly resourceDomainId: Schema.String;
|
|
297
340
|
}>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
@@ -302,11 +345,17 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
302
345
|
/** Measured at archive; null when it could not be. */
|
|
303
346
|
readonly bytes: Schema.NullOr<Schema.Int>;
|
|
304
347
|
}>>;
|
|
305
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceRuntimeUnsupportedError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"archiveResourceInstance", "POST", "/:resourceDomainId/instances/:key/archive", Schema.toCodecStringTree<Schema.Struct<{
|
|
348
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"archiveResourceInstance", "POST", "/:resourceDomainId/instances/:key/archive", Schema.toCodecStringTree<Schema.Struct<{
|
|
306
349
|
readonly resourceDomainId: Schema.String;
|
|
307
350
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
308
351
|
}>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
309
352
|
readonly instance: Schema.Struct<{
|
|
353
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
354
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
355
|
+
readonly host: Schema.String;
|
|
356
|
+
readonly port: Schema.Int;
|
|
357
|
+
readonly callbackHost: Schema.String;
|
|
358
|
+
}>>;
|
|
310
359
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
311
360
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
312
361
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -367,10 +416,16 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
367
416
|
/** Measured at archive; null when it could not be. */
|
|
368
417
|
readonly bytes: Schema.NullOr<Schema.Int>;
|
|
369
418
|
}>>;
|
|
370
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceNotFoundError | typeof ResourceRuntimeUnsupportedError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getResourceInstance", "GET", "/:resourceDomainId/instances/:key", Schema.toCodecStringTree<Schema.Struct<{
|
|
419
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceInstanceNotFoundError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getResourceInstance", "GET", "/:resourceDomainId/instances/:key", Schema.toCodecStringTree<Schema.Struct<{
|
|
371
420
|
readonly resourceDomainId: Schema.String;
|
|
372
421
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
373
422
|
}>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
423
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
424
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
425
|
+
readonly host: Schema.String;
|
|
426
|
+
readonly port: Schema.Int;
|
|
427
|
+
readonly callbackHost: Schema.String;
|
|
428
|
+
}>>;
|
|
374
429
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
375
430
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
376
431
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -423,7 +478,7 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
423
478
|
readonly name: Schema.String;
|
|
424
479
|
readonly dockerName: Schema.String;
|
|
425
480
|
}>>;
|
|
426
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"linkResourceWorkspace", "PUT", "/:resourceDomainId/workspace-links/:workspaceId", Schema.toCodecStringTree<Schema.Struct<{
|
|
481
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceInstanceNotFoundError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"linkResourceWorkspace", "PUT", "/:resourceDomainId/workspace-links/:workspaceId", Schema.toCodecStringTree<Schema.Struct<{
|
|
427
482
|
readonly resourceDomainId: Schema.String;
|
|
428
483
|
readonly workspaceId: Schema.String;
|
|
429
484
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
@@ -436,13 +491,19 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
436
491
|
readonly aliases: Schema.NullOr<Schema.$Record<Schema.brand<Schema.String, "ResourceInstanceAlias">, Schema.Literals<readonly ["project", "worktree"]>>>;
|
|
437
492
|
/** How many of the workspace's live executors were attached by this call. */
|
|
438
493
|
readonly attachedExecutors: Schema.Int;
|
|
439
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceRuntimeUnsupportedError | typeof ResourceDomainNotActiveError | typeof ResourceWorkspaceNotFoundError | typeof ResourceWorkspaceLinkedElsewhereError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listResourceInstances", "GET", "/:resourceDomainId/instances", Schema.toCodecStringTree<Schema.Struct<{
|
|
494
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceRuntimeUnsupportedError | typeof ResourceDomainNotActiveError | typeof ResourceWorkspaceNotFoundError | typeof ResourceWorkspaceLinkedElsewhereError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listResourceInstances", "GET", "/:resourceDomainId/instances", Schema.toCodecStringTree<Schema.Struct<{
|
|
440
495
|
readonly resourceDomainId: Schema.String;
|
|
441
496
|
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
442
497
|
/** `true`: the archived instances, whose volumes are kept. Otherwise every other one. */
|
|
443
498
|
readonly archived: Schema.optional<Schema.Literals<readonly ["true", "false"]>>;
|
|
444
499
|
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
445
500
|
readonly items: Schema.$Array<Schema.Struct<{
|
|
501
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
502
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
503
|
+
readonly host: Schema.String;
|
|
504
|
+
readonly port: Schema.Int;
|
|
505
|
+
readonly callbackHost: Schema.String;
|
|
506
|
+
}>>;
|
|
446
507
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
447
508
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
448
509
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -496,13 +557,19 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
496
557
|
readonly dockerName: Schema.String;
|
|
497
558
|
}>>;
|
|
498
559
|
}>>;
|
|
499
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"stopResourceInstance", "POST", "/:resourceDomainId/instances/:key/stop", Schema.toCodecStringTree<Schema.Struct<{
|
|
560
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"stopResourceInstance", "POST", "/:resourceDomainId/instances/:key/stop", Schema.toCodecStringTree<Schema.Struct<{
|
|
500
561
|
readonly resourceDomainId: Schema.String;
|
|
501
562
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
502
563
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
503
564
|
/** The application's words for who stopped it (Mend: a display name). */
|
|
504
565
|
readonly by: Schema.String;
|
|
505
566
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
567
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
568
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
569
|
+
readonly host: Schema.String;
|
|
570
|
+
readonly port: Schema.Int;
|
|
571
|
+
readonly callbackHost: Schema.String;
|
|
572
|
+
}>>;
|
|
506
573
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
507
574
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
508
575
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -555,7 +622,7 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
555
622
|
readonly name: Schema.String;
|
|
556
623
|
readonly dockerName: Schema.String;
|
|
557
624
|
}>>;
|
|
558
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceNotFoundError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceArchivedError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"upResourceInstance", "POST", "/:resourceDomainId/instances/:key/up", Schema.toCodecStringTree<Schema.Struct<{
|
|
625
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceInstanceNotFoundError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceArchivedError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"upResourceInstance", "POST", "/:resourceDomainId/instances/:key/up", Schema.toCodecStringTree<Schema.Struct<{
|
|
559
626
|
readonly resourceDomainId: Schema.String;
|
|
560
627
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
561
628
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
@@ -566,7 +633,14 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
566
633
|
readonly spec: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
567
634
|
/** `use`: a launch or a wake, which leaves a person's stop standing. `person`: a person's Start. */
|
|
568
635
|
readonly cause: Schema.Literals<readonly ["use", "person"]>;
|
|
636
|
+
readonly secretEnv: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
569
637
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
638
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
639
|
+
readonly endpoint: Schema.optional<Schema.Struct<{
|
|
640
|
+
readonly host: Schema.String;
|
|
641
|
+
readonly port: Schema.Int;
|
|
642
|
+
readonly callbackHost: Schema.String;
|
|
643
|
+
}>>;
|
|
570
644
|
readonly resourceInstanceId: Schema.brand<Schema.String, "ResourceInstanceId">;
|
|
571
645
|
readonly key: Schema.brand<Schema.String, "ResourceInstanceKey">;
|
|
572
646
|
readonly alias: Schema.brand<Schema.String, "ResourceInstanceAlias">;
|
|
@@ -619,7 +693,7 @@ export declare const ResourceInstancesGroup: HttpApiGroup.HttpApiGroup<"resource
|
|
|
619
693
|
readonly name: Schema.String;
|
|
620
694
|
readonly dockerName: Schema.String;
|
|
621
695
|
}>>;
|
|
622
|
-
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceArchivedError | typeof ResourceInstanceAliasTakenError | typeof ResourceDomainNotActiveError>, never, never>, false>;
|
|
696
|
+
}>>, Schema.toCodecJson<typeof ResourceDomainForbiddenError | typeof ResourceDomainNotFoundError | typeof ResourceDomainInternalServerError | typeof ResourceInstanceSpecRefusedError | typeof ResourceRuntimeUnsupportedError | typeof ResourceInstanceArchivedError | typeof ResourceInstanceAliasTakenError | typeof ResourceDomainNotActiveError | typeof ResourceInstanceBusyError | typeof ResourceInstanceBudgetError>, never, never>, false>;
|
|
623
697
|
/**
|
|
624
698
|
* The raw exec route, beside the contract: `POST /v1/resource-domains/:id/instances/:key/exec`.
|
|
625
699
|
* Its body is one JSON line (`execFrame`, at most `maxFrameBytes`) and then the command's stdin,
|
|
@@ -46,6 +46,8 @@ const Port = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 }))
|
|
|
46
46
|
export const resourceInstanceVolumeSchema = Schema.Struct({
|
|
47
47
|
name: VolumeName,
|
|
48
48
|
mountPath: MountPath,
|
|
49
|
+
/** Storage reserved in the scope budget; required for caller instances. */
|
|
50
|
+
storageBytes: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }))),
|
|
49
51
|
});
|
|
50
52
|
export const resourceInstanceReadySchema = Schema.Union([
|
|
51
53
|
Schema.Struct({ kind: Schema.Literal("tcp"), port: Port }),
|
|
@@ -58,8 +60,18 @@ export const resourceInstanceReadySchema = Schema.Union([
|
|
|
58
60
|
/** Ten days: the longest an instance may wait unreached before Core stops it. */
|
|
59
61
|
export const RESOURCE_INSTANCE_MAX_IDLE_SECONDS = 864_000;
|
|
60
62
|
const distinct = (by, message) => (items) => new Set(items.map(by)).size === items.length ? undefined : message;
|
|
63
|
+
/** A configured caller receives the service and exposes one private callback port. */
|
|
64
|
+
export const resourceCallerReachSchema = Schema.Struct({
|
|
65
|
+
kind: Schema.Literal("caller"),
|
|
66
|
+
caller: ResourceInstanceAlias,
|
|
67
|
+
port: Port,
|
|
68
|
+
callbackPort: Port,
|
|
69
|
+
});
|
|
70
|
+
/** Write-only process env. Core seals it before persistence and never returns or records it. */
|
|
71
|
+
export const resourceInstanceSecretEnvSchema = Schema.Record(EnvName, EnvValue);
|
|
61
72
|
/** What an instance runs. Excess keys are refused; see the header for what has no field. */
|
|
62
73
|
export const resourceInstanceSpecSchema = Schema.Struct({
|
|
74
|
+
reach: Schema.optional(resourceCallerReachSchema),
|
|
63
75
|
alias: ResourceInstanceAlias,
|
|
64
76
|
/** Null: every workspace linked to the domain reaches it. Set: only links with this key. */
|
|
65
77
|
worktreeKey: Schema.NullOr(ResourceWorktreeKey),
|
|
@@ -75,7 +87,7 @@ export const resourceInstanceSpecSchema = Schema.Struct({
|
|
|
75
87
|
}),
|
|
76
88
|
ready: resourceInstanceReadySchema,
|
|
77
89
|
/** Seconds with no live linked executor reaching it before Core stops it. */
|
|
78
|
-
idleStopAfterSeconds: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: RESOURCE_INSTANCE_MAX_IDLE_SECONDS })),
|
|
90
|
+
idleStopAfterSeconds: Schema.NullOr(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: RESOURCE_INSTANCE_MAX_IDLE_SECONDS }))),
|
|
79
91
|
});
|
|
80
92
|
export const resourceInstanceStopReasonSchema = Schema.Union([
|
|
81
93
|
Schema.Struct({ kind: Schema.Literal("idle") }),
|
|
@@ -151,6 +163,22 @@ export const decodeResourceInstanceSpec = (input) => {
|
|
|
151
163
|
if (forbidden.length > 0)
|
|
152
164
|
return { kind: "refused", refusals: forbidden };
|
|
153
165
|
const decoded = decodeSpec(input, { onExcessProperty: "error", errors: "all" });
|
|
166
|
+
if (Result.isSuccess(decoded)) {
|
|
167
|
+
const spec = decoded.success;
|
|
168
|
+
const reason = spec.reach === undefined
|
|
169
|
+
? spec.idleStopAfterSeconds === null
|
|
170
|
+
? "workspace instances require an idle stop"
|
|
171
|
+
: undefined
|
|
172
|
+
: spec.worktreeKey !== null || spec.idleStopAfterSeconds !== null
|
|
173
|
+
? "caller instances require no worktree key and no idle stop"
|
|
174
|
+
: spec.volumes.length === 0
|
|
175
|
+
? "caller instances require at least one retained named volume"
|
|
176
|
+
: spec.volumes.some((volume) => volume.storageBytes === undefined)
|
|
177
|
+
? "caller volumes require storageBytes for budget admission"
|
|
178
|
+
: undefined;
|
|
179
|
+
if (reason !== undefined)
|
|
180
|
+
return { kind: "refused", refusals: [{ field: "spec", reason }] };
|
|
181
|
+
}
|
|
154
182
|
return Result.isSuccess(decoded)
|
|
155
183
|
? { kind: "spec", spec: decoded.success }
|
|
156
184
|
: {
|
|
@@ -171,6 +199,7 @@ export const upResourceInstanceRequestSchema = Schema.Struct({
|
|
|
171
199
|
spec: Schema.Record(Schema.String, Schema.Unknown),
|
|
172
200
|
/** `use`: a launch or a wake, which leaves a person's stop standing. `person`: a person's Start. */
|
|
173
201
|
cause: resourceInstanceUpCauseSchema,
|
|
202
|
+
secretEnv: Schema.optional(resourceInstanceSecretEnvSchema),
|
|
174
203
|
});
|
|
175
204
|
export const stopResourceInstanceRequestSchema = Schema.Struct({
|
|
176
205
|
/** The application's words for who stopped it (Mend: a display name). */
|
|
@@ -178,6 +207,8 @@ export const stopResourceInstanceRequestSchema = Schema.Struct({
|
|
|
178
207
|
});
|
|
179
208
|
const Timestamp = Schema.String;
|
|
180
209
|
export const resourceInstanceSchema = Schema.Struct({
|
|
210
|
+
/** Stable caller-only endpoint; absent on workspace instances. */
|
|
211
|
+
endpoint: Schema.optional(Schema.Struct({ host: Schema.String, port: Port, callbackHost: Schema.String })),
|
|
181
212
|
resourceInstanceId: ResourceInstanceId,
|
|
182
213
|
key: ResourceInstanceKey,
|
|
183
214
|
alias: ResourceInstanceAlias,
|
|
@@ -250,6 +281,16 @@ export class ResourceWorkspaceNotFoundError extends Schema.TaggedError()("Resour
|
|
|
250
281
|
/** A workspace links to one domain; it is linked to `resourceDomainId`. */
|
|
251
282
|
export class ResourceWorkspaceLinkedElsewhereError extends Schema.TaggedError()("ResourceWorkspaceLinkedElsewhereError", { message: Schema.String, resourceDomainId: Schema.String }, { httpApiStatus: 409 }) {
|
|
252
283
|
}
|
|
284
|
+
/** Another lifecycle operation holds the instance. Retry after it finishes. */
|
|
285
|
+
export class ResourceInstanceBusyError extends Schema.TaggedError()("ResourceInstanceBusyError", { message: Schema.String }, { httpApiStatus: 409 }) {
|
|
286
|
+
}
|
|
287
|
+
/** A scope budget refuses an increase; existing work and retained data remain. */
|
|
288
|
+
export class ResourceInstanceBudgetError extends Schema.TaggedError()("ResourceInstanceBudgetError", { message: Schema.String }, { httpApiStatus: 409 }) {
|
|
289
|
+
}
|
|
290
|
+
/** A stopped, retained volume can be downloaded as a tar stream. */
|
|
291
|
+
export const RESOURCE_INSTANCE_BACKUP = {
|
|
292
|
+
path: "/v1/resource-domains/:resourceDomainId/instances/:key/volumes/:volume/backup",
|
|
293
|
+
};
|
|
253
294
|
const instanceParams = Schema.Struct({
|
|
254
295
|
resourceDomainId: ResourceDomainId,
|
|
255
296
|
key: ResourceInstanceKey,
|
|
@@ -259,6 +300,10 @@ const baseErrors = [
|
|
|
259
300
|
ResourceDomainForbiddenError,
|
|
260
301
|
ResourceDomainNotFoundError,
|
|
261
302
|
ResourceDomainInternalServerError,
|
|
303
|
+
ResourceInstanceSpecRefusedError,
|
|
304
|
+
ResourceInstanceBusyError,
|
|
305
|
+
ResourceInstanceBudgetError,
|
|
306
|
+
ResourceRuntimeUnsupportedError,
|
|
262
307
|
];
|
|
263
308
|
export const ResourceInstancesGroup = HttpApiGroup.make("resourceInstances")
|
|
264
309
|
.add(HttpApiEndpoint.post("upResourceInstance", "/:resourceDomainId/instances/:key/up", {
|
package/dist/index.d.ts
CHANGED
|
@@ -23,3 +23,5 @@ export * from "./core-api/users.js";
|
|
|
23
23
|
export * from "./workspace-environment.js";
|
|
24
24
|
export * from "./capture-owner-map.js";
|
|
25
25
|
export * from "./connected-account-selector.js";
|
|
26
|
+
export { resourceDomainOwnerKindSchema, ResourceDomainOwnerDiffersError, type ResourceDomainOwnerKind, } from "./core-api/resource-domains.js";
|
|
27
|
+
export { resourceCallerReachSchema, resourceInstanceSecretEnvSchema, ResourceInstanceBusyError, ResourceInstanceBudgetError, RESOURCE_INSTANCE_BACKUP, type ResourceCallerReach, } from "./core-api/resource-instances.js";
|
package/dist/index.js
CHANGED
|
@@ -23,3 +23,5 @@ export * from "./core-api/users.js";
|
|
|
23
23
|
export * from "./workspace-environment.js";
|
|
24
24
|
export * from "./capture-owner-map.js";
|
|
25
25
|
export * from "./connected-account-selector.js";
|
|
26
|
+
export { resourceDomainOwnerKindSchema, ResourceDomainOwnerDiffersError, } from "./core-api/resource-domains.js";
|
|
27
|
+
export { resourceCallerReachSchema, resourceInstanceSecretEnvSchema, ResourceInstanceBusyError, ResourceInstanceBudgetError, RESOURCE_INSTANCE_BACKUP, } from "./core-api/resource-instances.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealant/api-contracts-next",
|
|
3
|
-
"version": "0.40.0-next.
|
|
3
|
+
"version": "0.40.0-next.789",
|
|
4
4
|
"description": "Contract-first HTTP API definitions for Sealant services",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"effect": "^4.0.5"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "1a0bf7279c949110296c8f40f21c4c745d81db9d",
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
}
|