@pfdev/api-types 3.0.2 → 3.0.5

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.
Files changed (2) hide show
  1. package/package.json +3 -1
  2. package/v3.ts +59 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.2",
3
+ "version": "3.0.5",
4
4
  "description": "TypeScript types for PF API V3",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -9,6 +9,7 @@
9
9
  "v3.ts"
10
10
  ],
11
11
  "scripts": {
12
+ "watch": "chokidar '../pfapi-fs/src/routes/v3/*/schemas.ts' -c 'npm run generate'",
12
13
  "verify": "tsc --noEmit v3.ts",
13
14
  "generate": "bash generate-types.sh",
14
15
  "preversion": "npm run generate && git add v3.ts",
@@ -23,6 +24,7 @@
23
24
  "license": "MIT",
24
25
  "devDependencies": {
25
26
  "@sinclair/typebox": "^0.34.52",
27
+ "chokidar-cli": "^3.0.0",
26
28
  "typescript": "^7.0.2"
27
29
  }
28
30
  }
package/v3.ts CHANGED
@@ -4,6 +4,65 @@
4
4
  import { Static, Type } from '@sinclair/typebox';
5
5
 
6
6
 
7
+ // ============= CARDS =============
8
+
9
+
10
+ const CardImagesSchema = Type.Object(
11
+ {
12
+ small: Type.String({ format: 'uri', description: 'Small card image URL' }),
13
+ large: Type.String({ format: 'uri', description: 'Large card image URL' })
14
+ },
15
+ { title: 'CardImages' }
16
+ );
17
+
18
+ export const CardSchema = Type.Object(
19
+ {
20
+ cardid: Type.String({ description: 'Unique card identifier' }),
21
+ name: Type.String({ description: 'Card name' }),
22
+ number: Type.String({ description: 'Card number within set' }),
23
+ rarity: Type.Optional(Type.String({ description: 'Card rarity' })),
24
+ images: CardImagesSchema,
25
+ setid: Type.String({ description: 'Set this card belongs to' }),
26
+ setname: Type.String({ description: 'Name of the set' }),
27
+ price: Type.Optional(Type.Number({ description: 'Lowest price across all variants' })),
28
+ change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
29
+ change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
30
+ variants: Type.Optional(Type.Array(Type.String(), { description: 'Available variants for this card' }))
31
+ },
32
+ {
33
+ title: 'Card',
34
+ description: 'A Pokemon card'
35
+ }
36
+ );
37
+
38
+ export type Card = Static<typeof CardSchema>;
39
+
40
+ export const CardListResponseSchema = Type.Object(
41
+ {
42
+ data: Type.Array(CardSchema, { description: 'Array of cards' }),
43
+ total: Type.Number({ description: 'Total number of cards matching query' }),
44
+ count: Type.Number({ description: 'Number of cards returned in this response' })
45
+ },
46
+ {
47
+ title: 'CardListResponse',
48
+ description: 'Paginated list of Pokemon cards'
49
+ }
50
+ );
51
+
52
+ export type CardListResponse = Static<typeof CardListResponseSchema>;
53
+
54
+ export const CardListQuerySchema = Type.Object(
55
+ {
56
+ setid: Type.Optional(Type.String({ description: 'Filter by set ID' })),
57
+ name: Type.Optional(Type.String({ description: 'Search by card name' })),
58
+ limit: Type.Optional(Type.Number({ minimum: 1, maximum: 250, default: 50, description: 'Max results to return' })),
59
+ offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
60
+ },
61
+ { description: 'At least one of setid or name must be provided' }
62
+ );
63
+
64
+ export type CardListQuery = Static<typeof CardListQuerySchema>;
65
+
7
66
  // ============= SETS =============
8
67
 
9
68