mcp-scraper 0.88.2 → 0.89.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 (87) hide show
  1. package/CHANGELOG.md +36 -15
  2. package/README.md +6 -5
  3. package/THIRD_PARTY_NOTICES.html +203 -0
  4. package/dist/analytics-repository-2BMT5JNE.js +1 -0
  5. package/dist/bin/api-server.js +2 -41
  6. package/dist/bin/mcp-scraper-cli.js +39 -756
  7. package/dist/bin/mcp-scraper-core.js +1 -60
  8. package/dist/bin/mcp-scraper-install.js +2 -25
  9. package/dist/bin/mcp-stdio-server.js +1 -19
  10. package/dist/bin/paa-harvest.js +1 -41
  11. package/dist/chunk-3GP5CYZX.js +1 -0
  12. package/dist/chunk-4AI7DOS7.js +59 -0
  13. package/dist/chunk-4FROKQJN.js +1 -0
  14. package/dist/chunk-7YGVI5J4.js +21710 -0
  15. package/dist/chunk-CCYWSJNG.js +16 -0
  16. package/dist/chunk-CFI6CXIV.js +182 -0
  17. package/dist/chunk-E2WRWV3A.js +1 -0
  18. package/dist/chunk-GMWKPIYX.js +1172 -0
  19. package/dist/chunk-HDPYG3XV.js +102 -0
  20. package/dist/chunk-HE45FFBU.js +1 -0
  21. package/dist/chunk-HUV2WTRW.js +1 -0
  22. package/dist/chunk-KJQXUZ4Y.js +4 -0
  23. package/dist/chunk-L4CGLFPU.js +4 -0
  24. package/dist/chunk-M22MM4N4.js +84 -0
  25. package/dist/chunk-MASR22K4.js +73 -0
  26. package/dist/chunk-MZN4U5BL.js +1 -0
  27. package/dist/chunk-PUHFVA7P.js +1280 -0
  28. package/dist/chunk-QPWPR5XG.js +10 -0
  29. package/dist/chunk-TMB56NCA.js +1 -0
  30. package/dist/chunk-TXENITMS.js +20 -0
  31. package/dist/chunk-W2BVJ7S2.js +13 -0
  32. package/dist/chunk-WO3N5FH2.js +5 -0
  33. package/dist/chunk-WSCGYRWA.js +2595 -0
  34. package/dist/chunk-X54CQLK2.js +1 -0
  35. package/dist/chunk-XLWNEVUZ.js +27 -0
  36. package/dist/chunk-XPZVJIZ2.js +100 -0
  37. package/dist/chunk-YQZGZBB4.js +1 -0
  38. package/dist/chunk-Z2QGQJS2.js +1 -0
  39. package/dist/db-F2MX63GI.js +1 -0
  40. package/dist/extract-bundle-SNUIHM3J.js +26 -0
  41. package/dist/gmail-service-BZ3H75XC.js +1 -0
  42. package/dist/index.cjs +21750 -6045
  43. package/dist/index.d.cts +14 -14
  44. package/dist/index.d.ts +14 -14
  45. package/dist/index.js +18 -315
  46. package/dist/lead-list-enrichment-repository-S2H3U7T7.js +1 -0
  47. package/dist/location-data-repository-OTWHWMV6.js +1 -0
  48. package/dist/server-RFR2A5UJ.js +7303 -0
  49. package/dist/site-extract-repository-SE776XDC.js +1 -0
  50. package/dist/worker-XUDSM3AL.js +1 -0
  51. package/package.json +17 -124
  52. package/dist/analytics-repository-GGJJCVVP.js +0 -194
  53. package/dist/chunk-4QMUF6XM.js +0 -1013
  54. package/dist/chunk-6HAV7LCE.js +0 -265
  55. package/dist/chunk-ABF2CGOZ.js +0 -113
  56. package/dist/chunk-C5Z4OFKW.js +0 -404
  57. package/dist/chunk-DNM65UCK.js +0 -299
  58. package/dist/chunk-EQGTEHLZ.js +0 -592
  59. package/dist/chunk-F5GQJWZU.js +0 -732
  60. package/dist/chunk-GGZEC22A.js +0 -215
  61. package/dist/chunk-GXBZXWXB.js +0 -184
  62. package/dist/chunk-IHXAXYIS.js +0 -843
  63. package/dist/chunk-K3Z5AQYE.js +0 -683
  64. package/dist/chunk-K45K75OF.js +0 -6
  65. package/dist/chunk-LFW2FRPJ.js +0 -224
  66. package/dist/chunk-MZDNZQWT.js +0 -2078
  67. package/dist/chunk-NVUKO5NN.js +0 -256
  68. package/dist/chunk-OM7HVEJ3.js +0 -26
  69. package/dist/chunk-OPQIGAFB.js +0 -286
  70. package/dist/chunk-OZJMVCDK.js +0 -16
  71. package/dist/chunk-P7FWOMU7.js +0 -505
  72. package/dist/chunk-PGJQDMC2.js +0 -383
  73. package/dist/chunk-PKZS6SHW.js +0 -33139
  74. package/dist/chunk-RJ7JVYKU.js +0 -68
  75. package/dist/chunk-S24LFPL7.js +0 -5262
  76. package/dist/chunk-T3MZISOF.js +0 -240
  77. package/dist/chunk-UZPTGUDV.js +0 -1915
  78. package/dist/chunk-X623GTBV.js +0 -8290
  79. package/dist/chunk-YXNDOQXN.js +0 -4018
  80. package/dist/db-Z34LPZNR.js +0 -284
  81. package/dist/extract-bundle-565SBZCR.js +0 -1003
  82. package/dist/gmail-service-E6ALS7JG.js +0 -25
  83. package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
  84. package/dist/location-data-repository-WPRG62GE.js +0 -34
  85. package/dist/server-SQZ3A7SY.js +0 -86606
  86. package/dist/site-extract-repository-VYFZASPU.js +0 -69
  87. package/dist/worker-LDCAULWL.js +0 -146
