Comparing version 0.4.0 to 0.5.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.hasoopMethod = exports.sqoopAction = exports.linkType = exports.genericType = exports.connectorType = undefined; | ||
exports.jobStatusTypes = exports.hasoopMethodTypes = exports.sqoopConnectorCount = exports.version = exports.simpleVersion = exports.sqoopAction = exports.linkType = exports.genericType = exports.connectorType = undefined; | ||
@@ -54,10 +54,18 @@ var _keymirror = require('keymirror'); | ||
var simpleVersion = exports.simpleVersion = '1'; | ||
var version = exports.version = 'v1'; | ||
var sqoopConnectorCount = exports.sqoopConnectorCount = 7; | ||
/** | ||
* type of all hasoop method | ||
*/ | ||
var hasoopMethod = exports.hasoopMethod = (0, _keymirror2.default)({ | ||
var hasoopMethodTypes = exports.hasoopMethodTypes = (0, _keymirror2.default)({ | ||
// version | ||
getVersion: null, | ||
// driver | ||
getDriver: null, | ||
// connector | ||
getConnectorAll: null, | ||
getConnectorByConnectorName: null, | ||
// link | ||
getLinkAll: null, | ||
@@ -72,2 +80,3 @@ getLinkByConnectorName: null, | ||
deleteLinkAll: null, | ||
// job | ||
getJobAll: null, | ||
@@ -82,2 +91,3 @@ getJobByJobName: null, | ||
deleteJobAll: null, | ||
// submission | ||
startJob: null, | ||
@@ -88,2 +98,7 @@ stopJob: null, | ||
getSubmissionByJobName: null | ||
}); | ||
}); | ||
var jobStatusTypes = exports.jobStatusTypes = { | ||
allJobStatus: ['BOOTING', 'FAILURE_ON_SUBMIT', 'RUNNING', 'SUCCEEDED', 'FAILED', 'NEVER_EXECUTED', 'UNKNOWN'], | ||
startJobSucceedStatus: ['BOOTING', 'RUNNING', 'SUCCEEDED'] | ||
}; |
@@ -6,3 +6,2 @@ 'use strict'; | ||
}); | ||
exports.version = undefined; | ||
@@ -29,2 +28,14 @@ var _regenerator = require('babel-runtime/regenerator'); | ||
var _dispose = require('./dispose'); | ||
Object.keys(_dispose).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _dispose[key]; | ||
} | ||
}); | ||
}); | ||
var _utils = require('./utils'); | ||
@@ -72,9 +83,8 @@ | ||
var version = exports.version = 'v1'; | ||
var versionUri = 'version'; | ||
var driverUri = version + '/driver'; | ||
var connectorUri = version + '/connector'; | ||
var linkUri = version + '/link'; | ||
var jobUri = version + '/job'; | ||
var submissionsUri = version + '/submissions'; | ||
var driverUri = _constant.version + '/driver'; | ||
var connectorUri = _constant.version + '/connector'; | ||
var linkUri = _constant.version + '/link'; | ||
var jobUri = _constant.version + '/job'; | ||
var submissionsUri = _constant.version + '/submissions'; | ||
@@ -144,3 +154,3 @@ /** | ||
case 0: | ||
if (Object.keys(_constant.hasoopMethod).includes(methodName)) { | ||
if (Object.keys(_constant.hasoopMethodTypes).includes(methodName)) { | ||
_context.next = 2; | ||
@@ -374,3 +384,3 @@ break; | ||
_context2.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkAll); | ||
return this.launchRequest(_constant.hasoopMethodTypes.getLinkAll); | ||
@@ -461,3 +471,3 @@ case 2: | ||
_context3.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['fromLinkName']); | ||
return this.launchRequest(_constant.hasoopMethodTypes.getLinkByLinkName, config['fromLinkName']); | ||
@@ -467,3 +477,3 @@ case 2: | ||
_context3.next = 5; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['toLinkName']); | ||
return this.launchRequest(_constant.hasoopMethodTypes.getLinkByLinkName, config['toLinkName']); | ||
@@ -503,3 +513,3 @@ case 5: | ||
var _ref8 = _asyncToGenerator(_regenerator2.default.mark(function _callee4(oldJobName, config) { | ||
var oldJobConfig, fromLinkInfo, toLinkInfo, body, url; | ||
var oldJobConfig, updateJobConfig, jobName, fromLinkName, toLinkName, fromLinkInfo, toLinkInfo, body, url; | ||
return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
@@ -511,3 +521,3 @@ while (1) { | ||
_context4.next = 3; | ||
return this.launchRequest(_constant.hasoopMethod.getJobByJobName, oldJobName); | ||
return this.launchRequest(_constant.hasoopMethodTypes.getJobByJobName, oldJobName); | ||
@@ -517,17 +527,25 @@ case 3: | ||
oldJobConfig = (0, _context4.t0)(_context4.t1); | ||
_context4.next = 7; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['fromLinkName']); | ||
updateJobConfig = { | ||
schemaName: config.jobConfig.schemaName || oldJobConfig.fromSchemaName, | ||
tableName: config.jobConfig.tableName || oldJobConfig.fromTableName, | ||
outputDirectory: config.jobConfig.outputDirectory || oldJobConfig.toOutputDirectory | ||
}; | ||
jobName = config.jobName || oldJobConfig.topName; | ||
fromLinkName = config.fromLinkName || oldJobConfig.topFromLinkName; | ||
toLinkName = config.toLinkName || oldJobConfig.topToLinkName; | ||
_context4.next = 11; | ||
return this.launchRequest(_constant.hasoopMethodTypes.getLinkByLinkName, fromLinkName); | ||
case 7: | ||
case 11: | ||
fromLinkInfo = _context4.sent; | ||
_context4.next = 10; | ||
return this.launchRequest(_constant.hasoopMethod.getLinkByLinkName, config['toLinkName']); | ||
_context4.next = 14; | ||
return this.launchRequest(_constant.hasoopMethodTypes.getLinkByLinkName, toLinkName); | ||
case 10: | ||
case 14: | ||
toLinkInfo = _context4.sent; | ||
body = (0, _setJobOptions.setUpdateJobRequestBody)(config.jobName, config.jobConfig, fromLinkInfo, toLinkInfo, oldJobConfig.topId); | ||
body = (0, _setJobOptions.setUpdateJobRequestBody)(jobName, updateJobConfig, fromLinkInfo, toLinkInfo, oldJobConfig.topId); | ||
url = this.formatUrl([jobUri], oldJobName); | ||
return _context4.abrupt('return', (0, _sendRequest.sendPutRequest)(url, JSON.stringify(body))); | ||
case 14: | ||
case 18: | ||
case 'end': | ||
@@ -607,3 +625,3 @@ return _context4.stop(); | ||
_context5.next = 2; | ||
return this.launchRequest(_constant.hasoopMethod.getJobAll); | ||
return this.launchRequest(_constant.hasoopMethodTypes.getJobAll); | ||
@@ -610,0 +628,0 @@ case 2: |
@@ -6,8 +6,6 @@ 'use strict'; | ||
}); | ||
exports.splitSubmissionConfig = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /** | ||
* Created by Chyroc on 17/1/15. | ||
*/ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports.expectSqoopHeaders = expectSqoopHeaders; | ||
@@ -25,2 +23,9 @@ exports.splitLinkConfig = splitLinkConfig; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** | ||
* Created by Chyroc on 17/1/15. | ||
*/ | ||
function expectSqoopHeaders(res) { | ||
@@ -38,2 +43,12 @@ (0, _chai.expect)(res.headers.get('sqoop-error-code')).to.equal('1000'); | ||
var stringDecode = function stringDecode(value) { | ||
return _lodash2.default.isString(value) ? decodeURIComponent(value) : value; | ||
}; | ||
var keyCamelCaseValueDecode = function keyCamelCaseValueDecode(data) { | ||
return (0, _lodash2.default)(data).toPairs().map(function (keyValue) { | ||
return [_lodash2.default.camelCase(keyValue[0]), stringDecode(keyValue[1])]; | ||
}).fromPairs().value(); | ||
}; | ||
/** | ||
@@ -43,10 +58,11 @@ * @ignore | ||
function splitInputsConfig(configs) { | ||
var inputConfig = {}; | ||
_lodash2.default.map(configs, function (config) { | ||
_lodash2.default.map(config.inputs, function (input) { | ||
var nameSplit = input.name.split('.'); | ||
_lodash2.default.set(inputConfig, nameSplit[1], input.value || null); | ||
}); | ||
}); | ||
return inputConfig; | ||
var configListObject = (0, _lodash2.default)(configs).map('inputs').flatten().map(function (_ref) { | ||
var name = _ref.name, | ||
_ref$value = _ref.value, | ||
value = _ref$value === undefined ? null : _ref$value; | ||
var nameSplit = name.split('.'); | ||
return _defineProperty({}, nameSplit[1], stringDecode(value)); | ||
}).value(); | ||
return _lodash2.default.merge.apply(_lodash2.default, _toConsumableArray(configListObject)); | ||
} | ||
@@ -63,7 +79,3 @@ | ||
var otherConfig = splitInputsConfig(_lodash2.default.get(linkInfo, 'links[0].link-config-values.configs')); | ||
var linkConfig = {}; | ||
_lodash2.default.map(_extends({}, topConfig, otherConfig), function (value, key) { | ||
return _lodash2.default.set(linkConfig, _lodash2.default.camelCase(key), _lodash2.default.isString(value) ? decodeURIComponent(value) : value); | ||
}); | ||
return linkConfig; | ||
return keyCamelCaseValueDecode(_extends({}, topConfig, otherConfig)); | ||
} | ||
@@ -82,4 +94,3 @@ | ||
var driverConfig = splitInputsConfig(_lodash2.default.get(jobInfo, 'jobs[0].driver-config-values.configs')); | ||
var jobConfig = {}; | ||
_lodash2.default.map(_extends({}, _lodash2.default.mapKeys(topConfig, function (value, key) { | ||
return keyCamelCaseValueDecode(_extends({}, _lodash2.default.mapKeys(topConfig, function (value, key) { | ||
return 'top_' + key; | ||
@@ -92,6 +103,11 @@ }), _lodash2.default.mapKeys(driverConfig, function (value, key) { | ||
return 'to_' + key; | ||
})), function (value, key) { | ||
return _lodash2.default.set(jobConfig, _lodash2.default.camelCase(key), _lodash2.default.isString(value) ? decodeURIComponent(value) : value); | ||
}); | ||
return jobConfig; | ||
} | ||
}))); | ||
} | ||
var splitSubmissionConfig = exports.splitSubmissionConfig = function splitSubmissionConfig(submissionInfo) { | ||
return { | ||
topConfig: keyCamelCaseValueDecode(splitTopConfig(_lodash2.default.get(submissionInfo, 'submissions[0]'))), | ||
fromSchemaConfig: _lodash2.default.get(submissionInfo, 'submissions[0].from-schema', {}), | ||
toSchemaConfig: _lodash2.default.get(submissionInfo, 'submissions[0].to-schema', {}) | ||
}; | ||
}; |
{ | ||
"name": "hasoop", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62903
10
1470