@jsm-mit/chat-motoko-package 0.1.0 → 0.3.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 +21 -9
- package/declarations/chat-motoko-backend/chat-motoko-backend.did +141 -109
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.d.ts +115 -92
- package/declarations/chat-motoko-backend/chat-motoko-backend.did.js +131 -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 +24 -50
- package/dist/actors/chats-actor.d.ts.map +1 -1
- package/dist/actors/chats-actor.js +40 -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 +6 -5
- package/dist/actors/projects-actor.d.ts.map +1 -1
- package/dist/actors/projects-actor.js +8 -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 +81 -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 +61 -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,73 @@
|
|
|
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
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/** Asked (`isUser`) before somebody who is not an admin opens a chat in the project. */
|
|
17
|
+
accountsCanisterId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RecipientView {
|
|
20
|
+
principal: string;
|
|
21
|
+
role: RecipientRoleView;
|
|
22
|
+
/** What the customer sees instead of a principal. */
|
|
23
|
+
displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RoomView {
|
|
26
|
+
id: string;
|
|
27
|
+
projectId: string;
|
|
28
|
+
name: string;
|
|
29
|
+
createdBy: string;
|
|
30
|
+
createdAt: bigint;
|
|
31
|
+
recipients: RecipientView[];
|
|
21
32
|
}
|
|
22
|
-
export interface
|
|
33
|
+
export interface ParticipantView {
|
|
23
34
|
principal: string;
|
|
24
35
|
role: RoleView;
|
|
36
|
+
displayName: string;
|
|
25
37
|
joinedAt: bigint;
|
|
38
|
+
/** The seq of the participant's first own message; undefined until they have spoken. */
|
|
39
|
+
firstPostSeq?: number;
|
|
26
40
|
lastReadSeq: number;
|
|
27
41
|
}
|
|
28
42
|
export interface ChatView {
|
|
29
43
|
id: string;
|
|
30
44
|
projectId: string;
|
|
31
|
-
|
|
45
|
+
roomId: string;
|
|
46
|
+
customer: string;
|
|
32
47
|
createdAt: bigint;
|
|
33
|
-
|
|
34
|
-
subject?: string;
|
|
35
|
-
policy: PolicyView;
|
|
36
|
-
status: ChatStatusView;
|
|
37
|
-
members: MemberView[];
|
|
48
|
+
participants: ParticipantView[];
|
|
38
49
|
lastSeq: number;
|
|
39
50
|
lastMessageAt: bigint;
|
|
40
51
|
}
|
|
52
|
+
/** What a project admin sees of a chat: metadata, never content. */
|
|
53
|
+
export interface ChatSummaryView {
|
|
54
|
+
id: string;
|
|
55
|
+
projectId: string;
|
|
56
|
+
roomId: string;
|
|
57
|
+
customer: string;
|
|
58
|
+
createdAt: bigint;
|
|
59
|
+
participantCount: number;
|
|
60
|
+
messageCount: number;
|
|
61
|
+
lastMessageAt: bigint;
|
|
62
|
+
}
|
|
41
63
|
export type SystemEventView = {
|
|
42
64
|
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
65
|
};
|
|
65
66
|
export type MessageKindView = "text" | "toolTrace" | "event";
|
|
66
67
|
export interface MessageView {
|
|
67
68
|
chatId: string;
|
|
68
69
|
projectId: string;
|
|
70
|
+
roomId: string;
|
|
71
|
+
/** Whom the chat belongs to — so a recipient's poll routes without a lookup. */
|
|
72
|
+
customer: string;
|
|
69
73
|
/** Dense per-chat sequence starting at 1. */
|
|
70
74
|
seq: number;
|
|
71
75
|
/** Canister-wide sequence — the poll cursor. */
|
|
@@ -87,52 +91,64 @@ export interface PollResultView {
|
|
|
87
91
|
nextSinceGlobalSeq: number;
|
|
88
92
|
headGlobalSeq: number;
|
|
89
93
|
}
|
|
94
|
+
export interface QuotaLimitsView {
|
|
95
|
+
/** Messages one principal may post per UTC day. */
|
|
96
|
+
posts: number;
|
|
97
|
+
/** Chats one principal may open per UTC day. */
|
|
98
|
+
chats: number;
|
|
99
|
+
}
|
|
90
100
|
export interface CreateProjectInput {
|
|
91
101
|
id: string;
|
|
92
102
|
admins: string[];
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
defaultPolicy: PolicyView;
|
|
103
|
+
/** The canister that answers `isUser(principal)` for this project — mandatory. */
|
|
104
|
+
accountsCanisterId: string;
|
|
96
105
|
}
|
|
97
106
|
export interface UpdateProjectInput {
|
|
98
107
|
projectId: string;
|
|
99
108
|
admins?: string[];
|
|
100
|
-
|
|
101
|
-
agentsMayInvite?: boolean;
|
|
102
|
-
defaultPolicy?: PolicyView;
|
|
109
|
+
accountsCanisterId?: string;
|
|
103
110
|
}
|
|
104
|
-
export interface
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
export interface CreateRoomInput {
|
|
112
|
+
projectId: string;
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
recipients: RecipientView[];
|
|
107
116
|
}
|
|
108
|
-
export interface
|
|
117
|
+
export interface UpdateRoomInput {
|
|
109
118
|
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;
|
|
119
|
+
roomId: string;
|
|
120
|
+
name?: string;
|
|
121
|
+
/** Replaces the whole list; chats already opened keep their recipients. */
|
|
122
|
+
recipients?: RecipientView[];
|
|
121
123
|
}
|
|
122
|
-
export interface
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
export interface RoomRefInput {
|
|
125
|
+
projectId: string;
|
|
126
|
+
roomId: string;
|
|
127
|
+
}
|
|
128
|
+
export interface ListRoomsInput {
|
|
129
|
+
projectId: string;
|
|
130
|
+
limit?: number;
|
|
131
|
+
}
|
|
132
|
+
export interface OpenChatInput {
|
|
133
|
+
projectId: string;
|
|
134
|
+
roomId: string;
|
|
135
|
+
/** How the recipients see the caller; omitted = the principal. */
|
|
136
|
+
customerName?: string;
|
|
125
137
|
}
|
|
126
138
|
export interface GetMyChatsInput {
|
|
127
139
|
projectId: string;
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
roomId?: string;
|
|
141
|
+
limit?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface ListProjectChatsInput {
|
|
144
|
+
projectId: string;
|
|
145
|
+
roomId?: string;
|
|
130
146
|
limit?: number;
|
|
131
147
|
}
|
|
132
148
|
export interface PostInput {
|
|
133
149
|
chatId: string;
|
|
134
150
|
text: string;
|
|
135
|
-
/** Defaults to `text`; `toolTrace` needs the `agent`
|
|
151
|
+
/** Defaults to `text`; `toolTrace` needs the `agent` role. */
|
|
136
152
|
kind?: "text" | "toolTrace";
|
|
137
153
|
}
|
|
138
154
|
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;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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;IAC3E,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,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,OAAO,KAAK,EACR,IAAI,EACJ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,WAAW,EACd,MAAM,gEAAgE,CAAC;AACxE,OAAO,KAAK,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAEvD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAEvD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAEpE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAEhD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,CAE3E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAK5E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAMjE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CAMpE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ5D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAShD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAU5E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAWhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAWxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAEvE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAiB5D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,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,63 @@ 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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
accountsCanisterId: project.accountsCanister.toText(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function mapRoomView(room) {
|
|
47
|
+
return {
|
|
48
|
+
id: room.id,
|
|
49
|
+
projectId: room.projectId,
|
|
50
|
+
name: room.name,
|
|
51
|
+
createdBy: room.createdBy.toText(),
|
|
52
|
+
createdAt: room.createdAt,
|
|
53
|
+
recipients: room.recipients.map(mapRecipientView),
|
|
37
54
|
};
|
|
38
55
|
}
|
|
39
|
-
export function
|
|
56
|
+
export function mapParticipantView(participant) {
|
|
57
|
+
const firstPostSeq = fromOpt(participant.firstPostSeq);
|
|
40
58
|
return {
|
|
41
|
-
principal:
|
|
42
|
-
role: mapRoleView(
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
principal: participant.principal.toText(),
|
|
60
|
+
role: mapRoleView(participant.role),
|
|
61
|
+
displayName: participant.displayName,
|
|
62
|
+
joinedAt: participant.joinedAt,
|
|
63
|
+
firstPostSeq: firstPostSeq === undefined ? undefined : Number(firstPostSeq),
|
|
64
|
+
lastReadSeq: Number(participant.lastReadSeq),
|
|
45
65
|
};
|
|
46
66
|
}
|
|
47
67
|
export function mapChatView(chat) {
|
|
48
68
|
return {
|
|
49
69
|
id: chat.id,
|
|
50
70
|
projectId: chat.projectId,
|
|
51
|
-
|
|
71
|
+
roomId: chat.roomId,
|
|
72
|
+
customer: chat.customer.toText(),
|
|
52
73
|
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),
|
|
74
|
+
participants: chat.participants.map(mapParticipantView),
|
|
58
75
|
lastSeq: Number(chat.lastSeq),
|
|
59
76
|
lastMessageAt: chat.lastMessageAt,
|
|
60
77
|
};
|
|
61
78
|
}
|
|
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() };
|
|
79
|
+
export function mapChatSummaryView(summary) {
|
|
80
|
+
return {
|
|
81
|
+
id: summary.id,
|
|
82
|
+
projectId: summary.projectId,
|
|
83
|
+
roomId: summary.roomId,
|
|
84
|
+
customer: summary.customer.toText(),
|
|
85
|
+
createdAt: summary.createdAt,
|
|
86
|
+
participantCount: Number(summary.participantCount),
|
|
87
|
+
messageCount: Number(summary.messageCount),
|
|
88
|
+
lastMessageAt: summary.lastMessageAt,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function mapSystemEventView(_event) {
|
|
92
|
+
return { type: "chatCreated" };
|
|
84
93
|
}
|
|
85
94
|
export function mapMessageView(message) {
|
|
86
95
|
const base = {
|
|
87
96
|
chatId: message.chatId,
|
|
88
97
|
projectId: message.projectId,
|
|
98
|
+
roomId: message.roomId,
|
|
99
|
+
customer: message.customer.toText(),
|
|
89
100
|
seq: Number(message.seq),
|
|
90
101
|
globalSeq: Number(message.globalSeq),
|
|
91
102
|
author: message.author.toText(),
|
|
@@ -107,3 +118,9 @@ export function mapPollResultView(result) {
|
|
|
107
118
|
headGlobalSeq: Number(result.headGlobalSeq),
|
|
108
119
|
};
|
|
109
120
|
}
|
|
121
|
+
export function mapQuotaLimitsView(limits) {
|
|
122
|
+
return { posts: Number(limits.posts), chats: Number(limits.chats) };
|
|
123
|
+
}
|
|
124
|
+
export function toCandidQuotaLimits(limits) {
|
|
125
|
+
return { posts: BigInt(limits.posts), chats: BigInt(limits.chats) };
|
|
126
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/chat-motoko-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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": "caf02c560d1c988bb79f26d6221a173a0ba8b7c2"
|
|
60
62
|
}
|
|
61
63
|
}
|