@volorio/chat-uikit 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 ADDED
@@ -0,0 +1,3 @@
1
+ # @volorio/chat-uikit
2
+
3
+ React UI helper models for Volorio chat applications.
@@ -0,0 +1,36 @@
1
+ import type { VolorioChatAttachment, VolorioChatClient, VolorioChatMessage, VolorioChatModerationAction, VolorioChatServiceClient, VolorioConversationRole } from "@volorio/chat";
2
+ export interface VolorioChatUIKitModel {
3
+ messages: VolorioChatMessage[];
4
+ send: (text: string) => Promise<void>;
5
+ sendRichMessage: (input: {
6
+ text?: string;
7
+ attachments?: VolorioChatAttachment[];
8
+ replyToMessageId?: string;
9
+ }) => Promise<void>;
10
+ }
11
+ export declare function createVolorioChatUIKitModel(input: {
12
+ chat: VolorioChatClient;
13
+ conversationId: string;
14
+ senderId: string;
15
+ messages?: VolorioChatMessage[];
16
+ }): VolorioChatUIKitModel;
17
+ export interface VolorioChatProductConsoleModel {
18
+ reactions: string[];
19
+ attachmentActions: Array<{
20
+ type: VolorioChatAttachment["type"];
21
+ label: string;
22
+ accepts?: string;
23
+ }>;
24
+ roleActions: VolorioConversationRole[];
25
+ moderationActions: VolorioChatModerationAction[];
26
+ quickDurationsSeconds: Array<{
27
+ label: string;
28
+ value?: number;
29
+ }>;
30
+ react: (conversationId: string, messageId: string, actorId: string, emoji: string) => Promise<unknown>;
31
+ setRole: (conversationId: string, actorId: string, identity: string, role: VolorioConversationRole) => Promise<unknown>;
32
+ moderate: (conversationId: string, actorId: string, targetIdentity: string, action: VolorioChatModerationAction, reason: string, durationSeconds?: number) => Promise<unknown>;
33
+ }
34
+ export declare function createVolorioChatProductConsoleModel(input: {
35
+ service: VolorioChatServiceClient;
36
+ }): VolorioChatProductConsoleModel;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVolorioChatUIKitModel = createVolorioChatUIKitModel;
4
+ exports.createVolorioChatProductConsoleModel = createVolorioChatProductConsoleModel;
5
+ function createVolorioChatUIKitModel(input) {
6
+ return {
7
+ messages: input.messages ?? [],
8
+ send: (text) => input.chat.sendMessage({ conversationId: input.conversationId, senderId: input.senderId, text }),
9
+ sendRichMessage: (message) => input.chat.sendMessage({ conversationId: input.conversationId, senderId: input.senderId, ...message }),
10
+ };
11
+ }
12
+ function createVolorioChatProductConsoleModel(input) {
13
+ return {
14
+ reactions: ["👍", "❤️", "😂", "😮", "😢", "🙏"],
15
+ attachmentActions: [
16
+ { type: "image", label: "Photo", accepts: "image/*" },
17
+ { type: "video", label: "Video", accepts: "video/*" },
18
+ { type: "gif", label: "GIF", accepts: "image/gif" },
19
+ { type: "file", label: "File" },
20
+ { type: "location", label: "Location" },
21
+ { type: "contact", label: "Contact" },
22
+ ],
23
+ roleActions: ["owner", "admin", "moderator", "member"],
24
+ moderationActions: ["mute", "kick", "ban"],
25
+ quickDurationsSeconds: [
26
+ { label: "15m", value: 900 },
27
+ { label: "1h", value: 3600 },
28
+ { label: "24h", value: 86_400 },
29
+ { label: "Forever" },
30
+ ],
31
+ react: (conversationId, messageId, actorId, emoji) => input.service.reactToMessage(conversationId, messageId, { actorId, emoji }),
32
+ setRole: (conversationId, actorId, identity, role) => input.service.setMemberRole(conversationId, { actorId, identity, role }),
33
+ moderate: (conversationId, actorId, targetIdentity, action, reason, durationSeconds) => input.service.applyModerationAction(conversationId, { actorId, targetIdentity, action, reason, durationSeconds }),
34
+ };
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAQA,kEAWC;AAaD,oFAuBC;AA/CD,SAAgB,2BAA2B,CAAC,KAK3C;IACC,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;QAC9B,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAA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E,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;YAC/B,EAAE,KAAK,EAAE,SAAS,EAAE;SACrB;QACD,KAAK,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACjI,OAAO,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC9H,QAAQ,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;KAC1M,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@volorio/chat-uikit",
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "description": "React UI helpers for Volorio chat.",
6
+ "main": "dist/src/index.js",
7
+ "types": "dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "default": "./dist/src/index.js"
12
+ }
13
+ },
14
+ "files": ["dist/src", "README.md"],
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.build.json",
21
+ "test": "pnpm build",
22
+ "pack:local": "pnpm build && npm pack --pack-destination dist"
23
+ },
24
+ "peerDependencies": {
25
+ "react": ">=18.0.0"
26
+ },
27
+ "dependencies": {
28
+ "@volorio/chat": "^0.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^18.2.79",
32
+ "react": "^18.2.0"
33
+ }
34
+ }