@rool-dev/client 0.3.1-dev.5742de4 → 0.3.1-dev.5aaae9e

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.
@@ -1,29 +1,29 @@
1
1
  import { EventEmitter } from './event-emitter.js';
2
2
  import type { GraphQLClient } from './graphql.js';
3
3
  import type { MediaClient } from './media.js';
4
- import type { RoolGraphData, RoolNode, RoolEdge, JSONPatchOp, GraphEvents, RoolGraphRole, RoolGraphUser, PromptOptions, MediaItem } from './types.js';
4
+ import type { RoolSpaceData, RoolObject, JSONPatchOp, SpaceEvents, RoolUserRole, RoolUser, PromptOptions, MediaItem } from './types.js';
5
5
  export declare function generateEntityId(): string;
6
- interface GraphConfig {
6
+ interface SpaceConfig {
7
7
  id: string;
8
8
  name: string;
9
- role: RoolGraphRole;
10
- initialData: RoolGraphData;
9
+ role: RoolUserRole;
10
+ initialData: RoolSpaceData;
11
11
  graphqlClient: GraphQLClient;
12
12
  mediaClient: MediaClient;
13
- onRegisterForEvents: (graphId: string, graph: RoolGraph) => void;
14
- onUnregisterFromEvents: (graphId: string) => void;
13
+ onRegisterForEvents: (spaceId: string, space: RoolSpace) => void;
14
+ onUnregisterFromEvents: (spaceId: string) => void;
15
15
  }
16
16
  /**
17
- * First-class Graph object.
17
+ * First-class Space object.
18
18
  *
19
19
  * Features:
20
- * - High-level node/edge operations
20
+ * - High-level object/link operations
21
21
  * - Built-in undo/redo with checkpoints
22
22
  * - Metadata management
23
23
  * - Event emission for state changes
24
24
  * - Real-time subscription support
25
25
  */
26
- export declare class RoolGraph extends EventEmitter<GraphEvents> {
26
+ export declare class RoolSpace extends EventEmitter<SpaceEvents> {
27
27
  private _id;
28
28
  private _name;
29
29
  private _role;
@@ -35,18 +35,18 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
35
35
  private undoStack;
36
36
  private redoStack;
37
37
  private _isSubscribed;
38
- constructor(config: GraphConfig);
38
+ constructor(config: SpaceConfig);
39
39
  get id(): string;
40
40
  get name(): string;
41
- get role(): RoolGraphRole;
41
+ get role(): RoolUserRole;
42
42
  get isReadOnly(): boolean;
43
43
  get isSubscribed(): boolean;
44
44
  /**
45
- * Rename this graph.
45
+ * Rename this space.
46
46
  */
47
47
  rename(newName: string): Promise<void>;
48
48
  /**
49
- * Subscribe to real-time updates for this graph.
49
+ * Subscribe to real-time updates for this space.
50
50
  * Registers with the client for event routing.
51
51
  */
52
52
  subscribe(): void;
@@ -55,7 +55,7 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
55
55
  */
56
56
  unsubscribe(): void;
57
57
  /**
58
- * Close this graph and clean up resources.
58
+ * Close this space and clean up resources.
59
59
  */
60
60
  close(): void;
61
61
  /**
@@ -87,31 +87,36 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
87
87
  */
88
88
  clearHistory(): void;
89
89
  /**
90
- * Get a node by ID.
91
- * @throws Error if node not found
90
+ * Get an object's data by ID.
91
+ * Returns just the data portion (RoolObject), not the full entry with meta/links.
92
+ * @throws Error if object not found
92
93
  */
93
- getNode(nodeId: string): RoolNode;
94
+ getObject(objectId: string): RoolObject;
94
95
  /**
95
- * Get a node by ID, or undefined if not found.
96
+ * Get an object's data by ID, or undefined if not found.
96
97
  */
97
- getNodeOrUndefined(nodeId: string): RoolNode | undefined;
98
+ getObjectOrUndefined(objectId: string): RoolObject | undefined;
98
99
  /**
99
- * Get all nodes of a specific type.
100
+ * Get an object's metadata (position, UI state, etc).
100
101
  */
101
- getNodesByType(type: string): RoolNode[];
102
+ getObjectMeta(objectId: string): Record<string, unknown>;
102
103
  /**
103
- * Get all node IDs.
104
+ * Get all objects of a specific type.
104
105
  */
105
- getNodeIds(): string[];
106
+ getObjectsByType(type: string): RoolObject[];
106
107
  /**
107
- * Create a new node with optional AI generation.
108
- * @param options.type - The node type (required)
109
- * @param options.fields - Node fields (optional). Use {{placeholder}} for AI-generated content.
108
+ * Get all object IDs.
109
+ */
110
+ getObjectIds(): string[];
111
+ /**
112
+ * Create a new object with optional AI generation.
113
+ * @param options.type - The object type (required)
114
+ * @param options.fields - Object fields (optional). Use {{placeholder}} for AI-generated content.
110
115
  * @param options.meta - Client-private metadata (optional). Hidden from AI operations.
111
116
  * @param options.prompt - AI prompt for content generation (optional).
112
- * @returns The generated node ID
117
+ * @returns The generated object ID
113
118
  */
114
- createNode(options: {
119
+ createObject(options: {
115
120
  type: string;
116
121
  fields?: Record<string, unknown>;
117
122
  meta?: Record<string, unknown>;
@@ -121,87 +126,87 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
121
126
  message: string;
122
127
  }>;
123
128
  /**
124
- * Update an existing node.
125
- * @param nodeId - The ID of the node to update
126
- * @param options.type - Optional new type for the node
129
+ * Update an existing object.
130
+ * @param objectId - The ID of the object to update
131
+ * @param options.type - Optional new type for the object
127
132
  * @param options.fields - Fields to add or update. Use {{placeholder}} for AI-generated content.
128
133
  * @param options.meta - Client-private metadata to merge. Hidden from AI operations.
129
134
  * @param options.prompt - AI prompt for content editing (optional).
130
135
  */
131
- updateNode(nodeId: string, options: {
136
+ updateObject(objectId: string, options: {
132
137
  type?: string;
133
138
  fields?: Record<string, unknown>;
134
139
  meta?: Record<string, unknown>;
135
140
  prompt?: string;
136
141
  }): Promise<string>;
137
142
  /**
138
- * Delete nodes by IDs.
139
- * Also removes any edges connected to the deleted nodes.
140
- */
141
- deleteNodes(nodeIds: string[]): Promise<void>;
142
- /**
143
- * Create an edge between nodes.
144
- * @returns The generated edge ID
143
+ * Delete objects by IDs.
144
+ * Outbound links are automatically deleted with the object.
145
+ * Inbound links become orphans (tolerated).
145
146
  */
146
- createEdge(sourceId: string, targetId: string, edgeType: string): Promise<string>;
147
+ deleteObjects(objectIds: string[]): Promise<void>;
147
148
  /**
148
- * Remove edges between two nodes.
149
- * @returns true if any edges were removed
149
+ * Create a link between objects.
150
+ * Links are stored on the source object.
150
151
  */
151
- deleteEdge(sourceId: string, targetId: string): Promise<boolean>;
152
+ link(sourceId: string, targetId: string, linkType: string): Promise<void>;
152
153
  /**
153
- * Get parent node IDs (nodes that have edges pointing TO this node).
154
- * @param edgeType - Optional filter by edge type
154
+ * Remove a link between two objects.
155
+ * @param linkType - Optional: if provided, only removes that type; otherwise removes all links between the objects
156
+ * @returns true if any links were removed
155
157
  */
156
- getParents(nodeId: string, edgeType?: string): string[];
158
+ unlink(sourceId: string, targetId: string, linkType?: string): Promise<boolean>;
157
159
  /**
158
- * Get child node IDs (nodes that this node has edges pointing TO).
159
- * @param edgeType - Optional filter by edge type
160
+ * Get parent object IDs (objects that have links pointing TO this object).
161
+ * @param linkType - Optional filter by link type
160
162
  */
161
- getChildren(nodeId: string, edgeType?: string): string[];
163
+ getParents(objectId: string, linkType?: string): string[];
162
164
  /**
163
- * Get an edge by ID.
165
+ * Get child object IDs (objects that this object has links pointing TO).
166
+ * Filters out orphan targets (targets that don't exist).
167
+ * @param linkType - Optional filter by link type
164
168
  */
165
- getEdge(edgeId: string): RoolEdge | undefined;
169
+ getChildren(objectId: string, linkType?: string): string[];
166
170
  /**
167
- * Get all edge IDs.
171
+ * Get all child object IDs including orphans (targets that may not exist).
172
+ * @param linkType - Optional filter by link type
168
173
  */
169
- getEdgeIds(): string[];
174
+ getChildrenIncludingOrphans(objectId: string, linkType?: string): string[];
170
175
  /**
171
- * Set a metadata value.
172
- * Metadata is stored in _meta and hidden from AI operations.
176
+ * Set a space-level metadata value.
177
+ * Metadata is stored in meta and hidden from AI operations.
173
178
  */
174
179
  setMetadata(key: string, value: unknown): void;
175
180
  /**
176
- * Get a metadata value.
181
+ * Get a space-level metadata value.
177
182
  */
178
183
  getMetadata(key: string): unknown;
179
184
  /**
180
- * Get all metadata.
185
+ * Get all space-level metadata.
181
186
  */
182
187
  getAllMetadata(): Record<string, unknown>;
183
188
  /**
184
- * Send a prompt to the AI agent for graph manipulation.
189
+ * Send a prompt to the AI agent for space manipulation.
185
190
  */
186
191
  prompt(prompt: string, options?: PromptOptions): Promise<string | null>;
187
192
  /**
188
- * List users with access to this graph.
193
+ * List users with access to this space.
189
194
  */
190
- listUsers(): Promise<RoolGraphUser[]>;
195
+ listUsers(): Promise<RoolUser[]>;
191
196
  /**
192
- * Add a user to this graph with specified role.
197
+ * Add a user to this space with specified role.
193
198
  */
194
- addUser(userId: string, role: RoolGraphRole): Promise<void>;
199
+ addUser(userId: string, role: RoolUserRole): Promise<void>;
195
200
  /**
196
- * Remove a user from this graph.
201
+ * Remove a user from this space.
197
202
  */
198
203
  removeUser(userId: string): Promise<void>;
199
204
  /**
200
- * List all media files for this graph.
205
+ * List all media files for this space.
201
206
  */
202
207
  listMedia(): Promise<MediaItem[]>;
203
208
  /**
204
- * Upload a file to this graph.
209
+ * Upload a file to this space.
205
210
  */
206
211
  uploadMedia(file: File | Blob | {
207
212
  data: string;
@@ -220,10 +225,10 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
220
225
  */
221
226
  deleteMedia(uuid: string): Promise<void>;
222
227
  /**
223
- * Get the full graph data.
228
+ * Get the full space data.
224
229
  * Use sparingly - prefer specific operations.
225
230
  */
226
- getData(): RoolGraphData;
231
+ getData(): RoolSpaceData;
227
232
  /**
228
233
  * Handle a patch event from another client.
229
234
  * @internal
@@ -235,10 +240,10 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
235
240
  */
236
241
  private emitSemanticEventsFromPatch;
237
242
  /**
238
- * Handle a full graph reload from server.
243
+ * Handle a full reload from server.
239
244
  * @internal
240
245
  */
241
- handleRemoteChange(newData: RoolGraphData): void;
246
+ handleRemoteChange(newData: RoolSpaceData): void;
242
247
  /**
243
248
  * Update the name from external source.
244
249
  * @internal
@@ -247,4 +252,4 @@ export declare class RoolGraph extends EventEmitter<GraphEvents> {
247
252
  private resyncFromServer;
248
253
  }
249
254
  export {};
250
- //# sourceMappingURL=graph.d.ts.map
255
+ //# sourceMappingURL=space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../src/space.ts"],"names":[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