@lightsparkdev/lightspark-sdk 0.2.2 → 0.2.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.
@@ -4,7 +4,7 @@ var __commonJS = (cb, mod) => function __require() {
4
4
  };
5
5
 
6
6
  // src/objects/Account.ts
7
- import autoBind9 from "auto-bind";
7
+ import autoBind10 from "auto-bind";
8
8
 
9
9
  // src/objects/Permission.ts
10
10
  var Permission = /* @__PURE__ */ ((Permission2) => {
@@ -2894,6 +2894,168 @@ var AccountToTransactionsConnectionFromJson = (obj) => {
2894
2894
  };
2895
2895
  };
2896
2896
 
2897
+ // src/objects/Wallet.ts
2898
+ import autoBind9 from "auto-bind";
2899
+
2900
+ // src/objects/Balances.ts
2901
+ var BalancesFromJson = (obj) => {
2902
+ return {
2903
+ ownedBalance: CurrencyAmountFromJson(obj["balances_owned_balance"]),
2904
+ availableToSendBalance: CurrencyAmountFromJson(
2905
+ obj["balances_available_to_send_balance"]
2906
+ ),
2907
+ availableToWithdrawBalance: CurrencyAmountFromJson(
2908
+ obj["balances_available_to_withdraw_balance"]
2909
+ )
2910
+ };
2911
+ };
2912
+
2913
+ // src/objects/Wallet.ts
2914
+ var Wallet = class {
2915
+ constructor(id, createdAt, updatedAt, thirdPartyIdentifier, typename, lastLoginAt, balances) {
2916
+ this.id = id;
2917
+ this.createdAt = createdAt;
2918
+ this.updatedAt = updatedAt;
2919
+ this.thirdPartyIdentifier = thirdPartyIdentifier;
2920
+ this.typename = typename;
2921
+ this.lastLoginAt = lastLoginAt;
2922
+ this.balances = balances;
2923
+ autoBind9(this);
2924
+ }
2925
+ async getTotalAmountReceived(client, createdAfterDate = void 0, createdBeforeDate = void 0) {
2926
+ return await client.executeRawQuery({
2927
+ queryPayload: `
2928
+ query FetchWalletTotalAmountReceived($created_after_date: DateTime, $created_before_date: DateTime) {
2929
+ current_wallet {
2930
+ ... on Wallet {
2931
+ total_amount_received(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
2932
+ __typename
2933
+ currency_amount_original_value: original_value
2934
+ currency_amount_original_unit: original_unit
2935
+ currency_amount_preferred_currency_unit: preferred_currency_unit
2936
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
2937
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
2938
+ }
2939
+ }
2940
+ }
2941
+ }
2942
+ `,
2943
+ variables: {
2944
+ created_after_date: createdAfterDate,
2945
+ created_before_date: createdBeforeDate
2946
+ },
2947
+ constructObject: (json) => {
2948
+ const connection = json["current_wallet"]["total_amount_received"];
2949
+ return CurrencyAmountFromJson(connection);
2950
+ }
2951
+ });
2952
+ }
2953
+ async getTotalAmountSent(client, createdAfterDate = void 0, createdBeforeDate = void 0) {
2954
+ return await client.executeRawQuery({
2955
+ queryPayload: `
2956
+ query FetchWalletTotalAmountSent($created_after_date: DateTime, $created_before_date: DateTime) {
2957
+ current_wallet {
2958
+ ... on Wallet {
2959
+ total_amount_sent(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
2960
+ __typename
2961
+ currency_amount_original_value: original_value
2962
+ currency_amount_original_unit: original_unit
2963
+ currency_amount_preferred_currency_unit: preferred_currency_unit
2964
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
2965
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
2966
+ }
2967
+ }
2968
+ }
2969
+ }
2970
+ `,
2971
+ variables: {
2972
+ created_after_date: createdAfterDate,
2973
+ created_before_date: createdBeforeDate
2974
+ },
2975
+ constructObject: (json) => {
2976
+ const connection = json["current_wallet"]["total_amount_sent"];
2977
+ return CurrencyAmountFromJson(connection);
2978
+ }
2979
+ });
2980
+ }
2981
+ static getWalletQuery() {
2982
+ return {
2983
+ queryPayload: `
2984
+ query GetWallet {
2985
+ current_wallet {
2986
+ ... on Wallet {
2987
+ ...WalletFragment
2988
+ }
2989
+ }
2990
+ }
2991
+
2992
+ ${FRAGMENT15}
2993
+ `,
2994
+ variables: {},
2995
+ constructObject: (data) => WalletFromJson(data.current_wallet)
2996
+ };
2997
+ }
2998
+ };
2999
+ var WalletFromJson = (obj) => {
3000
+ return new Wallet(
3001
+ obj["wallet_id"],
3002
+ obj["wallet_created_at"],
3003
+ obj["wallet_updated_at"],
3004
+ obj["wallet_third_party_identifier"],
3005
+ "Wallet",
3006
+ obj["wallet_last_login_at"],
3007
+ !!obj["wallet_balances"] ? BalancesFromJson(obj["wallet_balances"]) : void 0
3008
+ );
3009
+ };
3010
+ var FRAGMENT15 = `
3011
+ fragment WalletFragment on Wallet {
3012
+ __typename
3013
+ wallet_id: id
3014
+ wallet_created_at: created_at
3015
+ wallet_updated_at: updated_at
3016
+ wallet_last_login_at: last_login_at
3017
+ wallet_balances: balances {
3018
+ __typename
3019
+ balances_owned_balance: owned_balance {
3020
+ __typename
3021
+ currency_amount_original_value: original_value
3022
+ currency_amount_original_unit: original_unit
3023
+ currency_amount_preferred_currency_unit: preferred_currency_unit
3024
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
3025
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
3026
+ }
3027
+ balances_available_to_send_balance: available_to_send_balance {
3028
+ __typename
3029
+ currency_amount_original_value: original_value
3030
+ currency_amount_original_unit: original_unit
3031
+ currency_amount_preferred_currency_unit: preferred_currency_unit
3032
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
3033
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
3034
+ }
3035
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
3036
+ __typename
3037
+ currency_amount_original_value: original_value
3038
+ currency_amount_original_unit: original_unit
3039
+ currency_amount_preferred_currency_unit: preferred_currency_unit
3040
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
3041
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
3042
+ }
3043
+ }
3044
+ wallet_third_party_identifier: third_party_identifier
3045
+ }`;
3046
+ var Wallet_default = Wallet;
3047
+
3048
+ // src/objects/AccountToWalletsConnection.ts
3049
+ var AccountToWalletsConnectionFromJson = (obj) => {
3050
+ return {
3051
+ pageInfo: PageInfoFromJson(obj["account_to_wallets_connection_page_info"]),
3052
+ count: obj["account_to_wallets_connection_count"],
3053
+ entities: obj["account_to_wallets_connection_entities"].map(
3054
+ (e) => WalletFromJson(e)
3055
+ )
3056
+ };
3057
+ };
3058
+
2897
3059
  // src/objects/Account.ts
2898
3060
  var Account = class {
2899
3061
  constructor(id, createdAt, updatedAt, typename, name) {
@@ -2902,7 +3064,7 @@ var Account = class {
2902
3064
  this.updatedAt = updatedAt;
2903
3065
  this.typename = typename;
2904
3066
  this.name = name;
2905
- autoBind9(this);
3067
+ autoBind10(this);
2906
3068
  }
2907
3069
  async getApiTokens(client, first = void 0) {
2908
3070
  return await client.executeRawQuery({
@@ -3980,6 +4142,69 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
3980
4142
  }
3981
4143
  });
3982
4144
  }
4145
+ async getWallets(client, first = void 0) {
4146
+ return await client.executeRawQuery({
4147
+ queryPayload: `
4148
+ query FetchAccountToWalletsConnection($first: Int) {
4149
+ current_account {
4150
+ ... on Account {
4151
+ wallets(, first: $first) {
4152
+ __typename
4153
+ account_to_wallets_connection_page_info: page_info {
4154
+ __typename
4155
+ page_info_has_next_page: has_next_page
4156
+ page_info_has_previous_page: has_previous_page
4157
+ page_info_start_cursor: start_cursor
4158
+ page_info_end_cursor: end_cursor
4159
+ }
4160
+ account_to_wallets_connection_count: count
4161
+ account_to_wallets_connection_entities: entities {
4162
+ __typename
4163
+ wallet_id: id
4164
+ wallet_created_at: created_at
4165
+ wallet_updated_at: updated_at
4166
+ wallet_last_login_at: last_login_at
4167
+ wallet_balances: balances {
4168
+ __typename
4169
+ balances_owned_balance: owned_balance {
4170
+ __typename
4171
+ currency_amount_original_value: original_value
4172
+ currency_amount_original_unit: original_unit
4173
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4174
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4175
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4176
+ }
4177
+ balances_available_to_send_balance: available_to_send_balance {
4178
+ __typename
4179
+ currency_amount_original_value: original_value
4180
+ currency_amount_original_unit: original_unit
4181
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4182
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4183
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4184
+ }
4185
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
4186
+ __typename
4187
+ currency_amount_original_value: original_value
4188
+ currency_amount_original_unit: original_unit
4189
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4190
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4191
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4192
+ }
4193
+ }
4194
+ wallet_third_party_identifier: third_party_identifier
4195
+ }
4196
+ }
4197
+ }
4198
+ }
4199
+ }
4200
+ `,
4201
+ variables: { first },
4202
+ constructObject: (json) => {
4203
+ const connection = json["current_account"]["wallets"];
4204
+ return AccountToWalletsConnectionFromJson(connection);
4205
+ }
4206
+ });
4207
+ }
3983
4208
  static getAccountQuery() {
3984
4209
  return {
3985
4210
  queryPayload: `
@@ -3991,7 +4216,7 @@ query GetAccount {
3991
4216
  }
3992
4217
  }
3993
4218
 
3994
- ${FRAGMENT15}
4219
+ ${FRAGMENT16}
3995
4220
  `,
3996
4221
  variables: {},
3997
4222
  constructObject: (data) => AccountFromJson(data.current_account)
@@ -4007,7 +4232,7 @@ var AccountFromJson = (obj) => {
4007
4232
  obj["account_name"]
4008
4233
  );
4009
4234
  };
4010
- var FRAGMENT15 = `
4235
+ var FRAGMENT16 = `
4011
4236
  fragment AccountFragment on Account {
4012
4237
  __typename
4013
4238
  account_id: id
@@ -4036,7 +4261,7 @@ var ChannelClosingTransactionFromJson = (obj) => {
4036
4261
  channelId: obj["channel_closing_transaction_channel"]?.id ?? void 0
4037
4262
  };
4038
4263
  };
4039
- var FRAGMENT16 = `
4264
+ var FRAGMENT17 = `
4040
4265
  fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
4041
4266
  __typename
4042
4267
  channel_closing_transaction_id: id
@@ -4080,7 +4305,7 @@ query GetChannelClosingTransaction($id: ID!) {
4080
4305
  }
4081
4306
  }
4082
4307
 
4083
- ${FRAGMENT16}
4308
+ ${FRAGMENT17}
4084
4309
  `,
4085
4310
  variables: { id },
4086
4311
  constructObject: (data) => ChannelClosingTransactionFromJson(data.entity)
@@ -4106,7 +4331,7 @@ var ChannelOpeningTransactionFromJson = (obj) => {
4106
4331
  channelId: obj["channel_opening_transaction_channel"]?.id ?? void 0
4107
4332
  };
4108
4333
  };
4109
- var FRAGMENT17 = `
4334
+ var FRAGMENT18 = `
4110
4335
  fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction {
4111
4336
  __typename
4112
4337
  channel_opening_transaction_id: id
@@ -4150,7 +4375,7 @@ query GetChannelOpeningTransaction($id: ID!) {
4150
4375
  }
4151
4376
  }
4152
4377
 
4153
- ${FRAGMENT17}
4378
+ ${FRAGMENT18}
4154
4379
  `,
4155
4380
  variables: { id },
4156
4381
  constructObject: (data) => ChannelOpeningTransactionFromJson(data.entity)
@@ -4185,7 +4410,7 @@ var DepositFromJson = (obj) => {
4185
4410
  numConfirmations: obj["deposit_num_confirmations"]
4186
4411
  };
4187
4412
  };
4188
- var FRAGMENT18 = `
4413
+ var FRAGMENT19 = `
4189
4414
  fragment DepositFragment on Deposit {
4190
4415
  __typename
4191
4416
  deposit_id: id
@@ -4229,7 +4454,7 @@ query GetDeposit($id: ID!) {
4229
4454
  }
4230
4455
  }
4231
4456
 
4232
- ${FRAGMENT18}
4457
+ ${FRAGMENT19}
4233
4458
  `,
4234
4459
  variables: { id },
4235
4460
  constructObject: (data) => DepositFromJson(data.entity)
@@ -4243,7 +4468,7 @@ var FeeEstimateFromJson = (obj) => {
4243
4468
  feeMin: CurrencyAmountFromJson(obj["fee_estimate_fee_min"])
4244
4469
  };
4245
4470
  };
4246
- var FRAGMENT19 = `
4471
+ var FRAGMENT20 = `
4247
4472
  fragment FeeEstimateFragment on FeeEstimate {
4248
4473
  __typename
4249
4474
  fee_estimate_fee_fast: fee_fast {
@@ -4276,7 +4501,7 @@ var InvoiceFromJson = (obj) => {
4276
4501
  amountPaid: !!obj["invoice_amount_paid"] ? CurrencyAmountFromJson(obj["invoice_amount_paid"]) : void 0
4277
4502
  };
4278
4503
  };
4279
- var FRAGMENT20 = `
4504
+ var FRAGMENT21 = `
4280
4505
  fragment InvoiceFragment on Invoice {
4281
4506
  __typename
4282
4507
  invoice_id: id
@@ -4440,7 +4665,7 @@ query GetInvoice($id: ID!) {
4440
4665
  }
4441
4666
  }
4442
4667
 
4443
- ${FRAGMENT20}
4668
+ ${FRAGMENT21}
4444
4669
  `,
4445
4670
  variables: { id },
4446
4671
  constructObject: (data) => InvoiceFromJson(data.entity)
@@ -4448,7 +4673,7 @@ ${FRAGMENT20}
4448
4673
  };
