rocketride 1.0.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.
Files changed (166) hide show
  1. package/README.md +476 -0
  2. package/dist/cjs/client.js +1745 -0
  3. package/dist/cjs/client.js.map +1 -0
  4. package/dist/cjs/constants.js +48 -0
  5. package/dist/cjs/constants.js.map +1 -0
  6. package/dist/cjs/core/DAPBase.js +328 -0
  7. package/dist/cjs/core/DAPBase.js.map +1 -0
  8. package/dist/cjs/core/DAPClient.js +226 -0
  9. package/dist/cjs/core/DAPClient.js.map +1 -0
  10. package/dist/cjs/core/TransportBase.js +152 -0
  11. package/dist/cjs/core/TransportBase.js.map +1 -0
  12. package/dist/cjs/core/TransportWebSocket.js +646 -0
  13. package/dist/cjs/core/TransportWebSocket.js.map +1 -0
  14. package/dist/cjs/exceptions/index.js +119 -0
  15. package/dist/cjs/exceptions/index.js.map +1 -0
  16. package/dist/cjs/index.js +56 -0
  17. package/dist/cjs/index.js.map +1 -0
  18. package/dist/cjs/package.json +3 -0
  19. package/dist/cjs/schema/Doc.js +79 -0
  20. package/dist/cjs/schema/Doc.js.map +1 -0
  21. package/dist/cjs/schema/DocFilter.js +133 -0
  22. package/dist/cjs/schema/DocFilter.js.map +1 -0
  23. package/dist/cjs/schema/DocGroup.js +230 -0
  24. package/dist/cjs/schema/DocGroup.js.map +1 -0
  25. package/dist/cjs/schema/DocMetadata.js +58 -0
  26. package/dist/cjs/schema/DocMetadata.js.map +1 -0
  27. package/dist/cjs/schema/Question.js +414 -0
  28. package/dist/cjs/schema/Question.js.map +1 -0
  29. package/dist/cjs/schema/index.js +50 -0
  30. package/dist/cjs/schema/index.js.map +1 -0
  31. package/dist/cjs/types/client.js +26 -0
  32. package/dist/cjs/types/client.js.map +1 -0
  33. package/dist/cjs/types/data.js +26 -0
  34. package/dist/cjs/types/data.js.map +1 -0
  35. package/dist/cjs/types/events.js +119 -0
  36. package/dist/cjs/types/events.js.map +1 -0
  37. package/dist/cjs/types/index.js +50 -0
  38. package/dist/cjs/types/index.js.map +1 -0
  39. package/dist/cjs/types/pipeline.js +26 -0
  40. package/dist/cjs/types/pipeline.js.map +1 -0
  41. package/dist/cjs/types/task.js +115 -0
  42. package/dist/cjs/types/task.js.map +1 -0
  43. package/dist/cli/cli/rocketride.js +1399 -0
  44. package/dist/cli/cli/rocketride.js.map +1 -0
  45. package/dist/cli/client/client.js +1745 -0
  46. package/dist/cli/client/client.js.map +1 -0
  47. package/dist/cli/client/constants.js +48 -0
  48. package/dist/cli/client/constants.js.map +1 -0
  49. package/dist/cli/client/core/DAPBase.js +328 -0
  50. package/dist/cli/client/core/DAPBase.js.map +1 -0
  51. package/dist/cli/client/core/DAPClient.js +226 -0
  52. package/dist/cli/client/core/DAPClient.js.map +1 -0
  53. package/dist/cli/client/core/TransportBase.js +152 -0
  54. package/dist/cli/client/core/TransportBase.js.map +1 -0
  55. package/dist/cli/client/core/TransportWebSocket.js +646 -0
  56. package/dist/cli/client/core/TransportWebSocket.js.map +1 -0
  57. package/dist/cli/client/exceptions/index.js +119 -0
  58. package/dist/cli/client/exceptions/index.js.map +1 -0
  59. package/dist/cli/client/index.js +56 -0
  60. package/dist/cli/client/index.js.map +1 -0
  61. package/dist/cli/client/schema/Doc.js +79 -0
  62. package/dist/cli/client/schema/Doc.js.map +1 -0
  63. package/dist/cli/client/schema/DocFilter.js +133 -0
  64. package/dist/cli/client/schema/DocFilter.js.map +1 -0
  65. package/dist/cli/client/schema/DocGroup.js +230 -0
  66. package/dist/cli/client/schema/DocGroup.js.map +1 -0
  67. package/dist/cli/client/schema/DocMetadata.js +58 -0
  68. package/dist/cli/client/schema/DocMetadata.js.map +1 -0
  69. package/dist/cli/client/schema/Question.js +414 -0
  70. package/dist/cli/client/schema/Question.js.map +1 -0
  71. package/dist/cli/client/schema/index.js +50 -0
  72. package/dist/cli/client/schema/index.js.map +1 -0
  73. package/dist/cli/client/types/client.js +26 -0
  74. package/dist/cli/client/types/client.js.map +1 -0
  75. package/dist/cli/client/types/data.js +26 -0
  76. package/dist/cli/client/types/data.js.map +1 -0
  77. package/dist/cli/client/types/events.js +119 -0
  78. package/dist/cli/client/types/events.js.map +1 -0
  79. package/dist/cli/client/types/index.js +50 -0
  80. package/dist/cli/client/types/index.js.map +1 -0
  81. package/dist/cli/client/types/pipeline.js +26 -0
  82. package/dist/cli/client/types/pipeline.js.map +1 -0
  83. package/dist/cli/client/types/task.js +115 -0
  84. package/dist/cli/client/types/task.js.map +1 -0
  85. package/dist/esm/client.js +1740 -0
  86. package/dist/esm/client.js.map +1 -0
  87. package/dist/esm/constants.js +45 -0
  88. package/dist/esm/constants.js.map +1 -0
  89. package/dist/esm/core/DAPBase.js +324 -0
  90. package/dist/esm/core/DAPBase.js.map +1 -0
  91. package/dist/esm/core/DAPClient.js +222 -0
  92. package/dist/esm/core/DAPClient.js.map +1 -0
  93. package/dist/esm/core/TransportBase.js +148 -0
  94. package/dist/esm/core/TransportBase.js.map +1 -0
  95. package/dist/esm/core/TransportWebSocket.js +609 -0
  96. package/dist/esm/core/TransportWebSocket.js.map +1 -0
  97. package/dist/esm/exceptions/index.js +109 -0
  98. package/dist/esm/exceptions/index.js.map +1 -0
  99. package/dist/esm/index.js +40 -0
  100. package/dist/esm/index.js.map +1 -0
  101. package/dist/esm/package.json +3 -0
  102. package/dist/esm/schema/Doc.js +75 -0
  103. package/dist/esm/schema/Doc.js.map +1 -0
  104. package/dist/esm/schema/DocFilter.js +129 -0
  105. package/dist/esm/schema/DocFilter.js.map +1 -0
  106. package/dist/esm/schema/DocGroup.js +226 -0
  107. package/dist/esm/schema/DocGroup.js.map +1 -0
  108. package/dist/esm/schema/DocMetadata.js +54 -0
  109. package/dist/esm/schema/DocMetadata.js.map +1 -0
  110. package/dist/esm/schema/Question.js +409 -0
  111. package/dist/esm/schema/Question.js.map +1 -0
  112. package/dist/esm/schema/index.js +34 -0
  113. package/dist/esm/schema/index.js.map +1 -0
  114. package/dist/esm/types/client.js +25 -0
  115. package/dist/esm/types/client.js.map +1 -0
  116. package/dist/esm/types/data.js +25 -0
  117. package/dist/esm/types/data.js.map +1 -0
  118. package/dist/esm/types/events.js +116 -0
  119. package/dist/esm/types/events.js.map +1 -0
  120. package/dist/esm/types/index.js +34 -0
  121. package/dist/esm/types/index.js.map +1 -0
  122. package/dist/esm/types/pipeline.js +25 -0
  123. package/dist/esm/types/pipeline.js.map +1 -0
  124. package/dist/esm/types/task.js +112 -0
  125. package/dist/esm/types/task.js.map +1 -0
  126. package/dist/types/client.d.ts +798 -0
  127. package/dist/types/client.d.ts.map +1 -0
  128. package/dist/types/constants.d.ts +45 -0
  129. package/dist/types/constants.d.ts.map +1 -0
  130. package/dist/types/core/DAPBase.d.ts +152 -0
  131. package/dist/types/core/DAPBase.d.ts.map +1 -0
  132. package/dist/types/core/DAPClient.d.ts +93 -0
  133. package/dist/types/core/DAPClient.d.ts.map +1 -0
  134. package/dist/types/core/TransportBase.d.ts +113 -0
  135. package/dist/types/core/TransportBase.d.ts.map +1 -0
  136. package/dist/types/core/TransportWebSocket.d.ts +100 -0
  137. package/dist/types/core/TransportWebSocket.d.ts.map +1 -0
  138. package/dist/types/exceptions/index.d.ts +87 -0
  139. package/dist/types/exceptions/index.d.ts.map +1 -0
  140. package/dist/types/index.d.ts +36 -0
  141. package/dist/types/index.d.ts.map +1 -0
  142. package/dist/types/schema/Doc.d.ts +69 -0
  143. package/dist/types/schema/Doc.d.ts.map +1 -0
  144. package/dist/types/schema/DocFilter.d.ts +101 -0
  145. package/dist/types/schema/DocFilter.d.ts.map +1 -0
  146. package/dist/types/schema/DocGroup.d.ts +113 -0
  147. package/dist/types/schema/DocGroup.d.ts.map +1 -0
  148. package/dist/types/schema/DocMetadata.d.ts +77 -0
  149. package/dist/types/schema/DocMetadata.d.ts.map +1 -0
  150. package/dist/types/schema/Question.d.ts +163 -0
  151. package/dist/types/schema/Question.d.ts.map +1 -0
  152. package/dist/types/schema/index.d.ts +34 -0
  153. package/dist/types/schema/index.d.ts.map +1 -0
  154. package/dist/types/types/client.d.ts +149 -0
  155. package/dist/types/types/client.d.ts.map +1 -0
  156. package/dist/types/types/data.d.ts +95 -0
  157. package/dist/types/types/data.d.ts.map +1 -0
  158. package/dist/types/types/events.d.ts +246 -0
  159. package/dist/types/types/events.d.ts.map +1 -0
  160. package/dist/types/types/index.d.ts +34 -0
  161. package/dist/types/types/index.d.ts.map +1 -0
  162. package/dist/types/types/pipeline.d.ts +83 -0
  163. package/dist/types/types/pipeline.d.ts.map +1 -0
  164. package/dist/types/types/task.d.ts +314 -0
  165. package/dist/types/types/task.d.ts.map +1 -0
  166. package/package.json +61 -0
