@zapier/policy-schema 0.12.0 → 0.15.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.d.cts CHANGED
@@ -1,137 +1,28 @@
1
1
  import { z } from 'zod';
2
2
 
3
- type ScalarOperator = "equals" | "in" | "matches" | "matches_host" | "matches_path" | "range";
4
- type JsonValue = string | number | boolean | null | JsonValue[] | {
5
- [key: string]: JsonValue;
6
- };
7
- type ArrayOperator = "values_in";
8
- type UrlOperator = "matches_url";
9
- type OtherOperator = "exists" | "keys_in" | "size";
10
- type Operator = ScalarOperator | ArrayOperator | UrlOperator | OtherOperator;
11
- type RangeValue = {
12
- min?: number;
13
- max?: number;
14
- };
15
- type SizeValue = number | RangeValue;
16
- type ConditionValue = JsonValue | RangeValue | SizeValue;
17
- interface Condition {
18
- path: (string | number)[];
19
- operator: Operator;
20
- value?: ConditionValue;
21
- }
22
- type Effect = "allow" | "ask" | "deny";
23
- interface Statement {
24
- id?: string;
25
- effect: Effect;
26
- permissions: string[];
27
- resources: string[];
28
- conditions?: Condition[];
29
- }
30
- interface Policy {
31
- version: 1 | 2;
32
- statements: Statement[];
33
- }
34
- interface PolicyRequest {
35
- permission: string;
36
- resource: string;
37
- context?: Record<string, unknown>;
38
- }
39
- /** SHA-256 hex digest of an RFC 8785 (JCS) canonicalized JSON value. */
40
- type CanonicalHash = string & {
41
- readonly __brand: "CanonicalHash";
42
- };
43
- interface OverrideBase {
44
- id?: string;
45
- statementHash: CanonicalHash;
46
- effect: "allow";
47
- }
48
- type Override = (OverrideBase & {
49
- match: "any";
50
- }) | (OverrideBase & {
51
- contextHash: CanonicalHash;
52
- }) | (OverrideBase & {
53
- conditionals: Condition[];
54
- });
55
- interface ConditionTrace {
56
- condition: Condition;
57
- resolved: unknown;
58
- passed: boolean;
59
- }
60
- interface OverrideTrace {
61
- override: Override;
62
- matched: boolean;
63
- conditionResults?: ConditionTrace[];
64
- }
65
- interface StatementTrace {
66
- statement: Statement;
67
- permissionMatched: boolean;
68
- resourceMatched: boolean;
69
- conditionResults?: ConditionTrace[];
70
- passed: boolean;
71
- overrides?: OverrideTrace[];
72
- }
73
- interface EvaluatePolicyOptions {
74
- policy: Policy;
75
- request: PolicyRequest;
76
- overrides?: Override[];
77
- trace?: boolean;
78
- }
79
- type PolicyReason = "matched" | "unmatched" | "hpp" | "overridden";
80
- interface PolicyResult {
81
- effect: Effect;
82
- explicit: boolean;
83
- reason: PolicyReason;
84
- statements: StatementTrace[];
85
- }
86
- interface ParsedUrl {
87
- scheme: string;
88
- host: string;
89
- port: number;
90
- path: string;
91
- query: Record<string, string[]>;
92
- }
93
- interface PolicyHttpRequest {
94
- method: string;
95
- url: ParsedUrl;
96
- headers: Record<string, string | string[]>;
97
- body: string | null;
98
- body_json: unknown;
99
- connection_id?: string;
100
- }
101
- interface PolicyActionRequest {
102
- connection_id?: string;
103
- selected_api?: string;
104
- action_type?: string;
105
- action_key?: string;
106
- inputs?: Record<string, unknown>;
107
- }
108
- /** Simplified OpenAPI-compatible JSON Schema type for getOpenApiSchema(). */
109
- interface OpenApiSchema {
110
- type?: string;
111
- required?: string[];
112
- properties?: Record<string, OpenApiSchema>;
113
- items?: OpenApiSchema;
114
- enum?: (string | number)[];
115
- description?: string;
116
- minItems?: number;
117
- oneOf?: OpenApiSchema[];
118
- anyOf?: OpenApiSchema[];
119
- }
120
-
121
- /** Current policy document version. */
122
- declare const VALID_VERSIONS: readonly [1, 2];
3
+ /** Release-candidate policy document version for the current experimental shape. */
4
+ declare const RUBBERDUCK_POLICY_VERSION: "rc-rubberduck";
5
+ /** Supported policy document versions. */
6
+ declare const VALID_VERSIONS: readonly [1, 2, "rc-rubberduck"];
123
7
  /** Valid policy effects. */
