@kumori/aurora-backend-handler 1.1.49 → 1.1.50
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/helpers/revision-helper.ts +1 -3
- package/helpers/service-helper.ts +19 -39
- package/package.json +1 -1
|
@@ -189,9 +189,7 @@ const handleRevisionStatus = (revisionStatus: any) => {
|
|
|
189
189
|
|
|
190
190
|
const containerError = getContainerError(revisionStatus);
|
|
191
191
|
if (containerError) return containerError;
|
|
192
|
-
|
|
193
|
-
return revisionStatus.runtime.status;
|
|
194
|
-
}
|
|
192
|
+
|
|
195
193
|
return revisionStatus?.state;
|
|
196
194
|
};
|
|
197
195
|
|
|
@@ -123,59 +123,40 @@ const determineFinalStatusAndError = (
|
|
|
123
123
|
eventData: any,
|
|
124
124
|
pendingRevisionErrors: Array<{ service: string; revision: Revision }>,
|
|
125
125
|
entityId: string,
|
|
126
|
-
currentRevision: Revision | undefined,
|
|
127
126
|
): {
|
|
128
127
|
finalStatus: any;
|
|
129
128
|
finalError: any;
|
|
130
129
|
pendingErrorIndex: number;
|
|
131
130
|
} => {
|
|
132
|
-
const
|
|
133
|
-
const incomingTs = getTimestamp(
|
|
131
|
+
const incomingStatus = eventData.status.state;
|
|
132
|
+
const incomingTs = getTimestamp(incomingStatus.timestamp);
|
|
134
133
|
const currentTs = getTimestamp(existingService?.status?.timestamp);
|
|
134
|
+
|
|
135
135
|
const isNewer = !existingService || incomingTs > currentTs;
|
|
136
|
+
let finalStatus = existingService?.status;
|
|
137
|
+
let finalError = existingService?.error;
|
|
138
|
+
|
|
139
|
+
if (isNewer) {
|
|
140
|
+
finalStatus = incomingStatus;
|
|
141
|
+
finalError = eventData.status.error ?? undefined;
|
|
142
|
+
}
|
|
136
143
|
|
|
137
144
|
const pendingErrorIndex = pendingRevisionErrors.findIndex(
|
|
138
145
|
(pending) => pending.service === entityId,
|
|
139
146
|
);
|
|
140
|
-
const pendingError =
|
|
141
|
-
pendingErrorIndex !== -1 ? pendingRevisionErrors[pendingErrorIndex] : null;
|
|
142
|
-
const serviceError = isNewer ? eventData.status.error : undefined;
|
|
143
|
-
const revisionError =
|
|
144
|
-
currentRevision?.errorCode
|
|
145
|
-
? {
|
|
146
|
-
code: currentRevision.errorCode,
|
|
147
|
-
message: currentRevision.errorMsg || "",
|
|
148
|
-
timestamp: currentRevision.status?.timestamp || "",
|
|
149
|
-
}
|
|
150
|
-
: null;
|
|
151
|
-
|
|
152
|
-
if (serviceError) {
|
|
153
|
-
return { finalStatus: incomingServiceStatus, finalError: serviceError, pendingErrorIndex };
|
|
154
|
-
}
|
|
155
147
|
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
code: pendingError.revision.errorCode || "",
|
|
165
|
-
message: pendingError.revision.errorMsg || "",
|
|
166
|
-
timestamp: pendingError.revision.status?.timestamp || "",
|
|
167
|
-
},
|
|
168
|
-
pendingErrorIndex,
|
|
148
|
+
if (pendingErrorIndex !== -1) {
|
|
149
|
+
const pendingError = pendingRevisionErrors[pendingErrorIndex];
|
|
150
|
+
|
|
151
|
+
finalStatus = pendingError.revision.status;
|
|
152
|
+
finalError = {
|
|
153
|
+
code: pendingError.revision.errorCode || "",
|
|
154
|
+
message: pendingError.revision.errorMsg || "",
|
|
155
|
+
timestamp: pendingError.revision.status.timestamp || "",
|
|
169
156
|
};
|
|
170
157
|
}
|
|
171
|
-
if (currentRevision?.status && isNewer) {
|
|
172
|
-
return { finalStatus: currentRevision.status, finalError: undefined, pendingErrorIndex };
|
|
173
|
-
}
|
|
174
|
-
if (isNewer) {
|
|
175
|
-
return { finalStatus: incomingServiceStatus, finalError: undefined, pendingErrorIndex };
|
|
176
|
-
}
|
|
177
158
|
|
|
178
|
-
return { finalStatus
|
|
159
|
+
return { finalStatus, finalError, pendingErrorIndex };
|
|
179
160
|
};
|
|
180
161
|
|
|
181
162
|
export const handleServiceEvent = ({
|
|
@@ -214,7 +195,6 @@ export const handleServiceEvent = ({
|
|
|
214
195
|
eventData,
|
|
215
196
|
pendingRevisionErrors,
|
|
216
197
|
entityId,
|
|
217
|
-
currentRevision,
|
|
218
198
|
);
|
|
219
199
|
|
|
220
200
|
const updatedPendingRevisionErrors = [...pendingRevisionErrors];
|