@mjhls/mjh-framework 1.0.844-beta.0 → 1.0.844-beta.2

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 (51) hide show
  1. package/dist/cjs/AdSlotsProvider.js +2 -895
  2. package/dist/cjs/AlgoliaSearch.js +336 -237
  3. package/dist/cjs/ArticleProgramLandingPage.js +2 -3
  4. package/dist/cjs/ArticleSeriesLandingPage.js +1 -1
  5. package/dist/cjs/ArticleSeriesListing.js +1 -1
  6. package/dist/cjs/DeckContent.js +1 -1
  7. package/dist/cjs/DeckQueue.js +1 -1
  8. package/dist/cjs/ExternalResources.js +2 -3
  9. package/dist/cjs/GridContent.js +1 -1
  10. package/dist/cjs/HorizontalArticleListing.js +2 -3
  11. package/dist/cjs/IssueLanding.js +2 -3
  12. package/dist/cjs/MasterDeck.js +1 -1
  13. package/dist/cjs/MediaSeriesLanding.js +5 -6
  14. package/dist/cjs/PartnerDetailListing.js +6 -1105
  15. package/dist/cjs/TaxonomyDescription.js +2 -3
  16. package/dist/cjs/VideoProgramLandingPage.js +2 -3
  17. package/dist/cjs/VideoSeriesCard.js +2 -2
  18. package/dist/cjs/VideoSeriesLandingPage.js +3 -3
  19. package/dist/cjs/VideoSeriesListing.js +1 -1
  20. package/dist/cjs/View.js +4 -6
  21. package/dist/cjs/faundadb.js +321 -4
  22. package/dist/cjs/getRelatedArticle.js +20 -24
  23. package/dist/cjs/getSerializers.js +2 -3
  24. package/dist/cjs/{index-45f8b70b.js → index-4fdc043f.js} +629 -32
  25. package/dist/cjs/index.js +4 -11
  26. package/dist/cjs/{inherits-452ff02c.js → inherits-9953db94.js} +4 -4
  27. package/dist/esm/AdSlotsProvider.js +6 -898
  28. package/dist/esm/AlgoliaSearch.js +100 -1
  29. package/dist/esm/ArticleProgramLandingPage.js +1 -2
  30. package/dist/esm/ExternalResources.js +1 -2
  31. package/dist/esm/HorizontalArticleListing.js +1 -2
  32. package/dist/esm/IssueLanding.js +1 -2
  33. package/dist/esm/MediaSeriesLanding.js +1 -2
  34. package/dist/esm/PartnerDetailListing.js +5 -1103
  35. package/dist/esm/TaxonomyDescription.js +1 -2
  36. package/dist/esm/VideoProgramLandingPage.js +1 -2
  37. package/dist/esm/View.js +1 -3
  38. package/dist/esm/faundadb.js +319 -2
  39. package/dist/esm/getRelatedArticle.js +20 -24
  40. package/dist/esm/getSerializers.js +1 -2
  41. package/dist/esm/{index-ea86ff20.js → index-fb819516.js} +617 -20
  42. package/dist/esm/index.js +3 -9
  43. package/package.json +6 -2
  44. package/dist/cjs/Auth.js +0 -3628
  45. package/dist/cjs/inherits-8d29278d.js +0 -110
  46. package/dist/cjs/md5-5039b1a6.js +0 -323
  47. package/dist/cjs/util-f2c1b65b.js +0 -576
  48. package/dist/esm/Auth.js +0 -3612
  49. package/dist/esm/inherits-77d5e4fc.js +0 -101
  50. package/dist/esm/md5-9be0e905.js +0 -321
  51. package/dist/esm/util-7700fc59.js +0 -574
