@zapier/policy-schema 0.3.0 → 0.5.0
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/index.cjs +23 -8
- package/dist/index.d.cts +27 -13
- package/dist/index.d.ts +27 -13
- package/dist/index.mjs +23 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,10 +5,20 @@ var zod = require('zod');
|
|
|
5
5
|
// src/schema.ts
|
|
6
6
|
var ScalarSchema = zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean()]);
|
|
7
7
|
var PathSchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).min(1);
|
|
8
|
+
var JsonValueSchema = zod.z.lazy(
|
|
9
|
+
() => zod.z.union([
|
|
10
|
+
zod.z.string(),
|
|
11
|
+
zod.z.number(),
|
|
12
|
+
zod.z.boolean(),
|
|
13
|
+
zod.z.null(),
|
|
14
|
+
zod.z.array(JsonValueSchema),
|
|
15
|
+
zod.z.record(zod.z.string(), JsonValueSchema)
|
|
16
|
+
])
|
|
17
|
+
);
|
|
8
18
|
var EqualsConditionSchema = zod.z.object({
|
|
9
19
|
path: PathSchema,
|
|
10
20
|
operator: zod.z.literal("equals"),
|
|
11
|
-
value:
|
|
21
|
+
value: JsonValueSchema
|
|
12
22
|
}).strict();
|
|
13
23
|
var InConditionSchema = zod.z.object({
|
|
14
24
|
path: PathSchema,
|
|
@@ -41,6 +51,11 @@ var RangeConditionSchema = zod.z.object({
|
|
|
41
51
|
operator: zod.z.literal("range"),
|
|
42
52
|
value: RangeValueSchema
|
|
43
53
|
}).strict();
|
|
54
|
+
var MatchesUrlConditionSchema = zod.z.object({
|
|
55
|
+
path: PathSchema,
|
|
56
|
+
operator: zod.z.literal("matches_url"),
|
|
57
|
+
value: zod.z.string()
|
|
58
|
+
}).strict();
|
|
44
59
|
var ValuesInConditionSchema = zod.z.object({
|
|
45
60
|
path: PathSchema,
|
|
46
61
|
operator: zod.z.literal("values_in"),
|
|
@@ -72,6 +87,8 @@ var ConditionSchema = zod.z.union([
|
|
|
72
87
|
MatchesHostConditionSchema,
|
|
73
88
|
MatchesPathConditionSchema,
|
|
74
89
|
RangeConditionSchema,
|
|
90
|
+
// URL operators
|
|
91
|
+
MatchesUrlConditionSchema,
|
|
75
92
|
// Array operators
|
|
76
93
|
ValuesInConditionSchema,
|
|
77
94
|
// Other operators
|
|
@@ -88,6 +105,7 @@ var ScalarOperatorSchema = zod.z.enum([
|
|
|
88
105
|
"range"
|
|
89
106
|
]);
|
|
90
107
|
var ArrayOperatorSchema = zod.z.enum(["values_in"]);
|
|
108
|
+
var UrlOperatorSchema = zod.z.enum(["matches_url"]);
|
|
91
109
|
var OtherOperatorSchema = zod.z.enum(["exists", "keys_in", "size"]);
|
|
92
110
|
var OperatorSchema = zod.z.enum([
|
|
93
111
|
// Scalar
|
|
@@ -97,6 +115,8 @@ var OperatorSchema = zod.z.enum([
|
|
|
97
115
|
"matches_host",
|
|
98
116
|
"matches_path",
|
|
99
117
|
"range",
|
|
118
|
+
// URL
|
|
119
|
+
"matches_url",
|
|
100
120
|
// Array
|
|
101
121
|
"values_in",
|
|
102
122
|
// Other
|
|
@@ -104,13 +124,7 @@ var OperatorSchema = zod.z.enum([
|
|
|
104
124
|
"keys_in",
|
|
105
125
|
"size"
|
|
106
126
|
]);
|
|
107
|
-
var ConditionValueSchema =
|
|
108
|
-
ScalarSchema,
|
|
109
|
-
zod.z.array(ScalarSchema),
|
|
110
|
-
RangeValueSchema,
|
|
111
|
-
SizeValueSchema,
|
|
112
|
-
zod.z.array(zod.z.string())
|
|
113
|
-
]);
|
|
127
|
+
var ConditionValueSchema = JsonValueSchema;
|
|
114
128
|
var StatementSchema = zod.z.object({
|
|
115
129
|
effect: zod.z.enum(["allow", "deny"]),
|
|
116
130
|
permissions: zod.z.array(zod.z.string()).min(1),
|
|
@@ -132,3 +146,4 @@ exports.RangeValueSchema = RangeValueSchema;
|
|
|
132
146
|
exports.ScalarOperatorSchema = ScalarOperatorSchema;
|
|
133
147
|
exports.SizeValueSchema = SizeValueSchema;
|
|
134
148
|
exports.StatementSchema = StatementSchema;
|
|
149
|
+
exports.UrlOperatorSchema = UrlOperatorSchema;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
type ScalarOperator = "equals" | "in" | "matches" | "matches_host" | "matches_path" | "range";
|
|
4
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
4
7
|
type ArrayOperator = "values_in";
|
|
8
|
+
type UrlOperator = "matches_url";
|
|
5
9
|
type OtherOperator = "exists" | "keys_in" | "size";
|
|
6
|
-
type Operator = ScalarOperator | ArrayOperator | OtherOperator;
|
|
10
|
+
type Operator = ScalarOperator | ArrayOperator | UrlOperator | OtherOperator;
|
|
7
11
|
type RangeValue = {
|
|
8
12
|
min?: number;
|
|
9
13
|
max?: number;
|
|
10
14
|
};
|
|
11
15
|
type SizeValue = number | RangeValue;
|
|
12
|
-
type ConditionValue =
|
|
16
|
+
type ConditionValue = JsonValue | RangeValue | SizeValue;
|
|
13
17
|
interface Condition {
|
|
14
18
|
path: (string | number)[];
|
|
15
19
|
operator: Operator;
|
|
@@ -61,7 +65,7 @@ declare const SizeValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
|
61
65
|
declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
62
66
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
63
67
|
operator: z.ZodLiteral<"equals">;
|
|
64
|
-
value: z.
|
|
68
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
65
69
|
}, z.core.$strict>, z.ZodObject<{
|
|
66
70
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
67
71
|
operator: z.ZodLiteral<"in">;
|
|
@@ -85,6 +89,10 @@ declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
85
89
|
min: z.ZodOptional<z.ZodNumber>;
|
|
86
90
|
max: z.ZodOptional<z.ZodNumber>;
|
|
87
91
|
}, z.core.$strict>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
94
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
95
|
+
value: z.ZodString;
|
|
88
96
|
}, z.core.$strict>, z.ZodObject<{
|
|
89
97
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
90
98
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -115,6 +123,9 @@ declare const ScalarOperatorSchema: z.ZodEnum<{
|
|
|
115
123
|
declare const ArrayOperatorSchema: z.ZodEnum<{
|
|
116
124
|
values_in: "values_in";
|
|
117
125
|
}>;
|
|
126
|
+
declare const UrlOperatorSchema: z.ZodEnum<{
|
|
127
|
+
matches_url: "matches_url";
|
|
128
|
+
}>;
|
|
118
129
|
declare const OtherOperatorSchema: z.ZodEnum<{
|
|
119
130
|
exists: "exists";
|
|
120
131
|
keys_in: "keys_in";
|
|
@@ -131,14 +142,9 @@ declare const OperatorSchema: z.ZodEnum<{
|
|
|
131
142
|
keys_in: "keys_in";
|
|
132
143
|
size: "size";
|
|
133
144
|
values_in: "values_in";
|
|
145
|
+
matches_url: "matches_url";
|
|
134
146
|
}>;
|
|
135
|
-
declare const ConditionValueSchema: z.
|
|
136
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
137
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
138
|
-
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
139
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
140
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
141
|
-
}, z.core.$strict>]>, z.ZodArray<z.ZodString>]>;
|
|
147
|
+
declare const ConditionValueSchema: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
142
148
|
declare const StatementSchema: z.ZodObject<{
|
|
143
149
|
effect: z.ZodEnum<{
|
|
144
150
|
allow: "allow";
|
|
@@ -149,7 +155,7 @@ declare const StatementSchema: z.ZodObject<{
|
|
|
149
155
|
conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
150
156
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
151
157
|
operator: z.ZodLiteral<"equals">;
|
|
152
|
-
value: z.
|
|
158
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
153
159
|
}, z.core.$strict>, z.ZodObject<{
|
|
154
160
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
155
161
|
operator: z.ZodLiteral<"in">;
|
|
@@ -173,6 +179,10 @@ declare const StatementSchema: z.ZodObject<{
|
|
|
173
179
|
min: z.ZodOptional<z.ZodNumber>;
|
|
174
180
|
max: z.ZodOptional<z.ZodNumber>;
|
|
175
181
|
}, z.core.$strict>;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
184
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
185
|
+
value: z.ZodString;
|
|
176
186
|
}, z.core.$strict>, z.ZodObject<{
|
|
177
187
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
178
188
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -205,7 +215,7 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
205
215
|
conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
206
216
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
207
217
|
operator: z.ZodLiteral<"equals">;
|
|
208
|
-
value: z.
|
|
218
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
209
219
|
}, z.core.$strict>, z.ZodObject<{
|
|
210
220
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
211
221
|
operator: z.ZodLiteral<"in">;
|
|
@@ -229,6 +239,10 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
229
239
|
min: z.ZodOptional<z.ZodNumber>;
|
|
230
240
|
max: z.ZodOptional<z.ZodNumber>;
|
|
231
241
|
}, z.core.$strict>;
|
|
242
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
243
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
244
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
245
|
+
value: z.ZodString;
|
|
232
246
|
}, z.core.$strict>, z.ZodObject<{
|
|
233
247
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
234
248
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -251,4 +265,4 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
251
265
|
}, z.core.$strict>>;
|
|
252
266
|
}, z.core.$strict>;
|
|
253
267
|
|
|
254
|
-
export { type ArrayOperator, ArrayOperatorSchema, type Condition, ConditionSchema, type ConditionValue, ConditionValueSchema, type Effect, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type ParsedUrl, type Policy, type PolicyHttpRequest, type PolicyRequest, type PolicyResult, PolicySchema, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, StatementSchema };
|
|
268
|
+
export { type ArrayOperator, ArrayOperatorSchema, type Condition, ConditionSchema, type ConditionValue, ConditionValueSchema, type Effect, type JsonValue, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type ParsedUrl, type Policy, type PolicyHttpRequest, type PolicyRequest, type PolicyResult, PolicySchema, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, StatementSchema, type UrlOperator, UrlOperatorSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
type ScalarOperator = "equals" | "in" | "matches" | "matches_host" | "matches_path" | "range";
|
|
4
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
4
7
|
type ArrayOperator = "values_in";
|
|
8
|
+
type UrlOperator = "matches_url";
|
|
5
9
|
type OtherOperator = "exists" | "keys_in" | "size";
|
|
6
|
-
type Operator = ScalarOperator | ArrayOperator | OtherOperator;
|
|
10
|
+
type Operator = ScalarOperator | ArrayOperator | UrlOperator | OtherOperator;
|
|
7
11
|
type RangeValue = {
|
|
8
12
|
min?: number;
|
|
9
13
|
max?: number;
|
|
10
14
|
};
|
|
11
15
|
type SizeValue = number | RangeValue;
|
|
12
|
-
type ConditionValue =
|
|
16
|
+
type ConditionValue = JsonValue | RangeValue | SizeValue;
|
|
13
17
|
interface Condition {
|
|
14
18
|
path: (string | number)[];
|
|
15
19
|
operator: Operator;
|
|
@@ -61,7 +65,7 @@ declare const SizeValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
|
61
65
|
declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
62
66
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
63
67
|
operator: z.ZodLiteral<"equals">;
|
|
64
|
-
value: z.
|
|
68
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
65
69
|
}, z.core.$strict>, z.ZodObject<{
|
|
66
70
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
67
71
|
operator: z.ZodLiteral<"in">;
|
|
@@ -85,6 +89,10 @@ declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
85
89
|
min: z.ZodOptional<z.ZodNumber>;
|
|
86
90
|
max: z.ZodOptional<z.ZodNumber>;
|
|
87
91
|
}, z.core.$strict>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
94
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
95
|
+
value: z.ZodString;
|
|
88
96
|
}, z.core.$strict>, z.ZodObject<{
|
|
89
97
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
90
98
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -115,6 +123,9 @@ declare const ScalarOperatorSchema: z.ZodEnum<{
|
|
|
115
123
|
declare const ArrayOperatorSchema: z.ZodEnum<{
|
|
116
124
|
values_in: "values_in";
|
|
117
125
|
}>;
|
|
126
|
+
declare const UrlOperatorSchema: z.ZodEnum<{
|
|
127
|
+
matches_url: "matches_url";
|
|
128
|
+
}>;
|
|
118
129
|
declare const OtherOperatorSchema: z.ZodEnum<{
|
|
119
130
|
exists: "exists";
|
|
120
131
|
keys_in: "keys_in";
|
|
@@ -131,14 +142,9 @@ declare const OperatorSchema: z.ZodEnum<{
|
|
|
131
142
|
keys_in: "keys_in";
|
|
132
143
|
size: "size";
|
|
133
144
|
values_in: "values_in";
|
|
145
|
+
matches_url: "matches_url";
|
|
134
146
|
}>;
|
|
135
|
-
declare const ConditionValueSchema: z.
|
|
136
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
137
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
138
|
-
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
139
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
140
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
141
|
-
}, z.core.$strict>]>, z.ZodArray<z.ZodString>]>;
|
|
147
|
+
declare const ConditionValueSchema: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
142
148
|
declare const StatementSchema: z.ZodObject<{
|
|
143
149
|
effect: z.ZodEnum<{
|
|
144
150
|
allow: "allow";
|
|
@@ -149,7 +155,7 @@ declare const StatementSchema: z.ZodObject<{
|
|
|
149
155
|
conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
150
156
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
151
157
|
operator: z.ZodLiteral<"equals">;
|
|
152
|
-
value: z.
|
|
158
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
153
159
|
}, z.core.$strict>, z.ZodObject<{
|
|
154
160
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
155
161
|
operator: z.ZodLiteral<"in">;
|
|
@@ -173,6 +179,10 @@ declare const StatementSchema: z.ZodObject<{
|
|
|
173
179
|
min: z.ZodOptional<z.ZodNumber>;
|
|
174
180
|
max: z.ZodOptional<z.ZodNumber>;
|
|
175
181
|
}, z.core.$strict>;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
184
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
185
|
+
value: z.ZodString;
|
|
176
186
|
}, z.core.$strict>, z.ZodObject<{
|
|
177
187
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
178
188
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -205,7 +215,7 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
205
215
|
conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
206
216
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
207
217
|
operator: z.ZodLiteral<"equals">;
|
|
208
|
-
value: z.
|
|
218
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
209
219
|
}, z.core.$strict>, z.ZodObject<{
|
|
210
220
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
211
221
|
operator: z.ZodLiteral<"in">;
|
|
@@ -229,6 +239,10 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
229
239
|
min: z.ZodOptional<z.ZodNumber>;
|
|
230
240
|
max: z.ZodOptional<z.ZodNumber>;
|
|
231
241
|
}, z.core.$strict>;
|
|
242
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
243
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
244
|
+
operator: z.ZodLiteral<"matches_url">;
|
|
245
|
+
value: z.ZodString;
|
|
232
246
|
}, z.core.$strict>, z.ZodObject<{
|
|
233
247
|
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
234
248
|
operator: z.ZodLiteral<"values_in">;
|
|
@@ -251,4 +265,4 @@ declare const PolicySchema: z.ZodObject<{
|
|
|
251
265
|
}, z.core.$strict>>;
|
|
252
266
|
}, z.core.$strict>;
|
|
253
267
|
|
|
254
|
-
export { type ArrayOperator, ArrayOperatorSchema, type Condition, ConditionSchema, type ConditionValue, ConditionValueSchema, type Effect, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type ParsedUrl, type Policy, type PolicyHttpRequest, type PolicyRequest, type PolicyResult, PolicySchema, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, StatementSchema };
|
|
268
|
+
export { type ArrayOperator, ArrayOperatorSchema, type Condition, ConditionSchema, type ConditionValue, ConditionValueSchema, type Effect, type JsonValue, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type ParsedUrl, type Policy, type PolicyHttpRequest, type PolicyRequest, type PolicyResult, PolicySchema, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, StatementSchema, type UrlOperator, UrlOperatorSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,20 @@ import { z } from 'zod';
|
|
|
3
3
|
// src/schema.ts
|
|
4
4
|
var ScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
5
5
|
var PathSchema = z.array(z.union([z.string(), z.number()])).min(1);
|
|
6
|
+
var JsonValueSchema = z.lazy(
|
|
7
|
+
() => z.union([
|
|
8
|
+
z.string(),
|
|
9
|
+
z.number(),
|
|
10
|
+
z.boolean(),
|
|
11
|
+
z.null(),
|
|
12
|
+
z.array(JsonValueSchema),
|
|
13
|
+
z.record(z.string(), JsonValueSchema)
|
|
14
|
+
])
|
|
15
|
+
);
|
|
6
16
|
var EqualsConditionSchema = z.object({
|
|
7
17
|
path: PathSchema,
|
|
8
18
|
operator: z.literal("equals"),
|
|
9
|
-
value:
|
|
19
|
+
value: JsonValueSchema
|
|
10
20
|
}).strict();
|
|
11
21
|
var InConditionSchema = z.object({
|
|
12
22
|
path: PathSchema,
|
|
@@ -39,6 +49,11 @@ var RangeConditionSchema = z.object({
|
|
|
39
49
|
operator: z.literal("range"),
|
|
40
50
|
value: RangeValueSchema
|
|
41
51
|
}).strict();
|
|
52
|
+
var MatchesUrlConditionSchema = z.object({
|
|
53
|
+
path: PathSchema,
|
|
54
|
+
operator: z.literal("matches_url"),
|
|
55
|
+
value: z.string()
|
|
56
|
+
}).strict();
|
|
42
57
|
var ValuesInConditionSchema = z.object({
|
|
43
58
|
path: PathSchema,
|
|
44
59
|
operator: z.literal("values_in"),
|
|
@@ -70,6 +85,8 @@ var ConditionSchema = z.union([
|
|
|
70
85
|
MatchesHostConditionSchema,
|
|
71
86
|
MatchesPathConditionSchema,
|
|
72
87
|
RangeConditionSchema,
|
|
88
|
+
// URL operators
|
|
89
|
+
MatchesUrlConditionSchema,
|
|
73
90
|
// Array operators
|
|
74
91
|
ValuesInConditionSchema,
|
|
75
92
|
// Other operators
|
|
@@ -86,6 +103,7 @@ var ScalarOperatorSchema = z.enum([
|
|
|
86
103
|
"range"
|
|
87
104
|
]);
|
|
88
105
|
var ArrayOperatorSchema = z.enum(["values_in"]);
|
|
106
|
+
var UrlOperatorSchema = z.enum(["matches_url"]);
|
|
89
107
|
var OtherOperatorSchema = z.enum(["exists", "keys_in", "size"]);
|
|
90
108
|
var OperatorSchema = z.enum([
|
|
91
109
|
// Scalar
|
|
@@ -95,6 +113,8 @@ var OperatorSchema = z.enum([
|
|
|
95
113
|
"matches_host",
|
|
96
114
|
"matches_path",
|
|
97
115
|
"range",
|
|
116
|
+
// URL
|
|
117
|
+
"matches_url",
|
|
98
118
|
// Array
|
|
99
119
|
"values_in",
|
|
100
120
|
// Other
|
|
@@ -102,13 +122,7 @@ var OperatorSchema = z.enum([
|
|
|
102
122
|
"keys_in",
|
|
103
123
|
"size"
|
|
104
124
|
]);
|
|
105
|
-
var ConditionValueSchema =
|
|
106
|
-
ScalarSchema,
|
|
107
|
-
z.array(ScalarSchema),
|
|
108
|
-
RangeValueSchema,
|
|
109
|
-
SizeValueSchema,
|
|
110
|
-
z.array(z.string())
|
|
111
|
-
]);
|
|
125
|
+
var ConditionValueSchema = JsonValueSchema;
|
|
112
126
|
var StatementSchema = z.object({
|
|
113
127
|
effect: z.enum(["allow", "deny"]),
|
|
114
128
|
permissions: z.array(z.string()).min(1),
|
|
@@ -120,4 +134,4 @@ var PolicySchema = z.object({
|
|
|
120
134
|
statements: z.array(StatementSchema)
|
|
121
135
|
}).strict();
|
|
122
136
|
|
|
123
|
-
export { ArrayOperatorSchema, ConditionSchema, ConditionValueSchema, OperatorSchema, OtherOperatorSchema, PolicySchema, RangeValueSchema, ScalarOperatorSchema, SizeValueSchema, StatementSchema };
|
|
137
|
+
export { ArrayOperatorSchema, ConditionSchema, ConditionValueSchema, OperatorSchema, OtherOperatorSchema, PolicySchema, RangeValueSchema, ScalarOperatorSchema, SizeValueSchema, StatementSchema, UrlOperatorSchema };
|