@casual-simulation/aux-runtime 4.2.3-alpha.24210455205 → 4.2.3-alpha.24685677737

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casual-simulation/aux-runtime",
3
- "version": "4.2.3-alpha.24210455205",
3
+ "version": "4.2.3-alpha.24685677737",
4
4
  "description": "Runtime for AUX projects",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "@casual-simulation/aux-common": "^4.2.3-alpha.24210455205",
29
- "@casual-simulation/aux-records": "^4.2.3-alpha.24210455205",
28
+ "@casual-simulation/aux-common": "^4.2.3-alpha.24685677737",
29
+ "@casual-simulation/aux-records": "^4.2.3-alpha.24685677737",
30
30
  "@casual-simulation/crypto": "^4.0.5",
31
31
  "@casual-simulation/engine262": "0.0.1-4de2170374e22761996e46eb1362f4496ee57f8f",
32
32
  "@casual-simulation/error-stack-parser": "^2.0.7",
@@ -58,7 +58,7 @@
58
58
  "seedrandom": "3.0.5",
59
59
  "stackframe": "^1.2.0",
60
60
  "three": "^0.182.0",
61
- "typesense": "2.0.3",
61
+ "typesense": "3.0.5",
62
62
  "uuid": "10.0.0",
63
63
  "yjs": "13.6.8"
64
64
  },
@@ -2,7 +2,7 @@ import type { AuxGlobalContext } from './AuxGlobalContext';
2
2
  import { DEBUG_STRING } from './AuxGlobalContext';
3
3
  import type { BotTags, Bot, ShowChatOptions, BotAction, BotsState, CameraType, BarcodeFormat, PortalType, ShowInputOptions, LocalFormAnimationAction, ShareOptions, Easing, BotAnchorPoint, RuntimeBot, BotSpace, EaseType, RegisterPrefixOptions, OpenCircleWipeOptions, SuperShoutAction, ShowToastAction, ShowJoinCodeAction, RequestFullscreenAction, ExitFullscreenAction, ShowHtmlAction, HideHtmlAction, SetClipboardAction, FocusOnBotAction, ShowChatBarAction, EnableARAction, EnableVRAction, DownloadAction, ShowUploadAuxFileAction, OpenQRCodeScannerAction, ShowQRCodeAction, OpenBarcodeScannerAction, ShowBarcodeAction, LoadServerAction, UnloadServerAction, ReplaceDragBotAction, ShowInputForTagAction, GoToDimensionAction, GoToURLAction, OpenURLAction, OpenConsoleAction, RejectAction, FocusOnOptions, SnapTarget, AddDropSnapTargetsAction, RecordingOptions, Recording, SyntheticVoice, EnablePOVAction, EnableCustomDraggingAction, SetAppOutputAction, PartialBotsState, ParsedBotLink, ConvertGeolocationToWhat3WordsOptions, BeginAudioRecordingAction, MediaPermssionOptions, ImageClassifierOptions, ClassifyImagesOptions, ClassifyImagesResult, AddDropGridTargetsAction, InstUpdate, StartFormAnimationOptions, StopFormAnimationOptions, FormAnimationData, WakeLockConfiguration, EnableXROptions, ShowConfirmOptions, ShowAlertOptions, StoredAux, Geolocation, OpenPhotoCameraOptions, Photo, Point2D, RecordLoomOptions, LoomVideo, LoomVideoEmbedMetadata, InstallAuxFileMode, LoadServerConfigAction, InstConfig, UnloadServerConfigAction, Point3D, MapLayer, DynamicListener, TrackConfigBotTagsAction, GenerateQRCodeOptions, ConfigureTypeCheckingOptions } from '@casual-simulation/aux-common/bots';
4
4
  import type { AIChatOptions, AIGenerateSkyboxOptions, AIGenerateImageOptions, JoinRoomActionOptions, RoomOptions, RoomTrackOptions, SetRoomTrackOptions, RoomRemoteOptions, DataRecordOptions, RecordActionOptions, ListDataOptions, AISloydGenerateModelOptions, ListWebhooksOptions, ListNotificationsOptions, SendNotificationOptions, GrantEntitlementsRequest, GrantEntitlementsResult, InstallPackageResult, ListPermissionsRequest, ListedChatModel, StoreItem, PurchasableItemReference, InstallPackageOptions, GetAccountBalancesActionOptions, AIListChatModelsOptions } from './RecordsEvents';
