ankka-console 0.10.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 +32 -0
- package/dist/auth/oidc.d.ts +64 -0
- package/dist/auth/oidc.js +199 -0
- package/dist/client/control-plane.d.ts +67 -0
- package/dist/client/control-plane.js +208 -0
- package/dist/client/errors.d.ts +26 -0
- package/dist/client/errors.js +59 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +3 -0
- package/dist/client/schemas.d.ts +365 -0
- package/dist/client/schemas.js +221 -0
- package/dist/context.d.ts +83 -0
- package/dist/context.js +156 -0
- package/dist/extensions/render.d.ts +20 -0
- package/dist/extensions/render.js +49 -0
- package/dist/extensions/types.d.ts +44 -0
- package/dist/extensions/types.js +30 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/middleware.d.ts +14 -0
- package/dist/middleware.js +48 -0
- package/dist/options.d.ts +45 -0
- package/dist/options.js +39 -0
- package/dist/routes/auth.callback.d.ts +11 -0
- package/dist/routes/auth.callback.js +43 -0
- package/dist/routes/auth.sign-in.d.ts +11 -0
- package/dist/routes/auth.sign-in.js +29 -0
- package/dist/routes/auth.sign-out.d.ts +19 -0
- package/dist/routes/auth.sign-out.js +37 -0
- package/dist/routes/front.d.ts +41 -0
- package/dist/routes/front.js +25 -0
- package/dist/routes/logs.d.ts +67 -0
- package/dist/routes/logs.js +72 -0
- package/dist/routes/members.d.ts +45 -0
- package/dist/routes/members.js +59 -0
- package/dist/routes/organization-new.d.ts +14 -0
- package/dist/routes/organization-new.js +30 -0
- package/dist/routes/organization.d.ts +43 -0
- package/dist/routes/organization.js +82 -0
- package/dist/routes/project-new.d.ts +27 -0
- package/dist/routes/project-new.js +27 -0
- package/dist/routes/project.d.ts +59 -0
- package/dist/routes/project.js +61 -0
- package/dist/routes/service-apply.d.ts +44 -0
- package/dist/routes/service-apply.js +65 -0
- package/dist/routes/service.d.ts +71 -0
- package/dist/routes/service.js +73 -0
- package/dist/routes/stream.project.d.ts +3 -0
- package/dist/routes/stream.project.js +25 -0
- package/dist/routes/stream.service.d.ts +9 -0
- package/dist/routes/stream.service.js +68 -0
- package/dist/routes/tokens.d.ts +47 -0
- package/dist/routes/tokens.js +50 -0
- package/dist/routes.d.ts +28 -0
- package/dist/routes.js +48 -0
- package/dist/runtime.d.ts +28 -0
- package/dist/runtime.js +77 -0
- package/dist/server/create-console-server.d.ts +33 -0
- package/dist/server/create-console-server.js +203 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +13 -0
- package/dist/server/transport.d.ts +25 -0
- package/dist/server/transport.js +97 -0
- package/dist/session/cookie-store.d.ts +51 -0
- package/dist/session/cookie-store.js +66 -0
- package/dist/session/cookies.d.ts +15 -0
- package/dist/session/cookies.js +33 -0
- package/dist/session/seal.d.ts +12 -0
- package/dist/session/seal.js +38 -0
- package/dist/session/token-cache.d.ts +21 -0
- package/dist/session/token-cache.js +47 -0
- package/dist/session/token-source.d.ts +41 -0
- package/dist/session/token-source.js +63 -0
- package/dist/stream/log-follow.d.ts +18 -0
- package/dist/stream/log-follow.js +40 -0
- package/dist/stream/registry.d.ts +6 -0
- package/dist/stream/registry.js +34 -0
- package/dist/stream/sse.d.ts +14 -0
- package/dist/stream/sse.js +87 -0
- package/dist/styles.css +481 -0
- package/dist/testing/fake-control-plane.d.ts +161 -0
- package/dist/testing/fake-control-plane.js +715 -0
- package/dist/testing/fake-issuer.d.ts +66 -0
- package/dist/testing/fake-issuer.js +303 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/scenarios.d.ts +6 -0
- package/dist/testing/scenarios.js +44 -0
- package/dist/ui/console.d.ts +60 -0
- package/dist/ui/console.js +73 -0
- package/dist/ui/errors.d.ts +6 -0
- package/dist/ui/errors.js +30 -0
- package/dist/ui/refused.d.ts +6 -0
- package/dist/ui/refused.js +12 -0
- package/dist/ui/status.d.ts +5 -0
- package/dist/ui/status.js +23 -0
- package/dist/ui/use-stream.d.ts +59 -0
- package/dist/ui/use-stream.js +67 -0
- package/package.json +79 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control plane's wire types, mirrored from `controlplane-api`'s `descriptors.scala`.
|
|
3
|
+
*
|
|
4
|
+
* Mapping rules, the same everywhere: a Scala `Option` is an optional field (absent or `null`), an
|
|
5
|
+
* `Instant` is an ISO-8601 string, a `LocalDate` is `YYYY-MM-DD`, an enum is its word, and a key this
|
|
6
|
+
* side does not know is dropped on decode, so a newer control plane answers an older console.
|
|
7
|
+
* `console/package/fixtures/control-plane/` holds what the platform's own codecs write for each type,
|
|
8
|
+
* and the package's tests decode every one of them.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/** `Role`'s codec writes the lowercase word. */
|
|
12
|
+
export declare const roleSchema: z.ZodEnum<{
|
|
13
|
+
member: "member";
|
|
14
|
+
owner: "owner";
|
|
15
|
+
}>;
|
|
16
|
+
export type Role = z.infer<typeof roleSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* The words `ServiceLifecycle`'s codec writes today. The schema accepts any string, so a word a newer
|
|
19
|
+
* control plane adds is shown as it is rather than failing the page.
|
|
20
|
+
*/
|
|
21
|
+
export declare const serviceLifecycles: readonly ["NotDeployed", "UpdateInProgress", "Ready", "PartiallyReady", "Unavailable", "Paused", "Failed", "Suspended"];
|
|
22
|
+
export type KnownServiceLifecycle = (typeof serviceLifecycles)[number];
|
|
23
|
+
export declare const serviceLifecycleSchema: z.ZodString;
|
|
24
|
+
export type ServiceLifecycle = KnownServiceLifecycle | (string & {});
|
|
25
|
+
export declare const authDiscoverySchema: z.ZodObject<{
|
|
26
|
+
issuer: z.ZodString;
|
|
27
|
+
clientId: z.ZodString;
|
|
28
|
+
audience: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type AuthDiscovery = z.infer<typeof authDiscoverySchema>;
|
|
31
|
+
export declare const organizationMembershipSchema: z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
role: z.ZodEnum<{
|
|
35
|
+
member: "member";
|
|
36
|
+
owner: "owner";
|
|
37
|
+
}>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type OrganizationMembership = z.infer<typeof organizationMembershipSchema>;
|
|
40
|
+
export declare const whoamiSchema: z.ZodObject<{
|
|
41
|
+
subject: z.ZodString;
|
|
42
|
+
name: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
43
|
+
email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
44
|
+
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
+
platformAdmin: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
organizations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
role: z.ZodEnum<{
|
|
50
|
+
member: "member";
|
|
51
|
+
owner: "owner";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type Whoami = z.infer<typeof whoamiSchema>;
|
|
56
|
+
export declare const quotaSchema: z.ZodObject<{
|
|
57
|
+
projects: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
58
|
+
services: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
59
|
+
instances: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type Quota = z.input<typeof quotaSchema>;
|
|
62
|
+
export declare const usageSchema: z.ZodObject<{
|
|
63
|
+
projects: z.ZodNumber;
|
|
64
|
+
services: z.ZodNumber;
|
|
65
|
+
instances: z.ZodNumber;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type Usage = z.infer<typeof usageSchema>;
|
|
68
|
+
export declare const organizationDetailSchema: z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
disabled: z.ZodDefault<z.ZodBoolean>;
|
|
72
|
+
quota: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
73
|
+
projects: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
74
|
+
services: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
75
|
+
instances: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
76
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
77
|
+
projects: number | undefined;
|
|
78
|
+
services: number | undefined;
|
|
79
|
+
instances: number | undefined;
|
|
80
|
+
} | undefined, {
|
|
81
|
+
projects: number | undefined;
|
|
82
|
+
services: number | undefined;
|
|
83
|
+
instances: number | undefined;
|
|
84
|
+
} | null | undefined>>;
|
|
85
|
+
usage: z.ZodDefault<z.ZodObject<{
|
|
86
|
+
projects: z.ZodNumber;
|
|
87
|
+
services: z.ZodNumber;
|
|
88
|
+
instances: z.ZodNumber;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type OrganizationDetail = z.infer<typeof organizationDetailSchema>;
|
|
92
|
+
export declare const organizationSummarySchema: z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
name: z.ZodString;
|
|
95
|
+
projects: z.ZodNumber;
|
|
96
|
+
disabled: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
role: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
98
|
+
member: "member";
|
|
99
|
+
owner: "owner";
|
|
100
|
+
}>>>, z.ZodTransform<NonNullable<"member" | "owner"> | undefined, "member" | "owner" | null | undefined>>;
|
|
101
|
+
quota: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
102
|
+
projects: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
103
|
+
services: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
104
|
+
instances: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
105
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
106
|
+
projects: number | undefined;
|
|
107
|
+
services: number | undefined;
|
|
108
|
+
instances: number | undefined;
|
|
109
|
+
} | undefined, {
|
|
110
|
+
projects: number | undefined;
|
|
111
|
+
services: number | undefined;
|
|
112
|
+
instances: number | undefined;
|
|
113
|
+
} | null | undefined>>;
|
|
114
|
+
usage: z.ZodDefault<z.ZodObject<{
|
|
115
|
+
projects: z.ZodNumber;
|
|
116
|
+
services: z.ZodNumber;
|
|
117
|
+
instances: z.ZodNumber;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export type OrganizationSummary = z.infer<typeof organizationSummarySchema>;
|
|
121
|
+
export declare const registrySummarySchema: z.ZodObject<{
|
|
122
|
+
server: z.ZodString;
|
|
123
|
+
username: z.ZodString;
|
|
124
|
+
setAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
125
|
+
setBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
export type RegistrySummary = z.infer<typeof registrySummarySchema>;
|
|
128
|
+
export declare const projectDetailSchema: z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
name: z.ZodString;
|
|
131
|
+
organizationId: z.ZodString;
|
|
132
|
+
registry: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
133
|
+
server: z.ZodString;
|
|
134
|
+
username: z.ZodString;
|
|
135
|
+
setAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
136
|
+
setBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
137
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
138
|
+
server: string;
|
|
139
|
+
username: string;
|
|
140
|
+
setAt: string | undefined;
|
|
141
|
+
setBy: string | undefined;
|
|
142
|
+
} | undefined, {
|
|
143
|
+
server: string;
|
|
144
|
+
username: string;
|
|
145
|
+
setAt: string | undefined;
|
|
146
|
+
setBy: string | undefined;
|
|
147
|
+
} | null | undefined>>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
export type ProjectDetail = z.infer<typeof projectDetailSchema>;
|
|
150
|
+
export declare const projectSummarySchema: z.ZodObject<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
name: z.ZodString;
|
|
153
|
+
organizationId: z.ZodString;
|
|
154
|
+
services: z.ZodNumber;
|
|
155
|
+
registry: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
156
|
+
server: z.ZodString;
|
|
157
|
+
username: z.ZodString;
|
|
158
|
+
setAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
159
|
+
setBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
160
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
161
|
+
server: string;
|
|
162
|
+
username: string;
|
|
163
|
+
setAt: string | undefined;
|
|
164
|
+
setBy: string | undefined;
|
|
165
|
+
} | undefined, {
|
|
166
|
+
server: string;
|
|
167
|
+
username: string;
|
|
168
|
+
setAt: string | undefined;
|
|
169
|
+
setBy: string | undefined;
|
|
170
|
+
} | null | undefined>>;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
export type ProjectSummary = z.infer<typeof projectSummarySchema>;
|
|
173
|
+
export declare const serviceStatusSchema: z.ZodObject<{
|
|
174
|
+
name: z.ZodString;
|
|
175
|
+
projectId: z.ZodString;
|
|
176
|
+
lifecycle: z.ZodString;
|
|
177
|
+
generation: z.ZodNumber;
|
|
178
|
+
image: z.ZodString;
|
|
179
|
+
readyInstances: z.ZodNumber;
|
|
180
|
+
desiredInstances: z.ZodNumber;
|
|
181
|
+
detail: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
182
|
+
confirmed: z.ZodDefault<z.ZodBoolean>;
|
|
183
|
+
database: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
184
|
+
hostname: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
185
|
+
exposed: z.ZodDefault<z.ZodBoolean>;
|
|
186
|
+
suspended: z.ZodDefault<z.ZodBoolean>;
|
|
187
|
+
paused: z.ZodDefault<z.ZodBoolean>;
|
|
188
|
+
hosting: z.ZodDefault<z.ZodString>;
|
|
189
|
+
protocol: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
export type ServiceStatus = z.infer<typeof serviceStatusSchema>;
|
|
192
|
+
export declare const historyActorSchema: z.ZodObject<{
|
|
193
|
+
subject: z.ZodString;
|
|
194
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
195
|
+
administrative: z.ZodDefault<z.ZodBoolean>;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
export type HistoryActor = z.infer<typeof historyActorSchema>;
|
|
198
|
+
export declare const historyEntrySchema: z.ZodObject<{
|
|
199
|
+
kind: z.ZodString;
|
|
200
|
+
generation: z.ZodNumber;
|
|
201
|
+
actor: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
202
|
+
subject: z.ZodString;
|
|
203
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
204
|
+
administrative: z.ZodDefault<z.ZodBoolean>;
|
|
205
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
206
|
+
subject: string;
|
|
207
|
+
display: string | undefined;
|
|
208
|
+
administrative: boolean;
|
|
209
|
+
} | undefined, {
|
|
210
|
+
subject: string;
|
|
211
|
+
display: string | undefined;
|
|
212
|
+
administrative: boolean;
|
|
213
|
+
} | null | undefined>>;
|
|
214
|
+
at: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
export type HistoryEntry = z.infer<typeof historyEntrySchema>;
|
|
217
|
+
export declare const instanceLogsSchema: z.ZodObject<{
|
|
218
|
+
instance: z.ZodString;
|
|
219
|
+
output: z.ZodString;
|
|
220
|
+
error: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
221
|
+
}, z.core.$strip>;
|
|
222
|
+
export type InstanceLogs = z.infer<typeof instanceLogsSchema>;
|
|
223
|
+
export declare const logsResponseSchema: z.ZodObject<{
|
|
224
|
+
instances: z.ZodArray<z.ZodObject<{
|
|
225
|
+
instance: z.ZodString;
|
|
226
|
+
output: z.ZodString;
|
|
227
|
+
error: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
228
|
+
}, z.core.$strip>>;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
export type LogsResponse = z.infer<typeof logsResponseSchema>;
|
|
231
|
+
export declare const memberSummarySchema: z.ZodObject<{
|
|
232
|
+
subject: z.ZodString;
|
|
233
|
+
role: z.ZodEnum<{
|
|
234
|
+
member: "member";
|
|
235
|
+
owner: "owner";
|
|
236
|
+
}>;
|
|
237
|
+
email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
238
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
239
|
+
since: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
240
|
+
addedBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
export type MemberSummary = z.infer<typeof memberSummarySchema>;
|
|
243
|
+
export declare const invitationSummarySchema: z.ZodObject<{
|
|
244
|
+
email: z.ZodString;
|
|
245
|
+
role: z.ZodEnum<{
|
|
246
|
+
member: "member";
|
|
247
|
+
owner: "owner";
|
|
248
|
+
}>;
|
|
249
|
+
invitedAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
250
|
+
invitedBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
export type InvitationSummary = z.infer<typeof invitationSummarySchema>;
|
|
253
|
+
export declare const membersResponseSchema: z.ZodObject<{
|
|
254
|
+
members: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
255
|
+
subject: z.ZodString;
|
|
256
|
+
role: z.ZodEnum<{
|
|
257
|
+
member: "member";
|
|
258
|
+
owner: "owner";
|
|
259
|
+
}>;
|
|
260
|
+
email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
261
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
262
|
+
since: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
263
|
+
addedBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
264
|
+
}, z.core.$strip>>>;
|
|
265
|
+
invitations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
266
|
+
email: z.ZodString;
|
|
267
|
+
role: z.ZodEnum<{
|
|
268
|
+
member: "member";
|
|
269
|
+
owner: "owner";
|
|
270
|
+
}>;
|
|
271
|
+
invitedAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
272
|
+
invitedBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
273
|
+
}, z.core.$strip>>>;
|
|
274
|
+
}, z.core.$strip>;
|
|
275
|
+
export type MembersResponse = z.infer<typeof membersResponseSchema>;
|
|
276
|
+
export declare const deployTokenSummarySchema: z.ZodObject<{
|
|
277
|
+
id: z.ZodString;
|
|
278
|
+
label: z.ZodString;
|
|
279
|
+
subject: z.ZodString;
|
|
280
|
+
createdBy: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
281
|
+
createdAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
282
|
+
expiresAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
283
|
+
lastUsed: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
284
|
+
}, z.core.$strip>;
|
|
285
|
+
export type DeployTokenSummary = z.infer<typeof deployTokenSummarySchema>;
|
|
286
|
+
export declare const deployTokenCreatedSchema: z.ZodObject<{
|
|
287
|
+
id: z.ZodString;
|
|
288
|
+
label: z.ZodString;
|
|
289
|
+
secret: z.ZodString;
|
|
290
|
+
subject: z.ZodString;
|
|
291
|
+
expiresAt: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
292
|
+
}, z.core.$strip>;
|
|
293
|
+
export type DeployTokenCreated = z.infer<typeof deployTokenCreatedSchema>;
|
|
294
|
+
export declare const errorBodySchema: z.ZodObject<{
|
|
295
|
+
status: z.ZodNumber;
|
|
296
|
+
error: z.ZodString;
|
|
297
|
+
}, z.core.$strip>;
|
|
298
|
+
export type ErrorBody = z.infer<typeof errorBodySchema>;
|
|
299
|
+
export declare const ownerSchema: z.ZodObject<{
|
|
300
|
+
subject: z.ZodString;
|
|
301
|
+
email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
302
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
303
|
+
}, z.core.$strip>;
|
|
304
|
+
export type Owner = z.input<typeof ownerSchema>;
|
|
305
|
+
export declare const createOrganizationSchema: z.ZodObject<{
|
|
306
|
+
name: z.ZodString;
|
|
307
|
+
owner: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
308
|
+
subject: z.ZodString;
|
|
309
|
+
email: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
310
|
+
display: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | undefined, string | null | undefined>>;
|
|
311
|
+
}, z.core.$strip>>>, z.ZodTransform<{
|
|
312
|
+
subject: string;
|
|
313
|
+
email: string | undefined;
|
|
314
|
+
display: string | undefined;
|
|
315
|
+
} | undefined, {
|
|
316
|
+
subject: string;
|
|
317
|
+
email: string | undefined;
|
|
318
|
+
display: string | undefined;
|
|
319
|
+
} | null | undefined>>;
|
|
320
|
+
}, z.core.$strip>;
|
|
321
|
+
export type CreateOrganization = z.input<typeof createOrganizationSchema>;
|
|
322
|
+
export declare const createProjectSchema: z.ZodObject<{
|
|
323
|
+
name: z.ZodString;
|
|
324
|
+
organizationId: z.ZodString;
|
|
325
|
+
}, z.core.$strip>;
|
|
326
|
+
export type CreateProject = z.input<typeof createProjectSchema>;
|
|
327
|
+
export declare const renameSchema: z.ZodObject<{
|
|
328
|
+
name: z.ZodString;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
export type Rename = z.input<typeof renameSchema>;
|
|
331
|
+
export declare const inviteSchema: z.ZodObject<{
|
|
332
|
+
email: z.ZodString;
|
|
333
|
+
role: z.ZodDefault<z.ZodEnum<{
|
|
334
|
+
member: "member";
|
|
335
|
+
owner: "owner";
|
|
336
|
+
}>>;
|
|
337
|
+
}, z.core.$strip>;
|
|
338
|
+
export type Invite = z.input<typeof inviteSchema>;
|
|
339
|
+
export declare const roleChangeSchema: z.ZodObject<{
|
|
340
|
+
role: z.ZodEnum<{
|
|
341
|
+
member: "member";
|
|
342
|
+
owner: "owner";
|
|
343
|
+
}>;
|
|
344
|
+
}, z.core.$strip>;
|
|
345
|
+
export type RoleChange = z.input<typeof roleChangeSchema>;
|
|
346
|
+
export declare const repairSchema: z.ZodObject<{
|
|
347
|
+
role: z.ZodDefault<z.ZodEnum<{
|
|
348
|
+
member: "member";
|
|
349
|
+
owner: "owner";
|
|
350
|
+
}>>;
|
|
351
|
+
}, z.core.$strip>;
|
|
352
|
+
export type Repair = z.input<typeof repairSchema>;
|
|
353
|
+
export declare const createDeployTokenSchema: z.ZodObject<{
|
|
354
|
+
label: z.ZodString;
|
|
355
|
+
expiresIn: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | undefined, number | null | undefined>>;
|
|
356
|
+
}, z.core.$strip>;
|
|
357
|
+
export type CreateDeployToken = z.input<typeof createDeployTokenSchema>;
|
|
358
|
+
export declare const setRegistrySchema: z.ZodObject<{
|
|
359
|
+
server: z.ZodString;
|
|
360
|
+
username: z.ZodString;
|
|
361
|
+
password: z.ZodString;
|
|
362
|
+
}, z.core.$strip>;
|
|
363
|
+
export type SetRegistry = z.input<typeof setRegistrySchema>;
|
|
364
|
+
/** Every schema by the Scala type's name, as the fixture files name them. */
|
|
365
|
+
export declare const schemasByType: Record<string, z.ZodType>;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control plane's wire types, mirrored from `controlplane-api`'s `descriptors.scala`.
|
|
3
|
+
*
|
|
4
|
+
* Mapping rules, the same everywhere: a Scala `Option` is an optional field (absent or `null`), an
|
|
5
|
+
* `Instant` is an ISO-8601 string, a `LocalDate` is `YYYY-MM-DD`, an enum is its word, and a key this
|
|
6
|
+
* side does not know is dropped on decode, so a newer control plane answers an older console.
|
|
7
|
+
* `console/package/fixtures/control-plane/` holds what the platform's own codecs write for each type,
|
|
8
|
+
* and the package's tests decode every one of them.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
const optional = (schema) => schema.nullish().transform((v) => v ?? undefined);
|
|
12
|
+
/** `Role`'s codec writes the lowercase word. */
|
|
13
|
+
export const roleSchema = z.enum(["owner", "member"]);
|
|
14
|
+
/**
|
|
15
|
+
* The words `ServiceLifecycle`'s codec writes today. The schema accepts any string, so a word a newer
|
|
16
|
+
* control plane adds is shown as it is rather than failing the page.
|
|
17
|
+
*/
|
|
18
|
+
export const serviceLifecycles = [
|
|
19
|
+
"NotDeployed",
|
|
20
|
+
"UpdateInProgress",
|
|
21
|
+
"Ready",
|
|
22
|
+
"PartiallyReady",
|
|
23
|
+
"Unavailable",
|
|
24
|
+
"Paused",
|
|
25
|
+
"Failed",
|
|
26
|
+
"Suspended",
|
|
27
|
+
];
|
|
28
|
+
export const serviceLifecycleSchema = z.string();
|
|
29
|
+
export const authDiscoverySchema = z.object({
|
|
30
|
+
issuer: z.string(),
|
|
31
|
+
clientId: z.string(),
|
|
32
|
+
audience: z.string(),
|
|
33
|
+
});
|
|
34
|
+
export const organizationMembershipSchema = z.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
name: z.string(),
|
|
37
|
+
role: roleSchema,
|
|
38
|
+
});
|
|
39
|
+
export const whoamiSchema = z.object({
|
|
40
|
+
subject: z.string(),
|
|
41
|
+
name: optional(z.string()),
|
|
42
|
+
email: optional(z.string()),
|
|
43
|
+
emailVerified: z.boolean().default(false),
|
|
44
|
+
platformAdmin: z.boolean().default(false),
|
|
45
|
+
organizations: z.array(organizationMembershipSchema).default([]),
|
|
46
|
+
});
|
|
47
|
+
export const quotaSchema = z.object({
|
|
48
|
+
projects: optional(z.number().int()),
|
|
49
|
+
services: optional(z.number().int()),
|
|
50
|
+
instances: optional(z.number().int()),
|
|
51
|
+
});
|
|
52
|
+
export const usageSchema = z.object({
|
|
53
|
+
projects: z.number().int(),
|
|
54
|
+
services: z.number().int(),
|
|
55
|
+
instances: z.number().int(),
|
|
56
|
+
});
|
|
57
|
+
const zeroUsage = { projects: 0, services: 0, instances: 0 };
|
|
58
|
+
export const organizationDetailSchema = z.object({
|
|
59
|
+
id: z.string(),
|
|
60
|
+
name: z.string(),
|
|
61
|
+
disabled: z.boolean().default(false),
|
|
62
|
+
quota: optional(quotaSchema),
|
|
63
|
+
usage: usageSchema.default(zeroUsage),
|
|
64
|
+
});
|
|
65
|
+
export const organizationSummarySchema = z.object({
|
|
66
|
+
id: z.string(),
|
|
67
|
+
name: z.string(),
|
|
68
|
+
projects: z.number().int(),
|
|
69
|
+
disabled: z.boolean().default(false),
|
|
70
|
+
role: optional(roleSchema),
|
|
71
|
+
quota: optional(quotaSchema),
|
|
72
|
+
usage: usageSchema.default(zeroUsage),
|
|
73
|
+
});
|
|
74
|
+
export const registrySummarySchema = z.object({
|
|
75
|
+
server: z.string(),
|
|
76
|
+
username: z.string(),
|
|
77
|
+
setAt: optional(z.string()),
|
|
78
|
+
setBy: optional(z.string()),
|
|
79
|
+
});
|
|
80
|
+
export const projectDetailSchema = z.object({
|
|
81
|
+
id: z.string(),
|
|
82
|
+
name: z.string(),
|
|
83
|
+
organizationId: z.string(),
|
|
84
|
+
registry: optional(registrySummarySchema),
|
|
85
|
+
});
|
|
86
|
+
export const projectSummarySchema = z.object({
|
|
87
|
+
id: z.string(),
|
|
88
|
+
name: z.string(),
|
|
89
|
+
organizationId: z.string(),
|
|
90
|
+
services: z.number().int(),
|
|
91
|
+
registry: optional(registrySummarySchema),
|
|
92
|
+
});
|
|
93
|
+
export const serviceStatusSchema = z.object({
|
|
94
|
+
name: z.string(),
|
|
95
|
+
projectId: z.string(),
|
|
96
|
+
lifecycle: serviceLifecycleSchema,
|
|
97
|
+
generation: z.number().int(),
|
|
98
|
+
image: z.string(),
|
|
99
|
+
readyInstances: z.number().int(),
|
|
100
|
+
desiredInstances: z.number().int(),
|
|
101
|
+
detail: optional(z.string()),
|
|
102
|
+
confirmed: z.boolean().default(true),
|
|
103
|
+
database: optional(z.string()),
|
|
104
|
+
hostname: optional(z.string()),
|
|
105
|
+
exposed: z.boolean().default(false),
|
|
106
|
+
suspended: z.boolean().default(false),
|
|
107
|
+
paused: z.boolean().default(false),
|
|
108
|
+
hosting: z.string().default("embedded"),
|
|
109
|
+
protocol: optional(z.string()),
|
|
110
|
+
});
|
|
111
|
+
export const historyActorSchema = z.object({
|
|
112
|
+
subject: z.string(),
|
|
113
|
+
display: optional(z.string()),
|
|
114
|
+
administrative: z.boolean().default(false),
|
|
115
|
+
});
|
|
116
|
+
export const historyEntrySchema = z.object({
|
|
117
|
+
kind: z.string(),
|
|
118
|
+
generation: z.number().int(),
|
|
119
|
+
actor: optional(historyActorSchema),
|
|
120
|
+
at: optional(z.string()),
|
|
121
|
+
});
|
|
122
|
+
export const instanceLogsSchema = z.object({
|
|
123
|
+
instance: z.string(),
|
|
124
|
+
output: z.string(),
|
|
125
|
+
error: optional(z.string()),
|
|
126
|
+
});
|
|
127
|
+
export const logsResponseSchema = z.object({
|
|
128
|
+
instances: z.array(instanceLogsSchema),
|
|
129
|
+
});
|
|
130
|
+
export const memberSummarySchema = z.object({
|
|
131
|
+
subject: z.string(),
|
|
132
|
+
role: roleSchema,
|
|
133
|
+
email: optional(z.string()),
|
|
134
|
+
display: optional(z.string()),
|
|
135
|
+
since: optional(z.string()),
|
|
136
|
+
addedBy: optional(z.string()),
|
|
137
|
+
});
|
|
138
|
+
export const invitationSummarySchema = z.object({
|
|
139
|
+
email: z.string(),
|
|
140
|
+
role: roleSchema,
|
|
141
|
+
invitedAt: optional(z.string()),
|
|
142
|
+
invitedBy: optional(z.string()),
|
|
143
|
+
});
|
|
144
|
+
export const membersResponseSchema = z.object({
|
|
145
|
+
members: z.array(memberSummarySchema).default([]),
|
|
146
|
+
invitations: z.array(invitationSummarySchema).default([]),
|
|
147
|
+
});
|
|
148
|
+
export const deployTokenSummarySchema = z.object({
|
|
149
|
+
id: z.string(),
|
|
150
|
+
label: z.string(),
|
|
151
|
+
subject: z.string(),
|
|
152
|
+
createdBy: optional(z.string()),
|
|
153
|
+
createdAt: optional(z.string()),
|
|
154
|
+
expiresAt: optional(z.string()),
|
|
155
|
+
lastUsed: optional(z.string()),
|
|
156
|
+
});
|
|
157
|
+
export const deployTokenCreatedSchema = z.object({
|
|
158
|
+
id: z.string(),
|
|
159
|
+
label: z.string(),
|
|
160
|
+
secret: z.string(),
|
|
161
|
+
subject: z.string(),
|
|
162
|
+
expiresAt: optional(z.string()),
|
|
163
|
+
});
|
|
164
|
+
export const errorBodySchema = z.object({
|
|
165
|
+
status: z.number().int(),
|
|
166
|
+
error: z.string(),
|
|
167
|
+
});
|
|
168
|
+
// ── Request bodies ──────────────────────────────────────────────────────────
|
|
169
|
+
export const ownerSchema = z.object({
|
|
170
|
+
subject: z.string(),
|
|
171
|
+
email: optional(z.string()),
|
|
172
|
+
display: optional(z.string()),
|
|
173
|
+
});
|
|
174
|
+
export const createOrganizationSchema = z.object({ name: z.string(), owner: optional(ownerSchema) });
|
|
175
|
+
export const createProjectSchema = z.object({ name: z.string(), organizationId: z.string() });
|
|
176
|
+
export const renameSchema = z.object({ name: z.string() });
|
|
177
|
+
export const inviteSchema = z.object({ email: z.string(), role: roleSchema.default("member") });
|
|
178
|
+
export const roleChangeSchema = z.object({ role: roleSchema });
|
|
179
|
+
export const repairSchema = z.object({ role: roleSchema.default("owner") });
|
|
180
|
+
export const createDeployTokenSchema = z.object({
|
|
181
|
+
label: z.string(),
|
|
182
|
+
expiresIn: optional(z.number().int()),
|
|
183
|
+
});
|
|
184
|
+
export const setRegistrySchema = z.object({
|
|
185
|
+
server: z.string(),
|
|
186
|
+
username: z.string(),
|
|
187
|
+
password: z.string(),
|
|
188
|
+
});
|
|
189
|
+
/** Every schema by the Scala type's name, as the fixture files name them. */
|
|
190
|
+
export const schemasByType = {
|
|
191
|
+
AuthDiscovery: authDiscoverySchema,
|
|
192
|
+
OrganizationMembership: organizationMembershipSchema,
|
|
193
|
+
Whoami: whoamiSchema,
|
|
194
|
+
Quota: quotaSchema,
|
|
195
|
+
Usage: usageSchema,
|
|
196
|
+
OrganizationDetail: organizationDetailSchema,
|
|
197
|
+
OrganizationSummary: organizationSummarySchema,
|
|
198
|
+
RegistrySummary: registrySummarySchema,
|
|
199
|
+
ProjectDetail: projectDetailSchema,
|
|
200
|
+
ProjectSummary: projectSummarySchema,
|
|
201
|
+
ServiceStatus: serviceStatusSchema,
|
|
202
|
+
HistoryActor: historyActorSchema,
|
|
203
|
+
HistoryEntry: historyEntrySchema,
|
|
204
|
+
InstanceLogs: instanceLogsSchema,
|
|
205
|
+
LogsResponse: logsResponseSchema,
|
|
206
|
+
MemberSummary: memberSummarySchema,
|
|
207
|
+
InvitationSummary: invitationSummarySchema,
|
|
208
|
+
MembersResponse: membersResponseSchema,
|
|
209
|
+
DeployTokenSummary: deployTokenSummarySchema,
|
|
210
|
+
DeployTokenCreated: deployTokenCreatedSchema,
|
|
211
|
+
ErrorBody: errorBodySchema,
|
|
212
|
+
Owner: ownerSchema,
|
|
213
|
+
CreateOrganization: createOrganizationSchema,
|
|
214
|
+
CreateProject: createProjectSchema,
|
|
215
|
+
Rename: renameSchema,
|
|
216
|
+
Invite: inviteSchema,
|
|
217
|
+
RoleChange: roleChangeSchema,
|
|
218
|
+
Repair: repairSchema,
|
|
219
|
+
CreateDeployToken: createDeployTokenSchema,
|
|
220
|
+
SetRegistry: setRegistrySchema,
|
|
221
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every package route receives about the request it is serving: a control plane client that
|
|
3
|
+
* acts as the signed-in person, where the package is mounted, and how to send someone to sign in.
|
|
4
|
+
*/
|
|
5
|
+
import { data, type RouterContextProvider } from "react-router";
|
|
6
|
+
import { ControlPlaneClient } from "./client/control-plane.ts";
|
|
7
|
+
import type { ConsoleRuntime } from "./runtime.ts";
|
|
8
|
+
import type { ConsoleExtensions, Operation } from "./extensions/types.ts";
|
|
9
|
+
export interface Principal {
|
|
10
|
+
subject: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
platformAdmin: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ConsoleContext {
|
|
16
|
+
runtime: ConsoleRuntime;
|
|
17
|
+
request: Request;
|
|
18
|
+
client: ControlPlaneClient;
|
|
19
|
+
/** Where a changed session is written; the middleware appends it to whatever response is sent. */
|
|
20
|
+
headers: Headers;
|
|
21
|
+
mount: string;
|
|
22
|
+
extensions: ConsoleExtensions;
|
|
23
|
+
/** A path under the mount: `href("organizations/acme")`. */
|
|
24
|
+
href(path?: string): string;
|
|
25
|
+
signInUrl(returnTo?: string): string;
|
|
26
|
+
accessToken(): Promise<string | null>;
|
|
27
|
+
principal(): Promise<Principal | null>;
|
|
28
|
+
/** The principal if this request has already obtained a token; never causes a call of its own. */
|
|
29
|
+
knownPrincipal(): Principal | null;
|
|
30
|
+
}
|
|
31
|
+
export declare const consoleContext: import("react-router").RouterContext<ConsoleContext>;
|
|
32
|
+
/** The context the console's middleware put on this request; a clear error if the host did not install it. */
|
|
33
|
+
export declare function useConsoleContext(context: Readonly<RouterContextProvider>): ConsoleContext;
|
|
34
|
+
export declare function principalOf(token: string | null): Principal | null;
|
|
35
|
+
/** Only a path within the console is ever returned to after sign-in; anything else lands on the front page. */
|
|
36
|
+
export declare function safeReturnTo(runtime: ConsoleRuntime, value: string | null | undefined): string;
|
|
37
|
+
export declare function createConsoleContext(runtime: ConsoleRuntime, request: Request): ConsoleContext;
|
|
38
|
+
/** A failure a page shows rather than crashes on, as its error boundary receives it. */
|
|
39
|
+
export type ConsoleFailure = {
|
|
40
|
+
kind: "lost";
|
|
41
|
+
reason: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "refused";
|
|
44
|
+
status: number;
|
|
45
|
+
reason: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "unavailable";
|
|
48
|
+
what: "identity provider" | "control plane";
|
|
49
|
+
reason: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Runs a loader's or action's work, turning what the person should see into responses: sign in
|
|
53
|
+
* again, access lost, a refusal, something unavailable. Anything else is a bug and propagates.
|
|
54
|
+
*/
|
|
55
|
+
export declare function guard<T>(ctx: ConsoleContext, work: () => Promise<T>): Promise<T>;
|
|
56
|
+
export declare function failureResponse(ctx: ConsoleContext, e: unknown): unknown;
|
|
57
|
+
/** What an action answers when the control plane refused it: shown beside the form, values kept. */
|
|
58
|
+
export interface ActionRefusal {
|
|
59
|
+
intent: string;
|
|
60
|
+
status: number;
|
|
61
|
+
reason: string;
|
|
62
|
+
problems: string[];
|
|
63
|
+
values: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Runs an action's work. A refusal the person can act on — a `400`, `403` or `409` — comes back as
|
|
67
|
+
* data for the page, with the form's values, so the form is shown again with the reason beside it.
|
|
68
|
+
* Everything else is what `guard` makes of it.
|
|
69
|
+
*/
|
|
70
|
+
export declare function act<T>(ctx: ConsoleContext, intent: string, form: FormData, work: () => Promise<T>): Promise<T | ReturnType<typeof data<ActionRefusal>>>;
|
|
71
|
+
export declare const text: (form: FormData, name: string) => string;
|
|
72
|
+
/** What every package page's loader data carries for the pages and the host's layout. */
|
|
73
|
+
export interface ConsolePageData {
|
|
74
|
+
mount: string;
|
|
75
|
+
principal: Principal | null;
|
|
76
|
+
hidden: Operation[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The page data every package page returns. It is also what makes a page require a session: nobody
|
|
80
|
+
* signed in is `SignInRequired`, which `guard` turns into the trip to sign in, even for a page whose
|
|
81
|
+
* loader asks the control plane nothing.
|
|
82
|
+
*/
|
|
83
|
+
export declare function pageData(ctx: ConsoleContext): Promise<ConsolePageData>;
|