@mercurjs/client 2.3.4-canary.0 → 2.3.4-canary.10

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
@@ -48,7 +48,13 @@ type InferClientOutput<T> = T extends (...args: any[]) => Promise<infer O> ? O :
48
48
  declare class ClientError extends Error {
49
49
  status: number | undefined;
50
50
  statusText: string | undefined;
51
- constructor(message: string, statusText?: string, status?: number);
51
+ /**
52
+ * The API's machine-readable error code (`MedusaError.code`), when the
53
+ * error body carried one — e.g. `"insufficient_inventory"`. Lets a caller
54
+ * branch on the reason for a refusal without matching on `message`.
55
+ */
56
+ code: string | undefined;
57
+ constructor(message: string, statusText?: string, status?: number, code?: string);
52
58
  }
53
59
  declare function createClient(options: ClientOptions): any;
54
60
 
package/dist/index.mjs CHANGED
@@ -77,10 +77,11 @@ var kebabCase = (string) => string.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/
77
77
 
78
78
  // src/index.ts
79
79
  var ClientError = class extends Error {
80
- constructor(message, statusText, status) {
80
+ constructor(message, statusText, status, code) {
81
81
  super(message);
82
82
  this.statusText = statusText;
83
83
  this.status = status;
84
+ this.code = code;
84
85
  }
85
86
  };
86
87
  var isFileLike = (value) => typeof Blob !== "undefined" && value instanceof Blob;
@@ -164,7 +165,8 @@ function createClient(options) {
164
165
  throw new ClientError(
165
166
  (_a2 = jsonError.message) != null ? _a2 : response.statusText,
166
167
  response.statusText,
167
- response.status
168
+ response.status,
169
+ typeof jsonError.code === "string" ? jsonError.code : void 0
168
170
  );
169
171
  }
170
172
  const isJsonRequest = (_b2 = headers.get("accept")) == null ? void 0 : _b2.includes("application/json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/client",
3
- "version": "2.3.4-canary.0",
3
+ "version": "2.3.4-canary.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",
@@ -39,7 +39,7 @@
39
39
  "qs": "^6.12.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@medusajs/framework": "2.18.0",
42
+ "@medusajs/framework": "2.20.1",
43
43
  "@types/qs": "^6.9.18",
44
44
  "tsup": "^8.5.0",
45
45
  "typescript": "5.9.3"