@zeroxyz/sdk 0.4.0 → 0.5.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.
- package/dist/{chunk-5ZVIL7AZ.cjs → chunk-ED754B5U.cjs} +61 -10
- package/dist/chunk-ED754B5U.cjs.map +1 -0
- package/dist/{chunk-RPL7VC32.js → chunk-RY3VFSIE.js} +61 -10
- package/dist/chunk-RY3VFSIE.js.map +1 -0
- package/dist/{client-qacxAiJ5.d.cts → client-BKAiYZYS.d.cts} +21 -1
- package/dist/{client-qacxAiJ5.d.ts → client-BKAiYZYS.d.ts} +21 -1
- package/dist/index.cjs +31 -31
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5ZVIL7AZ.cjs.map +0 -1
- package/dist/chunk-RPL7VC32.js.map +0 -1
|
@@ -1146,7 +1146,7 @@ var Payments = class {
|
|
|
1146
1146
|
|
|
1147
1147
|
// package.json
|
|
1148
1148
|
var package_default = {
|
|
1149
|
-
version: "0.
|
|
1149
|
+
version: "0.5.0"};
|
|
1150
1150
|
|
|
1151
1151
|
// src/version.ts
|
|
1152
1152
|
var SDK_VERSION = package_default.version;
|
|
@@ -1803,6 +1803,11 @@ var capabilityResponseSchema = zod.z.object({
|
|
|
1803
1803
|
lastUsedAt: zod.z.string().nullable().optional(),
|
|
1804
1804
|
lastSuccessfullyRanAt: zod.z.string().nullable().optional()
|
|
1805
1805
|
});
|
|
1806
|
+
var resolveCapabilityResponseSchema = zod.z.object({
|
|
1807
|
+
capabilityId: zod.z.string(),
|
|
1808
|
+
capabilitySlug: zod.z.string(),
|
|
1809
|
+
matchedVia: zod.z.enum(["exact", "template"])
|
|
1810
|
+
});
|
|
1806
1811
|
|
|
1807
1812
|
// src/namespaces/capabilities.ts
|
|
1808
1813
|
var Capabilities = class {
|
|
@@ -1819,6 +1824,31 @@ var Capabilities = class {
|
|
|
1819
1824
|
},
|
|
1820
1825
|
capabilityResponseSchema
|
|
1821
1826
|
);
|
|
1827
|
+
// Resolve a raw endpoint URL + method back to the capability that owns it,
|
|
1828
|
+
// for the `zero fetch <url>` case where the client has no local search
|
|
1829
|
+
// context to match against (a memoized/cross-session URL). Returns null on
|
|
1830
|
+
// 404 — i.e. no match or an ambiguous multi-match, both of which the server
|
|
1831
|
+
// reports as 404 (resolveByUrl fails closed rather than mis-attribute).
|
|
1832
|
+
// The URL travels in the POST body so it stays out of access logs and is
|
|
1833
|
+
// never stored; the caller uses the returned capabilityId to record an
|
|
1834
|
+
// attributed run without the URL ever touching the run row (ZERO-335).
|
|
1835
|
+
resolveByUrl = async (url, method, opts = {}) => {
|
|
1836
|
+
try {
|
|
1837
|
+
return await request(
|
|
1838
|
+
this.client,
|
|
1839
|
+
{
|
|
1840
|
+
method: "POST",
|
|
1841
|
+
path: "/v1/capabilities/resolve",
|
|
1842
|
+
body: { url, method },
|
|
1843
|
+
signal: opts.signal
|
|
1844
|
+
},
|
|
1845
|
+
resolveCapabilityResponseSchema
|
|
1846
|
+
);
|
|
1847
|
+
} catch (err) {
|
|
1848
|
+
if (err instanceof ZeroApiError && err.status === 404) return null;
|
|
1849
|
+
throw err;
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1822
1852
|
};
|
|
1823
1853
|
var createRunResponseSchema = zod.z.object({
|
|
1824
1854
|
runId: zod.z.string()
|
|
@@ -2399,14 +2429,17 @@ var resolveRecordingClient = (client, opts) => {
|
|
|
2399
2429
|
const canRecord = opts.account !== void 0 || credentials.kind === "account" || credentials.kind === "session";
|
|
2400
2430
|
return { recordingClient, canRecord };
|
|
2401
2431
|
};
|
|
2402
|
-
var recordErrorFetchRun = async (client, opts, result) => {
|
|
2403
|
-
|
|
2432
|
+
var recordErrorFetchRun = async (client, opts, result, capabilityIdOverride) => {
|
|
2433
|
+
const effectiveCapId = opts.capabilityId;
|
|
2434
|
+
if (effectiveCapId === void 0) return;
|
|
2404
2435
|
const { recordingClient, canRecord } = resolveRecordingClient(client, opts);
|
|
2405
2436
|
if (!canRecord) return;
|
|
2437
|
+
const fetchOriginForRecord = opts.capabilityId === void 0 ? "direct_url" : opts.fetchOrigin;
|
|
2406
2438
|
try {
|
|
2407
2439
|
const created = await recordingClient.runs.create({
|
|
2408
|
-
capabilityId:
|
|
2440
|
+
capabilityId: effectiveCapId,
|
|
2409
2441
|
...opts.searchId && { searchId: opts.searchId },
|
|
2442
|
+
...fetchOriginForRecord && { fetchOrigin: fetchOriginForRecord },
|
|
2410
2443
|
...result.status !== null && { status: result.status },
|
|
2411
2444
|
latencyMs: result.latencyMs,
|
|
2412
2445
|
...opts.requestSchema && { requestSchema: opts.requestSchema }
|
|
@@ -2416,7 +2449,7 @@ var recordErrorFetchRun = async (client, opts, result) => {
|
|
|
2416
2449
|
} catch {
|
|
2417
2450
|
}
|
|
2418
2451
|
};
|
|
2419
|
-
var recordTimeoutRun = async (client, opts, err, startedAt, capabilityIdRequested) => {
|
|
2452
|
+
var recordTimeoutRun = async (client, opts, err, startedAt, capabilityIdRequested, capabilityIdOverride) => {
|
|
2420
2453
|
const result = errorFetchResult(
|
|
2421
2454
|
startedAt,
|
|
2422
2455
|
err.message,
|
|
@@ -2453,6 +2486,11 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2453
2486
|
const startedAt = Date.now();
|
|
2454
2487
|
const capabilityIdRequested = opts.capabilityId !== void 0;
|
|
2455
2488
|
const method = opts.method ?? (opts.body !== void 0 ? "POST" : "GET");
|
|
2489
|
+
const { canRecord: canRecordForResolve } = resolveRecordingClient(
|
|
2490
|
+
client,
|
|
2491
|
+
opts
|
|
2492
|
+
);
|
|
2493
|
+
const resolvePromise = !capabilityIdRequested && canRecordForResolve ? client.capabilities.resolveByUrl(redactUrl(url), method).catch(() => null) : Promise.resolve(null);
|
|
2456
2494
|
const probeHeaders = withDefaultContentType(opts.headers, opts.body);
|
|
2457
2495
|
const requestInit = {
|
|
2458
2496
|
method,
|
|
@@ -2644,7 +2682,15 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2644
2682
|
else if (closeFailed)
|
|
2645
2683
|
skipReasons.push(FETCH_SKIP_REASONS.mppSessionCloseFailedNotRecorded);
|
|
2646
2684
|
}
|
|
2647
|
-
|
|
2685
|
+
const resolvedCap = await resolvePromise;
|
|
2686
|
+
const effectiveCapabilityId = opts.capabilityId ?? resolvedCap?.capabilityId;
|
|
2687
|
+
const capabilityResolution = !capabilityIdRequested && canRecordForResolve ? resolvedCap !== null ? {
|
|
2688
|
+
resolved: true,
|
|
2689
|
+
capabilityId: resolvedCap.capabilityId,
|
|
2690
|
+
capabilitySlug: resolvedCap.capabilitySlug,
|
|
2691
|
+
matchedVia: resolvedCap.matchedVia
|
|
2692
|
+
} : { resolved: false } : void 0;
|
|
2693
|
+
if (effectiveCapabilityId !== void 0 && !paidButStill402 && !closeFailed) {
|
|
2648
2694
|
const { recordingClient, canRecord } = resolveRecordingClient(client, opts);
|
|
2649
2695
|
if (!canRecord) {
|
|
2650
2696
|
skipReasons.push("no_credentials");
|
|
@@ -2664,8 +2710,11 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2664
2710
|
}
|
|
2665
2711
|
}
|
|
2666
2712
|
const result2 = await recordingClient.runs.create({
|
|
2667
|
-
capabilityId:
|
|
2713
|
+
capabilityId: effectiveCapabilityId,
|
|
2668
2714
|
searchId: opts.searchId,
|
|
2715
|
+
// Auto-resolved runs are always direct_url — they only fire when
|
|
2716
|
+
// no capabilityId was supplied (the direct_url path by definition).
|
|
2717
|
+
...opts.capabilityId === void 0 ? { fetchOrigin: "direct_url" } : opts.fetchOrigin && { fetchOrigin: opts.fetchOrigin },
|
|
2669
2718
|
status: response.status,
|
|
2670
2719
|
latencyMs,
|
|
2671
2720
|
...opts.requestSchema && { requestSchema: opts.requestSchema },
|
|
@@ -2698,7 +2747,7 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2698
2747
|
message: "Failed to record run for fetch",
|
|
2699
2748
|
meta: {
|
|
2700
2749
|
url: redactUrl(url),
|
|
2701
|
-
capabilityId:
|
|
2750
|
+
capabilityId: effectiveCapabilityId,
|
|
2702
2751
|
error: errorMessage2,
|
|
2703
2752
|
errorCode: code
|
|
2704
2753
|
}
|
|
@@ -2726,6 +2775,8 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2726
2775
|
result.runTrackingSkipped = skipReasons;
|
|
2727
2776
|
}
|
|
2728
2777
|
if (warnings.length > 0) result.warnings = warnings;
|
|
2778
|
+
if (capabilityResolution !== void 0)
|
|
2779
|
+
result.capabilityResolution = capabilityResolution;
|
|
2729
2780
|
return result;
|
|
2730
2781
|
};
|
|
2731
2782
|
var searchResultSchema = zod.z.object({
|
|
@@ -3169,5 +3220,5 @@ exports.coerceTempoChainId = coerceTempoChainId;
|
|
|
3169
3220
|
exports.createManagedAccount = createManagedAccount;
|
|
3170
3221
|
exports.paymentHasAnchor = paymentHasAnchor;
|
|
3171
3222
|
exports.tempoChainLabelFromId = tempoChainLabelFromId;
|
|
3172
|
-
//# sourceMappingURL=chunk-
|
|
3173
|
-
//# sourceMappingURL=chunk-
|
|
3223
|
+
//# sourceMappingURL=chunk-ED754B5U.cjs.map
|
|
3224
|
+
//# sourceMappingURL=chunk-ED754B5U.cjs.map
|