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:
parent
873ef1ebd0
commit
09637a1a57
2 changed files with 13 additions and 13 deletions
|
@ -23,7 +23,7 @@ export const createQuotaLibrary = (
|
|||
connectorLibrary: ConnectorLibrary
|
||||
) => {
|
||||
const {
|
||||
applications: { countNonM2mApplications, countM2mApplications },
|
||||
applications: { countAllApplications, countM2mApplications },
|
||||
resources: { findTotalNumberOfResources },
|
||||
hooks: { getTotalNumberOfHooks },
|
||||
roles: { countRoles },
|
||||
|
@ -37,7 +37,7 @@ export const createQuotaLibrary = (
|
|||
keyof FeatureQuota,
|
||||
(queryKey?: string) => Promise<{ count: number }>
|
||||
> = {
|
||||
applicationsLimit: countNonM2mApplications,
|
||||
applicationsLimit: countAllApplications,
|
||||
hooksLimit: getTotalNumberOfHooks,
|
||||
machineToMachineLimit: countM2mApplications,
|
||||
resourcesLimit: async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 { convertToIdentifiers, conditionalSql, conditionalArraySql } from '@logto/shared';
|
||||
import type { CommonQueryMethods, SqlSqlToken } from 'slonik';
|
||||
|
@ -162,15 +162,15 @@ export const createApplicationQueries = (pool: CommonQueryMethods) => {
|
|||
set: Partial<OmitAutoSetFields<CreateApplication>>
|
||||
) => updateApplication({ set, where: { id }, jsonbMode: 'merge' });
|
||||
|
||||
const countNonM2mApplications = async () => {
|
||||
const { count } = await pool.one<{ count: string }>(sql`
|
||||
select count(*)
|
||||
from ${table}
|
||||
where ${fields.type} != ${ApplicationType.MachineToMachine}
|
||||
`);
|
||||
|
||||
return { count: Number(count) };
|
||||
};
|
||||
const countAllApplications = async () =>
|
||||
countApplications(
|
||||
{
|
||||
matches: [],
|
||||
joint: SearchJointMode.And, // Dummy since there is no match
|
||||
isCaseSensitive: false, // Dummy since there is no match
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const countM2mApplications = async () => {
|
||||
const { count } = await pool.one<{ count: string }>(sql`
|
||||
|
@ -257,7 +257,7 @@ export const createApplicationQueries = (pool: CommonQueryMethods) => {
|
|||
insertApplication,
|
||||
updateApplication,
|
||||
updateApplicationById,
|
||||
countNonM2mApplications,
|
||||
countAllApplications,
|
||||
countM2mApplications,
|
||||
countM2mApplicationsByIds,
|
||||
findM2mApplicationsByIds,
|
||||
|
|
Loading…
Reference in a new issue