Skip to content

Commit

Permalink
fix(examples): typing fixes + pnpm setup
Browse files Browse the repository at this point in the history
  • Loading branch information
charlypoly committed Sep 27, 2024
1 parent d1bfa1d commit af7fabe
Show file tree
Hide file tree
Showing 9 changed files with 3,817 additions and 107 deletions.
2 changes: 1 addition & 1 deletion examples/nextjs-blog-cms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ To run this demo locally, you'll need the following:

Use the below button to deploy this template to Vercel:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Finngest%2Fworkflow-kit%2Ftree%2Fmain%2Fexamples%2Fnextjs-blog-cms%2F&project-name=nextjs-blog-cms-ai-workflow-with-inngest&repository-name=workflow-kit&demo-title=nextjs-blog-cms-ai-workflow-with-inngest&demo-description=Next.js%20blog%20back-office%20featuring%20some%20AI%20workflows%20helping%20with%20grammar%20fixes%2C%20generating%20Table%20of%20Contents%20or%20Tweets&demo-image=https%3A%2F%2Fraw.githubusercontent.com%2Finngest%2Fworkflow-kit%2Frefs%2Fheads%2Fmain%2Fworkflow-kit.jpg)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?install-command=pnpm%20--ignore-workspace%20i&repository-url=https%3A%2F%2Fgithub.com%2Finngest%2Fworkflow-kit%2Ftree%2Fmain%2Fexamples%2Fnextjs-blog-cms%2F&project-name=nextjs-blog-cms-ai-workflow-with-inngest&repository-name=workflow-kit&demo-title=nextjs-blog-cms-ai-workflow-with-inngest&demo-description=Next.js%20blog%20back-office%20featuring%20some%20AI%20workflows%20helping%20with%20grammar%20fixes%2C%20generating%20Table%20of%20Contents%20or%20Tweets&demo-image=https%3A%2F%2Fraw.githubusercontent.com%2Finngest%2Fworkflow-kit%2Frefs%2Fheads%2Fmain%2Fworkflow-kit.jpg)

**Once deployed, make sure to configure your `OPENAI_API_KEY` environment variable.**

Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs-blog-cms/app/blog-post/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function BlogPost({ params }: { params: { id: string } }) {
MDXBlogPostAIContent = (
await evaluate(
blogPost.markdown_ai_revision ||
blogPost.ai_publishing_recommendations,
blogPost.ai_publishing_recommendations!,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
runtime as any
)
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs-blog-cms/lib/inngest/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { actionsWithHandlers } from "./workflowActionHandlers";

const workflowEngine = new Engine({
actions: actionsWithHandlers,
// @ts-expect-error FIX
loader: loadWorkflow,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { type EngineAction, type WorkflowAction } from "@inngest/workflow-kit";
import OpenAI from "openai";

Expand All @@ -7,6 +6,7 @@ import { type BlogPost } from "../supabase/types";
import { loadBlogPost } from "../loaders/blog-post";
import { createClient } from "../supabase/server";
import { actions } from "./workflowActions";
import { inngest } from "./client";

// helper to ensure that each step of the workflow use
// the original content or current AI revision
Expand All @@ -28,7 +28,7 @@ function addAiPublishingSuggestion(
: blogPost.ai_publishing_recommendations + `<br/ >` + additionalSuggestion; // otherwise add one
}

export const actionsWithHandlers: EngineAction[] = [
export const actionsWithHandlers: EngineAction<typeof inngest>[] = [
{
// Add a Table of Contents
...actions[0],
Expand Down
5 changes: 2 additions & 3 deletions examples/nextjs-blog-cms/lib/inngest/workflowActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { type PublicEngineAction } from "@inngest/workflow-kit";
import { type PublicEngineAction } from "@inngest/workflow-kit";

// Actions
// - Review actions
Expand All @@ -9,8 +9,7 @@
// - Post-publish actions
// - Get Tweet verbatim
// - Get LinkedIn verbatim
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const actions: any[] = [
export const actions: PublicEngineAction[] = [
{
kind: "add_ToC",
name: "Add a Table of Contents",
Expand Down
11 changes: 9 additions & 2 deletions examples/nextjs-blog-cms/lib/loaders/blog-post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createClient } from "../supabase/server";
import { BlogPost } from "../supabase/types";

export async function loadBlogPost(id: string) {
export async function loadBlogPost(id: string): Promise<BlogPost> {
const supabase = createClient();
const { data: blogPosts } = await supabase
.from("blog_posts")
Expand All @@ -10,5 +11,11 @@ export async function loadBlogPost(id: string) {
.eq("id", id)
.limit(1);

return blogPosts && blogPosts[0];
const blogPost = blogPosts && blogPosts[0];

if (!blogPost) {
throw new Error(`Blog post #${id} not found`);
}

return blogPost;
}
2 changes: 1 addition & 1 deletion examples/nextjs-blog-cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@inngest/workflow-kit": "0.1.2",
"@inngest/workflow-kit": "0.0.0-alpha-20240927084938",
"@mdx-js/mdx": "^3.0.1",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
23 changes: 5 additions & 18 deletions examples/nextjs-blog-cms/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit af7fabe

Please sign in to comment.