zenodo 2.0.0 → 4.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 +66 -7
- package/lib/Zenodo.d.ts.map +1 -1
- package/lib/Zenodo.js +145 -29
- package/lib/Zenodo.js.map +1 -1
- package/lib/ZenodoAuthenticationStates.d.ts +22 -0
- package/lib/ZenodoAuthenticationStates.d.ts.map +1 -0
- package/lib/ZenodoAuthenticationStates.js +18 -0
- package/lib/ZenodoAuthenticationStates.js.map +1 -0
- package/lib/ZenodoFile.d.ts +22 -33
- package/lib/ZenodoFile.d.ts.map +1 -1
- package/lib/ZenodoFile.js +3 -19
- package/lib/ZenodoFile.js.map +1 -1
- package/lib/fetchZenodo.d.ts +45 -2
- package/lib/fetchZenodo.d.ts.map +1 -1
- package/lib/fetchZenodo.js +297 -15
- package/lib/fetchZenodo.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -17
- package/lib/index.js.map +1 -1
- package/{lib-esm/depositions → lib/records}/ListDepositionsOptions.d.ts +4 -2
- package/lib/records/ListDepositionsOptions.d.ts.map +1 -0
- package/lib/records/ListDepositionsOptions.js.map +1 -0
- package/lib/records/Record.d.ts +34 -0
- package/lib/records/Record.d.ts.map +1 -0
- package/lib/records/Record.js +225 -0
- package/lib/records/Record.js.map +1 -0
- package/lib/records/RecordType.d.ts +513 -0
- package/lib/records/RecordType.d.ts.map +1 -0
- package/lib/records/RecordType.js +2 -0
- package/lib/records/RecordType.js.map +1 -0
- package/lib/records/RequestType.d.ts +37 -0
- package/lib/records/RequestType.d.ts.map +1 -0
- package/lib/records/RequestType.js +2 -0
- package/lib/records/RequestType.js.map +1 -0
- package/lib/responseStatuses.js +1 -4
- package/lib/responseStatuses.js.map +1 -1
- 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 -26
- package/src/ZenodoAuthenticationStates.ts +23 -0
- package/src/ZenodoFile.ts +24 -18
- package/src/fetchZenodo.ts +491 -18
- package/src/index.ts +3 -1
- package/src/{depositions → records}/ListDepositionsOptions.ts +4 -2
- package/src/records/Record.ts +298 -0
- package/src/records/RecordType.ts +479 -0
- package/src/records/RequestType.ts +37 -0
- package/src/utilities/zipFiles.ts +36 -0
- package/lib/depositions/Deposition.d.ts +0 -14
- package/lib/depositions/Deposition.d.ts.map +0 -1
- package/lib/depositions/Deposition.js +0 -55
- package/lib/depositions/Deposition.js.map +0 -1
- package/lib/depositions/ListDepositionsOptions.d.ts +0 -32
- package/lib/depositions/ListDepositionsOptions.d.ts.map +0 -1
- package/lib/depositions/ListDepositionsOptions.js +0 -3
- package/lib/depositions/ListDepositionsOptions.js.map +0 -1
- 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.map +0 -1
- 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/Deposition.ts +0 -60
- package/src/depositions/depositionSchema.ts +0 -154
- /package/{lib-esm/depositions → lib/records}/ListDepositionsOptions.js +0 -0
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,19 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { Logger } from 'cheminfo-types';
|
|
2
|
+
import type { ZenodoAuthenticationStatesType } from './ZenodoAuthenticationStates.ts';
|
|
3
|
+
import type { ListDepositionsOptions } from './records/ListDepositionsOptions.ts';
|
|
4
|
+
import { Record } from './records/Record.ts';
|
|
5
|
+
import type { ZenodoMetadata, Identifier } from './records/RecordType.ts';
|
|
6
|
+
import type { ZenodoReview } from './records/RequestType.ts';
|
|
4
7
|
interface ZenodoOptions {
|
|
5
8
|
accessToken: string;
|
|
6
9
|
host?: string;
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
}
|
|
12
|
+
export interface PublicRecordOptions {
|
|
13
|
+
isPublished?: boolean;
|
|
7
14
|
}
|
|
8
15
|
export declare class Zenodo {
|
|
9
16
|
host: string;
|
|
10
17
|
accessToken: string;
|
|
11
18
|
baseURL: string;
|
|
19
|
+
logger?: Logger;
|
|
20
|
+
authenticationState: ZenodoAuthenticationStatesType;
|
|
12
21
|
constructor(options: ZenodoOptions);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Create a new Zenodo instance.
|
|
24
|
+
* This method authenticates the user and initializes a new Zenodo instance.
|
|
25
|
+
* @param options - the options for creating a Zenodo instance
|
|
26
|
+
* @throws {Error} If the authentication fails
|
|
27
|
+
* @returns a new Zenodo instance
|
|
28
|
+
*/
|
|
29
|
+
static create(options: ZenodoOptions): Promise<Zenodo>;
|
|
30
|
+
/**
|
|
31
|
+
* Verify the authentication state of the Zenodo instance.
|
|
32
|
+
* This method checks if the access token is valid by making a request to the Zenodo API.
|
|
33
|
+
* @returns true if authentication is successful, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
verifyAuthentication(): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Lists all records in the Zenodo instance.
|
|
38
|
+
* @param options - options for listing records
|
|
39
|
+
* @description Lists all records in the Zenodo instance.
|
|
40
|
+
* @returns An array of Record objects representing the records in the Zenodo instance.
|
|
41
|
+
*/
|
|
42
|
+
listRecords(options?: ListDepositionsOptions): Promise<Record[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new record in the Zenodo instance.
|
|
45
|
+
* @param metadata - the metadata for the new record
|
|
46
|
+
* @throws {Error} If the metadata is invalid or the request fails
|
|
47
|
+
* @returns The created record object
|
|
48
|
+
*/
|
|
49
|
+
createRecord(metadata: ZenodoMetadata): Promise<Record>;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve a public deposition record
|
|
52
|
+
* @param id - the deposition id
|
|
53
|
+
* @param options - additional options for the request
|
|
54
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
55
|
+
* @returns The public deposition record
|
|
56
|
+
*/
|
|
57
|
+
retrieveRecord(id: Identifier, options?: PublicRecordOptions): Promise<Record>;
|
|
58
|
+
/**
|
|
59
|
+
* List files in a deposition
|
|
60
|
+
* @param depositionId - the deposition id to retrieve requests for
|
|
61
|
+
* @returns An object containing the total number of requests and the list of requests
|
|
62
|
+
*/
|
|
63
|
+
retrieveRequests(depositionId?: Identifier): Promise<{
|
|
64
|
+
hits: {
|
|
65
|
+
total: number;
|
|
66
|
+
hits: ZenodoReview[];
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve all versions of a deposition
|
|
71
|
+
* @param id - the deposition id
|
|
72
|
+
* @returns unvalidated array of deposition versions
|
|
73
|
+
*/
|
|
74
|
+
retrieveVersions(id: Identifier): Promise<Record[]>;
|
|
75
|
+
deleteRecord(id: Identifier, options?: PublicRecordOptions): Promise<void>;
|
|
17
76
|
}
|
|
18
77
|
export {};
|
|
19
78
|
//# sourceMappingURL=Zenodo.d.ts.map
|
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,
|
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GAChC,OAAO,CAAC,MAAM,CAAC;IAWlB;;;;OAIG;IACG,gBAAgB,CACpB,YAAY,CAAC,EAAE,UAAU,GACxB,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,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBnD,YAAY,CAChB,EAAE,EAAE,UAAU,EACd,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC;CAUjB"}
|
package/lib/Zenodo.js
CHANGED
|
@@ -1,55 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Zenodo {
|
|
1
|
+
import { recursiveRemoveEmptyAndNull } from 'ml-spectra-processing';
|
|
2
|
+
import { ZenodoAuthenticationStates } from "./ZenodoAuthenticationStates.js";
|
|
3
|
+
import { fetchZenodo } from "./fetchZenodo.js";
|
|
4
|
+
import { Record } from "./records/Record.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: 'user/records',
|
|
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}user/records`;
|
|
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
|
}
|
|
19
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Lists all records in the Zenodo instance.
|
|
75
|
+
* @param options - options for listing records
|
|
76
|
+
* @description Lists all records in the Zenodo instance.
|
|
77
|
+
* @returns An array of Record objects representing the records in the Zenodo instance.
|
|
78
|
+
*/
|
|
79
|
+
async listRecords(options = {}) {
|
|
20
80
|
// all the values must be string
|
|
21
|
-
const optionsWithStrings = Object.fromEntries(Object.entries(options).map(([key, value]) =>
|
|
22
|
-
|
|
23
|
-
|
|
81
|
+
const optionsWithStrings = Object.fromEntries(Object.entries(options).map(([key, value]) => {
|
|
82
|
+
if (key === 'allVersions') {
|
|
83
|
+
return ['all_versions', String(value)];
|
|
84
|
+
}
|
|
85
|
+
return [key, String(value)];
|
|
86
|
+
}));
|
|
87
|
+
const response = await fetchZenodo(this, {
|
|
88
|
+
route: 'user/records',
|
|
24
89
|
searchParams: optionsWithStrings,
|
|
25
90
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
91
|
+
const records = (await response.json());
|
|
92
|
+
this.logger?.info(`Listed ${records.hits.hits.length} records`);
|
|
93
|
+
return records.hits.hits.map((record) => new Record(this, record));
|
|
28
94
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new record in the Zenodo instance.
|
|
97
|
+
* @param metadata - the metadata for the new record
|
|
98
|
+
* @throws {Error} If the metadata is invalid or the request fails
|
|
99
|
+
* @returns The created record object
|
|
100
|
+
*/
|
|
101
|
+
async createRecord(metadata) {
|
|
102
|
+
recursiveRemoveEmptyAndNull(metadata);
|
|
103
|
+
const response = await fetchZenodo(this, {
|
|
104
|
+
route: 'records',
|
|
32
105
|
expectedStatus: 201,
|
|
33
106
|
method: 'POST',
|
|
34
107
|
body: JSON.stringify({ metadata }),
|
|
35
108
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
109
|
+
const record = new Record(this, await response.json());
|
|
110
|
+
this.logger?.info(`Created record ${record.value.id}`);
|
|
111
|
+
return record;
|
|
38
112
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Retrieve a public deposition record
|
|
115
|
+
* @param id - the deposition id
|
|
116
|
+
* @param options - additional options for the request
|
|
117
|
+
* @throws {Error} If the deposition does not exist or the ID is undefined
|
|
118
|
+
* @returns The public deposition record
|
|
119
|
+
*/
|
|
120
|
+
async retrieveRecord(id, options = {}) {
|
|
121
|
+
const { isPublished = false } = options;
|
|
122
|
+
const route = isPublished ? `records/${id}` : `records/${id}/draft`;
|
|
123
|
+
const response = await fetchZenodo(this, {
|
|
124
|
+
route,
|
|
42
125
|
});
|
|
43
126
|
const deposition = await response.json();
|
|
44
|
-
|
|
127
|
+
this.logger?.info(`Retrieved public deposition ${id}`);
|
|
128
|
+
return new Record(this, deposition);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* List files in a deposition
|
|
132
|
+
* @param depositionId - the deposition id to retrieve requests for
|
|
133
|
+
* @returns An object containing the total number of requests and the list of requests
|
|
134
|
+
*/
|
|
135
|
+
async retrieveRequests(depositionId) {
|
|
136
|
+
const response = await fetchZenodo(this, {
|
|
137
|
+
route: `requests/`,
|
|
138
|
+
searchParams: {
|
|
139
|
+
q: String(depositionId),
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const requests = (await response.json());
|
|
143
|
+
this.logger?.info(`Retrieved ${requests.hits.total} requests for deposition ${depositionId}`);
|
|
144
|
+
return requests;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Retrieve all versions of a deposition
|
|
148
|
+
* @param id - the deposition id
|
|
149
|
+
* @returns unvalidated array of deposition versions
|
|
150
|
+
*/
|
|
151
|
+
async retrieveVersions(id) {
|
|
152
|
+
const response = await fetchZenodo(this, {
|
|
153
|
+
route: `records/${id}/versions`,
|
|
154
|
+
});
|
|
155
|
+
const versions = (await response.json());
|
|
156
|
+
this.logger?.info(`Retrieved ${versions?.hits.total} versions for deposition ${id}`);
|
|
157
|
+
const records = versions.hits.hits.map((version) => new Record(this, version));
|
|
158
|
+
return records;
|
|
45
159
|
}
|
|
46
|
-
async
|
|
47
|
-
|
|
160
|
+
async deleteRecord(id, options = {}) {
|
|
161
|
+
const { isPublished = false } = options;
|
|
162
|
+
const route = isPublished ? `records/${id}` : `records/${id}/draft`;
|
|
163
|
+
await fetchZenodo(this, {
|
|
48
164
|
method: 'DELETE',
|
|
49
|
-
route
|
|
165
|
+
route,
|
|
50
166
|
expectedStatus: 204,
|
|
51
167
|
});
|
|
168
|
+
this.logger?.info(`Deleted record ${id}`);
|
|
52
169
|
}
|
|
53
170
|
}
|
|
54
|
-
exports.Zenodo = Zenodo;
|
|
55
171
|
//# 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":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAc7C,MAAM,OAAO,MAAM;IACjB,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,mBAAmB,CAAiC;IAEpD,YAAY,OAAsB;QAChC,MAAM,EAAE,WAAW,EAAE,IAA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QAEjC,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QACxC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC;QACpE,MAAM,WAAW,CAAC,IAAI,EAAE;YACtB,MAAM,EAAE,QAAQ;YAChB,KAAK;YACL,cAAc,EAAE,GAAG;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the different states of Zenodo authentication for retry logic.
|
|
3
|
+
*
|
|
4
|
+
* Usage in retry mechanism (src/services/zenodoService.ts):
|
|
5
|
+
* The Zenodo API sometimes returns 401 Unauthorized or 403 Forbidden due to temporary issues.
|
|
6
|
+
* - If SUCCEEDED: Access token is valid, safe to retry the request
|
|
7
|
+
* - If FAILED: Access token is invalid/expired, do not retry
|
|
8
|
+
* - If NOT_TRIED: Can attempt authentication once to determine next steps
|
|
9
|
+
*/
|
|
10
|
+
export declare const ZenodoAuthenticationStates: {
|
|
11
|
+
/** Authentication verification has not been attempted yet. */
|
|
12
|
+
readonly NOT_TRIED: 0;
|
|
13
|
+
/** Authentication verification has failed (token is invalid/expired). */
|
|
14
|
+
readonly FAILED: 1;
|
|
15
|
+
/** Authentication verification has succeeded (token is valid). */
|
|
16
|
+
readonly SUCCEEDED: 2;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Type representing the authentication state numeric codes.
|
|
20
|
+
*/
|
|
21
|
+
export type ZenodoAuthenticationStatesType = (typeof ZenodoAuthenticationStates)[keyof typeof ZenodoAuthenticationStates];
|
|
22
|
+
//# sourceMappingURL=ZenodoAuthenticationStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZenodoAuthenticationStates.d.ts","sourceRoot":"","sources":["../src/ZenodoAuthenticationStates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B;IACrC,8DAA8D;;IAE9D,yEAAyE;;IAEzE,kEAAkE;;CAE1D,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the different states of Zenodo authentication for retry logic.
|
|
3
|
+
*
|
|
4
|
+
* Usage in retry mechanism (src/services/zenodoService.ts):
|
|
5
|
+
* The Zenodo API sometimes returns 401 Unauthorized or 403 Forbidden due to temporary issues.
|
|
6
|
+
* - If SUCCEEDED: Access token is valid, safe to retry the request
|
|
7
|
+
* - If FAILED: Access token is invalid/expired, do not retry
|
|
8
|
+
* - If NOT_TRIED: Can attempt authentication once to determine next steps
|
|
9
|
+
*/
|
|
10
|
+
export const ZenodoAuthenticationStates = {
|
|
11
|
+
/** Authentication verification has not been attempted yet. */
|
|
12
|
+
NOT_TRIED: 0,
|
|
13
|
+
/** Authentication verification has failed (token is invalid/expired). */
|
|
14
|
+
FAILED: 1,
|
|
15
|
+
/** Authentication verification has succeeded (token is valid). */
|
|
16
|
+
SUCCEEDED: 2,
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=ZenodoAuthenticationStates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZenodoAuthenticationStates.js","sourceRoot":"","sources":["../src/ZenodoAuthenticationStates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,8DAA8D;IAC9D,SAAS,EAAE,CAAC;IACZ,yEAAyE;IACzE,MAAM,EAAE,CAAC;IACT,kEAAkE;IAClE,SAAS,EAAE,CAAC;CACJ,CAAC"}
|
package/lib/ZenodoFile.d.ts
CHANGED
|
@@ -1,40 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
1
|
+
import type { Zenodo } from './Zenodo.ts';
|
|
2
|
+
interface ZenodoFileType {
|
|
3
|
+
created: string;
|
|
4
|
+
updated: string;
|
|
5
|
+
mimetype: string;
|
|
6
|
+
version_id: string;
|
|
7
|
+
file_id: string;
|
|
8
|
+
bucket_id: string;
|
|
9
|
+
metadata: object;
|
|
10
|
+
access: {
|
|
11
|
+
hidden: boolean;
|
|
26
12
|
};
|
|
27
|
-
}, {
|
|
28
|
-
id: string;
|
|
29
|
-
filename: string;
|
|
30
|
-
filesize: number;
|
|
31
|
-
checksum: string;
|
|
32
13
|
links: {
|
|
33
|
-
download: string;
|
|
34
14
|
self: string;
|
|
15
|
+
content: string;
|
|
16
|
+
commit: string;
|
|
17
|
+
};
|
|
18
|
+
key: string;
|
|
19
|
+
transfer: {
|
|
20
|
+
type: string;
|
|
35
21
|
};
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
status: string;
|
|
23
|
+
checksum: string;
|
|
24
|
+
size: number;
|
|
25
|
+
storage_class: string;
|
|
26
|
+
}
|
|
38
27
|
export declare class ZenodoFile {
|
|
39
28
|
private zenodo;
|
|
40
29
|
value: ZenodoFileType;
|
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;AAE1C,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,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,27 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
export class ZenodoFile {
|
|
17
2
|
zenodo;
|
|
18
3
|
value;
|
|
19
4
|
constructor(zenodo, file) {
|
|
20
|
-
this.value =
|
|
5
|
+
this.value = file;
|
|
21
6
|
this.zenodo = zenodo;
|
|
22
7
|
}
|
|
23
8
|
async getContentResponse() {
|
|
24
|
-
const link = this.value.links.
|
|
9
|
+
const link = this.value.links.content;
|
|
25
10
|
const response = await fetch(link, {
|
|
26
11
|
headers: {
|
|
27
12
|
Authorization: `Bearer ${this.zenodo.accessToken}`,
|
|
@@ -33,5 +18,4 @@ class ZenodoFile {
|
|
|
33
18
|
return response;
|
|
34
19
|
}
|
|
35
20
|
}
|
|
36
|
-
exports.ZenodoFile = ZenodoFile;
|
|
37
21
|
//# 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":"AAwBA,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IAChB,KAAK,CAAiB;IAE7B,YAAY,MAAc,EAAE,IAAa;QACvC,IAAI,CAAC,KAAK,GAAG,IAAsB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;QACtC,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"}
|
package/lib/fetchZenodo.d.ts
CHANGED
|
@@ -1,12 +1,55 @@
|
|
|
1
|
-
import type { Zenodo } from './Zenodo';
|
|
1
|
+
import type { Zenodo } from './Zenodo.ts';
|
|
2
2
|
interface FetchZenodoOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The route to append to the Zenodo base URL.
|
|
5
|
+
* @default 'user/records'
|
|
6
|
+
*/
|
|
3
7
|
route?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The HTTP method to use for the request.
|
|
10
|
+
* @default 'GET'
|
|
11
|
+
*/
|
|
4
12
|
method?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The content type of the request body.
|
|
15
|
+
* @default 'application/json' if body is not a FormData, undefined otherwise
|
|
16
|
+
*/
|
|
5
17
|
contentType?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The expected status code of the response. If the response status code does not match this
|
|
20
|
+
* value, we will retry.
|
|
21
|
+
* @default 200
|
|
22
|
+
*/
|
|
6
23
|
expectedStatus?: number;
|
|
7
24
|
searchParams?: Record<string, string>;
|
|
8
|
-
body?: string |
|
|
25
|
+
body?: string | File;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum number of retry attempts.
|
|
28
|
+
* @default 3
|
|
29
|
+
*/
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Base delay between retries in milliseconds.
|
|
33
|
+
* @default 1000
|
|
34
|
+
*/
|
|
35
|
+
baseDelay?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to use exponential backoff for retry delays.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
useExponentialBackoff?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to respect rate limit headers and wait accordingly.
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
respectRateLimit?: boolean;
|
|
9
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Fetch data from the Zenodo API with retry logic.
|
|
49
|
+
* @param zenodo - The Zenodo instance containing the base URL and access token.
|
|
50
|
+
* @param options - The options for the fetch request.
|
|
51
|
+
* @returns The response from the Zenodo API.
|
|
52
|
+
*/
|
|
10
53
|
export declare function fetchZenodo(zenodo: Zenodo, options: FetchZenodoOptions): Promise<Response>;
|
|
11
54
|
export {};
|
|
12
55
|
//# sourceMappingURL=fetchZenodo.d.ts.map
|
package/lib/fetchZenodo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchZenodo.d.ts","sourceRoot":"","sources":["../src/fetchZenodo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetchZenodo.d.ts","sourceRoot":"","sources":["../src/fetchZenodo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C,UAAU,kBAAkB;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA4ZD;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAwDnB"}
|