arri 0.0.29 → 0.0.31

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.50fd4bf9.cjs');
38
+ require('../shared/arri.0d456112.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.fa2beb45.cjs');
45
+ require('../shared/arri.a8b148d1.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.e62071ea.mjs';
36
+ import '../shared/arri.6f4fe9d8.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.64252c62.mjs';
43
+ import '../shared/arri.0f1b603c.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.50fd4bf9.cjs');
28
+ const app = require('./shared/arri.0d456112.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.fa2beb45.cjs');
36
+ const dart = require('./shared/arri.a8b148d1.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.e62071ea.mjs';
26
+ import { j as camelCase, r as removeDisallowedChars, o as kebabCase, k as isApplicationDef, D as DEV_DEFINITION_ENDPOINT } from './shared/arri.6f4fe9d8.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.64252c62.mjs';
34
+ import { a as dartClientGenerator } from './shared/arri.0f1b603c.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.50fd4bf9.cjs');
6
- const dart = require('./shared/arri.fa2beb45.cjs');
5
+ const app = require('./shared/arri.0d456112.cjs');
6
+ const dart = require('./shared/arri.a8b148d1.cjs');
7
7
  require('@sinclair/typebox');
8
8
  require('h3');
9
9
  require('@sinclair/typebox/errors');
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.e62071ea.mjs';
4
- export { m as JsonSchemaComplexTypeValues, l as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, k as isApplicationDef, n as normalizeWhitespace, r as removeDisallowedChars, s as setNestedObjectProperty } from './shared/arri.e62071ea.mjs';
5
- import { d as defineClientGeneratorPlugin } from './shared/arri.64252c62.mjs';
6
- export { j as classListTransformer, i as classTransformer, c as createDartClient, a as dartClientGenerator, f as dartModelFromJsonSchema, h as dartParsedJsonField, e as dartProcedureFromServiceDefinition, g as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, k as isDartType, l as isDartTypeWithNullables, t as transformers } from './shared/arri.64252c62.mjs';
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.6f4fe9d8.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.6f4fe9d8.mjs';
5
+ import { d as defineClientGeneratorPlugin } from './shared/arri.0f1b603c.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.0f1b603c.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.50fd4bf9.cjs');
3
+ const app = require('./shared/arri.0d456112.cjs');
4
4
  require('@sinclair/typebox');
5
5
  require('h3');
6
6
  require('@sinclair/typebox/errors');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { A as Arri, D as DEV_DEFINITION_ENDPOINT, q as DEV_ENDPOINT_ROOT, K as ErrorResponse, H as HttpMethodValues, x as createRpcDefinition, L as defineError, G as defineMiddleware, F as defineRoute, w as defineRpc, M as errorResponseFromValidationErrors, B as getRpcParamDefinition, z as getRpcParamName, y as getRpcPath, C as getRpcResponseName, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.e62071ea.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, t as isHttpMethod, v as isRpc, I as registerRoute, E as registerRpc } from './shared/arri.6f4fe9d8.mjs';
2
2
  import '@sinclair/typebox';
3
3
  import 'h3';
4
4
  import '@sinclair/typebox/errors';
@@ -623,6 +623,9 @@ function registerRpc(router, path, procedure, middleware, opts) {
623
623
  if (opts.onError) {
624
624
  await opts.onError(err, context, event);
625
625
  }
626
+ if (!event.handled) {
627
+ h3.sendError(event, err);
628
+ }
626
629
  }
627
630
  return "";
628
631
  });
@@ -714,6 +717,9 @@ function registerRoute(router, route, middleware, prefix, opts) {
714
717
  if (opts?.onError) {
715
718
  await opts.onError(err, context, event);
716
719
  }
720
+ if (!event.handled) {
721
+ h3.sendError(event, err);
722
+ }
717
723
  }
718
724
  return "";
719
725
  });
@@ -772,17 +778,58 @@ class Arri {
772
778
  this.onBeforeResponse = opts.onBeforeResponse;
773
779
  this.rpcRoutePrefix = opts?.rpcRoutePrefix ?? "";
774
780
  this.rpcDefinitionPath = opts?.rpcDefinitionPath ?? "__definition";
775
- this.h3Router.get(
776
- this.rpcRoutePrefix ? `/${this.rpcRoutePrefix}/${this.rpcDefinitionPath}`.split("//").join("/") : `/${this.rpcDefinitionPath}`,
777
- h3.eventHandler((_) => this.getAppDefinition())
778
- );
779
781
  this.h3App.use(this.h3Router);
782
+ this.registerRoute({
783
+ path: this.rpcRoutePrefix ? `/${this.rpcRoutePrefix}/${this.rpcDefinitionPath}`.split("//").join("/") : `/${this.rpcDefinitionPath}`,
784
+ method: "get",
785
+ handler: () => this.getAppDefinition()
786
+ });
780
787
  if (process.env.ARRI_DEV_MODE === "true") {
781
- this.h3Router.get(
782
- DEV_DEFINITION_ENDPOINT,
783
- h3.eventHandler((_) => this.getAppDefinition())
784
- );
788
+ this.registerRoute({
789
+ path: DEV_DEFINITION_ENDPOINT,
790
+ method: "get",
791
+ handler: () => this.getAppDefinition()
792
+ });
785
793
  }
794
+ this.h3Router.use(
795
+ "/**",
796
+ h3.eventHandler(async (event) => {
797
+ const error = defineError(404);
798
+ const query = h3.getQuery(event);
799
+ const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
800
+ const canBody = !disallowedBodyMethods.includes(event.method);
801
+ const context = {
802
+ type: "route",
803
+ params: event.context.params,
804
+ query,
805
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
806
+ body: canBody ? await h3.readBody(event).catch((_) => void 0) : void 0
807
+ };
808
+ try {
809
+ if (this.middlewares.length) {
810
+ for (const m of this.middlewares) {
811
+ await m(context, event);
812
+ }
813
+ }
814
+ } catch (_) {
815
+ }
816
+ if (this.onError) {
817
+ await this.onError(
818
+ error,
819
+ {
820
+ type: "route",
821
+ params: void 0,
822
+ query: void 0,
823
+ body: void 0
824
+ },
825
+ event
826
+ );
827
+ }
828
+ if (!event.handled) {
829
+ h3.sendError(event, error);
830
+ }
831
+ })
832
+ );
786
833
  }
