@pfdev/api-types 3.0.18 → 3.0.19

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 +1 -1
  2. package/v3.ts +67 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.18",
3
+ "version": "3.0.19",
4
4
  "description": "TypeScript types for PF API V3",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
package/v3.ts CHANGED
@@ -10,6 +10,8 @@ import { Static, Type } from '@sinclair/typebox';
10
10
  export const PriceStatsSchema = Type.Object(
11
11
  {
12
12
  current_price: Type.Optional(Type.Number({ description: 'Current price' })),
13
+ price_date: Type.Optional(Type.String({ description: 'Date (YYYY-MM-DD) this price was last updated' })),
14
+ change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
13
15
  change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
14
16
  change_7d: Type.Optional(Type.Number({ description: '7-day price change as a percentage' })),
15
17
  change_1m: Type.Optional(Type.Number({ description: '30-day price change as a percentage' })),
@@ -28,6 +30,38 @@ const CardImagesSchema = Type.Object(
28
30
  { title: 'CardImages' }
29
31
  );
30
32
 
33
+ const GradedVariantPricesSchema = Type.Record(
34
+ Type.String(),
35
+ Type.Record(Type.String(), PriceStatsSchema),
36
+ { description: 'Graded prices and period changes keyed by variant then grade' }
37
+ );
38
+
39
+ // Fields on every card used for filtering and for web URLs
40
+ const CardFilterFields = {
41
+ supertype: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Supertype (Pokémon, Trainer, Energy)' })),
42
+ subtypes: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()], { description: 'Card subtypes' })),
43
+ types: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()], { description: 'Card types' })),
44
+ nationalPokedexNumbers: Type.Optional(Type.Union([Type.Array(Type.Number()), Type.Null()], { description: 'National Pokédex numbers' })),
45
+ regulationMark: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Regulation mark' })),
46
+ set_release_date: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Release date of the set' })),
47
+ series: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Series the set belongs to' })),
48
+ slug: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'URL slug for the card' })),
49
+ set_slug: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'URL slug for the set' }))
50
+ };
51
+
52
+ const PriceVariantSchema = Type.Optional(Type.Union([Type.String(), Type.Null()], {
53
+ description: 'Variant that price, change_1d and change_1d_value come from (the lowest-priced variant)'
54
+ }));
55
+
56
+ const PriceDateSchema = Type.Optional(Type.Union([Type.String(), Type.Null()], {
57
+ description: 'Date (YYYY-MM-DD) the price was last updated, for the variant in price_variant'
58
+ }));
59
+
60
+ const CardIncludeSchema = Type.Optional(Type.String({
61
+ pattern: '^(variant_prices|graded_variants_prices)(,(variant_prices|graded_variants_prices))*$',
62
+ description: 'Comma-separated extras to include on each card: variant_prices (per-variant prices and period changes), graded_variants_prices (graded prices keyed by variant then grade)'
63
+ }));
64
+
31
65
  export const CardSchema = Type.Object(
32
66
  {
33
67
  cardid: Type.String({ description: 'Unique card identifier' }),
@@ -38,15 +72,22 @@ export const CardSchema = Type.Object(
38
72
  images: CardImagesSchema,
39
73
  setid: Type.String({ description: 'Set this card belongs to' }),
40
74
  setname: Type.String({ description: 'Name of the set' }),
75
+ ...CardFilterFields,
41
76
  price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
42
77
  change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
43
78
  change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
79
+ price_variant: PriceVariantSchema,
80
+ price_date: PriceDateSchema,
44
81
  variants: Type.Optional(Type.Array(Type.String(), { description: 'Available variants for this card' })),
45
82
  variant_prices: Type.Optional(
46
83
  Type.Record(Type.String(), PriceStatsSchema, {
47
84
  description: 'Prices and period changes keyed by variant name. Only present when requested via include=variant_prices. Variants without price data map to an empty object.'
48
85
  })
49
- )
86
+ ),
87
+ graded_variants_prices: Type.Optional({
88
+ ...GradedVariantPricesSchema,
89
+ description: 'Graded prices and period changes keyed by variant then grade. Only present when requested via include=graded_variants_prices; empty when the card has no graded prices.'
90
+ })
50
91
  },
51
92
  {
52
93
  title: 'Card',
@@ -88,7 +129,7 @@ export const CardListQuerySchema = Type.Object(
88
129
  setid: Type.Optional(Type.String({ description: 'Filter by set ID' })),
89
130
  search: Type.Optional(Type.String({ minLength: 1, description: 'Search by card name and/or number. Tokens with digits match card number; other tokens match card name.' })),
90
131
  sort: Type.Optional(CardListSortSchema),
91
- include: Type.Optional(Type.Literal('variant_prices', { description: 'Include per-variant prices and period changes on each card' })),
132
+ include: CardIncludeSchema,
92
133
  limit: Type.Optional(Type.Number({ minimum: 1, maximum: 250, default: 50, description: 'Max results to return' })),
93
134
  offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
94
135
  },
@@ -102,7 +143,7 @@ export const CardBatchQuerySchema = Type.Object({
102
143
  minLength: 1,
103
144
  description: 'Comma-separated list of card IDs (e.g. "xy1-2,base1-4"). Duplicates are deduped. Max 200 IDs per request.'
104
145
  }),
105
- include: Type.Optional(Type.Literal('variant_prices', { description: 'Include per-variant prices and period changes on each card' }))
146
+ include: CardIncludeSchema
106
147
  });
