@casual-simulation/aux-common 2.0.19 → 2.0.23
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/bots/Bot.js +0 -19
- package/bots/Bot.js.map +1 -1
- package/bots/BotEvents.d.ts +105 -130
- package/bots/BotEvents.js +43 -34
- package/bots/BotEvents.js.map +1 -1
- package/package.json +6 -5
- package/runtime/AuxLibrary.d.ts +70 -20
- package/runtime/AuxLibrary.js +85 -177
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +250 -143
- package/runtime/AuxRuntime.js +1 -7
- package/runtime/AuxRuntime.js.map +1 -1
- package/runtime/BlobPolyfill.js +34 -0
- package/runtime/BlobPolyfill.js.map +1 -1
- package/test/YjsTestHelpers.js.map +1 -1
- package/yjs/YjsHelpers.d.ts +1 -1
|
@@ -2238,96 +2238,26 @@ declare interface UnsuccessfulGeolocation {
|
|
|
2238
2238
|
*/
|
|
2239
2239
|
declare type GeoLocation = SuccessfulGeolocation | UnsuccessfulGeolocation;
|
|
2240
2240
|
|
|
2241
|
-
|
|
2242
2241
|
/**
|
|
2243
|
-
* Defines an
|
|
2242
|
+
* Defines an interface that represents options for converting a geolocation to a what3words address.
|
|
2244
2243
|
*/
|
|
2245
|
-
|
|
2246
|
-
type: 'publish_record';
|
|
2247
|
-
|
|
2244
|
+
export interface ConvertGeolocationToWhat3WordsOptions {
|
|
2248
2245
|
/**
|
|
2249
|
-
* The
|
|
2246
|
+
* The latitude to convert.
|
|
2250
2247
|
*/
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
/**
|
|
2254
|
-
* The address that the record should be published to.
|
|
2255
|
-
*/
|
|
2256
|
-
address: string;
|
|
2248
|
+
latitude: number;
|
|
2257
2249
|
|
|
2258
2250
|
/**
|
|
2259
|
-
* The
|
|
2251
|
+
* The longitude to convert.
|
|
2260
2252
|
*/
|
|
2261
|
-
|
|
2253
|
+
longitude: number;
|
|
2262
2254
|
|
|
2263
2255
|
/**
|
|
2264
|
-
* The
|
|
2256
|
+
* The identifier of the language that should be used for the resulting what3words address.
|
|
2265
2257
|
*/
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
uncopiable: true;
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
export interface RecordDefinition {
|
|
2272
|
-
/**
|
|
2273
|
-
* The auth token that should be used to authenticate the publish record request.
|
|
2274
|
-
* Different auth tokens can be used to publish records to different CasualOS.me accounts.
|
|
2275
|
-
* Defaults to using the auth token in the auth bot.
|
|
2276
|
-
*/
|
|
2277
|
-
authToken?: string;
|
|
2278
|
-
|
|
2279
|
-
/**
|
|
2280
|
-
* The space that the record should be published in.
|
|
2281
|
-
* Defaults to tempRestricted.
|
|
2282
|
-
*/
|
|
2283
|
-
space?: RecordSpace;
|
|
2284
|
-
|
|
2285
|
-
/**
|
|
2286
|
-
* The record that should be published.
|
|
2287
|
-
*/
|
|
2288
|
-
record: any;
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
export interface AddressedRecord extends RecordDefinition {
|
|
2292
|
-
/**
|
|
2293
|
-
* The address that the record should be published to.
|
|
2294
|
-
*/
|
|
2295
|
-
address: string;
|
|
2258
|
+
language?: string;
|
|
2296
2259
|
}
|
|
2297
2260
|
|
|
2298
|
-
export interface PrefixedRecord extends RecordDefinition {
|
|
2299
|
-
/**
|
|
2300
|
-
* The prefix that the record should be published with.
|
|
2301
|
-
*/
|
|
2302
|
-
prefix?: string;
|
|
2303
|
-
|
|
2304
|
-
/**
|
|
2305
|
-
* The ID that the record should be published with.
|
|
2306
|
-
* Defaults to a UUID.
|
|
2307
|
-
*/
|
|
2308
|
-
id?: string;
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
|
-
export type PublishableRecord = AddressedRecord | PrefixedRecord;
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
export interface DeletableRecord {
|
|
2315
|
-
/**
|
|
2316
|
-
* The auth token that should be used to authenticate the delete record request.
|
|
2317
|
-
*/
|
|
2318
|
-
authToken?: string;
|
|
2319
|
-
|
|
2320
|
-
/**
|
|
2321
|
-
* The space that the record lives in.
|
|
2322
|
-
*/
|
|
2323
|
-
space: RecordSpace;
|
|
2324
|
-
|
|
2325
|
-
/**
|
|
2326
|
-
* The address that the record was published to.
|
|
2327
|
-
*/
|
|
2328
|
-
address: string;
|
|
2329
|
-
};
|
|
2330
|
-
|
|
2331
2261
|
/**
|
|
2332
2262
|
* Defines an interface for options that show a payment box.
|
|
2333
2263
|
*/
|
|
@@ -2901,6 +2831,170 @@ export interface DebuggerOptions {
|
|
|
2901
2831
|
configBot: Bot | BotTags;
|
|
2902
2832
|
}
|
|
2903
2833
|
|
|
2834
|
+
|
|
2835
|
+
/**
|
|
2836
|
+
* Defines an interface that represents the result of a "create public record key" operation.
|
|
2837
|
+
*/
|
|
2838
|
+
export type CreatePublicRecordKeyResult =
|
|
2839
|
+
| CreatePublicRecordKeySuccess
|
|
2840
|
+
| CreatePublicRecordKeyFailure;
|
|
2841
|
+
|
|
2842
|
+
/**
|
|
2843
|
+
* Defines an interface that represents a successful "create public record key" result.
|
|
2844
|
+
*/
|
|
2845
|
+
export interface CreatePublicRecordKeySuccess {
|
|
2846
|
+
/**
|
|
2847
|
+
* Whether the operation was successful.
|
|
2848
|
+
*/
|
|
2849
|
+
success: true;
|
|
2850
|
+
|
|
2851
|
+
/**
|
|
2852
|
+
* The key that was created.
|
|
2853
|
+
*/
|
|
2854
|
+
recordKey: string;
|
|
2855
|
+
|
|
2856
|
+
/**
|
|
2857
|
+
* The name of the record the key was created for.
|
|
2858
|
+
*/
|
|
2859
|
+
recordName: string;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
/**
|
|
2863
|
+
* Defines an interface that represents a failed "create public record key" result.
|
|
2864
|
+
*/
|
|
2865
|
+
export interface CreatePublicRecordKeyFailure {
|
|
2866
|
+
/**
|
|
2867
|
+
* Whether the operation was successful.
|
|
2868
|
+
*/
|
|
2869
|
+
success: false;
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* The type of error that occurred.
|
|
2873
|
+
*/
|
|
2874
|
+
errorCode: UnauthorizedToCreateRecordKeyError | GeneralRecordError;
|
|
2875
|
+
|
|
2876
|
+
/**
|
|
2877
|
+
* The error message.
|
|
2878
|
+
*/
|
|
2879
|
+
errorMessage: string;
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
/**
|
|
2883
|
+
* Defines an error that occurs when a user is not authorized to create a key for the public record.
|
|
2884
|
+
* This may happen when the user is not the owner of the record.
|
|
2885
|
+
*/
|
|
2886
|
+
export type UnauthorizedToCreateRecordKeyError =
|
|
2887
|
+
'unauthorized_to_create_record_key';
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* Defines an error that occurs when an unspecified error occurs while creating a public record key.
|
|
2891
|
+
*/
|
|
2892
|
+
export type GeneralRecordError = 'general_record_error';
|
|
2893
|
+
|
|
2894
|
+
/**
|
|
2895
|
+
* Defines an error that occurs when an unspecified error occurs while creating a public record key.
|
|
2896
|
+
*/
|
|
2897
|
+
export type InvalidRecordKey = 'invalid_record_key';
|
|
2898
|
+
|
|
2899
|
+
/**
|
|
2900
|
+
* Defines an error that occurs when an unspecified error occurs while creating a public record key.
|
|
2901
|
+
*/
|
|
2902
|
+
export type ServerError = 'server_error';
|
|
2903
|
+
|
|
2904
|
+
/**
|
|
2905
|
+
* Defines an error that occurs when the user is not logged in but they are required to be in order to perform an action.
|
|
2906
|
+
*/
|
|
2907
|
+
export type NotLoggedInError = 'not_logged_in';
|
|
2908
|
+
|
|
2909
|
+
export type RecordNotFoundError = 'record_not_found';
|
|
2910
|
+
|
|
2911
|
+
|
|
2912
|
+
|
|
2913
|
+
export type RecordDataResult = RecordDataSuccess | RecordDataFailure;
|
|
2914
|
+
|
|
2915
|
+
export interface RecordDataSuccess {
|
|
2916
|
+
success: true;
|
|
2917
|
+
recordName: string;
|
|
2918
|
+
address: string;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
export interface RecordDataFailure {
|
|
2922
|
+
success: false;
|
|
2923
|
+
errorCode:
|
|
2924
|
+
| ServerError
|
|
2925
|
+
| NotLoggedInError
|
|
2926
|
+
| InvalidRecordKey
|
|
2927
|
+
| RecordNotFoundError
|
|
2928
|
+
| 'data_too_large';
|
|
2929
|
+
errorMessage: string;
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
export type GetDataResult = GetDataSuccess | GetDataFailure;
|
|
2933
|
+
|
|
2934
|
+
/**
|
|
2935
|
+
* Defines an interface that represents a successful "get data" result.
|
|
2936
|
+
*/
|
|
2937
|
+
export interface GetDataSuccess {
|
|
2938
|
+
success: true;
|
|
2939
|
+
|
|
2940
|
+
/**
|
|
2941
|
+
* The data that was stored.
|
|
2942
|
+
*/
|
|
2943
|
+
data: any;
|
|
2944
|
+
|
|
2945
|
+
/**
|
|
2946
|
+
* The name of the record.
|
|
2947
|
+
*/
|
|
2948
|
+
recordName: string;
|
|
2949
|
+
|
|
2950
|
+
/**
|
|
2951
|
+
* The ID of the user that owns the record.
|
|
2952
|
+
*/
|
|
2953
|
+
publisherId: string;
|
|
2954
|
+
|
|
2955
|
+
/**
|
|
2956
|
+
* The ID of the user that sent the data.
|
|
2957
|
+
*/
|
|
2958
|
+
subjectId: string;
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2961
|
+
export interface GetDataFailure {
|
|
2962
|
+
success: false;
|
|
2963
|
+
errorCode: ServerError | 'data_not_found';
|
|
2964
|
+
errorMessage: string;
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
export type RecordFileResult = RecordFileSuccess | RecordFileFailure;
|
|
2969
|
+
|
|
2970
|
+
export interface RecordFileSuccess {
|
|
2971
|
+
success: true;
|
|
2972
|
+
|
|
2973
|
+
/**
|
|
2974
|
+
* The URL that the file can be accessed at.
|
|
2975
|
+
*/
|
|
2976
|
+
url: string;
|
|
2977
|
+
|
|
2978
|
+
/**
|
|
2979
|
+
* The SHA-256 hash of the file.
|
|
2980
|
+
* When downloading the URL, the resulting data is guaranteed to have a SHA-256 hash that matches this value.
|
|
2981
|
+
*/
|
|
2982
|
+
sha256Hash: string;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
export interface RecordFileFailure {
|
|
2986
|
+
success: false;
|
|
2987
|
+
errorCode:
|
|
2988
|
+
| ServerError
|
|
2989
|
+
| NotLoggedInError
|
|
2990
|
+
| InvalidRecordKey
|
|
2991
|
+
| RecordNotFoundError
|
|
2992
|
+
| 'file_already_exists'
|
|
2993
|
+
| 'invalid_file_data';
|
|
2994
|
+
errorMessage: string;
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
|
|
2904
2998
|
declare global {
|
|
2905
2999
|
|
|
2906
3000
|
/**
|
|
@@ -3506,30 +3600,6 @@ declare global {
|
|
|
3506
3600
|
*/
|
|
3507
3601
|
function not(filter: BotFilterFunction): BotFilterFunction;
|
|
3508
3602
|
|
|
3509
|
-
/**
|
|
3510
|
-
* Creates a record filter that retrieves records created by the given Auth ID.
|
|
3511
|
-
* @param authID The ID of the creator of the records.
|
|
3512
|
-
*/
|
|
3513
|
-
function byAuthID(authID: string): AuthIdRecordFilter;
|
|
3514
|
-
|
|
3515
|
-
/**
|
|
3516
|
-
* Creates a record filter that retrieves records with the given address.
|
|
3517
|
-
* @param address The address that the record was stored at.
|
|
3518
|
-
*/
|
|
3519
|
-
function byAddress(address: string): AddressRecordFilter;
|
|
3520
|
-
|
|
3521
|
-
/**
|
|
3522
|
-
* Creates a record filter that retrieves records with the given address.
|
|
3523
|
-
* @param token The auth token that should be used to authenticate the getRecords() request.
|
|
3524
|
-
*/
|
|
3525
|
-
function withAuthToken(token: string): AuthTokenRecordFilter;
|
|
3526
|
-
|
|
3527
|
-
/**
|
|
3528
|
-
* Creates a record filter that retrieves records with the given prefix in their address.
|
|
3529
|
-
* @param prefix The prefix that should be matched to record addresses.
|
|
3530
|
-
*/
|
|
3531
|
-
function byPrefix(prefix: string): PrefixRecordFilter;
|
|
3532
|
-
|
|
3533
3603
|
/**
|
|
3534
3604
|
* Gets the value of the given tag stored in the given bot.
|
|
3535
3605
|
* @param bot The bot.
|
|
@@ -4279,30 +4349,6 @@ interface Debugger {
|
|
|
4279
4349
|
*/
|
|
4280
4350
|
not(filter: BotFilterFunction): BotFilterFunction;
|
|
4281
4351
|
|
|
4282
|
-
/**
|
|
4283
|
-
* Creates a record filter that retrieves records created by the given Auth ID.
|
|
4284
|
-
* @param authID The ID of the creator of the records.
|
|
4285
|
-
*/
|
|
4286
|
-
byAuthID(authID: string): AuthIdRecordFilter;
|
|
4287
|
-
|
|
4288
|
-
/**
|
|
4289
|
-
* Creates a record filter that retrieves records with the given address.
|
|
4290
|
-
* @param address The address that the record was stored at.
|
|
4291
|
-
*/
|
|
4292
|
-
byAddress(address: string): AddressRecordFilter;
|
|
4293
|
-
|
|
4294
|
-
/**
|
|
4295
|
-
* Creates a record filter that retrieves records with the given address.
|
|
4296
|
-
* @param token The auth token that should be used to authenticate the getRecords() request.
|
|
4297
|
-
*/
|
|
4298
|
-
withAuthToken(token: string): AuthTokenRecordFilter;
|
|
4299
|
-
|
|
4300
|
-
/**
|
|
4301
|
-
* Creates a record filter that retrieves records with the given prefix in their address.
|
|
4302
|
-
* @param prefix The prefix that should be matched to record addresses.
|
|
4303
|
-
*/
|
|
4304
|
-
byPrefix(prefix: string): PrefixRecordFilter;
|
|
4305
|
-
|
|
4306
4352
|
/**
|
|
4307
4353
|
* Gets the value of the given tag stored in the given bot.
|
|
4308
4354
|
* @param bot The bot.
|
|
@@ -4493,6 +4539,22 @@ interface Debugger {
|
|
|
4493
4539
|
perf: Perf;
|
|
4494
4540
|
}
|
|
4495
4541
|
|
|
4542
|
+
/**
|
|
4543
|
+
* Defines an interface that represents the set of additional options that can be provided when recording a file.
|
|
4544
|
+
*/
|
|
4545
|
+
interface RecordFileOptions {
|
|
4546
|
+
/**
|
|
4547
|
+
* The description of the file.
|
|
4548
|
+
*/
|
|
4549
|
+
description?: string;
|
|
4550
|
+
|
|
4551
|
+
/**
|
|
4552
|
+
* The MIME type of the file.
|
|
4553
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types for more information.
|
|
4554
|
+
*/
|
|
4555
|
+
mimeType?: string;
|
|
4556
|
+
}
|
|
4557
|
+
|
|
4496
4558
|
interface Os {
|
|
4497
4559
|
/**
|
|
4498
4560
|
* Sleeps for time in ms.
|
|
@@ -5115,35 +5177,80 @@ interface Os {
|
|
|
5115
5177
|
*/
|
|
5116
5178
|
requestAuthBot(): Promise<Bot>;
|
|
5117
5179
|
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5180
|
+
/**
|
|
5181
|
+
* Gets an access key for the given public record.
|
|
5182
|
+
* @param name The name of the record.
|
|
5183
|
+
*/
|
|
5184
|
+
getPublicRecordKey(recordName: string): Promise<CreatePublicRecordKeyResult>;
|
|
5122
5185
|
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5186
|
+
/**
|
|
5187
|
+
* Determines if the given value is a record key.
|
|
5188
|
+
* @param key The value to check.
|
|
5189
|
+
*/
|
|
5190
|
+
isRecordKey(key: unknown): boolean;
|
|
5191
|
+
|
|
5192
|
+
/**
|
|
5193
|
+
* Records the given data to the given address inside the record for the given record key.
|
|
5194
|
+
* @param recordKey The key that should be used to access the record.
|
|
5195
|
+
* @param address The address that the data should be stored at inside the record.
|
|
5196
|
+
* @param data The data that should be stored.
|
|
5197
|
+
*/
|
|
5198
|
+
recordData(
|
|
5199
|
+
recordKey: string,
|
|
5200
|
+
address: string,
|
|
5201
|
+
data: any
|
|
5202
|
+
): Promise<RecordDataResult>;
|
|
5128
5203
|
|
|
5204
|
+
/**
|
|
5205
|
+
* Gets the data stored in the given record at the given address.
|
|
5206
|
+
* @param recordKeyOrName The record that the data should be retrieved from.
|
|
5207
|
+
* @param address The address that the data is stored at.
|
|
5208
|
+
*/
|
|
5209
|
+
getData(
|
|
5210
|
+
recordKeyOrName: string,
|
|
5211
|
+
address: string
|
|
5212
|
+
): Promise<GetDataResult>;
|
|
5213
|
+
|
|
5214
|
+
/**
|
|
5215
|
+
* Records the given data as a file.
|
|
5216
|
+
* @param recordKey The record that the file should be recorded in.
|
|
5217
|
+
* @param data The data that should be recorded.
|
|
5218
|
+
* @param options The options that should be used to record the file.
|
|
5219
|
+
*/
|
|
5220
|
+
recordFile(
|
|
5221
|
+
recordKey: string,
|
|
5222
|
+
data: any,
|
|
5223
|
+
options?: RecordFileOptions
|
|
5224
|
+
): Promise<RecordFileResult>;
|
|
5225
|
+
|
|
5226
|
+
/**
|
|
5227
|
+
* Gets the data stored in the given file.
|
|
5228
|
+
* @param result The successful result of a os.recordFile() call.
|
|
5229
|
+
*/
|
|
5230
|
+
getFile(result: RecordFileSuccess): Promise<any>;
|
|
5129
5231
|
/**
|
|
5130
|
-
*
|
|
5131
|
-
* @param
|
|
5232
|
+
* Gets the data stored in the given file.
|
|
5233
|
+
* @param url The URL that the file is stored at.
|
|
5132
5234
|
*/
|
|
5133
|
-
|
|
5134
|
-
|
|
5235
|
+
getFile(url: string): Promise<any>;
|
|
5135
5236
|
/**
|
|
5136
|
-
*
|
|
5137
|
-
* @param
|
|
5237
|
+
* Gets the data stored in the given file.
|
|
5238
|
+
* @param urlOrRecordFileResult The URL or the successful result of the record file operation.
|
|
5138
5239
|
*/
|
|
5139
|
-
|
|
5240
|
+
getFile(urlOrRecordFileResult: string | RecordFileSuccess): Promise<any>;
|
|
5241
|
+
|
|
5242
|
+
/**
|
|
5243
|
+
* Converts the given geolocation to a what3words (https://what3words.com/) address.
|
|
5244
|
+
* @param location The latitude and longitude that should be converted to a 3 word address.
|
|
5245
|
+
*/
|
|
5246
|
+
convertGeolocationToWhat3Words(location: ConvertGeolocationToWhat3WordsOptions): Promise<string>;
|
|
5140
5247
|
|
|
5141
5248
|
/**
|
|
5142
5249
|
* Specifies that the given prefix should be interpreted as code.
|
|
5143
5250
|
* @param prefix The prefix that code tags should start with.
|
|
5144
5251
|
* @param options The options that should be used for the prefix.
|
|
5145
5252
|
*/
|
|
5146
|
-
|
|
5253
|
+
registerTagPrefix(prefix: string, options?: RegisterPrefixOptions): Promise<void>;
|
|
5147
5254
|
|
|
5148
5255
|
/**
|
|
5149
5256
|
* Gets the number of devices that are viewing the current inst.
|
package/runtime/AuxRuntime.js
CHANGED
|
@@ -12,7 +12,7 @@ import { addToContext, MemoryGlobalContext, removeFromContext, isInContext, } fr
|
|
|
12
12
|
import { createDefaultLibrary, } from './AuxLibrary';
|
|
13
13
|
import { createRuntimeBot, RealtimeEditMode, } from './RuntimeBot';
|
|
14
14
|
import { RanOutOfEnergyError } from './AuxResults';
|
|
15
|
-
import { convertToCopiableValue, DeepObjectError,
|
|
15
|
+
import { convertToCopiableValue, DeepObjectError, } from './Utils';
|
|
16
16
|
import { DefaultRealtimeEditModeProvider, } from './AuxRealtimeEditModeProvider';
|
|
17
17
|
import { sortBy, forOwn, merge, union } from 'lodash';
|
|
18
18
|
import { tagValueHash } from '../aux-format-2/AuxOpTypes';
|
|
@@ -326,12 +326,6 @@ export class AuxRuntime {
|
|
|
326
326
|
this._processCore([asyncResult(action.taskId, null)]);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
else if (action.type === 'update_auth_data') {
|
|
330
|
-
const bot = this._compiledState[action.data.userId];
|
|
331
|
-
if (bot) {
|
|
332
|
-
this.updateTag(bot, 'authToken', formatAuthToken(action.data.token, action.data.service));
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
329
|
else {
|
|
336
330
|
this._actionBatch.push(action);
|
|
337
331
|
}
|