@lightsparkdev/lightspark-sdk 1.8.0 → 1.8.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{chunk-J7GJGYME.js → chunk-4KFNQOMH.js} +84 -39
  3. package/dist/index.cjs +142 -91
  4. package/dist/index.js +3 -3
  5. package/dist/objects/index.cjs +97 -52
  6. package/dist/objects/index.js +1 -1
  7. package/package.json +2 -2
  8. package/src/objects/Account.ts +4 -2
  9. package/src/objects/ApiToken.ts +2 -2
  10. package/src/objects/AuditLogActor.ts +2 -2
  11. package/src/objects/Channel.ts +2 -2
  12. package/src/objects/ChannelClosingTransaction.ts +2 -2
  13. package/src/objects/ChannelOpeningTransaction.ts +2 -2
  14. package/src/objects/ChannelSnapshot.ts +2 -2
  15. package/src/objects/Deposit.ts +2 -2
  16. package/src/objects/GraphNode.ts +2 -2
  17. package/src/objects/Hop.ts +2 -2
  18. package/src/objects/IncomingPayment.ts +2 -2
  19. package/src/objects/IncomingPaymentAttempt.ts +2 -2
  20. package/src/objects/Invoice.ts +2 -2
  21. package/src/objects/LightningTransaction.ts +2 -2
  22. package/src/objects/LightsparkNode.ts +2 -2
  23. package/src/objects/LightsparkNodeOwner.ts +2 -2
  24. package/src/objects/LightsparkNodeWithOSK.ts +2 -2
  25. package/src/objects/LightsparkNodeWithRemoteSigning.ts +2 -2
  26. package/src/objects/Node.ts +2 -2
  27. package/src/objects/OnChainTransaction.ts +2 -2
  28. package/src/objects/OutgoingPayment.ts +2 -2
  29. package/src/objects/OutgoingPaymentAttempt.ts +2 -2
  30. package/src/objects/PaymentRequest.ts +2 -2
  31. package/src/objects/RoutingTransaction.ts +2 -2
  32. package/src/objects/Signable.ts +2 -2
  33. package/src/objects/SignablePayload.ts +2 -2
  34. package/src/objects/Transaction.ts +2 -2
  35. package/src/objects/UmaInvitation.ts +2 -2
  36. package/src/objects/Wallet.ts +2 -2
  37. package/src/objects/Withdrawal.ts +2 -2
  38. package/src/objects/WithdrawalRequest.ts +2 -2
  39. package/src/tests/generated-objects.test.ts +93 -0
  40. package/src/tests/serialization.test.ts +0 -21
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type AccountToApiTokensConnection from "./AccountToApiTokensConnection.js";
@@ -1891,7 +1891,9 @@ ${FRAGMENT}
1891
1891
  `,
1892
1892
  variables: {},
1893
1893
  constructObject: (data: unknown) =>
1894
- data && typeof data === "object" && "current_account" in data
1894
+ isObject(data) &&
1895
+ "current_account" in data &&
1896
+ isObject(data.current_account)
1895
1897
  ? AccountFromJson(data.current_account)
1896
1898
  : null,
1897
1899
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import Permission from "./Permission.js";
5
5
 
6
6
  /**
@@ -95,7 +95,7 @@ ${FRAGMENT}
95
95
  `,
96
96
  variables: { id },
97
97
  constructObject: (data: unknown) =>
98
- data && typeof data === "object" && "entity" in data
98
+ isObject(data) && "entity" in data && isObject(data.entity)
99
99
  ? ApiTokenFromJson(data.entity)
100
100
  : null,
101
101
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type ApiToken from "./ApiToken.js";
5
5
  import Permission from "./Permission.js";
6
6
 
@@ -90,7 +90,7 @@ ${FRAGMENT}
90
90
  `,
91
91
  variables: { id },
92
92
  constructObject: (data: unknown) =>
93
- data && typeof data === "object" && "entity" in data
93
+ isObject(data) && "entity" in data && isObject(data.entity)
94
94
  ? AuditLogActorFromJson(data.entity)
95
95
  : null,
96
96
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type ChannelFees from "./ChannelFees.js";
@@ -182,7 +182,7 @@ ${FRAGMENT}
182
182
  `,
