arri 0.0.15 → 0.0.17

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.
Files changed (64) hide show
  1. package/dist/chunks/index.cjs +8836 -65
  2. package/dist/chunks/index.mjs +8817 -66
  3. package/dist/cli.cjs +16563 -52524
  4. package/dist/cli.mjs +16529 -52475
  5. package/dist/codegen.cjs +308 -31
  6. package/dist/codegen.d.cts +23 -15
  7. package/dist/codegen.d.mts +23 -15
  8. package/dist/codegen.d.ts +23 -15
  9. package/dist/codegen.mjs +274 -17
  10. package/dist/index.cjs +47 -21
  11. package/dist/index.d.cts +19 -2
  12. package/dist/index.d.mts +19 -2
  13. package/dist/index.d.ts +19 -2
  14. package/dist/index.mjs +30 -1
  15. package/dist/shared/arri.234caf5e.cjs +655 -0
  16. package/dist/shared/arri.38792eb4.cjs +850 -0
  17. package/dist/shared/arri.4d2ea869.mjs +641 -0
  18. package/dist/shared/arri.54e67ffe.mjs +811 -0
  19. package/dist/shared/{arri.bb7e9a4e.d.ts → arri.b176bba1.d.cts} +61 -13
  20. package/dist/shared/{arri.bb7e9a4e.d.cts → arri.b176bba1.d.mts} +61 -13
  21. package/dist/shared/{arri.bb7e9a4e.d.mts → arri.b176bba1.d.ts} +61 -13
  22. package/package.json +1 -1
  23. package/dist/chunks/acorn.cjs +0 -18
  24. package/dist/chunks/acorn.mjs +0 -15
  25. package/dist/chunks/angular.cjs +0 -7
  26. package/dist/chunks/angular.mjs +0 -4
  27. package/dist/chunks/babel.cjs +0 -21
  28. package/dist/chunks/babel.mjs +0 -18
  29. package/dist/chunks/browser.cjs +0 -21
  30. package/dist/chunks/browser.mjs +0 -19
  31. package/dist/chunks/estree.cjs +0 -42
  32. package/dist/chunks/estree.mjs +0 -37
  33. package/dist/chunks/flow.cjs +0 -26
  34. package/dist/chunks/flow.mjs +0 -23
  35. package/dist/chunks/glimmer.cjs +0 -37
  36. package/dist/chunks/glimmer.mjs +0 -32
  37. package/dist/chunks/graphql.cjs +0 -37
  38. package/dist/chunks/graphql.mjs +0 -31
  39. package/dist/chunks/html.cjs +0 -27
  40. package/dist/chunks/html.mjs +0 -21
  41. package/dist/chunks/index2.cjs +0 -231
  42. package/dist/chunks/index2.mjs +0 -220
  43. package/dist/chunks/index3.cjs +0 -1822
  44. package/dist/chunks/index3.mjs +0 -1812
  45. package/dist/chunks/index4.cjs +0 -256
  46. package/dist/chunks/index4.mjs +0 -247
  47. package/dist/chunks/index5.cjs +0 -8854
  48. package/dist/chunks/index5.mjs +0 -8832
  49. package/dist/chunks/markdown.cjs +0 -67
  50. package/dist/chunks/markdown.mjs +0 -61
  51. package/dist/chunks/meriyah.cjs +0 -10
  52. package/dist/chunks/meriyah.mjs +0 -7
  53. package/dist/chunks/postcss.cjs +0 -60
  54. package/dist/chunks/postcss.mjs +0 -54
  55. package/dist/chunks/typescript.cjs +0 -30
  56. package/dist/chunks/typescript.mjs +0 -27
  57. package/dist/chunks/xdg-open.cjs +0 -1071
  58. package/dist/chunks/xdg-open.mjs +0 -1069
  59. package/dist/chunks/yaml.cjs +0 -169
  60. package/dist/chunks/yaml.mjs +0 -163
  61. package/dist/shared/arri.9717f131.cjs +0 -29694
  62. package/dist/shared/arri.bfebed73.cjs +0 -8711
  63. package/dist/shared/arri.dab1f9df.mjs +0 -8670
  64. package/dist/shared/arri.e335c10b.mjs +0 -29668
