@gr4vy/sdk 2.2.1 → 2.3.1
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/README.md +38 -0
- 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/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/auth.d.ts +20 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +20 -1
- package/lib/auth.js.map +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/index.ts +1 -0
- package/src/lib/auth.ts +36 -1
- 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/tests/auth.test.js +46 -2
- package/tests/flows/transaction-lifecycle.test.ts +30 -0
- 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/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/tests/auth.test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import jwt from "jsonwebtoken";
|
|
2
2
|
import snakecaseKeys from "snakecase-keys";
|
|
3
3
|
import timekeeper from "timekeeper";
|
|
4
|
-
import { describe, expect, test } from "vitest";
|
|
4
|
+
import { describe, expect, test, vi } from "vitest";
|
|
5
5
|
import { version } from "../package.json";
|
|
6
|
-
import { getEmbedToken, getToken, JWTScope, updateToken, SDK_METADATA } from "../src";
|
|
6
|
+
import { getEmbedToken, getEmbedTokenWithCheckoutSession, getToken, JWTScope, updateToken, SDK_METADATA } from "../src";
|
|
7
7
|
|
|
8
8
|
const privateKey = `-----BEGIN PRIVATE KEY-----
|
|
9
9
|
MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIBABM9jQu+HT87oIik
|
|
@@ -142,6 +142,50 @@ describe(".getEmbedToken", () => {
|
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
describe(".getEmbedTokenWithCheckoutSession", () => {
|
|
146
|
+
test("should create a checkout session and pin its ID in the Embed token", async () => {
|
|
147
|
+
const create = vi.fn().mockResolvedValue({ id: checkoutSessionId });
|
|
148
|
+
const client = { checkoutSessions: { create } };
|
|
149
|
+
|
|
150
|
+
const token = await getEmbedTokenWithCheckoutSession({
|
|
151
|
+
client,
|
|
152
|
+
privateKey,
|
|
153
|
+
embedParams,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const decoded = jwt.verify(token, privateKey, {
|
|
157
|
+
algorithms: ["ES512"],
|
|
158
|
+
complete: true,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(create).toHaveBeenCalledTimes(1);
|
|
162
|
+
expect(decoded.payload.scopes).toEqual(["embed"]);
|
|
163
|
+
expect(decoded.payload.checkout_session_id).toEqual(checkoutSessionId);
|
|
164
|
+
|
|
165
|
+
const connOptions =
|
|
166
|
+
embedParams.connectionOptions || embedParams["connection_options"];
|
|
167
|
+
const expected = snakecaseKeys(embedParams, { exclude: ["metadata"] });
|
|
168
|
+
expected["connection_options"] = connOptions;
|
|
169
|
+
expect(decoded.payload.embed).toEqual(expected);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("should forward the checkout session body and merchant account ID", async () => {
|
|
173
|
+
const create = vi.fn().mockResolvedValue({ id: checkoutSessionId });
|
|
174
|
+
const client = { checkoutSessions: { create } };
|
|
175
|
+
|
|
176
|
+
const checkoutSession = { metadata: { order: "123" } };
|
|
177
|
+
|
|
178
|
+
await getEmbedTokenWithCheckoutSession({
|
|
179
|
+
client,
|
|
180
|
+
privateKey,
|
|
181
|
+
checkoutSession,
|
|
182
|
+
merchantAccountId: "default",
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(create).toHaveBeenCalledWith(checkoutSession, "default");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
145
189
|
describe(".updateToken", () => {
|
|
146
190
|
test("should resign a token with a new signature and expiration", async () => {
|
|
147
191
|
timekeeper.freeze(Date.now());
|
|
@@ -84,6 +84,36 @@ describe("Transaction lifecycle", () => {
|
|
|
84
84
|
expect(topLevel.id).toBe(firstRefundId);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
test("authorize → capture → read captures back via list and get", async () => {
|
|
88
|
+
const transaction = await authorize(4500);
|
|
89
|
+
expect(transaction.status).toBe("authorization_succeeded");
|
|
90
|
+
|
|
91
|
+
unwrapTransaction(
|
|
92
|
+
await gr4vy.transactions.capture({
|
|
93
|
+
transactionId: transaction.id,
|
|
94
|
+
transactionCaptureCreate: { amount: 4500 },
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Wait until the capture is recorded against the transaction.
|
|
99
|
+
await pollUntil(
|
|
100
|
+
() => gr4vy.transactions.get(transaction.id),
|
|
101
|
+
(t) => t.status === "capture_succeeded",
|
|
102
|
+
{ description: "capture to succeed" }
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// List captures, then read one back by id.
|
|
106
|
+
const captures = await gr4vy.transactions.captures.list(transaction.id);
|
|
107
|
+
expect(captures.items.length).toBeGreaterThanOrEqual(1);
|
|
108
|
+
|
|
109
|
+
const captureId = captures.items[0]!.id;
|
|
110
|
+
const fetched = await gr4vy.transactions.captures.get(
|
|
111
|
+
transaction.id,
|
|
112
|
+
captureId
|
|
113
|
+
);
|
|
114
|
+
expect(fetched.id).toBe(captureId);
|
|
115
|
+
});
|
|
116
|
+
|
|
87
117
|
test("authorize → void releases the authorization", async () => {
|
|
88
118
|
const transaction = await authorize(3300);
|
|
89
119
|
expect(transaction.status).toBe("authorization_succeeded");
|
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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
MIT License
|
|
7
|
-
|
|
8
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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
|
-
// Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
|
|
29
|
-
|
|
30
|
-
export function isPlainObject(value: unknown): value is object {
|
|
31
|
-
if (typeof value !== "object" || value === null) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const prototype = Object.getPrototypeOf(value);
|
|
36
|
-
return (
|
|
37
|
-
(prototype === null ||
|
|
38
|
-
prototype === Object.prototype ||
|
|
39
|
-
Object.getPrototypeOf(prototype) === null) &&
|
|
40
|
-
!(Symbol.toStringTag in value) &&
|
|
41
|
-
!(Symbol.iterator in value)
|
|
42
|
-
);
|
|
43
|
-
}
|