@cooperarq/contracts 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/dist/auth.d.ts +20 -0
- package/dist/auth.js +17 -0
- package/dist/conversations.d.ts +69 -0
- package/dist/conversations.js +54 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.js +9 -0
- package/dist/workspace-files.d.ts +36 -0
- package/dist/workspace-files.js +29 -0
- package/dist/workspaces.d.ts +26 -0
- package/dist/workspaces.js +14 -0
- package/package.json +43 -0
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const authUserSchema: z.ZodObject<{
|
|
3
|
+
avatar_url: z.ZodNullable<z.ZodString>;
|
|
4
|
+
created_at: z.ZodString;
|
|
5
|
+
display_name: z.ZodNullable<z.ZodString>;
|
|
6
|
+
email: z.ZodNullable<z.ZodString>;
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
is_guest: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
role: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const credentialsSchema: z.ZodObject<{
|
|
12
|
+
email: z.ZodString;
|
|
13
|
+
password: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const registrationSchema: z.ZodObject<{
|
|
16
|
+
email: z.ZodString;
|
|
17
|
+
password: z.ZodString;
|
|
18
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type AuthUser = z.infer<typeof authUserSchema>;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const authUserSchema = z.object({
|
|
3
|
+
avatar_url: z.string().nullable(),
|
|
4
|
+
created_at: z.string(),
|
|
5
|
+
display_name: z.string().nullable(),
|
|
6
|
+
email: z.string().nullable(),
|
|
7
|
+
id: z.string(),
|
|
8
|
+
is_guest: z.boolean().optional(),
|
|
9
|
+
role: z.string()
|
|
10
|
+
});
|
|
11
|
+
export const credentialsSchema = z.object({
|
|
12
|
+
email: z.string().min(1),
|
|
13
|
+
password: z.string().min(8)
|
|
14
|
+
});
|
|
15
|
+
export const registrationSchema = credentialsSchema.extend({
|
|
16
|
+
displayName: z.string().max(200).optional()
|
|
17
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const messageRoleSchema: z.ZodEnum<{
|
|
3
|
+
user: "user";
|
|
4
|
+
assistant: "assistant";
|
|
5
|
+
system: "system";
|
|
6
|
+
tool: "tool";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const dbMessageRowSchema: z.ZodObject<{
|
|
9
|
+
content: z.ZodString;
|
|
10
|
+
created_at: z.ZodString;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
13
|
+
model_used: z.ZodNullable<z.ZodString>;
|
|
14
|
+
parts: z.ZodUnknown;
|
|
15
|
+
role: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const conversationSchema: z.ZodObject<{
|
|
18
|
+
created_at: z.ZodString;
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
is_archived: z.ZodBoolean;
|
|
21
|
+
is_pinned: z.ZodBoolean;
|
|
22
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
title: z.ZodNullable<z.ZodString>;
|
|
24
|
+
updated_at: z.ZodString;
|
|
25
|
+
user_id: z.ZodNullable<z.ZodString>;
|
|
26
|
+
workspace_id: z.ZodNullable<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const createConversationInputSchema: z.ZodObject<{
|
|
29
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
title: z.ZodDefault<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export declare const updateConversationInputSchema: z.ZodObject<{
|
|
33
|
+
is_archived: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
is_pinned: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
title: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export declare const guestConversationLimitErrorSchema: z.ZodObject<{
|
|
38
|
+
error: z.ZodLiteral<"guest_conversation_limit_reached">;
|
|
39
|
+
limit: z.ZodNumber;
|
|
40
|
+
message: z.ZodString;
|
|
41
|
+
used: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export declare const postMessagePayloadSchema: z.ZodObject<{
|
|
44
|
+
content: z.ZodString;
|
|
45
|
+
credits_charged: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
47
|
+
model_used: z.ZodOptional<z.ZodString>;
|
|
48
|
+
parts: z.ZodUnknown;
|
|
49
|
+
role: z.ZodString;
|
|
50
|
+
tokens_used: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const postConversationMessagesInputSchema: z.ZodObject<{
|
|
53
|
+
conversation_id: z.ZodString;
|
|
54
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
55
|
+
content: z.ZodString;
|
|
56
|
+
credits_charged: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
58
|
+
model_used: z.ZodOptional<z.ZodString>;
|
|
59
|
+
parts: z.ZodUnknown;
|
|
60
|
+
role: z.ZodString;
|
|
61
|
+
tokens_used: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type Conversation = z.infer<typeof conversationSchema>;
|
|
65
|
+
export type ConversationCreateInput = z.infer<typeof createConversationInputSchema>;
|
|
66
|
+
export type DbMessageRow = z.infer<typeof dbMessageRowSchema>;
|
|
67
|
+
export type GuestConversationLimitError = z.infer<typeof guestConversationLimitErrorSchema>;
|
|
68
|
+
export type PostMessagePayload = z.infer<typeof postMessagePayloadSchema>;
|
|
69
|
+
export type UpdateConversationInput = z.infer<typeof updateConversationInputSchema>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const messageRoleSchema = z.enum(['user', 'assistant', 'system', 'tool']);
|
|
3
|
+
export const dbMessageRowSchema = z.object({
|
|
4
|
+
content: z.string(),
|
|
5
|
+
created_at: z.string(),
|
|
6
|
+
id: z.string(),
|
|
7
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
8
|
+
model_used: z.string().nullable(),
|
|
9
|
+
parts: z.unknown(),
|
|
10
|
+
role: z.string()
|
|
11
|
+
});
|
|
12
|
+
export const conversationSchema = z.object({
|
|
13
|
+
created_at: z.string(),
|
|
14
|
+
id: z.string(),
|
|
15
|
+
is_archived: z.boolean(),
|
|
16
|
+
is_pinned: z.boolean(),
|
|
17
|
+
metadata: z.record(z.string(), z.unknown()).default({}),
|
|
18
|
+
title: z.string().nullable(),
|
|
19
|
+
updated_at: z.string(),
|
|
20
|
+
user_id: z.string().nullable(),
|
|
21
|
+
workspace_id: z.string().nullable()
|
|
22
|
+
});
|
|
23
|
+
export const createConversationInputSchema = z.object({
|
|
24
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
title: z.string().min(1).max(200).default('New Chat')
|
|
26
|
+
});
|
|
27
|
+
export const updateConversationInputSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
is_archived: z.boolean().optional(),
|
|
30
|
+
is_pinned: z.boolean().optional(),
|
|
31
|
+
title: z.string().max(200).optional()
|
|
32
|
+
})
|
|
33
|
+
.refine((value) => Object.values(value).some((item) => item !== undefined), {
|
|
34
|
+
message: 'No supported fields to update'
|
|
35
|
+
});
|
|
36
|
+
export const guestConversationLimitErrorSchema = z.object({
|
|
37
|
+
error: z.literal('guest_conversation_limit_reached'),
|
|
38
|
+
limit: z.number(),
|
|
39
|
+
message: z.string(),
|
|
40
|
+
used: z.number()
|
|
41
|
+
});
|
|
42
|
+
export const postMessagePayloadSchema = z.object({
|
|
43
|
+
content: z.string(),
|
|
44
|
+
credits_charged: z.number().optional(),
|
|
45
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
46
|
+
model_used: z.string().optional(),
|
|
47
|
+
parts: z.unknown(),
|
|
48
|
+
role: z.string(),
|
|
49
|
+
tokens_used: z.number().optional()
|
|
50
|
+
});
|
|
51
|
+
export const postConversationMessagesInputSchema = z.object({
|
|
52
|
+
conversation_id: z.string().min(1),
|
|
53
|
+
messages: z.array(postMessagePayloadSchema).min(1)
|
|
54
|
+
});
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const apiErrorSchema: z.ZodObject<{
|
|
3
|
+
error: z.ZodString;
|
|
4
|
+
message: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export type ApiError = z.infer<typeof apiErrorSchema>;
|
|
7
|
+
export declare function apiErrorMessage(value: unknown, fallback: string): string;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const apiErrorSchema = z.object({
|
|
3
|
+
error: z.string(),
|
|
4
|
+
message: z.string().optional()
|
|
5
|
+
});
|
|
6
|
+
export function apiErrorMessage(value, fallback) {
|
|
7
|
+
const parsed = apiErrorSchema.safeParse(value);
|
|
8
|
+
return parsed.success ? (parsed.data.message ?? parsed.data.error) : fallback;
|
|
9
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const workspaceFileKindSchema: z.ZodEnum<{
|
|
3
|
+
md: "md";
|
|
4
|
+
json: "json";
|
|
5
|
+
yaml: "yaml";
|
|
6
|
+
mermaid: "mermaid";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const workspaceFileSchema: z.ZodObject<{
|
|
9
|
+
content: z.ZodString;
|
|
10
|
+
created_at: z.ZodString;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
kind: z.ZodEnum<{
|
|
13
|
+
md: "md";
|
|
14
|
+
json: "json";
|
|
15
|
+
yaml: "yaml";
|
|
16
|
+
mermaid: "mermaid";
|
|
17
|
+
}>;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
updated_at: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const createWorkspaceFileInputSchema: z.ZodObject<{
|
|
22
|
+
content: z.ZodDefault<z.ZodString>;
|
|
23
|
+
path: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const updateWorkspaceFileInputSchema: z.ZodObject<{
|
|
26
|
+
content: z.ZodOptional<z.ZodString>;
|
|
27
|
+
path: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const moveWorkspaceFolderInputSchema: z.ZodObject<{
|
|
30
|
+
from: z.ZodString;
|
|
31
|
+
to: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const deleteWorkspaceFolderInputSchema: z.ZodObject<{
|
|
34
|
+
path: z.ZodString;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type WorkspaceFile = z.infer<typeof workspaceFileSchema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const workspaceFileKindSchema = z.enum(['md', 'json', 'yaml', 'mermaid']);
|
|
3
|
+
export const workspaceFileSchema = z.object({
|
|
4
|
+
content: z.string(),
|
|
5
|
+
created_at: z.string(),
|
|
6
|
+
id: z.string(),
|
|
7
|
+
kind: workspaceFileKindSchema,
|
|
8
|
+
path: z.string(),
|
|
9
|
+
updated_at: z.string()
|
|
10
|
+
});
|
|
11
|
+
export const createWorkspaceFileInputSchema = z.object({
|
|
12
|
+
content: z.string().default(''),
|
|
13
|
+
path: z.string().min(1).max(200).optional()
|
|
14
|
+
});
|
|
15
|
+
export const updateWorkspaceFileInputSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
content: z.string().optional(),
|
|
18
|
+
path: z.string().min(1).max(200).optional()
|
|
19
|
+
})
|
|
20
|
+
.refine((value) => value.content !== undefined || value.path !== undefined, {
|
|
21
|
+
message: 'Nothing to update'
|
|
22
|
+
});
|
|
23
|
+
export const moveWorkspaceFolderInputSchema = z.object({
|
|
24
|
+
from: z.string().min(1).max(200),
|
|
25
|
+
to: z.string().min(1).max(200)
|
|
26
|
+
});
|
|
27
|
+
export const deleteWorkspaceFolderInputSchema = z.object({
|
|
28
|
+
path: z.string().min(1).max(200)
|
|
29
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const workspaceEngineSchema: z.ZodEnum<{
|
|
3
|
+
json: "json";
|
|
4
|
+
yaml: "yaml";
|
|
5
|
+
mermaid: "mermaid";
|
|
6
|
+
markdown: "markdown";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const createWorkspaceInputSchema: z.ZodObject<{
|
|
9
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
document: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
|
+
engine: z.ZodDefault<z.ZodEnum<{
|
|
12
|
+
json: "json";
|
|
13
|
+
yaml: "yaml";
|
|
14
|
+
mermaid: "mermaid";
|
|
15
|
+
markdown: "markdown";
|
|
16
|
+
}>>;
|
|
17
|
+
title: z.ZodDefault<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const updateWorkspaceInputSchema: z.ZodObject<{
|
|
20
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
is_starred: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
title: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type CreateWorkspaceInput = z.infer<typeof createWorkspaceInputSchema>;
|
|
26
|
+
export type UpdateWorkspaceInput = z.infer<typeof updateWorkspaceInputSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const workspaceEngineSchema = z.enum(['mermaid', 'json', 'yaml', 'markdown']);
|
|
3
|
+
export const createWorkspaceInputSchema = z.object({
|
|
4
|
+
description: z.string().max(2000).optional().nullable(),
|
|
5
|
+
document: z.record(z.string(), z.unknown()).optional(),
|
|
6
|
+
engine: workspaceEngineSchema.default('mermaid'),
|
|
7
|
+
title: z.string().min(1).max(200).default('Untitled Workspace')
|
|
8
|
+
});
|
|
9
|
+
export const updateWorkspaceInputSchema = z.object({
|
|
10
|
+
description: z.string().max(2000).optional().nullable(),
|
|
11
|
+
is_starred: z.boolean().optional(),
|
|
12
|
+
tags: z.array(z.string()).optional(),
|
|
13
|
+
title: z.string().max(200).optional()
|
|
14
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cooperarq/contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"zod": "^4.1.12"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vitest": "^3.2.4"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
"./auth": {
|
|
19
|
+
"types": "./dist/auth.d.ts",
|
|
20
|
+
"default": "./dist/auth.js"
|
|
21
|
+
},
|
|
22
|
+
"./conversations": {
|
|
23
|
+
"types": "./dist/conversations.d.ts",
|
|
24
|
+
"default": "./dist/conversations.js"
|
|
25
|
+
},
|
|
26
|
+
"./http": {
|
|
27
|
+
"types": "./dist/http.d.ts",
|
|
28
|
+
"default": "./dist/http.js"
|
|
29
|
+
},
|
|
30
|
+
"./workspace-files": {
|
|
31
|
+
"types": "./dist/workspace-files.d.ts",
|
|
32
|
+
"default": "./dist/workspace-files.js"
|
|
33
|
+
},
|
|
34
|
+
"./workspaces": {
|
|
35
|
+
"types": "./dist/workspaces.d.ts",
|
|
36
|
+
"default": "./dist/workspaces.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc --project tsconfig.json",
|
|
41
|
+
"test": "vitest run"
|
|
42
|
+
}
|
|
43
|
+
}
|