@opentermsarchive/engine 4.2.0 → 5.0.0
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/README.md +1 -1
- package/package.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceA.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceAMultipleTermsUpdated.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceATermsAdded.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceATermsRemoved.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceATermsUpdated.json +1 -1
- package/scripts/declarations/utils/fixtures/serviceB.json +1 -1
- package/scripts/declarations/utils/index.js +4 -4
- package/scripts/declarations/validate/service.schema.js +2 -2
- package/src/archivist/services/index.js +3 -3
- package/src/archivist/services/terms.js +1 -1
- package/src/archivist/services/terms.test.js +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Open Terms Archive Engine
|
|
2
2
|
|
|
3
|
-
This codebase is a Node.js module enabling downloading, archiving and publishing versions of
|
|
3
|
+
This codebase is a Node.js module enabling downloading, archiving and publishing versions of terms obtained online. It can be used independently from the Open Terms Archive ecosystem. For a high-level overview of Open Terms Archive’s wider goals and processes, please read its [public homepage](https://opentermsarchive.org).
|
|
4
4
|
|
|
5
5
|
For documentation, visit [docs.opentermsarchive.org](https://docs.opentermsarchive.org/)
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -50,14 +50,14 @@ export default class DeclarationUtils {
|
|
|
50
50
|
if (modifiedFilePath.endsWith('.filters.js')) {
|
|
51
51
|
const declaration = await this.getJSONFromFile(this.defaultBranch, `declarations/${serviceId}.json`);
|
|
52
52
|
|
|
53
|
-
servicesTermsTypes[serviceId] = Object.keys(declaration.
|
|
53
|
+
servicesTermsTypes[serviceId] = Object.keys(declaration.terms); // Considering how rarely filters are used, simply return all term types that could potentially be impacted to spare implementing a function change check
|
|
54
54
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const originalService = await this.getJSONFromFile(this.defaultBranch, modifiedFilePath);
|
|
59
59
|
const modifiedService = await this.getJSONFromFile('HEAD', modifiedFilePath);
|
|
60
|
-
const modifiedServiceTermsTypes = Object.keys(modifiedService.
|
|
60
|
+
const modifiedServiceTermsTypes = Object.keys(modifiedService.terms);
|
|
61
61
|
|
|
62
62
|
if (!originalService) {
|
|
63
63
|
servicesTermsTypes[serviceId] = modifiedServiceTermsTypes;
|
|
@@ -65,11 +65,11 @@ export default class DeclarationUtils {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const originalServiceTermsTypes = Object.keys(originalService.
|
|
68
|
+
const originalServiceTermsTypes = Object.keys(originalService.terms);
|
|
69
69
|
|
|
70
70
|
modifiedServiceTermsTypes.forEach(termsType => {
|
|
71
71
|
const areTermsAdded = !originalServiceTermsTypes.includes(termsType);
|
|
72
|
-
const areTermsModified = JSON.stringify(originalService.
|
|
72
|
+
const areTermsModified = JSON.stringify(originalService.terms[termsType]) != JSON.stringify(modifiedService.terms[termsType]);
|
|
73
73
|
|
|
74
74
|
if (!areTermsAdded && !areTermsModified) {
|
|
75
75
|
return;
|
|
@@ -24,14 +24,14 @@ const schema = {
|
|
|
24
24
|
type: 'object',
|
|
25
25
|
additionalProperties: false,
|
|
26
26
|
title: 'Service declaration',
|
|
27
|
-
required: [ 'name', '
|
|
27
|
+
required: [ 'name', 'terms' ],
|
|
28
28
|
properties: {
|
|
29
29
|
name: {
|
|
30
30
|
type: 'string',
|
|
31
31
|
title: 'Service public name',
|
|
32
32
|
examples: ['Facebook'],
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
terms: {
|
|
35
35
|
type: 'object',
|
|
36
36
|
properties: termsProperties(),
|
|
37
37
|
propertyNames: { enum: AVAILABLE_TYPES_NAME },
|
|
@@ -21,7 +21,7 @@ export async function load(servicesIdsToLoad = []) {
|
|
|
21
21
|
const services = {};
|
|
22
22
|
|
|
23
23
|
await Promise.all(servicesIds.map(async serviceId => {
|
|
24
|
-
const { name,
|
|
24
|
+
const { name, terms } = await loadServiceDeclaration(serviceId);
|
|
25
25
|
|
|
26
26
|
const service = new Service({ id: serviceId, name });
|
|
27
27
|
|
|
@@ -220,9 +220,9 @@ async function loadServiceHistoryFiles(serviceId) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
Object.keys(serviceDeclaration.
|
|
223
|
+
Object.keys(serviceDeclaration.terms).forEach(termsType => {
|
|
224
224
|
serviceHistory[termsType] = serviceHistory[termsType] || [];
|
|
225
|
-
serviceHistory[termsType].push(serviceDeclaration.
|
|
225
|
+
serviceHistory[termsType].push(serviceDeclaration.terms[termsType]);
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
sortHistory(serviceHistory);
|
|
@@ -16,7 +16,7 @@ export default class Terms {
|
|
|
16
16
|
toPersistence() {
|
|
17
17
|
return {
|
|
18
18
|
name: this.service.name,
|
|
19
|
-
|
|
19
|
+
terms: {
|
|
20
20
|
[this.type]: this.hasMultipleSourceDocuments
|
|
21
21
|
? { combine: this.sourceDocuments.map(sourceDocument => sourceDocument.toPersistence()) }
|
|
22
22
|
: this.sourceDocuments[0].toPersistence(),
|
|
@@ -65,7 +65,7 @@ describe('Terms', () => {
|
|
|
65
65
|
|
|
66
66
|
const expectedResult = {
|
|
67
67
|
name: service.name,
|
|
68
|
-
|
|
68
|
+
terms: { [termsType]: document1AsJSON },
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
expect(result).to.deep.equal(expectedResult);
|
|
@@ -76,7 +76,7 @@ describe('Terms', () => {
|
|
|
76
76
|
|
|
77
77
|
const expectedResult = {
|
|
78
78
|
name: service.name,
|
|
79
|
-
|
|
79
|
+
terms: { [termsType]: { combine: [ document1AsJSON, document2AsJSON ] } },
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
expect(result).to.deep.equal(expectedResult);
|