Skip to content

Commit 5c847d3

Browse files
committed
ref(twitter): compose setup from web domains
- use fixed OAuth capabilities and ordinary Source, Cron, and Job models - separate Bookmark Source selection, creation, and scheduling in the wizard - publish the immutable Web Distribution as 0.2.1
1 parent b56b6fb commit 5c847d3

7 files changed

Lines changed: 426 additions & 287 deletions

File tree

‎apps/client-web/src/twitter-setup-api.spec.ts‎

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest'
2-
import { Peer, PeerManager, type ExtensionStatePort, type InstalledExtension } from '@inkcre/core'
2+
import {
3+
Cron,
4+
Peer,
5+
PeerManager,
6+
Source,
7+
SourceForm,
8+
type ExtensionStatePort,
9+
type InstalledExtension,
10+
} from '@inkcre/core'
311
import {
412
discoverCoreCandidates,
513
OAuthTransactionSchema,
14+
TwitterBookmarkSetup,
615
TwitterSetupAPI,
716
TwitterSetupStatusSchema,
817
} from '../../../extensions/twitter/src/setup-api'
918

1019
const corePeerId = '00000000-0000-4000-8000-000000000002'
1120
const installed: InstalledExtension = {
1221
name: 'inkcre/twitter',
13-
version: '0.2.0',
22+
version: '0.2.1',
1423
enabled: [corePeerId],
1524
nickname: 'Twitter',
1625
config: {},
@@ -28,7 +37,7 @@ const corePeer = Peer.parse({
2837
inbound: { protocol: 'core.peer.protocol.http.v1', parameters: {} },
2938
},
3039
{
31-
id: 'inkcre.twitter.setup.v1',
40+
id: 'inkcre.twitter.setup.status.v1',
3241
inbound: { protocol: 'core.peer.protocol.http.v1', parameters: {} },
3342
},
3443
],
@@ -70,20 +79,14 @@ describe('Twitter Peer setup API', () => {
7079
handle: null,
7180
scopes: [],
7281
reconnect_required: false,
73-
bookmark_source_id: null,
74-
bookmark_cron_id: null,
75-
bookmark_sources: [],
76-
collect_at: { day_of_week: null, hour: 0, minute: 0 },
77-
bookmark_source_ready: false,
78-
ready: false,
7982
},
8083
})
8184

8285
await new TwitterSetupAPI(corePeer).status()
8386

