@startsimpli/ui 0.4.81 → 0.4.82
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.82",
|
|
4
4
|
"description": "Shared UI components package for StartSimpli applications",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
44
44
|
"react": "^18.0.0 || ^19.0.0",
|
|
45
45
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
46
|
-
"@startsimpli/
|
|
47
|
-
"@startsimpli/
|
|
46
|
+
"@startsimpli/auth": "^0.4.31",
|
|
47
|
+
"@startsimpli/api": "^0.5.51"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@startsimpli/api": {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AccountActivityPanel — the PLATFORM-SCOPE activity composer
|
|
5
|
+
* (startsim-768w.19.1.5).
|
|
6
|
+
*
|
|
7
|
+
* The same event stream as `ActivityFeedPanel` renders for one foundry, at the
|
|
8
|
+
* scope ABOVE any foundry: the rows that belong to no single one of them.
|
|
9
|
+
* Sign-ins are the whole population today — central auth mints tokens for every
|
|
10
|
+
* app, so a login is recorded once, for the person, with an empty tenant slug.
|
|
11
|
+
* A user with access to N foundries would otherwise get N duplicate rows or one
|
|
12
|
+
* arbitrarily-attributed one; the row is right, and it needed a reader with a
|
|
13
|
+
* scope of its own.
|
|
14
|
+
*
|
|
15
|
+
* DELIBERATELY ALMOST NOTHING. The paging, filtering, day grouping, infinite
|
|
16
|
+
* scroll and three empty states are `ActivityFeedPanel`'s, and the rendering is
|
|
17
|
+
* `ActivityTimeline`'s — both already built to render whatever the stream
|
|
18
|
+
* returns and to humanise an action they have never seen. What this adds is the
|
|
19
|
+
* COPY: an account-scope surface has to say why its rows name no foundry, and
|
|
20
|
+
* has to describe an empty page without claiming nothing happened, because the
|
|
21
|
+
* server answers a caller who may not read sign-ins with an empty page rather
|
|
22
|
+
* than a 403. Every prop stays overridable — a host that wants different words
|
|
23
|
+
* passes them, it does not fork the panel.
|
|
24
|
+
*
|
|
25
|
+
* The consuming app supplies `{ list: (p) => api.foundry.accountActivity(p) }`
|
|
26
|
+
* and its theme classNames. Nothing else — rule #9.
|
|
27
|
+
*/
|
|
28
|
+
import { ActivityFeedPanel, type ActivityFeedPanelProps } from './ActivityFeedPanel';
|
|
29
|
+
|
|
30
|
+
/** Same props as the feed it composes: there is no account-only knob, and a
|
|
31
|
+
* `slug` would be a lie — these events have no foundry. */
|
|
32
|
+
export type AccountActivityPanelProps = ActivityFeedPanelProps;
|
|
33
|
+
|
|
34
|
+
/** Cache namespace for the platform-scope stream. Deliberately NOT under a
|
|
35
|
+
* foundry key, so invalidating one foundry never refetches it and vice versa. */
|
|
36
|
+
export const ACCOUNT_ACTIVITY_QUERY_KEY = ['account', 'activity'] as const;
|
|
37
|
+
|
|
38
|
+
export function AccountActivityPanel(props: AccountActivityPanelProps) {
|
|
39
|
+
return (
|
|
40
|
+
<ActivityFeedPanel
|
|
41
|
+
queryKey={ACCOUNT_ACTIVITY_QUERY_KEY}
|
|
42
|
+
title="Account activity"
|
|
43
|
+
description="Sign-ins across your account, newest first. These belong to the person rather than to one foundry, so they live here instead of on a foundry's own Activity tab."
|
|
44
|
+
// NOT "nothing has happened": an admin, member or viewer gets an empty
|
|
45
|
+
// page rather than a 403 (a 403 would confirm the rows exist), so copy
|
|
46
|
+
// that asserted the stream was empty would be wrong for most readers.
|
|
47
|
+
emptyTitle="No account activity to show"
|
|
48
|
+
emptyDescription="Sign-ins show up here. Sign-in history — who signed in, when and from where — is visible to foundry owners."
|
|
49
|
+
filteredEmptyTitle="No account activity matches these filters"
|
|
50
|
+
filteredEmptyDescription="Widen the date range or clear a filter to see more."
|
|
51
|
+
errorTitle="Could not load account activity"
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* startsim-768w.19.1.5 (RED) — the PLATFORM-SCOPE activity surface.
|
|
3
|
+
*
|
|
4
|
+
* `record_login()` writes a `member_login` row for every successful sign-in,
|
|
5
|
+
* with `tenant_slug=""` because a control-plane login belongs to the PERSON, not
|
|
6
|
+
* to one of the N foundries they can reach. The only reader was the per-foundry
|
|
7
|
+
* feed, which filters by slug — so the row was captured, permissioned and
|
|
8
|
+
* unreachable in every UI.
|
|
9
|
+
*
|
|
10
|
+
* THE SURFACE IS A CONSUMER, NOT A SECOND FEED. Everything here already exists:
|
|
11
|
+
* `ActivityFeedPanel` (paging, filters, day grouping, three empty states) over
|
|
12
|
+
* `ActivityTimeline` (the primitive), both built to render whatever the stream
|
|
13
|
+
* returns and to humanise an action they have never seen. The account scope
|
|
14
|
+
* differs by ONE thing — which client call it makes — plus the copy that says
|
|
15
|
+
* why these rows name no foundry. A second timeline here would be the bug.
|
|
16
|
+
*/
|
|
17
|
+
import * as fs from 'node:fs'
|
|
18
|
+
import * as path from 'node:path'
|
|
19
|
+
import { render, screen, waitFor, within } from '@testing-library/react'
|
|
20
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
AccountActivityPanel,
|
|
24
|
+
activityLabel,
|
|
25
|
+
activityTarget,
|
|
26
|
+
toActivityTimelineItems,
|
|
27
|
+
type ActivityEvent,
|
|
28
|
+
type ActivityPage,
|
|
29
|
+
type ActivityQuery,
|
|
30
|
+
} from '../index'
|
|
31
|
+
|
|
32
|
+
function login(over: Partial<ActivityEvent> & { id: string }): ActivityEvent {
|
|
33
|
+
return {
|
|
34
|
+
action: 'member_login',
|
|
35
|
+
type: 'member_login',
|
|
36
|
+
target_type: 'user',
|
|
37
|
+
target_id: '3f1c9e40-2b7a-4a11-9c33-8f0b2a5d61ee',
|
|
38
|
+
metadata: { app: 'foundry', method: 'credentials', user_agent: 'Firefox/141.0' },
|
|
39
|
+
actor: { id: 'u-1', email: 'ada@x.com', name: 'Ada Lovelace' },
|
|
40
|
+
actor_email: 'ada@x.com',
|
|
41
|
+
state: null,
|
|
42
|
+
previous_state: null,
|
|
43
|
+
source: '',
|
|
44
|
+
reason: '',
|
|
45
|
+
error: '',
|
|
46
|
+
run_id: '',
|
|
47
|
+
run_kind: '',
|
|
48
|
+
created_at: '2026-07-27T19:38:00Z',
|
|
49
|
+
...over,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function page(results: ActivityEvent[], over: Partial<ActivityPage> = {}): ActivityPage {
|
|
54
|
+
return { count: results.length, next: null, previous: null, results, ...over }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function withQuery(ui: React.ReactElement) {
|
|
58
|
+
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
59
|
+
return render(<QueryClientProvider client={qc}>{ui}</QueryClientProvider>)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function timeline() {
|
|
63
|
+
return within(screen.getByTestId('activity-timeline'))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe('AccountActivityPanel', () => {
|
|
67
|
+
it('renders a login the per-foundry feed could never reach', async () => {
|
|
68
|
+
const list = jest.fn(async () => page([login({ id: 'e1' })]))
|
|
69
|
+
withQuery(<AccountActivityPanel client={{ list }} />)
|
|
70
|
+
|
|
71
|
+
await waitFor(() => expect(timeline().getByText('Member login')).toBeInTheDocument())
|
|
72
|
+
expect(timeline().getByText('Ada Lovelace')).toBeInTheDocument()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('says which app the sign-in was for', async () => {
|
|
76
|
+
const list = jest.fn(async () => page([login({ id: 'e2' })]))
|
|
77
|
+
withQuery(<AccountActivityPanel client={{ list }} />)
|
|
78
|
+
|
|
79
|
+
// `app` is the row's own descriptor for what it touched. Without it the
|
|
80
|
+
// target app is captured on the row and invisible on the page — the same
|
|
81
|
+
// shape of bug one level down.
|
|
82
|
+
await waitFor(() => expect(timeline().getByText('foundry')).toBeInTheDocument())
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('pages server-side (rule #8) rather than asking for everything', async () => {
|
|
86
|
+
const list = jest.fn(async (_p: ActivityQuery) => page([login({ id: 'e3' })]))
|
|
87
|
+
withQuery(<AccountActivityPanel client={{ list }} />)
|
|
88
|
+
|
|
89
|
+
await waitFor(() => expect(list).toHaveBeenCalled())
|
|
90
|
+
const params = list.mock.calls[0][0] as ActivityQuery
|
|
91
|
+
expect(params.page).toBe(1)
|
|
92
|
+
expect(typeof params.pageSize).toBe('number')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('takes no slug — the events belong to no foundry', () => {
|
|
96
|
+
const list = jest.fn(async () => page([]))
|
|
97
|
+
// A slug prop would be a type error; the runtime check is that the panel
|
|
98
|
+
// renders from the injected client alone.
|
|
99
|
+
withQuery(<AccountActivityPanel client={{ list }} />)
|
|
100
|
+
expect(screen.getByTestId('activity-feed-panel')).toBeInTheDocument()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('explains an empty page without claiming nothing happened', async () => {
|
|
104
|
+
const list = jest.fn(async () => page([]))
|
|
105
|
+
withQuery(<AccountActivityPanel client={{ list }} />)
|
|
106
|
+
|
|
107
|
+
// An admin/member/viewer gets an empty page rather than a 403, so the copy
|
|
108
|
+
// must not assert "no sign-ins have happened".
|
|
109
|
+
await screen.findByText(/no account activity/i)
|
|
110
|
+
const body = screen.getByTestId('activity-feed-panel').textContent ?? ''
|
|
111
|
+
expect(body).toMatch(/sign-in/i)
|
|
112
|
+
expect(body).toMatch(/owner/i)
|
|
113
|
+
expect(body).not.toMatch(/nothing recorded/i)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('lets a host override the shared copy', async () => {
|
|
117
|
+
const list = jest.fn(async () => page([]))
|
|
118
|
+
withQuery(<AccountActivityPanel client={{ list }} title="Sign-in history" />)
|
|
119
|
+
await waitFor(() => expect(screen.getByText('Sign-in history')).toBeInTheDocument())
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
describe('the platform scope reuses the shared feed', () => {
|
|
124
|
+
it('humanises member_login with no new vocabulary', () => {
|
|
125
|
+
expect(activityLabel(login({ id: 'e4' }))).toBe('Member login')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('renders the app instead of the opaque user id', () => {
|
|
129
|
+
expect(activityTarget(login({ id: 'e5' }))).toBe('foundry')
|
|
130
|
+
// No app on the row -> nothing, never the UUID.
|
|
131
|
+
expect(activityTarget(login({ id: 'e6', metadata: { method: 'sso' } }))).toBe('')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('maps a login onto the same timeline item shape as any other row', () => {
|
|
135
|
+
const [item] = toActivityTimelineItems([login({ id: 'e7' })])
|
|
136
|
+
expect(item.title).toBe('Member login')
|
|
137
|
+
expect(item.actor?.email).toBe('ada@x.com')
|
|
138
|
+
expect(item.occurredAt).toBe('2026-07-27T19:38:00Z')
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('does not render its own list — it composes ActivityFeedPanel', () => {
|
|
142
|
+
const src = fs.readFileSync(
|
|
143
|
+
path.resolve(__dirname, '..', 'AccountActivityPanel.tsx'), 'utf8')
|
|
144
|
+
expect(src).toMatch(/<ActivityFeedPanel/)
|
|
145
|
+
// No list of its own, no second query, no second timeline. (The doc comment
|
|
146
|
+
// may NAME the timeline; what it may not do is import or render one.)
|
|
147
|
+
const banned = [/\.map\(/, /useInfiniteQuery/, /<ActivityTimeline/,
|
|
148
|
+
/from '\.\.\/ActivityTimeline'/]
|
|
149
|
+
for (const re of banned) {
|
|
150
|
+
expect(`${re.source}:${re.test(src)}`).toBe(`${re.source}:false`)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
})
|
|
@@ -132,6 +132,11 @@ const OPAQUE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
|
|
|
132
132
|
*/
|
|
133
133
|
const TARGET_DESCRIPTORS = [
|
|
134
134
|
'email', 'name', 'title', 'label', 'source', 'source_name',
|
|
135
|
+
// `app` is what a platform-scope row touched: a sign-in records which app it
|
|
136
|
+
// minted a token for, and its `target_id` is the actor's own UUID, so without
|
|
137
|
+
// this key the app is captured on the row and invisible on the page
|
|
138
|
+
// (startsim-768w.19.1.5). Same convention, not a login special case.
|
|
139
|
+
'app',
|
|
135
140
|
'repo', 'slug', 'path', 'source_key', 'provider_key', 'credential_type',
|
|
136
141
|
];
|
|
137
142
|
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
* never seen rather than dropping or mislabelling it.
|
|
13
13
|
*/
|
|
14
14
|
export { ActivityFeedPanel, type ActivityFeedPanelProps } from './ActivityFeedPanel';
|
|
15
|
+
export {
|
|
16
|
+
AccountActivityPanel,
|
|
17
|
+
ACCOUNT_ACTIVITY_QUERY_KEY,
|
|
18
|
+
type AccountActivityPanelProps,
|
|
19
|
+
} from './AccountActivityPanel';
|
|
15
20
|
export {
|
|
16
21
|
ACTIVITY_FEED_PANEL_DEFAULTS,
|
|
17
22
|
type ActivityFeedPanelClassNames,
|