@lightsparkdev/lightspark-sdk 1.1.6 → 1.2.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 (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-7UNNCH5S.js → chunk-VTPDR6P4.js} +1270 -342
  3. package/dist/{index-5235e43b.d.ts → index-f040db9f.d.ts} +707 -407
  4. package/dist/index.cjs +1247 -319
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +7 -7
  7. package/dist/objects/index.cjs +1180 -306
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -5
  10. package/package.json +2 -2
  11. package/src/objects/Account.ts +175 -2
  12. package/src/objects/AccountToApiTokensConnection.ts +16 -5
  13. package/src/objects/AccountToChannelsConnection.ts +9 -0
  14. package/src/objects/AccountToNodesConnection.ts +19 -5
  15. package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
  16. package/src/objects/AccountToTransactionsConnection.ts +33 -9
  17. package/src/objects/AccountToWalletsConnection.ts +13 -4
  18. package/src/objects/ApiToken.ts +13 -3
  19. package/src/objects/Balances.ts +17 -3
  20. package/src/objects/BlockchainBalance.ts +34 -9
  21. package/src/objects/Channel.ts +61 -16
  22. package/src/objects/ChannelClosingTransaction.ts +81 -61
  23. package/src/objects/ChannelFees.ts +16 -5
  24. package/src/objects/ChannelOpeningTransaction.ts +81 -61
  25. package/src/objects/ChannelSnapshot.ts +66 -6
  26. package/src/objects/ChannelToTransactionsConnection.ts +26 -6
  27. package/src/objects/Connection.ts +205 -10
  28. package/src/objects/CreateApiTokenInput.ts +8 -2
  29. package/src/objects/CreateApiTokenOutput.ts +9 -3
  30. package/src/objects/CreateInvoiceInput.ts +14 -5
  31. package/src/objects/CreateInvoiceOutput.ts +7 -2
  32. package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
  33. package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
  34. package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
  35. package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
  36. package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
  37. package/src/objects/CreateTestModePaymentInput.ts +12 -3
  38. package/src/objects/CreateTestModePaymentoutput.ts +12 -2
  39. package/src/objects/CreateUmaInvoiceInput.ts +13 -3
  40. package/src/objects/CurrencyAmount.ts +13 -2
  41. package/src/objects/DeclineToSignMessagesInput.ts +9 -2
  42. package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
  43. package/src/objects/DeleteApiTokenInput.ts +7 -2
  44. package/src/objects/DeleteApiTokenOutput.ts +7 -2
  45. package/src/objects/Deposit.ts +77 -61
  46. package/src/objects/Entity.ts +184 -2
  47. package/src/objects/FeeEstimate.ts +12 -3
  48. package/src/objects/FundNodeInput.ts +9 -3
  49. package/src/objects/FundNodeOutput.ts +11 -3
  50. package/src/objects/GraphNode.ts +21 -5
  51. package/src/objects/Hop.ts +27 -9
  52. package/src/objects/HtlcAttemptFailureCode.ts +2 -0
  53. package/src/objects/IdAndSignature.ts +8 -2
  54. package/src/objects/IncomingPayment.ts +33 -7
  55. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  56. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  57. package/src/objects/Invoice.ts +91 -24
  58. package/src/objects/InvoiceData.ts +75 -6
  59. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  60. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  61. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  62. package/src/objects/LightningTransaction.ts +171 -28
  63. package/src/objects/LightsparkNode.ts +311 -208
  64. package/src/objects/LightsparkNodeOwner.ts +35 -4
  65. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  66. package/src/objects/LightsparkNodeWithOSK.ts +97 -15
  67. package/src/objects/LightsparkNodeWithRemoteSigning.ts +93 -13
  68. package/src/objects/Node.ts +269 -67
  69. package/src/objects/NodeAddress.ts +8 -2
  70. package/src/objects/NodeToAddressesConnection.ts +13 -3
  71. package/src/objects/OnChainTransaction.ts +156 -44
  72. package/src/objects/OutgoingPayment.ts +127 -14
  73. package/src/objects/OutgoingPaymentAttempt.ts +57 -8
  74. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  75. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  76. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  77. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  78. package/src/objects/PageInfo.ts +14 -6
  79. package/src/objects/PayInvoiceInput.ts +12 -3
  80. package/src/objects/PayInvoiceOutput.ts +7 -2
  81. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  82. package/src/objects/PaymentRequest.ts +81 -5
  83. package/src/objects/PaymentRequestData.ts +81 -4
  84. package/src/objects/PostTransactionData.ts +12 -3
  85. package/src/objects/RegisterPaymentInput.ts +10 -2
  86. package/src/objects/RegisterPaymentOutput.ts +9 -2
  87. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  88. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  89. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  90. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  91. package/src/objects/RequestWithdrawalInput.ts +12 -2
  92. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  93. package/src/objects/RichText.ts +7 -2
  94. package/src/objects/RoutingTransaction.ts +62 -41
  95. package/src/objects/ScreenNodeInput.ts +8 -2
  96. package/src/objects/ScreenNodeOutput.ts +7 -2
  97. package/src/objects/Secret.ts +8 -2
  98. package/src/objects/SendPaymentInput.ts +11 -2
  99. package/src/objects/SendPaymentOutput.ts +7 -2
  100. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  101. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  102. package/src/objects/SignInvoiceInput.ts +9 -2
  103. package/src/objects/SignInvoiceOutput.ts +7 -2
  104. package/src/objects/SignMessagesInput.ts +13 -3
  105. package/src/objects/SignMessagesOutput.ts +13 -3
  106. package/src/objects/Signable.ts +10 -3
  107. package/src/objects/SignablePayload.ts +18 -5
  108. package/src/objects/Transaction.ts +260 -9
  109. package/src/objects/TransactionFailures.ts +11 -4
  110. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  111. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  112. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  113. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  114. package/src/objects/Wallet.ts +130 -5
  115. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  116. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  117. package/src/objects/Withdrawal.ts +77 -61
  118. package/src/objects/WithdrawalRequest.ts +25 -4
  119. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  120. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  121. package/src/objects/index.ts +5 -2
  122. package/src/tests/integration/client.test.ts +46 -7
  123. package/src/tests/serialization.test.ts +18 -0
