@raisindb/client 0.1.5 → 0.1.17

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.
Files changed (44) hide show
  1. package/README.md +281 -70
  2. package/dist/chunk-DJDP5CX6.mjs +866 -0
  3. package/dist/chunk-DJDP5CX6.mjs.map +1 -0
  4. package/dist/chunk-JRFBP4WK.mjs +170 -0
  5. package/dist/chunk-JRFBP4WK.mjs.map +1 -0
  6. package/dist/chunk-OLJOZIIU.mjs +1348 -0
  7. package/dist/chunk-OLJOZIIU.mjs.map +1 -0
  8. package/dist/chunk-T2ZSNYFG.mjs +248 -0
  9. package/dist/chunk-T2ZSNYFG.mjs.map +1 -0
  10. package/dist/chunk-VZX3ACSO.mjs +190 -0
  11. package/dist/chunk-VZX3ACSO.mjs.map +1 -0
  12. package/dist/chunk-WFBAWOVM.mjs +532 -0
  13. package/dist/chunk-WFBAWOVM.mjs.map +1 -0
  14. package/dist/conversation-list-store-CNcVagmw.d.mts +6120 -0
  15. package/dist/conversation-list-store-CNcVagmw.d.ts +6120 -0
  16. package/dist/index-DQjE-4Oj.d.ts +301 -0
  17. package/dist/index-FkFH4HHQ.d.mts +301 -0
  18. package/dist/index.d.mts +66 -6108
  19. package/dist/index.d.ts +66 -6108
  20. package/dist/index.js +859 -109
  21. package/dist/index.js.map +1 -0
  22. package/dist/index.mjs +639 -3108
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/react.d.mts +4 -0
  25. package/dist/react.d.ts +4 -0
  26. package/dist/react.js +2500 -0
  27. package/dist/react.js.map +1 -0
  28. package/dist/react.mjs +9 -0
  29. package/dist/react.mjs.map +1 -0
  30. package/dist/svelte-sql-62EaYoeM.d.ts +52 -0
  31. package/dist/svelte-sql-CgT-Ij-P.d.mts +52 -0
  32. package/dist/svelte.d.mts +288 -0
  33. package/dist/svelte.d.ts +288 -0
  34. package/dist/svelte.js +2413 -0
  35. package/dist/svelte.js.map +1 -0
  36. package/dist/svelte.mjs +25 -0
  37. package/dist/svelte.mjs.map +1 -0
  38. package/dist/vue.d.mts +197 -0
  39. package/dist/vue.d.ts +197 -0
  40. package/dist/vue.js +1441 -0
  41. package/dist/vue.js.map +1 -0
  42. package/dist/vue.mjs +9 -0
  43. package/dist/vue.mjs.map +1 -0
  44. package/package.json +18 -3
