@mjhls/mjh-framework 1.0.850-beta.0 → 1.0.850-beta.1

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