@arrirpc/codegen-ts 0.69.2 → 0.71.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 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +12 -16
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ function tsAnyFromSchema(schema, context) {
|
|
|
24
24
|
return `${target} += JSON.stringify(${input})`;
|
|
25
25
|
},
|
|
26
26
|
toQueryStringTemplate(_input, _target, _key) {
|
|
27
|
-
return `console.warn(
|
|
27
|
+
return `console.warn('[WARNING] Cannot serialize any\\'s to query string. Skipping property at ${context.instancePath}.')`;
|
|
28
28
|
},
|
|
29
29
|
content: ""
|
|
30
30
|
};
|
|
@@ -181,7 +181,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
181
181
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
182
182
|
},
|
|
183
183
|
toQueryStringTemplate(_input, _target) {
|
|
184
|
-
return `console.warn(
|
|
184
|
+
return `console.warn('[WARNING] Cannot serialize nested objects to query string. Skipping property at ${context.instancePath}.')`;
|
|
185
185
|
},
|
|
186
186
|
content: ""
|
|
187
187
|
};
|
|
@@ -229,8 +229,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
229
229
|
usedFeatures: context.usedFeatures,
|
|
230
230
|
rpcGenerators: context.rpcGenerators
|
|
231
231
|
});
|
|
232
|
-
if (prop.content)
|
|
233
|
-
subContentParts.push(prop.content);
|
|
232
|
+
if (prop.content) subContentParts.push(prop.content);
|
|
234
233
|
const fieldName = validVarName(codegenUtils.camelCase(key, { normalize: true }));
|
|
235
234
|
fieldParts.push(
|
|
236
235
|
`${getJsDocComment(subSchema.metadata)}${fieldName}: ${prop.typeName},`
|
|
@@ -273,8 +272,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
273
272
|
usedFeatures: context.usedFeatures,
|
|
274
273
|
rpcGenerators: context.rpcGenerators
|
|
275
274
|
});
|
|
276
|
-
if (prop.content)
|
|
277
|
-
subContentParts.push(prop.content);
|
|
275
|
+
if (prop.content) subContentParts.push(prop.content);
|
|
278
276
|
const fieldName = validVarName(codegenUtils.camelCase(key, { normalize: true }));
|
|
279
277
|
fieldParts.push(
|
|
280
278
|
`${getJsDocComment(subSchema.metadata)}${fieldName}?: ${prop.typeName},`
|
|
@@ -379,12 +377,11 @@ function tsTaggedUnionFromSchema(schema, context) {
|
|
|
379
377
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
380
378
|
},
|
|
381
379
|
toQueryStringTemplate(_, __, ___) {
|
|
382
|
-
return `console.warn(
|
|
380
|
+
return `console.warn('[WARNING] Cannot serialize nested objects to query string. Skipping property at ${context.instancePath}.');`;
|
|
383
381
|
},
|
|
384
382
|
content: ""
|
|
385
383
|
};
|
|
386
|
-
if (context.generatedTypes.includes(typeName))
|
|
387
|
-
return result;
|
|
384
|
+
if (context.generatedTypes.includes(typeName)) return result;
|
|
388
385
|
const subTypes = [];
|
|
389
386
|
const discriminatorKey = schema.discriminator;
|
|
390
387
|
for (const key of Object.keys(schema.mapping)) {
|
|
@@ -892,7 +889,7 @@ function tsRefFromSchema(schema, context) {
|
|
|
892
889
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
893
890
|
},
|
|
894
891
|
toQueryStringTemplate(_, __, ___) {
|
|
895
|
-
return `console.warn(
|
|
892
|
+
return `console.warn('[WARNING] Nested objects cannot be serialized to query string. Ignoring property at ${context.instancePath}.');`;
|
|
896
893
|
},
|
|
897
894
|
content: ""
|
|
898
895
|
};
|
|
@@ -903,8 +900,7 @@ function defineRpcGenerator(fn) {
|
|
|
903
900
|
}
|
|
904
901
|
function tsRpcFromDefinition(def, context) {
|
|
905
902
|
const customFn = context.rpcGenerators[def.transport];
|
|
906
|
-
if (customFn)
|
|
907
|
-
return customFn(def, context);
|
|
903
|
+
if (customFn) return customFn(def, context);
|
|
908
904
|
switch (def.transport) {
|
|
909
905
|
case "http":
|
|
910
906
|
return httpRpcFromDefinition(def, context);
|
|
@@ -919,8 +915,8 @@ function tsRpcFromDefinition(def, context) {
|
|
|
919
915
|
}
|
|
920
916
|
function httpRpcFromDefinition(def, context) {
|
|
921
917
|
const key = getRpcKey(context);
|
|
922
|
-
const params = def.params ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.params))}` :
|
|
923
|
-
const response = def.response ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.response), { normalize: true })}` :
|
|
918
|
+
const params = def.params ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.params))}` : undefined;
|
|
919
|
+
const response = def.response ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.response), { normalize: true })}` : undefined;
|
|
924
920
|
const serializerMethod = def.method === "get" ? "toUrlQueryString" : "toJsonString";
|
|
925
921
|
if (def.isEventStream) {
|
|
926
922
|
context.usedFeatures.sse = true;
|
|
@@ -964,8 +960,8 @@ function httpRpcFromDefinition(def, context) {
|
|
|
964
960
|
function wsRpcFromDefinition(def, context) {
|
|
965
961
|
context.usedFeatures.ws = true;
|
|
966
962
|
const key = getRpcKey(context);
|
|
967
|
-
const params = def.params ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.params))}` :
|
|
968
|
-
const response = def.response ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.response), { normalize: true })}` :
|
|
963
|
+
const params = def.params ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.params))}` : undefined;
|
|
964
|
+
const response = def.response ? `${context.typePrefix}${codegenUtils.pascalCase(validVarName(def.response), { normalize: true })}` : undefined;
|
|
969
965
|
return `${getJsDocComment({
|
|
970
966
|
description: def.description,
|
|
971
967
|
isDeprecated: def.isDeprecated
|
package/dist/index.d.cts
CHANGED
|
@@ -34,7 +34,7 @@ interface CodegenContext {
|
|
|
34
34
|
};
|
|
35
35
|
rpcGenerators: Record<string, RpcGenerator>;
|
|
36
36
|
}
|
|
37
|
-
declare function getJsDocComment(metadata: Schema[
|
|
37
|
+
declare function getJsDocComment(metadata: Schema['metadata']): string;
|
|
38
38
|
declare function validVarName(name: string): string;
|
|
39
39
|
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
40
40
|
|
|
@@ -42,11 +42,11 @@ interface TypescriptGeneratorOptions {
|
|
|
42
42
|
clientName: string;
|
|
43
43
|
outputFile: string;
|
|
44
44
|
typePrefix?: string;
|
|
45
|
-
prettierOptions?: Omit<prettier.Config,
|
|
45
|
+
prettierOptions?: Omit<prettier.Config, 'parser'>;
|
|
46
46
|
/**
|
|
47
47
|
* Override the default functions used for creating procedures
|
|
48
48
|
*/
|
|
49
|
-
rpcGenerators?: Record<RpcDefinition[
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition['transport'], RpcGenerator>;
|
|
50
50
|
}
|
|
51
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
52
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
package/dist/index.d.mts
CHANGED
|
@@ -34,7 +34,7 @@ interface CodegenContext {
|
|
|
34
34
|
};
|
|
35
35
|
rpcGenerators: Record<string, RpcGenerator>;
|
|
36
36
|
}
|
|
37
|
-
declare function getJsDocComment(metadata: Schema[
|
|
37
|
+
declare function getJsDocComment(metadata: Schema['metadata']): string;
|
|
38
38
|
declare function validVarName(name: string): string;
|
|
39
39
|
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
40
40
|
|
|
@@ -42,11 +42,11 @@ interface TypescriptGeneratorOptions {
|
|
|
42
42
|
clientName: string;
|
|
43
43
|
outputFile: string;
|
|
44
44
|
typePrefix?: string;
|
|
45
|
-
prettierOptions?: Omit<prettier.Config,
|
|
45
|
+
prettierOptions?: Omit<prettier.Config, 'parser'>;
|
|
46
46
|
/**
|
|
47
47
|
* Override the default functions used for creating procedures
|
|
48
48
|
*/
|
|
49
|
-
rpcGenerators?: Record<RpcDefinition[
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition['transport'], RpcGenerator>;
|
|
50
50
|
}
|
|
51
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
52
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ interface CodegenContext {
|
|
|
34
34
|
};
|
|
35
35
|
rpcGenerators: Record<string, RpcGenerator>;
|
|
36
36
|
}
|
|
37
|
-
declare function getJsDocComment(metadata: Schema[
|
|
37
|
+
declare function getJsDocComment(metadata: Schema['metadata']): string;
|
|
38
38
|
declare function validVarName(name: string): string;
|
|
39
39
|
declare function getTsTypeName(schema: Schema, context: CodegenContext): string;
|
|
40
40
|
|
|
@@ -42,11 +42,11 @@ interface TypescriptGeneratorOptions {
|
|
|
42
42
|
clientName: string;
|
|
43
43
|
outputFile: string;
|
|
44
44
|
typePrefix?: string;
|
|
45
|
-
prettierOptions?: Omit<prettier.Config,
|
|
45
|
+
prettierOptions?: Omit<prettier.Config, 'parser'>;
|
|
46
46
|
/**
|
|
47
47
|
* Override the default functions used for creating procedures
|
|
48
48
|
*/
|
|
49
|
-
rpcGenerators?: Record<RpcDefinition[
|
|
49
|
+
rpcGenerators?: Record<RpcDefinition['transport'], RpcGenerator>;
|
|
50
50
|
}
|
|
51
51
|
declare const typescriptClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<TypescriptGeneratorOptions>;
|
|
52
52
|
declare function createTypescriptClient(def: AppDefinition, options: TypescriptGeneratorOptions): Promise<string>;
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ function tsAnyFromSchema(schema, context) {
|
|
|
18
18
|
return `${target} += JSON.stringify(${input})`;
|
|
19
19
|
},
|
|
20
20
|
toQueryStringTemplate(_input, _target, _key) {
|
|
21
|
-
return `console.warn(
|
|
21
|
+
return `console.warn('[WARNING] Cannot serialize any\\'s to query string. Skipping property at ${context.instancePath}.')`;
|
|
22
22
|
},
|
|
23
23
|
content: ""
|
|
24
24
|
};
|
|
@@ -175,7 +175,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
175
175
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
176
176
|
},
|
|
177
177
|
toQueryStringTemplate(_input, _target) {
|
|
178
|
-
return `console.warn(
|
|
178
|
+
return `console.warn('[WARNING] Cannot serialize nested objects to query string. Skipping property at ${context.instancePath}.')`;
|
|
179
179
|
},
|
|
180
180
|
content: ""
|
|
181
181
|
};
|
|
@@ -223,8 +223,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
223
223
|
usedFeatures: context.usedFeatures,
|
|
224
224
|
rpcGenerators: context.rpcGenerators
|
|
225
225
|
});
|
|
226
|
-
if (prop.content)
|
|
227
|
-
subContentParts.push(prop.content);
|
|
226
|
+
if (prop.content) subContentParts.push(prop.content);
|
|
228
227
|
const fieldName = validVarName(camelCase(key, { normalize: true }));
|
|
229
228
|
fieldParts.push(
|
|
230
229
|
`${getJsDocComment(subSchema.metadata)}${fieldName}: ${prop.typeName},`
|
|
@@ -267,8 +266,7 @@ function tsObjectFromSchema(schema, context) {
|
|
|
267
266
|
usedFeatures: context.usedFeatures,
|
|
268
267
|
rpcGenerators: context.rpcGenerators
|
|
269
268
|
});
|
|
270
|
-
if (prop.content)
|
|
271
|
-
subContentParts.push(prop.content);
|
|
269
|
+
if (prop.content) subContentParts.push(prop.content);
|
|
272
270
|
const fieldName = validVarName(camelCase(key, { normalize: true }));
|
|
273
271
|
fieldParts.push(
|
|
274
272
|
`${getJsDocComment(subSchema.metadata)}${fieldName}?: ${prop.typeName},`
|
|
@@ -373,12 +371,11 @@ function tsTaggedUnionFromSchema(schema, context) {
|
|
|
373
371
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
374
372
|
},
|
|
375
373
|
toQueryStringTemplate(_, __, ___) {
|
|
376
|
-
return `console.warn(
|
|
374
|
+
return `console.warn('[WARNING] Cannot serialize nested objects to query string. Skipping property at ${context.instancePath}.');`;
|
|
377
375
|
},
|
|
378
376
|
content: ""
|
|
379
377
|
};
|
|
380
|
-
if (context.generatedTypes.includes(typeName))
|
|
381
|
-
return result;
|
|
378
|
+
if (context.generatedTypes.includes(typeName)) return result;
|
|
382
379
|
const subTypes = [];
|
|
383
380
|
const discriminatorKey = schema.discriminator;
|
|
384
381
|
for (const key of Object.keys(schema.mapping)) {
|
|
@@ -886,7 +883,7 @@ function tsRefFromSchema(schema, context) {
|
|
|
886
883
|
return `${target} += $$${prefixedTypeName}.toJsonString(${input});`;
|
|
887
884
|
},
|
|
888
885
|
toQueryStringTemplate(_, __, ___) {
|
|
889
|
-
return `console.warn(
|
|
886
|
+
return `console.warn('[WARNING] Nested objects cannot be serialized to query string. Ignoring property at ${context.instancePath}.');`;
|
|
890
887
|
},
|
|
891
888
|
content: ""
|
|
892
889
|
};
|
|
@@ -897,8 +894,7 @@ function defineRpcGenerator(fn) {
|
|
|
897
894
|
}
|
|
898
895
|
function tsRpcFromDefinition(def, context) {
|
|
899
896
|
const customFn = context.rpcGenerators[def.transport];
|
|
900
|
-
if (customFn)
|
|
901
|
-
return customFn(def, context);
|
|
897
|
+
if (customFn) return customFn(def, context);
|
|
902
898
|
switch (def.transport) {
|
|
903
899
|
case "http":
|
|
904
900
|
return httpRpcFromDefinition(def, context);
|
|
@@ -913,8 +909,8 @@ function tsRpcFromDefinition(def, context) {
|
|
|
913
909
|
}
|
|
914
910
|
function httpRpcFromDefinition(def, context) {
|
|
915
911
|
const key = getRpcKey(context);
|
|
916
|
-
const params = def.params ? `${context.typePrefix}${pascalCase(validVarName(def.params))}` :
|
|
917
|
-
const response = def.response ? `${context.typePrefix}${pascalCase(validVarName(def.response), { normalize: true })}` :
|
|
912
|
+
const params = def.params ? `${context.typePrefix}${pascalCase(validVarName(def.params))}` : undefined;
|
|
913
|
+
const response = def.response ? `${context.typePrefix}${pascalCase(validVarName(def.response), { normalize: true })}` : undefined;
|
|
918
914
|
const serializerMethod = def.method === "get" ? "toUrlQueryString" : "toJsonString";
|
|
919
915
|
if (def.isEventStream) {
|
|
920
916
|
context.usedFeatures.sse = true;
|
|
@@ -958,8 +954,8 @@ function httpRpcFromDefinition(def, context) {
|
|
|
958
954
|
function wsRpcFromDefinition(def, context) {
|
|
959
955
|
context.usedFeatures.ws = true;
|
|
960
956
|
const key = getRpcKey(context);
|
|
961
|
-
const params = def.params ? `${context.typePrefix}${pascalCase(validVarName(def.params))}` :
|
|
962
|
-
const response = def.response ? `${context.typePrefix}${pascalCase(validVarName(def.response), { normalize: true })}` :
|
|
957
|
+
const params = def.params ? `${context.typePrefix}${pascalCase(validVarName(def.params))}` : undefined;
|
|
958
|
+
const response = def.response ? `${context.typePrefix}${pascalCase(validVarName(def.response), { normalize: true })}` : undefined;
|
|
963
959
|
return `${getJsDocComment({
|
|
964
960
|
description: def.description,
|
|
965
961
|
isDeprecated: def.isDeprecated
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/codegen-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"prettier": "^3.4.
|
|
26
|
-
"@arrirpc/codegen-utils": "0.
|
|
25
|
+
"prettier": "^3.4.2",
|
|
26
|
+
"@arrirpc/codegen-utils": "0.71.0"
|
|
27
27
|
}
|
|
28
28
|
}
|