@cumulus/message 10.1.2 → 11.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/Collections.d.ts +3 -0
- package/Collections.d.ts.map +1 -1
- package/Collections.js +7 -5
- package/Collections.js.map +1 -1
- package/Executions.d.ts +19 -4
- package/Executions.d.ts.map +1 -1
- package/Executions.js +51 -3
- package/Executions.js.map +1 -1
- package/Granules.d.ts +76 -10
- package/Granules.d.ts.map +1 -1
- package/Granules.js +141 -2
- package/Granules.js.map +1 -1
- package/PDRs.d.ts +18 -12
- package/PDRs.d.ts.map +1 -1
- package/PDRs.js +73 -4
- package/PDRs.js.map +1 -1
- package/README.md +132 -28
- package/package.json +7 -7
- package/src/Collections.ts +4 -1
- package/src/Executions.ts +77 -7
- package/src/Granules.ts +218 -3
- package/src/PDRs.ts +99 -13
- package/src/types.ts +5 -0
- package/src/utils.ts +17 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types.d.ts +4 -0
- package/types.d.ts.map +1 -1
- package/utils.d.ts +8 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +26 -0
- package/utils.js.map +1 -0
package/Collections.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Message } from '@cumulus/types';
|
|
2
|
+
export declare const collectionIdSeparator = "___";
|
|
2
3
|
/**
|
|
3
4
|
* Utility functions for generating collection information or parsing collection information
|
|
4
5
|
* from a Cumulus message
|
|
@@ -28,6 +29,8 @@ export declare const constructCollectionId: (name: string, version: string) => s
|
|
|
28
29
|
*
|
|
29
30
|
* @param {string} collectionId - collectionId used in elasticsearch index
|
|
30
31
|
* @returns {Object} name and version as object
|
|
32
|
+
*
|
|
33
|
+
* @alias module:Collections
|
|
31
34
|
*/
|
|
32
35
|
export declare const deconstructCollectionId: (collectionId: string) => {
|
|
33
36
|
name: string;
|
package/Collections.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collections.d.ts","sourceRoot":"","sources":["src/Collections.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Collections.d.ts","sourceRoot":"","sources":["src/Collections.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;;;;;;GAQG;AAEH,aAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,SAAU,MAAM,WAAW,MAAM,WACtB,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,iBAAkB,MAAM;;;CAiB3D,CAAC;AA4BF;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,YACxC,QAAQ,cAAc,KAC9B,cAAc,GAAG,SAUnB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,YAC5B,QAAQ,cAAc,KAC9B,MAAM,GAAG,SAOX,CAAC"}
|
package/Collections.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCollectionIdFromMessage = exports.getCollectionNameAndVersionFromMessage = exports.deconstructCollectionId = exports.constructCollectionId = void 0;
|
|
4
|
-
|
|
3
|
+
exports.getCollectionIdFromMessage = exports.getCollectionNameAndVersionFromMessage = exports.deconstructCollectionId = exports.constructCollectionId = exports.collectionIdSeparator = void 0;
|
|
4
|
+
exports.collectionIdSeparator = '___';
|
|
5
5
|
/**
|
|
6
6
|
* Returns the collection ID.
|
|
7
7
|
*
|
|
@@ -11,7 +11,7 @@ const collectionIdSeparator = '___';
|
|
|
11
11
|
*
|
|
12
12
|
* @alias module:Collections
|
|
13
13
|
*/
|
|
14
|
-
const constructCollectionId = (name, version) => `${name}${collectionIdSeparator}${version}`;
|
|
14
|
+
const constructCollectionId = (name, version) => `${name}${exports.collectionIdSeparator}${version}`;
|
|
15
15
|
exports.constructCollectionId = constructCollectionId;
|
|
16
16
|
/**
|
|
17
17
|
* Returns the name and version of a collection based on
|
|
@@ -19,14 +19,16 @@ exports.constructCollectionId = constructCollectionId;
|
|
|
19
19
|
*
|
|
20
20
|
* @param {string} collectionId - collectionId used in elasticsearch index
|
|
21
21
|
* @returns {Object} name and version as object
|
|
22
|
+
*
|
|
23
|
+
* @alias module:Collections
|
|
22
24
|
*/
|
|
23
25
|
const deconstructCollectionId = (collectionId) => {
|
|
24
26
|
let name;
|
|
25
27
|
let version;
|
|
26
28
|
try {
|
|
27
|
-
const last = collectionId.lastIndexOf(collectionIdSeparator);
|
|
29
|
+
const last = collectionId.lastIndexOf(exports.collectionIdSeparator);
|
|
28
30
|
name = collectionId.substring(0, last);
|
|
29
|
-
version = collectionId.substring(last + collectionIdSeparator.length);
|
|
31
|
+
version = collectionId.substring(last + exports.collectionIdSeparator.length);
|
|
30
32
|
if (name && version) {
|
|
31
33
|
return {
|
|
32
34
|
name,
|
package/Collections.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collections.js","sourceRoot":"","sources":["src/Collections.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"Collections.js","sourceRoot":"","sources":["src/Collections.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIA,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAiB3C;;;;;;;;GAQG;AACI,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CACrE,GAAG,IAAI,GAAG,6BAAqB,GAAG,OAAO,EAAE,CAAC;AADjC,QAAA,qBAAqB,yBACY;AAE9C;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAAG,CA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W,QAAA,sCAAsC,0CAYjD;AAEF;;;;;;;;;GASG;AACI,MAAM,0BAA0B,GAAG,CACxC,OAA+B,EACX,EAAE;IACtB,MAAM,cAAc,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,iBAAiB,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,CAAC,cAAc,IAAI,CAAC,iBAAiB,EAAE;QACzC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAA,6BAAqB,EAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAClE,CAAC,CAAC;AATW,QAAA,0BAA0B,8BASrC"}
|
package/Executions.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Message } from '@cumulus/types';
|
|
2
|
+
import { ExecutionRecord } from '@cumulus/types/api/executions';
|
|
3
|
+
interface MessageWithPayload extends Message.CumulusMessage {
|
|
4
|
+
payload: object;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Build execution ARN from a state machine ARN and execution name
|
|
4
8
|
*
|
|
@@ -77,19 +81,30 @@ export declare const getMessageCumulusVersion: (message: Message.CumulusMessage)
|
|
|
77
81
|
/**
|
|
78
82
|
* Get the workflow original payload, if any.
|
|
79
83
|
*
|
|
80
|
-
* @param {
|
|
84
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
81
85
|
* @returns {unknown|undefined} The workflow original payload
|
|
82
86
|
*
|
|
83
87
|
* @alias module:Executions
|
|
84
88
|
*/
|
|
85
|
-
export declare const getMessageExecutionOriginalPayload: (message:
|
|
89
|
+
export declare const getMessageExecutionOriginalPayload: (message: MessageWithPayload) => object | undefined;
|
|
86
90
|
/**
|
|
87
91
|
* Get the workflow final payload, if any.
|
|
88
92
|
*
|
|
89
|
-
* @param {
|
|
93
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
90
94
|
* @returns {unknown|undefined} The workflow final payload
|
|
91
95
|
*
|
|
92
96
|
* @alias module:Executions
|
|
93
97
|
*/
|
|
94
|
-
export declare const getMessageExecutionFinalPayload: (message:
|
|
98
|
+
export declare const getMessageExecutionFinalPayload: (message: MessageWithPayload) => object | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Generate an execution record for the API from the message.
|
|
101
|
+
*
|
|
102
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
103
|
+
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
104
|
+
* @returns {ExecutionRecord} An execution API record
|
|
105
|
+
*
|
|
106
|
+
* @alias module:Executions
|
|
107
|
+
*/
|
|
108
|
+
export declare const generateExecutionApiRecordFromMessage: (message: MessageWithPayload, updatedAt?: number) => ExecutionRecord;
|
|
109
|
+
export {};
|
|
95
110
|
//# sourceMappingURL=Executions.d.ts.map
|
package/Executions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Executions.d.ts","sourceRoot":"","sources":["src/Executions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Executions.d.ts","sourceRoot":"","sources":["src/Executions.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAkBhE,UAAU,kBAAmB,SAAQ,OAAO,CAAC,cAAc;IACzD,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBACX,MAAM,iBACR,MAAM,kBAOtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,iBAAkB,MAAM,WAI1D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,iBAC/B,MAAM,kBAMrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,YACzB,QAAQ,cAAc,WAOhC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,YAC3B,QAAQ,cAAc,WAOhC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,YACxB,QAAQ,cAAc,kBAUhC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,YAC9B,QAAQ,cAAc,KAC9B,MAAM,GAAG,SAAqD,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,YAC1B,QAAQ,cAAc,KAC9B,MAAM,GAAG,SAAkD,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,YACpC,kBAAkB,uBAI5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,YACjC,kBAAkB,uBAI5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qCAAqC,YACvC,kBAAkB,yBAE1B,eAkCF,CAAC"}
|
package/Executions.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getMessageExecutionFinalPayload = exports.getMessageExecutionOriginalPayload = exports.getMessageCumulusVersion = exports.getMessageExecutionParentArn = exports.getMessageExecutionArn = exports.getMessageStateMachineArn = exports.getMessageExecutionName = exports.getStateMachineArnFromExecutionArn = exports.getExecutionUrlFromArn = exports.buildExecutionArn = void 0;
|
|
6
|
+
exports.generateExecutionApiRecordFromMessage = exports.getMessageExecutionFinalPayload = exports.getMessageExecutionOriginalPayload = exports.getMessageCumulusVersion = exports.getMessageExecutionParentArn = exports.getMessageExecutionArn = exports.getMessageStateMachineArn = exports.getMessageExecutionName = exports.getStateMachineArnFromExecutionArn = exports.getExecutionUrlFromArn = exports.buildExecutionArn = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Utility functions for generating execution information or parsing execution information
|
|
9
9
|
* from a Cumulus message
|
|
@@ -14,7 +14,12 @@ exports.getMessageExecutionFinalPayload = exports.getMessageExecutionOriginalPay
|
|
|
14
14
|
* const Executions = require('@cumulus/message/Executions');
|
|
15
15
|
*/
|
|
16
16
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
17
|
+
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
18
|
+
const omitBy_1 = __importDefault(require("lodash/omitBy"));
|
|
19
|
+
const AsyncOperations_1 = require("./AsyncOperations");
|
|
20
|
+
const Collections_1 = require("./Collections");
|
|
17
21
|
const workflows_1 = require("./workflows");
|
|
22
|
+
const utils_1 = require("./utils");
|
|
18
23
|
/**
|
|
19
24
|
* Build execution ARN from a state machine ARN and execution name
|
|
20
25
|
*
|
|
@@ -135,7 +140,7 @@ exports.getMessageCumulusVersion = getMessageCumulusVersion;
|
|
|
135
140
|
/**
|
|
136
141
|
* Get the workflow original payload, if any.
|
|
137
142
|
*
|
|
138
|
-
* @param {
|
|
143
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
139
144
|
* @returns {unknown|undefined} The workflow original payload
|
|
140
145
|
*
|
|
141
146
|
* @alias module:Executions
|
|
@@ -148,7 +153,7 @@ exports.getMessageExecutionOriginalPayload = getMessageExecutionOriginalPayload;
|
|
|
148
153
|
/**
|
|
149
154
|
* Get the workflow final payload, if any.
|
|
150
155
|
*
|
|
151
|
-
* @param {
|
|
156
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
152
157
|
* @returns {unknown|undefined} The workflow final payload
|
|
153
158
|
*
|
|
154
159
|
* @alias module:Executions
|
|
@@ -158,4 +163,47 @@ const getMessageExecutionFinalPayload = (message) => {
|
|
|
158
163
|
return status === 'running' ? undefined : message.payload;
|
|
159
164
|
};
|
|
160
165
|
exports.getMessageExecutionFinalPayload = getMessageExecutionFinalPayload;
|
|
166
|
+
/**
|
|
167
|
+
* Generate an execution record for the API from the message.
|
|
168
|
+
*
|
|
169
|
+
* @param {MessageWithPayload} message - A workflow message object
|
|
170
|
+
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
171
|
+
* @returns {ExecutionRecord} An execution API record
|
|
172
|
+
*
|
|
173
|
+
* @alias module:Executions
|
|
174
|
+
*/
|
|
175
|
+
const generateExecutionApiRecordFromMessage = (message, updatedAt = Date.now()) => {
|
|
176
|
+
const arn = (0, exports.getMessageExecutionArn)(message);
|
|
177
|
+
if ((0, isNil_1.default)(arn))
|
|
178
|
+
throw new Error('Unable to determine execution ARN from Cumulus message');
|
|
179
|
+
const status = (0, workflows_1.getMetaStatus)(message);
|
|
180
|
+
if (!status)
|
|
181
|
+
throw new Error('Unable to determine status from Cumulus message');
|
|
182
|
+
const now = Date.now();
|
|
183
|
+
const workflowStartTime = (0, workflows_1.getMessageWorkflowStartTime)(message);
|
|
184
|
+
const workflowStopTime = (0, workflows_1.getMessageWorkflowStopTime)(message);
|
|
185
|
+
const collectionId = (0, Collections_1.getCollectionIdFromMessage)(message);
|
|
186
|
+
const record = {
|
|
187
|
+
name: (0, exports.getMessageExecutionName)(message),
|
|
188
|
+
cumulusVersion: (0, exports.getMessageCumulusVersion)(message),
|
|
189
|
+
arn,
|
|
190
|
+
asyncOperationId: (0, AsyncOperations_1.getMessageAsyncOperationId)(message),
|
|
191
|
+
parentArn: (0, exports.getMessageExecutionParentArn)(message),
|
|
192
|
+
execution: (0, exports.getExecutionUrlFromArn)(arn),
|
|
193
|
+
tasks: (0, workflows_1.getMessageWorkflowTasks)(message),
|
|
194
|
+
error: (0, utils_1.parseException)(message.exception),
|
|
195
|
+
type: (0, workflows_1.getMessageWorkflowName)(message),
|
|
196
|
+
collectionId,
|
|
197
|
+
status,
|
|
198
|
+
createdAt: workflowStartTime,
|
|
199
|
+
timestamp: now,
|
|
200
|
+
updatedAt,
|
|
201
|
+
originalPayload: (0, exports.getMessageExecutionOriginalPayload)(message),
|
|
202
|
+
finalPayload: (0, exports.getMessageExecutionFinalPayload)(message),
|
|
203
|
+
duration: (0, workflows_1.getWorkflowDuration)(workflowStartTime, workflowStopTime),
|
|
204
|
+
};
|
|
205
|
+
const updated = (0, omitBy_1.default)(record, isNil_1.default);
|
|
206
|
+
return updated;
|
|
207
|
+
};
|
|
208
|
+
exports.generateExecutionApiRecordFromMessage = generateExecutionApiRecordFromMessage;
|
|
161
209
|
//# sourceMappingURL=Executions.js.map
|
package/Executions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Executions.js","sourceRoot":"","sources":["src/Executions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;;GAQG;AAEH,+DAAuC;
|
|
1
|
+
{"version":3,"file":"Executions.js","sourceRoot":"","sources":["src/Executions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;;;GAQG;AAEH,+DAAuC;AACvC,yDAAiC;AACjC,2DAAmC;AAKnC,uDAE2B;AAC3B,+CAEuB;AACvB,2CAOqB;AACrB,mCAAyC;AAMzC;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAC/B,eAAuB,EACvB,aAAqB,EACrB,EAAE;IACF,IAAI,eAAe,IAAI,aAAa,EAAE;QACpC,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACnE,OAAO,GAAG,KAAK,IAAI,aAAa,EAAE,CAAC;KACpC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B;AAEF;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAC;IAC7D,OAAO,qDAAqD,MAAM,EAAE;UAC3D,wBAAwB,YAAY,EAAE,CAAC;AAClD,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF;;;;;;;GAOG;AACI,MAAM,kCAAkC,GAAG,CAChD,YAAoB,EACpB,EAAE;I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ions for parsing granule information from a Cumulus message
|
|
3
|
-
* @module Granules
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* const Granules = require('@cumulus/message/Granules');
|
|
7
|
-
*/
|
|
8
1
|
import { Message } from '@cumulus/types';
|
|
9
|
-
import {
|
|
2
|
+
import { ExecutionProcessingTimes } from '@cumulus/types/api/executions';
|
|
3
|
+
import { ApiGranule, GranuleStatus, GranuleTemporalInfo, MessageGranule } from '@cumulus/types/api/granules';
|
|
4
|
+
import { ApiFile } from '@cumulus/types/api/files';
|
|
5
|
+
import { CmrUtilsClass } from './types';
|
|
10
6
|
interface MetaWithGranuleQueryFields extends Message.Meta {
|
|
11
7
|
granule?: {
|
|
12
8
|
queryFields?: unknown;
|
|
@@ -41,12 +37,12 @@ export declare const messageHasGranules: (message: MessageWithGranules) => boole
|
|
|
41
37
|
* Determine the status of a granule.
|
|
42
38
|
*
|
|
43
39
|
* @param {string} workflowStatus - The workflow status
|
|
44
|
-
* @param {
|
|
40
|
+
* @param {MessageGranule} granule - A granule record conforming to the 'api' schema
|
|
45
41
|
* @returns {string} The granule status
|
|
46
42
|
*
|
|
47
43
|
* @alias module:Granules
|
|
48
44
|
*/
|
|
49
|
-
export declare const getGranuleStatus: (workflowStatus: Message.WorkflowStatus, granule:
|
|
45
|
+
export declare const getGranuleStatus: (workflowStatus: Message.WorkflowStatus, granule: MessageGranule) => Message.WorkflowStatus | GranuleStatus;
|
|
50
46
|
/**
|
|
51
47
|
* Get the query fields of a granule, if any
|
|
52
48
|
*
|
|
@@ -56,5 +52,75 @@ export declare const getGranuleStatus: (workflowStatus: Message.WorkflowStatus,
|
|
|
56
52
|
* @alias module:Granules
|
|
57
53
|
*/
|
|
58
54
|
export declare const getGranuleQueryFields: (message: MessageWithGranules) => unknown;
|
|
55
|
+
/**
|
|
56
|
+
* Calculate granule product volume, which is the sum of the file
|
|
57
|
+
* sizes in bytes
|
|
58
|
+
*
|
|
59
|
+
* @param {Array<Object>} granuleFiles - array of granule file objects that conform to the
|
|
60
|
+
* Cumulus 'api' schema
|
|
61
|
+
* @returns {string} - sum of granule file sizes in bytes as a string
|
|
62
|
+
*/
|
|
63
|
+
export declare const getGranuleProductVolume: (granuleFiles?: ApiFile[]) => string;
|
|
64
|
+
export declare const getGranuleTimeToPreprocess: ({ sync_granule_duration, }?: {
|
|
65
|
+
sync_granule_duration?: number | undefined;
|
|
66
|
+
}) => number;
|
|
67
|
+
export declare const getGranuleTimeToArchive: ({ post_to_cmr_duration, }?: {
|
|
68
|
+
post_to_cmr_duration?: number | undefined;
|
|
69
|
+
}) => number;
|
|
70
|
+
/**
|
|
71
|
+
* Convert granule processing timestamps to a standardized ISO string
|
|
72
|
+
* format for compatibility across database systems.
|
|
73
|
+
*
|
|
74
|
+
* @param {ExecutionProcessingTimes} [processingTimeInfo]
|
|
75
|
+
* Granule processing time info, if any
|
|
76
|
+
* @returns {Promise<ExecutionProcessingTimes | undefined>}
|
|
77
|
+
*/
|
|
78
|
+
export declare const getGranuleProcessingTimeInfo: (processingTimeInfo?: ExecutionProcessingTimes | undefined) => ExecutionProcessingTimes | {};
|
|
79
|
+
/**
|
|
80
|
+
* Get granule temporal information from argument or directly from CMR.
|
|
81
|
+
*
|
|
82
|
+
* Converts temporal information timestamps to a standardized ISO string
|
|
83
|
+
* format for compatibility across database systems.
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} params
|
|
86
|
+
* @param {MessageGranule} params.granule - Granule from workflow message
|
|
87
|
+
* @param {Object} [params.cmrTemporalInfo] - CMR temporal info, if any
|
|
88
|
+
* @param {CmrUtilsClass} params.cmrUtils - CMR utilities object
|
|
89
|
+
* @returns {Promise<GranuleTemporalInfo | undefined>}
|
|
90
|
+
*/
|
|
91
|
+
export declare const getGranuleCmrTemporalInfo: ({ granule, cmrTemporalInfo, cmrUtils, }: {
|
|
92
|
+
granule: MessageGranule;
|
|
93
|
+
cmrTemporalInfo?: GranuleTemporalInfo | undefined;
|
|
94
|
+
cmrUtils: CmrUtilsClass;
|
|
95
|
+
}) => Promise<GranuleTemporalInfo | {}>;
|
|
96
|
+
/**
|
|
97
|
+
* Generate an API granule record
|
|
98
|
+
*
|
|
99
|
+
* @param {MessageWithGranules} message - A workflow message
|
|
100
|
+
* @returns {Promise<ApiGranule>} The granule API record
|
|
101
|
+
*
|
|
102
|
+
* @alias module:Granules
|
|
103
|
+
*/
|
|
104
|
+
export declare const generateGranuleApiRecord: ({ granule, executionUrl, collectionId, provider, workflowStartTime, error, pdrName, status, queryFields, updatedAt, files, processingTimeInfo, cmrUtils, timestamp, duration, productVolume, timeToPreprocess, timeToArchive, cmrTemporalInfo, }: {
|
|
105
|
+
granule: MessageGranule;
|
|
106
|
+
executionUrl?: string | undefined;
|
|
107
|
+
collectionId: string;
|
|
108
|
+
provider?: string | undefined;
|
|
109
|
+
workflowStartTime: number;
|
|
110
|
+
error?: Object | undefined;
|
|
111
|
+
pdrName?: string | undefined;
|
|
112
|
+
status: GranuleStatus;
|
|
113
|
+
queryFields?: Object | undefined;
|
|
114
|
+
updatedAt: number;
|
|
115
|
+
processingTimeInfo?: ExecutionProcessingTimes | undefined;
|
|
116
|
+
files?: ApiFile[] | undefined;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
cmrUtils: CmrUtilsClass;
|
|
119
|
+
cmrTemporalInfo?: GranuleTemporalInfo | undefined;
|
|
120
|
+
duration: number;
|
|
121
|
+
productVolume: string;
|
|
122
|
+
timeToPreprocess: number;
|
|
123
|
+
timeToArchive: number;
|
|
124
|
+
}) => Promise<ApiGranule>;
|
|
59
125
|
export {};
|
|
60
126
|
//# sourceMappingURL=Granules.d.ts.map
|
package/Granules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Granules.d.ts","sourceRoot":"","sources":["src/Granules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Granules.d.ts","sourceRoot":"","sources":["src/Granules.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,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,mBAAmB,GAAG,EAAE,CAUnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB;aAqB1B,cAAc;;kBAET,MAAM;;uBAED,MAAM;;;YAGjB,aAAa;;eAEV,MAAM;;;eAGN,MAAM;cACP,aAAa;;cAEb,MAAM;mBACD,MAAM;sBACH,MAAM;mBACT,MAAM;MACnB,QAAQ,UAAU,CAkDrB,CAAC"}
|
package/Granules.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGranuleQueryFields = exports.getGranuleStatus = exports.messageHasGranules = exports.getMessageGranules = void 0;
|
|
6
|
+
exports.generateGranuleApiRecord = exports.getGranuleCmrTemporalInfo = exports.getGranuleProcessingTimeInfo = exports.getGranuleTimeToArchive = exports.getGranuleTimeToPreprocess = exports.getGranuleProductVolume = exports.getGranuleQueryFields = exports.getGranuleStatus = exports.messageHasGranules = exports.getMessageGranules = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Utility functions for parsing granule information from a Cumulus message
|
|
9
|
+
* @module Granules
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const Granules = require('@cumulus/message/Granules');
|
|
13
|
+
*/
|
|
14
|
+
const isInteger_1 = __importDefault(require("lodash/isInteger"));
|
|
15
|
+
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
16
|
+
const mapValues_1 = __importDefault(require("lodash/mapValues"));
|
|
17
|
+
const omitBy_1 = __importDefault(require("lodash/omitBy"));
|
|
18
|
+
const errors_1 = require("@cumulus/errors");
|
|
4
19
|
/**
|
|
5
20
|
* Get granules from payload?.granules of a workflow message.
|
|
6
21
|
*
|
|
@@ -26,7 +41,7 @@ exports.messageHasGranules = messageHasGranules;
|
|
|
26
41
|
* Determine the status of a granule.
|
|
27
42
|
*
|
|
28
43
|
* @param {string} workflowStatus - The workflow status
|
|
29
|
-
* @param {
|
|
44
|
+
* @param {MessageGranule} granule - A granule record conforming to the 'api' schema
|
|
30
45
|
* @returns {string} The granule status
|
|
31
46
|
*
|
|
32
47
|
* @alias module:Granules
|
|
@@ -43,4 +58,128 @@ exports.getGranuleStatus = getGranuleStatus;
|
|
|
43
58
|
*/
|
|
44
59
|
const getGranuleQueryFields = (message) => { var _a, _b; return (_b = (_a = message.meta) === null || _a === void 0 ? void 0 : _a.granule) === null || _b === void 0 ? void 0 : _b.queryFields; };
|
|
45
60
|
exports.getGranuleQueryFields = getGranuleQueryFields;
|
|
61
|
+
/**
|
|
62
|
+
* Calculate granule product volume, which is the sum of the file
|
|
63
|
+
* sizes in bytes
|
|
64
|
+
*
|
|
65
|
+
* @param {Array<Object>} granuleFiles - array of granule file objects that conform to the
|
|
66
|
+
* Cumulus 'api' schema
|
|
67
|
+
* @returns {string} - sum of granule file sizes in bytes as a string
|
|
68
|
+
*/
|
|
69
|
+
const getGranuleProductVolume = (granuleFiles = []) => {
|
|
70
|
+
if (granuleFiles.length === 0)
|
|
71
|
+
return '0';
|
|
72
|
+
return String(granuleFiles
|
|
73
|
+
.map((f) => { var _a; return (_a = f.size) !== null && _a !== void 0 ? _a : 0; })
|
|
74
|
+
.filter(isInteger_1.default)
|
|
75
|
+
.reduce((x, y) => x + BigInt(y), BigInt(0)));
|
|
76
|
+
};
|
|
77
|
+
exports.getGranuleProductVolume = getGranuleProductVolume;
|
|
78
|
+
const getGranuleTimeToPreprocess = ({ sync_granule_duration = 0, } = {}) => sync_granule_duration / 1000;
|
|
79
|
+
exports.getGranuleTimeToPreprocess = getGranuleTimeToPreprocess;
|
|
80
|
+
const getGranuleTimeToArchive = ({ post_to_cmr_duration = 0, } = {}) => post_to_cmr_duration / 1000;
|
|
81
|
+
exports.getGranuleTimeToArchive = getGranuleTimeToArchive;
|
|
82
|
+
/**
|
|
83
|
+
* Convert date string to standard ISO format.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} date - Date string, possibly in multiple formats
|
|
86
|
+
* @returns {string} Standardized ISO date string
|
|
87
|
+
*/
|
|
88
|
+
const convertDateToISOString = (date) => new Date(date).toISOString();
|
|
89
|
+
function isProcessingTimeInfo(info = {}) {
|
|
90
|
+
return (info === null || info === void 0 ? void 0 : info.processingStartDateTime) !== undefined
|
|
91
|
+
&& (info === null || info === void 0 ? void 0 : info.processingEndDateTime) !== undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Convert granule processing timestamps to a standardized ISO string
|
|
95
|
+
* format for compatibility across database systems.
|
|
96
|
+
*
|
|
97
|
+
* @param {ExecutionProcessingTimes} [processingTimeInfo]
|
|
98
|
+
* Granule processing time info, if any
|
|
99
|
+
* @returns {Promise<ExecutionProcessingTimes | undefined>}
|
|
100
|
+
*/
|
|
101
|
+
const getGranuleProcessingTimeInfo = (processingTimeInfo) => {
|
|
102
|
+
const updatedProcessingTimeInfo = isProcessingTimeInfo(processingTimeInfo)
|
|
103
|
+
? { ...processingTimeInfo }
|
|
104
|
+
: {};
|
|
105
|
+
return (0, mapValues_1.default)(updatedProcessingTimeInfo, convertDateToISOString);
|
|
106
|
+
};
|
|
107
|
+
exports.getGranuleProcessingTimeInfo = getGranuleProcessingTimeInfo;
|
|
108
|
+
function isGranuleTemporalInfo(info = {}) {
|
|
109
|
+
return (info === null || info === void 0 ? void 0 : info.beginningDateTime) !== undefined
|
|
110
|
+
&& (info === null || info === void 0 ? void 0 : info.endingDateTime) !== undefined
|
|
111
|
+
&& (info === null || info === void 0 ? void 0 : info.productionDateTime) !== undefined
|
|
112
|
+
&& (info === null || info === void 0 ? void 0 : info.lastUpdateDateTime) !== undefined;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get granule temporal information from argument or directly from CMR.
|
|
116
|
+
*
|
|
117
|
+
* Converts temporal information timestamps to a standardized ISO string
|
|
118
|
+
* format for compatibility across database systems.
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} params
|
|
121
|
+
* @param {MessageGranule} params.granule - Granule from workflow message
|
|
122
|
+
* @param {Object} [params.cmrTemporalInfo] - CMR temporal info, if any
|
|
123
|
+
* @param {CmrUtilsClass} params.cmrUtils - CMR utilities object
|
|
124
|
+
* @returns {Promise<GranuleTemporalInfo | undefined>}
|
|
125
|
+
*/
|
|
126
|
+
const getGranuleCmrTemporalInfo = async ({ granule, cmrTemporalInfo, cmrUtils, }) => {
|
|
127
|
+
// Get CMR temporalInfo (beginningDateTime, endingDateTime,
|
|
128
|
+
// productionDateTime, lastUpdateDateTime)
|
|
129
|
+
const temporalInfo = isGranuleTemporalInfo(cmrTemporalInfo)
|
|
130
|
+
? { ...cmrTemporalInfo }
|
|
131
|
+
: await cmrUtils.getGranuleTemporalInfo(granule);
|
|
132
|
+
return (0, mapValues_1.default)(temporalInfo, convertDateToISOString);
|
|
133
|
+
};
|
|
134
|
+
exports.getGranuleCmrTemporalInfo = getGranuleCmrTemporalInfo;
|
|
135
|
+
/**
|
|
136
|
+
* Generate an API granule record
|
|
137
|
+
*
|
|
138
|
+
* @param {MessageWithGranules} message - A workflow message
|
|
139
|
+
* @returns {Promise<ApiGranule>} The granule API record
|
|
140
|
+
*
|
|
141
|
+
* @alias module:Granules
|
|
142
|
+
*/
|
|
143
|
+
const generateGranuleApiRecord = async ({ granule, executionUrl, collectionId, provider, workflowStartTime, error, pdrName, status, queryFields, updatedAt, files, processingTimeInfo, cmrUtils, timestamp, duration, productVolume, timeToPreprocess, timeToArchive, cmrTemporalInfo, }) => {
|
|
144
|
+
if (!granule.granuleId)
|
|
145
|
+
throw new errors_1.CumulusMessageError(`Could not create granule record, invalid granuleId: ${granule.granuleId}`);
|
|
146
|
+
if (!collectionId) {
|
|
147
|
+
throw new errors_1.CumulusMessageError('collectionId required to generate a granule record');
|
|
148
|
+
}
|
|
149
|
+
const { granuleId, cmrLink, published = false, createdAt, } = granule;
|
|
150
|
+
const now = Date.now();
|
|
151
|
+
const recordUpdatedAt = updatedAt !== null && updatedAt !== void 0 ? updatedAt : now;
|
|
152
|
+
const recordTimestamp = timestamp !== null && timestamp !== void 0 ? timestamp : now;
|
|
153
|
+
// Get CMR temporalInfo
|
|
154
|
+
const temporalInfo = await (0, exports.getGranuleCmrTemporalInfo)({
|
|
155
|
+
granule,
|
|
156
|
+
cmrTemporalInfo,
|
|
157
|
+
cmrUtils,
|
|
158
|
+
});
|
|
159
|
+
const updatedProcessingTimeInfo = (0, exports.getGranuleProcessingTimeInfo)(processingTimeInfo);
|
|
160
|
+
const record = {
|
|
161
|
+
granuleId,
|
|
162
|
+
pdrName,
|
|
163
|
+
collectionId,
|
|
164
|
+
status,
|
|
165
|
+
provider,
|
|
166
|
+
execution: executionUrl,
|
|
167
|
+
cmrLink,
|
|
168
|
+
files,
|
|
169
|
+
error,
|
|
170
|
+
published,
|
|
171
|
+
createdAt: createdAt || workflowStartTime,
|
|
172
|
+
timestamp: recordTimestamp,
|
|
173
|
+
updatedAt: recordUpdatedAt,
|
|
174
|
+
duration,
|
|
175
|
+
productVolume,
|
|
176
|
+
timeToPreprocess,
|
|
177
|
+
timeToArchive,
|
|
178
|
+
...updatedProcessingTimeInfo,
|
|
179
|
+
...temporalInfo,
|
|
180
|
+
queryFields,
|
|
181
|
+
};
|
|
182
|
+
return (0, omitBy_1.default)(record, isNil_1.default);
|
|
183
|
+
};
|
|
184
|
+
exports.generateGranuleApiRecord = generateGranuleApiRecord;
|
|
46
185
|
//# sourceMappingURL=Granules.js.map
|
package/Granules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Granules.js","sourceRoot":"","sources":["src/Granules.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"Granules.js","sourceRoot":"","sources":["src/Granules.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb;;;;;;GAMG;AAEH,iEA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G,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC;IACzC,MAAM,eAAe,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC;IAEzC,uBAAuB;IACvB,MAAM,YAAY,GAAG,MAAM,IAAA,iCAAyB,EAAC;QACnD,OAAO;QACP,eAAe;QACf,QAAQ;KACT,CAAC,CAAC;IACH,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC,kBAAkB,CAAC,CAAC;IAEnF,MAAM,MAAM,GAAG;QACb,SAAS;QACT,OAAO;QACP,YAAY;QACZ,MAAM;QACN,QAAQ;QACR,SAAS,EAAE,YAAY;QACvB,OAAO;QACP,KAAK;QACL,KAAK;QACL,SAAS;QACT,SAAS,EAAE,SAAS,IAAI,iBAAiB;QACzC,SAAS,EAAE,eAAe;QAC1B,SAAS,EAAE,eAAe;QAC1B,QAAQ;QACR,aAAa;QACb,gBAAgB;QAChB,aAAa;QACb,GAAG,yBAAyB;QAC5B,GAAG,YAAY;QACf,WAAW;KACZ,CAAC;IAEF,OAAmB,IAAA,gBAAM,EAAC,MAAM,EAAE,eAAK,CAAC,CAAC;AAC3C,CAAC,CAAC;AA1FW,QAAA,wBAAwB,4BA0FnC"}
|
package/PDRs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Message } from '@cumulus/types';
|
|
2
|
+
import { ApiPdr } from '@cumulus/types/api/pdrs';
|
|
2
3
|
interface PDR {
|
|
3
4
|
name: string;
|
|
4
5
|
PANSent: boolean;
|
|
@@ -7,11 +8,6 @@ interface PDR {
|
|
|
7
8
|
interface MessageWithOptionalPayloadPdr extends Message.CumulusMessage {
|
|
8
9
|
payload: {
|
|
9
10
|
pdr?: PDR;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
interface MessageWithOptionalPdrStats extends Message.CumulusMessage {
|
|
13
|
-
payload: {
|
|
14
|
-
pdr: PDR;
|
|
15
11
|
failed?: unknown[];
|
|
16
12
|
running?: unknown[];
|
|
17
13
|
completed?: unknown[];
|
|
@@ -71,30 +67,30 @@ export declare const getMessagePdrName: (message: MessageWithOptionalPayloadPdr)
|
|
|
71
67
|
/**
|
|
72
68
|
* Get the number of running executions for a PDR, if any.
|
|
73
69
|
*
|
|
74
|
-
* @param {
|
|
70
|
+
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
|
|
75
71
|
* @returns {number} Number of running executions
|
|
76
72
|
*
|
|
77
73
|
* @alias module:PDRs
|
|
78
74
|
*/
|
|
79
|
-
export declare const getMessagePdrRunningExecutions: (message:
|
|
75
|
+
export declare const getMessagePdrRunningExecutions: (message: MessageWithOptionalPayloadPdr) => number;
|
|
80
76
|
/**
|
|
81
77
|
* Get the number of completed executions for a PDR, if any.
|
|
82
78
|
*
|
|
83
|
-
* @param {
|
|
79
|
+
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
|
|
84
80
|
* @returns {number} Number of completed executions
|
|
85
81
|
*
|
|
86
82
|
* @alias module:PDRs
|
|
87
83
|
*/
|
|
88
|
-
export declare const getMessagePdrCompletedExecutions: (message:
|
|
84
|
+
export declare const getMessagePdrCompletedExecutions: (message: MessageWithOptionalPayloadPdr) => number;
|
|
89
85
|
/**
|
|
90
86
|
* Get the number of failed executions for a PDR, if any.
|
|
91
87
|
*
|
|
92
|
-
* @param {
|
|
88
|
+
* @param {MessageWithOptionalPayloadPdr} message - A workflow message
|
|
93
89
|
* @returns {number} Number of failed executions
|
|
94
90
|
*
|
|
95
91
|
* @alias module:PDRs
|
|
96
92
|
*/
|
|
97
|
-
export declare const getMessagePdrFailedExecutions: (message:
|
|
93
|
+
export declare const getMessagePdrFailedExecutions: (message: MessageWithOptionalPayloadPdr) => number;
|
|
98
94
|
/**
|
|
99
95
|
* Get the PDR stats from a workflow message, if any.
|
|
100
96
|
*
|
|
@@ -104,7 +100,7 @@ export declare const getMessagePdrFailedExecutions: (message: MessageWithOptiona
|
|
|
104
100
|
*
|
|
105
101
|
* @alias module:PDRs
|
|
106
102
|
*/
|
|
107
|
-
export declare const getMessagePdrStats: (message:
|
|
103
|
+
export declare const getMessagePdrStats: (message: MessageWithOptionalPayloadPdr) => PdrStats;
|
|
108
104
|
/**
|
|
109
105
|
* Get the percent completion of PDR executions
|
|
110
106
|
*
|
|
@@ -114,5 +110,15 @@ export declare const getMessagePdrStats: (message: MessageWithOptionalPdrStats)
|
|
|
114
110
|
* @alias module:PDRs
|
|
115
111
|
*/
|
|
116
112
|
export declare const getPdrPercentCompletion: (stats: PdrStats) => number;
|
|
113
|
+
/**
|
|
114
|
+
* Generate a PDR record for the API from the message.
|
|
115
|
+
*
|
|
116
|
+
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
|
|
117
|
+
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
118
|
+
* @returns {ExecutionRecord} An PDR API record
|
|
119
|
+
*
|
|
120
|
+
* @alias module:Executions
|
|
121
|
+
*/
|
|
122
|
+
export declare const generatePdrApiRecordFromMessage: (message: MessageWithOptionalPayloadPdr, updatedAt?: number) => ApiPdr | undefined;
|
|
117
123
|
export {};
|
|
118
124
|
//# sourceMappingURL=PDRs.d.ts.map
|
package/PDRs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PDRs.d.ts","sourceRoot":"","sources":["src/PDRs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PDRs.d.ts","sourceRoot":"","sources":["src/PDRs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAkBjD,UAAU,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,6BAA8B,SAAQ,OAAO,CAAC,cAAc;IACpE,OAAO,EAAE;QACP,GAAG,CAAC,EAAE,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