@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @brickset-api/types
2
2
 
3
+ ## 0.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - df6f3b5: Create new release
8
+
9
+ ## 0.0.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 92ab17b: Update types
14
+
3
15
  ## 0.0.8
4
16
 
5
17
  ### Patch Changes
package/data/get-sets.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type GetSets = GetSets_Response;
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 GetSets_Response {
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
- | '/v3.asmx/setCollection';
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
- // helper for paginated endpoints
21
- type PaginationParameters = `pageNumber=${number}` | CombineParameters<`pageNumber=${number}`, `pageSize=${number}`>;
22
- type PaginatedEndpointUrl<Endpoint extends KnownEndpoint> = Endpoint | WithParameters<Endpoint, PaginationParameters>;
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 KnownAuthenticatedEndpoint ? Options & AuthenticatedOptions :
34
- Endpoint extends KnownUnauthorizedEndpoint ? Options & ApiKeyOptions :
35
- ApiKeyOptions & Partial<AuthenticatedOptions>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brickset-api/types",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "TypeScript types for all datastructures used by the Brickset API",
5
5
  "license": "MIT",
6
6
  "repository": {