wikimasters-cli 0.0.0-stage → 0.1.0

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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -2
  3. package/dist/cli/config.js +47 -0
  4. package/dist/cli/config.js.map +1 -0
  5. package/dist/cli/main.js +10 -0
  6. package/dist/cli/main.js.map +1 -0
  7. package/dist/cli/output.js +297 -0
  8. package/dist/cli/output.js.map +1 -0
  9. package/dist/cli/pasted-session.js +49 -0
  10. package/dist/cli/pasted-session.js.map +1 -0
  11. package/dist/cli/program.js +334 -0
  12. package/dist/cli/program.js.map +1 -0
  13. package/dist/cli/session.js +30 -0
  14. package/dist/cli/session.js.map +1 -0
  15. package/dist/core/auction-bids.js +31 -0
  16. package/dist/core/auction-bids.js.map +1 -0
  17. package/dist/core/auction-cancel.js +17 -0
  18. package/dist/core/auction-cancel.js.map +1 -0
  19. package/dist/core/auction-create.js +40 -0
  20. package/dist/core/auction-create.js.map +1 -0
  21. package/dist/core/auction-list.js +16 -0
  22. package/dist/core/auction-list.js.map +1 -0
  23. package/dist/core/auction-search.js +38 -0
  24. package/dist/core/auction-search.js.map +1 -0
  25. package/dist/core/auction.js +79 -0
  26. package/dist/core/auction.js.map +1 -0
  27. package/dist/core/auth-cookie.js +50 -0
  28. package/dist/core/auth-cookie.js.map +1 -0
  29. package/dist/core/browser-login.js +81 -0
  30. package/dist/core/browser-login.js.map +1 -0
  31. package/dist/core/card-id.js +5 -0
  32. package/dist/core/card-id.js.map +1 -0
  33. package/dist/core/card-search.js +51 -0
  34. package/dist/core/card-search.js.map +1 -0
  35. package/dist/core/card-value.js +43 -0
  36. package/dist/core/card-value.js.map +1 -0
  37. package/dist/core/collection-entry.js +18 -0
  38. package/dist/core/collection-entry.js.map +1 -0
  39. package/dist/core/collection-list.js +44 -0
  40. package/dist/core/collection-list.js.map +1 -0
  41. package/dist/core/collection.js +46 -0
  42. package/dist/core/collection.js.map +1 -0
  43. package/dist/core/entry-id.js +4 -0
  44. package/dist/core/entry-id.js.map +1 -0
  45. package/dist/core/errors.js +28 -0
  46. package/dist/core/errors.js.map +1 -0
  47. package/dist/core/favourite.js +27 -0
  48. package/dist/core/favourite.js.map +1 -0
  49. package/dist/core/global-collection.js +58 -0
  50. package/dist/core/global-collection.js.map +1 -0
  51. package/dist/core/index.js +26 -0
  52. package/dist/core/index.js.map +1 -0
  53. package/dist/core/integer.js +15 -0
  54. package/dist/core/integer.js.map +1 -0
  55. package/dist/core/label.js +39 -0
  56. package/dist/core/label.js.map +1 -0
  57. package/dist/core/notification-list.js +32 -0
  58. package/dist/core/notification-list.js.map +1 -0
  59. package/dist/core/page.js +22 -0
  60. package/dist/core/page.js.map +1 -0
  61. package/dist/core/paged-read.js +14 -0
  62. package/dist/core/paged-read.js.map +1 -0
  63. package/dist/core/positive-integer.js +12 -0
  64. package/dist/core/positive-integer.js.map +1 -0
  65. package/dist/core/profile-collection.js +45 -0
  66. package/dist/core/profile-collection.js.map +1 -0
  67. package/dist/core/session.js +49 -0
  68. package/dist/core/session.js.map +1 -0
  69. package/dist/core/site.js +52 -0
  70. package/dist/core/site.js.map +1 -0
  71. package/dist/core/supabase.js +5 -0
  72. package/dist/core/supabase.js.map +1 -0
  73. package/dist/core/table-query.js +21 -0
  74. package/dist/core/table-query.js.map +1 -0
  75. package/dist/core/tag.js +25 -0
  76. package/dist/core/tag.js.map +1 -0
  77. package/dist/core/transient.js +40 -0
  78. package/dist/core/transient.js.map +1 -0
  79. package/dist/core/uuid.js +10 -0
  80. package/dist/core/uuid.js.map +1 -0
  81. package/dist/core/wishlist.js +66 -0
  82. package/dist/core/wishlist.js.map +1 -0
  83. package/package.json +42 -4
