@fabrika/control-contract 0.9.0-dev.4 → 0.9.0-dev.6

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.
@@ -1,8 +1,9 @@
1
1
  import type { RpcProcedureContract } from '@fabrika/app';
2
- import type { ExportDescription } from '@fabrika/auth-core';
2
+ import type { ExportDescription, OpsContentView, OpsView } from '@fabrika/auth-core';
3
+ import { z } from 'zod';
3
4
  import type { BuilderConnectionReceiptDto, CreateBuilderConnectionReceiptRequest, GetBuilderConnectionReceiptRequest } from './builder-connections.js';
4
5
  import type { ApproveDeviceAuthorizationResult, BuilderPairingProofRequest, DenyDeviceAuthorizationResult, InspectDeviceAuthorizationResult, ListOwnBuilderPairingsRequest, ListOwnDeviceAuthorizationsResult, RevokeBuilderPairingRequest, RevokeKeyResult } from './builder-pairing.js';
5
- import type { AdoptDeploymentNamespaceRequest, AppDto, AppEnvDto, ApprovalDto, AppSecretDto, AppVarDto, CompleteApprovalRequest, ConsoleAccessDto, CreateDeploymentNamespaceRequest, CursorList, DeploymentNamespaceDetailDto, DeploymentNamespaceListResponse, GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse, GitHubSourceConnectionStatusDto, InstallationDto, ListResponse, PlanDeploymentNamespaceRequest, PlanDeploymentNamespaceResponse, PutAppEnvRequest, PutAppSecretRequest, PutAppVarRequest, RegisterAppRequest, RegisterAppResponse, RemoveDeploymentNamespaceResponse, RunDto, RunLogResponse, RunTailResponse, SetEnvironmentProtectionRequest, StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse, TriggerDeployRequest, UpdateAppRequest, UpdateDeploymentNamespaceRequest } from './index.js';
6
+ import type { AdoptDeploymentNamespaceRequest, AppDto, AppEnvDto, ApprovalDto, AppSecretDto, AppVarDto, CompleteApprovalRequest, ConsoleAccessDto, CreateDeploymentNamespaceRequest, CursorList, DeploymentNamespaceDetailDto, DeploymentNamespaceListResponse, GitHubSourceConnectionListInput, GitHubSourceConnectionListResponse, GitHubSourceConnectionStatusDto, InstallationDto, ListResponse, PlanDeploymentNamespaceRequest, PlanDeploymentNamespaceResponse, PutAppEnvRequest, PutAppSecretRequest, PutAppVarRequest, RegisterAppRequest, RegisterAppResponse, ReleaseNamespaceClaimsResponse, RemoveDeploymentNamespaceResponse, RepublishAllNamespacesResponse, RunDto, RunLogResponse, RunStatus, RunTailResponse, SetEnvironmentProtectionRequest, StartGitHubSourceConnectionRequest, StartGitHubSourceConnectionResponse, TriggerDeployRequest, UpdateAppRequest, UpdateDeploymentNamespaceRequest } from './index.js';
6
7
  import type { MailMessageDetailDto, MailMessageDto, MailMessageIdInput, MailMessageListInput, MailRuleDto, MailRuleIdInput, SetMailRuleInput } from './mail.js';
7
8
  type RpcProcedure<TInput, TOutput> = RpcProcedureContract<TInput, TOutput>;
