@magicfeedback/native 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -47,7 +47,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
47
47
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
48
48
|
|
|
49
49
|
"use strict";
|
|
50
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Form = void 0;\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\nclass Form {\n /**\n *\n * @param config\n * @param appId\n */\n constructor(config, appId) {\n // Config\n this.config = config;\n this.request = new request_1.Request();\n this.log = new log_1.Log(config);\n // Attributes\n this.appId = appId;\n }\n /**\n * Generate\n * TODO: Check if is inside of a <form>\n * @param appId\n */\n generate(selector, options = {}) {\n //TODO: Check if already exist the form\n // Request question from the app\n this.request\n .get(`${this.config.get(\"url\")}/apps/${this.appId}/questions`, {})\n .then((appQuestions) => {\n if (appQuestions === undefined || !appQuestions) {\n this.log.err(`No questions for app ${this.appId}`);\n return;\n }\n // Create the from from the JSON\n this.generateForm(this.appId, appQuestions, selector, options);\n });\n }\n /**\n * Create\n * @param appId\n * @param appQuestions\n * @param selector\n * @param options\n *\n * TODO: Add option to generate in <form> or in other <tag>\n */\n generateForm(appId, appQuestions, selector, options = {}) {\n // Select the container\n const container = document.getElementById(selector);\n if (!container) {\n this.log.err(`Element with ID '${selector}' not found.`);\n return;\n }\n container.classList.add(\"magicfeedback-container\");\n // Create the form\n const form = document.createElement(\"form\");\n form.classList.add(\"magicfeedback-form\");\n form.id = \"magicfeedback-\" + appId;\n // Process questions and create in the form\n appQuestions.forEach((question) => {\n const { id, title, type, ref, require, \n //external_id,\n value, defaultValue, } = question;\n let element;\n let elementTypeClass;\n let elementContainer = document.createElement(\"div\");\n elementContainer.classList.add(\"magicfeedback-div\");\n switch (type) {\n case \"TEXT\":\n // Create a text input field\n element = document.createElement(\"input\");\n element.type = \"text\";\n elementTypeClass = \"magicfeedback-text\";\n break;\n case \"LONGTEXT\":\n // Create a textarea element for TEXT and LONGTEXT types\n element = document.createElement(\"textarea\");\n element.rows = 3; // Set the number of rows based on the type\n elementTypeClass = \"magicfeedback-longtext\";\n break;\n case \"NUMBER\":\n // Create an input element with type \"number\" for NUMBER type\n element = document.createElement(\"input\");\n element.type = \"number\";\n elementTypeClass = \"magicfeedback-number\";\n if (value.length) {\n value.sort((a, b) => {\n let aa = Number(a);\n let bb = Number(b);\n return aa - bb;\n });\n element.max = value[value.length - 1];\n element.min = value[0];\n element.value = value[0];\n }\n break;\n case \"RADIO\":\n case \"MULTIPLECHOICE\":\n element = document.createElement(\"div\");\n elementTypeClass =\n \"magicfeedback-\" + (type === \"RADIO\" ? \"radio\" : \"checkbox\");\n value.forEach((option) => {\n const label = document.createElement(\"label\");\n const input = document.createElement(\"input\");\n input.type = type === \"RADIO\" ? \"radio\" : \"checkbox\";\n input.name = ref;\n input.value = option;\n input.required = require;\n input.classList.add(elementTypeClass);\n input.classList.add(\"magicfeedback-input\");\n if (option === defaultValue) {\n input.checked = true;\n }\n label.textContent = option;\n element.appendChild(input);\n element.appendChild(label);\n });\n break;\n case \"SELECT\":\n // Create a select element for RADIO and MULTIPLECHOICE types\n element = document.createElement(\"select\");\n elementTypeClass = \"magicfeedback-select\";\n value.forEach((optionValue) => {\n // Create an option element for each value in the question's value array\n const option = document.createElement(\"option\");\n option.value = optionValue;\n option.text = optionValue;\n element.appendChild(option);\n });\n break;\n case \"DATE\":\n // Create an input element with type \"date\" for DATE type\n element = document.createElement(\"input\");\n element.type = \"date\";\n elementTypeClass = \"magicfeedback-date\";\n break;\n case \"BOOLEAN\":\n // Create an input element with type \"checkbox\" for BOOLEAN type\n element = document.createElement(\"input\");\n element.type = \"checkbox\";\n elementTypeClass = \"magicfeedback-boolean\";\n break;\n default:\n return; // Skip unknown types\n }\n element.id = `magicfeedback-${id}`;\n element.setAttribute(\"name\", ref);\n if (defaultValue !== undefined) {\n element.value = defaultValue;\n }\n // Add the label and input element to the form\n const label = document.createElement(\"label\");\n label.setAttribute(\"for\", `magicfeedback-${id}`);\n label.textContent = title;\n label.classList.add(\"magicfeedback-label\");\n elementContainer.appendChild(label);\n element.classList.add(elementTypeClass);\n if (type != \"RADIO\" && type != \"MULTIPLECHOICE\") {\n element.classList.add(\"magicfeedback-input\");\n element.required = require;\n }\n elementContainer.appendChild(element);\n form.appendChild(elementContainer);\n });\n // Submit button\n if (options.addButton) {\n // Create a submit button if specified in options\n const submitButton = document.createElement(\"button\");\n submitButton.type = \"submit\";\n submitButton.textContent = \"Submit\";\n submitButton.classList.add(\"magicfeedback-submit\");\n form.appendChild(submitButton);\n }\n // Add the form to the specified container\n container.appendChild(form);\n // Submit event\n form.addEventListener(\"submit\", (event) => __awaiter(this, void 0, void 0, function* () {\n event.preventDefault();\n try {\n // BEFORE\n if (options.beforeSubmitEvent) {\n yield options.beforeSubmitEvent();\n }\n // SEND\n const response = yield this.send();\n // AFTER\n if (options.afterSubmitEvent) {\n yield options.afterSubmitEvent(response);\n }\n return response;\n }\n catch (error) {\n // Handle error in beforeSubmitEvent, send(), or afterSubmitEvent\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n return error;\n }\n }));\n }\n /**\n * Answer\n * @param appId\n * @returns\n * TODO: Required\n */\n answer() {\n const form = document.getElementById(\"magicfeedback-\" + this.appId);\n if (!form) {\n this.log.err(`Form \"${form}\" not found.`);\n return [];\n }\n const surveyAnswers = [];\n let hasError = false; // Flag to track if an error has occurred\n const inputs = form.querySelectorAll(\".magicfeedback-input\");\n inputs.forEach((input) => {\n const inputType = input.type;\n //const required = (input as HTMLInputElement).required;\n const ans = {\n id: input.name,\n type: inputType,\n value: [],\n };\n const value = input.value;\n if (inputType === \"radio\" || inputType === \"checkbox\") {\n if (input.checked) {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n }\n else {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n });\n if (hasError) {\n return []; // Stop the process if there's an error\n }\n return surveyAnswers;\n }\n /**\n * Send\n * @returns\n */\n send() {\n return __awaiter(this, void 0, void 0, function* () {\n // Define the URL and request payload\n const url = `${this.config.get(\"url\")}/feedback/apps`;\n try {\n // Get the survey answers from the answer() function\n const surveyAnswers = this.answer();\n if (surveyAnswers.length === 0) {\n throw new Error(\"No answers provided\");\n }\n // Make the AJAX POST request\n const response = yield this.request.post(url, {\n appId: this.appId,\n answers: surveyAnswers,\n });\n if (response.ok) {\n // Handle success response\n this.log.log(`Form ${this.appId} submitted successfully!`);\n // You can perform additional actions here if needed\n }\n else {\n // Handle error response\n this.log.err(`Failed to submit form ${this.appId}:`, response.status, response.statusText);\n throw new Error(response.statusText);\n }\n return response;\n }\n catch (error) {\n // Handle network or request error\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n throw error;\n }\n });\n }\n}\nexports.Form = Form;\n\n\n//# sourceURL=webpack://magicfeedback/./src/form.ts?");
|
|
50
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Form = void 0;\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\nclass Form {\n /**\n *\n * @param config\n * @param appId\n */\n constructor(config, appId) {\n // Config\n this.config = config;\n this.request = new request_1.Request();\n this.log = new log_1.Log(config);\n // Attributes\n this.appId = appId;\n }\n /**\n * Generate\n * TODO: Check if is inside of a <form>\n * @param appId\n */\n generate(selector, options = {}) {\n //TODO: Check if already exist the form\n // Request question from the app\n this.request\n .get(`${this.config.get(\"url\")}/apps/${this.appId}/questions`, {})\n .then((appQuestions) => {\n if (appQuestions === undefined || !appQuestions) {\n this.log.err(`No questions for app ${this.appId}`);\n return;\n }\n // Create the from from the JSON\n this.generateForm(this.appId, appQuestions, selector, options);\n });\n }\n /**\n * Create\n * @param appId\n * @param appQuestions\n * @param selector\n * @param options\n *\n * TODO: Add option to generate in <form> or in other <tag>\n */\n generateForm(appId, appQuestions, selector, options = {}) {\n // Select the container\n const container = document.getElementById(selector);\n if (!container) {\n this.log.err(`Element with ID '${selector}' not found.`);\n return;\n }\n container.classList.add(\"magicfeedback-container\");\n // Create the form\n const form = document.createElement(\"form\");\n form.classList.add(\"magicfeedback-form\");\n form.id = \"magicfeedback-\" + appId;\n // Process questions and create in the form\n appQuestions.forEach((question) => {\n const { id, title, type, ref, require, \n //external_id,\n value, defaultValue, } = question;\n this.log.log(\"Question\", question);\n let element;\n let elementTypeClass;\n let elementContainer = document.createElement(\"div\");\n elementContainer.classList.add(\"magicfeedback-div\");\n switch (type) {\n case \"TEXT\":\n // Create a text input field\n element = document.createElement(\"input\");\n element.type = \"text\";\n elementTypeClass = \"magicfeedback-text\";\n break;\n case \"LONGTEXT\":\n // Create a textarea element for TEXT and LONGTEXT types\n element = document.createElement(\"textarea\");\n element.rows = 3; // Set the number of rows based on the type\n elementTypeClass = \"magicfeedback-longtext\";\n break;\n case \"NUMBER\":\n // Create an input element with type \"number\" for NUMBER type\n element = document.createElement(\"input\");\n element.type = \"number\";\n elementTypeClass = \"magicfeedback-number\";\n if (value.length) {\n value.sort((a, b) => {\n let aa = Number(a);\n let bb = Number(b);\n return aa - bb;\n });\n element.max = value[value.length - 1];\n element.min = value[0];\n element.value = value[0];\n }\n break;\n case \"RADIO\":\n case \"MULTIPLECHOICE\":\n element = document.createElement(\"div\");\n elementTypeClass =\n \"magicfeedback-\" + (type === \"RADIO\" ? \"radio\" : \"checkbox\");\n value.forEach((option) => {\n const label = document.createElement(\"label\");\n const input = document.createElement(\"input\");\n input.type = type === \"RADIO\" ? \"radio\" : \"checkbox\";\n input.name = ref;\n input.value = option;\n input.required =\n require.toLocaleLowerCase() === \"true\" ? true : false;\n input.classList.add(elementTypeClass);\n input.classList.add(\"magicfeedback-input\");\n if (option === defaultValue) {\n input.checked = true;\n }\n label.textContent = option;\n element.appendChild(input);\n element.appendChild(label);\n });\n break;\n case \"SELECT\":\n // Create a select element for RADIO and MULTIPLECHOICE types\n element = document.createElement(\"select\");\n elementTypeClass = \"magicfeedback-select\";\n value.forEach((optionValue) => {\n // Create an option element for each value in the question's value array\n const option = document.createElement(\"option\");\n option.value = optionValue;\n option.text = optionValue;\n element.appendChild(option);\n });\n break;\n case \"DATE\":\n // Create an input element with type \"date\" for DATE type\n element = document.createElement(\"input\");\n element.type = \"date\";\n elementTypeClass = \"magicfeedback-date\";\n break;\n case \"BOOLEAN\":\n // Create an input element with type \"checkbox\" for BOOLEAN type\n element = document.createElement(\"input\");\n element.type = \"checkbox\";\n elementTypeClass = \"magicfeedback-boolean\";\n break;\n default:\n return; // Skip unknown types\n }\n element.id = `magicfeedback-${id}`;\n element.setAttribute(\"name\", ref);\n if (defaultValue !== undefined) {\n element.value = defaultValue;\n }\n // Add the label and input element to the form\n const label = document.createElement(\"label\");\n label.setAttribute(\"for\", `magicfeedback-${id}`);\n label.textContent = title;\n label.classList.add(\"magicfeedback-label\");\n elementContainer.appendChild(label);\n element.classList.add(elementTypeClass);\n if (type != \"RADIO\" && type != \"MULTIPLECHOICE\") {\n element.classList.add(\"magicfeedback-input\");\n element.required =\n require.toLocaleLowerCase() === \"true\" ? true : false;\n }\n elementContainer.appendChild(element);\n form.appendChild(elementContainer);\n });\n // Submit button\n if (options.addButton) {\n // Create a submit button if specified in options\n const submitButton = document.createElement(\"button\");\n submitButton.type = \"submit\";\n submitButton.textContent = \"Submit\";\n submitButton.classList.add(\"magicfeedback-submit\");\n form.appendChild(submitButton);\n }\n // Add the form to the specified container\n container.appendChild(form);\n // Submit event\n form.addEventListener(\"submit\", (event) => __awaiter(this, void 0, void 0, function* () {\n event.preventDefault();\n try {\n // BEFORE\n if (options.beforeSubmitEvent) {\n yield options.beforeSubmitEvent();\n }\n // SEND\n const response = yield this.send();\n // AFTER\n if (options.afterSubmitEvent) {\n yield options.afterSubmitEvent(response);\n }\n return response;\n }\n catch (error) {\n // Handle error in beforeSubmitEvent, send(), or afterSubmitEvent\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n return error;\n }\n }));\n }\n /**\n * Answer\n * @param appId\n * @returns\n * TODO: Required\n */\n answer() {\n const form = document.getElementById(\"magicfeedback-\" + this.appId);\n if (!form) {\n this.log.err(`Form \"${form}\" not found.`);\n return [];\n }\n const surveyAnswers = [];\n let hasError = false; // Flag to track if an error has occurred\n const inputs = form.querySelectorAll(\".magicfeedback-input\");\n inputs.forEach((input) => {\n const inputType = input.type;\n //const required = (input as HTMLInputElement).required;\n const ans = {\n id: input.name,\n type: inputType,\n value: [],\n };\n const value = input.value;\n if (inputType === \"radio\" || inputType === \"checkbox\") {\n if (input.checked) {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n }\n else {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n });\n if (hasError) {\n return []; // Stop the process if there's an error\n }\n return surveyAnswers;\n }\n /**\n * Send\n * @returns\n */\n send() {\n return __awaiter(this, void 0, void 0, function* () {\n // Define the URL and request payload\n const url = `${this.config.get(\"url\")}/feedback/apps`;\n try {\n // Get the survey answers from the answer() function\n const surveyAnswers = this.answer();\n if (surveyAnswers.length === 0) {\n throw new Error(\"No answers provided\");\n }\n // Make the AJAX POST request\n const response = yield this.request.post(url, {\n appId: this.appId,\n answers: surveyAnswers,\n });\n if (response.ok) {\n // Handle success response\n this.log.log(`Form ${this.appId} submitted successfully!`);\n // You can perform additional actions here if needed\n }\n else {\n // Handle error response\n this.log.err(`Failed to submit form ${this.appId}:`, response.status, response.statusText);\n throw new Error(response.statusText);\n }\n return response;\n }\n catch (error) {\n // Handle network or request error\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n throw error;\n }\n });\n }\n}\nexports.Form = Form;\n\n\n//# sourceURL=webpack://magicfeedback/./src/form.ts?");
|
|
51
51
|
|
|
52
52
|
/***/ }),
|
|
53
53
|
|
|
@@ -80,7 +80,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
80
80
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
81
81
|
|
|
82
82
|
"use strict";
|
|
83
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst form_1 = __webpack_require__(/*! ./form */ \"./src/form.ts\");\nconst config_1 = __webpack_require__(/*! ./config */ \"./src/config.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\n/**\n *\n * @returns\n */\nfunction main() {\n //===============================================\n // Attributes\n //===============================================\n const config = new config_1.Config();\n const request = new request_1.Request();\n let log;\n //===============================================\n // Private\n //===============================================\n //===============================================\n // Public\n //===============================================\n /**\n *\n * @param options\n */\n function init(options) {\n if (options === null || options === void 0 ? void 0 : options.url)\n config.set(\"url\", options === null || options === void 0 ? void 0 : options.url);\n if (options === null || options === void 0 ? void 0 : options.debug)\n config.set(\"debug\", options === null || options === void 0 ? void 0 : options.debug);\n log = new log_1.Log(config);\n log.log(\"Initialized Magicfeedback\",
|
|
83
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst form_1 = __webpack_require__(/*! ./form */ \"./src/form.ts\");\nconst config_1 = __webpack_require__(/*! ./config */ \"./src/config.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\n/**\n *\n * @returns\n */\nfunction main() {\n //===============================================\n // Attributes\n //===============================================\n const config = new config_1.Config();\n const request = new request_1.Request();\n let log;\n //===============================================\n // Private\n //===============================================\n //===============================================\n // Public\n //===============================================\n /**\n *\n * @param options\n */\n function init(options) {\n if (options === null || options === void 0 ? void 0 : options.url)\n config.set(\"url\", options === null || options === void 0 ? void 0 : options.url);\n if (options === null || options === void 0 ? void 0 : options.debug)\n config.set(\"debug\", options === null || options === void 0 ? void 0 : options.debug);\n log = new log_1.Log(config);\n log.log(\"Initialized Magicfeedback\", config);\n }\n /**\n *\n * @param appId\n * @param answers\n * @param profile\n * @returns\n */\n function send(appId, answers, profile) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!appId)\n log.err(\"No appID provided\");\n if (!answers)\n log.err(\"No answers provided\");\n if (answers.length == 0)\n log.err(\"Answers are empty\");\n const payload = {\n appId: appId,\n answers: answers,\n };\n if (profile)\n payload.profile = profile;\n let res = {};\n try {\n res = yield request.post(`${config.get(\"url\")}/feedback/apps`, payload);\n log.log(`sent native feedback`, res);\n }\n catch (e) {\n log.err(`error native feedback`, e);\n }\n return res;\n });\n }\n /**\n *\n * @param appId\n * @returns\n */\n function form(appId) {\n if (!appId)\n log.err(\"No appID provided\");\n return new form_1.Form(config, appId);\n }\n //===============================================\n // Return\n //===============================================\n return {\n // lifecycle\n init,\n // requests\n send,\n form,\n };\n}\nexports[\"default\"] = main;\n\n\n//# sourceURL=webpack://magicfeedback/./src/main.ts?");
|
|
84
84
|
|
|
85
85
|
/***/ }),
|
|
86
86
|
|
|
@@ -102,7 +102,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
|
102
102
|
/***/ ((module) => {
|
|
103
103
|
|
|
104
104
|
"use strict";
|
|
105
|
-
eval("module.exports = JSON.parse('{\"name\":\"@magicfeedback/native\",\"version\":\"1.0.
|
|
105
|
+
eval("module.exports = JSON.parse('{\"name\":\"@magicfeedback/native\",\"version\":\"1.0.5\",\"main\":\"./dist/magicfeedback-sdk.node.js\",\"browser\":\"./dist/magicfeedback-sdk.browser.js\",\"types\":\"./dist/types/src/index.d.ts\",\"repository\":{\"type\":\"git\",\"url\":\"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git\"},\"author\":\"farias@magicfeedback.io\",\"license\":\"MIT\",\"private\":false,\"scripts\":{\"dev\":\"vite\",\"build\":\"webpack\",\"build:watch\":\"webpack --watch --mode development\",\"test\":\"jest\",\"test:watch\":\"jest --watchAll\",\"coverage\":\"vitest run --coverage\"},\"files\":[\"dist\"],\"devDependencies\":{\"@babel/preset-typescript\":\"^7.22.5\",\"@types/node\":\"^17.0.21\",\"@types/webpack\":\"^5.28.0\",\"@types/webpack-node-externals\":\"^2.5.3\",\"c8\":\"^7.11.0\",\"jest\":\"^29.5.0\",\"jest-environment-jsdom\":\"^29.5.0\",\"jest-fetch-mock\":\"^3.0.3\",\"nock\":\"^13.2.4\",\"ts-jest\":\"^29.1.0\",\"ts-loader\":\"^9.2.7\",\"ts-node\":\"^10.7.0\",\"typescript\":\"^4.6.2\",\"vite\":\"^2.8.0\",\"vite-plugin-dts\":\"^0.9.9\",\"vitest\":\"^0.5.9\",\"webpack\":\"^5.70.0\",\"webpack-cli\":\"^4.9.2\",\"webpack-node-externals\":\"^3.0.0\"},\"dependencies\":{\"cross-fetch\":\"^3.1.5\",\"is-bundling-for-browser-or-node\":\"^1.1.1\"},\"description\":\"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)\",\"bugs\":{\"url\":\"https://github.com/MagicFeedback/magicfeedback-sdk/issues\"},\"homepage\":\"https://github.com/MagicFeedback/magicfeedback-sdk#readme\",\"directories\":{\"example\":\"examples\",\"test\":\"test\"}}');\n\n//# sourceURL=webpack://magicfeedback/./package.json?");
|
|
106
106
|
|
|
107
107
|
/***/ })
|
|
108
108
|
|
|
@@ -36,7 +36,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
36
36
|
\*********************/
|
|
37
37
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
38
38
|
|
|
39
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Form = void 0;\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\nclass Form {\n /**\n *\n * @param config\n * @param appId\n */\n constructor(config, appId) {\n // Config\n this.config = config;\n this.request = new request_1.Request();\n this.log = new log_1.Log(config);\n // Attributes\n this.appId = appId;\n }\n /**\n * Generate\n * TODO: Check if is inside of a <form>\n * @param appId\n */\n generate(selector, options = {}) {\n //TODO: Check if already exist the form\n // Request question from the app\n this.request\n .get(`${this.config.get(\"url\")}/apps/${this.appId}/questions`, {})\n .then((appQuestions) => {\n if (appQuestions === undefined || !appQuestions) {\n this.log.err(`No questions for app ${this.appId}`);\n return;\n }\n // Create the from from the JSON\n this.generateForm(this.appId, appQuestions, selector, options);\n });\n }\n /**\n * Create\n * @param appId\n * @param appQuestions\n * @param selector\n * @param options\n *\n * TODO: Add option to generate in <form> or in other <tag>\n */\n generateForm(appId, appQuestions, selector, options = {}) {\n // Select the container\n const container = document.getElementById(selector);\n if (!container) {\n this.log.err(`Element with ID '${selector}' not found.`);\n return;\n }\n container.classList.add(\"magicfeedback-container\");\n // Create the form\n const form = document.createElement(\"form\");\n form.classList.add(\"magicfeedback-form\");\n form.id = \"magicfeedback-\" + appId;\n // Process questions and create in the form\n appQuestions.forEach((question) => {\n const { id, title, type, ref, require, \n //external_id,\n value, defaultValue, } = question;\n let element;\n let elementTypeClass;\n let elementContainer = document.createElement(\"div\");\n elementContainer.classList.add(\"magicfeedback-div\");\n switch (type) {\n case \"TEXT\":\n // Create a text input field\n element = document.createElement(\"input\");\n element.type = \"text\";\n elementTypeClass = \"magicfeedback-text\";\n break;\n case \"LONGTEXT\":\n // Create a textarea element for TEXT and LONGTEXT types\n element = document.createElement(\"textarea\");\n element.rows = 3; // Set the number of rows based on the type\n elementTypeClass = \"magicfeedback-longtext\";\n break;\n case \"NUMBER\":\n // Create an input element with type \"number\" for NUMBER type\n element = document.createElement(\"input\");\n element.type = \"number\";\n elementTypeClass = \"magicfeedback-number\";\n if (value.length) {\n value.sort((a, b) => {\n let aa = Number(a);\n let bb = Number(b);\n return aa - bb;\n });\n element.max = value[value.length - 1];\n element.min = value[0];\n element.value = value[0];\n }\n break;\n case \"RADIO\":\n case \"MULTIPLECHOICE\":\n element = document.createElement(\"div\");\n elementTypeClass =\n \"magicfeedback-\" + (type === \"RADIO\" ? \"radio\" : \"checkbox\");\n value.forEach((option) => {\n const label = document.createElement(\"label\");\n const input = document.createElement(\"input\");\n input.type = type === \"RADIO\" ? \"radio\" : \"checkbox\";\n input.name = ref;\n input.value = option;\n input.required = require;\n input.classList.add(elementTypeClass);\n input.classList.add(\"magicfeedback-input\");\n if (option === defaultValue) {\n input.checked = true;\n }\n label.textContent = option;\n element.appendChild(input);\n element.appendChild(label);\n });\n break;\n case \"SELECT\":\n // Create a select element for RADIO and MULTIPLECHOICE types\n element = document.createElement(\"select\");\n elementTypeClass = \"magicfeedback-select\";\n value.forEach((optionValue) => {\n // Create an option element for each value in the question's value array\n const option = document.createElement(\"option\");\n option.value = optionValue;\n option.text = optionValue;\n element.appendChild(option);\n });\n break;\n case \"DATE\":\n // Create an input element with type \"date\" for DATE type\n element = document.createElement(\"input\");\n element.type = \"date\";\n elementTypeClass = \"magicfeedback-date\";\n break;\n case \"BOOLEAN\":\n // Create an input element with type \"checkbox\" for BOOLEAN type\n element = document.createElement(\"input\");\n element.type = \"checkbox\";\n elementTypeClass = \"magicfeedback-boolean\";\n break;\n default:\n return; // Skip unknown types\n }\n element.id = `magicfeedback-${id}`;\n element.setAttribute(\"name\", ref);\n if (defaultValue !== undefined) {\n element.value = defaultValue;\n }\n // Add the label and input element to the form\n const label = document.createElement(\"label\");\n label.setAttribute(\"for\", `magicfeedback-${id}`);\n label.textContent = title;\n label.classList.add(\"magicfeedback-label\");\n elementContainer.appendChild(label);\n element.classList.add(elementTypeClass);\n if (type != \"RADIO\" && type != \"MULTIPLECHOICE\") {\n element.classList.add(\"magicfeedback-input\");\n element.required = require;\n }\n elementContainer.appendChild(element);\n form.appendChild(elementContainer);\n });\n // Submit button\n if (options.addButton) {\n // Create a submit button if specified in options\n const submitButton = document.createElement(\"button\");\n submitButton.type = \"submit\";\n submitButton.textContent = \"Submit\";\n submitButton.classList.add(\"magicfeedback-submit\");\n form.appendChild(submitButton);\n }\n // Add the form to the specified container\n container.appendChild(form);\n // Submit event\n form.addEventListener(\"submit\", (event) => __awaiter(this, void 0, void 0, function* () {\n event.preventDefault();\n try {\n // BEFORE\n if (options.beforeSubmitEvent) {\n yield options.beforeSubmitEvent();\n }\n // SEND\n const response = yield this.send();\n // AFTER\n if (options.afterSubmitEvent) {\n yield options.afterSubmitEvent(response);\n }\n return response;\n }\n catch (error) {\n // Handle error in beforeSubmitEvent, send(), or afterSubmitEvent\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n return error;\n }\n }));\n }\n /**\n * Answer\n * @param appId\n * @returns\n * TODO: Required\n */\n answer() {\n const form = document.getElementById(\"magicfeedback-\" + this.appId);\n if (!form) {\n this.log.err(`Form \"${form}\" not found.`);\n return [];\n }\n const surveyAnswers = [];\n let hasError = false; // Flag to track if an error has occurred\n const inputs = form.querySelectorAll(\".magicfeedback-input\");\n inputs.forEach((input) => {\n const inputType = input.type;\n //const required = (input as HTMLInputElement).required;\n const ans = {\n id: input.name,\n type: inputType,\n value: [],\n };\n const value = input.value;\n if (inputType === \"radio\" || inputType === \"checkbox\") {\n if (input.checked) {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n }\n else {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n });\n if (hasError) {\n return []; // Stop the process if there's an error\n }\n return surveyAnswers;\n }\n /**\n * Send\n * @returns\n */\n send() {\n return __awaiter(this, void 0, void 0, function* () {\n // Define the URL and request payload\n const url = `${this.config.get(\"url\")}/feedback/apps`;\n try {\n // Get the survey answers from the answer() function\n const surveyAnswers = this.answer();\n if (surveyAnswers.length === 0) {\n throw new Error(\"No answers provided\");\n }\n // Make the AJAX POST request\n const response = yield this.request.post(url, {\n appId: this.appId,\n answers: surveyAnswers,\n });\n if (response.ok) {\n // Handle success response\n this.log.log(`Form ${this.appId} submitted successfully!`);\n // You can perform additional actions here if needed\n }\n else {\n // Handle error response\n this.log.err(`Failed to submit form ${this.appId}:`, response.status, response.statusText);\n throw new Error(response.statusText);\n }\n return response;\n }\n catch (error) {\n // Handle network or request error\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n throw error;\n }\n });\n }\n}\nexports.Form = Form;\n\n\n//# sourceURL=webpack://magicfeedback/./src/form.ts?");
|
|
39
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Form = void 0;\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\nclass Form {\n /**\n *\n * @param config\n * @param appId\n */\n constructor(config, appId) {\n // Config\n this.config = config;\n this.request = new request_1.Request();\n this.log = new log_1.Log(config);\n // Attributes\n this.appId = appId;\n }\n /**\n * Generate\n * TODO: Check if is inside of a <form>\n * @param appId\n */\n generate(selector, options = {}) {\n //TODO: Check if already exist the form\n // Request question from the app\n this.request\n .get(`${this.config.get(\"url\")}/apps/${this.appId}/questions`, {})\n .then((appQuestions) => {\n if (appQuestions === undefined || !appQuestions) {\n this.log.err(`No questions for app ${this.appId}`);\n return;\n }\n // Create the from from the JSON\n this.generateForm(this.appId, appQuestions, selector, options);\n });\n }\n /**\n * Create\n * @param appId\n * @param appQuestions\n * @param selector\n * @param options\n *\n * TODO: Add option to generate in <form> or in other <tag>\n */\n generateForm(appId, appQuestions, selector, options = {}) {\n // Select the container\n const container = document.getElementById(selector);\n if (!container) {\n this.log.err(`Element with ID '${selector}' not found.`);\n return;\n }\n container.classList.add(\"magicfeedback-container\");\n // Create the form\n const form = document.createElement(\"form\");\n form.classList.add(\"magicfeedback-form\");\n form.id = \"magicfeedback-\" + appId;\n // Process questions and create in the form\n appQuestions.forEach((question) => {\n const { id, title, type, ref, require, \n //external_id,\n value, defaultValue, } = question;\n this.log.log(\"Question\", question);\n let element;\n let elementTypeClass;\n let elementContainer = document.createElement(\"div\");\n elementContainer.classList.add(\"magicfeedback-div\");\n switch (type) {\n case \"TEXT\":\n // Create a text input field\n element = document.createElement(\"input\");\n element.type = \"text\";\n elementTypeClass = \"magicfeedback-text\";\n break;\n case \"LONGTEXT\":\n // Create a textarea element for TEXT and LONGTEXT types\n element = document.createElement(\"textarea\");\n element.rows = 3; // Set the number of rows based on the type\n elementTypeClass = \"magicfeedback-longtext\";\n break;\n case \"NUMBER\":\n // Create an input element with type \"number\" for NUMBER type\n element = document.createElement(\"input\");\n element.type = \"number\";\n elementTypeClass = \"magicfeedback-number\";\n if (value.length) {\n value.sort((a, b) => {\n let aa = Number(a);\n let bb = Number(b);\n return aa - bb;\n });\n element.max = value[value.length - 1];\n element.min = value[0];\n element.value = value[0];\n }\n break;\n case \"RADIO\":\n case \"MULTIPLECHOICE\":\n element = document.createElement(\"div\");\n elementTypeClass =\n \"magicfeedback-\" + (type === \"RADIO\" ? \"radio\" : \"checkbox\");\n value.forEach((option) => {\n const label = document.createElement(\"label\");\n const input = document.createElement(\"input\");\n input.type = type === \"RADIO\" ? \"radio\" : \"checkbox\";\n input.name = ref;\n input.value = option;\n input.required =\n require.toLocaleLowerCase() === \"true\" ? true : false;\n input.classList.add(elementTypeClass);\n input.classList.add(\"magicfeedback-input\");\n if (option === defaultValue) {\n input.checked = true;\n }\n label.textContent = option;\n element.appendChild(input);\n element.appendChild(label);\n });\n break;\n case \"SELECT\":\n // Create a select element for RADIO and MULTIPLECHOICE types\n element = document.createElement(\"select\");\n elementTypeClass = \"magicfeedback-select\";\n value.forEach((optionValue) => {\n // Create an option element for each value in the question's value array\n const option = document.createElement(\"option\");\n option.value = optionValue;\n option.text = optionValue;\n element.appendChild(option);\n });\n break;\n case \"DATE\":\n // Create an input element with type \"date\" for DATE type\n element = document.createElement(\"input\");\n element.type = \"date\";\n elementTypeClass = \"magicfeedback-date\";\n break;\n case \"BOOLEAN\":\n // Create an input element with type \"checkbox\" for BOOLEAN type\n element = document.createElement(\"input\");\n element.type = \"checkbox\";\n elementTypeClass = \"magicfeedback-boolean\";\n break;\n default:\n return; // Skip unknown types\n }\n element.id = `magicfeedback-${id}`;\n element.setAttribute(\"name\", ref);\n if (defaultValue !== undefined) {\n element.value = defaultValue;\n }\n // Add the label and input element to the form\n const label = document.createElement(\"label\");\n label.setAttribute(\"for\", `magicfeedback-${id}`);\n label.textContent = title;\n label.classList.add(\"magicfeedback-label\");\n elementContainer.appendChild(label);\n element.classList.add(elementTypeClass);\n if (type != \"RADIO\" && type != \"MULTIPLECHOICE\") {\n element.classList.add(\"magicfeedback-input\");\n element.required =\n require.toLocaleLowerCase() === \"true\" ? true : false;\n }\n elementContainer.appendChild(element);\n form.appendChild(elementContainer);\n });\n // Submit button\n if (options.addButton) {\n // Create a submit button if specified in options\n const submitButton = document.createElement(\"button\");\n submitButton.type = \"submit\";\n submitButton.textContent = \"Submit\";\n submitButton.classList.add(\"magicfeedback-submit\");\n form.appendChild(submitButton);\n }\n // Add the form to the specified container\n container.appendChild(form);\n // Submit event\n form.addEventListener(\"submit\", (event) => __awaiter(this, void 0, void 0, function* () {\n event.preventDefault();\n try {\n // BEFORE\n if (options.beforeSubmitEvent) {\n yield options.beforeSubmitEvent();\n }\n // SEND\n const response = yield this.send();\n // AFTER\n if (options.afterSubmitEvent) {\n yield options.afterSubmitEvent(response);\n }\n return response;\n }\n catch (error) {\n // Handle error in beforeSubmitEvent, send(), or afterSubmitEvent\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n return error;\n }\n }));\n }\n /**\n * Answer\n * @param appId\n * @returns\n * TODO: Required\n */\n answer() {\n const form = document.getElementById(\"magicfeedback-\" + this.appId);\n if (!form) {\n this.log.err(`Form \"${form}\" not found.`);\n return [];\n }\n const surveyAnswers = [];\n let hasError = false; // Flag to track if an error has occurred\n const inputs = form.querySelectorAll(\".magicfeedback-input\");\n inputs.forEach((input) => {\n const inputType = input.type;\n //const required = (input as HTMLInputElement).required;\n const ans = {\n id: input.name,\n type: inputType,\n value: [],\n };\n const value = input.value;\n if (inputType === \"radio\" || inputType === \"checkbox\") {\n if (input.checked) {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n }\n else {\n ans.value.push(value);\n surveyAnswers.push(ans);\n }\n });\n if (hasError) {\n return []; // Stop the process if there's an error\n }\n return surveyAnswers;\n }\n /**\n * Send\n * @returns\n */\n send() {\n return __awaiter(this, void 0, void 0, function* () {\n // Define the URL and request payload\n const url = `${this.config.get(\"url\")}/feedback/apps`;\n try {\n // Get the survey answers from the answer() function\n const surveyAnswers = this.answer();\n if (surveyAnswers.length === 0) {\n throw new Error(\"No answers provided\");\n }\n // Make the AJAX POST request\n const response = yield this.request.post(url, {\n appId: this.appId,\n answers: surveyAnswers,\n });\n if (response.ok) {\n // Handle success response\n this.log.log(`Form ${this.appId} submitted successfully!`);\n // You can perform additional actions here if needed\n }\n else {\n // Handle error response\n this.log.err(`Failed to submit form ${this.appId}:`, response.status, response.statusText);\n throw new Error(response.statusText);\n }\n return response;\n }\n catch (error) {\n // Handle network or request error\n this.log.err(`An error occurred while submitting the form ${this.appId}:`, error);\n // You can perform error handling logic here if needed\n throw error;\n }\n });\n }\n}\nexports.Form = Form;\n\n\n//# sourceURL=webpack://magicfeedback/./src/form.ts?");
|
|
40
40
|
|
|
41
41
|
/***/ }),
|
|
42
42
|
|
|
@@ -66,7 +66,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
66
66
|
\*********************/
|
|
67
67
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
68
68
|
|
|
69
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst form_1 = __webpack_require__(/*! ./form */ \"./src/form.ts\");\nconst config_1 = __webpack_require__(/*! ./config */ \"./src/config.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\n/**\n *\n * @returns\n */\nfunction main() {\n //===============================================\n // Attributes\n //===============================================\n const config = new config_1.Config();\n const request = new request_1.Request();\n let log;\n //===============================================\n // Private\n //===============================================\n //===============================================\n // Public\n //===============================================\n /**\n *\n * @param options\n */\n function init(options) {\n if (options === null || options === void 0 ? void 0 : options.url)\n config.set(\"url\", options === null || options === void 0 ? void 0 : options.url);\n if (options === null || options === void 0 ? void 0 : options.debug)\n config.set(\"debug\", options === null || options === void 0 ? void 0 : options.debug);\n log = new log_1.Log(config);\n log.log(\"Initialized Magicfeedback\",
|
|
69
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst request_1 = __webpack_require__(/*! ./request */ \"./src/request.ts\");\nconst form_1 = __webpack_require__(/*! ./form */ \"./src/form.ts\");\nconst config_1 = __webpack_require__(/*! ./config */ \"./src/config.ts\");\nconst log_1 = __webpack_require__(/*! ./log */ \"./src/log.ts\");\n/**\n *\n * @returns\n */\nfunction main() {\n //===============================================\n // Attributes\n //===============================================\n const config = new config_1.Config();\n const request = new request_1.Request();\n let log;\n //===============================================\n // Private\n //===============================================\n //===============================================\n // Public\n //===============================================\n /**\n *\n * @param options\n */\n function init(options) {\n if (options === null || options === void 0 ? void 0 : options.url)\n config.set(\"url\", options === null || options === void 0 ? void 0 : options.url);\n if (options === null || options === void 0 ? void 0 : options.debug)\n config.set(\"debug\", options === null || options === void 0 ? void 0 : options.debug);\n log = new log_1.Log(config);\n log.log(\"Initialized Magicfeedback\", config);\n }\n /**\n *\n * @param appId\n * @param answers\n * @param profile\n * @returns\n */\n function send(appId, answers, profile) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!appId)\n log.err(\"No appID provided\");\n if (!answers)\n log.err(\"No answers provided\");\n if (answers.length == 0)\n log.err(\"Answers are empty\");\n const payload = {\n appId: appId,\n answers: answers,\n };\n if (profile)\n payload.profile = profile;\n let res = {};\n try {\n res = yield request.post(`${config.get(\"url\")}/feedback/apps`, payload);\n log.log(`sent native feedback`, res);\n }\n catch (e) {\n log.err(`error native feedback`, e);\n }\n return res;\n });\n }\n /**\n *\n * @param appId\n * @returns\n */\n function form(appId) {\n if (!appId)\n log.err(\"No appID provided\");\n return new form_1.Form(config, appId);\n }\n //===============================================\n // Return\n //===============================================\n return {\n // lifecycle\n init,\n // requests\n send,\n form,\n };\n}\nexports[\"default\"] = main;\n\n\n//# sourceURL=webpack://magicfeedback/./src/main.ts?");
|
|
70
70
|
|
|
71
71
|
/***/ }),
|
|
72
72
|
|
|
@@ -96,7 +96,7 @@ module.exports = require("cross-fetch");
|
|
|
96
96
|
\**********************/
|
|
97
97
|
/***/ ((module) => {
|
|
98
98
|
|
|
99
|
-
eval("module.exports = JSON.parse('{\"name\":\"@magicfeedback/native\",\"version\":\"1.0.
|
|
99
|
+
eval("module.exports = JSON.parse('{\"name\":\"@magicfeedback/native\",\"version\":\"1.0.5\",\"main\":\"./dist/magicfeedback-sdk.node.js\",\"browser\":\"./dist/magicfeedback-sdk.browser.js\",\"types\":\"./dist/types/src/index.d.ts\",\"repository\":{\"type\":\"git\",\"url\":\"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git\"},\"author\":\"farias@magicfeedback.io\",\"license\":\"MIT\",\"private\":false,\"scripts\":{\"dev\":\"vite\",\"build\":\"webpack\",\"build:watch\":\"webpack --watch --mode development\",\"test\":\"jest\",\"test:watch\":\"jest --watchAll\",\"coverage\":\"vitest run --coverage\"},\"files\":[\"dist\"],\"devDependencies\":{\"@babel/preset-typescript\":\"^7.22.5\",\"@types/node\":\"^17.0.21\",\"@types/webpack\":\"^5.28.0\",\"@types/webpack-node-externals\":\"^2.5.3\",\"c8\":\"^7.11.0\",\"jest\":\"^29.5.0\",\"jest-environment-jsdom\":\"^29.5.0\",\"jest-fetch-mock\":\"^3.0.3\",\"nock\":\"^13.2.4\",\"ts-jest\":\"^29.1.0\",\"ts-loader\":\"^9.2.7\",\"ts-node\":\"^10.7.0\",\"typescript\":\"^4.6.2\",\"vite\":\"^2.8.0\",\"vite-plugin-dts\":\"^0.9.9\",\"vitest\":\"^0.5.9\",\"webpack\":\"^5.70.0\",\"webpack-cli\":\"^4.9.2\",\"webpack-node-externals\":\"^3.0.0\"},\"dependencies\":{\"cross-fetch\":\"^3.1.5\",\"is-bundling-for-browser-or-node\":\"^1.1.1\"},\"description\":\"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)\",\"bugs\":{\"url\":\"https://github.com/MagicFeedback/magicfeedback-sdk/issues\"},\"homepage\":\"https://github.com/MagicFeedback/magicfeedback-sdk#readme\",\"directories\":{\"example\":\"examples\",\"test\":\"test\"}}');\n\n//# sourceURL=webpack://magicfeedback/./package.json?");
|
|
100
100
|
|
|
101
101
|
/***/ })
|
|
102
102
|
|