@elaraai/e3-types 0.0.2-beta.9 → 1.0.1

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 (68) hide show
  1. package/CLA.md +26 -0
  2. package/CLAUDE.md +11 -0
  3. package/CONTRIBUTING.md +28 -0
  4. package/LICENSE.md +1 -1
  5. package/README.md +56 -17
  6. package/dist/src/api.d.ts +1131 -0
  7. package/dist/src/api.d.ts.map +1 -0
  8. package/dist/src/api.js +652 -0
  9. package/dist/src/api.js.map +1 -0
  10. package/dist/src/constants.d.ts +12 -0
  11. package/dist/src/constants.d.ts.map +1 -0
  12. package/dist/src/constants.js +12 -0
  13. package/dist/src/constants.js.map +1 -0
  14. package/dist/src/dataflow.d.ts +574 -0
  15. package/dist/src/dataflow.d.ts.map +1 -0
  16. package/dist/src/dataflow.js +366 -0
  17. package/dist/src/dataflow.js.map +1 -0
  18. package/dist/src/dataset-ref.d.ts +86 -0
  19. package/dist/src/dataset-ref.d.ts.map +1 -0
  20. package/dist/src/dataset-ref.js +82 -0
  21. package/dist/src/dataset-ref.js.map +1 -0
  22. package/dist/src/dataset.d.ts +4 -4
  23. package/dist/src/execution.d.ts +29 -21
  24. package/dist/src/execution.d.ts.map +1 -1
  25. package/dist/src/execution.js +8 -0
  26. package/dist/src/execution.js.map +1 -1
  27. package/dist/src/index.d.ts +7 -1
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +39 -1
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lock.d.ts +85 -0
  32. package/dist/src/lock.d.ts.map +1 -0
  33. package/dist/src/lock.js +71 -0
  34. package/dist/src/lock.js.map +1 -0
  35. package/dist/src/package.d.ts +253 -134
  36. package/dist/src/package.d.ts.map +1 -1
  37. package/dist/src/package.js +53 -23
  38. package/dist/src/package.js.map +1 -1
  39. package/dist/src/structure.d.ts +99 -73
  40. package/dist/src/structure.d.ts.map +1 -1
  41. package/dist/src/structure.js +8 -3
  42. package/dist/src/structure.js.map +1 -1
  43. package/dist/src/task.d.ts +10 -6
  44. package/dist/src/task.d.ts.map +1 -1
  45. package/dist/src/task.js +5 -1
  46. package/dist/src/task.js.map +1 -1
  47. package/dist/src/transfer.d.ts +52 -0
  48. package/dist/src/transfer.d.ts.map +1 -0
  49. package/dist/src/transfer.js +49 -0
  50. package/dist/src/transfer.js.map +1 -0
  51. package/dist/src/workspace.d.ts +7 -9
  52. package/dist/src/workspace.d.ts.map +1 -1
  53. package/dist/src/workspace.js +3 -5
  54. package/dist/src/workspace.js.map +1 -1
  55. package/package.json +11 -11
  56. package/src/api.ts +763 -0
  57. package/src/constants.ts +12 -0
  58. package/src/dataflow.ts +427 -0
  59. package/src/dataset-ref.ts +91 -0
  60. package/src/execution.ts +8 -0
  61. package/src/index.ts +183 -0
  62. package/src/lock.ts +90 -0
  63. package/src/package.ts +72 -23
  64. package/src/structure.ts +8 -3
  65. package/src/task.ts +5 -1
  66. package/src/transfer.ts +56 -0
  67. package/src/workspace.ts +3 -5
  68. package/tsconfig.json +1 -2
