@pfdev/api-types 3.0.19 → 3.0.20

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 +50 -54
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.20",
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',
@@ -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' }