@pfdev/api-types 3.0.19 → 3.0.21

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 +56 -60
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "description": "TypeScript types for PF API V3",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
package/v3.ts CHANGED
@@ -22,20 +22,42 @@ export const PriceStatsSchema = Type.Object(
22
22
  { title: 'PriceStats' }
23
23
  );
24
24
 
25
+ const GradedPricesSchema = Type.Record(Type.String(), PriceStatsSchema, {
26
+ description: 'Graded prices and period changes keyed by grade (e.g. "PSA 10")'
27
+ });
28
+
29
+ export const CardVariantSchema = Type.Object(
30
+ {
31
+ id: Type.Integer({ description: 'Variant id (pfdata_variant_definitions.id). Matches variant_id on inventory and list rows.' }),
32
+ display_name: Type.String({ description: 'Label to show users' }),
33
+ short_name: Type.Union([Type.String(), Type.Null()], { description: 'Short label for tight spaces (e.g. RH)' }),
34
+ color: Type.Union([Type.String(), Type.Null()], { description: 'Hex color (#RRGGBB)' }),
35
+ sort_order: Type.Integer({ description: 'Variants are returned sorted by this, ascending' }),
36
+ hidden: Type.Boolean({ description: 'Not meant to be shown or picked (e.g. Unknown)' }),
37
+ prices: Type.Optional(Type.Union([PriceStatsSchema, Type.Null()], {
38
+ description: 'Prices and period changes. Only present with include=variant_prices; null when the variant has no price.'
39
+ })),
40
+ graded: Type.Optional(Type.Union([GradedPricesSchema, Type.Null()], {
41
+ description: 'Graded prices keyed by grade. Only present with include=graded_variants_prices; null when the variant has no graded prices.'
42
+ }))
43
+ },
44
+ { title: 'CardVariant' }
45
+ );
46
+
47
+ const CardVariantsSchema = Type.Array(CardVariantSchema, {
48
+ description: 'The card\'s variants (from the pricing map), sorted by sort_order. Hidden variants are included with hidden: true.'
49
+ });
50
+
25
51
  const CardImagesSchema = Type.Object(
26
52
  {
27
53
  small: Type.String({ format: 'uri', description: 'Small card image URL' }),
28
- large: Type.String({ format: 'uri', description: 'Large card image URL' })
54
+ large: Type.String({ format: 'uri', description: 'Large card image URL' }),
55
+ small_webp: Type.Optional(Type.String({ format: 'uri', description: 'Small card image as WebP. Not every card has one.' })),
56
+ large_webp: Type.Optional(Type.String({ format: 'uri', description: 'Large card image as WebP. Not every card has one.' }))
29
57
  },
30
58
  { title: 'CardImages' }
31
59
  );
32
60
 
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
61
  // Fields on every card used for filtering and for web URLs
40
62
  const CardFilterFields = {
41
63
  supertype: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Supertype (Pokémon, Trainer, Energy)' })),
@@ -49,17 +71,17 @@ const CardFilterFields = {
49
71
  set_slug: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'URL slug for the set' }))
50
72
  };
51
73
 
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)'
74
+ const PriceVariantIdSchema = Type.Optional(Type.Union([Type.Integer(), Type.Null()], {
75
+ description: 'Id of the variant that price, change_1d and change_1d_value come from (the lowest-priced variant that isn\'t hidden)'
54
76
  }));
55
77
 
56
78
  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'
79
+ description: 'Date (YYYY-MM-DD) the price was last updated, for the variant in price_variant_id'
58
80
  }));
59
81
 
60
82
  const CardIncludeSchema = Type.Optional(Type.String({
61
83
  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)'
84
+ description: 'Comma-separated extras to include on each card: variant_prices (prices on each variant), graded_variants_prices (graded prices on each variant, keyed by grade)'
63
85
  }));
64
86
 
