@opentermsarchive/engine 10.5.0 → 10.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "10.5.0",
3
+ "version": "10.6.1",
4
4
  "description": "Tracks and makes visible changes to the terms of online services",
5
5
  "homepage": "https://opentermsarchive.org",
6
6
  "bugs": {
@@ -50,6 +50,10 @@ export default class DeclarationUtils {
50
50
  if (modifiedFilePath.endsWith('.filters.js') || modifiedFilePath.endsWith('.filters.history.js')) {
51
51
  const declaration = await this.getJSONFromFile(this.defaultBranch, `declarations/${serviceId}.json`);
52
52
 
53
+ if (!declaration) { // Happens when the file declaration exists in the branch but not in the default branch
54
+ return;
55
+ }
56
+
53
57
  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
58
 
55
59
  return;
@@ -188,6 +188,23 @@ describe('DeclarationUtils', () => {
188
188
  });
189
189
  });
190
190
 
191
+ context('when a new declaration has been added along with a filters file', () => {
192
+ before(async () => {
193
+ await fs.writeFile(path.resolve(SUBJECT_PATH, COMMIT_PATHS.serviceB), JSON.stringify(FIXTURES.serviceB.content, null, 2));
194
+ await fs.writeFile(path.resolve(SUBJECT_PATH, './declarations/ServiceB.filters.js'), 'module.exports = {};');
195
+ await declarationUtils.git.add([ COMMIT_PATHS.serviceB, './declarations/ServiceB.filters.js' ]);
196
+ await declarationUtils.git.commit('Add declaration with filters for new service');
197
+ });
198
+ after(removeLatestCommit);
199
+
200
+ it('returns the added service ID along with all its terms types', async () => {
201
+ expect(await declarationUtils.getModifiedServicesAndTermsTypes()).to.deep.equal({
202
+ services: ['ServiceB'],
203
+ servicesTermsTypes: { ServiceB: ['Terms of Service'] },
204
+ });
205
+ });
206
+ });
207
+
191
208
  context('when history file is modified without declaration changes', () => {
192
209
  before(() => commitChanges(COMMIT_PATHS.serviceAHistory, FIXTURES.serviceATermsUpdatedHistory.content));
193
210
  after(removeLatestCommit);
@@ -10,6 +10,7 @@ export class FetchDocumentError extends Error {
10
10
  'EAI_AGAIN', // DNS lookup temporary failure - DNS server is temporarily unavailable or overloaded
11
11
  'ETIMEDOUT', // Connection timeout - network latency or server load issues
12
12
  'ERR_NAME_NOT_RESOLVED', // DNS lookup temporary failure - DNS server is temporarily unavailable or overloaded
13
+ 'Timed out after', // Navigation timeout - page took too long to load, might be temporary server overload
13
14
  'HTTP code 500', // Internal Server Error - server encountered an error while processing the request
14
15
  'HTTP code 503', // Service Unavailable - server is temporarily overloaded or down for maintenance
15
16
  'HTTP code 504', // Gateway Timeout - upstream server took too long to respond, might be temporary