@@ -1,18 +1,31 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
- type ChannelSnapshot = {
7
- localBalance?: CurrencyAmount;
9
+ interface ChannelSnapshot {
10
+ channelId: string;
8
11
 
9
- localUnsettledBalance?: CurrencyAmount;
12
+ timestamp: string;
10
13
 
11
- localChannelReserve?: CurrencyAmount;
12
- };
14
+ localBalance?: CurrencyAmount | undefined;
15
+
16
+ localUnsettledBalance?: CurrencyAmount | undefined;
17
+
18
+ localChannelReserve?: CurrencyAmount | undefined;
19
+
20
+ remoteBalance?: CurrencyAmount | undefined;
21
+
22
+ remoteUnsettledBalance?: CurrencyAmount | undefined;
23
+ }
13
24
 
14
25
  export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
15
26
  return {
27
+ channelId: obj["channel_snapshot_channel"].id,
28
+ timestamp: obj["channel_snapshot_timestamp"],
16
29
  localBalance: !!obj["channel_snapshot_local_balance"]
17
30
  ? CurrencyAmountFromJson(obj["channel_snapshot_local_balance"])
18
31
  : undefined,
@@ -22,12 +35,43 @@ export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
22
35
  localChannelReserve: !!obj["channel_snapshot_local_channel_reserve"]
23
36
  ? CurrencyAmountFromJson(obj["channel_snapshot_local_channel_reserve"])
24
37
  : undefined,
38
+ remoteBalance: !!obj["channel_snapshot_remote_balance"]
39
+ ? CurrencyAmountFromJson(obj["channel_snapshot_remote_balance"])
40
+ : undefined,
41
+ remoteUnsettledBalance: !!obj["channel_snapshot_remote_unsettled_balance"]
42
+ ? CurrencyAmountFromJson(obj["channel_snapshot_remote_unsettled_balance"])
43
+ : undefined,
25
44
  } as ChannelSnapshot;
26
45
  };
46
+ export const ChannelSnapshotToJson = (obj: ChannelSnapshot): any => {
47
+ return {
48
+ channel_snapshot_channel: { id: obj.channelId },
49
+ channel_snapshot_timestamp: obj.timestamp,
50
+ channel_snapshot_local_balance: obj.localBalance
51
+ ? CurrencyAmountToJson(obj.localBalance)
52
+ : undefined,
53
+ channel_snapshot_local_unsettled_balance: obj.localUnsettledBalance
54
+ ? CurrencyAmountToJson(obj.localUnsettledBalance)
55
+ : undefined,
56
+ channel_snapshot_local_channel_reserve: obj.localChannelReserve
57
+ ? CurrencyAmountToJson(obj.localChannelReserve)
58
+ : undefined,
59
+ channel_snapshot_remote_balance: obj.remoteBalance
60
+ ? CurrencyAmountToJson(obj.remoteBalance)
61
+ : undefined,
62
+ channel_snapshot_remote_unsettled_balance: obj.remoteUnsettledBalance
63
+ ? CurrencyAmountToJson(obj.remoteUnsettledBalance)
64
+ : undefined,
65
+ };
66
+ };
27
67
 
