@brickset-api/types 0.0.8 → 0.0.10
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 +12 -0
- package/data/get-sets.ts +2 -2
- package/endpoints.ts +20 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/data/get-sets.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type GetSets =
|
|
1
|
+
export type GetSets = GetSetsResponse;
|
|
2
2
|
|
|
3
3
|
export type Item = ItemBase;
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@ export type GetSetsOptions = {
|
|
|
23
23
|
extendedData?: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
interface
|
|
26
|
+
interface GetSetsResponse {
|
|
27
27
|
message?: string;
|
|
28
28
|
status: string;
|
|
29
29
|
matches?: number;
|
package/endpoints.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { GetSets } from "./data/get-sets";
|
|
2
2
|
|
|
3
|
-
// options
|
|
4
|
-
type Options = {};
|
|
5
|
-
|
|
6
3
|
export type KnownAuthenticatedEndpoint =
|
|
7
|
-
| '/
|
|
4
|
+
| '/setCollection';
|
|
8
5
|
|
|
9
6
|
export type KnownUnauthorizedEndpoint =
|
|
10
|
-
| '/v3.asmx/getSets'
|
|
7
|
+
| '/api/v3.asmx/getSets'
|
|
8
|
+
| '/api/v3.asmx/getThemes'
|
|
9
|
+
| '/api/v3.asmx/getYears';
|
|
11
10
|
|
|
12
11
|
export type KnownEndpoint = KnownAuthenticatedEndpoint | KnownUnauthorizedEndpoint;
|
|
13
12
|
|
|
@@ -17,9 +16,12 @@ type CombineParameters<P1 extends string, P2 extends string> = `${P1}&${P2}` | `
|
|
|
17
16
|
type WithParameters<Url extends string, Parameters extends string | undefined> =
|
|
18
17
|
Parameters extends undefined ? Url : `${Url}?${Parameters}`;
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
// helper for endpoints with parameters
|
|
20
|
+
type ParamsParameter = `params=${string}`;
|
|
21
|
+
type EndpointWithParams<Endpoint extends KnownEndpoint> = WithParameters<Endpoint, ParamsParameter>;
|
|
22
|
+
|
|
23
|
+
// options
|
|
24
|
+
type Options = {};
|
|
23
25
|
|
|
24
26
|
export type ApiKeyOptions = {
|
|
25
27
|
apiKey: string;
|
|
@@ -30,13 +32,19 @@ export type AuthenticatedOptions = ApiKeyOptions &{
|
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type OptionsByEndpoint<Endpoint extends string> =
|
|
33
|
-
Endpoint extends
|
|
34
|
-
Endpoint extends
|
|
35
|
-
|
|
35
|
+
Endpoint extends '/api/v3.asmx/getSets' ? Options & { params: string } & ApiKeyOptions :
|
|
36
|
+
Endpoint extends '/api/v3.asmx/getThemes' ? Options & ApiKeyOptions :
|
|
37
|
+
Endpoint extends '/api/v3.asmx/getYears' ? Options & { theme?: string } & ApiKeyOptions :
|
|
38
|
+
Partial<AuthenticatedOptions & ApiKeyOptions>;
|
|
39
|
+
|
|
40
|
+
type ApiResponse<T> = {
|
|
41
|
+
status: string;
|
|
42
|
+
message?: string;
|
|
43
|
+
} & T;
|
|
36
44
|
|
|
37
45
|
// result type for endpoint
|
|
38
46
|
export type EndpointType<Url extends KnownEndpoint | (string & {})> =
|
|
39
|
-
Url extends '/v3.asmx/getSets' ? GetSets :
|
|
47
|
+
Url extends '/api/v3.asmx/getSets' ? ApiResponse<{ sets: GetSets }> :
|
|
40
48
|
unknown;
|
|
41
49
|
|
|
42
50
|
export type ValidateEndpointUrl<T extends string> = unknown extends EndpointType<T> ? 'unknown endpoint url' : T;
|