zenodo 2.0.0 → 3.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.
Files changed (122) hide show
  1. package/README.md +12 -0
  2. package/lib/Zenodo.d.ts +76 -4
  3. package/lib/Zenodo.d.ts.map +1 -1
  4. package/lib/Zenodo.js +150 -19
  5. package/lib/Zenodo.js.map +1 -1
  6. package/lib/ZenodoAuthenticationStates.d.ts +21 -0
  7. package/lib/ZenodoAuthenticationStates.d.ts.map +1 -0
  8. package/lib/ZenodoAuthenticationStates.js +20 -0
  9. package/lib/ZenodoAuthenticationStates.js.map +1 -0
  10. package/lib/ZenodoFile.d.ts +2 -38
  11. package/lib/ZenodoFile.d.ts.map +1 -1
  12. package/lib/ZenodoFile.js +3 -18
  13. package/lib/ZenodoFile.js.map +1 -1
  14. package/lib/depositions/Deposition.d.ts +90 -6
  15. package/lib/depositions/Deposition.d.ts.map +1 -1
  16. package/lib/depositions/Deposition.js +198 -29
  17. package/lib/depositions/Deposition.js.map +1 -1
  18. package/lib/depositions/ListDepositionsOptions.d.ts +4 -2
  19. package/lib/depositions/ListDepositionsOptions.d.ts.map +1 -1
  20. package/lib/depositions/ListDepositionsOptions.js +1 -2
  21. package/lib/depositions/Record.d.ts +10 -0
  22. package/lib/depositions/Record.d.ts.map +1 -0
  23. package/lib/depositions/Record.js +19 -0
  24. package/lib/depositions/Record.js.map +1 -0
  25. package/lib/fetchZenodo.d.ts +44 -1
  26. package/lib/fetchZenodo.d.ts.map +1 -1
  27. package/lib/fetchZenodo.js +214 -15
  28. package/lib/fetchZenodo.js.map +1 -1
  29. package/lib/index.d.ts +3 -1
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +3 -17
  32. package/lib/index.js.map +1 -1
  33. package/lib/responseStatuses.js +1 -4
  34. package/lib/responseStatuses.js.map +1 -1
  35. package/lib/utilities/ZenodoDepositionSchema.d.ts +473 -0
  36. package/lib/utilities/ZenodoDepositionSchema.d.ts.map +1 -0
  37. package/lib/utilities/ZenodoDepositionSchema.js +80 -0
  38. package/lib/utilities/ZenodoDepositionSchema.js.map +1 -0
  39. package/lib/utilities/ZenodoFileSchema.d.ts +39 -0
  40. package/lib/utilities/ZenodoFileSchema.d.ts.map +1 -0
  41. package/lib/utilities/ZenodoFileSchema.js +37 -0
  42. package/lib/utilities/ZenodoFileSchema.js.map +1 -0
  43. package/lib/utilities/ZenodoMetadataSchema.d.ts +400 -0
  44. package/lib/utilities/ZenodoMetadataSchema.d.ts.map +1 -0
  45. package/lib/utilities/ZenodoMetadataSchema.js +602 -0
  46. package/lib/utilities/ZenodoMetadataSchema.js.map +1 -0
  47. package/lib/utilities/ZenodoRecordSchema.d.ts +544 -0
  48. package/lib/utilities/ZenodoRecordSchema.d.ts.map +1 -0
  49. package/lib/utilities/ZenodoRecordSchema.js +70 -0
  50. package/lib/utilities/ZenodoRecordSchema.js.map +1 -0
  51. package/lib/utilities/ZenodoReviewSchema.d.ts +112 -0
  52. package/lib/utilities/ZenodoReviewSchema.d.ts.map +1 -0
  53. package/lib/utilities/ZenodoReviewSchema.js +80 -0
  54. package/lib/utilities/ZenodoReviewSchema.js.map +1 -0
  55. package/lib/utilities/licensesEnum.d.ts +4 -0
  56. package/lib/utilities/licensesEnum.d.ts.map +1 -0
  57. package/lib/utilities/licensesEnum.js +449 -0
  58. package/lib/utilities/licensesEnum.js.map +1 -0
  59. package/lib/utilities/schemaValidation.d.ts +50 -0
  60. package/lib/utilities/schemaValidation.d.ts.map +1 -0
  61. package/lib/utilities/schemaValidation.js +124 -0
  62. package/lib/utilities/schemaValidation.js.map +1 -0
  63. package/lib/utilities/zipFiles.d.ts +9 -0
  64. package/lib/utilities/zipFiles.d.ts.map +1 -0
  65. package/lib/utilities/zipFiles.js +28 -0
  66. package/lib/utilities/zipFiles.js.map +1 -0
  67. package/package.json +28 -22
  68. package/src/Zenodo.ts +180 -10
  69. package/src/ZenodoAuthenticationStates.ts +22 -0
  70. package/src/ZenodoFile.ts +4 -18
  71. package/src/depositions/Deposition.ts +236 -24
  72. package/src/depositions/ListDepositionsOptions.ts +4 -2
  73. package/src/depositions/Record.ts +25 -0
  74. package/src/fetchZenodo.ts +402 -16
  75. package/src/index.ts +5 -1
  76. package/src/utilities/ZenodoDepositionSchema.ts +90 -0
  77. package/src/utilities/ZenodoFileSchema.ts +40 -0
  78. package/src/utilities/ZenodoMetadataSchema.ts +608 -0
  79. package/src/utilities/ZenodoRecordSchema.ts +75 -0
  80. package/src/utilities/ZenodoReviewSchema.ts +84 -0
  81. package/src/utilities/licensesEnum.ts +448 -0
  82. package/src/utilities/schemaValidation.ts +150 -0
  83. package/src/utilities/zipFiles.ts +36 -0
  84. package/lib/depositions/depositionSchema.d.ts +0 -982
  85. package/lib/depositions/depositionSchema.d.ts.map +0 -1
  86. package/lib/depositions/depositionSchema.js +0 -141
  87. package/lib/depositions/depositionSchema.js.map +0 -1
  88. package/lib-esm/Zenodo.d.ts +0 -19
  89. package/lib-esm/Zenodo.d.ts.map +0 -1
  90. package/lib-esm/Zenodo.js +0 -51
  91. package/lib-esm/Zenodo.js.map +0 -1
  92. package/lib-esm/ZenodoFile.d.ts +0 -45
  93. package/lib-esm/ZenodoFile.d.ts.map +0 -1
  94. package/lib-esm/ZenodoFile.js +0 -33
  95. package/lib-esm/ZenodoFile.js.map +0 -1
  96. package/lib-esm/depositions/Deposition.d.ts +0 -14
  97. package/lib-esm/depositions/Deposition.d.ts.map +0 -1
  98. package/lib-esm/depositions/Deposition.js +0 -51
  99. package/lib-esm/depositions/Deposition.js.map +0 -1
  100. package/lib-esm/depositions/ListDepositionsOptions.d.ts +0 -32
  101. package/lib-esm/depositions/ListDepositionsOptions.d.ts.map +0 -1
  102. package/lib-esm/depositions/ListDepositionsOptions.js +0 -2
  103. package/lib-esm/depositions/ListDepositionsOptions.js.map +0 -1
  104. package/lib-esm/depositions/depositionSchema.d.ts +0 -982
  105. package/lib-esm/depositions/depositionSchema.d.ts.map +0 -1
  106. package/lib-esm/depositions/depositionSchema.js +0 -138
  107. package/lib-esm/depositions/depositionSchema.js.map +0 -1
  108. package/lib-esm/fetchZenodo.d.ts +0 -12
  109. package/lib-esm/fetchZenodo.d.ts.map +0 -1
  110. package/lib-esm/fetchZenodo.js +0 -31
  111. package/lib-esm/fetchZenodo.js.map +0 -1
  112. package/lib-esm/index.d.ts +0 -2
  113. package/lib-esm/index.d.ts.map +0 -1
  114. package/lib-esm/index.js +0 -2
  115. package/lib-esm/index.js.map +0 -1
  116. package/lib-esm/responseStatuses.d.ts +0 -8
  117. package/lib-esm/responseStatuses.d.ts.map +0 -1
  118. package/lib-esm/responseStatuses.js +0 -68
  119. package/lib-esm/responseStatuses.js.map +0 -1
  120. package/src/__tests__/Zenodo.test.ts +0 -79
  121. package/src/__tests__/getConfig.ts +0 -9
  122. package/src/depositions/depositionSchema.ts +0 -154
