@casual-simulation/aux-common 3.2.1 → 3.2.2-alpha.5685728183
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/BotEvents.d.ts +133 -2
- package/bots/BotEvents.js +31 -0
- package/bots/BotEvents.js.map +1 -1
- package/package.json +3 -3
- package/runtime/AuxLibrary.d.ts +49 -2
- package/runtime/AuxLibrary.js +80 -2
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +408 -0
- package/runtime/CasualOSError.d.ts +37 -0
- package/runtime/CasualOSError.js +25 -0
- package/runtime/CasualOSError.js.map +1 -0
|
@@ -8569,6 +8569,11 @@ declare global {
|
|
|
8569
8569
|
*/
|
|
8570
8570
|
const os: Os;
|
|
8571
8571
|
|
|
8572
|
+
/**
|
|
8573
|
+
* Defines a set of functions that relate to AI operations.
|
|
8574
|
+
*/
|
|
8575
|
+
const ai: Ai;
|
|
8576
|
+
|
|
8572
8577
|
/**
|
|
8573
8578
|
* Defines a set of functions that relate to common server operations.
|
|
8574
8579
|
* Typically, these operations are instance-independent.
|
|
@@ -9399,6 +9404,11 @@ interface DebuggerBase {
|
|
|
9399
9404
|
*/
|
|
9400
9405
|
os: Os;
|
|
9401
9406
|
|
|
9407
|
+
/**
|
|
9408
|
+
* Defines a set of functions that relate to AI operations.
|
|
9409
|
+
*/
|
|
9410
|
+
ai: Ai;
|
|
9411
|
+
|
|
9402
9412
|
/**
|
|
9403
9413
|
* Defines a set of functions that relate to common server operations.
|
|
9404
9414
|
* Typically, these operations are instance-independent.
|
|
@@ -9760,6 +9770,404 @@ export interface StopFormAnimationOptions {
|
|
|
9760
9770
|
duration: number;
|
|
9761
9771
|
}
|
|
9762
9772
|
|
|
9773
|
+
/**
|
|
9774
|
+
* Defines an interface that represents a single chat message in a conversation with an AI.
|
|
9775
|
+
*
|
|
9776
|
+
* @dochash types/ai
|
|
9777
|
+
* @docname AIChatMessage
|
|
9778
|
+
*/
|
|
9779
|
+
export interface AIChatMessage {
|
|
9780
|
+
/**
|
|
9781
|
+
* The role of the message.
|
|
9782
|
+
*
|
|
9783
|
+
* - `system` means that the message was generated by the system. Useful for telling the AI how to behave while.
|
|
9784
|
+
* - `user` means that the message was generated by the user.
|
|
9785
|
+
* - `assistant` means that the message was generated by the AI assistant.
|
|
9786
|
+
* - `function` means that the message contains the results of a function call.
|
|
9787
|
+
*/
|
|
9788
|
+
role: 'system' | 'user' | 'assistant' | 'function';
|
|
9789
|
+
|
|
9790
|
+
/**
|
|
9791
|
+
* The contents of the message.
|
|
9792
|
+
*/
|
|
9793
|
+
content: string;
|
|
9794
|
+
|
|
9795
|
+
/**
|
|
9796
|
+
* The name of the author of the message.
|
|
9797
|
+
*
|
|
9798
|
+
* This is required if the role is `function`.
|
|
9799
|
+
*/
|
|
9800
|
+
author?: string;
|
|
9801
|
+
|
|
9802
|
+
/**
|
|
9803
|
+
* The reason why the message was finished.
|
|
9804
|
+
*/
|
|
9805
|
+
finishReason?: string;
|
|
9806
|
+
}
|
|
9807
|
+
|
|
9808
|
+
|
|
9809
|
+
/**
|
|
9810
|
+
* Defines an interface that represents options for {@link ai.chat}.
|
|
9811
|
+
*
|
|
9812
|
+
* @dochash types/ai
|
|
9813
|
+
* @docname AIChatOptions
|
|
9814
|
+
*/
|
|
9815
|
+
export interface AIChatOptions extends RecordActionOptions {
|
|
9816
|
+
/**
|
|
9817
|
+
* The model that should be used.
|
|
9818
|
+
*
|
|
9819
|
+
* If not specified, then a default will be used.
|
|
9820
|
+
*
|
|
9821
|
+
* Currently, the following models are supported:
|
|
9822
|
+
*
|
|
9823
|
+
* - `gpt-4`
|
|
9824
|
+
* - `gpt-3.5-turbo`
|
|
9825
|
+
*/
|
|
9826
|
+
preferredModel?: 'gpt-4' | 'gpt-3.5-turbo';
|
|
9827
|
+
|
|
9828
|
+
/**
|
|
9829
|
+
* The temperature that should be used.
|
|
9830
|
+
*
|
|
9831
|
+
* If not specified, then a default will be used.
|
|
9832
|
+
*/
|
|
9833
|
+
temperature?: number;
|
|
9834
|
+
|
|
9835
|
+
/**
|
|
9836
|
+
* The nucleus sampling probability.
|
|
9837
|
+
*/
|
|
9838
|
+
topP?: number;
|
|
9839
|
+
|
|
9840
|
+
/**
|
|
9841
|
+
* The presence penalty.
|
|
9842
|
+
*
|
|
9843
|
+
* Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
|
|
9844
|
+
*/
|
|
9845
|
+
presencePenalty?: number;
|
|
9846
|
+
|
|
9847
|
+
/**
|
|
9848
|
+
* The frequency penalty.
|
|
9849
|
+
*
|
|
9850
|
+
* Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
|
|
9851
|
+
*/
|
|
9852
|
+
frequencyPenalty?: number;
|
|
9853
|
+
|
|
9854
|
+
/**
|
|
9855
|
+
* The list of stop words that should be used.
|
|
9856
|
+
*
|
|
9857
|
+
* If the AI generates a sequence of tokens that match one of the given words, then it will stop generating tokens.
|
|
9858
|
+
*/
|
|
9859
|
+
stopWords?: string[];
|
|
9860
|
+
}
|
|
9861
|
+
|
|
9862
|
+
/**
|
|
9863
|
+
* Defines an interface that represents options for {@link ai.generateSkybox-string}.
|
|
9864
|
+
*
|
|
9865
|
+
* @dochash types/ai
|
|
9866
|
+
* @docname AIGenerateSkyboxOptions
|
|
9867
|
+
*/
|
|
9868
|
+
export interface AIGenerateSkyboxOptions extends RecordActionOptions {
|
|
9869
|
+
/**
|
|
9870
|
+
* Options that are specific to blockade-labs.
|
|
9871
|
+
*/
|
|
9872
|
+
blockadeLabs?: AIGenerateSkyboxBlockadeLabsOptions;
|
|
9873
|
+
}
|
|
9874
|
+
|
|
9875
|
+
/**
|
|
9876
|
+
* Options that are specific to Blockade Labs implementations for {@link ai.generateSkybox-string}.
|
|
9877
|
+
*
|
|
9878
|
+
* @dochash types/ai
|
|
9879
|
+
* @docname AIGenerateSkyboxOptions
|
|
9880
|
+
*/
|
|
9881
|
+
export interface AIGenerateSkyboxBlockadeLabsOptions {
|
|
9882
|
+
/**
|
|
9883
|
+
* The pre-defined style ID for the skybox.
|
|
9884
|
+
*/
|
|
9885
|
+
skyboxStyleId?: number;
|
|
9886
|
+
|
|
9887
|
+
/**
|
|
9888
|
+
* The ID of a previously generated skybox.
|
|
9889
|
+
*/
|
|
9890
|
+
remixImagineId?: number;
|
|
9891
|
+
|
|
9892
|
+
/**
|
|
9893
|
+
* The random seed to use for generating the skybox.
|
|
9894
|
+
*/
|
|
9895
|
+
seed?: number;
|
|
9896
|
+
}
|
|
9897
|
+
|
|
9898
|
+
/**
|
|
9899
|
+
* Defines an interface that represents a request for {@link ai.generateSkybox-request}.
|
|
9900
|
+
*
|
|
9901
|
+
* @dochash types/ai
|
|
9902
|
+
* @docname AIGenerateSkyboxRequest
|
|
9903
|
+
*/
|
|
9904
|
+
export interface AIGenerateSkyboxRequest {
|
|
9905
|
+
/**
|
|
9906
|
+
* The prompt that describes what the generated skybox should look like.
|
|
9907
|
+
*/
|
|
9908
|
+
prompt: string;
|
|
9909
|
+
|
|
9910
|
+
/**
|
|
9911
|
+
* The prompt that that describes what the generated skybox should avoid looking like.
|
|
9912
|
+
*/
|
|
9913
|
+
negativePrompt?: string;
|
|
9914
|
+
|
|
9915
|
+
/**
|
|
9916
|
+
* The options that should be included in the request.
|
|
9917
|
+
*/
|
|
9918
|
+
options: AIGenerateSkyboxOptions;
|
|
9919
|
+
}
|
|
9920
|
+
|
|
9921
|
+
/**
|
|
9922
|
+
* Defines an interface that represents the result from {@link ai.generateSkybox-request}.
|
|
9923
|
+
*
|
|
9924
|
+
* @dochash types/ai
|
|
9925
|
+
* @docname AIGenerateSkyboxResult
|
|
9926
|
+
*/
|
|
9927
|
+
export interface AIGenerateSkyboxResult {
|
|
9928
|
+
/**
|
|
9929
|
+
* The URL that the generated skybox is located at.
|
|
9930
|
+
*/
|
|
9931
|
+
fileUrl: string;
|
|
9932
|
+
|
|
9933
|
+
/**
|
|
9934
|
+
* The URL that the thumbnail for the generated skybox is located at.
|
|
9935
|
+
*/
|
|
9936
|
+
thumbnailUrl?: string;
|
|
9937
|
+
}
|
|
9938
|
+
|
|
9939
|
+
interface Ai {
|
|
9940
|
+
/**
|
|
9941
|
+
* Sends a chat message to the AI.
|
|
9942
|
+
* Returns a promise that contains the response from the AI.
|
|
9943
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
9944
|
+
*
|
|
9945
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
9946
|
+
*
|
|
9947
|
+
* @param message The message that should be sent to the AI.
|
|
9948
|
+
* @param options The options that should be used.
|
|
9949
|
+
*
|
|
9950
|
+
* @example Send a message to the AI and log the response.
|
|
9951
|
+
* const response = await ai.chat("Hello!");
|
|
9952
|
+
* console.log(response);
|
|
9953
|
+
*
|
|
9954
|
+
* @dochash actions/ai
|
|
9955
|
+
* @doctitle AI Actions
|
|
9956
|
+
* @docsidebar AI
|
|
9957
|
+
* @docdescription AI actions are functions that make it easier to work with the AI.
|
|
9958
|
+
* @docname ai.chat
|
|
9959
|
+
* @docid ai.chat-string
|
|
9960
|
+
*/
|
|
9961
|
+
chat(message: string, options?: AIChatOptions): Promise<string>;
|
|
9962
|
+
|
|
9963
|
+
/**
|
|
9964
|
+
* Sends a chat message to the AI.
|
|
9965
|
+
* Returns a promise that contains the response from the AI.
|
|
9966
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
9967
|
+
*
|
|
9968
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
9969
|
+
*
|
|
9970
|
+
* @param message The message that should be sent to the AI.
|
|
9971
|
+
* @param options The options that should be used.
|
|
9972
|
+
*
|
|
9973
|
+
* @example Send a message to the AI and log the response.
|
|
9974
|
+
* const response = await ai.chat({
|
|
9975
|
+
* role: "user",
|
|
9976
|
+
* content: "Hello!"
|
|
9977
|
+
* });
|
|
9978
|
+
* console.log(`${response.role}: ${response.content}`);
|
|
9979
|
+
*
|
|
9980
|
+
* @dochash actions/ai
|
|
9981
|
+
* @docname ai.chat
|
|
9982
|
+
* @docid ai.chat-message
|
|
9983
|
+
*/
|
|
9984
|
+
chat(
|
|
9985
|
+
message: AIChatMessage,
|
|
9986
|
+
options?: AIChatOptions
|
|
9987
|
+
): Promise<AIChatMessage>;
|
|
9988
|
+
|
|
9989
|
+
/**
|
|
9990
|
+
* Sends a chat message to the AI.
|
|
9991
|
+
* Returns a promise that contains the response from the AI.
|
|
9992
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
9993
|
+
*
|
|
9994
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
9995
|
+
*
|
|
9996
|
+
* @param message The message that should be sent to the AI.
|
|
9997
|
+
* @param options The options that should be used.
|
|
9998
|
+
*
|
|
9999
|
+
* @example Send a message to the AI and log the response.
|
|
10000
|
+
* const response = await ai.chat([
|
|
10001
|
+
* {
|
|
10002
|
+
* role: "system",
|
|
10003
|
+
* content: "You are a helpful assistant."
|
|
10004
|
+
* },
|
|
10005
|
+
* {
|
|
10006
|
+
* role: "user",
|
|
10007
|
+
* content: "Hello!"
|
|
10008
|
+
* }
|
|
10009
|
+
* ]);
|
|
10010
|
+
* console.log(`${response.role}: ${response.content}`);
|
|
10011
|
+
*
|
|
10012
|
+
* @example Build a basic chat bot.
|
|
10013
|
+
* const messages = [
|
|
10014
|
+
* {
|
|
10015
|
+
* role: "system",
|
|
10016
|
+
* content: "You are a helpful assistant."
|
|
10017
|
+
* },
|
|
10018
|
+
* ];
|
|
10019
|
+
*
|
|
10020
|
+
* while(true) {
|
|
10021
|
+
* const userInput = await os.showInput();
|
|
10022
|
+
* if (!userInput) {
|
|
10023
|
+
* break;
|
|
10024
|
+
* }
|
|
10025
|
+
* messages.push({
|
|
10026
|
+
* role: "user",
|
|
10027
|
+
* content: userInput
|
|
10028
|
+
* });
|
|
10029
|
+
*
|
|
10030
|
+
* const response = await ai.chat(messages);
|
|
10031
|
+
* messages.push(response);
|
|
10032
|
+
* os.toast(response.content);
|
|
10033
|
+
* }
|
|
10034
|
+
*
|
|
10035
|
+
* os.toast("Goodbye!");
|
|
10036
|
+
*
|
|
10037
|
+
* @dochash actions/ai
|
|
10038
|
+
* @docname ai.chat
|
|
10039
|
+
* @docid ai.chat-messages
|
|
10040
|
+
*/
|
|
10041
|
+
chat(
|
|
10042
|
+
messages: AIChatMessage[],
|
|
10043
|
+
options?: AIChatOptions
|
|
10044
|
+
): Promise<AIChatMessage>;
|
|
10045
|
+
|
|
10046
|
+
/**
|
|
10047
|
+
* Sends a chat message to the AI.
|
|
10048
|
+
* Returns a promise that contains the response from the AI.
|
|
10049
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
10050
|
+
*
|
|
10051
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
10052
|
+
*
|
|
10053
|
+
* @param message The message that should be sent to the AI.
|
|
10054
|
+
* @param options The options that should be used.
|
|
10055
|
+
*
|
|
10056
|
+
* @example Send a message to the AI and log the response.
|
|
10057
|
+
* const response = await ai.chat([
|
|
10058
|
+
* {
|
|
10059
|
+
* role: "system",
|
|
10060
|
+
* content: "You are a helpful assistant."
|
|
10061
|
+
* },
|
|
10062
|
+
* {
|
|
10063
|
+
* role: "user",
|
|
10064
|
+
* content: "Hello!"
|
|
10065
|
+
* }
|
|
10066
|
+
* ]);
|
|
10067
|
+
* console.log(`${response.role}: ${response.content}`);
|
|
10068
|
+
*
|
|
10069
|
+
* @example Build a basic chat bot.
|
|
10070
|
+
* const messages = [
|
|
10071
|
+
* {
|
|
10072
|
+
* role: "system",
|
|
10073
|
+
* content: "You are a helpful assistant."
|
|
10074
|
+
* },
|
|
10075
|
+
* ];
|
|
10076
|
+
*
|
|
10077
|
+
* while(true) {
|
|
10078
|
+
* const userInput = await os.showInput();
|
|
10079
|
+
* if (!userInput) {
|
|
10080
|
+
* break;
|
|
10081
|
+
* }
|
|
10082
|
+
* messages.push({
|
|
10083
|
+
* role: "user",
|
|
10084
|
+
* content: userInput
|
|
10085
|
+
* });
|
|
10086
|
+
*
|
|
10087
|
+
* const response = await ai.chat(messages);
|
|
10088
|
+
* messages.push(response);
|
|
10089
|
+
* os.toast(response.content);
|
|
10090
|
+
* }
|
|
10091
|
+
*
|
|
10092
|
+
* os.toast("Goodbye!");
|
|
10093
|
+
*
|
|
10094
|
+
* @dochash actions/ai
|
|
10095
|
+
* @docname ai.chat
|
|
10096
|
+
* @docid ai.chat-messages
|
|
10097
|
+
*/
|
|
10098
|
+
chat(
|
|
10099
|
+
messages: string | AIChatMessage | AIChatMessage[],
|
|
10100
|
+
options?: AIChatOptions
|
|
10101
|
+
): Promise<AIChatMessage | string>;
|
|
10102
|
+
|
|
10103
|
+
/**
|
|
10104
|
+
* Generates a [skybox image](https://en.wikipedia.org/wiki/Skybox_%28video_games%29) from the given prompt.
|
|
10105
|
+
*
|
|
10106
|
+
* Returns a promise that resolves with a URL to the generated image that can be used as the {@tag formAddress} of a bot that has {@tag form} set to `skybox`.
|
|
10107
|
+
*
|
|
10108
|
+
* @param prompt the string that describes what the skybox should look like.
|
|
10109
|
+
* @param negativePrompt the string that describes what the skybox should avoid looking like.
|
|
10110
|
+
* @param options the additional options that should be used.
|
|
10111
|
+
*
|
|
10112
|
+
* @example Generate a skybox from a prompt.
|
|
10113
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.");
|
|
10114
|
+
* masks.formAddress = skybox;
|
|
10115
|
+
*
|
|
10116
|
+
* @example Generate a skybox from a prompt and a negative prompt
|
|
10117
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.", "A skybox with a red sky and brown grass.");
|
|
10118
|
+
* masks.formAddress = skybox;
|
|
10119
|
+
*
|
|
10120
|
+
* @dochash actions/ai
|
|
10121
|
+
* @docname ai.generateSkybox
|
|
10122
|
+
* @docid ai.generateSkybox-string
|
|
10123
|
+
*/
|
|
10124
|
+
generateSkybox(prompt: string, negativePrompt?: string, options?: AIGenerateSkyboxOptions): Promise<string>;
|
|
10125
|
+
|
|
10126
|
+
/**
|
|
10127
|
+
* Generates a [skybox image](https://en.wikipedia.org/wiki/Skybox_%28video_games%29) from the given request object.
|
|
10128
|
+
*
|
|
10129
|
+
* Returns a promise that resolves with an object that contains a URL to the generated image that can be used as the {@tag formAddress} of a bot that has {@tag form} set to `skybox`.
|
|
10130
|
+
*
|
|
10131
|
+
* @param request the request object that describes what the skybox should look like.
|
|
10132
|
+
*
|
|
10133
|
+
* @example Generate a skybox from a prompt.
|
|
10134
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.");
|
|
10135
|
+
* masks.formAddress = skybox;
|
|
10136
|
+
*
|
|
10137
|
+
* @example Generate a skybox from a prompt and a negative prompt
|
|
10138
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.", "A skybox with a red sky and brown grass.");
|
|
10139
|
+
* masks.formAddress = skybox;
|
|
10140
|
+
*
|
|
10141
|
+
* @dochash actions/ai
|
|
10142
|
+
* @docname ai.generateSkybox
|
|
10143
|
+
* @docid ai.generateSkybox-request
|
|
10144
|
+
*/
|
|
10145
|
+
generateSkybox(request: AIGenerateSkyboxRequest): Promise<AIGenerateSkyboxResult>;
|
|
10146
|
+
|
|
10147
|
+
/**
|
|
10148
|
+
* Generates a [skybox image](https://en.wikipedia.org/wiki/Skybox_%28video_games%29) from the given request object.
|
|
10149
|
+
*
|
|
10150
|
+
* Returns a promise that resolves with an object that contains a URL to the generated image that can be used as the {@tag formAddress} of a bot that has {@tag form} set to `skybox`.
|
|
10151
|
+
*
|
|
10152
|
+
* @param request the request object that describes what the skybox should look like.
|
|
10153
|
+
* @param negativePrompt the string that describes what the skybox should avoid looking like.
|
|
10154
|
+
* @param options the additional options that should be used.
|
|
10155
|
+
*
|
|
10156
|
+
* @example Generate a skybox from a prompt.
|
|
10157
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.");
|
|
10158
|
+
* masks.formAddress = skybox;
|
|
10159
|
+
*
|
|
10160
|
+
* @example Generate a skybox from a prompt and a negative prompt
|
|
10161
|
+
* const skybox = await ai.generateSkybox("A skybox with a blue sky and green grass.", "A skybox with a red sky and brown grass.");
|
|
10162
|
+
* masks.formAddress = skybox;
|
|
10163
|
+
*
|
|
10164
|
+
* @dochash actions/ai
|
|
10165
|
+
* @docname ai.generateSkybox
|
|
10166
|
+
* @docid ai.generateSkybox-request
|
|
10167
|
+
*/
|
|
10168
|
+
generateSkybox(prompt: string | AIGenerateSkyboxRequest, negativePrompt?: string, options?: AIGenerateSkyboxOptions): Promise<string | AIGenerateSkyboxResult>
|
|
10169
|
+
}
|
|
10170
|
+
|
|
9763
10171
|
interface Os {
|
|
9764
10172
|
/**
|
|
9765
10173
|
* Sleeps for time in ms.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an interface that represents a generic error.
|
|
3
|
+
*
|
|
4
|
+
* @dochash types/error
|
|
5
|
+
* @docname GenericError
|
|
6
|
+
*/
|
|
7
|
+
export interface GenericError {
|
|
8
|
+
/**
|
|
9
|
+
* The error code.
|
|
10
|
+
*/
|
|
11
|
+
errorCode: string;
|
|
12
|
+
/**
|
|
13
|
+
* The error message.
|
|
14
|
+
*/
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Defines a class that represents a generic CasualOS error.
|
|
19
|
+
*
|
|
20
|
+
* @dochash types/error
|
|
21
|
+
* @doctitle Error Types
|
|
22
|
+
* @docsidebar Error
|
|
23
|
+
* @docdescription Types that contain information about errors that can occur in CasualOS.
|
|
24
|
+
* @docname CasualOSError
|
|
25
|
+
*/
|
|
26
|
+
export declare class CasualOSError extends Error {
|
|
27
|
+
/**
|
|
28
|
+
* The error code that occurred.
|
|
29
|
+
*/
|
|
30
|
+
errorCode: string;
|
|
31
|
+
/**
|
|
32
|
+
* The error message that occurred.
|
|
33
|
+
*/
|
|
34
|
+
errorMessage: string;
|
|
35
|
+
constructor(error: GenericError | string);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=CasualOSError.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a class that represents a generic CasualOS error.
|
|
3
|
+
*
|
|
4
|
+
* @dochash types/error
|
|
5
|
+
* @doctitle Error Types
|
|
6
|
+
* @docsidebar Error
|
|
7
|
+
* @docdescription Types that contain information about errors that can occur in CasualOS.
|
|
8
|
+
* @docname CasualOSError
|
|
9
|
+
*/
|
|
10
|
+
export class CasualOSError extends Error {
|
|
11
|
+
constructor(error) {
|
|
12
|
+
super(typeof error === 'string'
|
|
13
|
+
? error
|
|
14
|
+
: `${error.errorCode}: ${error.errorMessage}`);
|
|
15
|
+
if (typeof error === 'string') {
|
|
16
|
+
this.errorCode = 'error';
|
|
17
|
+
this.errorMessage = error;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.errorCode = error.errorCode;
|
|
21
|
+
this.errorMessage = error.errorMessage;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CasualOSError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CasualOSError.js","sourceRoot":"","sources":["CasualOSError.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAWpC,YAAY,KAA4B;QACpC,KAAK,CACD,OAAO,KAAK,KAAK,QAAQ;YACrB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,YAAY,EAAE,CACpD,CAAC;QACF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;YACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC7B;aAAM;YACH,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YACjC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;SAC1C;IACL,CAAC;CACJ"}
|