Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions atmn/src/commands/push/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ function validatePlanFeature(
});
}

// Cannot have both top-level reset AND price (with amount/tiers)
// These are conflicting billing models: reset = free allocation, price = paid
if (hasTopLevelReset && planFeature.price && (planFeature.price.amount !== undefined || planFeature.price.tiers)) {
errors.push({
path: basePath,
message: `Cannot have both "reset" and "price" with an amount/tiers. "reset" is for free allocations that reset periodically. For paid usage, remove "reset" and use "price: { interval: '...', amount: ..., billing_method: '...' }" instead.`,
});
}

// ========== FEATURE TYPE VALIDATIONS ==========
if (featureDefinition) {
// Boolean features cannot have reset
Expand Down
4 changes: 1 addition & 3 deletions atmn/src/compose/builders/builderFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { Plan, PlanFeature, FreeTrial } from "../models/planModels.js";
import type { Feature } from "../models/featureModels.js";

type PlanInput = Omit<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'> & Partial<Pick<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'>>;
type PlanInput = Omit<Plan, 'add_on' | 'auto_enable' | 'group'> & Partial<Pick<Plan, 'add_on' | 'auto_enable' | 'group'>>;

/**
* Define a pricing plan in your Autumn configuration
Expand All @@ -17,7 +17,6 @@ type PlanInput = Omit<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'>
* export const pro = plan({
* id: 'pro',
* name: 'Pro Plan',
* description: 'For growing teams',
* items: [
* planFeature({ feature_id: seats.id, included: 10 }),
* planFeature({
Expand All @@ -32,7 +31,6 @@ type PlanInput = Omit<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'>
export const plan = (params: PlanInput): Plan => {
return {
...params,
description: params.description ?? null,
add_on: params.add_on ?? false,
auto_enable: params.auto_enable ?? false,
group: params.group ?? ""
Expand Down
3 changes: 0 additions & 3 deletions atmn/src/compose/models/planModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ export type Plan = {
/** Display name for the plan */
name: string;

/** Optional description explaining what this plan offers */
description?: string | null;

/** Grouping identifier for organizing related plans */
group?: string;

Expand Down
1 change: 0 additions & 1 deletion atmn/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const messages = feature({
export const pro = plan({
id: 'pro',
name: 'Pro',
description: 'Professional plan for growing teams',
add_on: false,
auto_enable: false,
price: {
Expand Down
1 change: 0 additions & 1 deletion atmn/src/lib/transforms/apiToSdk/Transformer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe("Transformer", () => {
const apiPlan: any = {
id: "pro",
name: "Pro Plan",
description: "Professional tier",
auto_enable: true,
items: [],
};
Expand Down
2 changes: 1 addition & 1 deletion atmn/src/lib/transforms/apiToSdk/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createTransformer } from "./Transformer.js";
* Declarative plan transformer - replaces 57 lines with ~20 lines of config
*/
export const planTransformer = createTransformer<ApiPlan, Plan>({
copy: ["id", "name", "description", "group", "add_on", "auto_enable", "free_trial"],
copy: ["id", "name", "group", "add_on", "auto_enable", "free_trial"],

// Swap null to undefined for these fields (API → SDK direction)
// When pulling from API: null becomes undefined (cleaner, won't show in generated code)
Expand Down
5 changes: 0 additions & 5 deletions atmn/src/lib/transforms/sdkToApi/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { Plan, PlanFeature } from "../../../compose/models/index.js";
export interface ApiPlanParams {
id: string;
name: string;
description?: string | null;
group?: string;
add_on?: boolean;
auto_enable?: boolean;
Expand Down Expand Up @@ -137,10 +136,6 @@ export function transformPlanToApi(plan: Plan): ApiPlanParams {
name: plan.name,
};

if (plan.description !== undefined) {
result.description = plan.description;
}

if (plan.group !== undefined) {
result.group = plan.group;
}
Expand Down
5 changes: 0 additions & 5 deletions atmn/src/lib/transforms/sdkToCode/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ export function buildPlanCode(
lines.push(`\tid: '${plan.id}',`);
lines.push(`\tname: '${plan.name}',`);

// Add description
if (plan.description !== undefined && plan.description !== null) {
lines.push(`\tdescription: '${plan.description}',`);
}

// Add group (only if it has a non-empty string value)
// undefined and null both mean "no group" and should be omitted from generated code
if (plan.group !== undefined && plan.group !== null && plan.group !== "") {
Expand Down
2 changes: 0 additions & 2 deletions typegen/typeConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ export function getAtmnTypeConfigs(
paramType: "Plan",
targetFile: path.join(buildersDir, "builderFunctions.ts"),
defaults: {
description: null,
add_on: false,
auto_enable: false,
group: "",
Expand All @@ -664,7 +663,6 @@ export function getAtmnTypeConfigs(
* export const pro = plan({
* id: 'pro',
* name: 'Pro Plan',
* description: 'For growing teams',
* items: [
* planFeature({ feature_id: seats.id, included: 10 }),
* planFeature({
Expand Down