teleton 0.2.0 → 0.2.3

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/dist/cli/index.js CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  saveWallet,
18
18
  validateApiKeyFormat,
19
19
  walletExists
20
- } from "../chunk-QVTQORZB.js";
20
+ } from "../chunk-KU4Z3TYC.js";
21
+ import "../chunk-DUW5VBAZ.js";
21
22
  import "../chunk-OQGNS2FV.js";
22
23
  import "../chunk-TBIMVWQZ.js";
23
24
  import {
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  TonnetApp,
3
3
  main
4
- } from "./chunk-QVTQORZB.js";
4
+ } from "./chunk-KU4Z3TYC.js";
5
+ import "./chunk-DUW5VBAZ.js";
5
6
  import "./chunk-OQGNS2FV.js";
6
7
  import "./chunk-TBIMVWQZ.js";
7
8
  import "./chunk-WMIN6AGX.js";
@@ -1,3 +1,11 @@
1
+ import {
2
+ addPriceHistory,
3
+ getCollectionId,
4
+ getScraperStats,
5
+ initScraperDb,
6
+ upsertCollection,
7
+ upsertModel
8
+ } from "./chunk-DUW5VBAZ.js";
1
9
  import {
2
10
  MARKETAPP_BASE_URL
3
11
  } from "./chunk-WMIN6AGX.js";
@@ -19,136 +27,11 @@ import {
19
27
  SCRAPER_SCROLL_PADDING_PX,
20
28
  SCRAPER_SCROLL_STEP_MS
21
29
  } from "./chunk-LJXYESJJ.js";
22
- import {
23
- TELETON_ROOT
24
- } from "./chunk-EYWNOHMJ.js";
30
+ import "./chunk-EYWNOHMJ.js";
25
31
  import "./chunk-QGM4M3NI.js";
26
32
 
27
33
  // src/market/scraper.ts
28
34
  import { chromium } from "playwright";
