0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(core): include m2m apps in application limit (#5322)

This commit is contained in:
Xiao Yijun 2024-01-30 10:38:52 +08:00 committed by GitHub
parent 873ef1ebd0
commit 09637a1a57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 13 deletions

View file

@ -23,7 +23,7 @@ export const createQuotaLibrary = (
connectorLibrary: ConnectorLibrary connectorLibrary: ConnectorLibrary
) => { ) => {
const { const {
applications: { countNonM2mApplications, countM2mApplications }, applications: { countAllApplications, countM2mApplications },
resources: { findTotalNumberOfResources }, resources: { findTotalNumberOfResources },
hooks: { getTotalNumberOfHooks }, hooks: { getTotalNumberOfHooks },
roles: { countRoles }, roles: { countRoles },
@ -37,7 +37,7 @@ export const createQuotaLibrary = (
keyof FeatureQuota, keyof FeatureQuota,
(queryKey?: string) => Promise<{ count: number }> (queryKey?: string) => Promise<{ count: number }>
> = { > = {
applicationsLimit: countNonM2mApplications, applicationsLimit: countAllApplications,
hooksLimit: getTotalNumberOfHooks, hooksLimit: getTotalNumberOfHooks,
machineToMachineLimit: countM2mApplications, machineToMachineLimit: countM2mApplications,
resourcesLimit: async () => { resourcesLimit: async () => {

View file

@ -1,5 +1,5 @@
import type { Application, CreateApplication } from '@logto/schemas'; import type { Application, CreateApplication } from '@logto/schemas';
import { ApplicationType, Applications } from '@logto/schemas'; import { ApplicationType, Applications, SearchJointMode } from '@logto/schemas';
import type { OmitAutoSetFields } from '@logto/shared'; import type { OmitAutoSetFields } from '@logto/shared';
import { convertToIdentifiers, conditionalSql, conditionalArraySql } from '@logto/shared'; import { convertToIdentifiers, conditionalSql, conditionalArraySql } from '@logto/shared';
import type { CommonQueryMethods, SqlSqlToken } from 'slonik'; import type { CommonQueryMethods, SqlSqlToken } from 'slonik';
@ -162,15 +162,15 @@ export const createApplicationQueries = (pool: CommonQueryMethods) => {
set: Partial<OmitAutoSetFields<CreateApplication>> set: Partial<OmitAutoSetFields<CreateApplication>>
) => updateApplication({ set, where: { id }, jsonbMode: 'merge' }); ) => updateApplication({ set, where: { id }, jsonbMode: 'merge' });
const countNonM2mApplications = async () => { const countAllApplications = async () =>
const { count } = await pool.one<{ count: string }>(sql` countApplications(
select count(*) {
from ${table} matches: [],
where ${fields.type} != ${ApplicationType.MachineToMachine} joint: SearchJointMode.And, // Dummy since there is no match
`); isCaseSensitive: false, // Dummy since there is no match
},
return { count: Number(count) }; []
}; );
const countM2mApplications = async () => { const countM2mApplications = async () => {
const { count } = await pool.one<{ count: string }>(sql` const { count } = await pool.one<{ count: string }>(sql`
@ -257,7 +257,7 @@ export const createApplicationQueries = (pool: CommonQueryMethods) => {
insertApplication, insertApplication,
updateApplication, updateApplication,
updateApplicationById, updateApplicationById,
countNonM2mApplications, countAllApplications,
countM2mApplications, countM2mApplications,
countM2mApplicationsByIds, countM2mApplicationsByIds,
findM2mApplicationsByIds, findM2mApplicationsByIds,