@middlewr/contracts 0.0.2 → 0.0.3

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 (46) hide show
  1. package/cjs/common.schema.d.ts.map +1 -0
  2. package/{index.d.ts → cjs/index.d.ts} +54 -54
  3. package/cjs/index.d.ts.map +1 -0
  4. package/cjs/index.js +334 -0
  5. package/cjs/links.schema.d.ts.map +1 -0
  6. package/cjs/package.json +3 -0
  7. package/cjs/tags.schema.d.ts.map +1 -0
  8. package/cjs/users.schema.d.ts.map +1 -0
  9. package/cjs/workspaces.schema.d.ts.map +1 -0
  10. package/esm/common.schema.d.ts +24 -0
  11. package/esm/common.schema.d.ts.map +1 -0
  12. package/esm/common.schema.js +23 -0
  13. package/esm/index.d.ts +780 -0
  14. package/esm/index.d.ts.map +1 -0
  15. package/esm/index.js +107 -0
  16. package/esm/links.schema.d.ts +109 -0
  17. package/esm/links.schema.d.ts.map +1 -0
  18. package/esm/links.schema.js +95 -0
  19. package/esm/package.json +3 -0
  20. package/esm/tags.schema.d.ts +18 -0
  21. package/esm/tags.schema.d.ts.map +1 -0
  22. package/esm/tags.schema.js +24 -0
  23. package/esm/users.schema.d.ts +20 -0
  24. package/esm/users.schema.d.ts.map +1 -0
  25. package/esm/users.schema.js +19 -0
  26. package/esm/workspaces.schema.d.ts +50 -0
  27. package/esm/workspaces.schema.d.ts.map +1 -0
  28. package/esm/workspaces.schema.js +47 -0
  29. package/package.json +7 -6
  30. package/common.schema.d.ts.map +0 -1
  31. package/common.schema.js +0 -26
  32. package/index.d.ts.map +0 -1
  33. package/index.js +0 -124
  34. package/links.schema.d.ts.map +0 -1
  35. package/links.schema.js +0 -98
  36. package/tags.schema.d.ts.map +0 -1
  37. package/tags.schema.js +0 -27
  38. package/users.schema.d.ts.map +0 -1
  39. package/users.schema.js +0 -22
  40. package/workspaces.schema.d.ts.map +0 -1
  41. package/workspaces.schema.js +0 -50
  42. /package/{common.schema.d.ts → cjs/common.schema.d.ts} +0 -0
  43. /package/{links.schema.d.ts → cjs/links.schema.d.ts} +0 -0
  44. /package/{tags.schema.d.ts → cjs/tags.schema.d.ts} +0 -0
  45. /package/{users.schema.d.ts → cjs/users.schema.d.ts} +0 -0
  46. /package/{workspaces.schema.d.ts → cjs/workspaces.schema.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAE9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAGpC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASzB,CAAC;AAGF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkD9B,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;CAI/B,CAAC;AAGF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAGF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBxB,CAAC;AAGF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC"}
package/esm/index.js ADDED
@@ -0,0 +1,107 @@
1
+ import { oc } from '@orpc/contract';
2
+ import { z } from 'zod';
3
+ import { InvitationIdParamSchema, LinkIdParamSchema, MemberIdParamSchema, TagIdParamSchema, TokenParamSchema, WorkspaceIdParamSchema, } from './common.schema';
4
+ import { CreateLinkInputSchema, LinkFiltersSchema, LinkSchema, PaginatedLinksSchema, UpdateLinkInputSchema } from './links.schema';
5
+ import { CreateTagInputSchema, TagSchema, UpdateTagInputSchema } from './tags.schema';
6
+ import { SignInInputSchema, UpdateUserInputSchema, UserSchema } from './users.schema';
7
+ import { CreateInvitationInputSchema, CreateWorkspaceInputSchema, TransferOwnershipInputSchema, UpdateMemberInputSchema, UpdateWorkspaceInputSchema, WorkspaceInvitationSchema, WorkspaceMemberSchema, WorkspaceSchema, WorkspaceWithCountSchema, } from './workspaces.schema';
8
+ export * from './common.schema';
9
+ export * from './links.schema';
10
+ export * from './tags.schema';
11
+ // Re-export all schemas
12
+ export * from './users.schema';
13
+ export * from './workspaces.schema';
14
+ // Users contract
15
+ export const usersContract = {
16
+ me: oc.route({ method: 'GET', path: '/api/users/me' }).output(UserSchema),
17
+ signIn: oc
18
+ .route({ method: 'POST', path: '/api/users' })
19
+ .input(SignInInputSchema)
20
+ .output(z.object({ user: UserSchema, status: z.enum(['created', 'existing']) })),
21
+ update: oc.route({ method: 'PATCH', path: '/api/users/me' }).input(UpdateUserInputSchema).output(UserSchema),
22
+ };
23
+ // Workspaces contract
24
+ export const workspacesContract = {
25
+ create: oc.route({ method: 'POST', path: '/api/workspaces' }).input(CreateWorkspaceInputSchema).output(WorkspaceSchema),
26
+ list: oc.route({ method: 'GET', path: '/api/workspaces' }).output(z.array(WorkspaceWithCountSchema)),
27
+ get: oc.route({ method: 'GET', path: '/api/workspaces/{workspaceId}' }).input(WorkspaceIdParamSchema).output(WorkspaceWithCountSchema),
28
+ update: oc
29
+ .route({ method: 'PATCH', path: '/api/workspaces/{workspaceId}' })
30
+ .input(WorkspaceIdParamSchema.merge(UpdateWorkspaceInputSchema))
31
+ .output(WorkspaceSchema),
32
+ delete: oc.route({ method: 'DELETE', path: '/api/workspaces/{workspaceId}' }).input(WorkspaceIdParamSchema).output(z.void()),
33
+ transfer: oc
34
+ .route({ method: 'POST', path: '/api/workspaces/{workspaceId}/transfer' })
35
+ .input(WorkspaceIdParamSchema.merge(TransferOwnershipInputSchema))
36
+ .output(z.void()),
37
+ // Members
38
+ listMembers: oc
39
+ .route({ method: 'GET', path: '/api/workspaces/{workspaceId}/members' })
40
+ .input(WorkspaceIdParamSchema)
41
+ .output(z.array(WorkspaceMemberSchema)),
42
+ updateMember: oc
43
+ .route({ method: 'PATCH', path: '/api/workspaces/{workspaceId}/members/{userId}' })
44
+ .input(MemberIdParamSchema.merge(UpdateMemberInputSchema))
45
+ .output(WorkspaceMemberSchema),
46
+ removeMember: oc
47
+ .route({ method: 'DELETE', path: '/api/workspaces/{workspaceId}/members/{userId}' })
48
+ .input(MemberIdParamSchema)
49
+ .output(z.void()),
50
+ // Invitations
51
+ listInvitations: oc
52
+ .route({ method: 'GET', path: '/api/workspaces/{workspaceId}/invitations' })
53
+ .input(WorkspaceIdParamSchema)
54
+ .output(z.array(WorkspaceInvitationSchema)),
55
+ createInvitation: oc
56
+ .route({ method: 'POST', path: '/api/workspaces/{workspaceId}/invitations' })
57
+ .input(WorkspaceIdParamSchema.merge(CreateInvitationInputSchema))
58
+ .output(WorkspaceInvitationSchema),
59
+ revokeInvitation: oc
60
+ .route({ method: 'DELETE', path: '/api/workspaces/{workspaceId}/invitations/{invitationId}' })
61
+ .input(InvitationIdParamSchema)
62
+ .output(z.void()),
63
+ };
64
+ // Invitations contract (public)
65
+ export const invitationsContract = {
66
+ get: oc.route({ method: 'GET', path: '/api/invitations/{token}' }).input(TokenParamSchema).output(WorkspaceInvitationSchema),
67
+ accept: oc.route({ method: 'POST', path: '/api/invitations/{token}/accept' }).input(TokenParamSchema).output(WorkspaceMemberSchema),
68
+ };
69
+ // Links contract
70
+ export const linksContract = {
71
+ create: oc
72
+ .route({ method: 'POST', path: '/api/workspaces/{workspaceId}/links' })
73
+ .input(WorkspaceIdParamSchema.merge(CreateLinkInputSchema))
74
+ .output(LinkSchema),
75
+ list: oc
76
+ .route({ method: 'GET', path: '/api/workspaces/{workspaceId}/links' })
77
+ .input(WorkspaceIdParamSchema.merge(LinkFiltersSchema))
78
+ .output(PaginatedLinksSchema),
79
+ get: oc.route({ method: 'GET', path: '/api/workspaces/{workspaceId}/links/{linkId}' }).input(LinkIdParamSchema).output(LinkSchema),
80
+ update: oc
81
+ .route({ method: 'PATCH', path: '/api/workspaces/{workspaceId}/links/{linkId}' })
82
+ .input(LinkIdParamSchema.merge(UpdateLinkInputSchema))
83
+ .output(LinkSchema),
84
+ delete: oc.route({ method: 'DELETE', path: '/api/workspaces/{workspaceId}/links/{linkId}' }).input(LinkIdParamSchema).output(z.void()),
85
+ };
86
+ // Tags contract
87
+ export const tagsContract = {
88
+ create: oc
89
+ .route({ method: 'POST', path: '/api/workspaces/{workspaceId}/tags' })
90
+ .input(WorkspaceIdParamSchema.merge(CreateTagInputSchema))
91
+ .output(TagSchema),
92
+ list: oc.route({ method: 'GET', path: '/api/workspaces/{workspaceId}/tags' }).input(WorkspaceIdParamSchema).output(z.array(TagSchema)),
93
+ get: oc.route({ method: 'GET', path: '/api/workspaces/{workspaceId}/tags/{tagId}' }).input(TagIdParamSchema).output(TagSchema),
94
+ update: oc
95
+ .route({ method: 'PATCH', path: '/api/workspaces/{workspaceId}/tags/{tagId}' })
96
+ .input(TagIdParamSchema.merge(UpdateTagInputSchema))
97
+ .output(TagSchema),
98
+ delete: oc.route({ method: 'DELETE', path: '/api/workspaces/{workspaceId}/tags/{tagId}' }).input(TagIdParamSchema).output(z.void()),
99
+ };
100
+ // Full contract
101
+ export const contract = {
102
+ users: usersContract,
103
+ workspaces: workspacesContract,
104
+ invitations: invitationsContract,
105
+ links: linksContract,
106
+ tags: tagsContract,
107
+ };
@@ -0,0 +1,109 @@
1
+ import { z } from 'zod';
2
+ export declare const LinkSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ workspace_id: z.ZodString;
5
+ created_by_id: z.ZodString;
6
+ original_url: z.ZodString;
7
+ short_code: z.ZodString;
8
+ title: z.ZodNullable<z.ZodString>;
9
+ description: z.ZodNullable<z.ZodString>;
10
+ utm_source: z.ZodNullable<z.ZodString>;
11
+ utm_medium: z.ZodNullable<z.ZodString>;
12
+ utm_campaign: z.ZodNullable<z.ZodString>;
13
+ utm_term: z.ZodNullable<z.ZodString>;
14
+ utm_content: z.ZodNullable<z.ZodString>;
15
+ password: z.ZodNullable<z.ZodString>;
16
+ starts_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
17
+ expires_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
18
+ is_active: z.ZodBoolean;
19
+ redirect_type: z.ZodNumber;
20
+ click_count: z.ZodNumber;
21
+ click_count_updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
22
+ created_at: z.ZodCoercedDate<unknown>;
23
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
24
+ }, z.core.$strip>;
25
+ export declare const CreateLinkInputSchema: z.ZodObject<{
26
+ original_url: z.ZodString;
27
+ short_code: z.ZodOptional<z.ZodString>;
28
+ title: z.ZodOptional<z.ZodString>;
29
+ description: z.ZodOptional<z.ZodString>;
30
+ utm_source: z.ZodOptional<z.ZodString>;
31
+ utm_medium: z.ZodOptional<z.ZodString>;
32
+ utm_campaign: z.ZodOptional<z.ZodString>;
33
+ utm_term: z.ZodOptional<z.ZodString>;
34
+ utm_content: z.ZodOptional<z.ZodString>;
35
+ password: z.ZodOptional<z.ZodString>;
36
+ starts_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
37
+ expires_at: z.ZodOptional<z.ZodCoercedDate<unknown>>;
38
+ redirect_type: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
39
+ tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
40
+ }, z.core.$strip>;
41
+ export declare const UpdateLinkInputSchema: z.ZodObject<{
42
+ original_url: z.ZodOptional<z.ZodString>;
43
+ short_code: z.ZodOptional<z.ZodString>;
44
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ utm_source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ utm_medium: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ utm_campaign: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ utm_term: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ utm_content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ starts_at: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
53
+ expires_at: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
54
+ is_active: z.ZodOptional<z.ZodBoolean>;
55
+ redirect_type: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
56
+ tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
57
+ }, z.core.$strip>;
58
+ export declare const LinkFiltersSchema: z.ZodObject<{
59
+ search: z.ZodOptional<z.ZodString>;
60
+ is_active: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
61
+ has_expiration: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
62
+ expired: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
63
+ created_from: z.ZodOptional<z.ZodCoercedDate<unknown>>;
64
+ created_to: z.ZodOptional<z.ZodCoercedDate<unknown>>;
65
+ expires_from: z.ZodOptional<z.ZodCoercedDate<unknown>>;
66
+ expires_to: z.ZodOptional<z.ZodCoercedDate<unknown>>;
67
+ tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ sort_by: z.ZodDefault<z.ZodEnum<{
69
+ title: "title";
70
+ click_count: "click_count";
71
+ created_at: "created_at";
72
+ }>>;
73
+ sort_order: z.ZodDefault<z.ZodEnum<{
74
+ asc: "asc";
75
+ desc: "desc";
76
+ }>>;
77
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
78
+ per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
79
+ }, z.core.$strip>;
80
+ export declare const PaginatedLinksSchema: z.ZodObject<{
81
+ links: z.ZodArray<z.ZodObject<{
82
+ id: z.ZodString;
83
+ workspace_id: z.ZodString;
84
+ created_by_id: z.ZodString;
85
+ original_url: z.ZodString;
86
+ short_code: z.ZodString;
87
+ title: z.ZodNullable<z.ZodString>;
88
+ description: z.ZodNullable<z.ZodString>;
89
+ utm_source: z.ZodNullable<z.ZodString>;
90
+ utm_medium: z.ZodNullable<z.ZodString>;
91
+ utm_campaign: z.ZodNullable<z.ZodString>;
92
+ utm_term: z.ZodNullable<z.ZodString>;
93
+ utm_content: z.ZodNullable<z.ZodString>;
94
+ password: z.ZodNullable<z.ZodString>;
95
+ starts_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
96
+ expires_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
97
+ is_active: z.ZodBoolean;
98
+ redirect_type: z.ZodNumber;
99
+ click_count: z.ZodNumber;
100
+ click_count_updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
101
+ created_at: z.ZodCoercedDate<unknown>;
102
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
103
+ }, z.core.$strip>>;
104
+ total: z.ZodNumber;
105
+ page: z.ZodNumber;
106
+ per_page: z.ZodNumber;
107
+ total_pages: z.ZodNumber;
108
+ }, z.core.$strip>;
109
+ //# sourceMappingURL=links.schema.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,95 @@
1
+ import { z } from 'zod';
2
+ export const LinkSchema = z.object({
3
+ id: z.string().uuid(),
4
+ workspace_id: z.string().uuid(),
5
+ created_by_id: z.string().uuid(),
6
+ original_url: z.string().url(),
7
+ short_code: z.string(),
8
+ title: z.string().nullable(),
9
+ description: z.string().nullable(),
10
+ utm_source: z.string().nullable(),
11
+ utm_medium: z.string().nullable(),
12
+ utm_campaign: z.string().nullable(),
13
+ utm_term: z.string().nullable(),
14
+ utm_content: z.string().nullable(),
15
+ password: z.string().nullable(),
16
+ starts_at: z.coerce.date().nullable(),
17
+ expires_at: z.coerce.date().nullable(),
18
+ is_active: z.boolean(),
19
+ redirect_type: z.number().int(),
20
+ click_count: z.number().int(),
21
+ click_count_updated_at: z.coerce.date().nullable(),
22
+ created_at: z.coerce.date(),
23
+ updated_at: z.coerce.date().nullable(),
24
+ });
25
+ export const CreateLinkInputSchema = z.object({
26
+ original_url: z.string().url().max(2048),
27
+ short_code: z
28
+ .string()
29
+ .min(3)
30
+ .max(50)
31
+ .regex(/^[a-zA-Z0-9-]+$/)
32
+ .optional(),
33
+ title: z.string().max(255).optional(),
34
+ description: z.string().max(2000).optional(),
35
+ utm_source: z.string().max(255).optional(),
36
+ utm_medium: z.string().max(255).optional(),
37
+ utm_campaign: z.string().max(255).optional(),
38
+ utm_term: z.string().max(255).optional(),
39
+ utm_content: z.string().max(255).optional(),
40
+ password: z.string().min(4).max(100).optional(),
41
+ starts_at: z.coerce.date().optional(),
42
+ expires_at: z.coerce.date().optional(),
43
+ redirect_type: z.coerce
44
+ .number()
45
+ .refine((v) => [301, 302, 307, 308].includes(v))
46
+ .optional(),
47
+ tag_ids: z.array(z.string().uuid()).optional(),
48
+ });
49
+ export const UpdateLinkInputSchema = z.object({
50
+ original_url: z.string().url().max(2048).optional(),
51
+ short_code: z
52
+ .string()
53
+ .min(3)
54
+ .max(50)
55
+ .regex(/^[a-zA-Z0-9-]+$/)
56
+ .optional(),
57
+ title: z.string().max(255).nullable().optional(),
58
+ description: z.string().max(2000).nullable().optional(),
59
+ utm_source: z.string().max(255).nullable().optional(),
60
+ utm_medium: z.string().max(255).nullable().optional(),
61
+ utm_campaign: z.string().max(255).nullable().optional(),
62
+ utm_term: z.string().max(255).nullable().optional(),
63
+ utm_content: z.string().max(255).nullable().optional(),
64
+ password: z.string().min(4).max(100).nullable().optional(),
65
+ starts_at: z.coerce.date().nullable().optional(),
66
+ expires_at: z.coerce.date().nullable().optional(),
67
+ is_active: z.boolean().optional(),
68
+ redirect_type: z.coerce
69
+ .number()
70
+ .refine((v) => [301, 302, 307, 308].includes(v))
71
+ .optional(),
72
+ tag_ids: z.array(z.string().uuid()).optional(),
73
+ });
74
+ export const LinkFiltersSchema = z.object({
75
+ search: z.string().optional(),
76
+ is_active: z.coerce.boolean().optional(),
77
+ has_expiration: z.coerce.boolean().optional(),
78
+ expired: z.coerce.boolean().optional(),
79
+ created_from: z.coerce.date().optional(),
80
+ created_to: z.coerce.date().optional(),
81
+ expires_from: z.coerce.date().optional(),
82
+ expires_to: z.coerce.date().optional(),
83
+ tag_ids: z.array(z.string().uuid()).optional(),
84
+ sort_by: z.enum(['created_at', 'title', 'click_count']).default('created_at'),
85
+ sort_order: z.enum(['asc', 'desc']).default('desc'),
86
+ page: z.coerce.number().int().min(1).default(1),
87
+ per_page: z.coerce.number().int().min(1).max(100).default(20),
88
+ });
89
+ export const PaginatedLinksSchema = z.object({
90
+ links: z.array(LinkSchema),
91
+ total: z.number().int(),
92
+ page: z.number().int(),
93
+ per_page: z.number().int(),
94
+ total_pages: z.number().int(),
95
+ });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const TagSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ workspace_id: z.ZodString;
5
+ name: z.ZodString;
6
+ color: z.ZodNullable<z.ZodString>;
7
+ created_at: z.ZodCoercedDate<unknown>;
8
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
9
+ }, z.core.$strip>;
10
+ export declare const CreateTagInputSchema: z.ZodObject<{
11
+ name: z.ZodString;
12
+ color: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
14
+ export declare const UpdateTagInputSchema: z.ZodObject<{
15
+ name: z.ZodOptional<z.ZodString>;
16
+ color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ }, z.core.$strip>;
18
+ //# sourceMappingURL=tags.schema.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export const TagSchema = z.object({
3
+ id: z.string().uuid(),
4
+ workspace_id: z.string().uuid(),
5
+ name: z.string(),
6
+ color: z.string().nullable(),
7
+ created_at: z.coerce.date(),
8
+ updated_at: z.coerce.date().nullable(),
9
+ });
10
+ export const CreateTagInputSchema = z.object({
11
+ name: z.string().min(1).max(50),
12
+ color: z
13
+ .string()
14
+ .regex(/^#[0-9A-Fa-f]{6}$/)
15
+ .optional(),
16
+ });
17
+ export const UpdateTagInputSchema = z.object({
18
+ name: z.string().min(1).max(50).optional(),
19
+ color: z
20
+ .string()
21
+ .regex(/^#[0-9A-Fa-f]{6}$/)
22
+ .nullable()
23
+ .optional(),
24
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const UserSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ external_id: z.ZodString;
5
+ email: z.ZodString;
6
+ email_verified_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
7
+ first_name: z.ZodNullable<z.ZodString>;
8
+ last_name: z.ZodNullable<z.ZodString>;
9
+ created_at: z.ZodCoercedDate<unknown>;
10
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
11
+ }, z.core.$strip>;
12
+ export declare const SignInInputSchema: z.ZodObject<{
13
+ first_name: z.ZodOptional<z.ZodString>;
14
+ last_name: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export declare const UpdateUserInputSchema: z.ZodObject<{
17
+ first_name: z.ZodOptional<z.ZodString>;
18
+ last_name: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ //# sourceMappingURL=users.schema.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export const UserSchema = z.object({
3
+ id: z.string().uuid(),
4
+ external_id: z.string(),
5
+ email: z.string().email(),
6
+ email_verified_at: z.coerce.date().nullable(),
7
+ first_name: z.string().nullable(),
8
+ last_name: z.string().nullable(),
9
+ created_at: z.coerce.date(),
10
+ updated_at: z.coerce.date().nullable(),
11
+ });
12
+ export const SignInInputSchema = z.object({
13
+ first_name: z.string().min(1).max(100).optional(),
14
+ last_name: z.string().min(1).max(100).optional(),
15
+ });
16
+ export const UpdateUserInputSchema = z.object({
17
+ first_name: z.string().min(1).max(100).optional(),
18
+ last_name: z.string().min(1).max(100).optional(),
19
+ });
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ export declare const WorkspaceSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ created_at: z.ZodCoercedDate<unknown>;
6
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
7
+ }, z.core.$strip>;
8
+ export declare const WorkspaceWithCountSchema: z.ZodObject<{
9
+ id: z.ZodString;
10
+ name: z.ZodString;
11
+ created_at: z.ZodCoercedDate<unknown>;
12
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
13
+ member_count: z.ZodNumber;
14
+ }, z.core.$strip>;
15
+ export declare const CreateWorkspaceInputSchema: z.ZodObject<{
16
+ name: z.ZodString;
17
+ }, z.core.$strip>;
18
+ export declare const UpdateWorkspaceInputSchema: z.ZodObject<{
19
+ name: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export declare const TransferOwnershipInputSchema: z.ZodObject<{
22
+ to_user_id: z.ZodString;
23
+ }, z.core.$strip>;
24
+ export declare const WorkspaceMemberSchema: z.ZodObject<{
25
+ id: z.ZodString;
26
+ workspace_id: z.ZodString;
27
+ user_id: z.ZodString;
28
+ permissions: z.ZodNumber;
29
+ joined_at: z.ZodCoercedDate<unknown>;
30
+ created_at: z.ZodCoercedDate<unknown>;
31
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
32
+ }, z.core.$strip>;
33
+ export declare const UpdateMemberInputSchema: z.ZodObject<{
34
+ permissions: z.ZodNumber;
35
+ }, z.core.$strip>;
36
+ export declare const WorkspaceInvitationSchema: z.ZodObject<{
37
+ id: z.ZodString;
38
+ workspace_id: z.ZodString;
39
+ email: z.ZodString;
40
+ token: z.ZodString;
41
+ permissions: z.ZodNumber;
42
+ invited_by_id: z.ZodString;
43
+ expires_at: z.ZodCoercedDate<unknown>;
44
+ created_at: z.ZodCoercedDate<unknown>;
45
+ }, z.core.$strip>;
46
+ export declare const CreateInvitationInputSchema: z.ZodObject<{
47
+ email: z.ZodString;
48
+ permissions: z.ZodNumber;
49
+ }, z.core.$strip>;
50
+ //# sourceMappingURL=workspaces.schema.d.ts.map
@@ -0,0 +1 @@
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,qBAAqB;;;;;;;;iBAQhC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAGH,eAAO,MAAM,yBAAyB;;;;;;;;;iBASpC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ export const WorkspaceSchema = z.object({
3
+ id: z.string().uuid(),
4
+ name: z.string(),
5
+ created_at: z.coerce.date(),
6
+ updated_at: z.coerce.date().nullable(),
7
+ });
8
+ export const WorkspaceWithCountSchema = WorkspaceSchema.extend({
9
+ member_count: z.number().int(),
10
+ });
11
+ export const CreateWorkspaceInputSchema = z.object({
12
+ name: z.string().min(1).max(100),
13
+ });
14
+ export const UpdateWorkspaceInputSchema = z.object({
15
+ name: z.string().min(1).max(100).optional(),
16
+ });
17
+ export const TransferOwnershipInputSchema = z.object({
18
+ to_user_id: z.string().uuid(),
19
+ });
20
+ // Workspace member schemas
21
+ export const WorkspaceMemberSchema = z.object({
22
+ id: z.string().uuid(),
23
+ workspace_id: z.string().uuid(),
24
+ user_id: z.string().uuid(),
25
+ permissions: z.number().int(),
26
+ joined_at: z.coerce.date(),
27
+ created_at: z.coerce.date(),
28
+ updated_at: z.coerce.date().nullable(),
29
+ });
30
+ export const UpdateMemberInputSchema = z.object({
31
+ permissions: z.number().int().min(1),
32
+ });
33
+ // Invitation schemas
34
+ export const WorkspaceInvitationSchema = z.object({
35
+ id: z.string().uuid(),
36
+ workspace_id: z.string().uuid(),
37
+ email: z.string().email(),
38
+ token: z.string(),
39
+ permissions: z.number().int(),
40
+ invited_by_id: z.string().uuid(),
41
+ expires_at: z.coerce.date(),
42
+ created_at: z.coerce.date(),
43
+ });
44
+ export const CreateInvitationInputSchema = z.object({
45
+ email: z.string().email(),
46
+ permissions: z.number().int().min(1),
47
+ });
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@middlewr/contracts",
3
- "version": "0.0.2",
4
- "main": "index.js",
5
- "types": "index.d.ts",
6
- "type": "module",
3
+ "version": "0.0.3",
4
+ "main": "./cjs/index.js",
5
+ "module": "./esm/index.js",
6
+ "types": "./esm/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./index.d.ts",
10
- "default": "./index.js"
9
+ "types": "./esm/index.d.ts",
10
+ "import": "./esm/index.js",
11
+ "require": "./cjs/index.js"
11
12
  }
12
13
  },
13
14
  "peerDependencies": {
@@ -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,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;iBAE3B,CAAC"}
package/common.schema.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenParamSchema = exports.InvitationIdParamSchema = exports.MemberIdParamSchema = exports.TagIdParamSchema = exports.LinkIdParamSchema = exports.WorkspaceIdParamSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.WorkspaceIdParamSchema = zod_1.z.object({
6
- workspace_id: zod_1.z.string().uuid(),
7
- });
8
- exports.LinkIdParamSchema = zod_1.z.object({
9
- workspace_id: zod_1.z.string().uuid(),
10
- link_id: zod_1.z.string().uuid(),
11
- });
12
- exports.TagIdParamSchema = zod_1.z.object({
13
- workspace_id: zod_1.z.string().uuid(),
14
- tag_id: zod_1.z.string().uuid(),
15
- });
16
- exports.MemberIdParamSchema = zod_1.z.object({
17
- workspace_id: zod_1.z.string().uuid(),
18
- user_id: zod_1.z.string().uuid(),
19
- });
20
- exports.InvitationIdParamSchema = zod_1.z.object({
21
- workspace_id: zod_1.z.string().uuid(),
22
- invitation_id: zod_1.z.string().uuid(),
23
- });
24
- exports.TokenParamSchema = zod_1.z.object({
25
- token: zod_1.z.string(),
26
- });
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAE9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAGpC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASzB,CAAC;AAGF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkD9B,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;CAI/B,CAAC;AAGF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAGF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBxB,CAAC;AAGF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC"}