@seenn/node 0.1.1 → 0.2.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.
package/src/types.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // Child progress calculation mode
2
+ export type ChildProgressMode = 'average' | 'weighted' | 'sequential';
3
+
1
4
  // Job Parameters
2
5
 
3
6
  export interface StartJobParams {
@@ -7,16 +10,28 @@ export interface StartJobParams {
7
10
  userId: string;
8
11
  /** Human-readable title for the job */
9
12
  title: string;
13
+ /** Optional version for ETA tracking (e.g., '1.0', '2.1.0') */
14
+ version?: string;
10
15
  /** Optional metadata (max 10KB) */
11
16
  metadata?: Record<string, unknown>;
12
17
  /** Optional initial queue information */
13
18
  queue?: QueueInfo;
14
19
  /** Optional initial stage information */
15
20
  stage?: StageInfo;
16
- /** Optional estimated completion time (ISO 8601) */
21
+ /** Optional estimated completion time (ISO 8601) - overrides auto ETA */
17
22
  estimatedCompletionAt?: string;
23
+ /** Optional estimated duration in ms - overrides auto ETA */
24
+ estimatedDuration?: number;
18
25
  /** Optional TTL in seconds (default: 30 days) */
19
26
  ttlSeconds?: number;
27
+ /** Parent job ID (for child jobs) */
28
+ parentJobId?: string;
29
+ /** 0-based index within parent (for child jobs) */
30
+ childIndex?: number;
31
+ /** Total number of children (for parent jobs) */
32
+ totalChildren?: number;
33
+ /** How to calculate parent progress from children (default: 'average') */
34
+ childProgressMode?: ChildProgressMode;
20
35
  }
21
36
 
22
37
  export interface ProgressParams {
@@ -88,6 +103,98 @@ export interface JobError {
88
103
  details?: Record<string, unknown>;
89
104
  }
90
105
 
106
+ // Parent-child types
107
+
108
+ /** Summary of a child job */
109
+ export interface ChildJobSummary {
110
+ id: string;
111
+ childIndex: number;
112
+ title: string;
113
+ status: 'pending' | 'running' | 'completed' | 'failed';
114
+ progress: number;
115
+ message?: string;
116
+ result?: JobResult;
117
+ error?: JobError;
118
+ createdAt: string;
119
+ updatedAt: string;
120
+ completedAt?: string;
121
+ }
122
+
123
+ /** Parent info included in child job responses */
124
+ export interface ParentInfo {
125
+ parentJobId: string;
126
+ childIndex: number;
127
+ }
128
+
129
+ /** Children stats included in parent job responses */
130
+ export interface ChildrenStats {
131
+ total: number;
132
+ completed: number;
133
+ failed: number;
134
+ running: number;
135
+ pending: number;
136
+ }
137
+
138
+ /** Parameters for creating a parent job */
139
+ export interface CreateParentParams {
140
+ /** Unique job type identifier */
141
+ jobType: string;
142
+ /** User ID who owns this job */
143
+ userId: string;
144
+ /** Human-readable title for the parent job */
145
+ title: string;
146
+ /** Total number of children this parent will have */
147
+ childCount: number;
148
+ /** How to calculate parent progress from children (default: 'average') */
149
+ childProgressMode?: ChildProgressMode;
150
+ /** Optional metadata */
151
+ metadata?: Record<string, unknown>;
152
+ /** Optional TTL in seconds */
153
+ ttlSeconds?: number;
154
+ }
155
+
156
+ /** Parameters for creating a child job */
157
+ export interface CreateChildParams {
158
+ /** Parent job ID */
159
+ parentJobId: string;
160
+ /** 0-based index within parent */
161
+ childIndex: number;
162
+ /** Unique job type identifier */
163
+ jobType: string;
164
+ /** User ID who owns this job */
165
+ userId: string;
166
+ /** Human-readable title for the child job */
167
+ title: string;
168
+ /** Optional metadata */
169
+ metadata?: Record<string, unknown>;
170
+ /** Optional TTL in seconds */
171
+ ttlSeconds?: number;
172
+ }
173
+
174
+ /** Parameters for creating a batch of jobs */
175
+ export interface CreateBatchParams {
176
+ /** Unique job type identifier for all jobs */
177
+ jobType: string;
178
+ /** User ID who owns these jobs */
179
+ userId: string;
180
+ /** Human-readable title for the parent job */
181
+ parentTitle: string;
182
+ /** Titles for each child job */
183
+ childTitles: string[];
184
+ /** How to calculate parent progress from children (default: 'average') */
185
+ childProgressMode?: ChildProgressMode;
186
+ /** Optional metadata for parent job */
187
+ metadata?: Record<string, unknown>;
188
+ /** Optional TTL in seconds */
189
+ ttlSeconds?: number;
190
+ }
191
+
192
+ /** Parent job with all its children */
193
+ export interface ParentWithChildren {
194
+ parent: JobResponse;
195
+ children: ChildJobSummary[];
196
+ }
197
+
91
198
  // API Response Types
92
199
 
93
200
  export interface JobResponse {
@@ -96,6 +203,8 @@ export interface JobResponse {
96
203
  userId: string;
97
204
  jobType: string;
98
205
  title: string;
206
+ /** Job version for ETA tracking */
207
+ version?: string;
99
208
  status: 'pending' | 'running' | 'completed' | 'failed';
100
209
  progress: number;
101
210
  message?: string;
@@ -104,8 +213,57 @@ export interface JobResponse {
104
213
  result?: JobResult;
105
214
  error?: JobError;
106
215
  metadata?: Record<string, unknown>;
216
+ /** Estimated completion time (ISO 8601) */
107
217
  estimatedCompletionAt?: string;
218
+ /** ETA confidence score (0.0 - 1.0) */
219
+ etaConfidence?: number;
220
+ /** Number of historical jobs used to calculate ETA */
221
+ etaBasedOn?: number;
108
222
  createdAt: string;
109
223
  updatedAt: string;
224
+ /** When the job actually started running */
225
+ startedAt?: string;
110
226
  completedAt?: string;
227
+ /** Parent info (if this is a child job) */
228
+ parent?: ParentInfo;
229
+ /** Children stats (if this is a parent job) */
230
+ children?: ChildrenStats;
231
+ /** Child progress mode (if this is a parent job) */
232
+ childProgressMode?: ChildProgressMode;
233
+ }
234
+
235
+ // ETA Types
236
+
237
+ /** ETA statistics for a job type */
238
+ export interface EtaStats {
239
+ /** Job type identifier */
240
+ jobType: string;
241
+ /** Version (or 'default') */
242
+ version: string;
243
+ /** Number of completed jobs in statistics */
244
+ count: number;
245
+ /** Average duration in milliseconds */
246
+ avgDuration: number;
247
+ /** Median duration (50th percentile) in milliseconds */
248
+ p50Duration: number;
249
+ /** 95th percentile duration in milliseconds */
250
+ p95Duration: number;
251
+ /** Minimum recorded duration */
252
+ minDuration: number;
253
+ /** Maximum recorded duration */
254
+ maxDuration: number;
255
+ /** Confidence score for ETA predictions (0.0 - 1.0) */
256
+ confidence: number;
257
+ /** Last time stats were updated */
258
+ lastUpdated: string;
259
+ }
260
+
261
+ /** Default ETA configuration for job types */
262
+ export interface DefaultEtaConfig {
263
+ /** Job type identifier */
264
+ jobType: string;
265
+ /** Default duration in milliseconds (used when no history) */
266
+ defaultDuration: number;
267
+ /** Optional version */
268
+ version?: string;
111
269
  }