94b8c357b4
- add workspace-scoped billing storage, usage tracking, and add-on catalog - enforce plan entitlements for search and deep research routes - expand pricing and account UI around billing state, usage, and upgrades
177 lines
4.2 KiB
TypeScript
177 lines
4.2 KiB
TypeScript
import type { AddonCode, BillingInterval, PlanCode } from './billing/plans.js';
|
|
import type { UsageAllowanceAvailability, UsageResource } from './billing/entitlements.js';
|
|
|
|
export type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'stopped';
|
|
|
|
export interface AppUser {
|
|
id: string;
|
|
email: string;
|
|
displayName: string;
|
|
avatarUrl?: string | null;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface SessionUser extends AppUser {
|
|
sessionId: string;
|
|
}
|
|
|
|
export type WorkspaceType = 'personal' | 'company';
|
|
export type WorkspaceRole = 'owner' | 'admin' | 'member';
|
|
|
|
export interface AccountWorkspace {
|
|
id: string;
|
|
name: string;
|
|
workspaceType: WorkspaceType;
|
|
role: WorkspaceRole;
|
|
memberCount: number;
|
|
}
|
|
|
|
export interface AccountSummary {
|
|
totalSearchJobs: number;
|
|
totalDeepResearchBatches: number;
|
|
totalBusinesses: number;
|
|
}
|
|
|
|
export type AccountBillingStatus = 'not_configured' | 'inactive' | 'active' | 'past_due' | 'canceled';
|
|
|
|
export interface BillingUsageResourceSummary {
|
|
resource: UsageResource;
|
|
availability: UsageAllowanceAvailability;
|
|
included: number | null;
|
|
consumed: number;
|
|
remaining: number | null;
|
|
}
|
|
|
|
export interface BillingAddonBalanceSummary {
|
|
addonCode: AddonCode;
|
|
resource: UsageResource;
|
|
remainingQuantity: number;
|
|
expiresAt: string | null;
|
|
}
|
|
|
|
export interface AccountBillingState {
|
|
status: AccountBillingStatus;
|
|
planCode: PlanCode | null;
|
|
billingInterval: BillingInterval | null;
|
|
currentPeriodStartsAt: string | null;
|
|
currentPeriodEndsAt: string | null;
|
|
cancelAtPeriodEnd: boolean;
|
|
usage: BillingUsageResourceSummary[];
|
|
addonBalances: BillingAddonBalanceSummary[];
|
|
message: string;
|
|
}
|
|
|
|
export interface AccountTeamPlaceholder {
|
|
canManageMembers: boolean;
|
|
message: string;
|
|
}
|
|
|
|
export interface AccountPageData {
|
|
profile: AppUser;
|
|
workspace: AccountWorkspace;
|
|
summary: AccountSummary;
|
|
billing: AccountBillingState;
|
|
team: AccountTeamPlaceholder;
|
|
}
|
|
|
|
export interface UpdateAccountProfileRequest {
|
|
displayName?: string;
|
|
avatarUrl?: string | null;
|
|
workspaceName?: string;
|
|
}
|
|
|
|
export interface GeoJsonGeometry {
|
|
type: 'Polygon' | 'MultiPolygon';
|
|
coordinates: unknown;
|
|
}
|
|
|
|
export interface GeoJsonFeature<TProperties = Record<string, unknown>> {
|
|
type: 'Feature';
|
|
geometry: GeoJsonGeometry;
|
|
properties: TProperties;
|
|
}
|
|
|
|
export interface GeoJsonFeatureCollection<TProperties = Record<string, unknown>> {
|
|
type: 'FeatureCollection';
|
|
features: Array<GeoJsonFeature<TProperties>>;
|
|
}
|
|
|
|
export interface PostalAreaPreview {
|
|
id: string;
|
|
countryCode: string;
|
|
postalCode: string;
|
|
normalizedPostalCode: string;
|
|
displayName: string;
|
|
propagationRing: number;
|
|
centroidLat: number | null;
|
|
centroidLng: number | null;
|
|
}
|
|
|
|
export interface DeepResearchOverlayProperties {
|
|
postalAreaId: string;
|
|
countryCode: string;
|
|
postalCode: string;
|
|
displayName: string;
|
|
propagationRing: number;
|
|
}
|
|
|
|
export interface DeepResearchPreviewRequest {
|
|
lat: number;
|
|
lng: number;
|
|
propagation: number;
|
|
businessType: string;
|
|
keywords?: string;
|
|
}
|
|
|
|
export interface DeepResearchPreview {
|
|
baseArea: PostalAreaPreview;
|
|
areas: PostalAreaPreview[];
|
|
overlay: GeoJsonFeatureCollection<DeepResearchOverlayProperties>;
|
|
propagation: number;
|
|
countryCode: string;
|
|
totalAreas: number;
|
|
estimatedChildJobs: number;
|
|
businessType: string;
|
|
keywords?: string;
|
|
}
|
|
|
|
export interface DeepResearchChildJobSummary {
|
|
id: string;
|
|
name: string;
|
|
postalCode?: string;
|
|
status: JobStatus;
|
|
totalResults: number;
|
|
createdAt: string;
|
|
completedAt?: string;
|
|
}
|
|
|
|
export interface DeepResearchBatchSummary {
|
|
id: string;
|
|
userId: string;
|
|
pinLat: number;
|
|
pinLng: number;
|
|
basePostalCode?: string;
|
|
countryCode?: string;
|
|
propagation: number;
|
|
businessType: string;
|
|
keywords?: string;
|
|
status: JobStatus;
|
|
totalPostalAreas: number;
|
|
totalResults: number;
|
|
childJobCount: number;
|
|
completedJobCount: number;
|
|
failedJobCount: number;
|
|
startedAt?: string;
|
|
completedAt?: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface DeepResearchBatchDetail extends DeepResearchBatchSummary {
|
|
childJobs: DeepResearchChildJobSummary[];
|
|
jobIds: string[];
|
|
}
|
|
|
|
export interface CreateDeepResearchBatchRequest extends DeepResearchPreviewRequest {}
|