@brickset-api/types 0.0.9 → 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 +6 -0
- package/endpoints.ts +13 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/endpoints.ts
CHANGED
|
@@ -4,7 +4,9 @@ export type KnownAuthenticatedEndpoint =
|
|
|
4
4
|
| '/setCollection';
|
|
5
5
|
|
|
6
6
|
export type KnownUnauthorizedEndpoint =
|
|
7
|
-
| '/getSets'
|
|
7
|
+
| '/api/v3.asmx/getSets'
|
|
8
|
+
| '/api/v3.asmx/getThemes'
|
|
9
|
+
| '/api/v3.asmx/getYears';
|
|
8
10
|
|
|
9
11
|
export type KnownEndpoint = KnownAuthenticatedEndpoint | KnownUnauthorizedEndpoint;
|
|
10
12
|
|
|
@@ -14,17 +16,10 @@ type CombineParameters<P1 extends string, P2 extends string> = `${P1}&${P2}` | `
|
|
|
14
16
|
type WithParameters<Url extends string, Parameters extends string | undefined> =
|
|
15
17
|
Parameters extends undefined ? Url : `${Url}?${Parameters}`;
|
|
16
18
|
|
|
17
|
-
// helper for paginated endpoints
|
|
18
|
-
type PaginationParameters = `pageNumber=${number}` | CombineParameters<`pageNumber=${number}`, `pageSize=${number}`>;
|
|
19
|
-
type PaginatedEndpointUrl<Endpoint extends KnownEndpoint> = Endpoint | WithParameters<Endpoint, PaginationParameters>;
|
|
20
|
-
|
|
21
19
|
// helper for endpoints with parameters
|
|
22
20
|
type ParamsParameter = `params=${string}`;
|
|
23
21
|
type EndpointWithParams<Endpoint extends KnownEndpoint> = WithParameters<Endpoint, ParamsParameter>;
|
|
24
22
|
|
|
25
|
-
type BulkExpandedManyEndpointUrl<Endpoint extends KnownEndpoint> = EndpointWithParams<Endpoint>;
|
|
26
|
-
type BulkExpandedEndpointUrl<Endpoint extends KnownEndpoint> = BulkExpandedManyEndpointUrl<Endpoint> | Endpoint;
|
|
27
|
-
|
|
28
23
|
// options
|
|
29
24
|
type Options = {};
|
|
30
25
|
|
|
@@ -37,15 +32,19 @@ export type AuthenticatedOptions = ApiKeyOptions &{
|
|
|
37
32
|
};
|
|
38
33
|
|
|
39
34
|
export type OptionsByEndpoint<Endpoint extends string> =
|
|
40
|
-
Endpoint extends
|
|
41
|
-
Endpoint extends
|
|
42
|
-
Endpoint extends
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
45
44
|
|
|
46
45
|
// result type for endpoint
|
|
47
46
|
export type EndpointType<Url extends KnownEndpoint | (string & {})> =
|
|
48
|
-
Url extends
|
|
47
|
+
Url extends '/api/v3.asmx/getSets' ? ApiResponse<{ sets: GetSets }> :
|
|
49
48
|
unknown;
|
|
50
49
|
|
|
51
50
|
export type ValidateEndpointUrl<T extends string> = unknown extends EndpointType<T> ? 'unknown endpoint url' : T;
|