@spfn/core 0.1.0-alpha.88 → 0.2.0-beta.2
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 +1046 -384
- package/dist/boss-D-fGtVgM.d.ts +187 -0
- package/dist/cache/index.d.ts +13 -33
- package/dist/cache/index.js +14 -703
- package/dist/cache/index.js.map +1 -1
- package/dist/codegen/index.d.ts +167 -17
- package/dist/codegen/index.js +76 -1419
- package/dist/codegen/index.js.map +1 -1
- package/dist/config/index.d.ts +1191 -0
- package/dist/config/index.js +264 -0
- package/dist/config/index.js.map +1 -0
- package/dist/db/index.d.ts +728 -59
- package/dist/db/index.js +1028 -1225
- package/dist/db/index.js.map +1 -1
- package/dist/env/index.d.ts +579 -308
- package/dist/env/index.js +438 -930
- package/dist/env/index.js.map +1 -1
- package/dist/errors/index.d.ts +417 -29
- package/dist/errors/index.js +359 -98
- package/dist/errors/index.js.map +1 -1
- package/dist/event/index.d.ts +108 -0
- package/dist/event/index.js +122 -0
- package/dist/event/index.js.map +1 -0
- package/dist/job/index.d.ts +172 -0
- package/dist/job/index.js +361 -0
- package/dist/job/index.js.map +1 -0
- package/dist/logger/index.d.ts +20 -79
- package/dist/logger/index.js +82 -387
- package/dist/logger/index.js.map +1 -1
- package/dist/middleware/index.d.ts +2 -11
- package/dist/middleware/index.js +49 -703
- package/dist/middleware/index.js.map +1 -1
- package/dist/nextjs/index.d.ts +120 -0
- package/dist/nextjs/index.js +416 -0
- package/dist/nextjs/index.js.map +1 -0
- package/dist/{client/nextjs/index.d.ts → nextjs/server.d.ts} +288 -262
- package/dist/nextjs/server.js +568 -0
- package/dist/nextjs/server.js.map +1 -0
- package/dist/route/index.d.ts +686 -25
- package/dist/route/index.js +440 -1287
- package/dist/route/index.js.map +1 -1
- package/dist/route/types.d.ts +38 -0
- package/dist/route/types.js +3 -0
- package/dist/route/types.js.map +1 -0
- package/dist/server/index.d.ts +201 -67
- package/dist/server/index.js +921 -3182
- package/dist/server/index.js.map +1 -1
- package/dist/types-BGl4QL1w.d.ts +77 -0
- package/dist/types-DRG2XMTR.d.ts +157 -0
- package/package.json +52 -47
- package/dist/auto-loader-JFaZ9gON.d.ts +0 -80
- package/dist/client/index.d.ts +0 -358
- package/dist/client/index.js +0 -357
- package/dist/client/index.js.map +0 -1
- package/dist/client/nextjs/index.js +0 -371
- package/dist/client/nextjs/index.js.map +0 -1
- package/dist/codegen/generators/index.d.ts +0 -19
- package/dist/codegen/generators/index.js +0 -1404
- package/dist/codegen/generators/index.js.map +0 -1
- package/dist/database-errors-BNNmLTJE.d.ts +0 -86
- package/dist/events/index.d.ts +0 -183
- package/dist/events/index.js +0 -77
- package/dist/events/index.js.map +0 -1
- package/dist/index-DHiAqhKv.d.ts +0 -101
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -3674
- package/dist/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -121
- package/dist/types/index.js +0 -38
- package/dist/types/index.js.map +0 -1
- package/dist/types-BXibIEyj.d.ts +0 -60
package/dist/types/index.d.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
-
import { TSchema } from '@sinclair/typebox';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Standard error response format
|
|
6
|
-
*
|
|
7
|
-
* Used by ErrorHandler middleware for all error responses.
|
|
8
|
-
* Compatible with ApiResponse pattern for consistent API responses.
|
|
9
|
-
*/
|
|
10
|
-
interface ErrorResponse {
|
|
11
|
-
success: false;
|
|
12
|
-
error: {
|
|
13
|
-
message: string;
|
|
14
|
-
type: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
stack?: string;
|
|
17
|
-
details?: any;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Success response wrapper
|
|
22
|
-
*/
|
|
23
|
-
interface ApiSuccessResponse<T = any> {
|
|
24
|
-
success: true;
|
|
25
|
-
data: T;
|
|
26
|
-
meta?: {
|
|
27
|
-
timestamp?: string;
|
|
28
|
-
requestId?: string;
|
|
29
|
-
pagination?: {
|
|
30
|
-
page: number;
|
|
31
|
-
limit: number;
|
|
32
|
-
total: number;
|
|
33
|
-
totalPages: number;
|
|
34
|
-
};
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Error response type (alias for ErrorResponse)
|
|
40
|
-
*/
|
|
41
|
-
type ApiErrorResponse = ErrorResponse;
|
|
42
|
-
/**
|
|
43
|
-
* Unified API response type
|
|
44
|
-
*/
|
|
45
|
-
type ApiResponse<T = any> = ApiSuccessResponse<T> | ApiErrorResponse;
|
|
46
|
-
/**
|
|
47
|
-
* Creates a TypeBox schema for ApiSuccessResponse<T>
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```ts
|
|
51
|
-
* const UserSchema = Type.Object({
|
|
52
|
-
* id: Type.String(),
|
|
53
|
-
* name: Type.String(),
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* const contract = {
|
|
57
|
-
* response: ApiSuccessSchema(UserSchema),
|
|
58
|
-
* };
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare function ApiSuccessSchema<T extends TSchema>(dataSchema: T): _sinclair_typebox.TObject<{
|
|
62
|
-
success: _sinclair_typebox.TLiteral<true>;
|
|
63
|
-
data: T;
|
|
64
|
-
meta: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
65
|
-
timestamp: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
66
|
-
requestId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
67
|
-
pagination: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
68
|
-
page: _sinclair_typebox.TNumber;
|
|
69
|
-
limit: _sinclair_typebox.TNumber;
|
|
70
|
-
total: _sinclair_typebox.TNumber;
|
|
71
|
-
totalPages: _sinclair_typebox.TNumber;
|
|
72
|
-
}>>;
|
|
73
|
-
}>>;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Creates a TypeBox schema for ApiErrorResponse
|
|
77
|
-
*/
|
|
78
|
-
declare function ApiErrorSchema(): _sinclair_typebox.TObject<{
|
|
79
|
-
success: _sinclair_typebox.TLiteral<false>;
|
|
80
|
-
error: _sinclair_typebox.TObject<{
|
|
81
|
-
message: _sinclair_typebox.TString;
|
|
82
|
-
type: _sinclair_typebox.TString;
|
|
83
|
-
statusCode: _sinclair_typebox.TNumber;
|
|
84
|
-
stack: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
85
|
-
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
86
|
-
}>;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* Creates a TypeBox schema for ApiSuccessResponse<T>
|
|
90
|
-
*
|
|
91
|
-
* Use this in your route contract's response field for standardized responses.
|
|
92
|
-
* Note: ContractClient throws ApiClientError on failure, so only success type is needed.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const contract = {
|
|
97
|
-
* method: 'GET',
|
|
98
|
-
* path: '/users/:id',
|
|
99
|
-
* response: ApiResponseSchema(Type.Object({
|
|
100
|
-
* id: Type.String(),
|
|
101
|
-
* name: Type.String(),
|
|
102
|
-
* })),
|
|
103
|
-
* };
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
declare function ApiResponseSchema<T extends TSchema>(dataSchema: T): _sinclair_typebox.TObject<{
|
|
107
|
-
success: _sinclair_typebox.TLiteral<true>;
|
|
108
|
-
data: T;
|
|
109
|
-
meta: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
110
|
-
timestamp: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
111
|
-
requestId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
112
|
-
pagination: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
113
|
-
page: _sinclair_typebox.TNumber;
|
|
114
|
-
limit: _sinclair_typebox.TNumber;
|
|
115
|
-
total: _sinclair_typebox.TNumber;
|
|
116
|
-
totalPages: _sinclair_typebox.TNumber;
|
|
117
|
-
}>>;
|
|
118
|
-
}>>;
|
|
119
|
-
}>;
|
|
120
|
-
|
|
121
|
-
export { type ApiErrorResponse, ApiErrorSchema, type ApiResponse, ApiResponseSchema, type ApiSuccessResponse, ApiSuccessSchema, type ErrorResponse };
|
package/dist/types/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox';
|
|
2
|
-
|
|
3
|
-
// src/types/api-response.ts
|
|
4
|
-
function ApiSuccessSchema(dataSchema) {
|
|
5
|
-
return Type.Object({
|
|
6
|
-
success: Type.Literal(true),
|
|
7
|
-
data: dataSchema,
|
|
8
|
-
meta: Type.Optional(Type.Object({
|
|
9
|
-
timestamp: Type.Optional(Type.String()),
|
|
10
|
-
requestId: Type.Optional(Type.String()),
|
|
11
|
-
pagination: Type.Optional(Type.Object({
|
|
12
|
-
page: Type.Number(),
|
|
13
|
-
limit: Type.Number(),
|
|
14
|
-
total: Type.Number(),
|
|
15
|
-
totalPages: Type.Number()
|
|
16
|
-
}))
|
|
17
|
-
}))
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function ApiErrorSchema() {
|
|
21
|
-
return Type.Object({
|
|
22
|
-
success: Type.Literal(false),
|
|
23
|
-
error: Type.Object({
|
|
24
|
-
message: Type.String(),
|
|
25
|
-
type: Type.String(),
|
|
26
|
-
statusCode: Type.Number(),
|
|
27
|
-
stack: Type.Optional(Type.String()),
|
|
28
|
-
details: Type.Optional(Type.Any())
|
|
29
|
-
})
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function ApiResponseSchema(dataSchema) {
|
|
33
|
-
return ApiSuccessSchema(dataSchema);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { ApiErrorSchema, ApiResponseSchema, ApiSuccessSchema };
|
|
37
|
-
//# sourceMappingURL=index.js.map
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/api-response.ts"],"names":[],"mappings":";;;AAiFO,SAAS,iBAAoC,UAAA,EACpD;AACI,EAAA,OAAO,KAAK,MAAA,CAAO;AAAA,IACf,OAAA,EAAS,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA;AAAA,IAC1B,IAAA,EAAM,UAAA;AAAA,IACN,IAAA,EAAM,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,MAAA,CAAO;AAAA,MAC5B,SAAA,EAAW,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AAAA,MACtC,SAAA,EAAW,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AAAA,MACtC,UAAA,EAAY,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,MAAA,CAAO;AAAA,QAClC,IAAA,EAAM,KAAK,MAAA,EAAO;AAAA,QAClB,KAAA,EAAO,KAAK,MAAA,EAAO;AAAA,QACnB,KAAA,EAAO,KAAK,MAAA,EAAO;AAAA,QACnB,UAAA,EAAY,KAAK,MAAA;AAAO,OAC3B,CAAC;AAAA,KACL,CAAC;AAAA,GACL,CAAA;AACL;AAKO,SAAS,cAAA,GAChB;AACI,EAAA,OAAO,KAAK,MAAA,CAAO;AAAA,IACf,OAAA,EAAS,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAAA,IAC3B,KAAA,EAAO,KAAK,MAAA,CAAO;AAAA,MACf,OAAA,EAAS,KAAK,MAAA,EAAO;AAAA,MACrB,IAAA,EAAM,KAAK,MAAA,EAAO;AAAA,MAClB,UAAA,EAAY,KAAK,MAAA,EAAO;AAAA,MACxB,KAAA,EAAO,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AAAA,MAClC,OAAA,EAAS,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAK;AAAA,KACpC;AAAA,GACJ,CAAA;AACL;AAoBO,SAAS,kBAAqC,UAAA,EACrD;AACI,EAAA,OAAO,iBAAiB,UAAU,CAAA;AACtC","file":"index.js","sourcesContent":["/**\n * Standard API Response Types & Schemas\n *\n * Pure TypeBox schemas and type definitions for API responses.\n * Can be used in both server and client code.\n */\n\nimport type { TSchema } from '@sinclair/typebox';\nimport { Type } from '@sinclair/typebox';\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\n/**\n * Standard error response format\n *\n * Used by ErrorHandler middleware for all error responses.\n * Compatible with ApiResponse pattern for consistent API responses.\n */\nexport interface ErrorResponse\n{\n success: false;\n error: {\n message: string;\n type: string;\n statusCode: number;\n stack?: string;\n details?: any;\n };\n}\n\n/**\n * Success response wrapper\n */\nexport interface ApiSuccessResponse<T = any>\n{\n success: true;\n data: T;\n meta?: {\n timestamp?: string;\n requestId?: string;\n pagination?: {\n page: number;\n limit: number;\n total: number;\n totalPages: number;\n };\n [key: string]: any;\n };\n}\n\n/**\n * Error response type (alias for ErrorResponse)\n */\nexport type ApiErrorResponse = ErrorResponse;\n\n/**\n * Unified API response type\n */\nexport type ApiResponse<T = any> = ApiSuccessResponse<T> | ApiErrorResponse;\n\n// ============================================================================\n// TypeBox Schema Helpers\n// ============================================================================\n\n/**\n * Creates a TypeBox schema for ApiSuccessResponse<T>\n *\n * @example\n * ```ts\n * const UserSchema = Type.Object({\n * id: Type.String(),\n * name: Type.String(),\n * });\n *\n * const contract = {\n * response: ApiSuccessSchema(UserSchema),\n * };\n * ```\n */\nexport function ApiSuccessSchema<T extends TSchema>(dataSchema: T)\n{\n return Type.Object({\n success: Type.Literal(true),\n data: dataSchema,\n meta: Type.Optional(Type.Object({\n timestamp: Type.Optional(Type.String()),\n requestId: Type.Optional(Type.String()),\n pagination: Type.Optional(Type.Object({\n page: Type.Number(),\n limit: Type.Number(),\n total: Type.Number(),\n totalPages: Type.Number(),\n })),\n })),\n });\n}\n\n/**\n * Creates a TypeBox schema for ApiErrorResponse\n */\nexport function ApiErrorSchema()\n{\n return Type.Object({\n success: Type.Literal(false),\n error: Type.Object({\n message: Type.String(),\n type: Type.String(),\n statusCode: Type.Number(),\n stack: Type.Optional(Type.String()),\n details: Type.Optional(Type.Any()),\n }),\n });\n}\n\n/**\n * Creates a TypeBox schema for ApiSuccessResponse<T>\n *\n * Use this in your route contract's response field for standardized responses.\n * Note: ContractClient throws ApiClientError on failure, so only success type is needed.\n *\n * @example\n * ```ts\n * const contract = {\n * method: 'GET',\n * path: '/users/:id',\n * response: ApiResponseSchema(Type.Object({\n * id: Type.String(),\n * name: Type.String(),\n * })),\n * };\n * ```\n */\nexport function ApiResponseSchema<T extends TSchema>(dataSchema: T)\n{\n return ApiSuccessSchema(dataSchema);\n}\n"]}
|
package/dist/types-BXibIEyj.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Context } from 'hono';
|
|
2
|
-
import { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
3
|
-
import { TSchema, Static } from '@sinclair/typebox';
|
|
4
|
-
import { ApiSuccessResponse } from './types/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* File-based Routing System Type Definitions
|
|
8
|
-
*/
|
|
9
|
-
type HeaderRecord = Record<string, string | string[]>;
|
|
10
|
-
type RouteMeta = {
|
|
11
|
-
public?: boolean;
|
|
12
|
-
skipMiddlewares?: string[];
|
|
13
|
-
tags?: string[];
|
|
14
|
-
description?: string;
|
|
15
|
-
deprecated?: boolean;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Route Contract: TypeBox-based type-safe route definition
|
|
19
|
-
*
|
|
20
|
-
* Defines the shape of request/response for a route endpoint
|
|
21
|
-
*/
|
|
22
|
-
type RouteContract = {
|
|
23
|
-
method: HttpMethod;
|
|
24
|
-
path: string;
|
|
25
|
-
params?: TSchema;
|
|
26
|
-
query?: TSchema;
|
|
27
|
-
body?: TSchema;
|
|
28
|
-
response: TSchema;
|
|
29
|
-
meta?: RouteMeta;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Infer types from RouteContract
|
|
33
|
-
*
|
|
34
|
-
* Extracts TypeScript types from TypeBox schemas
|
|
35
|
-
*/
|
|
36
|
-
type InferContract<TContract extends RouteContract> = {
|
|
37
|
-
params: TContract['params'] extends TSchema ? Static<TContract['params']> : Record<string, never>;
|
|
38
|
-
query: TContract['query'] extends TSchema ? Static<TContract['query']> : Record<string, never>;
|
|
39
|
-
body: TContract['body'] extends TSchema ? Static<TContract['body']> : Record<string, never>;
|
|
40
|
-
response: TContract['response'] extends TSchema ? Static<TContract['response']> : unknown;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* RouteContext: Route Handler Dedicated Context
|
|
44
|
-
*
|
|
45
|
-
* Generic version with contract-based type inference
|
|
46
|
-
*/
|
|
47
|
-
type RouteContext<TContract extends RouteContract = any> = {
|
|
48
|
-
params: InferContract<TContract>['params'];
|
|
49
|
-
query: InferContract<TContract>['query'];
|
|
50
|
-
data(): Promise<InferContract<TContract>['body']>;
|
|
51
|
-
json(data: InferContract<TContract>['response'], status?: ContentfulStatusCode, headers?: HeaderRecord): Response;
|
|
52
|
-
success<T>(data: T, meta?: ApiSuccessResponse<T>['meta'], status?: number): Response;
|
|
53
|
-
paginated<T>(data: T[], page: number, limit: number, total: number): Response;
|
|
54
|
-
raw: Context;
|
|
55
|
-
};
|
|
56
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
57
|
-
type RouteHandler<TContract extends RouteContract = any> = (c: RouteContext<TContract>) => Response | Promise<Response>;
|
|
58
|
-
declare function isHttpMethod(value: unknown): value is HttpMethod;
|
|
59
|
-
|
|
60
|
-
export { type HttpMethod as H, type InferContract as I, type RouteContext as R, type RouteContract as a, type RouteHandler as b, type HeaderRecord as c, type RouteMeta as d, isHttpMethod as i };
|