arri 0.1.0-beta.5 → 0.1.0-beta.7

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 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.ab9313ca.cjs');
14
+ const config = require('./shared/arri.eea9df0a.cjs');
15
15
  const globby = require('globby');
16
16
  const scule = require('scule');
17
17
  const arriCodegenDart = require('arri-codegen-dart');
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 { m as defaultConfig, l as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.b5addda0.mjs';
13
+ import { m as defaultConfig, l as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.16b8531c.mjs';
14
14
  import { globby } from 'globby';
15
15
  import { camelCase, kebabCase } from 'scule';
16
16
  import { dartClientGenerator } from 'arri-codegen-dart';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./shared/arri.ab9313ca.cjs');
3
+ const config = require('./shared/arri.eea9df0a.cjs');
4
4
  const h3 = require('h3');
5
5
  require('arri-validate');
6
6
  require('arri-codegen-utils');
@@ -17,15 +17,18 @@ exports.createRpcDefinition = config.createRpcDefinition;
17
17
  exports.defaultConfig = config.defaultConfig;
18
18
  exports.defineConfig = config.defineConfig;
19
19
  exports.defineError = config.defineError;
20
+ exports.defineRoute = config.defineRoute;
20
21
  exports.defineRpc = config.defineRpc;
21
22
  exports.errorResponseFromValidationErrors = config.errorResponseFromValidationErrors;
22
23
  exports.getRpcParamName = config.getRpcParamName;
23
24
  exports.getRpcPath = config.getRpcPath;
24
25
  exports.getRpcResponseName = config.getRpcResponseName;
25
26
  exports.handleH3Error = config.handleH3Error;
27
+ exports.handleRoute = config.handleRoute;
26
28
  exports.isArriConfig = config.isArriConfig;
27
29
  exports.isResolvedArriConfig = config.isResolvedArriConfig;
28
30
  exports.isRpc = config.isRpc;
31
+ exports.registerRoute = config.registerRoute;
29
32
  exports.registerRpc = config.registerRpc;
30
33
  exports.defineMiddleware = defineMiddleware;
31
34
  Object.keys(h3).forEach(function (k) {
package/dist/index.d.cts CHANGED
@@ -13,11 +13,9 @@ interface MiddlewareEvent extends H3Event {
13
13
  }
14
14
  type Middleware = (event: MiddlewareEvent) => void | Promise<void>;
15
15
  declare const defineMiddleware: (middleware: Middleware) => Middleware;
16
- type ExtractParam$1<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
17
- type ExtractParams$1<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam$1<Segment, ExtractParams$1<Rest>> : ExtractParam$1<Path, {}>;
18
-
19
16
  type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
20
17
  type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
18
+
21
19
  interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
22
20
  params: ExtractParams<TPath>;
23
21
  query: TQuery;
@@ -40,9 +38,12 @@ interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any>
40
38
  handler: (event: RouteEvent<TPath, InferType<TQuery>, InferType<TBody>>) => TResponse;
41
39
  postHandler?: (event: PostRouteEvent<TPath, InferType<TQuery>, InferType<TBody>, Awaited<TResponse>>) => any;
42
40
  }
41
+ declare function defineRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends AObjectSchema<any, any> = any, TResponse = any>(route: ArriRoute<TPath, TQuery, TBody, TResponse>): ArriRoute<TPath, TQuery, TBody, TResponse>;
43
42
  type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "onError" | "onRequest"> & {
44
43
  middleware: Middleware[];
45
44
  };
45
+ declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
46
+ declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
46
47
 
47
48
  interface ArriProcedure<TParams extends AObjectSchema | undefined, TResponse extends AObjectSchema | undefined> {
48
49
  description?: string;
@@ -167,4 +168,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
167
168
  declare const defaultConfig: Required<ArriConfig>;
168
169
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
169
170
 
170
- export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam$1 as ExtractParam, type ExtractParams$1 as ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ResolvedArriConfig, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, isArriConfig, isResolvedArriConfig, isRpc, registerRpc };
171
+ 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 };
package/dist/index.d.mts CHANGED
@@ -13,11 +13,9 @@ interface MiddlewareEvent extends H3Event {
13
13
  }
14
14
  type Middleware = (event: MiddlewareEvent) => void | Promise<void>;
15
15
  declare const defineMiddleware: (middleware: Middleware) => Middleware;
16
- type ExtractParam$1<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
17
- type ExtractParams$1<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam$1<Segment, ExtractParams$1<Rest>> : ExtractParam$1<Path, {}>;
18
-
19
16
  type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
20
17
  type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
18
+
21
19
  interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
22
20
  params: ExtractParams<TPath>;
23
21
  query: TQuery;
@@ -40,9 +38,12 @@ interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any>
40
38
  handler: (event: RouteEvent<TPath, InferType<TQuery>, InferType<TBody>>) => TResponse;
41
39
  postHandler?: (event: PostRouteEvent<TPath, InferType<TQuery>, InferType<TBody>, Awaited<TResponse>>) => any;
42
40
  }
41
+ declare function defineRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends AObjectSchema<any, any> = any, TResponse = any>(route: ArriRoute<TPath, TQuery, TBody, TResponse>): ArriRoute<TPath, TQuery, TBody, TResponse>;
43
42
  type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "onError" | "onRequest"> & {
44
43
  middleware: Middleware[];
45
44
  };
45
+ declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
46
+ declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
46
47
 
47
48
  interface ArriProcedure<TParams extends AObjectSchema | undefined, TResponse extends AObjectSchema | undefined> {
48
49
  description?: string;
@@ -167,4 +168,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
167
168
  declare const defaultConfig: Required<ArriConfig>;
168
169
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
169
170
 
170
- export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam$1 as ExtractParam, type ExtractParams$1 as ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ResolvedArriConfig, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, isArriConfig, isResolvedArriConfig, isRpc, registerRpc };
171
+ 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 };
package/dist/index.d.ts CHANGED
@@ -13,11 +13,9 @@ interface MiddlewareEvent extends H3Event {
13
13
  }
