@jsm-mit/chat-motoko-package 0.5.0 → 0.7.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 +11 -0
- package/declarations/chat-motoko-backend/chat-motoko-backend.did +43 -9
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.d.ts +40 -9
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.js +31 -9
- package/dist/actors/messages-actor.d.ts +12 -1
- package/dist/actors/messages-actor.d.ts.map +1 -1
- package/dist/actors/messages-actor.js +14 -1
- package/dist/actors/projects-actor.d.ts +23 -1
- package/dist/actors/projects-actor.d.ts.map +1 -1
- package/dist/actors/projects-actor.js +29 -1
- package/dist/actors/rooms-actor.d.ts +22 -1
- package/dist/actors/rooms-actor.d.ts.map +1 -1
- package/dist/actors/rooms-actor.js +28 -1
- package/dist/deletion.d.ts +8 -0
- package/dist/deletion.d.ts.map +1 -0
- package/dist/deletion.js +17 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.d.ts +26 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +3 -2
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +21 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@ const chat = await new ChatsActor(canisterId, identity).openChatAsyncUnsafe({ pr
|
|
|
23
23
|
|
|
24
24
|
const messages = new MessagesActor(canisterId, identity);
|
|
25
25
|
await messages.postAsyncUnsafe({ chatId: chat.id, text: "dodaj usługę strzyżenie" });
|
|
26
|
+
|
|
27
|
+
// The page carries the thread AND what the others are doing: `presence[].typing` while
|
|
28
|
+
// somebody is writing (a room's recipients report it with setTypingAsyncUnsafe, and their
|
|
29
|
+
// own post clears it), `presence[].lastReadSeq` for "read up to here".
|
|
26
30
|
const page = await messages.getMessagesAsyncUnsafe({ chatId: chat.id, sinceSeq: 0 });
|
|
27
31
|
|
|
28
32
|
// An agent host: every new message in every chat this identity is a recipient of, with
|
|
@@ -38,6 +42,13 @@ One class per canister controller (`AdminActor`, `ProjectsActor`, `RoomsActor`,
|
|
|
38
42
|
throws). Views translate `Principal` → text, `opt` → optional, variants → string
|
|
39
43
|
unions; sequence numbers are plain `number`s, timestamps `bigint` nanoseconds.
|
|
40
44
|
|
|
45
|
+
Deleting: `RoomsActor.deleteRoomAsyncUnsafe` (project admins) takes a room with every chat
|
|
46
|
+
and message in it; `ProjectsActor.deleteProjectAsyncUnsafe` (canister admins only) takes a
|
|
47
|
+
project with all its rooms. The canister deletes in bounded calls (500 chats or 50 000
|
|
48
|
+
messages each), and these methods repeat the call until it is done — pass `onStep` to see
|
|
49
|
+
the progress, or call `deleteRoomStepAsyncUnsafe` / `deleteProjectStepAsyncUnsafe` for one
|
|
50
|
+
call at a time.
|
|
51
|
+
|
|
41
52
|
`src/` is browser-safe — the same package serves the agent host and a web panel.
|
|
42
53
|
|
|
43
54
|
Scripts: `build`, `typecheck`, `sync-declarations`, `test-suite`,
|
|
@@ -13,6 +13,7 @@ type UpdateProjectArgs =
|
|
|
13
13
|
projectId: ProjectId;
|
|
14
14
|
};
|
|
15
15
|
type SystemEvent = variant {chatCreated;};
|
|
16
|
+
type SetTypingArgs = record {chatId: ChatId;};
|
|
16
17
|
type SetQuotaLimitsArgs = record {limits: QuotaLimits;};
|
|
17
18
|
type SetLoggingEnabledArgs = record {enabled: bool;};
|
|
18
19
|
type RoomId = text;
|
|
@@ -65,12 +66,17 @@ type Result_4 =
|
|
|
65
66
|
type Result_3 =
|
|
66
67
|
variant {
|
|
67
68
|
err: Error;
|
|
68
|
-
ok:
|
|
69
|
+
ok: QuotaLimits;
|
|
69
70
|
};
|
|
70
71
|
type Result_2 =
|
|
71
72
|
variant {
|
|
72
73
|
err: Error;
|
|
73
|
-
ok:
|
|
74
|
+
ok: bool;
|
|
75
|
+
};
|
|
76
|
+
type Result_14 =
|
|
77
|
+
variant {
|
|
78
|
+
err: Error;
|
|
79
|
+
ok: DeletionProgress;
|
|
74
80
|
};
|
|
75
81
|
type Result_13 =
|
|
76
82
|
variant {
|
|
@@ -129,6 +135,12 @@ type Project =
|
|
|
129
135
|
createdBy: principal;
|
|
130
136
|
id: ProjectId;
|
|
131
137
|
};
|
|
138
|
+
type Presence =
|
|
139
|
+
record {
|
|
140
|
+
lastReadSeq: nat;
|
|
141
|
+
"principal": principal;
|
|
142
|
+
typingUntil: int;
|
|
143
|
+
};
|
|
132
144
|
type PostKind =
|
|
133
145
|
variant {
|
|
134
146
|
"text";
|
|
@@ -170,6 +182,7 @@ type MessagesPage =
|
|
|
170
182
|
record {
|
|
171
183
|
lastSeq: nat;
|
|
172
184
|
messages: vec Message;
|
|
185
|
+
presence: vec Presence;
|
|
173
186
|
};
|
|
174
187
|
type MessageKind =
|
|
175
188
|
variant {
|
|
@@ -242,6 +255,19 @@ type Error =
|
|
|
242
255
|
details: ErrorDetails;
|
|
243
256
|
logsJson: text;
|
|
244
257
|
};
|
|
258
|
+
type DeletionProgress =
|
|
259
|
+
record {
|
|
260
|
+
chatsPurged: nat;
|
|
261
|
+
finished: bool;
|
|
262
|
+
messagesPurged: nat;
|
|
263
|
+
roomsDeleted: nat;
|
|
264
|
+
};
|
|
265
|
+
type DeleteRoomArgs =
|
|
266
|
+
record {
|
|
267
|
+
projectId: ProjectId;
|
|
268
|
+
roomId: RoomId;
|
|
269
|
+
};
|
|
270
|
+
type DeleteProjectArgs = record {projectId: ProjectId;};
|
|
245
271
|
type CreateRoomArgs =
|
|
246
272
|
record {
|
|
247
273
|
allowedCustomers: vec principal;
|
|
@@ -281,30 +307,38 @@ type Chat =
|
|
|
281
307
|
};
|
|
282
308
|
type AddAdminArgs = record {"principal": principal;};
|
|
283
309
|
service : {
|
|
284
|
-
addAdmin: (args: AddAdminArgs) -> (
|
|
310
|
+
addAdmin: (args: AddAdminArgs) -> (Result_2);
|
|
285
311
|
clearLogs: () -> ();
|
|
286
312
|
createProject: (args: CreateProjectArgs) -> (Result_1);
|
|
287
313
|
createRoom: (args: CreateRoomArgs) -> (Result);
|
|
314
|
+
/// Canister admins. Takes every room, chat and message of the project with it; a big
|
|
315
|
+
/// project needs the call repeated until `finished`.
|
|
316
|
+
deleteProject: (args: DeleteProjectArgs) -> (Result_14);
|
|
317
|
+
/// Project admins. Takes every chat and message of the room with it; a big room needs the
|
|
318
|
+
/// call repeated until `finished`.
|
|
319
|
+
deleteRoom: (args: DeleteRoomArgs) -> (Result_14);
|
|
288
320
|
getAdmins: () -> (Result_13) query;
|
|
289
321
|
getChat: (args: GetChatArgs) -> (Result_7) query;
|
|
290
322
|
getLogs: () -> (text) query;
|
|
291
323
|
getMessages: (args: GetMessagesArgs) -> (Result_12) query;
|
|
292
324
|
getMyChats: (args: GetMyChatsArgs) -> (Result_11) query;
|
|
293
325
|
getProject: (args: GetProjectArgs) -> (Result_1) query;
|
|
294
|
-
getQuotaLimits: () -> (
|
|
326
|
+
getQuotaLimits: () -> (Result_3) query;
|
|
295
327
|
getRoom: (args: GetRoomArgs) -> (Result) query;
|
|
296
328
|
listProjectChats: (args: ListProjectChatsArgs) -> (Result_10) query;
|
|
297
329
|
listProjects: (args: ListProjectsArgs) -> (Result_9) query;
|
|
298
330
|
listRooms: (args: ListRoomsArgs) -> (Result_8) query;
|
|
299
|
-
markRead: (args: MarkReadArgs) -> (
|
|
331
|
+
markRead: (args: MarkReadArgs) -> (Result_2);
|
|
300
332
|
openChat: (args: OpenChatArgs) -> (Result_7);
|
|
301
333
|
pollNewMessages: (args: PollNewMessagesArgs) -> (Result_6) query;
|
|
302
334
|
post: (args: PostArgs) -> (Result_5);
|
|
303
|
-
purgeChat: (args: PurgeChatArgs) -> (
|
|
335
|
+
purgeChat: (args: PurgeChatArgs) -> (Result_2);
|
|
304
336
|
registerAsAdmin: () -> (Result_4);
|
|
305
|
-
removeAdmin: (args: RemoveAdminArgs) -> (
|
|
306
|
-
setLoggingEnabled: (args: SetLoggingEnabledArgs) -> (
|
|
307
|
-
setQuotaLimits: (args: SetQuotaLimitsArgs) -> (
|
|
337
|
+
removeAdmin: (args: RemoveAdminArgs) -> (Result_2);
|
|
338
|
+
setLoggingEnabled: (args: SetLoggingEnabledArgs) -> (Result_2);
|
|
339
|
+
setQuotaLimits: (args: SetQuotaLimitsArgs) -> (Result_3);
|
|
340
|
+
/// "I am writing" — a room's recipients only; it expires by itself and a post clears it.
|
|
341
|
+
setTyping: (args: SetTypingArgs) -> (Result_2);
|
|
308
342
|
updateProject: (args: UpdateProjectArgs) -> (Result_1);
|
|
309
343
|
updateRoom: (args: UpdateRoomArgs) -> (Result);
|
|
310
344
|
whoAmI: () -> (principal) query;
|
|
@@ -36,6 +36,14 @@ export interface CreateRoomArgs {
|
|
|
36
36
|
'projectId' : ProjectId,
|
|
37
37
|
'allowedCustomers' : Array<Principal>,
|
|
38
38
|
}
|
|
39
|
+
export interface DeleteProjectArgs { 'projectId' : ProjectId }
|
|
40
|
+
export interface DeleteRoomArgs { 'projectId' : ProjectId, 'roomId' : RoomId }
|
|
41
|
+
export interface DeletionProgress {
|
|
42
|
+
'chatsPurged' : bigint,
|
|
43
|
+
'messagesPurged' : bigint,
|
|
44
|
+
'finished' : boolean,
|
|
45
|
+
'roomsDeleted' : bigint,
|
|
46
|
+
}
|
|
39
47
|
export interface Error { 'details' : ErrorDetails, 'logsJson' : string }
|
|
40
48
|
export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
|
|
41
49
|
{ 'RemoteCanisterError' : string } |
|
|
@@ -86,6 +94,7 @@ export type MessageKind = { 'toolTrace' : null } |
|
|
|
86
94
|
{ 'event' : SystemEvent };
|
|
87
95
|
export interface MessagesPage {
|
|
88
96
|
'messages' : Array<Message>,
|
|
97
|
+
'presence' : Array<Presence>,
|
|
89
98
|
'lastSeq' : bigint,
|
|
90
99
|
}
|
|
91
100
|
export interface OpenChatArgs {
|
|
@@ -117,6 +126,11 @@ export interface PostArgs {
|
|
|
117
126
|
}
|
|
118
127
|
export type PostKind = { 'toolTrace' : null } |
|
|
119
128
|
{ 'text' : null };
|
|
129
|
+
export interface Presence {
|
|
130
|
+
'principal' : Principal,
|
|
131
|
+
'typingUntil' : bigint,
|
|
132
|
+
'lastReadSeq' : bigint,
|
|
133
|
+
}
|
|
120
134
|
export interface Project {
|
|
121
135
|
'id' : ProjectId,
|
|
122
136
|
'createdAt' : bigint,
|
|
@@ -147,9 +161,11 @@ export type Result_12 = { 'ok' : MessagesPage } |
|
|
|
147
161
|
{ 'err' : Error };
|
|
148
162
|
export type Result_13 = { 'ok' : Array<Principal> } |
|
|
149
163
|
{ 'err' : Error };
|
|
150
|
-
export type
|
|
164
|
+
export type Result_14 = { 'ok' : DeletionProgress } |
|
|
165
|
+
{ 'err' : Error };
|
|
166
|
+
export type Result_2 = { 'ok' : boolean } |
|
|
151
167
|
{ 'err' : Error };
|
|
152
|
-
export type Result_3 = { 'ok' :
|
|
168
|
+
export type Result_3 = { 'ok' : QuotaLimits } |
|
|
153
169
|
{ 'err' : Error };
|
|
154
170
|
export type Result_4 = { 'ok' : Principal } |
|
|
155
171
|
{ 'err' : Error };
|
|
@@ -178,6 +194,7 @@ export interface Room {
|
|
|
178
194
|
export type RoomId = string;
|
|
179
195
|
export interface SetLoggingEnabledArgs { 'enabled' : boolean }
|
|
180
196
|
export interface SetQuotaLimitsArgs { 'limits' : QuotaLimits }
|
|
197
|
+
export interface SetTypingArgs { 'chatId' : ChatId }
|
|
181
198
|
export type SystemEvent = { 'chatCreated' : null };
|
|
182
199
|
export interface UpdateProjectArgs {
|
|
183
200
|
'accountsCanister' : [] | [Principal],
|
|
@@ -192,30 +209,44 @@ export interface UpdateRoomArgs {
|
|
|
192
209
|
'allowedCustomers' : [] | [Array<Principal>],
|
|
193
210
|
}
|
|
194
211
|
export interface _SERVICE {
|
|
195
|
-
'addAdmin' : ActorMethod<[AddAdminArgs],
|
|
212
|
+
'addAdmin' : ActorMethod<[AddAdminArgs], Result_2>,
|
|
196
213
|
'clearLogs' : ActorMethod<[], undefined>,
|
|
197
214
|
'createProject' : ActorMethod<[CreateProjectArgs], Result_1>,
|
|
198
215
|
'createRoom' : ActorMethod<[CreateRoomArgs], Result>,
|
|
216
|
+
/**
|
|
217
|
+
* / Canister admins. Takes every room, chat and message of the project with it; a big
|
|
218
|
+
* / project needs the call repeated until `finished`.
|
|
219
|
+
*/
|
|
220
|
+
'deleteProject' : ActorMethod<[DeleteProjectArgs], Result_14>,
|
|
221
|
+
/**
|
|
222
|
+
* / Project admins. Takes every chat and message of the room with it; a big room needs the
|
|
223
|
+
* / call repeated until `finished`.
|
|
224
|
+
*/
|
|
225
|
+
'deleteRoom' : ActorMethod<[DeleteRoomArgs], Result_14>,
|
|
199
226
|
'getAdmins' : ActorMethod<[], Result_13>,
|
|
200
227
|
'getChat' : ActorMethod<[GetChatArgs], Result_7>,
|
|
201
228
|
'getLogs' : ActorMethod<[], string>,
|
|
202
229
|
'getMessages' : ActorMethod<[GetMessagesArgs], Result_12>,
|
|
203
230
|
'getMyChats' : ActorMethod<[GetMyChatsArgs], Result_11>,
|
|
204
231
|
'getProject' : ActorMethod<[GetProjectArgs], Result_1>,
|
|
205
|
-
'getQuotaLimits' : ActorMethod<[],
|
|
232
|
+
'getQuotaLimits' : ActorMethod<[], Result_3>,
|
|
206
233
|
'getRoom' : ActorMethod<[GetRoomArgs], Result>,
|
|
207
234
|
'listProjectChats' : ActorMethod<[ListProjectChatsArgs], Result_10>,
|
|
208
235
|
'listProjects' : ActorMethod<[ListProjectsArgs], Result_9>,
|
|
209
236
|
'listRooms' : ActorMethod<[ListRoomsArgs], Result_8>,
|
|
210
|
-
'markRead' : ActorMethod<[MarkReadArgs],
|
|
237
|
+
'markRead' : ActorMethod<[MarkReadArgs], Result_2>,
|
|
211
238
|
'openChat' : ActorMethod<[OpenChatArgs], Result_7>,
|
|
212
239
|
'pollNewMessages' : ActorMethod<[PollNewMessagesArgs], Result_6>,
|
|
213
240
|
'post' : ActorMethod<[PostArgs], Result_5>,
|
|
214
|
-
'purgeChat' : ActorMethod<[PurgeChatArgs],
|
|
241
|
+
'purgeChat' : ActorMethod<[PurgeChatArgs], Result_2>,
|
|
215
242
|
'registerAsAdmin' : ActorMethod<[], Result_4>,
|
|
216
|
-
'removeAdmin' : ActorMethod<[RemoveAdminArgs],
|
|
217
|
-
'setLoggingEnabled' : ActorMethod<[SetLoggingEnabledArgs],
|
|
218
|
-
'setQuotaLimits' : ActorMethod<[SetQuotaLimitsArgs],
|
|
243
|
+
'removeAdmin' : ActorMethod<[RemoveAdminArgs], Result_2>,
|
|
244
|
+
'setLoggingEnabled' : ActorMethod<[SetLoggingEnabledArgs], Result_2>,
|
|
245
|
+
'setQuotaLimits' : ActorMethod<[SetQuotaLimitsArgs], Result_3>,
|
|
246
|
+
/**
|
|
247
|
+
* / "I am writing" — a room's recipients only; it expires by itself and a post clears it.
|
|
248
|
+
*/
|
|
249
|
+
'setTyping' : ActorMethod<[SetTypingArgs], Result_2>,
|
|
219
250
|
'updateProject' : ActorMethod<[UpdateProjectArgs], Result_1>,
|
|
220
251
|
'updateRoom' : ActorMethod<[UpdateRoomArgs], Result>,
|
|
221
252
|
'whoAmI' : ActorMethod<[], Principal>,
|
|
@@ -10,7 +10,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
10
10
|
'ReturnsNull' : IDL.Null,
|
|
11
11
|
});
|
|
12
12
|
const Error = IDL.Record({ 'details' : ErrorDetails, 'logsJson' : IDL.Text });
|
|
13
|
-
const
|
|
13
|
+
const Result_2 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
|
|
14
14
|
const ProjectId = IDL.Text;
|
|
15
15
|
const CreateProjectArgs = IDL.Record({
|
|
16
16
|
'id' : ProjectId,
|
|
@@ -52,6 +52,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
52
52
|
'allowedCustomers' : IDL.Vec(IDL.Principal),
|
|
53
53
|
});
|
|
54
54
|
const Result = IDL.Variant({ 'ok' : Room, 'err' : Error });
|
|
55
|
+
const DeleteProjectArgs = IDL.Record({ 'projectId' : ProjectId });
|
|
56
|
+
const DeletionProgress = IDL.Record({
|
|
57
|
+
'chatsPurged' : IDL.Nat,
|
|
58
|
+
'messagesPurged' : IDL.Nat,
|
|
59
|
+
'finished' : IDL.Bool,
|
|
60
|
+
'roomsDeleted' : IDL.Nat,
|
|
61
|
+
});
|
|
62
|
+
const Result_14 = IDL.Variant({ 'ok' : DeletionProgress, 'err' : Error });
|
|
63
|
+
const DeleteRoomArgs = IDL.Record({
|
|
64
|
+
'projectId' : ProjectId,
|
|
65
|
+
'roomId' : RoomId,
|
|
66
|
+
});
|
|
55
67
|
const Result_13 = IDL.Variant({
|
|
56
68
|
'ok' : IDL.Vec(IDL.Principal),
|
|
57
69
|
'err' : Error,
|
|
@@ -105,8 +117,14 @@ export const idlFactory = ({ IDL }) => {
|
|
|
105
117
|
'chatId' : ChatId,
|
|
106
118
|
'roomId' : RoomId,
|
|
107
119
|
});
|
|
120
|
+
const Presence = IDL.Record({
|
|
121
|
+
'principal' : IDL.Principal,
|
|
122
|
+
'typingUntil' : IDL.Int,
|
|
123
|
+
'lastReadSeq' : IDL.Nat,
|
|
124
|
+
});
|
|
108
125
|
const MessagesPage = IDL.Record({
|
|
109
126
|
'messages' : IDL.Vec(Message),
|
|
127
|
+
'presence' : IDL.Vec(Presence),
|
|
110
128
|
'lastSeq' : IDL.Nat,
|
|
111
129
|
});
|
|
112
130
|
const Result_12 = IDL.Variant({ 'ok' : MessagesPage, 'err' : Error });
|
|
@@ -118,7 +136,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
118
136
|
const Result_11 = IDL.Variant({ 'ok' : IDL.Vec(Chat), 'err' : Error });
|
|
119
137
|
const GetProjectArgs = IDL.Record({ 'projectId' : ProjectId });
|
|
120
138
|
const QuotaLimits = IDL.Record({ 'chats' : IDL.Nat, 'posts' : IDL.Nat });
|
|
121
|
-
const
|
|
139
|
+
const Result_3 = IDL.Variant({ 'ok' : QuotaLimits, 'err' : Error });
|
|
122
140
|
const GetRoomArgs = IDL.Record({
|
|
123
141
|
'projectId' : ProjectId,
|
|
124
142
|
'roomId' : RoomId,
|
|
@@ -175,6 +193,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
175
193
|
const RemoveAdminArgs = IDL.Record({ 'principal' : IDL.Principal });
|
|
176
194
|
const SetLoggingEnabledArgs = IDL.Record({ 'enabled' : IDL.Bool });
|
|
177
195
|
const SetQuotaLimitsArgs = IDL.Record({ 'limits' : QuotaLimits });
|
|
196
|
+
const SetTypingArgs = IDL.Record({ 'chatId' : ChatId });
|
|
178
197
|
const UpdateProjectArgs = IDL.Record({
|
|
179
198
|
'accountsCanister' : IDL.Opt(IDL.Principal),
|
|
180
199
|
'projectId' : ProjectId,
|
|
@@ -188,17 +207,19 @@ export const idlFactory = ({ IDL }) => {
|
|
|
188
207
|
'allowedCustomers' : IDL.Opt(IDL.Vec(IDL.Principal)),
|
|
189
208
|
});
|
|
190
209
|
return IDL.Service({
|
|
191
|
-
'addAdmin' : IDL.Func([AddAdminArgs], [
|
|
210
|
+
'addAdmin' : IDL.Func([AddAdminArgs], [Result_2], []),
|
|
192
211
|
'clearLogs' : IDL.Func([], [], []),
|
|
193
212
|
'createProject' : IDL.Func([CreateProjectArgs], [Result_1], []),
|
|
194
213
|
'createRoom' : IDL.Func([CreateRoomArgs], [Result], []),
|
|
214
|
+
'deleteProject' : IDL.Func([DeleteProjectArgs], [Result_14], []),
|
|
215
|
+
'deleteRoom' : IDL.Func([DeleteRoomArgs], [Result_14], []),
|
|
195
216
|
'getAdmins' : IDL.Func([], [Result_13], ['query']),
|
|
196
217
|
'getChat' : IDL.Func([GetChatArgs], [Result_7], ['query']),
|
|
197
218
|
'getLogs' : IDL.Func([], [IDL.Text], ['query']),
|
|
198
219
|
'getMessages' : IDL.Func([GetMessagesArgs], [Result_12], ['query']),
|
|
199
220
|
'getMyChats' : IDL.Func([GetMyChatsArgs], [Result_11], ['query']),
|
|
200
221
|
'getProject' : IDL.Func([GetProjectArgs], [Result_1], ['query']),
|
|
201
|
-
'getQuotaLimits' : IDL.Func([], [
|
|
222
|
+
'getQuotaLimits' : IDL.Func([], [Result_3], ['query']),
|
|
202
223
|
'getRoom' : IDL.Func([GetRoomArgs], [Result], ['query']),
|
|
203
224
|
'listProjectChats' : IDL.Func(
|
|
204
225
|
[ListProjectChatsArgs],
|
|
@@ -207,15 +228,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
207
228
|
),
|
|
208
229
|
'listProjects' : IDL.Func([ListProjectsArgs], [Result_9], ['query']),
|
|
209
230
|
'listRooms' : IDL.Func([ListRoomsArgs], [Result_8], ['query']),
|
|
210
|
-
'markRead' : IDL.Func([MarkReadArgs], [
|
|
231
|
+
'markRead' : IDL.Func([MarkReadArgs], [Result_2], []),
|
|
211
232
|
'openChat' : IDL.Func([OpenChatArgs], [Result_7], []),
|
|
212
233
|
'pollNewMessages' : IDL.Func([PollNewMessagesArgs], [Result_6], ['query']),
|
|
213
234
|
'post' : IDL.Func([PostArgs], [Result_5], []),
|
|
214
|
-
'purgeChat' : IDL.Func([PurgeChatArgs], [
|
|
235
|
+
'purgeChat' : IDL.Func([PurgeChatArgs], [Result_2], []),
|
|
215
236
|
'registerAsAdmin' : IDL.Func([], [Result_4], []),
|
|
216
|
-
'removeAdmin' : IDL.Func([RemoveAdminArgs], [
|
|
217
|
-
'setLoggingEnabled' : IDL.Func([SetLoggingEnabledArgs], [
|
|
218
|
-
'setQuotaLimits' : IDL.Func([SetQuotaLimitsArgs], [
|
|
237
|
+
'removeAdmin' : IDL.Func([RemoveAdminArgs], [Result_2], []),
|
|
238
|
+
'setLoggingEnabled' : IDL.Func([SetLoggingEnabledArgs], [Result_2], []),
|
|
239
|
+
'setQuotaLimits' : IDL.Func([SetQuotaLimitsArgs], [Result_3], []),
|
|
240
|
+
'setTyping' : IDL.Func([SetTypingArgs], [Result_2], []),
|
|
219
241
|
'updateProject' : IDL.Func([UpdateProjectArgs], [Result_1], []),
|
|
220
242
|
'updateRoom' : IDL.Func([UpdateRoomArgs], [Result], []),
|
|
221
243
|
'whoAmI' : IDL.Func([], [IDL.Principal], ['query']),
|
|
@@ -22,7 +22,18 @@ export declare class MessagesActor extends ActorBase {
|
|
|
22
22
|
*/
|
|
23
23
|
markReadAsyncUnsafe(chatId: string, seq: number): Promise<boolean>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Reports that the caller is writing: true for 30 seconds, cleared by their own next
|
|
26
|
+
* post, and gone by itself afterwards — so a client that dies mid-turn leaves no
|
|
27
|
+
* indicator hanging. A ROOM'S RECIPIENTS ONLY (a person or an agent); a customer is
|
|
28
|
+
* refused. Send it once at the start of a turn, not per keystroke.
|
|
29
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for a customer or a non-participant, `NotFound` for the chat). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
30
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
31
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
32
|
+
*/
|
|
33
|
+
setTypingAsyncUnsafe(chatId: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* A chat's messages with seq > sinceSeq, oldest first (max 200 per call), together
|
|
36
|
+
* with `presence`: who is typing and how far each other participant has read.
|
|
26
37
|
* Participants only.
|
|
27
38
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
28
39
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-actor.d.ts","sourceRoot":"","sources":["../../src/actors/messages-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAA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,CAAC,OAAO,CAAC;IAI/E;;;;;;;;OAQG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE;;;;;;;OAOG;IACU,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWvF;;;;;;;OAOG;IACU,0BAA0B,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAU7F,sFAAsF;IACzE,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAOrG"}
|
|
@@ -40,7 +40,20 @@ export class MessagesActor extends ActorBase {
|
|
|
40
40
|
return this.executeFunctionAsyncUnsafe(() => this.actor.markRead({ chatId, seq: BigInt(seq) }));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Reports that the caller is writing: true for 30 seconds, cleared by their own next
|
|
44
|
+
* post, and gone by itself afterwards — so a client that dies mid-turn leaves no
|
|
45
|
+
* indicator hanging. A ROOM'S RECIPIENTS ONLY (a person or an agent); a customer is
|
|
46
|
+
* refused. Send it once at the start of a turn, not per keystroke.
|
|
47
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for a customer or a non-participant, `NotFound` for the chat). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
48
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
49
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
50
|
+
*/
|
|
51
|
+
async setTypingAsyncUnsafe(chatId) {
|
|
52
|
+
return this.executeFunctionAsyncUnsafe(() => this.actor.setTyping({ chatId }));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A chat's messages with seq > sinceSeq, oldest first (max 200 per call), together
|
|
56
|
+
* with `presence`: who is typing and how far each other participant has read.
|
|
44
57
|
* Participants only.
|
|
45
58
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
46
59
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Identity } from "@icp-sdk/core/agent";
|
|
2
2
|
import { ActorBase } from "../actor-base.js";
|
|
3
|
-
import type { CreateProjectInput, ProjectView, UpdateProjectInput } from "../interfaces.js";
|
|
3
|
+
import type { CreateProjectInput, DeletionProgressView, ProjectView, UpdateProjectInput } from "../interfaces.js";
|
|
4
4
|
/** 1:1 wrapper for the canister's ProjectsController — a project is the space of one site
|
|
5
5
|
* or company; its admins define the rooms. */
|
|
6
6
|
export declare class ProjectsActor extends ActorBase {
|
|
@@ -21,6 +21,28 @@ export declare class ProjectsActor extends ActorBase {
|
|
|
21
21
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
22
22
|
*/
|
|
23
23
|
updateProjectAsyncUnsafe(input: UpdateProjectInput): Promise<ProjectView>;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes a project with every room, every chat and every message in it, repeating the
|
|
26
|
+
* bounded canister call until the project is gone. Canister admins only — a project
|
|
27
|
+
* admin may not delete the project it works in. Irreversible. A failure half-way leaves
|
|
28
|
+
* the project partly emptied — call again to finish.
|
|
29
|
+
* @param onStep - Called after every canister call with what that call removed, e.g. to show progress on a big project.
|
|
30
|
+
* @returns The totals of all calls; `finished` is always true.
|
|
31
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized — canister admins only, `NotFound` for the project). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
32
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
33
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
34
|
+
*/
|
|
35
|
+
deleteProjectAsyncUnsafe(projectId: string, onStep?: (progress: DeletionProgressView) => void): Promise<DeletionProgressView>;
|
|
36
|
+
/**
|
|
37
|
+
* One bounded call of deleting a project — the canister method 1:1. It removes up to 500
|
|
38
|
+
* chats or 50 000 messages (always at least one chat) and, once no chat is left, every
|
|
39
|
+
* room and the project. Canister admins only. Most callers want `deleteProjectAsyncUnsafe`.
|
|
40
|
+
* @returns What this call removed; `finished` = the project is gone.
|
|
41
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized — canister admins only, `NotFound` for the project). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
42
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
43
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
44
|
+
*/
|
|
45
|
+
deleteProjectStepAsyncUnsafe(projectId: string): Promise<DeletionProgressView>;
|
|
24
46
|
/**
|
|
25
47
|
* One project. Canister admins and the project's admins.
|
|
26
48
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects-actor.d.ts","sourceRoot":"","sources":["../../src/actors/projects-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"projects-actor.d.ts","sourceRoot":"","sources":["../../src/actors/projects-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAIlH;8CAC8C;AAC9C,qBAAa,aAAc,SAAQ,SAAS;gBAE5B,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAWtF;;;;;;OAMG;IACU,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAWtF;;;;;;;;;;OAUG;IACU,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI1I;;;;;;;;OAQG;IACU,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAK3F;;;;;OAKG;IACU,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAK3E;;;;;OAKG;IACU,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAI/E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {} from "@icp-sdk/core/agent";
|
|
2
2
|
import { Principal } from "@icp-sdk/core/principal";
|
|
3
3
|
import { ActorBase } from "../actor-base.js";
|
|
4
|
-
import { mapProjectView, toOpt, toOptBigInt } from "../mappers.js";
|
|
4
|
+
import { mapDeletionProgressView, mapProjectView, toOpt, toOptBigInt } from "../mappers.js";
|
|
5
|
+
import { deleteUntilFinishedAsyncUnsafe } from "../deletion.js";
|
|
5
6
|
/** 1:1 wrapper for the canister's ProjectsController — a project is the space of one site
|
|
6
7
|
* or company; its admins define the rooms. */
|
|
7
8
|
export class ProjectsActor extends ActorBase {
|
|
@@ -38,6 +39,33 @@ export class ProjectsActor extends ActorBase {
|
|
|
38
39
|
}));
|
|
39
40
|
return mapProjectView(project);
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Deletes a project with every room, every chat and every message in it, repeating the
|
|
44
|
+
* bounded canister call until the project is gone. Canister admins only — a project
|
|
45
|
+
* admin may not delete the project it works in. Irreversible. A failure half-way leaves
|
|
46
|
+
* the project partly emptied — call again to finish.
|
|
47
|
+
* @param onStep - Called after every canister call with what that call removed, e.g. to show progress on a big project.
|
|
48
|
+
* @returns The totals of all calls; `finished` is always true.
|
|
49
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized — canister admins only, `NotFound` for the project). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
50
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
51
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
52
|
+
*/
|
|
53
|
+
async deleteProjectAsyncUnsafe(projectId, onStep) {
|
|
54
|
+
return deleteUntilFinishedAsyncUnsafe(() => this.deleteProjectStepAsyncUnsafe(projectId), onStep);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One bounded call of deleting a project — the canister method 1:1. It removes up to 500
|
|
58
|
+
* chats or 50 000 messages (always at least one chat) and, once no chat is left, every
|
|
59
|
+
* room and the project. Canister admins only. Most callers want `deleteProjectAsyncUnsafe`.
|
|
60
|
+
* @returns What this call removed; `finished` = the project is gone.
|
|
61
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized — canister admins only, `NotFound` for the project). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
62
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
63
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
64
|
+
*/
|
|
65
|
+
async deleteProjectStepAsyncUnsafe(projectId) {
|
|
66
|
+
const progress = await this.executeFunctionAsyncUnsafe(() => this.actor.deleteProject({ projectId }));
|
|
67
|
+
return mapDeletionProgressView(progress);
|
|
68
|
+
}
|
|
41
69
|
/**
|
|
42
70
|
* One project. Canister admins and the project's admins.
|
|
43
71
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Identity } from "@icp-sdk/core/agent";
|
|
2
2
|
import { ActorBase } from "../actor-base.js";
|
|
3
|
-
import type { CreateRoomInput, ListRoomsInput, RoomRefInput, RoomView, UpdateRoomInput } from "../interfaces.js";
|
|
3
|
+
import type { CreateRoomInput, DeletionProgressView, ListRoomsInput, RoomRefInput, RoomView, UpdateRoomInput } from "../interfaces.js";
|
|
4
4
|
/** 1:1 wrapper for the canister's RoomsController — a room is the template a chat is
|
|
5
5
|
* opened from: it names who receives the customer's messages. */
|
|
6
6
|
export declare class RoomsActor extends ActorBase {
|
|
@@ -20,6 +20,27 @@ export declare class RoomsActor extends ActorBase {
|
|
|
20
20
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
21
21
|
*/
|
|
22
22
|
updateRoomAsyncUnsafe(input: UpdateRoomInput): Promise<RoomView>;
|
|
23
|
+
/**
|
|
24
|
+
* Deletes a room with every chat opened from it and their messages, repeating the
|
|
25
|
+
* bounded canister call until the room is gone. Project admins and canister admins.
|
|
26
|
+
* Irreversible. A failure half-way leaves the room partly emptied — call again to finish.
|
|
27
|
+
* @param onStep - Called after every canister call with what that call removed, e.g. to show progress on a big room.
|
|
28
|
+
* @returns The totals of all calls; `finished` is always true.
|
|
29
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
30
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
31
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
32
|
+
*/
|
|
33
|
+
deleteRoomAsyncUnsafe(input: RoomRefInput, onStep?: (progress: DeletionProgressView) => void): Promise<DeletionProgressView>;
|
|
34
|
+
/**
|
|
35
|
+
* One bounded call of deleting a room — the canister method 1:1. It removes up to 500
|
|
36
|
+
* chats or 50 000 messages (always at least one chat) and, once no chat is left, the
|
|
37
|
+
* room. Project admins and canister admins. Most callers want `deleteRoomAsyncUnsafe`.
|
|
38
|
+
* @returns What this call removed; `finished` = the room is gone.
|
|
39
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
40
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
41
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
42
|
+
*/
|
|
43
|
+
deleteRoomStepAsyncUnsafe(input: RoomRefInput): Promise<DeletionProgressView>;
|
|
23
44
|
/**
|
|
24
45
|
* One room with its recipients. Any signed-in caller — a site shows the names before
|
|
25
46
|
* the customer opens the chat.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rooms-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rooms-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"rooms-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rooms-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIvI;iEACiE;AACjE,qBAAa,UAAW,SAAQ,SAAS;gBAEzB,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAa7E;;;;;OAKG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAa7E;;;;;;;;;OASG;IACU,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIzI;;;;;;;;OAQG;IACU,yBAAyB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAK1F;;;;;;OAMG;IACU,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKvE;;;;;;OAMG;IACU,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAIhF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {} from "@icp-sdk/core/agent";
|
|
2
2
|
import { Principal } from "@icp-sdk/core/principal";
|
|
3
3
|
import { ActorBase } from "../actor-base.js";
|
|
4
|
-
import { mapRoomView, toCandidRecipient, toOpt, toOptBigInt } from "../mappers.js";
|
|
4
|
+
import { mapDeletionProgressView, mapRoomView, toCandidRecipient, toOpt, toOptBigInt } from "../mappers.js";
|
|
5
|
+
import { deleteUntilFinishedAsyncUnsafe } from "../deletion.js";
|
|
5
6
|
/** 1:1 wrapper for the canister's RoomsController — a room is the template a chat is
|
|
6
7
|
* opened from: it names who receives the customer's messages. */
|
|
7
8
|
export class RoomsActor extends ActorBase {
|
|
@@ -41,6 +42,32 @@ export class RoomsActor extends ActorBase {
|
|
|
41
42
|
}));
|
|
42
43
|
return mapRoomView(room);
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Deletes a room with every chat opened from it and their messages, repeating the
|
|
47
|
+
* bounded canister call until the room is gone. Project admins and canister admins.
|
|
48
|
+
* Irreversible. A failure half-way leaves the room partly emptied — call again to finish.
|
|
49
|
+
* @param onStep - Called after every canister call with what that call removed, e.g. to show progress on a big room.
|
|
50
|
+
* @returns The totals of all calls; `finished` is always true.
|
|
51
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
52
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
53
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
54
|
+
*/
|
|
55
|
+
async deleteRoomAsyncUnsafe(input, onStep) {
|
|
56
|
+
return deleteUntilFinishedAsyncUnsafe(() => this.deleteRoomStepAsyncUnsafe(input), onStep);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One bounded call of deleting a room — the canister method 1:1. It removes up to 500
|
|
60
|
+
* chats or 50 000 messages (always at least one chat) and, once no chat is left, the
|
|
61
|
+
* room. Project admins and canister admins. Most callers want `deleteRoomAsyncUnsafe`.
|
|
62
|
+
* @returns What this call removed; `finished` = the room is gone.
|
|
63
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
64
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
65
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
66
|
+
*/
|
|
67
|
+
async deleteRoomStepAsyncUnsafe(input) {
|
|
68
|
+
const progress = await this.executeFunctionAsyncUnsafe(() => this.actor.deleteRoom({ projectId: input.projectId, roomId: input.roomId }));
|
|
69
|
+
return mapDeletionProgressView(progress);
|
|
70
|
+
}
|
|
44
71
|
/**
|
|
45
72
|
* One room with its recipients. Any signed-in caller — a site shows the names before
|
|
46
73
|
* the customer opens the chat.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeletionProgressView } from "./interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* Repeats one bounded delete call until the canister reports the room or project gone,
|
|
4
|
+
* adding up what every call removed. Every call removes at least one chat, so the loop
|
|
5
|
+
* ends unless chats are opened faster than they are deleted.
|
|
6
|
+
*/
|
|
7
|
+
export declare function deleteUntilFinishedAsyncUnsafe(step: () => Promise<DeletionProgressView>, onStep?: (progress: DeletionProgressView) => void): Promise<DeletionProgressView>;
|
|
8
|
+
//# sourceMappingURL=deletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deletion.d.ts","sourceRoot":"","sources":["../src/deletion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;;;GAIG;AACH,wBAAsB,8BAA8B,CAChD,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,EACzC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAClD,OAAO,CAAC,oBAAoB,CAAC,CAc/B"}
|
package/dist/deletion.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeats one bounded delete call until the canister reports the room or project gone,
|
|
3
|
+
* adding up what every call removed. Every call removes at least one chat, so the loop
|
|
4
|
+
* ends unless chats are opened faster than they are deleted.
|
|
5
|
+
*/
|
|
6
|
+
export async function deleteUntilFinishedAsyncUnsafe(step, onStep) {
|
|
7
|
+
const total = { finished: false, roomsDeleted: 0, chatsPurged: 0, messagesPurged: 0 };
|
|
8
|
+
while (!total.finished) {
|
|
9
|
+
const progress = await step();
|
|
10
|
+
onStep?.(progress);
|
|
11
|
+
total.finished = progress.finished;
|
|
12
|
+
total.roomsDeleted += progress.roomsDeleted;
|
|
13
|
+
total.chatsPurged += progress.chatsPurged;
|
|
14
|
+
total.messagesPurged += progress.messagesPurged;
|
|
15
|
+
}
|
|
16
|
+
return total;
|
|
17
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { RoomsActor } from "./actors/rooms-actor.js";
|
|
|
5
5
|
export { ChatsActor } from "./actors/chats-actor.js";
|
|
6
6
|
export { MessagesActor } from "./actors/messages-actor.js";
|
|
7
7
|
export { ChatPoller, type ChatPollerOptions } from "./chat-poller.js";
|
|
8
|
-
export type { RoleView, RecipientRoleView, ProjectView, RecipientView, RoomView, ParticipantView, ChatView, ChatSummaryView, SystemEventView, MessageKindView, MessageView, MessagesPageView, PollResultView, QuotaLimitsView, CreateProjectInput, UpdateProjectInput, CreateRoomInput, UpdateRoomInput, RoomRefInput, ListRoomsInput, OpenChatInput, GetMyChatsInput, ListProjectChatsInput, PostInput, GetMessagesInput, PollNewMessagesInput, } from "./interfaces.js";
|
|
9
|
-
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
|
10
|
-
export type { Chat, ChatId, ChatSummary, Message, MessageKind, MessagesPage, Participant, PollResult, Project, ProjectId, QuotaLimits, Recipient, RecipientRole, Role, Room, RoomId, SystemEvent, Error as CanisterErrorShape, ErrorDetails, } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
|
|
8
|
+
export type { RoleView, RecipientRoleView, ProjectView, RecipientView, RoomView, ParticipantView, ChatView, ChatSummaryView, SystemEventView, MessageKindView, MessageView, MessagesPageView, PresenceView, PollResultView, QuotaLimitsView, DeletionProgressView, CreateProjectInput, UpdateProjectInput, CreateRoomInput, UpdateRoomInput, RoomRefInput, ListRoomsInput, OpenChatInput, GetMyChatsInput, ListProjectChatsInput, PostInput, GetMessagesInput, PollNewMessagesInput, } from "./interfaces.js";
|
|
9
|
+
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapDeletionProgressView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
|
10
|
+
export type { Chat, ChatId, ChatSummary, DeletionProgress, Message, MessageKind, MessagesPage, Participant, PollResult, Project, ProjectId, QuotaLimits, Recipient, RecipientRole, Role, Room, RoomId, SystemEvent, Error as CanisterErrorShape, ErrorDetails, } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,gEAAgE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,gEAAgE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { RoomsActor } from "./actors/rooms-actor.js";
|
|
|
5
5
|
export { ChatsActor } from "./actors/chats-actor.js";
|
|
6
6
|
export { MessagesActor } from "./actors/messages-actor.js";
|
|
7
7
|
export { ChatPoller } from "./chat-poller.js";
|
|
8
|
-
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
|
8
|
+
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapDeletionProgressView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -86,6 +86,21 @@ export interface MessageView {
|
|
|
86
86
|
export interface MessagesPageView {
|
|
87
87
|
messages: MessageView[];
|
|
88
88
|
lastSeq: number;
|
|
89
|
+
/** What every OTHER participant is doing right now — the caller's own row is left out. */
|
|
90
|
+
presence: PresenceView[];
|
|
91
|
+
}
|
|
92
|
+
/** Who is typing and how far they have read, as of the moment the page was read. */
|
|
93
|
+
export interface PresenceView {
|
|
94
|
+
principal: string;
|
|
95
|
+
/**
|
|
96
|
+
* `true` while this participant's typing signal is still valid. Derived from the
|
|
97
|
+
* canister's instant and the clock at read time, so it needs no timer of its own.
|
|
98
|
+
*/
|
|
99
|
+
typing: boolean;
|
|
100
|
+
/** Nanoseconds; 0 when the participant is not typing. */
|
|
101
|
+
typingUntil: bigint;
|
|
102
|
+
/** Highest per-chat seq this participant has marked read (0 = nothing). */
|
|
103
|
+
lastReadSeq: number;
|
|
89
104
|
}
|
|
90
105
|
export interface PollResultView {
|
|
91
106
|
messages: MessageView[];
|
|
@@ -93,6 +108,17 @@ export interface PollResultView {
|
|
|
93
108
|
nextSinceGlobalSeq: number;
|
|
94
109
|
headGlobalSeq: number;
|
|
95
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* What one delete call removed. The canister deletes a big room or project over several
|
|
113
|
+
* bounded calls (500 chats or 50 000 messages each); `finished` = the room, or the project
|
|
114
|
+
* with all its rooms, is gone.
|
|
115
|
+
*/
|
|
116
|
+
export interface DeletionProgressView {
|
|
117
|
+
finished: boolean;
|
|
118
|
+
roomsDeleted: number;
|
|
119
|
+
chatsPurged: number;
|
|
120
|
+
messagesPurged: number;
|
|
121
|
+
}
|
|
96
122
|
export interface QuotaLimitsView {
|
|
97
123
|
/** Messages one principal may post per UTC day. */
|
|
98
124
|
posts: number;
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AACvD,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wFAAwF;IACxF,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,iBAAiB,CAAC;IACxB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,YAAY,CAAC,EAA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5 @@
|
|
|
1
|
-
import type { Chat, ChatSummary, Message, MessagesPage, Participant, PollResult, Project, QuotaLimits, Recipient, RecipientRole, Role, Room, SystemEvent } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
|
|
2
|
-
import type { ChatSummaryView, ChatView, MessageView, MessagesPageView, ParticipantView, PollResultView, ProjectView, QuotaLimitsView, RecipientRoleView, RecipientView, RoleView, RoomView, SystemEventView } from "./interfaces.js";
|
|
1
|
+
import type { Chat, ChatSummary, DeletionProgress, Message, MessagesPage, Participant, PollResult, Project, QuotaLimits, Recipient, RecipientRole, Role, Room, SystemEvent } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
|
|
2
|
+
import type { ChatSummaryView, ChatView, DeletionProgressView, MessageView, MessagesPageView, ParticipantView, PollResultView, ProjectView, QuotaLimitsView, RecipientRoleView, RecipientView, RoleView, RoomView, SystemEventView } from "./interfaces.js";
|
|
3
3
|
export declare function fromOpt<T>(opt: [] | [T]): T | undefined;
|
|
4
4
|
export declare function toOpt<T>(value: T | undefined): [] | [T];
|
|
5
5
|
export declare function toOptBigInt(value: number | undefined): [] | [bigint];
|
|
@@ -17,6 +17,7 @@ export declare function mapSystemEventView(_event: SystemEvent): SystemEventView
|
|
|
17
17
|
export declare function mapMessageView(message: Message): MessageView;
|
|
18
18
|
export declare function mapMessagesPageView(page: MessagesPage): MessagesPageView;
|
|
19
19
|
export declare function mapPollResultView(result: PollResult): PollResultView;
|
|
20
|
+
export declare function mapDeletionProgressView(progress: DeletionProgress): DeletionProgressView;
|
|
20
21
|
export declare function mapQuotaLimitsView(limits: QuotaLimits): QuotaLimitsView;
|
|
21
22
|
export declare function toCandidQuotaLimits(limits: QuotaLimitsView): QuotaLimits;
|
|
22
23
|
//# sourceMappingURL=mappers.d.ts.map
|
package/dist/mappers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings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aAAa,GAAG,iBAAiB,CAE3E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAK5E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAMjE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CAMpE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ5D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAUhD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAU5E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAWhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAWxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAiB5D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAcxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAMpE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,oBAAoB,CAOxF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAExE"}
|
package/dist/mappers.js
CHANGED
|
@@ -110,7 +110,19 @@ export function mapMessageView(message) {
|
|
|
110
110
|
return { ...base, kind: "toolTrace" in message.kind ? "toolTrace" : "text" };
|
|
111
111
|
}
|
|
112
112
|
export function mapMessagesPageView(page) {
|
|
113
|
-
|
|
113
|
+
// The canister answers with the instant a signal expires; whether it still holds is a
|
|
114
|
+
// question about now, and the caller should not have to ask it themselves.
|
|
115
|
+
const nowNs = BigInt(Date.now()) * 1000000n;
|
|
116
|
+
return {
|
|
117
|
+
messages: page.messages.map(mapMessageView),
|
|
118
|
+
lastSeq: Number(page.lastSeq),
|
|
119
|
+
presence: page.presence.map((entry) => ({
|
|
120
|
+
principal: entry.principal.toText(),
|
|
121
|
+
typing: entry.typingUntil > nowNs,
|
|
122
|
+
typingUntil: entry.typingUntil,
|
|
123
|
+
lastReadSeq: Number(entry.lastReadSeq),
|
|
124
|
+
})),
|
|
125
|
+
};
|
|
114
126
|
}
|
|
115
127
|
export function mapPollResultView(result) {
|
|
116
128
|
return {
|
|
@@ -119,6 +131,14 @@ export function mapPollResultView(result) {
|
|
|
119
131
|
headGlobalSeq: Number(result.headGlobalSeq),
|
|
120
132
|
};
|
|
121
133
|
}
|
|
134
|
+
export function mapDeletionProgressView(progress) {
|
|
135
|
+
return {
|
|
136
|
+
finished: progress.finished,
|
|
137
|
+
roomsDeleted: Number(progress.roomsDeleted),
|
|
138
|
+
chatsPurged: Number(progress.chatsPurged),
|
|
139
|
+
messagesPurged: Number(progress.messagesPurged),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
122
142
|
export function mapQuotaLimitsView(limits) {
|
|
123
143
|
return { posts: Number(limits.posts), chats: Number(limits.chats) };
|
|
124
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/chat-motoko-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Wrapper TypeScript package for the chat-motoko canister: projects, multi-party chats, messages and a poller for agent hosts.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"chatMotoko": {
|
|
59
59
|
"repo": "chat-motoko",
|
|
60
60
|
"repoUrl": "https://github.com/JSM-Chat-Platform/chat-motoko",
|
|
61
|
-
"commit": "
|
|
61
|
+
"commit": "7b8a10294dea4e255c23c77dc9e415e3996c7347"
|
|
62
62
|
}
|
|
63
63
|
}
|