28
68
  export const FRAGMENT = `
29
69
  fragment ChannelSnapshotFragment on ChannelSnapshot {
30
70
  __typename
71
+ channel_snapshot_channel: channel {
72
+ id
73
+ }
74
+ channel_snapshot_timestamp: timestamp
31
75
  channel_snapshot_local_balance: local_balance {
32
76
  __typename
33
77
  currency_amount_original_value: original_value
@@ -52,6 +96,22 @@ fragment ChannelSnapshotFragment on ChannelSnapshot {
52
96
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
53
97
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
54
98
  }
99
+ channel_snapshot_remote_balance: remote_balance {
100
+ __typename
101
+ currency_amount_original_value: original_value
102
+ currency_amount_original_unit: original_unit
103
+ currency_amount_preferred_currency_unit: preferred_currency_unit
104
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
105
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
106
+ }
107
+ channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
108
+ __typename
109
+ currency_amount_original_value: original_value
110
+ currency_amount_original_unit: original_unit
111
+ currency_amount_preferred_currency_unit: preferred_currency_unit
112
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
113
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
114
+ }
55
115
  }`;
56
116
 
57
117
  export default ChannelSnapshot;
@@ -1,9 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
- type ChannelToTransactionsConnection = {
9
+ interface ChannelToTransactionsConnection {
7
10
  /**
8
11
  * The total count of objects in this connection, using the current filters. It is different from the
9
12
  * number of objects returned in the current page (in the `entities` field).
@@ -14,20 +17,20 @@ type ChannelToTransactionsConnection = {
14
17
  * The average fee for the transactions that transited through this channel, according to the filters
15
18
  * and constraints of the connection.
16
19
  **/
17
- averageFee?: CurrencyAmount;
20
+ averageFee?: CurrencyAmount | undefined;
18
21
 
19
22
  /**
20
23
  * The total amount transacted for the transactions that transited through this channel, according to
21
24
  * the filters and constraints of the connection.
22
25
  **/
23
- totalAmountTransacted?: CurrencyAmount;
26
+ totalAmountTransacted?: CurrencyAmount | undefined;
24
27
 
25
28
  /**
26
29
  * The total amount of fees for the transactions that transited through this channel, according to the
27
30
  * filters and constraints of the connection.
28
31
  **/
29
- totalFees?: CurrencyAmount;
30
- };
32
+ totalFees?: CurrencyAmount | undefined;
33
+ }
31
34
 
32
35
  export const ChannelToTransactionsConnectionFromJson = (
33
36
  obj: any,
@@ -53,6 +56,23 @@ export const ChannelToTransactionsConnectionFromJson = (
53
56
  : undefined,
54
57
  } as ChannelToTransactionsConnection;
55
58
  };
59
+ export const ChannelToTransactionsConnectionToJson = (
60
+ obj: ChannelToTransactionsConnection,
61
+ ): any => {
62
+ return {
63
+ channel_to_transactions_connection_count: obj.count,
64
+ channel_to_transactions_connection_average_fee: obj.averageFee
65
+ ? CurrencyAmountToJson(obj.averageFee)
66
+ : undefined,
67
+ channel_to_transactions_connection_total_amount_transacted:
68
+ obj.totalAmountTransacted
69
+ ? CurrencyAmountToJson(obj.totalAmountTransacted)
70
+ : undefined,
71
+ channel_to_transactions_connection_total_fees: obj.totalFees
72
+ ? CurrencyAmountToJson(obj.totalFees)
73
+ : undefined,
74
+ };
75
+ };
56
76
 
