@paymos/sdk 2.0.2 → 2.0.3
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 +4 -0
- package/dist/index.cjs +9 -7
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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
|
|
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?.
|
|
109
|
+
return this.problem?.code ?? "";
|
|
110
110
|
}
|
|
111
111
|
get field() {
|
|
112
|
-
return this.problem?.
|
|
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
|
-
|
|
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.
|
|
209
|
+
var SDK_VERSION = "2.0.3";
|
|
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
|
|
153
|
+
field?: string | null;
|
|
154
154
|
message: string;
|
|
155
155
|
}
|
|
156
156
|
interface ProblemDetails {
|
|
157
|
-
type
|
|
158
|
-
title
|
|
159
|
-
status
|
|
160
|
-
detail
|
|
161
|
-
code
|
|
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.
|
|
261
|
+
declare const SDK_VERSION = "2.0.3";
|
|
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
|
|
153
|
+
field?: string | null;
|
|
154
154
|
message: string;
|
|
155
155
|
}
|
|
156
156
|
interface ProblemDetails {
|
|
157
|
-
type
|
|
158
|
-
title
|
|
159
|
-
status
|
|
160
|
-
detail
|
|
161
|
-
code
|
|
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.
|
|
261
|
+
declare const SDK_VERSION = "2.0.3";
|
|
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
|
|
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?.
|
|
63
|
+
return this.problem?.code ?? "";
|
|
64
64
|
}
|
|
65
65
|
get field() {
|
|
66
|
-
return this.problem?.
|
|
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
|
-
|
|
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.
|
|
163
|
+
var SDK_VERSION = "2.0.3";
|
|
162
164
|
|
|
163
165
|
// src/http.ts
|
|
164
166
|
var HttpClient = class {
|