@gr4vy/sdk 2.2.1 → 2.3.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/funcs/auditLogsList.d.ts.map +1 -1
- package/funcs/auditLogsList.js +1 -2
- package/funcs/auditLogsList.js.map +1 -1
- package/funcs/buyersList.d.ts.map +1 -1
- package/funcs/buyersList.js +1 -2
- package/funcs/buyersList.js.map +1 -1
- package/funcs/giftCardsList.d.ts.map +1 -1
- package/funcs/giftCardsList.js +1 -2
- package/funcs/giftCardsList.js.map +1 -1
- package/funcs/merchantAccountsList.d.ts.map +1 -1
- package/funcs/merchantAccountsList.js +1 -2
- package/funcs/merchantAccountsList.js.map +1 -1
- package/funcs/paymentLinksList.d.ts.map +1 -1
- package/funcs/paymentLinksList.js +1 -2
- package/funcs/paymentLinksList.js.map +1 -1
- package/funcs/paymentMethodsList.d.ts.map +1 -1
- package/funcs/paymentMethodsList.js +1 -2
- package/funcs/paymentMethodsList.js.map +1 -1
- package/funcs/paymentServiceDefinitionsList.d.ts.map +1 -1
- package/funcs/paymentServiceDefinitionsList.js +1 -2
- package/funcs/paymentServiceDefinitionsList.js.map +1 -1
- package/funcs/paymentServicesList.d.ts.map +1 -1
- package/funcs/paymentServicesList.js +1 -2
- package/funcs/paymentServicesList.js.map +1 -1
- package/funcs/payoutsList.d.ts.map +1 -1
- package/funcs/payoutsList.js +1 -2
- package/funcs/payoutsList.js.map +1 -1
- package/funcs/reportExecutionsList.d.ts.map +1 -1
- package/funcs/reportExecutionsList.js +1 -2
- package/funcs/reportExecutionsList.js.map +1 -1
- package/funcs/reportsExecutionsList.d.ts.map +1 -1
- package/funcs/reportsExecutionsList.js +1 -2
- package/funcs/reportsExecutionsList.js.map +1 -1
- package/funcs/reportsList.d.ts.map +1 -1
- package/funcs/reportsList.js +1 -2
- package/funcs/reportsList.js.map +1 -1
- package/funcs/threeDsScenariosList.d.ts.map +1 -1
- package/funcs/threeDsScenariosList.js +1 -2
- package/funcs/threeDsScenariosList.js.map +1 -1
- package/funcs/transactionsEventsList.d.ts.map +1 -1
- package/funcs/transactionsEventsList.js +1 -2
- package/funcs/transactionsEventsList.js.map +1 -1
- package/funcs/transactionsList.d.ts.map +1 -1
- package/funcs/transactionsList.js +1 -2
- package/funcs/transactionsList.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/encodings.js +12 -12
- package/lib/encodings.js.map +1 -1
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +3 -3
- package/lib/env.js.map +1 -1
- package/lib/matchers.js +3 -3
- package/lib/matchers.js.map +1 -1
- package/lib/primitives.d.ts +1 -0
- package/lib/primitives.d.ts.map +1 -1
- package/lib/primitives.js +18 -0
- package/lib/primitives.js.map +1 -1
- package/models/components/nuveipseoptions.d.ts +2 -2
- package/package.json +1 -1
- package/src/funcs/auditLogsList.ts +2 -2
- package/src/funcs/buyersList.ts +2 -2
- package/src/funcs/giftCardsList.ts +2 -2
- package/src/funcs/merchantAccountsList.ts +2 -2
- package/src/funcs/paymentLinksList.ts +2 -2
- package/src/funcs/paymentMethodsList.ts +2 -2
- package/src/funcs/paymentServiceDefinitionsList.ts +2 -2
- package/src/funcs/paymentServicesList.ts +2 -2
- package/src/funcs/payoutsList.ts +2 -2
- package/src/funcs/reportExecutionsList.ts +2 -2
- package/src/funcs/reportsExecutionsList.ts +2 -2
- package/src/funcs/reportsList.ts +2 -2
- package/src/funcs/threeDsScenariosList.ts +2 -2
- package/src/funcs/transactionsEventsList.ts +2 -2
- package/src/funcs/transactionsList.ts +2 -2
- package/src/lib/config.ts +3 -3
- package/src/lib/encodings.ts +1 -1
- package/src/lib/env.ts +7 -3
- package/src/lib/matchers.ts +1 -1
- package/src/lib/primitives.ts +16 -0
- package/src/models/components/nuveipseoptions.ts +2 -2
- package/lib/dlv.d.ts +0 -14
- package/lib/dlv.d.ts.map +0 -1
- package/lib/dlv.js +0 -49
- package/lib/dlv.js.map +0 -1
- package/lib/is-plain-object.d.ts +0 -2
- package/lib/is-plain-object.d.ts.map +0 -1
- package/lib/is-plain-object.js +0 -41
- package/lib/is-plain-object.js.map +0 -1
- package/src/lib/dlv.ts +0 -53
- package/src/lib/is-plain-object.ts +0 -43
package/lib/primitives.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.combineSignals = combineSignals;
|
|
|
9
9
|
exports.abortSignalAny = abortSignalAny;
|
|
10
10
|
exports.compactMap = compactMap;
|
|
11
11
|
exports.allRequired = allRequired;
|
|
12
|
+
exports.isPlainObject = isPlainObject;
|
|
12
13
|
class InvariantError extends Error {
|
|
13
14
|
constructor(message) {
|
|
14
15
|
super(message);
|
|
@@ -108,4 +109,21 @@ function allRequired(v) {
|
|
|
108
109
|
}
|
|
109
110
|
return v;
|
|
110
111
|
}
|
|
112
|
+
function isPlainObject(value) {
|
|
113
|
+
if (value === null || typeof value !== "object")
|
|
114
|
+
return false;
|
|
115
|
+
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
116
|
+
return false;
|
|
117
|
+
const proto = Object.getPrototypeOf(value);
|
|
118
|
+
if (proto === null || proto === Object.prototype)
|
|
119
|
+
return true;
|
|
120
|
+
// cross-realm plain objects (vm contexts, iframes) inherit from a
|
|
121
|
+
// different realm's Object.prototype, which itself has a null prototype
|
|
122
|
+
try {
|
|
123
|
+
return Object.getPrototypeOf(proto) === null;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
111
129
|
//# sourceMappingURL=primitives.js.map
|
package/lib/primitives.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/lib/primitives.ts"],"names":[],"mappings":";AAAA;;GAEG;;AASH,8BAOC;AAqBD,sBAoBC;AAED,wCAoBC;AAED,wCAsCC;AAED,gCAYC;AAED,kCAYC;
|
|
1
|
+
{"version":3,"file":"primitives.js","source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AkE;IAClE,wEAAwE;IACxE,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -5,11 +5,11 @@ export type NuveiPSEOptions = {
|
|
|
5
5
|
*/
|
|
6
6
|
userType?: string | null | undefined;
|
|
7
7
|
/**
|
|
8
|
-
* Customer
|
|
8
|
+
* Customer's document type
|
|
9
9
|
*/
|
|
10
10
|
userFisNumber?: string | null | undefined;
|
|
11
11
|
/**
|
|
12
|
-
* Customer
|
|
12
|
+
* Customer's document number
|
|
13
13
|
*/
|
|
14
14
|
fiscalNumber?: string | null | undefined;
|
|
15
15
|
/**
|
package/package.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -284,7 +283,8 @@ async function $do(
|
|
|
284
283
|
>;
|
|
285
284
|
"~next"?: { cursor: string };
|
|
286
285
|
} => {
|
|
287
|
-
const nextCursor =
|
|
286
|
+
const nextCursor =
|
|
287
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
288
288
|
if (typeof nextCursor !== "string") {
|
|
289
289
|
return { next: () => null };
|
|
290
290
|
}
|
package/src/funcs/buyersList.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -281,7 +280,8 @@ async function $do(
|
|
|
281
280
|
>;
|
|
282
281
|
"~next"?: { cursor: string };
|
|
283
282
|
} => {
|
|
284
|
-
const nextCursor =
|
|
283
|
+
const nextCursor =
|
|
284
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
285
285
|
if (typeof nextCursor !== "string") {
|
|
286
286
|
return { next: () => null };
|
|
287
287
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -283,7 +282,8 @@ async function $do(
|
|
|
283
282
|
>;
|
|
284
283
|
"~next"?: { cursor: string };
|
|
285
284
|
} => {
|
|
286
|
-
const nextCursor =
|
|
285
|
+
const nextCursor =
|
|
286
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
287
287
|
if (typeof nextCursor !== "string") {
|
|
288
288
|
return { next: () => null };
|
|
289
289
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -291,7 +290,8 @@ async function $do(
|
|
|
291
290
|
>;
|
|
292
291
|
"~next"?: { cursor: string };
|
|
293
292
|
} => {
|
|
294
|
-
const nextCursor =
|
|
293
|
+
const nextCursor =
|
|
294
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
295
295
|
if (typeof nextCursor !== "string") {
|
|
296
296
|
return { next: () => null };
|
|
297
297
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -298,7 +297,8 @@ async function $do(
|
|
|
298
297
|
>;
|
|
299
298
|
"~next"?: { cursor: string };
|
|
300
299
|
} => {
|
|
301
|
-
const nextCursor =
|
|
300
|
+
const nextCursor =
|
|
301
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
302
302
|
if (typeof nextCursor !== "string") {
|
|
303
303
|
return { next: () => null };
|
|
304
304
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -287,7 +286,8 @@ async function $do(
|
|
|
287
286
|
>;
|
|
288
287
|
"~next"?: { cursor: string };
|
|
289
288
|
} => {
|
|
290
|
-
const nextCursor =
|
|
289
|
+
const nextCursor =
|
|
290
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
291
291
|
if (typeof nextCursor !== "string") {
|
|
292
292
|
return { next: () => null };
|
|
293
293
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -287,7 +286,8 @@ async function $do(
|
|
|
287
286
|
>;
|
|
288
287
|
"~next"?: { cursor: string };
|
|
289
288
|
} => {
|
|
290
|
-
const nextCursor =
|
|
289
|
+
const nextCursor =
|
|
290
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
291
291
|
if (typeof nextCursor !== "string") {
|
|
292
292
|
return { next: () => null };
|
|
293
293
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -285,7 +284,8 @@ async function $do(
|
|
|
285
284
|
>;
|
|
286
285
|
"~next"?: { cursor: string };
|
|
287
286
|
} => {
|
|
288
|
-
const nextCursor =
|
|
287
|
+
const nextCursor =
|
|
288
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
289
289
|
if (typeof nextCursor !== "string") {
|
|
290
290
|
return { next: () => null };
|
|
291
291
|
}
|
package/src/funcs/payoutsList.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -293,7 +292,8 @@ async function $do(
|
|
|
293
292
|
>;
|
|
294
293
|
"~next"?: { cursor: string };
|
|
295
294
|
} => {
|
|
296
|
-
const nextCursor =
|
|
295
|
+
const nextCursor =
|
|
296
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
297
297
|
if (typeof nextCursor !== "string") {
|
|
298
298
|
return { next: () => null };
|
|
299
299
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -288,7 +287,8 @@ async function $do(
|
|
|
288
287
|
>;
|
|
289
288
|
"~next"?: { cursor: string };
|
|
290
289
|
} => {
|
|
291
|
-
const nextCursor =
|
|
290
|
+
const nextCursor =
|
|
291
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
292
292
|
if (typeof nextCursor !== "string") {
|
|
293
293
|
return { next: () => null };
|
|
294
294
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -303,7 +302,8 @@ async function $do(
|
|
|
303
302
|
>;
|
|
304
303
|
"~next"?: { cursor: string };
|
|
305
304
|
} => {
|
|
306
|
-
const nextCursor =
|
|
305
|
+
const nextCursor =
|
|
306
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
307
307
|
if (typeof nextCursor !== "string") {
|
|
308
308
|
return { next: () => null };
|
|
309
309
|
}
|
package/src/funcs/reportsList.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -284,7 +283,8 @@ async function $do(
|
|
|
284
283
|
>;
|
|
285
284
|
"~next"?: { cursor: string };
|
|
286
285
|
} => {
|
|
287
|
-
const nextCursor =
|
|
286
|
+
const nextCursor =
|
|
287
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
288
288
|
if (typeof nextCursor !== "string") {
|
|
289
289
|
return { next: () => null };
|
|
290
290
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -295,7 +294,8 @@ async function $do(
|
|
|
295
294
|
>;
|
|
296
295
|
"~next"?: { cursor: string };
|
|
297
296
|
} => {
|
|
298
|
-
const nextCursor =
|
|
297
|
+
const nextCursor =
|
|
298
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
299
299
|
if (typeof nextCursor !== "string") {
|
|
300
300
|
return { next: () => null };
|
|
301
301
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -303,7 +302,8 @@ async function $do(
|
|
|
303
302
|
>;
|
|
304
303
|
"~next"?: { cursor: string };
|
|
305
304
|
} => {
|
|
306
|
-
const nextCursor =
|
|
305
|
+
const nextCursor =
|
|
306
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
307
307
|
if (typeof nextCursor !== "string") {
|
|
308
308
|
return { next: () => null };
|
|
309
309
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Gr4vyCore } from "../core.js";
|
|
6
|
-
import { dlv } from "../lib/dlv.js";
|
|
7
6
|
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
7
|
import { matchStatusCode } from "../lib/http.js";
|
|
9
8
|
import * as M from "../lib/matchers.js";
|
|
@@ -323,7 +322,8 @@ async function $do(
|
|
|
323
322
|
>;
|
|
324
323
|
"~next"?: { cursor: string };
|
|
325
324
|
} => {
|
|
326
|
-
const nextCursor =
|
|
325
|
+
const nextCursor =
|
|
326
|
+
(responseData as { next_cursor?: unknown | null }).next_cursor;
|
|
327
327
|
if (typeof nextCursor !== "string") {
|
|
328
328
|
return { next: () => null };
|
|
329
329
|
}
|
package/src/lib/config.ts
CHANGED
|
@@ -77,7 +77,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
77
77
|
export const SDK_METADATA = {
|
|
78
78
|
language: "typescript",
|
|
79
79
|
openapiDocVersion: "1.0.0",
|
|
80
|
-
sdkVersion: "2.
|
|
81
|
-
genVersion: "2.
|
|
82
|
-
userAgent: "speakeasy-sdk/typescript 2.
|
|
80
|
+
sdkVersion: "2.3.0",
|
|
81
|
+
genVersion: "2.903.2",
|
|
82
|
+
userAgent: "speakeasy-sdk/typescript 2.3.0 2.903.2 1.0.0 @gr4vy/sdk",
|
|
83
83
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
package/src/lib/env.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
6
|
import { SDKOptions } from "./config.js";
|
|
7
|
-
import { dlv } from "./dlv.js";
|
|
8
7
|
|
|
9
8
|
export interface Env {
|
|
10
9
|
GR4VY_BEARER_AUTH?: string | undefined;
|
|
@@ -46,11 +45,16 @@ export function env(): Env {
|
|
|
46
45
|
return envMemo;
|
|
47
46
|
}
|
|
48
47
|
|
|
48
|
+
const globals = globalThis as {
|
|
49
|
+
Deno?: { env?: { toObject?: () => Record<string, string | undefined> } };
|
|
50
|
+
process?: { env?: Record<string, string | undefined> };
|
|
51
|
+
};
|
|
52
|
+
|
|
49
53
|
let envObject: Record<string, unknown> = {};
|
|
50
54
|
if (isDeno()) {
|
|
51
|
-
envObject =
|
|
55
|
+
envObject = globals.Deno?.env?.toObject?.() ?? {};
|
|
52
56
|
} else {
|
|
53
|
-
envObject =
|
|
57
|
+
envObject = globals.process?.env ?? {};
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
envMemo = envSchema.parse(envObject);
|
package/src/lib/matchers.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ResponseValidationError } from "../models/errors/responsevalidationerro
|
|
|
6
6
|
import { SDKError } from "../models/errors/sdkerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
-
import { isPlainObject } from "./
|
|
9
|
+
import { isPlainObject } from "./primitives.js";
|
|
10
10
|
|
|
11
11
|
export type Encoding =
|
|
12
12
|
| "jsonl"
|
package/src/lib/primitives.ts
CHANGED
|
@@ -148,3 +148,19 @@ export function allRequired<V extends Record<string, unknown>>(
|
|
|
148
148
|
|
|
149
149
|
return v as ReturnType<typeof allRequired<V>>;
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
export function isPlainObject(
|
|
153
|
+
value: unknown,
|
|
154
|
+
): value is Record<string, unknown> {
|
|
155
|
+
if (value === null || typeof value !== "object") return false;
|
|
156
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
157
|
+
const proto = Object.getPrototypeOf(value);
|
|
158
|
+
if (proto === null || proto === Object.prototype) return true;
|
|
159
|
+
// cross-realm plain objects (vm contexts, iframes) inherit from a
|
|
160
|
+
// different realm's Object.prototype, which itself has a null prototype
|
|
161
|
+
try {
|
|
162
|
+
return Object.getPrototypeOf(proto) === null;
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -10,11 +10,11 @@ export type NuveiPSEOptions = {
|
|
|
10
10
|
*/
|
|
11
11
|
userType?: string | null | undefined;
|
|
12
12
|
/**
|
|
13
|
-
* Customer
|
|
13
|
+
* Customer's document type
|
|
14
14
|
*/
|
|
15
15
|
userFisNumber?: string | null | undefined;
|
|
16
16
|
/**
|
|
17
|
-
* Customer
|
|
17
|
+
* Customer's document number
|
|
18
18
|
*/
|
|
19
19
|
fiscalNumber?: string | null | undefined;
|
|
20
20
|
/**
|
package/lib/dlv.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param obj The object to walk
|
|
3
|
-
* @param key The key path to walk the object with
|
|
4
|
-
* @param def A default value to return if the result is undefined
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* dlv(obj, "a.b.c.d")
|
|
8
|
-
* @example
|
|
9
|
-
* dlv(object, ["a", "b", "c", "d"])
|
|
10
|
-
* @example
|
|
11
|
-
* dlv(object, "foo.bar.baz", "Hello, default value!")
|
|
12
|
-
*/
|
|
13
|
-
export declare function dlv<T = any>(obj: any, key: string | string[], def?: T, p?: number, undef?: never): T | undefined;
|
|
14
|
-
//# sourceMappingURL=dlv.d.ts.map
|
package/lib/dlv.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dlv.d.ts","sourceRoot":"","sources":["../src/lib/dlv.ts"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EACzB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACtB,GAAG,CAAC,EAAE,CAAC,EACP,CAAC,CAAC,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,KAAK,GACZ,CAAC,GAAG,SAAS,CAOf"}
|
package/lib/dlv.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.dlv = dlv;
|
|
7
|
-
/*
|
|
8
|
-
MIT License
|
|
9
|
-
|
|
10
|
-
Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
|
|
11
|
-
|
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
13
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
14
|
-
the Software without restriction, including without limitation the rights to
|
|
15
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
16
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
-
subject to the following conditions:
|
|
18
|
-
|
|
19
|
-
The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
copies or substantial portions of the Software.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
24
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
25
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
26
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
27
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* @param obj The object to walk
|
|
31
|
-
* @param key The key path to walk the object with
|
|
32
|
-
* @param def A default value to return if the result is undefined
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* dlv(obj, "a.b.c.d")
|
|
36
|
-
* @example
|
|
37
|
-
* dlv(object, ["a", "b", "c", "d"])
|
|
38
|
-
* @example
|
|
39
|
-
* dlv(object, "foo.bar.baz", "Hello, default value!")
|
|
40
|
-
*/
|
|
41
|
-
function dlv(obj, key, def, p, undef) {
|
|
42
|
-
key = Array.isArray(key) ? key : key.split(".");
|
|
43
|
-
for (p = 0; p < key.length; p++) {
|
|
44
|
-
const k = key[p];
|
|
45
|
-
obj = k != null && obj ? obj[k] : undef;
|
|
46
|
-
}
|
|
47
|
-
return obj === undef ? def : obj;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=dlv.js.map
|
package/lib/dlv.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dlv.js","sourceRoot":"","sources":["../src/lib/dlv.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAqCH,kBAaC;AAhDD;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF;;;;;;;;;;;GAWG;AACH,SAAgB,GAAG,CACjB,GAAQ,EACR,GAAsB,EACtB,GAAO,EACP,CAAU,EACV,KAAa;IAEb,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,GAAG,GAAG,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACnC,CAAC"}
|
package/lib/is-plain-object.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.d.ts","sourceRoot":"","sources":["../src/lib/is-plain-object.ts"],"names":[],"mappings":"AA6BA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAa7D"}
|
package/lib/is-plain-object.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isPlainObject = isPlainObject;
|
|
7
|
-
/*
|
|
8
|
-
MIT License
|
|
9
|
-
|
|
10
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
11
|
-
|
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
13
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
14
|
-
the Software without restriction, including without limitation the rights to
|
|
15
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
16
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
-
subject to the following conditions:
|
|
18
|
-
|
|
19
|
-
The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
copies or substantial portions of the Software.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
24
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
25
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
26
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
27
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
// Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
|
|
30
|
-
function isPlainObject(value) {
|
|
31
|
-
if (typeof value !== "object" || value === null) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const prototype = Object.getPrototypeOf(value);
|
|
35
|
-
return ((prototype === null ||
|
|
36
|
-
prototype === Object.prototype ||
|
|
37
|
-
Object.getPrototypeOf(prototype) === null) &&
|
|
38
|
-
!(Symbol.toStringTag in value) &&
|
|
39
|
-
!(Symbol.iterator in value));
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=is-plain-object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.js","sourceRoot":"","sources":["../src/lib/is-plain-object.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA2BH,sCAaC;AAtCD;;;;;;;;;;;;;;;;;;;;;EAqBE;AAEF,iHAAiH;AAEjH,SAAgB,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CACL,CAAC,SAAS,KAAK,IAAI;QACjB,SAAS,KAAK,MAAM,CAAC,SAAS;QAC9B,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;QAC5C,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
package/src/lib/dlv.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
11
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
12
|
-
the Software without restriction, including without limitation the rights to
|
|
13
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
14
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
-
subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
22
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
23
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
24
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
25
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param obj The object to walk
|
|
30
|
-
* @param key The key path to walk the object with
|
|
31
|
-
* @param def A default value to return if the result is undefined
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* dlv(obj, "a.b.c.d")
|
|
35
|
-
* @example
|
|
36
|
-
* dlv(object, ["a", "b", "c", "d"])
|
|
37
|
-
* @example
|
|
38
|
-
* dlv(object, "foo.bar.baz", "Hello, default value!")
|
|
39
|
-
*/
|
|
40
|
-
export function dlv<T = any>(
|
|
41
|
-
obj: any,
|
|
42
|
-
key: string | string[],
|
|
43
|
-
def?: T,
|
|
44
|
-
p?: number,
|
|
45
|
-
undef?: never,
|
|
46
|
-
): T | undefined {
|
|
47
|
-
key = Array.isArray(key) ? key : key.split(".");
|
|
48
|
-
for (p = 0; p < key.length; p++) {
|
|
49
|
-
const k = key[p];
|
|
50
|
-
obj = k != null && obj ? obj[k] : undef;
|
|
51
|
-
}
|
|
52
|
-
return obj === undef ? def : obj;
|
|
53
|
-
}
|