@pfdev/api-types 3.0.17 → 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 +2 -2
  2. package/v3.ts +163 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.17",
3
+ "version": "3.0.19",
4
4
  "description": "TypeScript types for PF API V3",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -9,7 +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
+ "watch": "chokidar '../pfapi-fs/src/routes/v3/**/schemas.ts' -c 'npm run generate'",
13
13
  "verify": "tsc --noEmit v3.ts",
14
14
  "generate": "bash generate-types.sh",
15
15
  "preversion": "npm run generate && git add v3.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',
@@ -506,6 +547,99 @@ export const SetDetailParamSchema = Type.Object({
506
547
 
507
548
  export type SetDetailParam = Static<typeof SetDetailParamSchema>;
508
549
 
550
+ // ============= LISTS =============
551
+
552
+
553
+ export const ListTypeSchema = Type.Union(
554
+ [Type.Literal('static'), Type.Literal('dynamic'), Type.Literal('binder')],
555
+ { description: 'static = duplicates allowed, dynamic = one entry per card variant, binder = slot-based layout' }
556
+ );
557
+
558
+ export type ListType = Static<typeof ListTypeSchema>;
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
+
571
+ export const ListSchema = Type.Object(
572
+ {
573
+ uuid: Type.String({ format: 'uuid' }),
574
+ name: Type.String(),
575
+ description: Type.Union([Type.String(), Type.Null()]),
576
+ icon: Type.Union([Type.String(), Type.Null()]),
577
+ color: Type.Union([Type.String(), Type.Null()]),
578
+ is_private: Type.Boolean(),
579
+ type: Type.Union([ListTypeSchema, Type.Null()]),
580
+ binder_config: Type.Union([Type.Number(), Type.Null()], {
581
+ description: 'Binder layout preset. Only set for binders.'
582
+ }),
583
+ card_count: Type.Integer({ description: 'Total entries, including duplicates' }),
584
+ unique_count: Type.Integer({ description: 'Distinct cardids' }),
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
+ })
590
+ },
591
+ { title: 'List' }
592
+ );
593
+
594
+ export type List = Static<typeof ListSchema>;
595
+
596
+ export const ListsResponseSchema = Type.Array(ListSchema, {
597
+ title: 'ListsResponse',
598
+ description: 'All lists and binders owned by the authenticated user, oldest first.'
599
+ });
600
+
601
+ export const ListParamSchema = Type.Object({
602
+ uuid: Type.String({ format: 'uuid', description: 'UUID of the list' })
603
+ });
604
+
605
+ export type ListParam = Static<typeof ListParamSchema>;
606
+
607
+ const NameSchema = Type.String({ minLength: 1, maxLength: 100 });
608
+ const DescriptionSchema = Type.String({ maxLength: 1000 });
609
+
610
+ export const ListCreateRequestSchema = Type.Object(
611
+ {
612
+ name: NameSchema,
613
+ description: Type.Optional(DescriptionSchema),
614
+ icon: Type.String({ minLength: 1 }),
615
+ color: Type.String({ minLength: 1 }),
616
+ is_private: Type.Optional(Type.Boolean({ default: false })),
617
+ type: Type.Optional(ListTypeSchema),
618
+ binder_config: Type.Optional(Type.Number({ description: 'Required when type is binder; rejected otherwise' }))
619
+ },
620
+ { title: 'ListCreateRequest', additionalProperties: false }
621
+ );
622
+
623
+ export type ListCreateRequest = Static<typeof ListCreateRequestSchema>;
624
+
625
+ export const ListPatchRequestSchema = Type.Object(
626
+ {
627
+ name: Type.Optional(NameSchema),
628
+ description: Type.Optional(DescriptionSchema),
629
+ icon: Type.Optional(Type.String({ minLength: 1 })),
630
+ color: Type.Optional(Type.String({ minLength: 1 })),
631
+ is_private: Type.Optional(Type.Boolean())
632
+ },
633
+ {
634
+ title: 'ListPatchRequest',
635
+ description: 'Fields omitted from the body are left unchanged. type and binder_config cannot be changed.',
636
+ additionalProperties: false,
637
+ minProperties: 1
638
+ }
639
+ );
640
+
641
+ export type ListPatchRequest = Static<typeof ListPatchRequestSchema>;
642
+
509
643
  // ============= USERS =============
510
644
 
511
645
 
@@ -765,3 +899,22 @@ export const VisionResponseSchema = Type.Object(
765
899
  );
766
900
 
767
901
  export type VisionResponse = Static<typeof VisionResponseSchema>;
902
+
903
+ // ============= CLERK =============
904
+
905
+
906
+ export const WebhookAckSchema = Type.Object(
907
+ {
908
+ received: Type.Boolean()
909
+ },
910
+ { title: 'WebhookAck' }
911
+ );
912
+
913
+ export type WebhookAck = Static<typeof WebhookAckSchema>;
914
+
915
+ export const WebhookErrorSchema = Type.Object({
916
+ error: Type.String(),
917
+ message: Type.String()
918
+ });
919
+
920
+ export type WebhookError = Static<typeof WebhookErrorSchema>;