hackmud-script-manager 0.20.4-d6444f0 → 0.20.4-d8ff7a5

Sign up to get free protection for your applications and to get access to all the features.
package/env.d.ts CHANGED
@@ -1,55 +1,52 @@
1
- type Replace<T, R> =
2
- Omit<
3
- T,
4
- Extract<keyof R, keyof T>
5
- > & R
6
-
1
+ type Replace<T, R> = Omit<T, Extract<keyof R, keyof T>> & R
7
2
  type ScriptSuccess<T = object> = { ok: true } & T
8
-
9
- type ScriptFailure = {
10
- ok: false
11
- msg?: string
12
- }
13
-
3
+ type ScriptFailure = { ok: false, msg?: string }
14
4
  type ScriptResponse<T = object> = ScriptSuccess<T> | ScriptFailure
15
5
  type ErrorScripts = Record<string, () => ScriptFailure>
16
6
 
17
- type Subscripts =
18
- Record<
19
- string,
20
- Record<string, (...args: any) => any>
21
- > & {
22
- accts: ErrorScripts
23
- autos: ErrorScripts
24
- bbs: ErrorScripts
25
- chats: ErrorScripts
26
- corps: ErrorScripts
27
- escrow: ErrorScripts
28
- gui: ErrorScripts
29
- kernel: ErrorScripts
30
- market: ErrorScripts
31
- scripts: ErrorScripts
32
- sys: ErrorScripts
33
- trust: ErrorScripts
34
- users: ErrorScripts
35
- }
7
+ type AllOptional<T> = {
8
+ [K in keyof T]-?: {} extends Pick<T, K> ? true : false
9
+ }[keyof T]
36
10
 
37
- interface PlayerFullsec {}
11
+ type Scriptor<Args = unknown, Ret = unknown> = {
12
+ name: string,
13
+ call: AllOptional<Args> extends true
14
+ ? (args?: Args) => Ret
15
+ : (args: Args) => Ret
16
+ }
38
17
 
39
- interface PlayerHighsec {}
18
+ type Subscripts = Record<string, Record<string, (...args: any) => any>> & {
19
+ accts: ErrorScripts
20
+ autos: ErrorScripts
21
+ bbs: ErrorScripts
22
+ chats: ErrorScripts
23
+ corps: ErrorScripts
24
+ escrow: ErrorScripts
25
+ gui: ErrorScripts
26
+ kernel: ErrorScripts
27
+ market: ErrorScripts
28
+ scripts: ErrorScripts
29
+ sys: ErrorScripts
30
+ trust: ErrorScripts
31
+ users: ErrorScripts
32
+ }
40
33
 
34
+ interface PlayerFullsec {}
35
+ interface PlayerHighsec {}
41
36
  interface PlayerMidsec {}
42
-
43
37
  interface PlayerLowsec {}
44
-
45
38
  interface PlayerNullsec {}
46
39
 