183
183
  variables: { id },
184
184
  constructObject: (data: unknown) =>
185
- data && typeof data === "object" && "entity" in data
185
+ isObject(data) && "entity" in data && isObject(data.entity)
186
186
  ? ChannelFromJson(data.entity)
187
187
  : null,
188
188
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? ChannelClosingTransactionFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? ChannelOpeningTransactionFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -162,7 +162,7 @@ ${FRAGMENT}
162
162
  `,
163
163
  variables: { id },
164
164
  constructObject: (data: unknown) =>
165
- data && typeof data === "object" && "entity" in data
165
+ isObject(data) && "entity" in data && isObject(data.entity)
166
166
  ? ChannelSnapshotFromJson(data.entity)
167
167
  : null,
168
168
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -156,7 +156,7 @@ ${FRAGMENT}
156
156
  `,
157
157
  variables: { id },
158
158
  constructObject: (data: unknown) =>
159
- data && typeof data === "object" && "entity" in data
159
+ isObject(data) && "entity" in data && isObject(data.entity)
160
160
  ? DepositFromJson(data.entity)
161
161
  : null,
162
162
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
@@ -108,7 +108,7 @@ ${FRAGMENT}
108
108
  `,
109
109
  variables: { id },
110
110
  constructObject: (data: unknown) =>
111
- data && typeof data === "object" && "entity" in data
111
+ isObject(data) && "entity" in data && isObject(data.entity)
112
112
  ? GraphNodeFromJson(data.entity)
113
113
  : null,
114
114
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -125,7 +125,7 @@ ${FRAGMENT}
125
125
  `,
126
126
  variables: { id },
127
127
  constructObject: (data: unknown) =>
128
- data && typeof data === "object" && "entity" in data
128
+ isObject(data) && "entity" in data && isObject(data.entity)
129
129
  ? HopFromJson(data.entity)
130
130
  : null,
131
131
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -140,7 +140,7 @@ ${FRAGMENT}
140
140
  `,
141
141
  variables: { id },
142
142
  constructObject: (data: unknown) =>
143
- data && typeof data === "object" && "entity" in data
143
+ isObject(data) && "entity" in data && isObject(data.entity)
144
144
  ? IncomingPaymentFromJson(data.entity)
145
145
  : null,
146
146
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -111,7 +111,7 @@ ${FRAGMENT}
111
111
  `,
112
112
  variables: { id },
113
113
  constructObject: (data: unknown) =>
114
- data && typeof data === "object" && "entity" in data
114
+ isObject(data) && "entity" in data && isObject(data.entity)
115
115
  ? IncomingPaymentAttemptFromJson(data.entity)
116
116
  : null,
117
117
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -407,7 +407,7 @@ ${FRAGMENT}
407
407
  `,
408
408
  variables: { id },
409
409
  constructObject: (data: unknown) =>
410
- data && typeof data === "object" && "entity" in data
410
+ isObject(data) && "entity" in data && isObject(data.entity)
411
411
  ? InvoiceFromJson(data.entity)
412
412
  : null,
413
413
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -680,7 +680,7 @@ ${FRAGMENT}
680
680
  `,
681
681
  variables: { id },
682
682
  constructObject: (data: unknown) =>
683
- data && typeof data === "object" && "entity" in data
683
+ isObject(data) && "entity" in data && isObject(data.entity)
684
684
  ? LightningTransactionFromJson(data.entity)
685
685
  : null,
686
686
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type LightsparkClient from "../client.js";
5
5
  import type Balances from "./Balances.js";
6
6
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
@@ -662,7 +662,7 @@ ${FRAGMENT}
662
662
  `,
663
663
  variables: { id },
664
664
  constructObject: (data: unknown) =>
665
- data && typeof data === "object" && "entity" in data
665
+ isObject(data) && "entity" in data && isObject(data.entity)
666
666
  ? LightsparkNodeFromJson(data.entity)
667
667
  : null,
668
668
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import Account from "./Account.js";
5
5
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
6
  import Wallet from "./Wallet.js";
@@ -155,7 +155,7 @@ ${FRAGMENT}
155
155
  `,
156
156
  variables: { id },
157
157
  constructObject: (data: unknown) =>