package/src/api.ts ADDED
@@ -0,0 +1,763 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+
6
+ /**
7
+ * API wire types for e3.
8
+ *
9
+ * These East types define the request/response schemas used by the e3 REST API.
10
+ * They are shared between e3-api-client and e3-api-server.
11
+ *
12
+ * Types that also serve as domain types (PackageImportResultType, DataflowGraphType,
13
+ * DataflowGraphTaskType) are defined in their respective modules and re-exported here.
14
+ *
15
+ * Two types are prefixed with "Api" to avoid name conflicts with domain types
16
+ * that have the same name but different structure:
17
+ * - ApiExecutionStatusType (vs ExecutionStatusType in execution.ts — on-disk task status)
18
+ * - ApiDataflowExecutionStateType (vs DataflowExecutionStateType in dataflow.ts — persistent state)
19
+ */
20
+
21
+ import {
22
+ VariantType,
23
+ StructType,
24
+ ArrayType,
25
+ OptionType,
26
+ StringType,
27
+ IntegerType,
28
+ FloatType,
29
+ BooleanType,
30
+ BlobType,
31
+ NullType,
32
+ EastTypeType,
33
+ type EastType,
34
+ type ValueTypeOf,
35
+ } from '@elaraai/east';
36
+
37
+ import { StructureType, TreePathType } from './structure.js';
38
+
39
+ // =============================================================================
40
+ // Error Types
41
+ // =============================================================================
42
+
43
+ export const WorkspaceNotFoundErrorType = StructType({ workspace: StringType });
44
+ export const WorkspaceNotDeployedErrorType = StructType({ workspace: StringType });
45
+ export const WorkspaceExistsErrorType = StructType({ workspace: StringType });
46
+ export const LockHolderType = StructType({
47
+ pid: IntegerType,
48
+ acquiredAt: StringType,
49
+ bootId: OptionType(StringType),
50
+ command: OptionType(StringType),
51
+ });
52
+ export const WorkspaceLockedErrorType = StructType({
53
+ workspace: StringType,
54
+ holder: VariantType({ unknown: NullType, known: LockHolderType }),
55
+ });
56
+ export const PackageNotFoundErrorType = StructType({
57
+ packageName: StringType,
58
+ version: OptionType(StringType),
59
+ });
60
+ export const PackageExistsErrorType = StructType({ packageName: StringType, version: StringType });
61
+ export const PackageInvalidErrorType = StructType({ reason: StringType });
62
+ export const DatasetNotFoundErrorType = StructType({ workspace: StringType, path: StringType });
63
+ export const TaskNotFoundErrorType = StructType({ task: StringType });
64
+ export const ExecutionNotFoundErrorType = StructType({ task: StringType });
65
+ export const ObjectNotFoundErrorType = StructType({ hash: StringType });
66
+ export const DataflowErrorType = StructType({ message: StringType });
67
+ export const PermissionDeniedErrorType = StructType({ path: StringType });
68
+ export const InternalErrorType = StructType({ message: StringType });
69
+ export const RepositoryNotFoundErrorType = StructType({ repo: StringType });
70
+
71
+ export const ErrorType = VariantType({
72
+ repository_not_found: RepositoryNotFoundErrorType,
73
+ workspace_not_found: WorkspaceNotFoundErrorType,
74
+ workspace_not_deployed: WorkspaceNotDeployedErrorType,
75
+ workspace_exists: WorkspaceExistsErrorType,
76
+ workspace_locked: WorkspaceLockedErrorType,
77
+ package_not_found: PackageNotFoundErrorType,
78
+ package_exists: PackageExistsErrorType,
79
+ package_invalid: PackageInvalidErrorType,
80
+ dataset_not_found: DatasetNotFoundErrorType,
81
+ task_not_found: TaskNotFoundErrorType,
82
+ execution_not_found: ExecutionNotFoundErrorType,
83
+ object_not_found: ObjectNotFoundErrorType,
84
+ dataflow_error: DataflowErrorType,
85
+ dataflow_aborted: NullType,
86
+ permission_denied: PermissionDeniedErrorType,
87
+ internal: InternalErrorType,
88
+ });
89
+
90
+ // =============================================================================
91
+ // Response Wrapper
92
+ // =============================================================================
93
+
94
+ export const ResponseType = <T extends EastType>(successType: T) => VariantType({
95
+ success: successType,
96
+ error: ErrorType,
97
+ });
98
+
99
+ // =============================================================================
100
+ // Repository Types
101
+ // =============================================================================
102
+
103
+ /**
104
+ * Repository status information.
105
+ *
106
+ * @property path - Absolute path to the e3 repository directory
107
+ * @property objectCount - Number of content-addressed objects stored
108
+ * @property packageCount - Number of imported packages
109
+ * @property workspaceCount - Number of workspaces
110
+ */
111
+ export const RepositoryStatusType = StructType({
112
+ path: StringType,
113
+ objectCount: IntegerType,
114
+ packageCount: IntegerType,
115
+ workspaceCount: IntegerType,
116
+ });
117
+
118
+ /**
119
+ * Garbage collection request options.
120
+ *
121
+ * @property dryRun - If true, report what would be deleted without deleting
122
+ * @property minAge - Minimum age in milliseconds for objects to be considered for deletion
123
+ */
124
+ export const GcRequestType = StructType({
125
+ dryRun: BooleanType,
126
+ minAge: OptionType(IntegerType),
127
+ });
128
+
129
+ /**
130
+ * Garbage collection result.
131
+ *
132
+ * @property deletedObjects - Number of unreferenced objects deleted
133
+ * @property deletedPartials - Number of incomplete uploads deleted
134
+ * @property retainedObjects - Number of objects still referenced
135
+ * @property skippedYoung - Number of objects skipped due to minAge
136
+ * @property bytesFreed - Total bytes freed by deletion
137
+ */
138
+ export const GcResultType = StructType({
139
+ deletedObjects: IntegerType,
140
+ deletedPartials: IntegerType,
141
+ retainedObjects: IntegerType,
142
+ skippedYoung: IntegerType,
143
+ bytesFreed: IntegerType,
144
+ });
145
+
146
+ // =============================================================================
147
+ // Async Operation Types
148
+ // =============================================================================
149
+
150
+ /**
151
+ * Status of an async operation.
152
+ *
153
+ * - `running`: Operation is in progress
154
+ * - `succeeded`: Operation completed successfully
155
+ * - `failed`: Operation failed with an error
156
+ */
157
+ export const AsyncOperationStatusType = VariantType({
158
+ running: NullType,
159
+ succeeded: NullType,
160
+ failed: NullType,
161
+ });
162
+
163
+ /**
164
+ * Result of starting an async GC operation.
165
+ *
166
+ * @property executionId - Unique identifier for this GC execution (UUID locally, Step Function ARN in cloud)
167
+ */
168
+ export const GcStartResultType = StructType({
169
+ executionId: StringType,
170
+ });
171
+
172
+ /**
173
+ * Status of an async GC operation.
174
+ *
175
+ * @property status - Current execution status
176
+ * @property stats - GC statistics (available when succeeded)
177
+ * @property error - Error message (available when failed)
178
+ */
179
+ export const GcStatusResultType = StructType({
180
+ status: AsyncOperationStatusType,
181
+ stats: OptionType(GcResultType),
182
+ error: OptionType(StringType),
183
+ });
184
+
185
+ // =============================================================================
186
+ // Package Types
187
+ // =============================================================================
188
+
189
+ /**
190
+ * Package list item (summary info).
191
+ *
192
+ * @property name - Package name
193
+ * @property version - Semantic version string
194
+ */
195
+ export const PackageListItemType = StructType({
196
+ name: StringType,
197
+ version: StringType,
198
+ });
199
+
200
+ /**
201
+ * Basic package info.
202
+ *
203
+ * @property name - Package name
204
+ * @property version - Semantic version string
205
+ * @property hash - SHA256 content hash
206
+ */
207
+ export const PackageInfoType = StructType({
208
+ name: StringType,
209
+ version: StringType,
210
+ hash: StringType,
211
+ });
212
+
213
+ /**
214
+ * Detailed package information including structure.
215
+ *
216
+ * @property name - Package name
217
+ * @property version - Semantic version string
218
+ * @property hash - SHA256 content hash
219
+ * @property tasks - List of task names defined in the package
220
+ * @property dataStructure - East structure type describing the package's data schema
221
+ */
222
+ export const PackageDetailsType = StructType({
223
+ name: StringType,
224
+ version: StringType,
225
+ hash: StringType,
226
+ tasks: ArrayType(StringType),
227
+ dataStructure: StructureType,
228
+ });
229
+
230
+ // =============================================================================
231
+ // Workspace Types
232
+ // =============================================================================
233
+
234
+ /**
235
+ * Request to create a new workspace.
236
+ *
237
+ * @property name - Unique workspace name
238
+ */
239
+ export const WorkspaceCreateRequestType = StructType({
240
+ name: StringType,
241
+ });
242
+
243
+ /**
244
+ * Workspace summary information.
245
+ *
246
+ * @property name - Workspace name
247
+ * @property deployed - Whether a package is deployed to this workspace
248
+ * @property packageName - Name of deployed package (if deployed)
249
+ * @property packageVersion - Version of deployed package (if deployed)
250
+ */
251
+ export const WorkspaceInfoType = StructType({
252
+ name: StringType,
253
+ deployed: BooleanType,
254
+ packageName: OptionType(StringType),
255
+ packageVersion: OptionType(StringType),
256
+ });
257
+
258
+ /**
259
+ * Request to deploy a package to a workspace.
260
+ *
261
+ * @property packageRef - Package reference in format "name" or "name@version"
262
+ */
263
+ export const WorkspaceDeployRequestType = StructType({
264
+ packageRef: StringType,
265
+ });
266
+
267
+ /**
268
+ * Workspace export request body.
269
+ *
270
+ * @property name - Optional custom package name
271
+ * @property version - Optional custom version
272
+ */
273
+ export const WorkspaceExportRequestType = StructType({
274
+ name: OptionType(StringType),
275
+ version: OptionType(StringType),
276
+ });
277
+
278
+ // =============================================================================
279
+ // Workspace Status Types
280
+ // =============================================================================
281
+
282
+ /**
283
+ * Dataset status variant.
284
+ *
285
+ * - `unset`: No value assigned to this dataset
286
+ * - `stale`: Value exists but is outdated (upstream changed)
287
+ * - `up-to-date`: Value is current
288
+ */
289
+ export const DatasetStatusType = VariantType({
290
+ unset: NullType,
291
+ stale: NullType,
292
+ 'up-to-date': NullType,
293
+ });
294
+
295
+ /** Task completed successfully. @property cached - True if result was from cache */
296
+ export const TaskStatusUpToDateType = StructType({ cached: BooleanType });
297
+
298
+ /** Task waiting on dependencies. @property reason - Human-readable wait reason */
299
+ export const TaskStatusWaitingType = StructType({ reason: StringType });
300
+
301
+ /** Task currently executing. */
302
+ export const TaskStatusInProgressType = StructType({
303
+ /** Process ID of the running task */
304
+ pid: OptionType(IntegerType),
305
+ /** ISO timestamp when execution started */
306
+ startedAt: OptionType(StringType),
307
+ });
308
+
309
+ /** Task exited with non-zero code. */
310
+ export const TaskStatusFailedType = StructType({
311
+ /** Process exit code */
312
+ exitCode: IntegerType,
313
+ /** ISO timestamp when task completed */
314
+ completedAt: OptionType(StringType),
315
+ });
316
+
317
+ /** Task encountered an internal error. */
318
+ export const TaskStatusErrorType = StructType({
319
+ /** Error message */
320
+ message: StringType,
321
+ /** ISO timestamp when error occurred */
322
+ completedAt: OptionType(StringType),
323
+ });
324
+
325
+ /** Task was running but process is no longer alive. */
326
+ export const TaskStatusStaleRunningType = StructType({
327
+ /** Last known process ID */
328
+ pid: OptionType(IntegerType),
329
+ /** ISO timestamp when execution started */
330
+ startedAt: OptionType(StringType),
331
+ });
332
+
333
+ /**
334
+ * Task execution status variant.
335
+ *
336
+ * - `up-to-date`: Task completed successfully (cached indicates if from cache)
337
+ * - `ready`: Task is ready to run (all inputs available)
338
+ * - `waiting`: Task waiting on upstream dependencies
339
+ * - `in-progress`: Task currently executing
340
+ * - `failed`: Task exited with non-zero exit code
341
+ * - `error`: Internal error during task execution
342
+ * - `stale-running`: Task was marked running but process died
343
+ */
344
+ export const TaskStatusType = VariantType({
345
+ 'up-to-date': TaskStatusUpToDateType,
346
+ ready: NullType,
347
+ waiting: TaskStatusWaitingType,
348
+ 'in-progress': TaskStatusInProgressType,
349
+ failed: TaskStatusFailedType,
350
+ error: TaskStatusErrorType,
351
+ 'stale-running': TaskStatusStaleRunningType,
352
+ });
353
+
354
+ /**
355
+ * Status information for a single dataset.
356
+ *
357
+ * @property path - Dataset path (e.g., ".inputs.config" or ".tasks.foo.output")
358
+ * @property status - Current status (unset, stale, or up-to-date)
359
+ * @property hash - SHA256 hash of current value (if set)
360
+ * @property isTaskOutput - True if this dataset is produced by a task
361
+ * @property producedBy - Name of task that produces this dataset (if isTaskOutput)
362
+ */
363
+ export const DatasetStatusInfoType = StructType({
364
+ path: StringType,
365
+ status: DatasetStatusType,
366
+ hash: OptionType(StringType),
367
+ isTaskOutput: BooleanType,
368
+ producedBy: OptionType(StringType),
369
+ });
370
+
371
+ /**
372
+ * Status information for a single task.
373
+ *
374
+ * @property name - Task name
375
+ * @property hash - Task definition hash (changes when task code changes)
376
+ * @property status - Current execution status
377
+ * @property inputs - Dataset paths this task reads from
378
+ * @property output - Dataset path this task writes to
379
+ * @property dependsOn - Names of tasks that must complete before this one
380
+ */
381
+ export const TaskStatusInfoType = StructType({
382
+ name: StringType,
383
+ hash: StringType,
384
+ status: TaskStatusType,
385
+ inputs: ArrayType(StringType),
386
+ output: StringType,
387
+ dependsOn: ArrayType(StringType),
388
+ });
389
+
390
+ /**
391
+ * Summary counts for workspace status.
392
+ */
393
+ export const WorkspaceStatusSummaryType = StructType({
394
+ /** Dataset status counts */
395
+ datasets: StructType({
396
+ total: IntegerType,
397
+ unset: IntegerType,
398
+ stale: IntegerType,
399
+ upToDate: IntegerType,
400
+ }),
401
+ /** Task status counts */
402
+ tasks: StructType({
403
+ total: IntegerType,
404
+ upToDate: IntegerType,
405
+ ready: IntegerType,
406
+ waiting: IntegerType,
407
+ inProgress: IntegerType,
408
+ failed: IntegerType,
409
+ error: IntegerType,
410
+ staleRunning: IntegerType,
411
+ }),
412
+ });
413
+
414
+ /**
415
+ * Complete workspace status including all datasets, tasks, and summary.
416
+ *
417
+ * @property workspace - Workspace name
418
+ * @property lock - Information about current lock holder (if locked)
419
+ * @property datasets - Status of all datasets in the workspace
420
+ * @property tasks - Status of all tasks in the workspace
421
+ * @property summary - Aggregated counts by status
422
+ */
423
+ export const WorkspaceStatusResultType = StructType({
424
+ workspace: StringType,
425
+ lock: OptionType(LockHolderType),
426
+ datasets: ArrayType(DatasetStatusInfoType),
427
+ tasks: ArrayType(TaskStatusInfoType),
428
+ summary: WorkspaceStatusSummaryType,
429
+ });
430
+
431
+ // =============================================================================
432
+ // Task Types
433
+ // =============================================================================
434
+
435
+ /**
436
+ * Task list item (summary info).
437
+ *
438
+ * @property name - Task name
439
+ * @property hash - Task definition hash
440
+ */
441
+ export const TaskListItemType = StructType({
442
+ name: StringType,
443
+ hash: StringType,
444
+ });
445
+
446
+ /**
447
+ * Detailed task information.
448
+ *
449
+ * @property name - Task name
450
+ * @property hash - Task definition hash
451
+ * @property commandIr - East IR for the task's command
452
+ * @property inputs - Tree paths for task inputs
453
+ * @property output - Tree path for task output
454
+ */
455
+ export const TaskDetailsType = StructType({
456
+ name: StringType,
457
+ hash: StringType,
458
+ commandIr: StringType,
459
+ inputs: ArrayType(TreePathType),
460
+ output: TreePathType,
461
+ kind: OptionType(StringType),
462
+ metadata: OptionType(BlobType),
463
+ });
464
+
465
+ // =============================================================================
466
+ // Execution Types
467
+ // =============================================================================
468
+
469
+ /**
470
+ * Request to start dataflow execution.
471
+ *
472
+ * @property concurrency - Maximum parallel tasks (default: 4)
473
+ * @property force - Force re-execution of all tasks
474
+ * @property filter - Filter to specific task names (glob pattern)
475
+ */
476
+ export const DataflowRequestType = StructType({
477
+ concurrency: OptionType(IntegerType),
478
+ force: BooleanType,
479
+ filter: OptionType(StringType),
480
+ });
481
+
482
+ /**
483
+ * Chunk of log data from task execution.
484
+ *
485
+ * @property data - Log content (UTF-8 text)
486
+ * @property offset - Byte offset from start of log
487
+ * @property size - Size of this chunk in bytes
488
+ * @property totalSize - Total size of the log file
489
+ * @property complete - True if this chunk reaches end of file
490
+ */
491
+ export const LogChunkType = StructType({
492
+ data: StringType,
493
+ offset: IntegerType,
494
+ size: IntegerType,
495
+ totalSize: IntegerType,
496
+ complete: BooleanType,
497
+ });
498
+
499
+ /**
500
+ * Result of executing a single task.
501
+ *
502
+ * @property name - Task name
503
+ * @property cached - True if result was retrieved from cache
504
+ * @property state - Execution outcome (success, failed, error, skipped)
505
+ * @property duration - Execution time in seconds
506
+ */
507
+ export const TaskExecutionResultType = StructType({
508
+ name: StringType,
509
+ cached: BooleanType,
510
+ state: VariantType({
511
+ success: NullType,
512
+ failed: StructType({ exitCode: IntegerType }),
513
+ error: StructType({ message: StringType }),
514
+ skipped: NullType,
515
+ }),
516
+ duration: FloatType,
517
+ });
518
+
519
+ /**
520
+ * Result of dataflow execution.
521
+ *
522
+ * @property success - True if all tasks completed successfully
523
+ * @property executed - Number of tasks that were executed
524
+ * @property cached - Number of tasks that used cached results
525
+ * @property failed - Number of tasks that failed
526
+ * @property skipped - Number of tasks that were skipped
527
+ * @property tasks - Per-task execution results
528
+ * @property duration - Total execution time in seconds
529
+ */
530
+ export const DataflowResultType = StructType({
531
+ success: BooleanType,
532
+ executed: IntegerType,
533
+ cached: IntegerType,
534
+ failed: IntegerType,
535
+ skipped: IntegerType,
536
+ tasks: ArrayType(TaskExecutionResultType),
537
+ duration: FloatType,
538
+ });
539
+
540
+ // =============================================================================
541
+ // Dataflow Execution State Types (for API polling)
542
+ // =============================================================================
543
+
544
+ /**
545
+ * Dataflow event types for API polling.
546
+ *
547
+ * - `start`: Task started executing
548
+ * - `complete`: Task executed and succeeded
549
+ * - `cached`: Task result retrieved from cache (no execution)
550
+ * - `failed`: Task exited with non-zero code
551
+ * - `error`: Internal error during task execution
552
+ * - `input_unavailable`: Task couldn't run because inputs not available
553
+ */
554
+ export const DataflowEventType = VariantType({
555
+ start: StructType({
556
+ task: StringType,
557
+ timestamp: StringType,
558
+ }),
559
+ complete: StructType({
560
+ task: StringType,
561
+ timestamp: StringType,
562
+ duration: FloatType,
563
+ }),
564
+ cached: StructType({
565
+ task: StringType,
566
+ timestamp: StringType,
567
+ }),
568
+ failed: StructType({
569
+ task: StringType,
570
+ timestamp: StringType,
571
+ duration: FloatType,
572
+ exitCode: IntegerType,
573
+ }),
574
+ error: StructType({
575
+ task: StringType,
576
+ timestamp: StringType,
577
+ message: StringType,
578
+ }),
579
+ input_unavailable: StructType({
580
+ task: StringType,
581
+ timestamp: StringType,
582
+ reason: StringType,
583
+ }),
584
+ });
585
+
586
+ /**
587
+ * Execution status for API polling responses.
588
+ *
589
+ * - `running`: Execution is in progress
590
+ * - `completed`: Execution finished successfully
591
+ * - `failed`: Execution finished with failures
592
+ * - `aborted`: Execution was cancelled
593
+ *
594
+ * Note: Named "Api*" to distinguish from the on-disk ExecutionStatusType
595
+ * in execution.ts which tracks individual task execution states.
596
+ */
597
+ export const ApiExecutionStatusType = VariantType({
598
+ running: NullType,
599
+ completed: NullType,
600
+ failed: NullType,
601
+ aborted: NullType,
602
+ });
603
+
604
+ /**
605
+ * Summary of dataflow execution results.
606
+ */
607
+ export const DataflowExecutionSummaryType = StructType({
608
+ executed: IntegerType,
609
+ cached: IntegerType,
610
+ failed: IntegerType,
611
+ skipped: IntegerType,
612
+ duration: FloatType,
613
+ });
614
+
615
+ /**
616
+ * Dataflow execution state returned by API polling.
617
+ *
618
+ * A lightweight view of the execution state for client polling.
619
+ *
620
+ * Note: Named "Api*" to distinguish from the persistent
621
+ * DataflowExecutionStateType in dataflow.ts which stores the full
622
+ * execution state on disk.
623
+ *
624
+ * @property status - Current execution status
625
+ * @property startedAt - ISO timestamp when execution started
626
+ * @property completedAt - ISO timestamp when execution finished (if done)
627
+ * @property summary - Execution summary (available when complete)
628
+ * @property events - Task events (may be paginated via offset/limit)
629
+ * @property totalEvents - Total number of events (for pagination)
630
+ */
631
+ export const ApiDataflowExecutionStateType = StructType({
632
+ status: ApiExecutionStatusType,
633
+ startedAt: StringType,
634
+ completedAt: OptionType(StringType),
635
+ summary: OptionType(DataflowExecutionSummaryType),
636
+ events: ArrayType(DataflowEventType),
637
+ totalEvents: IntegerType,
638
+ });
639
+
640
+ // =============================================================================
641
+ // Task Execution History Types
642
+ // =============================================================================
643
+
644
+ /**
645
+ * Execution status for history listing.
646
+ */
647
+ export const ExecutionHistoryStatusType = VariantType({
648
+ running: NullType,
649
+ success: NullType,
650
+ failed: NullType,
651
+ error: NullType,
652
+ });
653
+
654
+ /**
655
+ * A single execution in task history.
656
+ *
657
+ * @property inputsHash - Hash of concatenated inputs (execution identifier)
658
+ * @property inputHashes - Individual input object hashes
659
+ * @property status - Execution outcome
660
+ * @property startedAt - ISO timestamp when execution started
661
+ * @property completedAt - ISO timestamp when execution finished (if done)
662
+ * @property duration - Execution duration in milliseconds (if done)
663
+ * @property exitCode - Process exit code (if failed)
664
+ */
665
+ export const ExecutionListItemType = StructType({
666
+ inputsHash: StringType,
667
+ inputHashes: ArrayType(StringType),
668
+ status: ExecutionHistoryStatusType,
669
+ startedAt: StringType,
670
+ completedAt: OptionType(StringType),
671
+ duration: OptionType(IntegerType),
672
+ exitCode: OptionType(IntegerType),
673
+ });
674
+
675
+ // =============================================================================
676
+ // Dataset List Types (recursive)
677
+ // =============================================================================
678
+
679
+ /**
680
+ * Tree branch kind variant.
681
+ *
682
+ * Currently only `struct` branches exist. Future: `dict`, `array`, `variant`.
683
+ */
684
+ export const TreeKindType = VariantType({ struct: NullType });
685
+
686
+ /**
687
+ * A list entry -- either a dataset leaf or a tree branch.
688
+ *
689
+ * Used by the `?list=true&status=true` endpoints to return both
690
+ * tree structure entries and dataset leaves in a single flat list.
691
+ */
692
+ export const ListEntryType = VariantType({
693
+ dataset: StructType({
694
+ path: StringType,
695
+ type: EastTypeType,
696
+ hash: OptionType(StringType),
697
+ size: OptionType(IntegerType),
698
+ }),
699
+ tree: StructType({
700
+ path: StringType,
701
+ kind: TreeKindType,
702
+ }),
703
+ });
704
+
705
+ // =============================================================================
706
+ // Dataset Status Detail Types (single dataset query)
707
+ // =============================================================================
708
+
709
+ /**
710
+ * Detailed status of a single dataset.
711
+ *
712
+ * @property path - Dataset path (e.g., ".inputs.config")
713
+ * @property type - East type of the dataset
714
+ * @property refType - Ref type: "unassigned", "null", or "value"
715
+ * @property hash - Object hash (None if unassigned/null)
716
+ * @property size - Size in bytes (None if unassigned)
717
+ */
718
+ export const DatasetStatusDetailType = StructType({
719
+ path: StringType,
720
+ type: EastTypeType,
721
+ refType: StringType,
722
+ hash: OptionType(StringType),
723
+ size: OptionType(IntegerType),
724
+ });
725
+
726
+ // =============================================================================
727
+ // Value type aliases
728
+ // =============================================================================
729
+
730
+ export type Error = ValueTypeOf<typeof ErrorType>;
731
+ export type RepositoryStatus = ValueTypeOf<typeof RepositoryStatusType>;
732
+ export type GcRequest = ValueTypeOf<typeof GcRequestType>;
733
+ export type GcResult = ValueTypeOf<typeof GcResultType>;
734
+ export type AsyncOperationStatus = ValueTypeOf<typeof AsyncOperationStatusType>;
735
+ export type GcStartResult = ValueTypeOf<typeof GcStartResultType>;
736
+ export type GcStatusResult = ValueTypeOf<typeof GcStatusResultType>;
737
+ export type PackageListItem = ValueTypeOf<typeof PackageListItemType>;
738
+ export type PackageInfo = ValueTypeOf<typeof PackageInfoType>;
739
+ export type PackageDetails = ValueTypeOf<typeof PackageDetailsType>;
740
+ export type WorkspaceInfo = ValueTypeOf<typeof WorkspaceInfoType>;
741
+ export type WorkspaceCreateRequest = ValueTypeOf<typeof WorkspaceCreateRequestType>;
742
+ export type WorkspaceDeployRequest = ValueTypeOf<typeof WorkspaceDeployRequestType>;
743
+ export type DatasetStatus = ValueTypeOf<typeof DatasetStatusType>;
744
+ export type TaskStatus = ValueTypeOf<typeof TaskStatusType>;
745
+ export type DatasetStatusInfo = ValueTypeOf<typeof DatasetStatusInfoType>;
746
+ export type TaskStatusInfo = ValueTypeOf<typeof TaskStatusInfoType>;
747
+ export type WorkspaceStatusSummary = ValueTypeOf<typeof WorkspaceStatusSummaryType>;
748
+ export type WorkspaceStatusResult = ValueTypeOf<typeof WorkspaceStatusResultType>;
749
+ export type TaskListItem = ValueTypeOf<typeof TaskListItemType>;
750
+ export type TaskDetails = ValueTypeOf<typeof TaskDetailsType>;
751
+ export type DataflowRequest = ValueTypeOf<typeof DataflowRequestType>;
752
+ export type LogChunk = ValueTypeOf<typeof LogChunkType>;
753
+ export type TaskExecutionResult = ValueTypeOf<typeof TaskExecutionResultType>;
754
+ export type DataflowResult = ValueTypeOf<typeof DataflowResultType>;
755
+ export type DataflowEvent = ValueTypeOf<typeof DataflowEventType>;
756
+ export type ApiExecutionStatus = ValueTypeOf<typeof ApiExecutionStatusType>;
757
+ export type DataflowExecutionSummary = ValueTypeOf<typeof DataflowExecutionSummaryType>;
758
+ export type ApiDataflowExecutionState = ValueTypeOf<typeof ApiDataflowExecutionStateType>;
759
+ export type ExecutionHistoryStatus = ValueTypeOf<typeof ExecutionHistoryStatusType>;
760
+ export type ExecutionListItem = ValueTypeOf<typeof ExecutionListItemType>;
761
+ export type TreeKind = ValueTypeOf<typeof TreeKindType>;
762
+ export type ListEntry = ValueTypeOf<typeof ListEntryType>;
763
+ export type DatasetStatusDetail = ValueTypeOf<typeof DatasetStatusDetailType>;