@opentermsarchive/engine 0.26.0 → 0.27.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.
Files changed (64) hide show
  1. package/README.md +1 -469
  2. package/bin/ota-track.js +3 -3
  3. package/bin/ota-validate.js +2 -2
  4. package/bin/ota.js +1 -1
  5. package/config/default.json +1 -1
  6. package/config/test.json +2 -2
  7. package/package.json +6 -7
  8. package/scripts/dataset/export/index.js +4 -4
  9. package/scripts/dataset/export/index.test.js +11 -17
  10. package/scripts/dataset/export/test/fixtures/dataset/README.md +1 -1
  11. package/scripts/declarations/lint/index.mocha.js +1 -1
  12. package/scripts/declarations/utils/index.js +12 -12
  13. package/scripts/declarations/validate/definitions.js +1 -1
  14. package/scripts/declarations/validate/index.mocha.js +30 -34
  15. package/scripts/declarations/validate/service.history.schema.js +11 -11
  16. package/scripts/declarations/validate/service.schema.js +13 -13
  17. package/scripts/history/migrate-services.js +4 -4
  18. package/scripts/history/update-to-full-hash.js +2 -2
  19. package/scripts/import/index.js +14 -14
  20. package/scripts/rewrite/config/rewrite-snapshots.json +1 -1
  21. package/scripts/rewrite/config/rewrite-versions.json +1 -1
  22. package/scripts/rewrite/rewrite-snapshots.js +3 -3
  23. package/scripts/rewrite/rewrite-versions.js +14 -14
  24. package/scripts/utils/renamer/README.md +3 -3
  25. package/scripts/utils/renamer/index.js +13 -13
  26. package/src/archivist/errors.js +1 -1
  27. package/src/archivist/extract/exports.js +3 -0
  28. package/src/archivist/{filter → extract}/index.js +23 -27
  29. package/src/archivist/extract/index.test.js +516 -0
  30. package/src/archivist/index.js +101 -140
  31. package/src/archivist/index.test.js +178 -166
  32. package/src/archivist/recorder/index.js +11 -55
  33. package/src/archivist/recorder/index.test.js +310 -356
  34. package/src/archivist/recorder/record.js +18 -7
  35. package/src/archivist/recorder/repositories/git/dataMapper.js +41 -31
  36. package/src/archivist/recorder/repositories/git/index.js +11 -15
  37. package/src/archivist/recorder/repositories/git/index.test.js +1058 -463
  38. package/src/archivist/recorder/repositories/interface.js +8 -6
  39. package/src/archivist/recorder/repositories/mongo/dataMapper.js +21 -14
  40. package/src/archivist/recorder/repositories/mongo/index.js +8 -8
  41. package/src/archivist/recorder/repositories/mongo/index.test.js +898 -479
  42. package/src/archivist/recorder/snapshot.js +5 -0
  43. package/src/archivist/recorder/snapshot.test.js +65 -0
  44. package/src/archivist/recorder/version.js +14 -0
  45. package/src/archivist/recorder/version.test.js +65 -0
  46. package/src/archivist/services/index.js +60 -51
  47. package/src/archivist/services/index.test.js +63 -83
  48. package/src/archivist/services/service.js +26 -22
  49. package/src/archivist/services/service.test.js +46 -68
  50. package/src/archivist/services/{pageDeclaration.js → sourceDocument.js} +11 -9
  51. package/src/archivist/services/{pageDeclaration.test.js → sourceDocument.test.js} +21 -21
  52. package/src/archivist/services/terms.js +26 -0
  53. package/src/archivist/services/{documentDeclaration.test.js → terms.test.js} +15 -15
  54. package/src/exports.js +2 -2
  55. package/src/index.js +16 -13
  56. package/src/logger/index.js +35 -36
  57. package/src/notifier/index.js +8 -8
  58. package/src/tracker/index.js +6 -6
  59. package/src/archivist/filter/exports.js +0 -3
  60. package/src/archivist/filter/index.test.js +0 -564
  61. package/src/archivist/recorder/record.test.js +0 -91
  62. package/src/archivist/services/documentDeclaration.js +0 -26
  63. /package/scripts/utils/renamer/rules/{documentTypes.json → termsTypes.json} +0 -0
  64. /package/scripts/utils/renamer/rules/{documentTypesByService.json → termsTypesByService.json} +0 -0
