hackmud-script-manager 0.19.1-b040eb5 → 0.19.1-b3a477d

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/bin/hsm.js +3 -3
  2. package/package.json +1 -4
  3. package/env.d.ts +0 -1357
package/bin/hsm.js CHANGED
@@ -12,7 +12,7 @@ import { pull } from "../pull.js"
12
12
  import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
14
  import "@samual/lib/copyFilePersistent"
15
- const version = "0.19.1-b040eb5",
15
+ const version = "0.19.1-b3a477d",
16
16
  options = new Map(),
17
17
  commands = [],
18
18
  userColours = new Cache(user => {
@@ -413,9 +413,9 @@ function logHelp() {
413
413
  function logInfo({ path, users, characterCount, error }, hackmudPath) {
414
414
  path = relative(".", path)
415
415
  error ?
416
- logError(`Error "${chalk.bold(error.message)}" in ${chalk.bold(path)}`)
416
+ logError(`error "${chalk.bold(error.message)}" in ${chalk.bold(path)}`)
417
417
  : log(
418
- `Pushed ${chalk.bold(path)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(characterCount + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(path, extname(path))) + ".js")}`
418
+ `pushed ${chalk.bold(path)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(characterCount + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(path, extname(path))) + ".js")}`
419
419
  )
420
420
  }
421
421
  function logError(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.19.1-b040eb5",
3
+ "version": "0.19.1-b3a477d",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -69,9 +69,6 @@
69
69
  "rollup": "^4.14.2",
70
70
  "terser": "^5.30.3"
71
71
  },
72
- "peerDependencies": {
73
- "typescript": "5.4.5"
74
- },
75
72
  "type": "module",
76
73
  "exports": {
77
74
  ".": "./index.js",
package/env.d.ts DELETED
@@ -1,1357 +0,0 @@
1
- /* eslint-disable @typescript-eslint/consistent-type-definitions */
2
- type Replace<T, R> =
3
- Omit<
4
- T,
5
- Extract<keyof R, keyof T>
6
- > & R
7
-
8
- type ScriptSuccess<T = object> = { ok: true } & T
9
-
10
- type ScriptFailure = {
11
- ok: false
12
- msg?: string
13
- }
14
-
15
- type ScriptResponse<T = object> = ScriptSuccess<T> | ScriptFailure
16
- type ErrorScripts = Record<string, () => ScriptFailure>
17
-
18
- type Subscripts =
19
- Record<
20
- string,
21
- Record<string, (...args: any) => any>
22
- > & {
23
- accts: ErrorScripts
24
- autos: ErrorScripts
25
- bbs: ErrorScripts
26
- chats: ErrorScripts
27
- corps: ErrorScripts
28
- escrow: ErrorScripts
29
- gui: ErrorScripts
30
- kernel: ErrorScripts
31
- market: ErrorScripts
32
- scripts: ErrorScripts
33
- sys: ErrorScripts
34
- trust: ErrorScripts
35
- users: ErrorScripts
36
- }
37
-
38
- interface PlayerFullsec {}
39
-
40
- interface PlayerHighsec {}
41
-
42
- interface PlayerMidsec {}
43
-
44
- interface PlayerLowsec {}
45
-
46
- interface PlayerNullsec {}
47
-
48
- type UpgradeCore = {
49
- name: string
50
- type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
51
- up_class?: -1 | 0 | 1 | 2 | 3
52
- tier: 1 | 2 | 3 | 4
53
- rarity: 0 | 1 | 2 | 3 | 4 | 5
54
- i: number
55
- loaded: boolean
56
- sn: string
57
- description: string
58
- }
59
-
60
- type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
61
-
62
- type CLIUpgrade = Omit<UpgradeCore, "rarity"> & {
63
- [x: string]: null | boolean | number | string
64
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
65
- }
66
-
67
- type UsersTopItem<R> = {
68
- rank: R
69
- name: string
70
- last_activity: string
71
- balance: string
72
- }
73
-
74
- type CorpsTopItem<R> = {
75
- rank: R
76
- name: string
77
- worth: string
78
- }
79
-
80
- type CorpsTop = [
81
- CorpsTopItem<1>,
82
- CorpsTopItem<2>,
83
- CorpsTopItem<3>,
84
- CorpsTopItem<4>,
85
- CorpsTopItem<5>,
86
- CorpsTopItem<6>,
87
- CorpsTopItem<7>,
88
- CorpsTopItem<8>,
89
- CorpsTopItem<9>,
90
- CorpsTopItem<10>
91
- ]
92
-
93
- type Fullsec = Subscripts & PlayerFullsec & {
94
- accts: {
95
- /**
96
- * **FULLSEC**
97
- *
98
- * @returns GC balance of script owner
99
- */
100
- balance_of_owner: () => number
101
-
102
- /**
103
- * **FULLSEC**
104
- */
105
- xfer_gc_to_caller: (args: {
106
- amount: number | string
107
- memo?: string | undefined
108
- }) => ScriptResponse
109
- }
110
-
111
- bbs: {
112
- read: () => {
113
- boards: {
114
- title: string
115
- slug: string
116
- }[]
117
-
118
- posts: {
119
- vote_count: number
120
- short_id: string
121
- is_sticky: boolean
122
- is_locked: boolean
123
- is_archived: boolean
124
- is_answered: boolean
125
- is_implemented: boolean
126
- title: string
127
- slug: string
128
- vote: boolean
129
- username: string
130
- time: string
131
- }[]
132
- }
133
-
134
- r: Fullsec["bbs"]["read"]
135
- }
136
-
137
- chats: {
138
- /**
139
- * **FULLSEC**
140
- *
141
- * @summary Create a new chat channel
142
- *
143
- * @description This script lets you create a new chat channel.
144
- * You cannot create a channel that already exists (including any of the default ports from `0000` to `FFFF`).
145
- * If you do not supply a password, anyone can join your channel (but the channel name is not displayed anywhere, so they would have to discover it in some way first).
146
- */
147
- create: ((args: {
148
- /**
149
- * The name of the channel to create
150
- */
151
- name: string
152
-
153
- /**
154
- * The password to secure the channel with
155
- */
156
- password?: string
157
- }) => ScriptResponse) & ((args: {
158
- /**
159
- * The name of the channel to create
160
- */
161
- c: string
162
-
163
- /**
164
- * The password to secure the channel with
165
- */
166
- password?: string
167
- }) => ScriptResponse)
168
-
169
- /**
170
- * **FULLSEC**
171
- *
172
- * @summary Send a chat message to a channel
173
- *
174
- * @description This script lets you send a message to the specified channel.
175
- * You must have joined the channel, and you will see your own message (unlike chats.tell).
176
- */
177
- send: (args: {
178
- /**
179
- * The channel to send the message to.
180
- */
181
- channel: string
182
-
183
- /**
184
- * The message to send
185
- */
186
- msg: string
187
- }) => ScriptResponse
188
-
189
- /**
190
- * **FULLSEC**
191
- *
192
- * @summary Send a chat message to a specific user
193
- *
194
- * @description This script lets you send a message to the specified user directly.
195
- * You can message any user, you only need their username.
196
- * Note that you will not be able to see your message after it is sent (though many chat scripts based on chats.tell also send the message to you to work around this limitation).
197
- */
198
- tell: (args: {
199
- /**
200
- * The username to send the message to
201
- */
202
- to: string
203
-
204
- /**
205
- * The message to send
206
- */
207
- msg: string
208
- }) => ScriptResponse
209
- }
210
-
211
- escrow: {
212
- /**
213
- * **FULLSEC**
214
- */
215
- charge: (args: {
216
- cost: number | string
217
- is_unlim?: boolean
218
- }) => null | ScriptFailure
219
-
220
- confirm: never
221
- }
222
-
223
- gui: {
224
- chats: never
225
- quiet: never
226
- size: never
227
- vfx: never
228
- vol: never
229
- }
230
-
231
- market: {
232
- /**
233
- * **FULLSEC**
234
- */
235
- browse: ((args: {
236
- seller: string
237
- listed_before: number
238
- listed_after: number
239
- cost: number | string
240
- } & CLIUpgrade) => {
241
- i: string
242
- name: string
243
- rarity: Upgrade["rarity"]
244
- cost: number
245
- }[] | ScriptFailure) & (<I extends string>(args: { i: I }) => {
246
- i: I
247
- seller: string
248
- cost: number
249
- count: number
250
- description: string
251
- upgrade: Upgrade
252
- no_notify: boolean
253
- } | ScriptFailure) & (<I extends string[]>(args: { i: I }) => {
254
- i: I
255
- seller: string
256
- cost: number
257
- count: number
258
- description: string
259
- upgrade: Upgrade
260
- no_notify: boolean
261
- }[] | ScriptFailure)
262
- }
263
-
264
- scripts: {
265
- /**
266
- * **FULLSEC**
267
- */
268
- fullsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
269
-
270
- /**
271
- * **FULLSEC**
272
- */
273
- get_access_level: (args: { name: string }) => {
274
- public: boolean
275
- hidden: boolean
276
- trust: boolean
277
- } | ScriptFailure
278
-
279
- /**
280
- * **FULLSEC**
281
- */
282
- get_level: (args: { name: string }) => 0 | 1 | 2 | 3 | 4 | ScriptFailure
283
-
284
- /**
285
- * **FULLSEC**
286
- */
287
- highsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
288
-
289
- /**
290
- * **FULLSEC**
291
- */
292
- lowsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
293
-
294
- /**
295
- * **FULLSEC**
296
- */
297
- midsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
298
-
299
- /**
300
- * **FULLSEC**
301
- */
302
- nullsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
303
-
304
- /**
305
- * **FULLSEC**
306
- */
307
- trust: () => string[]
308
-
309
- /**
310
- * FULLSEC
311
- *
312
- * @returns a code library containing useful helper functions you can use in your scripts.
313
- */
314
- lib: () => {
315
- ok: () => ScriptSuccess
316
-
317
- not_impl: () => {
318
- ok: false
319
- msg: "Not Implemented."
320
- }
321
-
322
- log: (message: any) => any
323
- get_log: () => string[]
324
- rand_int: (min: number, max: number) => number
325
- clamp: (floor: number, value: number, ceil: number) => number
326
- lerp: (...args: any) => any
327
- sample: (...args: any) => any
328
- are_ids_eq: (id1: any, id2: any) => boolean
329
- id_to_str: (...args: any) => any
330
- is_bool: (value: any) => value is boolean
331
- is_obj: (value: any) => value is Record<string, unknown> | null
332
- is_str: (value: any) => value is string
333
- is_num: (value: any) => value is number
334
- is_int: (value: any) => value is number
335
- is_neg: (value: any) => value is number
336
- is_arr: (value: any) => value is unknown[]
337
- is_func: (value: any) => value is (...args: any[]) => unknown
338
- is_def: (value: any) => boolean
339
- is_valid_name: (value: string) => boolean
340
- dump: (value: { toString: () => string }) => string
341
- clone: <T extends object>(object: T) => T
342
- merge: <F extends object, S>(firstValue: F, secondValue: S) => F & S
343
- get_values: (object: object) => any
344
- hash_code: (string: string) => number
345
- xmur3: (...args: any) => any
346
- sfc32: (...args: any) => any
347
- mulberry32: (...args: any) => any
348
- xoshiro128ss: (...args: any) => any
349
- JSF: (...args: any) => any
350
- LCG: (...args: any) => any
351
- to_gc_str: (number: number) => string
352
- to_gc_num: (string: string) => number | ScriptFailure
353
- to_game_timestr: (date: Date) => string
354
- corruption_chars: "¡¢Á¤Ã¦§¨©ª"
355
- colors: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
356
- corruptions: [ 0, 1, 1.5, 2.5, 5 ]
357
- corrupt: (text: string | string[], amount: 0 | 1 | 2 | 3 | 4) => string
358
- cap_str_len: (string: string, length: number) => string
359
- each: <T>(array: T[], function_: (key: string, value: T) => void) => void
360
- select: <T>(array: T[], function_: (key: string, value: T) => boolean) => T[]
361
- count: <T>(array: T[], function_: (key: string, value: T) => boolean) => number
362
- select_one: <T>(array: T[], function_: (key: string, value: T) => boolean) => T
363
- map: <T>(array: T[], function_: (key: string, value: T) => boolean) => T[]
364
- pick: (...args: any) => any
365
- shuffle: <T>(array: T[]) => T[]
366
- sort_asc: (...args: any) => any
367
- sort_desc: (...args: any) => any
368
- num_sort_asc: (one: number, two: number) => 1 | -1 | 0
369
- num_sort_desc: (one: number, two: number) => 1 | -1 | 0
370
- max_val_index: (array: number[]) => number
371
- add_time: (date: Date, add_ms: number) => Date
372
- security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
373
- get_security_level_name: (security_level: number) => any
374
- dbu_result_failed: (...args: any) => any
375
- dbir_result_failed: (...args: any) => any
376
- create_rand_string: (length: number) => string
377
- get_user_from_script: (script_name: string) => string
378
- get_scriptname_from_script: (...args: any) => any
379
- is_script: (...args: any) => any
380
- caller_is_owner: (...args: any) => any
381
- uniq: (...args: any) => any
382
- u_sort_num_arr_desc: <T>(array: T[]) => T[]
383
- ljust: (...args: any) => any
384
- rjust: (...args: any) => any
385
- columnize: (string: string[]) => string
386
- side_by_side: (...args: any) => any
387
- can_continue_execution: (time_left: number) => boolean
388
- can_continue_execution_error: (...args: any) => any
389
- date: typeof Date
390
- get_date: () => Date
391
- get_date_utcsecs: () => number
392
- one_day_ms: 86_400_000
393
- is_not_today: (...args: any) => any
394
- utc_day_diff: (...args: any) => any
395
- utc_days_ago_str: (...args: any) => any
396
- math: typeof Math
397
- array: typeof Array
398
- parse_int: typeof parseInt
399
- parse_float: typeof parseFloat
400
- json: typeof JSON
401
- number: typeof Number
402
- object: typeof Object
403
- }
404
-
405
- /**
406
- * **FULLSEC**
407
- */
408
- quine: () => string
409
- }
410
-
411
- sys: {
412
- init: never
413
-
414
- /**
415
- * **FULLSEC**
416
- */
417
- upgrades_of_owner: (<
418
- F extends Partial<Upgrade & { loaded: boolean }> = object
419
- >(args?: { filter?: F, full?: false }) => (
420
- Omit<
421
- Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
422
- keyof F
423
- > & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
424
- )[] | ScriptFailure) & (<
425
- F extends Partial<Upgrade & { loaded: boolean }> = object
426
- >(args: { filter?: F, full: true }) => (
427
- Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
428
- )[] | ScriptFailure) & (<I extends number>(args: { i: I }) => (
429
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
430
- ) | ScriptFailure)
431
-
432
- /**
433
- * **FULLSEC**
434
- */
435
- xfer_upgrade_to_caller: ((args: {
436
- i: number | number[]
437
- memo?: string
438
- }) => ScriptResponse) & ((args: {
439
- sn: string | string[]
440
- memo?: string
441
- }) => ScriptResponse)
442
- }
443
-
444
- users: {
445
- /**
446
- * **FULLSEC**
447
- */
448
- active: () => number
449
-
450
- /**
451
- * **FULLSEC**
452
- */
453
- last_action: (args: { name: string | string[] }) => ({
454
- n: string
455
- t?: Date
456
- } | null)[]
457
-
458
- /**
459
- * **FULLSEC**
460
- */
461
- top: () => [
462
- UsersTopItem<1>,
463
- UsersTopItem<2>,
464
- UsersTopItem<3>,
465
- UsersTopItem<4>,
466
- UsersTopItem<5>,
467
- UsersTopItem<6>,
468
- UsersTopItem<7>,
469
- UsersTopItem<8>,
470
- UsersTopItem<9>,
471
- UsersTopItem<10>
472
- ]
473
- }
474
- }
475
-
476
- type Highsec = Fullsec & PlayerHighsec & {
477
- accts: {
478
- /**
479
- * **HIGHSEC**
480
- *
481
- * @returns GC balance as number if `is_script` is true (default)
482
- * @returns GC balance as string if `is_script` is false
483
- */
484
- balance: ((args?: { is_script?: true }) => number) & ((args: { is_script: false }) => string)
485
-
486
- /**
487
- * **HIGHSEC**
488
- *
489
- * @returns transaction history according to filter
490
- * @returns if `is_script` is true (default), time property as Date object
491
- * @returns wraps transactions in object with msg, time property as string (game date format e.g. 201028.2147) if `is_script` is false
492
- */
493
- transactions: ((args?: {
494
- count?: number | "all"
495
- to?: string
496
- from?: string
497
- script?: string
498
- is_script?: true
499
- }) => {
500
- time: Date
501
- amount: number
502
- sender: string
503
- recipient: string
504
- script: string | null
505
- memo?: string
506
- }[]) & ((args: {
507
- count?: number | "all"
508
- to?: string
509
- from?: string
510
- script?: string
511
- is_script: false
512
- }) => {
513
- msg: string
514
- transactions: {
515
- time: string
516
- amount: string
517
- sender: string
518
- recipient: string
519
- script: string | null
520
- memo?: string
521
- }[]
522
- })
523
- }
524
-
525
- scripts: {
526
- /**
527
- * **HIGHSEC**
528
- */
529
- sys: () => string | string[]
530
- }
531
-
532
- sys: {
533
- /**
534
- * **HIGHSEC**
535
- */
536
- specs: () => string | ScriptFailure
537
-
538
- /**
539
- * **HIGHSEC**
540
- */
541
- status: () => {
542
- hardline: number
543
- tutorial: string
544
- breach: boolean
545
- }
546
-
547
- /**
548
- * **HIGHSEC**
549
- */
550
- upgrade_log: ((args?: {
551
- is_script?: true
552
- user?: string
553
- run_id?: string
554
- count?: number
555
- start?: number
556
- }) => {
557
- t: Date
558
- u: string
559
- r: string
560
- msg: string
561
- }[] | ScriptFailure) & ((args: {
562
- is_script: false
563
- user?: string
564
- run_id?: string
565
- count?: number
566
- start?: number
567
- }) => string[] | ScriptFailure)
568
-
569
- /**
570
- * **HIGHSEC**
571
- */
572
- upgrades: (<I extends number>(args: { i: I }) => (
573
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
574
- ) | ScriptFailure) & (<
575
- F extends Partial<Upgrade & { loaded: boolean }> = object
576
- >(args?: {
577
- filter?: F
578
- is_script?: true
579
- full?: false
580
- }) => (
581
- Omit<
582
- Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
583
- keyof F
584
- > & F & Record<string, null | boolean | number | string>
585
- )[] | ScriptFailure) & (<
586
- F extends Partial<Upgrade & { loaded: boolean }> = object
587
- >(args?: {
588
- filter?: F
589
- is_script?: true
590
- full: true
591
- }) => (
592
- Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
593
- )[] | ScriptFailure) & ((args?: {
594
- filter?: Partial<Upgrade & { loaded: boolean }>
595
- is_script: false
596
- full?: false
597
- }) => {
598
- msg: string
599
- upgrades: string[]
600
- } | ScriptFailure) & (<
601
- F extends Partial<Upgrade & { loaded: boolean }> = object
602
- >(args?: {
603
- filter?: F
604
- is_script: false
605
- full: true
606
- }) => (
607
- Omit<UpgradeCore, keyof F | "rarity"> & F & {
608
- [x: string]: null | boolean | number | string
609
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
610
- }
611
- )[] | ScriptFailure)
612
- }
613
-
614
- users: {
615
- /**
616
- * **HIGHSEC**
617
- */
618
- inspect: ((args: {
619
- name: "trust"
620
- is_script?: boolean
621
- }) => number) & ((args: {
622
- name: "risk"
623
- is_script?: boolean
624
- }) => string) & ((args: {
625
- name: string
626
- is_script?: true
627
- }) => {
628
- username: string
629
- avatar: string
630
- pronouns: string
631
- user_age?: Date
632
- bio?: string
633
- title?: string
634
- is_main: boolean
635
- alt_of?: string
636
- badges?: string[]
637
- } | ScriptFailure) & ((args: {
638
- name: string
639
- is_script: false
640
- }) => string | ScriptFailure)
641
- }
642
- }
643
-
644
- type Midsec = Highsec & PlayerMidsec & {
645
- accts: {
646
- /**
647
- * **MIDSEC**
648
- */
649
- xfer_gc_to: (args: {
650
- to: string
651
- amount: number | string
652
- memo?: string
653
- }) => ScriptResponse
654
- }
655
-
656
- autos: {
657
- /**
658
- * **MIDSEC**
659
- */
660
- reset: () => ScriptSuccess
661
- }
662
-
663
- chats: {
664
- /**
665
- * **MIDSEC**
666
- */
667
- channels: () => string[]
668
-
669
- /**
670
- * **MIDSEC**
671
- */
672
- join: (args: {
673
- channel: string
674
- password?: string
675
- }) => ScriptResponse
676
-
677
- /**
678
- * **MIDSEC**
679
- */
680
- leave: (args: { channel: string }) => ScriptResponse
681
-
682
- /**
683
- * **MIDSEC**
684
- */
685
- users: (args: { channel: string }) => string[] | ScriptFailure
686
- }
687
-
688
- escrow: {
689
- /**
690
- * **MIDSEC**
691
- */
692
- stats: () => {
693
- scripts: string[]
694
- total: string
695
- outstanding: string
696
- open_escrow_count: number
697
- } | ScriptFailure
698
- }
699
-
700
- market: {
701
- /**
702
- * **MIDSEC**
703
- */
704
- buy: (args: {
705
- i: string
706
- count: number
707
- confirm: true
708
- }) => ScriptResponse
709
-
710
- /**
711
- * **MIDSEC**
712
- */
713
- stats: () => ScriptFailure | {
714
- total: string
715
- outstanding: string
716
- listed: number
717
- sold: number
718
- }
719
- }
720
-
721
- scripts: {
722
- /**
723
- * **MIDSEC**
724
- */
725
- user: () => string[]
726
- }
727
-
728
- sys: {
729
- /**
730
- * **MIDSEC**
731
- */
732
- manage: ((args: {
733
- unload?: number | number[]
734
- load?: number | number[]
735
- }) => ScriptResponse) & ((args: { reorder?: ([ number, number ] | {
736
- from: number
737
- to: number
738
- })[] | {
739
- from: number
740
- to: number
741
- } }) => string[] | ScriptFailure)
742
- }
743
- }
744
-
745
- type Lowsec = Midsec & PlayerLowsec & {
746
- kernel: {
747
- /**
748
- * **LOWSEC**
749
- */
750
- hardline: () => ScriptResponse
751
- }
752
-
753
- market: {
754
- /**
755
- * **LOWSEC**
756
- */
757
- sell: (args: {
758
- i: number
759
- cost: number | string
760
- description?: string
761
- count?: number
762
- no_notify?: boolean
763
- confirm: true
764
- }) => ScriptResponse<{ token: string }>
765
- }
766
-
767
- sys: {
768
- /**
769
- * **LOWSEC**
770
- */
771
- access_log: ((args?: {
772
- user?: string
773
- run_id?: string
774
- is_script?: true
775
- count?: number
776
- start?: number
777
- }) => {
778
- t: Date
779
- u: string | undefined
780
- r: string | undefined
781
- msg: string
782
- }[] | ScriptFailure) & ((args: {
783
- user?: string
784
- run_id?: string
785
- is_script: false
786
- count?: number
787
- start?: number
788
- }) => string[])
789
-
790
- /**
791
- * **LOWSEC**
792
- */
793
- cull: (args: { i: number | number[], confirm: true }) => ScriptResponse
794
-
795
- /**
796
- * **LOWSEC**
797
- */
798
- loc: () => string | ScriptFailure
799
-
800
- /**
801
- * **LOWSEC**
802
- */
803
- xfer_upgrade_to: ((args: {
804
- i: number | number[]
805
- to: string
806
- memo?: string
807
- }) => ScriptResponse) & ((args: {
808
- sn: string | string[]
809
- to: string
810
- memo?: string
811
- }) => ScriptResponse)
812
- }
813
- }
814
-
815
- type Nullsec = Lowsec & PlayerNullsec & {
816
- corps: {
817
- /**
818
- * **NULLSEC**
819
- */
820
- create: (args: {
821
- name: string
822
- confirm: true
823
- }) => ScriptResponse
824
-
825
- /**
826
- * **NULLSEC**
827
- */
828
- hire: (args: { name: string }) => ScriptResponse
829
-
830
- /**
831
- * **NULLSEC**
832
- */
833
- manage: ((args: { command: "list" }) => {
834
- name: string
835
- is_admin: boolean
836
- }[] | ScriptFailure) & ((args: {
837
- command: "demote" | "promote"
838
- name: string
839
- } | {
840
- command: "fire"
841
- name: string
842
- confirm: true
843
- }) => ScriptResponse)
844
-
845
- /**
846
- * **NULLSEC**
847
- */
848
- offers: (() => {
849
- offers: string[]
850
- msg: string
851
- } | ScriptSuccess<{
852
- msg: string
853
- current_corp: string | null
854
- }>) & ((args: { accept: string }) => ScriptResponse)
855
-
856
- /**
857
- * **NULLSEC**
858
- */
859
- quit: (args: { confirm: true }) => ScriptResponse
860
-
861
- /**
862
- * **NULLSEC**
863
- */
864
- top: () => CorpsTop | {
865
- top: CorpsTop
866
- active: {
867
- name: string
868
- worth: string
869
- }
870
- }
871
- }
872
-
873
- sys: {
874
- /**
875
- * **NULLSEC**
876
- */
877
- breach: (args: { confirm: true }) => ScriptResponse
878
- }
879
-
880
- trust: {
881
- /**
882
- * **NULLSEC**
883
- */
884
- me: () => string
885
- }
886
-
887
- users: {
888
- /**
889
- * **NULLSEC**
890
- */
891
- config: ((args: {
892
- list: false
893
- is_script?: true | null
894
- avatar?: string | null
895
- user_age?: boolean | null
896
- account_age?: boolean | null
897
- bio?: string | null
898
- title?: string | null
899
- pronouns?: string | null
900
- corp?: boolean | null
901
- alt_of?: string | null
902
- badges?: string[] | null
903
- }) => ScriptResponse) & ((args: {
904
- list: true
905
- is_script?: true
906
- avatar?: string | null
907
- user_age?: boolean | null
908
- account_age?: boolean | null
909
- bio?: string | null
910
- title?: string | null
911
- pronouns?: string | null
912
- corp?: boolean | null
913
- alt_of?: string | null
914
- badges?: string[] | null
915
- }) => {
916
- avatar: string | null
917
- user_age?: boolean
918
- account_age?: boolean
919
- bio: string | null
920
- title: string | null
921
- pronouns: string
922
- corp?: boolean
923
- alt_of: string | null
924
- badges: string[]
925
- }) & ((args: {
926
- list: true
927
- is_script: false
928
- avatar?: string | null
929
- user_age?: boolean | null
930
- account_age?: boolean | null
931
- bio?: string | null
932
- title?: string | null
933
- pronouns?: string | null
934
- corp?: boolean | null
935
- alt_of?: string | null
936
- badges?: string[] | null
937
- }) => string)
938
- }
939
- }
940
-
941
- type MongoValue = string | number | boolean | Date | MongoValue[] | {
942
- [key: string]: MongoValue
943
- } | null
944
-
945
- type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | {
946
- [key: string]: MongoCommandValue
947
- } | null | undefined
948
-
949
- type Query = {
950
- [key: string]: MongoValue | Query
951
- } & {
952
- _id?: Id
953
- $in?: MongoValue[]
954
- }
955
-
956
- type Projection = Record<string, boolean | 0 | 1>
957
-
958
- type MongoCommand = MongoCommandValue & Partial<{
959
- $set: Record<string, MongoCommandValue>
960
- $push: Record<string, MongoCommandValue>
961
- $unset: Record<string, "">
962
- }>
963
-
964
- type Id = string | number | boolean | Date | Record<string, MongoValue>
965
-
966
- type MongoDocument = {
967
- [key: string]: MongoValue
968
- _id: Id
969
- }
970
-
971
- type SortOrder = {
972
- [key: string]: 1 | -1 | SortOrder
973
- }
974
-
975
- type Cursor = {
976
- /**
977
- * Returns the first document that satisfies the query.
978
- */
979
- first: () => MongoDocument | null
980
-
981
- /**
982
- * Returns an array of documents that satisfy the query.
983
- */
984
- array: () => MongoDocument[]
985
-
986
- /**
987
- * Returns the number of documents that match the query.
988
- */
989
- count: () => number
990
-
991
- /**
992
- * Returns the first document that satisfies the query.
993
- * Also makes cursor unusable.
994
- */
995
- first_and_close: () => MongoDocument
996
-
997
- /**
998
- * Returns an array of documents that satisfy the query.
999
- * Also makes cursor unusable.
1000
- */
1001
- array_and_close: () => MongoDocument[]
1002
-
1003
- /**
1004
- * Returns the number of documents that match the query.
1005
- * Also makes cursor unusable.
1006
- */
1007
- count_and_close: () => number
1008
-
1009
- /**
1010
- * Run callback on each document that satisfied the query.
1011
- *
1012
- * @param funct callback function
1013
- */
1014
- each: (funct: (document: MongoDocument) => void) => null
1015
-
1016
- /**
1017
- * Returns a new cursor with documents sorted as specified.
1018
- * A value of 1 sorts the property ascending, and -1 descending.
1019
- *
1020
- * @param order the way the documents are to be sorted
1021
- */
1022
- sort: (order?: SortOrder) => Cursor
1023
-
1024
- /**
1025
- * Returns a new cursor without the first number of documents.
1026
- *
1027
- * @param count number of documents to skip
1028
- */
1029
- skip: (count: number) => Cursor
1030
-
1031
- /**
1032
- * Returns a new cursor limited to a number of documents as specified
1033
- *
1034
- * @param count number of documents
1035
- */
1036
- limit: (count: number) => Cursor
1037
-
1038
- /**
1039
- * @param key they key of the documents
1040
- */
1041
- distinct: ((key: string) => MongoValue[]) & ((key: "_id") => Id[])
1042
-
1043
- /**
1044
- * Makes cursor unusable.
1045
- */
1046
- close: () => null
1047
-
1048
- NumberLong: (number: number) => number
1049
- ObjectId: () => any
1050
- }
1051
-
1052
- type CLIContext = {
1053
- /**
1054
- * The name of the user who is calling the script (i.e. n00b)
1055
- */
1056
- caller: string
1057
-
1058
- /**
1059
- * The name of this script
1060
- */
1061
- this_script: string
1062
-
1063
- /**
1064
- * the number of columns in the caller’s terminal, if reported by the client
1065
- */
1066
- cols: number
1067
-
1068
- /**
1069
- * the number of rows in the caller’s terminal, if reported by the client
1070
- */
1071
- rows: number
1072
-
1073
- /**
1074
- * The name of the script that directly called this script, or null if called on the command line or as a scriptor
1075
- */
1076
- calling_script: null
1077
- }
1078
-
1079
- type SubscriptContext = Replace<CLIContext, {
1080
- /**
1081
- * The name of the script that directly called this script, or null if called on the command line or as a scriptor
1082
- */
1083
- calling_script: string
1084
- }>
1085
-
1086
- type ScriptorContext = CLIContext & {
1087
- /**
1088
- * true if the script is being run as a scriptor, otherwise falsey (not present currently, but I wouldn’t rely on that)
1089
- */
1090
- is_scriptor: true
1091
- }
1092
-
1093
- type BrainContext = CLIContext & {
1094
- /**
1095
- * true if the script is being run via a bot brain
1096
- */
1097
- is_brain: true
1098
- }
1099
-
1100
- type Context = CLIContext | SubscriptContext | ScriptorContext | BrainContext
1101
-
1102
- /**
1103
- * Subscript space that can call FULLSEC scripts.
1104
- */
1105
- declare const $fs: Fullsec
1106
-
1107
- /**
1108
- * Subscript space that can call HIGHSEC and above scripts.
1109
- * Makes your script HIGHSEC (overrides FULLSEC).
1110
- */
1111
- declare const $hs: Highsec
1112
-
1113
- /**
1114
- * Subscript space that can call MIDSEC and above scripts.
1115
- * Makes your script MIDSEC (overrides higher security levels).
1116
- */
1117
- declare const $ms: Midsec
1118
-
1119
- /**
1120
- * Subscript space that can call LOWSEC and above scripts.
1121
- * Makes your script LOWSEC (overrides higher security levels).
1122
- */
1123
- declare const $ls: Lowsec
1124
-
1125
- /**
1126
- * Subscript space that can call any script.
1127
- * Makes your script NULLSEC (overrides higher security levels).
1128
- */
1129
- declare const $ns: Nullsec
1130
-
1131
- /**
1132
- * Subscript space that can call FULLSEC scripts.
1133
- */
1134
- declare const $4s: typeof $fs
1135
-
1136
- /**
1137
- * Subscript space that can call HIGHSEC and above scripts.
1138
- * Makes your script HIGHSEC (overrides FULLSEC).
1139
- */
1140
- declare const $3s: typeof $hs
1141
-
1142
- /**
1143
- * Subscript space that can call MIDSEC and above scripts.
1144
- * Makes your script MIDSEC (overrides higher security levels).
1145
- */
1146
- declare const $2s: typeof $ms
1147
-
1148
- /**
1149
- * Subscript space that can call LOWSEC and above scripts.
1150
- * Makes your script LOWSEC (overrides higher security levels).
1151
- */
1152
- declare const $1s: typeof $ls
1153
-
1154
- /**
1155
- * Subscript space that can call any script.
1156
- * Makes your script NULLSEC (overrides higher security levels).
1157
- */
1158
- declare const $0s: typeof $ns
1159
-
1160
- /**
1161
- * Subscript space that can call any script.
1162
- * Uses seclevel provided in comment before script (defaults to NULLSEC)
1163
- *
1164
- * ```js
1165
- * // @seclevel MIDSEC
1166
- * export function script() {
1167
- * $s.foo.bar() // will be converted to #ms.foo.bar()
1168
- * }
1169
- * ```
1170
- */
1171
- declare const $s: Nullsec
1172
-
1173
- declare const $db: {
1174
- /**
1175
- * Insert
1176
- *
1177
- * Inserts a document or documents into a collection.
1178
- * @param documents A document or array of documents to insert into the collection.
1179
- */
1180
- i: (documents: object | object[]) => {
1181
- ok: 1
1182
- n: number
1183
- opTime: {
1184
- ts: "Undefined Conversion"
1185
- t: number
1186
- }
1187
- electionId: "Undefined Conversion"
1188
- }
1189
-
1190
- /**
1191
- * Remove
1192
- *
1193
- * Removes documents from a collection.
1194
- * @param query Specifies deletion criteria using query operators.
1195
- */
1196
- r: (query: Query) => void
1197
-
1198
- /**
1199
- * Find
1200
- *
1201
- * Selects documents in a collection or view and returns a cursor to the selected documents.
1202
- * @param query Specifies deletion criteria using query operators.
1203
- * @param projection Specifies the fields to return in the documents that match the query filter.
1204
- */
1205
- f: (query?: Query, projection?: Projection) => Cursor
1206
-
1207
- /**
1208
- * Update
1209
- *
1210
- * Modifies an existing document or documents in a collection.
1211
- * @param query Specifies deletion criteria using query operators.
1212
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1213
- */
1214
- u: (query: Query | Query[], command: MongoCommand) => {
1215
- ok: 0 | 1
1216
- nModified: number
1217
- n: number
1218
- opTime: {
1219
- ts: "Undefined Conversion"
1220
- t: number
1221
- }
1222
- electionId: "Undefined Conversion"
1223
- }
1224
-
1225
- /**
1226
- * Update 1
1227
- *
1228
- * Updates a single document within the collection based on the filter.
1229
- * @param query Specifies deletion criteria using query operators.
1230
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1231
- */
1232
- u1: (query: Query | Query[], command: MongoCommand) => void
1233
-
1234
- /**
1235
- * Upsert
1236
- *
1237
- * Same as Update, but if no documents match the query, one document will be inserted based on the properties in both the query and the command.
1238
- * The `$setOnInsert` operator is useful to set defaults.
1239
- * @param query Specifies deletion criteria using query operators.
1240
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1241
- */
1242
- us: (query: Query | Query[], command: MongoCommand) => void
1243
- }
1244
-
1245
- /**
1246
- * Debug Log
1247
- *
1248
- * If `$D()` is called in a script you own, the `return` value of the top level script is suppressed and instead an array of every `$D()`’d entry is printed.
1249
- * This lets you use `$D()` like `console.log()`.
1250
- *
1251
- * `$D()` in scripts not owned by you are not shown but the `return` value always is.
1252
- *
1253
- * `$D()` returns the first argument so `$D("Hello, World!") evaluates to `"Hello, World!"` as if the `$D` text wasn't there.
1254
- *
1255
- * `$D()`’d items are returned even if the script times out or errors.
1256
- */
1257
- declare function $D<T>(args: T): T
1258
-
1259
- /**
1260
- * Function Multi-Call Lock
1261
- *
1262
- * This is used by escrow to ensure that it is only used once in script execution.
1263
- *
1264
- * The first time (per-script) `$FMCL` is encountered, it returns `undefined`, every other time it `return`s `true`.
1265
- *
1266
- * @example
1267
- * if ($FMCL)
1268
- * return { ok: false, msg: "this script can only be used once per script execution" }
1269
- *
1270
- * // all code here will only run once
1271
- */
1272
- declare const $FMCL: undefined | true
1273
-
1274
- /**
1275
- * Global
1276
- *
1277
- * A mutable, per-script global object.
1278
- * $G persists between script calls until the end of the main script run making it useful for caching db entries when your script is a subscript.
1279
- *
1280
- * @example
1281
- * if (!$G.dbCache)
1282
- * $G.dbCache = $db.f({ whatever: true }).first()
1283
- */
1284
- declare const $G: any
1285
-
1286
- /**
1287
- * This contains a JS timestamp (not Date) set immediately before your code begins running.
1288
- *
1289
- * @example
1290
- * Date.now() - _START // milliseconds left of run time
1291
- */
1292
- declare const _START: number
1293
-
1294
- /**
1295
- * This contains a JS timestamp (not Date) set immediately before your code begins running.
1296
- *
1297
- * @example
1298
- * Date.now() - _ST // milliseconds left of run time
1299
- */
1300
- declare const _ST: typeof _START
1301
-
1302
- /**
1303
- * JavaScript timestamp for the end of the script run (`_START + _TIMEOUT`).
1304
- */
1305
- declare const _END: number
1306
-
1307
- /**
1308
- * The number of milliseconds a script can run for.
1309
- * Normally `5000` though it has been known to change.
1310
- */
1311
- declare const _TIMEOUT: number
1312
-
1313
- /**
1314
- * The number of milliseconds a script can run for.
1315
- * Normally `5000` though it has been known to change.
1316
- */
1317
- declare const _TO: typeof _TIMEOUT
1318
-
1319
- /** The source code of this script as a string. */
1320
- declare const _SOURCE: string
1321
-
1322
- /** A unix timestamp of the date this script was built. */
1323
- declare const _BUILD_DATE: number
1324
-
1325
- /**
1326
- * The user this script has been uploaded to.
1327
- *
1328
- * Shorter alternative to `context.this_script.split(".")[0].
1329
- *
1330
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1331
- */
1332
- declare const _SCRIPT_USER: string
1333
-
1334
- /**
1335
- * The name of this script excluding the user and `.`.
1336
- *
1337
- * e.g. in the script `foo.bar`, `_SCRIPT_NAME` is `bar`.
1338
- *
1339
- * Shorter alternative to `context.this_script.split(".")[1].
1340
- *
1341
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1342
- */
1343
- declare const _SCRIPT_NAME: string
1344
-
1345
- /**
1346
- * The full name of this script equivilent to `context.this_script` but should use less characters.
1347
- *
1348
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1349
- */
1350
- declare const _FULL_SCRIPT_NAME: string
1351
-
1352
- /**
1353
- * The seclevel of this script as a number.
1354
- *
1355
- * In rare cases where it's not known at build time, it's `-1`.
1356
- */
1357
- declare const _SECLEVEL: -1 | 0 | 1 | 2 | 3 | 4