Skip to content

Commit

Permalink
feat: publish (#664)
Browse files Browse the repository at this point in the history
* chore: synchronized version

* chore: publish

* chore: publish config

* chore: publish

* chore(@Teable): publish 1.1.2-beta.0 release

* chore: correct import

* chore: remove knex from sdk

* chore: remove useless readme

* chore(@Teable): publish 1.1.3-beta.0 release

* fix: tailwindcss

* chore: remove chore scope

* refactor: move driver from sdk to env in nextjs

* chore: version v1.2.0-beta

* fix: lint error

* chore: publish 1.2.0-beta.0 release

* fix: useInstances in react strict mode
  • Loading branch information
boris-w committed Jun 17, 2024
1 parent ab43e4d commit 728bf63
Show file tree
Hide file tree
Showing 50 changed files with 174 additions and 416 deletions.
2 changes: 1 addition & 1 deletion apps/nestjs-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teable/backend",
"version": "1.0.0",
"version": "1.2.0-beta.0",
"license": "AGPL-3.0",
"private": true,
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class DbConnectionService {

async retrieve(baseId: string): Promise<IDbConnectionVo | null> {
if (this.dbProvider.driver !== DriverClient.Pg) {
throw new BadRequestException(`Unsupported database driver: ${this.dbProvider.driver}`);
return null;
}

const readOnlyRole = `read_only_role_${baseId}`;
Expand Down
2 changes: 0 additions & 2 deletions apps/nextjs-app/config/tests/AppTestProviders.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { DriverClient } from '@teable/core';
import type { IAppContext } from '@teable/sdk/context';
import { AppContext, FieldContext, ThemeKey, ViewContext } from '@teable/sdk/context';
import { defaultLocale } from '@teable/sdk/context/app/i18n';
Expand All @@ -9,7 +8,6 @@ import { I18nextTestStubProvider } from './I18nextTestStubProvider';

export const createAppContext = (context: Partial<IAppContext> = {}) => {
const defaultContext: IAppContext = {
driver: 'sqlite3' as DriverClient,
connected: false,
theme: ThemeKey.Dark,
isAutoTheme: false,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@teable/app",
"version": "1.0.0",
"version": "1.2.0-beta.0",
"license": "AGPL-3.0",
"private": true,
"main": "main/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ITableVo } from '@teable/openapi';
import { useDriver, useTable } from '@teable/sdk/hooks';
import { type ITableVo } from '@teable/openapi';
import { useTable } from '@teable/sdk/hooks';
import {
Card,
CardHeader,
Expand All @@ -11,17 +11,19 @@ import {
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import { useTranslation } from 'next-i18next';
import { useEnv } from '@/features/app/hooks/useEnv';
import { DbTableName } from '../components/DbTableName';
import { TableDescription } from '../components/TableDescription';
import { TableName } from '../components/TableName';
dayjs.extend(relativeTime);

export const TableDetail = () => {
const table = useTable() as ITableVo;
const driver = useDriver();
const [dbSchemaName] = table.dbTableName.split('.');
const { t } = useTranslation(['table']);

const { driver } = useEnv();

return (
<Card>
<CardHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ShareViewPage = (props: IShareViewPageProps) => {
<title>{view?.name ?? 'Teable'}</title>
</Head>
<AppLayout>
<AppProvider lang={i18n.language} wsPath={wsPath} locale={sdkLocale} driver={props.driver}>
<AppProvider lang={i18n.language} wsPath={wsPath} locale={sdkLocale}>
<SessionProvider
user={{
id: ANONYMOUS_USER_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ViewType } from '@teable/core';
import { ArrowUpRight, Code2, Component, Database, MoreHorizontal, Share2 } from '@teable/icons';
import { useDriver, useTablePermission, useView } from '@teable/sdk/hooks';
import { useTablePermission, useView } from '@teable/sdk/hooks';
import { Button, cn, Popover, PopoverContent, PopoverTrigger } from '@teable/ui-lib/shadcn';
import Link from 'next/link';
import { GUIDE_API_BUTTON } from '@/components/Guide';
Expand All @@ -19,7 +19,6 @@ const OthersList = ({
}) => {
const { toggleGraph } = useCellGraphStore();
const view = useView();
const driver = useDriver();
const permission = useTablePermission();

return (
Expand Down Expand Up @@ -88,7 +87,7 @@ const OthersList = ({
<DbConnectionPanelTrigger>
<Button variant={'ghost'} size={'xs'} className="w-full justify-start font-normal">
<Database className="pr-1 text-lg" />
<span className="capitalize">{driver}</span>Connection
Database Connection
</Button>
</DbConnectionPanelTrigger>
</PopoverContent>
Expand Down
12 changes: 8 additions & 4 deletions apps/nextjs-app/src/features/app/dashboard/hooks/useChartData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { ISelectFieldOptions } from '@teable/core';
import { Colors, ColorUtils, CellValueType, FieldType } from '@teable/core';
import { useBase, useFields, useTable, useView } from '@teable/sdk/hooks';
import { knex } from 'knex';
import { useEffect, useMemo, useState } from 'react';
import { useEnv } from '../../hooks/useEnv';

interface IData {
name: string;
Expand All @@ -14,6 +16,9 @@ export function useChartData() {
const table = useTable();
const view = useView();
const base = useBase();

const { driver } = useEnv();

const [data, setData] = useState<{ list: IData[]; title: string }>({ title: '', list: [] });
const groupingField = useMemo(
() => fields.find((field) => field.type === FieldType.SingleSelect),
Expand All @@ -27,15 +32,14 @@ export function useChartData() {
[fields]
);
useEffect(() => {
if (!base || !table || !groupingField || !numberField || !view) {
if (!base || !table || !groupingField || !numberField || !view || !driver) {
return;
}
if (table.id !== groupingField.tableId) {
return;
}

const nativeSql = base
.knex(table.dbTableName)
const nativeSql = knex({ client: driver })(table.dbTableName)
.select(`${groupingField.dbFieldName} as name`)
.sum(`${numberField.dbFieldName} as total`)
.groupBy(groupingField.dbFieldName)
Expand All @@ -57,6 +61,6 @@ export function useChartData() {
})),
});
});
}, [base, fields, groupingField, numberField, table, view]);
}, [base, driver, fields, groupingField, numberField, table, view]);
return data;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CellValueType, FieldType } from '@teable/core';
import { useBase, useFields, useTable, useViewId } from '@teable/sdk/hooks';
import { knex } from 'knex';
import { useEffect, useMemo, useState } from 'react';
import { useEnv } from '../../hooks/useEnv';

interface IData {
total: number;
Expand All @@ -13,6 +15,9 @@ export function useLineChartData() {
const table = useTable();
const viewId = useViewId();
const [data, setData] = useState<{ list: IData[]; title: string }>({ title: '', list: [] });

const { driver } = useEnv();

const selectField = useMemo(
() => fields.find((field) => field.type === FieldType.SingleSelect),
[fields]
Expand All @@ -25,7 +30,7 @@ export function useLineChartData() {
[fields]
);
useEffect(() => {
if (!base || !table || !selectField || !numberField || !viewId) {
if (!base || !table || !selectField || !numberField || !viewId || !driver) {
return;
}
if (table.id !== selectField.tableId) {
Expand All @@ -34,8 +39,7 @@ export function useLineChartData() {

const nameColumn = selectField.dbFieldName;
const numberColumn = numberField.dbFieldName;
const nativeSql = base
.knex(table.dbTableName)
const nativeSql = knex({ client: driver })(table.dbTableName)
.select(nameColumn)
.min(numberColumn + ' as total')
.avg(numberColumn + ' as average')
Expand All @@ -53,6 +57,6 @@ export function useLineChartData() {
})),
});
});
}, [fields, selectField, numberField, table, viewId, base]);
}, [fields, selectField, numberField, table, viewId, base, driver]);
return data;
}
6 changes: 2 additions & 4 deletions apps/nextjs-app/src/features/app/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { DriverClient } from '@teable/core';
import type { IGetBaseVo, ITableVo } from '@teable/openapi';
import { NotificationProvider, SessionProvider, useIsHydrated } from '@teable/sdk';
import type { IUser } from '@teable/sdk';
Expand All @@ -18,9 +17,8 @@ export const BaseLayout: React.FC<{
children: React.ReactNode;
tableServerData: ITableVo[];
baseServerData: IGetBaseVo;
driver?: DriverClient;
user?: IUser;
}> = ({ children, tableServerData, baseServerData, driver, user }) => {
}> = ({ children, tableServerData, baseServerData, user }) => {
const router = useRouter();
const { baseId, tableId, viewId } = router.query;
const sdkLocale = useSdkLocale();
Expand All @@ -29,7 +27,7 @@ export const BaseLayout: React.FC<{

return (
<AppLayout>
<AppProvider lang={i18n.language} locale={sdkLocale} driver={driver as DriverClient}>
<AppProvider lang={i18n.language} locale={sdkLocale}>
<SessionProvider user={user}>
<NotificationProvider>
<AnchorContext.Provider
Expand Down
9 changes: 2 additions & 7 deletions apps/nextjs-app/src/features/app/layouts/SettingLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const SettingLayout: React.FC<{
user?: IUser;
driver: DriverClient;
dehydratedState?: unknown;
}> = ({ children, user, driver, dehydratedState }) => {
}> = ({ children, user, dehydratedState }) => {
const router = useRouter();
const sdkLocale = useSdkLocale();
const { i18n } = useTranslation();
Expand All @@ -40,12 +40,7 @@ export const SettingLayout: React.FC<{

return (
<AppLayout>
<AppProvider
lang={i18n.language}
locale={sdkLocale}
dehydratedState={dehydratedState}
driver={driver}
>
<AppProvider lang={i18n.language} locale={sdkLocale} dehydratedState={dehydratedState}>
<SessionProvider user={user}>
<div id="portal" className="relative flex h-screen w-full items-start">
<Sidebar headerLeft={<SidebarHeaderLeft title={t('settings.title')} onBack={onBack} />}>
Expand Down
11 changes: 2 additions & 9 deletions apps/nextjs-app/src/features/app/layouts/SpaceLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DehydratedState } from '@tanstack/react-query';
import type { DriverClient } from '@teable/core';
import type { IUser } from '@teable/sdk';
import { NotificationProvider, SessionProvider } from '@teable/sdk';
import { AppProvider } from '@teable/sdk/context';
Expand All @@ -17,20 +16,14 @@ export const SpaceLayout: React.FC<{
children: React.ReactNode;
user?: IUser;
dehydratedState?: DehydratedState;
driver: DriverClient;
}> = ({ children, user, driver, dehydratedState }) => {
}> = ({ children, user, dehydratedState }) => {
const sdkLocale = useSdkLocale();
const { i18n } = useTranslation();

return (
<AppLayout>
<SpacePageTitle dehydratedState={dehydratedState} />
<AppProvider
locale={sdkLocale}
lang={i18n.language}
dehydratedState={dehydratedState}
driver={driver}
>
<AppProvider locale={sdkLocale} lang={i18n.language} dehydratedState={dehydratedState}>
<SessionProvider user={user}>
<NotificationProvider>
<div id="portal" className="relative flex h-screen w-full items-start">
Expand Down
11 changes: 2 additions & 9 deletions apps/nextjs-app/src/features/app/layouts/SpaceSettingLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DehydratedState } from '@tanstack/react-query';
import type { DriverClient } from '@teable/core';
import { Component, Home, Users } from '@teable/icons';
import type { IGetSpaceVo } from '@teable/openapi';
import type { IUser } from '@teable/sdk';
Expand All @@ -22,8 +21,7 @@ export const SpaceSettingLayout: React.FC<{
children: React.ReactNode;
user?: IUser;
dehydratedState?: DehydratedState;
driver: DriverClient;
}> = ({ children, user, driver, dehydratedState }) => {
}> = ({ children, user, dehydratedState }) => {
const sdkLocale = useSdkLocale();
const { i18n } = useTranslation();
const { t } = useTranslation(spaceConfig.i18nNamespaces);
Expand Down Expand Up @@ -64,12 +62,7 @@ export const SpaceSettingLayout: React.FC<{
<Head>
<title>{spaceId && dehydratedState ? space.name : t('allSpaces')}</title>
</Head>
<AppProvider
locale={sdkLocale}
lang={i18n.language}
dehydratedState={dehydratedState}
driver={driver}
>
<AppProvider locale={sdkLocale} lang={i18n.language} dehydratedState={dehydratedState}>
<SessionProvider user={user}>
<NotificationProvider>
<div id="portal" className="relative flex h-screen w-full items-start">
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs-app/src/lib/server-env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

export interface IServerEnv {
driver?: string;
templateSiteLink?: string;
microsoftClarityId?: string;
sentryDsn?: string;
Expand Down
9 changes: 4 additions & 5 deletions apps/nextjs-app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ export type AppProps = NextAppProps & {
type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
user?: IUser;
driver: string;
env: IServerEnv;
};

/**
* @link https://nextjs.org/docs/advanced-features/custom-app
*/
const MyApp = (appProps: AppPropsWithLayout) => {
const { Component, pageProps, err, user, driver, env } = appProps;
const { Component, pageProps, err, user, env } = appProps;
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout ?? ((page) => page);

Expand Down Expand Up @@ -82,7 +81,7 @@ const MyApp = (appProps: AppPropsWithLayout) => {
}}
/>
{/* Workaround for https://github.com/vercel/next.js/issues/8592 */}
{getLayout(<Component {...pageProps} err={err} />, { ...pageProps, user, driver })}
{getLayout(<Component {...pageProps} err={err} />, { ...pageProps, user })}
</AppProviders>
<Guide user={user} />
<RouterProgressBar />
Expand All @@ -105,12 +104,12 @@ MyApp.getInitialProps = async (appContext: AppContext) => {

const isLoginPage = appContext.ctx.pathname === '/auth/login';
const needLoginPage = isAuthLoginPage(appContext.ctx.pathname);

const { driver } = parseDsn(process.env.PRISMA_DATABASE_URL as string);

const initialProps = {
...appProps,
driver,
env: {
driver,
templateSiteLink: process.env.TEMPLATE_SITE_LINK,
microsoftClarityId: process.env.MICROSOFT_CLARITY_ID,
sentryDsn: process.env.SENTRY_DSN,
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@teable/teable",
"version": "1.2.0-beta.0",
"license": "AGPL-3.0",
"private": true,
"homepage": "https://github.com/teableio/teable",
Expand Down Expand Up @@ -42,6 +43,13 @@
"install:playwright": "playwright install",
"install:husky": "node .husky/install.mjs",
"nuke:node_modules": "pnpm -r exec -- rm -fr node_modules",
"publish:beta:prerelease": "node ./scripts/publish.mjs prerelease beta",
"publish:beta:patch": "node ./scripts/publish.mjs prepatch beta",
"publish:beta:minor": "node ./scripts/publish.mjs preminor beta",
"publish:beta:major": "node ./scripts/publish.mjs premajor beta",
"publish:next:patch": "node ./scripts/publish.mjs patch next",
"publish:next:minor": "node ./scripts/publish.mjs minor next",
"publish:next:major": "node ./scripts/publish.mjs major next",
"prepare": "run-s install:husky"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 728bf63

Please sign in to comment.