@anchrd/colab-sdk 0.1.36 → 0.1.38

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.
Files changed (49) hide show
  1. package/dist/actions/actions.d.ts +34 -23
  2. package/dist/actions/actions.js +5 -2
  3. package/dist/archive/archive.d.ts +1 -0
  4. package/dist/archive/archive.js +3 -0
  5. package/dist/boards/boards.d.ts +21 -21
  6. package/dist/columns/columns.d.ts +2 -2
  7. package/dist/connectors/connectors.d.ts +6 -6
  8. package/dist/crawls/crawls.d.ts +3 -3
  9. package/dist/error/error.d.ts +9 -3
  10. package/dist/error/error.js +12 -3
  11. package/dist/gadgets/gadgets.d.ts +147 -9
  12. package/dist/gadgets/gadgets.js +156 -0
  13. package/dist/goals/goals.d.ts +56 -10
  14. package/dist/goals/goals.js +36 -7
  15. package/dist/grammar/grammar.d.ts +2 -0
  16. package/dist/grammar/grammar.js +10 -0
  17. package/dist/home/home.d.ts +312 -0
  18. package/dist/home/home.js +53 -0
  19. package/dist/links/links.d.ts +166 -0
  20. package/dist/links/links.js +149 -0
  21. package/dist/mcps/mcps.d.ts +3 -3
  22. package/dist/messages/messages.d.ts +26 -0
  23. package/dist/messages/messages.js +33 -0
  24. package/dist/nodes/nodes.d.ts +46 -20
  25. package/dist/nodes/nodes.js +11 -3
  26. package/dist/operators/operators.d.ts +737 -47
  27. package/dist/operators/operators.js +388 -71
  28. package/dist/organisation/organisation.d.ts +2 -0
  29. package/dist/organisation/organisation.js +9 -0
  30. package/dist/primitives/primitives.d.ts +9 -0
  31. package/dist/primitives/primitives.js +16 -0
  32. package/dist/roles/roles.d.ts +1 -0
  33. package/dist/roles/roles.js +3 -0
  34. package/dist/runs/runs.d.ts +2 -2
  35. package/dist/sdk.d.ts +12 -11
  36. package/dist/sdk.js +12 -11
  37. package/dist/skills/skills.d.ts +37 -7
  38. package/dist/skills/skills.js +50 -0
  39. package/dist/sources/sources.d.ts +82 -20
  40. package/dist/sources/sources.js +71 -12
  41. package/dist/tables/tables.d.ts +42 -0
  42. package/dist/tables/tables.js +55 -2
  43. package/dist/tool.d.ts +1 -0
  44. package/dist/tree-order/tree-order.d.ts +2 -2
  45. package/dist/tree-order/tree-order.js +1 -1
  46. package/dist/users/users.d.ts +2 -0
  47. package/dist/users/users.js +3 -2
  48. package/dist/versions/versions.d.ts +13 -13
  49. package/package.json +1 -1
