@spacemolt/lib 14.0.0 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -84,6 +84,30 @@ account.credits, account.ship, account.location, account.cargo, account.skills;
84
84
  account.on('mining_yield', (y) => console.log(y.quantity, y.resource_id));
85
85
  ```
86
86
 
87
+ Push payloads are typed. Most come from the server's published schema; the `ok`
88
+ and `fleet` families are hand-written unions, because the server publishes no
89
+ schema for those two. `ok` splits its discriminator: most variants key on
90
+ `action`, seven key on `type`. A bare `p.action` therefore does not compile on
91
+ `OkPush` — guard with `'action' in p`, or narrow to the exported `OkActionPush`
92
+ / `OkTypePush` halves. `FleetPush` has one key and needs no guard:
93
+
94
+ ```ts
95
+ account.on('ok', (p) => {
96
+ if ('action' in p && p.action === 'fleet_dock') p.base_id; // canonical base id
97
+ if ('type' in p && p.type === 'emergency_warp_stabilizer_activated') p.hull;
98
+ });
99
+ account.on('fleet', (p) => {
100
+ if (p.action === 'fleet_invite') p.fleet_id;
101
+ });
102
+ ```
103
+
104
+ Both unions are closed and were derived from a specific server build. A frame
105
+ the server added since still arrives at your `on('ok')` handler — nothing
106
+ validates the payload against these types — as a value matching no member, so
107
+ give your `switch` a real default rather than a `never` assertion.
108
+ `OK_PUSH_ACTIONS`, `OK_PUSH_TYPES` and `FLEET_PUSH_ACTIONS` are exported with
109
+ their derived literal types if you want to enumerate.
110
+
87
111
  ## Gotchas worth knowing up front
88
112
 
89
113
  - **Preconditions are real.** A new account starts docked; `mine` needs an
package/dist/account.d.ts CHANGED
@@ -14,6 +14,7 @@ import { type Commands } from './generated/commands.gen.js';
14
14
  import type { AuthCredentials } from './auth/credentials.js';
15
15
  import type { LoggedInPayload as LoggedInPayloadSchema, SubscribeMarketResponse, SubscribeObservationResponse } from './generated/openapi/types.gen.js';
16
16
  import type { NotificationPayloads, TypedNotificationType } from './generated/notifications.gen.js';
17
+ import type { FleetPush, OkPush } from './push-frames.js';
17
18
  import { type ConnectionClosedError } from './errors.js';
18
19
  import { type MarketBook } from './state/market.js';
19
20
  import { type ObservationView } from './state/observation.js';
@@ -300,10 +301,14 @@ export declare class Account {
300
301
  send(tool: string, action: string, payload?: Record<string, unknown>, requestId?: string): Promise<QueryResult | MutationResult>;
301
302
  /**
302
303
  * Listen for a specific server push by msg_type. The handler receives the
303
- * typed payload for published notification types, or a loosely-typed object
304
- * for not-yet-typed pushes. Returns an unsubscribe function.
304
+ * typed payload for published notification types, and for the `ok` and
305
+ * `fleet` families from the hand-written unions in `push-frames.ts` (the
306
+ * server publishes no schema for those two). Anything else is a
307
+ * loosely-typed object. Returns an unsubscribe function.
305
308
  */
306
309
  on<K extends TypedNotificationType>(type: K, handler: (payload: NotificationPayloads[K]) => void): () => void;
310
+ on(type: 'ok', handler: (payload: OkPush) => void): () => void;
311
+ on(type: 'fleet', handler: (payload: FleetPush) => void): () => void;
307
312
  on(type: string, handler: (payload: Record<string, unknown>) => void): () => void;
308
313
  /** Listen for every server push frame. Returns an unsubscribe function. */
309
314
  onAny(handler: (frame: RawFrame) => void): () => void;
@@ -313,6 +318,8 @@ export declare class Account {
313
318
  * Buffered, so a slow consumer won't drop frames; `break` unsubscribes.
314
319
  */
315
320
  events<K extends TypedNotificationType>(type: K): AsyncIterableIterator<NotificationPayloads[K]>;
321
+ events(type: 'ok'): AsyncIterableIterator<OkPush>;
322
+ events(type: 'fleet'): AsyncIterableIterator<FleetPush>;
316
323
  events(type: string): AsyncIterableIterator<Record<string, unknown>>;
317
324
  /** Async-iterate every push frame. */
318
325
  anyEvents(): AsyncIterableIterator<RawFrame>;
@@ -380,27 +387,36 @@ export declare class Account {
380
387
  */
381
388
  private checkSubscriptionsAgainstLocation;
382
389
  /**
383
- * Fleet followers do not submit the movement mutation themselves, so their
384
- * arrival is delivered as a plain `ok` push rather than an `action_result`
385
- * carrying a state delta. Bridge the location data present on those pushes
386
- * into the cache. Fleet docking is the one exception: its push only contains
387
- * the station's display name, not the canonical base ID used by `docked_at`,
388
- * so refresh the canonical snapshot instead of caching the wrong identifier.
390
+ * Movement that the state delta does not cover arrives as a plain `ok` push.
391
+ * Bridge its location data into the cache.
392
+ *
393
+ * Two kinds of movement land here. **Transit start** (`travel`/`jump`, and
394
+ * their `fleet_` variants) is never delivered as a delta by design: the
395
+ * server holds one `action_result` back for the arrival so it can settle the
396
+ * mutation on the same `request_id`, and sends this push in the meantime.
397
+ * Everything the departure changed is either on the push or implied by it,
398
+ * so these patch and stop — the one field they cannot carry is `ship.fuel`,
399
+ * which the arrival delta corrects a transit later. **Fleet follower
400
+ * arrival** is the other kind: a follower never submitted the mutation, so
401
+ * on a server that cannot tell their connection speaks v2 there is no delta
402
+ * at all, and only then is a reconcile worth its round trip.
389
403
  *
390
404
  * These pushes carry only the few fields the movement itself changed, so
391
405
  * they go through `patchSection` — unlike a server delta, which always
392
- * carries a complete `location` and is applied with `applyDelta`. Patching
393
- * keeps the rest of the section (system, connections, POI details) intact
394
- * until `reconcileFleetState` refreshes the authoritative snapshot; the
395
- * per-POI fields that the move invalidates are only as stale as that
396
- * round trip.
406
+ * carries a complete `location` and is applied with `applyDelta`.
397
407
  */
398
- private applyFleetMovementPush;
408
+ private applyMovementPush;
399
409
  /**
400
- * Fleet movement pushes omit follower fuel and skill deltas, while docking
401
- * omits the canonical base ID. Reconcile those fields from one authoritative
402
- * snapshot. A newer movement push invalidates an older in-flight query so a
403
- * delayed dock/arrival snapshot cannot move the cache backwards.
410
+ * Refill a fleet follower's location from one authoritative snapshot.
411
+ *
412
+ * An arrival push carries the destination's name and little else, so the
413
+ * system-, POI- and presence-scoped fields it invalidates have nothing to
414
+ * refill them and no formula to derive them. This is the one movement gap a
415
+ * round trip is the only answer to, and only on a server that does not send
416
+ * followers a delta — a current one does, and these branches never run.
417
+ *
418
+ * A newer movement push invalidates an older in-flight query so a delayed
419
+ * snapshot cannot move the cache backwards.
404
420
  */
405
421
  private reconcileFleetState;
406
422
  /** Close the connection deliberately. Suppresses auto-reconnect. */
package/dist/index.d.ts CHANGED
@@ -30,3 +30,11 @@ export type { ToolName, ActionName, ActionDef, ActionParam } from './generated/a
30
30
  export type * from './generated/openapi/types.gen.js';
31
31
  export { TYPED_NOTIFICATION_TYPES } from './generated/notifications.gen.js';
32
32
  export type { NotificationPayloads, TypedNotificationType, } from './generated/notifications.gen.js';
33
+ /**
34
+ * Payload types for the `ok` and `fleet` push families, plus the discriminator
35
+ * lists. Hand-written rather than generated: the server publishes no
36
+ * `Notification_ok` or `Notification_fleet` schema, so codegen has nothing to
37
+ * derive them from. Re-exported wholesale so a variant added to the unions does
38
+ * not also have to be remembered here.
39
+ */
40
+ export * from './push-frames.js';
package/dist/index.js CHANGED
@@ -4189,6 +4189,8 @@ var ARRIVED_IN_NEW_SYSTEM = {
4189
4189
  empire: undefined,
4190
4190
  security_status: undefined
4191
4191
  };
4192
+ var DEPARTED = { ...ARRIVED, poi_id: "", poi_name: "", poi_type: "" };
4193
+ var DEPARTED_SYSTEM = { ...ARRIVED_IN_NEW_SYSTEM, ...DEPARTED, system_id: "", system_name: "" };
4192
4194
  var DEFAULT_URL = "wss://game.spacemolt.com/ws/v2";
4193
4195
  var DEFAULT_CONNECT_TIMEOUT_MS = 15000;
4194
4196
  var DEFAULT_MUTATION_TIMEOUT_MS = 600000;
@@ -4601,25 +4603,26 @@ class Account {
4601
4603
  this.subscribedObservationPoiId = undefined;
4602
4604
  }
4603
4605
  }
4604
- applyFleetMovementPush(frame) {
4606
+ applyMovementPush(frame) {
4605
4607
  if (frame.type !== "ok" || !isRecord(frame.payload) || typeof frame.payload.action !== "string")
4606
4608
  return;
4607
4609
  const payload = frame.payload;
4608
4610
  let changed = [];
4609
4611
  let reconcile = false;
4610
4612
  switch (payload.action) {
4613
+ case "jump":
4611
4614
  case "fleet_jump": {
4612
4615
  if (typeof payload.destination !== "string" || typeof payload.arrival_tick !== "number") {
4613
4616
  this.warnMalformedFrame(frame);
4614
4617
  return;
4615
4618
  }
4616
4619
  changed = this.cache.patchSection("location", {
4620
+ ...DEPARTED_SYSTEM,
4617
4621
  in_transit: true,
4618
4622
  transit_arrival_tick: payload.arrival_tick,
4619
4623
  transit_dest_system_id: payload.destination,
4620
4624
  transit_type: "jump"
4621
4625
  });
4622
- reconcile = true;
4623
4626
  break;
4624
4627
  }
4625
4628
  case "jumped":
@@ -4637,18 +4640,19 @@ class Account {
4637
4640
  reconcile = true;
4638
4641
  break;
4639
4642
  }
4643
+ case "travel":
4640
4644
  case "fleet_travel": {
4641
4645
  if (typeof payload.destination !== "string" || typeof payload.arrival_tick !== "number") {
4642
4646
  this.warnMalformedFrame(frame);
4643
4647
  return;
4644
4648
  }
4645
4649
  changed = this.cache.patchSection("location", {
4650
+ ...DEPARTED,
4646
4651
  in_transit: true,
4647
4652
  transit_arrival_tick: payload.arrival_tick,
4648
4653
  transit_dest_poi_id: payload.destination,
4649
4654
  transit_type: "travel"
4650
4655
  });
4651
- reconcile = true;
4652
4656
  break;
4653
4657
  }
4654
4658
  case "arrived": {
@@ -4668,7 +4672,11 @@ class Account {
4668
4672
  changed = this.cache.patchSection("location", { docked_at: null });
4669
4673
  break;
4670
4674
  case "fleet_dock":
4671
- reconcile = true;
4675
+ if (typeof payload.base_id === "string") {
4676
+ changed = this.cache.patchSection("location", { docked_at: payload.base_id });
4677
+ } else {
4678
+ reconcile = true;
4679
+ }
4672
4680
  break;
4673
4681
  default:
4674
4682
  return;
@@ -4824,7 +4832,9 @@ class Account {
4824
4832
  this.emitStateChange(changed);
4825
4833
  }
4826
4834
  if (!this.correlator.handle(frame)) {
4827
- console.warn(`[spacemolt] action_result for ${frame.request_id ?? "?"} arrived with no matching pending mutation (already timed out?)`);
4835
+ if (frame.request_id) {
4836
+ console.warn(`[spacemolt] action_result for ${frame.request_id} arrived with no matching pending mutation (already timed out?)`);
4837
+ }
4828
4838
  this.emitter.emit(frame);
4829
4839
  }
4830
4840
  return;
@@ -4852,7 +4862,7 @@ class Account {
4852
4862
  return;
4853
4863
  }
4854
4864
  default:
4855
- this.applyFleetMovementPush(frame);
4865
+ this.applyMovementPush(frame);
4856
4866
  this.emitter.emit(frame);
4857
4867
  }
4858
4868
  }
@@ -5523,6 +5533,48 @@ var TYPED_NOTIFICATION_TYPES = [
5523
5533
  "trade_declined",
5524
5534
  "trade_offer_received"
5525
5535
  ];
5536
+ // src/push-frames.ts
5537
+ var OK_PUSH_ACTIONS = [
5538
+ "travel",
5539
+ "jump",
5540
+ "fleet_travel",
5541
+ "fleet_jump",
5542
+ "fleet_dock",
5543
+ "fleet_undock",
5544
+ "passenger_stranded",
5545
+ "mobile_capital_transit",
5546
+ "espionage",
5547
+ "arrived",
5548
+ "jumped",
5549
+ "pathfinder_arrival",
5550
+ "dock",
5551
+ "attack",
5552
+ "pathfinder_jump",
5553
+ "pathfinder_redirect"
5554
+ ];
5555
+ var OK_PUSH_TYPES = [
5556
+ "auto_dock",
5557
+ "auto_undock",
5558
+ "emergency_warp_stabilizer_activated",
5559
+ "passenger_arrivals",
5560
+ "passengers_transferred",
5561
+ "ship_processing",
5562
+ "transit_lounge_departures",
5563
+ "shipment_overdue",
5564
+ "new_forum_post"
5565
+ ];
5566
+ var FLEET_PUSH_ACTIONS = [
5567
+ "fleet_invite",
5568
+ "fleet_member_joined",
5569
+ "fleet_member_left",
5570
+ "fleet_member_kicked",
5571
+ "fleet_kicked",
5572
+ "fleet_disbanded",
5573
+ "fleet_leader_promoted",
5574
+ "fleet_member_died",
5575
+ "fleet_passenger_boarded",
5576
+ "fleet_passenger_disembarked"
5577
+ ];
5526
5578
  export {
5527
5579
  ACTIONS,
5528
5580
  Account,
@@ -5531,10 +5583,13 @@ export {
5531
5583
  ClerkSource,
5532
5584
  ConnectionClosedError,
5533
5585
  EventStream,
5586
+ FLEET_PUSH_ACTIONS,
5534
5587
  GENERATED_SPEC_VERSION,
5535
5588
  MapCache,
5536
5589
  MarketCache,
5537
5590
  MemoryCredentialStore,
5591
+ OK_PUSH_ACTIONS,
5592
+ OK_PUSH_TYPES,
5538
5593
  ObservationCache,
5539
5594
  STATE_SECTIONS,
5540
5595
  Socket,
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Hand-written payload types for the `ok` and `fleet` push frames.
3
+ *
4
+ * Every other push frame is typed from the server's published
5
+ * `Notification_<msg_type>` schema, and the generated `NotificationPayloads`
6
+ * map carries it. These two families publish no schema at all — neither
7
+ * appears in the spec's notification union — so without this file they reach a
8
+ * consumer as `Record<string, unknown>`.
9
+ *
10
+ * They are hand-written rather than published because splitting them into
11
+ * distinct `msg_type`s is the fix, and that breaks any v1 client switching on
12
+ * `type === "ok"`. Until v1 is retired the shapes live here.
13
+ * `tests/push-frames.test.ts` fails the moment the server does publish either
14
+ * schema, which is the signal to delete this file and let codegen take over.
15
+ *
16
+ * **Two discriminators.** Most `ok` variants key on `action`; seven key on
17
+ * `type` instead. That split is the server's, not ours, so a bare `p.action`
18
+ * does not compile on `OkPush` — guard with `'action' in p` first, or narrow to
19
+ * `OkActionPush` / `OkTypePush`. `FleetPush` has a single key and needs no guard.
20
+ *
21
+ * **The unions are closed**, derived from gameserver v0.596.2. A member typed
22
+ * `{ action: string }` to absorb later frames would join every literal's
23
+ * narrowing and make all of them useless. The cost is that a variant the server
24
+ * adds after that build still arrives at your `on('ok')` handler — nothing
25
+ * validates the payload against these types — as a value matching no member. An
26
+ * exhaustive `switch` with a `never` default therefore compiles but is unsafe at
27
+ * runtime; give it a real default branch.
28
+ */
29
+ import type { AttackNpcResponse, AttackPlayerResponse, DockResponse, EspionageResponse, JumpResponse, PathfinderJumpResponse, TravelResponse } from './generated/openapi/types.gen.js';
30
+ /** Human-readable summary, carried by the hand-written variants below. */
31
+ interface PushBase {
32
+ message?: string;
33
+ }
34
+ /** Your own transit started. `applyMovementPush` applies this to the cache. */
35
+ export interface OkTravelStarted extends PushBase {
36
+ action: 'travel';
37
+ /** POI ID being travelled to. */
38
+ destination: string;
39
+ /** Engine tick the arrival lands on. */
40
+ arrival_tick: number;
41
+ }
42
+ /** Your own jump started. `applyMovementPush` applies this to the cache. */
43
+ export interface OkJumpStarted extends PushBase {
44
+ action: 'jump';
45
+ /** System ID being jumped to. */
46
+ destination: string;
47
+ arrival_tick: number;
48
+ /** True when the jump routes through a wormhole rather than a lane. */
49
+ is_wormhole: boolean;
50
+ }
51
+ /** Your fleet leader started an in-system travel and pulled you along. */
52
+ export interface OkFleetTravelStarted extends PushBase {
53
+ action: 'fleet_travel';
54
+ destination: string;
55
+ arrival_tick: number;
56
+ }
57
+ /** Your fleet leader started a jump and pulled you along. */
58
+ export interface OkFleetJumpStarted extends PushBase {
59
+ action: 'fleet_jump';
60
+ destination: string;
61
+ arrival_tick: number;
62
+ }
63
+ /** Your fleet leader docked and took the fleet with them. */
64
+ export interface OkFleetDocked extends PushBase {
65
+ action: 'fleet_dock';
66
+ /** Station display name. */
67
+ base: string;
68
+ /** Canonical base ID — this is what `location.docked_at` holds, not `base`. */
69
+ base_id: string;
70
+ }
71
+ /** Your fleet leader undocked and took the fleet with them. */
72
+ export interface OkFleetUndocked extends PushBase {
73
+ action: 'fleet_undock';
74
+ }
75
+ /**
76
+ * The ship you were riding was destroyed or captured. You are at your home
77
+ * station with no ship. A state delta follows on a v2 socket; `riding` is not a
78
+ * state section, so clear any cached value yourself.
79
+ */
80
+ export interface OkPassengerStranded extends PushBase {
81
+ action: 'passenger_stranded';
82
+ }
83
+ /** The Mobile Capital jumped while you were docked at it, taking you along. */
84
+ export interface OkMobileCapitalTransit extends PushBase {
85
+ action: 'mobile_capital_transit';
86
+ /** System ID the station arrived in. */
87
+ system: string;
88
+ }
89
+ /**
90
+ * An espionage operation you launched is under way (start) or resolved
91
+ * (outcome). The two shapes differ: the start carries `arrival_tick`, the
92
+ * resolution carries `outcome` and `story`. Only the start reaches a v2 socket
93
+ * — the resolution ships as a delta-carrying `action_result` — but both are
94
+ * here because a v1 transport sees both.
95
+ */
96
+ export type OkEspionage = (PushBase & {
97
+ action: 'espionage';
98
+ arrival_tick: number;
99
+ }) | (EspionageResponse & {
100
+ action: 'espionage';
101
+ });
102
+ /**
103
+ * In-system travel completed.
104
+ *
105
+ * v1 transports only. Over `/ws/v2` an arrival is a delta-carrying
106
+ * `action_result`; this plain broadcast is the fallback taken when no delta
107
+ * sections are set. A v2 consumer's `arrived` handler never fires — read
108
+ * `account.location` instead.
109
+ */
110
+ export type OkArrived = TravelResponse & {
111
+ action: 'arrived';
112
+ };
113
+ /**
114
+ * A jump or Pathfinder drift completed. `pathfinder_arrival` is the off-network
115
+ * variant. v1 transports only, for the same reason as `OkArrived`.
116
+ */
117
+ export type OkJumped = JumpResponse;
118
+ /** Docking completed. */
119
+ export type OkDocked = DockResponse & {
120
+ action: 'dock';
121
+ };
122
+ /**
123
+ * An attack resolved. Two shapes share the action and are separated by `kind`:
124
+ * `npc` covers pirates, wildlife, stations and prize hulls; `player` is PvP.
125
+ */
126
+ export type OkAttack = AttackNpcResponse | AttackPlayerResponse;
127
+ /** A Pathfinder off-network jump was plotted, or an in-flight drift replotted. */
128
+ export type OkPathfinderPlot = PathfinderJumpResponse;
129
+ /** The server docked you so a dock-required command could run. */
130
+ export interface OkAutoDock extends PushBase {
131
+ type: 'auto_dock';
132
+ }
133
+ /** The server undocked you so a command needing open space could run. */
134
+ export interface OkAutoUndock extends PushBase {
135
+ type: 'auto_undock';
136
+ }
137
+ /** An Emergency Warp Stabilizer fired at critical hull and warped you home. */
138
+ export interface OkEmergencyWarpStabilizer extends PushBase {
139
+ type: 'emergency_warp_stabilizer_activated';
140
+ /** Home station display name — not a base ID. */
141
+ home_base: string;
142
+ hull: number;
143
+ max_hull: number;
144
+ }
145
+ /** Passengers you were carrying reached their destination. */
146
+ export interface OkPassengerArrivals extends PushBase {
147
+ type: 'passenger_arrivals';
148
+ station: string;
149
+ delivered: number;
150
+ stranded: number;
151
+ fare_collected: number;
152
+ /**
153
+ * Reputation change per counterparty, keyed by empire or stronghold ID. The
154
+ * key is always present, but the value is `null` when the delivery moved no
155
+ * reputation — the common case. Check before iterating.
156
+ */
157
+ reputation_changes: Record<string, number> | null;
158
+ }
159
+ /** Another player moved connecting passengers onto one of your ships. */
160
+ export interface OkPassengersTransferred extends PushBase {
161
+ type: 'passengers_transferred';
162
+ /** ID of your ship the passengers were moved onto. */
163
+ ship_id: string;
164
+ count: number;
165
+ /** Station display name. */
166
+ station: string;
167
+ }
168
+ /** A ship-processing job at a station finished. */
169
+ export interface OkShipProcessing extends PushBase {
170
+ type: 'ship_processing';
171
+ }
172
+ /** Passengers are waiting in a transit lounge you can pick up from. */
173
+ export interface OkTransitLoungeDepartures extends PushBase {
174
+ type: 'transit_lounge_departures';
175
+ station: string;
176
+ base_id: string;
177
+ passengers: number;
178
+ /** Ticks until the soonest departure. */
179
+ soonest_ticks: number;
180
+ }
181
+ /** A shipment you contracted for is past its delivery window. */
182
+ export interface OkShipmentOverdue extends PushBase {
183
+ type: 'shipment_overdue';
184
+ shipment_id: string;
185
+ package_id: string;
186
+ /** Base ID the shipment is bound for. */
187
+ destination: string;
188
+ /** Ticks left before the shipment is recovered. */
189
+ recovery_ticks: number;
190
+ late_fee: number;
191
+ }
192
+ /** A new forum thread was posted. Broadcast to every connected player. */
193
+ export interface OkNewForumPost extends PushBase {
194
+ type: 'new_forum_post';
195
+ thread_id: string;
196
+ title: string;
197
+ author: string;
198
+ category: string;
199
+ /** RFC3339 timestamp. */
200
+ timestamp: string;
201
+ is_dev_team: boolean;
202
+ }
203
+ /**
204
+ * A wildlife kill notice, sent when a hunt lands. Carries neither `action` nor
205
+ * `type` — the optional-undefined keys are what let the other members stay
206
+ * narrowable alongside it.
207
+ */
208
+ export interface OkMessageOnly {
209
+ action?: undefined;
210
+ type?: undefined;
211
+ message: string;
212
+ }
213
+ /** You were invited to a fleet. */
214
+ export interface FleetInvite extends PushBase {
215
+ action: 'fleet_invite';
216
+ fleet_id: string;
217
+ leader_name: string;
218
+ leader_id: string;
219
+ /** True for a fleet auto-created to carry an arena challenge. */
220
+ arena_only: boolean;
221
+ }
222
+ /** Someone joined the fleet. Sent to every other member. */
223
+ export interface FleetMemberJoined {
224
+ action: 'fleet_member_joined';
225
+ player_id: string;
226
+ player_name: string;
227
+ }
228
+ /** Someone left the fleet. Sent to every other member. */
229
+ export interface FleetMemberLeft {
230
+ action: 'fleet_member_left';
231
+ player_id: string;
232
+ player_name: string;
233
+ }
234
+ /** The leader removed someone. Sent to the remaining members, not the target. */
235
+ export interface FleetMemberKicked {
236
+ action: 'fleet_member_kicked';
237
+ player_id: string;
238
+ player_name: string;
239
+ }
240
+ /** The leader removed *you* from the fleet. */
241
+ export interface FleetKicked extends PushBase {
242
+ action: 'fleet_kicked';
243
+ }
244
+ /** The fleet was disbanded. */
245
+ export interface FleetDisbanded extends PushBase {
246
+ action: 'fleet_disbanded';
247
+ }
248
+ /** Fleet leadership passed to another member. */
249
+ export interface FleetLeaderPromoted extends PushBase {
250
+ action: 'fleet_leader_promoted';
251
+ new_leader: string;
252
+ }
253
+ /** A fleet member died. */
254
+ export interface FleetMemberDied extends PushBase {
255
+ action: 'fleet_member_died';
256
+ player_name: string;
257
+ }
258
+ /** A passenger boarded a fleet ship. */
259
+ export interface FleetPassengerBoarded extends PushBase {
260
+ action: 'fleet_passenger_boarded';
261
+ player_id: string;
262
+ player_name: string;
263
+ }
264
+ /** A passenger stopped riding and left the fleet. */
265
+ export interface FleetPassengerDisembarked extends PushBase {
266
+ action: 'fleet_passenger_disembarked';
267
+ player_id: string;
268
+ player_name: string;
269
+ }
270
+ /** Every `ok` push known as of gameserver v0.596.2. */
271
+ export type OkPush = OkTravelStarted | OkJumpStarted | OkFleetTravelStarted | OkFleetJumpStarted | OkFleetDocked | OkFleetUndocked | OkPassengerStranded | OkMobileCapitalTransit | OkEspionage | OkArrived | OkJumped | OkDocked | OkAttack | OkPathfinderPlot | OkAutoDock | OkAutoUndock | OkEmergencyWarpStabilizer | OkPassengerArrivals | OkPassengersTransferred | OkShipProcessing | OkTransitLoungeDepartures | OkShipmentOverdue | OkNewForumPost | OkMessageOnly;
272
+ /** The `ok` variants keyed on `action`. `Extract`ed for an exhaustive switch. */
273
+ export type OkActionPush = Extract<OkPush, {
274
+ action: string;
275
+ }>;
276
+ /** The `ok` variants keyed on `type`. `Extract`ed for an exhaustive switch. */
277
+ export type OkTypePush = Extract<OkPush, {
278
+ type: string;
279
+ }>;
280
+ /** Every `fleet` push known as of gameserver v0.596.2, all keyed on `action`. */
281
+ export type FleetPush = FleetInvite | FleetMemberJoined | FleetMemberLeft | FleetMemberKicked | FleetKicked | FleetDisbanded | FleetLeaderPromoted | FleetMemberDied | FleetPassengerBoarded | FleetPassengerDisembarked;
282
+ /** `action` values carried by an `ok` push. */
283
+ export declare const OK_PUSH_ACTIONS: readonly ["travel", "jump", "fleet_travel", "fleet_jump", "fleet_dock", "fleet_undock", "passenger_stranded", "mobile_capital_transit", "espionage", "arrived", "jumped", "pathfinder_arrival", "dock", "attack", "pathfinder_jump", "pathfinder_redirect"];
284
+ export type OkPushAction = (typeof OK_PUSH_ACTIONS)[number];
285
+ /** `type` values carried by an `ok` push, for the frames that use that key. */
286
+ export declare const OK_PUSH_TYPES: readonly ["auto_dock", "auto_undock", "emergency_warp_stabilizer_activated", "passenger_arrivals", "passengers_transferred", "ship_processing", "transit_lounge_departures", "shipment_overdue", "new_forum_post"];
287
+ export type OkPushType = (typeof OK_PUSH_TYPES)[number];
288
+ /** `action` values carried by a `fleet` push. */
289
+ export declare const FLEET_PUSH_ACTIONS: readonly ["fleet_invite", "fleet_member_joined", "fleet_member_left", "fleet_member_kicked", "fleet_kicked", "fleet_disbanded", "fleet_leader_promoted", "fleet_member_died", "fleet_passenger_boarded", "fleet_passenger_disembarked"];
290
+ export type FleetPushAction = (typeof FLEET_PUSH_ACTIONS)[number];
291
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacemolt/lib",
3
- "version": "14.0.0",
3
+ "version": "14.1.0",
4
4
  "description": "The definitive TypeScript library for SpaceMolt. WebSocket-v2-first, multi-account, with local state caches. Internals are regenerated from the server's OpenAPI spec.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",