158
- data && typeof data === "object" && "entity" in data
158
+ isObject(data) && "entity" in data && isObject(data.entity)
159
159
  ? LightsparkNodeOwnerFromJson(data.entity)
160
160
  : null,
161
161
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
@@ -361,7 +361,7 @@ ${FRAGMENT}
361
361
  `,
362
362
  variables: { id },
363
363
  constructObject: (data: unknown) =>
364
- data && typeof data === "object" && "entity" in data
364
+ isObject(data) && "entity" in data && isObject(data.entity)
365
365
  ? LightsparkNodeWithOSKFromJson(data.entity)
366
366
  : null,
367
367
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
@@ -354,7 +354,7 @@ ${FRAGMENT}
354
354
  `,
355
355
  variables: { id },
356
356
  constructObject: (data: unknown) =>
357
- data && typeof data === "object" && "entity" in data
357
+ isObject(data) && "entity" in data && isObject(data.entity)
358
358
  ? LightsparkNodeWithRemoteSigningFromJson(data.entity)
359
359
  : null,
360
360
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type LightsparkClient from "../client.js";
5
5
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
@@ -631,7 +631,7 @@ ${FRAGMENT}
631
631
  `,
632
632
  variables: { id },
633
633
  constructObject: (data: unknown) =>
634
- data && typeof data === "object" && "entity" in data
634
+ isObject(data) && "entity" in data && isObject(data.entity)
635
635
  ? NodeFromJson(data.entity)
636
636
  : null,
637
637
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
5
5
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -426,7 +426,7 @@ ${FRAGMENT}
426
426
  `,
427
427
  variables: { id },
428
428
  constructObject: (data: unknown) =>
429
- data && typeof data === "object" && "entity" in data
429
+ isObject(data) && "entity" in data && isObject(data.entity)
430
430
  ? OnChainTransactionFromJson(data.entity)
431
431
  : null,
432
432
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? OutgoingPaymentFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -144,7 +144,7 @@ ${FRAGMENT}
144
144
  `,
145
145
  variables: { id },
146
146
  constructObject: (data: unknown) =>
147
- data && typeof data === "object" && "entity" in data
147
+ isObject(data) && "entity" in data && isObject(data.entity)
148
148
  ? OutgoingPaymentAttemptFromJson(data.entity)
149
149
  : null,
150
150
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import {
5
5
  CurrencyAmountFromJson,
6
6
  CurrencyAmountToJson,
@@ -412,7 +412,7 @@ ${FRAGMENT}
412
412
  `,
413
413
  variables: { id },
414
414
  constructObject: (data: unknown) =>
415
- data && typeof data === "object" && "entity" in data
415
+ isObject(data) && "entity" in data && isObject(data.entity)
416
416
  ? PaymentRequestFromJson(data.entity)
417
417
  : null,
418
418
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -171,7 +171,7 @@ ${FRAGMENT}
171
171
  `,
172
172
  variables: { id },
173
173
  constructObject: (data: unknown) =>
174
- data && typeof data === "object" && "entity" in data
174
+ isObject(data) && "entity" in data && isObject(data.entity)
175
175
  ? RoutingTransactionFromJson(data.entity)
176
176
  : null,
177
177
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
 
5
5
  interface Signable {
6
6
  /**
@@ -59,7 +59,7 @@ ${FRAGMENT}
59
59
  `,
60
60
  variables: { id },
61
61
  constructObject: (data: unknown) =>
62
- data && typeof data === "object" && "entity" in data
62
+ isObject(data) && "entity" in data && isObject(data.entity)
63
63
  ? SignableFromJson(data.entity)
64
64
  : null,
65
65
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import SignablePayloadStatus from "./SignablePayloadStatus.js";
5
5
 
