@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 CHANGED
@@ -204,7 +204,15 @@ declare class TaskHandle {
204
204
  /** Artifact URLs, once completed. */
205
205
  urls(): string[];
206
206
  progress(): number | null;
207
+ /**
208
+ * Fetch current task state, remembering it once terminal.
209
+ *
210
+ * A caller that drives its own poll loop — checking status between polls so it
211
+ * can report progress — only ever calls this. Without recording here, urls()
212
+ * and result() stay empty after the task has plainly finished.
213
+ */
207
214
  get(): Promise<Record<string, unknown>>;
215
+ private accept;
208
216
  isCompleted(): Promise<boolean>;
209
217
  wait(opts?: TaskHandleOptions): Promise<Record<string, unknown>>;
210
218
  get result(): Record<string, unknown> | null;
package/dist/index.d.ts CHANGED
@@ -204,7 +204,15 @@ declare class TaskHandle {
204
204
  /** Artifact URLs, once completed. */
205
205
  urls(): string[];
206
206
  progress(): number | null;
207
+ /**
208
+ * Fetch current task state, remembering it once terminal.
209
+ *
210
+ * A caller that drives its own poll loop — checking status between polls so it
211
+ * can report progress — only ever calls this. Without recording here, urls()
212
+ * and result() stay empty after the task has plainly finished.
213
+ */
207
214
  get(): Promise<Record<string, unknown>>;
215
+ private accept;
208
216
  isCompleted(): Promise<boolean>;
209
217
  wait(opts?: TaskHandleOptions): Promise<Record<string, unknown>>;
210
218
  get result(): Record<string, unknown> | null;
package/dist/index.js CHANGED
@@ -596,15 +596,30 @@ var TaskHandle = class {
596
596
  progress() {
597
597
  return taskProgress(this._result);
598
598
  }
599
+ /**
600
+ * Fetch current task state, remembering it once terminal.
601
+ *
602
+ * A caller that drives its own poll loop — checking status between polls so it
603
+ * can report progress — only ever calls this. Without recording here, urls()
604
+ * and result() stay empty after the task has plainly finished.
605
+ */
599
606
  async get() {
600
- return this.transport.request("POST", this.pollEndpoint, {
607
+ const state = await this.transport.request("POST", this.pollEndpoint, {
601
608
  json: { id: this.id, action: "retrieve" }
602
609
  });
610
+ this.accept(state);
611
+ return state;
612
+ }
613
+ accept(state) {
614
+ const status = taskStatus(state);
615
+ if (status === "succeeded" || status === "failed") {
616
+ this._result = state;
617
+ }
603
618
  }
604
619
  async isCompleted() {
605
620
  if (this.done) return true;
606
- const status = taskStatus(await this.get());
607
- return status === "succeeded" || status === "failed";
621
+ await this.get();
622
+ return this.done;
608
623
  }
609
624
  async wait(opts = {}) {
610
625
  if (this._result !== null) return this._result;
@@ -613,11 +628,7 @@ var TaskHandle = class {
613
628
  const start = Date.now();
614
629
  while (Date.now() - start < maxWait) {
615
630
  const state = await this.get();
616
- const status = taskStatus(state);
617
- if (status === "succeeded" || status === "failed") {
618
- this._result = state;
619
- return state;
620
- }
631
+ if (this.done) return state;
621
632
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
622
633
  }
623
634
  throw new Error(`Task ${this.id} did not complete within ${maxWait}ms`);