@jsm-mit/chat-motoko-package 0.4.0 → 0.5.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 +7 -5
- package/declarations/chat-motoko-backend/chat-motoko-backend.did +4 -6
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.d.ts +4 -6
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.js +4 -6
- package/dist/actors/chats-actor.d.ts +5 -4
- package/dist/actors/chats-actor.d.ts.map +1 -1
- package/dist/actors/chats-actor.js +5 -7
- package/dist/actors/rooms-actor.d.ts +3 -2
- package/dist/actors/rooms-actor.d.ts.map +1 -1
- package/dist/actors/rooms-actor.js +7 -3
- package/dist/interfaces.d.ts +9 -9
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +1 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,14 +10,16 @@ import { RoomsActor, ChatsActor, MessagesActor, ChatPoller } from "@jsm-mit/chat
|
|
|
10
10
|
// A canister admin creates the project with its accounts canister — the one asked
|
|
11
11
|
// `isUser(principal)` before a non-admin opens a chat (Sultana: sultana-core-motoko).
|
|
12
12
|
// A project admin defines a room: who receives the customer's messages.
|
|
13
|
+
// One room per thing the app wants a conversation about (Sultana: per salon), closed to
|
|
14
|
+
// the people who may open it — an empty allowedCustomers means everybody with an account.
|
|
13
15
|
await new RoomsActor(canisterId, adminIdentity).createRoomAsyncUnsafe({
|
|
14
|
-
projectId: "sultana-stage", id:
|
|
16
|
+
projectId: "sultana-stage", id: `salon-${salonId}`, name: "Asystent salonu",
|
|
15
17
|
recipients: [{ principal: villagePrincipal, role: "agent", displayName: "Asystentka Ola" }],
|
|
18
|
+
allowedCustomers: [ownerPrincipal],
|
|
16
19
|
});
|
|
17
20
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
const chat = await new ChatsActor(canisterId, identity).openChatAsyncUnsafe({ projectId: "sultana-stage", roomId: "assistant", desk: salonId, customerName: "Michał" });
|
|
21
|
+
// The customer opens the room; the same call returns the same chat next time.
|
|
22
|
+
const chat = await new ChatsActor(canisterId, identity).openChatAsyncUnsafe({ projectId: "sultana-stage", roomId: `salon-${salonId}`, customerName: "Michał" });
|
|
21
23
|
|
|
22
24
|
const messages = new MessagesActor(canisterId, identity);
|
|
23
25
|
await messages.postAsyncUnsafe({ chatId: chat.id, text: "dodaj usługę strzyżenie" });
|
|
@@ -26,7 +28,7 @@ const page = await messages.getMessagesAsyncUnsafe({ chatId: chat.id, sinceSeq:
|
|
|
26
28
|
// An agent host: every new message in every chat this identity is a recipient of, with
|
|
27
29
|
// the room and the customer on each message — route by (projectId, roomId).
|
|
28
30
|
const poller = new ChatPoller(messages, 1000, { onError: console.error });
|
|
29
|
-
poller.messages$.subscribe((m) => console.log(m.roomId, m.
|
|
31
|
+
poller.messages$.subscribe((m) => console.log(m.roomId, m.customer, m.kind, m.text));
|
|
30
32
|
poller.run();
|
|
31
33
|
```
|
|
32
34
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type UpdateRoomArgs =
|
|
2
2
|
record {
|
|
3
|
+
allowedCustomers: opt vec principal;
|
|
3
4
|
name: opt text;
|
|
4
5
|
projectId: ProjectId;
|
|
5
6
|
recipients: opt vec Recipient;
|
|
@@ -17,6 +18,7 @@ type SetLoggingEnabledArgs = record {enabled: bool;};
|
|
|
17
18
|
type RoomId = text;
|
|
18
19
|
type Room =
|
|
19
20
|
record {
|
|
21
|
+
allowedCustomers: vec principal;
|
|
20
22
|
createdAt: int;
|
|
21
23
|
createdBy: principal;
|
|
22
24
|
id: RoomId;
|
|
@@ -161,7 +163,6 @@ type Participant =
|
|
|
161
163
|
type OpenChatArgs =
|
|
162
164
|
record {
|
|
163
165
|
customerName: opt text;
|
|
164
|
-
desk: opt text;
|
|
165
166
|
projectId: ProjectId;
|
|
166
167
|
roomId: RoomId;
|
|
167
168
|
};
|
|
@@ -182,7 +183,6 @@ type Message =
|
|
|
182
183
|
chatId: ChatId;
|
|
183
184
|
createdAt: int;
|
|
184
185
|
customer: principal;
|
|
185
|
-
desk: opt text;
|
|
186
186
|
globalSeq: nat;
|
|
187
187
|
kind: MessageKind;
|
|
188
188
|
projectId: ProjectId;
|
|
@@ -198,12 +198,12 @@ type MarkReadArgs =
|
|
|
198
198
|
type ListRoomsArgs =
|
|
199
199
|
record {
|
|
200
200
|
limit: opt nat;
|
|
201
|
+
offset: opt nat;
|
|
201
202
|
projectId: ProjectId;
|
|
202
203
|
};
|
|
203
204
|
type ListProjectsArgs = record {limit: opt nat;};
|
|
204
205
|
type ListProjectChatsArgs =
|
|
205
206
|
record {
|
|
206
|
-
desk: opt text;
|
|
207
207
|
limit: opt nat;
|
|
208
208
|
projectId: ProjectId;
|
|
209
209
|
roomId: opt RoomId;
|
|
@@ -216,7 +216,6 @@ type GetRoomArgs =
|
|
|
216
216
|
type GetProjectArgs = record {projectId: ProjectId;};
|
|
217
217
|
type GetMyChatsArgs =
|
|
218
218
|
record {
|
|
219
|
-
desk: opt text;
|
|
220
219
|
limit: opt nat;
|
|
221
220
|
projectId: ProjectId;
|
|
222
221
|
roomId: opt RoomId;
|
|
@@ -245,6 +244,7 @@ type Error =
|
|
|
245
244
|
};
|
|
246
245
|
type CreateRoomArgs =
|
|
247
246
|
record {
|
|
247
|
+
allowedCustomers: vec principal;
|
|
248
248
|
id: RoomId;
|
|
249
249
|
name: text;
|
|
250
250
|
projectId: ProjectId;
|
|
@@ -260,7 +260,6 @@ type ChatSummary =
|
|
|
260
260
|
record {
|
|
261
261
|
createdAt: int;
|
|
262
262
|
customer: principal;
|
|
263
|
-
desk: opt text;
|
|
264
263
|
id: ChatId;
|
|
265
264
|
lastMessageAt: int;
|
|
266
265
|
messageCount: nat;
|
|
@@ -273,7 +272,6 @@ type Chat =
|
|
|
273
272
|
record {
|
|
274
273
|
createdAt: int;
|
|
275
274
|
customer: principal;
|
|
276
|
-
desk: opt text;
|
|
277
275
|
id: ChatId;
|
|
278
276
|
lastMessageAt: int;
|
|
279
277
|
lastSeq: nat;
|
|
@@ -8,7 +8,6 @@ export interface Chat {
|
|
|
8
8
|
'participants' : Array<Participant>,
|
|
9
9
|
'lastMessageAt' : bigint,
|
|
10
10
|
'customer' : Principal,
|
|
11
|
-
'desk' : [] | [string],
|
|
12
11
|
'createdAt' : bigint,
|
|
13
12
|
'projectId' : ProjectId,
|
|
14
13
|
'roomId' : RoomId,
|
|
@@ -19,7 +18,6 @@ export interface ChatSummary {
|
|
|
19
18
|
'id' : ChatId,
|
|
20
19
|
'lastMessageAt' : bigint,
|
|
21
20
|
'customer' : Principal,
|
|
22
|
-
'desk' : [] | [string],
|
|
23
21
|
'createdAt' : bigint,
|
|
24
22
|
'projectId' : ProjectId,
|
|
25
23
|
'messageCount' : bigint,
|
|
@@ -36,6 +34,7 @@ export interface CreateRoomArgs {
|
|
|
36
34
|
'name' : string,
|
|
37
35
|
'recipients' : Array<Recipient>,
|
|
38
36
|
'projectId' : ProjectId,
|
|
37
|
+
'allowedCustomers' : Array<Principal>,
|
|
39
38
|
}
|
|
40
39
|
export interface Error { 'details' : ErrorDetails, 'logsJson' : string }
|
|
41
40
|
export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
|
|
@@ -52,7 +51,6 @@ export interface GetMessagesArgs {
|
|
|
52
51
|
'sinceSeq' : bigint,
|
|
53
52
|
}
|
|
54
53
|
export interface GetMyChatsArgs {
|
|
55
|
-
'desk' : [] | [string],
|
|
56
54
|
'limit' : [] | [bigint],
|
|
57
55
|
'projectId' : ProjectId,
|
|
58
56
|
'roomId' : [] | [RoomId],
|
|
@@ -60,13 +58,13 @@ export interface GetMyChatsArgs {
|
|
|
60
58
|
export interface GetProjectArgs { 'projectId' : ProjectId }
|
|
61
59
|
export interface GetRoomArgs { 'projectId' : ProjectId, 'roomId' : RoomId }
|
|
62
60
|
export interface ListProjectChatsArgs {
|
|
63
|
-
'desk' : [] | [string],
|
|
64
61
|
'limit' : [] | [bigint],
|
|
65
62
|
'projectId' : ProjectId,
|
|
66
63
|
'roomId' : [] | [RoomId],
|
|
67
64
|
}
|
|
68
65
|
export interface ListProjectsArgs { 'limit' : [] | [bigint] }
|
|
69
66
|
export interface ListRoomsArgs {
|
|
67
|
+
'offset' : [] | [bigint],
|
|
70
68
|
'limit' : [] | [bigint],
|
|
71
69
|
'projectId' : ProjectId,
|
|
72
70
|
}
|
|
@@ -74,7 +72,6 @@ export interface MarkReadArgs { 'seq' : bigint, 'chatId' : ChatId }
|
|
|
74
72
|
export interface Message {
|
|
75
73
|
'seq' : bigint,
|
|
76
74
|
'customer' : Principal,
|
|
77
|
-
'desk' : [] | [string],
|
|
78
75
|
'kind' : MessageKind,
|
|
79
76
|
'createdAt' : bigint,
|
|
80
77
|
'text' : string,
|
|
@@ -93,7 +90,6 @@ export interface MessagesPage {
|
|
|
93
90
|
}
|
|
94
91
|
export interface OpenChatArgs {
|
|
95
92
|
'customerName' : [] | [string],
|
|
96
|
-
'desk' : [] | [string],
|
|
97
93
|
'projectId' : ProjectId,
|
|
98
94
|
'roomId' : RoomId,
|
|
99
95
|
}
|
|
@@ -177,6 +173,7 @@ export interface Room {
|
|
|
177
173
|
'createdBy' : Principal,
|
|
178
174
|
'recipients' : Array<Recipient>,
|
|
179
175
|
'projectId' : ProjectId,
|
|
176
|
+
'allowedCustomers' : Array<Principal>,
|
|
180
177
|
}
|
|
181
178
|
export type RoomId = string;
|
|
182
179
|
export interface SetLoggingEnabledArgs { 'enabled' : boolean }
|
|
@@ -192,6 +189,7 @@ export interface UpdateRoomArgs {
|
|
|
192
189
|
'recipients' : [] | [Array<Recipient>],
|
|
193
190
|
'projectId' : ProjectId,
|
|
194
191
|
'roomId' : RoomId,
|
|
192
|
+
'allowedCustomers' : [] | [Array<Principal>],
|
|
195
193
|
}
|
|
196
194
|
export interface _SERVICE {
|
|
197
195
|
'addAdmin' : ActorMethod<[AddAdminArgs], Result_3>,
|
|
@@ -40,6 +40,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
40
40
|
'name' : IDL.Text,
|
|
41
41
|
'recipients' : IDL.Vec(Recipient),
|
|
42
42
|
'projectId' : ProjectId,
|
|
43
|
+
'allowedCustomers' : IDL.Vec(IDL.Principal),
|
|
43
44
|
});
|
|
44
45
|
const Room = IDL.Record({
|
|
45
46
|
'id' : RoomId,
|
|
@@ -48,6 +49,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
48
49
|
'createdBy' : IDL.Principal,
|
|
49
50
|
'recipients' : IDL.Vec(Recipient),
|
|
50
51
|
'projectId' : ProjectId,
|
|
52
|
+
'allowedCustomers' : IDL.Vec(IDL.Principal),
|
|
51
53
|
});
|
|
52
54
|
const Result = IDL.Variant({ 'ok' : Room, 'err' : Error });
|
|
53
55
|
const Result_13 = IDL.Variant({
|
|
@@ -74,7 +76,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
74
76
|
'participants' : IDL.Vec(Participant),
|
|
75
77
|
'lastMessageAt' : IDL.Int,
|
|
76
78
|
'customer' : IDL.Principal,
|
|
77
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
78
79
|
'createdAt' : IDL.Int,
|
|
79
80
|
'projectId' : ProjectId,
|
|
80
81
|
'roomId' : RoomId,
|
|
@@ -95,7 +96,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
95
96
|
const Message = IDL.Record({
|
|
96
97
|
'seq' : IDL.Nat,
|
|
97
98
|
'customer' : IDL.Principal,
|
|
98
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
99
99
|
'kind' : MessageKind,
|
|
100
100
|
'createdAt' : IDL.Int,
|
|
101
101
|
'text' : IDL.Text,
|
|
@@ -111,7 +111,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
111
111
|
});
|
|
112
112
|
const Result_12 = IDL.Variant({ 'ok' : MessagesPage, 'err' : Error });
|
|
113
113
|
const GetMyChatsArgs = IDL.Record({
|
|
114
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
115
114
|
'limit' : IDL.Opt(IDL.Nat),
|
|
116
115
|
'projectId' : ProjectId,
|
|
117
116
|
'roomId' : IDL.Opt(RoomId),
|
|
@@ -125,7 +124,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
125
124
|
'roomId' : RoomId,
|
|
126
125
|
});
|
|
127
126
|
const ListProjectChatsArgs = IDL.Record({
|
|
128
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
129
127
|
'limit' : IDL.Opt(IDL.Nat),
|
|
130
128
|
'projectId' : ProjectId,
|
|
131
129
|
'roomId' : IDL.Opt(RoomId),
|
|
@@ -134,7 +132,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
134
132
|
'id' : ChatId,
|
|
135
133
|
'lastMessageAt' : IDL.Int,
|
|
136
134
|
'customer' : IDL.Principal,
|
|
137
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
138
135
|
'createdAt' : IDL.Int,
|
|
139
136
|
'projectId' : ProjectId,
|
|
140
137
|
'messageCount' : IDL.Nat,
|
|
@@ -145,6 +142,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
145
142
|
const ListProjectsArgs = IDL.Record({ 'limit' : IDL.Opt(IDL.Nat) });
|
|
146
143
|
const Result_9 = IDL.Variant({ 'ok' : IDL.Vec(Project), 'err' : Error });
|
|
147
144
|
const ListRoomsArgs = IDL.Record({
|
|
145
|
+
'offset' : IDL.Opt(IDL.Nat),
|
|
148
146
|
'limit' : IDL.Opt(IDL.Nat),
|
|
149
147
|
'projectId' : ProjectId,
|
|
150
148
|
});
|
|
@@ -152,7 +150,6 @@ export const idlFactory = ({ IDL }) => {
|
|
|
152
150
|
const MarkReadArgs = IDL.Record({ 'seq' : IDL.Nat, 'chatId' : ChatId });
|
|
153
151
|
const OpenChatArgs = IDL.Record({
|
|
154
152
|
'customerName' : IDL.Opt(IDL.Text),
|
|
155
|
-
'desk' : IDL.Opt(IDL.Text),
|
|
156
153
|
'projectId' : ProjectId,
|
|
157
154
|
'roomId' : RoomId,
|
|
158
155
|
});
|
|
@@ -188,6 +185,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
188
185
|
'recipients' : IDL.Opt(IDL.Vec(Recipient)),
|
|
189
186
|
'projectId' : ProjectId,
|
|
190
187
|
'roomId' : RoomId,
|
|
188
|
+
'allowedCustomers' : IDL.Opt(IDL.Vec(IDL.Principal)),
|
|
191
189
|
});
|
|
192
190
|
return IDL.Service({
|
|
193
191
|
'addAdmin' : IDL.Func([AddAdminArgs], [Result_3], []),
|
|
@@ -7,10 +7,11 @@ export declare class ChatsActor extends ActorBase {
|
|
|
7
7
|
/**
|
|
8
8
|
* Opens the caller's chat in a room: the caller becomes the `customer`, the room's
|
|
9
9
|
* recipients are copied in, the canister writes the `chatCreated` event. One chat per
|
|
10
|
-
* (room, customer, recipients
|
|
11
|
-
* chat
|
|
12
|
-
* (`isUser`); admins of the
|
|
13
|
-
*
|
|
10
|
+
* (room, customer, recipients) — calling again returns the same chat unchanged. A NEW
|
|
11
|
+
* chat needs the room to allow the caller (its allowed-customer list, when it has one)
|
|
12
|
+
* and the project's accounts canister to confirm the caller (`isUser`); admins of the
|
|
13
|
+
* canister and of the project skip the accounts call but not the allowed list.
|
|
14
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` when the room's allowed-customer list does not name the caller or the accounts canister does not know them, `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, `InterCanisterConnectionError` when the accounts canister cannot be asked). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
14
15
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
15
16
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution (anonymous, or today's chat quota used up).
|
|
16
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chats-actor.d.ts","sourceRoot":"","sources":["../../src/actors/chats-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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{
|
|
|
9
9
|
/**
|
|
10
10
|
* Opens the caller's chat in a room: the caller becomes the `customer`, the room's
|
|
11
11
|
* recipients are copied in, the canister writes the `chatCreated` event. One chat per
|
|
12
|
-
* (room, customer, recipients
|
|
13
|
-
* chat
|
|
14
|
-
* (`isUser`); admins of the
|
|
15
|
-
*
|
|
12
|
+
* (room, customer, recipients) — calling again returns the same chat unchanged. A NEW
|
|
13
|
+
* chat needs the room to allow the caller (its allowed-customer list, when it has one)
|
|
14
|
+
* and the project's accounts canister to confirm the caller (`isUser`); admins of the
|
|
15
|
+
* canister and of the project skip the accounts call but not the allowed list.
|
|
16
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` when the room's allowed-customer list does not name the caller or the accounts canister does not know them, `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, `InterCanisterConnectionError` when the accounts canister cannot be asked). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
16
17
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
17
18
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution (anonymous, or today's chat quota used up).
|
|
18
19
|
*/
|
|
@@ -20,7 +21,6 @@ export class ChatsActor extends ActorBase {
|
|
|
20
21
|
const chat = await this.executeFunctionAsyncUnsafe(() => this.actor.openChat({
|
|
21
22
|
projectId: input.projectId,
|
|
22
23
|
roomId: input.roomId,
|
|
23
|
-
desk: toOpt(input.desk),
|
|
24
24
|
customerName: toOpt(input.customerName),
|
|
25
25
|
}));
|
|
26
26
|
return mapChatView(chat);
|
|
@@ -46,7 +46,6 @@ export class ChatsActor extends ActorBase {
|
|
|
46
46
|
const chats = await this.executeFunctionAsyncUnsafe(() => this.actor.getMyChats({
|
|
47
47
|
projectId: input.projectId,
|
|
48
48
|
roomId: toOpt(input.roomId),
|
|
49
|
-
desk: toOpt(input.desk),
|
|
50
49
|
limit: toOptBigInt(input.limit),
|
|
51
50
|
}));
|
|
52
51
|
return chats.map(mapChatView);
|
|
@@ -62,7 +61,6 @@ export class ChatsActor extends ActorBase {
|
|
|
62
61
|
const summaries = await this.executeFunctionAsyncUnsafe(() => this.actor.listProjectChats({
|
|
63
62
|
projectId: input.projectId,
|
|
64
63
|
roomId: toOpt(input.roomId),
|
|
65
|
-
desk: toOpt(input.desk),
|
|
66
64
|
limit: toOptBigInt(input.limit),
|
|
67
65
|
}));
|
|
68
66
|
return summaries.map(mapChatSummaryView);
|
|
@@ -7,7 +7,7 @@ export declare class RoomsActor extends ActorBase {
|
|
|
7
7
|
constructor(canisterId: string, identity?: Identity);
|
|
8
8
|
/**
|
|
9
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).
|
|
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), and optionally the allowed customers (max 50; empty = every account of the project may open a chat here).
|
|
11
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
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.
|
|
@@ -29,7 +29,8 @@ export declare class RoomsActor extends ActorBase {
|
|
|
29
29
|
*/
|
|
30
30
|
getRoomAsyncUnsafe(input: RoomRefInput): Promise<RoomView>;
|
|
31
31
|
/**
|
|
32
|
-
* A project's rooms in creation order
|
|
32
|
+
* A project's rooms in creation order, one page at a time (max 100). Project admins
|
|
33
|
+
* and canister admins.
|
|
33
34
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
34
35
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
35
36
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
@@ -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;
|
|
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,4 +1,5 @@
|
|
|
1
1
|
import {} from "@icp-sdk/core/agent";
|
|
2
|
+
import { Principal } from "@icp-sdk/core/principal";
|
|
2
3
|
import { ActorBase } from "../actor-base.js";
|
|
3
4
|
import { mapRoomView, toCandidRecipient, toOpt, toOptBigInt } from "../mappers.js";
|
|
4
5
|
/** 1:1 wrapper for the canister's RoomsController — a room is the template a chat is
|
|
@@ -9,7 +10,7 @@ export class RoomsActor extends ActorBase {
|
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* 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
|
+
* @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), and optionally the allowed customers (max 50; empty = every account of the project may open a chat here).
|
|
13
14
|
* @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
15
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
15
16
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
@@ -20,6 +21,7 @@ export class RoomsActor extends ActorBase {
|
|
|
20
21
|
id: input.id,
|
|
21
22
|
name: input.name,
|
|
22
23
|
recipients: input.recipients.map(toCandidRecipient),
|
|
24
|
+
allowedCustomers: (input.allowedCustomers ?? []).map((principal) => Principal.fromText(principal)),
|
|
23
25
|
}));
|
|
24
26
|
return mapRoomView(room);
|
|
25
27
|
}
|
|
@@ -35,6 +37,7 @@ export class RoomsActor extends ActorBase {
|
|
|
35
37
|
roomId: input.roomId,
|
|
36
38
|
name: toOpt(input.name),
|
|
37
39
|
recipients: toOpt(input.recipients?.map(toCandidRecipient)),
|
|
40
|
+
allowedCustomers: toOpt(input.allowedCustomers?.map((principal) => Principal.fromText(principal))),
|
|
38
41
|
}));
|
|
39
42
|
return mapRoomView(room);
|
|
40
43
|
}
|
|
@@ -50,13 +53,14 @@ export class RoomsActor extends ActorBase {
|
|
|
50
53
|
return mapRoomView(room);
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
|
-
* A project's rooms in creation order
|
|
56
|
+
* A project's rooms in creation order, one page at a time (max 100). Project admins
|
|
57
|
+
* and canister admins.
|
|
54
58
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
55
59
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
56
60
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
57
61
|
*/
|
|
58
62
|
async listRoomsAsyncUnsafe(input) {
|
|
59
|
-
const rooms = await this.executeFunctionAsyncUnsafe(() => this.actor.listRooms({ projectId: input.projectId, limit: toOptBigInt(input.limit) }));
|
|
63
|
+
const rooms = await this.executeFunctionAsyncUnsafe(() => this.actor.listRooms({ projectId: input.projectId, offset: toOptBigInt(input.offset), limit: toOptBigInt(input.limit) }));
|
|
60
64
|
return rooms.map(mapRoomView);
|
|
61
65
|
}
|
|
62
66
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface RoomView {
|
|
|
29
29
|
createdBy: string;
|
|
30
30
|
createdAt: bigint;
|
|
31
31
|
recipients: RecipientView[];
|
|
32
|
+
/** Who may open a chat here. Empty = everybody with an account in the project. */
|
|
33
|
+
allowedCustomers: string[];
|
|
32
34
|
}
|
|
33
35
|
export interface ParticipantView {
|
|
34
36
|
principal: string;
|
|
@@ -44,8 +46,6 @@ export interface ChatView {
|
|
|
44
46
|
projectId: string;
|
|
45
47
|
roomId: string;
|
|
46
48
|
customer: string;
|
|
47
|
-
/** The desk of the room the customer walked up to — the consumer's id of what the chat is about. */
|
|
48
|
-
desk?: string;
|
|
49
49
|
createdAt: bigint;
|
|
50
50
|
participants: ParticipantView[];
|
|
51
51
|
lastSeq: number;
|
|
@@ -57,7 +57,6 @@ export interface ChatSummaryView {
|
|
|
57
57
|
projectId: string;
|
|
58
58
|
roomId: string;
|
|
59
59
|
customer: string;
|
|
60
|
-
desk?: string;
|
|
61
60
|
createdAt: bigint;
|
|
62
61
|
participantCount: number;
|
|
63
62
|
messageCount: number;
|
|
@@ -73,8 +72,6 @@ export interface MessageView {
|
|
|
73
72
|
roomId: string;
|
|
74
73
|
/** Whom the chat belongs to — so a recipient's poll routes without a lookup. */
|
|
75
74
|
customer: string;
|
|
76
|
-
/** The chat's desk, when it has one (Sultana: the salon). */
|
|
77
|
-
desk?: string;
|
|
78
75
|
/** Dense per-chat sequence starting at 1. */
|
|
79
76
|
seq: number;
|
|
80
77
|
/** Canister-wide sequence — the poll cursor. */
|
|
@@ -118,6 +115,8 @@ export interface CreateRoomInput {
|
|
|
118
115
|
id: string;
|
|
119
116
|
name: string;
|
|
120
117
|
recipients: RecipientView[];
|
|
118
|
+
/** Who may open a chat here; omitted or empty = everybody with an account (max 50). */
|
|
119
|
+
allowedCustomers?: string[];
|
|
121
120
|
}
|
|
122
121
|
export interface UpdateRoomInput {
|
|
123
122
|
projectId: string;
|
|
@@ -125,6 +124,8 @@ export interface UpdateRoomInput {
|
|
|
125
124
|
name?: string;
|
|
126
125
|
/** Replaces the whole list; chats already opened keep their recipients. */
|
|
127
126
|
recipients?: RecipientView[];
|
|
127
|
+
/** Replaces the whole list; chats already opened stay open. Empty = open to everybody. */
|
|
128
|
+
allowedCustomers?: string[];
|
|
128
129
|
}
|
|
129
130
|
export interface RoomRefInput {
|
|
130
131
|
projectId: string;
|
|
@@ -132,26 +133,25 @@ export interface RoomRefInput {
|
|
|
132
133
|
}
|
|
133
134
|
export interface ListRoomsInput {
|
|
134
135
|
projectId: string;
|
|
136
|
+
/** Skip this many rooms of the project's creation order; defaults to 0. */
|
|
137
|
+
offset?: number;
|
|
138
|
+
/** Max 100 per page. */
|
|
135
139
|
limit?: number;
|
|
136
140
|
}
|
|
137
141
|
export interface OpenChatInput {
|
|
138
142
|
projectId: string;
|
|
139
143
|
roomId: string;
|
|
140
|
-
/** Which desk of the room (max 200 chars) — another desk is another chat. */
|
|
141
|
-
desk?: string;
|
|
142
144
|
/** How the recipients see the caller; omitted = the principal. */
|
|
143
145
|
customerName?: string;
|
|
144
146
|
}
|
|
145
147
|
export interface GetMyChatsInput {
|
|
146
148
|
projectId: string;
|
|
147
149
|
roomId?: string;
|
|
148
|
-
desk?: string;
|
|
149
150
|
limit?: number;
|
|
150
151
|
}
|
|
151
152
|
export interface ListProjectChatsInput {
|
|
152
153
|
projectId: string;
|
|
153
154
|
roomId?: string;
|
|
154
|
-
desk?: string;
|
|
155
155
|
limit?: number;
|
|
156
156
|
}
|
|
157
157
|
export interface PostInput {
|
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;
|
|
1
|
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,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,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.map
CHANGED
|
@@ -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,wB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AgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAExE"}
|
package/dist/mappers.js
CHANGED
|
@@ -51,6 +51,7 @@ export function mapRoomView(room) {
|
|
|
51
51
|
createdBy: room.createdBy.toText(),
|
|
52
52
|
createdAt: room.createdAt,
|
|
53
53
|
recipients: room.recipients.map(mapRecipientView),
|
|
54
|
+
allowedCustomers: room.allowedCustomers.map((principal) => principal.toText()),
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
export function mapParticipantView(participant) {
|
|
@@ -70,7 +71,6 @@ export function mapChatView(chat) {
|
|
|
70
71
|
projectId: chat.projectId,
|
|
71
72
|
roomId: chat.roomId,
|
|
72
73
|
customer: chat.customer.toText(),
|
|
73
|
-
desk: fromOpt(chat.desk),
|
|
74
74
|
createdAt: chat.createdAt,
|
|
75
75
|
participants: chat.participants.map(mapParticipantView),
|
|
76
76
|
lastSeq: Number(chat.lastSeq),
|
|
@@ -83,7 +83,6 @@ export function mapChatSummaryView(summary) {
|
|
|
83
83
|
projectId: summary.projectId,
|
|
84
84
|
roomId: summary.roomId,
|
|
85
85
|
customer: summary.customer.toText(),
|
|
86
|
-
desk: fromOpt(summary.desk),
|
|
87
86
|
createdAt: summary.createdAt,
|
|
88
87
|
participantCount: Number(summary.participantCount),
|
|
89
88
|
messageCount: Number(summary.messageCount),
|
|
@@ -99,7 +98,6 @@ export function mapMessageView(message) {
|
|
|
99
98
|
projectId: message.projectId,
|
|
100
99
|
roomId: message.roomId,
|
|
101
100
|
customer: message.customer.toText(),
|
|
102
|
-
desk: fromOpt(message.desk),
|
|
103
101
|
seq: Number(message.seq),
|
|
104
102
|
globalSeq: Number(message.globalSeq),
|
|
105
103
|
author: message.author.toText(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/chat-motoko-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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": "1a505b79dfe4e90997143abe4d17607e9a5083f1"
|
|
62
62
|
}
|
|
63
63
|
}
|