@defra/flood-webchat 0.0.1-beta.8 → 1.0.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 (50) hide show
  1. package/README.md +89 -1
  2. package/dist/client.js +1 -754
  3. package/dist/server.js +1 -383
  4. package/main.scss +12 -8
  5. package/package.json +27 -22
  6. package/src/client/components/availability/availability.jsx +89 -54
  7. package/src/client/components/availability/availability.scss +20 -32
  8. package/src/client/components/chat/chat.jsx +239 -0
  9. package/src/client/components/chat/chat.scss +258 -0
  10. package/src/client/components/errorSummary/error-summary.jsx +34 -0
  11. package/src/client/components/live-region.jsx +55 -0
  12. package/src/client/components/message/message.jsx +21 -0
  13. package/src/client/components/panel/panel-footer.jsx +9 -0
  14. package/src/client/components/panel/panel-header.jsx +55 -15
  15. package/src/client/components/panel/panel.jsx +128 -71
  16. package/src/client/components/panel/panel.scss +63 -22
  17. package/src/client/components/screens/end-chat.jsx +77 -0
  18. package/src/client/components/screens/feedback.jsx +65 -0
  19. package/src/client/components/screens/pre-chat.jsx +50 -30
  20. package/src/client/components/screens/request-chat.jsx +177 -4
  21. package/src/client/components/screens/settings.jsx +97 -0
  22. package/src/client/components/screens/unavailable.jsx +23 -0
  23. package/src/client/components/skip-link.jsx +42 -0
  24. package/src/client/hooks/useFocusedElements.js +80 -0
  25. package/src/client/hooks/useTextareaAutosize.js +13 -0
  26. package/src/client/index.jsx +18 -1
  27. package/src/client/lib/agent-status-headline.js +17 -0
  28. package/src/client/lib/check-availability.js +1 -0
  29. package/src/client/lib/history.js +16 -0
  30. package/src/client/lib/message-notification.js +30 -0
  31. package/src/client/lib/transform-messages.js +47 -0
  32. package/src/client/scss/_objects.scss +33 -0
  33. package/src/client/scss/_settings.scss +101 -0
  34. package/src/client/scss/_tools.scss +33 -0
  35. package/src/client/scss/_utilities.scss +25 -0
  36. package/src/client/store/AppProvider.jsx +184 -0
  37. package/src/client/store/actions-map.js +153 -0
  38. package/src/client/store/constants.js +5 -0
  39. package/src/client/store/reducer.js +31 -0
  40. package/src/client/store/useApp.js +5 -0
  41. package/src/client/store/useChatSdk.js +37 -0
  42. package/src/server/index.js +15 -6
  43. package/src/server/lib/client.js +31 -37
  44. package/src/server/lib/utils.js +10 -2
  45. package/webpack.config.mjs +0 -2
  46. package/webpack.prod.mjs +7 -0
  47. package/dist/client.js.map +0 -1
  48. package/dist/server.js.map +0 -1
  49. package/src/client/lib/external-stores.js +0 -4
  50. package/src/client/lib/external-sync-store.js +0 -42
