Skip to content

Commit

Permalink
Merge pull request #171 from Longboyy/main
Browse files Browse the repository at this point in the history
Update `market.browse` to make all params optional, rather than required.
  • Loading branch information
samualtnorman authored May 4, 2024
2 parents 0e584dd + 25f0d02 commit d8ff7a5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ type ScriptFailure = { ok: false, msg?: string }
type ScriptResponse<T = object> = ScriptSuccess<T> | ScriptFailure
type ErrorScripts = Record<string, () => ScriptFailure>

type AllOptional<T> = {
[K in keyof T]-?: {} extends Pick<T, K> ? true : false
}[keyof T]

type Scriptor<Args = unknown, Ret = unknown> = {
name: string,
call: AllOptional<Args> extends true
? (args?: Args) => Ret
: (args: Args) => Ret
}

type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
accts: ErrorScripts
autos: ErrorScripts
Expand All @@ -26,12 +37,16 @@ interface PlayerMidsec {}
interface PlayerLowsec {}
interface PlayerNullsec {}

type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;

type UpgradeCore = {
name: string
type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
up_class?: -1 | 0 | 1 | 2 | 3
tier: 1 | 2 | 3 | 4
rarity: 0 | 1 | 2 | 3 | 4 | 5
rarity: UpgradeRarityNumber
i: number
loaded: boolean
sn: string
Expand All @@ -42,7 +57,7 @@ type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>

type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
[x: string]: null | boolean | number | string
rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
rarity: UpgradeRarityString
}

type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
Expand Down Expand Up @@ -140,7 +155,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
market: {
/** **FULLSEC** */ browse: {
(args:
{ seller: string, listed_before: number, listed_after: number, cost: number | string } & CLIUpgrade
Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CLIUpgrade, "rarity">>
): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure

<I extends string>(args: { i: I }): {
Expand Down Expand Up @@ -519,7 +534,7 @@ type Highsec = Fullsec & PlayerHighsec & {
args?: { filter?: F, is_script: false, full: true }
): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
[x: string]: null | boolean | number | string
rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
rarity: UpgradeRarityString
})[] | ScriptFailure
}
}
Expand Down

0 comments on commit d8ff7a5

Please sign in to comment.