@jsm-mit/chat-motoko-package 0.1.0 → 0.2.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.
@@ -1,6 +1,7 @@
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 { mapQuotaLimitsView, toCandidQuotaLimits } from "../mappers.js";
4
5
  /** 1:1 wrapper for the canister's AdminController plus the three diagnostics. */
5
6
  export class AdminActor extends ActorBase {
6
7
  constructor(canisterId, identity) {
@@ -52,6 +53,26 @@ export class AdminActor extends ActorBase {
52
53
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
53
54
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
54
55
  */
56
+ /**
57
+ * Sets the daily caps per principal (posts and new chats), both positive. Admin only.
58
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `InvalidData` for a zero). Examine "cause" for {errorKey, errorMessage, logs}.
59
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
60
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
61
+ */
62
+ async setQuotaLimitsAsyncUnsafe(limits) {
63
+ const result = await this.executeFunctionAsyncUnsafe(() => this.actor.setQuotaLimits({ limits: toCandidQuotaLimits(limits) }));
64
+ return mapQuotaLimitsView(result);
65
+ }
66
+ /**
67
+ * The daily caps in force. Any signed-in caller.
68
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized for anonymous). Examine "cause" for {errorKey, errorMessage, logs}.
69
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
70
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
71
+ */
72
+ async getQuotaLimitsAsyncUnsafe() {
73
+ const result = await this.executeFunctionAsyncUnsafe(() => this.actor.getQuotaLimits());
74
+ return mapQuotaLimitsView(result);
75
+ }
55
76
  async setLoggingEnabledAsyncUnsafe(enabled) {
56
77
  return this.executeFunctionAsyncUnsafe(() => this.actor.setLoggingEnabled({ enabled }));
57
78
  }
@@ -1,77 +1,49 @@
1
1
  import { type Identity } from "@icp-sdk/core/agent";
2
2
  import { ActorBase } from "../actor-base.js";
3
- import type { ChatView, CreateChatInput, GetMyChatsInput, InviteMemberInput, PolicyView, RemoveMemberInput } from "../interfaces.js";
4
- /** 1:1 wrapper for the canister's ChatsController — rooms, members, roles and policy. */
3
+ import type { ChatSummaryView, ChatView, GetMyChatsInput, ListProjectChatsInput, OpenChatInput } from "../interfaces.js";
4
+ /** 1:1 wrapper for the canister's ChatsController — chats opened from rooms. */
5
5
  export declare class ChatsActor extends ActorBase {
6
6
  constructor(canisterId: string, identity?: Identity);
7
7
  /**
8
- * Creates a chat: the caller becomes `owner`, the project's agents join as `agent`, the
9
- * canister writes the `chatCreated` event and — when given — the first text message,
10
- * all in one call.
11
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the project, `InvalidData` for members/lengths/quotas). Examine "cause" for {errorKey, errorMessage, logs}.
8
+ * Opens the caller's chat in a room: the caller becomes the `customer`, the room's
9
+ * recipients are copied in, the canister writes the `chatCreated` event. One chat per
10
+ * (room, customer, recipients) — calling again returns the same chat unchanged.
11
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room, `InvalidData` when the caller is a recipient of the room, the name is too long or the daily chat limit is reached). Examine "cause" for {errorKey, errorMessage, logs}.
12
12
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
13
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
14
- */
15
- createChatAsyncUnsafe(input: CreateChatInput): Promise<ChatView>;
16
- /**
17
- * Adds a member. Owner/admin members, project admins, canister admins — and agent
18
- * members when the project allows it (agents may only add `member`s).
19
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `AlreadyExists`, `InvalidData` for a closed chat / anonymous / limit). Examine "cause" for {errorKey, errorMessage, logs}.
20
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
21
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
22
- */
23
- inviteMemberAsyncUnsafe(input: InviteMemberInput): Promise<ChatView>;
24
- /**
25
- * Removes somebody else; an owner can be removed only by a project admin.
26
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for self-removal / closed chat). Examine "cause" for {errorKey, errorMessage, logs}.
27
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
28
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
29
- */
30
- removeMemberAsyncUnsafe(input: RemoveMemberInput): Promise<ChatView>;
31
- /**
32
- * Leaves the chat. The last owner/admin of an open chat cannot leave — close it instead.
33
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for the last manager). Examine "cause" for {errorKey, errorMessage, logs}.
34
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
35
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
13
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution (anonymous, or today's chat quota used up).
36
14
  */
37
- leaveChatAsyncUnsafe(chatId: string): Promise<boolean>;
15
+ openChatAsyncUnsafe(input: OpenChatInput): Promise<ChatView>;
38
16
  /**
39
- * Changes the policy agents read (e.g. `agentsReply: false` to hand the chat to a human).
40
- * Same callers as inviteMember.
41
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for a closed chat). Examine "cause" for {errorKey, errorMessage, logs}.
17
+ * One chat with its participants. Participants only — not even admins.
18
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
42
19
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
43
20
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
44
21
  */
45
- setPolicyAsyncUnsafe(chatId: string, policy: PolicyView): Promise<ChatView>;
22
+ getChatAsyncUnsafe(chatId: string): Promise<ChatView>;
46
23
  /**
47
- * Closes the chat for good (no more posts or membership changes). Owner/admin members,
48
- * project admins, canister admins — not agents.
49
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` when already closed). Examine "cause" for {errorKey, errorMessage, logs}.
24
+ * The caller's chats in a project — as customer or as recipient — newest first,
25
+ * optionally one room only.
26
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized). Examine "cause" for {errorKey, errorMessage, logs}.
50
27
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
51
28
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
52
29
  */
53
- closeChatAsyncUnsafe(chatId: string): Promise<ChatView>;
30
+ getMyChatsAsyncUnsafe(input: GetMyChatsInput): Promise<ChatView[]>;
54
31
  /**
55
- * Deletes the chat and every message of it. Canister admin only; irreversible — the
56
- * erasure path for personal data.
32
+ * A project's chats as metadata with message counts, newest first — never content.
33
+ * Project admins and canister admins.
57
34
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
58
35
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
59
36
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
60
37
  */
61
- purgeChatAsyncUnsafe(chatId: string): Promise<boolean>;
38
+ listProjectChatsAsyncUnsafe(input: ListProjectChatsInput): Promise<ChatSummaryView[]>;
62
39
  /**
63
- * One chat with its members. Members, project admins, canister admins.
40
+ * Deletes the chat and every message of it — the erasure path for personal data.
41
+ * Canister admins and the admins of the chat's project; irreversible. The customer
42
+ * may open the room again afterwards.
64
43
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
65
44
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
66
45
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
67
46
  */
68
- getChatAsyncUnsafe(chatId: string): Promise<ChatView>;
69
- /**
70
- * The caller's chats in a project, newest first, optionally filtered by subject.
71
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
72
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
73
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
74
- */
75
- getMyChatsAsyncUnsafe(input: GetMyChatsInput): Promise<ChatView[]>;
47
+ purgeChatAsyncUnsafe(chatId: string): Promise<boolean>;
76
48
  }
77
49
  //# sourceMappingURL=chats-actor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chats-actor.d.ts","sourceRoot":"","sources":["../../src/actors/chats-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,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrI,yFAAyF;AACzF,qBAAa,UAAW,SAAQ,SAAS;gBAEzB,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;;OAOG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAc7E;;;;;;OAMG;IACU,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWjF;;;;;OAKG;IACU,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOjF;;;;;OAKG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOxF;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKpE;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE;;;;;OAKG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKlE;;;;;OAKG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAWlF"}
1
+ {"version":3,"file":"chats-actor.d.ts","sourceRoot":"","sources":["../../src/actors/chats-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGzH,gFAAgF;AAChF,qBAAa,UAAW,SAAQ,SAAS;gBAEzB,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;;OAOG;IACU,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWzE;;;;;OAKG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKlE;;;;;;OAMG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAW/E;;;;;;OAMG;IACU,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAWlG;;;;;;;OAOG;IACU,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGtE"}
@@ -1,90 +1,71 @@
1
1
  import {} from "@icp-sdk/core/agent";
2
- import { Principal } from "@icp-sdk/core/principal";
3
2
  import { ActorBase } from "../actor-base.js";
4
- import { mapChatView, toCandidMemberInput, toCandidRole, toOpt, toOptBigInt } from "../mappers.js";
5
- /** 1:1 wrapper for the canister's ChatsController — rooms, members, roles and policy. */
3
+ import { mapChatSummaryView, mapChatView, toOpt, toOptBigInt } from "../mappers.js";
4
+ /** 1:1 wrapper for the canister's ChatsController — chats opened from rooms. */
6
5
  export class ChatsActor extends ActorBase {
7
6
  constructor(canisterId, identity) {
8
7
  super(canisterId, identity);
9
8
  }
10
9
  /**
11
- * Creates a chat: the caller becomes `owner`, the project's agents join as `agent`, the
12
- * canister writes the `chatCreated` event and — when given — the first text message,
13
- * all in one call.
14
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the project, `InvalidData` for members/lengths/quotas). Examine "cause" for {errorKey, errorMessage, logs}.
10
+ * Opens the caller's chat in a room: the caller becomes the `customer`, the room's
11
+ * recipients are copied in, the canister writes the `chatCreated` event. One chat per
12
+ * (room, customer, recipients) — calling again returns the same chat unchanged.
13
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the room, `InvalidData` when the caller is a recipient of the room, the name is too long or the daily chat limit is reached). Examine "cause" for {errorKey, errorMessage, logs}.
15
14
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
16
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
15
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution (anonymous, or today's chat quota used up).
17
16
  */
18
- async createChatAsyncUnsafe(input) {
19
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.createChat({
17
+ async openChatAsyncUnsafe(input) {
18
+ const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.openChat({
20
19
  projectId: input.projectId,
21
- members: (input.members ?? []).map(toCandidMemberInput),
22
- policy: toOpt(input.policy === undefined ? undefined : { agentsReply: input.policy.agentsReply }),
23
- title: toOpt(input.title),
24
- subject: toOpt(input.subject),
25
- firstMessage: toOpt(input.firstMessage),
26
- }));
27
- return mapChatView(chat);
28
- }
29
- /**
30
- * Adds a member. Owner/admin members, project admins, canister admins — and agent
31
- * members when the project allows it (agents may only add `member`s).
32
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `AlreadyExists`, `InvalidData` for a closed chat / anonymous / limit). Examine "cause" for {errorKey, errorMessage, logs}.
33
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
34
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
35
- */
36
- async inviteMemberAsyncUnsafe(input) {
37
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.inviteMember({
38
- chatId: input.chatId,
39
- principal: Principal.fromText(input.principal),
40
- role: toCandidRole(input.role),
20
+ roomId: input.roomId,
21
+ customerName: toOpt(input.customerName),
41
22
  }));
42
23
  return mapChatView(chat);
43
24
  }
44
25
  /**
45
- * Removes somebody else; an owner can be removed only by a project admin.
46
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for self-removal / closed chat). Examine "cause" for {errorKey, errorMessage, logs}.
26
+ * One chat with its participants. Participants only — not even admins.
27
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
47
28
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
48
29
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
49
30
  */
50
- async removeMemberAsyncUnsafe(input) {
51
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.removeMember({ chatId: input.chatId, principal: Principal.fromText(input.principal) }));
31
+ async getChatAsyncUnsafe(chatId) {
32
+ const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.getChat({ chatId }));
52
33
  return mapChatView(chat);
53
34
  }
54
35
  /**
55
- * Leaves the chat. The last owner/admin of an open chat cannot leave — close it instead.
56
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for the last manager). Examine "cause" for {errorKey, errorMessage, logs}.
57
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
58
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
59
- */
60
- async leaveChatAsyncUnsafe(chatId) {
61
- return this.executeFunctionAsyncUnsafe(() => this.actor.leaveChat({ chatId }));
62
- }
63
- /**
64
- * Changes the policy agents read (e.g. `agentsReply: false` to hand the chat to a human).
65
- * Same callers as inviteMember.
66
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for a closed chat). Examine "cause" for {errorKey, errorMessage, logs}.
36
+ * The caller's chats in a project — as customer or as recipient — newest first,
37
+ * optionally one room only.
38
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized). Examine "cause" for {errorKey, errorMessage, logs}.
67
39
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
68
40
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
69
41
  */
70
- async setPolicyAsyncUnsafe(chatId, policy) {
71
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.setPolicy({ chatId, policy: { agentsReply: policy.agentsReply } }));
72
- return mapChatView(chat);
42
+ async getMyChatsAsyncUnsafe(input) {
43
+ const chats = await this.executeFunctionAsyncUnsafe(() => this.actor.getMyChats({
44
+ projectId: input.projectId,
45
+ roomId: toOpt(input.roomId),
46
+ limit: toOptBigInt(input.limit),
47
+ }));
48
+ return chats.map(mapChatView);
73
49
  }
74
50
  /**
75
- * Closes the chat for good (no more posts or membership changes). Owner/admin members,
76
- * project admins, canister admins — not agents.
77
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` when already closed). Examine "cause" for {errorKey, errorMessage, logs}.
51
+ * A project's chats as metadata with message counts, newest first — never content.
52
+ * Project admins and canister admins.
53
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
78
54
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
79
55
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
80
56
  */
81
- async closeChatAsyncUnsafe(chatId) {
82
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.closeChat({ chatId }));
83
- return mapChatView(chat);
57
+ async listProjectChatsAsyncUnsafe(input) {
58
+ const summaries = await this.executeFunctionAsyncUnsafe(() => this.actor.listProjectChats({
59
+ projectId: input.projectId,
60
+ roomId: toOpt(input.roomId),
61
+ limit: toOptBigInt(input.limit),
62
+ }));
63
+ return summaries.map(mapChatSummaryView);
84
64
  }
85
65
  /**
86
- * Deletes the chat and every message of it. Canister admin only; irreversible — the
87
- * erasure path for personal data.
66
+ * Deletes the chat and every message of it — the erasure path for personal data.
67
+ * Canister admins and the admins of the chat's project; irreversible. The customer
68
+ * may open the room again afterwards.
88
69
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
89
70
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
90
71
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -92,29 +73,4 @@ export class ChatsActor extends ActorBase {
92
73
  async purgeChatAsyncUnsafe(chatId) {
93
74
  return this.executeFunctionAsyncUnsafe(() => this.actor.purgeChat({ chatId }));
94
75
  }
95
- /**
96
- * One chat with its members. Members, project admins, canister admins.
97
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
98
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
99
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
100
- */
101
- async getChatAsyncUnsafe(chatId) {
102
- const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.getChat({ chatId }));
103
- return mapChatView(chat);
104
- }
105
- /**
106
- * The caller's chats in a project, newest first, optionally filtered by subject.
107
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
108
- * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
109
- * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
110
- */
111
- async getMyChatsAsyncUnsafe(input) {
112
- const chats = await this.executeFunctionAsyncUnsafe(() => this.actor.getMyChats({
113
- projectId: input.projectId,
114
- subject: toOpt(input.subject),
115
- includeClosed: input.includeClosed ?? false,
116
- limit: toOptBigInt(input.limit),
117
- }));
118
- return chats.map(mapChatView);
119
- }
120
76
  }
@@ -5,9 +5,9 @@ import type { GetMessagesInput, MessageView, MessagesPageView, PollNewMessagesIn
5
5
  export declare class MessagesActor extends ActorBase {
6
6
  constructor(canisterId: string, identity?: Identity);
7
7
  /**
8
- * Posts a message as the caller. `text` for any member; `toolTrace` only for `agent`
9
- * and `admin` members.
10
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for empty/long text, closed or full chat, daily limit). Examine "cause" for {errorKey, errorMessage, logs}.
8
+ * Posts a message as the caller. `text` for any participant; `toolTrace` only for the
9
+ * `agent` role.
10
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for empty/long text or the daily limit). Examine "cause" for {errorKey, errorMessage, logs}.
11
11
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
12
12
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
13
13
  */
@@ -22,15 +22,16 @@ export declare class MessagesActor extends ActorBase {
22
22
  */
23
23
  markReadAsyncUnsafe(chatId: string, seq: number): Promise<boolean>;
24
24
  /**
25
- * A chat's messages with seq > sinceSeq, oldest first (max 200 per call). Members,
26
- * project admins, canister admins.
25
+ * A chat's messages with seq > sinceSeq, oldest first (max 200 per call).
26
+ * Participants only.
27
27
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
28
28
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
29
29
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
30
30
  */
31
31
  getMessagesAsyncUnsafe(input: GetMessagesInput): Promise<MessagesPageView>;
32
32
  /**
33
- * New messages in every chat the caller belongs to, after a global sequence number.
33
+ * New messages in every chat the caller takes part in, after a global sequence number.
34
+ * Each carries its `roomId` and `customer`, so an agent host routes without a lookup.
34
35
  * Always returns `nextSinceGlobalSeq` — pass it back next time, whatever matched.
35
36
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized). Examine "cause" for {errorKey, errorMessage, logs}.
36
37
  * @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,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzI,yDAAyD;AACzD,qBAAa,aAAc,SAAQ,SAAS;gBAE5B,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAWpE,2EAA2E;IAC9D,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAQzE;;;;;OAKG;IACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/E;;;;;;OAMG;IACU,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWvF;;;;;;OAMG;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"}
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,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGzI,yDAAyD;AACzD,qBAAa,aAAc,SAAQ,SAAS;gBAE5B,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAWpE,2EAA2E;IAC9D,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAQzE;;;;;OAKG;IACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/E;;;;;;OAMG;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"}
@@ -7,9 +7,9 @@ export class MessagesActor extends ActorBase {
7
7
  super(canisterId, identity);
8
8
  }
9
9
  /**
10
- * Posts a message as the caller. `text` for any member; `toolTrace` only for `agent`
11
- * and `admin` members.
12
- * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for empty/long text, closed or full chat, daily limit). Examine "cause" for {errorKey, errorMessage, logs}.
10
+ * Posts a message as the caller. `text` for any participant; `toolTrace` only for the
11
+ * `agent` role.
12
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData` for empty/long text or the daily limit). Examine "cause" for {errorKey, errorMessage, logs}.
13
13
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
14
14
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
15
15
  */
@@ -40,8 +40,8 @@ export class MessagesActor extends ActorBase {
40
40
  return this.executeFunctionAsyncUnsafe(() => this.actor.markRead({ chatId, seq: BigInt(seq) }));
41
41
  }
42
42
  /**
43
- * A chat's messages with seq > sinceSeq, oldest first (max 200 per call). Members,
44
- * project admins, canister admins.
43
+ * A chat's messages with seq > sinceSeq, oldest first (max 200 per call).
44
+ * Participants only.
45
45
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
46
46
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
47
47
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -55,7 +55,8 @@ export class MessagesActor extends ActorBase {
55
55
  return mapMessagesPageView(page);
56
56
  }
57
57
  /**
58
- * New messages in every chat the caller belongs to, after a global sequence number.
58
+ * New messages in every chat the caller takes part in, after a global sequence number.
59
+ * Each carries its `roomId` and `customer`, so an agent host routes without a lookup.
59
60
  * Always returns `nextSinceGlobalSeq` — pass it back next time, whatever matched.
60
61
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized). Examine "cause" for {errorKey, errorMessage, logs}.
61
62
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
@@ -1,27 +1,27 @@
1
1
  import { type Identity } from "@icp-sdk/core/agent";
2
2
  import { ActorBase } from "../actor-base.js";
3
3
  import type { CreateProjectInput, ProjectView, UpdateProjectInput } from "../interfaces.js";
4
- /** 1:1 wrapper for the canister's ProjectsController — a project is a consumer's namespace
5
- * with its own admins and the agents that auto-join every chat. */
4
+ /** 1:1 wrapper for the canister's ProjectsController — a project is the space of one site
5
+ * or company; its admins define the rooms. */
6
6
  export declare class ProjectsActor extends ActorBase {
7
7
  constructor(canisterId: string, identity?: Identity);
8
8
  /**
9
9
  * Creates a project. Canister admin only.
10
- * @param input - id (max 50 chars), admins and agents (max 10 each, no anonymous), whether agents may invite, the default policy.
10
+ * @param input - id (max 50 chars, no '/' or '|') and admins (max 10, no anonymous).
11
11
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `AlreadyExists`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
12
12
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
13
13
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
14
14
  */
15
15
  createProjectAsyncUnsafe(input: CreateProjectInput): Promise<ProjectView>;
16
16
  /**
17
- * Changes only the given fields. Canister admins and the project's admins.
17
+ * Replaces the admin list when given. Canister admins and the project's admins.
18
18
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
19
19
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
20
20
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
21
21
  */
22
22
  updateProjectAsyncUnsafe(input: UpdateProjectInput): Promise<ProjectView>;
23
23
  /**
24
- * One project. Canister admins, the project's admins and its agents.
24
+ * One project. Canister admins and the project's admins.
25
25
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
26
26
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
27
27
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -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;mEACmE;AACnE,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;IAatF;;;;;OAKG;IACU,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAatF;;;;;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,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;IAUtF;;;;;OAKG;IACU,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUtF;;;;;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"}
@@ -2,15 +2,15 @@ import {} from "@icp-sdk/core/agent";
2
2
  import { Principal } from "@icp-sdk/core/principal";
3
3
  import { ActorBase } from "../actor-base.js";
4
4
  import { mapProjectView, toOpt, toOptBigInt } from "../mappers.js";
5
- /** 1:1 wrapper for the canister's ProjectsController — a project is a consumer's namespace
6
- * with its own admins and the agents that auto-join every chat. */
5
+ /** 1:1 wrapper for the canister's ProjectsController — a project is the space of one site
6
+ * or company; its admins define the rooms. */
7
7
  export class ProjectsActor extends ActorBase {
8
8
  constructor(canisterId, identity) {
9
9
  super(canisterId, identity);
10
10
  }
11
11
  /**
12
12
  * Creates a project. Canister admin only.
13
- * @param input - id (max 50 chars), admins and agents (max 10 each, no anonymous), whether agents may invite, the default policy.
13
+ * @param input - id (max 50 chars, no '/' or '|') and admins (max 10, no anonymous).
14
14
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `AlreadyExists`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
15
15
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
16
16
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -19,14 +19,11 @@ export class ProjectsActor extends ActorBase {
19
19
  const project = await this.executeFunctionAsyncUnsafe(() => this.actor.createProject({
20
20
  id: input.id,
21
21
  admins: input.admins.map((p) => Principal.fromText(p)),
22
- agents: input.agents.map((p) => Principal.fromText(p)),
23
- agentsMayInvite: input.agentsMayInvite,
24
- defaultPolicy: { agentsReply: input.defaultPolicy.agentsReply },
25
22
  }));
26
23
  return mapProjectView(project);
27
24
  }
28
25
  /**
29
- * Changes only the given fields. Canister admins and the project's admins.
26
+ * Replaces the admin list when given. Canister admins and the project's admins.
30
27
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
31
28
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
32
29
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -35,14 +32,11 @@ export class ProjectsActor extends ActorBase {
35
32
  const project = await this.executeFunctionAsyncUnsafe(() => this.actor.updateProject({
36
33
  projectId: input.projectId,
37
34
  admins: toOpt(input.admins?.map((p) => Principal.fromText(p))),
38
- agents: toOpt(input.agents?.map((p) => Principal.fromText(p))),
39
- agentsMayInvite: toOpt(input.agentsMayInvite),
40
- defaultPolicy: toOpt(input.defaultPolicy === undefined ? undefined : { agentsReply: input.defaultPolicy.agentsReply }),
41
35
  }));
42
36
  return mapProjectView(project);
43
37
  }
44
38
  /**
45
- * One project. Canister admins, the project's admins and its agents.
39
+ * One project. Canister admins and the project's admins.
46
40
  * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
47
41
  * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
48
42
  * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
@@ -0,0 +1,39 @@
1
+ import { type Identity } from "@icp-sdk/core/agent";
2
+ import { ActorBase } from "../actor-base.js";
3
+ import type { CreateRoomInput, ListRoomsInput, RoomRefInput, RoomView, UpdateRoomInput } from "../interfaces.js";
4
+ /** 1:1 wrapper for the canister's RoomsController — a room is the template a chat is
5
+ * opened from: it names who receives the customer's messages. */
6
+ export declare class RoomsActor extends ActorBase {
7
+ constructor(canisterId: string, identity?: Identity);
8
+ /**
9
+ * Creates a room. Project admins and canister admins.
10
+ * @param input - id (max 50 chars, unique in the project, no '/' or '|'), name (max 100), 1–10 recipients (no anonymous, no duplicates, display names present).
11
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the project, `AlreadyExists`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
12
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
13
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
14
+ */
15
+ createRoomAsyncUnsafe(input: CreateRoomInput): Promise<RoomView>;
16
+ /**
17
+ * Changes only the given fields; chats already opened keep their recipients.
18
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
19
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
20
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
21
+ */
22
+ updateRoomAsyncUnsafe(input: UpdateRoomInput): Promise<RoomView>;
23
+ /**
24
+ * One room with its recipients. Any signed-in caller — a site shows the names before
25
+ * the customer opens the chat.
26
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized for anonymous, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
27
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
28
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
29
+ */
30
+ getRoomAsyncUnsafe(input: RoomRefInput): Promise<RoomView>;
31
+ /**
32
+ * A project's rooms in creation order. Project admins and canister admins.
33
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
34
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
35
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
36
+ */
37
+ listRoomsAsyncUnsafe(input: ListRoomsInput): Promise<RoomView[]>;
38
+ }
39
+ //# sourceMappingURL=rooms-actor.d.ts.map
@@ -0,0 +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;AACpD,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;IAY7E;;;;;OAKG;IACU,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY7E;;;;;;OAMG;IACU,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKvE;;;;;OAKG;IACU,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAIhF"}
@@ -0,0 +1,62 @@
1
+ import {} from "@icp-sdk/core/agent";
2
+ import { ActorBase } from "../actor-base.js";
3
+ import { mapRoomView, toCandidRecipient, toOpt, toOptBigInt } from "../mappers.js";
4
+ /** 1:1 wrapper for the canister's RoomsController — a room is the template a chat is
5
+ * opened from: it names who receives the customer's messages. */
6
+ export class RoomsActor extends ActorBase {
7
+ constructor(canisterId, identity) {
8
+ super(canisterId, identity);
9
+ }
10
+ /**
11
+ * Creates a room. Project admins and canister admins.
12
+ * @param input - id (max 50 chars, unique in the project, no '/' or '|'), name (max 100), 1–10 recipients (no anonymous, no duplicates, display names present).
13
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound` for the project, `AlreadyExists`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
14
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
15
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
16
+ */
17
+ async createRoomAsyncUnsafe(input) {
18
+ const room = await this.executeFunctionAsyncUnsafe(() => this.actor.createRoom({
19
+ projectId: input.projectId,
20
+ id: input.id,
21
+ name: input.name,
22
+ recipients: input.recipients.map(toCandidRecipient),
23
+ }));
24
+ return mapRoomView(room);
25
+ }
26
+ /**
27
+ * Changes only the given fields; chats already opened keep their recipients.
28
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`, `InvalidData`). Examine "cause" for {errorKey, errorMessage, logs}.
29
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
30
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
31
+ */
32
+ async updateRoomAsyncUnsafe(input) {
33
+ const room = await this.executeFunctionAsyncUnsafe(() => this.actor.updateRoom({
34
+ projectId: input.projectId,
35
+ roomId: input.roomId,
36
+ name: toOpt(input.name),
37
+ recipients: toOpt(input.recipients?.map(toCandidRecipient)),
38
+ }));
39
+ return mapRoomView(room);
40
+ }
41
+ /**
42
+ * One room with its recipients. Any signed-in caller — a site shows the names before
43
+ * the customer opens the chat.
44
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized for anonymous, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
45
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
46
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
47
+ */
48
+ async getRoomAsyncUnsafe(input) {
49
+ const room = await this.executeFunctionAsyncUnsafe(() => this.actor.getRoom({ projectId: input.projectId, roomId: input.roomId }));
50
+ return mapRoomView(room);
51
+ }
52
+ /**
53
+ * A project's rooms in creation order. Project admins and canister admins.
54
+ * @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
55
+ * @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
56
+ * @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
57
+ */
58
+ async listRoomsAsyncUnsafe(input) {
59
+ const rooms = await this.executeFunctionAsyncUnsafe(() => this.actor.listRooms({ projectId: input.projectId, limit: toOptBigInt(input.limit) }));
60
+ return rooms.map(mapRoomView);
61
+ }
62
+ }