+ throw new Error(`Chip of type ${type} and name ${name} has not yet been registered`);
+ }
+ return ret;
+ } catch (e){
+ throw new Errors.ValidationError(`ChipManager was asked to return a chip of type "${type}" and name "${name}", but it was not found`, {}, {short_message: "chip_not_found"});
+ throw Errors.Error("Chip manager was requested to return a datastore chip. Multiple chips of type `datastore` have been registered, and no default provided in configuration.");
+ log_error(`Syntax error in sealious.yml:\n#{e.message}`);
+ process.exit(1);
+ } else if (e.code === "ENOENT"){
+ log("\n\n\tNo 'sealious.yml' file detected.\n\tConsider creating it alongside your app's package.json file if you want to configure the app's chips.\n\n");
- * @returns {array} Array of names of resource types.
- */
- __get_all_collections: function(chips){
- const names = [];
- for (const collection in chips.collection){
- names.push(collection);
- }
- return names;
- },
- get_all_collections: function(){
- return this.__get_all_collections(chips);
- },
- /**
- * Checks if chip exists
- * @param {string} type - chip type
- * @param {string} name - chip name
- * @returns {boolean} true if exists, otherwise false
- */
- chip_exists: function(type, name){
- if (chips[type] && chips[type][name]){
- return true;
- } else {
- return false;
- }
- },
- __get_chip: function(chips, type, name){
- try {
- const ret = chips[type][name];
- if (ret === undefined){
- throw new Error(`Chip of type ${type} and name ${name} has not yet been registered`);
- }
- return ret;
- } catch (e){
- throw new Errors.ValidationError(`ChipManager was asked to return a chip of type "${type}" and name "${name}", but it was not found`, {}, {short_message: "chip_not_found"});
- throw Errors.Error("Chip manager was requested to return a datastore chip. Multiple chips of type `datastore` have been registered, and no default provided in configuration.");
+ // with_validators:boolean - whether to include validator functions in field descriptions. Warning! If set to true, the output is not serializable in JSON.
- // with_validators:boolean - whether to include validator functions in field descriptions. Warning! If set to true, the output is not serializable in JSON.
assert.deepEqual(to_insert, response, ".insert method should respond with the created document");
return Promise.resolve();
});
}).then(function(){
// check if find resolves with an array
return self.find(test_collection_name, {}, {})
.then(function(documents){
assert(documents instanceof Array, `datastore.${self.name}.find should resolve with an array`);
return Promise.resolve();
});
}).then(function(){
// check if amount of created documents checks out
const creates = [
self.insert(test_collection_name, {
value: 2,
random: rand,
}),
self.insert(test_collection_name, {
value: 3,
random: rand,
}),
self.insert(test_collection_name, {
value: 4,
random: -rand,
}),
];
const created_so_far = 4;
return Promise.all(creates)
.then(function(){
return self.find(test_collection_name, {}, {});
}).then(function(documents){
assert(documents.length === created_so_far, `Inserted ${created_so_far} documents so far, but ${documents.length} were returned on .find()`);
return Promise.resolve(created_so_far);
});
}).then(function(created_so_far){
// check if there is a proper amount of documents with random value set to rand
const documents_with_rand = created_so_far - 1;
return self.find(test_collection_name, {
random: rand,
}, {})
.then(function(documents){
assert(documents.length === documents_with_rand, `Inserted ${documents_with_rand} documents with "random" set to "${rand}" so far, but ${documents.length} were returned on .find({random: ${rand}})`);
"show-coverage": "npm run cover && (xdg-open ./coverage/lcov-report/index.html || exit 0)",
"coveralls": "npm run cover && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"eslint": "eslint lib && echo \"There are no errors.\" || (echo \"Errors in code were found. Run \"npm run eslint-fix\" or repair the problems yourself.\" && exit 1)",
"eslint-fix": "eslint --fix lib \"There are no errors.\" || (echo \"Errors in code were found. Run \"npm run eslint-fix\" or repair the problems yourself.\" && exit 1)"
},
"repository": {
"type": "git",
"url": "https://github.com/sealcode/sealious"
},
"keywords": [
"sealious"
],
"author": "The Sealious team (http://github.com/Sealious)",