@casual-simulation/aux-runtime 3.2.13 → 3.2.14-alpha.7893057655
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 +13 -46
- package/runtime/AuxLibrary.js +103 -14
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +601 -166
- package/runtime/RecordsEvents.d.ts +70 -43
- package/runtime/RecordsEvents.js +27 -11
- 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.2.
|
|
3
|
+
"version": "3.2.14-alpha.7893057655",
|
|
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.2.
|
|
36
|
-
"@casual-simulation/aux-records": "^3.2.
|
|
35
|
+
"@casual-simulation/aux-common": "^3.2.14-alpha.7893057655",
|
|
36
|
+
"@casual-simulation/aux-records": "^3.2.14-alpha.7893057655",
|
|
37
37
|
"@casual-simulation/crypto": "^3.2.7",
|
|
38
38
|
"@casual-simulation/engine262": "0.0.1-4de2170374e22761996e46eb1362f4496ee57f8f",
|
|
39
39
|
"@casual-simulation/error-stack-parser": "^2.0.7",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"**/*.d.ts",
|
|
80
80
|
"**/*.def"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "937496446cf48d34fd5e0da41a53b4616b386f1b"
|
|
83
83
|
}
|
package/runtime/AuxLibrary.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuxGlobalContext, DEBUG_STRING } from './AuxGlobalContext';
|
|
2
|
-
import { 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,
|
|
3
|
-
import { AIChatOptions, AIGenerateSkyboxOptions, AIGenerateImageOptions, JoinRoomActionOptions, RoomOptions, RoomTrackOptions, SetRoomTrackOptions, RoomRemoteOptions, DataRecordOptions, RecordActionOptions } from './RecordsEvents';
|
|
2
|
+
import { 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, AddDropGridTargetsAction, InstUpdate, StartFormAnimationOptions, StopFormAnimationOptions, FormAnimationData, WakeLockConfiguration, EnableXROptions, ShowConfirmOptions, Geolocation, OpenPhotoCameraOptions, Photo } from '@casual-simulation/aux-common/bots';
|
|
3
|
+
import { AIChatOptions, AIGenerateSkyboxOptions, AIGenerateImageOptions, JoinRoomActionOptions, RoomOptions, RoomTrackOptions, SetRoomTrackOptions, RoomRemoteOptions, DataRecordOptions, RecordActionOptions, ListDataOptions } from './RecordsEvents';
|
|
4
4
|
import { RemoteAction, AvailablePermissions } from '@casual-simulation/aux-common';
|
|
5
5
|
import '@casual-simulation/aux-common/polyfill/Array.first.polyfill';
|
|
6
6
|
import '@casual-simulation/aux-common/polyfill/Array.last.polyfill';
|
|
@@ -10,8 +10,8 @@ import '@casual-simulation/aux-common/BlobPolyfill';
|
|
|
10
10
|
import { AuxDevice } from './AuxDevice';
|
|
11
11
|
import { AuxVersion } from './AuxVersion';
|
|
12
12
|
import { Vector3, Vector2, Quaternion, Rotation } from '@casual-simulation/aux-common/math';
|
|
13
|
-
import { CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult,
|
|
14
|
-
import type { AIChatMessage, ListStudiosResult } from '@casual-simulation/aux-records';
|
|
13
|
+
import { CreatePublicRecordKeyResult, GetDataResult, RecordDataResult, RecordFileFailure, EraseDataResult, EraseFileResult, ListDataResult, AddCountResult, GetCountResult, GrantMarkerPermissionResult, GrantRoleResult, RevokeRoleResult } from '@casual-simulation/aux-records';
|
|
14
|
+
import type { AIChatMessage, GrantResourcePermissionResult, ListStudiosResult, RevokePermissionResult } from '@casual-simulation/aux-records';
|
|
15
15
|
import { DateTime } from 'luxon';
|
|
16
16
|
import * as hooks from 'preact/hooks';
|
|
17
17
|
import { render } from 'preact';
|
|
@@ -273,25 +273,6 @@ export interface BotFilterFunction {
|
|
|
273
273
|
sort?: (bot: Bot) => any;
|
|
274
274
|
[DEBUG_STRING]?: string;
|
|
275
275
|
}
|
|
276
|
-
export interface RecordFilter {
|
|
277
|
-
recordFilter: true;
|
|
278
|
-
[DEBUG_STRING]?: string;
|
|
279
|
-
}
|
|
280
|
-
export interface AuthIdRecordFilter extends RecordFilter {
|
|
281
|
-
authID: string;
|
|
282
|
-
}
|
|
283
|
-
export interface SpaceFilter extends BotFilterFunction, RecordFilter {
|
|
284
|
-
space: string;
|
|
285
|
-
toJSON: () => RecordFilter;
|
|
286
|
-
}
|
|
287
|
-
export interface AddressRecordFilter extends RecordFilter {
|
|
288
|
-
address: string;
|
|
289
|
-
}
|
|
290
|
-
export interface IDRecordFilter extends BotFilterFunction, RecordFilter {
|
|
291
|
-
id: string;
|
|
292
|
-
toJSON: () => RecordFilter;
|
|
293
|
-
}
|
|
294
|
-
export type RecordFilters = AuthIdRecordFilter | SpaceFilter | AddressRecordFilter | IDRecordFilter | RecordReference;
|
|
295
276
|
/**
|
|
296
277
|
* Defines the options for {@link experiment.speakText}.
|
|
297
278
|
*
|
|
@@ -377,27 +358,6 @@ export interface TagSpecificApiOptions {
|
|
|
377
358
|
*/
|
|
378
359
|
config: RuntimeBot;
|
|
379
360
|
}
|
|
380
|
-
/**
|
|
381
|
-
* Defines an interface that represents a set of records that were retrieved.
|
|
382
|
-
*/
|
|
383
|
-
export interface GetRecordsResult {
|
|
384
|
-
/**
|
|
385
|
-
* The set of records that were retrieved.
|
|
386
|
-
*/
|
|
387
|
-
records: Record[];
|
|
388
|
-
/**
|
|
389
|
-
* The total number of records that the query would have returned.
|
|
390
|
-
*/
|
|
391
|
-
totalCount: number;
|
|
392
|
-
/**
|
|
393
|
-
* Whether there are more records available to retrieve for the query.
|
|
394
|
-
*/
|
|
395
|
-
hasMoreRecords: boolean;
|
|
396
|
-
/**
|
|
397
|
-
* Gets the set page of records.
|
|
398
|
-
*/
|
|
399
|
-
getMoreRecords(): Promise<GetRecordsResult>;
|
|
400
|
-
}
|
|
401
361
|
export declare const GET_RUNTIME: unique symbol;
|
|
402
362
|
/**
|
|
403
363
|
* Defines an interface for objects that represent a debugger and can retrieve their internal runtime.
|
|
@@ -1618,6 +1578,9 @@ export interface SetRoomOptionsSuccess {
|
|
|
1618
1578
|
}
|
|
1619
1579
|
/**
|
|
1620
1580
|
* Defines an interface that represents a failed "set room options" request.
|
|
1581
|
+
*
|
|
1582
|
+
* @dochash types/os/portals
|
|
1583
|
+
* @docname SetRoomOptionsFailure
|
|
1621
1584
|
*/
|
|
1622
1585
|
export interface SetRoomOptionsFailure {
|
|
1623
1586
|
success: false;
|
|
@@ -1874,6 +1837,9 @@ export interface RaycastResult {
|
|
|
1874
1837
|
}
|
|
1875
1838
|
/**
|
|
1876
1839
|
* Defines an interface that represents the intersection of a bot and ray.
|
|
1840
|
+
*
|
|
1841
|
+
* @dochash types/os/portals
|
|
1842
|
+
* @docname BotIntersection
|
|
1877
1843
|
*/
|
|
1878
1844
|
export interface BotIntersection {
|
|
1879
1845
|
/**
|
|
@@ -2340,8 +2306,8 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2340
2306
|
requestAuthBotInBackground: () => Promise<Bot>;
|
|
2341
2307
|
getPublicRecordKey: (name: string) => Promise<CreatePublicRecordKeyResult>;
|
|
2342
2308
|
getSubjectlessPublicRecordKey: (name: string) => Promise<CreatePublicRecordKeyResult>;
|
|
2343
|
-
|
|
2344
|
-
|
|
2309
|
+
grantPermission: (recordName: string, permission: AvailablePermissions, options?: RecordActionOptions) => Promise<GrantMarkerPermissionResult | GrantResourcePermissionResult>;
|
|
2310
|
+
revokePermission: (recordName: string, permissionId: string, options?: RecordActionOptions) => Promise<RevokePermissionResult>;
|
|
2345
2311
|
grantInstAdminPermission: (recordName: string, options?: RecordActionOptions) => Promise<GrantRoleResult>;
|
|
2346
2312
|
grantUserRole: (recordName: string, role: string, userId: string, expireTimeMs?: number, options?: RecordActionOptions) => Promise<GrantRoleResult>;
|
|
2347
2313
|
revokeUserRole: (recordName: string, role: string, userId: string, options?: RecordActionOptions) => Promise<RevokeRoleResult>;
|
|
@@ -2353,6 +2319,7 @@ export declare function createDefaultLibrary(context: AuxGlobalContext): {
|
|
|
2353
2319
|
getData: (recordKeyOrName: string, address: string, endpoint?: string) => Promise<GetDataResult>;
|
|
2354
2320
|
getManualApprovalData: (recordKeyOrName: string, address: string, endpoint?: string) => Promise<GetDataResult>;
|
|
2355
2321
|
listData: (recordKeyOrName: string, startingAddress?: string, endpoint?: string) => Promise<ListDataResult>;
|
|
2322
|
+
listDataByMarker: (recordKeyOrName: string, marker: string, startingAddress?: string, options?: ListDataOptions) => Promise<ListDataResult>;
|
|
2356
2323
|
eraseData: (recordKeyOrName: string, address: string, endpoint?: string) => Promise<EraseDataResult>;
|
|
2357
2324
|
eraseManualApprovalData: (recordKeyOrName: string, address: string, endpoint?: string) => Promise<EraseDataResult>;
|
|
2358
2325
|
recordFile: (recordKeyOrName: string, data: any, options?: RecordFileOptions, endpoint?: string) => Promise<RecordFileApiResult>;
|
package/runtime/AuxLibrary.js
CHANGED
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
};
|
|
21
21
|
import { DEBUG_STRING, debugStringifyFunction, } from './AuxGlobalContext';
|
|
22
22
|
import { hasValue, trimTag, isBot, BOT_SPACE_TAG, toast as toastMessage, 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, 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, reportInst as calcReportInst, } from '@casual-simulation/aux-common/bots';
|
|
23
|
-
import { aiChat, aiGenerateSkybox, aiGenerateImage,
|
|
23
|
+
import { aiChat, aiGenerateSkybox, aiGenerateImage, grantRecordPermission as calcGrantRecordPermission, revokeRecordPermission as calcRevokeRecordPermission, grantInstAdminPermission as calcGrantInstAdminPermission, grantUserRole as calcGrantUserRole, revokeUserRole as calcRevokeUserRole, grantInstRole as calcGrantInstRole, revokeInstRole as calcRevokeInstRole, listUserStudios as calcListUserStudios, 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, } from './RecordsEvents';
|
|
24
24
|
import { sortBy, every, cloneDeep, union, isEqual, flatMap, } from 'lodash';
|
|
25
25
|
import { remote as calcRemote, DEFAULT_BRANCH_NAME, } from '@casual-simulation/aux-common';
|
|
26
26
|
import { RanOutOfEnergyError } from './AuxResults';
|
|
@@ -532,8 +532,8 @@ export function createDefaultLibrary(context) {
|
|
|
532
532
|
requestAuthBotInBackground,
|
|
533
533
|
getPublicRecordKey,
|
|
534
534
|
getSubjectlessPublicRecordKey,
|
|
535
|
-
|
|
536
|
-
|
|
535
|
+
grantPermission,
|
|
536
|
+
revokePermission,
|
|
537
537
|
grantInstAdminPermission,
|
|
538
538
|
grantUserRole,
|
|
539
539
|
revokeUserRole,
|
|
@@ -545,6 +545,7 @@ export function createDefaultLibrary(context) {
|
|
|
545
545
|
getData,
|
|
546
546
|
getManualApprovalData,
|
|
547
547
|
listData,
|
|
548
|
+
listDataByMarker,
|
|
548
549
|
eraseData,
|
|
549
550
|
eraseManualApprovalData,
|
|
550
551
|
recordFile,
|
|
@@ -4605,41 +4606,39 @@ export function createDefaultLibrary(context) {
|
|
|
4605
4606
|
return addAsyncAction(task, event);
|
|
4606
4607
|
}
|
|
4607
4608
|
/**
|
|
4608
|
-
* Grants the given
|
|
4609
|
+
* Grants the given permission in the given record.
|
|
4609
4610
|
*
|
|
4610
4611
|
* See [Record Security](page:learn/records/security) for more information.
|
|
4611
4612
|
*
|
|
4612
4613
|
* @param recordName the name of the record.
|
|
4613
|
-
* @param marker the marker that the permission should be added to.
|
|
4614
4614
|
* @param permission the permission that should be added.
|
|
4615
4615
|
* @param options the options for the operation.
|
|
4616
4616
|
*
|
|
4617
4617
|
* @dochash actions/os/records
|
|
4618
4618
|
* @docgroup 01-records
|
|
4619
|
-
* @docname os.
|
|
4619
|
+
* @docname os.grantPermission
|
|
4620
4620
|
*/
|
|
4621
|
-
function
|
|
4621
|
+
function grantPermission(recordName, permission, options) {
|
|
4622
4622
|
const task = context.createTask();
|
|
4623
|
-
const event =
|
|
4623
|
+
const event = calcGrantRecordPermission(recordName, permission, options !== null && options !== void 0 ? options : {}, task.taskId);
|
|
4624
4624
|
return addAsyncAction(task, event);
|
|
4625
4625
|
}
|
|
4626
4626
|
/**
|
|
4627
|
-
* Revokes the
|
|
4627
|
+
* Revokes the permission with the given ID from the the given record.
|
|
4628
4628
|
*
|
|
4629
4629
|
* See [Record Security](page:learn/records/security) for more information.
|
|
4630
4630
|
*
|
|
4631
4631
|
* @param recordName the name of the record.
|
|
4632
|
-
* @param
|
|
4633
|
-
* @param permission the permission that should be removed.
|
|
4632
|
+
* @param permissionId the ID of the permission that should be removed.
|
|
4634
4633
|
* @param options the options for the operation.
|
|
4635
4634
|
*
|
|
4636
4635
|
* @dochash actions/os/records
|
|
4637
4636
|
* @docgroup 01-records
|
|
4638
|
-
* @docname os.
|
|
4637
|
+
* @docname os.revokePermission
|
|
4639
4638
|
*/
|
|
4640
|
-
function
|
|
4639
|
+
function revokePermission(recordName, permissionId, options) {
|
|
4641
4640
|
const task = context.createTask();
|
|
4642
|
-
const event =
|
|
4641
|
+
const event = calcRevokeRecordPermission(recordName, permissionId, options !== null && options !== void 0 ? options : {}, task.taskId);
|
|
4643
4642
|
return addAsyncAction(task, event);
|
|
4644
4643
|
}
|
|
4645
4644
|
/**
|
|
@@ -4783,6 +4782,26 @@ export function createDefaultLibrary(context) {
|
|
|
4783
4782
|
* os.toast("Failed " + result.errorMessage);
|
|
4784
4783
|
* }
|
|
4785
4784
|
*
|
|
4785
|
+
* @example Record data to the user's personal record
|
|
4786
|
+
* const result = await os.recordData(authBot.id, 'myAddress', 'myData');
|
|
4787
|
+
*
|
|
4788
|
+
* if (result.success) {
|
|
4789
|
+
* os.toast("Success!");
|
|
4790
|
+
* } else {
|
|
4791
|
+
* os.toast("Failed " + result.errorMessage);
|
|
4792
|
+
* }
|
|
4793
|
+
*
|
|
4794
|
+
* @example Record data with a custom marker
|
|
4795
|
+
* const result = await os.recordData(authBot.id, 'myAddress', 'myData', {
|
|
4796
|
+
* marker: 'myMarker'
|
|
4797
|
+
* });
|
|
4798
|
+
*
|
|
4799
|
+
* if (result.success) {
|
|
4800
|
+
* os.toast("Success!");
|
|
4801
|
+
* } else {
|
|
4802
|
+
* os.toast("Failed " + result.errorMessage);
|
|
4803
|
+
* }
|
|
4804
|
+
*
|
|
4786
4805
|
* @dochash actions/os/records
|
|
4787
4806
|
* @docgroup 01-records
|
|
4788
4807
|
* @docname os.recordData
|
|
@@ -4961,6 +4980,76 @@ export function createDefaultLibrary(context) {
|
|
|
4961
4980
|
const event = listDataRecord(recordName, startingAddress, options, task.taskId);
|
|
4962
4981
|
return addAsyncAction(task, event);
|
|
4963
4982
|
}
|
|
4983
|
+
/**
|
|
4984
|
+
* Gets a partial list of [data](glossary:data-record) with the given marker that is stored in the given record.
|
|
4985
|
+
* Optionally accepts the address before the first item that should be included in the list.
|
|
4986
|
+
* Returns a promise that resolves with an object that contains the items (if successful) or information about the error that occurred.
|
|
4987
|
+
*
|
|
4988
|
+
* @param recordKeyOrName the record name or a record key. This indicates the record that the data should be retrieved from.
|
|
4989
|
+
* Note that you don't need a record key in order to retrieve public data from a record. Using a record name will work just fine.
|
|
4990
|
+
* @param marker The marker that needs to be assigned to the data items that should be included in the list.
|
|
4991
|
+
* e.g. Using "publicRead" will return all data items with the "publicRead" marker.
|
|
4992
|
+
* @param startingAddress the address after which items will be included in the list.
|
|
4993
|
+
* Since items are ordered within the record by address, this can be used as way to iterate through all the data items in a record.
|
|
4994
|
+
* If omitted, then the list will start with the first item.
|
|
4995
|
+
* @param options The options for the operation.
|
|
4996
|
+
*
|
|
4997
|
+
* @example Get a list of publicRead data items in a record
|
|
4998
|
+
* const result = await os.listDataByMarker('myRecord', 'publicRead');
|
|
4999
|
+
* if (result.success) {
|
|
5000
|
+
* os.toast(result.items);
|
|
5001
|
+
* } else {
|
|
5002
|
+
* os.toast("Failed " + result.errorMessage);
|
|
5003
|
+
* }
|
|
5004
|
+
*
|
|
5005
|
+
* @example List all the items that have the publicRead marker in a record
|
|
5006
|
+
* let lastAddress;
|
|
5007
|
+
* let items = [];
|
|
5008
|
+
* while(true) {
|
|
5009
|
+
* const result = await os.listDataByMarker('myRecord', 'publicRead', lastAddress);
|
|
5010
|
+
* if (result.success) {
|
|
5011
|
+
* console.log(result.items);
|
|
5012
|
+
* items.push(...result.items);
|
|
5013
|
+
* if (result.items.length > 0) {
|
|
5014
|
+
* lastAddress = result.items[result.items.length - 1].address;
|
|
5015
|
+
* } else {
|
|
5016
|
+
* // result.items is empty, so we can break out of the loop
|
|
5017
|
+
* break;
|
|
5018
|
+
* }
|
|
5019
|
+
* } else {
|
|
5020
|
+
* os.toast("Failed " + result.errorMessage);
|
|
5021
|
+
* break;
|
|
5022
|
+
* }
|
|
5023
|
+
* }
|
|
5024
|
+
*
|
|
5025
|
+
* @example List publicRead items in descending order
|
|
5026
|
+
* const result = await os.listDataByMarker('myRecord', 'publicRead', null, { sort: 'descending' });
|
|
5027
|
+
* if (result.success) {
|
|
5028
|
+
* os.toast(result.items);
|
|
5029
|
+
* } else {
|
|
5030
|
+
* os.toast("Failed " + result.errorMessage);
|
|
5031
|
+
* }
|
|
5032
|
+
*
|
|
5033
|
+
* @example List publicRead items stored at "myContainer" in descending order
|
|
5034
|
+
* const result = await os.listDataByMarker('myRecord', 'publicRead:myContainer', null, { sort: 'descending' });
|
|
5035
|
+
* if (result.success) {
|
|
5036
|
+
* os.toast(result.items);
|
|
5037
|
+
* } else {
|
|
5038
|
+
* os.toast("Failed " + result.errorMessage);
|
|
5039
|
+
* }
|
|
5040
|
+
*
|
|
5041
|
+
* @dochash actions/os/records
|
|
5042
|
+
* @docgroup 01-records
|
|
5043
|
+
* @docname os.listDataByMarker
|
|
5044
|
+
*/
|
|
5045
|
+
function listDataByMarker(recordKeyOrName, marker, startingAddress = null, options = {}) {
|
|
5046
|
+
const recordName = isRecordKey(recordKeyOrName)
|
|
5047
|
+
? parseRecordKey(recordKeyOrName)[0]
|
|
5048
|
+
: recordKeyOrName;
|
|
5049
|
+
const task = context.createTask();
|
|
5050
|
+
const event = listDataRecordByMarker(recordName, marker, startingAddress, options, task.taskId);
|
|
5051
|
+
return addAsyncAction(task, event);
|
|
5052
|
+
}
|
|
4964
5053
|
/**
|
|
4965
5054
|
* Erases the [data](glossary:data-record) stored at the given address in the given [record](glossary:record).
|
|
4966
5055
|
* Returns a promise that resolves with an object that contains the data (if successful) or information about the error that occurred.
|