package/dist/server.js CHANGED
@@ -1,383 +1 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ var __webpack_modules__ = ({
3
-
4
- /***/ "./src/server/index.js":
5
- /*!*****************************!*\
6
- !*** ./src/server/index.js ***!
7
- \*****************************/
8
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9
-
10
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
12
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
19
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
- var _require = __webpack_require__(/*! ./lib/client.js */ "./src/server/lib/client.js"),
21
- authenticate = _require.authenticate,
22
- getHost = _require.getHost,
23
- getIsOpen = _require.getIsOpen,
24
- getActivity = _require.getActivity;
25
-
26
- /**
27
- * Returns webchat availability
28
- * @param options {object}
29
- * @param options.clientId {string}
30
- * @param options.clientSecret {string}
31
- * @param options.accessKey {string}
32
- * @param options.accessSecret {string}
33
- * @param options.skillEndpoint {string}
34
- * @param options.hoursEndpoint {string}
35
- * @param options.maxQueueCount {string}
36
- * @returns {Promise<{date: Date, availability: (string)}>}
37
- */
38
- module.exports = /*#__PURE__*/function () {
39
- var _getAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
40
- var clientId, clientSecret, accessKey, accessSecret, skillEndpoint, hoursEndpoint, maxQueueCount, authorisation, _yield$authenticate, tenantId, token, tokenType, host, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, hasCapacity, hasAgentsAvailable, isOpen, isAvailable, isExistingOnly, availability;
41
- return _regeneratorRuntime().wrap(function _callee$(_context) {
42
- while (1) switch (_context.prev = _context.next) {
43
- case 0:
44
- clientId = _ref.clientId, clientSecret = _ref.clientSecret, accessKey = _ref.accessKey, accessSecret = _ref.accessSecret, skillEndpoint = _ref.skillEndpoint, hoursEndpoint = _ref.hoursEndpoint, maxQueueCount = _ref.maxQueueCount;
45
- authorisation = 'Basic ' + Buffer.from("".concat(encodeURIComponent(clientId), ":").concat(encodeURIComponent(clientSecret))).toString('base64'); // Cache authentication and re-authenticate when needed (lasts 1 hour?)
46
- _context.next = 4;
47
- return authenticate({
48
- authorisation: authorisation,
49
- accessKey: accessKey,
50
- accessSecret: accessSecret
51
- });
52
- case 4:
53
- _yield$authenticate = _context.sent;
54
- tenantId = _yield$authenticate.tenantId;
55
- token = _yield$authenticate.token;
56
- tokenType = _yield$authenticate.tokenType;
57
- _context.next = 10;
58
- return getHost({
59
- tenantId: tenantId
60
- });
61
- case 10:
62
- host = _context.sent;
63
- _context.next = 13;
64
- return Promise.all([getActivity({
65
- tokenType: tokenType,
66
- token: token,
67
- host: host,
68
- skillEndpoint: skillEndpoint,
69
- maxQueueCount: maxQueueCount
70
- }), getIsOpen({
71
- token: token,
72
- tokenType: tokenType,
73
- host: host,
74
- hoursEndpoint: hoursEndpoint
75
- })]);
76
- case 13:
77
- _yield$Promise$all = _context.sent;
78
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
79
- _yield$Promise$all2$ = _yield$Promise$all2[0];
80
- hasCapacity = _yield$Promise$all2$.hasCapacity;
81
- hasAgentsAvailable = _yield$Promise$all2$.hasAgentsAvailable;
82
- isOpen = _yield$Promise$all2[1];
83
- isAvailable = isOpen && hasAgentsAvailable && hasCapacity;
84
- isExistingOnly = isOpen && hasAgentsAvailable && !hasCapacity;
85
- availability = 'UNAVAILABLE';
86
- if (isAvailable) {
87
- availability = 'AVAILABLE';
88
- } else if (isExistingOnly) {
89
- availability = 'EXISTING';
90
- }
91
- return _context.abrupt("return", {
92
- date: new Date(),
93
- availability: availability
94
- });
95
- case 24:
96
- case "end":
97
- return _context.stop();
98
- }
99
- }, _callee);
100
- }));
101
- function getAvailability(_x) {
102
- return _getAvailability.apply(this, arguments);
103
- }
104
- return getAvailability;
105
- }();
106
-
107
- /***/ }),
108
-
109
- /***/ "./src/server/lib/client.js":
110
- /*!**********************************!*\
111
- !*** ./src/server/lib/client.js ***!
112
- \**********************************/
113
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
114
-
115
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
116
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
117
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
118
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
119
- var querystring = __webpack_require__(/*! querystring */ "querystring");
120
- var axios = __webpack_require__(/*! axios */ "axios");
121
- var jwtdecode = __webpack_require__(/*! jwt-decode */ "jwt-decode");
122
- var _require = __webpack_require__(/*! ./utils.js */ "./src/server/lib/utils.js"),
123
- isWithinHours = _require.isWithinHours;
124
- var contentType = 'application/x-www-form-urlencoded';
125
- var isFullUrl = function isFullUrl(endpoint) {
126
- return /^(https?:)?\/\//i.test(endpoint);
127
- };
128
- var authenticate = /*#__PURE__*/function () {
129
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
130
- var _jwtdecode;
131
- var authorisation, accessKey, accessSecret, uri, config, body, auth;
132
- return _regeneratorRuntime().wrap(function _callee$(_context) {
133
- while (1) switch (_context.prev = _context.next) {
134
- case 0:
135
- authorisation = _ref.authorisation, accessKey = _ref.accessKey, accessSecret = _ref.accessSecret;
136
- uri = 'https://cxone.niceincontact.com/auth/token';
137
- config = {
138
- signal: AbortSignal.timeout(3000),
139
- headers: {
140
- Host: 'eu1.niceincontact.com',
141
- 'Content-Type': contentType,
142
- Authorization: authorisation
143
- }
144
- };
145
- body = querystring.stringify({
146
- grant_type: 'password',
147
- username: accessKey,
148
- password: accessSecret
149
- });
150
- _context.next = 6;
151
- return axios.post(uri, body, config);
152
- case 6:
153
- auth = _context.sent;
154
- return _context.abrupt("return", {
155
- token: auth.data.access_token,
156
- tokenType: auth.data.token_type,
157
- tenantId: (_jwtdecode = jwtdecode(auth.data.id_token)) === null || _jwtdecode === void 0 ? void 0 : _jwtdecode.tenantId
158
- });
159
- case 8:
160
- case "end":
161
- return _context.stop();
162
- }
163
- }, _callee);
164
- }));
165
- return function authenticate(_x) {
166
- return _ref2.apply(this, arguments);
167
- };
168
- }();
169
- var getHost = /*#__PURE__*/function () {
170
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
171
- var tenantId, uri, config, api;
172
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
173
- while (1) switch (_context2.prev = _context2.next) {
174
- case 0:
175
- tenantId = _ref3.tenantId;
176
- uri = "https://cxone.niceincontact.com/.well-known/cxone-configuration?tenantId=".concat(tenantId);
177
- config = {
178
- signal: AbortSignal.timeout(3000)
179
- };
180
- _context2.next = 5;
181
- return axios.get(uri, config);
182
- case 5:
183
- api = _context2.sent;
184
- return _context2.abrupt("return", "api-".concat(api.data.area, ".niceincontact.com"));
185
- case 7:
186
- case "end":
187
- return _context2.stop();
188
- }
189
- }, _callee2);
190
- }));
191
- return function getHost(_x2) {
192
- return _ref4.apply(this, arguments);
193
- };
194
- }();
195
- var getActivity = /*#__PURE__*/function () {
196
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
197
- var tokenType, token, host, skillEndpoint, maxQueueCount, config, uri, skill, activity;
198
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
199
- while (1) switch (_context3.prev = _context3.next) {
200
- case 0:
201
- tokenType = _ref5.tokenType, token = _ref5.token, host = _ref5.host, skillEndpoint = _ref5.skillEndpoint, maxQueueCount = _ref5.maxQueueCount;
202
- config = {
203
- signal: AbortSignal.timeout(3000),
204
- headers: {
205
- Host: host,
206
- Authorization: "".concat(tokenType, " ").concat(token),
207
- 'Content-Type': contentType
208
- }
209
- };
210
- uri = isFullUrl(skillEndpoint) ? skillEndpoint : "https://".concat(host).concat(skillEndpoint);
211
- _context3.next = 5;
212
- return axios.get(uri, config);
213
- case 5:
214
- skill = _context3.sent;
215
- activity = skill.data.skillActivity[0];
216
- return _context3.abrupt("return", {
217
- hasCapacity: activity.queueCount < maxQueueCount,
218
- hasAgentsAvailable: activity.agentsAvailable >= 1
219
- });
220
- case 8:
221
- case "end":
222
- return _context3.stop();
223
- }
224
- }, _callee3);
225
- }));
226
- return function getActivity(_x3) {
227
- return _ref6.apply(this, arguments);
228
- };
229
- }();
230
- var getIsOpen = /*#__PURE__*/function () {
231
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref7) {
232
- var host, token, tokenType, hoursEndpoint, config, uri, hours, days;
233
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
234
- while (1) switch (_context4.prev = _context4.next) {
235
- case 0:
236
- host = _ref7.host, token = _ref7.token, tokenType = _ref7.tokenType, hoursEndpoint = _ref7.hoursEndpoint;
237
- config = {
238
- signal: AbortSignal.timeout(3000),
239
- headers: {
240
- Host: 'api-l36.niceincontact.com',
241
- Authorization: "".concat(tokenType, " ").concat(token),
242
- 'Content-Type': contentType
243
- }
244
- };
245
- uri = isFullUrl(hoursEndpoint) ? hoursEndpoint : "https://".concat(host).concat(hoursEndpoint);
246
- _context4.next = 5;
247
- return axios.get(uri, config);
248
- case 5:
249
- hours = _context4.sent;
250
- days = hours.data.resultSet.hoursOfOperationProfiles[0].days;
251
- return _context4.abrupt("return", isWithinHours(days));
252
- case 8:
253
- case "end":
254
- return _context4.stop();
255
- }
256
- }, _callee4);
257
- }));
258
- return function getIsOpen(_x4) {
259
- return _ref8.apply(this, arguments);
260
- };
261
- }();
262
- module.exports = {
263
- authenticate: authenticate,
264
- getHost: getHost,
265
- getIsOpen: getIsOpen,
266
- getActivity: getActivity
267
- };
268
-
269
- /***/ }),
270
-
271
- /***/ "./src/server/lib/utils.js":
272
- /*!*********************************!*\
273
- !*** ./src/server/lib/utils.js ***!
274
- \*********************************/
275
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
276
-
277
- var _require = __webpack_require__(/*! luxon */ "luxon"),
278
- DateTime = _require.DateTime;
279
- var getHour = function getHour(time) {
280
- return Number(time.split(':')[0]);
281
- };
282
- var isWithinHours = function isWithinHours(days, date) {
283
- var now = date ? DateTime.fromISO(date) : DateTime.local();
284
- now.setZone('Europe/London');
285
- var newDate = date ? new Date(date) : new Date();
286
- var today = newDate.toLocaleDateString('en-GB', {
287
- weekday: 'long'
288
- });
289
- var dateParts = newDate.toLocaleDateString('en-GB').split('/');
290
- var todaysAvailability = days.find(function (item) {
291
- return item.day === today;
292
- });
293
- var todaysDateTimeOpen = DateTime.local(Number(dateParts[2]), Number(dateParts[1]), Number(dateParts[0]), getHour(todaysAvailability.openTime));
294
- var todaysDateTimeClose = DateTime.local(Number(dateParts[2]), Number(dateParts[1]), Number(dateParts[0]), getHour(todaysAvailability.closeTime));
295
- return now.diff(todaysDateTimeOpen).milliseconds >= 0 && now.diff(todaysDateTimeClose).milliseconds <= 0;
296
- };
297
- module.exports = {
298
- isWithinHours: isWithinHours
299
- };
300
-
301
- /***/ }),
302
-
303
- /***/ "axios":
304
- /*!************************!*\
305
- !*** external "axios" ***!
306
- \************************/
307
- /***/ ((module) => {
308
-
309
- "use strict";
310
- module.exports = require("axios");
311
-
312
- /***/ }),
313
-
314
- /***/ "jwt-decode":
315
- /*!*****************************!*\
316
- !*** external "jwt-decode" ***!
317
- \*****************************/
318
- /***/ ((module) => {
319
-
320
- "use strict";
321
- module.exports = require("jwt-decode");
322
-
323
- /***/ }),
324
-
325
- /***/ "luxon":
326
- /*!************************!*\
327
- !*** external "luxon" ***!
328
- \************************/
329
- /***/ ((module) => {
330
-
331
- "use strict";
332
- module.exports = require("luxon");
333
-
334
- /***/ }),
335
-
336
- /***/ "querystring":
337
- /*!******************************!*\
338
- !*** external "querystring" ***!
339
- \******************************/
340
- /***/ ((module) => {
341
-
342
- "use strict";
343
- module.exports = require("querystring");
344
-
345
- /***/ })
346
-
347
- /******/ });
348
- /************************************************************************/
349
- /******/ // The module cache
350
- /******/ var __webpack_module_cache__ = {};
351
- /******/
352
- /******/ // The require function
353
- /******/ function __webpack_require__(moduleId) {
354
- /******/ // Check if module is in cache
355
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
356
- /******/ if (cachedModule !== undefined) {
357
- /******/ return cachedModule.exports;
358
- /******/ }
359
- /******/ // Create a new module (and put it into the cache)
360
- /******/ var module = __webpack_module_cache__[moduleId] = {
361
- /******/ // no module.id needed
362
- /******/ // no module.loaded needed
363
- /******/ exports: {}
364
- /******/ };
365
- /******/
366
- /******/ // Execute the module function
367
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
368
- /******/
369
- /******/ // Return the exports of the module
370
- /******/ return module.exports;
371
- /******/ }
372
- /******/
373
- /************************************************************************/
374
- /******/
375
- /******/ // startup
376
- /******/ // Load entry module and return exports
377
- /******/ // This entry module is referenced by other modules so it can't be inlined
378
- /******/ var __webpack_exports__ = __webpack_require__("./src/server/index.js");
379
- /******/ module.exports = __webpack_exports__;
380
- /******/
381
- /******/ })()
382
- ;
383
- //# sourceMappingURL=server.js.map
1
+ (()=>{var e={525:(e,t,n)=>{const{authenticate:o,getApiBaseUrl:a,getIsOpen:s,getActivity:i}=n(398);e.exports=async function({clientId:e,clientSecret:t,accessKey:n,accessSecret:r,maxQueueCount:c,skillEndpoint:l,hoursEndpoint:u,wellKnownUri:p="https://cxone.niceincontact.com/.well-known/cxone-configuration",authenticationUri:d="https://cxone.niceincontact.com/auth/token"}){const h="Basic "+Buffer.from(`${encodeURIComponent(e)}:${encodeURIComponent(t)}`).toString("base64"),{tenantId:m,token:g,tokenType:w}=await o({authenticationUri:d,authorisation:h,accessKey:n,accessSecret:r}),y=await a({wellKnownUri:p,tenantId:m}),[{hasCapacity:A,hasAgentsAvailable:k},f]=await Promise.all([i({baseUrl:y,tokenType:w,token:g,skillEndpoint:l,maxQueueCount:c}),s({baseUrl:y,token:g,tokenType:w,hoursEndpoint:u})]);let x="UNAVAILABLE";return f&&k&&A?x="AVAILABLE":f&&k&&!A&&(x="EXISTING"),{date:new Date,availability:x}}},398:(e,t,n)=>{const o=n(45),a=n(938),s=n(158),{isWithinHours:i}=n(792),r="application/x-www-form-urlencoded";e.exports={authenticate:async({authenticationUri:e,authorisation:t,accessKey:n,accessSecret:i})=>{const c=new URL(e),l=o.stringify({grant_type:"password",username:n,password:i}),u=await a.post(c.href,l,{signal:AbortSignal.timeout(3e3),headers:{Host:c.host,"Content-Type":r,Authorization:t}});return{token:u.data.access_token,tokenType:u.data.token_type,tenantId:s(u.data.id_token)?.tenantId}},getApiBaseUrl:async({wellKnownUri:e,tenantId:t})=>{const n=new URL(e);n.searchParams.set("tenantId",t);const{data:o}=await a.get(n.href,{headers:{Host:n.host},signal:AbortSignal.timeout(3e3)});return o.api_endpoint},getIsOpen:async({baseUrl:e,token:t,tokenType:n,hoursEndpoint:o})=>{const s=new URL(o,e),c=(await a.get(s.href,{signal:AbortSignal.timeout(3e3),headers:{Host:s.host,Authorization:`${n} ${t}`,"Content-Type":r}})).data.resultSet.hoursOfOperationProfiles[0].days;return i(c)},getActivity:async({tokenType:e,token:t,baseUrl:n,skillEndpoint:o,maxQueueCount:s})=>{const i=new URL(o,n),c=(await a.get(i.href,{signal:AbortSignal.timeout(3e3),headers:{Host:i.host,Authorization:`${e} ${t}`,"Content-Type":r}})).data.skillActivity[0];return{hasCapacity:c.queueCount<s,hasAgentsAvailable:c.agentsAvailable>=1}}}},792:(e,t,n)=>{const{DateTime:o}=n(168),a=e=>Number(e.split(":")[0]);e.exports={isWithinHours:(e,t)=>{const n=t?o.fromISO(t):o.local();n.setZone("Europe/London");const s=t?new Date(t):new Date,i=s.toLocaleDateString("en-GB",{weekday:"long"}),r=s.toLocaleDateString("en-GB").split("/"),c=e.find((e=>e.day===i)),l=o.local(Number(r[2]),Number(r[1]),Number(r[0]),a(c.openTime)),u=o.local(Number(r[2]),Number(r[1]),Number(r[0]),a(c.closeTime));return n.diff(l).milliseconds>=0&&n.diff(u).milliseconds<=0},stripPageTitle:e=>e.replace(/^\(\d+ new messages?\) - /,"")}},938:e=>{"use strict";e.exports=require("axios")},158:e=>{"use strict";e.exports=require("jwt-decode")},168:e=>{"use strict";e.exports=require("luxon")},45:e=>{"use strict";e.exports=require("querystring")}},t={},n=function n(o){var a=t[o];if(void 0!==a)return a.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}(525);module.exports=n})();
package/main.scss CHANGED
@@ -1,13 +1,17 @@
1
1
 
