@zapier/policy-schema 0.4.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 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: ScalarSchema
21
+ value: JsonValueSchema
12
22
  }).strict();
13
23
  var InConditionSchema = zod.z.object({
14
24
  path: PathSchema,
@@ -114,13 +124,7 @@ var OperatorSchema = zod.z.enum([
114
124
  "keys_in",
115
125
  "size"
116
126
  ]);
117
- var ConditionValueSchema = zod.z.union([
118
- ScalarSchema,
119
- zod.z.array(ScalarSchema),
120
- RangeValueSchema,
121
- SizeValueSchema,
122
- zod.z.array(zod.z.string())
123
- ]);
127
+ var ConditionValueSchema = JsonValueSchema;
124
128
  var StatementSchema = zod.z.object({
125
129
  effect: zod.z.enum(["allow", "deny"]),
126
130
  permissions: zod.z.array(zod.z.string()).min(1),
package/dist/index.d.cts CHANGED
@@ -1,6 +1,9 @@
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";
5
8
  type UrlOperator = "matches_url";
6
9
  type OtherOperator = "exists" | "keys_in" | "size";
@@ -10,7 +13,7 @@ type RangeValue = {
10
13
  max?: number;
11
14
  };
12
15
  type SizeValue = number | RangeValue;
13
- type ConditionValue = string | number | boolean | (string | number | boolean)[] | RangeValue | SizeValue;
16
+ type ConditionValue = JsonValue | RangeValue | SizeValue;
14
17
  interface Condition {
15
18
  path: (string | number)[];
16
19
  operator: Operator;
@@ -62,7 +65,7 @@ declare const SizeValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
62
65
  declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
63
66
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
64
67
  operator: z.ZodLiteral<"equals">;
65
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
68
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
66
69
  }, z.core.$strict>, z.ZodObject<{
67
70
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
68
71
  operator: z.ZodLiteral<"in">;
@@ -141,13 +144,7 @@ declare const OperatorSchema: z.ZodEnum<{
141
144
  values_in: "values_in";
142
145
  matches_url: "matches_url";
143
146
  }>;
144
- declare const ConditionValueSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodObject<{
145
- min: z.ZodOptional<z.ZodNumber>;
146
- max: z.ZodOptional<z.ZodNumber>;
147
- }, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
148
- min: z.ZodOptional<z.ZodNumber>;
149
- max: z.ZodOptional<z.ZodNumber>;
150
- }, z.core.$strict>]>, z.ZodArray<z.ZodString>]>;
147
+ declare const ConditionValueSchema: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
151
148
  declare const StatementSchema: z.ZodObject<{
152
149
  effect: z.ZodEnum<{
153
150
  allow: "allow";
@@ -158,7 +155,7 @@ declare const StatementSchema: z.ZodObject<{
158
155
  conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
159
156
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
160
157
  operator: z.ZodLiteral<"equals">;
161
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
158
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
162
159
  }, z.core.$strict>, z.ZodObject<{
163
160
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
164
161
  operator: z.ZodLiteral<"in">;
@@ -218,7 +215,7 @@ declare const PolicySchema: z.ZodObject<{
218
215
  conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
219
216
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
220
217
  operator: z.ZodLiteral<"equals">;
221
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
218
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
222
219
  }, z.core.$strict>, z.ZodObject<{
223
220
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
224
221
  operator: z.ZodLiteral<"in">;
@@ -268,4 +265,4 @@ declare const PolicySchema: z.ZodObject<{
268
265
  }, z.core.$strict>>;
269
266
  }, z.core.$strict>;
270
267
 
271
- 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, type UrlOperator, UrlOperatorSchema };
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,6 +1,9 @@
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";
5
8
  type UrlOperator = "matches_url";
6
9
  type OtherOperator = "exists" | "keys_in" | "size";
@@ -10,7 +13,7 @@ type RangeValue = {
10
13
  max?: number;
11
14
  };
12
15
  type SizeValue = number | RangeValue;
13
- type ConditionValue = string | number | boolean | (string | number | boolean)[] | RangeValue | SizeValue;
16
+ type ConditionValue = JsonValue | RangeValue | SizeValue;
14
17
  interface Condition {
15
18
  path: (string | number)[];
16
19
  operator: Operator;
@@ -62,7 +65,7 @@ declare const SizeValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
62
65
  declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
63
66
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
64
67
  operator: z.ZodLiteral<"equals">;
65
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
68
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
66
69
  }, z.core.$strict>, z.ZodObject<{
67
70
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
68
71
  operator: z.ZodLiteral<"in">;
@@ -141,13 +144,7 @@ declare const OperatorSchema: z.ZodEnum<{
141
144
  values_in: "values_in";
142
145
  matches_url: "matches_url";
143
146
  }>;
144
- declare const ConditionValueSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodObject<{
145
- min: z.ZodOptional<z.ZodNumber>;
146
- max: z.ZodOptional<z.ZodNumber>;
147
- }, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
148
- min: z.ZodOptional<z.ZodNumber>;
149
- max: z.ZodOptional<z.ZodNumber>;
150
- }, z.core.$strict>]>, z.ZodArray<z.ZodString>]>;
147
+ declare const ConditionValueSchema: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
151
148
  declare const StatementSchema: z.ZodObject<{
152
149
  effect: z.ZodEnum<{
153
150
  allow: "allow";
@@ -158,7 +155,7 @@ declare const StatementSchema: z.ZodObject<{
158
155
  conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
159
156
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
160
157
  operator: z.ZodLiteral<"equals">;
161
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
158
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
162
159
  }, z.core.$strict>, z.ZodObject<{
163
160
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
164
161
  operator: z.ZodLiteral<"in">;
@@ -218,7 +215,7 @@ declare const PolicySchema: z.ZodObject<{
218
215
  conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
219
216
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
220
217
  operator: z.ZodLiteral<"equals">;
221
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
218
+ value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
222
219
  }, z.core.$strict>, z.ZodObject<{
223
220
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
224
221
  operator: z.ZodLiteral<"in">;
@@ -268,4 +265,4 @@ declare const PolicySchema: z.ZodObject<{
268
265
  }, z.core.$strict>>;
269
266
  }, z.core.$strict>;
270
267
 
271
- 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, type UrlOperator, UrlOperatorSchema };
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: ScalarSchema
19
+ value: JsonValueSchema
10
20
  }).strict();
11
21
  var InConditionSchema = z.object({
12
22
  path: PathSchema,
@@ -112,13 +122,7 @@ var OperatorSchema = z.enum([
112
122
  "keys_in",
113
123
  "size"
114
124
  ]);
115
- var ConditionValueSchema = z.union([
116
- ScalarSchema,
117
- z.array(ScalarSchema),
118
- RangeValueSchema,
119
- SizeValueSchema,
120
- z.array(z.string())
121
- ]);
125
+ var ConditionValueSchema = JsonValueSchema;
122
126
  var StatementSchema = z.object({
123
127
  effect: z.enum(["allow", "deny"]),
124
128
  permissions: z.array(z.string()).min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/policy-schema",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Zod schemas and TypeScript types for the Zapier policy engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",