@spfn/core 0.2.0-beta.70 → 0.2.0-beta.71
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 +2 -2
- package/dist/{boss-gXhgctn6.d.ts → boss-D16fO2oG.d.ts} +1 -1
- package/dist/contract/index.d.ts +2 -2
- package/dist/{define-middleware-B9bFuXVU.d.ts → define-middleware-DfDP39Nq.d.ts} +1 -1
- package/dist/event/index.d.ts +3 -3
- package/dist/event/sse/client.d.ts +2 -2
- package/dist/event/sse/index.d.ts +4 -4
- package/dist/event/ws/client.d.ts +2 -2
- package/dist/event/ws/index.d.ts +3 -3
- package/dist/job/index.d.ts +2 -2
- package/dist/middleware/index.d.ts +1 -1
- package/dist/nextjs/index.d.ts +2 -2
- package/dist/nextjs/server.d.ts +1 -1
- package/dist/route/index.d.ts +3 -3
- package/dist/route/index.js +16 -8
- package/dist/route/index.js.map +1 -1
- package/dist/{router-HDVa6gfc.d.ts → router-BgZUDHp5.d.ts} +2 -2
- package/dist/server/index.d.ts +16 -9
- package/dist/server/index.js +33 -23
- package/dist/server/index.js.map +1 -1
- package/dist/{token-manager-vZeqBbtA.d.ts → token-manager-BT5EnUAR.d.ts} +1 -1
- package/dist/{types-CF-37KAG.d.ts → types-2AbaW4Ie.d.ts} +2 -2
- package/dist/{types-7Mhoxnnt.d.ts → types-9oszaJqp.d.ts} +1 -1
- package/dist/{types-D9uMxeQS.d.ts → types-ZQODsBft.d.ts} +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ pnpm add @spfn/core@beta drizzle-orm@1.0.0-rc.4 postgres pg
|
|
|
46
46
|
# optional peer: next ^16.2.11 (only for the Next.js bridge)
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Node `>=
|
|
49
|
+
Node `>=20.0.0`. ESM only.
|
|
50
50
|
|
|
51
51
|
> **Declare Drizzle and the Postgres drivers in your own app, not just in SPFN.**
|
|
52
52
|
> `@spfn/core` takes `drizzle-orm` as a peer dependency, and Drizzle changes how it
|
|
@@ -379,7 +379,7 @@ There is no `.` entry in `exports` — by design. Subpaths keep server-only code
|
|
|
379
379
|
client bundles, which a single barrel file cannot do.
|
|
380
380
|
|
|
381
381
|
**Which Node version?**
|
|
382
|
-
`>=
|
|
382
|
+
`>=20.0.0`. The package is ESM only.
|
|
383
383
|
|
|
384
384
|
**Where do my business rules go?**
|
|
385
385
|
In services and repositories, not in route handlers. A handler validates, calls, and
|
|
@@ -281,4 +281,4 @@ declare function isBossRunning(): boolean;
|
|
|
281
281
|
*/
|
|
282
282
|
declare function shouldClearOnStart(): boolean;
|
|
283
283
|
|
|
284
|
-
export { type
|
|
284
|
+
export { type BossConfig as B, type CompensateHandler as C, type InferJobInput as I, type JobOptions as J, type JobHandler as a, type JobDef as b, type JobRouter as c, type JobRouterEntry as d, type BossOptions as e, type InferJobOutput as f, type JobSendOptions as g, getBoss as h, initBoss as i, isBossRunning as j, stopBoss as k, shouldClearOnStart as s };
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as RouteAuthProfile, a as Router } from '../router-BgZUDHp5.js';
|
|
2
2
|
import { HttpMethod } from '../route/types.js';
|
|
3
|
-
import '../define-middleware-
|
|
3
|
+
import '../define-middleware-DfDP39Nq.js';
|
|
4
4
|
import 'hono';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'hono/utils/http-status';
|
|
@@ -164,4 +164,4 @@ declare function defineMiddlewareFactory<TName extends string, TArgs extends unk
|
|
|
164
164
|
*/
|
|
165
165
|
type ExtractMiddlewareNames<T extends readonly NamedMiddleware<string>[]> = T[number]['_name'];
|
|
166
166
|
|
|
167
|
-
export { type ExtractMiddlewareNames as E, type NamedMiddlewareFactory as N,
|
|
167
|
+
export { type ExtractMiddlewareNames as E, type NamedMiddlewareFactory as N, type NamedMiddleware as a, defineMiddlewareFactory as b, defineMiddleware as d };
|
package/dist/event/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { E as EventDef } from '../token-manager-BT5EnUAR.js';
|
|
3
|
+
export { a as EventHandler, b as EventRouterDef, I as InferEventNames, c as InferEventPayload, d as InferEventPayloads, e as InferRouterEventPayload, J as JobQueueSender, P as PubSubCache, f as defineEventRouter } from '../token-manager-BT5EnUAR.js';
|
|
4
4
|
export { defineWSRouter } from './ws/index.js';
|
|
5
|
-
import '../types-
|
|
5
|
+
import '../types-2AbaW4Ie.js';
|
|
6
6
|
import 'hono';
|
|
7
7
|
import 'node:http';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { b as EventRouterDef, I as InferEventNames } from '../../token-manager-BT5EnUAR.js';
|
|
2
|
+
import { S as SSEClientConfig, a as SSESubscribeOptions, b as SSEUnsubscribe, c as SSEConnectionState } from '../../types-ZQODsBft.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
4
4
|
import 'hono';
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import {
|
|
3
|
-
export { C as CacheTokenStore, g as SSEToken,
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
2
|
+
import { b as EventRouterDef, S as SSETokenManager } from '../../token-manager-BT5EnUAR.js';
|
|
3
|
+
export { C as CacheTokenStore, g as SSEToken, h as SSETokenManagerConfig, i as SSETokenStore } from '../../token-manager-BT5EnUAR.js';
|
|
4
|
+
import { d as SSEHandlerConfig } from '../../types-ZQODsBft.js';
|
|
5
|
+
export { e as SSEAuthConfig, S as SSEClientConfig, c as SSEConnectionState, f as SSEEventHandler, g as SSEEventHandlers, h as SSEHandlerAuthConfig, i as SSEMessage, a as SSESubscribeOptions, b as SSEUnsubscribe } from '../../types-ZQODsBft.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { W as WSRouterDef,
|
|
1
|
+
import { W as WSRouterDef, a as WSSubscribeOptions, b as WSUnsubscribe, c as WSConnectionState, d as WSClientConfig } from '../../types-2AbaW4Ie.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../../token-manager-
|
|
3
|
+
import '../../token-manager-BT5EnUAR.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/event/ws/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { E as EventDef, S as SSETokenManager } from '../../token-manager-BT5EnUAR.js';
|
|
2
|
+
import { e as WSMessageHandlers, W as WSRouterDef, f as WSHandlerConfig } from '../../types-2AbaW4Ie.js';
|
|
3
|
+
export { g as WSAuthConfig, d as WSClientConfig, c as WSConnectionState, h as WSEventHandlers, i as WSHandlerAuthConfig, j as WSMessageContext, k as WSMessageHandlerFn, l as WSRawConnection, a as WSSubscribeOptions, b as WSUnsubscribe } from '../../types-2AbaW4Ie.js';
|
|
4
4
|
import { Server } from 'node:http';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'hono';
|
package/dist/job/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { J as JobOptions, C as CompensateHandler, a as JobHandler, b as JobDef, c as JobRouter, d as JobRouterEntry } from '../boss-D16fO2oG.js';
|
|
2
|
+
export { B as BossConfig, e as BossOptions, I as InferJobInput, f as InferJobOutput, g as JobSendOptions, h as getBoss, i as initBoss, j as isBossRunning, s as shouldClearOnStart, k as stopBoss } from '../boss-D16fO2oG.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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Next, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { N as NamedMiddlewareFactory,
|
|
2
|
+
import { N as NamedMiddlewareFactory, a as NamedMiddleware } from '../define-middleware-DfDP39Nq.js';
|
|
3
3
|
import { Redis, Cluster } from 'ioredis';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/nextjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router, RouteDef } from '@spfn/core/route';
|
|
2
|
-
import { R as RequestInterceptor, a as ResponseInterceptor, I as InferRouteInput, b as InferRouteOutput, A as ApiConfig } from '../types-
|
|
3
|
-
export { C as CallOptions,
|
|
2
|
+
import { R as RequestInterceptor, a as ResponseInterceptor, I as InferRouteInput, b as InferRouteOutput, A as ApiConfig } from '../types-9oszaJqp.js';
|
|
3
|
+
export { C as CallOptions, c as CookieOptions, d as RouterInput, e as RouterOutput, S as SetCookie, f as StructuredInput } from '../types-9oszaJqp.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import '@spfn/core/errors';
|
|
6
6
|
|
package/dist/nextjs/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import { HttpMethod } from '@spfn/core/route';
|
|
3
3
|
import { InterceptorRule as InterceptorRule$1 } from '@spfn/core/nextjs/server';
|
|
4
|
-
import {
|
|
4
|
+
import { S as SetCookie } from '../types-9oszaJqp.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import '@spfn/core/errors';
|
|
7
7
|
|
package/dist/route/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { M as MergedInput, P as PaginatedResult,
|
|
1
|
+
import { b as RouteDef, a as Router } from '../router-BgZUDHp5.js';
|
|
2
|
+
export { M as MergedInput, P as PaginatedResult, R as RouteAuthProfile, c as RouteBuilderContext, d as RouteContract, e as RouteHandlerFn, f as RouteInput, g as defineRouter, r as route } from '../router-BgZUDHp5.js';
|
|
3
3
|
import { Hono, MiddlewareHandler } from 'hono';
|
|
4
4
|
import { HttpMethod } from './types.js';
|
|
5
|
-
export { E as ExtractMiddlewareNames,
|
|
5
|
+
export { E as ExtractMiddlewareNames, a as NamedMiddleware, N as NamedMiddlewareFactory, d as defineMiddleware, b as defineMiddlewareFactory } from '../define-middleware-DfDP39Nq.js';
|
|
6
6
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
7
7
|
import { TSchema, Kind } from '@sinclair/typebox';
|
|
8
8
|
import 'hono/utils/http-status';
|
package/dist/route/index.js
CHANGED
|
@@ -638,7 +638,7 @@ function registerRoutes(app, router, namedMiddlewares, collectedRoutes) {
|
|
|
638
638
|
return routes;
|
|
639
639
|
}
|
|
640
640
|
function registerRoute(app, name, routeDef, namedMiddlewares) {
|
|
641
|
-
const { method, path, input, middlewares = [], skipMiddlewares, handler } = routeDef;
|
|
641
|
+
const { method, path, input, interceptor, middlewares = [], skipMiddlewares, handler } = routeDef;
|
|
642
642
|
if (!method || !path) {
|
|
643
643
|
logger.warn(`Route "${name}" is missing method or path - skipping`, {
|
|
644
644
|
method,
|
|
@@ -647,7 +647,7 @@ function registerRoute(app, name, routeDef, namedMiddlewares) {
|
|
|
647
647
|
return null;
|
|
648
648
|
}
|
|
649
649
|
const wrappedHandler = async (c) => {
|
|
650
|
-
const { context, responseMeta } = await createRouteBuilderContext(c, input || {});
|
|
650
|
+
const { context, responseMeta } = await createRouteBuilderContext(c, input || {}, interceptor);
|
|
651
651
|
const result = await handler(context);
|
|
652
652
|
if (result instanceof Response) {
|
|
653
653
|
return result;
|
|
@@ -683,6 +683,8 @@ function registerRoute(app, name, routeDef, namedMiddlewares) {
|
|
|
683
683
|
logger.debug(`\u23ED\uFE0F Skipping middleware '${middleware.name}' for route: ${method} ${path}`, { name });
|
|
684
684
|
} else if (autoSkips.has(middleware.name)) {
|
|
685
685
|
logger.debug(`\u23ED\uFE0F Auto-skipping middleware '${middleware.name}' for route: ${method} ${path}`, { name });
|
|
686
|
+
} else if (middleware.name && registeredNames.has(middleware.name)) {
|
|
687
|
+
logger.debug(`\u{1F504} Skipping duplicate middleware '${middleware.name}' for route: ${method} ${path}`, { name });
|
|
686
688
|
} else {
|
|
687
689
|
allMiddlewares.push(middleware.handler);
|
|
688
690
|
registeredNames.add(middleware.name);
|
|
@@ -714,21 +716,27 @@ function registerRoute(app, name, routeDef, namedMiddlewares) {
|
|
|
714
716
|
logger.debug(`Registered route: ${method} ${path}`, { name });
|
|
715
717
|
return { method, path, name };
|
|
716
718
|
}
|
|
717
|
-
|
|
719
|
+
function methodCarriesBody(method) {
|
|
720
|
+
return method !== "GET" && method !== "HEAD";
|
|
721
|
+
}
|
|
722
|
+
async function createRouteBuilderContext(c, input, interceptor) {
|
|
718
723
|
const params = validateField(input.params, c.req.param(), "path parameters");
|
|
719
724
|
const query = validateField(input.query, extractQueryParams(c), "query parameters");
|
|
720
725
|
const headers = validateField(input.headers, extractHeaders(c), "headers");
|
|
721
726
|
const cookies = validateField(input.cookies, extractCookies(c), "cookies");
|
|
722
727
|
let body = {};
|
|
723
728
|
let formData = {};
|
|
724
|
-
|
|
729
|
+
const injected = methodCarriesBody(c.req.method) ? interceptor : void 0;
|
|
730
|
+
const expectsBody = input.body ?? injected?.body;
|
|
731
|
+
const expectsFormData = input.formData ?? injected?.formData;
|
|
732
|
+
if (expectsBody || expectsFormData) {
|
|
725
733
|
const contentType = c.req.header("content-type") || "";
|
|
726
|
-
if (contentType.includes("multipart/form-data") &&
|
|
734
|
+
if (contentType.includes("multipart/form-data") && expectsFormData) {
|
|
727
735
|
const rawFormData = await parseFormData(c);
|
|
728
|
-
formData = validateFormData(input.formData, rawFormData, "form data");
|
|
729
|
-
} else if (
|
|
736
|
+
formData = input.formData ? validateFormData(input.formData, rawFormData, "form data") : rawFormData;
|
|
737
|
+
} else if (expectsBody) {
|
|
730
738
|
const rawBody = await parseJsonBody(c);
|
|
731
|
-
body = validateField(input.body, rawBody, "request body");
|
|
739
|
+
body = input.body ? validateField(input.body, rawBody, "request body") : rawBody;
|
|
732
740
|
}
|
|
733
741
|
}
|
|
734
742
|
let cachedData = null;
|