2
2
  // Required GOVUK Styles
3
- @import "govuk-frontend/govuk/core/typography";
4
- @import "govuk-frontend/govuk/utilities/visually-hidden";
3
+ @import "govuk-frontend/dist/govuk/core/typography";
4
+ @import "govuk-frontend/dist/govuk/core/links";
5
+ @import "govuk-frontend/dist/govuk/utilities/visually-hidden";
6
+ @import "govuk-frontend/dist/govuk/components/button/button";
5
7
 
6
- // Components
8
+ // (ITCSS)
9
+ @import "./src/client/scss/settings";
10
+ @import "./src/client/scss/tools";
11
+ @import "./src/client/scss/objects";
12
+ @import "./src/client/scss/utilities";
13
+
14
+ // React components
7
15
  @import "./src/client/components/availability/availability";
8
16
  @import "./src/client/components/panel/panel";
9
-
10
-
11
- .wc-scroll-padding {
12
- scroll-padding-bottom: calc(2rem + 20px);
13
- }
17
+ @import "./src/client/components/chat/chat";
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@defra/flood-webchat",
3
- "version": "0.0.1-beta.8",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "dist/server.js",
6
6
  "browser": "dist/client.js",
7
7
  "scripts": {
8
8
  "test": "npm run lint && npm run unit-test",
9
9
  "dev": "(cd demo && webpack server)",
10
- "build": "webpack",
10
+ "build": "webpack --config webpack.prod.mjs",
11
11
  "unit-test": "jest",
12
12
  "lint": "npm run lint:js && npm run lint:scss",
13
13
  "lint:fix": "npm run lint:js -- --fix && npm run lint:scss -- --fix",
14
14
  "lint:js": "standard",
15
15
  "lint:scss": "stylelint \"**/*.scss\"",
16
- "prepare": "node -e \"try { require('husky').install() } catch (e) {if (e.code !== 'MODULE_NOT_FOUND') { throw e } }\""
16
+ "prepare": "husky install"
17
17
  },
