@pfdev/api-types 3.0.21 → 3.0.23
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 +69 -5
package/package.json
CHANGED
package/v3.ts
CHANGED
|
@@ -89,7 +89,8 @@ export const CardSchema = Type.Object(
|
|
|
89
89
|
cardid: Type.String({ description: 'Unique card identifier' }),
|
|
90
90
|
name: Type.String({ description: 'Card name' }),
|
|
91
91
|
number: Type.String({ description: 'Card number within set' }),
|
|
92
|
-
rarity: Type.Optional(Type.String({ description: 'Card rarity' })),
|
|
92
|
+
rarity: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Card rarity, the same for every language (no _JP suffix). None when the card has no rarity; null when not set.' })),
|
|
93
|
+
language: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Card language code (EN, JP)' })),
|
|
93
94
|
artist: Type.Optional(Type.String({ description: 'Card artist' })),
|
|
94
95
|
images: CardImagesSchema,
|
|
95
96
|
setid: Type.String({ description: 'Set this card belongs to' }),
|
|
@@ -137,20 +138,82 @@ export const CardListSortSchema = Type.Union([
|
|
|
137
138
|
|
|
138
139
|
export type CardListSort = Static<typeof CardListSortSchema>;
|
|
139
140
|
|
|
141
|
+
// Filters shared by /cards and /cards/facets. Each is a comma-separated list:
|
|
142
|
+
// values within one param match with OR, different params combine with AND.
|
|
143
|
+
const CardListFilterFields = {
|
|
144
|
+
setid: Type.Optional(Type.String({ description: 'Comma-separated set IDs (max 500). A single ID behaves as before.' })),
|
|
145
|
+
rarity: Type.Optional(Type.String({ description: 'Comma-separated rarities (max 50), matched exactly. A rarity matches cards in every language.' })),
|
|
146
|
+
language: Type.Optional(Type.String({ description: 'Comma-separated language codes (EN, JP; max 50)' })),
|
|
147
|
+
variant_id: Type.Optional(Type.String({ description: 'Comma-separated variant ids (variants[].id, max 50). Matches non-hidden variants only.' }))
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
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.' }));
|
|
151
|
+
|
|
140
152
|
export const CardListQuerySchema = Type.Object(
|
|
141
153
|
{
|
|
142
|
-
|
|
143
|
-
search:
|
|
154
|
+
...CardListFilterFields,
|
|
155
|
+
search: CardSearchField,
|
|
144
156
|
sort: Type.Optional(CardListSortSchema),
|
|
145
157
|
include: CardIncludeSchema,
|
|
146
158
|
limit: Type.Optional(Type.Number({ minimum: 1, maximum: 250, default: 50, description: 'Max results to return' })),
|
|
147
159
|
offset: Type.Optional(Type.Number({ minimum: 0, default: 0, description: 'Pagination offset' }))
|
|
148
160
|
},
|
|
149
|
-
{ description: 'At least one of setid or
|
|
161
|
+
{ description: 'At least one of search, setid, rarity, language or variant_id must be provided' }
|
|
150
162
|
);
|
|
151
163
|
|
|
152
164
|
export type CardListQuery = Static<typeof CardListQuerySchema>;
|
|
153
165
|
|
|
166
|
+
export const CardFacetsQuerySchema = Type.Object(
|
|
167
|
+
{
|
|
168
|
+
...CardListFilterFields,
|
|
169
|
+
search: CardSearchField
|
|
170
|
+
},
|
|
171
|
+
{ description: 'Same search and filters as /cards; at least one of them must be provided' }
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
export type CardFacetsQuery = Static<typeof CardFacetsQuerySchema>;
|
|
175
|
+
|
|
176
|
+
export const CardFacetGroupSchema = Type.Object(
|
|
177
|
+
{
|
|
178
|
+
value: Type.String({ description: 'Group id, e.g. the series name' }),
|
|
179
|
+
label: Type.String({ description: 'Heading to show users' })
|
|
180
|
+
},
|
|
181
|
+
{ title: 'CardFacetGroup' }
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
export const CardFacetOptionSchema = Type.Object(
|
|
185
|
+
{
|
|
186
|
+
value: Type.String({ description: 'Value to send back in the matching filter param' }),
|
|
187
|
+
label: Type.String({ description: 'Label to show users' }),
|
|
188
|
+
count: Type.Integer({ description: 'Cards this option matches, ignoring this facet\'s own selection' }),
|
|
189
|
+
variant_count: Type.Integer({ description: 'Non-hidden variants on those cards, same counting rule. With variant_id, only the selected variants count.' }),
|
|
190
|
+
order: Type.Optional(Type.Integer({ description: 'Display order, ascending: variant sort_order; sets by release date, newest first (0 = newest); languages English first. Omitted for rarity.' })),
|
|
191
|
+
group: Type.Optional(CardFacetGroupSchema)
|
|
192
|
+
},
|
|
193
|
+
{ title: 'CardFacetOption' }
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
export type CardFacetOption = Static<typeof CardFacetOptionSchema>;
|
|
197
|
+
|
|
198
|
+
export const CardFacetsResponseSchema = Type.Object(
|
|
199
|
+
{
|
|
200
|
+
total: Type.Integer({ description: 'Cards matching search and all filters' }),
|
|
201
|
+
variant_total: Type.Integer({ description: 'Non-hidden variants on those cards, counted like variant_count. With variant_id, only the selected variants count.' }),
|
|
202
|
+
facets: Type.Object({
|
|
203
|
+
rarity: Type.Array(CardFacetOptionSchema, { description: 'Cards with no rarity have the value None, labelled "No rarity". Cards with rarity unset are counted in total but have no option.' }),
|
|
204
|
+
language: Type.Array(CardFacetOptionSchema, { description: 'Value is the language code, label its name (e.g. JP, Japanese)' }),
|
|
205
|
+
variant: Type.Array(CardFacetOptionSchema),
|
|
206
|
+
set: Type.Array(CardFacetOptionSchema, { description: 'Each option carries its series in group, omitted when the set has no series' })
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
title: 'CardFacetsResponse',
|
|
211
|
+
description: 'Filter options for a card search, with counts'
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
export type CardFacetsResponse = Static<typeof CardFacetsResponseSchema>;
|
|
216
|
+
|
|
154
217
|
export const CardBatchQuerySchema = Type.Object({
|
|
155
218
|
ids: Type.String({
|
|
156
219
|
minLength: 1,
|
|
@@ -166,7 +229,8 @@ export const CardDetailSchema = Type.Object(
|
|
|
166
229
|
cardid: Type.String({ description: 'Unique card identifier' }),
|
|
167
230
|
name: Type.String({ description: 'Card name' }),
|
|
168
231
|
number: Type.String({ description: 'Card number within set' }),
|
|
169
|
-
rarity: Type.Optional(Type.String({ description: 'Card rarity' })),
|
|
232
|
+
rarity: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Card rarity, the same for every language (no _JP suffix). None when the card has no rarity; null when not set.' })),
|
|
233
|
+
language: Type.Optional(Type.Union([Type.String(), Type.Null()], { description: 'Card language code (EN, JP)' })),
|
|
170
234
|
images: CardImagesSchema,
|
|
171
235
|
setid: Type.String({ description: 'Set this card belongs to' }),
|
|
172
236
|
setname: Type.String({ description: 'Name of the set' }),
|