arri 0.0.30 → 0.0.33

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.
@@ -35,14 +35,14 @@ require('node:v8');
35
35
  require('consola');
36
36
  require('esbuild');
37
37
  require('prettier');
38
- require('../shared/arri.fb02cde0.cjs');
38
+ require('../shared/arri.a83bc214.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.6d256d98.cjs');
45
+ require('../shared/arri.aace9c55.cjs');
46
46
  require('child_process');
47
47
  require('listhen');
48
48
 
@@ -33,14 +33,14 @@ import 'node:v8';
33
33
  import 'consola';
34
34
  import 'esbuild';
35
35
  import 'prettier';
36
- import '../shared/arri.7d8427d5.mjs';
36
+ import '../shared/arri.76f7a6f9.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.edccaab8.mjs';
43
+ import '../shared/arri.984c232f.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.fb02cde0.cjs');
28
+ const app = require('./shared/arri.a83bc214.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.6d256d98.cjs');
36
+ const dart = require('./shared/arri.aace9c55.cjs');
37
37
  const listhen = require('listhen');
38
38
  require('child_process');
39
39
 
@@ -19950,13 +19950,13 @@ const build = citty.defineCommand({
19950
19950
  if (!config) {
19951
19951
  throw new Error("Unable to find arri config");
19952
19952
  }
19953
- await startBuild(config);
19953
+ await startBuild(config, args.skipCodegen);
19954
19954
  }
19955
19955
  });
19956
19956
  const logger$1 = consola.createConsola({
19957
19957
  fancy: true
19958
19958
  }).withTag("arri");
