@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.mjs CHANGED
@@ -548,15 +548,30 @@ var TaskHandle = class {
548
548
  progress() {
549
549
  return taskProgress(this._result);
550
550
  }
551
+ /**
552
+ * Fetch current task state, remembering it once terminal.
553
+ *
554
+ * A caller that drives its own poll loop — checking status between polls so it
555
+ * can report progress — only ever calls this. Without recording here, urls()
556
+ * and result() stay empty after the task has plainly finished.
557
+ */
551
558
  async get() {
552
- return this.transport.request("POST", this.pollEndpoint, {
559
+ const state = await this.transport.request("POST", this.pollEndpoint, {
553
560
  json: { id: this.id, action: "retrieve" }
554
561
  });
562
+ this.accept(state);
563
+ return state;
564
+ }
565
+ accept(state) {
566
+ const status = taskStatus(state);
567
+ if (status === "succeeded" || status === "failed") {
568
+ this._result = state;
569
+ }
555
570
  }
556
571
  async isCompleted() {
557
572
  if (this.done) return true;
558
- const status = taskStatus(await this.get());
559
- return status === "succeeded" || status === "failed";
573
+ await this.get();
574
+ return this.done;
560
575
  }
561
576
  async wait(opts = {}) {
562
577
  if (this._result !== null) return this._result;
@@ -565,11 +580,7 @@ var TaskHandle = class {
565
580
  const start = Date.now();
566
581
  while (Date.now() - start < maxWait) {
567
582
  const state = await this.get();
568
- const status = taskStatus(state);
569
- if (status === "succeeded" || status === "failed") {
570
- this._result = state;
571
- return state;
572
- }
583
+ if (this.done) return state;
573
584
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
574
585
  }
575
586
  throw new Error(`Task ${this.id} did not complete within ${maxWait}ms`);