arri 0.0.38 → 0.0.40

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.
@@ -1,205 +0,0 @@
1
- import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
3
-
4
- interface ApplicationDef {
5
- arriSchemaVersion: "0.0.1";
6
- info?: {
7
- title?: string;
8
- description?: string;
9
- version?: string;
10
- };
11
- externalDocs?: {
12
- description?: string;
13
- url: string;
14
- };
15
- procedures: Record<string, ProcedureDef>;
16
- models: Record<string, JsonSchemaObject>;
17
- errors: Omit<TObject, symbol>;
18
- }
19
- declare function normalizeWhitespace(input: string): string;
20
- interface ProcedureDef {
21
- path: string;
22
- description?: string;
23
- method: HttpMethod;
24
- params: string | undefined;
25
- response: string | undefined;
26
- }
27
- declare function isProcedureDef(input: any): input is ProcedureDef;
28
- interface ServiceDef {
29
- [key: string]: ProcedureDef | ServiceDef;
30
- }
31
- declare function isServiceDef(input: any): input is ServiceDef;
32
- declare function isApplicationDef(input: any): input is ApplicationDef;
33
- declare function unflattenObject(data: Record<string, any>): any;
34
- declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
- declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
- declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
37
- declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
38
- declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
- declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
40
- type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
- type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
42
- interface JsonSchemaScalarType {
43
- title?: string;
44
- description?: string;
45
- type: (typeof JsonSchemaScalarTypeValues)[number];
46
- }
47
- declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
48
- interface JsonSchemaNullType {
49
- type: (typeof JsonSchemaNullTypeValues)[number];
50
- }
51
- declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
52
- type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray | JsonSchemaRecord;
53
- interface JsonSchemaObject {
54
- $id?: string;
55
- title?: string;
56
- description?: string;
57
- type: "object";
58
- properties: Record<string, JsonSchemaType>;
59
- required?: string[];
60
- }
61
- declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
62
- interface JsonSchemaRecord {
63
- $id?: string;
64
- title?: string;
65
- type: "object";
66
- patternProperties: Record<string, JsonSchemaType>;
67
- }
68
- declare const isJsonSchemaRecord: (input: any) => input is JsonSchemaRecord;
69
- interface JsonSchemaArray {
70
- $id?: string;
71
- title?: string;
72
- description?: string;
73
- type: "array";
74
- items: JsonSchemaType;
75
- }
76
- declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
77
- interface JsonSchemaUint8Array {
78
- type: "Uint8Array";
79
- }
80
- interface JsonSchemaEnum {
81
- anyOf: Array<{
82
- type: "string";
83
- const: string;
84
- }> | Array<{
85
- type: "number";
86
- const: number;
87
- }> | Array<{
88
- type: "integer";
89
- const: number;
90
- }>;
91
- }
92
- declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
93
-
94
- 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> {
95
- path: TPath;
96
- method: TMethod;
97
- query?: TQuery;
98
- body?: TBody;
99
- response?: TResponse;
100
- handler: ArriRouteHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TSchema ? Static<TBody> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
101
- postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
102
- }
103
- declare function defineRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = any, TBody extends TSchema | undefined = any, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(config: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>;
104
- type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
105
- declare const defineMiddleware: (middleware: Middleware) => Middleware;
106
- type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
107
- type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
108
- type ArriRouteHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = any> = (context: RouteHandlerContext<ExtractParams<TPath>, TQuery, TBody>, event: H3Event) => TResponse extends undefined ? void | Promise<void> : TResponse | Promise<TResponse>;
109
- interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
110
- type: "route";
111
- params: TParams;
112
- query: TQuery;
113
- body: TBody;
114
- }
115
- interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
116
- response: TResponse;
117
- }
118
- type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>, event: H3Event) => any;
119
- declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string, opts?: ArriOptions): void;
120
-
121
- interface ArriProcedureBase {
122
- method: HttpMethod;
123
- params?: any;
124
- response?: any;
125
- handler: (context: any) => any;
126
- postHandler?: (context: any) => any;
127
- }
128
- interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
129
- description?: string;
130
- method?: HttpMethod;
131
- params: TParams;
132
- response: TResponse;
133
- handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
134
- postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
135
- }
136
- type HandlerContext = Record<string, any>;
137
- interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
138
- type: "procedure";
139
- params: TParams;
140
- }
141
- interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
142
- response: TResponse;
143
- }
144
- type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: H3Event) => TResponse | Promise<TResponse>;
145
- type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: H3Event) => any;
146
- declare function isRpc(input: any): input is ArriProcedure<any, any>;
147
- declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
148
- declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
149
- declare function getRpcPath(rpcName: string, prefix?: string): string;
150
- declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
151
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
152
- declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
153
- declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
154
-
155
- declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
156
- declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
157
- declare class Arri {
158
- __isArri__: boolean;
159
- private readonly h3App;
160
- private readonly h3Router;
161
- private readonly rpcDefinitionPath;
162
- private readonly rpcRoutePrefix;
163
- appInfo: ApplicationDef["info"];
164
- private procedures;
165
- private models;
166
- private readonly middlewares;
167
- private readonly onAfterResponse;
168
- private readonly onBeforeResponse;
169
- private readonly onError;
170
- constructor(opts?: ArriOptions);
171
- registerMiddleware(middleware: Middleware): void;
172
- registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
- 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;
174
- getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
176
- }
177
- interface ArriOptions {
178
- debug?: boolean;
179
- /**
180
- * Metadata to display in the __definition.json file
181
- */
182
- appInfo?: ApplicationDef["info"];
183
- rpcRoutePrefix?: string;
184
- /**
185
- * Defaults to /__definitions
186
- * This parameters also takes the rpcRoutePrefix option into account
187
- */
188
- rpcDefinitionPath?: string;
189
- onRequest?: (event: H3Event) => void | Promise<void>;
190
- onAfterResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
191
- onBeforeResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
192
- onError?: (error: H3Error, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event) => void | Promise<void>;
193
- }
194
- declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
195
- type HttpMethod = (typeof HttpMethodValues)[number];
196
- declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
197
-
198
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
199
- generator: (def: ApplicationDef) => any;
200
- options: TOptions;
201
- }
202
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
-
205
- export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,205 +0,0 @@
1
- import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
3
-
4
- interface ApplicationDef {
5
- arriSchemaVersion: "0.0.1";
6
- info?: {
7
- title?: string;
8
- description?: string;
9
- version?: string;
10
- };
11
- externalDocs?: {
12
- description?: string;
13
- url: string;
14
- };
15
- procedures: Record<string, ProcedureDef>;
16
- models: Record<string, JsonSchemaObject>;
17
- errors: Omit<TObject, symbol>;
18
- }
19
- declare function normalizeWhitespace(input: string): string;
20
- interface ProcedureDef {
21
- path: string;
22
- description?: string;
23
- method: HttpMethod;
24
- params: string | undefined;
25
- response: string | undefined;
26
- }
27
- declare function isProcedureDef(input: any): input is ProcedureDef;
28
- interface ServiceDef {
29
- [key: string]: ProcedureDef | ServiceDef;
30
- }
31
- declare function isServiceDef(input: any): input is ServiceDef;
32
- declare function isApplicationDef(input: any): input is ApplicationDef;
33
- declare function unflattenObject(data: Record<string, any>): any;
34
- declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
- declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
- declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
37
- declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
38
- declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
- declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
40
- type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
- type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
42
- interface JsonSchemaScalarType {
43
- title?: string;
44
- description?: string;
45
- type: (typeof JsonSchemaScalarTypeValues)[number];
46
- }
47
- declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
48
- interface JsonSchemaNullType {
49
- type: (typeof JsonSchemaNullTypeValues)[number];
50
- }
51
- declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
52
- type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray | JsonSchemaRecord;
53
- interface JsonSchemaObject {
54
- $id?: string;
55
- title?: string;
56
- description?: string;
57
- type: "object";
58
- properties: Record<string, JsonSchemaType>;
59
- required?: string[];
60
- }
61
- declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
62
- interface JsonSchemaRecord {
63
- $id?: string;
64
- title?: string;
65
- type: "object";
66
- patternProperties: Record<string, JsonSchemaType>;
67
- }
68
- declare const isJsonSchemaRecord: (input: any) => input is JsonSchemaRecord;
69
- interface JsonSchemaArray {
70
- $id?: string;
71
- title?: string;
72
- description?: string;
73
- type: "array";
74
- items: JsonSchemaType;
75
- }
76
- declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
77
- interface JsonSchemaUint8Array {
78
- type: "Uint8Array";
79
- }
80
- interface JsonSchemaEnum {
81
- anyOf: Array<{
82
- type: "string";
83
- const: string;
84
- }> | Array<{
85
- type: "number";
86
- const: number;
87
- }> | Array<{
88
- type: "integer";
89
- const: number;
90
- }>;
91
- }
92
- declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
93
-
94
- 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> {
95
- path: TPath;
96
- method: TMethod;
97
- query?: TQuery;
98
- body?: TBody;
99
- response?: TResponse;
100
- handler: ArriRouteHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TSchema ? Static<TBody> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
101
- postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
102
- }
103
- declare function defineRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = any, TBody extends TSchema | undefined = any, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(config: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>;
104
- type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
105
- declare const defineMiddleware: (middleware: Middleware) => Middleware;
106
- type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
107
- type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
108
- type ArriRouteHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = any> = (context: RouteHandlerContext<ExtractParams<TPath>, TQuery, TBody>, event: H3Event) => TResponse extends undefined ? void | Promise<void> : TResponse | Promise<TResponse>;
109
- interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
110
- type: "route";
111
- params: TParams;
112
- query: TQuery;
113
- body: TBody;
114
- }
115
- interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
116
- response: TResponse;
117
- }
118
- type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>, event: H3Event) => any;
119
- declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string, opts?: ArriOptions): void;
120
-
121
- interface ArriProcedureBase {
122
- method: HttpMethod;
123
- params?: any;
124
- response?: any;
125
- handler: (context: any) => any;
126
- postHandler?: (context: any) => any;
127
- }
128
- interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
129
- description?: string;
130
- method?: HttpMethod;
131
- params: TParams;
132
- response: TResponse;
133
- handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
134
- postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
135
- }
136
- type HandlerContext = Record<string, any>;
137
- interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
138
- type: "procedure";
139
- params: TParams;
140
- }
141
- interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
142
- response: TResponse;
143
- }
144
- type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: H3Event) => TResponse | Promise<TResponse>;
145
- type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: H3Event) => any;
146
- declare function isRpc(input: any): input is ArriProcedure<any, any>;
147
- declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
148
- declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
149
- declare function getRpcPath(rpcName: string, prefix?: string): string;
150
- declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
151
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
152
- declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
153
- declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
154
-
155
- declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
156
- declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
157
- declare class Arri {
158
- __isArri__: boolean;
159
- private readonly h3App;
160
- private readonly h3Router;
161
- private readonly rpcDefinitionPath;
162
- private readonly rpcRoutePrefix;
163
- appInfo: ApplicationDef["info"];
164
- private procedures;
165
- private models;
166
- private readonly middlewares;
167
- private readonly onAfterResponse;
168
- private readonly onBeforeResponse;
169
- private readonly onError;
170
- constructor(opts?: ArriOptions);
171
- registerMiddleware(middleware: Middleware): void;
172
- registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
- 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;
174
- getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
176
- }
177
- interface ArriOptions {
178
- debug?: boolean;
179
- /**
180
- * Metadata to display in the __definition.json file
181
- */
182
- appInfo?: ApplicationDef["info"];
183
- rpcRoutePrefix?: string;
184
- /**
185
- * Defaults to /__definitions
186
- * This parameters also takes the rpcRoutePrefix option into account
187
- */
188
- rpcDefinitionPath?: string;
189
- onRequest?: (event: H3Event) => void | Promise<void>;
190
- onAfterResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
191
- onBeforeResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
192
- onError?: (error: H3Error, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event) => void | Promise<void>;
193
- }
194
- declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
195
- type HttpMethod = (typeof HttpMethodValues)[number];
196
- declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
197
-
198
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
199
- generator: (def: ApplicationDef) => any;
200
- options: TOptions;
201
- }
202
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
-
205
- export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,205 +0,0 @@
1
- import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
3
-
4
- interface ApplicationDef {
5
- arriSchemaVersion: "0.0.1";
6
- info?: {
7
- title?: string;
8
- description?: string;
9
- version?: string;
10
- };
11
- externalDocs?: {
12
- description?: string;
13
- url: string;
14
- };
15
- procedures: Record<string, ProcedureDef>;
16
- models: Record<string, JsonSchemaObject>;
17
- errors: Omit<TObject, symbol>;
18
- }
19
- declare function normalizeWhitespace(input: string): string;
20
- interface ProcedureDef {
21
- path: string;
22
- description?: string;
23
- method: HttpMethod;
24
- params: string | undefined;
25
- response: string | undefined;
26
- }
27
- declare function isProcedureDef(input: any): input is ProcedureDef;
28
- interface ServiceDef {
29
- [key: string]: ProcedureDef | ServiceDef;
30
- }
31
- declare function isServiceDef(input: any): input is ServiceDef;
32
- declare function isApplicationDef(input: any): input is ApplicationDef;
33
- declare function unflattenObject(data: Record<string, any>): any;
34
- declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
- declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
- declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
37
- declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
38
- declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
- declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
40
- type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
- type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
42
- interface JsonSchemaScalarType {
43
- title?: string;
44
- description?: string;
45
- type: (typeof JsonSchemaScalarTypeValues)[number];
46
- }
47
- declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
48
- interface JsonSchemaNullType {
49
- type: (typeof JsonSchemaNullTypeValues)[number];
50
- }
51
- declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
52
- type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray | JsonSchemaRecord;
53
- interface JsonSchemaObject {
54
- $id?: string;
55
- title?: string;
56
- description?: string;
57
- type: "object";
58
- properties: Record<string, JsonSchemaType>;
59
- required?: string[];
60
- }
61
- declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
62
- interface JsonSchemaRecord {
63
- $id?: string;
64
- title?: string;
65
- type: "object";
66
- patternProperties: Record<string, JsonSchemaType>;
67
- }
68
- declare const isJsonSchemaRecord: (input: any) => input is JsonSchemaRecord;
69
- interface JsonSchemaArray {
70
- $id?: string;
71
- title?: string;
72
- description?: string;
73
- type: "array";
74
- items: JsonSchemaType;
75
- }
76
- declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
77
- interface JsonSchemaUint8Array {
78
- type: "Uint8Array";
79
- }
80
- interface JsonSchemaEnum {
81
- anyOf: Array<{
82
- type: "string";
83
- const: string;
84
- }> | Array<{
85
- type: "number";
86
- const: number;
87
- }> | Array<{
88
- type: "integer";
89
- const: number;
90
- }>;
91
- }
92
- declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
93
-
94
- 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> {
95
- path: TPath;
96
- method: TMethod;
97
- query?: TQuery;
98
- body?: TBody;
99
- response?: TResponse;
100
- handler: ArriRouteHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TSchema ? Static<TBody> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
101
- postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
102
- }
103
- declare function defineRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = any, TBody extends TSchema | undefined = any, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(config: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>;
104
- type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
105
- declare const defineMiddleware: (middleware: Middleware) => Middleware;
106
- type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
107
- type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
108
- type ArriRouteHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = any> = (context: RouteHandlerContext<ExtractParams<TPath>, TQuery, TBody>, event: H3Event) => TResponse extends undefined ? void | Promise<void> : TResponse | Promise<TResponse>;
109
- interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
110
- type: "route";
111
- params: TParams;
112
- query: TQuery;
113
- body: TBody;
114
- }
115
- interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
116
- response: TResponse;
117
- }
118
- type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>, event: H3Event) => any;
119
- declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string, opts?: ArriOptions): void;
120
-
121
- interface ArriProcedureBase {
122
- method: HttpMethod;
123
- params?: any;
124
- response?: any;
125
- handler: (context: any) => any;
126
- postHandler?: (context: any) => any;
127
- }
128
- interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
129
- description?: string;
130
- method?: HttpMethod;
131
- params: TParams;
132
- response: TResponse;
133
- handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
134
- postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
135
- }
136
- type HandlerContext = Record<string, any>;
137
- interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
138
- type: "procedure";
139
- params: TParams;
140
- }
141
- interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
142
- response: TResponse;
143
- }
144
- type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: H3Event) => TResponse | Promise<TResponse>;
145
- type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: H3Event) => any;
146
- declare function isRpc(input: any): input is ArriProcedure<any, any>;
147
- declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
148
- declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
149
- declare function getRpcPath(rpcName: string, prefix?: string): string;
150
- declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
151
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
152
- declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
153
- declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
154
-
155
- declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
156
- declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
157
- declare class Arri {
158
- __isArri__: boolean;
159
- private readonly h3App;
160
- private readonly h3Router;
161
- private readonly rpcDefinitionPath;
162
- private readonly rpcRoutePrefix;
163
- appInfo: ApplicationDef["info"];
164
- private procedures;
165
- private models;
166
- private readonly middlewares;
167
- private readonly onAfterResponse;
168
- private readonly onBeforeResponse;
169
- private readonly onError;
170
- constructor(opts?: ArriOptions);
171
- registerMiddleware(middleware: Middleware): void;
172
- registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
- 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;
174
- getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
176
- }
177
- interface ArriOptions {
178
- debug?: boolean;
179
- /**
180
- * Metadata to display in the __definition.json file
181
- */
182
- appInfo?: ApplicationDef["info"];
183
- rpcRoutePrefix?: string;
184
- /**
185
- * Defaults to /__definitions
186
- * This parameters also takes the rpcRoutePrefix option into account
187
- */
188
- rpcDefinitionPath?: string;
189
- onRequest?: (event: H3Event) => void | Promise<void>;
190
- onAfterResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
191
- onBeforeResponse?: (context: RpcPostHandlerContext | RoutePostHandlerContext<any>, event: H3Event) => void | Promise<void>;
192
- onError?: (error: H3Error, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event) => void | Promise<void>;
193
- }
194
- declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
195
- type HttpMethod = (typeof HttpMethodValues)[number];
196
- declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
197
-
198
- interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
199
- generator: (def: ApplicationDef) => any;
200
- options: TOptions;
201
- }
202
- type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
- declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
-
205
- export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };