@clevercloud/client
Advanced tools
Comparing version 7.7.0-beta.0 to 7.7.0
@@ -5,5 +5,10 @@ # Clever Client changelog | ||
... | ||
## 7.7.0 (2022-01-05) | ||
* utils/env-var: | ||
* add a json parser and return valid values | ||
* add a strict mode validation | ||
* add a warning error for Java validation | ||
@@ -10,0 +15,0 @@ ## 7.6.0 (2021-08-03) |
@@ -437,3 +437,3 @@ "use strict"; | ||
unpaid: { | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga, ['id']) | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga_1, ['id']) | ||
} | ||
@@ -447,3 +447,3 @@ }, | ||
methods: { | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga_1, ['id']), | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga, ['id']), | ||
post: prepareRequest(organisation.todo_addPaymentMethodByOrga, ['id']), | ||
@@ -450,0 +450,0 @@ _: { |
@@ -24,3 +24,3 @@ "use strict"; | ||
exports.todo_buyDropsByOrga = todo_buyDropsByOrga; | ||
exports.todo_getUnpaidInvoicesByOrga = todo_getUnpaidInvoicesByOrga; | ||
exports.todo_getUnpaidInvoicesByOrga_1 = todo_getUnpaidInvoicesByOrga_1; | ||
exports.deletePurchaseOrder = deletePurchaseOrder; | ||
@@ -31,3 +31,3 @@ exports.getInvoice = getInvoice; | ||
exports.todo_getPriceWithTaxByOrga = todo_getPriceWithTaxByOrga; | ||
exports.todo_getUnpaidInvoicesByOrga_1 = todo_getUnpaidInvoicesByOrga_1; | ||
exports.todo_getUnpaidInvoicesByOrga = todo_getUnpaidInvoicesByOrga; | ||
exports.todo_addPaymentMethodByOrga = todo_addPaymentMethodByOrga; | ||
@@ -431,3 +431,3 @@ exports.todo_getDefaultMethodByOrga = todo_getDefaultMethodByOrga; | ||
function todo_getUnpaidInvoicesByOrga(params) { | ||
function todo_getUnpaidInvoicesByOrga_1(params) { | ||
// no multipath for /self or /organisations/{id} | ||
@@ -557,3 +557,3 @@ return Promise.resolve({ | ||
function todo_getUnpaidInvoicesByOrga_1(params) { | ||
function todo_getUnpaidInvoicesByOrga(params) { | ||
// no multipath for /self or /organisations/{id} | ||
@@ -560,0 +560,0 @@ return Promise.resolve({ |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.parseRawJson = parseRawJson; | ||
exports.toJSONString = toJSONString; | ||
exports.toJson = toJson; | ||
exports.toNameEqualsValueString = toNameEqualsValueString; | ||
@@ -60,3 +60,4 @@ exports.toNameValueObject = toNameValueObject; | ||
INVALID_JSON_ENTRY: 6, | ||
INVALID_NAME_STRICT: 7 | ||
INVALID_NAME_STRICT: 7, | ||
JAVA_INFO: 8 | ||
}; | ||
@@ -165,5 +166,6 @@ exports.ERROR_TYPES = ERROR_TYPES; | ||
const name = rawInput.substring(startIdx, nextEqualIdx); | ||
const isNameInvalid = !validateName(name, mode); | ||
const isNameInvalidSimple = !validateName(name, 'simple'); | ||
const isNameInvalidStrict = !validateName(name, 'strict'); | ||
if (isNameInvalid && mode === 'strict') { | ||
if (isNameInvalidStrict && mode === 'strict') { | ||
parsingErrors.push({ | ||
@@ -174,3 +176,3 @@ type: ERROR_TYPES.INVALID_NAME_STRICT, | ||
}); | ||
} else if (isNameInvalid && mode !== 'strict') { | ||
} else if (isNameInvalidStrict && isNameInvalidSimple && mode !== 'strict') { | ||
parsingErrors.push({ | ||
@@ -181,2 +183,8 @@ type: ERROR_TYPES.INVALID_NAME, | ||
}); | ||
} else if (isNameInvalidStrict && !isNameInvalidSimple && mode !== 'strict') { | ||
parsingErrors.push({ | ||
type: ERROR_TYPES.JAVA_INFO, | ||
name, | ||
pos: getPosition(rawInput, startIdx) | ||
}); | ||
} | ||
@@ -204,3 +212,3 @@ | ||
if (!isNameInvalid && !isNameDuplicated && !isValueInvalid) { | ||
if (!isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode === 'strict') { | ||
parsedVariables.push({ | ||
@@ -210,2 +218,12 @@ name, | ||
}); | ||
} else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode !== 'strict') { | ||
parsedVariables.push({ | ||
name, | ||
value | ||
}); | ||
} else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode !== 'strict') { | ||
parsedVariables.push({ | ||
name, | ||
value | ||
}); | ||
} | ||
@@ -226,3 +244,3 @@ | ||
if (!isNameInvalid && !isNameDuplicated) { | ||
if (!isNameInvalidStrict && !isNameDuplicated && mode === 'strict') { | ||
parsedVariables.push({ | ||
@@ -232,2 +250,12 @@ name, | ||
}); | ||
} else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
parsedVariables.push({ | ||
name, | ||
value | ||
}); | ||
} else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
parsedVariables.push({ | ||
name, | ||
value | ||
}); | ||
} | ||
@@ -293,5 +321,7 @@ | ||
const invalidNames = new Set(); | ||
const infoJava = new Set(); | ||
variablesWithNameValue.forEach(variable => { | ||
const isNameDuplicated = visitedNames.includes(variable.name); | ||
const isNameInvalid = !validateName(variable.name, mode); | ||
const isNameInvalidSimple = !validateName(variable.name, 'simple'); | ||
const isNameInvalidStrict = !validateName(variable.name, 'strict'); | ||
@@ -302,9 +332,18 @@ if (isNameDuplicated) { | ||
if (isNameInvalid) { | ||
if (isNameInvalidStrict && mode === 'strict') { | ||
invalidNames.add(variable.name); | ||
} else if (isNameInvalidSimple && isNameInvalidStrict && mode !== 'strict') { | ||
invalidNames.add(variable.name); | ||
} | ||
if (!isNameDuplicated && !isNameInvalid) { | ||
if (!isNameDuplicated && !isNameInvalidStrict && mode === 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
} else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
} else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
infoJava.add(variable.name); | ||
} | ||
@@ -330,3 +369,7 @@ }); | ||
} | ||
}); // WARN: Array.prototype.sort edits in place | ||
}); | ||
Array.from(infoJava).forEach(name => parsingErrors.push({ | ||
type: ERROR_TYPES.JAVA_INFO, | ||
name | ||
})); // WARN: Array.prototype.sort edits in place | ||
@@ -340,5 +383,5 @@ validVariables.sort((a, b) => a.name.localeCompare(b.name)); | ||
function toJSONString(variables) { | ||
function toJson(variables) { | ||
if (variables.length === 0) { | ||
return ''; | ||
return '[]'; | ||
} | ||
@@ -345,0 +388,0 @@ |
@@ -411,3 +411,3 @@ import * as addon from './addon.js'; | ||
unpaid: { | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga, ['id']), | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga_1, ['id']), | ||
}, | ||
@@ -421,3 +421,3 @@ }, | ||
methods: { | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga_1, ['id']), | ||
get: prepareRequest(organisation.todo_getUnpaidInvoicesByOrga, ['id']), | ||
post: prepareRequest(organisation.todo_addPaymentMethodByOrga, ['id']), | ||
@@ -424,0 +424,0 @@ _: { |
@@ -317,3 +317,3 @@ import { pickNonNull } from '../../pick-non-null.js'; | ||
*/ | ||
export function todo_getUnpaidInvoicesByOrga(params) { | ||
export function todo_getUnpaidInvoicesByOrga_1(params) { | ||
// no multipath for /self or /organisations/{id} | ||
@@ -424,3 +424,3 @@ return Promise.resolve({ | ||
*/ | ||
export function todo_getUnpaidInvoicesByOrga_1(params) { | ||
export function todo_getUnpaidInvoicesByOrga(params) { | ||
// no multipath for /self or /organisations/{id} | ||
@@ -427,0 +427,0 @@ return Promise.resolve({ |
@@ -49,2 +49,3 @@ /** | ||
INVALID_NAME_STRICT: 7, | ||
JAVA_INFO: 8, | ||
}; | ||
@@ -143,9 +144,14 @@ | ||
const isNameInvalid = !validateName(name, mode); | ||
if (isNameInvalid && (mode === 'strict')) { | ||
const isNameInvalidSimple = !validateName(name, 'simple'); | ||
const isNameInvalidStrict = !validateName(name, 'strict'); | ||
if (isNameInvalidStrict && mode === 'strict') { | ||
parsingErrors.push({ type: ERROR_TYPES.INVALID_NAME_STRICT, name, pos: getPosition(rawInput, startIdx) }); | ||
} | ||
else if (isNameInvalid && (mode !== 'strict')) { | ||
else if (isNameInvalidStrict && isNameInvalidSimple && mode !== 'strict') { | ||
parsingErrors.push({ type: ERROR_TYPES.INVALID_NAME, name, pos: getPosition(rawInput, startIdx) }); | ||
} | ||
else if (isNameInvalidStrict && !isNameInvalidSimple && mode !== 'strict') { | ||
parsingErrors.push({ type: ERROR_TYPES.JAVA_INFO, name, pos: getPosition(rawInput, startIdx) }); | ||
} | ||
@@ -168,5 +174,11 @@ const isNameDuplicated = allNames.has(name); | ||
if (!isNameInvalid && !isNameDuplicated && !isValueInvalid) { | ||
if (!isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode === 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode !== 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && !isValueInvalid && mode !== 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
@@ -182,6 +194,15 @@ if (isValueInvalid) { | ||
else { | ||
const value = rawInput.substring(nextEqualIdx + 1, nextNewLineIdx); | ||
if (!isNameInvalid && !isNameDuplicated) { | ||
if (!isNameInvalidStrict && !isNameDuplicated && mode === 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
parsedVariables.push({ name, value }); | ||
} | ||
startIdx = nextNewLineIdx + 1; | ||
@@ -227,16 +248,33 @@ } | ||
const invalidNames = new Set(); | ||
const infoJava = new Set(); | ||
variablesWithNameValue.forEach((variable) => { | ||
const isNameDuplicated = visitedNames.includes(variable.name); | ||
const isNameInvalid = !validateName(variable.name, mode); | ||
const isNameInvalidSimple = !validateName(variable.name, 'simple'); | ||
const isNameInvalidStrict = !validateName(variable.name, 'strict'); | ||
if (isNameDuplicated) { | ||
duplicatedNames.add(variable.name); | ||
} | ||
if (isNameInvalid) { | ||
if (isNameInvalidStrict && mode === 'strict') { | ||
invalidNames.add(variable.name); | ||
} | ||
if (!isNameDuplicated && !isNameInvalid) { | ||
else if (isNameInvalidSimple && isNameInvalidStrict && mode !== 'strict') { | ||
invalidNames.add(variable.name); | ||
} | ||
if (!isNameDuplicated && !isNameInvalidStrict && mode === 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
} | ||
else if (!isNameInvalidSimple && !isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
} | ||
else if (!isNameInvalidSimple && isNameInvalidStrict && !isNameDuplicated && mode !== 'strict') { | ||
visitedNames.push(variable.name); | ||
validVariables.push(variable); | ||
infoJava.add(variable.name); | ||
} | ||
}); | ||
@@ -257,2 +295,4 @@ | ||
Array.from(infoJava).forEach((name) => parsingErrors.push({ type: ERROR_TYPES.JAVA_INFO, name })); | ||
// WARN: Array.prototype.sort edits in place | ||
@@ -264,5 +304,5 @@ validVariables.sort((a, b) => a.name.localeCompare(b.name)); | ||
export function toJSONString (variables) { | ||
export function toJson (variables) { | ||
if (variables.length === 0) { | ||
return ''; | ||
return '[]'; | ||
} | ||
@@ -269,0 +309,0 @@ const sortedVariables = variables |
{ | ||
"name": "@clevercloud/client", | ||
"version": "7.7.0-beta.0", | ||
"version": "7.7.0", | ||
"description": "JavaScript REST client and utils for Clever Cloud's API", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/CleverCloud/clever-client.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
470989
14193
0
0