124
8
  declare const VALID_EFFECTS: readonly ["allow", "ask", "deny"];
9
+ /** Derived from VALID_EFFECTS — the constant is the single source of truth. */
10
+ type Effect = (typeof VALID_EFFECTS)[number];
125
11
  /** Valid condition operators. */
126
12
  declare const VALID_OPERATOR_LIST: readonly ["equals", "exists", "in", "keys_in", "matches", "matches_host", "matches_path", "matches_url", "range", "size", "values_in"];
13
+ declare const ConditionValueSchema: z.ZodJSONSchema;
127
14
  declare const RangeValueSchema: z.ZodObject<{
128
15
  min: z.ZodOptional<z.ZodNumber>;
129
16
  max: z.ZodOptional<z.ZodNumber>;
130
17
  }, z.core.$strict>;
18
+ /** Derived from RangeValueSchema — the schema is the single source of truth. */
19
+ type RangeValue = z.infer<typeof RangeValueSchema>;
131
20
  declare const SizeValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
132
21
  min: z.ZodOptional<z.ZodNumber>;
133
22
  max: z.ZodOptional<z.ZodNumber>;
134
23
  }, z.core.$strict>]>;
24
+ /** Derived from SizeValueSchema — the schema is the single source of truth. */
25
+ type SizeValue = z.infer<typeof SizeValueSchema>;
135
26
  declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
136
27
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
137
28
  operator: z.ZodLiteral<"equals">;
@@ -182,6 +73,8 @@ declare const ConditionSchema: z.ZodUnion<readonly [z.ZodObject<{
182
73
  max: z.ZodOptional<z.ZodNumber>;
183
74
  }, z.core.$strict>]>;
184
75
  }, z.core.$strict>]>;
76
+ /** Derived from ConditionSchema — the schema is the single source of truth. */
77
+ type Condition = z.infer<typeof ConditionSchema>;
185
78
  declare const ScalarOperatorSchema: z.ZodEnum<{
186
79
  equals: "equals";
187
80
  in: "in";
@@ -190,31 +83,40 @@ declare const ScalarOperatorSchema: z.ZodEnum<{
190
83
  matches_path: "matches_path";
191
84
  range: "range";
192
85
  }>;
86
+ /** Derived from ScalarOperatorSchema — the schema is the single source of truth. */
87
+ type ScalarOperator = z.infer<typeof ScalarOperatorSchema>;
193
88
  declare const ArrayOperatorSchema: z.ZodEnum<{
194
89
  values_in: "values_in";
195
90
  }>;
91
+ /** Derived from ArrayOperatorSchema — the schema is the single source of truth. */
92
+ type ArrayOperator = z.infer<typeof ArrayOperatorSchema>;
196
93
  declare const UrlOperatorSchema: z.ZodEnum<{
197
94
  matches_url: "matches_url";
198
95
  }>;
96
+ /** Derived from UrlOperatorSchema — the schema is the single source of truth. */
97
+ type UrlOperator = z.infer<typeof UrlOperatorSchema>;
199
98
  declare const OtherOperatorSchema: z.ZodEnum<{
200
99
  exists: "exists";
201
100
  keys_in: "keys_in";
202
101
  size: "size";
203
102
  }>;
103
+ /** Derived from OtherOperatorSchema — the schema is the single source of truth. */
104
+ type OtherOperator = z.infer<typeof OtherOperatorSchema>;
204
105
  declare const OperatorSchema: z.ZodEnum<{
205
106
  equals: "equals";
107
+ exists: "exists";
206
108
  in: "in";
109
+ keys_in: "keys_in";
207
110
  matches: "matches";
208
111
  matches_host: "matches_host";
209
112
  matches_path: "matches_path";
113
+ matches_url: "matches_url";
210
114
  range: "range";
211
- exists: "exists";
212
- keys_in: "keys_in";
213
115
  size: "size";
214
116
  values_in: "values_in";
215
- matches_url: "matches_url";
216
117
  }>;
217
- declare const ConditionValueSchema: z.ZodJSONSchema;
118
+ /** Derived from OperatorSchema — the schema is the single source of truth. */
119
+ type Operator = z.infer<typeof OperatorSchema>;
218
120
  /** Statement schema accepting the union of all effects (use PolicySchema for version-aware validation). */
219
121
  declare const StatementSchema: z.ZodObject<{
220
122
  id: z.ZodOptional<z.ZodString>;
@@ -276,6 +178,23 @@ declare const StatementSchema: z.ZodObject<{
276
178
  }, z.core.$strict>]>;
277
179
  }, z.core.$strict>]>>>;
