@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.
- package/README.md +19 -9
- package/declarations/chat-motoko-backend/chat-motoko-backend.did +138 -109
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.d.ts +112 -92
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.js +128 -109
- package/dist/actors/admin-actor.d.ts +15 -0
- package/dist/actors/admin-actor.d.ts.map +1 -1
- package/dist/actors/admin-actor.js +21 -0
- package/dist/actors/chats-actor.d.ts +22 -50
- package/dist/actors/chats-actor.d.ts.map +1 -1
- package/dist/actors/chats-actor.js +38 -82
- package/dist/actors/messages-actor.d.ts +7 -6
- package/dist/actors/messages-actor.d.ts.map +1 -1
- package/dist/actors/messages-actor.js +7 -6
- package/dist/actors/projects-actor.d.ts +5 -5
- package/dist/actors/projects-actor.d.ts.map +1 -1
- package/dist/actors/projects-actor.js +5 -11
- package/dist/actors/rooms-actor.d.ts +39 -0
- package/dist/actors/rooms-actor.d.ts.map +1 -0
- package/dist/actors/rooms-actor.js +62 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interfaces.d.ts +76 -65
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +12 -7
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +60 -44
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { ActorBase, type LogEntry } from "./actor-base.js";
|
|
2
2
|
export { AdminActor } from "./actors/admin-actor.js";
|
|
3
3
|
export { ProjectsActor } from "./actors/projects-actor.js";
|
|
4
|
+
export { RoomsActor } from "./actors/rooms-actor.js";
|
|
4
5
|
export { ChatsActor } from "./actors/chats-actor.js";
|
|
5
6
|
export { MessagesActor } from "./actors/messages-actor.js";
|
|
6
7
|
export { ChatPoller, type ChatPollerOptions } from "./chat-poller.js";
|
|
7
|
-
export type { RoleView,
|
|
8
|
-
export { mapProjectView, mapChatView,
|
|
9
|
-
export type { Chat, ChatId,
|
|
8
|
+
export type { RoleView, RecipientRoleView, ProjectView, RecipientView, RoomView, ParticipantView, ChatView, ChatSummaryView, SystemEventView, MessageKindView, MessageView, MessagesPageView, PollResultView, QuotaLimitsView, CreateProjectInput, UpdateProjectInput, CreateRoomInput, UpdateRoomInput, RoomRefInput, ListRoomsInput, OpenChatInput, GetMyChatsInput, ListProjectChatsInput, PostInput, GetMessagesInput, PollNewMessagesInput, } from "./interfaces.js";
|
|
9
|
+
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
|
10
|
+
export type { Chat, ChatId, ChatSummary, Message, MessageKind, MessagesPage, Participant, PollResult, Project, ProjectId, QuotaLimits, Recipient, RecipientRole, Role, Room, RoomId, SystemEvent, Error as CanisterErrorShape, ErrorDetails, } from "../declarations/chat-motoko-backend/chat-motoko-backend.did.js";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EACR,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,gEAAgE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ActorBase } from "./actor-base.js";
|
|
2
2
|
export { AdminActor } from "./actors/admin-actor.js";
|
|
3
3
|
export { ProjectsActor } from "./actors/projects-actor.js";
|
|
4
|
+
export { RoomsActor } from "./actors/rooms-actor.js";
|
|
4
5
|
export { ChatsActor } from "./actors/chats-actor.js";
|
|
5
6
|
export { MessagesActor } from "./actors/messages-actor.js";
|
|
6
7
|
export { ChatPoller } from "./chat-poller.js";
|
|
7
|
-
export { mapProjectView, mapChatView,
|
|
8
|
+
export { mapProjectView, mapRoomView, mapRecipientView, mapChatView, mapChatSummaryView, mapParticipantView, mapMessageView, mapMessagesPageView, mapPollResultView, mapSystemEventView, mapQuotaLimitsView, mapRoleView, mapRecipientRoleView, toCandidRecipient, toCandidRecipientRole, } from "./mappers.js";
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -3,69 +3,71 @@
|
|
|
3
3
|
* variants → string unions, sequence numbers → `number` (they stay far below 2^53),
|
|
4
4
|
* timestamps kept as `bigint` nanoseconds like every other JSM package.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
agentsReply: boolean;
|
|
11
|
-
}
|
|
6
|
+
/** A participant's role in a chat: the customer who opened it, or one of the room's recipients. */
|
|
7
|
+
export type RoleView = "customer" | "worker" | "agent";
|
|
8
|
+
/** A room recipient: a person (`worker`) or an automated responder (`agent`). */
|
|
9
|
+
export type RecipientRoleView = "worker" | "agent";
|
|
12
10
|
export interface ProjectView {
|
|
13
11
|
id: string;
|
|
14
12
|
createdBy: string;
|
|
15
13
|
createdAt: bigint;
|
|
14
|
+
/** Define the rooms, see the project's chats as metadata, may purge them. */
|
|
16
15
|
admins: string[];
|
|
17
|
-
/** Auto-joined as `agent` on every new chat of the project. */
|
|
18
|
-
agents: string[];
|
|
19
|
-
agentsMayInvite: boolean;
|
|
20
|
-
defaultPolicy: PolicyView;
|
|
21
16
|
}
|
|
22
|
-
export interface
|
|
17
|
+
export interface RecipientView {
|
|
18
|
+
principal: string;
|
|
19
|
+
role: RecipientRoleView;
|
|
20
|
+
/** What the customer sees instead of a principal. */
|
|
21
|
+
displayName: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RoomView {
|
|
24
|
+
id: string;
|
|
25
|
+
projectId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
createdBy: string;
|
|
28
|
+
createdAt: bigint;
|
|
29
|
+
recipients: RecipientView[];
|
|
30
|
+
}
|
|
31
|
+
export interface ParticipantView {
|
|
23
32
|
principal: string;
|
|
24
33
|
role: RoleView;
|
|
34
|
+
displayName: string;
|
|
25
35
|
joinedAt: bigint;
|
|
36
|
+
/** The seq of the participant's first own message; undefined until they have spoken. */
|
|
37
|
+
firstPostSeq?: number;
|
|
26
38
|
lastReadSeq: number;
|
|
27
39
|
}
|
|
28
40
|
export interface ChatView {
|
|
29
41
|
id: string;
|
|
30
42
|
projectId: string;
|
|
31
|
-
|
|
43
|
+
roomId: string;
|
|
44
|
+
customer: string;
|
|
32
45
|
createdAt: bigint;
|
|
33
|
-
|
|
34
|
-
subject?: string;
|
|
35
|
-
policy: PolicyView;
|
|
36
|
-
status: ChatStatusView;
|
|
37
|
-
members: MemberView[];
|
|
46
|
+
participants: ParticipantView[];
|
|
38
47
|
lastSeq: number;
|
|
39
48
|
lastMessageAt: bigint;
|
|
40
49
|
}
|
|
50
|
+
/** What a project admin sees of a chat: metadata, never content. */
|
|
51
|
+
export interface ChatSummaryView {
|
|
52
|
+
id: string;
|
|
53
|
+
projectId: string;
|
|
54
|
+
roomId: string;
|
|
55
|
+
customer: string;
|
|
56
|
+
createdAt: bigint;
|
|
57
|
+
participantCount: number;
|
|
58
|
+
messageCount: number;
|
|
59
|
+
lastMessageAt: bigint;
|
|
60
|
+
}
|
|
41
61
|
export type SystemEventView = {
|
|
42
62
|
type: "chatCreated";
|
|
43
|
-
} | {
|
|
44
|
-
type: "memberJoined";
|
|
45
|
-
principal: string;
|
|
46
|
-
role: RoleView;
|
|
47
|
-
} | {
|
|
48
|
-
type: "memberInvited";
|
|
49
|
-
principal: string;
|
|
50
|
-
role: RoleView;
|
|
51
|
-
by: string;
|
|
52
|
-
} | {
|
|
53
|
-
type: "memberRemoved";
|
|
54
|
-
principal: string;
|
|
55
|
-
by: string;
|
|
56
|
-
} | {
|
|
57
|
-
type: "memberLeft";
|
|
58
|
-
principal: string;
|
|
59
|
-
} | {
|
|
60
|
-
type: "policyChanged";
|
|
61
|
-
policy: PolicyView;
|
|
62
|
-
} | {
|
|
63
|
-
type: "chatClosed";
|
|
64
63
|
};
|
|
65
64
|
export type MessageKindView = "text" | "toolTrace" | "event";
|
|
66
65
|
export interface MessageView {
|
|
67
66
|
chatId: string;
|
|
68
67
|
projectId: string;
|
|
68
|
+
roomId: string;
|
|
69
|
+
/** Whom the chat belongs to — so a recipient's poll routes without a lookup. */
|
|
70
|
+
customer: string;
|
|
69
71
|
/** Dense per-chat sequence starting at 1. */
|
|
70
72
|
seq: number;
|
|
71
73
|
/** Canister-wide sequence — the poll cursor. */
|
|
@@ -87,52 +89,61 @@ export interface PollResultView {
|
|
|
87
89
|
nextSinceGlobalSeq: number;
|
|
88
90
|
headGlobalSeq: number;
|
|
89
91
|
}
|
|
92
|
+
export interface QuotaLimitsView {
|
|
93
|
+
/** Messages one principal may post per UTC day. */
|
|
94
|
+
posts: number;
|
|
95
|
+
/** Chats one principal may open per UTC day. */
|
|
96
|
+
chats: number;
|
|
97
|
+
}
|
|
90
98
|
export interface CreateProjectInput {
|
|
91
99
|
id: string;
|
|
92
100
|
admins: string[];
|
|
93
|
-
agents: string[];
|
|
94
|
-
agentsMayInvite: boolean;
|
|
95
|
-
defaultPolicy: PolicyView;
|
|
96
101
|
}
|
|
97
102
|
export interface UpdateProjectInput {
|
|
98
103
|
projectId: string;
|
|
99
104
|
admins?: string[];
|
|
100
|
-
agents?: string[];
|
|
101
|
-
agentsMayInvite?: boolean;
|
|
102
|
-
defaultPolicy?: PolicyView;
|
|
103
105
|
}
|
|
104
|
-
export interface
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
export interface CreateRoomInput {
|
|
107
|
+
projectId: string;
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
recipients: RecipientView[];
|
|
107
111
|
}
|
|
108
|
-
export interface
|
|
112
|
+
export interface UpdateRoomInput {
|
|
109
113
|
projectId: string;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
subject?: string;
|
|
115
|
-
firstMessage?: string;
|
|
116
|
-
}
|
|
117
|
-
export interface InviteMemberInput {
|
|
118
|
-
chatId: string;
|
|
119
|
-
principal: string;
|
|
120
|
-
role: RoleView;
|
|
114
|
+
roomId: string;
|
|
115
|
+
name?: string;
|
|
116
|
+
/** Replaces the whole list; chats already opened keep their recipients. */
|
|
117
|
+
recipients?: RecipientView[];
|
|
121
118
|
}
|
|
122
|
-
export interface
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
export interface RoomRefInput {
|
|
120
|
+
projectId: string;
|
|
121
|
+
roomId: string;
|
|
122
|
+
}
|
|
123
|
+
export interface ListRoomsInput {
|
|
124
|
+
projectId: string;
|
|
125
|
+
limit?: number;
|
|
126
|
+
}
|
|
127
|
+
export interface OpenChatInput {
|
|
128
|
+
projectId: string;
|
|
129
|
+
roomId: string;
|
|
130
|
+
/** How the recipients see the caller; omitted = the principal. */
|
|
131
|
+
customerName?: string;
|
|
125
132
|
}
|
|
126
133
|
export interface GetMyChatsInput {
|
|
127
134
|
projectId: string;
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
roomId?: string;
|
|
136
|
+
limit?: number;
|
|
137
|
+
}
|
|
138
|
+
export interface ListProjectChatsInput {
|
|
139
|
+
projectId: string;
|
|
140
|
+
roomId?: string;
|
|
130
141
|
limit?: number;
|
|
131
142
|
}
|
|
132
143
|
export interface PostInput {
|
|
133
144
|
chatId: string;
|
|
134
145
|
text: string;
|
|
135
|
-
/** Defaults to `text`; `toolTrace` needs the `agent`
|
|
146
|
+
/** Defaults to `text`; `toolTrace` needs the `agent` role. */
|
|
136
147
|
kind?: "text" | "toolTrace";
|
|
137
148
|
}
|
|
138
149
|
export interface GetMessagesInput {
|
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,MAAM,MAAM,QAAQ,GAAG,
|
|
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;CACpB;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,CAA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,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,YAAY,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
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type { Chat,
|
|
2
|
-
import type {
|
|
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";
|
|
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];
|
|
6
6
|
export declare function mapRoleView(role: Role): RoleView;
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
7
|
+
export declare function mapRecipientRoleView(role: RecipientRole): RecipientRoleView;
|
|
8
|
+
export declare function toCandidRecipientRole(role: RecipientRoleView): RecipientRole;
|
|
9
|
+
export declare function toCandidRecipient(input: RecipientView): Recipient;
|
|
10
|
+
export declare function mapRecipientView(recipient: Recipient): RecipientView;
|
|
10
11
|
export declare function mapProjectView(project: Project): ProjectView;
|
|
11
|
-
export declare function
|
|
12
|
+
export declare function mapRoomView(room: Room): RoomView;
|
|
13
|
+
export declare function mapParticipantView(participant: Participant): ParticipantView;
|
|
12
14
|
export declare function mapChatView(chat: Chat): ChatView;
|
|
13
|
-
export declare function
|
|
15
|
+
export declare function mapChatSummaryView(summary: ChatSummary): ChatSummaryView;
|
|
16
|
+
export declare function mapSystemEventView(_event: SystemEvent): SystemEventView;
|
|
14
17
|
export declare function mapMessageView(message: Message): MessageView;
|
|
15
18
|
export declare function mapMessagesPageView(page: MessagesPage): MessagesPageView;
|
|
16
19
|
export declare function mapPollResultView(result: PollResult): PollResultView;
|
|
20
|
+
export declare function mapQuotaLimitsView(limits: QuotaLimits): QuotaLimitsView;
|
|
21
|
+
export declare function toCandidQuotaLimits(limits: QuotaLimitsView): QuotaLimits;
|
|
17
22
|
//# sourceMappingURL=mappers.d.ts.map
|
package/dist/mappers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AACA,OA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AAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAWhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAWxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAiB5D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAExE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAMpE;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
|
@@ -11,19 +11,28 @@ export function toOptBigInt(value) {
|
|
|
11
11
|
export function mapRoleView(role) {
|
|
12
12
|
return Object.keys(role)[0];
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function mapRecipientRoleView(role) {
|
|
15
|
+
return Object.keys(role)[0];
|
|
16
|
+
}
|
|
17
|
+
export function toCandidRecipientRole(role) {
|
|
15
18
|
switch (role) {
|
|
16
|
-
case "
|
|
17
|
-
case "member": return { member: null };
|
|
19
|
+
case "worker": return { worker: null };
|
|
18
20
|
case "agent": return { agent: null };
|
|
19
|
-
case "admin": return { admin: null };
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
export function
|
|
23
|
-
return {
|
|
23
|
+
export function toCandidRecipient(input) {
|
|
24
|
+
return {
|
|
25
|
+
principal: Principal.fromText(input.principal),
|
|
26
|
+
role: toCandidRecipientRole(input.role),
|
|
27
|
+
displayName: input.displayName,
|
|
28
|
+
};
|
|
24
29
|
}
|
|
25
|
-
export function
|
|
26
|
-
return
|
|
30
|
+
export function mapRecipientView(recipient) {
|
|
31
|
+
return {
|
|
32
|
+
principal: recipient.principal.toText(),
|
|
33
|
+
role: mapRecipientRoleView(recipient.role),
|
|
34
|
+
displayName: recipient.displayName,
|
|
35
|
+
};
|
|
27
36
|
}
|
|
28
37
|
export function mapProjectView(project) {
|
|
29
38
|
return {
|
|
@@ -31,61 +40,62 @@ export function mapProjectView(project) {
|
|
|
31
40
|
createdBy: project.createdBy.toText(),
|
|
32
41
|
createdAt: project.createdAt,
|
|
33
42
|
admins: project.admins.map((p) => p.toText()),
|
|
34
|
-
agents: project.agents.map((p) => p.toText()),
|
|
35
|
-
agentsMayInvite: project.agentsMayInvite,
|
|
36
|
-
defaultPolicy: { agentsReply: project.defaultPolicy.agentsReply },
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
|
-
export function
|
|
45
|
+
export function mapRoomView(room) {
|
|
46
|
+
return {
|
|
47
|
+
id: room.id,
|
|
48
|
+
projectId: room.projectId,
|
|
49
|
+
name: room.name,
|
|
50
|
+
createdBy: room.createdBy.toText(),
|
|
51
|
+
createdAt: room.createdAt,
|
|
52
|
+
recipients: room.recipients.map(mapRecipientView),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function mapParticipantView(participant) {
|
|
56
|
+
const firstPostSeq = fromOpt(participant.firstPostSeq);
|
|
40
57
|
return {
|
|
41
|
-
principal:
|
|
42
|
-
role: mapRoleView(
|
|
43
|
-
|
|
44
|
-
|
|
58
|
+
principal: participant.principal.toText(),
|
|
59
|
+
role: mapRoleView(participant.role),
|
|
60
|
+
displayName: participant.displayName,
|
|
61
|
+
joinedAt: participant.joinedAt,
|
|
62
|
+
firstPostSeq: firstPostSeq === undefined ? undefined : Number(firstPostSeq),
|
|
63
|
+
lastReadSeq: Number(participant.lastReadSeq),
|
|
45
64
|
};
|
|
46
65
|
}
|
|
47
66
|
export function mapChatView(chat) {
|
|
48
67
|
return {
|
|
49
68
|
id: chat.id,
|
|
50
69
|
projectId: chat.projectId,
|
|
51
|
-
|
|
70
|
+
roomId: chat.roomId,
|
|
71
|
+
customer: chat.customer.toText(),
|
|
52
72
|
createdAt: chat.createdAt,
|
|
53
|
-
|
|
54
|
-
subject: fromOpt(chat.subject),
|
|
55
|
-
policy: { agentsReply: chat.policy.agentsReply },
|
|
56
|
-
status: mapChatStatusView(chat.status),
|
|
57
|
-
members: chat.members.map(mapMemberView),
|
|
73
|
+
participants: chat.participants.map(mapParticipantView),
|
|
58
74
|
lastSeq: Number(chat.lastSeq),
|
|
59
75
|
lastMessageAt: chat.lastMessageAt,
|
|
60
76
|
};
|
|
61
77
|
}
|
|
62
|
-
export function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
role: mapRoleView(event.memberInvited.role),
|
|
77
|
-
by: event.memberInvited.by.toText(),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if ("memberRemoved" in event) {
|
|
81
|
-
return { type: "memberRemoved", principal: event.memberRemoved.principal.toText(), by: event.memberRemoved.by.toText() };
|
|
82
|
-
}
|
|
83
|
-
return { type: "memberLeft", principal: event.memberLeft.principal.toText() };
|
|
78
|
+
export function mapChatSummaryView(summary) {
|
|
79
|
+
return {
|
|
80
|
+
id: summary.id,
|
|
81
|
+
projectId: summary.projectId,
|
|
82
|
+
roomId: summary.roomId,
|
|
83
|
+
customer: summary.customer.toText(),
|
|
84
|
+
createdAt: summary.createdAt,
|
|
85
|
+
participantCount: Number(summary.participantCount),
|
|
86
|
+
messageCount: Number(summary.messageCount),
|
|
87
|
+
lastMessageAt: summary.lastMessageAt,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function mapSystemEventView(_event) {
|
|
91
|
+
return { type: "chatCreated" };
|
|
84
92
|
}
|
|
85
93
|
export function mapMessageView(message) {
|
|
86
94
|
const base = {
|
|
87
95
|
chatId: message.chatId,
|
|
88
96
|
projectId: message.projectId,
|
|
97
|
+
roomId: message.roomId,
|
|
98
|
+
customer: message.customer.toText(),
|
|
89
99
|
seq: Number(message.seq),
|
|
90
100
|
globalSeq: Number(message.globalSeq),
|
|
91
101
|
author: message.author.toText(),
|
|
@@ -107,3 +117,9 @@ export function mapPollResultView(result) {
|
|
|
107
117
|
headGlobalSeq: Number(result.headGlobalSeq),
|
|
108
118
|
};
|
|
109
119
|
}
|
|
120
|
+
export function mapQuotaLimitsView(limits) {
|
|
121
|
+
return { posts: Number(limits.posts), chats: Number(limits.chats) };
|
|
122
|
+
}
|
|
123
|
+
export function toCandidQuotaLimits(limits) {
|
|
124
|
+
return { posts: BigInt(limits.posts), chats: BigInt(limits.chats) };
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/chat-motoko-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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": "",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"sync-declarations": "bash scripts/sync-declarations.sh",
|
|
28
28
|
"test-suite": "bash scripts/run-tests.sh tests/test-suite.ts",
|
|
29
29
|
"test-access-restrictions": "bash scripts/run-tests.sh tests/test-access-restrictions.ts",
|
|
30
|
-
"
|
|
30
|
+
"redeploy": "bash scripts/redeploy.sh",
|
|
31
|
+
"user1": "npx tsx sandbox/main.ts USER1",
|
|
32
|
+
"user2": "npx tsx sandbox/main.ts USER2",
|
|
31
33
|
"stamp-canister": "bash scripts/stamp-canister-commit.sh"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
@@ -45,17 +47,17 @@
|
|
|
45
47
|
"tsx": "^4.18.0",
|
|
46
48
|
"typescript": "^5.9.3"
|
|
47
49
|
},
|
|
48
|
-
"homepage": "https://github.com/JSM-
|
|
50
|
+
"homepage": "https://github.com/JSM-Chat-Platform/chat-motoko-package#readme",
|
|
49
51
|
"bugs": {
|
|
50
|
-
"url": "https://github.com/JSM-
|
|
52
|
+
"url": "https://github.com/JSM-Chat-Platform/chat-motoko-package/issues"
|
|
51
53
|
},
|
|
52
54
|
"repository": {
|
|
53
55
|
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/JSM-
|
|
56
|
+
"url": "git+https://github.com/JSM-Chat-Platform/chat-motoko-package.git"
|
|
55
57
|
},
|
|
56
58
|
"chatMotoko": {
|
|
57
59
|
"repo": "chat-motoko",
|
|
58
|
-
"repoUrl": "https://github.com/JSM-
|
|
59
|
-
"commit": "
|
|
60
|
+
"repoUrl": "https://github.com/JSM-Chat-Platform/chat-motoko",
|
|
61
|
+
"commit": "e62bf2c80bf72ee8133b6e8259b14768f27efeb0"
|
|
60
62
|
}
|
|
61
63
|
}
|