@middlewr/contracts 0.0.47 → 0.0.49

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.
@@ -79,6 +79,30 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
79
79
  y: z.ZodNumber;
80
80
  }, z.core.$strip>;
81
81
  next: z.ZodNullable<z.ZodString>;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ id: z.ZodString;
84
+ type: z.ZodLiteral<"countdown">;
85
+ position: z.ZodObject<{
86
+ x: z.ZodNumber;
87
+ y: z.ZodNumber;
88
+ }, z.core.$strip>;
89
+ seconds: z.ZodNumber;
90
+ message: z.ZodNullable<z.ZodString>;
91
+ next: z.ZodNullable<z.ZodString>;
92
+ }, z.core.$strip>, z.ZodObject<{
93
+ id: z.ZodString;
94
+ type: z.ZodLiteral<"webhook">;
95
+ position: z.ZodObject<{
96
+ x: z.ZodNumber;
97
+ y: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ url: z.ZodString;
100
+ method: z.ZodEnum<{
101
+ POST: "POST";
102
+ GET: "GET";
103
+ }>;
104
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
105
+ next: z.ZodNullable<z.ZodString>;
82
106
  }, z.core.$strip>, z.ZodObject<{
83
107
  id: z.ZodString;
84
108
  type: z.ZodLiteral<"entry">;
@@ -87,6 +111,9 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
87
111
  y: z.ZodNumber;
88
112
  }, z.core.$strip>;
89
113
  next: z.ZodNullable<z.ZodString>;
114
+ starts_at: z.ZodNullable<z.ZodString>;
115
+ expires_at: z.ZodNullable<z.ZodString>;
116
+ fallback_url: z.ZodNullable<z.ZodString>;
90
117
  }, z.core.$strip>], "type">;
91
118
  export declare const RuleGraphOutputSchema: z.ZodObject<{
92
119
  entry: z.ZodString;
@@ -170,6 +197,30 @@ export declare const RuleGraphOutputSchema: z.ZodObject<{
170
197
  y: z.ZodNumber;
171
198
  }, z.core.$strip>;
172
199
  next: z.ZodNullable<z.ZodString>;
200
+ }, z.core.$strip>, z.ZodObject<{
201
+ id: z.ZodString;
202
+ type: z.ZodLiteral<"countdown">;
203
+ position: z.ZodObject<{
204
+ x: z.ZodNumber;
205
+ y: z.ZodNumber;
206
+ }, z.core.$strip>;
207
+ seconds: z.ZodNumber;
208
+ message: z.ZodNullable<z.ZodString>;
209
+ next: z.ZodNullable<z.ZodString>;
210
+ }, z.core.$strip>, z.ZodObject<{
211
+ id: z.ZodString;
212
+ type: z.ZodLiteral<"webhook">;
213
+ position: z.ZodObject<{
214
+ x: z.ZodNumber;
215
+ y: z.ZodNumber;
216
+ }, z.core.$strip>;
217
+ url: z.ZodString;
218
+ method: z.ZodEnum<{
219
+ POST: "POST";
220
+ GET: "GET";
221
+ }>;
222
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
223
+ next: z.ZodNullable<z.ZodString>;
173
224
  }, z.core.$strip>, z.ZodObject<{
174
225
  id: z.ZodString;
175
226
  type: z.ZodLiteral<"entry">;
@@ -178,6 +229,9 @@ export declare const RuleGraphOutputSchema: z.ZodObject<{
178
229
  y: z.ZodNumber;
179
230
  }, z.core.$strip>;
180
231
  next: z.ZodNullable<z.ZodString>;
232
+ starts_at: z.ZodNullable<z.ZodString>;
233
+ expires_at: z.ZodNullable<z.ZodString>;
234
+ fallback_url: z.ZodNullable<z.ZodString>;
181
235
  }, z.core.$strip>], "type">>;
182
236
  }, z.core.$strip>;