18
18
  "standard": {
19
19
  "ignore": [
@@ -27,43 +27,48 @@
27
27
  "author": "DEFRA",
28
28
  "license": "OGL-UK-3.0",
29
29
  "devDependencies": {
30
- "@babel/core": "^7.22.10",
31
- "@babel/preset-env": "^7.22.10",
32
- "@babel/preset-react": "^7.22.15",
33
- "@testing-library/jest-dom": "^6.1.3",
34
- "@testing-library/react": "^14.0.0",
35
- "@testing-library/user-event": "^14.5.1",
36
- "@types/jest": "^29.5.4",
30
+ "@babel/core": "^7.24.6",
31
+ "@babel/preset-env": "^7.24.6",
32
+ "@babel/preset-react": "^7.24.6",
33
+ "@testing-library/jest-dom": "^6.4.5",
34
+ "@testing-library/react": "^15.0.7",
35
+ "@testing-library/user-event": "^14.5.2",
36
+ "@types/jest": "^29.5.12",
37
37
  "babel-jest": "^29.6.4",
38
38
  "babel-loader": "^9.1.3",
39
- "core-js": "^2.6.11",
40
- "css-loader": "^6.8.1",
41
- "dotenv": "^16.3.1",
39
+ "core-js": "^3.37.1",
40
+ "css-loader": "^7.1.2",
41
+ "dotenv": "^16.4.5",
42
42
  "husky": "^8.0.3",
43
- "jest": "^29.6.3",
44
- "jest-environment-jsdom": "^29.6.3",
43
+ "jest": "^29.7.0",
44
+ "jest-environment-jsdom": "^29.7.0",
45
45
  "mini-css-extract-plugin": "^2.7.6",
46
46
  "node-cache": "^5.1.2",
47
47
  "node-sass": "^9.0.0",
48
48
  "sass": "^1.66.1",
49
- "sass-loader": "^13.3.2",
49
+ "sass-loader": "^14.2.1",
50
50
  "standard": "^17.1.0",
51
- "stylelint": "^15.10.3",
51
+ "stylelint": "^15.11.0",
52
52
  "stylelint-config-gds": "^1.0.0",
53
- "webpack": "^5.88.2",
53
+ "webpack": "^5.91.0",
54
54
  "webpack-cli": "^5.1.4",
55
- "webpack-dev-server": "^4.15.1",
55
+ "webpack-dev-server": "^5.0.4",
56
+ "webpack-merge": "^5.10.0",
56
57
  "webpack-node-externals": "^3.0.0"
57
58
  },
58
59
  "peerDependencies": {
59
- "govuk-frontend": "^4.0.0"
60
+ "govuk-frontend": "^5.4.0"
60
61
  },
61
62
  "dependencies": {
62
- "axios": "^1.5.0",
63
+ "@nice-devone/nice-cxone-chat-web-sdk": "^1.18.0",
64
+ "axios": "^1.7.2",
65
+ "html-react-parser": "^5.1.10",
63
66
  "jwt-decode": "^3.1.2",
67
+ "lodash.debounce": "^4.0.8",
64
68
  "luxon": "^3.4.3",
65
69
  "querystring": "^0.2.1",
66
70
  "react": "^18.2.0",
67
- "react-dom": "^18.2.0"
71
+ "react-dom": "^18.2.0",
72
+ "uuid": "^9.0.1"
68
73
  }
69
74
  }