@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.
Files changed (55) hide show
  1. package/{cjs → dist/cjs}/common.schema.d.ts +4 -0
  2. package/dist/cjs/common.schema.d.ts.map +1 -0
  3. package/dist/cjs/domains.schema.d.ts +17 -0
  4. package/dist/cjs/domains.schema.d.ts.map +1 -0
  5. package/{esm → dist/cjs}/index.d.ts +197 -10
  6. package/dist/cjs/index.d.ts.map +1 -0
  7. package/{cjs → dist/cjs}/index.js +196 -145
  8. package/{cjs → dist/cjs}/links.schema.d.ts +24 -3
  9. package/dist/cjs/links.schema.d.ts.map +1 -0
  10. package/dist/cjs/tags.schema.d.ts.map +1 -0
  11. package/dist/cjs/users.schema.d.ts.map +1 -0
  12. package/dist/cjs/workspaces.schema.d.ts.map +1 -0
  13. package/{esm → dist/esm}/common.schema.d.ts +4 -0
  14. package/dist/esm/common.schema.d.ts.map +1 -0
  15. package/dist/esm/domains.schema.d.ts +17 -0
  16. package/dist/esm/domains.schema.d.ts.map +1 -0
  17. package/{cjs → dist/esm}/index.d.ts +197 -10
  18. package/dist/esm/index.d.ts.map +1 -0
  19. package/dist/esm/index.js +332 -0
  20. package/{esm → dist/esm}/links.schema.d.ts +24 -3
  21. package/dist/esm/links.schema.d.ts.map +1 -0
  22. package/dist/esm/tags.schema.d.ts.map +1 -0
  23. package/dist/esm/users.schema.d.ts.map +1 -0
  24. package/dist/esm/workspaces.schema.d.ts.map +1 -0
  25. package/package.json +20 -7
  26. package/scripts/build.sh +55 -0
  27. package/src/common.schema.ts +34 -0
  28. package/src/domains.schema.ts +32 -0
  29. package/src/index.ts +196 -0
  30. package/src/links.schema.ts +107 -0
  31. package/src/tags.schema.ts +27 -0
  32. package/src/users.schema.ts +22 -0
  33. package/src/workspaces.schema.ts +64 -0
  34. package/tsconfig.json +17 -0
  35. package/cjs/common.schema.d.ts.map +0 -1
  36. package/cjs/index.d.ts.map +0 -1
  37. package/cjs/links.schema.d.ts.map +0 -1
  38. package/cjs/tags.schema.d.ts.map +0 -1
  39. package/cjs/users.schema.d.ts.map +0 -1
  40. package/cjs/workspaces.schema.d.ts.map +0 -1
  41. package/esm/common.schema.d.ts.map +0 -1
  42. package/esm/index.d.ts.map +0 -1
  43. package/esm/index.js +0 -286
  44. package/esm/links.schema.d.ts.map +0 -1
  45. package/esm/tags.schema.d.ts.map +0 -1
  46. package/esm/users.schema.d.ts.map +0 -1
  47. package/esm/workspaces.schema.d.ts.map +0 -1
  48. /package/{cjs → dist/cjs}/package.json +0 -0
  49. /package/{cjs → dist/cjs}/tags.schema.d.ts +0 -0
  50. /package/{cjs → dist/cjs}/users.schema.d.ts +0 -0
  51. /package/{cjs → dist/cjs}/workspaces.schema.d.ts +0 -0
  52. /package/{esm → dist/esm}/package.json +0 -0
  53. /package/{esm → dist/esm}/tags.schema.d.ts +0 -0
  54. /package/{esm → dist/esm}/users.schema.d.ts +0 -0
  55. /package/{esm → dist/esm}/workspaces.schema.d.ts +0 -0
