thumbgate 1.4.3 → 1.4.5
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/llms.txt +12 -8
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +18 -8
- package/adapters/README.md +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/codex/config.toml +2 -2
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/config/github-about.json +2 -2
- package/package.json +158 -10
- package/scripts/billing.js +5 -2
- package/scripts/statusline.sh +1 -0
- package/src/api/server.js +113 -16
- package/src/index.js +3 -0
- package/.claude-plugin/bundle/icon.png +0 -0
- package/.claude-plugin/bundle/icon.svg +0 -18
- package/.claude-plugin/bundle/server/index.js +0 -24
- package/adapters/chatgpt/INSTALL.md +0 -158
- package/adapters/perplexity/.mcp.json +0 -36
- package/adapters/perplexity/config.toml +0 -16
- package/adapters/perplexity/opencode.json +0 -29
- package/bin/memory.sh +0 -64
- package/bin/obsidian-sync.sh +0 -20
- package/plugins/amp-skill/INSTALL.md +0 -52
- package/plugins/amp-skill/SKILL.md +0 -64
- package/plugins/claude-codex-bridge/.claude-plugin/plugin.json +0 -22
- package/plugins/claude-codex-bridge/.mcp.json +0 -14
- package/plugins/claude-codex-bridge/INSTALL.md +0 -43
- package/plugins/claude-codex-bridge/README.md +0 -46
- package/plugins/claude-codex-bridge/scripts/codex-bridge.js +0 -286
- package/plugins/claude-codex-bridge/skills/adversarial-review/SKILL.md +0 -24
- package/plugins/claude-codex-bridge/skills/result/SKILL.md +0 -22
- package/plugins/claude-codex-bridge/skills/review/SKILL.md +0 -28
- package/plugins/claude-codex-bridge/skills/second-pass/SKILL.md +0 -27
- package/plugins/claude-codex-bridge/skills/setup/SKILL.md +0 -21
- package/plugins/claude-codex-bridge/skills/status/SKILL.md +0 -19
- package/plugins/claude-skill/INSTALL.md +0 -55
- package/plugins/claude-skill/SKILL.md +0 -46
- package/plugins/codex-profile/.codex-plugin/plugin.json +0 -43
- package/plugins/codex-profile/.mcp.json +0 -14
- package/plugins/codex-profile/AGENTS.md +0 -20
- package/plugins/codex-profile/INSTALL.md +0 -89
- package/plugins/codex-profile/README.md +0 -61
- package/plugins/cursor-marketplace/.cursor-plugin/plugin.json +0 -23
- package/plugins/cursor-marketplace/CHANGELOG.md +0 -30
- package/plugins/cursor-marketplace/LICENSE +0 -21
- package/plugins/cursor-marketplace/README.md +0 -124
- package/plugins/cursor-marketplace/agents/reliability-reviewer.md +0 -31
- package/plugins/cursor-marketplace/assets/logo-400x400.png +0 -0
- package/plugins/cursor-marketplace/commands/capture-feedback.md +0 -33
- package/plugins/cursor-marketplace/commands/check-gates.md +0 -25
- package/plugins/cursor-marketplace/commands/show-lessons.md +0 -27
- package/plugins/cursor-marketplace/hooks/hooks.json +0 -10
- package/plugins/cursor-marketplace/mcp.json +0 -14
- package/plugins/cursor-marketplace/rules/feedback-capture.mdc +0 -34
- package/plugins/cursor-marketplace/rules/pre-action-gates.mdc +0 -30
- package/plugins/cursor-marketplace/rules/session-continuity.mdc +0 -28
- package/plugins/cursor-marketplace/scripts/gate-check.sh +0 -21
- package/plugins/cursor-marketplace/skills/capture-feedback/SKILL.md +0 -48
- package/plugins/cursor-marketplace/skills/prevention-rules/SKILL.md +0 -31
- package/plugins/cursor-marketplace/skills/recall-context/SKILL.md +0 -30
- package/plugins/cursor-marketplace/skills/search-lessons/SKILL.md +0 -33
- package/plugins/gemini-extension/INSTALL.md +0 -92
- package/plugins/gemini-extension/gemini_prompt.txt +0 -14
- package/plugins/gemini-extension/tool_contract.json +0 -45
- package/plugins/opencode-profile/INSTALL.md +0 -57
- package/public/assets/instagram-card.png +0 -0
- package/public/assets/tiktok-agent-memory.mp4 +0 -0
- package/public/blog.html +0 -474
- package/public/compare/mem0.html +0 -189
- package/public/compare/speclock.html +0 -180
- package/public/compare.html +0 -310
- package/public/dashboard.html +0 -1100
- package/public/guide.html +0 -317
- package/public/guides/claude-code-prevent-repeated-mistakes.html +0 -161
- package/public/guides/codex-cli-guardrails.html +0 -158
- package/public/guides/cursor-prevent-repeated-mistakes.html +0 -161
- package/public/guides/pre-action-gates.html +0 -162
- package/public/guides/stop-repeated-ai-agent-mistakes.html +0 -159
- package/public/index.html +0 -1225
- package/public/js/buyer-intent.js +0 -252
- package/public/learn/agent-harness-pattern.html +0 -180
- package/public/learn/ai-agent-persistent-memory.html +0 -203
- package/public/learn/learn.css +0 -45
- package/public/learn/mcp-pre-action-gates-explained.html +0 -172
- package/public/learn/stop-ai-agent-force-push.html +0 -134
- package/public/learn/vibe-coding-safety-net.html +0 -142
- package/public/learn.html +0 -274
- package/public/lessons.html +0 -967
- package/public/llm-context.md +0 -156
- package/public/pro.html +0 -1087
- package/public/vercel.json +0 -8
- package/scripts/a2ui-engine.js +0 -73
- package/scripts/adk-consolidator.js +0 -274
- package/scripts/agent-security-hardening.js +0 -225
- package/scripts/ai-search-visibility.js +0 -116
- package/scripts/autonomous-sales-agent.js +0 -39
- package/scripts/autoresearch-runner.js +0 -216
- package/scripts/background-agent-governance.js +0 -229
- package/scripts/behavioral-extraction.js +0 -93
- package/scripts/budget-enforcer.js +0 -173
- package/scripts/budget-guard.js +0 -173
- package/scripts/build-claude-mcpb.js +0 -255
- package/scripts/build-codex-plugin.js +0 -152
- package/scripts/capture-railway-diagnostics.sh +0 -97
- package/scripts/changeset-check.js +0 -372
- package/scripts/check-congruence.js +0 -443
- package/scripts/computer-use-firewall.js +0 -280
- package/scripts/content-engine/linkedin-content-generator.js +0 -154
- package/scripts/content-engine/output/linkedin-memento-validation.md +0 -17
- package/scripts/content-engine/output/linkedin-posts-2026-04-09.md +0 -175
- package/scripts/content-engine/reddit-thread-finder.js +0 -154
- package/scripts/context-engine.js +0 -710
- package/scripts/daily-digest.js +0 -11
- package/scripts/data-governance.js +0 -173
- package/scripts/deploy-gcp.sh +0 -44
- package/scripts/deploy-policy.js +0 -249
- package/scripts/disagreement-mining.js +0 -315
- package/scripts/dpo-optimizer.js +0 -206
- package/scripts/ensure-repo-bootstrap.js +0 -130
- package/scripts/ephemeral-agent-store.js +0 -212
- package/scripts/eval-harness.js +0 -56
- package/scripts/export-kto-pairs.js +0 -309
- package/scripts/export-training.js +0 -446
- package/scripts/feedback-fallback.js +0 -111
- package/scripts/feedback-inbox-read.js +0 -162
- package/scripts/feedback-root-consolidator.js +0 -233
- package/scripts/feedback-to-memory.js +0 -185
- package/scripts/gate-satisfy.js +0 -42
- package/scripts/generate-paperbanana-diagrams.sh +0 -99
- package/scripts/generate-pretool-hook.sh +0 -40
- package/scripts/github-about.js +0 -430
- package/scripts/github-outreach.js +0 -65
- package/scripts/gtm-revenue-loop.js +0 -535
- package/scripts/hallucination-detector.js +0 -226
- package/scripts/hf-papers.js +0 -317
- package/scripts/hook-auto-capture.sh +0 -100
- package/scripts/hook-stop-pr-thread-check.sh +0 -68
- package/scripts/hook-stop-self-score.sh +0 -51
- package/scripts/hook-stop-verify-deploy.sh +0 -31
- package/scripts/hook-verify-before-done.sh +0 -20
- package/scripts/managed-dpo-export.js +0 -91
- package/scripts/markdown-escape.js +0 -12
- package/scripts/marketing-experiment.js +0 -657
- package/scripts/memalign-recall.js +0 -111
- package/scripts/memory-migration.js +0 -296
- package/scripts/meta-policy.js +0 -190
- package/scripts/metered-billing.js +0 -16
- package/scripts/model-tier-router.js +0 -310
- package/scripts/money-watcher.js +0 -218
- package/scripts/multi-hop-recall.js +0 -240
- package/scripts/per-step-scoring.js +0 -163
- package/scripts/perplexity-command-center.js +0 -644
- package/scripts/perplexity-marketing.js +0 -454
- package/scripts/pii-scanner.js +0 -153
- package/scripts/plan-gate.js +0 -154
- package/scripts/post-everywhere.js +0 -341
- package/scripts/post-to-x-retry.sh +0 -22
- package/scripts/post-to-x.js +0 -369
- package/scripts/pr-manager.js +0 -421
- package/scripts/principle-extractor.js +0 -162
- package/scripts/pro-features.js +0 -41
- package/scripts/prompt-dlp.js +0 -222
- package/scripts/prove-adapters.js +0 -860
- package/scripts/prove-attribution.js +0 -361
- package/scripts/prove-automation.js +0 -651
- package/scripts/prove-autoresearch.js +0 -304
- package/scripts/prove-claim-verification.js +0 -277
- package/scripts/prove-cloudflare-sandbox.js +0 -161
- package/scripts/prove-data-pipeline.js +0 -408
- package/scripts/prove-data-quality.js +0 -227
- package/scripts/prove-evolution.js +0 -352
- package/scripts/prove-harnesses.js +0 -287
- package/scripts/prove-intelligence.js +0 -257
- package/scripts/prove-lancedb.js +0 -425
- package/scripts/prove-local-intelligence.js +0 -340
- package/scripts/prove-loop-closure.js +0 -263
- package/scripts/prove-packaged-runtime.js +0 -327
- package/scripts/prove-predictive-insights.js +0 -355
- package/scripts/prove-runtime.js +0 -363
- package/scripts/prove-seo-gsd.js +0 -234
- package/scripts/prove-settings.js +0 -279
- package/scripts/prove-subway-upgrades.js +0 -277
- package/scripts/prove-tessl.js +0 -229
- package/scripts/prove-training-export.js +0 -325
- package/scripts/prove-workflow-contract.js +0 -112
- package/scripts/prove-xmemory.js +0 -332
- package/scripts/publish-decision.js +0 -159
- package/scripts/ralph-loop.js +0 -376
- package/scripts/ralph-mode-ci.js +0 -434
- package/scripts/reddit-dm-outreach.js +0 -192
- package/scripts/reddit-monitor-cron.sh +0 -26
- package/scripts/reminder-engine.js +0 -132
- package/scripts/revenue-status.js +0 -472
- package/scripts/rotate-stripe-webhook-secret.js +0 -314
- package/scripts/schedule-manager.js +0 -249
- package/scripts/self-healing-check.js +0 -193
- package/scripts/session-analyzer.js +0 -533
- package/scripts/shieldcortex-memory-firewall-runner.mjs +0 -53
- package/scripts/skill-exporter.js +0 -260
- package/scripts/skill-materializer.js +0 -134
- package/scripts/skill-packs.js +0 -136
- package/scripts/skill-proposer.js +0 -99
- package/scripts/skill-quality-tracker.js +0 -282
- package/scripts/slow-loop.js +0 -72
- package/scripts/social-analytics/db/marketing-db.js +0 -179
- package/scripts/social-analytics/db/schema.sql +0 -55
- package/scripts/social-analytics/digest.js +0 -256
- package/scripts/social-analytics/engagement-audit.js +0 -185
- package/scripts/social-analytics/generate-instagram-card.js +0 -123
- package/scripts/social-analytics/generate-slides.js +0 -268
- package/scripts/social-analytics/instagram-thumbgate-post.js +0 -111
- package/scripts/social-analytics/install-growth-automation.js +0 -114
- package/scripts/social-analytics/load-env.js +0 -77
- package/scripts/social-analytics/mcp-server.js +0 -289
- package/scripts/social-analytics/normalizer.js +0 -580
- package/scripts/social-analytics/notify.js +0 -162
- package/scripts/social-analytics/poll-all.js +0 -107
- package/scripts/social-analytics/pollers/github.js +0 -195
- package/scripts/social-analytics/pollers/instagram.js +0 -253
- package/scripts/social-analytics/pollers/linkedin.js +0 -340
- package/scripts/social-analytics/pollers/plausible.js +0 -245
- package/scripts/social-analytics/pollers/reddit.js +0 -306
- package/scripts/social-analytics/pollers/threads.js +0 -233
- package/scripts/social-analytics/pollers/tiktok.js +0 -203
- package/scripts/social-analytics/pollers/x.js +0 -227
- package/scripts/social-analytics/pollers/youtube.js +0 -304
- package/scripts/social-analytics/pollers/zernio.js +0 -183
- package/scripts/social-analytics/post-video.js +0 -316
- package/scripts/social-analytics/publish-instagram-thumbgate.js +0 -104
- package/scripts/social-analytics/publish-thumbgate-launch.js +0 -322
- package/scripts/social-analytics/publishers/devto.js +0 -122
- package/scripts/social-analytics/publishers/instagram.js +0 -317
- package/scripts/social-analytics/publishers/linkedin.js +0 -294
- package/scripts/social-analytics/publishers/reddit.js +0 -385
- package/scripts/social-analytics/publishers/threads.js +0 -275
- package/scripts/social-analytics/publishers/tiktok.js +0 -217
- package/scripts/social-analytics/publishers/x.js +0 -259
- package/scripts/social-analytics/publishers/youtube.js +0 -223
- package/scripts/social-analytics/publishers/zernio.js +0 -568
- package/scripts/social-analytics/reconcile-thumbgate-campaign.js +0 -165
- package/scripts/social-analytics/run-digest.js +0 -34
- package/scripts/social-analytics/schedule-thumbgate-campaign.js +0 -275
- package/scripts/social-analytics/store.js +0 -455
- package/scripts/social-analytics/sync-launch-assets.js +0 -185
- package/scripts/social-analytics/utm.js +0 -143
- package/scripts/social-pipeline.js +0 -2626
- package/scripts/social-post-hourly.js +0 -228
- package/scripts/social-quality-gate.js +0 -134
- package/scripts/social-reply-monitor.js +0 -592
- package/scripts/status-dashboard.js +0 -155
- package/scripts/stripe-live-status.js +0 -115
- package/scripts/subagent-profiles.js +0 -79
- package/scripts/sync-branch-protection.js +0 -340
- package/scripts/sync-gh-secrets-from-env.sh +0 -70
- package/scripts/sync-github-about.js +0 -55
- package/scripts/sync-version.js +0 -479
- package/scripts/synthetic-dpo.js +0 -234
- package/scripts/tessl-export.js +0 -369
- package/scripts/test-coverage.js +0 -128
- package/scripts/thumbgate-bench.js +0 -494
- package/scripts/thumbgate_session_start.sh +0 -32
- package/scripts/train_from_feedback.py +0 -929
- package/scripts/validate-feedback.js +0 -581
- package/scripts/verify-obsidian-setup.sh +0 -269
- package/scripts/verify-run.js +0 -269
- package/scripts/weekly-auto-post.js +0 -124
- package/scripts/x-autonomous-marketing.js +0 -139
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Instagram engagement poller using the Instagram Graph API v21.0.
|
|
5
|
-
*
|
|
6
|
-
* Required environment variables:
|
|
7
|
-
* INSTAGRAM_ACCESS_TOKEN — long-lived page/user access token
|
|
8
|
-
* INSTAGRAM_USER_ID — Instagram business/creator account user ID
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const { normalize } = require('../normalizer');
|
|
12
|
-
const { upsertMetric, upsertFollowerSnapshot, initDb } = require('../store');
|
|
13
|
-
|
|
14
|
-
const GRAPH_BASE = 'https://graph.facebook.com/v21.0';
|
|
15
|
-
|
|
16
|
-
// Map Instagram media_type to our normalised content_type.
|
|
17
|
-
const MEDIA_TYPE_MAP = {
|
|
18
|
-
CAROUSEL_ALBUM: 'carousel',
|
|
19
|
-
IMAGE: 'image',
|
|
20
|
-
VIDEO: 'reel',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Fetches the most recent 25 media items for a user.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} token - Instagram access token.
|
|
27
|
-
* @param {string} userId - Instagram user ID.
|
|
28
|
-
* @returns {Promise<object[]>} Array of media objects.
|
|
29
|
-
*/
|
|
30
|
-
async function fetchInstagramMedia(token, userId) {
|
|
31
|
-
const fields = [
|
|
32
|
-
'id',
|
|
33
|
-
'caption',
|
|
34
|
-
'media_type',
|
|
35
|
-
'permalink',
|
|
36
|
-
'timestamp',
|
|
37
|
-
'like_count',
|
|
38
|
-
'comments_count',
|
|
39
|
-
'children{media_type,media_url}',
|
|
40
|
-
].join(',');
|
|
41
|
-
|
|
42
|
-
const url =
|
|
43
|
-
`${GRAPH_BASE}/${userId}/media` +
|
|
44
|
-
`?fields=${fields}&limit=25&access_token=${token}`;
|
|
45
|
-
|
|
46
|
-
const res = await fetch(url);
|
|
47
|
-
if (!res.ok) {
|
|
48
|
-
const body = await res.text();
|
|
49
|
-
throw new Error(`fetchInstagramMedia HTTP ${res.status}: ${body}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const json = await res.json();
|
|
53
|
-
if (json.error) {
|
|
54
|
-
throw new Error(`fetchInstagramMedia API error: ${JSON.stringify(json.error)}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return json.data ?? [];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Fetches insights for a single media item.
|
|
62
|
-
* Some media types (e.g. stories) do not support all metrics — errors are
|
|
63
|
-
* caught and logged so polling continues for other posts.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} token - Instagram access token.
|
|
66
|
-
* @param {string} mediaId - Instagram media ID.
|
|
67
|
-
* @returns {Promise<object>} Map of metric name -> value (defaults to 0 on error).
|
|
68
|
-
*/
|
|
69
|
-
async function fetchMediaInsights(token, mediaId) {
|
|
70
|
-
const metrics = 'impressions,reach,saved,shares';
|
|
71
|
-
const url =
|
|
72
|
-
`${GRAPH_BASE}/${mediaId}/insights` +
|
|
73
|
-
`?metric=${metrics}&access_token=${token}`;
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const res = await fetch(url);
|
|
77
|
-
if (!res.ok) {
|
|
78
|
-
const body = await res.text();
|
|
79
|
-
console.warn(`fetchMediaInsights HTTP ${res.status} for ${mediaId}: ${body}`);
|
|
80
|
-
return {};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const json = await res.json();
|
|
84
|
-
if (json.error) {
|
|
85
|
-
// Some media types (Reels, Stories older than 24 h, etc.) return errors
|
|
86
|
-
// for certain metrics. Log and return an empty result rather than throw.
|
|
87
|
-
console.warn(
|
|
88
|
-
`fetchMediaInsights API warning for ${mediaId}: ${JSON.stringify(json.error)}`
|
|
89
|
-
);
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Reshape array of { name, values } -> flat { name: value }
|
|
94
|
-
const result = {};
|
|
95
|
-
for (const item of json.data ?? []) {
|
|
96
|
-
// Instagram returns period-scoped values; take the first value entry.
|
|
97
|
-
const val = Array.isArray(item.values) ? item.values[0]?.value : item.value;
|
|
98
|
-
result[item.name] = typeof val === 'number' ? val : 0;
|
|
99
|
-
}
|
|
100
|
-
return result;
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.warn(`fetchMediaInsights error for ${mediaId}: ${err.message}`);
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Fetches account-level insights: reach, impressions, follower_count.
|
|
109
|
-
*
|
|
110
|
-
* @param {string} token - Instagram access token.
|
|
111
|
-
* @param {string} userId - Instagram user ID.
|
|
112
|
-
* @param {string} since - Unix timestamp string (start of window).
|
|
113
|
-
* @param {string} until - Unix timestamp string (end of window).
|
|
114
|
-
* @returns {Promise<object[]>} Raw data array from the API response.
|
|
115
|
-
*/
|
|
116
|
-
async function fetchAccountInsights(token, userId, since, until) {
|
|
117
|
-
const metrics = 'reach,impressions,follower_count';
|
|
118
|
-
const url =
|
|
119
|
-
`${GRAPH_BASE}/${userId}/insights` +
|
|
120
|
-
`?metric=${metrics}&period=day&since=${since}&until=${until}&access_token=${token}`;
|
|
121
|
-
|
|
122
|
-
const res = await fetch(url);
|
|
123
|
-
if (!res.ok) {
|
|
124
|
-
const body = await res.text();
|
|
125
|
-
throw new Error(`fetchAccountInsights HTTP ${res.status}: ${body}`);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const json = await res.json();
|
|
129
|
-
if (json.error) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
`fetchAccountInsights API error: ${JSON.stringify(json.error)}`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return json.data ?? [];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Main entry point. Polls Instagram for recent media and account insights,
|
|
140
|
-
* normalises the data, and upserts it into the local SQLite database.
|
|
141
|
-
*
|
|
142
|
-
* @param {import('better-sqlite3').Database} db - Initialised db instance.
|
|
143
|
-
*/
|
|
144
|
-
async function pollInstagram(db) {
|
|
145
|
-
const token = process.env.INSTAGRAM_ACCESS_TOKEN;
|
|
146
|
-
const userId = process.env.INSTAGRAM_USER_ID;
|
|
147
|
-
|
|
148
|
-
if (!token) throw new Error('INSTAGRAM_ACCESS_TOKEN is not set');
|
|
149
|
-
if (!userId) throw new Error('INSTAGRAM_USER_ID is not set');
|
|
150
|
-
|
|
151
|
-
const fetchedAt = new Date().toISOString();
|
|
152
|
-
const today = fetchedAt.slice(0, 10);
|
|
153
|
-
|
|
154
|
-
console.log(`[instagram] Fetching media for user ${userId}…`);
|
|
155
|
-
const mediaItems = await fetchInstagramMedia(token, userId);
|
|
156
|
-
console.log(`[instagram] Got ${mediaItems.length} media items`);
|
|
157
|
-
|
|
158
|
-
for (const item of mediaItems) {
|
|
159
|
-
const mediaId = item.id;
|
|
160
|
-
|
|
161
|
-
// Fetch per-post insights (best-effort; some types may not support all).
|
|
162
|
-
const insights = await fetchMediaInsights(token, mediaId);
|
|
163
|
-
|
|
164
|
-
const rawContentType = MEDIA_TYPE_MAP[item.media_type] ?? 'image';
|
|
165
|
-
|
|
166
|
-
// Build a raw record compatible with the normalizer contract.
|
|
167
|
-
const raw = {
|
|
168
|
-
platform: 'instagram',
|
|
169
|
-
content_type: rawContentType,
|
|
170
|
-
post_id: mediaId,
|
|
171
|
-
post_url: item.permalink ?? null,
|
|
172
|
-
published_at: item.timestamp ?? null,
|
|
173
|
-
metric_date: today,
|
|
174
|
-
impressions: insights.impressions ?? 0,
|
|
175
|
-
reach: insights.reach ?? 0,
|
|
176
|
-
likes: item.like_count ?? 0,
|
|
177
|
-
comments: item.comments_count ?? 0,
|
|
178
|
-
shares: insights.shares ?? 0,
|
|
179
|
-
saves: insights.saved ?? 0,
|
|
180
|
-
clicks: 0,
|
|
181
|
-
video_views: 0,
|
|
182
|
-
followers_delta: 0,
|
|
183
|
-
fetched_at: fetchedAt,
|
|
184
|
-
extra_json: {
|
|
185
|
-
media_type: item.media_type,
|
|
186
|
-
caption_snippet: (item.caption ?? '').slice(0, 120),
|
|
187
|
-
children_count: item.children?.data?.length ?? null,
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const normalised = normalize(raw);
|
|
192
|
-
upsertMetric(db, normalised);
|
|
193
|
-
console.log(`[instagram] Upserted metric for post ${mediaId} (${rawContentType})`);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Fetch account-level follower count for today's snapshot.
|
|
197
|
-
const nowTs = Math.floor(Date.now() / 1000);
|
|
198
|
-
const dayAgoTs = nowTs - 86400;
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
console.log('[instagram] Fetching account insights for follower snapshot…');
|
|
202
|
-
const accountData = await fetchAccountInsights(
|
|
203
|
-
token,
|
|
204
|
-
userId,
|
|
205
|
-
String(dayAgoTs),
|
|
206
|
-
String(nowTs)
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
// Find the follower_count series and take the latest value.
|
|
210
|
-
const followerSeries = accountData.find((d) => d.name === 'follower_count');
|
|
211
|
-
if (followerSeries) {
|
|
212
|
-
const latestEntry = (followerSeries.values ?? []).slice(-1)[0];
|
|
213
|
-
const followerCount = latestEntry?.value ?? 0;
|
|
214
|
-
|
|
215
|
-
upsertFollowerSnapshot(db, {
|
|
216
|
-
platform: 'instagram',
|
|
217
|
-
follower_count: followerCount,
|
|
218
|
-
snapshot_date: today,
|
|
219
|
-
});
|
|
220
|
-
console.log(`[instagram] Upserted follower snapshot: ${followerCount} followers`);
|
|
221
|
-
} else {
|
|
222
|
-
console.warn('[instagram] follower_count not found in account insights response');
|
|
223
|
-
}
|
|
224
|
-
} catch (err) {
|
|
225
|
-
// Account insights failure should not abort per-post metric storage.
|
|
226
|
-
console.warn(`[instagram] Account insights error (non-fatal): ${err.message}`);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
console.log('[instagram] Poll complete.');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
module.exports = {
|
|
233
|
-
fetchInstagramMedia,
|
|
234
|
-
fetchMediaInsights,
|
|
235
|
-
fetchAccountInsights,
|
|
236
|
-
pollInstagram,
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
// Allow running directly: node scripts/social-analytics/pollers/instagram.js
|
|
240
|
-
if (require.main === module) {
|
|
241
|
-
(async () => {
|
|
242
|
-
const { initDb } = require('../store');
|
|
243
|
-
const db = initDb();
|
|
244
|
-
try {
|
|
245
|
-
await pollInstagram(db);
|
|
246
|
-
} catch (err) {
|
|
247
|
-
console.error('[instagram] Fatal error:', err.message);
|
|
248
|
-
process.exit(1);
|
|
249
|
-
} finally {
|
|
250
|
-
db.close();
|
|
251
|
-
}
|
|
252
|
-
})();
|
|
253
|
-
}
|
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LinkedIn engagement poller using the LinkedIn Posts API and related REST endpoints.
|
|
5
|
-
*
|
|
6
|
-
* Required environment variables:
|
|
7
|
-
* LINKEDIN_ACCESS_TOKEN — OAuth 2.0 access token with r_liteprofile, r_organization_social,
|
|
8
|
-
* and r_1st_connections_size scopes (required)
|
|
9
|
-
* LINKEDIN_PERSON_URN — Authenticated member URN, e.g. urn:li:person:XXXXX (required)
|
|
10
|
-
*
|
|
11
|
-
* LinkedIn API references:
|
|
12
|
-
* Posts API: https://api.linkedin.com/rest/posts
|
|
13
|
-
* Social Metadata: https://api.linkedin.com/v2/socialMetadata/{encoded-urn}
|
|
14
|
-
* Profile: https://api.linkedin.com/v2/me
|
|
15
|
-
* Network sizes: https://api.linkedin.com/v2/networkSizes/{encoded-urn}
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const LI_REST_BASE = 'https://api.linkedin.com/rest';
|
|
19
|
-
const LI_V2_BASE = 'https://api.linkedin.com/v2';
|
|
20
|
-
|
|
21
|
-
// Standard headers required by LinkedIn's versioned REST API.
|
|
22
|
-
function buildRestHeaders(token) {
|
|
23
|
-
return {
|
|
24
|
-
Authorization: `Bearer ${token}`,
|
|
25
|
-
'LinkedIn-Version': '202601',
|
|
26
|
-
'X-Restli-Protocol-Version': '2.0.0',
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function buildV2Headers(token) {
|
|
31
|
-
return {
|
|
32
|
-
Authorization: `Bearer ${token}`,
|
|
33
|
-
'X-Restli-Protocol-Version': '2.0.0',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Safely coerces a value to an integer, returning 0 for null/undefined/NaN.
|
|
39
|
-
* @param {*} v
|
|
40
|
-
* @returns {number}
|
|
41
|
-
*/
|
|
42
|
-
function toInt(v) {
|
|
43
|
-
const n = parseInt(v, 10);
|
|
44
|
-
return Number.isFinite(n) ? n : 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Fetches the most recent posts authored by the authenticated member.
|
|
49
|
-
*
|
|
50
|
-
* Uses the Posts API (LinkedIn-Version: 202401).
|
|
51
|
-
* Returns up to 20 posts sorted by recency.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} token - LinkedIn OAuth access token.
|
|
54
|
-
* @param {string} personUrn - Member URN, e.g. "urn:li:person:XXXXX".
|
|
55
|
-
* @returns {Promise<object[]>} Array of post objects.
|
|
56
|
-
*/
|
|
57
|
-
async function fetchLinkedInPosts(token, personUrn) {
|
|
58
|
-
if (!token) throw new Error('fetchLinkedInPosts: token is required');
|
|
59
|
-
if (!personUrn) throw new Error('fetchLinkedInPosts: personUrn is required');
|
|
60
|
-
|
|
61
|
-
const url =
|
|
62
|
-
`${LI_REST_BASE}/posts` +
|
|
63
|
-
`?author=${encodeURIComponent(personUrn)}&q=author&count=20`;
|
|
64
|
-
|
|
65
|
-
console.log(`[linkedin] Fetching posts for ${personUrn}`);
|
|
66
|
-
|
|
67
|
-
const res = await fetch(url, { headers: buildRestHeaders(token) });
|
|
68
|
-
if (!res.ok) {
|
|
69
|
-
const body = await res.text().catch(() => '');
|
|
70
|
-
throw new Error(`fetchLinkedInPosts HTTP ${res.status}: ${body}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const json = await res.json();
|
|
74
|
-
if (json.serviceErrorCode || json.code) {
|
|
75
|
-
throw new Error(`fetchLinkedInPosts API error: ${JSON.stringify(json)}`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return json.elements ?? [];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Fetches share statistics (impressions, likes, comments, shares) for a post.
|
|
83
|
-
*
|
|
84
|
-
* LinkedIn's analytics APIs have significant restrictions for personal accounts vs company pages.
|
|
85
|
-
* Strategy:
|
|
86
|
-
* 1. Try the organizational entity share statistics endpoint (works for company pages).
|
|
87
|
-
* 2. Fall back to /v2/socialMetadata (works for personal member posts).
|
|
88
|
-
*
|
|
89
|
-
* @param {string} token - LinkedIn OAuth access token.
|
|
90
|
-
* @param {string} postUrn - Post URN, e.g. "urn:li:share:XXXXX" or "urn:li:ugcPost:XXXXX".
|
|
91
|
-
* @returns {Promise<object>} Normalized stats: { impressions, likes, comments, shares }.
|
|
92
|
-
*/
|
|
93
|
-
async function fetchPostAnalytics(token, postUrn) {
|
|
94
|
-
if (!token) throw new Error('fetchPostAnalytics: token is required');
|
|
95
|
-
if (!postUrn) throw new Error('fetchPostAnalytics: postUrn is required');
|
|
96
|
-
|
|
97
|
-
// Attempt 1: Organizational entity share statistics (company pages / pages with analytics).
|
|
98
|
-
const orgStatsUrl =
|
|
99
|
-
`${LI_REST_BASE}/organizationalEntityShareStatistics` +
|
|
100
|
-
`?q=organizationalEntity&shares=List(${encodeURIComponent(postUrn)})`;
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
const res = await fetch(orgStatsUrl, { headers: buildRestHeaders(token) });
|
|
104
|
-
if (res.ok) {
|
|
105
|
-
const json = await res.json();
|
|
106
|
-
const el = (json.elements ?? [])[0];
|
|
107
|
-
if (el) {
|
|
108
|
-
const stats = el.totalShareStatistics ?? {};
|
|
109
|
-
console.log(`[linkedin] Got org share stats for ${postUrn}`);
|
|
110
|
-
return {
|
|
111
|
-
impressions: toInt(stats.impressionCount),
|
|
112
|
-
likes: toInt(stats.likeCount),
|
|
113
|
-
comments: toInt(stats.commentCount),
|
|
114
|
-
shares: toInt(stats.shareCount),
|
|
115
|
-
clicks: toInt(stats.clickCount),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
console.warn(`[linkedin] Org share stats error for ${postUrn} (trying fallback): ${err.message}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Attempt 2: socialMetadata — available for personal member posts.
|
|
124
|
-
const socialMetaUrl = `${LI_V2_BASE}/socialMetadata/${encodeURIComponent(postUrn)}`;
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
const res = await fetch(socialMetaUrl, { headers: buildV2Headers(token) });
|
|
128
|
-
if (res.ok) {
|
|
129
|
-
const json = await res.json();
|
|
130
|
-
console.log(`[linkedin] Got socialMetadata for ${postUrn}`);
|
|
131
|
-
return {
|
|
132
|
-
impressions: 0, // socialMetadata does not expose impression counts.
|
|
133
|
-
likes: toInt(json.numLikes ?? json.likes?.paging?.total ?? 0),
|
|
134
|
-
comments: toInt(json.numComments ?? json.comments?.paging?.total ?? 0),
|
|
135
|
-
shares: toInt(json.numShares ?? json.shares?.paging?.total ?? 0),
|
|
136
|
-
clicks: 0,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const body = await res.text().catch(() => '');
|
|
140
|
-
console.warn(`[linkedin] socialMetadata HTTP ${res.status} for ${postUrn}: ${body}`);
|
|
141
|
-
} catch (err) {
|
|
142
|
-
console.warn(`[linkedin] socialMetadata error for ${postUrn}: ${err.message}`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Both endpoints failed — return zeroed stats so polling continues.
|
|
146
|
-
return { impressions: 0, likes: 0, comments: 0, shares: 0, clicks: 0 };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Fetches the authenticated member's basic profile information.
|
|
151
|
-
*
|
|
152
|
-
* @param {string} token - LinkedIn OAuth access token.
|
|
153
|
-
* @returns {Promise<object>} Profile object with id, localizedFirstName, localizedLastName, etc.
|
|
154
|
-
*/
|
|
155
|
-
async function fetchLinkedInProfile(token) {
|
|
156
|
-
if (!token) throw new Error('fetchLinkedInProfile: token is required');
|
|
157
|
-
|
|
158
|
-
// Try /v2/userinfo first (works with openid+profile scopes), fall back to /v2/me.
|
|
159
|
-
for (const url of [`${LI_V2_BASE}/userinfo`, `${LI_V2_BASE}/me`]) {
|
|
160
|
-
const res = await fetch(url, { headers: buildV2Headers(token) });
|
|
161
|
-
if (!res.ok) {
|
|
162
|
-
const body = await res.text().catch(() => '');
|
|
163
|
-
console.warn(`[linkedin] ${url} HTTP ${res.status}: ${body.slice(0, 120)}`);
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
const json = await res.json();
|
|
167
|
-
if (json.serviceErrorCode) {
|
|
168
|
-
console.warn(`[linkedin] ${url} API error: ${JSON.stringify(json).slice(0, 120)}`);
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
return json;
|
|
172
|
-
}
|
|
173
|
-
throw new Error('fetchLinkedInProfile: all endpoints failed');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Fetches the network/connection size for a member or company.
|
|
178
|
-
*
|
|
179
|
-
* For company pages, uses CompanyFollowedByMember edgeType.
|
|
180
|
-
* For personal accounts the networkSizes endpoint returns connection count
|
|
181
|
-
* using MEMBER_TO_MEMBER_CONNECTION edgeType.
|
|
182
|
-
*
|
|
183
|
-
* LinkedIn limits this to the authenticated member's own network size
|
|
184
|
-
* due to privacy restrictions.
|
|
185
|
-
*
|
|
186
|
-
* @param {string} token - LinkedIn OAuth access token.
|
|
187
|
-
* @param {string} personUrn - Member or organization URN.
|
|
188
|
-
* @returns {Promise<number>} Follower / connection count.
|
|
189
|
-
*/
|
|
190
|
-
async function fetchFollowerCount(token, personUrn) {
|
|
191
|
-
if (!token) throw new Error('fetchFollowerCount: token is required');
|
|
192
|
-
if (!personUrn) throw new Error('fetchFollowerCount: personUrn is required');
|
|
193
|
-
|
|
194
|
-
// Determine edge type based on URN type.
|
|
195
|
-
const isOrg = personUrn.includes('urn:li:organization:');
|
|
196
|
-
const edgeType = isOrg
|
|
197
|
-
? 'CompanyFollowedByMember'
|
|
198
|
-
: 'MEMBER_TO_MEMBER_CONNECTION';
|
|
199
|
-
|
|
200
|
-
const url =
|
|
201
|
-
`${LI_V2_BASE}/networkSizes/${encodeURIComponent(personUrn)}` +
|
|
202
|
-
`?edgeType=${edgeType}`;
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
const res = await fetch(url, { headers: buildV2Headers(token) });
|
|
206
|
-
if (!res.ok) {
|
|
207
|
-
const body = await res.text().catch(() => '');
|
|
208
|
-
console.warn(`[linkedin] fetchFollowerCount HTTP ${res.status}: ${body}`);
|
|
209
|
-
return 0;
|
|
210
|
-
}
|
|
211
|
-
const json = await res.json();
|
|
212
|
-
// Response shape: { firstDegreeSize: N } or { followerCount: N }
|
|
213
|
-
return toInt(json.firstDegreeSize ?? json.followerCount ?? 0);
|
|
214
|
-
} catch (err) {
|
|
215
|
-
console.warn(`[linkedin] fetchFollowerCount error: ${err.message}`);
|
|
216
|
-
return 0;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Main entry point. Polls LinkedIn for recent posts and per-post analytics,
|
|
222
|
-
* normalises the data, and upserts it into the local SQLite database.
|
|
223
|
-
*
|
|
224
|
-
* Also records a follower snapshot for today.
|
|
225
|
-
*
|
|
226
|
-
* @param {import('better-sqlite3').Database} db - Initialised db instance.
|
|
227
|
-
*/
|
|
228
|
-
async function pollLinkedIn(db) {
|
|
229
|
-
const token = process.env.LINKEDIN_ACCESS_TOKEN;
|
|
230
|
-
const personUrn = process.env.LINKEDIN_PERSON_URN;
|
|
231
|
-
|
|
232
|
-
if (!token) throw new Error('LINKEDIN_ACCESS_TOKEN is not set');
|
|
233
|
-
if (!personUrn) throw new Error('LINKEDIN_PERSON_URN is not set');
|
|
234
|
-
|
|
235
|
-
const { upsertMetric, upsertFollowerSnapshot } = require('../store');
|
|
236
|
-
|
|
237
|
-
const fetchedAt = new Date().toISOString();
|
|
238
|
-
const today = fetchedAt.slice(0, 10);
|
|
239
|
-
|
|
240
|
-
console.log(`[linkedin] Starting poll for ${personUrn}`);
|
|
241
|
-
|
|
242
|
-
let posts = [];
|
|
243
|
-
try {
|
|
244
|
-
posts = await fetchLinkedInPosts(token, personUrn);
|
|
245
|
-
console.log(`[linkedin] Got ${posts.length} posts`);
|
|
246
|
-
} catch (err) {
|
|
247
|
-
// 403 = token lacks r_member_social scope; 426 = version expired.
|
|
248
|
-
// Either way, skip posts but still collect follower count.
|
|
249
|
-
console.warn(`[linkedin] Posts fetch failed (non-fatal): ${err.message}`);
|
|
250
|
-
console.warn('[linkedin] To read posts, re-authorize with r_member_social scope.');
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
for (const post of posts) {
|
|
254
|
-
// Post URN is at post.id for the Posts API (urn:li:share:... or urn:li:ugcPost:...).
|
|
255
|
-
const postUrn = post.id ?? post.urn ?? '';
|
|
256
|
-
if (!postUrn) {
|
|
257
|
-
console.warn('[linkedin] Post missing id/urn, skipping');
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const analytics = await fetchPostAnalytics(token, postUrn);
|
|
262
|
-
|
|
263
|
-
// Determine content type: article vs standard post.
|
|
264
|
-
const hasArticle = !!(post.content?.article);
|
|
265
|
-
const contentType = hasArticle ? 'article' : 'post';
|
|
266
|
-
|
|
267
|
-
// Published time: Posts API returns createdAt as milliseconds epoch.
|
|
268
|
-
let publishedAt = null;
|
|
269
|
-
if (post.createdAt) {
|
|
270
|
-
publishedAt = new Date(post.createdAt).toISOString();
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const record = {
|
|
274
|
-
platform: 'linkedin',
|
|
275
|
-
content_type: contentType,
|
|
276
|
-
post_id: postUrn,
|
|
277
|
-
post_url: post.content?.article?.source ?? null,
|
|
278
|
-
published_at: publishedAt,
|
|
279
|
-
metric_date: today,
|
|
280
|
-
impressions: analytics.impressions,
|
|
281
|
-
reach: 0,
|
|
282
|
-
likes: analytics.likes,
|
|
283
|
-
comments: analytics.comments,
|
|
284
|
-
shares: analytics.shares,
|
|
285
|
-
saves: 0,
|
|
286
|
-
clicks: analytics.clicks,
|
|
287
|
-
video_views: 0,
|
|
288
|
-
followers_delta: 0,
|
|
289
|
-
extra_json: JSON.stringify({
|
|
290
|
-
commentary_snippet: (post.commentary ?? '').slice(0, 120),
|
|
291
|
-
visibility: post.visibility ?? null,
|
|
292
|
-
lifecycle_state: post.lifecycleState ?? null,
|
|
293
|
-
}),
|
|
294
|
-
fetched_at: fetchedAt,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
upsertMetric(db, record);
|
|
298
|
-
console.log(`[linkedin] Upserted metric for post ${postUrn} (${contentType})`);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Follower / connection snapshot.
|
|
302
|
-
try {
|
|
303
|
-
console.log('[linkedin] Fetching follower/connection count…');
|
|
304
|
-
const followerCount = await fetchFollowerCount(token, personUrn);
|
|
305
|
-
upsertFollowerSnapshot(db, {
|
|
306
|
-
platform: 'linkedin',
|
|
307
|
-
follower_count: followerCount,
|
|
308
|
-
snapshot_date: today,
|
|
309
|
-
});
|
|
310
|
-
console.log(`[linkedin] Upserted follower snapshot: ${followerCount}`);
|
|
311
|
-
} catch (err) {
|
|
312
|
-
console.warn(`[linkedin] Follower snapshot error (non-fatal): ${err.message}`);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
console.log('[linkedin] Poll complete.');
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
module.exports = {
|
|
319
|
-
fetchLinkedInPosts,
|
|
320
|
-
fetchPostAnalytics,
|
|
321
|
-
fetchLinkedInProfile,
|
|
322
|
-
fetchFollowerCount,
|
|
323
|
-
pollLinkedIn,
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
// Allow running directly: node scripts/social-analytics/pollers/linkedin.js
|
|
327
|
-
if (require.main === module) {
|
|
328
|
-
(async () => {
|
|
329
|
-
const { initDb } = require('../store');
|
|
330
|
-
const db = initDb();
|
|
331
|
-
try {
|
|
332
|
-
await pollLinkedIn(db);
|
|
333
|
-
} catch (err) {
|
|
334
|
-
console.error('[linkedin] Fatal error:', err.message);
|
|
335
|
-
process.exit(1);
|
|
336
|
-
} finally {
|
|
337
|
-
db.close();
|
|
338
|
-
}
|
|
339
|
-
})();
|
|
340
|
-
}
|