@casual-simulation/aux-runtime 3.8.1 → 3.10.2
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 +677 -54
- package/package.json +85 -86
- package/runtime/AuxCompiler.d.ts +11 -2
- package/runtime/AuxCompiler.js +44 -31
- package/runtime/AuxCompiler.js.map +1 -1
- package/runtime/AuxDevice.d.ts +11 -0
- package/runtime/AuxGlobalContext.d.ts +7 -0
- package/runtime/AuxGlobalContext.js +3 -0
- package/runtime/AuxGlobalContext.js.map +1 -1
- package/runtime/AuxLibrary.d.ts +62 -6
- package/runtime/AuxLibrary.js +585 -107
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +2441 -675
- package/runtime/AuxRuntime.js +51 -46
- package/runtime/AuxRuntime.js.map +1 -1
- package/runtime/RecordsEvents.d.ts +294 -2
- package/runtime/RecordsEvents.js +178 -12
- package/runtime/RecordsEvents.js.map +1 -1
- package/runtime/RuntimeBot.js +1 -1
- package/runtime/RuntimeBot.js.map +1 -1
- package/runtime/Transpiler.d.ts +27 -2
- package/runtime/Transpiler.js +117 -20
- package/runtime/Transpiler.js.map +1 -1
- package/runtime/test/TestScriptBotFactory.js +1 -2
- package/runtime/test/TestScriptBotFactory.js.map +1 -1
package/runtime/AuxLibrary.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { DEBUG_STRING, debugStringifyFunction } from './AuxGlobalContext';
|
|
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, showAlert as calcShowAlert, 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, trackConfigBotTags as calcTrackConfigBotTags, } from '@casual-simulation/aux-common/bots';
|
|
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,
|
|
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, generateQRCode as calcGenerateQRCode, openBarcodeScanner as calcOpenBarcodeScanner, showBarcode as calcShowBarcode, importAUX as calcImportAUX, showInputForTag as calcShowInputForTag, showInput as calcShowInput, showConfirm as calcShowConfirm, showAlert as calcShowAlert, 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, signOut as calcSignOut, 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, trackConfigBotTags as calcTrackConfigBotTags, } from '@casual-simulation/aux-common/bots';
|
|
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,
|
|
4
|
+
// getXpUserMeta,
|
|
5
|
+
// createXpContract,
|
|
6
|
+
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, recordStoreItem as calcRecordStoreItem, getStoreItem as calcGetStoreItem, eraseStoreItem as calcEraseStoreItem, listStoreItems as calcListStoreItems, listStoreItemsByMarker as calcListStoreItemsByMarker, purchaseStoreItem as calcPurchaseStoreItem, } from './RecordsEvents';
|
|
4
7
|
import { sortBy, cloneDeep, union, isEqual } from 'es-toolkit/compat';
|
|
5
8
|
import { remote as calcRemote, DEFAULT_BRANCH_NAME, formatVersionNumber, parseVersionNumber, PRIVATE_MARKER, } from '@casual-simulation/aux-common';
|
|
6
9
|
import { RanOutOfEnergyError } from './AuxResults';
|
|
7
10
|
import '@casual-simulation/aux-common/polyfill/Array.first.polyfill';
|
|
8
11
|
import '@casual-simulation/aux-common/polyfill/Array.last.polyfill';
|
|
9
12
|
import { embedBase64InPdf, getEmbeddedBase64FromPdf, toHexString as utilToHexString, fromHexString as utilFromHexString, } from './Utils';
|
|
10
|
-
import { convertToCopiableValue } from '@casual-simulation/aux-common/partitions/PartitionUtils';
|
|
13
|
+
import { constructInitializationUpdateFromPreviousUpdates, convertToCopiableValue, } from '@casual-simulation/aux-common/partitions/PartitionUtils';
|
|
11
14
|
import { sha256 as hashSha256, sha512 as hashSha512, hmac as calcHmac, sha1 as hashSha1, } from 'hash.js';
|
|
12
15
|
import stableStringify from '@casual-simulation/fast-json-stable-stringify';
|
|
13
16
|
import { encrypt as realEncrypt, decrypt as realDecrypt, keypair as realKeypair, sign as realSign, verify as realVerify, asymmetricKeypair as realAsymmetricKeypair, asymmetricEncrypt as realAsymmetricEncrypt, asymmetricDecrypt as realAsymmetricDecrypt, isAsymmetricKeypair, isAsymmetricEncrypted, isEncrypted, } from '@casual-simulation/crypto';
|
|
@@ -34,6 +37,7 @@ import { constructInitializationUpdate, mergeInstUpdates as calcMergeInstUpdates
|
|
|
34
37
|
import { CasualOSError } from './CasualOSError';
|
|
35
38
|
import { attachRuntime, detachRuntime } from './RuntimeEvents';
|
|
36
39
|
import { query as q } from './database/DatabaseUtils';
|
|
40
|
+
// import type { PurchasableItem } from '@casual-simulation/aux-records/casualware/PurchasableItemRecordsStore';
|
|
37
41
|
const _html = htm.bind(h);
|
|
38
42
|
const html = ((...args) => {
|
|
39
43
|
return _html(...args);
|
|
@@ -124,7 +128,6 @@ expect.extend({
|
|
|
124
128
|
},
|
|
125
129
|
});
|
|
126
130
|
function getBotSnapshot(bot) {
|
|
127
|
-
var _a;
|
|
128
131
|
let b = {
|
|
129
132
|
id: bot.id,
|
|
130
133
|
space: bot.space,
|
|
@@ -134,7 +137,7 @@ function getBotSnapshot(bot) {
|
|
|
134
137
|
};
|
|
135
138
|
let masks = isRuntimeBot(bot)
|
|
136
139
|
? bot[GET_TAG_MASKS_SYMBOL]()
|
|
137
|
-
: cloneDeep(
|
|
140
|
+
: cloneDeep(bot.masks ?? {});
|
|
138
141
|
if (Object.keys(masks).length > 0) {
|
|
139
142
|
b.masks = masks;
|
|
140
143
|
}
|
|
@@ -576,6 +579,7 @@ export function createDefaultLibrary(context) {
|
|
|
576
579
|
closeQRCodeScanner,
|
|
577
580
|
showQRCode,
|
|
578
581
|
hideQRCode,
|
|
582
|
+
generateQRCode,
|
|
579
583
|
openBarcodeScanner,
|
|
580
584
|
closeBarcodeScanner,
|
|
581
585
|
showBarcode,
|
|
@@ -738,6 +742,7 @@ export function createDefaultLibrary(context) {
|
|
|
738
742
|
reportInst,
|
|
739
743
|
requestAuthBot,
|
|
740
744
|
requestAuthBotInBackground,
|
|
745
|
+
signOut,
|
|
741
746
|
createRecord,
|
|
742
747
|
getPublicRecordKey,
|
|
743
748
|
getSubjectlessPublicRecordKey,
|
|
@@ -813,6 +818,12 @@ export function createDefaultLibrary(context) {
|
|
|
813
818
|
listUserStudios,
|
|
814
819
|
listStudioRecords,
|
|
815
820
|
getRecordsEndpoint,
|
|
821
|
+
recordStoreItem,
|
|
822
|
+
getStoreItem,
|
|
823
|
+
eraseStoreItem,
|
|
824
|
+
listStoreItems,
|
|
825
|
+
listStoreItemsByMarker,
|
|
826
|
+
purchaseStoreItem,
|
|
816
827
|
convertGeolocationToWhat3Words,
|
|
817
828
|
raycastFromCamera,
|
|
818
829
|
raycast,
|
|
@@ -858,6 +869,20 @@ export function createDefaultLibrary(context) {
|
|
|
858
869
|
_attachDebugger,
|
|
859
870
|
_detachDebugger,
|
|
860
871
|
},
|
|
872
|
+
xp: {
|
|
873
|
+
recordContract: xpRecordContract,
|
|
874
|
+
getContract: xpGetContract,
|
|
875
|
+
listContracts: xpListContracts,
|
|
876
|
+
getContractPricing: xpGetContractPricing,
|
|
877
|
+
purchaseContract: xpPurchaseContract,
|
|
878
|
+
cancelContract: xpCancelContract,
|
|
879
|
+
invoiceContract: xpInvoiceContract,
|
|
880
|
+
cancelInvoice: xpCancelInvoice,
|
|
881
|
+
listInvoices: xpListInvoices,
|
|
882
|
+
payInvoice: xpPayInvoice,
|
|
883
|
+
payout: xpPayout,
|
|
884
|
+
getAccountBalances: xpGetAccountBalances,
|
|
885
|
+
},
|
|
861
886
|
portal: {
|
|
862
887
|
registerPrefix,
|
|
863
888
|
},
|
|
@@ -968,7 +993,7 @@ export function createDefaultLibrary(context) {
|
|
|
968
993
|
},
|
|
969
994
|
},
|
|
970
995
|
tagSpecificApi: {
|
|
971
|
-
create: tagAsInterpretableFunction((options) => (...args) =>
|
|
996
|
+
create: tagAsInterpretableFunction((options) => (...args) => create(options.bot?.id, ...args), (options) => (...args) => unwind(create(options.bot?.id, ...args))),
|
|
972
997
|
setTimeout: botTimer('timeout', setTimeout, true),
|
|
973
998
|
setInterval: botTimer('interval', setInterval, false),
|
|
974
999
|
watchPortal: watchPortalBots(),
|
|
@@ -1076,6 +1101,7 @@ export function createDefaultLibrary(context) {
|
|
|
1076
1101
|
let valid = true;
|
|
1077
1102
|
const generatorWrapper = {
|
|
1078
1103
|
[Symbol.iterator]: () => generatorWrapper,
|
|
1104
|
+
[Symbol.dispose]: () => { },
|
|
1079
1105
|
next(value) {
|
|
1080
1106
|
if (!valid) {
|
|
1081
1107
|
return {
|
|
@@ -1831,7 +1857,7 @@ export function createDefaultLibrary(context) {
|
|
|
1831
1857
|
* @docname getJSON
|
|
1832
1858
|
*/
|
|
1833
1859
|
function getJSON(data) {
|
|
1834
|
-
if (hasValue(data
|
|
1860
|
+
if (hasValue(data?.[ORIGINAL_OBJECT])) {
|
|
1835
1861
|
return stableStringify(data[ORIGINAL_OBJECT]);
|
|
1836
1862
|
}
|
|
1837
1863
|
return stableStringify(data);
|
|
@@ -1850,7 +1876,7 @@ export function createDefaultLibrary(context) {
|
|
|
1850
1876
|
* @docname getFormattedJSON
|
|
1851
1877
|
*/
|
|
1852
1878
|
function getFormattedJSON(data) {
|
|
1853
|
-
if (hasValue(data
|
|
1879
|
+
if (hasValue(data?.[ORIGINAL_OBJECT])) {
|
|
1854
1880
|
return stableStringify(data[ORIGINAL_OBJECT], { space: 2 });
|
|
1855
1881
|
}
|
|
1856
1882
|
return stableStringify(data, { space: 2 });
|
|
@@ -1865,7 +1891,6 @@ export function createDefaultLibrary(context) {
|
|
|
1865
1891
|
* @docname getSnapshot
|
|
1866
1892
|
*/
|
|
1867
1893
|
function getSnapshot(bots) {
|
|
1868
|
-
var _a;
|
|
1869
1894
|
if (!Array.isArray(bots)) {
|
|
1870
1895
|
return getSnapshot([bots]);
|
|
1871
1896
|
}
|
|
@@ -1884,7 +1909,7 @@ export function createDefaultLibrary(context) {
|
|
|
1884
1909
|
}
|
|
1885
1910
|
let masks = isRuntimeBot(bot)
|
|
1886
1911
|
? bot[GET_TAG_MASKS_SYMBOL]()
|
|
1887
|
-
: cloneDeep(
|
|
1912
|
+
: cloneDeep(bot.masks ?? {});
|
|
1888
1913
|
if (Object.keys(masks).length > 0) {
|
|
1889
1914
|
b.masks = masks;
|
|
1890
1915
|
}
|
|
@@ -2129,7 +2154,7 @@ export function createDefaultLibrary(context) {
|
|
|
2129
2154
|
const final = addAsyncResultAction(task, action).then((result) => {
|
|
2130
2155
|
const choice = result.choices[0];
|
|
2131
2156
|
if (returnString) {
|
|
2132
|
-
return choice
|
|
2157
|
+
return choice?.content;
|
|
2133
2158
|
}
|
|
2134
2159
|
return choice;
|
|
2135
2160
|
});
|
|
@@ -2164,7 +2189,7 @@ export function createDefaultLibrary(context) {
|
|
|
2164
2189
|
continue;
|
|
2165
2190
|
}
|
|
2166
2191
|
if (returnString) {
|
|
2167
|
-
const content = choice
|
|
2192
|
+
const content = choice?.content;
|
|
2168
2193
|
if (!hasValue(content)) {
|
|
2169
2194
|
continue;
|
|
2170
2195
|
}
|
|
@@ -2245,7 +2270,7 @@ export function createDefaultLibrary(context) {
|
|
|
2245
2270
|
action = aiGenerateImage(prompt, negativePrompt, task.taskId);
|
|
2246
2271
|
}
|
|
2247
2272
|
else {
|
|
2248
|
-
let { endpoint, ...parameters } = options
|
|
2273
|
+
let { endpoint, ...parameters } = options ?? {};
|
|
2249
2274
|
action = aiGenerateImage({
|
|
2250
2275
|
...parameters,
|
|
2251
2276
|
prompt,
|
|
@@ -2255,23 +2280,19 @@ export function createDefaultLibrary(context) {
|
|
|
2255
2280
|
}, task.taskId);
|
|
2256
2281
|
}
|
|
2257
2282
|
const final = addAsyncResultAction(task, action).then((result) => {
|
|
2258
|
-
var _a;
|
|
2259
2283
|
if (returnObject) {
|
|
2260
2284
|
return {
|
|
2261
2285
|
...result,
|
|
2262
|
-
images: result.images.map((image) => {
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
url: toBase64Url(image.base64, (_a = image.mimeType) !== null && _a !== void 0 ? _a : 'image/png'),
|
|
2267
|
-
});
|
|
2268
|
-
}),
|
|
2286
|
+
images: result.images.map((image) => ({
|
|
2287
|
+
...image,
|
|
2288
|
+
url: toBase64Url(image.base64, image.mimeType ?? 'image/png'),
|
|
2289
|
+
})),
|
|
2269
2290
|
};
|
|
2270
2291
|
}
|
|
2271
2292
|
else {
|
|
2272
2293
|
const image = result.images[0];
|
|
2273
2294
|
const base64 = image.base64;
|
|
2274
|
-
return toBase64Url(base64,
|
|
2295
|
+
return toBase64Url(base64, image.mimeType ?? 'image/png');
|
|
2275
2296
|
}
|
|
2276
2297
|
});
|
|
2277
2298
|
final[ORIGINAL_OBJECT] = action;
|
|
@@ -2480,7 +2501,7 @@ export function createDefaultLibrary(context) {
|
|
|
2480
2501
|
*/
|
|
2481
2502
|
function tip(message, pixelX, pixelY, duration) {
|
|
2482
2503
|
const task = context.createTask();
|
|
2483
|
-
const action = tipMessage(convertToCopiableValue(message), pixelX
|
|
2504
|
+
const action = tipMessage(convertToCopiableValue(message), pixelX ?? null, pixelY ?? null, (duration ?? 2) * 1000, task.taskId);
|
|
2484
2505
|
return addAsyncAction(task, action);
|
|
2485
2506
|
}
|
|
2486
2507
|
/**
|
|
@@ -2768,7 +2789,7 @@ export function createDefaultLibrary(context) {
|
|
|
2768
2789
|
const finalOptions = {
|
|
2769
2790
|
duration: 1,
|
|
2770
2791
|
easing: 'quadratic',
|
|
2771
|
-
...(options
|
|
2792
|
+
...(options ?? {}),
|
|
2772
2793
|
};
|
|
2773
2794
|
let action;
|
|
2774
2795
|
if (botOrPosition === null) {
|
|
@@ -2953,6 +2974,7 @@ export function createDefaultLibrary(context) {
|
|
|
2953
2974
|
isCollaborative: null,
|
|
2954
2975
|
allowCollaborationUpgrade: null,
|
|
2955
2976
|
ab1BootstrapUrl: null,
|
|
2977
|
+
comID: null,
|
|
2956
2978
|
};
|
|
2957
2979
|
}
|
|
2958
2980
|
/**
|
|
@@ -3389,8 +3411,7 @@ export function createDefaultLibrary(context) {
|
|
|
3389
3411
|
* @docname os.getAuxFileForBots
|
|
3390
3412
|
*/
|
|
3391
3413
|
function getAuxFileForBots(bots, options) {
|
|
3392
|
-
|
|
3393
|
-
const version = (_a = options === null || options === void 0 ? void 0 : options.version) !== null && _a !== void 0 ? _a : 2;
|
|
3414
|
+
const version = options?.version ?? 2;
|
|
3394
3415
|
if (version === 1) {
|
|
3395
3416
|
let state = {};
|
|
3396
3417
|
for (let bot of bots) {
|
|
@@ -3429,7 +3450,7 @@ export function createDefaultLibrary(context) {
|
|
|
3429
3450
|
*/
|
|
3430
3451
|
function installAuxFile(aux, mode) {
|
|
3431
3452
|
const task = context.createTask(true, true);
|
|
3432
|
-
const action = calcRemote(calcInstallAuxFile(aux, mode
|
|
3453
|
+
const action = calcRemote(calcInstallAuxFile(aux, mode ?? 'default'), undefined, undefined, task.taskId);
|
|
3433
3454
|
return addAsyncAction(task, action);
|
|
3434
3455
|
}
|
|
3435
3456
|
/**
|
|
@@ -3545,6 +3566,40 @@ export function createDefaultLibrary(context) {
|
|
|
3545
3566
|
const event = calcShowQRCode(false);
|
|
3546
3567
|
return addAction(event);
|
|
3547
3568
|
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Generates a [QR Code](https://en.wikipedia.org/wiki/QR_code) for the given data and returns a [Data URL](https://developer.mozilla.org/en-US/docs/web/http/basics_of_http/data_urls) that can be used in an img tag or as a {@tag formAddress}.
|
|
3571
|
+
*
|
|
3572
|
+
* Returns a promise that resolves with the data URL string.
|
|
3573
|
+
*
|
|
3574
|
+
* @param code the text or data that the generated QR Code should represent.
|
|
3575
|
+
* @param options the options that should be used when generating the QR Code.
|
|
3576
|
+
*
|
|
3577
|
+
* @example Generate a QR Code that contains the data "hello".
|
|
3578
|
+
* const qrCodeUrl = await os.generateQRCode("hello");
|
|
3579
|
+
* masks.formAddress = qrCodeUrl;
|
|
3580
|
+
*
|
|
3581
|
+
* @example Generate a QR Code that links to https://example.com
|
|
3582
|
+
* const qrCodeUrl = await os.generateQRCode("https://example.com");
|
|
3583
|
+
* masks.formAddress = qrCodeUrl;
|
|
3584
|
+
*
|
|
3585
|
+
* @example Generate a QR Code with custom colors.
|
|
3586
|
+
* const qrCodeUrl = await os.generateQRCode("Custom QR Code", {
|
|
3587
|
+
* color: {
|
|
3588
|
+
* dark: "#0000FFFF",
|
|
3589
|
+
* light: "#FFFF00FF"
|
|
3590
|
+
* }
|
|
3591
|
+
* });
|
|
3592
|
+
* masks.formAddress = qrCodeUrl;
|
|
3593
|
+
*
|
|
3594
|
+
* @dochash actions/os/barcodes
|
|
3595
|
+
* @docname os.generateQRCode
|
|
3596
|
+
* @docgroup 10-qr-code
|
|
3597
|
+
*/
|
|
3598
|
+
function generateQRCode(code, options) {
|
|
3599
|
+
const task = context.createTask();
|
|
3600
|
+
const event = calcGenerateQRCode(code, options, task.taskId);
|
|
3601
|
+
return addAsyncAction(task, event);
|
|
3602
|
+
}
|
|
3548
3603
|
/**
|
|
3549
3604
|
* Opens the [Barcode](https://en.wikipedia.org/wiki/Barcode) scanner.
|
|
3550
3605
|
* While open, each scanned Barcode will send a {@tag @onBarcodeScanned} shout. Optionally accepts which camera to use for scanning. (front/back)
|
|
@@ -3870,7 +3925,7 @@ export function createDefaultLibrary(context) {
|
|
|
3870
3925
|
}
|
|
3871
3926
|
}
|
|
3872
3927
|
}
|
|
3873
|
-
catch
|
|
3928
|
+
catch {
|
|
3874
3929
|
// Ignore errors
|
|
3875
3930
|
}
|
|
3876
3931
|
const task = context.createTask();
|
|
@@ -4053,10 +4108,11 @@ export function createDefaultLibrary(context) {
|
|
|
4053
4108
|
* @docgroup 10-config-values
|
|
4054
4109
|
*/
|
|
4055
4110
|
function getCurrentServer() {
|
|
4056
|
-
var _a;
|
|
4057
4111
|
const user = context.playerBot;
|
|
4058
4112
|
if (user) {
|
|
4059
|
-
let inst =
|
|
4113
|
+
let inst = getTag(user, 'inst') ??
|
|
4114
|
+
getTag(user, 'staticInst') ??
|
|
4115
|
+
getTag(user, 'tempInst');
|
|
4060
4116
|
if (hasValue(inst)) {
|
|
4061
4117
|
if (Array.isArray(inst)) {
|
|
4062
4118
|
return inst[0].toString();
|
|
@@ -4076,10 +4132,9 @@ export function createDefaultLibrary(context) {
|
|
|
4076
4132
|
* @docgroup 10-config-values
|
|
4077
4133
|
*/
|
|
4078
4134
|
function getCurrentInstRecord() {
|
|
4079
|
-
var _a;
|
|
4080
4135
|
const user = context.playerBot;
|
|
4081
4136
|
if (user) {
|
|
4082
|
-
return
|
|
4137
|
+
return getTag(user, 'record') ?? null;
|
|
4083
4138
|
}
|
|
4084
4139
|
return null;
|
|
4085
4140
|
}
|
|
@@ -4697,8 +4752,8 @@ export function createDefaultLibrary(context) {
|
|
|
4697
4752
|
function closeCircleWipe(options) {
|
|
4698
4753
|
const task = context.createTask();
|
|
4699
4754
|
const event = circleWipe(false, {
|
|
4700
|
-
color:
|
|
4701
|
-
duration:
|
|
4755
|
+
color: options?.color || 'black',
|
|
4756
|
+
duration: options?.duration || 1,
|
|
4702
4757
|
}, task.taskId);
|
|
4703
4758
|
return addAsyncAction(task, event);
|
|
4704
4759
|
}
|
|
@@ -4736,8 +4791,8 @@ export function createDefaultLibrary(context) {
|
|
|
4736
4791
|
function openCircleWipe(options) {
|
|
4737
4792
|
const task = context.createTask();
|
|
4738
4793
|
const event = circleWipe(true, {
|
|
4739
|
-
color:
|
|
4740
|
-
duration:
|
|
4794
|
+
color: options?.color || 'black',
|
|
4795
|
+
duration: options?.duration || 1,
|
|
4741
4796
|
}, task.taskId);
|
|
4742
4797
|
return addAsyncAction(task, event);
|
|
4743
4798
|
}
|
|
@@ -5024,6 +5079,274 @@ export function createDefaultLibrary(context) {
|
|
|
5024
5079
|
const event = calcGetGeolocation(task.taskId);
|
|
5025
5080
|
return addAsyncAction(task, event);
|
|
5026
5081
|
}
|
|
5082
|
+
/**
|
|
5083
|
+
* Creates a new contract record in the XP system.
|
|
5084
|
+
*
|
|
5085
|
+
* @param recordName The name of the record that the contract should be stored in.
|
|
5086
|
+
* @param contract The contract record data.
|
|
5087
|
+
* @param options The options for the request.
|
|
5088
|
+
*
|
|
5089
|
+
* @dochash actions/xp
|
|
5090
|
+
* @doctitle xpExchange Actions
|
|
5091
|
+
* @docsidebar xpExchange
|
|
5092
|
+
* @docdescription Actions for working with the xpExchange.
|
|
5093
|
+
* @docname xp.recordContract
|
|
5094
|
+
*/
|
|
5095
|
+
function xpRecordContract(recordName, contract, options = {}) {
|
|
5096
|
+
const task = context.createTask();
|
|
5097
|
+
const event = recordsCallProcedure({
|
|
5098
|
+
recordContract: {
|
|
5099
|
+
input: {
|
|
5100
|
+
recordName,
|
|
5101
|
+
item: contract,
|
|
5102
|
+
},
|
|
5103
|
+
},
|
|
5104
|
+
}, options, task.taskId);
|
|
5105
|
+
return addAsyncAction(task, event);
|
|
5106
|
+
}
|
|
5107
|
+
/**
|
|
5108
|
+
* Gets the contract with the given address.
|
|
5109
|
+
*
|
|
5110
|
+
* @param recordName The name of the record that the contract is stored in.
|
|
5111
|
+
* @param address The address of the contract.
|
|
5112
|
+
* @param options The options for the request.
|
|
5113
|
+
*
|
|
5114
|
+
* @dochash actions/xp
|
|
5115
|
+
* @docname xp.getContract
|
|
5116
|
+
*/
|
|
5117
|
+
function xpGetContract(recordName, address, options = {}) {
|
|
5118
|
+
const task = context.createTask();
|
|
5119
|
+
const event = recordsCallProcedure({
|
|
5120
|
+
getContract: {
|
|
5121
|
+
input: {
|
|
5122
|
+
recordName,
|
|
5123
|
+
address,
|
|
5124
|
+
},
|
|
5125
|
+
},
|
|
5126
|
+
}, options, task.taskId);
|
|
5127
|
+
return addAsyncAction(task, event);
|
|
5128
|
+
}
|
|
5129
|
+
/**
|
|
5130
|
+
* Gets a list of contracts from the given record.
|
|
5131
|
+
*
|
|
5132
|
+
* @param recordName The name of the record that the contracts are stored in.
|
|
5133
|
+
* @param address The address that the contracts should be listed after. If null, then the first page of contracts will be returned.
|
|
5134
|
+
* @param options The options for the request.
|
|
5135
|
+
* @returns A promise that resolves with the list of contracts.
|
|
5136
|
+
*
|
|
5137
|
+
* @dochash actions/xp
|
|
5138
|
+
* @docname xp.listContracts
|
|
5139
|
+
*/
|
|
5140
|
+
function xpListContracts(recordName, address = null, options = {}) {
|
|
5141
|
+
const task = context.createTask();
|
|
5142
|
+
const event = recordsCallProcedure({
|
|
5143
|
+
listContracts: {
|
|
5144
|
+
input: {
|
|
5145
|
+
recordName,
|
|
5146
|
+
address,
|
|
5147
|
+
},
|
|
5148
|
+
},
|
|
5149
|
+
}, options, task.taskId);
|
|
5150
|
+
return addAsyncAction(task, event);
|
|
5151
|
+
}
|
|
5152
|
+
/**
|
|
5153
|
+
* Gets the pricing for the given contract.
|
|
5154
|
+
*
|
|
5155
|
+
* @param recordName The name of the record that the contracts are stored in.
|
|
5156
|
+
* @param address The address of the contract.
|
|
5157
|
+
* @param options The options for the request.
|
|
5158
|
+
* @returns A promise that resolves with the pricing details for the contract.
|
|
5159
|
+
*
|
|
5160
|
+
* @dochash actions/xp
|
|
5161
|
+
* @docname xp.getContractPricing
|
|
5162
|
+
*/
|
|
5163
|
+
function xpGetContractPricing(recordName, address = null, options = {}) {
|
|
5164
|
+
const task = context.createTask();
|
|
5165
|
+
const event = recordsCallProcedure({
|
|
5166
|
+
getContractPricing: {
|
|
5167
|
+
input: {
|
|
5168
|
+
recordName,
|
|
5169
|
+
address,
|
|
5170
|
+
},
|
|
5171
|
+
},
|
|
5172
|
+
}, options, task.taskId);
|
|
5173
|
+
return addAsyncAction(task, event);
|
|
5174
|
+
}
|
|
5175
|
+
/**
|
|
5176
|
+
* Attempts to purchase a contract via the xpExchange.
|
|
5177
|
+
*
|
|
5178
|
+
* @param request The request for the purchase.
|
|
5179
|
+
* @param options The options for the request.
|
|
5180
|
+
* @returns A promise that resolves when the purchase is complete. Returns a URL to redirect the user to if additional payment details need to be collected.
|
|
5181
|
+
*
|
|
5182
|
+
* @dochash actions/xp
|
|
5183
|
+
* @docname xp.purchaseContract
|
|
5184
|
+
*/
|
|
5185
|
+
function xpPurchaseContract(request, options = {}) {
|
|
5186
|
+
const task = context.createTask();
|
|
5187
|
+
const event = recordsCallProcedure({
|
|
5188
|
+
purchaseContract: {
|
|
5189
|
+
input: {
|
|
5190
|
+
recordName: request.recordName,
|
|
5191
|
+
contract: {
|
|
5192
|
+
address: request.address,
|
|
5193
|
+
expectedCost: request.expectedCost,
|
|
5194
|
+
currency: request.currency,
|
|
5195
|
+
},
|
|
5196
|
+
returnUrl: request.returnUrl,
|
|
5197
|
+
successUrl: request.successUrl,
|
|
5198
|
+
},
|
|
5199
|
+
},
|
|
5200
|
+
}, options, task.taskId);
|
|
5201
|
+
return addAsyncAction(task, event);
|
|
5202
|
+
}
|
|
5203
|
+
/**
|
|
5204
|
+
* Cancels a contract contract via the xpExchange and refunds any funds.
|
|
5205
|
+
*
|
|
5206
|
+
* @param recordName The name of the record that the contract is stored in.
|
|
5207
|
+
* @param address The address of the contract to cancel.
|
|
5208
|
+
* @param options The options for the request.
|
|
5209
|
+
* @returns A promise that resolves when the contract is cancelled.
|
|
5210
|
+
*
|
|
5211
|
+
* @dochash actions/xp
|
|
5212
|
+
* @docname xp.cancelContract
|
|
5213
|
+
*/
|
|
5214
|
+
function xpCancelContract(recordName, address, options = {}) {
|
|
5215
|
+
const task = context.createTask();
|
|
5216
|
+
const event = recordsCallProcedure({
|
|
5217
|
+
cancelContract: {
|
|
5218
|
+
input: {
|
|
5219
|
+
recordName: recordName,
|
|
5220
|
+
address: address,
|
|
5221
|
+
},
|
|
5222
|
+
},
|
|
5223
|
+
}, options, task.taskId);
|
|
5224
|
+
return addAsyncAction(task, event);
|
|
5225
|
+
}
|
|
5226
|
+
/**
|
|
5227
|
+
* Creates a new invoice for the given contract.
|
|
5228
|
+
*
|
|
5229
|
+
* @param request The request for the invoice.
|
|
5230
|
+
* @param options The options for the request.
|
|
5231
|
+
* @returns A promise that resolves when the invoice is created.
|
|
5232
|
+
*
|
|
5233
|
+
* @dochash actions/xp
|
|
5234
|
+
* @docname xp.invoiceContract
|
|
5235
|
+
*/
|
|
5236
|
+
function xpInvoiceContract(request, options = {}) {
|
|
5237
|
+
const task = context.createTask();
|
|
5238
|
+
const event = recordsCallProcedure({
|
|
5239
|
+
invoiceContract: {
|
|
5240
|
+
input: {
|
|
5241
|
+
contractId: request.contractId,
|
|
5242
|
+
amount: request.amount,
|
|
5243
|
+
note: request.note,
|
|
5244
|
+
payoutDestination: request.payoutDestination,
|
|
5245
|
+
},
|
|
5246
|
+
},
|
|
5247
|
+
}, options, task.taskId);
|
|
5248
|
+
return addAsyncAction(task, event);
|
|
5249
|
+
}
|
|
5250
|
+
/**
|
|
5251
|
+
* Voids (cancels) an invoice.
|
|
5252
|
+
*
|
|
5253
|
+
* @param invoiceId The ID of the invoice to void.
|
|
5254
|
+
* @param options The options for the request.
|
|
5255
|
+
* @returns A promise that resolves when the invoice is voided.
|
|
5256
|
+
*
|
|
5257
|
+
* @dochash actions/xp
|
|
5258
|
+
* @docname xp.voidInvoice
|
|
5259
|
+
*/
|
|
5260
|
+
function xpCancelInvoice(invoiceId, options = {}) {
|
|
5261
|
+
const task = context.createTask();
|
|
5262
|
+
const event = recordsCallProcedure({
|
|
5263
|
+
cancelInvoice: {
|
|
5264
|
+
input: {
|
|
5265
|
+
invoiceId,
|
|
5266
|
+
},
|
|
5267
|
+
},
|
|
5268
|
+
}, options, task.taskId);
|
|
5269
|
+
return addAsyncAction(task, event);
|
|
5270
|
+
}
|
|
5271
|
+
/**
|
|
5272
|
+
* Lists the invoices for the given contract.
|
|
5273
|
+
*
|
|
5274
|
+
* @param contractId The ID of the contract to list invoices for.
|
|
5275
|
+
* @param options The options for the request.
|
|
5276
|
+
* @returns A promise that resolves with the invoices for the contract.
|
|
5277
|
+
*
|
|
5278
|
+
* @dochash actions/xp
|
|
5279
|
+
* @docname xp.listInvoices
|
|
5280
|
+
*/
|
|
5281
|
+
function xpListInvoices(contractId, options = {}) {
|
|
5282
|
+
const task = context.createTask();
|
|
5283
|
+
const event = recordsCallProcedure({
|
|
5284
|
+
listContractInvoices: {
|
|
5285
|
+
input: {
|
|
5286
|
+
contractId,
|
|
5287
|
+
},
|
|
5288
|
+
},
|
|
5289
|
+
}, options, task.taskId);
|
|
5290
|
+
return addAsyncAction(task, event);
|
|
5291
|
+
}
|
|
5292
|
+
/**
|
|
5293
|
+
* Pays an invoice. This will attempt to transfer funds from the contract account to the user holding the contract.
|
|
5294
|
+
*
|
|
5295
|
+
* @param invoiceId The ID of the invoice to pay.
|
|
5296
|
+
* @param options The options for the request.
|
|
5297
|
+
* @returns A promise that resolves when the invoice is paid.
|
|
5298
|
+
*/
|
|
5299
|
+
function xpPayInvoice(invoiceId, options = {}) {
|
|
5300
|
+
const task = context.createTask();
|
|
5301
|
+
const event = recordsCallProcedure({
|
|
5302
|
+
payContractInvoice: {
|
|
5303
|
+
input: {
|
|
5304
|
+
invoiceId,
|
|
5305
|
+
},
|
|
5306
|
+
},
|
|
5307
|
+
}, options, task.taskId);
|
|
5308
|
+
return addAsyncAction(task, event);
|
|
5309
|
+
}
|
|
5310
|
+
/**
|
|
5311
|
+
* Attempts to payout funds from the user's account to their linked payout destination.
|
|
5312
|
+
*
|
|
5313
|
+
* @param request The payout request.
|
|
5314
|
+
* @param options The options for the request.
|
|
5315
|
+
* @returns A promise that resolves when the payout is complete.
|
|
5316
|
+
*
|
|
5317
|
+
* @dochash actions/xp
|
|
5318
|
+
* @docname xp.payout
|
|
5319
|
+
*/
|
|
5320
|
+
function xpPayout(request, options = {}) {
|
|
5321
|
+
const task = context.createTask();
|
|
5322
|
+
const event = recordsCallProcedure({
|
|
5323
|
+
payoutAccount: {
|
|
5324
|
+
input: {
|
|
5325
|
+
amount: request.amount,
|
|
5326
|
+
destination: request.destination,
|
|
5327
|
+
},
|
|
5328
|
+
},
|
|
5329
|
+
}, options, task.taskId);
|
|
5330
|
+
return addAsyncAction(task, event);
|
|
5331
|
+
}
|
|
5332
|
+
/**
|
|
5333
|
+
* Attempts to retrieve the account balances for the user's account.
|
|
5334
|
+
*
|
|
5335
|
+
* @param options The options for the request.
|
|
5336
|
+
* @returns A promise that resolves with the account balances.
|
|
5337
|
+
*
|
|
5338
|
+
* @dochash actions/xp
|
|
5339
|
+
* @docname xp.getAccountBalances
|
|
5340
|
+
*/
|
|
5341
|
+
function xpGetAccountBalances(options = {}) {
|
|
5342
|
+
const task = context.createTask();
|
|
5343
|
+
const event = recordsCallProcedure({
|
|
5344
|
+
getBalances: {
|
|
5345
|
+
input: {},
|
|
5346
|
+
},
|
|
5347
|
+
}, options, task.taskId);
|
|
5348
|
+
return addAsyncAction(task, event);
|
|
5349
|
+
}
|
|
5027
5350
|
/**
|
|
5028
5351
|
* Specifies that the given prefix should be used to indicate that the tag contains script content.
|
|
5029
5352
|
* Use this function to specify custom prefixes that function similarly to `@` or `🧬`.
|
|
@@ -5056,8 +5379,8 @@ export function createDefaultLibrary(context) {
|
|
|
5056
5379
|
}
|
|
5057
5380
|
const task = context.createTask();
|
|
5058
5381
|
const event = calcRegisterPrefix(prefix, {
|
|
5059
|
-
language:
|
|
5060
|
-
name: options
|
|
5382
|
+
language: options?.language || 'javascript',
|
|
5383
|
+
name: options?.name,
|
|
5061
5384
|
}, task.taskId);
|
|
5062
5385
|
return addAsyncAction(task, event);
|
|
5063
5386
|
}
|
|
@@ -5303,6 +5626,23 @@ export function createDefaultLibrary(context) {
|
|
|
5303
5626
|
const event = calcDefineGlobalBot(name, botId, task.taskId);
|
|
5304
5627
|
return addAsyncAction(task, event);
|
|
5305
5628
|
}
|
|
5629
|
+
/**
|
|
5630
|
+
* Signs out the current user by revoking their session.
|
|
5631
|
+
* Returns a promise that resolves when the sign out request has been processed.
|
|
5632
|
+
*
|
|
5633
|
+
* @example Sign out the current user
|
|
5634
|
+
* await os.signOut();
|
|
5635
|
+
* os.toast("Signed out!");
|
|
5636
|
+
*
|
|
5637
|
+
* @dochash actions/os/records
|
|
5638
|
+
* @docgroup 01-records
|
|
5639
|
+
* @docname os.signOut
|
|
5640
|
+
*/
|
|
5641
|
+
function signOut() {
|
|
5642
|
+
const task = context.createTask();
|
|
5643
|
+
const event = calcSignOut(task.taskId);
|
|
5644
|
+
return addAsyncAction(task, event);
|
|
5645
|
+
}
|
|
5306
5646
|
/**
|
|
5307
5647
|
* Creates a record with the given name. If a studio is specified, then the record will be created in the given studio.
|
|
5308
5648
|
* If not specified, then the record will be owned by the current user.
|
|
@@ -5451,7 +5791,7 @@ export function createDefaultLibrary(context) {
|
|
|
5451
5791
|
*/
|
|
5452
5792
|
function grantPermission(recordName, permission, options) {
|
|
5453
5793
|
const task = context.createTask();
|
|
5454
|
-
const event = calcGrantRecordPermission(recordName, permission, options
|
|
5794
|
+
const event = calcGrantRecordPermission(recordName, permission, options ?? {}, task.taskId);
|
|
5455
5795
|
return addAsyncAction(task, event);
|
|
5456
5796
|
}
|
|
5457
5797
|
/**
|
|
@@ -5469,7 +5809,7 @@ export function createDefaultLibrary(context) {
|
|
|
5469
5809
|
*/
|
|
5470
5810
|
function revokePermission(recordName, permissionId, options) {
|
|
5471
5811
|
const task = context.createTask();
|
|
5472
|
-
const event = calcRevokeRecordPermission(recordName, permissionId, options
|
|
5812
|
+
const event = calcRevokeRecordPermission(recordName, permissionId, options ?? {}, task.taskId);
|
|
5473
5813
|
return addAsyncAction(task, event);
|
|
5474
5814
|
}
|
|
5475
5815
|
/**
|
|
@@ -5525,7 +5865,7 @@ export function createDefaultLibrary(context) {
|
|
|
5525
5865
|
*/
|
|
5526
5866
|
function grantInstAdminPermission(recordName, options) {
|
|
5527
5867
|
const task = context.createTask();
|
|
5528
|
-
const event = calcGrantInstAdminPermission(recordName, options
|
|
5868
|
+
const event = calcGrantInstAdminPermission(recordName, options ?? {}, task.taskId);
|
|
5529
5869
|
return addAsyncAction(task, event);
|
|
5530
5870
|
}
|
|
5531
5871
|
/**
|
|
@@ -5551,7 +5891,7 @@ export function createDefaultLibrary(context) {
|
|
|
5551
5891
|
*/
|
|
5552
5892
|
function grantUserRole(recordName, role, userId, expireTimeMs = null, options) {
|
|
5553
5893
|
const task = context.createTask();
|
|
5554
|
-
const event = calcGrantUserRole(recordName, role, userId, expireTimeMs, options
|
|
5894
|
+
const event = calcGrantUserRole(recordName, role, userId, expireTimeMs, options ?? {}, task.taskId);
|
|
5555
5895
|
return addAsyncAction(task, event);
|
|
5556
5896
|
}
|
|
5557
5897
|
/**
|
|
@@ -5573,7 +5913,7 @@ export function createDefaultLibrary(context) {
|
|
|
5573
5913
|
*/
|
|
5574
5914
|
function revokeUserRole(recordName, role, userId, options) {
|
|
5575
5915
|
const task = context.createTask();
|
|
5576
|
-
const event = calcRevokeUserRole(recordName, role, userId, options
|
|
5916
|
+
const event = calcRevokeUserRole(recordName, role, userId, options ?? {}, task.taskId);
|
|
5577
5917
|
return addAsyncAction(task, event);
|
|
5578
5918
|
}
|
|
5579
5919
|
/**
|
|
@@ -5627,7 +5967,7 @@ export function createDefaultLibrary(context) {
|
|
|
5627
5967
|
*/
|
|
5628
5968
|
function revokeInstRole(recordName, role, inst, options) {
|
|
5629
5969
|
const task = context.createTask();
|
|
5630
|
-
const event = calcRevokeInstRole(recordName, role, inst, options
|
|
5970
|
+
const event = calcRevokeInstRole(recordName, role, inst, options ?? {}, task.taskId);
|
|
5631
5971
|
return addAsyncAction(task, event);
|
|
5632
5972
|
}
|
|
5633
5973
|
/**
|
|
@@ -5730,7 +6070,6 @@ export function createDefaultLibrary(context) {
|
|
|
5730
6070
|
* @param endpointOrOptions The options that should be used. Optional.
|
|
5731
6071
|
*/
|
|
5732
6072
|
function baseRecordData(recordKey, address, data, requiresApproval, endpointOrOptions = null) {
|
|
5733
|
-
var _a;
|
|
5734
6073
|
const task = context.createTask();
|
|
5735
6074
|
let options = {};
|
|
5736
6075
|
if (hasValue(endpointOrOptions)) {
|
|
@@ -5743,7 +6082,7 @@ export function createDefaultLibrary(context) {
|
|
|
5743
6082
|
if (hasValue(marker)) {
|
|
5744
6083
|
options.markers = [
|
|
5745
6084
|
endpointOrOptions.marker,
|
|
5746
|
-
...(
|
|
6085
|
+
...(endpointOrOptions.markers ?? []),
|
|
5747
6086
|
];
|
|
5748
6087
|
}
|
|
5749
6088
|
}
|
|
@@ -6163,7 +6502,7 @@ export function createDefaultLibrary(context) {
|
|
|
6163
6502
|
*/
|
|
6164
6503
|
function recordWebhook(recordName, webhook, options) {
|
|
6165
6504
|
const task = context.createTask();
|
|
6166
|
-
const event = calcRecordWebhook(recordName, webhook, options
|
|
6505
|
+
const event = calcRecordWebhook(recordName, webhook, options ?? {}, task.taskId);
|
|
6167
6506
|
const final = addAsyncResultAction(task, event);
|
|
6168
6507
|
final[ORIGINAL_OBJECT] = event;
|
|
6169
6508
|
return final;
|
|
@@ -6184,7 +6523,7 @@ export function createDefaultLibrary(context) {
|
|
|
6184
6523
|
*/
|
|
6185
6524
|
function runWebhook(recordName, address, input, options) {
|
|
6186
6525
|
const task = context.createTask();
|
|
6187
|
-
const event = calcRunWebhook(recordName, address, input, options
|
|
6526
|
+
const event = calcRunWebhook(recordName, address, input, options ?? {}, task.taskId);
|
|
6188
6527
|
const final = addAsyncResultAction(task, event);
|
|
6189
6528
|
final[ORIGINAL_OBJECT] = event;
|
|
6190
6529
|
return final;
|
|
@@ -6204,7 +6543,7 @@ export function createDefaultLibrary(context) {
|
|
|
6204
6543
|
*/
|
|
6205
6544
|
function getWebhook(recordName, address, options) {
|
|
6206
6545
|
const task = context.createTask();
|
|
6207
|
-
const event = calcGetWebhook(recordName, address, options
|
|
6546
|
+
const event = calcGetWebhook(recordName, address, options ?? {}, task.taskId);
|
|
6208
6547
|
const final = addAsyncResultAction(task, event);
|
|
6209
6548
|
final[ORIGINAL_OBJECT] = event;
|
|
6210
6549
|
return final;
|
|
@@ -6221,7 +6560,7 @@ export function createDefaultLibrary(context) {
|
|
|
6221
6560
|
*/
|
|
6222
6561
|
function eraseWebhook(recordName, address, options) {
|
|
6223
6562
|
const task = context.createTask();
|
|
6224
|
-
const event = calcEraseWebhook(recordName, address, options
|
|
6563
|
+
const event = calcEraseWebhook(recordName, address, options ?? {}, task.taskId);
|
|
6225
6564
|
const final = addAsyncResultAction(task, event);
|
|
6226
6565
|
final[ORIGINAL_OBJECT] = event;
|
|
6227
6566
|
return final;
|
|
@@ -6240,7 +6579,7 @@ export function createDefaultLibrary(context) {
|
|
|
6240
6579
|
*/
|
|
6241
6580
|
function listWebhooks(recordName, startingAddress = null, options) {
|
|
6242
6581
|
const task = context.createTask();
|
|
6243
|
-
const event = calcListWebhooks(recordName, startingAddress, options
|
|
6582
|
+
const event = calcListWebhooks(recordName, startingAddress, options ?? {}, task.taskId);
|
|
6244
6583
|
const final = addAsyncResultAction(task, event);
|
|
6245
6584
|
final[ORIGINAL_OBJECT] = event;
|
|
6246
6585
|
return final;
|
|
@@ -6261,7 +6600,7 @@ export function createDefaultLibrary(context) {
|
|
|
6261
6600
|
*/
|
|
6262
6601
|
function listWebhooksByMarker(recordName, marker, startingAddress = null, options) {
|
|
6263
6602
|
const task = context.createTask();
|
|
6264
|
-
const event = calcListWebhooksByMarker(recordName, marker, startingAddress, options
|
|
6603
|
+
const event = calcListWebhooksByMarker(recordName, marker, startingAddress, options ?? {}, task.taskId);
|
|
6265
6604
|
const final = addAsyncResultAction(task, event);
|
|
6266
6605
|
final[ORIGINAL_OBJECT] = event;
|
|
6267
6606
|
return final;
|
|
@@ -6295,7 +6634,7 @@ export function createDefaultLibrary(context) {
|
|
|
6295
6634
|
*/
|
|
6296
6635
|
function recordNotification(recordName, notification, options) {
|
|
6297
6636
|
const task = context.createTask();
|
|
6298
|
-
const event = calcRecordNotification(recordName, notification, options
|
|
6637
|
+
const event = calcRecordNotification(recordName, notification, options ?? {}, task.taskId);
|
|
6299
6638
|
const final = addAsyncResultAction(task, event);
|
|
6300
6639
|
final[ORIGINAL_OBJECT] = event;
|
|
6301
6640
|
return final;
|
|
@@ -6315,7 +6654,7 @@ export function createDefaultLibrary(context) {
|
|
|
6315
6654
|
*/
|
|
6316
6655
|
function getNotification(recordName, address, options) {
|
|
6317
6656
|
const task = context.createTask();
|
|
6318
|
-
const event = calcGetNotification(recordName, address, options
|
|
6657
|
+
const event = calcGetNotification(recordName, address, options ?? {}, task.taskId);
|
|
6319
6658
|
const final = addAsyncResultAction(task, event);
|
|
6320
6659
|
final[ORIGINAL_OBJECT] = event;
|
|
6321
6660
|
return final;
|
|
@@ -6332,7 +6671,7 @@ export function createDefaultLibrary(context) {
|
|
|
6332
6671
|
*/
|
|
6333
6672
|
function eraseNotification(recordName, address, options) {
|
|
6334
6673
|
const task = context.createTask();
|
|
6335
|
-
const event = calcEraseNotification(recordName, address, options
|
|
6674
|
+
const event = calcEraseNotification(recordName, address, options ?? {}, task.taskId);
|
|
6336
6675
|
const final = addAsyncResultAction(task, event);
|
|
6337
6676
|
final[ORIGINAL_OBJECT] = event;
|
|
6338
6677
|
return final;
|
|
@@ -6351,7 +6690,7 @@ export function createDefaultLibrary(context) {
|
|
|
6351
6690
|
*/
|
|
6352
6691
|
function listNotifications(recordName, startingAddress = null, options) {
|
|
6353
6692
|
const task = context.createTask();
|
|
6354
|
-
const event = calcListNotifications(recordName, startingAddress, options
|
|
6693
|
+
const event = calcListNotifications(recordName, startingAddress, options ?? {}, task.taskId);
|
|
6355
6694
|
const final = addAsyncResultAction(task, event);
|
|
6356
6695
|
final[ORIGINAL_OBJECT] = event;
|
|
6357
6696
|
return final;
|
|
@@ -6372,7 +6711,7 @@ export function createDefaultLibrary(context) {
|
|
|
6372
6711
|
*/
|
|
6373
6712
|
function listNotificationsByMarker(recordName, marker, startingAddress = null, options) {
|
|
6374
6713
|
const task = context.createTask();
|
|
6375
|
-
const event = calcListNotificationsByMarker(recordName, marker, startingAddress, options
|
|
6714
|
+
const event = calcListNotificationsByMarker(recordName, marker, startingAddress, options ?? {}, task.taskId);
|
|
6376
6715
|
const final = addAsyncResultAction(task, event);
|
|
6377
6716
|
final[ORIGINAL_OBJECT] = event;
|
|
6378
6717
|
return final;
|
|
@@ -6395,7 +6734,7 @@ export function createDefaultLibrary(context) {
|
|
|
6395
6734
|
*/
|
|
6396
6735
|
function subscribeToNotification(recordName, address, options) {
|
|
6397
6736
|
const task = context.createTask();
|
|
6398
|
-
const event = calcSubscribeToNotification(recordName, address, options
|
|
6737
|
+
const event = calcSubscribeToNotification(recordName, address, options ?? {}, task.taskId);
|
|
6399
6738
|
const final = addAsyncResultAction(task, event);
|
|
6400
6739
|
final[ORIGINAL_OBJECT] = event;
|
|
6401
6740
|
return final;
|
|
@@ -6414,7 +6753,7 @@ export function createDefaultLibrary(context) {
|
|
|
6414
6753
|
*/
|
|
6415
6754
|
function unsubscribeFromNotification(subscriptionId, options) {
|
|
6416
6755
|
const task = context.createTask();
|
|
6417
|
-
const event = calcUnsubscribeFromNotification(subscriptionId, options
|
|
6756
|
+
const event = calcUnsubscribeFromNotification(subscriptionId, options ?? {}, task.taskId);
|
|
6418
6757
|
const final = addAsyncResultAction(task, event);
|
|
6419
6758
|
final[ORIGINAL_OBJECT] = event;
|
|
6420
6759
|
return final;
|
|
@@ -6441,7 +6780,7 @@ export function createDefaultLibrary(context) {
|
|
|
6441
6780
|
*/
|
|
6442
6781
|
function sendNotification(recordName, address, payload, options) {
|
|
6443
6782
|
const task = context.createTask();
|
|
6444
|
-
const event = calcSendNotification(recordName, address, payload, options
|
|
6783
|
+
const event = calcSendNotification(recordName, address, payload, options ?? {}, task.taskId);
|
|
6445
6784
|
const final = addAsyncResultAction(task, event);
|
|
6446
6785
|
final[ORIGINAL_OBJECT] = event;
|
|
6447
6786
|
return final;
|
|
@@ -6462,7 +6801,7 @@ export function createDefaultLibrary(context) {
|
|
|
6462
6801
|
*/
|
|
6463
6802
|
function listNotificationSubscriptions(recordName, address, options) {
|
|
6464
6803
|
const task = context.createTask();
|
|
6465
|
-
const event = calcListNotificationSubscriptions(recordName, address, options
|
|
6804
|
+
const event = calcListNotificationSubscriptions(recordName, address, options ?? {}, task.taskId);
|
|
6466
6805
|
const final = addAsyncResultAction(task, event);
|
|
6467
6806
|
final[ORIGINAL_OBJECT] = event;
|
|
6468
6807
|
return final;
|
|
@@ -6481,7 +6820,7 @@ export function createDefaultLibrary(context) {
|
|
|
6481
6820
|
*/
|
|
6482
6821
|
function listUserNotificationSubscriptions(options) {
|
|
6483
6822
|
const task = context.createTask();
|
|
6484
|
-
const event = calcListUserNotificationSubscriptions(options
|
|
6823
|
+
const event = calcListUserNotificationSubscriptions(options ?? {}, task.taskId);
|
|
6485
6824
|
const final = addAsyncResultAction(task, event);
|
|
6486
6825
|
final[ORIGINAL_OBJECT] = event;
|
|
6487
6826
|
return final;
|
|
@@ -6567,7 +6906,6 @@ export function createDefaultLibrary(context) {
|
|
|
6567
6906
|
* @docname os.recordFile
|
|
6568
6907
|
*/
|
|
6569
6908
|
function recordFile(recordKeyOrName, data, options, endpoint = null) {
|
|
6570
|
-
var _a;
|
|
6571
6909
|
if (!hasValue(recordKeyOrName)) {
|
|
6572
6910
|
throw new Error('recordKeyOrName must be provided.');
|
|
6573
6911
|
}
|
|
@@ -6584,7 +6922,7 @@ export function createDefaultLibrary(context) {
|
|
|
6584
6922
|
if (hasValue(marker)) {
|
|
6585
6923
|
recordOptions.markers = [
|
|
6586
6924
|
options.marker,
|
|
6587
|
-
...(
|
|
6925
|
+
...(options.markers ?? []),
|
|
6588
6926
|
];
|
|
6589
6927
|
}
|
|
6590
6928
|
}
|
|
@@ -6592,7 +6930,7 @@ export function createDefaultLibrary(context) {
|
|
|
6592
6930
|
recordOptions.endpoint = endpoint;
|
|
6593
6931
|
}
|
|
6594
6932
|
const task = context.createTask();
|
|
6595
|
-
const event = calcRecordFile(recordKeyOrName, convertToCopiableValue(data), options
|
|
6933
|
+
const event = calcRecordFile(recordKeyOrName, convertToCopiableValue(data), options?.description, options?.mimeType, recordOptions, task.taskId);
|
|
6596
6934
|
return addAsyncAction(task, event);
|
|
6597
6935
|
}
|
|
6598
6936
|
/**
|
|
@@ -6951,13 +7289,12 @@ export function createDefaultLibrary(context) {
|
|
|
6951
7289
|
* @docname os.recordPackageVersion
|
|
6952
7290
|
*/
|
|
6953
7291
|
function recordPackageVersion(request, options = {}) {
|
|
6954
|
-
var _a;
|
|
6955
7292
|
const task = context.createTask();
|
|
6956
7293
|
const event = calcRecordPackageVersion({
|
|
6957
7294
|
recordName: request.recordName,
|
|
6958
7295
|
address: request.address,
|
|
6959
7296
|
key: request.key,
|
|
6960
|
-
entitlements:
|
|
7297
|
+
entitlements: request.entitlements ?? [],
|
|
6961
7298
|
description: request.description,
|
|
6962
7299
|
markers: request.markers,
|
|
6963
7300
|
state: {
|
|
@@ -7042,7 +7379,7 @@ export function createDefaultLibrary(context) {
|
|
|
7042
7379
|
const task = context.createTask();
|
|
7043
7380
|
const event = calcRecordPackageContainer(recordName, address, typeof markers === 'string'
|
|
7044
7381
|
? [markers]
|
|
7045
|
-
: markers
|
|
7382
|
+
: markers ?? [PRIVATE_MARKER], options, task.taskId);
|
|
7046
7383
|
return addAsyncAction(task, event);
|
|
7047
7384
|
}
|
|
7048
7385
|
/**
|
|
@@ -7138,7 +7475,7 @@ export function createDefaultLibrary(context) {
|
|
|
7138
7475
|
*/
|
|
7139
7476
|
function installPackage(recordName, address, key, options = {}) {
|
|
7140
7477
|
const task = context.createTask();
|
|
7141
|
-
const event = calcInstallPackage(recordName, address, key
|
|
7478
|
+
const event = calcInstallPackage(recordName, address, key ?? null, options, task.taskId);
|
|
7142
7479
|
return addAsyncAction(task, event);
|
|
7143
7480
|
}
|
|
7144
7481
|
/**
|
|
@@ -7352,7 +7689,7 @@ export function createDefaultLibrary(context) {
|
|
|
7352
7689
|
recordName,
|
|
7353
7690
|
marker,
|
|
7354
7691
|
address: startingAddress,
|
|
7355
|
-
sort: options
|
|
7692
|
+
sort: options?.sort,
|
|
7356
7693
|
},
|
|
7357
7694
|
},
|
|
7358
7695
|
}, options, task.taskId);
|
|
@@ -7604,7 +7941,7 @@ export function createDefaultLibrary(context) {
|
|
|
7604
7941
|
recordName,
|
|
7605
7942
|
marker,
|
|
7606
7943
|
address: startingAddress,
|
|
7607
|
-
sort: options
|
|
7944
|
+
sort: options?.sort,
|
|
7608
7945
|
},
|
|
7609
7946
|
},
|
|
7610
7947
|
}, options, task.taskId);
|
|
@@ -7726,6 +8063,148 @@ export function createDefaultLibrary(context) {
|
|
|
7726
8063
|
const event = calcGetRecordsEndpoint(task.taskId);
|
|
7727
8064
|
return addAsyncAction(task, event);
|
|
7728
8065
|
}
|
|
8066
|
+
/**
|
|
8067
|
+
* Creates or updates a store item in a record.
|
|
8068
|
+
*
|
|
8069
|
+
* Returns a promise that resolves with an object that indicates whether the operation was successful or unsuccessful.
|
|
8070
|
+
*
|
|
8071
|
+
* @param recordName the name of the record that the store item should be created or updated in.
|
|
8072
|
+
* @param address the address of the item in the record.
|
|
8073
|
+
* @param item the item that should be stored in the record.
|
|
8074
|
+
* @param options the options that should be used to store the item.
|
|
8075
|
+
*
|
|
8076
|
+
* @example Record an item that can be purchased by anyone
|
|
8077
|
+
* await os.recordStoreItem('myRecord', 'myItem', {
|
|
8078
|
+
* name: 'My Item',
|
|
8079
|
+
* description: 'Description of my item!'
|
|
8080
|
+
* imageUrls: [],
|
|
8081
|
+
* currency: 'usd',
|
|
8082
|
+
* cost: 100, // $1.00
|
|
8083
|
+
* roleName: 'roleToBeGranted',
|
|
8084
|
+
* roleGrantTimeMs: null,
|
|
8085
|
+
* markers: ['publicRead']
|
|
8086
|
+
* });
|
|
8087
|
+
*
|
|
8088
|
+
* @dochash actions/os/records
|
|
8089
|
+
* @docgroup 01-store
|
|
8090
|
+
* @docname os.recordStoreItem
|
|
8091
|
+
*/
|
|
8092
|
+
function recordStoreItem(recordName, address, item, options = {}) {
|
|
8093
|
+
const task = context.createTask();
|
|
8094
|
+
const event = calcRecordStoreItem(recordName, address, item, options, task.taskId);
|
|
8095
|
+
return addAsyncAction(task, event);
|
|
8096
|
+
}
|
|
8097
|
+
/**
|
|
8098
|
+
* Gets the item with the given address from the specified record.
|
|
8099
|
+
*
|
|
8100
|
+
* Returns a promise that resolves with the item that was stored in the record.
|
|
8101
|
+
*
|
|
8102
|
+
* @param recordName the name of the record that the store item should be retrieved from.
|
|
8103
|
+
* @param address the address of the item in the record.
|
|
8104
|
+
* @param options the options that should be used to get the item.
|
|
8105
|
+
*
|
|
8106
|
+
* @example Get an item by address
|
|
8107
|
+
* const item = await os.getStoreItem('myRecord', 'myItem');
|
|
8108
|
+
*
|
|
8109
|
+
* @dochash actions/os/records
|
|
8110
|
+
* @docgroup 01-store
|
|
8111
|
+
* @docname os.getStoreItem
|
|
8112
|
+
*/
|
|
8113
|
+
function getStoreItem(recordName, address, options = {}) {
|
|
8114
|
+
const task = context.createTask();
|
|
8115
|
+
const event = calcGetStoreItem(recordName, address, options, task.taskId);
|
|
8116
|
+
return addAsyncAction(task, event);
|
|
8117
|
+
}
|
|
8118
|
+
/**
|
|
8119
|
+
* Deletes the item with the given address from the specified record.
|
|
8120
|
+
*
|
|
8121
|
+
* Returns a promise that resolves with the status of the operation.
|
|
8122
|
+
*
|
|
8123
|
+
* @param recordName the name of the record that the store item should be deleted from.
|
|
8124
|
+
* @param address the address of the item that should be deleted.
|
|
8125
|
+
* @param options the options that should be used to get the item.
|
|
8126
|
+
*
|
|
8127
|
+
* @example Delete an item by address
|
|
8128
|
+
* const result = await os.eraseStoreItem('myRecord', 'myItem');
|
|
8129
|
+
*
|
|
8130
|
+
* @dochash actions/os/records
|
|
8131
|
+
* @docgroup 01-store
|
|
8132
|
+
* @docname os.eraseStoreItem
|
|
8133
|
+
*/
|
|
8134
|
+
function eraseStoreItem(recordName, address, options = {}) {
|
|
8135
|
+
const task = context.createTask();
|
|
8136
|
+
const event = calcEraseStoreItem(recordName, address, options, task.taskId);
|
|
8137
|
+
return addAsyncAction(task, event);
|
|
8138
|
+
}
|
|
8139
|
+
/**
|
|
8140
|
+
* Gets a partial list of store items from the given record.
|
|
8141
|
+
* You must have permission to access all items in the record to list them.
|
|
8142
|
+
*
|
|
8143
|
+
* Returns a promise that contains the items in the list.
|
|
8144
|
+
*
|
|
8145
|
+
* @param recordName the name of the record that the store item should be deleted from.
|
|
8146
|
+
* @param startingAddress the address that the items should be listed after.
|
|
8147
|
+
* @param options the options that should be used to get the item.
|
|
8148
|
+
*
|
|
8149
|
+
* @example List all items in the record
|
|
8150
|
+
* const result = await os.listStoreItems('myRecord');
|
|
8151
|
+
*
|
|
8152
|
+
* @dochash actions/os/records
|
|
8153
|
+
* @docgroup 01-store
|
|
8154
|
+
* @docname os.listStoreItems
|
|
8155
|
+
*/
|
|
8156
|
+
function listStoreItems(recordName, startingAddress = null, options = {}) {
|
|
8157
|
+
const task = context.createTask();
|
|
8158
|
+
const event = calcListStoreItems(recordName, startingAddress, options, task.taskId);
|
|
8159
|
+
return addAsyncAction(task, event);
|
|
8160
|
+
}
|
|
8161
|
+
/**
|
|
8162
|
+
* Gets a partial list of store items that have the given marker from the given record.
|
|
8163
|
+
* You must have permission to access the given marker in the record to list them.
|
|
8164
|
+
*
|
|
8165
|
+
* Returns a promise that contains the items in the list.
|
|
8166
|
+
*
|
|
8167
|
+
* @param recordName the name of the record that the store item should be deleted from.
|
|
8168
|
+
* @param marker the marker that the items should have.
|
|
8169
|
+
* @param startingAddress the address that the items should be listed after.
|
|
8170
|
+
* @param options the options that should be used to get the item.
|
|
8171
|
+
*
|
|
8172
|
+
* @example List all items in the record with the 'publicRead' marker
|
|
8173
|
+
* const result = await os.listStoreItemsByMarker('myRecord', 'publicRead');
|
|
8174
|
+
*
|
|
8175
|
+
* @dochash actions/os/records
|
|
8176
|
+
* @docgroup 01-store
|
|
8177
|
+
* @docname os.listStoreItemsByMarker
|
|
8178
|
+
*/
|
|
8179
|
+
function listStoreItemsByMarker(recordName, marker, startingAddress = null, options = {}) {
|
|
8180
|
+
const task = context.createTask();
|
|
8181
|
+
const event = calcListStoreItemsByMarker(recordName, marker, startingAddress, options, task.taskId);
|
|
8182
|
+
return addAsyncAction(task, event);
|
|
8183
|
+
}
|
|
8184
|
+
/**
|
|
8185
|
+
* Attempts to purchase the given store item from the specified record.
|
|
8186
|
+
*
|
|
8187
|
+
* Returns a promise that resolves when the
|
|
8188
|
+
*
|
|
8189
|
+
* @param recordName the name of the record that the store item should be purchased from.
|
|
8190
|
+
* @param item the item that should be purchased from the store.
|
|
8191
|
+
* @param options the options that should be used to purchase the item.
|
|
8192
|
+
*
|
|
8193
|
+
* @example Purchase an item from the store
|
|
8194
|
+
* const item = await os.getStoreItem('myRecord', 'myItem');
|
|
8195
|
+
* const result = await os.purchaseStoreItem('myRecord', item);
|
|
8196
|
+
*
|
|
8197
|
+
* console.log(result);
|
|
8198
|
+
*
|
|
8199
|
+
* @dochash actions/os/records
|
|
8200
|
+
* @docgroup 01-store
|
|
8201
|
+
* @docname os.purchaseStoreItem
|
|
8202
|
+
*/
|
|
8203
|
+
function purchaseStoreItem(recordName, item, options = {}) {
|
|
8204
|
+
const task = context.createTask();
|
|
8205
|
+
const event = calcPurchaseStoreItem(recordName, item, options, task.taskId);
|
|
8206
|
+
return addAsyncAction(task, event);
|
|
8207
|
+
}
|
|
7729
8208
|
/**
|
|
7730
8209
|
* Converts the given geolocation to a [what3words](https://what3words.com/) address. Returns a promise that resolves with the 3 word address.
|
|
7731
8210
|
* @param location The latitude and longitude that should be converted to a 3 word address.
|
|
@@ -8020,7 +8499,7 @@ export function createDefaultLibrary(context) {
|
|
|
8020
8499
|
const botIds = Array.isArray(botOrBots)
|
|
8021
8500
|
? botOrBots.map((b) => (isBot(b) ? b.id : b))
|
|
8022
8501
|
: [isBot(botOrBots) ? botOrBots.id : botOrBots];
|
|
8023
|
-
const event = calcStartFormAnimation(botIds, nameOrIndex, options
|
|
8502
|
+
const event = calcStartFormAnimation(botIds, nameOrIndex, options ?? {}, task.taskId);
|
|
8024
8503
|
return addAsyncAction(task, event);
|
|
8025
8504
|
}
|
|
8026
8505
|
/**
|
|
@@ -8056,7 +8535,7 @@ export function createDefaultLibrary(context) {
|
|
|
8056
8535
|
const botIds = Array.isArray(botOrBots)
|
|
8057
8536
|
? botOrBots.map((b) => (isBot(b) ? b.id : b))
|
|
8058
8537
|
: [isBot(botOrBots) ? botOrBots.id : botOrBots];
|
|
8059
|
-
const event = calcStopFormAnimation(botIds, options
|
|
8538
|
+
const event = calcStopFormAnimation(botIds, options ?? {}, task.taskId);
|
|
8060
8539
|
return addAsyncAction(task, event);
|
|
8061
8540
|
}
|
|
8062
8541
|
/**
|
|
@@ -8077,14 +8556,13 @@ export function createDefaultLibrary(context) {
|
|
|
8077
8556
|
* @docorder 2
|
|
8078
8557
|
*/
|
|
8079
8558
|
function listFormAnimations(botOrAddress) {
|
|
8080
|
-
var _a;
|
|
8081
8559
|
let address;
|
|
8082
8560
|
let bot = isBot(botOrAddress)
|
|
8083
8561
|
? botOrAddress
|
|
8084
8562
|
: context.state[botOrAddress];
|
|
8085
8563
|
if (bot) {
|
|
8086
8564
|
address =
|
|
8087
|
-
|
|
8565
|
+
calculateStringTagValue(null, bot, 'auxFormAnimationAddress', null) ?? calculateStringTagValue(null, bot, 'auxFormAddress', null);
|
|
8088
8566
|
}
|
|
8089
8567
|
else if (typeof botOrAddress === 'string') {
|
|
8090
8568
|
address = botOrAddress;
|
|
@@ -8359,7 +8837,7 @@ export function createDefaultLibrary(context) {
|
|
|
8359
8837
|
instName = getCurrentServer();
|
|
8360
8838
|
recordName = getCurrentInstRecord();
|
|
8361
8839
|
branchName = recordOrName;
|
|
8362
|
-
markers = inst
|
|
8840
|
+
markers = inst?.markers;
|
|
8363
8841
|
}
|
|
8364
8842
|
else if (!inst && !name) {
|
|
8365
8843
|
// Called as getSharedDocument(name)
|
|
@@ -8375,7 +8853,7 @@ export function createDefaultLibrary(context) {
|
|
|
8375
8853
|
recordName = recordOrName;
|
|
8376
8854
|
instName = inst;
|
|
8377
8855
|
branchName = name;
|
|
8378
|
-
markers = options
|
|
8856
|
+
markers = options?.markers;
|
|
8379
8857
|
}
|
|
8380
8858
|
const event = loadSharedDocument(recordName, instName, `doc/${branchName}`, task.taskId, markers);
|
|
8381
8859
|
return addAsyncAction(task, event);
|
|
@@ -8548,33 +9026,35 @@ export function createDefaultLibrary(context) {
|
|
|
8548
9026
|
return addAsyncAction(task, event);
|
|
8549
9027
|
}
|
|
8550
9028
|
/**
|
|
8551
|
-
* Creates an inst update that, when applied, ensures the given bots are created on this inst. Returns a promise that resolves with the inst update.
|
|
9029
|
+
* Creates an inst update that, when applied in addition to the previous update(s), ensures the given bots are created or updated on this inst. Returns a promise that resolves with the inst update.
|
|
8552
9030
|
*
|
|
8553
9031
|
* Note that you can apply the same update multiple times and you will end up with only one version of the bots saved in the update. Additionally, future changes to the bots will be preserved even if the update is applied again.
|
|
8554
9032
|
*
|
|
8555
9033
|
* This feature makes inst updates useful when you want to ensure that an experience starts in an initial state but also able to change over time.
|
|
8556
9034
|
*
|
|
8557
|
-
* Unlike {@link os.
|
|
8558
|
-
*
|
|
8559
|
-
* @param bots the list of bots that should be included in the update.
|
|
8560
|
-
*
|
|
8561
|
-
* @example Create an update with this bot and save it to a tag
|
|
8562
|
-
* const update = await os.createInitializationUpdate([thisBot]);
|
|
8563
|
-
* tags.savedUpdate = update;
|
|
8564
|
-
*
|
|
8565
|
-
* @example Create an update with all the bots in the home dimension
|
|
8566
|
-
* const update = await os.createInitializationUpdate(getBots(inDimension('home')));
|
|
8567
|
-
* tags.savedUpdate = update;
|
|
9035
|
+
* Unlike {@link os.createInitializationUpdate}, this function creates an update that is linked to the previous update(s). This means that this update will overwrite the previous update(s) when applied to the same inst.
|
|
8568
9036
|
*
|
|
8569
|
-
* @
|
|
8570
|
-
* @
|
|
8571
|
-
* @docgroup 10-updates
|
|
9037
|
+
* @param previousUpdate The previous update or list of updates that this update should be based on and include.
|
|
9038
|
+
* @param bots The bots that reflect the final state that should be achieved when this update is applied in addition to the previous update(s).
|
|
8572
9039
|
*/
|
|
8573
|
-
function createInitializationUpdate(bots) {
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
9040
|
+
function createInitializationUpdate(previousUpdateOrBots, bots) {
|
|
9041
|
+
if (arguments.length === 2) {
|
|
9042
|
+
const convertedBots = bots.map((b) => isRuntimeBot(b) ? createBot(b.id, b.tags.toJSON(), b.space) : b);
|
|
9043
|
+
if (!Array.isArray(previousUpdateOrBots)) {
|
|
9044
|
+
previousUpdateOrBots = [previousUpdateOrBots];
|
|
9045
|
+
}
|
|
9046
|
+
const previousUpdates = previousUpdateOrBots;
|
|
9047
|
+
const update = constructInitializationUpdateFromPreviousUpdates(previousUpdates, convertedBots);
|
|
9048
|
+
return Promise.resolve(update);
|
|
9049
|
+
}
|
|
9050
|
+
else {
|
|
9051
|
+
const convertedBots = previousUpdateOrBots.map((b) => isRuntimeBot(b)
|
|
9052
|
+
? createBot(b.id, b.tags.toJSON(), b.space)
|
|
9053
|
+
: b);
|
|
9054
|
+
const task = context.createTask(true, true);
|
|
9055
|
+
const event = calcRemote(calcCreateInitalizationUpdate(convertedBots), undefined, undefined, task.taskId);
|
|
9056
|
+
return addAsyncAction(task, event);
|
|
9057
|
+
}
|
|
8578
9058
|
}
|
|
8579
9059
|
/**
|
|
8580
9060
|
* Applies the given updates to the current inst. Returns a promise that resolves once the updates have been applied.
|
|
@@ -8883,10 +9363,9 @@ export function createDefaultLibrary(context) {
|
|
|
8883
9363
|
}
|
|
8884
9364
|
}
|
|
8885
9365
|
async function _retryWebhook(options) {
|
|
8886
|
-
var _a, _b, _c, _d;
|
|
8887
9366
|
const retryCount = Math.min(options.retryCount, MAX_RETRY_COUNT);
|
|
8888
|
-
const timeToWait = Math.max(0, Math.min(
|
|
8889
|
-
const statusCodes =
|
|
9367
|
+
const timeToWait = Math.max(0, Math.min(options.retryAfterMs ?? DEFAULT_RETRY_AFTER_MS, MAX_RETRY_AFTER_MS));
|
|
9368
|
+
const statusCodes = options.retryStatusCodes ?? DEFUALT_RETRY_STATUS_CODES;
|
|
8890
9369
|
let retries = 0;
|
|
8891
9370
|
while (true) {
|
|
8892
9371
|
try {
|
|
@@ -8896,7 +9375,7 @@ export function createDefaultLibrary(context) {
|
|
|
8896
9375
|
if (retries >= retryCount) {
|
|
8897
9376
|
throw err;
|
|
8898
9377
|
}
|
|
8899
|
-
else if (!statusCodes.includes(
|
|
9378
|
+
else if (!statusCodes.includes(err.response?.status ?? 0)) {
|
|
8900
9379
|
throw err;
|
|
8901
9380
|
}
|
|
8902
9381
|
await sleep(timeToWait);
|
|
@@ -9721,7 +10200,7 @@ export function createDefaultLibrary(context) {
|
|
|
9721
10200
|
*/
|
|
9722
10201
|
function beginAudioRecording(options) {
|
|
9723
10202
|
const task = context.createTask();
|
|
9724
|
-
const action = calcBeginAudioRecording(options
|
|
10203
|
+
const action = calcBeginAudioRecording(options ?? {}, task.taskId);
|
|
9725
10204
|
return addAsyncAction(task, action);
|
|
9726
10205
|
}
|
|
9727
10206
|
/**
|
|
@@ -10119,11 +10598,10 @@ export function createDefaultLibrary(context) {
|
|
|
10119
10598
|
* @docname experiment.speakText
|
|
10120
10599
|
*/
|
|
10121
10600
|
function speakText(text, options) {
|
|
10122
|
-
|
|
10123
|
-
options = options !== null && options !== void 0 ? options : {};
|
|
10601
|
+
options = options ?? {};
|
|
10124
10602
|
const task = context.createTask();
|
|
10125
10603
|
const voice = typeof options.voice === 'object'
|
|
10126
|
-
?
|
|
10604
|
+
? options.voice?.name
|
|
10127
10605
|
: options.voice;
|
|
10128
10606
|
const action = calcSpeakText(text, {
|
|
10129
10607
|
...options,
|
|
@@ -12829,7 +13307,7 @@ export function createDefaultLibrary(context) {
|
|
|
12829
13307
|
*/
|
|
12830
13308
|
function joinRoom(roomName, options) {
|
|
12831
13309
|
const task = context.createTask();
|
|
12832
|
-
const event = calcJoinRoom(roomName, options
|
|
13310
|
+
const event = calcJoinRoom(roomName, options ?? {}, task.taskId);
|
|
12833
13311
|
return addAsyncAction(task, event);
|
|
12834
13312
|
}
|
|
12835
13313
|
/**
|
|
@@ -12853,7 +13331,7 @@ export function createDefaultLibrary(context) {
|
|
|
12853
13331
|
*/
|
|
12854
13332
|
function leaveRoom(roomName, options) {
|
|
12855
13333
|
const task = context.createTask();
|
|
12856
|
-
const event = calcLeaveRoom(roomName, options
|
|
13334
|
+
const event = calcLeaveRoom(roomName, options ?? {}, task.taskId);
|
|
12857
13335
|
return addAsyncAction(task, event);
|
|
12858
13336
|
}
|
|
12859
13337
|
/**
|