183
237
  export declare const RuleGraphSchema: z.ZodObject<{
@@ -262,6 +316,30 @@ export declare const RuleGraphSchema: z.ZodObject<{
262
316
  y: z.ZodNumber;
263
317
  }, z.core.$strip>;
264
318
  next: z.ZodNullable<z.ZodString>;
319
+ }, z.core.$strip>, z.ZodObject<{
320
+ id: z.ZodString;
321
+ type: z.ZodLiteral<"countdown">;
322
+ position: z.ZodObject<{
323
+ x: z.ZodNumber;
324
+ y: z.ZodNumber;
325
+ }, z.core.$strip>;
326
+ seconds: z.ZodNumber;
327
+ message: z.ZodNullable<z.ZodString>;
328
+ next: z.ZodNullable<z.ZodString>;
329
+ }, z.core.$strip>, z.ZodObject<{
330
+ id: z.ZodString;
331
+ type: z.ZodLiteral<"webhook">;
332
+ position: z.ZodObject<{
333
+ x: z.ZodNumber;
334
+ y: z.ZodNumber;
335
+ }, z.core.$strip>;
336
+ url: z.ZodString;
337
+ method: z.ZodEnum<{
338
+ POST: "POST";
339
+ GET: "GET";
340
+ }>;
341
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
342
+ next: z.ZodNullable<z.ZodString>;
265
343
  }, z.core.$strip>, z.ZodObject<{
266
344
  id: z.ZodString;
267
345
  type: z.ZodLiteral<"entry">;
@@ -270,6 +348,9 @@ export declare const RuleGraphSchema: z.ZodObject<{
270
348
  y: z.ZodNumber;
271
349
  }, z.core.$strip>;
272
350
  next: z.ZodNullable<z.ZodString>;
351
+ starts_at: z.ZodNullable<z.ZodString>;
352
+ expires_at: z.ZodNullable<z.ZodString>;
353
+ fallback_url: z.ZodNullable<z.ZodString>;
273
354
  }, z.core.$strip>], "type">>;
274
355
  }, z.core.$strip>;
275
356
  //# 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;AA+FxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAO9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,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;AA0HxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAS9B,CAAC;AAOH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middlewr/contracts",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -35,9 +35,6 @@ export const LinkSchema = z.object({
35
35
  utm_term: z.string().nullable(),
36
36
  utm_content: z.string().nullable(),
37
37
  password: z.string().nullable(),
38
- starts_at: z.coerce.date().nullable(),
39
- expires_at: z.coerce.date().nullable(),
40
- fallback_url: z.string().nullable(),
41
38
  is_active: z.boolean(),
42
39
  redirect_type: z.number().int(),
43
40
  click_count: z.coerce.number().int(),
@@ -47,81 +44,62 @@ export const LinkSchema = z.object({
47
44
  qr_code_settings: QrCodeSettingsSchema.nullable(),
48
45
  qr_logo_key: z.string().nullable(),
49
46
  logo_url: z.string().nullable(),
50
- link_type: z.enum(['redirect', 'rules']).default('redirect'),
51
47
  rule_graph: RuleGraphOutputSchema.nullable().optional(),
52
48
  tags: z.array(TagSchema),
53
49
  });
54
50
 