@@ -0,0 +1,332 @@
1
+ // src/index.ts
2
+ import { oc } from "@orpc/contract";
3
+ import { z as z7 } from "zod";
4
+
5
+ // src/common.schema.ts
6
+ import { z } from "zod";
7
+ var WorkspaceIdParamSchema = z.object({
8
+ workspace_id: z.string().uuid()
9
+ });
10
+ var LinkIdParamSchema = z.object({
11
+ workspace_id: z.string().uuid(),
12
+ link_id: z.string().uuid()
13
+ });
14
+ var TagIdParamSchema = z.object({
15
+ workspace_id: z.string().uuid(),
16
+ tag_id: z.string().uuid()
17
+ });
18
+ var MemberIdParamSchema = z.object({
19
+ workspace_id: z.string().uuid(),
20
+ user_id: z.string().uuid()
21
+ });
22
+ var InvitationIdParamSchema = z.object({
23
+ workspace_id: z.string().uuid(),
24
+ invitation_id: z.string().uuid()
25
+ });
26
+ var DomainIdParamSchema = z.object({
27
+ workspace_id: z.string().uuid(),
28
+ domain_id: z.string().uuid()
29
+ });
30
+ var TokenParamSchema = z.object({
31
+ token: z.string()
32
+ });
33
+
34
+ // src/domains.schema.ts
35
+ import { z as z2 } from "zod";
36
+ var DomainSchema = z2.object({
37
+ id: z2.string().uuid(),
38
+ workspace_id: z2.string().uuid().nullable(),
39
+ created_by_id: z2.string().uuid().nullable(),
40
+ domain: z2.string(),
41
+ is_verified: z2.boolean(),
42
+ created_at: z2.coerce.date(),
43
+ updated_at: z2.coerce.date().nullable()
44
+ });
45
+ var CreateDomainInputSchema = z2.object({
46
+ domain: z2.string().min(1).max(253).regex(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
47
+ message: "Invalid domain format"
48
+ })
49
+ });
50
+ var UpdateDomainInputSchema = z2.object({
51
+ domain: z2.string().min(1).max(253).regex(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
52
+ message: "Invalid domain format"
53
+ }).optional()
54
+ });
55
+
56
+ // src/links.schema.ts
57
+ import { z as z4 } from "zod";
58
+
59
+ // src/tags.schema.ts
60
+ import { z as z3 } from "zod";
61
+ var TagSchema = z3.object({
62
+ id: z3.string().uuid(),
63
+ workspace_id: z3.string().uuid(),
64
+ name: z3.string(),
65
+ color: z3.string().nullable(),
66
+ created_at: z3.coerce.date(),
67
+ updated_at: z3.coerce.date().nullable()
68
+ });
69
+ var CreateTagInputSchema = z3.object({
70
+ name: z3.string().min(1).max(50),
71
+ color: z3.string().regex(/^#[0-9A-Fa-f]{6}$/).optional()
72
+ });
73
+ var UpdateTagInputSchema = z3.object({
74
+ name: z3.string().min(1).max(50).optional(),
75
+ color: z3.string().regex(/^#[0-9A-Fa-f]{6}$/).nullable().optional()
76
+ });
77
+
78
+ // src/links.schema.ts
79
+ var LinkSchema = z4.object({
80
+ id: z4.string().uuid(),
81
+ workspace_id: z4.string().uuid(),
82
+ domain_id: z4.string().uuid(),
83
+ created_by_id: z4.string().uuid(),
84
+ original_url: z4.string().url(),
85
+ short_code: z4.string(),
86
+ title: z4.string().nullable(),
87
+ description: z4.string().nullable(),
88
+ utm_source: z4.string().nullable(),
89
+ utm_medium: z4.string().nullable(),
90
+ utm_campaign: z4.string().nullable(),
91
+ utm_term: z4.string().nullable(),
92
+ utm_content: z4.string().nullable(),
93
+ password: z4.string().nullable(),
94
+ starts_at: z4.coerce.date().nullable(),
95
+ expires_at: z4.coerce.date().nullable(),
96
+ is_active: z4.boolean(),
97
+ redirect_type: z4.number().int(),
98
+ click_count: z4.coerce.number().int(),
99
+ click_count_updated_at: z4.coerce.date().nullable(),
100
+ created_at: z4.coerce.date(),
101
+ updated_at: z4.coerce.date().nullable(),
102
+ tags: z4.array(TagSchema)
103
+ });
104
+ var CreateLinkInputSchema = z4.object({
105
+ original_url: z4.string().url().max(2048),
106
+ domain_id: z4.string().uuid().optional(),
107
+ short_code: z4.string().min(3).max(50).regex(/^[a-zA-Z0-9-]+$/).optional(),
108
+ title: z4.string().max(255).optional(),
109
+ description: z4.string().max(2e3).optional(),
110
+ utm_source: z4.string().max(255).optional(),
111
+ utm_medium: z4.string().max(255).optional(),
112
+ utm_campaign: z4.string().max(255).optional(),
113
+ utm_term: z4.string().max(255).optional(),
114
+ utm_content: z4.string().max(255).optional(),
115
+ password: z4.string().min(4).max(100).optional(),
116
+ starts_at: z4.coerce.date().optional(),
117
+ expires_at: z4.coerce.date().optional(),
118
+ redirect_type: z4.coerce.number().refine((v) => [301, 302, 307, 308].includes(v)).optional(),
119
+ tag_ids: z4.array(z4.string().uuid()).optional()
120
+ });
121
+ var UpdateLinkInputSchema = z4.object({
122
+ original_url: z4.string().url().max(2048).optional(),
123
+ domain_id: z4.string().uuid().optional(),
124
+ short_code: z4.string().min(3).max(50).regex(/^[a-zA-Z0-9-]+$/).optional(),
125
+ title: z4.string().max(255).nullable().optional(),
126
+ description: z4.string().max(2e3).nullable().optional(),
127
+ utm_source: z4.string().max(255).nullable().optional(),
128
+ utm_medium: z4.string().max(255).nullable().optional(),
129
+ utm_campaign: z4.string().max(255).nullable().optional(),
130
+ utm_term: z4.string().max(255).nullable().optional(),
131
+ utm_content: z4.string().max(255).nullable().optional(),
132
+ password: z4.string().min(4).max(100).nullable().optional(),
133
+ starts_at: z4.coerce.date().nullable().optional(),
134
+ expires_at: z4.coerce.date().nullable().optional(),
135
+ is_active: z4.boolean().optional(),
136
+ redirect_type: z4.coerce.number().refine((v) => [301, 302, 307, 308].includes(v)).optional(),
137
+ tag_ids: z4.array(z4.string().uuid()).optional()
138
+ });
139
+ var LinkFiltersSchema = z4.object({
140
+ search: z4.string().optional(),
141
+ domain_id: z4.string().uuid().optional(),
142
+ is_active: z4.coerce.boolean().optional(),
143
+ has_expiration: z4.coerce.boolean().optional(),
144
+ expired: z4.coerce.boolean().optional(),
145
+ created_from: z4.coerce.date().optional(),
146
+ created_to: z4.coerce.date().optional(),
147
+ expires_from: z4.coerce.date().optional(),
148
+ expires_to: z4.coerce.date().optional(),
149
+ tag_ids: z4.array(z4.string().uuid()).optional(),
150
+ sort_by: z4.enum(["created_at", "title", "click_count"]).default("created_at"),
151
+ sort_order: z4.enum(["asc", "desc"]).default("desc"),
152
+ page: z4.coerce.number().int().min(1).default(1),
153
+ per_page: z4.coerce.number().int().min(1).max(100).default(20)
154
+ });
155
+ var PaginatedLinksSchema = z4.object({
156
+ links: z4.array(LinkSchema),
157
+ total: z4.number().int(),
158
+ page: z4.number().int(),
159
+ per_page: z4.number().int(),
160
+ total_pages: z4.number().int()
161
+ });
162
+
163
+ // src/users.schema.ts
164
+ import { z as z5 } from "zod";
165
+ var UserSchema = z5.object({
166
+ id: z5.string().uuid(),
167
+ external_id: z5.string(),
168
+ email: z5.string().email(),
169
+ email_verified_at: z5.coerce.date().nullable(),
170
+ first_name: z5.string().nullable(),
171
+ last_name: z5.string().nullable(),
172
+ created_at: z5.coerce.date(),
173
+ updated_at: z5.coerce.date().nullable()
174
+ });
175
+ var SignInInputSchema = z5.object({
176
+ first_name: z5.string().min(1).max(100).optional(),
177
+ last_name: z5.string().min(1).max(100).optional()
178
+ });
179
+ var UpdateUserInputSchema = z5.object({
180
+ first_name: z5.string().min(1).max(100).optional(),
181
+ last_name: z5.string().min(1).max(100).optional()
182
+ });
183
+
184
+ // src/workspaces.schema.ts
185
+ import { z as z6 } from "zod";
186
+ var WorkspaceSchema = z6.object({
187
+ id: z6.string().uuid(),
188
+ name: z6.string(),
189
+ created_at: z6.coerce.date(),
190
+ updated_at: z6.coerce.date().nullable()
191
+ });
192
+ var WorkspaceWithCountSchema = WorkspaceSchema.extend({
193
+ member_count: z6.number().int()
194
+ });
195
+ var CreateWorkspaceInputSchema = z6.object({
196
+ name: z6.string().min(1).max(100)
197
+ });
198
+ var UpdateWorkspaceInputSchema = z6.object({
199
+ name: z6.string().min(1).max(100).optional()
200
+ });
201
+ var TransferOwnershipInputSchema = z6.object({
202
+ to_user_id: z6.string().uuid()
203
+ });
204
+ var WorkspaceMemberUserSchema = z6.object({
205
+ id: z6.string().uuid(),
206
+ email: z6.string().email(),
207
+ first_name: z6.string().nullable(),
208
+ last_name: z6.string().nullable()
209
+ });
210
+ var WorkspaceMemberSchema = z6.object({
211
+ id: z6.string().uuid(),
212
+ workspace_id: z6.string().uuid(),
213
+ user_id: z6.string().uuid(),
214
+ user: WorkspaceMemberUserSchema,
215
+ permissions: z6.number().int(),
216
+ joined_at: z6.coerce.date(),
217
+ created_at: z6.coerce.date(),
218
+ updated_at: z6.coerce.date().nullable()
219
+ });
220
+ var UpdateMemberInputSchema = z6.object({
221
+ permissions: z6.number().int().min(1)
222
+ });
223
+ var WorkspaceInvitationSchema = z6.object({
224
+ id: z6.string().uuid(),
225
+ workspace_id: z6.string().uuid(),
226
+ email: z6.string().email(),
227
+ token: z6.string(),
228
+ permissions: z6.number().int(),
229
+ invited_by_id: z6.string().uuid(),
230
+ expires_at: z6.coerce.date(),
231
+ created_at: z6.coerce.date()
232
+ });
233
+ var CreateInvitationInputSchema = z6.object({
234
+ email: z6.string().email(),
235
+ permissions: z6.number().int().min(1)
236
+ });
237
+
238
+ // src/index.ts
239
+ var usersContract = {
240
+ me: oc.route({ method: "GET", path: "/api/users/me" }).output(z7.object({ user: UserSchema })),
241
+ signIn: oc.route({ method: "POST", path: "/api/users" }).input(SignInInputSchema).output(z7.object({ user: UserSchema, status: z7.enum(["created", "existing"]) })),
242
+ update: oc.route({ method: "PATCH", path: "/api/users/me" }).input(UpdateUserInputSchema).output(z7.object({ user: UserSchema }))
243
+ };
244
+ var workspacesContract = {
245
+ create: oc.route({ method: "POST", path: "/api/workspaces" }).input(CreateWorkspaceInputSchema).output(WorkspaceSchema),
246
+ list: oc.route({ method: "GET", path: "/api/workspaces" }).output(z7.array(WorkspaceWithCountSchema)),
247
+ get: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}" }).input(WorkspaceIdParamSchema).output(WorkspaceWithCountSchema),
248
+ update: oc.route({ method: "PATCH", path: "/api/workspaces/{workspace_id}" }).input(WorkspaceIdParamSchema.merge(UpdateWorkspaceInputSchema)).output(WorkspaceSchema),
249
+ delete: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}" }).input(WorkspaceIdParamSchema).output(z7.void()),
250
+ transfer: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/transfer" }).input(WorkspaceIdParamSchema.merge(TransferOwnershipInputSchema)).output(z7.void()),
251
+ // Members
252
+ listMembers: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/members" }).input(WorkspaceIdParamSchema).output(z7.array(WorkspaceMemberSchema)),
253
+ updateMember: oc.route({ method: "PATCH", path: "/api/workspaces/{workspace_id}/members/{user_id}" }).input(MemberIdParamSchema.merge(UpdateMemberInputSchema)).output(WorkspaceMemberSchema),
254
+ removeMember: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/members/{user_id}" }).input(MemberIdParamSchema).output(z7.void()),
255
+ // Invitations
256
+ listInvitations: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/invitations" }).input(WorkspaceIdParamSchema).output(z7.array(WorkspaceInvitationSchema)),
257
+ createInvitation: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/invitations" }).input(WorkspaceIdParamSchema.merge(CreateInvitationInputSchema)).output(WorkspaceInvitationSchema),
258
+ revokeInvitation: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/invitations/{invitation_id}" }).input(InvitationIdParamSchema).output(z7.void())
259
+ };
260
+ var invitationsContract = {
261
+ get: oc.route({ method: "GET", path: "/api/invitations/{token}" }).input(TokenParamSchema).output(WorkspaceInvitationSchema),
262
+ accept: oc.route({ method: "POST", path: "/api/invitations/{token}/accept" }).input(TokenParamSchema).output(WorkspaceMemberSchema)
263
+ };
264
+ var linksContract = {
265
+ create: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/links" }).input(WorkspaceIdParamSchema.merge(CreateLinkInputSchema)).output(LinkSchema),
266
+ list: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/links" }).input(WorkspaceIdParamSchema.merge(LinkFiltersSchema)).output(PaginatedLinksSchema),
267
+ get: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/links/{link_id}" }).input(LinkIdParamSchema).output(LinkSchema),
268
+ update: oc.route({ method: "PATCH", path: "/api/workspaces/{workspace_id}/links/{link_id}" }).input(LinkIdParamSchema.merge(UpdateLinkInputSchema)).output(LinkSchema),
269
+ delete: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/links/{link_id}" }).input(LinkIdParamSchema).output(z7.void())
270
+ };
271
+ var tagsContract = {
272
+ create: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/tags" }).input(WorkspaceIdParamSchema.merge(CreateTagInputSchema)).output(TagSchema),
273
+ list: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/tags" }).input(WorkspaceIdParamSchema).output(z7.array(TagSchema)),
274
+ get: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/tags/{tag_id}" }).input(TagIdParamSchema).output(TagSchema),
275
+ update: oc.route({ method: "PATCH", path: "/api/workspaces/{workspace_id}/tags/{tag_id}" }).input(TagIdParamSchema.merge(UpdateTagInputSchema)).output(TagSchema),
276
+ delete: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/tags/{tag_id}" }).input(TagIdParamSchema).output(z7.void())
277
+ };
278
+ var domainsContract = {
279
+ create: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/domains" }).input(WorkspaceIdParamSchema.merge(CreateDomainInputSchema)).output(DomainSchema),
280
+ list: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/domains" }).input(WorkspaceIdParamSchema).output(z7.array(DomainSchema)),
281
+ get: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/domains/{domain_id}" }).input(DomainIdParamSchema).output(DomainSchema),
282
+ update: oc.route({ method: "PATCH", path: "/api/workspaces/{workspace_id}/domains/{domain_id}" }).input(DomainIdParamSchema.merge(UpdateDomainInputSchema)).output(DomainSchema),
283
+ delete: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/domains/{domain_id}" }).input(DomainIdParamSchema).output(z7.void())
284
+ };
285
+ var contract = {
286
+ users: usersContract,
287
+ workspaces: workspacesContract,
288
+ invitations: invitationsContract,
289
+ links: linksContract,
290
+ tags: tagsContract,
291
+ domains: domainsContract
292
+ };
293
+ export {
294
+ CreateDomainInputSchema,
295
+ CreateInvitationInputSchema,
296
+ CreateLinkInputSchema,
297
+ CreateTagInputSchema,
298
+ CreateWorkspaceInputSchema,
299
+ DomainIdParamSchema,
300
+ DomainSchema,
301
+ InvitationIdParamSchema,
302
+ LinkFiltersSchema,
303
+ LinkIdParamSchema,
304
+ LinkSchema,
305
+ MemberIdParamSchema,
306
+ PaginatedLinksSchema,
307
+ SignInInputSchema,
308
+ TagIdParamSchema,
309
+ TagSchema,
310
+ TokenParamSchema,
311
+ TransferOwnershipInputSchema,
312
+ UpdateDomainInputSchema,
313
+ UpdateLinkInputSchema,
314
+ UpdateMemberInputSchema,
315
+ UpdateTagInputSchema,
316
+ UpdateUserInputSchema,
317
+ UpdateWorkspaceInputSchema,
318
+ UserSchema,
319
+ WorkspaceIdParamSchema,
320
+ WorkspaceInvitationSchema,
321
+ WorkspaceMemberSchema,
322
+ WorkspaceMemberUserSchema,
323
+ WorkspaceSchema,
324
+ WorkspaceWithCountSchema,
325
+ contract,
326
+ domainsContract,
327
+ invitationsContract,
328
+ linksContract,
329
+ tagsContract,
330
+ usersContract,
331
+ workspacesContract
332
+ };
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  export declare const LinkSchema: z.ZodObject<{
3
3
  id: z.ZodString;
4
4
  workspace_id: z.ZodString;
5
+ domain_id: z.ZodString;
5
6
  created_by_id: z.ZodString;
6
7
  original_url: z.ZodString;
7
8
  short_code: z.ZodString;
@@ -17,13 +18,22 @@ export declare const LinkSchema: z.ZodObject<{
17
18
  expires_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
18
19
  is_active: z.ZodBoolean;
19
20
  redirect_type: z.ZodNumber;
20
- click_count: z.ZodNumber;
21
+ click_count: z.ZodCoercedNumber<unknown>;
21
22
  click_count_updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
22
23
  created_at: z.ZodCoercedDate<unknown>;
23
24
  updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
25
+ tags: z.ZodArray<z.ZodObject<{
26
+ id: z.ZodString;
27
+ workspace_id: z.ZodString;
28
+ name: z.ZodString;
29
+ color: z.ZodNullable<z.ZodString>;
30
+ created_at: z.ZodCoercedDate<unknown>;
31
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
32
+ }, z.core.$strip>>;
24
33
  }, z.core.$strip>;
25
34
  export declare const CreateLinkInputSchema: z.ZodObject<{
26
35
  original_url: z.ZodString;
36
+ domain_id: z.ZodOptional<z.ZodString>;
27
37
  short_code: z.ZodOptional<z.ZodString>;
28
38
  title: z.ZodOptional<z.ZodString>;
29
39
  description: z.ZodOptional<z.ZodString>;
@@ -40,6 +50,7 @@ export declare const CreateLinkInputSchema: z.ZodObject<{
40
50
  }, z.core.$strip>;
41
51
  export declare const UpdateLinkInputSchema: z.ZodObject<{
42
52
  original_url: z.ZodOptional<z.ZodString>;
53
+ domain_id: z.ZodOptional<z.ZodString>;
43
54
  short_code: z.ZodOptional<z.ZodString>;
44
55
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
56
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -57,6 +68,7 @@ export declare const UpdateLinkInputSchema: z.ZodObject<{
57
68
  }, z.core.$strip>;
58
69
  export declare const LinkFiltersSchema: z.ZodObject<{
59
70
  search: z.ZodOptional<z.ZodString>;
71
+ domain_id: z.ZodOptional<z.ZodString>;
60
72
  is_active: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
61
73
  has_expiration: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
62
74
  expired: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
@@ -66,9 +78,9 @@ export declare const LinkFiltersSchema: z.ZodObject<{
66
78
  expires_to: z.ZodOptional<z.ZodCoercedDate<unknown>>;
67
79
  tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
80
  sort_by: z.ZodDefault<z.ZodEnum<{
81
+ created_at: "created_at";
69
82
  title: "title";
70
83
  click_count: "click_count";
71
- created_at: "created_at";
72
84
  }>>;
73
85
  sort_order: z.ZodDefault<z.ZodEnum<{
74
86
  asc: "asc";
@@ -81,6 +93,7 @@ export declare const PaginatedLinksSchema: z.ZodObject<{
81
93
  links: z.ZodArray<z.ZodObject<{
82
94
  id: z.ZodString;
83
95
  workspace_id: z.ZodString;
96
+ domain_id: z.ZodString;
84
97
  created_by_id: z.ZodString;
85
98
  original_url: z.ZodString;
86
99
  short_code: z.ZodString;
@@ -96,10 +109,18 @@ export declare const PaginatedLinksSchema: z.ZodObject<{
96
109
  expires_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
97
110
  is_active: z.ZodBoolean;
98
111
  redirect_type: z.ZodNumber;
99
- click_count: z.ZodNumber;
112
+ click_count: z.ZodCoercedNumber<unknown>;
100
113
  click_count_updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
101
114
  created_at: z.ZodCoercedDate<unknown>;
102
115
  updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
116
+ tags: z.ZodArray<z.ZodObject<{
117
+ id: z.ZodString;
118
+ workspace_id: z.ZodString;
119
+ name: z.ZodString;
120
+ color: z.ZodNullable<z.ZodString>;
121
+ created_at: z.ZodCoercedDate<unknown>;
122
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
123
+ }, z.core.$strip>>;
103
124
  }, z.core.$strip>>;
104
125
  total: z.ZodNumber;
105
126
  page: z.ZodNumber;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.schema.d.ts","sourceRoot":"","sources":["../../src/links.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwBrB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;iBAwBhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;iBAyBhC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;iBAe5B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM/B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags.schema.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.schema.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.schema.d.ts","sourceRoot":"","sources":["../../src/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"}
package/package.json CHANGED
@@ -1,21 +1,34 @@
1
1
  {
2
2
  "name": "@middlewr/contracts",
3
- "version": "0.0.7",
4
- "main": "./cjs/index.js",
5
- "module": "./esm/index.js",
6
- "types": "./esm/index.d.ts",
3
+ "version": "0.0.8",
4
+ "type": "module",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "types": "./dist/esm/index.d.ts",
7
8
  "exports": {
8
9
  ".": {
9
- "types": "./esm/index.d.ts",
10
- "import": "./esm/index.js",
11
- "require": "./cjs/index.js"
10
+ "types": "./dist/esm/index.d.ts",
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js"
12
13
  }
13
14
  },
15
+ "scripts": {
16
+ "build": "./scripts/build.sh",
17
+ "lint": "biome check src",
18
+ "lint:fix": "biome check --write src"
19
+ },
14
20
  "peerDependencies": {
15
21
  "@orpc/client": "^1.13",
16
22
  "@orpc/contract": "^1.13",
17
23
  "zod": "^4.0.0"
18
24
  },
25
+ "devDependencies": {
26
+ "@orpc/client": "^1.13.4",
27
+ "@orpc/contract": "^1.13",
28
+ "esbuild": "^0.25.0",
29
+ "typescript": "^5.7",
30
+ "zod": "^4.3.5"
31
+ },
19
32
  "publishConfig": {
20
33
  "access": "public"
21
34
  }
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ OUT_DIR="dist"
5
+
6
+ # Clean previous build
7
+ rm -rf "$OUT_DIR"
8
+ mkdir -p "$OUT_DIR/cjs" "$OUT_DIR/esm"
9
+
10
+ # Generate type definitions only
11
+ echo "Generating type definitions..."
12
+ npx tsc --declaration --emitDeclarationOnly
13
+
14
+ # Bundle for ESM using esbuild
15
+ echo "Bundling contracts (ESM)..."
16
+ npx esbuild src/index.ts \
17
+ --bundle \
18
+ --platform=node \
19
+ --format=esm \
20
+ --outfile="$OUT_DIR/esm/index.js" \
21
+ --external:zod \
22
+ --external:@orpc/client \
23
+ --external:@orpc/contract
24
+
25
+ # Bundle for CJS using esbuild
26
+ echo "Bundling contracts (CJS)..."
27
+ npx esbuild src/index.ts \
28
+ --bundle \
29
+ --platform=node \
30
+ --format=cjs \
31
+ --outfile="$OUT_DIR/cjs/index.js" \
32
+ --external:zod \
33
+ --external:@orpc/client \
34
+ --external:@orpc/contract
35
+
36
+ # Copy type definitions to cjs folder
37
+ cp "$OUT_DIR/esm/"*.d.ts "$OUT_DIR/cjs/" 2>/dev/null || true
38
+ cp "$OUT_DIR/esm/"*.d.ts.map "$OUT_DIR/cjs/" 2>/dev/null || true
39
+
40
+ # Add package.json to esm folder to mark it as ESM
41
+ cat > "$OUT_DIR/esm/package.json" << 'EOF'
42
+ {
43
+ "type": "module"
44
+ }
45
+ EOF
46
+
47
+ # Add package.json to cjs folder to mark it as CJS
48
+ cat > "$OUT_DIR/cjs/package.json" << 'EOF'
49
+ {
50
+ "type": "commonjs"
51
+ }
52
+ EOF
53
+
54
+ echo ""
55
+ echo "Build complete: $OUT_DIR/"
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+
3
+ export const WorkspaceIdParamSchema = z.object({
4
+ workspace_id: z.string().uuid(),
5
+ });
6
+
7
+ export const LinkIdParamSchema = z.object({
8
+ workspace_id: z.string().uuid(),
9
+ link_id: z.string().uuid(),
10
+ });
11
+
12
+ export const TagIdParamSchema = z.object({
13
+ workspace_id: z.string().uuid(),
14
+ tag_id: z.string().uuid(),
15
+ });
16
+
17
+ export const MemberIdParamSchema = z.object({
18
+ workspace_id: z.string().uuid(),
19
+ user_id: z.string().uuid(),
20
+ });
21
+
22
+ export const InvitationIdParamSchema = z.object({
23
+ workspace_id: z.string().uuid(),
24
+ invitation_id: z.string().uuid(),
25
+ });
26
+
27
+ export const DomainIdParamSchema = z.object({
28
+ workspace_id: z.string().uuid(),
29
+ domain_id: z.string().uuid(),
30
+ });
31
+
32
+ export const TokenParamSchema = z.object({
33
+ token: z.string(),
34
+ });
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+
3
+ export const DomainSchema = z.object({
4
+ id: z.string().uuid(),
5
+ workspace_id: z.string().uuid().nullable(),
6
+ created_by_id: z.string().uuid().nullable(),
7
+ domain: z.string(),
8
+ is_verified: z.boolean(),
9
+ created_at: z.coerce.date(),
10
+ updated_at: z.coerce.date().nullable(),
11
+ });
12
+
13
+ export const CreateDomainInputSchema = z.object({
14
+ domain: z
15
+ .string()
16
+ .min(1)
17
+ .max(253)
18
+ .regex(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
19
+ message: 'Invalid domain format',
20
+ }),
21
+ });
22
+
23
+ export const UpdateDomainInputSchema = z.object({
24
+ domain: z
25
+ .string()
26
+ .min(1)
27
+ .max(253)
28
+ .regex(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
29
+ message: 'Invalid domain format',
30
+ })
31
+ .optional(),
32
+ });