57
77
  export const FRAGMENT = `
58
78
  fragment ChannelToTransactionsConnectionFragment on ChannelToTransactionsConnection {
@@ -6,26 +6,38 @@ import type AccountToNodesConnection from "./AccountToNodesConnection.js";
6
6
  import type AccountToPaymentRequestsConnection from "./AccountToPaymentRequestsConnection.js";
7
7
  import type AccountToTransactionsConnection from "./AccountToTransactionsConnection.js";
8
8
  import type AccountToWalletsConnection from "./AccountToWalletsConnection.js";
9
- import { ApiTokenFromJson } from "./ApiToken.js";
9
+ import { ApiTokenFromJson, ApiTokenToJson } from "./ApiToken.js";
10
10
  import { ChannelFromJson } from "./Channel.js";
11
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
12
- import { HopFromJson } from "./Hop.js";
13
- import { IncomingPaymentAttemptFromJson } from "./IncomingPaymentAttempt.js";
11
+ import {
12
+ CurrencyAmountFromJson,
13
+ CurrencyAmountToJson,
14
+ } from "./CurrencyAmount.js";
15
+ import { HopFromJson, HopToJson } from "./Hop.js";
16
+ import {
17
+ IncomingPaymentAttemptFromJson,
18
+ IncomingPaymentAttemptToJson,
19
+ } from "./IncomingPaymentAttempt.js";
14
20
  import type IncomingPaymentToAttemptsConnection from "./IncomingPaymentToAttemptsConnection.js";
15
- import { LightsparkNodeFromJson } from "./LightsparkNode.js";
21
+ import {
22
+ LightsparkNodeFromJson,
23
+ LightsparkNodeToJson,
24
+ } from "./LightsparkNode.js";
16
25
  import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
17
26
  import { OutgoingPaymentAttemptFromJson } from "./OutgoingPaymentAttempt.js";
18
27
  import type OutgoingPaymentAttemptToHopsConnection from "./OutgoingPaymentAttemptToHopsConnection.js";
19
28
  import type OutgoingPaymentToAttemptsConnection from "./OutgoingPaymentToAttemptsConnection.js";
20
29
  import type PageInfo from "./PageInfo.js";
21
- import { PageInfoFromJson } from "./PageInfo.js";
22
- import { PaymentRequestFromJson } from "./PaymentRequest.js";
23
- import { TransactionFromJson } from "./Transaction.js";
30
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
31
+ import {
32
+ PaymentRequestFromJson,
33
+ PaymentRequestToJson,
34
+ } from "./PaymentRequest.js";
35
+ import { TransactionFromJson, TransactionToJson } from "./Transaction.js";
24
36
  import { WalletFromJson } from "./Wallet.js";
25
37
  import type WalletToPaymentRequestsConnection from "./WalletToPaymentRequestsConnection.js";
26
38
  import type WalletToTransactionsConnection from "./WalletToTransactionsConnection.js";
27
39
 
28
- type Connection = {
40
+ interface Connection {
29
41
  /**
30
42
  * The total count of objects in this connection, using the current filters. It is different from the
31
43
  * number of objects returned in the current page (in the `entities` field).
@@ -37,7 +49,7 @@ type Connection = {
37
49
 
38
50
  /** The typename of the object **/
39
51
  typename: string;
40
- };
52
+ }
41
53
 
42
54
  export const ConnectionFromJson = (obj: any): Connection => {
43
55
  if (obj["__typename"] == "AccountToApiTokensConnection") {
@@ -194,6 +206,189 @@ export const ConnectionFromJson = (obj: any): Connection => {
194
206
  `Couldn't find a concrete type for interface Connection corresponding to the typename=${obj["__typename"]}`,
195
207
  );
196
208
  };
