@opentermsarchive/engine 4.1.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/src/reporter/gitlab/index.js +6 -9
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);
|
|
@@ -18,9 +18,7 @@ export default class GitLab {
|
|
|
18
18
|
static ISSUE_STATE_ALL = 'all';
|
|
19
19
|
|
|
20
20
|
constructor(repository, baseURL = BASE_URL, apiBaseURL = API_BASE_URL) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.commonParams = { owner, repo };
|
|
21
|
+
this.repositoryPath = repository;
|
|
24
22
|
this.projectId = null;
|
|
25
23
|
this.baseURL = baseURL;
|
|
26
24
|
console.log('this.baseURL', this.baseURL);
|
|
@@ -31,9 +29,8 @@ export default class GitLab {
|
|
|
31
29
|
const options = GitLab.baseOptionsHttpReq();
|
|
32
30
|
|
|
33
31
|
try {
|
|
34
|
-
const repositoryPath = `${this.commonParams.owner}/${this.commonParams.repo}`;
|
|
35
32
|
const response = await nodeFetch(
|
|
36
|
-
`${this.apiBaseURL}/projects/${encodeURIComponent(repositoryPath)}`,
|
|
33
|
+
`${this.apiBaseURL}/projects/${encodeURIComponent(this.repositoryPath)}`,
|
|
37
34
|
options,
|
|
38
35
|
);
|
|
39
36
|
|
|
@@ -42,7 +39,7 @@ export default class GitLab {
|
|
|
42
39
|
if (response.ok) {
|
|
43
40
|
this.projectId = res.id;
|
|
44
41
|
} else {
|
|
45
|
-
logger.error(`Error while obtaining projectId: ${JSON.
|
|
42
|
+
logger.error(`Error while obtaining projectId: ${JSON.stringify(res)}`);
|
|
46
43
|
this.projectId = null;
|
|
47
44
|
}
|
|
48
45
|
} catch (error) {
|
|
@@ -367,15 +364,15 @@ export default class GitLab {
|
|
|
367
364
|
}
|
|
368
365
|
|
|
369
366
|
generateDeclarationURL(serviceName) {
|
|
370
|
-
return `${this.baseURL}/${this.
|
|
367
|
+
return `${this.baseURL}/${this.repositoryPath}/-/blob/main/declarations/${encodeURIComponent(serviceName)}.json`;
|
|
371
368
|
}
|
|
372
369
|
|
|
373
370
|
generateVersionURL(serviceName, termsType) {
|
|
374
|
-
return `${this.baseURL}/${this.
|
|
371
|
+
return `${this.baseURL}/${this.repositoryPath}/-/blob/main/${encodeURIComponent(serviceName)}/${encodeURIComponent(serviceName, termsType)}.md`;
|
|
375
372
|
}
|
|
376
373
|
|
|
377
374
|
generateSnapshotsBaseUrl(serviceName, termsType) {
|
|
378
|
-
return `${this.baseURL}/${this.
|
|
375
|
+
return `${this.baseURL}/${this.repositoryPath}/-/blob/main/${encodeURIComponent(serviceName)}/${encodeURIComponent(termsType)}`;
|
|
379
376
|
}
|
|
380
377
|
|
|
381
378
|
// GitLab API responses are not cached unlike GitHub, so this method only exists to satisfy the Reporter interface contract
|