fulcrum-app
Advanced tools
Comparing version 0.7.0 to 1.0.0
@@ -1,137 +0,83 @@ | ||
var Base, Extendable, errors, moduleKeywords, request, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var request = require('request'); | ||
var errors = require('./errors'); | ||
request = require('request'); | ||
function Base(client) { | ||
this.client = client; | ||
this.base = this.client.url; | ||
} | ||
errors = require('./errors'); | ||
Base.prototype.url = function(id) { | ||
var path = id ? this.resource + '/' + id : this.resource; | ||
return this.base + path; | ||
}; | ||
moduleKeywords = ['extended', 'included']; | ||
Base.prototype.singular_resource = function() { | ||
return this.resource.slice(0, this.resource.length - 1); | ||
}; | ||
Extendable = (function() { | ||
function Extendable() {} | ||
Extendable.extend = function(obj) { | ||
var key, value, _ref; | ||
for (key in obj) { | ||
value = obj[key]; | ||
if (__indexOf.call(moduleKeywords, key) < 0) { | ||
this[key] = value; | ||
} | ||
} | ||
if ((_ref = obj.extended) != null) { | ||
_ref.apply(this); | ||
} | ||
return this; | ||
Base.prototype.request = function(method, url, opts, cb) { | ||
var headers = { | ||
'X-ApiToken': this.client.api_key, | ||
'Accept': 'application/json' | ||
}; | ||
Extendable.include = function(obj) { | ||
var key, value, _ref; | ||
for (key in obj) { | ||
value = obj[key]; | ||
if (__indexOf.call(moduleKeywords, key) < 0) { | ||
this.prototype[key] = value; | ||
} | ||
} | ||
if ((_ref = obj.included) != null) { | ||
_ref.apply(this); | ||
} | ||
return this; | ||
var options = { | ||
'headers': headers, | ||
'method': method, | ||
'url': url, | ||
'json': true | ||
}; | ||
return Extendable; | ||
})(); | ||
Base = (function(_super) { | ||
__extends(Base, _super); | ||
function Base(client) { | ||
this.client = client; | ||
this.base = this.client.url; | ||
if (opts && opts.qs) { | ||
options.qs = opts.qs; | ||
} | ||
if (opts && opts.data) { | ||
options.json = opts.data; | ||
} | ||
request(options, cb); | ||
}; | ||
Base.prototype.url = function(id) { | ||
var path; | ||
path = id ? this.resource + '/' + id : this.resource; | ||
return this.base + path; | ||
}; | ||
Base.prototype.singular_resource = function() { | ||
return this.resource.slice(0, this.resource.length - 1); | ||
}; | ||
Base.prototype.request = function(method, url, opts, cb) { | ||
var headers, options; | ||
headers = { | ||
'X-ApiToken': this.client.api_key, | ||
'Accept': 'application/json' | ||
}; | ||
Base.prototype.get = function(id, qs, cb) { | ||
var options; | ||
if (qs) { | ||
options = { | ||
'headers': headers, | ||
'method': method, | ||
'url': url, | ||
'json': true | ||
qs: qs | ||
}; | ||
if (opts && opts.qs) { | ||
options.qs = opts.qs; | ||
} | ||
if (opts && opts.data) { | ||
options.json = opts.data; | ||
} | ||
return request(options, cb); | ||
}; | ||
} else { | ||
options = null; | ||
} | ||
this.request('get', this.url(id), options, cb); | ||
}; | ||
Base.prototype.get = function(id, qs, cb) { | ||
var options; | ||
if (qs) { | ||
options = { | ||
qs: qs | ||
}; | ||
} else { | ||
options = null; | ||
} | ||
return this.request('get', this.url(id), options, cb); | ||
}; | ||
Base.prototype.del = function(id, cb) { | ||
this.request('delete', this.url(id), null, cb); | ||
}; | ||
Base.prototype.del = function(id, cb) { | ||
return this.request('delete', this.url(id), null, cb); | ||
Base.prototype.post = function(data, cb) { | ||
var options = { | ||
data: data | ||
}; | ||
this.request('post', this.url(), options, cb); | ||
}; | ||
Base.prototype.post = function(data, cb) { | ||
var options; | ||
options = { | ||
data: data | ||
}; | ||
return this.request('post', this.url(), options, cb); | ||
Base.prototype.put = function(id, data, cb) { | ||
var options = { | ||
data: data | ||
}; | ||
this.request('put', this.url(id), options, cb); | ||
}; | ||
Base.prototype.put = function(id, data, cb) { | ||
var options; | ||
options = { | ||
data: data | ||
}; | ||
return this.request('put', this.url(id), options, cb); | ||
}; | ||
Base.prototype.process_http_errors = function(response, cb) { | ||
var message, status_code; | ||
status_code = response.statusCode; | ||
if ((299 >= status_code && status_code >= 200)) { | ||
return cb(null); | ||
Base.prototype.process_http_errors = function(response, cb) { | ||
var message; | ||
var status_code = response.statusCode; | ||
if ((299 >= status_code && status_code >= 200)) { | ||
cb(null); | ||
} else { | ||
if (status_code in errors) { | ||
message = errors[status_code]; | ||
} else { | ||
if (status_code in errors) { | ||
message = errors[status_code]; | ||
} else { | ||
message = 'Unknown Error'; | ||
} | ||
return cb(new Error(message)); | ||
message = 'Unknown Error'; | ||
} | ||
}; | ||
cb(new Error(message)); | ||
} | ||
}; | ||
return Base; | ||
})(Extendable); | ||
module.exports = Base; |
@@ -1,60 +0,50 @@ | ||
var Base, Changesets, async, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
async = require('async'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
mixins = require('./mixins/'); | ||
function Changesets() { | ||
Base.apply(this, arguments); | ||
} | ||
Base = require('./base'); | ||
Changesets.prototype = Object.create(Base.prototype); | ||
Changesets.prototype.constructor = Changesets; | ||
Changesets = (function(_super) { | ||
__extends(Changesets, _super); | ||
Changesets.prototype.resource = 'changesets'; | ||
function Changesets() { | ||
return Changesets.__super__.constructor.apply(this, arguments); | ||
Changesets.prototype.close = function(id, cb) { | ||
var me = this; | ||
function do_put (callback) { | ||
me.request('put', me.url(id) + '/close', null, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
Changesets.prototype.resource = 'changesets'; | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null); | ||
} | ||
}); | ||
} | ||
Changesets.include(mixins.creatable); | ||
var tasks = [do_put, do_process_http_errors]; | ||
Changesets.include(mixins.findable); | ||
async.waterfall(tasks, cb); | ||
}; | ||
Changesets.include(mixins.updatable); | ||
_.extend(Changesets.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
Changesets.include(mixins.searchable); | ||
Changesets.prototype.close = function(id, cb) { | ||
var do_process_http_errors, do_put, tasks; | ||
do_put = (function(_this) { | ||
return function(callback) { | ||
return _this.request('put', _this.url(id) + '/close', null, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_put, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
}; | ||
return Changesets; | ||
})(Base); | ||
module.exports = Changesets; |
@@ -1,26 +0,17 @@ | ||
var Base, ChildRecords, async, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
async = require('async'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
mixins = require('./mixins/'); | ||
function ChildRecords() { | ||
Base.apply(this, arguments); | ||
} | ||
Base = require('./base'); | ||
ChildRecords.prototype = Object.create(Base.prototype); | ||
ChildRecords.prototype.constructor = ChildRecords; | ||
ChildRecords = (function(_super) { | ||
__extends(ChildRecords, _super); | ||
ChildRecords.prototype.resource = 'child_records'; | ||
function ChildRecords() { | ||
return ChildRecords.__super__.constructor.apply(this, arguments); | ||
} | ||
_.extend(ChildRecords.prototype, mixins.searchable); | ||
ChildRecords.prototype.resource = 'child_records'; | ||
ChildRecords.include(mixins.searchable); | ||
return ChildRecords; | ||
})(Base); | ||
module.exports = ChildRecords; |
@@ -1,32 +0,22 @@ | ||
var Base, ChoiceLists, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function ChoiceLists() { | ||
Base.apply(this, arguments); | ||
} | ||
ChoiceLists = (function(_super) { | ||
__extends(ChoiceLists, _super); | ||
ChoiceLists.prototype = Object.create(Base.prototype); | ||
ChoiceLists.prototype.constructor = ChoiceLists; | ||
function ChoiceLists() { | ||
return ChoiceLists.__super__.constructor.apply(this, arguments); | ||
} | ||
ChoiceLists.prototype.resource = 'choice_lists'; | ||
ChoiceLists.prototype.resource = 'choice_lists'; | ||
_.extend(ChoiceLists.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.deletable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
ChoiceLists.include(mixins.findable); | ||
ChoiceLists.include(mixins.searchable); | ||
ChoiceLists.include(mixins.deletable); | ||
ChoiceLists.include(mixins.creatable); | ||
ChoiceLists.include(mixins.updatable); | ||
return ChoiceLists; | ||
})(Base); | ||
module.exports = ChoiceLists; |
@@ -1,32 +0,22 @@ | ||
var Base, ClassificationSets, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function ClassificationSets() { | ||
Base.apply(this, arguments); | ||
} | ||
ClassificationSets = (function(_super) { | ||
__extends(ClassificationSets, _super); | ||
ClassificationSets.prototype = Object.create(Base.prototype); | ||
ClassificationSets.prototype.constructor = ClassificationSets; | ||
function ClassificationSets() { | ||
return ClassificationSets.__super__.constructor.apply(this, arguments); | ||
} | ||
ClassificationSets.prototype.resource = 'classification_sets'; | ||
ClassificationSets.prototype.resource = 'classification_sets'; | ||
_.extend(ClassificationSets.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.deletable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
ClassificationSets.include(mixins.findable); | ||
ClassificationSets.include(mixins.searchable); | ||
ClassificationSets.include(mixins.deletable); | ||
ClassificationSets.include(mixins.creatable); | ||
ClassificationSets.include(mixins.updatable); | ||
return ClassificationSets; | ||
})(Base); | ||
module.exports = ClassificationSets; |
@@ -1,4 +0,2 @@ | ||
var status_codes; | ||
status_codes = { | ||
var status_codes = { | ||
400: 'Bad Request', | ||
@@ -5,0 +3,0 @@ 401: 'Unauthorized', |
@@ -1,32 +0,22 @@ | ||
var Base, Forms, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Forms() { | ||
Base.apply(this, arguments); | ||
} | ||
Forms = (function(_super) { | ||
__extends(Forms, _super); | ||
Forms.prototype = Object.create(Base.prototype); | ||
Forms.prototype.constructor = Forms; | ||
function Forms() { | ||
return Forms.__super__.constructor.apply(this, arguments); | ||
} | ||
Forms.prototype.resource = 'forms'; | ||
Forms.prototype.resource = 'forms'; | ||
_.extend(Forms.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.deletable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
Forms.include(mixins.findable); | ||
Forms.include(mixins.searchable); | ||
Forms.include(mixins.deletable); | ||
Forms.include(mixins.creatable); | ||
Forms.include(mixins.updatable); | ||
return Forms; | ||
})(Base); | ||
module.exports = Forms; |
@@ -1,24 +0,17 @@ | ||
var Base, Memberships, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Memberships() { | ||
Base.apply(this, arguments); | ||
} | ||
Memberships = (function(_super) { | ||
__extends(Memberships, _super); | ||
Memberships.prototype = Object.create(Base.prototype); | ||
Memberships.prototype.constructor = Memberships; | ||
function Memberships() { | ||
return Memberships.__super__.constructor.apply(this, arguments); | ||
} | ||
Memberships.prototype.resource = 'memberships'; | ||
Memberships.prototype.resource = 'memberships'; | ||
_.extend(Memberships.prototype, mixins.searchable); | ||
Memberships.include(mixins.searchable); | ||
return Memberships; | ||
})(Base); | ||
module.exports = Memberships; |
@@ -1,32 +0,30 @@ | ||
var async, creatable; | ||
var async = require('async'); | ||
async = require('async'); | ||
var creatable = { | ||
create: function(data, cb) { | ||
var me = this; | ||
creatable = { | ||
create: function(data, cb) { | ||
var do_post, do_process_http_errors, tasks; | ||
do_post = (function(_this) { | ||
return function(callback) { | ||
return _this.post(data, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_post, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
function do_post (callback) { | ||
me.post(data, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
var tasks = [do_post, do_process_http_errors]; | ||
async.waterfall(tasks, cb); | ||
} | ||
@@ -33,0 +31,0 @@ }; |
@@ -1,32 +0,30 @@ | ||
var async, deletable; | ||
var async = require('async'); | ||
async = require('async'); | ||
var deletable = { | ||
"delete": function(id, cb) { | ||
var me = this; | ||
deletable = { | ||
"delete": function(id, cb) { | ||
var do_delete, do_process_http_errors, tasks; | ||
do_delete = (function(_this) { | ||
return function(callback) { | ||
return _this.del(id, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_delete, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
function do_delete (callback) { | ||
me.del(id, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null); | ||
} | ||
}); | ||
} | ||
var tasks = [do_delete, do_process_http_errors]; | ||
async.waterfall(tasks, cb); | ||
} | ||
@@ -33,0 +31,0 @@ }; |
@@ -1,31 +0,29 @@ | ||
var async, findable; | ||
var async = require('async'); | ||
async = require('async'); | ||
var findable = { | ||
find: function(id, cb) { | ||
var me = this; | ||
findable = { | ||
find: function(id, cb) { | ||
var do_get, do_process_http_errors, tasks; | ||
do_get = (function(_this) { | ||
return function(callback) { | ||
return _this.get(id, null, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_get, do_process_http_errors]; | ||
function do_get (callback) { | ||
me.get(id, null, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
var tasks = [do_get, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
@@ -32,0 +30,0 @@ } |
@@ -1,13 +0,7 @@ | ||
var creatable, deletable, findable, searchable, updatable; | ||
var searchable = require('./searchable'); | ||
var findable = require('./findable'); | ||
var deletable = require('./deletable'); | ||
var creatable = require('./creatable'); | ||
var updatable = require('./updatable'); | ||
searchable = require('./searchable'); | ||
findable = require('./findable'); | ||
deletable = require('./deletable'); | ||
creatable = require('./creatable'); | ||
updatable = require('./updatable'); | ||
module.exports = { | ||
@@ -14,0 +8,0 @@ searchable: searchable, |
@@ -1,31 +0,29 @@ | ||
var async, searchable; | ||
var async = require('async'); | ||
async = require('async'); | ||
var searchable = { | ||
search: function(qs, cb) { | ||
var me = this; | ||
searchable = { | ||
search: function(qs, cb) { | ||
var do_get, do_process_http_errors, tasks; | ||
do_get = (function(_this) { | ||
return function(callback) { | ||
return _this.get(null, qs, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_get, do_process_http_errors]; | ||
function do_get (callback) { | ||
me.get(null, qs, function (error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
} | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
} | ||
var tasks = [do_get, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
@@ -32,0 +30,0 @@ } |
@@ -1,31 +0,29 @@ | ||
var async, updatable; | ||
var async = require('async'); | ||
async = require('async'); | ||
var updatable = { | ||
update: function(id, data, cb) { | ||
var me = this; | ||
updatable = { | ||
update: function(id, data, cb) { | ||
var do_process_http_errors, do_put, tasks; | ||
do_put = (function(_this) { | ||
return function(callback) { | ||
return _this.put(id, data, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_put, do_process_http_errors]; | ||
function do_put (callback) { | ||
me.put(id, data, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
var tasks = [do_put, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
@@ -32,0 +30,0 @@ } |
@@ -1,26 +0,19 @@ | ||
var Base, Photos, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Photos() { | ||
Base.apply(this, arguments); | ||
} | ||
Photos = (function(_super) { | ||
__extends(Photos, _super); | ||
Photos.prototype = Object.create(Base.prototype); | ||
Photos.prototype.constructor = Photos; | ||
function Photos() { | ||
return Photos.__super__.constructor.apply(this, arguments); | ||
} | ||
Photos.prototype.resource = 'photos'; | ||
Photos.prototype.resource = 'photos'; | ||
_.extend(Photos.prototype, | ||
mixins.findable, | ||
mixins.searchable); | ||
Photos.include(mixins.findable); | ||
Photos.include(mixins.searchable); | ||
return Photos; | ||
})(Base); | ||
module.exports = Photos; |
@@ -1,24 +0,17 @@ | ||
var Base, Projects, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Projects() { | ||
Base.apply(this, arguments); | ||
} | ||
Projects = (function(_super) { | ||
__extends(Projects, _super); | ||
Projects.prototype = Object.create(Base.prototype); | ||
Projects.prototype.constructor = Projects; | ||
function Projects() { | ||
return Projects.__super__.constructor.apply(this, arguments); | ||
} | ||
Projects.prototype.resource = 'projects'; | ||
Projects.prototype.resource = 'projects'; | ||
_.extend(Projects.prototype, mixins.searchable); | ||
Projects.include(mixins.searchable); | ||
return Projects; | ||
})(Base); | ||
module.exports = Projects; |
@@ -1,62 +0,51 @@ | ||
var Base, Records, async, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
async = require('async'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
mixins = require('./mixins/'); | ||
function Records() { | ||
Base.apply(this, arguments); | ||
} | ||
Base = require('./base'); | ||
Records.prototype = Object.create(Base.prototype); | ||
Records.prototype.constructor = Records; | ||
Records = (function(_super) { | ||
__extends(Records, _super); | ||
Records.prototype.resource = 'records'; | ||
function Records() { | ||
return Records.__super__.constructor.apply(this, arguments); | ||
Records.prototype.history = function(id, cb) { | ||
var me = this; | ||
function do_get (callback) { | ||
me.request('get', me.url(id) + '/history', null, function (error, response, body) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, response, body); | ||
} | ||
}); | ||
} | ||
Records.prototype.resource = 'records'; | ||
function do_process_http_errors (response, body, callback) { | ||
me.process_http_errors(response, function (error) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
Records.include(mixins.findable); | ||
var tasks = [do_get, do_process_http_errors]; | ||
Records.include(mixins.searchable); | ||
async.waterfall(tasks, cb); | ||
}; | ||
Records.include(mixins.deletable); | ||
_.extend(Records.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.deletable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
Records.include(mixins.creatable); | ||
Records.include(mixins.updatable); | ||
Records.prototype.history = function(id, cb) { | ||
var do_get, do_process_http_errors, tasks; | ||
do_get = (function(_this) { | ||
return function(callback) { | ||
return _this.request('get', _this.url(id) + '/history', null, function(error, response, body) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, response, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
do_process_http_errors = (function(_this) { | ||
return function(response, body, callback) { | ||
return _this.process_http_errors(response, function(error) { | ||
if (error) { | ||
return callback(error); | ||
} else { | ||
return callback(null, body); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
tasks = [do_get, do_process_http_errors]; | ||
return async.waterfall(tasks, cb); | ||
}; | ||
return Records; | ||
})(Base); | ||
module.exports = Records; |
@@ -1,24 +0,17 @@ | ||
var Base, Roles, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Roles() { | ||
Base.apply(this, arguments); | ||
} | ||
Roles = (function(_super) { | ||
__extends(Roles, _super); | ||
Roles.prototype = Object.create(Base.prototype); | ||
Roles.prototype.constructor = Roles; | ||
function Roles() { | ||
return Roles.__super__.constructor.apply(this, arguments); | ||
} | ||
Roles.prototype.resource = 'roles'; | ||
Roles.prototype.resource = 'roles'; | ||
_.extend(Roles.prototype, mixins.searchable); | ||
Roles.include(mixins.searchable); | ||
return Roles; | ||
})(Base); | ||
module.exports = Roles; |
@@ -1,26 +0,19 @@ | ||
var Base, Videos, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Videos() { | ||
Base.apply(this, arguments); | ||
} | ||
Videos = (function(_super) { | ||
__extends(Videos, _super); | ||
Videos.prototype = Object.create(Base.prototype); | ||
Videos.prototype.constructor = Videos; | ||
function Videos() { | ||
return Videos.__super__.constructor.apply(this, arguments); | ||
} | ||
Videos.prototype.resource = 'videos'; | ||
Videos.prototype.resource = 'videos'; | ||
_.extend(Videos.prototype, | ||
mixins.findable, | ||
mixins.searchable); | ||
Videos.include(mixins.findable); | ||
Videos.include(mixins.searchable); | ||
return Videos; | ||
})(Base); | ||
module.exports = Videos; |
@@ -1,32 +0,22 @@ | ||
var Base, Webhooks, mixins, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var _ = require('lodash'); | ||
mixins = require('./mixins/'); | ||
var mixins = require('./mixins/'); | ||
var Base = require('./base'); | ||
Base = require('./base'); | ||
function Webhooks() { | ||
Base.apply(this, arguments); | ||
} | ||
Webhooks = (function(_super) { | ||
__extends(Webhooks, _super); | ||
Webhooks.prototype = Object.create(Base.prototype); | ||
Webhooks.prototype.constructor = Webhooks; | ||
function Webhooks() { | ||
return Webhooks.__super__.constructor.apply(this, arguments); | ||
} | ||
Webhooks.prototype.resource = 'webhooks'; | ||
Webhooks.prototype.resource = 'webhooks'; | ||
_.extend(Webhooks.prototype, | ||
mixins.findable, | ||
mixins.searchable, | ||
mixins.deletable, | ||
mixins.creatable, | ||
mixins.updatable); | ||
Webhooks.include(mixins.findable); | ||
Webhooks.include(mixins.searchable); | ||
Webhooks.include(mixins.deletable); | ||
Webhooks.include(mixins.creatable); | ||
Webhooks.include(mixins.updatable); | ||
return Webhooks; | ||
})(Base); | ||
module.exports = Webhooks; | ||
module.exports = Webhooks; |
@@ -1,4 +0,3 @@ | ||
var Fulcrum, resources; | ||
resources = { | ||
var resources = { | ||
photos: require('./api/photos'), | ||
records: require('./api/records'), | ||
@@ -11,3 +10,2 @@ changesets: require('./api/changesets'), | ||
classification_sets: require('./api/classification_sets'), | ||
photos: require('./api/photos'), | ||
videos: require('./api/videos'), | ||
@@ -19,17 +17,14 @@ memberships: require('./api/memberships'), | ||
Fulcrum = (function() { | ||
function Fulcrum(options) { | ||
var klass, name; | ||
this.api_key = options.api_key; | ||
this.url = options.url || 'https://api.fulcrumapp.com/api/v2/'; | ||
for (name in resources) { | ||
klass = resources[name]; | ||
this[name] = new klass(this); | ||
} | ||
} | ||
function Fulcrum(options) { | ||
var klass, name; | ||
return Fulcrum; | ||
this.api_key = options.api_key; | ||
this.url = options.url || 'https://api.fulcrumapp.com/api/v2/'; | ||
})(); | ||
for (name in resources) { | ||
klass = resources[name]; | ||
this[name] = new klass(this); | ||
} | ||
} | ||
module.exports = Fulcrum; |
{ | ||
"name": "fulcrum-app", | ||
"version": "0.7.0", | ||
"version": "1.0.0", | ||
"description": "JavaScript wrapper for the Fulcrum API", | ||
@@ -8,9 +8,6 @@ "main": "lib/index.js", | ||
"type": "git", | ||
"url": "git://github.com/JasonSanford/fulcrum-node.git" | ||
"url": "git://github.com/fulcrumapp/fulcrum-node.git" | ||
}, | ||
"scripts": { | ||
"test": "mocha -R spec", | ||
"watch": "coffee -w -c -b --no-header -o lib src", | ||
"build": "npm run build-node && npm run build-browser", | ||
"build-node": "coffee -c -b --no-header -o lib src", | ||
"build-browser": "browserify lib/index.js -s Fulcrum > fulcrum.js" | ||
@@ -31,6 +28,7 @@ }, | ||
"dependencies": { | ||
"async": "~0.9.0", | ||
"lodash": "^3.5.0", | ||
"request": "~2.37.0", | ||
"async": "~0.9.0", | ||
"xhr": "1.13.0" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
543997
15292
1
4
60
254
2
+ Addedlodash@^3.5.0
+ Addedlodash@3.10.1(transitive)