209
+ export const ConnectionToJson = (obj: Connection): any => {
210
+ if (obj.typename == "AccountToApiTokensConnection") {
211
+ const accountToApiTokensConnection = obj as AccountToApiTokensConnection;
212
+ return {
213
+ __typename: "AccountToApiTokensConnection",
214
+ account_to_api_tokens_connection_count:
215
+ accountToApiTokensConnection.count,
216
+ account_to_api_tokens_connection_page_info: PageInfoToJson(
217
+ accountToApiTokensConnection.pageInfo,
218
+ ),
219
+ account_to_api_tokens_connection_entities:
220
+ accountToApiTokensConnection.entities.map((e) => ApiTokenToJson(e)),
221
+ };
222
+ }
223
+ if (obj.typename == "AccountToNodesConnection") {
224
+ const accountToNodesConnection = obj as AccountToNodesConnection;
225
+ return {
226
+ __typename: "AccountToNodesConnection",
227
+ account_to_nodes_connection_count: accountToNodesConnection.count,
228
+ account_to_nodes_connection_page_info: PageInfoToJson(
229
+ accountToNodesConnection.pageInfo,
230
+ ),
231
+ account_to_nodes_connection_entities:
232
+ accountToNodesConnection.entities.map((e) => LightsparkNodeToJson(e)),
233
+ };
234
+ }
235
+ if (obj.typename == "AccountToPaymentRequestsConnection") {
236
+ const accountToPaymentRequestsConnection =
237
+ obj as AccountToPaymentRequestsConnection;
238
+ return {
239
+ __typename: "AccountToPaymentRequestsConnection",
240
+ account_to_payment_requests_connection_count:
241
+ accountToPaymentRequestsConnection.count,
242
+ account_to_payment_requests_connection_page_info: PageInfoToJson(
243
+ accountToPaymentRequestsConnection.pageInfo,
244
+ ),
245
+ account_to_payment_requests_connection_entities:
246
+ accountToPaymentRequestsConnection.entities.map((e) =>
247
+ PaymentRequestToJson(e),
248
+ ),
249
+ };
250
+ }
251
+ if (obj.typename == "AccountToTransactionsConnection") {
252
+ const accountToTransactionsConnection =
253
+ obj as AccountToTransactionsConnection;
254
+ return {
255
+ __typename: "AccountToTransactionsConnection",
256
+ account_to_transactions_connection_count:
257
+ accountToTransactionsConnection.count,
258
+ account_to_transactions_connection_page_info: PageInfoToJson(
259
+ accountToTransactionsConnection.pageInfo,
260
+ ),
261
+ account_to_transactions_connection_profit_loss:
262
+ accountToTransactionsConnection.profitLoss
263
+ ? CurrencyAmountToJson(accountToTransactionsConnection.profitLoss)
264
+ : undefined,
265
+ account_to_transactions_connection_average_fee_earned:
266
+ accountToTransactionsConnection.averageFeeEarned
267
+ ? CurrencyAmountToJson(
268
+ accountToTransactionsConnection.averageFeeEarned,
269
+ )
270
+ : undefined,
271
+ account_to_transactions_connection_total_amount_transacted:
272
+ accountToTransactionsConnection.totalAmountTransacted
273
+ ? CurrencyAmountToJson(
274
+ accountToTransactionsConnection.totalAmountTransacted,
275
+ )
276
+ : undefined,
277
+ account_to_transactions_connection_entities:
278
+ accountToTransactionsConnection.entities.map((e) =>
279
+ TransactionToJson(e),
280
+ ),
281
+ };
282
+ }
283
+ if (obj.typename == "AccountToWalletsConnection") {
284
+ const accountToWalletsConnection = obj as AccountToWalletsConnection;
285
+ return {
286
+ __typename: "AccountToWalletsConnection",
287
+ account_to_wallets_connection_count: accountToWalletsConnection.count,
288
+ account_to_wallets_connection_page_info: PageInfoToJson(
289
+ accountToWalletsConnection.pageInfo,
290
+ ),
291
+ account_to_wallets_connection_entities:
292
+ accountToWalletsConnection.entities.map((e) => e.toJson()),
293
+ };
294
+ }
295
+ if (obj.typename == "IncomingPaymentToAttemptsConnection") {
296
+ const incomingPaymentToAttemptsConnection =
297
+ obj as IncomingPaymentToAttemptsConnection;
298
+ return {
299
+ __typename: "IncomingPaymentToAttemptsConnection",
300
+ incoming_payment_to_attempts_connection_count:
301
+ incomingPaymentToAttemptsConnection.count,
302
+ incoming_payment_to_attempts_connection_page_info: PageInfoToJson(
303
+ incomingPaymentToAttemptsConnection.pageInfo,
304
+ ),
305
+ incoming_payment_to_attempts_connection_entities:
306
+ incomingPaymentToAttemptsConnection.entities.map((e) =>
307
+ IncomingPaymentAttemptToJson(e),
308
+ ),
309
+ };
310
+ }
311
+ if (obj.typename == "LightsparkNodeToChannelsConnection") {
312
+ const lightsparkNodeToChannelsConnection =
313
+ obj as LightsparkNodeToChannelsConnection;
314
+ return {
315
+ __typename: "LightsparkNodeToChannelsConnection",
316
+ lightspark_node_to_channels_connection_count:
317
+ lightsparkNodeToChannelsConnection.count,
318
+ lightspark_node_to_channels_connection_page_info: PageInfoToJson(
319
+ lightsparkNodeToChannelsConnection.pageInfo,
320
+ ),
321
+ lightspark_node_to_channels_connection_entities:
322
+ lightsparkNodeToChannelsConnection.entities.map((e) => e.toJson()),
323
+ };
324
+ }
325
+ if (obj.typename == "OutgoingPaymentAttemptToHopsConnection") {
326
+ const outgoingPaymentAttemptToHopsConnection =
327
+ obj as OutgoingPaymentAttemptToHopsConnection;
328
+ return {
329
+ __typename: "OutgoingPaymentAttemptToHopsConnection",
330
+ outgoing_payment_attempt_to_hops_connection_count:
331
+ outgoingPaymentAttemptToHopsConnection.count,
332
+ outgoing_payment_attempt_to_hops_connection_page_info: PageInfoToJson(
333
+ outgoingPaymentAttemptToHopsConnection.pageInfo,
334
+ ),
335
+ outgoing_payment_attempt_to_hops_connection_entities:
336
+ outgoingPaymentAttemptToHopsConnection.entities.map((e) =>
337
+ HopToJson(e),
338
+ ),
339
+ };
340
+ }
341
+ if (obj.typename == "OutgoingPaymentToAttemptsConnection") {
342
+ const outgoingPaymentToAttemptsConnection =
343
+ obj as OutgoingPaymentToAttemptsConnection;
344
+ return {
345
+ __typename: "OutgoingPaymentToAttemptsConnection",
346
+ outgoing_payment_to_attempts_connection_count:
347
+ outgoingPaymentToAttemptsConnection.count,
348
+ outgoing_payment_to_attempts_connection_page_info: PageInfoToJson(
349
+ outgoingPaymentToAttemptsConnection.pageInfo,
350
+ ),
351
+ outgoing_payment_to_attempts_connection_entities:
352
+ outgoingPaymentToAttemptsConnection.entities.map((e) => e.toJson()),
353
+ };
354
+ }
355
+ if (obj.typename == "WalletToPaymentRequestsConnection") {
356
+ const walletToPaymentRequestsConnection =
357
+ obj as WalletToPaymentRequestsConnection;
358
+ return {
359
+ __typename: "WalletToPaymentRequestsConnection",
360
+ wallet_to_payment_requests_connection_count:
361
+ walletToPaymentRequestsConnection.count,
362
+ wallet_to_payment_requests_connection_page_info: PageInfoToJson(
363
+ walletToPaymentRequestsConnection.pageInfo,
364
+ ),
365
+ wallet_to_payment_requests_connection_entities:
366
+ walletToPaymentRequestsConnection.entities.map((e) =>
367
+ PaymentRequestToJson(e),
368
+ ),
369
+ };
370
+ }
371
+ if (obj.typename == "WalletToTransactionsConnection") {
372
+ const walletToTransactionsConnection =
373
+ obj as WalletToTransactionsConnection;
374
+ return {
375
+ __typename: "WalletToTransactionsConnection",
376
+ wallet_to_transactions_connection_count:
377
+ walletToTransactionsConnection.count,
378
+ wallet_to_transactions_connection_page_info: PageInfoToJson(
379
+ walletToTransactionsConnection.pageInfo,
380
+ ),
381
+ wallet_to_transactions_connection_entities:
382
+ walletToTransactionsConnection.entities.map((e) =>
383
+ TransactionToJson(e),
384
+ ),
385
+ };
386
+ }
387
+ throw new LightsparkException(
388
+ "DeserializationError",
389
+ `Couldn't find a concrete type for interface Connection corresponding to the typename=${obj.typename}`,
390
+ );
391
+ };
197
392
 
