Files
cfw-autumn/shared/api/entities/entityOpModels.ts
John Yeo a005f6d879 refactor: separate subscriptions from customer cache
- Split subscription data into separate cache keys for better performance
- Updated cache utilities to handle subscriptions independently
- Modified Lua scripts to manage separate subscription cache entries
- Updated API models and expand logic for separated subscriptions
- Fixed test utilities to match new data structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:28:02 +00:00

42 lines
1.3 KiB
TypeScript

import { z } from "zod/v4";
import { CusExpand } from "../../models/cusModels/cusExpand.js";
import { queryStringArray } from "../apiUtils.js";
import { CustomerDataSchema } from "../common/customerData.js";
// Create Entity Params (based on CreateEntitySchema from shared/models)
export const CreateEntityParamsSchema = z.object({
id: z.string().nullable().meta({
description: "The ID of the entity",
}),
name: z.string().nullish().meta({
description: "The name of the entity",
}),
feature_id: z.string().meta({
description: "The ID of the feature this entity is associated with",
}),
customer_data: CustomerDataSchema.optional(),
});
// Get Entity Query Params
export const GetEntityQuerySchema = z.object({
expand: queryStringArray(
z.enum([
CusExpand.Invoices,
CusExpand.SubscriptionsPlan,
CusExpand.ScheduledSubscriptionsPlan,
CusExpand.BalancesFeature,
]),
).default([]),
skip_cache: z.boolean().optional(),
with_autumn_id: z.boolean().optional(),
});
export const CreateEntityQuerySchema = z.object({
with_autumn_id: z.boolean().default(false),
from_auto_create: z.boolean().default(false),
});
export type CreateEntityParams = z.infer<typeof CreateEntityParamsSchema>;
export type GetEntityQuery = z.infer<typeof GetEntityQuerySchema>;
export type CreateEntityQuery = z.infer<typeof CreateEntityQuerySchema>;