🩹 Fix stupid
This should fix all the dumb mistakes and allow for easy access to development things.
This commit is contained in:
parent
3e3250491b
commit
195603e353
13
src/main.ts
13
src/main.ts
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable import/first */
|
||||||
|
|
||||||
// SpookVooper API - src/main.ts
|
// SpookVooper API - src/main.ts
|
||||||
// Written by Brendan Lane - https://brndnln.dev/
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
@ -11,6 +13,13 @@ import TransactionHub from './modules/TransactionHub'
|
||||||
import * as DepersonalizedUser from './modules/depersonalized/user'
|
import * as DepersonalizedUser from './modules/depersonalized/user'
|
||||||
import * as DepersonalizedGroup from './modules/depersonalized/group'
|
import * as DepersonalizedGroup from './modules/depersonalized/group'
|
||||||
|
|
||||||
|
import * as SvidTool from './modules/tools/SvidTool'
|
||||||
|
const Tools = { SvidTool }
|
||||||
|
|
||||||
|
import * as Interfaces from './modules/interfaces/Interfaces'
|
||||||
|
import * as Types from './modules/types/Types'
|
||||||
|
const Dev = { Interfaces, Types }
|
||||||
|
|
||||||
export {
|
export {
|
||||||
User,
|
User,
|
||||||
Group,
|
Group,
|
||||||
|
@ -19,5 +28,7 @@ export {
|
||||||
Stock,
|
Stock,
|
||||||
TransactionHub,
|
TransactionHub,
|
||||||
DepersonalizedUser,
|
DepersonalizedUser,
|
||||||
DepersonalizedGroup
|
DepersonalizedGroup,
|
||||||
|
Tools,
|
||||||
|
Dev
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr'
|
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr'
|
||||||
import { AuthEntity, QueueType } from './types/Types'
|
import { QueueType } from './types/Types'
|
||||||
|
import { EntityUser } from './interfaces/Interfaces'
|
||||||
|
|
||||||
const URI = 'https://spookvooper.com/ExchangeHub'
|
const URI = 'https://spookvooper.com/ExchangeHub'
|
||||||
const retryTime = 5
|
const retryTime = 5
|
||||||
|
@ -76,7 +77,7 @@ class ExchangeHub {
|
||||||
await this.start()
|
await this.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendChatMessage (message: string, accountid: string, auth: AuthEntity, ticker: string, tradeState: QueueType): Promise<any> {
|
public async sendChatMessage (message: string, accountid: string, auth: EntityUser, ticker: string, tradeState: QueueType): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
if (message === undefined || accountid === undefined || auth === undefined || ticker === undefined || tradeState === undefined) {
|
if (message === undefined || accountid === undefined || auth === undefined || ticker === undefined || tradeState === undefined) {
|
||||||
throw new Error('All parameters need to be set')
|
throw new Error('All parameters need to be set')
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { EntityUser } from './interfaces/Interfaces'
|
import { EntityUser } from './interfaces/Interfaces'
|
||||||
import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
import { CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
||||||
|
|
||||||
const groupURL = 'https://api.spookvooper.com/group'
|
const groupURL = 'https://api.spookvooper.com/group'
|
||||||
const ecoURL = 'https://api.spookvooper.com/eco'
|
const ecoURL = 'https://api.spookvooper.com/eco'
|
||||||
|
@ -176,7 +176,7 @@ class Group {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buyStock (ticker: string, amount: number, price: CreditAmount, auth: AuthEntity): Promise<any> {
|
public async buyStock (ticker: string, amount: number, price: CreditAmount, auth: EntityUser): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/submitStockBuy`, {
|
axios.get(`${ecoURL}/submitStockBuy`, {
|
||||||
params: {
|
params: {
|
||||||
|
@ -196,7 +196,7 @@ class Group {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sellStock (ticker: string, amount: number, price: CreditAmount, auth: AuthEntity): Promise<any> {
|
public async sellStock (ticker: string, amount: number, price: CreditAmount, auth: EntityUser): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/submitStockSell`, {
|
axios.get(`${ecoURL}/submitStockSell`, {
|
||||||
params: {
|
params: {
|
||||||
|
@ -216,7 +216,7 @@ class Group {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cancelOffer (orderid: number, auth: AuthEntity): Promise<any> {
|
public async cancelOffer (orderid: number, auth: EntityUser): Promise<any> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
axios.get(`${ecoURL}/cancelOrder`, {
|
axios.get(`${ecoURL}/cancelOrder`, {
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -32,6 +32,21 @@ class TransactionHub {
|
||||||
this.fromAccount = this.val.FromAccount
|
this.fromAccount = this.val.FromAccount
|
||||||
this.toAccount = this.val.ToAccount
|
this.toAccount = this.val.ToAccount
|
||||||
|
|
||||||
|
if (this.fromAccount.startsWith('u-')) {
|
||||||
|
this.fromType = 'user'
|
||||||
|
} else if (this.fromAccount.startsWith('g-')) {
|
||||||
|
this.fromType = 'group'
|
||||||
|
} else {
|
||||||
|
this.fromType = 'Error'
|
||||||
|
}
|
||||||
|
if (this.toAccount.startsWith('u-')) {
|
||||||
|
this.toType = 'user'
|
||||||
|
} else if (this.toAccount.startsWith('g-')) {
|
||||||
|
this.toType = 'group'
|
||||||
|
} else {
|
||||||
|
this.toType = 'Error'
|
||||||
|
}
|
||||||
|
|
||||||
observer.next(this.val)
|
observer.next(this.val)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -110,6 +110,22 @@ class User {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getDaysSinceLastMove (): Promise<any> {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
axios.get(`${userURL}/getDaysSinceLastMove`, {
|
||||||
|
params: {
|
||||||
|
svid: this.accountid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
public async sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any> {
|
public async sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any> {
|
||||||
if (typeof to === 'string') {
|
if (typeof to === 'string') {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// SpookVooper API - modules/tools/SvidTool.ts
|
||||||
|
// Written by Brendan Lane - https://brndnln.dev/
|
||||||
|
|
||||||
|
function svidType (svid: string): string {
|
||||||
|
if (svid.startsWith('u-')) {
|
||||||
|
return 'user'
|
||||||
|
} else if (svid.startsWith('g-')) {
|
||||||
|
return 'group'
|
||||||
|
} else if (svid.startsWith('i-')) {
|
||||||
|
return 'item'
|
||||||
|
} else {
|
||||||
|
throw new Error('This is either a legacy svid or it is not an svid! If it is a legacy SVID, it is no longer supported.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
svidType
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import { EntityUser, ConfigAuth } from './../interfaces/Interfaces'
|
||||||
|
|
||||||
type CreditAmount = string | number
|
type CreditAmount = string | number
|
||||||
type PaymentEntity = string | EntityUser
|
type PaymentEntity = string | EntityUser
|
||||||
type AuthEntity = EntityUser
|
type SvidType = 'user' | 'group' | 'item'
|
||||||
type GroupMember = string | EntityUser
|
type GroupMember = string | EntityUser
|
||||||
type AuthConfig = ConfigAuth
|
type AuthConfig = ConfigAuth
|
||||||
type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula'
|
type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula'
|
||||||
|
@ -16,7 +16,7 @@ type QueueType = 'BUY' | 'SELL'
|
||||||
export {
|
export {
|
||||||
CreditAmount,
|
CreditAmount,
|
||||||
PaymentEntity,
|
PaymentEntity,
|
||||||
AuthEntity,
|
SvidType,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
AuthConfig,
|
AuthConfig,
|
||||||
District,
|
District,
|
||||||
|
|
|
@ -6,4 +6,11 @@ import Stock from './modules/Stock'
|
||||||
import TransactionHub from './modules/TransactionHub'
|
import TransactionHub from './modules/TransactionHub'
|
||||||
import * as DepersonalizedUser from './modules/depersonalized/user'
|
import * as DepersonalizedUser from './modules/depersonalized/user'
|
||||||
import * as DepersonalizedGroup from './modules/depersonalized/group'
|
import * as DepersonalizedGroup from './modules/depersonalized/group'
|
||||||
export { User, Group, Auth, District, Stock, TransactionHub, DepersonalizedUser, DepersonalizedGroup }
|
declare const Tools: {
|
||||||
|
SvidTool: any
|
||||||
|
}
|
||||||
|
declare const Dev: {
|
||||||
|
Interfaces: any
|
||||||
|
Types: any
|
||||||
|
}
|
||||||
|
export { User, Group, Auth, District, Stock, TransactionHub, DepersonalizedUser, DepersonalizedGroup, Tools, Dev }
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { Observable } from 'rxjs'
|
import { QueueType } from './types/Types'
|
||||||
import { AuthEntity, QueueType } from './types/Types'
|
import { EntityUser } from './interfaces/Interfaces'
|
||||||
declare class ExchangeHub {
|
declare class ExchangeHub {
|
||||||
private readonly connection
|
private readonly connection
|
||||||
onOffer: Observable<unknown>
|
onOffer: any
|
||||||
onOfferCancel: Observable<unknown>
|
onOfferCancel: any
|
||||||
onTradeEvent: Observable<unknown>
|
onTradeEvent: any
|
||||||
onMessage: Observable<unknown>
|
onMessage: any
|
||||||
onMessageHistory: Observable<unknown>
|
onMessageHistory: any
|
||||||
constructor ();
|
constructor ();
|
||||||
private readonly start
|
private readonly start
|
||||||
private readonly onClosed
|
private readonly onClosed
|
||||||
sendChatMessage (message: string, accountid: string, auth: AuthEntity, ticker: string, tradeState: QueueType): Promise<any>;
|
sendChatMessage (message: string, accountid: string, auth: EntityUser, ticker: string, tradeState: QueueType): Promise<any>;
|
||||||
getMessageHistory (): Promise<any>;
|
getMessageHistory (): Promise<any>;
|
||||||
}
|
}
|
||||||
export default ExchangeHub
|
export default ExchangeHub
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
import { AuthEntity, CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
import { EntityUser } from './interfaces/Interfaces'
|
||||||
|
import { CreditAmount, GroupMember, PaymentEntity } from './types/Types'
|
||||||
declare class Group {
|
declare class Group {
|
||||||
private readonly accountid
|
private readonly accountid
|
||||||
constructor (svid: string);
|
constructor (svid: string);
|
||||||
getGroup (): Promise<any>;
|
getGroup (): Promise<any>;
|
||||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: AuthEntity): Promise<any>;
|
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string, auth: EntityUser): Promise<any>;
|
||||||
doesGroupExist (): Promise<any>;
|
doesGroupExist (): Promise<any>;
|
||||||
getGroupMembers (): Promise<any>;
|
getGroupMembers (): Promise<any>;
|
||||||
hasGroupPermission (user: GroupMember, permission: string): Promise<any>;
|
hasGroupPermission (user: GroupMember, permission: string): Promise<any>;
|
||||||
get svid (): string;
|
get svid (): string;
|
||||||
set svid (svid: string);
|
set svid (svid: string);
|
||||||
|
getStockOffers (ticker: string): Promise<any>;
|
||||||
|
buyStock (ticker: string, amount: number, price: CreditAmount, auth: EntityUser): Promise<any>;
|
||||||
|
sellStock (ticker: string, amount: number, price: CreditAmount, auth: EntityUser): Promise<any>;
|
||||||
|
cancelOffer (orderid: number, auth: EntityUser): Promise<any>;
|
||||||
}
|
}
|
||||||
export default Group
|
export default Group
|
||||||
|
|
|
@ -4,6 +4,8 @@ declare class TransactionHub {
|
||||||
private readonly val
|
private readonly val
|
||||||
fromAccount: string
|
fromAccount: string
|
||||||
toAccount: string
|
toAccount: string
|
||||||
|
fromType: string
|
||||||
|
toType: string
|
||||||
event: Observable<unknown>
|
event: Observable<unknown>
|
||||||
constructor ();
|
constructor ();
|
||||||
start (): Promise<void>;
|
start (): Promise<void>;
|
||||||
|
|
|
@ -9,6 +9,7 @@ declare class User {
|
||||||
getBalance (): Promise<any>;
|
getBalance (): Promise<any>;
|
||||||
hasDiscordRole (role: string): Promise<any>;
|
hasDiscordRole (role: string): Promise<any>;
|
||||||
getDiscordRoles (): Promise<any>;
|
getDiscordRoles (): Promise<any>;
|
||||||
|
getDaysSinceLastMove (): Promise<any>;
|
||||||
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any>;
|
sendCredits (amount: CreditAmount, to: PaymentEntity, reason: string): Promise<any>;
|
||||||
getStockOffers (ticker: string): Promise<any>;
|
getStockOffers (ticker: string): Promise<any>;
|
||||||
buyStock (ticker: string, amount: number, price: CreditAmount): Promise<any>;
|
buyStock (ticker: string, amount: number, price: CreditAmount): Promise<any>;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare function svidType (svid: string): string
|
||||||
|
export { svidType }
|
|
@ -1,11 +1,11 @@
|
||||||
import { EntityUser, ConfigAuth } from './../interfaces/Interfaces'
|
import { EntityUser, ConfigAuth } from './../interfaces/Interfaces'
|
||||||
declare type CreditAmount = string | number
|
declare type CreditAmount = string | number
|
||||||
declare type PaymentEntity = string | EntityUser
|
declare type PaymentEntity = string | EntityUser
|
||||||
declare type AuthEntity = EntityUser
|
declare type SvidType = 'user' | 'group' | 'item'
|
||||||
declare type GroupMember = string | EntityUser
|
declare type GroupMember = string | EntityUser
|
||||||
declare type AuthConfig = ConfigAuth
|
declare type AuthConfig = ConfigAuth
|
||||||
declare type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula'
|
declare type District = 'Voopmont' | 'New Yam' | 'San Vooperisco' | 'Medievala' | 'Landing Cove' | 'New Spudland' | 'Vooperia City' | 'Corgi' | 'Old Yam' | 'New Vooperis' | 'The Netherlands' | 'Queensland' | 'Servers Past' | 'Los Vooperis' | 'Old King Peninsula'
|
||||||
declare type DistrictWealthType = 'ALL' | 'USER' | 'GROUP'
|
declare type DistrictWealthType = 'ALL' | 'USER' | 'GROUP'
|
||||||
declare type SenatorDistrict = District | 'ALL'
|
declare type SenatorDistrict = District | 'ALL'
|
||||||
declare type QueueType = 'BUY' | 'SELL'
|
declare type QueueType = 'BUY' | 'SELL'
|
||||||
export { CreditAmount, PaymentEntity, AuthEntity, GroupMember, AuthConfig, District, DistrictWealthType, SenatorDistrict, QueueType }
|
export { CreditAmount, PaymentEntity, SvidType, GroupMember, AuthConfig, District, DistrictWealthType, SenatorDistrict, QueueType }
|
||||||
|
|
Loading…
Reference in New Issue