arri 0.0.13 → 0.0.16
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 +8839 -68
- package/dist/chunks/index.mjs +8820 -69
- package/dist/cli.cjs +16918 -50228
- package/dist/cli.mjs +16898 -50196
- package/dist/codegen.cjs +314 -37
- package/dist/codegen.d.cts +23 -15
- package/dist/codegen.d.mts +23 -15
- package/dist/codegen.d.ts +23 -15
- package/dist/codegen.mjs +280 -23
- package/dist/index.cjs +47 -19
- package/dist/index.d.cts +19 -2
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.mjs +30 -1
- package/dist/shared/arri.0671bb8c.mjs +641 -0
- package/dist/shared/arri.a9b80e98.cjs +655 -0
- package/dist/shared/{arri.2ff96786.d.ts → arri.b176bba1.d.cts} +113 -70
- package/dist/shared/{arri.2ff96786.d.cts → arri.b176bba1.d.mts} +113 -70
- package/dist/shared/{arri.2ff96786.d.mts → arri.b176bba1.d.ts} +113 -70
- package/dist/shared/arri.b2f4eb7d.cjs +851 -0
- package/dist/shared/arri.fd713b2e.mjs +812 -0
- package/package.json +6 -4
- package/dist/chunks/acorn.cjs +0 -18
- package/dist/chunks/acorn.mjs +0 -15
- package/dist/chunks/angular.cjs +0 -7
- package/dist/chunks/angular.mjs +0 -4
- package/dist/chunks/babel.cjs +0 -21
- package/dist/chunks/babel.mjs +0 -18
- package/dist/chunks/browser.cjs +0 -21
- package/dist/chunks/browser.mjs +0 -19
- package/dist/chunks/estree.cjs +0 -42
- package/dist/chunks/estree.mjs +0 -37
- package/dist/chunks/flow.cjs +0 -26
- package/dist/chunks/flow.mjs +0 -23
- package/dist/chunks/glimmer.cjs +0 -37
- package/dist/chunks/glimmer.mjs +0 -32
- package/dist/chunks/graphql.cjs +0 -37
- package/dist/chunks/graphql.mjs +0 -31
- package/dist/chunks/html.cjs +0 -27
- package/dist/chunks/html.mjs +0 -21
- package/dist/chunks/index2.cjs +0 -231
- package/dist/chunks/index2.mjs +0 -220
- package/dist/chunks/index3.cjs +0 -8854
- package/dist/chunks/index3.mjs +0 -8832
- package/dist/chunks/markdown.cjs +0 -67
- package/dist/chunks/markdown.mjs +0 -61
- package/dist/chunks/meriyah.cjs +0 -10
- package/dist/chunks/meriyah.mjs +0 -7
- package/dist/chunks/postcss.cjs +0 -60
- package/dist/chunks/postcss.mjs +0 -54
- package/dist/chunks/typescript.cjs +0 -30
- package/dist/chunks/typescript.mjs +0 -27
- package/dist/chunks/xdg-open.cjs +0 -1071
- package/dist/chunks/xdg-open.mjs +0 -1069
- package/dist/chunks/yaml.cjs +0 -169
- package/dist/chunks/yaml.mjs +0 -163
- package/dist/shared/arri.3605a96c.cjs +0 -8796
- package/dist/shared/arri.a90e77aa.mjs +0 -29680
- package/dist/shared/arri.b0ab6d2f.mjs +0 -8756
- package/dist/shared/arri.d31eb2d5.cjs +0 -29706
|
@@ -1,34 +1,54 @@
|
|
|
1
|
-
import { TObject,
|
|
2
|
-
import {
|
|
1
|
+
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
+
import { Router, H3Event, App, AppOptions } from 'h3';
|
|
3
3
|
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>;
|
|
8
16
|
models: Record<string, JsonSchemaObject>;
|
|
9
17
|
errors: Omit<TObject, symbol>;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
declare function normalizeWhitespace(input: string): string;
|
|
20
|
+
interface ProcedureDef {
|
|
12
21
|
path: string;
|
|
13
22
|
description?: string;
|
|
14
23
|
method: HttpMethod;
|
|
15
24
|
params: string | undefined;
|
|
16
25
|
response: string | undefined;
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
declare function isProcedureDef(input: any): input is ProcedureDef;
|
|
28
|
+
interface ServiceDef {
|
|
29
|
+
[key: string]: ProcedureDef | ServiceDef;
|
|
20
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;
|
|
21
37
|
declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
|
|
22
38
|
declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
|
|
39
|
+
declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
|
|
23
40
|
type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
|
|
41
|
+
type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
|
|
24
42
|
interface JsonSchemaScalarType {
|
|
25
43
|
title?: string;
|
|
26
44
|
description?: string;
|
|
27
45
|
type: (typeof JsonSchemaScalarTypeValues)[number];
|
|
28
46
|
}
|
|
47
|
+
declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
|
|
29
48
|
interface JsonSchemaNullType {
|
|
30
49
|
type: (typeof JsonSchemaNullTypeValues)[number];
|
|
31
50
|
}
|
|
51
|
+
declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
|
|
32
52
|
type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray;
|
|
33
53
|
interface JsonSchemaObject {
|
|
34
54
|
$id?: string;
|
|
@@ -38,6 +58,7 @@ interface JsonSchemaObject {
|
|
|
38
58
|
properties: Record<string, JsonSchemaType>;
|
|
39
59
|
required?: string[];
|
|
40
60
|
}
|
|
61
|
+
declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
|
|
41
62
|
interface JsonSchemaArray {
|
|
42
63
|
$id?: string;
|
|
43
64
|
title?: string;
|
|
@@ -45,42 +66,23 @@ interface JsonSchemaArray {
|
|
|
45
66
|
type: "array";
|
|
46
67
|
items: JsonSchemaType;
|
|
47
68
|
}
|
|
48
|
-
|
|
49
|
-
interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
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;
|
|
69
|
+
declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
|
|
70
|
+
interface JsonSchemaUint8Array {
|
|
71
|
+
type: "Uint8Array";
|
|
72
|
+
}
|
|
73
|
+
interface JsonSchemaEnum {
|
|
74
|
+
anyOf: Array<{
|
|
75
|
+
type: "string";
|
|
76
|
+
const: string;
|
|
77
|
+
}> | Array<{
|
|
78
|
+
type: "number";
|
|
79
|
+
const: number;
|
|
80
|
+
}> | Array<{
|
|
81
|
+
type: "integer";
|
|
82
|
+
const: number;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
|
|
84
86
|
|
|
85
87
|
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
88
|
path: TPath;
|
|
@@ -108,41 +110,82 @@ interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery
|
|
|
108
110
|
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>) => any;
|
|
109
111
|
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
110
112
|
|
|
111
|
-
interface
|
|
113
|
+
interface ArriProcedureBase {
|
|
114
|
+
method: HttpMethod;
|
|
115
|
+
params?: any;
|
|
116
|
+
response?: any;
|
|
117
|
+
handler: (context: any) => any;
|
|
118
|
+
postHandler?: (context: any) => any;
|
|
119
|
+
}
|
|
120
|
+
interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
|
|
121
|
+
description?: string;
|
|
122
|
+
method?: HttpMethod;
|
|
123
|
+
params: TParams;
|
|
124
|
+
response: TResponse;
|
|
125
|
+
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
126
|
+
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
127
|
+
}
|
|
128
|
+
interface HandlerContext {
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
event: H3Event;
|
|
131
|
+
}
|
|
132
|
+
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
133
|
+
params: TParams;
|
|
134
|
+
}
|
|
135
|
+
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
136
|
+
response: TResponse;
|
|
137
|
+
}
|
|
138
|
+
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
|
|
139
|
+
type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
|
|
140
|
+
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
141
|
+
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
142
|
+
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
|
|
143
|
+
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
144
|
+
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
145
|
+
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
|
|
146
|
+
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
147
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
148
|
+
|
|
149
|
+
interface ArriOptions extends AppOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Metadata to display in the __definition.json file
|
|
152
|
+
*/
|
|
153
|
+
appInfo?: ApplicationDef["info"];
|
|
112
154
|
rpcRoutePrefix?: string;
|
|
113
155
|
/**
|
|
114
156
|
* Defaults to /__definitions
|
|
115
157
|
* This parameters also takes the rpcRoutePrefix option into account
|
|
116
158
|
*/
|
|
117
159
|
rpcDefinitionPath?: string;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
declare
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
}
|
|
161
|
+
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
162
|
+
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
163
|
+
declare class Arri {
|
|
164
|
+
__isArri__: boolean;
|
|
165
|
+
private readonly h3App;
|
|
166
|
+
private readonly h3Router;
|
|
167
|
+
private readonly rpcDefinitionPath;
|
|
168
|
+
private readonly rpcRoutePrefix;
|
|
169
|
+
appInfo: ApplicationDef["info"];
|
|
170
|
+
private procedures;
|
|
171
|
+
private models;
|
|
172
|
+
private readonly middlewares;
|
|
173
|
+
constructor(opts?: ArriOptions);
|
|
130
174
|
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;
|
|
175
|
+
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
137
176
|
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
|
-
getAppDefinition():
|
|
139
|
-
|
|
140
|
-
interface ArriService {
|
|
141
|
-
id: string;
|
|
142
|
-
procedures: Record<string, any>;
|
|
177
|
+
getAppDefinition(): ApplicationDef;
|
|
178
|
+
getH3Instance(): App;
|
|
143
179
|
}
|
|
144
180
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
145
181
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
146
182
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
147
183
|
|
|
148
|
-
|
|
184
|
+
interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
|
|
185
|
+
generator: (def: ApplicationDef) => any;
|
|
186
|
+
options: TOptions;
|
|
187
|
+
}
|
|
188
|
+
type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
|
|
189
|
+
declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
|
|
190
|
+
|
|
191
|
+
export { isJsonSchemaScalarType as $, Arri as A, type ClientGeneratorPlugin as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ApplicationDef as F, defineClientGeneratorPlugin as G, HttpMethodValues as H, normalizeWhitespace as I, type JsonSchemaObject as J, isProcedureDef as K, isServiceDef as L, type Middleware as M, isApplicationDef as N, unflattenObject as O, type ProcedureDef as P, unflattenProcedures as Q, type RpcHandlerContext as R, type ServiceDef as S, setNestedObjectProperty as T, removeDisallowedChars as U, JsonSchemaScalarTypeValues as V, JsonSchemaNullTypeValues as W, JsonSchemaComplexTypeValues as X, type JsonSchemaType as Y, type JsonSchemaTypeValue as Z, type JsonSchemaScalarType as _, DEV_DEFINITION_ENDPOINT as a, type JsonSchemaNullType as a0, isJsonSchemaNullType as a1, type JsonSchemaComplexType as a2, isJsonSchemaObject as a3, type JsonSchemaArray as a4, isJsonSchemaArray as a5, type JsonSchemaUint8Array as a6, type JsonSchemaEnum as a7, isJsonSchemaEnum as a8, 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 };
|
|
@@ -1,34 +1,54 @@
|
|
|
1
|
-
import { TObject,
|
|
2
|
-
import {
|
|
1
|
+
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
+
import { Router, H3Event, App, AppOptions } from 'h3';
|
|
3
3
|
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>;
|
|
8
16
|
models: Record<string, JsonSchemaObject>;
|
|
9
17
|
errors: Omit<TObject, symbol>;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
declare function normalizeWhitespace(input: string): string;
|
|
20
|
+
interface ProcedureDef {
|
|
12
21
|
path: string;
|
|
13
22
|
description?: string;
|
|
14
23
|
method: HttpMethod;
|
|
15
24
|
params: string | undefined;
|
|
16
25
|
response: string | undefined;
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
declare function isProcedureDef(input: any): input is ProcedureDef;
|
|
28
|
+
interface ServiceDef {
|
|
29
|
+
[key: string]: ProcedureDef | ServiceDef;
|
|
20
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;
|
|
21
37
|
declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
|
|
22
38
|
declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
|
|
39
|
+
declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
|
|
23
40
|
type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
|
|
41
|
+
type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
|
|
24
42
|
interface JsonSchemaScalarType {
|
|
25
43
|
title?: string;
|
|
26
44
|
description?: string;
|
|
27
45
|
type: (typeof JsonSchemaScalarTypeValues)[number];
|
|
28
46
|
}
|
|
47
|
+
declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
|
|
29
48
|
interface JsonSchemaNullType {
|
|
30
49
|
type: (typeof JsonSchemaNullTypeValues)[number];
|
|
31
50
|
}
|
|
51
|
+
declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
|
|
32
52
|
type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray;
|
|
33
53
|
interface JsonSchemaObject {
|
|
34
54
|
$id?: string;
|
|
@@ -38,6 +58,7 @@ interface JsonSchemaObject {
|
|
|
38
58
|
properties: Record<string, JsonSchemaType>;
|
|
39
59
|
required?: string[];
|
|
40
60
|
}
|
|
61
|
+
declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
|
|
41
62
|
interface JsonSchemaArray {
|
|
42
63
|
$id?: string;
|
|
43
64
|
title?: string;
|
|
@@ -45,42 +66,23 @@ interface JsonSchemaArray {
|
|
|
45
66
|
type: "array";
|
|
46
67
|
items: JsonSchemaType;
|
|
47
68
|
}
|
|
48
|
-
|
|
49
|
-
interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
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;
|
|
69
|
+
declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
|
|
70
|
+
interface JsonSchemaUint8Array {
|
|
71
|
+
type: "Uint8Array";
|
|
72
|
+
}
|
|
73
|
+
interface JsonSchemaEnum {
|
|
74
|
+
anyOf: Array<{
|
|
75
|
+
type: "string";
|
|
76
|
+
const: string;
|
|
77
|
+
}> | Array<{
|
|
78
|
+
type: "number";
|
|
79
|
+
const: number;
|
|
80
|
+
}> | Array<{
|
|
81
|
+
type: "integer";
|
|
82
|
+
const: number;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
|
|
84
86
|
|
|
85
87
|
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
88
|
path: TPath;
|
|
@@ -108,41 +110,82 @@ interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery
|
|
|
108
110
|
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>) => any;
|
|
109
111
|
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
110
112
|
|
|
111
|
-
interface
|
|
113
|
+
interface ArriProcedureBase {
|
|
114
|
+
method: HttpMethod;
|
|
115
|
+
params?: any;
|
|
116
|
+
response?: any;
|
|
117
|
+
handler: (context: any) => any;
|
|
118
|
+
postHandler?: (context: any) => any;
|
|
119
|
+
}
|
|
120
|
+
interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
|
|
121
|
+
description?: string;
|
|
122
|
+
method?: HttpMethod;
|
|
123
|
+
params: TParams;
|
|
124
|
+
response: TResponse;
|
|
125
|
+
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
126
|
+
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
127
|
+
}
|
|
128
|
+
interface HandlerContext {
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
event: H3Event;
|
|
131
|
+
}
|
|
132
|
+
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
133
|
+
params: TParams;
|
|
134
|
+
}
|
|
135
|
+
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
136
|
+
response: TResponse;
|
|
137
|
+
}
|
|
138
|
+
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
|
|
139
|
+
type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
|
|
140
|
+
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
141
|
+
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
142
|
+
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
|
|
143
|
+
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
144
|
+
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
145
|
+
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
|
|
146
|
+
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
147
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
148
|
+
|
|
149
|
+
interface ArriOptions extends AppOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Metadata to display in the __definition.json file
|
|
152
|
+
*/
|
|
153
|
+
appInfo?: ApplicationDef["info"];
|
|
112
154
|
rpcRoutePrefix?: string;
|
|
113
155
|
/**
|
|
114
156
|
* Defaults to /__definitions
|
|
115
157
|
* This parameters also takes the rpcRoutePrefix option into account
|
|
116
158
|
*/
|
|
117
159
|
rpcDefinitionPath?: string;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
declare
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
}
|
|
161
|
+
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
162
|
+
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
163
|
+
declare class Arri {
|
|
164
|
+
__isArri__: boolean;
|
|
165
|
+
private readonly h3App;
|
|
166
|
+
private readonly h3Router;
|
|
167
|
+
private readonly rpcDefinitionPath;
|
|
168
|
+
private readonly rpcRoutePrefix;
|
|
169
|
+
appInfo: ApplicationDef["info"];
|
|
170
|
+
private procedures;
|
|
171
|
+
private models;
|
|
172
|
+
private readonly middlewares;
|
|
173
|
+
constructor(opts?: ArriOptions);
|
|
130
174
|
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;
|
|
175
|
+
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
137
176
|
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
|
-
getAppDefinition():
|
|
139
|
-
|
|
140
|
-
interface ArriService {
|
|
141
|
-
id: string;
|
|
142
|
-
procedures: Record<string, any>;
|
|
177
|
+
getAppDefinition(): ApplicationDef;
|
|
178
|
+
getH3Instance(): App;
|
|
143
179
|
}
|
|
144
180
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
145
181
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
146
182
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
147
183
|
|
|
148
|
-
|
|
184
|
+
interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
|
|
185
|
+
generator: (def: ApplicationDef) => any;
|
|
186
|
+
options: TOptions;
|
|
187
|
+
}
|
|
188
|
+
type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
|
|
189
|
+
declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
|
|
190
|
+
|
|
191
|
+
export { isJsonSchemaScalarType as $, Arri as A, type ClientGeneratorPlugin as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ApplicationDef as F, defineClientGeneratorPlugin as G, HttpMethodValues as H, normalizeWhitespace as I, type JsonSchemaObject as J, isProcedureDef as K, isServiceDef as L, type Middleware as M, isApplicationDef as N, unflattenObject as O, type ProcedureDef as P, unflattenProcedures as Q, type RpcHandlerContext as R, type ServiceDef as S, setNestedObjectProperty as T, removeDisallowedChars as U, JsonSchemaScalarTypeValues as V, JsonSchemaNullTypeValues as W, JsonSchemaComplexTypeValues as X, type JsonSchemaType as Y, type JsonSchemaTypeValue as Z, type JsonSchemaScalarType as _, DEV_DEFINITION_ENDPOINT as a, type JsonSchemaNullType as a0, isJsonSchemaNullType as a1, type JsonSchemaComplexType as a2, isJsonSchemaObject as a3, type JsonSchemaArray as a4, isJsonSchemaArray as a5, type JsonSchemaUint8Array as a6, type JsonSchemaEnum as a7, isJsonSchemaEnum as a8, 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 };
|