package/dist/codegen.mjs CHANGED
@@ -1,17 +1,13 @@
1
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
- import 'module';
6
- import 'url';
7
- import 'path';
8
- import 'process';
9
- import 'os';
10
- import 'tty';
11
- import 'assert';
12
- import 'fs/promises';
13
- import 'v8';
14
- import 'util';
2
+ import { format } from 'prettier';
3
+ import { u as unflattenObject, o as isServiceDef, p as pascalCase, q as isProcedureDef, s as isJsonSchemaScalarType, t as isJsonSchemaNullType, v as isJsonSchemaObject, w as isJsonSchemaEnum, x as isJsonSchemaArray, y as unflattenProcedures, z as camelCase } from './shared/arri.54e67ffe.mjs';
4
+ export { K as JsonSchemaComplexTypeValues, I as JsonSchemaNullTypeValues, J as JsonSchemaScalarTypeValues, C as isApplicationDef, B as normalizeWhitespace, G as removeDisallowedChars, F as setNestedObjectProperty } from './shared/arri.54e67ffe.mjs';
5
+ import { d as defineClientGeneratorPlugin } from './shared/arri.4d2ea869.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.4d2ea869.mjs';
7
+ import '@sinclair/typebox';
8
+ import 'h3';
9
+ import '@sinclair/typebox/errors';
10
+ import '@sinclair/typebox/value';
15
11
  import 'child_process';
16
12
 
17
13
  let generatedModels = [];