package/dist/vue.d.mts ADDED
@@ -0,0 +1,197 @@
1
+ import { I as IdentityUser, C as ConnectionState, a as ConversationStoreSnapshot, b as ChatMessage, T as ToolCallInfo, P as PlanProjection, c as ConversationStore, d as ConversationListItem, e as ConversationListStore, R as RaisinClient, D as Database, S as SubscriptionFilters, E as EventMessage, f as ConversationStoreOptions, g as ConversationListStoreOptions } from './conversation-list-store-CNcVagmw.mjs';
2
+ import { S as SqlAdapterOptions } from './svelte-sql-CgT-Ij-P.mjs';
3
+ import 'events';
4
+ import 'fs/promises';
5
+
6
+ /** Minimal mutable ref shape (structural subset of Vue's `Ref<T>`) */
7
+ interface VueRef<T> {
8
+ value: T;
9
+ }
10
+ /**
11
+ * Minimal read-only ref shape (structural subset of Vue's `ComputedRef<T>`).
12
+ *
13
+ * At runtime these ARE real `vue.computed()` refs (created via the module you
14
+ * pass to `createRaisinVue`), but the declared type is structural — it lacks
15
+ * Vue's branded `ComputedRefSymbol`, so TypeScript will not accept it as a
16
+ * `watch()` / `watchEffect()` source directly. Wrap it in a getter instead:
17
+ *
18
+ * ```ts
19
+ * const { data } = useSql(db, sql);
20
+ * watch(() => data.value, (rows) => { ... }); // ✅ typechecks
21
+ * watch(data, (rows) => { ... }); // ❌ TS2345 (works at runtime)
22
+ * ```
23
+ */
24
+ interface VueComputedRef<T> {
25
+ readonly value: T;
26
+ }
27
+ /**
28
+ * Minimal subset of the Vue 3 API needed by the composables.
29
+ *
30
+ * The SDK follows the same "bring your own framework" pattern as the React
31
+ * integration (`createRaisinReact(React)`): instead of importing from `vue`
32
+ * (which would make Vue a dependency of the SDK), you pass the Vue module —
33
+ * or any object with compatible `ref` / `computed` / `onUnmounted` — to
34
+ * `createRaisinVue()`.
35
+ *
36
+ * The signatures are intentionally loose (`any`-based `ref`) so the real
37
+ * `import * as vue from 'vue'` module is structurally assignable despite
38
+ * Vue's `UnwrapRef` generics. Composables re-narrow the types internally.
39
+ */
40
+ interface VueLike {
41
+ /** Vue's `ref()` (or `shallowRef()`); snapshots are replaced wholesale. */
42
+ ref(value: any): {
43
+ value: any;
44
+ };
45
+ /** Vue's `computed()` */
46
+ computed<T>(getter: () => T): VueComputedRef<T>;
47
+ /** Vue's `onUnmounted()` lifecycle hook */
48
+ onUnmounted(fn: () => void): void;
49
+ }
50
+ /** Return type for useAuth() */
51
+ interface UseAuthReturn {
52
+ user: VueComputedRef<IdentityUser | null>;
53
+ isAuthenticated: VueComputedRef<boolean>;
54
+ isLoading: VueComputedRef<boolean>;
55
+ login: (email: string, password: string, repository: string) => Promise<IdentityUser>;
56
+ register: (email: string, password: string, repository: string, displayName?: string) => Promise<IdentityUser>;
57
+ logout: (options?: {
58
+ disconnect?: boolean;
59
+ reconnect?: boolean;
60
+ }) => Promise<void>;
61
+ initSession: (repository: string) => Promise<IdentityUser | null>;
62
+ }
63
+ /** Return type for useConnection() */
64
+ interface UseConnectionReturn {
65
+ state: VueComputedRef<ConnectionState>;
66
+ isConnected: VueComputedRef<boolean>;
67
+ isReady: VueComputedRef<boolean>;
68
+ connect: () => Promise<void>;
69
+ disconnect: () => void;
70
+ }
71
+ /** Return type for useSql<T>() */
72
+ interface UseSqlReturn<T> {
73
+ data: VueComputedRef<T[] | null>;
74
+ isLoading: VueComputedRef<boolean>;
75
+ error: VueComputedRef<Error | null>;
76
+ refetch: () => Promise<void>;
77
+ }
78
+ /** Handle returned by useSubscription() */
79
+ interface UseSubscriptionReturn {
80
+ /** Stop receiving events (also called automatically on unmount) */
81
+ unsubscribe: () => void;
82
+ }
83
+ /** Return type for useConversation() */
84
+ interface UseConversationReturn {
85
+ conversation: VueComputedRef<ConversationStoreSnapshot['conversation']>;
86
+ messages: VueComputedRef<ChatMessage[]>;
87
+ isStreaming: VueComputedRef<boolean>;
88
+ isWaiting: VueComputedRef<boolean>;
89
+ streamingText: VueComputedRef<string>;
90
+ error: VueComputedRef<string | null>;
91
+ activeToolCalls: VueComputedRef<ToolCallInfo[]>;
92
+ plans: VueComputedRef<PlanProjection[]>;
93
+ isLoading: VueComputedRef<boolean>;
94
+ conversationPath: VueComputedRef<string | null>;
95
+ sendMessage: (content: string) => Promise<void>;
96
+ approvePlan: (planPath: string) => Promise<void>;
97
+ rejectPlan: (planPath: string, feedback?: string) => Promise<void>;
98
+ stop: () => void;
99
+ loadMessages: () => Promise<ChatMessage[]>;
100
+ /** The underlying store, for advanced use */
101
+ store: ConversationStore;
102
+ }
103
+ /** Return type for useConversationList() */
104
+ interface UseConversationListReturn {
105
+ conversations: VueComputedRef<ConversationListItem[]>;
106
+ totalUnreadCount: VueComputedRef<number>;
107
+ isLoading: VueComputedRef<boolean>;
108
+ error: VueComputedRef<string | null>;
109
+ createConversation: (options: {
110
+ participant: string;
111
+ subject?: string;
112
+ input?: Record<string, unknown>;
113
+ }) => Promise<ConversationListItem>;
114
+ deleteConversation: (conversationPath: string) => Promise<void>;
115
+ markAsRead: (conversationPath: string) => Promise<void>;
116
+ /** Reload the list from the server */
117
+ refresh: () => Promise<void>;
118
+ /** The underlying store, for advanced use */
119
+ store: ConversationListStore;
120
+ }
121
+
122
+ /**
123
+ * Vue 3 integration layer for RaisinDB.
124
+ *
125
+ * Provides a `createRaisinVue(vue)` factory that returns composables for
126
+ * auth, connection, SQL queries, node-event subscriptions, and the
127
+ * conversation stores.
128
+ *
129
+ * Uses the same "bring your own framework" pattern as the React integration
130
+ * (`createRaisinReact(React)`): the SDK never imports `vue`, so Vue stays
131
+ * out of the SDK's dependency graph and the main `.` bundle. You pass the
132
+ * Vue module (its `ref`, `computed`, and `onUnmounted` are all that is
133
+ * needed) once at setup time.
134
+ *
135
+ * Each composable creates its underlying store/adapter when called and
136
+ * destroys it automatically in `onUnmounted`, so call them from
137
+ * `setup()` / `<script setup>`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // lib/raisin-vue.ts
142
+ * import * as vue from 'vue';
143
+ * import { RaisinClient, LocalStorageTokenStorage } from '@raisindb/client';
144
+ * import { createRaisinVue } from '@raisindb/client/vue';
145
+ *
146
+ * export const client = new RaisinClient('ws://localhost:8081/sys/default/myrepo', {
147
+ * tokenStorage: new LocalStorageTokenStorage('myapp'),
148
+ * });
149
+ * export const db = client.database('myrepo');
150
+ *
151
+ * export const {
152
+ * useAuth, useConnection, useSql, useSubscription,
153
+ * useConversation, useConversationList,
154
+ * } = createRaisinVue(vue);
155
+ * ```
156
+ *
157
+ * @example In a component:
158
+ * ```vue
159
+ * <script setup lang="ts">
160
+ * import { client, db, useConversation } from '@/lib/raisin-vue';
161
+ *
162
+ * const chat = useConversation({
163
+ * database: db,
164
+ * createOptions: { participant: '/agents/support' },
165
+ * });
166
+ * </script>
167
+ *
168
+ * <template>
169
+ * <div v-for="(m, i) in chat.messages.value" :key="i">{{ m.content }}</div>
170
+ * <p v-if="chat.isStreaming.value">{{ chat.streamingText.value }}</p>
171
+ * </template>
172
+ * ```
173
+ */
174
+
175
+ interface RaisinVue {
176
+ /** Reactive auth state + login/register/logout/initSession actions */
177
+ useAuth: (client: RaisinClient) => UseAuthReturn;
178
+ /** Reactive connection state (state / isConnected / isReady) */
179
+ useConnection: (client: RaisinClient) => UseConnectionReturn;
180
+ /** Run a SQL query with reactive data/isLoading/error + optional realtime refetch */
181
+ useSql: <T = Record<string, unknown>>(database: Database, sql: string, params?: unknown[], options?: SqlAdapterOptions) => UseSqlReturn<T>;
182
+ /** Subscribe to node events; unsubscribes automatically on unmount */
183
+ useSubscription: (database: Database, filters: SubscriptionFilters, callback: (event: EventMessage) => void) => UseSubscriptionReturn;
184
+ /** Bind a ConversationStore (chat: messages, streaming, tool calls, plans) */
185
+ useConversation: (options: ConversationStoreOptions) => UseConversationReturn;
186
+ /** Bind a ConversationListStore (inbox-style conversation list) */
187
+ useConversationList: (options: ConversationListStoreOptions) => UseConversationListReturn;
188
+ }
189
+ /**
190
+ * Create the full Vue 3 integration for RaisinDB.
191
+ *
192
+ * @param vue - The Vue module (or any object providing `ref`, `computed`, `onUnmounted`)
193
+ * @returns The set of composables
194
+ */
195
+ declare function createRaisinVue(vue: VueLike): RaisinVue;
196
+
197
+ export { type RaisinVue, type UseAuthReturn, type UseConnectionReturn, type UseConversationListReturn, type UseConversationReturn, SqlAdapterOptions as UseSqlOptions, type UseSqlReturn, type UseSubscriptionReturn, type VueComputedRef, type VueLike, type VueRef, createRaisinVue };
package/dist/vue.d.ts ADDED
@@ -0,0 +1,197 @@
1
+ import { I as IdentityUser, C as ConnectionState, a as ConversationStoreSnapshot, b as ChatMessage, T as ToolCallInfo, P as PlanProjection, c as ConversationStore, d as ConversationListItem, e as ConversationListStore, R as RaisinClient, D as Database, S as SubscriptionFilters, E as EventMessage, f as ConversationStoreOptions, g as ConversationListStoreOptions } from './conversation-list-store-CNcVagmw.js';
2
+ import { S as SqlAdapterOptions } from './svelte-sql-62EaYoeM.js';
3
+ import 'events';
4
+ import 'fs/promises';
5
+
6
+ /** Minimal mutable ref shape (structural subset of Vue's `Ref<T>`) */
7
+ interface VueRef<T> {
8
+ value: T;
9
+ }
10
+ /**
11
+ * Minimal read-only ref shape (structural subset of Vue's `ComputedRef<T>`).
12
+ *
13
+ * At runtime these ARE real `vue.computed()` refs (created via the module you
14
+ * pass to `createRaisinVue`), but the declared type is structural — it lacks
15
+ * Vue's branded `ComputedRefSymbol`, so TypeScript will not accept it as a
16
+ * `watch()` / `watchEffect()` source directly. Wrap it in a getter instead:
17
+ *
18
+ * ```ts
19
+ * const { data } = useSql(db, sql);
20
+ * watch(() => data.value, (rows) => { ... }); // ✅ typechecks
21
+ * watch(data, (rows) => { ... }); // ❌ TS2345 (works at runtime)
22
+ * ```
23
+ */
24
+ interface VueComputedRef<T> {
25
+ readonly value: T;
26
+ }
27
+ /**
28
+ * Minimal subset of the Vue 3 API needed by the composables.
29
+ *
30
+ * The SDK follows the same "bring your own framework" pattern as the React
31
+ * integration (`createRaisinReact(React)`): instead of importing from `vue`
32
+ * (which would make Vue a dependency of the SDK), you pass the Vue module —
33
+ * or any object with compatible `ref` / `computed` / `onUnmounted` — to
34
+ * `createRaisinVue()`.
35
+ *
36
+ * The signatures are intentionally loose (`any`-based `ref`) so the real
37
+ * `import * as vue from 'vue'` module is structurally assignable despite
38
+ * Vue's `UnwrapRef` generics. Composables re-narrow the types internally.
39
+ */
40
+ interface VueLike {
41
+ /** Vue's `ref()` (or `shallowRef()`); snapshots are replaced wholesale. */
42
+ ref(value: any): {
43
+ value: any;
44
+ };
45
+ /** Vue's `computed()` */
46
+ computed<T>(getter: () => T): VueComputedRef<T>;
47
+ /** Vue's `onUnmounted()` lifecycle hook */
48
+ onUnmounted(fn: () => void): void;
49
+ }
50
+ /** Return type for useAuth() */
51
+ interface UseAuthReturn {
52
+ user: VueComputedRef<IdentityUser | null>;
53
+ isAuthenticated: VueComputedRef<boolean>;
54
+ isLoading: VueComputedRef<boolean>;
55
+ login: (email: string, password: string, repository: string) => Promise<IdentityUser>;
56
+ register: (email: string, password: string, repository: string, displayName?: string) => Promise<IdentityUser>;
57
+ logout: (options?: {
58
+ disconnect?: boolean;
59
+ reconnect?: boolean;
60
+ }) => Promise<void>;
61
+ initSession: (repository: string) => Promise<IdentityUser | null>;
62
+ }
63
+ /** Return type for useConnection() */
64
+ interface UseConnectionReturn {
65
+ state: VueComputedRef<ConnectionState>;
66
+ isConnected: VueComputedRef<boolean>;
67
+ isReady: VueComputedRef<boolean>;
68
+ connect: () => Promise<void>;
69
+ disconnect: () => void;
70
+ }
71
+ /** Return type for useSql<T>() */
72
+ interface UseSqlReturn<T> {
73
+ data: VueComputedRef<T[] | null>;
74
+ isLoading: VueComputedRef<boolean>;
75
+ error: VueComputedRef<Error | null>;
76
+ refetch: () => Promise<void>;
77
+ }
78
+ /** Handle returned by useSubscription() */
79
+ interface UseSubscriptionReturn {
80
+ /** Stop receiving events (also called automatically on unmount) */
81
+ unsubscribe: () => void;
82
+ }
83
+ /** Return type for useConversation() */
84
+ interface UseConversationReturn {
85
+ conversation: VueComputedRef<ConversationStoreSnapshot['conversation']>;
86
+ messages: VueComputedRef<ChatMessage[]>;
87
+ isStreaming: VueComputedRef<boolean>;
88
+ isWaiting: VueComputedRef<boolean>;
89
+ streamingText: VueComputedRef<string>;
90
+ error: VueComputedRef<string | null>;
91
+ activeToolCalls: VueComputedRef<ToolCallInfo[]>;
92
+ plans: VueComputedRef<PlanProjection[]>;
93
+ isLoading: VueComputedRef<boolean>;
94
+ conversationPath: VueComputedRef<string | null>;
95
+ sendMessage: (content: string) => Promise<void>;
96
+ approvePlan: (planPath: string) => Promise<void>;
97
+ rejectPlan: (planPath: string, feedback?: string) => Promise<void>;
98
+ stop: () => void;
99
+ loadMessages: () => Promise<ChatMessage[]>;
100
+ /** The underlying store, for advanced use */
101
+ store: ConversationStore;
102
+ }
103
+ /** Return type for useConversationList() */
104
+ interface UseConversationListReturn {
105
+ conversations: VueComputedRef<ConversationListItem[]>;
106
+ totalUnreadCount: VueComputedRef<number>;
107
+ isLoading: VueComputedRef<boolean>;
108
+ error: VueComputedRef<string | null>;
109
+ createConversation: (options: {
110
+ participant: string;
111
+ subject?: string;
112
+ input?: Record<string, unknown>;
113
+ }) => Promise<ConversationListItem>;
114
+ deleteConversation: (conversationPath: string) => Promise<void>;
115
+ markAsRead: (conversationPath: string) => Promise<void>;
116
+ /** Reload the list from the server */
117
+ refresh: () => Promise<void>;
118
+ /** The underlying store, for advanced use */
119
+ store: ConversationListStore;
120
+ }
121
+
122
+ /**
123
+ * Vue 3 integration layer for RaisinDB.
124
+ *
125
+ * Provides a `createRaisinVue(vue)` factory that returns composables for
126
+ * auth, connection, SQL queries, node-event subscriptions, and the
127
+ * conversation stores.
128
+ *
129
+ * Uses the same "bring your own framework" pattern as the React integration
130
+ * (`createRaisinReact(React)`): the SDK never imports `vue`, so Vue stays
131
+ * out of the SDK's dependency graph and the main `.` bundle. You pass the
132
+ * Vue module (its `ref`, `computed`, and `onUnmounted` are all that is
133
+ * needed) once at setup time.
134
+ *
135
+ * Each composable creates its underlying store/adapter when called and
136
+ * destroys it automatically in `onUnmounted`, so call them from
137
+ * `setup()` / `<script setup>`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // lib/raisin-vue.ts
142
+ * import * as vue from 'vue';
143
+ * import { RaisinClient, LocalStorageTokenStorage } from '@raisindb/client';
144
+ * import { createRaisinVue } from '@raisindb/client/vue';
145
+ *
146
+ * export const client = new RaisinClient('ws://localhost:8081/sys/default/myrepo', {
147
+ * tokenStorage: new LocalStorageTokenStorage('myapp'),
148
+ * });
149
+ * export const db = client.database('myrepo');
150
+ *
151
+ * export const {
152
+ * useAuth, useConnection, useSql, useSubscription,
153
+ * useConversation, useConversationList,
154
+ * } = createRaisinVue(vue);
155
+ * ```
156
+ *
157
+ * @example In a component:
158
+ * ```vue
159
+ * <script setup lang="ts">
160
+ * import { client, db, useConversation } from '@/lib/raisin-vue';
161
+ *
162
+ * const chat = useConversation({
163
+ * database: db,
164
+ * createOptions: { participant: '/agents/support' },
165
+ * });
166
+ * </script>
167
+ *
168
+ * <template>
169
+ * <div v-for="(m, i) in chat.messages.value" :key="i">{{ m.content }}</div>
170
+ * <p v-if="chat.isStreaming.value">{{ chat.streamingText.value }}</p>
171
+ * </template>
172
+ * ```
173
+ */
174
+
175
+ interface RaisinVue {
176
+ /** Reactive auth state + login/register/logout/initSession actions */
177
+ useAuth: (client: RaisinClient) => UseAuthReturn;
178
+ /** Reactive connection state (state / isConnected / isReady) */
179
+ useConnection: (client: RaisinClient) => UseConnectionReturn;
180
+ /** Run a SQL query with reactive data/isLoading/error + optional realtime refetch */
181
+ useSql: <T = Record<string, unknown>>(database: Database, sql: string, params?: unknown[], options?: SqlAdapterOptions) => UseSqlReturn<T>;
182
+ /** Subscribe to node events; unsubscribes automatically on unmount */
183
+ useSubscription: (database: Database, filters: SubscriptionFilters, callback: (event: EventMessage) => void) => UseSubscriptionReturn;
184
+ /** Bind a ConversationStore (chat: messages, streaming, tool calls, plans) */
185
+ useConversation: (options: ConversationStoreOptions) => UseConversationReturn;
186
+ /** Bind a ConversationListStore (inbox-style conversation list) */
187
+ useConversationList: (options: ConversationListStoreOptions) => UseConversationListReturn;
188
+ }
189
+ /**
190
+ * Create the full Vue 3 integration for RaisinDB.
191
+ *
192
+ * @param vue - The Vue module (or any object providing `ref`, `computed`, `onUnmounted`)
193
+ * @returns The set of composables
194
+ */
195
+ declare function createRaisinVue(vue: VueLike): RaisinVue;
196
+
197
+ export { type RaisinVue, type UseAuthReturn, type UseConnectionReturn, type UseConversationListReturn, type UseConversationReturn, SqlAdapterOptions as UseSqlOptions, type UseSqlReturn, type UseSubscriptionReturn, type VueComputedRef, type VueLike, type VueRef, createRaisinVue };