@dadi/api-wrapper
Advanced tools
Comparing version 4.0.0-rc2 to 4.0.0
{ | ||
"name": "@dadi/api-wrapper-core", | ||
"version": "4.0.0-rc2", | ||
"version": "4.0.0", | ||
"description": "Core high-level methods for interacting with DADI API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,10 +28,9 @@ # DADI API wrapper (core) | ||
```js | ||
const APIWrapper = require('@dadi/api-wrapper-core') | ||
const APIWrapper = require("@dadi/api-wrapper-core"); | ||
const api = new APIWrapper({ | ||
uri: 'http://api.example.com', | ||
uri: "http://api.example.com", | ||
port: 80, | ||
version: 'vjoin', | ||
database: 'testdb' | ||
}) | ||
property: "test" | ||
}); | ||
``` | ||
@@ -44,6 +43,6 @@ | ||
const requestObject = api | ||
.in('users') | ||
.whereFieldContains('name', 'john') | ||
.whereFieldIsGreaterThan('age', 18) | ||
.find() | ||
.in("users") | ||
.whereFieldContains("name", "john") | ||
.whereFieldIsGreaterThan("age", 18) | ||
.find(); | ||
``` | ||
@@ -62,15 +61,14 @@ | ||
```js | ||
const APIWrapper = require('@dadi/api-wrapper-core') | ||
const APIWrapper = require("@dadi/api-wrapper-core"); | ||
const api = new APIWrapper({ | ||
uri: 'http://api.example.com', | ||
uri: "http://api.example.com", | ||
port: 80, | ||
version: 'vjoin', | ||
database: 'testdb', | ||
property: "test", | ||
callback: function(requestObject) { | ||
// This callback will return a JSON-stringified version | ||
// of the request object. | ||
return JSON.stringify(requestObject) | ||
return JSON.stringify(requestObject); | ||
} | ||
}) | ||
}); | ||
``` |
{ | ||
"name": "@dadi/api-wrapper", | ||
"version": "4.0.0-rc2", | ||
"version": "4.0.0", | ||
"description": "A high-level library for interacting with DADI API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
155
README.md
@@ -27,13 +27,12 @@ # DADI API wrapper | ||
```js | ||
const DadiAPI = require('@dadi/api-wrapper') | ||
const DadiAPI = require("@dadi/api-wrapper"); | ||
const api = new DadiAPI({ | ||
uri: 'http://api.example.com', | ||
uri: "http://api.example.com", | ||
port: 80, | ||
credentials: { | ||
clientId: 'johndoe', | ||
secret: 'f00b4r' | ||
clientId: "johndoe", | ||
secret: "f00b4r" | ||
}, | ||
version: 'vjoin', | ||
database: 'testdb' | ||
}) | ||
property: "test" | ||
}); | ||
``` | ||
@@ -46,9 +45,9 @@ | ||
api | ||
.in('users') | ||
.whereFieldContains('name', 'john') | ||
.whereFieldIsGreaterThan('age', 18) | ||
.in("users") | ||
.whereFieldContains("name", "john") | ||
.whereFieldIsGreaterThan("age", 18) | ||
.find() | ||
.then(response => { | ||
// Use documents here | ||
}) | ||
}); | ||
``` | ||
@@ -68,12 +67,12 @@ | ||
api | ||
.in('users') | ||
.whereFieldExists('gender') | ||
.in("users") | ||
.whereFieldExists("gender") | ||
.apply(document => { | ||
document.name = | ||
document.gender === 'male' | ||
document.gender === "male" | ||
? `Mr ${document.name}` | ||
: `Mrs ${document.name}` | ||
: `Mrs ${document.name}`; | ||
return document | ||
}) | ||
return document; | ||
}); | ||
``` | ||
@@ -88,14 +87,14 @@ | ||
api | ||
.in('users') | ||
.in("users") | ||
.create({ | ||
name: 'John Doe', | ||
name: "John Doe", | ||
age: 45, | ||
address: '123 Fake St' | ||
address: "123 Fake St" | ||
}) | ||
.then(function(doc) { | ||
console.log('New document:', doc) | ||
console.log("New document:", doc); | ||
}) | ||
.catch(function(err) { | ||
console.log('! Error:', err) | ||
}) | ||
console.log("! Error:", err); | ||
}); | ||
``` | ||
@@ -109,5 +108,5 @@ | ||
api | ||
.in('users') | ||
.whereFieldDoesNotExist('name') | ||
.delete() | ||
.in("users") | ||
.whereFieldDoesNotExist("name") | ||
.delete(); | ||
``` | ||
@@ -121,6 +120,6 @@ | ||
api | ||
.in('users') | ||
.whereFieldIsGreaterThan('age', 21) | ||
.useFields(['name', 'age']) | ||
.find(options) | ||
.in("users") | ||
.whereFieldIsGreaterThan("age", 21) | ||
.useFields(["name", "age"]) | ||
.find(options); | ||
``` | ||
@@ -138,3 +137,3 @@ | ||
```js | ||
api.getCollections() | ||
api.getCollections(); | ||
``` | ||
@@ -148,3 +147,3 @@ | ||
// Gets the collection config | ||
api.in('users').getConfig() | ||
api.in("users").getConfig(); | ||
``` | ||
@@ -154,3 +153,3 @@ | ||
// Gets the API config | ||
api.getConfig() | ||
api.getConfig(); | ||
``` | ||
@@ -163,3 +162,3 @@ | ||
```js | ||
api.getLanguages().then(({metadata, results}) => { | ||
api.getLanguages().then(({ metadata, results }) => { | ||
/* | ||
@@ -175,3 +174,3 @@ { | ||
*/ | ||
console.log(metadata) | ||
console.log(metadata); | ||
@@ -193,4 +192,4 @@ /* | ||
*/ | ||
console.log(results) | ||
}) | ||
console.log(results); | ||
}); | ||
``` | ||
@@ -203,5 +202,5 @@ | ||
```js | ||
api.in('images').getSignedUrl({ | ||
fileName: 'foobar.jpg' | ||
}) | ||
api.in("images").getSignedUrl({ | ||
fileName: "foobar.jpg" | ||
}); | ||
``` | ||
@@ -214,3 +213,3 @@ | ||
```js | ||
api.in('users').getStats() | ||
api.in("users").getStats(); | ||
``` | ||
@@ -223,3 +222,3 @@ | ||
```js | ||
api.getStatus() | ||
api.getStatus(); | ||
``` | ||
@@ -233,7 +232,7 @@ | ||
api | ||
.in('users') | ||
.whereFieldIsLessThan('age', 18) | ||
.in("users") | ||
.whereFieldIsLessThan("age", 18) | ||
.update({ | ||
adult: false | ||
}) | ||
}); | ||
``` | ||
@@ -251,3 +250,3 @@ | ||
// Example | ||
api.goToPage(3) | ||
api.goToPage(3); | ||
``` | ||
@@ -261,3 +260,3 @@ | ||
// Example | ||
api.limitTo(10) | ||
api.limitTo(10); | ||
``` | ||
@@ -271,3 +270,3 @@ | ||
// Example | ||
api.requestFeature('aclv1') | ||
api.requestFeature("aclv1"); | ||
``` | ||
@@ -281,3 +280,3 @@ | ||
// Example | ||
api.sortBy('age', 'desc') | ||
api.sortBy("age", "desc"); | ||
``` | ||
@@ -291,3 +290,3 @@ | ||
// Example | ||
api.useFields(['name', 'age']) | ||
api.useFields(["name", "age"]); | ||
``` | ||
@@ -301,3 +300,3 @@ | ||
// Example | ||
api.where({name: 'John Doe'}) | ||
api.where({ name: "John Doe" }); | ||
``` | ||
@@ -311,3 +310,3 @@ | ||
// Example | ||
api.inClients().whereClientIs('testClient') | ||
api.inClients().whereClientIs("testClient"); | ||
``` | ||
@@ -321,3 +320,3 @@ | ||
// Example | ||
api.inClients().whereClientIsSelf() | ||
api.inClients().whereClientIsSelf(); | ||
``` | ||
@@ -331,3 +330,3 @@ | ||
// Example | ||
api.whereFieldBeginsWith('name', 'john') | ||
api.whereFieldBeginsWith("name", "john"); | ||
``` | ||
@@ -341,3 +340,3 @@ | ||
// Example | ||
api.whereFieldContains('name', 'john') | ||
api.whereFieldContains("name", "john"); | ||
``` | ||
@@ -351,3 +350,3 @@ | ||
// Example | ||
api.whereFieldDoesNotContain('name', 'john') | ||
api.whereFieldDoesNotContain("name", "john"); | ||
``` | ||
@@ -361,3 +360,3 @@ | ||
// Example | ||
api.whereFieldEndsWith('name', 'john') | ||
api.whereFieldEndsWith("name", "john"); | ||
``` | ||
@@ -371,3 +370,3 @@ | ||
// Example | ||
api.whereFieldExists('name') | ||
api.whereFieldExists("name"); | ||
``` | ||
@@ -381,3 +380,3 @@ | ||
// Example | ||
api.whereFieldDoesNotExist('address') | ||
api.whereFieldDoesNotExist("address"); | ||
``` | ||
@@ -391,3 +390,3 @@ | ||
// Example | ||
api.whereFieldIsEqualTo('age', 53) | ||
api.whereFieldIsEqualTo("age", 53); | ||
``` | ||
@@ -401,3 +400,3 @@ | ||
// Example | ||
api.whereFieldIsGreaterThan('age', 18) | ||
api.whereFieldIsGreaterThan("age", 18); | ||
``` | ||
@@ -411,3 +410,3 @@ | ||
// Example | ||
api.whereFieldIsGreaterThanOrEqualTo('age', 19) | ||
api.whereFieldIsGreaterThanOrEqualTo("age", 19); | ||
``` | ||
@@ -421,3 +420,3 @@ | ||
// Example | ||
api.whereFieldIsLessThan('age', 65) | ||
api.whereFieldIsLessThan("age", 65); | ||
``` | ||
@@ -431,3 +430,3 @@ | ||
// Example | ||
api.whereFieldIsLessThanOrEqualTo('age', 64) | ||
api.whereFieldIsLessThanOrEqualTo("age", 64); | ||
``` | ||
@@ -441,3 +440,3 @@ | ||
// Example | ||
api.whereFieldIsOneOf('name', ['John', 'Jack', 'Peter']) | ||
api.whereFieldIsOneOf("name", ["John", "Jack", "Peter"]); | ||
``` | ||
@@ -451,3 +450,3 @@ | ||
// Example | ||
api.whereFieldIsEqualTo('age', 53) | ||
api.whereFieldIsEqualTo("age", 53); | ||
``` | ||
@@ -461,3 +460,3 @@ | ||
// Example | ||
api.whereFieldIsNotOneOf('name', ['Mark', 'Nathan', 'David']) | ||
api.whereFieldIsNotOneOf("name", ["Mark", "Nathan", "David"]); | ||
``` | ||
@@ -471,3 +470,3 @@ | ||
// Example | ||
api.whereFieldIsNotOneOf('name', ['Mark', 'Nathan', 'David']) | ||
api.whereFieldIsNotOneOf("name", ["Mark", "Nathan", "David"]); | ||
``` | ||
@@ -481,5 +480,5 @@ | ||
// Example | ||
api.withComposition() | ||
api.withComposition(true) // same as above | ||
api.withComposition(false) | ||
api.withComposition(); | ||
api.withComposition(true); // same as above | ||
api.withComposition(false); | ||
``` | ||
@@ -495,3 +494,3 @@ | ||
// Example | ||
api.fromEndpoint('custom-endpoint') | ||
api.fromEndpoint("custom-endpoint"); | ||
``` | ||
@@ -505,3 +504,3 @@ | ||
// Example | ||
api.in('users') | ||
api.in("users"); | ||
``` | ||
@@ -515,3 +514,3 @@ | ||
// Example | ||
api.inClients() | ||
api.inClients(); | ||
``` | ||
@@ -525,3 +524,3 @@ | ||
// Example | ||
api.inMedia('images') | ||
api.inMedia("images"); | ||
``` | ||
@@ -535,6 +534,6 @@ | ||
// Example | ||
api.inMedia('images') | ||
api.inMedia("images"); | ||
``` | ||
#### `.inProperty(database)` | ||
#### `.inProperty(property)` | ||
@@ -545,3 +544,3 @@ Selects the property to use. Overrides any property defined in the initialisation options, and is reset when called without arguments. | ||
// Example | ||
api.inProperty('testdb') | ||
api.inProperty("test"); | ||
``` |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
47808
23
1201
0
2
501