@@ -0,0 +1,84 @@
1
+ // The endpoint name is request but for clarity, we use the term review.
2
+ import type { FromSchema } from 'json-schema-to-ts';
3
+
4
+ export const ZenodoReviewSchema = {
5
+ $schema: 'http://json-schema.org/draft-07/schema#',
6
+ title: 'ZenodoReview',
7
+ type: 'object',
8
+ properties: {
9
+ id: { type: 'number' },
10
+ created: { type: 'string', format: 'date-time' },
11
+ updated: { type: 'string', format: 'date-time' },
12
+ links: {
13
+ type: 'object',
14
+ properties: {
15
+ actions: {
16
+ type: 'object',
17
+ properties: {
18
+ accept: { type: 'string' },
19
+ decline: { type: 'string' },
20
+ cancel: { type: 'string' },
21
+ submit: { type: 'string' }, // Only appears in the record/review endpoint but is not accessible (probably a bug)
22
+ },
23
+ additionalProperties: false,
24
+ },
25
+ self: { type: 'string' },
26
+ self_html: { type: 'string' },
27
+ comments: { type: 'string' },
28
+ timeline: { type: 'string' },
29
+ },
30
+ required: ['self', 'self_html', 'comments', 'timeline'],
31
+ additionalProperties: false,
32
+ },
33
+ revision_id: { type: 'number' },
34
+ type: { type: 'string' },
35
+ status: { type: 'string' },
36
+ is_closed: { type: 'boolean' },
37
+ is_open: { type: 'boolean' },
38
+ expires_at: { type: 'string', format: 'date-time' },
39
+ is_expired: { type: 'boolean' },
40
+ created_by: {
41
+ type: 'object',
42
+ properties: {
43
+ user: { type: 'string' },
44
+ },
45
+ required: ['user'],
46
+ additionalProperties: false,
47
+ },
48
+ receiver: {
49
+ type: 'object',
50
+ properties: {
51
+ community: { type: 'string' },
52
+ },
53
+ required: ['community'],
54
+ additionalProperties: false,
55
+ },
56
+ topic: {
57
+ type: 'object',
58
+ properties: {
59
+ record: { type: 'string' },
60
+ },
61
+ required: ['record'],
62
+ additionalProperties: false,
63
+ },
64
+ },
65
+ required: [
66
+ 'id',
67
+ 'created',
68
+ 'updated',
69
+ 'links',
70
+ 'revision_id',
71
+ 'type',
72
+ 'status',
73
+ 'is_closed',
74
+ 'is_open',
75
+ 'expires_at',
76
+ 'is_expired',
77
+ 'created_by',
78
+ 'receiver',
79
+ 'topic',
80
+ ],
81
+ additionalProperties: false,
82
+ } as const;
83
+
84
+ export type ZenodoReview = FromSchema<typeof ZenodoReviewSchema>;
@@ -0,0 +1,448 @@
1
+ export const licenseEnum = {
2
+ enum: [
3
+ 'glide',
4
+ 'amdplpa',
5
+ 'antlr-pd',
6
+ 'antlr-pd-fallback',
7
+ 'abstyles',
8
+ 'afl-1.1',
9
+ 'afl-1.2',
10
+ 'afl-2.0',
11
+ 'afl-2.1',
12
+ 'afl-3.0',
13
+ 'ampas',
14
+ 'apl-1.0',
15
+ 'adobe-glyph',
16
+ 'apafml',
17
+ 'adobe-2006',
18
+ 'agpl-1.0-only',
19
+ 'agpl-1.0-or-later',
20
+ 'afmparse',
21
+ 'against-drm',
22
+ 'aladdin',
23
+ 'adsl',
24
+ 'apache-1.0',
25
+ 'apache-1.1',
26
+ 'apache-2.0',
27
+ 'aml',
28
+ 'apsl-1.0',
29
+ 'apsl-1.1',
30
+ 'apsl-1.2',
31
+ 'apsl-2.0',
32
+ 'artistic-1.0',
33
+ 'artistic-1.0-perl',
34
+ 'artistic-1.0-cl8',
35
+ 'artistic-2.0',
36
+ 'aal',
37
+ 'bsd-1-clause',
38
+ 'bsd-2-clause',
39
+ 'bsd-2-clause-views',
40
+ 'bsd-3-clause',
41
+ 'bsd-3-clause-clear',
42
+ 'bsd-3-clause-no-nuclear-license',
43
+ 'bsd-3-clause-no-nuclear-license-2014',
44
+ 'bsd-3-clause-no-nuclear-warranty',
45
+ 'bsd-3-clause-open-mpi',
46
+ 'bsd-4-clause',
47
+ 'bsd-protection',
48
+ 'bsd-source-code',
49
+ '0bsd',
50
+ 'bsd-3-clause-attribution',
51
+ 'bsd-2-clause-patent',
52
+ 'bsd-4-clause-uc',
53
+ 'bahyph',
54
+ 'barr',
55
+ 'beerware',
56
+ 'bittorrent-1.0',
57
+ 'bittorrent-1.1',
58
+ 'blueoak-1.0.0',
59
+ 'bsl-1.0',
60
+ 'borceux',
61
+ 'busl-1.1',
62
+ 'cern-ohl-p-2.0',
63
+ 'cern-ohl-s-2.0',
64
+ 'cern-ohl-w-2.0',
65
+ 'cern-ohl-1.1',
66
+ 'cern-ohl-1.2',
67
+ 'mit-cmu',
68
+ 'cnri-jython',
69
+ 'cnri-python',
70
+ 'cnri-python-gpl-compatible',
71
+ 'cua-opl-1.0',
72
+ 'caldera',
73
+ 'cecill-1.0',
74
+ 'cecill-1.1',
75
+ 'cecill-2.0',
76
+ 'cecill-2.1',
77
+ 'cecill-b',
78
+ 'cecill-c',
79
+ 'clartistic',
80
+ 'cpol-1.02',
81
+ 'cddl-1.0',
82
+ 'cddl-1.1',
83
+ 'cpal-1.0',
84
+ 'cpl-1.0',
85
+ 'cdla-permissive-1.0',
86
+ 'cdla-sharing-1.0',
87
+ 'catosl-1.1',
88
+ 'condor-1.1',
89
+ 'cc-by-1.0',
90
+ 'cc-by-2.0',
91
+ 'cc-by-2.5',
92
+ 'cc-by-3.0-at',
93
+ 'cc-by-3.0-us',
94
+ 'cc-by-3.0',
95
+ 'cc-by-4.0',
96
+ 'cc-by-nd-1.0',
97
+ 'cc-by-nd-2.0',
98
+ 'cc-by-nd-2.5',
99
+ 'cc-by-nd-3.0',
100
+ 'cc-by-nd-4.0',
101
+ 'cc-by-nc-1.0',
102
+ 'cc-by-nc-2.0',
103
+ 'cc-by-nc-2.5',
104
+ 'cc-by-nc-3.0',
105
+ 'cc-by-nc-4.0',
106
+ 'cc-by-nc-nd-1.0',
107
+ 'cc-by-nc-nd-2.0',
108
+ 'cc-by-nc-nd-2.5',
109
+ 'cc-by-nc-nd-3.0-igo',
110
+ 'cc-by-nc-nd-3.0',
111
+ 'cc-by-nc-nd-4.0',
112
+ 'cc-by-nc-sa-1.0',
113
+ 'cc-by-nc-sa-2.0',
114
+ 'cc-by-nc-sa-2.5',
115
+ 'cc-by-nc-sa-3.0',
116
+ 'cc-by-nc-sa-4.0',
117
+ 'cc-by-sa-1.0',
118
+ 'cc-by-sa-2.0-uk',
119
+ 'cc-by-sa-2.0',
120
+ 'cc-by-sa-2.5',
121
+ 'cc-by-sa-3.0',
122
+ 'cc-by-sa-4.0',
123
+ 'cc-by-sa-3.0-at',
124
+ 'cc-pddc',
125
+ 'cc0-1.0',
126
+ 'crossword',
127
+ 'cal-1.0',
128
+ 'cal-1.0-combined-work-exception',
129
+ 'crystalstacker',
130
+ 'cube',
131
+ 'doc',
132
+ 'dsdp',
133
+ 'dsl',
134
+ 'd-fsl-1.0',
135
+ 'wtfpl',
136
+ 'dotseqn',
137
+ 'epics',
138
+ 'eudatagrid',
139
+ 'epl-1.0',
140
+ 'epl-2.0',
141
+ 'ecl-1.0',
142
+ 'ecl-2.0',
143
+ 'efl-1.0',
144
+ 'efl-2.0',
145
+ 'mit-advertising',
146
+ 'entessa',
147
+ 'erlpl-1.1',
148
+ 'etalab-2.0',
149
+ 'eurofound',
150
+ 'eupl-1.0',
151
+ 'eupl-1.1',
152
+ 'eupl-1.2',
153
+ 'eurosym',
154
+ 'fsfap',
155
+ 'fsful',
156
+ 'fsfullr',
157
+ 'fair',
158
+ 'frameworx-1.0',
159
+ 'zenodo-freetoread-1.0',
160
+ 'freeimage',
161
+ 'ftl',
162
+ 'gl2ps',
163
+ 'agpl-3.0-only',
164
+ 'agpl-3.0-or-later',
165
+ 'gfdl-1.1-only',
166
+ 'gfdl-1.1-invariants-only',
167
+ 'gfdl-1.1-no-invariants-only',
168
+ 'gfdl-1.1-or-later',
169
+ 'gfdl-1.1-invariants-or-later',
170
+ 'gfdl-1.1-no-invariants-or-later',
171
+ 'gfdl-1.2-only',
172
+ 'gfdl-1.2-invariants-only',
173
+ 'gfdl-1.2-no-invariants-only',
174
+ 'gfdl-1.2-or-later',
175
+ 'gfdl-1.2-invariants-or-later',
176
+ 'gfdl-1.2-no-invariants-or-later',
177
+ 'gfdl-1.3-only',
178
+ 'gfdl-1.3-invariants-only',
179
+ 'gfdl-1.3-no-invariants-only',
180
+ 'gfdl-1.3-or-later',
181
+ 'gfdl-1.3-invariants-or-later',
182
+ 'gfdl-1.3-no-invariants-or-later',
183
+ 'gpl-1.0-only',
184
+ 'gpl-1.0-or-later',
185
+ 'gpl-2.0-only',
186
+ 'gpl-2.0-or-later',
187
+ 'gpl-3.0-only',
188
+ 'gpl-3.0-or-later',
189
+ 'lgpl-2.1-only',
190
+ 'lgpl-2.1-or-later',
191
+ 'lgpl-3.0-only',
192
+ 'lgpl-3.0-or-later',
193
+ 'lgpl-2.0-only',
194
+ 'lgpl-2.0-or-later',
195
+ 'geogratis',
196
+ 'giftware',
197
+ 'glulxe',
198
+ 'glwtpl',
199
+ 'htmltidy',
200
+ 'haskellreport',
201
+ 'hesa-withrights',
202
+ 'hippocratic-2.1',
203
+ 'hpnd',
204
+ 'hpnd-sell-variant',
205
+ 'ibm-pibs',
206
+ 'ipl-1.0',
207
+ 'icu',
208
+ 'ipa',
209
+ 'isc',
210
+ 'imagemagick',
211
+ 'imlib2',
212
+ 'ijg',
213
+ 'info-zip',
214
+ 'intel-acpi',
215
+ 'intel',
216
+ 'interbase-1.0',
217
+ 'user-jsim',
218
+ 'json',
219
+ 'jabber-osl',
220
+ 'jpnic',
221
+ 'jasper-2.0',
222
+ 'lppl-1.0',
223
+ 'lppl-1.1',
224
+ 'lppl-1.2',
225
+ 'lppl-1.3a',
226
+ 'lppl-1.3c',
227
+ 'latex2e',
228
+ 'bsd-3-clause-lbnl',
229
+ 'leptonica',
230
+ 'lgpllr',
231
+ 'lal-1.2',
232
+ 'lal-1.3',
233
+ 'liliq-p-1.1',
234
+ 'liliq-rplus-1.1',
235
+ 'liliq-r-1.1',
236
+ 'notspecified',
237
+ 'linux-openib',
238
+ 'localauth-withrights',
239
+ 'lucent-plan9',
240
+ 'lpl-1.0',
241
+ 'lpl-1.02',
242
+ 'mitnfa',
243
+ 'mit',
244
+ 'mit-0',
245
+ 'mit-open-group',
246
+ 'mitre',
247
+ 'makeindex',
248
+ 'mtll',
249
+ 'met-office-cp',
250
+ 'ms-pl',
251
+ 'ms-rl',
252
+ 'motosoto',
253
+ 'mpl-1.0',
254
+ 'mpl-1.1',
255
+ 'mpl-2.0',
256
+ 'mpl-2.0-no-copyleft-exception',
257
+ 'mulanpsl-1.0',
258
+ 'mulanpsl-2.0',
259
+ 'multics',
260
+ 'mup',
261
+ 'nasa-1.3',
262
+ 'nist-pd',
263
+ 'nist-pd-fallback',
264
+ 'nrl',
265
+ 'ntp',
266
+ 'ntp-0',
267
+ 'naumen',
268
+ 'nbpl-1.0',
269
+ 'net-snmp',
270
+ 'netcdf',
271
+ 'ngpl',
272
+ 'nosl',
273
+ 'npl-1.0',
274
+ 'npl-1.1',
275
+ 'newsletr',
276
+ 'geo-no-fee-unrestricted',
277
+ 'nlpl',
278
+ 'nokia',
279
+ 'ncgl-uk-2.0',
280
+ 'nposl-3.0',
281
+ 'nlod-1.0',
282
+ 'noweb',
283
+ 'oclc-2.0',
284
+ 'odbl-1.0',
285
+ 'pddl-1.0',
286
+ 'ogc-1.0',
287
+ 'oset-pl-2.1',
288
+ 'occt-pl',
289
+ 'odc-by-1.0',
290
+ 'ogl-canada-2.0',
291
+ 'ogl-uk-1.0',
292
+ 'ogl-uk-2.0',
293
+ 'ogl-uk-3.0',
294
+ 'ogtsl',
295
+ 'oldap-2.2.2',
296
+ 'oldap-1.1',
297
+ 'oldap-1.2',
298
+ 'oldap-1.3',
299
+ 'oldap-1.4',
300
+ 'oldap-2.0',
301
+ 'oldap-2.0.1',
302
+ 'oldap-2.1',
303
+ 'oldap-2.2',
304
+ 'oldap-2.2.1',
305
+ 'oldap-2.3',
306
+ 'oldap-2.4',
307
+ 'oldap-2.5',
308
+ 'oldap-2.6',
309
+ 'oldap-2.7',
310
+ 'oldap-2.8',
311
+ 'oml',
312
+ 'opl-1.0',
313
+ 'osl-1.0',
314
+ 'osl-1.1',
315
+ 'osl-2.0',
316
+ 'osl-2.1',
317
+ 'osl-3.0',
318
+ 'o-uda-1.0',
319
+ 'openssl',
320
+ 'other-at',
321
+ 'other-nc',
322
+ 'other-closed',
323
+ 'other-open',
324
+ 'other-pd',
325
+ 'php-3.0',
326
+ 'php-3.01',
327
+ 'libpng-2.0',
328
+ 'plexus',
329
+ 'polyform-noncommercial-1.0.0',
330
+ 'polyform-small-business-1.0.0',
331
+ 'postgresql',
332
+ 'python-2.0',
333
+ 'psf-2.0',
334
+ 'qpl-1.0',
335
+ 'qhull',
336
+ 'qtpl',
337
+ 'rsa-md',
338
+ 'rdisc',
339
+ 'rpsl-1.0',
340
+ 'rpl-1.1',
341
+ 'rpl-1.5',
342
+ 'rhecos-1.1',
343
+ 'rscpl',
344
+ 'ruby',
345
+ 'scea',
346
+ 'sgi-b-1.0',
347
+ 'sgi-b-1.1',
348
+ 'sgi-b-2.0',
349
+ 'ofl-1.0',
350
+ 'ofl-1.0-rfn',
351
+ 'ofl-1.0-no-rfn',
352
+ 'ofl-1.1',
353
+ 'ofl-1.1-rfn',
354
+ 'ofl-1.1-no-rfn',
355
+ 'snia',
356
+ 'blessing',
357
+ 'ssh-openssh',
358
+ 'ssh-short',
359
+ 'sax-pd',
360
+ 'saxpath',
361
+ 'swl',
362
+ 'smppl',
363
+ 'sendmail',
364
+ 'sendmail-8.23',
365
+ 'sspl-1.0',
366
+ 'simpl-2.0',
367
+ 'sleepycat',
368
+ 'shl-0.5',
369
+ 'shl-0.51',
370
+ 'spencer-86',
371
+ 'spencer-94',
372
+ 'spencer-99',
373
+ 'smlnj',
374
+ 'dli-model-use',
375
+ 'sugarcrm-1.1.3',
376
+ 'sissl',
377
+ 'sissl-1.2',
378
+ 'spl-1.0',
379
+ 'watcom-1.0',
380
+ 'tapr-ohl-1.0',
381
+ 'tcl',
382
+ 'tcp-wrappers',
383
+ 'tmate',
384
+ 'torque-1.1',
385
+ 'tu-berlin-1.0',
386
+ 'tu-berlin-2.0',
387
+ 'miros',
388
+ 'parity-6.0.0',
389
+ 'parity-7.0.0',
390
+ 'unlicense',
391
+ 'tosl',
392
+ 'ukclickusepsi',
393
+ 'ukcrown',
394
+ 'ukcrown-withrights',
395
+ 'ukpsi',
396
+ 'unicode-dfs-2015',
397
+ 'unicode-dfs-2016',
398
+ 'unicode-tou',
399
+ 'upl-1.0',
400
+ 'ncsa',
401
+ 'ucl-1.0',
402
+ 'vostrom',
403
+ 'vim',
404
+ 'vsl-1.0',
405
+ 'w3c-20150513',
406
+ 'w3c-19980720',
407
+ 'w3c',
408
+ 'wsuipa',
409
+ 'xnet',
410
+ 'x11',
411
+ 'xfree86-1.1',
412
+ 'xpp',
413
+ 'xskat',
414
+ 'xerox',
415
+ 'ypl-1.0',
416
+ 'ypl-1.1',
417
+ 'zed',
418
+ 'zend-2.0',
419
+ 'zimbra-1.3',
420
+ 'zimbra-1.4',
421
+ 'zpl-1.1',
422
+ 'zpl-2.0',
423
+ 'zpl-2.1',
424
+ 'bzip2-1.0.5',
425
+ 'bzip2-1.0.6',
426
+ 'copyleft-next-0.3.0',
427
+ 'copyleft-next-0.3.1',
428
+ 'curl',
429
+ 'diffmark',
430
+ 'dvipdfm',
431
+ 'egenix',
432
+ 'mit-enna',
433
+ 'mit-feh',
434
+ 'gsoap-1.3b',
435
+ 'gnuplot',
436
+ 'imatix',
437
+ 'libpng',
438
+ 'libselinux-1.0',
439
+ 'libtiff',
440
+ 'mpich2',
441
+ 'psfrag',
442
+ 'psutils',
443
+ 'wxwindows',
444
+ 'xinetd',
445
+ 'zlib',
446
+ 'zlib-acknowledgement',
447
+ ],
448
+ } as const;
@@ -0,0 +1,150 @@
1
+ import Ajv from 'ajv';
2
+ import addFormats from 'ajv-formats';
3
+ import type { Logger } from 'cheminfo-types';
4
+ import orcidPkg from 'orcid-utils';
5
+
6
+ import { zenodoDepositionSchema } from './ZenodoDepositionSchema.ts';
7
+ import type { ZenodoDeposition } from './ZenodoDepositionSchema.ts';
8
+ import { zenodoFileSchema } from './ZenodoFileSchema.ts';
9
+ import type { ZenodoFileType } from './ZenodoFileSchema.ts';
10
+ import { zenodoMetadataSchema } from './ZenodoMetadataSchema.ts';
11
+ import type { ZenodoMetadata } from './ZenodoMetadataSchema.ts';
12
+ import type { ZenodoRecord } from './ZenodoRecordSchema.ts';
13
+ import { zenodoRecordSchema } from './ZenodoRecordSchema.ts';
14
+ import { ZenodoReviewSchema } from './ZenodoReviewSchema.ts';
15
+ import type { ZenodoReview } from './ZenodoReviewSchema.ts';
16
+ import { licenseEnum } from './licensesEnum.ts';
17
+
18
+ const { ORCID } = orcidPkg;
19
+
20
+ // eslint-disable-next-line new-cap
21
+ const ajv = new Ajv.default({
22
+ allErrors: true,
23
+ });
24
+ addFormats.default(ajv);
25
+
26
+ const validateMetadata = ajv.compile(zenodoMetadataSchema);
27
+
28
+ /**
29
+ * Validate Zenodo metadata against the schema
30
+ * @param metadata - Zenodo metadata object to validate
31
+ * @throws {Error} If the metadata does not conform to the Zenodo schema
32
+ * @returns The validated Zenodo metadata object
33
+ */
34
+ export function validateZenodoMetadata(metadata: unknown): ZenodoMetadata {
35
+ const isValid = validateMetadata(metadata);
36
+ if (!isValid) {
37
+ throw new Error(JSON.stringify(validateMetadata.errors, null, 2));
38
+ }
39
+ const validatedMetadata: ZenodoMetadata = metadata as ZenodoMetadata;
40
+ if (validatedMetadata.creators) {
41
+ for (const creator of validatedMetadata.creators) {
42
+ if (creator.orcid) {
43
+ validateORCID(creator.orcid);
44
+ }
45
+ }
46
+ }
47
+
48
+ return validatedMetadata;
49
+ }
50
+
51
+ const validateDeposition = ajv.compile(zenodoDepositionSchema);
52
+ /**
53
+ * Validate Zenodo deposition against the schema
54
+ * @param deposition - Zenodo deposition object to validate
55
+ * @param logger - FifoLogger instance for logging
56
+ * @throws {Error} If the deposition does not conform to the Zenodo schema
57
+ * @returns The validated Zenodo deposition object
58
+ */
59
+ export function validateZenodoDeposition(
60
+ deposition: unknown,
61
+ logger?: Logger,
62
+ ): ZenodoDeposition {
63
+ const licenses: string[] = [...licenseEnum.enum];
64
+ const isValid = validateDeposition(deposition);
65
+ if (!isValid) {
66
+ throw new Error(JSON.stringify(validateDeposition.errors, null, 2));
67
+ }
68
+ const validatedDeposition = deposition as ZenodoDeposition | ZenodoRecord;
69
+
70
+ const license = validatedDeposition.metadata?.license;
71
+
72
+ if (!license) {
73
+ logger?.warn(
74
+ `Invalid license "${license}". Valid licenses are: ${licenses.join(', ')}`,
75
+ );
76
+ }
77
+
78
+ if (validatedDeposition?.metadata?.creators) {
79
+ for (const creator of validatedDeposition.metadata.creators) {
80
+ if (creator.orcid) {
81
+ validateORCID(creator.orcid);
82
+ }
83
+ }
84
+ }
85
+
86
+ return validatedDeposition;
87
+ }
88
+
89
+ const validateRecord = ajv.compile(zenodoRecordSchema);
90
+ /**
91
+ * Validate Zenodo record against the schema
92
+ * @param record - Zenodo record object to validate
93
+ * @throws {Error} If the record does not conform to the Zenodo schema
94
+ * @returns The validated Zenodo record object
95
+ */
96
+ export function validateZenodoRecord(record: unknown): ZenodoRecord {
97
+ const isValid = validateRecord(record);
98
+ if (!isValid) {
99
+ throw new Error(JSON.stringify(validateRecord.errors, null, 2));
100
+ }
101
+ return record as ZenodoRecord;
102
+ }
103
+
104
+ const validateFile = ajv.compile(zenodoFileSchema);
105
+ /**
106
+ * Validate Zenodo file against the schema
107
+ * @param file - Zenodo deposition object to validate
108
+ * @throws {Error} If the deposition does not conform to the Zenodo schema
109
+ * @returns The validated Zenodo file object
110
+ */
111
+ export function validateZenodoFile(file: unknown): ZenodoFileType {
112
+ const isValid = validateFile(file);
113
+ if (!isValid) {
114
+ throw new Error(JSON.stringify(validateMetadata.errors, null, 2));
115
+ }
116
+ return file as ZenodoFileType;
117
+ }
118
+
119
+ const validateRequest = ajv.compile(ZenodoReviewSchema);
120
+
121
+ /**
122
+ * Validate Zenodo request against the schema
123
+ * @param request - Zenodo request object to validate
124
+ * @throws {Error} If the request does not conform to the Zenodo schema
125
+ * @returns The validated Zenodo request object
126
+ */
127
+ export function validateZenodoRequest(request: unknown): ZenodoReview {
128
+ const isValid = validateRequest(request);
129
+ if (!isValid) {
130
+ throw new Error(JSON.stringify(validateRequest.errors, null, 2));
131
+ }
132
+ return request as ZenodoReview;
133
+ }
134
+
135
+ /**
136
+ * This function checks if the provided ORCID ID is valid and returns it in dash format.
137
+ * @param id - ORCID ID to validate
138
+ * @throws {Error} If the ORCID ID is invalid or not provided
139
+ * @returns The ORCID ID in dash format
140
+ */
141
+ export function validateORCID(id: string): string {
142
+ if (!id) {
143
+ throw new Error('ORCID is required');
144
+ }
145
+ const isValid = ORCID.isValid(id);
146
+ if (!isValid) {
147
+ throw new Error(`Invalid ORCID: ${id}`);
148
+ }
149
+ return ORCID.toDashFormat(id);
150
+ }
@@ -0,0 +1,36 @@
1
+ import { ZipWriter, configure } from '@zip.js/zip.js';
2
+
3
+ configure({
4
+ useCompressionStream: true,
5
+ useWebWorkers: false,
6
+ });
7
+
8
+ /**
9
+ *
10
+ * This function zips an array of File objects into a single zip file.
11
+ * @param files - Array of File objects to be zipped
12
+ * @param zipName - The name of the resulting zip file (without extension)
13
+ * @returns A promise that resolves to a File object representing the zip file.
14
+ */
15
+ export async function zipFiles(files: File[], zipName: string): Promise<File> {
16
+ const zipFileStream = new TransformStream();
17
+ const zipFileBlobPromise = new Response(zipFileStream.readable).blob();
18
+ const zipWriter = new ZipWriter(zipFileStream.writable);
19
+
20
+ const attachmentPromises = files.map((file) =>
21
+ zipWriter.add(file.name, file.stream()),
22
+ );
23
+
24
+ await Promise.all(attachmentPromises);
25
+ await zipWriter.close();
26
+
27
+ const zipFileBlob = await zipFileBlobPromise;
28
+
29
+ if (zipFileBlob.size > 50 * 1024 * 1024 * 1024) {
30
+ throw new Error(`Zip file exceeds 50GB limit`);
31
+ }
32
+
33
+ return new File([zipFileBlob], `${zipName}.zip`, {
34
+ type: 'application/zip',
35
+ });
36
+ }