@@ -41,7 +37,7 @@ async function createTypescriptClient(def, prefix = "Client") {
41
37
  const modelParts = [];
42
38
  Object.keys(services).forEach((key) => {
43
39
  const item = services[key];
44
- if (isServiceDefinition(item)) {
40
+ if (isServiceDef(item)) {
45
41
  const serviceName = pascalCase(`${prefix}_${key}_service`);
46
42
  serviceParts.push({
47
43
  name: serviceName,
@@ -59,7 +55,7 @@ async function createTypescriptClient(def, prefix = "Client") {
59
55
  generatedModels.push(modelName);
60
56
  }
61
57
  });
62
- return format2(
58
+ return format(
63
59
  `/* eslint-disable */
64
60
  import { arriRequest, ArriRequestError } from 'arri-client';
65
61
 
@@ -90,7 +86,7 @@ function tsServiceFromServiceDefinition(name, def) {
90
86
  const subServiceParts = [];
91
87
  Object.keys(def).forEach((key) => {
92
88
  const val = def[key];
93
- if (isProcedureDefinition(val)) {
89
+ if (isProcedureDef(val)) {
94
90
  rpcParts.push(tsRpcFromProcedureDefinition(key, val));
95
91
  return;
96
92
  }
@@ -234,4 +230,265 @@ function tsInterfaceScalarField(key, prop, isOptional = false) {
234
230
  }
235
231
  }
236
232
 
237
- export { createTypescriptClient, defineClientGeneratorPlugin, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator };
233
+ const kotlinClientGenerator = defineClientGeneratorPlugin(function(options) {
234
+ return {
235
+ generator(def) {
236
+ },
237
+ options
238
+ };
239
+ });
240
+ function createKotlinClient(def, clientName, packageName) {
241
+ const procedures = unflattenProcedures(def.procedures);
242
+ const modelParts = [];
243
+ Object.keys(def.models).forEach((key) => {
244
+ const node = def.models[key];
245
+ if (isJsonSchemaObject(node)) {
246
+ modelParts.push(
247
+ createKotlinModelFromDefinition(
248
+ pascalCase(`${clientName}_${key}`),
249
+ node
250
+ )
251
+ );
252
+ }
253
+ });
254
+ return `${importStr(packageName)}
255
+
256
+ ${createKotlinServiceFromDefinition(clientName, clientName, procedures)}
257
+
258
+ ${handleRequestFnString}
259
+ `;
260
+ }
261
+ function createKotlinServiceFromDefinition(clientName, serviceName, def) {
262
+ const rpcParts = [];
263
+ const subServiceParts = [];
264
+ Object.keys(def).forEach((key) => {
265
+ const node = def[key];
266
+ if (isServiceDef(node)) {
267
+ const nameParts = serviceName.split("Service");
268
+ nameParts.pop();
269
+ const subServiceName = pascalCase(
270
+ `${nameParts.join("")}_${key}_service`
271
+ );
272
+ subServiceParts.push({
273
+ name: subServiceName,
274
+ key,
275
+ content: createKotlinServiceFromDefinition(
276
+ clientName,
277
+ subServiceName,
278
+ node
279
+ )
280
+ });
281
+ return;
282
+ }
283
+ rpcParts.push(createKotlinRpcFromDefinition(clientName, key, node));
284
+ });
285
+ return `class ${serviceName}(
286
+ private val httpClient: HttpClient,
287
+ private val baseUrl: string = "",
288
+ private val headers: Map<String, String> = mutableMapOf()
289
+ ) {
290
+ ${subServiceParts.map(
291
+ (service) => `val ${service.key} = ${service.name}(httpClient, baseUrl, headers)`
292
+ ).join("\n")}
293
+ ${rpcParts.join("\n")}
294
+ }
295
+ ${subServiceParts.map((service) => service.content).join("\n")}`;
296
+ }
297
+ function createKotlinRpcFromDefinition(clientName, name, def) {
298
+ const paramStr = def.params ? `params: ${pascalCase(def.params)}` : "";
299
+ const responseStr = def.response ? pascalCase(`${clientName}_${def.response}`) : "";
300
+ return `suspend fun ${camelCase(name)}(${paramStr}): ${responseStr} {
301
+ ${responseStr ? "val response = " : ""}handleRequest(
302
+ httpClient,
303
+ "\${baseUrl}${def.path}",
304
+ HttpMethod.${def.method.toUpperCase()},
305
+ ${paramStr.length ? `Json.encodeToJsonElement(params),
306
+ ` : ""}headers
307
+ )
308
+ ${responseStr ? `return Json.decodeFromString(${responseStr}.serializer(), response.body())` : ""}
309
+ }`;
310
+ }
311
+ function createKotlinModelFromDefinition(name, def) {
312
+ const finalName = pascalCase(name);
313
+ const requiredProps = def.required ?? [];
314
+ const fieldParts = [];
315
+ Object.keys(def.properties).forEach((key) => {
316
+ const isRequired = requiredProps.includes(key);
317
+ const prop = def.properties[key];
318
+ if (isJsonSchemaObject(prop)) {
319
+ const subModelName = pascalCase(`${name}_${key}`);
320
+ createKotlinModelFromDefinition(
321
+ subModelName,
322
+ prop
323
+ );
324
+ fieldParts.push(
325
+ isRequired ? `val ${key}: ${subModelName}` : `val ${key} ${subModelName}?`
326
+ );
327
+ return;
328
+ }
329
+ if (isJsonSchemaScalarType(prop)) {
330
+ switch (prop.type) {
331
+ case "string":
332
+ case "Date":
333
+ fieldParts.push(
334
+ isRequired ? `val ${key}: String` : `val ${key}: String?`
335
+ );
336
+ break;
337
+ case "bigint":
338
+ case "integer":
339
+ fieldParts.push(
340
+ isRequired ? `val ${key}: Int` : `val ${key}: Int?`
341
+ );
342
+ break;
343
+ case "number":
344
+ fieldParts.push(
345
+ isRequired ? `val ${key}: Double` : `val ${key}: Double?`
346
+ );
347
+ break;
348
+ case "boolean":
349
+ fieldParts.push(
350
+ isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
351
+ );
352
+ break;
353
+ }
354
+ return;
355
+ }
356
+ if (isJsonSchemaEnum(prop)) {
357
+ return;
358
+ }
359
+ if (isJsonSchemaNullType(prop)) {
360
+ return;
361
+ }
362
+ if (isJsonSchemaArray(prop)) {
363
+ if (isJsonSchemaScalarType(prop.items)) {
364
+ switch (prop.items.type) {
365
+ case "string":
366
+ case "Date":
367
+ fieldParts.push(
368
+ isRequired ? `val ${key}: List<String>` : `val ${key}: List<String>?`
369
+ );
370
+ break;
371
+ case "bigint":
372
+ case "integer":
373
+ fieldParts.push(
374
+ isRequired ? `val ${key}: Int` : `val ${key}: Int?`
375
+ );
376
+ break;
377
+ case "boolean":
378
+ fieldParts.push(
379
+ isRequired ? `val ${key}: Boolean` : `val ${key}: Boolean?`
380
+ );
381
+ break;
382
+ case "number":
383
+ fieldParts.push(
384
+ isRequired ? `val ${key}: Double` : `val ${key}: Double`
385
+ );
386
+ break;
387
+ }
388
+ }
389
+ }
390
+ });
391
+ return `@Serializable
392
+ data class ${finalName}(
393
+ ${fieldParts.join("\n")}
394
+ )`;
395
+ }
396
+ function importStr(packageName) {
397
+ return `package ${packageName}
398
+
399
+ import io.ktor.client.HttpClient
400
+ import io.ktor.client.call.body
401
+ import io.ktor.client.request.delete
402
+ import io.ktor.client.request.get
403
+ import io.ktor.client.request.head
404
+ import io.ktor.client.request.patch
405
+ import io.ktor.client.request.post
406
+ import io.ktor.client.request.put
407
+ import io.ktor.client.request.setBody
408
+ import io.ktor.client.statement.HttpResponse
409
+ import io.ktor.http.headers
410
+ import kotlinx.serialization.SerialName
411
+ import kotlinx.serialization.Serializable
412
+ import kotlinx.serialization.json.Json
413
+ import kotlinx.serialization.json.JsonElement
414
+ import kotlinx.serialization.json.encodeToJsonElement
415
+ import kotlinx.serialization.json.jsonObject`;
416
+ }
417
+ const handleRequestFnString = `private suspend fun handleRequest(
418
+ client: HttpClient,
419
+ url: String,
420
+ method: HttpMethod,
421
+ params: JsonElement?,
422
+ headers: Map<String, String>?,
423
+ ): HttpResponse {
424
+ var finalUrl = url;
425
+ var finalBody = ""
426
+ when (method) {
427
+ HttpMethod.GET, HttpMethod.HEAD -> {
428
+ var queryParts = mutableListOf<String>()
429
+ params?.jsonObject?.entries?.forEach {
430
+ queryParts.add("\${it.key}=\${it.value.toString()}")
431
+ }
432
+ finalUrl = "$finalUrl?\${queryParts.joinToString("&")}"
433
+ }
434
+
435
+ HttpMethod.POST, HttpMethod.PUT, HttpMethod.PATCH, HttpMethod.DELETE -> {
436
+ finalBody = params?.toString() ?: ""
437
+ }
438
+ }
439
+ return when (method) {
440
+ HttpMethod.GET -> client.get(finalUrl) {
441
+ headers {
442
+ headers?.entries?.forEach {
443
+ append(it.key, it.value)
444
+ }
445
+ }
446
+ }
447
+
448
+ HttpMethod.HEAD -> client.head(finalUrl) {
449
+ headers {
450
+ headers?.entries?.forEach {
451
+ append(it.key, it.value)
452
+ }
453
+ }
454
+ }
455
+
456
+ HttpMethod.POST -> client.post(finalUrl) {
457
+ headers {
458
+ headers?.entries?.forEach {
459
+ append(it.key, it.value)
460
+ }
461
+ }
462
+ setBody(finalBody)
463
+ }
464
+
465
+ HttpMethod.PUT -> client.put(finalUrl) {
466
+ headers {
467
+ headers?.entries?.forEach {
468
+ append(it.key, it.value)
469
+ }
470
+ }
471
+ setBody(finalBody)
472
+ }
473
+
474
+ HttpMethod.PATCH -> client.patch(finalUrl) {
475
+ headers {
476
+ headers?.entries?.forEach {
477
+ append(it.key, it.value)
478
+ }
479
+ }
480
+ setBody(finalBody)
481
+ }
482
+
483
+ HttpMethod.DELETE -> client.delete(finalUrl) {
484
+ headers {
485
+ headers?.entries?.forEach {
486
+ append(it.key, it.value)
487
+ }
488
+ }
489
+ setBody(finalBody)
490
+ }
491
+ }
492
+ }`;
493
+
494
+ export { createKotlinClient, createKotlinModelFromDefinition, createKotlinRpcFromDefinition, createKotlinServiceFromDefinition, createTypescriptClient, defineClientGeneratorPlugin, isJsonSchemaArray, isJsonSchemaEnum, isJsonSchemaNullType, isJsonSchemaObject, isJsonSchemaScalarType, isProcedureDef, isServiceDef, kotlinClientGenerator, tsModelFromDefinition, tsRpcFromProcedureDefinition, tsServiceFromServiceDefinition, typescriptClientGenerator, unflattenObject, unflattenProcedures };
package/dist/index.cjs CHANGED
@@ -1,25 +1,51 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/arri.bfebed73.cjs');
3
+ const app = require('./shared/arri.38792eb4.cjs');
4
+ require('@sinclair/typebox');
5
+ require('h3');
6
+ require('@sinclair/typebox/errors');
7
+ require('@sinclair/typebox/value');
4
8
 
9
+ const defaultConfig = {
10
+ port: 3e3,
11
+ rootDir: ".",
12
+ srcDir: ".",
13
+ entry: "app.ts",
14
+ procedureDir: "procedures",
15
+ procedureGlobPatterns: ["**/*.rpc.ts"],
16
+ clientGenerators: [],
17
+ buildDir: ".arri"
18
+ };
19
+ function defineConfig(config) {
20
+ return {
21
+ port: config.port ?? defaultConfig.port,
22
+ rootDir: config.rootDir ?? defaultConfig.rootDir,
23
+ srcDir: config.srcDir ?? defaultConfig.srcDir,
24
+ entry: config.entry ?? defaultConfig.entry,
25
+ procedureDir: config.procedureDir ?? defaultConfig.procedureDir,
26
+ procedureGlobPatterns: config.procedureGlobPatterns ?? defaultConfig.procedureGlobPatterns,
27
+ clientGenerators: config.clientGenerators ?? defaultConfig.clientGenerators,
28
+ buildDir: config.buildDir ?? defaultConfig.buildDir
29
+ };
30
+ }
5
31
 
6
-
7
- exports.Arri = index.Arri;
8
- exports.DEV_DEFINITION_ENDPOINT = index.DEV_DEFINITION_ENDPOINT;
9
- exports.DEV_ENDPOINT_ROOT = index.DEV_ENDPOINT_ROOT;
10
- exports.ErrorResponse = index.ErrorResponse;
11
- exports.HttpMethodValues = index.HttpMethodValues;
12
- exports.createRpcDefinition = index.createRpcDefinition;
13
- exports.defineError = index.defineError;
14
- exports.defineMiddleware = index.defineMiddleware;
15
- exports.defineRoute = index.defineRoute;
16
- exports.defineRpc = index.defineRpc;
17
- exports.errorResponseFromValidationErrors = index.errorResponseFromValidationErrors;
18
- exports.getRpcParamDefinition = index.getRpcParamDefinition;
19
- exports.getRpcParamName = index.getRpcParamName;
20
- exports.getRpcPath = index.getRpcPath;
21
- exports.getRpcResponseName = index.getRpcResponseName;
22
- exports.isHttpMethod = index.isHttpMethod;
23
- exports.isRpc = index.isRpc;
24
- exports.registerRoute = index.registerRoute;
25
- exports.registerRpc = index.registerRpc;
32
+ exports.Arri = app.Arri;
33
+ exports.DEV_DEFINITION_ENDPOINT = app.DEV_DEFINITION_ENDPOINT;
34
+ exports.DEV_ENDPOINT_ROOT = app.DEV_ENDPOINT_ROOT;
35
+ exports.ErrorResponse = app.ErrorResponse;
36
+ exports.HttpMethodValues = app.HttpMethodValues;
37
+ exports.createRpcDefinition = app.createRpcDefinition;
38
+ exports.defineError = app.defineError;
39
+ exports.defineMiddleware = app.defineMiddleware;
40
+ exports.defineRoute = app.defineRoute;
41
+ exports.defineRpc = app.defineRpc;
42
+ exports.errorResponseFromValidationErrors = app.errorResponseFromValidationErrors;
43
+ exports.getRpcParamDefinition = app.getRpcParamDefinition;
44
+ exports.getRpcParamName = app.getRpcParamName;
45
+ exports.getRpcPath = app.getRpcPath;
46
+ exports.getRpcResponseName = app.getRpcResponseName;
47
+ exports.isHttpMethod = app.isHttpMethod;
48
+ exports.isRpc = app.isRpc;
49
+ exports.registerRoute = app.registerRoute;
50
+ exports.registerRpc = app.registerRpc;
51
+ exports.defineConfig = defineConfig;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
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';
1
+ import { C as ClientGenerator } from './shared/arri.b176bba1.cjs';
2
+ 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.b176bba1.cjs';
2
3
  import * as _sinclair_typebox from '@sinclair/typebox';
3
4
  import { Static } from '@sinclair/typebox';
4
5
  import { ValueError } from '@sinclair/typebox/errors';
@@ -17,4 +18,20 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
17
18
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
18
19
  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;
19
20
 
20
- export { ErrorResponse, type StatusCode, defineError, errorResponseFromValidationErrors };
21
+ interface ArriConfig {
22
+ port: number;
23
+ entry: string;
24
+ rootDir?: string;
25
+ srcDir?: string;
26
+ procedureDir?: string | false;
27
+ /**
28
+ * this defaults to ["***\/*\*.rpc.ts"]
29
+ */
30
+ procedureGlobPatterns?: string[];
31
+ clientGenerators?: Array<ClientGenerator<any>>;
32
+ buildDir?: string;
33
+ }
34
+ type ResolvedArriConfig = Required<ArriConfig>;
35
+ declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
36
+
37
+ export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defineConfig, defineError, errorResponseFromValidationErrors };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
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';
1
+ import { C as ClientGenerator } from './shared/arri.b176bba1.mjs';
2
+ 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.b176bba1.mjs';
2
3
  import * as _sinclair_typebox from '@sinclair/typebox';
3
4
  import { Static } from '@sinclair/typebox';
4
5
  import { ValueError } from '@sinclair/typebox/errors';
@@ -17,4 +18,20 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
17
18
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
18
19
  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;
19
20
 
20
- export { ErrorResponse, type StatusCode, defineError, errorResponseFromValidationErrors };
21
+ interface ArriConfig {
22
+ port: number;
23
+ entry: string;
24
+ rootDir?: string;
25
+ srcDir?: string;
26
+ procedureDir?: string | false;
27
+ /**
28
+ * this defaults to ["***\/*\*.rpc.ts"]
29
+ */
30
+ procedureGlobPatterns?: string[];
31
+ clientGenerators?: Array<ClientGenerator<any>>;
32
+ buildDir?: string;
33
+ }
34
+ type ResolvedArriConfig = Required<ArriConfig>;
35
+ declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
36
+
37
+ export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defineConfig, defineError, errorResponseFromValidationErrors };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
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';
1
+ import { C as ClientGenerator } from './shared/arri.b176bba1.js';
2
+ 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.b176bba1.js';
2
3
  import * as _sinclair_typebox from '@sinclair/typebox';
3
4
  import { Static } from '@sinclair/typebox';
4
5
  import { ValueError } from '@sinclair/typebox/errors';
@@ -17,4 +18,20 @@ declare function defineError(statusCode: StatusCode, input?: Partial<Omit<ErrorR
17
18
  declare function errorResponseFromValidationErrors(errors: ValueError[], prefixText?: string): H3Error;
18
19
  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;
19
20
 
20
- export { ErrorResponse, type StatusCode, defineError, errorResponseFromValidationErrors };
21
+ interface ArriConfig {
22
+ port: number;
23
+ entry: string;
24
+ rootDir?: string;
25
+ srcDir?: string;
26
+ procedureDir?: string | false;
27
+ /**
28
+ * this defaults to ["***\/*\*.rpc.ts"]
29
+ */
30
+ procedureGlobPatterns?: string[];
31
+ clientGenerators?: Array<ClientGenerator<any>>;
32
+ buildDir?: string;
33
+ }
34
+ type ResolvedArriConfig = Required<ArriConfig>;
35
+ declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
36
+
37
+ export { type ArriConfig, ErrorResponse, type ResolvedArriConfig, type StatusCode, defineConfig, defineError, errorResponseFromValidationErrors };
package/dist/index.mjs CHANGED
@@ -1 +1,30 @@
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';
1
+ export { A as Arri, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as ErrorResponse, H as HttpMethodValues, c as createRpcDefinition, m as defineError, k as defineMiddleware, j as defineRoute, d as defineRpc, n as errorResponseFromValidationErrors, f as getRpcParamDefinition, e as getRpcParamName, g as getRpcPath, h as getRpcResponseName, i as isHttpMethod, b as isRpc, l as registerRoute, r as registerRpc } from './shared/arri.54e67ffe.mjs';
2
+ import '@sinclair/typebox';
3
+ import 'h3';
4
+ import '@sinclair/typebox/errors';
5
+ import '@sinclair/typebox/value';
6
+
7
+ const defaultConfig = {
8
+ port: 3e3,
9
+ rootDir: ".",
10
+ srcDir: ".",
11
+ entry: "app.ts",
12
+ procedureDir: "procedures",
13
+ procedureGlobPatterns: ["**/*.rpc.ts"],
14
+ clientGenerators: [],
15
+ buildDir: ".arri"
16
+ };
17
+ function defineConfig(config) {
18
+ return {
19
+ port: config.port ?? defaultConfig.port,
20
+ rootDir: config.rootDir ?? defaultConfig.rootDir,
21
+ srcDir: config.srcDir ?? defaultConfig.srcDir,
22
+ entry: config.entry ?? defaultConfig.entry,
23
+ procedureDir: config.procedureDir ?? defaultConfig.procedureDir,
24
+ procedureGlobPatterns: config.procedureGlobPatterns ?? defaultConfig.procedureGlobPatterns,
25
+ clientGenerators: config.clientGenerators ?? defaultConfig.clientGenerators,
26
+ buildDir: config.buildDir ?? defaultConfig.buildDir
27
+ };
28
+ }
29
+
30
+ export { defineConfig };