@spec2ts/openapi-client 2.0.0-beta.0 → 2.0.0-beta.11

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/CHANGELOG.md CHANGED
@@ -3,6 +3,112 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.0.0-beta.11](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.10...@spec2ts/openapi-client@2.0.0-beta.11) (2022-07-29)
7
+
8
+ **Note:** Version bump only for package @spec2ts/openapi-client
9
+
10
+
11
+
12
+
13
+
14
+ # [2.0.0-beta.10](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.9...@spec2ts/openapi-client@2.0.0-beta.10) (2022-06-27)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **openapi-client:** upgrade to typescript 4 ([932877f](https://github.com/touchifyapp/spec2ts/commit/932877f83915a953400b41fc74ea921aeaed3b1d))
20
+
21
+
22
+
23
+
24
+
25
+ # [2.0.0-beta.9](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.8...@spec2ts/openapi-client@2.0.0-beta.9) (2022-01-27)
26
+
27
+ **Note:** Version bump only for package @spec2ts/openapi-client
28
+
29
+
30
+
31
+
32
+
33
+ # [2.0.0-beta.8](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.7...@spec2ts/openapi-client@2.0.0-beta.8) (2021-11-03)
34
+
35
+ **Note:** Version bump only for package @spec2ts/openapi-client
36
+
37
+
38
+
39
+
40
+
41
+ # [2.0.0-beta.7](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.6...@spec2ts/openapi-client@2.0.0-beta.7) (2021-10-23)
42
+
43
+ **Note:** Version bump only for package @spec2ts/openapi-client
44
+
45
+
46
+
47
+
48
+
49
+ # [2.0.0-beta.6](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.5...@spec2ts/openapi-client@2.0.0-beta.6) (2021-02-27)
50
+
51
+ **Note:** Version bump only for package @spec2ts/openapi-client
52
+
53
+
54
+
55
+
56
+
57
+ # [2.0.0-beta.5](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.4...@spec2ts/openapi-client@2.0.0-beta.5) (2020-12-21)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * **openapi-client:** allow $ and _ in camelCase ([08c244e](https://github.com/touchifyapp/spec2ts/commit/08c244eb6e2c0a6f3ab833faa5159483ca1adda7))
63
+
64
+
65
+
66
+
67
+
68
+ # [2.0.0-beta.4](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.3...@spec2ts/openapi-client@2.0.0-beta.4) (2020-12-14)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * **openapi-client:** type issue in TS 4.1 ([09da142](https://github.com/touchifyapp/spec2ts/commit/09da1423ce16e1a8ccee81ba0ad160f5f6313a67))
74
+
75
+
76
+
77
+
78
+
79
+ # [2.0.0-beta.3](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.2...@spec2ts/openapi-client@2.0.0-beta.3) (2020-11-29)
80
+
81
+
82
+ ### Bug Fixes
83
+
84
+ * **openapi:** bad yargs options for enableDate ([cc799cb](https://github.com/touchifyapp/spec2ts/commit/cc799cb14600f5a5388a825932622251ed1df19c))
85
+
86
+
87
+
88
+
89
+
90
+ # [2.0.0-beta.2](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.1...@spec2ts/openapi-client@2.0.0-beta.2) (2020-11-29)
91
+
92
+
93
+ ### Features
94
+
95
+ * **openapi-client:** add support for new lax date style ([73ac242](https://github.com/touchifyapp/spec2ts/commit/73ac2428cf7195817cc66c41a9e18fa6e9a7abee))
96
+
97
+
98
+
99
+
100
+
101
+ # [2.0.0-beta.1](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.0...@spec2ts/openapi-client@2.0.0-beta.1) (2020-11-16)
102
+
103
+
104
+ ### Bug Fixes
105
+
106
+ * **openapi-client:** improve types for TypeScript v4 ([7927e7b](https://github.com/touchifyapp/spec2ts/commit/7927e7ba48f5abf03f0a51972213f9034cf5f09d))
107
+
108
+
109
+
110
+
111
+
6
112
  # [2.0.0-beta.0](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@1.4.3...@spec2ts/openapi-client@2.0.0-beta.0) (2020-11-13)
7
113
 
8
114
 
package/cli/command.js CHANGED
@@ -29,10 +29,10 @@ function builder(argv) {
29
29
  type: "boolean",
30
30
  describe: "Avoid the `any` type and use `unknown` instead"
31
31
  })
32
- // .option("enableDate", {
33
- // type: "boolean",
34
- // describe: "Build `Date` for format `date` and `date-time`"
35
- // })
32
+ .option("enableDate", {
33
+ choices: [true, "strict", "lax"],
34
+ describe: "Build `Date` for format `date` and `date-time`"
35
+ })
36
36
  .option("inlineRequired", {
37
37
  type: "boolean",
38
38
  describe: "Create a method argument for each required parameter"
@@ -140,12 +140,12 @@ async function generatePackage(output, options) {
140
140
  main: main.replace(/\.ts$/, ".js"),
141
141
  files: ["*.js", "*.d.ts"],
142
142
  scripts: {
143
- build: `tsc ${main} --strict --target ${options.packageBuildTarget || "ES2018"} --module ${options.packageBuildModule || "UMD"} --moduleResolution node`,
143
+ build: `tsc ${main} --strict --target ${options.packageBuildTarget || "ES2018"} --module ${options.packageBuildModule || "UMD"} --moduleResolution node --skipLibCheck`,
144
144
  prepublishOnly: "npm run build"
145
145
  },
146
146
  dependencies: {},
147
147
  devDependencies: {
148
- typescript: "^3.0.0"
148
+ typescript: "^4.2.0"
149
149
  }
150
150
  };
151
151
  if (options.importFetch) {
@@ -17,17 +17,20 @@ declare type FetchRequestOptions = RequestOptions & {
17
17
  body?: string | FormData;
18
18
  };
19
19
  declare type JsonRequestOptions = RequestOptions & {
20
- body: Record<string, unknown>;
20
+ body: unknown;
21
+ };
22
+ declare type FormRequestOptions<T extends Record<string, unknown>> = RequestOptions & {
23
+ body: T;
21
24
  };
22
25
  declare type MultipartRequestOptions = RequestOptions & {
23
- body: Record<string, string | Blob | undefined | any>;
26
+ body: Record<string, any>;
24
27
  };
25
28
  /** Utilities functions */
26
29
  export declare const _: {
27
30
  encodeReserved: (typeof encodeURI)[];
28
31
  allowReserved: (typeof encodeURI)[];
29
32
  /** Deeply remove all properties with undefined values. */
30
- stripUndefined<T>(obj?: T | undefined): T | undefined;
33
+ stripUndefined<T extends Record<string, U | undefined>, U>(obj?: T | undefined): Record<string, U> | undefined;
31
34
  isEmpty(v: unknown): boolean;
32
35
  /** Creates a tag-function to encode template strings with the given encoders. */
33
36
  encode(encoders: Encoders, delimiter?: string): TagFunction;
@@ -62,7 +65,7 @@ export declare const http: {
62
65
  fetchJson(url: string, req?: FetchRequestOptions): Promise<ApiResponse<any>>;
63
66
  fetchVoid(url: string, req?: FetchRequestOptions): Promise<ApiResponse<undefined>>;
64
67
  json({ body, headers, ...req }: JsonRequestOptions): FetchRequestOptions;
65
- form({ body, headers, ...req }: JsonRequestOptions): FetchRequestOptions;
68
+ form<T extends Record<string, unknown>>({ body, headers, ...req }: FormRequestOptions<T>): FetchRequestOptions;
66
69
  multipart({ body, ...req }: MultipartRequestOptions): FetchRequestOptions;
67
70
  headers(headers: Headers): Record<string, string>;
68
71
  };
@@ -25,11 +25,15 @@ type FetchRequestOptions = RequestOptions & {
25
25
  };
26
26
 
27
27
  type JsonRequestOptions = RequestOptions & {
28
- body: Record<string, unknown>;
28
+ body: unknown;
29
+ };
30
+
31
+ type FormRequestOptions<T extends Record<string, unknown>> = RequestOptions & {
32
+ body: T;
29
33
  };
30
34
 
31
35
  type MultipartRequestOptions = RequestOptions & {
32
- body: Record<string, string | Blob | undefined | any>;
36
+ body: Record<string, any>; // string | Blob
33
37
  };
34
38
 
35
39
  /** Utilities functions */
@@ -39,7 +43,7 @@ export const _ = {
39
43
  allowReserved: [encodeURI, encodeURI],
40
44
 
41
45
  /** Deeply remove all properties with undefined values. */
42
- stripUndefined<T>(obj?: T): T | undefined {
46
+ stripUndefined<T extends Record<string, U | undefined>, U>(obj?: T): Record<string, U> | undefined {
43
47
  return obj && JSON.parse(JSON.stringify(obj));
44
48
  },
45
49
 
@@ -215,7 +219,7 @@ export const http = {
215
219
  };
216
220
  },
217
221
 
218
- form({ body, headers, ...req }: JsonRequestOptions): FetchRequestOptions {
222
+ form<T extends Record<string, unknown>>({ body, headers, ...req }: FormRequestOptions<T>): FetchRequestOptions {
219
223
  return {
220
224
  ...req,
221
225
  body: QS.form(body),
package/lib/util.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.camelCase = void 0;
4
4
  function camelCase(str) {
5
- const regex = /[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g;
5
+ const regex = /[A-Z\xC0-\xD6\xD8-\xDE_$]?[a-z\xDF-\xF6\xF8-\xFF_$]+|[A-Z\xC0-\xD6\xD8-\xDE_$]+(?![a-z\xDF-\xF6\xF8-\xFF_$])|\d+/g;
6
6
  const words = str.match(regex);
7
7
  if (!words)
8
8
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spec2ts/openapi-client",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.11",
4
4
  "description": "Utility to convert OpenAPI v3 specifications to Typescript HTTP client using TypeScript native compiler",
5
5
  "author": "Touchify <dev@touchify.co>",
6
6
  "license": "MIT",
@@ -40,9 +40,9 @@
40
40
  "prepublishOnly": "npm test && npm run build"
41
41
  },
42
42
  "dependencies": {
43
- "@spec2ts/core": "^2.0.0-beta.0",
44
- "@spec2ts/jsonschema": "^2.0.0-beta.0",
45
- "@spec2ts/openapi": "^2.0.0-beta.0",
43
+ "@spec2ts/core": "^2.0.0-beta.2",
44
+ "@spec2ts/jsonschema": "^2.0.0-beta.7",
45
+ "@spec2ts/openapi": "^2.0.0-beta.7",
46
46
  "openapi3-ts": "^1.3.0",
47
47
  "yargs": "^15.3.1"
48
48
  },
@@ -70,5 +70,5 @@
70
70
  "spec2ts",
71
71
  "share"
72
72
  ],
73
- "gitHead": "55cd21647af32c7b523a54bc213a0358152f3af2"
73
+ "gitHead": "b333f1dc8e20d70f6b6657e106e59af99e96f403"
74
74
  }