198
393
  export const FRAGMENT = `
199
394
  fragment ConnectionFragment on Connection {
@@ -2,13 +2,13 @@
2
2
 
3
3
  import Permission from "./Permission.js";
4
4
 
5
- type CreateApiTokenInput = {
5
+ interface CreateApiTokenInput {
6
6
  /** An arbitrary name that the user can choose to identify the API token in a list. **/
7
7
  name: string;
8
8
 
9
9
  /** List of permissions to grant to the API token **/
10
10
  permissions: Permission[];
11
- };
11
+ }
12
12
 
13
13
  export const CreateApiTokenInputFromJson = (obj: any): CreateApiTokenInput => {
14
14
  return {
@@ -18,5 +18,11 @@ export const CreateApiTokenInputFromJson = (obj: any): CreateApiTokenInput => {
18
18
  ),
19
19
  } as CreateApiTokenInput;
20
20
  };
21
+ export const CreateApiTokenInputToJson = (obj: CreateApiTokenInput): any => {
22
+ return {
23
+ create_api_token_input_name: obj.name,
24
+ create_api_token_input_permissions: obj.permissions,
25
+ };
26
+ };
21
27
 
22
28
  export default CreateApiTokenInput;
@@ -1,9 +1,9 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type ApiToken from "./ApiToken.js";
4
- import { ApiTokenFromJson } from "./ApiToken.js";
4
+ import { ApiTokenFromJson, ApiTokenToJson } from "./ApiToken.js";
5
5
 
6
- type CreateApiTokenOutput = {
6
+ interface CreateApiTokenOutput {
7
7
  /** The API Token that has been created. **/
8
8
  apiToken: ApiToken;
9
9
 
@@ -13,7 +13,7 @@ type CreateApiTokenOutput = {
13
13
  * account.
14
14
  **/
15
15
  clientSecret: string;
16
- };
16
+ }
17
17
 
18
18
  export const CreateApiTokenOutputFromJson = (
19
19
  obj: any,
@@ -23,6 +23,12 @@ export const CreateApiTokenOutputFromJson = (
23
23
  clientSecret: obj["create_api_token_output_client_secret"],
24
24
  } as CreateApiTokenOutput;
25
25
  };
26
+ export const CreateApiTokenOutputToJson = (obj: CreateApiTokenOutput): any => {
27
+ return {
28
+ create_api_token_output_api_token: ApiTokenToJson(obj.apiToken),
29
+ create_api_token_output_client_secret: obj.clientSecret,
30
+ };
31
+ };
26
32
 
27
33
  export const FRAGMENT = `