40
+ type UpgradeRarityString = "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
41
+ type UpgradeRarityNumber = 0 | 1 | 2 | 3 | 4 | 5;
42
+ type UpgradeRarity = UpgradeRarityString | UpgradeRarityNumber;
43
+
47
44
  type UpgradeCore = {
48
45
  name: string
49
46
  type: "lock" | "script_space" | "chat" | "script" | "tool" | "bot_brain" | "glam"
50
47
  up_class?: -1 | 0 | 1 | 2 | 3
51
48
  tier: 1 | 2 | 3 | 4
52
- rarity: 0 | 1 | 2 | 3 | 4 | 5
49
+ rarity: UpgradeRarityNumber
53
50
  i: number
54
51
  loaded: boolean
55
52
  sn: string
@@ -60,59 +57,28 @@ type Upgrade = UpgradeCore & Record<string, null | boolean | number | string>
60
57
 
61
58
  type CLIUpgrade = Omit<UpgradeCore, `rarity`> & {
62
59
  [x: string]: null | boolean | number | string
63
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
64
- }
65
-
66
- type UsersTopItem<R> = {
67
- rank: R
68
- name: string
69
- last_activity: string
70
- balance: string
60
+ rarity: UpgradeRarityString
71
61
  }
72
62
 
73
- type CorpsTopItem<R> = {
74
- rank: R
75
- name: string
76
- worth: string
77
- }
63
+ type UsersTopItem<R> = { rank: R, name: string, last_activity: string, balance: string }
64
+ type CorpsTopItem<R> = { rank: R, name: string, worth: string }
78
65
 
79
66
  type CorpsTop = [
80
- CorpsTopItem<1>,
81
- CorpsTopItem<2>,
82
- CorpsTopItem<3>,
83
- CorpsTopItem<4>,
84
- CorpsTopItem<5>,
85
- CorpsTopItem<6>,
86
- CorpsTopItem<7>,
87
- CorpsTopItem<8>,
88
- CorpsTopItem<9>,
89
- CorpsTopItem<10>
67
+ CorpsTopItem<1>, CorpsTopItem<2>, CorpsTopItem<3>, CorpsTopItem<4>, CorpsTopItem<5>,
68
+ CorpsTopItem<6>,CorpsTopItem<7>, CorpsTopItem<8>, CorpsTopItem<9>, CorpsTopItem<10>
90
69
  ]
91
70
 
92
71
  type Fullsec = Subscripts & PlayerFullsec & {
93
72
  accts: {
94
- /**
95
- * **FULLSEC**
96
- *
97
- * @returns GC balance of script owner
98
- */
99
- balance_of_owner: () => number
100
-
101
- /**
102
- * **FULLSEC**
103
- */
104
- xfer_gc_to_caller: (args: {
105
- amount: number | string
106
- memo?: string | undefined
107
- }) => ScriptResponse
73
+ /** **FULLSEC** @returns GC balance of script owner. */ balance_of_owner: () => number
74
+
75
+ /** **FULLSEC** */
76
+ xfer_gc_to_caller: (args: { amount: number | string, memo?: string | undefined }) => ScriptResponse
108
77
  }
109
78
 
110
79
  bbs: {
111
80
  read: () => {
112
- boards: {
113
- title: string
114
- slug: string
115
- }[]
81
+ boards: { title: string, slug: string }[]
116
82
 
117
83
  posts: {
118
84
  vote_count: number
@@ -134,84 +100,43 @@ type Fullsec = Subscripts & PlayerFullsec & {
134
100
  }
135
101
 
136
102
  chats: {
137
- /**
138
- * **FULLSEC**
139
- *
140
- * @summary Create a new chat channel
141
- *
142
- * @description This script lets you create a new chat channel.
143
- * You cannot create a channel that already exists (including any of the default ports from `0000` to `FFFF`).
144
- * 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).
145
- */
103
+ /** **FULLSEC**
104
+ * @summary Create a new chat channel.
105
+ * @description This script lets you create a new chat channel.
106
+ * You cannot create a channel that already exists (including any of the default ports from `0000` to `FFFF`).
107
+ * If you do not supply a password, anyone can join your channel (but the channel name is not displayed
108
+ * anywhere, so they would have to discover it in some way first). */
146
109
  create: ((args: {
147
- /**
148
- * The name of the channel to create
149
- */
150
- name: string
151
-
152
- /**
153
- * The password to secure the channel with
154
- */
155
- password?: string
110
+ /** The name of the channel to create. */ name: string
111
+ /** The password to secure the channel with. */ password?: string
156
112
  }) => ScriptResponse) & ((args: {
157
- /**
158
- * The name of the channel to create
159
- */
160
- c: string
161
-
162
- /**
163
- * The password to secure the channel with
164
- */
165
- password?: string
113
+ /** The name of the channel to create. */ c: string
114
+ /** The password to secure the channel with. */ password?: string
166
115
  }) => ScriptResponse)
167
116
 
168
- /**
169
- * **FULLSEC**
170
- *
171
- * @summary Send a chat message to a channel
172
- *
173
- * @description This script lets you send a message to the specified channel.
174
- * You must have joined the channel, and you will see your own message (unlike chats.tell).
175
- */
117
+ /** **FULLSEC**
118
+ * @summary Send a chat message to a channel.
119
+ * @description This script lets you send a message to the specified channel.
120
+ * You must have joined the channel, and you will see your own message (unlike chats.tell). */
176
121
  send: (args: {
177
- /**
178
- * The channel to send the message to.
179
- */
180
- channel: string
181
-
182
- /**
183
- * The message to send
184
- */
185
- msg: string
122
+ /** The channel to send the message to. */ channel: string
123
+ /** The message to send. */ msg: string
186
124
  }) => ScriptResponse
187
125
 
188
- /**
189
- * **FULLSEC**
190
- *
191
- * @summary Send a chat message to a specific user
192
- *
193
- * @description This script lets you send a message to the specified user directly.
194
- * You can message any user, you only need their username.
195
- * 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).
196
- */
126
+ /** **FULLSEC**
127
+ * @summary Send a chat message to a specific user.
128
+ * @description This script lets you send a message to the specified user directly.
129
+ * You can message any user, you only need their username.
130
+ * Note that you will not be able to see your message after it is sent (though many chat scripts based on
131
+ * chats.tell also send the message to you to work around this limitation). */
197
132
  tell: (args: {
198
- /**
199
- * The username to send the message to
200
- */
201
- to: string
202
-
203
- /**
204
- * The message to send
205
- */
206
- msg: string
133
+ /** The username to send the message to. */ to: string
134
+ /** The message to send. */ msg: string
207
135
  }) => ScriptResponse
208
136
  }
209
137
 
210
138
  escrow: {
211
- /**
212
- * **FULLSEC**
213
- */
214
- charge: (args: {
139
+ /** **FULLSEC** */ charge: (args: {
215
140
  cost: number | string
216
141
  is_unlim?: boolean
217
142
  }) => null | ScriptFailure
@@ -228,405 +153,257 @@ type Fullsec = Subscripts & PlayerFullsec & {
228
153
  }
229
154
 
230
155
  market: {
231
- /**
232
- * **FULLSEC**
233
- */
234
- browse: ((args: {
235
- seller: string
236
- listed_before: number
237
- listed_after: number
238
- cost: number | string
239
- } & CLIUpgrade) => {
240
- i: string
241
- name: string
242
- rarity: Upgrade["rarity"]
243
- cost: number
244
- }[] | ScriptFailure) & (<I extends string>(args: { i: I }) => {
245
- i: I
246
- seller: string
247
- cost: number
248
- count: number
249
- description: string
250
- upgrade: Upgrade
251
- no_notify: boolean
252
- } | ScriptFailure) & (<I extends string[]>(args: { i: I }) => {
253
- i: I
254
- seller: string
255
- cost: number
256
- count: number
257
- description: string
258
- upgrade: Upgrade
259
- no_notify: boolean
260
- }[] | ScriptFailure)
156
+ /** **FULLSEC** */ browse: {
157
+ (args:
158
+ Partial<{ seller: string, listed_before: number, listed_after: number, cost: number | string } & Omit<CLIUpgrade, "rarity">>
159
+ ): { i: string, name: string, rarity: Upgrade["rarity"], cost: number }[] | ScriptFailure
160
+
161
+ <I extends string>(args: { i: I }): {
162
+ i: I
163
+ seller: string
164
+ cost: number
165
+ count: number
166
+ description: string
167
+ upgrade: Upgrade
168
+ no_notify: boolean
169
+ } | ScriptFailure
170
+
171
+ <I extends string[]>(args: { i: I }): {
172
+ i: I
173
+ seller: string
174
+ cost: number
175
+ count: number
176
+ description: string
177
+ upgrade: Upgrade
178
+ no_notify: boolean
179
+ }[] | ScriptFailure
180
+ }
261
181
  }
262
182
 
263
183
  scripts: {
264
- /**
265
- * **FULLSEC**
266
- */
267
- fullsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
268
-
269
- /**
270
- * **FULLSEC**
271
- */
272
- get_access_level: (args: { name: string }) => {
273
- public: boolean
274
- hidden: boolean
275
- trust: boolean
276
- } | ScriptFailure
277
-
278
- /**
279
- * **FULLSEC**
280
- */
281
- get_level: (args: { name: string }) => 0 | 1 | 2 | 3 | 4 | ScriptFailure
282
-
283
- /**
284
- * **FULLSEC**
285
- */
286
- highsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
287
-
288
- /**
289
- * **FULLSEC**
290
- */
291
- lowsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
292
-
293
- /**
294
- * **FULLSEC**
295
- */
296
- midsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
297
-
298
- /**
299
- * **FULLSEC**
300
- */
301
- nullsec: ((args?: object) => string[]) & ((args: { sector: string }) => string[] | ScriptFailure)
302
-
303
- /**
304
- * **FULLSEC**
305
- */
306
- trust: () => string[]
307
-
308
- /**
309
- * FULLSEC
310
- *
311
- * @returns a code library containing useful helper functions you can use in your scripts.
312
- */
184
+ /** **FULLSEC** */ get_access_level: (args: { name: string }) =>
185
+ { public: boolean, hidden: boolean, trust: boolean } | ScriptFailure
186
+
187
+ /** **FULLSEC** */ get_level: (args: { name: string }) => 0 | 1 | 2 | 3 | 4 | ScriptFailure
188
+ /** **FULLSEC** */ fullsec: { (): string[], (args: { sector: string }): string[] | ScriptFailure }
189
+ /** **FULLSEC** */ highsec: Fullsec["scripts"]["fullsec"]
190
+ /** **FULLSEC** */ lowsec: Fullsec["scripts"]["fullsec"]
191
+ /** **FULLSEC** */ midsec: Fullsec["scripts"]["fullsec"]
192
+ /** **FULLSEC** */ nullsec: Fullsec["scripts"]["fullsec"]
193
+ /** **FULLSEC** */ trust: () => string[]
194
+
195
+ /** FULLSEC
196
+ * @returns A code library containing useful helper functions you can use in your scripts. */
313
197
  lib: () => {
314
198
  ok: () => ScriptSuccess
199
+ not_impl: () => { ok: false, msg: "Not Implemented." }
200
+ /** Append `message` to the current script run's log. */ log: (message: any) => void
201
+ /** @returns All messages added using `scripts.lib().log` during this script run. */ get_log: () => string[]
315
202
 
316
- not_impl: () => {
317
- ok: false
318
- msg: "Not Implemented."
319
- }
320
- /**
321
- * Append `message` to the current script run's log.
322
- */
323
- log: (message: any) => void
324
- /**
325
- * @returns all messages added using `scripts.lib().log` during this script run
326
- */
327
- get_log: () => string[]
328
- /**
329
- * @returns a random integer in the range [min, max) generated using `rng` (defaults to `Math.random`)
330
- */
203
+ /** @returns A random integer in the range [min, max) generated using `rng` (defaults to `Math.random`). */
331
204
  rand_int: (min: number, max: number, rng?:()=>number) => number
332
- /**
333
- * @returns the value of `value`, bounded by the range [`floor`, `ceil`]
334
- */
205
+
206
+ /** @returns `floor` if `value` is less than `floor`, `ceil` if `value` is more than `ceil`, otherwise
207
+ * `value`. */
335
208
  clamp: (value: number, floor: number, ceil: number) => number
336
- /**
337
- * Linear interpolation function.
338
- * @returns a number <`amount*100`>% of the way from `start` to `stop`
339
- */
209
+
210
+ /** Linear interpolation function.
211
+ * @returns A number between `start` and `stop` using `amount` as a percent. */
340
212
  lerp: (amount: number, start: number, stop: number) => number
341
- /**
342
- * @returns a random element from `array`, selected with a random number generated using `rng` (defaults to `Math.random`)
343
- */
213
+
214
+ /** @returns A random element from `array`, selected with a random number generated using `rng`
215
+ * (defaults to `Math.random`). */
344
216
  sample: (array: any[], rng?: ()=>number) => any
345
- /**
346
- * @returns whether two MongoDB ObjectIds are equivalent
347
- */
348
- are_ids_eq: (id1: any, id2: any) => boolean
349
- /**
350
- * Convert a MongoDB ObjectId to a string
351
- */
352
- id_to_str: (id: string | {$oid: string}) => any
353
- /**
354
- * @returns whether `value` is a boolean primitive
355
- */
356
- is_bool: (value: any) => value is boolean
357
- /**
358
- * @returns whether `value` is an object or `null`
359
- */
217
+
218
+ /** @returns Whether two MongoDB `ObjectId`s are equivalent. */ are_ids_eq: (id1: any, id2: any) => boolean
219
+ /** Convert a MongoDB `ObjectId` to a string. */ id_to_str: (id: string | {$oid: string}) => any
220
+ /** @returns Whether `value` is a boolean primitive. */ is_bool: (value: any) => value is boolean
221
+ /** @returns Whether `value` is an object or `null`. */
360
222
  is_obj: (value: any) => value is Record<string, unknown> | null
361
- /**
362
- * @returns whether `value` is a string
363
- */
364
- is_str: (value: any) => value is string
365
- /**
366
- * @returns whether `value` is a number
367
- */
368
- is_num: (value: any) => value is number
369
- /**
370
- * @returns whether `value` is an integer
371
- */
372
- is_int: (value: any) => value is number
373
- /**
374
- * @returns whether `value` is a negative number
375
- */
376
- is_neg: (value: any) => value is number
377
- /**
378
- * @returns whether `value` is an array
379
- */
380
- is_arr: (value: any) => value is unknown[]
381
- /**
382
- * @returns whether `value` is a function
383
- */
384
- is_func: (value: any) => value is (...args: any[]) => unknown
385
- /**
386
- * @returns whether `value` is not `undefined`
387
- */
388
- is_def: (value: any) => boolean
389
- /**
390
- * @returns whether `name` is a valid in-game username
391
- */
392
- is_valid_name: (name: string) => boolean
393
- /**
394
- * @returns the string representation of `value`
395
- */
396
- dump: (value: { toString: () => string }) => string
397
- /**
398
- * @returns a deep clone of `object`
399
- */
400
- clone: <T extends object>(object: T) => T
401
- /**
402
- * Applies all key-value pairs from `obj2` to `obj1`, overwriting if necessary.
403
- */
223
+ /** @returns Whether `value` is a string. */ is_str: (value: any) => value is string
224
+ /** @returns Whether `value` is a number. */ is_num: (value: any) => value is number
225
+ /** @returns Whether `value` is an integer. */ is_int: (value: any) => value is number
226
+ /** @returns Whether `value` is a negative number. */ is_neg: (value: any) => value is number
227
+ /** @returns Whether `value` is an array. */ is_arr: (value: any) => value is unknown[]
228
+ /** @returns Whether `value` is a function. */ is_func: (value: any) => value is (...args: any[]) => unknown
229
+ /** @returns Whether `value` is not `undefined`. */ is_def: (value: any) => boolean
230
+ /** @returns Whether `name` is a valid in-game username. */ is_valid_name: (name: string) => boolean
231
+ /** @returns The string representation of `value`. */ dump: (value: { toString: () => string }) => string
232
+ /** @returns A deep clone of `object`. */ clone: <T extends object>(object: T) => T
233
+
234
+ /** Applies all key-value pairs from `obj2` to `obj1`, overwriting if necessary. */
404
235
  merge: <F extends object, S extends object>(obj1: F, obj2: S) => F & S
405
- /**
406
- * @returns an array of `object`'s values
407
- */
408
- get_values: (object: object) => any[]
409
- /**
410
- * @returns a numeric hash of `string`
411
- */
412
- hash_code: (string: string) => number
413
- /**
414
- * @returns a numeric hash of `string`
415
- */
416
- xmur3: (string: string) => number
417
- /**
418
- * @returns function that generates random floats in the range [0,1] based on the numerical seeds
419
- */
236
+
237
+ /** @returns An array of `object`'s values */ get_values: (object: object) => any[]
238
+ /** @returns A numeric hash of `string`. */ hash_code: (string: string) => number
239
+
240
+ /** @returns A numeric hash of `string`. */ xmur3: (string: string) => number
241
+
242
+ /** @returns Function that generates random floats in the range 0-1 based on the numerical seeds. */
420
243
  sfc32: (seed1: number, seed2: number, seed3: number, seed4: number) => () => number
421
- /**
422
- * @returns function that generates random floats in the range [0,1] based on the numerical seed
423
- */
244
+
245
+ /** @returns Function that generates random floats in the range 0-1 based on the numerical seed. */
424
246
  mulberry32: (seed: number) => () => number
425
- /**
426
- * @returns function that generates random floats in the range [0,1] based on the numerical seeds
427
- */
247
+
248
+ /** @returns Function that generates random floats in the range 0-1 based on the numerical seeds. */
428
249
  xoshiro128ss: (seed1: number, seed2: number, seed3: number, seed4: number) => () => number
429
- /**
430
- * @returns function that generates random floats in the range [0,1] based on the numerical seed
431
- */
250
+
251
+ /** @returns Function that generates random floats in the range 0-1 based on the numerical seed. */
432
252
  JSF: (seed: number) => () => number
433
- /**
434
- * @returns function that generates random floats in the range [0,1] based on the numerical seed
435
- */
253
+
254
+ /** @returns Function that generates random floats in the range 0-1 based on the numerical seed. */
436
255
  LCG: (seed: number) => () => number
437
- /**
438
- * Converts a number to a GC string of the form `"1M5K20GC"`.
439
- */
440
- to_gc_str: (number: number) => string
441
- /**
442
- * Converts a string similar to `"1M5K20GC"` to an equivalent numerical representation.
443
- */
256
+
257
+ /** Converts a number to a GC string of the form `"1M5K20GC"`. */ to_gc_str: (number: number) => string
258
+
259
+ /** Converts a string similar to `"1M5K20GC"` to an equivalent numerical representation. */
444
260
  to_gc_num: (string: string) => number | ScriptFailure
445
- /**
446
- * @returns a string of the form YYMMDD.HHMM derived from `date`
447
- */
448
- to_game_timestr: (date: Date) => string
261
+
262
+ /** @returns A string of the form YYMMDD.HHMM derived from `date`. */ to_game_timestr: (date: Date) => string
263
+
449
264
  corruption_chars: "¡¢Á¤Ã¦§¨©ª"
450
- /**
451
- * A list of unique color codes to be used with hackmud's color formatting syntax.
452
- * Does not include numeric codes, which are duplicates of some alphabetic codes.
453
- */
265
+
266
+ /** A list of unique color codes to be used with hackmud's color formatting syntax.
267
+ * Does not include numeric codes, which are duplicates of some alphabetic codes. */
454
268
  colors: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
455
- /**
456
- * Used by `scripts.lib().corrupt` to determine the frequency of corruption.
457
- */
269
+
270
+ /** Used by `$fs.scripts.lib().corrupt()` to determine the frequency of corruption. */
458
271
  corruptions: [ 0, 1, 1.5, 2.5, 5 ]
459
- /**
460
- * Adds colored corruption characters to `text`, with frequency determined by `amount`.
461
- */
272
+
273
+ /** Adds colored corruption characters to `text`, with frequency determined by `amount`. */
462
274
  corrupt: (text: string | string[], amount: 0 | 1 | 2 | 3 | 4) => string
463
- /**
464
- * @returns the first <`length`> characters of `string`, or the original string if it is shorter than `length`
465
- */
275
+
276
+ /** @returns The first `length` characters of `string`, or the original string if it is shorter than
277
+ * `length`. */
466
278
  cap_str_len: (string: string, length: number) => string
467
- /**
468
- * Applies `func` to each element in `array` and returns the original array.
469
- */
470
- each: <T>(array: T[], func: (index: number, value: T) => void) => T[]
471
- /**
472
- * @returns a new array containing the elments of `array` for which `func` returns `true`
473
- */
474
- select: <T>(array: T[], func: (index: number, value: T) => boolean) => T[]
475
- /**
476
- * @returns the number of elements in `array` for which `func` returns `true`
477
- */
478
- count: <T>(array: T[], func: (index: number, value: T) => boolean) => number
479
- /**
480
- * @returns the first element in `array` for which `func` returns `true`
481
- */
482
- select_one: <T>(array: T[], func: (index: number, value: T) => boolean) => T
483
- /**
484
- * @returns a new array composed of the result of applying `func` to each element of the original array in order
485
- */
486
- map: <T, U>(array: T[], func: (index: number, value: T) => U) => U[]
487
- /**
488
- * @returns a new object derived from `obj` with only the keys specified in `keys`
489
- */
279
+
280
+ /** Applies `callback` to each element in `array` and returns the original array. */
281
+ each: <T>(array: T[], callback: (index: number, value: T) => void) => T[]
282
+
283
+ /** @returns A new array containing the elments of `array` for which `callback` returns `true`. */
284
+ select: <T>(array: T[], callback: (index: number, value: T) => boolean) => T[]
285
+
286
+ /** @returns The number of elements in `array` for which `callback` returns `true`. */
287
+ count: <T>(array: T[], callback: (index: number, value: T) => boolean) => number
288
+
289
+ /** @returns The first element in `array` for which `callback` returns `true`. */
290
+ select_one: <T>(array: T[], callback: (index: number, value: T) => boolean) => T
291
+
292
+ /** @returns A new array composed of the result of applying `callback` to each element of the original array
293
+ * in order. */
294
+ map: <T, U>(array: T[], callback: (index: number, value: T) => U) => U[]
295
+
296
+ /** @returns A new object derived from `obj` with only the keys specified in `keys`. */
490
297
  pick: (obj: object, keys: string[]) => any
491
- /**
492
- * @returns an array with the elements from `array` in a random order
493
- */
494
- shuffle: <T>(array: T[]) => T[]
495
- /**
496
- * Comparison function for sorting arbitrary values in ascending order using builtin comparison operators.
497
- */
298
+
299
+ /** @returns An array with the elements from `array` in a random order. */ shuffle: <T>(array: T[]) => T[]
300
+
301
+ /** Comparison function for sorting arbitrary values in ascending order using builtin comparison operators.
302
+ */
498
303
  sort_asc: (one: any, two: any) => 1 | -1 | 0
499
- /**
500
- * Comparison function for sorting arbitrary values in descending order using builtin comparison operators.
501
- */
304
+
305
+ /** Comparison function for sorting arbitrary values in descending order using builtin comparison operators.
306
+ */
502
307
  sort_desc: (one: any, two: any) => 1 | -1 | 0
503
- /**
504
- * Comparison function for sorting numbers in ascending order.
505
- */
308
+
309
+ /** Comparison function for sorting numbers in ascending order. */
506
310
  num_sort_asc: (one: number, two: number) => 1 | -1 | 0
507
- /**
508
- * Comparison function for sorting numbers in descending order.
509
- */
311
+
312
+ /** Comparison function for sorting numbers in descending order. */
510
313
  num_sort_desc: (one: number, two: number) => 1 | -1 | 0
511
- /**
512
- * @returns the value and the index of the largest number in `array` as `[maxVal, maxIdx]`
513
- */
514
- max_val_index: (array: number[]) => number[]
515
- /**
516
- * @returns a new `Date` equivalent to `date.getTime() + add_ms`
517
- */
314
+
315
+ /** @returns The value and the index of the largest number in `array`. */
316
+ max_val_index: (array: number[]) => [ largestValue: number, index: number ]
317
+
318
+ /** @returns A new `Date` equivalent to `date.getTime() + add_ms`. */
518
319
  add_time: (date: Date, add_ms: number) => Date
519
- /**
520
- * String representations of the in-game seclevels.
521
- */
320
+
321
+ /** Array of strings representing seclevels. */
522
322
  security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
523
- /**
524
- * @returns the string name of a numeric security level
525
- */
323
+
324
+ /** @returns The string name of a numeric security level. */
526
325
  get_security_level_name: (security_level: number) => any
527
- /**
528
- * @param result the return value of a call to `#db.i` or `#db.r`
529
- * @param nModified the expected value of `result.nModified`
530
- * @returns whether the database operation failed
531
- */
532
- dbu_result_failed: (result: ReturnType<typeof $db.u | typeof $db.u1 | typeof $db.us>, nModified?: number) => boolean
533
- /**
534
- * @param result the return value of a call to `#db.i` or `#db.r`
535
- * @param n the expected value of `result.n`
536
- * @returns whether the database operation failed
537
- */
326
+
327
+ /** @param result The return value of a call to `$db.i()` or `$db.r()`.
328
+ * @param nModified The expected value of `result.nModified`.
329
+ * @returns Whether the database operation failed. */
330
+ dbu_result_failed: (result: ReturnType<typeof $db.u | typeof $db.u1 | typeof $db.us>, nModified?: number) =>
331
+ boolean
332
+
333
+ /** @param result The return value of a call to `$db.i()` or `$db.r()`.
334
+ * @param n The expected value of `result.n`.
335
+ * @returns Whether the database operation failed. */
538
336
  dbir_result_failed: (result: ReturnType<typeof $db.i | typeof $db.r>, n?: number) => boolean
539
- /**
540
- * @returns a random string of length `length` on the alphabet [a-z0-9]
541
- */
337
+
338
+ /** @returns A random string of length `length` using lowercase letters and numbers. */
542
339
  create_rand_string: (length: number) => string
543
- /**
544
- * @returns the user half `x` of a fully-qualified script name `x.y`
545
- */
340
+
341
+ /** @returns The user half `x` of a fully-qualified script name `x.y`. */
546
342
  get_user_from_script: (script_name: string) => string
547
- /**
548
- * @returns the script half `y` of a fully-qualified script name `x.y`
549
- */
343
+
344
+ /** @returns The script half `y` of a fully-qualified script name `x.y`. */
550
345
  get_scriptname_from_script: (name: string) => string
551
- /**
552
- * Determines whether to treat this run as a subscript, based either on the presence of `calling_script` in `context`,
553
- * or the explicit passing of `is_script:true` in `args`.
554
- */
346
+
347
+ /** Determines whether to treat this run as a subscript, based either on the presence of `calling_script` in
348
+ * `context`, or the explicit passing of `is_script: true` in `args`. */
555
349
  is_script: (context: Context, args: any) => boolean
556
- /**
557
- * @returns whether the script is being called by its owner
558
- */
350
+
351
+ /** @returns Whether the script is being called by its owner. */
559
352
  caller_is_owner: (context: Context) => boolean
560
- /**
561
- * Removes consecutive duplicate elements from an array.
562
- * @example
563
- * ```js
564
- * const arr = [1, 2, 2, 3, 2]
565
- * return #fs.scripts.lib().uniq(arr)
566
- * // [1, 2, 3, 2]
567
- * ```
568
- */
353
+
354
+ /** Removes consecutive duplicate elements from an array.
355
+ * @example
356
+ * const { uniq } = $fs.scripts.lib()
357
+ * const arr = [ 1, 2, 2, 3, 2 ]
358
+ *
359
+ * $D(uniq(arr)) // [ 1, 2, 3, 2 ] */
569
360
  uniq: (array: T[]) => T[]
570
- /**
571
- * Sorts an array of numbers or number-coercible strings in descending order.
572
- */
361
+
362
+ /** Sorts an array of numbers or number-coercible strings in descending order. */
573
363
  u_sort_num_arr_desc: <T>(array: T[]) => T[]
574
- /**
575
- * BUGGED: Creates a new string of length `length` by repeating `pad_char`.
576
- */
364
+
365
+ /** BUGGED: Creates a new string of length `length` by repeating `pad_char`. */
577
366
  ljust: (input: string, length: number, pad_char?: string) => string
578
- /**
579
- * Add characters from `pad_char` to the left of `input` until it reaches length `length`.
580
- */
367
+
368
+ /** Add characters from `pad_char` to the left of `input` until it reaches length `length`. */
581
369
  rjust: (input: string, length: number, pad_char?: string) => string
582
- /**
583
- * @returns a string with the entries from `strings` split into evenly spaced columns,
584
- * organized donward and then rightward, to fit the current user's terminal
585
- */
370
+
371
+ /** @returns A string with the entries from `strings` split into evenly spaced columns, organized donward
372
+ * and then rightward, to fit the current user's terminal. */
586
373
  columnize: (strings: string[]) => string
587
- /**
588
- * Takes two newline-separated strings and formats a new string where they appear in columns, separated by `space`.
589
- * @example
590
- * ```js
591
- * const str1 = "one\ntwo\nthree"
592
- * const str2 = "four\nfive\nsix"
593
- * return $fs.scripts.lib().side_by_side(str1, str2, "|")
594
- * // one|four\n
595
- * // two|five\n
596
- * // three|six
597
- * ```
598
- */
599
- side_by_side: (str1: string, str2: string, space?:string) => string
600
- /**
601
- * @returns whether enough time remains in the script execution window to satisfy `time_left`
602
- */
374
+
375
+ /** Takes two newline-separated strings and formats a new string where they appear in columns, separated by
376
+ * `space`.
377
+ * @example
378
+ * const { side_by_side } = $fs.scripts.lib()
379
+ * const str1 = "one\ntwo\nthree"
380
+ * const str2 = "four\nfive\nsix"
381
+ *
382
+ * $D(side_by_side(str1, str2, "|"))
383
+ * // one|four\n
384
+ * // two|five\n
385
+ * // three|six */
386
+ side_by_side: (str1: string, str2: string, space?: string) => string
387
+
388
+ /** @returns Whether enough time remains in the script execution window to satisfy `time_left`. */
603
389
  can_continue_execution: (time_left: number) => boolean
604
- /**
605
- * @returns a human-readable error object when not enough time remains in the script execution window to satisfy `time_left`
606
- */
607
- can_continue_execution_error: (time_left: number, name?:string) => {ok:false, msg: string}
608
- date: typeof Date
609
- /**
610
- * @returns current date, equivalent to `new Date()`
611
- */
612
- get_date: () => Date
613
- /**
614
- * @returns time since the epoch, equivalent to `Date.now()`
615
- */
616
- get_date_utcsecs: () => number
617
- /**
618
- * The amount of milliseconds in a single day.
619
- */
620
- one_day_ms: 86_400_000
390
+
391
+ /** @returns A human-readable error object when not enough time remains in the script execution window to
392
+ * satisfy `time_left`. */
393
+ can_continue_execution_error: (time_left: number, name?: string) => { ok:false, msg: string }
394
+
395
+ /** @returns Current date, equivalent to `new Date()`. */ get_date: () => Date
396
+ /** @returns time since the epoch, equivalent to `Date.now()`. */ get_date_utcsecs: () => number
397
+ /** The amount of milliseconds in a single day. */ one_day_ms: 86_400_000
398
+
621
399
  is_not_today: (date: Date) => boolean
622
- /**
623
- * @returns the number of days that have passed between `d2` and `d1`
624
- */
400
+
401
+ /** @returns The number of days that have passed between `d2` and `d1` */
625
402
  utc_day_diff: (d1: Date, d2: Date) => number
626
- /**
627
- * @returns the number of days elapsed since `date` as a string, e.g. "<n> days"
628
- */
403
+
404
+ /** @returns The number of days elapsed since `date` as a string, e.g. "<n> days" */
629
405
  utc_days_ago_str: (date: Date) => string
406
+
630
407
  math: typeof Math
631
408
  array: typeof Array
632
409
  parse_int: typeof parseInt
@@ -634,361 +411,200 @@ type Fullsec = Subscripts & PlayerFullsec & {
634
411
  json: typeof JSON
635
412
  number: typeof Number
636
413
  object: typeof Object
414
+ date: typeof Date
637
415
  }
638
416
 
639
- /**
640
- * **FULLSEC**
641
- */
642
- quine: () => string
417
+ /** **FULLSEC** */ quine: () => string
643
418
  }
644
419
 
645
420
  sys: {
646
421
  init: never
647
422
 
648
- /**
649
- * **FULLSEC**
650
- */
651
- upgrades_of_owner: (<
652
- F extends Partial<Upgrade & { loaded: boolean }> = object
653
- >(args?: { filter?: F, full?: false }) => (
654
- Omit<
655
- Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
656
- keyof F
657
- > & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
658
- )[] | ScriptFailure) & (<
659
- F extends Partial<Upgrade & { loaded: boolean }> = object
660
- >(args: { filter?: F, full: true }) => (
661
- Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
662
- )[] | ScriptFailure) & (<I extends number>(args: { i: I }) => (
663
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
664
- ) | ScriptFailure)
665
-
666
- /**
667
- * **FULLSEC**
668
- */
669
- xfer_upgrade_to_caller: ((args: {
670
- i: number | number[]
671
- memo?: string
672
- }) => ScriptResponse) & ((args: {
673
- sn: string | string[]
674
- memo?: string
675
- }) => ScriptResponse)
423
+ /** **FULLSEC** */
424
+ upgrades_of_owner: {
425
+ <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: { filter?: F, full?: false }): (
426
+ Omit<
427
+ Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
428
+ keyof F
429
+ > & Pick<F, "tier" | "rarity" | "name" | "type" | "i" | "loaded">
430
+ )[] | ScriptFailure
431
+
432
+ <F extends Partial<Upgrade & { loaded: boolean }> = object>(args: { filter?: F, full: true }): (
433
+ Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
434
+ )[] | ScriptFailure
435
+
436
+ <I extends number>(args: { i: I }): (
437
+ Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
438
+ ) | ScriptFailure
439
+ }
440
+
441
+ /** **FULLSEC** */
442
+ xfer_upgrade_to_caller: (args: ({ i: number | number[] } | { sn: string | string[] }) & { memo?: string }) =>
443
+ ScriptResponse
676
444
  }
677
445
 
678
446
  users: {
679
- /**
680
- * **FULLSEC**
681
- */
682
- active: () => number
683
-
684
- /**
685
- * **FULLSEC**
686
- */
687
- last_action: (args: { name: string | string[] }) => ({
688
- n: string
689
- t?: Date
690
- } | null)[]
691
-
692
- /**
693
- * **FULLSEC**
694
- */
447
+ /** **FULLSEC** */ active: () => number
448
+ /** **FULLSEC** */ last_action: (args: { name: string | string[] }) => ({ n: string, t?: Date } | null)[]
449
+
450
+ /** **FULLSEC** */
695
451
  top: () => [
696
- UsersTopItem<1>,
697
- UsersTopItem<2>,
698
- UsersTopItem<3>,
699
- UsersTopItem<4>,
700
- UsersTopItem<5>,
701
- UsersTopItem<6>,
702
- UsersTopItem<7>,
703
- UsersTopItem<8>,
704
- UsersTopItem<9>,
705
- UsersTopItem<10>
452
+ UsersTopItem<1>, UsersTopItem<2>, UsersTopItem<3>, UsersTopItem<4>, UsersTopItem<5>,
453
+ UsersTopItem<6>, UsersTopItem<7>, UsersTopItem<8>, UsersTopItem<9>, UsersTopItem<10>
706
454
  ]
707
455
  }
708
456
  }
709
457
 
710
458
  type Highsec = Fullsec & PlayerHighsec & {
711
459
  accts: {
712
- /**
713
- * **HIGHSEC**
714
- *
715
- * @returns GC balance as number if `is_script` is true (default)
716
- * @returns GC balance as string if `is_script` is false
717
- */
460
+ /** **HIGHSEC**
461
+ * @returns GC balance as number if `is_script` is true (default).
462
+ * @returns GC balance as string if `is_script` is false. */
718
463
  balance: ((args?: { is_script?: true }) => number) & ((args: { is_script: false }) => string)
719
464
 
720
- /**
721
- * **HIGHSEC**
722
- *
723
- * @returns transaction history according to filter
724
- * @returns if `is_script` is true (default), time property as Date object
725
- * @returns wraps transactions in object with msg, time property as string (game date format e.g. 201028.2147) if `is_script` is false
726
- */
727
- transactions: ((args?: {
728
- count?: number | "all"
729
- to?: string
730
- from?: string
731
- script?: string
732
- is_script?: true
733
- }) => {
734
- time: Date
735
- amount: number
736
- sender: string
737
- recipient: string
738
- script: string | null
739
- memo?: string
740
- }[]) & ((args: {
741
- count?: number | "all"
742
- to?: string
743
- from?: string
744
- script?: string
745
- is_script: false
746
- }) => {
747
- msg: string
748
- transactions: {
749
- time: string
750
- amount: string
465
+ /** **HIGHSEC**
466
+ * @returns Transaction history according to filter.
467
+ * @returns If `is_script` is true (default), time property as Date object.
468
+ * @returns Wraps transactions in object with msg, time property as string (game date format e.g. 201028.2147)
469
+ * if `is_script` is false. */
470
+ transactions: {
471
+ (args?: { count?: number | "all", to?: string, from?: string, script?: string, is_script?: true }): {
472
+ time: Date
473
+ amount: number
751
474
  sender: string
752
475
  recipient: string
753
476
  script: string | null
754
477
  memo?: string
755
478
  }[]
756
- })
479
+
480
+ (args: { count?: number | "all", to?: string, from?: string, script?: string, is_script: false }): {
481
+ msg: string
482
+ transactions: {
483
+ time: string
484
+ amount: string
485
+ sender: string
486
+ recipient: string
487
+ script: string | null
488
+ memo?: string
489
+ }[]
490
+ }
491
+ }
757
492
  }
758
493
 
759
494
  scripts: {
760
- /**
761
- * **HIGHSEC**
762
- */
763
- sys: () => string | string[]
495
+ /** **HIGHSEC** */ sys: () => string | string[]
764
496
  }
765
497
 
766
498
  sys: {
767
- /**
768
- * **HIGHSEC**
769
- */
770
- specs: () => string | ScriptFailure
771
-
772
- /**
773
- * **HIGHSEC**
774
- */
775
- status: () => {
776
- hardline: number
777
- tutorial: string
778
- breach: boolean
499
+ /** **HIGHSEC** */ specs: () => string | ScriptFailure
500
+ /** **HIGHSEC** */ status: () => { hardline: number, tutorial: string, breach: boolean }
501
+
502
+ /** **HIGHSEC** */
503
+ upgrade_log: {
504
+ (args?: { is_script?: true, user?: string, run_id?: string, count?: number, start?: number }):
505
+ { t: Date, u: string, r: string, msg: string }[] | ScriptFailure
506
+
507
+ (args: { is_script: false, user?: string, run_id?: string, count?: number, start?: number }):
508
+ string[] | ScriptFailure
779
509
  }
780
510
 
781
- /**
782
- * **HIGHSEC**
783
- */
784
- upgrade_log: ((args?: {
785
- is_script?: true
786
- user?: string
787
- run_id?: string
788
- count?: number
789
- start?: number
790
- }) => {
791
- t: Date
792
- u: string
793
- r: string
794
- msg: string
795
- }[] | ScriptFailure) & ((args: {
796
- is_script: false
797
- user?: string
798
- run_id?: string
799
- count?: number
800
- start?: number
801
- }) => string[] | ScriptFailure)
802
-
803
- /**
804
- * **HIGHSEC**
805
- */
806
- upgrades: (<I extends number>(args: { i: I }) => (
807
- Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
808
- ) | ScriptFailure) & (<
809
- F extends Partial<Upgrade & { loaded: boolean }> = object
810
- >(args?: {
811
- filter?: F
812
- is_script?: true
813
- full?: false
814
- }) => (
815
- Omit<
816
- Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">,
817
- keyof F
818
- > & F & Record<string, null | boolean | number | string>
819
- )[] | ScriptFailure) & (<
820
- F extends Partial<Upgrade & { loaded: boolean }> = object
821
- >(args?: {
822
- filter?: F
823
- is_script?: true
824
- full: true
825
- }) => (
826
- Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>
827
- )[] | ScriptFailure) & ((args?: {
828
- filter?: Partial<Upgrade & { loaded: boolean }>
829
- is_script: false
830
- full?: false
831
- }) => {
832
- msg: string
833
- upgrades: string[]
834
- } | ScriptFailure) & (<
835
- F extends Partial<Upgrade & { loaded: boolean }> = object
836
- >(args?: {
837
- filter?: F
838
- is_script: false
839
- full: true
840
- }) => (
841
- Omit<UpgradeCore, keyof F | `rarity`> & F & {
511
+ /** **HIGHSEC** */
512
+ upgrades: {
513
+ <I extends number>(args: { i: I }): (
514
+ Omit<UpgradeCore, "i"> & { [x: string]: null | boolean | number | string, i: I }
515
+ ) | ScriptFailure
516
+
517
+ <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?: {
518
+ filter?: F
519
+ is_script?: true
520
+ full?: false
521
+ }): (
522
+ Omit<Pick<UpgradeCore, "tier" | "rarity" | "name" | "type" | "i" | "loaded">, keyof F> & F &
523
+ Record<string, null | boolean | number | string>
524
+ )[] | ScriptFailure
525
+
526
+ <F extends Partial<Upgrade & { loaded: boolean }> = object>(args?:
527
+ { filter?: F, is_script?: true, full: true }
528
+ ): (Omit<UpgradeCore, keyof F> & F & Record<string, null | boolean | number | string>)[] | ScriptFailure
529
+
530
+ (args?: { filter?: Partial<Upgrade & { loaded: boolean }>, is_script: false, full?: false }):
531
+ { msg: string, upgrades: string[] } | ScriptFailure
532
+
533
+ <F extends Partial<Upgrade & { loaded: boolean }> = object>(
534
+ args?: { filter?: F, is_script: false, full: true }
535
+ ): (Omit<UpgradeCore, keyof F | `rarity`> & F & {
842
536
  [x: string]: null | boolean | number | string
843
- rarity: "`0noob`" | "`1kiddie`" | "`2h4x0r`" | "`3h4rdc0r3`" | "`4|_|b3|2`" | "`531337`"
844
- }
845
- )[] | ScriptFailure)
537
+ rarity: UpgradeRarityString
538
+ })[] | ScriptFailure
539
+ }
846
540
  }
847
541
 
848
542
  users: {
849
- /**
850
- * **HIGHSEC**
851
- */
852
- inspect: ((args: {
853
- name: "trust"
854
- is_script?: boolean
855
- }) => number) & ((args: {
856
- name: "risk"
857
- is_script?: boolean
858
- }) => string) & ((args: {
859
- name: string
860
- is_script?: true
861
- }) => {
862
- username: string
863
- avatar: string
864
- pronouns: string
865
- user_age?: Date
866
- bio?: string
867
- title?: string
868
- is_main: boolean
869
- alt_of?: string
870
- badges?: string[]
871
- } | ScriptFailure) & ((args: {
872
- name: string
873
- is_script: false
874
- }) => string | ScriptFailure)
543
+ /** **HIGHSEC** */ inspect: {
544
+ (args: { name: "trust", is_script?: boolean }): number
545
+ (args: { name: "risk", is_script?: boolean }): string
546
+
547
+ (args: { name: string, is_script?: true }): {
548
+ username: string
549
+ avatar: string
550
+ pronouns: string
551
+ user_age?: Date
552
+ bio?: string
553
+ title?: string
554
+ is_main: boolean
555
+ alt_of?: string
556
+ badges?: string[]
557
+ } | ScriptFailure
558
+
559
+ (args: { name: string, is_script: false }): string | ScriptFailure
560
+ }
875
561
  }
876
562
  }
877
563
 
878
564
  type Midsec = Highsec & PlayerMidsec & {
879
565
  accts: {
880
- /**
881
- * **MIDSEC**
882
- */
883
- xfer_gc_to: (args: {
884
- to: string
885
- amount: number | string
886
- memo?: string
887
- }) => ScriptResponse
566
+ /** **MIDSEC** */ xfer_gc_to: (args: { to: string, amount: number | string, memo?: string }) => ScriptResponse
888
567
  }
889
568
 
890
- autos: {
891
- /**
892
- * **MIDSEC**
893
- */
894
- reset: () => ScriptSuccess
895
- }
569
+ autos: { /** **MIDSEC** */ reset: () => ScriptSuccess }
896
570
 
897
571
  chats: {
898
- /**
899
- * **MIDSEC**
900
- */
901
- channels: () => string[]
902
-
903
- /**
904
- * **MIDSEC**
905
- */
906
- join: (args: {
907
- channel: string
908
- password?: string
909
- }) => ScriptResponse
910
-
911
- /**
912
- * **MIDSEC**
913
- */
914
- leave: (args: { channel: string }) => ScriptResponse
915
-
916
- /**
917
- * **MIDSEC**
918
- */
919
- users: (args: { channel: string }) => string[] | ScriptFailure
572
+ /** **MIDSEC** */ channels: () => string[]
573
+ /** **MIDSEC** */ join: (args: { channel: string, password?: string }) => ScriptResponse
574
+ /** **MIDSEC** */ leave: (args: { channel: string }) => ScriptResponse
575
+ /** **MIDSEC** */ users: (args: { channel: string }) => string[] | ScriptFailure
920
576
  }
921
577
 
922
578
  escrow: {
923
- /**
924
- * **MIDSEC**
925
- */
926
- stats: () => {
927
- scripts: string[]
928
- total: string
929
- outstanding: string
930
- open_escrow_count: number
931
- } | ScriptFailure
579
+ /** **MIDSEC** */ stats: () =>
580
+ { scripts: string[], total: string, outstanding: string, open_escrow_count: number } | ScriptFailure
932
581
  }
933
582
 
934
583
  market: {
935
- /**
936
- * **MIDSEC**
937
- */
938
- buy: (args: {
939
- i: string
940
- count: number
941
- confirm: true
942
- }) => ScriptResponse
584
+ /** **MIDSEC** */ buy: (args: { i: string, count: number, confirm: true }) => ScriptResponse
943
585
 
944
- /**
945
- * **MIDSEC**
946
- */
947
- stats: () => ScriptFailure | {
948
- total: string
949
- outstanding: string
950
- listed: number
951
- sold: number
952
- }
586
+ /** **MIDSEC** */ stats: () =>
587
+ ScriptFailure | { total: string, outstanding: string, listed: number, sold: number }
953
588
  }
954
589
 
955
- scripts: {
956
- /**
957
- * **MIDSEC**
958
- */
959
- user: () => string[]
960
- }
590
+ scripts: { /** **MIDSEC** */ user: () => string[] }
961
591
 
962
592
  sys: {
963
- /**
964
- * **MIDSEC**
965
- */
966
- manage: ((args: {
967
- unload?: number | number[]
968
- load?: number | number[]
969
- }) => ScriptResponse) & ((args: { reorder?: ([ number, number ] | {
970
- from: number
971
- to: number
972
- })[] | {
973
- from: number
974
- to: number
975
- } }) => string[] | ScriptFailure)
593
+ /** **MIDSEC** */
594
+ manage: {
595
+ (args: { unload?: number | number[], load?: number | number[] }): ScriptResponse
596
+
597
+ (args: { reorder?: ([ number, number ] | { from: number, to: number })[] | { from: number, to: number } }):
598
+ string[] | ScriptFailure
599
+ }
976
600
  }
977
601
  }
978
602
 
979
603
  type Lowsec = Midsec & PlayerLowsec & {
980
- kernel: {
981
- /**
982
- * **LOWSEC**
983
- */
984
- hardline: () => ScriptResponse
985
- }
604
+ kernel: { /** **LOWSEC** */ hardline: () => ScriptResponse }
986
605
 
987
606
  market: {
988
- /**
989
- * **LOWSEC**
990
- */
991
- sell: (args: {
607
+ /** **LOWSEC** */ sell: (args: {
992
608
  i: number
993
609
  cost: number | string
994
610
  description?: string
@@ -999,502 +615,273 @@ type Lowsec = Midsec & PlayerLowsec & {
999
615
  }
1000
616
 
1001
617
  sys: {
1002
- /**
1003
- * **LOWSEC**
1004
- */
1005
- access_log: ((args?: {
1006
- user?: string
1007
- run_id?: string
1008
- is_script?: true
1009
- count?: number
1010
- start?: number
1011
- }) => {
1012
- t: Date
1013
- u: string | undefined
1014
- r: string | undefined
1015
- msg: string
1016
- }[] | ScriptFailure) & ((args: {
1017
- user?: string
1018
- run_id?: string
1019
- is_script: false
1020
- count?: number
1021
- start?: number
1022
- }) => string[])
1023
-
1024
- /**
1025
- * **LOWSEC**
1026
- */
1027
- cull: (args: { i: number | number[], confirm: true }) => ScriptResponse
1028
-
1029
- /**
1030
- * **LOWSEC**
1031
- */
1032
- loc: () => string | ScriptFailure
1033
-
1034
- /**
1035
- * **LOWSEC**
1036
- */
1037
- xfer_upgrade_to: ((args: {
1038
- i: number | number[]
1039
- to: string
1040
- memo?: string
1041
- }) => ScriptResponse) & ((args: {
1042
- sn: string | string[]
1043
- to: string
1044
- memo?: string
1045
- }) => ScriptResponse)
618
+ /** **LOWSEC** */ access_log: {
619
+ (args?: { user?: string, run_id?: string, is_script?: true, count?: number, start?: number }):
620
+ { t: Date, u: string | undefined, r: string | undefined, msg: string }[] | ScriptFailure
621
+
622
+ (args: { user?: string, run_id?: string, is_script: false, count?: number, start?: number }): string[]
623
+ }
624
+
625
+ /** **LOWSEC** */ cull: (args: { i: number | number[], confirm: true }) => ScriptResponse
626
+
627
+ /** **LOWSEC** */ loc: () => string | ScriptFailure
628
+
629
+ /** **LOWSEC** */ xfer_upgrade_to: {
630
+ (args: { i: number | number[], to: string, memo?: string }): ScriptResponse
631
+ (args: { sn: string | string[], to: string, memo?: string }): ScriptResponse
632
+ }
1046
633
  }
1047
634
  }
1048
635
 
1049
636
  type Nullsec = Lowsec & PlayerNullsec & {
1050
637
  corps: {
1051
- /**
1052
- * **NULLSEC**
1053
- */
1054
- create: (args: {
1055
- name: string
1056
- confirm: true
1057
- }) => ScriptResponse
638
+ /** **NULLSEC** */ create: (args: { name: string, confirm: true }) => ScriptResponse
639
+ /** **NULLSEC** */ hire: (args: { name: string }) => ScriptResponse
1058
640
 
1059
- /**
1060
- * **NULLSEC**
1061
- */
1062
- hire: (args: { name: string }) => ScriptResponse
1063
-
1064
- /**
1065
- * **NULLSEC**
1066
- */
1067
- manage: ((args: { command: "list" }) => {
1068
- name: string
1069
- is_admin: boolean
1070
- }[] | ScriptFailure) & ((args: {
1071
- command: "demote" | "promote"
1072
- name: string
1073
- } | {
1074
- command: "fire"
1075
- name: string
1076
- confirm: true
1077
- }) => ScriptResponse)
641
+ /** **NULLSEC** */ manage: {
642
+ (args: { command: "list" }): { name: string, is_admin: boolean }[] | ScriptFailure
1078
643
 
1079
- /**
1080
- * **NULLSEC**
1081
- */
1082
- offers: (() => {
1083
- offers: string[]
1084
- msg: string
1085
- } | ScriptSuccess<{
1086
- msg: string
1087
- current_corp: string | null
1088
- }>) & ((args: { accept: string }) => ScriptResponse)
1089
-
1090
- /**
1091
- * **NULLSEC**
1092
- */
1093
- quit: (args: { confirm: true }) => ScriptResponse
1094
-
1095
- /**
1096
- * **NULLSEC**
1097
- */
1098
- top: () => CorpsTop | {
1099
- top: CorpsTop
1100
- active: {
1101
- name: string
1102
- worth: string
1103
- }
644
+ (args: { command: "demote" | "promote", name: string } | { command: "fire", name: string, confirm: true }):
645
+ ScriptResponse
1104
646
  }
1105
- }
1106
647
 
1107
- sys: {
1108
- /**
1109
- * **NULLSEC**
1110
- */
1111
- breach: (args: { confirm: true }) => ScriptResponse
1112
- }
648
+ /** **NULLSEC** */ offers: {
649
+ (): { offers: string[], msg: string } | ScriptSuccess<{ msg: string, current_corp: string | null }>
650
+ (args: { accept: string }): ScriptResponse
651
+ }
1113
652
 
1114
- trust: {
1115
- /**
1116
- * **NULLSEC**
1117
- */
1118
- me: () => string
653
+ /** **NULLSEC** */ quit: (args: { confirm: true }) => ScriptResponse
654
+ /** **NULLSEC** */ top: () => CorpsTop | { top: CorpsTop, active: { name: string, worth: string } }
1119
655
  }
1120
656
 
657
+ sys: { /** **NULLSEC** */ breach: (args: { confirm: true }) => ScriptResponse }
658
+ trust: { /** **NULLSEC** */ me: () => string }
659
+
1121
660
  users: {
1122
- /**
1123
- * **NULLSEC**
1124
- */
1125
- config: ((args: {
1126
- list: false
1127
- is_script?: true | null
1128
- avatar?: string | null
1129
- user_age?: boolean | null
1130
- account_age?: boolean | null
1131
- bio?: string | null
1132
- title?: string | null
1133
- pronouns?: string | null
1134
- corp?: boolean | null
1135
- alt_of?: string | null
1136
- badges?: string[] | null
1137
- }) => ScriptResponse) & ((args: {
1138
- list: true
1139
- is_script?: true
1140
- avatar?: string | null
1141
- user_age?: boolean | null
1142
- account_age?: boolean | null
1143
- bio?: string | null
1144
- title?: string | null
1145
- pronouns?: string | null
1146
- corp?: boolean | null
1147
- alt_of?: string | null
1148
- badges?: string[] | null
1149
- }) => {
1150
- avatar: string | null
1151
- user_age?: boolean
1152
- account_age?: boolean
1153
- bio: string | null
1154
- title: string | null
1155
- pronouns: string
1156
- corp?: boolean
1157
- alt_of: string | null
1158
- badges: string[]
1159
- }) & ((args: {
1160
- list: true
1161
- is_script: false
1162
- avatar?: string | null
1163
- user_age?: boolean | null
1164
- account_age?: boolean | null
1165
- bio?: string | null
1166
- title?: string | null
1167
- pronouns?: string | null
1168
- corp?: boolean | null
1169
- alt_of?: string | null
1170
- badges?: string[] | null
1171
- }) => string)
661
+ /** **NULLSEC** */ config: {
662
+ (args: {
663
+ list: false
664
+ is_script?: true | null
665
+ avatar?: string | null
666
+ user_age?: boolean | null
667
+ account_age?: boolean | null
668
+ bio?: string | null
669
+ title?: string | null
670
+ pronouns?: string | null
671
+ corp?: boolean | null
672
+ alt_of?: string | null
673
+ badges?: string[] | null
674
+ }): ScriptResponse
675
+
676
+ (args: {
677
+ list: true
678
+ is_script?: true
679
+ avatar?: string | null
680
+ user_age?: boolean | null
681
+ account_age?: boolean | null
682
+ bio?: string | null
683
+ title?: string | null
684
+ pronouns?: string | null
685
+ corp?: boolean | null
686
+ alt_of?: string | null
687
+ badges?: string[] | null
688
+ }): {
689
+ avatar: string | null
690
+ user_age?: boolean
691
+ account_age?: boolean
692
+ bio: string | null
693
+ title: string | null
694
+ pronouns: string
695
+ corp?: boolean
696
+ alt_of: string | null
697
+ badges: string[]
698
+ }
699
+
700
+ (args: {
701
+ list: true
702
+ is_script: false
703
+ avatar?: string | null
704
+ user_age?: boolean | null
705
+ account_age?: boolean | null
706
+ bio?: string | null
707
+ title?: string | null
708
+ pronouns?: string | null
709
+ corp?: boolean | null
710
+ alt_of?: string | null
711
+ badges?: string[] | null
712
+ }): string
713
+ }
1172
714
  }
1173
715
  }
1174
716
 
1175
- type MongoValue = string | number | boolean | Date | MongoValue[] | {
1176
- [key: string]: MongoValue
1177
- } | null
717
+ type MongoValue = string | number | boolean | Date | MongoValue[] | { [key: string]: MongoValue } | null
1178
718
 
1179
- type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | {
1180
- [key: string]: MongoCommandValue
1181
- } | null | undefined
1182
-
1183
- type Query = {
1184
- [key: string]: MongoValue | Query
1185
- } & {
1186
- _id?: Id
1187
- $in?: MongoValue[]
1188
- }
719
+ type MongoCommandValue = string | number | boolean | Date | MongoCommandValue[] | { [key: string]: MongoCommandValue } |
720
+ null | undefined
1189
721
 
722
+ type Query = { [key: string]: MongoValue | Query } & { _id?: Id, $in?: MongoValue[] }
1190
723
  type Projection = Record<string, boolean | 0 | 1>
1191
724
 
1192
- type MongoCommand = MongoCommandValue & Partial<{
1193
- $set: Record<string, MongoCommandValue>
1194
- $push: Record<string, MongoCommandValue>
1195
- $unset: Record<string, "">
1196
- }>
725
+ type MongoCommand = MongoCommandValue & Partial<
726
+ { $set: Record<string, MongoCommandValue>, $push: Record<string, MongoCommandValue>, $unset: Record<string, ""> }
727
+ >
1197
728
 
1198
729
  type Id = string | number | boolean | Date | Record<string, MongoValue>
1199
-
1200
- type MongoDocument = {
1201
- [key: string]: MongoValue
1202
- _id: Id
1203
- }
1204
-
1205
- type SortOrder = {
1206
- [key: string]: 1 | -1 | SortOrder
1207
- }
730
+ type MongoDocument = { [key: string]: MongoValue, _id: Id }
731
+ type SortOrder = { [key: string]: 1 | -1 | SortOrder }
1208
732
 
1209
733
  type Cursor = {
1210
- /**
1211
- * Returns the first document that satisfies the query.
1212
- */
1213
- first: () => MongoDocument | null
1214
-
1215
- /**
1216
- * Returns an array of documents that satisfy the query.
1217
- */
1218
- array: () => MongoDocument[]
1219
-
1220
- /**
1221
- * Returns the number of documents that match the query.
1222
- */
1223
- count: () => number
1224
-
1225
- /**
1226
- * Returns the first document that satisfies the query.
1227
- * Also makes cursor unusable.
1228
- */
734
+ /** Returns the first document that satisfies the query. */ first: () => MongoDocument | null
735
+ /** Returns an array of documents that satisfy the query. */ array: () => MongoDocument[]
736
+ /** Returns the number of documents that match the query. */ count: () => number
737
+
738
+ /** Returns the first document that satisfies the query. Also makes cursor unusable. */
1229
739
  first_and_close: () => MongoDocument
1230
740
 
1231
- /**
1232
- * Returns an array of documents that satisfy the query.
1233
- * Also makes cursor unusable.
1234
- */
741
+ /** Returns an array of documents that satisfy the query. Also makes cursor unusable. */
1235
742
  array_and_close: () => MongoDocument[]
1236
743
 
1237
- /**
1238
- * Returns the number of documents that match the query.
1239
- * Also makes cursor unusable.
1240
- */
744
+ /** Returns the number of documents that match the query. Also makes cursor unusable. */
1241
745
  count_and_close: () => number
1242
746
 
1243
- /**
1244
- * Run callback on each document that satisfied the query.
1245
- *
1246
- * @param funct callback function
1247
- */
1248
- each: (funct: (document: MongoDocument) => void) => null
1249
-
1250
- /**
1251
- * Returns a new cursor with documents sorted as specified.
1252
- * A value of 1 sorts the property ascending, and -1 descending.
1253
- *
1254
- * @param order the way the documents are to be sorted
1255
- */
747
+ /** Run `callback` on each document that satisfied the query. */
748
+ each: (callback: (document: MongoDocument) => void) => null
749
+
750
+ /** Returns a new cursor with documents sorted as specified.
751
+ * A value of 1 sorts the property ascending, and -1 descending.
752
+ * @param order The way the documents are to be sorted. */
1256
753
  sort: (order?: SortOrder) => Cursor
1257
754
 
1258
- /**
1259
- * Returns a new cursor without the first number of documents.
1260
- *
1261
- * @param count number of documents to skip
1262
- */
755
+ /** Returns a new cursor without the first number of documents.
756
+ * @param count Number of documents to skip. */
1263
757
  skip: (count: number) => Cursor
1264
758
 
1265
- /**
1266
- * Returns a new cursor limited to a number of documents as specified
1267
- *
1268
- * @param count number of documents
1269
- */
759
+ /** Returns a new cursor limited to a number of documents as specified.
760
+ * @param count Number of documents. */
1270
761
  limit: (count: number) => Cursor
1271
762
 
1272
- /**
1273
- * @param key they key of the documents
1274
- */
1275
- distinct: ((key: string) => MongoValue[]) & ((key: "_id") => Id[])
1276
-
1277
- /**
1278
- * Makes cursor unusable.
1279
- */
1280
- close: () => null
1281
-
763
+ /** @param key The key of the documents. */ distinct: ((key: string) => MongoValue[]) & ((key: "_id") => Id[])
764
+ /** Make cursor unusable. */ close: () => null
1282
765
  NumberLong: (number: number) => number
1283
766
  ObjectId: () => any
1284
767
  }
1285
768
 
1286
769
  type CLIContext = {
1287
- /**
1288
- * The name of the user who is calling the script (i.e. n00b)
1289
- */
1290
- caller: string
1291
-
1292
- /**
1293
- * The name of this script
1294
- */
1295
- this_script: string
1296
-
1297
- /**
1298
- * the number of columns in the caller’s terminal, if reported by the client
1299
- */
1300
- cols: number
1301
-
1302
- /**
1303
- * the number of rows in the caller’s terminal, if reported by the client
1304
- */
1305
- rows: number
1306
-
1307
- /**
1308
- * The name of the script that directly called this script, or null if called on the command line or as a scriptor
1309
- */
1310
- calling_script: null
770
+ /** The name of the user who is calling the script. */ caller: string
771
+ /** The name of this script. */ this_script: string
772
+ /** The number of columns in the caller’s terminal. */ cols: number
773
+ /** The number of rows in the caller’s terminal. */ rows: number
774
+
775
+ /** The name of the script that directly called this script, or null if called on the command line or as a
776
+ * scriptor. */ calling_script: null
1311
777
  }
1312
778
 
1313
779
  type SubscriptContext = Replace<CLIContext, {
1314
- /**
1315
- * The name of the script that directly called this script, or null if called on the command line or as a scriptor
1316
- */
780
+ /** The name of the script that directly called this script, or null if called on the command line or as a scriptor.
781
+ */
1317
782
  calling_script: string
1318
783
  }>
1319
784
 
1320
- type ScriptorContext = CLIContext & {
1321
- /**
1322
- * true if the script is being run as a scriptor, otherwise falsey (not present currently, but I wouldn’t rely on that)
1323
- */
1324
- is_scriptor: true
1325
- }
1326
-
1327
- type BrainContext = CLIContext & {
1328
- /**
1329
- * true if the script is being run via a bot brain
1330
- */
1331
- is_brain: true
1332
- }
1333
-
785
+ type ScriptorContext = CLIContext & { /** Whether the script is being run as a scriptor. */ is_scriptor: true }
786
+ type BrainContext = CLIContext & { /** Whether the script is being run via a bot brain. */ is_brain: true }
1334
787
  type Context = CLIContext | SubscriptContext | ScriptorContext | BrainContext
1335
788
 
1336
- /**
1337
- * Subscript space that can call FULLSEC scripts.
1338
- */
1339
- declare const $fs: Fullsec
789
+ /** Subscript space that can call FULLSEC scripts. */ declare const $fs: Fullsec
1340
790
 
1341
- /**
1342
- * Subscript space that can call HIGHSEC and above scripts.
1343
- * Makes your script HIGHSEC (overrides FULLSEC).
1344
- */
791
+ /** Subscript space that can call HIGHSEC and above scripts. Makes your script HIGHSEC (overrides FULLSEC). */
1345
792
  declare const $hs: Highsec
1346
793
 
1347
- /**
1348
- * Subscript space that can call MIDSEC and above scripts.
1349
- * Makes your script MIDSEC (overrides higher security levels).
1350
- */
794
+ /** Subscript space that can call MIDSEC and above scripts. Makes your script MIDSEC (overrides higher security levels).
795
+ */
1351
796
  declare const $ms: Midsec
1352
797
 
1353
- /**
1354
- * Subscript space that can call LOWSEC and above scripts.
1355
- * Makes your script LOWSEC (overrides higher security levels).
1356
- */
798
+ /** Subscript space that can call LOWSEC and above scripts. Makes your script LOWSEC (overrides higher security levels).
799
+ */
1357
800
  declare const $ls: Lowsec
1358
801
 
1359
- /**
1360
- * Subscript space that can call any script.
1361
- * Makes your script NULLSEC (overrides higher security levels).
1362
- */
802
+ /** Subscript space that can call any script. Makes your script NULLSEC (overrides higher security levels). */
1363
803
  declare const $ns: Nullsec
1364
804
 
1365
- /**
1366
- * Subscript space that can call FULLSEC scripts.
1367
- */
1368
- declare const $4s: typeof $fs
805
+ /** Subscript space that can call FULLSEC scripts. */ declare const $4s: typeof $fs
1369
806
 
1370
- /**
1371
- * Subscript space that can call HIGHSEC and above scripts.
1372
- * Makes your script HIGHSEC (overrides FULLSEC).
1373
- */
807
+ /** Subscript space that can call HIGHSEC and above scripts. Makes your script HIGHSEC (overrides FULLSEC). */
1374
808
  declare const $3s: typeof $hs
1375
809
 
1376
- /**
1377
- * Subscript space that can call MIDSEC and above scripts.
1378
- * Makes your script MIDSEC (overrides higher security levels).
1379
- */
810
+ /** Subscript space that can call MIDSEC and above scripts. Makes your script MIDSEC (overrides higher security levels).
811
+ */
1380
812
  declare const $2s: typeof $ms
1381
813
 
1382
- /**
1383
- * Subscript space that can call LOWSEC and above scripts.
1384
- * Makes your script LOWSEC (overrides higher security levels).
1385
- */
814
+ /** Subscript space that can call LOWSEC and above scripts. Makes your script LOWSEC (overrides higher security levels).
815
+ */
1386
816
  declare const $1s: typeof $ls
1387
817
 
1388
- /**
1389
- * Subscript space that can call any script.
1390
- * Makes your script NULLSEC (overrides higher security levels).
1391
- */
818
+ /** Subscript space that can call any script. Makes your script NULLSEC (overrides higher security levels). */
1392
819
  declare const $0s: typeof $ns
1393
820
 
1394
- /**
1395
- * Subscript space that can call any script.
1396
- * Uses seclevel provided in comment before script (defaults to NULLSEC)
1397
- *
1398
- * ```js
1399
- * // @seclevel MIDSEC
1400
- * export function script() {
1401
- * $s.foo.bar() // will be converted to #ms.foo.bar()
1402
- * }
1403
- * ```
1404
- */
821
+ /** Subscript space that can call any script. Uses seclevel provided in comment before script (defaults to NULLSEC)
822
+ * @example
823
+ * // @ seclevel MIDSEC
824
+ * // remove the space betwen "@" and "s", there's only a space because otherwise vscode breaks
825
+ * export function script() {
826
+ * $s.foo.bar() // will be converted to #ms.foo.bar()
827
+ * } */
1405
828
  declare const $s: Nullsec
1406
829
 
1407
830
  declare const $db: {
1408
- /**
1409
- * Insert
1410
- *
1411
- * Inserts a document or documents into a collection.
1412
- * @param documents A document or array of documents to insert into the collection.
1413
- */
831
+ /** Insert a document or documents into a collection.
832
+ * @param documents A document or array of documents to insert into the collection. */
1414
833
  i: (documents: object | object[]) => {
1415
834
  ok: 1
1416
835
  n: number
1417
- opTime: {
1418
- ts: "Undefined Conversion"
1419
- t: number
1420
- }
836
+ opTime: { ts: "Undefined Conversion", t: number }
1421
837
  electionId: "Undefined Conversion"
1422
838
  operationTime: "Undefined Conversion"
1423
839
  $clusterTime: {
1424
840
  clusterTime: "Undefined Conversion"
1425
- signature: {
1426
- hash: "Undefined Conversion"
1427
- keyId: "Undefined Conversion"
1428
- }
841
+ signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
1429
842
  }
1430
843
  }
1431
844
 
1432
- /**
1433
- * Remove
1434
- *
1435
- * Removes documents from a collection.
1436
- * @param query Specifies deletion criteria using query operators.
1437
- */
845
+ /** Remove documents from a collection.
846
+ * @param query Specifies deletion criteria using query operators. */
1438
847
  r: (query: Query) => {
1439
848
  ok: 0 | 1
1440
849
  n: number
1441
- opTime: {
1442
- ts: "Undefined Conversion"
1443
- t: number
1444
- }
850
+ opTime: { ts: "Undefined Conversion", t: number }
1445
851
  electionId: "Undefined Conversion"
1446
852
  operationTime: "Undefined Conversion"
1447
853
  $clusterTime: {
1448
854
  clusterTime: "Undefined Conversion"
1449
- signature: {
1450
- hash: "Undefined Conversion"
1451
- keyId: "Undefined Conversion"
1452
- }
855
+ signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
1453
856
  }
1454
857
  }
1455
858
 
1456
- /**
1457
- * Find
1458
- *
1459
- * Selects documents in a collection or view and returns a cursor to the selected documents.
1460
- * @param query Specifies deletion criteria using query operators.
1461
- * @param projection Specifies the fields to return in the documents that match the query filter.
1462
- */
859
+ /** Find documents in a collection or view and returns a cursor to the selected documents.
860
+ * @param query Specifies deletion criteria using query operators.
861
+ * @param projection Specifies the fields to return in the documents that match the query filter. */
1463
862
  f: (query?: Query, projection?: Projection) => Cursor
1464
863
 
1465
- /**
1466
- * Update
1467
- *
1468
- * Modifies an existing document or documents in a collection.
1469
- * @param query Specifies deletion criteria using query operators.
1470
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1471
- */
864
+ /** Update an existing documents in a collection.
865
+ * @param query Specifies deletion criteria using query operators.
866
+ * @param command The modifications to apply.
867
+ * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
1472
868
  u: (query: Query | Query[], command: MongoCommand) => {
1473
869
  ok: 0 | 1
1474
870
  nModified: number
1475
871
  n: number
1476
- opTime: {
1477
- ts: "Undefined Conversion"
1478
- t: number
1479
- }
872
+ opTime: { ts: "Undefined Conversion", t: number }
1480
873
  electionId: "Undefined Conversion"
1481
874
  operationTime: "Undefined Conversion"
1482
875
  $clusterTime: {
1483
876
  clusterTime: "Undefined Conversion"
1484
- signature: {
1485
- hash: "Undefined Conversion"
1486
- keyId: "Undefined Conversion"
1487
- }
877
+ signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
1488
878
  }
1489
879
  }
1490
880
 
1491
- /**
1492
- * Update 1
1493
- *
1494
- * Updates a single document within the collection based on the filter.
1495
- * @param query Specifies deletion criteria using query operators.
1496
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1497
- */
881
+ /** Updates one document within the collection based on the filter.
882
+ * @param query Specifies deletion criteria using query operators.
883
+ * @param command The modifications to apply.
884
+ * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
1498
885
  u1: (query: Query | Query[], command: MongoCommand) => {
1499
886
  ok: 0 | 1
1500
887
  nModified: number
@@ -1514,144 +901,107 @@ declare const $db: {
1514
901
  }
1515
902
  }
1516
903
 
1517
- /**
1518
- * Upsert
1519
- *
1520
- * 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.
1521
- * The `$setOnInsert` operator is useful to set defaults.
1522
- * @param query Specifies deletion criteria using query operators.
1523
- * @param command The modifications to apply. {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters}
1524
- */
904
+ /** Update or insert or insert document.
905
+ * Same as Update, but if no documents match the query, one document will be inserted based on the properties in
906
+ * both the query and the command.
907
+ * The `$setOnInsert` operator is useful to set defaults.
908
+ * @param query Specifies deletion criteria using query operators.
909
+ * @param command The modifications to apply.
910
+ * {@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#parameters} */
1525
911
  us: (query: Query | Query[], command: MongoCommand) => {
1526
912
  ok: 0 | 1
1527
913
  nModified: number
1528
914
  n: number
1529
- opTime: {
1530
- ts: "Undefined Conversion"
1531
- t: number
1532
- }
915
+ opTime: { ts: "Undefined Conversion", t: number }
1533
916
  electionId: "Undefined Conversion"
1534
917
  operationTime: "Undefined Conversion"
1535
918
  $clusterTime: {
1536
919
  clusterTime: "Undefined Conversion"
1537
- signature: {
1538
- hash: "Undefined Conversion"
1539
- keyId: "Undefined Conversion"
1540
- }
920
+ signature: { hash: "Undefined Conversion", keyId: "Undefined Conversion" }
1541
921
  }
1542
922
  }
1543
923
  }
1544
924
 
1545
- /**
1546
- * Debug Log
1547
- *
1548
- * 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.
1549
- * This lets you use `$D()` like `console.log()`.
1550
- *
1551
- * `$D()` in scripts not owned by you are not shown but the `return` value always is.
1552
- *
1553
- * `$D()` returns the first argument so `$D("Hello, World!") evaluates to `"Hello, World!"` as if the `$D` text wasn't there.
1554
- *
1555
- * `$D()`’d items are returned even if the script times out or errors.
1556
- */
925
+ /** Debug Log.
926
+ *
927
+ * If `$D()` is called in a script you own, the `return` value of the top level script is suppressed and instead an
928
+ * array of every `$D()`’d entry is printed.
929
+ * This lets you use `$D()` like `console.log()`.
930
+ *
931
+ * `$D()` in scripts not owned by you are not shown but the `return` value always is.
932
+ *
933
+ * `$D()` returns the first argument so `$D("Hello, World!") evaluates to `"Hello, World!"` as if the `$D` text wasn't
934
+ * there.
935
+ *
936
+ * `$D()`’d items are returned even if the script times out or errors. */
1557
937
  declare function $D<T>(args: T): T
1558
938
 
1559
- /**
1560
- * Function Multi-Call Lock
1561
- *
1562
- * This is used by escrow to ensure that it is only used once in script execution.
1563
- *
1564
- * The first time (per-script) `$FMCL` is encountered, it returns `undefined`, every other time it `return`s `true`.
1565
- *
1566
- * @example
1567
- * if ($FMCL)
1568
- * return { ok: false, msg: "this script can only be used once per script execution" }
1569
- *
1570
- * // all code here will only run once
1571
- */
939
+ /** Function Multi-Call Lock.
940
+ *
941
+ * This is used by escrow to ensure that it is only used once in script execution.
942
+ *
943
+ * The first time (per-script) `$FMCL` is encountered, it returns `undefined`, every other time it `return`s `true`.
944
+ *
945
+ * @example
946
+ * if ($FMCL)
947
+ * return { ok: false, msg: "This script can only be used once per script execution." }
948
+ *
949
+ * // all code here will only run once */
1572
950
  declare const $FMCL: undefined | true
1573
951
 
1574
- /**
1575
- * Global
1576
- *
1577
- * A mutable, per-script global object.
1578
- * $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.
1579
- *
1580
- * @example
1581
- * if (!$G.dbCache)
1582
- * $G.dbCache = $db.f({ whatever: true }).first()
1583
- */
952
+ /** Per-script mutable "global" persistent object that is discarded at the end of top level script execution.
953
+ *
954
+ * `$G` persists between script calls until the end of the main script run making it useful for caching db entries when
955
+ * your script is a subscript.
956
+ * @example
957
+ * if (!$G.dbCache)
958
+ * $G.dbCache = $db.f({ whatever: true }).first() */
1584
959
  declare const $G: any
1585
960
 
1586
- /**
1587
- * This contains a JS timestamp (not Date) set immediately before your code begins running.
1588
- *
1589
- * @example
1590
- * Date.now() - _START // milliseconds left of run time
1591
- */
961
+ /** This contains a JS timestamp (not Date) set immediately before your code begins running.
962
+ * @example
963
+ * $D(Date.now() - _START) // milliseconds left of run time
964
+ */
1592
965
  declare const _START: number
1593
966
 
1594
- /**
1595
- * This contains a JS timestamp (not Date) set immediately before your code begins running.
1596
- *
1597
- * @example
1598
- * Date.now() - _ST // milliseconds left of run time
1599
- */
967
+ /** This contains a JS timestamp (not Date) set immediately before your code begins running.
968
+ * @example
969
+ * $D(Date.now() - _ST) // milliseconds left of run time */
1600
970
  declare const _ST: typeof _START
1601
971
 
1602
- /**
1603
- * JavaScript timestamp for the end of the script run (`_START + _TIMEOUT`).
1604
- */
1605
- declare const _END: number
972
+ /** JavaScript timestamp for the end of the script run (`_START + _TIMEOUT`). */ declare const _END: number
1606
973
 
1607
- /**
1608
- * The number of milliseconds a script can run for.
1609
- * Normally `5000` though it has been known to change.
1610
- */
974
+ /** The number of milliseconds a script can run for. Normally `5000` though it has been known to change. */
1611
975
  declare const _TIMEOUT: number
1612
976
 
1613
- /**
1614
- * The number of milliseconds a script can run for.
1615
- * Normally `5000` though it has been known to change.
1616
- */
977
+ /** The number of milliseconds a script can run for. Normally `5000` though it has been known to change. */
1617
978
  declare const _TO: typeof _TIMEOUT
1618
979
 
1619
- /** The source code of this script as a string. */
1620
- declare const _SOURCE: string
1621
-
1622
- /** A unix timestamp of the date this script was built. */
1623
- declare const _BUILD_DATE: number
980
+ /** The source code of this script as a string. */ declare const _SOURCE: string
981
+ /** A unix timestamp of the date this script was built. */ declare const _BUILD_DATE: number
1624
982
 
1625
- /**
1626
- * The user this script has been uploaded to.
1627
- *
1628
- * Shorter alternative to `context.this_script.split(".")[0].
1629
- *
1630
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1631
- */
983
+ /** The user this script has been uploaded to.
984
+ *
985
+ * Shorter alternative to `context.this_script.split(".")[0].
986
+ *
987
+ * In rare cases where it's not known at build time, it's `"UNKNOWN"`. */
1632
988
  declare const _SCRIPT_USER: string
1633
989
 
1634
- /**
1635
- * The name of this script excluding the user and `.`.
1636
- *
1637
- * e.g. in the script `foo.bar`, `_SCRIPT_NAME` is `bar`.
1638
- *
1639
- * Shorter alternative to `context.this_script.split(".")[1].
1640
- *
1641
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1642
- */
990
+ /** The name of this script excluding the user and `.`.
991
+ *
992
+ * e.g. in the script `foo.bar`, `_SCRIPT_NAME` is `bar`.
993
+ *
994
+ * Shorter alternative to `context.this_script.split(".")[1].
995
+ *
996
+ * In rare cases where it's not known at build time, it's `"UNKNOWN"`. */
1643
997
  declare const _SCRIPT_NAME: string
1644
998
 
1645
- /**
1646
- * The full name of this script equivilent to `context.this_script` but should use less characters.
1647
- *
1648
- * In rare cases where it's not known at build time, it's `"UNKNOWN"`.
1649
- */
999
+ /** The full name of this script equivilent to `context.this_script` but should use less characters.
1000
+ *
1001
+ * In rare cases where it's not known at build time, it's `"UNKNOWN"`. */
1650
1002
  declare const _FULL_SCRIPT_NAME: string
1651
1003
 
1652
- /**
1653
- * The seclevel of this script as a number.
1654
- *
1655
- * In rare cases where it's not known at build time, it's `-1`.
1656
- */
1004
+ /** The seclevel of this script as a number.
1005
+ *
1006
+ * In rare cases where it's not known at build time, it's `-1`. */
1657
1007
  declare const _SECLEVEL: -1 | 0 | 1 | 2 | 3 | 4