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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

Expand Down Expand Up @@ -39,4 +40,6 @@ next-env.d.ts
# contentlayer
.contentlayer

.turbo
.turbo
dist
.next
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers = true
# public-hoist-pattern[]=*prisma*
22 changes: 22 additions & 0 deletions apps/process-queue/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "process-queue",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "rm -rf dist && pnpm run build && nodemon ./dist/src/index.js",
"build": "tsc"
},
"dependencies": {
"bull": "^4.11.3"
},
"devDependencies": {
"@types/node": "^17.0.12",
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"eslint-config-custom": "workspace:*",
"nodemon": "^3.0.1",
"ts-node": "^10.9.1",
"tsconfig": "workspace:*",
"typescript": "5.1.6"
}
}
18 changes: 18 additions & 0 deletions apps/process-queue/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// A long running service that consumes requests from a queue and passes them to our Next.js endpoints to be handled.
// This helps us avoid being rate limited by the OpenAI API.

import Queue from 'bull';

console.log("Started process queue")

const apiRequestQueue = new Queue("openai-requests", {
redis: {
host: process.env.UPSTASH_REDIS_URL,
},
});

apiRequestQueue.process(async (job) => {
const requestData = job.data;
console.log("🚀 ~ file: process-queue.ts:8 ~ apiRequestQueue.process ~ requestData:", requestData)
// Logic to make the API call and handle the response
});
9 changes: 9 additions & 0 deletions apps/process-queue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "tsconfig/base.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"include": ["src/"],
"exclude": ["dist", "build", "node_modules"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const metadata: Metadata = {

export default function Terms() {
const post = allLegalPosts.find(
(post) => post._raw.flattenedPath === "legal/privacy"
(post) => post._raw.flattenedPath === "privacy"
);
if (!post) throw new Error(`Post not found for slug: "privacy"`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const metadata: Metadata = {

export default function Terms() {
const post = allLegalPosts.find(
(post) => post._raw.flattenedPath === "legal/terms"
(post) => post._raw.flattenedPath === "terms"
);
if (!post) throw new Error(`Post not found for slug: "terms"`);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextResponse } from "next/server";
import groupBy from "lodash/groupBy";
import { getAuthSession } from "@/utils/auth";
import { getGmailClient } from "@/utils/gmail/client";
import { getPlans } from "@/utils/redis/plan";
Expand All @@ -17,6 +18,25 @@ async function getPlanned() {

const gmail = getGmailClient(session);

const messagesByThreadId = groupBy(plans, (p) => p.threadId);

// const threads = await Promise.all(
// Object.entries(messagesByThreadId).map(async ([threadId, plans]) => {
// if (!plans.length) return;

// const thread = await gmail.users.threads.get({
// userId: "me",
// id: threadId,
// });

// return {
// ...thread.data,
// plans,
// }

// })
// );

const messages = await Promise.all(
plans.map(async (plan) => {
if (!plan.rule) return;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { ActionType } from "@prisma/client";

type Plan = {
rule?: {
name: string;
actions: {
type: ActionType;
name?: string;
actions?: {
type?: ActionType;
to?: string | null;
content?: string | null;
label?: string | null;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions contentlayer.config.ts → apps/web/contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineDocumentType, makeSource } from "contentlayer/source-files";

export const LegalPost = defineDocumentType(() => ({
name: "LegalPost",
filePathPattern: `**/legal/*.md`,
filePathPattern: `**/*.md`,
fields: {
title: {
type: "string",
Expand All @@ -19,6 +19,6 @@ export const LegalPost = defineDocumentType(() => ({
}));

export default makeSource({
contentDirPath: "content",
contentDirPath: "legal",
documentTypes: [LegalPost],
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
102 changes: 102 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"name": "inbox-zero-ai",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"preinstall": "npx only-allow pnpm",
"postinstall": "prisma generate"
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.1",
"@google-cloud/local-auth": "2.1.1",
"@headlessui/react": "^1.7.16",
"@heroicons/react": "^2.0.18",
"@hookform/resolvers": "^3.2.0",
"@prisma/client": "^5.1.1",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-hover-card": "^1.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.6",
"@tailwindcss/forms": "^0.5.4",
"@tanstack/react-query": "^4.32.6",
"@tremor/react": "^3.6.1",
"@upstash/redis": "^1.22.0",
"ai": "^2.1.32",
"bull": "^4.11.3",
"capital-case": "^1.0.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"contentlayer": "^0.3.4",
"date-fns": "^2.30.0",
"email-forward-parser": "^1.5.5",
"email-reply-parser": "^1.5.3",
"encoding": "^0.1.13",
"eslint": "8.46.0",
"eslint-config-next": "13.4.13",
"gmail-api-parse-message": "^2.1.2",
"googleapis": "124",
"he": "^1.2.0",
"json5": "^2.2.3",
"linkify-react": "^4.1.1",
"linkifyjs": "^4.1.1",
"lodash": "^4.17.21",
"lucide-react": "^0.263.1",
"next": "13.4.13",
"next-auth": "^4.22.5",
"next-contentlayer": "^0.3.4",
"nodemailer": "^6.9.4",
"openai-edge": "^1.2.2",
"prettier": "2.8.8",
"prettier-plugin-tailwindcss": "^0.4.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-dom-confetti": "^0.2.0",
"react-hook-form": "^7.45.4",
"react-hotkeys-hook": "^4.4.1",
"server-only": "^0.0.1",
"sonner": "^0.6.2",
"swr": "^2.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.6",
"typescript": "5.1.6",
"zod": "^3.21.4"
},
"devDependencies": {
"@headlessui/tailwindcss": "^0.2.0",
"@types/he": "^1.2.0",
"@types/lodash": "^4.14.197",
"@types/node": "20.4.9",
"@types/nodemailer": "^6.4.9",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.14",
"postcss": "8.4.27",
"prisma": "^5.1.1",
"tailwindcss": "3.3.3",
"turbo": "^1.10.12",
"eslint-config-custom": "workspace:*",
"tsconfig": "workspace:*"
},
"engines": {
"node": ">=18.0.0"
},
"pnpm": {
"overrides": {
"@opentelemetry/api": "1.4.1",
"@opentelemetry/core": "1.13.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.39.1",
"@opentelemetry/resources": "1.13.0",
"@opentelemetry/sdk-trace-base": "1.13.0",
"@opentelemetry/sdk-trace-node": "1.13.0",
"@opentelemetry/semantic-conventions": "1.13.0"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "tsconfig/nextjs.json",
"compilerOptions": {
"baseUrl": ".",
"plugins": [{ "name": "next" }],
"paths": {
"@/*": ["./*"],
"contentlayer/generated": ["./.contentlayer/generated"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".contentlayer/generated"
],
"exclude": ["node_modules"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions apps/web/utils/queue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Queue from "bull";

const apiRequestQueue = new Queue("openai-requests", {
redis: {
host: process.env.UPSTASH_REDIS_URL,
},
});

export async function addRequestToQueue(requestData: any) {
await apiRequestQueue.add("api-request", requestData);
// Logic to acknowledge the request has been queued
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading