@byte-42/fantastico-sdk 0.21.0 → 0.22.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.
package/README.md CHANGED
@@ -468,3 +468,17 @@ remint on `401`/`402`; a plain `Error` is treated as an error and nothing more.
468
468
  ## Licence
469
469
 
470
470
  MIT — Byte42 S.r.l. See [LICENSE](LICENSE).
471
+
472
+ ### Displaying account credit
473
+
474
+ For account keys (`ck-fant-…`), `await ai.balance()` returns `remainingUsd` (free to commit to new
475
+ runtime keys). An updated Cloud also returns `reservedUnspentUsd` (unspent reservations across all
476
+ open keys, priced for the customer) and `totalRemainingUsd` (their sum). Display `totalRemainingUsd`
477
+ as residual credit and use `lowTotalBalance` for its recharge warning. Existing `remainingUsd` and
478
+ `lowBalance` keep their availability semantics; they must not be interpreted as spending.
479
+
480
+ A $10 account with a $5 reservation that has consumed $0.03 therefore shows $9.97 residual credit,
481
+ not $5.00. Open-key spending is measured so far and can change until reconciliation. No additional
482
+ provider call or money movement is performed by this read. The new fields are optional in the SDK
483
+ so it can still talk to older Cloud versions; when absent, do not invent a total by adding a locally
484
+ cached key's reservation.
package/dist/types.d.ts CHANGED
@@ -623,7 +623,15 @@ export interface RuntimeKeyHandle {
623
623
  * conto è a secco; questo serve a dire "stai per finire" prima che succeda.
624
624
  */
625
625
  export interface ContoBalance {
626
+ /** Free to commit to NEW runtime keys. Does not include unspent reservations. Unchanged. */
626
627
  remainingUsd: number;
628
+ /** Unspent reservations across all open keys, at the customer's price. Requires updated Cloud. */
629
+ reservedUnspentUsd?: number;
630
+ /** remainingUsd + reservedUnspentUsd. Use for a credit indicator, NOT to authorize spending.
631
+ * Based on measured usage so far; open-key costs remain provisional until reconciliation. */
632
+ totalRemainingUsd?: number;
633
+ /** Warning based on totalRemainingUsd. Optional for compatibility with older Cloud versions. */
634
+ lowTotalBalance?: boolean;
627
635
  lowBalance: boolean;
628
636
  status: string;
629
637
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byte-42/fantastico-sdk",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"