From a030b0817f20b00c81b3ea673512918850d4eaf1 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Thu, 13 Jul 2023 14:59:07 +0800 Subject: [PATCH] chore(console): bump `withtyped` and `@logto/cloud` version (#4167) --- packages/console/package.json | 4 +-- packages/console/src/cloud/types/router.ts | 8 ++--- packages/console/src/consts/subscriptions.ts | 3 +- .../PlanQuotaKeyLabel/index.tsx | 1 - .../Subscription/PlanQuotaTable/index.tsx | 10 +++---- .../Subscription/PlanQuotaTable/utils.ts | 6 ++-- pnpm-lock.yaml | 29 +++++++++++++++---- 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/packages/console/package.json b/packages/console/package.json index 5a35f35cd..afc8a9657 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -26,7 +26,7 @@ "@fontsource/roboto-mono": "^5.0.0", "@jest/types": "^29.5.0", "@logto/app-insights": "workspace:^1.3.1", - "@logto/cloud": "0.2.5-cbbfdc2", + "@logto/cloud": "0.2.5-4f1d80b", "@logto/connector-kit": "workspace:^1.1.1", "@logto/core-kit": "workspace:^2.0.1", "@logto/language-kit": "workspace:^1.0.0", @@ -60,7 +60,7 @@ "@types/react-helmet": "^6.1.6", "@types/react-modal": "^3.13.1", "@types/react-syntax-highlighter": "^15.5.1", - "@withtyped/client": "^0.7.17", + "@withtyped/client": "^0.7.19", "buffer": "^5.7.1", "classnames": "^2.3.1", "clean-deep": "^3.4.0", diff --git a/packages/console/src/cloud/types/router.ts b/packages/console/src/cloud/types/router.ts index 0b61f4593..a29d586dd 100644 --- a/packages/console/src/cloud/types/router.ts +++ b/packages/console/src/cloud/types/router.ts @@ -1,12 +1,8 @@ import type router from '@logto/cloud/routes'; -import { type RouterRoutes } from '@withtyped/client'; -import { type z, type ZodType } from 'zod'; +import { type GuardedResponse, type RouterRoutes } from '@withtyped/client'; export type GetRoutes = RouterRoutes['get']; -type RouteResponseType = - z.infer>; - -export type SubscriptionPlanResponse = RouteResponseType< +export type SubscriptionPlanResponse = GuardedResponse< GetRoutes['/api/subscription-plans'] >[number]; diff --git a/packages/console/src/consts/subscriptions.ts b/packages/console/src/consts/subscriptions.ts index c05ed2fb7..68fd40258 100644 --- a/packages/console/src/consts/subscriptions.ts +++ b/packages/console/src/consts/subscriptions.ts @@ -27,7 +27,6 @@ export const ticketSupportResponseTimeMap: Record = * `undefined` => Contact */ const enterprisePlanTable: SubscriptionPlanTable = { - tenantLimit: null, basePrice: undefined, mauUnitPrice: undefined, mauLimit: undefined, @@ -58,7 +57,7 @@ export const enterprisePlanTableData: SubscriptionPlanTableData = { }; export const planTableGroupKeyMap: SubscriptionPlanTableGroupKeyMap = Object.freeze({ - [SubscriptionPlanTableGroupKey.base]: ['tenantLimit', 'basePrice', 'mauUnitPrice', 'mauLimit'], + [SubscriptionPlanTableGroupKey.base]: ['basePrice', 'mauUnitPrice', 'mauLimit'], [SubscriptionPlanTableGroupKey.applications]: ['applicationsLimit', 'machineToMachineLimit'], [SubscriptionPlanTableGroupKey.resources]: ['resourcesLimit', 'scopesPerResourceLimit'], [SubscriptionPlanTableGroupKey.branding]: ['customDomainEnabled'], diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/PlanQuotaKeyLabel/index.tsx b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/PlanQuotaKeyLabel/index.tsx index 1ff4abd6c..06cee7ecc 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/PlanQuotaKeyLabel/index.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/PlanQuotaKeyLabel/index.tsx @@ -9,7 +9,6 @@ const planQuotaKeyPhraseMap: { 'admin_console.subscription.quota_table' >; } = { - tenantLimit: 'quota.tenant_limit', mauLimit: 'quota.mau_limit', applicationsLimit: 'application.total', machineToMachineLimit: 'application.m2m', diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/index.tsx b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/index.tsx index 847d77445..a44096a86 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/index.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/index.tsx @@ -113,11 +113,9 @@ function PlanQuotaTable({ subscriptionPlans }: Props) { // For mau unit price if (Array.isArray(quotaValue)) { - if (quotaValue.length === 0) { - return ; - } - - return ( + return quotaValue.length === 0 ? ( + '-' + ) : (
{quotaValue.map((value) => (
@@ -132,7 +130,7 @@ function PlanQuotaTable({ subscriptionPlans }: Props) { } if (typeof quotaValue === 'boolean') { - return quotaValue ? : '- '; + return quotaValue ? : '-'; } // Note: handle number type diff --git a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/utils.ts b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/utils.ts index 085390b2d..e65ee257b 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/utils.ts +++ b/packages/console/src/pages/TenantSettings/Subscription/PlanQuotaTable/utils.ts @@ -6,7 +6,7 @@ export const constructPlanTableDataArray = ( plans: SubscriptionPlan[] ): SubscriptionPlanTableData[] => plans.map((plan) => { - const { id, name, products, quota } = plan; + const { id, name, stripeProducts, quota } = plan; return { id, @@ -14,9 +14,9 @@ export const constructPlanTableDataArray = ( table: { ...quota, basePrice: conditional( - products.find((product) => product.type === 'flat')?.price.unitAmountDecimal + stripeProducts.find((product) => product.type === 'flat')?.price.unitAmountDecimal ), - mauUnitPrice: products + mauUnitPrice: stripeProducts .filter(({ type }) => type !== 'flat') .map(({ price: { unitAmountDecimal } }) => conditionalString(unitAmountDecimal)), }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dcd1ffa2a..2e57f6e7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2755,8 +2755,8 @@ importers: specifier: workspace:^1.3.1 version: link:../app-insights '@logto/cloud': - specifier: 0.2.5-cbbfdc2 - version: 0.2.5-cbbfdc2(zod@3.20.2) + specifier: 0.2.5-4f1d80b + version: 0.2.5-4f1d80b(zod@3.20.2) '@logto/connector-kit': specifier: workspace:^1.1.1 version: link:../toolkit/connector-kit @@ -2857,8 +2857,8 @@ importers: specifier: ^15.5.1 version: 15.5.1 '@withtyped/client': - specifier: ^0.7.17 - version: 0.7.17(zod@3.20.2) + specifier: ^0.7.19 + version: 0.7.19(zod@3.20.2) buffer: specifier: ^5.7.1 version: 5.7.1 @@ -7185,6 +7185,16 @@ packages: jose: 4.14.4 dev: true + /@logto/cloud@0.2.5-4f1d80b(zod@3.20.2): + resolution: {integrity: sha512-AF0YnJiXDMS3HQ2ugZcwJRBkspvNtlXk992IwTNFZxbZdinpPoVmPnDnHuekACcQY5bFRgHjMB2/o/GKkdLpWg==} + engines: {node: ^18.12.0} + dependencies: + '@silverhand/essentials': 2.7.0 + '@withtyped/server': 0.12.7(zod@3.20.2) + transitivePeerDependencies: + - zod + dev: true + /@logto/cloud@0.2.5-cbbfdc2(zod@3.20.2): resolution: {integrity: sha512-qul8lxkbAczEHJSyramQJW3BaNAdJQHlryIzTAHpcWpNGZogP3aacJuF0neBnnn8mJqAWy1rIGAGnb4d16fEFQ==} engines: {node: ^18.12.0} @@ -9816,6 +9826,16 @@ packages: '@withtyped/shared': 0.2.2 transitivePeerDependencies: - zod + dev: false + + /@withtyped/client@0.7.19(zod@3.20.2): + resolution: {integrity: sha512-cHmqCIsEMonrE9kDbu8YAPWWPHmy6imUGbUWQ2PGaPLTJagbgH3ABsxgnLiM0lm0LeuZFd3BHh+JYKRDUmS8cw==} + dependencies: + '@withtyped/server': 0.12.7(zod@3.20.2) + '@withtyped/shared': 0.2.2 + transitivePeerDependencies: + - zod + dev: true /@withtyped/server@0.12.5(zod@3.20.2): resolution: {integrity: sha512-mKDPGCJzh0xna4Vi2zVsHg/ZfMNQHDV3+jvsral2PJdRzI8qU7au7I/ytU6Vr6BU1fFESkNrIuUpCmyfBAwX7g==} @@ -9834,7 +9854,6 @@ packages: '@silverhand/essentials': 2.7.0 '@withtyped/shared': 0.2.2 zod: 3.20.2 - dev: false /@withtyped/shared@0.2.2: resolution: {integrity: sha512-Vpcj12NqaoZ8M5Z/1kffheI9FBZEm9goed0THmgTcMKXLHjXSRbMZMp0olVxovEgaTIAydshqJOQUXKZMctIZw==}