@lightsparkdev/lightspark-sdk 1.5.2 → 1.5.4

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.
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { LightsparkException } from "@lightsparkdev/core";
4
4
  import type AccountToApiTokensConnection from "./AccountToApiTokensConnection.js";
5
+ import type AccountToChannelsConnection from "./AccountToChannelsConnection.js";
5
6
  import type AccountToNodesConnection from "./AccountToNodesConnection.js";
6
7
  import type AccountToPaymentRequestsConnection from "./AccountToPaymentRequestsConnection.js";
7
8
  import type AccountToTransactionsConnection from "./AccountToTransactionsConnection.js";
@@ -67,6 +68,18 @@ export const ConnectionFromJson = (obj: any): Connection => {
67
68
  typename: "AccountToApiTokensConnection",
68
69
  } as AccountToApiTokensConnection;
69
70
  }
71
+ if (obj["__typename"] == "AccountToChannelsConnection") {
72
+ return {
73
+ count: obj["account_to_channels_connection_count"],
74
+ pageInfo: PageInfoFromJson(
75
+ obj["account_to_channels_connection_page_info"],
76
+ ),
77
+ entities: obj["account_to_channels_connection_entities"].map((e) =>
78
+ ChannelFromJson(e),
79
+ ),
80
+ typename: "AccountToChannelsConnection",
81
+ } as AccountToChannelsConnection;
82
+ }
70
83
  if (obj["__typename"] == "AccountToNodesConnection") {
71
84
  return {
72
85
  count: obj["account_to_nodes_connection_count"],
@@ -247,6 +260,18 @@ export const ConnectionToJson = (obj: Connection): any => {
247
260
  accountToApiTokensConnection.entities.map((e) => ApiTokenToJson(e)),
248
261
  };
249
262
  }
263
+ if (obj.typename == "AccountToChannelsConnection") {
264
+ const accountToChannelsConnection = obj as AccountToChannelsConnection;
265
+ return {
266
+ __typename: "AccountToChannelsConnection",
267
+ account_to_channels_connection_count: accountToChannelsConnection.count,
268
+ account_to_channels_connection_page_info: PageInfoToJson(
269
+ accountToChannelsConnection.pageInfo,
270
+ ),
271
+ account_to_channels_connection_entities:
272
+ accountToChannelsConnection.entities.map((e) => e.toJson()),
273
+ };
274
+ }
250
275
  if (obj.typename == "AccountToNodesConnection") {
251
276
  const accountToNodesConnection = obj as AccountToNodesConnection;
252
277
  return {
@@ -462,6 +487,20 @@ fragment ConnectionFragment on Connection {
462
487
  id
463
488
  }
464
489
  }
490
+ ... on AccountToChannelsConnection {
491
+ __typename
492
+ account_to_channels_connection_count: count
493
+ account_to_channels_connection_page_info: page_info {
494
+ __typename
495
+ page_info_has_next_page: has_next_page
496
+ page_info_has_previous_page: has_previous_page
497
+ page_info_start_cursor: start_cursor
498
+ page_info_end_cursor: end_cursor
499
+ }
500
+ account_to_channels_connection_entities: entities {
501
+ id
502
+ }
503
+ }
465
504
  ... on AccountToNodesConnection {
466
505
  __typename
467
506
  account_to_nodes_connection_count: count
@@ -0,0 +1,60 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import type CurrencyAmount from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
8
+ import LightningPaymentDirection from "./LightningPaymentDirection.js";
9
+
10
+ interface DailyLiquidityForecast {
11
+ /** The date for which this forecast was generated. **/
12
+ date: string;
13
+
14
+ /** The direction for which this forecast was generated. **/
15
+ direction: LightningPaymentDirection;
16
+
17
+ /**
18
+ * The value of the forecast. It represents the amount of msats that we think will be moved for
19
+ * that specified direction, for that node, on that date.
20
+ **/
21
+ amount: CurrencyAmount;
22
+ }
23
+
24
+ export const DailyLiquidityForecastFromJson = (
25
+ obj: any,
26
+ ): DailyLiquidityForecast => {
27
+ return {
28
+ date: obj["daily_liquidity_forecast_date"],
29
+ direction:
30
+ LightningPaymentDirection[obj["daily_liquidity_forecast_direction"]] ??
31
+ LightningPaymentDirection.FUTURE_VALUE,
32
+ amount: CurrencyAmountFromJson(obj["daily_liquidity_forecast_amount"]),
33
+ } as DailyLiquidityForecast;
34
+ };
35
+ export const DailyLiquidityForecastToJson = (
36
+ obj: DailyLiquidityForecast,
37
+ ): any => {
38
+ return {
39
+ daily_liquidity_forecast_date: obj.date,
40
+ daily_liquidity_forecast_direction: obj.direction,
41
+ daily_liquidity_forecast_amount: CurrencyAmountToJson(obj.amount),
42
+ };
43
+ };
44
+
45
+ export const FRAGMENT = `
46
+ fragment DailyLiquidityForecastFragment on DailyLiquidityForecast {
47
+ __typename
48
+ daily_liquidity_forecast_date: date
49
+ daily_liquidity_forecast_direction: direction
50
+ daily_liquidity_forecast_amount: amount {
51
+ __typename
52
+ currency_amount_original_value: original_value
53
+ currency_amount_original_unit: original_unit
54
+ currency_amount_preferred_currency_unit: preferred_currency_unit
55
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
56
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
57
+ }
58
+ }`;
59
+
60
+ export default DailyLiquidityForecast;
@@ -0,0 +1,16 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ /** This is an enum identifying the payment direction. **/
4
+ export enum LightningPaymentDirection {
5
+ /**
6
+ * This is an enum value that represents values that could be added in the future.
7
+ * Clients should support unknown values as more of them could be added without notice.
8
+ */
9
+ FUTURE_VALUE = "FUTURE_VALUE",
10
+ /** A payment that is received by the node. **/
11
+ INCOMING = "INCOMING",
12
+ /** A payment that is sent by the node. **/
13
+ OUTGOING = "OUTGOING",
14
+ }
15
+
16
+ export default LightningPaymentDirection;
@@ -16,8 +16,10 @@ import {
16
16
  CurrencyAmountFromJson,
17
17
  CurrencyAmountToJson,
18
18
  } from "./CurrencyAmount.js";
19
+ import type LightningPaymentDirection from "./LightningPaymentDirection.js";
19
20
  import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
20
21
  import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
22
+ import type LightsparkNodeToDailyLiquidityForecastsConnection from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
21
23
  import LightsparkNodeWithOSK from "./LightsparkNodeWithOSK.js";
22
24
  import LightsparkNodeWithRemoteSigning from "./LightsparkNodeWithRemoteSigning.js";
23
25
  import type NodeAddressType from "./NodeAddressType.js";
@@ -143,6 +145,13 @@ interface LightsparkNode {
143
145
  statuses?: ChannelStatus[] | undefined,
144
146
  after?: string | undefined,
145
147
  ): Promise<LightsparkNodeToChannelsConnection>;
148
+
149
+ getDailyLiquidityForecasts(
150
+ client: LightsparkClient,
151
+ fromDate: string,
152
+ toDate: string,
153
+ direction: LightningPaymentDirection,
154
+ ): Promise<LightsparkNodeToDailyLiquidityForecastsConnection>;
146
155
  }
147
156
 
148
157
  export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
@@ -0,0 +1,73 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import type DailyLiquidityForecast from "./DailyLiquidityForecast.js";
4
+ import {
5
+ DailyLiquidityForecastFromJson,
6
+ DailyLiquidityForecastToJson,
7
+ } from "./DailyLiquidityForecast.js";
8
+ import LightningPaymentDirection from "./LightningPaymentDirection.js";
9
+
10
+ interface LightsparkNodeToDailyLiquidityForecastsConnection {
11
+ fromDate: string;
12
+
13
+ toDate: string;
14
+
15
+ direction: LightningPaymentDirection;
16
+
17
+ /** The daily liquidity forecasts for the current page of this connection. **/
18
+ entities: DailyLiquidityForecast[];
19
+ }
20
+
21
+ export const LightsparkNodeToDailyLiquidityForecastsConnectionFromJson = (
22
+ obj: any,
23
+ ): LightsparkNodeToDailyLiquidityForecastsConnection => {
24
+ return {
25
+ fromDate:
26
+ obj["lightspark_node_to_daily_liquidity_forecasts_connection_from_date"],
27
+ toDate:
28
+ obj["lightspark_node_to_daily_liquidity_forecasts_connection_to_date"],
29
+ direction:
30
+ LightningPaymentDirection[
31
+ obj["lightspark_node_to_daily_liquidity_forecasts_connection_direction"]
32
+ ] ?? LightningPaymentDirection.FUTURE_VALUE,
33
+ entities: obj[
34
+ "lightspark_node_to_daily_liquidity_forecasts_connection_entities"
35
+ ].map((e) => DailyLiquidityForecastFromJson(e)),
36
+ } as LightsparkNodeToDailyLiquidityForecastsConnection;
37
+ };
38
+ export const LightsparkNodeToDailyLiquidityForecastsConnectionToJson = (
39
+ obj: LightsparkNodeToDailyLiquidityForecastsConnection,
40
+ ): any => {
41
+ return {
42
+ lightspark_node_to_daily_liquidity_forecasts_connection_from_date:
43
+ obj.fromDate,
44
+ lightspark_node_to_daily_liquidity_forecasts_connection_to_date: obj.toDate,
45
+ lightspark_node_to_daily_liquidity_forecasts_connection_direction:
46
+ obj.direction,
47
+ lightspark_node_to_daily_liquidity_forecasts_connection_entities:
48
+ obj.entities.map((e) => DailyLiquidityForecastToJson(e)),
49
+ };
50
+ };
51
+
52
+ export const FRAGMENT = `
53
+ fragment LightsparkNodeToDailyLiquidityForecastsConnectionFragment on LightsparkNodeToDailyLiquidityForecastsConnection {
54
+ __typename
55
+ lightspark_node_to_daily_liquidity_forecasts_connection_from_date: from_date
56
+ lightspark_node_to_daily_liquidity_forecasts_connection_to_date: to_date
57
+ lightspark_node_to_daily_liquidity_forecasts_connection_direction: direction
58
+ lightspark_node_to_daily_liquidity_forecasts_connection_entities: entities {
59
+ __typename
60
+ daily_liquidity_forecast_date: date
61
+ daily_liquidity_forecast_direction: direction
62
+ daily_liquidity_forecast_amount: amount {
63
+ __typename
64
+ currency_amount_original_value: original_value
65
+ currency_amount_original_unit: original_unit
66
+ currency_amount_preferred_currency_unit: preferred_currency_unit
67
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
68
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
69
+ }
70
+ }
71
+ }`;
72
+
73
+ export default LightsparkNodeToDailyLiquidityForecastsConnection;
@@ -18,10 +18,13 @@ import {
18
18
  CurrencyAmountToJson,
19
19
  } from "./CurrencyAmount.js";
20
20
  import type Entity from "./Entity.js";
21
+ import type LightningPaymentDirection from "./LightningPaymentDirection.js";
21
22
  import type LightsparkNode from "./LightsparkNode.js";
22
23
  import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
23
24
  import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
24
25
  import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
26
+ import type LightsparkNodeToDailyLiquidityForecastsConnection from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
27
+ import { LightsparkNodeToDailyLiquidityForecastsConnectionFromJson } from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
25
28
  import type Node from "./Node.js";
26
29
  import type NodeAddressType from "./NodeAddressType.js";
27
30
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
@@ -288,6 +291,55 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
288
291
  }))!;
