@casual-simulation/aux-runtime 3.8.2-alpha.19511653187 → 3.10.3-alpha.20787554310
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 +61 -6
- package/runtime/AuxLibrary.js +567 -107
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +2432 -671
- 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, 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,
|
|
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,
|
|
@@ -814,6 +818,12 @@ export function createDefaultLibrary(context) {
|
|
|
814
818
|
listUserStudios,
|
|
815
819
|
listStudioRecords,
|
|
816
820
|
getRecordsEndpoint,
|
|
821
|
+
recordStoreItem,
|
|
822
|
+
getStoreItem,
|
|
823
|
+
eraseStoreItem,
|
|
824
|
+
listStoreItems,
|
|
825
|
+
listStoreItemsByMarker,
|
|
826
|
+
purchaseStoreItem,
|
|
817
827
|
convertGeolocationToWhat3Words,
|
|
818
828
|
raycastFromCamera,
|
|
819
829
|
raycast,
|
|
@@ -859,6 +869,20 @@ export function createDefaultLibrary(context) {
|
|
|
859
869
|
_attachDebugger,
|
|
860
870
|
_detachDebugger,
|
|
861
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
|
+
},
|
|
862
886
|
portal: {
|
|
863
887
|
registerPrefix,
|
|
864
888
|
},
|
|
@@ -969,7 +993,7 @@ export function createDefaultLibrary(context) {
|
|
|
969
993
|
},
|
|
970
994
|
},
|
|
971
995
|
tagSpecificApi: {
|
|
972
|
-
create: tagAsInterpretableFunction((options) => (...args) =>
|
|
996
|
+
create: tagAsInterpretableFunction((options) => (...args) => create(options.bot?.id, ...args), (options) => (...args) => unwind(create(options.bot?.id, ...args))),
|
|
973
997
|
setTimeout: botTimer('timeout', setTimeout, true),
|
|
974
998
|
setInterval: botTimer('interval', setInterval, false),
|
|
975
999
|
watchPortal: watchPortalBots(),
|
|
@@ -1077,6 +1101,7 @@ export function createDefaultLibrary(context) {
|
|
|
1077
1101
|
let valid = true;
|
|
1078
1102
|
const generatorWrapper = {
|
|
1079
1103
|
[Symbol.iterator]: () => generatorWrapper,
|
|
1104
|
+
[Symbol.dispose]: () => { },
|
|
1080
1105
|
next(value) {
|
|
1081
1106
|
if (!valid) {
|
|
1082
1107
|
return {
|
|
@@ -1832,7 +1857,7 @@ export function createDefaultLibrary(context) {
|
|
|
1832
1857
|
* @docname getJSON
|
|
1833
1858
|
*/
|
|
1834
1859
|
function getJSON(data) {
|
|
1835
|
-
if (hasValue(data
|
|
1860
|
+
if (hasValue(data?.[ORIGINAL_OBJECT])) {
|
|
1836
1861
|
return stableStringify(data[ORIGINAL_OBJECT]);
|
|
1837
1862
|
}
|
|
1838
1863
|
return stableStringify(data);
|
|
@@ -1851,7 +1876,7 @@ export function createDefaultLibrary(context) {
|
|
|
1851
1876
|
* @docname getFormattedJSON
|
|
1852
1877
|
*/
|
|
1853
1878
|
function getFormattedJSON(data) {
|
|
1854
|
-
if (hasValue(data
|
|
1879
|
+
if (hasValue(data?.[ORIGINAL_OBJECT])) {
|
|
1855
1880
|
return stableStringify(data[ORIGINAL_OBJECT], { space: 2 });
|
|
1856
1881
|
}
|
|
1857
1882
|
return stableStringify(data, { space: 2 });
|
|
@@ -1866,7 +1891,6 @@ export function createDefaultLibrary(context) {
|
|
|
1866
1891
|
* @docname getSnapshot
|
|
1867
1892
|
*/
|
|
1868
1893
|
function getSnapshot(bots) {
|
|
1869
|
-
var _a;
|
|
1870
1894
|
if (!Array.isArray(bots)) {
|
|
1871
1895
|
return getSnapshot([bots]);
|
|
1872
1896
|
}
|
|
@@ -1885,7 +1909,7 @@ export function createDefaultLibrary(context) {
|
|
|
1885
1909
|
}
|
|
1886
1910
|
let masks = isRuntimeBot(bot)
|
|
1887
1911
|
? bot[GET_TAG_MASKS_SYMBOL]()
|
|
1888
|
-
: cloneDeep(
|
|
1912
|
+
: cloneDeep(bot.masks ?? {});
|
|
1889
1913
|
if (Object.keys(masks).length > 0) {
|
|
1890
1914
|
b.masks = masks;
|
|
1891
1915
|
}
|
|
@@ -2130,7 +2154,7 @@ export function createDefaultLibrary(context) {
|
|
|
2130
2154
|
const final = addAsyncResultAction(task, action).then((result) => {
|
|
2131
2155
|
const choice = result.choices[0];
|
|
2132
2156
|
if (returnString) {
|
|
2133
|
-
return choice
|
|
2157
|
+
return choice?.content;
|
|
2134
2158
|
}
|
|
2135
2159
|
return choice;
|
|
2136
2160
|
});
|
|
@@ -2165,7 +2189,7 @@ export function createDefaultLibrary(context) {
|
|
|
2165
2189
|
continue;
|
|
2166
2190
|
}
|
|
2167
2191
|
if (returnString) {
|
|
2168
|
-
const content = choice
|
|
2192
|
+
const content = choice?.content;
|
|
2169
2193
|
if (!hasValue(content)) {
|
|
2170
2194
|
continue;
|
|
2171
2195
|
}
|
|
@@ -2246,7 +2270,7 @@ export function createDefaultLibrary(context) {
|
|
|
2246
2270
|
action = aiGenerateImage(prompt, negativePrompt, task.taskId);
|
|
2247
2271
|
}
|
|
2248
2272
|
else {
|
|
2249
|
-
let { endpoint, ...parameters } = options
|
|
2273
|
+
let { endpoint, ...parameters } = options ?? {};
|
|
2250
2274
|
action = aiGenerateImage({
|
|
2251
2275
|
...parameters,
|
|
2252
2276
|
prompt,
|
|
@@ -2256,23 +2280,19 @@ export function createDefaultLibrary(context) {
|
|
|
2256
2280
|
}, task.taskId);
|
|
2257
2281
|
}
|
|
2258
2282
|
const final = addAsyncResultAction(task, action).then((result) => {
|
|
2259
|
-
var _a;
|
|
2260
2283
|
if (returnObject) {
|
|
2261
2284
|
return {
|
|
2262
2285
|
...result,
|
|
2263
|
-
images: result.images.map((image) => {
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
url: toBase64Url(image.base64, (_a = image.mimeType) !== null && _a !== void 0 ? _a : 'image/png'),
|
|
2268
|
-
});
|
|
2269
|
-
}),
|
|
2286
|
+
images: result.images.map((image) => ({
|
|
2287
|
+
...image,
|
|
2288
|
+
url: toBase64Url(image.base64, image.mimeType ?? 'image/png'),
|
|
2289
|
+
})),
|
|
2270
2290
|
};
|
|
2271
2291
|
}
|
|
2272
2292
|
else {
|
|
2273
2293
|
const image = result.images[0];
|
|
2274
2294
|
const base64 = image.base64;
|
|
2275
|
-
return toBase64Url(base64,
|
|
2295
|
+
return toBase64Url(base64, image.mimeType ?? 'image/png');
|
|
2276
2296
|
}
|
|
2277
2297
|
});
|
|
2278
2298
|
final[ORIGINAL_OBJECT] = action;
|
|
@@ -2481,7 +2501,7 @@ export function createDefaultLibrary(context) {
|
|
|
2481
2501
|
*/
|
|
2482
2502
|
function tip(message, pixelX, pixelY, duration) {
|
|
2483
2503
|
const task = context.createTask();
|
|
2484
|
-
const action = tipMessage(convertToCopiableValue(message), pixelX
|
|
2504
|
+
const action = tipMessage(convertToCopiableValue(message), pixelX ?? null, pixelY ?? null, (duration ?? 2) * 1000, task.taskId);
|
|
2485
2505
|
return addAsyncAction(task, action);
|
|
2486
2506
|
}
|
|
2487
2507
|
/**
|
|
@@ -2769,7 +2789,7 @@ export function createDefaultLibrary(context) {
|
|
|
2769
2789
|
const finalOptions = {
|
|
2770
2790
|
duration: 1,
|
|
2771
2791
|
easing: 'quadratic',
|
|
2772
|
-
...(options
|
|
2792
|
+
...(options ?? {}),
|
|
2773
2793
|
};
|
|
2774
2794
|
let action;
|
|
2775
2795
|
if (botOrPosition === null) {
|
|
@@ -2954,6 +2974,7 @@ export function createDefaultLibrary(context) {
|
|
|
2954
2974
|
isCollaborative: null,
|
|
2955
2975
|
allowCollaborationUpgrade: null,
|
|
2956
2976
|
ab1BootstrapUrl: null,
|
|
2977
|
+
comID: null,
|
|
2957
2978
|
};
|
|
2958
2979
|
}
|
|
2959
2980
|
/**
|
|
@@ -3390,8 +3411,7 @@ export function createDefaultLibrary(context) {
|
|
|
3390
3411
|
* @docname os.getAuxFileForBots
|
|
3391
3412
|
*/
|
|
3392
3413
|
function getAuxFileForBots(bots, options) {
|
|
3393
|
-
|
|
3394
|
-
const version = (_a = options === null || options === void 0 ? void 0 : options.version) !== null && _a !== void 0 ? _a : 2;
|
|
3414
|
+
const version = options?.version ?? 2;
|
|
3395
3415
|
if (version === 1) {
|
|
3396
3416
|
let state = {};
|
|
3397
3417
|
for (let bot of bots) {
|
|
@@ -3430,7 +3450,7 @@ export function createDefaultLibrary(context) {
|
|
|
3430
3450
|
*/
|
|
3431
3451
|
function installAuxFile(aux, mode) {
|
|
3432
3452
|
const task = context.createTask(true, true);
|
|
3433
|
-
const action = calcRemote(calcInstallAuxFile(aux, mode
|
|
3453
|
+
const action = calcRemote(calcInstallAuxFile(aux, mode ?? 'default'), undefined, undefined, task.taskId);
|
|
3434
3454
|
return addAsyncAction(task, action);
|
|
3435
3455
|
}
|
|
3436
3456
|
/**
|
|
@@ -3546,6 +3566,40 @@ export function createDefaultLibrary(context) {
|
|
|
3546
3566
|
const event = calcShowQRCode(false);
|
|
3547
3567
|
return addAction(event);
|
|
3548
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
|
+
}
|
|
3549
3603
|
/**
|
|
3550
3604
|
* Opens the [Barcode](https://en.wikipedia.org/wiki/Barcode) scanner.
|
|
3551
3605
|
* While open, each scanned Barcode will send a {@tag @onBarcodeScanned} shout. Optionally accepts which camera to use for scanning. (front/back)
|
|
@@ -3871,7 +3925,7 @@ export function createDefaultLibrary(context) {
|
|
|
3871
3925
|
}
|
|
3872
3926
|
}
|
|
3873
3927
|
}
|
|
3874
|
-
catch
|
|
3928
|
+
catch {
|
|
3875
3929
|
// Ignore errors
|
|
3876
3930
|
}
|
|
3877
3931
|
const task = context.createTask();
|
|
@@ -4054,10 +4108,11 @@ export function createDefaultLibrary(context) {
|
|
|
4054
4108
|
* @docgroup 10-config-values
|
|
4055
4109
|
*/
|
|
4056
4110
|
function getCurrentServer() {
|
|
4057
|
-
var _a;
|
|
4058
4111
|
const user = context.playerBot;
|
|
4059
4112
|
if (user) {
|
|
4060
|
-
let inst =
|
|
4113
|
+
let inst = getTag(user, 'inst') ??
|
|
4114
|
+
getTag(user, 'staticInst') ??
|
|
4115
|
+
getTag(user, 'tempInst');
|
|
4061
4116
|
if (hasValue(inst)) {
|
|
4062
4117
|
if (Array.isArray(inst)) {
|
|
4063
4118
|
return inst[0].toString();
|
|
@@ -4077,10 +4132,9 @@ export function createDefaultLibrary(context) {
|
|
|
4077
4132
|
* @docgroup 10-config-values
|
|
4078
4133
|
*/
|
|
4079
4134
|
function getCurrentInstRecord() {
|
|
4080
|
-
var _a;
|
|
4081
4135
|
const user = context.playerBot;
|
|
4082
4136
|
if (user) {
|
|
4083
|
-
return
|
|
4137
|
+
return getTag(user, 'record') ?? null;
|
|
4084
4138
|
}
|
|
4085
4139
|
return null;
|
|
4086
4140
|
}
|
|
@@ -4698,8 +4752,8 @@ export function createDefaultLibrary(context) {
|
|
|
4698
4752
|
function closeCircleWipe(options) {
|
|
4699
4753
|
const task = context.createTask();
|
|
4700
4754
|
const event = circleWipe(false, {
|
|
4701
|
-
color:
|
|
4702
|
-
duration:
|
|
4755
|
+
color: options?.color || 'black',
|
|
4756
|
+
duration: options?.duration || 1,
|
|
4703
4757
|
}, task.taskId);
|
|
4704
4758
|
return addAsyncAction(task, event);
|
|
4705
4759
|
}
|
|
@@ -4737,8 +4791,8 @@ export function createDefaultLibrary(context) {
|
|
|
4737
4791
|
function openCircleWipe(options) {
|
|
4738
4792
|
const task = context.createTask();
|
|
4739
4793
|
const event = circleWipe(true, {
|
|
4740
|
-
color:
|
|
4741
|
-
duration:
|
|
4794
|
+
color: options?.color || 'black',
|
|
4795
|
+
duration: options?.duration || 1,
|
|
4742
4796
|
}, task.taskId);
|
|
4743
4797
|
return addAsyncAction(task, event);
|
|
4744
4798
|
}
|
|
@@ -5025,6 +5079,274 @@ export function createDefaultLibrary(context) {
|
|
|
5025
5079
|
const event = calcGetGeolocation(task.taskId);
|
|
5026
5080
|
return addAsyncAction(task, event);
|
|
5027
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
|
+
}
|
|
5028
5350
|
/**
|
|
5029
5351
|
* Specifies that the given prefix should be used to indicate that the tag contains script content.
|
|
5030
5352
|
* Use this function to specify custom prefixes that function similarly to `@` or `🧬`.
|
|
@@ -5057,8 +5379,8 @@ export function createDefaultLibrary(context) {
|
|
|
5057
5379
|
}
|
|
5058
5380
|
const task = context.createTask();
|
|
5059
5381
|
const event = calcRegisterPrefix(prefix, {
|
|
5060
|
-
language:
|
|
5061
|
-
name: options
|
|
5382
|
+
language: options?.language || 'javascript',
|
|
5383
|
+
name: options?.name,
|
|
5062
5384
|
}, task.taskId);
|
|
5063
5385
|
return addAsyncAction(task, event);
|
|
5064
5386
|
}
|
|
@@ -5469,7 +5791,7 @@ export function createDefaultLibrary(context) {
|
|
|
5469
5791
|
*/
|
|
5470
5792
|
function grantPermission(recordName, permission, options) {
|
|
5471
5793
|
const task = context.createTask();
|
|
5472
|
-
const event = calcGrantRecordPermission(recordName, permission, options
|
|
5794
|
+
const event = calcGrantRecordPermission(recordName, permission, options ?? {}, task.taskId);
|
|
5473
5795
|
return addAsyncAction(task, event);
|
|
5474
5796
|
}
|
|
5475
5797
|
/**
|
|
@@ -5487,7 +5809,7 @@ export function createDefaultLibrary(context) {
|
|
|
5487
5809
|
*/
|
|
5488
5810
|
function revokePermission(recordName, permissionId, options) {
|
|
5489
5811
|
const task = context.createTask();
|
|
5490
|
-
const event = calcRevokeRecordPermission(recordName, permissionId, options
|
|
5812
|
+
const event = calcRevokeRecordPermission(recordName, permissionId, options ?? {}, task.taskId);
|
|
5491
5813
|
return addAsyncAction(task, event);
|
|
5492
5814
|
}
|
|
5493
5815
|
/**
|
|
@@ -5543,7 +5865,7 @@ export function createDefaultLibrary(context) {
|
|
|
5543
5865
|
*/
|
|
5544
5866
|
function grantInstAdminPermission(recordName, options) {
|
|
5545
5867
|
const task = context.createTask();
|
|
5546
|
-
const event = calcGrantInstAdminPermission(recordName, options
|
|
5868
|
+
const event = calcGrantInstAdminPermission(recordName, options ?? {}, task.taskId);
|
|
5547
5869
|
return addAsyncAction(task, event);
|
|
5548
5870
|
}
|
|
5549
5871
|
/**
|
|
@@ -5569,7 +5891,7 @@ export function createDefaultLibrary(context) {
|
|
|
5569
5891
|
*/
|
|
5570
5892
|
function grantUserRole(recordName, role, userId, expireTimeMs = null, options) {
|
|
5571
5893
|
const task = context.createTask();
|
|
5572
|
-
const event = calcGrantUserRole(recordName, role, userId, expireTimeMs, options
|
|
5894
|
+
const event = calcGrantUserRole(recordName, role, userId, expireTimeMs, options ?? {}, task.taskId);
|
|
5573
5895
|
return addAsyncAction(task, event);
|
|
5574
5896
|
}
|
|
5575
5897
|
/**
|
|
@@ -5591,7 +5913,7 @@ export function createDefaultLibrary(context) {
|
|
|
5591
5913
|
*/
|
|
5592
5914
|
function revokeUserRole(recordName, role, userId, options) {
|
|
5593
5915
|
const task = context.createTask();
|
|
5594
|
-
const event = calcRevokeUserRole(recordName, role, userId, options
|
|
5916
|
+
const event = calcRevokeUserRole(recordName, role, userId, options ?? {}, task.taskId);
|
|
5595
5917
|
return addAsyncAction(task, event);
|
|
5596
5918
|
}
|
|
5597
5919
|
/**
|
|
@@ -5645,7 +5967,7 @@ export function createDefaultLibrary(context) {
|
|
|
5645
5967
|
*/
|
|
5646
5968
|
function revokeInstRole(recordName, role, inst, options) {
|
|
5647
5969
|
const task = context.createTask();
|
|
5648
|
-
const event = calcRevokeInstRole(recordName, role, inst, options
|
|
5970
|
+
const event = calcRevokeInstRole(recordName, role, inst, options ?? {}, task.taskId);
|
|
5649
5971
|
return addAsyncAction(task, event);
|
|
5650
5972
|
}
|
|
5651
5973
|
/**
|
|
@@ -5748,7 +6070,6 @@ export function createDefaultLibrary(context) {
|
|
|
5748
6070
|
* @param endpointOrOptions The options that should be used. Optional.
|
|
5749
6071
|
*/
|
|
5750
6072
|
function baseRecordData(recordKey, address, data, requiresApproval, endpointOrOptions = null) {
|
|
5751
|
-
var _a;
|
|
5752
6073
|
const task = context.createTask();
|
|
5753
6074
|
let options = {};
|
|
5754
6075
|
if (hasValue(endpointOrOptions)) {
|
|
@@ -5761,7 +6082,7 @@ export function createDefaultLibrary(context) {
|
|
|
5761
6082
|
if (hasValue(marker)) {
|
|
5762
6083
|
options.markers = [
|
|
5763
6084
|
endpointOrOptions.marker,
|
|
5764
|
-
...(
|
|
6085
|
+
...(endpointOrOptions.markers ?? []),
|
|
5765
6086
|
];
|
|
5766
6087
|
}
|
|
5767
6088
|
}
|
|
@@ -6181,7 +6502,7 @@ export function createDefaultLibrary(context) {
|
|
|
6181
6502
|
*/
|
|
6182
6503
|
function recordWebhook(recordName, webhook, options) {
|
|
6183
6504
|
const task = context.createTask();
|
|
6184
|
-
const event = calcRecordWebhook(recordName, webhook, options
|
|
6505
|
+
const event = calcRecordWebhook(recordName, webhook, options ?? {}, task.taskId);
|
|
6185
6506
|
const final = addAsyncResultAction(task, event);
|
|
6186
6507
|
final[ORIGINAL_OBJECT] = event;
|
|
6187
6508
|
return final;
|
|
@@ -6202,7 +6523,7 @@ export function createDefaultLibrary(context) {
|
|
|
6202
6523
|
*/
|
|
6203
6524
|
function runWebhook(recordName, address, input, options) {
|
|
6204
6525
|
const task = context.createTask();
|
|
6205
|
-
const event = calcRunWebhook(recordName, address, input, options
|
|
6526
|
+
const event = calcRunWebhook(recordName, address, input, options ?? {}, task.taskId);
|
|
6206
6527
|
const final = addAsyncResultAction(task, event);
|
|
6207
6528
|
final[ORIGINAL_OBJECT] = event;
|
|
6208
6529
|
return final;
|
|
@@ -6222,7 +6543,7 @@ export function createDefaultLibrary(context) {
|
|
|
6222
6543
|
*/
|
|
6223
6544
|
function getWebhook(recordName, address, options) {
|
|
6224
6545
|
const task = context.createTask();
|
|
6225
|
-
const event = calcGetWebhook(recordName, address, options
|
|
6546
|
+
const event = calcGetWebhook(recordName, address, options ?? {}, task.taskId);
|
|
6226
6547
|
const final = addAsyncResultAction(task, event);
|
|
6227
6548
|
final[ORIGINAL_OBJECT] = event;
|
|
6228
6549
|
return final;
|
|
@@ -6239,7 +6560,7 @@ export function createDefaultLibrary(context) {
|
|
|
6239
6560
|
*/
|
|
6240
6561
|
function eraseWebhook(recordName, address, options) {
|
|
6241
6562
|
const task = context.createTask();
|
|
6242
|
-
const event = calcEraseWebhook(recordName, address, options
|
|
6563
|
+
const event = calcEraseWebhook(recordName, address, options ?? {}, task.taskId);
|
|
6243
6564
|
const final = addAsyncResultAction(task, event);
|
|
6244
6565
|
final[ORIGINAL_OBJECT] = event;
|
|
6245
6566
|
return final;
|
|
@@ -6258,7 +6579,7 @@ export function createDefaultLibrary(context) {
|
|
|
6258
6579
|
*/
|
|
6259
6580
|
function listWebhooks(recordName, startingAddress = null, options) {
|
|
6260
6581
|
const task = context.createTask();
|
|
6261
|
-
const event = calcListWebhooks(recordName, startingAddress, options
|
|
6582
|
+
const event = calcListWebhooks(recordName, startingAddress, options ?? {}, task.taskId);
|
|
6262
6583
|
const final = addAsyncResultAction(task, event);
|
|
6263
6584
|
final[ORIGINAL_OBJECT] = event;
|
|
6264
6585
|
return final;
|
|
@@ -6279,7 +6600,7 @@ export function createDefaultLibrary(context) {
|
|
|
6279
6600
|
*/
|
|
6280
6601
|
function listWebhooksByMarker(recordName, marker, startingAddress = null, options) {
|
|
6281
6602
|
const task = context.createTask();
|
|
6282
|
-
const event = calcListWebhooksByMarker(recordName, marker, startingAddress, options
|
|
6603
|
+
const event = calcListWebhooksByMarker(recordName, marker, startingAddress, options ?? {}, task.taskId);
|
|
6283
6604
|
const final = addAsyncResultAction(task, event);
|
|
6284
6605
|
final[ORIGINAL_OBJECT] = event;
|
|
6285
6606
|
return final;
|
|
@@ -6313,7 +6634,7 @@ export function createDefaultLibrary(context) {
|
|
|
6313
6634
|
*/
|
|
6314
6635
|
function recordNotification(recordName, notification, options) {
|
|
6315
6636
|
const task = context.createTask();
|
|
6316
|
-
const event = calcRecordNotification(recordName, notification, options
|
|
6637
|
+
const event = calcRecordNotification(recordName, notification, options ?? {}, task.taskId);
|
|
6317
6638
|
const final = addAsyncResultAction(task, event);
|
|
6318
6639
|
final[ORIGINAL_OBJECT] = event;
|
|
6319
6640
|
return final;
|
|
@@ -6333,7 +6654,7 @@ export function createDefaultLibrary(context) {
|
|
|
6333
6654
|
*/
|
|
6334
6655
|
function getNotification(recordName, address, options) {
|
|
6335
6656
|
const task = context.createTask();
|
|
6336
|
-
const event = calcGetNotification(recordName, address, options
|
|
6657
|
+
const event = calcGetNotification(recordName, address, options ?? {}, task.taskId);
|
|
6337
6658
|
const final = addAsyncResultAction(task, event);
|
|
6338
6659
|
final[ORIGINAL_OBJECT] = event;
|
|
6339
6660
|
return final;
|
|
@@ -6350,7 +6671,7 @@ export function createDefaultLibrary(context) {
|
|
|
6350
6671
|
*/
|
|
6351
6672
|
function eraseNotification(recordName, address, options) {
|
|
6352
6673
|
const task = context.createTask();
|
|
6353
|
-
const event = calcEraseNotification(recordName, address, options
|
|
6674
|
+
const event = calcEraseNotification(recordName, address, options ?? {}, task.taskId);
|
|
6354
6675
|
const final = addAsyncResultAction(task, event);
|
|
6355
6676
|
final[ORIGINAL_OBJECT] = event;
|
|
6356
6677
|
return final;
|
|
@@ -6369,7 +6690,7 @@ export function createDefaultLibrary(context) {
|
|
|
6369
6690
|
*/
|
|
6370
6691
|
function listNotifications(recordName, startingAddress = null, options) {
|
|
6371
6692
|
const task = context.createTask();
|
|
6372
|
-
const event = calcListNotifications(recordName, startingAddress, options
|
|
6693
|
+
const event = calcListNotifications(recordName, startingAddress, options ?? {}, task.taskId);
|
|
6373
6694
|
const final = addAsyncResultAction(task, event);
|
|
6374
6695
|
final[ORIGINAL_OBJECT] = event;
|
|
6375
6696
|
return final;
|
|
@@ -6390,7 +6711,7 @@ export function createDefaultLibrary(context) {
|
|
|
6390
6711
|
*/
|
|
6391
6712
|
function listNotificationsByMarker(recordName, marker, startingAddress = null, options) {
|
|
6392
6713
|
const task = context.createTask();
|
|
6393
|
-
const event = calcListNotificationsByMarker(recordName, marker, startingAddress, options
|
|
6714
|
+
const event = calcListNotificationsByMarker(recordName, marker, startingAddress, options ?? {}, task.taskId);
|
|
6394
6715
|
const final = addAsyncResultAction(task, event);
|
|
6395
6716
|
final[ORIGINAL_OBJECT] = event;
|
|
6396
6717
|
return final;
|
|
@@ -6413,7 +6734,7 @@ export function createDefaultLibrary(context) {
|
|
|
6413
6734
|
*/
|
|
6414
6735
|
function subscribeToNotification(recordName, address, options) {
|
|
6415
6736
|
const task = context.createTask();
|
|
6416
|
-
const event = calcSubscribeToNotification(recordName, address, options
|
|
6737
|
+
const event = calcSubscribeToNotification(recordName, address, options ?? {}, task.taskId);
|
|
6417
6738
|
const final = addAsyncResultAction(task, event);
|
|
6418
6739
|
final[ORIGINAL_OBJECT] = event;
|
|
6419
6740
|
return final;
|
|
@@ -6432,7 +6753,7 @@ export function createDefaultLibrary(context) {
|
|
|
6432
6753
|
*/
|
|
6433
6754
|
function unsubscribeFromNotification(subscriptionId, options) {
|
|
6434
6755
|
const task = context.createTask();
|
|
6435
|
-
const event = calcUnsubscribeFromNotification(subscriptionId, options
|
|
6756
|
+
const event = calcUnsubscribeFromNotification(subscriptionId, options ?? {}, task.taskId);
|
|
6436
6757
|
const final = addAsyncResultAction(task, event);
|
|
6437
6758
|
final[ORIGINAL_OBJECT] = event;
|
|
6438
6759
|
return final;
|
|
@@ -6459,7 +6780,7 @@ export function createDefaultLibrary(context) {
|
|
|
6459
6780
|
*/
|
|
6460
6781
|
function sendNotification(recordName, address, payload, options) {
|
|
6461
6782
|
const task = context.createTask();
|
|
6462
|
-
const event = calcSendNotification(recordName, address, payload, options
|
|
6783
|
+
const event = calcSendNotification(recordName, address, payload, options ?? {}, task.taskId);
|
|
6463
6784
|
const final = addAsyncResultAction(task, event);
|
|
6464
6785
|
final[ORIGINAL_OBJECT] = event;
|
|
6465
6786
|
return final;
|
|
@@ -6480,7 +6801,7 @@ export function createDefaultLibrary(context) {
|
|
|
6480
6801
|
*/
|
|
6481
6802
|
function listNotificationSubscriptions(recordName, address, options) {
|
|
6482
6803
|
const task = context.createTask();
|
|
6483
|
-
const event = calcListNotificationSubscriptions(recordName, address, options
|
|
6804
|
+
const event = calcListNotificationSubscriptions(recordName, address, options ?? {}, task.taskId);
|
|
6484
6805
|
const final = addAsyncResultAction(task, event);
|
|
6485
6806
|
final[ORIGINAL_OBJECT] = event;
|
|
6486
6807
|
return final;
|
|
@@ -6499,7 +6820,7 @@ export function createDefaultLibrary(context) {
|
|
|
6499
6820
|
*/
|
|
6500
6821
|
function listUserNotificationSubscriptions(options) {
|
|
6501
6822
|
const task = context.createTask();
|
|
6502
|
-
const event = calcListUserNotificationSubscriptions(options
|
|
6823
|
+
const event = calcListUserNotificationSubscriptions(options ?? {}, task.taskId);
|
|
6503
6824
|
const final = addAsyncResultAction(task, event);
|
|
6504
6825
|
final[ORIGINAL_OBJECT] = event;
|
|
6505
6826
|
return final;
|
|
@@ -6585,7 +6906,6 @@ export function createDefaultLibrary(context) {
|
|
|
6585
6906
|
* @docname os.recordFile
|
|
6586
6907
|
*/
|
|
6587
6908
|
function recordFile(recordKeyOrName, data, options, endpoint = null) {
|
|
6588
|
-
var _a;
|
|
6589
6909
|
if (!hasValue(recordKeyOrName)) {
|
|
6590
6910
|
throw new Error('recordKeyOrName must be provided.');
|
|
6591
6911
|
}
|
|
@@ -6602,7 +6922,7 @@ export function createDefaultLibrary(context) {
|
|
|
6602
6922
|
if (hasValue(marker)) {
|
|
6603
6923
|
recordOptions.markers = [
|
|
6604
6924
|
options.marker,
|
|
6605
|
-
...(
|
|
6925
|
+
...(options.markers ?? []),
|
|
6606
6926
|
];
|
|
6607
6927
|
}
|
|
6608
6928
|
}
|
|
@@ -6610,7 +6930,7 @@ export function createDefaultLibrary(context) {
|
|
|
6610
6930
|
recordOptions.endpoint = endpoint;
|
|
6611
6931
|
}
|
|
6612
6932
|
const task = context.createTask();
|
|
6613
|
-
const event = calcRecordFile(recordKeyOrName, convertToCopiableValue(data), options
|
|
6933
|
+
const event = calcRecordFile(recordKeyOrName, convertToCopiableValue(data), options?.description, options?.mimeType, recordOptions, task.taskId);
|
|
6614
6934
|
return addAsyncAction(task, event);
|
|
6615
6935
|
}
|
|
6616
6936
|
/**
|
|
@@ -6969,13 +7289,12 @@ export function createDefaultLibrary(context) {
|
|
|
6969
7289
|
* @docname os.recordPackageVersion
|
|
6970
7290
|
*/
|
|
6971
7291
|
function recordPackageVersion(request, options = {}) {
|
|
6972
|
-
var _a;
|
|
6973
7292
|
const task = context.createTask();
|
|
6974
7293
|
const event = calcRecordPackageVersion({
|
|
6975
7294
|
recordName: request.recordName,
|
|
6976
7295
|
address: request.address,
|
|
6977
7296
|
key: request.key,
|
|
6978
|
-
entitlements:
|
|
7297
|
+
entitlements: request.entitlements ?? [],
|
|
6979
7298
|
description: request.description,
|
|
6980
7299
|
markers: request.markers,
|
|
6981
7300
|
state: {
|
|
@@ -7060,7 +7379,7 @@ export function createDefaultLibrary(context) {
|
|
|
7060
7379
|
const task = context.createTask();
|
|
7061
7380
|
const event = calcRecordPackageContainer(recordName, address, typeof markers === 'string'
|
|
7062
7381
|
? [markers]
|
|
7063
|
-
: markers
|
|
7382
|
+
: markers ?? [PRIVATE_MARKER], options, task.taskId);
|
|
7064
7383
|
return addAsyncAction(task, event);
|
|
7065
7384
|
}
|
|
7066
7385
|
/**
|
|
@@ -7156,7 +7475,7 @@ export function createDefaultLibrary(context) {
|
|
|
7156
7475
|
*/
|
|
7157
7476
|
function installPackage(recordName, address, key, options = {}) {
|
|
7158
7477
|
const task = context.createTask();
|
|
7159
|
-
const event = calcInstallPackage(recordName, address, key
|
|
7478
|
+
const event = calcInstallPackage(recordName, address, key ?? null, options, task.taskId);
|
|
7160
7479
|
return addAsyncAction(task, event);
|
|
7161
7480
|
}
|
|
7162
7481
|
/**
|
|
@@ -7370,7 +7689,7 @@ export function createDefaultLibrary(context) {
|
|
|
7370
7689
|
recordName,
|
|
7371
7690
|
marker,
|
|
7372
7691
|
address: startingAddress,
|
|
7373
|
-
sort: options
|
|
7692
|
+
sort: options?.sort,
|
|
7374
7693
|
},
|
|
7375
7694
|
},
|
|
7376
7695
|
}, options, task.taskId);
|
|
@@ -7622,7 +7941,7 @@ export function createDefaultLibrary(context) {
|
|
|
7622
7941
|
recordName,
|
|
7623
7942
|
marker,
|
|
7624
7943
|
address: startingAddress,
|
|
7625
|
-
sort: options
|
|
7944
|
+
sort: options?.sort,
|
|
7626
7945
|
},
|
|
7627
7946
|
},
|
|
7628
7947
|
}, options, task.taskId);
|
|
@@ -7744,6 +8063,148 @@ export function createDefaultLibrary(context) {
|
|
|
7744
8063
|
const event = calcGetRecordsEndpoint(task.taskId);
|
|
7745
8064
|
return addAsyncAction(task, event);
|
|
7746
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
|
+
}
|
|
7747
8208
|
/**
|
|
7748
8209
|
* Converts the given geolocation to a [what3words](https://what3words.com/) address. Returns a promise that resolves with the 3 word address.
|
|
7749
8210
|
* @param location The latitude and longitude that should be converted to a 3 word address.
|
|
@@ -8038,7 +8499,7 @@ export function createDefaultLibrary(context) {
|
|
|
8038
8499
|
const botIds = Array.isArray(botOrBots)
|
|
8039
8500
|
? botOrBots.map((b) => (isBot(b) ? b.id : b))
|
|
8040
8501
|
: [isBot(botOrBots) ? botOrBots.id : botOrBots];
|
|
8041
|
-
const event = calcStartFormAnimation(botIds, nameOrIndex, options
|
|
8502
|
+
const event = calcStartFormAnimation(botIds, nameOrIndex, options ?? {}, task.taskId);
|
|
8042
8503
|
return addAsyncAction(task, event);
|
|
8043
8504
|
}
|
|
8044
8505
|
/**
|
|
@@ -8074,7 +8535,7 @@ export function createDefaultLibrary(context) {
|
|
|
8074
8535
|
const botIds = Array.isArray(botOrBots)
|
|
8075
8536
|
? botOrBots.map((b) => (isBot(b) ? b.id : b))
|
|
8076
8537
|
: [isBot(botOrBots) ? botOrBots.id : botOrBots];
|
|
8077
|
-
const event = calcStopFormAnimation(botIds, options
|
|
8538
|
+
const event = calcStopFormAnimation(botIds, options ?? {}, task.taskId);
|
|
8078
8539
|
return addAsyncAction(task, event);
|
|
8079
8540
|
}
|
|
8080
8541
|
/**
|
|
@@ -8095,14 +8556,13 @@ export function createDefaultLibrary(context) {
|
|
|
8095
8556
|
* @docorder 2
|
|
8096
8557
|
*/
|
|
8097
8558
|
function listFormAnimations(botOrAddress) {
|
|
8098
|
-
var _a;
|
|
8099
8559
|
let address;
|
|
8100
8560
|
let bot = isBot(botOrAddress)
|
|
8101
8561
|
? botOrAddress
|
|
8102
8562
|
: context.state[botOrAddress];
|
|
8103
8563
|
if (bot) {
|
|
8104
8564
|
address =
|
|
8105
|
-
|
|
8565
|
+
calculateStringTagValue(null, bot, 'auxFormAnimationAddress', null) ?? calculateStringTagValue(null, bot, 'auxFormAddress', null);
|
|
8106
8566
|
}
|
|
8107
8567
|
else if (typeof botOrAddress === 'string') {
|
|
8108
8568
|
address = botOrAddress;
|
|
@@ -8377,7 +8837,7 @@ export function createDefaultLibrary(context) {
|
|
|
8377
8837
|
instName = getCurrentServer();
|
|
8378
8838
|
recordName = getCurrentInstRecord();
|
|
8379
8839
|
branchName = recordOrName;
|
|
8380
|
-
markers = inst
|
|
8840
|
+
markers = inst?.markers;
|
|
8381
8841
|
}
|
|
8382
8842
|
else if (!inst && !name) {
|
|
8383
8843
|
// Called as getSharedDocument(name)
|
|
@@ -8393,7 +8853,7 @@ export function createDefaultLibrary(context) {
|
|
|
8393
8853
|
recordName = recordOrName;
|
|
8394
8854
|
instName = inst;
|
|
8395
8855
|
branchName = name;
|
|
8396
|
-
markers = options
|
|
8856
|
+
markers = options?.markers;
|
|
8397
8857
|
}
|
|
8398
8858
|
const event = loadSharedDocument(recordName, instName, `doc/${branchName}`, task.taskId, markers);
|
|
8399
8859
|
return addAsyncAction(task, event);
|
|
@@ -8566,33 +9026,35 @@ export function createDefaultLibrary(context) {
|
|
|
8566
9026
|
return addAsyncAction(task, event);
|
|
8567
9027
|
}
|
|
8568
9028
|
/**
|
|
8569
|
-
* 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.
|
|
8570
9030
|
*
|
|
8571
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.
|
|
8572
9032
|
*
|
|
8573
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.
|
|
8574
9034
|
*
|
|
8575
|
-
* Unlike {@link os.
|
|
8576
|
-
*
|
|
8577
|
-
* @param bots the list of bots that should be included in the update.
|
|
8578
|
-
*
|
|
8579
|
-
* @example Create an update with this bot and save it to a tag
|
|
8580
|
-
* const update = await os.createInitializationUpdate([thisBot]);
|
|
8581
|
-
* tags.savedUpdate = update;
|
|
8582
|
-
*
|
|
8583
|
-
* @example Create an update with all the bots in the home dimension
|
|
8584
|
-
* const update = await os.createInitializationUpdate(getBots(inDimension('home')));
|
|
8585
|
-
* 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.
|
|
8586
9036
|
*
|
|
8587
|
-
* @
|
|
8588
|
-
* @
|
|
8589
|
-
* @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).
|
|
8590
9039
|
*/
|
|
8591
|
-
function createInitializationUpdate(bots) {
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
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
|
+
}
|
|
8596
9058
|
}
|
|
8597
9059
|
/**
|
|
8598
9060
|
* Applies the given updates to the current inst. Returns a promise that resolves once the updates have been applied.
|
|
@@ -8901,10 +9363,9 @@ export function createDefaultLibrary(context) {
|
|
|
8901
9363
|
}
|
|
8902
9364
|
}
|
|
8903
9365
|
async function _retryWebhook(options) {
|
|
8904
|
-
var _a, _b, _c, _d;
|
|
8905
9366
|
const retryCount = Math.min(options.retryCount, MAX_RETRY_COUNT);
|
|
8906
|
-
const timeToWait = Math.max(0, Math.min(
|
|
8907
|
-
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;
|
|
8908
9369
|
let retries = 0;
|
|
8909
9370
|
while (true) {
|
|
8910
9371
|
try {
|
|
@@ -8914,7 +9375,7 @@ export function createDefaultLibrary(context) {
|
|
|
8914
9375
|
if (retries >= retryCount) {
|
|
8915
9376
|
throw err;
|
|
8916
9377
|
}
|
|
8917
|
-
else if (!statusCodes.includes(
|
|
9378
|
+
else if (!statusCodes.includes(err.response?.status ?? 0)) {
|
|
8918
9379
|
throw err;
|
|
8919
9380
|
}
|
|
8920
9381
|
await sleep(timeToWait);
|
|
@@ -9739,7 +10200,7 @@ export function createDefaultLibrary(context) {
|
|
|
9739
10200
|
*/
|
|
9740
10201
|
function beginAudioRecording(options) {
|
|
9741
10202
|
const task = context.createTask();
|
|
9742
|
-
const action = calcBeginAudioRecording(options
|
|
10203
|
+
const action = calcBeginAudioRecording(options ?? {}, task.taskId);
|
|
9743
10204
|
return addAsyncAction(task, action);
|
|
9744
10205
|
}
|
|
9745
10206
|
/**
|
|
@@ -10137,11 +10598,10 @@ export function createDefaultLibrary(context) {
|
|
|
10137
10598
|
* @docname experiment.speakText
|
|
10138
10599
|
*/
|
|
10139
10600
|
function speakText(text, options) {
|
|
10140
|
-
|
|
10141
|
-
options = options !== null && options !== void 0 ? options : {};
|
|
10601
|
+
options = options ?? {};
|
|
10142
10602
|
const task = context.createTask();
|
|
10143
10603
|
const voice = typeof options.voice === 'object'
|
|
10144
|
-
?
|
|
10604
|
+
? options.voice?.name
|
|
10145
10605
|
: options.voice;
|
|
10146
10606
|
const action = calcSpeakText(text, {
|
|
10147
10607
|
...options,
|
|
@@ -12847,7 +13307,7 @@ export function createDefaultLibrary(context) {
|
|
|
12847
13307
|
*/
|
|
12848
13308
|
function joinRoom(roomName, options) {
|
|
12849
13309
|
const task = context.createTask();
|
|
12850
|
-
const event = calcJoinRoom(roomName, options
|
|
13310
|
+
const event = calcJoinRoom(roomName, options ?? {}, task.taskId);
|
|
12851
13311
|
return addAsyncAction(task, event);
|
|
12852
13312
|
}
|
|
12853
13313
|
/**
|
|
@@ -12871,7 +13331,7 @@ export function createDefaultLibrary(context) {
|
|
|
12871
13331
|
*/
|
|
12872
13332
|
function leaveRoom(roomName, options) {
|
|
12873
13333
|
const task = context.createTask();
|
|
12874
|
-
const event = calcLeaveRoom(roomName, options
|
|
13334
|
+
const event = calcLeaveRoom(roomName, options ?? {}, task.taskId);
|
|
12875
13335
|
return addAsyncAction(task, event);
|
|
12876
13336
|
}
|
|
12877
13337
|
/**
|