varsnap 1.9.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/dist/browser.js +25 -50
- package/dist/browser.min.js +3 -3
- package/dist/node.js +13 -24
- package/dist/node.min.js +3 -3
- package/package.json +2 -5
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Varsnap.js v1.
|
|
1
|
+
/*! Varsnap.js v1.10.0 */
|
|
2
2
|
/*
|
|
3
3
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
4
4
|
* This devtool is neither made for production nor for readable output files.
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
11
11
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
12
|
-
module.exports = factory(
|
|
12
|
+
module.exports = factory();
|
|
13
13
|
else if(typeof define === 'function' && define.amd)
|
|
14
|
-
define([
|
|
14
|
+
define([], factory);
|
|
15
15
|
else if(typeof exports === 'object')
|
|
16
|
-
exports["varsnap"] = factory(
|
|
16
|
+
exports["varsnap"] = factory();
|
|
17
17
|
else
|
|
18
|
-
root["varsnap"] = factory(
|
|
19
|
-
})(this, (
|
|
18
|
+
root["varsnap"] = factory();
|
|
19
|
+
})(this, () => {
|
|
20
20
|
return /******/ (() => { // webpackBootstrap
|
|
21
21
|
/******/ var __webpack_modules__ = ({
|
|
22
22
|
|
|
@@ -640,18 +640,18 @@ eval("\nconst os = __webpack_require__(/*! os */ \"os\");\nconst hasFlag = __web
|
|
|
640
640
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
641
641
|
|
|
642
642
|
"use strict";
|
|
643
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.runTests = exports.varsnap = exports.Consumer = exports.Producer = exports.Util = exports.clientName = exports.version = void 0;\nconst axios_1 = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\nconst produceURL = 'https://www.varsnap.com/api/snap/produce/';\nconst consumeURL = 'https://www.varsnap.com/api/snap/consume/';\nconst produceTrialURL = 'https://www.varsnap.com/api/trial/produce/';\nconst trialGroupURL = 'https://www.varsnap.com/api/trial_group/';\nexports.version = '1.9.1';\nexports.clientName = 'javascript.' + exports.version;\nconst defaultConfig = {\n varsnap: true,\n env: 'development',\n branch: '',\n producerToken: '',\n consumerToken: '',\n logger: console, // eslint-disable-line no-console\n};\nlet Producers = [];\nlet Consumers = [];\nclass Util {\n static getConfig(config, configKey) {\n if (!config) {\n return '';\n }\n let val = config[configKey];\n if (!val) {\n return '';\n }\n val = val.toString().toLowerCase();\n return val;\n }\n static setConfig(config, configKey, configValue) {\n if (configKey === 'varsnap') {\n if (typeof configValue === 'string') {\n configValue = configValue === 'true';\n }\n config[configKey] = configValue;\n }\n if (configKey === 'env' || configKey === 'producerToken' || configKey === 'consumerToken' || configKey === 'branch') {\n config[configKey] = configValue;\n }\n if (configKey === 'logger') {\n config[configKey] = configValue;\n }\n return config;\n }\n static getSignature(targetFunc, funcName) {\n let signature = '';\n if (funcName !== '' && funcName !== undefined) {\n signature = funcName;\n }\n else {\n // Remove any implementation code from signature\n signature = targetFunc.toString().split('{')[0];\n // Trim preceding and trailing whitespace\n signature = signature.replace(/^\\s+|\\s+$/g, '');\n // Trim whitespace between comma separated arguments\n signature = signature.replace(/,\\s+/g, ',');\n }\n return 'javascript.' + exports.version + '.' + signature;\n }\n static ajax(url, requestData) {\n const requestParams = new URLSearchParams(requestData);\n const data = requestParams.toString();\n const options = {\n method: 'POST',\n url: url,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n data: data,\n responseType: 'json',\n };\n if (Util.isNode() && options.headers) {\n options.headers['User-Agent'] = 'varsnap.js';\n }\n const ajaxPromise = (0, axios_1.default)(options).then((response) => {\n return response.data;\n }).catch((error) => {\n return error;\n });\n return ajaxPromise;\n }\n static debug(config, data) {\n if (config.logger) {\n config.logger.debug(data);\n }\n }\n static log(config, data) {\n if (config.logger) {\n config.logger.log(data);\n }\n }\n static error(config, data) {\n if (config.logger) {\n config.logger.error(data);\n }\n }\n static resetProducers() {\n Producers = [];\n }\n static resetConsumers() {\n Consumers = [];\n }\n static getProducers() {\n return Producers;\n }\n static getConsumers() {\n return Consumers;\n }\n static limitString(x) {\n const limitedString = String(x);\n const limit = 30;\n const ellipsis = '...';\n if (limitedString.length <= limit) {\n return limitedString;\n }\n return limitedString.substring(0, 30 - ellipsis.length) + ellipsis;\n }\n static isNode() {\n if (typeof process !== 'object') {\n return false;\n }\n if (typeof window !== 'undefined') {\n return false;\n }\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n static getBranch(config) {\n return new Promise((resolve) => {\n return resolve('');\n });\n }\n}\nexports.Util = Util;\nclass Producer {\n constructor(targetFunc, signature, config) {\n this.targetFunc = targetFunc;\n this.signature = signature;\n this.config = config;\n }\n isEnabled() {\n if (!this.config.varsnap) {\n return false;\n }\n if (Util.getConfig(this.config, 'env') !== 'production') {\n return false;\n }\n if (!Util.getConfig(this.config, 'producerToken')) {\n return false;\n }\n return true;\n }\n static serialize(data) {\n return JSON.stringify(data);\n }\n static serialize_formatted(data) {\n return JSON.stringify(data, null, 2);\n }\n produce(args, output) {\n if (!this.isEnabled()) {\n const errorPromise = new Promise((resolve) => {\n return resolve(false);\n });\n return errorPromise;\n }\n Util.debug(this.config, 'Sending call to Varsnap');\n return Promise.resolve(output).then((outputValue) => {\n const data = {\n 'producer_token': Util.getConfig(this.config, 'producerToken'),\n 'signature': this.signature,\n 'inputs': Producer.serialize(args),\n 'prod_outputs': Producer.serialize(outputValue),\n };\n return Util.ajax(produceURL, data).then(() => {\n return true;\n }).catch((err) => {\n if (err.response) {\n if (err.response.status === 429) {\n Util.error(this.config, 'Cannot produce to Varsnap; Signature at rate limit');\n return true;\n }\n if (err.response.status === 404) {\n Util.error(this.config, 'Cannot produce to Varsnap; check your producer token');\n }\n else {\n Util.error(this.config, err.response.statusText);\n }\n }\n return false;\n });\n });\n }\n}\nexports.Producer = Producer;\nclass Consumer {\n constructor(targetFunc, signature, config) {\n this.targetFunc = targetFunc;\n this.signature = signature;\n this.config = config;\n }\n isEnabled() {\n if (!this.config.varsnap) {\n return false;\n }\n if (Util.getConfig(this.config, 'env') !== 'development') {\n return false;\n }\n if (!Util.getConfig(this.config, 'consumerToken')) {\n return false;\n }\n return true;\n }\n static deserialize(data) {\n if (data === '') {\n return undefined;\n }\n return JSON.parse(data);\n }\n consume(trialGroup) {\n if (!this.isEnabled()) {\n const errorPromise = new Promise((resolve) => {\n Util.error(this.config, 'Varsnap not enabled for testing');\n return resolve(false);\n });\n return errorPromise;\n }\n const data = {\n 'consumer_token': Util.getConfig(this.config, 'consumerToken'),\n 'signature': this.signature,\n };\n const ajax = Util.ajax(consumeURL, data);\n const consume = ajax.then((rawResponse) => {\n const response = rawResponse;\n if (!response || response.status !== 'ok') {\n const errorPromise = new Promise((resolve) => {\n Util.error(this.config, 'Received error from Varsnap: ' + response.status);\n return resolve(false);\n });\n return [errorPromise];\n }\n if (response.results.length === 0) {\n Util.log(this.config, 'No snaps found for signature: ' + data.signature);\n }\n const trialPromises = [];\n for (const snap of response.results) {\n const inputs = Consumer.deserialize(snap['inputs']);\n const prodOutputs = Consumer.deserialize(snap['prod_outputs']);\n let localOutputs;\n try {\n localOutputs = this.targetFunc(...inputs);\n }\n catch (err) {\n localOutputs = err;\n }\n const trialPromise = Promise.resolve(localOutputs).then((localOutputValue) => {\n const prodOutputsSerialized = Producer.serialize(prodOutputs);\n const localOutputsSerialized = Producer.serialize(localOutputValue);\n const matches = prodOutputsSerialized === localOutputsSerialized;\n this.reportCentral(trialGroup, snap, prodOutputs, localOutputValue, matches).then((trialURL) => {\n this.reportLog(snap['id'], inputs, prodOutputs, localOutputValue, matches, trialURL);\n });\n return matches;\n });\n trialPromises.push(trialPromise);\n }\n return trialPromises;\n }).then((trialPromises) => {\n return Promise.all(trialPromises).then((results) => {\n const allMatches = results.every((result) => result);\n return allMatches;\n });\n }).catch((error) => {\n Util.error(this.config, 'Cannot contact Varsnap: ' + error);\n return false;\n });\n return consume;\n }\n reportCentral(trialGroup, snap, prodOutputs, localOutputs, matches) {\n const data = {\n 'trial_group_id': trialGroup.trial_group_id,\n 'consumer_token': Util.getConfig(this.config, 'consumerToken'),\n 'snap_id': snap.id,\n 'test_outputs': Producer.serialize(localOutputs),\n 'matches': matches.toString(),\n 'snap_outputs_formatted': Producer.serialize_formatted(prodOutputs),\n 'test_outputs_formatted': Producer.serialize_formatted(localOutputs),\n };\n const ajax = Util.ajax(produceTrialURL, data);\n const report = ajax.then((rawResponse) => {\n const response = rawResponse;\n if (!response || response.status !== 'ok') {\n return false;\n }\n const trialURL = response['trial_url'];\n return trialURL;\n }).catch((error) => {\n Util.error(this.config, 'Cannot upload test results to Varsnap: ' + error);\n return false;\n });\n return report;\n }\n reportLog(snapID, inputs, prodOutputs, localOutputs, matches, trialURL) {\n if (matches) {\n return;\n }\n Util.log(this.config, '');\n Util.log(this.config, 'Testing with Varsnap uuid: ' + snapID);\n Util.log(this.config, 'Signature: ' + this.signature);\n Util.log(this.config, 'Function input args: ' + Util.limitString(inputs));\n Util.log(this.config, 'Production function outputs: ' + Util.limitString(prodOutputs));\n Util.log(this.config, 'Your function outputs: ' + Util.limitString(localOutputs));\n Util.log(this.config, 'Matching outputs: ' + matches);\n let trialURLView = 'Cannot upload trial';\n if (trialURL) {\n trialURLView = String(trialURL);\n }\n Util.log(this.config, 'Trial URL: ' + trialURLView);\n }\n reportTrialGroup(trialGroup) {\n Util.log(this.config, 'Trial Group: ' + trialGroup.trial_group_url);\n }\n}\nexports.Consumer = Consumer;\nfunction varsnap(func, funcName) {\n if (funcName === undefined) {\n funcName = '';\n }\n const signature = Util.getSignature(func, funcName);\n const producer = new Producer(func, signature, varsnap._config);\n const consumer = new Consumer(func, signature, varsnap._config);\n const wrapped = function (...args) {\n let result;\n try {\n result = func(...args);\n }\n catch (err) {\n producer.produce(args, err);\n throw (err);\n }\n producer.produce(args, result);\n return result;\n };\n wrapped.producer = producer;\n wrapped.consumer = consumer;\n wrapped.signature = signature;\n Producers.push(producer);\n Consumers.push(consumer);\n return wrapped;\n}\nexports.varsnap = varsnap;\nvarsnap._config = defaultConfig;\nvarsnap.updateConfig = function updateConfig(newConfig) {\n let config = varsnap._config;\n for (const key of Object.keys(varsnap._config)) {\n if (Object.prototype.hasOwnProperty.call(newConfig, key)) {\n config = Util.setConfig(config, key, newConfig[key]);\n }\n }\n varsnap._config = config;\n};\nvarsnap.reset = function reset() {\n Util.resetConsumers();\n Util.resetProducers();\n};\nvarsnap.version = exports.version;\nfunction getTrialGroup(consumerConfig) {\n const getBranch = Util.getBranch(consumerConfig);\n const getRequestConfig = getBranch.then((branch) => {\n const data = {\n 'branch': branch,\n 'consumer_token': Util.getConfig(consumerConfig, 'consumerToken'),\n 'client': exports.clientName,\n };\n return data;\n });\n const ajax = getRequestConfig.then((data) => {\n const raw = data;\n return Util.ajax(trialGroupURL, raw);\n });\n const trialGroup = ajax.then((rawResponse) => {\n const response = rawResponse;\n return response;\n }).catch((error) => {\n let errorMessage = '';\n if (error && error.response && error.response.data) {\n const response = error.response.data;\n errorMessage = response.error;\n }\n else {\n errorMessage = error.toString();\n }\n Util.error(consumerConfig, 'Cannot generate a new Trial Group: ' + errorMessage);\n return {\n status: 'not ok',\n project_id: '',\n trial_group_id: '',\n trial_group_url: '',\n };\n });\n return trialGroup;\n}\nfunction runTests() {\n const consumers = Util.getConsumers();\n if (consumers.length === 0) {\n return Promise.resolve(true);\n }\n const consumerConfig = consumers[0].config;\n return getTrialGroup(consumerConfig).then((trialGroup) => {\n const testPromises = [];\n for (const consumer of consumers) {\n const testPromise = consumer.consume(trialGroup);\n testPromises.push(testPromise);\n }\n if (consumers.length > 0) {\n consumers[0].reportTrialGroup(trialGroup);\n }\n return Promise.all(testPromises);\n }).then((results) => {\n const allPass = results.every((result) => result);\n return allPass;\n });\n}\nexports.runTests = runTests;\nvarsnap.runTests = runTests;\n\n\n//# sourceURL=webpack://varsnap/./varsnap/core.ts?");
|
|
643
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.runTests = exports.varsnap = exports.Consumer = exports.Producer = exports.Util = exports.clientName = exports.version = void 0;\nconst axios_1 = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\nconst produceURL = 'https://www.varsnap.com/api/snap/produce/';\nconst consumeURL = 'https://www.varsnap.com/api/snap/consume/';\nconst produceTrialURL = 'https://www.varsnap.com/api/trial/produce/';\nconst trialGroupURL = 'https://www.varsnap.com/api/trial_group/';\nexports.version = '1.10.0';\nexports.clientName = 'javascript.' + exports.version;\nconst defaultConfig = {\n varsnap: true,\n env: 'development',\n branch: '',\n producerToken: '',\n consumerToken: '',\n logger: console, // eslint-disable-line no-console\n};\nlet Producers = [];\nlet Consumers = [];\nclass Util {\n static getConfig(config, configKey) {\n if (!config) {\n return '';\n }\n let val = config[configKey];\n if (!val) {\n return '';\n }\n val = val.toString().toLowerCase();\n return val;\n }\n static setConfig(config, configKey, configValue) {\n if (configKey === 'varsnap') {\n if (typeof configValue === 'string') {\n configValue = configValue === 'true';\n }\n config[configKey] = configValue;\n }\n if (configKey === 'env' || configKey === 'producerToken' || configKey === 'consumerToken' || configKey === 'branch') {\n config[configKey] = configValue;\n }\n if (configKey === 'logger') {\n config[configKey] = configValue;\n }\n return config;\n }\n static getSignature(targetFunc, funcName) {\n let signature = '';\n if (funcName !== '' && funcName !== undefined) {\n signature = funcName;\n }\n else {\n // Remove any implementation code from signature\n signature = targetFunc.toString().split('{')[0];\n // Trim preceding and trailing whitespace\n signature = signature.replace(/^\\s+|\\s+$/g, '');\n // Trim whitespace between comma separated arguments\n signature = signature.replace(/,\\s+/g, ',');\n }\n return 'javascript.' + exports.version + '.' + signature;\n }\n static ajax(url, requestData) {\n const requestParams = new URLSearchParams(requestData);\n const data = requestParams.toString();\n const options = {\n method: 'POST',\n url: url,\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n data: data,\n responseType: 'json',\n };\n if (Util.isNode() && options.headers) {\n options.headers['User-Agent'] = 'varsnap.js';\n }\n const ajaxPromise = (0, axios_1.default)(options).then((response) => {\n return response.data;\n }).catch((error) => {\n return error;\n });\n return ajaxPromise;\n }\n static debug(config, data) {\n if (config.logger) {\n config.logger.debug(data);\n }\n }\n static log(config, data) {\n if (config.logger) {\n config.logger.log(data);\n }\n }\n static error(config, data) {\n if (config.logger) {\n config.logger.error(data);\n }\n }\n static resetProducers() {\n Producers = [];\n }\n static resetConsumers() {\n Consumers = [];\n }\n static getProducers() {\n return Producers;\n }\n static getConsumers() {\n return Consumers;\n }\n static limitString(x) {\n const limitedString = String(x);\n const limit = 30;\n const ellipsis = '...';\n if (limitedString.length <= limit) {\n return limitedString;\n }\n return limitedString.substring(0, 30 - ellipsis.length) + ellipsis;\n }\n static isNode() {\n if (typeof process !== 'object') {\n return false;\n }\n if (typeof window !== 'undefined') {\n return false;\n }\n return true;\n }\n}\nexports.Util = Util;\nclass Producer {\n constructor(targetFunc, signature, config) {\n this.targetFunc = targetFunc;\n this.signature = signature;\n this.config = config;\n }\n isEnabled() {\n if (!this.config.varsnap) {\n return false;\n }\n if (Util.getConfig(this.config, 'env') !== 'production') {\n return false;\n }\n if (!Util.getConfig(this.config, 'producerToken')) {\n return false;\n }\n return true;\n }\n static serialize(data) {\n return JSON.stringify(data);\n }\n static serialize_formatted(data) {\n return JSON.stringify(data, null, 2);\n }\n produce(args, output) {\n if (!this.isEnabled()) {\n const errorPromise = new Promise((resolve) => {\n return resolve(false);\n });\n return errorPromise;\n }\n Util.debug(this.config, 'Sending call to Varsnap');\n return Promise.resolve(output).then((outputValue) => {\n const data = {\n 'producer_token': Util.getConfig(this.config, 'producerToken'),\n 'signature': this.signature,\n 'inputs': Producer.serialize(args),\n 'prod_outputs': Producer.serialize(outputValue),\n };\n return Util.ajax(produceURL, data).then(() => {\n return true;\n }).catch((err) => {\n if (err.response) {\n if (err.response.status === 429) {\n Util.error(this.config, 'Cannot produce to Varsnap; Signature at rate limit');\n return true;\n }\n if (err.response.status === 404) {\n Util.error(this.config, 'Cannot produce to Varsnap; check your producer token');\n }\n else {\n Util.error(this.config, err.response.statusText);\n }\n }\n return false;\n });\n });\n }\n}\nexports.Producer = Producer;\nclass Consumer {\n constructor(targetFunc, signature, config) {\n this.targetFunc = targetFunc;\n this.signature = signature;\n this.config = config;\n }\n isEnabled() {\n if (!this.config.varsnap) {\n return false;\n }\n if (Util.getConfig(this.config, 'env') !== 'development') {\n return false;\n }\n if (!Util.getConfig(this.config, 'consumerToken')) {\n return false;\n }\n return true;\n }\n static deserialize(data) {\n if (data === '') {\n return undefined;\n }\n return JSON.parse(data);\n }\n consume(trialGroup) {\n if (!this.isEnabled()) {\n const errorPromise = new Promise((resolve) => {\n Util.error(this.config, 'Varsnap not enabled for testing');\n return resolve(false);\n });\n return errorPromise;\n }\n const data = {\n 'consumer_token': Util.getConfig(this.config, 'consumerToken'),\n 'signature': this.signature,\n };\n const ajax = Util.ajax(consumeURL, data);\n const consume = ajax.then((rawResponse) => {\n const response = rawResponse;\n if (!response || response.status !== 'ok') {\n const errorPromise = new Promise((resolve) => {\n Util.error(this.config, 'Received error from Varsnap: ' + response.status);\n return resolve(false);\n });\n return [errorPromise];\n }\n if (response.results.length === 0) {\n Util.log(this.config, 'No snaps found for signature: ' + data.signature);\n }\n const trialPromises = [];\n for (const snap of response.results) {\n const inputs = Consumer.deserialize(snap['inputs']);\n const prodOutputs = Consumer.deserialize(snap['prod_outputs']);\n let localOutputs;\n try {\n localOutputs = this.targetFunc(...inputs);\n }\n catch (err) {\n localOutputs = err;\n }\n const trialPromise = Promise.resolve(localOutputs).then((localOutputValue) => {\n const prodOutputsSerialized = Producer.serialize(prodOutputs);\n const localOutputsSerialized = Producer.serialize(localOutputValue);\n const matches = prodOutputsSerialized === localOutputsSerialized;\n this.reportCentral(trialGroup, snap, prodOutputs, localOutputValue, matches).then((trialURL) => {\n this.reportLog(snap['id'], inputs, prodOutputs, localOutputValue, matches, trialURL);\n });\n return matches;\n });\n trialPromises.push(trialPromise);\n }\n return trialPromises;\n }).then((trialPromises) => {\n return Promise.all(trialPromises).then((results) => {\n const allMatches = results.every((result) => result);\n return allMatches;\n });\n }).catch((error) => {\n Util.error(this.config, 'Cannot contact Varsnap: ' + error);\n return false;\n });\n return consume;\n }\n reportCentral(trialGroup, snap, prodOutputs, localOutputs, matches) {\n const data = {\n 'trial_group_id': trialGroup.trial_group_id,\n 'consumer_token': Util.getConfig(this.config, 'consumerToken'),\n 'snap_id': snap.id,\n 'test_outputs': Producer.serialize(localOutputs),\n 'matches': matches.toString(),\n 'snap_outputs_formatted': Producer.serialize_formatted(prodOutputs),\n 'test_outputs_formatted': Producer.serialize_formatted(localOutputs),\n };\n const ajax = Util.ajax(produceTrialURL, data);\n const report = ajax.then((rawResponse) => {\n const response = rawResponse;\n if (!response || response.status !== 'ok') {\n return false;\n }\n const trialURL = response['trial_url'];\n return trialURL;\n }).catch((error) => {\n Util.error(this.config, 'Cannot upload test results to Varsnap: ' + error);\n return false;\n });\n return report;\n }\n reportLog(snapID, inputs, prodOutputs, localOutputs, matches, trialURL) {\n if (matches) {\n return;\n }\n Util.log(this.config, '');\n Util.log(this.config, 'Testing with Varsnap uuid: ' + snapID);\n Util.log(this.config, 'Signature: ' + this.signature);\n Util.log(this.config, 'Function input args: ' + Util.limitString(inputs));\n Util.log(this.config, 'Production function outputs: ' + Util.limitString(prodOutputs));\n Util.log(this.config, 'Your function outputs: ' + Util.limitString(localOutputs));\n Util.log(this.config, 'Matching outputs: ' + matches);\n let trialURLView = 'Cannot upload trial';\n if (trialURL) {\n trialURLView = String(trialURL);\n }\n Util.log(this.config, 'Trial URL: ' + trialURLView);\n }\n reportTrialGroup(trialGroup) {\n Util.log(this.config, 'Trial Group: ' + trialGroup.trial_group_url);\n }\n}\nexports.Consumer = Consumer;\nfunction varsnap(func, funcName) {\n if (funcName === undefined) {\n funcName = '';\n }\n const signature = Util.getSignature(func, funcName);\n const producer = new Producer(func, signature, varsnap._config);\n const consumer = new Consumer(func, signature, varsnap._config);\n const wrapped = function (...args) {\n let result;\n try {\n result = func(...args);\n }\n catch (err) {\n producer.produce(args, err);\n throw (err);\n }\n producer.produce(args, result);\n return result;\n };\n wrapped.producer = producer;\n wrapped.consumer = consumer;\n wrapped.signature = signature;\n Producers.push(producer);\n Consumers.push(consumer);\n return wrapped;\n}\nexports.varsnap = varsnap;\nvarsnap._config = defaultConfig;\nvarsnap.updateConfig = function updateConfig(newConfig) {\n let config = varsnap._config;\n for (const key of Object.keys(varsnap._config)) {\n if (Object.prototype.hasOwnProperty.call(newConfig, key)) {\n config = Util.setConfig(config, key, newConfig[key]);\n }\n }\n varsnap._config = config;\n};\nvarsnap.reset = function reset() {\n Util.resetConsumers();\n Util.resetProducers();\n};\nvarsnap.version = exports.version;\nfunction getTrialGroup(consumerConfig) {\n const data = {\n 'branch': Util.getConfig(consumerConfig, 'branch'),\n 'consumer_token': Util.getConfig(consumerConfig, 'consumerToken'),\n 'client': exports.clientName,\n };\n const raw = data;\n const ajax = Util.ajax(trialGroupURL, raw);\n const trialGroup = ajax.then((rawResponse) => {\n const response = rawResponse;\n return response;\n }).catch((error) => {\n let errorMessage = '';\n if (error && error.response && error.response.data) {\n const response = error.response.data;\n errorMessage = response.error;\n }\n else {\n errorMessage = error.toString();\n }\n Util.error(consumerConfig, 'Cannot generate a new Trial Group: ' + errorMessage);\n return {\n status: 'not ok',\n project_id: '',\n trial_group_id: '',\n trial_group_url: '',\n };\n });\n return trialGroup;\n}\nfunction runTests() {\n const consumers = Util.getConsumers();\n if (consumers.length === 0) {\n return Promise.resolve(true);\n }\n const consumerConfig = consumers[0].config;\n return getTrialGroup(consumerConfig).then((trialGroup) => {\n const testPromises = [];\n for (const consumer of consumers) {\n const testPromise = consumer.consume(trialGroup);\n testPromises.push(testPromise);\n }\n if (consumers.length > 0) {\n consumers[0].reportTrialGroup(trialGroup);\n }\n return Promise.all(testPromises);\n }).then((results) => {\n const allPass = results.every((result) => result);\n return allPass;\n });\n}\nexports.runTests = runTests;\nvarsnap.runTests = runTests;\n\n\n//# sourceURL=webpack://varsnap/./varsnap/core.ts?");
|
|
644
644
|
|
|
645
645
|
/***/ }),
|
|
646
646
|
|
|
647
|
-
/***/ "./varsnap/
|
|
648
|
-
|
|
649
|
-
!*** ./varsnap/
|
|
650
|
-
|
|
647
|
+
/***/ "./varsnap/index.ts":
|
|
648
|
+
/*!**************************!*\
|
|
649
|
+
!*** ./varsnap/index.ts ***!
|
|
650
|
+
\**************************/
|
|
651
651
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
652
652
|
|
|
653
653
|
"use strict";
|
|
654
|
-
eval("\nconst core = __webpack_require__(/*! ./core */ \"./varsnap/core.ts\");\
|
|
654
|
+
eval("\nconst core = __webpack_require__(/*! ./core */ \"./varsnap/core.ts\");\nmodule.exports = core.varsnap;\n\n\n//# sourceURL=webpack://varsnap/./varsnap/index.ts?");
|
|
655
655
|
|
|
656
656
|
/***/ }),
|
|
657
657
|
|
|
@@ -776,17 +776,6 @@ module.exports = require("zlib");
|
|
|
776
776
|
|
|
777
777
|
/***/ }),
|
|
778
778
|
|
|
779
|
-
/***/ "child_process":
|
|
780
|
-
/*!********************************!*\
|
|
781
|
-
!*** external "child_process" ***!
|
|
782
|
-
\********************************/
|
|
783
|
-
/***/ ((module) => {
|
|
784
|
-
|
|
785
|
-
"use strict";
|
|
786
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_child_process__;
|
|
787
|
-
|
|
788
|
-
/***/ }),
|
|
789
|
-
|
|
790
779
|
/***/ "./node_modules/mime-db/db.json":
|
|
791
780
|
/*!**************************************!*\
|
|
792
781
|
!*** ./node_modules/mime-db/db.json ***!
|
|
@@ -829,7 +818,7 @@ eval("module.exports = JSON.parse('{\"application/1d-interleaved-parityfec\":{\"
|
|
|
829
818
|
/******/ // startup
|
|
830
819
|
/******/ // Load entry module and return exports
|
|
831
820
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
832
|
-
/******/ var __webpack_exports__ = __webpack_require__("./varsnap/
|
|
821
|
+
/******/ var __webpack_exports__ = __webpack_require__("./varsnap/index.ts");
|
|
833
822
|
/******/
|
|
834
823
|
/******/ return __webpack_exports__;
|
|
835
824
|
/******/ })()
|