8487
expect(delegate).toHaveBeenCalledWith(
85-
'inkcre.twitter.setup.v1',
86-
{ body: { action: 'get_status' } },
88+
'inkcre.twitter.setup.status.v1',
89+
{ body: {} },
8790
corePeerId
8891
)
8992
})
@@ -100,12 +103,6 @@ describe('Twitter Peer setup API', () => {
100103
handle: null,
101104
scopes: [],
102105
reconnect_required: false,
103-
bookmark_source_id: null,
104-
bookmark_cron_id: null,
105-
bookmark_sources: [],
106-
collect_at: { day_of_week: null, hour: 0, minute: 0 },
107-
bookmark_source_ready: false,
108-
ready: false,
109106
})
110107
).toThrow('HTTP or HTTPS')
111108
expect(() =>
@@ -127,4 +124,49 @@ describe('Twitter Peer setup API', () => {
127124
})
128125
).toThrow('embedded credentials')
129126
})
127+
128+
it('composes bookmark Source, Cron, and initial Job through ordinary database models', async () => {
129+
const source = Source.parse({
130+
id: 25,
131+
type: 'extensions.twitter.bookmark.Source',
132+
nickname: 'Bookmarks',
133+
config: {},
134+
state: {},
135+
storage: null,
136+
block: null,
137+
created_at: '2026-01-01T00:00:00Z',
138+
updated_at: '2026-01-01T00:00:00Z',
139+
})
140+
const cron = Cron.parse({
141+
id: 9,
142+
schedule: '30 6 * * *',
143+
enabled: false,
144+
job_type: 'core.source.collect.v1',
145+
job_parameters: { source: 25, config: { full: false, result_limit: 40 } },
146+
job_timeout_seconds: null,
147+
last_job: null,
148+
last_scheduled_for: null,
149+
created_at: '2026-01-01T00:00:00Z',
150+
updated_at: '2026-01-01T00:00:00Z',
151+
})
152+
vi.spyOn(Source, 'getAll').mockResolvedValue([source])
153+
vi.spyOn(Cron, 'getBySource').mockResolvedValue([cron])
154+
vi.spyOn(SourceForm.prototype, 'create').mockResolvedValue(source)
155+
const update = vi
156+
.spyOn(Cron.prototype, 'update')
157+
.mockImplementation(async (form) =>
158+
Cron.parse({ ...cron, ...form, id: cron.id, enabled: form.enabled })
159+
)
160+
const runNow = vi.spyOn(Cron.prototype, 'runNow').mockResolvedValue({} as never)
161+
162+
await expect(TwitterBookmarkSetup.read()).resolves.toMatchObject({ source, cron })
163+
await expect(TwitterBookmarkSetup.createSource('Bookmarks')).resolves.toBe(source)
164+
const scheduled = await TwitterBookmarkSetup.saveSchedule(source, 7, 15)
165+
expect(update).toHaveBeenLastCalledWith(
166+
expect.objectContaining({ schedule: '15 7 * * *', enabled: false })
167+
)
168+
await TwitterBookmarkSetup.finish(source, scheduled)
169+
expect(update).toHaveBeenLastCalledWith(expect.objectContaining({ enabled: true }))
170+
expect(runNow).toHaveBeenCalledOnce()
171+
})
130172
})

‎extensions/twitter/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"nickname": "Twitter",
3737
"module_federation": {
3838
"host_sdk": "@inkcre/core",
39-
"host_sdk_version": ">=0.1.0 <0.2.0"
39+
"host_sdk_version": ">=0.1.2 <0.2.0"
4040
}
4141
}
4242
}

‎extensions/twitter/src/components/twitterSetupWizard/twitterSetupWizard.scss‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
display: flex;
2121
align-items: center;
2222
gap: 0.4rem;
23-
color: #6b7280;
23+
color: sys-var(color, text, muted);
2424
font-size: 0.8rem;
2525
}
2626

@@ -35,7 +35,7 @@
3535

3636
.is-current,
3737
.is-complete {
38-
color: #2563eb;
38+
color: sys-var(color, info, base);
3939
font-weight: 600;
4040
}
4141
}
@@ -58,20 +58,36 @@
5858
}
5959
}
6060

61+
&__section,
62+
&__empty {
63+
display: grid;
64+
gap: sys-var(space, sm);
65+
padding: sys-var(space, md);
66+
border: 1px solid sys-var(color, border, base);
67+
background: sys-var(color, surface, subtle);
68+
69+
h4,
70+
p {
71+
margin: 0;
72+
}
73+
}
74+
75+
&__hint {
76+
color: sys-var(color, text, subtle);
77+
}
78+
6179
&__field,
6280
&__schedule label {
6381
display: grid;
6482
gap: 0.35rem;
6583
}
6684

67-
select,
68-
input {
85+
&__field input {
6986
min-height: 2.5rem;
70-
padding: 0.5rem;
71-
border: 1px solid #d1d5db;
72-
border-radius: 0.35rem;
73-
background: transparent;
74-
color: inherit;
87+
padding: sys-var(space, sm);
88+
border: 1px solid sys-var(color, border, base);
89+
background: sys-var(color, surface, base);
90+
color: sys-var(color, text, base);
7591
}
7692

7793
&__schedule,
@@ -94,7 +110,7 @@
94110

95111
&__error {
96112
margin: 0;
97-
color: #b91c1c;
113+
color: sys-var(color, danger, base);
98114
}
99115

100116
dl {

0 commit comments

Comments
 (0)