@@ -0,0 +1,798 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2026 RocketRide, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { DAPClient } from './core/DAPClient';
25
+ import { DAPMessage, RocketRideClientConfig } from './types';
26
+ import { TASK_STATUS, UPLOAD_RESULT, PIPELINE_RESULT, PipelineConfig } from './types';
27
+ import { Question } from './schema/Question';
28
+ /**
29
+ * Streaming data pipe for sending large datasets to RocketRide pipelines.
30
+ *
31
+ * DataPipe provides a stream-like interface for uploading data to an RocketRide
32
+ * pipeline. It handles the low-level protocol details of opening, writing to,
33
+ * and closing data pipes on the server.
34
+ *
35
+ * Usage pattern:
36
+ * 1. Create pipe using client.pipe()
37
+ * 2. Call open() to establish the pipe
38
+ * 3. Call write() multiple times with data chunks
39
+ * 4. Call close() to finalize and get results
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const pipe = await client.pipe(token, { filename: 'data.json' }, 'application/json');
44
+ * await pipe.open();
45
+ * await pipe.write(new TextEncoder().encode('{"data": "value"}'));
46
+ * const result = await pipe.close();
47
+ * ```
48
+ */
49
+ export declare class DataPipe {
50
+ private _client;
51
+ private _token;
52
+ private _objinfo;
53
+ private _mimeType;
54
+ private _provider?;
55
+ private _pipeId?;
56
+ private _opened;
57
+ private _closed;
58
+ /**
59
+ * Creates a new DataPipe instance.
60
+ *
61
+ * @param client - The RocketRideClient instance managing this pipe
62
+ * @param token - Task token for the pipeline receiving the data
63
+ * @param objinfo - Metadata about the object being sent (e.g., filename, size)
64
+ * @param mimeType - MIME type of the data being sent (default: 'application/octet-stream')
65
+ * @param provider - Optional provider name for the data source
66
+ */
67
+ constructor(client: RocketRideClient, token: string, objinfo?: Record<string, unknown>, mimeType?: string, provider?: string);
68
+ /**
69
+ * Check if the pipe is currently open for writing.
70
+ *
71
+ * @returns true if the pipe has been opened and not yet closed
72
+ */
73
+ get isOpened(): boolean;
74
+ /**
75
+ * Get the unique ID assigned to this pipe by the server.
76
+ *
77
+ * This ID is assigned when the pipe is opened and is used for subsequent
78
+ * write operations. It remains undefined until open() is called successfully.
79
+ *
80
+ * @returns The server-assigned pipe ID, or undefined if not yet opened
81
+ */
82
+ get pipeId(): number | undefined;
83
+ /**
84
+ * Open the pipe for data transmission.
85
+ *
86
+ * Establishes a data pipe on the server for streaming data to the pipeline.
87
+ * Must be called before any write() operations. The server will assign a
88
+ * unique pipe ID that is used for subsequent operations.
89
+ *
90
+ * @returns This DataPipe instance (for method chaining)
91
+ * @throws Error if the pipe is already opened or if the pipeline is not running
92
+ */
93
+ open(): Promise<DataPipe>;
94
+ /**
95
+ * Write data to the pipe.
96
+ *
97
+ * Sends a chunk of data through the pipe to the server pipeline. Can be called
98
+ * multiple times to stream large datasets. The pipe must be opened first.
99
+ *
100
+ * @param buffer - Data to write, must be a Uint8Array
101
+ * @throws Error if the pipe is not opened, buffer is invalid, or write fails
102
+ */
103
+ write(buffer: Uint8Array): Promise<void>;
104
+ /**
105
+ * Close the pipe and get the processing results.
106
+ *
107
+ * Finalizes the data stream and signals the server that no more data will be sent.
108
+ * The server processes any buffered data and returns the final result. After closing,
109
+ * the pipe cannot be reopened or written to again.
110
+ *
111
+ * @returns The processing result from the server, or undefined if already closed
112
+ * @throws Error if closing the pipe fails
113
+ */
114
+ close(): Promise<PIPELINE_RESULT | undefined>;
115
+ }
116
+ /**
117
+ * Main RocketRide client for connecting to RocketRide servers and services.
118
+ *
119
+ * This client provides a comprehensive API for interacting with RocketRide services,
120
+ * including connection management, pipeline execution, data operations, AI chat,
121
+ * event handling, and server connectivity testing.
122
+ *
123
+ * Key features:
124
+ * - Single shared WebSocket connection for all operations
125
+ * - Connection management (connect/disconnect) with optional persistence
126
+ * - Automatic reconnection when persist mode is enabled
127
+ * - Pipeline execution (use, terminate, getTaskStatus)
128
+ * - Data operations (send, sendFiles, pipe)
129
+ * - AI chat functionality (chat)
130
+ * - Event handling (setEvents, event callbacks)
131
+ * - Server connectivity testing (ping)
132
+ * - Full TypeScript type safety
133
+ */
134
+ export declare class RocketRideClient extends DAPClient {
135
+ private _uri;
136
+ private _apikey?;
137
+ private _env;
138
+ private _callerOnEvent?;
139
+ private _callerOnConnected?;
140
+ private _callerOnDisconnected?;
141
+ private _callerOnConnectError?;
142
+ private _dapAttempted;
143
+ private _dapSend?;
144
+ private _nextChatId;
145
+ private _persist;
146
+ private _reconnectTimeout?;
147
+ private _manualDisconnect;
148
+ private _maxRetryTime?;
149
+ private _retryStartTime?;
150
+ private _currentReconnectDelay;
151
+ /** True after onConnected has been invoked; used to only invoke onDisconnected when we had a connection. */
152
+ private _didNotifyConnected;
153
+ /**
154
+ * Creates a new RocketRideClient instance.
155
+ *
156
+ * Configuration priority (highest to lowest):
157
+ * 1. Values passed in config parameter (auth, uri)
158
+ * 2. Values from env parameter (if provided)
159
+ * 3. Values from .env file (Node.js only)
160
+ * 4. Default values
161
+ *
162
+ * @param config - Configuration options for the client
163
+ * @param config.auth - API key for authentication (required)
164
+ * @param config.uri - Server URI (default: CONST_DEFAULT_SERVICE)
165
+ * @param config.env - Environment variables dictionary for configuration and substitution
166
+ * @param config.onEvent - Callback for server events
167
+ * @param config.onConnected - Callback when connection is established
168
+ * @param config.onDisconnected - Callback when connection is lost
169
+ * @param config.persist - Enable automatic reconnection
170
+ * @param config.requestTimeout - Default timeout in ms for individual requests
171
+ * @param config.maxRetryTime - Max total time in ms to keep retrying connections
172
+ * @param config.module - Optional module name for client identification
173
+ *
174
+ * @throws Error if auth is not provided via config, env, or .env file
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * // Using explicit auth and URI
179
+ * const client = new RocketRideClient({
180
+ * auth: 'your-api-key',
181
+ * uri: 'wss://your-server.com',
182
+ * persist: true,
183
+ * onEvent: (event) => console.log('Event:', event)
184
+ * });
185
+ *
186
+ * // Using custom env dictionary
187
+ * const client = new RocketRideClient({
188
+ * env: {
189
+ * ROCKETRIDE_APIKEY: 'your-api-key',
190
+ * ROCKETRIDE_URI: 'wss://your-server.com',
191
+ * ROCKETRIDE_PROJECT_ID: 'my-project'
192
+ * }
193
+ * });
194
+ * ```
195
+ */
196
+ constructor(config?: RocketRideClientConfig);
197
+ /**
198
+ * Update the server URI (internal). Accepts HTTP/HTTPS/WS/WSS; converts to WebSocket and appends /task/service.
199
+ */
200
+ private _setUri;
201
+ /**
202
+ * Update the authentication credential (internal).
203
+ */
204
+ private _setAuth;
205
+ /**
206
+ * Clear any pending reconnection timeout.
207
+ */
208
+ private _clearReconnectTimeout;
209
+ /**
210
+ * Single place for physical connection. Creates transport if needed, then
211
+ * calls DAPClient.connect (transport connect + auth handshake + onConnected).
212
+ */
213
+ private _internalConnect;
214
+ /**
215
+ * Single place for physical disconnect. Closes the transport directly,
216
+ * which triggers onDisconnected via the transport callback.
217
+ */
218
+ private _internalDisconnect;
219
+ /**
220
+ * Try to connect; on auth error notify and stop; on other error notify and
221
+ * reschedule with exponential backoff. Used by persist-mode connect() and
222
+ * by the reconnect timer.
223
+ */
224
+ private _attemptConnection;
225
+ /**
226
+ * Schedule a reconnection attempt with exponential backoff.
227
+ */
228
+ private _scheduleReconnect;
229
+ /**
230
+ * Check if the client is currently connected to the RocketRide server.
231
+ */
232
+ isConnected(): boolean;
233
+ /**
234
+ * Connect to the RocketRide server.
235
+ *
236
+ * Must be called before executing pipelines or other operations.
237
+ * In persist mode, enables automatic reconnection on disconnect and on initial failure
238
+ * (calls onConnectError on each failed attempt and keeps retrying).
239
+ * @param timeout - Optional overall timeout in ms for the connect + auth handshake.
240
+ */
241
+ connect(timeout?: number): Promise<void>;
242
+ /**
243
+ * Disconnect from the RocketRide server and stop automatic reconnection.
244
+ *
245
+ * Should be called when finished with the client to clean up resources.
246
+ */
247
+ disconnect(): Promise<void>;
248
+ /**
249
+ * Update server URI and/or auth at runtime. If currently connected,
250
+ * disconnects and reconnects with the new params. In persist mode,
251
+ * reconnection is scheduled only if we were connected.
252
+ */
253
+ setConnectionParams(options: {
254
+ uri?: string;
255
+ auth?: string;
256
+ }): Promise<void>;
257
+ /**
258
+ * Test connectivity to the RocketRide server.
259
+ *
260
+ * Sends a lightweight ping request to the server to verify it's responding
261
+ * and reachable. This is useful for connectivity testing, health checks,
262
+ * and measuring response times.
263
+ */
264
+ ping(token?: string): Promise<void>;
265
+ /**
266
+ * Substitute environment variables in a string.
267
+ * Replaces ${ROCKETRIDE_*} patterns with values from client's env dictionary.
268
+ * If variable is not found, leaves it unchanged.
269
+ */
270
+ private substituteEnvVars;
271
+ /**
272
+ * Recursively process an object/array to substitute environment variables.
273
+ * Only processes string values, leaving other types unchanged.
274
+ */
275
+ private processEnvSubstitution;
276
+ /**
277
+ * Validate a pipeline configuration.
278
+ *
279
+ * Sends the pipeline to the server for structural validation, checking
280
+ * component compatibility, connection integrity, and the resolved
281
+ * execution chain.
282
+ *
283
+ * Source resolution follows the same logic as {@link use}:
284
+ * 1. Explicit `source` option (if provided)
285
+ * 2. `source` field inside the pipeline config
286
+ * 3. Implied source: the single component whose config.mode is 'Source'
287
+ *
288
+ * @param options.pipeline - Pipeline configuration to validate
289
+ * @param options.source - Optional override for the source component ID
290
+ * @returns Promise resolving to validation result with errors, warnings,
291
+ * resolved component, and execution chain
292
+ * @throws Error if the server returns a validation error
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const result = await client.validate({
297
+ * pipeline: { components: [...], project_id: '123' },
298
+ * source: 'webhook_1'
299
+ * });
300
+ * if (result.errors?.length) {
301
+ * console.log('Validation errors:', result.errors);
302
+ * }
303
+ * ```
304
+ */
305
+ validate(options: {
306
+ pipeline: PipelineConfig | Record<string, unknown>;
307
+ source?: string;
308
+ }): Promise<Record<string, unknown>>;
309
+ /**
310
+ * Start an RocketRide pipeline for processing data.
311
+ *
312
+ * This method loads and executes a pipeline configuration. It automatically performs
313
+ * environment variable substitution on the pipeline config, replacing ${ROCKETRIDE_*}
314
+ * placeholders with values from the .env file.
315
+ *
316
+ * @param options - Pipeline execution options
317
+ * @param options.token - Custom token for the pipeline (auto-generated if not provided)
318
+ * @param options.filepath - Path to JSON file containing pipeline configuration
319
+ * @param options.pipeline - Pipeline configuration object (alternative to filepath)
320
+ * @param options.source - Override pipeline source
321
+ * @param options.threads - Number of threads for execution (default: 1)
322
+ * @param options.useExisting - Use existing pipeline instance
323
+ * @param options.args - Command line arguments to pass to pipeline
324
+ * @param options.ttl - Time-to-live in seconds for idle pipelines (optional, server default if not provided; use 0 for no timeout)
325
+ *
326
+ * @returns Promise resolving to an object containing the task token and other metadata
327
+ * @throws Error if neither pipeline nor filepath is provided
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * // Using pipeline file
332
+ * const result = await client.use({ filepath: './pipeline.json' });
333
+ *
334
+ * // Using pipeline object
335
+ * const result = await client.use({
336
+ * pipeline: { name: 'My Pipeline', components: [...], source: 'local', project_id: '123' }
337
+ * });
338
+ *
339
+ * // With environment variable substitution
340
+ * // Pipeline config: { "endpoint": "${ROCKETRIDE_URI}/api" }
341
+ * // Will be replaced with actual ROCKETRIDE_URI value from .env
342
+ * ```
343
+ */
344
+ use(options?: {
345
+ token?: string;
346
+ filepath?: string;
347
+ pipeline?: PipelineConfig;
348
+ source?: string;
349
+ threads?: number;
350
+ useExisting?: boolean;
351
+ args?: string[];
352
+ ttl?: number;
353
+ }): Promise<Record<string, unknown> & {
354
+ token: string;
355
+ }>;
356
+ /**
357
+ * Terminate a running pipeline.
358
+ */
359
+ terminate(token: string): Promise<void>;
360
+ /**
361
+ * Get the current status of a running pipeline.
362
+ */
363
+ getTaskStatus(token: string): Promise<TASK_STATUS>;
364
+ /** Return objinfo with size set; never 0 (parse filter skips "empty"). */
365
+ private _objinfoWithSize;
366
+ /**
367
+ * Create a data pipe for streaming operations.
368
+ */
369
+ pipe(token: string, objinfo?: Record<string, unknown>, mimeType?: string, provider?: string): Promise<DataPipe>;
370
+ /**
371
+ * Send data to a running pipeline.
372
+ */
373
+ send(token: string, data: string | Uint8Array, objinfo?: Record<string, unknown>, mimetype?: string): Promise<PIPELINE_RESULT | undefined>;
374
+ /**
375
+ * Upload multiple files to a pipeline with progress tracking and parallel execution.
376
+ *
377
+ * This method efficiently uploads files in parallel with configurable concurrency control.
378
+ * Each file is streamed through a data pipe, and progress events are emitted through the
379
+ * event system for all subscribers. The order of results matches the input file order.
380
+ *
381
+ * Progress events are sent through the event system as 'apaevt_status_upload' events
382
+ * (matching Python client behavior) rather than through a callback parameter.
383
+ *
384
+ * @param files - Array of file objects with optional metadata and MIME types
385
+ * @param token - Pipeline task token to receive the uploads
386
+ * @param maxConcurrent - Maximum number of concurrent uploads (default: 5)
387
+ *
388
+ * @returns Promise resolving to array of UPLOAD_RESULT objects in the same order as input
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * // Subscribe to upload events
393
+ * client.on('apaevt_status_upload', (event) => {
394
+ * console.log(`${event.body.filepath}: ${event.body.bytes_sent}/${event.body.file_size}`);
395
+ * });
396
+ *
397
+ * // Upload files
398
+ * const results = await client.sendFiles(
399
+ * [
400
+ * { file: fileObject1 },
401
+ * { file: fileObject2, mimetype: 'application/json' },
402
+ * { file: fileObject3, objinfo: { custom: 'metadata' } }
403
+ * ],
404
+ * 'task-token',
405
+ * 10 // Upload max 10 files concurrently
406
+ * );
407
+ * ```
408
+ */
409
+ sendFiles(files: Array<{
410
+ file: File;
411
+ objinfo?: Record<string, unknown>;
412
+ mimetype?: string;
413
+ }>, token: string): Promise<UPLOAD_RESULT[]>;
414
+ /**
415
+ * Ask a question to RocketRide's AI and get an intelligent response.
416
+ */
417
+ chat(options: {
418
+ token: string;
419
+ question: Question;
420
+ }): Promise<PIPELINE_RESULT>;
421
+ /**
422
+ * Send events to debugging interface if available (for development).
423
+ */
424
+ private _sendVSCodeEvent;
425
+ /**
426
+ * Handle incoming events from the RocketRide server.
427
+ */
428
+ onEvent(message: DAPMessage): Promise<void>;
429
+ /**
430
+ * Handle connection attempt failure.
431
+ * Calls the user callback and chains to parent.
432
+ */
433
+ onConnectError(error: Error): Promise<void>;
434
+ /**
435
+ * Handle connected events from the RocketRide server.
436
+ */
437
+ onConnected(connectionInfo: string): Promise<void>;
438
+ /**
439
+ * Handle disconnected events from the RocketRide server.
440
+ * Only invokes the user's onDisconnected if onConnected had previously been called
441
+ * (so "disconnect without ever connecting" does not fire the user callback).
442
+ */
443
+ onDisconnected(reason: string, hasError: boolean): Promise<void>;
444
+ /**
445
+ * Subscribe to specific types of events from the server.
446
+ */
447
+ setEvents(token: string, eventTypes: string[]): Promise<void>;
448
+ /**
449
+ * Save or update a project pipeline.
450
+ *
451
+ * Stores a project pipeline configuration on the server. If the project
452
+ * already exists, it will be updated. Use expectedVersion to ensure
453
+ * you're updating the version you expect (prevents conflicts).
454
+ *
455
+ * @param options - Save project options
456
+ * @param options.projectId - Unique identifier for the project
457
+ * @param options.pipeline - Pipeline configuration object
458
+ * @param options.expectedVersion - Expected current version for atomic updates (optional)
459
+ * @returns Promise resolving to save result with success status, projectId, and new version
460
+ * @throws Error if save fails due to version mismatch, storage error, or invalid input
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * // Save a new project
465
+ * const result = await client.saveProject({
466
+ * projectId: 'proj-123',
467
+ * pipeline: {
468
+ * name: 'Data Processor',
469
+ * source: 'source_1',
470
+ * components: [...]
471
+ * }
472
+ * });
473
+ * console.log(`Saved version: ${result.version}`);
474
+ *
475
+ * // Update existing project with version check
476
+ * const existing = await client.getProject({ projectId: 'proj-123' });
477
+ * existing.name = 'Updated Name';
478
+ * const updated = await client.saveProject({
479
+ * projectId: 'proj-123',
480
+ * pipeline: existing,
481
+ * expectedVersion: existing.version
482
+ * });
483
+ * ```
484
+ */
485
+ saveProject(options: {
486
+ projectId: string;
487
+ pipeline: Record<string, any>;
488
+ expectedVersion?: string;
489
+ }): Promise<{
490
+ success: boolean;
491
+ project_id: string;
492
+ version: string;
493
+ }>;
494
+ /**
495
+ * Retrieve a project by its ID.
496
+ *
497
+ * Fetches the complete pipeline configuration and current version for
498
+ * the specified project. Use this before updating to get the current
499
+ * version for atomic updates.
500
+ *
501
+ * @param options - Get project options
502
+ * @param options.projectId - Unique identifier of the project to retrieve
503
+ * @returns Promise resolving to project data with success status, pipeline, and version
504
+ * @throws Error if project doesn't exist or retrieval fails
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * // Get a project
509
+ * try {
510
+ * const project = await client.getProject({ projectId: 'proj-123' });
511
+ * console.log(`Project: ${project.name}`);
512
+ * console.log(`Version: ${project.version}`);
513
+ * } catch (error) {
514
+ * if (error.message.includes('NOT_FOUND')) {
515
+ * console.log("Project doesn't exist");
516
+ * }
517
+ * }
518
+ *
519
+ * // Before updating - get current version
520
+ * const project = await client.getProject({ projectId: 'proj-123' });
521
+ * project.name = 'Updated';
522
+ * await client.saveProject({
523
+ * projectId: 'proj-123',
524
+ * pipeline: project,
525
+ * expectedVersion: project.version
526
+ * });
527
+ * ```
528
+ */
529
+ getProject(options: {
530
+ projectId: string;
531
+ }): Promise<{
532
+ success: boolean;
533
+ pipeline: Record<string, any>;
534
+ version: string;
535
+ }>;
536
+ /**
537
+ * Delete a project by its ID.
538
+ *
539
+ * Permanently removes a project from storage. Optionally verify the
540
+ * version before deletion to ensure you're deleting the version you
541
+ * expect (prevents accidental deletion of modified projects).
542
+ *
543
+ * @param options - Delete project options
544
+ * @param options.projectId - Unique identifier of the project to delete
545
+ * @param options.expectedVersion - Expected current version for atomic deletion (required)
546
+ * @returns Promise resolving to deletion result with success status and message
547
+ * @throws Error if project doesn't exist, version mismatch, or deletion fails
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * // Safe deletion with version check
552
+ * const project = await client.getProject({ projectId: 'proj-123' });
553
+ * try {
554
+ * const result = await client.deleteProject({
555
+ * projectId: 'proj-123',
556
+ * expectedVersion: project.version
557
+ * });
558
+ * console.log('Project deleted successfully');
559
+ * } catch (error) {
560
+ * if (error.message.includes('CONFLICT')) {
561
+ * console.log('Project was modified, deletion cancelled');
562
+ * }
563
+ * }
564
+ * ```
565
+ */
566
+ deleteProject(options: {
567
+ projectId: string;
568
+ expectedVersion?: string;
569
+ }): Promise<{
570
+ success: boolean;
571
+ message: string;
572
+ }>;
573
+ /**
574
+ * List all projects for the current user.
575
+ *
576
+ * Retrieves a summary of all projects stored for the authenticated user.
577
+ * Each project summary includes the ID, name, list of data sources, and total component count.
578
+ *
579
+ * @returns Promise resolving to list result with success status, projects array, and count
580
+ * @throws Error if retrieval fails
581
+ *
582
+ * @example
583
+ * ```typescript
584
+ * // List all projects
585
+ * const result = await client.getAllProjects();
586
+ * console.log(`Found ${result.count} projects:`);
587
+ * for (const project of result.projects) {
588
+ * console.log(`- ${project.id}: ${project.name} (${project.totalComponents} components)`);
589
+ * for (const source of project.sources) {
590
+ * console.log(` * ${source.name} (${source.provider})`);
591
+ * }
592
+ * }
593
+ *
594
+ * // Find specific project
595
+ * const result = await client.getAllProjects();
596
+ * const myProject = result.projects.find(p => p.id === 'proj-123');
597
+ * ```
598
+ */
599
+ getAllProjects(): Promise<{
600
+ success: boolean;
601
+ projects: Array<{
602
+ id: string;
603
+ name: string;
604
+ sources: Array<{
605
+ id: string;
606
+ provider: string;
607
+ name: string;
608
+ }>;
609
+ totalComponents: number;
610
+ }>;
611
+ count: number;
612
+ }>;
613
+ /**
614
+ * Save or update a template pipeline.
615
+ *
616
+ * Stores a template pipeline configuration on the server. Templates are system-wide
617
+ * and accessible to all users. If the template already exists, it will be updated.
618
+ * Use expectedVersion to ensure you're updating the version you expect.
619
+ *
620
+ * @param options - Save template options
621
+ * @param options.templateId - Unique identifier for the template
622
+ * @param options.pipeline - Pipeline configuration object
623
+ * @param options.expectedVersion - Expected current version for atomic updates (optional)
624
+ * @returns Promise resolving to save result with success status, templateId, and new version
625
+ * @throws Error if save fails due to version mismatch, storage error, or invalid input
626
+ */
627
+ saveTemplate(options: {
628
+ templateId: string;
629
+ pipeline: Record<string, any>;
630
+ expectedVersion?: string;
631
+ }): Promise<{
632
+ success: boolean;
633
+ template_id: string;
634
+ version: string;
635
+ }>;
636
+ /**
637
+ * Retrieve a template by its ID.
638
+ */
639
+ getTemplate(options: {
640
+ templateId: string;
641
+ }): Promise<{
642
+ success: boolean;
643
+ pipeline: Record<string, any>;
644
+ version: string;
645
+ }>;
646
+ /**
647
+ * Delete a template by its ID.
648
+ */
649
+ deleteTemplate(options: {
650
+ templateId: string;
651
+ expectedVersion?: string;
652
+ }): Promise<{
653
+ success: boolean;
654
+ message: string;
655
+ }>;
656
+ /**
657
+ * List all templates.
658
+ */
659
+ getAllTemplates(): Promise<{
660
+ success: boolean;
661
+ templates: Array<{
662
+ id: string;
663
+ name: string;
664
+ sources: Array<{
665
+ id: string;
666
+ provider: string;
667
+ name: string;
668
+ }>;
669
+ totalComponents: number;
670
+ }>;
671
+ count: number;
672
+ }>;
673
+ /**
674
+ * Save a log file for a source run.
675
+ */
676
+ saveLog(options: {
677
+ projectId: string;
678
+ source: string;
679
+ contents: Record<string, any>;
680
+ }): Promise<{
681
+ success: boolean;
682
+ filename: string;
683
+ }>;
684
+ /**
685
+ * Get a log file by source name and start time.
686
+ */
687
+ getLog(options: {
688
+ projectId: string;
689
+ source: string;
690
+ startTime: number;
691
+ }): Promise<{
692
+ success: boolean;
693
+ contents: Record<string, any>;
694
+ }>;
695
+ /**
696
+ * List log files for a project.
697
+ */
698
+ listLogs(options: {
699
+ projectId: string;
700
+ source?: string;
701
+ page?: number;
702
+ }): Promise<{
703
+ success: boolean;
704
+ logs: string[];
705
+ count: number;
706
+ total_count: number;
707
+ page: number;
708
+ total_pages: number;
709
+ }>;
710
+ /**
711
+ * Send an arbitrary DAP command with command name, arguments, and optional token.
712
+ *
713
+ * This is a convenience method for callers that don't want to construct
714
+ * full DAPMessage objects. It builds the request internally and delegates
715
+ * to the underlying request() method.
716
+ *
717
+ * @param command - The DAP command name (e.g., 'rrext_services', 'rrext_monitor')
718
+ * @param args - Optional arguments for the command
719
+ * @param token - Optional task/session token
720
+ * @param timeout - Optional per-request timeout in ms
721
+ * @returns The response DAPMessage from the server
722
+ */
723
+ dapRequest(command: string, args?: Record<string, unknown>, token?: string, timeout?: number): Promise<DAPMessage>;
724
+ /**
725
+ * Async disposal support for 'await using' pattern.
726
+ * Equivalent to Python's __aexit__
727
+ */
728
+ [Symbol.asyncDispose](): Promise<void>;
729
+ /**
730
+ * Static factory method for automatic connection management.
731
+ * Equivalent to Python's async with pattern
732
+ */
733
+ static withConnection<T>(config: RocketRideClientConfig, callback: (client: RocketRideClient) => Promise<T>): Promise<T>;
734
+ /**
735
+ * Retrieve all available service definitions from the server.
736
+ *
737
+ * Returns a dictionary containing all service definitions available on
738
+ * the connected RocketRide server. Each service definition includes schemas,
739
+ * UI schemas, and configuration metadata.
740
+ *
741
+ * @returns Promise resolving to object mapping service names to their definitions
742
+ * @throws Error if the request fails or server returns an error
743
+ *
744
+ * @example
745
+ * ```typescript
746
+ * // Get all available services
747
+ * const services = await client.getServices();
748
+ *
749
+ * // List available service names
750
+ * for (const name of Object.keys(services)) {
751
+ * console.log(`Available service: ${name}`);
752
+ * }
753
+ *
754
+ * // Access a specific service's schema
755
+ * if (services['ocr']) {
756
+ * console.log('OCR schema:', services['ocr'].schema);
757
+ * }
758
+ * ```
759
+ */
760
+ getServices(): Promise<Record<string, unknown>>;
761
+ /**
762
+ * Retrieve a specific service definition from the server.
763
+ *
764
+ * Returns the definition for a specific service (connector) by name.
765
+ * The definition includes schemas, UI schemas, and configuration metadata.
766
+ *
767
+ * @param service - Name of the service to retrieve (e.g., 'ocr', 'embed', 'chat')
768
+ * @returns Promise resolving to service definition or undefined if not found
769
+ * @throws Error if the request fails or server returns an error
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * // Get OCR service definition
774
+ * const ocr = await client.getService('ocr');
775
+ * if (ocr) {
776
+ * console.log('OCR schema:', ocr.schema);
777
+ * console.log('OCR UI schema:', ocr.uiSchema);
778
+ * } else {
779
+ * console.log('OCR service not available');
780
+ * }
781
+ * ```
782
+ */
783
+ getService(service: string): Promise<Record<string, unknown> | undefined>;
784
+ /**
785
+ * Get connection information (TypeScript-specific convenience)
786
+ */
787
+ getConnectionInfo(): {
788
+ connected: boolean;
789
+ transport: string;
790
+ uri: string;
791
+ };
792
+ /**
793
+ * Get API key (for debugging/validation)
794
+ */
795
+ getApiKey(): string | undefined;
796
+ }
797
+ export { RocketRideClient as default };
798
+ //# sourceMappingURL=client.d.ts.map