@anchrd/colab-sdk 0.1.43 → 0.1.45

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.
@@ -0,0 +1,112 @@
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
+ // The ontology's types (#1124, E250, Nodes › Ontologie): what something is (an object), what
6
+ // connects two things (a relation), what may change (an action) and who acts (an actor). Described
7
+ // per type, never per instance, and nothing has to be described: a type without description carries
8
+ // the name of where it comes from.
9
+ //
10
+ // Colab brings base types along, locked: every node has its kind as object type, every relation
11
+ // rule of `baseRelationTypes` is a relation type, people, machines and Colab itself are actor
12
+ // types, and creating, changing and archiving are the base actions of every type. A company adds
13
+ // its own types over them; an own object type stands on a source (a node, e.g. the table whose rows
14
+ // are its objects) or on none, a thing of the real world ("Monteur", "Schlüsselkasten").
15
+ export const typeKinds = ["object", "relation", "action", "actor"];
16
+ export const TypeKind = z.enum(typeKinds);
17
+ // Switched on per type: null is off.
18
+ export const typeStatuses = ["experimental", "active", "deprecated"];
19
+ export const TypeStatus = z.enum(typeStatuses);
20
+ // How many things a relation type connects on its far end: 1, 0..1, 0..n.
21
+ export const cardinalities = ["one", "optional", "many"];
22
+ export const Cardinality = z.enum(cardinalities);
23
+ // The locked base types, by word. A node's object type is its kind.
24
+ export const baseObjectTypes = [
25
+ "document",
26
+ "file",
27
+ "table",
28
+ "board",
29
+ "task",
30
+ "gadget",
31
+ "skill",
32
+ "goal",
33
+ "source",
34
+ ];
35
+ export const baseActorTypes = ["person", "machine", "system"];
36
+ export const baseActionTypes = ["create", "update", "archive"];
37
+ export const TypeId = idSchema("type").describe("An own type's id, `type_…`.");
38
+ // A type as a relation, an action or a set relation names it: an own type's id, or a base type as
39
+ // `base:<word>` (`base:table`, `base:person`, `base:mentions`, `base:create`).
40
+ export const TypeRef = z
41
+ .string()
42
+ .regex(/^(base:[a-z]+|type_[0-9A-HJKMNP-TV-Z]{26})$/)
43
+ .describe("A type: an own type's id `type_…`, or a base type as `base:<word>`.");
44
+ export const baseRef = (word) => `base:${word}`;
45
+ export const OntologyType = z.object({
46
+ typeId: TypeRef,
47
+ kind: TypeKind,
48
+ // A base type is locked: it has no rev and changes with Colab, not with the company.
49
+ base: z.boolean(),
50
+ name: z.string(),
51
+ description: z.string(),
52
+ status: TypeStatus.nullable(),
53
+ // An object type: the node its objects are, or come from (rows of a table); null for a thing of
54
+ // the real world without a source, and for every base type.
55
+ sourceNodeId: NodeId.nullable(),
56
+ // A relation type: the rule "from type × to type → meaning" and how many it connects.
57
+ from: TypeRef.nullable(),
58
+ to: TypeRef.nullable(),
59
+ cardinality: Cardinality.nullable(),
60
+ // Where its relations come from: a base rule's source ("text", "field", …); null for a type whose
61
+ // relations are set.
62
+ arisesFrom: z.string().nullable(),
63
+ // An action type: the type it acts on, what carries it out in Colab (a gadget, a skill, a board),
64
+ // and whether a person has to approve it first.
65
+ on: TypeRef.nullable(),
66
+ implementedBy: NodeId.nullable(),
67
+ approval: z.boolean(),
68
+ rev: z.int().nullable(),
69
+ updatedAt: z.iso.datetime().nullable(),
70
+ });
71
+ export const TypeListInput = z.strictObject({
72
+ kind: TypeKind.optional().describe("Only the types of this kind; all four without it."),
73
+ });
74
+ export const TypeList = z.object({
75
+ items: z.array(OntologyType),
76
+ nextCursor: z.null(),
77
+ });
78
+ const name = z.string().trim().min(1).max(120);
79
+ const description = z.string().max(4000);
80
+ export const TypeCreateInput = z.strictObject({
81
+ kind: TypeKind.describe("object: what something is; relation: a rule that connects two types; action: what may change a type; actor: who acts."),
82
+ name: name.describe("The type's name, e.g. Unterkunft, Monteur, vermietet an."),
83
+ description: description.optional().describe("What the type means, for people and their AI."),
84
+ status: TypeStatus.optional(),
85
+ sourceNodeId: NodeId.optional().describe("An object type only: the node its objects are or come from, e.g. the table whose rows they are. Leave it out for a thing of the real world."),
86
+ from: TypeRef.optional().describe("A relation type only: the type it starts at."),
87
+ to: TypeRef.optional().describe("A relation type only: the type it leads to."),
88
+ cardinality: Cardinality.optional().describe("A relation type only: how many it connects at its far end (one, optional, many)."),
89
+ on: TypeRef.optional().describe("An action type only: the type it acts on."),
90
+ implementedBy: NodeId.optional().describe("An action type only: the gadget, skill or board that carries it out."),
91
+ approval: z
92
+ .boolean()
93
+ .optional()
94
+ .describe("An action type only: true when a person has to approve it before it runs."),
95
+ idempotencyKey: IdempotencyKey,
96
+ });
97
+ export const TypeUpdateInput = z.strictObject({
98
+ typeId: TypeId,
99
+ rev: Rev,
100
+ name: name.optional(),
101
+ description: description.optional(),
102
+ status: TypeStatus.nullable().optional().describe("null switches the status off."),
103
+ sourceNodeId: NodeId.nullable().optional(),
104
+ from: TypeRef.optional(),
105
+ to: TypeRef.optional(),
106
+ cardinality: Cardinality.nullable().optional(),
107
+ on: TypeRef.optional(),
108
+ implementedBy: NodeId.nullable().optional(),
109
+ approval: z.boolean().optional(),
110
+ });
111
+ export const TypeArchiveInput = z.strictObject({ typeId: TypeId });
112
+ export const TypeRestoreInput = z.strictObject({ typeId: TypeId });
@@ -44,6 +44,10 @@ export declare const VersionMove: z.ZodObject<{
44
44
  }>>;
