@lightsparkdev/lightspark-sdk 0.4.8 → 0.4.10

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 (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{chunk-YTXDF6SQ.js → chunk-NXUFC5J7.js} +950 -246
  3. package/dist/{index-adeff42d.d.ts → index-3ffe9e7b.d.ts} +194 -56
  4. package/dist/index.cjs +962 -254
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +15 -9
  7. package/dist/objects/index.cjs +952 -246
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -1
  10. package/package.json +1 -2
  11. package/src/client.ts +13 -14
  12. package/src/objects/Account.ts +36 -30
  13. package/src/objects/AccountToApiTokensConnection.ts +11 -6
  14. package/src/objects/AccountToNodesConnection.ts +11 -6
  15. package/src/objects/AccountToPaymentRequestsConnection.ts +20 -15
  16. package/src/objects/AccountToTransactionsConnection.ts +19 -14
  17. package/src/objects/AccountToWalletsConnection.ts +11 -6
  18. package/src/objects/ApiToken.ts +2 -1
  19. package/src/objects/Balances.ts +1 -0
  20. package/src/objects/BitcoinNetwork.ts +2 -1
  21. package/src/objects/BlockchainBalance.ts +1 -1
  22. package/src/objects/Channel.ts +2 -2
  23. package/src/objects/ChannelClosingTransaction.ts +2 -2
  24. package/src/objects/ChannelFees.ts +1 -0
  25. package/src/objects/ChannelOpeningTransaction.ts +2 -2
  26. package/src/objects/ChannelStatus.ts +1 -0
  27. package/src/objects/Connection.ts +387 -0
  28. package/src/objects/CreateInvoiceInput.ts +12 -0
  29. package/src/objects/CreateLnurlInvoiceInput.ts +10 -0
  30. package/src/objects/CreateTestModePaymentoutput.ts +1 -0
  31. package/src/objects/CryptoSanctionsScreeningProvider.ts +14 -0
  32. package/src/objects/CurrencyAmount.ts +1 -1
  33. package/src/objects/CurrencyUnit.ts +1 -0
  34. package/src/objects/Deposit.ts +2 -2
  35. package/src/objects/Entity.ts +1 -1
  36. package/src/objects/FeeEstimate.ts +1 -0
  37. package/src/objects/GraphNode.ts +2 -2
  38. package/src/objects/Hop.ts +2 -2
  39. package/src/objects/HtlcAttemptFailureCode.ts +1 -0
  40. package/src/objects/IncomingPayment.ts +19 -6
  41. package/src/objects/IncomingPaymentAttempt.ts +2 -2
  42. package/src/objects/IncomingPaymentAttemptStatus.ts +1 -1
  43. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -1
  44. package/src/objects/Invoice.ts +2 -2
  45. package/src/objects/InvoiceData.ts +1 -1
  46. package/src/objects/InvoiceType.ts +1 -0
  47. package/src/objects/LightningTransaction.ts +2 -2
  48. package/src/objects/LightsparkNode.ts +12 -6
  49. package/src/objects/LightsparkNodeOwner.ts +2 -2
  50. package/src/objects/LightsparkNodePurpose.ts +1 -0
  51. package/src/objects/LightsparkNodeToChannelsConnection.ts +11 -6
  52. package/src/objects/Node.ts +2 -3
  53. package/src/objects/NodeAddress.ts +1 -1
  54. package/src/objects/NodeAddressType.ts +1 -1
  55. package/src/objects/OnChainTransaction.ts +2 -3
  56. package/src/objects/OutgoingPayment.ts +14 -6
  57. package/src/objects/OutgoingPaymentAttempt.ts +14 -6
  58. package/src/objects/OutgoingPaymentAttemptStatus.ts +1 -1
  59. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +21 -1
  60. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +21 -1
  61. package/src/objects/PageInfo.ts +1 -0
  62. package/src/objects/PaymentFailureReason.ts +1 -0
  63. package/src/objects/PaymentRequest.ts +2 -2
  64. package/src/objects/PaymentRequestData.ts +1 -1
  65. package/src/objects/PaymentRequestStatus.ts +1 -0
  66. package/src/objects/Permission.ts +1 -0
  67. package/src/objects/RiskRating.ts +18 -0
  68. package/src/objects/RoutingTransaction.ts +2 -2
  69. package/src/objects/RoutingTransactionFailureReason.ts +1 -0
  70. package/src/objects/ScreenBitcoinAddressesInput.ts +23 -0
  71. package/src/objects/ScreenBitcoinAddressesOutput.ts +25 -0
  72. package/src/objects/Transaction.ts +2 -2
  73. package/src/objects/TransactionFailures.ts +1 -0
  74. package/src/objects/TransactionStatus.ts +1 -0
  75. package/src/objects/TransactionType.ts +1 -0
  76. package/src/objects/Wallet.ts +632 -7
  77. package/src/objects/WalletStatus.ts +1 -0
  78. package/src/objects/WalletToPaymentRequestsConnection.ts +57 -0
  79. package/src/objects/WalletToTransactionsConnection.ts +57 -0
  80. package/src/objects/WebhookEventType.ts +3 -0
  81. package/src/objects/Withdrawal.ts +2 -2
  82. package/src/objects/WithdrawalMode.ts +1 -0
  83. package/src/objects/WithdrawalRequest.ts +2 -1
  84. package/src/objects/WithdrawalRequestStatus.ts +1 -0
  85. package/src/objects/index.ts +7 -0
  86. package/src/objects/.eslintrc.cjs +0 -5
@@ -1,11 +1,11 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
7
7
 
8
- /** One hop signifies a payment moving one node ahead on a payment route; a list of sequential hops defines the path from sender node to recipient node for a payment attempt. **/
8
+ /** This object represents a specific node that existed on a particular payment route. You can retrieve this object to get information about a node on a particular payment path and all payment-relevant information for that node. **/
9
9
  type Hop = Entity & {
10
10
  /**
11
11
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an enum representing a particular reason why an htlc sent over the Lightning Network may have failed. **/
3
4
  export enum HtlcAttemptFailureCode {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -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 { 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";
@@ -11,7 +11,7 @@ import { IncomingPaymentToAttemptsConnectionFromJson } from "./IncomingPaymentTo
11
11
  import type LightningTransaction from "./LightningTransaction.js";
12
12
  import TransactionStatus from "./TransactionStatus.js";
13
13
 
14
- /** A transaction that was sent to a Lightspark node on the Lightning Network. **/
14
+ /** This object represents any payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific payment received by a Lightspark node. **/
15
15
  class IncomingPayment implements LightningTransaction {
16
16
  constructor(
17
17
  public readonly id: string,
@@ -32,16 +32,24 @@ class IncomingPayment implements LightningTransaction {
32
32
  public async getAttempts(
33
33
  client: LightsparkClient,
34
34
  first: number | undefined = undefined,
35
- statuses: IncomingPaymentAttemptStatus[] | undefined = undefined
35
+ statuses: IncomingPaymentAttemptStatus[] | undefined = undefined,
36
+ after: string | undefined = undefined
36
37
  ): Promise<IncomingPaymentToAttemptsConnection> {
37
38
  return (await client.executeRawQuery({
38
39
  queryPayload: `
39
- query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!]) {
40
+ query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!], $after: String) {
40
41
  entity(id: $entity_id) {
41
42
  ... on IncomingPayment {
42
- attempts(, first: $first, statuses: $statuses) {
43
+ attempts(, first: $first, statuses: $statuses, after: $after) {
43
44
  __typename
44
45
  incoming_payment_to_attempts_connection_count: count
46
+ incoming_payment_to_attempts_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
45
53
  incoming_payment_to_attempts_connection_entities: entities {
46
54
  __typename
47
55
  incoming_payment_attempt_id: id
@@ -66,7 +74,12 @@ query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $st
66
74
  }
67
75
  }
68
76
  `,
69
- variables: { entity_id: this.id, first: first, statuses: statuses },
77
+ variables: {
78
+ entity_id: this.id,
79
+ first: first,
80
+ statuses: statuses,
81
+ after: after,
82
+ },
70
83
  constructObject: (json) => {
71
84
  const connection = json["entity"]["attempts"];
72
85
  return IncomingPaymentToAttemptsConnectionFromJson(connection);
@@ -1,12 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
7
7
  import IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
8
8
 
9
- /** An attempt for a payment over a route from sender node to recipient node. **/
9
+ /** This object represents any attempted payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific incoming payment attempt. **/
10
10
  type IncomingPaymentAttempt = Entity & {
11
11
  /**
12
12
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- /** Enum that enumerates all the possible status of an incoming payment attempt. **/
3
+ /** This is an enum that enumerates all potential statuses for an incoming payment attempt. **/
4
4
  export enum IncomingPaymentAttemptStatus {
5
5
  /**
6
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,18 +1,27 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ import type Connection from "./Connection.js";
3
4
  import type IncomingPaymentAttempt from "./IncomingPaymentAttempt.js";
4
5
  import { IncomingPaymentAttemptFromJson } from "./IncomingPaymentAttempt.js";
6
+ import type PageInfo from "./PageInfo.js";
7
+ import { PageInfoFromJson } from "./PageInfo.js";
5
8
 
6
9
  /** The connection from incoming payment to all attempts. **/
7
- type IncomingPaymentToAttemptsConnection = {
10
+ type IncomingPaymentToAttemptsConnection = Connection & {
8
11
  /**
9
12
  * The total count of objects in this connection, using the current filters. It is different from the
10
13
  * number of objects returned in the current page (in the `entities` field).
11
14
  **/
12
15
  count: number;
13
16
 
17
+ /** An object that holds pagination information about the objects in this connection. **/
18
+ pageInfo: PageInfo;
19
+
14
20
  /** The incoming payment attempts for the current page of this connection. **/
15
21
  entities: IncomingPaymentAttempt[];
22
+
23
+ /** The typename of the object **/
24
+ typename: string;
16
25
  };
17
26
 
18
27
  export const IncomingPaymentToAttemptsConnectionFromJson = (
@@ -20,9 +29,13 @@ export const IncomingPaymentToAttemptsConnectionFromJson = (
20
29
  ): IncomingPaymentToAttemptsConnection => {
21
30
  return {
22
31
  count: obj["incoming_payment_to_attempts_connection_count"],
32
+ pageInfo: PageInfoFromJson(
33
+ obj["incoming_payment_to_attempts_connection_page_info"]
34
+ ),
23
35
  entities: obj["incoming_payment_to_attempts_connection_entities"].map((e) =>
24
36
  IncomingPaymentAttemptFromJson(e)
25
37
  ),
38
+ typename: "IncomingPaymentToAttemptsConnection",
26
39
  } as IncomingPaymentToAttemptsConnection;
27
40
  };
28
41
 
@@ -30,6 +43,13 @@ export const FRAGMENT = `
30
43
  fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection {
31
44
  __typename
32
45
  incoming_payment_to_attempts_connection_count: count
46
+ incoming_payment_to_attempts_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
33
53
  incoming_payment_to_attempts_connection_entities: entities {
34
54
  id
35
55
  }
@@ -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 { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
@@ -9,7 +9,7 @@ import { InvoiceDataFromJson } from "./InvoiceData.js";
9
9
  import type PaymentRequest from "./PaymentRequest.js";
10
10
  import PaymentRequestStatus from "./PaymentRequestStatus.js";
11
11
 
12
- /** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) initiated by a Lightspark Node. **/
12
+ /** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node. **/
13
13
  type Invoice = PaymentRequest &
14
14
  Entity & {
15
15
  /**
@@ -7,7 +7,7 @@ import type Node from "./Node.js";
7
7
  import { NodeFromJson } from "./Node.js";
8
8
  import type PaymentRequestData from "./PaymentRequestData.js";
9
9
 
10
- /** This object represents the BOLT #11 invoice protocol for Lightning Payments. See https://github.com/lightning/bolts/blob/master/11-payment-encoding.md. **/
10
+ /** This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice. **/
11
11
  type InvoiceData = PaymentRequestData & {
12
12
  encodedPaymentRequest: string;
13
13
 
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an enum for potential invoice types. **/
3
4
  export enum InvoiceType {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,7 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
4
- import { LightsparkException } from "@lightsparkdev/core";
3
+ import { LightsparkException, type Query } from "@lightsparkdev/core";
5
4
  import type CurrencyAmount from "./CurrencyAmount.js";
6
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
6
  import type Entity from "./Entity.js";
@@ -15,6 +14,7 @@ import RoutingTransactionFailureReason from "./RoutingTransactionFailureReason.j
15
14
  import type Transaction from "./Transaction.js";
16
15
  import TransactionStatus from "./TransactionStatus.js";
17
16
 
17
+ /** This is an object representing a transaction made over the Lightning Network. You can retrieve this object to receive information about a specific transaction made over Lightning for a Lightspark node. **/
18
18
  type LightningTransaction = Transaction &
19
19
  Entity & {
20
20
  /**
@@ -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 { 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";
@@ -81,15 +81,17 @@ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [Node
81
81
  public async getChannels(
82
82
  client: LightsparkClient,
83
83
  first: number | undefined = undefined,
84
- statuses: ChannelStatus[] | undefined = undefined
84
+ statuses: ChannelStatus[] | undefined = undefined,
85
+ after: string | undefined = undefined
85
86
  ): Promise<LightsparkNodeToChannelsConnection> {
86
87
  return (await client.executeRawQuery({
87
88
  queryPayload: `
88
- query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!]) {
89
+ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) {
89
90
  entity(id: $entity_id) {
90
91
  ... on LightsparkNode {
91
- channels(, first: $first, statuses: $statuses) {
92
+ channels(, first: $first, statuses: $statuses, after: $after) {
92
93
  __typename
94
+ lightspark_node_to_channels_connection_count: count
93
95
  lightspark_node_to_channels_connection_page_info: page_info {
94
96
  __typename
95
97
  page_info_has_next_page: has_next_page
@@ -97,7 +99,6 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
97
99
  page_info_start_cursor: start_cursor
98
100
  page_info_end_cursor: end_cursor
99
101
  }
100
- lightspark_node_to_channels_connection_count: count
101
102
  lightspark_node_to_channels_connection_entities: entities {
102
103
  __typename
103
104
  channel_id: id
@@ -197,7 +198,12 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
197
198
  }
198
199
  }
199
200
  `,
200
- variables: { entity_id: this.id, first: first, statuses: statuses },
201
+ variables: {
202
+ entity_id: this.id,
203
+ first: first,
204
+ statuses: statuses,
205
+ after: after,
206
+ },
201
207
  constructObject: (json) => {
202
208
  const connection = json["entity"]["channels"];
203
209
  return LightsparkNodeToChannelsConnectionFromJson(connection);
@@ -1,13 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
4
- import { LightsparkException } from "@lightsparkdev/core";
3
+ import { LightsparkException, type Query } from "@lightsparkdev/core";
5
4
  import Account from "./Account.js";
6
5
  import { BalancesFromJson } from "./Balances.js";
7
6
  import type Entity from "./Entity.js";
8
7
  import Wallet from "./Wallet.js";
9
8
  import WalletStatus from "./WalletStatus.js";
10
9
 
10
+ /** This is an object representing the owner of a LightsparkNode. **/
11
11
  type LightsparkNodeOwner = Entity & {
12
12
  /**
13
13
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an enum of potential purposes set by a user for a Lightspark node. **/
3
4
  export enum LightsparkNodePurpose {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -2,40 +2,46 @@
2
2
 
3
3
  import type Channel from "./Channel.js";
4
4
  import { ChannelFromJson } from "./Channel.js";
5
+ import type Connection from "./Connection.js";
5
6
  import type PageInfo from "./PageInfo.js";
6
7
  import { PageInfoFromJson } from "./PageInfo.js";
7
8
 
8
- type LightsparkNodeToChannelsConnection = {
9
- /** An object that holds pagination information about the objects in this connection. **/
10
- pageInfo: PageInfo;
11
-
9
+ type LightsparkNodeToChannelsConnection = Connection & {
12
10
  /**
13
11
  * The total count of objects in this connection, using the current filters. It is different from the
14
12
  * number of objects returned in the current page (in the `entities` field).
15
13
  **/
16
14
  count: number;
17
15
 
16
+ /** An object that holds pagination information about the objects in this connection. **/
17
+ pageInfo: PageInfo;
18
+
18
19
  /** The channels for the current page of this connection. **/
19
20
  entities: Channel[];
21
+
22
+ /** The typename of the object **/
23
+ typename: string;
20
24
  };
21
25
 
22
26
  export const LightsparkNodeToChannelsConnectionFromJson = (
23
27
  obj: any
24
28
  ): LightsparkNodeToChannelsConnection => {
25
29
  return {
30
+ count: obj["lightspark_node_to_channels_connection_count"],
26
31
  pageInfo: PageInfoFromJson(
27
32
  obj["lightspark_node_to_channels_connection_page_info"]
28
33
  ),
29
- count: obj["lightspark_node_to_channels_connection_count"],
30
34
  entities: obj["lightspark_node_to_channels_connection_entities"].map((e) =>
31
35
  ChannelFromJson(e)
32
36
  ),
37
+ typename: "LightsparkNodeToChannelsConnection",
33
38
  } as LightsparkNodeToChannelsConnection;
34
39
  };
35
40
 
36
41
  export const FRAGMENT = `
37
42
  fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsConnection {
38
43
  __typename
44
+ lightspark_node_to_channels_connection_count: count
39
45
  lightspark_node_to_channels_connection_page_info: page_info {
40
46
  __typename
41
47
  page_info_has_next_page: has_next_page
@@ -43,7 +49,6 @@ fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsC
43
49
  page_info_start_cursor: start_cursor
44
50
  page_info_end_cursor: end_cursor
45
51
  }
46
- lightspark_node_to_channels_connection_count: count
47
52
  lightspark_node_to_channels_connection_entities: entities {
48
53
  id
49
54
  }
@@ -1,7 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
4
- import { LightsparkException } from "@lightsparkdev/core";
3
+ import { LightsparkException, type Query } from "@lightsparkdev/core";
5
4
  import autoBind from "auto-bind";
6
5
  import type LightsparkClient from "../client.js";
7
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
@@ -17,7 +16,7 @@ import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
17
16
  import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
18
17
  import { SecretFromJson } from "./Secret.js";
19
18
 
20
- /** This interface represents a lightning node that can be connected to the Lightning Network to send and receive transactions. **/
19
+ /** This object is an interface representing a Lightning Node on the Lightning Network, and could either be a Lightspark node or a node managed by a third party. **/
21
20
  class Node implements Entity {
22
21
  constructor(
23
22
  public readonly id: string,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import NodeAddressType from "./NodeAddressType.js";
4
4
 
5
- /** An object that represents the address of a node on the Lightning Network. **/
5
+ /** This object represents the address of a node on the Lightning Network. **/
6
6
  type NodeAddress = {
7
7
  /** The string representation of the address. **/
8
8
  address: string;
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- /** An enum that enumerates all possible types of addresses of a node on the Lightning Network. **/
3
+ /** This is an enum of the potential types of addresses that a node on the Lightning Network can have. **/
4
4
  export enum NodeAddressType {
5
5
  /**
6
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,7 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
4
- import { LightsparkException } from "@lightsparkdev/core";
3
+ import { LightsparkException, type Query } from "@lightsparkdev/core";
5
4
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
6
5
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
7
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -12,7 +11,7 @@ import type Transaction from "./Transaction.js";
12
11
  import TransactionStatus from "./TransactionStatus.js";
13
12
  import type Withdrawal from "./Withdrawal.js";
14
13
 
15
- /** Transaction happened on Bitcoin blockchain. **/
14
+ /** This object represents an L1 transaction that occurred on the Bitcoin Network. You can retrieve this object to receive information about a specific on-chain transaction made on the Lightning Network associated with your Lightspark Node. **/
16
15
  type OnChainTransaction = Transaction &
17
16
  Entity & {
18
17
  /**
@@ -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 { 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";
@@ -15,7 +15,7 @@ import type RichText from "./RichText.js";
15
15
  import { RichTextFromJson } from "./RichText.js";
16
16
  import TransactionStatus from "./TransactionStatus.js";
17
17
 
18
- /** A transaction that was sent from a Lightspark node on the Lightning Network. **/
18
+ /** This object represents a Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment sent from your Lightspark Node on the Lightning Network. **/
19
19
  class OutgoingPayment implements LightningTransaction {
20
20
  constructor(
21
21
  public readonly id: string,
@@ -38,16 +38,24 @@ class OutgoingPayment implements LightningTransaction {
38
38
 
39
39
  public async getAttempts(
40
40
  client: LightsparkClient,
41
- first: number | undefined = undefined
41
+ first: number | undefined = undefined,
42
+ after: string | undefined = undefined
42
43
  ): Promise<OutgoingPaymentToAttemptsConnection> {
43
44
  return (await client.executeRawQuery({
44
45
  queryPayload: `
45
- query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int) {
46
+ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $after: String) {
46
47
  entity(id: $entity_id) {
47
48
  ... on OutgoingPayment {
48
- attempts(, first: $first) {
49
+ attempts(, first: $first, after: $after) {
49
50
  __typename
50
51
  outgoing_payment_to_attempts_connection_count: count
52
+ outgoing_payment_to_attempts_connection_page_info: page_info {
53
+ __typename
54
+ page_info_has_next_page: has_next_page
55
+ page_info_has_previous_page: has_previous_page
56
+ page_info_start_cursor: start_cursor
57
+ page_info_end_cursor: end_cursor
58
+ }
51
59
  outgoing_payment_to_attempts_connection_entities: entities {
52
60
  __typename
53
61
  outgoing_payment_attempt_id: id
@@ -82,7 +90,7 @@ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int) {
82
90
  }
83
91
  }
84
92
  `,
85
- variables: { entity_id: this.id, first: first },
93
+ variables: { entity_id: this.id, first: first, after: after },
86
94
  constructObject: (json) => {
87
95
  const connection = json["entity"]["attempts"];
88
96
  return OutgoingPaymentToAttemptsConnectionFromJson(connection);
@@ -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 { 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";
@@ -11,7 +11,7 @@ import OutgoingPaymentAttemptStatus from "./OutgoingPaymentAttemptStatus.js";
11
11
  import type OutgoingPaymentAttemptToHopsConnection from "./OutgoingPaymentAttemptToHopsConnection.js";
12
12
  import { OutgoingPaymentAttemptToHopsConnectionFromJson } from "./OutgoingPaymentAttemptToHopsConnection.js";
13
13
 
14
- /** An attempt for a payment over a route from sender node to recipient node. **/
14
+ /** This object represents an attempted Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment attempt sent from your Lightspark Node on the Lightning Network, including any potential reasons the payment may have failed. **/
15
15
  class OutgoingPaymentAttempt implements Entity {
16
16
  constructor(
17
17
  public readonly id: string,
@@ -31,16 +31,24 @@ class OutgoingPaymentAttempt implements Entity {
31
31
 
32
32
  public async getHops(
33
33
  client: LightsparkClient,
34
- first: number | undefined = undefined
34
+ first: number | undefined = undefined,
35
+ after: string | undefined = undefined
35
36
  ): Promise<OutgoingPaymentAttemptToHopsConnection> {
36
37
  return (await client.executeRawQuery({
37
38
  queryPayload: `
38
- query FetchOutgoingPaymentAttemptToHopsConnection($entity_id: ID!, $first: Int) {
39
+ query FetchOutgoingPaymentAttemptToHopsConnection($entity_id: ID!, $first: Int, $after: String) {
39
40
  entity(id: $entity_id) {
40
41
  ... on OutgoingPaymentAttempt {
41
- hops(, first: $first) {
42
+ hops(, first: $first, after: $after) {
42
43
  __typename
43
44
  outgoing_payment_attempt_to_hops_connection_count: count
45
+ outgoing_payment_attempt_to_hops_connection_page_info: page_info {
46
+ __typename
47
+ page_info_has_next_page: has_next_page
48
+ page_info_has_previous_page: has_previous_page
49
+ page_info_start_cursor: start_cursor
50
+ page_info_end_cursor: end_cursor
51
+ }
44
52
  outgoing_payment_attempt_to_hops_connection_entities: entities {
45
53
  __typename
46
54
  hop_id: id
@@ -74,7 +82,7 @@ query FetchOutgoingPaymentAttemptToHopsConnection($entity_id: ID!, $first: Int)
74
82
  }
75
83
  }
76
84
  `,
77
- variables: { entity_id: this.id, first: first },
85
+ variables: { entity_id: this.id, first: first, after: after },
78
86
  constructObject: (json) => {
79
87
  const connection = json["entity"]["hops"];
80
88
  return OutgoingPaymentAttemptToHopsConnectionFromJson(connection);
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- /** Enum that enumerates all the possible status of an outgoing payment attempt. **/
3
+ /** This is an enum of all potential statuses of a payment attempt made from a Lightspark Node. **/
4
4
  export enum OutgoingPaymentAttemptStatus {
5
5
  /**
6
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,18 +1,27 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ import type Connection from "./Connection.js";
3
4
  import type Hop from "./Hop.js";
4
5
  import { HopFromJson } from "./Hop.js";
6
+ import type PageInfo from "./PageInfo.js";
7
+ import { PageInfoFromJson } from "./PageInfo.js";
5
8
 
6
9
  /** The connection from an outgoing payment attempt to the list of sequential hops that define the path from sender node to recipient node. **/
7
- type OutgoingPaymentAttemptToHopsConnection = {
10
+ type OutgoingPaymentAttemptToHopsConnection = Connection & {
8
11
  /**
9
12
  * The total count of objects in this connection, using the current filters. It is different from the
10
13
  * number of objects returned in the current page (in the `entities` field).
11
14
  **/
12
15
  count: number;
13
16
 
17
+ /** An object that holds pagination information about the objects in this connection. **/
18
+ pageInfo: PageInfo;
19
+
14
20
  /** The hops for the current page of this connection. **/
15
21
  entities: Hop[];
22
+
23
+ /** The typename of the object **/
24
+ typename: string;
16
25
  };
17
26
 
18
27
  export const OutgoingPaymentAttemptToHopsConnectionFromJson = (
@@ -20,9 +29,13 @@ export const OutgoingPaymentAttemptToHopsConnectionFromJson = (
20
29
  ): OutgoingPaymentAttemptToHopsConnection => {
21
30
  return {
22
31
  count: obj["outgoing_payment_attempt_to_hops_connection_count"],
32
+ pageInfo: PageInfoFromJson(
33
+ obj["outgoing_payment_attempt_to_hops_connection_page_info"]
34
+ ),
23
35
  entities: obj["outgoing_payment_attempt_to_hops_connection_entities"].map(
24
36
  (e) => HopFromJson(e)
25
37
  ),
38
+ typename: "OutgoingPaymentAttemptToHopsConnection",
26
39
  } as OutgoingPaymentAttemptToHopsConnection;
27
40
  };
28
41
 
@@ -30,6 +43,13 @@ export const FRAGMENT = `
30
43
  fragment OutgoingPaymentAttemptToHopsConnectionFragment on OutgoingPaymentAttemptToHopsConnection {
31
44
  __typename
32
45
  outgoing_payment_attempt_to_hops_connection_count: count
46
+ outgoing_payment_attempt_to_hops_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
33
53
  outgoing_payment_attempt_to_hops_connection_entities: entities {
34
54
  id
35
55
  }
@@ -1,18 +1,27 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ import type Connection from "./Connection.js";
3
4
  import type OutgoingPaymentAttempt from "./OutgoingPaymentAttempt.js";
4
5
  import { OutgoingPaymentAttemptFromJson } from "./OutgoingPaymentAttempt.js";
6
+ import type PageInfo from "./PageInfo.js";
7
+ import { PageInfoFromJson } from "./PageInfo.js";
5
8
 
6
9
  /** The connection from outgoing payment to all attempts. **/
7
- type OutgoingPaymentToAttemptsConnection = {
10
+ type OutgoingPaymentToAttemptsConnection = Connection & {
8
11
  /**
9
12
  * The total count of objects in this connection, using the current filters. It is different from the
10
13
  * number of objects returned in the current page (in the `entities` field).
11
14
  **/
12
15
  count: number;
13
16
 
17
+ /** An object that holds pagination information about the objects in this connection. **/
18
+ pageInfo: PageInfo;
19
+
14
20
  /** The attempts for the current page of this connection. **/
15
21
  entities: OutgoingPaymentAttempt[];
22
+
23
+ /** The typename of the object **/
24
+ typename: string;
16
25
  };
17
26
 
18
27
  export const OutgoingPaymentToAttemptsConnectionFromJson = (
@@ -20,9 +29,13 @@ export const OutgoingPaymentToAttemptsConnectionFromJson = (
20
29
  ): OutgoingPaymentToAttemptsConnection => {
21
30
  return {
22
31
  count: obj["outgoing_payment_to_attempts_connection_count"],
32
+ pageInfo: PageInfoFromJson(
33
+ obj["outgoing_payment_to_attempts_connection_page_info"]
34
+ ),
23
35
  entities: obj["outgoing_payment_to_attempts_connection_entities"].map((e) =>
24
36
  OutgoingPaymentAttemptFromJson(e)
25
37
  ),
38
+ typename: "OutgoingPaymentToAttemptsConnection",
26
39
  } as OutgoingPaymentToAttemptsConnection;
27
40
  };
28
41
 
@@ -30,6 +43,13 @@ export const FRAGMENT = `
30
43
  fragment OutgoingPaymentToAttemptsConnectionFragment on OutgoingPaymentToAttemptsConnection {
31
44
  __typename
32
45
  outgoing_payment_to_attempts_connection_count: count
46
+ outgoing_payment_to_attempts_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
33
53
  outgoing_payment_to_attempts_connection_entities: entities {
34
54
  id
35
55
  }