29
-
30
- // src/market/scraper-db.ts
31
- import Database from "better-sqlite3";
32
- import { join } from "path";
33
- var DB_PATH = join(TELETON_ROOT, "gifts.db");
34
- function initScraperDb() {
35
- const db = new Database(DB_PATH);
36
- db.pragma("journal_mode = WAL");
37
- db.exec(`
38
- -- Gift collections (Plush Pepes, Heart Lockets, etc.)
39
- CREATE TABLE IF NOT EXISTS gift_collections (
40
- id INTEGER PRIMARY KEY AUTOINCREMENT,
41
- address TEXT UNIQUE NOT NULL,
42
- name TEXT NOT NULL,
43
- floor_ton REAL,
44
- floor_usd REAL,
45
- volume_7d REAL,
46
- listed_count INTEGER,
47
- owners INTEGER,
48
- supply INTEGER,
49
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
50
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
51
- );
52
-
53
- -- Models per collection (Cozy Galaxy, Milano, etc.)
54
- CREATE TABLE IF NOT EXISTS gift_models (
55
- id INTEGER PRIMARY KEY AUTOINCREMENT,
56
- collection_id INTEGER NOT NULL,
57
- name TEXT NOT NULL,
58
- floor_ton REAL,
59
- rarity_percent REAL,
60
- count INTEGER,
61
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
62
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
63
- FOREIGN KEY (collection_id) REFERENCES gift_collections(id),
64
- UNIQUE(collection_id, name)
65
- );
66
-
67
- -- Price history (for trends)
68
- CREATE TABLE IF NOT EXISTS price_history (
69
- id INTEGER PRIMARY KEY AUTOINCREMENT,
70
- collection_id INTEGER,
71
- model_id INTEGER,
72
- floor_ton REAL NOT NULL,
73
- floor_usd REAL,
74
- timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
75
- FOREIGN KEY (collection_id) REFERENCES gift_collections(id),
76
- FOREIGN KEY (model_id) REFERENCES gift_models(id)
77
- );
78
-
79
- -- Indexes for frequent queries
80
- CREATE INDEX IF NOT EXISTS idx_price_history_collection ON price_history(collection_id, timestamp);
81
- CREATE INDEX IF NOT EXISTS idx_price_history_model ON price_history(model_id, timestamp);
82
- CREATE INDEX IF NOT EXISTS idx_models_collection ON gift_models(collection_id);
83
- `);
84
- return db;
85
- }
86
- function upsertCollection(db, collection) {
87
- const stmt = db.prepare(`
88
- INSERT INTO gift_collections (address, name, floor_ton, floor_usd, volume_7d, updated_at)
89
- VALUES (@address, @name, @floor_ton, @floor_usd, @volume_7d, CURRENT_TIMESTAMP)
90
- ON CONFLICT(address) DO UPDATE SET
91
- name = @name,
92
- floor_ton = @floor_ton,
93
- floor_usd = @floor_usd,
94
- volume_7d = @volume_7d,
95
- updated_at = CURRENT_TIMESTAMP
96
- RETURNING id
97
- `);
98
- const result = stmt.get({
99
- address: collection.address,
100
- name: collection.name,
101
- floor_ton: collection.floorTON || null,
102
- floor_usd: collection.floorUSD || null,
103
- volume_7d: collection.volume7d || null
104
- });
105
- return result.id;
106
- }
107
- function getCollectionId(db, address) {
108
- const row = db.prepare(`SELECT id FROM gift_collections WHERE address = ?`).get(address);
109
- return row?.id ?? null;
110
- }
111
- function upsertModel(db, collectionId, model) {
112
- const stmt = db.prepare(`
113
- INSERT INTO gift_models (collection_id, name, floor_ton, rarity_percent, count, updated_at)
114
- VALUES (@collection_id, @name, @floor_ton, @rarity_percent, @count, CURRENT_TIMESTAMP)
115
- ON CONFLICT(collection_id, name) DO UPDATE SET
116
- floor_ton = @floor_ton,
117
- rarity_percent = @rarity_percent,
118
- count = @count,
119
- updated_at = CURRENT_TIMESTAMP
120
- RETURNING id
121
- `);
122
- const result = stmt.get({
123
- collection_id: collectionId,
124
- name: model.name,
125
- floor_ton: model.floor || null,
126
- rarity_percent: model.pct ? parseFloat(model.pct) : null,
127
- count: model.count || null
128
- });
129
- return result.id;
130
- }
131
- function addPriceHistory(db, collectionId, modelId, floorTon, floorUsd = null) {
132
- const stmt = db.prepare(`
133
- INSERT INTO price_history (collection_id, model_id, floor_ton, floor_usd)
134
- VALUES (?, ?, ?, ?)
135
- `);
136
- stmt.run(collectionId, modelId, floorTon, floorUsd);
137
- }
138
- function getScraperStats(db) {
139
- const collections = db.prepare("SELECT COUNT(*) as count FROM gift_collections").get();
140
- const models = db.prepare("SELECT COUNT(*) as count FROM gift_models").get();
141
- const history = db.prepare("SELECT COUNT(*) as count FROM price_history").get();
142
- const lastUpdate = db.prepare("SELECT MAX(updated_at) as last FROM gift_collections").get();
143
- return {
144
- collections: collections.count,
145
- models: models.count,
146
- historyEntries: history.count,
147
- lastUpdate: lastUpdate.last
148
- };
149
- }
150
-
151
- // src/market/scraper.ts
152
35
  async function scrapeAllModels(page, collection, db) {
153
36
  try {
154
37
  const url = `${MARKETAPP_BASE_URL}/collection/${collection.address}/?tab=nfts`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleton",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Personal AI Agent for Telegram",
5
5
  "author": "ZKProof (https://t.me/zkproof)",
6
6
  "license": "MIT",