5
- import type { RemoteAction, AvailablePermissions, Entitlement, VersionNumber, GenericResult, SimpleError, JSONAccountBalance } from '@casual-simulation/aux-common';
5
+ import type { RemoteAction, AvailablePermissions, Entitlement, VersionNumber, GenericResult, SimpleError } from '@casual-simulation/aux-common';
6
6
  import '@casual-simulation/aux-common/polyfill/Array.first.polyfill';
7
7
  import '@casual-simulation/aux-common/polyfill/Array.last.polyfill';
8
8
  import { isAsymmetricKeypair, isAsymmetricEncrypted, isEncrypted } from '@casual-simulation/crypto';
@@ -11,7 +11,7 @@ import '@casual-simulation/aux-common/BlobPolyfill';
11
11
  import type { AuxDevice } from './AuxDevice';
12
12
  import type { AuxVersion } from './AuxVersion';
13
13
  import { Vector3, Vector2, Quaternion, Rotation } from '@casual-simulation/aux-common/math';
14
- import type { AIChatMessage, CreateRecordResult, GrantResourcePermissionResult, ListStudiosResult, ListRecordsResult, ListSubscriptionsResult, NotificationRecord, PushNotificationPayload, RevokePermissionResult, ListPermissionsResult, SendNotificationResult, SubscribeToNotificationResult, UnsubscribeToNotificationResult, WebhookRecord, CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult, GrantRoleResult, RevokeRoleResult, PackageRecord, ListInstalledPackagesResult, ListInstsResult, EraseInstResult, PurchasableItem, PayoutDestination, ContractPricing } from '@casual-simulation/aux-records';
14
+ import type { AIChatMessage, CreateRecordResult, GrantResourcePermissionResult, ListStudiosResult, ListRecordsResult, ListSubscriptionsResult, NotificationRecord, PushNotificationPayload, RevokePermissionResult, ListPermissionsResult, SendNotificationResult, SubscribeToNotificationResult, UnsubscribeToNotificationResult, WebhookRecord, CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult, GrantRoleResult, RevokeRoleResult, PackageRecord, ListInstalledPackagesResult, ListInstsResult, EraseInstResult, PurchasableItem, PayoutDestination, ContractPricing, JSONAccountBalancesAndSubscriptionInfo, PurchaseCreditsResult } from '@casual-simulation/aux-records';
15
15
  import { DateTime } from 'luxon';
16
16
  import * as hooks from 'preact/hooks';
17
17
  import { render, createRef, createContext } from 'preact';
@@ -47,6 +47,33 @@ export interface APIPurchaseContractRequest {
47
47
  returnUrl: string;
48
48
  successUrl: string;
49
49
  }
50
+ /**
51
+ * Defines an interface that represents the options for purchasing credits for an account.
52
+ *
53
+ * @dochash types/records/extra
54
+ * @docname PurchaseCreditsRequest
55
+ * @docid PurchaseCreditsRequest
56
+ */
57
+ export interface APIPurchaseCreditsRequest {
58
+ /**
59
+ * The ID of the user that the credits should be purchased for.
60
+ * Currently, credits can only be purchased for yourself.
61
+ */
62
+ targetUserId?: string;
63
+ /**
64
+ * The ID of the studio that the credits should be purchased for.
65
+ * Currently, only studio admins can purchase credits.
66
+ */
67
+ targetStudioId?: string;
68
+ /**
69
+ * The URL that the user should be sent to if they cancel the purchase.
70
+ */
71
+ returnUrl: string;
72
+ /**
73
+ * The URL that the user should be sent to if the purchase completes successfully.
74
+ */
75
+ successUrl: string;
76
+ }
50
77
  export interface APIInvoiceContractRequest {
51
78
  contractId: string;
52
79
  amount: number;
@@ -2879,7 +2906,8 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
2879
2906
  listInvoices: (contractId: string, options?: RecordActionOptions) => Promise<GenericResult<ContractInvoice[], SimpleError>>;
2880
2907
  payInvoice: (invoiceId: string, options?: RecordActionOptions) => Promise<GenericResult<void, SimpleError>>;
2881
2908
  payout: (request: APIPayoutRequest, options?: RecordActionOptions) => Promise<GenericResult<void, SimpleError>>;
2882
- getAccountBalances: (options?: GetAccountBalancesActionOptions) => Promise<GenericResult<JSONAccountBalance, SimpleError>>;
2909
+ getAccountBalances: (options?: GetAccountBalancesActionOptions) => Promise<GenericResult<JSONAccountBalancesAndSubscriptionInfo, SimpleError>>;
2910
+ purchaseCredits: (request: APIPurchaseCreditsRequest, options?: RecordActionOptions) => Promise<PurchaseCreditsResult>;
2883
2911
  };
