@spfn/core 0.3.0-beta.7 → 0.3.0-beta.8
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.
|
@@ -125,8 +125,17 @@ interface JobSendOptions {
|
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* Job handler function type
|
|
128
|
+
*
|
|
129
|
+
* The check is wrapped in a tuple — `[TInput] extends [void]`, not
|
|
130
|
+
* `TInput extends void` — to stop the conditional from distributing. A bare
|
|
131
|
+
* type parameter in the check position makes the conditional distributive, so a
|
|
132
|
+
* union input `A | B | C` is evaluated per member and the results are unioned
|
|
133
|
+
* into three function types whose parameters intersect to `never`: no caller
|
|
134
|
+
* can then pass any member. The tuple makes the union one opaque type, which is
|
|
135
|
+
* what a handler taking `A | B | C` needs. The same wrap is on `send`, `run`
|
|
136
|
+
* and `sendBatch` below, for the same reason. Do not "simplify" it away.
|
|
128
137
|
*/
|
|
129
|
-
type JobHandler<TInput, TOutput = void> = TInput extends void ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
138
|
+
type JobHandler<TInput, TOutput = void> = [TInput] extends [void] ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
130
139
|
/**
|
|
131
140
|
* Compensate handler function type (for rollback)
|
|
132
141
|
*/
|
|
@@ -178,17 +187,17 @@ interface JobDef<TInput = void, TOutput = void> {
|
|
|
178
187
|
/**
|
|
179
188
|
* Send job to queue (returns immediately, executes in background)
|
|
180
189
|
*/
|
|
181
|
-
send: TInput extends void ? (options?: JobSendOptions) => Promise<string | null> : (input: TInput, options?: JobSendOptions) => Promise<string | null>;
|
|
190
|
+
send: [TInput] extends [void] ? (options?: JobSendOptions) => Promise<string | null> : (input: TInput, options?: JobSendOptions) => Promise<string | null>;
|
|
182
191
|
/**
|
|
183
192
|
* Run job synchronously (for testing/debugging)
|
|
184
193
|
*/
|
|
185
|
-
run: TInput extends void ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
194
|
+
run: [TInput] extends [void] ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
186
195
|
/**
|
|
187
196
|
* Bulk insert jobs into the queue (pg-boss insert).
|
|
188
197
|
* Much faster than calling send() in a loop.
|
|
189
198
|
* Only available for jobs with input schema.
|
|
190
199
|
*/
|
|
191
|
-
sendBatch: TInput extends void ? (options?: JobSendOptions) => Promise<void> : (inputs: TInput[], options?: JobSendOptions) => Promise<void>;
|
|
200
|
+
sendBatch: [TInput] extends [void] ? (options?: JobSendOptions) => Promise<void> : (inputs: TInput[], options?: JobSendOptions) => Promise<void>;
|
|
192
201
|
/**
|
|
193
202
|
* Type inference helpers
|
|
194
203
|
*/
|
package/dist/job/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as JobOptions, C as CompensateHandler, a as JobHandler, b as JobDef, c as JobRouter, d as JobRouterEntry, e as JobQueuePolicy } from '../boss-
|
|
2
|
-
export { B as BossConfig, f as BossOptions, I as InferJobInput, g as InferJobOutput, h as JobSendOptions, i as getBoss, j as initBoss, k as isBossRunning, s as shouldClearOnStart, l as stopBoss } from '../boss-
|
|
1
|
+
import { J as JobOptions, C as CompensateHandler, a as JobHandler, b as JobDef, c as JobRouter, d as JobRouterEntry, e as JobQueuePolicy } from '../boss-BiDCbbAQ.js';
|
|
2
|
+
export { B as BossConfig, f as BossOptions, I as InferJobInput, g as InferJobOutput, h as JobSendOptions, i as getBoss, j as initBoss, k as isBossRunning, s as shouldClearOnStart, l as stopBoss } from '../boss-BiDCbbAQ.js';
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
5
5
|
import { EventDef, InferEventPayload } from '@spfn/core/event';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { serve } from '@hono/node-server';
|
|
|
5
5
|
import { NamedMiddleware, Router } from '@spfn/core/route';
|
|
6
6
|
import { OnErrorContext, ProxyGuardConfig, RateLimitOptions } from '@spfn/core/middleware';
|
|
7
7
|
import { SafeFetchPolicy } from '@spfn/core/security';
|
|
8
|
-
import { c as JobRouter, f as BossOptions } from '../boss-
|
|
8
|
+
import { c as JobRouter, f as BossOptions } from '../boss-BiDCbbAQ.js';
|
|
9
9
|
import { b as EventRouterDef, E as EventDef } from '../token-manager-BT5EnUAR.js';
|
|
10
10
|
import { d as SSEHandlerConfig, e as SSEAuthConfig } from '../types-ZQODsBft.js';
|
|
11
11
|
import { W as WSRouterDef, f as WSHandlerConfig, e as WSMessageHandlers, g as WSAuthConfig } from '../types-2AbaW4Ie.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spfn/core",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.8",
|
|
4
4
|
"description": "Full-stack TypeScript backend for Next.js: file-based typed routes, Drizzle entities and repositories, PostgreSQL transactions and a generated end-to-end client, in one fixed vertical slice per feature",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/job/README.md
CHANGED
|
@@ -140,6 +140,10 @@ const typedJob = job('typed')
|
|
|
140
140
|
const noInput = job('simple').handler(async () => { await db.cleanup(); });
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
+
A `Type.Union([...])` input is supported: `send`, `run`, `sendBatch` and the handler are
|
|
144
|
+
typed on the whole union, so each member is accepted and a non-member is rejected — no cast
|
|
145
|
+
and no per-member overload.
|
|
146
|
+
|
|
143
147
|
### Cron — scheduled
|
|
144
148
|
|
|
145
149
|
```typescript
|