@opentermsarchive/engine 0.15.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 (168) hide show
  1. package/.env.example +3 -0
  2. package/.eslintrc.yaml +116 -0
  3. package/.github/workflows/deploy.yml +50 -0
  4. package/.github/workflows/release.yml +64 -0
  5. package/.github/workflows/test.yml +77 -0
  6. package/CHANGELOG.md +14 -0
  7. package/CODE_OF_CONDUCT.md +128 -0
  8. package/CONTRIBUTING.md +143 -0
  9. package/LICENSE +153 -0
  10. package/MIGRATING.md +42 -0
  11. package/README.fr.md +110 -0
  12. package/README.md +438 -0
  13. package/Vagrantfile +38 -0
  14. package/ansible.cfg +13 -0
  15. package/bin/.env.js +1 -0
  16. package/bin/lint-declarations.js +31 -0
  17. package/bin/track.js +26 -0
  18. package/bin/validate-declarations.js +68 -0
  19. package/config/ci.json +5 -0
  20. package/config/contrib.json +35 -0
  21. package/config/dating.json +37 -0
  22. package/config/default.json +71 -0
  23. package/config/france.json +40 -0
  24. package/config/p2b-compliance.json +40 -0
  25. package/config/pga.json +40 -0
  26. package/config/production.json +27 -0
  27. package/config/test.json +49 -0
  28. package/config/vagrant.json +24 -0
  29. package/decision-records/0001-service-name-and-id.md +73 -0
  30. package/decision-records/0002-service-history.md +212 -0
  31. package/decision-records/0003-snapshots-database.md +123 -0
  32. package/ops/README.md +280 -0
  33. package/ops/app.yml +5 -0
  34. package/ops/infra.yml +6 -0
  35. package/ops/inventories/dev.yml +7 -0
  36. package/ops/inventories/production.yml +27 -0
  37. package/ops/roles/infra/defaults/main.yml +2 -0
  38. package/ops/roles/infra/files/.gitconfig +3 -0
  39. package/ops/roles/infra/files/mongod.conf +18 -0
  40. package/ops/roles/infra/files/ota-bot-key.private_key +26 -0
  41. package/ops/roles/infra/tasks/main.yml +78 -0
  42. package/ops/roles/infra/tasks/mongo.yml +40 -0
  43. package/ops/roles/infra/templates/ssh_config.j2 +5 -0
  44. package/ops/roles/ota/defaults/main.yml +14 -0
  45. package/ops/roles/ota/files/.env +21 -0
  46. package/ops/roles/ota/tasks/database.yml +65 -0
  47. package/ops/roles/ota/tasks/main.yml +110 -0
  48. package/ops/site.yml +6 -0
  49. package/package.json +101 -0
  50. package/pm2.config.cjs +20 -0
  51. package/scripts/dataset/README.md +37 -0
  52. package/scripts/dataset/assets/LICENSE +540 -0
  53. package/scripts/dataset/assets/README.template.js +65 -0
  54. package/scripts/dataset/export/index.js +106 -0
  55. package/scripts/dataset/export/index.test.js +155 -0
  56. package/scripts/dataset/export/test/fixtures/dataset/LICENSE +540 -0
  57. package/scripts/dataset/export/test/fixtures/dataset/README.md +40 -0
  58. package/scripts/dataset/export/test/fixtures/dataset/ServiceA/Terms of Service/2021-01-01T11-27-00Z.md +1 -0
  59. package/scripts/dataset/export/test/fixtures/dataset/ServiceA/Terms of Service/2021-01-11T11-32-47Z.md +1 -0
  60. package/scripts/dataset/export/test/fixtures/dataset/ServiceB/Privacy Policy/2022-01-01T12-12-24Z.md +1 -0
  61. package/scripts/dataset/export/test/fixtures/dataset/ServiceB/Terms of Service/2022-01-06T11-32-47Z.md +1 -0
  62. package/scripts/dataset/index.js +40 -0
  63. package/scripts/dataset/logger/index.js +17 -0
  64. package/scripts/dataset/main.js +25 -0
  65. package/scripts/dataset/publish/index.js +39 -0
  66. package/scripts/declarations/lint/index.js +36 -0
  67. package/scripts/declarations/utils/index.js +81 -0
  68. package/scripts/declarations/validate/definitions.js +63 -0
  69. package/scripts/declarations/validate/index.mocha.js +262 -0
  70. package/scripts/declarations/validate/service.history.schema.js +86 -0
  71. package/scripts/declarations/validate/service.schema.js +91 -0
  72. package/scripts/history/logger/index.js +39 -0
  73. package/scripts/history/migrate-services.js +212 -0
  74. package/scripts/history/update-to-full-hash.js +61 -0
  75. package/scripts/history/utils/index.js +23 -0
  76. package/scripts/import/README.md +59 -0
  77. package/scripts/import/config/import.json +12 -0
  78. package/scripts/import/index.js +224 -0
  79. package/scripts/import/loadCommits.js +66 -0
  80. package/scripts/import/logger/index.js +43 -0
  81. package/scripts/rewrite/README.md +131 -0
  82. package/scripts/rewrite/config/rewrite-snapshots.json +32 -0
  83. package/scripts/rewrite/config/rewrite-versions.json +32 -0
  84. package/scripts/rewrite/initializer/files/license +428 -0
  85. package/scripts/rewrite/initializer/files/readme.md +8 -0
  86. package/scripts/rewrite/initializer/index.js +44 -0
  87. package/scripts/rewrite/rewrite-snapshots.js +108 -0
  88. package/scripts/rewrite/rewrite-versions.js +160 -0
  89. package/scripts/rewrite/utils.js +33 -0
  90. package/scripts/utils/renamer/README.md +49 -0
  91. package/scripts/utils/renamer/index.js +45 -0
  92. package/scripts/utils/renamer/rules/documentTypes.json +25 -0
  93. package/scripts/utils/renamer/rules/documentTypesByService.json +170 -0
  94. package/scripts/utils/renamer/rules/serviceNames.json +92 -0
  95. package/src/archivist/errors.js +9 -0
  96. package/src/archivist/fetcher/errors.js +6 -0
  97. package/src/archivist/fetcher/exports.js +18 -0
  98. package/src/archivist/fetcher/fullDomFetcher.js +84 -0
  99. package/src/archivist/fetcher/htmlOnlyFetcher.js +62 -0
  100. package/src/archivist/fetcher/index.js +35 -0
  101. package/src/archivist/fetcher/index.test.js +239 -0
  102. package/src/archivist/filter/exports.js +3 -0
  103. package/src/archivist/filter/index.js +178 -0
  104. package/src/archivist/filter/index.test.js +561 -0
  105. package/src/archivist/index.js +276 -0
  106. package/src/archivist/index.test.js +600 -0
  107. package/src/archivist/recorder/index.js +77 -0
  108. package/src/archivist/recorder/index.test.js +463 -0
  109. package/src/archivist/recorder/record.js +35 -0
  110. package/src/archivist/recorder/record.test.js +91 -0
  111. package/src/archivist/recorder/repositories/factory.js +23 -0
  112. package/src/archivist/recorder/repositories/git/dataMapper.js +83 -0
  113. package/src/archivist/recorder/repositories/git/git.js +122 -0
  114. package/src/archivist/recorder/repositories/git/git.test.js +86 -0
  115. package/src/archivist/recorder/repositories/git/index.js +182 -0
  116. package/src/archivist/recorder/repositories/git/index.test.js +714 -0
  117. package/src/archivist/recorder/repositories/interface.js +108 -0
  118. package/src/archivist/recorder/repositories/mongo/dataMapper.js +32 -0
  119. package/src/archivist/recorder/repositories/mongo/index.js +121 -0
  120. package/src/archivist/recorder/repositories/mongo/index.test.js +721 -0
  121. package/src/archivist/services/documentDeclaration.js +26 -0
  122. package/src/archivist/services/documentDeclaration.test.js +85 -0
  123. package/src/archivist/services/documentTypes.json +386 -0
  124. package/src/archivist/services/index.js +255 -0
  125. package/src/archivist/services/index.test.js +327 -0
  126. package/src/archivist/services/pageDeclaration.js +51 -0
  127. package/src/archivist/services/pageDeclaration.test.js +224 -0
  128. package/src/archivist/services/service.js +60 -0
  129. package/src/archivist/services/service.test.js +164 -0
  130. package/src/exports.js +3 -0
  131. package/src/index.js +59 -0
  132. package/src/logger/README.md +1 -0
  133. package/src/logger/index.js +131 -0
  134. package/src/main.js +18 -0
  135. package/src/notifier/README.md +1 -0
  136. package/src/notifier/index.js +150 -0
  137. package/src/tracker/README.md +1 -0
  138. package/src/tracker/index.js +215 -0
  139. package/test/fixtures/service_A.js +22 -0
  140. package/test/fixtures/service_A_terms.md +10 -0
  141. package/test/fixtures/service_A_terms_snapshot.html +14 -0
  142. package/test/fixtures/service_B.js +22 -0
  143. package/test/fixtures/service_with_declaration_history.js +65 -0
  144. package/test/fixtures/service_with_filters_history.js +155 -0
  145. package/test/fixtures/service_with_history.js +188 -0
  146. package/test/fixtures/service_with_multipage_document.js +100 -0
  147. package/test/fixtures/service_without_history.js +31 -0
  148. package/test/fixtures/services.js +19 -0
  149. package/test/fixtures/terms.pdf +0 -0
  150. package/test/fixtures/termsFromPDF.md +25 -0
  151. package/test/fixtures/termsModified.pdf +0 -0
  152. package/test/services/service_A.json +9 -0
  153. package/test/services/service_B.json +9 -0
  154. package/test/services/service_with_declaration_history.filters.js +7 -0
  155. package/test/services/service_with_declaration_history.history.json +17 -0
  156. package/test/services/service_with_declaration_history.json +13 -0
  157. package/test/services/service_with_filters_history.filters.history.js +29 -0
  158. package/test/services/service_with_filters_history.filters.js +7 -0
  159. package/test/services/service_with_filters_history.json +13 -0
  160. package/test/services/service_with_history.filters.history.js +29 -0
  161. package/test/services/service_with_history.filters.js +7 -0
  162. package/test/services/service_with_history.history.json +26 -0
  163. package/test/services/service_with_history.json +17 -0
  164. package/test/services/service_with_multipage_document.filters.js +7 -0
  165. package/test/services/service_with_multipage_document.history.json +37 -0
  166. package/test/services/service_with_multipage_document.json +28 -0
  167. package/test/services/service_without_history.filters.js +7 -0
  168. package/test/services/service_without_history.json +13 -0