2884
2912
  portal: {
2885
2913
  registerPrefix: (prefix: string, options?: RegisterPrefixOptions) => Promise<void>;
@@ -828,6 +828,7 @@ export function createDefaultLibrary(context) {
828
828
  payInvoice: xpPayInvoice,
829
829
  payout: xpPayout,
830
830
  getAccountBalances: xpGetAccountBalances,
831
+ purchaseCredits: xpPurchaseCredits,
831
832
  },
832
833
  portal: {
833
834
  registerPrefix,
@@ -5364,6 +5365,20 @@ export function createDefaultLibrary(context) {
5364
5365
  * @param options The options for the request.
5365
5366
  * @returns A promise that resolves with the account balances.
5366
5367
  *
5368
+ * @example Get the current user's account balances and log them to the console.
5369
+ * const balancesResult = await xp.getAccountBalances();
5370
+ * console.log(balancesResult);
5371
+ *
5372
+ * @example Get the account balances for a studio
5373
+ * const balances = await xp.getAccountBalances({
5374
+ * studioId: "myStudioId"
5375
+ * });
5376
+ *
5377
+ * @example Get the account balances for a contract
5378
+ * const balances = await xp.getAccountBalances({
5379
+ * contractId: "myContractId"
5380
+ * });
5381
+ *
5367
5382
  * @dochash actions/xp
5368
5383
  * @docname xp.getAccountBalances
5369
5384
  */
@@ -5381,6 +5396,53 @@ export function createDefaultLibrary(context) {
5381
5396
  }, rest, task.taskId);
5382
5397
  return addAsyncAction(task, event);
5383
5398
  }
5399
+ /**
5400
+ * Creates a new checkout session that can be used to purchase credits for an account. Returns a promise which resolves with the URL that the user should be redirected to in order to complete the purchase.
5401
+ *
5402
+ * @param options The options for the request.
5403
+ * @returns A promise that resolves with the account balances.
5404
+ *
5405
+ * @example Purchase credits for the current user.
5406
+ * const purchaseResult = await xp.purchaseCredits({
5407
+ * targetUserId: authBot.id,
5408
+ * returnUrl: configBot.tags.url,
5409
+ * successUrl: configBot.tags.url
5410
+ * });
5411
+ * if (purchaseResult.success) {
5412
+ * os.goToURL(purchaseResult.url);
5413
+ * } else {
5414
+ * os.toast("Failed to create checkout session")
5415
+ * }
5416
+ *
5417
+ * @example Purchase credits for a studio.
5418
+ * const purchaseResult = await xp.purchaseCredits({
5419
+ * targetUserId: "studioId",
5420
+ * returnUrl: configBot.tags.url,
5421
+ * successUrl: configBot.tags.url
5422
+ * });
5423
+ * if (purchaseResult.success) {
5424
+ * os.goToURL(purchaseResult.url);
5425
+ * } else {
5426
+ * os.toast("Failed to create checkout session")
5427
+ * }
5428
+ *
5429
+ * @dochash actions/xp
5430
+ * @docname xp.purchaseCredits
5431
+ */
5432
+ function xpPurchaseCredits(request, options = {}) {
5433
+ const task = context.createTask();
5434
+ const event = recordsCallProcedure({
5435
+ purchaseCredits: {
5436
+ input: {
5437
+ targetUserId: request.targetUserId,
5438
+ targetStudioId: request.targetStudioId,
5439
+ returnUrl: request.returnUrl,
5440
+ successUrl: request.successUrl,
5441
+ },
5442
+ },
5443
+ }, options, task.taskId);
5444
+ return addAsyncAction(task, event);
5445
+ }
5384
5446
  /**
5385
5447
  * Specifies that the given prefix should be used to indicate that the tag contains script content.
5386
5448
  * Use this function to specify custom prefixes that function similarly to `@` or `🧬`.