289
292
  }
290
293
 
294
+ public async getDailyLiquidityForecasts(
295
+ client: LightsparkClient,
296
+ fromDate: string,
297
+ toDate: string,
298
+ direction: LightningPaymentDirection,
299
+ ): Promise<LightsparkNodeToDailyLiquidityForecastsConnection> {
300
+ return (await client.executeRawQuery({
301
+ queryPayload: `
302
+ query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) {
303
+ entity(id: $entity_id) {
304
+ ... on LightsparkNodeWithOSK {
305
+ daily_liquidity_forecasts(, from_date: $from_date, to_date: $to_date, direction: $direction) {
306
+ __typename
307
+ lightspark_node_to_daily_liquidity_forecasts_connection_from_date: from_date
308
+ lightspark_node_to_daily_liquidity_forecasts_connection_to_date: to_date
309
+ lightspark_node_to_daily_liquidity_forecasts_connection_direction: direction
310
+ lightspark_node_to_daily_liquidity_forecasts_connection_entities: entities {
311
+ __typename
312
+ daily_liquidity_forecast_date: date
313
+ daily_liquidity_forecast_direction: direction
314
+ daily_liquidity_forecast_amount: amount {
315
+ __typename
316
+ currency_amount_original_value: original_value
317
+ currency_amount_original_unit: original_unit
318
+ currency_amount_preferred_currency_unit: preferred_currency_unit
319
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
320
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }
326
+ }
327
+ `,
328
+ variables: {
329
+ entity_id: this.id,
330
+ from_date: fromDate,
331
+ to_date: toDate,
332
+ direction: direction,
333
+ },
334
+ constructObject: (json) => {
335
+ const connection = json["entity"]["daily_liquidity_forecasts"];
336
+ return LightsparkNodeToDailyLiquidityForecastsConnectionFromJson(
337
+ connection,
338
+ );
339
+ },
340
+ }))!;
341
+ }
342
+
291
343
  static getLightsparkNodeWithOSKQuery(
292
344
  id: string,
293
345
  ): Query<LightsparkNodeWithOSK> {
@@ -18,10 +18,13 @@ import {
18
18
  CurrencyAmountToJson,
19
19
  } from "./CurrencyAmount.js";
20
20
  import type Entity from "./Entity.js";
21
+ import type LightningPaymentDirection from "./LightningPaymentDirection.js";
21
22
  import type LightsparkNode from "./LightsparkNode.js";
22
23
  import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
23
24
  import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
24
25
  import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
26
+ import type LightsparkNodeToDailyLiquidityForecastsConnection from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
27
+ import { LightsparkNodeToDailyLiquidityForecastsConnectionFromJson } from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
25
28
  import type Node from "./Node.js";
26
29
  import type NodeAddressType from "./NodeAddressType.js";
27
30
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
@@ -281,6 +284,55 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
281
284
  }))!;