8
9
  export interface AppIdInput {
@@ -51,9 +52,16 @@ export interface AdoptNamespaceInput extends NamespaceIdInput {
51
52
  export interface UpdateNamespaceInput extends NamespaceIdInput {
52
53
  readonly namespace: UpdateDeploymentNamespaceRequest;
53
54
  }
55
+ /** The app environment whose claims in the namespace are released. */
56
+ export interface ReleaseNamespaceClaimsInput extends NamespaceIdInput {
57
+ readonly appId: string;
58
+ readonly env: string;
59
+ }
54
60
  export interface RunListInput {
55
61
  readonly appId?: string;
56
62
  readonly env?: string;
63
+ /** Filter before pagination, so an old queued or running deploy is not hidden by newer finished runs. */
64
+ readonly statuses?: RunStatus[];
57
65
  readonly before?: string;
58
66
  readonly limit?: number;
59
67
  }
@@ -136,6 +144,16 @@ export interface ControlRpcContract {
136
144
  update: RpcProcedure<UpdateNamespaceInput, DeploymentNamespaceDetailDto>;
137
145
  /** Free a namespace id. Refused while any app environment is registered in it (backlog 73). */
138
146
  remove: RpcProcedure<NamespaceIdInput, RemoveDeploymentNamespaceResponse>;
147
+ /**
148
+ * Republish the proxy of every ready namespace, as after a change of the installation's client logo (ADR-0066).
149
+ * Returns once each rebuild is submitted; a failure is a 502 naming the namespaces to reconcile.
150
+ */
151
+ republishAll: RpcProcedure<void, RepublishAllNamespacesResponse>;
152
+ /**
153
+ * Release one app environment's resource claims in the namespace, only when the provider confirms every claimed
154
+ * resource gone. The operator deletes the resources first; fabrika deletes none (ADR-0034).
155
+ */
156
+ releaseClaims: RpcProcedure<ReleaseNamespaceClaimsInput, ReleaseNamespaceClaimsResponse>;
139
157
  };
140
158
  runs: {
141
159
  list: RpcProcedure<RunListInput, CursorList<RunDto>>;
@@ -178,6 +196,29 @@ export interface ControlRpcContract {
178
196
  remove: RpcProcedure<MailRuleIdInput, OkResponse>;
179
197
  };
180
198
  };
199
+ /**
200
+ * An application environment's data (ADR-0069): `data.read` and `data.manage` at the coordinates,
201
+ * `data.content.read` as a global grant only; every denial is the 404 of an absent environment.
202
+ */
203
+ data: {
204
+ operations: {
205
+ list: RpcProcedure<DataOperationListInput, CursorList<DataOperationDto>>;
206
+ get: RpcProcedure<{
207
+ operationId: string;
208
+ }, DataOperationDto>;
209
+ };
210
+ /** The metadata view; never content. */
211
+ view: RpcProcedure<AppEnvironmentInput, OpsView>;
212
+ content: RpcProcedure<AppEnvironmentInput, OpsContentView>;
213
+ start: RpcProcedure<StartDataOperationInput, DataOperationDto>;
214
+ recover: RpcProcedure<RecoverDataOperationInput, DataOperationDto>;
215
+ /** Consistent backups (ADR-0070): listed and their schedule read under `data.read`, the schedule set under `data.manage`. */
216
+ backups: {
217
+ list: RpcProcedure<DataOperationListInput, CursorList<DataBackupDto>>;
218
+ schedule: RpcProcedure<AppEnvironmentInput, DataBackupScheduleDto>;
219
+ setSchedule: RpcProcedure<SetDataBackupScheduleInput, DataBackupScheduleDto>;
220
+ };
221
+ };
181
222
  }
182
223
  /**
183
224
  * One export version of `app` as the environment `env` approved it, read for its consumer `consumer`. Unknown, not
@@ -190,4 +231,186 @@ export interface DescribeConnectorRequest {
190
231
  readonly export: string;
191
232
  readonly version: number;
192
233
  }
234
+ /** What an application environment's object admits (ADR-0069 §3). */
235
+ export type MaintenanceMode = 'open' | 'read-only' | 'closed' | 'inspect';
236
+ export type DataOperationKind = 'maintenance' | 'backup' | 'migrate' | 'recovery' | 'restore';
237
+ /**
238
+ * Where an operation stands: `reconcile` reads the record and the object's published state (a recovery's first step),
239
+ * `restrict` publishes a generation in a restricting mode, `backup` and `verify` take and check a consistent backup,
240
+ * `deploy` runs the operation's own deploy, `migrate` runs the pending migrations, `resume` continues the interrupted
241
+ * operation from its recorded step, and `open` publishes the generation that opens the object. A side restore (ADR-0070
242
+ * §9) also `list`s its clone with a deploy, `import`s the backup into it, `promote`s it (the clone `open`, the original
243
+ * `inspect`), `point`s ordinary traffic at it with a deploy, waits for it to `serve`, `rewind`s the original to the
244
+ * target time and `check`s the original's schema; `revert` points traffic back at the original with a deploy.
245
+ */
246
+ export type DataOperationStep = 'reconcile' | 'restrict' | 'backup' | 'verify' | 'deploy' | 'migrate' | 'resume' | 'open' | 'list' | 'import' | 'promote' | 'point' | 'serve' | 'rewind' | 'check' | 'revert';
247
+ export type DataOperationState = 'running' | 'succeeded' | 'failed';
248
+ /** What a recovery does after its closed fence: resume the interrupted operation, or open the object. */
249
+ export type DataOperationResolution = 'resume' | 'open';
250
+ /**
251
+ * One operation as `data.read` shows it: an allowlisted projection of Control's record, with identifiers, states,
252
+ * codes and timestamps only. It carries no free text and no content.
253
+ */
254
+ export interface DataOperationDto {
255
+ readonly id: string;
256
+ readonly appId: string;
257
+ readonly env: string;
258
+ readonly kind: DataOperationKind;
259
+ readonly step: DataOperationStep;
260
+ /** The mode the operation requires of the object at its step; a successor publishes its fresh generation in it. */
261
+ readonly targetMode: MaintenanceMode;
262
+ /** The latest generation the operation reserved. */
263
+ readonly generation: number;
264
+ readonly state: DataOperationState;
265
+ /** A code once it failed, never an error message. */
266
+ readonly errorCode: string | null;
267
+ /** An opaque principal id (as `runActor`), never an email or label. */
268
+ readonly actor: string;
269
+ readonly createdAt: number;
270
+ readonly updatedAt: number;
271
+ readonly finishedAt: number | null;
272
+ /** A recovery's interrupted operation, of the same environment; `null` for every other kind. */
273
+ readonly recoversOperationId: string | null;
274
+ /** A recovery's choice after its closed fence; `null` for every other kind. */
275
+ readonly resolution: DataOperationResolution | null;
276
+ /** A `migrate` operation's deploy run; `null` for every other kind. */
277
+ readonly runId: string | null;
278
+ }
279
+ export declare const DATA_OPERATION_MAX_PAGE_SIZE = 100;
280
+ /** One environment's operations, newest first; `before` is the last id of the previous page. */
281
+ export declare const dataOperationListInputSchema: z.ZodObject<{
282
+ appId: z.ZodString;
283
+ env: z.ZodString;
284
+ before: z.ZodOptional<z.ZodString>;
285
+ limit: z.ZodOptional<z.ZodNumber>;
286
+ }, "strict", z.ZodTypeAny, {
287
+ env: string;
288
+ appId: string;
289
+ before?: string | undefined;
290
+ limit?: number | undefined;
291
+ }, {
292
+ env: string;
293
+ appId: string;
294
+ before?: string | undefined;
295
+ limit?: number | undefined;
296
+ }>;
297
+ export type DataOperationListInput = z.infer<typeof dataOperationListInputSchema>;
298
+ /**
299
+ * An operation a person starts. A migration starts inside a deploy and a recovery has its own request, so neither is
300
+ * started here. A restore names the time `at` (ISO 8601 with an offset) its environment's data is recovered as of.
301
+ */
302
+ export declare const startDataOperationInputSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
303
+ appId: z.ZodString;
304
+ env: z.ZodString;
305
+ kind: z.ZodLiteral<"maintenance">;
306
+ mode: z.ZodEnum<["open", "read-only", "closed", "inspect"]>;
307
+ }, "strict", z.ZodTypeAny, {
308
+ env: string;
309
+ kind: "maintenance";
310
+ mode: "open" | "inspect" | "read-only" | "closed";
311
+ appId: string;
312
+ }, {
313
+ env: string;
314
+ kind: "maintenance";
315
+ mode: "open" | "inspect" | "read-only" | "closed";
316
+ appId: string;
317
+ }>, z.ZodObject<{
318
+ appId: z.ZodString;
319
+ env: z.ZodString;
320
+ kind: z.ZodLiteral<"backup">;
321
+ }, "strict", z.ZodTypeAny, {
322
+ env: string;
323
+ kind: "backup";
324
+ appId: string;
325
+ }, {
326
+ env: string;
327
+ kind: "backup";
328
+ appId: string;
329
+ }>, z.ZodObject<{
330
+ appId: z.ZodString;
331
+ env: z.ZodString;
332
+ kind: z.ZodLiteral<"restore">;
333
+ at: z.ZodString;
334
+ }, "strict", z.ZodTypeAny, {
335
+ env: string;
336
+ at: string;
337
+ kind: "restore";
338
+ appId: string;
339
+ }, {
340
+ env: string;
341
+ at: string;
342
+ kind: "restore";
343
+ appId: string;
344
+ }>]>;
345
+ export type StartDataOperationInput = z.infer<typeof startDataOperationInputSchema>;
346
+ /**
347
+ * Recover an environment whose operation `operationId` is stuck: fence it with a fresh generation in `closed`, then
348
+ * resume that operation from its recorded step, or open the object at a new generation.
349
+ */
350
+ export declare const recoverDataOperationInputSchema: z.ZodObject<{
351
+ appId: z.ZodString;
352
+ env: z.ZodString;
353
+ operationId: z.ZodString;
354
+ resolution: z.ZodEnum<["resume", "open"]>;
355
+ }, "strict", z.ZodTypeAny, {
356
+ env: string;
357
+ appId: string;
358
+ operationId: string;
359
+ resolution: "open" | "resume";
360
+ }, {
361
+ env: string;
362
+ appId: string;
363
+ operationId: string;
364
+ resolution: "open" | "resume";
365
+ }>;
366
+ export type RecoverDataOperationInput = z.infer<typeof recoverDataOperationInputSchema>;
367
+ /** `succeeded` only once its rehearsal passed. */
368
+ export type DataBackupState = 'running' | 'succeeded' | 'failed';
369
+ export type DataRehearsalOutcome = 'pending' | 'passed' | 'failed';
370
+ /**
371
+ * One consistent backup as `data.read` shows it: identifiers, states, codes, sizes and timestamps. It carries no free
372
+ * text and no content; downloading a dump is `data.content.read`.
373
+ */
374
+ export interface DataBackupDto {
375
+ /** The backup's record. */
376
+ readonly id: string;
377
+ readonly appId: string;
378
+ readonly env: string;
379
+ /** The `backup` operation that took it. */
380
+ readonly operationId: string;
381
+ /** The object it was taken from. */
382
+ readonly object: string;
383
+ /** The dump's key in the bucket; a resumed backup whose dump started again carries the new one. */
384
+ readonly dumpId: string;
385
+ /** Taken by a deploy's migration phase, not by the daily schedule. */
386
+ readonly preMigration: boolean;
387
+ readonly state: DataBackupState;
388
+ /** A code once it failed, never an error message. */
389
+ readonly errorCode: string | null;
390
+ readonly createdAt: number;
391
+ readonly finishedAt: number | null;
392
+ /** The object's bookmark when the dump began. */
393
+ readonly bookmark: string | null;
394
+ /** Set once the upload completed. */
395
+ readonly sizeBytes: number | null;
396
+ readonly parts: number | null;
397
+ /** How many tables the manifest lists. */
398
+ readonly tables: number | null;
399
+ readonly rehearsal: DataRehearsalOutcome;
400
+ /** The code the rehearsal failed with. */
401
+ readonly rehearsalCode: string | null;
402
+ /** Past its 30-day retention: never offered for a restore. */
403
+ readonly expired: boolean;
404
+ }
405
+ /** Whether the environment takes daily backups: on unless it opted out. Opting out leaves the pre-migration backup. */
406
+ export interface DataBackupScheduleDto {
407
+ readonly appId: string;
408
+ readonly env: string;
409
+ readonly daily: boolean;
410
+ /** When it was last set; `null` while it keeps the default. */
411
+ readonly updatedAt: number | null;
412
+ }
413
+ export interface SetDataBackupScheduleInput extends AppEnvironmentInput {
414
+ readonly daily: boolean;
415
+ }
193
416
  export {};