arri 0.0.15 → 0.0.16

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.0671bb8c.mjs +641 -0
  16. package/dist/shared/arri.a9b80e98.cjs +655 -0
  17. package/dist/shared/{arri.bb7e9a4e.d.ts → arri.b176bba1.d.cts} +61 -13
  18. package/dist/shared/{arri.bb7e9a4e.d.cts → arri.b176bba1.d.mts} +61 -13
  19. package/dist/shared/{arri.bb7e9a4e.d.mts → arri.b176bba1.d.ts} +61 -13
  20. package/dist/shared/arri.b2f4eb7d.cjs +851 -0
  21. package/dist/shared/arri.fd713b2e.mjs +812 -0
  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
@@ -1,34 +1,54 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
2
  import { Router, H3Event, App, AppOptions } from 'h3';
3
3
 
4
- interface ApplicationDefinition {
5
- schemaVersion: "0.0.1";
6
- description: string;
7
- procedures: Record<string, ProcedureDefinition>;
4
+ interface ApplicationDef {
5
+ arriSchemaVersion: "0.0.1";
6
+ info?: {
7
+ title?: string;
8
+ description?: string;
9
+ version?: string;
10
+ };
11
+ externalDocs?: {
12
+ description?: string;
13
+ url: string;
14
+ };
15
+ procedures: Record<string, ProcedureDef>;
8
16
  models: Record<string, JsonSchemaObject>;
9
17
  errors: Omit<TObject, symbol>;
10
18
  }
11
- interface ProcedureDefinition {
19
+ declare function normalizeWhitespace(input: string): string;
20
+ interface ProcedureDef {
12
21
  path: string;
13
22
  description?: string;
14
23
  method: HttpMethod;
15
24
  params: string | undefined;
16
25
  response: string | undefined;
17
26
  }
18
- interface ServiceDefinition {
19
- [key: string]: ProcedureDefinition | ServiceDefinition;
27
+ declare function isProcedureDef(input: any): input is ProcedureDef;
28
+ interface ServiceDef {
29
+ [key: string]: ProcedureDef | ServiceDef;
20
30
  }
31
+ declare function isServiceDef(input: any): input is ServiceDef;
32
+ declare function isApplicationDef(input: any): input is ApplicationDef;
33
+ declare function unflattenObject(data: Record<string, any>): any;
34
+ declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
+ declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
+ declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
21
37
  declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
22
38
  declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
+ declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
23
40
  type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
+ type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
24
42
  interface JsonSchemaScalarType {
25
43
  title?: string;
26
44
  description?: string;
27
45
  type: (typeof JsonSchemaScalarTypeValues)[number];
28
46
  }
47
+ declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
29
48
  interface JsonSchemaNullType {
30
49
  type: (typeof JsonSchemaNullTypeValues)[number];
31
50
  }
51
+ declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
32
52
  type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray;
33
53
  interface JsonSchemaObject {
34
54
  $id?: string;
@@ -38,6 +58,7 @@ interface JsonSchemaObject {
38
58
  properties: Record<string, JsonSchemaType>;
39
59
  required?: string[];
40
60
  }
61
+ declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
41
62
  interface JsonSchemaArray {
42
63
  $id?: string;
43
64
  title?: string;
@@ -45,6 +66,23 @@ interface JsonSchemaArray {
45
66
  type: "array";
46
67
  items: JsonSchemaType;
47
68
  }
69
+ declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
70
+ interface JsonSchemaUint8Array {
71
+ type: "Uint8Array";
72
+ }
73
+ interface JsonSchemaEnum {
74
+ anyOf: Array<{
75
+ type: "string";
76
+ const: string;
77
+ }> | Array<{
78
+ type: "number";
79
+ const: number;
80
+ }> | Array<{
81
+ type: "integer";
82
+ const: number;
83
+ }>;
84
+ }
85
+ declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
48
86
 
49
87
  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> {
50
88
  path: TPath;
@@ -101,21 +139,24 @@ type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TPar
101
139
  type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
102
140
  declare function isRpc(input: any): input is ArriProcedure<any, any>;
103
141
  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;
142
+ declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
105
143
  declare function getRpcPath(rpcName: string, prefix?: string): string;
106
144
  declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
107
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
145
+ declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
108
146
  declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
109
147
  declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
110
148
 
111
149
  interface ArriOptions extends AppOptions {
150
+ /**
151
+ * Metadata to display in the __definition.json file
152
+ */
153
+ appInfo?: ApplicationDef["info"];
112
154
  rpcRoutePrefix?: string;
113
155
  /**
114
156
  * Defaults to /__definitions
115
157
  * This parameters also takes the rpcRoutePrefix option into account
116
158
  */
117
159
  rpcDefinitionPath?: string;
118
- appDescription?: string;
119
160
  }
120
161
  declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
121
162
  declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
@@ -125,19 +166,26 @@ declare class Arri {
125
166
  private readonly h3Router;
126
167
  private readonly rpcDefinitionPath;
127
168
  private readonly rpcRoutePrefix;
169
+ appInfo: ApplicationDef["info"];
128
170
  private procedures;
129
171
  private models;
130
172
  private readonly middlewares;
131
- private readonly appDescription;
132
173
  constructor(opts?: ArriOptions);
133
174
  registerMiddleware(middleware: Middleware): void;
134
175
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
135
176
  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;
136
- getAppDefinition(): ApplicationDefinition;
177
+ getAppDefinition(): ApplicationDef;
137
178
  getH3Instance(): App;
138
179
  }
139
180
  declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
140
181
  type HttpMethod = (typeof HttpMethodValues)[number];
141
182
  declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
142
183
 
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 };
184
+ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
185
+ generator: (def: ApplicationDef) => any;
186
+ options: TOptions;
187
+ }
188
+ type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
189
+ declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
190
+
191
+ export { isJsonSchemaScalarType as $, Arri as A, type ClientGeneratorPlugin as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ApplicationDef as F, defineClientGeneratorPlugin as G, HttpMethodValues as H, normalizeWhitespace as I, type JsonSchemaObject as J, isProcedureDef as K, isServiceDef as L, type Middleware as M, isApplicationDef as N, unflattenObject as O, type ProcedureDef as P, unflattenProcedures as Q, type RpcHandlerContext as R, type ServiceDef as S, setNestedObjectProperty as T, removeDisallowedChars as U, JsonSchemaScalarTypeValues as V, JsonSchemaNullTypeValues as W, JsonSchemaComplexTypeValues as X, type JsonSchemaType as Y, type JsonSchemaTypeValue as Z, type JsonSchemaScalarType as _, DEV_DEFINITION_ENDPOINT as a, type JsonSchemaNullType as a0, isJsonSchemaNullType as a1, type JsonSchemaComplexType as a2, isJsonSchemaObject as a3, type JsonSchemaArray as a4, isJsonSchemaArray as a5, type JsonSchemaUint8Array as a6, type JsonSchemaEnum as a7, isJsonSchemaEnum as a8, 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,34 +1,54 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
2
  import { Router, H3Event, App, AppOptions } from 'h3';
3
3
 
4
- interface ApplicationDefinition {
5
- schemaVersion: "0.0.1";
6
- description: string;
7
- procedures: Record<string, ProcedureDefinition>;
4
+ interface ApplicationDef {
5
+ arriSchemaVersion: "0.0.1";
6
+ info?: {
7
+ title?: string;
8
+ description?: string;
9
+ version?: string;
10
+ };
11
+ externalDocs?: {
12
+ description?: string;
13
+ url: string;
14
+ };
15
+ procedures: Record<string, ProcedureDef>;
8
16
  models: Record<string, JsonSchemaObject>;
9
17
  errors: Omit<TObject, symbol>;
10
18
  }
11
- interface ProcedureDefinition {
19
+ declare function normalizeWhitespace(input: string): string;
20
+ interface ProcedureDef {
12
21
  path: string;
13
22
  description?: string;
14
23
  method: HttpMethod;
15
24
  params: string | undefined;
16
25
  response: string | undefined;
17
26
  }
18
- interface ServiceDefinition {
19
- [key: string]: ProcedureDefinition | ServiceDefinition;
27
+ declare function isProcedureDef(input: any): input is ProcedureDef;
28
+ interface ServiceDef {
29
+ [key: string]: ProcedureDef | ServiceDef;
20
30
  }
31
+ declare function isServiceDef(input: any): input is ServiceDef;
32
+ declare function isApplicationDef(input: any): input is ApplicationDef;
33
+ declare function unflattenObject(data: Record<string, any>): any;
34
+ declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
+ declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
+ declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
21
37
  declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
22
38
  declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
+ declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
23
40
  type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
+ type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
24
42
  interface JsonSchemaScalarType {
25
43
  title?: string;
26
44
  description?: string;
27
45
  type: (typeof JsonSchemaScalarTypeValues)[number];
28
46
  }
47
+ declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
29
48
  interface JsonSchemaNullType {
30
49
  type: (typeof JsonSchemaNullTypeValues)[number];
31
50
  }
51
+ declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
32
52
  type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray;
33
53
  interface JsonSchemaObject {
34
54
  $id?: string;
@@ -38,6 +58,7 @@ interface JsonSchemaObject {
38
58
  properties: Record<string, JsonSchemaType>;
39
59
  required?: string[];
40
60
  }
61
+ declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
41
62
  interface JsonSchemaArray {
42
63
  $id?: string;
43
64
  title?: string;
@@ -45,6 +66,23 @@ interface JsonSchemaArray {
45
66
  type: "array";
46
67
  items: JsonSchemaType;
47
68
  }
69
+ declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
70
+ interface JsonSchemaUint8Array {
71
+ type: "Uint8Array";
72
+ }
73
+ interface JsonSchemaEnum {
74
+ anyOf: Array<{
75
+ type: "string";
76
+ const: string;
77
+ }> | Array<{
78
+ type: "number";
79
+ const: number;
80
+ }> | Array<{
81
+ type: "integer";
82
+ const: number;
83
+ }>;
84
+ }
85
+ declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
48
86
 
49
87
  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> {
50
88
  path: TPath;
@@ -101,21 +139,24 @@ type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TPar
101
139
  type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
102
140
  declare function isRpc(input: any): input is ArriProcedure<any, any>;
103
141
  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;
142
+ declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
105
143
  declare function getRpcPath(rpcName: string, prefix?: string): string;
106
144
  declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
107
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
145
+ declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
108
146
  declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
109
147
  declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
110
148
 
111
149
  interface ArriOptions extends AppOptions {
150
+ /**
151
+ * Metadata to display in the __definition.json file
152
+ */
153
+ appInfo?: ApplicationDef["info"];
112
154
  rpcRoutePrefix?: string;
113
155
  /**
114
156
  * Defaults to /__definitions
115
157
  * This parameters also takes the rpcRoutePrefix option into account
116
158
  */
117
159
  rpcDefinitionPath?: string;
118
- appDescription?: string;
119
160
  }
120
161
  declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
121
162
  declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
@@ -125,19 +166,26 @@ declare class Arri {
125
166
  private readonly h3Router;
126
167
  private readonly rpcDefinitionPath;
127
168
  private readonly rpcRoutePrefix;
169
+ appInfo: ApplicationDef["info"];
128
170
  private procedures;
129
171
  private models;
130
172
  private readonly middlewares;
131
- private readonly appDescription;
132
173
  constructor(opts?: ArriOptions);
133
174
  registerMiddleware(middleware: Middleware): void;
134
175
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
135
176
  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;
136
- getAppDefinition(): ApplicationDefinition;
177
+ getAppDefinition(): ApplicationDef;
137
178
  getH3Instance(): App;
138
179
  }
139
180
  declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
140
181
  type HttpMethod = (typeof HttpMethodValues)[number];
141
182
  declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
142
183
 
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 };
184
+ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
185
+ generator: (def: ApplicationDef) => any;
186
+ options: TOptions;
187
+ }
188
+ type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
189
+ declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
190
+
191
+ export { isJsonSchemaScalarType as $, Arri as A, type ClientGeneratorPlugin as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ApplicationDef as F, defineClientGeneratorPlugin as G, HttpMethodValues as H, normalizeWhitespace as I, type JsonSchemaObject as J, isProcedureDef as K, isServiceDef as L, type Middleware as M, isApplicationDef as N, unflattenObject as O, type ProcedureDef as P, unflattenProcedures as Q, type RpcHandlerContext as R, type ServiceDef as S, setNestedObjectProperty as T, removeDisallowedChars as U, JsonSchemaScalarTypeValues as V, JsonSchemaNullTypeValues as W, JsonSchemaComplexTypeValues as X, type JsonSchemaType as Y, type JsonSchemaTypeValue as Z, type JsonSchemaScalarType as _, DEV_DEFINITION_ENDPOINT as a, type JsonSchemaNullType as a0, isJsonSchemaNullType as a1, type JsonSchemaComplexType as a2, isJsonSchemaObject as a3, type JsonSchemaArray as a4, isJsonSchemaArray as a5, type JsonSchemaUint8Array as a6, type JsonSchemaEnum as a7, isJsonSchemaEnum as a8, 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,34 +1,54 @@
1
1
  import { TObject, TSchema, Static } from '@sinclair/typebox';
2
2
  import { Router, H3Event, App, AppOptions } from 'h3';
3
3
 
4
- interface ApplicationDefinition {
5
- schemaVersion: "0.0.1";
6
- description: string;
7
- procedures: Record<string, ProcedureDefinition>;
4
+ interface ApplicationDef {
5
+ arriSchemaVersion: "0.0.1";
6
+ info?: {
7
+ title?: string;
8
+ description?: string;
9
+ version?: string;
10
+ };
11
+ externalDocs?: {
12
+ description?: string;
13
+ url: string;
14
+ };
15
+ procedures: Record<string, ProcedureDef>;
8
16
  models: Record<string, JsonSchemaObject>;
9
17
  errors: Omit<TObject, symbol>;
10
18
  }
11
- interface ProcedureDefinition {
19
+ declare function normalizeWhitespace(input: string): string;
20
+ interface ProcedureDef {
12
21
  path: string;
13
22
  description?: string;
14
23
  method: HttpMethod;
15
24
  params: string | undefined;
16
25
  response: string | undefined;
17
26
  }
18
- interface ServiceDefinition {
19
- [key: string]: ProcedureDefinition | ServiceDefinition;
27
+ declare function isProcedureDef(input: any): input is ProcedureDef;
28
+ interface ServiceDef {
29
+ [key: string]: ProcedureDef | ServiceDef;
20
30
  }
31
+ declare function isServiceDef(input: any): input is ServiceDef;
32
+ declare function isApplicationDef(input: any): input is ApplicationDef;
33
+ declare function unflattenObject(data: Record<string, any>): any;
34
+ declare function unflattenProcedures(procedures: ApplicationDef["procedures"]): Record<string, ProcedureDef | ServiceDef>;
35
+ declare function setNestedObjectProperty<T>(targetProp: string, value: T, object: Record<any, any>): Record<any, any>;
36
+ declare const removeDisallowedChars: (input: string, disallowedChars: string) => string;
21
37
  declare const JsonSchemaScalarTypeValues: readonly ["integer", "number", "bigint", "string", "boolean", "Date"];
22
38
  declare const JsonSchemaNullTypeValues: readonly ["null", "undefined"];
39
+ declare const JsonSchemaComplexTypeValues: readonly ["object", "list", "array", "Uint8Array"];
23
40
  type JsonSchemaType = JsonSchemaScalarType | JsonSchemaNullType | JsonSchemaComplexType;
41
+ type JsonSchemaTypeValue = (typeof JsonSchemaScalarTypeValues)[number] | (typeof JsonSchemaNullTypeValues)[number] | (typeof JsonSchemaComplexTypeValues)[number];
24
42
  interface JsonSchemaScalarType {
25
43
  title?: string;
26
44
  description?: string;
27
45
  type: (typeof JsonSchemaScalarTypeValues)[number];
28
46
  }
47
+ declare function isJsonSchemaScalarType(input: any): input is JsonSchemaScalarType;
29
48
  interface JsonSchemaNullType {
30
49
  type: (typeof JsonSchemaNullTypeValues)[number];
31
50
  }
51
+ declare function isJsonSchemaNullType(input: any): input is JsonSchemaNullType;
32
52
  type JsonSchemaComplexType = JsonSchemaObject | JsonSchemaArray;
33
53
  interface JsonSchemaObject {
34
54
  $id?: string;
@@ -38,6 +58,7 @@ interface JsonSchemaObject {
38
58
  properties: Record<string, JsonSchemaType>;
39
59
  required?: string[];
40
60
  }
61
+ declare const isJsonSchemaObject: (input: any) => input is JsonSchemaObject;
41
62
  interface JsonSchemaArray {
42
63
  $id?: string;
43
64
  title?: string;
@@ -45,6 +66,23 @@ interface JsonSchemaArray {
45
66
  type: "array";
46
67
  items: JsonSchemaType;
47
68
  }
69
+ declare function isJsonSchemaArray(input: any): input is JsonSchemaArray;
70
+ interface JsonSchemaUint8Array {
71
+ type: "Uint8Array";
72
+ }
73
+ interface JsonSchemaEnum {
74
+ anyOf: Array<{
75
+ type: "string";
76
+ const: string;
77
+ }> | Array<{
78
+ type: "number";
79
+ const: number;
80
+ }> | Array<{
81
+ type: "integer";
82
+ const: number;
83
+ }>;
84
+ }
85
+ declare function isJsonSchemaEnum(input: any): input is JsonSchemaEnum;
48
86
 
49
87
  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> {
50
88
  path: TPath;
@@ -101,21 +139,24 @@ type ArriProcedureHandler<TParams, TResponse> = (context: RpcHandlerContext<TPar
101
139
  type ArriProcedurePostHandler<TParams, TResponse> = (event: RpcPostHandlerContext<TParams, TResponse>) => any;
102
140
  declare function isRpc(input: any): input is ArriProcedure<any, any>;
103
141
  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;
142
+ declare function createRpcDefinition(rpcName: string, httpPath: string, procedure: ArriProcedure<any, any>): ProcedureDef;
105
143
  declare function getRpcPath(rpcName: string, prefix?: string): string;
106
144
  declare function getRpcParamName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
107
- declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDefinition["params"];
145
+ declare function getRpcParamDefinition(rpcName: string, procedure: ArriProcedure<any, any>): ProcedureDef["params"];
108
146
  declare function getRpcResponseName(rpcName: string, procedure: ArriProcedure<any, any>): string | null;
109
147
  declare function registerRpc(router: Router, path: string, procedure: ArriProcedure<any, any>, middleware: Middleware[]): void;
110
148
 
111
149
  interface ArriOptions extends AppOptions {
150
+ /**
151
+ * Metadata to display in the __definition.json file
152
+ */
153
+ appInfo?: ApplicationDef["info"];
112
154
  rpcRoutePrefix?: string;
113
155
  /**
114
156
  * Defaults to /__definitions
115
157
  * This parameters also takes the rpcRoutePrefix option into account
116
158
  */
117
159
  rpcDefinitionPath?: string;
118
- appDescription?: string;
119
160
  }
120
161
  declare const DEV_ENDPOINT_ROOT = "/__arri_dev__";
121
162
  declare const DEV_DEFINITION_ENDPOINT = "/__arri_dev__/definition";
@@ -125,19 +166,26 @@ declare class Arri {
125
166
  private readonly h3Router;
126
167
  private readonly rpcDefinitionPath;
127
168
  private readonly rpcRoutePrefix;
169
+ appInfo: ApplicationDef["info"];
128
170
  private procedures;
129
171
  private models;
130
172
  private readonly middlewares;
131
- private readonly appDescription;
132
173
  constructor(opts?: ArriOptions);
133
174
  registerMiddleware(middleware: Middleware): void;
134
175
  registerRpc<TParams extends TObject | undefined, TResponse extends TObject | undefined>(name: string, procedure: ArriProcedure<TParams, TResponse>): void;
135
176
  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;
136
- getAppDefinition(): ApplicationDefinition;
177
+ getAppDefinition(): ApplicationDef;
137
178
  getH3Instance(): App;
138
179
  }
139
180
  declare const HttpMethodValues: readonly ["get", "post", "put", "patch", "delete", "head"];
140
181
  type HttpMethod = (typeof HttpMethodValues)[number];
141
182
  declare const isHttpMethod: (input: any) => input is "get" | "post" | "put" | "patch" | "delete" | "head";
142
183
 
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 };
184
+ interface ClientGenerator<TOptions extends Record<string, any> | undefined> {
185
+ generator: (def: ApplicationDef) => any;
186
+ options: TOptions;
187
+ }
188
+ type ClientGeneratorPlugin<TOptions extends Record<string, any> | undefined> = (options: TOptions) => ClientGenerator<TOptions>;
189
+ declare function defineClientGeneratorPlugin<TOptions extends Record<string, any> | undefined>(plugin: ClientGeneratorPlugin<TOptions>): ClientGeneratorPlugin<TOptions>;
190
+
191
+ export { isJsonSchemaScalarType as $, Arri as A, type ClientGeneratorPlugin as B, type ClientGenerator as C, DEV_ENDPOINT_ROOT as D, type ExtractParam as E, type ApplicationDef as F, defineClientGeneratorPlugin as G, HttpMethodValues as H, normalizeWhitespace as I, type JsonSchemaObject as J, isProcedureDef as K, isServiceDef as L, type Middleware as M, isApplicationDef as N, unflattenObject as O, type ProcedureDef as P, unflattenProcedures as Q, type RpcHandlerContext as R, type ServiceDef as S, setNestedObjectProperty as T, removeDisallowedChars as U, JsonSchemaScalarTypeValues as V, JsonSchemaNullTypeValues as W, JsonSchemaComplexTypeValues as X, type JsonSchemaType as Y, type JsonSchemaTypeValue as Z, type JsonSchemaScalarType as _, DEV_DEFINITION_ENDPOINT as a, type JsonSchemaNullType as a0, isJsonSchemaNullType as a1, type JsonSchemaComplexType as a2, isJsonSchemaObject as a3, type JsonSchemaArray as a4, isJsonSchemaArray as a5, type JsonSchemaUint8Array as a6, type JsonSchemaEnum as a7, isJsonSchemaEnum as a8, 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 };