4449
4674
 
4450
4675
  // src/objects/LightningFeeEstimateOutput.ts
4451
- var FRAGMENT21 = `
4676
+ var FRAGMENT22 = `
4452
4677
  fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput {
4453
4678
  __typename
4454
4679
  lightning_fee_estimate_output_fee_estimate: fee_estimate {
@@ -4521,7 +4746,7 @@ var LightningTransactionFromJson = (obj) => {
4521
4746
  `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`
4522
4747
  );
4523
4748
  };
4524
- var FRAGMENT22 = `
4749
+ var FRAGMENT23 = `
4525
4750
  fragment LightningTransactionFragment on LightningTransaction {
4526
4751
  __typename
4527
4752
  ... on IncomingPayment {
@@ -4774,7 +4999,7 @@ query GetLightningTransaction($id: ID!) {
4774
4999
  }
4775
5000
  }
4776
5001
 
4777
- ${FRAGMENT22}
5002
+ ${FRAGMENT23}
4778
5003
  `,
4779
5004
  variables: { id },
4780
5005
  constructObject: (data) => LightningTransactionFromJson(data.entity)
@@ -4861,7 +5086,7 @@ var OnChainTransactionFromJson = (obj) => {
4861
5086
  `Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename=${obj["__typename"]}`
4862
5087
  );
4863
5088
  };
4864
- var FRAGMENT23 = `
5089
+ var FRAGMENT24 = `
4865
5090
  fragment OnChainTransactionFragment on OnChainTransaction {
4866
5091
  __typename
4867
5092
  ... on ChannelClosingTransaction {
@@ -5004,7 +5229,7 @@ query GetOnChainTransaction($id: ID!) {
5004
5229
  }
5005
5230
  }
5006
5231
 
5007
- ${FRAGMENT23}
5232
+ ${FRAGMENT24}
5008
5233
  `,
5009
5234
  variables: { id },
5010
5235
  constructObject: (data) => OnChainTransactionFromJson(data.entity)
@@ -5038,7 +5263,7 @@ var RoutingTransactionFromJson = (obj) => {
5038
5263
  failureReason: !!obj["routing_transaction_failure_reason"] ? RoutingTransactionFailureReason_default[obj["routing_transaction_failure_reason"]] ?? RoutingTransactionFailureReason_default.FUTURE_VALUE : null
5039
5264
  };
5040
5265
  };
5041
- var FRAGMENT24 = `
5266
+ var FRAGMENT25 = `
5042
5267
  fragment RoutingTransactionFragment on RoutingTransaction {
5043
5268
  __typename
5044
5269
  routing_transaction_id: id
@@ -5086,7 +5311,7 @@ query GetRoutingTransaction($id: ID!) {
5086
5311
  }
5087
5312
  }
5088
5313
 
5089
- ${FRAGMENT24}
5314
+ ${FRAGMENT25}
5090
5315
  `,
5091
5316
  variables: { id },
5092
5317
  constructObject: (data) => RoutingTransactionFromJson(data.entity)
@@ -5123,7 +5348,7 @@ var TransactionUpdateFromJson = (obj) => {
5123
5348
  transactionHash: obj["transaction_hash"]
5124
5349
  };
5125
5350
  };
5126
- var FRAGMENT25 = `
5351
+ var FRAGMENT26 = `
5127
5352
  fragment TransactionUpdateFragment on Transaction {
5128
5353
  __typename
5129
5354
  id
@@ -5175,7 +5400,7 @@ var WithdrawalFromJson = (obj) => {
5175
5400
  numConfirmations: obj["withdrawal_num_confirmations"]
5176
5401
  };
5177
5402
  };
5178
- var FRAGMENT26 = `
5403
+ var FRAGMENT27 = `
5179
5404
  fragment WithdrawalFragment on Withdrawal {
5180
5405
  __typename
5181
5406
  withdrawal_id: id
@@ -5219,7 +5444,7 @@ query GetWithdrawal($id: ID!) {
5219
5444
  }
5220
5445
  }
5221
5446
 
5222
- ${FRAGMENT26}
5447
+ ${FRAGMENT27}
5223
5448
  `,
5224
5449
  variables: { id },
5225
5450
  constructObject: (data) => WithdrawalFromJson(data.entity)
@@ -5227,7 +5452,7 @@ ${FRAGMENT26}
5227
5452
  };