@@ -1,240 +0,0 @@
1
- // src/api/connected-data-artifacts.ts
2
- import { createHash, randomUUID } from "crypto";
3
- import { mkdir, readFile, stat, writeFile } from "fs/promises";
4
- import { homedir } from "os";
5
- import { dirname, join } from "path";
6
- var CONNECTED_DATA_ARTIFACT_PREFIX = "connected-data-exports/";
7
- var CONNECTED_DATA_ARTIFACT_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
8
- var CONNECTED_DATA_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
9
- function privateBlobToken() {
10
- return process.env.CONNECTED_DATA_READ_WRITE_TOKEN?.trim() || process.env.CONNECTED_DATA_BLOB_READ_WRITE_TOKEN?.trim() || null;
11
- }
12
- function localBaseDir() {
13
- return process.env.MCP_SCRAPER_OUTPUT_DIR?.trim() || join(homedir(), "Downloads", "mcp-scraper");
14
- }
15
- function isHosted() {
16
- return process.env.VERCEL === "1" || process.env.NODE_ENV === "production";
17
- }
18
- function safeFilename(value) {
19
- const safe = value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
20
- return (safe || "connected-data-export").slice(0, 120);
21
- }
22
- function artifactTimestamp(artifactId) {
23
- if (!artifactId.startsWith(CONNECTED_DATA_ARTIFACT_PREFIX)) return null;
24
- const filename = artifactId.split("/").at(-1) ?? "";
25
- const match = filename.match(/^(\d{13})-/);
26
- if (!match) return null;
27
- const timestamp = Number(match[1]);
28
- return Number.isFinite(timestamp) ? timestamp : null;
29
- }
30
- function connectedDataArtifactOwnerId(artifactId) {
31
- if (!artifactId.startsWith(CONNECTED_DATA_ARTIFACT_PREFIX)) return null;
32
- const rest = artifactId.slice(CONNECTED_DATA_ARTIFACT_PREFIX.length);
33
- const owner = rest.split("/")[0];
34
- return owner || null;
35
- }
36
- function connectedDataArtifactExpiresAt(artifactId) {
37
- const timestamp = artifactTimestamp(artifactId);
38
- return timestamp === null ? null : new Date(timestamp + CONNECTED_DATA_ARTIFACT_TTL_MS);
39
- }
40
- function connectedDataArtifactIsExpired(artifactId, now = Date.now()) {
41
- const timestamp = artifactTimestamp(artifactId);
42
- return timestamp === null || timestamp + CONNECTED_DATA_ARTIFACT_TTL_MS <= now;
43
- }
44
- async function signedDownloadUrl(pathname, expiresAt) {
45
- const token = privateBlobToken();
46
- if (!token) return null;
47
- const validUntil = Math.min(Date.now() + CONNECTED_DATA_DOWNLOAD_TTL_MS, expiresAt.getTime());
48
- if (validUntil <= Date.now()) return null;
49
- const { issueSignedToken, presignUrl } = await import("@vercel/blob");
50
- const signedToken = await issueSignedToken({
51
- token,
52
- pathname,
53
- operations: ["get"],
54
- validUntil
55
- });
56
- const { presignedUrl } = await presignUrl(signedToken, {
57
- access: "private",
58
- operation: "get",
59
- pathname,
60
- validUntil
61
- });
62
- return { url: presignedUrl, expiresAt: new Date(validUntil).toISOString() };
63
- }
64
- async function createConnectedDataArtifact(args) {
65
- return createConnectedDataBinaryArtifact({
66
- ...args,
67
- contentType: "application/x-ndjson"
68
- });
69
- }
70
- async function createConnectedDataBinaryArtifact(args) {
71
- const requestedCreatedAt = args.stableCreatedAt ? Date.parse(args.stableCreatedAt) : Number.NaN;
72
- const createdAt = Number.isFinite(requestedCreatedAt) ? requestedCreatedAt : Date.now();
73
- const filename = safeFilename(args.filename);
74
- const extension = filename.includes(".") ? `.${filename.split(".").at(-1)}` : ".bin";
75
- const stableSuffix = args.stableKey ? safeFilename(args.stableKey) : randomUUID();
76
- const requestedPathname = `${CONNECTED_DATA_ARTIFACT_PREFIX}${args.ownerId}/${createdAt}-${safeFilename(args.exportId)}-${stableSuffix}--${filename}`;
77
- const content = typeof args.content === "string" ? Buffer.from(args.content) : Buffer.from(args.content);
78
- const bytes = content.byteLength;
79
- const sha256 = createHash("sha256").update(content).digest("hex");
80
- const expiresAt = new Date(createdAt + CONNECTED_DATA_ARTIFACT_TTL_MS);
81
- const token = privateBlobToken();
82
- let artifactId = requestedPathname;
83
- if (token) {
84
- const { put } = await import("@vercel/blob");
85
- const stored = await put(requestedPathname, content, {
86
- access: "private",
87
- token,
88
- contentType: args.contentType,
89
- addRandomSuffix: !args.stableKey,
90
- ...args.stableKey ? { allowOverwrite: true } : {},
91
- cacheControlMaxAge: 60,
92
- multipart: bytes > 100 * 1024 * 1024
93
- });
94
- artifactId = stored.pathname;
95
- } else {
96
- if (isHosted()) throw new Error("connected_data_private_blob_not_configured");
97
- const path = join(localBaseDir(), "blobs", requestedPathname);
98
- await mkdir(dirname(path), { recursive: true });
99
- await writeFile(path, content);
100
- }
101
- const download = await signedDownloadUrl(artifactId, expiresAt);
102
- return {
103
- artifactId,
104
- filename,
105
- contentType: args.contentType,
106
- bytes,
107
- sha256,
108
- createdAt: new Date(createdAt).toISOString(),
109
- expiresAt: expiresAt.toISOString(),
110
- downloadUrl: download?.url ?? null,
111
- downloadUrlExpiresAt: download?.expiresAt ?? null,
112
- readback: {
113
- tool: "report_artifact_read",
114
- arguments: { artifactId, offset: 0, maxBytes: 2e4 },
115
- continuation: "Repeat with offset set to the previous result nextOffset until nextOffset is null."
116
- }
117
- };
118
- }
119
- async function renewConnectedDataArtifactDownload(args) {
120
- if (connectedDataArtifactOwnerId(args.artifactId) !== args.ownerId) return null;
121
- const expiresAt = connectedDataArtifactExpiresAt(args.artifactId);
122
- if (!expiresAt || expiresAt.getTime() <= Date.now()) return null;
123
- const download = await signedDownloadUrl(args.artifactId, expiresAt);
124
- if (!download) return null;
125
- return {
126
- downloadUrl: download.url,
127
- downloadUrlExpiresAt: download.expiresAt,
128
- expiresAt: expiresAt.toISOString()
129
- };
130
- }
131
- async function streamToBuffer(stream, maxBytes = Number.POSITIVE_INFINITY) {
132
- const reader = stream.getReader();
133
- const chunks = [];
134
- let totalBytes = 0;
135
- try {
136
- for (; ; ) {
137
- const { done, value } = await reader.read();
138
- if (done) break;
139
- if (value) {
140
- const chunk = Buffer.from(value);
141
- totalBytes += chunk.byteLength;
142
- if (totalBytes > maxBytes) {
143
- await reader.cancel("artifact_too_large").catch(() => void 0);
144
- return null;
145
- }
146
- chunks.push(chunk);
147
- }
148
- }
149
- } finally {
150
- reader.releaseLock();
151
- }
152
- return Buffer.concat(chunks);
153
- }
154
- async function readConnectedDataArtifactWindow(artifactId, offset, maxBytes) {
155
- if (connectedDataArtifactIsExpired(artifactId)) return null;
156
- const token = privateBlobToken();
157
- let buffer;
158
- if (token) {
159
- const { get } = await import("@vercel/blob");
160
- const result = await get(artifactId, { access: "private", token, useCache: false });
161
- if (!result || result.statusCode !== 200) return null;
162
- const streamed = await streamToBuffer(result.stream);
163
- if (!streamed) return null;
164
- buffer = streamed;
165
- } else {
166
- if (isHosted()) return null;
167
- try {
168
- buffer = await readFile(join(localBaseDir(), "blobs", artifactId));
169
- } catch {
170
- return null;
171
- }
172
- }
173
- const totalBytes = buffer.length;
174
- const start = Math.max(0, offset);
175
- const end = Math.min(totalBytes, start + maxBytes);
176
- return {
177
- text: buffer.subarray(start, end).toString("utf8"),
178
- totalBytes,
179
- nextOffset: end < totalBytes ? end : null
180
- };
181
- }
182
- async function readConnectedDataArtifactBytes(args) {
183
- if (connectedDataArtifactOwnerId(args.artifactId) !== args.ownerId || connectedDataArtifactIsExpired(args.artifactId)) return null;
184
- const token = privateBlobToken();
185
- let buffer;
186
- if (token) {
187
- const { get } = await import("@vercel/blob");
188
- const result = await get(args.artifactId, { access: "private", token, useCache: false });
189
- if (!result || result.statusCode !== 200) return null;
190
- const streamed = await streamToBuffer(result.stream, args.maxBytes ?? 25 * 1024 * 1024);
191
- if (!streamed) return null;
192
- buffer = streamed;
193
- } else {
194
- if (isHosted()) return null;
195
- try {
196
- const path = join(localBaseDir(), "blobs", args.artifactId);
197
- const info = await stat(path);
198
- if (info.size > (args.maxBytes ?? 25 * 1024 * 1024)) return null;
199
- buffer = await readFile(path);
200
- } catch {
201
- return null;
202
- }
203
- }
204
- if (buffer.byteLength > (args.maxBytes ?? 25 * 1024 * 1024)) return null;
205
- return buffer;
206
- }
207
- async function cleanupExpiredConnectedDataArtifacts(args = {}) {
208
- const now = args.now ?? /* @__PURE__ */ new Date();
209
- const token = privateBlobToken();
210
- if (!token) return { deleted: 0, store: isHosted() ? "none" : "local" };
211
- if (!args.force && !(now.getUTCHours() === 3 && now.getUTCMinutes() === 17)) {
212
- return { deleted: 0, store: "private-vercel-blob", skipped: true };
213
- }
214
- const cutoff = now.getTime() - CONNECTED_DATA_ARTIFACT_TTL_MS;
215
- const { list, del } = await import("@vercel/blob");
216
- let cursor;
217
- let deleted = 0;
218
- for (let page = 0; page < 20; page++) {
219
- const result = await list({ prefix: CONNECTED_DATA_ARTIFACT_PREFIX, token, limit: 1e3, cursor });
220
- const expired = result.blobs.filter((blob) => new Date(blob.uploadedAt).getTime() <= cutoff);
221
- if (expired.length > 0) {
222
- await del(expired.map((blob) => blob.pathname), { token });
223
- deleted += expired.length;
224
- }
225
- if (!result.hasMore || !result.cursor) break;
226
- cursor = result.cursor;
227
- }
228
- return { deleted, store: "private-vercel-blob" };
229
- }
230
-
231
- export {
232
- CONNECTED_DATA_ARTIFACT_PREFIX,
233
- connectedDataArtifactOwnerId,
234
- createConnectedDataArtifact,
235
- createConnectedDataBinaryArtifact,
236
- renewConnectedDataArtifactDownload,
237
- readConnectedDataArtifactWindow,
238
- readConnectedDataArtifactBytes,
239
- cleanupExpiredConnectedDataArtifacts
240
- };