@paymos/sdk 2.0.2 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.0] - 2026-07-21
4
+
5
+ - feat(docs): make the developer surface consumable by LLM agents
6
+
7
+ ## [2.0.3] - 2026-07-19
8
+
9
+ - fix: align SDK problem details semantics
10
+
3
11
  ## [2.0.2] - 2026-07-12
4
12
 
5
13
  - fix(typescript-sdk): retry trusted npm publication
package/dist/index.cjs CHANGED
@@ -97,8 +97,8 @@ var ApiError = class extends PaymosError {
97
97
  headers;
98
98
  problem;
99
99
  constructor(status, body, headers) {
100
- const problem = parseProblem(body);
101
- const detail = problem?.detail ?? problem?.errors?.[0]?.message ?? problem?.code ?? problem?.title;
100
+ const problem = parseProblem(status, body);
101
+ const detail = problem?.detail || problem?.code || problem?.title;
102
102
  super(`Paymos API ${status}: ${detail || body || "empty response"}`);
103
103
  this.status = status;
104
104
  this.body = body;
@@ -106,10 +106,10 @@ var ApiError = class extends PaymosError {
106
106
  this.problem = problem;
107
107
  }
108
108
  get code() {
109
- return this.problem?.errors?.[0]?.code ?? this.problem?.code ?? "";
109
+ return this.problem?.code ?? "";
110
110
  }
111
111
  get field() {
112
- return this.problem?.errors?.[0]?.field ?? this.problem?.field ?? null;
112
+ return this.problem?.field ?? null;
113
113
  }
114
114
  get errors() {
115
115
  return this.problem?.errors ?? [];
@@ -149,11 +149,13 @@ function apiErrorFromResponse(status, body, headers) {
149
149
  if (status >= 500) return new ServerError(status, body, headers);
150
150
  return new ApiError(status, body, headers);
151
151
  }
152
- function parseProblem(body) {
152
+ function parseProblem(status, body) {
153
153
  if (!body) return null;
154
154
  try {
155
155
  const parsed = JSON.parse(body);
156
- return parsed !== null && typeof parsed === "object" ? fromWire(parsed) : null;
156
+ if (parsed === null || typeof parsed !== "object") return null;
157
+ const problem = fromWire(parsed);
158
+ return typeof problem.type === "string" && typeof problem.title === "string" && typeof problem.status === "number" && Number.isInteger(problem.status) && problem.status === status && typeof problem.detail === "string" && typeof problem.code === "string" ? problem : null;
157
159
  } catch {
158
160
  return null;
159
161
  }
@@ -204,7 +206,7 @@ function rfc3986(value) {
204
206
  }
205
207
 
206
208
  // src/version.ts
207
- var SDK_VERSION = "2.0.2";
209
+ var SDK_VERSION = "2.1.0";
208
210
 
209
211
  // src/http.ts
210
212
  var HttpClient = class {
package/dist/index.d.cts CHANGED
@@ -150,15 +150,15 @@ interface Balance {
150
150
  }
151
151
  interface ProblemError {
152
152
  code: string;
153
- field: string | null;
153
+ field?: string | null;
154
154
  message: string;
155
155
  }
156
156
  interface ProblemDetails {
157
- type?: string;
158
- title?: string;
159
- status?: number;
160
- detail?: string;
161
- code?: string;
157
+ type: string;
158
+ title: string;
159
+ status: number;
160
+ detail: string;
161
+ code: string;
162
162
  field?: string | null;
163
163
  errors?: ProblemError[];
164
164
  traceId?: string;
@@ -258,7 +258,7 @@ declare class WebhookVerifier {
258
258
  constructEvent<T = unknown>(signatureHeader: string, rawBody: string | Buffer, now?: number): WebhookEvent<T>;
259
259
  }
260
260
 
261
- declare const SDK_VERSION = "2.0.2";
261
+ declare const SDK_VERSION = "2.1.0";
262
262
 
263
263
  declare class Paymos {
264
264
  readonly invoices: InvoicesResource;
package/dist/index.d.ts CHANGED
@@ -150,15 +150,15 @@ interface Balance {
150
150
  }
151
151
  interface ProblemError {
152
152
  code: string;
153
- field: string | null;
153
+ field?: string | null;
154
154
  message: string;
155
155
  }
156
156
  interface ProblemDetails {
157
- type?: string;
158
- title?: string;
159
- status?: number;
160
- detail?: string;
161
- code?: string;
157
+ type: string;
158
+ title: string;
159
+ status: number;
160
+ detail: string;
161
+ code: string;
162
162
  field?: string | null;
163
163
  errors?: ProblemError[];
164
164
  traceId?: string;
@@ -258,7 +258,7 @@ declare class WebhookVerifier {
258
258
  constructEvent<T = unknown>(signatureHeader: string, rawBody: string | Buffer, now?: number): WebhookEvent<T>;
259
259
  }
260
260
 
261
- declare const SDK_VERSION = "2.0.2";
261
+ declare const SDK_VERSION = "2.1.0";
262
262
 
263
263
  declare class Paymos {
264
264
  readonly invoices: InvoicesResource;
package/dist/index.js CHANGED
@@ -51,8 +51,8 @@ var ApiError = class extends PaymosError {
51
51
  headers;
52
52
  problem;
53
53
  constructor(status, body, headers) {
54
- const problem = parseProblem(body);
55
- const detail = problem?.detail ?? problem?.errors?.[0]?.message ?? problem?.code ?? problem?.title;
54
+ const problem = parseProblem(status, body);
55
+ const detail = problem?.detail || problem?.code || problem?.title;
56
56
  super(`Paymos API ${status}: ${detail || body || "empty response"}`);
57
57
  this.status = status;
58
58
  this.body = body;
@@ -60,10 +60,10 @@ var ApiError = class extends PaymosError {
60
60
  this.problem = problem;
61
61
  }
62
62
  get code() {
63
- return this.problem?.errors?.[0]?.code ?? this.problem?.code ?? "";
63
+ return this.problem?.code ?? "";
64
64
  }
65
65
  get field() {
66
- return this.problem?.errors?.[0]?.field ?? this.problem?.field ?? null;
66
+ return this.problem?.field ?? null;
67
67
  }
68
68
  get errors() {
69
69
  return this.problem?.errors ?? [];
@@ -103,11 +103,13 @@ function apiErrorFromResponse(status, body, headers) {
103
103
  if (status >= 500) return new ServerError(status, body, headers);
104
104
  return new ApiError(status, body, headers);
105
105
  }
106
- function parseProblem(body) {
106
+ function parseProblem(status, body) {
107
107
  if (!body) return null;
108
108
  try {
109
109
  const parsed = JSON.parse(body);
110
- return parsed !== null && typeof parsed === "object" ? fromWire(parsed) : null;
110
+ if (parsed === null || typeof parsed !== "object") return null;
111
+ const problem = fromWire(parsed);
112
+ return typeof problem.type === "string" && typeof problem.title === "string" && typeof problem.status === "number" && Number.isInteger(problem.status) && problem.status === status && typeof problem.detail === "string" && typeof problem.code === "string" ? problem : null;
111
113
  } catch {
112
114
  return null;
113
115
  }
@@ -158,7 +160,7 @@ function rfc3986(value) {
158
160
  }
159
161
 
160
162
  // src/version.ts
161
- var SDK_VERSION = "2.0.2";
163
+ var SDK_VERSION = "2.1.0";
162
164
 
163
165
  // src/http.ts
164
166
  var HttpClient = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paymos/sdk",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Official TypeScript and JavaScript SDK for the Paymos Merchant API",
5
5
  "keywords": [
6
6
  "paymos",