5228
5453
 
5229
5454
  // src/objects/WithdrawalRequest.ts
5230
- import autoBind10 from "auto-bind";
5455
+ import autoBind11 from "auto-bind";
5231
5456
 
5232
5457
  // src/objects/WithdrawalRequestStatus.ts
5233
5458
  var WithdrawalRequestStatus = /* @__PURE__ */ ((WithdrawalRequestStatus2) => {
@@ -5275,7 +5500,7 @@ var WithdrawalRequest = class {
5275
5500
  this.estimatedAmount = estimatedAmount;
5276
5501
  this.completedAt = completedAt;
5277
5502
  this.withdrawalId = withdrawalId;
5278
- autoBind10(this);
5503
+ autoBind11(this);
5279
5504
  }
5280
5505
  async getChannelClosingTransactions(client, first = void 0) {
5281
5506
  return await client.executeRawQuery({
@@ -5412,7 +5637,7 @@ query GetWithdrawalRequest($id: ID!) {
5412
5637
  }
5413
5638
  }
5414
5639
 
5415
- ${FRAGMENT27}
5640
+ ${FRAGMENT28}
5416
5641
  `,
5417
5642
  variables: { id },
5418
5643
  constructObject: (data) => WithdrawalRequestFromJson(data.entity)
@@ -5434,7 +5659,7 @@ var WithdrawalRequestFromJson = (obj) => {
5434
5659
  obj["withdrawal_request_withdrawal"]?.id ?? void 0
5435
5660
  );
5436
5661
  };
5437
- var FRAGMENT27 = `
5662
+ var FRAGMENT28 = `
5438
5663
  fragment WithdrawalRequestFragment on WithdrawalRequest {
5439
5664
  __typename
5440
5665
  withdrawal_request_id: id
@@ -5472,7 +5697,7 @@ export {
5472
5697
  CurrencyAmountFromJson,
5473
5698
  FRAGMENT2 as FRAGMENT,
5474
5699
  FeeEstimateFromJson,
5475
- FRAGMENT19 as FRAGMENT2,
5700
+ FRAGMENT20 as FRAGMENT2,
5476
5701
  Permission_default,
5477
5702
  ApiTokenFromJson,
5478
5703
  FRAGMENT as FRAGMENT3,
@@ -5488,7 +5713,7 @@ export {
5488
5713
  Node_default,
5489
5714
  InvoiceDataFromJson,
5490
5715
  FRAGMENT7 as FRAGMENT4,
5491
- FRAGMENT21 as FRAGMENT5,
5716
+ FRAGMENT22 as FRAGMENT5,
5492
5717
  HtlcAttemptFailureCode_default,
5493
5718
  OutgoingPaymentAttemptStatus_default,
5494
5719
  getHopQuery,
@@ -5503,7 +5728,7 @@ export {
5503
5728
  getChannelClosingTransactionQuery,
5504
5729
  getChannelOpeningTransactionQuery,
5505
5730
  WithdrawalRequestFromJson,
5506
- FRAGMENT27 as FRAGMENT7,
5731
+ FRAGMENT28 as FRAGMENT7,
5507
5732
  WithdrawalRequest_default,
5508
5733
  IncomingPaymentAttemptStatus_default,
5509
5734
  getIncomingPaymentAttemptQuery,
@@ -5513,10 +5738,11 @@ export {
5513
5738
  FRAGMENT14 as FRAGMENT8,
5514
5739
  getTransactionQuery,
5515
5740
  TransactionUpdateFromJson,
5516
- FRAGMENT25 as FRAGMENT9,
5741
+ FRAGMENT26 as FRAGMENT9,
5517
5742
  AccountToChannelsConnection_default,
5518
5743
  PaymentRequestStatus_default,
5519
5744
  getPaymentRequestQuery,
5745
+ Wallet_default,
5520
5746
  Account_default,
5521
5747
  InvoiceType_default,
5522
5748
  getDepositQuery,