@evergis/react 4.0.168 → 4.0.169
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/dist/components/Dashboard/actions/types.d.ts +2 -0
- package/dist/components/Dashboard/types.d.ts +2 -0
- package/dist/dashboardActions/index.js +6 -0
- package/dist/dashboardActions/index.js.map +1 -1
- package/dist/hooks/task/runtime/getPythonTaskConfiguration.d.ts +2 -0
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +32 -7
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Icon, IconButtonInnerChild, IconButton, Flex, CircularProgress, transit
|
|
|
3
3
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
4
4
|
import { memo, forwardRef, isValidElement, Fragment, createContext, useContext, useId, useMemo, useRef, useCallback, useLayoutEffect, useSyncExternalStore, useEffect, useState, createElement } from 'react';
|
|
5
5
|
import { barChartClassNames, lineChartClassNames, BarChart as BarChart$1, LineChart, PieChart } from '@evergis/charts';
|
|
6
|
-
import { AttributeType, AttributeIconType, StringSubType, RemoteTaskStatus, generateId, STORAGE_TOKEN_KEY, parseJwt, STORAGE_REFRESH_TOKEN_KEY, AttributeConfigurationType, LayerServiceType, OgcGeometryType } from '@evergis/api';
|
|
6
|
+
import { AttributeType, AttributeIconType, StringSubType, RemoteTaskStatus, HTTPError, TaskResourceSubType, generateId, STORAGE_TOKEN_KEY, parseJwt, STORAGE_REFRESH_TOKEN_KEY, AttributeConfigurationType, LayerServiceType, OgcGeometryType } from '@evergis/api';
|
|
7
7
|
import { Color as Color$1, ColorScale } from '@evergis/color';
|
|
8
8
|
import { isValid, format, parseJSON, parseISO, toDate } from 'date-fns';
|
|
9
9
|
import { isNil, isUndefined, isEqual, cloneDeep, isEmpty, uniqueId, uniqBy, unescape } from 'lodash';
|
|
@@ -6467,6 +6467,12 @@ function getActionOptionsError(type, value) {
|
|
|
6467
6467
|
return "Options must be an object";
|
|
6468
6468
|
if (type === "runTask" && (typeof value.taskName !== "string" || !value.taskName))
|
|
6469
6469
|
return "runTask requires taskName";
|
|
6470
|
+
if (type === "runTask") {
|
|
6471
|
+
for (const field of ["fileName", "methodName"]) {
|
|
6472
|
+
if (value[field] !== undefined && (typeof value[field] !== "string" || !value[field].trim()))
|
|
6473
|
+
return `runTask ${field} must be a non-empty string`;
|
|
6474
|
+
}
|
|
6475
|
+
}
|
|
6470
6476
|
if (type === "openModal" && (typeof value.modalId !== "string" || !value.modalId))
|
|
6471
6477
|
return "openModal requires modalId";
|
|
6472
6478
|
if (type === "openUrl" && (typeof value.url !== "string" || !value.url))
|
|
@@ -9035,6 +9041,22 @@ class PythonExecutionError extends Error {
|
|
|
9035
9041
|
const RUN_ID_RADIX = 36;
|
|
9036
9042
|
const TASK_OBSERVATION_TIMEOUT_MS = 86_400_000;
|
|
9037
9043
|
|
|
9044
|
+
const BAD_REQUEST_STATUS = 400;
|
|
9045
|
+
const getPythonTaskConfiguration = async (resourceId, manager, hasExplicitTarget) => {
|
|
9046
|
+
try {
|
|
9047
|
+
return await manager.getTaskResource({ id: resourceId });
|
|
9048
|
+
}
|
|
9049
|
+
catch (error) {
|
|
9050
|
+
if (!hasExplicitTarget || !(error instanceof HTTPError) || error.response.status !== BAD_REQUEST_STATUS)
|
|
9051
|
+
throw error;
|
|
9052
|
+
// Clone the response so a propagated error retains its body for the caller.
|
|
9053
|
+
const body = await error.response.clone().text().catch(() => "");
|
|
9054
|
+
if (!body.includes("Python importMethod is required"))
|
|
9055
|
+
throw error;
|
|
9056
|
+
return undefined;
|
|
9057
|
+
}
|
|
9058
|
+
};
|
|
9059
|
+
|
|
9038
9060
|
const resolvePythonTaskDefinition = async (request, manager) => {
|
|
9039
9061
|
const task = request.taskName ? request.tasks?.find(({ name }) => name === request.taskName) : undefined;
|
|
9040
9062
|
if (request.taskName && !task)
|
|
@@ -9042,20 +9064,23 @@ const resolvePythonTaskDefinition = async (request, manager) => {
|
|
|
9042
9064
|
const resourceId = task?.resourceId ?? request.resourceId;
|
|
9043
9065
|
if (!resourceId)
|
|
9044
9066
|
throw new Error(`Task resourceId is missing: ${request.taskName ?? ""}`);
|
|
9045
|
-
const
|
|
9046
|
-
|
|
9067
|
+
const fileName = request.fileName ?? task?.fileName;
|
|
9068
|
+
const methodName = request.methodName ?? task?.methodName;
|
|
9069
|
+
const hasExplicitTarget = typeof fileName === "string" && !!fileName.trim() && typeof methodName === "string" && !!methodName.trim();
|
|
9070
|
+
const configuration = await getPythonTaskConfiguration(resourceId, manager, hasExplicitTarget);
|
|
9071
|
+
if (configuration && configuration.taskResourceSubType !== TaskResourceSubType.PythonTask && !["pythonService", "PythonTask"].includes(configuration.taskType)) {
|
|
9047
9072
|
throw new Error(`Task ${request.taskName ?? resourceId} is not a Python task`);
|
|
9048
9073
|
}
|
|
9049
|
-
const schema = configuration
|
|
9074
|
+
const schema = configuration?.defaultConfiguration ?? {};
|
|
9050
9075
|
const defaults = buildDefaultForSchema(new SchemaResolver(schema), schema);
|
|
9051
|
-
const parameters = [defaults, configuration
|
|
9076
|
+
const parameters = [defaults, configuration?.userConfiguration, task?.params, request.parameters]
|
|
9052
9077
|
.filter(isObject)
|
|
9053
9078
|
.reduce((base, override) => mergeActionParameters(base, override), {});
|
|
9054
9079
|
return {
|
|
9055
9080
|
resourceId,
|
|
9056
9081
|
parameters,
|
|
9057
|
-
fileName:
|
|
9058
|
-
methodName:
|
|
9082
|
+
fileName: fileName ?? schema.fileName,
|
|
9083
|
+
methodName: methodName ?? schema.methodName,
|
|
9059
9084
|
script: request.script,
|
|
9060
9085
|
};
|
|
9061
9086
|
};
|