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.
- package/README.md +12 -0
- package/lib/Zenodo.d.ts +76 -4
- package/lib/Zenodo.d.ts.map +1 -1
- package/lib/Zenodo.js +150 -19
- package/lib/Zenodo.js.map +1 -1
- package/lib/ZenodoAuthenticationStates.d.ts +21 -0
- package/lib/ZenodoAuthenticationStates.d.ts.map +1 -0
- package/lib/ZenodoAuthenticationStates.js +20 -0
- package/lib/ZenodoAuthenticationStates.js.map +1 -0
- package/lib/ZenodoFile.d.ts +2 -38
- package/lib/ZenodoFile.d.ts.map +1 -1
- package/lib/ZenodoFile.js +3 -18
- package/lib/ZenodoFile.js.map +1 -1
- package/lib/depositions/Deposition.d.ts +90 -6
- package/lib/depositions/Deposition.d.ts.map +1 -1
- package/lib/depositions/Deposition.js +198 -29
- package/lib/depositions/Deposition.js.map +1 -1
- package/lib/depositions/ListDepositionsOptions.d.ts +4 -2
- package/lib/depositions/ListDepositionsOptions.d.ts.map +1 -1
- package/lib/depositions/ListDepositionsOptions.js +1 -2
- package/lib/depositions/Record.d.ts +10 -0
- package/lib/depositions/Record.d.ts.map +1 -0
- package/lib/depositions/Record.js +19 -0
- package/lib/depositions/Record.js.map +1 -0
- package/lib/fetchZenodo.d.ts +44 -1
- package/lib/fetchZenodo.d.ts.map +1 -1
- package/lib/fetchZenodo.js +214 -15
- package/lib/fetchZenodo.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -17
- package/lib/index.js.map +1 -1
- package/lib/responseStatuses.js +1 -4
- package/lib/responseStatuses.js.map +1 -1
- package/lib/utilities/ZenodoDepositionSchema.d.ts +473 -0
- package/lib/utilities/ZenodoDepositionSchema.d.ts.map +1 -0
- package/lib/utilities/ZenodoDepositionSchema.js +80 -0
- package/lib/utilities/ZenodoDepositionSchema.js.map +1 -0
- package/lib/utilities/ZenodoFileSchema.d.ts +39 -0
- package/lib/utilities/ZenodoFileSchema.d.ts.map +1 -0
- package/lib/utilities/ZenodoFileSchema.js +37 -0
- package/lib/utilities/ZenodoFileSchema.js.map +1 -0
- package/lib/utilities/ZenodoMetadataSchema.d.ts +400 -0
- package/lib/utilities/ZenodoMetadataSchema.d.ts.map +1 -0
- package/lib/utilities/ZenodoMetadataSchema.js +602 -0
- package/lib/utilities/ZenodoMetadataSchema.js.map +1 -0
- package/lib/utilities/ZenodoRecordSchema.d.ts +544 -0
- package/lib/utilities/ZenodoRecordSchema.d.ts.map +1 -0
- package/lib/utilities/ZenodoRecordSchema.js +70 -0
- package/lib/utilities/ZenodoRecordSchema.js.map +1 -0
- package/lib/utilities/ZenodoReviewSchema.d.ts +112 -0
- package/lib/utilities/ZenodoReviewSchema.d.ts.map +1 -0
- package/lib/utilities/ZenodoReviewSchema.js +80 -0
- package/lib/utilities/ZenodoReviewSchema.js.map +1 -0
- package/lib/utilities/licensesEnum.d.ts +4 -0
- package/lib/utilities/licensesEnum.d.ts.map +1 -0
- package/lib/utilities/licensesEnum.js +449 -0
- package/lib/utilities/licensesEnum.js.map +1 -0
- package/lib/utilities/schemaValidation.d.ts +50 -0
- package/lib/utilities/schemaValidation.d.ts.map +1 -0
- package/lib/utilities/schemaValidation.js +124 -0
- package/lib/utilities/schemaValidation.js.map +1 -0
- package/lib/utilities/zipFiles.d.ts +9 -0
- package/lib/utilities/zipFiles.d.ts.map +1 -0
- package/lib/utilities/zipFiles.js +28 -0
- package/lib/utilities/zipFiles.js.map +1 -0
- package/package.json +28 -22
- package/src/Zenodo.ts +180 -10
- package/src/ZenodoAuthenticationStates.ts +22 -0
- package/src/ZenodoFile.ts +4 -18
- package/src/depositions/Deposition.ts +236 -24
- package/src/depositions/ListDepositionsOptions.ts +4 -2
- package/src/depositions/Record.ts +25 -0
- package/src/fetchZenodo.ts +402 -16
- package/src/index.ts +5 -1
- package/src/utilities/ZenodoDepositionSchema.ts +90 -0
- package/src/utilities/ZenodoFileSchema.ts +40 -0
- package/src/utilities/ZenodoMetadataSchema.ts +608 -0
- package/src/utilities/ZenodoRecordSchema.ts +75 -0
- package/src/utilities/ZenodoReviewSchema.ts +84 -0
- package/src/utilities/licensesEnum.ts +448 -0
- package/src/utilities/schemaValidation.ts +150 -0
- package/src/utilities/zipFiles.ts +36 -0
- package/lib/depositions/depositionSchema.d.ts +0 -982
- package/lib/depositions/depositionSchema.d.ts.map +0 -1
- package/lib/depositions/depositionSchema.js +0 -141
- package/lib/depositions/depositionSchema.js.map +0 -1
- package/lib-esm/Zenodo.d.ts +0 -19
- package/lib-esm/Zenodo.d.ts.map +0 -1
- package/lib-esm/Zenodo.js +0 -51
- package/lib-esm/Zenodo.js.map +0 -1
- package/lib-esm/ZenodoFile.d.ts +0 -45
- package/lib-esm/ZenodoFile.d.ts.map +0 -1
- package/lib-esm/ZenodoFile.js +0 -33
- package/lib-esm/ZenodoFile.js.map +0 -1
- package/lib-esm/depositions/Deposition.d.ts +0 -14
- package/lib-esm/depositions/Deposition.d.ts.map +0 -1
- package/lib-esm/depositions/Deposition.js +0 -51
- package/lib-esm/depositions/Deposition.js.map +0 -1
- package/lib-esm/depositions/ListDepositionsOptions.d.ts +0 -32
- package/lib-esm/depositions/ListDepositionsOptions.d.ts.map +0 -1
- package/lib-esm/depositions/ListDepositionsOptions.js +0 -2
- package/lib-esm/depositions/ListDepositionsOptions.js.map +0 -1
- package/lib-esm/depositions/depositionSchema.d.ts +0 -982
- package/lib-esm/depositions/depositionSchema.d.ts.map +0 -1
- package/lib-esm/depositions/depositionSchema.js +0 -138
- package/lib-esm/depositions/depositionSchema.js.map +0 -1
- package/lib-esm/fetchZenodo.d.ts +0 -12
- package/lib-esm/fetchZenodo.d.ts.map +0 -1
- package/lib-esm/fetchZenodo.js +0 -31
- package/lib-esm/fetchZenodo.js.map +0 -1
- package/lib-esm/index.d.ts +0 -2
- package/lib-esm/index.d.ts.map +0 -1
- package/lib-esm/index.js +0 -2
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/responseStatuses.d.ts +0 -8
- package/lib-esm/responseStatuses.d.ts.map +0 -1
- package/lib-esm/responseStatuses.js +0 -68
- package/lib-esm/responseStatuses.js.map +0 -1
- package/src/__tests__/Zenodo.test.ts +0 -79
- package/src/__tests__/getConfig.ts +0 -9
- package/src/depositions/depositionSchema.ts +0 -154
package/README.md
CHANGED
|
@@ -45,6 +45,18 @@ const newFile = await firstDeposition.createFile(firstFile);
|
|
|
45
45
|
const secondFile = new File(['Hello, world 2!'], 'example2.txt', {
|
|
46
46
|
type: 'text/plain',
|
|
47
47
|
});
|
|
48
|
+
const newFile2 = await firstDeposition.createFile(secondFile);
|
|
49
|
+
|
|
50
|
+
await firstDeposition.deleteFile(newFile.id);
|
|
51
|
+
await firstDeposition.deleteFile(newFile2.id);
|
|
52
|
+
|
|
53
|
+
// alternatively you can upload both files at once
|
|
54
|
+
await firstDeposition.createFiles([firstFile, secondFile]);
|
|
55
|
+
|
|
56
|
+
// you can also create a zip contains many files
|
|
57
|
+
await firstDeposition.createFilesAsZip([firstFile, secondFile], {
|
|
58
|
+
zipName: 'data.zip',
|
|
59
|
+
});
|
|
48
60
|
```
|
|
49
61
|
|
|
50
62
|
## Development
|
package/lib/Zenodo.d.ts
CHANGED
|
@@ -1,18 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
1
|
+
import type { Logger } from 'cheminfo-types';
|
|
2
|
+
import type { ZenodoAuthenticationStatesType } from './ZenodoAuthenticationStates.ts';
|
|
3
|
+
import { Deposition } from './depositions/Deposition.ts';
|
|
4
|
+
import type { ListDepositionsOptions } from './depositions/ListDepositionsOptions.ts';
|
|
5
|
+
import { Record } from './depositions/Record.ts';
|
|
6
|
+
import type { ZenodoMetadata } from './utilities/ZenodoMetadataSchema.ts';
|
|
7
|
+
import type { ZenodoReview } from './utilities/ZenodoReviewSchema.ts';
|
|
4
8
|
interface ZenodoOptions {
|
|
5
9
|
accessToken: string;
|
|
6
10
|
host?: string;
|
|
11
|
+
logger?: Logger;
|
|
12
|
+
}
|
|
13
|
+
interface PublicRecordOptions {
|
|
14
|
+
isPublished?: boolean;
|
|
7
15
|
}
|
|
8
16
|
export declare class Zenodo {
|
|
9
17
|
host: string;
|
|
10
18
|
accessToken: string;
|
|
11
19
|
baseURL: string;
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
authenticationState: ZenodoAuthenticationStatesType;
|
|
12
22
|
constructor(options: ZenodoOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Create a new Zenodo instance.
|
|
25
|
+
* This method authenticates the user and initializes a new Zenodo instance.
|
|
26
|
+
* @param options - the options for creating a Zenodo instance
|
|
27
|
+
* @throws {Error} If the authentication fails
|
|
28
|
+
* @returns a new Zenodo instance
|
|
29
|
+
*/
|
|
30
|
+
static create(options: ZenodoOptions): Promise<Zenodo>;
|
|
31
|
+
/**
|
|
32
|
+
* Verify the authentication state of the Zenodo instance.
|
|
33
|
+
* This method checks if the access token is valid by making a request to the Zenodo API.
|
|
34
|
+
* @returns true if authentication is successful, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
verifyAuthentication(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* List all depositions
|
|
39
|
+
* @param options - options for listing depositions
|
|
40
|
+
* @returns an array of deposition objects
|
|
41
|
+
*/
|
|
13
42
|
listDepositions(options?: ListDepositionsOptions): Promise<Deposition[]>;
|
|
14
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Create a new deposition
|
|
45
|
+
* @param metadata - the metadata for the new deposition
|
|
46
|
+
* @throws {Error} If the metadata is invalid or the request fails
|
|
47
|
+
* @description Creates a new deposition with the provided metadata.
|
|
48
|
+
* @returns The created deposition object
|
|
49
|
+
*/
|
|
50
|
+
createDeposition(metadata: ZenodoMetadata): Promise<Deposition>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieve a deposition by its ID
|
|
53
|
+
* @param id - the deposition id
|
|
54
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
55
|
+
* @returns The retrieved deposition object
|
|
56
|
+
*/
|
|
15
57
|
retrieveDeposition(id: number): Promise<Deposition>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve a public deposition record
|
|
60
|
+
* @param id - the deposition id
|
|
61
|
+
* @param options - additional options for the request
|
|
62
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
63
|
+
* @returns The public deposition record
|
|
64
|
+
*/
|
|
65
|
+
retrieveRecord(id: number, options?: PublicRecordOptions): Promise<Record>;
|
|
66
|
+
/**
|
|
67
|
+
* List files in a deposition
|
|
68
|
+
* @param depositionId - the deposition id to retrieve requests for
|
|
69
|
+
* @returns An object containing the total number of requests and the list of requests
|
|
70
|
+
*/
|
|
71
|
+
retrieveRequests(depositionId?: number): Promise<{
|
|
72
|
+
hits: {
|
|
73
|
+
total: number;
|
|
74
|
+
hits: ZenodoReview[];
|
|
75
|
+
};
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve all versions of a deposition
|
|
79
|
+
* @param id - the deposition id
|
|
80
|
+
* @returns unvalidated array of deposition versions
|
|
81
|
+
*/
|
|
82
|
+
retrieveVersions(id: number): Promise<unknown[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes a deposition.
|
|
85
|
+
* @param id - the deposition id
|
|
86
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
87
|
+
*/
|
|
16
88
|
deleteDeposition(id: number): Promise<void>;
|
|
17
89
|
}
|
|
18
90
|
export {};
|
package/lib/Zenodo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Zenodo.d.ts","sourceRoot":"","sources":["../src/Zenodo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Zenodo.d.ts","sourceRoot":"","sources":["../src/Zenodo.ts"],"names":[],"mappings":"AAAA,OAAO,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M,EACV,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC;IAWlB;;;;OAIG;IACG,gBAAgB,CACpB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;QAAE,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,YAAY,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IAgB7D;;;;OAIG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IActD;;;;OAIG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQlD"}
|
package/lib/Zenodo.js
CHANGED
|
@@ -1,55 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Zenodo {
|
|
1
|
+
import { ZenodoAuthenticationStates } from "./ZenodoAuthenticationStates.js";
|
|
2
|
+
import { Deposition } from "./depositions/Deposition.js";
|
|
3
|
+
import { Record } from "./depositions/Record.js";
|
|
4
|
+
import { fetchZenodo } from "./fetchZenodo.js";
|
|
5
|
+
export class Zenodo {
|
|
7
6
|
host;
|
|
8
7
|
accessToken;
|
|
9
8
|
baseURL;
|
|
9
|
+
logger;
|
|
10
|
+
authenticationState;
|
|
10
11
|
constructor(options) {
|
|
11
|
-
const { accessToken, host = 'sandbox.zenodo.org' } = options;
|
|
12
|
+
const { accessToken, host = 'sandbox.zenodo.org', logger } = options;
|
|
12
13
|
this.host = host;
|
|
13
14
|
this.baseURL = `https://${host}/api/`;
|
|
14
|
-
|
|
15
|
-
throw new Error('accessToken is required');
|
|
16
|
-
}
|
|
15
|
+
this.logger = logger;
|
|
17
16
|
this.accessToken = accessToken;
|
|
17
|
+
this.authenticationState = ZenodoAuthenticationStates.NOT_TRIED;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new Zenodo instance.
|
|
21
|
+
* This method authenticates the user and initializes a new Zenodo instance.
|
|
22
|
+
* @param options - the options for creating a Zenodo instance
|
|
23
|
+
* @throws {Error} If the authentication fails
|
|
24
|
+
* @returns a new Zenodo instance
|
|
25
|
+
*/
|
|
26
|
+
static async create(options) {
|
|
27
|
+
const zenodo = new Zenodo(options);
|
|
28
|
+
const response = await fetchZenodo(zenodo, {
|
|
29
|
+
route: 'deposit/depositions',
|
|
30
|
+
expectedStatus: 200,
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error(`Failed to authenticate: ${response.statusText}`);
|
|
34
|
+
}
|
|
35
|
+
zenodo.logger?.info('Authenticated successfully');
|
|
36
|
+
zenodo.authenticationState = ZenodoAuthenticationStates.SUCCEEDED;
|
|
37
|
+
return zenodo;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Verify the authentication state of the Zenodo instance.
|
|
41
|
+
* This method checks if the access token is valid by making a request to the Zenodo API.
|
|
42
|
+
* @returns true if authentication is successful, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
async verifyAuthentication() {
|
|
45
|
+
const url = `${this.baseURL}deposit/depositions`;
|
|
46
|
+
const headers = new Headers();
|
|
47
|
+
if (this.accessToken) {
|
|
48
|
+
headers.set('Authorization', `Bearer ${this.accessToken}`);
|
|
49
|
+
}
|
|
50
|
+
// can't use fetchZenodo to avoid circular dependency
|
|
51
|
+
try {
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
method: 'GET',
|
|
54
|
+
headers,
|
|
55
|
+
});
|
|
56
|
+
if (response.status === 200) {
|
|
57
|
+
this.authenticationState = ZenodoAuthenticationStates.SUCCEEDED;
|
|
58
|
+
this.logger?.info('Authentication verified successfully');
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.authenticationState = ZenodoAuthenticationStates.FAILED;
|
|
63
|
+
this.logger?.warn(`Authentication failed with status ${response.status}`);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.authenticationState = ZenodoAuthenticationStates.FAILED;
|
|
69
|
+
this.logger?.error(`Authentication verification failed: ${String(error)}`);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
18
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* List all depositions
|
|
75
|
+
* @param options - options for listing depositions
|
|
76
|
+
* @returns an array of deposition objects
|
|
77
|
+
*/
|
|
19
78
|
async listDepositions(options = {}) {
|
|
20
79
|
// all the values must be string
|
|
21
|
-
const optionsWithStrings = Object.fromEntries(Object.entries(options).map(([key, value]) =>
|
|
22
|
-
|
|
80
|
+
const optionsWithStrings = Object.fromEntries(Object.entries(options).map(([key, value]) => {
|
|
81
|
+
if (key === 'allVersions') {
|
|
82
|
+
return ['all_versions', String(value)];
|
|
83
|
+
}
|
|
84
|
+
return [key, String(value)];
|
|
85
|
+
}));
|
|
86
|
+
const response = await fetchZenodo(this, {
|
|
23
87
|
route: 'deposit/depositions',
|
|
24
88
|
searchParams: optionsWithStrings,
|
|
25
89
|
});
|
|
26
90
|
const depositions = (await response.json());
|
|
27
|
-
|
|
91
|
+
this.logger?.info(`Listed ${depositions.length} depositions`);
|
|
92
|
+
return depositions.map((deposition) => new Deposition(this, deposition));
|
|
28
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a new deposition
|
|
96
|
+
* @param metadata - the metadata for the new deposition
|
|
97
|
+
* @throws {Error} If the metadata is invalid or the request fails
|
|
98
|
+
* @description Creates a new deposition with the provided metadata.
|
|
99
|
+
* @returns The created deposition object
|
|
100
|
+
*/
|
|
29
101
|
async createDeposition(metadata) {
|
|
30
|
-
const response = await
|
|
102
|
+
const response = await fetchZenodo(this, {
|
|
31
103
|
route: 'deposit/depositions',
|
|
32
104
|
expectedStatus: 201,
|
|
33
105
|
method: 'POST',
|
|
34
106
|
body: JSON.stringify({ metadata }),
|
|
35
107
|
});
|
|
36
|
-
const deposition = new
|
|
108
|
+
const deposition = new Deposition(this, await response.json());
|
|
109
|
+
this.logger?.info(`Created deposition ${deposition.value.id}`);
|
|
37
110
|
return deposition;
|
|
38
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieve a deposition by its ID
|
|
114
|
+
* @param id - the deposition id
|
|
115
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
116
|
+
* @returns The retrieved deposition object
|
|
117
|
+
*/
|
|
39
118
|
async retrieveDeposition(id) {
|
|
40
|
-
const response = await
|
|
119
|
+
const response = await fetchZenodo(this, {
|
|
41
120
|
route: `deposit/depositions/${id}`,
|
|
42
121
|
});
|
|
43
122
|
const deposition = await response.json();
|
|
44
|
-
|
|
123
|
+
this.logger?.info(`Retrieved deposition ${id}`);
|
|
124
|
+
return new Deposition(this, deposition);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Retrieve a public deposition record
|
|
128
|
+
* @param id - the deposition id
|
|
129
|
+
* @param options - additional options for the request
|
|
130
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
131
|
+
* @returns The public deposition record
|
|
132
|
+
*/
|
|
133
|
+
async retrieveRecord(id, options = {}) {
|
|
134
|
+
const { isPublished = false } = options;
|
|
135
|
+
const route = isPublished ? `records/${id}` : `records/${id}/draft`;
|
|
136
|
+
const response = await fetchZenodo(this, {
|
|
137
|
+
route,
|
|
138
|
+
});
|
|
139
|
+
const deposition = await response.json();
|
|
140
|
+
this.logger?.info(`Retrieved public deposition ${id}`);
|
|
141
|
+
return new Record(this, deposition);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* List files in a deposition
|
|
145
|
+
* @param depositionId - the deposition id to retrieve requests for
|
|
146
|
+
* @returns An object containing the total number of requests and the list of requests
|
|
147
|
+
*/
|
|
148
|
+
async retrieveRequests(depositionId) {
|
|
149
|
+
const response = await fetchZenodo(this, {
|
|
150
|
+
route: `requests/`,
|
|
151
|
+
searchParams: {
|
|
152
|
+
q: String(depositionId),
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
const requests = (await response.json());
|
|
156
|
+
this.logger?.info(`Retrieved ${requests.hits.total} requests for deposition ${depositionId}`);
|
|
157
|
+
return requests;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Retrieve all versions of a deposition
|
|
161
|
+
* @param id - the deposition id
|
|
162
|
+
* @returns unvalidated array of deposition versions
|
|
163
|
+
*/
|
|
164
|
+
async retrieveVersions(id) {
|
|
165
|
+
const response = await fetchZenodo(this, {
|
|
166
|
+
route: `records/${id}/versions`,
|
|
167
|
+
});
|
|
168
|
+
const versions = (await response.json());
|
|
169
|
+
this.logger?.info(`Retrieved ${versions?.hits.total} versions for deposition ${id}`);
|
|
170
|
+
return versions?.hits.hits || [];
|
|
45
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Deletes a deposition.
|
|
174
|
+
* @param id - the deposition id
|
|
175
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
176
|
+
*/
|
|
46
177
|
async deleteDeposition(id) {
|
|
47
|
-
await
|
|
178
|
+
await fetchZenodo(this, {
|
|
48
179
|
method: 'DELETE',
|
|
49
180
|
route: `deposit/depositions/${id}`,
|
|
50
181
|
expectedStatus: 204,
|
|
51
182
|
});
|
|
183
|
+
this.logger?.info(`Deleted deposition ${id}`);
|
|
52
184
|
}
|
|
53
185
|
}
|
|
54
|
-
exports.Zenodo = Zenodo;
|
|
55
186
|
//# sourceMappingURL=Zenodo.js.map
|
package/lib/Zenodo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Zenodo.js","sourceRoot":"","sources":["../src/Zenodo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Zenodo.js","sourceRoot":"","sources":["../src/Zenodo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;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IG;IACH,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAC/B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE;YACvC,KAAK,EAAE,WAAW,EAAE,WAAW;SAChC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAEtC,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,IAAI,CACf,aAAa,QAAQ,EAAE,IAAI,CAAC,KAAK,4BAA4B,EAAE,EAAE,CAClE,CAAC;QAEF,OAAO,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAC/B,MAAM,WAAW,CAAC,IAAI,EAAE;YACtB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,uBAAuB,EAAE,EAAE;YAClC,cAAc,EAAE,GAAG;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the different states of Zenodo authentication for retry logic.
|
|
3
|
+
*
|
|
4
|
+
* States:
|
|
5
|
+
* - NOT_TRIED: Authentication verification has not been attempted yet
|
|
6
|
+
* - FAILED: Authentication verification has failed
|
|
7
|
+
* - SUCCEEDED: Authentication verification has succeeded
|
|
8
|
+
*
|
|
9
|
+
* Usage in retry mechanism (src/services/zenodoService.ts):
|
|
10
|
+
* The Zenodo API sometimes returns 401 Unauthorized or 403 Forbidden due to temporary issues.
|
|
11
|
+
* - If SUCCEEDED: Access token is valid, safe to retry the request
|
|
12
|
+
* - If FAILED: Access token is invalid/expired, do not retry
|
|
13
|
+
* - If NOT_TRIED: Can attempt authentication once to determine next steps
|
|
14
|
+
*/
|
|
15
|
+
export declare const ZenodoAuthenticationStates: {
|
|
16
|
+
readonly NOT_TRIED: 0;
|
|
17
|
+
readonly FAILED: 1;
|
|
18
|
+
readonly SUCCEEDED: 2;
|
|
19
|
+
};
|
|
20
|
+
export type ZenodoAuthenticationStatesType = (typeof ZenodoAuthenticationStates)[keyof typeof ZenodoAuthenticationStates];
|
|
21
|
+
//# sourceMappingURL=ZenodoAuthenticationStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZenodoAuthenticationStates.d.ts","sourceRoot":"","sources":["../src/ZenodoAuthenticationStates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B;;;;CAI7B,CAAC;AAEX,MAAM,MAAM,8BAA8B,GACxC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the different states of Zenodo authentication for retry logic.
|
|
3
|
+
*
|
|
4
|
+
* States:
|
|
5
|
+
* - NOT_TRIED: Authentication verification has not been attempted yet
|
|
6
|
+
* - FAILED: Authentication verification has failed
|
|
7
|
+
* - SUCCEEDED: Authentication verification has succeeded
|
|
8
|
+
*
|
|
9
|
+
* Usage in retry mechanism (src/services/zenodoService.ts):
|
|
10
|
+
* The Zenodo API sometimes returns 401 Unauthorized or 403 Forbidden due to temporary issues.
|
|
11
|
+
* - If SUCCEEDED: Access token is valid, safe to retry the request
|
|
12
|
+
* - If FAILED: Access token is invalid/expired, do not retry
|
|
13
|
+
* - If NOT_TRIED: Can attempt authentication once to determine next steps
|
|
14
|
+
*/
|
|
15
|
+
export const ZenodoAuthenticationStates = {
|
|
16
|
+
NOT_TRIED: 0,
|
|
17
|
+
FAILED: 1,
|
|
18
|
+
SUCCEEDED: 2,
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ZenodoAuthenticationStates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZenodoAuthenticationStates.js","sourceRoot":"","sources":["../src/ZenodoAuthenticationStates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;CACJ,CAAC"}
|
package/lib/ZenodoFile.d.ts
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
export declare const zenodoFileSchema: z.ZodObject<{
|
|
4
|
-
id: z.ZodString;
|
|
5
|
-
filename: z.ZodString;
|
|
6
|
-
filesize: z.ZodNumber;
|
|
7
|
-
checksum: z.ZodString;
|
|
8
|
-
links: z.ZodObject<{
|
|
9
|
-
download: z.ZodString;
|
|
10
|
-
self: z.ZodString;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
download: string;
|
|
13
|
-
self: string;
|
|
14
|
-
}, {
|
|
15
|
-
download: string;
|
|
16
|
-
self: string;
|
|
17
|
-
}>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
id: string;
|
|
20
|
-
filename: string;
|
|
21
|
-
filesize: number;
|
|
22
|
-
checksum: string;
|
|
23
|
-
links: {
|
|
24
|
-
download: string;
|
|
25
|
-
self: string;
|
|
26
|
-
};
|
|
27
|
-
}, {
|
|
28
|
-
id: string;
|
|
29
|
-
filename: string;
|
|
30
|
-
filesize: number;
|
|
31
|
-
checksum: string;
|
|
32
|
-
links: {
|
|
33
|
-
download: string;
|
|
34
|
-
self: string;
|
|
35
|
-
};
|
|
36
|
-
}>;
|
|
37
|
-
type ZenodoFileType = z.infer<typeof zenodoFileSchema>;
|
|
1
|
+
import type { Zenodo } from './Zenodo.ts';
|
|
2
|
+
import type { ZenodoFileType } from './utilities/ZenodoFileSchema.ts';
|
|
38
3
|
export declare class ZenodoFile {
|
|
39
4
|
private zenodo;
|
|
40
5
|
value: ZenodoFileType;
|
|
41
6
|
constructor(zenodo: Zenodo, file: unknown);
|
|
42
7
|
getContentResponse(): Promise<Response>;
|
|
43
8
|
}
|
|
44
|
-
export {};
|
|
45
9
|
//# sourceMappingURL=ZenodoFile.d.ts.map
|
package/lib/ZenodoFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZenodoFile.d.ts","sourceRoot":"","sources":["../src/ZenodoFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ZenodoFile.d.ts","sourceRoot":"","sources":["../src/ZenodoFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGtE,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IAChB,KAAK,EAAE,cAAc,CAAC;gBAEjB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAKnC,kBAAkB;CAYzB"}
|
package/lib/ZenodoFile.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ZenodoFile = exports.zenodoFileSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
// Define the Zod schema
|
|
6
|
-
exports.zenodoFileSchema = zod_1.z.object({
|
|
7
|
-
id: zod_1.z.string(),
|
|
8
|
-
filename: zod_1.z.string(),
|
|
9
|
-
filesize: zod_1.z.number(),
|
|
10
|
-
checksum: zod_1.z.string(),
|
|
11
|
-
links: zod_1.z.object({
|
|
12
|
-
download: zod_1.z.string().url(),
|
|
13
|
-
self: zod_1.z.string().url(),
|
|
14
|
-
}),
|
|
15
|
-
});
|
|
16
|
-
class ZenodoFile {
|
|
1
|
+
import { validateZenodoFile } from "./utilities/schemaValidation.js";
|
|
2
|
+
export class ZenodoFile {
|
|
17
3
|
zenodo;
|
|
18
4
|
value;
|
|
19
5
|
constructor(zenodo, file) {
|
|
20
|
-
this.value =
|
|
6
|
+
this.value = validateZenodoFile(file);
|
|
21
7
|
this.zenodo = zenodo;
|
|
22
8
|
}
|
|
23
9
|
async getContentResponse() {
|
|
@@ -33,5 +19,4 @@ class ZenodoFile {
|
|
|
33
19
|
return response;
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
|
-
exports.ZenodoFile = ZenodoFile;
|
|
37
22
|
//# sourceMappingURL=ZenodoFile.js.map
|
package/lib/ZenodoFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZenodoFile.js","sourceRoot":"","sources":["../src/ZenodoFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ZenodoFile.js","sourceRoot":"","sources":["../src/ZenodoFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IAChB,KAAK,CAAiB;IAE7B,YAAY,MAAc,EAAE,IAAa;QACvC,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;QACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE;YACjC,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;aACnD;SACF,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,14 +1,98 @@
|
|
|
1
|
-
import type { Zenodo } from '../Zenodo';
|
|
2
|
-
import { ZenodoFile } from '../ZenodoFile';
|
|
3
|
-
import type {
|
|
1
|
+
import type { Zenodo } from '../Zenodo.ts';
|
|
2
|
+
import { ZenodoFile } from '../ZenodoFile.ts';
|
|
3
|
+
import type { ZenodoDeposition } from '../utilities/ZenodoDepositionSchema.ts';
|
|
4
|
+
import type { ZenodoMetadata } from '../utilities/ZenodoMetadataSchema.ts';
|
|
5
|
+
import type { ZenodoReview } from '../utilities/ZenodoReviewSchema.ts';
|
|
4
6
|
export declare class Deposition {
|
|
5
7
|
private zenodo;
|
|
6
8
|
value: ZenodoDeposition;
|
|
7
9
|
constructor(zenodo: Zenodo, deposition: unknown);
|
|
10
|
+
/**
|
|
11
|
+
* This method creates a new file in the deposition. If the file is already it will first
|
|
12
|
+
* delete the existing file and then create a new one.
|
|
13
|
+
* @param file - the file to create in the deposition
|
|
14
|
+
* @returns the created file object
|
|
15
|
+
*/
|
|
8
16
|
createFile(file: File): Promise<ZenodoFile>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates multiple files in the deposition. It will attempt to create each file
|
|
19
|
+
* multiple times with delays in between until all files are successfully created or
|
|
20
|
+
* the maximum number of attempts is reached.
|
|
21
|
+
* @param filesAndNames - an array of File objects to be created in the deposition
|
|
22
|
+
* @returns an array of the created ZenodoFile objects
|
|
23
|
+
*/
|
|
24
|
+
createFiles(filesAndNames: File[]): Promise<ZenodoFile[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a zip file from multiple files and uploads it to the deposition.
|
|
27
|
+
* @param filesAndNames - an array of File objects to be created in the deposition
|
|
28
|
+
* @param zipName - the name of the zip file to be created
|
|
29
|
+
* @returns an array of the created ZenodoFile objects
|
|
30
|
+
*/
|
|
31
|
+
createFilesAsZip(filesAndNames: File[], zipName: string): Promise<ZenodoFile[]>;
|
|
32
|
+
/**
|
|
33
|
+
* List all files in the deposition
|
|
34
|
+
* @returns an array of ZenodoFile objects
|
|
35
|
+
*/
|
|
9
36
|
listFiles(): Promise<ZenodoFile[]>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Delete a file from the deposition
|
|
39
|
+
* @param id - the ID or the name of the file to delete
|
|
40
|
+
*/
|
|
41
|
+
deleteFile(id: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* delete all files from the deposition
|
|
44
|
+
*/
|
|
45
|
+
deleteAllFiles(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieve a file from the deposition
|
|
48
|
+
* @param id - the ID or the name of the file to retrieve
|
|
49
|
+
* @returns the file object
|
|
50
|
+
*/
|
|
51
|
+
retrieveFile(id: string): Promise<ZenodoFile>;
|
|
52
|
+
/**
|
|
53
|
+
* Update the metadata of the deposition
|
|
54
|
+
* @param metadata - the new metadata to update the deposition with
|
|
55
|
+
* @returns the updated deposition object
|
|
56
|
+
*/
|
|
57
|
+
update(metadata: ZenodoMetadata): Promise<Deposition>;
|
|
58
|
+
/**
|
|
59
|
+
* Publish the deposition. This will make it publicly available.
|
|
60
|
+
* !!! Note that the deposition cannot be deleted after it is published.
|
|
61
|
+
* @returns the updated deposition object after publishing
|
|
62
|
+
*/
|
|
63
|
+
publish(): Promise<Deposition>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new version of a published deposition.
|
|
66
|
+
* This is useful for updating the deposition with new files or metadata.
|
|
67
|
+
* The new version will have a new ID and will not overwrite the existing deposition.
|
|
68
|
+
* @returns a new deposition object that is a new version of the current deposition
|
|
69
|
+
*/
|
|
70
|
+
newVersion(): Promise<Deposition>;
|
|
71
|
+
/**
|
|
72
|
+
* Upload a file to the deposition
|
|
73
|
+
* @param file - the file to upload to the deposition
|
|
74
|
+
* @returns the created file object
|
|
75
|
+
*/
|
|
76
|
+
uploadFile(file: File): Promise<ZenodoFile>;
|
|
77
|
+
/**
|
|
78
|
+
* Submits the deposition for review via browser.
|
|
79
|
+
* CORS request won't work from the other endpoint when using a browser.
|
|
80
|
+
* If a URL is provided, it will use that URL to submit the request.
|
|
81
|
+
* Otherwise, it will find the request for the current deposition and submit it.
|
|
82
|
+
* This is not the intended endpoint for submitting requests via browser.
|
|
83
|
+
* But the base endpoint is not CORS enabled.
|
|
84
|
+
* You can find the method with the right endpoint at:
|
|
85
|
+
* https://github.com/cheminfo/zenodo/blob/7fbf3e8bb44246b3465b94b68c21cd3f4fee3bf6/src/depositions/Deposition.ts#L286-L301
|
|
86
|
+
* @param url - optional URL to submit the request
|
|
87
|
+
* @returns The submitted Zenodo request object
|
|
88
|
+
*/
|
|
89
|
+
submitForReview(url?: string): Promise<ZenodoReview>;
|
|
90
|
+
/**
|
|
91
|
+
* Adds the deposition to a community.
|
|
92
|
+
* This method adds the deposition to a community by creating a review request.
|
|
93
|
+
* @param communityId - the ID of the community to add the deposition to
|
|
94
|
+
* @returns the response from the Zenodo API
|
|
95
|
+
*/
|
|
96
|
+
addToCommunity(communityId: string): Promise<unknown>;
|
|
13
97
|
}
|
|
14
98
|
//# sourceMappingURL=Deposition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deposition.d.ts","sourceRoot":"","sources":["../../src/depositions/Deposition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Deposition.d.ts","sourceRoot":"","sources":["../../src/depositions/Deposition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAIvE,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IAChB,KAAK,EAAE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