@getanyapi/sdk 0.9.6 → 0.9.7

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.cts CHANGED
@@ -10,6 +10,26 @@ interface RunResult<T> {
10
10
  costUsd: number;
11
11
  /** Number of result rows returned (present on per-result SKUs). */
12
12
  items?: number;
13
+ /**
14
+ * True when the gateway served a stored response for a repeated Idempotency-Key instead
15
+ * of running the SKU again. A replay is not billed twice. Always present on the wire.
16
+ *
17
+ * A replay whose stored payload is no longer retained (a 24h TTL expiry, or a payload
18
+ * that exceeded the storage size cap) arrives with the metadata only and `output` null,
19
+ * which {@link unwrap} rejects. See SPEC 2.3.
20
+ */
21
+ replayed: boolean;
22
+ /**
23
+ * Opaque handle to the full unshaped result, cached for about 15 minutes, so it can be
24
+ * re-read and re-shaped for free via GET /v1/results/{id}. Absent when the gateway did
25
+ * not cache the result.
26
+ */
27
+ resultId?: string;
28
+ /**
29
+ * Why a requested jq reshape did not apply. The run was still billed and `output` carries
30
+ * the full unshaped result. Absent when no jq was requested or it succeeded.
31
+ */
32
+ jqError?: string;
13
33
  /** Optional server nudge when a large result was returned untrimmed. */
14
34
  hint?: string;
15
35
  }
@@ -37,6 +57,26 @@ interface BareRunResult<T> {
37
57
  costUsd: number;
38
58
  /** Number of result rows returned (present on per-result SKUs). */
39
59
  items?: number;
60
+ /**
61
+ * True when the gateway served a stored response for a repeated Idempotency-Key instead
62
+ * of running the SKU again. A replay is not billed twice. Always present on the wire.
63
+ *
64
+ * A replay whose stored payload is no longer retained (a 24h TTL expiry, or a payload
65
+ * that exceeded the storage size cap) arrives with the metadata only and `output` null,
66
+ * which {@link unwrap} rejects. See SPEC 2.3.
67
+ */
68
+ replayed: boolean;
69
+ /**
70
+ * Opaque handle to the full unshaped result, cached for about 15 minutes, so it can be
71
+ * re-read and re-shaped for free via GET /v1/results/{id}. Absent when the gateway did
72
+ * not cache the result.
73
+ */
74
+ resultId?: string;
75
+ /**
76
+ * Why a requested jq reshape did not apply. The run was still billed and `output` carries
77
+ * the full unshaped result. Absent when no jq was requested or it succeeded.
78
+ */
79
+ jqError?: string;
40
80
  /** Optional server nudge when a large result was returned untrimmed. */
41
81
  hint?: string;
42
82
  }
@@ -45,7 +85,10 @@ interface BareRunResult<T> {
45
85
  * matching entity. Narrows Output<T> to T.
46
86
  *
47
87
  * Two overloads: a found-data RunResult may be empty (throws when found is false); a bare
48
- * result always carries its data (returns output directly, never throws).
88
+ * result always carries its data (returns output directly).
89
+ *
90
+ * Either shape throws AnyAPIError when `output` is null: an idempotent replay can outlive
91
+ * its stored payload, and the caller must not receive `null` typed as T. See SPEC 2.3.
49
92
  */
50
93
  declare function unwrap<T>(result: BareRunResult<T>): T;
51
94
  declare function unwrap<T>(result: RunResult<T>): T;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,26 @@ interface RunResult<T> {
10
10
  costUsd: number;
11
11
  /** Number of result rows returned (present on per-result SKUs). */
12
12
  items?: number;
13
+ /**
14
+ * True when the gateway served a stored response for a repeated Idempotency-Key instead
15
+ * of running the SKU again. A replay is not billed twice. Always present on the wire.
16
+ *
17
+ * A replay whose stored payload is no longer retained (a 24h TTL expiry, or a payload
18
+ * that exceeded the storage size cap) arrives with the metadata only and `output` null,
19
+ * which {@link unwrap} rejects. See SPEC 2.3.
20
+ */
21
+ replayed: boolean;
22
+ /**
23
+ * Opaque handle to the full unshaped result, cached for about 15 minutes, so it can be
24
+ * re-read and re-shaped for free via GET /v1/results/{id}. Absent when the gateway did
25
+ * not cache the result.
26
+ */
27
+ resultId?: string;
28
+ /**
29
+ * Why a requested jq reshape did not apply. The run was still billed and `output` carries
30
+ * the full unshaped result. Absent when no jq was requested or it succeeded.
31
+ */
32
+ jqError?: string;
13
33
  /** Optional server nudge when a large result was returned untrimmed. */
14
34
  hint?: string;
15
35
  }
@@ -37,6 +57,26 @@ interface BareRunResult<T> {
37
57
  costUsd: number;
38
58
  /** Number of result rows returned (present on per-result SKUs). */
39
59
  items?: number;
60
+ /**
61
+ * True when the gateway served a stored response for a repeated Idempotency-Key instead
62
+ * of running the SKU again. A replay is not billed twice. Always present on the wire.
63
+ *
64
+ * A replay whose stored payload is no longer retained (a 24h TTL expiry, or a payload
65
+ * that exceeded the storage size cap) arrives with the metadata only and `output` null,
66
+ * which {@link unwrap} rejects. See SPEC 2.3.
67
+ */
68
+ replayed: boolean;
69
+ /**
70
+ * Opaque handle to the full unshaped result, cached for about 15 minutes, so it can be
71
+ * re-read and re-shaped for free via GET /v1/results/{id}. Absent when the gateway did
72
+ * not cache the result.
73
+ */
74
+ resultId?: string;
75
+ /**
76
+ * Why a requested jq reshape did not apply. The run was still billed and `output` carries
77
+ * the full unshaped result. Absent when no jq was requested or it succeeded.
78
+ */
79
+ jqError?: string;
40
80
  /** Optional server nudge when a large result was returned untrimmed. */
41
81
  hint?: string;
42
82
  }
@@ -45,7 +85,10 @@ interface BareRunResult<T> {
45
85
  * matching entity. Narrows Output<T> to T.
46
86
  *
47
87
  * Two overloads: a found-data RunResult may be empty (throws when found is false); a bare
48
- * result always carries its data (returns output directly, never throws).
88
+ * result always carries its data (returns output directly).
89
+ *
90
+ * Either shape throws AnyAPIError when `output` is null: an idempotent replay can outlive
91
+ * its stored payload, and the caller must not receive `null` typed as T. See SPEC 2.3.
49
92
  */
50
93
  declare function unwrap<T>(result: BareRunResult<T>): T;
51
94
  declare function unwrap<T>(result: RunResult<T>): T;
package/dist/index.js CHANGED
@@ -788,8 +788,12 @@ var AnyAPI = class {
788
788
  };
789
789
 
790
790
  // src/core/types.ts
791
+ var OUTPUT_NOT_RETAINED = "the run output was not retained: this response is an idempotent replay whose stored payload has expired or was too large to store, so only the run metadata came back. Re-run the request without the idempotency key (or with a fresh one) to fetch the data again.";
791
792
  function unwrap(result) {
792
793
  const output = result.output;
794
+ if (output === null || output === void 0) {
795
+ throw new AnyAPIError(OUTPUT_NOT_RETAINED, 200);
796
+ }
793
797
  if (output !== null && typeof output === "object" && "found" in output) {
794
798
  const env = output;
795
799
  if (env.found) {