@swimmesberger/elarion-jsonrpc-client-generator 0.1.0-preview.6.1
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/README.md +17 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +76 -0
- package/dist/generate.d.ts +4 -0
- package/dist/generate.js +63 -0
- package/dist/json-schema-to-ts.d.ts +3 -0
- package/dist/json-schema-to-ts.js +38 -0
- package/dist/json-schema-to-zod.d.ts +3 -0
- package/dist/json-schema-to-zod.js +50 -0
- package/dist/json-schema.d.ts +16 -0
- package/dist/json-schema.js +96 -0
- package/dist/schema.d.ts +33 -0
- package/dist/schema.js +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @swimmesberger/elarion-jsonrpc-client-generator
|
|
2
|
+
|
|
3
|
+
Generate TypeScript RPC method contracts and Zod result schemas from an Elarion `rpc-schema.json` export.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install --save-dev @swimmesberger/elarion-jsonrpc-client-generator
|
|
7
|
+
npx elarion-jsonrpc-client-generator --schema rpc-schema.json --out src/generated
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The generated files are:
|
|
11
|
+
|
|
12
|
+
| File | Purpose |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `rpc-types.ts` | `RpcMethods` interface mapping method names to params/result types. |
|
|
15
|
+
| `rpc-schemas.ts` | `rpcResultSchemas` Zod map for runtime result validation. |
|
|
16
|
+
|
|
17
|
+
The generated schema file imports `zod`, so consuming applications should install `zod` as a runtime dependency.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, resolve } from 'node:path';
|
|
4
|
+
import { generateRpcClientFiles } from './generate.js';
|
|
5
|
+
function parseArgs(argv) {
|
|
6
|
+
const options = {
|
|
7
|
+
schemaPath: 'rpc-schema.json',
|
|
8
|
+
outDir: 'src/generated',
|
|
9
|
+
};
|
|
10
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
11
|
+
const arg = argv[index];
|
|
12
|
+
const next = argv[index + 1];
|
|
13
|
+
if (arg === '--help' || arg === '-h') {
|
|
14
|
+
printHelp();
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
if (!next) {
|
|
18
|
+
throw new Error(`Missing value for ${arg}`);
|
|
19
|
+
}
|
|
20
|
+
if (arg === '--schema') {
|
|
21
|
+
options.schemaPath = next;
|
|
22
|
+
index += 1;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (arg === '--out') {
|
|
26
|
+
options.outDir = next;
|
|
27
|
+
index += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (arg === '--types') {
|
|
31
|
+
options.typesFileName = next;
|
|
32
|
+
index += 1;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arg === '--schemas') {
|
|
36
|
+
options.schemasFileName = next;
|
|
37
|
+
index += 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (arg === '--source-label') {
|
|
41
|
+
options.sourceLabel = next;
|
|
42
|
+
index += 1;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Unknown argument ${arg}`);
|
|
46
|
+
}
|
|
47
|
+
return options;
|
|
48
|
+
}
|
|
49
|
+
function printHelp() {
|
|
50
|
+
console.log(`Usage: elarion-jsonrpc-client-generator [options]
|
|
51
|
+
|
|
52
|
+
Options:
|
|
53
|
+
--schema <path> Path to rpc-schema.json (default: rpc-schema.json)
|
|
54
|
+
--out <dir> Output directory (default: src/generated)
|
|
55
|
+
--types <file> TypeScript types filename (default: rpc-types.ts)
|
|
56
|
+
--schemas <file> Zod schemas filename (default: rpc-schemas.ts)
|
|
57
|
+
--source-label <text> Source label written into generated file headers
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
function main() {
|
|
61
|
+
const options = parseArgs(process.argv.slice(2));
|
|
62
|
+
const schemaPath = resolve(process.cwd(), options.schemaPath);
|
|
63
|
+
const outDir = resolve(process.cwd(), options.outDir);
|
|
64
|
+
const raw = readFileSync(schemaPath, 'utf-8');
|
|
65
|
+
const schema = JSON.parse(raw);
|
|
66
|
+
const generated = generateRpcClientFiles(schema, {
|
|
67
|
+
sourceLabel: options.sourceLabel ?? basename(schemaPath),
|
|
68
|
+
typesFileName: options.typesFileName,
|
|
69
|
+
schemasFileName: options.schemasFileName,
|
|
70
|
+
});
|
|
71
|
+
mkdirSync(outDir, { recursive: true });
|
|
72
|
+
writeFileSync(resolve(outDir, generated.typesFileName), generated.typesSource, 'utf-8');
|
|
73
|
+
writeFileSync(resolve(outDir, generated.schemasFileName), generated.schemasSource, 'utf-8');
|
|
74
|
+
console.log(`[jsonrpc-client-generator] Generated ${generated.methodCount} RPC method types and schemas -> ${outDir}`);
|
|
75
|
+
}
|
|
76
|
+
main();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneratedRpcClientFiles, GenerateRpcClientOptions, RpcSchema } from './schema.js';
|
|
2
|
+
export { UnsupportedJsonSchemaError } from './json-schema.js';
|
|
3
|
+
export type { GeneratedRpcClientFiles, GenerateRpcClientOptions, JsonSchema, RpcSchema } from './schema.js';
|
|
4
|
+
export declare function generateRpcClientFiles(schema: RpcSchema, options?: GenerateRpcClientOptions): GeneratedRpcClientFiles;
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsonSchemaToTypeScript } from './json-schema-to-ts.js';
|
|
2
|
+
import { jsonSchemaToZod } from './json-schema-to-zod.js';
|
|
3
|
+
import { stripNullable } from './json-schema.js';
|
|
4
|
+
const DEFAULT_GENERATED_BY = 'elarion-jsonrpc-client-generator';
|
|
5
|
+
const DEFAULT_SOURCE_LABEL = 'rpc-schema.json';
|
|
6
|
+
const DEFAULT_TYPES_FILE = 'rpc-types.ts';
|
|
7
|
+
const DEFAULT_SCHEMAS_FILE = 'rpc-schemas.ts';
|
|
8
|
+
export { UnsupportedJsonSchemaError } from './json-schema.js';
|
|
9
|
+
export function generateRpcClientFiles(schema, options = {}) {
|
|
10
|
+
const generatedBy = options.generatedBy ?? DEFAULT_GENERATED_BY;
|
|
11
|
+
const sourceLabel = options.sourceLabel ?? DEFAULT_SOURCE_LABEL;
|
|
12
|
+
const typesFileName = options.typesFileName ?? DEFAULT_TYPES_FILE;
|
|
13
|
+
const schemasFileName = options.schemasFileName ?? DEFAULT_SCHEMAS_FILE;
|
|
14
|
+
const methods = Object.keys(schema.methods).sort();
|
|
15
|
+
const typesLines = [
|
|
16
|
+
`// Auto-generated by ${generatedBy} — DO NOT EDIT`,
|
|
17
|
+
`// Source: ${sourceLabel}`,
|
|
18
|
+
'',
|
|
19
|
+
'export interface RpcMethods {',
|
|
20
|
+
];
|
|
21
|
+
for (const method of methods) {
|
|
22
|
+
const definition = schema.methods[method];
|
|
23
|
+
const paramsType = jsonSchemaToTypeScript(stripNullable(definition.params), createContext(definition.params, `methods.${method}.params`), 1);
|
|
24
|
+
const resultType = jsonSchemaToTypeScript(stripNullable(definition.result), createContext(definition.result, `methods.${method}.result`), 1);
|
|
25
|
+
typesLines.push(` ${JSON.stringify(method)}: {`);
|
|
26
|
+
typesLines.push(` params: ${paramsType}`);
|
|
27
|
+
typesLines.push(` result: ${resultType}`);
|
|
28
|
+
typesLines.push(' }');
|
|
29
|
+
}
|
|
30
|
+
typesLines.push('}');
|
|
31
|
+
typesLines.push('');
|
|
32
|
+
const schemasLines = [
|
|
33
|
+
`// Auto-generated by ${generatedBy} — DO NOT EDIT`,
|
|
34
|
+
`// Source: ${sourceLabel}`,
|
|
35
|
+
'',
|
|
36
|
+
"import { z } from 'zod'",
|
|
37
|
+
'',
|
|
38
|
+
'export const rpcResultSchemas = {',
|
|
39
|
+
];
|
|
40
|
+
for (const method of methods) {
|
|
41
|
+
const definition = schema.methods[method];
|
|
42
|
+
const zodSchema = jsonSchemaToZod(stripNullable(definition.result), createContext(definition.result, `methods.${method}.result`), 1);
|
|
43
|
+
schemasLines.push(` ${JSON.stringify(method)}: ${zodSchema},`);
|
|
44
|
+
}
|
|
45
|
+
schemasLines.push('} as const');
|
|
46
|
+
schemasLines.push('');
|
|
47
|
+
schemasLines.push('export type RpcResultSchemas = typeof rpcResultSchemas');
|
|
48
|
+
schemasLines.push('');
|
|
49
|
+
return {
|
|
50
|
+
methodCount: methods.length,
|
|
51
|
+
typesFileName,
|
|
52
|
+
schemasFileName,
|
|
53
|
+
typesSource: typesLines.join('\n'),
|
|
54
|
+
schemasSource: schemasLines.join('\n'),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function createContext(root, path) {
|
|
58
|
+
return {
|
|
59
|
+
root,
|
|
60
|
+
path,
|
|
61
|
+
resolvingRefs: new Set(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { baseType, childContext, formatPropertyName, isNullable, resolveSchema, stripNullable, } from './json-schema.js';
|
|
2
|
+
export function jsonSchemaToTypeScript(schema, ctx, indent = 0) {
|
|
3
|
+
const resolved = resolveSchema(schema, ctx);
|
|
4
|
+
const pad = ' '.repeat(indent);
|
|
5
|
+
const nullable = isNullable(resolved);
|
|
6
|
+
const base = baseType(resolved);
|
|
7
|
+
if (resolved.enum) {
|
|
8
|
+
const values = resolved.enum
|
|
9
|
+
.filter((value) => value !== null)
|
|
10
|
+
.map((value) => JSON.stringify(value));
|
|
11
|
+
const union = values.length > 0 ? values.join(' | ') : 'never';
|
|
12
|
+
return nullable ? `(${union}) | null | undefined` : union;
|
|
13
|
+
}
|
|
14
|
+
if (base === 'string') {
|
|
15
|
+
return nullable ? 'string | null | undefined' : 'string';
|
|
16
|
+
}
|
|
17
|
+
if (base === 'number' || base === 'integer') {
|
|
18
|
+
return nullable ? 'number | null | undefined' : 'number';
|
|
19
|
+
}
|
|
20
|
+
if (base === 'boolean') {
|
|
21
|
+
return nullable ? 'boolean | null | undefined' : 'boolean';
|
|
22
|
+
}
|
|
23
|
+
if (base === 'array' && resolved.items) {
|
|
24
|
+
const itemType = jsonSchemaToTypeScript(stripNullable(resolved.items), childContext(ctx, 'items'), indent);
|
|
25
|
+
return nullable ? `(${itemType})[] | null | undefined` : `${itemType}[]`;
|
|
26
|
+
}
|
|
27
|
+
if (base === 'object' && resolved.properties) {
|
|
28
|
+
const required = new Set(resolved.required ?? []);
|
|
29
|
+
const lines = Object.entries(resolved.properties).map(([key, property]) => {
|
|
30
|
+
const optional = required.has(key) ? '' : '?';
|
|
31
|
+
const propertyType = jsonSchemaToTypeScript(property, childContext(ctx, `properties.${key}`), indent + 1);
|
|
32
|
+
return `${pad} ${formatPropertyName(key)}${optional}: ${propertyType}`;
|
|
33
|
+
});
|
|
34
|
+
const objectType = `{\n${lines.join('\n')}\n${pad}}`;
|
|
35
|
+
return nullable ? `${objectType} | null | undefined` : objectType;
|
|
36
|
+
}
|
|
37
|
+
return 'unknown';
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { baseType, childContext, formatPropertyName, isNullable, resolveSchema, stripNullable, } from './json-schema.js';
|
|
2
|
+
export function jsonSchemaToZod(schema, ctx, indent = 0) {
|
|
3
|
+
const resolved = resolveSchema(schema, ctx);
|
|
4
|
+
const nullable = isNullable(resolved);
|
|
5
|
+
const base = baseType(resolved);
|
|
6
|
+
if (resolved.enum) {
|
|
7
|
+
const values = resolved.enum.filter((value) => value !== null);
|
|
8
|
+
const allStrings = values.every((value) => typeof value === 'string');
|
|
9
|
+
let zodExpression;
|
|
10
|
+
if (allStrings && values.length > 0) {
|
|
11
|
+
zodExpression = `z.enum([${values.map((value) => JSON.stringify(value)).join(', ')}])`;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const literals = values.map((value) => `z.literal(${JSON.stringify(value)})`);
|
|
15
|
+
zodExpression = literals.length === 1
|
|
16
|
+
? literals[0]
|
|
17
|
+
: `z.union([${literals.join(', ')}])`;
|
|
18
|
+
}
|
|
19
|
+
return nullish(zodExpression, nullable);
|
|
20
|
+
}
|
|
21
|
+
if (base === 'string') {
|
|
22
|
+
return nullish('z.string()', nullable);
|
|
23
|
+
}
|
|
24
|
+
if (base === 'number' || base === 'integer') {
|
|
25
|
+
return nullish('z.number()', nullable);
|
|
26
|
+
}
|
|
27
|
+
if (base === 'boolean') {
|
|
28
|
+
return nullish('z.boolean()', nullable);
|
|
29
|
+
}
|
|
30
|
+
if (base === 'array' && resolved.items) {
|
|
31
|
+
const itemSchema = jsonSchemaToZod(stripNullable(resolved.items), childContext(ctx, 'items'), indent);
|
|
32
|
+
return nullish(`z.array(${itemSchema})`, nullable);
|
|
33
|
+
}
|
|
34
|
+
if (base === 'object' && resolved.properties) {
|
|
35
|
+
const required = new Set(resolved.required ?? []);
|
|
36
|
+
const pad = ' '.repeat(indent + 1);
|
|
37
|
+
const fields = Object.entries(resolved.properties).map(([key, property]) => {
|
|
38
|
+
let fieldSchema = jsonSchemaToZod(property, childContext(ctx, `properties.${key}`), indent + 1);
|
|
39
|
+
if (!required.has(key)) {
|
|
40
|
+
fieldSchema += '.optional()';
|
|
41
|
+
}
|
|
42
|
+
return `${pad}${formatPropertyName(key)}: ${fieldSchema},`;
|
|
43
|
+
});
|
|
44
|
+
return nullish(`z.object({\n${fields.join('\n')}\n${' '.repeat(indent)}})`, nullable);
|
|
45
|
+
}
|
|
46
|
+
return 'z.unknown()';
|
|
47
|
+
}
|
|
48
|
+
function nullish(expression, nullable) {
|
|
49
|
+
return nullable ? `${expression}.nullish()` : expression;
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonSchema } from './schema.js';
|
|
2
|
+
export declare class UnsupportedJsonSchemaError extends Error {
|
|
3
|
+
readonly schemaPath: string;
|
|
4
|
+
constructor(schemaPath: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface SchemaContext {
|
|
7
|
+
root: JsonSchema;
|
|
8
|
+
path: string;
|
|
9
|
+
resolvingRefs: ReadonlySet<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function isNullable(schema: JsonSchema): boolean;
|
|
12
|
+
export declare function baseType(schema: JsonSchema): string | undefined;
|
|
13
|
+
export declare function stripNullable(schema: JsonSchema): JsonSchema;
|
|
14
|
+
export declare function resolveSchema(schema: JsonSchema, ctx: SchemaContext): JsonSchema;
|
|
15
|
+
export declare function childContext(ctx: SchemaContext, segment: string): SchemaContext;
|
|
16
|
+
export declare function formatPropertyName(key: string): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export class UnsupportedJsonSchemaError extends Error {
|
|
2
|
+
schemaPath;
|
|
3
|
+
constructor(schemaPath, message) {
|
|
4
|
+
super(`${schemaPath}: ${message}`);
|
|
5
|
+
this.schemaPath = schemaPath;
|
|
6
|
+
this.name = 'UnsupportedJsonSchemaError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function isNullable(schema) {
|
|
10
|
+
if (Array.isArray(schema.type)) {
|
|
11
|
+
return schema.type.includes('null');
|
|
12
|
+
}
|
|
13
|
+
if (schema.enum) {
|
|
14
|
+
return schema.enum.includes(null);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export function baseType(schema) {
|
|
19
|
+
if (Array.isArray(schema.type)) {
|
|
20
|
+
return schema.type.find((type) => type !== 'null');
|
|
21
|
+
}
|
|
22
|
+
return schema.type;
|
|
23
|
+
}
|
|
24
|
+
export function stripNullable(schema) {
|
|
25
|
+
const copy = { ...schema };
|
|
26
|
+
if (Array.isArray(copy.type)) {
|
|
27
|
+
const nonNull = copy.type.filter((type) => type !== 'null');
|
|
28
|
+
copy.type = nonNull.length === 1 ? nonNull[0] : nonNull;
|
|
29
|
+
}
|
|
30
|
+
if (copy.enum) {
|
|
31
|
+
copy.enum = copy.enum.filter((value) => value !== null);
|
|
32
|
+
}
|
|
33
|
+
return copy;
|
|
34
|
+
}
|
|
35
|
+
export function resolveSchema(schema, ctx) {
|
|
36
|
+
assertSupportedComposition(schema, ctx.path);
|
|
37
|
+
if (!schema.$ref) {
|
|
38
|
+
return schema;
|
|
39
|
+
}
|
|
40
|
+
if (!schema.$ref.startsWith('#/')) {
|
|
41
|
+
throw new UnsupportedJsonSchemaError(ctx.path, `only local JSON Pointer $ref values are supported (${schema.$ref})`);
|
|
42
|
+
}
|
|
43
|
+
if (ctx.resolvingRefs.has(schema.$ref)) {
|
|
44
|
+
throw new UnsupportedJsonSchemaError(ctx.path, `cyclic $ref detected (${schema.$ref})`);
|
|
45
|
+
}
|
|
46
|
+
const target = resolveJsonPointer(ctx.root, schema.$ref, ctx.path);
|
|
47
|
+
return resolveSchema(target, {
|
|
48
|
+
root: ctx.root,
|
|
49
|
+
path: `${ctx.path}${schema.$ref}`,
|
|
50
|
+
resolvingRefs: new Set([...ctx.resolvingRefs, schema.$ref]),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function childContext(ctx, segment) {
|
|
54
|
+
return {
|
|
55
|
+
root: ctx.root,
|
|
56
|
+
path: `${ctx.path}.${segment}`,
|
|
57
|
+
resolvingRefs: ctx.resolvingRefs,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function formatPropertyName(key) {
|
|
61
|
+
if (/^[A-Za-z_$][\w$]*$/.test(key)) {
|
|
62
|
+
return key;
|
|
63
|
+
}
|
|
64
|
+
return JSON.stringify(key);
|
|
65
|
+
}
|
|
66
|
+
function assertSupportedComposition(schema, path) {
|
|
67
|
+
if (schema.oneOf) {
|
|
68
|
+
throw new UnsupportedJsonSchemaError(path, 'oneOf is not supported');
|
|
69
|
+
}
|
|
70
|
+
if (schema.anyOf) {
|
|
71
|
+
throw new UnsupportedJsonSchemaError(path, 'anyOf is not supported');
|
|
72
|
+
}
|
|
73
|
+
if (schema.allOf) {
|
|
74
|
+
throw new UnsupportedJsonSchemaError(path, 'allOf is not supported');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function resolveJsonPointer(root, ref, path) {
|
|
78
|
+
const segments = ref
|
|
79
|
+
.slice(2)
|
|
80
|
+
.split('/')
|
|
81
|
+
.map((segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~'));
|
|
82
|
+
let current = root;
|
|
83
|
+
for (const segment of segments) {
|
|
84
|
+
if (!isObjectRecord(current) || !(segment in current)) {
|
|
85
|
+
throw new UnsupportedJsonSchemaError(path, `could not resolve $ref ${ref}`);
|
|
86
|
+
}
|
|
87
|
+
current = current[segment];
|
|
88
|
+
}
|
|
89
|
+
if (!isObjectRecord(current)) {
|
|
90
|
+
throw new UnsupportedJsonSchemaError(path, `$ref ${ref} does not point to a schema object`);
|
|
91
|
+
}
|
|
92
|
+
return current;
|
|
93
|
+
}
|
|
94
|
+
function isObjectRecord(value) {
|
|
95
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
96
|
+
}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface JsonSchema {
|
|
2
|
+
$ref?: string;
|
|
3
|
+
type?: string | string[];
|
|
4
|
+
properties?: Record<string, JsonSchema>;
|
|
5
|
+
required?: string[];
|
|
6
|
+
items?: JsonSchema;
|
|
7
|
+
enum?: Array<string | number | boolean | null>;
|
|
8
|
+
format?: string;
|
|
9
|
+
default?: unknown;
|
|
10
|
+
oneOf?: unknown[];
|
|
11
|
+
anyOf?: unknown[];
|
|
12
|
+
allOf?: unknown[];
|
|
13
|
+
}
|
|
14
|
+
export interface RpcMethodSchema {
|
|
15
|
+
params: JsonSchema;
|
|
16
|
+
result: JsonSchema;
|
|
17
|
+
}
|
|
18
|
+
export interface RpcSchema {
|
|
19
|
+
methods: Record<string, RpcMethodSchema>;
|
|
20
|
+
}
|
|
21
|
+
export interface GenerateRpcClientOptions {
|
|
22
|
+
generatedBy?: string;
|
|
23
|
+
sourceLabel?: string;
|
|
24
|
+
typesFileName?: string;
|
|
25
|
+
schemasFileName?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface GeneratedRpcClientFiles {
|
|
28
|
+
methodCount: number;
|
|
29
|
+
typesFileName: string;
|
|
30
|
+
schemasFileName: string;
|
|
31
|
+
typesSource: string;
|
|
32
|
+
schemasSource: string;
|
|
33
|
+
}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swimmesberger/elarion-jsonrpc-client-generator",
|
|
3
|
+
"version": "0.1.0-preview.6.1",
|
|
4
|
+
"description": "Generate TypeScript RPC contracts and Zod result schemas from Elarion JSON-RPC schema exports.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"elarion-jsonrpc-client-generator": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/generate.d.ts",
|
|
13
|
+
"import": "./dist/generate.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"prepack": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/swimmesberger/Elarion.git",
|
|
29
|
+
"directory": "src/elarion-jsonrpc-client-generator"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/swimmesberger/Elarion/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/swimmesberger/Elarion#readme",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20.11"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.3.3",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vitest": "^4.0.18"
|
|
46
|
+
}
|
|
47
|
+
}
|