arri 0.36.0 → 0.36.1

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/README.md CHANGED
@@ -18,6 +18,7 @@ Typescript implementation of Arri RPC. It's built on top of [H3](https://github.
18
18
  - [Key Concepts](#key-concepts)
19
19
  - [Arri Definition File](#arri-definition-file)
20
20
  - [How Procedures Map To Endpoints](#how-procedures-map-to-endpoints)
21
+ - [H3 Support](#h3-support)
21
22
  - [Arri CLI](#arri-cli)
22
23
 
23
24
  ## Quickstart
@@ -480,6 +481,37 @@ The supported HTTP methods are as follows:
480
481
 
481
482
  When using a get method the RPC params will be mapped as query parameters which will be coerced into their type using the `a.coerce` method from `arri-validate`. Get methods support all basic scalar types however arrays and nested objects are not supported.
482
483
 
484
+ ### H3 Support
485
+ Arri is built on top of [H3](https://h3.unjs.io/utils/request#getrequestipevent) so many of the concepts that apply to H3 also apply to Arri.
486
+
487
+ #### Accessing Utilities
488
+ Arri re-eports all of the H3 utilities.
489
+
490
+ ```ts
491
+ import { getRequestIP, setResponseHeader } from 'arri';
492
+ ```
493
+
494
+ #### Accessing H3 Events
495
+ You can access H3 events from inside procedures handlers.
496
+
497
+ ```ts
498
+ defineRpc({
499
+ params: undefined,
500
+ response: undefined,
501
+ handler(_, event) {
502
+ getRequestIP(event);
503
+ }
504
+ )
505
+
506
+ defineEventStreamRpc({
507
+ params: undefined,
508
+ response: undefined,
509
+ handler(_, event) {
510
+ getRequestIP(event);
511
+ }
512
+ )
513
+ ```
514
+
483
515
  ## Arri CLI
484
516
 
485
517
  ```bash
package/dist/cli.cjs CHANGED
@@ -11,7 +11,7 @@ const esbuild = require('esbuild');
11
11
  const esbuildPluginReplace = require('esbuild-plugin-replace');
12
12
  const path = require('pathe');
13
13
  const prettier = require('prettier');
14
- const config = require('./shared/arri.087dabd0.cjs');
14
+ const config = require('./shared/arri.8e96548e.cjs');
15
15
  const consola = require('consola');
16
16
  const globby = require('globby');
17
17
  const scule = require('scule');
package/dist/cli.mjs CHANGED
@@ -10,7 +10,7 @@ import { build as build$1 } from 'esbuild';
10
10
  import { replace } from 'esbuild-plugin-replace';
11
11
  import path from 'pathe';
12
12
  import prettier from 'prettier';
13
- import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.b0950dad.mjs';
13
+ import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.b1ff441a.mjs';
14
14
  import { createConsola } from 'consola';
15
15
  import { globby } from 'globby';
16
16
  import { camelCase, kebabCase } from 'scule';
package/dist/index.cjs CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./shared/arri.087dabd0.cjs');
3
+ const config = require('./shared/arri.8e96548e.cjs');
4
4
  const h3 = require('h3');
5
5
  require('arri-codegen-utils');
6
+ require('consola');
6
7
  require('arri-validate');
7
8
  require('h3-sse');
8
9
  require('scule');
package/dist/index.d.cts CHANGED
@@ -195,6 +195,7 @@ declare class ArriApp implements ArriRouterBase {
195
195
  private readonly _onBeforeResponse;
196
196
  private readonly _onError;
197
197
  private readonly _debug;
198
+ readonly definitionPath: string;
198
199
  constructor(opts?: ArriOptions);
199
200
  use(input: Middleware | ArriRouter): void;
200
201
  rpc<TIsEventStream extends boolean = false, TParams extends AObjectSchema<any, any> | undefined = undefined, TResponse extends AObjectSchema<any, any> | undefined = undefined>(procedure: NamedRpc<TIsEventStream, TParams, TResponse>): void;
package/dist/index.d.mts CHANGED
@@ -195,6 +195,7 @@ declare class ArriApp implements ArriRouterBase {
195
195
  private readonly _onBeforeResponse;
196
196
  private readonly _onError;
197
197
  private readonly _debug;
198
+ readonly definitionPath: string;
198
199
  constructor(opts?: ArriOptions);
199
200
  use(input: Middleware | ArriRouter): void;
200
201
  rpc<TIsEventStream extends boolean = false, TParams extends AObjectSchema<any, any> | undefined = undefined, TResponse extends AObjectSchema<any, any> | undefined = undefined>(procedure: NamedRpc<TIsEventStream, TParams, TResponse>): void;
package/dist/index.d.ts CHANGED
@@ -195,6 +195,7 @@ declare class ArriApp implements ArriRouterBase {
195
195
  private readonly _onBeforeResponse;
196
196
  private readonly _onError;
197
197
  private readonly _debug;
198
+ readonly definitionPath: string;
198
199
  constructor(opts?: ArriOptions);
199
200
  use(input: Middleware | ArriRouter): void;
200
201
  rpc<TIsEventStream extends boolean = false, TParams extends AObjectSchema<any, any> | undefined = undefined, TResponse extends AObjectSchema<any, any> | undefined = undefined>(procedure: NamedRpc<TIsEventStream, TParams, TResponse>): void;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, c as createAppDefinition, e as createHttpRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.b0950dad.mjs';
1
+ export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, c as createAppDefinition, e as createHttpRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, v as validateRpcRequestInput } from './shared/arri.b1ff441a.mjs';
2
2
  export * from 'h3';
3
3
  import 'arri-codegen-utils';
4
+ import 'consola';
4
5
  import 'arri-validate';
5
6
  import 'h3-sse';
6
7
  import 'scule';
@@ -1,11 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  const arriCodegenUtils = require('arri-codegen-utils');
4
+ const consola = require('consola');
4
5
  const h3 = require('h3');
5
6
  const arriValidate = require('arri-validate');
6
7
  const h3Sse = require('h3-sse');
7
8
  const scule = require('scule');
8
9
 
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
+
12
+ const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
13
+
9
14
  var __defProp$3 = Object.defineProperty;
10
15
  var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
16
  var __publicField$3 = (obj, key, value) => {
@@ -871,6 +876,7 @@ class ArriApp {
871
876
  __publicField(this, "_onBeforeResponse");
872
877
  __publicField(this, "_onError");
873
878
  __publicField(this, "_debug");
879
+ __publicField(this, "definitionPath");
874
880
  this.appInfo = opts?.appInfo;
875
881
  this.h3App = h3.createApp({
876
882
  debug: opts?.debug
@@ -883,11 +889,15 @@ class ArriApp {
883
889
  this._rpcRoutePrefix = opts?.rpcRoutePrefix ?? "";
884
890
  this._rpcDefinitionPath = opts?.rpcDefinitionPath ?? "__definition";
885
891
  this.h3App.use(this.h3Router);
892
+ this.definitionPath = this._rpcRoutePrefix ? `/${this._rpcRoutePrefix}/${this._rpcDefinitionPath}`.split("//").join("/") : `/${this._rpcDefinitionPath}`;
886
893
  this.h3Router.get(
887
- this._rpcRoutePrefix ? `/${this._rpcRoutePrefix}/${this._rpcDefinitionPath}`.split("//").join("/") : `/${this._rpcDefinitionPath}`,
894
+ this.definitionPath,
888
895
  h3.eventHandler(() => this.getAppDefinition())
889
896
  );
890
897
  if (process.env.ARRI_DEV_MODE === "true") {
898
+ consola__default.info(
899
+ `Arri definition available at \`http://<host>${this.definitionPath}\``
900
+ );
891
901
  this.h3Router.get(
892
902
  DEV_DEFINITION_ENDPOINT,
893
903
  h3.eventHandler(() => this.getAppDefinition())
@@ -1,4 +1,5 @@
1
1
  import { isRpcHttpMethod, removeDisallowedChars, SCHEMA_VERSION } from 'arri-codegen-utils';
2
+ import consola from 'consola';
2
3
  import { isError, setResponseStatus, setResponseHeader, send, eventHandler, isPreflightRequest, readRawBody, getValidatedQuery, defineEventHandler, getQuery, setHeader, createRouter, createApp } from 'h3';
3
4
  import { a, isAObjectSchema, isADiscriminatorSchema } from 'arri-validate';
4
5
  import { createEventStream } from 'h3-sse';
@@ -869,6 +870,7 @@ class ArriApp {
869
870
  __publicField(this, "_onBeforeResponse");
870
871
  __publicField(this, "_onError");
871
872
  __publicField(this, "_debug");
873
+ __publicField(this, "definitionPath");
872
874
  this.appInfo = opts?.appInfo;
873
875
  this.h3App = createApp({
874
876
  debug: opts?.debug
@@ -881,11 +883,15 @@ class ArriApp {
881
883
  this._rpcRoutePrefix = opts?.rpcRoutePrefix ?? "";
882
884
  this._rpcDefinitionPath = opts?.rpcDefinitionPath ?? "__definition";
883
885
  this.h3App.use(this.h3Router);
886
+ this.definitionPath = this._rpcRoutePrefix ? `/${this._rpcRoutePrefix}/${this._rpcDefinitionPath}`.split("//").join("/") : `/${this._rpcDefinitionPath}`;
884
887
  this.h3Router.get(
885
- this._rpcRoutePrefix ? `/${this._rpcRoutePrefix}/${this._rpcDefinitionPath}`.split("//").join("/") : `/${this._rpcDefinitionPath}`,
888
+ this.definitionPath,
886
889
  eventHandler(() => this.getAppDefinition())
887
890
  );
888
891
  if (process.env.ARRI_DEV_MODE === "true") {
892
+ consola.info(
893
+ `Arri definition available at \`http://<host>${this.definitionPath}\``
894
+ );
889
895
  this.h3Router.get(
890
896
  DEV_DEFINITION_ENDPOINT,
891
897
  eventHandler(() => this.getAppDefinition())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.36.0",
3
+ "version": "0.36.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -43,10 +43,10 @@
43
43
  "prettier": "^3.2.5",
44
44
  "scule": "^1.3.0",
45
45
  "uncrypto": "^0.1.3",
46
- "arri-codegen-dart": "0.36.0",
47
- "arri-codegen-ts": "0.36.0",
48
- "arri-codegen-utils": "0.36.0",
49
- "arri-validate": "0.36.0"
46
+ "arri-codegen-utils": "0.36.1",
47
+ "arri-validate": "0.36.1",
48
+ "arri-codegen-ts": "0.36.1",
49
+ "arri-codegen-dart": "0.36.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/degit": "^2.8.6",