arri 0.6.0 → 0.7.0
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/cli.cjs +2 -3
- package/dist/cli.mjs +2 -3
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +9 -7
- package/dist/index.d.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.458d7a5c.cjs → arri.3b472e3d.cjs} +11 -7
- package/dist/shared/{arri.f6cbbd0d.mjs → arri.b635ea35.mjs} +11 -8
- package/package.json +6 -6
package/dist/cli.cjs
CHANGED
|
@@ -11,7 +11,7 @@ const consola = require('consola');
|
|
|
11
11
|
const esbuild = require('esbuild');
|
|
12
12
|
const path = require('pathe');
|
|
13
13
|
const prettier = require('prettier');
|
|
14
|
-
const config = require('./shared/arri.
|
|
14
|
+
const config = require('./shared/arri.3b472e3d.cjs');
|
|
15
15
|
const globby = require('globby');
|
|
16
16
|
const scule = require('scule');
|
|
17
17
|
const arriCodegenDart = require('arri-codegen-dart');
|
|
@@ -19,8 +19,8 @@ const ofetch = require('ofetch');
|
|
|
19
19
|
const chokidar = require('chokidar');
|
|
20
20
|
const listhen = require('listhen');
|
|
21
21
|
const Degit = require('degit');
|
|
22
|
-
require('arri-validate');
|
|
23
22
|
require('h3');
|
|
23
|
+
require('arri-validate');
|
|
24
24
|
|
|
25
25
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
26
26
|
|
|
@@ -237,7 +237,6 @@ async function bundleFiles(config, allowCodegen = true) {
|
|
|
237
237
|
platform: config.esbuild.platform ?? "node",
|
|
238
238
|
target: config.esbuild.target ?? "node18",
|
|
239
239
|
bundle: true,
|
|
240
|
-
packages: "external",
|
|
241
240
|
format: "esm",
|
|
242
241
|
sourcemap: false,
|
|
243
242
|
minifyWhitespace: true,
|
package/dist/cli.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import * as esbuild from 'esbuild';
|
|
|
10
10
|
import { build as build$1 } from 'esbuild';
|
|
11
11
|
import path from 'pathe';
|
|
12
12
|
import prettier from 'prettier';
|
|
13
|
-
import {
|
|
13
|
+
import { n as defaultConfig, m as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.b635ea35.mjs';
|
|
14
14
|
import { globby } from 'globby';
|
|
15
15
|
import { camelCase, kebabCase } from 'scule';
|
|
16
16
|
import { dartClientGenerator } from 'arri-codegen-dart';
|
|
@@ -18,8 +18,8 @@ import { ofetch } from 'ofetch';
|
|
|
18
18
|
import chokidar from 'chokidar';
|
|
19
19
|
import { listenAndWatch } from 'listhen';
|
|
20
20
|
import Degit from 'degit';
|
|
21
|
-
import 'arri-validate';
|
|
22
21
|
import 'h3';
|
|
22
|
+
import 'arri-validate';
|
|
23
23
|
|
|
24
24
|
async function setupWorkingDir(config) {
|
|
25
25
|
const arriDir = path.resolve(config.rootDir, config.buildDir);
|
|
@@ -213,7 +213,6 @@ async function bundleFiles(config, allowCodegen = true) {
|
|
|
213
213
|
platform: config.esbuild.platform ?? "node",
|
|
214
214
|
target: config.esbuild.target ?? "node18",
|
|
215
215
|
bundle: true,
|
|
216
|
-
packages: "external",
|
|
217
216
|
format: "esm",
|
|
218
217
|
sourcemap: false,
|
|
219
218
|
minifyWhitespace: true,
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/arri.
|
|
3
|
+
const config = require('./shared/arri.3b472e3d.cjs');
|
|
4
4
|
const h3 = require('h3');
|
|
5
5
|
require('arri-validate');
|
|
6
6
|
require('arri-codegen-utils');
|
|
@@ -28,6 +28,7 @@ exports.handleRoute = config.handleRoute;
|
|
|
28
28
|
exports.isArriConfig = config.isArriConfig;
|
|
29
29
|
exports.isResolvedArriConfig = config.isResolvedArriConfig;
|
|
30
30
|
exports.isRpc = config.isRpc;
|
|
31
|
+
exports.isRpcParamSchema = config.isRpcParamSchema;
|
|
31
32
|
exports.registerRoute = config.registerRoute;
|
|
32
33
|
exports.registerRpc = config.registerRpc;
|
|
33
34
|
exports.defineMiddleware = defineMiddleware;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpMethod, RpcDefinition, AppDefinition, ClientGenerator } from 'arri-codegen-utils';
|
|
2
|
-
import { AObjectSchema, ASchema, InferType, a, ValidationError } from 'arri-validate';
|
|
2
|
+
import { AObjectSchema, ASchema, InferType, ARecordSchema, ADiscriminatorSchema, a, ValidationError } from 'arri-validate';
|
|
3
3
|
import { H3EventContext, H3Event, Router, App, H3Error } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { BuildOptions } from 'esbuild';
|
|
@@ -44,16 +44,18 @@ type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "
|
|
|
44
44
|
declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
45
45
|
declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
type RpcParamSchema<TObjectInner = any, TRecordInner extends ASchema = any, TDiscriminatorInner = any> = AObjectSchema<TObjectInner> | ARecordSchema<TRecordInner> | ADiscriminatorSchema<TDiscriminatorInner>;
|
|
48
|
+
declare function isRpcParamSchema(input: unknown): input is RpcParamSchema;
|
|
49
|
+
interface ArriProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> {
|
|
48
50
|
description?: string;
|
|
49
51
|
method?: HttpMethod;
|
|
50
52
|
path?: string;
|
|
51
53
|
params: TParams;
|
|
52
54
|
response: TResponse;
|
|
53
|
-
handler: ArriProcedureHandler<TParams extends
|
|
54
|
-
postHandler?: ArriProcedurePostHandler<TParams extends
|
|
55
|
+
handler: ArriProcedureHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
|
|
56
|
+
postHandler?: ArriProcedurePostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
55
57
|
}
|
|
56
|
-
interface ArriNamedProcedure<TParams extends
|
|
58
|
+
interface ArriNamedProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> extends ArriProcedure<TParams, TResponse> {
|
|
57
59
|
name: string;
|
|
58
60
|
}
|
|
59
61
|
type HandlerContext = Record<string, any>;
|
|
@@ -73,7 +75,7 @@ interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<
|
|
|
73
75
|
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
74
76
|
type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
75
77
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
76
|
-
declare function defineRpc<TParams extends
|
|
78
|
+
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
77
79
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): RpcDefinition;
|
|
78
80
|
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
79
81
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | undefined;
|
|
@@ -167,4 +169,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
167
169
|
declare const defaultConfig: Required<ArriConfig>;
|
|
168
170
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
169
171
|
|
|
170
|
-
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, registerRoute, registerRpc };
|
|
172
|
+
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcParamSchema, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, isRpcParamSchema, registerRoute, registerRpc };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpMethod, RpcDefinition, AppDefinition, ClientGenerator } from 'arri-codegen-utils';
|
|
2
|
-
import { AObjectSchema, ASchema, InferType, a, ValidationError } from 'arri-validate';
|
|
2
|
+
import { AObjectSchema, ASchema, InferType, ARecordSchema, ADiscriminatorSchema, a, ValidationError } from 'arri-validate';
|
|
3
3
|
import { H3EventContext, H3Event, Router, App, H3Error } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { BuildOptions } from 'esbuild';
|
|
@@ -44,16 +44,18 @@ type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "
|
|
|
44
44
|
declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
45
45
|
declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
type RpcParamSchema<TObjectInner = any, TRecordInner extends ASchema = any, TDiscriminatorInner = any> = AObjectSchema<TObjectInner> | ARecordSchema<TRecordInner> | ADiscriminatorSchema<TDiscriminatorInner>;
|
|
48
|
+
declare function isRpcParamSchema(input: unknown): input is RpcParamSchema;
|
|
49
|
+
interface ArriProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> {
|
|
48
50
|
description?: string;
|
|
49
51
|
method?: HttpMethod;
|
|
50
52
|
path?: string;
|
|
51
53
|
params: TParams;
|
|
52
54
|
response: TResponse;
|
|
53
|
-
handler: ArriProcedureHandler<TParams extends
|
|
54
|
-
postHandler?: ArriProcedurePostHandler<TParams extends
|
|
55
|
+
handler: ArriProcedureHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
|
|
56
|
+
postHandler?: ArriProcedurePostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
55
57
|
}
|
|
56
|
-
interface ArriNamedProcedure<TParams extends
|
|
58
|
+
interface ArriNamedProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> extends ArriProcedure<TParams, TResponse> {
|
|
57
59
|
name: string;
|
|
58
60
|
}
|
|
59
61
|
type HandlerContext = Record<string, any>;
|
|
@@ -73,7 +75,7 @@ interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<
|
|
|
73
75
|
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
74
76
|
type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
75
77
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
76
|
-
declare function defineRpc<TParams extends
|
|
78
|
+
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
77
79
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): RpcDefinition;
|
|
78
80
|
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
79
81
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | undefined;
|
|
@@ -167,4 +169,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
167
169
|
declare const defaultConfig: Required<ArriConfig>;
|
|
168
170
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
169
171
|
|
|
170
|
-
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, registerRoute, registerRpc };
|
|
172
|
+
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcParamSchema, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, isRpcParamSchema, registerRoute, registerRpc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpMethod, RpcDefinition, AppDefinition, ClientGenerator } from 'arri-codegen-utils';
|
|
2
|
-
import { AObjectSchema, ASchema, InferType, a, ValidationError } from 'arri-validate';
|
|
2
|
+
import { AObjectSchema, ASchema, InferType, ARecordSchema, ADiscriminatorSchema, a, ValidationError } from 'arri-validate';
|
|
3
3
|
import { H3EventContext, H3Event, Router, App, H3Error } from 'h3';
|
|
4
4
|
export * from 'h3';
|
|
5
5
|
import { BuildOptions } from 'esbuild';
|
|
@@ -44,16 +44,18 @@ type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "
|
|
|
44
44
|
declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
45
45
|
declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
type RpcParamSchema<TObjectInner = any, TRecordInner extends ASchema = any, TDiscriminatorInner = any> = AObjectSchema<TObjectInner> | ARecordSchema<TRecordInner> | ADiscriminatorSchema<TDiscriminatorInner>;
|
|
48
|
+
declare function isRpcParamSchema(input: unknown): input is RpcParamSchema;
|
|
49
|
+
interface ArriProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> {
|
|
48
50
|
description?: string;
|
|
49
51
|
method?: HttpMethod;
|
|
50
52
|
path?: string;
|
|
51
53
|
params: TParams;
|
|
52
54
|
response: TResponse;
|
|
53
|
-
handler: ArriProcedureHandler<TParams extends
|
|
54
|
-
postHandler?: ArriProcedurePostHandler<TParams extends
|
|
55
|
+
handler: ArriProcedureHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : void>;
|
|
56
|
+
postHandler?: ArriProcedurePostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
55
57
|
}
|
|
56
|
-
interface ArriNamedProcedure<TParams extends
|
|
58
|
+
interface ArriNamedProcedure<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> extends ArriProcedure<TParams, TResponse> {
|
|
57
59
|
name: string;
|
|
58
60
|
}
|
|
59
61
|
type HandlerContext = Record<string, any>;
|
|
@@ -73,7 +75,7 @@ interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<
|
|
|
73
75
|
type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
74
76
|
type ArriProcedurePostHandler<TParams, TResponse> = (context: RpcPostHandlerContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
75
77
|
declare function isRpc(input: any): input is ArriProcedure<any, any>;
|
|
76
|
-
declare function defineRpc<TParams extends
|
|
78
|
+
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
|
|
77
79
|
declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): RpcDefinition;
|
|
78
80
|
declare function getRpcPath(rpcName: string, prefix?: string): string;
|
|
79
81
|
declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | undefined;
|
|
@@ -167,4 +169,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
167
169
|
declare const defaultConfig: Required<ArriConfig>;
|
|
168
170
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
169
171
|
|
|
170
|
-
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, registerRoute, registerRpc };
|
|
172
|
+
export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, type ArriRoute, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam, type ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type PostRouteEvent, type PostRouteEventContext, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RpcEvent, type RpcHandlerContext, type RpcParamSchema, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRoute, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isResolvedArriConfig, isRpc, isRpcParamSchema, registerRoute, registerRpc };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ArriApp,
|
|
1
|
+
export { A as ArriApp, p as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, c as createRpcDefinition, n as defaultConfig, o as defineConfig, h as defineError, q as defineRoute, d as defineRpc, j as errorResponseFromValidationErrors, e as getRpcParamName, g as getRpcPath, f as getRpcResponseName, k as handleH3Error, t as handleRoute, l as isArriConfig, m as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, s as registerRoute, r as registerRpc } from './shared/arri.b635ea35.mjs';
|
|
2
2
|
export * from 'h3';
|
|
3
3
|
import 'arri-validate';
|
|
4
4
|
import 'arri-codegen-utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const arriValidate = require('arri-validate');
|
|
4
3
|
const h3 = require('h3');
|
|
4
|
+
const arriValidate = require('arri-validate');
|
|
5
5
|
const arriCodegenUtils = require('arri-codegen-utils');
|
|
6
6
|
const scule = require('scule');
|
|
7
7
|
|
|
@@ -206,6 +206,9 @@ async function handleH3Error(err, event, onError) {
|
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
function isRpcParamSchema(input) {
|
|
210
|
+
return arriValidate.isAObjectSchema(input) || arriValidate.isARecordSchema(input) || arriValidate.isADiscriminatorSchema(input);
|
|
211
|
+
}
|
|
209
212
|
function isRpc(input) {
|
|
210
213
|
if (typeof input !== "object") {
|
|
211
214
|
return false;
|
|
@@ -242,7 +245,7 @@ function getRpcPath(rpcName, prefix = "") {
|
|
|
242
245
|
return finalPath;
|
|
243
246
|
}
|
|
244
247
|
function getRpcParamName(rpcName, procedure) {
|
|
245
|
-
if (!
|
|
248
|
+
if (!isRpcParamSchema(procedure.params)) {
|
|
246
249
|
return void 0;
|
|
247
250
|
}
|
|
248
251
|
const nameParts = rpcName.split(".").map(
|
|
@@ -252,7 +255,7 @@ function getRpcParamName(rpcName, procedure) {
|
|
|
252
255
|
return paramName;
|
|
253
256
|
}
|
|
254
257
|
function getRpcResponseName(rpcName, procedure) {
|
|
255
|
-
if (!
|
|
258
|
+
if (!isRpcParamSchema(procedure.response)) {
|
|
256
259
|
return void 0;
|
|
257
260
|
}
|
|
258
261
|
const nameParts = rpcName.split(".").map(
|
|
@@ -262,7 +265,7 @@ function getRpcResponseName(rpcName, procedure) {
|
|
|
262
265
|
return responseName;
|
|
263
266
|
}
|
|
264
267
|
function getRpcResponseDefinition(rpcName, procedure) {
|
|
265
|
-
if (!
|
|
268
|
+
if (!isRpcParamSchema(procedure.response)) {
|
|
266
269
|
return void 0;
|
|
267
270
|
}
|
|
268
271
|
const name = getRpcResponseName(rpcName, procedure);
|
|
@@ -293,7 +296,7 @@ function registerRpc(router, path, procedure, opts) {
|
|
|
293
296
|
await m(event);
|
|
294
297
|
}
|
|
295
298
|
}
|
|
296
|
-
if (
|
|
299
|
+
if (isRpcParamSchema(procedure.params)) {
|
|
297
300
|
switch (httpMethod) {
|
|
298
301
|
case "get":
|
|
299
302
|
case "head": {
|
|
@@ -651,13 +654,13 @@ class ArriApp {
|
|
|
651
654
|
path,
|
|
652
655
|
procedure
|
|
653
656
|
);
|
|
654
|
-
if (
|
|
657
|
+
if (isRpcParamSchema(procedure.params)) {
|
|
655
658
|
const paramName = getRpcParamName(procedure.name, procedure);
|
|
656
659
|
if (paramName) {
|
|
657
660
|
this.models[paramName] = procedure.params;
|
|
658
661
|
}
|
|
659
662
|
}
|
|
660
|
-
if (
|
|
663
|
+
if (isRpcParamSchema(procedure.response)) {
|
|
661
664
|
const responseName = getRpcResponseName(procedure.name, procedure);
|
|
662
665
|
if (responseName) {
|
|
663
666
|
this.models[responseName] = procedure.response;
|
|
@@ -752,5 +755,6 @@ exports.handleRoute = handleRoute;
|
|
|
752
755
|
exports.isArriConfig = isArriConfig;
|
|
753
756
|
exports.isResolvedArriConfig = isResolvedArriConfig;
|
|
754
757
|
exports.isRpc = isRpc;
|
|
758
|
+
exports.isRpcParamSchema = isRpcParamSchema;
|
|
755
759
|
exports.registerRoute = registerRoute;
|
|
756
760
|
exports.registerRpc = registerRpc;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, isAObjectSchema } from 'arri-validate';
|
|
2
1
|
import { createError, isError, setResponseStatus, send, eventHandler, isPreflightRequest, readRawBody, getValidatedQuery, setResponseHeader, defineEventHandler, getQuery, setHeader, createRouter, createApp, sendError } from 'h3';
|
|
2
|
+
import { a, isAObjectSchema, isARecordSchema, isADiscriminatorSchema } from 'arri-validate';
|
|
3
3
|
import { isHttpMethod, removeDisallowedChars } from 'arri-codegen-utils';
|
|
4
4
|
import { kebabCase, pascalCase } from 'scule';
|
|
5
5
|
|
|
@@ -204,6 +204,9 @@ async function handleH3Error(err, event, onError) {
|
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
function isRpcParamSchema(input) {
|
|
208
|
+
return isAObjectSchema(input) || isARecordSchema(input) || isADiscriminatorSchema(input);
|
|
209
|
+
}
|
|
207
210
|
function isRpc(input) {
|
|
208
211
|
if (typeof input !== "object") {
|
|
209
212
|
return false;
|
|
@@ -240,7 +243,7 @@ function getRpcPath(rpcName, prefix = "") {
|
|
|
240
243
|
return finalPath;
|
|
241
244
|
}
|
|
242
245
|
function getRpcParamName(rpcName, procedure) {
|
|
243
|
-
if (!
|
|
246
|
+
if (!isRpcParamSchema(procedure.params)) {
|
|
244
247
|
return void 0;
|
|
245
248
|
}
|
|
246
249
|
const nameParts = rpcName.split(".").map(
|
|
@@ -250,7 +253,7 @@ function getRpcParamName(rpcName, procedure) {
|
|
|
250
253
|
return paramName;
|
|
251
254
|
}
|
|
252
255
|
function getRpcResponseName(rpcName, procedure) {
|
|
253
|
-
if (!
|
|
256
|
+
if (!isRpcParamSchema(procedure.response)) {
|
|
254
257
|
return void 0;
|
|
255
258
|
}
|
|
256
259
|
const nameParts = rpcName.split(".").map(
|
|
@@ -260,7 +263,7 @@ function getRpcResponseName(rpcName, procedure) {
|
|
|
260
263
|
return responseName;
|
|
261
264
|
}
|
|
262
265
|
function getRpcResponseDefinition(rpcName, procedure) {
|
|
263
|
-
if (!
|
|
266
|
+
if (!isRpcParamSchema(procedure.response)) {
|
|
264
267
|
return void 0;
|
|
265
268
|
}
|
|
266
269
|
const name = getRpcResponseName(rpcName, procedure);
|
|
@@ -291,7 +294,7 @@ function registerRpc(router, path, procedure, opts) {
|
|
|
291
294
|
await m(event);
|
|
292
295
|
}
|
|
293
296
|
}
|
|
294
|
-
if (
|
|
297
|
+
if (isRpcParamSchema(procedure.params)) {
|
|
295
298
|
switch (httpMethod) {
|
|
296
299
|
case "get":
|
|
297
300
|
case "head": {
|
|
@@ -649,13 +652,13 @@ class ArriApp {
|
|
|
649
652
|
path,
|
|
650
653
|
procedure
|
|
651
654
|
);
|
|
652
|
-
if (
|
|
655
|
+
if (isRpcParamSchema(procedure.params)) {
|
|
653
656
|
const paramName = getRpcParamName(procedure.name, procedure);
|
|
654
657
|
if (paramName) {
|
|
655
658
|
this.models[paramName] = procedure.params;
|
|
656
659
|
}
|
|
657
660
|
}
|
|
658
|
-
if (
|
|
661
|
+
if (isRpcParamSchema(procedure.response)) {
|
|
659
662
|
const responseName = getRpcResponseName(procedure.name, procedure);
|
|
660
663
|
if (responseName) {
|
|
661
664
|
this.models[responseName] = procedure.response;
|
|
@@ -730,4 +733,4 @@ function defineConfig(config) {
|
|
|
730
733
|
};
|
|
731
734
|
}
|
|
732
735
|
|
|
733
|
-
export { ArriApp as A, DEV_ENDPOINT_ROOT as D, ErrorResponse as E, DEV_DEFINITION_ENDPOINT as a,
|
|
736
|
+
export { ArriApp as A, DEV_ENDPOINT_ROOT as D, ErrorResponse as E, DEV_DEFINITION_ENDPOINT as a, isRpc as b, createRpcDefinition as c, defineRpc as d, getRpcParamName as e, getRpcResponseName as f, getRpcPath as g, defineError as h, isRpcParamSchema as i, errorResponseFromValidationErrors as j, handleH3Error as k, isArriConfig as l, isResolvedArriConfig as m, defaultConfig as n, defineConfig as o, ArriRouter as p, defineRoute as q, registerRpc as r, registerRoute as s, handleRoute as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"esbuild": "^0.19.5",
|
|
26
26
|
"globby": "^13.2.2",
|
|
27
27
|
"h3": "^1.8.2",
|
|
28
|
-
"jiti": "^1.
|
|
28
|
+
"jiti": "^1.21.0",
|
|
29
29
|
"ofetch": "^1.3.3",
|
|
30
30
|
"pathe": "^1.1.1",
|
|
31
31
|
"prettier": "^3.0.3",
|
|
32
32
|
"scule": "^1.0.0",
|
|
33
|
-
"arri-codegen-dart": "0.
|
|
34
|
-
"arri-codegen-ts": "0.
|
|
35
|
-
"arri-
|
|
36
|
-
"arri-
|
|
33
|
+
"arri-codegen-dart": "0.7.0",
|
|
34
|
+
"arri-codegen-ts": "0.7.0",
|
|
35
|
+
"arri-validate": "0.7.0",
|
|
36
|
+
"arri-codegen-utils": "0.7.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"listhen": "1.x"
|