6
6
  interface SignablePayload {
@@ -103,7 +103,7 @@ ${FRAGMENT}
103
103
  `,
104
104
  variables: { id },
105
105
  constructObject: (data: unknown) =>
106
- data && typeof data === "object" && "entity" in data
106
+ isObject(data) && "entity" in data && isObject(data.entity)
107
107
  ? SignablePayloadFromJson(data.entity)
108
108
  : null,
109
109
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
5
5
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -1004,7 +1004,7 @@ ${FRAGMENT}
1004
1004
  `,
1005
1005
  variables: { id },
1006
1006
  constructObject: (data: unknown) =>
1007
- data && typeof data === "object" && "entity" in data
1007
+ isObject(data) && "entity" in data && isObject(data.entity)
1008
1008
  ? TransactionFromJson(data.entity)
1009
1009
  : null,
1010
1010
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import IncentivesIneligibilityReason from "./IncentivesIneligibilityReason.js";
5
5
  import IncentivesStatus from "./IncentivesStatus.js";
6
6
 
@@ -107,7 +107,7 @@ ${FRAGMENT}
107
107
  `,
108
108
  variables: { id },
109
109
  constructObject: (data: unknown) =>
110
- data && typeof data === "object" && "entity" in data
110
+ isObject(data) && "entity" in data && isObject(data.entity)
111
111
  ? UmaInvitationFromJson(data.entity)
112
112
  : null,
113
113
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
@@ -1182,7 +1182,7 @@ ${FRAGMENT}
1182
1182
  `,
1183
1183
  variables: { id },
1184
1184
  constructObject: (data: unknown) =>
1185
- data && typeof data === "object" && "entity" in data
1185
+ isObject(data) && "entity" in data && isObject(data.entity)
1186
1186
  ? WalletFromJson(data.entity)
1187
1187
  : null,
1188
1188
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -156,7 +156,7 @@ ${FRAGMENT}
156
156
  `,
157
157
  variables: { id },
158
158
  constructObject: (data: unknown) =>
159
- data && typeof data === "object" && "entity" in data
159
+ isObject(data) && "entity" in data && isObject(data.entity)
160
160
  ? WithdrawalFromJson(data.entity)
161
161
  : null,
162
162
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -295,7 +295,7 @@ ${FRAGMENT}
295
295
  `,
296
296
  variables: { id },
297
297
  constructObject: (data: unknown) =>
298
- data && typeof data === "object" && "entity" in data
298
+ isObject(data) && "entity" in data && isObject(data.entity)
299
299
  ? WithdrawalRequestFromJson(data.entity)
300
300
  : null,
301
301
  };
