@gr4vy/sdk 2.2.0 → 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.
Files changed (148) hide show
  1. package/README.md +7 -0
  2. package/funcs/auditLogsList.d.ts.map +1 -1
  3. package/funcs/auditLogsList.js +1 -2
  4. package/funcs/auditLogsList.js.map +1 -1
  5. package/funcs/buyersList.d.ts.map +1 -1
  6. package/funcs/buyersList.js +1 -2
  7. package/funcs/buyersList.js.map +1 -1
  8. package/funcs/giftCardsList.d.ts.map +1 -1
  9. package/funcs/giftCardsList.js +1 -2
  10. package/funcs/giftCardsList.js.map +1 -1
  11. package/funcs/merchantAccountsList.d.ts.map +1 -1
  12. package/funcs/merchantAccountsList.js +1 -2
  13. package/funcs/merchantAccountsList.js.map +1 -1
  14. package/funcs/paymentLinksList.d.ts.map +1 -1
  15. package/funcs/paymentLinksList.js +1 -2
  16. package/funcs/paymentLinksList.js.map +1 -1
  17. package/funcs/paymentMethodsList.d.ts.map +1 -1
  18. package/funcs/paymentMethodsList.js +1 -2
  19. package/funcs/paymentMethodsList.js.map +1 -1
  20. package/funcs/paymentServiceDefinitionsList.d.ts.map +1 -1
  21. package/funcs/paymentServiceDefinitionsList.js +1 -2
  22. package/funcs/paymentServiceDefinitionsList.js.map +1 -1
  23. package/funcs/paymentServicesList.d.ts.map +1 -1
  24. package/funcs/paymentServicesList.js +1 -2
  25. package/funcs/paymentServicesList.js.map +1 -1
  26. package/funcs/payoutsList.d.ts.map +1 -1
  27. package/funcs/payoutsList.js +1 -2
  28. package/funcs/payoutsList.js.map +1 -1
  29. package/funcs/reportExecutionsList.d.ts.map +1 -1
  30. package/funcs/reportExecutionsList.js +1 -2
  31. package/funcs/reportExecutionsList.js.map +1 -1
  32. package/funcs/reportsExecutionsList.d.ts.map +1 -1
  33. package/funcs/reportsExecutionsList.js +1 -2
  34. package/funcs/reportsExecutionsList.js.map +1 -1
  35. package/funcs/reportsList.d.ts.map +1 -1
  36. package/funcs/reportsList.js +1 -2
  37. package/funcs/reportsList.js.map +1 -1
  38. package/funcs/threeDsScenariosList.d.ts.map +1 -1
  39. package/funcs/threeDsScenariosList.js +1 -2
  40. package/funcs/threeDsScenariosList.js.map +1 -1
  41. package/funcs/transactionsCapturesGet.d.ts +18 -0
  42. package/funcs/transactionsCapturesGet.d.ts.map +1 -0
  43. package/funcs/transactionsCapturesGet.js +145 -0
  44. package/funcs/transactionsCapturesGet.js.map +1 -0
  45. package/funcs/transactionsCapturesList.d.ts +18 -0
  46. package/funcs/transactionsCapturesList.d.ts.map +1 -0
  47. package/funcs/transactionsCapturesList.js +140 -0
  48. package/funcs/transactionsCapturesList.js.map +1 -0
  49. package/funcs/transactionsEventsList.d.ts.map +1 -1
  50. package/funcs/transactionsEventsList.js +1 -2
  51. package/funcs/transactionsEventsList.js.map +1 -1
  52. package/funcs/transactionsList.d.ts.map +1 -1
  53. package/funcs/transactionsList.js +1 -2
  54. package/funcs/transactionsList.js.map +1 -1
  55. package/jsr.json +1 -1
  56. package/lib/config.d.ts +3 -3
  57. package/lib/config.js +3 -3
  58. package/lib/encodings.js +12 -12
  59. package/lib/encodings.js.map +1 -1
  60. package/lib/env.d.ts.map +1 -1
  61. package/lib/env.js +3 -3
  62. package/lib/env.js.map +1 -1
  63. package/lib/matchers.js +3 -3
  64. package/lib/matchers.js.map +1 -1
  65. package/lib/primitives.d.ts +1 -0
  66. package/lib/primitives.d.ts.map +1 -1
  67. package/lib/primitives.js +18 -0
  68. package/lib/primitives.js.map +1 -1
  69. package/models/components/capture.d.ts +84 -0
  70. package/models/components/capture.d.ts.map +1 -0
  71. package/models/components/capture.js +86 -0
  72. package/models/components/capture.js.map +1 -0
  73. package/models/components/capturecollection.d.ts +26 -0
  74. package/models/components/capturecollection.d.ts.map +1 -0
  75. package/models/components/capturecollection.js +60 -0
  76. package/models/components/capturecollection.js.map +1 -0
  77. package/models/components/index.d.ts +2 -0
  78. package/models/components/index.d.ts.map +1 -1
  79. package/models/components/index.js +2 -0
  80. package/models/components/index.js.map +1 -1
  81. package/models/components/nuveipseoptions.d.ts +2 -2
  82. package/models/components/transactioncapturecreate.d.ts +10 -0
  83. package/models/components/transactioncapturecreate.d.ts.map +1 -1
  84. package/models/components/transactioncapturecreate.js +3 -0
  85. package/models/components/transactioncapturecreate.js.map +1 -1
  86. package/models/operations/gettransactioncapture.d.ts +28 -0
  87. package/models/operations/gettransactioncapture.d.ts.map +1 -0
  88. package/models/operations/gettransactioncapture.js +57 -0
  89. package/models/operations/gettransactioncapture.js.map +1 -0
  90. package/models/operations/index.d.ts +2 -0
  91. package/models/operations/index.d.ts.map +1 -1
  92. package/models/operations/index.js +2 -0
  93. package/models/operations/index.js.map +1 -1
  94. package/models/operations/listtransactioncaptures.d.ts +23 -0
  95. package/models/operations/listtransactioncaptures.d.ts.map +1 -0
  96. package/models/operations/listtransactioncaptures.js +55 -0
  97. package/models/operations/listtransactioncaptures.js.map +1 -0
  98. package/package.json +1 -1
  99. package/sdk/captures.d.ts +19 -0
  100. package/sdk/captures.d.ts.map +1 -0
  101. package/sdk/captures.js +32 -0
  102. package/sdk/captures.js.map +1 -0
  103. package/sdk/transactions.d.ts +3 -0
  104. package/sdk/transactions.d.ts.map +1 -1
  105. package/sdk/transactions.js +4 -0
  106. package/sdk/transactions.js.map +1 -1
  107. package/src/funcs/auditLogsList.ts +2 -2
  108. package/src/funcs/buyersList.ts +2 -2
  109. package/src/funcs/giftCardsList.ts +2 -2
  110. package/src/funcs/merchantAccountsList.ts +2 -2
  111. package/src/funcs/paymentLinksList.ts +2 -2
  112. package/src/funcs/paymentMethodsList.ts +2 -2
  113. package/src/funcs/paymentServiceDefinitionsList.ts +2 -2
  114. package/src/funcs/paymentServicesList.ts +2 -2
  115. package/src/funcs/payoutsList.ts +2 -2
  116. package/src/funcs/reportExecutionsList.ts +2 -2
  117. package/src/funcs/reportsExecutionsList.ts +2 -2
  118. package/src/funcs/reportsList.ts +2 -2
  119. package/src/funcs/threeDsScenariosList.ts +2 -2
  120. package/src/funcs/transactionsCapturesGet.ts +255 -0
  121. package/src/funcs/transactionsCapturesList.ts +247 -0
  122. package/src/funcs/transactionsEventsList.ts +2 -2
  123. package/src/funcs/transactionsList.ts +2 -2
  124. package/src/lib/config.ts +3 -3
  125. package/src/lib/encodings.ts +1 -1
  126. package/src/lib/env.ts +7 -3
  127. package/src/lib/matchers.ts +1 -1
  128. package/src/lib/primitives.ts +16 -0
  129. package/src/models/components/capture.ts +142 -0
  130. package/src/models/components/capturecollection.ts +56 -0
  131. package/src/models/components/index.ts +2 -0
  132. package/src/models/components/nuveipseoptions.ts +2 -2
  133. package/src/models/components/transactioncapturecreate.ts +13 -0
  134. package/src/models/operations/gettransactioncapture.ts +58 -0
  135. package/src/models/operations/index.ts +2 -0
  136. package/src/models/operations/listtransactioncaptures.ts +51 -0
  137. package/src/sdk/captures.ts +51 -0
  138. package/src/sdk/transactions.ts +6 -0
  139. package/lib/dlv.d.ts +0 -14
  140. package/lib/dlv.d.ts.map +0 -1
  141. package/lib/dlv.js +0 -49
  142. package/lib/dlv.js.map +0 -1
  143. package/lib/is-plain-object.d.ts +0 -2
  144. package/lib/is-plain-object.d.ts.map +0 -1
  145. package/lib/is-plain-object.js +0 -41
  146. package/lib/is-plain-object.js.map +0 -1
  147. package/src/lib/dlv.ts +0 -53
  148. package/src/lib/is-plain-object.ts +0 -43
