@brickset-api/types 0.0.7 → 0.0.9
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 +64 -48
- package/endpoints.ts +18 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/data/get-sets.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export type GetSets =
|
|
1
|
+
export type GetSets = GetSetsResponse;
|
|
2
|
+
|
|
3
|
+
export type Item = ItemBase;
|
|
2
4
|
|
|
3
5
|
export type GetSetsOptions = {
|
|
4
6
|
setID?: number;
|
|
@@ -21,14 +23,14 @@ export type GetSetsOptions = {
|
|
|
21
23
|
extendedData?: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
interface
|
|
26
|
+
interface GetSetsResponse {
|
|
25
27
|
message?: string;
|
|
26
28
|
status: string;
|
|
27
29
|
matches?: number;
|
|
28
|
-
sets?:
|
|
30
|
+
sets?: ItemBase[];
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
interface
|
|
33
|
+
interface ItemBase {
|
|
32
34
|
setID: number;
|
|
33
35
|
number: string;
|
|
34
36
|
numberVariant: string;
|
|
@@ -41,37 +43,15 @@ interface GetSets_Base {
|
|
|
41
43
|
released: boolean;
|
|
42
44
|
pieces: number;
|
|
43
45
|
minifigs: number;
|
|
44
|
-
image:
|
|
45
|
-
thumbnailURL: string;
|
|
46
|
-
imageURL: string;
|
|
47
|
-
};
|
|
46
|
+
image: Image;
|
|
48
47
|
bricksetURL: string;
|
|
49
|
-
collection:
|
|
50
|
-
collections:
|
|
51
|
-
ownedBy: number;
|
|
52
|
-
wantedBy: number;
|
|
53
|
-
};
|
|
48
|
+
collection: Collection;
|
|
49
|
+
collections: Collections;
|
|
54
50
|
LEGOCom: {
|
|
55
|
-
US:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
UK: {
|
|
61
|
-
retailPrice: number;
|
|
62
|
-
dateFirstAvailable: string;
|
|
63
|
-
dateLastAvailable: string;
|
|
64
|
-
};
|
|
65
|
-
CA: {
|
|
66
|
-
retailPrice: number;
|
|
67
|
-
dateFirstAvailable: string;
|
|
68
|
-
dateLastAvailable: string;
|
|
69
|
-
};
|
|
70
|
-
DE: {
|
|
71
|
-
retailPrice: number;
|
|
72
|
-
dateFirstAvailable: string;
|
|
73
|
-
dateLastAvailable: string;
|
|
74
|
-
};
|
|
51
|
+
US: LEGOComDetails;
|
|
52
|
+
UK: LEGOComDetails;
|
|
53
|
+
CA: LEGOComDetails;
|
|
54
|
+
DE: LEGOComDetails;
|
|
75
55
|
};
|
|
76
56
|
rating: number;
|
|
77
57
|
reviewCount: number;
|
|
@@ -79,20 +59,56 @@ interface GetSets_Base {
|
|
|
79
59
|
availability: string;
|
|
80
60
|
instructionsCount: number;
|
|
81
61
|
additionalImageCount: number;
|
|
82
|
-
ageRange:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
dimensions: {
|
|
87
|
-
height: number;
|
|
88
|
-
width: number;
|
|
89
|
-
depth: number;
|
|
90
|
-
weight: number;
|
|
91
|
-
};
|
|
92
|
-
barcodes: {
|
|
93
|
-
EAN: string;
|
|
94
|
-
UPC: string;
|
|
95
|
-
};
|
|
96
|
-
extendedData: {};
|
|
62
|
+
ageRange: AgeRange;
|
|
63
|
+
dimensions: Dimensions;
|
|
64
|
+
barcodes: Barcodes;
|
|
65
|
+
extendedData: ExtendedData;
|
|
97
66
|
lastUpdated: string;
|
|
98
67
|
}
|
|
68
|
+
|
|
69
|
+
interface LEGOComDetails {
|
|
70
|
+
retailPrice?: number;
|
|
71
|
+
dateFirstAvailable?: string;
|
|
72
|
+
dateLastAvailable?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface Dimensions {
|
|
76
|
+
height?: number;
|
|
77
|
+
width?: number;
|
|
78
|
+
depth?: number;
|
|
79
|
+
weight?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface ExtendedData {
|
|
83
|
+
notes: string;
|
|
84
|
+
tags: string[];
|
|
85
|
+
description: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface Collection {
|
|
89
|
+
owned?: boolean;
|
|
90
|
+
wanted?: boolean;
|
|
91
|
+
qtyOwned?: number;
|
|
92
|
+
rating?: number;
|
|
93
|
+
notes: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface Collections {
|
|
97
|
+
ownedBy?: number;
|
|
98
|
+
wantedBy?: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface Barcodes {
|
|
102
|
+
EAN: string;
|
|
103
|
+
UPC: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface AgeRange {
|
|
107
|
+
min?: number;
|
|
108
|
+
max?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface Image {
|
|
112
|
+
thumbnailURL: string;
|
|
113
|
+
imageURL: string;
|
|
114
|
+
}
|
package/endpoints.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
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
|
-
| '/
|
|
7
|
+
| '/getSets';
|
|
11
8
|
|
|
12
9
|
export type KnownEndpoint = KnownAuthenticatedEndpoint | KnownUnauthorizedEndpoint;
|
|
13
10
|
|
|
@@ -17,9 +14,19 @@ type CombineParameters<P1 extends string, P2 extends string> = `${P1}&${P2}` | `
|
|
|
17
14
|
type WithParameters<Url extends string, Parameters extends string | undefined> =
|
|
18
15
|
Parameters extends undefined ? Url : `${Url}?${Parameters}`;
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
// helper for endpoints with parameters
|
|
22
|
+
type ParamsParameter = `params=${string}`;
|
|
23
|
+
type EndpointWithParams<Endpoint extends KnownEndpoint> = WithParameters<Endpoint, ParamsParameter>;
|
|
24
|
+
|
|
25
|
+
type BulkExpandedManyEndpointUrl<Endpoint extends KnownEndpoint> = EndpointWithParams<Endpoint>;
|
|
26
|
+
type BulkExpandedEndpointUrl<Endpoint extends KnownEndpoint> = BulkExpandedManyEndpointUrl<Endpoint> | Endpoint;
|
|
27
|
+
|
|
28
|
+
// options
|
|
29
|
+
type Options = {};
|
|
23
30
|
|
|
24
31
|
export type ApiKeyOptions = {
|
|
25
32
|
apiKey: string;
|
|
@@ -30,13 +37,15 @@ export type AuthenticatedOptions = ApiKeyOptions &{
|
|
|
30
37
|
};
|
|
31
38
|
|
|
32
39
|
export type OptionsByEndpoint<Endpoint extends string> =
|
|
40
|
+
Endpoint extends BulkExpandedEndpointUrl<KnownEndpoint & KnownUnauthorizedEndpoint> ? Options & ApiKeyOptions :
|
|
33
41
|
Endpoint extends KnownAuthenticatedEndpoint ? Options & AuthenticatedOptions :
|
|
34
42
|
Endpoint extends KnownUnauthorizedEndpoint ? Options & ApiKeyOptions :
|
|
43
|
+
Endpoint extends KnownEndpoint ? Options & ApiKeyOptions :
|
|
35
44
|
ApiKeyOptions & Partial<AuthenticatedOptions>;
|
|
36
45
|
|
|
37
46
|
// result type for endpoint
|
|
38
47
|
export type EndpointType<Url extends KnownEndpoint | (string & {})> =
|
|
39
|
-
Url extends '/
|
|
48
|
+
Url extends BulkExpandedEndpointUrl<'/getSets'> ? GetSets :
|
|
40
49
|
unknown;
|
|
41
50
|
|
|
42
51
|
export type ValidateEndpointUrl<T extends string> = unknown extends EndpointType<T> ? 'unknown endpoint url' : T;
|