@@ -0,0 +1,93 @@
1
+ import { getHopQuery } from "../objects/Hop.js";
2
+ import {
3
+ InvoiceDataFromJson,
4
+ InvoiceDataToJson,
5
+ } from "../objects/InvoiceData.js";
6
+
7
+ describe("Serialization", () => {
8
+ test("should serialize and deserialize InvoiceData to the same object", () => {
9
+ const serialized = `{"__typename": "InvoiceData", "invoice_data_encoded_payment_request":"lnbcrt34170n1pj5vdn4pp56jhw0672v566u4rvl333v8hwwuvavvu9gx4a2mqag4pkrvm0hwkqhp5xaz278y6cejcvpqnndl4wfq3slgthjduwlfksg778aevn23v2pdscqzpgxqyz5vqsp5ee5jezfvjqvvz7hfwta3ekk8hs6dq36szkgp40qh7twa8upquxlq9qyyssqjg2slc95falxf2t67y0wu2w43qwfcvfflwl8tn4ppqw9tumwqxk36qkfct9p2w8c3yy2ld7c6nacy4ssv2gl6qyqfpmhl4jmarnjf8cpvjlxek","invoice_data_bitcoin_network":"REGTEST","invoice_data_payment_hash":"d4aee7ebca6535ae546cfc63161eee7719d6338541abd56c1d454361b36fbbac","invoice_data_amount":{"currency_amount_original_value":3417,"currency_amount_original_unit":"SATOSHI","currency_amount_preferred_currency_unit":"USD","currency_amount_preferred_currency_value_rounded":118,"currency_amount_preferred_currency_value_approx":118.89352818371607},"invoice_data_created_at":"2023-11-04T12:17:57Z","invoice_data_expires_at":"2023-11-05T12:17:57Z","invoice_data_memo":null,"invoice_data_destination":{"graph_node_id":"GraphNode:0189a572-6dba-cf00-0000-ac0908d34ea6","graph_node_created_at":"2023-07-30T06:18:07.162759Z","graph_node_updated_at":"2023-11-04T12:01:04.015414Z","graph_node_alias":"ls_test_vSViIQitob_SE","graph_node_bitcoin_network":"REGTEST","graph_node_color":"#3399ff","graph_node_conductivity":null,"graph_node_display_name":"ls_test_vSViIQitob_SE","graph_node_public_key":"02253935a5703a6f0429081e08d2defce0faa15f4d75305302284751d53a4e0608", "__typename":"GraphNode"}}`;
10
+ const deserialized = InvoiceDataFromJson(JSON.parse(serialized));
11
+ const reserialized = InvoiceDataToJson(deserialized) as Record<
12
+ string,
13
+ unknown
14
+ >;
15
+ expect(reserialized).toEqual(JSON.parse(serialized));
16
+
17
+ const deserializedAgain = InvoiceDataFromJson(reserialized);
18
+ expect(JSON.stringify(deserializedAgain)).toEqual(
19
+ JSON.stringify(deserialized),
20
+ );
21
+ });
22
+ });
23
+
24
+ describe("Get entity query functions", () => {
25
+ test("constructObject should return null when data is not an object", () => {
26
+ const query = getHopQuery("something");
27
+ expect(query.constructObject(null)).toBeNull();
28
+ expect(query.constructObject(undefined)).toBeNull();
29
+ expect(query.constructObject("string")).toBeNull();
30
+ expect(query.constructObject(123)).toBeNull();
31
+ expect(query.constructObject(true)).toBeNull();
32
+ });
33
+ test("constructObject should return null when data.{path} is not an object", () => {
34
+ const query = getHopQuery("something");
35
+ expect(query.constructObject({ entity: null })).toBeNull();
36
+ expect(query.constructObject({ entity: undefined })).toBeNull();
37
+ expect(query.constructObject({ entity: "string" })).toBeNull();
38
+ expect(query.constructObject({ entity: 123 })).toBeNull();
39
+ expect(query.constructObject({ entity: true })).toBeNull();
40
+ });
41
+ test("constructObject should return the object when data.{path} is an object", () => {
42
+ const query = getHopQuery("something");
43
+ const data = {
44
+ entity: {
45
+ hop_id: "123",
46
+ hop_created_at: "2023-11-04T12:17:57Z",
47
+ hop_updated_at: "2023-11-04T12:17:57Z",
48
+ hop_index: 1,
49
+ hop_destination: { id: "destination" },
50
+ hop_public_key: "public_key",
51
+ hop_amount_to_forward: {
52
+ currency_amount_original_value: 3417,
53
+ currency_amount_original_unit: "SATOSHI",
54
+ currency_amount_preferred_currency_unit: "USD",
55
+ currency_amount_preferred_currency_value_rounded: 118,
56
+ currency_amount_preferred_currency_value_approx: 118.89352818371607,
57
+ },
58
+ hop_fee: {
59
+ currency_amount_original_value: 3417,
60
+ currency_amount_original_unit: "SATOSHI",
61
+ currency_amount_preferred_currency_unit: "USD",
62
+ currency_amount_preferred_currency_value_rounded: 118,
63
+ currency_amount_preferred_currency_value_approx: 118.89352818371607,
64
+ },
65
+ hop_expiry_block_height: 123,
66
+ },
67
+ };
68
+ expect(query.constructObject(data)).toEqual({
69
+ id: "123",
70
+ createdAt: "2023-11-04T12:17:57Z",
71
+ updatedAt: "2023-11-04T12:17:57Z",
72
+ index: 1,
73
+ typename: "Hop",
74
+ destinationId: "destination",
75
+ publicKey: "public_key",
76
+ amountToForward: {
77
+ originalValue: 3417,
78
+ originalUnit: "SATOSHI",
79
+ preferredCurrencyUnit: "USD",
80
+ preferredCurrencyValueRounded: 118,
81
+ preferredCurrencyValueApprox: 118.89352818371607,
82
+ },
83
+ fee: {
84
+ originalValue: 3417,
85
+ originalUnit: "SATOSHI",
86
+ preferredCurrencyUnit: "USD",
87
+ preferredCurrencyValueRounded: 118,
88
+ preferredCurrencyValueApprox: 118.89352818371607,
89
+ },
90
+ expiryBlockHeight: 123,
91
+ });
92
+ });
93
+ });