kayvee 3.16.0 → 3.18.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/test/router.ts CHANGED
@@ -55,41 +55,61 @@ routes:
55
55
  stat_type: "gauge"
56
56
  `;
57
57
  const expected = [
58
- new router.Rule("rule-one", {title: ["authorize-app"]}, {
59
- type: "notifications",
60
- channel: "%{foo.bar}",
61
- icon: ":rocket:",
62
- message: "authorized %{foo.bar} in Hogwarts",
63
- user: "@fishman",
64
- }),
65
- new router.Rule("rule-two", {"foo.bar": ["multiple", "matches"], baz: ["whatever"]}, {
66
- type: "alerts",
67
- series: "other-series",
68
- dimensions: ["baz"],
69
- stat_type: "gauge",
70
- value_field: "value",
71
- }),
72
- new router.Rule("rule-three", {"foo.bar": ["multiple", "matches"], baz: ["whatever"]}, {
73
- type: "alerts",
74
- series: "other-series",
75
- dimensions: ["baz"],
76
- stat_type: "gauge",
77
- value_field: "hello",
78
- }),
79
- new router.Rule("rule-four", {"foo.bar": ["multiple", "matches"], baz: ["whatever"]}, {
80
- type: "alerts",
81
- series: "other-series",
82
- dimensions: [],
83
- stat_type: "gauge",
84
- value_field: "value",
85
- }),
86
- new router.Rule("rule-five", {"foo.bar": [true], baz: [false]}, {
87
- type: "alerts",
88
- series: "other-series",
89
- dimensions: [],
90
- stat_type: "gauge",
91
- value_field: "value",
92
- }),
58
+ new router.Rule(
59
+ "rule-one",
60
+ { title: ["authorize-app"] },
61
+ {
62
+ type: "notifications",
63
+ channel: "%{foo.bar}",
64
+ icon: ":rocket:",
65
+ message: "authorized %{foo.bar} in Hogwarts",
66
+ user: "@fishman",
67
+ },
68
+ ),
69
+ new router.Rule(
70
+ "rule-two",
71
+ { "foo.bar": ["multiple", "matches"], baz: ["whatever"] },
72
+ {
73
+ type: "alerts",
74
+ series: "other-series",
75
+ dimensions: ["baz"],
76
+ stat_type: "gauge",
77
+ value_field: "value",
78
+ },
79
+ ),
80
+ new router.Rule(
81
+ "rule-three",
82
+ { "foo.bar": ["multiple", "matches"], baz: ["whatever"] },
83
+ {
84
+ type: "alerts",
85
+ series: "other-series",
86
+ dimensions: ["baz"],
87
+ stat_type: "gauge",
88
+ value_field: "hello",
89
+ },
90
+ ),
91
+ new router.Rule(
92
+ "rule-four",
93
+ { "foo.bar": ["multiple", "matches"], baz: ["whatever"] },
94
+ {
95
+ type: "alerts",
96
+ series: "other-series",
97
+ dimensions: [],
98
+ stat_type: "gauge",
99
+ value_field: "value",
100
+ },
101
+ ),
102
+ new router.Rule(
103
+ "rule-five",
104
+ { "foo.bar": [true], baz: [false] },
105
+ {
106
+ type: "alerts",
107
+ series: "other-series",
108
+ dimensions: [],
109
+ stat_type: "gauge",
110
+ value_field: "value",
111
+ },
112
+ ),
93
113
  ];
94
114
  const actual = new router.Router();
95
115
  actual._loadConfigString(conf);
@@ -108,7 +128,7 @@ routes:
108
128
  `;
109
129
 
110
130
  // Make sure the template works
111
- const conf = confTmpl("\"valid\"");
131
+ const conf = confTmpl('"valid"');
112
132
  const actual = new router.Router();
113
133
  assert.doesNotThrow(() => actual._loadConfigString(conf));
114
134
 
@@ -116,11 +136,10 @@ routes:
116
136
  const invalidConf = confTmpl(invalidVal);
117
137
  assert.throws(() => actual._loadConfigString(invalidConf));
118
138
  }
119
- assert.throws(() => actual._loadConfigString(confTmpl("\"\"")));
139
+ assert.throws(() => actual._loadConfigString(confTmpl('""')));
120
140
  return;
121
141
  });
122
142
 
