Files
cfw-autumn/shared/models/cusModels/fullSubject/fullSubjectModel.ts
2026-05-13 17:24:08 +08:00

47 lines
1.8 KiB
TypeScript

import { z } from "zod/v4";
import { FullAggregatedFeatureBalanceSchema } from "../../cusProductModels/cusEntModels/aggregatedCusEnt.js";
import { FullCustomerEntitlementSchema } from "../../cusProductModels/cusEntModels/cusEntModels.js";
import { FullCusProductSchema } from "../../cusProductModels/cusProductModels.js";
import { MigrationItemRunSchema } from "../../migrationV2Models/migrationItemRunSchema.js";
import { SubscriptionSchema } from "../../subModels/subModels.js";
import { CustomerSchema } from "../cusModels.js";
import { EntitySchema } from "../entityModels/entityModels.js";
import { InvoiceSchema } from "../invoiceModels/invoiceModels.js";
import { AggregatedSubjectFlagSchema } from "./normalizedFullSubjectModel.js";
export const SubjectType = {
Customer: "customer",
Entity: "entity",
} as const;
export type SubjectType = (typeof SubjectType)[keyof typeof SubjectType];
export const FullSubjectSchema = z.object({
subjectType: z.enum(["customer", "entity"]),
customerId: z.string(),
internalCustomerId: z.string(),
entityId: z.string().optional(),
internalEntityId: z.string().optional(),
customer: CustomerSchema,
entity: EntitySchema.optional(),
customer_products: z.array(FullCusProductSchema),
extra_customer_entitlements: z.array(FullCustomerEntitlementSchema),
subscriptions: z.array(SubscriptionSchema).optional(),
invoices: z.array(InvoiceSchema),
aggregated_customer_products: z.array(FullCusProductSchema).optional(),
aggregated_customer_entitlements: z
.array(FullAggregatedFeatureBalanceSchema)
.optional(),
aggregated_subject_flags: z
.record(z.string(), AggregatedSubjectFlagSchema)
.optional(),
migration_item_runs: z.array(MigrationItemRunSchema).optional(),
});
export type FullSubject = z.infer<typeof FullSubjectSchema>;