@cumulus/cmrjs 20.2.1 → 21.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/cmr-utils.d.ts +371 -108
- package/cmr-utils.d.ts.map +1 -1
- package/cmr-utils.js +263 -101
- package/cmr-utils.js.map +1 -1
- package/echo10Modifiers.d.ts +23 -0
- package/echo10Modifiers.d.ts.map +1 -0
- package/echo10Modifiers.js +38 -0
- package/echo10Modifiers.js.map +1 -0
- package/package.json +11 -11
- package/src/cmr-utils.js +333 -125
- package/src/echo10Modifiers.ts +52 -0
- package/src/ummgModifiers.ts +71 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/ummgModifiers.d.ts +35 -0
- package/ummgModifiers.d.ts.map +1 -0
- package/ummgModifiers.js +45 -0
- package/ummgModifiers.js.map +1 -0
package/cmr-utils.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export type CmrCredentials = {
|
|
2
|
-
provider: string;
|
|
3
|
-
clientId: string;
|
|
4
|
-
username?: string;
|
|
5
|
-
password?: string;
|
|
6
|
-
token?: string;
|
|
7
|
-
};
|
|
8
1
|
export type OnlineAccessUrl = {
|
|
9
2
|
/**
|
|
10
3
|
* - The generated file URL.
|
|
@@ -25,7 +18,79 @@ export type OnlineAccessUrl = {
|
|
|
25
18
|
};
|
|
26
19
|
export type CMRConstructorParams = import('@cumulus/cmr-client/CMR').CMRConstructorParams;
|
|
27
20
|
export type DistributionBucketMap = import('@cumulus/distribution-utils/dist/types').DistributionBucketMap;
|
|
28
|
-
export type
|
|
21
|
+
export type ApiFileGranuleIdOptional = import('@cumulus/types').ApiFileGranuleIdOptional;
|
|
22
|
+
export type ApiFileWithFilePath = ApiFileGranuleIdOptional & {
|
|
23
|
+
filepath?: string;
|
|
24
|
+
};
|
|
25
|
+
export type CmrFile = {
|
|
26
|
+
/**
|
|
27
|
+
* - The S3 bucket name
|
|
28
|
+
*/
|
|
29
|
+
bucket: string;
|
|
30
|
+
/**
|
|
31
|
+
* - The S3 key for the metadata file
|
|
32
|
+
*/
|
|
33
|
+
key: string;
|
|
34
|
+
/**
|
|
35
|
+
* - The granule ID associated with the file
|
|
36
|
+
*/
|
|
37
|
+
granuleId: string;
|
|
38
|
+
/**
|
|
39
|
+
* - Optional entity tag for file versioning
|
|
40
|
+
*/
|
|
41
|
+
etag?: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* /**
|
|
46
|
+
*/
|
|
47
|
+
export type CmrCredentials = {
|
|
48
|
+
provider: string;
|
|
49
|
+
clientId: string;
|
|
50
|
+
username?: string;
|
|
51
|
+
password?: string;
|
|
52
|
+
token?: string;
|
|
53
|
+
};
|
|
54
|
+
export type Echo10URLObject = {
|
|
55
|
+
URL: string;
|
|
56
|
+
Type?: string | undefined;
|
|
57
|
+
Description?: string | undefined;
|
|
58
|
+
URLDescription?: string | undefined;
|
|
59
|
+
};
|
|
60
|
+
export type Echo10MetadataObject = {
|
|
61
|
+
/**
|
|
62
|
+
* - The root ECHO10 granule object
|
|
63
|
+
*/
|
|
64
|
+
Granule: {
|
|
65
|
+
OnlineAccessURLs?: {
|
|
66
|
+
OnlineAccessURL?: Echo10URLObject[] | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
OnlineResources?: {
|
|
69
|
+
OnlineResource?: Echo10URLObject[] | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
AssociatedBrowseImageUrls?: {
|
|
72
|
+
ProviderBrowseUrl?: Echo10URLObject[] | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export type getS3UrlOfFileFile = {
|
|
77
|
+
/**
|
|
78
|
+
* - Full S3 URI (e.g., s3://bucket/key)
|
|
79
|
+
*/
|
|
80
|
+
filename?: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* - Bucket name (used with `key` or `filepath`)
|
|
83
|
+
*/
|
|
84
|
+
bucket?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* - S3 key (used with `bucket`)
|
|
87
|
+
*/
|
|
88
|
+
key?: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* - Alternate key for the file within the bucket
|
|
91
|
+
*/
|
|
92
|
+
filepath?: string | undefined;
|
|
93
|
+
};
|
|
29
94
|
/**
|
|
30
95
|
* Add ETags to file objects as some downstream functions expect this structure.
|
|
31
96
|
*
|
|
@@ -34,6 +99,22 @@ export type ApiFile = import('@cumulus/types').ApiFile;
|
|
|
34
99
|
* @returns {Object} - updated granule object
|
|
35
100
|
*/
|
|
36
101
|
export function addEtagsToFileObjects(granule: Object, etags: Object): Object;
|
|
102
|
+
/**
|
|
103
|
+
* Creates the query object used in POSTing to CMR.
|
|
104
|
+
* This query is a compound conditional using JSONQueryLanguage supported by CMR.
|
|
105
|
+
* This returns every collection that matches any of the short_name version pairs provided.
|
|
106
|
+
* the final query should be like
|
|
107
|
+
* {"condition":
|
|
108
|
+
* { "or": [{ "and": [{"short_name": "sn1"}, {"version": "001"}] },
|
|
109
|
+
* { "and": [{"short_name": "sn2"}, {"version": "006"}] },
|
|
110
|
+
* { "and": [{"short_name": "sn3"}, {"version": "001"}] },
|
|
111
|
+
* .... ] } }
|
|
112
|
+
*
|
|
113
|
+
* @param {Array<Object>} results - objects with keys "short_name" and "version"
|
|
114
|
+
* @returns {Object} - query object for a post to CMR that will return all of the collections that
|
|
115
|
+
* match any of the results.
|
|
116
|
+
*/
|
|
117
|
+
export function buildCMRQuery(results: Array<Object>): Object;
|
|
37
118
|
export function constructCmrConceptLink(conceptId: any, extension: any): string;
|
|
38
119
|
/**
|
|
39
120
|
* @typedef {Object} OnlineAccessUrl
|
|
@@ -45,33 +126,49 @@ export function constructCmrConceptLink(conceptId: any, extension: any): string;
|
|
|
45
126
|
/**
|
|
46
127
|
* Construct online access url for a given file and a url type.
|
|
47
128
|
*
|
|
48
|
-
* @param {Object} params
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {
|
|
53
|
-
*
|
|
54
|
-
* @param {boolean} [params.useDirectS3Type] -
|
|
55
|
-
* @returns {
|
|
129
|
+
* @param {Object} params
|
|
130
|
+
* @param {ApiFileWithFilePath} params.file - File object
|
|
131
|
+
* @param {string} params.distEndpoint - Distribution endpoint from config
|
|
132
|
+
* @param {{ [key: string]: string }} params.bucketTypes - Map of bucket names to bucket types
|
|
133
|
+
* @param {'distribution' | 's3'} params.urlType - URL type: 'distribution' or 's3'
|
|
134
|
+
* @param {DistributionBucketMap} params.distributionBucketMap - Map of bucket to distribution path
|
|
135
|
+
* @param {boolean} [params.useDirectS3Type=false] - Whether to use direct S3 Type
|
|
136
|
+
* @returns {Echo10URLObject | undefined} - Online access URL object, or undefined if not applicable
|
|
56
137
|
*/
|
|
57
|
-
export function constructOnlineAccessUrl({ file, distEndpoint, bucketTypes, urlType, distributionBucketMap, useDirectS3Type, }:
|
|
138
|
+
export function constructOnlineAccessUrl({ file, distEndpoint, bucketTypes, urlType, distributionBucketMap, useDirectS3Type, }: {
|
|
139
|
+
file: ApiFileWithFilePath;
|
|
140
|
+
distEndpoint: string;
|
|
141
|
+
bucketTypes: {
|
|
142
|
+
[key: string]: string;
|
|
143
|
+
};
|
|
144
|
+
urlType: 'distribution' | 's3';
|
|
145
|
+
distributionBucketMap: DistributionBucketMap;
|
|
146
|
+
useDirectS3Type?: boolean | undefined;
|
|
147
|
+
}): Echo10URLObject | undefined;
|
|
58
148
|
/**
|
|
59
149
|
* Construct a list of online access urls grouped by link type.
|
|
60
150
|
*
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {string} params.
|
|
65
|
-
* @param {
|
|
66
|
-
*
|
|
67
|
-
* @param {
|
|
68
|
-
*
|
|
69
|
-
*
|
|
151
|
+
* @param {Object} params
|
|
152
|
+
* @param {ApiFileWithFilePath[]} params.files - Array of file objects
|
|
153
|
+
* @param {string} params.distEndpoint - Distribution endpoint from config
|
|
154
|
+
* @param {{ [key: string]: string }} params.bucketTypes - Map of bucket name to bucket type
|
|
155
|
+
* @param {DistributionBucketMap} params.distributionBucketMap - Mapping of bucket to
|
|
156
|
+
* distribution path
|
|
157
|
+
* @param {string} [params.cmrGranuleUrlType=both] - Granule URL type: 's3',
|
|
158
|
+
* 'distribution', or 'both'
|
|
159
|
+
* @param {boolean} [params.useDirectS3Type=false] - Whether direct S3 URL types are used
|
|
160
|
+
* @returns {Echo10URLObject[]} Array of online access URL objects
|
|
70
161
|
*/
|
|
71
|
-
export function constructOnlineAccessUrls({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
162
|
+
export function constructOnlineAccessUrls({ bucketTypes, cmrGranuleUrlType, distEndpoint, distributionBucketMap, files, useDirectS3Type, }: {
|
|
163
|
+
files: ApiFileWithFilePath[];
|
|
164
|
+
distEndpoint: string;
|
|
165
|
+
bucketTypes: {
|
|
166
|
+
[key: string]: string;
|
|
167
|
+
};
|
|
168
|
+
distributionBucketMap: DistributionBucketMap;
|
|
169
|
+
cmrGranuleUrlType?: string | undefined;
|
|
170
|
+
useDirectS3Type?: boolean | undefined;
|
|
171
|
+
}): Echo10URLObject[];
|
|
75
172
|
export function generateEcho10XMLString(granule: any): string;
|
|
76
173
|
/**
|
|
77
174
|
* generate a url for a given file and a url type.
|
|
@@ -79,33 +176,24 @@ export function generateEcho10XMLString(granule: any): string;
|
|
|
79
176
|
* @param {Object} params - input parameters
|
|
80
177
|
* @param {Object} params.file - file object
|
|
81
178
|
* @param {string} params.distEndpoint - distribution endpoint from config
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {
|
|
84
|
-
* for all distribution
|
|
85
|
-
* @returns {(
|
|
179
|
+
* @param {string} [params.urlType = 'distribution'] - url type, distribution or s3
|
|
180
|
+
* @param {Object} params.distributionBucketMap - Object with bucket:tea-path mapping
|
|
181
|
+
* for all distribution buckets
|
|
182
|
+
* @returns {(string | undefined)} online access url object, undefined if no URL exists
|
|
86
183
|
*/
|
|
87
184
|
export function generateFileUrl({ file, distEndpoint, urlType, distributionBucketMap, }: {
|
|
88
185
|
file: Object;
|
|
89
186
|
distEndpoint: string;
|
|
90
|
-
urlType
|
|
91
|
-
distributionBucketMap:
|
|
92
|
-
}): (
|
|
187
|
+
urlType?: string | undefined;
|
|
188
|
+
distributionBucketMap: Object;
|
|
189
|
+
}): (string | undefined);
|
|
93
190
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* @param {
|
|
97
|
-
*
|
|
98
|
-
* @param {Array<Object>} granule.files - array of files for a granule
|
|
99
|
-
* @param {string} granule.granuleId - granule ID
|
|
100
|
-
* @param {Function} filterFunc - function to determine if the given file object is a
|
|
101
|
-
CMR file; defaults to `isCMRFile`
|
|
102
|
-
* @returns {Array<Object>} an array of CMR file objects, each with properties
|
|
103
|
-
* `granuleId`, `bucket`, `key`, and possibly `etag` (if present on input)
|
|
191
|
+
* Get collectionId from cmr metadata
|
|
192
|
+
* @param {object} cmrObject - cmr metadata object
|
|
193
|
+
* @param {string} cmrFileName - used to know how to parse this object
|
|
194
|
+
* @returns {string}
|
|
104
195
|
*/
|
|
105
|
-
export function
|
|
106
|
-
files: Array<Object>;
|
|
107
|
-
granuleId: string;
|
|
108
|
-
}, filterFunc?: Function): Array<Object>;
|
|
196
|
+
export function getCMRCollectionId(cmrObject: object, cmrFileName: string): string;
|
|
109
197
|
/**
|
|
110
198
|
* Helper to build an CMR settings object, used to initialize CMR.
|
|
111
199
|
*
|
|
@@ -133,14 +221,24 @@ export function getCmrSettings(cmrConfig?: {
|
|
|
133
221
|
passwordSecretName: string;
|
|
134
222
|
}): Promise<CMRConstructorParams>;
|
|
135
223
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @param {
|
|
139
|
-
* @returns {
|
|
224
|
+
* Call CMR to get the all matching Collections information with a compound query call.
|
|
225
|
+
*
|
|
226
|
+
* @param {Array<Object>} results - pared results from a Cumulus collection search.
|
|
227
|
+
* @returns {Promise<Object>} - resolves to the CMR return
|
|
228
|
+
* containing the found collections
|
|
140
229
|
*/
|
|
141
|
-
export function
|
|
230
|
+
export function getCollectionsByShortNameAndVersion(results: Array<Object>): Promise<Object>;
|
|
142
231
|
export function getFileDescription(file: any, urlType?: string): string;
|
|
143
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Returns the file 'name' of a given object.
|
|
234
|
+
*
|
|
235
|
+
* Accepts multiple file shapes commonly used throughout Cumulus and resolves
|
|
236
|
+
* them to a valid `s3://bucket/key` URI.
|
|
237
|
+
*
|
|
238
|
+
* @param {ApiFileWithFilePath} file - API File
|
|
239
|
+
* @returns {string | undefined} - The file name, or undefined if not found
|
|
240
|
+
*/
|
|
241
|
+
export function getFilename(file: ApiFileWithFilePath): string | undefined;
|
|
144
242
|
/**
|
|
145
243
|
* Extract temporal information from granule object
|
|
146
244
|
*
|
|
@@ -152,14 +250,16 @@ export function getFilename(file: any): any;
|
|
|
152
250
|
*/
|
|
153
251
|
export function getGranuleTemporalInfo(granule: Object): Promise<import('@cumulus/types').PartialGranuleProcessingInfo>;
|
|
154
252
|
/**
|
|
155
|
-
*
|
|
253
|
+
* Returns the S3 URI for a given file object.
|
|
156
254
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
255
|
+
* Accepts multiple file shapes commonly used throughout Cumulus and resolves
|
|
256
|
+
* them to a valid `s3://bucket/key` URI.
|
|
257
|
+
*
|
|
258
|
+
* @param {getS3UrlOfFileFile} file - File object containing filename or bucket/key data
|
|
259
|
+
* @returns {string} - A string representing the S3 URI (e.g., `s3://bucket/key`)
|
|
260
|
+
* @throws {Error} if the file does not contain enough information to construct the URI
|
|
160
261
|
*/
|
|
161
|
-
export function
|
|
162
|
-
export function getS3UrlOfFile(file: any): any;
|
|
262
|
+
export function getS3UrlOfFile(file: getS3UrlOfFileFile): string;
|
|
163
263
|
/**
|
|
164
264
|
* Call CMR to get a list of bucket/paths that a user has access to
|
|
165
265
|
*
|
|
@@ -168,6 +268,15 @@ export function getS3UrlOfFile(file: any): any;
|
|
|
168
268
|
* @returns {Object} list of bucket/paths that a user has access to
|
|
169
269
|
*/
|
|
170
270
|
export function getUserAccessibleBuckets(edlUser: string, cmrProvider?: string): Object;
|
|
271
|
+
/**
|
|
272
|
+
* Gets metadata for a CMR XML file from S3.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} xmlFilePath - S3 URI to the XML metadata document
|
|
275
|
+
* @param {string} [etag] - optional entity tag for the desired version of the
|
|
276
|
+
* CMR file
|
|
277
|
+
* @returns {Promise<string>} stringified XML document downloaded from S3
|
|
278
|
+
*/
|
|
279
|
+
export function getXMLMetadataAsString(xmlFilePath: string, etag?: string | undefined): Promise<string>;
|
|
171
280
|
/**
|
|
172
281
|
* Reduce granule object array to CMR files array
|
|
173
282
|
*
|
|
@@ -175,9 +284,25 @@ export function getUserAccessibleBuckets(edlUser: string, cmrProvider?: string):
|
|
|
175
284
|
* @param {Function} filterFunc - function to determine if the given file object is a
|
|
176
285
|
CMR file; defaults to `isCMRFile`
|
|
177
286
|
*
|
|
178
|
-
* @returns {Array<
|
|
287
|
+
* @returns {Array<CmrFile>} - CMR file object array: { etag, bucket, key, granuleId }
|
|
288
|
+
*/
|
|
289
|
+
export function granulesToCmrFileObjects(granules: Array<Object>, filterFunc?: Function): Array<CmrFile>;
|
|
290
|
+
/**
|
|
291
|
+
* Extracts CMR file objects from the specified granule object.
|
|
292
|
+
*
|
|
293
|
+
* @param {Object} granule - granule object containing CMR files within its
|
|
294
|
+
* `files` property
|
|
295
|
+
* @param {Array<Object>} granule.files - array of files for a granule
|
|
296
|
+
* @param {string} granule.granuleId - granule ID
|
|
297
|
+
* @param {Function} filterFunc - function to determine if the given file object is a
|
|
298
|
+
CMR file; defaults to `isCMRFile`
|
|
299
|
+
* @returns {Array<CmrFile>} an array of CMR file objects, each with properties
|
|
300
|
+
* `granuleId`, `bucket`, `key`, and possibly `etag` (if present on input)
|
|
179
301
|
*/
|
|
180
|
-
export function
|
|
302
|
+
export function granuleToCmrFileObject({ granuleId, files }: {
|
|
303
|
+
files: Array<Object>;
|
|
304
|
+
granuleId: string;
|
|
305
|
+
}, filterFunc?: Function): Array<CmrFile>;
|
|
181
306
|
/**
|
|
182
307
|
* Returns True if this object can be determined to be a cmrMetadata object.
|
|
183
308
|
*
|
|
@@ -219,6 +344,13 @@ export function mapFileEtags(files: Object[]): Object;
|
|
|
219
344
|
* @see isUMMGFilename
|
|
220
345
|
*/
|
|
221
346
|
export function metadataObjectFromCMRFile(cmrFilename: string, etag?: string | undefined): Promise<Object>;
|
|
347
|
+
/**
|
|
348
|
+
* Parse an xml string
|
|
349
|
+
*
|
|
350
|
+
* @param {string} xml - xml to parse
|
|
351
|
+
* @returns {Promise<Object>} promise resolves to object version of the xml
|
|
352
|
+
*/
|
|
353
|
+
export function parseXmlString(xml: string): Promise<Object>;
|
|
222
354
|
/**
|
|
223
355
|
* Determines what type of metadata object and posts either ECHO10XML or UMMG
|
|
224
356
|
* JSON data to CMR.
|
|
@@ -246,7 +378,7 @@ export function publish2CMR(cmrPublishObject: {
|
|
|
246
378
|
username: string;
|
|
247
379
|
password: string;
|
|
248
380
|
token: string;
|
|
249
|
-
}, cmrRevisionId: string): Object
|
|
381
|
+
}, cmrRevisionId: string): Promise<Object>;
|
|
250
382
|
/**
|
|
251
383
|
* Update CMR Metadata record with the information contained in updatedFiles
|
|
252
384
|
* @param {Object} params - parameter object
|
|
@@ -286,80 +418,207 @@ export function removeEtagsFromFileObjects(granule: Object): undefined;
|
|
|
286
418
|
* @param {CmrCredentials} creds - credentials needed to post to CMR service
|
|
287
419
|
*/
|
|
288
420
|
export function removeFromCMR(granuleUR: string, creds: CmrCredentials): Promise<unknown>;
|
|
421
|
+
/**
|
|
422
|
+
* Update collection in an ECHO10 cmr metadata object
|
|
423
|
+
*
|
|
424
|
+
* @param {object} cmrObject - CMR metadata object
|
|
425
|
+
* @param {{ name: string, version: string }} collection - collection name and version to update to
|
|
426
|
+
* @returns {object}
|
|
427
|
+
*/
|
|
428
|
+
export function setECHO10Collection(cmrObject: object, collection: {
|
|
429
|
+
name: string;
|
|
430
|
+
version: string;
|
|
431
|
+
}): object;
|
|
432
|
+
/**
|
|
433
|
+
* Update collection in an UMMG cmr metadata object
|
|
434
|
+
*
|
|
435
|
+
* @param {object} cmrObject - CMR metadata object
|
|
436
|
+
* @param {{ name: string, version: string }} collection - collection name and version to update to
|
|
437
|
+
* @returns {object}
|
|
438
|
+
*/
|
|
439
|
+
export function setUMMGCollection(cmrObject: object, collection: {
|
|
440
|
+
name: string;
|
|
441
|
+
version: string;
|
|
442
|
+
}): object;
|
|
289
443
|
/**
|
|
290
444
|
* Modifies cmr metadata file with file's URLs updated to their new locations.
|
|
291
445
|
*
|
|
292
446
|
* @param {Object} params - parameter object
|
|
293
447
|
* @param {string} params.granuleId - granuleId
|
|
294
|
-
* @param {
|
|
295
|
-
* @param {
|
|
448
|
+
* @param {string} [params.producerGranuleId] - producer granuleId
|
|
449
|
+
* @param {CmrFile} params.cmrFile - cmr file to be updated
|
|
450
|
+
* @param {ApiFileWithFilePath[]} params.files - array of file objects
|
|
296
451
|
* @param {string} params.distEndpoint - distribution enpoint from config
|
|
297
452
|
* @param {boolean} params.published - indicate if publish is needed
|
|
298
453
|
* @param {{ [key: string]: string }} params.bucketTypes - map of bucket names to bucket types
|
|
299
454
|
* @param {string} params.cmrGranuleUrlType - type of granule CMR url
|
|
455
|
+
* @param {boolean} [params.updateGranuleIdentifiers]
|
|
456
|
+
* - If true, update the GranuleUR and ProducerGranuleId in metadata
|
|
457
|
+
* @param {any} [params.testOverrides]
|
|
458
|
+
* - Optional test overrides for internal functions
|
|
300
459
|
* @param {DistributionBucketMap} params.distributionBucketMap - Object with bucket:tea-path
|
|
301
460
|
* mapping for all distribution buckets
|
|
302
461
|
* @returns {Promise<Object>} CMR file object with the `etag` of the newly
|
|
303
462
|
* updated metadata file
|
|
304
463
|
*/
|
|
305
|
-
export function updateCMRMetadata({ granuleId, cmrFile, files, distEndpoint, published, bucketTypes, cmrGranuleUrlType, distributionBucketMap, }: {
|
|
464
|
+
export function updateCMRMetadata({ granuleId, producerGranuleId, cmrFile, files, distEndpoint, published, bucketTypes, cmrGranuleUrlType, updateGranuleIdentifiers, distributionBucketMap, testOverrides, }: {
|
|
306
465
|
granuleId: string;
|
|
307
|
-
|
|
308
|
-
|
|
466
|
+
producerGranuleId?: string | undefined;
|
|
467
|
+
cmrFile: CmrFile;
|
|
468
|
+
files: ApiFileWithFilePath[];
|
|
309
469
|
distEndpoint: string;
|
|
310
470
|
published: boolean;
|
|
311
471
|
bucketTypes: {
|
|
312
472
|
[key: string]: string;
|
|
313
473
|
};
|
|
314
474
|
cmrGranuleUrlType: string;
|
|
475
|
+
updateGranuleIdentifiers?: boolean | undefined;
|
|
476
|
+
testOverrides?: any;
|
|
315
477
|
distributionBucketMap: DistributionBucketMap;
|
|
316
478
|
}): Promise<Object>;
|
|
317
479
|
/**
|
|
318
|
-
*
|
|
480
|
+
* Updates an ECHO10 CMR XML metadata file on S3 to reflect new URLs and optionally
|
|
481
|
+
* a new GranuleUR and ProducerGranuleId.
|
|
319
482
|
*
|
|
320
|
-
* @param {Object} params
|
|
321
|
-
* @param {
|
|
322
|
-
* @param {
|
|
323
|
-
* @param {
|
|
324
|
-
* @param {
|
|
325
|
-
*
|
|
326
|
-
* @
|
|
483
|
+
* @param {Object} params
|
|
484
|
+
* @param {string} params.granuleId - New GranuleUR to set in metadata
|
|
485
|
+
* @param {string} params.producerGranuleId - Original ProducerGranuleId to record
|
|
486
|
+
* @param {CmrFile} params.cmrFile - The cmr xml file to be updated
|
|
487
|
+
* @param {ApiFileWithFilePath[]} params.files - List of granule files used
|
|
488
|
+
* to generate OnlineAccess URLs
|
|
489
|
+
* @param {string} params.distEndpoint - Distribution endpoint for download URLs
|
|
490
|
+
* @param {{ [bucket: string]: string }} params.bucketTypes - Mapping of bucket names to their types
|
|
491
|
+
* @param {string} [params.cmrGranuleUrlType]
|
|
492
|
+
* - Type of URLs to generate ('distribution' | 's3' | 'both')
|
|
493
|
+
* @param {DistributionBucketMap} params.distributionBucketMap
|
|
494
|
+
* - Maps buckets to distribution paths
|
|
495
|
+
* @param {boolean} [params.updateGranuleIdentifiers]
|
|
496
|
+
* - If true, update the GranuleUR and ProducerGranuleId in metadata
|
|
497
|
+
* @param {any} [params.testOverrides]
|
|
498
|
+
* - Optional test overrides for internal functions
|
|
499
|
+
* @returns {Promise<{ metadataObject: any, etag: string }>}
|
|
500
|
+
* The updated metadata object and resulting ETag
|
|
327
501
|
*/
|
|
328
|
-
export function
|
|
502
|
+
export function updateEcho10XMLMetadata({ granuleId, producerGranuleId, cmrFile, files, distEndpoint, bucketTypes, cmrGranuleUrlType, distributionBucketMap, updateGranuleIdentifiers, testOverrides, }: {
|
|
503
|
+
granuleId: string;
|
|
504
|
+
producerGranuleId: string;
|
|
505
|
+
cmrFile: CmrFile;
|
|
506
|
+
files: ApiFileWithFilePath[];
|
|
507
|
+
distEndpoint: string;
|
|
508
|
+
bucketTypes: {
|
|
509
|
+
[bucket: string]: string;
|
|
510
|
+
};
|
|
511
|
+
cmrGranuleUrlType?: string | undefined;
|
|
512
|
+
distributionBucketMap: DistributionBucketMap;
|
|
513
|
+
updateGranuleIdentifiers?: boolean | undefined;
|
|
514
|
+
testOverrides?: any;
|
|
515
|
+
}): Promise<{
|
|
516
|
+
metadataObject: any;
|
|
517
|
+
etag: string;
|
|
518
|
+
}>;
|
|
329
519
|
/**
|
|
330
|
-
*
|
|
520
|
+
* Updates the OnlineAccessURLs, OnlineResources, and AssociatedBrowseImageUrls
|
|
521
|
+
* fields of an ECHO10 CMR metadata object with newly constructed URLs.
|
|
331
522
|
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* @
|
|
523
|
+
* This function:
|
|
524
|
+
* - Extracts the original URL sets from the ECHO10 XML metadata.
|
|
525
|
+
* - Constructs new URL entries based on the provided file list and configuration.
|
|
526
|
+
* - Merges new URLs with original ones, removing outdated or irrelevant URLs.
|
|
527
|
+
* - Returns a new metadata object with an updated `Granule` field.
|
|
528
|
+
*
|
|
529
|
+
* @param {Object} params - Input parameters
|
|
530
|
+
* @param {Echo10MetadataObject} params.metadataObject - The parsed ECHO10 metadata XML
|
|
531
|
+
* object (as a JavaScript object), expected to include a `Granule` key
|
|
532
|
+
* @param {ApiFileWithFilePath[]} params.files - Granule files to generate
|
|
533
|
+
* updated URLs from
|
|
534
|
+
* @param {string} params.distEndpoint - The base distribution endpoint URL
|
|
535
|
+
* (e.g., CloudFront origin)
|
|
536
|
+
* @param {{ [bucketName: string]: string }} params.bucketTypes - Mapping of bucket names
|
|
537
|
+
* to access types ('public', 'protected', etc.)
|
|
538
|
+
* @param {string} [params.cmrGranuleUrlType='both'] - Type of URLs to generate
|
|
539
|
+
* for CMR: 'distribution', 's3', or 'both'
|
|
540
|
+
* @param {DistributionBucketMap} params.distributionBucketMap - Maps S3 buckets to their
|
|
541
|
+
* distribution URL paths
|
|
542
|
+
*
|
|
543
|
+
* @returns {Echo10MetadataObject} A new ECHO10 metadata object with updated
|
|
544
|
+
* `Granule.OnlineAccessURLs`, `Granule.OnlineResources`, and `Granule.AssociatedBrowseImageUrls`
|
|
545
|
+
* fields
|
|
339
546
|
*/
|
|
340
|
-
export function
|
|
547
|
+
export function updateEcho10XMLMetadataObjectUrls({ metadataObject, files, distEndpoint, bucketTypes, cmrGranuleUrlType, distributionBucketMap, }: {
|
|
548
|
+
metadataObject: Echo10MetadataObject;
|
|
549
|
+
files: ApiFileWithFilePath[];
|
|
550
|
+
distEndpoint: string;
|
|
551
|
+
bucketTypes: {
|
|
552
|
+
[bucketName: string]: string;
|
|
553
|
+
};
|
|
554
|
+
cmrGranuleUrlType?: string | undefined;
|
|
555
|
+
distributionBucketMap: DistributionBucketMap;
|
|
556
|
+
}): Echo10MetadataObject;
|
|
341
557
|
/**
|
|
342
|
-
*
|
|
558
|
+
* After files are moved, create new online access URLs and then update the S3
|
|
559
|
+
* UMMG cmr.json file with this information.
|
|
343
560
|
*
|
|
344
|
-
* @param {
|
|
345
|
-
* @param {
|
|
346
|
-
* @
|
|
561
|
+
* @param {Object} params - parameter object
|
|
562
|
+
* @param {CmrFile} params.cmrFile - cmr.json file whose contents will be updated.
|
|
563
|
+
* @param {ApiFileWithFilePath[]} params.files - array of moved file objects.
|
|
564
|
+
* @param {string} params.distEndpoint - distribution endpoint form config.
|
|
565
|
+
* @param {{ [bucket: string]: string }} params.bucketTypes - map of bucket names to bucket types
|
|
566
|
+
* @param {string} params.cmrGranuleUrlType - cmrGranuleUrlType from config
|
|
567
|
+
* @param {DistributionBucketMap} params.distributionBucketMap - Object with bucket:tea-path
|
|
568
|
+
* mapping for all distribution buckets
|
|
569
|
+
* @param {string} params.producerGranuleId - producer granule id
|
|
570
|
+
* @param {string} params.granuleId - granule id
|
|
571
|
+
* @param {boolean} [params.updateGranuleIdentifiers=false] - whether to update the granule UR/add
|
|
572
|
+
* producerGranuleID to the CMR metadata object
|
|
573
|
+
* @param {any} [params.testOverrides] - overrides for testing
|
|
574
|
+
* @returns {Promise<{ metadataObject: Object, etag: string | undefined}>} an object
|
|
575
|
+
* containing a `metadataObject` (the updated UMMG metadata object) and the
|
|
576
|
+
* `etag` of the uploaded CMR file
|
|
347
577
|
*/
|
|
348
|
-
export function
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
578
|
+
export function updateUMMGMetadata({ cmrFile, files, distEndpoint, bucketTypes, cmrGranuleUrlType, distributionBucketMap, producerGranuleId, granuleId, updateGranuleIdentifiers, testOverrides, }: {
|
|
579
|
+
cmrFile: CmrFile;
|
|
580
|
+
files: ApiFileWithFilePath[];
|
|
581
|
+
distEndpoint: string;
|
|
582
|
+
bucketTypes: {
|
|
583
|
+
[bucket: string]: string;
|
|
584
|
+
};
|
|
585
|
+
cmrGranuleUrlType: string;
|
|
586
|
+
distributionBucketMap: DistributionBucketMap;
|
|
587
|
+
producerGranuleId: string;
|
|
588
|
+
granuleId: string;
|
|
589
|
+
updateGranuleIdentifiers?: boolean | undefined;
|
|
590
|
+
testOverrides?: any;
|
|
591
|
+
}): Promise<{
|
|
592
|
+
metadataObject: Object;
|
|
593
|
+
etag: string | undefined;
|
|
594
|
+
}>;
|
|
352
595
|
/**
|
|
353
|
-
* Update
|
|
596
|
+
* Update the UMMG cmr metadata object to have corrected urls
|
|
354
597
|
*
|
|
355
|
-
* @param {
|
|
356
|
-
* @param {
|
|
357
|
-
* @
|
|
598
|
+
* @param {Object} params - Parameters for updating the metadata object
|
|
599
|
+
* @param {Object} params.metadataObject - The existing UMMG CMR metadata object to update
|
|
600
|
+
* @param {ApiFileWithFilePath[]} params.files - Array of file
|
|
601
|
+
* objects used to generate URLs
|
|
602
|
+
* @param {string} params.distEndpoint - Base URL for distribution endpoints (e.g., CloudFront)
|
|
603
|
+
* @param {{ [bucket: string]: string }} params.bucketTypes - Map of bucket names
|
|
604
|
+
* to types (e.g., public, protected)
|
|
605
|
+
* @param {string} [params.cmrGranuleUrlType='both'] - Type of URLs to generate: 'distribution',
|
|
606
|
+
* 's3', or 'both'
|
|
607
|
+
* @param {DistributionBucketMap} params.distributionBucketMap - Mapping of bucket names to
|
|
608
|
+
* distribution paths
|
|
609
|
+
*
|
|
610
|
+
* @returns {Object} - A deep clone of the original metadata object with updated RelatedUrls
|
|
358
611
|
*/
|
|
359
|
-
export function
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
612
|
+
export function updateUMMGMetadataObject({ metadataObject, files, distEndpoint, bucketTypes, cmrGranuleUrlType, distributionBucketMap, }: {
|
|
613
|
+
metadataObject: Object;
|
|
614
|
+
files: ApiFileWithFilePath[];
|
|
615
|
+
distEndpoint: string;
|
|
616
|
+
bucketTypes: {
|
|
617
|
+
[bucket: string]: string;
|
|
618
|
+
};
|
|
619
|
+
cmrGranuleUrlType?: string | undefined;
|
|
620
|
+
distributionBucketMap: DistributionBucketMap;
|
|
621
|
+
}): Object;
|
|
363
622
|
/**
|
|
364
623
|
* Updates CMR xml file with 'xml' string
|
|
365
624
|
*
|
|
@@ -372,8 +631,12 @@ export function uploadEcho10CMRFile(xml: string, cmrFile: Object): Promise<any>;
|
|
|
372
631
|
* Updates CMR JSON file with stringified 'metadataObject'
|
|
373
632
|
*
|
|
374
633
|
* @param {Object} metadataObject - JSON Object to stringify
|
|
375
|
-
* @param {
|
|
376
|
-
* @returns {Promise} returns promised
|
|
634
|
+
* @param {CmrFile} cmrFile - cmr file object to write body to
|
|
635
|
+
* @returns {Promise<{[key: string]: any, ETag?: string | undefined }>} returns promised
|
|
636
|
+
* promiseS3Upload response
|
|
377
637
|
*/
|
|
378
|
-
export function uploadUMMGJSONCMRFile(metadataObject: Object, cmrFile:
|
|
638
|
+
export function uploadUMMGJSONCMRFile(metadataObject: Object, cmrFile: CmrFile): Promise<{
|
|
639
|
+
[key: string]: any;
|
|
640
|
+
ETag?: string | undefined;
|
|
641
|
+
}>;
|
|
379
642
|
//# sourceMappingURL=cmr-utils.d.ts.map
|
package/cmr-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmr-utils.d.ts","sourceRoot":"","sources":["src/cmr-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cmr-utils.d.ts","sourceRoot":"","sources":["src/cmr-utils.js"],"names":[],"mappings":";;;;SAqjBc,MAAM;;;;oBACN,MAAM;;;;iBACN,MAAM;;;;UACN,MAAM;;mCA7gBP,OAAO,yBAAyB,EAAE,oBAAoB;oCACtD,OAAO,wCAAwC,EAAE,qBAAqB;uCACtE,OAAO,gBAAgB,EAAE,wBAAwB;kCAChD,wBAAwB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;YAKhD,MAAM;;;;SACN,MAAM;;;;eACN,MAAM;;;;;;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