Enforce config for billing; updated packages
This commit is contained in:
@@ -2,8 +2,6 @@ import 'server-only';
|
|||||||
|
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
|
|
||||||
import { SupabaseClient } from '@supabase/supabase-js';
|
|
||||||
|
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { createAccountsApi } from '@kit/accounts/api';
|
import { createAccountsApi } from '@kit/accounts/api';
|
||||||
|
|||||||
@@ -5,15 +5,27 @@ import { redirect } from 'next/navigation';
|
|||||||
import { enhanceAction } from '@kit/next/actions';
|
import { enhanceAction } from '@kit/next/actions';
|
||||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||||
|
|
||||||
|
import featureFlagsConfig from '~/config/feature-flags.config';
|
||||||
|
|
||||||
import { PersonalAccountCheckoutSchema } from '../schema/personal-account-checkout.schema';
|
import { PersonalAccountCheckoutSchema } from '../schema/personal-account-checkout.schema';
|
||||||
import { createUserBillingService } from './user-billing.service';
|
import { createUserBillingService } from './user-billing.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name enabled
|
||||||
|
* @description This feature flag is used to enable or disable personal account billing.
|
||||||
|
*/
|
||||||
|
const enabled = featureFlagsConfig.enablePersonalAccountBilling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name createPersonalAccountCheckoutSession
|
* @name createPersonalAccountCheckoutSession
|
||||||
* @description Creates a checkout session for a personal account.
|
* @description Creates a checkout session for a personal account.
|
||||||
*/
|
*/
|
||||||
export const createPersonalAccountCheckoutSession = enhanceAction(
|
export const createPersonalAccountCheckoutSession = enhanceAction(
|
||||||
async function (data) {
|
async function (data) {
|
||||||
|
if (!enabled) {
|
||||||
|
throw new Error('Personal account billing is not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
const client = getSupabaseServerActionClient();
|
const client = getSupabaseServerActionClient();
|
||||||
const service = createUserBillingService(client);
|
const service = createUserBillingService(client);
|
||||||
|
|
||||||
@@ -30,6 +42,10 @@ export const createPersonalAccountCheckoutSession = enhanceAction(
|
|||||||
*/
|
*/
|
||||||
export const createPersonalAccountBillingPortalSession = enhanceAction(
|
export const createPersonalAccountBillingPortalSession = enhanceAction(
|
||||||
async () => {
|
async () => {
|
||||||
|
if (!enabled) {
|
||||||
|
throw new Error('Personal account billing is not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
const client = getSupabaseServerActionClient();
|
const client = getSupabaseServerActionClient();
|
||||||
const service = createUserBillingService(client);
|
const service = createUserBillingService(client);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { redirect } from 'next/navigation';
|
|||||||
import { enhanceAction } from '@kit/next/actions';
|
import { enhanceAction } from '@kit/next/actions';
|
||||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||||
|
|
||||||
|
import featureFlagsConfig from '~/config/feature-flags.config';
|
||||||
|
|
||||||
// billing imports
|
// billing imports
|
||||||
import {
|
import {
|
||||||
TeamBillingPortalSchema,
|
TeamBillingPortalSchema,
|
||||||
@@ -12,12 +14,22 @@ import {
|
|||||||
} from '../schema/team-billing.schema';
|
} from '../schema/team-billing.schema';
|
||||||
import { createTeamBillingService } from './team-billing.service';
|
import { createTeamBillingService } from './team-billing.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name enabled
|
||||||
|
* @description This feature flag is used to enable or disable team account billing.
|
||||||
|
*/
|
||||||
|
const enabled = featureFlagsConfig.enableTeamAccountBilling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name createTeamAccountCheckoutSession
|
* @name createTeamAccountCheckoutSession
|
||||||
* @description Creates a checkout session for a team account.
|
* @description Creates a checkout session for a team account.
|
||||||
*/
|
*/
|
||||||
export const createTeamAccountCheckoutSession = enhanceAction(
|
export const createTeamAccountCheckoutSession = enhanceAction(
|
||||||
(data) => {
|
(data) => {
|
||||||
|
if (!enabled) {
|
||||||
|
throw new Error('Team account billing is not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
const client = getSupabaseServerActionClient();
|
const client = getSupabaseServerActionClient();
|
||||||
const service = createTeamBillingService(client);
|
const service = createTeamBillingService(client);
|
||||||
|
|
||||||
@@ -35,6 +47,10 @@ export const createTeamAccountCheckoutSession = enhanceAction(
|
|||||||
*/
|
*/
|
||||||
export const createBillingPortalSession = enhanceAction(
|
export const createBillingPortalSession = enhanceAction(
|
||||||
async (formData: FormData) => {
|
async (formData: FormData) => {
|
||||||
|
if (!enabled) {
|
||||||
|
throw new Error('Team account billing is not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
|
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
|
||||||
|
|
||||||
const client = getSupabaseServerActionClient();
|
const client = getSupabaseServerActionClient();
|
||||||
|
|||||||
@@ -67,23 +67,23 @@
|
|||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"react-i18next": "^14.1.1",
|
"react-i18next": "^14.1.1",
|
||||||
"recharts": "^2.12.6",
|
"recharts": "^2.12.7",
|
||||||
"sonner": "^1.4.41",
|
"sonner": "^1.4.41",
|
||||||
"tailwind-merge": "^2.3.0",
|
"tailwind-merge": "^2.3.0",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kit/eslint-config": "workspace:^",
|
"@kit/eslint-config": "workspace:^",
|
||||||
"@kit/prettier-config": "workspace:^",
|
"@kit/prettier-config": "workspace:^",
|
||||||
"@kit/tailwind-config": "workspace:^",
|
"@kit/tailwind-config": "workspace:^",
|
||||||
"@kit/tsconfig": "workspace:^",
|
"@kit/tsconfig": "workspace:^",
|
||||||
"@next/bundle-analyzer": "14.3.0-canary.9",
|
"@next/bundle-analyzer": "14.2.3",
|
||||||
"@types/mdx": "^2.0.13",
|
"@types/mdx": "^2.0.13",
|
||||||
"@types/node": "^20.12.8",
|
"@types/node": "^20.12.8",
|
||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"autoprefixer": "^10.4.19",
|
"autoprefixer": "^10.4.19",
|
||||||
"dotenv-cli": "^7.4.1",
|
"dotenv-cli": "^7.4.2",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"supabase": "^1.165.0",
|
"supabase": "^1.165.0",
|
||||||
@@ -107,4 +107,4 @@
|
|||||||
"> 0.2%",
|
"> 0.2%",
|
||||||
"not dead"
|
"not dead"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"@kit/tailwind-config": "workspace:*",
|
"@kit/tailwind-config": "workspace:*",
|
||||||
"@kit/tsconfig": "workspace:*",
|
"@kit/tsconfig": "workspace:*",
|
||||||
"@kit/ui": "workspace:*",
|
"@kit/ui": "workspace:*",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"react-i18next": "^14.1.1",
|
"react-i18next": "^14.1.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
"@types/node": "^20.12.8",
|
"@types/node": "^20.12.8",
|
||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"@kit/team-accounts": "workspace:^",
|
"@kit/team-accounts": "workspace:^",
|
||||||
"@kit/tsconfig": "workspace:*",
|
"@kit/tsconfig": "workspace:*",
|
||||||
"@supabase/supabase-js": "^2.43.1",
|
"@supabase/supabase-js": "^2.43.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"react-i18next": "^14.1.1",
|
"react-i18next": "^14.1.1",
|
||||||
"sonner": "^1.4.41",
|
"sonner": "^1.4.41",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"prettier": "@kit/prettier-config",
|
"prettier": "@kit/prettier-config",
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"react-i18next": "^14.1.1",
|
"react-i18next": "^14.1.1",
|
||||||
"sonner": "^1.4.41",
|
"sonner": "^1.4.41",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"prettier": "@kit/prettier-config",
|
"prettier": "@kit/prettier-config",
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
"react-hook-form": "^7.51.4",
|
"react-hook-form": "^7.51.4",
|
||||||
"react-i18next": "^14.1.1",
|
"react-i18next": "^14.1.1",
|
||||||
"sonner": "^1.4.41",
|
"sonner": "^1.4.41",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"prettier": "@kit/prettier-config",
|
"prettier": "@kit/prettier-config",
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"@kit/tailwind-config": "workspace:*",
|
"@kit/tailwind-config": "workspace:*",
|
||||||
"@kit/tsconfig": "workspace:*",
|
"@kit/tsconfig": "workspace:*",
|
||||||
"@types/nodemailer": "6.4.15",
|
"@types/nodemailer": "6.4.15",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
"@kit/tsconfig": "workspace:*",
|
"@kit/tsconfig": "workspace:*",
|
||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
"./config/edge": "./src/config/sentry.server.edge.ts"
|
"./config/edge": "./src/config/sentry.server.edge.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentelemetry/resources": "1.24.0",
|
"@opentelemetry/resources": "1.24.1",
|
||||||
"@opentelemetry/sdk-node": "0.51.0",
|
"@opentelemetry/sdk-node": "0.51.1",
|
||||||
"@opentelemetry/semantic-conventions": "^1.24.0",
|
"@opentelemetry/semantic-conventions": "^1.24.1",
|
||||||
"@sentry/nextjs": "^7.113.0",
|
"@sentry/nextjs": "^7.114.0",
|
||||||
"@sentry/opentelemetry-node": "^7.113.0"
|
"@sentry/opentelemetry-node": "^7.114.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kit/eslint-config": "workspace:*",
|
"@kit/eslint-config": "workspace:*",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"@kit/tsconfig": "workspace:*",
|
"@kit/tsconfig": "workspace:*",
|
||||||
"@supabase/supabase-js": "^2.43.1",
|
"@supabase/supabase-js": "^2.43.1",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"next": "14.2.3",
|
"next": "14.2.3",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
"tailwindcss": "3.4.3",
|
"tailwindcss": "3.4.3",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"zod": "^3.23.6"
|
"zod": "^3.23.7"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
|||||||
561
pnpm-lock.yaml
generated
561
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user