diff --git a/demos/demo-minimal-js/package-lock.json b/demos/demo-minimal-js/package-lock.json index 47cf2725..92bf73fd 100644 --- a/demos/demo-minimal-js/package-lock.json +++ b/demos/demo-minimal-js/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@hubspot/calling-extensions-sdk": "^0.8.2", + "@hubspot/calling-extensions-sdk": "^0.8.4-alpha.0", "uuid": "^10.0.0" }, "devDependencies": { @@ -33,9 +33,9 @@ } }, "node_modules/@hubspot/calling-extensions-sdk": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.2.tgz", - "integrity": "sha512-nv67Mm3PhP1zb4giwudoqb69u0q2lvE6Y+gEEMrYqVDl8mnwQALKEYanflH4LKV2PxjrjXgrvcmpOLgn4n6gtQ==", + "version": "0.8.4-alpha.0", + "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.4-alpha.0.tgz", + "integrity": "sha512-ryxoIbo+LqwkWbXwcOwThvTPBngx8HkP1bckL2R4k45b0Oi13NoEdGj+R3E6DpIrSHPql8nt32sl2bVskpLMJg==", "license": "MIT", "engines": { "node": ">=14" diff --git a/demos/demo-minimal-js/package.json b/demos/demo-minimal-js/package.json index cc502c91..dcd99937 100644 --- a/demos/demo-minimal-js/package.json +++ b/demos/demo-minimal-js/package.json @@ -21,7 +21,7 @@ "webpack-dev-server": "^4.11.1" }, "dependencies": { - "@hubspot/calling-extensions-sdk": "^0.8.2", + "@hubspot/calling-extensions-sdk": "^0.8.4-alpha.0", "uuid": "^10.0.0" } } diff --git a/demos/demo-react-ts/package-lock.json b/demos/demo-react-ts/package-lock.json index 5be879da..f4f88d1c 100644 --- a/demos/demo-react-ts/package-lock.json +++ b/demos/demo-react-ts/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@hubspot/calling-extensions-sdk": "^0.8.2", + "@hubspot/calling-extensions-sdk": "^0.8.4-alpha.0", "react": "^18.2.0", "react-aria": "^3.22.0", "react-dom": "^18.2.0", @@ -1861,9 +1861,9 @@ } }, "node_modules/@hubspot/calling-extensions-sdk": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.2.tgz", - "integrity": "sha512-nv67Mm3PhP1zb4giwudoqb69u0q2lvE6Y+gEEMrYqVDl8mnwQALKEYanflH4LKV2PxjrjXgrvcmpOLgn4n6gtQ==", + "version": "0.8.4-alpha.0", + "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.4-alpha.0.tgz", + "integrity": "sha512-ryxoIbo+LqwkWbXwcOwThvTPBngx8HkP1bckL2R4k45b0Oi13NoEdGj+R3E6DpIrSHPql8nt32sl2bVskpLMJg==", "license": "MIT", "engines": { "node": ">=14" @@ -10041,9 +10041,9 @@ } }, "@hubspot/calling-extensions-sdk": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.2.tgz", - "integrity": "sha512-nv67Mm3PhP1zb4giwudoqb69u0q2lvE6Y+gEEMrYqVDl8mnwQALKEYanflH4LKV2PxjrjXgrvcmpOLgn4n6gtQ==" + "version": "0.8.4-alpha.0", + "resolved": "https://registry.npmjs.org/@hubspot/calling-extensions-sdk/-/calling-extensions-sdk-0.8.4-alpha.0.tgz", + "integrity": "sha512-ryxoIbo+LqwkWbXwcOwThvTPBngx8HkP1bckL2R4k45b0Oi13NoEdGj+R3E6DpIrSHPql8nt32sl2bVskpLMJg==" }, "@internationalized/date": { "version": "3.1.0", diff --git a/demos/demo-react-ts/package.json b/demos/demo-react-ts/package.json index 734e1fdf..9c9bc334 100644 --- a/demos/demo-react-ts/package.json +++ b/demos/demo-react-ts/package.json @@ -18,7 +18,7 @@ "node": ">=14" }, "dependencies": { - "@hubspot/calling-extensions-sdk": "^0.8.2", + "@hubspot/calling-extensions-sdk": "^0.8.4-alpha.0", "react": "^18.2.0", "react-aria": "^3.22.0", "react-dom": "^18.2.0", diff --git a/index.js b/index.ts similarity index 87% rename from index.js rename to index.ts index 463874c5..1d5ae37b 100644 --- a/index.js +++ b/index.ts @@ -4,4 +4,4 @@ import IFrameManager from "./src/IFrameManager"; export default CallingExtensions; export { Constants, IFrameManager }; -export * from "./src/typedefs"; +export * from "./src/types"; diff --git a/package-lock.json b/package-lock.json index f09504b1..32d27e89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,19 @@ { "name": "@hubspot/calling-extensions-sdk", - "version": "0.8.3", + "version": "0.8.4-beta.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@hubspot/calling-extensions-sdk", - "version": "0.8.3", + "version": "0.8.4-beta.0", "license": "MIT", "devDependencies": { "@babel/cli": "^7.21.0", "@babel/core": "^7.4.5", "@babel/preset-env": "^7.21.4", + "@babel/preset-typescript": "^7.26.0", + "@types/jasmine": "^5.1.5", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", "babel-loader": "^8.0.6", @@ -28,7 +30,8 @@ "ts-loader": "^9.5.1", "typescript": "^5.5.4", "webpack": "^5.77.0", - "webpack-cli": "^5.0.1" + "webpack-cli": "^5.0.1", + "webpack-merge": "^6.0.1" }, "engines": { "node": ">=14" @@ -77,13 +80,15 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", - "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.23.4", - "chalk": "^2.4.2" + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" @@ -138,41 +143,45 @@ } }, "node_modules/@babel/generator": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.5.tgz", - "integrity": "sha512-BPssCHrBD+0YrxviOa3QzpqwhNIXKEtOa2jQrm4FlmkC2apYgRnQcmPWiGZDlGxiNtltnUFolMe8497Esry+jA==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.3.tgz", + "integrity": "sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.23.5", - "@jridgewell/gen-mapping": "^0.3.2", - "@jridgewell/trace-mapping": "^0.3.17", - "jsesc": "^2.5.1" + "@babel/parser": "^7.26.3", + "@babel/types": "^7.26.3", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, + "license": "MIT", "dependencies": { - "@jridgewell/set-array": "^1.0.1", + "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" } }, "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", - "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.25.9.tgz", + "integrity": "sha512-gv7320KBUFJz1RnylIg5WWYPRXKZ884AGkYpgpWW02TH66Dl+HaC1t1CKd0z3R4b6hdYEcmrNZHUmfCP+1u3/g==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -220,19 +229,19 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.0.tgz", - "integrity": "sha512-Q8wNiMIdwsv5la5SPxNYzzkPnjgC0Sy0i7jLkVOCdllu/xcVNkr3TeZzbHBJrj+XXRqzX5uCyCoV9eu6xUG7KQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.9.tgz", + "integrity": "sha512-UTZQMvt0d/rSz6KI+qdu7GQze5TIajwTS++GUozlw8VBJDEOAqSXwm1WvmYEZwqdqSGQshRocPDqrt4HBZB3fQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.18.6", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-member-expression-to-functions": "^7.21.0", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/helper-replace-supers": "^7.20.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/helper-split-export-declaration": "^7.18.6" + "@babel/helper-annotate-as-pure": "^7.25.9", + "@babel/helper-member-expression-to-functions": "^7.25.9", + "@babel/helper-optimise-call-expression": "^7.25.9", + "@babel/helper-replace-supers": "^7.25.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.25.9", + "@babel/traverse": "^7.25.9", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -241,6 +250,16 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-regexp-features-plugin": { "version": "7.21.0", "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.21.0.tgz", @@ -330,65 +349,70 @@ } }, "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.0.tgz", - "integrity": "sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.25.9.tgz", + "integrity": "sha512-wbfdZ9w5vk0C0oyHqAJbc62+vet5prjj01jjJ8sKn3j9h3MQQlflEdXYvuqRWjHnM12coDEqiC1IRCi0U/EKwQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.21.0" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz", - "integrity": "sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.20.2", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.2", - "@babel/types": "^7.21.2" + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", - "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.25.9.tgz", + "integrity": "sha512-FIpuNaz5ow8VyrYcnXQTDRGvV6tTjkNtCK/RYNDXGSLlUD6cBuQTSw43CShGxjvfBTfcUA/r6UhUCbtYqkhcuQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz", - "integrity": "sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -412,41 +436,32 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.20.7.tgz", - "integrity": "sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.25.9.tgz", + "integrity": "sha512-IiDqTOTBQy0sWyeXyGSC5TBJpGFXBkRynjBeXsvbhQFKj2viwJC76Epz35YLU1fpe/Am6Vppb7W7zM4fPQzLsQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-member-expression-to-functions": "^7.20.7", - "@babel/helper-optimise-call-expression": "^7.18.6", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/helper-member-expression-to-functions": "^7.25.9", + "@babel/helper-optimise-call-expression": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", - "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.20.2" }, - "engines": { - "node": ">=6.9.0" + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", - "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.25.9.tgz", + "integrity": "sha512-K4Du3BFa3gvyhzgPcntrkDgZzQaq6uozzcpGbOO1OEJaI+EJdqWIMTLgFgQf6lrfiDFo5FU+BxKepI9RmZqahA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.20.0" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -465,28 +480,31 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.23.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", - "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -520,25 +538,15 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/highlight": { - "version": "7.23.4", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", - "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", + "node_modules/@babel/parser": { + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz", + "integrity": "sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.20", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0" + "@babel/types": "^7.26.3" }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.5.tgz", - "integrity": "sha512-hOOqoiNXrmGdFbhgCzu6GiURxUgM27Xwd/aPuu8RfHEZPBzL1Z54okAHAQjXfcQNwvrlkAmAp4SlRTZ45vlthQ==", - "dev": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -917,6 +925,22 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-logical-assignment-operators": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", @@ -1019,6 +1043,22 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-arrow-functions": { "version": "7.20.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.20.7.tgz", @@ -1261,14 +1301,14 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.2.tgz", - "integrity": "sha512-Cln+Yy04Gxua7iPdj6nOV96smLGjpElir5YwzF0LBPKoPlLDNJePNlrGGaybAJkd0zKRnOVXOgizSqPYMNYkzA==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.26.3.tgz", + "integrity": "sha512-MgR55l4q9KddUDITEzEFYn5ZsGDXMSsU9E+kh7fjRXTIC3RHqfCo8RPRbyReYJh44HQ/yomFkqbOFohXvDCiIQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.21.2", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-simple-access": "^7.20.2" + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -1495,6 +1535,26 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.26.3.tgz", + "integrity": "sha512-6+5hpdr6mETwSKjmJUdYw0EIkATiQhnELWlE3kJFBwSg/BGIVwVaVbX+gOXBCdc7Ln1RXZxyWGecIXhUfnl7oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.25.9", + "@babel/helper-create-class-features-plugin": "^7.25.9", + "@babel/helper-plugin-utils": "^7.25.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.25.9", + "@babel/plugin-syntax-typescript": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-unicode-escapes": { "version": "7.18.10", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz", @@ -1640,6 +1700,26 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-typescript": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.26.0.tgz", + "integrity": "sha512-NMk1IGZ5I/oHhoXEElcm+xUnL/szL6xflkFZmoEU9xj1qSJXpiS7rsspYo92B4DRCDvZn2erT5LdsCeXAKNCkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", + "@babel/plugin-syntax-jsx": "^7.25.9", + "@babel/plugin-transform-modules-commonjs": "^7.25.9", + "@babel/plugin-transform-typescript": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/regjsgen": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz", @@ -1659,34 +1739,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.5.tgz", - "integrity": "sha512-czx7Xy5a6sapWWRx61m1Ke1Ra4vczu1mCTtJam5zRTBOonfdJ+S/B6HYmGYu3fJtr8GGET3si6IhgWVBhJ/m8w==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.23.5", - "@babel/generator": "^7.23.5", - "@babel/helper-environment-visitor": "^7.22.20", - "@babel/helper-function-name": "^7.23.0", - "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.23.5", - "@babel/types": "^7.23.5", - "debug": "^4.1.0", + "version": "7.26.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.4.tgz", + "integrity": "sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.3", + "@babel/parser": "^7.26.3", + "@babel/template": "^7.25.9", + "@babel/types": "^7.26.3", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { @@ -1694,14 +1773,14 @@ } }, "node_modules/@babel/types": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.5.tgz", - "integrity": "sha512-ON5kSOJwVO6xXVRTvOI0eOnWe7VdUcIpsovGo9U/Br4Ie4UVFQTboO2cYnDhAGU6Fp+UxSiT+pMft0SMHfuq6w==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz", + "integrity": "sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.23.4", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -1939,6 +2018,13 @@ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, + "node_modules/@types/jasmine": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-5.1.5.tgz", + "integrity": "sha512-SaCZ3kM5NjOiJqMRYwHpLbTfUC2Dyk1KS3QanNFsUYPGTk70CWVK/J9ueun6zNhw/UkgV7xl8V4ZLQZNRbfnNw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -2469,18 +2555,6 @@ "node": ">=8" } }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -2920,20 +2994,6 @@ } ] }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -2985,21 +3045,6 @@ "node": ">=6" } }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, "node_modules/colorette": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", @@ -3485,15 +3530,6 @@ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "dev": true }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/eslint": { "version": "8.41.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", @@ -4414,6 +4450,16 @@ "node": ">=8" } }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "license": "BSD-3-Clause", + "bin": { + "flat": "cli.js" + } + }, "node_modules/flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -4708,15 +4754,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", @@ -5422,15 +5459,16 @@ } }, "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, + "license": "MIT", "bin": { "jsesc": "bin/jsesc" }, "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/json-parse-even-better-errors": { @@ -6858,18 +6896,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -6985,15 +7011,6 @@ "node": ">=8.17.0" } }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -7481,19 +7498,36 @@ "node": ">=14" } }, - "node_modules/webpack-merge": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", - "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "node_modules/webpack-cli/node_modules/webpack-merge": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz", + "integrity": "sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==", "dev": true, + "license": "MIT", "dependencies": { "clone-deep": "^4.0.1", + "flat": "^5.0.2", "wildcard": "^2.0.0" }, "engines": { "node": ">=10.0.0" } }, + "node_modules/webpack-merge": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-6.0.1.tgz", + "integrity": "sha512-hXXvrjtx2PLYx4qruKl+kyRSLc52V+cCvMxRjmKwoA+CBbbF5GfIBtR6kCvl0fYGqTUPKB+1ktVmTHqMOzgCBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone-deep": "^4.0.1", + "flat": "^5.0.2", + "wildcard": "^2.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/webpack-sources": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", diff --git a/package.json b/package.json index 28e3b181..cc422e18 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,14 @@ { "name": "@hubspot/calling-extensions-sdk", - "version": "0.8.3", + "version": "0.8.4-beta.0", "description": "A JavaScript SDK for integrating calling apps into HubSpot.", "publishConfig": { "access": "public" }, "scripts": { - "build": "webpack", + "build": "rm -rf dist && npm run build:cjs && npm run build:esm", + "build:cjs": "webpack --config webpack.cjs.config.js", + "build:esm": "webpack --config webpack.esm.config.js", "build:test": "npm run build && npm run test", "cover": "open coverage/lcov-report/index.html", "eslint": "eslint src --ext .js", @@ -29,14 +31,13 @@ "test": "cross-env NODE_ENV=test npm run test:build && jasmine-browser-runner runSpecs --config=test/support/jasmine-browser.json --browser=headlessChrome" }, "main": "./dist/main.js", + "module": "./dist/main.esm.js", "files": [ "dist/**/*", "src/", - "index.js", - "src/typedefs.js" + "index.ts" ], "types": "./dist/types/index.d.ts", - "module": "./index.js", "author": "", "license": "MIT", "engines": { @@ -46,6 +47,8 @@ "@babel/cli": "^7.21.0", "@babel/core": "^7.4.5", "@babel/preset-env": "^7.21.4", + "@babel/preset-typescript": "^7.26.0", + "@types/jasmine": "^5.1.5", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", "babel-loader": "^8.0.6", @@ -62,6 +65,7 @@ "ts-loader": "^9.5.1", "typescript": "^5.5.4", "webpack": "^5.77.0", - "webpack-cli": "^5.0.1" + "webpack-cli": "^5.0.1", + "webpack-merge": "^6.0.1" } } diff --git a/src/CallingExtensions.js b/src/CallingExtensions.ts similarity index 71% rename from src/CallingExtensions.js rename to src/CallingExtensions.ts index 65b1042b..a6909e7e 100644 --- a/src/CallingExtensions.js +++ b/src/CallingExtensions.ts @@ -1,7 +1,3 @@ -// @ts-check - -"use es6"; - import IFrameManager from "./IFrameManager"; import { messageType, @@ -10,6 +6,22 @@ import { VERSION, messageHandlerNames, } from "./Constants"; +import { + EventHandlers, + OnCallAnswered, + OnCallCompleted, + OnCallEnded, + OnError, + OnIncomingCall, + OnInitialized, + OnMessage, + OnNavigateToRecord, + OnOutgoingCall, + OnPublishToChannel, + OnResize, + OnSetWidgetUrl, + Options, +} from "./types"; const prefix = `[calling-extensions-sdk@${VERSION}]`; @@ -17,10 +29,12 @@ const prefix = `[calling-extensions-sdk@${VERSION}]`; * CallingExtensions allows call providers to communicate with HubSpot. */ class CallingExtensions { + options: Options; + iFrameManager: IFrameManager; /** - * @param {import('./typedefs').Options} options + * @param {Options} options */ - constructor(options) { + constructor(options: Options) { if (!options || !options.eventHandlers) { throw new Error("Invalid options or missing eventHandlers."); } @@ -30,7 +44,7 @@ class CallingExtensions { this.iFrameManager = new IFrameManager({ iFrameOptions: options.iFrameOptions, debugMode: options.debugMode, - onMessageHandler: (/** @type {any} */ event) => + onMessageHandler: (event: any) => // eslint-disable-next-line implicit-arrow-linebreak this.onMessageHandler(event), }); @@ -39,9 +53,9 @@ class CallingExtensions { /** * Send a message indicating that the soft phone is ready for interaction. * - * @param {import('./typedefs').OnInitialized} payload + * @param {OnInitialized} payload */ - initialized(payload) { + initialized(payload: OnInitialized) { this.sendMessage({ type: messageType.INITIALIZED, data: payload, @@ -87,9 +101,9 @@ class CallingExtensions { /** * Event when incoming call is received. * - * @param {import('./typedefs').OnIncomingCall} callInfo + * @param {OnIncomingCall} callInfo */ - incomingCall(callInfo) { + incomingCall(callInfo: OnIncomingCall) { this.sendMessage({ type: messageType.INCOMING_CALL, data: callInfo, @@ -99,9 +113,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that an outgoing call has started. * - * @param {import('./typedefs').OnOutgoingCall} callInfo + * @param {OnOutgoingCall} callInfo */ - outgoingCall(callInfo) { + outgoingCall(callInfo: OnOutgoingCall) { this.sendMessage({ type: messageType.OUTGOING_CALL_STARTED, data: callInfo, @@ -111,9 +125,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that a call is being answered. * - * @param {import('./typedefs').OnCallAnswered} payload + * @param {OnCallAnswered} payload */ - callAnswered(payload) { + callAnswered(payload: OnCallAnswered) { this.sendMessage({ type: messageType.CALL_ANSWERED, data: payload, @@ -123,9 +137,9 @@ class CallingExtensions { /** * Event to navigate to record page. * - * @param {import('./typedefs').OnNavigateToRecord} payload + * @param {OnNavigateToRecord} payload */ - navigateToRecord(payload) { + navigateToRecord(payload: OnNavigateToRecord) { this.sendMessage({ type: messageType.NAVIGATE_TO_RECORD, data: payload, @@ -135,7 +149,7 @@ class CallingExtensions { /** * @param {any} payload */ - callData(payload) { + callData(payload: any) { this.sendMessage({ type: messageType.CALL_DATA, data: payload, @@ -145,9 +159,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that the call has ended. * - * @param {import('./typedefs').OnCallEnded} data + * @param {OnCallEnded} data */ - callEnded(data) { + callEnded(data: OnCallEnded) { this.sendMessage({ type: messageType.CALL_ENDED, data, @@ -157,9 +171,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that the call has completed. * - * @param {import('./typedefs').OnCallCompleted} data + * @param {OnCallCompleted} data */ - callCompleted(data) { + callCompleted(data: OnCallCompleted) { this.sendMessage({ type: messageType.CALL_COMPLETED, data, @@ -168,9 +182,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that the calling app has encountered an error. - * @param {import('./typedefs').OnError} data + * @param {OnError} data */ - sendError(data) { + sendError(data: OnError) { this.sendMessage({ type: messageType.ERROR, data, @@ -180,9 +194,9 @@ class CallingExtensions { /** * Sends a message to notify HubSpot that the calling app needs to be resized. * - * @param {import('./typedefs').OnResize} data + * @param {OnResize} data */ - resizeWidget(data) { + resizeWidget(data: OnResize) { this.sendMessage({ type: messageType.RESIZE_WIDGET, data, @@ -191,9 +205,9 @@ class CallingExtensions { /** * - * @param {import('./typedefs').OnMessage} message + * @param {OnMessage} message */ - sendMessage(message) { + sendMessage(message: OnMessage) { this.iFrameManager.sendMessage(message); } @@ -201,14 +215,20 @@ class CallingExtensions { * * @param {{message: string, type: string}} param0 */ - logDebugMessage({ message, type = debugMessageType.GENERIC_MESSAGE }) { + logDebugMessage({ + message, + type = debugMessageType.GENERIC_MESSAGE, + }: { + message: string; + type: string; + }) { this.iFrameManager.logDebugMessage(prefix, type, message); } /** - * @param {{ type: keyof import('./typedefs').EventHandlers; data: any; }} event + * @param {{ type: keyof EventHandlers; data: any; }} event */ - onMessageHandler(event) { + onMessageHandler(event: { type: keyof EventHandlers; data: any }) { const { type, data } = event; const { eventHandlers } = this.options; @@ -235,8 +255,11 @@ class CallingExtensions { const isFailedEvent = String(type).endsWith("_FAILED"); if (isFailedEvent) { - const failedHandler = eventHandlers[messageType.FAILED]; - failedHandler(data, event); + const failedHandler = + eventHandlers[messageType.FAILED as keyof EventHandlers]; + if (failedHandler) { + failedHandler(data, event); + } } handler = handler || eventHandlers.defaultEventHandler; @@ -252,9 +275,9 @@ class CallingExtensions { /** * Publishes the call to a connected channel. * - * @param {import('./typedefs').OnPublishToChannel} data - The data object to be published. + * @param {OnPublishToChannel} data - The data object to be published. */ - publishToChannel(data) { + publishToChannel(data: OnPublishToChannel) { this.sendMessage({ type: messageType.PUBLISH_TO_CHANNEL, data, @@ -264,9 +287,9 @@ class CallingExtensions { /** * Sends a message to update the widget url. * - * @param {import('./typedefs').OnSetWidgetUrl} data - The data object to be published. + * @param {OnSetWidgetUrl} data - The data object to be published. */ - setWidgetUrl(data) { + setWidgetUrl(data: OnSetWidgetUrl) { this.sendMessage({ type: messageType.SET_WIDGET_URL, data, diff --git a/src/Constants.js b/src/Constants.ts similarity index 97% rename from src/Constants.js rename to src/Constants.ts index 5e22d32e..51e38e7d 100644 --- a/src/Constants.js +++ b/src/Constants.ts @@ -1,6 +1,5 @@ -"use es6"; - import packageJson from "../package.json"; +import { EventHandlers } from "./types"; export const VERSION = packageJson.version; @@ -62,10 +61,7 @@ export const messageType = { FAILED: "FAILED", }; -/** - * @type {{ [key: string]: keyof import('./typedefs').EventHandlers }} - */ -export const messageHandlerNames = { +export const messageHandlerNames: Record = { [messageType.CALLER_ID_MATCH_FAILED]: "onCallerIdMatchFailed", [messageType.CALLER_ID_MATCH_SUCCEEDED]: "onCallerIdMatchSucceeded", [messageType.CREATE_ENGAGEMENT_FAILED]: "onCreateEngagementFailed", diff --git a/src/IFrameManager.js b/src/IFrameManager.ts similarity index 84% rename from src/IFrameManager.js rename to src/IFrameManager.ts index 40429b9a..ee5684e9 100644 --- a/src/IFrameManager.js +++ b/src/IFrameManager.ts @@ -1,22 +1,29 @@ -// @ts-check - -"use es6"; - import { messageType, debugMessageType, VERSION } from "./Constants"; +import { IframeManagerOptions, IframeOptions, SizeInfo } from "./types"; const prefix = `[calling-extensions-sdk@${VERSION}]`; + /* * IFrameManager abstracts the iFrame communication between the IFrameHost and an IFrame * An IFrameManager instance can act as part of the IFrameHost and an IFrame depending on * the options. */ class IFrameManager { - /** - * - * @param {import('./typedefs').IframeManagerOptions} options - */ - constructor(options) { - /** @type {import('./typedefs').IframeManagerOptions | null} */ + options: IframeManagerOptions | null; + onMessageHandler: IframeManagerOptions["onMessageHandler"]; + isIFrameHost: boolean; + debugMode: boolean; + callbacks: { [key: string]: Function }; + instanceId: number; + instanceRegexp: RegExp; + isReady: boolean; + messageHandler: (event: any) => void; + iFrame: HTMLIFrameElement | null; + firstSyncSent: number = 0; + destinationWindow: Window | null; + destinationHost: string; + + constructor(options: IframeManagerOptions) { this.options = options; const { iFrameOptions, onMessageHandler, debugMode } = options; @@ -28,18 +35,16 @@ class IFrameManager { this.debugMode = debugMode; // Keeps track of all the callbacks - /** @type {{ [key: string]: Function }} */ this.callbacks = {}; this.instanceId = Date.now(); this.instanceRegexp = new RegExp(`^${this.instanceId}`); this.isReady = false; - this.messageHandler = (/** @type {any} */ event) => this.onMessage(event); + this.messageHandler = event => this.onMessage(event); window.addEventListener("message", this.messageHandler); if (iFrameOptions) { - /** @type {HTMLIFrameElement | null} */ this.iFrame = IFrameManager.createIFrame( iFrameOptions, () => { @@ -50,7 +55,6 @@ class IFrameManager { this.handleLoadError, ); } else { - /** @type {HTMLIFrameElement | null} */ this.iFrame = null; } @@ -65,7 +69,7 @@ class IFrameManager { * @param {string|number} instanceId * @returns {string} */ - static createMessageId(instanceId) { + static createMessageId(instanceId: string | number) { return `${instanceId}_${Date.now()}`; } @@ -73,7 +77,7 @@ class IFrameManager { * Gets the html element that hosts the iFrame * @param {string} hostElementSelector */ - static getHostElement(hostElementSelector) { + static getHostElement(hostElementSelector: string) { const hostElement = document.querySelector(hostElementSelector); if (!hostElement) { throw new Error( @@ -86,7 +90,7 @@ class IFrameManager { /** * @param {string} url */ - static extractHostFromUrl(url) { + static extractHostFromUrl(url: string) { const a = document.createElement("a"); a.href = url; return `${a.protocol}//${a.host}`; @@ -94,9 +98,9 @@ class IFrameManager { /** * - * @param {import('./typedefs').IframeOptions} [iFrameOptions] + * @param {IframeOptions} [iFrameOptions] */ - static getDestinationHost(iFrameOptions) { + static getDestinationHost(iFrameOptions: IframeOptions | undefined) { const url = iFrameOptions ? iFrameOptions.src : document.referrer; return IFrameManager.extractHostFromUrl(url); } @@ -108,12 +112,16 @@ class IFrameManager { } /** - * @param {import('./typedefs').IframeOptions} iFrameOptions + * @param {IframeOptions} iFrameOptions * @param { (this: GlobalEventHandlers, ev: Event) => any } onLoadCallback * @param { OnErrorEventHandler } onLoadErrorCallback * @returns {HTMLIFrameElement | null} */ - static createIFrame(iFrameOptions, onLoadCallback, onLoadErrorCallback) { + static createIFrame( + iFrameOptions: IframeOptions, + onLoadCallback: (event: Event) => void, + onLoadErrorCallback: OnErrorEventHandler, + ) { // eslint-disable-next-line object-curly-newline const { src, width, height, hostElementSelector } = iFrameOptions; @@ -123,8 +131,7 @@ class IFrameManager { ); } - /** @type {HTMLIFrameElement} */ - const iFrame = document.createElement("iframe"); + const iFrame: HTMLIFrameElement = document.createElement("iframe"); iFrame.onload = onLoadCallback; iFrame.onerror = onLoadErrorCallback; iFrame.src = src; @@ -141,9 +148,9 @@ class IFrameManager { } /** - * @param {import('./typedefs').SizeInfo} sizeInfo + * @param {SizeInfo} sizeInfo */ - updateIFrameSize(sizeInfo) { + updateIFrameSize(sizeInfo: SizeInfo) { const { width, height } = sizeInfo; if (this.iFrame) { if (width) { @@ -160,7 +167,7 @@ class IFrameManager { * @param {number | string} size * @returns {string} */ - static formatSize(size) { + static formatSize(size: number | string) { return typeof size === "number" ? `${size}px` : size; } @@ -195,7 +202,10 @@ class IFrameManager { * @param {{type: string, messageId?: string|number, hostUrl?: string}} message * @param {function} [callback] */ - sendMessage(message, callback) { + sendMessage( + message: { type: string; messageId?: string | number; hostUrl?: string }, + callback?: Function, + ) { const { type } = message; if (type !== messageType.SYNC && !this.isReady) { // Do not send a message unless the iFrame is ready to receive. @@ -230,7 +240,7 @@ class IFrameManager { /** * @param {{ data: any; origin?: any; }} event */ - onMessage(event) { + onMessage(event: { data: any; origin?: any }) { const { data, origin } = event; // eslint-disable-next-line object-curly-newline const { type } = event.data; @@ -315,7 +325,7 @@ class IFrameManager { type: messageType.SYNC, hostUrl: IFrameManager.extractHostFromUrl(window.location.href), }, - (/** @type {{ debugMode?: any; iFrameUrl?: any; }} */ eventData) => { + (eventData: { debugMode?: any; iFrameUrl?: any }) => { const { iFrameUrl } = eventData; this.destinationHost = iFrameUrl || this.destinationHost; this.onReady(); @@ -335,7 +345,7 @@ class IFrameManager { /** * @param {any[]} args */ - logDebugMessage(...args) { + logDebugMessage(...args: any[]) { if (this.debugMode) { console.log.call(null, args); return; diff --git a/src/typedefs.js b/src/typedefs.js deleted file mode 100644 index 7febbcd4..00000000 --- a/src/typedefs.js +++ /dev/null @@ -1,185 +0,0 @@ -/* eslint-disable max-len */ -// typedefs.js -/** - * @namespace typedefs - */ - -/** - * @typedef {Object.} EventHandlers - * @property {function} onCallerIdMatchFailed - Called when the caller ID match fails. - * @property {function} onCallerIdMatchSucceeded - Called when the caller ID match succeeds. - * @property {function} onCreateEngagementFailed - Called when creating an engagement fails. - * @property {function} onCreateEngagementSucceeded - Called when creating an engagement succeeds. - * @property {function} onDialNumber - Called when the HubSpot sends a dial number from the contact. - * @property {function} onEndCall - Called when the call ends. - * @property {function} onEngagementCreated - Called when HubSpot creates an engagement for the call. - * @property {function} onInitiateCallIdFailed - Called when initiating a call ID fails. - * @property {function} onInitiateCallIdSucceeded - Called when initiating a call ID succeeds. - * @property {function} onNavigateToRecordFailed - Called when navigating to a record fails. - * @property {function} onUpdateAssociationsFailed - Called when updating associations for a record fails. - * @property {function} onPublishToChannelFailed - Called when publishing to a channel fails. - * @property {function} onPublishToChannelSucceeded - Called when publishing to a channel succeeds. - * @property {function} onReady - Called when HubSpot is ready to receive messages. - * @property {function} onSetCallState - Called when the call state changes. - * @property {function} onSetWidgetUrlFailed - Called when HubSpot was unable to change the widget iframe src URL. - * @property {function} onUpdateEngagementFailed - Called when updating an engagement fails. - * @property {function} onUpdateEngagementSucceeded - Called when updating an engagement succeeds. - * @property {function} onVisibilityChanged - Called when the call widget's visibility changes. - * @property {function} onFailed - Called when any of the failed events occurs. - * @property {function} [defaultEventHandler] - Default event handler to handle unhandled events. - */ - -/** - * @typedef {Object} IframeOptions - * @property {string} src - iframe URL - * @property {string} height - Height of iframe - * @property {string} width - Width of iframe - * @property {string} hostElementSelector - Selector for host element where iframe will be bound - */ - -/** - * @typedef {Object} Options - * @property {IframeOptions} [iFrameOptions] - iFrame configuration options - * @property {boolean} debugMode - Whether to log various inbound/outbound debug messages - * to the console. - * @property {EventHandlers} eventHandlers - Event handlers handle inbound messages. - */ - -/** - * @typedef {Object} IframeManagerOptions - * @property {IframeOptions} [iFrameOptions] - iFrame configuration options - * @property {boolean} debugMode - Whether to log various inbound/outbound debug messages - * to the console. - * @property {function} onMessageHandler - Callback function to handle inbound messages. - */ - -/** - * @typedef {Object} OnResize - * @property {number} width - * @property {number} height - */ - -/** - * @typedef {OnResize} SizeInfo - */ - -/** - * @typedef {Object} OnInitialized - * @property {boolean} [isLoggedIn] - * @property {number} [engagementId] - */ - -/** - * @typedef {Object} OnIncomingCall - * @property {string} externalCallId - * @property {number} [callStartTime] - * @property {boolean} [createEngagement] - * @property {string} fromNumber - * @property {string} toNumber - */ - -/** - * @typedef {Object} OnOutgoingCall - * @property {string} externalCallId - * @property {number} [callStartTime] - * @property {boolean} [createEngagement] - * @property {string} [fromNumber] - * @property {string} [toNumber] - */ - -/** - * @typedef {Object} OnCallAnswered - * @property {string} externalCallId - */ - -/** - * @typedef {Object} OnPublishToChannel - * @property {string} externalCallId - * @property {number} engagementId - */ - -/** - * @typedef {Object} OnSetWidgetUrl - * @property {string} iFrameUrl - */ - -/** - * @typedef {'COMPLETED'|'FAILED'|'CANCELED'|'BUSY'|'NO_ANSWER'|'REJECTED'|'MISSED'} EndStatus - */ - -/** - * @typedef {Object} OnCallEnded - * @property {string} externalCallId - * @property {number} engagementId - * @property {EndStatus} [callEndStatus] - */ - -/** - * @typedef {Object} RawEngagementProperties - * @property {number|string} hs_timestamp - This field marks the call's time of creation and determines where the call sits on the record timeline. - * @property {string} [hs_call_body] - The description of the call, including any notes that you want to add. - * @property {string} [hs_call_callee_object_id] - The ID of the HubSpot record associated with the call. This will be the recipient of the call for OUTBOUND calls, or the dialer of the call for INBOUND calls. - * @property {string} [hs_call_callee_object_type] - The type of the object to which the call's associated record belongs (e.g., specifies if the record is a contact or company). This will be the object of the recipient for OUTBOUNDcalls, or the object of the dialer for INBOUND calls. - * @property {string} [hs_call_direction] - The direction of the call from the perspective of the HubSpot user. If the user is the call recipient, the direction should be set to INBOUND. If the user initiated the call, the direction should be set to OUTBOUND. - * @property {string} [hs_call_disposition] - * @property {string} [hs_call_duration] - The duration of the call in milliseconds. - * @property {string} [hs_call_from_number] - The phone number that the call was made from. - * @property {string} [hs_call_recording_url] - The URL that stores the call recording. URLS to .mp3 or .wav files can be played back on CRM records. Only HTTPS, secure URLs will be accepted. - * @property {string} [hs_call_status] - The status of the call. The statuses are BUSY, CALLING_CRM_USER, CANCELED, COMPLETED, CONNECTING, FAILED, IN_PROGRESS, NO_ANSWER, QUEUED, and RINGING. - * @property {string} [hs_call_title] - The title of the call. - * @property {string} [hs_call_source] - The source of the call. This is not required, but it is required to leverage the recording and transcriptions pipeline. If the property is set, it must be set to INTEGRATIONS_PLATFORM. - * @property {string} [hs_call_to_number] - The phone number that received the call. - * @property {string} [hubspot_owner_id] - The ID of the owner associated with the call. This field determines the user listed as the call creator on the record timeline. - * @property {string} [hs_activity_type] - The type of call. The options are based on the call types set in your HubSpot account. - * @property {string} [hs_attachment_ids] - The IDs of the call's attachments. Multiple attachment IDs are separated by a semi-colon. - */ - -/** - * @typedef {Object} OnCallCompleted - * @property {string} externalCallId - * @property {number|string} [engagementId] - * @property {boolean} [hideWidget] - * @property {RawEngagementProperties} [engagementProperties] - */ - -/** - * @typedef {Object} ObjectCoordinates - * @property {number} portalId - * @property {number} objectId - * @property {"0-1"|"0-2"} objectTypeId - */ - -/** - * @typedef {Object} OnNavigateToRecord - * @property {number} [engagementId] - * @property {ObjectCoordinates} objectCoordinates - */ - -/** - * @typedef {Object} OnError - * @property {string} message - */ - -/** - * @typedef {Object} OnMessage - * @property {string} type - * @property {Object} [data] - */ - -/** - * @typedef {Object} ContactIdMatch - * @property {"CONTACT"} callerIdType - * @property {ObjectCoordinates} objectCoordinates - * @property {string} firstName - * @property {string} lastName - * @property {string} email - */ - -/** - * @typedef {Object} CompanyIdMatch - * @property {"COMPANY"} callerIdType - * @property {ObjectCoordinates} objectCoordinates - * @property {string} name - */ - -export {}; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 00000000..be9d74c9 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,158 @@ +export type EventHandlers = { + onCallerIdMatchFailed: Function; + onCallerIdMatchSucceeded: Function; + onCreateEngagementFailed: Function; + onCreateEngagementSucceeded: Function; + onDialNumber: Function; + onEndCall: Function; + onEngagementCreated: Function; + onInitiateCallIdFailed: Function; + onInitiateCallIdSucceeded: Function; + onNavigateToRecordFailed: Function; + onUpdateAssociationsFailed: Function; + onPublishToChannelFailed: Function; + onPublishToChannelSucceeded: Function; + onReady: Function; + onSetCallState: Function; + onSetWidgetUrlFailed: Function; + onUpdateEngagementFailed: Function; + onUpdateEngagementSucceeded: Function; + onVisibilityChanged: Function; + onFailed: Function; + defaultEventHandler?: Function; +}; + +export type IframeOptions = { + src: string; + height: string; + width: string; + hostElementSelector: string; +}; + +export type Options = { + iFrameOptions?: IframeOptions; + debugMode: boolean; + eventHandlers: EventHandlers; +}; + +export type IframeManagerOptions = { + iFrameOptions?: IframeOptions; + debugMode: boolean; + onMessageHandler: Function; +}; + +export type OnResize = { + width: number; + height: number; +}; + +export type SizeInfo = OnResize; + +export type OnInitialized = { + isLoggedIn?: boolean; + engagementId?: number; +}; + +export type OnIncomingCall = { + externalCallId: string; + fromNumber: string; + toNumber: string; + callStartTime?: number; + createEngagement?: boolean; +}; + +export type OnOutgoingCall = { + externalCallId: string; + fromNumber?: string; + toNumber?: string; + callStartTime?: number; + createEngagement?: boolean; +}; + +export type OnCallAnswered = { + externalCallId: string; +}; + +export type OnPublishToChannel = { + externalCallId: string; + engagementId: number; +}; + +export type OnSetWidgetUrl = { + iFrameUrl: string; +}; + +export type EndStatus = + | "COMPLETED" + | "FAILED" + | "CANCELED" + | "BUSY" + | "NO_ANSWER" + | "REJECTED" + | "MISSED"; + +export type OnCallEnded = { + externalCallId: string; + engagementId: number; + callEndStatus?: EndStatus; +}; + +export type RawEngagementProperties = { + hs_timestamp: number | string; // This field marks the call's time of creation and determines where the call sits on the record timeline. + hs_call_body?: string; // The description of the call, including any notes that you want to add. + hs_call_callee_object_id?: string; // The ID of the HubSpot record associated with the call. This will be the recipient of the call for OUTBOUND calls, or the dialer of the call for INBOUND calls. + hs_call_callee_object_type?: string; // The type of the object to which the call's associated record belongs (e.g., specifies if the record is a contact or company). This will be the object of the recipient for OUTBOUNDcalls, or the object of the dialer for INBOUND calls. + hs_call_direction?: string; // The direction of the call from the perspective of the HubSpot user. If the user is the call recipient, the direction should be set to INBOUND. If the user initiated the call, the direction should be set to OUTBOUND. + hs_call_disposition?: string; + hs_call_duration?: string; // The duration of the call in milliseconds. + hs_call_from_number?: string; // The phone number that the call was made from. + hs_call_recording_url?: string; // The URL that stores the call recording. URLS to .mp3 or .wav files can be played back on CRM records. Only HTTPS, secure URLs will be accepted. + hs_call_status?: string; // The status of the call. The statuses are BUSY, CALLING_CRM_USER, CANCELED, COMPLETED, CONNECTING, FAILED, IN_PROGRESS, NO_ANSWER, QUEUED, and RINGING. + hs_call_title?: string; // The title of the call. + hs_call_source?: string; // The source of the call. This is not required, but it is required to leverage the recording and transcriptions pipeline. If the property is set, it must be set to INTEGRATIONS_PLATFORM. + hs_call_to_number?: string; // The phone number that received the call. + hubspot_owner_id?: string; // The ID of the owner associated with the call. This field determines the user listed as the call creator on the record timeline. + hs_activity_type?: string; // The type of call. The options are based on the call types set in your HubSpot account. + hs_attachment_ids?: string; // The IDs of the call's attachments. Multiple attachment IDs are separated by a semi-colon. +}; + +export type OnCallCompleted = { + externalCallId: string; + engagementId?: number | string; + hideWidget?: boolean; + engagementProperties?: RawEngagementProperties; +}; + +export type ObjectCoordinates = { + portalId: number; + objectId: number; + objectTypeId: "0-1" | "0-2"; +}; + +export type OnNavigateToRecord = { + engagementId?: number; + objectCoordinates: ObjectCoordinates; +}; + +export type OnError = { + message: string; +}; + +export type OnMessage = { + type: string; + data?: Object; +}; + +export type ContactIdMatch = { + callerIdType: "CONTACT"; + objectCoordinates: ObjectCoordinates; + firstName: string; + lastName: string; + email: string; +}; + +export type CompanyIdMatch = { + callerIdType: "COMPANY"; + objectCoordinates: ObjectCoordinates; + name: string; +}; diff --git a/test/spec/CallingExtensions-test.js b/test/spec/CallingExtensions-test.ts similarity index 67% rename from test/spec/CallingExtensions-test.js rename to test/spec/CallingExtensions-test.ts index 4a99d283..281f494a 100644 --- a/test/spec/CallingExtensions-test.js +++ b/test/spec/CallingExtensions-test.ts @@ -1,13 +1,41 @@ -"use es6"; - import CallingExtensions from "../../src/CallingExtensions"; import { messageType } from "../../src/Constants"; +import { + OnCallCompleted, + OnIncomingCall, + OnInitialized, + OnOutgoingCall, +} from "../../src/types"; + +const noop = () => {}; describe("CallingExtensions", () => { - let instance; + let instance: CallingExtensions; beforeEach(() => { instance = new CallingExtensions({ - eventHandlers: {}, + debugMode: false, + eventHandlers: { + onCallerIdMatchFailed: noop, + onCallerIdMatchSucceeded: noop, + onCreateEngagementFailed: noop, + onCreateEngagementSucceeded: noop, + onDialNumber: noop, + onEndCall: noop, + onEngagementCreated: noop, + onInitiateCallIdFailed: noop, + onInitiateCallIdSucceeded: noop, + onNavigateToRecordFailed: noop, + onUpdateAssociationsFailed: noop, + onPublishToChannelFailed: noop, + onPublishToChannelSucceeded: noop, + onReady: noop, + onSetCallState: noop, + onSetWidgetUrlFailed: noop, + onUpdateEngagementFailed: noop, + onUpdateEngagementSucceeded: noop, + onVisibilityChanged: noop, + onFailed: noop, + }, }); }); it("should instantiate", () => { @@ -48,8 +76,10 @@ describe("CallingExtensions", () => { }); it("should handle incoming call.", () => { - const callData = { - phoneNumber: 1234, + const callData: OnIncomingCall = { + fromNumber: "+1234567890", + externalCallId: "fake-id", + toNumber: "+0987654321", }; instance.incomingCall(callData); expect(instance.sendMessage).toHaveBeenCalledWith({ @@ -59,8 +89,8 @@ describe("CallingExtensions", () => { }); it("should handle initialize.", () => { - const data = { - phoneNumber: 1234, + const data: OnInitialized = { + isLoggedIn: true, }; instance.initialized(data); expect(instance.sendMessage).toHaveBeenCalledWith({ @@ -70,8 +100,9 @@ describe("CallingExtensions", () => { }); it("should handle outgoing call.", () => { - const data = { + const data: OnOutgoingCall = { createEngagement: true, + externalCallId: "fake-id", }; instance.outgoingCall(data); expect(instance.sendMessage).toHaveBeenCalledWith({ @@ -81,8 +112,9 @@ describe("CallingExtensions", () => { }); it("should handle call completed.", () => { - const data = { + const data: OnCallCompleted = { engagementId: 123, + externalCallId: "fake-id", }; instance.callCompleted(data); expect(instance.sendMessage).toHaveBeenCalledWith({ diff --git a/test/spec/IFrameManager-test.js b/test/spec/IFrameManager-test.ts similarity index 75% rename from test/spec/IFrameManager-test.js rename to test/spec/IFrameManager-test.ts index 3aa0ce04..9ff270c3 100644 --- a/test/spec/IFrameManager-test.js +++ b/test/spec/IFrameManager-test.ts @@ -1,11 +1,10 @@ -"use es6"; - import IFrameManager from "../../src/IFrameManager"; import { VERSION, messageType } from "../../src/Constants"; describe("iFrameManager", () => { const defaultOptions = { onMessageHandler: () => {}, + debugMode: false, }; function createInstance(options = {}) { @@ -39,23 +38,37 @@ describe("iFrameManager", () => { }; instance.onMessage(eventData); - expect(instance.sendMessage).toHaveBeenCalledWith({ - type: messageType.SYNC_ACK, - debugMode: undefined, - version: VERSION, - iFrameUrl: IFrameManager.extractHostFromUrl(window.location.href), - }); + expect(instance.sendMessage).toHaveBeenCalledWith( + jasmine.objectContaining({ + type: messageType.SYNC_ACK, + debugMode: false, + version: VERSION, + iFrameUrl: IFrameManager.extractHostFromUrl(window.location.href), + }), + ); }); }); describe("as iFrame host", () => { it("should validate iFrameOptions", () => { - expect(() => new IFrameManager({ iFrameOptions: {} })).toThrow(); + expect( + () => + new IFrameManager({ + iFrameOptions: { + src: "", + height: "", + width: "", + hostElementSelector: "", + }, + debugMode: false, + onMessageHandler: () => {}, + }), + ).toThrow(); }); it("should get host element", () => { expect(IFrameManager.getHostElement("body")).toBe( - document.querySelector("body"), + document.querySelector("body")!, ); }); @@ -71,7 +84,7 @@ describe("iFrameManager", () => { it("should get origin", done => { spyOn(IFrameManager, "createIFrame").and.returnValue({ contentWindow: null, - }); + } as HTMLIFrameElement); const instance = createInstance(options); expect(instance).toBeDefined(); @@ -83,7 +96,7 @@ describe("iFrameManager", () => { const createIFrameSpy = spyOn( IFrameManager, "createIFrame", - ).and.returnValue({ contentWindow: null }); + ).and.returnValue({ contentWindow: null } as HTMLIFrameElement); const instance = createInstance(options); expect(instance).toBeDefined(); diff --git a/test/support/jasmine-browser.json b/test/support/jasmine-browser.json index 5839b114..f3354813 100644 --- a/test/support/jasmine-browser.json +++ b/test/support/jasmine-browser.json @@ -2,9 +2,7 @@ "srcDir": "src", "srcFiles": [], "specDir": "dist-test", - "specFiles": [ - "test.js" - ], + "specFiles": ["test.js"], "helpers": [], "env": { "random": true diff --git a/tsconfig.json b/tsconfig.json index 801ad1a8..da09f254 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,17 @@ { "compilerOptions": { - "target": "es5", - "module": "commonjs", + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "node", "declaration": true, "declarationDir": "./dist/types", "outDir": "./dist", "strict": true, - "allowJs": true, - "checkJs": true, "resolveJsonModule": true, - "esModuleInterop": true + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true }, - "include": ["src/**/*", "src/typedefs.js"], + "include": ["src/**/*"], "exclude": ["node_modules"] } diff --git a/webpack-test.config.js b/webpack-test.config.js index 32603893..58ab6fea 100644 --- a/webpack-test.config.js +++ b/webpack-test.config.js @@ -2,7 +2,7 @@ const path = require("path"); const glob = require("glob"); module.exports = { - entry: glob.sync("./test/spec/**/*-test.js"), + entry: glob.sync("./test/spec/**/*-test.ts"), resolve: { extensions: [".tsx", ".ts", ".js"], }, @@ -13,15 +13,10 @@ module.exports = { module: { rules: [ { - test: /\.(ts|tsx|js)$/, + test: /\.(ts|tsx)$/, exclude: /node_modules/, use: { - loader: "babel-loader", - options: { - presets: [ - "@babel/preset-env", - ], - }, + loader: "ts-loader", }, }, ], diff --git a/webpack.cjs.config.js b/webpack.cjs.config.js new file mode 100644 index 00000000..b95fa585 --- /dev/null +++ b/webpack.cjs.config.js @@ -0,0 +1,14 @@ +const path = require("path"); +const { merge } = require("webpack-merge"); +const common = require("./webpack.common"); + +module.exports = merge(common, { + mode: "production", + output: { + filename: "main.js", + library: { + type: "commonjs2", + }, + path: path.resolve(__dirname, "dist"), + }, +}); diff --git a/webpack.common.js b/webpack.common.js new file mode 100644 index 00000000..c42eafcd --- /dev/null +++ b/webpack.common.js @@ -0,0 +1,17 @@ +module.exports = { + entry: "./index.ts", + resolve: { + extensions: [".ts", ".tsx", ".js"], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + exclude: /node_modules/, + use: { + loader: "ts-loader", + }, + }, + ], + }, +}; diff --git a/webpack.config.js b/webpack.config.js index ea27618e..74c6aad3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,29 +1,26 @@ const path = require("path"); -const babelLoader = { - test: /\.js$/, - exclude: /(node_modules)/, - use: { - loader: "babel-loader", - options: { - presets: ["@babel/preset-env"], - }, - }, -}; +// const babelLoader = { +// test: /\.(js|ts)$/, +// exclude: /(node_modules)/, +// use: { +// loader: "babel-loader", +// options: { +// presets: ["@babel/preset-env", "@babel/preset-typescript"], +// }, +// }, +// }; const tsLoader = { - test: /\.js$/, + test: /\.ts$/, exclude: /(node_modules)/, use: { loader: "ts-loader", - options: { - allowTsInNodeModules: true, - }, }, }; module.exports = { - entry: "./index.js", + entry: "./index.ts", mode: "production", output: { filename: "main.js", @@ -32,9 +29,9 @@ module.exports = { clean: true, }, resolve: { - extensions: [".ts", ".js"], + extensions: [".ts", ".tsx", ".js"], }, module: { - rules: [babelLoader, tsLoader], + rules: [tsLoader], }, }; diff --git a/webpack.esm.config.js b/webpack.esm.config.js new file mode 100644 index 00000000..ca6e54f6 --- /dev/null +++ b/webpack.esm.config.js @@ -0,0 +1,17 @@ +const path = require("path"); +const { merge } = require("webpack-merge"); +const common = require("./webpack.common"); + +module.exports = merge(common, { + mode: "production", + output: { + filename: "main.esm.js", + library: { + type: "module", + }, + path: path.resolve(__dirname, "dist"), + }, + experiments: { + outputModule: true, + }, +});