55
- export const CreateLinkInputSchema = z
56
- .object({
57
- original_url: z.string().url().max(2048),
58
- domain_id: z.string().uuid().optional(),
59
- short_code: z
60
- .string()
61
- .min(3)
62
- .max(50)
63
- .regex(/^[a-zA-Z0-9-]+$/)
64
- .optional(),
65
- title: z.string().max(255).optional(),
66
- description: z.string().max(2000).optional(),
67
- utm_source: z.string().max(255).optional(),
68
- utm_medium: z.string().max(255).optional(),
69
- utm_campaign: z.string().max(255).optional(),
70
- utm_term: z.string().max(255).optional(),
71
- utm_content: z.string().max(255).optional(),
72
- password: z.string().min(4).max(100).optional(),
73
- starts_at: z.coerce.date().optional(),
74
- expires_at: z.coerce.date().optional(),
75
- fallback_url: z.string().url().max(2048).optional(),
76
- redirect_type: z.coerce
77
- .number()
78
- .refine((v) => [301, 302, 307, 308].includes(v))
79
- .optional(),
80
- qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
81
- tag_ids: z.array(z.string().uuid()).optional(),
82
- link_type: z.enum(['redirect', 'rules']).optional(),
83
- rule_graph: RuleGraphSchema.nullable().optional(),
84
- })
85
- .refine((data) => data.link_type !== 'rules' || data.rule_graph != null, {
86
- message: 'rule_graph is required when link_type is "rules"',
87
- path: ['rule_graph'],
88
- });
51
+ export const CreateLinkInputSchema = z.object({
52
+ original_url: z.string().url().max(2048),
53
+ domain_id: z.string().uuid().optional(),
54
+ short_code: z
55
+ .string()
56
+ .min(3)
57
+ .max(50)
58
+ .regex(/^[a-zA-Z0-9-]+$/)
59
+ .optional(),
60
+ title: z.string().max(255).optional(),
61
+ description: z.string().max(2000).optional(),
62
+ utm_source: z.string().max(255).optional(),
63
+ utm_medium: z.string().max(255).optional(),
64
+ utm_campaign: z.string().max(255).optional(),
65
+ utm_term: z.string().max(255).optional(),
66
+ utm_content: z.string().max(255).optional(),
67
+ password: z.string().min(4).max(100).optional(),
68
+ redirect_type: z.coerce
69
+ .number()
70
+ .refine((v) => [301, 302, 307, 308].includes(v))
71
+ .optional(),
72
+ qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
73
+ tag_ids: z.array(z.string().uuid()).optional(),
74
+ rule_graph: RuleGraphSchema.nullable().optional(),
75
+ });
89
76
 
90
- export const UpdateLinkInputSchema = z
91
- .object({
92
- original_url: z.string().url().max(2048).optional(),
93
- domain_id: z.string().uuid().optional(),
94
- short_code: z
95
- .string()
96
- .min(3)
97
- .max(50)
98
- .regex(/^[a-zA-Z0-9-]+$/)
99
- .optional(),
100
- title: z.string().max(255).nullable().optional(),
101
- description: z.string().max(2000).nullable().optional(),
102
- utm_source: z.string().max(255).nullable().optional(),
103
- utm_medium: z.string().max(255).nullable().optional(),
104
- utm_campaign: z.string().max(255).nullable().optional(),
105
- utm_term: z.string().max(255).nullable().optional(),
106
- utm_content: z.string().max(255).nullable().optional(),
107
- password: z.string().min(4).max(100).nullable().optional(),
108
- starts_at: z.coerce.date().nullable().optional(),
109
- expires_at: z.coerce.date().nullable().optional(),
110
- fallback_url: z.string().url().max(2048).nullable().optional(),
111
- is_active: z.boolean().optional(),
112
- redirect_type: z.coerce
113
- .number()
114
- .refine((v) => [301, 302, 307, 308].includes(v))
115
- .optional(),
116
- qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
117
- tag_ids: z.array(z.string().uuid()).optional(),
118
- link_type: z.enum(['redirect', 'rules']).optional(),
119
- rule_graph: RuleGraphSchema.nullable().optional(),
120
- })
121
- .refine((data) => data.link_type !== 'rules' || data.rule_graph != null, {
122
- message: 'rule_graph is required when link_type is "rules"',
123
- path: ['rule_graph'],
124
- });
77
+ export const UpdateLinkInputSchema = z.object({
78
+ original_url: z.string().url().max(2048).optional(),
79
+ domain_id: z.string().uuid().optional(),
80
+ short_code: z
81
+ .string()
82
+ .min(3)
83
+ .max(50)
84
+ .regex(/^[a-zA-Z0-9-]+$/)
85
+ .optional(),
86
+ title: z.string().max(255).nullable().optional(),
87
+ description: z.string().max(2000).nullable().optional(),
88
+ utm_source: z.string().max(255).nullable().optional(),
89
+ utm_medium: z.string().max(255).nullable().optional(),
90
+ utm_campaign: z.string().max(255).nullable().optional(),
91
+ utm_term: z.string().max(255).nullable().optional(),
92
+ utm_content: z.string().max(255).nullable().optional(),
93
+ password: z.string().min(4).max(100).nullable().optional(),
94
+ is_active: z.boolean().optional(),
95
+ redirect_type: z.coerce
96
+ .number()
97
+ .refine((v) => [301, 302, 307, 308].includes(v))
98
+ .optional(),
99
+ qr_code_settings: QrCodeSettingsSchema.nullable().optional(),
100
+ tag_ids: z.array(z.string().uuid()).optional(),
101
+ rule_graph: RuleGraphSchema.nullable().optional(),
102
+ });
125
103
 
