@brickset-api/types 0.0.14 → 0.0.16
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-themes.ts +11 -0
- package/endpoints.ts +6 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/endpoints.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GetSets } from "./data/get-sets";
|
|
2
|
+
import type { GetThemes } from "./data/get-themes";
|
|
2
3
|
|
|
3
4
|
export type KnownAuthenticatedEndpoint =
|
|
4
5
|
| '/setCollection';
|
|
@@ -25,14 +26,15 @@ export type ApiKeyOptions = {
|
|
|
25
26
|
apiKey: string;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export type AuthenticatedOptions =
|
|
29
|
+
export type AuthenticatedOptions = {
|
|
29
30
|
userHash: string;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export type OptionsByEndpoint<Endpoint extends string> =
|
|
33
34
|
Endpoint extends UrlWithParams<'/api/v3.asmx/getSets'> ? Options & ApiKeyOptions :
|
|
34
|
-
Endpoint extends
|
|
35
|
-
|
|
35
|
+
Endpoint extends KnownAuthenticatedEndpoint ? Options & ApiKeyOptions & AuthenticatedOptions :
|
|
36
|
+
Endpoint extends KnownEndpoint ? Options & ApiKeyOptions :
|
|
37
|
+
Partial<ApiKeyOptions>;
|
|
36
38
|
|
|
37
39
|
// Common Brickset API v3 response
|
|
38
40
|
export type ApiResponse<T> = { status: 'success' } & T | { status: 'error'; message: string };
|
|
@@ -42,7 +44,7 @@ export type ApiResponse<T> = { status: 'success' } & T | { status: 'error'; mess
|
|
|
42
44
|
// result type for endpoint
|
|
43
45
|
export type EndpointType<Url extends KnownEndpoint | (string & {})> =
|
|
44
46
|
Url extends UrlWithParams<'/api/v3.asmx/getSets'> ? ApiResponse<{ matches: number; sets: GetSets[] }> :
|
|
45
|
-
Url extends '/api/v3.asmx/getThemes' ? ApiResponse<{ matches: number, themes:
|
|
47
|
+
Url extends '/api/v3.asmx/getThemes' ? ApiResponse<{ matches: number, themes: GetThemes[] }> :
|
|
46
48
|
unknown;
|
|
47
49
|
|
|
48
50
|
export type ValidateEndpointUrl<T extends string> = unknown extends EndpointType<T> ? 'unknown endpoint url' : T;
|