65
87
  export const CardSchema = Type.Object(
@@ -76,18 +98,9 @@ export const CardSchema = Type.Object(
76
98
  price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
77
99
  change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
78
100
  change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
79
- price_variant: PriceVariantSchema,
101
+ price_variant_id: PriceVariantIdSchema,
80
102
  price_date: PriceDateSchema,
81
- variants: Type.Optional(Type.Array(Type.String(), { description: 'Available variants for this card' })),
82
- variant_prices: Type.Optional(
83
- Type.Record(Type.String(), PriceStatsSchema, {
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.'
85
- })
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
- })
103
+ variants: CardVariantsSchema
91
104
  },
92
105
  {
93
106
  title: 'Card',
@@ -180,16 +193,15 @@ export const CardDetailSchema = Type.Object(
180
193
  series: CardFilterFields.series,
181
194
  slug: CardFilterFields.slug,
182
195
  set_slug: CardFilterFields.set_slug,
183
- price_variant: PriceVariantSchema,
196
+ price_variant_id: PriceVariantIdSchema,
184
197
  price_date: PriceDateSchema,
185
198
  price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
186
199
  change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
187
200
  change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
188
- variants: Type.Optional(Type.Array(Type.String(), { description: 'Available variants for this card' })),
189
- variant_prices: Type.Optional(
190
- Type.Record(Type.String(), PriceStatsSchema, { description: 'Prices and period changes keyed by variant name' })
191
- ),
192
- graded_variants_prices: Type.Optional(GradedVariantPricesSchema)
201
+ variants: {
202
+ ...CardVariantsSchema,
203
+ description: 'The card\'s variants (from the pricing map), sorted by sort_order, each with prices and graded. Hidden variants are included with hidden: true.'
204
+ }
193
205
  },
194
206
  {
195
207
  title: 'CardDetail',
@@ -209,7 +221,7 @@ const PricePointSchema = Type.Object(
209
221
  {
210
222
  date: Type.String({ description: 'Date of the price point' }),
211
223
  price: Type.Number({ description: 'Price on this date' }),
212
- variant: Type.String({ description: 'Card variant' }),
224
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (variants[].id on the card). Null when the variant text has no definition.' }),
213
225
  grade: Type.Optional(Type.String({ description: 'Grade (graded cards only)' }))
214
226
  },
215
227
  { title: 'PricePoint' }
@@ -217,7 +229,7 @@ const PricePointSchema = Type.Object(
217
229
 
218
230
  export const CardPricesQuerySchema = Type.Object({
219
231
  interval: Type.Number({ minimum: 1, maximum: 1825, default: 30, description: 'Number of days of price history to return' }),
220
- variant: Type.Optional(Type.String({ description: 'Variant name. If omitted, returns all variants.' })),
232
+ variant_id: Type.Optional(Type.Integer({ minimum: 1, description: 'Variant id (variants[].id on the card). If omitted, returns all variants.' })),
221
233
  grade: Type.Optional(Type.String({ description: 'Grade (e.g. "PSA 10", "BGS 9.5"). Omit or use "RAW" for ungraded.' })),
222
234
  source: Type.Optional(Type.Union(
223
235
  [Type.Literal('tcgplayer'), Type.Literal('ebay')],
@@ -230,7 +242,7 @@ export type CardPricesQuery = Static<typeof CardPricesQuerySchema>;
230
242
  export const CardPricesResponseSchema = Type.Object(
231
243
  {
232
244
  cardid: Type.String({ description: 'Card ID' }),
233
- variant: Type.Optional(Type.String({ description: 'Filtered variant, if specified' })),
245
+ variant_id: Type.Optional(Type.Integer({ description: 'Filtered variant id, if specified' })),
234
246
  grade: Type.String({ description: 'Resolved grade used for the query' }),
235
247
  source: Type.String({ description: 'Resolved price source used for the query' }),
236
248
  interval: Type.Number({ description: 'Number of days of history returned' }),
@@ -249,7 +261,7 @@ const SaleRecordSchema = Type.Object(
249
261
  sold_date: Type.String({ description: 'Date the card was sold' }),
250
262
  price: Type.Number({ description: 'Sale price' }),
251
263
  grade: Type.String({ description: 'Grade at time of sale' }),
252
- variant: Type.String({ description: 'Card variant' }),
264
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (variants[].id on the card). Null when the variant text has no definition.' }),
253
265
  title: Type.Optional(Type.String({ description: 'eBay listing title' })),
254
266
  url: Type.Optional(Type.String({ description: 'eBay listing URL' })),
255
267
  image_url: Type.Optional(Type.String({ description: 'Listing image URL' })),
@@ -260,7 +272,7 @@ const SaleRecordSchema = Type.Object(
260
272
 
261
273
  export const CardSalesQuerySchema = Type.Object({
262
274
  grade: Type.Optional(Type.String({ description: 'Filter by grade (e.g. "PSA 10"). Returns all grades if omitted.' })),
263
- variant: Type.Optional(Type.String({ description: 'Filter by variant. Returns all variants if omitted.' })),
275
+ variant_id: Type.Optional(Type.Integer({ minimum: 1, description: 'Filter by variant id (variants[].id on the card). Returns all variants if omitted.' })),
264
276
  limit: Type.Optional(Type.Number({ minimum: 1, maximum: 100, default: 25, description: 'Max results to return' })),
265
277
  offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
266
278
  });
@@ -271,7 +283,7 @@ export const CardSalesResponseSchema = Type.Object(
271
283
  {
272
284
  cardid: Type.String({ description: 'Card ID' }),
273
285
  grade: Type.Optional(Type.String({ description: 'Filtered grade, if specified' })),
274
- variant: Type.Optional(Type.String({ description: 'Filtered variant, if specified' })),
286
+ variant_id: Type.Optional(Type.Integer({ description: 'Filtered variant id, if specified' })),
275
287
  data: Type.Array(SaleRecordSchema, { description: 'Individual eBay sold listings, most recent first' }),
276
288
  total: Type.Number({ description: 'Total matching sales records' }),
277
289
  count: Type.Number({ description: 'Records returned in this response' })
@@ -309,14 +321,14 @@ export const DexCardSchema = Type.Intersect(
309
321
  [
310
322
  CardSchema,
311
323
  Type.Object({
312
- variant_prices: Type.Record(Type.String(), PriceStatsSchema, {
313
- description: 'Per-variant prices and period changes keyed by variant name'
324
+ variants: Type.Array(CardVariantSchema, {
325
+ description: 'The card\'s variants, sorted by sort_order, each with prices'
314
326
  })
315
327
  })
316
328
  ],
317
329
  {
318
330
  title: 'DexCard',
319
- description: 'A card in a Pokémon dex view, with full per-variant price breakdown'
331
+ description: 'A card in a Pokémon dex view, with prices on each variant'
320
332
  }
321
333
  );
322
334
  export type DexCard = Static<typeof DexCardSchema>;
@@ -560,7 +572,7 @@ export type ListType = Static<typeof ListTypeSchema>;
560
572
  export const ListCoverCardSchema = Type.Object(
561
573
  {
562
574
  cardid: Type.String(),
563
- variant: Type.String(),
575
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (pfdata_variant_definitions.id); matches variants[].id on cards. Null when the variant has no definition.' }),
564
576
  image: Type.Union([Type.String(), Type.Null()], { description: 'Small card image URL' })
565
577
  },
566
578
  { title: 'ListCoverCard' }
@@ -688,7 +700,7 @@ export const DexCollectionItemSchema = Type.Object(
688
700
  {
689
701
  id: Type.Integer({ description: 'Pokémon id (matches /dex/ response.id)' }),
690
702
  collected: Type.Integer({ description: 'Distinct cardids the user owns for this Pokémon' }),
691
- master_collected: Type.Integer({ description: 'Distinct (cardid, variant) pairs the user owns for this Pokémon' })
703
+ master_collected: Type.Integer({ description: 'Distinct (cardid, variant_id) pairs the user owns for this Pokémon' })
692
704
  },
693
705
  { title: 'DexCollectionItem' }
694
706
  );
@@ -701,7 +713,7 @@ export const InventorySummaryItemSchema = Type.Object(
701
713
  {
702
714
  uuid: Type.String({ description: 'Unique ID of this inventory row' }),
703
715
  cardid: Type.String({ description: 'Card ID this inventory row belongs to' }),
704
- variant: Type.String({ description: 'Card variant (e.g. Normal, Holofoil, Reverse Holofoil)' }),
716
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (pfdata_variant_definitions.id); matches variants[].id on cards. Null when the variant has no definition.' }),
705
717
  status: Type.Union([Type.Number(), Type.Null()], {
706
718
  description: 'Numeric status code. <100 = active, >=100 = sold/past. Null when no details row exists yet.'
707
719
  }),
@@ -725,7 +737,7 @@ export type InventorySummaryResponse = Static<typeof InventorySummaryResponseSch
725
737
  export const InventoryAddRequestSchema = Type.Object(
726
738
  {
727
739
  cardid: Type.String({ minLength: 1, description: 'Card ID to add to inventory' }),
728
- variant: Type.String({ minLength: 1, description: 'Card variant (e.g. Normal, Holofoil, Reverse Holofoil)' })
740
+ variant_id: Type.Integer({ minimum: 1, description: 'Variant id (variants[].id on the card). Must be one of the card\'s variants and not hidden.' })
729
741
  },
730
742
  { title: 'InventoryAddRequest' }
731
743
  );
@@ -759,7 +771,7 @@ export const InventoryItemDetailSchema = Type.Object(
759
771
  {
760
772
  uuid: Type.String({ format: 'uuid' }),
761
773
  cardid: Type.String(),
762
- variant: Type.String(),
774
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (pfdata_variant_definitions.id); matches variants[].id on cards. Null when the variant has no definition.' }),
763
775
  status: Type.Union([Type.Number(), Type.Null()]),
764
776
  grade: Type.Union([Type.String(), Type.Null()]),
765
777
  acquired: Type.Union([Type.String(), Type.Null()]),
@@ -840,20 +852,6 @@ export type InventoryPatchRequest = Static<typeof InventoryPatchRequestSchema>;
840
852
  // ============= VISION =============
841
853
 
842
854
 
843
- const VariantPriceSchema = Type.Object(
844
- {
845
- variant: Type.String(),
846
- current_price: Type.Optional(Type.Number()),
847
- change_1d: Type.Optional(Type.Number()),
848
- change_7d: Type.Optional(Type.Number()),
849
- change_1m: Type.Optional(Type.Number()),
850
- change_3m: Type.Optional(Type.Number()),
851
- change_6m: Type.Optional(Type.Number()),
852
- change_1y: Type.Optional(Type.Number())
853
- },
854
- { title: 'VisionVariantPrice' }
855
- );
856
-
857
855
  const DetectedCardSchema = Type.Object(
858
856
  {
859
857
  name: Type.String({ description: 'Card name from image recognition' }),
@@ -868,11 +866,9 @@ const DetectedCardSchema = Type.Object(
868
866
 
869
867
  const MatchedCardSchema = Type.Intersect(
870
868
  [
871
- // Vision returns variant_prices as an array, not CardSchema's map
872
- Type.Omit(CardSchema, ['variant_prices']),
869
+ CardSchema,
873
870
  Type.Object({
874
- score: Type.Number({ description: 'Fuzzy match score — higher is a better match' }),
875
- variant_prices: Type.Array(VariantPriceSchema, { description: 'Per-variant prices with extended period changes' })
871
+ score: Type.Number({ description: 'Fuzzy match score — higher is a better match' })
876
872
  })
877
873
  ],
878
874
  { title: 'MatchedCard' }