Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,22 +1,20 @@
|
||||
import { getDbClient } from "./client.server.js";
|
||||
import type { Tenant, TenantInboundAddress, TenantIpAddress, TenantType, TenantUser } from "./prisma-browser.js";
|
||||
import type { AdminUser, Tenant, TenantInboundAddress, TenantIpAddress, TenantUser } from "./prisma-browser.js";
|
||||
import type { TenantSubscriptionWithDetails } from "./subscriptions.server.js";
|
||||
|
||||
const ACTIVE_TENANT_USER_STATUS = 2;
|
||||
|
||||
export type LegacyTenantSimple = Tenant & {
|
||||
subscription: { id: string } | null;
|
||||
types: TenantType[];
|
||||
};
|
||||
|
||||
export type LegacyTenantSummary = Pick<Tenant, "id" | "name" | "slug">;
|
||||
export type PlatformOperatorIdentity = { userId: AdminUser["id"] };
|
||||
|
||||
export type LegacyTenantMemberSimple = Pick<
|
||||
Tenant,
|
||||
"id" | "name" | "slug" | "icon" | "logo" | "deactivatedReason" | "active" | "theme" | "themeConfig"
|
||||
> & {
|
||||
types: TenantType[];
|
||||
};
|
||||
>;
|
||||
|
||||
export type AuthBoundaryTenantMembership = TenantUser & {
|
||||
tenant: Tenant;
|
||||
@@ -39,7 +37,6 @@ export type LegacyTenantWithDetails = Tenant & {
|
||||
user: LegacyTenantUserSummary;
|
||||
})[];
|
||||
subscription: TenantSubscriptionWithDetails | null;
|
||||
types: TenantType[];
|
||||
};
|
||||
|
||||
export type LegacyTenantAccountReaderClient = {
|
||||
@@ -67,7 +64,7 @@ export type LegacyTenantAccountReaderClient = {
|
||||
}): Promise<LegacyTenantWithDetails | null>;
|
||||
findFirst(args: {
|
||||
where: { OR: [{ id: string }, { slug: string }] };
|
||||
include: { subscription: true; types: true };
|
||||
include: { subscription: true };
|
||||
}): Promise<LegacyTenantSimple | null>;
|
||||
};
|
||||
tenantUser: {
|
||||
@@ -100,6 +97,12 @@ export type LegacyTenantIpAddressWriterClient = {
|
||||
};
|
||||
};
|
||||
|
||||
export type PlatformOperatorReaderClient = {
|
||||
adminUser: {
|
||||
findUnique(args: { where: { id: string }; select: { id: true } }): Promise<Pick<AdminUser, "id"> | null>;
|
||||
};
|
||||
};
|
||||
|
||||
const selectLegacyTenantUserSummary = {
|
||||
id: true,
|
||||
email: true,
|
||||
@@ -117,7 +120,6 @@ const selectLegacyTenantMemberSimple = {
|
||||
icon: true,
|
||||
logo: true,
|
||||
deactivatedReason: true,
|
||||
types: true,
|
||||
active: true,
|
||||
theme: true,
|
||||
themeConfig: true,
|
||||
@@ -149,7 +151,6 @@ export const legacyTenantDetailsInclude = {
|
||||
},
|
||||
},
|
||||
},
|
||||
types: true,
|
||||
} as const;
|
||||
|
||||
export async function adminGetAllLegacyTenants(
|
||||
@@ -161,6 +162,26 @@ export async function adminGetAllLegacyTenants(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Revalidates the caller-bound app.user_id against the RLS-protected
|
||||
* tenant-less AdminUser identity. Callers must bind the same userId before invoking this
|
||||
* reader; a supplied identifier alone never grants platform access.
|
||||
*/
|
||||
export async function findPlatformOperatorByUserId(
|
||||
userId: string,
|
||||
client: PlatformOperatorReaderClient = getDbClient() as unknown as PlatformOperatorReaderClient,
|
||||
): Promise<PlatformOperatorIdentity | null> {
|
||||
const normalizedUserId = userId.trim();
|
||||
if (!normalizedUserId || normalizedUserId.length > 191 || normalizedUserId.includes("\u0000")) {
|
||||
return null;
|
||||
}
|
||||
const operator = await client.adminUser.findUnique({
|
||||
where: { id: normalizedUserId },
|
||||
select: { id: true },
|
||||
});
|
||||
return operator ? { userId: operator.id } : null;
|
||||
}
|
||||
|
||||
export async function adminGetAllLegacyTenantSummaries(
|
||||
client: LegacyTenantAccountReaderClient = getDbClient() as unknown as LegacyTenantAccountReaderClient,
|
||||
): Promise<LegacyTenantSummary[]> {
|
||||
@@ -243,7 +264,6 @@ export async function findLegacyTenantByIdOrSlug(
|
||||
},
|
||||
include: {
|
||||
subscription: true,
|
||||
types: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user