Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clarifai

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clarifai - npm Package Compare versions

Comparing version 2.0.17 to 2.0.18

sdk/clarifai-2.0.18.js

56

dist/Models.js

@@ -282,5 +282,3 @@ 'use strict';

var data = { models: models.map(formatModel) };
if (obj.concepts) {
data['action'] = obj.action || 'merge';
}
data['action'] = obj.action || 'merge';

@@ -360,5 +358,5 @@ return wrapToken(this._config, function (headers) {

/**
* Deletes all models or a model (if given id) or a model version (if given id and verion id)
* @param {String} id The model's id
* @param {String} versionId The model's version id
* Deletes all models (if no ids and versionId given) or a model (if given id) or a model version (if given id and verion id)
* @param {String|String[]} ids Can be a single string or an array of strings representing the model ids
* @param {String} versionId The model's version id
* @return {Promise(response, error)} A Promise that is fulfilled with the API response or rejected with an error

@@ -369,14 +367,40 @@ */

key: 'delete',
value: function _delete(id, versionId) {
var url = void 0;
if (id) {
url = '' + this._config.apiEndpoint + replaceVars(MODEL_PATH, [id]);
} else if (versionId) {
url = '' + this._config.apiEndpoint + replaceVars(MODEL_VERSION_PATH, [id, versionId]);
value: function _delete(ids) {
var versionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var request = void 0,
url = void 0,
data = void 0;
var id = ids;
if (checkType(/String/, ids) || checkType(/Array/, ids) && ids.length === 1) {
if (versionId) {
url = '' + this._config.apiEndpoint + replaceVars(MODEL_VERSION_PATH, [id, versionId]);
} else {
url = '' + this._config.apiEndpoint + replaceVars(MODEL_PATH, [id]);
}
request = wrapToken(this._config, function (headers) {
return axios.delete(url, { headers: headers });
});
} else {
url = '' + this._config.apiEndpoint + MODELS_PATH;
if (!ids && !versionId) {
url = '' + this._config.apiEndpoint + MODELS_PATH;
data = { 'delete_all': true };
} else if (!versionId && ids.length > 1) {
url = '' + this._config.apiEndpoint + MODELS_PATH;
data = { ids: ids };
} else {
throw new Error('Wrong arguments passed. You can only delete all\nmodels (provide no arguments), delete select\nmodels (provide list of ids), delete a single\nmodel (providing a single id) or delete a model\nversion (provide a single id and version id)');
}
request = wrapToken(this._config, function (headers) {
return axios({
method: 'delete',
url: url,
data: data,
headers: headers
});
});
}
return wrapToken(this._config, function (headers) {
return axios.delete(url, { headers: headers });
});
return request;
}

@@ -383,0 +407,0 @@ /**

{
"name": "clarifai",
"version": "2.0.17",
"version": "2.0.18",
"description": "Official Clarifai Javascript SDK",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -24,2 +24,4 @@ var fs = require('fs');

var inputId2 = 'foobaz' + d;
var testModelId;
var testModelVersionId;

@@ -298,2 +300,3 @@ describe('Clarifai JS SDK', function() {

expect(counts.errors).toBeDefined();
expect(counts.errors).toBe(0);
done();

@@ -396,3 +399,3 @@ },

var generalModelId;
var testModelId = 'vroom-vroom' + Date.now();
testModelId = 'vroom-vroom' + Date.now();

@@ -455,2 +458,3 @@ it('Creates a new model', function(done) {

expect(model.modelVersion).toBeDefined();
testModelVersionId = model.modelVersion.id;
done();

@@ -731,3 +735,3 @@ },

describe('Delete Resources', function() {
it('Allows you to delete inputs partially', function(done) {
it('Allows you to delete select inputs', function(done) {
app.inputs.delete(inputsIDs.slice(0, 1)).then(

@@ -758,4 +762,92 @@ function(response) {

it('Throws an error if model delete arguments list is incorrect', function(done) {
expect(function(){
app.models.delete(['model-1', 'model-2'], 'version-1');
}).toThrow();
done();
});
it('Allows you to delete a single model version', function(done) {
app.models.delete(testModelId, testModelVersionId).then(
function(response) {
var data = response.data;
expect(data.status).toBeDefined();
expect(data.status.code).toBe(10000);
expect(data.status.description).toBe('Ok');
done();
},
errorHandler.bind(done)
);
});
it('Allows you to delete a list of models', function(done) {
var modelIds = [
'abc' + Date.now(),
'def' + Date.now(),
'ghi' + Date.now(),
'jkl' + Date.now()
];
var completed = 0;
var totalToDelete = 4;
modelIds.forEach(function(modelId) {
app.models.create(modelId).then(
function(response) {
completed++;
if (completed === totalToDelete) {
app.models.delete(modelIds).then(
function(response) {
var data = response.data;
expect(data.status).toBeDefined();
expect(data.status.code).toBe(10000);
expect(data.status.description).toBe('Ok');
done();
},
errorHandler.bind(done)
);
}
},
errorHandler.bind(done)
);
});
});
it('Allows you to delete a single model', function(done) {
var modelId = 'abc' + Date.now();
app.models.create(modelId).then(
function(response) {
app.models.delete(modelId).then(
function(response) {
expect(response.data.status).toBeDefined();
expect(response.data.status.code).toBe(10000);
expect(response.data.status.description).toBe('Ok');
done();
},
errorHandler.bind(done)
);
},
errorHandler.bind(done)
);
});
it('Allows you to delete a single model with id given in array', function(done) {
var modelId = 'abc' + Date.now();
app.models.create(modelId).then(
function(response) {
app.models.delete([modelId]).then(
function(response) {
expect(response.data.status).toBeDefined();
expect(response.data.status.code).toBe(10000);
expect(response.data.status.description).toBe('Ok');
done();
},
errorHandler.bind(done)
);
},
errorHandler.bind(done)
);
});
it('Allows you to delete all models', function(done) {
app.models.delete(null, null).then(
app.models.delete().then(
function(response) {

@@ -782,2 +874,3 @@ var data = response.data;

expect(err.data).toBe(true);
log(obj);
this();

@@ -784,0 +877,0 @@ };

@@ -211,5 +211,3 @@ let axios = require('axios');

let data = {models: models.map(formatModel)};
if (obj.concepts) {
data['action'] = obj.action || 'merge';
}
data['action'] = obj.action || 'merge';

@@ -274,19 +272,45 @@ return wrapToken(this._config, (headers)=> {

/**
* Deletes all models or a model (if given id) or a model version (if given id and verion id)
* @param {String} id The model's id
* @param {String} versionId The model's version id
* Deletes all models (if no ids and versionId given) or a model (if given id) or a model version (if given id and verion id)
* @param {String|String[]} ids Can be a single string or an array of strings representing the model ids
* @param {String} versionId The model's version id
* @return {Promise(response, error)} A Promise that is fulfilled with the API response or rejected with an error
*/
delete(id, versionId) {
let url;
if (id) {
url = `${this._config.apiEndpoint}${replaceVars(MODEL_PATH, [id])}`;
} else if (versionId) {
url = `${this._config.apiEndpoint}${replaceVars(MODEL_VERSION_PATH, [id, versionId])}`;
delete(ids, versionId=null) {
let request, url, data;
let id = ids;
if (checkType(/String/, ids) || (checkType(/Array/, ids) && ids.length === 1 )) {
if (versionId) {
url = `${this._config.apiEndpoint}${replaceVars(MODEL_VERSION_PATH, [id, versionId])}`;
} else {
url = `${this._config.apiEndpoint}${replaceVars(MODEL_PATH, [id])}`;
}
request = wrapToken(this._config, (headers)=> {
return axios.delete(url, {headers});
});
} else {
url = `${this._config.apiEndpoint}${MODELS_PATH}`;
if (!ids && !versionId) {
url = `${this._config.apiEndpoint}${MODELS_PATH}`;
data = {'delete_all': true};
} else if (!versionId && ids.length > 1) {
url = `${this._config.apiEndpoint}${MODELS_PATH}`;
data = {ids};
} else {
throw new Error(`Wrong arguments passed. You can only delete all
models (provide no arguments), delete select
models (provide list of ids), delete a single
model (providing a single id) or delete a model
version (provide a single id and version id)`);
}
request = wrapToken(this._config, (headers)=> {
return axios({
method: 'delete',
url,
data,
headers
});
});
}
return wrapToken(this._config, (headers)=> {
return axios.delete(url, {headers});
});
return request;
}

@@ -293,0 +317,0 @@ /**

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc