kizunajs 2.0.0-beta.2 → 2.0.0-beta.21
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/README.md +3 -2
- package/dist/{adapter-CZW-unqX.mjs → adapter-BSqNrxhq.mjs} +522 -104
- package/dist/adapter-C3WYdSfx.d.cts +2754 -0
- package/dist/{adapter-DDR_yo9L.cjs → adapter-ClaFZoab.cjs} +638 -196
- package/dist/adapter-D4bTPElA.d.mts +2754 -0
- package/dist/adapter.cjs +37 -29
- package/dist/adapter.d.cts +3 -5
- package/dist/adapter.d.mts +3 -5
- package/dist/adapter.mjs +5 -5
- package/dist/{error-response-C8Ragjcd.cjs → error-response-C9ymqSU4.cjs} +25 -5
- package/dist/{error-response-C839d8By.mjs → error-response-CNQaKVYd.mjs} +20 -6
- package/dist/{security-scheme-BrszwGD5.d.cts → error-response-NoOGdh8H.d.mts} +151 -24
- package/dist/{security-scheme-D3nb4XKj.d.mts → error-response-YbkRMKno.d.cts} +151 -24
- package/dist/generator.cjs +190 -95
- package/dist/generator.d.cts +189 -28
- package/dist/generator.d.mts +189 -28
- package/dist/generator.mjs +151 -60
- package/dist/index.cjs +159 -84
- package/dist/index.d.cts +193 -253
- package/dist/index.d.mts +193 -253
- package/dist/index.mjs +112 -38
- package/dist/jobs-entry.cjs +12 -11
- package/dist/jobs-entry.d.cts +1 -1
- package/dist/jobs-entry.d.mts +1 -1
- package/dist/jobs-entry.mjs +3 -2
- package/dist/plugin-Dw-yCjTY.cjs +233 -0
- package/dist/{cache-CLN5y0Xp.mjs → plugin-server-BztlE1fz.mjs} +188 -49
- package/dist/{cache-BgohRj0i.cjs → plugin-server-kUsK7thV.cjs} +238 -93
- package/dist/plugin-xxCxibmu.mjs +138 -0
- package/dist/plugin.cjs +8 -72
- package/dist/plugin.d.cts +3 -3
- package/dist/plugin.d.mts +3 -3
- package/dist/plugin.mjs +2 -68
- package/dist/{protected-resource-metadata-CA0v5cjg.d.mts → protected-resource-metadata-B9hMFQ9N.d.cts} +1 -1
- package/dist/{protected-resource-metadata-Cprrv0mt.d.cts → protected-resource-metadata-CfBVsqIk.d.mts} +1 -1
- package/dist/{schemas-C56no6bv.cjs → schemas-DNPVDvkd.cjs} +28 -1
- package/dist/{schemas-CJQcc97N.mjs → schemas-HW2FDsvz.mjs} +23 -2
- package/dist/schemas.cjs +3 -2
- package/dist/schemas.d.cts +24 -3
- package/dist/schemas.d.mts +24 -3
- package/dist/schemas.mjs +3 -3
- package/package.json +1 -1
- package/src/adapter.ts +245 -29
- package/src/api-definition.ts +12 -16
- package/src/api.ts +7 -3
- package/src/brand.ts +29 -0
- package/src/config.ts +51 -10
- package/src/configured.ts +13 -6
- package/src/define-config.ts +118 -39
- package/src/generator.ts +363 -46
- package/src/group-routes.ts +106 -0
- package/src/groups.ts +140 -0
- package/src/handler-pipeline.ts +78 -19
- package/src/index.ts +15 -6
- package/src/job-runner.ts +5 -0
- package/src/job-transport.ts +3 -3
- package/src/job.ts +8 -6
- package/src/jobs-dev-runner.ts +6 -0
- package/src/jobs.ts +61 -8
- package/src/kizuna.ts +56 -33
- package/src/plugin-server.ts +129 -19
- package/src/plugin.ts +269 -127
- package/src/routes.ts +80 -32
- package/src/schemas.ts +1 -0
- package/src/tool-answer.ts +21 -0
- package/src/tool-definitions.ts +166 -0
- package/src/tool-events.ts +90 -18
- package/src/tool-records.ts +11 -3
- package/src/tool-runner.ts +298 -0
- package/src/types.ts +90 -24
- package/src/zod-internals.ts +22 -5
- package/src/zod-meta.ts +7 -2
- package/dist/adapter-BGfMqEkM.d.cts +0 -563
- package/dist/adapter-Ci3cfcoT.d.mts +0 -563
- package/dist/api-definition-BHnh15zD.d.mts +0 -803
- package/dist/api-definition-DQj-ewHy.d.cts +0 -803
- package/dist/error-response-BBGSdgYw.d.mts +0 -67
- package/dist/error-response-Do38sr-9.d.cts +0 -67
- package/dist/plugin-Cz0kn6Lk.d.mts +0 -830
- package/dist/plugin-DhKvx_T0.d.cts +0 -830
- package/src/tags.ts +0 -67
|
@@ -1,803 +0,0 @@
|
|
|
1
|
-
import { J as Routes, Q as StreamResponseDefinition, V as ResponseDefinition, Z as StreamDefinition, a as SecurityScheme, k as CachePolicy } from "./security-scheme-BrszwGD5.cjs";
|
|
2
|
-
import { P as HandlerReturn, n as ApiPlugins } from "./plugin-DhKvx_T0.cjs";
|
|
3
|
-
import { t as ProblemDetailsSchema } from "./error-response-Do38sr-9.cjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/schedule.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* A job's schedule: a five-field cron expression, or that expression together
|
|
9
|
-
* with the IANA time zone its fields are read in.
|
|
10
|
-
*/
|
|
11
|
-
type JobSchedule = string | {
|
|
12
|
-
cron: string;
|
|
13
|
-
/**
|
|
14
|
-
* IANA time zone name, e.g. `'Europe/Oslo'`. Omitted means UTC.
|
|
15
|
-
*/
|
|
16
|
-
timezone?: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The cron expression of a {@link JobSchedule}, whichever form it was written in.
|
|
20
|
-
*/
|
|
21
|
-
declare const scheduleExpression: (schedule: JobSchedule) => string;
|
|
22
|
-
/**
|
|
23
|
-
* The time zone of a {@link JobSchedule}, or `undefined` for UTC.
|
|
24
|
-
*/
|
|
25
|
-
declare const scheduleTimezone: (schedule: JobSchedule) => string | undefined;
|
|
26
|
-
declare const DAY_NAMES: Readonly<Record<string, number>>;
|
|
27
|
-
/**
|
|
28
|
-
* A cron expression resolved to the set of values each field permits.
|
|
29
|
-
*/
|
|
30
|
-
interface ParsedCron {
|
|
31
|
-
minutes: ReadonlySet<number>;
|
|
32
|
-
hours: ReadonlySet<number>;
|
|
33
|
-
daysOfMonth: ReadonlySet<number>;
|
|
34
|
-
months: ReadonlySet<number>;
|
|
35
|
-
daysOfWeek: ReadonlySet<number>;
|
|
36
|
-
/**
|
|
37
|
-
* Whether the day-of-month field was narrowed from `*`. When both day fields
|
|
38
|
-
* are narrowed, a run happens on a day matching *either* of them, the Vixie
|
|
39
|
-
* cron rule.
|
|
40
|
-
*/
|
|
41
|
-
dayOfMonthRestricted: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the day-of-week field was narrowed from `*`. See
|
|
44
|
-
* {@link ParsedCron.dayOfMonthRestricted}.
|
|
45
|
-
*/
|
|
46
|
-
dayOfWeekRestricted: boolean;
|
|
47
|
-
timezone: string | undefined;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Parse a five-field cron expression into the values each field permits.
|
|
51
|
-
* Throws with the offending field named.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* parseCron('0 5 * * *').hours; // Set { 5 }
|
|
55
|
-
*/
|
|
56
|
-
declare const parseCron: (schedule: JobSchedule) => ParsedCron;
|
|
57
|
-
/**
|
|
58
|
-
* Throws when a job's schedule is not a valid cron expression, naming the job.
|
|
59
|
-
* Called by `k.jobs` so a bad schedule fails when the api is built rather
|
|
60
|
-
* than when the scheduler first fires.
|
|
61
|
-
*/
|
|
62
|
-
declare const assertValidSchedule: (schedule: JobSchedule, jobName: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* The first time at or after `from` that `schedule` fires, exclusive of `from`
|
|
65
|
-
* itself. Returns `undefined` for a schedule that names a date which never
|
|
66
|
-
* occurs, such as February 30th.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* nextRun('0 5 * * *', new Date('2026-08-05T06:00:00Z'));
|
|
70
|
-
* // 2026-08-06T05:00:00Z
|
|
71
|
-
*/
|
|
72
|
-
declare const nextRun: (schedule: JobSchedule, from?: Date) => Date | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* The next `count` times a schedule fires after `from`. Stops early when the
|
|
75
|
-
* schedule names a date that never occurs.
|
|
76
|
-
*/
|
|
77
|
-
declare const nextRuns: (schedule: JobSchedule, count: number, from?: Date) => Date[];
|
|
78
|
-
/**
|
|
79
|
-
* Whether a schedule fires in the half-open window `(after, at]`.
|
|
80
|
-
*/
|
|
81
|
-
declare const firesBetween: (schedule: JobSchedule, after: Date, at: Date) => boolean;
|
|
82
|
-
/**
|
|
83
|
-
* The schedules due as of `at`, keyed as they were passed in.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* const due = dueSchedules(
|
|
87
|
-
* Object.fromEntries(Object.entries(kizuna.api.jobs ?? {}).map(([name, job]) => [name, job.schedule]))
|
|
88
|
-
* );
|
|
89
|
-
*/
|
|
90
|
-
declare const dueSchedules: (schedules: Record<string, JobSchedule>, options?: {
|
|
91
|
-
at?: Date;
|
|
92
|
-
/**
|
|
93
|
-
* How far back a tick looks. Widen it when the platform's delivery is
|
|
94
|
-
* less punctual than its cron expression suggests.
|
|
95
|
-
*
|
|
96
|
-
* @default 60000
|
|
97
|
-
*/
|
|
98
|
-
windowMs?: number;
|
|
99
|
-
}) => string[];
|
|
100
|
-
/**
|
|
101
|
-
* Builders for a five-field cron expression, for a `schedule` you would rather
|
|
102
|
-
* read than decode. Each returns a plain cron string.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* schedule: cron.daily('05:00');
|
|
106
|
-
*/
|
|
107
|
-
declare const cron: {
|
|
108
|
-
every: (interval: string) => string;
|
|
109
|
-
hourly: (minute?: number) => string;
|
|
110
|
-
daily: (time: string) => string;
|
|
111
|
-
weekly: (day: keyof typeof DAY_NAMES, time: string) => string;
|
|
112
|
-
monthly: (dayOfMonth: number, time: string) => string;
|
|
113
|
-
};
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/job-transport.d.ts
|
|
116
|
-
/**
|
|
117
|
-
* One job, ready to deliver. The input is already validated, so a transport
|
|
118
|
-
* never looks at a schema.
|
|
119
|
-
*/
|
|
120
|
-
interface JobMessage {
|
|
121
|
-
/**
|
|
122
|
-
* The job's dotted key, e.g. `billing.reconcileInvoices`. It is how the
|
|
123
|
-
* message is addressed: a job has no URL of its own.
|
|
124
|
-
*/
|
|
125
|
-
job: string;
|
|
126
|
-
/**
|
|
127
|
-
* The validated input, or `undefined` when the job declares none. JSON-safe.
|
|
128
|
-
*/
|
|
129
|
-
input: unknown;
|
|
130
|
-
/**
|
|
131
|
-
* Hold delivery until this time.
|
|
132
|
-
*/
|
|
133
|
-
runAt?: Date;
|
|
134
|
-
/**
|
|
135
|
-
* Deliver at most one message carrying this key.
|
|
136
|
-
*/
|
|
137
|
-
dedupeKey?: string;
|
|
138
|
-
/**
|
|
139
|
-
* How many attempts the job declared. Backoff is the transport's own.
|
|
140
|
-
*/
|
|
141
|
-
retry?: number;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* What a transport honours. `defineConfig` warns when a job asks for something
|
|
145
|
-
* left out.
|
|
146
|
-
*/
|
|
147
|
-
interface JobTransportSupports {
|
|
148
|
-
retry?: boolean;
|
|
149
|
-
dedupe?: boolean;
|
|
150
|
-
runAt?: boolean;
|
|
151
|
-
}
|
|
152
|
-
interface JobDescriptor {
|
|
153
|
-
/**
|
|
154
|
-
* The job's dotted key.
|
|
155
|
-
*/
|
|
156
|
-
job: string;
|
|
157
|
-
}
|
|
158
|
-
interface ScheduledJob extends JobDescriptor {
|
|
159
|
-
/**
|
|
160
|
-
* A five-field cron expression.
|
|
161
|
-
*/
|
|
162
|
-
cron: string;
|
|
163
|
-
/**
|
|
164
|
-
* IANA time zone the expression is read in, or `undefined` for UTC.
|
|
165
|
-
*/
|
|
166
|
-
timezone: string | undefined;
|
|
167
|
-
}
|
|
168
|
-
interface JobWorker {
|
|
169
|
-
stop: () => Promise<void> | void;
|
|
170
|
-
}
|
|
171
|
-
interface JobWorkerContext {
|
|
172
|
-
/**
|
|
173
|
-
* Every job the api declares, to subscribe by name.
|
|
174
|
-
*/
|
|
175
|
-
jobs: readonly JobDescriptor[];
|
|
176
|
-
/**
|
|
177
|
-
* Run one message through the same handler a route would reach. Let its
|
|
178
|
-
* rejection propagate: that is how the transport learns to retry.
|
|
179
|
-
*/
|
|
180
|
-
run: (message: JobMessage) => Promise<void>;
|
|
181
|
-
}
|
|
182
|
-
interface JobTransportDefinition {
|
|
183
|
-
name: string;
|
|
184
|
-
supports?: JobTransportSupports;
|
|
185
|
-
/**
|
|
186
|
-
* Deliver one job. Resolve once the message is handed over, not once the job
|
|
187
|
-
* has run; reject when it could not be handed over at all.
|
|
188
|
-
*/
|
|
189
|
-
dispatch: (message: JobMessage) => Promise<void> | void;
|
|
190
|
-
/**
|
|
191
|
-
* Drain stored work, for a transport that is pulled rather than pushed.
|
|
192
|
-
*/
|
|
193
|
-
start?: (context: JobWorkerContext) => Promise<JobWorker>;
|
|
194
|
-
/**
|
|
195
|
-
* Take scheduling over, for a transport with a scheduler of its own.
|
|
196
|
-
* `startJobs` then hands the schedules across instead of ticking them.
|
|
197
|
-
*/
|
|
198
|
-
register?: (schedules: readonly ScheduledJob[]) => Promise<void> | void;
|
|
199
|
-
}
|
|
200
|
-
interface JobTransport extends JobTransportDefinition {
|
|
201
|
-
readonly supports: JobTransportSupports;
|
|
202
|
-
}
|
|
203
|
-
declare class JobDispatchError extends Error {
|
|
204
|
-
readonly transport: string;
|
|
205
|
-
readonly job: string;
|
|
206
|
-
constructor(transport: string, job: string, cause: unknown);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Define a transport: what carries a queued job to whatever runs it.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* export const pgBoss = (boss: PgBoss) =>
|
|
213
|
-
* createJobTransport({
|
|
214
|
-
* name: 'pg-boss',
|
|
215
|
-
* supports: {
|
|
216
|
-
* retry: true,
|
|
217
|
-
* dedupe: true,
|
|
218
|
-
* runAt: true,
|
|
219
|
-
* },
|
|
220
|
-
* dispatch: async (message) => {
|
|
221
|
-
* await boss.send(message.job, message.input ?? {}, {
|
|
222
|
-
* startAfter: message.runAt,
|
|
223
|
-
* singletonKey: message.dedupeKey,
|
|
224
|
-
* retryLimit: message.retry,
|
|
225
|
-
* });
|
|
226
|
-
* },
|
|
227
|
-
* start: async ({ jobs, run }) => {
|
|
228
|
-
* for (const { job } of jobs) {
|
|
229
|
-
* await boss.work(job, async ([queued]) => {
|
|
230
|
-
* await run({
|
|
231
|
-
* job,
|
|
232
|
-
* input: queued.data,
|
|
233
|
-
* });
|
|
234
|
-
* });
|
|
235
|
-
* }
|
|
236
|
-
* return {
|
|
237
|
-
* stop: () => boss.stop(),
|
|
238
|
-
* };
|
|
239
|
-
* },
|
|
240
|
-
* });
|
|
241
|
-
*/
|
|
242
|
-
declare const createJobTransport: (definition: JobTransportDefinition) => JobTransport;
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/job-runner.d.ts
|
|
245
|
-
/**
|
|
246
|
-
* The arguments a job takes when run in code: its input when it declares one,
|
|
247
|
-
* nothing otherwise.
|
|
248
|
-
*/
|
|
249
|
-
type JobRunArgs<Job extends CompiledJob> = Job['definition'] extends {
|
|
250
|
-
input: z.ZodType;
|
|
251
|
-
} ? [input: z.input<Job['definition']['input']>] : [];
|
|
252
|
-
/**
|
|
253
|
-
* What `queue` takes: the job's input when it declares one, alongside how the
|
|
254
|
-
* message should be delivered.
|
|
255
|
-
*/
|
|
256
|
-
type JobQueueArgs<Job extends CompiledJob> = Job['definition'] extends {
|
|
257
|
-
input: z.ZodType;
|
|
258
|
-
} ? [message: {
|
|
259
|
-
input: z.input<Job['definition']['input']>;
|
|
260
|
-
} & JobQueueOptions] : [message?: JobQueueOptions];
|
|
261
|
-
interface JobQueueOptions {
|
|
262
|
-
/**
|
|
263
|
-
* Hold the job until this time. Honoured by transports declaring
|
|
264
|
-
* `supports.runAt`.
|
|
265
|
-
*/
|
|
266
|
-
runAt?: Date;
|
|
267
|
-
/**
|
|
268
|
-
* Run this at most once, however many times it is queued. Honoured by
|
|
269
|
-
* transports declaring `supports.dedupe`.
|
|
270
|
-
*/
|
|
271
|
-
dedupeKey?: string;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* One job, reachable two ways.
|
|
275
|
-
*/
|
|
276
|
-
interface JobFn<Job extends CompiledJob> {
|
|
277
|
-
/**
|
|
278
|
-
* Run the job now and resolve to what its handler returned.
|
|
279
|
-
*/
|
|
280
|
-
run: (...args: JobRunArgs<Job>) => Promise<JobHandlerReturn<Job['definition']>>;
|
|
281
|
-
/**
|
|
282
|
-
* Put the job in line and answer without waiting for it. With no transport
|
|
283
|
-
* configured the job runs in this process and is lost on a crash.
|
|
284
|
-
*/
|
|
285
|
-
queue: (...args: JobQueueArgs<Job>) => Promise<void>;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* An api's jobs, shaped exactly like the declaration.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* await jobs.billing.reconcileInvoices.run({ since });
|
|
292
|
-
* await jobs.indexUser.queue({
|
|
293
|
-
* input: {
|
|
294
|
-
* userId,
|
|
295
|
-
* },
|
|
296
|
-
* });
|
|
297
|
-
*/
|
|
298
|
-
type JobRunner<Jobs_ extends Jobs> = { [Name in keyof Jobs_]: Jobs_[Name] extends CompiledJob ? JobFn<Jobs_[Name]> : Jobs_[Name] extends Jobs ? JobRunner<Jobs_[Name]> : never };
|
|
299
|
-
declare class JobInputError extends Error {
|
|
300
|
-
readonly job: string;
|
|
301
|
-
readonly issues: z.core.$ZodIssue[];
|
|
302
|
-
constructor(job: string, issues: z.core.$ZodIssue[]);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Called when a job queued without a transport rejects. Without one, the
|
|
306
|
-
* failure is logged.
|
|
307
|
-
*/
|
|
308
|
-
type JobErrorHandler = (job: string, error: unknown) => void;
|
|
309
|
-
interface JobRunnerOptions {
|
|
310
|
-
/**
|
|
311
|
-
* Carries a queued job to whatever runs it. Without one, `queue` runs the job
|
|
312
|
-
* in this process without waiting for it.
|
|
313
|
-
*/
|
|
314
|
-
transport?: JobTransport;
|
|
315
|
-
onError?: JobErrorHandler;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* A job's `run` and `queue` reached by dotted key. Untyped, because a caller
|
|
319
|
-
* holding a key does not know it statically.
|
|
320
|
-
*/
|
|
321
|
-
interface JobFnByKey {
|
|
322
|
-
run: (input?: unknown) => Promise<unknown>;
|
|
323
|
-
queue: (message?: JobQueueOptions & {
|
|
324
|
-
input?: unknown;
|
|
325
|
-
}) => Promise<void>;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Walk a {@link JobRunner} tree to the pair for one dotted key.
|
|
329
|
-
*/
|
|
330
|
-
declare const jobFnAt: (runner: unknown, jobKey: string) => JobFnByKey | undefined;
|
|
331
|
-
/**
|
|
332
|
-
* Pair a job tree with the handlers that run it, so the jobs can be run from
|
|
333
|
-
* anywhere. `defineConfig` builds one from the handlers each job carries, and
|
|
334
|
-
* every route and job handler receives it as `jobs`.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* const jobs = createJobRunner(jobTree, handlers);
|
|
338
|
-
*
|
|
339
|
-
* await jobs.billing.reconcileInvoices.run({ since: '2026-08-01' });
|
|
340
|
-
* await jobs.indexUser.queue({
|
|
341
|
-
* input: {
|
|
342
|
-
* userId: user.id,
|
|
343
|
-
* },
|
|
344
|
-
* });
|
|
345
|
-
*/
|
|
346
|
-
declare const createJobRunner: <Jobs_ extends Jobs>(source: Jobs_ | {
|
|
347
|
-
jobs?: Jobs_;
|
|
348
|
-
}, handlers: JobHandlers<Jobs_>, options?: JobRunnerOptions) => JobRunner<Jobs_>;
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/jobs.d.ts
|
|
351
|
-
/**
|
|
352
|
-
* Settings shared by every job, named in `defineConfig` under `jobsConfig`. The jobs
|
|
353
|
-
* themselves are declared with `k.jobs`.
|
|
354
|
-
*/
|
|
355
|
-
interface JobsConfig {
|
|
356
|
-
/**
|
|
357
|
-
* The namespace both job endpoints are mounted under, `dispatch` and `run`
|
|
358
|
-
* beneath it. Nothing is served on the namespace itself.
|
|
359
|
-
*
|
|
360
|
-
* @default '/jobs'
|
|
361
|
-
*/
|
|
362
|
-
path?: `/${string}`;
|
|
363
|
-
/**
|
|
364
|
-
* `GET` instead of `POST`. Vercel Cron sends `GET` and nothing else.
|
|
365
|
-
*
|
|
366
|
-
* @default 'POST'
|
|
367
|
-
*/
|
|
368
|
-
method?: 'POST' | 'GET';
|
|
369
|
-
/**
|
|
370
|
-
* How far back a tick looks for due jobs. Widen it when the scheduler
|
|
371
|
-
* delivers late.
|
|
372
|
-
*
|
|
373
|
-
* @default 60000
|
|
374
|
-
*/
|
|
375
|
-
windowMs?: number;
|
|
376
|
-
/**
|
|
377
|
-
* Dispatch only these jobs.
|
|
378
|
-
*/
|
|
379
|
-
only?: readonly string[];
|
|
380
|
-
/**
|
|
381
|
-
* Never dispatch these.
|
|
382
|
-
*/
|
|
383
|
-
exclude?: readonly string[];
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* How a deployment runs the jobs it declares: where the two endpoints sit, what
|
|
387
|
-
* carries queued work out of the process, and where a failure that happened
|
|
388
|
-
* after the response went out is reported.
|
|
389
|
-
*/
|
|
390
|
-
interface JobRunnerConfig extends JobsConfig {
|
|
391
|
-
/**
|
|
392
|
-
* Carries a queued job to whatever runs it. Without one, `queue` runs the
|
|
393
|
-
* job in this process and it is lost on a crash.
|
|
394
|
-
*/
|
|
395
|
-
transport?: JobTransport;
|
|
396
|
-
/**
|
|
397
|
-
* Reached when a job fails after its response was sent, which is the only
|
|
398
|
-
* point where nothing else can report it.
|
|
399
|
-
*/
|
|
400
|
-
onError?: JobErrorHandler;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* A scheduled job, as authored in `k.jobs`.
|
|
404
|
-
*/
|
|
405
|
-
interface JobDefinition {
|
|
406
|
-
/**
|
|
407
|
-
* A five-field cron expression, or `{ cron, timezone }`. Validated when the
|
|
408
|
-
* contract is built. Omit it for a job that is only ever queued from code.
|
|
409
|
-
*/
|
|
410
|
-
schedule?: JobSchedule;
|
|
411
|
-
/**
|
|
412
|
-
* How many attempts a failed run deserves. Handed to the transport, which is
|
|
413
|
-
* what retries.
|
|
414
|
-
*
|
|
415
|
-
* @default 1
|
|
416
|
-
*/
|
|
417
|
-
retry?: number;
|
|
418
|
-
summary?: string;
|
|
419
|
-
description?: string;
|
|
420
|
-
/**
|
|
421
|
-
* Schema for the payload the job is queued with.
|
|
422
|
-
*/
|
|
423
|
-
input?: z.ZodType;
|
|
424
|
-
/**
|
|
425
|
-
* Schema for what the job reports on success. Omit it and the job answers
|
|
426
|
-
* `204`.
|
|
427
|
-
*/
|
|
428
|
-
result?: z.ZodType;
|
|
429
|
-
/**
|
|
430
|
-
* Extra responses beyond the synthesized `200`/`204`, `422`, `500`, `503`.
|
|
431
|
-
*/
|
|
432
|
-
responses?: {
|
|
433
|
-
[status: number]: Exclude<ResponseDefinition, StreamResponseDefinition>;
|
|
434
|
-
};
|
|
435
|
-
/**
|
|
436
|
-
* The handler that runs this job. Attach it with `k.job(...).handler(...)`,
|
|
437
|
-
* which types `input` from this job and checks the return against `result`.
|
|
438
|
-
*/
|
|
439
|
-
handler?: (args: never) => unknown;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* A job as authored in `k.job`.
|
|
443
|
-
*/
|
|
444
|
-
type AuthoredJobDefinition = JobDefinition;
|
|
445
|
-
/**
|
|
446
|
-
* A job's synthesized responses. These are the retry contract: `503` asks for a
|
|
447
|
-
* retry, `422` says the failure is permanent.
|
|
448
|
-
*/
|
|
449
|
-
type JobResponses<Definition extends JobDefinition> = (Definition extends {
|
|
450
|
-
result: z.ZodType;
|
|
451
|
-
} ? {
|
|
452
|
-
200: Definition['result'];
|
|
453
|
-
} : {
|
|
454
|
-
204: z.ZodVoid;
|
|
455
|
-
}) & {
|
|
456
|
-
422: typeof ProblemDetailsSchema;
|
|
457
|
-
500: typeof ProblemDetailsSchema;
|
|
458
|
-
503: typeof ProblemDetailsSchema;
|
|
459
|
-
};
|
|
460
|
-
/**
|
|
461
|
-
* A job after `k.jobs` compiles it.
|
|
462
|
-
*/
|
|
463
|
-
interface CompiledJob<Definition extends JobDefinition = JobDefinition, IdentityName extends string | undefined = string | undefined> {
|
|
464
|
-
definition: Definition;
|
|
465
|
-
schedule: JobSchedule | undefined;
|
|
466
|
-
/**
|
|
467
|
-
* The identity every job in the group requires, or `undefined` when the group
|
|
468
|
-
* was declared without one. It guards the dispatch endpoint.
|
|
469
|
-
*/
|
|
470
|
-
identity: IdentityName;
|
|
471
|
-
/**
|
|
472
|
-
* The payload schema, or `undefined` when the job takes none.
|
|
473
|
-
*/
|
|
474
|
-
input: z.ZodType | undefined;
|
|
475
|
-
responses: JobResponses<Definition>;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* An api's jobs. Nestable, like routes, so a large codebase can group them ,
|
|
479
|
-
* `jobs.billing.reconcileInvoices`.
|
|
480
|
-
*/
|
|
481
|
-
interface Jobs {
|
|
482
|
-
[key: string]: CompiledJob | Jobs;
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* The compiled form of an authored job tree, preserving its shape.
|
|
486
|
-
*/
|
|
487
|
-
type CompiledJobs<Definitions extends AuthoredJobs, IdentityName extends string | undefined> = { [Name in keyof Definitions]: Definitions[Name] extends JobDefinition ? CompiledJob<Definitions[Name], IdentityName> : Definitions[Name] extends AuthoredJobs ? CompiledJobs<Definitions[Name], IdentityName> : never };
|
|
488
|
-
/**
|
|
489
|
-
* The shape `k.jobs` accepts: jobs, or groups of them, to any depth.
|
|
490
|
-
*/
|
|
491
|
-
interface AuthoredJobs {
|
|
492
|
-
[key: string]: JobDefinition | AuthoredJobs;
|
|
493
|
-
}
|
|
494
|
-
type JobHandlerReturn<Definition extends JobDefinition> = HandlerReturn<{
|
|
495
|
-
responses: JobResponses<Definition>;
|
|
496
|
-
}>;
|
|
497
|
-
/**
|
|
498
|
-
* The single object a job handler receives: its own input and `throwError`, and
|
|
499
|
-
* nothing else. Anything more it imports, as a route handler would.
|
|
500
|
-
*/
|
|
501
|
-
type JobHandlerArgs<Definition extends JobDefinition> = {
|
|
502
|
-
/**
|
|
503
|
-
* The validated payload, or `undefined` when the job declares no `input`.
|
|
504
|
-
*/
|
|
505
|
-
input: Definition extends {
|
|
506
|
-
input: z.ZodType;
|
|
507
|
-
} ? z.output<Definition['input']> : undefined;
|
|
508
|
-
/**
|
|
509
|
-
* Throws a typed response. Takes the same `{ status, body }` shape as a
|
|
510
|
-
* handler return.
|
|
511
|
-
*
|
|
512
|
-
* This function throws internally and never returns.
|
|
513
|
-
*/
|
|
514
|
-
throwError: (response: JobHandlerReturn<Definition>) => never;
|
|
515
|
-
};
|
|
516
|
-
/**
|
|
517
|
-
* A job declaring no `result` has only `204` to answer, so it may return nothing
|
|
518
|
-
* at all.
|
|
519
|
-
*/
|
|
520
|
-
type JobVoidReturn<Definition extends JobDefinition> = Definition extends {
|
|
521
|
-
result: z.ZodType;
|
|
522
|
-
} ? never : void;
|
|
523
|
-
type JobHandler<Job extends CompiledJob, Jobs_ extends Jobs = Jobs> = (args: JobHandlerArgs<Job['definition']> & JobsArg<Jobs_>) => Promise<JobHandlerReturn<Job['definition']> | JobVoidReturn<Job['definition']>> | JobHandlerReturn<Job['definition']> | JobVoidReturn<Job['definition']>;
|
|
524
|
-
/**
|
|
525
|
-
* The `jobs` argument every handler receives: the api's jobs bound to their
|
|
526
|
-
* handlers, so one can be run in process. Absent when the api declares none.
|
|
527
|
-
*/
|
|
528
|
-
type JobsArg<Jobs_ extends Jobs> = string extends keyof Jobs_ ? {} : {
|
|
529
|
-
jobs: JobRunner<Jobs_>;
|
|
530
|
-
};
|
|
531
|
-
/**
|
|
532
|
-
* A job tree with no jobs in it, for an api that declares none.
|
|
533
|
-
*/
|
|
534
|
-
type NoJobs = Record<string, never>;
|
|
535
|
-
/**
|
|
536
|
-
* The handler each declared job carries, keyed by name.
|
|
537
|
-
*/
|
|
538
|
-
type JobHandlers<Jobs_ extends Jobs, Root extends Jobs = Jobs_> = { [Name in keyof Jobs_]: Jobs_[Name] extends CompiledJob ? JobHandler<Jobs_[Name], Root> : Jobs_[Name] extends Jobs ? JobHandlers<Jobs_[Name], Root> : never };
|
|
539
|
-
/**
|
|
540
|
-
* Whether a node in an authored tree is a job rather than a group of them.
|
|
541
|
-
*/
|
|
542
|
-
declare const isJobDefinition: (value: unknown) => value is JobDefinition;
|
|
543
|
-
interface FlattenedJob {
|
|
544
|
-
/**
|
|
545
|
-
* Dotted path to the job, e.g. `billing.reconcileInvoices`. It is how every
|
|
546
|
-
* other part of the system names a job.
|
|
547
|
-
*/
|
|
548
|
-
jobKey: string;
|
|
549
|
-
job: CompiledJob;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Every job in a tree, with its dotted key.
|
|
553
|
-
*/
|
|
554
|
-
declare const flattenJobs: (jobs: Jobs, prefix?: string) => FlattenedJob[];
|
|
555
|
-
/**
|
|
556
|
-
* The job at a dotted key, or `undefined`.
|
|
557
|
-
*/
|
|
558
|
-
declare const jobAt: (jobs: Jobs, jobKey: string) => CompiledJob | undefined;
|
|
559
|
-
declare const isCompiledJob: (value: unknown) => value is CompiledJob;
|
|
560
|
-
//#endregion
|
|
561
|
-
//#region src/generator-utils.d.ts
|
|
562
|
-
declare const isZodSchema: (value: unknown) => value is z.ZodType;
|
|
563
|
-
/**
|
|
564
|
-
* Whether a response is sent piece by piece, declared with `stream` in place of `body`.
|
|
565
|
-
*/
|
|
566
|
-
declare const isStreamResponse: (value: ResponseDefinition | undefined) => value is StreamResponseDefinition;
|
|
567
|
-
/**
|
|
568
|
-
* The body schema of a response, or `undefined` for a stream, which has none.
|
|
569
|
-
*/
|
|
570
|
-
declare const resolveResponseBody: (value: ResponseDefinition) => z.ZodType | undefined;
|
|
571
|
-
declare const resolveResponseStream: (value: ResponseDefinition) => StreamDefinition | undefined;
|
|
572
|
-
declare const resolveResponseHeaders: (value: ResponseDefinition) => z.ZodType | undefined;
|
|
573
|
-
declare const resolveResponseContentType: (value: ResponseDefinition | undefined) => string | undefined;
|
|
574
|
-
declare const resolveResponseCache: (value: ResponseDefinition | undefined) => CachePolicy | undefined;
|
|
575
|
-
declare const resolveResponseEtag: (value: ResponseDefinition | undefined) => boolean;
|
|
576
|
-
declare const toPascalCase: (input: string) => string;
|
|
577
|
-
declare const toCamelCase: (input: string) => string;
|
|
578
|
-
/**
|
|
579
|
-
* The local name a type gets when nested inside its owning type: the owner's
|
|
580
|
-
* name stripped from the front (`UserAvatar` inside `User` → `Avatar`).
|
|
581
|
-
*/
|
|
582
|
-
declare const shortTypeName: (typeName: string, ownerName: string) => string;
|
|
583
|
-
/**
|
|
584
|
-
* A hint prefix must end on a PascalCase word boundary. Otherwise `Image` claims
|
|
585
|
-
* `ImagesItem` and the nested short name becomes the mid-word slice `sItem`.
|
|
586
|
-
*/
|
|
587
|
-
declare const isHintPrefix: (typeName: string, prefix: string) => boolean;
|
|
588
|
-
/**
|
|
589
|
-
* The type name local to an operation scope: the operation name stripped from
|
|
590
|
-
* the front (`createUserInput` inside `createUser` → `Input`), or the full name
|
|
591
|
-
* when stripping would leave nothing.
|
|
592
|
-
*/
|
|
593
|
-
declare const localTypeName: (fullName: string, operationName: string) => string;
|
|
594
|
-
/**
|
|
595
|
-
* Returns a wire field key as a valid identifier: kept verbatim when already
|
|
596
|
-
* valid, otherwise camelCased from its segments, with a `_` prefix when it
|
|
597
|
-
* starts with a digit.
|
|
598
|
-
*/
|
|
599
|
-
declare const sanitizeFieldName: (key: string) => string;
|
|
600
|
-
/**
|
|
601
|
-
* Returns the input with every non-identifier character replaced by `_`, with a
|
|
602
|
-
* `_` prefix when it starts with a digit.
|
|
603
|
-
*/
|
|
604
|
-
declare const sanitizeIdentifier: (input: string) => string;
|
|
605
|
-
/**
|
|
606
|
-
* Returns the camelCase name for a known HTTP error status (`404` → `notFound`),
|
|
607
|
-
* or `status<code>` for unknown ones.
|
|
608
|
-
*/
|
|
609
|
-
declare const statusToCamelCase: (status: number) => string;
|
|
610
|
-
/**
|
|
611
|
-
* True for 2xx status codes.
|
|
612
|
-
*/
|
|
613
|
-
declare const isSuccessStatus: (status: number) => boolean;
|
|
614
|
-
/**
|
|
615
|
-
* Merges per-status response header fields into one list, marking fields that
|
|
616
|
-
* are not present on every status as optional.
|
|
617
|
-
*/
|
|
618
|
-
declare const mergeHeaderFields: <Field extends {
|
|
619
|
-
name: string;
|
|
620
|
-
optional: boolean;
|
|
621
|
-
}>(perStatusHeaders: Field[][]) => Field[];
|
|
622
|
-
/**
|
|
623
|
-
* Whether a media type is JSON-serialized: `application/json` or any
|
|
624
|
-
* structured-suffix `+json` type (e.g. `application/problem+json`). Any other
|
|
625
|
-
* type carries a raw body that is written/read as-is.
|
|
626
|
-
*/
|
|
627
|
-
declare const isJsonMediaType: (contentType: string) => boolean;
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region src/tags.d.ts
|
|
630
|
-
interface TagOptions {
|
|
631
|
-
/**
|
|
632
|
-
* The tag name, used as the OpenAPI tag and shown in rendered API docs.
|
|
633
|
-
*/
|
|
634
|
-
title: string;
|
|
635
|
-
/**
|
|
636
|
-
* Optional description shown alongside the tag in the OpenAPI spec.
|
|
637
|
-
*/
|
|
638
|
-
description?: string;
|
|
639
|
-
/**
|
|
640
|
-
* Optional external documentation for the tag.
|
|
641
|
-
*/
|
|
642
|
-
externalDocs?: {
|
|
643
|
-
url: string;
|
|
644
|
-
description?: string;
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* A set of OpenAPI tags created with `k.tags`. Named in `defineConfig` under `tags`,
|
|
649
|
-
* where routes reference each tag by its key.
|
|
650
|
-
*/
|
|
651
|
-
interface TagSet<T extends Record<string, TagOptions> = Record<string, TagOptions>> {
|
|
652
|
-
readonly __brand: 'TagSet';
|
|
653
|
-
readonly tags: T;
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* The union of tag keys declared in a {@link TagSet}, e.g. `'health' | 'users'`.
|
|
657
|
-
*/
|
|
658
|
-
type TagKeysOf<Set extends TagSet> = Set extends TagSet<infer T> ? Extract<keyof T, string> : never;
|
|
659
|
-
declare const isTagSet: (value: unknown) => value is TagSet;
|
|
660
|
-
/**
|
|
661
|
-
* Define a set of tags. A tag value may be a full {@link TagOptions} object or a
|
|
662
|
-
* string, which is shorthand for `{ title }`. Pass the result to `defineConfig`
|
|
663
|
-
* under `tags`.
|
|
664
|
-
*
|
|
665
|
-
* @example
|
|
666
|
-
* const tags = k.tags({
|
|
667
|
-
* orders: {
|
|
668
|
-
* title: 'Orders',
|
|
669
|
-
* description: 'Create and manage orders',
|
|
670
|
-
* },
|
|
671
|
-
* health: 'Health',
|
|
672
|
-
* });
|
|
673
|
-
*/
|
|
674
|
-
declare const createTags: <const T extends Record<string, TagOptions | string>>(tags: T) => TagSet<NormalizeTags<T>>;
|
|
675
|
-
/**
|
|
676
|
-
* Normalize a `k.tags` input, where each value is {@link TagOptions}
|
|
677
|
-
* or a title string, into a uniform `Record<string, TagOptions>`.
|
|
678
|
-
*/
|
|
679
|
-
type NormalizeTags<T extends Record<string, TagOptions | string>> = { [Key in keyof T]: T[Key] extends string ? {
|
|
680
|
-
title: T[Key];
|
|
681
|
-
} : T[Key] extends TagOptions ? T[Key] : never };
|
|
682
|
-
//#endregion
|
|
683
|
-
//#region src/request-context.d.ts
|
|
684
|
-
/**
|
|
685
|
-
* A request context declaration from `k.requestContext`: the schema of a
|
|
686
|
-
* request-scoped value every handler receives, and optionally the request
|
|
687
|
-
* headers it derives from. The declaration carries its own `handler`, and
|
|
688
|
-
* `defineConfig` names it under `requestContext`.
|
|
689
|
-
*/
|
|
690
|
-
interface RequestContextSchema<ContextSchema extends z.ZodType = z.ZodType, HeadersSchema extends z.ZodType | undefined = z.ZodType | undefined> {
|
|
691
|
-
readonly __brand: 'RequestContext';
|
|
692
|
-
/**
|
|
693
|
-
* Schema for the value the resolver returns and handlers receive.
|
|
694
|
-
*/
|
|
695
|
-
readonly context: ContextSchema;
|
|
696
|
-
/**
|
|
697
|
-
* Schema for the request headers the value derives from. Clients type
|
|
698
|
-
* against it: the generated fetch client takes the values once under
|
|
699
|
-
* `requestContext`, and the Swift and Kotlin clients take them in their
|
|
700
|
-
* initializers. Routes and the OpenAPI document are untouched.
|
|
701
|
-
*/
|
|
702
|
-
readonly headers?: HeadersSchema;
|
|
703
|
-
}
|
|
704
|
-
interface RequestContextConfig<ContextSchema extends z.ZodType, HeadersSchema extends z.ZodType | undefined> {
|
|
705
|
-
context: ContextSchema;
|
|
706
|
-
headers?: HeadersSchema;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* The header inputs a client sends for a declaration: the `z.input` of its
|
|
710
|
-
* `headers` schema, or nothing when the declaration has none.
|
|
711
|
-
*/
|
|
712
|
-
type RequestContextHeaderInputs<Declaration> = Declaration extends {
|
|
713
|
-
headers?: infer HeadersSchema;
|
|
714
|
-
} ? [NonNullable<HeadersSchema>] extends [never] ? {} : NonNullable<HeadersSchema> extends z.ZodType ? z.input<NonNullable<HeadersSchema>> : {} : {};
|
|
715
|
-
/**
|
|
716
|
-
* The header values a resolver reads for a declaration: the `z.output` of its
|
|
717
|
-
* `headers` schema, or the adapter's raw header record when it has none.
|
|
718
|
-
*/
|
|
719
|
-
type RequestContextHeaderValues<Declaration> = Declaration extends {
|
|
720
|
-
headers?: infer HeadersSchema;
|
|
721
|
-
} ? [NonNullable<HeadersSchema>] extends [never] ? Record<string, string | string[] | undefined> : NonNullable<HeadersSchema> extends z.ZodType ? z.output<NonNullable<HeadersSchema>> : Record<string, string | string[] | undefined> : Record<string, string | string[] | undefined>;
|
|
722
|
-
//#endregion
|
|
723
|
-
//#region src/api-definition.d.ts
|
|
724
|
-
/**
|
|
725
|
-
* A kizuna API definition: its routes plus tags, identities, and validation
|
|
726
|
-
* settings. Produced by `defineConfig` and consumed by the server adapters,
|
|
727
|
-
* fetch client, OpenAPI generator, and SDK generators.
|
|
728
|
-
*/
|
|
729
|
-
interface ApiDefinition<Routes_ extends Routes = Routes, Tags extends Record<string, TagOptions> = Record<string, TagOptions>, Codes extends string = string, Schemes extends Record<string, SecurityScheme> = Record<string, SecurityScheme>, RequestContext extends Record<string, RequestContextSchema> = Record<string, RequestContextSchema>, Plugins extends ApiPlugins = ApiPlugins, Jobs_ extends Jobs = Jobs, GuardSchema extends z.ZodType | undefined = z.ZodType | undefined> {
|
|
730
|
-
/**
|
|
731
|
-
* The API's route groups.
|
|
732
|
-
*/
|
|
733
|
-
routes: Routes_;
|
|
734
|
-
/**
|
|
735
|
-
* The body every guard's `deny()` produces, named in `defineConfig` under
|
|
736
|
-
* `guardSchema`. Each guarded route's `401` and `403` carry it in place of
|
|
737
|
-
* bare Problem Details.
|
|
738
|
-
*/
|
|
739
|
-
guardSchema?: GuardSchema;
|
|
740
|
-
/**
|
|
741
|
-
* The plugins installed on `defineConfig`. Their routes are served by
|
|
742
|
-
* `api.mount` but stay outside `routes`, so the client and the generators
|
|
743
|
-
* do not see them.
|
|
744
|
-
*/
|
|
745
|
-
plugins?: Plugins;
|
|
746
|
-
/**
|
|
747
|
-
* The scheduled jobs declared with `k.jobs`, keyed by name.
|
|
748
|
-
*/
|
|
749
|
-
jobs?: Jobs_;
|
|
750
|
-
/**
|
|
751
|
-
* The job settings named in `defineConfig` under `jobsConfig`.
|
|
752
|
-
*/
|
|
753
|
-
jobsConfig?: JobsConfig;
|
|
754
|
-
/**
|
|
755
|
-
* The tag set declared with `k.tags`. Routes reference its keys; the
|
|
756
|
-
* OpenAPI generator resolves each key to its title and description.
|
|
757
|
-
*/
|
|
758
|
-
tags?: TagSet<Tags>;
|
|
759
|
-
/**
|
|
760
|
-
* The identities named in `defineConfig`. A route's `auth` names them,
|
|
761
|
-
* `defineConfig` writes each route's `security` from it, and the
|
|
762
|
-
* OpenAPI generator emits them under `components.securitySchemes`.
|
|
763
|
-
*/
|
|
764
|
-
securitySchemes?: Schemes;
|
|
765
|
-
/**
|
|
766
|
-
* The request context schemas named in `defineConfig`. Each key names a
|
|
767
|
-
* provider registered on `defineConfig`; every handler receives its value.
|
|
768
|
-
* Never gates a request and never appears in the OpenAPI document.
|
|
769
|
-
*/
|
|
770
|
-
requestContext?: RequestContext;
|
|
771
|
-
/**
|
|
772
|
-
* Validation behavior for the API.
|
|
773
|
-
*/
|
|
774
|
-
validation?: {
|
|
775
|
-
/**
|
|
776
|
-
* Custom validation issue codes this API's handlers may emit.
|
|
777
|
-
*/
|
|
778
|
-
issueCodes?: readonly Codes[];
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* An api's route groups.
|
|
783
|
-
*/
|
|
784
|
-
type RoutesOf<C extends ApiDefinition> = C['routes'];
|
|
785
|
-
/**
|
|
786
|
-
* An api's identities, or an empty map when it declares none.
|
|
787
|
-
*/
|
|
788
|
-
type SchemesOf<C extends ApiDefinition> = Exclude<C['securitySchemes'], undefined>;
|
|
789
|
-
/**
|
|
790
|
-
* An api's request context schemas, or an empty map when it declares none.
|
|
791
|
-
*/
|
|
792
|
-
type RequestContextOf<C extends ApiDefinition> = Exclude<C['requestContext'], undefined>;
|
|
793
|
-
/**
|
|
794
|
-
* An api's plugins, or an empty map when it declares none.
|
|
795
|
-
*/
|
|
796
|
-
type ApiPluginsOf<C extends ApiDefinition> = Exclude<C['plugins'], undefined>;
|
|
797
|
-
/**
|
|
798
|
-
* An api's jobs, or an empty map when it declares none.
|
|
799
|
-
*/
|
|
800
|
-
type JobsOf<C extends ApiDefinition> = Exclude<C['jobs'], undefined>;
|
|
801
|
-
type GuardSchemaOf<C extends ApiDefinition> = Extract<C['guardSchema'], z.ZodType>;
|
|
802
|
-
//#endregion
|
|
803
|
-
export { NoJobs as $, resolveResponseStream as A, firesBetween as At, CompiledJobs as B, localTypeName as C, ScheduledJob as Ct, resolveResponseContentType as D, assertValidSchedule as Dt, resolveResponseCache as E, ParsedCron as Et, toCamelCase as F, scheduleTimezone as Ft, JobHandlerReturn as G, JobDefinition as H, toPascalCase as I, JobRunnerConfig as J, JobHandlers as K, AuthoredJobDefinition as L, sanitizeIdentifier as M, nextRuns as Mt, shortTypeName as N, parseCron as Nt, resolveResponseEtag as O, cron as Ot, statusToCamelCase as P, scheduleExpression as Pt, JobsConfig as Q, AuthoredJobs as R, isZodSchema as S, JobWorkerContext as St, resolveResponseBody as T, JobSchedule as Tt, JobHandler as U, FlattenedJob as V, JobHandlerArgs as W, Jobs as X, JobVoidReturn as Y, JobsArg as Z, isTagSet as _, JobMessage as _t, RequestContextOf as a, JobFn as at, isStreamResponse as b, JobTransportSupports as bt, RequestContextConfig as c, JobQueueArgs as ct, RequestContextSchema as d, JobRunner as dt, flattenJobs as et, NormalizeTags as f, JobRunnerOptions as ft, createTags as g, JobDispatchError as gt, TagSet as h, JobDescriptor as ht, JobsOf as i, JobErrorHandler as it, sanitizeFieldName as j, nextRun as jt, resolveResponseHeaders as k, dueSchedules as kt, RequestContextHeaderInputs as l, JobQueueOptions as lt, TagOptions as m, jobFnAt as mt, ApiPluginsOf as n, isJobDefinition as nt, RoutesOf as o, JobFnByKey as ot, TagKeysOf as p, createJobRunner as pt, JobResponses as q, GuardSchemaOf as r, jobAt as rt, SchemesOf as s, JobInputError as st, ApiDefinition as t, isCompiledJob as tt, RequestContextHeaderValues as u, JobRunArgs as ut, isHintPrefix as v, JobTransport as vt, mergeHeaderFields as w, createJobTransport as wt, isSuccessStatus as x, JobWorker as xt, isJsonMediaType as y, JobTransportDefinition as yt, CompiledJob as z };
|