arri 0.0.12 → 0.0.15

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/codegen.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.3605a96c.cjs');
4
- const dart = require('./shared/arri.5b9d1682.cjs');
5
3
  const fs = require('fs');
4
+ const dart = require('./shared/arri.9717f131.cjs');
5
+ const index = require('./shared/arri.bfebed73.cjs');
6
6
  require('module');
7
7
  require('url');
8
8
  require('path');
@@ -15,7 +15,7 @@ require('v8');
15
15
  require('util');
16
16
  require('child_process');
17
17
 
18
- let createdModels = [];
18
+ let generatedModels = [];
19
19
  const typescriptClientGenerator = dart.defineClientGeneratorPlugin(
20
20
  (options) => ({
21
21
  generator: async (def) => {
@@ -35,7 +35,7 @@ const typescriptClientGenerator = dart.defineClientGeneratorPlugin(
35
35
  })
36
36
  );
37
37
  async function createTypescriptClient(def, prefix = "Client") {
38
- createdModels = [];
38
+ generatedModels = [];
39
39
  const services = index.unflattenObject(def.procedures);
40
40
  const serviceParts = [];
41
41
  const procedureParts = [];
@@ -55,9 +55,9 @@ async function createTypescriptClient(def, prefix = "Client") {
55
55
  });
56
56
  Object.keys(def.models).forEach((key) => {
57
57
  const modelName = index.pascalCase(`${key}`);
58
- if (!createdModels.includes(modelName)) {
58
+ if (!generatedModels.includes(modelName)) {
59
59
  modelParts.push(tsModelFromDefinition(modelName, def.models[key]));
60
- createdModels.push(modelName);
60
+ generatedModels.push(modelName);
61
61
  }
62
62
  });
63
63
  return dart.format2(
@@ -163,7 +163,7 @@ function tsModelFromDefinition(name, def) {
163
163
  }
164
164
  if (index.isJsonSchemaObject(prop)) {
165
165
  const subModelName = prop.$id ?? index.pascalCase(`${name}_${key}`);
166
- if (!createdModels.includes(subModelName)) {
166
+ if (!generatedModels.includes(subModelName)) {
167
167
  const content = tsModelFromDefinition(
168
168
  subModelName,
169
169
  prop
@@ -200,7 +200,7 @@ function tsModelFromDefinition(name, def) {
200
200
  }
201
201
  if (index.isJsonSchemaObject(prop.items)) {
202
202
  const subModelName = prop.items.$id ?? index.pascalCase(`${name}_${key}_item`);
203
- if (!createdModels.includes(subModelName)) {
203
+ if (!generatedModels.includes(subModelName)) {
204
204
  subModelParts.push(
205
205
  tsModelFromDefinition(subModelName, prop.items)
206
206
  );
@@ -1,4 +1,4 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.cjs';
1
+ import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.bb7e9a4e.cjs';
2
2
  import '@sinclair/typebox';
3
3
  import 'h3';
4
4
 
@@ -1,4 +1,4 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.mjs';
1
+ import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.bb7e9a4e.mjs';
2
2
  import '@sinclair/typebox';
3
3
  import 'h3';
4
4
 
package/dist/codegen.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.2ff96786.js';
1
+ import { B as ApplicationDefinition, S as ServiceDefinition, P as ProcedureDefinition, J as JsonSchemaObject } from './shared/arri.bb7e9a4e.js';
2
2
  import '@sinclair/typebox';
3
3
  import 'h3';
4
4
 
package/dist/codegen.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { u as unflattenObject, i as isServiceDefinition, p as pascalCase, a as isProcedureDefinition, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.b0ab6d2f.mjs';
2
- import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.fa163587.mjs';
3
- export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.fa163587.mjs';
4
1
  import { writeFileSync } from 'fs';
2
+ import { d as defineClientGeneratorPlugin, f as format2 } from './shared/arri.e335c10b.mjs';
3
+ export { k as classListTransformer, j as classTransformer, c as createDartClient, a as dartClientGenerator, g as dartModelFromJsonSchema, i as dartParsedJsonField, e as dartProcedureFromServiceDefinition, h as dartPropertyTypeFromSchema, b as dartServiceFromServiceDefinition, l as isDartType, m as isDartTypeWithNullables, t as transformers } from './shared/arri.e335c10b.mjs';
4
+ import { u as unflattenObject, i as isServiceDefinition, p as pascalCase, a as isProcedureDefinition, b as isJsonSchemaScalarType, c as isJsonSchemaNullType, d as isJsonSchemaObject, e as isJsonSchemaEnum, f as isJsonSchemaArray } from './shared/arri.dab1f9df.mjs';
5
5
  import 'module';
6
6
  import 'url';
7
7
  import 'path';
@@ -14,7 +14,7 @@ import 'v8';
14
14
  import 'util';
15
15
  import 'child_process';
16
16
 
17
- let createdModels = [];
17
+ let generatedModels = [];
18
18
  const typescriptClientGenerator = defineClientGeneratorPlugin(
19
19
  (options) => ({
20
20
  generator: async (def) => {
@@ -34,7 +34,7 @@ const typescriptClientGenerator = defineClientGeneratorPlugin(
34
34
  })
35
35
  );
36
36
  async function createTypescriptClient(def, prefix = "Client") {
37
- createdModels = [];
37
+ generatedModels = [];
38
38
  const services = unflattenObject(def.procedures);
39
39
  const serviceParts = [];
40
40
  const procedureParts = [];
@@ -54,9 +54,9 @@ async function createTypescriptClient(def, prefix = "Client") {
54
54
  });
55
55
  Object.keys(def.models).forEach((key) => {
56
56
  const modelName = pascalCase(`${key}`);
57
- if (!createdModels.includes(modelName)) {
57
+ if (!generatedModels.includes(modelName)) {
58
58
  modelParts.push(tsModelFromDefinition(modelName, def.models[key]));
59
- createdModels.push(modelName);
59
+ generatedModels.push(modelName);
60
60
  }
61
61
  });
62
62
  return format2(
@@ -162,7 +162,7 @@ function tsModelFromDefinition(name, def) {
162
162
  }
163
163
  if (isJsonSchemaObject(prop)) {
164
164
  const subModelName = prop.$id ?? pascalCase(`${name}_${key}`);
165
- if (!createdModels.includes(subModelName)) {
165
+ if (!generatedModels.includes(subModelName)) {
166
166
  const content = tsModelFromDefinition(
167
167
  subModelName,
168
168
  prop
@@ -199,7 +199,7 @@ function tsModelFromDefinition(name, def) {
199
199
  }
200
200
  if (isJsonSchemaObject(prop.items)) {
201
201
  const subModelName = prop.items.$id ?? pascalCase(`${name}_${key}_item`);
202
- if (!createdModels.includes(subModelName)) {
202
+ if (!generatedModels.includes(subModelName)) {
203
203
  subModelParts.push(
204
204
  tsModelFromDefinition(subModelName, prop.items)
205
205
  );
package/dist/index.cjs CHANGED
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.3605a96c.cjs');
3
+ const index = require('./shared/arri.bfebed73.cjs');
4
4
 
5
5
 
6
6
 
7
- exports.ArriServer = index.ArriServer;
7
+ exports.Arri = index.Arri;
8
+ exports.DEV_DEFINITION_ENDPOINT = index.DEV_DEFINITION_ENDPOINT;
9
+ exports.DEV_ENDPOINT_ROOT = index.DEV_ENDPOINT_ROOT;
8
10
  exports.ErrorResponse = index.ErrorResponse;
9
11
  exports.HttpMethodValues = index.HttpMethodValues;
10
12
  exports.createRpcDefinition = index.createRpcDefinition;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, A as ArriServer, a as ArriService, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.2ff96786.cjs';
1
+ export { A as Arri, d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.bb7e9a4e.cjs';
2
2
  import * as _sinclair_typebox from '@sinclair/typebox';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { ValueError } from '@sinclair/typebox/errors';
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, A as ArriServer, a as ArriService, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.2ff96786.mjs';
1
+ export { A as Arri, d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.bb7e9a4e.mjs';
2
2
  import * as _sinclair_typebox from '@sinclair/typebox';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { ValueError } from '@sinclair/typebox/errors';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, A as ArriServer, a as ArriService, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.2ff96786.js';
1
+ export { A as Arri, d as ArriProcedure, c as ArriProcedureBase, g as ArriProcedureHandler, h as ArriProcedurePostHandler, q as ArriRoute, v as ArriRouteHandler, y as ArriRoutePostHandler, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ExtractParam, u as ExtractParams, e as HandlerContext, b as HttpMethod, H as HttpMethodValues, M as Middleware, w as RouteHandlerContext, x as RoutePostHandlerContext, R as RpcHandlerContext, f as RpcPostHandlerContext, l as createRpcDefinition, t as defineMiddleware, s as defineRoute, k as defineRpc, o as getRpcParamDefinition, n as getRpcParamName, m as getRpcPath, p as getRpcResponseName, i as isHttpMethod, j as isRpc, z as registerRoute, r as registerRpc } from './shared/arri.bb7e9a4e.js';
2
2
  import * as _sinclair_typebox from '@sinclair/typebox';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { ValueError } from '@sinclair/typebox/errors';
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { A as ArriServer, E as ErrorResponse, H as HttpMethodValues, z as createRpcDefinition, L as defineError, J as defineMiddleware, I as defineRoute, y as defineRpc, M as errorResponseFromValidationErrors, D as getRpcParamDefinition, C as getRpcParamName, B as getRpcPath, F as getRpcResponseName, x as isHttpMethod, o as isRpc, K as registerRoute, G as registerRpc } from './shared/arri.b0ab6d2f.mjs';
1
+ export { A as Arri, D as DEV_DEFINITION_ENDPOINT, t as DEV_ENDPOINT_ROOT, L as ErrorResponse, H as HttpMethodValues, z as createRpcDefinition, M as defineError, J as defineMiddleware, I as defineRoute, y as defineRpc, N as errorResponseFromValidationErrors, E as getRpcParamDefinition, C as getRpcParamName, B as getRpcPath, F as getRpcResponseName, v as isHttpMethod, x as isRpc, K as registerRoute, G as registerRpc } from './shared/arri.dab1f9df.mjs';
@@ -4,29 +4,29 @@ const require$$2 = require('module');
4
4
  const require$$7 = require('url');
5
5
  const require$$0 = require('path');
6
6
  const process4 = require('process');
7
- const require$$0$2 = require('os');
7
+ const require$$1 = require('os');
8
8
  const tty = require('tty');
9
9
  const fs$1 = require('fs');
10
10
  const assert4 = require('assert');
11
11
  const fs = require('fs/promises');
12
12
  const v8 = require('v8');
13
13
  const require$$0$1 = require('util');
14
- const index = require('./arri.3605a96c.cjs');
15
- const require$$1 = require('child_process');
14
+ const require$$4 = require('child_process');
15
+ const index = require('./arri.bfebed73.cjs');
16
16
 
17
17
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
18
18
 
19
19
  const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
20
20
  const process4__default = /*#__PURE__*/_interopDefaultCompat(process4);
21
- const require$$0__default$1 = /*#__PURE__*/_interopDefaultCompat(require$$0$2);
21
+ const require$$1__default = /*#__PURE__*/_interopDefaultCompat(require$$1);
22
22
  const tty__default = /*#__PURE__*/_interopDefaultCompat(tty);
23
23
  const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
24
24
  const assert4__default = /*#__PURE__*/_interopDefaultCompat(assert4);
25
25
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
26
26
  const v8__default = /*#__PURE__*/_interopDefaultCompat(v8);
27
27
 
28
- const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.5b9d1682.cjs', document.baseURI).href)));
29
- const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.5b9d1682.cjs', document.baseURI).href)));
28
+ const require$2 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.9717f131.cjs', document.baseURI).href)));
29
+ const __filename$2 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.9717f131.cjs', document.baseURI).href)));
30
30
  const __dirname$1 = require$$0.dirname(__filename$2);
31
31
 
32
32
  var __create$1 = Object.create;
@@ -7791,8 +7791,8 @@ const doc = {
7791
7791
  utils: utils
7792
7792
  };
7793
7793
 
7794
- const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.5b9d1682.cjs', document.baseURI).href)));
7795
- const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.5b9d1682.cjs', document.baseURI).href)));
7794
+ const require$1 = require$$2.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.9717f131.cjs', document.baseURI).href)));
7795
+ const __filename$1 = require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/arri.9717f131.cjs', document.baseURI).href)));
7796
7796
  require$$0.dirname(__filename$1);
7797
7797
 
7798
7798
  var __create = Object.create;
@@ -21416,7 +21416,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
21416
21416
  return min;
21417
21417
  }
21418
21418
  if (process4__default.platform === "win32") {
21419
- const osRelease = require$$0__default$1.release().split(".");
21419
+ const osRelease = require$$1__default.release().split(".");
21420
21420
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
21421
21421
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
21422
21422
  }
@@ -29064,14 +29064,19 @@ const dartClientGenerator = defineClientGeneratorPlugin(
29064
29064
  clientName: options.clientName
29065
29065
  });
29066
29066
  fs$1.writeFileSync(options.outputFile, result);
29067
- require$$1.execSync(`dart format ${options.outputFile}`);
29067
+ try {
29068
+ require$$4.execSync(`dart format ${options.outputFile}`);
29069
+ } catch (err) {
29070
+ console.error("Error formatting dart client", err);
29071
+ }
29068
29072
  },
29069
29073
  options
29070
29074
  };
29071
29075
  }
29072
29076
  );
29073
- const generatedModels = [];
29077
+ let generatedModels = [];
29074
29078
  function createDartClient(appDef, opts = { clientName: "Client" }) {
29079
+ generatedModels = [];
29075
29080
  const { models, procedures } = appDef;
29076
29081
  const serviceParts = [];
29077
29082
  const procedureParts = [];
@@ -29109,9 +29114,9 @@ function createDartClient(appDef, opts = { clientName: "Client" }) {
29109
29114
  generatedModels.push(typeName);
29110
29115
  }
29111
29116
  });
29112
- return `// This code was autogenerated by arri. Do not modify directly.
29117
+ return `// This code was autogenerated by Arri. Do not modify directly.
29118
+ // For additional documentation visit http://github.com/modiimedia/arri
29113
29119
  import "dart:convert";
29114
- import "package:http/http.dart" as http;
29115
29120
  import "package:arri_client/arri_client.dart";
29116
29121
 
29117
29122
  class ${opts.clientName} {
@@ -29130,22 +29135,6 @@ class ${opts.clientName} {
29130
29135
  );
29131
29136
  }`
29132
29137
  ).join("\n ")}
29133
- Future<http.Response> rawRequest(
29134
- ${opts.clientName}Endpoints endpoint, {
29135
- Map<String, String>? query,
29136
- dynamic body,
29137
- Map<String, String>? headers,
29138
- Encoding? encoding,
29139
- }) async {
29140
- return arriRequest(
29141
- "$_baseUrl\${endpoint.path}",
29142
- method: endpoint.method,
29143
- headers: headers ?? _headers,
29144
- body: body,
29145
- query: query,
29146
- encoding: encoding,
29147
- );
29148
- }
29149
29138
  }
29150
29139
  ${serviceParts.map((item) => item.content).join("\n")}
29151
29140
  ${modelParts.join("\n")}
@@ -1,5 +1,5 @@
1
- import { TObject, Static, TVoid, TSchema } from '@sinclair/typebox';
2
- import { H3Event, Router, App, AppOptions } from 'h3';
1
+ import { TObject, TSchema, Static } from '@sinclair/typebox';
2
+ import { Router, H3Event, App, AppOptions } from 'h3';
3
3
 
4
4
  interface ApplicationDefinition {
5
5
  schemaVersion: "0.0.1";
@@ -46,42 +46,6 @@ interface JsonSchemaArray {
46
46
  items: JsonSchemaType;
47
47
  }
48
48
 
49
- interface ArriProcedureBase {
50
- method: HttpMethod;
51
- params?: any;
52
- response?: any;
53
- handler: (context: any) => any;
54
- postHandler?: (context: any) => any;
55
- }
56
- interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>> {
57
- description?: string;
58
- method?: HttpMethod;
59
- params: TParams;
60
- response: TResponse;
61
- handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
62
- postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
63
- }
64
- interface HandlerContext {
65
- [key: string]: any;
66
- event: H3Event;
67
- }
68
- interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
69
- params: TParams;
70
- }
71
- interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
72
- response: TResponse;
73
- }
74
- type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
75
- type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
76
- declare function isRpc(input: any): input is ArriProcedure<any, any, any>;
77
- declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined, TFinalResponse extends TResponse extends TObject ? Static<TObject> : Static<TVoid> = any>(config: ArriProcedure<TParams, TResponse, TFinalResponse>): ArriProcedure<TParams, TResponse, TFinalResponse>;
78
- declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition;
79
- declare function getRpcPath(rpcName: string, prefix?: string): string;
80
- declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
81
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition["params"];
82
- declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
83
- declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any, any>, middleware: Middleware[]): void;
84
-
85
49
  interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any> {
86
50
  path: TPath;
87
51
  method: TMethod;
@@ -108,7 +72,43 @@ interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery
108
72
  type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>) => any;
109
73
  declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
110
74
 
111
- interface ArriServerOptions extends AppOptions {
75
+ interface ArriProcedureBase {
76
+ method: HttpMethod;
77
+ params?: any;
78
+ response?: any;
79
+ handler: (context: any) => any;
80
+ postHandler?: (context: any) => any;
81
+ }
82
+ interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
83
+ description?: string;
84
+ method?: HttpMethod;
85
+ params: TParams;
86
+ response: TResponse;
87
+ handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
88
+ postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
89
+ }
90
+ interface HandlerContext {
91
+ [key: string]: any;
92
+ event: H3Event;
93
+ }
94
+ interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
95
+ params: TParams;
96
+ }
97
+ interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
98
+ response: TResponse;
99
+ }
100
+ type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
101
+ type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
102
+ declare function isRpc(input: any): input is ArriProcedure<any, any>;
103
+ declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
104
+ declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDefinition;
105
+ declare function getRpcPath(rpcName: string, prefix?: string): string;
106
+ declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
107
+ declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
108
+ declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
109
+ declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
110
+
111
+ interface ArriOptions extends AppOptions {
112
112
  rpcRoutePrefix?: string;
113
113
  /**
114
114
  * Defaults to /__definitions
@@ -117,32 +117,27 @@ interface ArriServerOptions extends AppOptions {
117
117
  rpcDefinitionPath?: string;
118
118
  appDescription?: string;
119
119
  }
120
- declare class ArriServer {
121
- app: App;
122
- router: Router;
123
- rpcRoutePrefix: string;
124
- rpcDefinitionPath: string;
125
- procedures: Record<string, ProcedureDefinition>;
126
- models: Record<string, TObject>;
127
- middlewares: Middleware[];
128
- appDescription: string;
129
- constructor(opts?: ArriServerOptions);
120
+ declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
121
+ declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
122
+ declare class Arri {
123
+ __isArri__: boolean;
124
+ private readonly h3App;
125
+ private readonly h3Router;
126
+ private readonly rpcDefinitionPath;
127
+ private readonly rpcRoutePrefix;
128
+ private procedures;
129
+ private models;
130
+ private readonly middlewares;
131
+ private readonly appDescription;
132
+ constructor(opts?: ArriOptions);
130
133
  registerMiddleware(middleware: Middleware): void;
131
- /**
132
- * Statically register routes to the server router
133
- * Routes will not be served until this is done
134
- */
135
- initializeRoutes(): void;
136
- registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>>(name: string, procedure: ArriProcedure<TParams, TResponse, TFinalResponse>): void;
134
+ registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
137
135
  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;
138
136
  getAppDefinition(): ApplicationDefinition;
139
- }
140
- interface ArriService {
141
- id: string;
142
- procedures: Record<string, any>;
137
+ getH3Instance(): App;
143
138
  }
144
139
  declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
145
140
  type HttpMethod = (typeof HttpMethodValues)[number];
146
141
  declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
147
142
 
148
- export { ArriServer as A, type ApplicationDefinition as B, type ExtractParam as E, HttpMethodValues as H, type JsonSchemaObject as J, type Middleware as M, type ProcedureDefinition as P, type RpcHandlerContext as R, type ServiceDefinition as S, type ArriService as a, type HttpMethod as b, type ArriProcedureBase as c, type ArriProcedure as d, type HandlerContext as e, type RpcPostHandlerContext as f, type ArriProcedureHandler as g, type ArriProcedurePostHandler as h, isHttpMethod as i, isRpc as j, defineRpc as k, createRpcDefinition as l, getRpcPath as m, getRpcParamName as n, getRpcParamDefinition as o, getRpcResponseName as p, type ArriRoute as q, registerRpc as r, defineRoute as s, defineMiddleware as t, type ExtractParams as u, type ArriRouteHandler as v, type RouteHandlerContext as w, type RoutePostHandlerContext as x, type ArriRoutePostHandler as y, registerRoute as z };
143
+ export { Arri as A, type ApplicationDefinition as B, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, HttpMethodValues as H, type JsonSchemaObject as J, type Middleware as M, type ProcedureDefinition as P, type RpcHandlerContext as R, type ServiceDefinition as S, DEV_DEFINITION_ENDPOINT as a, type HttpMethod as b, type ArriProcedureBase as c, type ArriProcedure as d, type HandlerContext as e, type RpcPostHandlerContext as f, type ArriProcedureHandler as g, type ArriProcedurePostHandler as h, isHttpMethod as i, isRpc as j, defineRpc as k, createRpcDefinition as l, getRpcPath as m, getRpcParamName as n, getRpcParamDefinition as o, getRpcResponseName as p, type ArriRoute as q, registerRpc as r, defineRoute as s, defineMiddleware as t, type ExtractParams as u, type ArriRouteHandler as v, type RouteHandlerContext as w, type RoutePostHandlerContext as x, type ArriRoutePostHandler as y, registerRoute as z };
@@ -1,5 +1,5 @@
1
- import { TObject, Static, TVoid, TSchema } from '@sinclair/typebox';
2
- import { H3Event, Router, App, AppOptions } from 'h3';
1
+ import { TObject, TSchema, Static } from '@sinclair/typebox';
2
+ import { Router, H3Event, App, AppOptions } from 'h3';
3
3
 
4
4
  interface ApplicationDefinition {
5
5
  schemaVersion: "0.0.1";
@@ -46,42 +46,6 @@ interface JsonSchemaArray {
46
46
  items: JsonSchemaType;
47
47
  }
48
48
 
49
- interface ArriProcedureBase {
50
- method: HttpMethod;
51
- params?: any;
52
- response?: any;
53
- handler: (context: any) => any;
54
- postHandler?: (context: any) => any;
55
- }
56
- interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>> {
57
- description?: string;
58
- method?: HttpMethod;
59
- params: TParams;
60
- response: TResponse;
61
- handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
62
- postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TFinalResponse>;
63
- }
64
- interface HandlerContext {
65
- [key: string]: any;
66
- event: H3Event;
67
- }
68
- interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
69
- params: TParams;
70
- }
71
- interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
72
- response: TResponse;
73
- }
74
- type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
75
- type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
76
- declare function isRpc(input: any): input is ArriProcedure<any, any, any>;
77
- declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined, TFinalResponse extends TResponse extends TObject ? Static<TObject> : Static<TVoid> = any>(config: ArriProcedure<TParams, TResponse, TFinalResponse>): ArriProcedure<TParams, TResponse, TFinalResponse>;
78
- declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition;
79
- declare function getRpcPath(rpcName: string, prefix?: string): string;
80
- declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
81
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any, any>): ProcedureDefinition["params"];
82
- declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any, any>): string | null;
83
- declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any, any>, middleware: Middleware[]): void;
84
-
85
49
  interface ArriRoute<TPath extends string, TMethod extends HttpMethod, TQuery extends TObject | undefined = undefined, TBody extends TSchema | undefined = undefined, TResponse extends TSchema | undefined = undefined, TFallbackResponse = any> {
86
50
  path: TPath;
87
51
  method: TMethod;
@@ -108,7 +72,43 @@ interface RoutePostHandlerContext<TParams extends Record<string, string>, TQuery
108
72
  type ArriRoutePostHandler<TPath extends string, TQuery = undefined, TBody = undefined, TResponse = undefined> = (context: RoutePostHandlerContext<ExtractParams<TPath>, TQuery, TBody, TResponse>) => any;
109
73
  declare function registerRoute<TPath extends string>(router: Router, route: ArriRoute<TPath, HttpMethod, any, any, any>, middleware: Middleware[], prefix?: string): void;
110
74
 
111
- interface ArriServerOptions extends AppOptions {
75
+ interface ArriProcedureBase {
76
+ method: HttpMethod;
77
+ params?: any;
78
+ response?: any;
79
+ handler: (context: any) => any;
80
+ postHandler?: (context: any) => any;
81
+ }
82
+ interface ArriProcedure<TParams extends TObject | undefined, TResponse extends TObject | undefined> {
83
+ description?: string;
84
+ method?: HttpMethod;
85
+ params: TParams;
86
+ response: TResponse;
87
+ handler: ArriProcedureHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : void>;
88
+ postHandler?: ArriProcedurePostHandler<TParams extends TObject ? Static<TParams> : undefined, TResponse extends TObject ? Static<TResponse> : undefined>;
89
+ }
90
+ interface HandlerContext {
91
+ [key: string]: any;
92
+ event: H3Event;
93
+ }
94
+ interface RpcHandlerContext<TParams = undefined> extends HandlerContext {
95
+ params: TParams;
96
+ }
97
+ interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
98
+ response: TResponse;
99
+ }
100
+ type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TParams>) => TResponse | Promise<TResponse>;
101
+ type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
102
+ declare function isRpc(input: any): input is ArriProcedure<any, any>;
103
+ declare function defineRpc<TParams extends TObject | undefined = undefined, TResponse extends TObject | undefined | never = undefined>(config: ArriProcedure<TParams, TResponse>): ArriProcedure<TParams, TResponse>;
104
+ declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDefinition;
105
+ declare function getRpcPath(rpcName: string, prefix?: string): string;
106
+ declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
107
+ declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
108
+ declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
109
+ declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
110
+
111
+ interface ArriOptions extends AppOptions {
112
112
  rpcRoutePrefix?: string;
113
113
  /**
114
114
  * Defaults to /__definitions
@@ -117,32 +117,27 @@ interface ArriServerOptions extends AppOptions {
117
117
  rpcDefinitionPath?: string;
118
118
  appDescription?: string;
119
119
  }
120
- declare class ArriServer {
121
- app: App;
122
- router: Router;
123
- rpcRoutePrefix: string;
124
- rpcDefinitionPath: string;
125
- procedures: Record<string, ProcedureDefinition>;
126
- models: Record<string, TObject>;
127
- middlewares: Middleware[];
128
- appDescription: string;
129
- constructor(opts?: ArriServerOptions);
120
+ declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
121
+ declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
122
+ declare class Arri {
123
+ __isArri__: boolean;
124
+ private readonly h3App;
125
+ private readonly h3Router;
126
+ private readonly rpcDefinitionPath;
127
+ private readonly rpcRoutePrefix;
128
+ private procedures;
129
+ private models;
130
+ private readonly middlewares;
131
+ private readonly appDescription;
132
+ constructor(opts?: ArriOptions);
130
133
  registerMiddleware(middleware: Middleware): void;
131
- /**
132
- * Statically register routes to the server router
133
- * Routes will not be served until this is done
134
- */
135
- initializeRoutes(): void;
136
- registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined, TFinalResponse extends TResponse extends TObject ? Static<TResponse> : Static<TVoid>>(name: string, procedure: ArriProcedure<TParams, TResponse, TFinalResponse>): void;
134
+ registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
137
135
  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;
138
136
  getAppDefinition(): ApplicationDefinition;
139
- }
140
- interface ArriService {
141
- id: string;
142
- procedures: Record<string, any>;
137
+ getH3Instance(): App;
143
138
  }
144
139
  declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
145
140
  type HttpMethod = (typeof HttpMethodValues)[number];
146
141
  declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
147
142
 
148
- export { ArriServer as A, type ApplicationDefinition as B, type ExtractParam as E, HttpMethodValues as H, type JsonSchemaObject as J, type Middleware as M, type ProcedureDefinition as P, type RpcHandlerContext as R, type ServiceDefinition as S, type ArriService as a, type HttpMethod as b, type ArriProcedureBase as c, type ArriProcedure as d, type HandlerContext as e, type RpcPostHandlerContext as f, type ArriProcedureHandler as g, type ArriProcedurePostHandler as h, isHttpMethod as i, isRpc as j, defineRpc as k, createRpcDefinition as l, getRpcPath as m, getRpcParamName as n, getRpcParamDefinition as o, getRpcResponseName as p, type ArriRoute as q, registerRpc as r, defineRoute as s, defineMiddleware as t, type ExtractParams as u, type ArriRouteHandler as v, type RouteHandlerContext as w, type RoutePostHandlerContext as x, type ArriRoutePostHandler as y, registerRoute as z };
143
+ export { Arri as A, type ApplicationDefinition as B, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, HttpMethodValues as H, type JsonSchemaObject as J, type Middleware as M, type ProcedureDefinition as P, type RpcHandlerContext as R, type ServiceDefinition as S, DEV_DEFINITION_ENDPOINT as a, type HttpMethod as b, type ArriProcedureBase as c, type ArriProcedure as d, type HandlerContext as e, type RpcPostHandlerContext as f, type ArriProcedureHandler as g, type ArriProcedurePostHandler as h, isHttpMethod as i, isRpc as j, defineRpc as k, createRpcDefinition as l, getRpcPath as m, getRpcParamName as n, getRpcParamDefinition as o, getRpcResponseName as p, type ArriRoute as q, registerRpc as r, defineRoute as s, defineMiddleware as t, type ExtractParams as u, type ArriRouteHandler as v, type RouteHandlerContext as w, type RoutePostHandlerContext as x, type ArriRoutePostHandler as y, registerRoute as z };