twenty-app-intake 0.2.1 → 0.4.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 +293 -8
- package/manifest.json +419 -667
- package/package.json +6 -9
- package/public/cover.generated.png +0 -0
- package/src/front-components/dashboard.mjs +19 -21947
- package/src/front-components/dashboard.mjs.map +4 -4
- package/src/front-components/dashboard.tsx +118 -0
- package/src/front-components/settings-panel.mjs +19 -22103
- package/src/front-components/settings-panel.mjs.map +4 -4
- package/src/front-components/settings-panel.tsx +304 -0
- package/src/front-components/source-panel.mjs +20 -21962
- package/src/front-components/source-panel.mjs.map +4 -4
- package/src/front-components/source-panel.tsx +113 -0
- package/src/logic-functions/check-silence.mjs +263 -0
- package/src/logic-functions/check-silence.mjs.map +7 -0
- package/src/logic-functions/check-silence.ts +52 -0
- package/src/logic-functions/contract.mjs +507 -0
- package/src/logic-functions/contract.mjs.map +7 -0
- package/src/logic-functions/contract.ts +172 -0
- package/src/logic-functions/health.mjs +125 -5
- package/src/logic-functions/health.mjs.map +3 -3
- package/src/logic-functions/health.ts +62 -0
- package/src/logic-functions/quarantine-discard.mjs +380 -0
- package/src/logic-functions/quarantine-discard.mjs.map +7 -0
- package/src/logic-functions/quarantine-discard.ts +65 -0
- package/src/logic-functions/quarantine-list.mjs +211 -0
- package/src/logic-functions/quarantine-list.mjs.map +7 -0
- package/src/logic-functions/quarantine-list.ts +93 -0
- package/src/logic-functions/quarantine-release.mjs +1974 -0
- package/src/logic-functions/quarantine-release.mjs.map +7 -0
- package/src/logic-functions/quarantine-release.ts +94 -0
- package/src/logic-functions/register.mjs +34 -1
- package/src/logic-functions/register.mjs.map +2 -2
- package/src/logic-functions/register.ts +105 -0
- package/src/logic-functions/replay-bulk.mjs +2040 -0
- package/src/logic-functions/replay-bulk.mjs.map +7 -0
- package/src/logic-functions/replay-bulk.ts +83 -0
- package/src/logic-functions/replay-log.mjs +1987 -0
- package/src/logic-functions/replay-log.mjs.map +7 -0
- package/src/logic-functions/replay-log.ts +54 -0
- package/src/logic-functions/retry.mjs +1004 -248
- package/src/logic-functions/retry.mjs.map +4 -4
- package/src/logic-functions/retry.ts +101 -0
- package/src/logic-functions/test-ingest.mjs +616 -28
- package/src/logic-functions/test-ingest.mjs.map +4 -4
- package/src/logic-functions/test-ingest.ts +179 -0
- package/src/logic-functions/webhook.mjs +968 -209
- package/src/logic-functions/webhook.mjs.map +4 -4
- package/src/logic-functions/webhook.ts +58 -0
- package/src/post-install.mjs +34 -1
- package/src/post-install.mjs.map +2 -2
- package/src/post-install.ts +81 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineFrontComponent } from 'twenty-sdk/define';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
type SourceStat = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
status: string;
|
|
9
|
+
totalIngested: number;
|
|
10
|
+
lastIngestedAt: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type LogStat = {
|
|
14
|
+
status: string;
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Dashboard: React.FC = () => {
|
|
19
|
+
const [sources, setSources] = useState<SourceStat[]>([]);
|
|
20
|
+
const [logStats, setLogStats] = useState<LogStat[]>([]);
|
|
21
|
+
const [loading, setLoading] = useState(true);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const apiUrl = (window as any).__TWENTY_API_URL__ ?? '';
|
|
25
|
+
const token = (window as any).__TWENTY_API_TOKEN__ ?? '';
|
|
26
|
+
|
|
27
|
+
const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' };
|
|
28
|
+
|
|
29
|
+
const query = (q: string) =>
|
|
30
|
+
fetch(`${apiUrl}/graphql`, { method: 'POST', headers, body: JSON.stringify({ query: q }) })
|
|
31
|
+
.then(r => r.json());
|
|
32
|
+
|
|
33
|
+
Promise.all([
|
|
34
|
+
query(`{ intakeSources(first: 20, orderBy: { lastIngestedAt: DescNullsLast }) { edges { node { id name slug status totalIngested lastIngestedAt } } } }`),
|
|
35
|
+
query(`{ intakeLogs(first: 200) { edges { node { status } } } }`),
|
|
36
|
+
]).then(([srcRes, logRes]) => {
|
|
37
|
+
setSources((srcRes.data?.intakeSources?.edges ?? []).map((e: any) => e.node));
|
|
38
|
+
const counts: Record<string, number> = {};
|
|
39
|
+
for (const e of (logRes.data?.intakeLogs?.edges ?? [])) {
|
|
40
|
+
counts[e.node.status] = (counts[e.node.status] ?? 0) + 1;
|
|
41
|
+
}
|
|
42
|
+
setLogStats(Object.entries(counts).map(([status, count]) => ({ status, count })));
|
|
43
|
+
}).finally(() => setLoading(false));
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const statusColor = (s: string) => s === 'ACTIVE' ? '#22c55e' : '#f59e0b';
|
|
47
|
+
const logColor = (s: string) =>
|
|
48
|
+
s === 'SUCCESS' ? '#22c55e' : s === 'PARTIAL' ? '#f59e0b' : s === 'FAILED' ? '#ef4444' : '#6b7280';
|
|
49
|
+
|
|
50
|
+
if (loading) return <div style={{ padding: 24, color: '#6b7280' }}>Loading...</div>;
|
|
51
|
+
|
|
52
|
+
const total = logStats.reduce((s, l) => s + l.count, 0);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div style={{ padding: 24, fontFamily: 'system-ui, sans-serif', maxWidth: 800 }}>
|
|
56
|
+
<h2 style={{ margin: '0 0 4px', fontSize: 18, fontWeight: 600 }}>Intake</h2>
|
|
57
|
+
<p style={{ margin: '0 0 24px', color: '#6b7280', fontSize: 14 }}>
|
|
58
|
+
{sources.length} source{sources.length !== 1 ? 's' : ''} · {total} total ingestions
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
{/* Log stats */}
|
|
62
|
+
{logStats.length > 0 && (
|
|
63
|
+
<div style={{ display: 'flex', gap: 12, marginBottom: 28, flexWrap: 'wrap' }}>
|
|
64
|
+
{logStats.map(l => (
|
|
65
|
+
<div key={l.status} style={{
|
|
66
|
+
background: '#f9fafb', border: '1px solid #e5e7eb', borderRadius: 8,
|
|
67
|
+
padding: '10px 16px', minWidth: 100,
|
|
68
|
+
}}>
|
|
69
|
+
<div style={{ fontSize: 22, fontWeight: 700, color: logColor(l.status) }}>{l.count}</div>
|
|
70
|
+
<div style={{ fontSize: 12, color: '#6b7280', marginTop: 2 }}>{l.status}</div>
|
|
71
|
+
</div>
|
|
72
|
+
))}
|
|
73
|
+
</div>
|
|
74
|
+
)}
|
|
75
|
+
|
|
76
|
+
{/* Sources table */}
|
|
77
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13 }}>
|
|
78
|
+
<thead>
|
|
79
|
+
<tr style={{ borderBottom: '2px solid #e5e7eb' }}>
|
|
80
|
+
{['Source', 'Slug', 'Status', 'Ingested', 'Last Active'].map(h => (
|
|
81
|
+
<th key={h} style={{ textAlign: 'left', padding: '6px 8px', color: '#6b7280', fontWeight: 500 }}>{h}</th>
|
|
82
|
+
))}
|
|
83
|
+
</tr>
|
|
84
|
+
</thead>
|
|
85
|
+
<tbody>
|
|
86
|
+
{sources.map(s => (
|
|
87
|
+
<tr key={s.id} style={{ borderBottom: '1px solid #f3f4f6' }}>
|
|
88
|
+
<td style={{ padding: '8px', fontWeight: 500 }}>{s.name}</td>
|
|
89
|
+
<td style={{ padding: '8px', fontFamily: 'monospace', color: '#6b7280', fontSize: 12 }}>{s.slug}</td>
|
|
90
|
+
<td style={{ padding: '8px' }}>
|
|
91
|
+
<span style={{
|
|
92
|
+
background: s.status === 'ACTIVE' ? '#dcfce7' : '#fef3c7',
|
|
93
|
+
color: statusColor(s.status), borderRadius: 4, padding: '2px 6px', fontSize: 11, fontWeight: 600,
|
|
94
|
+
}}>{s.status}</span>
|
|
95
|
+
</td>
|
|
96
|
+
<td style={{ padding: '8px', textAlign: 'right' }}>{s.totalIngested ?? 0}</td>
|
|
97
|
+
<td style={{ padding: '8px', color: '#6b7280', fontSize: 12 }}>
|
|
98
|
+
{s.lastIngestedAt ? new Date(s.lastIngestedAt).toLocaleString() : '—'}
|
|
99
|
+
</td>
|
|
100
|
+
</tr>
|
|
101
|
+
))}
|
|
102
|
+
{sources.length === 0 && (
|
|
103
|
+
<tr><td colSpan={5} style={{ padding: 24, textAlign: 'center', color: '#6b7280' }}>
|
|
104
|
+
No sources yet — use the registration endpoint to add one.
|
|
105
|
+
</td></tr>
|
|
106
|
+
)}
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default defineFrontComponent({
|
|
114
|
+
universalIdentifier: '7a3f8b12-c4d9-4e1a-b2f5-8c6d0e9f1a2b',
|
|
115
|
+
name: 'intake-dashboard',
|
|
116
|
+
description: 'Intake sources and ingestion statistics',
|
|
117
|
+
component: Dashboard,
|
|
118
|
+
});
|