Update packages and refactor logging in diverse services

This commit updates diverse packages such as "@makerkit/data-loader-supabase-core" and "@makerkit/data-loader-supabase-nextjs" to the new versions in the package.json files. Also, several refactorings were done in logging within services and loaders by progressing 'server-only' imports and improving context handling. Additionally, type annotations have been added to several exported functions for better code readability and maintainability.
This commit is contained in:
giancarlo
2024-04-09 17:23:48 +08:00
parent 5adfb3edac
commit a9eaaafd3d
45 changed files with 159 additions and 128 deletions

View File

@@ -14,8 +14,8 @@
"@kit/next": "workspace:*",
"@kit/supabase": "workspace:*",
"@kit/ui": "workspace:*",
"@makerkit/data-loader-supabase-core": "0.0.5",
"@makerkit/data-loader-supabase-nextjs": "^0.0.7",
"@makerkit/data-loader-supabase-core": "^0.0.7",
"@makerkit/data-loader-supabase-nextjs": "^0.0.9",
"lucide-react": "^0.363.0",
"react-hook-form": "^7.51.2",
"zod": "^3.22.4"
@@ -29,8 +29,8 @@
"@kit/tailwind-config": "workspace:*",
"@kit/tsconfig": "workspace:*",
"@kit/ui": "workspace:^",
"@makerkit/data-loader-supabase-core": "0.0.5",
"@makerkit/data-loader-supabase-nextjs": "^0.0.7",
"@makerkit/data-loader-supabase-core": "^0.0.7",
"@makerkit/data-loader-supabase-nextjs": "^0.0.9",
"@supabase/supabase-js": "^2.42.0",
"lucide-react": "^0.363.0",
"react-hook-form": "^7.51.2",

View File

@@ -1,4 +1,4 @@
import { BadgeX, Ban, ShieldPlus, Trash, VenetianMask } from 'lucide-react';
import { BadgeX, Ban, ShieldPlus, VenetianMask } from 'lucide-react';
import { Database } from '@kit/supabase/database';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';

View File

@@ -4,6 +4,11 @@ import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-clie
import { isSuperAdmin } from './is-super-admin';
/**
* @name enhanceAdminAction
* @description Wrap a server action to ensure the user is a super admin.
* @param fn
*/
export function enhanceAdminAction<Args, Response>(
fn: (params: Args) => Response,
) {

View File

@@ -2,6 +2,11 @@ import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';
/**
* @name isSuperAdmin
* @description Check if the current user is a super admin.
* @param client
*/
export async function isSuperAdmin(client: SupabaseClient<Database>) {
const { data, error } = await client.auth.getUser();

View File

@@ -1,5 +1,12 @@
import 'server-only';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
/**
* @name loadAdminDashboard
* @description Load the admin dashboard data.
* @param params
*/
export async function loadAdminDashboard(params?: {
count: 'exact' | 'estimated' | 'planned';
}) {

View File

@@ -1,3 +1,5 @@
import 'server-only';
import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';

View File

@@ -1,3 +1,5 @@
import 'server-only';
import { SupabaseClient } from '@supabase/supabase-js';
import { Database } from '@kit/supabase/database';