@@ -0,0 +1,428 @@
1
+ # ODC Attribution License (ODC-By)
2
+
3
+ ### Preamble
4
+
5
+ The Open Data Commons Attribution License is a license agreement
6
+ intended to allow users to freely share, modify, and use this Database
7
+ subject only to the attribution requirements set out in Section 4.
8
+
9
+ Databases can contain a wide variety of types of content (images,
10
+ audiovisual material, and sounds all in the same database, for example),
11
+ and so this license only governs the rights over the Database, and not
12
+ the contents of the Database individually. Licensors may therefore wish
13
+ to use this license together with another license for the contents.
14
+
15
+ Sometimes the contents of a database, or the database itself, can be
16
+ covered by other rights not addressed here (such as private contracts,
17
+ trademark over the name, or privacy rights / data protection rights
18
+ over information in the contents), and so you are advised that you may
19
+ have to consult other documents or clear other rights before doing
20
+ activities not covered by this License.
21
+
22
+ ------
23
+
24
+ The Licensor (as defined below)
25
+
26
+ and
27
+
28
+ You (as defined below)
29
+
30
+ agree as follows:
31
+
32
+ ### 1.0 Definitions of Capitalised Words
33
+
34
+ "Collective Database" – Means this Database in unmodified form as part
35
+ of a collection of independent databases in themselves that together are
36
+ assembled into a collective whole. A work that constitutes a Collective
37
+ Database will not be considered a Derivative Database.
38
+
39
+ "Convey" – As a verb, means Using the Database, a Derivative Database,
40
+ or the Database as part of a Collective Database in any way that enables
41
+ a Person to make or receive copies of the Database or a Derivative
42
+ Database. Conveying does not include interaction with a user through a
43
+ computer network, or creating and Using a Produced Work, where no
44
+ transfer of a copy of the Database or a Derivative Database occurs.
45
+
46
+ "Contents" – The contents of this Database, which includes the
47
+ information, independent works, or other material collected into the
48
+ Database. For example, the contents of the Database could be factual
49
+ data or works such as images, audiovisual material, text, or sounds.
50
+
51
+ "Database" – A collection of material (the Contents) arranged in a
52
+ systematic or methodical way and individually accessible by electronic
53
+ or other means offered under the terms of this License.
54
+
55
+ "Database Directive" – Means Directive 96/9/EC of the European
56
+ Parliament and of the Council of 11 March 1996 on the legal protection
57
+ of databases, as amended or succeeded.
58
+
59
+ "Database Right" – Means rights resulting from the Chapter III ("sui
60
+ generis") rights in the Database Directive (as amended and as transposed
61
+ by member states), which includes the Extraction and Re-utilisation of
62
+ the whole or a Substantial part of the Contents, as well as any similar
63
+ rights available in the relevant jurisdiction under Section 10.4.
64
+
65
+ "Derivative Database" – Means a database based upon the Database, and
66
+ includes any translation, adaptation, arrangement, modification, or any
67
+ other alteration of the Database or of a Substantial part of the
68
+ Contents. This includes, but is not limited to, Extracting or
69
+ Re-utilising the whole or a Substantial part of the Contents in a new
70
+ Database.
71
+
72
+ "Extraction" – Means the permanent or temporary transfer of all or a
73
+ Substantial part of the Contents to another medium by any means or in
74
+ any form.
75
+
76
+ "License" – Means this license agreement and is both a license of rights
77
+ such as copyright and Database Rights and an agreement in contract.
78
+
79
+ "Licensor" – Means the Person that offers the Database under the terms
80
+ of this License.
81
+
82
+ "Person" – Means a natural or legal person or a body of persons
83
+ corporate or incorporate.
84
+
85
+ "Produced Work" – a work (such as an image, audiovisual material, text,
86
+ or sounds) resulting from using the whole or a Substantial part of the
87
+ Contents (via a search or other query) from this Database, a Derivative
88
+ Database, or this Database as part of a Collective Database.
89
+
90
+ "Publicly" – means to Persons other than You or under Your control by
91
+ either more than 50% ownership or by the power to direct their
92
+ activities (such as contracting with an independent consultant).
93
+
94
+ "Re-utilisation" – means any form of making available to the public all
95
+ or a Substantial part of the Contents by the distribution of copies, by
96
+ renting, by online or other forms of transmission.
97
+
98
+ "Substantial" – Means substantial in terms of quantity or quality or a
99
+ combination of both. The repeated and systematic Extraction or
100
+ Re-utilisation of insubstantial parts of the Contents may amount to the
101
+ Extraction or Re-utilisation of a Substantial part of the Contents.
102
+
103
+ "Use" – As a verb, means doing any act that is restricted by copyright
104
+ or Database Rights whether in the original medium or any other; and
105
+ includes without limitation distributing, copying, publicly performing,
106
+ publicly displaying, and preparing derivative works of the Database, as
107
+ well as modifying the Database as may be technically necessary to use it
108
+ in a different mode or format.
109
+
110
+ "You" – Means a Person exercising rights under this License who has not
111
+ previously violated the terms of this License with respect to the
112
+ Database, or who has received express permission from the Licensor to
113
+ exercise rights under this License despite a previous violation.
114
+
115
+ Words in the singular include the plural and vice versa.
116
+
117
+ ### 2.0 What this License covers
118
+
119
+ 2.1. Legal effect of this document. This License is:
120
+
121
+ a. A license of applicable copyright and neighbouring rights;
122
+
123
+ b. A license of the Database Right; and
124
+
125
+ c. An agreement in contract between You and the Licensor.
126
+
127
+ 2.2 Legal rights covered. This License covers the legal rights in the
128
+ Database, including:
129
+
130
+ a. Copyright. Any copyright or neighbouring rights in the Database.
131
+ The copyright licensed includes any individual elements of the
132
+ Database, but does not cover the copyright over the Contents
133
+ independent of this Database. See Section 2.4 for details. Copyright
134
+ law varies between jurisdictions, but is likely to cover: the Database
135
+ model or schema, which is the structure, arrangement, and organisation
136
+ of the Database, and can also include the Database tables and table
137
+ indexes; the data entry and output sheets; and the Field names of
138
+ Contents stored in the Database;
139
+
140
+ b. Database Rights. Database Rights only extend to the Extraction and
141
+ Re-utilisation of the whole or a Substantial part of the Contents.
142
+ Database Rights can apply even when there is no copyright over the
143
+ Database. Database Rights can also apply when the Contents are removed
144
+ from the Database and are selected and arranged in a way that would
145
+ not infringe any applicable copyright; and
146
+
147
+ c. Contract. This is an agreement between You and the Licensor for
148
+ access to the Database. In return you agree to certain conditions of
149
+ use on this access as outlined in this License.
150
+
151
+ 2.3 Rights not covered.
152
+
153
+ a. This License does not apply to computer programs used in the making
154
+ or operation of the Database;
155
+
156
+ b. This License does not cover any patents over the Contents or the
157
+ Database; and
158
+
159
+ c. This License does not cover any trademarks associated with the
160
+ Database.
161
+
162
+ 2.4 Relationship to Contents in the Database. The individual items of
163
+ the Contents contained in this Database may be covered by other rights,
164
+ including copyright, patent, data protection, privacy, or personality
165
+ rights, and this License does not cover any rights (other than Database
166
+ Rights or in contract) in individual Contents contained in the Database.
167
+ For example, if used on a Database of images (the Contents), this
168
+ License would not apply to copyright over individual images, which could
169
+ have their own separate licenses, or one single license covering all of
170
+ the rights over the images.
171
+
172
+ ### 3.0 Rights granted
173
+
174
+ 3.1 Subject to the terms and conditions of this License, the Licensor
175
+ grants to You a worldwide, royalty-free, non-exclusive, terminable (but
176
+ only under Section 9) license to Use the Database for the duration of
177
+ any applicable copyright and Database Rights. These rights explicitly
178
+ include commercial use, and do not exclude any field of endeavour. To
179
+ the extent possible in the relevant jurisdiction, these rights may be
180
+ exercised in all media and formats whether now known or created in the
181
+ future.
182
+
183
+ The rights granted cover, for example:
184
+
185
+ a. Extraction and Re-utilisation of the whole or a Substantial part of
186
+ the Contents;
187
+
188
+ b. Creation of Derivative Databases;
189
+
190
+ c. Creation of Collective Databases;
191
+
192
+ d. Creation of temporary or permanent reproductions by any means and
193
+ in any form, in whole or in part, including of any Derivative
194
+ Databases or as a part of Collective Databases; and
195
+
196
+ e. Distribution, communication, display, lending, making available, or
197
+ performance to the public by any means and in any form, in whole or in
198
+ part, including of any Derivative Database or as a part of Collective
199
+ Databases.
200
+
201
+ 3.2 Compulsory license schemes. For the avoidance of doubt:
202
+
203
+ a. Non-waivable compulsory license schemes. In those jurisdictions in
204
+ which the right to collect royalties through any statutory or
205
+ compulsory licensing scheme cannot be waived, the Licensor reserves
206
+ the exclusive right to collect such royalties for any exercise by You
207
+ of the rights granted under this License;
208
+
209
+ b. Waivable compulsory license schemes. In those jurisdictions in
210
+ which the right to collect royalties through any statutory or
211
+ compulsory licensing scheme can be waived, the Licensor waives the
212
+ exclusive right to collect such royalties for any exercise by You of
213
+ the rights granted under this License; and,
214
+
215
+ c. Voluntary license schemes. The Licensor waives the right to collect
216
+ royalties, whether individually or, in the event that the Licensor is
217
+ a member of a collecting society that administers voluntary licensing
218
+ schemes, via that society, from any exercise by You of the rights
219
+ granted under this License.
220
+
221
+ 3.3 The right to release the Database under different terms, or to stop
222
+ distributing or making available the Database, is reserved. Note that
223
+ this Database may be multiple-licensed, and so You may have the choice
224
+ of using alternative licenses for this Database. Subject to Section
225
+ 10.4, all other rights not expressly granted by Licensor are reserved.
226
+
227
+ ### 4.0 Conditions of Use
228
+
229
+ 4.1 The rights granted in Section 3 above are expressly made subject to
230
+ Your complying with the following conditions of use. These are important
231
+ conditions of this License, and if You fail to follow them, You will be
232
+ in material breach of its terms.
233
+
234
+ 4.2 Notices. If You Publicly Convey this Database, any Derivative
235
+ Database, or the Database as part of a Collective Database, then You
236
+ must:
237
+
238
+ a. Do so only under the terms of this License;
239
+
240
+ b. Include a copy of this License or its Uniform Resource Identifier (URI)
241
+ with the Database or Derivative Database, including both in the
242
+ Database or Derivative Database and in any relevant documentation;
243
+
244
+ c. Keep intact any copyright or Database Right notices and notices
245
+ that refer to this License; and
246
+
247
+ d. If it is not possible to put the required notices in a particular
248
+ file due to its structure, then You must include the notices in a
249
+ location (such as a relevant directory) where users would be likely to
250
+ look for it.
251
+
252
+ 4.3 Notice for using output (Contents). Creating and Using a Produced
253
+ Work does not require the notice in Section 4.2. However, if you
254
+ Publicly Use a Produced Work, You must include a notice associated with
255
+ the Produced Work reasonably calculated to make any Person that uses,
256
+ views, accesses, interacts with, or is otherwise exposed to the Produced
257
+ Work aware that Content was obtained from the Database, Derivative
258
+ Database, or the Database as part of a Collective Database, and that it
259
+ is available under this License.
260
+
261
+ a. Example notice. The following text will satisfy notice under
262
+ Section 4.3:
263
+
264
+ Contains information from DATABASE NAME which is made available
265
+ under the ODC Attribution License.
266
+
267
+ DATABASE NAME should be replaced with the name of the Database and a
268
+ hyperlink to the location of the Database. "ODC Attribution License"
269
+ should contain a hyperlink to the URI of the text of this License. If
270
+ hyperlinks are not possible, You should include the plain text of the
271
+ required URI's with the above notice.
272
+
273
+ 4.4 Licensing of others. You may not sublicense the Database. Each time
274
+ You communicate the Database, the whole or Substantial part of the
275
+ Contents, or any Derivative Database to anyone else in any way, the
276
+ Licensor offers to the recipient a license to the Database on the same
277
+ terms and conditions as this License. You are not responsible for
278
+ enforcing compliance by third parties with this License, but You may
279
+ enforce any rights that You have over a Derivative Database. You are
280
+ solely responsible for any modifications of a Derivative Database made
281
+ by You or another Person at Your direction. You may not impose any
282
+ further restrictions on the exercise of the rights granted or affirmed
283
+ under this License.
284
+
285
+ ### 5.0 Moral rights
286
+
287
+ 5.1 Moral rights. This section covers moral rights, including any rights
288
+ to be identified as the author of the Database or to object to treatment
289
+ that would otherwise prejudice the author's honour and reputation, or
290
+ any other derogatory treatment:
291
+
292
+ a. For jurisdictions allowing waiver of moral rights, Licensor waives
293
+ all moral rights that Licensor may have in the Database to the fullest
294
+ extent possible by the law of the relevant jurisdiction under Section
295
+ 10.4;
296
+
297
+ b. If waiver of moral rights under Section 5.1 a in the relevant
298
+ jurisdiction is not possible, Licensor agrees not to assert any moral
299
+ rights over the Database and waives all claims in moral rights to the
300
+ fullest extent possible by the law of the relevant jurisdiction under
301
+ Section 10.4; and
302
+
303
+ c. For jurisdictions not allowing waiver or an agreement not to assert
304
+ moral rights under Section 5.1 a and b, the author may retain their
305
+ moral rights over certain aspects of the Database.
306
+
307
+ Please note that some jurisdictions do not allow for the waiver of moral
308
+ rights, and so moral rights may still subsist over the Database in some
309
+ jurisdictions.
310
+
311
+ ### 6.0 Fair dealing, Database exceptions, and other rights not affected
312
+
313
+ 6.1 This License does not affect any rights that You or anyone else may
314
+ independently have under any applicable law to make any use of this
315
+ Database, including without limitation:
316
+
317
+ a. Exceptions to the Database Right including: Extraction of Contents
318
+ from non-electronic Databases for private purposes, Extraction for
319
+ purposes of illustration for teaching or scientific research, and
320
+ Extraction or Re-utilisation for public security or an administrative
321
+ or judicial procedure.
322
+
323
+ b. Fair dealing, fair use, or any other legally recognised limitation
324
+ or exception to infringement of copyright or other applicable laws.
325
+
326
+ 6.2 This License does not affect any rights of lawful users to Extract
327
+ and Re-utilise insubstantial parts of the Contents, evaluated
328
+ quantitatively or qualitatively, for any purposes whatsoever, including
329
+ creating a Derivative Database (subject to other rights over the
330
+ Contents, see Section 2.4). The repeated and systematic Extraction or
331
+ Re-utilisation of insubstantial parts of the Contents may however amount
332
+ to the Extraction or Re-utilisation of a Substantial part of the
333
+ Contents.
334
+
335
+ ### 7.0 Warranties and Disclaimer
336
+
337
+ 7.1 The Database is licensed by the Licensor "as is" and without any
338
+ warranty of any kind, either express, implied, or arising by statute,
339
+ custom, course of dealing, or trade usage. Licensor specifically
340
+ disclaims any and all implied warranties or conditions of title,
341
+ non-infringement, accuracy or completeness, the presence or absence of
342
+ errors, fitness for a particular purpose, merchantability, or otherwise.
343
+ Some jurisdictions do not allow the exclusion of implied warranties, so
344
+ this exclusion may not apply to You.
345
+
346
+ ### 8.0 Limitation of liability
347
+
348
+ 8.1 Subject to any liability that may not be excluded or limited by law,
349
+ the Licensor is not liable for, and expressly excludes, all liability
350
+ for loss or damage however and whenever caused to anyone by any use
351
+ under this License, whether by You or by anyone else, and whether caused
352
+ by any fault on the part of the Licensor or not. This exclusion of
353
+ liability includes, but is not limited to, any special, incidental,
354
+ consequential, punitive, or exemplary damages such as loss of revenue,
355
+ data, anticipated profits, and lost business. This exclusion applies
356
+ even if the Licensor has been advised of the possibility of such
357
+ damages.
358
+
359
+ 8.2 If liability may not be excluded by law, it is limited to actual and
360
+ direct financial loss to the extent it is caused by proved negligence on
361
+ the part of the Licensor.
362
+
363
+ ### 9.0 Termination of Your rights under this License
364
+
365
+ 9.1 Any breach by You of the terms and conditions of this License
366
+ automatically terminates this License with immediate effect and without
367
+ notice to You. For the avoidance of doubt, Persons who have received the
368
+ Database, the whole or a Substantial part of the Contents, Derivative
369
+ Databases, or the Database as part of a Collective Database from You
370
+ under this License will not have their licenses terminated provided
371
+ their use is in full compliance with this License or a license granted
372
+ under Section 4.8 of this License. Sections 1, 2, 7, 8, 9 and 10 will
373
+ survive any termination of this License.
374
+
375
+ 9.2 If You are not in breach of the terms of this License, the Licensor
376
+ will not terminate Your rights under it.
377
+
378
+ 9.3 Unless terminated under Section 9.1, this License is granted to You
379
+ for the duration of applicable rights in the Database.
380
+
381
+ 9.4 Reinstatement of rights. If you cease any breach of the terms and
382
+ conditions of this License, then your full rights under this License
383
+ will be reinstated:
384
+
385
+ a. Provisionally and subject to permanent termination until the 60th
386
+ day after cessation of breach;
387
+
388
+ b. Permanently on the 60th day after cessation of breach unless
389
+ otherwise reasonably notified by the Licensor; or
390
+
391
+ c. Permanently if reasonably notified by the Licensor of the
392
+ violation, this is the first time You have received notice of
393
+ violation of this License from the Licensor, and You cure the
394
+ violation prior to 30 days after your receipt of the notice.
395
+
396
+ 9.5 Notwithstanding the above, Licensor reserves the right to release
397
+ the Database under different license terms or to stop distributing or
398
+ making available the Database. Releasing the Database under different
399
+ license terms or stopping the distribution of the Database will not
400
+ withdraw this License (or any other license that has been, or is
401
+ required to be, granted under the terms of this License), and this
402
+ License will continue in full force and effect unless terminated as
403
+ stated above.
404
+
405
+ ### 10.0 General
406
+
407
+ 10.1 If any provision of this License is held to be invalid or
408
+ unenforceable, that must not affect the validity or enforceability of
409
+ the remainder of the terms and conditions of this License and each
410
+ remaining provision of this License shall be valid and enforced to the
411
+ fullest extent permitted by law.
412
+
413
+ 10.2 This License is the entire agreement between the parties with
414
+ respect to the rights granted here over the Database. It replaces any
415
+ earlier understandings, agreements or representations with respect to
416
+ the Database.
417
+
418
+ 10.3 If You are in breach of the terms of this License, You will not be
419
+ entitled to rely on the terms of this License or to complain of any
420
+ breach by the Licensor.
421
+
422
+ 10.4 Choice of law. This License takes effect in and will be governed by
423
+ the laws of the relevant jurisdiction in which the License terms are
424
+ sought to be enforced. If the standard suite of rights granted under
425
+ applicable copyright law and Database Rights in the relevant
426
+ jurisdiction includes additional rights not granted under this License,
427
+ these additional rights are granted in this License in order to meet the
428
+ terms of this License.
@@ -0,0 +1,8 @@
1
+ This repository is to be considered as a database only.
2
+ You can find the documentation by following the link in the “About” section of this page.
3
+
4
+ # License
5
+
6
+ Data in this repository are distributed under an ODC-BY 1.0 license. That means you are free to share (to copy, distribute and use the database), to Create (to produce works from the database), to Adapt (to modify, transform and build upon the database) as long as you attribute to *Office of the French Ambassador for Digital Affairs*.
7
+
8
+ Contact the author if you have any specific need or question regarding licensing.
@@ -0,0 +1,44 @@
1
+ import fsApi from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ import config from 'config';
6
+
7
+ import Git from '../../../src/archivist/recorder/repositories/git/git.js';
8
+ import { fileExists } from '../utils.js';
9
+
10
+ const fs = fsApi.promises;
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+
13
+ const README_PATH = path.resolve(__dirname, './files/readme.md');
14
+ const LICENSE_PATH = path.resolve(__dirname, './files/license');
15
+
16
+ export async function initReadmeAndLicense(targetRepo, targetPath, authorDate) {
17
+ const targetReadmeFilePath = path.resolve(targetPath, 'README.md');
18
+ const targetLicenseFilePath = path.resolve(targetPath, 'LICENSE');
19
+
20
+ await fs.copyFile(README_PATH, targetReadmeFilePath);
21
+ await fs.copyFile(LICENSE_PATH, targetLicenseFilePath);
22
+ await targetRepo.add(targetReadmeFilePath);
23
+ await targetRepo.add(targetLicenseFilePath);
24
+ await targetRepo.commit({
25
+ message: 'Add readme and license',
26
+ date: authorDate,
27
+ });
28
+ }
29
+
30
+ export async function initTargetRepo(targetRepoPath) {
31
+ console.log('Initializing target repository');
32
+
33
+ if (await fileExists(targetRepoPath)) {
34
+ console.log(`Removed already existing target repository: ${targetRepoPath}`);
35
+ await fs.rm(targetRepoPath, { recursive: true });
36
+ }
37
+ await fs.mkdir(targetRepoPath);
38
+
39
+ const targetRepo = await new Git({ path: targetRepoPath, author: config.get('recorder.versions.storage.git.author') });
40
+
41
+ await targetRepo.initialize();
42
+
43
+ return targetRepo;
44
+ }
@@ -0,0 +1,108 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+
4
+ import config from 'config';
5
+
6
+ import Recorder from '../../src/archivist/recorder/index.js';
7
+ import Git from '../../src/archivist/recorder/repositories/git/git.js';
8
+ import GitRepository from '../../src/archivist/recorder/repositories/git/index.js';
9
+ import * as renamer from '../utils/renamer/index.js';
10
+
11
+ import * as initializer from './initializer/index.js';
12
+ import { loadFile } from './utils.js';
13
+
14
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+
16
+ const ROOT_PATH = path.resolve(__dirname, '../../');
17
+
18
+ export const SNAPSHOTS_SOURCE_PATH = path.resolve(ROOT_PATH, config.get('rewrite.snapshotsSourcePath'));
19
+ export const SNAPSHOTS_TARGET_PATH = path.resolve(ROOT_PATH, config.get('recorder.snapshots.storage.git.path'));
20
+ export const VERSIONS_TARGET_PATH = path.resolve(ROOT_PATH, config.get('recorder.versions.storage.git.path'));
21
+
22
+ const initialize = process.argv.includes('--init');
23
+
24
+ const COUNTERS = {
25
+ rewritten: 0,
26
+ skippedNoChanges: 0,
27
+ };
28
+
29
+ let recorder;
30
+
31
+ (async () => {
32
+ console.time('Total time');
33
+ console.log('Start rewritting history.');
34
+
35
+ await renamer.loadRules();
36
+ const sourceRepo = new Git({ path: SNAPSHOTS_SOURCE_PATH, author: config.get('recorder.snapshots.storage.git.author') });
37
+
38
+ await sourceRepo.initialize();
39
+
40
+ console.log('Waiting for git log… (this can take a while)');
41
+ const commits = (await sourceRepo.log(['--stat=4096'])).sort((a, b) => new Date(a.date) - new Date(b.date));
42
+
43
+ console.log(`Source repo contains ${commits.length} commits.\n`);
44
+
45
+ if (initialize) {
46
+ const targetRepo = await initializer.initTargetRepo(SNAPSHOTS_TARGET_PATH);
47
+ const [readmeCommit] = commits;
48
+
49
+ await initializer.initReadmeAndLicense(targetRepo, SNAPSHOTS_TARGET_PATH, readmeCommit.date);
50
+ }
51
+
52
+ recorder = new Recorder({
53
+ versionsRepository: new GitRepository({
54
+ ...config.get('recorder.versions.storage.git'),
55
+ path: VERSIONS_TARGET_PATH,
56
+ }),
57
+ snapshotsRepository: new GitRepository({
58
+ ...config.get('recorder.snapshots.storage.git'),
59
+ path: SNAPSHOTS_TARGET_PATH,
60
+ }),
61
+ });
62
+ await recorder.initialize();
63
+
64
+ const filteredCommits = commits.filter(({ message }) =>
65
+ message.match(/^(Start tracking|Update)/));
66
+
67
+ /* eslint-disable no-await-in-loop */
68
+ /* eslint-disable no-continue */
69
+ for (const commit of filteredCommits) {
70
+ console.log(Date.now(), commit.hash, commit.date, commit.message);
71
+
72
+ await sourceRepo.checkout(commit.hash);
73
+
74
+ const [{ file: relativeFilePath }] = commit.diff.files;
75
+
76
+ const { content, mimeType } = await loadFile(SNAPSHOTS_SOURCE_PATH, relativeFilePath);
77
+
78
+ let serviceId = path.dirname(relativeFilePath);
79
+ let documentType = path.basename(relativeFilePath, path.extname(relativeFilePath));
80
+
81
+ ({ serviceId, documentType } = renamer.applyRules(serviceId, documentType));
82
+
83
+ const { id: snapshotId } = await recorder.recordSnapshot({
84
+ serviceId,
85
+ documentType,
86
+ content,
87
+ mimeType,
88
+ fetchDate: commit.date,
89
+ });
90
+
91
+ if (snapshotId) {
92
+ COUNTERS.rewritten++;
93
+ } else {
94
+ COUNTERS.skippedNoChanges++;
95
+ }
96
+ }
97
+
98
+ const totalTreatedCommits = Object.values(COUNTERS).reduce((acc, value) => acc + value, 0);
99
+
100
+ console.log(`\nCommits treated: ${totalTreatedCommits} on ${filteredCommits.length}`);
101
+ console.log(`⌙ Commits rewritten: ${COUNTERS.rewritten}`);
102
+ console.log(`⌙ Skipped not changed commits: ${COUNTERS.skippedNoChanges}`);
103
+ console.timeEnd('Total time');
104
+
105
+ if (totalTreatedCommits != filteredCommits.length) {
106
+ console.error('\n⚠ WARNING: Total treated commits does not match the total number of commits to be treated! ⚠');
107
+ }
108
+ })();