@pfdev/api-types 3.0.21 → 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 +62 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pfdev/api-types",
3
- "version": "3.0.21",
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,