Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.handleValSubmit = (key, newVal) => {
if (!this.opts.onsubmit) {
return;
}
const ret = this.opts.val;
ret[key] = newVal;
// Delete the key if it's undefined.
forOwn(ret, (val, key) => {
if (isUndefined(val)) {
delete ret[key];
}
});
this.opts.onsubmit(ret);
};
this.handleChange = (name, value) => {
const values = ObjectAssign({}, this.opts.parametervalues, {
[name]: value
});
forOwn(values, (v, k) => {
// TODO: deleteするためのもっと良い方法を模索すること。
if (typeof v === 'string' && !v.length) {
delete values[k];
}
});
this.opts.onchange(this.opts.name, values);
};
}
case 'null':
ret._type = 'null';
ret._value = null;
ret._rawValue = null;
break;
case 'boolean':
ret._type = 'boolean';
ret._value = response;
ret._rawValue = response;
break;
case 'object':
ret._type = 'object';
ret._value = {};
ret._rawValue = response;
ret._keys = [];
forOwn(response, (v, k) => {
ret._keys.push(k);
let nextSchema;
if (!!schema.properties) {
nextSchema = schema.properties[k];
} else if (schema.additionalProperties) {
nextSchema = {};
} else {
// TODO: swagger定義が間違っているので警告を出す。
}
ret._value[k] = this.mergeSchemaAndResponse(nextSchema, v);
ret._value[k]._key = k;
});
break;
case 'array':
ret._type = 'array';
ret._value = [];
allWithoutToken: state => {
const version = state.application.version;
const endpoints = deepClone(state.endpoints[version]);
// 認証用トークンはexport対象外とする。
forOwn(endpoints, endpoint => {
delete endpoint.token;
});
return endpoints;
},
}).on('updated', () => {
const newCrossSearchQueries = this.opts.crosssearchqueries;
let isCrossSearchQueriesChanged = false;
// 値が一つでも違ったらtrue。
forOwn(newCrossSearchQueries, (value, key) => {
if (value !== prevCrossSearchQueries[key]) {
isCrossSearchQueriesChanged = true;
}
});
// 長さが違ってもtrue。
if (size(newCrossSearchQueries) !== size(prevCrossSearchQueries)) {
isCrossSearchQueriesChanged = true;
}
// 変更があればデータ更新。
if (isCrossSearchQueriesChanged) {
forOwn(newCrossSearchQueries, (value, key) => {
if (!isUndefined(value)) {
this.searchQueries[key] = value;
} else {
delete this.searchQueries[key];
}
});
this.hasSearchQueries = !!size(this.searchQueries);
// 検索クエリ変更時は強制的にページ番号を1に戻す。
if (!this.hasPagination) {
getData();
} else {
const pagination = {};
const size = this.pagination.size;
const current = 1;
pagination.limit = size;
pagination.offset = (current - 1) * size;
apisFlatObject() {
if (!this.client) {
return {};
}
const apis = {};
forOwn(this.client.apis, (v) => {
forOwn(v, (v1, k1) => {
apis[k1] = v1;
});
});
return apis;
}
const generateDefaultProperties = (schemaObject, val = {}) => {
const properties = schemaObject.properties;
const required = schemaObject.required || [];
forOwn(properties, (property, key) => {
if (contains(['boolean', 'integer', 'number', 'null', 'string'], property.type)) {
if (!isUndefined(val[key])) {
return;
}
if (isUndefined(property.default)) {
return;
}
val[key] = property.default;
}
if (property.type === 'object') {
if (!contains(required, key)) {
return;
}
val[key] = {};
generateDefaultProperties(property, val[key]);
}
parallel(tasks, cb) {
var results = {};
var completed = 0;
var length = 0;
forOwn(tasks, () => {
length += 1;
});
forOwn(tasks, function (task, key) {
task(function (err) {
var args = Array.prototype.slice.call(arguments, 1);
if (args.length <= 1) {
args = args[0];
}
results[key] = args;
done(err);
});
});
function done(err) {
completed += 1;
if (err || completed >= length) {
cb(err, results);
}
}
forEach(parameterObjects, parameterObject => {
const name = parameterObject.name;
if (parameterObject.in === 'body') {
queries[name] = {};
forOwn(parameterObject.schema.properties, (v, k) => {
if (rowData[k]) {
queries[name][k] = rowData[k];
}
});
} else {
if (!rowData[name]) {
return;
}
queries[name] = rowData[name];
}
});
mergeAll: (state, endpoints) => {
const version = state.application.version;
let modifiedEndpoints = ObjectAssign({}, state.endpoints[version]);
forOwn(endpoints, endpoint => {
let duplicatedEndpoint = find(modifiedEndpoints, val => {
return endpoint.url === val.url;
});
if (!duplicatedEndpoint) {
const key = shortid.generate();
endpoint.key = key;
modifiedEndpoints[key] = endpoint;
} else {
ObjectAssign(duplicatedEndpoint, endpoint);
}
});
modifiedEndpoints = putEndpointsInOrder(modifiedEndpoints);
state.endpoints[version] = modifiedEndpoints;
storage.set('endpoints', state.endpoints);