19959
- async function startBuild(config) {
19959
+ async function startBuild(config, skipCodeGen = false) {
19960
19960
  logger$1.log("Bundling server....");
19961
19961
  await setupWorkingDir(config);
19962
19962
  await Promise.all([
@@ -19973,7 +19973,7 @@ async function startBuild(config) {
19973
19973
  config.buildDir,
19974
19974
  "codegen.js"
19975
19975
  );
19976
- if (clientCount > 0) {
19976
+ if (clientCount > 0 && !skipCodeGen) {
19977
19977
  logger$1.log("Generating clients");
19978
19978
  node_child_process.execSync(`node ${codegenModule}`);
19979
19979
  const defJson = path__default$1.resolve(
@@ -20010,7 +20010,9 @@ async function bundleFiles$1(config) {
20010
20010
  sourcemap: true,
20011
20011
  minifyWhitespace: true,
20012
20012
  banner: {
20013
- js: "import { createRequire as topLevelCreateRequire } from 'module';\n const require = topLevelCreateRequire(import.meta.url);"
20013
+ js: `import { createRequire as topLevelCreateRequire } from 'module';
20014
+ const require = topLevelCreateRequire(import.meta.url);
20015
+ const __dirname = new URL(".", import.meta.url).pathname;`
20014
20016
  },
20015
20017
  outdir: path__default$1.resolve(config.rootDir, ".output")
20016
20018
  });
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.7d8427d5.mjs';
26
+ import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.76f7a6f9.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.edccaab8.mjs';
34
+ import { a as dartClientGenerator } from './shared/arri.984c232f.mjs';
35
35
  import { listenAndWatch } from 'listhen';
36
36
  import 'child_process';
37
37
 
@@ -19929,13 +19929,13 @@ const build = defineCommand({
19929
19929
  if (!config) {
19930
19930
  throw new Error("Unable to find arri config");
19931
19931
  }
19932
- await startBuild(config);
19932
+ await startBuild(config, args.skipCodegen);
19933
19933
  }
19934
19934
  });
19935
19935
  const logger$1 = createConsola({
19936
19936
  fancy: true
19937
19937
  }).withTag("arri");
19938
- async function startBuild(config) {
19938
+ async function startBuild(config, skipCodeGen = false) {
19939
19939
  logger$1.log("Bundling server....");
19940
19940
  await setupWorkingDir(config);
19941
19941
  await Promise.all([
@@ -19952,7 +19952,7 @@ async function startBuild(config) {
19952
19952
  config.buildDir,
19953
19953
  "codegen.js"
19954
19954
  );
19955
- if (clientCount > 0) {
19955
+ if (clientCount > 0 && !skipCodeGen) {
19956
19956
  logger$1.log("Generating clients");
19957
19957
  execSync(`node ${codegenModule}`);
19958
19958
  const defJson = path$e.resolve(
@@ -19989,7 +19989,9 @@ async function bundleFiles$1(config) {
19989
19989
  sourcemap: true,
19990
19990
  minifyWhitespace: true,
19991
19991
  banner: {
19992
- js: "import { createRequire as topLevelCreateRequire } from 'module';\n const require = topLevelCreateRequire(import.meta.url);"
19992
+ js: `import { createRequire as topLevelCreateRequire } from 'module';
19993
+ const require = topLevelCreateRequire(import.meta.url);
19994
+ const __dirname = new URL(".", import.meta.url).pathname;`
19993
19995
  },
19994
19996
  outdir: path$e.resolve(config.rootDir, ".output")
19995
19997
  });
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.fb02cde0.cjs');
6
- const dart = require('./shared/arri.6d256d98.cjs');
5
+ const app = require('./shared/arri.a83bc214.cjs');
6
+ const dart = require('./shared/arri.aace9c55.cjs');
7
7
  require('@sinclair/typebox');
8
8
  require('h3');
9
9
  require('@sinclair/typebox/errors');
@@ -1,5 +1,5 @@
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';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.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.36bc8896.cjs';
3
3
  import '@sinclair/typebox';
4
4
  import 'h3';
5
5
 
@@ -1,5 +1,5 @@
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';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.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.36bc8896.mjs';
3
3
  import '@sinclair/typebox';
4
4
  import 'h3';
5
5
 
package/dist/codegen.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { F as ClientGeneratorPlugin, G as ApplicationDef, S as ServiceDef, P as ProcedureDef, J as JsonSchemaObject } from './shared/arri.36bc8896.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.36bc8896.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.7d8427d5.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.7d8427d5.mjs';
5
- import { d as defineClientGeneratorPlugin } from './shared/arri.edccaab8.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.edccaab8.mjs';
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.76f7a6f9.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.76f7a6f9.mjs';
5
+ import { d as defineClientGeneratorPlugin } from './shared/arri.984c232f.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.984c232f.mjs';
7
7
  import '@sinclair/typebox';
8
8
  import 'h3';
9
9
  import '@sinclair/typebox/errors';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const app = require('./shared/arri.fb02cde0.cjs');
3
+ const app = require('./shared/arri.a83bc214.cjs');
4
4
  require('@sinclair/typebox');
5
5
  require('h3');
6
6
  require('@sinclair/typebox/errors');
@@ -46,6 +46,7 @@ exports.getRpcParamDefinition = app.getRpcParamDefinition;
46
46
  exports.getRpcParamName = app.getRpcParamName;
47
47
  exports.getRpcPath = app.getRpcPath;
48
48
  exports.getRpcResponseName = app.getRpcResponseName;
49
+ exports.handleH3Error = app.handleH3Error;
49
50
  exports.isHttpMethod = app.isHttpMethod;
50
51
  exports.isRpc = app.isRpc;
51
52
  exports.registerRoute = app.registerRoute;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
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';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.cjs';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.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';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
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';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.mjs';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.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';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
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';
1
+ import { R as RpcHandlerContext, a as RouteHandlerContext, A as ArriOptions, C as ClientGenerator } from './shared/arri.36bc8896.js';
2
+ export { c as Arri, f as ArriProcedure, e as ArriProcedureBase, j as ArriProcedureHandler, k as ArriProcedurePostHandler, t as ArriRoute, x as ArriRouteHandler, z as ArriRoutePostHandler, b as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, w as ExtractParams, g as HandlerContext, d as HttpMethod, H as HttpMethodValues, M as Middleware, y as RoutePostHandlerContext, h as RpcPostHandlerContext, n as createRpcDefinition, v as defineMiddleware, u as defineRoute, m as defineRpc, q as getRpcParamDefinition, p as getRpcParamName, o as getRpcPath, r as getRpcResponseName, i as isHttpMethod, l as isRpc, B as registerRoute, s as registerRpc } from './shared/arri.36bc8896.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';
6
- import { H3Error } from 'h3';
6
+ import { H3Error, H3Event } from 'h3';
7
7
  import { BuildOptions } from 'esbuild';
8
8
 
9
9
  declare const ErrorResponse: _sinclair_typebox.TObject<{
@@ -18,6 +18,7 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
18
18
  }): H3Error;
19
19
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
20
20
  type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ declare function handleH3Error(err: unknown, context: RpcHandlerContext | RouteHandlerContext<any>, event: H3Event, onError: ArriOptions["onError"]): Promise<void>;
21
22
 
22
23
  interface ArriConfig {
23
24
  port: number;
@@ -37,4 +38,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
37
38
  declare const defaultConfig: Required<ArriConfig>;
38
39
  declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
39
40
 
40
- export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors };
41
+ export { type ArriConfig, ArriOptions, ErrorResponse, type ResolvedArriConfig, RouteHandlerContext, RpcHandlerContext, type StatusCode, defaultConfig, defineConfig, defineError, errorResponseFromValidationErrors, handleH3Error };
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.7d8427d5.mjs';
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, N as handleH3Error, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.76f7a6f9.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 { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
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 };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
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 };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
- import { H3Event, Router, App, H3Error } from 'h3';
2
+ import { H3Event, Router, H3Error } from 'h3';
3
3
 
4
4
  interface ApplicationDef {
5
5
  arriSchemaVersion: "0.0.1";
@@ -172,7 +172,7 @@ declare class Arri {
172
172
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
173
173
  registerRoute<TPath extends string, TMethod extends HttpMethod = HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any>(route: ArriRoute<TPath, TMethod, TQuery, TBody, TResponse, TFallbackResponse>): void;
174
174
  getAppDefinition(): ApplicationDef;
175
- getH3Instance(): App;
175
+ getH3Instance(): void;
176
176
  }
177
177
  interface ArriOptions {
178
178
  debug?: boolean;
@@ -202,4 +202,4 @@ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
202
202
  type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
203
203
  declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
204
204
 
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 };
205
+ export { type JsonSchemaScalarType as $, type ArriOptions as A, registerRoute as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ClientGeneratorPlugin as F, type ApplicationDef as G, HttpMethodValues as H, defineClientGeneratorPlugin as I, type JsonSchemaObject as J, normalizeWhitespace as K, isProcedureDef as L, type Middleware as M, isServiceDef as N, isApplicationDef as O, type ProcedureDef as P, unflattenObject as Q, type RpcHandlerContext as R, type ServiceDef as S, unflattenProcedures as T, setNestedObjectProperty as U, removeDisallowedChars as V, JsonSchemaScalarTypeValues as W, JsonSchemaNullTypeValues as X, JsonSchemaComplexTypeValues as Y, type JsonSchemaType as Z, type JsonSchemaTypeValue as _, type RouteHandlerContext as a, isJsonSchemaScalarType as a0, type JsonSchemaNullType as a1, isJsonSchemaNullType as a2, type JsonSchemaComplexType as a3, isJsonSchemaObject as a4, type JsonSchemaRecord as a5, isJsonSchemaRecord as a6, type JsonSchemaArray as a7, isJsonSchemaArray as a8, type JsonSchemaUint8Array as a9, type JsonSchemaEnum as aa, isJsonSchemaEnum as ab, DEV_DEFINITION_ENDPOINT as b, Arri as c, type HttpMethod as d, type ArriProcedureBase as e, type ArriProcedure as f, type HandlerContext as g, type RpcPostHandlerContext as h, isHttpMethod as i, type ArriProcedureHandler as j, type ArriProcedurePostHandler as k, isRpc as l, defineRpc as m, createRpcDefinition as n, getRpcPath as o, getRpcParamName as p, getRpcParamDefinition as q, getRpcResponseName as r, registerRpc as s, type ArriRoute as t, defineRoute as u, defineMiddleware as v, type ExtractParams as w, type ArriRouteHandler as x, type RoutePostHandlerContext as y, type ArriRoutePostHandler as z };
@@ -1,5 +1,5 @@
1
1
  import { Type, TypeGuard } from '@sinclair/typebox';
2
- import { createError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, createRouter, createApp, getQuery, readBody, sendError } from 'h3';
2
+ import { createError, isError, setResponseStatus, sendError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, createRouter, createApp, getQuery, readBody } from 'h3';
3
3
  import { ValueErrorType } from '@sinclair/typebox/errors';
4
4
  import { Value } from '@sinclair/typebox/value';
5
5
 
@@ -185,6 +185,17 @@ const errorResponseDefaults = {
185
185
  message: "Network Authentication Required"
186
186
  }
187
187
  };
188
+ async function handleH3Error(err, context, event, onError) {
189
+ const error = isError(err) ? err : defineError(500, { data: err, stack: `${err}` });
190
+ setResponseStatus(event, error.statusCode);
191
+ if (onError) {
192
+ await onError(error, context, event);
193
+ }
194
+ if (event.handled) {
195
+ return;
196
+ }
197
+ sendError(event, error);
198
+ }
188
199
 
189
200
  const NUMBER_CHAR_RE = /\d/;
190
201
  const STR_SPLITTERS = ["-", "_", "/", "."];
@@ -618,9 +629,7 @@ function registerRpc(router, path, procedure, middleware, opts) {
618
629
  await procedure.postHandler(context, event);
619
630
  }
620
631
  } catch (err) {
621
- if (opts.onError) {
622
- await opts.onError(err, context, event);
623
- }
632
+ await handleH3Error(err, context, event, opts.onError);
624
633
  }
625
634
  return "";
626
635
  });
@@ -709,9 +718,7 @@ function registerRoute(router, route, middleware, prefix, opts) {
709
718
  await route.postHandler(context, event);
710
719
  }
711
720
  } catch (err) {
712
- if (opts?.onError) {
713
- await opts.onError(err, context, event);
714
- }
721
+ await handleH3Error(err, context, event, opts?.onError);
715
722
  }
716
723
  return "";
717
724
  });
@@ -786,6 +793,7 @@ class Arri {
786
793
  this.h3Router.use(
787
794
  "/**",
788
795
  eventHandler(async (event) => {
796
+ setResponseStatus(event, 404);
789
797
  const error = defineError(404);
790
798
  const query = getQuery(event);
791
799
  const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
@@ -803,23 +811,19 @@ class Arri {
803
811
  await m(context, event);
804
812
  }
805
813
  }
806
- } catch (_) {
814
+ } catch (err) {
815
+ await handleH3Error(err, context, event, this.onError);
816
+ }
817
+ if (event.handled) {
818
+ return;
807
819
  }
808
820
  if (this.onError) {
809
- await this.onError(
810
- error,
811
- {
812
- type: "route",
813
- params: void 0,
814
- query: void 0,
815
- body: void 0
816
- },
817
- event
818
- );
821
+ await this.onError(error, context, event);
819
822
  }
820
- if (!event.handled) {
821
- sendError(event, error);
823
+ if (event.handled) {
824
+ return;
822
825
  }
826
+ sendError(event, error);
823
827
  })
824
828
  );
825
829
  }
@@ -865,7 +869,6 @@ class Arri {
865
869
  return appDef;
866
870
  }
867
871
  getH3Instance() {
868
- return this.h3App;
869
872
  }
870
873
  }
871
874
  const HttpMethodValues = [
@@ -883,4 +886,4 @@ const isHttpMethod = (input) => {
883
886
  return HttpMethodValues.includes(input);
884
887
  };
885
888
 
886
- export { Arri as A, getRpcParamDefinition as B, getRpcResponseName as C, DEV_DEFINITION_ENDPOINT as D, registerRpc as E, defineRoute as F, defineMiddleware as G, HttpMethodValues as H, registerRoute as I, JsonSchemaScalarTypeValues as J, ErrorResponse as K, defineError as L, errorResponseFromValidationErrors as M, isProcedureDef as a, isJsonSchemaScalarType as b, isJsonSchemaNullType as c, isJsonSchemaObject as d, isJsonSchemaRecord as e, isJsonSchemaEnum as f, isJsonSchemaArray as g, unflattenProcedures as h, isServiceDef as i, camelCase as j, isApplicationDef as k, JsonSchemaNullTypeValues as l, JsonSchemaComplexTypeValues as m, normalizeWhitespace as n, kebabCase as o, pascalCase as p, DEV_ENDPOINT_ROOT as q, removeDisallowedChars as r, setNestedObjectProperty as s, isHttpMethod as t, unflattenObject as u, isRpc as v, defineRpc as w, createRpcDefinition as x, getRpcPath as y, getRpcParamName as z };
889
+ export { Arri as A, getRpcParamDefinition as B, getRpcResponseName as C, DEV_DEFINITION_ENDPOINT as D, registerRpc as E, defineRoute as F, defineMiddleware as G, HttpMethodValues as H, registerRoute as I, JsonSchemaScalarTypeValues as J, ErrorResponse as K, defineError as L, errorResponseFromValidationErrors as M, handleH3Error as N, isProcedureDef as a, isJsonSchemaScalarType as b, isJsonSchemaNullType as c, isJsonSchemaObject as d, isJsonSchemaRecord as e, isJsonSchemaEnum as f, isJsonSchemaArray as g, unflattenProcedures as h, isServiceDef as i, camelCase as j, isApplicationDef as k, JsonSchemaNullTypeValues as l, JsonSchemaComplexTypeValues as m, normalizeWhitespace as n, kebabCase as o, pascalCase as p, DEV_ENDPOINT_ROOT as q, removeDisallowedChars as r, setNestedObjectProperty as s, isHttpMethod as t, unflattenObject as u, isRpc as v, defineRpc as w, createRpcDefinition as x, getRpcPath as y, getRpcParamName as z };
@@ -1,6 +1,6 @@
1
1
  import { execSync } from 'child_process';
2
2
  import { writeFileSync } from 'fs';
3
- import { h as unflattenProcedures, i as isServiceDef, p as pascalCase, j as camelCase, a as isProcedureDef, d as isJsonSchemaObject, f as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, e as isJsonSchemaRecord, g as isJsonSchemaArray } from './arri.7d8427d5.mjs';
3
+ import { h as unflattenProcedures, i as isServiceDef, p as pascalCase, j as camelCase, a as isProcedureDef, d as isJsonSchemaObject, f as isJsonSchemaEnum, c as isJsonSchemaNullType, b as isJsonSchemaScalarType, e as isJsonSchemaRecord, g as isJsonSchemaArray } from './arri.76f7a6f9.mjs';
4
4
 
5
5
  function defineClientGeneratorPlugin(plugin) {
6
6
  return plugin;
@@ -187,6 +187,17 @@ const errorResponseDefaults = {
187
187
  message: "Network Authentication Required"
188
188
  }
189
189
  };
190
+ async function handleH3Error(err, context, event, onError) {
191
+ const error = h3.isError(err) ? err : defineError(500, { data: err, stack: `${err}` });
192
+ h3.setResponseStatus(event, error.statusCode);
193
+ if (onError) {
194
+ await onError(error, context, event);
195
+ }
196
+ if (event.handled) {
197
+ return;
198
+ }
199
+ h3.sendError(event, error);
200
+ }
190
201
 
191
202
  const NUMBER_CHAR_RE = /\d/;
192
203
  const STR_SPLITTERS = ["-", "_", "/", "."];
@@ -620,9 +631,7 @@ function registerRpc(router, path, procedure, middleware, opts) {
620
631
  await procedure.postHandler(context, event);
621
632
  }
622
633
  } catch (err) {
623
- if (opts.onError) {
624
- await opts.onError(err, context, event);
625
- }
634
+ await handleH3Error(err, context, event, opts.onError);
626
635
  }
627
636
  return "";
628
637
  });
