@nurama/types 1.4.2 → 1.4.4
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/dist/feed-event.d.ts +19 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/read-state.d.ts +21 -0
- package/dist/read-state.js +2 -0
- package/dist/user-feed.d.ts +194 -0
- package/dist/user-feed.js +2 -0
- package/dist/user.d.ts +56 -0
- package/package.json +1 -1
- package/src/feed-event.ts +26 -1
- package/src/index.ts +2 -0
- package/src/read-state.ts +21 -0
- package/src/user-feed.ts +204 -0
- package/src/user.ts +58 -0
package/dist/feed-event.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { CursorPaginatedResult } from './pagination';
|
|
|
8
8
|
* Every card is self-contained: `data` carries everything it renders, so a
|
|
9
9
|
* page of the feed needs no further lookups.
|
|
10
10
|
*/
|
|
11
|
-
export type FeedEventKind = 'upload' | 'assetChat' | 'publish' | 'submission' | 'public' | 'member' | 'task';
|
|
11
|
+
export type FeedEventKind = 'upload' | 'assetChat' | 'projectChat' | 'publish' | 'submission' | 'public' | 'member' | 'task';
|
|
12
12
|
export type FeedVisibility = 'creator' | 'reviewer';
|
|
13
13
|
/** The slice of an asset a card draws: name, type and thumbnail files. */
|
|
14
14
|
export interface FeedEventAssetPreview {
|
|
@@ -52,6 +52,21 @@ export interface FeedEventAssetChatData {
|
|
|
52
52
|
recentMessages: FeedEventChatMessage[];
|
|
53
53
|
messageCount: number;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* `data` for project-chat cards. The same shape as an asset chat's minus the
|
|
57
|
+
* asset: the project's own chat is about the project, not about any one thing
|
|
58
|
+
* in it.
|
|
59
|
+
*/
|
|
60
|
+
export interface FeedEventProjectChatData {
|
|
61
|
+
chatId: ObjectId;
|
|
62
|
+
/** The chat's own subject, where it has been given one. */
|
|
63
|
+
chatSubject: string | null;
|
|
64
|
+
participants: PublicUser[];
|
|
65
|
+
participantCount: number;
|
|
66
|
+
/** Oldest → newest, at most five. */
|
|
67
|
+
recentMessages: FeedEventChatMessage[];
|
|
68
|
+
messageCount: number;
|
|
69
|
+
}
|
|
55
70
|
export interface FeedEventSubmissionData extends FeedEventGroupData {
|
|
56
71
|
submissionId: ObjectId;
|
|
57
72
|
subject: string | null;
|
|
@@ -133,6 +148,9 @@ export type FeedEvent = (FeedEventBase & {
|
|
|
133
148
|
}) | (FeedEventBase & {
|
|
134
149
|
kind: 'assetChat';
|
|
135
150
|
data: FeedEventAssetChatData;
|
|
151
|
+
}) | (FeedEventBase & {
|
|
152
|
+
kind: 'projectChat';
|
|
153
|
+
data: FeedEventProjectChatData;
|
|
136
154
|
}) | (FeedEventBase & {
|
|
137
155
|
kind: 'submission';
|
|
138
156
|
data: FeedEventSubmissionData;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export * from './scratch';
|
|
|
29
29
|
export * from './ai-revision';
|
|
30
30
|
export * from './search';
|
|
31
31
|
export * from './feed-event';
|
|
32
|
+
export * from './read-state';
|
|
33
|
+
export * from './user-feed';
|
|
32
34
|
export * from './pagination';
|
|
33
35
|
export * from './misc';
|
|
34
36
|
export * from './config';
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,8 @@ __exportStar(require("./scratch"), exports);
|
|
|
47
47
|
__exportStar(require("./ai-revision"), exports);
|
|
48
48
|
__exportStar(require("./search"), exports);
|
|
49
49
|
__exportStar(require("./feed-event"), exports);
|
|
50
|
+
__exportStar(require("./read-state"), exports);
|
|
51
|
+
__exportStar(require("./user-feed"), exports);
|
|
50
52
|
// Utility/Helper types
|
|
51
53
|
__exportStar(require("./pagination"), exports);
|
|
52
54
|
__exportStar(require("./misc"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far one person has read through something whose activity is time-ordered.
|
|
3
|
+
*
|
|
4
|
+
* Generic: a project's event feed, a member chat, a list of highlights. The
|
|
5
|
+
* shape is the same whatever is being read, so one response type covers all of
|
|
6
|
+
* them.
|
|
7
|
+
*
|
|
8
|
+
* `lastReadAt` is a boundary on that resource's own activity time, not a pointer
|
|
9
|
+
* at the last thing read. In the feed it is compared against
|
|
10
|
+
* `FeedEvent.lastActivityAt`, which MOVES when a card gets new activity: a card
|
|
11
|
+
* you had read that someone comments on drops below the line and is new again.
|
|
12
|
+
*/
|
|
13
|
+
export interface ReadState {
|
|
14
|
+
/** Epoch ms. Null when this person has never recorded a position here. */
|
|
15
|
+
lastReadAt: number | null;
|
|
16
|
+
/**
|
|
17
|
+
* Activity newer than `lastReadAt`, excluding anything this person is
|
|
18
|
+
* themselves the actor on. 0 when `lastReadAt` is null.
|
|
19
|
+
*/
|
|
20
|
+
unreadCount: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ObjectId } from './common';
|
|
2
|
+
import { PublicUser } from './user';
|
|
3
|
+
import { File } from './asset';
|
|
4
|
+
import { FeedEvent, FeedEventKind, FeedVisibility } from './feed-event';
|
|
5
|
+
import { CursorPaginatedResult } from './pagination';
|
|
6
|
+
/**
|
|
7
|
+
* User feed — one person's cross-project feed.
|
|
8
|
+
*
|
|
9
|
+
* Two categories of item:
|
|
10
|
+
* - `activity`: a project card. `event` is the card, loaded exactly as the
|
|
11
|
+
* project feed serves it.
|
|
12
|
+
* - `action`: something waiting on this person. `data` is its snapshot, and
|
|
13
|
+
* it settles itself (`state` → `done`) when the thing it asks for happens.
|
|
14
|
+
*/
|
|
15
|
+
export type UserFeedCategory = 'activity' | 'action';
|
|
16
|
+
export type UserFeedActionKind = 'mention' | 'taskAssigned' | 'invite' | 'joinRequest' | 'convoLive';
|
|
17
|
+
export type UserFeedState = 'open' | 'done' | 'dismissed';
|
|
18
|
+
export interface UserFeedMentionData {
|
|
19
|
+
taskId: ObjectId;
|
|
20
|
+
messageId: ObjectId | null;
|
|
21
|
+
chatId: ObjectId | null;
|
|
22
|
+
topicType: string;
|
|
23
|
+
topicId: ObjectId;
|
|
24
|
+
visibility: string | null;
|
|
25
|
+
/** The message, cut short; `{{mention:<id>}}` tokens are left whole. */
|
|
26
|
+
excerpt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface UserFeedTaskAssignedData {
|
|
29
|
+
taskId: ObjectId;
|
|
30
|
+
taskNumber: number | null;
|
|
31
|
+
subject: string;
|
|
32
|
+
status: string;
|
|
33
|
+
boardId: ObjectId;
|
|
34
|
+
boardName: string | null;
|
|
35
|
+
boardVisibility: FeedVisibility[];
|
|
36
|
+
}
|
|
37
|
+
export interface UserFeedInviteData {
|
|
38
|
+
inviteId: ObjectId;
|
|
39
|
+
resourceType: 'project' | 'workspace';
|
|
40
|
+
resourceId: ObjectId;
|
|
41
|
+
resourceName: string;
|
|
42
|
+
role: string;
|
|
43
|
+
/** Epoch ms. */
|
|
44
|
+
expires: number;
|
|
45
|
+
}
|
|
46
|
+
export interface UserFeedJoinRequestData {
|
|
47
|
+
requestId: ObjectId;
|
|
48
|
+
role: string;
|
|
49
|
+
additionalRoles: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface UserFeedConvoLiveData {
|
|
52
|
+
convoId: ObjectId;
|
|
53
|
+
chatId: ObjectId;
|
|
54
|
+
chatType: string;
|
|
55
|
+
convoType: string;
|
|
56
|
+
subject: string | null;
|
|
57
|
+
}
|
|
58
|
+
/** A project's or workspace's logo: just the files needed to draw it. */
|
|
59
|
+
export interface UserFeedLogo {
|
|
60
|
+
id: ObjectId;
|
|
61
|
+
files: File[];
|
|
62
|
+
}
|
|
63
|
+
/** The project an item is in, as its header shows it. */
|
|
64
|
+
export interface UserFeedProject {
|
|
65
|
+
id: ObjectId;
|
|
66
|
+
workspaceId: ObjectId;
|
|
67
|
+
name: string;
|
|
68
|
+
slug: string | null;
|
|
69
|
+
color: string | null;
|
|
70
|
+
logo: UserFeedLogo | null;
|
|
71
|
+
}
|
|
72
|
+
export interface UserFeedWorkspace {
|
|
73
|
+
id: ObjectId;
|
|
74
|
+
name: string;
|
|
75
|
+
slug: string;
|
|
76
|
+
color: string | null;
|
|
77
|
+
logo: UserFeedLogo | null;
|
|
78
|
+
}
|
|
79
|
+
interface UserFeedEntryBase {
|
|
80
|
+
id: ObjectId;
|
|
81
|
+
/** Unique within one person's feed: the card id, or the task / invite / request / convo id. */
|
|
82
|
+
subjectKey: string;
|
|
83
|
+
state: UserFeedState;
|
|
84
|
+
workspaceId: ObjectId | null;
|
|
85
|
+
/** Null for an invite to a project the person is not in yet. */
|
|
86
|
+
projectId: ObjectId | null;
|
|
87
|
+
actorId: ObjectId | null;
|
|
88
|
+
/** Epoch ms. The feed's sort key. */
|
|
89
|
+
lastActivityAt: number;
|
|
90
|
+
createdAt: number;
|
|
91
|
+
resolvedAt: number | null;
|
|
92
|
+
project: UserFeedProject | null;
|
|
93
|
+
workspace: UserFeedWorkspace | null;
|
|
94
|
+
}
|
|
95
|
+
export type UserFeedActivityEntry = UserFeedEntryBase & {
|
|
96
|
+
category: 'activity';
|
|
97
|
+
kind: FeedEventKind;
|
|
98
|
+
visibility: FeedVisibility;
|
|
99
|
+
feedEventId: ObjectId;
|
|
100
|
+
data: null;
|
|
101
|
+
event: FeedEvent;
|
|
102
|
+
};
|
|
103
|
+
export type UserFeedActionEntry = UserFeedEntryBase & {
|
|
104
|
+
category: 'action';
|
|
105
|
+
visibility: '';
|
|
106
|
+
feedEventId: null;
|
|
107
|
+
/** Who caused it. */
|
|
108
|
+
actor: PublicUser | null;
|
|
109
|
+
} & ({
|
|
110
|
+
kind: 'mention';
|
|
111
|
+
data: UserFeedMentionData;
|
|
112
|
+
} | {
|
|
113
|
+
kind: 'taskAssigned';
|
|
114
|
+
data: UserFeedTaskAssignedData;
|
|
115
|
+
} | {
|
|
116
|
+
kind: 'invite';
|
|
117
|
+
data: UserFeedInviteData;
|
|
118
|
+
} | {
|
|
119
|
+
kind: 'joinRequest';
|
|
120
|
+
data: UserFeedJoinRequestData;
|
|
121
|
+
} | {
|
|
122
|
+
kind: 'convoLive';
|
|
123
|
+
data: UserFeedConvoLiveData;
|
|
124
|
+
});
|
|
125
|
+
export type UserFeedEntry = UserFeedActivityEntry | UserFeedActionEntry;
|
|
126
|
+
export interface ListUserFeedParams {
|
|
127
|
+
category?: UserFeedCategory;
|
|
128
|
+
/** Defaults to open and done. */
|
|
129
|
+
states?: UserFeedState[];
|
|
130
|
+
workspaceId?: ObjectId;
|
|
131
|
+
projectId?: ObjectId;
|
|
132
|
+
/**
|
|
133
|
+
* The project feed's filters, across every project. They narrow project
|
|
134
|
+
* cards only; any of them set leaves action items out.
|
|
135
|
+
*/
|
|
136
|
+
kinds?: FeedEventKind[];
|
|
137
|
+
mediaTypes?: string[];
|
|
138
|
+
search?: string;
|
|
139
|
+
followedOnly?: boolean;
|
|
140
|
+
cursor?: string;
|
|
141
|
+
limit?: number;
|
|
142
|
+
}
|
|
143
|
+
export type CursorPaginatedUserFeed = CursorPaginatedResult & {
|
|
144
|
+
results: UserFeedEntry[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* One project's unread activity in your feed — the badge on its icon.
|
|
148
|
+
*
|
|
149
|
+
* Counted against that project's OWN read marker, not the feed-wide one, so
|
|
150
|
+
* opening a project clears its badge and leaves the rest alone. A project with
|
|
151
|
+
* nothing new is absent rather than zero, and one you have never opened reports
|
|
152
|
+
* nothing at all.
|
|
153
|
+
*/
|
|
154
|
+
export interface UserFeedProjectUnread {
|
|
155
|
+
projectId: ObjectId;
|
|
156
|
+
/** Null for an item that belongs to no workspace. */
|
|
157
|
+
workspaceId: ObjectId | null;
|
|
158
|
+
/** Which side of the project the count came from — you follow one of the two. */
|
|
159
|
+
visibility: FeedVisibility;
|
|
160
|
+
unreadCount: number;
|
|
161
|
+
}
|
|
162
|
+
/** Every badge the app shows. `unread` stops at 100 — show "99+" past 99. */
|
|
163
|
+
export interface UserFeedSummary {
|
|
164
|
+
/** Items other people put in the feed since the read marker; answered or cleared ones don't count. */
|
|
165
|
+
unread: number;
|
|
166
|
+
/** Epoch ms, or null when no read position has been recorded. */
|
|
167
|
+
lastReadAt: number | null;
|
|
168
|
+
/**
|
|
169
|
+
* Per-project activity badges. Normally one row per project, since you follow
|
|
170
|
+
* one side of each; not capped, because each row is one icon's number.
|
|
171
|
+
*/
|
|
172
|
+
byProject: UserFeedProjectUnread[];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The `userFeed` websocket event's `tokens.item`: what changed, named by
|
|
176
|
+
* `kind` + `subjectKey`, the same for everyone it is sent to.
|
|
177
|
+
*/
|
|
178
|
+
export interface UserFeedChange {
|
|
179
|
+
change: 'placed' | 'state' | 'removed' | 'cleared';
|
|
180
|
+
category: UserFeedCategory;
|
|
181
|
+
kind?: FeedEventKind | UserFeedActionKind;
|
|
182
|
+
subjectKey?: string;
|
|
183
|
+
/** In place of `subjectKey` when several items of one kind changed state at once. */
|
|
184
|
+
subjectKeys?: string[];
|
|
185
|
+
state?: UserFeedState;
|
|
186
|
+
feedEventId?: ObjectId;
|
|
187
|
+
projectId?: ObjectId | null;
|
|
188
|
+
visibility?: FeedVisibility;
|
|
189
|
+
/** Epoch ms, for `placed`. */
|
|
190
|
+
lastActivityAt?: number;
|
|
191
|
+
/** Epoch ms, for `cleared`: every open action item at or before it was dismissed. */
|
|
192
|
+
before?: number;
|
|
193
|
+
}
|
|
194
|
+
export {};
|
package/dist/user.d.ts
CHANGED
|
@@ -141,6 +141,42 @@ export interface User {
|
|
|
141
141
|
*/
|
|
142
142
|
updatedAt?: number;
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* A passkey saved to the user's account. The key itself never leaves the user's device or password manager.
|
|
146
|
+
*/
|
|
147
|
+
export interface Passkey {
|
|
148
|
+
id: string;
|
|
149
|
+
/** A name to tell it apart, e.g. "MacBook" */
|
|
150
|
+
name: string;
|
|
151
|
+
/** `multiDevice` passkeys sync between devices (iCloud Keychain, Google Password Manager, 1Password) */
|
|
152
|
+
deviceType: 'singleDevice' | 'multiDevice';
|
|
153
|
+
backedUp: boolean;
|
|
154
|
+
transports: string[];
|
|
155
|
+
createdAt: string;
|
|
156
|
+
lastUsedAt: string | null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* What adding a passkey asks for: the password when the account has one, and a two-factor code when two-factor is
|
|
160
|
+
* on. An account with neither sends nothing.
|
|
161
|
+
*/
|
|
162
|
+
export interface PasskeyRegistrationProof {
|
|
163
|
+
password?: string;
|
|
164
|
+
mfaToken?: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* WebAuthn options for the browser's passkey prompt (PublicKeyCredentialCreationOptionsJSON or
|
|
168
|
+
* PublicKeyCredentialRequestOptionsJSON). Passed straight to the WebAuthn library, so kept opaque here.
|
|
169
|
+
*/
|
|
170
|
+
export type PasskeyCredentialOptions = Record<string, unknown> & {
|
|
171
|
+
challenge: string;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* The browser's response to a passkey prompt (RegistrationResponseJSON or AuthenticationResponseJSON), as the
|
|
175
|
+
* WebAuthn library returns it.
|
|
176
|
+
*/
|
|
177
|
+
export type PasskeyCredentialResponse = Record<string, unknown> & {
|
|
178
|
+
id: string;
|
|
179
|
+
};
|
|
144
180
|
/**
|
|
145
181
|
* OAuth platform types
|
|
146
182
|
*/
|
|
@@ -153,6 +189,26 @@ export interface OAuthExchangeRequest {
|
|
|
153
189
|
* Exchange code received from OAuth callback
|
|
154
190
|
*/
|
|
155
191
|
code: string;
|
|
192
|
+
/**
|
|
193
|
+
* PKCE verifier, for a code made with a challenge (the desktop app's passkey sign-in)
|
|
194
|
+
*/
|
|
195
|
+
codeVerifier?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Signing the desktop app in with a passkey, sent from the browser: the passkey response plus the `state` and PKCE
|
|
199
|
+
* challenge the desktop app made.
|
|
200
|
+
*/
|
|
201
|
+
export interface PasskeyDesktopLoginRequest {
|
|
202
|
+
credential: PasskeyCredentialResponse;
|
|
203
|
+
state: string;
|
|
204
|
+
/** base64url SHA-256 of the desktop app's code verifier (S256) */
|
|
205
|
+
codeChallenge: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The one-time code the browser hands to the desktop app, which redeems it with its verifier.
|
|
209
|
+
*/
|
|
210
|
+
export interface PasskeyDesktopLoginResponse {
|
|
211
|
+
code: string;
|
|
156
212
|
}
|
|
157
213
|
/**
|
|
158
214
|
* OAuth exchange response with user and tokens
|
package/package.json
CHANGED
package/src/feed-event.ts
CHANGED
|
@@ -9,7 +9,15 @@ import { CursorPaginatedResult } from './pagination';
|
|
|
9
9
|
* Every card is self-contained: `data` carries everything it renders, so a
|
|
10
10
|
* page of the feed needs no further lookups.
|
|
11
11
|
*/
|
|
12
|
-
export type FeedEventKind =
|
|
12
|
+
export type FeedEventKind =
|
|
13
|
+
| 'upload'
|
|
14
|
+
| 'assetChat'
|
|
15
|
+
| 'projectChat'
|
|
16
|
+
| 'publish'
|
|
17
|
+
| 'submission'
|
|
18
|
+
| 'public'
|
|
19
|
+
| 'member'
|
|
20
|
+
| 'task';
|
|
13
21
|
|
|
14
22
|
export type FeedVisibility = 'creator' | 'reviewer';
|
|
15
23
|
|
|
@@ -60,6 +68,22 @@ export interface FeedEventAssetChatData {
|
|
|
60
68
|
messageCount: number;
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
/**
|
|
72
|
+
* `data` for project-chat cards. The same shape as an asset chat's minus the
|
|
73
|
+
* asset: the project's own chat is about the project, not about any one thing
|
|
74
|
+
* in it.
|
|
75
|
+
*/
|
|
76
|
+
export interface FeedEventProjectChatData {
|
|
77
|
+
chatId: ObjectId;
|
|
78
|
+
/** The chat's own subject, where it has been given one. */
|
|
79
|
+
chatSubject: string | null;
|
|
80
|
+
participants: PublicUser[];
|
|
81
|
+
participantCount: number;
|
|
82
|
+
/** Oldest → newest, at most five. */
|
|
83
|
+
recentMessages: FeedEventChatMessage[];
|
|
84
|
+
messageCount: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
63
87
|
export interface FeedEventSubmissionData extends FeedEventGroupData {
|
|
64
88
|
submissionId: ObjectId;
|
|
65
89
|
subject: string | null;
|
|
@@ -137,6 +161,7 @@ interface FeedEventBase {
|
|
|
137
161
|
export type FeedEvent =
|
|
138
162
|
| (FeedEventBase & { kind: 'upload' | 'publish'; data: FeedEventGroupData })
|
|
139
163
|
| (FeedEventBase & { kind: 'assetChat'; data: FeedEventAssetChatData })
|
|
164
|
+
| (FeedEventBase & { kind: 'projectChat'; data: FeedEventProjectChatData })
|
|
140
165
|
| (FeedEventBase & { kind: 'submission'; data: FeedEventSubmissionData })
|
|
141
166
|
| (FeedEventBase & { kind: 'public'; data: FeedEventPublicData })
|
|
142
167
|
| (FeedEventBase & { kind: 'member'; data: FeedEventMemberData })
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far one person has read through something whose activity is time-ordered.
|
|
3
|
+
*
|
|
4
|
+
* Generic: a project's event feed, a member chat, a list of highlights. The
|
|
5
|
+
* shape is the same whatever is being read, so one response type covers all of
|
|
6
|
+
* them.
|
|
7
|
+
*
|
|
8
|
+
* `lastReadAt` is a boundary on that resource's own activity time, not a pointer
|
|
9
|
+
* at the last thing read. In the feed it is compared against
|
|
10
|
+
* `FeedEvent.lastActivityAt`, which MOVES when a card gets new activity: a card
|
|
11
|
+
* you had read that someone comments on drops below the line and is new again.
|
|
12
|
+
*/
|
|
13
|
+
export interface ReadState {
|
|
14
|
+
/** Epoch ms. Null when this person has never recorded a position here. */
|
|
15
|
+
lastReadAt: number | null;
|
|
16
|
+
/**
|
|
17
|
+
* Activity newer than `lastReadAt`, excluding anything this person is
|
|
18
|
+
* themselves the actor on. 0 when `lastReadAt` is null.
|
|
19
|
+
*/
|
|
20
|
+
unreadCount: number;
|
|
21
|
+
}
|
package/src/user-feed.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { ObjectId } from './common';
|
|
2
|
+
import { PublicUser } from './user';
|
|
3
|
+
import { File } from './asset';
|
|
4
|
+
import { FeedEvent, FeedEventKind, FeedVisibility } from './feed-event';
|
|
5
|
+
import { CursorPaginatedResult } from './pagination';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* User feed — one person's cross-project feed.
|
|
9
|
+
*
|
|
10
|
+
* Two categories of item:
|
|
11
|
+
* - `activity`: a project card. `event` is the card, loaded exactly as the
|
|
12
|
+
* project feed serves it.
|
|
13
|
+
* - `action`: something waiting on this person. `data` is its snapshot, and
|
|
14
|
+
* it settles itself (`state` → `done`) when the thing it asks for happens.
|
|
15
|
+
*/
|
|
16
|
+
export type UserFeedCategory = 'activity' | 'action';
|
|
17
|
+
|
|
18
|
+
export type UserFeedActionKind = 'mention' | 'taskAssigned' | 'invite' | 'joinRequest' | 'convoLive';
|
|
19
|
+
|
|
20
|
+
export type UserFeedState = 'open' | 'done' | 'dismissed';
|
|
21
|
+
|
|
22
|
+
export interface UserFeedMentionData {
|
|
23
|
+
taskId: ObjectId;
|
|
24
|
+
messageId: ObjectId | null;
|
|
25
|
+
chatId: ObjectId | null;
|
|
26
|
+
topicType: string;
|
|
27
|
+
topicId: ObjectId;
|
|
28
|
+
visibility: string | null;
|
|
29
|
+
/** The message, cut short; `{{mention:<id>}}` tokens are left whole. */
|
|
30
|
+
excerpt: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface UserFeedTaskAssignedData {
|
|
34
|
+
taskId: ObjectId;
|
|
35
|
+
taskNumber: number | null;
|
|
36
|
+
subject: string;
|
|
37
|
+
status: string;
|
|
38
|
+
boardId: ObjectId;
|
|
39
|
+
boardName: string | null;
|
|
40
|
+
boardVisibility: FeedVisibility[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface UserFeedInviteData {
|
|
44
|
+
inviteId: ObjectId;
|
|
45
|
+
resourceType: 'project' | 'workspace';
|
|
46
|
+
resourceId: ObjectId;
|
|
47
|
+
resourceName: string;
|
|
48
|
+
role: string;
|
|
49
|
+
/** Epoch ms. */
|
|
50
|
+
expires: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface UserFeedJoinRequestData {
|
|
54
|
+
requestId: ObjectId;
|
|
55
|
+
role: string;
|
|
56
|
+
additionalRoles: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface UserFeedConvoLiveData {
|
|
60
|
+
convoId: ObjectId;
|
|
61
|
+
chatId: ObjectId;
|
|
62
|
+
chatType: string;
|
|
63
|
+
convoType: string;
|
|
64
|
+
subject: string | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A project's or workspace's logo: just the files needed to draw it. */
|
|
68
|
+
export interface UserFeedLogo {
|
|
69
|
+
id: ObjectId;
|
|
70
|
+
files: File[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The project an item is in, as its header shows it. */
|
|
74
|
+
export interface UserFeedProject {
|
|
75
|
+
id: ObjectId;
|
|
76
|
+
workspaceId: ObjectId;
|
|
77
|
+
name: string;
|
|
78
|
+
slug: string | null;
|
|
79
|
+
color: string | null;
|
|
80
|
+
logo: UserFeedLogo | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface UserFeedWorkspace {
|
|
84
|
+
id: ObjectId;
|
|
85
|
+
name: string;
|
|
86
|
+
slug: string;
|
|
87
|
+
color: string | null;
|
|
88
|
+
logo: UserFeedLogo | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface UserFeedEntryBase {
|
|
92
|
+
id: ObjectId;
|
|
93
|
+
/** Unique within one person's feed: the card id, or the task / invite / request / convo id. */
|
|
94
|
+
subjectKey: string;
|
|
95
|
+
state: UserFeedState;
|
|
96
|
+
workspaceId: ObjectId | null;
|
|
97
|
+
/** Null for an invite to a project the person is not in yet. */
|
|
98
|
+
projectId: ObjectId | null;
|
|
99
|
+
actorId: ObjectId | null;
|
|
100
|
+
/** Epoch ms. The feed's sort key. */
|
|
101
|
+
lastActivityAt: number;
|
|
102
|
+
createdAt: number;
|
|
103
|
+
resolvedAt: number | null;
|
|
104
|
+
project: UserFeedProject | null;
|
|
105
|
+
workspace: UserFeedWorkspace | null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type UserFeedActivityEntry = UserFeedEntryBase & {
|
|
109
|
+
category: 'activity';
|
|
110
|
+
kind: FeedEventKind;
|
|
111
|
+
visibility: FeedVisibility;
|
|
112
|
+
feedEventId: ObjectId;
|
|
113
|
+
data: null;
|
|
114
|
+
event: FeedEvent;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type UserFeedActionEntry = UserFeedEntryBase & {
|
|
118
|
+
category: 'action';
|
|
119
|
+
visibility: '';
|
|
120
|
+
feedEventId: null;
|
|
121
|
+
/** Who caused it. */
|
|
122
|
+
actor: PublicUser | null;
|
|
123
|
+
} & (
|
|
124
|
+
| { kind: 'mention'; data: UserFeedMentionData }
|
|
125
|
+
| { kind: 'taskAssigned'; data: UserFeedTaskAssignedData }
|
|
126
|
+
| { kind: 'invite'; data: UserFeedInviteData }
|
|
127
|
+
| { kind: 'joinRequest'; data: UserFeedJoinRequestData }
|
|
128
|
+
| { kind: 'convoLive'; data: UserFeedConvoLiveData }
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
export type UserFeedEntry = UserFeedActivityEntry | UserFeedActionEntry;
|
|
132
|
+
|
|
133
|
+
export interface ListUserFeedParams {
|
|
134
|
+
category?: UserFeedCategory;
|
|
135
|
+
/** Defaults to open and done. */
|
|
136
|
+
states?: UserFeedState[];
|
|
137
|
+
workspaceId?: ObjectId;
|
|
138
|
+
projectId?: ObjectId;
|
|
139
|
+
/**
|
|
140
|
+
* The project feed's filters, across every project. They narrow project
|
|
141
|
+
* cards only; any of them set leaves action items out.
|
|
142
|
+
*/
|
|
143
|
+
kinds?: FeedEventKind[];
|
|
144
|
+
mediaTypes?: string[];
|
|
145
|
+
search?: string;
|
|
146
|
+
followedOnly?: boolean;
|
|
147
|
+
cursor?: string;
|
|
148
|
+
limit?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type CursorPaginatedUserFeed = CursorPaginatedResult & {
|
|
152
|
+
results: UserFeedEntry[];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* One project's unread activity in your feed — the badge on its icon.
|
|
157
|
+
*
|
|
158
|
+
* Counted against that project's OWN read marker, not the feed-wide one, so
|
|
159
|
+
* opening a project clears its badge and leaves the rest alone. A project with
|
|
160
|
+
* nothing new is absent rather than zero, and one you have never opened reports
|
|
161
|
+
* nothing at all.
|
|
162
|
+
*/
|
|
163
|
+
export interface UserFeedProjectUnread {
|
|
164
|
+
projectId: ObjectId;
|
|
165
|
+
/** Null for an item that belongs to no workspace. */
|
|
166
|
+
workspaceId: ObjectId | null;
|
|
167
|
+
/** Which side of the project the count came from — you follow one of the two. */
|
|
168
|
+
visibility: FeedVisibility;
|
|
169
|
+
unreadCount: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Every badge the app shows. `unread` stops at 100 — show "99+" past 99. */
|
|
173
|
+
export interface UserFeedSummary {
|
|
174
|
+
/** Items other people put in the feed since the read marker; answered or cleared ones don't count. */
|
|
175
|
+
unread: number;
|
|
176
|
+
/** Epoch ms, or null when no read position has been recorded. */
|
|
177
|
+
lastReadAt: number | null;
|
|
178
|
+
/**
|
|
179
|
+
* Per-project activity badges. Normally one row per project, since you follow
|
|
180
|
+
* one side of each; not capped, because each row is one icon's number.
|
|
181
|
+
*/
|
|
182
|
+
byProject: UserFeedProjectUnread[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The `userFeed` websocket event's `tokens.item`: what changed, named by
|
|
187
|
+
* `kind` + `subjectKey`, the same for everyone it is sent to.
|
|
188
|
+
*/
|
|
189
|
+
export interface UserFeedChange {
|
|
190
|
+
change: 'placed' | 'state' | 'removed' | 'cleared';
|
|
191
|
+
category: UserFeedCategory;
|
|
192
|
+
kind?: FeedEventKind | UserFeedActionKind;
|
|
193
|
+
subjectKey?: string;
|
|
194
|
+
/** In place of `subjectKey` when several items of one kind changed state at once. */
|
|
195
|
+
subjectKeys?: string[];
|
|
196
|
+
state?: UserFeedState;
|
|
197
|
+
feedEventId?: ObjectId;
|
|
198
|
+
projectId?: ObjectId | null;
|
|
199
|
+
visibility?: FeedVisibility;
|
|
200
|
+
/** Epoch ms, for `placed`. */
|
|
201
|
+
lastActivityAt?: number;
|
|
202
|
+
/** Epoch ms, for `cleared`: every open action item at or before it was dismissed. */
|
|
203
|
+
before?: number;
|
|
204
|
+
}
|
package/src/user.ts
CHANGED
|
@@ -146,6 +146,42 @@ export interface User {
|
|
|
146
146
|
updatedAt?: number;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* A passkey saved to the user's account. The key itself never leaves the user's device or password manager.
|
|
151
|
+
*/
|
|
152
|
+
export interface Passkey {
|
|
153
|
+
id: string;
|
|
154
|
+
/** A name to tell it apart, e.g. "MacBook" */
|
|
155
|
+
name: string;
|
|
156
|
+
/** `multiDevice` passkeys sync between devices (iCloud Keychain, Google Password Manager, 1Password) */
|
|
157
|
+
deviceType: 'singleDevice' | 'multiDevice';
|
|
158
|
+
backedUp: boolean;
|
|
159
|
+
transports: string[];
|
|
160
|
+
createdAt: string;
|
|
161
|
+
lastUsedAt: string | null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* What adding a passkey asks for: the password when the account has one, and a two-factor code when two-factor is
|
|
166
|
+
* on. An account with neither sends nothing.
|
|
167
|
+
*/
|
|
168
|
+
export interface PasskeyRegistrationProof {
|
|
169
|
+
password?: string;
|
|
170
|
+
mfaToken?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* WebAuthn options for the browser's passkey prompt (PublicKeyCredentialCreationOptionsJSON or
|
|
175
|
+
* PublicKeyCredentialRequestOptionsJSON). Passed straight to the WebAuthn library, so kept opaque here.
|
|
176
|
+
*/
|
|
177
|
+
export type PasskeyCredentialOptions = Record<string, unknown> & { challenge: string };
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The browser's response to a passkey prompt (RegistrationResponseJSON or AuthenticationResponseJSON), as the
|
|
181
|
+
* WebAuthn library returns it.
|
|
182
|
+
*/
|
|
183
|
+
export type PasskeyCredentialResponse = Record<string, unknown> & { id: string };
|
|
184
|
+
|
|
149
185
|
/**
|
|
150
186
|
* OAuth platform types
|
|
151
187
|
*/
|
|
@@ -159,6 +195,28 @@ export interface OAuthExchangeRequest {
|
|
|
159
195
|
* Exchange code received from OAuth callback
|
|
160
196
|
*/
|
|
161
197
|
code: string;
|
|
198
|
+
/**
|
|
199
|
+
* PKCE verifier, for a code made with a challenge (the desktop app's passkey sign-in)
|
|
200
|
+
*/
|
|
201
|
+
codeVerifier?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Signing the desktop app in with a passkey, sent from the browser: the passkey response plus the `state` and PKCE
|
|
206
|
+
* challenge the desktop app made.
|
|
207
|
+
*/
|
|
208
|
+
export interface PasskeyDesktopLoginRequest {
|
|
209
|
+
credential: PasskeyCredentialResponse;
|
|
210
|
+
state: string;
|
|
211
|
+
/** base64url SHA-256 of the desktop app's code verifier (S256) */
|
|
212
|
+
codeChallenge: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The one-time code the browser hands to the desktop app, which redeems it with its verifier.
|
|
217
|
+
*/
|
|
218
|
+
export interface PasskeyDesktopLoginResponse {
|
|
219
|
+
code: string;
|
|
162
220
|
}
|
|
163
221
|
|
|
164
222
|
/**
|