@fnlb-project/shared 1.5.10 → 1.5.11
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/dist/commands/index.js +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +2 -1
package/dist/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class w{params;constructor(f){this.params=f??[]}addParam(f,b,h,j,v){return this.params.push({id:f,type:0,name:b,description:h,extended:j??!1,examples:v}),this}addOptionalParam(f,b,h,j,v){return this.params.push({id:f,type:1,name:b,description:h,extended:j??!1,examples:v}),this}addSelect(f,b,h,j,v){return this.params.push({id:f,type:2,name:b,description:h,options:j,examples:v}),this}addOptionalSelect(f,b,h,j,v){return this.params.push({id:f,type:3,name:b,description:h,options:j,examples:v}),this}addNumericParam(f,b,h,j){return this.params.push({id:f,type:4,name:b,description:h,examples:j}),this}addNumericOptionalParam(f,b,h,j){return this.params.push({id:f,type:5,name:b,description:h,examples:j}),this}getUsage(){return this.params.map((f)=>w.getParamUsage(f)).join(" ")}getExample(){return this.params.map((f)=>w.getParamExample(f)).join(" ")}static getParamUsage(f){switch(f.type){case 0:return`<${f.extended?"...":""}${f.name}>`;case 1:return`[${f.extended?"...":""}${f.name}]`;case 2:return`<${f.options.map((b)=>b.name).join(" | ")}>`;case 3:return`[${f.options.map((b)=>b.name).join(" | ")}]`;case 4:return`<$${f.name}>`;case 5:return`[$${f.name}]`;default:return""}}static getParamExample(f){let b=(q)=>q[Math.floor(Math.random()*q.length)],h=(q)=>q?b(q):b(["Angel","Brian","Catherine","David","Emma","Frank","Grace","Hannah","Ian","Julia"]),j=(q)=>q?b(q):b(["Brian Stronghold","Catherine Joyful","David Noble","Emma Graceful","Frank Fearless","Grace Serene","Hannah Bold","Ian Clever","Julia Kindhearted"]),v=(q)=>b(q)?.name,z=(q)=>q?b(q):Math.floor(Math.random()*1000);switch(f.type){case 1:case 0:return f.extended?j(f.examples):h(f.examples);case 2:case 3:return v(f.options);case 4:case 5:return z(f.examples);default:return""}}}export{w as CommandUsageClient};
|
package/dist/errors/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u;((n)=>{n.GenericUnknown="net.fnlb.errors.generic.unknown";n.GenericInternalError="net.fnlb.errors.generic.internal_error";n.GenericValidationFailed="net.fnlb.errors.generic.validation_failed";n.GenericParseFailed="net.fnlb.errors.generic.parse_failed";n.GenericNotFound="net.fnlb.errors.generic.not_found";n.GenericAlreadyExists="net.fnlb.errors.generic.already_exists";n.CommonInvalidRequest="net.fnlb.errors.common.invalid_request";n.CommonUnableToProcessRequest="net.fnlb.errors.common.unable_to_process_request";n.CommonInvalidFieldsLength="net.fnlb.errors.common.invalid_body_fields_length";n.CommonRateLimitExceeded="net.fnlb.errors.common.rate_limit_exceeded";n.CommonUnableToSaveToDatabase="net.fnlb.errors.common.unable_to_save_to_database";n.AuthInvalidToken="net.fnlb.errors.auth.invalid_token";n.AuthInvalidAPIToken="net.fnlb.errors.auth.invalid_api_token";n.AuthInvalidCaptchaToken="net.fnlb.errors.auth.invalid_captcha_token";n.AuthUnauthorized="net.fnlb.errors.auth.unauthorized";n.AuthForbidden="net.fnlb.errors.auth.forbidden";n.AuthUserBanned="net.fnlb.errors.auth.user_banned";n.Oauth2InvalidCode="net.fnlb.errors.oauth2.invalid_code";n.Oauth2InvalidScope="net.fnlb.errors.oauth2.invalid_scope";n.Oauth2TokenInvalid="net.fnlb.errors.oauth2.token_invalid";n.Oauth2UnableToFetchUser="net.fnlb.errors.oauth2.unable_to_fetch_user";n.Oauth2UnableToFetchConnections="net.fnlb.errors.oauth2.unable_to_fetch_connections";n.Oauth2UserWithoutConnection="net.fnlb.errors.oauth2.user_without_connection";n.Oauth2ConnectionNotVerified="net.fnlb.errors.oauth2.connection_not_verified";n.ReleaseNotFound="net.fnlb.errors.release.no_release_found";n.ReleaseVersionAlreadyExists="net.fnlb.errors.release.version_already_exists"})(u||={});var c;((o)=>{o.LoginInvalidCredentials="net.fnlb.errors.login.invalid_credentials";o.LoginInvalidEmail="net.fnlb.errors.login.invalid_email";o.LoginInvalidOrUsedEmail="net.fnlb.errors.login.invalid_or_used_email";o.AuthPasswordConfirmationInvalid="net.fnlb.errors.auth.invalid_password_confirmation"})(c||={});var e={...u,...c};var l={[e.GenericUnknown]:{type:"general",message:"An unknown error occurred. Please try again later."},[e.GenericInternalError]:{type:"general",message:"An internal error occurred. Please try again later."},[e.GenericValidationFailed]:{type:"general",message:"Validation of the request data failed."},[e.GenericParseFailed]:{type:"general",message:"The request could not be parsed. This may be due to a malformed input or an unsupported data format."},[e.GenericNotFound]:{type:"general",message:"The requested resource does not exist."},[e.GenericAlreadyExists]:{type:"general",message:"This resource already exists."},[e.CommonInvalidRequest]:{type:"general",message:"The request is not valid."},[e.CommonUnableToProcessRequest]:{type:"general",message:"Unable to process the request. Please try again later."},[e.CommonInvalidFieldsLength]:{type:"general",message:"The body fields have an invalid length."},[e.CommonRateLimitExceeded]:{type:"general",message:"You are being rate limited."},[e.CommonUnableToSaveToDatabase]:{type:"general",message:"Unable to save changes. Please check all fields."},[e.AuthInvalidToken]:{type:"general",message:"Invalid token provided."},[e.AuthInvalidAPIToken]:{type:"general",message:"Invalid API token provided."},[e.AuthInvalidCaptchaToken]:{type:"general",message:"Sorry, the captcha was not resolved correctly. Please try again."},[e.AuthUnauthorized]:{type:"general",message:"You lack the necessary authorization to perform this action."},[e.AuthForbidden]:{type:"general",message:"You do not have permission to perform this action."},[e.AuthUserBanned]:{type:"general",message:"Your account is banned from the service."},[e.AuthPasswordConfirmationInvalid]:{type:"input",message:"Sorry, the password is invalid or does not match."},[e.LoginInvalidCredentials]:{type:"input",message:"The email or password is incorrect."},[e.LoginInvalidEmail]:{type:"input",message:"The email is invalid."},[e.LoginInvalidOrUsedEmail]:{type:"input",message:"The email is invalid or is already used."},[e.Oauth2InvalidCode]:{type:"general",message:"Unable to verify your request at this moment. Please try again later."},[e.Oauth2InvalidScope]:{type:"general",message:"Invalid scope provided."},[e.Oauth2TokenInvalid]:{type:"general",message:"Unable to verify Oauth2 token. Please try again later."},[e.Oauth2UnableToFetchUser]:{type:"general",message:"Unable to obtain user information. Please try again later."},[e.Oauth2UnableToFetchConnections]:{type:"general",message:"Unable to obtain connections. Please try again later."},[e.Oauth2UserWithoutConnection]:{type:"general",message:"No connections found. Please add a connection and try again later."},[e.Oauth2ConnectionNotVerified]:{type:"general",message:"The connection is not verified. Please try again later."},[e.ReleaseNotFound]:{type:"general",message:"Sorry, no release found. Please try again later."},[e.ReleaseVersionAlreadyExists]:{type:"general",message:"Release version already exists."}};class a{static getError(t){return l[t]??l[e.GenericUnknown]}static getErrorResponse(t,i){if(Array.isArray(t))return{type:"error",errors:t.map((s)=>a.parseErrorCode(s,i))};else return{type:"error",errors:[a.parseErrorCode(t,i)]}}static parseErrorResponse(t){if(!a.isErrorResponse(t))return null;return t.errors}static isErrorResponse(t){return t?.type==="error"}static parseErrorCode(t,i){let{type:s,message:r}=a.getError(t);if(s==="input"){if(i===void 0)throw new Error("Input is required for Input errors");return{type:s,message:r,errorCode:t,input:i}}else return{type:s,message:r,errorCode:t}}static handleErrors(t,i){switch(t){case"VALIDATION":return[400,a.getErrorResponse(e.GenericValidationFailed)];case"NOT_FOUND":return[404,a.getErrorResponse(e.GenericNotFound)];case"PARSE":return[400,a.getErrorResponse(e.GenericParseFailed)];case"INTERNAL_SERVER_ERROR":return console.error(i),[500,a.getErrorResponse(e.GenericInternalError)];default:return console.error(i),[500,a.getErrorResponse(e.GenericUnknown)]}}}class d{}export{d as GenericErrorSender,a as ErrorHandler};
|
package/dist/http/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d;((s)=>{s.GenericUnknown="net.fnlb.errors.generic.unknown";s.GenericInternalError="net.fnlb.errors.generic.internal_error";s.GenericValidationFailed="net.fnlb.errors.generic.validation_failed";s.GenericParseFailed="net.fnlb.errors.generic.parse_failed";s.GenericNotFound="net.fnlb.errors.generic.not_found";s.GenericAlreadyExists="net.fnlb.errors.generic.already_exists";s.CommonInvalidRequest="net.fnlb.errors.common.invalid_request";s.CommonUnableToProcessRequest="net.fnlb.errors.common.unable_to_process_request";s.CommonInvalidFieldsLength="net.fnlb.errors.common.invalid_body_fields_length";s.CommonRateLimitExceeded="net.fnlb.errors.common.rate_limit_exceeded";s.CommonUnableToSaveToDatabase="net.fnlb.errors.common.unable_to_save_to_database";s.AuthInvalidToken="net.fnlb.errors.auth.invalid_token";s.AuthInvalidAPIToken="net.fnlb.errors.auth.invalid_api_token";s.AuthInvalidCaptchaToken="net.fnlb.errors.auth.invalid_captcha_token";s.AuthUnauthorized="net.fnlb.errors.auth.unauthorized";s.AuthForbidden="net.fnlb.errors.auth.forbidden";s.AuthUserBanned="net.fnlb.errors.auth.user_banned";s.Oauth2InvalidCode="net.fnlb.errors.oauth2.invalid_code";s.Oauth2InvalidScope="net.fnlb.errors.oauth2.invalid_scope";s.Oauth2TokenInvalid="net.fnlb.errors.oauth2.token_invalid";s.Oauth2UnableToFetchUser="net.fnlb.errors.oauth2.unable_to_fetch_user";s.Oauth2UnableToFetchConnections="net.fnlb.errors.oauth2.unable_to_fetch_connections";s.Oauth2UserWithoutConnection="net.fnlb.errors.oauth2.user_without_connection";s.Oauth2ConnectionNotVerified="net.fnlb.errors.oauth2.connection_not_verified";s.ReleaseNotFound="net.fnlb.errors.release.no_release_found";s.ReleaseVersionAlreadyExists="net.fnlb.errors.release.version_already_exists"})(d||={});var u;((l)=>{l.LoginInvalidCredentials="net.fnlb.errors.login.invalid_credentials";l.LoginInvalidEmail="net.fnlb.errors.login.invalid_email";l.LoginInvalidOrUsedEmail="net.fnlb.errors.login.invalid_or_used_email";l.AuthPasswordConfirmationInvalid="net.fnlb.errors.auth.invalid_password_confirmation"})(u||={});var e={...d,...u};var r={[e.GenericUnknown]:{type:"general",message:"An unknown error occurred. Please try again later."},[e.GenericInternalError]:{type:"general",message:"An internal error occurred. Please try again later."},[e.GenericValidationFailed]:{type:"general",message:"Validation of the request data failed."},[e.GenericParseFailed]:{type:"general",message:"The request could not be parsed. This may be due to a malformed input or an unsupported data format."},[e.GenericNotFound]:{type:"general",message:"The requested resource does not exist."},[e.GenericAlreadyExists]:{type:"general",message:"This resource already exists."},[e.CommonInvalidRequest]:{type:"general",message:"The request is not valid."},[e.CommonUnableToProcessRequest]:{type:"general",message:"Unable to process the request. Please try again later."},[e.CommonInvalidFieldsLength]:{type:"general",message:"The body fields have an invalid length."},[e.CommonRateLimitExceeded]:{type:"general",message:"You are being rate limited."},[e.CommonUnableToSaveToDatabase]:{type:"general",message:"Unable to save changes. Please check all fields."},[e.AuthInvalidToken]:{type:"general",message:"Invalid token provided."},[e.AuthInvalidAPIToken]:{type:"general",message:"Invalid API token provided."},[e.AuthInvalidCaptchaToken]:{type:"general",message:"Sorry, the captcha was not resolved correctly. Please try again."},[e.AuthUnauthorized]:{type:"general",message:"You lack the necessary authorization to perform this action."},[e.AuthForbidden]:{type:"general",message:"You do not have permission to perform this action."},[e.AuthUserBanned]:{type:"general",message:"Your account is banned from the service."},[e.AuthPasswordConfirmationInvalid]:{type:"input",message:"Sorry, the password is invalid or does not match."},[e.LoginInvalidCredentials]:{type:"input",message:"The email or password is incorrect."},[e.LoginInvalidEmail]:{type:"input",message:"The email is invalid."},[e.LoginInvalidOrUsedEmail]:{type:"input",message:"The email is invalid or is already used."},[e.Oauth2InvalidCode]:{type:"general",message:"Unable to verify your request at this moment. Please try again later."},[e.Oauth2InvalidScope]:{type:"general",message:"Invalid scope provided."},[e.Oauth2TokenInvalid]:{type:"general",message:"Unable to verify Oauth2 token. Please try again later."},[e.Oauth2UnableToFetchUser]:{type:"general",message:"Unable to obtain user information. Please try again later."},[e.Oauth2UnableToFetchConnections]:{type:"general",message:"Unable to obtain connections. Please try again later."},[e.Oauth2UserWithoutConnection]:{type:"general",message:"No connections found. Please add a connection and try again later."},[e.Oauth2ConnectionNotVerified]:{type:"general",message:"The connection is not verified. Please try again later."},[e.ReleaseNotFound]:{type:"general",message:"Sorry, no release found. Please try again later."},[e.ReleaseVersionAlreadyExists]:{type:"general",message:"Release version already exists."}};class o{static getError(t){return r[t]??r[e.GenericUnknown]}static getErrorResponse(t,i){if(Array.isArray(t))return{type:"error",errors:t.map((n)=>o.parseErrorCode(n,i))};else return{type:"error",errors:[o.parseErrorCode(t,i)]}}static parseErrorResponse(t){if(!o.isErrorResponse(t))return null;return t.errors}static isErrorResponse(t){return t?.type==="error"}static parseErrorCode(t,i){let{type:n,message:a}=o.getError(t);if(n==="input"){if(i===void 0)throw new Error("Input is required for Input errors");return{type:n,message:a,errorCode:t,input:i}}else return{type:n,message:a,errorCode:t}}static handleErrors(t,i){switch(t){case"VALIDATION":return[400,o.getErrorResponse(e.GenericValidationFailed)];case"NOT_FOUND":return[404,o.getErrorResponse(e.GenericNotFound)];case"PARSE":return[400,o.getErrorResponse(e.GenericParseFailed)];case"INTERNAL_SERVER_ERROR":return console.error(i),[500,o.getErrorResponse(e.GenericInternalError)];default:return console.error(i),[500,o.getErrorResponse(e.GenericUnknown)]}}}class c{static get(t,i,n,a){return this.request(t,i,n,{...a,method:"GET"})}static post(t,i,n,a){return this.request(t,i,n,{...a,method:"POST"})}static put(t,i,n,a){return this.request(t,i,n,{...a,method:"PUT"})}static patch(t,i,n,a){return this.request(t,i,n,{...a,method:"PATCH"})}static delete(t,i,n,a){return this.request(t,i,n,{...a,method:"DELETE"})}static async request(t,i,n,a){let l={...a,body:a.body?JSON.stringify(a.body):void 0,headers:a.headers??{}};if(n)l.headers.Authorization=n;if(!l.headers["Content-Type"]&&l.body)l.headers["Content-Type"]="application/json";let m=await fetch(t+i,l);return c.parseResponse(m)}static async parseResponse(t){if(t.headers.get("Content-Type")?.includes("text/plain")){let n=await t.text(),a=o.parseErrorResponse(n);if(a)return{data:void 0,errors:a};if(!t.ok)throw new Error(`Request failed with status code ${t.status}: ${n}`);return{data:n,errors:void 0}}else{let n=await t.json(),a=o.parseErrorResponse(n);if(a)return{data:void 0,errors:a};if(!t.ok)throw new Error(`Request failed with status code ${t.status}: ${JSON.stringify(n,null,2)}`);return{data:n,errors:void 0}}}}export{c as HTTP};
|
package/dist/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var f;((_)=>{_[_.Public=0]="Public";_[_.Private=1]="Private"})(f||={});var
|
|
1
|
+
var f;((_)=>{_[_.Public=0]="Public";_[_.Private=1]="Private"})(f||={});var d;((u)=>{u[u.Offline=0]="Offline";u[u.Booting=1]="Booting";u[u.Available=2]="Available";u[u.Busy=3]="Busy";u[u.Disconnected=4]="Disconnected"})(d||={});var i;((u)=>{u[u.Neutral=0]="Neutral";u[u.Success=1]="Success";u[u.Info=2]="Info";u[u.Warn=3]="Warn";u[u.Error=4]="Error"})(i||={});var c;((s)=>{s.Win="WIN";s.Mac="MAC";s.Psn="PSN";s.Xbl="XBL";s.Swt="SWT";s.Ios="IOS";s.And="AND";s.Ps5="PS5";s.Xsx="XSX"})(c||={});var O;((_)=>{_[_.Public=0]="Public";_[_.Private=1]="Private"})(O||={});var U;((e)=>{e[e.Equals=0]="Equals";e[e.Includes=1]="Includes";e[e.StartsWith=2]="StartsWith";e[e.EndsWith=3]="EndsWith"})(U||={});var k;((l)=>{l[l.ChatBan=0]="ChatBan";l[l.Kick=1]="Kick";l[l.Block=2]="Block";l[l.RemoveFriend=3]="RemoveFriend";l[l.AddFriend=4]="AddFriend";l[l.Promote=5]="Promote";l[l.Copy=6]="Copy";l[l.Mimic=7]="Mimic";l[l.Hide=8]="Hide";l[l.Show=9]="Show";l[l.Blacklist=10]="Blacklist";l[l.Whitelist=11]="Whitelist"})(k||={});var t;((b)=>{b[b.RequiredParam=0]="RequiredParam";b[b.OptionalParam=1]="OptionalParam";b[b.RequiredSelect=2]="RequiredSelect";b[b.OptionalSelect=3]="OptionalSelect";b[b.RequiredNumericParam=4]="RequiredNumericParam";b[b.OptionalNumericParam=5]="OptionalNumericParam"})(t||={});var v;((n)=>{n.GenericUnknown="net.fnlb.errors.generic.unknown";n.GenericInternalError="net.fnlb.errors.generic.internal_error";n.GenericValidationFailed="net.fnlb.errors.generic.validation_failed";n.GenericParseFailed="net.fnlb.errors.generic.parse_failed";n.GenericNotFound="net.fnlb.errors.generic.not_found";n.GenericAlreadyExists="net.fnlb.errors.generic.already_exists";n.CommonInvalidRequest="net.fnlb.errors.common.invalid_request";n.CommonUnableToProcessRequest="net.fnlb.errors.common.unable_to_process_request";n.CommonInvalidFieldsLength="net.fnlb.errors.common.invalid_body_fields_length";n.CommonRateLimitExceeded="net.fnlb.errors.common.rate_limit_exceeded";n.CommonUnableToSaveToDatabase="net.fnlb.errors.common.unable_to_save_to_database";n.AuthInvalidToken="net.fnlb.errors.auth.invalid_token";n.AuthInvalidAPIToken="net.fnlb.errors.auth.invalid_api_token";n.AuthInvalidCaptchaToken="net.fnlb.errors.auth.invalid_captcha_token";n.AuthUnauthorized="net.fnlb.errors.auth.unauthorized";n.AuthForbidden="net.fnlb.errors.auth.forbidden";n.AuthUserBanned="net.fnlb.errors.auth.user_banned";n.Oauth2InvalidCode="net.fnlb.errors.oauth2.invalid_code";n.Oauth2InvalidScope="net.fnlb.errors.oauth2.invalid_scope";n.Oauth2TokenInvalid="net.fnlb.errors.oauth2.token_invalid";n.Oauth2UnableToFetchUser="net.fnlb.errors.oauth2.unable_to_fetch_user";n.Oauth2UnableToFetchConnections="net.fnlb.errors.oauth2.unable_to_fetch_connections";n.Oauth2UserWithoutConnection="net.fnlb.errors.oauth2.user_without_connection";n.Oauth2ConnectionNotVerified="net.fnlb.errors.oauth2.connection_not_verified";n.ReleaseNotFound="net.fnlb.errors.release.no_release_found";n.ReleaseVersionAlreadyExists="net.fnlb.errors.release.version_already_exists"})(v||={});var x;((e)=>{e.LoginInvalidCredentials="net.fnlb.errors.login.invalid_credentials";e.LoginInvalidEmail="net.fnlb.errors.login.invalid_email";e.LoginInvalidOrUsedEmail="net.fnlb.errors.login.invalid_or_used_email";e.AuthPasswordConfirmationInvalid="net.fnlb.errors.auth.invalid_password_confirmation"})(x||={});var P={...v,...x};var I;((e)=>{e.Username="username";e.Email="email";e.Password="password";e.Shared="shared"})(I||={});var q;((_)=>{_.General="general";_.Input="input"})(q||={});var w;((h)=>{h.Default="en";h.De="de";h.Es="es";h.Fr="fr";h.It="it";h.Pl="pl";h.Pt="pt";h.Tr="tr"})(w||={});export{w as Locales,x as InputErrorCodes,v as GeneralErrorCodes,q as ErrorTypes,I as ErrorInputTypes,P as ErrorCodes,i as CommandReplyFormat,t as CommandParamType,U as CategoryConfigTriggerStringDetectionMethod,k as CategoryConfigTriggerAction,c as CategoryConfigSupportedPlatforms,O as CategoryConfigPartyPrivacy,f as BotTypes,d as BotStatus};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnlb-project/shared",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.11",
|
|
4
4
|
"description": "FNLB Shared Library",
|
|
5
5
|
"files": ["dist"],
|
|
6
6
|
"author": "FNLB-Project",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"devDependencies": {
|
|
8
9
|
"@biomejs/biome": "^1.9.4",
|
|
9
10
|
"@types/bun": "^1.1.14",
|