package/dist/cjs/Auth.js DELETED
@@ -1,3628 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
8
- require('./_to-object-329a650b.js');
9
- require('./es6.string.iterator-cc0bbaa4.js');
10
- require('./_library-dd23b178.js');
11
- require('./_iter-detect-60b2f026.js');
12
- require('./core.get-iterator-method-f62321d4.js');
13
- require('./_object-pie-68c5bcbc.js');
14
- var _extends$1 = require('./extends-0a918631.js');
15
- require('./web.dom.iterable-a0e279c1.js');
16
- var React = require('react');
17
- var React__default = _interopDefault(React);
18
- var Router = require('next/router');
19
- var Router__default = _interopDefault(Router);
20
- var slicedToArray = require('./slicedToArray-8f385299.js');
21
- var stringify = require('./stringify-7c5aff47.js');
22
- var asyncToGenerator = require('./asyncToGenerator-140e5f89.js');
23
- var reactBootstrap = require('react-bootstrap');
24
- var util = require('./util-f2c1b65b.js');
25
- var useSWR = _interopDefault(require('swr'));
26
- var Local = _interopDefault(require('passport-local'));
27
- var mysql = _interopDefault(require('mysql'));
28
- var md5 = require('./md5-5039b1a6.js');
29
-
30
- var returnFormField = function returnFormField(_ref) {
31
- var name = _ref.name,
32
- label = _ref.label,
33
- type = _ref.type,
34
- _ref$required = _ref.required,
35
- required = _ref$required === undefined ? false : _ref$required,
36
- _ref$readonly = _ref.readonly,
37
- readonly = _ref$readonly === undefined ? false : _ref$readonly,
38
- _ref$options = _ref.options,
39
- options = _ref$options === undefined ? null : _ref$options,
40
- _ref$groupType = _ref.groupType,
41
- groupType = _ref$groupType === undefined ? '' : _ref$groupType,
42
- _ref$errors = _ref.errors,
43
- errors = _ref$errors === undefined ? {} : _ref$errors,
44
- _ref$handleChanged = _ref.handleChanged,
45
- handleChanged = _ref$handleChanged === undefined ? null : _ref$handleChanged,
46
- _ref$default_value = _ref.default_value,
47
- default_value = _ref$default_value === undefined ? null : _ref$default_value;
48
-
49
- var opts = [];
50
- if (groupType) {
51
- opts['as'] = groupType;
52
- if (groupType === reactBootstrap.Col) {
53
- opts['xs'] = 12;
54
- opts['md'] = 6;
55
- }
56
- }
57
-
58
- if (handleChanged) {
59
- opts['onChange'] = handleChanged;
60
- }
61
-
62
- if (readonly) {
63
- opts['readOnly'] = readonly;
64
- }
65
-
66
- if (type == 'text' || type == 'email' || type == 'password' || type == 'number') {
67
- return React__default.createElement(
68
- reactBootstrap.Form.Group,
69
- _extends$1._extends({}, opts, { controlId: name }),
70
- React__default.createElement(
71
- reactBootstrap.Form.Label,
72
- { kye: name + '_label' },
73
- label,
74
- required && React__default.createElement(
75
- 'span',
76
- { style: { color: 'red' } },
77
- '*'
78
- )
79
- ),
80
- React__default.createElement(reactBootstrap.Form.Control, { key: name + '_' + type, type: type, readOnly: readonly, name: name, placeholder: '', defaultValue: default_value, required: required }),
81
- React__default.createElement(
82
- reactBootstrap.Form.Control.Feedback,
83
- { key: name + '_feedback', type: 'invalid' },
84
- errors[name]
85
- )
86
- );
87
- }
88
- if (type == 'select') {
89
- return React__default.createElement(
90
- reactBootstrap.Form.Group,
91
- _extends$1._extends({}, opts, { key: name, controlId: name }),
92
- React__default.createElement(
93
- reactBootstrap.Form.Label,
94
- { key: name + '_' + label },
95
- label,
96
- required && React__default.createElement(
97
- 'span',
98
- { key: name + '_required_span', style: { color: 'red' } },
99
- '*'
100
- )
101
- ),
102
- React__default.createElement(
103
- reactBootstrap.Form.Control,
104
- { key: name + '_select', as: 'select', name: name, required: required, defaultValue: default_value },
105
- React__default.createElement('option', { value: '', key: name + '_options_empty' }),
106
- options.map(function (option, index) {
107
- var value = option.value ? option.value : option;
108
- var label = option.label ? option.label : option;
109
- var key = name + '_options_' + index;
110
- return React__default.createElement(
111
- 'option',
112
- { key: key, value: value },
113
- label
114
- );
115
- })
116
- )
117
- );
118
- }
119
-
120
- if (type == 'radio' || type == 'checkbox') {
121
- return React__default.createElement(
122
- reactBootstrap.Form.Group,
123
- opts,
124
- React__default.createElement(
125
- reactBootstrap.Form.Label,
126
- null,
127
- label,
128
- required && React__default.createElement(
129
- 'span',
130
- { style: { color: 'red' } },
131
- '*'
132
- )
133
- ),
134
- options.map(function (option, index) {
135
- return React__default.createElement(
136
- reactBootstrap.Form.Check,
137
- { type: type, key: index, required: required },
138
- React__default.createElement(reactBootstrap.Form.Check.Input, { type: type, key: type + '_' + index + '_input', defaultChecked: default_value ? default_value === option.value : false, name: name, id: name + '_' + index, value: option.value, required: required }),
139
- React__default.createElement(reactBootstrap.Form.Check.Label, { style: { cursor: 'pointer' }, 'for': name + '_' + index, key: type + '_' + index + '_label', dangerouslySetInnerHTML: { __html: option.label } })
140
- );
141
- })
142
- );
143
- }
144
- };
145
-
146
- var _this = undefined;
147
-
148
- var dataHandler = function () {
149
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(api_url, body) {
150
- var res, result;
151
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
152
- while (1) {
153
- switch (_context.prev = _context.next) {
154
- case 0:
155
- _context.prev = 0;
156
- _context.next = 3;
157
- return fetch(api_url, {
158
- method: 'POST',
159
- headers: { 'Content-Type': 'application/json' },
160
- body: stringify._JSON$stringify(body)
161
- });
162
-
163
- case 3:
164
- res = _context.sent;
165
-
166
- if (!(res.status === 200)) {
167
- _context.next = 13;
168
- break;
169
- }
170
-
171
- _context.next = 7;
172
- return res.json();
173
-
174
- case 7:
175
- result = _context.sent;
176
-
177
- if (!result.error) {
178
- _context.next = 10;
179
- break;
180
- }
181
-
182
- throw new Error(result.error);
183
-
184
- case 10:
185
- return _context.abrupt('return', result.data);
186
-
187
- case 13:
188
- _context.t0 = Error;
189
- _context.next = 16;
190
- return res.text();
191
-
192
- case 16:
193
- _context.t1 = _context.sent;
194
- throw new _context.t0(_context.t1);
195
-
196
- case 18:
197
- _context.next = 24;
198
- break;
199
-
200
- case 20:
201
- _context.prev = 20;
202
- _context.t2 = _context['catch'](0);
203
-
204
- console.error('data handler failed : ' + api_url, _context.t2);
205
- return _context.abrupt('return', null);
206
-
207
- case 24:
208
- case 'end':
209
- return _context.stop();
210
- }
211
- }
212
- }, _callee, _this, [[0, 20]]);
213
- }));
214
-
215
- return function dataHandler(_x, _x2) {
216
- return _ref.apply(this, arguments);
217
- };
218
- }();
219
-
220
- function useUser() {
221
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
222
- redirectTo = _ref.redirectTo,
223
- redirectIfFound = _ref.redirectIfFound;
224
-
225
- var _useSWR = useSWR('/api/auth/user', dataHandler),
226
- data = _useSWR.data,
227
- error = _useSWR.error;
228
-
229
- var user = data;
230
- var finished = Boolean(data);
231
- var hasUser = Boolean(user);
232
-
233
- React.useEffect(function () {
234
- if (!redirectTo || !finished) return;
235
- if (
236
- // If redirectTo is set, redirect if the user was not found.
237
- redirectTo && !redirectIfFound && !hasUser ||
238
- // If redirectIfFound is also set, redirect if the user was found
239
- redirectIfFound && hasUser) {
240
- Router__default.push(redirectTo);
241
- }
242
- }, [redirectTo, redirectIfFound, finished, hasUser]);
243
-
244
- return error ? null : user;
245
- }
246
-
247
- var hooks = /*#__PURE__*/Object.freeze({
248
- __proto__: null,
249
- useUser: useUser
250
- });
251
-
252
- var LoginForm = function LoginForm(props) {
253
- var handleSubmit = function () {
254
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(e) {
255
- var body, res;
256
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
257
- while (1) {
258
- switch (_context.prev = _context.next) {
259
- case 0:
260
- event.preventDefault();
261
-
262
- if (errorMsg) setErrorMsg('');
263
- setLoading(true);
264
-
265
- body = {
266
- email: e.currentTarget.email.value,
267
- password: e.currentTarget.password.value
268
- };
269
- _context.prev = 4;
270
- _context.next = 7;
271
- return fetch('/api/auth/login', {
272
- method: 'POST',
273
- headers: { 'Content-Type': 'application/json' },
274
- body: stringify._JSON$stringify(body)
275
- });
276
-
277
- case 7:
278
- res = _context.sent;
279
-
280
- setLoading(false);
281
-
282
- if (!(res.status === 200)) {
283
- _context.next = 13;
284
- break;
285
- }
286
-
287
- // here, Router.push() does not carry new cookie value.
288
- // so need hard redirect
289
- window.location.href = callbackUrl;
290
- _context.next = 18;
291
- break;
292
-
293
- case 13:
294
- _context.t0 = Error;
295
- _context.next = 16;
296
- return res.text();
297
-
298
- case 16:
299
- _context.t1 = _context.sent;
300
- throw new _context.t0(_context.t1);
301
-
302
- case 18:
303
- _context.next = 23;
304
- break;
305
-
306
- case 20:
307
- _context.prev = 20;
308
- _context.t2 = _context['catch'](4);
309
-
310
- setErrorMsg(_context.t2.message);
311
-
312
- case 23:
313
- case 'end':
314
- return _context.stop();
315
- }
316
- }
317
- }, _callee, this, [[4, 20]]);
318
- }));
319
-
320
- return function handleSubmit(_x) {
321
- return _ref.apply(this, arguments);
322
- };
323
- }();
324
-
325
- var _props$callbackUrl = props.callbackUrl,
326
- callbackUrl = _props$callbackUrl === undefined ? '/' : _props$callbackUrl;
327
-
328
-
329
- React.useEffect(function () {
330
- if (props.user) {
331
- window.location.href = '/auth/profile';
332
- }
333
- }, []);
334
- useUser('/auth/profile', true);
335
-
336
- var _useState = React.useState(''),
337
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
338
- errorMsg = _useState2[0],
339
- setErrorMsg = _useState2[1];
340
-
341
- var _useState3 = React.useState(false),
342
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
343
- loading = _useState4[0],
344
- setLoading = _useState4[1];
345
-
346
- return React__default.createElement(
347
- reactBootstrap.Form,
348
- { className: 'login', onSubmit: handleSubmit },
349
- React__default.createElement(
350
- 'h1',
351
- null,
352
- 'Login'
353
- ),
354
- React__default.createElement('hr', null),
355
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
356
- returnFormField({ name: 'password', label: 'Password', type: 'password', required: true }),
357
- React__default.createElement('hr', null),
358
- React__default.createElement(
359
- reactBootstrap.Form.Row,
360
- null,
361
- React__default.createElement(
362
- reactBootstrap.Form.Group,
363
- { as: reactBootstrap.Col },
364
- React__default.createElement(
365
- 'a',
366
- { href: '/auth/signup' },
367
- 'I don\'t have an account'
368
- )
369
- ),
370
- React__default.createElement(
371
- reactBootstrap.Form.Group,
372
- { as: reactBootstrap.Col, className: 'text-right' },
373
- !loading && React__default.createElement(
374
- reactBootstrap.Button,
375
- { type: 'submit' },
376
- 'Login'
377
- ),
378
- loading && React__default.createElement(
379
- reactBootstrap.Button,
380
- { variant: 'primary', disabled: true },
381
- React__default.createElement(reactBootstrap.Spinner, { as: 'span', animation: 'border', role: 'status', 'aria-hidden': 'true', size: 'sm' }),
382
- React__default.createElement(
383
- 'span',
384
- { className: 'sr-only' },
385
- 'Loading...'
386
- )
387
- )
388
- )
389
- ),
390
- errorMsg && React__default.createElement(
391
- 'p',
392
- { className: 'error' },
393
- errorMsg
394
- ),
395
- React__default.createElement(
396
- 'style',
397
- { jsx: 'true'.toString() },
398
- '\n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
399
- )
400
- );
401
- };
402
-
403
- // get country & state options
404
- var countries = ["United States", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas (the)", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia (Plurinational State of)", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory (the)", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands (the)", "Central African Republic (the)", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands (the)", "Colombia", "Comoros (the)", "Congo (the Democratic Republic of the)", "Congo (the)", "Cook Islands (the)", "Costa Rica", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czechia", "Côte d'Ivoire", "Denmark", "Djibouti", "Dominica", "Dominican Republic (the)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Falkland Islands (the) [Malvinas]", "Faroe Islands (the)", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories (the)", "Gabon", "Gambia (the)", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (the)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea (the Democratic People's Republic of)", "Korea (the Republic of)", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic (the)", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands (the)", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia (Federated States of)", "Moldova (the Republic of)", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands (the)", "New Caledonia", "New Zealand", "Nicaragua", "Niger (the)", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands (the)", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines (the)", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Republic of North Macedonia", "Romania", "Russian Federation (the)", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan (the)", "Suriname", "Svalbard and Jan Mayen", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan (Province of China)", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands (the)", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates (the)", "United Kingdom of Great Britain and Northern Ireland (the)", "United States Minor Outlying Islands (the)", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela (Bolivarian Republic of)", "Viet Nam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åland Islands"];
405
-
406
- var states = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY'];
407
-
408
- var _this$1 = undefined;
409
-
410
- var SignupForm = function SignupForm(props) {
411
- var handleSubmit = function () {
412
- var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(e) {
413
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
414
-
415
- return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
416
- while (1) {
417
- switch (_context3.prev = _context3.next) {
418
- case 0:
419
- event.preventDefault();
420
- setLoading(true);
421
- if (errorMsg) setErrorMsg('');
422
-
423
- formData = new FormData(e.currentTarget);
424
- body = {};
425
- _iteratorNormalCompletion = true;
426
- _didIteratorError = false;
427
- _iteratorError = undefined;
428
- _context3.prev = 8;
429
-
430
- for (_iterator = slicedToArray._getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
431
- key = _step.value;
432
-
433
- body[key] = formData.get(key);
434
- }
435
-
436
- _context3.next = 16;
437
- break;
438
-
439
- case 12:
440
- _context3.prev = 12;
441
- _context3.t0 = _context3['catch'](8);
442
- _didIteratorError = true;
443
- _iteratorError = _context3.t0;
444
-
445
- case 16:
446
- _context3.prev = 16;
447
- _context3.prev = 17;
448
-
449
- if (!_iteratorNormalCompletion && _iterator.return) {
450
- _iterator.return();
451
- }
452
-
453
- case 19:
454
- _context3.prev = 19;
455
-
456
- if (!_didIteratorError) {
457
- _context3.next = 22;
458
- break;
459
- }
460
-
461
- throw _iteratorError;
462
-
463
- case 22:
464
- return _context3.finish(19);
465
-
466
- case 23:
467
- return _context3.finish(16);
468
-
469
- case 24:
470
- _context3.prev = 24;
471
- _context3.next = 27;
472
- return fetch('/api/auth/signup', {
473
- method: 'POST',
474
- headers: { 'Content-Type': 'application/json' },
475
- body: stringify._JSON$stringify(body)
476
- });
477
-
478
- case 27:
479
- res = _context3.sent;
480
-
481
- setLoading(false);
482
-
483
- if (!(res.status === 200)) {
484
- _context3.next = 33;
485
- break;
486
- }
487
-
488
- window.location.href = '/';
489
- _context3.next = 38;
490
- break;
491
-
492
- case 33:
493
- _context3.t1 = Error;
494
- _context3.next = 36;
495
- return res.text();
496
-
497
- case 36:
498
- _context3.t2 = _context3.sent;
499
- throw new _context3.t1(_context3.t2);
500
-
501
- case 38:
502
- _context3.next = 43;
503
- break;
504
-
505
- case 40:
506
- _context3.prev = 40;
507
- _context3.t3 = _context3['catch'](24);
508
-
509
- setErrorMsg(_context3.t3.message);
510
-
511
- case 43:
512
- case 'end':
513
- return _context3.stop();
514
- }
515
- }
516
- }, _callee3, this, [[8, 12, 16, 24], [17,, 19, 23], [24, 40]]);
517
- }));
518
-
519
- return function handleSubmit(_x2) {
520
- return _ref3.apply(this, arguments);
521
- };
522
- }();
523
-
524
- var _useState = React.useState(''),
525
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
526
- errorMsg = _useState2[0],
527
- setErrorMsg = _useState2[1];
528
-
529
- var _useState3 = React.useState(false),
530
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
531
- countryUS = _useState4[0],
532
- setCountryUS = _useState4[1];
533
-
534
- var _useState5 = React.useState([]),
535
- _useState6 = slicedToArray._slicedToArray(_useState5, 2),
536
- healthcareOccupation = _useState6[0],
537
- setHealthcareOccupation = _useState6[1];
538
-
539
- var _useState7 = React.useState([]),
540
- _useState8 = slicedToArray._slicedToArray(_useState7, 2),
541
- nonHealthcareOccupation = _useState8[0],
542
- setNonHealthcareOccupation = _useState8[1];
543
-
544
- var loadInitData = function () {
545
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
546
- var healthcare_occupation, non_healthcare_occupation;
547
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
548
- while (1) {
549
- switch (_context.prev = _context.next) {
550
- case 0:
551
- _context.next = 2;
552
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
553
-
554
- case 2:
555
- healthcare_occupation = _context.sent;
556
- _context.next = 5;
557
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
558
-
559
- case 5:
560
- non_healthcare_occupation = _context.sent;
561
-
562
-
563
- setHealthcareOccupation(healthcare_occupation);
564
- setNonHealthcareOccupation(non_healthcare_occupation);
565
-
566
- case 8:
567
- case 'end':
568
- return _context.stop();
569
- }
570
- }
571
- }, _callee, _this$1);
572
- }));
573
-
574
- return function loadInitData() {
575
- return _ref.apply(this, arguments);
576
- };
577
- }();
578
-
579
- React.useEffect(function () {
580
- if (props.user) {
581
- window.location.href = '/auth/profile';
582
- } else {
583
- loadInitData();
584
- }
585
- }, []);
586
-
587
- // make it to change layout based on radio buton
588
- var handleCountryChanged = function handleCountryChanged(e) {
589
- if (e.target.value === 'United States') {
590
- setCountryUS(true);
591
- } else {
592
- setCountryUS(false);
593
- }
594
- };
595
-
596
- var _useState9 = React.useState(true),
597
- _useState10 = slicedToArray._slicedToArray(_useState9, 2),
598
- healcareProfessional = _useState10[0],
599
- setHealthcareProfessional = _useState10[1];
600
-
601
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
602
-
603
- if (e.target.value === 'Y') {
604
- setHealthcareProfessional(true);
605
- } else {
606
- setHealthcareProfessional(false);
607
- }
608
- document.getElementById('occupation').value = '';
609
- setOccupationFields(null);
610
- };
611
-
612
- var _useState11 = React.useState(null),
613
- _useState12 = slicedToArray._slicedToArray(_useState11, 2),
614
- occupationFields = _useState12[0],
615
- setOccupationFields = _useState12[1];
616
-
617
- var handleOccupationChanged = function () {
618
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(e) {
619
- var occupation, fields;
620
- return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
621
- while (1) {
622
- switch (_context2.prev = _context2.next) {
623
- case 0:
624
- occupation = e.target.value;
625
- _context2.next = 3;
626
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
627
-
628
- case 3:
629
- fields = _context2.sent;
630
-
631
- setOccupationFields(fields);
632
-
633
- case 5:
634
- case 'end':
635
- return _context2.stop();
636
- }
637
- }
638
- }, _callee2, _this$1);
639
- }));
640
-
641
- return function handleOccupationChanged(_x) {
642
- return _ref2.apply(this, arguments);
643
- };
644
- }();
645
-
646
- var _useState13 = React.useState(false),
647
- _useState14 = slicedToArray._slicedToArray(_useState13, 2),
648
- loading = _useState14[0],
649
- setLoading = _useState14[1];
650
-
651
- return React__default.createElement(
652
- reactBootstrap.Form,
653
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
654
- React__default.createElement(
655
- 'h1',
656
- null,
657
- 'Sign Up'
658
- ),
659
- React__default.createElement('hr', null),
660
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
661
- React__default.createElement(
662
- reactBootstrap.Form.Row,
663
- null,
664
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: reactBootstrap.Col, required: true }),
665
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: reactBootstrap.Col, required: true })
666
- ),
667
- React__default.createElement(
668
- reactBootstrap.Form.Row,
669
- null,
670
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: reactBootstrap.Col, required: true }),
671
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: reactBootstrap.Col, required: true })
672
- ),
673
- React__default.createElement(
674
- reactBootstrap.Form.Row,
675
- null,
676
- returnFormField({
677
- name: 'country',
678
- label: 'Country',
679
- type: 'select',
680
- required: true,
681
- groupType: reactBootstrap.Col,
682
- options: countries,
683
- handleChanged: handleCountryChanged
684
- }),
685
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: reactBootstrap.Col, options: states })
686
- ),
687
- React__default.createElement(
688
- reactBootstrap.Form.Row,
689
- null,
690
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: reactBootstrap.Col }),
691
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: reactBootstrap.Col })
692
- ),
693
- returnFormField({
694
- name: 'healthcare_professional',
695
- label: 'Are You a Health Care Professional?',
696
- type: 'radio',
697
- required: true,
698
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
699
- handleChanged: handleHealthcareProfessionalChanged,
700
- default_value: 'Y'
701
- }),
702
- healcareProfessional && returnFormField({
703
- name: 'occupation',
704
- label: 'Occupation',
705
- type: 'select',
706
- required: true,
707
- options: healthcareOccupation,
708
- handleChanged: handleOccupationChanged
709
- }),
710
- !healcareProfessional && returnFormField({
711
- name: 'occupation',
712
- label: 'Non Provider Role',
713
- type: 'select',
714
- required: true,
715
- options: nonHealthcareOccupation,
716
- handleChanged: handleOccupationChanged
717
- }),
718
- occupationFields && occupationFields.map(function (field) {
719
- return returnFormField({
720
- name: field.name,
721
- label: field.label,
722
- type: field.type,
723
- required: field.required === 1,
724
- options: field.options
725
- });
726
- }),
727
- returnFormField({
728
- name: 'agree',
729
- label: 'Terms & Conditions | Privacy Policy',
730
- type: 'checkbox',
731
- required: true,
732
- options: [{ label: 'By registering you agree to our <a href="/terms" style="color:blue">Terms and Conditions</a> and <a href="/privacy" style="color:blue">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
733
- }),
734
- React__default.createElement('hr', null),
735
- React__default.createElement(
736
- reactBootstrap.Form.Row,
737
- null,
738
- React__default.createElement(
739
- reactBootstrap.Form.Group,
740
- { as: reactBootstrap.Col },
741
- React__default.createElement(
742
- 'a',
743
- { href: '/auth/login' },
744
- 'I already have an account'
745
- )
746
- ),
747
- React__default.createElement(
748
- reactBootstrap.Form.Group,
749
- { as: reactBootstrap.Col, className: 'text-right' },
750
- !loading && React__default.createElement(
751
- reactBootstrap.Button,
752
- { type: 'submit' },
753
- 'Sign Up'
754
- ),
755
- loading && React__default.createElement(
756
- reactBootstrap.Button,
757
- { variant: 'primary', disabled: true },
758
- React__default.createElement(reactBootstrap.Spinner, {
759
- as: 'span',
760
- animation: 'border',
761
- role: 'status',
762
- 'aria-hidden': 'true',
763
- size: 'sm'
764
- }),
765
- React__default.createElement(
766
- 'span',
767
- { className: 'sr-only' },
768
- 'Loading...'
769
- )
770
- )
771
- )
772
- ),
773
- errorMsg && React__default.createElement(
774
- 'p',
775
- { className: 'error' },
776
- errorMsg
777
- ),
778
- React__default.createElement(
779
- 'style',
780
- { jsx: 'true'.toString() },
781
- ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
782
- )
783
- );
784
- };
785
-
786
- var _this$2 = undefined;
787
-
788
- var SignupForm$1 = function SignupForm(props) {
789
- var handleSubmit = function () {
790
- var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(e) {
791
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
792
-
793
- return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
794
- while (1) {
795
- switch (_context3.prev = _context3.next) {
796
- case 0:
797
- event.preventDefault();
798
-
799
- setErrorMsg('');
800
- setSuccessMsg('');
801
- setLoading(true);
802
-
803
- formData = new FormData(e.currentTarget);
804
- body = {};
805
- _iteratorNormalCompletion = true;
806
- _didIteratorError = false;
807
- _iteratorError = undefined;
808
- _context3.prev = 9;
809
-
810
- for (_iterator = slicedToArray._getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
811
- key = _step.value;
812
-
813
- body[key] = formData.get(key);
814
- }
815
-
816
- _context3.next = 17;
817
- break;
818
-
819
- case 13:
820
- _context3.prev = 13;
821
- _context3.t0 = _context3['catch'](9);
822
- _didIteratorError = true;
823
- _iteratorError = _context3.t0;
824
-
825
- case 17:
826
- _context3.prev = 17;
827
- _context3.prev = 18;
828
-
829
- if (!_iteratorNormalCompletion && _iterator.return) {
830
- _iterator.return();
831
- }
832
-
833
- case 20:
834
- _context3.prev = 20;
835
-
836
- if (!_didIteratorError) {
837
- _context3.next = 23;
838
- break;
839
- }
840
-
841
- throw _iteratorError;
842
-
843
- case 23:
844
- return _context3.finish(20);
845
-
846
- case 24:
847
- return _context3.finish(17);
848
-
849
- case 25:
850
- body['user_id'] = userData.id;
851
-
852
- _context3.prev = 26;
853
- _context3.next = 29;
854
- return fetch('/api/auth/profile', {
855
- method: 'POST',
856
- headers: { 'Content-Type': 'application/json' },
857
- body: stringify._JSON$stringify(body)
858
- });
859
-
860
- case 29:
861
- res = _context3.sent;
862
-
863
- setLoading(false);
864
-
865
- if (!(res.status === 200)) {
866
- _context3.next = 35;
867
- break;
868
- }
869
-
870
- setSuccessMsg('Your request has been processed successfully!');
871
- _context3.next = 40;
872
- break;
873
-
874
- case 35:
875
- _context3.t1 = Error;
876
- _context3.next = 38;
877
- return res.text();
878
-
879
- case 38:
880
- _context3.t2 = _context3.sent;
881
- throw new _context3.t1(_context3.t2);
882
-
883
- case 40:
884
- _context3.next = 45;
885
- break;
886
-
887
- case 42:
888
- _context3.prev = 42;
889
- _context3.t3 = _context3['catch'](26);
890
-
891
- setErrorMsg(_context3.t3.message);
892
-
893
- case 45:
894
- case 'end':
895
- return _context3.stop();
896
- }
897
- }
898
- }, _callee3, this, [[9, 13, 17, 25], [18,, 20, 24], [26, 42]]);
899
- }));
900
-
901
- return function handleSubmit(_x2) {
902
- return _ref3.apply(this, arguments);
903
- };
904
- }();
905
-
906
- var _useState = React.useState(''),
907
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
908
- errorMsg = _useState2[0],
909
- setErrorMsg = _useState2[1];
910
-
911
- var _useState3 = React.useState(false),
912
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
913
- countryUS = _useState4[0],
914
- setCountryUS = _useState4[1];
915
-
916
- var _useState5 = React.useState([]),
917
- _useState6 = slicedToArray._slicedToArray(_useState5, 2),
918
- healthcareOccupation = _useState6[0],
919
- setHealthcareOccupation = _useState6[1];
920
-
921
- var _useState7 = React.useState([]),
922
- _useState8 = slicedToArray._slicedToArray(_useState7, 2),
923
- nonHealthcareOccupation = _useState8[0],
924
- setNonHealthcareOccupation = _useState8[1];
925
-
926
- var _useState9 = React.useState(null),
927
- _useState10 = slicedToArray._slicedToArray(_useState9, 2),
928
- userData = _useState10[0],
929
- setUserData = _useState10[1];
930
-
931
- var user = props.user;
932
-
933
- var loadInitData = function () {
934
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
935
- var healthcare_occupation, non_healthcare_occupation, foundOccupation, fields;
936
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
937
- while (1) {
938
- switch (_context.prev = _context.next) {
939
- case 0:
940
- _context.next = 2;
941
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
942
-
943
- case 2:
944
- healthcare_occupation = _context.sent;
945
- _context.next = 5;
946
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
947
-
948
- case 5:
949
- non_healthcare_occupation = _context.sent;
950
- foundOccupation = healthcare_occupation.find(function (item) {
951
- return item.value === user.shared.occupation_id;
952
- });
953
-
954
- if (foundOccupation) {
955
- user.shared.healthcare_professional = 'Y';
956
- } else {
957
- user.shared.healthcare_professional = 'N';
958
- }
959
-
960
- setHealthcareOccupation(healthcare_occupation);
961
- setNonHealthcareOccupation(non_healthcare_occupation);
962
- setUserData(user);
963
-
964
- if (user.shared.country === 'United States') {
965
- setCountryUS(true);
966
- } else {
967
- setCountryUS(false);
968
- }
969
-
970
- _context.next = 14;
971
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: user.shared.occupation_id });
972
-
973
- case 14:
974
- fields = _context.sent;
975
-
976
- setOccupationFields(fields);
977
-
978
- case 16:
979
- case 'end':
980
- return _context.stop();
981
- }
982
- }
983
- }, _callee, _this$2);
984
- }));
985
-
986
- return function loadInitData() {
987
- return _ref.apply(this, arguments);
988
- };
989
- }();
990
-
991
- React.useEffect(function () {
992
- if (!user) {
993
- window.location.href = '/auth/login';
994
- } else {
995
- loadInitData();
996
- }
997
- }, []);
998
-
999
- // make it to change layout based on radio buton
1000
- var handleCountryChanged = function handleCountryChanged(e) {
1001
- if (e.target.value === 'United States') {
1002
- setCountryUS(true);
1003
- } else {
1004
- setCountryUS(false);
1005
- }
1006
- };
1007
-
1008
- var _useState11 = React.useState(true),
1009
- _useState12 = slicedToArray._slicedToArray(_useState11, 2),
1010
- healcareProfessional = _useState12[0],
1011
- setHealthcareProfessional = _useState12[1];
1012
-
1013
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
1014
-
1015
- if (e.target.value === 'Y') {
1016
- setHealthcareProfessional(true);
1017
- } else {
1018
- setHealthcareProfessional(false);
1019
- }
1020
- document.getElementById('occupation').value = '';
1021
- setOccupationFields(null);
1022
- };
1023
-
1024
- var _useState13 = React.useState(null),
1025
- _useState14 = slicedToArray._slicedToArray(_useState13, 2),
1026
- occupationFields = _useState14[0],
1027
- setOccupationFields = _useState14[1];
1028
-
1029
- var handleOccupationChanged = function () {
1030
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(e) {
1031
- var occupation, fields;
1032
- return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
1033
- while (1) {
1034
- switch (_context2.prev = _context2.next) {
1035
- case 0:
1036
- occupation = e.target.value;
1037
- _context2.next = 3;
1038
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
1039
-
1040
- case 3:
1041
- fields = _context2.sent;
1042
-
1043
- setOccupationFields(fields);
1044
-
1045
- case 5:
1046
- case 'end':
1047
- return _context2.stop();
1048
- }
1049
- }
1050
- }, _callee2, _this$2);
1051
- }));
1052
-
1053
- return function handleOccupationChanged(_x) {
1054
- return _ref2.apply(this, arguments);
1055
- };
1056
- }();
1057
-
1058
- var _useState15 = React.useState(''),
1059
- _useState16 = slicedToArray._slicedToArray(_useState15, 2),
1060
- successMsg = _useState16[0],
1061
- setSuccessMsg = _useState16[1];
1062
-
1063
- var _useState17 = React.useState(false),
1064
- _useState18 = slicedToArray._slicedToArray(_useState17, 2),
1065
- loading = _useState18[0],
1066
- setLoading = _useState18[1];
1067
-
1068
- return React__default.createElement(
1069
- reactBootstrap.Form,
1070
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
1071
- React__default.createElement(
1072
- 'h1',
1073
- null,
1074
- 'Profile'
1075
- ),
1076
- React__default.createElement('hr', null),
1077
- userData ? React__default.createElement(
1078
- React__default.Fragment,
1079
- null,
1080
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true, readonly: true, default_value: userData.email }),
1081
- React__default.createElement(
1082
- reactBootstrap.Form.Row,
1083
- null,
1084
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: reactBootstrap.Col, required: false }),
1085
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: reactBootstrap.Col, required: false })
1086
- ),
1087
- React__default.createElement(
1088
- reactBootstrap.Form.Row,
1089
- null,
1090
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: reactBootstrap.Col, required: true, default_value: userData.shared.first_name }),
1091
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: reactBootstrap.Col, required: true, default_value: userData.shared.last_name })
1092
- ),
1093
- React__default.createElement(
1094
- reactBootstrap.Form.Row,
1095
- null,
1096
- returnFormField({
1097
- name: 'country',
1098
- label: 'Country',
1099
- type: 'select',
1100
- required: true,
1101
- groupType: reactBootstrap.Col,
1102
- options: countries,
1103
- handleChanged: handleCountryChanged,
1104
- default_value: userData.shared.country
1105
- }),
1106
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: reactBootstrap.Col, options: states, default_value: userData.shared.state })
1107
- ),
1108
- React__default.createElement(
1109
- reactBootstrap.Form.Row,
1110
- null,
1111
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: reactBootstrap.Col, default_value: userData.shared.zip }),
1112
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: reactBootstrap.Col, default_value: userData.shared.phone })
1113
- ),
1114
- returnFormField({
1115
- name: 'healthcare_professional',
1116
- label: 'Are You a Health Care Professional?',
1117
- type: 'radio',
1118
- required: true,
1119
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
1120
- default_value: userData.shared.healthcare_professional,
1121
- handleChanged: handleHealthcareProfessionalChanged
1122
- }),
1123
- healcareProfessional && returnFormField({
1124
- name: 'occupation',
1125
- label: 'Occupation',
1126
- type: 'select',
1127
- required: true,
1128
- options: healthcareOccupation,
1129
- handleChanged: handleOccupationChanged,
1130
- default_value: userData.shared.occupation_id
1131
- }),
1132
- !healcareProfessional && returnFormField({
1133
- name: 'occupation',
1134
- label: 'Non Provider Role',
1135
- type: 'select',
1136
- required: true,
1137
- options: nonHealthcareOccupation,
1138
- handleChanged: handleOccupationChanged,
1139
- default_value: userData.shared.occupation_id
1140
- }),
1141
- occupationFields && occupationFields.map(function (field) {
1142
- return returnFormField({
1143
- name: field.name,
1144
- label: field.label,
1145
- type: field.type,
1146
- required: field.required === 1,
1147
- options: field.options,
1148
- default_value: userData.shared[field.name]
1149
- });
1150
- }),
1151
- returnFormField({
1152
- name: 'agree',
1153
- label: 'Terms & Conditions | Privacy Policy',
1154
- type: 'checkbox',
1155
- required: true,
1156
- options: [{ label: 'By registering you agree to our <a href="/terms">Terms and Conditions</a> and <a href="/privacy">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
1157
- }),
1158
- React__default.createElement('hr', null),
1159
- React__default.createElement(
1160
- reactBootstrap.Form.Row,
1161
- null,
1162
- React__default.createElement(
1163
- reactBootstrap.Form.Group,
1164
- { as: reactBootstrap.Col },
1165
- !loading && React__default.createElement(
1166
- reactBootstrap.Button,
1167
- { type: 'submit' },
1168
- 'Update'
1169
- ),
1170
- loading && React__default.createElement(
1171
- reactBootstrap.Button,
1172
- { variant: 'primary', disabled: true },
1173
- React__default.createElement(reactBootstrap.Spinner, {
1174
- as: 'span',
1175
- animation: 'border',
1176
- role: 'status',
1177
- 'aria-hidden': 'true',
1178
- size: 'sm'
1179
- }),
1180
- React__default.createElement(
1181
- 'span',
1182
- { className: 'sr-only' },
1183
- 'Loading...'
1184
- )
1185
- )
1186
- )
1187
- )
1188
- ) : React__default.createElement(reactBootstrap.Spinner, {
1189
- as: 'span',
1190
- animation: 'border',
1191
- role: 'status',
1192
- 'aria-hidden': 'true',
1193
- size: 'sm'
1194
- }),
1195
- errorMsg && React__default.createElement(
1196
- 'p',
1197
- { className: 'error' },
1198
- errorMsg
1199
- ),
1200
- successMsg && React__default.createElement(
1201
- 'p',
1202
- { className: 'success' },
1203
- successMsg
1204
- ),
1205
- React__default.createElement(
1206
- 'style',
1207
- { jsx: 'true'.toString() },
1208
- ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n .success {\n color: green;\n margin: 1rem 0 0;\n }\n '
1209
- )
1210
- );
1211
- };
1212
-
1213
- /*!
1214
- * cookie
1215
- * Copyright(c) 2012-2014 Roman Shtylman
1216
- * Copyright(c) 2015 Douglas Christopher Wilson
1217
- * MIT Licensed
1218
- */
1219
-
1220
- /**
1221
- * Module exports.
1222
- * @public
1223
- */
1224
-
1225
- var parse_1 = parse;
1226
- var serialize_1 = serialize;
1227
-
1228
- /**
1229
- * Module variables.
1230
- * @private
1231
- */
1232
-
1233
- var decode = decodeURIComponent;
1234
- var encode = encodeURIComponent;
1235
- var pairSplitRegExp = /; */;
1236
-
1237
- /**
1238
- * RegExp to match field-content in RFC 7230 sec 3.2
1239
- *
1240
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
1241
- * field-vchar = VCHAR / obs-text
1242
- * obs-text = %x80-FF
1243
- */
1244
-
1245
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1246
-
1247
- /**
1248
- * Parse a cookie header.
1249
- *
1250
- * Parse the given cookie header string into an object
1251
- * The object has the various cookies as keys(names) => values
1252
- *
1253
- * @param {string} str
1254
- * @param {object} [options]
1255
- * @return {object}
1256
- * @public
1257
- */
1258
-
1259
- function parse(str, options) {
1260
- if (typeof str !== 'string') {
1261
- throw new TypeError('argument str must be a string');
1262
- }
1263
-
1264
- var obj = {};
1265
- var opt = options || {};
1266
- var pairs = str.split(pairSplitRegExp);
1267
- var dec = opt.decode || decode;
1268
-
1269
- for (var i = 0; i < pairs.length; i++) {
1270
- var pair = pairs[i];
1271
- var eq_idx = pair.indexOf('=');
1272
-
1273
- // skip things that don't look like key=value
1274
- if (eq_idx < 0) {
1275
- continue;
1276
- }
1277
-
1278
- var key = pair.substr(0, eq_idx).trim();
1279
- var val = pair.substr(++eq_idx, pair.length).trim();
1280
-
1281
- // quoted values
1282
- if ('"' == val[0]) {
1283
- val = val.slice(1, -1);
1284
- }
1285
-
1286
- // only assign once
1287
- if (undefined == obj[key]) {
1288
- obj[key] = tryDecode(val, dec);
1289
- }
1290
- }
1291
-
1292
- return obj;
1293
- }
1294
-
1295
- /**
1296
- * Serialize data into a cookie header.
1297
- *
1298
- * Serialize the a name value pair into a cookie string suitable for
1299
- * http headers. An optional options object specified cookie parameters.
1300
- *
1301
- * serialize('foo', 'bar', { httpOnly: true })
1302
- * => "foo=bar; httpOnly"
1303
- *
1304
- * @param {string} name
1305
- * @param {string} val
1306
- * @param {object} [options]
1307
- * @return {string}
1308
- * @public
1309
- */
1310
-
1311
- function serialize(name, val, options) {
1312
- var opt = options || {};
1313
- var enc = opt.encode || encode;
1314
-
1315
- if (typeof enc !== 'function') {
1316
- throw new TypeError('option encode is invalid');
1317
- }
1318
-
1319
- if (!fieldContentRegExp.test(name)) {
1320
- throw new TypeError('argument name is invalid');
1321
- }
1322
-
1323
- var value = enc(val);
1324
-
1325
- if (value && !fieldContentRegExp.test(value)) {
1326
- throw new TypeError('argument val is invalid');
1327
- }
1328
-
1329
- var str = name + '=' + value;
1330
-
1331
- if (null != opt.maxAge) {
1332
- var maxAge = opt.maxAge - 0;
1333
-
1334
- if (isNaN(maxAge) || !isFinite(maxAge)) {
1335
- throw new TypeError('option maxAge is invalid')
1336
- }
1337
-
1338
- str += '; Max-Age=' + Math.floor(maxAge);
1339
- }
1340
-
1341
- if (opt.domain) {
1342
- if (!fieldContentRegExp.test(opt.domain)) {
1343
- throw new TypeError('option domain is invalid');
1344
- }
1345
-
1346
- str += '; Domain=' + opt.domain;
1347
- }
1348
-
1349
- if (opt.path) {
1350
- if (!fieldContentRegExp.test(opt.path)) {
1351
- throw new TypeError('option path is invalid');
1352
- }
1353
-
1354
- str += '; Path=' + opt.path;
1355
- }
1356
-
1357
- if (opt.expires) {
1358
- if (typeof opt.expires.toUTCString !== 'function') {
1359
- throw new TypeError('option expires is invalid');
1360
- }
1361
-
1362
- str += '; Expires=' + opt.expires.toUTCString();
1363
- }
1364
-
1365
- if (opt.httpOnly) {
1366
- str += '; HttpOnly';
1367
- }
1368
-
1369
- if (opt.secure) {
1370
- str += '; Secure';
1371
- }
1372
-
1373
- if (opt.sameSite) {
1374
- var sameSite = typeof opt.sameSite === 'string'
1375
- ? opt.sameSite.toLowerCase() : opt.sameSite;
1376
-
1377
- switch (sameSite) {
1378
- case true:
1379
- str += '; SameSite=Strict';
1380
- break;
1381
- case 'lax':
1382
- str += '; SameSite=Lax';
1383
- break;
1384
- case 'strict':
1385
- str += '; SameSite=Strict';
1386
- break;
1387
- case 'none':
1388
- str += '; SameSite=None';
1389
- break;
1390
- default:
1391
- throw new TypeError('option sameSite is invalid');
1392
- }
1393
- }
1394
-
1395
- return str;
1396
- }
1397
-
1398
- /**
1399
- * Try decoding a string using a decoding function.
1400
- *
1401
- * @param {string} str
1402
- * @param {function} decode
1403
- * @private
1404
- */
1405
-
1406
- function tryDecode(str, decode) {
1407
- try {
1408
- return decode(str);
1409
- } catch (e) {
1410
- return str;
1411
- }
1412
- }
1413
-
1414
- var TOKEN_NAME = 'token';
1415
- var MAX_AGE = 60 * 60 * 8; // 8 hours
1416
-
1417
- function setTokenCookie(res, token, eKey) {
1418
- var cookies_serailized = [];
1419
- cookies_serailized.push(serialize_1(TOKEN_NAME, token, {
1420
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1421
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1422
- //httpOnly: true,
1423
- //secure: process.env.NODE_ENV === 'production',
1424
- path: '/'
1425
- //sameSite: 'lax',
1426
- }));
1427
-
1428
- cookies_serailized.push(serialize_1('eKey', eKey, {
1429
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1430
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1431
- //httpOnly: true,
1432
- //secure: process.env.NODE_ENV === 'production',
1433
- path: '/'
1434
- //sameSite: 'lax',
1435
- }));
1436
-
1437
- res.setHeader('Set-Cookie', cookies_serailized);
1438
- }
1439
-
1440
- function removeTokenCookie(res) {
1441
- var cookies_serailized = [];
1442
- cookies_serailized.push(serialize_1(TOKEN_NAME, '', {
1443
- maxAge: -1,
1444
- expires: new Date(Date.now() - MAX_AGE * 1000),
1445
- path: '/'
1446
- }));
1447
- cookies_serailized.push(serialize_1('eKey', '', {
1448
- maxAge: -1,
1449
- expires: new Date(Date.now() - MAX_AGE * 1000),
1450
- path: '/'
1451
- }));
1452
-
1453
- res.setHeader('Set-Cookie', cookies_serailized);
1454
- }
1455
-
1456
- function parseCookies(req) {
1457
- // For API Routes we don't need to parse the cookies.
1458
- if (req.cookies) return req.cookies;
1459
-
1460
- // For pages we do need to parse the cookies.
1461
- var cookie = req.headers ? req.headers.cookie : null;
1462
- return parse_1(cookie || '');
1463
- }
1464
-
1465
- function getTokenCookie(req) {
1466
- var cookies = parseCookies(req);
1467
- return cookies[TOKEN_NAME];
1468
- }
1469
-
1470
- var authCookies = /*#__PURE__*/Object.freeze({
1471
- __proto__: null,
1472
- setTokenCookie: setTokenCookie,
1473
- removeTokenCookie: removeTokenCookie,
1474
- parseCookies: parseCookies,
1475
- getTokenCookie: getTokenCookie
1476
- });
1477
-
1478
- function encryptSession(session) {
1479
- var buffer = new Buffer(stringify._JSON$stringify(session));
1480
- return buffer.toString('base64');
1481
- //return jwt.sign(session, TOKEN_SECRET)
1482
- //return Iron.seal(session, TOKEN_SECRET, Iron.defaults)
1483
- }
1484
-
1485
- var getSession = function () {
1486
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(req) {
1487
- var token, buff;
1488
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
1489
- while (1) {
1490
- switch (_context.prev = _context.next) {
1491
- case 0:
1492
- token = getTokenCookie(req);
1493
-
1494
- if (!token) {
1495
- _context.next = 4;
1496
- break;
1497
- }
1498
-
1499
- buff = new Buffer(token, 'base64');
1500
- return _context.abrupt('return', JSON.parse(buff.toString('utf8')));
1501
-
1502
- case 4:
1503
- return _context.abrupt('return', null);
1504
-
1505
- case 5:
1506
- case 'end':
1507
- return _context.stop();
1508
- }
1509
- }
1510
- }, _callee, this);
1511
- }));
1512
-
1513
- return function getSession(_x) {
1514
- return _ref.apply(this, arguments);
1515
- };
1516
- }();
1517
-
1518
- var iron = /*#__PURE__*/Object.freeze({
1519
- __proto__: null,
1520
- encryptSession: encryptSession,
1521
- getSession: getSession
1522
- });
1523
-
1524
- var toStr = Object.prototype.toString;
1525
-
1526
- var isArguments = function isArguments(value) {
1527
- var str = toStr.call(value);
1528
- var isArgs = str === '[object Arguments]';
1529
- if (!isArgs) {
1530
- isArgs = str !== '[object Array]' &&
1531
- value !== null &&
1532
- typeof value === 'object' &&
1533
- typeof value.length === 'number' &&
1534
- value.length >= 0 &&
1535
- toStr.call(value.callee) === '[object Function]';
1536
- }
1537
- return isArgs;
1538
- };
1539
-
1540
- var keysShim;
1541
- if (!Object.keys) {
1542
- // modified from https://github.com/es-shims/es5-shim
1543
- var has = Object.prototype.hasOwnProperty;
1544
- var toStr$1 = Object.prototype.toString;
1545
- var isArgs = isArguments; // eslint-disable-line global-require
1546
- var isEnumerable = Object.prototype.propertyIsEnumerable;
1547
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
1548
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
1549
- var dontEnums = [
1550
- 'toString',
1551
- 'toLocaleString',
1552
- 'valueOf',
1553
- 'hasOwnProperty',
1554
- 'isPrototypeOf',
1555
- 'propertyIsEnumerable',
1556
- 'constructor'
1557
- ];
1558
- var equalsConstructorPrototype = function (o) {
1559
- var ctor = o.constructor;
1560
- return ctor && ctor.prototype === o;
1561
- };
1562
- var excludedKeys = {
1563
- $applicationCache: true,
1564
- $console: true,
1565
- $external: true,
1566
- $frame: true,
1567
- $frameElement: true,
1568
- $frames: true,
1569
- $innerHeight: true,
1570
- $innerWidth: true,
1571
- $onmozfullscreenchange: true,
1572
- $onmozfullscreenerror: true,
1573
- $outerHeight: true,
1574
- $outerWidth: true,
1575
- $pageXOffset: true,
1576
- $pageYOffset: true,
1577
- $parent: true,
1578
- $scrollLeft: true,
1579
- $scrollTop: true,
1580
- $scrollX: true,
1581
- $scrollY: true,
1582
- $self: true,
1583
- $webkitIndexedDB: true,
1584
- $webkitStorageInfo: true,
1585
- $window: true
1586
- };
1587
- var hasAutomationEqualityBug = (function () {
1588
- /* global window */
1589
- if (typeof window === 'undefined') { return false; }
1590
- for (var k in window) {
1591
- try {
1592
- if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
1593
- try {
1594
- equalsConstructorPrototype(window[k]);
1595
- } catch (e) {
1596
- return true;
1597
- }
1598
- }
1599
- } catch (e) {
1600
- return true;
1601
- }
1602
- }
1603
- return false;
1604
- }());
1605
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
1606
- /* global window */
1607
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
1608
- return equalsConstructorPrototype(o);
1609
- }
1610
- try {
1611
- return equalsConstructorPrototype(o);
1612
- } catch (e) {
1613
- return false;
1614
- }
1615
- };
1616
-
1617
- keysShim = function keys(object) {
1618
- var isObject = object !== null && typeof object === 'object';
1619
- var isFunction = toStr$1.call(object) === '[object Function]';
1620
- var isArguments = isArgs(object);
1621
- var isString = isObject && toStr$1.call(object) === '[object String]';
1622
- var theKeys = [];
1623
-
1624
- if (!isObject && !isFunction && !isArguments) {
1625
- throw new TypeError('Object.keys called on a non-object');
1626
- }
1627
-
1628
- var skipProto = hasProtoEnumBug && isFunction;
1629
- if (isString && object.length > 0 && !has.call(object, 0)) {
1630
- for (var i = 0; i < object.length; ++i) {
1631
- theKeys.push(String(i));
1632
- }
1633
- }
1634
-
1635
- if (isArguments && object.length > 0) {
1636
- for (var j = 0; j < object.length; ++j) {
1637
- theKeys.push(String(j));
1638
- }
1639
- } else {
1640
- for (var name in object) {
1641
- if (!(skipProto && name === 'prototype') && has.call(object, name)) {
1642
- theKeys.push(String(name));
1643
- }
1644
- }
1645
- }
1646
-
1647
- if (hasDontEnumBug) {
1648
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
1649
-
1650
- for (var k = 0; k < dontEnums.length; ++k) {
1651
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
1652
- theKeys.push(dontEnums[k]);
1653
- }
1654
- }
1655
- }
1656
- return theKeys;
1657
- };
1658
- }
1659
- var implementation = keysShim;
1660
-
1661
- var slice = Array.prototype.slice;
1662
-
1663
-
1664
- var origKeys = Object.keys;
1665
- var keysShim$1 = origKeys ? function keys(o) { return origKeys(o); } : implementation;
1666
-
1667
- var originalKeys = Object.keys;
1668
-
1669
- keysShim$1.shim = function shimObjectKeys() {
1670
- if (Object.keys) {
1671
- var keysWorksWithArguments = (function () {
1672
- // Safari 5.0 bug
1673
- var args = Object.keys(arguments);
1674
- return args && args.length === arguments.length;
1675
- }(1, 2));
1676
- if (!keysWorksWithArguments) {
1677
- Object.keys = function keys(object) { // eslint-disable-line func-name-matching
1678
- if (isArguments(object)) {
1679
- return originalKeys(slice.call(object));
1680
- }
1681
- return originalKeys(object);
1682
- };
1683
- }
1684
- } else {
1685
- Object.keys = keysShim$1;
1686
- }
1687
- return Object.keys || keysShim$1;
1688
- };
1689
-
1690
- var objectKeys = keysShim$1;
1691
-
1692
- var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
1693
-
1694
- var toStr$2 = Object.prototype.toString;
1695
- var concat = Array.prototype.concat;
1696
- var origDefineProperty = Object.defineProperty;
1697
-
1698
- var isFunction = function (fn) {
1699
- return typeof fn === 'function' && toStr$2.call(fn) === '[object Function]';
1700
- };
1701
-
1702
- var arePropertyDescriptorsSupported = function () {
1703
- var obj = {};
1704
- try {
1705
- origDefineProperty(obj, 'x', { enumerable: false, value: obj });
1706
- // eslint-disable-next-line no-unused-vars, no-restricted-syntax
1707
- for (var _ in obj) { // jscs:ignore disallowUnusedVariables
1708
- return false;
1709
- }
1710
- return obj.x === obj;
1711
- } catch (e) { /* this is IE 8. */
1712
- return false;
1713
- }
1714
- };
1715
- var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
1716
-
1717
- var defineProperty = function (object, name, value, predicate) {
1718
- if (name in object && (!isFunction(predicate) || !predicate())) {
1719
- return;
1720
- }
1721
- if (supportsDescriptors) {
1722
- origDefineProperty(object, name, {
1723
- configurable: true,
1724
- enumerable: false,
1725
- value: value,
1726
- writable: true
1727
- });
1728
- } else {
1729
- object[name] = value;
1730
- }
1731
- };
1732
-
1733
- var defineProperties = function (object, map) {
1734
- var predicates = arguments.length > 2 ? arguments[2] : {};
1735
- var props = objectKeys(map);
1736
- if (hasSymbols) {
1737
- props = concat.call(props, Object.getOwnPropertySymbols(map));
1738
- }
1739
- for (var i = 0; i < props.length; i += 1) {
1740
- defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
1741
- }
1742
- };
1743
-
1744
- defineProperties.supportsDescriptors = !!supportsDescriptors;
1745
-
1746
- var defineProperties_1 = defineProperties;
1747
-
1748
- /* eslint complexity: [2, 18], max-statements: [2, 33] */
1749
- var shams = function hasSymbols() {
1750
- if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
1751
- if (typeof Symbol.iterator === 'symbol') { return true; }
1752
-
1753
- var obj = {};
1754
- var sym = Symbol('test');
1755
- var symObj = Object(sym);
1756
- if (typeof sym === 'string') { return false; }
1757
-
1758
- if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
1759
- if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
1760
-
1761
- // temp disabled per https://github.com/ljharb/object.assign/issues/17
1762
- // if (sym instanceof Symbol) { return false; }
1763
- // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
1764
- // if (!(symObj instanceof Symbol)) { return false; }
1765
-
1766
- // if (typeof Symbol.prototype.toString !== 'function') { return false; }
1767
- // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
1768
-
1769
- var symVal = 42;
1770
- obj[sym] = symVal;
1771
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
1772
- if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
1773
-
1774
- if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
1775
-
1776
- var syms = Object.getOwnPropertySymbols(obj);
1777
- if (syms.length !== 1 || syms[0] !== sym) { return false; }
1778
-
1779
- if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
1780
-
1781
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
1782
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
1783
- if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
1784
- }
1785
-
1786
- return true;
1787
- };
1788
-
1789
- var origSymbol = _commonjsHelpers.commonjsGlobal.Symbol;
1790
-
1791
-
1792
- var hasSymbols$1 = function hasNativeSymbols() {
1793
- if (typeof origSymbol !== 'function') { return false; }
1794
- if (typeof Symbol !== 'function') { return false; }
1795
- if (typeof origSymbol('foo') !== 'symbol') { return false; }
1796
- if (typeof Symbol('bar') !== 'symbol') { return false; }
1797
-
1798
- return shams();
1799
- };
1800
-
1801
- /* eslint no-invalid-this: 1 */
1802
-
1803
- var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
1804
- var slice$1 = Array.prototype.slice;
1805
- var toStr$3 = Object.prototype.toString;
1806
- var funcType = '[object Function]';
1807
-
1808
- var implementation$1 = function bind(that) {
1809
- var target = this;
1810
- if (typeof target !== 'function' || toStr$3.call(target) !== funcType) {
1811
- throw new TypeError(ERROR_MESSAGE + target);
1812
- }
1813
- var args = slice$1.call(arguments, 1);
1814
-
1815
- var bound;
1816
- var binder = function () {
1817
- if (this instanceof bound) {
1818
- var result = target.apply(
1819
- this,
1820
- args.concat(slice$1.call(arguments))
1821
- );
1822
- if (Object(result) === result) {
1823
- return result;
1824
- }
1825
- return this;
1826
- } else {
1827
- return target.apply(
1828
- that,
1829
- args.concat(slice$1.call(arguments))
1830
- );
1831
- }
1832
- };
1833
-
1834
- var boundLength = Math.max(0, target.length - args.length);
1835
- var boundArgs = [];
1836
- for (var i = 0; i < boundLength; i++) {
1837
- boundArgs.push('$' + i);
1838
- }
1839
-
1840
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
1841
-
1842
- if (target.prototype) {
1843
- var Empty = function Empty() {};
1844
- Empty.prototype = target.prototype;
1845
- bound.prototype = new Empty();
1846
- Empty.prototype = null;
1847
- }
1848
-
1849
- return bound;
1850
- };
1851
-
1852
- var functionBind = Function.prototype.bind || implementation$1;
1853
-
1854
- /* globals
1855
- Atomics,
1856
- SharedArrayBuffer,
1857
- */
1858
-
1859
- var undefined$1;
1860
-
1861
- var $TypeError = TypeError;
1862
-
1863
- var $gOPD = Object.getOwnPropertyDescriptor;
1864
- if ($gOPD) {
1865
- try {
1866
- $gOPD({}, '');
1867
- } catch (e) {
1868
- $gOPD = null; // this is IE 8, which has a broken gOPD
1869
- }
1870
- }
1871
-
1872
- var throwTypeError = function () { throw new $TypeError(); };
1873
- var ThrowTypeError = $gOPD
1874
- ? (function () {
1875
- try {
1876
- // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
1877
- arguments.callee; // IE 8 does not throw here
1878
- return throwTypeError;
1879
- } catch (calleeThrows) {
1880
- try {
1881
- // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
1882
- return $gOPD(arguments, 'callee').get;
1883
- } catch (gOPDthrows) {
1884
- return throwTypeError;
1885
- }
1886
- }
1887
- }())
1888
- : throwTypeError;
1889
-
1890
- var hasSymbols$2 = hasSymbols$1();
1891
-
1892
- var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
1893
- var generatorFunction = undefined$1;
1894
- var asyncFunction = undefined$1;
1895
- var asyncGenFunction = undefined$1;
1896
-
1897
- var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
1898
-
1899
- var INTRINSICS = {
1900
- '%Array%': Array,
1901
- '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
1902
- '%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer.prototype,
1903
- '%ArrayIteratorPrototype%': hasSymbols$2 ? getProto([][Symbol.iterator]()) : undefined$1,
1904
- '%ArrayPrototype%': Array.prototype,
1905
- '%ArrayProto_entries%': Array.prototype.entries,
1906
- '%ArrayProto_forEach%': Array.prototype.forEach,
1907
- '%ArrayProto_keys%': Array.prototype.keys,
1908
- '%ArrayProto_values%': Array.prototype.values,
1909
- '%AsyncFromSyncIteratorPrototype%': undefined$1,
1910
- '%AsyncFunction%': asyncFunction,
1911
- '%AsyncFunctionPrototype%': undefined$1,
1912
- '%AsyncGenerator%': undefined$1,
1913
- '%AsyncGeneratorFunction%': asyncGenFunction,
1914
- '%AsyncGeneratorPrototype%': undefined$1,
1915
- '%AsyncIteratorPrototype%': undefined$1,
1916
- '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
1917
- '%Boolean%': Boolean,
1918
- '%BooleanPrototype%': Boolean.prototype,
1919
- '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
1920
- '%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$1 : DataView.prototype,
1921
- '%Date%': Date,
1922
- '%DatePrototype%': Date.prototype,
1923
- '%decodeURI%': decodeURI,
1924
- '%decodeURIComponent%': decodeURIComponent,
1925
- '%encodeURI%': encodeURI,
1926
- '%encodeURIComponent%': encodeURIComponent,
1927
- '%Error%': Error,
1928
- '%ErrorPrototype%': Error.prototype,
1929
- '%eval%': eval, // eslint-disable-line no-eval
1930
- '%EvalError%': EvalError,
1931
- '%EvalErrorPrototype%': EvalError.prototype,
1932
- '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
1933
- '%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array.prototype,
1934
- '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
1935
- '%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array.prototype,
1936
- '%Function%': Function,
1937
- '%FunctionPrototype%': Function.prototype,
1938
- '%Generator%': undefined$1,
1939
- '%GeneratorFunction%': generatorFunction,
1940
- '%GeneratorPrototype%': undefined$1,
1941
- '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
1942
- '%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array.prototype,
1943
- '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
1944
- '%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$1 : Int8Array.prototype,
1945
- '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
1946
- '%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array.prototype,
1947
- '%isFinite%': isFinite,
1948
- '%isNaN%': isNaN,
1949
- '%IteratorPrototype%': hasSymbols$2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
1950
- '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
1951
- '%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$1,
1952
- '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
1953
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
1954
- '%MapPrototype%': typeof Map === 'undefined' ? undefined$1 : Map.prototype,
1955
- '%Math%': Math,
1956
- '%Number%': Number,
1957
- '%NumberPrototype%': Number.prototype,
1958
- '%Object%': Object,
1959
- '%ObjectPrototype%': Object.prototype,
1960
- '%ObjProto_toString%': Object.prototype.toString,
1961
- '%ObjProto_valueOf%': Object.prototype.valueOf,
1962
- '%parseFloat%': parseFloat,
1963
- '%parseInt%': parseInt,
1964
- '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
1965
- '%PromisePrototype%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype,
1966
- '%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype.then,
1967
- '%Promise_all%': typeof Promise === 'undefined' ? undefined$1 : Promise.all,
1968
- '%Promise_reject%': typeof Promise === 'undefined' ? undefined$1 : Promise.reject,
1969
- '%Promise_resolve%': typeof Promise === 'undefined' ? undefined$1 : Promise.resolve,
1970
- '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
1971
- '%RangeError%': RangeError,
1972
- '%RangeErrorPrototype%': RangeError.prototype,
1973
- '%ReferenceError%': ReferenceError,
1974
- '%ReferenceErrorPrototype%': ReferenceError.prototype,
1975
- '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
1976
- '%RegExp%': RegExp,
1977
- '%RegExpPrototype%': RegExp.prototype,
1978
- '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
1979
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
1980
- '%SetPrototype%': typeof Set === 'undefined' ? undefined$1 : Set.prototype,
1981
- '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
1982
- '%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer.prototype,
1983
- '%String%': String,
1984
- '%StringIteratorPrototype%': hasSymbols$2 ? getProto(''[Symbol.iterator]()) : undefined$1,
1985
- '%StringPrototype%': String.prototype,
1986
- '%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
1987
- '%SymbolPrototype%': hasSymbols$2 ? Symbol.prototype : undefined$1,
1988
- '%SyntaxError%': SyntaxError,
1989
- '%SyntaxErrorPrototype%': SyntaxError.prototype,
1990
- '%ThrowTypeError%': ThrowTypeError,
1991
- '%TypedArray%': TypedArray,
1992
- '%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined$1,
1993
- '%TypeError%': $TypeError,
1994
- '%TypeErrorPrototype%': $TypeError.prototype,
1995
- '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
1996
- '%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array.prototype,
1997
- '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
1998
- '%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray.prototype,
1999
- '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
2000
- '%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array.prototype,
2001
- '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
2002
- '%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array.prototype,
2003
- '%URIError%': URIError,
2004
- '%URIErrorPrototype%': URIError.prototype,
2005
- '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
2006
- '%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap.prototype,
2007
- '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
2008
- '%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet.prototype
2009
- };
2010
-
2011
-
2012
- var $replace = functionBind.call(Function.call, String.prototype.replace);
2013
-
2014
- /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
2015
- var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
2016
- var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
2017
- var stringToPath = function stringToPath(string) {
2018
- var result = [];
2019
- $replace(string, rePropName, function (match, number, quote, subString) {
2020
- result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
2021
- });
2022
- return result;
2023
- };
2024
- /* end adaptation */
2025
-
2026
- var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
2027
- if (!(name in INTRINSICS)) {
2028
- throw new SyntaxError('intrinsic ' + name + ' does not exist!');
2029
- }
2030
-
2031
- // istanbul ignore if // hopefully this is impossible to test :-)
2032
- if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) {
2033
- throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
2034
- }
2035
-
2036
- return INTRINSICS[name];
2037
- };
2038
-
2039
- var GetIntrinsic = function GetIntrinsic(name, allowMissing) {
2040
- if (typeof name !== 'string' || name.length === 0) {
2041
- throw new TypeError('intrinsic name must be a non-empty string');
2042
- }
2043
- if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
2044
- throw new TypeError('"allowMissing" argument must be a boolean');
2045
- }
2046
-
2047
- var parts = stringToPath(name);
2048
-
2049
- var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
2050
- for (var i = 1; i < parts.length; i += 1) {
2051
- if (value != null) {
2052
- if ($gOPD && (i + 1) >= parts.length) {
2053
- var desc = $gOPD(value, parts[i]);
2054
- if (!allowMissing && !(parts[i] in value)) {
2055
- throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
2056
- }
2057
- value = desc ? (desc.get || desc.value) : value[parts[i]];
2058
- } else {
2059
- value = value[parts[i]];
2060
- }
2061
- }
2062
- }
2063
- return value;
2064
- };
2065
-
2066
- var $Function = GetIntrinsic('%Function%');
2067
- var $apply = $Function.apply;
2068
- var $call = $Function.call;
2069
-
2070
- var callBind = function callBind() {
2071
- return functionBind.apply($call, arguments);
2072
- };
2073
-
2074
- var apply = function applyBind() {
2075
- return functionBind.apply($apply, arguments);
2076
- };
2077
- callBind.apply = apply;
2078
-
2079
- var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
2080
-
2081
- var callBound = function callBoundIntrinsic(name, allowMissing) {
2082
- var intrinsic = GetIntrinsic(name, !!allowMissing);
2083
- if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) {
2084
- return callBind(intrinsic);
2085
- }
2086
- return intrinsic;
2087
- };
2088
-
2089
- var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
2090
-
2091
- if ($defineProperty) {
2092
- try {
2093
- $defineProperty({}, 'a', { value: 1 });
2094
- } catch (e) {
2095
- // IE 8 has a broken defineProperty
2096
- $defineProperty = null;
2097
- }
2098
- }
2099
-
2100
-
2101
-
2102
- var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
2103
-
2104
- // eslint-disable-next-line max-params
2105
- var DefineOwnProperty = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
2106
- if (!$defineProperty) {
2107
- if (!IsDataDescriptor(desc)) {
2108
- // ES3 does not support getters/setters
2109
- return false;
2110
- }
2111
- if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
2112
- return false;
2113
- }
2114
-
2115
- // fallback for ES3
2116
- if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
2117
- // a non-enumerable existing property
2118
- return false;
2119
- }
2120
-
2121
- // property does not exist at all, or exists but is enumerable
2122
- var V = desc['[[Value]]'];
2123
- // eslint-disable-next-line no-param-reassign
2124
- O[P] = V; // will use [[Define]]
2125
- return SameValue(O[P], V);
2126
- }
2127
- $defineProperty(O, P, FromPropertyDescriptor(desc));
2128
- return true;
2129
- };
2130
-
2131
- var src = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
2132
-
2133
- var $TypeError$1 = GetIntrinsic('%TypeError%');
2134
- var $SyntaxError = GetIntrinsic('%SyntaxError%');
2135
-
2136
-
2137
-
2138
- var predicates = {
2139
- // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
2140
- 'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
2141
- if (Type(Desc) !== 'Object') {
2142
- return false;
2143
- }
2144
- var allowed = {
2145
- '[[Configurable]]': true,
2146
- '[[Enumerable]]': true,
2147
- '[[Get]]': true,
2148
- '[[Set]]': true,
2149
- '[[Value]]': true,
2150
- '[[Writable]]': true
2151
- };
2152
-
2153
- for (var key in Desc) { // eslint-disable-line
2154
- if (src(Desc, key) && !allowed[key]) {
2155
- return false;
2156
- }
2157
- }
2158
-
2159
- var isData = src(Desc, '[[Value]]');
2160
- var IsAccessor = src(Desc, '[[Get]]') || src(Desc, '[[Set]]');
2161
- if (isData && IsAccessor) {
2162
- throw new $TypeError$1('Property Descriptors may not be both accessor and data descriptors');
2163
- }
2164
- return true;
2165
- }
2166
- };
2167
-
2168
- var assertRecord = function assertRecord(Type, recordType, argumentName, value) {
2169
- var predicate = predicates[recordType];
2170
- if (typeof predicate !== 'function') {
2171
- throw new $SyntaxError('unknown record type: ' + recordType);
2172
- }
2173
- if (!predicate(Type, value)) {
2174
- throw new $TypeError$1(argumentName + ' must be a ' + recordType);
2175
- }
2176
- };
2177
-
2178
- // https://www.ecma-international.org/ecma-262/5.1/#sec-8
2179
-
2180
- var Type = function Type(x) {
2181
- if (x === null) {
2182
- return 'Null';
2183
- }
2184
- if (typeof x === 'undefined') {
2185
- return 'Undefined';
2186
- }
2187
- if (typeof x === 'function' || typeof x === 'object') {
2188
- return 'Object';
2189
- }
2190
- if (typeof x === 'number') {
2191
- return 'Number';
2192
- }
2193
- if (typeof x === 'boolean') {
2194
- return 'Boolean';
2195
- }
2196
- if (typeof x === 'string') {
2197
- return 'String';
2198
- }
2199
- };
2200
-
2201
- // https://www.ecma-international.org/ecma-262/6.0/#sec-tostring
2202
-
2203
- var Type$1 = function Type$1(x) {
2204
- if (typeof x === 'symbol') {
2205
- return 'Symbol';
2206
- }
2207
- return Type(x);
2208
- };
2209
-
2210
- // https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
2211
-
2212
- var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
2213
- if (typeof Desc === 'undefined') {
2214
- return Desc;
2215
- }
2216
-
2217
- assertRecord(Type$1, 'Property Descriptor', 'Desc', Desc);
2218
-
2219
- var obj = {};
2220
- if ('[[Value]]' in Desc) {
2221
- obj.value = Desc['[[Value]]'];
2222
- }
2223
- if ('[[Writable]]' in Desc) {
2224
- obj.writable = Desc['[[Writable]]'];
2225
- }
2226
- if ('[[Get]]' in Desc) {
2227
- obj.get = Desc['[[Get]]'];
2228
- }
2229
- if ('[[Set]]' in Desc) {
2230
- obj.set = Desc['[[Set]]'];
2231
- }
2232
- if ('[[Enumerable]]' in Desc) {
2233
- obj.enumerable = Desc['[[Enumerable]]'];
2234
- }
2235
- if ('[[Configurable]]' in Desc) {
2236
- obj.configurable = Desc['[[Configurable]]'];
2237
- }
2238
- return obj;
2239
- };
2240
-
2241
- var $gOPD$1 = GetIntrinsic('%Object.getOwnPropertyDescriptor%');
2242
- if ($gOPD$1) {
2243
- try {
2244
- $gOPD$1([], 'length');
2245
- } catch (e) {
2246
- // IE 8 has a broken gOPD
2247
- $gOPD$1 = null;
2248
- }
2249
- }
2250
-
2251
- var getOwnPropertyDescriptor = $gOPD$1;
2252
-
2253
- var $Array = GetIntrinsic('%Array%');
2254
-
2255
- // eslint-disable-next-line global-require
2256
- var toStr$4 = !$Array.isArray && callBound('Object.prototype.toString');
2257
-
2258
- // https://www.ecma-international.org/ecma-262/6.0/#sec-isarray
2259
-
2260
- var IsArray = $Array.isArray || function IsArray(argument) {
2261
- return toStr$4(argument) === '[object Array]';
2262
- };
2263
-
2264
- // https://www.ecma-international.org/ecma-262/6.0/#sec-ispropertykey
2265
-
2266
- var IsPropertyKey = function IsPropertyKey(argument) {
2267
- return typeof argument === 'string' || typeof argument === 'symbol';
2268
- };
2269
-
2270
- var regexExec = RegExp.prototype.exec;
2271
- var gOPD = Object.getOwnPropertyDescriptor;
2272
-
2273
- var tryRegexExecCall = function tryRegexExec(value) {
2274
- try {
2275
- var lastIndex = value.lastIndex;
2276
- value.lastIndex = 0; // eslint-disable-line no-param-reassign
2277
-
2278
- regexExec.call(value);
2279
- return true;
2280
- } catch (e) {
2281
- return false;
2282
- } finally {
2283
- value.lastIndex = lastIndex; // eslint-disable-line no-param-reassign
2284
- }
2285
- };
2286
- var toStr$5 = Object.prototype.toString;
2287
- var regexClass = '[object RegExp]';
2288
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
2289
-
2290
- var isRegex = function isRegex(value) {
2291
- if (!value || typeof value !== 'object') {
2292
- return false;
2293
- }
2294
- if (!hasToStringTag) {
2295
- return toStr$5.call(value) === regexClass;
2296
- }
2297
-
2298
- var descriptor = gOPD(value, 'lastIndex');
2299
- var hasLastIndexDataProperty = descriptor && src(descriptor, 'value');
2300
- if (!hasLastIndexDataProperty) {
2301
- return false;
2302
- }
2303
-
2304
- return tryRegexExecCall(value);
2305
- };
2306
-
2307
- // http://www.ecma-international.org/ecma-262/5.1/#sec-9.2
2308
-
2309
- var ToBoolean = function ToBoolean(value) { return !!value; };
2310
-
2311
- var $match = GetIntrinsic('%Symbol.match%', true);
2312
-
2313
-
2314
-
2315
-
2316
-
2317
- // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
2318
-
2319
- var IsRegExp = function IsRegExp(argument) {
2320
- if (!argument || typeof argument !== 'object') {
2321
- return false;
2322
- }
2323
- if ($match) {
2324
- var isRegExp = argument[$match];
2325
- if (typeof isRegExp !== 'undefined') {
2326
- return ToBoolean(isRegExp);
2327
- }
2328
- }
2329
- return isRegex(argument);
2330
- };
2331
-
2332
- var fnToStr = Function.prototype.toString;
2333
-
2334
- var constructorRegex = /^\s*class\b/;
2335
- var isES6ClassFn = function isES6ClassFunction(value) {
2336
- try {
2337
- var fnStr = fnToStr.call(value);
2338
- return constructorRegex.test(fnStr);
2339
- } catch (e) {
2340
- return false; // not a function
2341
- }
2342
- };
2343
-
2344
- var tryFunctionObject = function tryFunctionToStr(value) {
2345
- try {
2346
- if (isES6ClassFn(value)) { return false; }
2347
- fnToStr.call(value);
2348
- return true;
2349
- } catch (e) {
2350
- return false;
2351
- }
2352
- };
2353
- var toStr$6 = Object.prototype.toString;
2354
- var fnClass = '[object Function]';
2355
- var genClass = '[object GeneratorFunction]';
2356
- var hasToStringTag$1 = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
2357
-
2358
- var isCallable = function isCallable(value) {
2359
- if (!value) { return false; }
2360
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
2361
- if (typeof value === 'function' && !value.prototype) { return true; }
2362
- if (hasToStringTag$1) { return tryFunctionObject(value); }
2363
- if (isES6ClassFn(value)) { return false; }
2364
- var strClass = toStr$6.call(value);
2365
- return strClass === fnClass || strClass === genClass;
2366
- };
2367
-
2368
- // http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
2369
-
2370
- var IsCallable = isCallable;
2371
-
2372
- var $TypeError$2 = GetIntrinsic('%TypeError%');
2373
-
2374
-
2375
-
2376
-
2377
-
2378
- // https://ecma-international.org/ecma-262/5.1/#sec-8.10.5
2379
-
2380
- var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
2381
- if (Type$1(Obj) !== 'Object') {
2382
- throw new $TypeError$2('ToPropertyDescriptor requires an object');
2383
- }
2384
-
2385
- var desc = {};
2386
- if (src(Obj, 'enumerable')) {
2387
- desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable);
2388
- }
2389
- if (src(Obj, 'configurable')) {
2390
- desc['[[Configurable]]'] = ToBoolean(Obj.configurable);
2391
- }
2392
- if (src(Obj, 'value')) {
2393
- desc['[[Value]]'] = Obj.value;
2394
- }
2395
- if (src(Obj, 'writable')) {
2396
- desc['[[Writable]]'] = ToBoolean(Obj.writable);
2397
- }
2398
- if (src(Obj, 'get')) {
2399
- var getter = Obj.get;
2400
- if (typeof getter !== 'undefined' && !IsCallable(getter)) {
2401
- throw new TypeError('getter must be a function');
2402
- }
2403
- desc['[[Get]]'] = getter;
2404
- }
2405
- if (src(Obj, 'set')) {
2406
- var setter = Obj.set;
2407
- if (typeof setter !== 'undefined' && !IsCallable(setter)) {
2408
- throw new $TypeError$2('setter must be a function');
2409
- }
2410
- desc['[[Set]]'] = setter;
2411
- }
2412
-
2413
- if ((src(desc, '[[Get]]') || src(desc, '[[Set]]')) && (src(desc, '[[Value]]') || src(desc, '[[Writable]]'))) {
2414
- throw new $TypeError$2('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
2415
- }
2416
- return desc;
2417
- };
2418
-
2419
- var $TypeError$3 = GetIntrinsic('%TypeError%');
2420
-
2421
-
2422
-
2423
- var $isEnumerable$1 = callBound('Object.prototype.propertyIsEnumerable');
2424
-
2425
-
2426
-
2427
-
2428
-
2429
-
2430
-
2431
-
2432
-
2433
- // https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
2434
-
2435
- var OrdinaryGetOwnProperty = function OrdinaryGetOwnProperty(O, P) {
2436
- if (Type$1(O) !== 'Object') {
2437
- throw new $TypeError$3('Assertion failed: O must be an Object');
2438
- }
2439
- if (!IsPropertyKey(P)) {
2440
- throw new $TypeError$3('Assertion failed: P must be a Property Key');
2441
- }
2442
- if (!src(O, P)) {
2443
- return void 0;
2444
- }
2445
- if (!getOwnPropertyDescriptor) {
2446
- // ES3 / IE 8 fallback
2447
- var arrayLength = IsArray(O) && P === 'length';
2448
- var regexLastIndex = IsRegExp(O) && P === 'lastIndex';
2449
- return {
2450
- '[[Configurable]]': !(arrayLength || regexLastIndex),
2451
- '[[Enumerable]]': $isEnumerable$1(O, P),
2452
- '[[Value]]': O[P],
2453
- '[[Writable]]': true
2454
- };
2455
- }
2456
- return ToPropertyDescriptor(getOwnPropertyDescriptor(O, P));
2457
- };
2458
-
2459
- // https://www.ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
2460
-
2461
- var IsDataDescriptor = function IsDataDescriptor(Desc) {
2462
- if (typeof Desc === 'undefined') {
2463
- return false;
2464
- }
2465
-
2466
- assertRecord(Type$1, 'Property Descriptor', 'Desc', Desc);
2467
-
2468
- if (!src(Desc, '[[Value]]') && !src(Desc, '[[Writable]]')) {
2469
- return false;
2470
- }
2471
-
2472
- return true;
2473
- };
2474
-
2475
- var isPrimitive = function isPrimitive(value) {
2476
- return value === null || (typeof value !== 'function' && typeof value !== 'object');
2477
- };
2478
-
2479
- var $Object = GetIntrinsic('%Object%');
2480
-
2481
-
2482
-
2483
- var $preventExtensions = $Object.preventExtensions;
2484
- var $isExtensible = $Object.isExtensible;
2485
-
2486
- // https://www.ecma-international.org/ecma-262/6.0/#sec-isextensible-o
2487
-
2488
- var IsExtensible = $preventExtensions
2489
- ? function IsExtensible(obj) {
2490
- return !isPrimitive(obj) && $isExtensible(obj);
2491
- }
2492
- : function IsExtensible(obj) {
2493
- return !isPrimitive(obj);
2494
- };
2495
-
2496
- var _isNaN = Number.isNaN || function isNaN(a) {
2497
- return a !== a;
2498
- };
2499
-
2500
- // http://www.ecma-international.org/ecma-262/5.1/#sec-9.12
2501
-
2502
- var SameValue = function SameValue(x, y) {
2503
- if (x === y) { // 0 === -0, but they are not identical.
2504
- if (x === 0) { return 1 / x === 1 / y; }
2505
- return true;
2506
- }
2507
- return _isNaN(x) && _isNaN(y);
2508
- };
2509
-
2510
- var $TypeError$4 = GetIntrinsic('%TypeError%');
2511
-
2512
-
2513
-
2514
-
2515
-
2516
-
2517
-
2518
-
2519
-
2520
-
2521
-
2522
- // https://www.ecma-international.org/ecma-262/6.0/#sec-createdataproperty
2523
-
2524
- var CreateDataProperty = function CreateDataProperty(O, P, V) {
2525
- if (Type$1(O) !== 'Object') {
2526
- throw new $TypeError$4('Assertion failed: Type(O) is not Object');
2527
- }
2528
- if (!IsPropertyKey(P)) {
2529
- throw new $TypeError$4('Assertion failed: IsPropertyKey(P) is not true');
2530
- }
2531
- var oldDesc = OrdinaryGetOwnProperty(O, P);
2532
- var extensible = oldDesc || IsExtensible(O);
2533
- var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
2534
- if (immutable || !extensible) {
2535
- return false;
2536
- }
2537
- return DefineOwnProperty(
2538
- IsDataDescriptor,
2539
- SameValue,
2540
- FromPropertyDescriptor,
2541
- O,
2542
- P,
2543
- {
2544
- '[[Configurable]]': true,
2545
- '[[Enumerable]]': true,
2546
- '[[Value]]': V,
2547
- '[[Writable]]': true
2548
- }
2549
- );
2550
- };
2551
-
2552
- var $TypeError$5 = GetIntrinsic('%TypeError%');
2553
-
2554
- // http://www.ecma-international.org/ecma-262/5.1/#sec-9.10
2555
-
2556
- var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
2557
- if (value == null) {
2558
- throw new $TypeError$5(optMessage || ('Cannot call method on ' + value));
2559
- }
2560
- return value;
2561
- };
2562
-
2563
- var RequireObjectCoercible = CheckObjectCoercible;
2564
-
2565
- var $Object$1 = GetIntrinsic('%Object%');
2566
-
2567
-
2568
-
2569
- // https://www.ecma-international.org/ecma-262/6.0/#sec-toobject
2570
-
2571
- var ToObject = function ToObject(value) {
2572
- RequireObjectCoercible(value);
2573
- return $Object$1(value);
2574
- };
2575
-
2576
- var $gOPD$2 = Object.getOwnPropertyDescriptor;
2577
- var $getOwnNames = Object.getOwnPropertyNames;
2578
- var $getSymbols = Object.getOwnPropertySymbols;
2579
- var $concat = callBound('Array.prototype.concat');
2580
- var $reduce = callBound('Array.prototype.reduce');
2581
- var getAll = $getSymbols ? function (obj) {
2582
- return $concat($getOwnNames(obj), $getSymbols(obj));
2583
- } : $getOwnNames;
2584
-
2585
- var isES5 = IsCallable($gOPD$2) && IsCallable($getOwnNames);
2586
-
2587
- var implementation$2 = function getOwnPropertyDescriptors(value) {
2588
- RequireObjectCoercible(value);
2589
- if (!isES5) {
2590
- throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
2591
- }
2592
-
2593
- var O = ToObject(value);
2594
- return $reduce(
2595
- getAll(O),
2596
- function (acc, key) {
2597
- var descriptor = $gOPD$2(O, key);
2598
- if (typeof descriptor !== 'undefined') {
2599
- CreateDataProperty(acc, key, descriptor);
2600
- }
2601
- return acc;
2602
- },
2603
- {}
2604
- );
2605
- };
2606
-
2607
- var polyfill = function getPolyfill() {
2608
- return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation$2;
2609
- };
2610
-
2611
- var shim = function shimGetOwnPropertyDescriptors() {
2612
- var polyfill$1 = polyfill();
2613
- defineProperties_1(
2614
- Object,
2615
- { getOwnPropertyDescriptors: polyfill$1 },
2616
- { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill$1; } }
2617
- );
2618
- return polyfill$1;
2619
- };
2620
-
2621
- defineProperties_1(implementation$2, {
2622
- getPolyfill: polyfill,
2623
- implementation: implementation$2,
2624
- shim: shim
2625
- });
2626
-
2627
- var object_getownpropertydescriptors = implementation$2;
2628
-
2629
- var isES5$1 = typeof Object.defineProperty === 'function'
2630
- && typeof Object.defineProperties === 'function';
2631
-
2632
- var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
2633
-
2634
- if (!isES5$1 || !hasProto) {
2635
- throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
2636
- }
2637
-
2638
-
2639
-
2640
- if (typeof Promise !== 'function') {
2641
- throw new TypeError('`Promise` must be globally available for util.promisify to work.');
2642
- }
2643
-
2644
-
2645
-
2646
- var $slice = callBound('Array.prototype.slice');
2647
- var $concat$1 = callBound('Array.prototype.concat');
2648
- var $forEach = callBound('Array.prototype.forEach');
2649
-
2650
- var hasSymbols$3 = hasSymbols$1();
2651
-
2652
- var kCustomPromisifiedSymbol = hasSymbols$3 ? Symbol('util.promisify.custom') : null;
2653
- var kCustomPromisifyArgsSymbol = hasSymbols$3 ? Symbol('customPromisifyArgs') : null;
2654
-
2655
- var implementation$3 = function promisify(orig) {
2656
- if (typeof orig !== 'function') {
2657
- var error = new TypeError('The "original" argument must be of type function');
2658
- error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
2659
- error.code = 'ERR_INVALID_ARG_TYPE';
2660
- throw error;
2661
- }
2662
-
2663
- if (hasSymbols$3 && orig[kCustomPromisifiedSymbol]) {
2664
- var customFunction = orig[kCustomPromisifiedSymbol];
2665
- if (typeof customFunction !== 'function') {
2666
- throw new TypeError('The [util.promisify.custom] property must be a function');
2667
- }
2668
- Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
2669
- configurable: true,
2670
- enumerable: false,
2671
- value: customFunction,
2672
- writable: false
2673
- });
2674
- return customFunction;
2675
- }
2676
-
2677
- // Names to create an object from in case the callback receives multiple
2678
- // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
2679
- var argumentNames = orig[kCustomPromisifyArgsSymbol];
2680
-
2681
- var promisified = function fn() {
2682
- var args = $slice(arguments);
2683
- var self = this; // eslint-disable-line no-invalid-this
2684
- return new Promise(function (resolve, reject) {
2685
- orig.apply(self, $concat$1(args, function (err) {
2686
- var values = arguments.length > 1 ? $slice(arguments, 1) : [];
2687
- if (err) {
2688
- reject(err);
2689
- } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
2690
- var obj = {};
2691
- $forEach(argumentNames, function (name, index) {
2692
- obj[name] = values[index];
2693
- });
2694
- resolve(obj);
2695
- } else {
2696
- resolve(values[0]);
2697
- }
2698
- }));
2699
- });
2700
- };
2701
-
2702
- promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
2703
-
2704
- Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
2705
- configurable: true,
2706
- enumerable: false,
2707
- value: promisified,
2708
- writable: false
2709
- });
2710
- return Object.defineProperties(promisified, object_getownpropertydescriptors(orig));
2711
- };
2712
-
2713
- var custom = kCustomPromisifiedSymbol;
2714
- var customPromisifyArgs = kCustomPromisifyArgsSymbol;
2715
- implementation$3.custom = custom;
2716
- implementation$3.customPromisifyArgs = customPromisifyArgs;
2717
-
2718
- var polyfill$1 = function getPolyfill() {
2719
- if (typeof util.util.promisify === 'function') {
2720
- return util.util.promisify;
2721
- }
2722
- return implementation$3;
2723
- };
2724
-
2725
- var shim$1 = function shimUtilPromisify() {
2726
- var polyfill = polyfill$1();
2727
- if (polyfill !== util.util.promisify) {
2728
- Object.defineProperty(util.util, 'promisify', {
2729
- configurable: true,
2730
- enumerable: true,
2731
- value: polyfill,
2732
- writable: true
2733
- });
2734
- }
2735
- return polyfill;
2736
- };
2737
-
2738
- var polyfill$2 = polyfill$1();
2739
-
2740
-
2741
- /* eslint-disable no-unused-vars */
2742
- var boundPromisify = function promisify(orig) {
2743
- /* eslint-enable no-unused-vars */
2744
- return polyfill$2.apply(util.util, arguments);
2745
- };
2746
- defineProperties_1(boundPromisify, {
2747
- custom: polyfill$2.custom,
2748
- customPromisifyArgs: polyfill$2.customPromisifyArgs,
2749
- getPolyfill: polyfill$1,
2750
- implementation: implementation$3,
2751
- shim: shim$1
2752
- });
2753
-
2754
- var util_promisify = boundPromisify;
2755
-
2756
- util_promisify.shim();
2757
-
2758
- function connect() {
2759
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2760
-
2761
- if (!config) {
2762
- config = {
2763
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2764
- user: 'nasp',
2765
- password: 'uRNkF9SkfXQs6AKK',
2766
- database: 'user'
2767
- };
2768
- }
2769
-
2770
- var connection = mysql.createConnection(config);
2771
- return {
2772
- query: function query(sql, args) {
2773
- return util.util.promisify(connection.query).call(connection, sql, args);
2774
- },
2775
- beginTransaction: function beginTransaction() {
2776
- return util.util.promisify(connection.beginTransaction).call(connection);
2777
- },
2778
- commit: function commit() {
2779
- return util.util.promisify(connection.commit).call(connection);
2780
- },
2781
- rollback: function rollback() {
2782
- return util.util.promisify(connection.rollback).call(connection);
2783
- },
2784
- close: function close() {
2785
- return util.util.promisify(connection.end).call(connection);
2786
- }
2787
- };
2788
- }
2789
-
2790
- var db = connect;
2791
-
2792
- var _this$3 = undefined;
2793
-
2794
- var config = {
2795
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2796
- user: 'nasp',
2797
- password: 'uRNkF9SkfXQs6AKK',
2798
- database: 'user'
2799
- };
2800
-
2801
- var findUser = function () {
2802
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(email) {
2803
- var password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2804
- var db$1, query, res, user, hash, passwordsMatch, user_shared, occupation_id;
2805
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
2806
- while (1) {
2807
- switch (_context.prev = _context.next) {
2808
- case 0:
2809
- db$1 = null;
2810
- _context.prev = 1;
2811
-
2812
-
2813
- db$1 = db(config);
2814
-
2815
- query = '\n select * \n from user \n where trim(lower(email)) = ?\n ';
2816
- _context.next = 6;
2817
- return db$1.query(query, [email.toLowerCase().trim()]);
2818
-
2819
- case 6:
2820
- res = _context.sent;
2821
- user = res.length > 0 ? res[0] : null;
2822
-
2823
- if (user) {
2824
- _context.next = 10;
2825
- break;
2826
- }
2827
-
2828
- throw new Error('Invalid credential provided');
2829
-
2830
- case 10:
2831
- if (!password) {
2832
- _context.next = 15;
2833
- break;
2834
- }
2835
-
2836
- hash = md5.md5(password);
2837
- passwordsMatch = hash === user.password;
2838
-
2839
- if (passwordsMatch) {
2840
- _context.next = 15;
2841
- break;
2842
- }
2843
-
2844
- throw new Error('Password doesn\'t match');
2845
-
2846
- case 15:
2847
-
2848
- query = '\n select * \n from user_shared \n where user_id = ?\n ';
2849
- _context.next = 18;
2850
- return db$1.query(query, [user.id]);
2851
-
2852
- case 18:
2853
- res = _context.sent;
2854
- user_shared = res.length > 0 ? res[0] : null;
2855
-
2856
- user.shared = user_shared;
2857
-
2858
- // occupation
2859
- query = '\n select id \n from occupation \n where name = ?\n ';
2860
- _context.next = 24;
2861
- return db$1.query(query, [user_shared.occupation]);
2862
-
2863
- case 24:
2864
- res = _context.sent;
2865
- occupation_id = res.length > 0 ? res[0].id : '';
2866
-
2867
- user.shared.occupation_id = occupation_id;
2868
-
2869
- _context.next = 29;
2870
- return db$1.close();
2871
-
2872
- case 29:
2873
- return _context.abrupt('return', {
2874
- error: '',
2875
- user: user
2876
- });
2877
-
2878
- case 32:
2879
- _context.prev = 32;
2880
- _context.t0 = _context['catch'](1);
2881
-
2882
- if (!db$1) {
2883
- _context.next = 37;
2884
- break;
2885
- }
2886
-
2887
- _context.next = 37;
2888
- return db$1.close();
2889
-
2890
- case 37:
2891
- return _context.abrupt('return', {
2892
- error: _context.t0.message,
2893
- user: null
2894
- });
2895
-
2896
- case 38:
2897
- case 'end':
2898
- return _context.stop();
2899
- }
2900
- }
2901
- }, _callee, this, [[1, 32]]);
2902
- }));
2903
-
2904
- return function findUser(_x) {
2905
- return _ref.apply(this, arguments);
2906
- };
2907
- }();
2908
-
2909
- var updateUser = function () {
2910
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(data) {
2911
- var db$1, query, res, hash, columns, i, column, occupation_name;
2912
- return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
2913
- while (1) {
2914
- switch (_context2.prev = _context2.next) {
2915
- case 0:
2916
- db$1 = null;
2917
- _context2.prev = 1;
2918
-
2919
-
2920
- validateUserData(data);
2921
-
2922
- db$1 = db(config);
2923
-
2924
- _context2.next = 6;
2925
- return db$1.beginTransaction();
2926
-
2927
- case 6:
2928
- if (data.user_id) {
2929
- _context2.next = 8;
2930
- break;
2931
- }
2932
-
2933
- throw new Error('Please provide user ID');
2934
-
2935
- case 8:
2936
-
2937
- data.email = data.email.toLowerCase().trim();
2938
-
2939
- // check if new email is taken
2940
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n and id != ?\n ';
2941
- _context2.next = 12;
2942
- return db$1.query(query, [data.email, data.user_id]);
2943
-
2944
- case 12:
2945
- res = _context2.sent;
2946
-
2947
- if (!(res && res.length > 0)) {
2948
- _context2.next = 15;
2949
- break;
2950
- }
2951
-
2952
- throw new Error('Email already taken');
2953
-
2954
- case 15:
2955
- if (!data.password) {
2956
- _context2.next = 23;
2957
- break;
2958
- }
2959
-
2960
- hash = md5.md5(data.password);
2961
-
2962
- query = '\n update user \n set password = ?\n where user_id = ?\n ';
2963
- _context2.next = 20;
2964
- return db$1.query(query, [hash, data.user_id]);
2965
-
2966
- case 20:
2967
- res = _context2.sent;
2968
-
2969
- if (!(!res || res.affectedRows < 1)) {
2970
- _context2.next = 23;
2971
- break;
2972
- }
2973
-
2974
- throw new Error('Failed to update password');
2975
-
2976
- case 23:
2977
-
2978
- query = 'show columns from user_shared';
2979
- _context2.next = 26;
2980
- return db$1.query(query);
2981
-
2982
- case 26:
2983
- columns = _context2.sent;
2984
-
2985
-
2986
- for (i = 0; i < columns.length; i++) {
2987
- column = columns[i].Field;
2988
-
2989
- if (typeof data[column] === 'undefined') {
2990
- data[column] = '';
2991
- }
2992
- }
2993
-
2994
- // user_shared
2995
- query = '\n update user_shared\n set \n first_name = ?,\n last_name = ?,\n country = ?,\n city = ?,\n state = ?,\n zip = ?,\n phone = ?,\n occupation = ?,\n primary_specialty = ?,\n area_of_practice = ?,\n work_place = ?,\n graduation_year = ?,\n medical_school = ?,\n npi = ?,\n role = ?,\n updated = current_timestamp\n where user_id = ?\n ';
2996
-
2997
- _context2.next = 31;
2998
- return getOccupationNameById(db$1, data.occupation);
2999
-
3000
- case 31:
3001
- occupation_name = _context2.sent;
3002
- _context2.next = 34;
3003
- return db$1.query(query, [data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role, data.user_id]);
3004
-
3005
- case 34:
3006
- res = _context2.sent;
3007
-
3008
- if (!(!res || res.affectedRows < 1)) {
3009
- _context2.next = 37;
3010
- break;
3011
- }
3012
-
3013
- throw new Error('Failed to update user shared information record');
3014
-
3015
- case 37:
3016
- _context2.next = 39;
3017
- return db$1.commit();
3018
-
3019
- case 39:
3020
- _context2.next = 41;
3021
- return db$1.close();
3022
-
3023
- case 41:
3024
-
3025
- db$1 = null;
3026
-
3027
- return _context2.abrupt('return', {
3028
- error: '',
3029
- user: findUser(data.email)
3030
- });
3031
-
3032
- case 45:
3033
- _context2.prev = 45;
3034
- _context2.t0 = _context2['catch'](1);
3035
-
3036
-
3037
- console.log('error:', _context2.t0);
3038
-
3039
- if (!db$1) {
3040
- _context2.next = 53;
3041
- break;
3042
- }
3043
-
3044
- _context2.next = 51;
3045
- return db$1.rollback();
3046
-
3047
- case 51:
3048
- _context2.next = 53;
3049
- return db$1.close();
3050
-
3051
- case 53:
3052
- return _context2.abrupt('return', {
3053
- error: _context2.t0.message,
3054
- user: null
3055
- });
3056
-
3057
- case 54:
3058
- case 'end':
3059
- return _context2.stop();
3060
- }
3061
- }
3062
- }, _callee2, this, [[1, 45]]);
3063
- }));
3064
-
3065
- return function updateUser(_x3) {
3066
- return _ref2.apply(this, arguments);
3067
- };
3068
- }();
3069
-
3070
- var validateUserData = function validateUserData(data) {
3071
- var requirePassword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3072
-
3073
- if (!data.email) {
3074
- throw new Error('Email is required');
3075
- }
3076
-
3077
- if (requirePassword && !data.password) {
3078
- throw new Error('Password is required');
3079
- }
3080
-
3081
- if (data.password && data.password !== data.rpassword) {
3082
- throw new Error('Password does not match');
3083
- }
3084
-
3085
- if (!data.first_name) {
3086
- throw new Error('First name is required');
3087
- }
3088
-
3089
- if (!data.last_name) {
3090
- throw new Error('Last name is required');
3091
- }
3092
-
3093
- if (!data.country) {
3094
- throw new Error('Country is required');
3095
- }
3096
-
3097
- if (data.country === 'United States') {
3098
- if (!data.state) {
3099
- throw new Error('State is required');
3100
- }
3101
-
3102
- if (!data.zip) {
3103
- throw new Error('Zip code is required');
3104
- }
3105
-
3106
- if (!data.phone) {
3107
- throw new Error('Phone is required');
3108
- }
3109
- }
3110
- };
3111
-
3112
- var getOccupationNameById = function () {
3113
- var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(db, occupation_id) {
3114
- var query, res;
3115
- return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
3116
- while (1) {
3117
- switch (_context3.prev = _context3.next) {
3118
- case 0:
3119
- query = '\n select name\n from occupation \n where id = ?\n ';
3120
- _context3.next = 3;
3121
- return db.query(query, [occupation_id]);
3122
-
3123
- case 3:
3124
- res = _context3.sent;
3125
-
3126
- if (!(res && res.length > 0)) {
3127
- _context3.next = 6;
3128
- break;
3129
- }
3130
-
3131
- return _context3.abrupt('return', res[0].name);
3132
-
3133
- case 6:
3134
- throw new Error('Failed to get occupation name by ID: ' + occupation_id);
3135
-
3136
- case 7:
3137
- case 'end':
3138
- return _context3.stop();
3139
- }
3140
- }
3141
- }, _callee3, _this$3);
3142
- }));
3143
-
3144
- return function getOccupationNameById(_x5, _x6) {
3145
- return _ref3.apply(this, arguments);
3146
- };
3147
- }();
3148
-
3149
- var createUser = function () {
3150
- var _ref4 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee4(data) {
3151
- var db$1, query, res, hash, columns, i, column, user_id, occupation_name;
3152
- return asyncToGenerator.regenerator.wrap(function _callee4$(_context4) {
3153
- while (1) {
3154
- switch (_context4.prev = _context4.next) {
3155
- case 0:
3156
- db$1 = null;
3157
- _context4.prev = 1;
3158
-
3159
-
3160
- validateUserData(data, true);
3161
-
3162
- db$1 = db(config);
3163
-
3164
- _context4.next = 6;
3165
- return db$1.beginTransaction();
3166
-
3167
- case 6:
3168
-
3169
- data.email = data.email.toLowerCase().trim();
3170
-
3171
- // check if user exists
3172
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n ';
3173
- _context4.next = 10;
3174
- return db$1.query(query, [data.email]);
3175
-
3176
- case 10:
3177
- res = _context4.sent;
3178
-
3179
- if (!(res && res.length > 0)) {
3180
- _context4.next = 13;
3181
- break;
3182
- }
3183
-
3184
- throw new Error('User already exists');
3185
-
3186
- case 13:
3187
- hash = md5.md5(data.password);
3188
-
3189
- // basic user info
3190
-
3191
- query = '\n insert into user ( \n email, password, created\n ) values (\n ?, ?, current_timestamp\n )\n ';
3192
- _context4.next = 17;
3193
- return db$1.query(query, [data.email, hash]);
3194
-
3195
- case 17:
3196
- res = _context4.sent;
3197
-
3198
- if (!(!res || res.insertId < 1)) {
3199
- _context4.next = 20;
3200
- break;
3201
- }
3202
-
3203
- throw new Error('Failed to create user');
3204
-
3205
- case 20:
3206
-
3207
- query = 'show columns from user_shared';
3208
- _context4.next = 23;
3209
- return db$1.query(query);
3210
-
3211
- case 23:
3212
- columns = _context4.sent;
3213
-
3214
-
3215
- for (i = 0; i < columns.length; i++) {
3216
- column = columns[i].Field;
3217
-
3218
- if (typeof data[column] === 'undefined') {
3219
- data[column] = '';
3220
- }
3221
- }
3222
-
3223
- user_id = res.insertId;
3224
-
3225
- // user_shared
3226
-
3227
- query = '\n insert into user_shared (\n user_id, first_name, last_name, country, city, state, zip, phone, \n occupation, primary_specialty, area_of_practice, work_place, graduation_year, medical_school, \n npi, role, updated \n ) values (\n ?, ?, ?, ?, ?, ?, ?, ?,\n ?, ?, ?, ?, ?, ?,\n ?, ?, current_timestamp\n )\n ';
3228
-
3229
- _context4.next = 29;
3230
- return getOccupationNameById(db$1, data.occupation);
3231
-
3232
- case 29:
3233
- occupation_name = _context4.sent;
3234
- _context4.next = 32;
3235
- return db$1.query(query, [user_id, data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role]);
3236
-
3237
- case 32:
3238
- res = _context4.sent;
3239
-
3240
- if (!(!res || res.affectedRows < 1)) {
3241
- _context4.next = 35;
3242
- break;
3243
- }
3244
-
3245
- throw new Error('Failed to create user shared information record');
3246
-
3247
- case 35:
3248
- _context4.next = 37;
3249
- return db$1.commit();
3250
-
3251
- case 37:
3252
- _context4.next = 39;
3253
- return db$1.close();
3254
-
3255
- case 39:
3256
- return _context4.abrupt('return', {
3257
- error: '',
3258
- user: findUser(data.email)
3259
- });
3260
-
3261
- case 42:
3262
- _context4.prev = 42;
3263
- _context4.t0 = _context4['catch'](1);
3264
-
3265
- if (!db$1) {
3266
- _context4.next = 49;
3267
- break;
3268
- }
3269
-
3270
- _context4.next = 47;
3271
- return db$1.rollback();
3272
-
3273
- case 47:
3274
- _context4.next = 49;
3275
- return db$1.close();
3276
-
3277
- case 49:
3278
- return _context4.abrupt('return', {
3279
- error: _context4.t0.message,
3280
- user: null
3281
- });
3282
-
3283
- case 50:
3284
- case 'end':
3285
- return _context4.stop();
3286
- }
3287
- }
3288
- }, _callee4, this, [[1, 42]]);
3289
- }));
3290
-
3291
- return function createUser(_x7) {
3292
- return _ref4.apply(this, arguments);
3293
- };
3294
- }();
3295
-
3296
- var createUser$1 = function () {
3297
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(data) {
3298
- var res;
3299
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
3300
- while (1) {
3301
- switch (_context.prev = _context.next) {
3302
- case 0:
3303
- _context.next = 2;
3304
- return createUser(data);
3305
-
3306
- case 2:
3307
- res = _context.sent;
3308
-
3309
- if (!res.error) {
3310
- _context.next = 5;
3311
- break;
3312
- }
3313
-
3314
- throw new Error(res.error);
3315
-
3316
- case 5:
3317
- return _context.abrupt('return', res.user);
3318
-
3319
- case 6:
3320
- case 'end':
3321
- return _context.stop();
3322
- }
3323
- }
3324
- }, _callee, this);
3325
- }));
3326
-
3327
- return function createUser(_x) {
3328
- return _ref.apply(this, arguments);
3329
- };
3330
- }();
3331
-
3332
- var updateUser$1 = function () {
3333
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(data) {
3334
- var res;
3335
- return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
3336
- while (1) {
3337
- switch (_context2.prev = _context2.next) {
3338
- case 0:
3339
- _context2.next = 2;
3340
- return updateUser(data);
3341
-
3342
- case 2:
3343
- res = _context2.sent;
3344
-
3345
- if (!res.error) {
3346
- _context2.next = 5;
3347
- break;
3348
- }
3349
-
3350
- throw new Error(res.error);
3351
-
3352
- case 5:
3353
- return _context2.abrupt('return', res.user);
3354
-
3355
- case 6:
3356
- case 'end':
3357
- return _context2.stop();
3358
- }
3359
- }
3360
- }, _callee2, this);
3361
- }));
3362
-
3363
- return function updateUser(_x2) {
3364
- return _ref2.apply(this, arguments);
3365
- };
3366
- }();
3367
-
3368
- var findUser$1 = function () {
3369
- var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(_ref4) {
3370
- var email = _ref4.email,
3371
- password = _ref4.password;
3372
- var res;
3373
- return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
3374
- while (1) {
3375
- switch (_context3.prev = _context3.next) {
3376
- case 0:
3377
- _context3.next = 2;
3378
- return findUser(email, password);
3379
-
3380
- case 2:
3381
- res = _context3.sent;
3382
-
3383
- if (!res.error) {
3384
- _context3.next = 5;
3385
- break;
3386
- }
3387
-
3388
- throw new Error(res.error);
3389
-
3390
- case 5:
3391
- return _context3.abrupt('return', res.user);
3392
-
3393
- case 6:
3394
- case 'end':
3395
- return _context3.stop();
3396
- }
3397
- }
3398
- }, _callee3, this);
3399
- }));
3400
-
3401
- return function findUser(_x3) {
3402
- return _ref3.apply(this, arguments);
3403
- };
3404
- }();
3405
-
3406
- var user = /*#__PURE__*/Object.freeze({
3407
- __proto__: null,
3408
- createUser: createUser$1,
3409
- updateUser: updateUser$1,
3410
- findUser: findUser$1
3411
- });
3412
-
3413
- var localStrategy = new Local.Strategy({
3414
- usernameField: 'email',
3415
- passwordField: 'password'
3416
- }, function (email, password, done) {
3417
-
3418
- findUser$1({ email: email, password: password }).then(function (user) {
3419
- done(null, user);
3420
- }).catch(function (error) {
3421
- done(error);
3422
- });
3423
- });
3424
-
3425
- var passportLocal = /*#__PURE__*/Object.freeze({
3426
- __proto__: null,
3427
- localStrategy: localStrategy
3428
- });
3429
-
3430
- var _this$4 = undefined;
3431
-
3432
- var config$1 = {
3433
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
3434
- user: 'nasp',
3435
- password: 'uRNkF9SkfXQs6AKK',
3436
- database: 'user'
3437
- };
3438
-
3439
- var getOccupation = function () {
3440
- var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(type) {
3441
- var db$1, query, result;
3442
- return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
3443
- while (1) {
3444
- switch (_context.prev = _context.next) {
3445
- case 0:
3446
- db$1 = db(config$1);
3447
- query = '\n select name as label, id as value\n from occupation\n where type = ?\n ';
3448
- _context.next = 4;
3449
- return db$1.query(query, [type]);
3450
-
3451
- case 4:
3452
- result = _context.sent;
3453
- _context.next = 7;
3454
- return db$1.close();
3455
-
3456
- case 7:
3457
- return _context.abrupt('return', result);
3458
-
3459
- case 8:
3460
- case 'end':
3461
- return _context.stop();
3462
- }
3463
- }
3464
- }, _callee, _this$4);
3465
- }));
3466
-
3467
- return function getOccupation(_x) {
3468
- return _ref.apply(this, arguments);
3469
- };
3470
- }();
3471
-
3472
- var getFieldsAndOptions = function () {
3473
- var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(occupation) {
3474
- var db$1, query, result, i, field, optionQuery, options;
3475
- return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
3476
- while (1) {
3477
- switch (_context2.prev = _context2.next) {
3478
- case 0:
3479
- db$1 = db(config$1);
3480
- query = '\n select * \n from field\n where occupation_id = ?\n order by sorting\n ';
3481
- _context2.next = 4;
3482
- return db$1.query(query, [occupation]);
3483
-
3484
- case 4:
3485
- result = _context2.sent;
3486
- i = 0;
3487
-
3488
- case 6:
3489
- if (!(i < result.length)) {
3490
- _context2.next = 17;
3491
- break;
3492
- }
3493
-
3494
- field = result[i];
3495
-
3496
- if (!(field.type === 'select')) {
3497
- _context2.next = 14;
3498
- break;
3499
- }
3500
-
3501
- optionQuery = '\n select * \n from options\n where list_id = ?\n order by sorting\n ';
3502
- _context2.next = 12;
3503
- return db$1.query(optionQuery, [field.list_id]);
3504
-
3505
- case 12:
3506
- options = _context2.sent;
3507
-
3508
- field.options = options ? options : [];
3509
-
3510
- case 14:
3511
- i++;
3512
- _context2.next = 6;
3513
- break;
3514
-
3515
- case 17:
3516
- _context2.next = 19;
3517
- return db$1.close();
3518
-
3519
- case 19:
3520
- return _context2.abrupt('return', result);
3521
-
3522
- case 20:
3523
- case 'end':
3524
- return _context2.stop();
3525
- }
3526
- }
3527
- }, _callee2, _this$4);
3528
- }));
3529
-
3530
- return function getFieldsAndOptions(_x2) {
3531
- return _ref2.apply(this, arguments);
3532
- };
3533
- }();
3534
-
3535
- var ProcessData = (function () {
3536
- var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(req, res) {
3537
- var action, data, type, occupation;
3538
- return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
3539
- while (1) {
3540
- switch (_context3.prev = _context3.next) {
3541
- case 0:
3542
- _context3.prev = 0;
3543
- action = req.body.action;
3544
- data = null;
3545
- _context3.t0 = action;
3546
- _context3.next = _context3.t0 === 'get-occupation' ? 6 : _context3.t0 === 'get-fields' ? 11 : 16;
3547
- break;
3548
-
3549
- case 6:
3550
- type = req.body.type;
3551
- _context3.next = 9;
3552
- return getOccupation(type);
3553
-
3554
- case 9:
3555
- data = _context3.sent;
3556
- return _context3.abrupt('break', 17);
3557
-
3558
- case 11:
3559
- occupation = req.body.occupation;
3560
- _context3.next = 14;
3561
- return getFieldsAndOptions(occupation);
3562
-
3563
- case 14:
3564
- data = _context3.sent;
3565
- return _context3.abrupt('break', 17);
3566
-
3567
- case 16:
3568
- throw new Error('Invalid action: ' + action);
3569
-
3570
- case 17:
3571
- return _context3.abrupt('return', res.json({
3572
- error: '',
3573
- data: data
3574
- }));
3575
-
3576
- case 20:
3577
- _context3.prev = 20;
3578
- _context3.t1 = _context3['catch'](0);
3579
- return _context3.abrupt('return', res.json({
3580
- error: _context3.t1.message,
3581
- data: null
3582
- }));
3583
-
3584
- case 23:
3585
- case 'end':
3586
- return _context3.stop();
3587
- }
3588
- }
3589
- }, _callee3, this, [[0, 20]]);
3590
- }));
3591
-
3592
- return function (_x3, _x4) {
3593
- return _ref3.apply(this, arguments);
3594
- };
3595
- })();
3596
-
3597
- var LoginForm_1 = LoginForm;
3598
- var SignupForm_1 = SignupForm;
3599
- var ProfileForm_1 = SignupForm$1;
3600
- var AuthCookies_1 = authCookies;
3601
- var AuthHooks_1 = hooks;
3602
- var Iron_1 = iron;
3603
- var PassportLocal_1 = passportLocal;
3604
- var User_1 = user;
3605
- var ProcessData_1 = ProcessData;
3606
-
3607
- var auth = {
3608
- LoginForm: LoginForm_1,
3609
- SignupForm: SignupForm_1,
3610
- ProfileForm: ProfileForm_1,
3611
- AuthCookies: AuthCookies_1,
3612
- AuthHooks: AuthHooks_1,
3613
- Iron: Iron_1,
3614
- PassportLocal: PassportLocal_1,
3615
- User: User_1,
3616
- ProcessData: ProcessData_1
3617
- };
3618
-
3619
- exports.AuthCookies = AuthCookies_1;
3620
- exports.AuthHooks = AuthHooks_1;
3621
- exports.Iron = Iron_1;
3622
- exports.LoginForm = LoginForm_1;
3623
- exports.PassportLocal = PassportLocal_1;
3624
- exports.ProcessData = ProcessData_1;
3625
- exports.ProfileForm = ProfileForm_1;
3626
- exports.SignupForm = SignupForm_1;
3627
- exports.User = User_1;
3628
- exports.default = auth;