Skip to content
Open

test #58

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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
# Nix
/.direnv/

.env.local
.env.local
.vercel
.env*.local
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts=true
1 change: 1 addition & 0 deletions .pnpmrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts: true
1 change: 1 addition & 0 deletions examples/nextjs-blog-cms/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts=true
29 changes: 19 additions & 10 deletions examples/nextjs-blog-cms/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"use server";

import { inngest } from "@/lib/inngest/client";
import { Json } from "@/lib/supabase/database.types";
import { createClient } from "@/lib/supabase/server";
import { type Workflow } from "@/lib/supabase/types";

export const sendBlogPostToReview = async (id: string) => {
const supabase = createClient();
await supabase
const supabase = await createClient();

await (supabase as any)
.from("blog_posts")
.update({
status: "under review",
Expand All @@ -32,8 +34,9 @@ export const approveBlogPostAiSuggestions = async (id: string) => {
};

export const publishBlogPost = async (id: string) => {
const supabase = createClient();
await supabase
const supabase = await createClient();

await (supabase as any)
.from("blog_posts")
.update({
status: "published",
Expand All @@ -48,23 +51,29 @@ export const publishBlogPost = async (id: string) => {
},
});
};

export const updateWorkflow = async (workflow: Workflow) => {
const supabase = createClient();
await supabase
const supabase = await createClient();

await (supabase as any)
.from("workflows")
.update({
workflow: workflow.workflow as unknown as Json,
})
.eq("id", workflow.id);
};

export const toggleWorkflow = async (workflowId: number, enabled: boolean) => {
const supabase = createClient();
await supabase
export const toggleWorkflow = async (
workflowId: number,
enabled: boolean
) => {
const supabase = await createClient();

await (supabase as any)
.from("workflows")
.update({
enabled,
})
.eq("id", workflowId)
.select("*");
};
};
8 changes: 6 additions & 2 deletions examples/nextjs-blog-cms/app/api/blog-posts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { createClient } from "@/lib/supabase/server";
import { NextResponse } from "next/server";

export async function GET() {
const supabase = createClient();
const { data: blogPosts } = await supabase
const supabase = await createClient();
const { data: blogPosts, error } = await supabase
.from("blog_posts")
.select(
"id, title, subtitle, markdown_ai_revision, created_at, status, markdown, ai_publishing_recommendations"
)
.order("created_at", { ascending: false });

if (error) {
return NextResponse.json({ error: error.message }, { status: 500 });
}

return NextResponse.json({ blogPosts });
}
2 changes: 1 addition & 1 deletion examples/nextjs-blog-cms/app/api/workflows/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createClient } from "@/lib/supabase/server";
import { NextResponse } from "next/server";

export async function GET() {
const supabase = createClient();
const supabase = await createClient();
const { data: workflows } = await supabase
.from("workflows")
.select("*")
Expand Down
3 changes: 1 addition & 2 deletions examples/nextjs-blog-cms/app/automation/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { AutomationEditor } from "@/components/automation-editor";
import { createClient } from "@/lib/supabase/server";
import { notFound } from "next/navigation";

export const runtime = "edge";

export default async function Automation({
params,
}: {
params: { id: string };
}) {
const supabase = createClient();
const supabase = await createClient();
const { data: workflow } = await supabase
.from("workflows")
.select("*")
Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-blog-cms/components/automation-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
import { updateWorkflow } from "@/app/actions";
import { actions } from "@/lib/inngest/workflowActions";

import "@inngest/workflow-kit/ui/ui.css";
import "@xyflow/react/dist/style.css";
// import "@inngest/workflow-kit/ui/ui.css";
// import "@xyflow/react/dist/style.css";

export const AutomationEditor = ({ workflow }: { workflow: Workflow }) => {
const router = useRouter();
Expand Down
36 changes: 18 additions & 18 deletions examples/nextjs-blog-cms/lib/inngest/workflowActionHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import OpenAI from "openai";
import { type BlogPost } from "../supabase/types";

import { loadBlogPost } from "../loaders/blog-post";
import { createClient } from "../supabase/server";
import { createClient } from "../supabase/service";
import { actions } from "./workflowActions";
import { inngest } from "./client";

Expand All @@ -28,7 +28,7 @@ function addAiPublishingSuggestion(
: blogPost.ai_publishing_recommendations + `<br/ >` + additionalSuggestion; // otherwise add one
}

export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
export const actionsWithHandlers: EngineAction<any>[] = [
{
// Add a Table of Contents
...actions[0],
Expand Down Expand Up @@ -71,8 +71,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
});

await step.run("save-ai-revision", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
markdown_ai_revision: aiRevision,
status: "under review",
Expand Down Expand Up @@ -124,8 +124,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
});

await step.run("save-ai-revision", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
markdown_ai_revision: aiRevision,
status: "under review",
Expand All @@ -146,8 +146,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
);

await step.run("update-blog-post-status", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
status: "needs approval",
})
Expand All @@ -168,8 +168,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
// without action from the user within 1 day, the AI suggestions are discarded
if (!approval) {
await step.run("discard-ai-revision", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
markdown_ai_revision: null,
status: "draft",
Expand All @@ -179,8 +179,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
});
} else {
await step.run("apply-ai-revision", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
markdown: blogPost.markdown_ai_revision,
markdown_ai_revision: null,
Expand All @@ -203,8 +203,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
);

await step.run("apply-ai-revision", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
markdown: blogPost.markdown_ai_revision,
markdown_ai_revision: null,
Expand Down Expand Up @@ -261,8 +261,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
);

await step.run("save-ai-recommendations", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
ai_publishing_recommendations: addAiPublishingSuggestion(
workflowAction,
Expand Down Expand Up @@ -320,8 +320,8 @@ export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
});

await step.run("save-ai-recommendations", async () => {
await supabase
.from("blog_posts")
await (supabase as any)
.from("blog_posts")
.update({
ai_publishing_recommendations: addAiPublishingSuggestion(
workflowAction,
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-blog-cms/lib/loaders/blog-post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createClient } from "../supabase/server";
import { createClient } from "../supabase/service";
import { BlogPost } from "../supabase/types";

export async function loadBlogPost(id: string): Promise<BlogPost> {
Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-blog-cms/lib/loaders/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Workflow } from "@inngest/workflow-kit";

import { createClient } from "../supabase/server";
import { createClient } from "../supabase/service";

export async function loadWorkflow(event: { name: string }) {
const supabase = createClient();
Expand All @@ -10,5 +10,5 @@ export async function loadWorkflow(event: { name: string }) {
.eq("trigger", event.name)
.eq("enabled", true)
.single();
return (data && data.workflow) as unknown as Workflow;
return (data as any)?.workflow as Workflow;
}
Loading