directus-sdk-javascript
Advanced tools
Comparing version 2.3.1 to 3.0.0-0
{ | ||
"name": "directus-sdk-javascript", | ||
"version": "2.3.1", | ||
"version": "3.0.0-0", | ||
"description": "WIP - Directus SDK for JavaScript (Node and Browser)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
239
remote.js
@@ -10,7 +10,2 @@ const axios = require('axios'); | ||
this.headers = headers; | ||
if (!url) { | ||
throw new Error('No Directus URL provided'); | ||
} | ||
this.url = url; | ||
@@ -97,239 +92,17 @@ } | ||
// Authentication | ||
// ------------------------------------------- | ||
authenticate(email = requiredParam('email'), password = requiredParam('password')) { | ||
return new Promise((resolve, reject) => { | ||
this._post('auth/request-token', {email, password}) | ||
.then(res => { | ||
if (res.success) { | ||
this.accessToken = res.data.token; | ||
return resolve(res); | ||
} | ||
return reject(res); | ||
}) | ||
.catch(err => reject(err)); | ||
}); | ||
} | ||
// Items | ||
// ---------------------------------------------------------------------------------- | ||
createItem(table = requiredParam('table'), data = {}) { | ||
return this._post(`tables/${table}/rows`, data); | ||
} | ||
// --------------------------------------------------------------------------- | ||
getItems(table = requiredParam('table'), params = {}) { | ||
return this._get(`tables/${table}/rows`, params); | ||
return this._get(`items/${table}/`, params); | ||
} | ||
getItem(table = requiredParam('table'), id = requiredParam('id'), params = {}) { | ||
return this._get(`tables/${table}/rows/${id}`, params); | ||
getItem(table = requiredParam('table'), primaryKey = requiredParam('primaryKey'), params = {}) { | ||
return this._get(`items/${table}/${primaryKey}`, params); | ||
} | ||
updateItem(table = requiredParam('table'), id = requiredParam('id'), data = requiredParam('data')) { | ||
return this._put(`tables/${table}/rows/${id}`, data); | ||
} | ||
deleteItem(table = requiredParam('table'), id = requiredParam('id')) { | ||
return this._delete(`tables/${table}/rows/${id}`); | ||
} | ||
createBulk(table = requiredParam('table'), data = requiredParam('data')) { | ||
if (Array.isArray(data) === false) { | ||
throw new TypeError(`Parameter data should be an array of objects`); | ||
} | ||
return this._post(`tables/${table}/rows/bulk`, { | ||
rows: data | ||
}); | ||
} | ||
updateBulk(table = requiredParam('table'), data = requiredParam('data')) { | ||
if (Array.isArray(data) === false) { | ||
throw new TypeError(`Parameter data should be an array of objects`); | ||
} | ||
return this._put(`tables/${table}/rows/bulk`, { | ||
rows: data | ||
}); | ||
} | ||
deleteBulk(table = requiredParam('table'), data = requiredParam('data')) { | ||
if (Array.isArray(data) === false) { | ||
throw new TypeError(`Parameter data should be an array of objects`); | ||
} | ||
return this._delete(`tables/${table}/rows/bulk`, { | ||
rows: data | ||
}); | ||
} | ||
// Files | ||
// ---------------------------------------------------------------------------------- | ||
createFile(data = {}) { | ||
return this._post('files', data); | ||
} | ||
getFiles(params = {}) { | ||
return this._get('files', params); | ||
} | ||
getFile(id = requiredParam('id')) { | ||
return this._get(`files/${id}`); | ||
} | ||
updateFile(id = requiredParam('id'), data = requiredParam('data')) { | ||
return this._put(`files/${id}`, data); | ||
} | ||
// Tables | ||
// ---------------------------------------------------------------------------------- | ||
createTable(name = requiredParam('name')) { | ||
return this._post('tables', {name}); | ||
} | ||
// --------------------------------------------------------------------------- | ||
getTables(params = {}) { | ||
return this._get('tables', params); | ||
return this._post('tables', params); | ||
} | ||
getTable(table = requiredParam('table'), params = {}) { | ||
return this._get(`tables/${table}`, params); | ||
} | ||
// Columns | ||
// ---------------------------------------------------------------------------------- | ||
createColumn(table = requiredParam('table'), data = {}) { | ||
return this._post(`tables/${table}/columns`, data); | ||
} | ||
getColumns(table = requiredParam('table'), params = {}) { | ||
return this._get(`tables/${table}/columns`, params); | ||
} | ||
getColumn(table = requiredParam('table'), column = requiredParam('column')) { | ||
return this._get(`tables/${table}/columns/${column}`); | ||
} | ||
updateColumn(table = requiredParam('table'), column = requiredParam('column'), data = {}) { | ||
return this._put(`tables/${table}/columns/${column}`, data); | ||
} | ||
deleteColumn(table = requiredParam('table'), column = requiredParam('column')) { | ||
return this._delete(`tables/${table}/columns/${column}`); | ||
} | ||
// Groups | ||
// ---------------------------------------------------------------------------------- | ||
createGroup(name = requiredParam('name')) { | ||
return this._post('groups', {name}); | ||
} | ||
getGroups() { | ||
return this._get('groups'); | ||
} | ||
getGroup(id = requiredParam('id')) { | ||
return this._get(`groups/${id}`); | ||
} | ||
// Privileges | ||
// ---------------------------------------------------------------------------------- | ||
createPrivileges(id = requiredParam('id'), data = {}) { | ||
return this._post(`privileges/${id}`, data); | ||
} | ||
getPrivileges(id = requiredParam('id')) { | ||
return this._get(`privileges/${id}`); | ||
} | ||
getTablePrivileges(id = requiredParam('id'), table = requiredParam('table')) { | ||
return this._get(`privileges/${id}/${table}`); | ||
} | ||
updatePrivileges(id = requiredParam('id'), table = requiredParam('table')) { | ||
return this._get(`privileges/${id}/${table}`); | ||
} | ||
// Preferences | ||
// ---------------------------------------------------------------------------------- | ||
getPreferences(table = requiredParam('table')) { | ||
return this._get(`tables/${table}/preferences`); | ||
} | ||
updatePreference(table = requiredParam('table'), data = {}) { | ||
return this._update(`tables/${table}/preferences`, data); | ||
} | ||
// Messages | ||
// ---------------------------------------------------------------------------------- | ||
getMessages(params = {}) { | ||
return this._get('messages/rows', params); | ||
} | ||
getMessage(id = requiredParam('id')) { | ||
return this._get(`messages/rows/${id}`); | ||
} | ||
// Activity | ||
// ---------------------------------------------------------------------------------- | ||
getActivity(params = {}) { | ||
return this._get('activity', params); | ||
} | ||
// Bookmarks | ||
// ---------------------------------------------------------------------------------- | ||
getBookmarks() { | ||
return this._get('bookmarks'); | ||
} | ||
getUserBookmarks() { | ||
return this._get('bookmarks/self'); | ||
} | ||
getBookmark(id = requiredParam('id')) { | ||
return this._get(`bookmarks/${id}`); | ||
} | ||
createBookmark(data = requiredParam('data')) { | ||
return this._post('bookmarks', data); | ||
} | ||
deleteBookmark(id = requiredParam('id')) { | ||
return this._delete(`bookmarks/${id}`); | ||
} | ||
// Settings | ||
// ---------------------------------------------------------------------------------- | ||
getSettings() { | ||
return this._get('settings'); | ||
} | ||
getSettingsByCollection(name = requiredParam('name')) { | ||
return this._get(`settings/${name}`); | ||
} | ||
updateSettings(name = requiredParam('name'), data = {}) { | ||
return this._put(`settings/${name}`, data); | ||
} | ||
// Users | ||
// ---------------------------------------------------------------------------------- | ||
getUsers(params = {}) { | ||
return this._get('users', params); | ||
} | ||
getUser(id = requiredParam('id')) { | ||
return this._get(`users/${id}`); | ||
} | ||
// Hash | ||
// ---------------------------------------------------------------------------------- | ||
getHash(string = requiredParam('string'), data = {}) { | ||
return this._post('hash', data); | ||
} | ||
// Random | ||
// ---------------------------------------------------------------------------------- | ||
getRandom(params = {}) { | ||
return this._get('random', params); | ||
} | ||
} | ||
@@ -336,0 +109,0 @@ |
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
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
39483
93
2