123
-
124
143
  it("rejects duplicates in matchers", () => {
125
144
  const confTmpl = (v) => `
126
145
  routes:
@@ -133,10 +152,10 @@ routes:
133
152
  `;
134
153
 
135
154
  const actual = new router.Router();
136
- const validConf = confTmpl("\"non-repeated\", \"name\"");
155
+ const validConf = confTmpl('"non-repeated", "name"');
137
156
  assert.doesNotThrow(() => actual._loadConfigString(validConf));
138
157
 
139
- const invalidConf = confTmpl("\"repeated\", \"repeated\", \"name\"");
158
+ const invalidConf = confTmpl('"repeated", "repeated", "name"');
140
159
  assert.throws(() => actual._loadConfigString(invalidConf));
141
160
  });
142
161
 
@@ -155,13 +174,13 @@ routes:
155
174
  `;
156
175
 
157
176
  const actual = new router.Router();
158
- const validConf = confTmpl("\"my-series\"", "[\"dim1\", \"dim2\"]");
177
+ const validConf = confTmpl('"my-series"', '["dim1", "dim2"]');
159
178
  assert.doesNotThrow(() => actual._loadConfigString(validConf));
160
179
 
161
- const invalidConf0 = confTmpl("[\"my-series\"]", "[\"dim1\", \"dim2\"]");
180
+ const invalidConf0 = confTmpl('["my-series"]', '["dim1", "dim2"]');
162
181
  assert.throws(() => actual._loadConfigString(invalidConf0));
163
182
 
164
- const invalidConf1 = confTmpl("\"my-series\"", "\"dim1\"");
183
+ const invalidConf1 = confTmpl('"my-series"', '"dim1"');
165
184
  assert.throws(() => actual._loadConfigString(invalidConf1));
166
185
  });
167
186
 
@@ -285,25 +304,23 @@ routes:
285
304
  const r = new router.Router([
286
305
  new router.Rule(
287
306
  "rule-one",
288
- {title: ["hello", "hi"], foo: ["bar", "baz"]},
289
- {channel: "#-%{foo}-", dimensions: ["-%{foo}-"]}
290
- ),
291
- new router.Rule(
292
- "rule-two",
293
- {"bing.bong": ["buzz"]},
294
- {series: "x"}
307
+ { title: ["hello", "hi"], foo: ["bar", "baz"] },
308
+ { channel: "#-%{foo}-", dimensions: ["-%{foo}-"] },
295
309
  ),
310
+ new router.Rule("rule-two", { "bing.bong": ["buzz"] }, { series: "x" }),
296
311
  ]);
297
312
 
298
313
  const msg0 = {
299
314
  title: "hi",
300
- foo: "bar",
315
+ foo: "bar",
301
316
  };
302
- const expected0 = [{
303
- rule: "rule-one",
304
- channel: "#-bar-",
305
- dimensions: ["-bar-"],
306
- }];
317
+ const expected0 = [
318
+ {
319
+ rule: "rule-one",
320
+ channel: "#-bar-",
321
+ dimensions: ["-bar-"],
322
+ },
323
+ ];
307
324
  const actual0 = r.route(msg0).routes;
308
325
  assert.deepEqual(expected0, actual0);
309
326
 
@@ -313,28 +330,30 @@ routes:
313
330
  bong: "buzz",
314
331
  },
315
332
  };
316
- const expected1 = [{
317
- rule: "rule-two",
318
- series: "x",
319
- }];
333
+ const expected1 = [
334
+ {
335
+ rule: "rule-two",
336
+ series: "x",
337
+ },
338
+ ];
320
339
  const actual1 = r.route(msg1).routes;
321
340
  assert.deepEqual(expected1, actual1);
322
341
 
323
342
  const msg2 = {
324
343
  title: "hello",
325
- foo: "baz",
344
+ foo: "baz",
326
345
  bing: {
327
346
  bong: "buzz",
328
347
  },
329
348
  };
330
349
  const expected2 = [
331
350
  {
332
- rule: "rule-one",
333
- channel: "#-baz-",
351
+ rule: "rule-one",
352
+ channel: "#-baz-",
334
353
  dimensions: ["-baz-"],
335
354
  },
336
355
  {
337
- rule: "rule-two",
356
+ rule: "rule-two",
338
357
  series: "x",
339
358
  },
340
359
  ];
@@ -347,137 +366,189 @@ routes:
347
366
  describe("router.Rule", () => {
348
367
  describe("matches", () => {
349
368
  it("works on simple cases", () => {
350
- const r = new router.Rule("test-rule", {title: ["hello", "hi"], foo: ["bar"]}, {});
351
- assert(r.matches({
352
- title: "hello",
353
- foo: "bar",
354
- }));
355
- assert(r.matches({
356
- title: "hi",
357
- foo: "bar",
358
- }));
359
- assert(!r.matches({
360
- title: "hi",
361
- foo: "fighters",
362
- }));
363
- assert(!r.matches({
364
- title: "howdy",
365
- foo: "bar",
366
- }));
367
- assert(!r.matches({
368
- "missing-stuff": "indeed",
369
- }));
369
+ const r = new router.Rule("test-rule", { title: ["hello", "hi"], foo: ["bar"] }, {});
370
+ assert(
371
+ r.matches({
372
+ title: "hello",
373
+ foo: "bar",
374
+ }),
375
+ );
376
+ assert(
377
+ r.matches({
378
+ title: "hi",
379
+ foo: "bar",
380
+ }),
381
+ );
382
+ assert(
383
+ !r.matches({
384
+ title: "hi",
385
+ foo: "fighters",
386
+ }),
387
+ );
388
+ assert(
389
+ !r.matches({
390
+ title: "howdy",
391
+ foo: "bar",
392
+ }),
393
+ );
394
+ assert(
395
+ !r.matches({
396
+ "missing-stuff": "indeed",
397
+ }),
398
+ );
370
399
  });
371
400
 
372
401
  it("works on nested messages", () => {
373
- const r = new router.Rule("test-rule", {"foo.bar": ["hello", "hi"]}, {});
374
- assert(r.matches({
375
- title: "greeting",
376
- foo: {
377
- bar: "hello",
378
- },
379
- }));
380
- assert(r.matches({
381
- title: "greeting",
382
- foo: {
383
- bar: "hi",
384
- },
385
- }));
386
- assert(!r.matches({
387
- title: "greeting",
388
- foo: {
389
- bar: "howdy",
390
- },
391
- }));
392
- assert(!r.matches({
393
- title: "greeting",
394
- foo: {
395
- baz: "howdy",
396
- },
397
- }));
398
- assert(!r.matches({
399
- title: "greeting",
400
- boo: {
401
- bar: "howdy",
402
- },
403
- }));
404
- assert(!r.matches({
405
- title: "greeting",
406
- foo: "hi",
407
- }));
402
+ const r = new router.Rule("test-rule", { "foo.bar": ["hello", "hi"] }, {});
403
+ assert(
404
+ r.matches({
405
+ title: "greeting",
406
+ foo: {
407
+ bar: "hello",
408
+ },
409
+ }),
410
+ );
411
+ assert(
412
+ r.matches({
413
+ title: "greeting",
414
+ foo: {
415
+ bar: "hi",
416
+ },
417
+ }),
418
+ );
419
+ assert(
420
+ !r.matches({
421
+ title: "greeting",
422
+ foo: {
423
+ bar: "howdy",
424
+ },
425
+ }),
426
+ );
427
+ assert(
428
+ !r.matches({
429
+ title: "greeting",
430
+ foo: {
431
+ baz: "howdy",
432
+ },
433
+ }),
434
+ );
435
+ assert(
436
+ !r.matches({
437
+ title: "greeting",
438
+ boo: {
439
+ bar: "howdy",
440
+ },
441
+ }),
442
+ );
443
+ assert(
444
+ !r.matches({
445
+ title: "greeting",
446
+ foo: "hi",
447
+ }),
448
+ );
408
449
  });
409
450
  it("wild card matching", () => {
410
- const r = new router.Rule("test-rule", {any: ["*"]}, {});
411
- assert(r.matches({
412
- any: false,
413
- }));
414
- assert(r.matches({
415
- any: 5,
416
- }));
417
- assert(r.matches({
418
- any: "hello",
419
- }));
420
- assert(r.matches({
421
- any: {
422
- bar: "hi",
423
- },
424
- }));
425
- assert(!r.matches({
426
- any: "",
427
- }));
428
- assert(!r.matches({
429
- any: null,
430
- }));
431
- assert(!r.matches({
432
- any: undefined,
433
- }));
434
- assert(!r.matches({
435
- title: "greeting",
436
- foo: {
437
- bar: "howdy",
438
- },
439
- }));
451
+ const r = new router.Rule("test-rule", { any: ["*"] }, {});
452
+ assert(
453
+ r.matches({
454
+ any: false,
455
+ }),
456
+ );
457
+ assert(
458
+ r.matches({
459
+ any: 5,
460
+ }),
461
+ );
462
+ assert(
463
+ r.matches({
464
+ any: "hello",
465
+ }),
466
+ );
467
+ assert(
468
+ r.matches({
469
+ any: {
470
+ bar: "hi",
471
+ },
472
+ }),
473
+ );
474
+ assert(
475
+ !r.matches({
476
+ any: "",
477
+ }),
478
+ );
479
+ assert(
480
+ !r.matches({
481
+ any: null,
482
+ }),
483
+ );
484
+ assert(
485
+ !r.matches({
486
+ any: undefined,
487
+ }),
488
+ );
489
+ assert(
490
+ !r.matches({
491
+ title: "greeting",
492
+ foo: {
493
+ bar: "howdy",
494
+ },
495
+ }),
496
+ );
440
497
  });
441
498
  it("bool matching", () => {
442
- const r = new router.Rule("test-rule", {bull: [true]}, {});
443
- assert(r.matches({
444
- bull: true,
445
- }));
446
- assert(r.matches({
447
- any: false,
448
- bull: true,
449
- }));
450
- assert(!r.matches({
451
- bull: false,
452
- }));
453
- assert(!r.matches({
454
- bull: "false",
455
- }));
456
- assert(!r.matches({
457
- title: "greeting",
458
- foo: {
459
- bar: "howdy",
460
- },
461
- }));
499
+ const r = new router.Rule("test-rule", { bull: [true] }, {});
500
+ assert(
501
+ r.matches({
502
+ bull: true,
503
+ }),
504
+ );
505
+ assert(
506
+ r.matches({
507
+ any: false,
508
+ bull: true,
509
+ }),
510
+ );
511
+ assert(
512
+ !r.matches({
513
+ bull: false,
514
+ }),
515
+ );
516
+ assert(
517
+ !r.matches({
518
+ bull: "false",
519
+ }),
520
+ );
521
+ assert(
522
+ !r.matches({
523
+ title: "greeting",
524
+ foo: {
525
+ bar: "howdy",
526
+ },
527
+ }),
528
+ );
462
529
  });
463
530
  });
464
531
 
465
532
  describe("outputFor", () => {
466
533
  it("substitutes kv entries", () => {
467
- const r = new router.Rule("myrule", {}, {
468
- channel: "#-%{foo}-",
469
- dimensions: ["-%{foo}-", "-%{bar.baz}-"],
470
- });
534
+ const r = new router.Rule(
535
+ "myrule",
536
+ {},
537
+ {
538
+ channel: "#-%{foo}-",
539
+ dimensions: ["-%{foo}-", "-%{bar.baz}-"],
540
+ },
541
+ );
471
542
  const msg = {
472
543
  title: "greeting",
473
- foo: "partner",
544
+ foo: "partner",
474
545
  bar: {
475
546
  baz: "nest egg",
476
547
  },
477
548
  };
478
549
  const expected = {
479
- rule: "myrule",
480
- channel: "#-partner-",
550
+ rule: "myrule",
551
+ channel: "#-partner-",
481
552
  dimensions: ["-partner-", "-nest egg-"],
482
553
  };
483
554
  const actual = r.outputFor(msg);
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "module": "commonjs",
4
- "target": "es5",
4
+ "target": "ES2019",
5
5
  "noImplicitAny": false
6
6
  },
7
7
  "exclude": [
package/.eslintrc.yml DELETED
@@ -1,47 +0,0 @@
1
- extends: "airbnb"
2
- env:
3
- mocha: true
4
- parser: "babel-eslint"
5
- parserOptions:
6
- ecmaVersion: 6
7
- rules:
8
- # no hard limit on line length
9
- max-len: 0
10
-
11
- # we allow use of console...for now
12
- no-console: 0
13
-
14
- # we currently use snake case in most places, however, we'd like to switch to camelCase eventually since it's more common in the JS community
15
- camelcase: 0
16
-
17
- # vars are necessary for server-side requires right now
18
- no-var: 0
19
- vars-on-top: 0
20
-
21
- # multi spaces only allowed for aligning variable/import declarations
22
- no-multi-spaces:
23
- - 2
24
- - exceptions:
25
- VariableDeclarator: true
26
- ImportDeclaration: true
27
-
28
- # we currently use null in many places, so allow == for null checks
29
- eqeqeq:
30
- - 2
31
- - "smart"
32
-
33
- quotes: [2, "double", "avoid-escape"]
34
- object-curly-spacing:
35
- - 2
36
- - "never"
37
- new-cap:
38
- - 2
39
- - newIsCapExceptions: ["kayvee.logger"]
40
- no-param-reassign:
41
- - 2
42
- - props: false
43
- key-spacing:
44
- - 2
45
- - mode: "minimum"
46
-
47
- guard-for-in: 0
package/tsd.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "version": "v4",
3
- "repo": "borisyankov/DefinitelyTyped",
4
- "ref": "master",
5
- "path": "typings",
6
- "bundle": "typings/tsd.d.ts",
7
- "installed": {
8
- "node/node.d.ts": {
9
- "commit": "641df27e73ca67fa7199a3deedae104198d41a17"
10
- },
11
- "mocha/mocha.d.ts": {
12
- "commit": "641df27e73ca67fa7199a3deedae104198d41a17"
13
- }
14
- }
15
- }