14
14
  type Middleware = (event: MiddlewareEvent) => void | Promise<void>;
15
15
  declare const defineMiddleware: (middleware: Middleware) => Middleware;
16
- type ExtractParam$1<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
17
- type ExtractParams$1<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam$1<Segment, ExtractParams$1<Rest>> : ExtractParam$1<Path, {}>;
18
-
19
16
  type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
20
17
  type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
18
+
21
19
  interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
22
20
  params: ExtractParams<TPath>;
23
21
  query: TQuery;
@@ -40,9 +38,12 @@ interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any>
40
38
  handler: (event: RouteEvent<TPath, InferType<TQuery>, InferType<TBody>>) => TResponse;
41
39
  postHandler?: (event: PostRouteEvent<TPath, InferType<TQuery>, InferType<TBody>, Awaited<TResponse>>) => any;
42
40
  }
41
+ declare function defineRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends AObjectSchema<any, any> = any, TResponse = any>(route: ArriRoute<TPath, TQuery, TBody, TResponse>): ArriRoute<TPath, TQuery, TBody, TResponse>;
43
42
  type RouteOptions = Pick<ArriOptions, "onAfterResponse" | "onBeforeResponse" | "onError" | "onRequest"> & {
44
43
  middleware: Middleware[];
45
44
  };
45
+ declare function registerRoute(router: Router, route: ArriRoute<any>, opts: RouteOptions): void;
46
+ declare function handleRoute(router: Router, method: HttpMethod, route: ArriRoute<any>, opts: RouteOptions): void;
46
47
 
47
48
  interface ArriProcedure<TParams extends AObjectSchema | undefined, TResponse extends AObjectSchema | undefined> {
48
49
  description?: string;
@@ -167,4 +168,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
167
168
  declare const defaultConfig: Required<ArriConfig>;
168
169
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
169
170
 
170
- export { ArriApp, type ArriConfig, type ArriNamedProcedure, type ArriOptions, type ArriProcedure, type ArriProcedureHandler, type ArriProcedurePostHandler, ArriRouter, type ArriRouterBase, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, ErrorResponse, type ExtractParam$1 as ExtractParam, type ExtractParams$1 as ExtractParams, type HandlerContext, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ResolvedArriConfig, type RpcEvent, type RpcHandlerContext, type RpcPostEvent, type RpcPostHandlerContext, type StatusCode, createRpcDefinition, defaultConfig, defineConfig, defineError, defineMiddleware, defineRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, isArriConfig, isResolvedArriConfig, isRpc, registerRpc };
171
+ 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 };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as ArriApp, o as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, c as createRpcDefinition, m as defaultConfig, n as defineConfig, f as defineError, d as defineRpc, h as errorResponseFromValidationErrors, b as getRpcParamName, g as getRpcPath, e as getRpcResponseName, j as handleH3Error, k as isArriConfig, l as isResolvedArriConfig, i as isRpc, r as registerRpc } from './shared/arri.b5addda0.mjs';
1
+ export { A as ArriApp, o as ArriRouter, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, c as createRpcDefinition, m as defaultConfig, n as defineConfig, f as defineError, p as defineRoute, d as defineRpc, h as errorResponseFromValidationErrors, b as getRpcParamName, g as getRpcPath, e as getRpcResponseName, j as handleH3Error, s as handleRoute, k as isArriConfig, l as isResolvedArriConfig, i as isRpc, q as registerRoute, r as registerRpc } from './shared/arri.16b8531c.mjs';
2
2
  export * from 'h3';
