colonies-ts 0.1.2 → 0.1.3

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 CHANGED
@@ -275,6 +275,7 @@ new ColoniesClient({
275
275
  | `getProcesses(colonyName, count, state)` | List processes by state |
276
276
  | `closeProcess(processId, output)` | Close a process successfully |
277
277
  | `failProcess(processId, errors)` | Close a process with failure |
278
+ | `cancelProcess(processId)` | Cancel a running process |
278
279
  | `removeProcess(processId)` | Remove a process |
279
280
  | `removeAllProcesses(colonyName, state)` | Remove all processes |
280
281
 
@@ -286,6 +287,7 @@ new ColoniesClient({
286
287
  | `getProcessGraph(graphId)` | Get workflow details |
287
288
  | `getProcessGraphs(colonyName, count, state?)` | List workflows |
288
289
  | `getProcessesForWorkflow(graphId, colonyName, count?)` | Get processes for a workflow |
290
+ | `cancelProcessGraph(graphId)` | Cancel a running workflow |
289
291
  | `removeProcessGraph(graphId)` | Remove a workflow |
290
292
  | `removeAllProcessGraphs(colonyName, state?)` | Remove all workflows |
291
293
 
package/dist/index.d.mts CHANGED
@@ -79,6 +79,147 @@ declare enum ProcessState {
79
79
  SUCCESS = 2,
80
80
  FAILED = 3
81
81
  }
82
+ interface Colony {
83
+ colonyid: string;
84
+ name: string;
85
+ }
86
+ interface User {
87
+ colonyname: string;
88
+ userid: string;
89
+ name: string;
90
+ email: string;
91
+ phone: string;
92
+ }
93
+ interface Executor {
94
+ executorid: string;
95
+ executortype: string;
96
+ executorname: string;
97
+ colonyname: string;
98
+ approved?: boolean;
99
+ }
100
+ interface Process {
101
+ processid: string;
102
+ processgraphid?: string;
103
+ state: ProcessState;
104
+ spec: FunctionSpec;
105
+ assignedexecutorname?: string;
106
+ assignedexecutortype?: string;
107
+ waitingtime?: number;
108
+ exectime?: number;
109
+ out?: string[];
110
+ errors?: string[];
111
+ submissiontime?: string;
112
+ starttime?: string;
113
+ endtime?: string;
114
+ }
115
+ interface WorkflowSpec {
116
+ colonyname: string;
117
+ functionspecs: FunctionSpec[];
118
+ }
119
+ interface ProcessGraph {
120
+ processgraphid: string;
121
+ state: ProcessState;
122
+ colonyname?: string;
123
+ roots?: string[];
124
+ }
125
+ interface FunctionArg {
126
+ name: string;
127
+ type: string;
128
+ description?: string;
129
+ required?: boolean;
130
+ enum?: string[];
131
+ }
132
+ interface ColonyFunction {
133
+ funcname: string;
134
+ executorname: string;
135
+ executortype: string;
136
+ colonyname: string;
137
+ description?: string;
138
+ locationname?: string;
139
+ args?: FunctionArg[];
140
+ }
141
+ interface ColonyFile {
142
+ fileid?: string;
143
+ colonyname: string;
144
+ label: string;
145
+ name: string;
146
+ size: number;
147
+ checksum: string;
148
+ checksumalg: string;
149
+ ref: {
150
+ protocol: string;
151
+ s3object: {
152
+ server: string;
153
+ port: number;
154
+ tls: boolean;
155
+ accesskey: string;
156
+ secretkey: string;
157
+ region: string;
158
+ bucket: string;
159
+ object: string;
160
+ };
161
+ };
162
+ }
163
+ interface Attribute {
164
+ attributeid?: string;
165
+ targetid: string;
166
+ targetcolonyname: string;
167
+ targetprocessgraphid: string;
168
+ attributetype: number;
169
+ key: string;
170
+ value: string;
171
+ }
172
+ interface Cron {
173
+ cronid?: string;
174
+ colonyname: string;
175
+ name: string;
176
+ cron: string;
177
+ workflowspec?: WorkflowSpec;
178
+ nextrun?: string;
179
+ lastrun?: string;
180
+ checkin?: string;
181
+ }
182
+ interface Generator {
183
+ generatorid?: string;
184
+ colonyname: string;
185
+ name: string;
186
+ workflowspec?: WorkflowSpec;
187
+ trigger?: number;
188
+ timeout?: number;
189
+ lastrun?: string;
190
+ }
191
+ interface BlueprintMetadata {
192
+ name: string;
193
+ colonyname: string;
194
+ [key: string]: unknown;
195
+ }
196
+ interface BlueprintHandler {
197
+ executortype: string;
198
+ }
199
+ interface BlueprintDefinition {
200
+ kind: string;
201
+ metadata: BlueprintMetadata;
202
+ spec?: Record<string, unknown>;
203
+ }
204
+ interface Blueprint {
205
+ blueprintid?: string;
206
+ kind: string;
207
+ metadata: BlueprintMetadata;
208
+ handler?: BlueprintHandler;
209
+ spec: Record<string, unknown>;
210
+ status?: Record<string, unknown>;
211
+ }
212
+ interface ChannelEntry {
213
+ sequence: number;
214
+ inreplyto: number;
215
+ payload: string;
216
+ }
217
+ interface Log {
218
+ processid?: string;
219
+ executorname?: string;
220
+ message: string;
221
+ timestamp?: string;
222
+ }
82
223
  declare class ColoniesClient {
83
224
  private host;
84
225
  private port;
@@ -90,86 +231,76 @@ declare class ColoniesClient {
90
231
  private getBaseUrl;
91
232
  private createRPCMsg;
92
233
  private sendRPC;
93
- getColonies(): Promise<any>;
234
+ getColonies(): Promise<Colony[]>;
94
235
  getStatistics(): Promise<any>;
95
236
  /**
96
237
  * Add a new colony (requires server private key)
97
238
  * @param colony - Colony object with colonyid and name
98
239
  */
99
- addColony(colony: {
100
- colonyid: string;
101
- name: string;
102
- }): Promise<any>;
240
+ addColony(colony: Colony): Promise<Colony>;
103
241
  /**
104
242
  * Remove a colony (requires server private key)
105
243
  * @param colonyName - Name of the colony to remove
106
244
  */
107
- removeColony(colonyName: string): Promise<any>;
108
- getExecutors(colonyName: string): Promise<any>;
109
- getExecutor(colonyName: string, executorName: string): Promise<any>;
110
- addExecutor(executor: {
111
- executorid: string;
112
- executortype: string;
113
- executorname: string;
114
- colonyname: string;
115
- }): Promise<any>;
116
- approveExecutor(colonyName: string, executorName: string): Promise<any>;
117
- removeExecutor(colonyName: string, executorName: string): Promise<any>;
118
- submitFunctionSpec(spec: FunctionSpec): Promise<any>;
119
- getProcess(processId: string): Promise<any>;
120
- getProcesses(colonyName: string, count: number, state: ProcessState): Promise<any>;
121
- removeProcess(processId: string): Promise<any>;
122
- removeAllProcesses(colonyName: string, state?: number): Promise<any>;
123
- assign(colonyName: string, timeout: number, executorPrvKey: string): Promise<any>;
124
- closeProcess(processId: string, output: string[]): Promise<any>;
125
- failProcess(processId: string, errors: string[]): Promise<any>;
126
- submitWorkflowSpec(workflowSpec: {
127
- colonyname: string;
128
- functionspecs: FunctionSpec[];
129
- }): Promise<any>;
130
- getProcessGraph(processGraphId: string): Promise<any>;
131
- getProcessGraphs(colonyName: string, count: number, state?: ProcessState): Promise<any>;
132
- removeProcessGraph(processGraphId: string): Promise<any>;
133
- getProcessesForWorkflow(processGraphId: string, colonyName: string, count?: number): Promise<any>;
134
- removeAllProcessGraphs(colonyName: string, state?: ProcessState): Promise<any>;
135
- addLog(processId: string, message: string, executorPrvKey: string): Promise<any>;
136
- getLogs(colonyName: string, processId: string, executorName: string, count?: number, since?: number): Promise<any>;
137
- getFunctions(executorName: string, colonyName: string): Promise<any>;
138
- getCrons(colonyName: string, count?: number): Promise<any>;
139
- getCron(cronId: string): Promise<any>;
140
- addCron(cronSpec: any): Promise<any>;
141
- removeCron(cronId: string): Promise<any>;
142
- runCron(cronId: string): Promise<any>;
143
- getGenerators(colonyName: string, count?: number): Promise<any>;
144
- getGenerator(generatorId: string): Promise<any>;
145
- addGenerator(generatorSpec: any): Promise<any>;
146
- getUsers(colonyName: string): Promise<any>;
147
- addUser(user: {
148
- colonyname: string;
149
- userid: string;
150
- name: string;
151
- email: string;
152
- phone: string;
153
- }): Promise<any>;
154
- removeUser(colonyName: string, name: string): Promise<any>;
155
- getFileLabels(colonyName: string, name?: string, exact?: boolean): Promise<any>;
156
- getFiles(colonyName: string, label: string): Promise<any>;
245
+ removeColony(colonyName: string): Promise<void>;
246
+ getExecutors(colonyName: string): Promise<Executor[]>;
247
+ getExecutor(colonyName: string, executorName: string): Promise<Executor>;
248
+ addExecutor(executor: Executor): Promise<Executor>;
249
+ approveExecutor(colonyName: string, executorName: string): Promise<Executor>;
250
+ removeExecutor(colonyName: string, executorName: string): Promise<void>;
251
+ submitFunctionSpec(spec: FunctionSpec): Promise<Process>;
252
+ getProcess(processId: string): Promise<Process>;
253
+ getProcesses(colonyName: string, count: number, state: ProcessState): Promise<Process[]>;
254
+ removeProcess(processId: string): Promise<void>;
255
+ removeAllProcesses(colonyName: string, state?: number): Promise<void>;
256
+ assign(colonyName: string, timeout: number, executorPrvKey: string): Promise<Process>;
257
+ closeProcess(processId: string, output: string[]): Promise<void>;
258
+ failProcess(processId: string, errors: string[]): Promise<void>;
259
+ cancelProcess(processId: string): Promise<void>;
260
+ submitWorkflowSpec(workflowSpec: WorkflowSpec): Promise<ProcessGraph>;
261
+ getProcessGraph(processGraphId: string): Promise<ProcessGraph>;
262
+ getProcessGraphs(colonyName: string, count: number, state?: ProcessState): Promise<ProcessGraph[]>;
263
+ removeProcessGraph(processGraphId: string): Promise<void>;
264
+ getProcessesForWorkflow(processGraphId: string, colonyName: string, count?: number): Promise<Process[]>;
265
+ cancelProcessGraph(processGraphId: string): Promise<void>;
266
+ removeAllProcessGraphs(colonyName: string, state?: ProcessState): Promise<void>;
267
+ addLog(processId: string, message: string, executorPrvKey: string): Promise<void>;
268
+ getLogs(colonyName: string, processId: string, executorName: string, count?: number, since?: number): Promise<Log[]>;
269
+ addFunction(func: ColonyFunction): Promise<ColonyFunction>;
270
+ getFunctions(executorName: string, colonyName: string): Promise<ColonyFunction[]>;
271
+ getCrons(colonyName: string, count?: number): Promise<Cron[]>;
272
+ getCron(cronId: string): Promise<Cron>;
273
+ addCron(cronSpec: Cron): Promise<Cron>;
274
+ removeCron(cronId: string): Promise<void>;
275
+ runCron(cronId: string): Promise<void>;
276
+ getGenerators(colonyName: string, count?: number): Promise<Generator[]>;
277
+ getGenerator(generatorId: string): Promise<Generator>;
278
+ addGenerator(generatorSpec: Generator): Promise<Generator>;
279
+ getUsers(colonyName: string): Promise<User[]>;
280
+ addUser(user: User): Promise<User>;
281
+ removeUser(colonyName: string, name: string): Promise<void>;
282
+ getFileLabels(colonyName: string, name?: string, exact?: boolean): Promise<string[]>;
283
+ getFiles(colonyName: string, label: string): Promise<ColonyFile[]>;
157
284
  getFile(colonyName: string, options: {
158
285
  fileId: string;
159
286
  } | {
160
287
  name: string;
161
288
  label: string;
162
289
  latest?: boolean;
163
- }): Promise<any>;
164
- addAttribute(attribute: {
165
- targetid: string;
166
- targetcolonyname: string;
167
- targetprocessgraphid: string;
168
- attributetype: number;
169
- key: string;
170
- value: string;
171
- }): Promise<any>;
172
- getAttribute(attributeId: string): Promise<any>;
290
+ }): Promise<ColonyFile>;
291
+ /**
292
+ * Register a file in ColonyFS
293
+ * @param file - File metadata including colony, label, name, size, checksum, and S3 reference
294
+ */
295
+ addFile(file: ColonyFile): Promise<ColonyFile>;
296
+ /**
297
+ * Remove a file from ColonyFS
298
+ * @param colonyName - Name of the colony
299
+ * @param fileId - ID of the file to remove
300
+ */
301
+ removeFile(colonyName: string, fileId: string): Promise<void>;
302
+ addAttribute(attribute: Attribute): Promise<Attribute>;
303
+ getAttribute(attributeId: string): Promise<Attribute>;
173
304
  /**
174
305
  * Append a message to a process channel
175
306
  * @param processId - ID of the process
@@ -178,7 +309,7 @@ declare class ColoniesClient {
178
309
  * @param inReplyTo - Sequence number this message is replying to (0 if not a reply)
179
310
  * @param payload - Message content (string or Uint8Array)
180
311
  */
181
- channelAppend(processId: string, channelName: string, sequence: number, inReplyTo: number, payload: string | Uint8Array): Promise<any>;
312
+ channelAppend(processId: string, channelName: string, sequence: number, inReplyTo: number, payload: string | Uint8Array): Promise<void>;
182
313
  /**
183
314
  * Read messages from a process channel
184
315
  * @param processId - ID of the process
@@ -186,7 +317,7 @@ declare class ColoniesClient {
186
317
  * @param afterSeq - Read messages after this sequence number (use 0 for all)
187
318
  * @param limit - Maximum number of messages to return (0 for no limit)
188
319
  */
189
- channelRead(processId: string, channelName: string, afterSeq: number, limit: number): Promise<any[]>;
320
+ channelRead(processId: string, channelName: string, afterSeq: number, limit: number): Promise<ChannelEntry[]>;
190
321
  /**
191
322
  * Subscribe to a channel using WebSocket for real-time updates
192
323
  * @param processId - ID of the process
@@ -198,23 +329,23 @@ declare class ColoniesClient {
198
329
  * @param onClose - Callback when connection closes
199
330
  * @returns WebSocket instance for cleanup
200
331
  */
201
- subscribeChannel(processId: string, channelName: string, afterSeq: number, timeout: number, onMessage: (entries: any[]) => void, onError: (error: Error) => void, onClose: () => void): WebSocket;
332
+ subscribeChannel(processId: string, channelName: string, afterSeq: number, timeout: number, onMessage: (entries: ChannelEntry[]) => void, onError: (error: Error) => void, onClose: () => void): WebSocket;
202
333
  /**
203
334
  * Add a blueprint definition
204
335
  * @param definition - Blueprint definition object
205
336
  */
206
- addBlueprintDefinition(definition: any): Promise<any>;
337
+ addBlueprintDefinition(definition: BlueprintDefinition): Promise<BlueprintDefinition>;
207
338
  /**
208
339
  * Get a blueprint definition by name
209
340
  * @param colonyName - Name of the colony
210
341
  * @param name - Name of the blueprint definition
211
342
  */
212
- getBlueprintDefinition(colonyName: string, name: string): Promise<any>;
343
+ getBlueprintDefinition(colonyName: string, name: string): Promise<BlueprintDefinition>;
213
344
  /**
214
345
  * Get all blueprint definitions in a colony
215
346
  * @param colonyName - Name of the colony
216
347
  */
217
- getBlueprintDefinitions(colonyName: string): Promise<any[]>;
348
+ getBlueprintDefinitions(colonyName: string): Promise<BlueprintDefinition[]>;
218
349
  /**
219
350
  * Remove a blueprint definition
220
351
  * @param colonyName - Name of the colony (namespace)
@@ -225,26 +356,26 @@ declare class ColoniesClient {
225
356
  * Add a blueprint instance
226
357
  * @param blueprint - Blueprint object
227
358
  */
228
- addBlueprint(blueprint: any): Promise<any>;
359
+ addBlueprint(blueprint: Blueprint): Promise<Blueprint>;
229
360
  /**
230
361
  * Get a blueprint by name
231
362
  * @param colonyName - Name of the colony (namespace)
232
363
  * @param name - Name of the blueprint
233
364
  */
234
- getBlueprint(colonyName: string, name: string): Promise<any>;
365
+ getBlueprint(colonyName: string, name: string): Promise<Blueprint>;
235
366
  /**
236
367
  * Get blueprints in a colony, optionally filtered by kind and location
237
368
  * @param colonyName - Name of the colony (namespace)
238
369
  * @param kind - Optional kind filter
239
370
  * @param location - Optional location filter
240
371
  */
241
- getBlueprints(colonyName: string, kind?: string, location?: string): Promise<any[]>;
372
+ getBlueprints(colonyName: string, kind?: string, location?: string): Promise<Blueprint[]>;
242
373
  /**
243
374
  * Update an existing blueprint
244
375
  * @param blueprint - Updated blueprint object
245
376
  * @param forceGeneration - Force generation bump even if spec unchanged
246
377
  */
247
- updateBlueprint(blueprint: any, forceGeneration?: boolean): Promise<any>;
378
+ updateBlueprint(blueprint: Blueprint, forceGeneration?: boolean): Promise<Blueprint>;
248
379
  /**
249
380
  * Remove a blueprint
250
381
  * @param colonyName - Name of the colony (namespace)
@@ -257,20 +388,20 @@ declare class ColoniesClient {
257
388
  * @param name - Name of the blueprint
258
389
  * @param status - Status object representing current state
259
390
  */
260
- updateBlueprintStatus(colonyName: string, name: string, status: any): Promise<void>;
391
+ updateBlueprintStatus(colonyName: string, name: string, status: Record<string, unknown>): Promise<void>;
261
392
  /**
262
393
  * Trigger reconciliation for a blueprint
263
394
  * @param colonyName - Name of the colony (namespace)
264
395
  * @param name - Name of the blueprint
265
396
  * @param force - Force reconciliation even if no changes detected
266
397
  */
267
- reconcileBlueprint(colonyName: string, name: string, force?: boolean): Promise<any>;
398
+ reconcileBlueprint(colonyName: string, name: string, force?: boolean): Promise<Blueprint>;
268
399
  /**
269
400
  * Get the history of changes for a specific blueprint
270
401
  * @param blueprintId - ID of the blueprint
271
402
  * @param limit - Optional limit on number of history entries to retrieve
272
403
  */
273
- getBlueprintHistory(blueprintId: string, limit?: number): Promise<any>;
404
+ getBlueprintHistory(blueprintId: string, limit?: number): Promise<Blueprint[]>;
274
405
  /**
275
406
  * Subscribe to process state changes using WebSocket
276
407
  * Use this to wait for a process to be assigned (RUNNING state) before subscribing to channels
@@ -283,7 +414,7 @@ declare class ColoniesClient {
283
414
  * @param onClose - Callback when connection closes
284
415
  * @returns WebSocket instance for cleanup
285
416
  */
286
- subscribeProcess(colonyName: string, processId: string, state: number, timeout: number, onProcess: (process: any) => void, onError: (error: Error) => void, onClose: () => void): WebSocket;
417
+ subscribeProcess(colonyName: string, processId: string, state: number, timeout: number, onProcess: (process: Process) => void, onError: (error: Error) => void, onClose: () => void): WebSocket;
287
418
  }
288
419
 
289
- export { ColoniesClient, type ColoniesClientConfig, Crypto, type FunctionSpec, ProcessState, type RPCMessage, deriveId, generatePrivateKey, sign };
420
+ export { type Attribute, type Blueprint, type BlueprintDefinition, type BlueprintHandler, type BlueprintMetadata, type ChannelEntry, ColoniesClient, type ColoniesClientConfig, type Colony, type ColonyFile, type ColonyFunction, type Cron, Crypto, type Executor, type FunctionArg, type FunctionSpec, type Generator, type Log, type Process, type ProcessGraph, ProcessState, type RPCMessage, type User, type WorkflowSpec, deriveId, generatePrivateKey, sign };