278
180
  }, z.core.$strict>;
181
+ /** Derived from StatementSchema — the schema is the single source of truth. */
182
+ type Statement = z.infer<typeof StatementSchema>;
183
+ /** Statement identifier for rc-rubberduck policies. Must match ^s_\S+$ and be ≤512 chars. */
184
+ declare const StatementIdSchema: z.ZodString;
185
+ /** Derived from StatementIdSchema — the schema is the single source of truth. */
186
+ type StatementId = z.infer<typeof StatementIdSchema>;
187
+ /** Policy identifier for rc-rubberduck policies. Must match ^p_\S+$ and be ≤512 chars. */
188
+ declare const PolicyIdSchema: z.ZodString;
189
+ /** Derived from PolicyIdSchema — the schema is the single source of truth. */
190
+ type PolicyId = z.infer<typeof PolicyIdSchema>;
191
+ /** Effect applied when no statement matches (rc-rubberduck, required). deny == implicit deny. */
192
+ declare const DefaultEffectSchema: z.ZodEnum<{
193
+ ask: "ask";
194
+ deny: "deny";
195
+ }>;
196
+ /** Derived from DefaultEffectSchema — the schema is the single source of truth. */
197
+ type DefaultEffect = z.infer<typeof DefaultEffectSchema>;
279
198
  declare const PolicySchema: z.ZodUnion<readonly [z.ZodObject<{
280
199
  version: z.ZodLiteral<1>;
281
200
  statements: z.ZodArray<z.ZodObject<{
@@ -399,7 +318,289 @@ declare const PolicySchema: z.ZodUnion<readonly [z.ZodObject<{
399
318
  }, z.core.$strict>]>;
400
319
  }, z.core.$strict>]>>>;
401
320
  }, z.core.$strict>>;
