Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
805 changes: 41 additions & 764 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@eslint/js": "^10.0.1",
"@inlang/paraglide-js": "^2.22.0",
"@playwright/test": "^1.61.1",
"@sveltejs/adapter-node": "^5.5.7",
"@sveltejs/kit": "^2.63.0",
"@sveltejs/adapter-node": "^6.0.0",
"@sveltejs/kit": "^3.0.0",
"@sveltejs/vite-plugin-svelte": "^7.1.2",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@types/node": "^24.13.3",
Expand All @@ -36,8 +36,8 @@
"globals": "^17.6.0",
"prettier": "^3.8.3",
"prettier-plugin-svelte": "^4.1.0",
"svelte": "^5.56.1",
"svelte-check": "^4.6.0",
"svelte": "^5.57.1",
"svelte-check": "^4.7.5",
"typescript": "^6.0.3",
"typescript-eslint": "^8.60.1",
"vite": "^8.0.16",
Expand All @@ -48,5 +48,9 @@
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1",
"yaml": "^2.9.0"
},
"imports": {
"#lib": "./src/lib/index.js",
"#lib/*": "./src/lib/*"
}
}
16 changes: 9 additions & 7 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paraglideMiddleware } from '$lib/paraglide/server';
import type { Handle } from '@sveltejs/kit';
import { paraglideMiddleware } from '#lib/paraglide/server.js';
import type { Handle } from '@sveltejs/kit/hooks';

/**
* Resolve the request locale per DESIGN.md §6: server-side, from the browser's
Expand All @@ -24,10 +24,12 @@ import type { Handle } from '@sveltejs/kit';
* request-scoped via `AsyncLocalStorage`, so concurrent requests don't leak.
*/
export const handle: Handle = ({ event, resolve }) =>
paraglideMiddleware(event.request, ({ request, locale }) => {
event.request = request;
return resolve(event, {
// `event.request` is readonly in SvelteKit 3, so the middleware's request
// clone is not reassigned. With no `url` strategy it carries the same URL as
// the original; revisit this if a `url` strategy is ever added.
paraglideMiddleware(event.request, ({ locale }) =>
resolve(event, {
transformPageChunk: ({ html }) =>
html.replace('%paraglide.lang%', locale),
});
});
}),
);
4 changes: 2 additions & 2 deletions src/lib/components/Breadcrumb.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { ScopePath } from '$lib/graph/model';
import { m } from '$lib/paraglide/messages';
import type { ScopePath } from '#lib/graph/model.js';
import { m } from '#lib/paraglide/messages.js';

type Props = {
path: ScopePath;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Canvas.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { browser } from '$app/environment';
import type { FlowGraph } from '$lib/graph/model';
import { m } from '$lib/paraglide/messages';
import type { FlowGraph } from '#lib/graph/model.js';
import { m } from '#lib/paraglide/messages.js';
import { browser } from '$app/env';
import {
Background,
Controls,
Expand Down
10 changes: 5 additions & 5 deletions src/lib/components/Inspector.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import type { RenameOutcome } from '$lib/editor/commands';
import { containerField, isContainerKind } from '$lib/editor/drilldown';
import type { ScopeField, TaskKind } from '$lib/graph/model';
import { m } from '$lib/paraglide/messages';
import type { Task } from '$lib/types/zigflow';
import type { RenameOutcome } from '#lib/editor/commands.js';
import { containerField, isContainerKind } from '#lib/editor/drilldown.js';
import type { ScopeField, TaskKind } from '#lib/graph/model.js';
import { m } from '#lib/paraglide/messages.js';
import type { Task } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import CommonFieldsForm from './forms/CommonFieldsForm.svelte';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/NodePalette.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { TASK_KINDS } from '$lib/graph/model';
import type { TaskKind } from '$lib/graph/model';
import { m } from '$lib/paraglide/messages';
import { TASK_KINDS } from '#lib/graph/model.js';
import type { TaskKind } from '#lib/graph/model.js';
import { m } from '#lib/paraglide/messages.js';

import { DND_TASK_KIND_MIME } from './canvas';
import { kindLabel } from './labels';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/TaskNode.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { taskSubtitle } from '$lib/editor/subtitle';
import type { SubtitleDescriptor } from '$lib/editor/subtitle';
import { m } from '$lib/paraglide/messages';
import { taskSubtitle } from '#lib/editor/subtitle.js';
import type { SubtitleDescriptor } from '#lib/editor/subtitle.js';
import { m } from '#lib/paraglide/messages.js';
import { Handle, Position } from '@xyflow/svelte';
import { getContext } from 'svelte';

Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/WorkflowDetails.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import type { ZigflowDocumentMeta } from '$lib/types/zigflow';
import { m } from '#lib/paraglide/messages.js';
import type { ZigflowDocumentMeta } from '#lib/types/zigflow.js';

type Props = {
/** Routing/directory name — read-only, never a document field (DESIGN.md §6). */
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/CallForm.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import type { CallTask } from '$lib/types/zigflow';
import { m } from '#lib/paraglide/messages.js';
import type { CallTask } from '#lib/types/zigflow.js';

import CallHttpForm from './CallHttpForm.svelte';
import JsonFallbackForm from './JsonFallbackForm.svelte';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/forms/CallHttpForm.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { isInvalidJsonField } from '$lib/editor/formValues';
import { m } from '$lib/paraglide/messages';
import type { CallHttpTask } from '$lib/types/zigflow';
import { isInvalidJsonField } from '#lib/editor/formValues.js';
import { m } from '#lib/paraglide/messages.js';
import type { CallHttpTask } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import HttpMapField from './HttpMapField.svelte';
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/forms/CommonFieldsForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
thenOptions,
writeCommonFields,
writeThen,
} from '$lib/editor/commonFields';
import { isInvalidJsonField } from '$lib/editor/formValues';
import { m } from '$lib/paraglide/messages';
import type { Task } from '$lib/types/zigflow';
} from '#lib/editor/commonFields.js';
import { isInvalidJsonField } from '#lib/editor/formValues.js';
import { m } from '#lib/paraglide/messages.js';
import type { Task } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

let {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/ForForm.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import type { ForTask } from '$lib/types/zigflow';
import { m } from '#lib/paraglide/messages.js';
import type { ForTask } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import { readForForm, writeForTask } from './forForm';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/HttpMapField.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import { m } from '#lib/paraglide/messages.js';
import { untrack } from 'svelte';

import {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/forms/JsonFallbackForm.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { isContainerKind } from '$lib/editor/drilldown';
import { taskKind } from '$lib/graph/model';
import { m } from '$lib/paraglide/messages';
import type { Task } from '$lib/types/zigflow';
import { isContainerKind } from '#lib/editor/drilldown.js';
import { taskKind } from '#lib/graph/model.js';
import { m } from '#lib/paraglide/messages.js';
import type { Task } from '#lib/types/zigflow.js';

// Shared inspector fallback for task kinds without a dedicated form
// (DESIGN.md §6). A container kind (fork/try/do) shows the "open the
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/forms/SetForm.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { isInvalidJsonField } from '$lib/editor/formValues';
import { m } from '$lib/paraglide/messages';
import type { SetTask } from '$lib/types/zigflow';
import { isInvalidJsonField } from '#lib/editor/formValues.js';
import { m } from '#lib/paraglide/messages.js';
import type { SetTask } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/forms/SwitchForm.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { thenOptions } from '$lib/editor/commonFields';
import { m } from '$lib/paraglide/messages';
import type { SwitchTask } from '$lib/types/zigflow';
import { thenOptions } from '#lib/editor/commonFields.js';
import { m } from '#lib/paraglide/messages.js';
import type { SwitchTask } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import { readSwitchCases, writeSwitchTask } from './switchForm';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/WaitForm.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import type { WaitTask } from '$lib/types/zigflow';
import { m } from '#lib/paraglide/messages.js';
import type { WaitTask } from '#lib/types/zigflow.js';
import { untrack } from 'svelte';

import { readWaitForm, writeWaitTask } from './waitForm';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/callForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { CallTask } from '$lib/types/zigflow';
import type { CallTask } from '#lib/types/zigflow.js';

/**
* The call-wrapper logic for `CallForm.svelte` (DESIGN.md §6). `CallForm` picks a
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/forms/callHttpForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { formatJson, parseJsonField } from '$lib/editor/formValues';
import { endpointText } from '$lib/editor/subtitle';
import type { CallHttpTask, Endpoint } from '$lib/types/zigflow';
import { formatJson, parseJsonField } from '#lib/editor/formValues.js';
import { endpointText } from '#lib/editor/subtitle.js';
import type { CallHttpTask, Endpoint } from '#lib/types/zigflow.js';

/**
* Form ↔ task mapping for `call: http` (DESIGN.md §6), paired with
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/forForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { ForTask } from '$lib/types/zigflow';
import type { ForTask } from '#lib/types/zigflow.js';

/**
* Form ↔ task mapping for `for` (DESIGN.md §6), paired with `ForForm.svelte`.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/setForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { parseJsonField } from '$lib/editor/formValues';
import type { SetTask } from '$lib/types/zigflow';
import { parseJsonField } from '#lib/editor/formValues.js';
import type { SetTask } from '#lib/types/zigflow.js';

/**
* Form ↔ task mapping for `set` (DESIGN.md §6), paired with `SetForm.svelte`.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/switchForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { SwitchCase, SwitchTask } from '$lib/types/zigflow';
import type { SwitchCase, SwitchTask } from '#lib/types/zigflow.js';

/**
* Form ↔ task mapping for `switch` (DESIGN.md §6), paired with
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/taskForms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { TaskKind } from '$lib/graph/model';
import type { Task } from '$lib/types/zigflow';
import type { TaskKind } from '#lib/graph/model.js';
import type { Task } from '#lib/types/zigflow.js';
import type { Component } from 'svelte';

import CallForm from './CallForm.svelte';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/forms/waitForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { durationField, parseDurationField } from '$lib/editor/formValues';
import type { ExpressionDuration, WaitTask } from '$lib/types/zigflow';
import { durationField, parseDurationField } from '#lib/editor/formValues.js';
import type { ExpressionDuration, WaitTask } from '#lib/types/zigflow.js';

/**
* Form ↔ task mapping for `wait` (DESIGN.md §6), paired with `WaitForm.svelte`.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

// place files you want to import through the `$lib` alias in this folder.
// place files you want to import through the `#lib` alias in this folder.
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import favicon from '$lib/assets/favicon.svg';
import favicon from '#lib/assets/favicon.svg';

let { children } = $props();
</script>
Expand Down
28 changes: 15 additions & 13 deletions src/routes/api/workflows/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ensureTaskIds, syncWorkflowType } from '$lib/graph/mutations';
import { validateWorkflow } from '$lib/schema/validate';
import { workflowStore } from '$lib/server/store';
import { UnsafeWorkflowNameError } from '$lib/server/workflowStore';
import type { ZigflowWorkflow } from '$lib/types/zigflow';
import { json } from '@sveltejs/kit';
import { ensureTaskIds, syncWorkflowType } from '#lib/graph/mutations.js';
import { validateWorkflow } from '#lib/schema/validate.js';
import { workflowStore } from '#lib/server/store.js';
import { UnsafeWorkflowNameError } from '#lib/server/workflowStore.js';
import type { ZigflowWorkflow } from '#lib/types/zigflow.js';

import type { RequestHandler } from './$types';

Expand All @@ -44,7 +43,7 @@ export const GET: RequestHandler = async () => {
}
}),
);
return json({ workflows });
return Response.json({ workflows });
};

interface CreateBody {
Expand All @@ -66,15 +65,18 @@ export const POST: RequestHandler = async ({ request }) => {
try {
body = await request.json();
} catch {
return json(
return Response.json(
{ message: 'Request body must be valid JSON.' },
{ status: 400 },
);
}

const { name } = body;
if (typeof name !== 'string' || name === '') {
return json({ message: 'A workflow "name" is required.' }, { status: 400 });
return Response.json(
{ message: 'A workflow "name" is required.' },
{ status: 400 },
);
}

const taskQueue = typeof body.taskQueue === 'string' ? body.taskQueue : name;
Expand All @@ -86,12 +88,12 @@ export const POST: RequestHandler = async ({ request }) => {
exists = await workflowStore.exists(name);
} catch (err) {
if (err instanceof UnsafeWorkflowNameError) {
return json({ message: err.message }, { status: 400 });
return Response.json({ message: err.message }, { status: 400 });
}
throw err;
}
if (exists) {
return json(
return Response.json(
{ message: `A workflow named "${name}" already exists.` },
{ status: 409 },
);
Expand All @@ -106,12 +108,12 @@ export const POST: RequestHandler = async ({ request }) => {

const result = validateWorkflow(workflow);
if (!result.valid) {
return json(
return Response.json(
{ message: 'Workflow failed schema validation.', errors: result.errors },
{ status: 422 },
);
}

await workflowStore.save(name, workflow);
return json(workflow, { status: 201 });
return Response.json(workflow, { status: 201 });
};
Loading
Loading