@fayz-ai/plugin-conversations 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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/ConversationsContext.d.ts +9 -0
- package/dist/ConversationsContext.d.ts.map +1 -0
- package/dist/ConversationsPage.d.ts +7 -0
- package/dist/ConversationsPage.d.ts.map +1 -0
- package/dist/channel.d.ts +14 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/data/mock.d.ts +3 -0
- package/dist/data/mock.d.ts.map +1 -0
- package/dist/data/supabase.d.ts +11 -0
- package/dist/data/supabase.d.ts.map +1 -0
- package/dist/data/types.d.ts +9 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/index.cjs +904 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +896 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/en.d.ts +2 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/index.d.ts +2 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/store.d.ts +21 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/views/ContactPanel.d.ts +8 -0
- package/dist/views/ContactPanel.d.ts.map +1 -0
- package/dist/views/ConversationList.d.ts +5 -0
- package/dist/views/ConversationList.d.ts.map +1 -0
- package/dist/views/InboxView.d.ts +3 -0
- package/dist/views/InboxView.d.ts.map +1 -0
- package/dist/views/MessageThread.d.ts +10 -0
- package/dist/views/MessageThread.d.ts.map +1 -0
- package/dist/views/shared.d.ts +20 -0
- package/dist/views/shared.d.ts.map +1 -0
- package/package.json +54 -0
- package/src/ConversationsContext.tsx +21 -0
- package/src/ConversationsPage.tsx +18 -0
- package/src/channel.ts +34 -0
- package/src/data/mock.ts +142 -0
- package/src/data/supabase.ts +202 -0
- package/src/data/types.ts +15 -0
- package/src/index.ts +132 -0
- package/src/locales/en.ts +4 -0
- package/src/locales/index.ts +5 -0
- package/src/store.ts +93 -0
- package/src/types.ts +58 -0
- package/src/views/ContactPanel.tsx +95 -0
- package/src/views/ConversationList.tsx +108 -0
- package/src/views/InboxView.tsx +62 -0
- package/src/views/MessageThread.tsx +169 -0
- package/src/views/shared.tsx +97 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Faya Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @fayz-ai/plugin-conversations
|
|
2
|
+
|
|
3
|
+
> One omni-channel inbox — SMS, WhatsApp, Instagram, email, and web chat in one thread.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fayz-ai/plugin-conversations)
|
|
6
|
+
[](https://github.com/FayaLabs/fayz-sdk/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Customers reach out everywhere — a WhatsApp here, an Instagram DM there, an email, a text. Replying across five tabs is how businesses drop conversations. `plugin-conversations` is the GoHighLevel-style unified inbox for the Fayz engine: every channel collapses into one threaded view, so a salon, a restaurant, or an agency answers everyone from a single place.
|
|
9
|
+
|
|
10
|
+
This is foundational today. The plugin ships a complete inbox UI and a data-provider seam: it runs on a rich mock out of the box, and reads/writes the `conversations` + `conversation_messages` tables (tenant-scoped) when a Supabase client is registered. Real channel connectors — Twilio, WhatsApp Cloud, Meta, IMAP — are the next milestone, but the inbox, the store, the events, and the AI tools are already wired so the rest snaps in behind them.
|
|
11
|
+
|
|
12
|
+
## What's inside
|
|
13
|
+
- A full-bleed `/conversations` inbox view backed by a Zustand store
|
|
14
|
+
- A `ConversationsProvider` seam: mock provider, or a Supabase provider (tenant-scoped via the active org) when a client is registered
|
|
15
|
+
- Domain events: `conversations.message.received`, `conversations.message.sent`
|
|
16
|
+
- AI tools: `listConversations` (filter by `sms` / `whatsapp` / `instagram` / `email` / `webchat`) and `sendMessage`
|
|
17
|
+
- Configurable navigation and full i18n
|
|
18
|
+
- Exported types (`Conversation`, `Message`, `Channel`) and the Supabase provider factory for custom wiring
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
```bash
|
|
22
|
+
npm install @fayz-ai/plugin-conversations
|
|
23
|
+
```
|
|
24
|
+
Peer deps: `@fayz-ai/core`, `@fayz-ai/ui`, `@fayz-ai/saas`, plus `react` / `react-dom`.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
```tsx
|
|
28
|
+
import { defineSaas } from '@fayz-ai/saas'
|
|
29
|
+
import { createConversationsPlugin } from '@fayz-ai/plugin-conversations'
|
|
30
|
+
|
|
31
|
+
export const app = defineSaas({
|
|
32
|
+
// ...
|
|
33
|
+
plugins: [
|
|
34
|
+
createConversationsPlugin({ navLabel: 'Inbox', navPosition: 1 }),
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
With no Supabase client registered it runs on the mock inbox; register one and it persists to `conversations` / `conversation_messages` automatically.
|
|
39
|
+
|
|
40
|
+
## Part of the Fayz SDK
|
|
41
|
+
The conversation layer of the engine. Pairs with `plugin-crm` (who you're talking to), `plugin-marketing` (broadcasts that start the thread), and `plugin-reputation` (turning a happy reply into a review).
|
|
42
|
+
|
|
43
|
+
## Roadmap & contributing
|
|
44
|
+
Early and foundational — built in the open. See the [Fayz SDK roadmap](../../docs/ROADMAP.md#plugin-conversations) for current gaps, missing features, and good first issues.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StoreApi } from 'zustand';
|
|
3
|
+
import type { ConversationsUIState } from './store';
|
|
4
|
+
export declare function ConversationsContextProvider({ store, children, }: {
|
|
5
|
+
store: StoreApi<ConversationsUIState>;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
export declare function useConversationsStore<T>(selector: (state: ConversationsUIState) => T): T;
|
|
9
|
+
//# sourceMappingURL=ConversationsContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationsContext.d.ts","sourceRoot":"","sources":["../src/ConversationsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAInD,wBAAgB,4BAA4B,CAAC,EAC3C,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,qBAEA;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,CAAC,GAAG,CAAC,CAIxF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StoreApi } from 'zustand/vanilla';
|
|
3
|
+
import type { ConversationsUIState } from './store';
|
|
4
|
+
export declare function ConversationsPage({ store }: {
|
|
5
|
+
store: StoreApi<ConversationsUIState>;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ConversationsPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationsPage.d.ts","sourceRoot":"","sources":["../src/ConversationsPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGnD,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAA;CAAE,qBAWrF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CHANNEL_LABELS, type Channel } from './types';
|
|
3
|
+
export declare const CHANNEL_ICON: Record<Channel, React.ComponentType<{
|
|
4
|
+
className?: string;
|
|
5
|
+
}>>;
|
|
6
|
+
export interface ChannelAccent {
|
|
7
|
+
/** Solid brand color (hex) — bubbles, dots, header chips. */
|
|
8
|
+
color: string;
|
|
9
|
+
/** Soft tinted background classes for badges. */
|
|
10
|
+
badge: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const CHANNEL_ACCENT: Record<Channel, ChannelAccent>;
|
|
13
|
+
export { CHANNEL_LABELS };
|
|
14
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAQtD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAMrF,CAAA;AAED,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,OAAO,EAAE,aAAa,CAMzD,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAoFpD,wBAAgB,+BAA+B,IAAI,qBAAqB,CAyDvE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConversationsProvider } from './types';
|
|
2
|
+
export interface SupabaseConversationsConfig {
|
|
3
|
+
/** Supabase client; defaults to the global one registered by createFayzApp. */
|
|
4
|
+
supabaseClient?: unknown;
|
|
5
|
+
/** Active tenant id (value or getter) used to scope reads and stamp writes. */
|
|
6
|
+
tenantId?: string | (() => string | undefined);
|
|
7
|
+
/** Display name stamped as the author of outbound messages. */
|
|
8
|
+
selfAuthor?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createSupabaseConversationsProvider(config?: SupabaseConversationsConfig): ConversationsProvider;
|
|
11
|
+
//# sourceMappingURL=supabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAoBpD,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAA;IAC9C,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAkCD,wBAAgB,mCAAmC,CACjD,MAAM,CAAC,EAAE,2BAA2B,GACnC,qBAAqB,CAyIvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Conversation, Message, ListConversationsQuery, SendMessageInput, ConversationStatus } from '../types';
|
|
2
|
+
export interface ConversationsProvider {
|
|
3
|
+
listConversations(query?: ListConversationsQuery): Promise<Conversation[]>;
|
|
4
|
+
getMessages(conversationId: string): Promise<Message[]>;
|
|
5
|
+
sendMessage(input: SendMessageInput): Promise<Message>;
|
|
6
|
+
markRead(conversationId: string): Promise<void>;
|
|
7
|
+
setStatus(conversationId: string, status: ConversationStatus): Promise<Conversation>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/data/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,CAAC,KAAK,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IAC1E,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IACvD,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtD,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CACrF"}
|