@pfdev/api-types 3.0.18 → 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.
- package/package.json +1 -1
- package/v3.ts +98 -46
package/package.json
CHANGED
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' })),
|
|
@@ -20,14 +22,68 @@ export const PriceStatsSchema = Type.Object(
|
|
|
20
22
|
{ title: 'PriceStats' }
|
|
21
23
|
);
|
|
22
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
|
+
|
|
23
51
|
const CardImagesSchema = Type.Object(
|
|
24
52
|
{
|
|
25
53
|
small: Type.String({ format: 'uri', description: 'Small card image URL' }),
|
|
26
|
-
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.' }))
|
|
27
57
|
},
|
|
28
58
|
{ title: 'CardImages' }
|
|
29
59
|
);
|
|
30
60
|
|
|
61
|
+
// Fields on every card used for filtering and for web URLs
|
|
62
|
+
const CardFilterFields = {
|
|
63
|
+
supertype: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Supertype (Pokémon, Trainer, Energy)' })),
|
|
64
|
+
subtypes: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()], { description: 'Card subtypes' })),
|
|
65
|
+
types: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()], { description: 'Card types' })),
|
|
66
|
+
nationalPokedexNumbers: Type.Optional(Type.Union([Type.Array(Type.Number()), Type.Null()], { description: 'National Pokédex numbers' })),
|
|
67
|
+
regulationMark: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Regulation mark' })),
|
|
68
|
+
set_release_date: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Release date of the set' })),
|
|
69
|
+
series: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Series the set belongs to' })),
|
|
70
|
+
slug: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'URL slug for the card' })),
|
|
71
|
+
set_slug: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'URL slug for the set' }))
|
|
72
|
+
};
|
|
73
|
+
|
|
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)'
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
const PriceDateSchema = Type.Optional(Type.Union([Type.String(), Type.Null()], {
|
|
79
|
+
description: 'Date (YYYY-MM-DD) the price was last updated, for the variant in price_variant_id'
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
const CardIncludeSchema = Type.Optional(Type.String({
|
|
83
|
+
pattern: '^(variant_prices|graded_variants_prices)(,(variant_prices|graded_variants_prices))*$',
|
|
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)'
|
|
85
|
+
}));
|
|
86
|
+
|
|
31
87
|
export const CardSchema = Type.Object(
|
|
32
88
|
{
|
|
33
89
|
cardid: Type.String({ description: 'Unique card identifier' }),
|
|
@@ -38,15 +94,13 @@ export const CardSchema = Type.Object(
|
|
|
38
94
|
images: CardImagesSchema,
|
|
39
95
|
setid: Type.String({ description: 'Set this card belongs to' }),
|
|
40
96
|
setname: Type.String({ description: 'Name of the set' }),
|
|
97
|
+
...CardFilterFields,
|
|
41
98
|
price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
|
|
42
99
|
change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
|
|
43
100
|
change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
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
|
-
})
|
|
49
|
-
)
|
|
101
|
+
price_variant_id: PriceVariantIdSchema,
|
|
102
|
+
price_date: PriceDateSchema,
|
|
103
|
+
variants: CardVariantsSchema
|
|
50
104
|
},
|
|
51
105
|
{
|
|
52
106
|
title: 'Card',
|
|
@@ -88,7 +142,7 @@ export const CardListQuerySchema = Type.Object(
|
|
|
88
142
|
setid: Type.Optional(Type.String({ description: 'Filter by set ID' })),
|
|
89
143
|
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
144
|
sort: Type.Optional(CardListSortSchema),
|
|
91
|
-
include:
|
|
145
|
+
include: CardIncludeSchema,
|
|
92
146
|
limit: Type.Optional(Type.Number({ minimum: 1, maximum: 250, default: 50, description: 'Max results to return' })),
|
|
93
147
|
offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
|
|
94
148
|
},
|
|
@@ -102,7 +156,7 @@ export const CardBatchQuerySchema = Type.Object({
|
|
|
102
156
|
minLength: 1,
|
|
103
157
|
description: 'Comma-separated list of card IDs (e.g. "xy1-2,base1-4"). Duplicates are deduped. Max 200 IDs per request.'
|
|
104
158
|
}),
|
|
105
|
-
include:
|
|
159
|
+
include: CardIncludeSchema
|
|
106
160
|
});
|
|
107
161
|
|
|
108
162
|
export type CardBatchQuery = Static<typeof CardBatchQuerySchema>;
|
|
@@ -135,20 +189,19 @@ export const CardDetailSchema = Type.Object(
|
|
|
135
189
|
nationalPokedexNumbers: Type.Optional(Type.Array(Type.Number(), { description: 'National Pokédex numbers' })),
|
|
136
190
|
legalities: Type.Optional(Type.Any({ description: 'Format legalities' })),
|
|
137
191
|
regulationMark: Type.Optional(Type.String({ description: 'Regulation mark' })),
|
|
192
|
+
set_release_date: CardFilterFields.set_release_date,
|
|
193
|
+
series: CardFilterFields.series,
|
|
194
|
+
slug: CardFilterFields.slug,
|
|
195
|
+
set_slug: CardFilterFields.set_slug,
|
|
196
|
+
price_variant_id: PriceVariantIdSchema,
|
|
197
|
+
price_date: PriceDateSchema,
|
|
138
198
|
price: Type.Optional(Type.Number({ description: 'Price of the lowest-priced variant' })),
|
|
139
199
|
change_1d: Type.Optional(Type.Number({ description: '1-day price change as a percentage' })),
|
|
140
200
|
change_1d_value: Type.Optional(Type.Number({ description: '1-day price change in dollars' })),
|
|
141
|
-
variants:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
)
|
|
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
|
+
}
|
|
152
205
|
},
|
|
153
206
|
{
|
|
154
207
|
title: 'CardDetail',
|
|
@@ -268,14 +321,14 @@ export const DexCardSchema = Type.Intersect(
|
|
|
268
321
|
[
|
|
269
322
|
CardSchema,
|
|
270
323
|
Type.Object({
|
|
271
|
-
|
|
272
|
-
description: '
|
|
324
|
+
variants: Type.Array(CardVariantSchema, {
|
|
325
|
+
description: 'The card\'s variants, sorted by sort_order, each with prices'
|
|
273
326
|
})
|
|
274
327
|
})
|
|
275
328
|
],
|
|
276
329
|
{
|
|
277
330
|
title: 'DexCard',
|
|
278
|
-
description: 'A card in a Pokémon dex view, with
|
|
331
|
+
description: 'A card in a Pokémon dex view, with prices on each variant'
|
|
279
332
|
}
|
|
280
333
|
);
|
|
281
334
|
export type DexCard = Static<typeof DexCardSchema>;
|
|
@@ -516,6 +569,17 @@ export const ListTypeSchema = Type.Union(
|
|
|
516
569
|
|
|
517
570
|
export type ListType = Static<typeof ListTypeSchema>;
|
|
518
571
|
|
|
572
|
+
export const ListCoverCardSchema = Type.Object(
|
|
573
|
+
{
|
|
574
|
+
cardid: 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.' }),
|
|
576
|
+
image: Type.Union([Type.String(), Type.Null()], { description: 'Small card image URL' })
|
|
577
|
+
},
|
|
578
|
+
{ title: 'ListCoverCard' }
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
export type ListCoverCard = Static<typeof ListCoverCardSchema>;
|
|
582
|
+
|
|
519
583
|
export const ListSchema = Type.Object(
|
|
520
584
|
{
|
|
521
585
|
uuid: Type.String({ format: 'uuid' }),
|
|
@@ -530,7 +594,11 @@ export const ListSchema = Type.Object(
|
|
|
530
594
|
}),
|
|
531
595
|
card_count: Type.Integer({ description: 'Total entries, including duplicates' }),
|
|
532
596
|
unique_count: Type.Integer({ description: 'Distinct cardids' }),
|
|
533
|
-
total_value: Type.Number({ description: 'Sum of current USD prices of every entry' })
|
|
597
|
+
total_value: Type.Number({ description: 'Sum of current USD prices of every entry' }),
|
|
598
|
+
cover: Type.Array(ListCoverCardSchema, {
|
|
599
|
+
maxItems: 3,
|
|
600
|
+
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.'
|
|
601
|
+
})
|
|
534
602
|
},
|
|
535
603
|
{ title: 'List' }
|
|
536
604
|
);
|
|
@@ -632,7 +700,7 @@ export const DexCollectionItemSchema = Type.Object(
|
|
|
632
700
|
{
|
|
633
701
|
id: Type.Integer({ description: 'Pokémon id (matches /dex/ response.id)' }),
|
|
634
702
|
collected: Type.Integer({ description: 'Distinct cardids the user owns for this Pokémon' }),
|
|
635
|
-
master_collected: Type.Integer({ description: 'Distinct (cardid,
|
|
703
|
+
master_collected: Type.Integer({ description: 'Distinct (cardid, variant_id) pairs the user owns for this Pokémon' })
|
|
636
704
|
},
|
|
637
705
|
{ title: 'DexCollectionItem' }
|
|
638
706
|
);
|
|
@@ -645,7 +713,7 @@ export const InventorySummaryItemSchema = Type.Object(
|
|
|
645
713
|
{
|
|
646
714
|
uuid: Type.String({ description: 'Unique ID of this inventory row' }),
|
|
647
715
|
cardid: Type.String({ description: 'Card ID this inventory row belongs to' }),
|
|
648
|
-
|
|
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.' }),
|
|
649
717
|
status: Type.Union([Type.Number(), Type.Null()], {
|
|
650
718
|
description: 'Numeric status code. <100 = active, >=100 = sold/past. Null when no details row exists yet.'
|
|
651
719
|
}),
|
|
@@ -669,7 +737,7 @@ export type InventorySummaryResponse = Static<typeof InventorySummaryResponseSch
|
|
|
669
737
|
export const InventoryAddRequestSchema = Type.Object(
|
|
670
738
|
{
|
|
671
739
|
cardid: Type.String({ minLength: 1, description: 'Card ID to add to inventory' }),
|
|
672
|
-
|
|
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.' })
|
|
673
741
|
},
|
|
674
742
|
{ title: 'InventoryAddRequest' }
|
|
675
743
|
);
|
|
@@ -703,7 +771,7 @@ export const InventoryItemDetailSchema = Type.Object(
|
|
|
703
771
|
{
|
|
704
772
|
uuid: Type.String({ format: 'uuid' }),
|
|
705
773
|
cardid: Type.String(),
|
|
706
|
-
|
|
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.' }),
|
|
707
775
|
status: Type.Union([Type.Number(), Type.Null()]),
|
|
708
776
|
grade: Type.Union([Type.String(), Type.Null()]),
|
|
709
777
|
acquired: Type.Union([Type.String(), Type.Null()]),
|
|
@@ -784,20 +852,6 @@ export type InventoryPatchRequest = Static<typeof InventoryPatchRequestSchema>;
|
|
|
784
852
|
// ============= VISION =============
|
|
785
853
|
|
|
786
854
|
|
|
787
|
-
const VariantPriceSchema = Type.Object(
|
|
788
|
-
{
|
|
789
|
-
variant: Type.String(),
|
|
790
|
-
current_price: Type.Optional(Type.Number()),
|
|
791
|
-
change_1d: Type.Optional(Type.Number()),
|
|
792
|
-
change_7d: Type.Optional(Type.Number()),
|
|
793
|
-
change_1m: Type.Optional(Type.Number()),
|
|
794
|
-
change_3m: Type.Optional(Type.Number()),
|
|
795
|
-
change_6m: Type.Optional(Type.Number()),
|
|
796
|
-
change_1y: Type.Optional(Type.Number())
|
|
797
|
-
},
|
|
798
|
-
{ title: 'VisionVariantPrice' }
|
|
799
|
-
);
|
|
800
|
-
|
|
801
855
|
const DetectedCardSchema = Type.Object(
|
|
802
856
|
{
|
|
803
857
|
name: Type.String({ description: 'Card name from image recognition' }),
|
|
@@ -812,11 +866,9 @@ const DetectedCardSchema = Type.Object(
|
|
|
812
866
|
|
|
813
867
|
const MatchedCardSchema = Type.Intersect(
|
|
814
868
|
[
|
|
815
|
-
|
|
816
|
-
Type.Omit(CardSchema, ['variant_prices']),
|
|
869
|
+
CardSchema,
|
|
817
870
|
Type.Object({
|
|
818
|
-
score: Type.Number({ description: 'Fuzzy match score — higher is a better match' })
|
|
819
|
-
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' })
|
|
820
872
|
})
|
|
821
873
|
],
|
|
822
874
|
{ title: 'MatchedCard' }
|