durability 5.2.0 → 5.3.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.
@@ -1,239 +1,451 @@
1
- import { z } from 'zod';
1
+ import * as v from 'valibot';
2
2
  /** Bounds one message's work so a client cannot monopolize the holder. */
3
3
  export declare const maxDemandEntries = 100;
4
4
  export declare const maxGrantReports = 200;
5
5
  /** Cumulative counts for one grant. Replaying a report can never free capacity twice. */
6
- export declare const grantReportSchema: z.ZodObject<{
7
- grantId: z.ZodString;
8
- claimed: z.ZodNumber;
9
- released: z.ZodNumber;
10
- }, z.core.$strip>;
11
- export type GrantReport = z.infer<typeof grantReportSchema>;
6
+ export declare const grantReportSchema: v.ObjectSchema<{
7
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
8
+ /** Permits of this grant the client has used, as a high-water mark. */
9
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
10
+ /** Claimed permits the client has returned, as a high-water mark. */
11
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
12
+ }, undefined>;
13
+ export type GrantReport = v.InferOutput<typeof grantReportSchema>;
12
14
  /** Cumulative counts for one lease the client holds. */
13
- export declare const leaseReportSchema: z.ZodObject<{
14
- leaseId: z.ZodString;
15
- drawn: z.ZodNumber;
16
- released: z.ZodNumber;
17
- retired: z.ZodOptional<z.ZodBoolean>;
18
- }, z.core.$strip>;
19
- export type LeaseReport = z.infer<typeof leaseReportSchema>;
20
- export declare const leaseGrantSchema: z.ZodObject<{
21
- leaseId: z.ZodString;
22
- group: z.ZodString;
23
- permits: z.ZodNumber;
24
- expiresAt: z.ZodNumber;
25
- }, z.core.$strip>;
26
- export type LeaseGrant = z.infer<typeof leaseGrantSchema>;
27
- export declare const permitRequestSchema: z.ZodObject<{
28
- type: z.ZodLiteral<"request">;
29
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
30
- clientId: z.ZodString;
31
- clientChannel: z.ZodOptional<z.ZodString>;
32
- demand: z.ZodArray<z.ZodObject<{
33
- group: z.ZodString;
34
- count: z.ZodNumber;
35
- oldestAt: z.ZodNumber;
36
- }, z.core.$strip>>;
37
- grants: z.ZodArray<z.ZodObject<{
38
- grantId: z.ZodString;
39
- claimed: z.ZodNumber;
40
- released: z.ZodNumber;
41
- }, z.core.$strip>>;
42
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
43
- leaseId: z.ZodString;
44
- drawn: z.ZodNumber;
45
- released: z.ZodNumber;
46
- retired: z.ZodOptional<z.ZodBoolean>;
47
- }, z.core.$strip>>>;
48
- }, z.core.$strip>;
49
- export type PermitRequest = z.infer<typeof permitRequestSchema>;
50
- export declare const permitSyncSchema: z.ZodObject<{
51
- type: z.ZodLiteral<"sync">;
52
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
53
- clientId: z.ZodString;
54
- clientChannel: z.ZodOptional<z.ZodString>;
55
- grants: z.ZodArray<z.ZodObject<{
56
- grantId: z.ZodString;
57
- claimed: z.ZodNumber;
58
- released: z.ZodNumber;
59
- }, z.core.$strip>>;
60
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
61
- leaseId: z.ZodString;
62
- drawn: z.ZodNumber;
63
- released: z.ZodNumber;
64
- retired: z.ZodOptional<z.ZodBoolean>;
65
- }, z.core.$strip>>>;
66
- }, z.core.$strip>;
67
- export type PermitSync = z.infer<typeof permitSyncSchema>;
68
- export declare const semaphoreRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
69
- type: z.ZodLiteral<"request">;
70
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
71
- clientId: z.ZodString;
72
- clientChannel: z.ZodOptional<z.ZodString>;
73
- demand: z.ZodArray<z.ZodObject<{
74
- group: z.ZodString;
75
- count: z.ZodNumber;
76
- oldestAt: z.ZodNumber;
77
- }, z.core.$strip>>;
78
- grants: z.ZodArray<z.ZodObject<{
79
- grantId: z.ZodString;
80
- claimed: z.ZodNumber;
81
- released: z.ZodNumber;
82
- }, z.core.$strip>>;
83
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
- leaseId: z.ZodString;
85
- drawn: z.ZodNumber;
86
- released: z.ZodNumber;
87
- retired: z.ZodOptional<z.ZodBoolean>;
88
- }, z.core.$strip>>>;
89
- }, z.core.$strip>, z.ZodObject<{
90
- type: z.ZodLiteral<"sync">;
91
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
92
- clientId: z.ZodString;
93
- clientChannel: z.ZodOptional<z.ZodString>;
94
- grants: z.ZodArray<z.ZodObject<{
95
- grantId: z.ZodString;
96
- claimed: z.ZodNumber;
97
- released: z.ZodNumber;
98
- }, z.core.$strip>>;
99
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
- leaseId: z.ZodString;
101
- drawn: z.ZodNumber;
102
- released: z.ZodNumber;
103
- retired: z.ZodOptional<z.ZodBoolean>;
104
- }, z.core.$strip>>>;
105
- }, z.core.$strip>], "type">;
106
- export type SemaphoreRequest = z.infer<typeof semaphoreRequestSchema>;
107
- export declare const semaphoreBlockedReasonSchema: z.ZodEnum<{
108
- limit: "limit";
109
- group_limit: "group_limit";
110
- limit_resolution_error: "limit_resolution_error";
111
- not_permitted: "not_permitted";
112
- }>;
113
- export type SemaphoreBlockedReason = z.infer<typeof semaphoreBlockedReasonSchema>;
114
- export declare const grantResultSchema: z.ZodObject<{
115
- grantId: z.ZodString;
116
- claimed: z.ZodNumber;
117
- status: z.ZodEnum<{
118
- not_found: "not_found";
119
- ok: "ok";
120
- expired: "expired";
121
- }>;
122
- }, z.core.$strip>;
123
- export type GrantResult = z.infer<typeof grantResultSchema>;
124
- export declare const permitGrantSchema: z.ZodObject<{
125
- type: z.ZodLiteral<"grant">;
126
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
127
- grants: z.ZodArray<z.ZodObject<{
128
- grantId: z.ZodString;
129
- group: z.ZodString;
130
- permits: z.ZodNumber;
131
- }, z.core.$strip>>;
132
- blocked: z.ZodArray<z.ZodObject<{
133
- group: z.ZodString;
134
- reason: z.ZodEnum<{
135
- limit: "limit";
136
- group_limit: "group_limit";
137
- limit_resolution_error: "limit_resolution_error";
138
- not_permitted: "not_permitted";
139
- }>;
140
- }, z.core.$strip>>;
141
- nextRequestAt: z.ZodNumber;
142
- grantResults: z.ZodArray<z.ZodObject<{
143
- grantId: z.ZodString;
144
- claimed: z.ZodNumber;
145
- status: z.ZodEnum<{
146
- not_found: "not_found";
147
- ok: "ok";
148
- expired: "expired";
149
- }>;
150
- }, z.core.$strip>>;
151
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
152
- leaseId: z.ZodString;
153
- group: z.ZodString;
154
- permits: z.ZodNumber;
155
- expiresAt: z.ZodNumber;
156
- }, z.core.$strip>>>;
157
- contended: z.ZodOptional<z.ZodBoolean>;
158
- clientChannel: z.ZodOptional<z.ZodString>;
159
- }, z.core.$strip>;
160
- export type PermitGrant = z.infer<typeof permitGrantSchema>;
161
- export declare const permitSyncResultSchema: z.ZodObject<{
162
- type: z.ZodLiteral<"synced">;
163
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
164
- grantResults: z.ZodArray<z.ZodObject<{
165
- grantId: z.ZodString;
166
- claimed: z.ZodNumber;
167
- status: z.ZodEnum<{
168
- not_found: "not_found";
169
- ok: "ok";
170
- expired: "expired";
171
- }>;
172
- }, z.core.$strip>>;
173
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
174
- leaseId: z.ZodString;
175
- group: z.ZodString;
176
- permits: z.ZodNumber;
177
- expiresAt: z.ZodNumber;
178
- }, z.core.$strip>>>;
179
- contended: z.ZodOptional<z.ZodBoolean>;
180
- clientChannel: z.ZodOptional<z.ZodString>;
181
- }, z.core.$strip>;
182
- export type PermitSyncResult = z.infer<typeof permitSyncResultSchema>;
183
- export declare const semaphoreResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
- type: z.ZodLiteral<"grant">;
185
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
186
- grants: z.ZodArray<z.ZodObject<{
187
- grantId: z.ZodString;
188
- group: z.ZodString;
189
- permits: z.ZodNumber;
190
- }, z.core.$strip>>;
191
- blocked: z.ZodArray<z.ZodObject<{
192
- group: z.ZodString;
193
- reason: z.ZodEnum<{
194
- limit: "limit";
195
- group_limit: "group_limit";
196
- limit_resolution_error: "limit_resolution_error";
197
- not_permitted: "not_permitted";
198
- }>;
199
- }, z.core.$strip>>;
200
- nextRequestAt: z.ZodNumber;
201
- grantResults: z.ZodArray<z.ZodObject<{
202
- grantId: z.ZodString;
203
- claimed: z.ZodNumber;
204
- status: z.ZodEnum<{
205
- not_found: "not_found";
206
- ok: "ok";
207
- expired: "expired";
208
- }>;
209
- }, z.core.$strip>>;
210
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
211
- leaseId: z.ZodString;
212
- group: z.ZodString;
213
- permits: z.ZodNumber;
214
- expiresAt: z.ZodNumber;
215
- }, z.core.$strip>>>;
216
- contended: z.ZodOptional<z.ZodBoolean>;
217
- clientChannel: z.ZodOptional<z.ZodString>;
218
- }, z.core.$strip>, z.ZodObject<{
219
- type: z.ZodLiteral<"synced">;
220
- v: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
221
- grantResults: z.ZodArray<z.ZodObject<{
222
- grantId: z.ZodString;
223
- claimed: z.ZodNumber;
224
- status: z.ZodEnum<{
225
- not_found: "not_found";
226
- ok: "ok";
227
- expired: "expired";
228
- }>;
229
- }, z.core.$strip>>;
230
- leases: z.ZodOptional<z.ZodArray<z.ZodObject<{
231
- leaseId: z.ZodString;
232
- group: z.ZodString;
233
- permits: z.ZodNumber;
234
- expiresAt: z.ZodNumber;
235
- }, z.core.$strip>>>;
236
- contended: z.ZodOptional<z.ZodBoolean>;
237
- clientChannel: z.ZodOptional<z.ZodString>;
238
- }, z.core.$strip>], "type">;
239
- export type SemaphoreResponse = z.infer<typeof semaphoreResponseSchema>;
15
+ export declare const leaseReportSchema: v.ObjectSchema<{
16
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
17
+ /** Permits drawn locally so far, as a high-water mark. */
18
+ readonly drawn: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
19
+ /** Drawn permits returned, as a high-water mark. */
20
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
21
+ /** The client stopped drawing: the lease's undrawn permits are returned. */
22
+ readonly retired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
23
+ }, undefined>;
24
+ export type LeaseReport = v.InferOutput<typeof leaseReportSchema>;
25
+ export declare const leaseGrantSchema: v.ObjectSchema<{
26
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
27
+ readonly group: v.StringSchema<undefined>;
28
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
29
+ /** `expiresAt <= now` retires the lease: stop drawing immediately. */
30
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
31
+ }, undefined>;
32
+ export type LeaseGrant = v.InferOutput<typeof leaseGrantSchema>;
33
+ export declare const permitRequestSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
34
+ readonly type: v.LiteralSchema<"request", undefined>;
35
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
36
+ readonly clientId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
37
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
38
+ /** Sparse demand per group with the oldest queued time, for FIFO allocation. */
39
+ readonly demand: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
40
+ readonly group: v.StringSchema<undefined>;
41
+ readonly count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
42
+ readonly oldestAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
43
+ }, undefined>, undefined>, v.MaxLengthAction<{
44
+ group: string;
45
+ count: number;
46
+ oldestAt: number;
47
+ }[], 100, undefined>]>;
48
+ readonly grants: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
49
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
50
+ /** Permits of this grant the client has used, as a high-water mark. */
51
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
52
+ /** Claimed permits the client has returned, as a high-water mark. */
53
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
54
+ }, undefined>, undefined>, v.MaxLengthAction<{
55
+ grantId: string;
56
+ claimed: number;
57
+ released: number;
58
+ }[], 200, undefined>]>;
59
+ readonly leases: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
60
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
61
+ /** Permits drawn locally so far, as a high-water mark. */
62
+ readonly drawn: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
63
+ /** Drawn permits returned, as a high-water mark. */
64
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
65
+ /** The client stopped drawing: the lease's undrawn permits are returned. */
66
+ readonly retired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
67
+ }, undefined>, undefined>, v.MaxLengthAction<{
68
+ leaseId: string;
69
+ drawn: number;
70
+ released: number;
71
+ retired?: boolean | undefined;
72
+ }[], 200, undefined>]>, undefined>;
73
+ }, undefined>, v.CheckAction<{
74
+ type: "request";
75
+ v: 1 | 2;
76
+ clientId: string;
77
+ clientChannel?: string | undefined;
78
+ demand: {
79
+ group: string;
80
+ count: number;
81
+ oldestAt: number;
82
+ }[];
83
+ grants: {
84
+ grantId: string;
85
+ claimed: number;
86
+ released: number;
87
+ }[];
88
+ leases?: {
89
+ leaseId: string;
90
+ drawn: number;
91
+ released: number;
92
+ retired?: boolean | undefined;
93
+ }[] | undefined;
94
+ }, "Client channel does not match semaphore protocol version">]>;
95
+ export type PermitRequest = v.InferOutput<typeof permitRequestSchema>;
96
+ export declare const permitSyncSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
97
+ readonly type: v.LiteralSchema<"sync", undefined>;
98
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
99
+ readonly clientId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
100
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
101
+ readonly grants: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
102
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
103
+ /** Permits of this grant the client has used, as a high-water mark. */
104
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
105
+ /** Claimed permits the client has returned, as a high-water mark. */
106
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
107
+ }, undefined>, undefined>, v.MaxLengthAction<{
108
+ grantId: string;
109
+ claimed: number;
110
+ released: number;
111
+ }[], 200, undefined>]>;
112
+ readonly leases: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
113
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
114
+ /** Permits drawn locally so far, as a high-water mark. */
115
+ readonly drawn: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
116
+ /** Drawn permits returned, as a high-water mark. */
117
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
118
+ /** The client stopped drawing: the lease's undrawn permits are returned. */
119
+ readonly retired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
120
+ }, undefined>, undefined>, v.MaxLengthAction<{
121
+ leaseId: string;
122
+ drawn: number;
123
+ released: number;
124
+ retired?: boolean | undefined;
125
+ }[], 200, undefined>]>, undefined>;
126
+ }, undefined>, v.CheckAction<{
127
+ type: "sync";
128
+ v: 1 | 2;
129
+ clientId: string;
130
+ clientChannel?: string | undefined;
131
+ grants: {
132
+ grantId: string;
133
+ claimed: number;
134
+ released: number;
135
+ }[];
136
+ leases?: {
137
+ leaseId: string;
138
+ drawn: number;
139
+ released: number;
140
+ retired?: boolean | undefined;
141
+ }[] | undefined;
142
+ }, "Client channel does not match semaphore protocol version">]>;
143
+ export type PermitSync = v.InferOutput<typeof permitSyncSchema>;
144
+ export declare const semaphoreRequestSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
145
+ readonly type: v.LiteralSchema<"request", undefined>;
146
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
147
+ readonly clientId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
148
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
149
+ /** Sparse demand per group with the oldest queued time, for FIFO allocation. */
150
+ readonly demand: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
151
+ readonly group: v.StringSchema<undefined>;
152
+ readonly count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
153
+ readonly oldestAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
154
+ }, undefined>, undefined>, v.MaxLengthAction<{
155
+ group: string;
156
+ count: number;
157
+ oldestAt: number;
158
+ }[], 100, undefined>]>;
159
+ readonly grants: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
160
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
161
+ /** Permits of this grant the client has used, as a high-water mark. */
162
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
163
+ /** Claimed permits the client has returned, as a high-water mark. */
164
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
165
+ }, undefined>, undefined>, v.MaxLengthAction<{
166
+ grantId: string;
167
+ claimed: number;
168
+ released: number;
169
+ }[], 200, undefined>]>;
170
+ readonly leases: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
171
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
172
+ /** Permits drawn locally so far, as a high-water mark. */
173
+ readonly drawn: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
174
+ /** Drawn permits returned, as a high-water mark. */
175
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
176
+ /** The client stopped drawing: the lease's undrawn permits are returned. */
177
+ readonly retired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
178
+ }, undefined>, undefined>, v.MaxLengthAction<{
179
+ leaseId: string;
180
+ drawn: number;
181
+ released: number;
182
+ retired?: boolean | undefined;
183
+ }[], 200, undefined>]>, undefined>;
184
+ }, undefined>, v.CheckAction<{
185
+ type: "request";
186
+ v: 1 | 2;
187
+ clientId: string;
188
+ clientChannel?: string | undefined;
189
+ demand: {
190
+ group: string;
191
+ count: number;
192
+ oldestAt: number;
193
+ }[];
194
+ grants: {
195
+ grantId: string;
196
+ claimed: number;
197
+ released: number;
198
+ }[];
199
+ leases?: {
200
+ leaseId: string;
201
+ drawn: number;
202
+ released: number;
203
+ retired?: boolean | undefined;
204
+ }[] | undefined;
205
+ }, "Client channel does not match semaphore protocol version">]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
206
+ readonly type: v.LiteralSchema<"sync", undefined>;
207
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
208
+ readonly clientId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
209
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
210
+ readonly grants: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
211
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
212
+ /** Permits of this grant the client has used, as a high-water mark. */
213
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
214
+ /** Claimed permits the client has returned, as a high-water mark. */
215
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
216
+ }, undefined>, undefined>, v.MaxLengthAction<{
217
+ grantId: string;
218
+ claimed: number;
219
+ released: number;
220
+ }[], 200, undefined>]>;
221
+ readonly leases: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
222
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
223
+ /** Permits drawn locally so far, as a high-water mark. */
224
+ readonly drawn: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
225
+ /** Drawn permits returned, as a high-water mark. */
226
+ readonly released: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
227
+ /** The client stopped drawing: the lease's undrawn permits are returned. */
228
+ readonly retired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
229
+ }, undefined>, undefined>, v.MaxLengthAction<{
230
+ leaseId: string;
231
+ drawn: number;
232
+ released: number;
233
+ retired?: boolean | undefined;
234
+ }[], 200, undefined>]>, undefined>;
235
+ }, undefined>, v.CheckAction<{
236
+ type: "sync";
237
+ v: 1 | 2;
238
+ clientId: string;
239
+ clientChannel?: string | undefined;
240
+ grants: {
241
+ grantId: string;
242
+ claimed: number;
243
+ released: number;
244
+ }[];
245
+ leases?: {
246
+ leaseId: string;
247
+ drawn: number;
248
+ released: number;
249
+ retired?: boolean | undefined;
250
+ }[] | undefined;
251
+ }, "Client channel does not match semaphore protocol version">]>], undefined>;
252
+ export type SemaphoreRequest = v.InferOutput<typeof semaphoreRequestSchema>;
253
+ export declare const semaphoreBlockedReasonSchema: v.PicklistSchema<["group_limit", "limit", "limit_resolution_error", "not_permitted"], undefined>;
254
+ export type SemaphoreBlockedReason = v.InferOutput<typeof semaphoreBlockedReasonSchema>;
255
+ export declare const grantResultSchema: v.ObjectSchema<{
256
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
257
+ /** Server-clamped claim high-water mark; the client admits only up to this. */
258
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
259
+ readonly status: v.PicklistSchema<["ok", "not_found", "expired"], undefined>;
260
+ }, undefined>;
261
+ export type GrantResult = v.InferOutput<typeof grantResultSchema>;
262
+ export declare const permitGrantSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
263
+ readonly type: v.LiteralSchema<"grant", undefined>;
264
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
265
+ readonly grants: v.ArraySchema<v.ObjectSchema<{
266
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
267
+ readonly group: v.StringSchema<undefined>;
268
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
269
+ }, undefined>, undefined>;
270
+ readonly blocked: v.ArraySchema<v.ObjectSchema<{
271
+ readonly group: v.StringSchema<undefined>;
272
+ readonly reason: v.PicklistSchema<["group_limit", "limit", "limit_resolution_error", "not_permitted"], undefined>;
273
+ }, undefined>, undefined>;
274
+ /** The client must not send another request before this. */
275
+ readonly nextRequestAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
276
+ readonly grantResults: v.ArraySchema<v.ObjectSchema<{
277
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
278
+ /** Server-clamped claim high-water mark; the client admits only up to this. */
279
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
280
+ readonly status: v.PicklistSchema<["ok", "not_found", "expired"], undefined>;
281
+ }, undefined>, undefined>;
282
+ readonly leases: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
283
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
284
+ readonly group: v.StringSchema<undefined>;
285
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
286
+ /** `expiresAt <= now` retires the lease: stop drawing immediately. */
287
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
288
+ }, undefined>, undefined>, undefined>;
289
+ /** Demand went unserved: return undrawn lease permits in groups with nothing queued. */
290
+ readonly contended: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
291
+ /** Echoes the request's client channel in version 2. */
292
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
293
+ }, undefined>, v.CheckAction<{
294
+ type: "grant";
295
+ v: 1 | 2;
296
+ grants: {
297
+ grantId: string;
298
+ group: string;
299
+ permits: number;
300
+ }[];
301
+ blocked: {
302
+ group: string;
303
+ reason: "limit" | "group_limit" | "limit_resolution_error" | "not_permitted";
304
+ }[];
305
+ nextRequestAt: number;
306
+ grantResults: {
307
+ grantId: string;
308
+ claimed: number;
309
+ status: "not_found" | "ok" | "expired";
310
+ }[];
311
+ leases?: {
312
+ leaseId: string;
313
+ group: string;
314
+ permits: number;
315
+ expiresAt: number;
316
+ }[] | undefined;
317
+ contended?: boolean | undefined;
318
+ clientChannel?: string | undefined;
319
+ }, "Client channel does not match semaphore protocol version">]>;
320
+ export type PermitGrant = v.InferOutput<typeof permitGrantSchema>;
321
+ export declare const permitSyncResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
322
+ readonly type: v.LiteralSchema<"synced", undefined>;
323
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
324
+ readonly grantResults: v.ArraySchema<v.ObjectSchema<{
325
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
326
+ /** Server-clamped claim high-water mark; the client admits only up to this. */
327
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
328
+ readonly status: v.PicklistSchema<["ok", "not_found", "expired"], undefined>;
329
+ }, undefined>, undefined>;
330
+ readonly leases: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
331
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
332
+ readonly group: v.StringSchema<undefined>;
333
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
334
+ /** `expiresAt <= now` retires the lease: stop drawing immediately. */
335
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
336
+ }, undefined>, undefined>, undefined>;
337
+ readonly contended: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
338
+ /** Echoes the sync's `clientChannel`, as for a grant. */
339
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
340
+ }, undefined>, v.CheckAction<{
341
+ type: "synced";
342
+ v: 1 | 2;
343
+ grantResults: {
344
+ grantId: string;
345
+ claimed: number;
346
+ status: "not_found" | "ok" | "expired";
347
+ }[];
348
+ leases?: {
349
+ leaseId: string;
350
+ group: string;
351
+ permits: number;
352
+ expiresAt: number;
353
+ }[] | undefined;
354
+ contended?: boolean | undefined;
355
+ clientChannel?: string | undefined;
356
+ }, "Client channel does not match semaphore protocol version">]>;
357
+ export type PermitSyncResult = v.InferOutput<typeof permitSyncResultSchema>;
358
+ export declare const semaphoreResponseSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
359
+ readonly type: v.LiteralSchema<"grant", undefined>;
360
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
361
+ readonly grants: v.ArraySchema<v.ObjectSchema<{
362
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
363
+ readonly group: v.StringSchema<undefined>;
364
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
365
+ }, undefined>, undefined>;
366
+ readonly blocked: v.ArraySchema<v.ObjectSchema<{
367
+ readonly group: v.StringSchema<undefined>;
368
+ readonly reason: v.PicklistSchema<["group_limit", "limit", "limit_resolution_error", "not_permitted"], undefined>;
369
+ }, undefined>, undefined>;
370
+ /** The client must not send another request before this. */
371
+ readonly nextRequestAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
372
+ readonly grantResults: v.ArraySchema<v.ObjectSchema<{
373
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
374
+ /** Server-clamped claim high-water mark; the client admits only up to this. */
375
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
376
+ readonly status: v.PicklistSchema<["ok", "not_found", "expired"], undefined>;
377
+ }, undefined>, undefined>;
378
+ readonly leases: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
379
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
380
+ readonly group: v.StringSchema<undefined>;
381
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
382
+ /** `expiresAt <= now` retires the lease: stop drawing immediately. */
383
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
384
+ }, undefined>, undefined>, undefined>;
385
+ /** Demand went unserved: return undrawn lease permits in groups with nothing queued. */
386
+ readonly contended: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
387
+ /** Echoes the request's client channel in version 2. */
388
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
389
+ }, undefined>, v.CheckAction<{
390
+ type: "grant";
391
+ v: 1 | 2;
392
+ grants: {
393
+ grantId: string;
394
+ group: string;
395
+ permits: number;
396
+ }[];
397
+ blocked: {
398
+ group: string;
399
+ reason: "limit" | "group_limit" | "limit_resolution_error" | "not_permitted";
400
+ }[];
401
+ nextRequestAt: number;
402
+ grantResults: {
403
+ grantId: string;
404
+ claimed: number;
405
+ status: "not_found" | "ok" | "expired";
406
+ }[];
407
+ leases?: {
408
+ leaseId: string;
409
+ group: string;
410
+ permits: number;
411
+ expiresAt: number;
412
+ }[] | undefined;
413
+ contended?: boolean | undefined;
414
+ clientChannel?: string | undefined;
415
+ }, "Client channel does not match semaphore protocol version">]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
416
+ readonly type: v.LiteralSchema<"synced", undefined>;
417
+ readonly v: v.PicklistSchema<[1, 2], undefined>;
418
+ readonly grantResults: v.ArraySchema<v.ObjectSchema<{
419
+ readonly grantId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
420
+ /** Server-clamped claim high-water mark; the client admits only up to this. */
421
+ readonly claimed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
422
+ readonly status: v.PicklistSchema<["ok", "not_found", "expired"], undefined>;
423
+ }, undefined>, undefined>;
424
+ readonly leases: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
425
+ readonly leaseId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
426
+ readonly group: v.StringSchema<undefined>;
427
+ readonly permits: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
428
+ /** `expiresAt <= now` retires the lease: stop drawing immediately. */
429
+ readonly expiresAt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
430
+ }, undefined>, undefined>, undefined>;
431
+ readonly contended: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
432
+ /** Echoes the sync's `clientChannel`, as for a grant. */
433
+ readonly clientChannel: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
434
+ }, undefined>, v.CheckAction<{
435
+ type: "synced";
436
+ v: 1 | 2;
437
+ grantResults: {
438
+ grantId: string;
439
+ claimed: number;
440
+ status: "not_found" | "ok" | "expired";
441
+ }[];
442
+ leases?: {
443
+ leaseId: string;
444
+ group: string;
445
+ permits: number;
446
+ expiresAt: number;
447
+ }[] | undefined;
448
+ contended?: boolean | undefined;
449
+ clientChannel?: string | undefined;
450
+ }, "Client channel does not match semaphore protocol version">]>], undefined>;
451
+ export type SemaphoreResponse = v.InferOutput<typeof semaphoreResponseSchema>;