Skip to content

Commit cc6cffb

Browse files
authored
Merge pull request #8 from WURFL/3.1.0
3.1.0
2 parents d4c5756 + 056192d commit cc6cffb

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
3.1.0 - Oct 29th, 2024
2+
------------------------------------
3+
- Deprecated method setRequestedCapabilities()
4+
15
3.0.0
26
------------------------------------
37
- Complete rewrite of all API using async/await. NOT compatible with older versions

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const example = async () => {
6161
console.log('Static capabilities loaded: ' + client.staticCaps.length)
6262
console.log('Virtual capabilities loaded: ' + client.virtualCaps.length + '\n')
6363
separate()
64+
// Get server info
6465
try {
6566
let info = await client.getInfo()
6667
console.log('Server info: \n')
@@ -71,7 +72,7 @@ const example = async () => {
7172
console.log("Unable to load WURFL Info")
7273
}
7374
separate()
74-
// Perform a detection using passing a whole HTTP request to WM server API
75+
// Perform a detection using a whole HTTP request to WM server API
7576
// When building a request object for node, headers must be lowercase, according to Node standard
7677
let req_headers = {
7778
'accept': 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
@@ -89,6 +90,7 @@ const example = async () => {
8990
'x-operamini-phone-Ua': 'Mozilla/5.0 (Linux; Android 8.1.0; SM-J610G Build/M1AJQ; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36',
9091
}
9192

93+
// Request refer a local WM server. Change the host and port to your WM server if needed
9294
let options = {
9395
protocol: 'http:',
9496
host: 'localhost',
@@ -100,6 +102,8 @@ const example = async () => {
100102
let req = http.request(options)
101103
req.headers = req_headers
102104
req.end()
105+
106+
// Get device info using wmclient
103107
let device
104108
try {
105109
device = await client.lookupRequest(req)
@@ -121,7 +125,9 @@ const example = async () => {
121125
}
122126
}
123127
separate()
124-
// Get all the device manufacturers, and print the first twenty
128+
// Get some data using wmclient
129+
130+
// Get all the device manufacturers, and print the first twenty returned
125131
let deviceMakes = await client.getAllDeviceMakes()
126132
let limit = 20
127133
console.log("Print the first " + limit + " Brand of " + deviceMakes.length)
@@ -131,7 +137,7 @@ const example = async () => {
131137
console.log(" - " + deviceMakes[i])
132138
}
133139
separate()
134-
// Now call the WM server to get all device model and marketing names produced by Apple
140+
// Get all device model and marketing names produced by Apple
135141
let brandName = "Apple"
136142
try {
137143
let devsForMake = await client.getAllDevicesForMake(brandName)
@@ -149,7 +155,7 @@ const example = async () => {
149155
console.log(`Error looking for models for device, brand ${error.message}`)
150156
}
151157
separate()
152-
// Now call the WM server to get all operative system names
158+
// Get all operative system names
153159
let oses = await client.getAllOSes()
154160
// Sort and print all OS names
155161
console.log("Print the list of OSes")
@@ -158,7 +164,7 @@ const example = async () => {
158164
console.log(" - " + oses[i])
159165
}
160166

161-
// Let's call the WM server to get all version of the Android OS
167+
// Get all Android OS versions
162168
let os = 'Android'
163169
try {
164170
let versions = await client.getAllVersionsForOS(os)

example.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
limitations under the License.
1515
*/
1616

17-
// this must be used when executing directly from source code downloaded from git repo
18-
//let wmclient = require('./src/app/wmclient')
17+
// Use the commented require to refer local source code instead of client installed from NPM repo
18+
// let wmclient = require('./src/app/wmclient')
1919
let wmclient = require('wmclient')
2020
const http = require("http")
2121
const TEXT_SEPARATOR = '---------------------------------------------------------------------------------'
@@ -36,6 +36,7 @@ const example = async () => {
3636
console.log('Static capabilities loaded: ' + client.staticCaps.length)
3737
console.log('Virtual capabilities loaded: ' + client.virtualCaps.length + '\n')
3838
separate()
39+
// Get server info
3940
try {
4041
let info = await client.getInfo()
4142
console.log('Server info: \n')
@@ -46,7 +47,7 @@ const example = async () => {
4647
console.log("Unable to load WURFL Info")
4748
}
4849
separate()
49-
// Perform a detection using passing a whole HTTP request to WM server API
50+
// Perform a detection using a whole HTTP request to WM server API
5051
// When building a request object for node, headers must be lowercase, according to Node standard
5152
let req_headers = {
5253
'accept': 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
@@ -64,6 +65,7 @@ const example = async () => {
6465
'x-operamini-phone-Ua': 'Mozilla/5.0 (Linux; Android 8.1.0; SM-J610G Build/M1AJQ; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36',
6566
}
6667

68+
// Request refer a local WM server. Change the host and port to your WM server if needed
6769
let options = {
6870
protocol: 'http:',
6971
host: 'localhost',
@@ -75,6 +77,8 @@ const example = async () => {
7577
let req = http.request(options)
7678
req.headers = req_headers
7779
req.end()
80+
81+
// Get device info using wmclient
7882
let device
7983
try {
8084
device = await client.lookupRequest(req)
@@ -96,7 +100,9 @@ const example = async () => {
96100
}
97101
}
98102
separate()
99-
// Get all the device manufacturers, and print the first twenty
103+
// Get some data using wmclient
104+
105+
// Get all the device manufacturers, and print the first twenty returned
100106
let deviceMakes = await client.getAllDeviceMakes()
101107
let limit = 20
102108
console.log("Print the first " + limit + " Brand of " + deviceMakes.length)
@@ -106,7 +112,7 @@ const example = async () => {
106112
console.log(" - " + deviceMakes[i])
107113
}
108114
separate()
109-
// Now call the WM server to get all device model and marketing names produced by Apple
115+
// Get all device model and marketing names produced by Apple
110116
let brandName = "Apple"
111117
try {
112118
let devsForMake = await client.getAllDevicesForMake(brandName)
@@ -124,7 +130,7 @@ const example = async () => {
124130
console.log(`Error looking for models for device, brand ${error.message}`)
125131
}
126132
separate()
127-
// Now call the WM server to get all operative system names
133+
// Get all operative system names
128134
let oses = await client.getAllOSes()
129135
// Sort and print all OS names
130136
console.log("Print the list of OSes")
@@ -133,7 +139,7 @@ const example = async () => {
133139
console.log(" - " + oses[i])
134140
}
135141

136-
// Let's call the WM server to get all version of the Android OS
142+
// Get all Android OS versions
137143
let os = 'Android'
138144
try {
139145
let versions = await client.getAllVersionsForOS(os)

src/app/__tests__/wmclientTest.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("Wm client", () => {
3737

3838

3939
let wm = await wmClient.create('http:', 'localhost', '8080', '')
40-
expect(wm.importantHeaders.length).toBe(7)
40+
expect(wm.importantHeaders.length).toBeGreaterThan(0)
4141
expect(wm.virtualCaps.length).toBeGreaterThan(0)
4242
expect(wm.staticCaps.length).toBeGreaterThan(0)
4343
}
@@ -48,14 +48,14 @@ describe("Wm client", () => {
4848

4949
test('create client should work when schema is provided without the column', async () => {
5050
let wm = await wmClient.create('http', 'localhost', '8080', '')
51-
expect(wm.importantHeaders.length).toBe(7)
51+
expect(wm.importantHeaders.length).toBeGreaterThan(0)
5252
expect(wm.virtualCaps.length).toBeGreaterThan(0)
5353
expect(wm.staticCaps.length).toBeGreaterThan(0)
5454
});
5555

5656
test('create client should pass when schema is not passed, defaulting to http', async () => {
5757
let wm = await wmClient.create('', 'localhost', '8080', '')
58-
expect(wm.importantHeaders.length).toBe(7)
58+
expect(wm.importantHeaders.length).toBeGreaterThan(0)
5959
expect(wm.virtualCaps.length).toBeGreaterThan(0)
6060
expect(wm.staticCaps.length).toBeGreaterThan(0)
6161
})
@@ -193,8 +193,7 @@ describe("Wm client", () => {
193193
expect(device.capabilities['brand_name']).toBe('Asus')
194194
expect(device.capabilities['is_robot']).toBe('false')
195195
expect(device.capabilities['model_name']).toBe('Z017D')
196-
expect(device.capabilities['model_name']).toBe('Z017D')
197-
expect(device.capabilities['form_factor']).toBe('Smartphone')
196+
expect(device.capabilities['form_factor']).toBe('Feature Phone')
198197
expect(client.getCapabilityCount(device)).toBe(5)
199198

200199
// These caps have not been defined
@@ -248,7 +247,7 @@ describe("Wm client", () => {
248247
expect(device.capabilities['brand_name']).toBe('Asus')
249248
expect(device.capabilities['model_name']).toBe('Z017D')
250249
expect(device.capabilities['is_robot']).toBe('false')
251-
expect(device.capabilities['form_factor']).toBe('Smartphone')
250+
expect(device.capabilities['form_factor']).toBe('Feature Phone')
252251
expect(device.APIVersion).toBeDefined()
253252
expect(device.mtime).toBeGreaterThan(0)
254253
// This capability is not included in the filter

src/app/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
"testResultsProcessor": "jest-teamcity-reporter"
88
},
99
"description": "WURFL by ScientiaMobile. WURFL Microservice Client",
10-
"version": "3.0.0",
10+
"version": "3.1.0",
1111
"license": "Apache-2.0",
1212
"main": "./wmclient.js",
13-
"repository": "https://github.com/WURFL/wurfl-microservice-client-nodejs",
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/WURFL/wurfl-microservice-client-nodejs.git"
16+
},
1417
"author": {
1518
"name": "Andrea Castello, ScientiaMobile Inc.",
1619
"email": "support@scientiamobile.com"

src/app/wmclient.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ checkData = (jsonInfoData) => {
150150
* setRequestedCapabilities - set the given capability names to that the client requires to the WM server
151151
* @param caps {array} list of capabilities that you want to select from the ones exposed by the server
152152
* @return {void} Nothing
153+
*
154+
* @deprecated This method is deprecated and will be removed in a future version.
153155
*/
154156
WmClient.prototype.setRequestedCapabilities = function (caps) {
155157

@@ -424,7 +426,7 @@ WmClient.prototype.genericRequest = async function (method, path, reqData, parse
424426
* @return {string} this client API version
425427
*/
426428
WmClient.prototype.getApiVersion = () => {
427-
return '3.0.0'
429+
return '3.1.0'
428430
}
429431

430432
/**

0 commit comments

Comments
 (0)