fiftyone.pipeline.engines.fiftyone 4.4.91 → 4.4.93
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/examples/usageSharing/usageSharing.js +49 -53
- package/package.json +1 -1
- package/shareUsage.js +26 -24
- package/tests/shareUsage.test.js +22 -22
|
@@ -1,59 +1,55 @@
|
|
|
1
|
-
/* *********************************************************************
|
|
2
|
-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
-
* Copyright 2023 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.
|
|
1
|
+
/* *********************************************************************
|
|
2
|
+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
* Copyright 2023 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
21
|
* ********************************************************************* */
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
@example usageSharing/usageSharing.js
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Pipeline created with share usage element. Evidence processed
|
|
54
|
-
with this pipeline will now be shared with 51Degrees using the
|
|
55
|
-
specified configuration.
|
|
56
|
-
```
|
|
24
|
+
* @example usageSharing/usageSharing.js
|
|
25
|
+
*
|
|
26
|
+
* Usage sharing is enabled by default if using some 51Degrees pipeline
|
|
27
|
+
* builders such as the [DeviceDetectionOnPremisePipelineBuilder](https://github.com/51Degrees/device-detection-node/blob/master/fiftyone.devicedetection.onpremise/deviceDetectionOnPremisePipelineBuilder.js)
|
|
28
|
+
* In this example, we show how to specifically add a shareUsage element to a
|
|
29
|
+
* Pipeline using configuration.
|
|
30
|
+
*
|
|
31
|
+
* As with all flow elements, this can also be handled in code, using
|
|
32
|
+
* the constructor parameters. The commented section in the example
|
|
33
|
+
* demonstrates this.
|
|
34
|
+
*
|
|
35
|
+
* The 51d.json file contains all the configuration options.
|
|
36
|
+
* These are all optional, so each can be omitted if the default
|
|
37
|
+
* for that option is sufficient:
|
|
38
|
+
*
|
|
39
|
+
* For details of what each setting does, see the constructor
|
|
40
|
+
* parameters in the reference documentation for the
|
|
41
|
+
* [share usage element](https://51degrees.com/pipeline-node/class_share_usage.html)
|
|
42
|
+
*
|
|
43
|
+
* This example is available in full on [GitHub](https://github.com/51Degrees/pipeline-node/tree/master/fiftyone.pipeline.engines.fiftyone/examples/usageSharing/usageSharing.js).
|
|
44
|
+
*
|
|
45
|
+
* Expected output
|
|
46
|
+
* ```
|
|
47
|
+
* Constructing pipeline from configuration file.
|
|
48
|
+
*
|
|
49
|
+
* Pipeline created with share usage element. Evidence processed
|
|
50
|
+
* with this pipeline will now be shared with 51Degrees using the
|
|
51
|
+
* specified configuration.
|
|
52
|
+
* ```
|
|
57
53
|
*/
|
|
58
54
|
|
|
59
55
|
const core = require('fiftyone.pipeline.core');
|
package/package.json
CHANGED
package/shareUsage.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/* *********************************************************************
|
|
2
|
-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
-
* Copyright 2023 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.
|
|
1
|
+
/* *********************************************************************
|
|
2
|
+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
* Copyright 2023 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
21
|
* ********************************************************************* */
|
|
22
22
|
|
|
23
23
|
const engines = require('fiftyone.pipeline.engines');
|
|
@@ -73,7 +73,8 @@ class ShareUsage extends Engine {
|
|
|
73
73
|
* be excluded from sharing by adding them to this list.
|
|
74
74
|
* @param {number} options.sharePercentage approximate proportion of
|
|
75
75
|
* requests to be shared. 1 = 100%, 0.5 = 50%, etc..
|
|
76
|
-
* @param options.endpoint
|
|
76
|
+
* @param {string} options.endpoint The target destination for usage
|
|
77
|
+
* sharing data. The default is https://devices-v4.51degrees.com/new.ashx.
|
|
77
78
|
*/
|
|
78
79
|
constructor (
|
|
79
80
|
{
|
|
@@ -146,7 +147,7 @@ class ShareUsage extends Engine {
|
|
|
146
147
|
* within the flow data provided.
|
|
147
148
|
*
|
|
148
149
|
* @param {FlowData} flowData the flow data containing the evidence to use
|
|
149
|
-
* @returns
|
|
150
|
+
* @returns {ShareUsageData} New ShareUsageData instance, populated from the evidence
|
|
150
151
|
* provided
|
|
151
152
|
*/
|
|
152
153
|
getDataFromEvidence (flowData) {
|
|
@@ -312,7 +313,7 @@ class ShareUsage extends Engine {
|
|
|
312
313
|
* If the list is null then populate from the pipeline.
|
|
313
314
|
* If there are multiple or no pipelines then log an error.
|
|
314
315
|
*
|
|
315
|
-
* @returns list of flow elements
|
|
316
|
+
* @returns {Array<FlowElement>} list of flow elements
|
|
316
317
|
*/
|
|
317
318
|
getFlowElements () {
|
|
318
319
|
if (!this.flowElements) {
|
|
@@ -344,11 +345,12 @@ const VALID_XML_CHARS =
|
|
|
344
345
|
.concat(
|
|
345
346
|
Array.from({ length: parseInt('0x100', 16) - parseInt('0x40', 16) }, (v, k) => k + parseInt('0x40', 16)));
|
|
346
347
|
|
|
347
|
-
// an array describing whether a character value is valid
|
|
348
348
|
const IS_VALID_XML_CHAR = __getIsValidCharMap();
|
|
349
349
|
|
|
350
350
|
/**
|
|
351
|
+
* Get an object describing whether a character value is valid
|
|
351
352
|
*
|
|
353
|
+
* @returns {object} Object of valid chars
|
|
352
354
|
*/
|
|
353
355
|
function __getIsValidCharMap () {
|
|
354
356
|
const maxChar = parseInt('0x100', 16);
|
package/tests/shareUsage.test.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/* *********************************************************************
|
|
2
|
-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
-
* Copyright 2023 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.
|
|
1
|
+
/* *********************************************************************
|
|
2
|
+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
* Copyright 2023 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
21
|
* ********************************************************************* */
|
|
22
22
|
|
|
23
23
|
const { PipelineBuilder } = require('fiftyone.pipeline.core');
|
|
@@ -36,8 +36,8 @@ let server = null;
|
|
|
36
36
|
/**
|
|
37
37
|
* Local server used to capture usage data sent.
|
|
38
38
|
*
|
|
39
|
-
* @param req the request
|
|
40
|
-
* @param res the response
|
|
39
|
+
* @param {http.IncomingMessage} req the request
|
|
40
|
+
* @param {http.ServerResponse} res the response
|
|
41
41
|
*/
|
|
42
42
|
const requestListener = function (req, res) {
|
|
43
43
|
let data = '';
|