@middlewr/contracts 0.0.7 → 0.0.8
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/{cjs → dist/cjs}/common.schema.d.ts +4 -0
- package/dist/cjs/common.schema.d.ts.map +1 -0
- package/dist/cjs/domains.schema.d.ts +17 -0
- package/dist/cjs/domains.schema.d.ts.map +1 -0
- package/{esm → dist/cjs}/index.d.ts +197 -10
- package/dist/cjs/index.d.ts.map +1 -0
- package/{cjs → dist/cjs}/index.js +196 -145
- package/{cjs → dist/cjs}/links.schema.d.ts +24 -3
- package/dist/cjs/links.schema.d.ts.map +1 -0
- package/dist/cjs/tags.schema.d.ts.map +1 -0
- package/dist/cjs/users.schema.d.ts.map +1 -0
- package/dist/cjs/workspaces.schema.d.ts.map +1 -0
- package/{esm → dist/esm}/common.schema.d.ts +4 -0
- package/dist/esm/common.schema.d.ts.map +1 -0
- package/dist/esm/domains.schema.d.ts +17 -0
- package/dist/esm/domains.schema.d.ts.map +1 -0
- package/{cjs → dist/esm}/index.d.ts +197 -10
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +332 -0
- package/{esm → dist/esm}/links.schema.d.ts +24 -3
- package/dist/esm/links.schema.d.ts.map +1 -0
- package/dist/esm/tags.schema.d.ts.map +1 -0
- package/dist/esm/users.schema.d.ts.map +1 -0
- package/dist/esm/workspaces.schema.d.ts.map +1 -0
- package/package.json +20 -7
- package/scripts/build.sh +55 -0
- package/src/common.schema.ts +34 -0
- package/src/domains.schema.ts +32 -0
- package/src/index.ts +196 -0
- package/src/links.schema.ts +107 -0
- package/src/tags.schema.ts +27 -0
- package/src/users.schema.ts +22 -0
- package/src/workspaces.schema.ts +64 -0
- package/tsconfig.json +17 -0
- package/cjs/common.schema.d.ts.map +0 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/links.schema.d.ts.map +0 -1
- package/cjs/tags.schema.d.ts.map +0 -1
- package/cjs/users.schema.d.ts.map +0 -1
- package/cjs/workspaces.schema.d.ts.map +0 -1
- package/esm/common.schema.d.ts.map +0 -1
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -286
- package/esm/links.schema.d.ts.map +0 -1
- package/esm/tags.schema.d.ts.map +0 -1
- package/esm/users.schema.d.ts.map +0 -1
- package/esm/workspaces.schema.d.ts.map +0 -1
- /package/{cjs → dist/cjs}/package.json +0 -0
- /package/{cjs → dist/cjs}/tags.schema.d.ts +0 -0
- /package/{cjs → dist/cjs}/users.schema.d.ts +0 -0
- /package/{cjs → dist/cjs}/workspaces.schema.d.ts +0 -0
- /package/{esm → dist/esm}/package.json +0 -0
- /package/{esm → dist/esm}/tags.schema.d.ts +0 -0
- /package/{esm → dist/esm}/users.schema.d.ts +0 -0
- /package/{esm → dist/esm}/workspaces.schema.d.ts +0 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { ContractRouterClient } from '@orpc/contract';
|
|
2
|
+
import { oc } from '@orpc/contract';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
DomainIdParamSchema,
|
|
7
|
+
InvitationIdParamSchema,
|
|
8
|
+
LinkIdParamSchema,
|
|
9
|
+
MemberIdParamSchema,
|
|
10
|
+
TagIdParamSchema,
|
|
11
|
+
TokenParamSchema,
|
|
12
|
+
WorkspaceIdParamSchema,
|
|
13
|
+
} from './common.schema';
|
|
14
|
+
import { CreateDomainInputSchema, DomainSchema, UpdateDomainInputSchema } from './domains.schema';
|
|
15
|
+
import { CreateLinkInputSchema, LinkFiltersSchema, LinkSchema, PaginatedLinksSchema, UpdateLinkInputSchema } from './links.schema';
|
|
16
|
+
import { CreateTagInputSchema, TagSchema, UpdateTagInputSchema } from './tags.schema';
|
|
17
|
+
import { SignInInputSchema, UpdateUserInputSchema, UserSchema } from './users.schema';
|
|
18
|
+
import {
|
|
19
|
+
CreateInvitationInputSchema,
|
|
20
|
+
CreateWorkspaceInputSchema,
|
|
21
|
+
TransferOwnershipInputSchema,
|
|
22
|
+
UpdateMemberInputSchema,
|
|
23
|
+
UpdateWorkspaceInputSchema,
|
|
24
|
+
WorkspaceInvitationSchema,
|
|
25
|
+
WorkspaceMemberSchema,
|
|
26
|
+
WorkspaceSchema,
|
|
27
|
+
WorkspaceWithCountSchema,
|
|
28
|
+
} from './workspaces.schema';
|
|
29
|
+
|
|
30
|
+
export * from './common.schema';
|
|
31
|
+
export * from './domains.schema';
|
|
32
|
+
export * from './links.schema';
|
|
33
|
+
export * from './tags.schema';
|
|
34
|
+
// Re-export all schemas
|
|
35
|
+
export * from './users.schema';
|
|
36
|
+
export * from './workspaces.schema';
|
|
37
|
+
|
|
38
|
+
// Users contract
|
|
39
|
+
export const usersContract = {
|
|
40
|
+
me: oc.route({ method: 'GET', path: '/api/users/me' }).output(z.object({ user: UserSchema })),
|
|
41
|
+
|
|
42
|
+
signIn: oc
|
|
43
|
+
.route({ method: 'POST', path: '/api/users' })
|
|
44
|
+
.input(SignInInputSchema)
|
|
45
|
+
.output(z.object({ user: UserSchema, status: z.enum(['created', 'existing']) })),
|
|
46
|
+
|
|
47
|
+
update: oc
|
|
48
|
+
.route({ method: 'PATCH', path: '/api/users/me' })
|
|
49
|
+
.input(UpdateUserInputSchema)
|
|
50
|
+
.output(z.object({ user: UserSchema })),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Workspaces contract
|
|
54
|
+
export const workspacesContract = {
|
|
55
|
+
create: oc.route({ method: 'POST', path: '/api/workspaces' }).input(CreateWorkspaceInputSchema).output(WorkspaceSchema),
|
|
56
|
+
|
|
57
|
+
list: oc.route({ method: 'GET', path: '/api/workspaces' }).output(z.array(WorkspaceWithCountSchema)),
|
|
58
|
+
|
|
59
|
+
get: oc.route({ method: 'GET', path: '/api/workspaces/{workspace_id}' }).input(WorkspaceIdParamSchema).output(WorkspaceWithCountSchema),
|
|
60
|
+
|
|
61
|
+
update: oc
|
|
62
|
+
.route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}' })
|
|
63
|
+
.input(WorkspaceIdParamSchema.merge(UpdateWorkspaceInputSchema))
|
|
64
|
+
.output(WorkspaceSchema),
|
|
65
|
+
|
|
66
|
+
delete: oc.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}' }).input(WorkspaceIdParamSchema).output(z.void()),
|
|
67
|
+
|
|
68
|
+
transfer: oc
|
|
69
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/transfer' })
|
|
70
|
+
.input(WorkspaceIdParamSchema.merge(TransferOwnershipInputSchema))
|
|
71
|
+
.output(z.void()),
|
|
72
|
+
|
|
73
|
+
// Members
|
|
74
|
+
listMembers: oc
|
|
75
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/members' })
|
|
76
|
+
.input(WorkspaceIdParamSchema)
|
|
77
|
+
.output(z.array(WorkspaceMemberSchema)),
|
|
78
|
+
|
|
79
|
+
updateMember: oc
|
|
80
|
+
.route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}/members/{user_id}' })
|
|
81
|
+
.input(MemberIdParamSchema.merge(UpdateMemberInputSchema))
|
|
82
|
+
.output(WorkspaceMemberSchema),
|
|
83
|
+
|
|
84
|
+
removeMember: oc
|
|
85
|
+
.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/members/{user_id}' })
|
|
86
|
+
.input(MemberIdParamSchema)
|
|
87
|
+
.output(z.void()),
|
|
88
|
+
|
|
89
|
+
// Invitations
|
|
90
|
+
listInvitations: oc
|
|
91
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/invitations' })
|
|
92
|
+
.input(WorkspaceIdParamSchema)
|
|
93
|
+
.output(z.array(WorkspaceInvitationSchema)),
|
|
94
|
+
|
|
95
|
+
createInvitation: oc
|
|
96
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/invitations' })
|
|
97
|
+
.input(WorkspaceIdParamSchema.merge(CreateInvitationInputSchema))
|
|
98
|
+
.output(WorkspaceInvitationSchema),
|
|
99
|
+
|
|
100
|
+
revokeInvitation: oc
|
|
101
|
+
.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/invitations/{invitation_id}' })
|
|
102
|
+
.input(InvitationIdParamSchema)
|
|
103
|
+
.output(z.void()),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Invitations contract (public)
|
|
107
|
+
export const invitationsContract = {
|
|
108
|
+
get: oc.route({ method: 'GET', path: '/api/invitations/{token}' }).input(TokenParamSchema).output(WorkspaceInvitationSchema),
|
|
109
|
+
|
|
110
|
+
accept: oc.route({ method: 'POST', path: '/api/invitations/{token}/accept' }).input(TokenParamSchema).output(WorkspaceMemberSchema),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Links contract
|
|
114
|
+
export const linksContract = {
|
|
115
|
+
create: oc
|
|
116
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/links' })
|
|
117
|
+
.input(WorkspaceIdParamSchema.merge(CreateLinkInputSchema))
|
|
118
|
+
.output(LinkSchema),
|
|
119
|
+
|
|
120
|
+
list: oc
|
|
121
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/links' })
|
|
122
|
+
.input(WorkspaceIdParamSchema.merge(LinkFiltersSchema))
|
|
123
|
+
.output(PaginatedLinksSchema),
|
|
124
|
+
|
|
125
|
+
get: oc.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/links/{link_id}' }).input(LinkIdParamSchema).output(LinkSchema),
|
|
126
|
+
|
|
127
|
+
update: oc
|
|
128
|
+
.route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}/links/{link_id}' })
|
|
129
|
+
.input(LinkIdParamSchema.merge(UpdateLinkInputSchema))
|
|
130
|
+
.output(LinkSchema),
|
|
131
|
+
|
|
132
|
+
delete: oc
|
|
133
|
+
.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/links/{link_id}' })
|
|
134
|
+
.input(LinkIdParamSchema)
|
|
135
|
+
.output(z.void()),
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Tags contract
|
|
139
|
+
export const tagsContract = {
|
|
140
|
+
create: oc
|
|
141
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/tags' })
|
|
142
|
+
.input(WorkspaceIdParamSchema.merge(CreateTagInputSchema))
|
|
143
|
+
.output(TagSchema),
|
|
144
|
+
|
|
145
|
+
list: oc.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/tags' }).input(WorkspaceIdParamSchema).output(z.array(TagSchema)),
|
|
146
|
+
|
|
147
|
+
get: oc.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/tags/{tag_id}' }).input(TagIdParamSchema).output(TagSchema),
|
|
148
|
+
|
|
149
|
+
update: oc
|
|
150
|
+
.route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}/tags/{tag_id}' })
|
|
151
|
+
.input(TagIdParamSchema.merge(UpdateTagInputSchema))
|
|
152
|
+
.output(TagSchema),
|
|
153
|
+
|
|
154
|
+
delete: oc.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/tags/{tag_id}' }).input(TagIdParamSchema).output(z.void()),
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Domains contract
|
|
158
|
+
export const domainsContract = {
|
|
159
|
+
create: oc
|
|
160
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/domains' })
|
|
161
|
+
.input(WorkspaceIdParamSchema.merge(CreateDomainInputSchema))
|
|
162
|
+
.output(DomainSchema),
|
|
163
|
+
|
|
164
|
+
list: oc
|
|
165
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/domains' })
|
|
166
|
+
.input(WorkspaceIdParamSchema)
|
|
167
|
+
.output(z.array(DomainSchema)),
|
|
168
|
+
|
|
169
|
+
get: oc
|
|
170
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/domains/{domain_id}' })
|
|
171
|
+
.input(DomainIdParamSchema)
|
|
172
|
+
.output(DomainSchema),
|
|
173
|
+
|
|
174
|
+
update: oc
|
|
175
|
+
.route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}/domains/{domain_id}' })
|
|
176
|
+
.input(DomainIdParamSchema.merge(UpdateDomainInputSchema))
|
|
177
|
+
.output(DomainSchema),
|
|
178
|
+
|
|
179
|
+
delete: oc
|
|
180
|
+
.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/domains/{domain_id}' })
|
|
181
|
+
.input(DomainIdParamSchema)
|
|
182
|
+
.output(z.void()),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Full contract
|
|
186
|
+
export const contract = {
|
|
187
|
+
users: usersContract,
|
|
188
|
+
workspaces: workspacesContract,
|
|
189
|
+
invitations: invitationsContract,
|
|
190
|
+
links: linksContract,
|
|
191
|
+
tags: tagsContract,
|
|
192
|
+
domains: domainsContract,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export type Contract = typeof contract;
|
|
196
|
+
export type Client = ContractRouterClient<Contract>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { TagSchema } from './tags.schema';
|
|
4
|
+
|
|
5
|
+
export const LinkSchema = z.object({
|
|
6
|
+
id: z.string().uuid(),
|
|
7
|
+
workspace_id: z.string().uuid(),
|
|
8
|
+
domain_id: z.string().uuid(),
|
|
9
|
+
created_by_id: z.string().uuid(),
|
|
10
|
+
original_url: z.string().url(),
|
|
11
|
+
short_code: z.string(),
|
|
12
|
+
title: z.string().nullable(),
|
|
13
|
+
description: z.string().nullable(),
|
|
14
|
+
utm_source: z.string().nullable(),
|
|
15
|
+
utm_medium: z.string().nullable(),
|
|
16
|
+
utm_campaign: z.string().nullable(),
|
|
17
|
+
utm_term: z.string().nullable(),
|
|
18
|
+
utm_content: z.string().nullable(),
|
|
19
|
+
password: z.string().nullable(),
|
|
20
|
+
starts_at: z.coerce.date().nullable(),
|
|
21
|
+
expires_at: z.coerce.date().nullable(),
|
|
22
|
+
is_active: z.boolean(),
|
|
23
|
+
redirect_type: z.number().int(),
|
|
24
|
+
click_count: z.coerce.number().int(),
|
|
25
|
+
click_count_updated_at: z.coerce.date().nullable(),
|
|
26
|
+
created_at: z.coerce.date(),
|
|
27
|
+
updated_at: z.coerce.date().nullable(),
|
|
28
|
+
tags: z.array(TagSchema),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const CreateLinkInputSchema = z.object({
|
|
32
|
+
original_url: z.string().url().max(2048),
|
|
33
|
+
domain_id: z.string().uuid().optional(),
|
|
34
|
+
short_code: z
|
|
35
|
+
.string()
|
|
36
|
+
.min(3)
|
|
37
|
+
.max(50)
|
|
38
|
+
.regex(/^[a-zA-Z0-9-]+$/)
|
|
39
|
+
.optional(),
|
|
40
|
+
title: z.string().max(255).optional(),
|
|
41
|
+
description: z.string().max(2000).optional(),
|
|
42
|
+
utm_source: z.string().max(255).optional(),
|
|
43
|
+
utm_medium: z.string().max(255).optional(),
|
|
44
|
+
utm_campaign: z.string().max(255).optional(),
|
|
45
|
+
utm_term: z.string().max(255).optional(),
|
|
46
|
+
utm_content: z.string().max(255).optional(),
|
|
47
|
+
password: z.string().min(4).max(100).optional(),
|
|
48
|
+
starts_at: z.coerce.date().optional(),
|
|
49
|
+
expires_at: z.coerce.date().optional(),
|
|
50
|
+
redirect_type: z.coerce
|
|
51
|
+
.number()
|
|
52
|
+
.refine((v) => [301, 302, 307, 308].includes(v))
|
|
53
|
+
.optional(),
|
|
54
|
+
tag_ids: z.array(z.string().uuid()).optional(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const UpdateLinkInputSchema = z.object({
|
|
58
|
+
original_url: z.string().url().max(2048).optional(),
|
|
59
|
+
domain_id: z.string().uuid().optional(),
|
|
60
|
+
short_code: z
|
|
61
|
+
.string()
|
|
62
|
+
.min(3)
|
|
63
|
+
.max(50)
|
|
64
|
+
.regex(/^[a-zA-Z0-9-]+$/)
|
|
65
|
+
.optional(),
|
|
66
|
+
title: z.string().max(255).nullable().optional(),
|
|
67
|
+
description: z.string().max(2000).nullable().optional(),
|
|
68
|
+
utm_source: z.string().max(255).nullable().optional(),
|
|
69
|
+
utm_medium: z.string().max(255).nullable().optional(),
|
|
70
|
+
utm_campaign: z.string().max(255).nullable().optional(),
|
|
71
|
+
utm_term: z.string().max(255).nullable().optional(),
|
|
72
|
+
utm_content: z.string().max(255).nullable().optional(),
|
|
73
|
+
password: z.string().min(4).max(100).nullable().optional(),
|
|
74
|
+
starts_at: z.coerce.date().nullable().optional(),
|
|
75
|
+
expires_at: z.coerce.date().nullable().optional(),
|
|
76
|
+
is_active: z.boolean().optional(),
|
|
77
|
+
redirect_type: z.coerce
|
|
78
|
+
.number()
|
|
79
|
+
.refine((v) => [301, 302, 307, 308].includes(v))
|
|
80
|
+
.optional(),
|
|
81
|
+
tag_ids: z.array(z.string().uuid()).optional(),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const LinkFiltersSchema = z.object({
|
|
85
|
+
search: z.string().optional(),
|
|
86
|
+
domain_id: z.string().uuid().optional(),
|
|
87
|
+
is_active: z.coerce.boolean().optional(),
|
|
88
|
+
has_expiration: z.coerce.boolean().optional(),
|
|
89
|
+
expired: z.coerce.boolean().optional(),
|
|
90
|
+
created_from: z.coerce.date().optional(),
|
|
91
|
+
created_to: z.coerce.date().optional(),
|
|
92
|
+
expires_from: z.coerce.date().optional(),
|
|
93
|
+
expires_to: z.coerce.date().optional(),
|
|
94
|
+
tag_ids: z.array(z.string().uuid()).optional(),
|
|
95
|
+
sort_by: z.enum(['created_at', 'title', 'click_count']).default('created_at'),
|
|
96
|
+
sort_order: z.enum(['asc', 'desc']).default('desc'),
|
|
97
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
98
|
+
per_page: z.coerce.number().int().min(1).max(100).default(20),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const PaginatedLinksSchema = z.object({
|
|
102
|
+
links: z.array(LinkSchema),
|
|
103
|
+
total: z.number().int(),
|
|
104
|
+
page: z.number().int(),
|
|
105
|
+
per_page: z.number().int(),
|
|
106
|
+
total_pages: z.number().int(),
|
|
107
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const TagSchema = z.object({
|
|
4
|
+
id: z.string().uuid(),
|
|
5
|
+
workspace_id: z.string().uuid(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
color: z.string().nullable(),
|
|
8
|
+
created_at: z.coerce.date(),
|
|
9
|
+
updated_at: z.coerce.date().nullable(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const CreateTagInputSchema = z.object({
|
|
13
|
+
name: z.string().min(1).max(50),
|
|
14
|
+
color: z
|
|
15
|
+
.string()
|
|
16
|
+
.regex(/^#[0-9A-Fa-f]{6}$/)
|
|
17
|
+
.optional(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const UpdateTagInputSchema = z.object({
|
|
21
|
+
name: z.string().min(1).max(50).optional(),
|
|
22
|
+
color: z
|
|
23
|
+
.string()
|
|
24
|
+
.regex(/^#[0-9A-Fa-f]{6}$/)
|
|
25
|
+
.nullable()
|
|
26
|
+
.optional(),
|
|
27
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const UserSchema = z.object({
|
|
4
|
+
id: z.string().uuid(),
|
|
5
|
+
external_id: z.string(),
|
|
6
|
+
email: z.string().email(),
|
|
7
|
+
email_verified_at: z.coerce.date().nullable(),
|
|
8
|
+
first_name: z.string().nullable(),
|
|
9
|
+
last_name: z.string().nullable(),
|
|
10
|
+
created_at: z.coerce.date(),
|
|
11
|
+
updated_at: z.coerce.date().nullable(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const SignInInputSchema = z.object({
|
|
15
|
+
first_name: z.string().min(1).max(100).optional(),
|
|
16
|
+
last_name: z.string().min(1).max(100).optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const UpdateUserInputSchema = z.object({
|
|
20
|
+
first_name: z.string().min(1).max(100).optional(),
|
|
21
|
+
last_name: z.string().min(1).max(100).optional(),
|
|
22
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const WorkspaceSchema = z.object({
|
|
4
|
+
id: z.string().uuid(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
created_at: z.coerce.date(),
|
|
7
|
+
updated_at: z.coerce.date().nullable(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const WorkspaceWithCountSchema = WorkspaceSchema.extend({
|
|
11
|
+
member_count: z.number().int(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const CreateWorkspaceInputSchema = z.object({
|
|
15
|
+
name: z.string().min(1).max(100),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const UpdateWorkspaceInputSchema = z.object({
|
|
19
|
+
name: z.string().min(1).max(100).optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const TransferOwnershipInputSchema = z.object({
|
|
23
|
+
to_user_id: z.string().uuid(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Workspace member schemas
|
|
27
|
+
export const WorkspaceMemberUserSchema = z.object({
|
|
28
|
+
id: z.string().uuid(),
|
|
29
|
+
email: z.string().email(),
|
|
30
|
+
first_name: z.string().nullable(),
|
|
31
|
+
last_name: z.string().nullable(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const WorkspaceMemberSchema = z.object({
|
|
35
|
+
id: z.string().uuid(),
|
|
36
|
+
workspace_id: z.string().uuid(),
|
|
37
|
+
user_id: z.string().uuid(),
|
|
38
|
+
user: WorkspaceMemberUserSchema,
|
|
39
|
+
permissions: z.number().int(),
|
|
40
|
+
joined_at: z.coerce.date(),
|
|
41
|
+
created_at: z.coerce.date(),
|
|
42
|
+
updated_at: z.coerce.date().nullable(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const UpdateMemberInputSchema = z.object({
|
|
46
|
+
permissions: z.number().int().min(1),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Invitation schemas
|
|
50
|
+
export const WorkspaceInvitationSchema = z.object({
|
|
51
|
+
id: z.string().uuid(),
|
|
52
|
+
workspace_id: z.string().uuid(),
|
|
53
|
+
email: z.string().email(),
|
|
54
|
+
token: z.string(),
|
|
55
|
+
permissions: z.number().int(),
|
|
56
|
+
invited_by_id: z.string().uuid(),
|
|
57
|
+
expires_at: z.coerce.date(),
|
|
58
|
+
created_at: z.coerce.date(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const CreateInvitationInputSchema = z.object({
|
|
62
|
+
email: z.string().email(),
|
|
63
|
+
permissions: z.number().int().min(1),
|
|
64
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"outDir": "./dist/esm",
|
|
14
|
+
"rootDir": "./src"
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts"]
|
|
17
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/common.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;iBAG5B,C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O,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/links.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;iBAsBrB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;iBAuBhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;iBAwBhC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;iBAc5B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM/B,CAAC"}
|
package/cjs/tags.schema.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tags.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/tags.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS;;;;;;;iBAOpB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;iBAM/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;iBAO/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"users.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/users.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;;;;;;;iBASrB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;iBAGhC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/workspaces.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe;;;;;iBAK1B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;iBAEnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;iBAErC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;iBAErC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;iBAEvC,CAAC;AAGH,eAAO,MAAM,yBAAyB;;;;;iBAKpC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;iBAShC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAGH,eAAO,MAAM,yBAAyB;;;;;;;;;iBASpC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.schema.d.ts","sourceRoot":"","sources":["../../src/contracts/common.schema.ts"],"names":[],"mappings":"AAAA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