282
285
  }
283
286
 
287
+ public async getDailyLiquidityForecasts(
288
+ client: LightsparkClient,
289
+ fromDate: string,
290
+ toDate: string,
291
+ direction: LightningPaymentDirection,
292
+ ): Promise<LightsparkNodeToDailyLiquidityForecastsConnection> {
293
+ return (await client.executeRawQuery({
294
+ queryPayload: `
295
+ query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) {
296
+ entity(id: $entity_id) {
297
+ ... on LightsparkNodeWithRemoteSigning {
298
+ daily_liquidity_forecasts(, from_date: $from_date, to_date: $to_date, direction: $direction) {
299
+ __typename
300
+ lightspark_node_to_daily_liquidity_forecasts_connection_from_date: from_date
301
+ lightspark_node_to_daily_liquidity_forecasts_connection_to_date: to_date
302
+ lightspark_node_to_daily_liquidity_forecasts_connection_direction: direction
303
+ lightspark_node_to_daily_liquidity_forecasts_connection_entities: entities {
304
+ __typename
305
+ daily_liquidity_forecast_date: date
306
+ daily_liquidity_forecast_direction: direction
307
+ daily_liquidity_forecast_amount: amount {
308
+ __typename
309
+ currency_amount_original_value: original_value
310
+ currency_amount_original_unit: original_unit
311
+ currency_amount_preferred_currency_unit: preferred_currency_unit
312
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
313
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ }
320
+ `,
321
+ variables: {
322
+ entity_id: this.id,
323
+ from_date: fromDate,
324
+ to_date: toDate,
325
+ direction: direction,
326
+ },
327
+ constructObject: (json) => {
328
+ const connection = json["entity"]["daily_liquidity_forecasts"];
329
+ return LightsparkNodeToDailyLiquidityForecastsConnectionFromJson(
330
+ connection,
331
+ );
332
+ },
333
+ }))!;
334
+ }
335
+
284
336
  static getLightsparkNodeWithRemoteSigningQuery(
285
337
  id: string,
286
338
  ): Query<LightsparkNodeWithRemoteSigning> {
@@ -49,6 +49,7 @@ export { default as CreateUmaInvitationOutput } from "./CreateUmaInvitationOutpu
49
49
  export { default as CreateUmaInvoiceInput } from "./CreateUmaInvoiceInput.js";
50
50
  export { default as CurrencyAmount } from "./CurrencyAmount.js";
51
51
  export { default as CurrencyUnit } from "./CurrencyUnit.js";
52
+ export { default as DailyLiquidityForecast } from "./DailyLiquidityForecast.js";
52
53
  export { default as DeclineToSignMessagesInput } from "./DeclineToSignMessagesInput.js";
53
54
  export { default as DeclineToSignMessagesOutput } from "./DeclineToSignMessagesOutput.js";
54
55
  export { default as DeleteApiTokenInput } from "./DeleteApiTokenInput.js";
@@ -77,6 +78,7 @@ export { default as InvoiceType } from "./InvoiceType.js";
77
78
  export { default as LightningFeeEstimateForInvoiceInput } from "./LightningFeeEstimateForInvoiceInput.js";
78
79
  export { default as LightningFeeEstimateForNodeInput } from "./LightningFeeEstimateForNodeInput.js";
79
80
  export { default as LightningFeeEstimateOutput } from "./LightningFeeEstimateOutput.js";
81
+ export { default as LightningPaymentDirection } from "./LightningPaymentDirection.js";
80
82
  export {
81
83
  default as LightningTransaction,
82
84
  getLightningTransactionQuery,
@@ -91,6 +93,7 @@ export {
91
93
  } from "./LightsparkNodeOwner.js";
92
94
  export { default as LightsparkNodeStatus } from "./LightsparkNodeStatus.js";
93
95
  export { default as LightsparkNodeToChannelsConnection } from "./LightsparkNodeToChannelsConnection.js";
96
+ export { default as LightsparkNodeToDailyLiquidityForecastsConnection } from "./LightsparkNodeToDailyLiquidityForecastsConnection.js";
94
97
  export { default as LightsparkNodeWithOSK } from "./LightsparkNodeWithOSK.js";
95
98
  export { default as LightsparkNodeWithRemoteSigning } from "./LightsparkNodeWithRemoteSigning.js";
96
99
  export { default as Node, getNodeQuery } from "./Node.js";