@brytdesigns/shopify-ajax-cart-api 1.0.42 → 1.0.43
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/esm/index.js +53 -23
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -7037,6 +7037,7 @@ var logWithLevel = (level) => (...message) => {
|
|
|
7037
7037
|
});
|
|
7038
7038
|
};
|
|
7039
7039
|
var logInfo = /* @__PURE__ */ logWithLevel(Info);
|
|
7040
|
+
var logError = /* @__PURE__ */ logWithLevel(Error2);
|
|
7040
7041
|
var withLogSpan = /* @__PURE__ */ dual(2, (effect3, label) => flatMap7(currentTimeMillis2, (now) => fiberRefLocallyWith(effect3, currentLogSpan, prepend3(make26(label, now)))));
|
|
7041
7042
|
var mapErrorCause = /* @__PURE__ */ dual(2, (self, f) => matchCauseEffect(self, {
|
|
7042
7043
|
onFailure: (c) => failCauseSync(() => f(c)),
|
|
@@ -11510,6 +11511,7 @@ var match12 = match8;
|
|
|
11510
11511
|
var matchCause4 = matchCause;
|
|
11511
11512
|
var matchCauseEffect3 = matchCauseEffect;
|
|
11512
11513
|
var logInfo2 = logInfo;
|
|
11514
|
+
var logError2 = logError;
|
|
11513
11515
|
var withLogSpan2 = withLogSpan;
|
|
11514
11516
|
var annotateLogsScoped2 = annotateLogsScoped;
|
|
11515
11517
|
var runtime3 = runtime2;
|
|
@@ -19086,6 +19088,50 @@ extend3(
|
|
|
19086
19088
|
})
|
|
19087
19089
|
);
|
|
19088
19090
|
var Default = layer2;
|
|
19091
|
+
var formatCause = (cause2) => {
|
|
19092
|
+
if (cause2 == null) return void 0;
|
|
19093
|
+
if (cause2 instanceof Error) {
|
|
19094
|
+
const nested2 = formatCause(cause2.cause);
|
|
19095
|
+
const base = `${cause2.name}: ${cause2.message}`;
|
|
19096
|
+
return nested2 ? `${base} -> ${nested2}` : base;
|
|
19097
|
+
}
|
|
19098
|
+
if (typeof cause2 === "object") {
|
|
19099
|
+
try {
|
|
19100
|
+
return JSON.stringify(cause2);
|
|
19101
|
+
} catch {
|
|
19102
|
+
return String(cause2);
|
|
19103
|
+
}
|
|
19104
|
+
}
|
|
19105
|
+
return String(cause2);
|
|
19106
|
+
};
|
|
19107
|
+
var toError = (error) => {
|
|
19108
|
+
if (error._tag === "RequestError" || error._tag === "ResponseError") {
|
|
19109
|
+
const detail = formatCause(error.cause);
|
|
19110
|
+
const message2 = detail ? `${error.message}: ${detail}` : error.message;
|
|
19111
|
+
return Object.assign(new Error(message2, { cause: error.cause }), {
|
|
19112
|
+
_tag: error._tag,
|
|
19113
|
+
reason: error.reason
|
|
19114
|
+
});
|
|
19115
|
+
}
|
|
19116
|
+
if (error._tag === "ParseError" || error._tag === "@brytdesigns/ajax-client/InvalidAjaxMethodError") {
|
|
19117
|
+
return new Error(error.message, { cause: error.cause });
|
|
19118
|
+
}
|
|
19119
|
+
if (error._tag === "HttpBodyError") {
|
|
19120
|
+
const reason = error.reason;
|
|
19121
|
+
if (reason._tag === "JsonError") {
|
|
19122
|
+
return new Error("Failed to serialize JSON request body", {
|
|
19123
|
+
cause: reason
|
|
19124
|
+
});
|
|
19125
|
+
}
|
|
19126
|
+
if (reason._tag === "SchemaError") {
|
|
19127
|
+
return new Error(reason.error.message, {
|
|
19128
|
+
cause: reason.error.cause
|
|
19129
|
+
});
|
|
19130
|
+
}
|
|
19131
|
+
}
|
|
19132
|
+
const message = formatCause(error) ?? error?.message ?? error?.toString?.() ?? String(error);
|
|
19133
|
+
return new Error(message, { cause: error });
|
|
19134
|
+
};
|
|
19089
19135
|
var METHOD = {
|
|
19090
19136
|
GET: "get",
|
|
19091
19137
|
POST: "post"
|
|
@@ -19196,29 +19242,13 @@ var makeFactory = ({
|
|
|
19196
19242
|
withNamespacedLogSpan(
|
|
19197
19243
|
routeName.replace("_url", "").replace("_", ":")
|
|
19198
19244
|
),
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
}
|
|
19207
|
-
if (error._tag === "HttpBodyError") {
|
|
19208
|
-
const reason = error.reason;
|
|
19209
|
-
if (reason._tag === "JsonError") {
|
|
19210
|
-
return fail7(new Error("Failed to parse JSON response"));
|
|
19211
|
-
}
|
|
19212
|
-
if (reason._tag === "SchemaError") {
|
|
19213
|
-
return fail7(
|
|
19214
|
-
new Error(reason.error.message, {
|
|
19215
|
-
cause: reason.error.cause
|
|
19216
|
-
})
|
|
19217
|
-
);
|
|
19218
|
-
}
|
|
19219
|
-
}
|
|
19220
|
-
return fail7(new Error(error.toString()));
|
|
19221
|
-
})
|
|
19245
|
+
// Log the full failure cause (including defects and the underlying
|
|
19246
|
+
// `cause` chain) before we flatten it. This is gated by the consumer's
|
|
19247
|
+
// minimum log level, so it only surfaces when `debug` is enabled.
|
|
19248
|
+
tapErrorCause2(
|
|
19249
|
+
(cause2) => logError2("Ajax request failed", cause2)
|
|
19250
|
+
),
|
|
19251
|
+
catchAll2((error) => fail7(toError(error)))
|
|
19222
19252
|
);
|
|
19223
19253
|
|
|
19224
19254
|
// src/effect/api/CartAdd.ts
|