@itcase/storybook-config 1.1.38 → 1.1.39

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.
@@ -6,6 +6,7 @@ var UIContext = require('@itcase/ui/context/UIContext');
6
6
  var index = require('./components/FormSubmitWrapper.js');
7
7
  require('lodash/camelCase');
8
8
  require('@itcase/common');
9
+ var msw = require('msw');
9
10
 
10
11
  function withExtraProviders(providers) {
11
12
  if (providers === void 0) {
@@ -24,26 +25,399 @@ function withExtraProviders(providers) {
24
25
  };
25
26
  }
26
27
 
28
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
29
+ try {
30
+ var i = n[a](c),
31
+ u = i.value;
32
+ } catch (n) {
33
+ return void e(n);
34
+ }
35
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
36
+ }
37
+ function _asyncToGenerator(n) {
38
+ return function () {
39
+ var t = this,
40
+ e = arguments;
41
+ return new Promise(function (r, o) {
42
+ var a = n.apply(t, e);
43
+ function _next(n) {
44
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
45
+ }
46
+ function _throw(n) {
47
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
48
+ }
49
+ _next(void 0);
50
+ });
51
+ };
52
+ }
53
+ function _regeneratorRuntime() {
54
+ _regeneratorRuntime = function () {
55
+ return e;
56
+ };
57
+ var t,
58
+ e = {},
59
+ r = Object.prototype,
60
+ n = r.hasOwnProperty,
61
+ o = Object.defineProperty || function (t, e, r) {
62
+ t[e] = r.value;
63
+ },
64
+ i = "function" == typeof Symbol ? Symbol : {},
65
+ a = i.iterator || "@@iterator",
66
+ c = i.asyncIterator || "@@asyncIterator",
67
+ u = i.toStringTag || "@@toStringTag";
68
+ function define(t, e, r) {
69
+ return Object.defineProperty(t, e, {
70
+ value: r,
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true
74
+ }), t[e];
75
+ }
76
+ try {
77
+ define({}, "");
78
+ } catch (t) {
79
+ define = function (t, e, r) {
80
+ return t[e] = r;
81
+ };
82
+ }
83
+ function wrap(t, e, r, n) {
84
+ var i = e && e.prototype instanceof Generator ? e : Generator,
85
+ a = Object.create(i.prototype),
86
+ c = new Context(n || []);
87
+ return o(a, "_invoke", {
88
+ value: makeInvokeMethod(t, r, c)
89
+ }), a;
90
+ }
91
+ function tryCatch(t, e, r) {
92
+ try {
93
+ return {
94
+ type: "normal",
95
+ arg: t.call(e, r)
96
+ };
97
+ } catch (t) {
98
+ return {
99
+ type: "throw",
100
+ arg: t
101
+ };
102
+ }
103
+ }
104
+ e.wrap = wrap;
105
+ var h = "suspendedStart",
106
+ l = "suspendedYield",
107
+ f = "executing",
108
+ s = "completed",
109
+ y = {};
110
+ function Generator() {}
111
+ function GeneratorFunction() {}
112
+ function GeneratorFunctionPrototype() {}
113
+ var p = {};
114
+ define(p, a, function () {
115
+ return this;
116
+ });
117
+ var d = Object.getPrototypeOf,
118
+ v = d && d(d(values([])));
119
+ v && v !== r && n.call(v, a) && (p = v);
120
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
121
+ function defineIteratorMethods(t) {
122
+ ["next", "throw", "return"].forEach(function (e) {
123
+ define(t, e, function (t) {
124
+ return this._invoke(e, t);
125
+ });
126
+ });
127
+ }
128
+ function AsyncIterator(t, e) {
129
+ function invoke(r, o, i, a) {
130
+ var c = tryCatch(t[r], t, o);
131
+ if ("throw" !== c.type) {
132
+ var u = c.arg,
133
+ h = u.value;
134
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
135
+ invoke("next", t, i, a);
136
+ }, function (t) {
137
+ invoke("throw", t, i, a);
138
+ }) : e.resolve(h).then(function (t) {
139
+ u.value = t, i(u);
140
+ }, function (t) {
141
+ return invoke("throw", t, i, a);
142
+ });
143
+ }
144
+ a(c.arg);
145
+ }
146
+ var r;
147
+ o(this, "_invoke", {
148
+ value: function (t, n) {
149
+ function callInvokeWithMethodAndArg() {
150
+ return new e(function (e, r) {
151
+ invoke(t, n, e, r);
152
+ });
153
+ }
154
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
155
+ }
156
+ });
157
+ }
158
+ function makeInvokeMethod(e, r, n) {
159
+ var o = h;
160
+ return function (i, a) {
161
+ if (o === f) throw Error("Generator is already running");
162
+ if (o === s) {
163
+ if ("throw" === i) throw a;
164
+ return {
165
+ value: t,
166
+ done: true
167
+ };
168
+ }
169
+ for (n.method = i, n.arg = a;;) {
170
+ var c = n.delegate;
171
+ if (c) {
172
+ var u = maybeInvokeDelegate(c, n);
173
+ if (u) {
174
+ if (u === y) continue;
175
+ return u;
176
+ }
177
+ }
178
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
179
+ if (o === h) throw o = s, n.arg;
180
+ n.dispatchException(n.arg);
181
+ } else "return" === n.method && n.abrupt("return", n.arg);
182
+ o = f;
183
+ var p = tryCatch(e, r, n);
184
+ if ("normal" === p.type) {
185
+ if (o = n.done ? s : l, p.arg === y) continue;
186
+ return {
187
+ value: p.arg,
188
+ done: n.done
189
+ };
190
+ }
191
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
192
+ }
193
+ };
194
+ }
195
+ function maybeInvokeDelegate(e, r) {
196
+ var n = r.method,
197
+ o = e.iterator[n];
198
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
199
+ var i = tryCatch(o, e.iterator, r.arg);
200
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
201
+ var a = i.arg;
202
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
203
+ }
204
+ function pushTryEntry(t) {
205
+ var e = {
206
+ tryLoc: t[0]
207
+ };
208
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
209
+ }
210
+ function resetTryEntry(t) {
211
+ var e = t.completion || {};
212
+ e.type = "normal", delete e.arg, t.completion = e;
213
+ }
214
+ function Context(t) {
215
+ this.tryEntries = [{
216
+ tryLoc: "root"
217
+ }], t.forEach(pushTryEntry, this), this.reset(true);
218
+ }
219
+ function values(e) {
220
+ if (e || "" === e) {
221
+ var r = e[a];
222
+ if (r) return r.call(e);
223
+ if ("function" == typeof e.next) return e;
224
+ if (!isNaN(e.length)) {
225
+ var o = -1,
226
+ i = function next() {
227
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
228
+ return next.value = t, next.done = true, next;
229
+ };
230
+ return i.next = i;
231
+ }
232
+ }
233
+ throw new TypeError(typeof e + " is not iterable");
234
+ }
235
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
236
+ value: GeneratorFunctionPrototype,
237
+ configurable: true
238
+ }), o(GeneratorFunctionPrototype, "constructor", {
239
+ value: GeneratorFunction,
240
+ configurable: true
241
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
242
+ var e = "function" == typeof t && t.constructor;
243
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
244
+ }, e.mark = function (t) {
245
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
246
+ }, e.awrap = function (t) {
247
+ return {
248
+ __await: t
249
+ };
250
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
251
+ return this;
252
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
253
+ void 0 === i && (i = Promise);
254
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
255
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
256
+ return t.done ? t.value : a.next();
257
+ });
258
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
259
+ return this;
260
+ }), define(g, "toString", function () {
261
+ return "[object Generator]";
262
+ }), e.keys = function (t) {
263
+ var e = Object(t),
264
+ r = [];
265
+ for (var n in e) r.push(n);
266
+ return r.reverse(), function next() {
267
+ for (; r.length;) {
268
+ var t = r.pop();
269
+ if (t in e) return next.value = t, next.done = false, next;
270
+ }
271
+ return next.done = true, next;
272
+ };
273
+ }, e.values = values, Context.prototype = {
274
+ constructor: Context,
275
+ reset: function (e) {
276
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
277
+ },
278
+ stop: function () {
279
+ this.done = true;
280
+ var t = this.tryEntries[0].completion;
281
+ if ("throw" === t.type) throw t.arg;
282
+ return this.rval;
283
+ },
284
+ dispatchException: function (e) {
285
+ if (this.done) throw e;
286
+ var r = this;
287
+ function handle(n, o) {
288
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
289
+ }
290
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
291
+ var i = this.tryEntries[o],
292
+ a = i.completion;
293
+ if ("root" === i.tryLoc) return handle("end");
294
+ if (i.tryLoc <= this.prev) {
295
+ var c = n.call(i, "catchLoc"),
296
+ u = n.call(i, "finallyLoc");
297
+ if (c && u) {
298
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
299
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
300
+ } else if (c) {
301
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
302
+ } else {
303
+ if (!u) throw Error("try statement without catch or finally");
304
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
305
+ }
306
+ }
307
+ }
308
+ },
309
+ abrupt: function (t, e) {
310
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
311
+ var o = this.tryEntries[r];
312
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
313
+ var i = o;
314
+ break;
315
+ }
316
+ }
317
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
318
+ var a = i ? i.completion : {};
319
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
320
+ },
321
+ complete: function (t, e) {
322
+ if ("throw" === t.type) throw t.arg;
323
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
324
+ },
325
+ finish: function (t) {
326
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
327
+ var r = this.tryEntries[e];
328
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
329
+ }
330
+ },
331
+ catch: function (t) {
332
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
333
+ var r = this.tryEntries[e];
334
+ if (r.tryLoc === t) {
335
+ var n = r.completion;
336
+ if ("throw" === n.type) {
337
+ var o = n.arg;
338
+ resetTryEntry(r);
339
+ }
340
+ return o;
341
+ }
342
+ }
343
+ throw Error("illegal catch attempt");
344
+ },
345
+ delegateYield: function (e, r, n) {
346
+ return this.delegate = {
347
+ iterator: values(e),
348
+ resultName: r,
349
+ nextLoc: n
350
+ }, "next" === this.method && (this.arg = t), y;
351
+ }
352
+ }, e;
353
+ }
354
+
355
+ var serverErrorHandler = function serverErrorHandler(formUrl, errors) {
356
+ return msw.http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
357
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
358
+ while (1) switch (_context.prev = _context.next) {
359
+ case 0:
360
+ return _context.abrupt("return", msw.HttpResponse.json(errors, {
361
+ status: 400
362
+ }));
363
+ case 1:
364
+ case "end":
365
+ return _context.stop();
366
+ }
367
+ }, _callee);
368
+ })));
369
+ };
370
+ var error500Handler = function error500Handler(formUrl) {
371
+ msw.http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
372
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
373
+ while (1) switch (_context2.prev = _context2.next) {
374
+ case 0:
375
+ return _context2.abrupt("return", msw.HttpResponse.json({}, {
376
+ status: 500
377
+ }));
378
+ case 1:
379
+ case "end":
380
+ return _context2.stop();
381
+ }
382
+ }, _callee2);
383
+ })));
384
+ };
385
+ var loadingHandler = function loadingHandler(formUrl) {
386
+ msw.http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
387
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
388
+ while (1) switch (_context3.prev = _context3.next) {
389
+ case 0:
390
+ _context3.next = 2;
391
+ return msw.delay(60000);
392
+ case 2:
393
+ return _context3.abrupt("return", msw.HttpResponse({}, {
394
+ status: 200
395
+ }));
396
+ case 3:
397
+ case "end":
398
+ return _context3.stop();
399
+ }
400
+ }, _callee3);
401
+ })));
402
+ };
403
+
27
404
  function handleMSWParameters(parameters, args) {
28
405
  var mswHandlersParams = {};
29
406
  if (parameters.serverError) {
30
407
  mswHandlersParams = {
31
408
  msw: {
32
- // eslint-disable-next-line no-undef
33
409
  handlers: [serverErrorHandler(parameters.formUrl, args.errors)]
34
410
  }
35
411
  };
36
412
  } else if (parameters.error500) {
37
413
  mswHandlersParams = {
38
414
  msw: {
39
- // eslint-disable-next-line no-undef
40
415
  handlers: [error500Handler(parameters.formUrl)]
41
416
  }
42
417
  };
43
418
  } else if (parameters.loading) {
44
419
  mswHandlersParams = {
45
420
  msw: {
46
- // eslint-disable-next-line no-undef
47
421
  handlers: [loadingHandler(parameters.formUrl)]
48
422
  }
49
423
  };
@@ -4,6 +4,7 @@ import { UIProvider } from '@itcase/ui/context/UIContext';
4
4
  import { FormSubmitWrapper } from './components/FormSubmitWrapper.js';
5
5
  import 'lodash/camelCase';
6
6
  import '@itcase/common';
7
+ import { http, HttpResponse, delay } from 'msw';
7
8
 
8
9
  function withExtraProviders(providers) {
9
10
  if (providers === void 0) {
@@ -22,26 +23,399 @@ function withExtraProviders(providers) {
22
23
  };
23
24
  }
24
25
 
26
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
27
+ try {
28
+ var i = n[a](c),
29
+ u = i.value;
30
+ } catch (n) {
31
+ return void e(n);
32
+ }
33
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
34
+ }
35
+ function _asyncToGenerator(n) {
36
+ return function () {
37
+ var t = this,
38
+ e = arguments;
39
+ return new Promise(function (r, o) {
40
+ var a = n.apply(t, e);
41
+ function _next(n) {
42
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
43
+ }
44
+ function _throw(n) {
45
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
46
+ }
47
+ _next(void 0);
48
+ });
49
+ };
50
+ }
51
+ function _regeneratorRuntime() {
52
+ _regeneratorRuntime = function () {
53
+ return e;
54
+ };
55
+ var t,
56
+ e = {},
57
+ r = Object.prototype,
58
+ n = r.hasOwnProperty,
59
+ o = Object.defineProperty || function (t, e, r) {
60
+ t[e] = r.value;
61
+ },
62
+ i = "function" == typeof Symbol ? Symbol : {},
63
+ a = i.iterator || "@@iterator",
64
+ c = i.asyncIterator || "@@asyncIterator",
65
+ u = i.toStringTag || "@@toStringTag";
66
+ function define(t, e, r) {
67
+ return Object.defineProperty(t, e, {
68
+ value: r,
69
+ enumerable: true,
70
+ configurable: true,
71
+ writable: true
72
+ }), t[e];
73
+ }
74
+ try {
75
+ define({}, "");
76
+ } catch (t) {
77
+ define = function (t, e, r) {
78
+ return t[e] = r;
79
+ };
80
+ }
81
+ function wrap(t, e, r, n) {
82
+ var i = e && e.prototype instanceof Generator ? e : Generator,
83
+ a = Object.create(i.prototype),
84
+ c = new Context(n || []);
85
+ return o(a, "_invoke", {
86
+ value: makeInvokeMethod(t, r, c)
87
+ }), a;
88
+ }
89
+ function tryCatch(t, e, r) {
90
+ try {
91
+ return {
92
+ type: "normal",
93
+ arg: t.call(e, r)
94
+ };
95
+ } catch (t) {
96
+ return {
97
+ type: "throw",
98
+ arg: t
99
+ };
100
+ }
101
+ }
102
+ e.wrap = wrap;
103
+ var h = "suspendedStart",
104
+ l = "suspendedYield",
105
+ f = "executing",
106
+ s = "completed",
107
+ y = {};
108
+ function Generator() {}
109
+ function GeneratorFunction() {}
110
+ function GeneratorFunctionPrototype() {}
111
+ var p = {};
112
+ define(p, a, function () {
113
+ return this;
114
+ });
115
+ var d = Object.getPrototypeOf,
116
+ v = d && d(d(values([])));
117
+ v && v !== r && n.call(v, a) && (p = v);
118
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
119
+ function defineIteratorMethods(t) {
120
+ ["next", "throw", "return"].forEach(function (e) {
121
+ define(t, e, function (t) {
122
+ return this._invoke(e, t);
123
+ });
124
+ });
125
+ }
126
+ function AsyncIterator(t, e) {
127
+ function invoke(r, o, i, a) {
128
+ var c = tryCatch(t[r], t, o);
129
+ if ("throw" !== c.type) {
130
+ var u = c.arg,
131
+ h = u.value;
132
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
133
+ invoke("next", t, i, a);
134
+ }, function (t) {
135
+ invoke("throw", t, i, a);
136
+ }) : e.resolve(h).then(function (t) {
137
+ u.value = t, i(u);
138
+ }, function (t) {
139
+ return invoke("throw", t, i, a);
140
+ });
141
+ }
142
+ a(c.arg);
143
+ }
144
+ var r;
145
+ o(this, "_invoke", {
146
+ value: function (t, n) {
147
+ function callInvokeWithMethodAndArg() {
148
+ return new e(function (e, r) {
149
+ invoke(t, n, e, r);
150
+ });
151
+ }
152
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
153
+ }
154
+ });
155
+ }
156
+ function makeInvokeMethod(e, r, n) {
157
+ var o = h;
158
+ return function (i, a) {
159
+ if (o === f) throw Error("Generator is already running");
160
+ if (o === s) {
161
+ if ("throw" === i) throw a;
162
+ return {
163
+ value: t,
164
+ done: true
165
+ };
166
+ }
167
+ for (n.method = i, n.arg = a;;) {
168
+ var c = n.delegate;
169
+ if (c) {
170
+ var u = maybeInvokeDelegate(c, n);
171
+ if (u) {
172
+ if (u === y) continue;
173
+ return u;
174
+ }
175
+ }
176
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
177
+ if (o === h) throw o = s, n.arg;
178
+ n.dispatchException(n.arg);
179
+ } else "return" === n.method && n.abrupt("return", n.arg);
180
+ o = f;
181
+ var p = tryCatch(e, r, n);
182
+ if ("normal" === p.type) {
183
+ if (o = n.done ? s : l, p.arg === y) continue;
184
+ return {
185
+ value: p.arg,
186
+ done: n.done
187
+ };
188
+ }
189
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
190
+ }
191
+ };
192
+ }
193
+ function maybeInvokeDelegate(e, r) {
194
+ var n = r.method,
195
+ o = e.iterator[n];
196
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
197
+ var i = tryCatch(o, e.iterator, r.arg);
198
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
199
+ var a = i.arg;
200
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
201
+ }
202
+ function pushTryEntry(t) {
203
+ var e = {
204
+ tryLoc: t[0]
205
+ };
206
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
207
+ }
208
+ function resetTryEntry(t) {
209
+ var e = t.completion || {};
210
+ e.type = "normal", delete e.arg, t.completion = e;
211
+ }
212
+ function Context(t) {
213
+ this.tryEntries = [{
214
+ tryLoc: "root"
215
+ }], t.forEach(pushTryEntry, this), this.reset(true);
216
+ }
217
+ function values(e) {
218
+ if (e || "" === e) {
219
+ var r = e[a];
220
+ if (r) return r.call(e);
221
+ if ("function" == typeof e.next) return e;
222
+ if (!isNaN(e.length)) {
223
+ var o = -1,
224
+ i = function next() {
225
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
226
+ return next.value = t, next.done = true, next;
227
+ };
228
+ return i.next = i;
229
+ }
230
+ }
231
+ throw new TypeError(typeof e + " is not iterable");
232
+ }
233
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
234
+ value: GeneratorFunctionPrototype,
235
+ configurable: true
236
+ }), o(GeneratorFunctionPrototype, "constructor", {
237
+ value: GeneratorFunction,
238
+ configurable: true
239
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
240
+ var e = "function" == typeof t && t.constructor;
241
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
242
+ }, e.mark = function (t) {
243
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
244
+ }, e.awrap = function (t) {
245
+ return {
246
+ __await: t
247
+ };
248
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
249
+ return this;
250
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
251
+ void 0 === i && (i = Promise);
252
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
253
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
254
+ return t.done ? t.value : a.next();
255
+ });
256
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
257
+ return this;
258
+ }), define(g, "toString", function () {
259
+ return "[object Generator]";
260
+ }), e.keys = function (t) {
261
+ var e = Object(t),
262
+ r = [];
263
+ for (var n in e) r.push(n);
264
+ return r.reverse(), function next() {
265
+ for (; r.length;) {
266
+ var t = r.pop();
267
+ if (t in e) return next.value = t, next.done = false, next;
268
+ }
269
+ return next.done = true, next;
270
+ };
271
+ }, e.values = values, Context.prototype = {
272
+ constructor: Context,
273
+ reset: function (e) {
274
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
275
+ },
276
+ stop: function () {
277
+ this.done = true;
278
+ var t = this.tryEntries[0].completion;
279
+ if ("throw" === t.type) throw t.arg;
280
+ return this.rval;
281
+ },
282
+ dispatchException: function (e) {
283
+ if (this.done) throw e;
284
+ var r = this;
285
+ function handle(n, o) {
286
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
287
+ }
288
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
289
+ var i = this.tryEntries[o],
290
+ a = i.completion;
291
+ if ("root" === i.tryLoc) return handle("end");
292
+ if (i.tryLoc <= this.prev) {
293
+ var c = n.call(i, "catchLoc"),
294
+ u = n.call(i, "finallyLoc");
295
+ if (c && u) {
296
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
297
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
298
+ } else if (c) {
299
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
300
+ } else {
301
+ if (!u) throw Error("try statement without catch or finally");
302
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
303
+ }
304
+ }
305
+ }
306
+ },
307
+ abrupt: function (t, e) {
308
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
309
+ var o = this.tryEntries[r];
310
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
311
+ var i = o;
312
+ break;
313
+ }
314
+ }
315
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
316
+ var a = i ? i.completion : {};
317
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
318
+ },
319
+ complete: function (t, e) {
320
+ if ("throw" === t.type) throw t.arg;
321
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
322
+ },
323
+ finish: function (t) {
324
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
325
+ var r = this.tryEntries[e];
326
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
327
+ }
328
+ },
329
+ catch: function (t) {
330
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
331
+ var r = this.tryEntries[e];
332
+ if (r.tryLoc === t) {
333
+ var n = r.completion;
334
+ if ("throw" === n.type) {
335
+ var o = n.arg;
336
+ resetTryEntry(r);
337
+ }
338
+ return o;
339
+ }
340
+ }
341
+ throw Error("illegal catch attempt");
342
+ },
343
+ delegateYield: function (e, r, n) {
344
+ return this.delegate = {
345
+ iterator: values(e),
346
+ resultName: r,
347
+ nextLoc: n
348
+ }, "next" === this.method && (this.arg = t), y;
349
+ }
350
+ }, e;
351
+ }
352
+
353
+ var serverErrorHandler = function serverErrorHandler(formUrl, errors) {
354
+ return http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
355
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
356
+ while (1) switch (_context.prev = _context.next) {
357
+ case 0:
358
+ return _context.abrupt("return", HttpResponse.json(errors, {
359
+ status: 400
360
+ }));
361
+ case 1:
362
+ case "end":
363
+ return _context.stop();
364
+ }
365
+ }, _callee);
366
+ })));
367
+ };
368
+ var error500Handler = function error500Handler(formUrl) {
369
+ http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
370
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
371
+ while (1) switch (_context2.prev = _context2.next) {
372
+ case 0:
373
+ return _context2.abrupt("return", HttpResponse.json({}, {
374
+ status: 500
375
+ }));
376
+ case 1:
377
+ case "end":
378
+ return _context2.stop();
379
+ }
380
+ }, _callee2);
381
+ })));
382
+ };
383
+ var loadingHandler = function loadingHandler(formUrl) {
384
+ http.post(formUrl, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
385
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
386
+ while (1) switch (_context3.prev = _context3.next) {
387
+ case 0:
388
+ _context3.next = 2;
389
+ return delay(60000);
390
+ case 2:
391
+ return _context3.abrupt("return", HttpResponse({}, {
392
+ status: 200
393
+ }));
394
+ case 3:
395
+ case "end":
396
+ return _context3.stop();
397
+ }
398
+ }, _callee3);
399
+ })));
400
+ };
401
+
25
402
  function handleMSWParameters(parameters, args) {
26
403
  var mswHandlersParams = {};
27
404
  if (parameters.serverError) {
28
405
  mswHandlersParams = {
29
406
  msw: {
30
- // eslint-disable-next-line no-undef
31
407
  handlers: [serverErrorHandler(parameters.formUrl, args.errors)]
32
408
  }
33
409
  };
34
410
  } else if (parameters.error500) {
35
411
  mswHandlersParams = {
36
412
  msw: {
37
- // eslint-disable-next-line no-undef
38
413
  handlers: [error500Handler(parameters.formUrl)]
39
414
  }
40
415
  };
41
416
  } else if (parameters.loading) {
42
417
  mswHandlersParams = {
43
418
  msw: {
44
- // eslint-disable-next-line no-undef
45
419
  handlers: [loadingHandler(parameters.formUrl)]
46
420
  }
47
421
  };
@@ -1,24 +1,27 @@
1
+ import {
2
+ error500Handler,
3
+ loadingHandler,
4
+ serverErrorHandler,
5
+ } from '../config/mswHandlers'
6
+
1
7
  function handleMSWParameters(parameters, args) {
2
8
  let mswHandlersParams = {}
3
9
 
4
10
  if (parameters.serverError) {
5
11
  mswHandlersParams = {
6
12
  msw: {
7
- // eslint-disable-next-line no-undef
8
13
  handlers: [serverErrorHandler(parameters.formUrl, args.errors)],
9
14
  },
10
15
  }
11
16
  } else if (parameters.error500) {
12
17
  mswHandlersParams = {
13
18
  msw: {
14
- // eslint-disable-next-line no-undef
15
19
  handlers: [error500Handler(parameters.formUrl)],
16
20
  },
17
21
  }
18
22
  } else if (parameters.loading) {
19
23
  mswHandlersParams = {
20
24
  msw: {
21
- // eslint-disable-next-line no-undef
22
25
  handlers: [loadingHandler(parameters.formUrl)],
23
26
  },
24
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.1.38",
3
+ "version": "1.1.39",
4
4
  "author": "ITCase",
5
5
  "description": "Code style linter configuration presets",
6
6
  "engines": {