Skip to content

Commit

Permalink
chore(cb): orgs (#320)
Browse files Browse the repository at this point in the history
* chore(cb): orgs

* remove dead imports

* feat: schema changes for orgs

* iterate

* fix

* fix test

* build fixin

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
joelhooks and kodiakhq[bot] authored Nov 14, 2024
1 parent 34456e1 commit d6caa19
Show file tree
Hide file tree
Showing 77 changed files with 790 additions and 149 deletions.
8 changes: 8 additions & 0 deletions .changeset/breezy-cameras-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@coursebuilder/adapter-drizzle": major
"utils": major
"@coursebuilder/core": major
"@coursebuilder/ui": major
---

adds organizations for multi-tenant
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"epic-web",
"pro-nextjs",
"astro-party",
"js-visualized",
"egghead",
"epic-react",
"ai-hero",
Expand Down
2 changes: 1 addition & 1 deletion apps/ai-hero/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NEXT_PUBLIC_PRODUCT_DESCRIPTION="From Zero to AI Hero"
# App Features
CREATE_USER_ON_LOGIN=true
LOG_VERIFICATION_URL=true
SKIP_EMAIL=true
SKIP_EMAIL=false
SKIP_CK_TAGGING=true
DEFAULT_COUNTRY=US

3 changes: 2 additions & 1 deletion apps/ai-hero/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "concurrently --kill-others-on-fail \"npm:dev:*\"",
"dev:next": "next dev --turbo",
"dev:next": "next dev",
"dev:inngest": "pnpx inngest-cli@latest dev --no-discovery -u http://localhost:3000/api/inngest",
"dev:party": "pnpx partykit dev",
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
Expand Down Expand Up @@ -139,6 +139,7 @@
"holy-loader": "^2.2.10",
"html-to-text": "^9.0.5",
"i": "^0.3.7",
"import-in-the-middle": "^1.11.2",
"inngest": "^3.22.5",
"intl-segmenter-polyfill": "^0.4.4",
"js-cookie": "^3.0.5",
Expand Down
10 changes: 10 additions & 0 deletions apps/ai-hero/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ export const {
commentsRelations,
userPrefs,
userPrefsRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
merchantSubscription,
merchantSubscriptionRelations,
subscription,
subscriptionRelations,
} = getCourseBuilderSchema(mysqlTable)
47 changes: 26 additions & 21 deletions apps/ai-hero/src/lib/lessons.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import { z } from 'zod'

import { ContentResourceResourceSchema } from '@coursebuilder/core/schemas/content-resource-schema'
import {
ContentResourceResourceSchema,
ContentResourceSchema,
} from '@coursebuilder/core/schemas/content-resource-schema'

export const LessonSchema = z.object({
id: z.string(),
type: z.string(),
createdById: z.string(),
createdAt: z.coerce.date().nullable(),
updatedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
fields: z.object({
title: z.string().min(2).max(90),
body: z.string().optional(),
slug: z.string(),
description: z.string().optional(),
state: z
.enum(['draft', 'published', 'archived', 'deleted'])
.default('draft'),
visibility: z.enum(['public', 'private', 'unlisted']).default('unlisted'),
github: z.string().optional(),
gitpod: z.string().optional(),
export const LessonSchema = ContentResourceSchema.merge(
z.object({
id: z.string(),
type: z.string(),
createdById: z.string(),
createdAt: z.coerce.date().nullable(),
updatedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
fields: z.object({
title: z.string().min(2).max(90),
body: z.string().optional(),
slug: z.string(),
description: z.string().optional(),
state: z
.enum(['draft', 'published', 'archived', 'deleted'])
.default('draft'),
visibility: z.enum(['public', 'private', 'unlisted']).default('unlisted'),
github: z.string().optional(),
gitpod: z.string().optional(),
}),
resources: z.array(ContentResourceResourceSchema).default([]).nullable(),
}),
resources: z.array(ContentResourceResourceSchema).default([]).nullable(),
})
)

export type Lesson = z.infer<typeof LessonSchema>
2 changes: 1 addition & 1 deletion apps/ai-hero/src/lib/pages-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getPages(): Promise<Page[]> {

const pagesParsed = z.array(PageSchema).safeParse(pages)
if (!pagesParsed.success) {
console.error('Error parsing pages', pagesParsed)
console.debug('Error parsing pages', pagesParsed.error)
return []
}

Expand Down
4 changes: 2 additions & 2 deletions apps/astro-party/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:push": "dotenv drizzle-kit push",
"db:studio": "dotenv drizzle-kit studio",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:generate": "dotenv drizzle-kit generate",
"lint": "next lint",
"start": "next start",
"typecheck": "tsc --noEmit",
Expand Down
6 changes: 6 additions & 0 deletions apps/astro-party/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ export const {
contentResourceProductRelations,
upgradableProducts,
upgradableProductsRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
47 changes: 26 additions & 21 deletions apps/astro-party/src/lib/lessons.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import { z } from 'zod'

import { ContentResourceResourceSchema } from '@coursebuilder/core/schemas/content-resource-schema'
import {
ContentResourceResourceSchema,
ContentResourceSchema,
} from '@coursebuilder/core/schemas/content-resource-schema'

export const LessonSchema = z.object({
id: z.string(),
type: z.string(),
createdById: z.string(),
createdAt: z.coerce.date().nullable(),
updatedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
fields: z.object({
title: z.string().min(2).max(90),
body: z.string().optional(),
slug: z.string(),
description: z.string().optional(),
state: z
.enum(['draft', 'published', 'archived', 'deleted'])
.default('draft'),
visibility: z.enum(['public', 'private', 'unlisted']).default('unlisted'),
github: z.string().optional(),
gitpod: z.string().optional(),
export const LessonSchema = ContentResourceSchema.merge(
z.object({
id: z.string(),
type: z.string(),
createdById: z.string(),
createdAt: z.coerce.date().nullable(),
updatedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
fields: z.object({
title: z.string().min(2).max(90),
body: z.string().optional(),
slug: z.string(),
description: z.string().optional(),
state: z
.enum(['draft', 'published', 'archived', 'deleted'])
.default('draft'),
visibility: z.enum(['public', 'private', 'unlisted']).default('unlisted'),
github: z.string().optional(),
gitpod: z.string().optional(),
}),
resources: z.array(ContentResourceResourceSchema).default([]).nullable(),
}),
resources: z.array(ContentResourceResourceSchema).default([]).nullable(),
})
)

export type Lesson = z.infer<typeof LessonSchema>

Expand Down
4 changes: 2 additions & 2 deletions apps/course-builder-video-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:push": "dotenv drizzle-kit push",
"db:studio": "dotenv drizzle-kit studio",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:generate": "dotenv drizzle-kit generate",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"lint": "next lint",
"start": "next start",
Expand Down
6 changes: 6 additions & 0 deletions apps/course-builder-video-blog/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ export const {
deviceVerificationRelations,
deviceAccessToken,
deviceAccessTokenRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
4 changes: 2 additions & 2 deletions apps/course-builder-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:push": "dotenv drizzle-kit push",
"db:studio": "dotenv drizzle-kit studio",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:generate": "dotenv drizzle-kit generate",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"lint": "next lint",
"start": "next start",
Expand Down
6 changes: 6 additions & 0 deletions apps/course-builder-web/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ export const {
contentResourceProductRelations,
upgradableProducts,
upgradableProductsRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
4 changes: 2 additions & 2 deletions apps/egghead/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:push": "dotenv drizzle-kit push",
"db:studio": "dotenv drizzle-kit studio",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:generate": "dotenv drizzle-kit generate",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"lint": "next lint",
"start": "next start",
Expand Down
5 changes: 2 additions & 3 deletions apps/egghead/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GET as authGet, POST as authPost } from '@/server/auth'
import { withSkill } from '@/server/with-skill'

export const GET = withSkill(authGet)
export const POST = withSkill(authPost)
export const GET = authGet
export const POST = authPost
6 changes: 6 additions & 0 deletions apps/egghead/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@ export const {
deviceVerificationRelations,
deviceAccessToken,
deviceAccessTokenRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
4 changes: 2 additions & 2 deletions apps/epic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:push": "dotenv drizzle-kit push",
"db:studio": "dotenv drizzle-kit studio",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:generate": "dotenv drizzle-kit generate",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"lint": "next lint",
"start": "next start",
Expand Down
6 changes: 6 additions & 0 deletions apps/epic-react/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ export const {
contributionTypes,
contributionTypesRelations,
resourceProgress,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
4 changes: 2 additions & 2 deletions apps/epic-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"tunnel": "ngrok http --domain=neatly-diverse-goldfish.ngrok-free.app 3000",
"email:preview": "email dev --dir ./src/emails",
"build": "next build",
"db:push": "dotenv drizzle-kit push mysql",
"db:generate": "dotenv drizzle-kit generate mysql",
"db:push": "dotenv drizzle-kit push",
"db:generate": "dotenv drizzle-kit generate",
"db:studio": "dotenv drizzle-kit studio",
"db:seed": "dotenv tsx ./src/db/seed.ts",
"lint": "next lint",
Expand Down
6 changes: 6 additions & 0 deletions apps/epic-web/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ export const {
userPrefs,
userPrefsRelations,
lessonProgress,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
5 changes: 1 addition & 4 deletions apps/go-local-first/src/components/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import * as React from 'react'
import Link from 'next/link'
import { useParams, usePathname, useRouter } from 'next/navigation'
import { createAppAbility } from '@/ability'
import config from '@/config'
import { env } from '@/env.mjs'
import { useFeedback } from '@/feedback-widget/feedback-context'
import { useSaleToastNotifier } from '@/hooks/use-sale-toast-notifier'
import { api } from '@/trpc/react'
import { cn } from '@/utils/cn'
import { Menu, X } from 'lucide-react'
import { X } from 'lucide-react'
import { useSession } from 'next-auth/react'

import { Button } from '@coursebuilder/ui'

import { useLiveEventToastNotifier } from '../app/use-live-event-toast-notifier'
import { useNavLinks } from '../app/use-nav-links'
import { LogoMark } from '../logo'
import { NavLinkItem } from './nav-link-item'
Expand Down
2 changes: 1 addition & 1 deletion apps/go-local-first/src/db/mysql-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import { mysqlTableCreator } from 'drizzle-orm/mysql-core'
*/
export const mysqlTable = mysqlTableCreator(
(name) =>
`${env.DATABASE_TABLE_PREFIX ? `${env.DATABASE_TABLE_PREFIX}_${name}` : ''}${name}`,
`${env.DATABASE_TABLE_PREFIX ? `${env.DATABASE_TABLE_PREFIX}_${name}` : name}`,
)
6 changes: 6 additions & 0 deletions apps/go-local-first/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ export const {
commentsRelations,
userPrefs,
userPrefsRelations,
organization,
organizationRelations,
organizationMemberships,
organizationMembershipRelations,
organizationMembershipRoles,
organizationMembershipRolesRelations,
} = getCourseBuilderSchema(mysqlTable)
Loading

0 comments on commit d6caa19

Please sign in to comment.