@pfdev/api-types 3.0.20 → 3.0.22

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 +68 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.20",
3
+ "version": "3.0.22",
4
4
  "description": "TypeScript types for PF API V3",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
package/v3.ts CHANGED
@@ -137,20 +137,79 @@ export const CardListSortSchema = Type.Union([
137
137
 
138
138
  export type CardListSort = Static<typeof CardListSortSchema>;
139
139
 
140
+ // Filters shared by /cards and /cards/facets. Each is a comma-separated list:
141
+ // values within one param match with OR, different params combine with AND.
142
+ const CardListFilterFields = {
143
+ setid: Type.Optional(Type.String({ description: 'Comma-separated set IDs (max 500). A single ID behaves as before.' })),
144
+ rarity: Type.Optional(Type.String({ description: 'Comma-separated rarities (max 50), matched exactly' })),
145
+ variant_id: Type.Optional(Type.String({ description: 'Comma-separated variant ids (variants[].id, max 50). Matches non-hidden variants only.' }))
146
+ };
147
+
148
+ const CardSearchField = 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.' }));
149
+
140
150
  export const CardListQuerySchema = Type.Object(
141
151
  {
142
- setid: Type.Optional(Type.String({ description: 'Filter by set ID' })),
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.' })),
152
+ ...CardListFilterFields,
153
+ search: CardSearchField,
144
154
  sort: Type.Optional(CardListSortSchema),
145
155
  include: CardIncludeSchema,
146
156
  limit: Type.Optional(Type.Number({ minimum: 1, maximum: 250, default: 50, description: 'Max results to return' })),
147
157
  offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
148
158
  },
149
- { description: 'At least one of setid or search must be provided' }
159
+ { description: 'At least one of search, setid, rarity or variant_id must be provided' }
150
160
  );
151
161
 
152
162
  export type CardListQuery = Static<typeof CardListQuerySchema>;
153
163
 
164
+ export const CardFacetsQuerySchema = Type.Object(
165
+ {
166
+ ...CardListFilterFields,
167
+ search: CardSearchField
168
+ },
169
+ { description: 'Same search and filters as /cards; at least one of them must be provided' }
170
+ );
171
+
172
+ export type CardFacetsQuery = Static<typeof CardFacetsQuerySchema>;
173
+
174
+ export const CardFacetGroupSchema = Type.Object(
175
+ {
176
+ value: Type.String({ description: 'Group id, e.g. the series name' }),
177
+ label: Type.String({ description: 'Heading to show users' })
178
+ },
179
+ { title: 'CardFacetGroup' }
180
+ );
181
+
182
+ export const CardFacetOptionSchema = Type.Object(
183
+ {
184
+ value: Type.String({ description: 'Value to send back in the matching filter param' }),
185
+ label: Type.String({ description: 'Label to show users' }),
186
+ count: Type.Integer({ description: 'Cards this option matches, ignoring this facet\'s own selection' }),
187
+ variant_count: Type.Integer({ description: 'Non-hidden variants on those cards, same counting rule. With variant_id, only the selected variants count.' }),
188
+ order: Type.Optional(Type.Integer({ description: 'Display order, ascending: variant sort_order; sets by release date, newest first (0 = newest). Omitted for rarity.' })),
189
+ group: Type.Optional(CardFacetGroupSchema)
190
+ },
191
+ { title: 'CardFacetOption' }
192
+ );
193
+
194
+ export type CardFacetOption = Static<typeof CardFacetOptionSchema>;
195
+
196
+ export const CardFacetsResponseSchema = Type.Object(
197
+ {
198
+ total: Type.Integer({ description: 'Cards matching search and all filters' }),
199
+ facets: Type.Object({
200
+ rarity: Type.Array(CardFacetOptionSchema),
201
+ variant: Type.Array(CardFacetOptionSchema),
202
+ set: Type.Array(CardFacetOptionSchema, { description: 'Each option carries its series in group, omitted when the set has no series' })
203
+ })
204
+ },
205
+ {
206
+ title: 'CardFacetsResponse',
207
+ description: 'Filter options for a card search, with counts'
208
+ }
209
+ );
210
+
211
+ export type CardFacetsResponse = Static<typeof CardFacetsResponseSchema>;
212
+
154
213
  export const CardBatchQuerySchema = Type.Object({
155
214
  ids: Type.String({
156
215
  minLength: 1,
@@ -221,7 +280,7 @@ const PricePointSchema = Type.Object(
221
280
  {
222
281
  date: Type.String({ description: 'Date of the price point' }),
223
282
  price: Type.Number({ description: 'Price on this date' }),
224
- variant: Type.String({ description: 'Card variant' }),
283
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (variants[].id on the card). Null when the variant text has no definition.' }),
225
284
  grade: Type.Optional(Type.String({ description: 'Grade (graded cards only)' }))
226
285
  },
227
286
  { title: 'PricePoint' }
@@ -229,7 +288,7 @@ const PricePointSchema = Type.Object(
229
288
 
230
289
  export const CardPricesQuerySchema = Type.Object({
231
290
  interval: Type.Number({ minimum: 1, maximum: 1825, default: 30, description: 'Number of days of price history to return' }),
232
- variant: Type.Optional(Type.String({ description: 'Variant name. If omitted, returns all variants.' })),
291
+ variant_id: Type.Optional(Type.Integer({ minimum: 1, description: 'Variant id (variants[].id on the card). If omitted, returns all variants.' })),
233
292
  grade: Type.Optional(Type.String({ description: 'Grade (e.g. "PSA 10", "BGS 9.5"). Omit or use "RAW" for ungraded.' })),
234
293
  source: Type.Optional(Type.Union(
235
294
  [Type.Literal('tcgplayer'), Type.Literal('ebay')],
@@ -242,7 +301,7 @@ export type CardPricesQuery = Static<typeof CardPricesQuerySchema>;
242
301
  export const CardPricesResponseSchema = Type.Object(
243
302
  {
244
303
  cardid: Type.String({ description: 'Card ID' }),
245
- variant: Type.Optional(Type.String({ description: 'Filtered variant, if specified' })),
304
+ variant_id: Type.Optional(Type.Integer({ description: 'Filtered variant id, if specified' })),
246
305
  grade: Type.String({ description: 'Resolved grade used for the query' }),
247
306
  source: Type.String({ description: 'Resolved price source used for the query' }),
248
307
  interval: Type.Number({ description: 'Number of days of history returned' }),
@@ -261,7 +320,7 @@ const SaleRecordSchema = Type.Object(
261
320
  sold_date: Type.String({ description: 'Date the card was sold' }),
262
321
  price: Type.Number({ description: 'Sale price' }),
263
322
  grade: Type.String({ description: 'Grade at time of sale' }),
264
- variant: Type.String({ description: 'Card variant' }),
323
+ variant_id: Type.Union([Type.Integer(), Type.Null()], { description: 'Variant id (variants[].id on the card). Null when the variant text has no definition.' }),
265
324
  title: Type.Optional(Type.String({ description: 'eBay listing title' })),
266
325
  url: Type.Optional(Type.String({ description: 'eBay listing URL' })),
267
326
  image_url: Type.Optional(Type.String({ description: 'Listing image URL' })),
@@ -272,7 +331,7 @@ const SaleRecordSchema = Type.Object(
272
331
 
273
332
  export const CardSalesQuerySchema = Type.Object({
274
333
  grade: Type.Optional(Type.String({ description: 'Filter by grade (e.g. "PSA 10"). Returns all grades if omitted.' })),
275
- variant: Type.Optional(Type.String({ description: 'Filter by variant. Returns all variants if omitted.' })),
334
+ variant_id: Type.Optional(Type.Integer({ minimum: 1, description: 'Filter by variant id (variants[].id on the card). Returns all variants if omitted.' })),
276
335
  limit: Type.Optional(Type.Number({ minimum: 1, maximum: 100, default: 25, description: 'Max results to return' })),
277
336
  offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
278
337
  });
@@ -283,7 +342,7 @@ export const CardSalesResponseSchema = Type.Object(
283
342
  {
284
343
  cardid: Type.String({ description: 'Card ID' }),
285
344
  grade: Type.Optional(Type.String({ description: 'Filtered grade, if specified' })),
286
- variant: Type.Optional(Type.String({ description: 'Filtered variant, if specified' })),
345
+ variant_id: Type.Optional(Type.Integer({ description: 'Filtered variant id, if specified' })),
287
346
  data: Type.Array(SaleRecordSchema, { description: 'Individual eBay sold listings, most recent first' }),
288
347
  total: Type.Number({ description: 'Total matching sales records' }),
289
348
  count: Type.Number({ description: 'Records returned in this response' })