@middlewr/contracts 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,373 @@
1
+ import { z } from 'zod';
2
+ export declare const LinkTemplateSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ workspace_id: z.ZodString;
5
+ title: z.ZodString;
6
+ description: z.ZodNullable<z.ZodString>;
7
+ rule_graph: z.ZodObject<{
8
+ entry: z.ZodString;
9
+ nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
10
+ id: z.ZodString;
11
+ type: z.ZodLiteral<"condition">;
12
+ position: z.ZodObject<{
13
+ x: z.ZodNumber;
14
+ y: z.ZodNumber;
15
+ }, z.core.$strip>;
16
+ field: z.ZodString;
17
+ operator: z.ZodEnum<{
18
+ eq: "eq";
19
+ neq: "neq";
20
+ in: "in";
21
+ not_in: "not_in";
22
+ contains: "contains";
23
+ not_contains: "not_contains";
24
+ gt: "gt";
25
+ lt: "lt";
26
+ gte: "gte";
27
+ lte: "lte";
28
+ regex: "regex";
29
+ }>;
30
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodNumber]>;
31
+ outputs: z.ZodObject<{
32
+ true: z.ZodNullable<z.ZodString>;
33
+ false: z.ZodNullable<z.ZodString>;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ id: z.ZodString;
37
+ type: z.ZodLiteral<"split">;
38
+ position: z.ZodObject<{
39
+ x: z.ZodNumber;
40
+ y: z.ZodNumber;
41
+ }, z.core.$strip>;
42
+ variants: z.ZodArray<z.ZodObject<{
43
+ weight: z.ZodNumber;
44
+ target: z.ZodNullable<z.ZodString>;
45
+ }, z.core.$strip>>;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ id: z.ZodString;
48
+ type: z.ZodLiteral<"destination">;
49
+ position: z.ZodObject<{
50
+ x: z.ZodNumber;
51
+ y: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ url: z.ZodString;
54
+ }, z.core.$strip>, z.ZodObject<{
55
+ id: z.ZodString;
56
+ type: z.ZodLiteral<"transform">;
57
+ position: z.ZodObject<{
58
+ x: z.ZodNumber;
59
+ y: z.ZodNumber;
60
+ }, z.core.$strip>;
61
+ transforms: z.ZodObject<{
62
+ query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
+ key: z.ZodString;
64
+ value: z.ZodString;
65
+ mode: z.ZodEnum<{
66
+ set: "set";
67
+ append: "append";
68
+ }>;
69
+ }, z.core.$strip>>>;
70
+ redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
71
+ response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
72
+ key: z.ZodString;
73
+ value: z.ZodString;
74
+ mode: z.ZodEnum<{
75
+ set: "set";
76
+ append: "append";
77
+ }>;
78
+ }, z.core.$strip>>>;
79
+ }, z.core.$strip>;
80
+ next: z.ZodNullable<z.ZodString>;
81
+ }, z.core.$strip>, z.ZodObject<{
82
+ id: z.ZodString;
83
+ type: z.ZodLiteral<"password">;
84
+ position: z.ZodObject<{
85
+ x: z.ZodNumber;
86
+ y: z.ZodNumber;
87
+ }, z.core.$strip>;
88
+ next: z.ZodNullable<z.ZodString>;
89
+ }, z.core.$strip>], "type">>;
90
+ }, z.core.$strip>;
91
+ created_at: z.ZodCoercedDate<unknown>;
92
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
93
+ }, z.core.$strip>;
94
+ export declare const CreateLinkTemplateInputSchema: z.ZodObject<{
95
+ title: z.ZodString;
96
+ description: z.ZodOptional<z.ZodString>;
97
+ rule_graph: z.ZodObject<{
98
+ entry: z.ZodString;
99
+ nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
100
+ id: z.ZodString;
101
+ type: z.ZodLiteral<"condition">;
102
+ position: z.ZodObject<{
103
+ x: z.ZodNumber;
104
+ y: z.ZodNumber;
105
+ }, z.core.$strip>;
106
+ field: z.ZodString;
107
+ operator: z.ZodEnum<{
108
+ eq: "eq";
109
+ neq: "neq";
110
+ in: "in";
111
+ not_in: "not_in";
112
+ contains: "contains";
113
+ not_contains: "not_contains";
114
+ gt: "gt";
115
+ lt: "lt";
116
+ gte: "gte";
117
+ lte: "lte";
118
+ regex: "regex";
119
+ }>;
120
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodNumber]>;
121
+ outputs: z.ZodObject<{
122
+ true: z.ZodNullable<z.ZodString>;
123
+ false: z.ZodNullable<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ id: z.ZodString;
127
+ type: z.ZodLiteral<"split">;
128
+ position: z.ZodObject<{
129
+ x: z.ZodNumber;
130
+ y: z.ZodNumber;
131
+ }, z.core.$strip>;
132
+ variants: z.ZodArray<z.ZodObject<{
133
+ weight: z.ZodNumber;
134
+ target: z.ZodNullable<z.ZodString>;
135
+ }, z.core.$strip>>;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ id: z.ZodString;
138
+ type: z.ZodLiteral<"destination">;
139
+ position: z.ZodObject<{
140
+ x: z.ZodNumber;
141
+ y: z.ZodNumber;
142
+ }, z.core.$strip>;
143
+ url: z.ZodString;
144
+ }, z.core.$strip>, z.ZodObject<{
145
+ id: z.ZodString;
146
+ type: z.ZodLiteral<"transform">;
147
+ position: z.ZodObject<{
148
+ x: z.ZodNumber;
149
+ y: z.ZodNumber;
150
+ }, z.core.$strip>;
151
+ transforms: z.ZodObject<{
152
+ query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
153
+ key: z.ZodString;
154
+ value: z.ZodString;
155
+ mode: z.ZodEnum<{
156
+ set: "set";
157
+ append: "append";
158
+ }>;
159
+ }, z.core.$strip>>>;
160
+ redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
161
+ response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
162
+ key: z.ZodString;
163
+ value: z.ZodString;
164
+ mode: z.ZodEnum<{
165
+ set: "set";
166
+ append: "append";
167
+ }>;
168
+ }, z.core.$strip>>>;
169
+ }, z.core.$strip>;
170
+ next: z.ZodNullable<z.ZodString>;
171
+ }, z.core.$strip>, z.ZodObject<{
172
+ id: z.ZodString;
173
+ type: z.ZodLiteral<"password">;
174
+ position: z.ZodObject<{
175
+ x: z.ZodNumber;
176
+ y: z.ZodNumber;
177
+ }, z.core.$strip>;
178
+ next: z.ZodNullable<z.ZodString>;
179
+ }, z.core.$strip>], "type">>;
180
+ }, z.core.$strip>;
181
+ }, z.core.$strip>;
182
+ export declare const UpdateLinkTemplateInputSchema: z.ZodObject<{
183
+ title: z.ZodOptional<z.ZodString>;
184
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
185
+ rule_graph: z.ZodOptional<z.ZodObject<{
186
+ entry: z.ZodString;
187
+ nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
188
+ id: z.ZodString;
189
+ type: z.ZodLiteral<"condition">;
190
+ position: z.ZodObject<{
191
+ x: z.ZodNumber;
192
+ y: z.ZodNumber;
193
+ }, z.core.$strip>;
194
+ field: z.ZodString;
195
+ operator: z.ZodEnum<{
196
+ eq: "eq";
197
+ neq: "neq";
198
+ in: "in";
199
+ not_in: "not_in";
200
+ contains: "contains";
201
+ not_contains: "not_contains";
202
+ gt: "gt";
203
+ lt: "lt";
204
+ gte: "gte";
205
+ lte: "lte";
206
+ regex: "regex";
207
+ }>;
208
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodNumber]>;
209
+ outputs: z.ZodObject<{
210
+ true: z.ZodNullable<z.ZodString>;
211
+ false: z.ZodNullable<z.ZodString>;
212
+ }, z.core.$strip>;
213
+ }, z.core.$strip>, z.ZodObject<{
214
+ id: z.ZodString;
215
+ type: z.ZodLiteral<"split">;
216
+ position: z.ZodObject<{
217
+ x: z.ZodNumber;
218
+ y: z.ZodNumber;
219
+ }, z.core.$strip>;
220
+ variants: z.ZodArray<z.ZodObject<{
221
+ weight: z.ZodNumber;
222
+ target: z.ZodNullable<z.ZodString>;
223
+ }, z.core.$strip>>;
224
+ }, z.core.$strip>, z.ZodObject<{
225
+ id: z.ZodString;
226
+ type: z.ZodLiteral<"destination">;
227
+ position: z.ZodObject<{
228
+ x: z.ZodNumber;
229
+ y: z.ZodNumber;
230
+ }, z.core.$strip>;
231
+ url: z.ZodString;
232
+ }, z.core.$strip>, z.ZodObject<{
233
+ id: z.ZodString;
234
+ type: z.ZodLiteral<"transform">;
235
+ position: z.ZodObject<{
236
+ x: z.ZodNumber;
237
+ y: z.ZodNumber;
238
+ }, z.core.$strip>;
239
+ transforms: z.ZodObject<{
240
+ query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
241
+ key: z.ZodString;
242
+ value: z.ZodString;
243
+ mode: z.ZodEnum<{
244
+ set: "set";
245
+ append: "append";
246
+ }>;
247
+ }, z.core.$strip>>>;
248
+ redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
249
+ response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
250
+ key: z.ZodString;
251
+ value: z.ZodString;
252
+ mode: z.ZodEnum<{
253
+ set: "set";
254
+ append: "append";
255
+ }>;
256
+ }, z.core.$strip>>>;
257
+ }, z.core.$strip>;
258
+ next: z.ZodNullable<z.ZodString>;
259
+ }, z.core.$strip>, z.ZodObject<{
260
+ id: z.ZodString;
261
+ type: z.ZodLiteral<"password">;
262
+ position: z.ZodObject<{
263
+ x: z.ZodNumber;
264
+ y: z.ZodNumber;
265
+ }, z.core.$strip>;
266
+ next: z.ZodNullable<z.ZodString>;
267
+ }, z.core.$strip>], "type">>;
268
+ }, z.core.$strip>>;
269
+ }, z.core.$strip>;
270
+ export declare const LinkTemplateFiltersSchema: z.ZodObject<{
271
+ search: z.ZodOptional<z.ZodString>;
272
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
273
+ per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
274
+ }, z.core.$strip>;
275
+ export declare const PaginatedLinkTemplatesSchema: z.ZodObject<{
276
+ link_templates: z.ZodArray<z.ZodObject<{
277
+ id: z.ZodString;
278
+ workspace_id: z.ZodString;
279
+ title: z.ZodString;
280
+ description: z.ZodNullable<z.ZodString>;
281
+ rule_graph: z.ZodObject<{
282
+ entry: z.ZodString;
283
+ nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
284
+ id: z.ZodString;
285
+ type: z.ZodLiteral<"condition">;
286
+ position: z.ZodObject<{
287
+ x: z.ZodNumber;
288
+ y: z.ZodNumber;
289
+ }, z.core.$strip>;
290
+ field: z.ZodString;
291
+ operator: z.ZodEnum<{
292
+ eq: "eq";
293
+ neq: "neq";
294
+ in: "in";
295
+ not_in: "not_in";
296
+ contains: "contains";
297
+ not_contains: "not_contains";
298
+ gt: "gt";
299
+ lt: "lt";
300
+ gte: "gte";
301
+ lte: "lte";
302
+ regex: "regex";
303
+ }>;
304
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodNumber]>;
305
+ outputs: z.ZodObject<{
306
+ true: z.ZodNullable<z.ZodString>;
307
+ false: z.ZodNullable<z.ZodString>;
308
+ }, z.core.$strip>;
309
+ }, z.core.$strip>, z.ZodObject<{
310
+ id: z.ZodString;
311
+ type: z.ZodLiteral<"split">;
312
+ position: z.ZodObject<{
313
+ x: z.ZodNumber;
314
+ y: z.ZodNumber;
315
+ }, z.core.$strip>;
316
+ variants: z.ZodArray<z.ZodObject<{
317
+ weight: z.ZodNumber;
318
+ target: z.ZodNullable<z.ZodString>;
319
+ }, z.core.$strip>>;
320
+ }, z.core.$strip>, z.ZodObject<{
321
+ id: z.ZodString;
322
+ type: z.ZodLiteral<"destination">;
323
+ position: z.ZodObject<{
324
+ x: z.ZodNumber;
325
+ y: z.ZodNumber;
326
+ }, z.core.$strip>;
327
+ url: z.ZodString;
328
+ }, z.core.$strip>, z.ZodObject<{
329
+ id: z.ZodString;
330
+ type: z.ZodLiteral<"transform">;
331
+ position: z.ZodObject<{
332
+ x: z.ZodNumber;
333
+ y: z.ZodNumber;
334
+ }, z.core.$strip>;
335
+ transforms: z.ZodObject<{
336
+ query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
337
+ key: z.ZodString;
338
+ value: z.ZodString;
339
+ mode: z.ZodEnum<{
340
+ set: "set";
341
+ append: "append";
342
+ }>;
343
+ }, z.core.$strip>>>;
344
+ redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
345
+ response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
346
+ key: z.ZodString;
347
+ value: z.ZodString;
348
+ mode: z.ZodEnum<{
349
+ set: "set";
350
+ append: "append";
351
+ }>;
352
+ }, z.core.$strip>>>;
353
+ }, z.core.$strip>;
354
+ next: z.ZodNullable<z.ZodString>;
355
+ }, z.core.$strip>, z.ZodObject<{
356
+ id: z.ZodString;
357
+ type: z.ZodLiteral<"password">;
358
+ position: z.ZodObject<{
359
+ x: z.ZodNumber;
360
+ y: z.ZodNumber;
361
+ }, z.core.$strip>;
362
+ next: z.ZodNullable<z.ZodString>;
363
+ }, z.core.$strip>], "type">>;
364
+ }, z.core.$strip>;
365
+ created_at: z.ZodCoercedDate<unknown>;
366
+ updated_at: z.ZodNullable<z.ZodCoercedDate<unknown>>;
367
+ }, z.core.$strip>>;
368
+ total: z.ZodNumber;
369
+ page: z.ZodNumber;
370
+ per_page: z.ZodNumber;
371
+ total_pages: z.ZodNumber;
372
+ }, z.core.$strip>;
373
+ //# sourceMappingURL=link-templates.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-templates.schema.d.ts","sourceRoot":"","sources":["../../src/link-templates.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ7B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;iBAIpC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMvC,CAAC"}
@@ -461,8 +461,8 @@ export declare const LinkFiltersSchema: z.ZodObject<{
461
461
  tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
462
462
  sort_by: z.ZodDefault<z.ZodEnum<{
463
463
  created_at: "created_at";
464
- original_url: "original_url";
465
464
  title: "title";
465
+ original_url: "original_url";
466
466
  click_count: "click_count";
467
467
  }>>;
468
468
  sort_order: z.ZodDefault<z.ZodEnum<{
@@ -473,12 +473,12 @@ export declare const LinkFiltersSchema: z.ZodObject<{
473
473
  per_page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
474
474
  }, z.core.$strip>;
475
475
  export declare const ExportLinksFiltersSchema: z.ZodObject<{
476
+ search: z.ZodOptional<z.ZodString>;
476
477
  is_active: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
477
478
  true: "true";
478
479
  false: "false";
479
480
  }>]>, z.ZodTransform<boolean, boolean | "true" | "false">>>;
480
481
  tag_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
481
- search: z.ZodOptional<z.ZodString>;
482
482
  domain_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
483
483
  has_expiration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
484
484
  true: "true";
@@ -494,8 +494,8 @@ export declare const ExportLinksFiltersSchema: z.ZodObject<{
494
494
  expires_to: z.ZodOptional<z.ZodCoercedDate<unknown>>;
495
495
  sort_by: z.ZodDefault<z.ZodEnum<{
496
496
  created_at: "created_at";
497
- original_url: "original_url";
498
497
  title: "title";
498
+ original_url: "original_url";
499
499
  click_count: "click_count";
500
500
  }>>;
501
501
  sort_order: z.ZodDefault<z.ZodEnum<{
@@ -80,7 +80,7 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
80
80
  }, z.core.$strip>;
81
81
  next: z.ZodNullable<z.ZodString>;
82
82
  }, z.core.$strip>], "type">;
