@casual-simulation/aux-runtime 3.7.2-alpha.18014719607 → 3.8.0-alpha.18204122333
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 +4 -4
- package/runtime/AuxLibrary.d.ts +4 -2
- package/runtime/AuxLibrary.js +72 -1
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +73 -0
- package/runtime/RecordsEvents.d.ts +27 -0
- package/runtime/RecordsEvents.js +13 -0
- package/runtime/RecordsEvents.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casual-simulation/aux-runtime",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0-alpha.18204122333",
|
|
4
4
|
"description": "Runtime for AUX projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@casual-simulation/aux-common": "^3.
|
|
36
|
-
"@casual-simulation/aux-records": "^3.
|
|
35
|
+
"@casual-simulation/aux-common": "^3.8.0-alpha.18204122333",
|
|
36
|
+
"@casual-simulation/aux-records": "^3.8.0-alpha.18204122333",
|
|
37
37
|
"@casual-simulation/crypto": "^3.5.0",
|
|
38
38
|
"@casual-simulation/engine262": "0.0.1-4de2170374e22761996e46eb1362f4496ee57f8f",
|
|
39
39
|
"@casual-simulation/error-stack-parser": "^2.0.7",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"**/*.d.ts",
|
|
84
84
|
"**/*.def"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "61916dc671764c173e2e371073f08df6985b866f"
|
|
87
87
|
}
|
package/runtime/AuxLibrary.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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, StoredAux, Geolocation, OpenPhotoCameraOptions, Photo, Point2D, RecordLoomOptions, LoomVideo, LoomVideoEmbedMetadata, InstallAuxFileMode, LoadServerConfigAction, InstConfig, UnloadServerConfigAction, Point3D, MapLayer, DynamicListener } from '@casual-simulation/aux-common/bots';
|
|
4
|
-
import type { AIChatOptions, AIGenerateSkyboxOptions, AIGenerateImageOptions, JoinRoomActionOptions, RoomOptions, RoomTrackOptions, SetRoomTrackOptions, RoomRemoteOptions, DataRecordOptions, RecordActionOptions, ListDataOptions, AISloydGenerateModelOptions, ListWebhooksOptions, ListNotificationsOptions, SendNotificationOptions, GrantEntitlementsRequest, GrantEntitlementsResult, InstallPackageResult, ListPermissionsRequest } from './RecordsEvents';
|
|
4
|
+
import type { AIChatOptions, AIGenerateSkyboxOptions, AIGenerateImageOptions, JoinRoomActionOptions, RoomOptions, RoomTrackOptions, SetRoomTrackOptions, RoomRemoteOptions, DataRecordOptions, RecordActionOptions, ListDataOptions, AISloydGenerateModelOptions, ListWebhooksOptions, ListNotificationsOptions, SendNotificationOptions, GrantEntitlementsRequest, GrantEntitlementsResult, InstallPackageResult, ListPermissionsRequest, ListedChatModel } from './RecordsEvents';
|
|
5
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';
|
|
@@ -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 } 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 } 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';
|
|
@@ -2326,6 +2326,7 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2326
2326
|
(message: AIChatMessage, options?: AIChatOptions): Promise<AIChatMessage>;
|
|
2327
2327
|
(messages: AIChatMessage[], options?: AIChatOptions): Promise<AIChatMessage>;
|
|
2328
2328
|
};
|
|
2329
|
+
listChatModels: (options?: RecordActionOptions) => Promise<ListedChatModel[]>;
|
|
2329
2330
|
generateSkybox: {
|
|
2330
2331
|
(prompt: string, negativePrompt?: string, options?: AIGenerateSkyboxOptions): Promise<string>;
|
|
2331
2332
|
(request: AIGenerateSkyboxRequest): Promise<AIGenerateSkyboxResult>;
|
|
@@ -2686,6 +2687,7 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2686
2687
|
eraseManualApprovalData: (recordKeyOrName: string, address: string, endpoint?: string) => Promise<EraseDataResult>;
|
|
2687
2688
|
listInsts: (recordName: string, startingInst?: string | null, endpoint?: string | null) => Promise<ListInstsResult>;
|
|
2688
2689
|
listInstsByMarker: (recordName: string, marker: string, startingInst?: string | null, options?: RecordActionOptions) => Promise<ListInstsResult>;
|
|
2690
|
+
eraseInst: (recordKeyOrName: string, instName: string, options?: RecordActionOptions) => Promise<EraseInstResult>;
|
|
2689
2691
|
recordWebhook: (recordName: string, webhook: WebhookRecord, options?: RecordActionOptions) => Promise<CrudRecordItemResult>;
|
|
2690
2692
|
runWebhook: (recordName: string, address: string, input: any, options?: RecordActionOptions) => Promise<HandleWebhookResult>;
|
|
2691
2693
|
getWebhook: (recordName: string, address: string, options?: RecordActionOptions) => Promise<CrudGetItemResult<WebhookRecord>>;
|
package/runtime/AuxLibrary.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEBUG_STRING, debugStringifyFunction } from './AuxGlobalContext';
|
|
2
2
|
import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, getScriptIssues as scriptIssues, tip as tipMessage, hideTips as hideTipMessages, showJoinCode as calcShowJoinCode, requestFullscreen, exitFullscreen, html as htmlMessage, hideHtml as hideHtmlMessage, setClipboard as calcSetClipboard, tweenTo as calcTweenTo, showChat as calcShowChat, hideChat as calcHideChat, runScript, getMediaPermission as calcGetMediaPermission, getAverageFrameRate as calcGetAverageFrameRate, enableAR as calcEnableAR, disableAR as calcDisableAR, enableVR as calcEnableVR, disableVR as calcDisableVR, arSupported as calcARSupported, vrSupported as calcVRSupported, showUploadAuxFile as calcShowUploadAuxFile, openQRCodeScanner as calcOpenQRCodeScanner, showQRCode as calcShowQRCode, openBarcodeScanner as calcOpenBarcodeScanner, showBarcode as calcShowBarcode, importAUX as calcImportAUX, showInputForTag as calcShowInputForTag, showInput as calcShowInput, showConfirm as calcShowConfirm, replaceDragBot as calcReplaceDragBot, goToDimension as calcGoToDimension, goToURL as calcGoToURL, openURL as calcOpenURL, playSound as calcPlaySound, bufferSound as calcBufferSound, cancelSound as calcCancelSound, shell as calcShell, reject as calcReject, localFormAnimation as calcLocalFormAnimation, webhook as calcWebhook, superShout as calcSuperShout, share as calcShare, registerPrefix as calcRegisterPrefix, localPositionTween as calcLocalPositionTween, localRotationTween as calcLocalRotationTween, showUploadFiles as calcShowUploadFiles, download, loadSimulation, unloadSimulation, getUploadState, addState, getPortalTag, KNOWN_PORTALS, openConsole, tagsOnBot, getOriginalObject, getBotSpace, trimEvent, CREATE_ACTION_NAME, CREATE_ANY_ACTION_NAME, DESTROY_ACTION_NAME, ORIGINAL_OBJECT, getRemoteCount, getRemotes, listInstUpdates as calcListInstUpdates, getInstStateFromUpdates as calcGetInstStateFromUpdates, action, calculateAnchorPoint, calculateAnchorPointOffset, getBotPosition as calcGetBotPosition, getBotRotation as calcGetBotRotation, isRuntimeBot, SET_TAG_MASK_SYMBOL, CLEAR_TAG_MASKS_SYMBOL, getBotScale, EDIT_TAG_SYMBOL, EDIT_TAG_MASK_SYMBOL, circleWipe, addDropSnap as calcAddDropSnap, addDropGrid as calcAddDropGrid, animateToPosition, beginAudioRecording as calcBeginAudioRecording, endAudioRecording as calcEndAudioRecording, beginRecording as calcBeginRecording, endRecording as calcEndRecording, speakText as calcSpeakText, getVoices as calcGetVoices, getGeolocation as calcGetGeolocation, cancelAnimation, disablePOV, enablePOV, enableCustomDragging as calcEnableCustomDragging, MINI_PORTAL, registerCustomApp, setAppOutput, unregisterCustomApp, requestAuthData as calcRequestAuthData, createBot, defineGlobalBot as calcDefineGlobalBot, TEMPORARY_BOT_PARTITION_ID, convertToString, GET_TAG_MASKS_SYMBOL, isBotLink, parseBotLink, createBotLink, convertGeolocationToWhat3Words as calcConvertGeolocationToWhat3Words, meetCommand as calcMeetCommand, meetFunction as calcMeetFunction, openImageClassifier as calcOpenImageClassifier, classifyImages as calcOpenClassifyImages, isBotDate, DATE_TAG_PREFIX, parseBotDate, realNumberOrDefault, raycastFromCamera as calcRaycastFromCamera, raycastInPortal as calcRaycastInPortal, calculateRayFromCamera as calcCalculateRayFromCamera, bufferFormAddressGltf, startFormAnimation as calcStartFormAnimation, stopFormAnimation as calcStopFormAnimation, listFormAnimations as calcListFormAnimations, calculateStringTagValue, createInitializationUpdate as calcCreateInitalizationUpdate, applyUpdatesToInst as calcApplyUpdatesToInst, configureWakeLock, getWakeLockConfiguration as calcGetWakeLockConfiguration, analyticsRecordEvent as calcAnalyticsRecordEvent, KNOWN_TAGS, isStoredVersion2, getCurrentInstUpdate as calcGetCurrentInstUpdate, openPhotoCamera as calcOpenPhotoCamera, getEasing, enableCollaboration as calcEnableCollaboration, showAccountInfo as calcShowAccountInfo, reportInst as calcReportInst, getRecordsEndpoint as calcGetRecordsEndpoint, ldrawCountAddressBuildSteps as calcLdrawCountAddressBuildSteps, ldrawCountTextBuildSteps as calcLdrawCountTextBuildSteps, calculateViewportCoordinatesFromPosition as calcCalculateViewportCoordinatesFromPosition, calculateScreenCoordinatesFromViewportCoordinates as calcCalculateScreenCoordinatesFromViewportCoordinates, calculateViewportCoordinatesFromScreenCoordinates as calcCalculateViewportCoordinatesFromScreenCoordinates, capturePortalScreenshot as calcCapturePortalScreenshot, createStaticHtml as calcCreateStaticHtmlFromBots, recordLoom, watchLoom, getLoomMetadata, loadSharedDocument, installAuxFile as calcInstallAuxFile, calculateStringListTagValue, calculateScreenCoordinatesFromPosition as calcCalculateScreenCoordinatesFromPosition, addMapLayer as calcAddMapLayer, removeMapLayer as calcRemoveMapLayer, GET_DYNAMIC_LISTENERS_SYMBOL, ADD_BOT_LISTENER_SYMBOL, REMOVE_BOT_LISTENER_SYMBOL, } from '@casual-simulation/aux-common/bots';
|
|
3
|
-
import { aiChat, aiChatStream, aiGenerateSkybox, aiGenerateImage, grantRecordPermission as calcGrantRecordPermission, revokeRecordPermission as calcRevokeRecordPermission, listPermissions as calcListPermissions, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, listUserStudios as calcListUserStudios, listStudioRecords as calcListStudioRecords, joinRoom as calcJoinRoom, leaveRoom as calcLeaveRoom, setRoomOptions as calcSetRoomOptions, getRoomOptions as calcGetRoomOptions, getRoomTrackOptions as calcGetRoomTrackOptions, setRoomTrackOptions as calcSetRoomTrackOptions, getRoomRemoteOptions as calcGetRoomRemoteOptions, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, getFile as calcGetFile, eraseFile as calcEraseFile, getPublicRecordKey as calcGetPublicRecordKey, recordData as calcRecordData, getRecordData, eraseRecordData, recordFile as calcRecordFile, listDataRecordByMarker, aiHumeGetAccessToken, aiSloydGenerateModel, recordWebhook as calcRecordWebhook, getWebhook as calcGetWebhook, listWebhooks as calcListWebhooks, listWebhooksByMarker as calcListWebhooksByMarker, eraseWebhook as calcEraseWebhook, runWebhook as calcRunWebhook, recordNotification as calcRecordNotification, getNotification as calcGetNotification, listNotifications as calcListNotifications, listNotificationsByMarker as calcListNotificationsByMarker, eraseNotification as calcEraseNotification, subscribeToNotification as calcSubscribeToNotification, unsubscribeFromNotification as calcUnsubscribeFromNotification, sendNotification as calcSendNotification, listNotificationSubscriptions as calcListNotificationSubscriptions, listUserNotificationSubscriptions as calcListUserNotificationSubscriptions, aiOpenAICreateRealtimeSession, grantEntitlements as calcGrantEntitlements, recordPackageVersion as calcRecordPackageVersion, erasePackageVersion as calcErasePackageVersion, listPackageVersions as calcListPackageVersions, getPackageVersion as calcGetPackageVersion, recordPackageContainer as calcRecordPackageContainer, erasePackageContaienr as calcErasePackageContainer, listPackageContainers as calcListPackageContainers, listPackageContainersByMarker as calcListPackageContainersByMarker, getPackageContainer as calcGetPackageContainer, installPackage as calcInstallPackage, listInstalledPackages as calcListInstalledPackages, listInsts as calcListInsts, listInstsByMarker as calcListInstsByMarker, recordsCallProcedure, } from './RecordsEvents';
|
|
3
|
+
import { aiChat, aiChatStream, aiListChatModels, aiGenerateSkybox, aiGenerateImage, grantRecordPermission as calcGrantRecordPermission, revokeRecordPermission as calcRevokeRecordPermission, listPermissions as calcListPermissions, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, listUserStudios as calcListUserStudios, listStudioRecords as calcListStudioRecords, joinRoom as calcJoinRoom, leaveRoom as calcLeaveRoom, setRoomOptions as calcSetRoomOptions, getRoomOptions as calcGetRoomOptions, getRoomTrackOptions as calcGetRoomTrackOptions, setRoomTrackOptions as calcSetRoomTrackOptions, getRoomRemoteOptions as calcGetRoomRemoteOptions, listDataRecord, recordEvent as calcRecordEvent, getEventCount as calcGetEventCount, getFile as calcGetFile, eraseFile as calcEraseFile, getPublicRecordKey as calcGetPublicRecordKey, recordData as calcRecordData, getRecordData, eraseRecordData, recordFile as calcRecordFile, listDataRecordByMarker, aiHumeGetAccessToken, aiSloydGenerateModel, recordWebhook as calcRecordWebhook, getWebhook as calcGetWebhook, listWebhooks as calcListWebhooks, listWebhooksByMarker as calcListWebhooksByMarker, eraseWebhook as calcEraseWebhook, runWebhook as calcRunWebhook, recordNotification as calcRecordNotification, getNotification as calcGetNotification, listNotifications as calcListNotifications, listNotificationsByMarker as calcListNotificationsByMarker, eraseNotification as calcEraseNotification, subscribeToNotification as calcSubscribeToNotification, unsubscribeFromNotification as calcUnsubscribeFromNotification, sendNotification as calcSendNotification, listNotificationSubscriptions as calcListNotificationSubscriptions, listUserNotificationSubscriptions as calcListUserNotificationSubscriptions, aiOpenAICreateRealtimeSession, grantEntitlements as calcGrantEntitlements, recordPackageVersion as calcRecordPackageVersion, erasePackageVersion as calcErasePackageVersion, listPackageVersions as calcListPackageVersions, getPackageVersion as calcGetPackageVersion, recordPackageContainer as calcRecordPackageContainer, erasePackageContaienr as calcErasePackageContainer, listPackageContainers as calcListPackageContainers, listPackageContainersByMarker as calcListPackageContainersByMarker, getPackageContainer as calcGetPackageContainer, installPackage as calcInstallPackage, listInstalledPackages as calcListInstalledPackages, listInsts as calcListInsts, listInstsByMarker as calcListInstsByMarker, recordsCallProcedure, } from './RecordsEvents';
|
|
4
4
|
import { sortBy, cloneDeep, union, isEqual } from 'es-toolkit/compat';
|
|
5
5
|
import { remote as calcRemote, DEFAULT_BRANCH_NAME, formatVersionNumber, parseVersionNumber, PRIVATE_MARKER, } from '@casual-simulation/aux-common';
|
|
6
6
|
import { RanOutOfEnergyError } from './AuxResults';
|
|
@@ -504,6 +504,7 @@ export function createDefaultLibrary(context) {
|
|
|
504
504
|
},
|
|
505
505
|
ai: {
|
|
506
506
|
chat,
|
|
507
|
+
listChatModels,
|
|
507
508
|
generateSkybox,
|
|
508
509
|
generateImage,
|
|
509
510
|
hume: {
|
|
@@ -757,6 +758,7 @@ export function createDefaultLibrary(context) {
|
|
|
757
758
|
eraseManualApprovalData,
|
|
758
759
|
listInsts,
|
|
759
760
|
listInstsByMarker,
|
|
761
|
+
eraseInst,
|
|
760
762
|
recordWebhook,
|
|
761
763
|
runWebhook,
|
|
762
764
|
getWebhook,
|
|
@@ -2176,6 +2178,25 @@ export function createDefaultLibrary(context) {
|
|
|
2176
2178
|
promise[ORIGINAL_OBJECT] = action;
|
|
2177
2179
|
return promise;
|
|
2178
2180
|
}
|
|
2181
|
+
/**
|
|
2182
|
+
* Lists the available chat models that the user can use.
|
|
2183
|
+
* Returns a promise that resolves with an array of available chat models.
|
|
2184
|
+
* Throws a {@link CasualOSError} if an error occurs.
|
|
2185
|
+
*
|
|
2186
|
+
* @example List available chat models
|
|
2187
|
+
* const models = await ai.listChatModels();
|
|
2188
|
+
* console.log(models);
|
|
2189
|
+
*
|
|
2190
|
+
* @dochash actions/ai
|
|
2191
|
+
* @docname ai.listChatModels
|
|
2192
|
+
*/
|
|
2193
|
+
function listChatModels(options) {
|
|
2194
|
+
const task = context.createTask();
|
|
2195
|
+
const action = aiListChatModels(options, task.taskId);
|
|
2196
|
+
const final = addAsyncResultAction(task, action).then((result) => result.items);
|
|
2197
|
+
final[ORIGINAL_OBJECT] = action;
|
|
2198
|
+
return final;
|
|
2199
|
+
}
|
|
2179
2200
|
/**
|
|
2180
2201
|
* Generates a [skybox image](https://en.wikipedia.org/wiki/Skybox_%28video_games%29) from the given request object.
|
|
2181
2202
|
*
|
|
@@ -5923,6 +5944,56 @@ export function createDefaultLibrary(context) {
|
|
|
5923
5944
|
const event = calcListInstsByMarker(recordName, marker, startingInst, options, task.taskId);
|
|
5924
5945
|
return addAsyncAction(task, event);
|
|
5925
5946
|
}
|
|
5947
|
+
/**
|
|
5948
|
+
* Erases the inst with the given name from the given record.
|
|
5949
|
+
* Returns a promise that resolves with an object that indicates if the operation was successful or not.
|
|
5950
|
+
* @param recordKeyOrName the record key or record name that should be used to access the record. You can request a record key by using {@link os.getPublicRecordKey}.
|
|
5951
|
+
* @param instName the name of the inst that should be deleted.
|
|
5952
|
+
* @param options the options for the request.
|
|
5953
|
+
*
|
|
5954
|
+
* @example Erase an inst from a record
|
|
5955
|
+
* const result = await os.eraseInst('myRecord', 'myInst');
|
|
5956
|
+
*
|
|
5957
|
+
* if (result.success) {
|
|
5958
|
+
* os.toast("Inst deleted!");
|
|
5959
|
+
* } else {
|
|
5960
|
+
* os.toast("Failed: " + result.errorMessage);
|
|
5961
|
+
* }
|
|
5962
|
+
*
|
|
5963
|
+
* @dochash actions/os/records
|
|
5964
|
+
* @docgroup 01-records
|
|
5965
|
+
* @docname os.eraseInst
|
|
5966
|
+
* @docid eraseInst
|
|
5967
|
+
*/
|
|
5968
|
+
function eraseInst(recordKeyOrName, instName, options = {}) {
|
|
5969
|
+
if (!hasValue(recordKeyOrName)) {
|
|
5970
|
+
throw new Error('recordKeyOrName must be provided.');
|
|
5971
|
+
}
|
|
5972
|
+
else if (typeof recordKeyOrName !== 'string') {
|
|
5973
|
+
throw new Error('recordKeyOrName must be a string.');
|
|
5974
|
+
}
|
|
5975
|
+
if (!hasValue(instName)) {
|
|
5976
|
+
throw new Error('instName must be provided.');
|
|
5977
|
+
}
|
|
5978
|
+
else if (typeof instName !== 'string') {
|
|
5979
|
+
throw new Error('instName must be a string.');
|
|
5980
|
+
}
|
|
5981
|
+
const task = context.createTask();
|
|
5982
|
+
const event = recordsCallProcedure({
|
|
5983
|
+
deleteInst: {
|
|
5984
|
+
input: {
|
|
5985
|
+
recordKey: isRecordKey(recordKeyOrName)
|
|
5986
|
+
? recordKeyOrName
|
|
5987
|
+
: undefined,
|
|
5988
|
+
recordName: !isRecordKey(recordKeyOrName)
|
|
5989
|
+
? recordKeyOrName
|
|
5990
|
+
: undefined,
|
|
5991
|
+
inst: instName,
|
|
5992
|
+
},
|
|
5993
|
+
},
|
|
5994
|
+
}, options, task.taskId);
|
|
5995
|
+
return addAsyncAction(task, event);
|
|
5996
|
+
}
|
|
5926
5997
|
/**
|
|
5927
5998
|
* Erases the [data](glossary:data-record) stored at the given address in the given [record](glossary:record).
|
|
5928
5999
|
* Returns a promise that resolves with an object that contains the data (if successful) or information about the error that occurred.
|