28
34
  fragment CreateApiTokenOutputFragment on CreateApiTokenOutput {
@@ -2,20 +2,20 @@
2
2
 
3
3
  import InvoiceType from "./InvoiceType.js";
4
4
 
5
- type CreateInvoiceInput = {
5
+ interface CreateInvoiceInput {
6
6
  /** The node from which to create the invoice. **/
7
7
  nodeId: string;
8
8
 
9
9
  /** The amount for which the invoice should be created, in millisatoshis. **/
10
10
  amountMsats: number;
11
11
 
12
- memo?: string;
12
+ memo?: string | undefined;
13
13
 
14
- invoiceType?: InvoiceType;
14
+ invoiceType?: InvoiceType | undefined;
15
15
 
16
16
  /** The expiry of the invoice in seconds. Default value is 86400 (1 day). **/
17
- expirySecs?: number;
18
- };
17
+ expirySecs?: number | undefined;
18
+ }
19
19
 
20
20
  export const CreateInvoiceInputFromJson = (obj: any): CreateInvoiceInput => {
21
21
  return {
@@ -29,5 +29,14 @@ export const CreateInvoiceInputFromJson = (obj: any): CreateInvoiceInput => {
29
29
  expirySecs: obj["create_invoice_input_expiry_secs"],
30
30
  } as CreateInvoiceInput;
31
31
  };
32
+ export const CreateInvoiceInputToJson = (obj: CreateInvoiceInput): any => {
33
+ return {
34
+ create_invoice_input_node_id: obj.nodeId,
35
+ create_invoice_input_amount_msats: obj.amountMsats,
36
+ create_invoice_input_memo: obj.memo,
37
+ create_invoice_input_invoice_type: obj.invoiceType,
38
+ create_invoice_input_expiry_secs: obj.expirySecs,
39
+ };
40
+ };
32
41
 
33
42
  export default CreateInvoiceInput;
@@ -1,14 +1,19 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type CreateInvoiceOutput = {
3
+ interface CreateInvoiceOutput {
4
4
  invoiceId: string;
5
- };
5
+ }
6
6
 
7
7
  export const CreateInvoiceOutputFromJson = (obj: any): CreateInvoiceOutput => {
8
8
  return {
9
9
  invoiceId: obj["create_invoice_output_invoice"].id,
10
10
  } as CreateInvoiceOutput;
11
11
  };
12
+ export const CreateInvoiceOutputToJson = (obj: CreateInvoiceOutput): any => {
13
+ return {
14
+ create_invoice_output_invoice: { id: obj.invoiceId },
15
+ };
16
+ };
12
17
 
13
18
  export const FRAGMENT = `
14
19
  fragment CreateInvoiceOutputFragment on CreateInvoiceOutput {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type CreateLnurlInvoiceInput = {
3
+ interface CreateLnurlInvoiceInput {
4
4
  /** The node from which to create the invoice. **/
5
5
  nodeId: string;
6
6
 
@@ -14,8 +14,8 @@ type CreateLnurlInvoiceInput = {
14
14
  metadataHash: string;
15
15
 
16
16
  /** The expiry of the invoice in seconds. Default value is 86400 (1 day). **/
17
- expirySecs?: number;
18
- };
17
+ expirySecs?: number | undefined;
18
+ }
19
19
 
20
20
  export const CreateLnurlInvoiceInputFromJson = (
21
21
  obj: any,
@@ -27,5 +27,15 @@ export const CreateLnurlInvoiceInputFromJson = (
27
27
  expirySecs: obj["create_lnurl_invoice_input_expiry_secs"],
28
28
  } as CreateLnurlInvoiceInput;
29
29
  };
30
+ export const CreateLnurlInvoiceInputToJson = (
31
+ obj: CreateLnurlInvoiceInput,
32
+ ): any => {
33
+ return {
34
+ create_lnurl_invoice_input_node_id: obj.nodeId,
35
+ create_lnurl_invoice_input_amount_msats: obj.amountMsats,
36
+ create_lnurl_invoice_input_metadata_hash: obj.metadataHash,
37
+ create_lnurl_invoice_input_expiry_secs: obj.expirySecs,
38
+ };
39
+ };
30
40
 
31
41
  export default CreateLnurlInvoiceInput;
@@ -1,8 +1,8 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type CreateNodeWalletAddressInput = {
3
+ interface CreateNodeWalletAddressInput {
4
4
  nodeId: string;
5
- };
5
+ }
6
6
 
7
7
  export const CreateNodeWalletAddressInputFromJson = (
8
8
  obj: any,
@@ -11,5 +11,12 @@ export const CreateNodeWalletAddressInputFromJson = (
11
11
  nodeId: obj["create_node_wallet_address_input_node_id"],
12
12
  } as CreateNodeWalletAddressInput;
13
13
  };
14
+ export const CreateNodeWalletAddressInputToJson = (
15
+ obj: CreateNodeWalletAddressInput,
16
+ ): any => {
17
+ return {
18
+ create_node_wallet_address_input_node_id: obj.nodeId,
19
+ };
20
+ };
14
21
 
15
22
  export default CreateNodeWalletAddressInput;
@@ -1,10 +1,10 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type CreateNodeWalletAddressOutput = {
3
+ interface CreateNodeWalletAddressOutput {
4
4
  nodeId: string;
5
5
 
6
6
  walletAddress: string;
7
- };
7
+ }
8
8
 
9
9
  export const CreateNodeWalletAddressOutputFromJson = (
10
10
  obj: any,
@@ -14,6 +14,14 @@ export const CreateNodeWalletAddressOutputFromJson = (
14
14
  walletAddress: obj["create_node_wallet_address_output_wallet_address"],
15
15
  } as CreateNodeWalletAddressOutput;
16
16
  };
17
+ export const CreateNodeWalletAddressOutputToJson = (
18
+ obj: CreateNodeWalletAddressOutput,
19
+ ): any => {
20
+ return {
21
+ create_node_wallet_address_output_node: { id: obj.nodeId },
22
+ create_node_wallet_address_output_wallet_address: obj.walletAddress,
23
+ };
24
+ };
17
25
 
18
26
  export const FRAGMENT = `
19
27
  fragment CreateNodeWalletAddressOutputFragment on CreateNodeWalletAddressOutput {
@@ -2,15 +2,15 @@
2
2
 
3
3
  import InvoiceType from "./InvoiceType.js";
4
4
 
5
- type CreateTestModeInvoiceInput = {
5
+ interface CreateTestModeInvoiceInput {
6
6
  localNodeId: string;
7
7
 
8
8
  amountMsats: number;
9
9
 
10
- memo?: string;
10
+ memo?: string | undefined;
11
11
 
12
- invoiceType?: InvoiceType;
13
- };
12
+ invoiceType?: InvoiceType | undefined;
13
+ }
14
14
 
15
15
  export const CreateTestModeInvoiceInputFromJson = (
16
16
  obj: any,
@@ -25,5 +25,15 @@ export const CreateTestModeInvoiceInputFromJson = (
25
25
  : null,
26
26
  } as CreateTestModeInvoiceInput;
27
27
  };
28
+ export const CreateTestModeInvoiceInputToJson = (
29
+ obj: CreateTestModeInvoiceInput,
30
+ ): any => {
31
+ return {
32
+ create_test_mode_invoice_input_local_node_id: obj.localNodeId,
33
+ create_test_mode_invoice_input_amount_msats: obj.amountMsats,
34
+ create_test_mode_invoice_input_memo: obj.memo,
35
+ create_test_mode_invoice_input_invoice_type: obj.invoiceType,
36
+ };
37
+ };
28
38
 
29
39
  export default CreateTestModeInvoiceInput;