@casual-simulation/aux-runtime 4.2.6 → 4.2.7-alpha.28681314276

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.
@@ -19626,6 +19626,108 @@ export type PurchaseCreditsResult = GenericResult<
19626
19626
  SimpleError
19627
19627
  >;
19628
19628
 
19629
+ /**
19630
+ * Defines an interface that represents a budget that has been configured for a record.
19631
+ *
19632
+ * @dochash types/records/extra
19633
+ * @docname RecordCreditBudget
19634
+ * @docid RecordCreditBudget
19635
+ */
19636
+ export interface RecordCreditBudget {
19637
+ /**
19638
+ * The type of the budget.
19639
+ * - "fixed" means that a set number of credits will be transferred to the record from the owner's account upon a subscription credit grant.
19640
+ * - "percent" means that the record will be granted a percentage of the total amount that the owner's account receives upon a subscription credit grant.
19641
+ */
19642
+ type: 'fixed' | 'percent';
19643
+
19644
+ /**
19645
+ * The budget amount. A bigint value represented as a string.
19646
+ */
19647
+ amount: string;
19648
+ }
19649
+
19650
+ /**
19651
+ * Defines an interface that represents the options for setting a record's budget.
19652
+ *
19653
+ * @dochash types/records/extra
19654
+ * @docname SetRecordBudgetRequest
19655
+ * @docid SetRecordBudgetRequest
19656
+ */
19657
+ export interface APISetRecordBudgetRequest {
19658
+ /**
19659
+ * The name of the record that the budget should be set for.
19660
+ */
19661
+ recordName: string;
19662
+
19663
+ /**
19664
+ * The budget that should be set for the record.
19665
+ * Setting this value to null will clear the budget, causing billing for the record to go to the owner's account.
19666
+ */
19667
+ budget: {
19668
+ /**
19669
+ * The type of the budget.
19670
+ * - "fixed" means that a set number of credits will be transferred to the record from the owner's account upon a subscription credit grant.
19671
+ * - "percent" means that the record will be granted a percentage of the total amount that the owner's account receives upon a subscription credit grant.
19672
+ */
19673
+ type: 'fixed' | 'percent';
19674
+
19675
+ /**
19676
+ * The budget amount. Can be a string containing a bigint value. Must be an integer.
19677
+ * Must be between 0 and 100 if type is "percent".
19678
+ */
19679
+ amount: number | string;
19680
+ } | null;
19681
+ }
19682
+
19683
+ /**
19684
+ * Defines an interface that represents the result of a request to set a record's budget.
19685
+ *
19686
+ * @dochash types/records/extra
19687
+ * @docname SetRecordBudgetResult
19688
+ * @docid SetRecordBudgetResult
19689
+ */
19690
+ export type SetRecordBudgetResult =
19691
+ | SetRecordBudgetSuccess
19692
+ | SetRecordBudgetFailure;
19693
+
19694
+ export interface SetRecordBudgetSuccess {
19695
+ success: true;
19696
+ }
19697
+
19698
+ export interface SetRecordBudgetFailure {
19699
+ success: false;
19700
+ errorCode: KnownErrorCodes;
19701
+ errorMessage: string;
19702
+ }
19703
+
19704
+ /**
19705
+ * Defines an interface that represents the result of a request to get a record's budget.
19706
+ *
19707
+ * @dochash types/records/extra
19708
+ * @docname GetRecordBudgetResult
19709
+ * @docid GetRecordBudgetResult
19710
+ */
19711
+ export type GetRecordBudgetResult =
19712
+ | GetRecordBudgetSuccess
19713
+ | GetRecordBudgetFailure;
19714
+
19715
+ export interface GetRecordBudgetSuccess {
19716
+ success: true;
19717
+
19718
+ /**
19719
+ * The budget that is configured for the record.
19720
+ * Null if no budget is configured (billing for the record goes to the owner's account).
19721
+ */
19722
+ budget: RecordCreditBudget | null;
19723
+ }
19724
+
19725
+ export interface GetRecordBudgetFailure {
19726
+ success: false;
19727
+ errorCode: KnownErrorCodes;
19728
+ errorMessage: string;
19729
+ }
19730
+
19629
19731
  /**
19630
19732
  * The destination for the payout of an invoice.
19631
19733
  * - "stripe" means that the invoiced amount will be transfered to the users Stripe account once paid.
@@ -19983,6 +20085,65 @@ interface Xp {
19983
20085
  request: APIPurchaseCreditsRequest,
19984
20086
  options?: RecordActionOptions
19985
20087
  ): Promise<PurchaseCreditsResult>;
20088
+
20089
+ /**
20090
+ * Sets the budget that should be used to automatically transfer credits from a record's owner to the record's own credit account whenever the owner is granted credits from their subscription.
20091
+ * Setting the budget to null clears it, causing billing for the record to go to the owner's account.
20092
+ * Only studio admins and superUsers are authorized to set a record's budget.
20093
+ *
20094
+ * @param request The options for the request.
20095
+ * @returns A promise that resolves with the result of the request.
20096
+ *
20097
+ * @example Set a fixed record budget
20098
+ * const result = await xp.setRecordBudget({
20099
+ * recordName: "myRecord",
20100
+ * budget: {
20101
+ * type: "fixed",
20102
+ * amount: 100
20103
+ * }
20104
+ * });
20105
+ *
20106
+ * @example Set a percent record budget
20107
+ * const result = await xp.setRecordBudget({
20108
+ * recordName: "myRecord",
20109
+ * budget: {
20110
+ * type: "percent",
20111
+ * amount: 10
20112
+ * }
20113
+ * });
20114
+ *
20115
+ * @example Clear a record budget
20116
+ * const result = await xp.setRecordBudget({
20117
+ * recordName: "myRecord",
20118
+ * budget: null
20119
+ * });
20120
+ *
20121
+ * @dochash actions/xp
20122
+ * @docname xp.setRecordBudget
20123
+ */
20124
+ setRecordBudget(
20125
+ request: APISetRecordBudgetRequest,
20126
+ options?: RecordActionOptions
20127
+ ): Promise<SetRecordBudgetResult>;
20128
+
20129
+ /**
20130
+ * Gets the budget that has been configured for the given record.
20131
+ *
20132
+ * @param recordName The name of the record to get the budget for.
20133
+ * @param options The options for the request.
20134
+ * @returns A promise that resolves with the result of the request.
20135
+ *
20136
+ * @example Get a record's budget
20137
+ * const result = await xp.getRecordBudget("myRecord");
20138
+ * console.log(result);
20139
+ *
20140
+ * @dochash actions/xp
20141
+ * @docname xp.getRecordBudget
20142
+ */
20143
+ getRecordBudget(
20144
+ recordName: string,
20145
+ options?: RecordActionOptions
20146
+ ): Promise<GetRecordBudgetResult>;
19986
20147
  }
19987
20148
 
19988
20149
  interface Perf {