nqm-common-import
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -44,3 +44,3 @@ /** | ||
buildSchema(schema[k], v); | ||
} else if (typeof v === "string" && k !== "type") { | ||
} else if (typeof v === "string" && k !== "__tdxType") { | ||
schema[k] = { type: v }; | ||
@@ -53,15 +53,12 @@ } else { | ||
}; | ||
function createTargetDataset(commandHost, accessToken, name, schema, primaryKey, cb) { | ||
var url = util.format("%s/commandSync/dataset/create", commandHost); | ||
function createTargetDataset(commandHost, accessToken, targetFolder, name, basedOn, schema, primaryKey, cb) { | ||
var url = util.format("%s/commandSync/resource/create", commandHost); | ||
var data = {}; | ||
data.parentId = targetFolder; | ||
data.name = name; | ||
data.uniqueIndex = _.map(primaryKey, function(key) { return { asc: key }} ); | ||
data.schema = {}; | ||
buildSchema(data.schema, schema); | ||
_.forEach(primaryKey, function(key) { | ||
var pointer = parser.DotNotationPointers(data.schema, key)[0]; | ||
pointer.val.index = true; | ||
pointer.val.unique = true; | ||
}); | ||
data.basedOnSchema = basedOn; | ||
data.schema = { dataSchema: schema }; | ||
data.schema.uniqueIndex = _.map(primaryKey, function(key) { return { asc: key }} ); | ||
// buildSchema(data.schema.dataSchema, schema); | ||
log("sending create dataset [%j]",data); | ||
@@ -116,4 +113,5 @@ request({ url: url, method: "post", headers: { authorization: "Bearer " + accessToken }, json: true, body: data }, function(err, response, content) { | ||
bulk.payload = data; | ||
log("sending createMany [%d - %d bytes]",data.length, JSON.stringify(data).length); | ||
request({ url: url, timeout: 3600000, method: "post", headers: { authorization: "Bearer " + accessToken }, json: true, body: bulk }, function(err, response, content) { | ||
var requestOptions = { url: url, timeout: 3600000, method: "post", headers: { authorization: "Bearer " + accessToken }, json: true, body: bulk }; | ||
log("sending createMany [%d - %d bytes] to %s using token %s",data.length, JSON.stringify(data).length, url, accessToken); | ||
request(requestOptions, function(err, response, content) { | ||
if (err || response.statusCode !== 200 || response.body.error) { | ||
@@ -120,0 +118,0 @@ err = err || new Error(response.body.error || "not found"); |
@@ -94,10 +94,13 @@ /** | ||
var flattened = exports.flattenSchema(schema); | ||
// Create a lookup for all possible target fields, and determine | ||
// if the target is an array. | ||
// Create a lookup for all possible target fields | ||
var fieldMap = {}; | ||
_.forEach(flattened, function(v,k) { | ||
fieldMap[k] = { | ||
name: k, | ||
type: v.type ? v.type : v | ||
}; | ||
var comps = k.split("."); | ||
var last = comps.splice(-1,1); | ||
if (last[0].indexOf("__tdxType") !== 0) { | ||
fieldMap[k] = { | ||
name: k, | ||
type: v.__tdxType ? v.__tdxType : v | ||
}; | ||
} | ||
}); | ||
@@ -104,0 +107,0 @@ |
{ | ||
"name": "nqm-common-import", | ||
"version": "0.0.4", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nqminds/nqm-common-import.git" | ||
}, | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -5,0 +9,0 @@ "main": "index.js", |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10619
274
2