@jsm-mit/chat-motoko-package 0.6.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 CHANGED
@@ -42,6 +42,13 @@ One class per canister controller (`AdminActor`, `ProjectsActor`, `RoomsActor`,
42
42
  throws). Views translate `Principal` → text, `opt` → optional, variants → string
43
43
  unions; sequence numbers are plain `number`s, timestamps `bigint` nanoseconds.
44
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
+
45
52
  `src/` is browser-safe — the same package serves the agent host and a web panel.
46
53
 
47
54
  Scripts: `build`, `typecheck`, `sync-declarations`, `test-suite`,
@@ -73,6 +73,11 @@ type Result_2 =
73
73
  err: Error;
74
74
  ok: bool;
75
75
  };
76
+ type Result_14 =
77
+ variant {
78
+ err: Error;
79
+ ok: DeletionProgress;
80
+ };
76
81
  type Result_13 =
77
82
  variant {
78
83
  err: Error;
@@ -250,6 +255,19 @@ type Error =
250
255
  details: ErrorDetails;
251
256
  logsJson: text;
252
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;};
253
271
  type CreateRoomArgs =
254
272
  record {
255
273
  allowedCustomers: vec principal;
@@ -293,6 +311,12 @@ service : {
293
311
  clearLogs: () -> ();
294
312
  createProject: (args: CreateProjectArgs) -> (Result_1);
295
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);
296
320
  getAdmins: () -> (Result_13) query;
297
321
  getChat: (args: GetChatArgs) -> (Result_7) query;
298
322
  getLogs: () -> (text) 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 } |
@@ -153,6 +161,8 @@ export type Result_12 = { 'ok' : MessagesPage } |
153
161
  { 'err' : Error };
154
162
  export type Result_13 = { 'ok' : Array<Principal> } |
155
163
  { 'err' : Error };
164
+ export type Result_14 = { 'ok' : DeletionProgress } |
165
+ { 'err' : Error };
156
166
  export type Result_2 = { 'ok' : boolean } |
157
167
  { 'err' : Error };
158
168
  export type Result_3 = { 'ok' : QuotaLimits } |
@@ -203,6 +213,16 @@ export interface _SERVICE {
203
213
  'clearLogs' : ActorMethod<[], undefined>,
204
214
  'createProject' : ActorMethod<[CreateProjectArgs], Result_1>,
205
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>,
206
226
  'getAdmins' : ActorMethod<[], Result_13>,
207
227
  'getChat' : ActorMethod<[GetChatArgs], Result_7>,
208
228
  'getLogs' : ActorMethod<[], string>,
@@ -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,
@@ -199,6 +211,8 @@ export const idlFactory = ({ IDL }) => {
199
211
  'clearLogs' : IDL.Func([], [], []),
200
212
  'createProject' : IDL.Func([CreateProjectArgs], [Result_1], []),
201
213
  'createRoom' : IDL.Func([CreateRoomArgs], [Result], []),
214
+ 'deleteProject' : IDL.Func([DeleteProjectArgs], [Result_14], []),
215
+ 'deleteRoom' : IDL.Func([DeleteRoomArgs], [Result_14], []),
202
216
  'getAdmins' : IDL.Func([], [Result_13], ['query']),
203
217
  'getChat' : IDL.Func([GetChatArgs], [Result_7], ['query']),
204
218
  'getLogs' : IDL.Func([], [IDL.Text], ['query']),
@@ -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;AAG5F;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;;;;;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
+ {"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;AAGjH;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;;;;;;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
+ {"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"}
@@ -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, PresenceView, 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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,E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AAa,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";
@@ -108,6 +108,17 @@ export interface PollResultView {
108
108
  nextSinceGlobalSeq: number;
109
109
  headGlobalSeq: number;
110
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
+ }
111
122
  export interface QuotaLimitsView {
112
123
  /** Messages one principal may post per UTC day. */
113
124
  posts: number;
@@ -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,G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MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
package/dist/mappers.d.ts CHANGED
@@ -1,5 +1,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
@@ -1 +1 @@
1
- {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,IAAI,EACJ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,WAAW,EACd,MAAM,gEAAgE,CAAC;AACxE,OAAO,KAAK,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAEvD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAEvD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAA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AAQ,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
@@ -131,6 +131,14 @@ export function mapPollResultView(result) {
131
131
  headGlobalSeq: Number(result.headGlobalSeq),
132
132
  };
133
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
+ }
134
142
  export function mapQuotaLimitsView(limits) {
135
143
  return { posts: Number(limits.posts), chats: Number(limits.chats) };
136
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsm-mit/chat-motoko-package",
3
- "version": "0.6.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": "a5184ccd2c42aefd0b21dc0419cd24530e10de5b"
61
+ "commit": "7b8a10294dea4e255c23c77dc9e415e3996c7347"
62
62
  }
63
63
  }