3
3
  import 'arri-validate';
4
4
  import 'arri-codegen-utils';
@@ -430,6 +430,9 @@ class ArriRouter {
430
430
  }
431
431
  }
432
432
 
433
+ function defineRoute(route) {
434
+ return route;
435
+ }
433
436
  function registerRoute(router, route, opts) {
434
437
  if (typeof route.method === "string") {
435
438
  handleRoute(router, route.method, route, opts);
@@ -722,4 +725,4 @@ function defineConfig(config) {
722
725
  };
723
726
  }
724
727
 
725
- export { ArriApp as A, DEV_ENDPOINT_ROOT as D, ErrorResponse as E, DEV_DEFINITION_ENDPOINT as a, getRpcParamName as b, createRpcDefinition as c, defineRpc as d, getRpcResponseName as e, defineError as f, getRpcPath as g, errorResponseFromValidationErrors as h, isRpc as i, handleH3Error as j, isArriConfig as k, isResolvedArriConfig as l, defaultConfig as m, defineConfig as n, ArriRouter as o, registerRpc as r };
728
+ export { ArriApp as A, DEV_ENDPOINT_ROOT as D, ErrorResponse as E, DEV_DEFINITION_ENDPOINT as a, getRpcParamName as b, createRpcDefinition as c, defineRpc as d, getRpcResponseName as e, defineError as f, getRpcPath as g, errorResponseFromValidationErrors as h, isRpc as i, handleH3Error as j, isArriConfig as k, isResolvedArriConfig as l, defaultConfig as m, defineConfig as n, ArriRouter as o, defineRoute as p, registerRoute as q, registerRpc as r, handleRoute as s };
@@ -432,6 +432,9 @@ class ArriRouter {
432
432
  }
433
433
  }
434
434
 
435
+ function defineRoute(route) {
436
+ return route;
437
+ }
435
438
  function registerRoute(router, route, opts) {
436
439
  if (typeof route.method === "string") {
437
440
  handleRoute(router, route.method, route, opts);
@@ -733,13 +736,16 @@ exports.createRpcDefinition = createRpcDefinition;
733
736
  exports.defaultConfig = defaultConfig;
734
737
  exports.defineConfig = defineConfig;
735
738
  exports.defineError = defineError;
739
+ exports.defineRoute = defineRoute;
736
740
  exports.defineRpc = defineRpc;
737
741
  exports.errorResponseFromValidationErrors = errorResponseFromValidationErrors;
738
742
  exports.getRpcParamName = getRpcParamName;
739
743
  exports.getRpcPath = getRpcPath;
740
744
  exports.getRpcResponseName = getRpcResponseName;
741
745
  exports.handleH3Error = handleH3Error;
746
+ exports.handleRoute = handleRoute;
742
747
  exports.isArriConfig = isArriConfig;
743
748
  exports.isResolvedArriConfig = isResolvedArriConfig;
744
749
  exports.isRpc = isRpc;
750
+ exports.registerRoute = registerRoute;
745
751
  exports.registerRpc = registerRpc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0-beta.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -31,10 +31,10 @@
31
31
  "pathe": "^1.1.1",
32
32
  "prettier": "^3.0.3",
33
33
  "scule": "^1.0.0",
34
- "arri-codegen-dart": "0.1.0-beta.5",
35
- "arri-codegen-utils": "0.1.0-beta.5",
36
- "arri-validate": "0.1.0-beta.5",
37
- "arri-codegen-ts": "0.1.0-beta.5"
34
+ "arri-validate": "0.1.0-beta.7",
35
+ "arri-codegen-utils": "0.1.0-beta.7",
36
+ "arri-codegen-ts": "0.1.0-beta.7",
37
+ "arri-codegen-dart": "0.1.0-beta.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "bun-types": "^1.0.5"