arri 0.0.28 → 0.0.29
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 +2 -2
- package/dist/chunks/index.mjs +2 -2
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/codegen.cjs +2 -2
- package/dist/codegen.d.cts +2 -2
- package/dist/codegen.d.mts +2 -2
- package/dist/codegen.d.ts +2 -2
- package/dist/codegen.mjs +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.f0cec5fb.d.ts → arri.1f0e8d09.d.cts} +32 -25
- package/dist/shared/{arri.f0cec5fb.d.cts → arri.1f0e8d09.d.mts} +32 -25
- package/dist/shared/{arri.f0cec5fb.d.mts → arri.1f0e8d09.d.ts} +32 -25
- package/dist/shared/{arri.198ae3ea.cjs → arri.50fd4bf9.cjs} +152 -124
- package/dist/shared/{arri.7f1296ca.mjs → arri.64252c62.mjs} +1 -1
- package/dist/shared/{arri.74885d3a.mjs → arri.e62071ea.mjs} +153 -125
- package/dist/shared/{arri.2826746b.cjs → arri.fa2beb45.cjs} +1 -1
- package/package.json +1 -1
package/dist/chunks/index.cjs
CHANGED
|
@@ -35,14 +35,14 @@ require('node:v8');
|
|
|
35
35
|
require('consola');
|
|
36
36
|
require('esbuild');
|
|
37
37
|
require('prettier');
|
|
38
|
-
require('../shared/arri.
|
|
38
|
+
require('../shared/arri.50fd4bf9.cjs');
|
|
39
39
|
require('@sinclair/typebox');
|
|
40
40
|
require('h3');
|
|
41
41
|
require('@sinclair/typebox/errors');
|
|
42
42
|
require('@sinclair/typebox/value');
|
|
43
43
|
require('../index.cjs');
|
|
44
44
|
require('ofetch');
|
|
45
|
-
require('../shared/arri.
|
|
45
|
+
require('../shared/arri.fa2beb45.cjs');
|
|
46
46
|
require('child_process');
|
|
47
47
|
require('listhen');
|
|
48
48
|
|
package/dist/chunks/index.mjs
CHANGED
|
@@ -33,14 +33,14 @@ import 'node:v8';
|
|
|
33
33
|
import 'consola';
|
|
34
34
|
import 'esbuild';
|
|
35
35
|
import 'prettier';
|
|
36
|
-
import '../shared/arri.
|
|
36
|
+
import '../shared/arri.e62071ea.mjs';
|
|
37
37
|
import '@sinclair/typebox';
|
|
38
38
|
import 'h3';
|
|
39
39
|
import '@sinclair/typebox/errors';
|
|
40
40
|
import '@sinclair/typebox/value';
|
|
41
41
|
import '../index.mjs';
|
|
42
42
|
import 'ofetch';
|
|
43
|
-
import '../shared/arri.
|
|
43
|
+
import '../shared/arri.64252c62.mjs';
|
|
44
44
|
import 'child_process';
|
|
45
45
|
import 'listhen';
|
|
46
46
|
|
package/dist/cli.cjs
CHANGED
|
@@ -25,7 +25,7 @@ const require$$0$3 = require('stream');
|
|
|
25
25
|
const consola = require('consola');
|
|
26
26
|
const esbuild = require('esbuild');
|
|
27
27
|
const prettier = require('prettier');
|
|
28
|
-
const app = require('./shared/arri.
|
|
28
|
+
const app = require('./shared/arri.50fd4bf9.cjs');
|
|
29
29
|
const index = require('./index.cjs');
|
|
30
30
|
require('node:stream');
|
|
31
31
|
const ofetch = require('ofetch');
|
|
@@ -33,7 +33,7 @@ require('@sinclair/typebox');
|
|
|
33
33
|
require('h3');
|
|
34
34
|
require('@sinclair/typebox/errors');
|
|
35
35
|
require('@sinclair/typebox/value');
|
|
36
|
-
const dart = require('./shared/arri.
|
|
36
|
+
const dart = require('./shared/arri.fa2beb45.cjs');
|
|
37
37
|
const listhen = require('listhen');
|
|
38
38
|
require('child_process');
|
|
39
39
|
|
package/dist/cli.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import require$$0$3 from 'stream';
|
|
|
23
23
|
import { createConsola } from 'consola';
|
|
24
24
|
import { build as build$1 } from 'esbuild';
|
|
25
25
|
import prettier from 'prettier';
|
|
26
|
-
import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.
|
|
26
|
+
import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.e62071ea.mjs';
|
|
27
27
|
import { defaultConfig } from './index.mjs';
|
|
28
28
|
import 'node:stream';
|
|
29
29
|
import { ofetch } from 'ofetch';
|
|
@@ -31,7 +31,7 @@ import '@sinclair/typebox';
|
|
|
31
31
|
import 'h3';
|
|
32
32
|
import '@sinclair/typebox/errors';
|
|
33
33
|
import '@sinclair/typebox/value';
|
|
34
|
-
import { a as dartClientGenerator } from './shared/arri.
|
|
34
|
+
import { a as dartClientGenerator } from './shared/arri.64252c62.mjs';
|
|
35
35
|
import { listenAndWatch } from 'listhen';
|
|
36
36
|
import 'child_process';
|
|
37
37
|
|
package/dist/codegen.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const require$$0 = require('fs');
|
|
4
4
|
const prettier = require('prettier');
|
|
5
|
-
const app = require('./shared/arri.
|
|
6
|
-
const dart = require('./shared/arri.
|
|
5
|
+
const app = require('./shared/arri.50fd4bf9.cjs');
|
|
6
|
+
const dart = require('./shared/arri.fa2beb45.cjs');
|
|
7
7
|
require('@sinclair/typebox');
|
|
8
8
|
require('h3');
|
|
9
9
|
require('@sinclair/typebox/errors');
|
package/dist/codegen.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientGenerator,
|
|
1
|
+
import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.cjs';
|
|
2
|
+
export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.cjs';
|
|
3
3
|
import '@sinclair/typebox';
|
|
4
4
|
import 'h3';
|
|
5
5
|
|
package/dist/codegen.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientGenerator,
|
|
1
|
+
import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.mjs';
|
|
2
|
+
export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.mjs';
|
|
3
3
|
import '@sinclair/typebox';
|
|
4
4
|
import 'h3';
|
|
5
5
|
|
package/dist/codegen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientGenerator,
|
|
1
|
+
import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.1f0e8d09.js';
|
|
2
|
+
export { C as ClientGenerator, a7 as JsonSchemaArray, a3 as JsonSchemaComplexType, Y as JsonSchemaComplexTypeValues, aa as JsonSchemaEnum, a1 as JsonSchemaNullType, X as JsonSchemaNullTypeValues, a5 as JsonSchemaRecord, $ as JsonSchemaScalarType, W as JsonSchemaScalarTypeValues, Z as JsonSchemaType, _ as JsonSchemaTypeValue, a9 as JsonSchemaUint8Array, I as defineClientGeneratorPlugin, O as isApplicationDef, a8 as isJsonSchemaArray, ab as isJsonSchemaEnum, a2 as isJsonSchemaNullType, a4 as isJsonSchemaObject, a6 as isJsonSchemaRecord, a0 as isJsonSchemaScalarType, L as isProcedureDef, N as isServiceDef, K as normalizeWhitespace, V as removeDisallowedChars, U as setNestedObjectProperty, Q as unflattenObject, T as unflattenProcedures } from './shared/arri.1f0e8d09.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
4
4
|
import 'h3';
|
|
5
5
|
|
package/dist/codegen.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { writeFileSync } from 'fs';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
|
-
import { u as unflattenObject, i as isServiceDef, p as pascalCase, a as isProcedureDef, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaRecord, f as isJsonSchemaEnum, g as isJsonSchemaArray, h as unflattenProcedures, j as camelCase } from './shared/arri.
|
|
4
|
-
export { m as JsonSchemaComplexTypeValues, l as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, k as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.
|
|
5
|
-
import { d as defineClientGeneratorPlugin } from './shared/arri.
|
|
6
|
-
export { j as classListTransformer, i as classTransformer, c as createDartClient, a as dartClientGenerator, f as dartModelFromJsonSchema, h as dartParsedJsonField, e as dartProcedureFromServiceDefinition, g as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, k as isDartType, l as isDartTypeWithNullables, t as transformers } from './shared/arri.
|
|
3
|
+
import { u as unflattenObject, i as isServiceDef, p as pascalCase, a as isProcedureDef, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaRecord, f as isJsonSchemaEnum, g as isJsonSchemaArray, h as unflattenProcedures, j as camelCase } from './shared/arri.e62071ea.mjs';
|
|
4
|
+
export { m as JsonSchemaComplexTypeValues, l as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, k as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.e62071ea.mjs';
|
|
5
|
+
import { d as defineClientGeneratorPlugin } from './shared/arri.64252c62.mjs';
|
|
6
|
+
export { j as classListTransformer, i as classTransformer, c as createDartClient, a as dartClientGenerator, f as dartModelFromJsonSchema, h as dartParsedJsonField, e as dartProcedureFromServiceDefinition, g as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, k as isDartType, l as isDartTypeWithNullables, t as transformers } from './shared/arri.64252c62.mjs';
|
|
7
7
|
import '@sinclair/typebox';
|
|
8
8
|
import 'h3';
|
|
9
9
|
import '@sinclair/typebox/errors';
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientGenerator } from './shared/arri.
|
|
2
|
-
export { A as Arri,
|
|
1
|
+
import { C as ClientGenerator } from './shared/arri.1f0e8d09.cjs';
|
|
2
|
+
export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.cjs';
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
5
5
|
import { ValueError } from '@sinclair/typebox/errors';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientGenerator } from './shared/arri.
|
|
2
|
-
export { A as Arri,
|
|
1
|
+
import { C as ClientGenerator } from './shared/arri.1f0e8d09.mjs';
|
|
2
|
+
export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.mjs';
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
5
5
|
import { ValueError } from '@sinclair/typebox/errors';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientGenerator } from './shared/arri.
|
|
2
|
-
export { A as Arri,
|
|
1
|
+
import { C as ClientGenerator } from './shared/arri.1f0e8d09.js';
|
|
2
|
+
export { A as Arri, b as ArriOptions, e as ArriProcedure, d as ArriProcedureBase, h as ArriProcedureHandler, j as ArriProcedurePostHandler, s as ArriRoute, w as ArriRouteHandler, z as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, v as ExtractParams, f as HandlerContext, c as HttpMethod, H as HttpMethodValues, M as Middleware, x as RouteHandlerContext, y as RoutePostHandlerContext, R as RpcHandlerContext, g as RpcPostHandlerContext, m as createRpcDefinition, u as defineMiddleware, t as defineRoute, l as defineRpc, p as getRpcParamDefinition, o as getRpcParamName, n as getRpcPath, q as getRpcResponseName, i as isHttpMethod, k as isRpc, B as registerRoute, r as registerRpc } from './shared/arri.1f0e8d09.js';
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
5
5
|
import { ValueError } from '@sinclair/typebox/errors';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Arri, D as DEV_DEFINITION_ENDPOINT, q as DEV_ENDPOINT_ROOT, K as ErrorResponse, H as HttpMethodValues, x as createRpcDefinition, L as defineError, G as defineMiddleware, F as defineRoute, w as defineRpc, M as errorResponseFromValidationErrors, B as getRpcParamDefinition, z as getRpcParamName, y as getRpcPath, C as getRpcResponseName, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.
|
|
1
|
+
export { A as Arri, D as DEV_DEFINITION_ENDPOINT, q as DEV_ENDPOINT_ROOT, K as ErrorResponse, H as HttpMethodValues, x as createRpcDefinition, L as defineError, G as defineMiddleware, F as defineRoute, w as defineRpc, M as errorResponseFromValidationErrors, B as getRpcParamDefinition, z as getRpcParamName, y as getRpcPath, C as getRpcResponseName, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.e62071ea.mjs';
|
|
2
2
|
import '@sinclair/typebox';
|
|
3
3
|
import 'h3';
|
|
4
4
|
import '@sinclair/typebox/errors';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
2
|
+
import { H3Event, Router, App, H3Error } from 'h3';
|
|
3
3
|
|
|
4
4
|
interface ApplicationDef {
|
|
5
5
|
arriSchemaVersion: "0.0.1";
|
|
@@ -101,12 +101,13 @@ interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery ext
|
|
|
101
101
|
postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
|
|
102
102
|
}
|
|
103
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) => void | Promise<void>;
|
|
104
|
+
type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
|
|
105
105
|
declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
106
106
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
107
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
|
|
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
109
|
interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
|
|
110
|
+
type: "route";
|
|
110
111
|
params: TParams;
|
|
111
112
|
query: TQuery;
|
|
112
113
|
body: TBody;
|
|
@@ -114,8 +115,8 @@ interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = u
|
|
|
114
115
|
interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
|
|
115
116
|
response: TResponse;
|
|
116
117
|
}
|
|
117
|
-
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse
|
|
118
|
-
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
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;
|
|
119
120
|
|
|
120
121
|
interface ArriProcedureBase {
|
|
121
122
|
method: HttpMethod;
|
|
@@ -132,18 +133,16 @@ interface ArriProcedure<TParams extends TObject | undefined, TResponse extends T
|
|
|
132
133
|
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
133
134
|
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
event: H3Event;
|
|
138
|
-
}
|
|
136
|
+
type HandlerContext = Record<string, any>;
|
|
139
137
|
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
138
|
+
type: "procedure";
|
|
140
139
|
params: TParams;
|
|
141
140
|
}
|
|
142
141
|
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
143
142
|
response: TResponse;
|
|
144
143
|
}
|
|
145
|
-
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams
|
|
146
|
-
type ArriProcedurePostHandler<TParams, TResponse> = (
|
|
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;
|
|
147
146
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
148
147
|
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
149
148
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
|
|
@@ -151,20 +150,8 @@ declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
|
151
150
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
152
151
|
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
|
|
153
152
|
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
154
|
-
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
153
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
|
|
155
154
|
|
|
156
|
-
interface ArriOptions extends AppOptions {
|
|
157
|
-
/**
|
|
158
|
-
* Metadata to display in the __definition.json file
|
|
159
|
-
*/
|
|
160
|
-
appInfo?: ApplicationDef["info"];
|
|
161
|
-
rpcRoutePrefix?: string;
|
|
162
|
-
/**
|
|
163
|
-
* Defaults to /__definitions
|
|
164
|
-
* This parameters also takes the rpcRoutePrefix option into account
|
|
165
|
-
*/
|
|
166
|
-
rpcDefinitionPath?: string;
|
|
167
|
-
}
|
|
168
155
|
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
169
156
|
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
170
157
|
declare class Arri {
|
|
@@ -177,6 +164,9 @@ declare class Arri {
|
|
|
177
164
|
private procedures;
|
|
178
165
|
private models;
|
|
179
166
|
private readonly middlewares;
|
|
167
|
+
private readonly onAfterResponse;
|
|
168
|
+
private readonly onBeforeResponse;
|
|
169
|
+
private readonly onError;
|
|
180
170
|
constructor(opts?: ArriOptions);
|
|
181
171
|
registerMiddleware(middleware: Middleware): void;
|
|
182
172
|
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
@@ -184,6 +174,23 @@ declare class Arri {
|
|
|
184
174
|
getAppDefinition(): ApplicationDef;
|
|
185
175
|
getH3Instance(): App;
|
|
186
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
|
+
}
|
|
187
194
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
188
195
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
189
196
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
@@ -195,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
|
|
|
195
202
|
type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
|
|
196
203
|
declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
|
|
197
204
|
|
|
198
|
-
export {
|
|
205
|
+
export { type JsonSchemaScalarType as $, Arri 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 _, DEV_DEFINITION_ENDPOINT 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, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
2
|
+
import { H3Event, Router, App, H3Error } from 'h3';
|
|
3
3
|
|
|
4
4
|
interface ApplicationDef {
|
|
5
5
|
arriSchemaVersion: "0.0.1";
|
|
@@ -101,12 +101,13 @@ interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery ext
|
|
|
101
101
|
postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
|
|
102
102
|
}
|
|
103
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) => void | Promise<void>;
|
|
104
|
+
type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
|
|
105
105
|
declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
106
106
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
107
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
|
|
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
109
|
interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
|
|
110
|
+
type: "route";
|
|
110
111
|
params: TParams;
|
|
111
112
|
query: TQuery;
|
|
112
113
|
body: TBody;
|
|
@@ -114,8 +115,8 @@ interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = u
|
|
|
114
115
|
interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
|
|
115
116
|
response: TResponse;
|
|
116
117
|
}
|
|
117
|
-
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse
|
|
118
|
-
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
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;
|
|
119
120
|
|
|
120
121
|
interface ArriProcedureBase {
|
|
121
122
|
method: HttpMethod;
|
|
@@ -132,18 +133,16 @@ interface ArriProcedure<TParams extends TObject | undefined, TResponse extends T
|
|
|
132
133
|
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
133
134
|
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
event: H3Event;
|
|
138
|
-
}
|
|
136
|
+
type HandlerContext = Record<string, any>;
|
|
139
137
|
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
138
|
+
type: "procedure";
|
|
140
139
|
params: TParams;
|
|
141
140
|
}
|
|
142
141
|
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
143
142
|
response: TResponse;
|
|
144
143
|
}
|
|
145
|
-
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams
|
|
146
|
-
type ArriProcedurePostHandler<TParams, TResponse> = (
|
|
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;
|
|
147
146
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
148
147
|
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
149
148
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
|
|
@@ -151,20 +150,8 @@ declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
|
151
150
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
152
151
|
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
|
|
153
152
|
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
154
|
-
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
153
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
|
|
155
154
|
|
|
156
|
-
interface ArriOptions extends AppOptions {
|
|
157
|
-
/**
|
|
158
|
-
* Metadata to display in the __definition.json file
|
|
159
|
-
*/
|
|
160
|
-
appInfo?: ApplicationDef["info"];
|
|
161
|
-
rpcRoutePrefix?: string;
|
|
162
|
-
/**
|
|
163
|
-
* Defaults to /__definitions
|
|
164
|
-
* This parameters also takes the rpcRoutePrefix option into account
|
|
165
|
-
*/
|
|
166
|
-
rpcDefinitionPath?: string;
|
|
167
|
-
}
|
|
168
155
|
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
169
156
|
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
170
157
|
declare class Arri {
|
|
@@ -177,6 +164,9 @@ declare class Arri {
|
|
|
177
164
|
private procedures;
|
|
178
165
|
private models;
|
|
179
166
|
private readonly middlewares;
|
|
167
|
+
private readonly onAfterResponse;
|
|
168
|
+
private readonly onBeforeResponse;
|
|
169
|
+
private readonly onError;
|
|
180
170
|
constructor(opts?: ArriOptions);
|
|
181
171
|
registerMiddleware(middleware: Middleware): void;
|
|
182
172
|
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
@@ -184,6 +174,23 @@ declare class Arri {
|
|
|
184
174
|
getAppDefinition(): ApplicationDef;
|
|
185
175
|
getH3Instance(): App;
|
|
186
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
|
+
}
|
|
187
194
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
188
195
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
189
196
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
@@ -195,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
|
|
|
195
202
|
type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
|
|
196
203
|
declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
|
|
197
204
|
|
|
198
|
-
export {
|
|
205
|
+
export { type JsonSchemaScalarType as $, Arri 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 _, DEV_DEFINITION_ENDPOINT 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, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TObject, TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
2
|
+
import { H3Event, Router, App, H3Error } from 'h3';
|
|
3
3
|
|
|
4
4
|
interface ApplicationDef {
|
|
5
5
|
arriSchemaVersion: "0.0.1";
|
|
@@ -101,12 +101,13 @@ interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery ext
|
|
|
101
101
|
postHandler?: ArriRoutePostHandler<TPath, TQuery extends TObject ? Static<TQuery> : undefined, TBody extends TObject ? Static<TObject> : undefined, TResponse extends TSchema ? Static<TResponse> : TFallbackResponse>;
|
|
102
102
|
}
|
|
103
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) => void | Promise<void>;
|
|
104
|
+
type Middleware = (context: HandlerContext, event: H3Event) => void | Promise<void>;
|
|
105
105
|
declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
106
106
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
107
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
|
|
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
109
|
interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined> extends HandlerContext {
|
|
110
|
+
type: "route";
|
|
110
111
|
params: TParams;
|
|
111
112
|
query: TQuery;
|
|
112
113
|
body: TBody;
|
|
@@ -114,8 +115,8 @@ interface RouteHandlerContext<TParams extends Record<string, string>, TQuery = u
|
|
|
114
115
|
interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery = undefined, TBody = undefined, TResponse = undefined> extends RouteHandlerContext<TParams, TQuery, TBody> {
|
|
115
116
|
response: TResponse;
|
|
116
117
|
}
|
|
117
|
-
type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse
|
|
118
|
-
declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
|
|
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;
|
|
119
120
|
|
|
120
121
|
interface ArriProcedureBase {
|
|
121
122
|
method: HttpMethod;
|
|
@@ -132,18 +133,16 @@ interface ArriProcedure<TParams extends TObject | undefined, TResponse extends T
|
|
|
132
133
|
handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
|
|
133
134
|
postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
event: H3Event;
|
|
138
|
-
}
|
|
136
|
+
type HandlerContext = Record<string, any>;
|
|
139
137
|
interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
|
|
138
|
+
type: "procedure";
|
|
140
139
|
params: TParams;
|
|
141
140
|
}
|
|
142
141
|
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
143
142
|
response: TResponse;
|
|
144
143
|
}
|
|
145
|
-
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams
|
|
146
|
-
type ArriProcedurePostHandler<TParams, TResponse> = (
|
|
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;
|
|
147
146
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
148
147
|
declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
149
148
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
|
|
@@ -151,20 +150,8 @@ declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
|
151
150
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
152
151
|
declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
|
|
153
152
|
declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
|
|
154
|
-
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
|
|
153
|
+
declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[], opts: ArriOptions): void;
|
|
155
154
|
|
|
156
|
-
interface ArriOptions extends AppOptions {
|
|
157
|
-
/**
|
|
158
|
-
* Metadata to display in the __definition.json file
|
|
159
|
-
*/
|
|
160
|
-
appInfo?: ApplicationDef["info"];
|
|
161
|
-
rpcRoutePrefix?: string;
|
|
162
|
-
/**
|
|
163
|
-
* Defaults to /__definitions
|
|
164
|
-
* This parameters also takes the rpcRoutePrefix option into account
|
|
165
|
-
*/
|
|
166
|
-
rpcDefinitionPath?: string;
|
|
167
|
-
}
|
|
168
155
|
declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
|
|
169
156
|
declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
|
|
170
157
|
declare class Arri {
|
|
@@ -177,6 +164,9 @@ declare class Arri {
|
|
|
177
164
|
private procedures;
|
|
178
165
|
private models;
|
|
179
166
|
private readonly middlewares;
|
|
167
|
+
private readonly onAfterResponse;
|
|
168
|
+
private readonly onBeforeResponse;
|
|
169
|
+
private readonly onError;
|
|
180
170
|
constructor(opts?: ArriOptions);
|
|
181
171
|
registerMiddleware(middleware: Middleware): void;
|
|
182
172
|
registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
|
|
@@ -184,6 +174,23 @@ declare class Arri {
|
|
|
184
174
|
getAppDefinition(): ApplicationDef;
|
|
185
175
|
getH3Instance(): App;
|
|
186
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
|
+
}
|
|
187
194
|
declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
|
|
188
195
|
type HttpMethod = (typeof HttpMethodValues)[number];
|
|
189
196
|
declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
@@ -195,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
|
|
|
195
202
|
type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
|
|
196
203
|
declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
|
|
197
204
|
|
|
198
|
-
export {
|
|
205
|
+
export { type JsonSchemaScalarType as $, Arri 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 _, DEV_DEFINITION_ENDPOINT 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, type ArriOptions as b, type HttpMethod as c, type ArriProcedureBase as d, type ArriProcedure as e, type HandlerContext as f, type RpcPostHandlerContext as g, type ArriProcedureHandler as h, isHttpMethod as i, type ArriProcedurePostHandler as j, isRpc as k, defineRpc as l, createRpcDefinition as m, getRpcPath as n, getRpcParamName as o, getRpcParamDefinition as p, getRpcResponseName as q, registerRpc as r, type ArriRoute as s, defineRoute as t, defineMiddleware as u, type ExtractParams as v, type ArriRouteHandler as w, type RouteHandlerContext as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
|