@cumulus/message 18.2.2 → 18.3.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/CumulusMessage.d.ts +6 -0
- package/CumulusMessage.d.ts.map +1 -0
- package/CumulusMessage.js +10 -0
- package/CumulusMessage.js.map +1 -0
- package/DeadLetterMessage.d.ts +18 -8
- package/DeadLetterMessage.d.ts.map +1 -1
- package/DeadLetterMessage.js +130 -14
- package/DeadLetterMessage.js.map +1 -1
- package/Providers.d.ts +2 -0
- package/Providers.d.ts.map +1 -1
- package/Providers.js +12 -1
- package/Providers.js.map +1 -1
- package/README.md +50 -13
- package/StepFunctions.d.ts +13 -15
- package/StepFunctions.d.ts.map +1 -1
- package/StepFunctions.js +8 -8
- package/StepFunctions.js.map +1 -1
- package/package.json +12 -10
- package/src/CumulusMessage.ts +9 -0
- package/src/DeadLetterMessage.ts +166 -23
- package/src/Providers.ts +18 -1
- package/src/StepFunctions.ts +17 -17
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CumulusMessage.d.ts","sourceRoot":"","sources":["src/CumulusMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,oBAAoB,YAAa,GAAG,sCAGhD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCumulusMessageLike = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Bare check for CumulusMessage Shape
|
|
6
|
+
*/
|
|
7
|
+
const isCumulusMessageLike = (message) => (message instanceof Object
|
|
8
|
+
&& 'cumulus_meta' in message);
|
|
9
|
+
exports.isCumulusMessageLike = isCumulusMessageLike;
|
|
10
|
+
//# sourceMappingURL=CumulusMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CumulusMessage.js","sourceRoot":"","sources":["src/CumulusMessage.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACI,MAAM,oBAAoB,GAAG,CAAC,OAAY,EAAqC,EAAE,CAAC,CACvF,OAAO,YAAY,MAAM;OACtB,cAAc,IAAI,OAAO,CAC7B,CAAC;AAHW,QAAA,oBAAoB,wBAG/B"}
|
package/DeadLetterMessage.d.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { SQSRecord
|
|
1
|
+
import { SQSRecord } from 'aws-lambda';
|
|
2
|
+
import { StepFunctionEventBridgeEvent } from '@cumulus/aws-client/Lambda';
|
|
2
3
|
import { CumulusMessage } from '@cumulus/types/message';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { DLQRecord, DLARecord } from '@cumulus/types/api/dead_letters';
|
|
5
|
+
declare type UnwrapDeadLetterCumulusMessageInputType = (StepFunctionEventBridgeEvent | DLQRecord | SQSRecord | CumulusMessage);
|
|
6
|
+
/**
|
|
7
|
+
* Bare check for SQS message Shape
|
|
8
|
+
*/
|
|
9
|
+
export declare const isDLQRecordLike: (message: Object) => message is DLQRecord;
|
|
7
10
|
/**
|
|
8
11
|
* Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
9
12
|
* States cloudwatch event, which is wrapped in an SQS message.
|
|
13
|
+
*/
|
|
14
|
+
export declare const unwrapDeadLetterCumulusMessage: (messageBody: UnwrapDeadLetterCumulusMessageInputType) => Promise<UnwrapDeadLetterCumulusMessageInputType>;
|
|
15
|
+
/**
|
|
16
|
+
* Reformat object with key attributes at top level.
|
|
10
17
|
*
|
|
11
|
-
* @param {Object} messageBody - received SQS message
|
|
12
|
-
* @returns {Object} the cumulus message or nearest available object
|
|
13
18
|
*/
|
|
14
|
-
export declare const
|
|
19
|
+
export declare const hoistCumulusMessageDetails: (dlqRecord: SQSRecord) => Promise<DLARecord>;
|
|
20
|
+
export declare const getDLARootKey: (stackName: string) => string;
|
|
21
|
+
export declare const extractDateString: (message: DLARecord) => string;
|
|
22
|
+
export declare const extractFileName: (message: DLARecord) => string;
|
|
23
|
+
export declare const getDLAKey: (stackName: string, message: DLARecord) => string;
|
|
24
|
+
export declare const getDLAFailureKey: (stackName: string, message: DLARecord) => string;
|
|
15
25
|
export {};
|
|
16
26
|
//# sourceMappingURL=DeadLetterMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeadLetterMessage.d.ts","sourceRoot":"","sources":["src/DeadLetterMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeadLetterMessage.d.ts","sourceRoot":"","sources":["src/DeadLetterMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAsB,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAUvE,aAAK,uCAAuC,GAAG,CAC7C,4BAA4B,GAC1B,SAAS,GAAG,SAAS,GACrB,cAAc,CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,YAAa,MAAM,yBAG9C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,gBAC5B,uCAAuC,KACnD,QAAQ,uCAAuC,CA0BjD,CAAC;AAyCF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,cAAqB,SAAS,KAAG,QAAQ,SAAS,CA6DxF,CAAC;AAEF,eAAO,MAAM,aAAa,cAAe,MAAM,WAE9C,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,SAAS,KAAG,MAEtD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,SAAS,KAAG,MAIpD,CAAC;AAEF,eAAO,MAAM,SAAS,cAAe,MAAM,WAAW,SAAS,KAAG,MAIjE,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAAe,MAAM,WAAW,SAAS,KAAG,MAIxE,CAAC"}
|
package/DeadLetterMessage.js
CHANGED
|
@@ -3,40 +3,156 @@ 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.unwrapDeadLetterCumulusMessage = void 0;
|
|
6
|
+
exports.getDLAFailureKey = exports.getDLAKey = exports.extractFileName = exports.extractDateString = exports.getDLARootKey = exports.hoistCumulusMessageDetails = exports.unwrapDeadLetterCumulusMessage = exports.isDLQRecordLike = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
const uuidv4_1 = require("uuidv4");
|
|
9
|
+
const Lambda_1 = require("@cumulus/aws-client/Lambda");
|
|
7
10
|
const SQS_1 = require("@cumulus/aws-client/SQS");
|
|
8
11
|
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
12
|
+
const Providers_1 = require("./Providers");
|
|
13
|
+
const CumulusMessage_1 = require("./CumulusMessage");
|
|
9
14
|
const StepFunctions_1 = require("./StepFunctions");
|
|
15
|
+
const Collections_1 = require("./Collections");
|
|
10
16
|
const log = new logger_1.default({ sender: '@cumulus/DeadLetterMessage' });
|
|
17
|
+
/**
|
|
18
|
+
* Bare check for SQS message Shape
|
|
19
|
+
*/
|
|
20
|
+
const isDLQRecordLike = (message) => ((0, SQS_1.isSQSRecordLike)(message)
|
|
21
|
+
&& 'error' in message);
|
|
22
|
+
exports.isDLQRecordLike = isDLQRecordLike;
|
|
11
23
|
/**
|
|
12
24
|
* Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
13
25
|
* States cloudwatch event, which is wrapped in an SQS message.
|
|
14
|
-
*
|
|
15
|
-
* @param {Object} messageBody - received SQS message
|
|
16
|
-
* @returns {Object} the cumulus message or nearest available object
|
|
17
26
|
*/
|
|
18
27
|
const unwrapDeadLetterCumulusMessage = async (messageBody) => {
|
|
19
28
|
try {
|
|
20
|
-
if (
|
|
21
|
-
return messageBody;
|
|
22
|
-
}
|
|
23
|
-
if ('Body' in messageBody || 'body' in messageBody) {
|
|
29
|
+
if ((0, SQS_1.isSQSRecordLike)(messageBody)) {
|
|
24
30
|
// AWS.SQS.Message/SQS.Record case
|
|
25
31
|
const unwrappedMessageBody = (0, SQS_1.parseSQSMessageBody)(messageBody);
|
|
26
32
|
return await (0, exports.unwrapDeadLetterCumulusMessage)(unwrappedMessageBody);
|
|
27
33
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
34
|
+
if ((0, Lambda_1.isEventBridgeEvent)(messageBody)) {
|
|
35
|
+
return await (0, StepFunctions_1.getCumulusMessageFromExecutionEvent)(messageBody);
|
|
36
|
+
}
|
|
37
|
+
if ((0, CumulusMessage_1.isCumulusMessageLike)(messageBody)) {
|
|
30
38
|
return messageBody;
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
const unwrappedMessageBody = await (0, StepFunctions_1.getCumulusMessageFromExecutionEvent)(messageBody);
|
|
34
|
-
return await (0, exports.unwrapDeadLetterCumulusMessage)(unwrappedMessageBody);
|
|
40
|
+
throw new TypeError('DeadLetter CumulusMessage in unrecognized format');
|
|
35
41
|
}
|
|
36
42
|
catch (error) {
|
|
37
|
-
log.error('Falling back to storing wrapped message after encountering unwrap error', error);
|
|
43
|
+
log.error('Falling back to storing wrapped message after encountering unwrap error', error, JSON.stringify(messageBody));
|
|
38
44
|
return messageBody;
|
|
39
45
|
}
|
|
40
46
|
};
|
|
41
47
|
exports.unwrapDeadLetterCumulusMessage = unwrapDeadLetterCumulusMessage;
|
|
48
|
+
const payloadHasGranules = (payload) => (payload instanceof Object
|
|
49
|
+
&& 'granules' in payload
|
|
50
|
+
&& Array.isArray(payload.granules));
|
|
51
|
+
const extractCollectionId = (message) => {
|
|
52
|
+
const collectionName = message?.meta?.collection?.name || null;
|
|
53
|
+
const collectionVersion = message?.meta?.collection?.version || null;
|
|
54
|
+
if (collectionName && collectionVersion) {
|
|
55
|
+
return (0, Collections_1.constructCollectionId)(collectionName, collectionVersion);
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
const extractGranules = (message) => {
|
|
60
|
+
if (payloadHasGranules(message.payload)) {
|
|
61
|
+
return message.payload.granules.map((granule) => granule?.granuleId || null);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* peel out metadata from an SQS(/DLQ)record
|
|
67
|
+
* @param message DLQ or SQS message
|
|
68
|
+
* @returns the given message without its body
|
|
69
|
+
*/
|
|
70
|
+
const extractSQSMetadata = (message) => {
|
|
71
|
+
const metadata = { ...message };
|
|
72
|
+
delete metadata.body;
|
|
73
|
+
delete metadata.Body;
|
|
74
|
+
return metadata;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Reformat object with key attributes at top level.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
const hoistCumulusMessageDetails = async (dlqRecord) => {
|
|
81
|
+
let executionArn = null;
|
|
82
|
+
let stateMachineArn = null;
|
|
83
|
+
let status = null;
|
|
84
|
+
let time = null;
|
|
85
|
+
let collectionId = null;
|
|
86
|
+
let granules = null;
|
|
87
|
+
let providerId = null;
|
|
88
|
+
let messageBody;
|
|
89
|
+
messageBody = dlqRecord;
|
|
90
|
+
let metadata = extractSQSMetadata(messageBody);
|
|
91
|
+
/* de-nest sqs records of unknown depth */
|
|
92
|
+
while ((0, SQS_1.isSQSRecordLike)(messageBody)) {
|
|
93
|
+
/* prefer outermost recorded metadata */
|
|
94
|
+
metadata = { ...extractSQSMetadata(messageBody), ...metadata };
|
|
95
|
+
messageBody = (0, SQS_1.parseSQSMessageBody)(messageBody);
|
|
96
|
+
}
|
|
97
|
+
const error = 'error' in metadata ? metadata.error : null;
|
|
98
|
+
if ((0, Lambda_1.isEventBridgeEvent)(messageBody)) {
|
|
99
|
+
executionArn = messageBody?.detail?.executionArn || null;
|
|
100
|
+
stateMachineArn = messageBody?.detail?.stateMachineArn || null;
|
|
101
|
+
status = messageBody?.detail?.status || null;
|
|
102
|
+
time = messageBody?.time || null;
|
|
103
|
+
let cumulusMessage;
|
|
104
|
+
try {
|
|
105
|
+
cumulusMessage = await (0, StepFunctions_1.getCumulusMessageFromExecutionEvent)(messageBody);
|
|
106
|
+
}
|
|
107
|
+
catch (error_) {
|
|
108
|
+
cumulusMessage = undefined;
|
|
109
|
+
log.error('could not parse details from DLQ message body', error_, messageBody);
|
|
110
|
+
}
|
|
111
|
+
if (cumulusMessage) {
|
|
112
|
+
collectionId = extractCollectionId(cumulusMessage);
|
|
113
|
+
granules = extractGranules(cumulusMessage);
|
|
114
|
+
if ((0, Providers_1.isMessageWithProvider)(cumulusMessage)) {
|
|
115
|
+
providerId = (0, Providers_1.getMessageProviderId)(cumulusMessage) || null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
log.error('could not parse details from DLQ message body', messageBody, 'expected EventBridgeEvent');
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...metadata,
|
|
124
|
+
body: JSON.stringify(messageBody),
|
|
125
|
+
collectionId,
|
|
126
|
+
providerId,
|
|
127
|
+
granules,
|
|
128
|
+
executionArn,
|
|
129
|
+
stateMachineArn,
|
|
130
|
+
status,
|
|
131
|
+
time,
|
|
132
|
+
error,
|
|
133
|
+
}; // cast to DLARecord: ts is confused by explicit 'undefined' fields in metadata
|
|
134
|
+
};
|
|
135
|
+
exports.hoistCumulusMessageDetails = hoistCumulusMessageDetails;
|
|
136
|
+
const getDLARootKey = (stackName) => (`${stackName}/dead-letter-archive/sqs/`);
|
|
137
|
+
exports.getDLARootKey = getDLARootKey;
|
|
138
|
+
const extractDateString = (message) => (message.time && moment_1.default.utc(message.time).isValid() ? moment_1.default.utc(message.time).format('YYYY-MM-DD') : moment_1.default.utc().format('YYYY-MM-DD'));
|
|
139
|
+
exports.extractDateString = extractDateString;
|
|
140
|
+
const extractFileName = (message) => {
|
|
141
|
+
// get token after the last / or :
|
|
142
|
+
const executionName = message.executionArn ? message.executionArn.split(/[/:]/).pop() : 'unknown';
|
|
143
|
+
return `${executionName}-${(0, uuidv4_1.uuid)()}`;
|
|
144
|
+
};
|
|
145
|
+
exports.extractFileName = extractFileName;
|
|
146
|
+
const getDLAKey = (stackName, message) => {
|
|
147
|
+
const dateString = (0, exports.extractDateString)(message);
|
|
148
|
+
const fileName = (0, exports.extractFileName)(message);
|
|
149
|
+
return `${(0, exports.getDLARootKey)(stackName)}${dateString}/${fileName}`;
|
|
150
|
+
};
|
|
151
|
+
exports.getDLAKey = getDLAKey;
|
|
152
|
+
const getDLAFailureKey = (stackName, message) => {
|
|
153
|
+
const dateString = (0, exports.extractDateString)(message);
|
|
154
|
+
const fileName = (0, exports.extractFileName)(message);
|
|
155
|
+
return `${stackName}/dead-letter-archive/failed-sqs/${dateString}/${fileName}`;
|
|
156
|
+
};
|
|
157
|
+
exports.getDLAFailureKey = getDLAFailureKey;
|
|
42
158
|
//# sourceMappingURL=DeadLetterMessage.js.map
|
package/DeadLetterMessage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeadLetterMessage.js","sourceRoot":"","sources":["src/DeadLetterMessage.ts"],"names":[],"mappings":";;;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"DeadLetterMessage.js","sourceRoot":"","sources":["src/DeadLetterMessage.ts"],"names":[],"mappings":";;;;;;AAEA,oDAA4B;AAE5B,mCAA8B;AAC9B,uDAA8F;AAC9F,iDAA+E;AAG/E,6DAAqC;AAErC,2CAA0E;AAC1E,qDAAwD;AACxD,mDAAsE;AACtE,+CAAsD;AAEtD,MAAM,GAAG,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC,CAAC;AAQj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,SAAS,CAAC,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;AAChE,CAAC,CAAC;AAJW,QAAA,SAAS,aAIpB;AAEK,MAAM,gBAAgB,GAAG,CAAC,SAAiB,EAAE,OAAkB,EAAU,EAAE;IAChF,MAAM,UAAU,GAAG,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,GAAG,SAAS,mCAAmC,UAAU,IAAI,QAAQ,EAAE,CAAC;AACjF,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}
|
package/Providers.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ declare type MessageProvider = {
|
|
|
5
5
|
host: string;
|
|
6
6
|
port?: number;
|
|
7
7
|
};
|
|
8
|
+
export declare const isMessageProvider: (obj: any) => obj is MessageProvider;
|
|
8
9
|
declare type MessageWithProvider = Message.CumulusMessage & {
|
|
9
10
|
meta: {
|
|
10
11
|
provider?: MessageProvider;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
14
|
+
export declare const isMessageWithProvider: (obj: any) => obj is MessageWithProvider;
|
|
13
15
|
/**
|
|
14
16
|
* Get the provider from a workflow message, if any.
|
|
15
17
|
*
|
package/Providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Providers.d.ts","sourceRoot":"","sources":["src/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,aAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAC;AAEF,aAAK,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG;IAClD,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,eAAe,CAAA;KAC3B,CAAA;CACF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,YACpB,mBAAmB,KAC3B,eAAe,GAAG,SAAmC,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,YACtB,mBAAmB,KAC3B,MAAM,GAAG,SAA4C,CAAC"}
|
|
1
|
+
{"version":3,"file":"Providers.d.ts","sourceRoot":"","sources":["src/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,aAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAC;AAEF,eAAO,MAAM,iBAAiB,QACvB,GAAG,2BAQT,CAAC;AAEF,aAAK,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG;IAClD,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,eAAe,CAAA;KAC3B,CAAA;CACF,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAC3B,GAAG,+BAIT,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,YACpB,mBAAmB,KAC3B,eAAe,GAAG,SAAmC,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,YACtB,mBAAmB,KAC3B,MAAM,GAAG,SAA4C,CAAC"}
|
package/Providers.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMessageProviderId = exports.getMessageProvider = void 0;
|
|
3
|
+
exports.getMessageProviderId = exports.getMessageProvider = exports.isMessageWithProvider = exports.isMessageProvider = void 0;
|
|
4
|
+
const CumulusMessage_1 = require("./CumulusMessage");
|
|
5
|
+
const isMessageProvider = (obj) => (obj instanceof Object
|
|
6
|
+
// in testing instanceof String can return false for string literals
|
|
7
|
+
&& 'id' in obj && (typeof (obj.id) === 'string' || obj.id instanceof String)
|
|
8
|
+
&& 'protocol' in obj && (typeof (obj.protocol) === 'string' || obj.protocol instanceof String)
|
|
9
|
+
&& 'host' in obj && (typeof (obj.host) === 'string' || obj.host instanceof String)
|
|
10
|
+
&& ('port' in obj ? (typeof (obj.port) === 'number' || obj.port instanceof Number) : true));
|
|
11
|
+
exports.isMessageProvider = isMessageProvider;
|
|
12
|
+
const isMessageWithProvider = (obj) => ((0, CumulusMessage_1.isCumulusMessageLike)(obj)
|
|
13
|
+
&& (0, exports.isMessageProvider)(obj?.meta?.provider));
|
|
14
|
+
exports.isMessageWithProvider = isMessageWithProvider;
|
|
4
15
|
/**
|
|
5
16
|
* Get the provider from a workflow message, if any.
|
|
6
17
|
*
|
package/Providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["src/Providers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["src/Providers.ts"],"names":[],"mappings":";;;AACA,qDAAwD;AAQjD,MAAM,iBAAiB,GAAG,CAC/B,GAAQ,EACgB,EAAE,CAAC,CAC3B,GAAG,YAAY,MAAM;IACrB,oEAAoE;OACjE,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,EAAE,YAAY,MAAM,CAAC;OACzE,UAAU,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,YAAY,MAAM,CAAC;OAC3F,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,YAAY,MAAM,CAAC;OAC/E,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAC3F,CAAC;AATW,QAAA,iBAAiB,qBAS5B;AAQK,MAAM,qBAAqB,GAAG,CACnC,GAAQ,EACoB,EAAE,CAAC,CAC/B,IAAA,qCAAoB,EAAC,GAAG,CAAC;OACtB,IAAA,yBAAiB,EAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAC1C,CAAC;AALW,QAAA,qBAAqB,yBAKhC;AACF;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAChC,OAA4B,EACC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;AAF5C,QAAA,kBAAkB,sBAE0B;AAEzD;;;;;;;GAOG;AACI,MAAM,oBAAoB,GAAG,CAClC,OAA4B,EACR,EAAE,CAAC,IAAA,0BAAkB,EAAC,OAAO,CAAC,EAAE,EAAE,CAAC;AAF5C,QAAA,oBAAoB,wBAEwB"}
|
package/README.md
CHANGED
|
@@ -47,10 +47,22 @@ the collectionId used in elasticsearch indexing</p>
|
|
|
47
47
|
<dt><a href="#exp_module_Collections--getCollectionIdFromMessage">getCollectionIdFromMessage(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
|
|
48
48
|
<dd><p>Get collection ID from execution message.</p>
|
|
49
49
|
</dd>
|
|
50
|
-
<dt><a href="#
|
|
50
|
+
<dt><a href="#isCumulusMessageLike">isCumulusMessageLike()</a></dt>
|
|
51
|
+
<dd><p>Bare check for CumulusMessage Shape</p>
|
|
52
|
+
</dd>
|
|
53
|
+
<dt><a href="#isDLQRecordLike">isDLQRecordLike()</a></dt>
|
|
54
|
+
<dd><p>Bare check for SQS message Shape</p>
|
|
55
|
+
</dd>
|
|
56
|
+
<dt><a href="#unwrapDeadLetterCumulusMessage">unwrapDeadLetterCumulusMessage()</a></dt>
|
|
51
57
|
<dd><p>Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
52
58
|
States cloudwatch event, which is wrapped in an SQS message.</p>
|
|
53
59
|
</dd>
|
|
60
|
+
<dt><a href="#extractSQSMetadata">extractSQSMetadata(message)</a> ⇒</dt>
|
|
61
|
+
<dd><p>peel out metadata from an SQS(/DLQ)record</p>
|
|
62
|
+
</dd>
|
|
63
|
+
<dt><a href="#hoistCumulusMessageDetails">hoistCumulusMessageDetails()</a></dt>
|
|
64
|
+
<dd><p>Reformat object with key attributes at top level.</p>
|
|
65
|
+
</dd>
|
|
54
66
|
<dt><a href="#exp_module_PDRs--getMessagePdr">getMessagePdr(message)</a> ⇒ <code>undefined</code> | <code>Object</code> ⏏</dt>
|
|
55
67
|
<dd><p>Get the PDR object from a workflow message, if any.</p>
|
|
56
68
|
</dd>
|
|
@@ -90,11 +102,11 @@ States cloudwatch event, which is wrapped in an SQS message.</p>
|
|
|
90
102
|
<dt><a href="#exp_module_Providers--getMessageProviderId">getMessageProviderId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
|
|
91
103
|
<dd><p>Get the provider ID from a workflow message, if any.</p>
|
|
92
104
|
</dd>
|
|
93
|
-
<dt><a href="#exp_module_StepFunctions--pullStepFunctionEvent">pullStepFunctionEvent(event)</a> ⇒ <code>Promise.<
|
|
105
|
+
<dt><a href="#exp_module_StepFunctions--pullStepFunctionEvent">pullStepFunctionEvent(event)</a> ⇒ <code>Promise.<object></code> ⏏</dt>
|
|
94
106
|
<dd><p>Given a Step Function event, replace specified key in event with contents
|
|
95
107
|
of S3 remote message</p>
|
|
96
108
|
</dd>
|
|
97
|
-
<dt><a href="#exp_module_StepFunctions--parseStepMessage">parseStepMessage(stepMessage, stepName)</a> ⇒ <code>Promise.<
|
|
109
|
+
<dt><a href="#exp_module_StepFunctions--parseStepMessage">parseStepMessage(stepMessage, stepName)</a> ⇒ <code>Promise.<object></code> ⏏</dt>
|
|
98
110
|
<dd><p>Parse step message with CMA keys and replace specified key in event with contents
|
|
99
111
|
of S3 remote message</p>
|
|
100
112
|
</dd>
|
|
@@ -103,7 +115,7 @@ of S3 remote message</p>
|
|
|
103
115
|
the failed task Id. HistoryEvent ids are numbered sequentially, starting at
|
|
104
116
|
one.</p>
|
|
105
117
|
</dd>
|
|
106
|
-
<dt><a href="#lastFailedEventStep">lastFailedEventStep(events)</a> ⇒ <code>
|
|
118
|
+
<dt><a href="#lastFailedEventStep">lastFailedEventStep(events)</a> ⇒ <code>Array.<HistoryEvent></code> | <code>undefined</code></dt>
|
|
107
119
|
<dd><p>Finds all failed execution events and returns the last one in the list.</p>
|
|
108
120
|
</dd>
|
|
109
121
|
<dt><a href="#getFailedExecutionMessage">getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction)</a> ⇒ <code>Object</code></dt>
|
|
@@ -486,19 +498,43 @@ Determine if there is a queue and queue execution limit in the message.
|
|
|
486
498
|
| --- | --- | --- |
|
|
487
499
|
| message | <code>MessageWithQueueInfo</code> | A workflow message object |
|
|
488
500
|
|
|
501
|
+
<a name="isCumulusMessageLike"></a>
|
|
502
|
+
|
|
503
|
+
### isCumulusMessageLike()
|
|
504
|
+
Bare check for CumulusMessage Shape
|
|
505
|
+
|
|
506
|
+
**Kind**: global function
|
|
507
|
+
<a name="isDLQRecordLike"></a>
|
|
508
|
+
|
|
509
|
+
### isDLQRecordLike()
|
|
510
|
+
Bare check for SQS message Shape
|
|
511
|
+
|
|
512
|
+
**Kind**: global function
|
|
489
513
|
<a name="unwrapDeadLetterCumulusMessage"></a>
|
|
490
514
|
|
|
491
|
-
### unwrapDeadLetterCumulusMessage(
|
|
515
|
+
### unwrapDeadLetterCumulusMessage()
|
|
492
516
|
Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
493
517
|
States cloudwatch event, which is wrapped in an SQS message.
|
|
494
518
|
|
|
495
519
|
**Kind**: global function
|
|
496
|
-
|
|
520
|
+
<a name="extractSQSMetadata"></a>
|
|
497
521
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
522
|
+
### extractSQSMetadata(message) ⇒
|
|
523
|
+
peel out metadata from an SQS(/DLQ)record
|
|
524
|
+
|
|
525
|
+
**Kind**: global function
|
|
526
|
+
**Returns**: the given message without its body
|
|
501
527
|
|
|
528
|
+
| Param | Description |
|
|
529
|
+
| --- | --- |
|
|
530
|
+
| message | DLQ or SQS message |
|
|
531
|
+
|
|
532
|
+
<a name="hoistCumulusMessageDetails"></a>
|
|
533
|
+
|
|
534
|
+
### hoistCumulusMessageDetails()
|
|
535
|
+
Reformat object with key attributes at top level.
|
|
536
|
+
|
|
537
|
+
**Kind**: global function
|
|
502
538
|
<a name="getFailedStepName"></a>
|
|
503
539
|
|
|
504
540
|
### getFailedStepName(events, failedStepEvent) ⇒ <code>string</code>
|
|
@@ -512,20 +548,21 @@ one.
|
|
|
512
548
|
| Param | Type | Description |
|
|
513
549
|
| --- | --- | --- |
|
|
514
550
|
| events | <code>Array.<HistoryEvent></code> | Step Function events array |
|
|
515
|
-
| failedStepEvent | <code>
|
|
551
|
+
| failedStepEvent | <code>failedStepEvent</code> | Step Function's failed event. |
|
|
552
|
+
| failedStepEvent.id | | number (long), Step Functions failed event id. |
|
|
516
553
|
|
|
517
554
|
<a name="lastFailedEventStep"></a>
|
|
518
555
|
|
|
519
|
-
### lastFailedEventStep(events) ⇒ <code>
|
|
556
|
+
### lastFailedEventStep(events) ⇒ <code>Array.<HistoryEvent></code> \| <code>undefined</code>
|
|
520
557
|
Finds all failed execution events and returns the last one in the list.
|
|
521
558
|
|
|
522
559
|
**Kind**: global function
|
|
523
|
-
**Returns**: <code>
|
|
560
|
+
**Returns**: <code>Array.<HistoryEvent></code> \| <code>undefined</code> - - the last lambda or activity that failed in the
|
|
524
561
|
event array, or an empty array.
|
|
525
562
|
|
|
526
563
|
| Param | Type | Description |
|
|
527
564
|
| --- | --- | --- |
|
|
528
|
-
| events | <code>Array.<
|
|
565
|
+
| events | <code>Array.<HistoryEvent></code> | array of AWS Stepfunction execution HistoryEvents |
|
|
529
566
|
|
|
530
567
|
<a name="getFailedExecutionMessage"></a>
|
|
531
568
|
|
package/StepFunctions.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions for working with AWS Step Function events/messages
|
|
3
|
-
* @module StepFunctions
|
|
4
3
|
*
|
|
4
|
+
* @module StepFunctions
|
|
5
5
|
* @example
|
|
6
|
-
*
|
|
6
|
+
* const StepFunctions = require('@cumulus/message/StepFunctions');
|
|
7
7
|
*/
|
|
8
8
|
import { EventBridgeEvent } from 'aws-lambda';
|
|
9
|
-
import { getExecutionHistory } from '@cumulus/aws-client/StepFunctions';
|
|
9
|
+
import { getExecutionHistory, HistoryEvent } from '@cumulus/aws-client/StepFunctions';
|
|
10
10
|
import { Message } from '@cumulus/types';
|
|
11
11
|
/**
|
|
12
12
|
* Given a Step Function event, replace specified key in event with contents
|
|
13
13
|
* of S3 remote message
|
|
14
14
|
*
|
|
15
15
|
* @param {Message.CumulusRemoteMessage} event - Source event
|
|
16
|
-
* @
|
|
16
|
+
* @param event.replace - Cumulus message replace config
|
|
17
|
+
* @returns {Promise<object>} Updated event with target path replaced by remote message
|
|
17
18
|
* @throws {Error} if target path cannot be found on source event
|
|
18
|
-
*
|
|
19
19
|
* @async
|
|
20
20
|
* @alias module:StepFunctions
|
|
21
21
|
*/
|
|
@@ -28,8 +28,7 @@ export declare const pullStepFunctionEvent: (event: {
|
|
|
28
28
|
*
|
|
29
29
|
* @param {CMAMessage} stepMessage - Message for the step
|
|
30
30
|
* @param {string} stepName - Name of the step
|
|
31
|
-
* @returns {Promise<
|
|
32
|
-
*
|
|
31
|
+
* @returns {Promise<object>} Parsed and updated event with target path replaced by remote message
|
|
33
32
|
* @async
|
|
34
33
|
* @alias module:StepFunctions
|
|
35
34
|
*/
|
|
@@ -38,22 +37,21 @@ export declare const parseStepMessage: (stepMessage: Message.CMAMessage, stepNam
|
|
|
38
37
|
* Searches the Execution step History for the TaskStateEntered pertaining to
|
|
39
38
|
* the failed task Id. HistoryEvent ids are numbered sequentially, starting at
|
|
40
39
|
* one.
|
|
41
|
-
*
|
|
40
|
+
*
|
|
42
41
|
* @param {HistoryEvent[]} events - Step Function events array
|
|
43
|
-
* @param {
|
|
42
|
+
* @param {failedStepEvent} failedStepEvent - Step Function's failed event.
|
|
43
|
+
* @param failedStepEvent.id - number (long), Step Functions failed event id.
|
|
44
44
|
* @returns {string} name of the current stepfunction task or 'UnknownFailedStepName'.
|
|
45
45
|
*/
|
|
46
|
-
export declare const getFailedStepName: (events:
|
|
47
|
-
id: number;
|
|
48
|
-
}) => string;
|
|
46
|
+
export declare const getFailedStepName: (events: HistoryEvent[], failedStepEvent: HistoryEvent) => string;
|
|
49
47
|
/**
|
|
50
48
|
* Finds all failed execution events and returns the last one in the list.
|
|
51
49
|
*
|
|
52
|
-
* @param {
|
|
53
|
-
* @returns {
|
|
50
|
+
* @param {HistoryEvent[]} events - array of AWS Stepfunction execution HistoryEvents
|
|
51
|
+
* @returns {HistoryEvent[] | undefined} - the last lambda or activity that failed in the
|
|
54
52
|
* event array, or an empty array.
|
|
55
53
|
*/
|
|
56
|
-
export declare const lastFailedEventStep: (events:
|
|
54
|
+
export declare const lastFailedEventStep: (events: HistoryEvent[]) => HistoryEvent | undefined;
|
|
57
55
|
/**
|
|
58
56
|
* Get message to use for publishing failed execution notifications.
|
|
59
57
|
*
|
package/StepFunctions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepFunctions.d.ts","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"StepFunctions.d.ts","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA6BzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,UACzB;IACL,OAAO,CAAC,EAAE,QAAQ,aAAa,CAAA;CAChC,KACA,QAAQ,OAAO,CAyBjB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gBACd,QAAQ,UAAU,YACrB,MAAM,oCAkBjB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,WACpB,YAAY,EAAE,mBACL,YAAY,WAe9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,WACtB,YAAY,EAAE,KACrB,YAAY,GAAG,SAIjB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,wBACf,QAAQ,cAAc,gCACd,0BAA0B;;;;;;;;;EAwCxD,CAAC;AAEF,eAAO,MAAM,mCAAmC;;sCA2B/C,CAAC"}
|
package/StepFunctions.js
CHANGED
|
@@ -53,9 +53,9 @@ const executionStatusToWorkflowStatus = (executionStatus) => {
|
|
|
53
53
|
* of S3 remote message
|
|
54
54
|
*
|
|
55
55
|
* @param {Message.CumulusRemoteMessage} event - Source event
|
|
56
|
-
* @
|
|
56
|
+
* @param event.replace - Cumulus message replace config
|
|
57
|
+
* @returns {Promise<object>} Updated event with target path replaced by remote message
|
|
57
58
|
* @throws {Error} if target path cannot be found on source event
|
|
58
|
-
*
|
|
59
59
|
* @async
|
|
60
60
|
* @alias module:StepFunctions
|
|
61
61
|
*/
|
|
@@ -88,8 +88,7 @@ exports.pullStepFunctionEvent = pullStepFunctionEvent;
|
|
|
88
88
|
*
|
|
89
89
|
* @param {CMAMessage} stepMessage - Message for the step
|
|
90
90
|
* @param {string} stepName - Name of the step
|
|
91
|
-
* @returns {Promise<
|
|
92
|
-
*
|
|
91
|
+
* @returns {Promise<object>} Parsed and updated event with target path replaced by remote message
|
|
93
92
|
* @async
|
|
94
93
|
* @alias module:StepFunctions
|
|
95
94
|
*/
|
|
@@ -116,9 +115,10 @@ exports.parseStepMessage = parseStepMessage;
|
|
|
116
115
|
* Searches the Execution step History for the TaskStateEntered pertaining to
|
|
117
116
|
* the failed task Id. HistoryEvent ids are numbered sequentially, starting at
|
|
118
117
|
* one.
|
|
119
|
-
*
|
|
118
|
+
*
|
|
120
119
|
* @param {HistoryEvent[]} events - Step Function events array
|
|
121
|
-
* @param {
|
|
120
|
+
* @param {failedStepEvent} failedStepEvent - Step Function's failed event.
|
|
121
|
+
* @param failedStepEvent.id - number (long), Step Functions failed event id.
|
|
122
122
|
* @returns {string} name of the current stepfunction task or 'UnknownFailedStepName'.
|
|
123
123
|
*/
|
|
124
124
|
const getFailedStepName = (events, failedStepEvent) => {
|
|
@@ -140,8 +140,8 @@ exports.getFailedStepName = getFailedStepName;
|
|
|
140
140
|
/**
|
|
141
141
|
* Finds all failed execution events and returns the last one in the list.
|
|
142
142
|
*
|
|
143
|
-
* @param {
|
|
144
|
-
* @returns {
|
|
143
|
+
* @param {HistoryEvent[]} events - array of AWS Stepfunction execution HistoryEvents
|
|
144
|
+
* @returns {HistoryEvent[] | undefined} - the last lambda or activity that failed in the
|
|
145
145
|
* event array, or an empty array.
|
|
146
146
|
*/
|
|
147
147
|
const lastFailedEventStep = (events) => {
|
package/StepFunctions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepFunctions.js","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWb,iDAAyC;AACzC,qDAA6B;AAC7B,qDAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"StepFun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AAmC,GAAG,KAAK,EAAE,cAAqG,EAAE,EAAE;IACjK,IAAI,cAAc,CAAC;IACnB,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;QAC9C,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KAC1D;SAAM,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE;QACvD,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KAC3D;SAAM;QACL,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,aAAG,EAAC,cAAc,EAAE,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC;QAC7E,cAAc,GAAG,MAAM,IAAA,iCAAyB,EAAC,YAAY,CAAC,CAAC;KAChE;IAED,MAAM,kBAAkB,GAAG,CAAC,MAAM,IAAA,6BAAqB,EACrD,cAAc,CACf,CAA2B,CAAC;IAE7B,MAAM,cAAc,GAAG,+BAA+B,CACpD,cAAc,CAAC,MAAM,CAAC,MAAyB,CAChD,CAAC;IACF,IAAA,aAAG,EAAC,kBAAkB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAA,aAAG,EACD,kBAAkB,EAClB,iCAAiC,EACjC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAC/B,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AA3BW,QAAA,mCAAmC,uCA2B9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/message",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.3.0",
|
|
4
4
|
"description": "Utilities for building and parsing Cumulus messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"GIBS",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"NASA"
|
|
9
9
|
],
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=20.12.2"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"build-docs": "npm run clean && npm run tsc && ../../node_modules/.bin/jsdoc2md --heading-depth 3 -t templates/README.md.hbs *.js > README.md",
|
|
23
23
|
"clean": "git clean -d -x -e node_modules -f",
|
|
24
24
|
"test": "../../node_modules/.bin/ava",
|
|
25
|
+
"test:ci": "../../scripts/run_package_ci_unit.sh",
|
|
25
26
|
"test:coverage": "../../node_modules/.bin/nyc npm test",
|
|
26
27
|
"prepare": "npm run tsc",
|
|
27
28
|
"tsc": "../../node_modules/.bin/tsc",
|
|
@@ -34,22 +35,23 @@
|
|
|
34
35
|
"tests/**"
|
|
35
36
|
],
|
|
36
37
|
"verbose": true,
|
|
37
|
-
"timeout": "15m"
|
|
38
|
+
"timeout": "15m",
|
|
39
|
+
"failFast": true
|
|
38
40
|
},
|
|
39
41
|
"author": "Cumulus Authors",
|
|
40
42
|
"license": "Apache-2.0",
|
|
41
43
|
"dependencies": {
|
|
42
|
-
"@cumulus/aws-client": "18.
|
|
43
|
-
"@cumulus/common": "18.
|
|
44
|
-
"@cumulus/errors": "18.
|
|
45
|
-
"@cumulus/logger": "18.
|
|
46
|
-
"@cumulus/types": "18.
|
|
44
|
+
"@cumulus/aws-client": "18.3.0",
|
|
45
|
+
"@cumulus/common": "18.3.0",
|
|
46
|
+
"@cumulus/errors": "18.3.0",
|
|
47
|
+
"@cumulus/logger": "18.3.0",
|
|
48
|
+
"@cumulus/types": "18.3.0",
|
|
47
49
|
"jsonpath-plus": "^3.0.0",
|
|
48
50
|
"lodash": "^4.17.21",
|
|
49
|
-
"
|
|
51
|
+
"uuidv4": "^6.2.13"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@types/uuid": "^8.0.0"
|
|
53
55
|
},
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e8731c150ac49c1bab058183a7a5d91464e1701c"
|
|
55
57
|
}
|