83
- export declare const RuleGraphSchema: z.ZodNullable<z.ZodObject<{
83
+ export declare const RuleGraphSchema: z.ZodObject<{
84
84
  entry: z.ZodString;
85
85
  nodes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
86
86
  id: z.ZodString;
@@ -163,5 +163,5 @@ export declare const RuleGraphSchema: z.ZodNullable<z.ZodObject<{
163
163
  }, z.core.$strip>;
164
164
  next: z.ZodNullable<z.ZodString>;
165
165
  }, z.core.$strip>], "type">>;
166
- }, z.core.$strip>>;
166
+ }, z.core.$strip>;
167
167
  //# sourceMappingURL=rules.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwFxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASb,CAAC"}
1
+ {"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwFxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middlewr/contracts",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -42,6 +42,11 @@ export const WorkspaceApiKeyIdParamSchema = z.object({
42
42
  api_key_id: z.string().uuid(),
43
43
  });
44
44
 
45
+ export const LinkTemplateIdParamSchema = z.object({
46
+ workspace_id: z.string().uuid(),
47
+ link_template_id: z.string().uuid(),
48
+ });
49
+
45
50
  export const TokenParamSchema = z.object({
46
51
  token: z.string(),
47
52
  });
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  DomainIdParamSchema,
23
23
  InvitationIdParamSchema,
24
24
  LinkIdParamSchema,
25
+ LinkTemplateIdParamSchema,
25
26
  MemberIdParamSchema,
26
27
  TagIdParamSchema,
27
28
  TokenParamSchema,
@@ -29,6 +30,13 @@ import {
29
30
  WorkspaceIdParamSchema,
30
31
  } from './common.schema';
31
32
  import { CreateDomainInputSchema, DomainSchema, UpdateDomainInputSchema } from './domains.schema';
33
+ import {
34
+ CreateLinkTemplateInputSchema,
35
+ LinkTemplateFiltersSchema,
36
+ LinkTemplateSchema,
37
+ PaginatedLinkTemplatesSchema,
38
+ UpdateLinkTemplateInputSchema,
39
+ } from './link-templates.schema';
32
40
  import {
33
41
  CreateLinkInputSchema,
34
42
  ExportLinksFiltersSchema,
@@ -60,6 +68,7 @@ export * from './api-keys.schema';
60
68
  export * from './billing.schema';
61
69
  export * from './common.schema';
62
70
  export * from './domains.schema';
71
+ export * from './link-templates.schema';
63
72
  export * from './links.schema';
64
73
  export * from './rules.schema';
65
74
  export * from './tags.schema';
@@ -193,6 +202,34 @@ export const invitationsContract = {
193
202
  accept: oc.route({ method: 'POST', path: '/api/invitations/{token}/accept' }).input(TokenParamSchema).output(WorkspaceMemberSchema),
194
203
  };
195
204
 
205
+ // Link Templates contract
206
+ export const linkTemplatesContract = {
207
+ create: oc
208
+ .route({ method: 'POST', path: '/api/workspaces/{workspace_id}/link-templates' })
209
+ .input(WorkspaceIdParamSchema.merge(CreateLinkTemplateInputSchema))
210
+ .output(LinkTemplateSchema),
211
+
212
+ list: oc
213
+ .route({ method: 'GET', path: '/api/workspaces/{workspace_id}/link-templates' })
214
+ .input(WorkspaceIdParamSchema.merge(LinkTemplateFiltersSchema))
215
+ .output(PaginatedLinkTemplatesSchema),
216
+
217
+ get: oc
218
+ .route({ method: 'GET', path: '/api/workspaces/{workspace_id}/link-templates/{link_template_id}' })
219
+ .input(LinkTemplateIdParamSchema)
220
+ .output(LinkTemplateSchema),
221
+
222
+ update: oc
223
+ .route({ method: 'PATCH', path: '/api/workspaces/{workspace_id}/link-templates/{link_template_id}' })
224
+ .input(LinkTemplateIdParamSchema.merge(UpdateLinkTemplateInputSchema))
225
+ .output(LinkTemplateSchema),
226
+
227
+ delete: oc
228
+ .route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/link-templates/{link_template_id}' })
229
+ .input(LinkTemplateIdParamSchema)
230
+ .output(z.void()),
231
+ };
232
+
196
233
  // Links contract
197
234
  export const linksContract = {
198
235
  create: oc
@@ -336,6 +373,7 @@ export const contract = {
336
373
  workspaceApiKeys: workspaceApiKeysContract,
337
374
  workspaces: workspacesContract,
338
375
  invitations: invitationsContract,
376
+ linkTemplates: linkTemplatesContract,
339
377
  links: linksContract,
340
378
  tags: tagsContract,
341
379
  domains: domainsContract,
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+
3
+ import { RuleGraphSchema } from './rules.schema';
4
+
5
+ export const LinkTemplateSchema = z.object({
6
+ id: z.string().uuid(),
7
+ workspace_id: z.string().uuid(),
8
+ title: z.string(),
9
+ description: z.string().nullable(),
10
+ rule_graph: RuleGraphSchema,
11
+ created_at: z.coerce.date(),
12
+ updated_at: z.coerce.date().nullable(),
13
+ });
14
+
15
+ export const CreateLinkTemplateInputSchema = z.object({
16
+ title: z.string().min(1).max(255),
17
+ description: z.string().max(2000).optional(),
18
+ rule_graph: RuleGraphSchema,
19
+ });
20
+
21
+ export const UpdateLinkTemplateInputSchema = z.object({
22
+ title: z.string().min(1).max(255).optional(),
23
+ description: z.string().max(2000).nullable().optional(),
24
+ rule_graph: RuleGraphSchema.optional(),
25
+ });
26
+
27
+ export const LinkTemplateFiltersSchema = z.object({
28
+ search: z.string().optional(),
29
+ page: z.coerce.number().int().min(1).default(1),
30
+ per_page: z.coerce.number().int().min(1).max(100).default(20),
31
+ });
32
+
33
+ export const PaginatedLinkTemplatesSchema = z.object({
34
+ link_templates: z.array(LinkTemplateSchema),
35
+ total: z.number().int(),
36
+ page: z.number().int(),
37
+ per_page: z.number().int(),
38
+ total_pages: z.number().int(),
39
+ });
@@ -48,7 +48,7 @@ export const LinkSchema = z.object({
48
48
  qr_logo_key: z.string().nullable(),
49
49
  logo_url: z.string().nullable(),
50
50
  link_type: z.enum(['redirect', 'rules']).default('redirect'),
51
- rule_graph: RuleGraphSchema.optional(),
51
+ rule_graph: RuleGraphSchema.nullable().optional(),
52
52
  tags: z.array(TagSchema),
53
53
  });
54
54
 
@@ -80,7 +80,7 @@ export const CreateLinkInputSchema = z
80
80
  qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
81
81
  tag_ids: z.array(z.string().uuid()).optional(),
82
82
  link_type: z.enum(['redirect', 'rules']).optional(),
83
- rule_graph: RuleGraphSchema.optional(),
83
+ rule_graph: RuleGraphSchema.nullable().optional(),
84
84
  })
85
85
  .refine((data) => data.link_type !== 'rules' || data.rule_graph != null, {
86
86
  message: 'rule_graph is required when link_type is "rules"',
@@ -116,7 +116,7 @@ export const UpdateLinkInputSchema = z
116
116
  qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
117
117
  tag_ids: z.array(z.string().uuid()).optional(),
118
118
  link_type: z.enum(['redirect', 'rules']).optional(),
119
- rule_graph: RuleGraphSchema.optional(),
119
+ rule_graph: RuleGraphSchema.nullable().optional(),
120
120
  })
121
121
  .refine((data) => data.link_type !== 'rules' || data.rule_graph != null, {
122
122
  message: 'rule_graph is required when link_type is "rules"',
@@ -102,5 +102,4 @@ export const RuleGraphSchema = z
102
102
  .refine((data) => data.nodes[data.entry] !== undefined, {
103
103
  message: 'Entry node must reference an existing node in the graph',
104
104
  path: ['entry'],
105
- })
106
- .nullable();
105
+ });