@shipfox/client-workspace-settings 2.0.0 → 4.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +53 -0
- package/dist/components/members/workspace-members-section.d.ts.map +1 -1
- package/dist/components/members/workspace-members-section.js +4 -4
- package/dist/components/members/workspace-members-section.js.map +1 -1
- package/dist/core/invitation.d.ts +15 -0
- package/dist/core/invitation.d.ts.map +1 -0
- package/dist/core/invitation.js +3 -0
- package/dist/core/invitation.js.map +1 -0
- package/dist/hooks/api/create-invitation.d.ts +2 -13
- package/dist/hooks/api/create-invitation.d.ts.map +1 -1
- package/dist/hooks/api/create-invitation.js +12 -9
- package/dist/hooks/api/create-invitation.js.map +1 -1
- package/dist/hooks/api/invitation-mapper.d.ts +4 -0
- package/dist/hooks/api/invitation-mapper.d.ts.map +1 -0
- package/dist/hooks/api/invitation-mapper.js +15 -0
- package/dist/hooks/api/invitation-mapper.js.map +1 -0
- package/dist/hooks/api/list-invitations.d.ts +10 -13
- package/dist/hooks/api/list-invitations.d.ts.map +1 -1
- package/dist/hooks/api/list-invitations.js +11 -5
- package/dist/hooks/api/list-invitations.js.map +1 -1
- package/dist/hooks/api/revoke-invitation.js +2 -4
- package/dist/hooks/api/revoke-invitation.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +11 -31
- package/src/components/members/workspace-members-section.tsx +6 -11
- package/src/core/invitation.ts +15 -0
- package/src/hooks/api/create-invitation.ts +20 -10
- package/src/hooks/api/invitation-mapper.test.ts +29 -0
- package/src/hooks/api/invitation-mapper.ts +16 -0
- package/src/hooks/api/list-invitations.ts +17 -7
- package/src/hooks/api/revoke-invitation.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/client-workspace-settings",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@swc/helpers": "^0.5.17",
|
|
33
33
|
"@tanstack/react-form": "^1.32.0",
|
|
34
|
-
"@shipfox/client-agent": "2.0.0",
|
|
35
34
|
"@shipfox/api-workspaces-dto": "6.0.0",
|
|
36
|
-
"@shipfox/client-
|
|
37
|
-
"@shipfox/client-api": "
|
|
38
|
-
"@shipfox/client-
|
|
39
|
-
"@shipfox/client-
|
|
40
|
-
"@shipfox/client-
|
|
41
|
-
"@shipfox/client-
|
|
42
|
-
"@shipfox/client-
|
|
43
|
-
"@shipfox/client-
|
|
44
|
-
"@shipfox/
|
|
35
|
+
"@shipfox/client-agent": "4.0.0",
|
|
36
|
+
"@shipfox/client-api": "4.0.0",
|
|
37
|
+
"@shipfox/client-auth": "4.0.0",
|
|
38
|
+
"@shipfox/client-integrations": "4.0.0",
|
|
39
|
+
"@shipfox/client-runners": "4.0.0",
|
|
40
|
+
"@shipfox/client-shell": "4.0.0",
|
|
41
|
+
"@shipfox/client-secrets": "4.0.0",
|
|
42
|
+
"@shipfox/client-triggers": "4.0.0",
|
|
43
|
+
"@shipfox/client-ui": "4.0.0",
|
|
44
|
+
"@shipfox/react-ui": "0.3.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@tanstack/react-query": "^5.101.0",
|
|
@@ -49,26 +49,6 @@
|
|
|
49
49
|
"react": "^19.0.0",
|
|
50
50
|
"react-dom": "^19.0.0"
|
|
51
51
|
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@tanstack/react-query": "^5.101.0",
|
|
54
|
-
"@tanstack/react-router": "^1.170.16",
|
|
55
|
-
"@testing-library/jest-dom": "^6.6.3",
|
|
56
|
-
"@testing-library/react": "^16.3.2",
|
|
57
|
-
"@testing-library/user-event": "^14.6.1",
|
|
58
|
-
"@types/react": "^19.1.11",
|
|
59
|
-
"@types/react-dom": "^19.1.7",
|
|
60
|
-
"jotai": "^2.19.1",
|
|
61
|
-
"jsdom": "^29.0.0",
|
|
62
|
-
"react": "^19.1.1",
|
|
63
|
-
"react-dom": "^19.1.1",
|
|
64
|
-
"@shipfox/biome": "1.8.2",
|
|
65
|
-
"@shipfox/client-test-setup": "0.0.3",
|
|
66
|
-
"@shipfox/swc": "1.2.6",
|
|
67
|
-
"@shipfox/vite": "1.2.5",
|
|
68
|
-
"@shipfox/vitest": "1.2.3",
|
|
69
|
-
"@shipfox/typescript": "1.1.7",
|
|
70
|
-
"@shipfox/ts-config": "1.3.8"
|
|
71
|
-
},
|
|
72
52
|
"scripts": {
|
|
73
53
|
"build": "shipfox-swc",
|
|
74
54
|
"check": "shipfox-biome-check",
|
|
@@ -31,6 +31,7 @@ import {Code, Header, Text} from '@shipfox/react-ui/typography';
|
|
|
31
31
|
import {formatDate} from '@shipfox/react-ui/utils';
|
|
32
32
|
import {useForm} from '@tanstack/react-form';
|
|
33
33
|
import {useState} from 'react';
|
|
34
|
+
import type {Invitation} from '#core/invitation.js';
|
|
34
35
|
import {useCreateInvitation} from '#hooks/api/create-invitation.js';
|
|
35
36
|
import {useListInvitations} from '#hooks/api/list-invitations.js';
|
|
36
37
|
import {useListMembers} from '#hooks/api/list-members.js';
|
|
@@ -194,7 +195,7 @@ function PendingInvitationsSection({
|
|
|
194
195
|
workspaceName: string;
|
|
195
196
|
}) {
|
|
196
197
|
const query = useListInvitations(workspaceId);
|
|
197
|
-
const invitations = query.data
|
|
198
|
+
const invitations = query.data ?? [];
|
|
198
199
|
const [inviteOpen, setInviteOpen] = useState(false);
|
|
199
200
|
|
|
200
201
|
return (
|
|
@@ -249,16 +250,10 @@ function PendingInvitationsSection({
|
|
|
249
250
|
);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
function InvitationRow({
|
|
253
|
-
invitation,
|
|
254
|
-
workspaceId,
|
|
255
|
-
}: {
|
|
256
|
-
invitation: import('@shipfox/api-workspaces-dto').InvitationDto;
|
|
257
|
-
workspaceId: string;
|
|
258
|
-
}) {
|
|
253
|
+
function InvitationRow({invitation, workspaceId}: {invitation: Invitation; workspaceId: string}) {
|
|
259
254
|
const [open, setOpen] = useState(false);
|
|
260
255
|
const revoke = useRevokeInvitation(workspaceId);
|
|
261
|
-
const expiresAt = new Date(invitation.
|
|
256
|
+
const expiresAt = new Date(invitation.expiresAt);
|
|
262
257
|
const expiresSoon = expiresAt.getTime() - Date.now() < EXPIRES_SOON_MS;
|
|
263
258
|
|
|
264
259
|
async function handleRevoke() {
|
|
@@ -276,10 +271,10 @@ function InvitationRow({
|
|
|
276
271
|
<TableCell>
|
|
277
272
|
<Code variant="paragraph">{invitation.email}</Code>
|
|
278
273
|
</TableCell>
|
|
279
|
-
<TableCell>{invitation.
|
|
274
|
+
<TableCell>{invitation.invitedByDisplay ?? '—'}</TableCell>
|
|
280
275
|
<TableCell>
|
|
281
276
|
<div className="flex items-center gap-8">
|
|
282
|
-
<Text size="sm">{formatDate(invitation.
|
|
277
|
+
<Text size="sm">{formatDate(invitation.expiresAt)}</Text>
|
|
283
278
|
{expiresSoon ? <Badge variant="warning">Soon</Badge> : null}
|
|
284
279
|
</div>
|
|
285
280
|
</TableCell>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Invitation {
|
|
2
|
+
id: string;
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
expiresAt: string;
|
|
6
|
+
acceptedAt: string | null;
|
|
7
|
+
invitedByUserId: string;
|
|
8
|
+
invitedByDisplay: string | null;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CreateInvitationCommand {
|
|
14
|
+
email: string;
|
|
15
|
+
}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import {invitationDtoSchema} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import {checkedApiRequest} from '@shipfox/client-api';
|
|
3
3
|
import {useMutation, useQueryClient} from '@tanstack/react-query';
|
|
4
|
-
import {
|
|
4
|
+
import type {CreateInvitationCommand, Invitation} from '#core/invitation.js';
|
|
5
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
6
|
+
import {listInvitationsQueryOptions} from './list-invitations.js';
|
|
5
7
|
|
|
6
|
-
async function createInvitation(params: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
async function createInvitation(params: {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
command: CreateInvitationCommand;
|
|
11
|
+
}): Promise<Invitation> {
|
|
12
|
+
const response = await checkedApiRequest(
|
|
13
|
+
invitationDtoSchema,
|
|
14
|
+
`/workspaces/${params.workspaceId}/invitations`,
|
|
15
|
+
{
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: {email: params.command.email},
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
return toInvitation(response);
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
export function useCreateInvitation(workspaceId: string) {
|
|
14
24
|
const queryClient = useQueryClient();
|
|
15
25
|
return useMutation({
|
|
16
|
-
mutationFn: (
|
|
26
|
+
mutationFn: (command: CreateInvitationCommand) => createInvitation({workspaceId, command}),
|
|
17
27
|
onSuccess: async () => {
|
|
18
|
-
await queryClient.invalidateQueries(
|
|
28
|
+
await queryClient.invalidateQueries(listInvitationsQueryOptions(workspaceId));
|
|
19
29
|
},
|
|
20
30
|
});
|
|
21
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
2
|
+
|
|
3
|
+
describe('toInvitation', () => {
|
|
4
|
+
test('maps the transport response to the package domain model', () => {
|
|
5
|
+
const invitation = toInvitation({
|
|
6
|
+
id: 'f87901d8-4a7e-43e7-84f5-a9c73456657f',
|
|
7
|
+
workspace_id: 'ab03cfd0-1845-453b-867c-a661c8e62f13',
|
|
8
|
+
email: 'member@example.com',
|
|
9
|
+
expires_at: '2026-07-29T12:00:00.000Z',
|
|
10
|
+
accepted_at: null,
|
|
11
|
+
invited_by_user_id: 'b8d2ab85-9e38-4449-af50-8beaabf058e5',
|
|
12
|
+
invited_by_display: 'Noé',
|
|
13
|
+
created_at: '2026-07-22T12:00:00.000Z',
|
|
14
|
+
updated_at: '2026-07-22T12:00:00.000Z',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(invitation).toEqual({
|
|
18
|
+
id: 'f87901d8-4a7e-43e7-84f5-a9c73456657f',
|
|
19
|
+
workspaceId: 'ab03cfd0-1845-453b-867c-a661c8e62f13',
|
|
20
|
+
email: 'member@example.com',
|
|
21
|
+
expiresAt: '2026-07-29T12:00:00.000Z',
|
|
22
|
+
acceptedAt: null,
|
|
23
|
+
invitedByUserId: 'b8d2ab85-9e38-4449-af50-8beaabf058e5',
|
|
24
|
+
invitedByDisplay: 'Noé',
|
|
25
|
+
createdAt: '2026-07-22T12:00:00.000Z',
|
|
26
|
+
updatedAt: '2026-07-22T12:00:00.000Z',
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {InvitationDto} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import type {Invitation} from '#core/invitation.js';
|
|
3
|
+
|
|
4
|
+
export function toInvitation(dto: InvitationDto): Invitation {
|
|
5
|
+
return {
|
|
6
|
+
id: dto.id,
|
|
7
|
+
workspaceId: dto.workspace_id,
|
|
8
|
+
email: dto.email,
|
|
9
|
+
expiresAt: dto.expires_at,
|
|
10
|
+
acceptedAt: dto.accepted_at,
|
|
11
|
+
invitedByUserId: dto.invited_by_user_id,
|
|
12
|
+
invitedByDisplay: dto.invited_by_display,
|
|
13
|
+
createdAt: dto.created_at,
|
|
14
|
+
updatedAt: dto.updated_at,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {useQuery} from '@tanstack/react-query';
|
|
1
|
+
import {listInvitationsResponseSchema} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import {checkedApiRequest} from '@shipfox/client-api';
|
|
3
|
+
import {queryOptions, useQuery} from '@tanstack/react-query';
|
|
4
|
+
import type {Invitation} from '#core/invitation.js';
|
|
5
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
4
6
|
|
|
5
7
|
export const listInvitationsQueryKey = (workspaceId: string) =>
|
|
6
8
|
['workspaces', workspaceId, 'invitations'] as const;
|
|
7
9
|
|
|
8
|
-
async function listInvitations(workspaceId: string): Promise<
|
|
9
|
-
|
|
10
|
+
async function listInvitations(workspaceId: string): Promise<Invitation[]> {
|
|
11
|
+
const response = await checkedApiRequest(
|
|
12
|
+
listInvitationsResponseSchema,
|
|
13
|
+
`/workspaces/${workspaceId}/invitations`,
|
|
14
|
+
);
|
|
15
|
+
return response.invitations.map(toInvitation);
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
export function
|
|
13
|
-
return
|
|
18
|
+
export function listInvitationsQueryOptions(workspaceId: string) {
|
|
19
|
+
return queryOptions({
|
|
14
20
|
queryKey: listInvitationsQueryKey(workspaceId),
|
|
15
21
|
queryFn: () => listInvitations(workspaceId),
|
|
16
22
|
});
|
|
17
23
|
}
|
|
24
|
+
|
|
25
|
+
export function useListInvitations(workspaceId: string) {
|
|
26
|
+
return useQuery(listInvitationsQueryOptions(workspaceId));
|
|
27
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {apiRequest} from '@shipfox/client-api';
|
|
2
2
|
import {useMutation, useQueryClient} from '@tanstack/react-query';
|
|
3
|
-
import {
|
|
3
|
+
import {listInvitationsQueryOptions} from './list-invitations.js';
|
|
4
4
|
|
|
5
5
|
async function revokeInvitation(params: {workspaceId: string; invitationId: string}) {
|
|
6
6
|
await apiRequest<void>(`/workspaces/${params.workspaceId}/invitations/${params.invitationId}`, {
|
|
@@ -13,7 +13,7 @@ export function useRevokeInvitation(workspaceId: string) {
|
|
|
13
13
|
return useMutation({
|
|
14
14
|
mutationFn: (invitationId: string) => revokeInvitation({workspaceId, invitationId}),
|
|
15
15
|
onSuccess: async () => {
|
|
16
|
-
await queryClient.invalidateQueries(
|
|
16
|
+
await queryClient.invalidateQueries(listInvitationsQueryOptions(workspaceId));
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
}
|