@lobu/cli 6.0.1 → 7.0.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.
- package/README.md +20 -27
- package/dist/bundled-skills/lobu/SKILL.md +11 -11
- package/dist/commands/_lib/apply/apply-cmd.d.ts +38 -0
- package/dist/commands/_lib/apply/apply-cmd.d.ts.map +1 -1
- package/dist/commands/_lib/apply/apply-cmd.js +574 -40
- package/dist/commands/_lib/apply/apply-cmd.js.map +1 -1
- package/dist/commands/_lib/apply/client.d.ts +180 -1
- package/dist/commands/_lib/apply/client.d.ts.map +1 -1
- package/dist/commands/_lib/apply/client.js +308 -28
- package/dist/commands/_lib/apply/client.js.map +1 -1
- package/dist/commands/_lib/apply/desired-state.d.ts +134 -3
- package/dist/commands/_lib/apply/desired-state.d.ts.map +1 -1
- package/dist/commands/_lib/apply/desired-state.js +703 -89
- package/dist/commands/_lib/apply/desired-state.js.map +1 -1
- package/dist/commands/_lib/apply/diff.d.ts +61 -3
- package/dist/commands/_lib/apply/diff.d.ts.map +1 -1
- package/dist/commands/_lib/apply/diff.js +382 -92
- package/dist/commands/_lib/apply/diff.js.map +1 -1
- package/dist/commands/_lib/apply/prompt.d.ts +6 -0
- package/dist/commands/_lib/apply/prompt.d.ts.map +1 -1
- package/dist/commands/_lib/apply/prompt.js +16 -0
- package/dist/commands/_lib/apply/prompt.js.map +1 -1
- package/dist/commands/_lib/apply/render.d.ts +9 -0
- package/dist/commands/_lib/apply/render.d.ts.map +1 -1
- package/dist/commands/_lib/apply/render.js +80 -3
- package/dist/commands/_lib/apply/render.js.map +1 -1
- package/dist/commands/agent.d.ts +7 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +65 -1
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/chat.d.ts +12 -9
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +125 -57
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/dev.d.ts +23 -7
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +197 -49
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +136 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/eval.d.ts +8 -0
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +72 -6
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/init.d.ts +22 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +355 -182
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts +11 -0
- package/dist/commands/link.d.ts.map +1 -0
- package/dist/commands/link.js +28 -0
- package/dist/commands/link.js.map +1 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +14 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/memory/_lib/browser-auth-cmd.d.ts.map +1 -1
- package/dist/commands/memory/_lib/browser-auth-cmd.js +3 -3
- package/dist/commands/memory/_lib/browser-auth-cmd.js.map +1 -1
- package/dist/commands/memory/_lib/mcp.d.ts +2 -2
- package/dist/commands/memory/_lib/mcp.d.ts.map +1 -1
- package/dist/commands/memory/_lib/mcp.js +24 -12
- package/dist/commands/memory/_lib/mcp.js.map +1 -1
- package/dist/commands/memory/_lib/openclaw-auth.d.ts +1 -0
- package/dist/commands/memory/_lib/openclaw-auth.d.ts.map +1 -1
- package/dist/commands/memory/_lib/openclaw-auth.js +14 -3
- package/dist/commands/memory/_lib/openclaw-auth.js.map +1 -1
- package/dist/commands/memory/_lib/openclaw-cmd.js +1 -1
- package/dist/commands/memory/_lib/openclaw-cmd.js.map +1 -1
- package/dist/commands/memory/_lib/schema.d.ts +29 -2
- package/dist/commands/memory/_lib/schema.d.ts.map +1 -1
- package/dist/commands/memory/_lib/schema.js +121 -5
- package/dist/commands/memory/_lib/schema.js.map +1 -1
- package/dist/commands/memory/_lib/seed-cmd.d.ts.map +1 -1
- package/dist/commands/memory/_lib/seed-cmd.js +46 -24
- package/dist/commands/memory/_lib/seed-cmd.js.map +1 -1
- package/dist/commands/memory/run.d.ts.map +1 -1
- package/dist/commands/memory/run.js +2 -2
- package/dist/commands/memory/run.js.map +1 -1
- package/dist/commands/org.d.ts +4 -0
- package/dist/commands/org.d.ts.map +1 -1
- package/dist/commands/org.js +10 -0
- package/dist/commands/org.js.map +1 -1
- package/dist/commands/platforms/platform-prompts.d.ts +0 -1
- package/dist/commands/platforms/platform-prompts.d.ts.map +1 -1
- package/dist/commands/platforms/platform-prompts.js +54 -8
- package/dist/commands/platforms/platform-prompts.js.map +1 -1
- package/dist/commands/telemetry.d.ts +10 -0
- package/dist/commands/telemetry.d.ts.map +1 -0
- package/dist/commands/telemetry.js +68 -0
- package/dist/commands/telemetry.js.map +1 -0
- package/dist/commands/token.d.ts +9 -0
- package/dist/commands/token.d.ts.map +1 -1
- package/dist/commands/token.js +54 -0
- package/dist/commands/token.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/connectors/README.md +534 -0
- package/dist/connectors/__tests__/browser-scraper-utils.test.ts +186 -0
- package/dist/connectors/apple_health.ts +138 -0
- package/dist/connectors/apple_screen_time.ts +82 -0
- package/dist/connectors/browser-scraper-utils.ts +246 -0
- package/dist/connectors/capterra.ts +277 -0
- package/dist/connectors/g2.ts +290 -0
- package/dist/connectors/github.ts +1530 -0
- package/dist/connectors/glassdoor.ts +295 -0
- package/dist/connectors/gmaps.ts +197 -0
- package/dist/connectors/google_calendar.ts +641 -0
- package/dist/connectors/google_gmail.ts +754 -0
- package/dist/connectors/google_photos.ts +776 -0
- package/dist/connectors/google_play.ts +349 -0
- package/dist/connectors/hackernews.ts +471 -0
- package/dist/connectors/index.ts +28 -0
- package/dist/connectors/ios_appstore.ts +226 -0
- package/dist/connectors/linkedin.ts +494 -0
- package/dist/connectors/local_directory.ts +91 -0
- package/dist/connectors/microsoft_outlook.ts +410 -0
- package/dist/connectors/producthunt.ts +471 -0
- package/dist/connectors/reddit.ts +600 -0
- package/dist/connectors/revolut.ts +572 -0
- package/dist/connectors/rss.ts +448 -0
- package/dist/connectors/spotify.ts +590 -0
- package/dist/connectors/trustpilot.ts +203 -0
- package/dist/connectors/website.ts +629 -0
- package/dist/connectors/whatsapp.ts +1081 -0
- package/dist/connectors/whatsapp_local.ts +125 -0
- package/dist/connectors/x.ts +536 -0
- package/dist/connectors/youtube.ts +666 -0
- package/dist/db/migrations/00000000000000_baseline.sql +4867 -0
- package/dist/db/migrations/20260405193000_add_mcp_sessions.sql +33 -0
- package/dist/db/migrations/20260408120000_remove_system_connectors.sql +48 -0
- package/dist/db/migrations/20260408120001_optional_compiled_code.sql +6 -0
- package/dist/db/migrations/20260409110000_add_active_watcher_run_index.sql +9 -0
- package/dist/db/migrations/20260409130000_connector_default_config.sql +5 -0
- package/dist/db/migrations/20260410120000_add_agent_secrets.sql +25 -0
- package/dist/db/migrations/20260413170000_add_watcher_group_id.sql +67 -0
- package/dist/db/migrations/20260416120000_add_entity_wa_jid_index.sql +14 -0
- package/dist/db/migrations/20260417100000_add_entity_identities.sql +77 -0
- package/dist/db/migrations/20260418100000_add_auth_runs.sql +83 -0
- package/dist/db/migrations/20260418110000_add_runs_created_by_user.sql +18 -0
- package/dist/db/migrations/20260419120000_add_event_identity_indexes.sql +56 -0
- package/dist/db/migrations/20260420120000_extend_reserved_org_slugs.sql +56 -0
- package/dist/db/migrations/20260424030000_add_watcher_run_correlation.sql +52 -0
- package/dist/db/migrations/20260424130000_relax_events_client_id_fk.sql +47 -0
- package/dist/db/migrations/20260425100000_normalize_watcher_feedback.sql +91 -0
- package/dist/db/migrations/20260425120000_add_run_diagnostics.sql +20 -0
- package/dist/db/migrations/20260425130000_add_repair_agent_plumbing.sql +46 -0
- package/dist/db/migrations/20260426120000_entities_entity_type_fk.sql +101 -0
- package/dist/db/migrations/20260426130000_db_integrity_cleanup.sql +104 -0
- package/dist/db/migrations/20260426130001_db_integrity_cleanup_concurrent.sql +187 -0
- package/dist/db/migrations/20260427133000_events_created_by_nullable.sql +74 -0
- package/dist/db/migrations/20260427140000_identity_engine_indexes.sql +140 -0
- package/dist/db/migrations/20260427150000_drop_events_source_id.sql +177 -0
- package/dist/db/migrations/20260427160000_drop_dead_schema.sql +76 -0
- package/dist/db/migrations/20260427170000_market_founder_to_member.sql +364 -0
- package/dist/db/migrations/20260428040000_cascade_events_watchers_org_fk.sql +66 -0
- package/dist/db/migrations/20260428050000_add_runs_approved_input.sql +9 -0
- package/dist/db/migrations/20260429010000_auth_profile_tenant_scoped_fk.sql +79 -0
- package/dist/db/migrations/20260429060000_extend_runs_for_lobu_queue.sql +108 -0
- package/dist/db/migrations/20260429120000_agent_changed_notify.sql +97 -0
- package/dist/db/migrations/20260429120100_user_auth_profiles_and_model_prefs.sql +36 -0
- package/dist/db/migrations/20260429120200_fix_notify_old_keys.sql +130 -0
- package/dist/db/migrations/20260429130000_oauth_states_cli_sessions_rate_limits.sql +83 -0
- package/dist/db/migrations/20260429140000_phase8_grants_chat_connections_mcp_sessions.sql +84 -0
- package/dist/db/migrations/20260429140100_runs_priority_expires_at_retry_delay.sql +44 -0
- package/dist/db/migrations/20260429180000_drop_invalidatable_cache_triggers.sql +25 -0
- package/dist/db/migrations/20260430005614_agents_apply_fields.sql +21 -0
- package/dist/db/migrations/20260430022231_fix_connection_config_encryption.sql +69 -0
- package/dist/db/migrations/20260430151215_add_task_run_type.sql +77 -0
- package/dist/db/migrations/20260501000000_drop_cli_sessions.sql +27 -0
- package/dist/db/migrations/20260501133000_lobu_memory_mcp_id.sql +117 -0
- package/dist/db/migrations/20260502000000_drop_chat_connections.sql +60 -0
- package/dist/db/migrations/20260503000000_agent_secrets_org_scope.sql +56 -0
- package/dist/db/migrations/20260504000000_flatten_agents_drop_sandbox_model.sql +48 -0
- package/dist/db/migrations/20260510220000_connector_required_capability.sql +47 -0
- package/dist/db/migrations/20260512000000_device_worker_connection_binding.sql +113 -0
- package/dist/db/migrations/20260512131703_connections_slug.sql +131 -0
- package/dist/db/migrations/20260513000000_chat_user_identities.sql +24 -0
- package/dist/db/migrations/20260513120000_auth_profiles_device_binding.sql +50 -0
- package/dist/db/migrations/20260513150000_auth_profiles_cdp_url.sql +43 -0
- package/dist/db/migrations/20260513200000_notifications_as_events.sql +86 -0
- package/dist/db/migrations/20260514000000_scheduled_jobs.sql +97 -0
- package/dist/db/migrations/20260514120000_auth_profiles_connector_key_nullable.sql +42 -0
- package/dist/eval/types.d.ts +2 -0
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +210 -132
- package/dist/index.js.map +1 -1
- package/dist/internal/api-client.d.ts +4 -8
- package/dist/internal/api-client.d.ts.map +1 -1
- package/dist/internal/api-client.js +1 -1
- package/dist/internal/api-client.js.map +1 -1
- package/dist/internal/context.js +2 -2
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/credentials.d.ts.map +1 -1
- package/dist/internal/credentials.js +6 -1
- package/dist/internal/credentials.js.map +1 -1
- package/dist/internal/gateway-url.d.ts +14 -0
- package/dist/internal/gateway-url.d.ts.map +1 -1
- package/dist/internal/gateway-url.js +19 -0
- package/dist/internal/gateway-url.js.map +1 -1
- package/dist/internal/index.d.ts +3 -4
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +3 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/oauth.d.ts +6 -5
- package/dist/internal/oauth.d.ts.map +1 -1
- package/dist/internal/oauth.js +2 -2
- package/dist/internal/project-link.d.ts +10 -0
- package/dist/internal/project-link.d.ts.map +1 -0
- package/dist/internal/project-link.js +48 -0
- package/dist/internal/project-link.js.map +1 -0
- package/dist/providers.json +2 -2
- package/dist/server.bundle.mjs +31654 -30866
- package/dist/start-local.bundle.mjs +74409 -0
- package/dist/templates/README.md.tmpl +10 -11
- package/dist/templates/TESTING.md.tmpl +9 -9
- package/package.json +15 -13
- package/dist/__tests__/chat.integration.test.d.ts +0 -2
- package/dist/__tests__/chat.integration.test.d.ts.map +0 -1
- package/dist/__tests__/chat.integration.test.js +0 -337
- package/dist/__tests__/chat.integration.test.js.map +0 -1
- package/dist/__tests__/dev.test.d.ts +0 -2
- package/dist/__tests__/dev.test.d.ts.map +0 -1
- package/dist/__tests__/dev.test.js +0 -25
- package/dist/__tests__/dev.test.js.map +0 -1
- package/dist/__tests__/init-memory.test.d.ts +0 -2
- package/dist/__tests__/init-memory.test.d.ts.map +0 -1
- package/dist/__tests__/init-memory.test.js +0 -45
- package/dist/__tests__/init-memory.test.js.map +0 -1
- package/dist/__tests__/token.test.d.ts +0 -2
- package/dist/__tests__/token.test.d.ts.map +0 -1
- package/dist/__tests__/token.test.js +0 -52
- package/dist/__tests__/token.test.js.map +0 -1
- package/dist/commands/_lib/apply/__tests__/client.test.d.ts +0 -2
- package/dist/commands/_lib/apply/__tests__/client.test.d.ts.map +0 -1
- package/dist/commands/_lib/apply/__tests__/client.test.js +0 -23
- package/dist/commands/_lib/apply/__tests__/client.test.js.map +0 -1
- package/dist/commands/_lib/apply/__tests__/desired-state.test.d.ts +0 -2
- package/dist/commands/_lib/apply/__tests__/desired-state.test.d.ts.map +0 -1
- package/dist/commands/_lib/apply/__tests__/desired-state.test.js +0 -140
- package/dist/commands/_lib/apply/__tests__/desired-state.test.js.map +0 -1
- package/dist/commands/_lib/apply/__tests__/diff.test.d.ts +0 -2
- package/dist/commands/_lib/apply/__tests__/diff.test.d.ts.map +0 -1
- package/dist/commands/_lib/apply/__tests__/diff.test.js +0 -378
- package/dist/commands/_lib/apply/__tests__/diff.test.js.map +0 -1
- package/dist/commands/apply.d.ts +0 -3
- package/dist/commands/apply.d.ts.map +0 -1
- package/dist/commands/apply.js +0 -5
- package/dist/commands/apply.js.map +0 -1
- package/dist/commands/memory/_lib/openclaw-auth.test.d.ts +0 -2
- package/dist/commands/memory/_lib/openclaw-auth.test.d.ts.map +0 -1
- package/dist/commands/memory/_lib/openclaw-auth.test.js +0 -9
- package/dist/commands/memory/_lib/openclaw-auth.test.js.map +0 -1
- package/dist/internal/__tests__/api-client.test.d.ts +0 -2
- package/dist/internal/__tests__/api-client.test.d.ts.map +0 -1
- package/dist/internal/__tests__/api-client.test.js +0 -95
- package/dist/internal/__tests__/api-client.test.js.map +0 -1
- package/dist/internal/__tests__/context.test.d.ts +0 -2
- package/dist/internal/__tests__/context.test.d.ts.map +0 -1
- package/dist/internal/__tests__/context.test.js +0 -77
- package/dist/internal/__tests__/context.test.js.map +0 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iOS App Store Connector (V1 runtime)
|
|
3
|
+
*
|
|
4
|
+
* Fetches app reviews from the Apple App Store via RSS feeds.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
type ActionContext,
|
|
9
|
+
type ActionResult,
|
|
10
|
+
type ConnectorDefinition,
|
|
11
|
+
ConnectorRuntime,
|
|
12
|
+
calculateEngagementScore,
|
|
13
|
+
type EventEnvelope,
|
|
14
|
+
type SyncContext,
|
|
15
|
+
type SyncResult,
|
|
16
|
+
} from '@lobu/connector-sdk';
|
|
17
|
+
|
|
18
|
+
const IOS_HEADERS: Record<string, string> = {
|
|
19
|
+
'User-Agent':
|
|
20
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
21
|
+
Accept: 'application/json, text/plain, */*',
|
|
22
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
23
|
+
Referer: 'https://apps.apple.com/',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
interface IOSCheckpoint {
|
|
27
|
+
last_timestamp?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface RSSFeed {
|
|
31
|
+
feed?: {
|
|
32
|
+
entry?: RSSEntry | RSSEntry[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface RSSEntry {
|
|
37
|
+
id?: { label?: string };
|
|
38
|
+
title?: { label?: string };
|
|
39
|
+
content?: { label?: string };
|
|
40
|
+
author?: { name?: { label?: string } };
|
|
41
|
+
updated?: { label?: string };
|
|
42
|
+
link?: { attributes?: { href?: string } };
|
|
43
|
+
'im:rating'?: { label?: string };
|
|
44
|
+
'im:voteSum'?: { label?: string };
|
|
45
|
+
'im:voteCount'?: { label?: string };
|
|
46
|
+
'im:version'?: { label?: string };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const FEED_CONFIG_SCHEMA = {
|
|
50
|
+
type: 'object',
|
|
51
|
+
required: ['app_id', 'country'],
|
|
52
|
+
properties: {
|
|
53
|
+
app_id: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
minLength: 1,
|
|
56
|
+
description: 'iOS App Store ID (e.g., "324684580")',
|
|
57
|
+
},
|
|
58
|
+
country: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
minLength: 2,
|
|
61
|
+
maxLength: 2,
|
|
62
|
+
pattern: '^[A-Z]{2}$',
|
|
63
|
+
description: 'ISO country code (e.g., "US")',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
} as const;
|
|
67
|
+
|
|
68
|
+
export default class IOSAppStoreConnector extends ConnectorRuntime {
|
|
69
|
+
readonly definition: ConnectorDefinition = {
|
|
70
|
+
key: 'ios_appstore',
|
|
71
|
+
name: 'iOS App Store',
|
|
72
|
+
description: 'Fetches app reviews from the Apple App Store via RSS feeds.',
|
|
73
|
+
version: '1.0.0',
|
|
74
|
+
faviconDomain: 'apple.com',
|
|
75
|
+
authSchema: {
|
|
76
|
+
methods: [{ type: 'none' }],
|
|
77
|
+
},
|
|
78
|
+
feeds: {
|
|
79
|
+
reviews: {
|
|
80
|
+
key: 'reviews',
|
|
81
|
+
name: 'App Reviews',
|
|
82
|
+
description: 'Fetch reviews for an iOS app.',
|
|
83
|
+
configSchema: FEED_CONFIG_SCHEMA,
|
|
84
|
+
eventKinds: {
|
|
85
|
+
review: {
|
|
86
|
+
description: 'An iOS App Store review',
|
|
87
|
+
metadataSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
rating: { type: 'number', description: 'Star rating (1-5)' },
|
|
91
|
+
vote_sum: { type: 'number', description: 'Net helpful votes' },
|
|
92
|
+
vote_count: { type: 'number', description: 'Total vote count' },
|
|
93
|
+
version: { type: 'string', description: 'App version reviewed' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
optionsSchema: FEED_CONFIG_SCHEMA,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
async sync(ctx: SyncContext): Promise<SyncResult> {
|
|
104
|
+
const appId = ctx.config.app_id as string;
|
|
105
|
+
const country = ctx.config.country as string;
|
|
106
|
+
const checkpoint = (ctx.checkpoint ?? {}) as IOSCheckpoint;
|
|
107
|
+
const lastTimestamp = checkpoint.last_timestamp ? new Date(checkpoint.last_timestamp) : null;
|
|
108
|
+
|
|
109
|
+
const MAX_PAGES = 10;
|
|
110
|
+
const allReviews: RSSEntry[] = [];
|
|
111
|
+
let shouldContinue = true;
|
|
112
|
+
|
|
113
|
+
for (let page = 1; shouldContinue && page <= MAX_PAGES; page++) {
|
|
114
|
+
const rssUrl = `https://itunes.apple.com/${country}/rss/customerreviews/page=${page}/id=${appId}/sortby=mostrecent/json`;
|
|
115
|
+
|
|
116
|
+
const response = await fetch(rssUrl, { headers: IOS_HEADERS });
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
if (page === 1) {
|
|
119
|
+
throw new Error(`RSS feed returned ${response.status}: ${rssUrl}`);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let rssData: RSSFeed;
|
|
125
|
+
try {
|
|
126
|
+
rssData = await response.json();
|
|
127
|
+
} catch {
|
|
128
|
+
if (page === 1) {
|
|
129
|
+
const text = await response.text();
|
|
130
|
+
throw new Error(`RSS feed returned invalid JSON: ${text.substring(0, 100)}`);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const rawEntries = rssData.feed?.entry;
|
|
136
|
+
const feedEntries: RSSEntry[] = Array.isArray(rawEntries)
|
|
137
|
+
? rawEntries
|
|
138
|
+
: rawEntries
|
|
139
|
+
? [rawEntries]
|
|
140
|
+
: [];
|
|
141
|
+
|
|
142
|
+
if (feedEntries.length === 0) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Filter out the first entry on page 1 if it lacks im:rating (app metadata entry)
|
|
147
|
+
const reviews = feedEntries.filter((entry, index) => {
|
|
148
|
+
if (page === 1 && index === 0 && !entry['im:rating']) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return !!entry['im:rating'];
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (reviews.length === 0) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Check if the oldest review on this page is older than or equal to the checkpoint
|
|
159
|
+
if (lastTimestamp) {
|
|
160
|
+
const oldestReviewDate = new Date(reviews[reviews.length - 1].updated?.label || Date.now());
|
|
161
|
+
if (oldestReviewDate <= lastTimestamp) {
|
|
162
|
+
// Add only reviews newer than the checkpoint and stop
|
|
163
|
+
allReviews.push(
|
|
164
|
+
...reviews.filter((r) => new Date(r.updated?.label || Date.now()) > lastTimestamp)
|
|
165
|
+
);
|
|
166
|
+
shouldContinue = false;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
allReviews.push(...reviews);
|
|
172
|
+
|
|
173
|
+
// 1 second delay between pages
|
|
174
|
+
if (shouldContinue && page < MAX_PAGES) {
|
|
175
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Transform reviews to EventEnvelope format
|
|
180
|
+
const appUrl = `https://apps.apple.com/${country.toLowerCase()}/app/id${appId}`;
|
|
181
|
+
|
|
182
|
+
const events: EventEnvelope[] = allReviews.map((review) => {
|
|
183
|
+
const rating = parseInt(review['im:rating']?.label || '0', 10);
|
|
184
|
+
const title = review.title?.label || '';
|
|
185
|
+
const body = review.content?.label || '';
|
|
186
|
+
const content = title ? `${title}\n\n${body}` : body;
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
origin_id: review.id?.label || '',
|
|
190
|
+
payload_text: content,
|
|
191
|
+
author_name: review.author?.name?.label || undefined,
|
|
192
|
+
occurred_at: new Date(review.updated?.label || Date.now()),
|
|
193
|
+
origin_type: 'review',
|
|
194
|
+
score: calculateEngagementScore('ios_appstore', { rating }),
|
|
195
|
+
source_url: review.link?.attributes?.href || appUrl,
|
|
196
|
+
metadata: {
|
|
197
|
+
rating,
|
|
198
|
+
vote_sum: parseInt(review['im:voteSum']?.label || '0', 10),
|
|
199
|
+
vote_count: parseInt(review['im:voteCount']?.label || '0', 10),
|
|
200
|
+
version: review['im:version']?.label,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Sort descending by occurred_at
|
|
206
|
+
events.sort((a, b) => b.occurred_at.getTime() - a.occurred_at.getTime());
|
|
207
|
+
|
|
208
|
+
// Build new checkpoint from the most recent event
|
|
209
|
+
const newCheckpoint: IOSCheckpoint =
|
|
210
|
+
events.length > 0
|
|
211
|
+
? { last_timestamp: events[0].occurred_at.toISOString() }
|
|
212
|
+
: { last_timestamp: checkpoint.last_timestamp };
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
events,
|
|
216
|
+
checkpoint: newCheckpoint as Record<string, unknown>,
|
|
217
|
+
metadata: {
|
|
218
|
+
items_found: allReviews.length,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async execute(_ctx: ActionContext): Promise<ActionResult> {
|
|
224
|
+
return { success: false, error: 'Actions not supported' };
|
|
225
|
+
}
|
|
226
|
+
}
|