@spacemolt/lib 12.1.0 → 12.2.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/dist/index.js CHANGED
@@ -2988,7 +2988,8 @@ var ACTIONS = {
2988
2988
 
2989
2989
  // src/generated/commands.gen.ts
2990
2990
  function buildCommands(dispatch) {
2991
- const bind = (tool, action) => (params) => dispatch(tool, action, params);
2991
+ const bind = (tool, action) => (params, requestId) => dispatch(tool, action, params, requestId);
2992
+ const bindBare = (tool, action) => (requestId) => dispatch(tool, action, undefined, requestId);
2992
2993
  return {
2993
2994
  spacemolt: {
2994
2995
  abandon_mission: bind("spacemolt", "abandon_mission"),
@@ -2997,45 +2998,45 @@ function buildCommands(dispatch) {
2997
2998
  buy: bind("spacemolt", "buy"),
2998
2999
  cloak: bind("spacemolt", "cloak"),
2999
3000
  complete_mission: bind("spacemolt", "complete_mission"),
3000
- completed_missions: bind("spacemolt", "completed_missions"),
3001
+ completed_missions: bindBare("spacemolt", "completed_missions"),
3001
3002
  craft: bind("spacemolt", "craft"),
3002
3003
  decline_mission: bind("spacemolt", "decline_mission"),
3003
3004
  distress_signal: bind("spacemolt", "distress_signal"),
3004
- dock: bind("spacemolt", "dock"),
3005
+ dock: bindBare("spacemolt", "dock"),
3005
3006
  find_route: bind("spacemolt", "find_route"),
3006
- get_achievements: bind("spacemolt", "get_achievements"),
3007
- get_active_missions: bind("spacemolt", "get_active_missions"),
3008
- get_base: bind("spacemolt", "get_base"),
3009
- get_cargo: bind("spacemolt", "get_cargo"),
3010
- get_commands: bind("spacemolt", "get_commands"),
3007
+ get_achievements: bindBare("spacemolt", "get_achievements"),
3008
+ get_active_missions: bindBare("spacemolt", "get_active_missions"),
3009
+ get_base: bindBare("spacemolt", "get_base"),
3010
+ get_cargo: bindBare("spacemolt", "get_cargo"),
3011
+ get_commands: bindBare("spacemolt", "get_commands"),
3011
3012
  get_empire_info: bind("spacemolt", "get_empire_info"),
3012
- get_faction_achievements: bind("spacemolt", "get_faction_achievements"),
3013
+ get_faction_achievements: bindBare("spacemolt", "get_faction_achievements"),
3013
3014
  get_guide: bind("spacemolt", "get_guide"),
3014
- get_location: bind("spacemolt", "get_location"),
3015
+ get_location: bindBare("spacemolt", "get_location"),
3015
3016
  get_map: bind("spacemolt", "get_map"),
3016
- get_missions: bind("spacemolt", "get_missions"),
3017
- get_nearby: bind("spacemolt", "get_nearby"),
3017
+ get_missions: bindBare("spacemolt", "get_missions"),
3018
+ get_nearby: bindBare("spacemolt", "get_nearby"),
3018
3019
  get_notifications: bind("spacemolt", "get_notifications"),
3019
- get_player: bind("spacemolt", "get_player"),
3020
- get_poi: bind("spacemolt", "get_poi"),
3021
- get_queue: bind("spacemolt", "get_queue"),
3022
- get_ship: bind("spacemolt", "get_ship"),
3023
- get_skills: bind("spacemolt", "get_skills"),
3024
- get_state: bind("spacemolt", "get_state"),
3025
- get_status: bind("spacemolt", "get_status"),
3026
- get_system: bind("spacemolt", "get_system"),
3027
- get_system_agents: bind("spacemolt", "get_system_agents"),
3028
- get_tax_estimate: bind("spacemolt", "get_tax_estimate"),
3020
+ get_player: bindBare("spacemolt", "get_player"),
3021
+ get_poi: bindBare("spacemolt", "get_poi"),
3022
+ get_queue: bindBare("spacemolt", "get_queue"),
3023
+ get_ship: bindBare("spacemolt", "get_ship"),
3024
+ get_skills: bindBare("spacemolt", "get_skills"),
3025
+ get_state: bindBare("spacemolt", "get_state"),
3026
+ get_status: bindBare("spacemolt", "get_status"),
3027
+ get_system: bindBare("spacemolt", "get_system"),
3028
+ get_system_agents: bindBare("spacemolt", "get_system_agents"),
3029
+ get_tax_estimate: bindBare("spacemolt", "get_tax_estimate"),
3029
3030
  get_version: bind("spacemolt", "get_version"),
3030
3031
  hunt: bind("spacemolt", "hunt"),
3031
3032
  inspect: bind("spacemolt", "inspect"),
3032
3033
  install_mod: bind("spacemolt", "install_mod"),
3033
3034
  jettison: bind("spacemolt", "jettison"),
3034
3035
  jump: bind("spacemolt", "jump"),
3035
- list_passengers: bind("spacemolt", "list_passengers"),
3036
- list_station_passengers: bind("spacemolt", "list_station_passengers"),
3036
+ list_passengers: bindBare("spacemolt", "list_passengers"),
3037
+ list_station_passengers: bindBare("spacemolt", "list_station_passengers"),
3037
3038
  load_passenger: bind("spacemolt", "load_passenger"),
3038
- mine: bind("spacemolt", "mine"),
3039
+ mine: bindBare("spacemolt", "mine"),
3039
3040
  prepay_tax: bind("spacemolt", "prepay_tax"),
3040
3041
  recycle: bind("spacemolt", "recycle"),
3041
3042
  refuel: bind("spacemolt", "refuel"),
@@ -3043,48 +3044,48 @@ function buildCommands(dispatch) {
3043
3044
  repair_module: bind("spacemolt", "repair_module"),
3044
3045
  scan: bind("spacemolt", "scan"),
3045
3046
  search_systems: bind("spacemolt", "search_systems"),
3046
- self_destruct: bind("spacemolt", "self_destruct"),
3047
+ self_destruct: bindBare("spacemolt", "self_destruct"),
3047
3048
  sell: bind("spacemolt", "sell"),
3048
3049
  subscribe_observation: bind("spacemolt", "subscribe_observation"),
3049
- survey_system: bind("spacemolt", "survey_system"),
3050
+ survey_system: bindBare("spacemolt", "survey_system"),
3050
3051
  travel: bind("spacemolt", "travel"),
3051
- undock: bind("spacemolt", "undock"),
3052
+ undock: bindBare("spacemolt", "undock"),
3052
3053
  uninstall_mod: bind("spacemolt", "uninstall_mod"),
3053
3054
  unload_passenger: bind("spacemolt", "unload_passenger"),
3054
- unsubscribe_observation: bind("spacemolt", "unsubscribe_observation"),
3055
+ unsubscribe_observation: bindBare("spacemolt", "unsubscribe_observation"),
3055
3056
  use_item: bind("spacemolt", "use_item"),
3056
3057
  view_completed_mission: bind("spacemolt", "view_completed_mission")
3057
3058
  },
3058
3059
  spacemolt_auth: {
3059
3060
  claim: bind("spacemolt_auth", "claim"),
3060
3061
  login: bind("spacemolt_auth", "login"),
3061
- login_link: bind("spacemolt_auth", "login_link"),
3062
+ login_link: bindBare("spacemolt_auth", "login_link"),
3062
3063
  login_link_poll: bind("spacemolt_auth", "login_link_poll"),
3063
3064
  login_token: bind("spacemolt_auth", "login_token"),
3064
- logout: bind("spacemolt_auth", "logout"),
3065
+ logout: bindBare("spacemolt_auth", "logout"),
3065
3066
  register: bind("spacemolt_auth", "register")
3066
3067
  },
3067
3068
  spacemolt_battle: {
3068
- advance: bind("spacemolt_battle", "advance"),
3069
+ advance: bindBare("spacemolt_battle", "advance"),
3069
3070
  engage: bind("spacemolt_battle", "engage"),
3070
3071
  log: bind("spacemolt_battle", "log"),
3071
3072
  reload: bind("spacemolt_battle", "reload"),
3072
- retreat: bind("spacemolt_battle", "retreat"),
3073
+ retreat: bindBare("spacemolt_battle", "retreat"),
3073
3074
  stance: bind("spacemolt_battle", "stance"),
3074
- status: bind("spacemolt_battle", "status"),
3075
+ status: bindBare("spacemolt_battle", "status"),
3075
3076
  summary: bind("spacemolt_battle", "summary"),
3076
3077
  target: bind("spacemolt_battle", "target")
3077
3078
  },
3078
3079
  spacemolt_citizenship: {
3079
3080
  apply: bind("spacemolt_citizenship", "apply"),
3080
- list: bind("spacemolt_citizenship", "list"),
3081
+ list: bindBare("spacemolt_citizenship", "list"),
3081
3082
  renounce: bind("spacemolt_citizenship", "renounce"),
3082
3083
  withdraw: bind("spacemolt_citizenship", "withdraw")
3083
3084
  },
3084
3085
  spacemolt_drone: {
3085
3086
  deploy: bind("spacemolt_drone", "deploy"),
3086
3087
  get: bind("spacemolt_drone", "get"),
3087
- list: bind("spacemolt_drone", "list"),
3088
+ list: bindBare("spacemolt_drone", "list"),
3088
3089
  load: bind("spacemolt_drone", "load"),
3089
3090
  name: bind("spacemolt_drone", "name"),
3090
3091
  recall: bind("spacemolt_drone", "recall"),
@@ -3095,7 +3096,7 @@ function buildCommands(dispatch) {
3095
3096
  allow_faction: bind("spacemolt_facility", "allow_faction"),
3096
3097
  allow_player: bind("spacemolt_facility", "allow_player"),
3097
3098
  ban: bind("spacemolt_facility", "ban"),
3098
- base_cost: bind("spacemolt_facility", "base_cost"),
3099
+ base_cost: bindBare("spacemolt_facility", "base_cost"),
3099
3100
  browse_for_sale: bind("spacemolt_facility", "browse_for_sale"),
3100
3101
  build: bind("spacemolt_facility", "build"),
3101
3102
  buy_listing: bind("spacemolt_facility", "buy_listing"),
@@ -3103,21 +3104,21 @@ function buildCommands(dispatch) {
3103
3104
  cancel_listing: bind("spacemolt_facility", "cancel_listing"),
3104
3105
  deploy_outpost: bind("spacemolt_facility", "deploy_outpost"),
3105
3106
  dismantle: bind("spacemolt_facility", "dismantle"),
3106
- dismantle_outpost: bind("spacemolt_facility", "dismantle_outpost"),
3107
+ dismantle_outpost: bindBare("spacemolt_facility", "dismantle_outpost"),
3107
3108
  facility_set_description: bind("spacemolt_facility", "facility_set_description"),
3108
3109
  faction_build: bind("spacemolt_facility", "faction_build"),
3109
3110
  faction_dismantle: bind("spacemolt_facility", "faction_dismantle"),
3110
- faction_list: bind("spacemolt_facility", "faction_list"),
3111
- faction_owned: bind("spacemolt_facility", "faction_owned"),
3111
+ faction_list: bindBare("spacemolt_facility", "faction_list"),
3112
+ faction_owned: bindBare("spacemolt_facility", "faction_owned"),
3112
3113
  faction_upgrade: bind("spacemolt_facility", "faction_upgrade"),
3113
3114
  found_station: bind("spacemolt_facility", "found_station"),
3114
3115
  job_add: bind("spacemolt_facility", "job_add"),
3115
3116
  job_cancel: bind("spacemolt_facility", "job_cancel"),
3116
3117
  job_list: bind("spacemolt_facility", "job_list"),
3117
3118
  job_reorder: bind("spacemolt_facility", "job_reorder"),
3118
- list: bind("spacemolt_facility", "list"),
3119
+ list: bindBare("spacemolt_facility", "list"),
3119
3120
  list_for_sale: bind("spacemolt_facility", "list_for_sale"),
3120
- owned: bind("spacemolt_facility", "owned"),
3121
+ owned: bindBare("spacemolt_facility", "owned"),
3121
3122
  personal_build: bind("spacemolt_facility", "personal_build"),
3122
3123
  personal_decorate: bind("spacemolt_facility", "personal_decorate"),
3123
3124
  personal_visit: bind("spacemolt_facility", "personal_visit"),
@@ -3137,13 +3138,13 @@ function buildCommands(dispatch) {
3137
3138
  set_refuel_price: bind("spacemolt_facility", "set_refuel_price"),
3138
3139
  set_repair_price: bind("spacemolt_facility", "set_repair_price"),
3139
3140
  set_service_access: bind("spacemolt_facility", "set_service_access"),
3140
- station_info: bind("spacemolt_facility", "station_info"),
3141
+ station_info: bindBare("spacemolt_facility", "station_info"),
3141
3142
  station_set_name: bind("spacemolt_facility", "station_set_name"),
3142
3143
  transfer: bind("spacemolt_facility", "transfer"),
3143
3144
  types: bind("spacemolt_facility", "types"),
3144
3145
  unban: bind("spacemolt_facility", "unban"),
3145
3146
  upgrade: bind("spacemolt_facility", "upgrade"),
3146
- upgrades: bind("spacemolt_facility", "upgrades")
3147
+ upgrades: bindBare("spacemolt_facility", "upgrades")
3147
3148
  },
3148
3149
  spacemolt_faction: {
3149
3150
  accept_ally: bind("spacemolt_faction", "accept_ally"),
@@ -3155,23 +3156,23 @@ function buildCommands(dispatch) {
3155
3156
  decline_invite: bind("spacemolt_faction", "decline_invite"),
3156
3157
  delete_role: bind("spacemolt_faction", "delete_role"),
3157
3158
  delete_room: bind("spacemolt_faction", "delete_room"),
3158
- garages: bind("spacemolt_faction", "garages"),
3159
- get_invites: bind("spacemolt_faction", "get_invites"),
3159
+ garages: bindBare("spacemolt_faction", "garages"),
3160
+ get_invites: bindBare("spacemolt_faction", "get_invites"),
3160
3161
  info: bind("spacemolt_faction", "info"),
3161
3162
  invite: bind("spacemolt_faction", "invite"),
3162
3163
  join: bind("spacemolt_faction", "join"),
3163
3164
  kick: bind("spacemolt_faction", "kick"),
3164
- leave: bind("spacemolt_faction", "leave"),
3165
+ leave: bindBare("spacemolt_faction", "leave"),
3165
3166
  list: bind("spacemolt_faction", "list"),
3166
- list_missions: bind("spacemolt_faction", "list_missions"),
3167
+ list_missions: bindBare("spacemolt_faction", "list_missions"),
3167
3168
  prepay_tax: bind("spacemolt_faction", "prepay_tax"),
3168
3169
  propose_ally: bind("spacemolt_faction", "propose_ally"),
3169
3170
  propose_peace: bind("spacemolt_faction", "propose_peace"),
3170
3171
  remove_ally: bind("spacemolt_faction", "remove_ally"),
3171
3172
  remove_enemy: bind("spacemolt_faction", "remove_enemy"),
3172
- rooms: bind("spacemolt_faction", "rooms"),
3173
+ rooms: bindBare("spacemolt_faction", "rooms"),
3173
3174
  set_enemy: bind("spacemolt_faction", "set_enemy"),
3174
- tax_estimate: bind("spacemolt_faction", "tax_estimate"),
3175
+ tax_estimate: bindBare("spacemolt_faction", "tax_estimate"),
3175
3176
  visit_room: bind("spacemolt_faction", "visit_room"),
3176
3177
  withdraw_invite: bind("spacemolt_faction", "withdraw_invite")
3177
3178
  },
@@ -3188,50 +3189,50 @@ function buildCommands(dispatch) {
3188
3189
  create_sell_order: bind("spacemolt_faction_commerce", "create_sell_order")
3189
3190
  },
3190
3191
  spacemolt_fleet: {
3191
- accept: bind("spacemolt_fleet", "accept"),
3192
+ accept: bindBare("spacemolt_fleet", "accept"),
3192
3193
  board: bind("spacemolt_fleet", "board"),
3193
- create: bind("spacemolt_fleet", "create"),
3194
- decline: bind("spacemolt_fleet", "decline"),
3195
- disband: bind("spacemolt_fleet", "disband"),
3196
- disembark: bind("spacemolt_fleet", "disembark"),
3194
+ create: bindBare("spacemolt_fleet", "create"),
3195
+ decline: bindBare("spacemolt_fleet", "decline"),
3196
+ disband: bindBare("spacemolt_fleet", "disband"),
3197
+ disembark: bindBare("spacemolt_fleet", "disembark"),
3197
3198
  invite: bind("spacemolt_fleet", "invite"),
3198
3199
  kick: bind("spacemolt_fleet", "kick"),
3199
- leave: bind("spacemolt_fleet", "leave"),
3200
- status: bind("spacemolt_fleet", "status")
3200
+ leave: bindBare("spacemolt_fleet", "leave"),
3201
+ status: bindBare("spacemolt_fleet", "status")
3201
3202
  },
3202
3203
  spacemolt_intel: {
3203
- espionage: bind("spacemolt_intel", "espionage"),
3204
- intel_status: bind("spacemolt_intel", "intel_status"),
3204
+ espionage: bindBare("spacemolt_intel", "espionage"),
3205
+ intel_status: bindBare("spacemolt_intel", "intel_status"),
3205
3206
  query_intel: bind("spacemolt_intel", "query_intel"),
3206
3207
  query_trade_intel: bind("spacemolt_intel", "query_trade_intel"),
3207
3208
  scan_poi: bind("spacemolt_intel", "scan_poi"),
3208
3209
  submit_intel: bind("spacemolt_intel", "submit_intel"),
3209
3210
  submit_trade_intel: bind("spacemolt_intel", "submit_trade_intel"),
3210
- trade_intel_status: bind("spacemolt_intel", "trade_intel_status")
3211
+ trade_intel_status: bindBare("spacemolt_intel", "trade_intel_status")
3211
3212
  },
3212
3213
  spacemolt_market: {
3213
- analyze_market: bind("spacemolt_market", "analyze_market"),
3214
+ analyze_market: bindBare("spacemolt_market", "analyze_market"),
3214
3215
  cancel_order: bind("spacemolt_market", "cancel_order"),
3215
3216
  create_buy_order: bind("spacemolt_market", "create_buy_order"),
3216
3217
  create_sell_order: bind("spacemolt_market", "create_sell_order"),
3217
3218
  estimate_purchase: bind("spacemolt_market", "estimate_purchase"),
3218
3219
  modify_order: bind("spacemolt_market", "modify_order"),
3219
- subscribe_market: bind("spacemolt_market", "subscribe_market"),
3220
- unsubscribe_market: bind("spacemolt_market", "unsubscribe_market"),
3220
+ subscribe_market: bindBare("spacemolt_market", "subscribe_market"),
3221
+ unsubscribe_market: bindBare("spacemolt_market", "unsubscribe_market"),
3221
3222
  view_market: bind("spacemolt_market", "view_market"),
3222
3223
  view_orders: bind("spacemolt_market", "view_orders")
3223
3224
  },
3224
3225
  spacemolt_salvage: {
3225
- insure: bind("spacemolt_salvage", "insure"),
3226
+ insure: bindBare("spacemolt_salvage", "insure"),
3226
3227
  loot: bind("spacemolt_salvage", "loot"),
3227
- policies: bind("spacemolt_salvage", "policies"),
3228
- quote: bind("spacemolt_salvage", "quote"),
3229
- release: bind("spacemolt_salvage", "release"),
3230
- scrap: bind("spacemolt_salvage", "scrap"),
3231
- sell: bind("spacemolt_salvage", "sell"),
3228
+ policies: bindBare("spacemolt_salvage", "policies"),
3229
+ quote: bindBare("spacemolt_salvage", "quote"),
3230
+ release: bindBare("spacemolt_salvage", "release"),
3231
+ scrap: bindBare("spacemolt_salvage", "scrap"),
3232
+ sell: bindBare("spacemolt_salvage", "sell"),
3232
3233
  set_home: bind("spacemolt_salvage", "set_home"),
3233
3234
  tow: bind("spacemolt_salvage", "tow"),
3234
- wrecks: bind("spacemolt_salvage", "wrecks")
3235
+ wrecks: bindBare("spacemolt_salvage", "wrecks")
3235
3236
  },
3236
3237
  spacemolt_ship: {
3237
3238
  browse_ships: bind("spacemolt_ship", "browse_ships"),
@@ -3243,15 +3244,15 @@ function buildCommands(dispatch) {
3243
3244
  commission_ship: bind("spacemolt_ship", "commission_ship"),
3244
3245
  commission_status: bind("spacemolt_ship", "commission_status"),
3245
3246
  list_ship_for_sale: bind("spacemolt_ship", "list_ship_for_sale"),
3246
- list_ships: bind("spacemolt_ship", "list_ships"),
3247
+ list_ships: bindBare("spacemolt_ship", "list_ships"),
3247
3248
  place_ship_buy_order: bind("spacemolt_ship", "place_ship_buy_order"),
3248
- refit_ship: bind("spacemolt_ship", "refit_ship"),
3249
+ refit_ship: bindBare("spacemolt_ship", "refit_ship"),
3249
3250
  rename_ship: bind("spacemolt_ship", "rename_ship"),
3250
3251
  scrap_ship: bind("spacemolt_ship", "scrap_ship"),
3251
3252
  sell_ship_to_order: bind("spacemolt_ship", "sell_ship_to_order"),
3252
3253
  supply_commission: bind("spacemolt_ship", "supply_commission"),
3253
3254
  switch_ship: bind("spacemolt_ship", "switch_ship"),
3254
- view_ship_buy_orders: bind("spacemolt_ship", "view_ship_buy_orders")
3255
+ view_ship_buy_orders: bindBare("spacemolt_ship", "view_ship_buy_orders")
3255
3256
  },
3256
3257
  spacemolt_shipping: {
3257
3258
  accept: bind("spacemolt_shipping", "accept"),
@@ -3284,7 +3285,7 @@ function buildCommands(dispatch) {
3284
3285
  get_action_log: bind("spacemolt_social", "get_action_log"),
3285
3286
  get_chat_history: bind("spacemolt_social", "get_chat_history"),
3286
3287
  get_notes: bind("spacemolt_social", "get_notes"),
3287
- get_notification_settings: bind("spacemolt_social", "get_notification_settings"),
3288
+ get_notification_settings: bindBare("spacemolt_social", "get_notification_settings"),
3288
3289
  mute_notifications: bind("spacemolt_social", "mute_notifications"),
3289
3290
  petition: bind("spacemolt_social", "petition"),
3290
3291
  read_note: bind("spacemolt_social", "read_note"),
@@ -3301,7 +3302,7 @@ function buildCommands(dispatch) {
3301
3302
  withdraw: bind("spacemolt_storage", "withdraw")
3302
3303
  },
3303
3304
  spacemolt_transfer: {
3304
- get_trades: bind("spacemolt_transfer", "get_trades"),
3305
+ get_trades: bindBare("spacemolt_transfer", "get_trades"),
3305
3306
  trade_accept: bind("spacemolt_transfer", "trade_accept"),
3306
3307
  trade_cancel: bind("spacemolt_transfer", "trade_cancel"),
3307
3308
  trade_decline: bind("spacemolt_transfer", "trade_decline"),
@@ -4087,7 +4088,7 @@ class Account {
4087
4088
  }
4088
4089
  get commands() {
4089
4090
  if (!this._commands) {
4090
- this._commands = buildCommands((tool, action, payload) => this.send(tool, action, payload));
4091
+ this._commands = buildCommands((tool, action, payload, requestId) => this.send(tool, action, payload, requestId));
4091
4092
  }
4092
4093
  return this._commands;
4093
4094
  }
@@ -4222,25 +4223,25 @@ class Account {
4222
4223
  await this.query("spacemolt_auth", "logout");
4223
4224
  this._authenticated = false;
4224
4225
  }
4225
- query(tool, action, payload) {
4226
+ query(tool, action, payload, requestId) {
4226
4227
  return this.withRateLimitRetry(async () => {
4227
- const requestId = this.nextRequestId();
4228
- const promise = this.correlator.awaitQuery(requestId);
4229
- this.sendFrame(tool, action, payload, requestId);
4228
+ const id = this.claimRequestId(requestId);
4229
+ const promise = this.correlator.awaitQuery(id);
4230
+ this.sendFrame(tool, action, payload, id);
4230
4231
  try {
4231
4232
  return await withTimeout(promise, this.queryTimeoutMs, `No response to ${tool}/${action} within ${this.queryTimeoutMs}ms`);
4232
4233
  } catch (err) {
4233
- this.correlator.cancel(requestId);
4234
+ this.correlator.cancel(id);
4234
4235
  throw err;
4235
4236
  }
4236
4237
  });
4237
4238
  }
4238
- mutate(tool, action, payload, onAck) {
4239
+ mutate(tool, action, payload, onAck, requestId) {
4239
4240
  const mutationTimeoutMs = TRANSIT_ACTIONS.has(`${tool}/${action}`) ? this.mutationTimeoutMs : this.fastMutationTimeoutMs;
4240
4241
  return this.enqueueMutation(() => this.withRateLimitRetry(() => {
4241
- const requestId = this.nextRequestId();
4242
- const promise = this.awaitMutationWithTimeout(requestId, mutationTimeoutMs, onAck);
4243
- this.sendFrame(tool, action, payload, requestId);
4242
+ const id = this.claimRequestId(requestId);
4243
+ const promise = this.awaitMutationWithTimeout(id, mutationTimeoutMs, onAck);
4244
+ this.sendFrame(tool, action, payload, id);
4244
4245
  return promise;
4245
4246
  }));
4246
4247
  }
@@ -4270,9 +4271,9 @@ class Account {
4270
4271
  });
4271
4272
  });
4272
4273
  }
4273
- send(tool, action, payload) {
4274
+ send(tool, action, payload, requestId) {
4274
4275
  const def = ACTIONS[`${tool}/${action}`];
4275
- return def?.kind === "mutation" ? this.mutate(tool, action, payload) : this.query(tool, action, payload);
4276
+ return def?.kind === "mutation" ? this.mutate(tool, action, payload, undefined, requestId) : this.query(tool, action, payload, requestId);
4276
4277
  }
4277
4278
  on(type, handler) {
4278
4279
  return this.emitter.on(type, handler);
@@ -4408,7 +4409,18 @@ class Account {
4408
4409
  this.socket.send({ tool, action, ...payload ? { payload } : {}, request_id: requestId });
4409
4410
  }
4410
4411
  nextRequestId() {
4411
- return `r${++this.requestSeq}`;
4412
+ let id = `r${++this.requestSeq}`;
4413
+ while (this.correlator.has(id))
4414
+ id = `r${++this.requestSeq}`;
4415
+ return id;
4416
+ }
4417
+ claimRequestId(requestId) {
4418
+ if (!requestId)
4419
+ return this.nextRequestId();
4420
+ if (this.correlator.has(requestId)) {
4421
+ throw new SpacemoltError("duplicate_request_id", `request_id "${requestId}" is already in flight`);
4422
+ }
4423
+ return requestId;
4412
4424
  }
4413
4425
  routeFrame(frame) {
4414
4426
  if (isRecord(frame.payload))
@@ -5115,38 +5127,38 @@ var TYPED_NOTIFICATION_TYPES = [
5115
5127
  "trade_offer_received"
5116
5128
  ];
5117
5129
  export {
5118
- retryAfterMsFromClose,
5119
- mintWsToken,
5120
- isWelcomeFrame,
5121
- isResultFrame,
5122
- isRegisteredFrame,
5123
- isLoggedInFrame,
5124
- isErrorFrame,
5125
- isActionResultFrame,
5126
- isActionErrorFrame,
5127
- httpBaseFromWs,
5128
- fetchStations,
5129
- fetchMap,
5130
- fetchCatalogConditional,
5131
- fetchCatalog,
5132
- buildCommands,
5133
- TypedEmitter,
5134
- TYPED_NOTIFICATION_TYPES,
5135
- StateCache,
5136
- SpacemoltError,
5137
- SpacemoltClient,
5138
- Socket,
5139
- STATE_SECTIONS,
5140
- ObservationCache,
5141
- MemoryCredentialStore,
5142
- MarketCache,
5143
- MapCache,
5144
- GENERATED_SPEC_VERSION,
5145
- EventStream,
5146
- ConnectionClosedError,
5147
- ClerkSource,
5148
- CatalogCache,
5149
- CLOSE_CODE,
5130
+ ACTIONS,
5150
5131
  Account,
5151
- ACTIONS
5132
+ CLOSE_CODE,
5133
+ CatalogCache,
5134
+ ClerkSource,
5135
+ ConnectionClosedError,
5136
+ EventStream,
5137
+ GENERATED_SPEC_VERSION,
5138
+ MapCache,
5139
+ MarketCache,
5140
+ MemoryCredentialStore,
5141
+ ObservationCache,
5142
+ STATE_SECTIONS,
5143
+ Socket,
5144
+ SpacemoltClient,
5145
+ SpacemoltError,
5146
+ StateCache,
5147
+ TYPED_NOTIFICATION_TYPES,
5148
+ TypedEmitter,
5149
+ buildCommands,
5150
+ fetchCatalog,
5151
+ fetchCatalogConditional,
5152
+ fetchMap,
5153
+ fetchStations,
5154
+ httpBaseFromWs,
5155
+ isActionErrorFrame,
5156
+ isActionResultFrame,
5157
+ isErrorFrame,
5158
+ isLoggedInFrame,
5159
+ isRegisteredFrame,
5160
+ isResultFrame,
5161
+ isWelcomeFrame,
5162
+ mintWsToken,
5163
+ retryAfterMsFromClose
5152
5164
  };
package/dist/node.js CHANGED
@@ -29,24 +29,6 @@ function isStoredAccount(value) {
29
29
  }
30
30
  }
31
31
 
32
- class MemoryCredentialStore {
33
- accounts = new Map;
34
- list() {
35
- return Promise.resolve([...this.accounts.values()]);
36
- }
37
- get(id) {
38
- return Promise.resolve(this.accounts.get(id));
39
- }
40
- put(account) {
41
- this.accounts.set(account.id, account);
42
- return Promise.resolve();
43
- }
44
- remove(id) {
45
- this.accounts.delete(id);
46
- return Promise.resolve();
47
- }
48
- }
49
-
50
32
  // src/auth/file-store.ts
51
33
  class FileCredentialStore {
52
34
  path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacemolt/lib",
3
- "version": "12.1.0",
3
+ "version": "12.2.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",