@@ -711,9 +720,7 @@ function registerRoute(router, route, middleware, prefix, opts) {
711
720
  await route.postHandler(context, event);
712
721
  }
713
722
  } catch (err) {
714
- if (opts?.onError) {
715
- await opts.onError(err, context, event);
716
- }
723
+ await handleH3Error(err, context, event, opts?.onError);
717
724
  }
718
725
  return "";
719
726
  });
@@ -788,6 +795,7 @@ class Arri {
788
795
  this.h3Router.use(
789
796
  "/**",
790
797
  h3.eventHandler(async (event) => {
798
+ h3.setResponseStatus(event, 404);
791
799
  const error = defineError(404);
792
800
  const query = h3.getQuery(event);
793
801
  const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
@@ -805,23 +813,19 @@ class Arri {
805
813
  await m(context, event);
806
814
  }
807
815
  }
808
- } catch (_) {
816
+ } catch (err) {
817
+ await handleH3Error(err, context, event, this.onError);
818
+ }
819
+ if (event.handled) {
820
+ return;
809
821
  }
810
822
  if (this.onError) {
811
- await this.onError(
812
- error,
813
- {
814
- type: "route",
815
- params: void 0,
816
- query: void 0,
817
- body: void 0
818
- },
819
- event
820
- );
823
+ await this.onError(error, context, event);
821
824
  }
822
- if (!event.handled) {
823
- h3.sendError(event, error);
825
+ if (event.handled) {
826
+ return;
824
827
  }
828
+ h3.sendError(event, error);
825
829
  })
826
830
  );
