2024-01-02 11:02:16 +08:00
|
|
|
import { TenantTag, ReservedPlanId, defaultManagementApi } from '@logto/schemas';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
import { type TenantResponse } from '@/cloud/types/router';
|
|
|
|
import { type SubscriptionPlan } from '@/types/subscriptions';
|
|
|
|
|
2023-06-08 10:57:02 +08:00
|
|
|
import { adminEndpoint, isCloud } from './env';
|
2023-02-22 22:35:17 +08:00
|
|
|
|
2024-01-02 11:02:16 +08:00
|
|
|
const { tenantId, indicator } = defaultManagementApi.resource;
|
|
|
|
|
|
|
|
const defaultSubscriptionPlanId = ReservedPlanId.Development;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* - For cloud, the initial tenants data is empty, and it will be fetched from the cloud API.
|
|
|
|
* - OSS has a fixed tenant with ID `default` and no cloud API to dynamically fetch tenants.
|
|
|
|
*/
|
|
|
|
export const defaultTenantResponse: TenantResponse = {
|
|
|
|
id: tenantId,
|
|
|
|
name: `tenant_${tenantId}`,
|
|
|
|
tag: TenantTag.Development,
|
|
|
|
indicator,
|
|
|
|
subscription: {
|
|
|
|
status: 'active',
|
|
|
|
planId: defaultSubscriptionPlanId,
|
|
|
|
currentPeriodStart: dayjs().toDate(),
|
|
|
|
currentPeriodEnd: dayjs().add(1, 'month').toDate(),
|
|
|
|
},
|
|
|
|
usage: {
|
|
|
|
activeUsers: 0,
|
|
|
|
cost: 0,
|
|
|
|
tokenUsage: 0,
|
|
|
|
},
|
|
|
|
openInvoices: [],
|
|
|
|
isSuspended: false,
|
|
|
|
planId: defaultSubscriptionPlanId, // Reserved for compatibility with cloud
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* - For cloud, the initial tenant's subscription plan will be fetched from the cloud API.
|
|
|
|
* - OSS has a fixed subscription plan with `development` id and no cloud API to dynamically fetch the subscription plan.
|
|
|
|
*/
|
|
|
|
export const defaultSubscriptionPlan: SubscriptionPlan = {
|
|
|
|
id: defaultSubscriptionPlanId,
|
|
|
|
name: 'Development',
|
|
|
|
createdAt: new Date(),
|
|
|
|
updatedAt: new Date(),
|
|
|
|
stripeProducts: [],
|
|
|
|
quota: {
|
|
|
|
mauLimit: null,
|
|
|
|
tokenLimit: null,
|
|
|
|
applicationsLimit: null,
|
|
|
|
machineToMachineLimit: null,
|
|
|
|
resourcesLimit: null,
|
|
|
|
scopesPerResourceLimit: null,
|
|
|
|
customDomainEnabled: true,
|
|
|
|
mfaEnabled: true,
|
|
|
|
omniSignInEnabled: true,
|
|
|
|
socialConnectorsLimit: null,
|
|
|
|
standardConnectorsLimit: null,
|
|
|
|
rolesLimit: null,
|
|
|
|
machineToMachineRolesLimit: null,
|
|
|
|
scopesPerRoleLimit: null,
|
|
|
|
auditLogsRetentionDays: null,
|
|
|
|
hooksLimit: null,
|
|
|
|
organizationsEnabled: true,
|
|
|
|
ssoEnabled: true,
|
|
|
|
communitySupportEnabled: true,
|
|
|
|
ticketSupportResponseTime: 48,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-27 21:51:34 +08:00
|
|
|
const getAdminTenantEndpoint = () => {
|
|
|
|
// Allow endpoint override for dev or testing
|
2023-06-08 10:57:02 +08:00
|
|
|
if (adminEndpoint) {
|
|
|
|
return new URL(adminEndpoint);
|
2023-03-27 21:51:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return new URL(
|
|
|
|
isCloud ? window.location.origin.replace('cloud.', 'auth.') : window.location.origin
|
|
|
|
);
|
|
|
|
};
|
2023-02-18 18:37:49 +08:00
|
|
|
|
2023-03-27 21:51:34 +08:00
|
|
|
export const adminTenantEndpoint = getAdminTenantEndpoint();
|
2023-02-22 22:35:17 +08:00
|
|
|
|
2023-03-29 01:51:14 +08:00
|
|
|
export const mainTitle = isCloud ? 'Logto Cloud' : 'Logto Console';
|