@anchrd/colab-sdk 0.0.0-stage → 0.1.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 +65 -2
- package/dist/actions/actions.d.ts +810 -0
- package/dist/actions/actions.js +177 -0
- package/dist/admin-mode.d.ts +2 -0
- package/dist/admin-mode.js +5 -0
- package/dist/apps/apps.d.ts +108 -0
- package/dist/apps/apps.js +73 -0
- package/dist/archive/archive.d.ts +25 -0
- package/dist/archive/archive.js +27 -0
- package/dist/auth/auth.d.ts +27 -0
- package/dist/auth/auth.js +22 -0
- package/dist/authorization/authorization.d.ts +36 -0
- package/dist/authorization/authorization.js +23 -0
- package/dist/boards/boards.d.ts +612 -0
- package/dist/boards/boards.js +289 -0
- package/dist/columns/columns.d.ts +28 -0
- package/dist/columns/columns.js +28 -0
- package/dist/connections/connections.d.ts +149 -0
- package/dist/connections/connections.js +74 -0
- package/dist/connectors/connectors.d.ts +148 -0
- package/dist/connectors/connectors.js +83 -0
- package/dist/dashboards/dashboards.d.ts +221 -0
- package/dist/dashboards/dashboards.js +520 -0
- package/dist/directory/directory.d.ts +20 -0
- package/dist/directory/directory.js +18 -0
- package/dist/documents/documents.d.ts +61 -0
- package/dist/documents/documents.js +58 -0
- package/dist/error/error.d.ts +34 -0
- package/dist/error/error.js +30 -0
- package/dist/events/events.d.ts +104 -0
- package/dist/events/events.js +69 -0
- package/dist/files/files.d.ts +60 -0
- package/dist/files/files.js +139 -0
- package/dist/functions/functions.d.ts +26 -0
- package/dist/functions/functions.js +28 -0
- package/dist/grammar/grammar.d.ts +62 -0
- package/dist/grammar/grammar.js +197 -0
- package/dist/grants/grants.d.ts +93 -0
- package/dist/grants/grants.js +66 -0
- package/dist/ids/ids.d.ts +5 -0
- package/dist/ids/ids.js +12 -0
- package/dist/instructions/instructions.d.ts +19 -0
- package/dist/instructions/instructions.js +35 -0
- package/dist/interfaces/interfaces.d.ts +41 -0
- package/dist/interfaces/interfaces.js +52 -0
- package/dist/invitations/invitations.d.ts +98 -0
- package/dist/invitations/invitations.js +58 -0
- package/dist/links/links.d.ts +76 -0
- package/dist/links/links.js +73 -0
- package/dist/list-input.d.ts +3 -0
- package/dist/list-input.js +11 -0
- package/dist/machines/machines.d.ts +69 -0
- package/dist/machines/machines.js +39 -0
- package/dist/messages/messages.d.ts +117 -0
- package/dist/messages/messages.js +77 -0
- package/dist/nodes/nodes.d.ts +673 -0
- package/dist/nodes/nodes.js +354 -0
- package/dist/operators/operators.d.ts +898 -0
- package/dist/operators/operators.js +398 -0
- package/dist/pages/pages.d.ts +89 -0
- package/dist/pages/pages.js +62 -0
- package/dist/primitives/primitives.d.ts +5 -0
- package/dist/primitives/primitives.js +19 -0
- package/dist/profile/profile.d.ts +37 -0
- package/dist/profile/profile.js +43 -0
- package/dist/roles/roles.d.ts +135 -0
- package/dist/roles/roles.js +87 -0
- package/dist/runs/runs.d.ts +244 -0
- package/dist/runs/runs.js +137 -0
- package/dist/runtime-config.d.ts +12 -0
- package/dist/runtime-config.js +18 -0
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.js +48 -0
- package/dist/secrets/secrets.d.ts +65 -0
- package/dist/secrets/secrets.js +57 -0
- package/dist/service-client/service-client.d.ts +35 -0
- package/dist/service-client/service-client.js +90 -0
- package/dist/services/services.d.ts +122 -0
- package/dist/services/services.js +89 -0
- package/dist/sso/sso.d.ts +70 -0
- package/dist/sso/sso.js +54 -0
- package/dist/tables/tables.d.ts +133 -0
- package/dist/tables/tables.js +131 -0
- package/dist/tool.d.ts +31 -0
- package/dist/tool.js +4 -0
- package/dist/user-settings/user-settings.d.ts +44 -0
- package/dist/user-settings/user-settings.js +44 -0
- package/dist/users/users.d.ts +254 -0
- package/dist/users/users.js +125 -0
- package/dist/validation/validation.d.ts +106 -0
- package/dist/validation/validation.js +41 -0
- package/dist/versions/versions.d.ts +100 -0
- package/dist/versions/versions.js +70 -0
- package/package.json +27 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Instructions } from "../instructions/instructions.js";
|
|
3
|
+
import { NodeId, NodePath, NodePerson, SecretFields } from "../nodes/nodes.js";
|
|
4
|
+
import { IdempotencyKey, Rev } from "../primitives/primitives.js";
|
|
5
|
+
// Documents (#39, Nodes › Dokument, E36, E59): the inputs of `intelligence_document_create`, `_get`
|
|
6
|
+
// and `_update`, and their answer. A document is Markdown and is stored as Markdown, never as editor
|
|
7
|
+
// JSON; a front matter at its top is part of the text. Every save is a version (#38) and sends the
|
|
8
|
+
// node's `rev`.
|
|
9
|
+
const DocumentId = NodeId.describe("The document's id, a `node_…` of kind document.");
|
|
10
|
+
// The text of a document. Up to 1 MB in UTF-8 (`maxContentBytes` of #38).
|
|
11
|
+
const Content = z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("The whole document as Markdown, at most 1 MB in UTF-8. A front matter at the top stays as written. Images only by URL, links to other nodes in the text (`[Name](/n/node_…)`).");
|
|
14
|
+
export const DocumentCreateInput = z.strictObject({
|
|
15
|
+
parentId: NodeId.describe("The folder to create the document in, one you can write to."),
|
|
16
|
+
name: z
|
|
17
|
+
.string()
|
|
18
|
+
.max(200)
|
|
19
|
+
.describe("The name as people read it. A name that starts with a dot hides it from listings. `INSTRUCTIONS` or `.INSTRUCTIONS` makes it the folder's INSTRUCTIONS; a folder holds at most one."),
|
|
20
|
+
// Required, and empty is a value: an empty document is created with an empty first version.
|
|
21
|
+
content: Content,
|
|
22
|
+
idempotencyKey: IdempotencyKey,
|
|
23
|
+
});
|
|
24
|
+
export const DocumentGetInput = z.strictObject({ documentId: DocumentId });
|
|
25
|
+
export const DocumentUpdateInput = z.strictObject({
|
|
26
|
+
documentId: DocumentId,
|
|
27
|
+
content: Content,
|
|
28
|
+
rev: Rev,
|
|
29
|
+
editSession: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.max(100)
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("The editing session the editor keeps while a person stays on the document: saves of one session go into one version. Leaving it out makes every save a version of its own, which is right for an AI."),
|
|
35
|
+
});
|
|
36
|
+
export const DocumentDetail = z.strictObject({
|
|
37
|
+
documentId: DocumentId,
|
|
38
|
+
name: z.string(),
|
|
39
|
+
hidden: z.boolean(),
|
|
40
|
+
// Null at the top level of Shared, and where the caller cannot read the parent.
|
|
41
|
+
parentId: NodeId.nullable(),
|
|
42
|
+
path: NodePath,
|
|
43
|
+
content: z.string(),
|
|
44
|
+
// The current version's number, as people read it ("Version 6"); null for a document without one.
|
|
45
|
+
version: z.number().int().nullable(),
|
|
46
|
+
// When the current version was last saved into, and who began it; null without a version.
|
|
47
|
+
savedAt: z.iso.datetime().nullable(),
|
|
48
|
+
savedBy: NodePerson.nullable(),
|
|
49
|
+
// The OAuth client the current version was written through, null in the browser.
|
|
50
|
+
appHandle: z.string().nullable(),
|
|
51
|
+
// The state the next save sends (E70).
|
|
52
|
+
rev: z.number().int(),
|
|
53
|
+
archivedAt: z.iso.datetime().nullable(),
|
|
54
|
+
// Over MCP only, the INSTRUCTIONS of the document's folder (#39).
|
|
55
|
+
instructions: Instructions.optional(),
|
|
56
|
+
// A secret document (#357): `content` is empty while it is `locked` for this caller.
|
|
57
|
+
...SecretFields,
|
|
58
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const errorCodes: readonly ["not_found", "invalid", "conflict", "unauthenticated", "unavailable"];
|
|
3
|
+
export declare const ErrorCode: z.ZodEnum<{
|
|
4
|
+
unavailable: "unavailable";
|
|
5
|
+
not_found: "not_found";
|
|
6
|
+
invalid: "invalid";
|
|
7
|
+
conflict: "conflict";
|
|
8
|
+
unauthenticated: "unauthenticated";
|
|
9
|
+
}>;
|
|
10
|
+
export type ErrorCode = z.infer<typeof ErrorCode>;
|
|
11
|
+
export declare const ErrorIssue: z.ZodObject<{
|
|
12
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
13
|
+
message: z.ZodString;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type ErrorIssue = z.infer<typeof ErrorIssue>;
|
|
16
|
+
export declare const ErrorResponse: z.ZodObject<{
|
|
17
|
+
error: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
code: z.ZodLiteral<"invalid">;
|
|
19
|
+
message: z.ZodString;
|
|
20
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
22
|
+
message: z.ZodString;
|
|
23
|
+
}, z.core.$strict>>>;
|
|
24
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
25
|
+
code: z.ZodEnum<{
|
|
26
|
+
unavailable: "unavailable";
|
|
27
|
+
not_found: "not_found";
|
|
28
|
+
conflict: "conflict";
|
|
29
|
+
unauthenticated: "unauthenticated";
|
|
30
|
+
}>;
|
|
31
|
+
message: z.ZodString;
|
|
32
|
+
}, z.core.$strict>], "code">;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type ErrorResponse = z.infer<typeof ErrorResponse>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// The one error shape of API and MCP (E68, E70). Missing rights answer `not_found`, never a code of
|
|
3
|
+
// their own: a caller must not learn that something exists which it may not see.
|
|
4
|
+
export const errorCodes = [
|
|
5
|
+
"not_found",
|
|
6
|
+
"invalid",
|
|
7
|
+
"conflict",
|
|
8
|
+
"unauthenticated",
|
|
9
|
+
"unavailable",
|
|
10
|
+
];
|
|
11
|
+
export const ErrorCode = z.enum(errorCodes);
|
|
12
|
+
// One entry per rejected field: where, and a sentence why.
|
|
13
|
+
export const ErrorIssue = z.strictObject({
|
|
14
|
+
path: z.array(z.union([z.string(), z.number()])),
|
|
15
|
+
message: z.string(),
|
|
16
|
+
});
|
|
17
|
+
// `issues` exists only next to `invalid`; on every other code a strict object rejects it.
|
|
18
|
+
export const ErrorResponse = z.strictObject({
|
|
19
|
+
error: z.discriminatedUnion("code", [
|
|
20
|
+
z.strictObject({
|
|
21
|
+
code: z.literal("invalid"),
|
|
22
|
+
message: z.string(),
|
|
23
|
+
issues: z.array(ErrorIssue).optional(),
|
|
24
|
+
}),
|
|
25
|
+
z.strictObject({
|
|
26
|
+
code: ErrorCode.exclude(["invalid"]),
|
|
27
|
+
message: z.string(),
|
|
28
|
+
}),
|
|
29
|
+
]),
|
|
30
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const EventId: z.ZodTemplateLiteral<`event_${string}`>;
|
|
3
|
+
export declare const EventKind: z.ZodEnum<{
|
|
4
|
+
app: "app";
|
|
5
|
+
connector: "connector";
|
|
6
|
+
change: "change";
|
|
7
|
+
signin: "signin";
|
|
8
|
+
}>;
|
|
9
|
+
export type EventKind = z.infer<typeof EventKind>;
|
|
10
|
+
export declare const ActorKind: z.ZodEnum<{
|
|
11
|
+
machine: "machine";
|
|
12
|
+
service: "service";
|
|
13
|
+
human: "human";
|
|
14
|
+
}>;
|
|
15
|
+
export type ActorKind = z.infer<typeof ActorKind>;
|
|
16
|
+
export declare const EventListInput: z.ZodObject<{
|
|
17
|
+
actorId: z.ZodOptional<z.ZodUnion<readonly [z.ZodTemplateLiteral<`user_${string}`>, z.ZodTemplateLiteral<`service_${string}`>]>>;
|
|
18
|
+
actorKind: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
machine: "machine";
|
|
20
|
+
human: "human";
|
|
21
|
+
}>>;
|
|
22
|
+
userId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
|
|
23
|
+
kind: z.ZodOptional<z.ZodPreprocess<z.ZodUnion<readonly [z.ZodEnum<{
|
|
24
|
+
app: "app";
|
|
25
|
+
connector: "connector";
|
|
26
|
+
change: "change";
|
|
27
|
+
signin: "signin";
|
|
28
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
29
|
+
app: "app";
|
|
30
|
+
connector: "connector";
|
|
31
|
+
change: "change";
|
|
32
|
+
signin: "signin";
|
|
33
|
+
}>>]>, unknown>>;
|
|
34
|
+
search: z.ZodOptional<z.ZodString>;
|
|
35
|
+
failed: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean, unknown>>;
|
|
36
|
+
from: z.ZodOptional<z.ZodISODateTime>;
|
|
37
|
+
to: z.ZodOptional<z.ZodISODateTime>;
|
|
38
|
+
cursor: z.ZodOptional<z.ZodTemplateLiteral<`event_${string}`>>;
|
|
39
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type EventListInput = z.infer<typeof EventListInput>;
|
|
42
|
+
export declare const Event: z.ZodObject<{
|
|
43
|
+
eventId: z.ZodTemplateLiteral<`event_${string}`>;
|
|
44
|
+
createdAt: z.ZodISODateTime;
|
|
45
|
+
action: z.ZodString;
|
|
46
|
+
kind: z.ZodEnum<{
|
|
47
|
+
app: "app";
|
|
48
|
+
connector: "connector";
|
|
49
|
+
change: "change";
|
|
50
|
+
signin: "signin";
|
|
51
|
+
}>;
|
|
52
|
+
target: z.ZodNullable<z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
name: z.ZodNullable<z.ZodString>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
actor: z.ZodNullable<z.ZodObject<{
|
|
57
|
+
userId: z.ZodString;
|
|
58
|
+
name: z.ZodNullable<z.ZodString>;
|
|
59
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
60
|
+
machine: "machine";
|
|
61
|
+
service: "service";
|
|
62
|
+
human: "human";
|
|
63
|
+
}>>;
|
|
64
|
+
image: z.ZodNullable<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
failed: z.ZodBoolean;
|
|
67
|
+
code: z.ZodNullable<z.ZodString>;
|
|
68
|
+
ip: z.ZodNullable<z.ZodString>;
|
|
69
|
+
detail: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
export type Event = z.infer<typeof Event>;
|
|
72
|
+
export declare const EventList: z.ZodObject<{
|
|
73
|
+
items: z.ZodArray<z.ZodObject<{
|
|
74
|
+
eventId: z.ZodTemplateLiteral<`event_${string}`>;
|
|
75
|
+
createdAt: z.ZodISODateTime;
|
|
76
|
+
action: z.ZodString;
|
|
77
|
+
kind: z.ZodEnum<{
|
|
78
|
+
app: "app";
|
|
79
|
+
connector: "connector";
|
|
80
|
+
change: "change";
|
|
81
|
+
signin: "signin";
|
|
82
|
+
}>;
|
|
83
|
+
target: z.ZodNullable<z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
name: z.ZodNullable<z.ZodString>;
|
|
86
|
+
}, z.core.$strict>>;
|
|
87
|
+
actor: z.ZodNullable<z.ZodObject<{
|
|
88
|
+
userId: z.ZodString;
|
|
89
|
+
name: z.ZodNullable<z.ZodString>;
|
|
90
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
91
|
+
machine: "machine";
|
|
92
|
+
service: "service";
|
|
93
|
+
human: "human";
|
|
94
|
+
}>>;
|
|
95
|
+
image: z.ZodNullable<z.ZodString>;
|
|
96
|
+
}, z.core.$strict>>;
|
|
97
|
+
failed: z.ZodBoolean;
|
|
98
|
+
code: z.ZodNullable<z.ZodString>;
|
|
99
|
+
ip: z.ZodNullable<z.ZodString>;
|
|
100
|
+
detail: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
101
|
+
}, z.core.$strict>>;
|
|
102
|
+
nextCursor: z.ZodNullable<z.ZodTemplateLiteral<`event_${string}`>>;
|
|
103
|
+
}, z.core.$strict>;
|
|
104
|
+
export type EventList = z.infer<typeof EventList>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idSchema } from "../ids/ids.js";
|
|
3
|
+
import { Flag, Limit } from "../list-input.js";
|
|
4
|
+
import { ServiceId } from "../services/services.js";
|
|
5
|
+
import { UserId, UserKind } from "../users/users.js";
|
|
6
|
+
// The protocol (Einstellungen › Protokoll, Nutzer › Person › Protokoll, #28): the input of
|
|
7
|
+
// `access_event_list` and its answer. Only who may do what and who comes in; what happens to nodes
|
|
8
|
+
// is not here.
|
|
9
|
+
export const EventId = idSchema("event");
|
|
10
|
+
// The filter "Art": changes to people, roles, services and connectors' settings, sign-ins (only the
|
|
11
|
+
// failed ones are booked), connected apps and sessions, connectors.
|
|
12
|
+
export const EventKind = z.enum(["change", "signin", "app", "connector"]);
|
|
13
|
+
// Who did it: a person or a machine, or an outside service that declared its own interfaces under
|
|
14
|
+
// `/auth/service` (#178).
|
|
15
|
+
export const ActorKind = z.enum([...UserKind.options, "service"]);
|
|
16
|
+
export const EventListInput = z.strictObject({
|
|
17
|
+
// Who did it: a user, or a service for what it declared itself (#178).
|
|
18
|
+
actorId: z.union([UserId, ServiceId]).optional(),
|
|
19
|
+
// What did it: a person or a machine. An event without an actor (a failed sign-in, what Colab does
|
|
20
|
+
// itself) is neither.
|
|
21
|
+
actorKind: UserKind.optional(),
|
|
22
|
+
// One person's protocol: the events this user did OR that were done to them.
|
|
23
|
+
userId: UserId.optional(),
|
|
24
|
+
// One kind or several (#125). Over REST one comma-separated value (`?kind=change,app`): a query
|
|
25
|
+
// string carries text.
|
|
26
|
+
kind: z
|
|
27
|
+
.preprocess((value) => (typeof value === "string" && value.includes(",") ? value.split(",") : value), z.union([EventKind, z.array(EventKind).min(1).max(EventKind.options.length)]))
|
|
28
|
+
.optional(),
|
|
29
|
+
// Part of the action, the target's or the actor's name, case-insensitive.
|
|
30
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
31
|
+
// Only the failed events, or only the others.
|
|
32
|
+
failed: Flag.optional(),
|
|
33
|
+
// The time range: `from` inclusive, `to` exclusive.
|
|
34
|
+
from: z.iso.datetime().optional(),
|
|
35
|
+
to: z.iso.datetime().optional(),
|
|
36
|
+
// The last event of the page before; the list runs newest first.
|
|
37
|
+
cursor: EventId.optional(),
|
|
38
|
+
limit: Limit.optional(),
|
|
39
|
+
});
|
|
40
|
+
export const Event = z.strictObject({
|
|
41
|
+
eventId: EventId,
|
|
42
|
+
createdAt: z.iso.datetime(),
|
|
43
|
+
// `resource.action`: `role.update`, `session.create` (a sign-in).
|
|
44
|
+
action: z.string(),
|
|
45
|
+
kind: EventKind,
|
|
46
|
+
// The name is the one at the time of the event: after a rename or a removal it is still the name
|
|
47
|
+
// the event was about.
|
|
48
|
+
target: z.strictObject({ id: z.string(), name: z.string().nullable() }).nullable(),
|
|
49
|
+
// Null for an anonymous attempt (a failed sign-in) and for what Colab does itself (a cleanup).
|
|
50
|
+
// Name and kind are null when the id no longer names anybody. `image` is the person's picture as
|
|
51
|
+
// `access.directory.resolve` gives it: null for a machine, a service and a person without one
|
|
52
|
+
// (#140). ⚠️ `userId` also carries a `service_…` id when `kind` is `service` (#178): the field
|
|
53
|
+
// keeps its name so the answer's shape stays as the UI reads it.
|
|
54
|
+
actor: z
|
|
55
|
+
.strictObject({
|
|
56
|
+
userId: z.string(),
|
|
57
|
+
name: z.string().nullable(),
|
|
58
|
+
kind: ActorKind.nullable(),
|
|
59
|
+
image: z.string().nullable(),
|
|
60
|
+
})
|
|
61
|
+
.nullable(),
|
|
62
|
+
failed: z.boolean(),
|
|
63
|
+
// The refusal's code, only next to `failed`.
|
|
64
|
+
code: z.string().nullable(),
|
|
65
|
+
// Only on a failed sign-in, and only for 90 days.
|
|
66
|
+
ip: z.string().nullable(),
|
|
67
|
+
detail: z.record(z.string(), z.unknown()).nullable(),
|
|
68
|
+
});
|
|
69
|
+
export const EventList = z.strictObject({ items: z.array(Event), nextCursor: EventId.nullable() });
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FileId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
3
|
+
export type FileId = z.infer<typeof FileId>;
|
|
4
|
+
export declare const maxFileBytes: number;
|
|
5
|
+
export type FileFormat = "pdf" | "image" | "presentation" | "spreadsheet" | "word" | "code";
|
|
6
|
+
export declare const fileFormatExtensions: Record<FileFormat, readonly string[]>;
|
|
7
|
+
export declare function fileFormatOf(name: string): FileFormat | null;
|
|
8
|
+
export declare const uploadTicketHeader = "x-colab-upload-ticket";
|
|
9
|
+
export declare const uploadTicketLifetimeMs: number;
|
|
10
|
+
export declare const FileCreateInput: z.ZodObject<{
|
|
11
|
+
parentId: z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
mediaType: z.ZodString;
|
|
14
|
+
size: z.ZodNumber;
|
|
15
|
+
idempotencyKey: z.ZodString;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export type FileCreateInput = z.infer<typeof FileCreateInput>;
|
|
18
|
+
export declare const FileUpdateInput: z.ZodObject<{
|
|
19
|
+
fileId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
mediaType: z.ZodString;
|
|
22
|
+
size: z.ZodNumber;
|
|
23
|
+
rev: z.ZodNumber;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type FileUpdateInput = z.infer<typeof FileUpdateInput>;
|
|
26
|
+
export declare const FileGetInput: z.ZodObject<{
|
|
27
|
+
fileId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
export type FileGetInput = z.infer<typeof FileGetInput>;
|
|
30
|
+
export declare const UploadTicket: z.ZodObject<{
|
|
31
|
+
url: z.ZodURL;
|
|
32
|
+
ticket: z.ZodString;
|
|
33
|
+
expiresAt: z.ZodISODateTime;
|
|
34
|
+
curl: z.ZodString;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export type UploadTicket = z.infer<typeof UploadTicket>;
|
|
37
|
+
export declare const FileUpload: z.ZodObject<{
|
|
38
|
+
upload: z.ZodObject<{
|
|
39
|
+
url: z.ZodURL;
|
|
40
|
+
ticket: z.ZodString;
|
|
41
|
+
expiresAt: z.ZodISODateTime;
|
|
42
|
+
curl: z.ZodString;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export type FileUpload = z.infer<typeof FileUpload>;
|
|
46
|
+
export declare const FileDetail: z.ZodObject<{
|
|
47
|
+
fileId: z.ZodTemplateLiteral<`node_${string}`>;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
fileName: z.ZodString;
|
|
50
|
+
mediaType: z.ZodString;
|
|
51
|
+
size: z.ZodNumber;
|
|
52
|
+
version: z.ZodObject<{
|
|
53
|
+
versionId: z.ZodTemplateLiteral<`version_${string}`>;
|
|
54
|
+
number: z.ZodNumber;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
rev: z.ZodNumber;
|
|
57
|
+
text: z.ZodNullable<z.ZodString>;
|
|
58
|
+
contentUrl: z.ZodURL;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
export type FileDetail = z.infer<typeof FileDetail>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idSchema } from "../ids/ids.js";
|
|
3
|
+
import { NodeId } from "../nodes/nodes.js";
|
|
4
|
+
import { IdempotencyKey, Rev } from "../primitives/primitives.js";
|
|
5
|
+
import { VersionId } from "../versions/versions.js";
|
|
6
|
+
// Files (#41, Nodes › Datei, E47): the inputs of `intelligence_file_create`, `_get` and `_update`,
|
|
7
|
+
// the upload ticket they answer with, and what a file reads as. The bytes never travel through these
|
|
8
|
+
// schemas: `_create` and `_update` hand out a short-lived ticket, and the bytes go to the upload door
|
|
9
|
+
// with it, from a browser or a `curl` alike, so they never pass through an AI's context.
|
|
10
|
+
// A file node's id, `node_…`: a file is a node like every other kind.
|
|
11
|
+
export const FileId = idSchema("node").describe("The file's id, `node_…`.");
|
|
12
|
+
// The largest file Colab takes (E47): 100 MB, in bytes. ⚠️ Decimal like every size the UI shows
|
|
13
|
+
// ("3 kB", "1.2 MB"): with 100 MiB a file shown as "103 MB" was taken and one of 106 MB refused (#253).
|
|
14
|
+
export const maxFileBytes = 100 * 1000 * 1000;
|
|
15
|
+
export const fileFormatExtensions = {
|
|
16
|
+
pdf: ["pdf"],
|
|
17
|
+
image: ["png", "jpg", "jpeg", "gif", "webp", "avif", "bmp", "svg"],
|
|
18
|
+
presentation: ["pptx"],
|
|
19
|
+
spreadsheet: ["xlsx"],
|
|
20
|
+
word: ["docx"],
|
|
21
|
+
code: [
|
|
22
|
+
"txt",
|
|
23
|
+
"md",
|
|
24
|
+
"markdown",
|
|
25
|
+
"yaml",
|
|
26
|
+
"yml",
|
|
27
|
+
"json",
|
|
28
|
+
"csv",
|
|
29
|
+
"tsv",
|
|
30
|
+
"xml",
|
|
31
|
+
"html",
|
|
32
|
+
"css",
|
|
33
|
+
"js",
|
|
34
|
+
"mjs",
|
|
35
|
+
"ts",
|
|
36
|
+
"tsx",
|
|
37
|
+
"jsx",
|
|
38
|
+
"py",
|
|
39
|
+
"rb",
|
|
40
|
+
"go",
|
|
41
|
+
"rs",
|
|
42
|
+
"java",
|
|
43
|
+
"kt",
|
|
44
|
+
"swift",
|
|
45
|
+
"c",
|
|
46
|
+
"h",
|
|
47
|
+
"cpp",
|
|
48
|
+
"cs",
|
|
49
|
+
"php",
|
|
50
|
+
"sh",
|
|
51
|
+
"sql",
|
|
52
|
+
"toml",
|
|
53
|
+
"ini",
|
|
54
|
+
"env",
|
|
55
|
+
"log",
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
// A file's format by the extension of its name, without regard to case; null for an unknown
|
|
59
|
+
// extension and for a name without one.
|
|
60
|
+
export function fileFormatOf(name) {
|
|
61
|
+
const extension = name.includes(".") ? (name.toLowerCase().split(".").at(-1) ?? "") : "";
|
|
62
|
+
for (const [format, known] of Object.entries(fileFormatExtensions)) {
|
|
63
|
+
if (known.includes(extension))
|
|
64
|
+
return format;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
// The header the upload door reads the ticket from. ⚠️ A header and never a query parameter: a
|
|
69
|
+
// ticket is a credential, and a query string lands in every proxy and edge log on the way.
|
|
70
|
+
export const uploadTicketHeader = "x-colab-upload-ticket";
|
|
71
|
+
// How long a ticket opens the door, from the moment it is issued.
|
|
72
|
+
export const uploadTicketLifetimeMs = 15 * 60 * 1000;
|
|
73
|
+
// What the uploader's client says the bytes are, `type/subtype` without parameters.
|
|
74
|
+
const MediaType = z
|
|
75
|
+
.string()
|
|
76
|
+
.trim()
|
|
77
|
+
.toLowerCase()
|
|
78
|
+
.regex(/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/, {
|
|
79
|
+
error: "A media type is written type/subtype, like application/pdf or image/png.",
|
|
80
|
+
})
|
|
81
|
+
.max(160)
|
|
82
|
+
.describe("The file's media type, like application/pdf, image/png or text/csv. It decides how the file is shown and whether its text is read for search and AI.");
|
|
83
|
+
const Size = z
|
|
84
|
+
.number()
|
|
85
|
+
.int()
|
|
86
|
+
.min(1)
|
|
87
|
+
.max(maxFileBytes, {
|
|
88
|
+
error: `A file can be at most ${maxFileBytes} bytes (100 MB).`,
|
|
89
|
+
})
|
|
90
|
+
.describe(`The file's size in bytes, at most ${maxFileBytes} (100 MB). The upload is refused when its body is longer than this.`);
|
|
91
|
+
const FileName = z
|
|
92
|
+
.string()
|
|
93
|
+
.max(200)
|
|
94
|
+
.describe("The file's name with its extension, like Preisliste.pdf. It is the name the download carries; on a new file it is also the node's name.");
|
|
95
|
+
export const FileCreateInput = z.strictObject({
|
|
96
|
+
// ⚠️ Required and nullable (trap C015): null is the top level of Shared, like a folder.
|
|
97
|
+
parentId: NodeId.nullable().describe("The folder to put the file in, one you can write to; null puts it on the top level of Shared, visible to you until you share it."),
|
|
98
|
+
name: FileName,
|
|
99
|
+
mediaType: MediaType,
|
|
100
|
+
size: Size,
|
|
101
|
+
idempotencyKey: IdempotencyKey,
|
|
102
|
+
});
|
|
103
|
+
export const FileUpdateInput = z.strictObject({
|
|
104
|
+
fileId: FileId.describe("The file to upload a new version of."),
|
|
105
|
+
name: FileName,
|
|
106
|
+
mediaType: MediaType,
|
|
107
|
+
size: Size,
|
|
108
|
+
rev: Rev,
|
|
109
|
+
});
|
|
110
|
+
export const FileGetInput = z.strictObject({ fileId: FileId });
|
|
111
|
+
// What `_create` and `_update` answer: the door, the ticket and the whole command. ⚠️ `ticket` is a
|
|
112
|
+
// credential, and it is in this answer on purpose: it opens ONE upload for ONE person for fifteen
|
|
113
|
+
// minutes. It appears nowhere else, never in an error and never in a log.
|
|
114
|
+
export const UploadTicket = z.strictObject({
|
|
115
|
+
url: z.url(),
|
|
116
|
+
ticket: z.string().min(1),
|
|
117
|
+
expiresAt: z.iso.datetime(),
|
|
118
|
+
// A shell command that sends the file; the path to the file is the one placeholder left.
|
|
119
|
+
curl: z.string().min(1),
|
|
120
|
+
});
|
|
121
|
+
export const FileUpload = z.strictObject({ upload: UploadTicket });
|
|
122
|
+
// A file as `_get` and the upload door answer it, always about its current version.
|
|
123
|
+
export const FileDetail = z.strictObject({
|
|
124
|
+
fileId: FileId,
|
|
125
|
+
// The node's name, as the tree shows it.
|
|
126
|
+
name: z.string(),
|
|
127
|
+
// The name of the current version's file, the one a download carries.
|
|
128
|
+
fileName: z.string(),
|
|
129
|
+
mediaType: z.string(),
|
|
130
|
+
size: z.number().int(),
|
|
131
|
+
version: z.strictObject({ versionId: VersionId, number: z.number().int() }),
|
|
132
|
+
// The node's revision, to send with the next `_update`.
|
|
133
|
+
rev: z.number().int(),
|
|
134
|
+
// The text read from the current version for search and AI; null while it is being read, and for
|
|
135
|
+
// a file without text (an image, a ZIP).
|
|
136
|
+
text: z.string().nullable(),
|
|
137
|
+
// Where the bytes are read, with a session or a token and the right to read the file.
|
|
138
|
+
contentUrl: z.url(),
|
|
139
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ServiceInterfaceFunctionCreateInput: z.ZodObject<{
|
|
3
|
+
serviceId: z.ZodTemplateLiteral<`service_${string}`>;
|
|
4
|
+
interfaceId: z.ZodTemplateLiteral<`interface_${string}`>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type ServiceInterfaceFunctionCreateInput = z.infer<typeof ServiceInterfaceFunctionCreateInput>;
|
|
8
|
+
export declare const ServiceInterfaceFunctionUpdateInput: z.ZodObject<{
|
|
9
|
+
serviceId: z.ZodTemplateLiteral<`service_${string}`>;
|
|
10
|
+
interfaceId: z.ZodTemplateLiteral<`interface_${string}`>;
|
|
11
|
+
functionId: z.ZodTemplateLiteral<`function_${string}`>;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export type ServiceInterfaceFunctionUpdateInput = z.infer<typeof ServiceInterfaceFunctionUpdateInput>;
|
|
15
|
+
export declare const ServiceInterfaceFunctionRemoveInput: z.ZodObject<{
|
|
16
|
+
serviceId: z.ZodTemplateLiteral<`service_${string}`>;
|
|
17
|
+
interfaceId: z.ZodTemplateLiteral<`interface_${string}`>;
|
|
18
|
+
functionId: z.ZodTemplateLiteral<`function_${string}`>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type ServiceInterfaceFunctionRemoveInput = z.infer<typeof ServiceInterfaceFunctionRemoveInput>;
|
|
21
|
+
export declare const FunctionRemoved: z.ZodObject<{
|
|
22
|
+
functionId: z.ZodTemplateLiteral<`function_${string}`>;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type FunctionRemoved = z.infer<typeof FunctionRemoved>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FunctionId, InterfaceId, RightWord, ServiceId } from "../services/services.js";
|
|
3
|
+
// The functions of an outside service's interface (#26). A function is the last word of a right:
|
|
4
|
+
// `datawarehouse / reports / read`.
|
|
5
|
+
export const ServiceInterfaceFunctionCreateInput = z.strictObject({
|
|
6
|
+
serviceId: ServiceId,
|
|
7
|
+
interfaceId: InterfaceId,
|
|
8
|
+
name: RightWord,
|
|
9
|
+
});
|
|
10
|
+
// Renames the function and its rights in every role, in one step; a name the interface already
|
|
11
|
+
// carries is `conflict`.
|
|
12
|
+
export const ServiceInterfaceFunctionUpdateInput = z.strictObject({
|
|
13
|
+
serviceId: ServiceId,
|
|
14
|
+
interfaceId: InterfaceId,
|
|
15
|
+
functionId: FunctionId,
|
|
16
|
+
name: RightWord,
|
|
17
|
+
});
|
|
18
|
+
export const ServiceInterfaceFunctionRemoveInput = z.strictObject({
|
|
19
|
+
serviceId: ServiceId,
|
|
20
|
+
interfaceId: InterfaceId,
|
|
21
|
+
functionId: FunctionId,
|
|
22
|
+
});
|
|
23
|
+
// What fell with a removed function: the rights the roles held on it.
|
|
24
|
+
export const FunctionRemoved = z.strictObject({
|
|
25
|
+
functionId: FunctionId,
|
|
26
|
+
name: z.string(),
|
|
27
|
+
permissions: z.array(z.string()),
|
|
28
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const packages: readonly ["intelligence", "access", "connectors", "documentation", "mail", "operator"];
|
|
2
|
+
export declare const resources: {
|
|
3
|
+
readonly node: "nodes";
|
|
4
|
+
readonly folder: "folders";
|
|
5
|
+
readonly document: "documents";
|
|
6
|
+
readonly table: "tables";
|
|
7
|
+
readonly board: "boards";
|
|
8
|
+
readonly task: "tasks";
|
|
9
|
+
readonly dashboard: "dashboards";
|
|
10
|
+
readonly file: "files";
|
|
11
|
+
readonly run: "runs";
|
|
12
|
+
readonly version: "versions";
|
|
13
|
+
readonly chat: "chats";
|
|
14
|
+
readonly message: "messages";
|
|
15
|
+
readonly action: "actions";
|
|
16
|
+
readonly grant: "grants";
|
|
17
|
+
readonly link: "links";
|
|
18
|
+
readonly user: "users";
|
|
19
|
+
readonly role: "roles";
|
|
20
|
+
readonly machine: "machines";
|
|
21
|
+
readonly app: "apps";
|
|
22
|
+
readonly session: "sessions";
|
|
23
|
+
readonly service: "services";
|
|
24
|
+
readonly interface: "interfaces";
|
|
25
|
+
readonly function: "functions";
|
|
26
|
+
readonly invitation: "invitations";
|
|
27
|
+
readonly connector: "connectors";
|
|
28
|
+
readonly connection: "connections";
|
|
29
|
+
readonly call: "calls";
|
|
30
|
+
readonly event: "events";
|
|
31
|
+
readonly page: "pages";
|
|
32
|
+
readonly credential: "credentials";
|
|
33
|
+
readonly sso: "sso";
|
|
34
|
+
readonly secret: "secrets";
|
|
35
|
+
};
|
|
36
|
+
export declare const actions: readonly ["list", "get", "create", "update", "archive", "restore", "purge"];
|
|
37
|
+
export declare const verbs: readonly ["invite", "resend", "disable", "enable", "rotate", "share", "move", "start", "complete", "test", "revoke", "remove", "unlock"];
|
|
38
|
+
export type Package = (typeof packages)[number];
|
|
39
|
+
export type Resource = keyof typeof resources;
|
|
40
|
+
export type Action = (typeof actions)[number] | (typeof verbs)[number];
|
|
41
|
+
export type ToolName = {
|
|
42
|
+
package: Package;
|
|
43
|
+
resources: readonly Resource[];
|
|
44
|
+
action: Action;
|
|
45
|
+
};
|
|
46
|
+
export type Route = {
|
|
47
|
+
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
48
|
+
path: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function isPackage(word: string): word is Package;
|
|
51
|
+
export declare function isAction(word: string): word is Action;
|
|
52
|
+
export declare function isWord(word: string): boolean;
|
|
53
|
+
export declare function parseConnectorFunction(key: string): {
|
|
54
|
+
resources: string[];
|
|
55
|
+
action: Action;
|
|
56
|
+
};
|
|
57
|
+
export declare function hasRoute(name: string): boolean;
|
|
58
|
+
export declare function parseToolName(name: string): ToolName;
|
|
59
|
+
export declare function toolRoute(name: string): Route;
|
|
60
|
+
export declare function toolPermission(name: string): string;
|
|
61
|
+
export declare function toolEvent(name: string): string;
|
|
62
|
+
export declare function toolSchemaName(name: string): string;
|