827
831
  }
@@ -867,7 +871,6 @@ class Arri {
867
871
  return appDef;
868
872
  }
869
873
  getH3Instance() {
870
- return this.h3App;
871
874
  }
872
875
  }
873
876
  const HttpMethodValues = [
@@ -904,6 +907,7 @@ exports.getRpcParamDefinition = getRpcParamDefinition;
904
907
  exports.getRpcParamName = getRpcParamName;
905
908
  exports.getRpcPath = getRpcPath;
906
909
  exports.getRpcResponseName = getRpcResponseName;
910
+ exports.handleH3Error = handleH3Error;
907
911
  exports.isApplicationDef = isApplicationDef;
908
912
  exports.isHttpMethod = isHttpMethod;
909
913
  exports.isJsonSchemaArray = isJsonSchemaArray;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const child_process = require('child_process');
4
4
  const require$$0 = require('fs');
5
- const app = require('./arri.fb02cde0.cjs');
5
+ const app = require('./arri.a83bc214.cjs');
6
6
 
7
7
  function defineClientGeneratorPlugin(plugin) {
8
8
  return plugin;
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "chokidar": "^3.5.3",
26
26
  "listhen": "^1.4.4"
27
27
  },
28
- "version": "0.0.30",
28
+ "version": "0.0.33",
29
29
  "repository": {
30
30
  "url": "https://github.com/modiimedia/arri"
31
31
  }