Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { LoaderFunctionArgs } from "react-router";
|
||||
import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { featureKeys } from "@hivegrid/entitlements";
|
||||
import { requireTenantProductAccess } from "~/utils/entitlements/.server/productAccess.server";
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import WorkflowsService from "~/modules/workflowEngine/services/WorkflowsService
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
|
||||
export namespace WorkflowsIdExecutionsApi {
|
||||
export type LoaderData = {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Link, useLoaderData, useParams, useSearchParams } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useState } from "react";
|
||||
import "@xyflow/react/dist/style.css";
|
||||
import BreadcrumbSimple from "~/components/ui/breadcrumbs/BreadcrumbSimple";
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { safeRedirectPathFromRequest } from "~/utils/app/RedirectSafety.server";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT, type TFunction } from "i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { formatWorkflowBuilderActionError } from "../workflowRunActionErrors.server";
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Link, useActionData, useLoaderData, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useState } from "react";
|
||||
import "@xyflow/react/dist/style.css";
|
||||
import { toast } from "sonner";
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { getAbsoluteApiUrl } from "~/utils/url.server";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { formatWorkflowRunActionError, workflowActionText } from "../workflowRunActionErrors.server";
|
||||
|
||||
|
||||
+4
-7
@@ -1,7 +1,7 @@
|
||||
import { Form, Link, useActionData, useLoaderData, useNavigation, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useId, useRef, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { toast } from "sonner";
|
||||
import MonacoEditor from "~/components/editors/MonacoEditor";
|
||||
import BreadcrumbSimple from "~/components/ui/breadcrumbs/BreadcrumbSimple";
|
||||
import LoadingButton from "~/components/ui/buttons/LoadingButton";
|
||||
@@ -85,10 +85,7 @@ export default function WorkflowsIdRunApiApiView() {
|
||||
<div>
|
||||
<div className="border-border bg-background w-full border-b px-4 py-2 shadow-2xs">
|
||||
<BreadcrumbSimple
|
||||
menu={[
|
||||
{ title: i18nT("workflows.title"), routePath: UrlUtils.getModulePath(params, `workflow-engine/workflows`) },
|
||||
{ title: data.workflow.name },
|
||||
]}
|
||||
menu={[{ title: i18nT("workflows.title"), routePath: UrlUtils.getModulePath(params, `workflow-engine/workflows`) }, { title: data.workflow.name }]}
|
||||
/>
|
||||
</div>
|
||||
<div className="border-border bg-background w-full border-b px-4 py-2 shadow-2xs">
|
||||
@@ -229,7 +226,7 @@ export default function WorkflowsIdRunApiApiView() {
|
||||
<div>{actionData.error}</div>
|
||||
{actionData.errorCode === "noValidApiKey" && params.tenant && (
|
||||
<div>
|
||||
<Link className="underline" target="_blank" to={appPath({ tenantSlug: params.tenant, path: "settings/api/keys", mode: "host-aware" })}>
|
||||
<Link className="underline" target="_blank" to={appPath({ tenantSlug: params.tenant, path: "api/keys", mode: "host-aware" })}>
|
||||
{i18nT("workflows.run.createApiKeyLink")}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { formatWorkflowRunActionError, workflowActionText } from "../workflowRunActionErrors.server";
|
||||
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
import { Form, Link, useActionData, useLoaderData, useNavigation, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import clsx from "clsx";
|
||||
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { toast } from "sonner";
|
||||
import { Colors } from "~/application/enums/shared/Colors";
|
||||
import MonacoEditor from "~/components/editors/MonacoEditor";
|
||||
import SimpleBadge from "~/components/ui/badges/SimpleBadge";
|
||||
@@ -21,6 +21,7 @@ import ErrorBanner from "~/components/ui/banners/ErrorBanner";
|
||||
import { appendCSRFToken } from "~/utils/csrf";
|
||||
import { formatWorkflowExecutionErrorText } from "~/modules/workflowEngine/utils/workflowExecutionErrorText";
|
||||
import { SendIcon } from "~/components/ui/icons/vendor";
|
||||
import { useCopyToast } from "~/hooks/use-copy-toast";
|
||||
|
||||
export default function WorkflowsIdRunManualView() {
|
||||
const data = useLoaderData<WorkflowsIdRunManualApi.LoaderData>();
|
||||
@@ -64,12 +65,10 @@ export default function WorkflowsIdRunManualView() {
|
||||
actionData?.execution?.executionAlerts.forEach((executionAlert) => {
|
||||
if (executionAlert.type === "error") {
|
||||
toast.error(executionAlert.message, {
|
||||
position: "bottom-right",
|
||||
duration: 10000,
|
||||
});
|
||||
} else {
|
||||
toast.success(executionAlert.message, {
|
||||
position: "bottom-right",
|
||||
duration: 10000,
|
||||
});
|
||||
}
|
||||
@@ -342,6 +341,7 @@ function WorkflowRun({ workflow }: { workflow: WorkflowExecutionDto }) {
|
||||
}
|
||||
|
||||
function InputOutput({ input, output }: { input?: any; output?: any }) {
|
||||
const copyText = useCopyToast();
|
||||
const compactInput = useMemo(() => (input ? JSON.stringify(input) : ""), [input]);
|
||||
const compactOutput = useMemo(() => (output ? JSON.stringify(output) : ""), [output]);
|
||||
const formattedInput = useMemo(() => (input ? JSON.stringify(input, null, 2) : ""), [input]);
|
||||
@@ -362,7 +362,7 @@ function InputOutput({ input, output }: { input?: any; output?: any }) {
|
||||
<button
|
||||
type="button"
|
||||
className="hover:text-muted-foreground text-foreground/80 text-xs font-medium"
|
||||
onClick={() => navigator.clipboard.writeText(compactInput)}
|
||||
onClick={() => void copyText(compactInput, { successKey: "workflows.run.inputCopied" })}
|
||||
>
|
||||
{i18nT("workflows.actions.copy")}
|
||||
</button>
|
||||
@@ -384,7 +384,7 @@ function InputOutput({ input, output }: { input?: any; output?: any }) {
|
||||
<button
|
||||
type="button"
|
||||
className="hover:text-muted-foreground text-foreground/80 text-xs font-medium"
|
||||
onClick={() => navigator.clipboard.writeText(compactOutput)}
|
||||
onClick={() => void copyText(compactOutput, { successKey: "workflows.run.outputCopied" })}
|
||||
>
|
||||
{i18nT("workflows.actions.copy")}
|
||||
</button>
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { formatWorkflowRunActionError, workflowActionText } from "../workflowRunActionErrors.server";
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { Link, useActionData, useLoaderData, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { toast } from "sonner";
|
||||
import MonacoEditor from "~/components/editors/MonacoEditor";
|
||||
import BreadcrumbSimple from "~/components/ui/breadcrumbs/BreadcrumbSimple";
|
||||
import LoadingButton from "~/components/ui/buttons/LoadingButton";
|
||||
|
||||
+22
-5
@@ -1,16 +1,22 @@
|
||||
import { WorkflowCredential } from "@hivegrid/db/prisma-browser";
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs, redirect } from "react-router";
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
|
||||
import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { deleteWorkflowCredential, getAllWorkflowCredentials } from "~/modules/workflowEngine/db/workflowCredentials.db.server";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsCredentialsApi {
|
||||
export type ActionData = {
|
||||
intent: "delete";
|
||||
ok?: true;
|
||||
messageKey?: string;
|
||||
errorKey?: string;
|
||||
};
|
||||
|
||||
export type LoaderData = {
|
||||
metatags: MetaTagsDto;
|
||||
items: WorkflowCredential[];
|
||||
@@ -37,8 +43,19 @@ export namespace WorkflowsCredentialsApi {
|
||||
const action = form.get("action")?.toString();
|
||||
if (action === "delete") {
|
||||
const id = form.get("id")?.toString() ?? "";
|
||||
await deleteWorkflowCredential(id, { tenantId });
|
||||
throw redirect(UrlUtils.getModulePath(params, `workflow-engine/credentials`));
|
||||
try {
|
||||
await deleteWorkflowCredential(id, { tenantId });
|
||||
return Response.json({
|
||||
intent: "delete",
|
||||
ok: true,
|
||||
messageKey: "workflows.toast.credentialDeleted",
|
||||
} satisfies ActionData);
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ intent: "delete", errorKey: "workflows.errors.credentialDeleteFailed" } satisfies ActionData,
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Response.json({ error: t("workflows.errors.invalidForm") }, { status: 400 });
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,6 +1,6 @@
|
||||
import { WorkflowCredential } from "@hivegrid/db/prisma-browser";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { MetaFunction, useLoaderData } from "react-router";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { MetaFunction, useActionData, useLoaderData } from "react-router";
|
||||
import { Outlet, useSubmit } from "react-router";
|
||||
import { useRef } from "react";
|
||||
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
|
||||
@@ -11,13 +11,17 @@ import TableSimple from "~/components/ui/tables/TableSimple";
|
||||
import { WorkflowDto } from "~/modules/workflowEngine/dtos/WorkflowDto";
|
||||
import { WorkflowsCredentialsApi } from "./credentials.api.server";
|
||||
import { appendCSRFToken } from "~/utils/csrf";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export const meta: MetaFunction = () => [{ title: i18nT("workflows.credentials.title") }];
|
||||
|
||||
export default function WorkflowsCredentialsView() {
|
||||
const data = useLoaderData<WorkflowsCredentialsApi.LoaderData>();
|
||||
const actionData = useActionData<WorkflowsCredentialsApi.ActionData>();
|
||||
const submit = useSubmit();
|
||||
|
||||
useSaveToast(actionData);
|
||||
|
||||
const confirmDelete = useRef<RefConfirmModal>(null);
|
||||
|
||||
function onDelete(item: WorkflowCredential) {
|
||||
@@ -59,7 +63,7 @@ export default function WorkflowsCredentialsView() {
|
||||
title: i18nT("workflows.columns.value"),
|
||||
name: "value",
|
||||
className: "w-full",
|
||||
value: (item) => <div className="max-w-sm truncate">{"".padEnd(36, "*")}</div>,
|
||||
value: (_item) => <div className="max-w-sm truncate">{"".padEnd(36, "*")}</div>,
|
||||
},
|
||||
{
|
||||
title: i18nT("shared.createdAt"),
|
||||
|
||||
+31
-14
@@ -1,5 +1,4 @@
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs, redirect } from "react-router";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
|
||||
import { createWorkflowCredential, getWorkflowCredentialByName } from "~/modules/workflowEngine/db/workflowCredentials.db.server";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import CryptoApi from "~/utils/api/.server/CryptoApi";
|
||||
@@ -7,10 +6,18 @@ import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsCredentialsNewApi {
|
||||
export type ActionData = {
|
||||
intent: "create";
|
||||
ok?: true;
|
||||
messageKey?: string;
|
||||
errorKey?: string;
|
||||
errorValues?: Readonly<Record<string, string>>;
|
||||
};
|
||||
|
||||
export type LoaderData = {
|
||||
metatags: MetaTagsDto;
|
||||
};
|
||||
@@ -35,15 +42,18 @@ export namespace WorkflowsCredentialsNewApi {
|
||||
let value = form.get("credential-value")?.toString() ?? "";
|
||||
|
||||
if (action === "create") {
|
||||
const existing = await getWorkflowCredentialByName(name, { tenantId });
|
||||
if (existing) {
|
||||
return Response.json(
|
||||
{
|
||||
intent: "create",
|
||||
errorKey: "workflows.errors.credentialAlreadyExists",
|
||||
errorValues: { value0: name },
|
||||
} satisfies ActionData,
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
try {
|
||||
const existing = await getWorkflowCredentialByName(name, { tenantId });
|
||||
if (existing) {
|
||||
throw Error(
|
||||
t("workflows.errors.credentialAlreadyExists", {
|
||||
value0: name,
|
||||
})
|
||||
);
|
||||
}
|
||||
value = CryptoApi.encrypt(value);
|
||||
await createWorkflowCredential({
|
||||
tenantId,
|
||||
@@ -51,9 +61,16 @@ export namespace WorkflowsCredentialsNewApi {
|
||||
name,
|
||||
value,
|
||||
});
|
||||
throw redirect(UrlUtils.getModulePath(params, `workflow-engine/credentials`));
|
||||
} catch (e: any) {
|
||||
return Response.json({ error: e.message }, { status: 400 });
|
||||
return Response.json({
|
||||
intent: "create",
|
||||
ok: true,
|
||||
messageKey: "workflows.toast.credentialCreated",
|
||||
} satisfies ActionData);
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ intent: "create", errorKey: "workflows.errors.credentialCreateFailed" } satisfies ActionData,
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
return Response.json({ error: t("workflows.errors.invalidAction") }, { status: 400 });
|
||||
|
||||
+15
-3
@@ -1,14 +1,26 @@
|
||||
import { useNavigate, useParams } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { useActionData, useNavigate, useParams } from "react-router";
|
||||
import { useEffect } from "react";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import WorkflowCredentialForm from "~/modules/workflowEngine/components/workflowVariables/WorkflowCredentialForm";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import SlideOverWideEmpty from "~/components/ui/slideOvers/SlideOverWideEmpty";
|
||||
import { WorkflowsCredentialsNewApi } from "./credentials.new.api.server";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export default function WorkflowsCredentialsNewView() {
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const actionData = useActionData<WorkflowsCredentialsNewApi.ActionData>();
|
||||
const listPath = UrlUtils.getModulePath(params, `workflow-engine/credentials`);
|
||||
|
||||
useSaveToast(actionData);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.ok) navigate(listPath);
|
||||
}, [actionData, listPath, navigate]);
|
||||
|
||||
function close() {
|
||||
navigate(UrlUtils.getModulePath(params, `workflow-engine/credentials`));
|
||||
navigate(listPath);
|
||||
}
|
||||
return (
|
||||
<SlideOverWideEmpty title={i18nT("workflows.credentials.newTitle")} className="sm:max-w-sm" open={true} onClose={close}>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsDangerApi {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { useActionData, useLoaderData, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { WorkflowsDangerApi } from "./danger.api.server";
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsExecutionsApi {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Link, useLoaderData, useNavigation, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useRef } from "react";
|
||||
import TenantBadge from "~/components/core/tenants/TenantBadge";
|
||||
import DateCell from "~/components/ui/dates/DateCell";
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { db } from "~/utils/db.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { countWorkflowExecutions } from "../../db/workflowExecutions.db.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
|
||||
export namespace WorkflowEngineIndexApi {
|
||||
export type LoaderData = {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { useLoaderData } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { WorkflowEngineIndexApi } from "./index.api.server";
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { localizeWorkflowTemplate } from "../../utils/workflowTemplateI18n";
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Form, Link, useActionData, useParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { useEffect, useState } from "react";
|
||||
import LoadingButton from "~/components/ui/buttons/LoadingButton";
|
||||
import InputText from "~/components/ui/input/InputText";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { getAllWorkflowVariables } from "~/modules/workflowEngine/db/workflowVar
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
|
||||
export namespace WorkflowsVariablesApi {
|
||||
export type LoaderData = {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Outlet, useLoaderData } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
|
||||
import DateCell from "~/components/ui/dates/DateCell";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
|
||||
+31
-6
@@ -7,10 +7,17 @@ import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsVariablesIdApi {
|
||||
export type ActionData = {
|
||||
intent: "edit" | "delete";
|
||||
ok?: true;
|
||||
messageKey?: string;
|
||||
errorKey?: string;
|
||||
};
|
||||
|
||||
export type LoaderData = {
|
||||
metatags: MetaTagsDto;
|
||||
item: WorkflowVariable;
|
||||
@@ -51,13 +58,31 @@ export namespace WorkflowsVariablesIdApi {
|
||||
tenantId,
|
||||
value,
|
||||
});
|
||||
throw redirect(UrlUtils.getModulePath(params, `workflow-engine/variables`));
|
||||
} catch (e: any) {
|
||||
return Response.json({ error: e.message }, { status: 400 });
|
||||
return Response.json({
|
||||
intent: "edit",
|
||||
ok: true,
|
||||
messageKey: "workflows.toast.variableSaved",
|
||||
} satisfies ActionData);
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ intent: "edit", errorKey: "workflows.errors.variableSaveFailed" } satisfies ActionData,
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
} else if (action === "delete") {
|
||||
await deleteWorkflowVariable(existing.id, { tenantId });
|
||||
throw redirect(UrlUtils.getModulePath(params, `workflow-engine/variables`));
|
||||
try {
|
||||
await deleteWorkflowVariable(existing.id, { tenantId });
|
||||
return Response.json({
|
||||
intent: "delete",
|
||||
ok: true,
|
||||
messageKey: "workflows.toast.variableDeleted",
|
||||
} satisfies ActionData);
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ intent: "delete", errorKey: "workflows.errors.variableDeleteFailed" } satisfies ActionData,
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
return Response.json({ error: t("workflows.errors.invalidAction") }, { status: 400 });
|
||||
};
|
||||
|
||||
+14
-3
@@ -1,16 +1,27 @@
|
||||
import { useLoaderData, useNavigate, useParams } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { useActionData, useLoaderData, useNavigate, useParams } from "react-router";
|
||||
import { useEffect } from "react";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import WorkflowVariableForm from "~/modules/workflowEngine/components/workflowVariables/WorkflowVariableForm";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import SlideOverWideEmpty from "~/components/ui/slideOvers/SlideOverWideEmpty";
|
||||
import { WorkflowsVariablesIdApi } from "./variables.$id.api.server";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export default function WorkflowsVariablesIdView() {
|
||||
const data = useLoaderData<WorkflowsVariablesIdApi.LoaderData>();
|
||||
const actionData = useActionData<WorkflowsVariablesIdApi.ActionData>();
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const listPath = UrlUtils.getModulePath(params, `workflow-engine/variables`);
|
||||
|
||||
useSaveToast(actionData);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.ok) navigate(listPath);
|
||||
}, [actionData, listPath, navigate]);
|
||||
|
||||
function close() {
|
||||
navigate(UrlUtils.getModulePath(params, `workflow-engine/variables`));
|
||||
navigate(listPath);
|
||||
}
|
||||
return (
|
||||
<SlideOverWideEmpty title={i18nT("workflows.variables.editTitle")} className="sm:max-w-sm" open={true} onClose={close}>
|
||||
|
||||
+31
-14
@@ -1,15 +1,22 @@
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs, redirect } from "react-router";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
|
||||
import { createWorkflowVariable, getWorkflowVariableByName } from "~/modules/workflowEngine/db/workflowVariable.db.server";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { requireWorkflowMutationAccess } from "../workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsVariablesNewApi {
|
||||
export type ActionData = {
|
||||
intent: "create";
|
||||
ok?: true;
|
||||
messageKey?: string;
|
||||
errorKey?: string;
|
||||
errorValues?: Readonly<Record<string, string>>;
|
||||
};
|
||||
|
||||
export type LoaderData = {
|
||||
metatags: MetaTagsDto;
|
||||
};
|
||||
@@ -34,24 +41,34 @@ export namespace WorkflowsVariablesNewApi {
|
||||
const value = form.get("value")?.toString() ?? "";
|
||||
|
||||
if (action === "create") {
|
||||
const existing = await getWorkflowVariableByName(name, { tenantId });
|
||||
if (existing) {
|
||||
return Response.json(
|
||||
{
|
||||
intent: "create",
|
||||
errorKey: "workflows.errors.variableAlreadyExists",
|
||||
errorValues: { value0: name },
|
||||
} satisfies ActionData,
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
try {
|
||||
const existing = await getWorkflowVariableByName(name, { tenantId });
|
||||
if (existing) {
|
||||
throw Error(
|
||||
t("workflows.errors.variableAlreadyExists", {
|
||||
value0: name,
|
||||
})
|
||||
);
|
||||
}
|
||||
await createWorkflowVariable({
|
||||
tenantId,
|
||||
createdByUserId: userInfo.userId,
|
||||
name,
|
||||
value,
|
||||
});
|
||||
throw redirect(UrlUtils.getModulePath(params, `workflow-engine/variables`));
|
||||
} catch (e: any) {
|
||||
return Response.json({ error: e.message }, { status: 400 });
|
||||
return Response.json({
|
||||
intent: "create",
|
||||
ok: true,
|
||||
messageKey: "workflows.toast.variableCreated",
|
||||
} satisfies ActionData);
|
||||
} catch {
|
||||
return Response.json(
|
||||
{ intent: "create", errorKey: "workflows.errors.variableCreateFailed" } satisfies ActionData,
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
return Response.json({ error: t("workflows.errors.invalidAction") }, { status: 400 });
|
||||
|
||||
+15
-3
@@ -1,14 +1,26 @@
|
||||
import { useNavigate, useParams } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { useActionData, useNavigate, useParams } from "react-router";
|
||||
import { useEffect } from "react";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import WorkflowVariableForm from "~/modules/workflowEngine/components/workflowVariables/WorkflowVariableForm";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import SlideOverWideEmpty from "~/components/ui/slideOvers/SlideOverWideEmpty";
|
||||
import { WorkflowsVariablesNewApi } from "./variables.new.api.server";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export default function WorkflowsVariablesNewView() {
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const actionData = useActionData<WorkflowsVariablesNewApi.ActionData>();
|
||||
const listPath = UrlUtils.getModulePath(params, `workflow-engine/variables`);
|
||||
|
||||
useSaveToast(actionData);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.ok) navigate(listPath);
|
||||
}, [actionData, listPath, navigate]);
|
||||
|
||||
function close() {
|
||||
navigate(UrlUtils.getModulePath(params, `workflow-engine/variables`));
|
||||
navigate(listPath);
|
||||
}
|
||||
return (
|
||||
<SlideOverWideEmpty title={i18nT("workflows.variables.newTitle")} className="sm:max-w-sm" open={true} onClose={close}>
|
||||
|
||||
+10
-6
@@ -506,9 +506,13 @@ describe("workflow producer inventory", () => {
|
||||
expect(eventsServiceSource).toContain("buildWorkflowTriggerOutboxEvent");
|
||||
expect(eventsServiceSource).toContain("sourceId: item.id");
|
||||
expect(eventsServiceSource).not.toContain('type: "workflow.trigger.event"');
|
||||
expect(eventsServiceSource.indexOf("const item = await tx.event.create")).toBeLessThan(
|
||||
eventsServiceSource.indexOf("await publishOutboxEvent(tx, buildWorkflowTriggerOutboxEvent")
|
||||
);
|
||||
const eventCreateIndex = eventsServiceSource.indexOf("(await tx.event.create({");
|
||||
const outboxBuildIndex = eventsServiceSource.indexOf("const outboxEvent = buildWorkflowTriggerOutboxEvent({");
|
||||
const outboxPublishIndex = eventsServiceSource.indexOf("await publishOutboxEvent(");
|
||||
expect(eventCreateIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(outboxBuildIndex).toBeGreaterThan(eventCreateIndex);
|
||||
expect(outboxPublishIndex).toBeGreaterThanOrEqual(0);
|
||||
expect(outboxBuildIndex).toBeLessThan(outboxPublishIndex);
|
||||
});
|
||||
|
||||
it("keeps the workflow outbox documentation honest after the entity-builder removal", () => {
|
||||
@@ -516,9 +520,9 @@ describe("workflow producer inventory", () => {
|
||||
const workerQueuesDoc = readSource(path.join(repoRoot, "docs/ops/worker-queues.md"));
|
||||
const workflowBlockSource = readSource(path.join(repoRoot, "apps/web/app/modules/workflowEngine/services/blocks/WorkflowBlockProService.ts"));
|
||||
|
||||
// R-P6B-β (AD-2): the generic entity-builder row.* outbox producers (RowsApi)
|
||||
// were removed; workflow row blocks address typed models through the typed
|
||||
// model registry. The docs must say so, not advertise the deleted producers.
|
||||
// R-P6B-β (AD-2): the generic entity-builder row.* outbox producers were
|
||||
// removed; workflow row blocks address typed models through the typed model
|
||||
// registry. The docs must say so, not advertise the deleted producers.
|
||||
expect(outboxDoc).toContain("removed with the entity-builder");
|
||||
expect(outboxDoc).toContain("the typed model registry");
|
||||
expect(outboxDoc).toContain("`row.*` outbox events");
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ function t(key: string, options?: Record<string, unknown>) {
|
||||
"workflows.errors.missingRequiredInputOnBlock": "Missing required input on block {{blockId}}: {{name}}",
|
||||
"workflows.errors.missingWorkflowCredential": "Missing workflow credential: {{name}}",
|
||||
"workflows.errors.missingWorkflowVariable": "Missing workflow variable: {{name}}",
|
||||
"workflows.errors.invalidManualValidationSchema": "Invalid manual trigger validation schema on block {{blockId}}: {{error}}",
|
||||
"workflows.errors.nativeCapabilityUnsupported": "Worker-native execution does not support this workflow yet: {{error}}",
|
||||
"workflows.errors.invalidManualValidationSchemaSummary": "The validation schema on manual trigger block {{blockId}} is invalid.",
|
||||
"workflows.errors.nativeCapabilityUnsupportedCredential": "Block {{blockId}} references credential {{credential}}, which worker execution cannot access.",
|
||||
"workflows.errors.preflightFailed": "Workflow preflight failed: {{errors}}",
|
||||
"workflows.errors.workflowContinueFailed": "Workflow continuation failed. Check the execution input and try again.",
|
||||
"workflows.errors.workflowRunFailed": "Workflow run failed. Check the workflow setup and try again.",
|
||||
@@ -43,7 +43,7 @@ describe("workflow run action errors", () => {
|
||||
});
|
||||
|
||||
expect(formatWorkflowRunActionError(t, preflightError, "run")).toBe(
|
||||
'Workflow preflight failed: Missing workflow variable: recipient; Missing workflow credential: mail; Missing required input on block email: body; Invalid manual trigger validation schema on block manual: Expected property name; Worker-native execution does not support this workflow yet: unsupported credential reference "mail" on block email'
|
||||
"Workflow preflight failed: Missing workflow variable: recipient; Missing workflow credential: mail; Missing required input on block email: body; The validation schema on manual trigger block manual is invalid.; Block email references credential mail, which worker execution cannot access."
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
+3
-16
@@ -1,5 +1,6 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type { WorkflowPreflightResult } from "../../services/WorkflowPreflightService";
|
||||
import { formatWorkflowInvalidSchemaText, formatWorkflowNativeCapabilityErrorText } from "../../utils/workflowPreflightErrorText";
|
||||
|
||||
export function workflowActionText(t: TFunction, key: string, fallback: string, values?: Record<string, unknown>) {
|
||||
const translated = t(key, { defaultValue: fallback, ...(values ?? {}) });
|
||||
@@ -39,24 +40,10 @@ function formatPreflightError(t: TFunction, preflight: Partial<WorkflowPreflight
|
||||
)
|
||||
: []),
|
||||
...(isValidationSchemaIssueArray(preflight.invalidValidationSchemas)
|
||||
? preflight.invalidValidationSchemas.map((issue) =>
|
||||
workflowActionText(
|
||||
t,
|
||||
"workflows.errors.invalidManualValidationSchema",
|
||||
"Invalid manual trigger validation schema on block {{blockId}}: {{error}}",
|
||||
{
|
||||
blockId: issue.blockId,
|
||||
error: issue.error,
|
||||
}
|
||||
)
|
||||
)
|
||||
? preflight.invalidValidationSchemas.map((issue) => formatWorkflowInvalidSchemaText(t, issue.blockId))
|
||||
: []),
|
||||
...(isStringArray(preflight.nativeCapabilityErrors)
|
||||
? preflight.nativeCapabilityErrors.map((error) =>
|
||||
workflowActionText(t, "workflows.errors.nativeCapabilityUnsupported", "Worker-native execution does not support this workflow yet: {{error}}", {
|
||||
error,
|
||||
})
|
||||
)
|
||||
? preflight.nativeCapabilityErrors.map((error) => formatWorkflowNativeCapabilityErrorText(t, error))
|
||||
: []),
|
||||
];
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { requireWorkflowMutationAccess } from "./workflowAccess.server";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
export namespace WorkflowsIndexApi {
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
import { Link, Outlet, useActionData, useLoaderData, useParams, useSearchParams, useSubmit } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import TabsWithIcons from "~/components/ui/tabs/TabsWithIcons";
|
||||
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
|
||||
import PlusIcon from "~/components/ui/icons/PlusIcon";
|
||||
@@ -12,7 +12,7 @@ import ConfirmModal, { RefConfirmModal } from "~/components/ui/modals/ConfirmMod
|
||||
import { WorkflowDto } from "~/modules/workflowEngine/dtos/WorkflowDto";
|
||||
import { WorkflowsIndexApi } from "./workflows.index.api.server";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import toast from "react-hot-toast";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import TenantBadge from "~/components/core/tenants/TenantBadge";
|
||||
import { appendCSRFToken } from "~/utils/csrf";
|
||||
@@ -49,9 +49,9 @@ export default function WorkflowsIndexView() {
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.success) {
|
||||
toast.success(actionData.success, { position: "bottom-right" });
|
||||
toast.success(actionData.success);
|
||||
} else if (actionData?.error) {
|
||||
toast.error(actionData.error, { position: "bottom-right" });
|
||||
toast.error(actionData.error);
|
||||
}
|
||||
}, [actionData]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user