From 2f653468e6b397b79290abc9a90ea26812a24526 Mon Sep 17 00:00:00 2001 From: Baber-Jan Date: Thu, 23 Jul 2020 20:02:16 +0400 Subject: [PATCH 1/8] Added all the product methods, now have to figure out how to use id in call back function --- .../src/userInteraction/messages.js | 269 +++++++++++++++++- 1 file changed, 268 insertions(+), 1 deletion(-) diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 5884fee..4e569f3 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -1,6 +1,11 @@ const { Command } = require("../models/commands"); const logic = require("../businessLogic/logic"); +const { Website } = require("../models/website"); +const { Product } = require('../models/product'); + +var selected_product = null;// Will keep track of the selected product +var selected_website = new Website; // Selected website. /////////// //add the commands here @@ -23,7 +28,269 @@ const commands = [ return message; } }), + new Command({ + //User command + command: `wg product new `, + //function to be executed + callback : () => { + + logic.onWG(); + var id; + if(selected_website==null) + { + let message = [ + `A website should be selected or created before creating a product ` + ]; + return message; + } + // Create a product and select it. At this point all the product properties will be default including the id will be empty + selected_product = new Product(); + if(id==null) + { + // Setting up the product id if not given + id = Math.floor((Math.random() * 100000) + 1); + while(selected_website.products.isData(id))// This is will check if the generated id is already used + { + id = Math.floor((Math.random() * 100000) + 1); + } + } + selected_product.id =id; + // Add a product to the selected website. We will add the id based on the count of the products on the website + selected_website.addProduct(selected_product) + //mesage to be sent to the user + let message = [ + `The product has been created with the id : ` + selected_product.id , + `This product has been selected . \nNow you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ` + ]; + + return message; + } + }), + new Command({ + //User command + command: `wg delete product `, + + //function to be executed + callback : () => { + + logic.onWG(); + var id ; + if(selected_website==null) + { + let message = [ + `A website should be selected or created before deleting a product ` + ]; + return message; + } + // Find the product with the given id + selected_product = selected_website.products.deleteData(id); + if(selected_product == false) + { + let message = [ + `No product with the given id` + ]; + return message; + } + + let message = [ + `The product has been deleted with the id : ` + id + ]; + selected_product =null; + return message; + } + }), + new Command({ + //User command + command: `wg product `, + + //function to be executed + callback : () => { + + logic.onWG(); + var id ; + if(selected_website==null) + { + let message = [ + `A website should be selected or created before selecting a product ` + ]; + return message; + } + // Find the product with the given id + selected_product = selected_website.products.getData(id); + if(selected_product == null) + { + selected_product = new Product(); + selected_product.id =id; + // Add a product to the selected website. We will add the id based on the count of the products on the website + selected_website.addProduct(selected_product) + //mesage to be sent to the user + let message = [ + `There was no product with the give id. So a new product was created and selected with the id : ` + selected_product.id , + `Now you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ` + ]; + + return message; + } + + let message = [ + `The product has been selected with the id : ` + id , + 'Now you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ' + + ]; + + return message; + } + }), + new Command({ + //User command + command: `wg product all`, + + //function to be executed + callback : () => { + + logic.onWG(); + if(selected_website==null) + { + let message = [ + `A website should be selected or created ` + ]; + return message; + } + let message = [ + 'Your website has following products' + ]; + for(let p of selected_website.products.getAllData().values()) + { + let m = 'Product id: ' + p.id + '\nProduct Name : ' + p.name + '\nProduct description : '+ p.desc + '\nProduct Cost: ' + p.cost + '\nProduct Image : '+ p.image + message.push(m); + } + + return message; + } + }), + new Command({ + //User command + command: `wg product info`, + + //function to be executed + callback : () => { + + logic.onWG(); + if(selected_product == null) + { + let message = [ + `A product should be selected ` + ]; + return message; + } + let message = [ + 'Product id: ' + p.id, + 'Product Name : ' + p.name , + 'Product description : '+ p.desc , + 'Product Cost: ' + p.cost , + 'Product Image : '+ p.image + ]; + + return message; + } + }), + new Command({ + //User command + command: `wg product name `, + + //function to be executed + callback : () => { + + logic.onWG(); + given_name= null; + if(selected_product == null) + { + let message = [ + `A product should be selected ` + ]; + return message; + } + selected_product.name= given_name; + let message = [ + 'The product name has been set to '+ given_name + ]; + + return message; + } + }), + new Command({ + //User command + command: `wg product cost `, + + //function to be executed + callback : () => { + + logic.onWG(); + given_cost= null; + if(selected_product == null) + { + let message = [ + `A product should be selected ` + ]; + return message; + } + selected_product.cost= given_cost; + let message = [ + 'The product cost has been set to '+ given_cost + ]; + + return message; + } + }), + new Command({ + //User command + command: 'wg product desc ', + + //function to be executed + callback : () => { + + logic.onWG(); + given_desc= null; + if(selected_product == null) + { + let message = [ + `A product should be selected ` + ]; + return message; + } + selected_product.desc= given_desc; + let message = [ + 'The product description has been set to : '+ given_desc + ]; + + return message; + } + }), + new Command({ + //User command + command: 'wg product image ', + + //function to be executed + callback : () => { + + logic.onWG(); + given_image= null; + if(selected_product == null) + { + let message = [ + `A product should be selected ` + ]; + return message; + } + selected_product.image = given_image; + let message = [ + 'The product image has been set to : '+ given_image + ]; + + return message; + } + }), ]; @@ -52,7 +319,7 @@ module.exports= onMessage = (message, client) => { } } -}; +}; From 4ca9d1418c25e7b114d5b0b20ecb42981393778c Mon Sep 17 00:00:00 2001 From: Baber-Jan Date: Thu, 23 Jul 2020 20:23:15 +0400 Subject: [PATCH 2/8] moved some code to logic.j --- whatsapp-web.js/src/businessLogic/logic.js | 28 +++++++++++++++++++ .../src/userInteraction/messages.js | 27 +++--------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 483cb10..28c0495 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -1,5 +1,6 @@ const { Website } = require("../models/website"); const { data } = require("../models/data"); +const { Product } = require('../models/product'); module.exports.onWG = () => { console.log('hello world'); @@ -17,4 +18,31 @@ module.exports.onCreate = (id, companyName) => { //add the website with the company name user.addWebsite(new Website(companyName)); +} +module.exports.addProduct = (id,website) => { + + if(id==null) + { + // Setting up the product id if not given + id = Math.floor((Math.random() * 100000) + 1); + while(website.products.isData(id))// This is will check if the generated id is already used + { + id = Math.floor((Math.random() * 100000) + 1); + } + } + + // Create a product and select it. At this point all the product properties will be default including the id will be empty + var product = new Product(); + product.id =id; + // Add a product to the selected website. We will add the id based on the count of the products on the website + website.addProduct(product); + return product; +} +module.exports.deleteProduct = (id,website) => { + + return website.products.deleteData(id); +} + +module.exports.deleteProduct = (id,website) => { + return website.products.deleteData(id); } \ No newline at end of file diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 4e569f3..157b1f4 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -44,20 +44,7 @@ const commands = [ ]; return message; } - // Create a product and select it. At this point all the product properties will be default including the id will be empty - selected_product = new Product(); - if(id==null) - { - // Setting up the product id if not given - id = Math.floor((Math.random() * 100000) + 1); - while(selected_website.products.isData(id))// This is will check if the generated id is already used - { - id = Math.floor((Math.random() * 100000) + 1); - } - } - selected_product.id =id; - // Add a product to the selected website. We will add the id based on the count of the products on the website - selected_website.addProduct(selected_product) + selected_product= logic.addProduct(id,selected_website); //mesage to be sent to the user let message = [ `The product has been created with the id : ` + selected_product.id , @@ -83,9 +70,8 @@ const commands = [ ]; return message; } - // Find the product with the given id - selected_product = selected_website.products.deleteData(id); - if(selected_product == false) + + if(logic.deleteProduct == false) { let message = [ `No product with the given id` @@ -96,7 +82,6 @@ const commands = [ let message = [ `The product has been deleted with the id : ` + id ]; - selected_product =null; return message; } }), @@ -120,11 +105,7 @@ const commands = [ selected_product = selected_website.products.getData(id); if(selected_product == null) { - selected_product = new Product(); - selected_product.id =id; - // Add a product to the selected website. We will add the id based on the count of the products on the website - selected_website.addProduct(selected_product) - //mesage to be sent to the user + logic.addProduct(id,selected_website); let message = [ `There was no product with the give id. So a new product was created and selected with the id : ` + selected_product.id , `Now you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ` From 0b0569b7835bbc85b50fba912c902afeb28117d9 Mon Sep 17 00:00:00 2001 From: Mohammed Ashab Uddin Date: Sat, 25 Jul 2020 10:15:33 +0400 Subject: [PATCH 3/8] deleted all the logic.onWg() --- whatsapp-web.js/src/userInteraction/messages.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index c3fd555..b4a86dc 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -35,7 +35,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_website==null) { let message = [ @@ -60,7 +59,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_website==null) { let message = [ @@ -90,7 +88,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_website==null) { let message = [ @@ -127,7 +124,6 @@ const commands = [ //function to be executed callback : () => { - logic.onWG(); if(selected_website==null) { let message = [ @@ -154,7 +150,6 @@ const commands = [ //function to be executed callback : () => { - logic.onWG(); if(selected_product == null) { let message = [ @@ -180,7 +175,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_product == null) { let message = [ @@ -203,7 +197,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_product == null) { let message = [ @@ -226,7 +219,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_product == null) { let message = [ @@ -249,7 +241,6 @@ const commands = [ //function to be executed callback : (input) => { - logic.onWG(); if(selected_product == null) { let message = [ From d4be542a91098a7bb7d699a5cae6b1465d0b39c1 Mon Sep 17 00:00:00 2001 From: Mohammed Ashab Uddin Date: Sat, 25 Jul 2020 21:17:11 +0400 Subject: [PATCH 4/8] fixed bug in command.js --- whatsapp-web.js/src/models/commands.js | 2 +- whatsapp-web.js/test/test_command.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/whatsapp-web.js/src/models/commands.js b/whatsapp-web.js/src/models/commands.js index ab084c2..674a54b 100644 --- a/whatsapp-web.js/src/models/commands.js +++ b/whatsapp-web.js/src/models/commands.js @@ -45,7 +45,7 @@ class Command{ //else return false if(splitMsg[i] == splitCommand[i]){ continue; - }else if(splitCommand[i].match(/[<>]/g).length > 1){ + }else if(splitCommand[i].match(/[<>]/g) != null){ continue; }else{ return false; diff --git a/whatsapp-web.js/test/test_command.js b/whatsapp-web.js/test/test_command.js index 1fca64a..b0786b7 100644 --- a/whatsapp-web.js/test/test_command.js +++ b/whatsapp-web.js/test/test_command.js @@ -91,6 +91,21 @@ describe('Command', () => { }); + it.only('Test : equals() with different message', () => { + + let message = 'wg website web'; + + let a = new Command({ + command: "wg create ", + callback: () => { + + } + }); + + expect(a.equals(message)).to.false; + + }); + it('Test : equals() with spelling error', () => { let message = 'wg websit'; From eeb04e1615874820fcdf71b97ea2d0d6c93d1c94 Mon Sep 17 00:00:00 2001 From: Baber-Jan Date: Sun, 26 Jul 2020 19:12:51 +0400 Subject: [PATCH 5/8] Did the required changes --- whatsapp-web.js/src/businessLogic/logic.js | 4 +- whatsapp-web.js/src/models/product.js | 37 ++++++++++++++++++ whatsapp-web.js/src/models/website.js | 8 ++++ .../src/userInteraction/messages.js | 38 +++++++++---------- 4 files changed, 66 insertions(+), 21 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index f96eca2..489aad5 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -33,12 +33,12 @@ module.exports.addProduct = (id,website) => { // Create a product and select it. At this point all the product properties will be default including the id will be empty var product = new Product(); - product.id =id; + product.setId(id); // Add a product to the selected website. We will add the id based on the count of the products on the website website.addProduct(product); return product; } module.exports.deleteProduct = (id,website) => { - return website.products.deleteData(id); + return website.deleteProduct(id); } diff --git a/whatsapp-web.js/src/models/product.js b/whatsapp-web.js/src/models/product.js index 8a01ddb..ebbefca 100644 --- a/whatsapp-web.js/src/models/product.js +++ b/whatsapp-web.js/src/models/product.js @@ -8,6 +8,43 @@ class Product { this.cost = cost; this.image = image; } + + /** + * + * @param {Number} id + */ + setId(id){ + return this.id = id; + } + /** + * + * @param {String} name + */ + setName(name){ + return this.name = name; + } + /** + * + * @param {String} description + */ + setDesc(description){ + return this.desc = description; + } + /** + * + * @param {Number} cost + */ + setCost(cost){ + return this.cost = cost; + } + /** + * + * @param {String} image + */ + setImage(image){ + return this.image = image; + } + } module.exports.Product = Product; diff --git a/whatsapp-web.js/src/models/website.js b/whatsapp-web.js/src/models/website.js index 9584f76..86e0f35 100644 --- a/whatsapp-web.js/src/models/website.js +++ b/whatsapp-web.js/src/models/website.js @@ -37,6 +37,14 @@ class Website { return this.products.getData(productId); } + /** + * + * @returns {[]} + */ + getAllProduct(){ + return this.products.getAllData().values(); + } + /** * * @param {string} productId diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 9e32940..cf19e39 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -4,7 +4,7 @@ const logic = require("../businessLogic/logic"); const { Website } = require("../models/website"); const { Product } = require('../models/product'); -var selected_product = null;// Will keep track of the selected product +var selected_product = new Product;// Will keep track of the selected product var selected_website = null; // Selected website. /////////// @@ -85,7 +85,7 @@ const commands = [ }), new Command({ //User command - command: `wg product `, + command: `wg select product `, //function to be executed callback : (input) => { @@ -99,7 +99,7 @@ const commands = [ return message; } // Find the product with the given id - selected_product = selected_website.products.getData(input['id']); + selected_product = selected_website.getProduct(input['id']); if(selected_product == null) { logic.addProduct(id,selected_website); @@ -112,7 +112,7 @@ const commands = [ } let message = [ - `The product has been selected with the id : ` + id , + `The product has been selected with the id : ` + selected_product.id , 'Now you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ' ]; @@ -136,9 +136,9 @@ const commands = [ return message; } let message = [ - 'Your website has following products' + 'Your website has following products: ' ]; - for(let p of selected_website.products.getAllData().values()) + for(let p of selected_website.getAllProduct()) { let m = 'Product id: ' + p.id + '\nProduct Name : ' + p.name + '\nProduct description : '+ p.desc + '\nProduct Cost: ' + p.cost + '\nProduct Image : '+ p.image message.push(m); @@ -163,11 +163,11 @@ const commands = [ return message; } let message = [ - 'Product id: ' + p.id, - 'Product Name : ' + p.name , - 'Product description : '+ p.desc , - 'Product Cost: ' + p.cost , - 'Product Image : '+ p.image + 'Product id: ' + selected_product.id, + 'Product Name : ' + selected_product.name , + 'Product description : '+ selected_product.desc , + 'Product Cost: ' + selected_product.cost , + 'Product Image : '+ selected_product.image ]; return message; @@ -188,9 +188,9 @@ const commands = [ ]; return message; } - selected_product.name= input['product-name']; + selected_product.setName(input['product-name']); let message = [ - 'The product name has been set to '+ given_name + 'The product name has been set to '+ selected_product.name ]; return message; @@ -211,9 +211,9 @@ const commands = [ ]; return message; } - selected_product.cost= input['product-cost']; + selected_product.setCost(input['product-cost']); let message = [ - 'The product cost has been set to '+ given_cost + 'The product cost has been set to '+ selected_product.cost ]; return message; @@ -234,9 +234,9 @@ const commands = [ ]; return message; } - selected_product.desc = input['product-desc']; + selected_product.setDesc(input['product-desc']); let message = [ - 'The product description has been set to : '+ given_desc + 'The product description has been set to : '+ selected_product.desc ]; return message; @@ -257,9 +257,9 @@ const commands = [ ]; return message; } - selected_product.image = input['product-image']; + selected_product.setImage(input['product-image']); let message = [ - 'The product image has been set to : '+ given_image + 'The product image has been set to : '+ selected_product.image ]; return message; From ff7eb53eef18eb8a57351d4bfd7f1c6b997bdf2d Mon Sep 17 00:00:00 2001 From: Baber-Jan Date: Sun, 26 Jul 2020 20:10:58 +0400 Subject: [PATCH 6/8] Single change --- whatsapp-web.js/src/userInteraction/messages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index cf19e39..c5cefbe 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -4,7 +4,7 @@ const logic = require("../businessLogic/logic"); const { Website } = require("../models/website"); const { Product } = require('../models/product'); -var selected_product = new Product;// Will keep track of the selected product +var selected_product = null;// Will keep track of the selected product var selected_website = null; // Selected website. /////////// From e71e9f372b1a88d0ec271f137d0c8d01f648e774 Mon Sep 17 00:00:00 2001 From: Mohammed Ashab Uddin Date: Tue, 28 Jul 2020 10:44:40 +0400 Subject: [PATCH 7/8] fixed entity map problems --- whatsapp-web.js/src/models/entity.js | 9 +++++---- whatsapp-web.js/test/test_command.js | 2 +- whatsapp-web.js/test/test_entity.js | 13 +++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/whatsapp-web.js/src/models/entity.js b/whatsapp-web.js/src/models/entity.js index 8297cb3..0bcce8f 100644 --- a/whatsapp-web.js/src/models/entity.js +++ b/whatsapp-web.js/src/models/entity.js @@ -9,7 +9,7 @@ class Entity { addData(key ,value){ if(!this.isData(key)){ - this.data[key] = value; + this.data.set(key, value); return true; } return false; @@ -20,12 +20,13 @@ class Entity { * @param {string} key */ isData(key){ - return this.data[key] != undefined ? true : false; + return this.data.has(key) ? true : false; } deleteData(key){ if(this.isData(key)){ - return delete this.data[key]; + this.data.delete(key); + return true; } return false; } @@ -37,7 +38,7 @@ class Entity { getData(key){ if(this.isData(key)){ - return this.data[key]; + return this.data.get(key); } return null; } diff --git a/whatsapp-web.js/test/test_command.js b/whatsapp-web.js/test/test_command.js index b0786b7..fff3df5 100644 --- a/whatsapp-web.js/test/test_command.js +++ b/whatsapp-web.js/test/test_command.js @@ -91,7 +91,7 @@ describe('Command', () => { }); - it.only('Test : equals() with different message', () => { + it('Test : equals() with different message', () => { let message = 'wg website web'; diff --git a/whatsapp-web.js/test/test_entity.js b/whatsapp-web.js/test/test_entity.js index f42eb2e..56a3e22 100644 --- a/whatsapp-web.js/test/test_entity.js +++ b/whatsapp-web.js/test/test_entity.js @@ -52,4 +52,17 @@ describe('Entity', () => { expect(a.getData('gada')).to.null; }) + it('Test: getAllData', () => { + let a = new Entity(); + a.addData('hello world', new Website('hello world')); + a.addData('gada', new Website('gada')); + a.addData('pagol', new Website('pagol')); + + let websitegen = a.getAllData().values(); + for(let t of websitegen) + { + console.log(t.companyName); + } + }) + }) \ No newline at end of file From 2aae4fe6e917251e804aa50658a2361baeef66fe Mon Sep 17 00:00:00 2001 From: Mohammed Ashab Uddin Date: Tue, 28 Jul 2020 10:46:02 +0400 Subject: [PATCH 8/8] small fixes --- whatsapp-web.js/src/userInteraction/messages.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index 1fd12e0..d75293c 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -83,7 +83,7 @@ const commands = [ }), new Command({ //User command - command: `wg select product `, + command: `wg product select `, //function to be executed callback : (input) => { @@ -99,7 +99,8 @@ const commands = [ selected_product = selected_website.getProduct(input['id']); if(selected_product == null) { - logic.addProduct(id,selected_website); + logic.addProduct(input['id'],selected_website); + selected_product = selected_website.getProduct(input['id']); let message = [ `There was no product with the give id. So a new product was created and selected with the id : ` + selected_product.id , `Now you can make change to the product with the following commands : \n1. wg product info \n2. wg product name \n3. wg product cost \n4. wg product desc \n5. wg product image ` @@ -136,7 +137,7 @@ const commands = [ ]; for(let p of selected_website.getAllProduct()) { - let m = 'Product id: ' + p.id + '\nProduct Name : ' + p.name + '\nProduct description : '+ p.desc + '\nProduct Cost: ' + p.cost + '\nProduct Image : '+ p.image + let m = 'Product id: ' + p.id + '\nProduct Name : ' + p.name + '\nProduct description : '+ p.desc + '\nProduct Cost: ' + p.cost + '\nProduct Image : '+ p.image; message.push(m); } @@ -278,7 +279,7 @@ module.exports= onMessage = (message, client) => { if(command != null){ let input = {}; if(command.requireInput){ - input = command.getInput(); + input = command.getInput(message.body); } let messageToBeSent = command.callback(input);