@synap-core/client 0.1.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 +253 -0
- package/dist/core.d.ts +1292 -0
- package/dist/facade.d.ts +188 -0
- package/dist/facades/capabilities.d.ts +27 -0
- package/dist/facades/content.d.ts +138 -0
- package/dist/index.cjs +43 -0
- package/dist/index.d.ts +1348 -0
- package/dist/index.js +18 -0
- package/dist/react/index.d.ts +9 -0
- package/dist/react/provider.cjs +94 -0
- package/dist/react/provider.d.ts +57 -0
- package/dist/react/provider.js +67 -0
- package/dist/react/useEntities.d.ts +34 -0
- package/dist/react/useEvents.d.ts +21 -0
- package/dist/react/useThreads.d.ts +27 -0
- package/dist/react.cjs +38 -0
- package/dist/react.d.ts +76 -0
- package/dist/react.js +12 -0
- package/dist/realtime.cjs +117 -0
- package/dist/realtime.d.ts +80 -0
- package/dist/realtime.js +92 -0
- package/dist/types.d.ts +8 -0
- package/package.json +77 -0
package/dist/facade.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business Facade - Couche 2: Façade Métier
|
|
3
|
+
*
|
|
4
|
+
* High-level convenience methods that abstract the event-driven architecture.
|
|
5
|
+
* These methods provide a simple, semantic API for common operations.
|
|
6
|
+
*/
|
|
7
|
+
import type { TRPCClient } from '@trpc/client';
|
|
8
|
+
import type { AppRouter } from './types.js';
|
|
9
|
+
export { ContentFacade } from './facades/content.js';
|
|
10
|
+
export { CapabilitiesFacade } from './facades/capabilities.js';
|
|
11
|
+
/**
|
|
12
|
+
* Business Facade for Notes
|
|
13
|
+
*/
|
|
14
|
+
export declare class NotesFacade {
|
|
15
|
+
private rpc;
|
|
16
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
17
|
+
/**
|
|
18
|
+
* Create a note
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = await synap.notes.create({
|
|
23
|
+
* content: '# My Note\n\nContent here',
|
|
24
|
+
* title: 'My Note',
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
create(input: {
|
|
29
|
+
content: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
}): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
status: 'pending';
|
|
35
|
+
requestId: string;
|
|
36
|
+
entityId: string;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* List notes
|
|
40
|
+
*/
|
|
41
|
+
list(options?: {
|
|
42
|
+
limit?: number;
|
|
43
|
+
offset?: number;
|
|
44
|
+
type?: 'note' | 'task' | 'all';
|
|
45
|
+
}): Promise<Array<{
|
|
46
|
+
id: string;
|
|
47
|
+
title: string | null;
|
|
48
|
+
preview: string | null;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
}>>;
|
|
52
|
+
/**
|
|
53
|
+
* Get a note by ID
|
|
54
|
+
*/
|
|
55
|
+
get(id: string): Promise<{
|
|
56
|
+
id: string;
|
|
57
|
+
title: string | null;
|
|
58
|
+
preview: string | null;
|
|
59
|
+
content?: string;
|
|
60
|
+
fileUrl?: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Business Facade for Chat
|
|
67
|
+
*/
|
|
68
|
+
export declare class ChatFacade {
|
|
69
|
+
private rpc;
|
|
70
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
71
|
+
/**
|
|
72
|
+
* Send a message to the AI assistant
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const result = await synap.chat.sendMessage({
|
|
77
|
+
* content: 'Create a note about AI',
|
|
78
|
+
* threadId: 'thread-123',
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
sendMessage(input: {
|
|
83
|
+
content: string;
|
|
84
|
+
threadId?: string;
|
|
85
|
+
parentId?: string;
|
|
86
|
+
}): Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
status: 'pending';
|
|
89
|
+
requestId: string;
|
|
90
|
+
threadId: string;
|
|
91
|
+
websocketUrl: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Get thread history
|
|
95
|
+
*/
|
|
96
|
+
getThread(threadId: string): Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
messages: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
role: 'user' | 'assistant';
|
|
101
|
+
content: string;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
}>;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* List all threads
|
|
107
|
+
*/
|
|
108
|
+
listThreads(): Promise<Array<{
|
|
109
|
+
id: string;
|
|
110
|
+
preview: string | null;
|
|
111
|
+
createdAt: Date;
|
|
112
|
+
updatedAt: Date;
|
|
113
|
+
}>>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Business Facade for Tasks
|
|
117
|
+
*
|
|
118
|
+
* Note: Tasks are managed through the events API in the current architecture.
|
|
119
|
+
* This facade provides convenience methods that abstract the event-driven flow.
|
|
120
|
+
*/
|
|
121
|
+
export declare class TasksFacade {
|
|
122
|
+
private rpc;
|
|
123
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
124
|
+
/**
|
|
125
|
+
* Complete a task
|
|
126
|
+
*
|
|
127
|
+
* This is a convenience method that publishes a task.completion.requested event.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* await synap.tasks.complete('task-123');
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
complete(taskId: string): Promise<{
|
|
135
|
+
success: boolean;
|
|
136
|
+
eventId: string;
|
|
137
|
+
}>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Business Facade for Capture
|
|
141
|
+
*/
|
|
142
|
+
export declare class CaptureFacade {
|
|
143
|
+
private rpc;
|
|
144
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
145
|
+
/**
|
|
146
|
+
* Capture a raw thought
|
|
147
|
+
*
|
|
148
|
+
* The AI will analyze the thought and create appropriate entities.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* await synap.capture.thought('I need to remember to buy milk');
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
thought(content: string, context?: Record<string, unknown>): Promise<{
|
|
156
|
+
success: boolean;
|
|
157
|
+
message: string;
|
|
158
|
+
}>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Business Facade for System
|
|
162
|
+
*/
|
|
163
|
+
export declare class SystemFacade {
|
|
164
|
+
private rpc;
|
|
165
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
166
|
+
/**
|
|
167
|
+
* Health check
|
|
168
|
+
*/
|
|
169
|
+
health(): Promise<{
|
|
170
|
+
status: string;
|
|
171
|
+
timestamp: string;
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* Get system information
|
|
175
|
+
*/
|
|
176
|
+
info(): Promise<{
|
|
177
|
+
version: string;
|
|
178
|
+
environment: string;
|
|
179
|
+
database: {
|
|
180
|
+
dialect: string;
|
|
181
|
+
connected: boolean;
|
|
182
|
+
};
|
|
183
|
+
storage: {
|
|
184
|
+
provider: string;
|
|
185
|
+
configured: boolean;
|
|
186
|
+
};
|
|
187
|
+
}>;
|
|
188
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capabilities Facade
|
|
3
|
+
* High-level API for discovering Data Pod capabilities
|
|
4
|
+
*
|
|
5
|
+
* DISABLED - capabilities router not implemented in @synap/api yet
|
|
6
|
+
*/
|
|
7
|
+
export declare class CapabilitiesFacade {
|
|
8
|
+
/**
|
|
9
|
+
* List all available capabilities
|
|
10
|
+
* - Core features
|
|
11
|
+
* - Installed plugins
|
|
12
|
+
* - Intelligence services
|
|
13
|
+
*/
|
|
14
|
+
list(): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if specific capability is available
|
|
17
|
+
*/
|
|
18
|
+
has(_capability: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Check if intelligence service with capability exists
|
|
21
|
+
*/
|
|
22
|
+
hasIntelligence(_capability: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Get list of available intelligence services
|
|
25
|
+
*/
|
|
26
|
+
getIntelligenceServices(): Promise<any[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Facade
|
|
3
|
+
*
|
|
4
|
+
* Unified API for creating content using schema-driven events:
|
|
5
|
+
* - Entities: Notes, tasks, projects (→ entities.create.requested)
|
|
6
|
+
* - Documents: PDFs, code files (→ documents.create.requested)
|
|
7
|
+
*
|
|
8
|
+
* Supports metadata for AI context and tags.
|
|
9
|
+
*/
|
|
10
|
+
import type { AppRouter } from '@synap/api';
|
|
11
|
+
import type { TRPCClient } from '@trpc/client';
|
|
12
|
+
/**
|
|
13
|
+
* Entity types supported by the entities worker
|
|
14
|
+
*/
|
|
15
|
+
export type EntityType = 'note' | 'task' | 'project' | 'contact' | 'meeting' | 'idea';
|
|
16
|
+
/**
|
|
17
|
+
* Options for creating an entity (note, task, project, etc.)
|
|
18
|
+
*/
|
|
19
|
+
export interface CreateEntityOptions {
|
|
20
|
+
/** Type of entity to create */
|
|
21
|
+
entityType: EntityType;
|
|
22
|
+
/** Main content (for notes: markdown, for tasks: description) */
|
|
23
|
+
content?: string;
|
|
24
|
+
/** Title of the entity */
|
|
25
|
+
title?: string;
|
|
26
|
+
/** Additional metadata (type-specific: dueDate for tasks, etc.) */
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Legacy: Options for creating a note (kept for backward compatibility)
|
|
31
|
+
* @deprecated Use CreateEntityOptions with entityType: 'note' instead
|
|
32
|
+
*/
|
|
33
|
+
export interface CreateNoteOptions {
|
|
34
|
+
content: string;
|
|
35
|
+
type?: 'note' | 'task';
|
|
36
|
+
metadata?: {
|
|
37
|
+
title?: string;
|
|
38
|
+
tags?: string[];
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for uploading a file
|
|
43
|
+
*/
|
|
44
|
+
export interface UploadFileOptions {
|
|
45
|
+
file: File | Buffer;
|
|
46
|
+
filename: string;
|
|
47
|
+
contentType: string;
|
|
48
|
+
targetType: 'note' | 'document';
|
|
49
|
+
metadata?: {
|
|
50
|
+
title?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
tags?: string[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result of a content creation request
|
|
57
|
+
*/
|
|
58
|
+
export interface CreateResult {
|
|
59
|
+
success: boolean;
|
|
60
|
+
status: 'pending' | 'completed';
|
|
61
|
+
requestId: string;
|
|
62
|
+
entityId?: string;
|
|
63
|
+
documentId?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare class ContentFacade {
|
|
66
|
+
private rpc;
|
|
67
|
+
constructor(rpc: TRPCClient<AppRouter>);
|
|
68
|
+
/**
|
|
69
|
+
* Create entity (note, task, project, etc.)
|
|
70
|
+
*
|
|
71
|
+
* This is the new schema-driven API that uses the consolidated entities worker.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* // Create a note
|
|
76
|
+
* await client.content.createEntity({
|
|
77
|
+
* entityType: 'note',
|
|
78
|
+
* content: '# My Note\n\nContent here...',
|
|
79
|
+
* title: 'My Note',
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Create a task with metadata
|
|
83
|
+
* await client.content.createEntity({
|
|
84
|
+
* entityType: 'task',
|
|
85
|
+
* content: 'Implement feature X',
|
|
86
|
+
* title: 'Feature X',
|
|
87
|
+
* metadata: {
|
|
88
|
+
* dueDate: '2024-12-31',
|
|
89
|
+
* priority: 1,
|
|
90
|
+
* tags: ['dev', 'urgent'],
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
createEntity(options: CreateEntityOptions): Promise<CreateResult>;
|
|
96
|
+
/**
|
|
97
|
+
* Create note from text input
|
|
98
|
+
*
|
|
99
|
+
* @deprecated Use createEntity({ entityType: 'note', ... }) instead
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* await client.content.createNote({
|
|
104
|
+
* content: "# Project Ideas\n\nBuild a knowledge graph...",
|
|
105
|
+
* type: 'note',
|
|
106
|
+
* metadata: { title: 'Q1 Ideas', tags: ['planning'] }
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
createNote(options: CreateNoteOptions): Promise<CreateResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Upload file (direct upload or AI-generated)
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* // Upload PDF as document
|
|
117
|
+
* await client.content.uploadFile({
|
|
118
|
+
* file: pdfBuffer,
|
|
119
|
+
* filename: 'report.pdf',
|
|
120
|
+
* contentType: 'application/pdf',
|
|
121
|
+
* targetType: 'document'
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // Upload markdown as note
|
|
125
|
+
* await client.content.uploadFile({
|
|
126
|
+
* file: markdownFile,
|
|
127
|
+
* filename: 'ideas.md',
|
|
128
|
+
* contentType: 'text/markdown',
|
|
129
|
+
* targetType: 'note'
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
uploadFile(options: UploadFileOptions): Promise<CreateResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Helper: Convert File to Buffer (browser/Node.js compatible)
|
|
136
|
+
*/
|
|
137
|
+
private fileToBuffer;
|
|
138
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createSynapClient: () => createSynapClient,
|
|
24
|
+
default: () => index_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_client = require("@trpc/client");
|
|
28
|
+
function createSynapClient(config) {
|
|
29
|
+
return (0, import_client.createTRPCClient)({
|
|
30
|
+
links: [
|
|
31
|
+
(0, import_client.httpBatchLink)({
|
|
32
|
+
url: `${config.url}/trpc`,
|
|
33
|
+
headers: config.headers,
|
|
34
|
+
fetch: config.fetch
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var index_default = createSynapClient;
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
createSynapClient
|
|
43
|
+
});
|