@zeroxyz/sdk 0.5.0 → 0.6.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.
@@ -128,6 +128,78 @@ var ZeroConfigurationError = class extends ZeroError {
128
128
  }
129
129
  };
130
130
 
131
+ // src/input-envelope.ts
132
+ var asSchemaNode = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : null;
133
+ var extractInputEnvelope = (bodySchema, method) => {
134
+ const root = asSchemaNode(bodySchema);
135
+ if (!root) return {};
136
+ const props = asSchemaNode(root.properties);
137
+ if (!props) return {};
138
+ const inputProps = asSchemaNode(asSchemaNode(props.input)?.properties);
139
+ if (inputProps) {
140
+ return {
141
+ queryParams: asSchemaNode(inputProps.queryParams) ?? void 0,
142
+ body: asSchemaNode(inputProps.body) ?? void 0
143
+ };
144
+ }
145
+ const upperMethod = method.toUpperCase();
146
+ const isGetLike = upperMethod === "GET" || upperMethod === "DELETE";
147
+ return isGetLike ? { queryParams: root } : { body: root };
148
+ };
149
+ var unwrapTransportEnvelope = (request2) => {
150
+ const input = asSchemaNode(asSchemaNode(request2)?.input);
151
+ if (!input || input.type !== "http") return request2;
152
+ const body = input.body;
153
+ const hasBody = body !== void 0 && body !== null && !(typeof body === "object" && Object.keys(body).length === 0);
154
+ if (hasBody) return body;
155
+ const qp = asSchemaNode(input.queryParams);
156
+ if (qp && Object.keys(qp).length > 0) return qp;
157
+ return null;
158
+ };
159
+ var GET_LIKE = /* @__PURE__ */ new Set(["GET", "HEAD", "DELETE"]);
160
+ var appendQueryParams = (url, params) => {
161
+ const entries = Object.entries(params).filter(([, v]) => v != null);
162
+ if (entries.length === 0) return url;
163
+ try {
164
+ const u = new URL(url);
165
+ for (const [k, v] of entries) u.searchParams.set(k, String(v));
166
+ return u.toString();
167
+ } catch {
168
+ const qs = entries.map(
169
+ ([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`
170
+ ).join("&");
171
+ return url.includes("?") ? `${url}&${qs}` : `${url}?${qs}`;
172
+ }
173
+ };
174
+ var normalizeTransportEnvelopeRequest = (url, opts) => {
175
+ const { method, body } = opts;
176
+ if (typeof body !== "string") return { url, method, body };
177
+ let parsed;
178
+ try {
179
+ parsed = JSON.parse(body);
180
+ } catch {
181
+ return { url, method, body };
182
+ }
183
+ const input = asSchemaNode(asSchemaNode(parsed)?.input);
184
+ if (!input || input.type !== "http") return { url, method, body };
185
+ const innerBody = input.body;
186
+ const hasInnerBody = innerBody !== void 0 && innerBody !== null && !(typeof innerBody === "object" && Object.keys(innerBody).length === 0);
187
+ const verb = (method ?? (typeof input.method === "string" ? input.method : void 0) ?? (hasInnerBody ? "POST" : "GET")).toUpperCase();
188
+ if (GET_LIKE.has(verb)) {
189
+ const qp = asSchemaNode(input.queryParams);
190
+ return {
191
+ url: qp ? appendQueryParams(url, qp) : url,
192
+ method: verb,
193
+ body: void 0
194
+ };
195
+ }
196
+ return {
197
+ url,
198
+ method: verb,
199
+ body: hasInnerBody ? JSON.stringify(innerBody) : void 0
200
+ };
201
+ };
202
+
131
203
  // src/chains/eip712.ts
132
204
  var KNOWN_EIP712_DOMAINS = {
133
205
  // Base mainnet USDC. On-chain `name()` is "USD Coin" (NOT "USDC")
@@ -1146,7 +1218,7 @@ var Payments = class {
1146
1218
 
1147
1219
  // package.json
1148
1220
  var package_default = {
1149
- version: "0.5.0"};
1221
+ version: "0.6.0"};
1150
1222
 
1151
1223
  // src/version.ts
1152
1224
  var SDK_VERSION = package_default.version;
@@ -1874,6 +1946,30 @@ var listRunsResponseSchema = zod.z.object({
1874
1946
  runs: zod.z.array(runListItemSchema),
1875
1947
  nextCursor: zod.z.string().nullable()
1876
1948
  });
1949
+ var runDetailSchema = zod.z.object({
1950
+ runId: zod.z.string(),
1951
+ status: zod.z.number().nullable(),
1952
+ latencyMs: zod.z.number().nullable(),
1953
+ errorClass: zod.z.string().nullable(),
1954
+ createdAt: zod.z.coerce.date(),
1955
+ cost: zod.z.object({ amount: zod.z.string(), asset: zod.z.string().nullable() }).nullable(),
1956
+ payment: zod.z.object({
1957
+ protocol: zod.z.string(),
1958
+ chain: zod.z.string().nullable(),
1959
+ txHash: zod.z.string().nullable(),
1960
+ mode: zod.z.string().nullable()
1961
+ }).nullable(),
1962
+ capability: zod.z.object({
1963
+ uid: zod.z.string(),
1964
+ slug: zod.z.string(),
1965
+ name: zod.z.string(),
1966
+ url: zod.z.string(),
1967
+ method: zod.z.string(),
1968
+ whatItDoes: zod.z.string().nullable(),
1969
+ tags: zod.z.array(zod.z.string())
1970
+ }),
1971
+ reviewed: zod.z.boolean()
1972
+ });
1877
1973
  var createReviewResponseSchema = zod.z.object({
1878
1974
  reviewId: zod.z.string(),
1879
1975
  recorded: zod.z.boolean(),
@@ -1955,6 +2051,15 @@ var Runs = class {
1955
2051
  listRunsResponseSchema
1956
2052
  );
1957
2053
  };
2054
+ get = (runId, opts = {}) => request(
2055
+ this.client,
2056
+ {
2057
+ method: "GET",
2058
+ path: `/v1/runs/${runId}`,
2059
+ signal: opts.signal
2060
+ },
2061
+ runDetailSchema
2062
+ );
1958
2063
  review = (input, opts = {}) => request(
1959
2064
  this.client,
1960
2065
  {
@@ -2485,17 +2590,23 @@ var withDefaultContentType = (headers, body) => {
2485
2590
  var clientFetch = async (client, url, opts = {}) => {
2486
2591
  const startedAt = Date.now();
2487
2592
  const capabilityIdRequested = opts.capabilityId !== void 0;
2488
- const method = opts.method ?? (opts.body !== void 0 ? "POST" : "GET");
2593
+ const normalized = normalizeTransportEnvelopeRequest(url, {
2594
+ method: opts.method,
2595
+ body: opts.body
2596
+ });
2597
+ const requestUrl = normalized.url;
2598
+ const requestBody = normalized.body;
2599
+ const method = normalized.method ?? (requestBody !== void 0 ? "POST" : "GET");
2489
2600
  const { canRecord: canRecordForResolve } = resolveRecordingClient(
2490
2601
  client,
2491
2602
  opts
2492
2603
  );
2493
- const resolvePromise = !capabilityIdRequested && canRecordForResolve ? client.capabilities.resolveByUrl(redactUrl(url), method).catch(() => null) : Promise.resolve(null);
2494
- const probeHeaders = withDefaultContentType(opts.headers, opts.body);
2604
+ const resolvePromise = !capabilityIdRequested && canRecordForResolve ? client.capabilities.resolveByUrl(redactUrl(requestUrl), method).catch(() => null) : Promise.resolve(null);
2605
+ const probeHeaders = withDefaultContentType(opts.headers, requestBody);
2495
2606
  const requestInit = {
2496
2607
  method,
2497
2608
  headers: probeHeaders,
2498
- body: opts.body,
2609
+ body: requestBody,
2499
2610
  signal: opts.signal
2500
2611
  };
2501
2612
  const configuredFetch = buildConfiguredFetch(client, {
@@ -2506,7 +2617,7 @@ var clientFetch = async (client, url, opts = {}) => {
2506
2617
  const skipReasons = [];
2507
2618
  const warnings = [];
2508
2619
  try {
2509
- response = await configuredFetch(url, requestInit);
2620
+ response = await configuredFetch(requestUrl, requestInit);
2510
2621
  } catch (err) {
2511
2622
  if (err instanceof ZeroTimeoutError) {
2512
2623
  await recordTimeoutRun(
@@ -2536,13 +2647,13 @@ var clientFetch = async (client, url, opts = {}) => {
2536
2647
  const payCall = requirement.protocol === "x402" ? client.payments.pay : client.payments.payMpp;
2537
2648
  try {
2538
2649
  const paid = await payCall({
2539
- url,
2650
+ url: requestUrl,
2540
2651
  method,
2541
2652
  // Fresh clone for the paid retry — same rationale as
2542
2653
  // the probe-side clone above. Re-derives the default
2543
2654
  // Content-Type so the paid leg matches the probe.
2544
- headers: withDefaultContentType(opts.headers, opts.body),
2545
- body: opts.body,
2655
+ headers: withDefaultContentType(opts.headers, requestBody),
2656
+ body: requestBody,
2546
2657
  maxPay: opts.maxPay,
2547
2658
  account: opts.account,
2548
2659
  signal: opts.signal,
@@ -3216,9 +3327,13 @@ exports.ZeroSessionCloseFailedError = ZeroSessionCloseFailedError;
3216
3327
  exports.ZeroTimeoutError = ZeroTimeoutError;
3217
3328
  exports.ZeroValidationError = ZeroValidationError;
3218
3329
  exports.ZeroWalletError = ZeroWalletError;
3330
+ exports.asSchemaNode = asSchemaNode;
3219
3331
  exports.coerceTempoChainId = coerceTempoChainId;
3220
3332
  exports.createManagedAccount = createManagedAccount;
3333
+ exports.extractInputEnvelope = extractInputEnvelope;
3334
+ exports.normalizeTransportEnvelopeRequest = normalizeTransportEnvelopeRequest;
3221
3335
  exports.paymentHasAnchor = paymentHasAnchor;
3222
3336
  exports.tempoChainLabelFromId = tempoChainLabelFromId;
3223
- //# sourceMappingURL=chunk-ED754B5U.cjs.map
3224
- //# sourceMappingURL=chunk-ED754B5U.cjs.map
3337
+ exports.unwrapTransportEnvelope = unwrapTransportEnvelope;
3338
+ //# sourceMappingURL=chunk-UIK7QKNQ.cjs.map
3339
+ //# sourceMappingURL=chunk-UIK7QKNQ.cjs.map