fiftyone.devicedetection.onpremise 4.4.2 → 4.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/component.js ADDED
@@ -0,0 +1,39 @@
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
+ * ********************************************************************* */
22
+
23
+ class Component {
24
+ constructor (metadata, engineMetadata) {
25
+ this.metadata = metadata;
26
+ this.engineMetadata = engineMetadata;
27
+ this.name = metadata.getName();
28
+ this.properties = engineMetadata.getPropertiesForComponent(metadata);
29
+ }
30
+
31
+ * getProperties () {
32
+ const Property = require('./property');
33
+ for (let i = 0; i < this.properties.getSize(); i++) {
34
+ yield new Property(this.properties.getByIndex(i), this.engineMetadata);
35
+ }
36
+ }
37
+ }
38
+
39
+ module.exports = Component;
package/constants.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
@@ -34,6 +34,10 @@ const EvidenceKeyFilter = core.BasicListEvidenceKeyFilter;
34
34
  const fs = require('fs');
35
35
  const util = require('util');
36
36
  const constants = require('./constants');
37
+ const metricCategory = 'Device metrics';
38
+ const Component = require('./component');
39
+ const Property = require('./property');
40
+ const Profile = require('./profile');
37
41
 
38
42
  /**
39
43
  * @typedef {import('fiftyone.pipeline.engines').DataKeyedCache} DataKeyedCache
@@ -43,6 +47,120 @@ const constants = require('./constants');
43
47
 
44
48
  const nodeVersion = Number(process.version.match(/^v(\d+\.)/)[1]);
45
49
 
50
+ // Private method to init properties.
51
+ // This should only be called by the call() method with an input for 'this'
52
+ // object.
53
+ const initProperties = function (metadata) {
54
+ const propertiesInternal = metadata.getProperties();
55
+ const properties = {};
56
+
57
+ for (var i = 0; i < propertiesInternal.getSize(); i++) {
58
+ var property = propertiesInternal.getByIndex(i);
59
+ if (property.getAvailable()) {
60
+ properties[property.getName().toLowerCase()] =
61
+ new Property(property, metadata);
62
+ }
63
+ };
64
+ this.properties = properties;
65
+ };
66
+
67
+ // Private method to init components
68
+ // This should only be called by the call() method with an input for 'this'
69
+ // object.
70
+ const initComponents = function (metadata) {
71
+ // Get components list
72
+ const componentsInternal = metadata.getComponents();
73
+
74
+ const components = {};
75
+ for (let i = 0; i < componentsInternal.getSize(); i++) {
76
+ const component = componentsInternal.getByIndex(i);
77
+ components[component.getName().toLowerCase()] =
78
+ new Component(component, metadata);
79
+ }
80
+ this.components = components;
81
+ };
82
+
83
+ const initMatchMetrics = function () {
84
+ // Add a component for Device Metrics
85
+ const metricComponent = {
86
+ name: 'Metrics'
87
+ };
88
+ metricComponent.getProperties = function * (limit) {
89
+ for (const property of metricComponent.properties) {
90
+ yield property;
91
+ }
92
+ };
93
+
94
+ // Special properties
95
+ this.properties.deviceID = {
96
+ name: 'DeviceId',
97
+ type: 'string',
98
+ category: metricCategory,
99
+ description: constants.deviceIdDescription,
100
+ component: metricComponent
101
+ };
102
+
103
+ this.properties.userAgents = {
104
+ name: 'UserAgents',
105
+ type: 'string[]',
106
+ category: metricCategory,
107
+ description: constants.userAgentsDescription,
108
+ component: metricComponent
109
+ };
110
+
111
+ this.properties.difference = {
112
+ name: 'Difference',
113
+ type: 'int',
114
+ category: metricCategory,
115
+ description: constants.differenceDescription,
116
+ component: metricComponent
117
+ };
118
+
119
+ this.properties.method = {
120
+ name: 'Method',
121
+ type: 'string',
122
+ category: metricCategory,
123
+ description: constants.methodDescription,
124
+ component: metricComponent
125
+ };
126
+
127
+ this.properties.matchedNodes = {
128
+ name: 'MatchedNodes',
129
+ type: 'int',
130
+ category: metricCategory,
131
+ description: constants.matchedNodesDescription,
132
+ component: metricComponent
133
+ };
134
+
135
+ this.properties.drift = {
136
+ name: 'Drift',
137
+ type: 'int',
138
+ category: metricCategory,
139
+ description: constants.driftDescription,
140
+ component: metricComponent
141
+ };
142
+
143
+ this.properties.iterations = {
144
+ name: 'Iterations',
145
+ type: 'int',
146
+ category: metricCategory,
147
+ description: constants.iterationsDescription,
148
+ component: metricComponent
149
+ };
150
+
151
+ metricComponent.properties = [
152
+ this.properties.deviceID,
153
+ this.properties.userAgents,
154
+ this.properties.difference,
155
+ this.properties.method,
156
+ this.properties.matchedNodes,
157
+ this.properties.drift,
158
+ this.properties.iterations
159
+ ];
160
+
161
+ this.components.metrics = metricComponent;
162
+ };
163
+
46
164
  /**
47
165
  * On premise version of the 51Degrees Device Detection Engine
48
166
  * Uses a data file to process evidence in FlowData and create results
@@ -323,77 +441,10 @@ class DeviceDetectionOnPremise extends Engine {
323
441
 
324
442
  // Get properties list
325
443
 
326
- const propertiesInternal = engine.getMetaData().getProperties();
327
-
328
- const properties = {};
329
-
330
- for (var i = 0; i < propertiesInternal.getSize(); i++) {
331
- var property = propertiesInternal.getByIndex(i);
332
- if (property.getAvailable()) {
333
- properties[property.getName().toLowerCase()] = {
334
- name: property.getName(),
335
- type: property.getType(),
336
- datafiles: swigHelpers.vectorToArray(property.getDataFilesWherePresent()),
337
- category: property.getCategory(),
338
- description: property.getDescription()
339
- };
340
- }
341
- };
342
-
343
- current.properties = properties;
344
-
345
- // Special properties
346
-
347
- current.properties.deviceID = {
348
- name: 'DeviceId',
349
- type: 'string',
350
- category: 'Device metrics',
351
- description: constants.deviceIdDescription
352
- };
353
-
354
- current.properties.userAgents = {
355
- name: 'UserAgents',
356
- type: 'string[]',
357
- category: 'Device metrics',
358
- description: constants.userAgentsDescription
359
- };
360
-
361
- current.properties.difference = {
362
- name: 'Difference',
363
- type: 'int',
364
- category: 'Device metrics',
365
- description: constants.differenceDescription
366
- };
367
-
368
- current.properties.method = {
369
- name: 'Method',
370
- type: 'string',
371
- category: 'Device metrics',
372
- description: constants.methodDescription
373
- };
374
-
375
- if (swigWrapperType === 'Hash') {
376
- current.properties.matchedNodes = {
377
- name: 'MatchedNodes',
378
- type: 'int',
379
- category: 'Device metrics',
380
- description: constants.matchedNodesDescription
381
- };
382
-
383
- current.properties.drift = {
384
- name: 'Drift',
385
- type: 'int',
386
- category: 'Device metrics',
387
- description: constants.driftDescription
388
- };
389
-
390
- current.properties.iterations = {
391
- name: 'Iterations',
392
- type: 'int',
393
- category: 'Device metrics',
394
- description: constants.iterationsDescription
395
- };
396
- }
444
+ const metadata = engine.getMetaData();
445
+ initProperties.call(current, metadata);
446
+ initComponents.call(current, metadata);
447
+ initMatchMetrics.call(current);
397
448
  });
398
449
  };
399
450
 
@@ -473,6 +524,14 @@ class DeviceDetectionOnPremise extends Engine {
473
524
  this.registerDataFile(ddDatafile);
474
525
  }
475
526
 
527
+ * profiles () {
528
+ const engineMetadata = this.engine.getMetaData();
529
+ const profilesInternal = engineMetadata.getProfiles();
530
+ for (let i = 0; i < profilesInternal.getSize(); i++) {
531
+ yield new Profile(profilesInternal.getByIndex(i), engineMetadata);
532
+ }
533
+ }
534
+
476
535
  /**
477
536
  * Internal process method for Device Detection On Premise engine
478
537
  * Fetches the results from the SWIG wrapper into an instance of
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiftyone.devicedetection.onpremise",
3
- "version": "4.4.2",
3
+ "version": "4.4.6",
4
4
  "description": "Device detection on-premise services for the 51Degrees Pipeline API",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -22,23 +22,25 @@
22
22
  "Tung Pham <tung@51degrees.com> (https://51degrees.com)"
23
23
  ],
24
24
  "dependencies": {
25
- "fiftyone.devicedetection.shared": "^4.4.2",
26
- "fiftyone.pipeline.core": "^4.4.0",
27
- "fiftyone.pipeline.engines": "^4.4.0",
28
- "fiftyone.pipeline.engines.fiftyone": "^4.4.0",
25
+ "fiftyone.devicedetection.shared": "^4.4.7",
26
+ "fiftyone.pipeline.core": "^4.4.1",
27
+ "fiftyone.pipeline.engines": "^4.4.1",
28
+ "fiftyone.pipeline.engines.fiftyone": "^4.4.1",
29
+ "js-yaml": "^4.1.0",
29
30
  "n-readlines": "^1.0.1"
30
31
  },
31
32
  "devDependencies": {
32
- "eslint": "^6.8.0",
33
- "eslint-config-standard": "^14.1.1",
34
- "eslint-plugin-import": "^2.20.2",
35
- "eslint-plugin-jsdoc": "^25.4.0",
33
+ "@types/node": "^15.12.2",
34
+ "eslint": "^8.16.0",
35
+ "eslint-config-standard": "^17.0.0",
36
+ "eslint-plugin-import": "^2.26.0",
37
+ "eslint-plugin-jsdoc": "^38.1.6",
36
38
  "eslint-plugin-node": "^11.1.0",
37
- "eslint-plugin-promise": "^4.2.1",
38
- "eslint-plugin-standard": "^4.0.1",
39
- "eslint-plugin-jest": "^23.13.2",
40
- "jest": "^24.9.0",
41
- "jest-junit": "^9.0.0"
39
+ "eslint-plugin-promise": "^6.0.0",
40
+ "eslint-plugin-jest": "^26.2.2",
41
+ "eslint-plugin-n": "^15.0.0",
42
+ "jest": "^28.1.0",
43
+ "jest-junit": "^13.2.0"
42
44
  },
43
45
  "license": "EUPL-1.2",
44
46
  "bugs": {
package/profile.js ADDED
@@ -0,0 +1,35 @@
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
+ * ********************************************************************* */
22
+
23
+ class Profile {
24
+ constructor (metadata, engineMetadata) {
25
+ this.metadata = metadata;
26
+ this.engineMetadata = engineMetadata;
27
+
28
+ const Component = require('./component');
29
+ this.component = new Component(
30
+ engineMetadata.getComponentForProfile(metadata), engineMetadata);
31
+ this.profileId = metadata.getProfileId();
32
+ }
33
+ }
34
+
35
+ module.exports = Profile;
package/property.js ADDED
@@ -0,0 +1,54 @@
1
+ /* *********************************************************************
2
+ * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
+ *
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
+ *
9
+ * If a copy of the EUPL was not distributed with this file, You can obtain
10
+ * one at https://opensource.org/licenses/EUPL-1.2.
11
+ *
12
+ * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13
+ * amended by the European Commission) shall be deemed incompatible for
14
+ * the purposes of the Work and the provisions of the compatibility
15
+ * clause in Article 5 of the EUPL shall not apply.
16
+ *
17
+ * If using the Work as, or as part of, a network application, by
18
+ * including the attribution notice(s) required under Article 5 of the EUPL
19
+ * in the end user terms of the application under an appropriate heading,
20
+ * such notice(s) shall fulfill the requirements of that article.
21
+ * ********************************************************************* */
22
+
23
+ const swigHelpers = require('./swigHelpers');
24
+
25
+ class Property {
26
+ constructor (
27
+ metadata,
28
+ engineMetadata) {
29
+ this.metadata = metadata;
30
+ this.engineMetadata = engineMetadata;
31
+ this.name = metadata.getName();
32
+ this.type = metadata.getType();
33
+ this.dataFiles = swigHelpers.vectorToArray(metadata.getDataFilesWherePresent());
34
+ this.category = metadata.getCategory();
35
+ this.description = metadata.getDescription();
36
+
37
+ const Component = require('./component');
38
+ this.component = new Component(
39
+ engineMetadata.getComponentForProperty(metadata), engineMetadata);
40
+ this.values = engineMetadata.getValuesForProperty(metadata);
41
+ }
42
+
43
+ * getValues () {
44
+ for (let i = 0; i < this.values.getSize(); i++) {
45
+ yield this.values.getByIndex(i);
46
+ }
47
+ }
48
+
49
+ getNumberOfValues () {
50
+ return this.values.getSize();
51
+ }
52
+ }
53
+
54
+ module.exports = Property;
package/swigData.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.
package/swigHelpers.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /* *********************************************************************
2
2
  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3
- * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4
- * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
3
+ * Copyright 2022 51 Degrees Mobile Experts Limited, Davidson House,
4
+ * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5
5
  *
6
- * This Original Work is licensed under the European Union Public Licence (EUPL)
7
- * v.1.2 and is subject to its terms as set out below.
6
+ * This Original Work is licensed under the European Union Public Licence
7
+ * (EUPL) v.1.2 and is subject to its terms as set out below.
8
8
  *
9
9
  * If a copy of the EUPL was not distributed with this file, You can obtain
10
10
  * one at https://opensource.org/licenses/EUPL-1.2.