@defra/flood-webchat 0.0.1-alpha.7 → 0.0.1-alpha.8

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.
package/package.json CHANGED
@@ -1,20 +1,19 @@
1
1
  {
2
2
  "name": "@defra/flood-webchat",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/server/index.js",
7
7
  "browser": "src/client/index.js",
8
8
  "scripts": {
9
- "test": "npm run compile-templates && npm run lint && npm run unit-test",
10
- "dev": "npm run compile-templates && node -r dotenv/config node_modules/.bin/webpack server --config demo/webpack.config.mjs",
9
+ "test": "npm run lint && npm run unit-test",
10
+ "dev": "(cd demo && webpack server)",
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 } }\"",
17
- "compile-templates": "mkdir -p dist && nunjucks-precompile templates > ./dist/templates.js"
16
+ "prepare": "node -e \"try { require('husky').install() } catch (e) {if (e.code !== 'MODULE_NOT_FOUND') { throw e } }\""
18
17
  },
19
18
  "standard": {
20
19
  "ignore": [
@@ -35,28 +34,21 @@
35
34
  "babel-loader": "^9.1.3",
36
35
  "core-js": "^2.6.11",
37
36
  "css-loader": "^6.8.1",
38
- "dotenv": "^16.3.1",
39
37
  "husky": "^8.0.3",
40
38
  "jest": "^29.6.3",
41
39
  "jest-environment-jsdom": "^29.6.3",
42
40
  "mini-css-extract-plugin": "^2.7.6",
43
- "node-cache": "^5.1.2",
44
41
  "node-sass": "^9.0.0",
45
42
  "sass": "^1.66.1",
46
43
  "sass-loader": "^13.3.2",
47
44
  "standard": "^17.1.0",
48
45
  "stylelint": "^15.10.3",
49
- "stylelint-config-gds": "^1.0.0",
46
+ "stylelint-config-standard-scss": "^10.0.0",
50
47
  "webpack": "^5.88.2",
51
48
  "webpack-cli": "^5.1.4",
52
49
  "webpack-dev-server": "^4.15.1"
53
50
  },
54
51
  "peerDependencies": {
55
52
  "govuk-frontend": "^3.14.0"
56
- },
57
- "dependencies": {
58
- "@nice-devone/nice-cxone-chat-web-sdk": "1.3.0",
59
- "axios": "^0.24.0",
60
- "nunjucks": "^3.2.4"
61
53
  }
62
54
  }
@@ -1,14 +1,3 @@
1
- import WebChat from './lib/webchat.js'
2
-
3
- /**
4
- * @param {string} id
5
- * @param {object} options
6
- * @param {string} options.brandId
7
- * @param {string} options.channelId
8
- * @param {string} options.environmentName
9
- * @param {string} options.availabilityEndpoint
10
- * @param {string} options.audioUrl
11
- **/
12
- export function init (id, options) {
13
- return new WebChat(id, options)
1
+ export function init (value) {
2
+ return value === true
14
3
  }
@@ -1,46 +1,3 @@
1
- import { authenticate, getHost, getIsOpen, getActivity } from './client.js'
2
-
3
- /**
4
- * Returns webchat availability
5
- * @param options {object}
6
- * @param options.clientId {string}
7
- * @param options.clientSecret {string}
8
- * @param options.accessKey {string}
9
- * @param options.accessSecret {string}
10
- * @param options.skillEndpoint {string}
11
- * @param options.hoursEndpoint {string}
12
- * @param options.maxQueueCount {string}
13
- * @returns {Promise<{date: Date, availability: (string)}>}
14
- */
15
- export default async function getAvailability ({
16
- clientId,
17
- clientSecret,
18
- accessKey,
19
- accessSecret,
20
- skillEndpoint,
21
- hoursEndpoint,
22
- maxQueueCount
23
- }) {
24
- const authorisation = 'Basic ' + Buffer.from(`${encodeURIComponent(clientId)}:${encodeURIComponent(clientSecret)}`).toString('base64')
25
-
26
- // Cache authentication and re-authenticate when needed (lasts 1 hour?)
27
- const { tenantId, token, tokenType } = await authenticate({ authorisation, accessKey, accessSecret })
28
- const host = await getHost({ tenantId })
29
-
30
- const [{ hasCapacity, hasAgentsAvailable }, isOpen] = await Promise.all([
31
- getActivity({ tokenType, token, host, skillEndpoint, maxQueueCount }),
32
- getIsOpen({ token, tokenType, host, hoursEndpoint })
33
- ])
34
-
35
- // Hours of operation
36
-
37
- // Availability
38
- const isAvailable = isOpen && hasAgentsAvailable && hasCapacity
39
- const isExistingOnly = isOpen && hasAgentsAvailable && !hasCapacity
40
- const availability = isAvailable ? 'AVAILABLE' : isExistingOnly ? 'EXISTING' : 'UNAVAILABLE'
41
-
42
- return {
43
- date: new Date(),
44
- availability
45
- }
1
+ export function foo (value) {
2
+ return value === 'bar'
46
3
  }
Binary file
package/babel.config.cjs DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: [['@babel/preset-env', { targets: { node: 'current' } }]]
3
- }