@blackasteroid/kuma-cli 1.0.0 → 1.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.
Files changed (2) hide show
  1. package/dist/index.js +508 -173
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3218,11 +3218,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
3218
3218
  */
3219
3219
  _getOutputContext(contextOptions) {
3220
3220
  contextOptions = contextOptions || {};
3221
- const error2 = !!contextOptions.error;
3221
+ const error3 = !!contextOptions.error;
3222
3222
  let baseWrite;
3223
3223
  let hasColors;
3224
3224
  let helpWidth;
3225
- if (error2) {
3225
+ if (error3) {
3226
3226
  baseWrite = (str) => this._outputConfiguration.writeErr(str);
3227
3227
  hasColors = this._outputConfiguration.getErrHasColors();
3228
3228
  helpWidth = this._outputConfiguration.getErrHelpWidth();
@@ -3235,7 +3235,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3235
3235
  if (!hasColors) str = this._outputConfiguration.stripColor(str);
3236
3236
  return baseWrite(str);
3237
3237
  };
3238
- return { error: error2, write, hasColors, helpWidth };
3238
+ return { error: error3, write, hasColors, helpWidth };
3239
3239
  }
3240
3240
  /**
3241
3241
  * Output help information for this command.
@@ -4805,13 +4805,13 @@ var require_prompt = __commonJS({
4805
4805
  }
4806
4806
  let result = this.state.error || await this.validate(this.value, this.state);
4807
4807
  if (result !== true) {
4808
- let error2 = "\n" + this.symbols.pointer + " ";
4808
+ let error3 = "\n" + this.symbols.pointer + " ";
4809
4809
  if (typeof result === "string") {
4810
- error2 += result.trim();
4810
+ error3 += result.trim();
4811
4811
  } else {
4812
- error2 += "Invalid input";
4812
+ error3 += "Invalid input";
4813
4813
  }
4814
- this.state.error = "\n" + this.styles.danger(error2);
4814
+ this.state.error = "\n" + this.styles.danger(error3);
4815
4815
  this.state.submitted = false;
4816
4816
  await this.render();
4817
4817
  await this.alert();
@@ -7184,11 +7184,11 @@ var require_interpolate = __commonJS({
7184
7184
  state.keys = keys;
7185
7185
  state.output = "";
7186
7186
  let validate = async (value2, state2, item, index2) => {
7187
- let error2 = await isValid(value2, state2, item, index2);
7188
- if (error2 === false) {
7187
+ let error3 = await isValid(value2, state2, item, index2);
7188
+ if (error3 === false) {
7189
7189
  return "Invalid field " + item.name;
7190
7190
  }
7191
- return error2;
7191
+ return error3;
7192
7192
  };
7193
7193
  for (let token of tabstops) {
7194
7194
  let value2 = token.value;
@@ -7206,9 +7206,9 @@ var require_interpolate = __commonJS({
7206
7206
  let field = item.field || {};
7207
7207
  let message = field.message || token.inner;
7208
7208
  if (submitted) {
7209
- let error2 = await validate(state.values[key], state, item, index);
7210
- if (error2 && typeof error2 === "string" || error2 === false) {
7211
- state.invalid.set(key, error2);
7209
+ let error3 = await validate(state.values[key], state, item, index);
7210
+ if (error3 && typeof error3 === "string" || error3 === false) {
7211
+ state.invalid.set(key, error3);
7212
7212
  continue;
7213
7213
  }
7214
7214
  state.invalid.delete(key);
@@ -7394,7 +7394,7 @@ var require_snippet = __commonJS({
7394
7394
  let prompt3 = [prefix, message, separator].filter(Boolean).join(" ");
7395
7395
  this.state.prompt = prompt3;
7396
7396
  let header = await this.header();
7397
- let error2 = await this.error() || "";
7397
+ let error3 = await this.error() || "";
7398
7398
  let hint = await this.hint() || "";
7399
7399
  let body = submitted ? "" : await this.interpolate(this.state);
7400
7400
  let key = this.state.key = keys[index] || "";
@@ -7403,7 +7403,7 @@ var require_snippet = __commonJS({
7403
7403
  if (input) prompt3 += " " + input;
7404
7404
  if (hint && !input && this.state.completed === 0) prompt3 += " " + hint;
7405
7405
  this.clear(size);
7406
- let lines = [header, prompt3, body, footer, error2.trim()];
7406
+ let lines = [header, prompt3, body, footer, error3.trim()];
7407
7407
  this.write(lines.filter(Boolean).join(newline));
7408
7408
  this.restore();
7409
7409
  }
@@ -8175,9 +8175,9 @@ var require_XMLHttpRequest = __commonJS({
8175
8175
  throw new Error("XMLHttpRequest: Only GET method is supported");
8176
8176
  }
8177
8177
  if (settings.async) {
8178
- fs3.readFile(unescape(url2.pathname), function(error2, data2) {
8179
- if (error2) {
8180
- self.handleError(error2, error2.errno || -1);
8178
+ fs3.readFile(unescape(url2.pathname), function(error3, data2) {
8179
+ if (error3) {
8180
+ self.handleError(error3, error3.errno || -1);
8181
8181
  } else {
8182
8182
  self.status = 200;
8183
8183
  self.responseText = data2.toString("utf8");
@@ -8290,14 +8290,14 @@ var require_XMLHttpRequest = __commonJS({
8290
8290
  self.responseText = self.response.toString("utf8");
8291
8291
  }
8292
8292
  });
8293
- response.on("error", function(error2) {
8294
- self.handleError(error2);
8293
+ response.on("error", function(error3) {
8294
+ self.handleError(error3);
8295
8295
  });
8296
8296
  };
8297
- var errorHandler = function(error2) {
8298
- if (request.reusedSocket && error2.code === "ECONNRESET")
8297
+ var errorHandler = function(error3) {
8298
+ if (request.reusedSocket && error3.code === "ECONNRESET")
8299
8299
  return doRequest(options, responseHandler).on("error", errorHandler);
8300
- self.handleError(error2);
8300
+ self.handleError(error3);
8301
8301
  };
8302
8302
  request = doRequest(options, responseHandler).on("error", errorHandler);
8303
8303
  if (opts.autoUnref) {
@@ -8338,10 +8338,10 @@ var require_XMLHttpRequest = __commonJS({
8338
8338
  }
8339
8339
  }
8340
8340
  };
8341
- this.handleError = function(error2, status) {
8341
+ this.handleError = function(error3, status) {
8342
8342
  this.status = status || 0;
8343
- this.statusText = error2;
8344
- this.responseText = error2.stack;
8343
+ this.statusText = error3;
8344
+ this.responseText = error3.stack;
8345
8345
  errorFlag = true;
8346
8346
  setState(this.DONE);
8347
8347
  };
@@ -8851,14 +8851,14 @@ var require_browser = __commonJS({
8851
8851
  } else {
8852
8852
  exports2.storage.removeItem("debug");
8853
8853
  }
8854
- } catch (error2) {
8854
+ } catch (error3) {
8855
8855
  }
8856
8856
  }
8857
8857
  function load() {
8858
8858
  let r;
8859
8859
  try {
8860
8860
  r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
8861
- } catch (error2) {
8861
+ } catch (error3) {
8862
8862
  }
8863
8863
  if (!r && typeof process !== "undefined" && "env" in process) {
8864
8864
  r = process.env.DEBUG;
@@ -8868,7 +8868,7 @@ var require_browser = __commonJS({
8868
8868
  function localstorage() {
8869
8869
  try {
8870
8870
  return localStorage;
8871
- } catch (error2) {
8871
+ } catch (error3) {
8872
8872
  }
8873
8873
  }
8874
8874
  module2.exports = require_common()(exports2);
@@ -8876,8 +8876,8 @@ var require_browser = __commonJS({
8876
8876
  formatters.j = function(v) {
8877
8877
  try {
8878
8878
  return JSON.stringify(v);
8879
- } catch (error2) {
8880
- return "[UnexpectedJSONParseError]: " + error2.message;
8879
+ } catch (error3) {
8880
+ return "[UnexpectedJSONParseError]: " + error3.message;
8881
8881
  }
8882
8882
  };
8883
8883
  }
@@ -9098,7 +9098,7 @@ var require_node = __commonJS({
9098
9098
  221
9099
9099
  ];
9100
9100
  }
9101
- } catch (error2) {
9101
+ } catch (error3) {
9102
9102
  }
9103
9103
  exports2.inspectOpts = Object.keys(process.env).filter((key) => {
9104
9104
  return /^debug_/i.test(key);
@@ -10077,26 +10077,26 @@ var require_receiver = __commonJS({
10077
10077
  }
10078
10078
  const buf = this.consume(2);
10079
10079
  if ((buf[0] & 48) !== 0) {
10080
- const error2 = this.createError(
10080
+ const error3 = this.createError(
10081
10081
  RangeError,
10082
10082
  "RSV2 and RSV3 must be clear",
10083
10083
  true,
10084
10084
  1002,
10085
10085
  "WS_ERR_UNEXPECTED_RSV_2_3"
10086
10086
  );
10087
- cb(error2);
10087
+ cb(error3);
10088
10088
  return;
10089
10089
  }
10090
10090
  const compressed = (buf[0] & 64) === 64;
10091
10091
  if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
10092
- const error2 = this.createError(
10092
+ const error3 = this.createError(
10093
10093
  RangeError,
10094
10094
  "RSV1 must be clear",
10095
10095
  true,
10096
10096
  1002,
10097
10097
  "WS_ERR_UNEXPECTED_RSV_1"
10098
10098
  );
10099
- cb(error2);
10099
+ cb(error3);
10100
10100
  return;
10101
10101
  }
10102
10102
  this._fin = (buf[0] & 128) === 128;
@@ -10104,109 +10104,109 @@ var require_receiver = __commonJS({
10104
10104
  this._payloadLength = buf[1] & 127;
10105
10105
  if (this._opcode === 0) {
10106
10106
  if (compressed) {
10107
- const error2 = this.createError(
10107
+ const error3 = this.createError(
10108
10108
  RangeError,
10109
10109
  "RSV1 must be clear",
10110
10110
  true,
10111
10111
  1002,
10112
10112
  "WS_ERR_UNEXPECTED_RSV_1"
10113
10113
  );
10114
- cb(error2);
10114
+ cb(error3);
10115
10115
  return;
10116
10116
  }
10117
10117
  if (!this._fragmented) {
10118
- const error2 = this.createError(
10118
+ const error3 = this.createError(
10119
10119
  RangeError,
10120
10120
  "invalid opcode 0",
10121
10121
  true,
10122
10122
  1002,
10123
10123
  "WS_ERR_INVALID_OPCODE"
10124
10124
  );
10125
- cb(error2);
10125
+ cb(error3);
10126
10126
  return;
10127
10127
  }
10128
10128
  this._opcode = this._fragmented;
10129
10129
  } else if (this._opcode === 1 || this._opcode === 2) {
10130
10130
  if (this._fragmented) {
10131
- const error2 = this.createError(
10131
+ const error3 = this.createError(
10132
10132
  RangeError,
10133
10133
  `invalid opcode ${this._opcode}`,
10134
10134
  true,
10135
10135
  1002,
10136
10136
  "WS_ERR_INVALID_OPCODE"
10137
10137
  );
10138
- cb(error2);
10138
+ cb(error3);
10139
10139
  return;
10140
10140
  }
10141
10141
  this._compressed = compressed;
10142
10142
  } else if (this._opcode > 7 && this._opcode < 11) {
10143
10143
  if (!this._fin) {
10144
- const error2 = this.createError(
10144
+ const error3 = this.createError(
10145
10145
  RangeError,
10146
10146
  "FIN must be set",
10147
10147
  true,
10148
10148
  1002,
10149
10149
  "WS_ERR_EXPECTED_FIN"
10150
10150
  );
10151
- cb(error2);
10151
+ cb(error3);
10152
10152
  return;
10153
10153
  }
10154
10154
  if (compressed) {
10155
- const error2 = this.createError(
10155
+ const error3 = this.createError(
10156
10156
  RangeError,
10157
10157
  "RSV1 must be clear",
10158
10158
  true,
10159
10159
  1002,
10160
10160
  "WS_ERR_UNEXPECTED_RSV_1"
10161
10161
  );
10162
- cb(error2);
10162
+ cb(error3);
10163
10163
  return;
10164
10164
  }
10165
10165
  if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
10166
- const error2 = this.createError(
10166
+ const error3 = this.createError(
10167
10167
  RangeError,
10168
10168
  `invalid payload length ${this._payloadLength}`,
10169
10169
  true,
10170
10170
  1002,
10171
10171
  "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
10172
10172
  );
10173
- cb(error2);
10173
+ cb(error3);
10174
10174
  return;
10175
10175
  }
10176
10176
  } else {
10177
- const error2 = this.createError(
10177
+ const error3 = this.createError(
10178
10178
  RangeError,
10179
10179
  `invalid opcode ${this._opcode}`,
10180
10180
  true,
10181
10181
  1002,
10182
10182
  "WS_ERR_INVALID_OPCODE"
10183
10183
  );
10184
- cb(error2);
10184
+ cb(error3);
10185
10185
  return;
10186
10186
  }
10187
10187
  if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
10188
10188
  this._masked = (buf[1] & 128) === 128;
10189
10189
  if (this._isServer) {
10190
10190
  if (!this._masked) {
10191
- const error2 = this.createError(
10191
+ const error3 = this.createError(
10192
10192
  RangeError,
10193
10193
  "MASK must be set",
10194
10194
  true,
10195
10195
  1002,
10196
10196
  "WS_ERR_EXPECTED_MASK"
10197
10197
  );
10198
- cb(error2);
10198
+ cb(error3);
10199
10199
  return;
10200
10200
  }
10201
10201
  } else if (this._masked) {
10202
- const error2 = this.createError(
10202
+ const error3 = this.createError(
10203
10203
  RangeError,
10204
10204
  "MASK must be clear",
10205
10205
  true,
10206
10206
  1002,
10207
10207
  "WS_ERR_UNEXPECTED_MASK"
10208
10208
  );
10209
- cb(error2);
10209
+ cb(error3);
10210
10210
  return;
10211
10211
  }
10212
10212
  if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
@@ -10241,14 +10241,14 @@ var require_receiver = __commonJS({
10241
10241
  const buf = this.consume(8);
10242
10242
  const num = buf.readUInt32BE(0);
10243
10243
  if (num > Math.pow(2, 53 - 32) - 1) {
10244
- const error2 = this.createError(
10244
+ const error3 = this.createError(
10245
10245
  RangeError,
10246
10246
  "Unsupported WebSocket frame: payload length > 2^53 - 1",
10247
10247
  false,
10248
10248
  1009,
10249
10249
  "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
10250
10250
  );
10251
- cb(error2);
10251
+ cb(error3);
10252
10252
  return;
10253
10253
  }
10254
10254
  this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
@@ -10264,14 +10264,14 @@ var require_receiver = __commonJS({
10264
10264
  if (this._payloadLength && this._opcode < 8) {
10265
10265
  this._totalPayloadLength += this._payloadLength;
10266
10266
  if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
10267
- const error2 = this.createError(
10267
+ const error3 = this.createError(
10268
10268
  RangeError,
10269
10269
  "Max payload size exceeded",
10270
10270
  false,
10271
10271
  1009,
10272
10272
  "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
10273
10273
  );
10274
- cb(error2);
10274
+ cb(error3);
10275
10275
  return;
10276
10276
  }
10277
10277
  }
@@ -10338,14 +10338,14 @@ var require_receiver = __commonJS({
10338
10338
  if (buf.length) {
10339
10339
  this._messageLength += buf.length;
10340
10340
  if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
10341
- const error2 = this.createError(
10341
+ const error3 = this.createError(
10342
10342
  RangeError,
10343
10343
  "Max payload size exceeded",
10344
10344
  false,
10345
10345
  1009,
10346
10346
  "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
10347
10347
  );
10348
- cb(error2);
10348
+ cb(error3);
10349
10349
  return;
10350
10350
  }
10351
10351
  this._fragments.push(buf);
@@ -10396,14 +10396,14 @@ var require_receiver = __commonJS({
10396
10396
  } else {
10397
10397
  const buf = concat(fragments, messageLength);
10398
10398
  if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
10399
- const error2 = this.createError(
10399
+ const error3 = this.createError(
10400
10400
  Error,
10401
10401
  "invalid UTF-8 sequence",
10402
10402
  true,
10403
10403
  1007,
10404
10404
  "WS_ERR_INVALID_UTF8"
10405
10405
  );
10406
- cb(error2);
10406
+ cb(error3);
10407
10407
  return;
10408
10408
  }
10409
10409
  if (this._state === INFLATING || this._allowSynchronousEvents) {
@@ -10435,14 +10435,14 @@ var require_receiver = __commonJS({
10435
10435
  } else {
10436
10436
  const code = data.readUInt16BE(0);
10437
10437
  if (!isValidStatusCode(code)) {
10438
- const error2 = this.createError(
10438
+ const error3 = this.createError(
10439
10439
  RangeError,
10440
10440
  `invalid status code ${code}`,
10441
10441
  true,
10442
10442
  1002,
10443
10443
  "WS_ERR_INVALID_CLOSE_CODE"
10444
10444
  );
10445
- cb(error2);
10445
+ cb(error3);
10446
10446
  return;
10447
10447
  }
10448
10448
  const buf = new FastBuffer(
@@ -10451,14 +10451,14 @@ var require_receiver = __commonJS({
10451
10451
  data.length - 2
10452
10452
  );
10453
10453
  if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
10454
- const error2 = this.createError(
10454
+ const error3 = this.createError(
10455
10455
  Error,
10456
10456
  "invalid UTF-8 sequence",
10457
10457
  true,
10458
10458
  1007,
10459
10459
  "WS_ERR_INVALID_UTF8"
10460
10460
  );
10461
- cb(error2);
10461
+ cb(error3);
10462
10462
  return;
10463
10463
  }
10464
10464
  this._loop = false;
@@ -11167,10 +11167,10 @@ var require_event_target = __commonJS({
11167
11167
  callListener(handler, this, event);
11168
11168
  };
11169
11169
  } else if (type === "error") {
11170
- wrapper = function onError(error2) {
11170
+ wrapper = function onError(error3) {
11171
11171
  const event = new ErrorEvent("error", {
11172
- error: error2,
11173
- message: error2.message
11172
+ error: error3,
11173
+ message: error3.message
11174
11174
  });
11175
11175
  event[kTarget] = this;
11176
11176
  callListener(handler, this, event);
@@ -12295,7 +12295,7 @@ var require_stream = __commonJS({
12295
12295
  const data = !isBinary2 && duplex._readableState.objectMode ? msg.toString() : msg;
12296
12296
  if (!duplex.push(data)) ws.pause();
12297
12297
  });
12298
- ws.once("error", function error2(err) {
12298
+ ws.once("error", function error3(err) {
12299
12299
  if (duplex.destroyed) return;
12300
12300
  terminateOnDestroy = false;
12301
12301
  duplex.destroy(err);
@@ -12311,7 +12311,7 @@ var require_stream = __commonJS({
12311
12311
  return;
12312
12312
  }
12313
12313
  let called = false;
12314
- ws.once("error", function error2(err2) {
12314
+ ws.once("error", function error3(err2) {
12315
12315
  called = true;
12316
12316
  callback(err2);
12317
12317
  });
@@ -13233,9 +13233,9 @@ var require_codegen = __commonJS({
13233
13233
  }
13234
13234
  };
13235
13235
  var Throw = class extends Node {
13236
- constructor(error2) {
13236
+ constructor(error3) {
13237
13237
  super();
13238
- this.error = error2;
13238
+ this.error = error3;
13239
13239
  }
13240
13240
  render({ _n }) {
13241
13241
  return `throw ${this.error};` + _n;
@@ -13472,9 +13472,9 @@ var require_codegen = __commonJS({
13472
13472
  }
13473
13473
  };
13474
13474
  var Catch = class extends BlockNode {
13475
- constructor(error2) {
13475
+ constructor(error3) {
13476
13476
  super();
13477
- this.error = error2;
13477
+ this.error = error3;
13478
13478
  }
13479
13479
  render(opts) {
13480
13480
  return `catch(${this.error})` + super.render(opts);
@@ -13665,9 +13665,9 @@ var require_codegen = __commonJS({
13665
13665
  this._blockNode(node);
13666
13666
  this.code(tryBody);
13667
13667
  if (catchCode) {
13668
- const error2 = this.name("e");
13669
- this._currNode = node.catch = new Catch(error2);
13670
- catchCode(error2);
13668
+ const error3 = this.name("e");
13669
+ this._currNode = node.catch = new Catch(error3);
13670
+ catchCode(error3);
13671
13671
  }
13672
13672
  if (finallyCode) {
13673
13673
  this._currNode = node.finally = new Finally();
@@ -13676,8 +13676,8 @@ var require_codegen = __commonJS({
13676
13676
  return this._endBlockNode(Catch, Finally);
13677
13677
  }
13678
13678
  // `throw` statement
13679
- throw(error2) {
13680
- return this._leafNode(new Throw(error2));
13679
+ throw(error3) {
13680
+ return this._leafNode(new Throw(error3));
13681
13681
  }
13682
13682
  // start self-balancing block
13683
13683
  block(body, nodeCount) {
@@ -14033,10 +14033,10 @@ var require_errors = __commonJS({
14033
14033
  exports2.keyword$DataError = {
14034
14034
  message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
14035
14035
  };
14036
- function reportError(cxt, error2 = exports2.keywordError, errorPaths, overrideAllErrors) {
14036
+ function reportError(cxt, error3 = exports2.keywordError, errorPaths, overrideAllErrors) {
14037
14037
  const { it } = cxt;
14038
14038
  const { gen, compositeRule, allErrors } = it;
14039
- const errObj = errorObjectCode(cxt, error2, errorPaths);
14039
+ const errObj = errorObjectCode(cxt, error3, errorPaths);
14040
14040
  if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) {
14041
14041
  addError(gen, errObj);
14042
14042
  } else {
@@ -14044,10 +14044,10 @@ var require_errors = __commonJS({
14044
14044
  }
14045
14045
  }
14046
14046
  exports2.reportError = reportError;
14047
- function reportExtraError(cxt, error2 = exports2.keywordError, errorPaths) {
14047
+ function reportExtraError(cxt, error3 = exports2.keywordError, errorPaths) {
14048
14048
  const { it } = cxt;
14049
14049
  const { gen, compositeRule, allErrors } = it;
14050
- const errObj = errorObjectCode(cxt, error2, errorPaths);
14050
+ const errObj = errorObjectCode(cxt, error3, errorPaths);
14051
14051
  addError(gen, errObj);
14052
14052
  if (!(compositeRule || allErrors)) {
14053
14053
  returnErrors(it, names_1.default.vErrors);
@@ -14098,19 +14098,19 @@ var require_errors = __commonJS({
14098
14098
  schema: new codegen_1.Name("schema"),
14099
14099
  parentSchema: new codegen_1.Name("parentSchema")
14100
14100
  };
14101
- function errorObjectCode(cxt, error2, errorPaths) {
14101
+ function errorObjectCode(cxt, error3, errorPaths) {
14102
14102
  const { createErrors } = cxt.it;
14103
14103
  if (createErrors === false)
14104
14104
  return (0, codegen_1._)`{}`;
14105
- return errorObject(cxt, error2, errorPaths);
14105
+ return errorObject(cxt, error3, errorPaths);
14106
14106
  }
14107
- function errorObject(cxt, error2, errorPaths = {}) {
14107
+ function errorObject(cxt, error3, errorPaths = {}) {
14108
14108
  const { gen, it } = cxt;
14109
14109
  const keyValues = [
14110
14110
  errorInstancePath(it, errorPaths),
14111
14111
  errorSchemaPath(cxt, errorPaths)
14112
14112
  ];
14113
- extraErrorProps(cxt, error2, keyValues);
14113
+ extraErrorProps(cxt, error3, keyValues);
14114
14114
  return gen.object(...keyValues);
14115
14115
  }
14116
14116
  function errorInstancePath({ errorPath }, { instancePath }) {
@@ -17378,7 +17378,7 @@ var require_limitNumber = __commonJS({
17378
17378
  exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
17379
17379
  exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
17380
17380
  };
17381
- var error2 = {
17381
+ var error3 = {
17382
17382
  message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
17383
17383
  params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
17384
17384
  };
@@ -17387,7 +17387,7 @@ var require_limitNumber = __commonJS({
17387
17387
  type: "number",
17388
17388
  schemaType: "number",
17389
17389
  $data: true,
17390
- error: error2,
17390
+ error: error3,
17391
17391
  code(cxt) {
17392
17392
  const { keyword, data, schemaCode } = cxt;
17393
17393
  cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
@@ -17403,7 +17403,7 @@ var require_multipleOf = __commonJS({
17403
17403
  "use strict";
17404
17404
  Object.defineProperty(exports2, "__esModule", { value: true });
17405
17405
  var codegen_1 = require_codegen();
17406
- var error2 = {
17406
+ var error3 = {
17407
17407
  message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
17408
17408
  params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
17409
17409
  };
@@ -17412,7 +17412,7 @@ var require_multipleOf = __commonJS({
17412
17412
  type: "number",
17413
17413
  schemaType: "number",
17414
17414
  $data: true,
17415
- error: error2,
17415
+ error: error3,
17416
17416
  code(cxt) {
17417
17417
  const { gen, data, schemaCode, it } = cxt;
17418
17418
  const prec = it.opts.multipleOfPrecision;
@@ -17459,7 +17459,7 @@ var require_limitLength = __commonJS({
17459
17459
  var codegen_1 = require_codegen();
17460
17460
  var util_1 = require_util();
17461
17461
  var ucs2length_1 = require_ucs2length();
17462
- var error2 = {
17462
+ var error3 = {
17463
17463
  message({ keyword, schemaCode }) {
17464
17464
  const comp = keyword === "maxLength" ? "more" : "fewer";
17465
17465
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
@@ -17471,7 +17471,7 @@ var require_limitLength = __commonJS({
17471
17471
  type: "string",
17472
17472
  schemaType: "number",
17473
17473
  $data: true,
17474
- error: error2,
17474
+ error: error3,
17475
17475
  code(cxt) {
17476
17476
  const { keyword, data, schemaCode, it } = cxt;
17477
17477
  const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -17491,7 +17491,7 @@ var require_pattern = __commonJS({
17491
17491
  var code_1 = require_code2();
17492
17492
  var util_1 = require_util();
17493
17493
  var codegen_1 = require_codegen();
17494
- var error2 = {
17494
+ var error3 = {
17495
17495
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
17496
17496
  params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
17497
17497
  };
@@ -17500,7 +17500,7 @@ var require_pattern = __commonJS({
17500
17500
  type: "string",
17501
17501
  schemaType: "string",
17502
17502
  $data: true,
17503
- error: error2,
17503
+ error: error3,
17504
17504
  code(cxt) {
17505
17505
  const { gen, data, $data, schema, schemaCode, it } = cxt;
17506
17506
  const u = it.opts.unicodeRegExp ? "u" : "";
@@ -17526,7 +17526,7 @@ var require_limitProperties = __commonJS({
17526
17526
  "use strict";
17527
17527
  Object.defineProperty(exports2, "__esModule", { value: true });
17528
17528
  var codegen_1 = require_codegen();
17529
- var error2 = {
17529
+ var error3 = {
17530
17530
  message({ keyword, schemaCode }) {
17531
17531
  const comp = keyword === "maxProperties" ? "more" : "fewer";
17532
17532
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
@@ -17538,7 +17538,7 @@ var require_limitProperties = __commonJS({
17538
17538
  type: "object",
17539
17539
  schemaType: "number",
17540
17540
  $data: true,
17541
- error: error2,
17541
+ error: error3,
17542
17542
  code(cxt) {
17543
17543
  const { keyword, data, schemaCode } = cxt;
17544
17544
  const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -17557,7 +17557,7 @@ var require_required = __commonJS({
17557
17557
  var code_1 = require_code2();
17558
17558
  var codegen_1 = require_codegen();
17559
17559
  var util_1 = require_util();
17560
- var error2 = {
17560
+ var error3 = {
17561
17561
  message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
17562
17562
  params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
17563
17563
  };
@@ -17566,7 +17566,7 @@ var require_required = __commonJS({
17566
17566
  type: "object",
17567
17567
  schemaType: "array",
17568
17568
  $data: true,
17569
- error: error2,
17569
+ error: error3,
17570
17570
  code(cxt) {
17571
17571
  const { gen, schema, schemaCode, data, $data, it } = cxt;
17572
17572
  const { opts } = it;
@@ -17637,7 +17637,7 @@ var require_limitItems = __commonJS({
17637
17637
  "use strict";
17638
17638
  Object.defineProperty(exports2, "__esModule", { value: true });
17639
17639
  var codegen_1 = require_codegen();
17640
- var error2 = {
17640
+ var error3 = {
17641
17641
  message({ keyword, schemaCode }) {
17642
17642
  const comp = keyword === "maxItems" ? "more" : "fewer";
17643
17643
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
@@ -17649,7 +17649,7 @@ var require_limitItems = __commonJS({
17649
17649
  type: "array",
17650
17650
  schemaType: "number",
17651
17651
  $data: true,
17652
- error: error2,
17652
+ error: error3,
17653
17653
  code(cxt) {
17654
17654
  const { keyword, data, schemaCode } = cxt;
17655
17655
  const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -17680,7 +17680,7 @@ var require_uniqueItems = __commonJS({
17680
17680
  var codegen_1 = require_codegen();
17681
17681
  var util_1 = require_util();
17682
17682
  var equal_1 = require_equal();
17683
- var error2 = {
17683
+ var error3 = {
17684
17684
  message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
17685
17685
  params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}`
17686
17686
  };
@@ -17689,7 +17689,7 @@ var require_uniqueItems = __commonJS({
17689
17689
  type: "array",
17690
17690
  schemaType: "boolean",
17691
17691
  $data: true,
17692
- error: error2,
17692
+ error: error3,
17693
17693
  code(cxt) {
17694
17694
  const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
17695
17695
  if (!$data && !schema)
@@ -17746,14 +17746,14 @@ var require_const = __commonJS({
17746
17746
  var codegen_1 = require_codegen();
17747
17747
  var util_1 = require_util();
17748
17748
  var equal_1 = require_equal();
17749
- var error2 = {
17749
+ var error3 = {
17750
17750
  message: "must be equal to constant",
17751
17751
  params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
17752
17752
  };
17753
17753
  var def = {
17754
17754
  keyword: "const",
17755
17755
  $data: true,
17756
- error: error2,
17756
+ error: error3,
17757
17757
  code(cxt) {
17758
17758
  const { gen, data, $data, schemaCode, schema } = cxt;
17759
17759
  if ($data || schema && typeof schema == "object") {
@@ -17775,7 +17775,7 @@ var require_enum = __commonJS({
17775
17775
  var codegen_1 = require_codegen();
17776
17776
  var util_1 = require_util();
17777
17777
  var equal_1 = require_equal();
17778
- var error2 = {
17778
+ var error3 = {
17779
17779
  message: "must be equal to one of the allowed values",
17780
17780
  params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
17781
17781
  };
@@ -17783,7 +17783,7 @@ var require_enum = __commonJS({
17783
17783
  keyword: "enum",
17784
17784
  schemaType: "array",
17785
17785
  $data: true,
17786
- error: error2,
17786
+ error: error3,
17787
17787
  code(cxt) {
17788
17788
  const { gen, data, $data, schema, schemaCode, it } = cxt;
17789
17789
  if (!$data && schema.length === 0)
@@ -17862,7 +17862,7 @@ var require_additionalItems = __commonJS({
17862
17862
  exports2.validateAdditionalItems = void 0;
17863
17863
  var codegen_1 = require_codegen();
17864
17864
  var util_1 = require_util();
17865
- var error2 = {
17865
+ var error3 = {
17866
17866
  message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
17867
17867
  params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
17868
17868
  };
@@ -17871,7 +17871,7 @@ var require_additionalItems = __commonJS({
17871
17871
  type: "array",
17872
17872
  schemaType: ["boolean", "object"],
17873
17873
  before: "uniqueItems",
17874
- error: error2,
17874
+ error: error3,
17875
17875
  code(cxt) {
17876
17876
  const { parentSchema, it } = cxt;
17877
17877
  const { items } = parentSchema;
@@ -17990,7 +17990,7 @@ var require_items2020 = __commonJS({
17990
17990
  var util_1 = require_util();
17991
17991
  var code_1 = require_code2();
17992
17992
  var additionalItems_1 = require_additionalItems();
17993
- var error2 = {
17993
+ var error3 = {
17994
17994
  message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
17995
17995
  params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
17996
17996
  };
@@ -17999,7 +17999,7 @@ var require_items2020 = __commonJS({
17999
17999
  type: "array",
18000
18000
  schemaType: ["object", "boolean"],
18001
18001
  before: "uniqueItems",
18002
- error: error2,
18002
+ error: error3,
18003
18003
  code(cxt) {
18004
18004
  const { schema, parentSchema, it } = cxt;
18005
18005
  const { prefixItems } = parentSchema;
@@ -18023,7 +18023,7 @@ var require_contains = __commonJS({
18023
18023
  Object.defineProperty(exports2, "__esModule", { value: true });
18024
18024
  var codegen_1 = require_codegen();
18025
18025
  var util_1 = require_util();
18026
- var error2 = {
18026
+ var error3 = {
18027
18027
  message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
18028
18028
  params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
18029
18029
  };
@@ -18033,7 +18033,7 @@ var require_contains = __commonJS({
18033
18033
  schemaType: ["object", "boolean"],
18034
18034
  before: "uniqueItems",
18035
18035
  trackErrors: true,
18036
- error: error2,
18036
+ error: error3,
18037
18037
  code(cxt) {
18038
18038
  const { gen, schema, parentSchema, data, it } = cxt;
18039
18039
  let min;
@@ -18211,7 +18211,7 @@ var require_propertyNames = __commonJS({
18211
18211
  Object.defineProperty(exports2, "__esModule", { value: true });
18212
18212
  var codegen_1 = require_codegen();
18213
18213
  var util_1 = require_util();
18214
- var error2 = {
18214
+ var error3 = {
18215
18215
  message: "property name must be valid",
18216
18216
  params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
18217
18217
  };
@@ -18219,7 +18219,7 @@ var require_propertyNames = __commonJS({
18219
18219
  keyword: "propertyNames",
18220
18220
  type: "object",
18221
18221
  schemaType: ["object", "boolean"],
18222
- error: error2,
18222
+ error: error3,
18223
18223
  code(cxt) {
18224
18224
  const { gen, schema, data, it } = cxt;
18225
18225
  if ((0, util_1.alwaysValidSchema)(it, schema))
@@ -18256,7 +18256,7 @@ var require_additionalProperties = __commonJS({
18256
18256
  var codegen_1 = require_codegen();
18257
18257
  var names_1 = require_names();
18258
18258
  var util_1 = require_util();
18259
- var error2 = {
18259
+ var error3 = {
18260
18260
  message: "must NOT have additional properties",
18261
18261
  params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
18262
18262
  };
@@ -18266,7 +18266,7 @@ var require_additionalProperties = __commonJS({
18266
18266
  schemaType: ["boolean", "object"],
18267
18267
  allowUndefined: true,
18268
18268
  trackErrors: true,
18269
- error: error2,
18269
+ error: error3,
18270
18270
  code(cxt) {
18271
18271
  const { gen, schema, parentSchema, data, errsCount, it } = cxt;
18272
18272
  if (!errsCount)
@@ -18540,7 +18540,7 @@ var require_oneOf = __commonJS({
18540
18540
  Object.defineProperty(exports2, "__esModule", { value: true });
18541
18541
  var codegen_1 = require_codegen();
18542
18542
  var util_1 = require_util();
18543
- var error2 = {
18543
+ var error3 = {
18544
18544
  message: "must match exactly one schema in oneOf",
18545
18545
  params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
18546
18546
  };
@@ -18548,7 +18548,7 @@ var require_oneOf = __commonJS({
18548
18548
  keyword: "oneOf",
18549
18549
  schemaType: "array",
18550
18550
  trackErrors: true,
18551
- error: error2,
18551
+ error: error3,
18552
18552
  code(cxt) {
18553
18553
  const { gen, schema, parentSchema, it } = cxt;
18554
18554
  if (!Array.isArray(schema))
@@ -18625,7 +18625,7 @@ var require_if = __commonJS({
18625
18625
  Object.defineProperty(exports2, "__esModule", { value: true });
18626
18626
  var codegen_1 = require_codegen();
18627
18627
  var util_1 = require_util();
18628
- var error2 = {
18628
+ var error3 = {
18629
18629
  message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
18630
18630
  params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
18631
18631
  };
@@ -18633,7 +18633,7 @@ var require_if = __commonJS({
18633
18633
  keyword: "if",
18634
18634
  schemaType: ["object", "boolean"],
18635
18635
  trackErrors: true,
18636
- error: error2,
18636
+ error: error3,
18637
18637
  code(cxt) {
18638
18638
  const { gen, parentSchema, it } = cxt;
18639
18639
  if (parentSchema.then === void 0 && parentSchema.else === void 0) {
@@ -18958,7 +18958,7 @@ var require_unevaluatedProperties = __commonJS({
18958
18958
  var codegen_1 = require_codegen();
18959
18959
  var util_1 = require_util();
18960
18960
  var names_1 = require_names();
18961
- var error2 = {
18961
+ var error3 = {
18962
18962
  message: "must NOT have unevaluated properties",
18963
18963
  params: ({ params }) => (0, codegen_1._)`{unevaluatedProperty: ${params.unevaluatedProperty}}`
18964
18964
  };
@@ -18967,7 +18967,7 @@ var require_unevaluatedProperties = __commonJS({
18967
18967
  type: "object",
18968
18968
  schemaType: ["boolean", "object"],
18969
18969
  trackErrors: true,
18970
- error: error2,
18970
+ error: error3,
18971
18971
  code(cxt) {
18972
18972
  const { gen, schema, data, errsCount, it } = cxt;
18973
18973
  if (!errsCount)
@@ -19023,7 +19023,7 @@ var require_unevaluatedItems = __commonJS({
19023
19023
  Object.defineProperty(exports2, "__esModule", { value: true });
19024
19024
  var codegen_1 = require_codegen();
19025
19025
  var util_1 = require_util();
19026
- var error2 = {
19026
+ var error3 = {
19027
19027
  message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
19028
19028
  params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
19029
19029
  };
@@ -19031,7 +19031,7 @@ var require_unevaluatedItems = __commonJS({
19031
19031
  keyword: "unevaluatedItems",
19032
19032
  type: "array",
19033
19033
  schemaType: ["boolean", "object"],
19034
- error: error2,
19034
+ error: error3,
19035
19035
  code(cxt) {
19036
19036
  const { gen, schema, data, it } = cxt;
19037
19037
  const items = it.items || 0;
@@ -19078,7 +19078,7 @@ var require_format = __commonJS({
19078
19078
  "use strict";
19079
19079
  Object.defineProperty(exports2, "__esModule", { value: true });
19080
19080
  var codegen_1 = require_codegen();
19081
- var error2 = {
19081
+ var error3 = {
19082
19082
  message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
19083
19083
  params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
19084
19084
  };
@@ -19087,7 +19087,7 @@ var require_format = __commonJS({
19087
19087
  type: ["number", "string"],
19088
19088
  schemaType: "string",
19089
19089
  $data: true,
19090
- error: error2,
19090
+ error: error3,
19091
19091
  code(cxt, ruleType) {
19092
19092
  const { gen, data, $data, schema, schemaCode, it } = cxt;
19093
19093
  const { opts, errSchemaPath, schemaEnv, self } = it;
@@ -19248,7 +19248,7 @@ var require_discriminator = __commonJS({
19248
19248
  var compile_1 = require_compile();
19249
19249
  var ref_error_1 = require_ref_error();
19250
19250
  var util_1 = require_util();
19251
- var error2 = {
19251
+ var error3 = {
19252
19252
  message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
19253
19253
  params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
19254
19254
  };
@@ -19256,7 +19256,7 @@ var require_discriminator = __commonJS({
19256
19256
  keyword: "discriminator",
19257
19257
  type: "object",
19258
19258
  schemaType: "object",
19259
- error: error2,
19259
+ error: error3,
19260
19260
  code(cxt) {
19261
19261
  const { gen, data, schema, parentSchema, it } = cxt;
19262
19262
  const { oneOf } = parentSchema;
@@ -20287,7 +20287,7 @@ var require_limit = __commonJS({
20287
20287
  formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
20288
20288
  formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
20289
20289
  };
20290
- var error2 = {
20290
+ var error3 = {
20291
20291
  message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
20292
20292
  params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
20293
20293
  };
@@ -20296,7 +20296,7 @@ var require_limit = __commonJS({
20296
20296
  type: "string",
20297
20297
  schemaType: "string",
20298
20298
  $data: true,
20299
- error: error2,
20299
+ error: error3,
20300
20300
  code(cxt) {
20301
20301
  const { gen, data, schemaCode, keyword, it } = cxt;
20302
20302
  const { opts, self } = it;
@@ -25921,11 +25921,11 @@ var SocketWithUpgrade = class extends SocketWithoutUpgrade {
25921
25921
  transport = null;
25922
25922
  }
25923
25923
  const onerror = (err) => {
25924
- const error2 = new Error("probe error: " + err);
25925
- error2.transport = transport.name;
25924
+ const error3 = new Error("probe error: " + err);
25925
+ error3.transport = transport.name;
25926
25926
  freezeTransport();
25927
25927
  debug6('probe transport "%s" failed because of error: %s', name, err);
25928
- this.emitReserved("upgradeError", error2);
25928
+ this.emitReserved("upgradeError", error3);
25929
25929
  };
25930
25930
  function onTransportClose() {
25931
25931
  onerror("transport closed");
@@ -27696,6 +27696,8 @@ var KumaClient = class {
27696
27696
  this.uptimeCache = {};
27697
27697
  // BUG-02 fix: buffer statusPageList pushed by Kuma during afterLogin
27698
27698
  this.statusPageCache = null;
27699
+ // Buffer notificationList pushed by Kuma during afterLogin
27700
+ this.notificationCache = null;
27699
27701
  this.url = url2;
27700
27702
  this.socket = lookup(url2, {
27701
27703
  transports: ["websocket"],
@@ -27719,6 +27721,9 @@ var KumaClient = class {
27719
27721
  this.socket.on("statusPageList", (data) => {
27720
27722
  this.statusPageCache = data;
27721
27723
  });
27724
+ this.socket.on("notificationList", (data) => {
27725
+ this.notificationCache = Array.isArray(data) ? data : [];
27726
+ });
27722
27727
  }
27723
27728
  /**
27724
27729
  * Wait for a server-pushed event (not a callback response).
@@ -27963,6 +27968,110 @@ var KumaClient = class {
27963
27968
  });
27964
27969
  });
27965
27970
  }
27971
+ // ---------------------------------------------------------------------------
27972
+ // Notifications
27973
+ // ---------------------------------------------------------------------------
27974
+ /**
27975
+ * Return the notification list pushed by Kuma after login.
27976
+ * Falls back to a short waitFor if the push hasn't arrived yet.
27977
+ */
27978
+ async getNotificationList() {
27979
+ if (this.notificationCache !== null) {
27980
+ return this.notificationCache;
27981
+ }
27982
+ return new Promise((resolve) => {
27983
+ const timer = setTimeout(() => resolve([]), 5e3);
27984
+ this.socket.once("notificationList", (data) => {
27985
+ clearTimeout(timer);
27986
+ const list = Array.isArray(data) ? data : [];
27987
+ this.notificationCache = list;
27988
+ resolve(list);
27989
+ });
27990
+ });
27991
+ }
27992
+ /**
27993
+ * Create a new notification channel, or update one if id is provided.
27994
+ * Returns the id of the created/updated notification.
27995
+ *
27996
+ * Server event: addNotification(notification, id|null, callback)
27997
+ * callback: { ok: boolean, id?: number, msg?: string }
27998
+ */
27999
+ async addNotification(payload, id = null) {
28000
+ return new Promise((resolve, reject) => {
28001
+ const timer = setTimeout(
28002
+ () => reject(new Error("addNotification timeout")),
28003
+ 1e4
28004
+ );
28005
+ this.socket.emit(
28006
+ "addNotification",
28007
+ payload,
28008
+ id,
28009
+ (result) => {
28010
+ clearTimeout(timer);
28011
+ if (!result.ok) {
28012
+ reject(new Error(result.msg ?? "Failed to create notification"));
28013
+ return;
28014
+ }
28015
+ resolve(result.id);
28016
+ }
28017
+ );
28018
+ });
28019
+ }
28020
+ /**
28021
+ * Delete a notification channel by id.
28022
+ */
28023
+ async deleteNotification(id) {
28024
+ return new Promise((resolve, reject) => {
28025
+ const timer = setTimeout(
28026
+ () => reject(new Error("deleteNotification timeout")),
28027
+ 1e4
28028
+ );
28029
+ this.socket.emit(
28030
+ "deleteNotification",
28031
+ id,
28032
+ (result) => {
28033
+ clearTimeout(timer);
28034
+ if (!result.ok) {
28035
+ reject(new Error(result.msg ?? "Failed to delete notification"));
28036
+ return;
28037
+ }
28038
+ resolve();
28039
+ }
28040
+ );
28041
+ });
28042
+ }
28043
+ /**
28044
+ * Assign a notification to a monitor.
28045
+ * Uses addMonitorTag-style approach: sends the notificationIDList via
28046
+ * the `editMonitor` event with the full monitor object + updated notificationIDList.
28047
+ * `notificationIDList` is { [notifId]: true } — Kuma's internal format.
28048
+ */
28049
+ async setMonitorNotification(monitorId, notificationId, enabled, monitorMap) {
28050
+ const existing = monitorMap[String(monitorId)];
28051
+ if (!existing) {
28052
+ throw new Error(`Monitor ${monitorId} not found`);
28053
+ }
28054
+ const notifIdList = {};
28055
+ notifIdList[String(notificationId)] = enabled;
28056
+ return new Promise((resolve, reject) => {
28057
+ const timer = setTimeout(
28058
+ () => reject(new Error("setMonitorNotification timeout")),
28059
+ 1e4
28060
+ );
28061
+ this.socket.emit(
28062
+ "editMonitor",
28063
+ { ...existing, id: monitorId, notificationIDList: notifIdList },
28064
+ (result) => {
28065
+ clearTimeout(timer);
28066
+ if (!result.ok) {
28067
+ reject(new Error(result.msg ?? "Failed to update monitor notification"));
28068
+ return;
28069
+ }
28070
+ resolve();
28071
+ }
28072
+ );
28073
+ });
28074
+ }
27966
28075
  disconnect() {
27967
28076
  this.socket.disconnect();
27968
28077
  }
@@ -28328,8 +28437,8 @@ var attemptifySync = (fn, options) => {
28328
28437
  return function attemptified(...args) {
28329
28438
  try {
28330
28439
  return fn.apply(void 0, args);
28331
- } catch (error2) {
28332
- return onError(error2);
28440
+ } catch (error3) {
28441
+ return onError(error3);
28333
28442
  }
28334
28443
  };
28335
28444
  };
@@ -28346,11 +28455,11 @@ var retryifyAsync = (fn, options) => {
28346
28455
  const interval = options2.interval ?? RETRY_INTERVAL;
28347
28456
  const timestamp = Date.now() + timeout;
28348
28457
  return function attempt(...args) {
28349
- return fn.apply(void 0, args).catch((error2) => {
28350
- if (!isRetriable(error2))
28351
- throw error2;
28458
+ return fn.apply(void 0, args).catch((error3) => {
28459
+ if (!isRetriable(error3))
28460
+ throw error3;
28352
28461
  if (Date.now() >= timestamp)
28353
- throw error2;
28462
+ throw error3;
28354
28463
  const delay = Math.round(interval * Math.random());
28355
28464
  if (delay > 0) {
28356
28465
  const delayPromise = new Promise((resolve) => setTimeout(resolve, delay));
@@ -28374,11 +28483,11 @@ var retryifySync = (fn, options) => {
28374
28483
  while (true) {
28375
28484
  try {
28376
28485
  return fn.apply(void 0, args);
28377
- } catch (error2) {
28378
- if (!isRetriable(error2))
28379
- throw error2;
28486
+ } catch (error3) {
28487
+ if (!isRetriable(error3))
28488
+ throw error3;
28380
28489
  if (Date.now() >= timestamp)
28381
- throw error2;
28490
+ throw error3;
28382
28491
  continue;
28383
28492
  }
28384
28493
  }
@@ -28393,33 +28502,33 @@ var import_node_process2 = __toESM(require("process"), 1);
28393
28502
  // node_modules/stubborn-fs/dist/handlers.js
28394
28503
  var Handlers = {
28395
28504
  /* API */
28396
- isChangeErrorOk: (error2) => {
28397
- if (!Handlers.isNodeError(error2))
28505
+ isChangeErrorOk: (error3) => {
28506
+ if (!Handlers.isNodeError(error3))
28398
28507
  return false;
28399
- const { code } = error2;
28508
+ const { code } = error3;
28400
28509
  if (code === "ENOSYS")
28401
28510
  return true;
28402
28511
  if (!IS_USER_ROOT && (code === "EINVAL" || code === "EPERM"))
28403
28512
  return true;
28404
28513
  return false;
28405
28514
  },
28406
- isNodeError: (error2) => {
28407
- return error2 instanceof Error;
28515
+ isNodeError: (error3) => {
28516
+ return error3 instanceof Error;
28408
28517
  },
28409
- isRetriableError: (error2) => {
28410
- if (!Handlers.isNodeError(error2))
28518
+ isRetriableError: (error3) => {
28519
+ if (!Handlers.isNodeError(error3))
28411
28520
  return false;
28412
- const { code } = error2;
28521
+ const { code } = error3;
28413
28522
  if (code === "EMFILE" || code === "ENFILE" || code === "EAGAIN" || code === "EBUSY" || code === "EACCESS" || code === "EACCES" || code === "EACCS" || code === "EPERM")
28414
28523
  return true;
28415
28524
  return false;
28416
28525
  },
28417
- onChangeError: (error2) => {
28418
- if (!Handlers.isNodeError(error2))
28419
- throw error2;
28420
- if (Handlers.isChangeErrorOk(error2))
28526
+ onChangeError: (error3) => {
28527
+ if (!Handlers.isNodeError(error3))
28528
+ throw error3;
28529
+ if (Handlers.isChangeErrorOk(error3))
28421
28530
  return;
28422
- throw error2;
28531
+ throw error3;
28423
28532
  }
28424
28533
  };
28425
28534
  var handlers_default = Handlers;
@@ -28686,11 +28795,11 @@ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
28686
28795
  }
28687
28796
  try {
28688
28797
  dist_default.retry.renameSync(retryOptions)(tempPath, filePath);
28689
- } catch (error2) {
28690
- if (!isException(error2))
28691
- throw error2;
28692
- if (error2.code !== "ENAMETOOLONG")
28693
- throw error2;
28798
+ } catch (error3) {
28799
+ if (!isException(error3))
28800
+ throw error3;
28801
+ if (error3.code !== "ENAMETOOLONG")
28802
+ throw error3;
28694
28803
  dist_default.retry.renameSync(retryOptions)(tempPath, temp_default.truncate(filePath));
28695
28804
  }
28696
28805
  tempDisposer();
@@ -29088,13 +29197,13 @@ var Conf = class {
29088
29197
  return Object.assign(createPlainObject(), deserializedData);
29089
29198
  };
29090
29199
  return parseStore(dataString);
29091
- } catch (error2) {
29092
- if (error2?.code === "ENOENT") {
29200
+ } catch (error3) {
29201
+ if (error3?.code === "ENOENT") {
29093
29202
  this._ensureDirectory();
29094
29203
  return createPlainObject();
29095
29204
  }
29096
29205
  if (this.#options.clearInvalidConfig) {
29097
- const errorInstance = error2;
29206
+ const errorInstance = error3;
29098
29207
  if (errorInstance.name === "SyntaxError") {
29099
29208
  return createPlainObject();
29100
29209
  }
@@ -29105,7 +29214,7 @@ var Conf = class {
29105
29214
  return createPlainObject();
29106
29215
  }
29107
29216
  }
29108
- throw error2;
29217
+ throw error3;
29109
29218
  }
29110
29219
  }
29111
29220
  set store(value2) {
@@ -29269,12 +29378,12 @@ var Conf = class {
29269
29378
  } else {
29270
29379
  try {
29271
29380
  writeFileSync(this.path, data, { mode: this.#options.configFileMode });
29272
- } catch (error2) {
29273
- if (error2?.code === "EXDEV") {
29381
+ } catch (error3) {
29382
+ if (error3?.code === "EXDEV") {
29274
29383
  import_node_fs3.default.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
29275
29384
  return;
29276
29385
  }
29277
- throw error2;
29386
+ throw error3;
29278
29387
  }
29279
29388
  }
29280
29389
  }
@@ -29328,9 +29437,9 @@ var Conf = class {
29328
29437
  this._set(MIGRATION_KEY, version);
29329
29438
  previousMigratedVersion = version;
29330
29439
  storeBackup = structuredClone(this.store);
29331
- } catch (error2) {
29440
+ } catch (error3) {
29332
29441
  this.store = storeBackup;
29333
- const errorMessage = error2 instanceof Error ? error2.message : String(error2);
29442
+ const errorMessage = error3 instanceof Error ? error3.message : String(error3);
29334
29443
  throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${errorMessage}`);
29335
29444
  }
29336
29445
  }
@@ -30575,6 +30684,48 @@ ${source_default.dim("Examples:")}
30575
30684
  handleError(err, opts);
30576
30685
  }
30577
30686
  });
30687
+ monitors.command("set-notification <id>").description("Assign or remove a notification channel from a monitor").requiredOption("--notification-id <nid>", "ID of the notification channel to assign").option("--remove", "Remove the notification instead of assigning it").option("--json", "Output as JSON ({ ok, data })").addHelpText(
30688
+ "after",
30689
+ `
30690
+ ${source_default.dim("Examples:")}
30691
+ ${source_default.cyan("kuma monitors set-notification 42 --notification-id 3")}
30692
+ ${source_default.cyan("kuma monitors set-notification 42 --notification-id 3 --remove")}
30693
+ ${source_default.cyan("kuma monitors set-notification 42 --notification-id 3 --json")}
30694
+
30695
+ ${source_default.dim("Bulk assign via pipe:")}
30696
+ ${source_default.cyan("kuma monitors list --tag Production --json | jq '.data[].id' | xargs -I{} kuma monitors set-notification {} --notification-id 3")}
30697
+ `
30698
+ ).action(async (id, opts) => {
30699
+ const config = getConfig();
30700
+ if (!config) requireAuth(opts);
30701
+ const json = isJsonMode(opts);
30702
+ const monitorId = parseInt(id, 10);
30703
+ const notifId = parseInt(opts.notificationId, 10);
30704
+ if (isNaN(monitorId)) {
30705
+ handleError(new Error(`Invalid monitor ID: ${id}`), opts);
30706
+ }
30707
+ if (isNaN(notifId)) {
30708
+ handleError(new Error(`Invalid notification ID: ${opts.notificationId}`), opts);
30709
+ }
30710
+ try {
30711
+ const client = await createAuthenticatedClient(config.url, config.token);
30712
+ const monitorMap = await client.getMonitorList();
30713
+ await client.setMonitorNotification(
30714
+ monitorId,
30715
+ notifId,
30716
+ !opts.remove,
30717
+ monitorMap
30718
+ );
30719
+ client.disconnect();
30720
+ const action = opts.remove ? "removed from" : "assigned to";
30721
+ if (json) {
30722
+ jsonOut({ monitorId, notificationId: notifId, action: opts.remove ? "removed" : "assigned" });
30723
+ }
30724
+ success(`Notification ${notifId} ${action} monitor ${monitorId}`);
30725
+ } catch (err) {
30726
+ handleError(err, opts);
30727
+ }
30728
+ });
30578
30729
  }
30579
30730
 
30580
30731
  // src/commands/heartbeat.ts
@@ -30779,7 +30930,7 @@ ${source_default.bold(`Upgrading kuma-cli`)} ${source_default.dim(`v${current}`)
30779
30930
  );
30780
30931
  }
30781
30932
  try {
30782
- (0, import_child_process.execSync)("npm install -g github:BlackAsteroid/kuma-cli", {
30933
+ (0, import_child_process.execSync)("npm install -g @blackasteroid/kuma-cli@latest", {
30783
30934
  stdio: json ? "pipe" : "inherit"
30784
30935
  });
30785
30936
  } catch (err) {
@@ -30811,6 +30962,189 @@ ${source_default.bold(`Upgrading kuma-cli`)} ${source_default.dim(`v${current}`)
30811
30962
  });
30812
30963
  }
30813
30964
 
30965
+ // src/commands/notifications.ts
30966
+ function notificationsCommand(program3) {
30967
+ const notifications = program3.command("notifications").description("Manage notification channels (Discord, Telegram, webhook, ...)").addHelpText(
30968
+ "after",
30969
+ `
30970
+ ${source_default.dim("Subcommands:")}
30971
+ ${source_default.cyan("notifications list")} List all notification channels
30972
+ ${source_default.cyan("notifications create --type discord ...")} Create a new notification channel
30973
+ ${source_default.cyan("notifications delete <id>")} Delete a notification channel
30974
+
30975
+ ${source_default.dim("Run")} ${source_default.cyan("kuma notifications <subcommand> --help")} ${source_default.dim("for examples.")}
30976
+ `
30977
+ );
30978
+ notifications.command("list").description("List all configured notification channels with their IDs and types").option("--json", "Output as JSON ({ ok, data })").addHelpText(
30979
+ "after",
30980
+ `
30981
+ ${source_default.dim("Examples:")}
30982
+ ${source_default.cyan("kuma notifications list")}
30983
+ ${source_default.cyan("kuma notifications list --json")}
30984
+ ${source_default.cyan("kuma notifications list --json | jq '.data[] | {id, name}'")}
30985
+ `
30986
+ ).action(async (opts) => {
30987
+ const config = getConfig();
30988
+ if (!config) requireAuth(opts);
30989
+ const json = isJsonMode(opts);
30990
+ try {
30991
+ const client = await createAuthenticatedClient(config.url, config.token);
30992
+ const list = await client.getNotificationList();
30993
+ client.disconnect();
30994
+ if (json) {
30995
+ const enriched = list.map((n) => {
30996
+ try {
30997
+ const parsed = JSON.parse(n.config);
30998
+ return { ...n, config: parsed };
30999
+ } catch {
31000
+ return n;
31001
+ }
31002
+ });
31003
+ jsonOut(enriched);
31004
+ }
31005
+ if (list.length === 0) {
31006
+ console.log("No notification channels configured.");
31007
+ return;
31008
+ }
31009
+ const table = createTable(["ID", "Name", "Type", "Default", "Active"]);
31010
+ list.forEach((n) => {
31011
+ let type = "\u2014";
31012
+ try {
31013
+ const parsed = JSON.parse(n.config);
31014
+ type = parsed.type ?? "\u2014";
31015
+ } catch {
31016
+ }
31017
+ table.push([
31018
+ String(n.id),
31019
+ n.name,
31020
+ type,
31021
+ n.isDefault ? source_default.green("Yes") : source_default.gray("No"),
31022
+ n.active ? source_default.green("Yes") : source_default.red("No")
31023
+ ]);
31024
+ });
31025
+ console.log(table.toString());
31026
+ console.log(`
31027
+ ${list.length} notification channel(s)`);
31028
+ } catch (err) {
31029
+ handleError(err, opts);
31030
+ }
31031
+ });
31032
+ notifications.command("create").description("Create a new notification channel").requiredOption("--type <type>", "Notification type: discord, telegram, slack, webhook, ...").requiredOption("--name <name>", "Friendly name for this notification channel").option("--discord-webhook <url>", "Discord webhook URL (required for --type discord)").option("--discord-username <name>", "Discord bot display name (optional)").option("--telegram-token <token>", "Telegram bot token (required for --type telegram)").option("--telegram-chat-id <id>", "Telegram chat ID (required for --type telegram)").option("--slack-webhook <url>", "Slack webhook URL (required for --type slack)").option("--webhook-url <url>", "Webhook URL (required for --type webhook)").option("--webhook-content-type <type>", "Webhook content type (default: application/json)", "application/json").option("--default", "Enable this notification by default on all new monitors").option("--apply-existing", "Apply this notification to all existing monitors immediately").option("--json", "Output as JSON ({ ok, data })").addHelpText(
31033
+ "after",
31034
+ `
31035
+ ${source_default.dim("Examples:")}
31036
+ ${source_default.cyan('kuma notifications create --type discord --name "Alerts" --discord-webhook https://discord.com/api/webhooks/...')}
31037
+ ${source_default.cyan('kuma notifications create --type telegram --name "TG" --telegram-token 123:ABC --telegram-chat-id -100...')}
31038
+ ${source_default.cyan('kuma notifications create --type webhook --name "My Hook" --webhook-url https://example.com/hook')}
31039
+ ${source_default.cyan('kuma notifications create --type discord --name "Default" --discord-webhook $URL --default --apply-existing')}
31040
+
31041
+ ${source_default.dim("Supported types:")}
31042
+ discord, telegram, slack, webhook, gotify, ntfy, pushover, matrix, mattermost, teams ...
31043
+ (full list at https://uptime.kuma.pet/docs)
31044
+ `
31045
+ ).action(async (opts) => {
31046
+ const config = getConfig();
31047
+ if (!config) requireAuth(opts);
31048
+ const json = isJsonMode(opts);
31049
+ const payload = {
31050
+ name: opts.name,
31051
+ type: opts.type,
31052
+ isDefault: opts.default ?? false,
31053
+ active: true,
31054
+ applyExisting: opts.applyExisting ?? false
31055
+ };
31056
+ switch (opts.type.toLowerCase()) {
31057
+ case "discord":
31058
+ if (!opts.discordWebhook) {
31059
+ handleError(new Error("--discord-webhook is required for --type discord"), opts);
31060
+ }
31061
+ payload.discordWebhookUrl = opts.discordWebhook;
31062
+ if (opts.discordUsername) payload.discordUsername = opts.discordUsername;
31063
+ break;
31064
+ case "telegram":
31065
+ if (!opts.telegramToken || !opts.telegramChatId) {
31066
+ handleError(new Error("--telegram-token and --telegram-chat-id are required for --type telegram"), opts);
31067
+ }
31068
+ payload.telegramBotToken = opts.telegramToken;
31069
+ payload.telegramChatID = opts.telegramChatId;
31070
+ break;
31071
+ case "slack":
31072
+ if (!opts.slackWebhook) {
31073
+ handleError(new Error("--slack-webhook is required for --type slack"), opts);
31074
+ }
31075
+ payload.slackwebhookURL = opts.slackWebhook;
31076
+ break;
31077
+ case "webhook":
31078
+ if (!opts.webhookUrl) {
31079
+ handleError(new Error("--webhook-url is required for --type webhook"), opts);
31080
+ }
31081
+ payload.webhookURL = opts.webhookUrl;
31082
+ payload.webhookContentType = opts.webhookContentType ?? "application/json";
31083
+ break;
31084
+ default:
31085
+ if (!json) {
31086
+ console.log(source_default.yellow(
31087
+ `\u26A0\uFE0F Type "${opts.type}" may require additional fields not exposed as flags.
31088
+ The notification will be created but may need manual config in the UI.`
31089
+ ));
31090
+ }
31091
+ }
31092
+ try {
31093
+ const client = await createAuthenticatedClient(config.url, config.token);
31094
+ const id = await client.addNotification(payload);
31095
+ client.disconnect();
31096
+ if (json) {
31097
+ jsonOut({ id, name: opts.name, type: opts.type });
31098
+ }
31099
+ success(`Notification "${opts.name}" created (ID: ${id})`);
31100
+ } catch (err) {
31101
+ handleError(err, opts);
31102
+ }
31103
+ });
31104
+ notifications.command("delete <id>").description("Permanently delete a notification channel").option("--force", "Skip the confirmation prompt").option("--json", "Output as JSON ({ ok, data })").addHelpText(
31105
+ "after",
31106
+ `
31107
+ ${source_default.dim("Examples:")}
31108
+ ${source_default.cyan("kuma notifications delete 3")}
31109
+ ${source_default.cyan("kuma notifications delete 3 --force")}
31110
+ ${source_default.cyan("kuma notifications delete 3 --json")}
31111
+ `
31112
+ ).action(async (id, opts) => {
31113
+ const config = getConfig();
31114
+ if (!config) requireAuth(opts);
31115
+ const json = isJsonMode(opts);
31116
+ const notifId = parseInt(id, 10);
31117
+ if (isNaN(notifId)) {
31118
+ handleError(new Error(`Invalid notification ID: ${id}`), opts);
31119
+ }
31120
+ if (!opts.force && !json) {
31121
+ const enquirer3 = await Promise.resolve().then(() => __toESM(require_enquirer()));
31122
+ const { prompt: prompt3 } = enquirer3.default;
31123
+ const { confirm } = await prompt3({
31124
+ type: "confirm",
31125
+ name: "confirm",
31126
+ message: `Delete notification ${id}?`,
31127
+ initial: false
31128
+ });
31129
+ if (!confirm) {
31130
+ console.log("Aborted.");
31131
+ return;
31132
+ }
31133
+ }
31134
+ try {
31135
+ const client = await createAuthenticatedClient(config.url, config.token);
31136
+ await client.deleteNotification(notifId);
31137
+ client.disconnect();
31138
+ if (json) {
31139
+ jsonOut({ id: notifId, deleted: true });
31140
+ }
31141
+ success(`Notification ${id} deleted`);
31142
+ } catch (err) {
31143
+ handleError(err, opts);
31144
+ }
31145
+ });
31146
+ }
31147
+
30814
31148
  // src/index.ts
30815
31149
  var program2 = new Command();
30816
31150
  program2.name("kuma").description("Manage Uptime Kuma monitors, heartbeats, and status pages from your terminal.").version("0.1.0").addHelpText(
@@ -30881,6 +31215,7 @@ monitorsCommand(program2);
30881
31215
  heartbeatCommand(program2);
30882
31216
  statusPagesCommand(program2);
30883
31217
  upgradeCommand(program2);
31218
+ notificationsCommand(program2);
30884
31219
  program2.parse(process.argv);
30885
31220
  /*! Bundled license information:
30886
31221