321
+ }, z.core.$strict>, z.ZodObject<{
322
+ version: z.ZodLiteral<"rc-rubberduck">;
323
+ id: z.ZodString;
324
+ defaultEffect: z.ZodEnum<{
325
+ ask: "ask";
326
+ deny: "deny";
327
+ }>;
328
+ statements: z.ZodArray<z.ZodObject<{
329
+ id: z.ZodString;
330
+ effect: z.ZodEnum<{
331
+ allow: "allow";
332
+ ask: "ask";
333
+ deny: "deny";
334
+ }>;
335
+ permissions: z.ZodArray<z.ZodString>;
336
+ resources: z.ZodArray<z.ZodString>;
337
+ conditions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
338
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
339
+ operator: z.ZodLiteral<"equals">;
340
+ value: z.ZodJSONSchema;
341
+ }, z.core.$strict>, z.ZodObject<{
342
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
343
+ operator: z.ZodLiteral<"in">;
344
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
345
+ }, z.core.$strict>, z.ZodObject<{
346
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
347
+ operator: z.ZodLiteral<"matches">;
348
+ value: z.ZodString;
349
+ }, z.core.$strict>, z.ZodObject<{
350
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
351
+ operator: z.ZodLiteral<"matches_host">;
352
+ value: z.ZodString;
353
+ }, z.core.$strict>, z.ZodObject<{
354
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
355
+ operator: z.ZodLiteral<"matches_path">;
356
+ value: z.ZodString;
357
+ }, z.core.$strict>, z.ZodObject<{
358
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
359
+ operator: z.ZodLiteral<"range">;
360
+ value: z.ZodObject<{
361
+ min: z.ZodOptional<z.ZodNumber>;
362
+ max: z.ZodOptional<z.ZodNumber>;
363
+ }, z.core.$strict>;
364
+ }, z.core.$strict>, z.ZodObject<{
365
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
366
+ operator: z.ZodLiteral<"matches_url">;
367
+ value: z.ZodString;
368
+ }, z.core.$strict>, z.ZodObject<{
369
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
370
+ operator: z.ZodLiteral<"values_in">;
371
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
372
+ }, z.core.$strict>, z.ZodObject<{
373
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
374
+ operator: z.ZodLiteral<"exists">;
375
+ }, z.core.$strict>, z.ZodObject<{
376
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
377
+ operator: z.ZodLiteral<"keys_in">;
378
+ value: z.ZodArray<z.ZodString>;
379
+ }, z.core.$strict>, z.ZodObject<{
380
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
381
+ operator: z.ZodLiteral<"size">;
382
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
383
+ min: z.ZodOptional<z.ZodNumber>;
384
+ max: z.ZodOptional<z.ZodNumber>;
385
+ }, z.core.$strict>]>;
386
+ }, z.core.$strict>]>>>;
387
+ }, z.core.$strict>>;
388
+ }, z.core.$strict>]>;
389
+ /** Derived from PolicySchema — the schema is the single source of truth. */
390
+ type Policy = z.infer<typeof PolicySchema>;
391
+ /** SHA-256 hex digest of an RFC 8785 (JCS) canonicalized JSON value. */
392
+ declare const CanonicalHashSchema: z.ZodCustom<CanonicalHash, CanonicalHash>;
393
+ /**
394
+ * Runtime schema for the Override type. Each variant has exactly one target
395
+ * field (statementHash for v1/v2, statementId or policyId for rc-rubberduck) and exactly
396
+ * one binding mode (match, contextHash, or conditionals). `.strict()` keeps
397
+ * the variants mutually exclusive (an object carrying fields from two variants
398
+ * fails all branches).
399
+ *
400
+ * Targets are all non-null:
401
+ * - statementHash: targets a v1/v2 statement by canonical hash
402
+ * - statementId: targets an rc-rubberduck statement by id
403
+ * - policyId: targets that policy's default effect (rc-rubberduck only)
404
+ *
405
+ * Empty conditionals is intentional (the "blank check"): the override applies
406
+ * whenever the targeted ask statement fires, with no extra conditions. Do not
407
+ * add .min(1) to conditionals.
408
+ */
409
+ declare const OverrideSchema: z.ZodUnion<readonly [z.ZodObject<{
410
+ match: z.ZodLiteral<"any">;
411
+ id: z.ZodOptional<z.ZodString>;
412
+ statementHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
413
+ effect: z.ZodLiteral<"allow">;
414
+ }, z.core.$strict>, z.ZodObject<{
415
+ contextHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
416
+ id: z.ZodOptional<z.ZodString>;
417
+ statementHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
418
+ effect: z.ZodLiteral<"allow">;
419
+ }, z.core.$strict>, z.ZodObject<{
420
+ conditionals: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
421
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
422
+ operator: z.ZodLiteral<"equals">;
423
+ value: z.ZodJSONSchema;
424
+ }, z.core.$strict>, z.ZodObject<{
425
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
426
+ operator: z.ZodLiteral<"in">;
427
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
428
+ }, z.core.$strict>, z.ZodObject<{
429
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
430
+ operator: z.ZodLiteral<"matches">;
431
+ value: z.ZodString;
432
+ }, z.core.$strict>, z.ZodObject<{
433
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
434
+ operator: z.ZodLiteral<"matches_host">;
435
+ value: z.ZodString;
436
+ }, z.core.$strict>, z.ZodObject<{
437
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
438
+ operator: z.ZodLiteral<"matches_path">;
439
+ value: z.ZodString;
440
+ }, z.core.$strict>, z.ZodObject<{
441
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
442
+ operator: z.ZodLiteral<"range">;
443
+ value: z.ZodObject<{
444
+ min: z.ZodOptional<z.ZodNumber>;
445
+ max: z.ZodOptional<z.ZodNumber>;
446
+ }, z.core.$strict>;
447
+ }, z.core.$strict>, z.ZodObject<{
448
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
449
+ operator: z.ZodLiteral<"matches_url">;
450
+ value: z.ZodString;
451
+ }, z.core.$strict>, z.ZodObject<{
452
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
453
+ operator: z.ZodLiteral<"values_in">;
454
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
455
+ }, z.core.$strict>, z.ZodObject<{
456
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
457
+ operator: z.ZodLiteral<"exists">;
458
+ }, z.core.$strict>, z.ZodObject<{
459
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
460
+ operator: z.ZodLiteral<"keys_in">;
461
+ value: z.ZodArray<z.ZodString>;
462
+ }, z.core.$strict>, z.ZodObject<{
463
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
464
+ operator: z.ZodLiteral<"size">;
465
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
466
+ min: z.ZodOptional<z.ZodNumber>;
467
+ max: z.ZodOptional<z.ZodNumber>;
468
+ }, z.core.$strict>]>;
469
+ }, z.core.$strict>]>>;
470
+ id: z.ZodOptional<z.ZodString>;
471
+ statementHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
472
+ effect: z.ZodLiteral<"allow">;
473
+ }, z.core.$strict>, z.ZodObject<{
474
+ match: z.ZodLiteral<"any">;
475
+ id: z.ZodOptional<z.ZodString>;
476
+ statementId: z.ZodString;
477
+ effect: z.ZodLiteral<"allow">;
478
+ }, z.core.$strict>, z.ZodObject<{
479
+ contextHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
480
+ id: z.ZodOptional<z.ZodString>;
481
+ statementId: z.ZodString;
482
+ effect: z.ZodLiteral<"allow">;
483
+ }, z.core.$strict>, z.ZodObject<{
484
+ conditionals: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
485
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
486
+ operator: z.ZodLiteral<"equals">;
487
+ value: z.ZodJSONSchema;
488
+ }, z.core.$strict>, z.ZodObject<{
489
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
490
+ operator: z.ZodLiteral<"in">;
491
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
492
+ }, z.core.$strict>, z.ZodObject<{
493
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
494
+ operator: z.ZodLiteral<"matches">;
495
+ value: z.ZodString;
496
+ }, z.core.$strict>, z.ZodObject<{
497
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
498
+ operator: z.ZodLiteral<"matches_host">;
499
+ value: z.ZodString;
500
+ }, z.core.$strict>, z.ZodObject<{
501
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
502
+ operator: z.ZodLiteral<"matches_path">;
503
+ value: z.ZodString;
504
+ }, z.core.$strict>, z.ZodObject<{
505
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
506
+ operator: z.ZodLiteral<"range">;
507
+ value: z.ZodObject<{
508
+ min: z.ZodOptional<z.ZodNumber>;
509
+ max: z.ZodOptional<z.ZodNumber>;
510
+ }, z.core.$strict>;
511
+ }, z.core.$strict>, z.ZodObject<{
512
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
513
+ operator: z.ZodLiteral<"matches_url">;
514
+ value: z.ZodString;
515
+ }, z.core.$strict>, z.ZodObject<{
516
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
517
+ operator: z.ZodLiteral<"values_in">;
518
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
519
+ }, z.core.$strict>, z.ZodObject<{
520
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
521
+ operator: z.ZodLiteral<"exists">;
522
+ }, z.core.$strict>, z.ZodObject<{
523
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
524
+ operator: z.ZodLiteral<"keys_in">;
525
+ value: z.ZodArray<z.ZodString>;
526
+ }, z.core.$strict>, z.ZodObject<{
527
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
528
+ operator: z.ZodLiteral<"size">;
529
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
530
+ min: z.ZodOptional<z.ZodNumber>;
531
+ max: z.ZodOptional<z.ZodNumber>;
532
+ }, z.core.$strict>]>;
533
+ }, z.core.$strict>]>>;
534
+ id: z.ZodOptional<z.ZodString>;
535
+ statementId: z.ZodString;
536
+ effect: z.ZodLiteral<"allow">;
537
+ }, z.core.$strict>, z.ZodObject<{
538
+ match: z.ZodLiteral<"any">;
539
+ id: z.ZodOptional<z.ZodString>;
540
+ policyId: z.ZodString;
541
+ effect: z.ZodLiteral<"allow">;
542
+ }, z.core.$strict>, z.ZodObject<{
543
+ contextHash: z.ZodCustom<CanonicalHash, CanonicalHash>;
544
+ id: z.ZodOptional<z.ZodString>;
545
+ policyId: z.ZodString;
546
+ effect: z.ZodLiteral<"allow">;
547
+ }, z.core.$strict>, z.ZodObject<{
548
+ conditionals: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
549
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
550
+ operator: z.ZodLiteral<"equals">;
551
+ value: z.ZodJSONSchema;
552
+ }, z.core.$strict>, z.ZodObject<{
553
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
554
+ operator: z.ZodLiteral<"in">;
555
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
556
+ }, z.core.$strict>, z.ZodObject<{
557
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
558
+ operator: z.ZodLiteral<"matches">;
559
+ value: z.ZodString;
560
+ }, z.core.$strict>, z.ZodObject<{
561
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
562
+ operator: z.ZodLiteral<"matches_host">;
563
+ value: z.ZodString;
564
+ }, z.core.$strict>, z.ZodObject<{
565
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
566
+ operator: z.ZodLiteral<"matches_path">;
567
+ value: z.ZodString;
568
+ }, z.core.$strict>, z.ZodObject<{
569
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
570
+ operator: z.ZodLiteral<"range">;
571
+ value: z.ZodObject<{
572
+ min: z.ZodOptional<z.ZodNumber>;
573
+ max: z.ZodOptional<z.ZodNumber>;
574
+ }, z.core.$strict>;
575
+ }, z.core.$strict>, z.ZodObject<{
576
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
577
+ operator: z.ZodLiteral<"matches_url">;
578
+ value: z.ZodString;
579
+ }, z.core.$strict>, z.ZodObject<{
580
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
581
+ operator: z.ZodLiteral<"values_in">;
582
+ value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
583
+ }, z.core.$strict>, z.ZodObject<{
584
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
585
+ operator: z.ZodLiteral<"exists">;
586
+ }, z.core.$strict>, z.ZodObject<{
587
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
588
+ operator: z.ZodLiteral<"keys_in">;
589
+ value: z.ZodArray<z.ZodString>;
590
+ }, z.core.$strict>, z.ZodObject<{
591
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
592
+ operator: z.ZodLiteral<"size">;
593
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
594
+ min: z.ZodOptional<z.ZodNumber>;
595
+ max: z.ZodOptional<z.ZodNumber>;
596
+ }, z.core.$strict>]>;
597
+ }, z.core.$strict>]>>;
598
+ id: z.ZodOptional<z.ZodString>;
599
+ policyId: z.ZodString;
600
+ effect: z.ZodLiteral<"allow">;
402
601
  }, z.core.$strict>]>;
