@brickset-api/types 0.0.8 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @brickset-api/types
2
2
 
3
+ ## 0.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 92ab17b: Update types
8
+
3
9
  ## 0.0.8
4
10
 
5
11
  ### 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,10 @@
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
+ | '/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
- // helper for paginated endpoints
21
- type PaginationParameters = `pageNumber=${number}` | CombineParameters<`pageNumber=${number}`, `pageSize=${number}`>;
22
- type PaginatedEndpointUrl<Endpoint extends KnownEndpoint> = Endpoint | WithParameters<Endpoint, PaginationParameters>;
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 '/v3.asmx/getSets' ? GetSets :
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;
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.9",
4
4
  "description": "TypeScript types for all datastructures used by the Brickset API",
5
5
  "license": "MIT",
6
6
  "repository": {