@cumulus/cmrjs 20.3.0 → 21.0.0-echo10
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 +69 -0
- package/echo10Modifiers.js.map +1 -0
- package/package.json +12 -12
- package/src/cmr-utils.js +333 -125
- package/src/echo10Modifiers.ts +91 -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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare type UMMGGranule = {
|
|
2
|
+
GranuleUR: string;
|
|
3
|
+
DataGranule?: {
|
|
4
|
+
Identifiers?: {
|
|
5
|
+
Identifier: string;
|
|
6
|
+
IdentifierType: string;
|
|
7
|
+
IdentifierName?: string;
|
|
8
|
+
}[];
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Updates a UMM-G metadata object with a new GranuleUR and ProducerGranuleId.
|
|
15
|
+
*
|
|
16
|
+
* This function:
|
|
17
|
+
* - Validates that the input is a valid UMM-G granule metadata object.
|
|
18
|
+
* - Performs a deep clone to preserve the original input.
|
|
19
|
+
* - Sets the GranuleUR to the specified value.
|
|
20
|
+
* - Ensures that the DataGranule.Identifiers array exists.
|
|
21
|
+
* - Adds or updates an entry of type "ProducerGranuleId" with the provided identifier.
|
|
22
|
+
*
|
|
23
|
+
* @param metadataObject - The parsed UMM-G metadata object to be modified.
|
|
24
|
+
* @param granuleUr - The new GranuleUR value to assign.
|
|
25
|
+
* @param producerGranuleId - The ProducerGranuleId to store in the Identifiers list.
|
|
26
|
+
* @returns A deep-cloned and updated copy of the UMM-G metadata object.
|
|
27
|
+
* @throws If the input does not match the expected UMM-G granule structure.
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateUMMGGranuleURAndGranuleIdentifier({ metadataObject, granuleUr, producerGranuleId, }: {
|
|
30
|
+
metadataObject: unknown;
|
|
31
|
+
granuleUr: string;
|
|
32
|
+
producerGranuleId: string;
|
|
33
|
+
}): UMMGGranule;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=ummgModifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ummgModifiers.d.ts","sourceRoot":"","sources":["src/ummgModifiers.ts"],"names":[],"mappings":"AACA,aAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE;YACZ,UAAU,EAAE,MAAM,CAAC;YACnB,cAAc,EAAE,MAAM,CAAC;YACvB,cAAc,CAAC,EAAE,MAAM,CAAC;SACzB,EAAE,CAAC;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAMF;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,uCAAuC,CAAC,EACtD,cAAc,EACd,SAAS,EACT,iBAAiB,GAClB,EAAE;IACD,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,GAAG,WAAW,CA2Bd"}
|
package/ummgModifiers.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateUMMGGranuleURAndGranuleIdentifier = void 0;
|
|
4
|
+
function isUMMGGranule(obj) {
|
|
5
|
+
return typeof obj === 'object' && obj !== null && typeof obj.GranuleUR === 'string';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Updates a UMM-G metadata object with a new GranuleUR and ProducerGranuleId.
|
|
9
|
+
*
|
|
10
|
+
* This function:
|
|
11
|
+
* - Validates that the input is a valid UMM-G granule metadata object.
|
|
12
|
+
* - Performs a deep clone to preserve the original input.
|
|
13
|
+
* - Sets the GranuleUR to the specified value.
|
|
14
|
+
* - Ensures that the DataGranule.Identifiers array exists.
|
|
15
|
+
* - Adds or updates an entry of type "ProducerGranuleId" with the provided identifier.
|
|
16
|
+
*
|
|
17
|
+
* @param metadataObject - The parsed UMM-G metadata object to be modified.
|
|
18
|
+
* @param granuleUr - The new GranuleUR value to assign.
|
|
19
|
+
* @param producerGranuleId - The ProducerGranuleId to store in the Identifiers list.
|
|
20
|
+
* @returns A deep-cloned and updated copy of the UMM-G metadata object.
|
|
21
|
+
* @throws If the input does not match the expected UMM-G granule structure.
|
|
22
|
+
*/
|
|
23
|
+
function updateUMMGGranuleURAndGranuleIdentifier({ metadataObject, granuleUr, producerGranuleId, }) {
|
|
24
|
+
if (!isUMMGGranule(metadataObject)) {
|
|
25
|
+
throw new Error('Invalid UMM-G JSON metadata');
|
|
26
|
+
}
|
|
27
|
+
const moddedJson = structuredClone(metadataObject);
|
|
28
|
+
moddedJson.GranuleUR = granuleUr;
|
|
29
|
+
moddedJson.DataGranule ??= {};
|
|
30
|
+
moddedJson.DataGranule.Identifiers ??= [];
|
|
31
|
+
const producerIndex = moddedJson.DataGranule.Identifiers.findIndex((id) => id.IdentifierType === 'ProducerGranuleId');
|
|
32
|
+
const producerGranuleIdIdentifier = {
|
|
33
|
+
Identifier: producerGranuleId,
|
|
34
|
+
IdentifierType: 'ProducerGranuleId',
|
|
35
|
+
};
|
|
36
|
+
if (producerIndex !== -1) {
|
|
37
|
+
moddedJson.DataGranule.Identifiers[producerIndex] = producerGranuleIdIdentifier;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
moddedJson.DataGranule.Identifiers.push(producerGranuleIdIdentifier);
|
|
41
|
+
}
|
|
42
|
+
return moddedJson;
|
|
43
|
+
}
|
|
44
|
+
exports.updateUMMGGranuleURAndGranuleIdentifier = updateUMMGGranuleURAndGranuleIdentifier;
|
|
45
|
+
//# sourceMappingURL=ummgModifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ummgModifiers.js","sourceRoot":"","sources":["src/ummgModifiers.ts"],"names":[],"mappings":";;;AAcA,SAAS,aAAa,CAAC,GAAQ;IAC7B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AAEH,SAAgB,uCAAuC,CAAC,EACtD,cAAc,EACd,SAAS,EACT,iBAAiB,GAKlB;IACC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,MAAM,UAAU,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEnD,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;IACjC,UAAU,CAAC,WAAW,KAAK,EAAE,CAAC;IAC9B,UAAU,CAAC,WAAW,CAAC,WAAW,KAAK,EAAE,CAAC;IAE1C,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAChE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,KAAK,mBAAmB,CAClD,CAAC;IAEF,MAAM,2BAA2B,GAAG;QAClC,UAAU,EAAE,iBAAiB;QAC7B,cAAc,EAAE,mBAAmB;KACpC,CAAC;IAEF,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;QACxB,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,2BAA2B,CAAC;KACjF;SAAM;QACL,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;KACtE;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAnCD,0FAmCC"}
|