45
45
  }, z.core.$strip>;
46
46
  comment: z.ZodNullable<z.ZodString>;
47
+ cause: z.ZodNullable<z.ZodObject<{
48
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
49
+ title: z.ZodString;
50
+ }, z.core.$strip>>;
47
51
  }, z.core.$strip>;
48
52
  export type VersionMove = z.infer<typeof VersionMove>;
49
53
  export declare const taskVersionChanges: readonly ["title", "text", "assignee", "dates", "labels", "parent", "dependencies", "waiting", "fields"];
@@ -123,6 +127,10 @@ export declare const NodeVersion: z.ZodObject<{
123
127
  }>>;
124
128
  }, z.core.$strip>;
125
129
  comment: z.ZodNullable<z.ZodString>;
130
+ cause: z.ZodNullable<z.ZodObject<{
131
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
132
+ title: z.ZodString;
133
+ }, z.core.$strip>>;
126
134
  }, z.core.$strip>>;
127
135
  changes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
128
136
  title: "title";
@@ -184,6 +192,10 @@ export declare const NodeVersionList: z.ZodObject<{
184
192
  }>>;
185
193
  }, z.core.$strip>;
186
194
  comment: z.ZodNullable<z.ZodString>;
195
+ cause: z.ZodNullable<z.ZodObject<{
196
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
197
+ title: z.ZodString;
198
+ }, z.core.$strip>>;
187
199
  }, z.core.$strip>>;
188
200
  changes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
189
201
  title: "title";
@@ -247,6 +259,10 @@ export declare const NodeVersionDetail: z.ZodObject<{
247
259
  }>>;
248
260
  }, z.core.$strip>;
249
261
  comment: z.ZodNullable<z.ZodString>;
262
+ cause: z.ZodNullable<z.ZodObject<{
263
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
264
+ title: z.ZodString;
265
+ }, z.core.$strip>>;
250
266
  }, z.core.$strip>>;
251
267
  changes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
252
268
  title: "title";
