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
+2
-2
@@ -186,7 +186,7 @@ describe("WorkflowPreflightService", () => {
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.invalidValidationSchemas).toHaveLength(1);
|
||||
expect(result.invalidValidationSchemas[0]).toMatchObject({ blockId: "manual_1" });
|
||||
expect(result.errors[0]).toContain("Invalid manual trigger validation schema on block manual_1:");
|
||||
expect(result.errors[0]).toBe("The manual trigger validation schema is invalid.");
|
||||
});
|
||||
|
||||
it("reports worker-native credential references as capability errors", async () => {
|
||||
@@ -229,7 +229,7 @@ describe("WorkflowPreflightService", () => {
|
||||
});
|
||||
|
||||
expect(result.nativeCapabilityErrors).toEqual(['unsupported credential reference "apiBase" on block http']);
|
||||
expect(result.errors).toContain('Worker-native execution does not support this workflow yet: unsupported credential reference "apiBase" on block http');
|
||||
expect(result.errors).toContain("At least one block uses credentials that are not supported by worker-native execution.");
|
||||
});
|
||||
|
||||
it("reports worker-native if edge shape errors before queueing manual execution", async () => {
|
||||
|
||||
+4
-8
@@ -1,7 +1,8 @@
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { getNativeWorkflowTriggerCapabilityErrors } from "@hivegrid/foundation";
|
||||
import { WorkflowDto } from "../dtos/WorkflowDto";
|
||||
import { preflightWorkflow, type WorkflowRequiredInputIssue } from "../helpers/WorkflowReferenceUtils";
|
||||
import { formatWorkflowInvalidSchemaText, formatWorkflowNativeCapabilityErrorText } from "../utils/workflowPreflightErrorText";
|
||||
import WorkflowVariablesAndCredentialsService from "./WorkflowVariablesAndCredentialsService";
|
||||
import WorkflowsValidationService from "./WorkflowsValidationService";
|
||||
|
||||
@@ -44,13 +45,8 @@ function formatMissingReferences({
|
||||
})
|
||||
)
|
||||
),
|
||||
...invalidValidationSchemas.map((issue) =>
|
||||
i18nT("workflows.errors.invalidManualValidationSchema", {
|
||||
blockId: issue.blockId,
|
||||
error: issue.error,
|
||||
})
|
||||
),
|
||||
...nativeCapabilityErrors.map((error) => i18nT("workflows.errors.nativeCapabilityUnsupported", { error })),
|
||||
...invalidValidationSchemas.map((issue) => formatWorkflowInvalidSchemaText(i18nT, issue.blockId)),
|
||||
...nativeCapabilityErrors.map((error) => formatWorkflowNativeCapabilityErrorText(i18nT, error)),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -545,7 +545,7 @@ async function stream(
|
||||
status: "error",
|
||||
output: "{}",
|
||||
duration: 0,
|
||||
error: error instanceof Error ? error.message : "Workflow stream execution failed.",
|
||||
error: error instanceof Error ? error.message : "workflows.executionErrors.streamFailed",
|
||||
waitingBlockId: null,
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ const source = fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.
|
||||
|
||||
describe("WorkflowsService DTO conversion", () => {
|
||||
it("does not repair missing condition groups with database writes during reads", () => {
|
||||
const workflowToDtoBody = source.slice(source.indexOf("async function workflowToDto"), source.indexOf("async function addConditionGroup"));
|
||||
const workflowToDtoBody = source.slice(source.indexOf("async function workflowToDto"), source.indexOf("async function update("));
|
||||
|
||||
expect(workflowToDtoBody).not.toContain("await addConditionGroup");
|
||||
expect(workflowToDtoBody).not.toContain("db.workflowBlockConditionGroup.create");
|
||||
@@ -17,7 +17,7 @@ describe("WorkflowsService DTO conversion", () => {
|
||||
|
||||
describe("WorkflowsService tenant scope guards", () => {
|
||||
it("keeps workflow child mutations scoped through the parent workflow tenant", () => {
|
||||
expect(source).toContain("updateWorkflowBlock({ id, workflowId: workflow.id, tenantId: workflow.tenantId }");
|
||||
expect(source).toMatch(/updateWorkflowBlock\(\s*\{\s*id,\s*workflowId:\s*workflow\.id,\s*tenantId:\s*workflow\.tenantId\s*\}/);
|
||||
expect(source).toContain("createInputExample({ workflowId, tenantId, title, input }");
|
||||
expect(source).toContain("updateInputExample(scope: { id: string; workflowId: string; tenantId: string | null }");
|
||||
expect(source).toContain("deleteInputExample(scope: { id: string; workflowId: string; tenantId: string | null }");
|
||||
|
||||
+45
-55
@@ -20,7 +20,7 @@ import { getWorkflowExecution, getWorkflowExecutions } from "../db/workflowExecu
|
||||
import { getAllWorkflowVariables } from "../db/workflowVariable.db.server";
|
||||
import { getAllWorkflowCredentials } from "../db/workflowCredentials.db.server";
|
||||
import WorkflowBlockUtils from "../helpers/WorkflowBlockUtils";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import {
|
||||
PLUGIN_HOOK_WORKFLOW_CREATED,
|
||||
PLUGIN_HOOK_WORKFLOW_DELETED,
|
||||
@@ -160,34 +160,6 @@ async function workflowToDto(
|
||||
return workflow;
|
||||
}
|
||||
|
||||
async function addConditionGroup(workflowBlock: WorkflowBlockDto, workflow: WorkflowDto, data: WorkflowConditionsGroupDto[]) {
|
||||
await requireWorkflowBlocksInWorkflow({ workflowId: workflow.id, tenantId: workflow.tenantId }, [workflowBlock.id]);
|
||||
return await Promise.all(
|
||||
data.map(async (conditionGroup) => {
|
||||
const conditions = conditionGroup.conditions.map((condition) => {
|
||||
return {
|
||||
index: condition.index,
|
||||
variable: condition.variable,
|
||||
operator: condition.operator,
|
||||
value: condition.value,
|
||||
};
|
||||
});
|
||||
await db.workflowBlockConditionGroup.create({
|
||||
data: {
|
||||
workflowBlockId: workflowBlock.id,
|
||||
index: conditionGroup.index,
|
||||
type: conditionGroup.type,
|
||||
conditions: {
|
||||
create: conditions,
|
||||
},
|
||||
},
|
||||
});
|
||||
workflowBlock.conditionGroups.push(conditionGroup);
|
||||
return conditionGroup;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
async function update(
|
||||
id: string,
|
||||
workflow: {
|
||||
@@ -210,11 +182,14 @@ async function update(
|
||||
}
|
||||
const changedFields = getChangedWorkflowFields(item, workflow);
|
||||
|
||||
const updatedItem = await updateWorkflow({ id, tenantId: session.tenantId }, {
|
||||
name: workflow.name,
|
||||
description: workflow.description,
|
||||
status: workflow.status,
|
||||
});
|
||||
const updatedItem = await updateWorkflow(
|
||||
{ id, tenantId: session.tenantId },
|
||||
{
|
||||
name: workflow.name,
|
||||
description: workflow.description,
|
||||
status: workflow.status,
|
||||
}
|
||||
);
|
||||
await emitWorkflowDefinitionHook(PLUGIN_HOOK_WORKFLOW_UPDATED, updatedItem, {
|
||||
userId: session.userId ?? null,
|
||||
changedFields,
|
||||
@@ -343,23 +318,29 @@ function toWorkflowDefinitionHookStatus(status: string): PluginHookWorkflowDefin
|
||||
|
||||
async function updateBlock(id: string, block: WorkflowBlockDto, { workflow, userId = null }: { workflow: WorkflowDto; userId?: string | null }) {
|
||||
const changedFields = ["blocks"];
|
||||
const item = await updateWorkflowBlock({ id, workflowId: workflow.id, tenantId: workflow.tenantId }, {
|
||||
type: block.type,
|
||||
input: JSON.stringify(block.input),
|
||||
description: block.description,
|
||||
isTrigger: block.isTrigger,
|
||||
isBlock: block.isBlock,
|
||||
// positionX: block.position.x,
|
||||
// positionY: block.position.y,
|
||||
});
|
||||
const item = await updateWorkflowBlock(
|
||||
{ id, workflowId: workflow.id, tenantId: workflow.tenantId },
|
||||
{
|
||||
type: block.type,
|
||||
input: JSON.stringify(block.input),
|
||||
description: block.description,
|
||||
isTrigger: block.isTrigger,
|
||||
isBlock: block.isBlock,
|
||||
// positionX: block.position.x,
|
||||
// positionY: block.position.y,
|
||||
}
|
||||
);
|
||||
if (workflow.tenantId === null) {
|
||||
await updateWorkflowApplyToAllTenants(item.workflowId, workflow.tenantId);
|
||||
}
|
||||
if (block.type === "event" && block.input.event) {
|
||||
if (isGeneratedUntitledWorkflowName(workflow.name)) {
|
||||
await updateWorkflow({ id: item.workflowId, tenantId: workflow.tenantId }, {
|
||||
name: `${GENERATED_APP_EVENT_WORKFLOW_PREFIX}: ${block.input.event}`,
|
||||
});
|
||||
await updateWorkflow(
|
||||
{ id: item.workflowId, tenantId: workflow.tenantId },
|
||||
{
|
||||
name: `${GENERATED_APP_EVENT_WORKFLOW_PREFIX}: ${block.input.event}`,
|
||||
}
|
||||
);
|
||||
changedFields.push("name");
|
||||
}
|
||||
}
|
||||
@@ -459,14 +440,20 @@ async function updateWorkflowApplyToAllTenants(workflowId: string, tenantId: str
|
||||
appliesToAllTenants = true;
|
||||
}
|
||||
});
|
||||
const item = await updateWorkflow({ id: workflowId, tenantId }, {
|
||||
appliesToAllTenants,
|
||||
});
|
||||
const item = await updateWorkflow(
|
||||
{ id: workflowId, tenantId },
|
||||
{
|
||||
appliesToAllTenants,
|
||||
}
|
||||
);
|
||||
if (item.tenantId && item.appliesToAllTenants) {
|
||||
// just for good measure
|
||||
await updateWorkflow({ id: workflowId, tenantId: item.tenantId }, {
|
||||
appliesToAllTenants: false,
|
||||
});
|
||||
await updateWorkflow(
|
||||
{ id: workflowId, tenantId: item.tenantId },
|
||||
{
|
||||
appliesToAllTenants: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@@ -621,9 +608,12 @@ async function emitWorkflowBuilderMutationHook(
|
||||
if (!workflow.tenantId) {
|
||||
return;
|
||||
}
|
||||
const updatedWorkflow = await updateWorkflow({ id: workflow.id, tenantId: workflow.tenantId }, {
|
||||
status: workflow.status,
|
||||
});
|
||||
const updatedWorkflow = await updateWorkflow(
|
||||
{ id: workflow.id, tenantId: workflow.tenantId },
|
||||
{
|
||||
status: workflow.status,
|
||||
}
|
||||
);
|
||||
await emitWorkflowDefinitionHook(PLUGIN_HOOK_WORKFLOW_UPDATED, updatedWorkflow, {
|
||||
userId,
|
||||
changedFields,
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseVariable } from "./WorkflowsVariablesService";
|
||||
|
||||
describe("parseVariable", () => {
|
||||
it("fails malformed templates with a translatable execution error", () => {
|
||||
expect(() => parseVariable("{{#if active}}", { active: true })).toThrow("workflows.executionErrors.variableParsingFailed");
|
||||
});
|
||||
});
|
||||
+2
-2
@@ -74,7 +74,7 @@ export function parseVariable(value: string | null, workflowContext: { [key: str
|
||||
result = JSON.stringify(result);
|
||||
}
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
return "Error parsing string: " + e.message;
|
||||
} catch {
|
||||
throw new Error("workflows.executionErrors.variableParsingFailed");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -99,12 +99,12 @@ describe("WorkflowBlockProService row blocks (typed model registry)", () => {
|
||||
expect(result.output).toEqual({ row: { id: "k-deleted" } });
|
||||
});
|
||||
|
||||
test("an unaddressable model yields a Klartext error, not a silent fail", async () => {
|
||||
test("an unaddressable model yields a translatable error, not a silent fail", async () => {
|
||||
const result = await WorkflowBlockProService.executeBlock(
|
||||
params(block({ type: "rowCreate", input: { entity: "projekt", row: JSON.stringify({}) } }))
|
||||
);
|
||||
expect(result.throwsError).toBe(true);
|
||||
expect(result.error).toContain("projekt");
|
||||
expect(result.error).toBe("workflows.errors.unknownModel");
|
||||
expect(mocks.adapter.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -114,6 +114,6 @@ describe("WorkflowBlockProService row blocks (typed model registry)", () => {
|
||||
params(block({ type: "rowCreate", input: { entity: "kontakt", row: JSON.stringify({ vorname: "Max" }) } }))
|
||||
);
|
||||
expect(result.throwsError).toBe(true);
|
||||
expect(result.error).toContain("kontaktTyp");
|
||||
expect(result.error).toBe("workflows.errors.invalidFieldValue");
|
||||
});
|
||||
});
|
||||
+20
-13
@@ -7,9 +7,11 @@ import { TypedModelError, type ModelCtx, type TypedModelAdapter } from "~/servic
|
||||
import EmailService from "~/modules/emails/services/EmailService.server";
|
||||
import { WorkflowBlockType } from "../../dtos/WorkflowBlockTypes";
|
||||
|
||||
// AD-2 / R-P14D: the row* blocks address a TYPED model from the registry
|
||||
const WORKFLOW_INVALID_INPUT_ERROR_KEY = "workflows.executionErrors.invalidInput";
|
||||
|
||||
// AD-2 / R-P14D: the row* blocks address a typed model from the registry
|
||||
// (Kontakt today; the kern chain registers more) instead of resolving a generic
|
||||
// entity by name and CRUDing through the polymorphic RowsApi. The block JSON keeps
|
||||
// entity by name and CRUDing through the removed polymorphic row store. The block JSON keeps
|
||||
// `entity: "<key>"`, but the key now resolves to a typed adapter; an unaddressable
|
||||
// key surfaces as a Klartext error (M002), never a silent fail.
|
||||
|
||||
@@ -18,7 +20,7 @@ function resolveModel(entityName: string): { adapter: TypedModelAdapter } | { er
|
||||
try {
|
||||
return { adapter: getModelAdapterOrThrow(entityName) };
|
||||
} catch (error) {
|
||||
if (error instanceof TypedModelError) return { error: error.message };
|
||||
if (error instanceof TypedModelError) return { error: error.messageKey };
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -76,15 +78,15 @@ async function executeRowGetBlock({ block, workflowContext, session }: BlockExec
|
||||
}
|
||||
);
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
const resolved = resolveModel(entityName);
|
||||
if ("error" in resolved) {
|
||||
return { output: null, error: resolved.error, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
|
||||
// read() returns null when the record is absent/not visible (parity with the
|
||||
// old RowsApi.get(...).catch(() => null)).
|
||||
// read() returns null when the record is absent/not visible; writes still
|
||||
// surface typed model errors explicitly.
|
||||
const row = await resolved.adapter.read(id, modelCtx(session)).catch(() => null);
|
||||
|
||||
return {
|
||||
@@ -110,7 +112,7 @@ async function executeRowCreateBlock({ block, workflowContext, session }: BlockE
|
||||
}
|
||||
);
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
const resolved = resolveModel(entityName);
|
||||
if ("error" in resolved) {
|
||||
@@ -124,7 +126,7 @@ async function executeRowCreateBlock({ block, workflowContext, session }: BlockE
|
||||
};
|
||||
} catch (e) {
|
||||
if (e instanceof TypedModelError) {
|
||||
return { output: null, error: e.message, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: e.messageKey, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -149,7 +151,7 @@ async function executeRowUpdateBlock({ block, workflowContext, session }: BlockE
|
||||
}
|
||||
);
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
const resolved = resolveModel(entityName);
|
||||
if ("error" in resolved) {
|
||||
@@ -163,7 +165,7 @@ async function executeRowUpdateBlock({ block, workflowContext, session }: BlockE
|
||||
};
|
||||
} catch (e) {
|
||||
if (e instanceof TypedModelError) {
|
||||
return { output: null, error: e.message, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: e.messageKey, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -186,7 +188,7 @@ async function executeRowDeleteBlock({ block, workflowContext, session }: BlockE
|
||||
}
|
||||
);
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
const resolved = resolveModel(entityName);
|
||||
if ("error" in resolved) {
|
||||
@@ -201,11 +203,16 @@ async function executeRowDeleteBlock({ block, workflowContext, session }: BlockE
|
||||
toBlockIds: block.toBlocks.map((f) => f.toBlockId),
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { output: null, error: e.message, throwsError: true, toBlockIds: block.toBlocks.map((f) => f.toBlockId) };
|
||||
return {
|
||||
output: null,
|
||||
error: e instanceof TypedModelError ? e.messageKey : e.message,
|
||||
throwsError: true,
|
||||
toBlockIds: block.toBlocks.map((f) => f.toBlockId),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function executeEmailBlock({ block, workflowContext, session }: BlockExecutionParamsDto): Promise<BlockExecutionResultDto> {
|
||||
async function executeEmailBlock({ block, workflowContext, session: _session }: BlockExecutionParamsDto): Promise<BlockExecutionResultDto> {
|
||||
const provider = parseVariable(block.input.provider, workflowContext);
|
||||
const to = parseVariable(block.input.to, workflowContext)!;
|
||||
const subject = parseVariable(block.input.subject, workflowContext)!;
|
||||
|
||||
+2
-2
@@ -517,13 +517,13 @@ describe("WorkflowBlockService.execute", () => {
|
||||
fromBlock: null,
|
||||
session,
|
||||
})
|
||||
).rejects.toThrow(/Expected property name|JSON/u);
|
||||
).rejects.toThrow("workflows.executionErrors.invalidValidationSchema");
|
||||
|
||||
expect(mocks.updateBlockExecution).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
status: "error",
|
||||
error: expect.any(String),
|
||||
error: "workflows.executionErrors.invalidValidationSchema",
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
+6
-4
@@ -18,6 +18,8 @@ import { fetchOutboundHttpWithRedirects, readLimitedResponseText, type OutboundH
|
||||
|
||||
const MAX_WORKFLOW_EXECUTION_DEPTH = 200;
|
||||
const WORKFLOW_HTTP_RESPONSE_BODY_LIMIT_BYTES = 16_384;
|
||||
const WORKFLOW_INVALID_INPUT_ERROR_KEY = "workflows.executionErrors.invalidInput";
|
||||
const WORKFLOW_INVALID_VALIDATION_SCHEMA_ERROR_KEY = "workflows.executionErrors.invalidValidationSchema";
|
||||
export const CORE_WORKFLOW_BLOCK_TYPES = [
|
||||
"manual",
|
||||
"doNothing",
|
||||
@@ -207,7 +209,7 @@ async function executeManualBlock({ block, workflowContext }: BlockExecutionPara
|
||||
if (block.input.validation) {
|
||||
const parsed = WorkflowsValidationService.parseJsonSchema(block.input.validation);
|
||||
if (parsed.error) {
|
||||
return { output: null, error: parsed.error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_VALIDATION_SCHEMA_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
if (parsed.schema === null) {
|
||||
return {
|
||||
@@ -217,7 +219,7 @@ async function executeManualBlock({ block, workflowContext }: BlockExecutionPara
|
||||
}
|
||||
const error = WorkflowsValidationService.validate(workflowContext["$params"], parsed.schema);
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
block.input.validation = undefined;
|
||||
}
|
||||
@@ -469,7 +471,7 @@ async function executeEventBlock({ block, workflowContext }: BlockExecutionParam
|
||||
required: ["data"],
|
||||
});
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
|
||||
if (["row.created", "row.updated", "row.deleted"].includes(block.input.event)) {
|
||||
@@ -484,7 +486,7 @@ async function executeEventBlock({ block, workflowContext }: BlockExecutionParam
|
||||
required: ["id", "title", "row", "entity"],
|
||||
});
|
||||
if (error) {
|
||||
return { output: null, error, throwsError: true, toBlockIds: [] };
|
||||
return { output: null, error: WORKFLOW_INVALID_INPUT_ERROR_KEY, throwsError: true, toBlockIds: [] };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user