@@ -60,6 +60,7 @@ export * from "./getreport.js";
60
60
  export * from "./getreportexecution.js";
61
61
  export * from "./getthreedsscenario.js";
62
62
  export * from "./gettransaction.js";
63
+ export * from "./gettransactioncapture.js";
63
64
  export * from "./gettransactionrefund.js";
64
65
  export * from "./gettransactionsettlement.js";
65
66
  export * from "./listallreportexecutions.js";
@@ -85,6 +86,7 @@ export * from "./listreportexecutions.js";
85
86
  export * from "./listreports.js";
86
87
  export * from "./listthreedsconfigurations.js";
87
88
  export * from "./listtransactionactions.js";
89
+ export * from "./listtransactioncaptures.js";
88
90
  export * from "./listtransactionevents.js";
89
91
  export * from "./listtransactionrefunds.js";
90
92
  export * from "./listtransactions.js";
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+
8
+ export type ListTransactionCapturesGlobals = {
9
+ merchantAccountId?: string | undefined;
10
+ };
11
+
12
+ export type ListTransactionCapturesRequest = {
13
+ /**
14
+ * The unique identifier of the transaction.
15
+ */
16
+ transactionId: string;
17
+ /**
18
+ * The ID of the merchant account to use for this request.
19
+ */
20
+ merchantAccountId?: string | null | undefined;
21
+ };
22
+
23
+ /** @internal */
24
+ export type ListTransactionCapturesRequest$Outbound = {
25
+ transaction_id: string;
26
+ merchantAccountId?: string | null | undefined;
27
+ };
28
+
29
+ /** @internal */
30
+ export const ListTransactionCapturesRequest$outboundSchema: z.ZodType<
31
+ ListTransactionCapturesRequest$Outbound,
32
+ z.ZodTypeDef,
33
+ ListTransactionCapturesRequest
34
+ > = z.object({
35
+ transactionId: z.string(),
36
+ merchantAccountId: z.nullable(z.string()).optional(),
37
+ }).transform((v) => {
38
+ return remap$(v, {
39
+ transactionId: "transaction_id",
40
+ });
41
+ });
42
+
43
+ export function listTransactionCapturesRequestToJSON(
44
+ listTransactionCapturesRequest: ListTransactionCapturesRequest,
45
+ ): string {
46
+ return JSON.stringify(
47
+ ListTransactionCapturesRequest$outboundSchema.parse(
48
+ listTransactionCapturesRequest,
49
+ ),
50
+ );
51
+ }
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { transactionsCapturesGet } from "../funcs/transactionsCapturesGet.js";
6
+ import { transactionsCapturesList } from "../funcs/transactionsCapturesList.js";
7
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
8
+ import * as components from "../models/components/index.js";
9
+ import { unwrapAsync } from "../types/fp.js";
10
+
11
+ export class Captures extends ClientSDK {
12
+ /**
13
+ * List transaction captures
14
+ *
15
+ * @remarks
16
+ * List all captures for a specific transaction.
17
+ */
18
+ async list(
19
+ transactionId: string,
20
+ merchantAccountId?: string | null | undefined,
21
+ options?: RequestOptions,
22
+ ): Promise<components.CaptureCollection> {
23
+ return unwrapAsync(transactionsCapturesList(
24
+ this,
25
+ transactionId,
26
+ merchantAccountId,
27
+ options,
28
+ ));
29
+ }
30
+
31
+ /**
32
+ * Get transaction capture
33
+ *
34
+ * @remarks
35
+ * Retrieve a specific capture for a transaction by its unique identifier.
36
+ */
37
+ async get(
38
+ transactionId: string,
39
+ captureId: string,
40
+ merchantAccountId?: string | null | undefined,
41
+ options?: RequestOptions,
42
+ ): Promise<components.Capture> {
43
+ return unwrapAsync(transactionsCapturesGet(
44
+ this,
45
+ transactionId,
46
+ captureId,
47
+ merchantAccountId,
48
+ options,
49
+ ));
50
+ }
51
+ }
@@ -16,6 +16,7 @@ import * as operations from "../models/operations/index.js";
16
16
  import { unwrapAsync } from "../types/fp.js";
17
17
  import { PageIterator, unwrapResultIterator } from "../types/operations.js";
18
18
  import { Actions } from "./actions.js";
19
+ import { Captures } from "./captures.js";
19
20
  import { Events } from "./events.js";
20
21
  import { Gr4vyRefunds } from "./gr4vyrefunds.js";
21
22
  import { Settlements } from "./settlements.js";
@@ -41,6 +42,11 @@ export class Transactions extends ClientSDK {
41
42
  return (this._settlements ??= new Settlements(this._options));
42
43
  }
43
44
 
45
+ private _captures?: Captures;
46
+ get captures(): Captures {
47
+ return (this._captures ??= new Captures(this._options));
48
+ }
49
+
44
50
  /**
45
51
  * List transactions
46
52
  *
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"}
@@ -1,2 +0,0 @@
1
- export declare function isPlainObject(value: unknown): value is object;
2
- //# sourceMappingURL=is-plain-object.d.ts.map
@@ -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"}
@@ -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
- }