polytown 0.1.6 → 0.1.7

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/dist/index.js +45 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -129,7 +129,10 @@ var GammaClient = class {
129
129
  return fetchJson(buildUrl(this.baseUrl, "/tags", params));
130
130
  }
131
131
  async getTag(idOrSlug) {
132
- return fetchJson(buildUrl(this.baseUrl, `/tags/${idOrSlug}`));
132
+ if (/^\d+$/.test(idOrSlug)) {
133
+ return fetchJson(buildUrl(this.baseUrl, `/tags/${idOrSlug}`));
134
+ }
135
+ return fetchJson(buildUrl(this.baseUrl, `/tags/slug/${idOrSlug}`));
133
136
  }
134
137
  async getRelated(idOrSlug) {
135
138
  return fetchJson(buildUrl(this.baseUrl, `/tags/${idOrSlug}/related`));
@@ -238,11 +241,14 @@ marketsCommand.command("list").description("List markets").option("--full", "Out
238
241
  description: m.description,
239
242
  outcomes: m.outcomes,
240
243
  outcomePrices: m.outcomePrices,
244
+ active: m.active,
241
245
  closed: m.closed,
242
246
  endDate: m.endDate,
243
247
  volume: m.volumeNum || m.volume,
244
248
  volume24hr: m.volume24hr,
245
- image: m.image
249
+ lastTradePrice: m.lastTradePrice,
250
+ oneWeekPriceChange: m.oneWeekPriceChange,
251
+ ...opts.includeTag && m.tags ? { tags: m.tags } : {}
246
252
  }));
247
253
  console.log(JSON.stringify(simplified, null, 2));
248
254
  }
@@ -263,7 +269,7 @@ import { Command as Command3 } from "commander";
263
269
  var eventsCommand = new Command3("events").description(
264
270
  "Events commands"
265
271
  );
266
- eventsCommand.command("list").description("List events").option("--full", "Output full format (default: simplified)").option("--active", "Only active events").option("--closed", "Only closed events").option("--archived", "Include archived events").option("--featured", "Only featured events").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by event IDs (comma-separated)").option("--tag <tag>", "Filter by tag slug").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--exclude-tag-id <ids>", "Exclude tag IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--related-tags", "Include related tags").option("--recurrence <pattern>", "Filter by recurrence pattern").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").action(async (opts) => {
272
+ eventsCommand.command("list").description("List events").option("--full", "Output full format (default: simplified)").option("--active", "Only active events").option("--closed", "Only closed events").option("--archived", "Include archived events").option("--featured", "Only featured events").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by event IDs (comma-separated)").option("--tag <tag>", "Filter by tag slug").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--exclude-tag-id <ids>", "Exclude tag IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--related-tags", "Include related tags").option("--include-tag", "Include tag data").option("--recurrence <pattern>", "Filter by recurrence pattern").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").action(async (opts) => {
267
273
  const gamma = new GammaClient();
268
274
  const params = {
269
275
  active: opts.active ?? true,
@@ -282,6 +288,7 @@ eventsCommand.command("list").description("List events").option("--full", "Outpu
282
288
  if (opts.excludeTagId) params.exclude_tag_id = opts.excludeTagId.split(",");
283
289
  if (opts.slug) params.slug = opts.slug;
284
290
  if (opts.relatedTags) params.related_tags = true;
291
+ if (opts.includeTag) params.include_tag = true;
285
292
  if (opts.recurrence) params.recurrence = opts.recurrence;
286
293
  if (opts.liquidityMin) params.liquidity_min = opts.liquidityMin;
287
294
  if (opts.liquidityMax) params.liquidity_max = opts.liquidityMax;
@@ -303,7 +310,24 @@ eventsCommand.command("list").description("List events").option("--full", "Outpu
303
310
  closed: e.closed,
304
311
  endDate: e.endDate,
305
312
  volume: e.volume,
306
- markets: e.markets?.length || 0
313
+ ...opts.includeTag && e.tags ? { tags: e.tags } : {},
314
+ markets: (e.markets || []).map((m) => ({
315
+ id: m.id,
316
+ question: m.question,
317
+ slug: m.slug,
318
+ conditionId: m.conditionId,
319
+ clobTokenIds: m.clobTokenIds,
320
+ outcomes: m.outcomes,
321
+ outcomePrices: m.outcomePrices,
322
+ active: m.active,
323
+ closed: m.closed,
324
+ endDate: m.endDate,
325
+ volume: m.volumeNum || m.volume,
326
+ volume24hr: m.volume24hr,
327
+ liquidity: m.liquidityNum || m.liquidity,
328
+ lastTradePrice: m.lastTradePrice,
329
+ oneWeekPriceChange: m.oneWeekPriceChange
330
+ }))
307
331
  }));
308
332
  console.log(JSON.stringify(simplified, null, 2));
309
333
  }
@@ -317,10 +341,24 @@ eventsCommand.command("get <id_or_slug>").description("Get event by ID or slug")
317
341
  // src/commands/tags.ts
318
342
  import { Command as Command4 } from "commander";
319
343
  var tagsCommand = new Command4("tags").description("Tags commands");
320
- tagsCommand.command("list").description("List tags").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--ascending", "Sort ascending").action(async (opts) => {
344
+ tagsCommand.command("list").description("List tags").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--ascending", "Sort ascending").option("--search <query>", "Search tags by label or slug").action(async (opts) => {
321
345
  const gamma = new GammaClient();
322
- const result = await gamma.getTags(opts);
323
- console.log(JSON.stringify(result, null, 2));
346
+ if (opts.search) {
347
+ const query = opts.search.toLowerCase();
348
+ const all = [];
349
+ for (let offset = 0; ; offset += 300) {
350
+ const batch = await gamma.getTags({ limit: 300, offset });
351
+ all.push(...batch);
352
+ if (batch.length < 300) break;
353
+ }
354
+ const matched = all.filter(
355
+ (t) => t.label?.toLowerCase().includes(query) || t.slug?.toLowerCase().includes(query)
356
+ );
357
+ console.log(JSON.stringify(matched, null, 2));
358
+ } else {
359
+ const result = await gamma.getTags(opts);
360
+ console.log(JSON.stringify(result, null, 2));
361
+ }
324
362
  });
325
363
  tagsCommand.command("get <id_or_slug>").description("Get tag by ID or slug").action(async (idOrSlug) => {
326
364
  const gamma = new GammaClient();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polytown",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polytown": "./dist/index.js"