@seenn/node 0.1.0 → 0.2.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.
- package/dist/client.d.ts +24 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/job.d.ts +25 -1
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +40 -0
- package/dist/job.js.map +1 -1
- package/dist/types.d.ts +98 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +90 -1
- package/src/index.ts +9 -0
- package/src/job.ts +49 -0
- package/src/types.ts +109 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Job } from './job.js';
|
|
2
|
-
import type { StartJobParams } from './types.js';
|
|
2
|
+
import type { StartJobParams, CreateParentParams, CreateChildParams, CreateBatchParams, ChildJobSummary } from './types.js';
|
|
3
3
|
export interface SeennConfig {
|
|
4
4
|
/** API key (sk_live_xxx or sk_test_xxx) */
|
|
5
5
|
apiKey: string;
|
|
@@ -38,6 +38,29 @@ export declare class SeennClient {
|
|
|
38
38
|
jobs: Job[];
|
|
39
39
|
nextCursor: string | undefined;
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a parent job (batch container)
|
|
43
|
+
*/
|
|
44
|
+
createParent: (params: CreateParentParams) => Promise<Job>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a child job under a parent
|
|
47
|
+
*/
|
|
48
|
+
createChild: (params: CreateChildParams) => Promise<Job>;
|
|
49
|
+
/**
|
|
50
|
+
* Get a parent job with all its children
|
|
51
|
+
*/
|
|
52
|
+
getWithChildren: (parentJobId: string) => Promise<{
|
|
53
|
+
parent: Job;
|
|
54
|
+
children: ChildJobSummary[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Create a batch of jobs (parent + children) in one go
|
|
58
|
+
* Returns the parent job and all child jobs
|
|
59
|
+
*/
|
|
60
|
+
createBatch: (params: CreateBatchParams) => Promise<{
|
|
61
|
+
parent: Job;
|
|
62
|
+
children: Job[];
|
|
63
|
+
}>;
|
|
41
64
|
};
|
|
42
65
|
}
|
|
43
66
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAEjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;gBAEnC,MAAM,EAAE,WAAW;IAoB/B;;OAEG;IACH,IAAI,IAAI;QAEJ;;WAEG;wBACmB,cAAc,KAAG,OAAO,CAAC,GAAG,CAAC;QAKnD;;WAEG;qBACgB,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;QAKxC;;WAEG;uBACkB,MAAM,YAAY;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE;;;;QAgB1E;;WAEG;+BAC0B,kBAAkB,KAAG,OAAO,CAAC,GAAG,CAAC;QAa9D;;WAEG;8BACyB,iBAAiB,KAAG,OAAO,CAAC,GAAG,CAAC;QAa5D;;WAEG;uCACkC,MAAM,KAAG,OAAO,CAAC;YAAE,MAAM,EAAE,GAAG,CAAC;YAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;SAAE,CAAC;QAUnG;;;WAGG;8BACyB,iBAAiB,KAAG,OAAO,CAAC;YAAE,MAAM,EAAE,GAAG,CAAC;YAAC,QAAQ,EAAE,GAAG,EAAE,CAAA;SAAE,CAAC;MAgC5F;CACF"}
|
package/dist/client.js
CHANGED
|
@@ -53,6 +53,75 @@ export class SeennClient {
|
|
|
53
53
|
nextCursor: response.nextCursor,
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
|
+
/**
|
|
57
|
+
* Create a parent job (batch container)
|
|
58
|
+
*/
|
|
59
|
+
createParent: async (params) => {
|
|
60
|
+
const response = await this.http.post('/v1/jobs', {
|
|
61
|
+
jobType: params.jobType,
|
|
62
|
+
userId: params.userId,
|
|
63
|
+
title: params.title,
|
|
64
|
+
totalChildren: params.childCount,
|
|
65
|
+
childProgressMode: params.childProgressMode,
|
|
66
|
+
metadata: params.metadata,
|
|
67
|
+
ttlSeconds: params.ttlSeconds,
|
|
68
|
+
});
|
|
69
|
+
return new Job(response, this.http);
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Create a child job under a parent
|
|
73
|
+
*/
|
|
74
|
+
createChild: async (params) => {
|
|
75
|
+
const response = await this.http.post('/v1/jobs', {
|
|
76
|
+
jobType: params.jobType,
|
|
77
|
+
userId: params.userId,
|
|
78
|
+
title: params.title,
|
|
79
|
+
parentJobId: params.parentJobId,
|
|
80
|
+
childIndex: params.childIndex,
|
|
81
|
+
metadata: params.metadata,
|
|
82
|
+
ttlSeconds: params.ttlSeconds,
|
|
83
|
+
});
|
|
84
|
+
return new Job(response, this.http);
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Get a parent job with all its children
|
|
88
|
+
*/
|
|
89
|
+
getWithChildren: async (parentJobId) => {
|
|
90
|
+
const response = await this.http.get(`/v1/jobs/${parentJobId}/children`);
|
|
91
|
+
return {
|
|
92
|
+
parent: new Job(response.parent, this.http),
|
|
93
|
+
children: response.children,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Create a batch of jobs (parent + children) in one go
|
|
98
|
+
* Returns the parent job and all child jobs
|
|
99
|
+
*/
|
|
100
|
+
createBatch: async (params) => {
|
|
101
|
+
// Create parent job first
|
|
102
|
+
const parent = await this.jobs.createParent({
|
|
103
|
+
jobType: params.jobType,
|
|
104
|
+
userId: params.userId,
|
|
105
|
+
title: params.parentTitle,
|
|
106
|
+
childCount: params.childTitles.length,
|
|
107
|
+
childProgressMode: params.childProgressMode,
|
|
108
|
+
metadata: params.metadata,
|
|
109
|
+
ttlSeconds: params.ttlSeconds,
|
|
110
|
+
});
|
|
111
|
+
// Create all children in parallel
|
|
112
|
+
const childPromises = params.childTitles.map((title, index) => this.jobs.createChild({
|
|
113
|
+
parentJobId: parent.id,
|
|
114
|
+
childIndex: index,
|
|
115
|
+
jobType: params.jobType,
|
|
116
|
+
userId: params.userId,
|
|
117
|
+
title,
|
|
118
|
+
ttlSeconds: params.ttlSeconds,
|
|
119
|
+
}));
|
|
120
|
+
const children = await Promise.all(childPromises);
|
|
121
|
+
// Refresh parent to get updated counters
|
|
122
|
+
await parent.refresh();
|
|
123
|
+
return { parent, children };
|
|
124
|
+
},
|
|
56
125
|
};
|
|
57
126
|
}
|
|
58
127
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAwBvC,MAAM,OAAO,WAAW;IACL,IAAI,CAAa;IACjB,MAAM,CAAwB;IAE/C,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,sBAAsB;YACjD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC;YAClC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;SAC7B,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO;YACL;;eAEG;YACH,KAAK,EAAE,KAAK,EAAE,MAAsB,EAAgB,EAAE;gBACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAc,UAAU,EAAE,MAAM,CAAC,CAAC;gBACvE,OAAO,IAAI,GAAG,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,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;oBAC1C,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,KAAK,EAAE,MAAM,CAAC,WAAW;oBACzB,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM;oBACrC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;oBAC3C,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,MAAM,CAAC,UAAU;iBAC9B,CAAC,CAAC;gBAEH,kCAAkC;gBAClC,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC5D,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;oBACpB,WAAW,EAAE,MAAM,CAAC,EAAE;oBACtB,UAAU,EAAE,KAAK;oBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,KAAK;oBACL,UAAU,EAAE,MAAM,CAAC,UAAU;iBAC9B,CAAC,CACH,CAAC;gBAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAElD,yCAAyC;gBACzC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC9B,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { SeennClient } from './client.js';
|
|
|
2
2
|
export type { SeennConfig } from './client.js';
|
|
3
3
|
export { Job } from './job.js';
|
|
4
4
|
export type { JobStatus, JobData, ProgressOptions, CompleteOptions, FailOptions } from './job.js';
|
|
5
|
-
export type { StartJobParams, ProgressParams, CompleteParams, FailParams, QueueInfo, StageInfo, JobResult, JobError, } from './types.js';
|
|
5
|
+
export type { StartJobParams, ProgressParams, CompleteParams, FailParams, QueueInfo, StageInfo, JobResult, JobError, ChildProgressMode, ChildJobSummary, ParentInfo, ChildrenStats, CreateParentParams, CreateChildParams, CreateBatchParams, ParentWithChildren, } from './types.js';
|
|
6
6
|
export { SeennError, RateLimitError, ValidationError, NotFoundError } from './errors.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElG,YAAY,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElG,YAAY,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EAER,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAuB/B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/job.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from './http.js';
|
|
2
|
-
import type { JobResponse, QueueInfo, StageInfo, JobResult, JobError } from './types.js';
|
|
2
|
+
import type { JobResponse, QueueInfo, StageInfo, JobResult, JobError, ParentInfo, ChildrenStats, ChildProgressMode } from './types.js';
|
|
3
3
|
export type JobStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
4
4
|
export interface JobData {
|
|
5
5
|
id: string;
|
|
@@ -19,6 +19,9 @@ export interface JobData {
|
|
|
19
19
|
createdAt: Date;
|
|
20
20
|
updatedAt: Date;
|
|
21
21
|
completedAt?: Date;
|
|
22
|
+
parent?: ParentInfo;
|
|
23
|
+
children?: ChildrenStats;
|
|
24
|
+
childProgressMode?: ChildProgressMode;
|
|
22
25
|
}
|
|
23
26
|
export interface ProgressOptions {
|
|
24
27
|
message?: string;
|
|
@@ -56,6 +59,9 @@ export declare class Job implements JobData {
|
|
|
56
59
|
readonly createdAt: Date;
|
|
57
60
|
updatedAt: Date;
|
|
58
61
|
completedAt?: Date;
|
|
62
|
+
parent?: ParentInfo;
|
|
63
|
+
children?: ChildrenStats;
|
|
64
|
+
childProgressMode?: ChildProgressMode;
|
|
59
65
|
private readonly http;
|
|
60
66
|
constructor(data: JobResponse, http: HttpClient);
|
|
61
67
|
/**
|
|
@@ -78,6 +84,24 @@ export declare class Job implements JobData {
|
|
|
78
84
|
* Check if job is in a terminal state
|
|
79
85
|
*/
|
|
80
86
|
get isTerminal(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Check if this is a parent job (has children)
|
|
89
|
+
*/
|
|
90
|
+
get isParent(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Check if this is a child job (has a parent)
|
|
93
|
+
*/
|
|
94
|
+
get isChild(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get child progress summary (only for parent jobs)
|
|
97
|
+
*/
|
|
98
|
+
get childProgress(): {
|
|
99
|
+
completed: number;
|
|
100
|
+
failed: number;
|
|
101
|
+
running: number;
|
|
102
|
+
pending: number;
|
|
103
|
+
total: number;
|
|
104
|
+
} | null;
|
|
81
105
|
/**
|
|
82
106
|
* Get plain object representation
|
|
83
107
|
*/
|
package/dist/job.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EAIX,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EAIX,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,aAAa,EAC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EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CASjH;IAED;;OAEG;IACH,MAAM,IAAI,OAAO;IAyBjB,OAAO,CAAC,kBAAkB;CAgB3B"}
|
package/dist/job.js
CHANGED
|
@@ -19,6 +19,10 @@ export class Job {
|
|
|
19
19
|
createdAt;
|
|
20
20
|
updatedAt;
|
|
21
21
|
completedAt;
|
|
22
|
+
// Parent-child fields
|
|
23
|
+
parent;
|
|
24
|
+
children;
|
|
25
|
+
childProgressMode;
|
|
22
26
|
http;
|
|
23
27
|
constructor(data, http) {
|
|
24
28
|
this.id = data.id;
|
|
@@ -38,6 +42,10 @@ export class Job {
|
|
|
38
42
|
this.createdAt = new Date(data.createdAt);
|
|
39
43
|
this.updatedAt = new Date(data.updatedAt);
|
|
40
44
|
this.completedAt = data.completedAt ? new Date(data.completedAt) : undefined;
|
|
45
|
+
// Parent-child fields
|
|
46
|
+
this.parent = data.parent;
|
|
47
|
+
this.children = data.children;
|
|
48
|
+
this.childProgressMode = data.childProgressMode;
|
|
41
49
|
this.http = http;
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
@@ -84,6 +92,32 @@ export class Job {
|
|
|
84
92
|
get isTerminal() {
|
|
85
93
|
return this.status === 'completed' || this.status === 'failed';
|
|
86
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if this is a parent job (has children)
|
|
97
|
+
*/
|
|
98
|
+
get isParent() {
|
|
99
|
+
return this.children !== undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if this is a child job (has a parent)
|
|
103
|
+
*/
|
|
104
|
+
get isChild() {
|
|
105
|
+
return this.parent !== undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get child progress summary (only for parent jobs)
|
|
109
|
+
*/
|
|
110
|
+
get childProgress() {
|
|
111
|
+
if (!this.children)
|
|
112
|
+
return null;
|
|
113
|
+
return {
|
|
114
|
+
completed: this.children.completed,
|
|
115
|
+
failed: this.children.failed,
|
|
116
|
+
running: this.children.running,
|
|
117
|
+
pending: this.children.pending,
|
|
118
|
+
total: this.children.total,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
87
121
|
/**
|
|
88
122
|
* Get plain object representation
|
|
89
123
|
*/
|
|
@@ -106,6 +140,9 @@ export class Job {
|
|
|
106
140
|
createdAt: this.createdAt,
|
|
107
141
|
updatedAt: this.updatedAt,
|
|
108
142
|
completedAt: this.completedAt,
|
|
143
|
+
parent: this.parent,
|
|
144
|
+
children: this.children,
|
|
145
|
+
childProgressMode: this.childProgressMode,
|
|
109
146
|
};
|
|
110
147
|
}
|
|
111
148
|
updateFromResponse(response) {
|
|
@@ -120,6 +157,9 @@ export class Job {
|
|
|
120
157
|
this.estimatedCompletionAt = response.estimatedCompletionAt;
|
|
121
158
|
this.updatedAt = new Date(response.updatedAt);
|
|
122
159
|
this.completedAt = response.completedAt ? new Date(response.completedAt) : undefined;
|
|
160
|
+
this.parent = response.parent;
|
|
161
|
+
this.children = response.children;
|
|
162
|
+
this.childProgressMode = response.childProgressMode;
|
|
123
163
|
}
|
|
124
164
|
}
|
|
125
165
|
//# sourceMappingURL=job.js.map
|
package/dist/job.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"
|
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AC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IACtD,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type ChildProgressMode = 'average' | 'weighted' | 'sequential';
|
|
1
2
|
export interface StartJobParams {
|
|
2
3
|
/** Unique job type identifier (e.g., 'video-generation', 'image-processing') */
|
|
3
4
|
jobType: string;
|
|
@@ -15,6 +16,14 @@ export interface StartJobParams {
|
|
|
15
16
|
estimatedCompletionAt?: string;
|
|
16
17
|
/** Optional TTL in seconds (default: 30 days) */
|
|
17
18
|
ttlSeconds?: number;
|
|
19
|
+
/** Parent job ID (for child jobs) */
|
|
20
|
+
parentJobId?: string;
|
|
21
|
+
/** 0-based index within parent (for child jobs) */
|
|
22
|
+
childIndex?: number;
|
|
23
|
+
/** Total number of children (for parent jobs) */
|
|
24
|
+
totalChildren?: number;
|
|
25
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
26
|
+
childProgressMode?: ChildProgressMode;
|
|
18
27
|
}
|
|
19
28
|
export interface ProgressParams {
|
|
20
29
|
/** Progress percentage (0-100) */
|
|
@@ -76,6 +85,89 @@ export interface JobError {
|
|
|
76
85
|
/** Additional error details */
|
|
77
86
|
details?: Record<string, unknown>;
|
|
78
87
|
}
|
|
88
|
+
/** Summary of a child job */
|
|
89
|
+
export interface ChildJobSummary {
|
|
90
|
+
id: string;
|
|
91
|
+
childIndex: number;
|
|
92
|
+
title: string;
|
|
93
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
94
|
+
progress: number;
|
|
95
|
+
message?: string;
|
|
96
|
+
result?: JobResult;
|
|
97
|
+
error?: JobError;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
updatedAt: string;
|
|
100
|
+
completedAt?: string;
|
|
101
|
+
}
|
|
102
|
+
/** Parent info included in child job responses */
|
|
103
|
+
export interface ParentInfo {
|
|
104
|
+
parentJobId: string;
|
|
105
|
+
childIndex: number;
|
|
106
|
+
}
|
|
107
|
+
/** Children stats included in parent job responses */
|
|
108
|
+
export interface ChildrenStats {
|
|
109
|
+
total: number;
|
|
110
|
+
completed: number;
|
|
111
|
+
failed: number;
|
|
112
|
+
running: number;
|
|
113
|
+
pending: number;
|
|
114
|
+
}
|
|
115
|
+
/** Parameters for creating a parent job */
|
|
116
|
+
export interface CreateParentParams {
|
|
117
|
+
/** Unique job type identifier */
|
|
118
|
+
jobType: string;
|
|
119
|
+
/** User ID who owns this job */
|
|
120
|
+
userId: string;
|
|
121
|
+
/** Human-readable title for the parent job */
|
|
122
|
+
title: string;
|
|
123
|
+
/** Total number of children this parent will have */
|
|
124
|
+
childCount: number;
|
|
125
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
126
|
+
childProgressMode?: ChildProgressMode;
|
|
127
|
+
/** Optional metadata */
|
|
128
|
+
metadata?: Record<string, unknown>;
|
|
129
|
+
/** Optional TTL in seconds */
|
|
130
|
+
ttlSeconds?: number;
|
|
131
|
+
}
|
|
132
|
+
/** Parameters for creating a child job */
|
|
133
|
+
export interface CreateChildParams {
|
|
134
|
+
/** Parent job ID */
|
|
135
|
+
parentJobId: string;
|
|
136
|
+
/** 0-based index within parent */
|
|
137
|
+
childIndex: number;
|
|
138
|
+
/** Unique job type identifier */
|
|
139
|
+
jobType: string;
|
|
140
|
+
/** User ID who owns this job */
|
|
141
|
+
userId: string;
|
|
142
|
+
/** Human-readable title for the child job */
|
|
143
|
+
title: string;
|
|
144
|
+
/** Optional metadata */
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
/** Optional TTL in seconds */
|
|
147
|
+
ttlSeconds?: number;
|
|
148
|
+
}
|
|
149
|
+
/** Parameters for creating a batch of jobs */
|
|
150
|
+
export interface CreateBatchParams {
|
|
151
|
+
/** Unique job type identifier for all jobs */
|
|
152
|
+
jobType: string;
|
|
153
|
+
/** User ID who owns these jobs */
|
|
154
|
+
userId: string;
|
|
155
|
+
/** Human-readable title for the parent job */
|
|
156
|
+
parentTitle: string;
|
|
157
|
+
/** Titles for each child job */
|
|
158
|
+
childTitles: string[];
|
|
159
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
160
|
+
childProgressMode?: ChildProgressMode;
|
|
161
|
+
/** Optional metadata for parent job */
|
|
162
|
+
metadata?: Record<string, unknown>;
|
|
163
|
+
/** Optional TTL in seconds */
|
|
164
|
+
ttlSeconds?: number;
|
|
165
|
+
}
|
|
166
|
+
/** Parent job with all its children */
|
|
167
|
+
export interface ParentWithChildren {
|
|
168
|
+
parent: JobResponse;
|
|
169
|
+
children: ChildJobSummary[];
|
|
170
|
+
}
|
|
79
171
|
export interface JobResponse {
|
|
80
172
|
id: string;
|
|
81
173
|
appId: string;
|
|
@@ -94,5 +186,11 @@ export interface JobResponse {
|
|
|
94
186
|
createdAt: string;
|
|
95
187
|
updatedAt: string;
|
|
96
188
|
completedAt?: string;
|
|
189
|
+
/** Parent info (if this is a child job) */
|
|
190
|
+
parent?: ParentInfo;
|
|
191
|
+
/** Children stats (if this is a parent job) */
|
|
192
|
+
children?: ChildrenStats;
|
|
193
|
+
/** Child progress mode (if this is a parent job) */
|
|
194
|
+
childProgressMode?: ChildProgressMode;
|
|
97
195
|
}
|
|
98
196
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAItE,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,oDAAoD;IACpD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,2BAA2B;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sDAAsD;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AM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seenn/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Seenn Node.js Backend SDK - Open source job state transport for real-time progress tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"type": "git",
|
|
52
52
|
"url": "https://github.com/seenn-io/node.git"
|
|
53
53
|
},
|
|
54
|
-
"homepage": "https://seenn
|
|
54
|
+
"homepage": "https://github.com/seenn-io/node#readme",
|
|
55
55
|
"bugs": {
|
|
56
56
|
"url": "https://github.com/seenn-io/node/issues"
|
|
57
57
|
},
|
package/src/client.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Job } from './job.js';
|
|
2
2
|
import { HttpClient } from './http.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
StartJobParams,
|
|
5
|
+
JobResponse,
|
|
6
|
+
CreateParentParams,
|
|
7
|
+
CreateChildParams,
|
|
8
|
+
CreateBatchParams,
|
|
9
|
+
ParentWithChildren,
|
|
10
|
+
ChildJobSummary,
|
|
11
|
+
} from './types.js';
|
|
4
12
|
|
|
5
13
|
export interface SeennConfig {
|
|
6
14
|
/** API key (sk_live_xxx or sk_test_xxx) */
|
|
@@ -78,6 +86,87 @@ export class SeennClient {
|
|
|
78
86
|
nextCursor: response.nextCursor,
|
|
79
87
|
};
|
|
80
88
|
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create a parent job (batch container)
|
|
92
|
+
*/
|
|
93
|
+
createParent: async (params: CreateParentParams): Promise<Job> => {
|
|
94
|
+
const response = await this.http.post<JobResponse>('/v1/jobs', {
|
|
95
|
+
jobType: params.jobType,
|
|
96
|
+
userId: params.userId,
|
|
97
|
+
title: params.title,
|
|
98
|
+
totalChildren: params.childCount,
|
|
99
|
+
childProgressMode: params.childProgressMode,
|
|
100
|
+
metadata: params.metadata,
|
|
101
|
+
ttlSeconds: params.ttlSeconds,
|
|
102
|
+
});
|
|
103
|
+
return new Job(response, this.http);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Create a child job under a parent
|
|
108
|
+
*/
|
|
109
|
+
createChild: async (params: CreateChildParams): Promise<Job> => {
|
|
110
|
+
const response = await this.http.post<JobResponse>('/v1/jobs', {
|
|
111
|
+
jobType: params.jobType,
|
|
112
|
+
userId: params.userId,
|
|
113
|
+
title: params.title,
|
|
114
|
+
parentJobId: params.parentJobId,
|
|
115
|
+
childIndex: params.childIndex,
|
|
116
|
+
metadata: params.metadata,
|
|
117
|
+
ttlSeconds: params.ttlSeconds,
|
|
118
|
+
});
|
|
119
|
+
return new Job(response, this.http);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get a parent job with all its children
|
|
124
|
+
*/
|
|
125
|
+
getWithChildren: async (parentJobId: string): Promise<{ parent: Job; children: ChildJobSummary[] }> => {
|
|
126
|
+
const response = await this.http.get<ParentWithChildren>(
|
|
127
|
+
`/v1/jobs/${parentJobId}/children`
|
|
128
|
+
);
|
|
129
|
+
return {
|
|
130
|
+
parent: new Job(response.parent, this.http),
|
|
131
|
+
children: response.children,
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Create a batch of jobs (parent + children) in one go
|
|
137
|
+
* Returns the parent job and all child jobs
|
|
138
|
+
*/
|
|
139
|
+
createBatch: async (params: CreateBatchParams): Promise<{ parent: Job; children: Job[] }> => {
|
|
140
|
+
// Create parent job first
|
|
141
|
+
const parent = await this.jobs.createParent({
|
|
142
|
+
jobType: params.jobType,
|
|
143
|
+
userId: params.userId,
|
|
144
|
+
title: params.parentTitle,
|
|
145
|
+
childCount: params.childTitles.length,
|
|
146
|
+
childProgressMode: params.childProgressMode,
|
|
147
|
+
metadata: params.metadata,
|
|
148
|
+
ttlSeconds: params.ttlSeconds,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Create all children in parallel
|
|
152
|
+
const childPromises = params.childTitles.map((title, index) =>
|
|
153
|
+
this.jobs.createChild({
|
|
154
|
+
parentJobId: parent.id,
|
|
155
|
+
childIndex: index,
|
|
156
|
+
jobType: params.jobType,
|
|
157
|
+
userId: params.userId,
|
|
158
|
+
title,
|
|
159
|
+
ttlSeconds: params.ttlSeconds,
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const children = await Promise.all(childPromises);
|
|
164
|
+
|
|
165
|
+
// Refresh parent to get updated counters
|
|
166
|
+
await parent.refresh();
|
|
167
|
+
|
|
168
|
+
return { parent, children };
|
|
169
|
+
},
|
|
81
170
|
};
|
|
82
171
|
}
|
|
83
172
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,15 @@ export type {
|
|
|
15
15
|
StageInfo,
|
|
16
16
|
JobResult,
|
|
17
17
|
JobError,
|
|
18
|
+
// Parent-child types
|
|
19
|
+
ChildProgressMode,
|
|
20
|
+
ChildJobSummary,
|
|
21
|
+
ParentInfo,
|
|
22
|
+
ChildrenStats,
|
|
23
|
+
CreateParentParams,
|
|
24
|
+
CreateChildParams,
|
|
25
|
+
CreateBatchParams,
|
|
26
|
+
ParentWithChildren,
|
|
18
27
|
} from './types.js';
|
|
19
28
|
|
|
20
29
|
export { SeennError, RateLimitError, ValidationError, NotFoundError } from './errors.js';
|
package/src/job.ts
CHANGED
|
@@ -8,6 +8,9 @@ import type {
|
|
|
8
8
|
StageInfo,
|
|
9
9
|
JobResult,
|
|
10
10
|
JobError,
|
|
11
|
+
ParentInfo,
|
|
12
|
+
ChildrenStats,
|
|
13
|
+
ChildProgressMode,
|
|
11
14
|
} from './types.js';
|
|
12
15
|
|
|
13
16
|
export type JobStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
@@ -30,6 +33,10 @@ export interface JobData {
|
|
|
30
33
|
createdAt: Date;
|
|
31
34
|
updatedAt: Date;
|
|
32
35
|
completedAt?: Date;
|
|
36
|
+
// Parent-child fields
|
|
37
|
+
parent?: ParentInfo;
|
|
38
|
+
children?: ChildrenStats;
|
|
39
|
+
childProgressMode?: ChildProgressMode;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
export interface ProgressOptions {
|
|
@@ -71,6 +78,10 @@ export class Job implements JobData {
|
|
|
71
78
|
readonly createdAt: Date;
|
|
72
79
|
updatedAt: Date;
|
|
73
80
|
completedAt?: Date;
|
|
81
|
+
// Parent-child fields
|
|
82
|
+
parent?: ParentInfo;
|
|
83
|
+
children?: ChildrenStats;
|
|
84
|
+
childProgressMode?: ChildProgressMode;
|
|
74
85
|
|
|
75
86
|
private readonly http: HttpClient;
|
|
76
87
|
|
|
@@ -92,6 +103,10 @@ export class Job implements JobData {
|
|
|
92
103
|
this.createdAt = new Date(data.createdAt);
|
|
93
104
|
this.updatedAt = new Date(data.updatedAt);
|
|
94
105
|
this.completedAt = data.completedAt ? new Date(data.completedAt) : undefined;
|
|
106
|
+
// Parent-child fields
|
|
107
|
+
this.parent = data.parent;
|
|
108
|
+
this.children = data.children;
|
|
109
|
+
this.childProgressMode = data.childProgressMode;
|
|
95
110
|
|
|
96
111
|
this.http = http;
|
|
97
112
|
}
|
|
@@ -160,6 +175,34 @@ export class Job implements JobData {
|
|
|
160
175
|
return this.status === 'completed' || this.status === 'failed';
|
|
161
176
|
}
|
|
162
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Check if this is a parent job (has children)
|
|
180
|
+
*/
|
|
181
|
+
get isParent(): boolean {
|
|
182
|
+
return this.children !== undefined;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Check if this is a child job (has a parent)
|
|
187
|
+
*/
|
|
188
|
+
get isChild(): boolean {
|
|
189
|
+
return this.parent !== undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Get child progress summary (only for parent jobs)
|
|
194
|
+
*/
|
|
195
|
+
get childProgress(): { completed: number; failed: number; running: number; pending: number; total: number } | null {
|
|
196
|
+
if (!this.children) return null;
|
|
197
|
+
return {
|
|
198
|
+
completed: this.children.completed,
|
|
199
|
+
failed: this.children.failed,
|
|
200
|
+
running: this.children.running,
|
|
201
|
+
pending: this.children.pending,
|
|
202
|
+
total: this.children.total,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
163
206
|
/**
|
|
164
207
|
* Get plain object representation
|
|
165
208
|
*/
|
|
@@ -182,6 +225,9 @@ export class Job implements JobData {
|
|
|
182
225
|
createdAt: this.createdAt,
|
|
183
226
|
updatedAt: this.updatedAt,
|
|
184
227
|
completedAt: this.completedAt,
|
|
228
|
+
parent: this.parent,
|
|
229
|
+
children: this.children,
|
|
230
|
+
childProgressMode: this.childProgressMode,
|
|
185
231
|
};
|
|
186
232
|
}
|
|
187
233
|
|
|
@@ -197,5 +243,8 @@ export class Job implements JobData {
|
|
|
197
243
|
this.estimatedCompletionAt = response.estimatedCompletionAt;
|
|
198
244
|
this.updatedAt = new Date(response.updatedAt);
|
|
199
245
|
this.completedAt = response.completedAt ? new Date(response.completedAt) : undefined;
|
|
246
|
+
this.parent = response.parent;
|
|
247
|
+
this.children = response.children;
|
|
248
|
+
this.childProgressMode = response.childProgressMode;
|
|
200
249
|
}
|
|
201
250
|
}
|
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 {
|
|
@@ -17,6 +20,14 @@ export interface StartJobParams {
|
|
|
17
20
|
estimatedCompletionAt?: string;
|
|
18
21
|
/** Optional TTL in seconds (default: 30 days) */
|
|
19
22
|
ttlSeconds?: number;
|
|
23
|
+
/** Parent job ID (for child jobs) */
|
|
24
|
+
parentJobId?: string;
|
|
25
|
+
/** 0-based index within parent (for child jobs) */
|
|
26
|
+
childIndex?: number;
|
|
27
|
+
/** Total number of children (for parent jobs) */
|
|
28
|
+
totalChildren?: number;
|
|
29
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
30
|
+
childProgressMode?: ChildProgressMode;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export interface ProgressParams {
|
|
@@ -88,6 +99,98 @@ export interface JobError {
|
|
|
88
99
|
details?: Record<string, unknown>;
|
|
89
100
|
}
|
|
90
101
|
|
|
102
|
+
// Parent-child types
|
|
103
|
+
|
|
104
|
+
/** Summary of a child job */
|
|
105
|
+
export interface ChildJobSummary {
|
|
106
|
+
id: string;
|
|
107
|
+
childIndex: number;
|
|
108
|
+
title: string;
|
|
109
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
110
|
+
progress: number;
|
|
111
|
+
message?: string;
|
|
112
|
+
result?: JobResult;
|
|
113
|
+
error?: JobError;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt: string;
|
|
116
|
+
completedAt?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Parent info included in child job responses */
|
|
120
|
+
export interface ParentInfo {
|
|
121
|
+
parentJobId: string;
|
|
122
|
+
childIndex: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Children stats included in parent job responses */
|
|
126
|
+
export interface ChildrenStats {
|
|
127
|
+
total: number;
|
|
128
|
+
completed: number;
|
|
129
|
+
failed: number;
|
|
130
|
+
running: number;
|
|
131
|
+
pending: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Parameters for creating a parent job */
|
|
135
|
+
export interface CreateParentParams {
|
|
136
|
+
/** Unique job type identifier */
|
|
137
|
+
jobType: string;
|
|
138
|
+
/** User ID who owns this job */
|
|
139
|
+
userId: string;
|
|
140
|
+
/** Human-readable title for the parent job */
|
|
141
|
+
title: string;
|
|
142
|
+
/** Total number of children this parent will have */
|
|
143
|
+
childCount: number;
|
|
144
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
145
|
+
childProgressMode?: ChildProgressMode;
|
|
146
|
+
/** Optional metadata */
|
|
147
|
+
metadata?: Record<string, unknown>;
|
|
148
|
+
/** Optional TTL in seconds */
|
|
149
|
+
ttlSeconds?: number;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Parameters for creating a child job */
|
|
153
|
+
export interface CreateChildParams {
|
|
154
|
+
/** Parent job ID */
|
|
155
|
+
parentJobId: string;
|
|
156
|
+
/** 0-based index within parent */
|
|
157
|
+
childIndex: number;
|
|
158
|
+
/** Unique job type identifier */
|
|
159
|
+
jobType: string;
|
|
160
|
+
/** User ID who owns this job */
|
|
161
|
+
userId: string;
|
|
162
|
+
/** Human-readable title for the child job */
|
|
163
|
+
title: string;
|
|
164
|
+
/** Optional metadata */
|
|
165
|
+
metadata?: Record<string, unknown>;
|
|
166
|
+
/** Optional TTL in seconds */
|
|
167
|
+
ttlSeconds?: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Parameters for creating a batch of jobs */
|
|
171
|
+
export interface CreateBatchParams {
|
|
172
|
+
/** Unique job type identifier for all jobs */
|
|
173
|
+
jobType: string;
|
|
174
|
+
/** User ID who owns these jobs */
|
|
175
|
+
userId: string;
|
|
176
|
+
/** Human-readable title for the parent job */
|
|
177
|
+
parentTitle: string;
|
|
178
|
+
/** Titles for each child job */
|
|
179
|
+
childTitles: string[];
|
|
180
|
+
/** How to calculate parent progress from children (default: 'average') */
|
|
181
|
+
childProgressMode?: ChildProgressMode;
|
|
182
|
+
/** Optional metadata for parent job */
|
|
183
|
+
metadata?: Record<string, unknown>;
|
|
184
|
+
/** Optional TTL in seconds */
|
|
185
|
+
ttlSeconds?: number;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Parent job with all its children */
|
|
189
|
+
export interface ParentWithChildren {
|
|
190
|
+
parent: JobResponse;
|
|
191
|
+
children: ChildJobSummary[];
|
|
192
|
+
}
|
|
193
|
+
|
|
91
194
|
// API Response Types
|
|
92
195
|
|
|
93
196
|
export interface JobResponse {
|
|
@@ -108,4 +211,10 @@ export interface JobResponse {
|
|
|
108
211
|
createdAt: string;
|
|
109
212
|
updatedAt: string;
|
|
110
213
|
completedAt?: string;
|
|
214
|
+
/** Parent info (if this is a child job) */
|
|
215
|
+
parent?: ParentInfo;
|
|
216
|
+
/** Children stats (if this is a parent job) */
|
|
217
|
+
children?: ChildrenStats;
|
|
218
|
+
/** Child progress mode (if this is a parent job) */
|
|
219
|
+
childProgressMode?: ChildProgressMode;
|
|
111
220
|
}
|