@opentermsarchive/engine 12.0.0 → 12.0.1

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
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
+ [![DPG Badge](https://img.shields.io/badge/Verified-DPG-3333AB?logo=data:image/svg%2bxml;base64,PHN2ZyB3aWR0aD0iMzEiIGhlaWdodD0iMzMiIHZpZXdCb3g9IjAgMCAzMSAzMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0LjIwMDggMjEuMzY3OEwxMC4xNzM2IDE4LjAxMjRMMTEuNTIxOSAxNi40MDAzTDEzLjk5MjggMTguNDU5TDE5LjYyNjkgMTIuMjExMUwyMS4xOTA5IDEzLjYxNkwxNC4yMDA4IDIxLjM2NzhaTTI0LjYyNDEgOS4zNTEyN0wyNC44MDcxIDMuMDcyOTdMMTguODgxIDUuMTg2NjJMMTUuMzMxNCAtMi4zMzA4MmUtMDVMMTEuNzgyMSA1LjE4NjYyTDUuODU2MDEgMy4wNzI5N0w2LjAzOTA2IDkuMzUxMjdMMCAxMS4xMTc3TDMuODQ1MjEgMTYuMDg5NUwwIDIxLjA2MTJMNi4wMzkwNiAyMi44Mjc3TDUuODU2MDEgMjkuMTA2TDExLjc4MjEgMjYuOTkyM0wxNS4zMzE0IDMyLjE3OUwxOC44ODEgMjYuOTkyM0wyNC44MDcxIDI5LjEwNkwyNC42MjQxIDIyLjgyNzdMMzAuNjYzMSAyMS4wNjEyTDI2LjgxNzYgMTYuMDg5NUwzMC42NjMxIDExLjExNzdMMjQuNjI0MSA5LjM1MTI3WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)](https://digitalpublicgoods.net/r/open-terms-archive)
6
+
5
7
  For documentation, visit [docs.opentermsarchive.org](https://docs.opentermsarchive.org/)
6
8
 
7
9
  ## Testing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "Tracks and makes visible changes to the terms of online services",
5
5
  "homepage": "https://opentermsarchive.org",
6
6
  "bugs": {
@@ -137,7 +137,11 @@ No changes were found in the last run, so no new version has been recorded.`,
137
137
  });
138
138
  const contributionToolUrl = `${CONTRIBUTION_TOOL_URL}?${contributionToolParams}`;
139
139
 
140
- const latestDeclarationLink = `[Latest declaration](${this.reporter.generateDeclarationURL(terms.service.name)})`;
140
+ const declarationFileUrl = this.reporter.generateDeclarationURL(terms.service.name);
141
+ const updateDeclarationLink = terms.hasMultipleSourceDocuments ? `[on GitHub](${declarationFileUrl})` : `[on the contribution tool](${contributionToolUrl})`;
142
+ const multiDocumentsUpdateInfo = terms.hasMultipleSourceDocuments ? ' (the contribution tool does not support multi-document)' : '';
143
+
144
+ const latestDeclarationLink = `[Latest declaration](${declarationFileUrl})`;
141
145
  const latestVersionLink = `[Latest version](${this.reporter.generateVersionURL(terms.service.name, terms.type)})`;
142
146
  const snapshotsBaseUrl = this.reporter.generateSnapshotsBaseUrl(terms.service.name, terms.type);
143
147
  const latestSnapshotsLink = terms.hasMultipleSourceDocuments
@@ -163,13 +167,13 @@ First of all, check if the source documents are accessible through a web browser
163
167
 
164
168
  #### If the source documents are accessible through a web browser
165
169
 
166
- [Edit the declaration](${contributionToolUrl}):
170
+ Edit the declaration ${updateDeclarationLink}${multiDocumentsUpdateInfo}:
167
171
  - Try updating the selectors.
168
172
  - Try switching client scripts on with expert mode.
169
173
 
170
174
  #### If the source documents are not accessible anymore
171
175
 
172
- - If the source documents have moved, find their new location and [update it](${contributionToolUrl}).
176
+ - If the source documents have moved, find their new location and update it ${updateDeclarationLink}.
173
177
  - If these terms have been removed, move them from the declaration to its [history file](${DOC_URL}/terms/explanation/declarations-maintenance/#service-history-reference), using \`${validUntil}\` as the \`validUntil\` value.
174
178
  - If the service has closed, move the entire contents of the declaration to its [history file](${DOC_URL}/contributing-terms/#service-history), using \`${validUntil}\` as the \`validUntil\` value.
175
179
 
@@ -60,4 +60,66 @@ describe('Reporter', () => {
60
60
  });
61
61
  });
62
62
  });
63
+
64
+ describe('#generateDescription', () => {
65
+ const buildReporter = () => new Reporter({
66
+ type: 'github',
67
+ repositories: { declarations: 'OpenTermsArchive/test-declarations' },
68
+ });
69
+
70
+ const buildTerms = ({ sourceCount = 1 } = {}) => {
71
+ const sourceDocuments = Array.from({ length: sourceCount }, (_, index) => ({
72
+ id: `source-${index}`,
73
+ location: `https://example.com/source-${index}`,
74
+ mimeType: 'text/html',
75
+ snapshotId: `snapshot-${index}`,
76
+ toPersistence: () => ({ fetch: `https://example.com/source-${index}` }),
77
+ }));
78
+
79
+ return {
80
+ service: { id: 'TestService', name: 'TestService' },
81
+ type: 'Terms of Service',
82
+ sourceDocuments,
83
+ hasMultipleSourceDocuments: sourceCount > 1,
84
+ toPersistence: () => ({
85
+ name: 'TestService',
86
+ terms: {
87
+ 'Terms of Service': sourceCount > 1
88
+ ? { combine: sourceDocuments.map(sourceDocument => sourceDocument.toPersistence()) }
89
+ : sourceDocuments[0].toPersistence(),
90
+ },
91
+ }),
92
+ };
93
+ };
94
+
95
+ const error = { reasons: ['HTTP code 404'] };
96
+
97
+ context('when the terms has a single source document', () => {
98
+ it('deep-links to the contribution tool with the serialized declaration as the edit target', () => {
99
+ const description = buildReporter().generateDescription({ error, terms: buildTerms({ sourceCount: 1 }) });
100
+
101
+ expect(description).to.match(/\(https:\/\/contribute\.opentermsarchive\.org\/[^)]*\bjson=[^)]*\)/);
102
+ });
103
+ });
104
+
105
+ context('when the terms has multiple source documents (combine)', () => {
106
+ it('does not deep-link to the contribution tool because it cannot edit multi-source declarations', () => {
107
+ const description = buildReporter().generateDescription({ error, terms: buildTerms({ sourceCount: 5 }) });
108
+
109
+ expect(description).to.not.include('json=');
110
+ });
111
+
112
+ it('links to the declaration file on GitHub as the edit target', () => {
113
+ const description = buildReporter().generateDescription({ error, terms: buildTerms({ sourceCount: 5 }) });
114
+
115
+ expect(description).to.include('github.com/OpenTermsArchive/test-declarations/blob/main/declarations/TestService.json');
116
+ });
117
+
118
+ it('keeps the description below the GitHub 65,536-character issue body limit even with many sources', () => {
119
+ const description = buildReporter().generateDescription({ error, terms: buildTerms({ sourceCount: 50 }) });
120
+
121
+ expect(description.length).to.be.lessThan(65000);
122
+ });
123
+ });
124
+ });
63
125
  });