602
+ /** Derived from OverrideSchema — the schema is the single source of truth. */
603
+ type Override = z.infer<typeof OverrideSchema>;
403
604
  /**
404
605
  * Returns an OpenAPI-compatible JSON Schema object for a policy document.
405
606
  *
@@ -408,4 +609,89 @@ declare const PolicySchema: z.ZodUnion<readonly [z.ZodObject<{
408
609
  */
409
610
  declare function getOpenApiSchema(): OpenApiSchema;
410
611
 
411
- export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type Effect, type EvaluatePolicyOptions, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyHttpRequest, type PolicyReason, type PolicyRequest, type PolicyResult, PolicySchema, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, StatementSchema, type StatementTrace, type UrlOperator, UrlOperatorSchema, VALID_EFFECTS, VALID_OPERATOR_LIST, VALID_VERSIONS, getOpenApiSchema };
612
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
613
+ [key: string]: JsonValue;
614
+ };
615
+ type ConditionValue = JsonValue | RangeValue | SizeValue;
616
+ interface PolicyRequest {
617
+ permission: string;
618
+ resource: string;
619
+ context?: Record<string, unknown>;
620
+ }
621
+ /** SHA-256 hex digest of an RFC 8785 (JCS) canonicalized JSON value. */
622
+ type CanonicalHash = string & {
623
+ readonly __brand: "CanonicalHash";
624
+ };
625
+ interface ConditionTrace {
626
+ condition: Condition;
627
+ resolved: unknown;
628
+ passed: boolean;
629
+ }
630
+ interface OverrideTrace {
631
+ override: Override;
632
+ matched: boolean;
633
+ conditionResults?: ConditionTrace[];
634
+ }
635
+ interface DefaultTrace {
636
+ defaultEffect: DefaultEffect;
637
+ overrides: OverrideTrace[];
638
+ }
639
+ interface StatementTrace {
640
+ statement: Statement;
641
+ permissionMatched: boolean;
642
+ resourceMatched: boolean;
643
+ conditionResults?: ConditionTrace[];
644
+ passed: boolean;
645
+ overrides?: OverrideTrace[];
646
+ }
647
+ interface EvaluatePolicyOptions {
648
+ policy: Policy;
649
+ request: PolicyRequest;
650
+ overrides?: Override[];
651
+ trace?: boolean;
652
+ }
653
+ type PolicyReason = "matched" | "unmatched" | "hpp" | "overridden";
654
+ interface PolicyResult {
655
+ effect: Effect;
656
+ explicit: boolean;
657
+ reason: PolicyReason;
658
+ statements: StatementTrace[];
659
+ /** Trace mode only. Present when no statement matched and an ask default was consulted (never attached for deny defaults). */
660
+ default?: DefaultTrace;
661
+ }
662
+ interface ParsedUrl {
663
+ scheme: string;
664
+ host: string;
665
+ port: number;
666
+ path: string;
667
+ query: Record<string, string[]>;
668
+ }
669
+ interface PolicyHttpRequest {
670
+ method: string;
671
+ url: ParsedUrl;
672
+ headers: Record<string, string | string[]>;
673
+ body: string | null;
674
+ body_json: unknown;
675
+ connection_id?: string;
676
+ }
677
+ interface PolicyActionRequest {
678
+ connection_id?: string;
679
+ selected_api?: string;
680
+ action_type?: string;
681
+ action_key?: string;
682
+ inputs?: Record<string, unknown>;
683
+ }
684
+ /** Simplified OpenAPI-compatible JSON Schema type for getOpenApiSchema(). */
685
+ interface OpenApiSchema {
686
+ type?: string;
687
+ required?: string[];
688
+ properties?: Record<string, OpenApiSchema>;
689
+ items?: OpenApiSchema;
690
+ enum?: (string | number)[];
691
+ description?: string;
692
+ minItems?: number;
693
+ oneOf?: OpenApiSchema[];
694
+ anyOf?: OpenApiSchema[];
695
+ }
696
+
697
+ export { type ArrayOperator, ArrayOperatorSchema, type CanonicalHash, CanonicalHashSchema, type Condition, ConditionSchema, type ConditionTrace, type ConditionValue, ConditionValueSchema, type DefaultEffect, DefaultEffectSchema, type DefaultTrace, type Effect, type EvaluatePolicyOptions, type JsonValue, type OpenApiSchema, type Operator, OperatorSchema, type OtherOperator, OtherOperatorSchema, type Override, OverrideSchema, type OverrideTrace, type ParsedUrl, type Policy, type PolicyActionRequest, type PolicyHttpRequest, type PolicyId, PolicyIdSchema, type PolicyReason, type PolicyRequest, type PolicyResult, PolicySchema, RUBBERDUCK_POLICY_VERSION, type RangeValue, RangeValueSchema, type ScalarOperator, ScalarOperatorSchema, type SizeValue, SizeValueSchema, type Statement, type StatementId, StatementIdSchema, StatementSchema, type StatementTrace, type UrlOperator, UrlOperatorSchema, VALID_EFFECTS, VALID_OPERATOR_LIST, VALID_VERSIONS, getOpenApiSchema };