@@ -0,0 +1,334 @@
1
+ import { Command } from "commander";
2
+ import { AUCTION_LIMIT, CARD_SEARCH_FIELDS, NOTIFICATION_LIMIT, PAGE_LIMIT, addToWishlist, asEntryId, asLabelId, cancelAuction, createAuction, createLabel, deleteLabel, discardEntries, listAuctions, listCollection, listLabels, listNotifications, listRunningBids, listWishlist, loginInBrowser, parseAuctionDuration, parseAuctionId, parseAuctionLimit, parseAuctionSearchPage, parseBidAmount, parseCardId, parseCardSearchField, parsePageLimit, parsePageNumber, parseStartingPrice, placeBid, readCardValues, readProfileCollection, removeFromWishlist, searchAuctions, searchCards, searchGlobalCollection, showAuction, starEntry, tagEntry, unstarEntry, untagEntry, } from "../core/index.js";
3
+ import { loadConfig } from "./config.js";
4
+ import { formatAddition, formatAuction, formatAuctionSearch, formatAuctions, formatBid, formatCancelledAuction, formatCardSearch, formatCardValues, formatCollection, formatCreatedAuction, formatDiscard, formatEntryFavourite, formatEntryTag, formatEntryUntag, formatGlobalCollection, formatLabelCreation, formatLabelDeletion, formatLabels, formatLogin, formatNotifications, formatProfileCollection, formatRemoval, formatRunningBids, formatWishlist, } from "./output.js";
5
+ import { readPastedRefreshToken } from "./pasted-session.js";
6
+ import { openSession } from "./session.js";
7
+ export const program = new Command("wikimasters")
8
+ .description("Interact with WikiMasters")
9
+ .option("--json", "print the result as JSON on stdout")
10
+ .configureHelp({ showGlobalOptions: true });
11
+ const EXAMPLE_AUCTION_ID = "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f";
12
+ const EXAMPLE_CARD_ID = "9b2e4f6a-1c3d-4e5f-8a7b-2c4d6e8f0a1b";
13
+ const OTHER_EXAMPLE_CARD_ID = "0d4f6b8a-3e5c-4a7b-9c1d-5e7f9a1b3c5d";
14
+ const EXAMPLE_ENTRY_ID = "4a7c9e1b-6d2f-4b8a-9e3c-1f5a7b9d2e4c";
15
+ const OTHER_EXAMPLE_ENTRY_ID = "8e2d5a9c-3b7f-4c1e-a6d4-9f3b1e7c5a28";
16
+ const EXAMPLE_LABEL_ID = "0b6c1f5e-2d8a-4f3e-9c41-7a2b9e8d1c34";
17
+ function examples(...calls) {
18
+ return `\nExamples:\n${calls.map((call) => ` $ ${call}`).join("\n")}`;
19
+ }
20
+ function format() {
21
+ return program.opts().json ? "json" : "text";
22
+ }
23
+ function loginInFirefox() {
24
+ console.error("Sign in to WikiMasters in the Firefox window that just opened; it closes once the session is found…");
25
+ return loginInBrowser();
26
+ }
27
+ program
28
+ .command("login")
29
+ .description("Sign in by pasting the session of your browser and store it in $XDG_CONFIG_HOME/wikimasters-cli/.env, ~/.config/wikimasters-cli/.env by default")
30
+ .option("--firefox", "sign in through a Firefox window the command opens instead, on macOS")
31
+ .addHelpText("after", examples("wikimasters login", "wikimasters login --firefox"))
32
+ .action(async ({ firefox }) => {
33
+ loadConfig();
34
+ const session = await openSession(firefox ? await loginInFirefox() : await readPastedRefreshToken());
35
+ console.log(formatLogin(session.userId, format()));
36
+ });
37
+ const auction = program.command("auction").description("Take part in auctions");
38
+ auction
39
+ .command("bid")
40
+ .description("Bid an exact amount on an auction; the game accepts or refuses it and gives its reason")
41
+ .argument("<auction-id>", "auction UUID")
42
+ .argument("<amount>", "wikibidous to bid, a strictly positive integer")
43
+ .addHelpText("after", examples(`wikimasters auction bid ${EXAMPLE_AUCTION_ID} 250`))
44
+ .action(async (rawAuctionId, rawAmount) => {
45
+ const auctionId = parseAuctionId(rawAuctionId);
46
+ const amount = parseBidAmount(rawAmount);
47
+ const session = await openSession();
48
+ console.log(formatBid(await placeBid(session, auctionId, amount), format()));
49
+ });
50
+ auction
51
+ .command("bids")
52
+ .description("Read a page of your bids on running auctions, in the order the game returns them, each with its auction id, card title, amount, date, the current bid, whether you lead and the end time; says when the page is full")
53
+ .option("--page <p>", "page to read, a strictly positive integer", "1")
54
+ .option("--limit <n>", "number of bids per page, an integer sent to the game as given", String(PAGE_LIMIT))
55
+ .addHelpText("after", examples("wikimasters auction bids", "wikimasters auction bids --page 2"))
56
+ .action(async ({ page, limit }) => {
57
+ const request = {
58
+ page: parsePageNumber(page),
59
+ limit: parsePageLimit(limit),
60
+ };
61
+ const result = await listRunningBids(await openSession(), request);
62
+ console.log(formatRunningBids(result, format()));
63
+ });
64
+ auction
65
+ .command("create")
66
+ .description("Put an entry of your collection up for auction at a starting price for a duration; the game accepts or refuses it and gives its reason")
67
+ .argument("<entry-id>", "entry id, as given by collection list")
68
+ .argument("<starting-price>", "wikibidous the bidding starts at, an integer")
69
+ .argument("<duration>", "minutes the auction lasts, an integer")
70
+ .addHelpText("after", examples(`wikimasters auction create ${EXAMPLE_ENTRY_ID} 50 60`))
71
+ .action(async (entryId, rawStartingPrice, rawDuration) => {
72
+ const startingPrice = parseStartingPrice(rawStartingPrice);
73
+ const duration = parseAuctionDuration(rawDuration);
74
+ const session = await openSession();
75
+ console.log(formatCreatedAuction(await createAuction(session, asEntryId(entryId), startingPrice, duration), format()));
76
+ });
77
+ auction
78
+ .command("cancel")
79
+ .description("Cancel one of your auctions so its card returns to your collection; the game accepts or refuses it and gives its reason")
80
+ .argument("<auction-id>", "auction UUID")
81
+ .addHelpText("after", examples(`wikimasters auction cancel ${EXAMPLE_AUCTION_ID}`))
82
+ .action(async (rawAuctionId) => {
83
+ const auctionId = parseAuctionId(rawAuctionId);
84
+ const session = await openSession();
85
+ console.log(formatCancelledAuction(await cancelAuction(session, auctionId), format()));
86
+ });
87
+ auction
88
+ .command("list")
89
+ .description("List auctions in the order the game returns them, with their card, status, end time, starting price, current bid, and whether you lead or sell them")
90
+ .option("--status <status>", "list only the auctions of this status, e.g. active")
91
+ .option("--limit <n>", "maximum number of auctions, a strictly positive integer", String(AUCTION_LIMIT))
92
+ .addHelpText("after", examples("wikimasters auction list --status active --limit 10"))
93
+ .action(async ({ limit, ...filter }) => {
94
+ const maximum = parseAuctionLimit(limit);
95
+ const auctions = await listAuctions(await openSession(), filter, maximum);
96
+ console.log(formatAuctions(auctions, format(), filter.status));
97
+ });
98
+ auction
99
+ .command("search")
100
+ .description("Find the auctions the game matches with the given text, in the order it returns them, with their card, status, end time, starting price, current bid, and whether you lead or sell them")
101
+ .argument("<text...>", "text to search for, as in the marketplace search field")
102
+ .option("--limit <n>", "maximum number of auctions, a strictly positive integer", String(AUCTION_LIMIT))
103
+ .option("--page <p>", "page of results to read, a strictly positive integer", "1")
104
+ .addHelpText("after", examples("wikimasters auction search Half Dome --limit 5", "wikimasters auction search Half Dome --page 2"))
105
+ .action(async (words, { limit, page }) => {
106
+ const maximum = parseAuctionLimit(limit);
107
+ const pageRead = parseAuctionSearchPage(page);
108
+ const session = await openSession();
109
+ const text = words.join(" ");
110
+ const result = await searchAuctions(session, text, maximum, pageRead);
111
+ console.log(formatAuctionSearch(result, format()));
112
+ });
113
+ auction
114
+ .command("show")
115
+ .description("Show an auction's card, status, end time, starting price, current bid, and whether you lead or sell it")
116
+ .argument("<auction-id>", "auction UUID")
117
+ .addHelpText("after", examples(`wikimasters auction show ${EXAMPLE_AUCTION_ID}`))
118
+ .action(async (rawAuctionId) => {
119
+ const auctionId = parseAuctionId(rawAuctionId);
120
+ const session = await openSession();
121
+ console.log(formatAuction(await showAuction(session, auctionId), format()));
122
+ });
123
+ const cards = program.command("cards").description("Browse the card catalogue");
124
+ cards
125
+ .command("search")
126
+ .description("Find the cards of the catalogue whose title, category or summary contains the given text, regardless of case, at most 50, ordered by title")
127
+ .argument("<text...>", "text to search for, e.g. all or part of the title")
128
+ .option("--in <field>", `where to search the text: ${CARD_SEARCH_FIELDS.join(", ")}`, "title")
129
+ .addHelpText("after", examples("wikimasters cards search Half Dome", "wikimasters cards search Karmine --in summary"))
130
+ .action(async (words, { in: rawField }) => {
131
+ const field = parseCardSearchField(rawField);
132
+ const session = await openSession();
133
+ const result = await searchCards(session, words.join(" "), field);
134
+ console.log(formatCardSearch(result, format()));
135
+ });
136
+ cards
137
+ .command("value")
138
+ .description("Show the average sale price of each given card for each rarity it sold under, whether you own it or not; stops at the first card the game refuses")
139
+ .argument("<card-id...>", "card UUIDs")
140
+ .addHelpText("after", examples(`wikimasters cards value ${EXAMPLE_CARD_ID} ${OTHER_EXAMPLE_CARD_ID}`))
141
+ .action(async (rawCardIds) => {
142
+ const cardIds = rawCardIds.map(parseCardId);
143
+ const values = await readCardValues(await openSession(), cardIds);
144
+ console.log(formatCardValues(values, format()));
145
+ });
146
+ function repeated(value, previous = []) {
147
+ return [...previous, value];
148
+ }
149
+ cards
150
+ .command("global")
151
+ .description("Search the Global Collection page of the game, with or without text, and print one page of the cards it finds, whether you own or wish each one, and the friends who own it with their rarities")
152
+ .argument("[text]", "text the game searches in the card title and category")
153
+ .option("--page <n>", "page of results, sent to the game as given; the game counts pages from 0")
154
+ .option("--sort <field>", "sort field, sent to the game as given; the page offers rarity, name, atk and def")
155
+ .option("--rarity <code>", "keep this rarity, sent to the game as given, e.g. R; repeat it for several", repeated)
156
+ .option("--wishlist", "keep only the cards of your wishlist")
157
+ .addHelpText("after", examples('wikimasters cards global "Mont Blanc"', "wikimasters cards global --wishlist", "wikimasters cards global Castaldi --rarity L --rarity UR --sort name --page 1"))
158
+ .action(async (text, { page, sort, rarity, wishlist }) => {
159
+ const session = await openSession();
160
+ const result = await searchGlobalCollection(session, {
161
+ text,
162
+ page,
163
+ sort,
164
+ rarities: rarity,
165
+ wishlist,
166
+ });
167
+ console.log(formatGlobalCollection(result, format()));
168
+ });
169
+ const collection = program
170
+ .command("collection")
171
+ .description("Manage your collection");
172
+ collection
173
+ .command("list")
174
+ .description("Read a page of your collection, earliest obtained first, with each card's entry id, card id, owned rarity, copies, favourite and shiny state, labels and obtention date; says when the page is full")
175
+ .option("--rarity <code>", "list only the cards of this owned rarity: C, PC, R, SR, UR or L")
176
+ .option("--page <p>", "page to read, a strictly positive integer", "1")
177
+ .option("--limit <n>", "number of cards per page, an integer sent to the game as given", String(PAGE_LIMIT))
178
+ .addHelpText("after", examples("wikimasters collection list --rarity C", "wikimasters collection list --page 2"))
179
+ .action(async ({ page, limit, ...filter }) => {
180
+ const request = {
181
+ page: parsePageNumber(page),
182
+ limit: parsePageLimit(limit),
183
+ };
184
+ const result = await listCollection(await openSession(), request, filter);
185
+ console.log(formatCollection(result, format(), filter.rarity));
186
+ });
187
+ collection
188
+ .command("discard")
189
+ .description("Discard the given entries of your collection for 1 wikibidou each, in a single request; exits 1 if the game refused some")
190
+ .argument("<entry-id...>", "entry ids, as given by collection list")
191
+ .addHelpText("after", examples(`wikimasters collection discard ${EXAMPLE_ENTRY_ID} ${OTHER_EXAMPLE_ENTRY_ID}`))
192
+ .action(async (entryIds) => {
193
+ const result = await discardEntries(await openSession(), entryIds.map(asEntryId));
194
+ console.log(formatDiscard(result, format()));
195
+ if (result.failed.length > 0)
196
+ process.exitCode = 1;
197
+ });
198
+ collection
199
+ .command("star")
200
+ .description("Mark an entry of your collection as favourite")
201
+ .argument("<entry-id>", "entry id, as given by collection list")
202
+ .addHelpText("after", examples(`wikimasters collection star ${EXAMPLE_ENTRY_ID}`))
203
+ .action(async (entryId) => {
204
+ const session = await openSession();
205
+ console.log(formatEntryFavourite(await starEntry(session, asEntryId(entryId)), format()));
206
+ });
207
+ collection
208
+ .command("unstar")
209
+ .description("Remove an entry of your collection from the favourites")
210
+ .argument("<entry-id>", "entry id, as given by collection list")
211
+ .addHelpText("after", examples(`wikimasters collection unstar ${EXAMPLE_ENTRY_ID}`))
212
+ .action(async (entryId) => {
213
+ const session = await openSession();
214
+ console.log(formatEntryFavourite(await unstarEntry(session, asEntryId(entryId)), format()));
215
+ });
216
+ collection
217
+ .command("tag")
218
+ .description("Put one of your labels on an entry of your collection")
219
+ .argument("<entry-id>", "entry id, as given by collection list")
220
+ .argument("<label-id>", "label id, as given by labels list")
221
+ .addHelpText("after", examples(`wikimasters collection tag ${EXAMPLE_ENTRY_ID} ${EXAMPLE_LABEL_ID}`))
222
+ .action(async (entryId, labelId) => {
223
+ const session = await openSession();
224
+ console.log(formatEntryTag(await tagEntry(session, asEntryId(entryId), asLabelId(labelId)), format()));
225
+ });
226
+ collection
227
+ .command("untag")
228
+ .description("Remove one of your labels from an entry of your collection; succeeds if the entry does not have it")
229
+ .argument("<entry-id>", "entry id, as given by collection list")
230
+ .argument("<label-id>", "label id, as given by labels list")
231
+ .addHelpText("after", examples(`wikimasters collection untag ${EXAMPLE_ENTRY_ID} ${EXAMPLE_LABEL_ID}`))
232
+ .action(async (entryId, labelId) => {
233
+ const session = await openSession();
234
+ console.log(formatEntryUntag(await untagEntry(session, asEntryId(entryId), asLabelId(labelId)), format()));
235
+ });
236
+ const labels = program.command("labels").description("Manage your labels");
237
+ labels
238
+ .command("list")
239
+ .description("List your labels, ordered by name, with their id and colour")
240
+ .addHelpText("after", examples("wikimasters labels list"))
241
+ .action(async () => {
242
+ console.log(formatLabels(await listLabels(await openSession()), format()));
243
+ });
244
+ labels
245
+ .command("create")
246
+ .description("Create a label and show its id, name and colour")
247
+ .argument("<name>", "label name")
248
+ .option("--color <colour>", "label colour, sent to the game as given")
249
+ .addHelpText("after", examples('wikimasters labels create "Karmine Corp" --color "#1e40af"'))
250
+ .action(async (name, { color }) => {
251
+ const session = await openSession();
252
+ console.log(formatLabelCreation(await createLabel(session, name, color), format()));
253
+ });
254
+ labels
255
+ .command("delete")
256
+ .description("Delete one of your labels, removing it from your cards")
257
+ .argument("<label-id>", "label id, as given by labels list")
258
+ .addHelpText("after", examples(`wikimasters labels delete ${EXAMPLE_LABEL_ID}`))
259
+ .action(async (labelId) => {
260
+ const session = await openSession();
261
+ console.log(formatLabelDeletion(await deleteLabel(session, asLabelId(labelId)), format()));
262
+ });
263
+ const notifications = program
264
+ .command("notifications")
265
+ .description("Read the notifications the game sent you");
266
+ notifications
267
+ .command("list")
268
+ .description("Read a page of your notifications, most recent first, each with its date, type, whether it is unread, message and the other data the game attaches to it, such as the auction, card, player or trade concerned; says when the page is full")
269
+ .option("--type <type>", "keep this type, sent as given, e.g. marketplace_wishlist_listed, marketplace_outbid, marketplace_auction_won, marketplace_auction_sold, marketplace_auction_unsold, friend_request, trade_offer or trade_accepted; repeat to keep several", repeated, [])
270
+ .option("--unread", "keep only the notifications you have not read")
271
+ .option("--after <date>", "keep the notifications received strictly after this date, sent as given, e.g. 2026-10-16T13:31:00.222902+00:00")
272
+ .option("--page <p>", "page to read, a strictly positive integer", "1")
273
+ .option("--limit <n>", "number of notifications per page, an integer sent to the game as given", String(NOTIFICATION_LIMIT))
274
+ .addHelpText("after", examples("wikimasters notifications list", "wikimasters notifications list --type marketplace_wishlist_listed --after 2026-10-16T13:31:00.222902+00:00", "wikimasters notifications list --type marketplace_outbid --type marketplace_auction_won --unread", "wikimasters notifications list --limit 10 --page 2"))
275
+ .action(async ({ type, page, limit, ...filter }) => {
276
+ const request = {
277
+ page: parsePageNumber(page),
278
+ limit: parsePageLimit(limit),
279
+ };
280
+ const result = await listNotifications(await openSession(), { types: type, ...filter }, request);
281
+ console.log(formatNotifications(result, format()));
282
+ });
283
+ const profile = program
284
+ .command("profile")
285
+ .description("Look at other players' profiles");
286
+ profile
287
+ .command("collection")
288
+ .description("Read a page of a player's collection, at most 50 entries, in the game's order, with each entry's id, card id, title, owned rarity, copies, favourite and shiny state, labels and whether a pending trade holds the card")
289
+ .argument("<pseudo>", "the player's pseudo, as the game shows it")
290
+ .option("--page <n>", "page to read, sent to the game as given; the game numbers pages from 0", "0")
291
+ .option("--sort <field>", "order sent to the game as given, e.g. rarity, name or added")
292
+ .option("--search <text>", "text the game searches for, sent as given")
293
+ .option("--rarity <code>", "keep this owned rarity, sent as given, e.g. SR; repeat to keep several", repeated, [])
294
+ .option("--wishlisted", "keep only the cards of your wishlist")
295
+ .addHelpText("after", examples("wikimasters profile collection LucasPerso", "wikimasters profile collection LucasPerso --rarity UR --rarity L --page 1", "wikimasters profile collection LucasPerso --sort name", 'wikimasters profile collection LucasPerso --search "Half Dome" --wishlisted'))
296
+ .action(async (pseudo, { rarity, ...query }) => {
297
+ const session = await openSession();
298
+ const result = await readProfileCollection(session, pseudo, {
299
+ ...query,
300
+ rarities: rarity,
301
+ });
302
+ console.log(formatProfileCollection(result, format()));
303
+ });
304
+ const wishlist = program
305
+ .command("wishlist")
306
+ .description("Manage your wishlist");
307
+ wishlist
308
+ .command("list")
309
+ .description("List the cards of your wishlist, most recently added first, marking those already in your collection")
310
+ .addHelpText("after", examples("wikimasters wishlist list"))
311
+ .action(async () => {
312
+ console.log(formatWishlist(await listWishlist(await openSession()), format()));
313
+ });
314
+ wishlist
315
+ .command("add")
316
+ .description("Add a card of the catalogue to your wishlist; succeeds if the card is already there")
317
+ .argument("<card-id>", "card UUID")
318
+ .addHelpText("after", examples(`wikimasters wishlist add ${EXAMPLE_CARD_ID}`))
319
+ .action(async (rawCardId) => {
320
+ const cardId = parseCardId(rawCardId);
321
+ const session = await openSession();
322
+ console.log(formatAddition(await addToWishlist(session, cardId), format()));
323
+ });
324
+ wishlist
325
+ .command("remove")
326
+ .description("Remove a card from your wishlist; succeeds if the card is already absent")
327
+ .argument("<card-id>", "card UUID")
328
+ .addHelpText("after", examples(`wikimasters wishlist remove ${EXAMPLE_CARD_ID}`))
329
+ .action(async (rawCardId) => {
330
+ const cardId = parseCardId(rawCardId);
331
+ const session = await openSession();
332
+ console.log(formatRemoval(await removeFromWishlist(session, cardId), format()));
333
+ });
334
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,WAAW,EACX,SA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;KACL,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CACV,qFAAqF,CACtF;KACA,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;KAClC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,4BAA4B,eAAe,EAAE,CAAC,CAAC;KAC7E,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,EAAE;IAClC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,MAAM,WAAW,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEL,QAAQ;KACL,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CACV,0EAA0E,CAC3E;KACA,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;KAClC,WAAW,CACV,OAAO,EACP,QAAQ,CAAC,+BAA+B,eAAe,EAAE,CAAC,CAC3D;KACA,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,EAAE;IAClC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,MAAM,WAAW,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CACT,aAAa,CAAC,MAAM,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CACnE,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { ApiUnavailableError, AuthRequiredError, resumeSession, } from "../core/index.js";
2
+ import { loadConfig, requireRefreshToken, saveRefreshToken } from "./config.js";
3
+ const EXIT_AUTH_REQUIRED = 4;
4
+ const EXIT_TEMPORARY_FAILURE = 75;
5
+ const LOGIN_COMMAND = "wikimasters login";
6
+ export async function openSession(refreshToken) {
7
+ const config = loadConfig();
8
+ const session = await resumeSession({
9
+ anonKey: config.anonKey,
10
+ refreshToken: refreshToken ?? requireRefreshToken(config),
11
+ });
12
+ saveRefreshToken(session.refreshToken);
13
+ return session;
14
+ }
15
+ function failureMessage(error) {
16
+ if (error instanceof AuthRequiredError) {
17
+ return `${error.message}: run \`${LOGIN_COMMAND}\``;
18
+ }
19
+ return error instanceof Error ? error.message : String(error);
20
+ }
21
+ export function reportFailure(command, error) {
22
+ console.error(`${command}: ${failureMessage(error)}`);
23
+ process.exitCode =
24
+ error instanceof AuthRequiredError
25
+ ? EXIT_AUTH_REQUIRED
26
+ : error instanceof ApiUnavailableError
27
+ ? EXIT_TEMPORARY_FAILURE
28
+ : 1;
29
+ }
30
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/cli/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhF,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,YAAqB;IACrD,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,YAAY,EAAE,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC;KAC1D,CAAC,CAAC;IACH,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;QACvC,OAAO,GAAG,KAAK,CAAC,OAAO,WAAW,aAAa,IAAI,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,KAAc;IAC3D,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,KAAK,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,QAAQ;QACd,KAAK,YAAY,iBAAiB;YAChC,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,KAAK,YAAY,mBAAmB;gBACpC,CAAC,CAAC,sBAAsB;gBACxB,CAAC,CAAC,CAAC,CAAC;AACZ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { auctionedTitle, leads, } from "./auction.js";
2
+ import { apiFailure } from "./errors.js";
3
+ import { isFullPage, pageRange } from "./page.js";
4
+ export async function listRunningBids(session, request) {
5
+ const [from, to] = pageRange(request);
6
+ const { data, error, status } = await session.client
7
+ .from("auction_bids")
8
+ .select("auction_id, amount, placed_at, auctions!inner(end_at, current_bid, current_bidder_id, cards(wikipedia_title))")
9
+ .eq("bidder_id", session.userId)
10
+ .eq("auctions.status", "active")
11
+ .gt("auctions.end_at", new Date().toISOString())
12
+ .order("placed_at")
13
+ .order("id")
14
+ .range(from, to)
15
+ .overrideTypes();
16
+ if (error)
17
+ throw apiFailure("Listing your bids", status, error.message);
18
+ return {
19
+ bids: data.map(({ auction_id, amount, placed_at, auctions: auction }) => ({
20
+ auctionId: auction_id,
21
+ title: auctionedTitle(auction_id, auction),
22
+ amount,
23
+ placedAt: placed_at,
24
+ currentBid: auction.current_bid,
25
+ leading: leads(session, auction),
26
+ endsAt: auction.end_at,
27
+ })),
28
+ full: isFullPage(data, request.limit),
29
+ };
30
+ }
31
+ //# sourceMappingURL=auction-bids.js.map
@@ -0,0 +1 @@
1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AW;YAC/B,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { WikiMastersError } from "./errors.js";
2
+ import { siteCookie, siteRequest } from "./site.js";
3
+ function isCancelledAuctionResponse(body) {
4
+ return (typeof body === "object" &&
5
+ body !== null &&
6
+ "status" in body &&
7
+ typeof body.status === "string");
8
+ }
9
+ export async function cancelAuction(session, auctionId) {
10
+ const action = `Cancelling auction ${auctionId}`;
11
+ const body = await siteRequest(session, await siteCookie(session), action, `/marketplace/${auctionId}`, `/api/marketplace/${auctionId}`, { method: "DELETE" });
12
+ if (!isCancelledAuctionResponse(body)) {
13
+ throw new WikiMastersError(`${action} returned an unexpected response, which may have cancelled it: ${JSON.stringify(body)}`);
14
+ }
15
+ return { auctionId, status: body.status };
16
+ }
17
+ //# sourceMappingURL=auction-cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-cancel.js","sourceRoot":"","sources":["../../src/core/auction-cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAWpD,SAAS,0BAA0B,CACjC,IAAa;IAEb,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,QAAQ,IAAI,IAAI;QAChB,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,SAAoB;IAEpB,MAAM,MAAM,GAAG,sBAAsB,SAAS,EAAE,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,WAAW,CAC5B,OAAO,EACP,MAAM,UAAU,CAAC,OAAO,CAAC,EACzB,MAAM,EACN,gBAAgB,SAAS,EAAE,EAC3B,oBAAoB,SAAS,EAAE,EAC/B,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB,CAAC;IACF,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,gBAAgB,CACxB,GAAG,MAAM,kEAAkE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAClG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { COLLECTION_PAGE } from "./collection.js";
2
+ import { WikiMastersError } from "./errors.js";
3
+ import { parseInteger } from "./integer.js";
4
+ import { siteCookie, siteRequest } from "./site.js";
5
+ export function parseStartingPrice(raw) {
6
+ return parseInteger(raw, {
7
+ subject: "starting price",
8
+ unit: "wikibidous",
9
+ untouched: "nothing was put up for auction",
10
+ });
11
+ }
12
+ export function parseAuctionDuration(raw) {
13
+ return parseInteger(raw, {
14
+ subject: "duration",
15
+ unit: "minutes",
16
+ untouched: "nothing was put up for auction",
17
+ });
18
+ }
19
+ function isCreatedAuctionResponse(body) {
20
+ return (typeof body === "object" &&
21
+ body !== null &&
22
+ "auction_id" in body &&
23
+ typeof body.auction_id === "string");
24
+ }
25
+ export async function createAuction(session, entryId, startingPrice, duration) {
26
+ const action = `Putting entry ${entryId} up for auction`;
27
+ const body = await siteRequest(session, await siteCookie(session), action, COLLECTION_PAGE, "/api/marketplace", {
28
+ method: "POST",
29
+ body: {
30
+ card_id: entryId,
31
+ base_amount: startingPrice,
32
+ duration_minutes: duration,
33
+ },
34
+ });
35
+ if (!isCreatedAuctionResponse(body)) {
36
+ throw new WikiMastersError(`${action} returned an unexpected response, which may have put it up for auction: ${JSON.stringify(body)}`);
37
+ }
38
+ return { auctionId: body.auction_id };
39
+ }
40
+ //# sourceMappingURL=auction-create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-create.js","sourceRoot":"","sources":["../../src/core/auction-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAcpD,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,OAAO,YAAY,CAAC,GAAG,EAAE;QACvB,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE,gCAAgC;KAC5C,CAAkB,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,YAAY,CAAC,GAAG,EAAE;QACvB,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,gCAAgC;KAC5C,CAAoB,CAAC;AACxB,CAAC;AAED,SAAS,wBAAwB,CAC/B,IAAa;IAEb,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,YAAY,IAAI,IAAI;QACpB,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,OAAgB,EAChB,aAA4B,EAC5B,QAAyB;IAEzB,MAAM,MAAM,GAAG,iBAAiB,OAAO,iBAAiB,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,WAAW,CAC5B,OAAO,EACP,MAAM,UAAU,CAAC,OAAO,CAAC,EACzB,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB;QACE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,aAAa;YAC1B,gBAAgB,EAAE,QAAQ;SAC3B;KACF,CACF,CAAC;IACF,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,gBAAgB,CACxB,GAAG,MAAM,2EAA2E,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC3G,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,UAAuB,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { AUCTION_COLUMNS, toAuction, } from "./auction.js";
2
+ import { apiFailure } from "./errors.js";
3
+ export async function listAuctions(session, { status }, limit) {
4
+ const query = session.client
5
+ .from("auctions")
6
+ .select(`id, ${AUCTION_COLUMNS}`)
7
+ .limit(limit);
8
+ const { data, error, status: httpStatus, } = await (status === undefined
9
+ ? query
10
+ : query.eq("status", status)).overrideTypes();
11
+ if (error) {
12
+ throw apiFailure("Listing the auctions", httpStatus, error.message);
13
+ }
14
+ return data.map((row) => toAuction(session, row.id, row));
15
+ }
16
+ //# sourceMappingURL=auction-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-list.js","sourceRoot":"","sources":["../../src/core/auction-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,GAKV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASzC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAgB,EAChB,EAAE,MAAM,EAAiB,EACzB,KAAmB;IAEnB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM;SACzB,IAAI,CAAC,UAAU,CAAC;SAChB,MAAM,CAAC,OAAO,eAAe,EAAE,CAAC;SAChC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChB,MAAM,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EAAE,UAAU,GACnB,GAAG,MAAM,CAAC,MAAM,KAAK,SAAS;QAC7B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAC7B,CAAC,aAAa,EAAwC,CAAC;IACxD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,UAAU,CAAC,sBAAsB,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { toAuction, } from "./auction.js";
2
+ import { WikiMastersError } from "./errors.js";
3
+ import { parseStrictlyPositiveInteger } from "./integer.js";
4
+ import { siteCookie, siteRequest } from "./site.js";
5
+ export function parseAuctionSearchPage(raw) {
6
+ return parseStrictlyPositiveInteger(raw, {
7
+ subject: "page",
8
+ untouched: "nothing was read",
9
+ });
10
+ }
11
+ function isMarketplaceResponse(body) {
12
+ return (typeof body === "object" &&
13
+ body !== null &&
14
+ "auctions" in body &&
15
+ Array.isArray(body.auctions) &&
16
+ "hasMore" in body &&
17
+ typeof body.hasMore === "boolean");
18
+ }
19
+ export async function searchAuctions(session, text, limit, page) {
20
+ const action = "Searching the auctions";
21
+ const query = new URLSearchParams({
22
+ page: String(page),
23
+ limit: String(limit),
24
+ sort: "recent",
25
+ });
26
+ const trimmed = text.trim();
27
+ if (trimmed)
28
+ query.set("q", trimmed);
29
+ const body = await siteRequest(session, await siteCookie(session), action, "/marketplace", `/api/marketplace?${query}`, { method: "GET" });
30
+ if (!isMarketplaceResponse(body)) {
31
+ throw new WikiMastersError(`${action} returned an unexpected response: ${JSON.stringify(body)}`);
32
+ }
33
+ return {
34
+ auctions: body.auctions.map(({ id, card, ...row }) => toAuction(session, id, { ...row, cards: card })),
35
+ truncated: body.hasMore,
36
+ };
37
+ }
38
+ //# sourceMappingURL=auction-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-search.js","sourceRoot":"","sources":["../../src/core/auction-search.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAKV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMpD,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,4BAA4B,CAAC,GAAG,EAAE;QACvC,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,kBAAkB;KAC9B,CAAsB,CAAC;AAC1B,CAAC;AAiBD,SAAS,qBAAqB,CAAC,IAAa;IAC1C,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,UAAU,IAAI,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC5B,SAAS,IAAI,IAAI;QACjB,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAgB,EAChB,IAAY,EACZ,KAAmB,EACnB,IAAuB;IAEvB,MAAM,MAAM,GAAG,wBAAwB,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;QACpB,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,OAAO;QAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,WAAW,CAC5B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