@arrirpc/codegen-ts 0.65.2 → 0.66.0
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/index.cjs +12 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.mjs +5 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -898,6 +898,9 @@ function tsRefFromSchema(schema, context) {
|
|
|
898
898
|
};
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
+
function defineRpcGenerator(fn) {
|
|
902
|
+
return fn;
|
|
903
|
+
}
|
|
901
904
|
function tsRpcFromDefinition(def, context) {
|
|
902
905
|
const customFn = context.rpcGenerators[def.transport];
|
|
903
906
|
if (customFn)
|
|
@@ -1080,7 +1083,7 @@ function getServiceName(context) {
|
|
|
1080
1083
|
|
|
1081
1084
|
const typescriptClientGenerator = codegenUtils.defineGeneratorPlugin(
|
|
1082
1085
|
(options) => ({
|
|
1083
|
-
|
|
1086
|
+
run: async (def) => {
|
|
1084
1087
|
if (!options.clientName) {
|
|
1085
1088
|
throw new Error("Name is requires");
|
|
1086
1089
|
}
|
|
@@ -1239,5 +1242,13 @@ function tsTypeFromSchema(schema, context) {
|
|
|
1239
1242
|
}
|
|
1240
1243
|
|
|
1241
1244
|
exports.createTypescriptClient = createTypescriptClient;
|
|
1245
|
+
exports.defineRpcGenerator = defineRpcGenerator;
|
|
1246
|
+
exports.getJsDocComment = getJsDocComment;
|
|
1247
|
+
exports.getRpcKey = getRpcKey;
|
|
1248
|
+
exports.getTsTypeName = getTsTypeName;
|
|
1249
|
+
exports.httpRpcFromDefinition = httpRpcFromDefinition;
|
|
1250
|
+
exports.tsRpcFromDefinition = tsRpcFromDefinition;
|
|
1242
1251
|
exports.tsTypeFromSchema = tsTypeFromSchema;
|
|
1243
1252
|
exports.typescriptClientGenerator = typescriptClientGenerator;
|
|
1253
|
+
exports.validVarName = validVarName;
|
|
1254
|
+
exports.wsRpcFromDefinition = wsRpcFromDefinition;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as _arrirpc_codegen_utils from '@arrirpc/codegen-utils';
|
|
2
|
-
import { RpcDefinition,
|
|
2
|
+
import { RpcDefinition, HttpRpcDefinition, WsRpcDefinition, Schema, AppDefinition } from '@arrirpc/codegen-utils';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type RpcGenerator = (def: RpcDefinition, context: CodegenContext) => string;
|
|
6
|
+
declare function defineRpcGenerator(fn: RpcGenerator): RpcGenerator;
|
|
7
|
+
declare function tsRpcFromDefinition(def: RpcDefinition, context: CodegenContext): string;
|
|
8
|
+
declare function httpRpcFromDefinition(def: HttpRpcDefinition, context: CodegenContext): string;
|
|
9
|
+
declare function wsRpcFromDefinition(def: WsRpcDefinition, context: CodegenContext): string;
|
|
10
|
+
declare function getRpcKey(context: CodegenContext): string;
|
|
6
11
|
|
|
7
12
|
interface TsProperty {
|
|
8
13
|
typeName: string;
|
|
@@ -27,8 +32,11 @@ interface CodegenContext {
|
|
|
27
32
|
sse: boolean;
|
|
28
33
|
ws: boolean;
|
|
29
34
|
};
|
|
30
|
-
rpcGenerators: Record<string,
|
|
35
|
+
rpcGenerators: Record<string, RpcGenerator>;
|
|
31
36
|
}
|
|
37
|
+
declare function getJsDocComment(metadata: Schema["metadata"]): string;
|
|
38
|
+
declare function validVarName(name: string): string;
|
|
39
|
+
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
32
40
|
|
|
33
41
|
interface TypescriptGeneratorOptions {
|
|
34
42
|
clientName: string;
|
|
@@ -38,10 +46,10 @@ interface TypescriptGeneratorOptions {
|
|
|
38
46
|
/**
|
|
39
47
|
* Override the default functions used for creating procedures
|
|
40
48
|
*/
|
|
41
|
-
rpcGenerators?: Record<RpcDefinition["transport"],
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition["transport"], RpcGenerator>;
|
|
42
50
|
}
|
|
43
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
44
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
|
45
53
|
declare function tsTypeFromSchema(schema: Schema, context: CodegenContext): TsProperty;
|
|
46
54
|
|
|
47
|
-
export { type TypescriptGeneratorOptions, createTypescriptClient, tsTypeFromSchema, typescriptClientGenerator };
|
|
55
|
+
export { type CodegenContext, type RpcGenerator, type TsProperty, type TypescriptGeneratorOptions, createTypescriptClient, defineRpcGenerator, getJsDocComment, getRpcKey, getTsTypeName, httpRpcFromDefinition, tsRpcFromDefinition, tsTypeFromSchema, typescriptClientGenerator, validVarName, wsRpcFromDefinition };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as _arrirpc_codegen_utils from '@arrirpc/codegen-utils';
|
|
2
|
-
import { RpcDefinition,
|
|
2
|
+
import { RpcDefinition, HttpRpcDefinition, WsRpcDefinition, Schema, AppDefinition } from '@arrirpc/codegen-utils';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type RpcGenerator = (def: RpcDefinition, context: CodegenContext) => string;
|
|
6
|
+
declare function defineRpcGenerator(fn: RpcGenerator): RpcGenerator;
|
|
7
|
+
declare function tsRpcFromDefinition(def: RpcDefinition, context: CodegenContext): string;
|
|
8
|
+
declare function httpRpcFromDefinition(def: HttpRpcDefinition, context: CodegenContext): string;
|
|
9
|
+
declare function wsRpcFromDefinition(def: WsRpcDefinition, context: CodegenContext): string;
|
|
10
|
+
declare function getRpcKey(context: CodegenContext): string;
|
|
6
11
|
|
|
7
12
|
interface TsProperty {
|
|
8
13
|
typeName: string;
|
|
@@ -27,8 +32,11 @@ interface CodegenContext {
|
|
|
27
32
|
sse: boolean;
|
|
28
33
|
ws: boolean;
|
|
29
34
|
};
|
|
30
|
-
rpcGenerators: Record<string,
|
|
35
|
+
rpcGenerators: Record<string, RpcGenerator>;
|
|
31
36
|
}
|
|
37
|
+
declare function getJsDocComment(metadata: Schema["metadata"]): string;
|
|
38
|
+
declare function validVarName(name: string): string;
|
|
39
|
+
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
32
40
|
|
|
33
41
|
interface TypescriptGeneratorOptions {
|
|
34
42
|
clientName: string;
|
|
@@ -38,10 +46,10 @@ interface TypescriptGeneratorOptions {
|
|
|
38
46
|
/**
|
|
39
47
|
* Override the default functions used for creating procedures
|
|
40
48
|
*/
|
|
41
|
-
rpcGenerators?: Record<RpcDefinition["transport"],
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition["transport"], RpcGenerator>;
|
|
42
50
|
}
|
|
43
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
44
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
|
45
53
|
declare function tsTypeFromSchema(schema: Schema, context: CodegenContext): TsProperty;
|
|
46
54
|
|
|
47
|
-
export { type TypescriptGeneratorOptions, createTypescriptClient, tsTypeFromSchema, typescriptClientGenerator };
|
|
55
|
+
export { type CodegenContext, type RpcGenerator, type TsProperty, type TypescriptGeneratorOptions, createTypescriptClient, defineRpcGenerator, getJsDocComment, getRpcKey, getTsTypeName, httpRpcFromDefinition, tsRpcFromDefinition, tsTypeFromSchema, typescriptClientGenerator, validVarName, wsRpcFromDefinition };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as _arrirpc_codegen_utils from '@arrirpc/codegen-utils';
|
|
2
|
-
import { RpcDefinition,
|
|
2
|
+
import { RpcDefinition, HttpRpcDefinition, WsRpcDefinition, Schema, AppDefinition } from '@arrirpc/codegen-utils';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type RpcGenerator = (def: RpcDefinition, context: CodegenContext) => string;
|
|
6
|
+
declare function defineRpcGenerator(fn: RpcGenerator): RpcGenerator;
|
|
7
|
+
declare function tsRpcFromDefinition(def: RpcDefinition, context: CodegenContext): string;
|
|
8
|
+
declare function httpRpcFromDefinition(def: HttpRpcDefinition, context: CodegenContext): string;
|
|
9
|
+
declare function wsRpcFromDefinition(def: WsRpcDefinition, context: CodegenContext): string;
|
|
10
|
+
declare function getRpcKey(context: CodegenContext): string;
|
|
6
11
|
|
|
7
12
|
interface TsProperty {
|
|
8
13
|
typeName: string;
|
|
@@ -27,8 +32,11 @@ interface CodegenContext {
|
|
|
27
32
|
sse: boolean;
|
|
28
33
|
ws: boolean;
|
|
29
34
|
};
|
|
30
|
-
rpcGenerators: Record<string,
|
|
35
|
+
rpcGenerators: Record<string, RpcGenerator>;
|
|
31
36
|
}
|
|
37
|
+
declare function getJsDocComment(metadata: Schema["metadata"]): string;
|
|
38
|
+
declare function validVarName(name: string): string;
|
|
39
|
+
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
32
40
|
|
|
33
41
|
interface TypescriptGeneratorOptions {
|
|
34
42
|
clientName: string;
|
|
@@ -38,10 +46,10 @@ interface TypescriptGeneratorOptions {
|
|
|
38
46
|
/**
|
|
39
47
|
* Override the default functions used for creating procedures
|
|
40
48
|
*/
|
|
41
|
-
rpcGenerators?: Record<RpcDefinition["transport"],
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition["transport"], RpcGenerator>;
|
|
42
50
|
}
|
|
43
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
44
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
|
45
53
|
declare function tsTypeFromSchema(schema: Schema, context: CodegenContext): TsProperty;
|
|
46
54
|
|
|
47
|
-
export { type TypescriptGeneratorOptions, createTypescriptClient, tsTypeFromSchema, typescriptClientGenerator };
|
|
55
|
+
export { type CodegenContext, type RpcGenerator, type TsProperty, type TypescriptGeneratorOptions, createTypescriptClient, defineRpcGenerator, getJsDocComment, getRpcKey, getTsTypeName, httpRpcFromDefinition, tsRpcFromDefinition, tsTypeFromSchema, typescriptClientGenerator, validVarName, wsRpcFromDefinition };
|
package/dist/index.mjs
CHANGED
|
@@ -892,6 +892,9 @@ function tsRefFromSchema(schema, context) {
|
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
+
function defineRpcGenerator(fn) {
|
|
896
|
+
return fn;
|
|
897
|
+
}
|
|
895
898
|
function tsRpcFromDefinition(def, context) {
|
|
896
899
|
const customFn = context.rpcGenerators[def.transport];
|
|
897
900
|
if (customFn)
|
|
@@ -1074,7 +1077,7 @@ function getServiceName(context) {
|
|
|
1074
1077
|
|
|
1075
1078
|
const typescriptClientGenerator = defineGeneratorPlugin(
|
|
1076
1079
|
(options) => ({
|
|
1077
|
-
|
|
1080
|
+
run: async (def) => {
|
|
1078
1081
|
if (!options.clientName) {
|
|
1079
1082
|
throw new Error("Name is requires");
|
|
1080
1083
|
}
|
|
@@ -1232,4 +1235,4 @@ function tsTypeFromSchema(schema, context) {
|
|
|
1232
1235
|
return tsAnyFromSchema(schema, context);
|
|
1233
1236
|
}
|
|
1234
1237
|
|
|
1235
|
-
export { createTypescriptClient, tsTypeFromSchema, typescriptClientGenerator };
|
|
1238
|
+
export { createTypescriptClient, defineRpcGenerator, getJsDocComment, getRpcKey, getTsTypeName, httpRpcFromDefinition, tsRpcFromDefinition, tsTypeFromSchema, typescriptClientGenerator, validVarName, wsRpcFromDefinition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/codegen-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"prettier": "^3.3.3",
|
|
26
|
-
"@arrirpc/codegen-utils": "0.
|
|
26
|
+
"@arrirpc/codegen-utils": "0.66.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {}
|
|
29
29
|
}
|