package/README.md CHANGED
@@ -4,475 +4,7 @@ _The document you are reading now is targeted at developers wanting to use or co
4
4
 
5
5
  This codebase is a Node.js module enabling downloading, archiving and publishing versions of documents obtained online. It can be used independently from the Open Terms Archive ecosystem.
6
6
 
7
- ## Table of contents
8
-
9
- - [Motivation](#motivation)
10
- - [Main concepts](#main-concepts)
11
- - [How to add documents to a collection](#how-to-add-documents-to-a-collection)
12
- - [How to use the engine](#how-to-use-the-engine)
13
- - [Configuring](#configuring)
14
- - [Deploying](#deploying)
15
- - [Contributing](#contributing)
16
- - [License](#license)
17
-
18
- ## Motivation
19
-
20
- _Words in bold are [business domain names](https://en.wikipedia.org/wiki/Domain-driven_design)._
21
-
22
- **Services** have **terms** written in **documents**, contractual (Terms of Services, Privacy Policy…) or not (Community Guidelines, Deceased User Policy…), that can change over time. Open Terms Archive enables users rights advocates, regulatory bodies and interested citizens to follow the **changes** to these **terms**, to be notified whenever a new **version** is published, to explore their entire **history** and to collaborate in analysing them. This free and open-source engine is developed to support these goals.
23
-
24
- ## Main concepts
25
-
26
- ### Instances
27
-
28
- Open Terms Archive is a decentralised system.
29
-
30
- It aims at enabling any entity to **track** **terms** on its own and at federating a number of public **instances** in a single ecosystem to maximise discoverability, collaboration and political power. To that end, the Open Terms Archive **engine** can be run on any server, thus making it a dedicated **instance**.
31
-
32
- > Federated public instances can be [found on GitHub](
33
- https://github.com/OpenTermsArchive?q=declarations).
34
-
35
- ### Collections
36
-
37
- An **instance** **tracks** **documents** of a single **collection**.
38
-
39
- A **collection** is characterised by a **scope** across **dimensions** that describe the **terms** it **tracks**, such as **language**, **jurisdiction** and **industry**.
40
-
41
- > Federated public collections can be [found on GitHub](https://github.com/OpenTermsArchive?q=versions).
42
-
43
- #### Example scope
44
-
45
- > The documents declared in this collection are:
46
- > - Related to dating services used in Europe.
47
- > - In the European Union and Switzerland jurisdictions.
48
- > - In English, unless no English version exists, in which case the primary official language of the jurisdiction of incorporation of the service operator will be used.
49
-
50
- ### Terms types
51
-
52
- To distinguish between the different **terms** of a **service**, each has a **type**, such as “Terms of Service”, “Privacy Policy”, “Developer Agreement”…
53
-
54
- This **type** matches the topic, but not necessarily the title the **service** gives to it. Unifying the **types** enables comparing **terms** across **services**.
55
-
56
- > More information on terms types can be found in the [dedicated repository](https://github.com/OpenTermsArchive/terms-types). They are published on NPM under [`@opentermsarchive/terms-types`](https://www.npmjs.com/package/@opentermsarchive/terms-types), enabling standardisation and interoperability beyond the Open Terms Archive engine.
57
-
58
- ### Declarations
59
-
60
- The **documents** that constitute a **collection** are defined in simple JSON files called **declarations**.
61
-
62
- A **declaration** also contains some metadata on the **service** the **documents** relate to.
63
-
64
- > Here is an example declaration tracking the Privacy Policy of Open Terms Archive:
65
- >
66
- > ```json
67
- > {
68
- > "name": "Open Terms Archive",
69
- > "documents": {
70
- > "Privacy Policy": {
71
- > "fetch": "https://opentermsarchive.org/en/privacy-policy",
72
- > "select": ".TextContent_textContent__ToW2S"
73
- > }
74
- > }
75
- > }
76
- > ```
77
-
78
- ## How to add documents to a collection
79
-
80
- Open Terms Archive **acquires** **documents** to deliver an explorable **history** of **changes**. This can be done in two ways:
81
-
82
- 1. For the present and future, by **tracking** **documents**.
83
- 2. For the past, by **importing** from an existing **fonds** such as [ToSBack](https://tosback.org), the [Internet Archive](https://archive.org/web/), [Common Crawl](https://commoncrawl.org) or any other in-house format.
84
-
85
- ### Tracking documents
86
-
87
- The **engine** **reads** **declarations** to **record** a **snapshot** by **fetching** the declared web **location** periodically. The **engine** then **extracts** a **version** from this **snapshot** by:
88
-
89
- 1. **Selecting** the subset of the **snapshot** that contains the **terms** (instead of navigation menus, footers, cookies banners…).
90
- 2. **Removing** residual content in this subset that is not part of the **terms** (ads, illustrative pictures, internal navigation links…).
91
- 3. **Filtering noise** by preventing parts that change frequently from triggering false positives for **changes** (tracker identifiers in links, relative dates…). The **engine** can execute custom **filters** written in JavaScript to that end.
92
-
93
- After these steps, if **changes** are spotted in the resulting **document**, a new **version** is **recorded**.
94
-
95
- Preserving **snapshots** enables recovering after the fact information potentially lost in the **extraction** step: if **declarations** were wrong, they can be **maintained** and corrected **versions** can be **extracted** from the original **snapshots**.
96
-
97
- ### Importing documents
98
-
99
- Existing **fonds** can be prepared for easier analysis by unifying their format to the **Open Terms Archive dataset format**. This unique format enables building interoperable tools, fostering collaboration across reusers.
100
- Such a dataset can be generated from **versions** alone. If **snapshots** and **declarations** can be retrieved from the **fonds** too, then a full-fledged **collection** can be created.
101
-
102
- ## How to use the engine
103
-
104
- This documentation describes how to execute the **engine** independently from any specific **instance**. For other use cases, other parts of the documentation could be more relevant:
105
-
106
- - to contribute **declarations** to an existing **instance**, see [how to contribute documents](./docs/doc-contributing-documents.md);
107
- - to create a new **collection**, see the [collection bootstrap](https://github.com/OpenTermsArchive/template-declarations) script;
108
- - to create a new public **instance**, see the [governance](./docs/doc-governance.md) documentation.
109
-
110
- ### Requirements
111
-
112
- This module is tested to work across operating systems (continuous testing on UNIX, macOS and Windows).
113
-
114
- A [Node.js](https://nodejs.org/en/download/) runtime is required to execute this engine.
115
-
116
- ![Supported Node.js version can be found in the package.json file](https://img.shields.io/node/v/@opentermsarchive/engine?color=informational&label=Supported%20Node.js%20version)
117
-
118
- ### Getting started
119
-
120
- This engine is published as a [module on NPM](https://npmjs.com/package/@opentermsarchive/engine). The recommended install is as a dependency in a `package.json` file, next to a folder containing [declaration files](#declarations).
121
-
122
- ```sh
123
- npm install --save @opentermsarchive/engine
124
- mkdir declarations
125
- ```
126
-
127
- In an editor, create the following declaration file in `declarations/Open Terms Archive.json` to track the terms of the Open Terms Archive website:
128
-
129
- ```json
130
- {
131
- "name": "Open Terms Archive",
132
- "documents": {
133
- "Privacy Policy": {
134
- "fetch": "https://opentermsarchive.org/en/privacy-policy",
135
- "select": ".TextContent_textContent__ToW2S"
136
- }
137
- }
138
- }
139
- ```
140
-
141
- In the terminal:
142
-
143
- ```sh
144
- npx ota-track
145
- ```
146
-
147
- The tracked documents can be found in the `data` folder.
148
-
149
- This quick example aimed at letting you try the engine quickly. Most likely, you will simply `npm install` from an existing collection, or create a new collection from the [collection template](https://github.com/OpenTermsArchive/template-declarations).
150
-
151
- ### CLI
152
-
153
- Once the engine module is installed as a dependency within another module, the `ota` command with the following subcommands is available.
154
-
155
- In these commands:
156
-
157
- - **`<service_id>`** is the case sensitive name of the service declaration file without the extension. For example, for `Twitter.json`, the service ID is `Twitter`.
158
- - **`<terms_type>`** is the property name used under the `documents` property in the declaration to declare a terms. For example, in the getting started declaration, the terms type declared is `Privacy Policy`.
159
-
160
- #### `ota track`
161
-
162
- ```sh
163
- npx ota track
164
- ```
165
-
166
- [Track](#tracking-documents) the current terms of services according to provided declarations.
167
-
168
- The declarations, snapshots and versions paths are defined in the [configuration](#configuring).
169
-
170
- > Note that the snapshots and versions will be recorded at the moment the command is executed, on top of the existing local history. If a shared history already exists and the goal is to add on top of it, that history has to be downloaded before executing that command.
171
-
172
- ##### Recap of available options
173
-
174
- ```sh
175
- npx ota track --help
176
- ```
177
-
178
- ##### Track terms of specific services
179
-
180
- ```sh
181
- npx ota track --services "<service_id>" ["<service_id>"...]
182
- ```
183
-
184
- ##### Track specific terms of specific services
185
-
186
- ```sh
187
- npx ota track --services "<service_id>" ["<service_id>"...] --terms-types "<terms_type>" ["<terms_type>"...]
188
- ```
189
-
190
- ##### Track documents four times a day
191
-
192
- ```sh
193
- npx ota track --schedule
194
- ```
195
-
196
- #### `ota validate`
197
-
198
- ```sh
199
- npx ota validate [--services <service_id>...] [--terms-types <terms_type>...]
200
- ```
201
-
202
- Check that all declarations allow recording a snapshot and a version properly.
203
-
204
- If one or several `<service_id>` are provided, check only those services.
205
-
206
- ##### Validate schema only
207
-
208
- ```sh
209
- npx ota validate --schema-only [--services <service_id>...] [--terms-types <terms_type>...]
210
- ```
211
-
212
- Check that all declarations are readable by the engine.
213
-
214
- Allows for a much faster check of declarations, but does not check that the documents are actually accessible.
215
-
216
- If one or several `<service_id>` are provided, check only those services.
217
-
218
- ##### Validate modified terms only
219
-
220
- ```sh
221
- npx ota validate --modified
222
- ```
223
-
224
- Run [`ota validate`](#ota-validate) only on files that have been modified in Git.
225
-
226
- #### `ota lint`
227
-
228
- ```sh
229
- npx ota lint [--services <service_id>...] [--fix] [--modified]
230
- ```
231
-
232
- Test the the format of declarations' normalisation.
233
-
234
- Use `--fix` to automatically correct formatting mistakes and ensure that all declarations are standardised.
235
-
236
- If one or several `<service_id>` are provided, check only those services.
237
-
238
- #### `ota dataset`
239
-
240
- Export the versions dataset into a ZIP file and publish it to GitHub releases.
241
-
242
- The dataset title and the URL of the versions repository are defined in the [configuration](#configuring).
243
-
244
- To export the dataset into a local ZIP file:
245
-
246
- ```sh
247
- npx ota dataset [--file <filename>]
248
- ```
249
-
250
- To export the dataset into a ZIP file and publish it on GitHub releases:
251
-
252
- ```sh
253
- GITHUB_TOKEN=ghp_XXXXXXXXX npx ota dataset --publish
254
- ```
255
-
256
- The `GITHUB_TOKEN` can also be defined in a [`.env` file](#environment-variables).
257
-
258
- To export, publish the dataset and remove the local copy that was created after it has been uploaded:
259
-
260
- ```sh
261
- GITHUB_TOKEN=ghp_XXXXXXXXX npx ota dataset --publish --remove-local-copy
262
- ```
263
-
264
- ##### Publish dataset on monday every week
265
-
266
- To schedule export, publishing and local copy removal:
267
-
268
- ```sh
269
- GITHUB_TOKEN=ghp_XXXXXXXXX npx ota dataset --schedule --publish --remove-local-copy
270
- ```
271
-
272
- ### API
273
-
274
- Once added as a dependency, the engine exposes a JavaScript API that can be called in your own code. The following modules are available.
275
-
276
- #### `fetch`
277
-
278
- The `fetch` module gets the MIME type and content of a document from its URL
279
-
280
- ```js
281
- import fetch from '@opentermsarchive/engine/fetch';
282
- ```
283
-
284
- Documentation on how to use `fetch` is provided [as JSDoc](./src/archivist/fetcher/index.js).
285
-
286
- ##### Headless browser management
287
-
288
- If you pass the `executeClientScripts` option to `fetch`, a headless browser will be used to download and execute the page before serialising its DOM. For performance reasons, the starting and stopping of the browser is your responsibility to avoid instantiating a browser on each fetch. Here is an example on how to use this feature:
289
-
290
- ```js
291
- import fetch, { launchHeadlessBrowser, stopHeadlessBrowser } from '@opentermsarchive/engine/fetch';
292
-
293
- await launchHeadlessBrowser();
294
- await fetch({ executeClientScripts: true, ... });
295
- await fetch({ executeClientScripts: true, ... });
296
- await fetch({ executeClientScripts: true, ... });
297
- await stopHeadlessBrowser();
298
- ```
299
-
300
- The `fetch` module options are defined as a [`node-config` submodule](https://github.com/node-config/node-config/wiki/Sub-Module-Configuration). The default `fetcher` configuration can be overridden by adding a `fetcher` object to the [local configuration file](#configuration-file).
301
-
302
- #### `filter`
303
-
304
- The `filter` module transforms HTML or PDF content into a Markdown string according to a [declaration](#declarations).
305
-
306
- ```js
307
- import filter from '@opentermsarchive/engine/filter';
308
- ```
309
-
310
- The `filter` function documentation is available [as JSDoc](./src/archivist/filter/index.js).
311
-
312
- #### `PageDeclaration`
313
-
314
- The `PageDeclaration` class encapsulates information about a page tracked by Open Terms Archive.
315
-
316
- ```js
317
- import pageDeclaration from '@opentermsarchive/engine/page-declaration';
318
- ```
319
-
320
- The `PageDeclaration` format is defined [in source code](./src/archivist/services/pageDeclaration.js).
321
-
322
- ## Configuring
323
-
324
- ### Configuration file
325
-
326
- The default configuration can be found in `config/default.json`. The full reference is given below. You are unlikely to want to edit all of these elements.
327
-
328
- ```js
329
- {
330
- "services": {
331
- "declarationsPath": "Directory containing services declarations and associated filters"
332
- },
333
- "recorder": {
334
- "versions": {
335
- "storage": {
336
- "<storage-repository>": "Storage repository configuration object; see below"
337
- }
338
- },
339
- "snapshots": {
340
- "storage": {
341
- "<storage-repository>": "Storage repository configuration object; see below"
342
- }
343
- }
344
- },
345
- "fetcher": {
346
- "waitForElementsTimeout": "Maximum time (in milliseconds) to wait for elements to be present in the page when fetching document in a headless browser"
347
- "navigationTimeout": "Maximum time (in milliseconds) to wait for page to load",
348
- "language": "Language (in ISO 639-1 format) to pass in request headers"
349
- },
350
- "notifier": { // Notify specified mailing lists when new versions are recorded
351
- "sendInBlue": { // SendInBlue API Key is defined in environment variables, see the “Environment variables” section below
352
- "updatesListId": "SendInBlue contacts list ID of persons to notify on document updates",
353
- "updateTemplateId": "SendInBlue email template ID used for updates notifications"
354
- }
355
- },
356
- "logger": { // Logging mechanism to be notified upon error
357
- "smtp": {
358
- "host": "SMTP server hostname",
359
- "username": "User for server authentication" // Password for server authentication is defined in environment variables, see the “Environment variables” section below
360
- },
361
- "sendMailOnError": { // Can be set to `false` if sending email on error is not needed
362
- "to": "The address to send the email to in case of an error",
363
- "from": "The address from which to send the email",
364
- "sendWarnings": "Boolean. Set to true to also send email in case of warning",
365
- }
366
- },
367
- "tracker": { // Tracking mechanism to create GitHub issues when document content is inaccessible
368
- "githubIssues": {
369
- "repository": "GitHub repository where to create isssues",
370
- "label": {
371
- "name": "Label to attach to bot-created issues. This specific label will be created automatically in the target repository",
372
- "color": "The hexadecimal color code for the label, without the leading #",
373
- "description": "A short description of the label"
374
- }
375
- }
376
- },
377
- "dataset": { // Release mechanism to create dataset periodically
378
- "title": "Title of the dataset; recommended to be the name of the instance that generated it",
379
- "versionsRepositoryURL": "GitHub repository where the dataset will be published as a release; recommended to be the versions repository for discoverability and tagging purposes"
380
- }
381
- }
382
- ```
383
-
384
- The default configuration is merged with (and overridden by) environment-specific configuration that can be specified at startup with the `NODE_ENV` environment variable. See [node-config](https://github.com/node-config/node-config) for more information about configuration files.
385
-
386
- In order to have a local configuration that override all exisiting config, it is recommended to create a `config/development.json` file with overridden values.
387
-
388
- #### Storage repositories
389
-
390
- Two storage repositories are currently supported: Git and MongoDB. Each one can be used independently for versions and snapshots.
391
-
392
- ##### Git
393
-
394
- ```json
395
- {
396
-
397
- "storage": {
398
- "git": {
399
- "path": "Versions database directory path, relative to the root of this project",
400
- "publish": "Boolean. Set to true to push changes to the origin of the cloned repository at the end of every run. Recommended for production only.",
401
- "snapshotIdentiferTemplate": "Text. Template used to explicit where to find the referenced snapshot id. Must contain a %SNAPSHOT_ID that will be replaced by the snapshot ID. Only useful for versions",
402
- "author": {
403
- "name": "Name to which changes in tracked documents will be credited",
404
- "email": "Email to which changes in tracked documents will be credited"
405
- }
406
- }
407
- }
408
-
409
- }
410
- ```
411
- ##### MongoDB
412
-
413
- ```json
414
- {
415
-
416
- "storage": {
417
- "mongo": {
418
- "connectionURI": "URI for defining connection to the MongoDB instance. See https://docs.mongodb.com/manual/reference/connection-string/",
419
- "database": "Database name",
420
- "collection": "Collection name"
421
- }
422
- }
423
-
424
- }
425
- ```
426
-
427
- ### Environment variables
428
-
429
- Environment variables can be passed in the command-line or provided in a `.env` file at the root of the repository. See `.env.example` for an example of such a file.
430
-
431
- - `SMTP_PASSWORD`: a password for email server authentication, in order to send email notifications.
432
- - `SENDINBLUE_API_KEY`: a SendInBlue API key, in order to send email notifications with that service.
433
- - `GITHUB_TOKEN`: a token with repository privileges to access the [GitHub API](https://github.com/settings/tokens).
434
-
435
- If an outgoing HTTP/HTTPS proxy to access the Internet is required, it is possible to provide it through the `HTTP_PROXY` and `HTTPS_PROXY` environment variable.
436
-
437
- ## Deploying
438
-
439
- Deployment recipes are available in a [dedicated repository](https://github.com/OpenTermsArchive/deployment). Look at the [README](https://github.com/OpenTermsArchive/deployment#readme) to know how to deploy the engine.
440
- ## Contributing
441
-
442
- ### Getting a copy
443
-
444
- In order to edit the code of the engine itself, an editable and executable copy is necessary.
445
-
446
- First of all, follow the [requirements](#requirements) above. Then, clone the repository:
447
-
448
- ```sh
449
- git clone https://github.com/ambanum/OpenTermsArchive.git
450
- cd OpenTermsArchive
451
- ```
452
-
453
- Install dependencies:
454
-
455
- ```sh
456
- npm install
457
- ```
458
-
459
- ### Testing
460
-
461
- If changes are made to the engine, check that all parts covered by tests still work properly:
462
-
463
- ```sh
464
- npm test
465
- ```
466
-
467
- If existing features are changed or new ones are added, relevant tests must be added too.
468
-
469
- ### Suggesting changes
470
-
471
- To contribute to the core engine of Open Terms Archive, see the [CONTRIBUTING](CONTRIBUTING.md) file of this repository. You will need knowledge of JavaScript and Node.js.
472
-
473
- ### Sponsorship and partnerships
474
-
475
- Beyond individual contributions, we need funds and committed partners to pay for a core team to maintain and grow Open Terms Archive. If you know of opportunities, please let us know over email at `contact@[project name without spaces].org`!
7
+ For documentation, visit [docs.opentermsarchive.org](https://docs.opentermsarchive.org/)
476
8
 
477
9
  - - -
478
10
 
package/bin/ota-track.js CHANGED
@@ -14,8 +14,8 @@ program
14
14
  .name('ota track')
15
15
  .description('Retrieve declared documents, record snapshots, extract versions and publish the resulting records')
16
16
  .option('-s, --services [serviceId...]', 'service IDs of services to track')
17
- .option('-t, --terms-types [termsType...]', 'terms types to track')
18
- .option('-r, --refilter-only', 'refilter existing snapshots with latest declarations and engine, without recording new snapshots')
19
- .option('--schedule', 'schedule automatic document tracking');
17
+ .option('-t, --types [termsType...]', 'terms types to track')
18
+ .option('-e, --extract-only', 'extract versions from existing snapshots with latest declarations and engine, without recording new snapshots')
19
+ .option('--schedule', 'track automatically at a regular interval');
20
20
 
21
21
  track(program.parse(process.argv).opts());
@@ -20,9 +20,9 @@ process.on('unhandledRejection', reason => {
20
20
 
21
21
  program
22
22
  .name('ota validate')
23
- .description('Run a series of tests to check the validity of document declarations')
23
+ .description('Run a series of tests to check the validity of terms declarations')
24
24
  .option('-s, --services [serviceId...]', 'service IDs of services to validate')
25
- .option('-t, --terms-types [termsType...]', 'terms types to validate')
25
+ .option('-t, --types [termsType...]', 'terms types to validate')
26
26
  .option('-m, --modified', 'target only services modified in the current git branch')
27
27
  .option('-o, --schema-only', 'much faster check of declarations, but does not check that the documents are actually accessible');
28
28
 
package/bin/ota.js CHANGED
@@ -11,7 +11,7 @@ program
11
11
  .description(description)
12
12
  .version(version)
13
13
  .command('track', 'Track the current terms of services according to provided declarations')
14
- .command('validate', 'Run a series of tests to check the validity of document declarations')
14
+ .command('validate', 'Run a series of tests to check the validity of terms declarations')
15
15
  .command('lint', 'Check format and stylistic errors in declarations and auto fix them')
16
16
  .command('dataset', 'Export the versions dataset into a ZIP file and optionally publish it to GitHub releases')
17
17
  .parse(process.argv);
@@ -60,7 +60,7 @@
60
60
  "label": {
61
61
  "name": "bot-report",
62
62
  "color": "FEF2C0",
63
- "description": "Automatically created by Open Terms Archive when a document cannot be fetched"
63
+ "description": "Automatically created when terms cannot be tracked"
64
64
  }
65
65
  }
66
66
  },
package/config/test.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "git": {
9
9
  "path": "./test/data/versions",
10
10
  "publish": false,
11
- "snapshotIdentiferTemplate": "https://github.com/ambanum/OpenTermsArchive-snapshots/commit/%SNAPSHOT_ID",
11
+ "snapshotIdentiferTemplate": "https://github.com/OpenTermsArchive/sandbox-snapshots/commit/%SNAPSHOT_ID",
12
12
  "author": {
13
13
  "name": "Open Terms Archive Testing Bot",
14
14
  "email": "bot@opentermsarchive.org"
@@ -44,6 +44,6 @@
44
44
  },
45
45
  "dataset": {
46
46
  "title": "sandbox",
47
- "versionsRepositoryURL": "https://github.com/OpenTermsArchive/sandbox"
47
+ "versionsRepositoryURL": "https://github.com/OpenTermsArchive/sandbox-versions"
48
48
  }
49
49
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Tracks and makes visible changes to the terms of online services",
5
- "homepage": "https://github.com/ambanum/OpenTermsArchive#readme",
5
+ "homepage": "https://github.com/OpenTermsArchive/engine#readme",
6
6
  "bugs": {
7
- "url": "https://github.com/ambanum/OpenTermsArchive/issues"
7
+ "url": "https://github.com/OpenTermsArchive/engine/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/ambanum/OpenTermsArchive.git"
11
+ "url": "git+https://github.com/OpenTermsArchive/engine.git"
12
12
  },
13
13
  "license": "EUPL-1.2",
14
14
  "author": "ambanum",
@@ -16,8 +16,8 @@
16
16
  "exports": {
17
17
  ".": "./src/exports.js",
18
18
  "./fetch": "./src/archivist/fetcher/exports.js",
19
- "./filter": "./src/archivist/filter/exports.js",
20
- "./page-declaration": "./src/archivist/services/pageDeclaration.js"
19
+ "./extract": "./src/archivist/extract/exports.js",
20
+ "./sourceDocument": "./src/archivist/services/sourceDocument.js"
21
21
  },
22
22
  "bin": {
23
23
  "ota": "./bin/ota.js"
@@ -38,7 +38,6 @@
38
38
  "declarations:validate:schema": "npm run declarations:validate -- --schema-only",
39
39
  "lint": "eslint src test scripts bin",
40
40
  "lint:fix": "npm run lint -- --fix",
41
- "refilter": "npm start -- --refilter-only",
42
41
  "start": "node --max-http-header-size=32768 bin/ota.js track",
43
42
  "start:scheduler": "npm start -- --schedule",
44
43
  "test": "cross-env NODE_ENV=test mocha --recursive \"./src/**/*.test.js\" \"./scripts/**/*.test.js\" --exit",
@@ -31,7 +31,7 @@ export default async function generate({ archivePath, releaseDate }) {
31
31
 
32
32
  for await (const version of versionsRepository.iterate()) {
33
33
  const { content, fetchDate } = version;
34
- const { serviceId, documentType } = renamer.applyRules(version.serviceId, version.documentType);
34
+ const { serviceId, termsType } = renamer.applyRules(version.serviceId, version.termsType);
35
35
 
36
36
  if (firstVersionDate > fetchDate) {
37
37
  firstVersionDate = fetchDate;
@@ -43,7 +43,7 @@ export default async function generate({ archivePath, releaseDate }) {
43
43
 
44
44
  services.add(serviceId);
45
45
 
46
- const versionPath = generateVersionPath({ serviceId, documentType, fetchDate });
46
+ const versionPath = generateVersionPath({ serviceId, termsType, fetchDate });
47
47
 
48
48
  logger.info({ message: versionPath, counter: index, hash: version.id });
49
49
 
@@ -97,10 +97,10 @@ async function initializeArchive(targetPath) {
97
97
  return { basename, stream, done };
98
98
  }
99
99
 
100
- function generateVersionPath({ serviceId, documentType, fetchDate }) {
100
+ function generateVersionPath({ serviceId, termsType, fetchDate }) {
101
101
  const fsCompliantDate = fetchDate.toISOString()
102
102
  .replace(/\.\d{3}/, '') // remove milliseconds
103
103
  .replace(/:|\./g, '-'); // replace `:` and `.` by `-` to be compliant with the file system
104
104
 
105
- return `${serviceId}/${documentType}/${fsCompliantDate}.md`;
105
+ return `${serviceId}/${termsType}/${fsCompliantDate}.md`;
106
106
  }