126
104
  const stringToBoolean = z
127
105
  .union([z.boolean(), z.enum(['true', 'false'])])
@@ -131,12 +109,8 @@ export const LinkFiltersSchema = z.object({
131
109
  search: z.string().optional(),
132
110
  domain_ids: z.array(z.string().uuid()).optional(),
133
111
  is_active: stringToBoolean.optional(),
134
- has_expiration: stringToBoolean.optional(),
135
- expired: stringToBoolean.optional(),
136
112
  created_from: z.coerce.date().optional(),
137
113
  created_to: z.coerce.date().optional(),
138
- expires_from: z.coerce.date().optional(),
139
- expires_to: z.coerce.date().optional(),
140
114
  tag_ids: z.array(z.string().uuid()).optional(),
141
115
  sort_by: z.enum(['created_at', 'title', 'click_count', 'original_url']).default('created_at'),
142
116
  sort_order: z.enum(['asc', 'desc']).default('desc'),
@@ -86,11 +86,38 @@ const PasswordNodeSchema = z.object({
86
86
  next: z.string().nullable(),
87
87
  });
88
88
 
89
+ const CountdownNodeSchema = z.object({
90
+ id: z.string(),
91
+ type: z.literal('countdown'),
92
+ position: PositionSchema,
93
+ seconds: z.number().int().min(1).max(300),
94
+ message: z.string().max(500).nullable(),
95
+ next: z.string().nullable(),
96
+ });
97
+
98
+ const WebhookNodeSchema = z.object({
99
+ id: z.string(),
100
+ type: z.literal('webhook'),
101
+ position: PositionSchema,
102
+ url: z
103
+ .string()
104
+ .url()
105
+ .refine((u) => u.startsWith('https://') || u.startsWith('http://'), {
106
+ message: 'Webhook URL must use http or https protocol',
107
+ }),
108
+ method: z.enum(['POST', 'GET']),
109
+ headers: z.record(z.string(), z.string().regex(/^[^\r\n]*$/, 'Header value must not contain newlines')).optional(),
110
+ next: z.string().nullable(),
111
+ });
112
+
89
113
  const EntryNodeSchema = z.object({
90
114
  id: z.string(),
91
115
  type: z.literal('entry'),
92
116
  position: PositionSchema,
93
117
  next: z.string().nullable(),
118
+ starts_at: z.string().nullable(),
119
+ expires_at: z.string().nullable(),
120
+ fallback_url: z.string().nullable(),
94
121
  });
95
122
 
96
123
  export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
@@ -99,6 +126,8 @@ export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
99
126
  DestinationNodeSchema,
100
127
  TransformNodeSchema,
101
128
  PasswordNodeSchema,
129
+ CountdownNodeSchema,
130
+ WebhookNodeSchema,
102
131
  EntryNodeSchema,
103
132
  ]);
104
133