@@ -0,0 +1,312 @@
1
+ import { z } from "zod";
2
+ export declare const homeSetupSteps: readonly ["profile", "ai", "operator", "goal", "team", "credential", "signin", "connector"];
3
+ export declare const HomeSetupStep: z.ZodEnum<{
4
+ operator: "operator";
5
+ goal: "goal";
6
+ connector: "connector";
7
+ credential: "credential";
8
+ signin: "signin";
9
+ profile: "profile";
10
+ ai: "ai";
11
+ team: "team";
12
+ }>;
13
+ export type HomeSetupStep = z.infer<typeof HomeSetupStep>;
14
+ export declare const homePersonSteps: ReadonlySet<HomeSetupStep>;
15
+ export declare const homeIncludes: readonly ["setup", "news", "gadget"];
16
+ export declare const HomeGetInput: z.ZodObject<{
17
+ include: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodEnum<{
18
+ gadget: "gadget";
19
+ setup: "setup";
20
+ news: "news";
21
+ }>>, unknown>>;
22
+ }, z.core.$strict>;
23
+ export type HomeGetInput = z.infer<typeof HomeGetInput>;
24
+ export declare const ColabNews: z.ZodObject<{
25
+ version: z.ZodString;
26
+ area: z.ZodString;
27
+ text: z.ZodString;
28
+ ticket: z.ZodNumber;
29
+ }, z.core.$strip>;
30
+ export type ColabNews = z.infer<typeof ColabNews>;
31
+ export declare const HomeSetupState: z.ZodObject<{
32
+ step: z.ZodEnum<{
33
+ operator: "operator";
34
+ goal: "goal";
35
+ connector: "connector";
36
+ credential: "credential";
37
+ signin: "signin";
38
+ profile: "profile";
39
+ ai: "ai";
40
+ team: "team";
41
+ }>;
42
+ scope: z.ZodEnum<{
43
+ organisation: "organisation";
44
+ person: "person";
45
+ }>;
46
+ done: z.ZodBoolean;
47
+ }, z.core.$strip>;
48
+ export type HomeSetupState = z.infer<typeof HomeSetupState>;
49
+ export declare const Home: z.ZodObject<{
50
+ gadgetId: z.ZodNullable<z.ZodString>;
51
+ setup: z.ZodOptional<z.ZodArray<z.ZodObject<{
52
+ step: z.ZodEnum<{
53
+ operator: "operator";
54
+ goal: "goal";
55
+ connector: "connector";
56
+ credential: "credential";
57
+ signin: "signin";
58
+ profile: "profile";
59
+ ai: "ai";
60
+ team: "team";
61
+ }>;
62
+ scope: z.ZodEnum<{
63
+ organisation: "organisation";
64
+ person: "person";
65
+ }>;
66
+ done: z.ZodBoolean;
67
+ }, z.core.$strip>>>;
68
+ news: z.ZodOptional<z.ZodArray<z.ZodObject<{
69
+ version: z.ZodString;
70
+ area: z.ZodString;
71
+ text: z.ZodString;
72
+ ticket: z.ZodNumber;
73
+ }, z.core.$strip>>>;
74
+ gadget: z.ZodOptional<z.ZodNullable<z.ZodObject<{
75
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
76
+ name: z.ZodString;
77
+ hidden: z.ZodBoolean;
78
+ parentId: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
79
+ path: z.ZodObject<{
80
+ section: z.ZodEnum<{
81
+ users: "users";
82
+ own: "own";
83
+ shared: "shared";
84
+ }>;
85
+ items: z.ZodArray<z.ZodObject<{
86
+ nodeId: z.ZodTemplateLiteral<`node_${string}`>;
87
+ name: z.ZodString;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$strip>;
90
+ version: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>>;
91
+ commit: z.ZodNullable<z.ZodString>;
92
+ manifest: z.ZodNullable<z.ZodObject<{
93
+ name: z.ZodString;
94
+ description: z.ZodOptional<z.ZodString>;
95
+ access: z.ZodOptional<z.ZodObject<{
96
+ service: z.ZodTemplateLiteral<`service_${string}`>;
97
+ }, z.core.$strict>>;
98
+ uses: z.ZodOptional<z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodEnum<{
99
+ write: "write";
100
+ read: "read";
101
+ }>>>;
102
+ functions: z.ZodRecord<z.ZodString, z.ZodObject<{
103
+ description: z.ZodString;
104
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
105
+ requires: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strict>>;
107
+ }, z.core.$strict>>;
108
+ files: z.ZodArray<z.ZodObject<{
109
+ path: z.ZodString;
110
+ size: z.ZodNumber;
111
+ content: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$strip>>;
113
+ live: z.ZodNullable<z.ZodObject<{
114
+ version: z.ZodNumber;
115
+ publishedAt: z.ZodISODateTime;
116
+ publishedBy: z.ZodObject<{
117
+ userId: z.ZodString;
118
+ name: z.ZodNullable<z.ZodString>;
119
+ kind: z.ZodNullable<z.ZodEnum<{
120
+ machine: "machine";
121
+ human: "human";
122
+ }>>;
123
+ }, z.core.$strip>;
124
+ }, z.core.$strip>>;
125
+ draft: z.ZodNullable<z.ZodObject<{
126
+ updatedAt: z.ZodISODateTime;
127
+ updatedBy: z.ZodObject<{
128
+ userId: z.ZodString;
129
+ name: z.ZodNullable<z.ZodString>;
130
+ kind: z.ZodNullable<z.ZodEnum<{
131
+ machine: "machine";
132
+ human: "human";
133
+ }>>;
134
+ }, z.core.$strip>;
135
+ changes: z.ZodArray<z.ZodObject<{
136
+ path: z.ZodString;
137
+ change: z.ZodEnum<{
138
+ added: "added";
139
+ changed: "changed";
140
+ removed: "removed";
141
+ }>;
142
+ }, z.core.$strip>>;
143
+ newTools: z.ZodArray<z.ZodString>;
144
+ newUses: z.ZodOptional<z.ZodArray<z.ZodObject<{
145
+ nodeId: z.ZodString;
146
+ name: z.ZodNullable<z.ZodString>;
147
+ right: z.ZodEnum<{
148
+ write: "write";
149
+ read: "read";
150
+ }>;
151
+ }, z.core.$strip>>>;
152
+ }, z.core.$strip>>;
153
+ test: z.ZodNullable<z.ZodObject<{
154
+ version: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>;
155
+ current: z.ZodBoolean;
156
+ status: z.ZodEnum<{
157
+ running: "running";
158
+ failed: "failed";
159
+ passed: "passed";
160
+ }>;
161
+ passed: z.ZodNumber;
162
+ failed: z.ZodNumber;
163
+ at: z.ZodISODateTime;
164
+ by: z.ZodObject<{
165
+ userId: z.ZodString;
166
+ name: z.ZodNullable<z.ZodString>;
167
+ kind: z.ZodNullable<z.ZodEnum<{
168
+ machine: "machine";
169
+ human: "human";
170
+ }>>;
171
+ }, z.core.$strip>;
172
+ durationMs: z.ZodNumber;
173
+ error: z.ZodNullable<z.ZodObject<{
174
+ message: z.ZodString;
175
+ stack: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strip>>;
177
+ tests: z.ZodArray<z.ZodObject<{
178
+ file: z.ZodString;
179
+ path: z.ZodArray<z.ZodString>;
180
+ name: z.ZodString;
181
+ status: z.ZodEnum<{
182
+ failed: "failed";
183
+ passed: "passed";
184
+ }>;
185
+ durationMs: z.ZodNumber;
186
+ message: z.ZodNullable<z.ZodString>;
187
+ location: z.ZodNullable<z.ZodObject<{
188
+ file: z.ZodString;
189
+ line: z.ZodNumber;
190
+ column: z.ZodNumber;
191
+ }, z.core.$strip>>;
192
+ calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
193
+ name: z.ZodString;
194
+ durationMs: z.ZodNumber;
195
+ code: z.ZodNullable<z.ZodEnum<{
196
+ unavailable: "unavailable";
197
+ not_found: "not_found";
198
+ invalid: "invalid";
199
+ conflict: "conflict";
200
+ unauthenticated: "unauthenticated";
201
+ }>>;
202
+ }, z.core.$strip>>>;
203
+ }, z.core.$strip>>;
204
+ hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
205
+ file: z.ZodString;
206
+ durationMs: z.ZodNumber;
207
+ calls: z.ZodArray<z.ZodObject<{
208
+ name: z.ZodString;
209
+ durationMs: z.ZodNumber;
210
+ code: z.ZodNullable<z.ZodEnum<{
211
+ unavailable: "unavailable";
212
+ not_found: "not_found";
213
+ invalid: "invalid";
214
+ conflict: "conflict";
215
+ unauthenticated: "unauthenticated";
216
+ }>>;
217
+ }, z.core.$strip>>;
218
+ }, z.core.$strip>>>;
219
+ note: z.ZodOptional<z.ZodString>;
220
+ limits: z.ZodObject<{
221
+ testMs: z.ZodNumber;
222
+ testTools: z.ZodNumber;
223
+ fileMs: z.ZodNumber;
224
+ fileCpuMs: z.ZodNumber;
225
+ fileMemoryMb: z.ZodNumber;
226
+ filesAtOnce: z.ZodNumber;
227
+ runMs: z.ZodNumber;
228
+ hooksMs: z.ZodNumber;
229
+ hooksTools: z.ZodNumber;
230
+ }, z.core.$strip>;
231
+ }, z.core.$strip>>;
232
+ usage: z.ZodNullable<z.ZodObject<{
233
+ calls: z.ZodNumber;
234
+ errors: z.ZodNumber;
235
+ lastCallAt: z.ZodNullable<z.ZodISODateTime>;
236
+ }, z.core.$strip>>;
237
+ dist: z.ZodOptional<z.ZodNullable<z.ZodObject<{
238
+ bytes: z.ZodNumber;
239
+ gzipBytes: z.ZodNumber;
240
+ startMs: z.ZodNullable<z.ZodNumber>;
241
+ limits: z.ZodObject<{
242
+ bytes: z.ZodNumber;
243
+ startMs: z.ZodNumber;
244
+ }, z.core.$strip>;
245
+ warnings: z.ZodArray<z.ZodString>;
246
+ error: z.ZodNullable<z.ZodString>;
247
+ }, z.core.$strip>>>;
248
+ settings: z.ZodNullable<z.ZodObject<{
249
+ responsible: z.ZodNullable<z.ZodObject<{
250
+ userId: z.ZodString;
251
+ name: z.ZodNullable<z.ZodString>;
252
+ kind: z.ZodNullable<z.ZodEnum<{
253
+ machine: "machine";
254
+ human: "human";
255
+ }>>;
256
+ }, z.core.$strip>>;
257
+ level: z.ZodEnum<{
258
+ publish: "publish";
259
+ draft: "draft";
260
+ report: "report";
261
+ }>;
262
+ logDays: z.ZodNumber;
263
+ }, z.core.$strip>>;
264
+ rights: z.ZodObject<{
265
+ write: z.ZodBoolean;
266
+ }, z.core.$strip>;
267
+ access: z.ZodOptional<z.ZodNullable<z.ZodObject<{
268
+ serviceId: z.ZodString;
269
+ name: z.ZodNullable<z.ZodString>;
270
+ archived: z.ZodBoolean;
271
+ functions: z.ZodArray<z.ZodString>;
272
+ held: z.ZodArray<z.ZodString>;
273
+ }, z.core.$strip>>>;
274
+ uses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
275
+ nodeId: z.ZodString;
276
+ name: z.ZodNullable<z.ZodString>;
277
+ path: z.ZodArray<z.ZodString>;
278
+ right: z.ZodEnum<{
279
+ write: "write";
280
+ read: "read";
281
+ }>;
282
+ missing: z.ZodBoolean;
283
+ own: z.ZodOptional<z.ZodBoolean>;
284
+ }, z.core.$strip>>>>;
285
+ link: z.ZodOptional<z.ZodNullable<z.ZodObject<{
286
+ originalId: z.ZodTemplateLiteral<`node_${string}`>;
287
+ name: z.ZodNullable<z.ZodString>;
288
+ uses: z.ZodRecord<z.ZodString, z.ZodString>;
289
+ }, z.core.$strip>>>;
290
+ links: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
291
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
292
+ name: z.ZodNullable<z.ZodString>;
293
+ }, z.core.$strip>>>>;
294
+ diff: z.ZodOptional<z.ZodNullable<z.ZodObject<{
295
+ from: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>>;
296
+ to: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>>;
297
+ files: z.ZodArray<z.ZodObject<{
298
+ path: z.ZodString;
299
+ change: z.ZodEnum<{
300
+ added: "added";
301
+ changed: "changed";
302
+ removed: "removed";
303
+ }>;
304
+ before: z.ZodNullable<z.ZodString>;
305
+ after: z.ZodNullable<z.ZodString>;
306
+ }, z.core.$strip>>;
307
+ }, z.core.$strip>>>;
308
+ rev: z.ZodNumber;
309
+ archivedAt: z.ZodNullable<z.ZodISODateTime>;
310
+ }, z.core.$strip>>>;
311
+ }, z.core.$strip>;
312
+ export type Home = z.infer<typeof Home>;
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ import { GadgetDetail } from "../gadgets/gadgets.js";
3
+ // The start (#1020, E208, Seiten › Startfläche): what stands under `/` is the live version of a
4
+ // gadget the organisation names. This read gives the page which gadget that is, and the gadget what
5
+ // only Colab knows: the setup steps and Colab's news. Its look lives in the gadget, not here.
6
+ // The fixed steps, in the order a gadget may show them; Colab knows when each is done.
7
+ export const homeSetupSteps = [
8
+ "profile",
9
+ "ai",
10
+ "operator",
11
+ "goal",
12
+ "team",
13
+ "credential",
14
+ "signin",
15
+ "connector",
16
+ ];
17
+ export const HomeSetupStep = z.enum(homeSetupSteps);
18
+ // The four steps of a person; the others hold for the whole installation.
19
+ export const homePersonSteps = new Set([
20
+ "profile",
21
+ "ai",
22
+ "operator",
23
+ "goal",
24
+ ]);
25
+ export const homeIncludes = ["setup", "news", "gadget"];
26
+ // `include` over REST is one comma-separated value (`?include=setup,news`): a query carries text.
27
+ export const HomeGetInput = z.strictObject({
28
+ include: z
29
+ .preprocess((value) => (typeof value === "string" ? value.split(",") : value), z.array(z.enum(homeIncludes)).max(homeIncludes.length))
30
+ .optional()
31
+ .describe("What to add to gadgetId: setup (the fixed setup steps, each done or not), news (Colab's newest changelog lines) and gadget (that gadget's live version with its files, as intelligence_gadget_get answers it, or null where you may not read it or it has none). Left out: none of them."),
32
+ });
33
+ // One line of Colab's changelog: `- Area: what changed (#n).` under `## <version>`.
34
+ export const ColabNews = z.object({
35
+ version: z.string(),
36
+ area: z.string(),
37
+ text: z.string(),
38
+ ticket: z.number().int(),
39
+ });
40
+ export const HomeSetupState = z.object({
41
+ step: HomeSetupStep,
42
+ scope: z.enum(["person", "organisation"]),
43
+ done: z.boolean(),
44
+ });
45
+ export const Home = z.object({
46
+ // The gadget under `/`, null while the organisation names none.
47
+ gadgetId: z.string().nullable(),
48
+ setup: z.array(HomeSetupState).optional(),
49
+ news: z.array(ColabNews).optional(),
50
+ // The start's live version with its files, read with the caller's rights in the same answer, so
51
+ // `/` needs one request (#1020); null without the right or without a live version.
52
+ gadget: GadgetDetail.nullable().optional(),
53
+ });
@@ -74,3 +74,169 @@ export declare const NodeLinkList: z.ZodObject<{
74
74
  nextCursor: z.ZodNullable<z.ZodTemplateLiteral<`link_${string}`>>;
75
75
  }, z.core.$strip>;
76
76
  export type NodeLinkList = z.infer<typeof NodeLinkList>;
77
+ export declare const gadgetLinkLimits: {
78
+ readonly visitorHour: 60;
79
+ readonly linkDay: 2000;
80
+ };
81
+ export declare const gadgetLinkPath = "/l";
82
+ export declare const GadgetLinkCreateInput: z.ZodObject<{
83
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
84
+ name: z.ZodOptional<z.ZodString>;
85
+ kind: z.ZodEnum<{
86
+ link: "link";
87
+ embed: "embed";
88
+ }>;
89
+ opensWith: z.ZodOptional<z.ZodEnum<{
90
+ mail: "mail";
91
+ password: "password";
92
+ }>>;
93
+ functions: z.ZodArray<z.ZodString>;
94
+ expiresInDays: z.ZodOptional<z.ZodNumber>;
95
+ password: z.ZodOptional<z.ZodString>;
96
+ domains: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
+ limits: z.ZodOptional<z.ZodObject<{
98
+ visitorHour: z.ZodOptional<z.ZodNumber>;
99
+ linkDay: z.ZodOptional<z.ZodNumber>;
100
+ }, z.core.$strict>>;
101
+ idempotencyKey: z.ZodString;
102
+ }, z.core.$strict>;
103
+ export type GadgetLinkCreateInput = z.infer<typeof GadgetLinkCreateInput>;
104
+ export declare const GadgetLinkListInput: z.ZodObject<{
105
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
106
+ }, z.core.$strict>;
107
+ export type GadgetLinkListInput = z.infer<typeof GadgetLinkListInput>;
108
+ export declare const GadgetLinkRevokeInput: z.ZodObject<{
109
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
110
+ linkId: z.ZodTemplateLiteral<`link_${string}`>;
111
+ }, z.core.$strict>;
112
+ export type GadgetLinkRevokeInput = z.infer<typeof GadgetLinkRevokeInput>;
113
+ export declare const GadgetLink: z.ZodObject<{
114
+ linkId: z.ZodTemplateLiteral<`link_${string}`>;
115
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
116
+ kind: z.ZodEnum<{
117
+ link: "link";
118
+ embed: "embed";
119
+ }>;
120
+ name: z.ZodString;
121
+ opensWith: z.ZodNullable<z.ZodEnum<{
122
+ mail: "mail";
123
+ password: "password";
124
+ }>>;
125
+ url: z.ZodString;
126
+ functions: z.ZodArray<z.ZodString>;
127
+ domains: z.ZodArray<z.ZodString>;
128
+ password: z.ZodBoolean;
129
+ limits: z.ZodObject<{
130
+ visitorHour: z.ZodNumber;
131
+ linkDay: z.ZodNumber;
132
+ }, z.core.$strip>;
133
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
134
+ status: z.ZodEnum<{
135
+ expired: "expired";
136
+ revoked: "revoked";
137
+ active: "active";
138
+ inactive: "inactive";
139
+ }>;
140
+ calls: z.ZodNumber;
141
+ createdAt: z.ZodISODateTime;
142
+ createdBy: z.ZodObject<{
143
+ userId: z.ZodString;
144
+ name: z.ZodNullable<z.ZodString>;
145
+ }, z.core.$strip>;
146
+ madePassword: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strip>;
148
+ export type GadgetLink = z.infer<typeof GadgetLink>;
149
+ export declare const GadgetLinkList: z.ZodObject<{
150
+ items: z.ZodArray<z.ZodObject<{
151
+ linkId: z.ZodTemplateLiteral<`link_${string}`>;
152
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
153
+ kind: z.ZodEnum<{
154
+ link: "link";
155
+ embed: "embed";
156
+ }>;
157
+ name: z.ZodString;
158
+ opensWith: z.ZodNullable<z.ZodEnum<{
159
+ mail: "mail";
160
+ password: "password";
161
+ }>>;
162
+ url: z.ZodString;
163
+ functions: z.ZodArray<z.ZodString>;
164
+ domains: z.ZodArray<z.ZodString>;
165
+ password: z.ZodBoolean;
166
+ limits: z.ZodObject<{
167
+ visitorHour: z.ZodNumber;
168
+ linkDay: z.ZodNumber;
169
+ }, z.core.$strip>;
170
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
171
+ status: z.ZodEnum<{
172
+ expired: "expired";
173
+ revoked: "revoked";
174
+ active: "active";
175
+ inactive: "inactive";
176
+ }>;
177
+ calls: z.ZodNumber;
178
+ createdAt: z.ZodISODateTime;
179
+ createdBy: z.ZodObject<{
180
+ userId: z.ZodString;
181
+ name: z.ZodNullable<z.ZodString>;
182
+ }, z.core.$strip>;
183
+ madePassword: z.ZodOptional<z.ZodString>;
184
+ }, z.core.$strip>>;
185
+ }, z.core.$strip>;
186
+ export type GadgetLinkList = z.infer<typeof GadgetLinkList>;
187
+ export declare const GadgetLinkCallInput: z.ZodObject<{
188
+ function: z.ZodString;
189
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
190
+ password: z.ZodOptional<z.ZodString>;
191
+ visit: z.ZodOptional<z.ZodString>;
192
+ }, z.core.$strict>;
193
+ export type GadgetLinkCallInput = z.infer<typeof GadgetLinkCallInput>;
194
+ export declare const GadgetLinkVisitInput: z.ZodObject<{
195
+ password: z.ZodOptional<z.ZodString>;
196
+ address: z.ZodOptional<z.ZodEmail>;
197
+ code: z.ZodOptional<z.ZodString>;
198
+ turnstile: z.ZodOptional<z.ZodString>;
199
+ }, z.core.$strict>;
200
+ export type GadgetLinkVisitInput = z.infer<typeof GadgetLinkVisitInput>;
201
+ export declare const GadgetLinkCodeInput: z.ZodObject<{
202
+ address: z.ZodEmail;
203
+ }, z.core.$strict>;
204
+ export type GadgetLinkCodeInput = z.infer<typeof GadgetLinkCodeInput>;
205
+ export declare const GadgetLinkVisit: z.ZodObject<{
206
+ visit: z.ZodString;
207
+ expiresAt: z.ZodISODateTime;
208
+ gadget: z.ZodObject<{
209
+ name: z.ZodString;
210
+ files: z.ZodRecord<z.ZodString, z.ZodString>;
211
+ }, z.core.$strip>;
212
+ viewer: z.ZodObject<{
213
+ kind: z.ZodLiteral<"external">;
214
+ linkId: z.ZodString;
215
+ rights: z.ZodArray<z.ZodString>;
216
+ }, z.core.$strip>;
217
+ }, z.core.$strip>;
218
+ export type GadgetLinkVisit = z.infer<typeof GadgetLinkVisit>;
219
+ export declare const GadgetLinkPage: z.ZodDiscriminatedUnion<[z.ZodObject<{
220
+ status: z.ZodLiteral<"unknown">;
221
+ }, z.core.$strip>, z.ZodObject<{
222
+ status: z.ZodEnum<{
223
+ expired: "expired";
224
+ revoked: "revoked";
225
+ }>;
226
+ gadgetName: z.ZodString;
227
+ linkName: z.ZodString;
228
+ }, z.core.$strip>, z.ZodObject<{
229
+ status: z.ZodLiteral<"active">;
230
+ kind: z.ZodEnum<{
231
+ link: "link";
232
+ embed: "embed";
233
+ }>;
234
+ opensWith: z.ZodNullable<z.ZodEnum<{
235
+ mail: "mail";
236
+ password: "password";
237
+ }>>;
238
+ gadgetName: z.ZodString;
239
+ linkName: z.ZodString;
240
+ domains: z.ZodArray<z.ZodString>;
241
+ }, z.core.$strip>], "status">;
242
+ export type GadgetLinkPage = z.infer<typeof GadgetLinkPage>;
@@ -71,3 +71,152 @@ export const NodeLinkList = z.object({
71
71
  items: z.array(NodeLink),
72
72
  nextCursor: LinkId.nullable(),
73
73
  });
74
+ // A gadget's links for outside visitors (#820, E164): `link` (opened with a password, at most 90
75
+ // days) or `embed` (on allowed domains, without an end). A visitor calls only the checked functions
76
+ // of the gadget's service, with the gadget's own rights (`uses`, #986).
77
+ // The brakes' defaults (E164): calls per visitor and hour, per link and day.
78
+ export const gadgetLinkLimits = { visitorHour: 60, linkDay: 2000 };
79
+ // The path of the door a visitor reaches (`/l/<code>`), its code 12 letters and digits.
80
+ export const gadgetLinkPath = "/l";
81
+ const GadgetLinkFunction = z
82
+ .string()
83
+ .regex(/^[a-z][a-z0-9]*\.[a-z][a-z0-9]*$/)
84
+ .describe("A function of the gadget's service a visitor may call, as interface.function.");
85
+ const GadgetLinkDomain = z
86
+ .string()
87
+ .min(1)
88
+ .max(253)
89
+ .regex(/^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/)
90
+ .describe("A domain the embed may stand on, such as kunde.de or *.kunde.de.");
91
+ const GadgetLinkLimitsInput = z.strictObject({
92
+ visitorHour: z
93
+ .number()
94
+ .int()
95
+ .min(1)
96
+ .max(10_000)
97
+ .optional()
98
+ .describe("Calls per visitor and hour; leaving it out gives 60."),
99
+ linkDay: z
100
+ .number()
101
+ .int()
102
+ .min(1)
103
+ .max(1_000_000)
104
+ .optional()
105
+ .describe("Calls per link and day; leaving it out gives 2,000."),
106
+ });
107
+ const GadgetIdForLink = NodeId.describe("The gadget's id, a `node_…` of kind gadget.");
108
+ export const GadgetLinkCreateInput = z.strictObject({
109
+ gadgetId: GadgetIdForLink,
110
+ name: z
111
+ .string()
112
+ .trim()
113
+ .min(1)
114
+ .max(120)
115
+ .optional()
116
+ .describe("The link's name for the people who share it; leaving it out gives the gadget's name."),
117
+ kind: z
118
+ .enum(["link", "embed"])
119
+ .describe("link: opened with a password or a code by mail, at most 90 days. embed: on the allowed domains only, without an end."),
120
+ opensWith: z
121
+ .enum(["password", "mail"])
122
+ .optional()
123
+ .describe("How a link opens: password (the default) or mail, a code the visitor gets by mail. Not for an embed."),
124
+ functions: z
125
+ .array(GadgetLinkFunction)
126
+ .min(1)
127
+ .max(100)
128
+ .describe("The functions of the gadget's service a visitor may call; everything else is not there."),
129
+ expiresInDays: z
130
+ .number()
131
+ .int()
132
+ .min(1)
133
+ .max(maxLinkDays)
134
+ .optional()
135
+ .describe("A link's days, 1 to 90; leaving it out gives 7. An embed has no end."),
136
+ password: z
137
+ .string()
138
+ .min(8)
139
+ .max(200)
140
+ .optional()
141
+ .describe("The password a visitor opens a link with, stored hashed. Only for a link that opens with a password; leaving it out makes one, shown once in the browser."),
142
+ domains: z
143
+ .array(GadgetLinkDomain)
144
+ .max(50)
145
+ .optional()
146
+ .describe("The domains an embed may stand on; required for kind embed, refused for a link."),
147
+ limits: GadgetLinkLimitsInput.optional().describe("The brakes; leaving them out gives the defaults."),
148
+ idempotencyKey: IdempotencyKey,
149
+ });
150
+ export const GadgetLinkListInput = z.strictObject({ gadgetId: GadgetIdForLink });
151
+ export const GadgetLinkRevokeInput = z.strictObject({ gadgetId: GadgetIdForLink, linkId: LinkId });
152
+ export const GadgetLink = z.object({
153
+ linkId: LinkId,
154
+ gadgetId: NodeId,
155
+ kind: z.enum(["link", "embed"]),
156
+ name: z.string(),
157
+ // How a link opens; null for an embed.
158
+ opensWith: z.enum(["password", "mail"]).nullable(),
159
+ // Derived every time, never stored: `<installation>/l/<code>`.
160
+ url: z.string(),
161
+ functions: z.array(z.string()),
162
+ domains: z.array(z.string()),
163
+ password: z.boolean(),
164
+ limits: z.object({ visitorHour: z.number().int(), linkDay: z.number().int() }),
165
+ // Null for an embed.
166
+ expiresAt: z.iso.datetime().nullable(),
167
+ status: LinkStatus,
168
+ // The calls the link took in the last seven days, counted by its daily brake.
169
+ calls: z.number().int(),
170
+ createdAt: z.iso.datetime(),
171
+ createdBy: z.object({ userId: z.string(), name: z.string().nullable() }),
172
+ // Only in the answer of the create that made it: the password Colab made, shown once.
173
+ madePassword: z.string().optional(),
174
+ });
175
+ export const GadgetLinkList = z.object({ items: z.array(GadgetLink) });
176
+ // What a visitor's call sends to `POST /l/<code>/calls` (#820): the function, its input, and the
177
+ // visit the page opened (or, for a link with a password, the password itself).
178
+ export const GadgetLinkCallInput = z.strictObject({
179
+ function: z.string().min(1).max(64),
180
+ input: z.record(z.string(), z.unknown()).optional(),
181
+ password: z.string().max(200).optional(),
182
+ visit: z.string().max(200).optional(),
183
+ });
184
+ // How the visitor's page opens a link (`POST /l/<code>/visits`, #820, E164): with the password, with
185
+ // the address and the code that came by mail, or for an embed with the token of the bot check.
186
+ export const GadgetLinkVisitInput = z.strictObject({
187
+ password: z.string().max(200).optional(),
188
+ address: z.email().max(254).optional(),
189
+ code: z.string().max(20).optional(),
190
+ turnstile: z.string().max(4096).optional(),
191
+ });
192
+ // A code by mail asked for (`POST /l/<code>/codes`).
193
+ export const GadgetLinkCodeInput = z.strictObject({ address: z.email().max(254) });
194
+ // An opened visit: the token every call sends, until when it holds, and the gadget's interface (its
195
+ // client files only, never `server.js` or its tests).
196
+ export const GadgetLinkVisit = z.object({
197
+ visit: z.string(),
198
+ expiresAt: z.iso.datetime(),
199
+ gadget: z.object({ name: z.string(), files: z.record(z.string(), z.string()) }),
200
+ viewer: z.object({
201
+ kind: z.literal("external"),
202
+ linkId: z.string(),
203
+ rights: z.array(z.string()),
204
+ }),
205
+ });
206
+ // What the page at `/l/<code>` is (#820): which screen it opens with. `unknown` names nothing.
207
+ export const GadgetLinkPage = z.discriminatedUnion("status", [
208
+ z.object({ status: z.literal("unknown") }),
209
+ z.object({
210
+ status: z.enum(["expired", "revoked"]),
211
+ gadgetName: z.string(),
212
+ linkName: z.string(),
213
+ }),
214
+ z.object({
215
+ status: z.literal("active"),
216
+ kind: z.enum(["link", "embed"]),
217
+ opensWith: z.enum(["password", "mail"]).nullable(),
218
+ gadgetName: z.string(),
219
+ linkName: z.string(),
220
+ domains: z.array(z.string()),
221
+ }),
222
+ ]);