787
834
  registerMiddleware(middleware) {
788
835
  this.middlewares.push(middleware);
@@ -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.e62071ea.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.6f4fe9d8.mjs';
4
4
 
5
5
  function defineClientGeneratorPlugin(plugin) {
6
6
  return plugin;
@@ -1,5 +1,5 @@
1
1
  import { Type, TypeGuard } from '@sinclair/typebox';
2
- import { createError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, createRouter, createApp } from 'h3';
2
+ import { createError, eventHandler, isPreflightRequest, readValidatedBody, getValidatedQuery, setResponseHeader, send, sendError, createRouter, createApp, getQuery, readBody } from 'h3';
3
3
  import { ValueErrorType } from '@sinclair/typebox/errors';
4
4
  import { Value } from '@sinclair/typebox/value';
5
5
 
@@ -621,6 +621,9 @@ function registerRpc(router, path, procedure, middleware, opts) {
621
621
  if (opts.onError) {
622
622
  await opts.onError(err, context, event);
623
623
  }
624
+ if (!event.handled) {
625
+ sendError(event, err);
626
+ }
624
627
  }
625
628
  return "";
626
629
  });
@@ -712,6 +715,9 @@ function registerRoute(router, route, middleware, prefix, opts) {
712
715
  if (opts?.onError) {
713
716
  await opts.onError(err, context, event);
714
717
  }
718
+ if (!event.handled) {
719
+ sendError(event, err);
720
+ }
715
721
  }
716
722
  return "";
717
723
  });
@@ -770,17 +776,58 @@ class Arri {
770
776
  this.onBeforeResponse = opts.onBeforeResponse;
771
777
  this.rpcRoutePrefix = opts?.rpcRoutePrefix ?? "";
772
778
  this.rpcDefinitionPath = opts?.rpcDefinitionPath ?? "__definition";
773
- this.h3Router.get(
774
- this.rpcRoutePrefix ? `/${this.rpcRoutePrefix}/${this.rpcDefinitionPath}`.split("//").join("/") : `/${this.rpcDefinitionPath}`,
775
- eventHandler((_) => this.getAppDefinition())
776
- );
777
779
  this.h3App.use(this.h3Router);
780
+ this.registerRoute({
781
+ path: this.rpcRoutePrefix ? `/${this.rpcRoutePrefix}/${this.rpcDefinitionPath}`.split("//").join("/") : `/${this.rpcDefinitionPath}`,
782
+ method: "get",
783
+ handler: () => this.getAppDefinition()
784
+ });
778
785
  if (process.env.ARRI_DEV_MODE === "true") {
779
- this.h3Router.get(
780
- DEV_DEFINITION_ENDPOINT,
781
- eventHandler((_) => this.getAppDefinition())
782
- );
786
+ this.registerRoute({
787
+ path: DEV_DEFINITION_ENDPOINT,
788
+ method: "get",
789
+ handler: () => this.getAppDefinition()
790
+ });
783
791
  }
792
+ this.h3Router.use(
793
+ "/**",
794
+ eventHandler(async (event) => {
795
+ const error = defineError(404);
796
+ const query = getQuery(event);
797
+ const disallowedBodyMethods = ["GET", "HEAD", "OPTION"];
798
+ const canBody = !disallowedBodyMethods.includes(event.method);
799
+ const context = {
800
+ type: "route",
801
+ params: event.context.params,
802
+ query,
803
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
804
+ body: canBody ? await readBody(event).catch((_) => void 0) : void 0
805
+ };
806
+ try {
807
+ if (this.middlewares.length) {
808
+ for (const m of this.middlewares) {
809
+ await m(context, event);
810
+ }
811
+ }
812
+ } catch (_) {
813
+ }
814
+ if (this.onError) {
815
+ await this.onError(
816
+ error,
817
+ {
818
+ type: "route",
819
+ params: void 0,
820
+ query: void 0,
821
+ body: void 0
822
+ },
823
+ event
824
+ );
825
+ }
826
+ if (!event.handled) {
827
+ sendError(event, error);
828
+ }
829
+ })
830
+ );
784
831
  }
785
832
  registerMiddleware(middleware) {
786
833
  this.middlewares.push(middleware);
@@ -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.50fd4bf9.cjs');
5
+ const app = require('./arri.0d456112.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.29",
28
+ "version": "0.0.31",
29
29
  "repository": {
30
30
  "url": "https://github.com/modiimedia/arri"
31
31
  }