arri 0.0.13 → 0.0.15
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/dist/chunks/index.cjs +19 -19
- package/dist/chunks/index.mjs +19 -19
- package/dist/chunks/index2.cjs +18 -18
- package/dist/chunks/index2.mjs +18 -18
- package/dist/chunks/index3.cjs +1670 -8702
- package/dist/chunks/index3.mjs +1667 -8687
- package/dist/chunks/index4.cjs +256 -0
- package/dist/chunks/index4.mjs +247 -0
- package/dist/chunks/index5.cjs +8854 -0
- package/dist/chunks/index5.mjs +8832 -0
- package/dist/cli.cjs +21663 -19012
- package/dist/cli.mjs +21641 -18993
- package/dist/codegen.cjs +8 -8
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.mjs +9 -9
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.d31eb2d5.cjs → arri.9717f131.cjs} +16 -28
- package/dist/shared/{arri.2ff96786.d.cts → arri.bb7e9a4e.d.cts} +55 -60
- package/dist/shared/{arri.2ff96786.d.mts → arri.bb7e9a4e.d.mts} +55 -60
- package/dist/shared/{arri.2ff96786.d.ts → arri.bb7e9a4e.d.ts} +55 -60
- package/dist/shared/{arri.3605a96c.cjs → arri.bfebed73.cjs} +534 -619
- package/dist/shared/{arri.b0ab6d2f.mjs → arri.dab1f9df.mjs} +531 -617
- package/dist/shared/{arri.a90e77aa.mjs → arri.e335c10b.mjs} +10 -22
- package/package.json +6 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TObject,
|
|
2
|
-
import {
|
|
1
|
+
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
+
import { Router, H3Event, App, AppOptions } from 'h3';
|
|
3
3
|
|
|
4
4
|
interface ApplicationDefinition {
|
|
5
5
|
schemaVersion: "0.0.1";
|
|
@@ -46,42 +46,6 @@ interface JsonSchemaArray {
|
|
|
46
46
|
items: JsonSchemaType;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
interface ArriProcedureBase {
|
|
50
|
-
method: HttpMethod;
|
|
51
|
-
params?: any;
|
|
52
|
-
response?: any;
|
|
53
|
-
handler: (context: any) => any;
|
|
54
|
-
postHandler?: (context: any) => any;
|
|
55
|
-
}
|
|
56
|
-
interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>> {
|
|
57
|
-
description?: string;
|
|
58
|
-
method?: HttpMethod;
|
|
59
|
-
params: TParams;
|
|
60
|
-
response: TResponse;
|
|
61
|
-
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
|
|
62
|
-
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
|
|
63
|
-
}
|
|
64
|
-
interface HandlerContext {
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
event: H3Event;
|
|
67
|
-
}
|
|
68
|
-
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
69
|
-
params: TParams;
|
|
70
|
-
}
|
|
71
|
-
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
72
|
-
response: TResponse;
|
|
73
|
-
}
|
|
74
|
-
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
|
|
75
|
-
type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
|
|
76
|
-
declare function isRpc(input: any): input is ArriProcedure<any, any, any>;
|
|
77
|
-
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined, TFinalResponse extends TResponse extends TObject ? Static<TObject> : Static<TVoid> = any>(config: ArriProcedure<TParams, TResponse, TFinalResponse>): ArriProcedure<TParams, TResponse, TFinalResponse>;
|
|
78
|
-
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition;
|
|
79
|
-
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
80
|
-
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
|
|
81
|
-
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition["params"];
|
|
82
|
-
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
|
|
83
|
-
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any, any>, middleware: Middleware[]): void;
|
|
84
|
-
|
|
85
49
|
interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any> {
|
|
86
50
|
path: TPath;
|
|
87
51
|
method: TMethod;
|
|
@@ -108,7 +72,43 @@ interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery
|
|
|
108
72
|
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>) => any;
|
|
109
73
|
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
110
74
|
|
|
111
|
-
interface
|
|
75
|
+
interface ArriProcedureBase {
|
|
76
|
+
method: HttpMethod;
|
|
77
|
+
params?: any;
|
|
78
|
+
response?: any;
|
|
79
|
+
handler: (context: any) => any;
|
|
80
|
+
postHandler?: (context: any) => any;
|
|
81
|
+
}
|
|
82
|
+
interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
|
|
83
|
+
description?: string;
|
|
84
|
+
method?: HttpMethod;
|
|
85
|
+
params: TParams;
|
|
86
|
+
response: TResponse;
|
|
87
|
+
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
88
|
+
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
89
|
+
}
|
|
90
|
+
interface HandlerContext {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
event: H3Event;
|
|
93
|
+
}
|
|
94
|
+
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
95
|
+
params: TParams;
|
|
96
|
+
}
|
|
97
|
+
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
98
|
+
response: TResponse;
|
|
99
|
+
}
|
|
100
|
+
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
|
|
101
|
+
type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
|
|
102
|
+
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
103
|
+
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
104
|
+
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDefinition;
|
|
105
|
+
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
106
|
+
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
107
|
+
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
|
|
108
|
+
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
109
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
110
|
+
|
|
111
|
+
interface ArriOptions extends AppOptions {
|
|
112
112
|
rpcRoutePrefix?: string;
|
|
113
113
|
/**
|
|
114
114
|
* Defaults to /__definitions
|
|
@@ -117,32 +117,27 @@ interface ArriServerOptions extends AppOptions {
|
|
|
117
117
|
rpcDefinitionPath?: string;
|
|
118
118
|
appDescription?: string;
|
|
119
119
|
}
|
|
120
|
-
declare
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
121
|
+
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
122
|
+
declare class Arri {
|
|
123
|
+
__isArri__: boolean;
|
|
124
|
+
private readonly h3App;
|
|
125
|
+
private readonly h3Router;
|
|
126
|
+
private readonly rpcDefinitionPath;
|
|
127
|
+
private readonly rpcRoutePrefix;
|
|
128
|
+
private procedures;
|
|
129
|
+
private models;
|
|
130
|
+
private readonly middlewares;
|
|
131
|
+
private readonly appDescription;
|
|
132
|
+
constructor(opts?: ArriOptions);
|
|
130
133
|
registerMiddleware(middleware: Middleware): void;
|
|
131
|
-
|
|
132
|
-
* Statically register routes to the server router
|
|
133
|
-
* Routes will not be served until this is done
|
|
134
|
-
*/
|
|
135
|
-
initializeRoutes(): void;
|
|
136
|
-
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>>(name: string, procedure: ArriProcedure<TParams, TResponse, TFinalResponse>): void;
|
|
134
|
+
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
137
135
|
registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
|
|
138
136
|
getAppDefinition(): ApplicationDefinition;
|
|
139
|
-
|
|
140
|
-
interface ArriService {
|
|
141
|
-
id: string;
|
|
142
|
-
procedures: Record<string, any>;
|
|
137
|
+
getH3Instance(): App;
|
|
143
138
|
}
|
|
144
139
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
145
140
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
146
141
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
147
142
|
|
|
148
|
-
export {
|
|
143
|
+
export { Arri as A, type ApplicationDefinition as B, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, HttpMethodValues as H, type JsonSchemaObject as J, type Middleware as M, type ProcedureDefinition as P, type RpcHandlerContext as R, type ServiceDefinition as S, DEV_DEFINITION_ENDPOINT as a, type HttpMethod as b, type ArriProcedureBase as c, type ArriProcedure as d, type HandlerContext as e, type RpcPostHandlerContext as f, type ArriProcedureHandler as g, type ArriProcedurePostHandler as h, isHttpMethod as i, isRpc as j, defineRpc as k, createRpcDefinition as l, getRpcPath as m, getRpcParamName as n, getRpcParamDefinition as o, getRpcResponseName as p, type ArriRoute as q, registerRpc as r, defineRoute as s, defineMiddleware as t, type ExtractParams as u, type ArriRouteHandler as v, type RouteHandlerContext as w, type RoutePostHandlerContext as x, type ArriRoutePostHandler as y, registerRoute as z };
|