ajsc 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajsc",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Another Json-Schema Converter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,13 @@
10
10
  "build": "tsc",
11
11
  "test": "vitest --run"
12
12
  },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.js"
18
+ }
19
+ },
13
20
  "keywords": [
14
21
  "json-schema",
15
22
  "converter",
@@ -93,12 +93,12 @@ export class TypescriptBaseConverter {
93
93
  });
94
94
 
95
95
  if (!props.length) {
96
- return "Record<string | number, unknown>";
96
+ return "{ [key:string]: unknown }";
97
97
  }
98
98
 
99
99
  return `{ ${props.join(" ")} }`;
100
100
  }
101
- return "Record<string | number, unknown>";
101
+ return "{ [key:string]: unknown }";
102
102
  }
103
103
 
104
104
  protected isValidIdentifier(name: string): boolean {
@@ -3,6 +3,21 @@ import { TypescriptProcedureConverter } from "./TypescriptProcedureConverter.js"
3
3
  import { JSONSchema7Definition } from "json-schema";
4
4
 
5
5
  describe("TypescriptProceduresPlugin", () => {
6
+ it("sets `unknown` for Args/Data that is empty or undefined", () => {
7
+ const converter = new TypescriptProcedureConverter("MyScope", {
8
+ args: {},
9
+ data: {},
10
+ });
11
+
12
+ expect(converter.code.replace(/\s/g, "")).toMatch(
13
+ `export namespace MyScope {
14
+ export interface Args { [key:string]: unknown }
15
+
16
+ export interface Data { [key:string]: unknown }
17
+ }`.replace(/\s/g, ""),
18
+ );
19
+ });
20
+
6
21
  it("complex json-schema", () => {
7
22
  const argsAndData: JSONSchema7Definition = {
8
23
  type: "object",