@nehorai/credits 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -369,6 +369,7 @@ interface CreditBalanceUpdate {
369
369
  balance?: number;
370
370
  bonusCredits?: number;
371
371
  reserved?: number;
372
+ /** Writes no journal line. To change a tier, use `updateUserTier`. */
372
373
  tier?: SubscriptionTier;
373
374
  monthlyLimit?: number;
374
375
  monthlyUsed?: number;
@@ -461,7 +462,9 @@ interface ICreditRepository extends Partial<ICreditRepositoryV2>, Partial<ICredi
461
462
  */
462
463
  getUserCredits(userId: string): Promise<PortableUserCredits | null>;
463
464
  /**
464
- * Initialize credits for a new user
465
+ * Initialize credits for a new user. Creating an account with a balance above 0
466
+ * writes its journal line (`signupGrantJournalInput`) in the same atomic step, and
467
+ * a call that finds the account writes nothing.
465
468
  * @param userId - User ID
466
469
  * @param tier - Initial subscription tier
467
470
  * @param initialBalance - Initial credit balance
@@ -469,13 +472,16 @@ interface ICreditRepository extends Partial<ICreditRepositoryV2>, Partial<ICredi
469
472
  */
470
473
  initializeUserCredits(userId: string, tier: SubscriptionTier, initialBalance: number): Promise<PortableUserCredits>;
471
474
  /**
472
- * Update user credits balance
475
+ * Patch fields of the account. This writes no journal line, whatever it changes.
476
+ * A tier change goes through `updateUserTier`, which journals a balance it moves.
473
477
  * @param userId - User ID
474
478
  * @param updates - Partial updates to apply
475
479
  */
476
480
  updateUserCredits(userId: string, updates: CreditBalanceUpdate): Promise<void>;
477
481
  /**
478
- * Update user subscription tier
482
+ * Update user subscription tier. A write that moves the balance writes one journal
483
+ * line (`tierChangeJournalInput`) in the same atomic step, and one that does not
484
+ * writes none.
479
485
  * @param userId - User ID
480
486
  * @param input - Tier update data
481
487
  */
@@ -369,6 +369,7 @@ interface CreditBalanceUpdate {
369
369
  balance?: number;
370
370
  bonusCredits?: number;
371
371
  reserved?: number;
372
+ /** Writes no journal line. To change a tier, use `updateUserTier`. */
372
373
  tier?: SubscriptionTier;
373
374
  monthlyLimit?: number;
374
375
  monthlyUsed?: number;
@@ -461,7 +462,9 @@ interface ICreditRepository extends Partial<ICreditRepositoryV2>, Partial<ICredi
461
462
  */
462
463
  getUserCredits(userId: string): Promise<PortableUserCredits | null>;
463
464
  /**
464
- * Initialize credits for a new user
465
+ * Initialize credits for a new user. Creating an account with a balance above 0
466
+ * writes its journal line (`signupGrantJournalInput`) in the same atomic step, and
467
+ * a call that finds the account writes nothing.
465
468
  * @param userId - User ID
466
469
  * @param tier - Initial subscription tier
467
470
  * @param initialBalance - Initial credit balance
@@ -469,13 +472,16 @@ interface ICreditRepository extends Partial<ICreditRepositoryV2>, Partial<ICredi
469
472
  */
470
473
  initializeUserCredits(userId: string, tier: SubscriptionTier, initialBalance: number): Promise<PortableUserCredits>;
471
474
  /**
472
- * Update user credits balance
475
+ * Patch fields of the account. This writes no journal line, whatever it changes.
476
+ * A tier change goes through `updateUserTier`, which journals a balance it moves.
473
477
  * @param userId - User ID
474
478
  * @param updates - Partial updates to apply
475
479
  */
476
480
  updateUserCredits(userId: string, updates: CreditBalanceUpdate): Promise<void>;
477
481
  /**
478
- * Update user subscription tier
482
+ * Update user subscription tier. A write that moves the balance writes one journal
483
+ * line (`tierChangeJournalInput`) in the same atomic step, and one that does not
484
+ * writes none.
479
485
  * @param userId - User ID
480
486
  * @param input - Tier update data
481
487
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nehorai/credits",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",