@middlewr/contracts 0.0.28 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api-keys.schema.d.ts +34 -2
- package/dist/cjs/api-keys.schema.d.ts.map +1 -1
- package/dist/cjs/common.schema.d.ts +4 -0
- package/dist/cjs/common.schema.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +438 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +61 -2
- package/dist/cjs/links.schema.d.ts +108 -0
- package/dist/cjs/links.schema.d.ts.map +1 -1
- package/dist/cjs/rules.schema.d.ts +54 -0
- package/dist/cjs/rules.schema.d.ts.map +1 -1
- package/dist/esm/api-keys.schema.d.ts +34 -2
- package/dist/esm/api-keys.schema.d.ts.map +1 -1
- package/dist/esm/common.schema.d.ts +4 -0
- package/dist/esm/common.schema.d.ts.map +1 -1
- package/dist/esm/index.d.ts +438 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +57 -2
- package/dist/esm/links.schema.d.ts +108 -0
- package/dist/esm/links.schema.d.ts.map +1 -1
- package/dist/esm/rules.schema.d.ts +54 -0
- package/dist/esm/rules.schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api-keys.schema.ts +13 -1
- package/src/common.schema.ts +5 -0
- package/src/index.ts +27 -1
- package/src/rules.schema.ts +41 -1
package/dist/esm/index.js
CHANGED
|
@@ -39,9 +39,12 @@ var LinkAnalyticsQuerySchema = z.object({
|
|
|
39
39
|
import { z as z2 } from "zod";
|
|
40
40
|
var ApiKeySchema = z2.object({
|
|
41
41
|
id: z2.string().uuid(),
|
|
42
|
-
|
|
42
|
+
owner_type: z2.enum(["user", "workspace"]),
|
|
43
|
+
owner_id: z2.string().uuid(),
|
|
44
|
+
created_by_id: z2.string().uuid().nullable(),
|
|
43
45
|
name: z2.string(),
|
|
44
46
|
key_prefix: z2.string(),
|
|
47
|
+
permissions: z2.number().int().nullable(),
|
|
45
48
|
last_used_at: z2.coerce.date().nullable(),
|
|
46
49
|
created_at: z2.coerce.date(),
|
|
47
50
|
updated_at: z2.coerce.date().nullable()
|
|
@@ -52,6 +55,13 @@ var CreateApiKeyInputSchema = z2.object({
|
|
|
52
55
|
var CreateApiKeyResponseSchema = ApiKeySchema.extend({
|
|
53
56
|
key: z2.string()
|
|
54
57
|
});
|
|
58
|
+
var CreateWorkspaceApiKeyInputSchema = z2.object({
|
|
59
|
+
name: z2.string().min(1).max(255),
|
|
60
|
+
permissions: z2.number().int().min(1)
|
|
61
|
+
});
|
|
62
|
+
var CreateWorkspaceApiKeyResponseSchema = ApiKeySchema.extend({
|
|
63
|
+
key: z2.string()
|
|
64
|
+
});
|
|
55
65
|
|
|
56
66
|
// src/billing.schema.ts
|
|
57
67
|
import { z as z3 } from "zod";
|
|
@@ -109,6 +119,10 @@ var UserIdParamSchema = z4.object({
|
|
|
109
119
|
var ApiKeyIdParamSchema = z4.object({
|
|
110
120
|
api_key_id: z4.string().uuid()
|
|
111
121
|
});
|
|
122
|
+
var WorkspaceApiKeyIdParamSchema = z4.object({
|
|
123
|
+
workspace_id: z4.string().uuid(),
|
|
124
|
+
api_key_id: z4.string().uuid()
|
|
125
|
+
});
|
|
112
126
|
var TokenParamSchema = z4.object({
|
|
113
127
|
token: z4.string()
|
|
114
128
|
});
|
|
@@ -185,7 +199,38 @@ var DestinationNodeSchema = z6.object({
|
|
|
185
199
|
position: PositionSchema,
|
|
186
200
|
url: z6.string().url()
|
|
187
201
|
});
|
|
188
|
-
var
|
|
202
|
+
var FORBIDDEN_HEADERS = ["set-cookie", "authorization", "host", "transfer-encoding"];
|
|
203
|
+
var TransformNodeSchema = z6.object({
|
|
204
|
+
id: z6.string(),
|
|
205
|
+
type: z6.literal("transform"),
|
|
206
|
+
position: PositionSchema,
|
|
207
|
+
transforms: z6.object({
|
|
208
|
+
query_params: z6.array(
|
|
209
|
+
z6.object({
|
|
210
|
+
key: z6.string().min(1),
|
|
211
|
+
value: z6.string(),
|
|
212
|
+
mode: z6.enum(["set", "append"])
|
|
213
|
+
})
|
|
214
|
+
).optional(),
|
|
215
|
+
redirect_status: z6.union([z6.literal(301), z6.literal(302), z6.literal(307), z6.literal(308)]).optional(),
|
|
216
|
+
response_headers: z6.array(
|
|
217
|
+
z6.object({
|
|
218
|
+
key: z6.string().min(1).refine((k) => !FORBIDDEN_HEADERS.includes(k.toLowerCase()), {
|
|
219
|
+
message: "This header is not allowed"
|
|
220
|
+
}),
|
|
221
|
+
value: z6.string().regex(/^[^\r\n]*$/, "Header value must not contain newlines"),
|
|
222
|
+
mode: z6.enum(["set", "append"])
|
|
223
|
+
})
|
|
224
|
+
).optional()
|
|
225
|
+
}),
|
|
226
|
+
next: z6.string().nullable()
|
|
227
|
+
});
|
|
228
|
+
var RuleGraphNodeSchema = z6.discriminatedUnion("type", [
|
|
229
|
+
ConditionNodeSchema,
|
|
230
|
+
SplitNodeSchema,
|
|
231
|
+
DestinationNodeSchema,
|
|
232
|
+
TransformNodeSchema
|
|
233
|
+
]);
|
|
189
234
|
var RuleGraphSchema = z6.object({
|
|
190
235
|
entry: z6.string(),
|
|
191
236
|
nodes: z6.record(z6.string(), RuleGraphNodeSchema)
|
|
@@ -449,6 +494,11 @@ var apiKeysContract = {
|
|
|
449
494
|
list: oc.route({ method: "GET", path: "/api/api-keys" }).output(z11.array(ApiKeySchema)),
|
|
450
495
|
delete: oc.route({ method: "DELETE", path: "/api/api-keys/{api_key_id}" }).input(ApiKeyIdParamSchema).output(z11.void())
|
|
451
496
|
};
|
|
497
|
+
var workspaceApiKeysContract = {
|
|
498
|
+
create: oc.route({ method: "POST", path: "/api/workspaces/{workspace_id}/api-keys" }).input(WorkspaceIdParamSchema.merge(CreateWorkspaceApiKeyInputSchema)).output(CreateWorkspaceApiKeyResponseSchema),
|
|
499
|
+
list: oc.route({ method: "GET", path: "/api/workspaces/{workspace_id}/api-keys" }).input(WorkspaceIdParamSchema).output(z11.array(ApiKeySchema)),
|
|
500
|
+
delete: oc.route({ method: "DELETE", path: "/api/workspaces/{workspace_id}/api-keys/{api_key_id}" }).input(WorkspaceApiKeyIdParamSchema).output(z11.void())
|
|
501
|
+
};
|
|
452
502
|
var workspacesContract = {
|
|
453
503
|
create: oc.route({ method: "POST", path: "/api/workspaces" }).input(CreateWorkspaceInputSchema).output(WorkspaceSchema),
|
|
454
504
|
list: oc.route({ method: "GET", path: "/api/workspaces" }).output(z11.array(WorkspaceWithCountSchema)),
|
|
@@ -506,6 +556,7 @@ var contract = {
|
|
|
506
556
|
analytics: analyticsContract,
|
|
507
557
|
users: usersContract,
|
|
508
558
|
apiKeys: apiKeysContract,
|
|
559
|
+
workspaceApiKeys: workspaceApiKeysContract,
|
|
509
560
|
workspaces: workspacesContract,
|
|
510
561
|
invitations: invitationsContract,
|
|
511
562
|
links: linksContract,
|
|
@@ -529,6 +580,8 @@ export {
|
|
|
529
580
|
CreateInvitationInputSchema,
|
|
530
581
|
CreateLinkInputSchema,
|
|
531
582
|
CreateTagInputSchema,
|
|
583
|
+
CreateWorkspaceApiKeyInputSchema,
|
|
584
|
+
CreateWorkspaceApiKeyResponseSchema,
|
|
532
585
|
CreateWorkspaceInputSchema,
|
|
533
586
|
CustomerPortalSchema,
|
|
534
587
|
DomainIdParamSchema,
|
|
@@ -559,6 +612,7 @@ export {
|
|
|
559
612
|
UpdateWorkspaceInputSchema,
|
|
560
613
|
UserIdParamSchema,
|
|
561
614
|
UserSchema,
|
|
615
|
+
WorkspaceApiKeyIdParamSchema,
|
|
562
616
|
WorkspaceIdParamSchema,
|
|
563
617
|
WorkspaceInvitationSchema,
|
|
564
618
|
WorkspaceMemberSchema,
|
|
@@ -575,5 +629,6 @@ export {
|
|
|
575
629
|
linksContract,
|
|
576
630
|
tagsContract,
|
|
577
631
|
usersContract,
|
|
632
|
+
workspaceApiKeysContract,
|
|
578
633
|
workspacesContract
|
|
579
634
|
};
|
|
@@ -124,6 +124,33 @@ export declare const LinkSchema: z.ZodObject<{
|
|
|
124
124
|
y: z.ZodNumber;
|
|
125
125
|
}, z.core.$strip>;
|
|
126
126
|
url: z.ZodString;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
type: z.ZodLiteral<"transform">;
|
|
130
|
+
position: z.ZodObject<{
|
|
131
|
+
x: z.ZodNumber;
|
|
132
|
+
y: z.ZodNumber;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
transforms: z.ZodObject<{
|
|
135
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
|
+
key: z.ZodString;
|
|
137
|
+
value: z.ZodString;
|
|
138
|
+
mode: z.ZodEnum<{
|
|
139
|
+
set: "set";
|
|
140
|
+
append: "append";
|
|
141
|
+
}>;
|
|
142
|
+
}, z.core.$strip>>>;
|
|
143
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
144
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
145
|
+
key: z.ZodString;
|
|
146
|
+
value: z.ZodString;
|
|
147
|
+
mode: z.ZodEnum<{
|
|
148
|
+
set: "set";
|
|
149
|
+
append: "append";
|
|
150
|
+
}>;
|
|
151
|
+
}, z.core.$strip>>>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
next: z.ZodNullable<z.ZodString>;
|
|
127
154
|
}, z.core.$strip>], "type">>;
|
|
128
155
|
}, z.core.$strip>>>;
|
|
129
156
|
tags: z.ZodArray<z.ZodObject<{
|
|
@@ -228,6 +255,33 @@ export declare const CreateLinkInputSchema: z.ZodObject<{
|
|
|
228
255
|
y: z.ZodNumber;
|
|
229
256
|
}, z.core.$strip>;
|
|
230
257
|
url: z.ZodString;
|
|
258
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
259
|
+
id: z.ZodString;
|
|
260
|
+
type: z.ZodLiteral<"transform">;
|
|
261
|
+
position: z.ZodObject<{
|
|
262
|
+
x: z.ZodNumber;
|
|
263
|
+
y: z.ZodNumber;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
transforms: z.ZodObject<{
|
|
266
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
267
|
+
key: z.ZodString;
|
|
268
|
+
value: z.ZodString;
|
|
269
|
+
mode: z.ZodEnum<{
|
|
270
|
+
set: "set";
|
|
271
|
+
append: "append";
|
|
272
|
+
}>;
|
|
273
|
+
}, z.core.$strip>>>;
|
|
274
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
275
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
276
|
+
key: z.ZodString;
|
|
277
|
+
value: z.ZodString;
|
|
278
|
+
mode: z.ZodEnum<{
|
|
279
|
+
set: "set";
|
|
280
|
+
append: "append";
|
|
281
|
+
}>;
|
|
282
|
+
}, z.core.$strip>>>;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
next: z.ZodNullable<z.ZodString>;
|
|
231
285
|
}, z.core.$strip>], "type">>;
|
|
232
286
|
}, z.core.$strip>>>;
|
|
233
287
|
}, z.core.$strip>;
|
|
@@ -325,6 +379,33 @@ export declare const UpdateLinkInputSchema: z.ZodObject<{
|
|
|
325
379
|
y: z.ZodNumber;
|
|
326
380
|
}, z.core.$strip>;
|
|
327
381
|
url: z.ZodString;
|
|
382
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
383
|
+
id: z.ZodString;
|
|
384
|
+
type: z.ZodLiteral<"transform">;
|
|
385
|
+
position: z.ZodObject<{
|
|
386
|
+
x: z.ZodNumber;
|
|
387
|
+
y: z.ZodNumber;
|
|
388
|
+
}, z.core.$strip>;
|
|
389
|
+
transforms: z.ZodObject<{
|
|
390
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
391
|
+
key: z.ZodString;
|
|
392
|
+
value: z.ZodString;
|
|
393
|
+
mode: z.ZodEnum<{
|
|
394
|
+
set: "set";
|
|
395
|
+
append: "append";
|
|
396
|
+
}>;
|
|
397
|
+
}, z.core.$strip>>>;
|
|
398
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
399
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
400
|
+
key: z.ZodString;
|
|
401
|
+
value: z.ZodString;
|
|
402
|
+
mode: z.ZodEnum<{
|
|
403
|
+
set: "set";
|
|
404
|
+
append: "append";
|
|
405
|
+
}>;
|
|
406
|
+
}, z.core.$strip>>>;
|
|
407
|
+
}, z.core.$strip>;
|
|
408
|
+
next: z.ZodNullable<z.ZodString>;
|
|
328
409
|
}, z.core.$strip>], "type">>;
|
|
329
410
|
}, z.core.$strip>>>;
|
|
330
411
|
}, z.core.$strip>;
|
|
@@ -462,6 +543,33 @@ export declare const PaginatedLinksSchema: z.ZodObject<{
|
|
|
462
543
|
y: z.ZodNumber;
|
|
463
544
|
}, z.core.$strip>;
|
|
464
545
|
url: z.ZodString;
|
|
546
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
547
|
+
id: z.ZodString;
|
|
548
|
+
type: z.ZodLiteral<"transform">;
|
|
549
|
+
position: z.ZodObject<{
|
|
550
|
+
x: z.ZodNumber;
|
|
551
|
+
y: z.ZodNumber;
|
|
552
|
+
}, z.core.$strip>;
|
|
553
|
+
transforms: z.ZodObject<{
|
|
554
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
555
|
+
key: z.ZodString;
|
|
556
|
+
value: z.ZodString;
|
|
557
|
+
mode: z.ZodEnum<{
|
|
558
|
+
set: "set";
|
|
559
|
+
append: "append";
|
|
560
|
+
}>;
|
|
561
|
+
}, z.core.$strip>>>;
|
|
562
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
563
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
564
|
+
key: z.ZodString;
|
|
565
|
+
value: z.ZodString;
|
|
566
|
+
mode: z.ZodEnum<{
|
|
567
|
+
set: "set";
|
|
568
|
+
append: "append";
|
|
569
|
+
}>;
|
|
570
|
+
}, z.core.$strip>>>;
|
|
571
|
+
}, z.core.$strip>;
|
|
572
|
+
next: z.ZodNullable<z.ZodString>;
|
|
465
573
|
}, z.core.$strip>], "type">>;
|
|
466
574
|
}, z.core.$strip>>>;
|
|
467
575
|
tags: z.ZodArray<z.ZodObject<{
|
|
@@ -1 +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;AASxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;iBAU/B,CAAC;AAEH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"links.schema.d.ts","sourceRoot":"","sources":["../../src/links.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;iBAU/B,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BrB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5B,CAAC;AAEP,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC5B,CAAC;AAMP,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAe5B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM/B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;iBAYxB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC"}
|
|
@@ -44,6 +44,33 @@ export declare const RuleGraphNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
44
44
|
y: z.ZodNumber;
|
|
45
45
|
}, z.core.$strip>;
|
|
46
46
|
url: z.ZodString;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
type: z.ZodLiteral<"transform">;
|
|
50
|
+
position: z.ZodObject<{
|
|
51
|
+
x: z.ZodNumber;
|
|
52
|
+
y: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
transforms: z.ZodObject<{
|
|
55
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
56
|
+
key: z.ZodString;
|
|
57
|
+
value: z.ZodString;
|
|
58
|
+
mode: z.ZodEnum<{
|
|
59
|
+
set: "set";
|
|
60
|
+
append: "append";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strip>>>;
|
|
63
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
64
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
+
key: z.ZodString;
|
|
66
|
+
value: z.ZodString;
|
|
67
|
+
mode: z.ZodEnum<{
|
|
68
|
+
set: "set";
|
|
69
|
+
append: "append";
|
|
70
|
+
}>;
|
|
71
|
+
}, z.core.$strip>>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
next: z.ZodNullable<z.ZodString>;
|
|
47
74
|
}, z.core.$strip>], "type">;
|
|
48
75
|
export declare const RuleGraphSchema: z.ZodNullable<z.ZodObject<{
|
|
49
76
|
entry: z.ZodString;
|
|
@@ -92,6 +119,33 @@ export declare const RuleGraphSchema: z.ZodNullable<z.ZodObject<{
|
|
|
92
119
|
y: z.ZodNumber;
|
|
93
120
|
}, z.core.$strip>;
|
|
94
121
|
url: z.ZodString;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
type: z.ZodLiteral<"transform">;
|
|
125
|
+
position: z.ZodObject<{
|
|
126
|
+
x: z.ZodNumber;
|
|
127
|
+
y: z.ZodNumber;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
transforms: z.ZodObject<{
|
|
130
|
+
query_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
131
|
+
key: z.ZodString;
|
|
132
|
+
value: z.ZodString;
|
|
133
|
+
mode: z.ZodEnum<{
|
|
134
|
+
set: "set";
|
|
135
|
+
append: "append";
|
|
136
|
+
}>;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
138
|
+
redirect_status: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>>;
|
|
139
|
+
response_headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
140
|
+
key: z.ZodString;
|
|
141
|
+
value: z.ZodString;
|
|
142
|
+
mode: z.ZodEnum<{
|
|
143
|
+
set: "set";
|
|
144
|
+
append: "append";
|
|
145
|
+
}>;
|
|
146
|
+
}, z.core.$strip>>>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
next: z.ZodNullable<z.ZodString>;
|
|
95
149
|
}, z.core.$strip>], "type">>;
|
|
96
150
|
}, z.core.$strip>>;
|
|
97
151
|
//# 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;
|
|
1
|
+
{"version":3,"file":"rules.schema.d.ts","sourceRoot":"","sources":["../../src/rules.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiFxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAK9B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASb,CAAC"}
|
package/package.json
CHANGED
package/src/api-keys.schema.ts
CHANGED
|
@@ -2,9 +2,12 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
export const ApiKeySchema = z.object({
|
|
4
4
|
id: z.string().uuid(),
|
|
5
|
-
|
|
5
|
+
owner_type: z.enum(['user', 'workspace']),
|
|
6
|
+
owner_id: z.string().uuid(),
|
|
7
|
+
created_by_id: z.string().uuid().nullable(),
|
|
6
8
|
name: z.string(),
|
|
7
9
|
key_prefix: z.string(),
|
|
10
|
+
permissions: z.number().int().nullable(),
|
|
8
11
|
last_used_at: z.coerce.date().nullable(),
|
|
9
12
|
created_at: z.coerce.date(),
|
|
10
13
|
updated_at: z.coerce.date().nullable(),
|
|
@@ -17,3 +20,12 @@ export const CreateApiKeyInputSchema = z.object({
|
|
|
17
20
|
export const CreateApiKeyResponseSchema = ApiKeySchema.extend({
|
|
18
21
|
key: z.string(),
|
|
19
22
|
});
|
|
23
|
+
|
|
24
|
+
export const CreateWorkspaceApiKeyInputSchema = z.object({
|
|
25
|
+
name: z.string().min(1).max(255),
|
|
26
|
+
permissions: z.number().int().min(1),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const CreateWorkspaceApiKeyResponseSchema = ApiKeySchema.extend({
|
|
30
|
+
key: z.string(),
|
|
31
|
+
});
|
package/src/common.schema.ts
CHANGED
|
@@ -37,6 +37,11 @@ export const ApiKeyIdParamSchema = z.object({
|
|
|
37
37
|
api_key_id: z.string().uuid(),
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
export const WorkspaceApiKeyIdParamSchema = z.object({
|
|
41
|
+
workspace_id: z.string().uuid(),
|
|
42
|
+
api_key_id: z.string().uuid(),
|
|
43
|
+
});
|
|
44
|
+
|
|
40
45
|
export const TokenParamSchema = z.object({
|
|
41
46
|
token: z.string(),
|
|
42
47
|
});
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,13 @@ import { oc } from '@orpc/contract';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { AnalyticsOutputSchema, AnalyticsQuerySchema } from './analytics.schema';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ApiKeySchema,
|
|
8
|
+
CreateApiKeyInputSchema,
|
|
9
|
+
CreateApiKeyResponseSchema,
|
|
10
|
+
CreateWorkspaceApiKeyInputSchema,
|
|
11
|
+
CreateWorkspaceApiKeyResponseSchema,
|
|
12
|
+
} from './api-keys.schema';
|
|
7
13
|
import { BillingStatusSchema, CheckoutSessionSchema, CreateCheckoutInputSchema, CustomerPortalSchema } from './billing.schema';
|
|
8
14
|
import {
|
|
9
15
|
ApiKeyIdParamSchema,
|
|
@@ -13,6 +19,7 @@ import {
|
|
|
13
19
|
MemberIdParamSchema,
|
|
14
20
|
TagIdParamSchema,
|
|
15
21
|
TokenParamSchema,
|
|
22
|
+
WorkspaceApiKeyIdParamSchema,
|
|
16
23
|
WorkspaceIdParamSchema,
|
|
17
24
|
} from './common.schema';
|
|
18
25
|
import { CreateDomainInputSchema, DomainSchema, UpdateDomainInputSchema } from './domains.schema';
|
|
@@ -89,6 +96,24 @@ export const apiKeysContract = {
|
|
|
89
96
|
delete: oc.route({ method: 'DELETE', path: '/api/api-keys/{api_key_id}' }).input(ApiKeyIdParamSchema).output(z.void()),
|
|
90
97
|
};
|
|
91
98
|
|
|
99
|
+
// Workspace API Keys contract
|
|
100
|
+
export const workspaceApiKeysContract = {
|
|
101
|
+
create: oc
|
|
102
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/api-keys' })
|
|
103
|
+
.input(WorkspaceIdParamSchema.merge(CreateWorkspaceApiKeyInputSchema))
|
|
104
|
+
.output(CreateWorkspaceApiKeyResponseSchema),
|
|
105
|
+
|
|
106
|
+
list: oc
|
|
107
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/api-keys' })
|
|
108
|
+
.input(WorkspaceIdParamSchema)
|
|
109
|
+
.output(z.array(ApiKeySchema)),
|
|
110
|
+
|
|
111
|
+
delete: oc
|
|
112
|
+
.route({ method: 'DELETE', path: '/api/workspaces/{workspace_id}/api-keys/{api_key_id}' })
|
|
113
|
+
.input(WorkspaceApiKeyIdParamSchema)
|
|
114
|
+
.output(z.void()),
|
|
115
|
+
};
|
|
116
|
+
|
|
92
117
|
// Workspaces contract
|
|
93
118
|
export const workspacesContract = {
|
|
94
119
|
create: oc.route({ method: 'POST', path: '/api/workspaces' }).input(CreateWorkspaceInputSchema).output(WorkspaceSchema),
|
|
@@ -275,6 +300,7 @@ export const contract = {
|
|
|
275
300
|
analytics: analyticsContract,
|
|
276
301
|
users: usersContract,
|
|
277
302
|
apiKeys: apiKeysContract,
|
|
303
|
+
workspaceApiKeys: workspaceApiKeysContract,
|
|
278
304
|
workspaces: workspacesContract,
|
|
279
305
|
invitations: invitationsContract,
|
|
280
306
|
links: linksContract,
|
package/src/rules.schema.ts
CHANGED
|
@@ -44,7 +44,47 @@ const DestinationNodeSchema = z.object({
|
|
|
44
44
|
url: z.string().url(),
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const FORBIDDEN_HEADERS = ['set-cookie', 'authorization', 'host', 'transfer-encoding'];
|
|
48
|
+
|
|
49
|
+
const TransformNodeSchema = z.object({
|
|
50
|
+
id: z.string(),
|
|
51
|
+
type: z.literal('transform'),
|
|
52
|
+
position: PositionSchema,
|
|
53
|
+
transforms: z.object({
|
|
54
|
+
query_params: z
|
|
55
|
+
.array(
|
|
56
|
+
z.object({
|
|
57
|
+
key: z.string().min(1),
|
|
58
|
+
value: z.string(),
|
|
59
|
+
mode: z.enum(['set', 'append']),
|
|
60
|
+
}),
|
|
61
|
+
)
|
|
62
|
+
.optional(),
|
|
63
|
+
redirect_status: z.union([z.literal(301), z.literal(302), z.literal(307), z.literal(308)]).optional(),
|
|
64
|
+
response_headers: z
|
|
65
|
+
.array(
|
|
66
|
+
z.object({
|
|
67
|
+
key: z
|
|
68
|
+
.string()
|
|
69
|
+
.min(1)
|
|
70
|
+
.refine((k) => !FORBIDDEN_HEADERS.includes(k.toLowerCase()), {
|
|
71
|
+
message: 'This header is not allowed',
|
|
72
|
+
}),
|
|
73
|
+
value: z.string().regex(/^[^\r\n]*$/, 'Header value must not contain newlines'),
|
|
74
|
+
mode: z.enum(['set', 'append']),
|
|
75
|
+
}),
|
|
76
|
+
)
|
|
77
|
+
.optional(),
|
|
78
|
+
}),
|
|
79
|
+
next: z.string().nullable(),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const RuleGraphNodeSchema = z.discriminatedUnion('type', [
|
|
83
|
+
ConditionNodeSchema,
|
|
84
|
+
SplitNodeSchema,
|
|
85
|
+
DestinationNodeSchema,
|
|
86
|
+
TransformNodeSchema,
|
|
87
|
+
]);
|
|
48
88
|
|
|
49
89
|
export const RuleGraphSchema = z
|
|
50
90
|
.object({
|