@acedatacloud/sdk 2026.727.0 → 2026.727.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/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/runtime/tasks.ts +20 -9
package/package.json
CHANGED
package/src/runtime/tasks.ts
CHANGED
|
@@ -184,16 +184,32 @@ export class TaskHandle {
|
|
|
184
184
|
return taskProgress(this._result);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Fetch current task state, remembering it once terminal.
|
|
189
|
+
*
|
|
190
|
+
* A caller that drives its own poll loop — checking status between polls so it
|
|
191
|
+
* can report progress — only ever calls this. Without recording here, urls()
|
|
192
|
+
* and result() stay empty after the task has plainly finished.
|
|
193
|
+
*/
|
|
187
194
|
async get(): Promise<Record<string, unknown>> {
|
|
188
|
-
|
|
195
|
+
const state = await this.transport.request('POST', this.pollEndpoint, {
|
|
189
196
|
json: { id: this.id, action: 'retrieve' },
|
|
190
197
|
});
|
|
198
|
+
this.accept(state);
|
|
199
|
+
return state;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private accept(state: Record<string, unknown>): void {
|
|
203
|
+
const status = taskStatus(state);
|
|
204
|
+
if (status === 'succeeded' || status === 'failed') {
|
|
205
|
+
this._result = state;
|
|
206
|
+
}
|
|
191
207
|
}
|
|
192
208
|
|
|
193
209
|
async isCompleted(): Promise<boolean> {
|
|
194
210
|
if (this.done) return true;
|
|
195
|
-
|
|
196
|
-
return
|
|
211
|
+
await this.get(); // records a terminal state as a side effect
|
|
212
|
+
return this.done;
|
|
197
213
|
}
|
|
198
214
|
|
|
199
215
|
async wait(opts: TaskHandleOptions = {}): Promise<Record<string, unknown>> {
|
|
@@ -205,12 +221,7 @@ export class TaskHandle {
|
|
|
205
221
|
|
|
206
222
|
while (Date.now() - start < maxWait) {
|
|
207
223
|
const state = await this.get();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (status === 'succeeded' || status === 'failed') {
|
|
211
|
-
this._result = state;
|
|
212
|
-
return state;
|
|
213
|
-
}
|
|
224
|
+
if (this.done) return state;
|
|
214
225
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
215
226
|
}
|
|
216
227
|
throw new Error(`Task ${this.id} did not complete within ${maxWait}ms`);
|