@@ -263,6 +279,7 @@ export declare const NodeVersionDetail: z.ZodObject<{
263
279
  locked: z.ZodOptional<z.ZodBoolean>;
264
280
  content: z.ZodNullable<z.ZodString>;
265
281
  mediaType: z.ZodNullable<z.ZodString>;
282
+ description: z.ZodNullable<z.ZodString>;
266
283
  columns: z.ZodNullable<z.ZodArray<z.ZodObject<{
267
284
  name: z.ZodString;
268
285
  type: z.ZodEnum<{
@@ -398,6 +415,10 @@ export declare const NodeVersionExcerpt: z.ZodObject<{
398
415
  }>>;
399
416
  }, z.core.$strip>;
400
417
  comment: z.ZodNullable<z.ZodString>;
418
+ cause: z.ZodNullable<z.ZodObject<{
419
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
420
+ title: z.ZodString;
421
+ }, z.core.$strip>>;
401
422
  }, z.core.$strip>>;
402
423
  changes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
403
424
  title: "title";
@@ -414,6 +435,7 @@ export declare const NodeVersionExcerpt: z.ZodObject<{
414
435
  locked: z.ZodOptional<z.ZodBoolean>;
415
436
  content: z.ZodNullable<z.ZodString>;
416
437
  mediaType: z.ZodNullable<z.ZodString>;
438
+ description: z.ZodNullable<z.ZodString>;
417
439
  columns: z.ZodNullable<z.ZodArray<z.ZodObject<{
418
440
  name: z.ZodString;
419
441
  type: z.ZodEnum<{
@@ -31,6 +31,8 @@ export const VersionMove = z.object({
31
31
  from: MoveColumn.nullable(),
32
32
  to: MoveColumn,
33
33
  comment: z.string().nullable(),
34
+ // The card whose move made Colab move this one by a rule on its waits for (E242); null otherwise.
35
+ cause: z.object({ taskId: NodeId, title: z.string() }).nullable(),
34
36
  });
35
37
  // What a task's version changed besides a move (E117): the words the history names, in this order.
36
38
  // The fields of a card kind (#638) come later as their own entries.
@@ -101,6 +103,9 @@ export const NodeVersionDetail = NodeVersion.extend({
101
103
  content: z.string().nullable(),
102
104
  // Only for a file: its media type.
103
105
  mediaType: z.string().nullable(),
106
+ // Only for an image file (#1126, E244): the description `intelligence_file_describe` stored at
107
+ // this version; null before anyone asked and for every other version.
108
+ description: z.string().nullable(),
104
109
  // Only for a table: its columns with their types in this version (#40).
105
110
  columns: z.array(TableColumn).nullable(),
106
111
  // Only for a task of a card kind (#638): the values of its fields in this version, by the field's
@@ -19,6 +19,8 @@ export declare const Changed: z.ZodObject<{
19
19
  userId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
20
20
  machineId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
21
21
  roleId: z.ZodOptional<z.ZodTemplateLiteral<`role_${string}`>>;
22
+ teamId: z.ZodOptional<z.ZodTemplateLiteral<`team_${string}`>>;
23
+ memberId: z.ZodOptional<z.ZodTemplateLiteral<`member_${string}`>>;
22
24
  permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
25
  invitationId: z.ZodOptional<z.ZodTemplateLiteral<`invitation_${string}`>>;
24
26
  serviceId: z.ZodOptional<z.ZodTemplateLiteral<`service_${string}`>>;
@@ -35,6 +37,8 @@ export declare const Changed: z.ZodObject<{
35
37
  connectionId: z.ZodOptional<z.ZodTemplateLiteral<`connection_${string}`>>;
36
38
  credentialId: z.ZodOptional<z.ZodTemplateLiteral<`credential_${string}`>>;
37
39
  mcpId: z.ZodOptional<z.ZodTemplateLiteral<`mcp_${string}`>>;
40
+ typeId: z.ZodOptional<z.ZodTemplateLiteral<`type_${string}`>>;
41
+ relationId: z.ZodOptional<z.ZodTemplateLiteral<`relation_${string}`>>;
38
42
  ref: z.ZodOptional<z.ZodString>;
39
43
  rev: z.ZodOptional<z.ZodNumber>;
40
44
  version: z.ZodOptional<z.ZodNumber>;
@@ -51,6 +55,26 @@ export declare const Unblocked: z.ZodObject<{
51
55
  own: z.ZodOptional<z.ZodLiteral<true>>;
52
56
  }, z.core.$strip>;
53
57
  export type Unblocked = z.infer<typeof Unblocked>;
58
+ export declare const Moved: z.ZodObject<{
59
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
60
+ title: z.ZodString;
61
+ column: z.ZodObject<{
62
+ columnId: z.ZodTemplateLiteral<`column_${string}`>;
63
+ name: z.ZodString;
64
+ type: z.ZodEnum<{
65
+ archive: "archive";
66
+ done: "done";
67
+ backlog: "backlog";
68
+ open: "open";
69
+ progress: "progress";
70
+ discarded: "discarded";
71
+ blocked: "blocked";
72
+ }>;
73
+ }, z.core.$strip>;
74
+ rev: z.ZodNumber;
75
+ cause: z.ZodTemplateLiteral<`node_${string}`>;
76
+ }, z.core.$strip>;
77
+ export type Moved = z.infer<typeof Moved>;
54
78
  export declare const Effects: z.ZodObject<{
55
79
  woken: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
80
  userId: z.ZodString;
@@ -70,6 +94,25 @@ export declare const Effects: z.ZodObject<{
70
94
  rev: z.ZodNumber;
71
95
  own: z.ZodOptional<z.ZodLiteral<true>>;
72
96
  }, z.core.$strip>>>;
97
+ moved: z.ZodOptional<z.ZodArray<z.ZodObject<{
98
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
99
+ title: z.ZodString;
100
+ column: z.ZodObject<{
101
+ columnId: z.ZodTemplateLiteral<`column_${string}`>;
102
+ name: z.ZodString;
103
+ type: z.ZodEnum<{
104
+ archive: "archive";
105
+ done: "done";
106
+ backlog: "backlog";
107
+ open: "open";
108
+ progress: "progress";
109
+ discarded: "discarded";
110
+ blocked: "blocked";
111
+ }>;
112
+ }, z.core.$strip>;
113
+ rev: z.ZodNumber;
114
+ cause: z.ZodTemplateLiteral<`node_${string}`>;
115
+ }, z.core.$strip>>>;
73
116
  readers: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
117
  userId: z.ZodString;
75
118
  name: z.ZodNullable<z.ZodString>;
@@ -112,6 +155,8 @@ export declare const Written: z.ZodObject<{
112
155
  userId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
113
156
  machineId: z.ZodOptional<z.ZodTemplateLiteral<`user_${string}`>>;
114
157
  roleId: z.ZodOptional<z.ZodTemplateLiteral<`role_${string}`>>;
158
+ teamId: z.ZodOptional<z.ZodTemplateLiteral<`team_${string}`>>;
159
+ memberId: z.ZodOptional<z.ZodTemplateLiteral<`member_${string}`>>;
115
160
  permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
116
161
  invitationId: z.ZodOptional<z.ZodTemplateLiteral<`invitation_${string}`>>;
117
162
  serviceId: z.ZodOptional<z.ZodTemplateLiteral<`service_${string}`>>;
@@ -128,6 +173,8 @@ export declare const Written: z.ZodObject<{
128
173
  connectionId: z.ZodOptional<z.ZodTemplateLiteral<`connection_${string}`>>;
129
174
  credentialId: z.ZodOptional<z.ZodTemplateLiteral<`credential_${string}`>>;
130
175
  mcpId: z.ZodOptional<z.ZodTemplateLiteral<`mcp_${string}`>>;
176
+ typeId: z.ZodOptional<z.ZodTemplateLiteral<`type_${string}`>>;
177
+ relationId: z.ZodOptional<z.ZodTemplateLiteral<`relation_${string}`>>;
131
178
  ref: z.ZodOptional<z.ZodString>;
132
179
  rev: z.ZodOptional<z.ZodNumber>;
133
180
  version: z.ZodOptional<z.ZodNumber>;
@@ -151,6 +198,25 @@ export declare const Written: z.ZodObject<{
151
198
  rev: z.ZodNumber;
152
199
  own: z.ZodOptional<z.ZodLiteral<true>>;
153
200
  }, z.core.$strip>>>;
201
+ moved: z.ZodOptional<z.ZodArray<z.ZodObject<{
202
+ taskId: z.ZodTemplateLiteral<`node_${string}`>;
203
+ title: z.ZodString;
204
+ column: z.ZodObject<{
205
+ columnId: z.ZodTemplateLiteral<`column_${string}`>;
206
+ name: z.ZodString;
207
+ type: z.ZodEnum<{
208
+ archive: "archive";
209
+ done: "done";
210
+ backlog: "backlog";
211
+ open: "open";
212
+ progress: "progress";
213
+ discarded: "discarded";
214
+ blocked: "blocked";
215
+ }>;
216
+ }, z.core.$strip>;
217
+ rev: z.ZodNumber;
218
+ cause: z.ZodTemplateLiteral<`node_${string}`>;
219
+ }, z.core.$strip>>>;
154
220
  readers: z.ZodOptional<z.ZodArray<z.ZodObject<{
155
221
  userId: z.ZodString;
156
222
  name: z.ZodNullable<z.ZodString>;
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AppId, SessionId } from "../apps/apps.js";
3
+ import { TaskColumn } from "../columns/columns.js";
3
4
  import { ConnectionId } from "../connections/connections.js";
4
5
  import { ConnectorId } from "../connectors/connectors.js";
5
6
  import { Warning } from "../error/error.js";
@@ -13,10 +14,13 @@ import { Missing, Reached } from "../missing/missing.js";
13
14
  import { NodeId, NodeReader } from "../nodes/nodes.js";
14
15
  import { CredentialId } from "../operators/operators.js";
15
16
  import { ProviderId } from "../providers/providers.js";
17
+ import { RelationId } from "../relations/relations.js";
16
18
  import { RoleId } from "../roles/roles.js";
17
19
  import { RunId } from "../runs/runs.js";
18
20
  import { FunctionId, InterfaceId, ServiceId } from "../services/services.js";
19
21
  import { QueryId } from "../sources/sources.js";
22
+ import { MemberId, TeamId } from "../teams/teams.js";
23
+ import { TypeId } from "../types/types.js";
20
24
  import { UserId } from "../users/users.js";
21
25
  // What a write answers over `/mcp` (E126, #672): what it changed and what that caused, never the
22
26
  // object it wrote. The AI sent the object itself; echoing it back filled an Operator's context with
@@ -48,6 +52,9 @@ export const Changed = z.object({
48
52
  // its `user_…` id either way.
49
53
  machineId: MachineId.optional(),
50
54
  roleId: RoleId.optional(),
55
+ // A team and a membership in it (#1121).
56
+ teamId: TeamId.optional(),
57
+ memberId: MemberId.optional(),
51
58
  // The rights a switch of a role really turned on or off, which a level in the call expands to.
52
59
  permissions: z.array(z.string()).optional(),
53
60
  invitationId: InvitationId.optional(),
@@ -62,6 +69,9 @@ export const Changed = z.object({
62
69
  credentialId: CredentialId.optional(),
63
70
  // A person's own MCP (#802).
64
71
  mcpId: McpId.optional(),
72
+ // The ontology (#1124): an own type and a relation somebody set.
73
+ typeId: TypeId.optional(),
74
+ relationId: RelationId.optional(),
65
75
  // The caller's own name for an entry of a create of many (#625).
66
76
  ref: z.string().optional(),
67
77
  rev: z.number().int().optional(),
@@ -77,6 +87,15 @@ export const Unblocked = z.object({
77
87
  rev: z.number().int(),
78
88
  own: z.literal(true).optional(),
79
89
  });
90
+ // A card Colab moved because a rule on its "waits for" fired (E242, #1132): where it lies now, its
91
+ // `rev` for the next save, and the card whose move caused it.
92
+ export const Moved = z.object({
93
+ taskId: NodeId,
94
+ title: z.string(),
95
+ column: TaskColumn,
96
+ rev: z.number().int(),
97
+ cause: NodeId,
98
+ });
80
99
  // What the write caused for others; an empty field is left out.
81
100
  export const Effects = z.object({
82
101
  // Machines whose Actions changed by it (#334, E124): an Operator among them wakes.
@@ -85,6 +104,8 @@ export const Effects = z.object({
85
104
  notified: z.array(Reached).optional(),
86
105
  // Tasks ready now, because the last thing they waited on was closed by this call.
87
106
  unblocked: z.array(Unblocked).optional(),
107
+ // Cards moved by a rule on their "waits for" (E242), a chain of them in the order they moved.
108
+ moved: z.array(Moved).optional(),
88
109
  // Who reads a moved node now (#36): a move takes the grants of its new folder.
89
110
  readers: z.array(NodeReader).optional(),
90
111
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchrd/colab-sdk",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Types, Zod schemas and the service client of Colab, the contract between its UI, backends and outside services.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",