msw 0.48.2 → 0.49.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.
@@ -107,8 +107,8 @@ function toReadonlyArray(source) {
107
107
 
108
108
  // src/SetupApi.ts
109
109
  var SetupApi = class {
110
- constructor(initialHandlers) {
111
- this.validateHandlers(initialHandlers);
110
+ constructor(...initialHandlers) {
111
+ this.validateHandlers(...initialHandlers);
112
112
  this.initialHandlers = toReadonlyArray(initialHandlers);
113
113
  this.currentHandlers = [...initialHandlers];
114
114
  this.emitter = new StrictEventEmitter();
@@ -116,7 +116,7 @@ var SetupApi = class {
116
116
  pipeEvents(this.emitter, this.publicEmitter);
117
117
  this.events = this.createLifeCycleEvents();
118
118
  }
119
- validateHandlers(handlers) {
119
+ validateHandlers(...handlers) {
120
120
  for (const handler of handlers) {
121
121
  invariant(!Array.isArray(handler), devUtils.formatMessage('Failed to construct "%s" given an Array of request handlers. Make sure you spread the request handlers when calling the respective setup function.'), this.constructor.name);
122
122
  }
@@ -506,12 +506,141 @@ function parseGraphQLRequest(request) {
506
506
  };
507
507
  }
508
508
 
509
+ // node_modules/statuses/codes.json
510
+ var _00 = "Continue";
511
+ var _01 = "Switching Protocols";
512
+ var _02 = "Processing";
513
+ var _03 = "Early Hints";
514
+ var _002 = "OK";
515
+ var _012 = "Created";
516
+ var _022 = "Accepted";
517
+ var _032 = "Non-Authoritative Information";
518
+ var _04 = "No Content";
519
+ var _05 = "Reset Content";
520
+ var _06 = "Partial Content";
521
+ var _07 = "Multi-Status";
522
+ var _08 = "Already Reported";
523
+ var _26 = "IM Used";
524
+ var _003 = "Multiple Choices";
525
+ var _013 = "Moved Permanently";
526
+ var _023 = "Found";
527
+ var _033 = "See Other";
528
+ var _042 = "Not Modified";
529
+ var _052 = "Use Proxy";
530
+ var _072 = "Temporary Redirect";
531
+ var _082 = "Permanent Redirect";
532
+ var _004 = "Bad Request";
533
+ var _014 = "Unauthorized";
534
+ var _024 = "Payment Required";
535
+ var _034 = "Forbidden";
536
+ var _043 = "Not Found";
537
+ var _053 = "Method Not Allowed";
538
+ var _062 = "Not Acceptable";
539
+ var _073 = "Proxy Authentication Required";
540
+ var _083 = "Request Timeout";
541
+ var _09 = "Conflict";
542
+ var _10 = "Gone";
543
+ var _11 = "Length Required";
544
+ var _12 = "Precondition Failed";
545
+ var _13 = "Payload Too Large";
546
+ var _14 = "URI Too Long";
547
+ var _15 = "Unsupported Media Type";
548
+ var _16 = "Range Not Satisfiable";
549
+ var _17 = "Expectation Failed";
550
+ var _18 = "I'm a Teapot";
551
+ var _21 = "Misdirected Request";
552
+ var _22 = "Unprocessable Entity";
553
+ var _23 = "Locked";
554
+ var _24 = "Failed Dependency";
555
+ var _25 = "Too Early";
556
+ var _262 = "Upgrade Required";
557
+ var _28 = "Precondition Required";
558
+ var _29 = "Too Many Requests";
559
+ var _31 = "Request Header Fields Too Large";
560
+ var _51 = "Unavailable For Legal Reasons";
561
+ var _005 = "Internal Server Error";
562
+ var _015 = "Not Implemented";
563
+ var _025 = "Bad Gateway";
564
+ var _035 = "Service Unavailable";
565
+ var _044 = "Gateway Timeout";
566
+ var _054 = "HTTP Version Not Supported";
567
+ var _063 = "Variant Also Negotiates";
568
+ var _074 = "Insufficient Storage";
569
+ var _084 = "Loop Detected";
570
+ var _092 = "Bandwidth Limit Exceeded";
571
+ var _102 = "Not Extended";
572
+ var _112 = "Network Authentication Required";
573
+ var codes_default = {
574
+ "100": _00,
575
+ "101": _01,
576
+ "102": _02,
577
+ "103": _03,
578
+ "200": _002,
579
+ "201": _012,
580
+ "202": _022,
581
+ "203": _032,
582
+ "204": _04,
583
+ "205": _05,
584
+ "206": _06,
585
+ "207": _07,
586
+ "208": _08,
587
+ "226": _26,
588
+ "300": _003,
589
+ "301": _013,
590
+ "302": _023,
591
+ "303": _033,
592
+ "304": _042,
593
+ "305": _052,
594
+ "307": _072,
595
+ "308": _082,
596
+ "400": _004,
597
+ "401": _014,
598
+ "402": _024,
599
+ "403": _034,
600
+ "404": _043,
601
+ "405": _053,
602
+ "406": _062,
603
+ "407": _073,
604
+ "408": _083,
605
+ "409": _09,
606
+ "410": _10,
607
+ "411": _11,
608
+ "412": _12,
609
+ "413": _13,
610
+ "414": _14,
611
+ "415": _15,
612
+ "416": _16,
613
+ "417": _17,
614
+ "418": _18,
615
+ "421": _21,
616
+ "422": _22,
617
+ "423": _23,
618
+ "424": _24,
619
+ "425": _25,
620
+ "426": _262,
621
+ "428": _28,
622
+ "429": _29,
623
+ "431": _31,
624
+ "451": _51,
625
+ "500": _005,
626
+ "501": _015,
627
+ "502": _025,
628
+ "503": _035,
629
+ "504": _044,
630
+ "505": _054,
631
+ "506": _063,
632
+ "507": _074,
633
+ "508": _084,
634
+ "509": _092,
635
+ "510": _102,
636
+ "511": _112
637
+ };
638
+
509
639
  // src/context/status.ts
510
- import statuses from "statuses/codes.json";
511
640
  var status = (statusCode, statusText) => {
512
641
  return (res) => {
513
642
  res.status = statusCode;
514
- res.statusText = statusText || statuses[String(statusCode)];
643
+ res.statusText = statusText || codes_default[String(statusCode)];
515
644
  return res;
516
645
  };
517
646
  };
@@ -1283,8 +1412,8 @@ var DEFAULT_LISTEN_OPTIONS = {
1283
1412
  onUnhandledRequest: "warn"
1284
1413
  };
1285
1414
  var SetupServerApi = class extends SetupApi {
1286
- constructor(interceptors, handlers) {
1287
- super(handlers);
1415
+ constructor(interceptors, ...handlers) {
1416
+ super(...handlers);
1288
1417
  this.interceptor = new BatchInterceptor({
1289
1418
  name: "setup-server",
1290
1419
  interceptors: interceptors.map((Interceptor2) => new Interceptor2())
@@ -1354,7 +1483,7 @@ var SetupServerApi = class extends SetupApi {
1354
1483
  import { ClientRequestInterceptor } from "@mswjs/interceptors/lib/interceptors/ClientRequest/index.js";
1355
1484
  import { XMLHttpRequestInterceptor } from "@mswjs/interceptors/lib/interceptors/XMLHttpRequest/index.js";
1356
1485
  var setupServer = (...handlers) => {
1357
- return new SetupServerApi([ClientRequestInterceptor, XMLHttpRequestInterceptor], handlers);
1486
+ return new SetupServerApi([ClientRequestInterceptor, XMLHttpRequestInterceptor], ...handlers);
1358
1487
  };
1359
1488
  export {
1360
1489
  setupServer