casualos 4.2.6 → 4.2.7-alpha.28599452017

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 (2) hide show
  1. package/dist/cli.js +240 -126
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -166714,7 +166714,7 @@ var trace = TraceAPI.getInstance();
166714
166714
  function hashLowEntropyPasswordWithSalt2(password, salt) {
166715
166715
  const tracer = trace.getTracer(
166716
166716
  "InstrumentedHashHelpers",
166717
- false ? void 0 : "v4.2.6"
166717
+ false ? void 0 : "v4.2.7-alpha.28599452017"
166718
166718
  );
166719
166719
  return tracer.startActiveSpan(
166720
166720
  "hashLowEntropyPasswordWithSalt",
@@ -166732,7 +166732,7 @@ function hashLowEntropyPasswordWithSalt2(password, salt) {
166732
166732
  function hashHighEntropyPasswordWithSalt2(password, salt) {
166733
166733
  const tracer = trace.getTracer(
166734
166734
  "InstrumentedHashHelpers",
166735
- false ? void 0 : "v4.2.6"
166735
+ false ? void 0 : "v4.2.7-alpha.28599452017"
166736
166736
  );
166737
166737
  return tracer.startActiveSpan(
166738
166738
  "hashHighEntropyPasswordWithSalt",
@@ -166750,7 +166750,7 @@ function hashHighEntropyPasswordWithSalt2(password, salt) {
166750
166750
  function verifyPasswordAgainstHashes2(password, salt, hashes) {
166751
166751
  const tracer = trace.getTracer(
166752
166752
  "InstrumentedHashHelpers",
166753
- false ? void 0 : "v4.2.6"
166753
+ false ? void 0 : "v4.2.7-alpha.28599452017"
166754
166754
  );
166755
166755
  return tracer.startActiveSpan(
166756
166756
  "verifyPasswordAgainstHashes",
@@ -174351,7 +174351,7 @@ function traced(tracerName, options = {}, metricOptions = {}) {
174351
174351
  }
174352
174352
  const tracer = trace.getTracer(
174353
174353
  tracerName,
174354
- false ? void 0 : "v4.2.6"
174354
+ false ? void 0 : "v4.2.7-alpha.28599452017"
174355
174355
  );
174356
174356
  return function(target, propertyKey, descriptor) {
174357
174357
  const originalMethod = descriptor.value;
@@ -174437,7 +174437,7 @@ function getHistogram(meter) {
174437
174437
  }
174438
174438
  return metrics.getMeter(
174439
174439
  meter.meter,
174440
- false ? void 0 : "v4.2.6"
174440
+ false ? void 0 : "v4.2.7-alpha.28599452017"
174441
174441
  ).createHistogram(meter.name, meter.options);
174442
174442
  }
174443
174443
  function getCounter(meter) {
@@ -174446,7 +174446,7 @@ function getCounter(meter) {
174446
174446
  }
174447
174447
  return metrics.getMeter(
174448
174448
  meter.meter,
174449
- false ? void 0 : "v4.2.6"
174449
+ false ? void 0 : "v4.2.7-alpha.28599452017"
174450
174450
  ).createCounter(meter.name, meter.options);
174451
174451
  }
174452
174452
  function traceHttpResponse(options = {}) {
@@ -183682,17 +183682,16 @@ var FinancialController = class {
183682
183682
  if (typeof accountId === "string") {
183683
183683
  accountId = BigInt(accountId);
183684
183684
  }
183685
- const minTime = typeof options?.minTimeMs === "number" ? BigInt(Math.floor(options.minTimeMs)) * 1000000n : 0n;
183686
- const maxTime = typeof options?.maxTimeMs === "number" ? BigInt(Math.floor(options.maxTimeMs)) * 1000000n : 0n;
183687
- const limit2 = Math.max(0, options?.limit ?? 0);
183688
183685
  const transfers = await this._financialInterface.getAccountTransfers({
183689
183686
  account_id: accountId,
183690
183687
  code: 0,
183691
183688
  // 0 means all codes
183692
183689
  flags: (void 0).credits | (void 0).debits,
183693
- limit: limit2,
183694
- timestamp_max: maxTime,
183695
- timestamp_min: minTime,
183690
+ // 0 means no limit for account transfer queries.
183691
+ limit: options?.limit ?? 0,
183692
+ // 0 means no timestamp bound.
183693
+ timestamp_max: typeof options?.maxTimeMs === "number" ? BigInt(options.maxTimeMs) * 1000000n : 0n,
183694
+ timestamp_min: typeof options?.minTimeMs === "number" ? BigInt(options.minTimeMs) * 1000000n : 0n,
183696
183695
  user_data_128: 0n,
183697
183696
  // No user data filter
183698
183697
  user_data_64: 0n,
@@ -183742,26 +183741,73 @@ var FinancialController = class {
183742
183741
  }
183743
183742
  async billForUsage(params2) {
183744
183743
  const gen = this._billForUsage(params2);
183745
- await gen.next();
183744
+ const first2 = await gen.next();
183745
+ if (first2.done) {
183746
+ async function* doneGen() {
183747
+ yield* [];
183748
+ return first2.value;
183749
+ }
183750
+ return doneGen();
183751
+ }
183746
183752
  return gen;
183747
183753
  }
183748
183754
  async *_billForUsage(params2) {
183749
183755
  let accountResult = null;
183756
+ let accountId;
183750
183757
  const maxSteps = params2.maxSteps || 100;
183751
- accountResult = await this.getOrCreateFinancialAccount({
183752
- userId: params2.userId,
183753
- studioId: params2.studioId,
183754
- ledger: LEDGERS.credits
183755
- });
183756
- if (isFailure(accountResult)) {
183757
- logError(
183758
- accountResult.error,
183759
- `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId}] Failed to get or create financial account for filter`
183760
- );
183761
- return failure({
183762
- errorCode: "server_error",
183763
- errorMessage: "The server encountered an error."
183758
+ const billingAccount = params2.billingAccount;
183759
+ if (billingAccount) {
183760
+ if (billingAccount.recordAccountId) {
183761
+ const account = await this.getAccount(
183762
+ billingAccount.recordAccountId
183763
+ );
183764
+ if (isFailure(account)) {
183765
+ return account;
183766
+ }
183767
+ accountId = account.value.id.toString();
183768
+ } else {
183769
+ const billingUserId = billingAccount.userId ?? void 0;
183770
+ const billingStudioId = billingAccount.studioId ?? void 0;
183771
+ if (!billingUserId && !billingStudioId) {
183772
+ return failure({
183773
+ errorCode: "invalid_request",
183774
+ errorMessage: "Billing account must specify userId, studioId, or recordAccountId."
183775
+ });
183776
+ }
183777
+ accountResult = await this.getOrCreateFinancialAccount({
183778
+ userId: billingUserId,
183779
+ studioId: billingStudioId,
183780
+ ledger: LEDGERS.credits
183781
+ });
183782
+ if (isFailure(accountResult)) {
183783
+ logError(
183784
+ accountResult.error,
183785
+ `[FinancialController] [userId: ${billingAccount.userId} studioId: ${billingAccount.studioId}] Failed to get or create financial account for billing account`
183786
+ );
183787
+ return failure({
183788
+ errorCode: "server_error",
183789
+ errorMessage: "The server encountered an error."
183790
+ });
183791
+ }
183792
+ accountId = accountResult.value.account.id.toString();
183793
+ }
183794
+ } else {
183795
+ accountResult = await this.getOrCreateFinancialAccount({
183796
+ userId: params2.userId,
183797
+ studioId: params2.studioId,
183798
+ ledger: LEDGERS.credits
183764
183799
  });
183800
+ if (isFailure(accountResult)) {
183801
+ logError(
183802
+ accountResult.error,
183803
+ `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId}] Failed to get or create financial account for filter`
183804
+ );
183805
+ return failure({
183806
+ errorCode: "server_error",
183807
+ errorMessage: "The server encountered an error."
183808
+ });
183809
+ }
183810
+ accountId = accountResult.value.account.id.toString();
183765
183811
  }
183766
183812
  let initialAmount = 0n;
183767
183813
  let initialTransferResult;
@@ -183769,7 +183815,7 @@ var FinancialController = class {
183769
183815
  let initialBillingCode;
183770
183816
  const transactionId = this._financialInterface.generateId();
183771
183817
  console.log(
183772
- `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId} billingCode: ${params2.billingCode}] Billing usage for account ID ${accountResult.value.account.id}`
183818
+ `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId} billingCode: ${params2.billingCode}] Billing usage for account ID ${accountId}`
183773
183819
  );
183774
183820
  try {
183775
183821
  for (let steps = 0; steps < maxSteps; steps++) {
@@ -183777,7 +183823,7 @@ var FinancialController = class {
183777
183823
  if (isFailure(result)) {
183778
183824
  if (initialTransferResult && isSuccess(initialTransferResult)) {
183779
183825
  console.log(
183780
- `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Voiding billing transfer for account ${accountResult.value.account.id} due to action failure.`
183826
+ `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Voiding billing transfer for account ${accountId} due to action failure.`
183781
183827
  );
183782
183828
  const cancelResult = await this.completePendingTransfers({
183783
183829
  transfers: initialTransferResult.value.transferIds,
@@ -183799,7 +183845,7 @@ var FinancialController = class {
183799
183845
  const additionalAmount = costBigInt - initialAmount;
183800
183846
  const hadInitialTransfer = initialTransferResult && isSuccess(initialTransferResult);
183801
183847
  console.log(
183802
- `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Billing for cost of ${cost} credits for account ${accountResult.value.account.id}.
183848
+ `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Billing for cost of ${cost} credits for account ${accountId}.
183803
183849
  Currently pending: ${initialAmount}
183804
183850
  Additional amount: ${additionalAmount}
183805
183851
  `
@@ -183846,7 +183892,7 @@ Additional amount: ${additionalAmount}
183846
183892
  transactionId,
183847
183893
  transfers: [
183848
183894
  {
183849
- debitAccountId: accountResult.value.account.id,
183895
+ debitAccountId: accountId,
183850
183896
  creditAccountId: ACCOUNT_IDS.revenue_records_usage_credits,
183851
183897
  amount: additionalAmount,
183852
183898
  currency: "credits",
@@ -183857,7 +183903,7 @@ Additional amount: ${additionalAmount}
183857
183903
  ]
183858
183904
  });
183859
183905
  if (isFailure(additionalTransferResult)) {
183860
- if (additionalTransferResult.error.errorCode === "debits_exceed_credits" && additionalTransferResult.error.accountId === accountResult.value.account.id.toString()) {
183906
+ if (additionalTransferResult.error.errorCode === "debits_exceed_credits" && additionalTransferResult.error.accountId === accountId) {
183861
183907
  logError(
183862
183908
  additionalTransferResult.error,
183863
183909
  `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] User has insufficient funds for additional billing transfer of ${additionalAmount} credits.`,
@@ -183890,7 +183936,7 @@ Additional amount: ${additionalAmount}
183890
183936
  });
183891
183937
  }
183892
183938
  console.log(
183893
- `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Creating initial pending transfer for ${result.value.initialCost} credits for account ${accountResult.value.account.id}.`
183939
+ `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] Creating initial pending transfer for ${result.value.initialCost} credits for account ${accountId}.`
183894
183940
  );
183895
183941
  initialTransferCode = result.value.transferCode ?? params2.transferCode;
183896
183942
  initialBillingCode = result.value.billingCode ?? params2.billingCode;
@@ -183898,7 +183944,7 @@ Additional amount: ${additionalAmount}
183898
183944
  transactionId,
183899
183945
  transfers: [
183900
183946
  {
183901
- debitAccountId: accountResult.value.account.id,
183947
+ debitAccountId: accountId,
183902
183948
  creditAccountId: ACCOUNT_IDS.revenue_records_usage_credits,
183903
183949
  amount: result.value.initialCost,
183904
183950
  currency: "credits",
@@ -183910,7 +183956,7 @@ Additional amount: ${additionalAmount}
183910
183956
  ]
183911
183957
  });
183912
183958
  if (isFailure(newInitialTransferResult)) {
183913
- if (newInitialTransferResult.error.errorCode === "debits_exceed_credits" && newInitialTransferResult.error.accountId === accountResult.value.account.id.toString()) {
183959
+ if (newInitialTransferResult.error.errorCode === "debits_exceed_credits" && newInitialTransferResult.error.accountId === accountId) {
183914
183960
  logError(
183915
183961
  newInitialTransferResult.error,
183916
183962
  `[FinancialController] [userId: ${params2.userId} studioId: ${params2.studioId} transactionId: ${transactionId}] User has insufficient funds for initial billing transfer of ${result.value.initialCost} credits.`,
@@ -184272,6 +184318,64 @@ async function billForUsage(financial, params2) {
184272
184318
  }
184273
184319
  return await financial.billForUsage(params2);
184274
184320
  }
184321
+ async function getBillingAccountForRecord(recordName, recordStore) {
184322
+ try {
184323
+ if (!recordStore.getRecordByName) {
184324
+ return {
184325
+ success: false,
184326
+ errorCode: "not_supported",
184327
+ errorMessage: "Record billing is not supported by this record store."
184328
+ };
184329
+ }
184330
+ const record2 = await recordStore.getRecordByName(recordName);
184331
+ if (!record2) {
184332
+ return {
184333
+ success: false,
184334
+ errorCode: "record_not_found",
184335
+ errorMessage: "The specified record was not found."
184336
+ };
184337
+ }
184338
+ if (record2.creditBillingEnabled && record2.creditAccountId) {
184339
+ return {
184340
+ success: true,
184341
+ userId: null,
184342
+ studioId: null,
184343
+ recordAccountId: record2.creditAccountId
184344
+ };
184345
+ }
184346
+ if (record2.ownerId) {
184347
+ return {
184348
+ success: true,
184349
+ userId: record2.ownerId,
184350
+ studioId: null,
184351
+ recordAccountId: null
184352
+ };
184353
+ }
184354
+ if (record2.studioId) {
184355
+ return {
184356
+ success: true,
184357
+ userId: null,
184358
+ studioId: record2.studioId,
184359
+ recordAccountId: null
184360
+ };
184361
+ }
184362
+ return {
184363
+ success: false,
184364
+ errorCode: "not_authorized",
184365
+ errorMessage: "The record has no owner or credit account to bill."
184366
+ };
184367
+ } catch (err) {
184368
+ console.error(
184369
+ "[getBillingAccountForRecord] Error getting billing account for record:",
184370
+ err
184371
+ );
184372
+ return {
184373
+ success: false,
184374
+ errorCode: "server_error",
184375
+ errorMessage: "A server error occurred."
184376
+ };
184377
+ }
184378
+ }
184275
184379
 
184276
184380
  // ../aux-records/financial/MemoryFinancialInterface.ts
184277
184381
  var MAX_BIGINT_128 = BigInt("340282366920938463463374607431768211454");
@@ -185038,9 +185142,21 @@ var DataRecordsController = class {
185038
185142
  }
185039
185143
  }
185040
185144
  if (features.data.creditFeePerWrite) {
185145
+ const billingAccountResult = await getBillingAccountForRecord(
185146
+ recordName,
185147
+ this._store
185148
+ );
185149
+ if (billingAccountResult.success === false) {
185150
+ return {
185151
+ success: false,
185152
+ errorCode: billingAccountResult.errorCode,
185153
+ errorMessage: billingAccountResult.errorMessage
185154
+ };
185155
+ }
185041
185156
  const billing = await billForUsage(this._financialController, {
185042
- userId: metricsResult.ownerId,
185043
- studioId: metricsResult.studioId,
185157
+ userId: billingAccountResult.userId,
185158
+ studioId: billingAccountResult.studioId,
185159
+ billingAccount: billingAccountResult,
185044
185160
  transferCode: 3004 /* records_usage_fee */,
185045
185161
  billingCode: 1001 /* data_write */
185046
185162
  });
@@ -185152,9 +185268,21 @@ var DataRecordsController = class {
185152
185268
  metricsResult.ownerId ? "user" : "studio"
185153
185269
  );
185154
185270
  if (features.data.creditFeePerRead) {
185271
+ const billingAccountResult = await getBillingAccountForRecord(
185272
+ context.context.recordName,
185273
+ this._store
185274
+ );
185275
+ if (billingAccountResult.success === false) {
185276
+ return {
185277
+ success: false,
185278
+ errorCode: billingAccountResult.errorCode,
185279
+ errorMessage: billingAccountResult.errorMessage
185280
+ };
185281
+ }
185155
185282
  const billing = await billForUsage(this._financialController, {
185156
- userId: metricsResult.ownerId,
185157
- studioId: metricsResult.studioId,
185283
+ userId: billingAccountResult.userId,
185284
+ studioId: billingAccountResult.studioId,
185285
+ billingAccount: billingAccountResult,
185158
185286
  transferCode: 3004 /* records_usage_fee */,
185159
185287
  billingCode: 1002 /* data_read */
185160
185288
  });
@@ -185583,9 +185711,21 @@ var FileRecordsController = class {
185583
185711
  }
185584
185712
  }
185585
185713
  if (features.files.creditFeePerFileWrite) {
185714
+ const billingAccountResult = await getBillingAccountForRecord(
185715
+ recordName,
185716
+ this._store
185717
+ );
185718
+ if (billingAccountResult.success === false) {
185719
+ return {
185720
+ success: false,
185721
+ errorCode: billingAccountResult.errorCode,
185722
+ errorMessage: billingAccountResult.errorMessage
185723
+ };
185724
+ }
185586
185725
  const billing = await billForUsage(this._financialController, {
185587
- userId: metricsResult.ownerId,
185588
- studioId: metricsResult.studioId,
185726
+ billingAccount: billingAccountResult,
185727
+ userId: billingAccountResult.userId,
185728
+ studioId: billingAccountResult.studioId,
185589
185729
  transferCode: 3004 /* records_usage_fee */,
185590
185730
  billingCode: 2001 /* file_write */
185591
185731
  });
@@ -188647,7 +188787,7 @@ var RecordsServer = class {
188647
188787
  this._viewTemplateRenderer = viewTemplateRenderer;
188648
188788
  this._tracer = trace.getTracer(
188649
188789
  "RecordsServer",
188650
- false ? void 0 : "v4.2.6"
188790
+ false ? void 0 : "v4.2.7-alpha.28599452017"
188651
188791
  );
188652
188792
  this._purchasableItems = purchasableItemsController;
188653
188793
  this._procedures = this._createProcedures();
@@ -192741,8 +192881,8 @@ var RecordsServer = class {
192741
192881
  return {
192742
192882
  success: true,
192743
192883
  ...metadata,
192744
- version: true ? "v4.2.6" : void 0,
192745
- versionHash: true ? "b0bd09966fe5825a438278324d102f2804bb920f" : void 0
192884
+ version: true ? "v4.2.7-alpha.28599452017" : void 0,
192885
+ versionHash: true ? "605001d27cbcf4a3a10057c8b35b3bfe579aac8a" : void 0
192746
192886
  };
192747
192887
  }),
192748
192888
  getPurchasableItem: procedure().origins(true).http("GET", "/api/v2/records/purchasableItems").inputs(
@@ -195138,55 +195278,6 @@ var SubscriptionController = class {
195138
195278
  }
195139
195279
  return success2();
195140
195280
  }
195141
- async listAccountTransfers(request2) {
195142
- if (!this._financialController) {
195143
- return failure({
195144
- errorCode: "not_supported",
195145
- errorMessage: "This feature is not supported."
195146
- });
195147
- }
195148
- const accountDetailsResult = await this._financialController.getAccountDetails(
195149
- request2.accountId
195150
- );
195151
- if (isFailure(accountDetailsResult)) {
195152
- return accountDetailsResult;
195153
- }
195154
- const { account, financialAccount } = accountDetailsResult.value;
195155
- const authorizationResult = await this._checkAuthorizationForFilter(
195156
- financialAccount,
195157
- request2.userId,
195158
- request2.userRole
195159
- );
195160
- if (isFailure(authorizationResult)) {
195161
- return authorizationResult;
195162
- }
195163
- const transfersResult = await this._financialController.listTransfers(
195164
- request2.accountId
195165
- );
195166
- if (isFailure(transfersResult)) {
195167
- return transfersResult;
195168
- }
195169
- const transfers = transfersResult.value;
195170
- const accountTransfers = transfers.map(
195171
- (transfer) => ({
195172
- id: transfer.id.toString(),
195173
- amount: transfer.amount,
195174
- debitAccountId: transfer.debit_account_id.toString(),
195175
- creditAccountId: transfer.credit_account_id.toString(),
195176
- pending: (transfer.flags & (void 0).pending) !== 0,
195177
- code: transfer.code,
195178
- timeMs: Number(transfer.timestamp / 1000000n),
195179
- // Convert nanoseconds to milliseconds
195180
- transactionId: transfer.user_data_128 !== 0n ? transfer.user_data_128.toString() : void 0,
195181
- note: charactarizeTransfer(transfer)
195182
- })
195183
- );
195184
- return success2({
195185
- accountDetails: financialAccount,
195186
- account: this._financialController.convertToAccountBalance(account),
195187
- transfers: accountTransfers
195188
- });
195189
- }
195190
195281
  async listTransfers(request2) {
195191
195282
  if (!this._financialController) {
195192
195283
  return failure({
@@ -195209,45 +195300,19 @@ var SubscriptionController = class {
195209
195300
  if (isFailure(authorizationResult)) {
195210
195301
  return authorizationResult;
195211
195302
  }
195212
- const maxTimeMs = request2.maxTimeMs ?? Date.now();
195213
195303
  const transfersResult = await this._financialController.listTransfers(
195214
195304
  request2.accountId,
195215
195305
  {
195216
195306
  minTimeMs: request2.minTimeMs,
195217
- maxTimeMs,
195218
- limit: request2.limit ?? void 0
195307
+ maxTimeMs: request2.maxTimeMs,
195308
+ limit: request2.limit
195219
195309
  }
195220
195310
  );
195221
195311
  if (isFailure(transfersResult)) {
195222
195312
  return transfersResult;
195223
195313
  }
195224
195314
  const transfers = transfersResult.value;
195225
- const balanceHistoryResult = await this._financialController.listBalanceHistory(
195226
- request2.accountId,
195227
- {
195228
- minTimeMs: request2.minTimeMs,
195229
- maxTimeMs,
195230
- limit: request2.limit ?? void 0
195231
- }
195232
- );
195233
- if (isFailure(balanceHistoryResult)) {
195234
- return balanceHistoryResult;
195235
- }
195236
- const balanceByTimestamp = /* @__PURE__ */ new Map();
195237
- for (const balance of balanceHistoryResult.value) {
195238
- const accountAtTime = {
195239
- ...account,
195240
- credits_pending: balance.credits_pending,
195241
- credits_posted: balance.credits_posted,
195242
- debits_pending: balance.debits_pending,
195243
- debits_posted: balance.debits_posted,
195244
- timestamp: balance.timestamp
195245
- };
195246
- balanceByTimestamp.set(
195247
- balance.timestamp,
195248
- this._financialController.convertToAccountBalance(accountAtTime).freeCreditBalance().toString()
195249
- );
195250
- }
195315
+ const currentBalance = this._financialController.convertToAccountBalance(account).freeCreditBalance().toString();
195251
195316
  const resolvedPendingIds = /* @__PURE__ */ new Set();
195252
195317
  for (const t6 of transfers) {
195253
195318
  const isResolutionTransfer = (t6.flags & (void 0).post_pending_transfer) !== 0 || (t6.flags & (void 0).void_pending_transfer) !== 0;
@@ -195276,7 +195341,7 @@ var SubscriptionController = class {
195276
195341
  timeMs: Number(transfer.timestamp / 1000000n),
195277
195342
  pending,
195278
195343
  pendingTimeoutMs: pending ? transfer.timeout * 1e3 : null,
195279
- balance: balanceByTimestamp.get(transfer.timestamp) ?? null,
195344
+ balance: currentBalance,
195280
195345
  description: charactarizeTransfer(transfer)
195281
195346
  };
195282
195347
  })
@@ -195286,6 +195351,55 @@ var SubscriptionController = class {
195286
195351
  transfers: listedTransfers
195287
195352
  });
195288
195353
  }
195354
+ async listAccountTransfers(request2) {
195355
+ if (!this._financialController) {
195356
+ return failure({
195357
+ errorCode: "not_supported",
195358
+ errorMessage: "This feature is not supported."
195359
+ });
195360
+ }
195361
+ const accountDetailsResult = await this._financialController.getAccountDetails(
195362
+ request2.accountId
195363
+ );
195364
+ if (isFailure(accountDetailsResult)) {
195365
+ return accountDetailsResult;
195366
+ }
195367
+ const { account, financialAccount } = accountDetailsResult.value;
195368
+ const authorizationResult = await this._checkAuthorizationForFilter(
195369
+ financialAccount,
195370
+ request2.userId,
195371
+ request2.userRole
195372
+ );
195373
+ if (isFailure(authorizationResult)) {
195374
+ return authorizationResult;
195375
+ }
195376
+ const transfersResult = await this._financialController.listTransfers(
195377
+ request2.accountId
195378
+ );
195379
+ if (isFailure(transfersResult)) {
195380
+ return transfersResult;
195381
+ }
195382
+ const transfers = transfersResult.value;
195383
+ const accountTransfers = transfers.map(
195384
+ (transfer) => ({
195385
+ id: transfer.id.toString(),
195386
+ amount: transfer.amount,
195387
+ debitAccountId: transfer.debit_account_id.toString(),
195388
+ creditAccountId: transfer.credit_account_id.toString(),
195389
+ pending: (transfer.flags & (void 0).pending) !== 0,
195390
+ code: transfer.code,
195391
+ timeMs: Number(transfer.timestamp / 1000000n),
195392
+ // Convert nanoseconds to milliseconds
195393
+ transactionId: transfer.user_data_128 !== 0n ? transfer.user_data_128.toString() : void 0,
195394
+ note: charactarizeTransfer(transfer)
195395
+ })
195396
+ );
195397
+ return success2({
195398
+ accountDetails: financialAccount,
195399
+ account: this._financialController.convertToAccountBalance(account),
195400
+ transfers: accountTransfers
195401
+ });
195402
+ }
195289
195403
  async getAccountDescription(accountId) {
195290
195404
  if (typeof accountId === "string") {
195291
195405
  accountId = BigInt(accountId);
@@ -197333,7 +197447,7 @@ var SubscriptionController = class {
197333
197447
  const sessionResult = await wrap(
197334
197448
  () => this._stripe.createCheckoutSession({
197335
197449
  mode: "payment",
197336
- allow_promotion_codes: true,
197450
+ allow_promotion_codes: config3.checkoutConfig?.allow_promotion_codes ?? true,
197337
197451
  line_items: [
197338
197452
  {
197339
197453
  adjustable_quantity: {
@@ -198972,10 +199086,10 @@ __decorateClass([
198972
199086
  ], SubscriptionController.prototype, "getBalances", 1);
198973
199087
  __decorateClass([
198974
199088
  traced(TRACE_NAME14)
198975
- ], SubscriptionController.prototype, "listAccountTransfers", 1);
199089
+ ], SubscriptionController.prototype, "listTransfers", 1);
198976
199090
  __decorateClass([
198977
199091
  traced(TRACE_NAME14)
198978
- ], SubscriptionController.prototype, "listTransfers", 1);
199092
+ ], SubscriptionController.prototype, "listAccountTransfers", 1);
198979
199093
  __decorateClass([
198980
199094
  traced(TRACE_NAME14)
198981
199095
  ], SubscriptionController.prototype, "updateSubscription", 1);
@@ -272661,7 +272775,7 @@ var config2 = new Conf({
272661
272775
  projectName: "casualos-cli"
272662
272776
  });
272663
272777
  var program2 = new Command();
272664
- program2.name("casualos").description("A CLI for CasualOS").version("v4.2.6").option(
272778
+ program2.name("casualos").description("A CLI for CasualOS").version("v4.2.7-alpha.28599452017").option(
272665
272779
  "-e, --endpoint <url>",
272666
272780
  "The endpoint to use for queries. Can be used to override the current endpoint."
272667
272781
  ).option(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casualos",
3
- "version": "4.2.6",
3
+ "version": "4.2.7-alpha.28599452017",
4
4
  "description": "Command line interface for CasualOS.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@casual-simulation/aux-common": "^4.2.6",
32
- "@casual-simulation/aux-records": "^4.2.6",
33
- "@casual-simulation/aux-runtime": "^4.2.6",
34
- "@casual-simulation/aux-vm": "^4.2.6",
31
+ "@casual-simulation/aux-common": "^4.2.7-alpha.28599452017",
32
+ "@casual-simulation/aux-records": "^4.2.7-alpha.28599452017",
33
+ "@casual-simulation/aux-runtime": "^4.2.7-alpha.28599452017",
34
+ "@casual-simulation/aux-vm": "^4.2.7-alpha.28599452017",
35
35
  "@octokit/app": "^15.1.0",
36
36
  "@octokit/auth-oauth-device": "^7.1.1",
37
37
  "@octokit/core": "^6.1.2",