From bee6f84743bc6c9b3859cee38de487eba922e575 Mon Sep 17 00:00:00 2001 From: Lawrence Ephrim Date: Tue, 19 Mar 2024 07:14:01 +0000 Subject: [PATCH] feat: add helper field/method to retrieve msisdn of the current session --- package-lock.json | 73 +++++++++++++++++++++-------------- package.json | 19 +++++---- src/gateways/wigal.gateway.ts | 1 + src/menus/base.menu.ts | 7 ++++ src/types/request.ts | 2 + 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8d2563..b469a98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,23 @@ { "name": "ananse", - "version": "1.2.3", + "version": "1.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ananse", - "version": "1.2.3", + "version": "1.5.0", "license": "ISC", + "dependencies": { + "arg": "^5.0.2" + }, "bin": { - "ananse.simulator": "dist/cli/simulator.js" + "simulator": "dist/cli/simulator.js" }, "devDependencies": { - "@japa/api-client": "^2.0.0-1", - "@japa/assert": "2.0.0-2", - "@japa/runner": "3.0.0-9", + "@japa/api-client": "^2.0.2", + "@japa/assert": "2.1.0", + "@japa/runner": "3.1.1", "@types/express": "^4.17.21", "@types/node": "^20.4.5", "@typescript-eslint/eslint-plugin": "^6.19.0", @@ -759,32 +762,32 @@ } }, "node_modules/@japa/assert": { - "version": "2.0.0-2", - "resolved": "https://registry.npmjs.org/@japa/assert/-/assert-2.0.0-2.tgz", - "integrity": "sha512-RefTQOvSA6TR92j2ToaSwxzzZrX3dyxadEl6a1YunEr58xCD0ViLG4cKZz8KUCSvj6vqirKrFw9hqOkcKrskAA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@japa/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-klSa1nO6VFYJqW9oSeMRZQpTSw01+yZpBDoHNuUse7SqbScau9SvNIvBEYxbdDB2bj9hTXxt/z6cwVWf1UltZg==", "dev": true, "dependencies": { - "@poppinss/macroable": "^1.0.0-8", - "@types/chai": "^4.3.6", + "@poppinss/macroable": "^1.0.1", + "@types/chai": "^4.3.11", "api-contract-validator": "^2.2.8", - "chai": "^4.3.8" + "chai": "^4.3.10" }, "engines": { "node": ">=18.16.0" }, "peerDependencies": { - "@japa/runner": "^3.0.0-8" + "@japa/runner": "^3.0.0" } }, "node_modules/@japa/core": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/@japa/core/-/core-8.1.2.tgz", - "integrity": "sha512-Eae5c5/QLcgaAB63Mo/SlHvXGP1dlG3yx3mq++EEbMfpdX5j4LKFfGlTxo81KdrIMU/3kq0OwGKGtgcBxjimwQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@japa/core/-/core-9.0.0.tgz", + "integrity": "sha512-BQiS8rd1qiSkz+uTsx+Bfsp+FVeoKpJXMtUse4XDt2cUfDdCnvYkvRnqmR/F/u8ttt71sZ4mHKizGa1Q5MG3DQ==", "dev": true, "dependencies": { - "@poppinss/cliui": "^6.2.1", - "@poppinss/hooks": "^7.2.1", - "@poppinss/macroable": "^1.0.0", + "@poppinss/cliui": "^6.2.2", + "@poppinss/hooks": "^7.2.2", + "@poppinss/macroable": "^1.0.1", "async-retry": "^1.3.3", "emittery": "^1.0.1", "string-width": "^7.0.0", @@ -810,20 +813,20 @@ } }, "node_modules/@japa/runner": { - "version": "3.0.0-9", - "resolved": "https://registry.npmjs.org/@japa/runner/-/runner-3.0.0-9.tgz", - "integrity": "sha512-l8nGNd+K4EdX4lrYtj2v+2KecshgDlsnimIYpWKFEY8uCSHeQci7gwKaVb6Xs1J6EOClnn/dchHuYVCjNrkLdw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@japa/runner/-/runner-3.1.1.tgz", + "integrity": "sha512-DWy16uw2naDMitXGNN0ULURLaVIQY/VBVtxw7rpdA8QL1Q2nCaaqJXufHqS8kO1ZRd0bOtFHMgx2/eYvxkmapA==", "dev": true, "dependencies": { - "@japa/core": "^8.0.0-11", - "@japa/errors-printer": "^3.0.0-6", - "@poppinss/colors": "^4.1.0-4", - "@poppinss/hooks": "^7.1.1-5", - "fast-glob": "^3.3.1", + "@japa/core": "^9.0.0", + "@japa/errors-printer": "^3.0.2", + "@poppinss/colors": "^4.1.2", + "@poppinss/hooks": "^7.2.2", + "fast-glob": "^3.3.2", "find-cache-dir": "^5.0.0", "getopts": "^2.3.0", "ms": "^2.1.3", - "serialize-error": "^11.0.0", + "serialize-error": "^11.0.3", "slash": "^5.1.0" }, "engines": { @@ -1839,6 +1842,11 @@ "node": ">=8" } }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -4860,12 +4868,19 @@ "swagger-schema-official": "2.0.0-bab6bed" } }, - "node_modules/openapi-types": { + "node_modules/openapi-schema-validator/node_modules/openapi-types": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-1.3.4.tgz", "integrity": "sha512-h8rADpW3k/wepLdERKF0VKMAPdoFYNQCLGPmc/f8sgQ2dxUy+7sY4WAX2XDUDjhKTjbJVbxxofLkzy7f1/tE4g==", "dev": true }, + "node_modules/openapi-types": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", + "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==", + "dev": true, + "peer": true + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", diff --git a/package.json b/package.json index 2dc27ed..a68a11a 100644 --- a/package.json +++ b/package.json @@ -45,21 +45,24 @@ "redis": "^4.6.11" }, "devDependencies": { - "@japa/api-client": "^2.0.0-1", - "@japa/assert": "2.0.0-2", - "@japa/runner": "3.0.0-9", + "@japa/api-client": "^2.0.2", + "@japa/assert": "2.1.0", + "@japa/runner": "3.1.1", "@types/express": "^4.17.21", "@types/node": "^20.4.5", - "tsup": "^8.0.1", - "tsx": "^4.2.0", - "typescript": "^4.8.4", - "rimraf": "^5.0.1", "@typescript-eslint/eslint-plugin": "^6.19.0", "@typescript-eslint/parser": "^6.19.0", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.0", "eslint-plugin-unused-imports": "^3.0.0", - "prettier-eslint": "^16.3.0" + "prettier-eslint": "^16.3.0", + "rimraf": "^5.0.1", + "tsup": "^8.0.1", + "tsx": "^4.2.0", + "typescript": "^4.8.4" + }, + "dependencies": { + "arg": "^5.0.2" } } diff --git a/src/gateways/wigal.gateway.ts b/src/gateways/wigal.gateway.ts index c3a4ec0..498af4a 100644 --- a/src/gateways/wigal.gateway.ts +++ b/src/gateways/wigal.gateway.ts @@ -20,6 +20,7 @@ export class WigalGateway extends Gateway { // await this.session.setState(this.sessionId, _state); this.request.state = _state; this.request.input = this.request.query?.userdata!; + this.request.msisdn = _state.msisdn return _state; } diff --git a/src/menus/base.menu.ts b/src/menus/base.menu.ts index dd75532..261f3cf 100644 --- a/src/menus/base.menu.ts +++ b/src/menus/base.menu.ts @@ -55,6 +55,13 @@ export abstract class BaseMenu { }; } + /** + * Returns the current msisdn/phone number of the session. + */ + get msisdn(): string { + return this.request.state.msisdn + } + async back(): Promise { return undefined; } diff --git a/src/types/request.ts b/src/types/request.ts index 814a1c6..1d5557a 100644 --- a/src/types/request.ts +++ b/src/types/request.ts @@ -19,6 +19,8 @@ export class Request { url: string; + msisdn?: string; + /** * The input from the user */