107
148
 
108
149
  export type CardBatchQuery = Static<typeof CardBatchQuerySchema>;
@@ -135,6 +176,12 @@ export const CardDetailSchema = Type.Object(
135
176
  nationalPokedexNumbers: Type.Optional(Type.Array(Type.Number(), { description: 'National Pokédex numbers' })),
136
177
  legalities: Type.Optional(Type.Any({ description: 'Format legalities' })),
137
178
  regulationMark: Type.Optional(Type.String({ description: 'Regulation mark' })),
179
+ set_release_date: CardFilterFields.set_release_date,
180
+ series: CardFilterFields.series,
181
+ slug: CardFilterFields.slug,
182
+ set_slug: CardFilterFields.set_slug,
183
+ price_variant: PriceVariantSchema,
184
+ price_date: PriceDateSchema,
138
185
  price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
139
186
  change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
140
187
  change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
@@ -142,13 +189,7 @@ export const CardDetailSchema = Type.Object(
142
189
  variant_prices: Type.Optional(
143
190
  Type.Record(Type.String(), PriceStatsSchema, { description: 'Prices and period changes keyed by variant name' })
144
191
  ),
145
- graded_variants_prices: Type.Optional(
146
- Type.Record(
147
- Type.String(),
148
- Type.Record(Type.String(), PriceStatsSchema),
149
- { description: 'Graded prices and period changes keyed by variant then grade' }
150
- )
151
- )
192
+ graded_variants_prices: Type.Optional(GradedVariantPricesSchema)
152
193
  },
153
194
  {
154
195
  title: 'CardDetail',
@@ -516,6 +557,17 @@ export const ListTypeSchema = Type.Union(
516
557
 
517
558
  export type ListType = Static<typeof ListTypeSchema>;
518
559
 
560
+ export const ListCoverCardSchema = Type.Object(
561
+ {
562
+ cardid: Type.String(),
563
+ variant: Type.String(),
564
+ image: Type.Union([Type.String(), Type.Null()], { description: 'Small card image URL' })
565
+ },
566
+ { title: 'ListCoverCard' }
567
+ );
568
+
569
+ export type ListCoverCard = Static<typeof ListCoverCardSchema>;
570
+
519
571
  export const ListSchema = Type.Object(
520
572
  {
521
573
  uuid: Type.String({ format: 'uuid' }),
@@ -530,7 +582,11 @@ export const ListSchema = Type.Object(
530
582
  }),
531
583
  card_count: Type.Integer({ description: 'Total entries, including duplicates' }),
532
584
  unique_count: Type.Integer({ description: 'Distinct cardids' }),
533
- total_value: Type.Number({ description: 'Sum of current USD prices of every entry' })
585
+ total_value: Type.Number({ description: 'Sum of current USD prices of every entry' }),
586
+ cover: Type.Array(ListCoverCardSchema, {
587
+ maxItems: 3,
588
+ description: 'Up to 3 cards for the list tile: the most recently added entries, or the first slots for binders. Empty when the list has no cards.'
589
+ })
534
590
  },
535
591
  { title: 'List' }
536
592
  );