@cumulus/cmrjs 21.1.0 → 21.2.1
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 +14 -5
- package/cmr-utils.d.ts.map +1 -1
- package/cmr-utils.js +14 -5
- package/cmr-utils.js.map +1 -1
- package/echo10Modifiers.d.ts +4 -1
- package/echo10Modifiers.d.ts.map +1 -1
- package/echo10Modifiers.js +37 -2
- package/echo10Modifiers.js.map +1 -1
- package/package.json +12 -12
- package/src/cmr-utils.js +14 -2
- package/src/echo10Modifiers.ts +46 -2
- package/src/ummgModifiers.ts +22 -13
- package/tsconfig.tsbuildinfo +1 -1
- package/ummgModifiers.d.ts +3 -1
- package/ummgModifiers.d.ts.map +1 -1
- package/ummgModifiers.js +18 -13
- package/ummgModifiers.js.map +1 -1
package/src/ummgModifiers.ts
CHANGED
|
@@ -29,6 +29,7 @@ function isUMMGGranule(obj: any): obj is UMMGGranule {
|
|
|
29
29
|
* @param metadataObject - The parsed UMM-G metadata object to be modified.
|
|
30
30
|
* @param granuleUr - The new GranuleUR value to assign.
|
|
31
31
|
* @param producerGranuleId - The ProducerGranuleId to store in the Identifiers list.
|
|
32
|
+
* @param excludeDataGranule - Whether to add or update the DataGranule node in the metadata
|
|
32
33
|
* @returns A deep-cloned and updated copy of the UMM-G metadata object.
|
|
33
34
|
* @throws If the input does not match the expected UMM-G granule structure.
|
|
34
35
|
*/
|
|
@@ -37,10 +38,12 @@ export function updateUMMGGranuleURAndGranuleIdentifier({
|
|
|
37
38
|
metadataObject,
|
|
38
39
|
granuleUr,
|
|
39
40
|
producerGranuleId,
|
|
41
|
+
excludeDataGranule = false,
|
|
40
42
|
}: {
|
|
41
43
|
metadataObject: unknown;
|
|
42
44
|
granuleUr: string;
|
|
43
45
|
producerGranuleId: string;
|
|
46
|
+
excludeDataGranule?: boolean;
|
|
44
47
|
}): UMMGGranule {
|
|
45
48
|
if (!isUMMGGranule(metadataObject)) {
|
|
46
49
|
throw new Error('Invalid UMM-G JSON metadata');
|
|
@@ -49,22 +52,28 @@ export function updateUMMGGranuleURAndGranuleIdentifier({
|
|
|
49
52
|
const moddedJson = structuredClone(metadataObject);
|
|
50
53
|
|
|
51
54
|
moddedJson.GranuleUR = granuleUr;
|
|
52
|
-
moddedJson.DataGranule ??= {};
|
|
53
|
-
moddedJson.DataGranule.Identifiers ??= [];
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
if (excludeDataGranule === false) {
|
|
57
|
+
moddedJson.DataGranule ??= {};
|
|
58
|
+
moddedJson.DataGranule.Identifiers ??= [];
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const producerIndex = moddedJson.DataGranule.Identifiers.findIndex(
|
|
61
|
+
(id) => id.IdentifierType === 'ProducerGranuleId'
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const producerGranuleIdIdentifier = {
|
|
65
|
+
Identifier: producerGranuleId,
|
|
66
|
+
IdentifierType: 'ProducerGranuleId',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (producerIndex !== -1) {
|
|
70
|
+
moddedJson.DataGranule.Identifiers[producerIndex] = producerGranuleIdIdentifier;
|
|
71
|
+
} else {
|
|
72
|
+
moddedJson.DataGranule.Identifiers.push(producerGranuleIdIdentifier);
|
|
73
|
+
}
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
moddedJson.DataGranule.
|
|
66
|
-
} else {
|
|
67
|
-
moddedJson.DataGranule.Identifiers.push(producerGranuleIdIdentifier);
|
|
75
|
+
moddedJson.DataGranule.DayNightFlag ??= 'Unspecified';
|
|
76
|
+
moddedJson.DataGranule.ProductionDateTime ??= new Date().toISOString();
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
return moddedJson;
|