@mittwald/api-client-commons 3.0.2 → 3.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.
@@ -30,7 +30,7 @@ class Request {
30
30
  };
31
31
  }
32
32
  makeAxiosHeaders(headers) {
33
- return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, value.toString()]));
33
+ return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, value === null || value === void 0 ? void 0 : value.toString()]));
34
34
  }
35
35
  }
36
36
  exports.Request = Request;
@@ -1,6 +1,6 @@
1
- import { HasRequiredKeys, PartialOnUndefinedDeep } from "type-fest";
2
- type PartialOnNoRequiredKeysDeep<T> = PartialOnUndefinedDeep<{
1
+ import { HasRequiredKeys, OmitIndexSignature, PartialOnUndefinedDeep } from "type-fest";
2
+ type PartialOnNoRequiredKeysDeep<T> = PartialOnUndefinedDeep<OmitIndexSignature<{
3
3
  [TKey in keyof T]: HasRequiredKeys<PartialOnNoRequiredKeysDeep<T[TKey]>> extends true ? T[TKey] : T[TKey] | undefined;
4
- }>;
4
+ }>>;
5
5
  export type NullableOnNoRequiredKeysDeep<T> = HasRequiredKeys<PartialOnNoRequiredKeysDeep<T>> extends true ? PartialOnNoRequiredKeysDeep<T> : PartialOnNoRequiredKeysDeep<T> | null;
6
6
  export {};
@@ -10,3 +10,13 @@ function ignoredTestEmptyRequestTypes() {
10
10
  headers: { extra: true },
11
11
  });
12
12
  }
13
+ function ignoredTestOptionalHeadersRequestTypes() {
14
+ const f = {};
15
+ void f();
16
+ void f({
17
+ headers: {},
18
+ });
19
+ void f({
20
+ headers: { extra: true },
21
+ });
22
+ }
@@ -5,8 +5,8 @@ type SafeHttpMethod = "GET" | "HEAD" | "OPTIONS";
5
5
  type UnsafeHttpMethod = "PUT" | "DELETE" | "POST" | "PATCH";
6
6
  export type HttpMethod = SafeHttpMethod | UnsafeHttpMethod;
7
7
  type HeaderValue = string | number | boolean;
8
- export type HttpHeaders = {
8
+ export type HttpHeaders = Partial<{
9
9
  [TKey: string]: HeaderValue | HeaderValue[];
10
- };
10
+ }>;
11
11
  export type PathParameters = Record<string, string | number>;
12
12
  export {};
@@ -30,7 +30,7 @@ export class Request {
30
30
  };
31
31
  }
32
32
  makeAxiosHeaders(headers) {
33
- return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, value.toString()]));
33
+ return Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, value?.toString()]));
34
34
  }
35
35
  }
36
36
  export default Request;
@@ -1,6 +1,6 @@
1
- import { HasRequiredKeys, PartialOnUndefinedDeep } from "type-fest";
2
- type PartialOnNoRequiredKeysDeep<T> = PartialOnUndefinedDeep<{
1
+ import { HasRequiredKeys, OmitIndexSignature, PartialOnUndefinedDeep } from "type-fest";
2
+ type PartialOnNoRequiredKeysDeep<T> = PartialOnUndefinedDeep<OmitIndexSignature<{
3
3
  [TKey in keyof T]: HasRequiredKeys<PartialOnNoRequiredKeysDeep<T[TKey]>> extends true ? T[TKey] : T[TKey] | undefined;
4
- }>;
4
+ }>>;
5
5
  export type NullableOnNoRequiredKeysDeep<T> = HasRequiredKeys<PartialOnNoRequiredKeysDeep<T>> extends true ? PartialOnNoRequiredKeysDeep<T> : PartialOnNoRequiredKeysDeep<T> | null;
6
6
  export {};
@@ -8,4 +8,14 @@ function ignoredTestEmptyRequestTypes() {
8
8
  headers: { extra: true },
9
9
  });
10
10
  }
11
+ function ignoredTestOptionalHeadersRequestTypes() {
12
+ const f = {};
13
+ void f();
14
+ void f({
15
+ headers: {},
16
+ });
17
+ void f({
18
+ headers: { extra: true },
19
+ });
20
+ }
11
21
  export {};
@@ -5,8 +5,8 @@ type SafeHttpMethod = "GET" | "HEAD" | "OPTIONS";
5
5
  type UnsafeHttpMethod = "PUT" | "DELETE" | "POST" | "PATCH";
6
6
  export type HttpMethod = SafeHttpMethod | UnsafeHttpMethod;
7
7
  type HeaderValue = string | number | boolean;
8
- export type HttpHeaders = {
8
+ export type HttpHeaders = Partial<{
9
9
  [TKey: string]: HeaderValue | HeaderValue[];
10
- };
10
+ }>;
11
11
  export type PathParameters = Record<string, string | number>;
12
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-client-commons",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Common types and utilities for mittwald API clients",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/mittwald/api-client-js.git",