Skip to content

Commit

Permalink
Merge pull request #4905 from signalco-io/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
AleksandarDev authored Apr 1, 2024
2 parents 323ce5c + abdd96e commit aa27220
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 11 deletions.
31 changes: 20 additions & 11 deletions web/apps/workingparty/app/(rest)/(marketing)/DemoMessages.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
'use client';

import { useRouter } from 'next/navigation';
import { Typography } from '@signalco/ui-primitives/Typography';
import { Stack } from '@signalco/ui-primitives/Stack';
import { ListItem } from '@signalco/ui-primitives/ListItem';
import { Input } from '@signalco/ui-primitives/Input';
import { IconButton } from '@signalco/ui-primitives/IconButton';
import { Avatar } from '@signalco/ui-primitives/Avatar';
import { Send } from '@signalco/ui-icons';
import { initials } from '@signalco/js';
import { KnownPages } from '../../../src/knownPages';
import { ThreadMessageInput } from '../(app)/app/workers/[workerid]/threads/[threadid]/ThreadMessageInput';
import { ThreadMessage } from '../(app)/app/workers/[workerid]/threads/[threadid]/ThreadMessage';

export function DemoMessages() {
const router = useRouter();

const handleMessage = () => {
router.push(KnownPages.App);
};

return (
<Stack spacing={4}>
<Stack>
Expand Down Expand Up @@ -48,7 +41,23 @@ export function DemoMessages() {
}} />
</Stack>
<Stack spacing={0.5}>
<ThreadMessageInput workerId="" threadId="" onMessage={handleMessage} />
<form action={KnownPages.App}>
<Input
type="text"
name="message"
className="bg-muted"
autoComplete="off"
placeholder="Enter message..."
fullWidth
endDecorator={(
<IconButton
title="Send message"
type="submit"
variant="plain">
<Send />
</IconButton>
)} />
</form>
<Typography level="body3" className="text-right">Interacting with AI will redirect you to the App.</Typography>
</Stack>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { plansGet } from '../../../../../../../src/lib/repository/plansRepositor
import { accountGet } from '../../../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export type CheckoutSessionDto = Awaited<ReturnType<typeof stripeCheckout>>;

export async function GET(_request: Request, { params }: { params: { accountId: string, planId: string } }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { stripeCustomerBillingInfo } from '../../../../../../src/lib/stripe/serv
import { accountGet } from '../../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export type AccountBillingInfoDto = ReturnType<typeof stripeCustomerBillingInfo>;

export async function GET(_request: Request, { params }: { params: { accountId: string } }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { stripeCustomerPaymentMethods } from '../../../../../../src/lib/stripe/s
import { accountGet } from '../../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export type AccountPaymentMethodsDto = ReturnType<typeof stripeCustomerPaymentMethods>;

export async function GET(_request: Request, { params }: { params: { accountId: string } }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { stripeCreatePortal } from '../../../../../../src/lib/stripe/serverStrip
import { accountGet } from '../../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { accountId: string } }) {
const { accountId } = params;
if (!accountId)
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/accounts/[accountId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { accountGet, accountUpdate } from '../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { accountId: string } }) {
const { accountId } = params;
if (!accountId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { accountSubscriptions } from '../../../../../src/lib/repository/accounts
import { SubscriptionDto } from '../../../../../src/lib/dtos/subscription';
import { withAuth } from '../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { accountId: string } }) {
const { accountId } = params;
if (!accountId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { accountUsageScope } from '../../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { accountId: string, scope: string } }) {
const { accountId, scope } = params;
if (!accountId || !scope)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { accountUsage } from '../../../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export type AccountUsageDto = {
messages: {
unlimited: boolean
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/auth/login/confirm/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { loginRequestsVerify } from '../../../../../src/lib/repository/loginRequ
import { accountCreate } from '../../../../../src/lib/repository/accountsRepository';
import { createJwt } from '../../../../../src/lib/auth/createJwt';

export const runtime = 'edge';

export async function POST(request: Request) {
const json = await request.json();
let email: string | undefined = undefined;
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/auth/login/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { loginRequestsCreate } from '../../../../src/lib/repository/loginRequest
import { sendEmail } from '../../../../src/lib/email/emailService';
import { words } from './shortWordsList';

export const runtime = 'edge';

function toPhrase(token: string) {
const wordsLength = words.length;
const tokenLength = token.length;
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { cookies } from 'next/headers';

export const runtime = 'edge';

export async function POST() {
cookies().delete('wp_session');
return Response.json(null);
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/plans/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { plansGetAll } from '../../../src/lib/repository/plansRepository';
import { PlanDto } from '../../../src/lib/dtos/plan';

export const runtime = 'edge';

export async function GET() {
const plans = await plansGetAll();
const dtos: PlanDto[] = plans.filter(plan => plan.active).map((plan) => ({
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/stripe/webhook/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { stripe } from '../../../../src/lib/stripe/config';
import { plansCreate, plansDelete, plansGetAll, plansGetByStripePriceId, plansUpdate } from '../../../../src/lib/repository/plansRepository';
import { accountGetByStripeCustomerId, accountSubscriptionCreate, accountSubscriptionSetStatus, accountSubscriptions } from '../../../../src/lib/repository/accountsRepository';

export const runtime = 'edge';

const relevantEvents = new Set([
'product.created',
'product.updated',
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/users/current/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { usersGet, usersPatch } from '../../../../src/lib/repository/usersRepository';
import { ensureAuthUserId } from '../../../../src/lib/auth/ensureAuthUserId';

export const runtime = 'edge';

export async function GET() {
const userIdOrResponse = await ensureAuthUserId();
if (userIdOrResponse instanceof Response)
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/workers/[workerid]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { workersDelete, workersGet } from '../../../../src/lib/repository/workersRepository';
import { withAuth } from '../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { workerid: string } }) {
const { workerid } = params;
if (!workerid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { openAiCreateMessage, openAiListMessages } from '../../../../../../../sr
import { cosmosDataContainerThreads } from '../../../../../../../src/lib/cosmosClient';
import { withAuth } from '../../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(request: Request, { params }: { params: { threadid: string } }) {
const { threadid } = params;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { threadsDelete, threadsGet } from '../../../../../../src/lib/repository/threadsRepository';
import { withAuth } from '../../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { workerid: string, threadid: string } }) {
const { threadid } = params;
if (!threadid)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { threadsCreate, threadsGetAll } from '../../../../../src/lib/repository/threadsRepository';
import { withAuth } from '../../../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET(_request: Request, { params }: { params: { workerid: string } }) {
const { workerid } = params;
if (!workerid)
Expand Down
2 changes: 2 additions & 0 deletions web/apps/workingparty/app/api/workers/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { workersCreate, workersGetAll } from '../../../src/lib/repository/worker
import { accountUsageOverLimit } from '../../../src/lib/repository/accountsRepository';
import { withAuth } from '../../../src/lib/auth/withAuth';

export const runtime = 'edge';

export async function GET() {
return withAuth(async ({ accountId }) =>
Response.json(await workersGetAll(accountId)));
Expand Down

0 comments on commit aa27220

Please sign in to comment.