Skip to content

Commit

Permalink
fix(admin): add flow graph tab to edit event admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea committed Oct 27, 2023
1 parent 9b570b2 commit bcc444e
Show file tree
Hide file tree
Showing 27 changed files with 498 additions and 143 deletions.
23 changes: 19 additions & 4 deletions packages/@liexp/backend/src/providers/fs/fs.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export interface FSClient {
) => TE.TaskEither<FSError, "valid" | "older" | "not-found">;
getObject: (filePath: string) => TE.TaskEither<FSError, string>;
writeObject: (filePath: string, data: string) => TE.TaskEither<FSError, void>;
deleteObject: (filePath: string) => TE.TaskEither<FSError, void>;
deleteObject: (
filePath: string,
throwIfNoExists?: boolean,
) => TE.TaskEither<FSError, void>;
getOlderThanOr: (
filePath: string,
time?: number,
Expand Down Expand Up @@ -124,11 +127,23 @@ export const GetFSClient = (): FSClient => {
olderThan,
writeObject,
getObject,
deleteObject: (filePath) => {
deleteObject: (filePath, throwIfNoExists) => {
fsLogger.debug.log("Deleting object at path %s", filePath);
return pipe(
TE.fromIO(() => {
fs.rmSync(filePath);
objectExists(filePath),
TE.chain((exists) => {
if (exists) {
return TE.fromIO(() => {
fs.rmSync(filePath);
});
} else {
if (throwIfNoExists) {
return TE.left(
toFSError(new Error(`File ${filePath} don't exists.`)),
);
}
return TE.right(undefined);
}
}),
);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/@liexp/core/src/fp/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as A from "fp-ts/Array";
import * as E from "fp-ts/Either";
import * as Eq from 'fp-ts/Eq'
import * as IOE from "fp-ts/IOEither";
import * as Json from "fp-ts/Json";
import * as Map from "fp-ts/Map";
Expand Down Expand Up @@ -27,6 +28,7 @@ export const fp = {
N,
Ord,
Json,
Eq
};

export { pipe, flow };
8 changes: 4 additions & 4 deletions packages/@liexp/shared/src/endpoints/Network.endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as t from "io-ts";
import { UUID } from "io-ts-types/UUID";
import { optionFromNullable } from "io-ts-types/lib/optionFromNullable";
import { Endpoint } from "ts-endpoint";
import { ListOutput, Output } from "../io/http/Common/Output";
import {
Expand Down Expand Up @@ -49,11 +50,10 @@ export const Get = Endpoint({

export const Edit = Endpoint({
Method: "PUT",
getPath: ({ id }) => `/networks/${id}`,
getPath: ({ type, id }) => `/networks/${type}/${id}`,
Input: {
Query: undefined,
Params: t.type({ id: UUID }),
Body: t.unknown,
Params: t.type({...GetNetworkParams.props, id: UUID }),
Body: t.strict({ regenerate: optionFromNullable(t.boolean) }),
},
Output: SingleOutput,
});
Expand Down
13 changes: 13 additions & 0 deletions packages/@liexp/shared/src/endpoints/graph.endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ export const GetFlowGraph = Endpoint({
Output: t.strict({ data: FlowGraphOutput }),
});

export const EditFlowGraph = Endpoint({
Method: "PUT",
getPath: ({ id, type }) => `/graphs/flows/${type}/${id}`,
Input: {
Params: GetFlowGraphParams,
Body: t.strict({
regenerate: t.boolean
})
},
Output: t.strict({ data: FlowGraphOutput }),
});

export const ListGraphs = Endpoint({
Method: "GET",
getPath: () => `/graphs`,
Expand Down Expand Up @@ -78,5 +90,6 @@ export const graphs = ResourceEndpoints({
Delete: DeleteGraph,
Custom: {
GetGraphByType: GetFlowGraph,
EditFlowGraph,
},
});
Loading

0 comments on commit bcc444e

Please sign in to comment.