atmn 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cli.js +96 -96
  2. package/dist/source/compose/builders/builderFunctions.d.ts +83 -0
  3. package/dist/source/compose/index.d.ts +10 -0
  4. package/dist/source/compose/models/featureModels.d.ts +53 -0
  5. package/dist/source/compose/models/index.d.ts +2 -0
  6. package/dist/source/compose/models/planModels.d.ts +228 -0
  7. package/dist/source/index.d.ts +1 -0
  8. package/dist/source/index.js +52 -0
  9. package/dist/src/cli.js +87240 -0
  10. package/dist/src/compose/models/planModels.d.ts +17 -10
  11. package/package.json +1 -1
  12. package/dist/cli.cjs +0 -1640
  13. package/dist/cli.d.cts +0 -1
  14. package/dist/cli.d.ts +0 -1
  15. package/dist/cli.js.map +0 -278
  16. package/dist/commands/auth.d.ts +0 -1
  17. package/dist/commands/init.d.ts +0 -3
  18. package/dist/commands/nuke.d.ts +0 -1
  19. package/dist/commands/pull.d.ts +0 -3
  20. package/dist/commands/push.d.ts +0 -5
  21. package/dist/compose/builders/builderFunctions.d.ts +0 -63
  22. package/dist/compose/index.d.ts +0 -10
  23. package/dist/compose/models/composeModels.d.ts +0 -74
  24. package/dist/compose/models/productItemModels.d.ts +0 -77
  25. package/dist/constants.d.ts +0 -3
  26. package/dist/core/api.d.ts +0 -31
  27. package/dist/core/auth.d.ts +0 -1
  28. package/dist/core/builders/featureBuilder.d.ts +0 -2
  29. package/dist/core/builders/features.d.ts +0 -2
  30. package/dist/core/builders/freeTrialBuilder.d.ts +0 -4
  31. package/dist/core/builders/productBuilder.d.ts +0 -18
  32. package/dist/core/builders/products.d.ts +0 -18
  33. package/dist/core/config.d.ts +0 -40
  34. package/dist/core/nuke.d.ts +0 -6
  35. package/dist/core/pull.d.ts +0 -29
  36. package/dist/core/push.d.ts +0 -25
  37. package/dist/core/requests/featureRequests.d.ts +0 -10
  38. package/dist/core/requests/orgRequests.d.ts +0 -1
  39. package/dist/core/requests/prodRequests.d.ts +0 -10
  40. package/dist/core/utils.d.ts +0 -11
  41. package/dist/index.cjs +0 -58
  42. package/dist/index.d.cts +0 -188
  43. package/dist/index.d.ts +0 -188
  44. package/dist/index.js +0 -52
  45. package/dist/index.js.map +0 -10
@@ -0,0 +1,83 @@
1
+ import type { Plan, PlanFeature } from "../models/planModels.js";
2
+ import type { Feature } from "../models/featureModels.js";
3
+ type PlanInput = Omit<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'> & Partial<Pick<Plan, 'description' | 'add_on' | 'auto_enable' | 'group'>>;
4
+ /**
5
+ * Define a pricing plan in your Autumn configuration
6
+ *
7
+ * @param p - Plan configuration
8
+ * @returns Plan object for use in autumn.config.ts
9
+ *
10
+ * @example
11
+ * export const pro = plan({
12
+ * id: 'pro',
13
+ * name: 'Pro Plan',
14
+ * description: 'For growing teams',
15
+ * features: [
16
+ * planFeature({ feature_id: seats.id, included: 10 }),
17
+ * planFeature({
18
+ * feature_id: messages.id,
19
+ * included: 1000,
20
+ * reset: { interval: 'month' }
21
+ * })
22
+ * ],
23
+ * price: { amount: 50, interval: 'month' }
24
+ * });
25
+ */
26
+ export declare const plan: (params: PlanInput) => Plan;
27
+ /**
28
+ * Define a feature that can be included in plans
29
+ *
30
+ * @param f - Feature configuration
31
+ * @returns Feature object for use in autumn.config.ts
32
+ *
33
+ * @example
34
+ * // Metered consumable feature (like API calls, tokens)
35
+ * export const apiCalls = feature({
36
+ * id: 'api_calls',
37
+ * name: 'API Calls',
38
+ * type: 'metered',
39
+ * consumable: true
40
+ * });
41
+ *
42
+ * @example
43
+ * // Metered non-consumable feature (like seats)
44
+ * export const seats = feature({
45
+ * id: 'seats',
46
+ * name: 'Team Seats',
47
+ * type: 'metered',
48
+ * consumable: false
49
+ * });
50
+ */
51
+ export declare const feature: (params: Feature) => Feature;
52
+ /**
53
+ * Include a feature in a plan with specific configuration
54
+ *
55
+ * @param config - Feature configuration for this plan
56
+ * @returns PlanFeature for use in plan's features array
57
+ *
58
+ * @example
59
+ * // Simple included usage
60
+ * planFeature({
61
+ * feature_id: messages.id,
62
+ * included: 1000,
63
+ * reset: { interval: 'month' }
64
+ * })
65
+ *
66
+ * @example
67
+ * // Priced feature with tiers
68
+ * planFeature({
69
+ * feature_id: seats.id,
70
+ * included: 5,
71
+ * reset: { interval: 'month' },
72
+ * price: {
73
+ * tiers: [
74
+ * { to: 10, amount: 10 },
75
+ * { to: 'inf', amount: 8 }
76
+ * ],
77
+ * billing_method: 'usage_based',
78
+ * billing_units: 1
79
+ * }
80
+ * })
81
+ */
82
+ export declare const planFeature: (params: PlanFeature) => PlanFeature;
83
+ export {};
@@ -0,0 +1,10 @@
1
+ import { feature, plan, planFeature } from "./builders/builderFunctions.js";
2
+ import type { Feature } from "./models/featureModels.js";
3
+ import type { Plan, PlanFeature, FreeTrial } from "./models/planModels.js";
4
+ export { plan, feature, planFeature };
5
+ export type { Feature, Plan, PlanFeature, FreeTrial, };
6
+ export type Infinity = "infinity";
7
+ export type AutumnConfig = {
8
+ plans: Plan[];
9
+ features: Feature[];
10
+ };
@@ -0,0 +1,53 @@
1
+ import { z } from "zod/v4";
2
+ export declare const FeatureSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ event_names: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ credit_schema: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ metered_feature_id: z.ZodString;
8
+ credit_cost: z.ZodNumber;
9
+ }, z.core.$strip>>>;
10
+ }, z.core.$strip>;
11
+ type FeatureBase = {
12
+ /** Unique identifier for the feature */
13
+ id: string;
14
+ /** Display name for the feature */
15
+ name: string;
16
+ /** Event names that trigger this feature */
17
+ event_names?: string[];
18
+ /** Credit schema for credit_system features */
19
+ credit_schema?: Array<{
20
+ metered_feature_id: string;
21
+ credit_cost: number;
22
+ }>;
23
+ };
24
+ /** Boolean feature - no consumable field allowed */
25
+ export type BooleanFeature = FeatureBase & {
26
+ type: "boolean";
27
+ consumable?: never;
28
+ };
29
+ /** Metered feature - requires consumable field */
30
+ export type MeteredFeature = FeatureBase & {
31
+ type: "metered";
32
+ /** Whether usage is consumed (true) or accumulated (false) */
33
+ consumable: boolean;
34
+ };
35
+ /** Credit system feature - always consumable */
36
+ export type CreditSystemFeature = FeatureBase & {
37
+ type: "credit_system";
38
+ /** Credit systems are always consumable */
39
+ consumable?: true;
40
+ /** Required: defines how credits map to metered features */
41
+ credit_schema: Array<{
42
+ metered_feature_id: string;
43
+ credit_cost: number;
44
+ }>;
45
+ };
46
+ /**
47
+ * Feature definition with type-safe constraints:
48
+ * - Boolean features cannot have consumable
49
+ * - Metered features require consumable (true = single_use style, false = continuous_use style)
50
+ * - Credit system features are always consumable and require credit_schema
51
+ */
52
+ export type Feature = BooleanFeature | MeteredFeature | CreditSystemFeature;
53
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './planModels.js';
2
+ export * from './featureModels.js';
@@ -0,0 +1,228 @@
1
+ import { z } from "zod/v4";
2
+ export declare const UsageTierSchema: z.ZodObject<{
3
+ to: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"inf">]>;
4
+ amount: z.ZodNumber;
5
+ }, z.core.$strip>;
6
+ export declare const PlanFeatureSchema: z.ZodObject<{
7
+ feature_id: z.ZodString;
8
+ granted_balance: z.ZodOptional<z.ZodNumber>;
9
+ unlimited: z.ZodOptional<z.ZodBoolean>;
10
+ reset: z.ZodOptional<z.ZodObject<{
11
+ interval: z.ZodUnion<readonly [z.ZodLiteral<"one_off">, z.ZodLiteral<"hour">, z.ZodLiteral<"day">, z.ZodLiteral<"week">, z.ZodLiteral<"month">, z.ZodLiteral<"quarter">, z.ZodLiteral<"year">]>;
12
+ interval_count: z.ZodOptional<z.ZodNumber>;
13
+ reset_when_enabled: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>>;
15
+ price: z.ZodOptional<z.ZodObject<{
16
+ amount: z.ZodOptional<z.ZodNumber>;
17
+ tiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
18
+ to: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"inf">]>;
19
+ amount: z.ZodNumber;
20
+ }, z.core.$strip>>>;
21
+ interval: z.ZodUnion<readonly [z.ZodLiteral<"month">, z.ZodLiteral<"quarter">, z.ZodLiteral<"semi_annual">, z.ZodLiteral<"year">]>;
22
+ interval_count: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
23
+ billing_units: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
24
+ usage_model: z.ZodUnion<readonly [z.ZodLiteral<"prepaid">, z.ZodLiteral<"pay_per_use">]>;
25
+ max_purchase: z.ZodOptional<z.ZodNumber>;
26
+ }, z.core.$strip>>;
27
+ proration: z.ZodOptional<z.ZodObject<{
28
+ on_increase: z.ZodUnion<readonly [z.ZodLiteral<"prorate">, z.ZodLiteral<"charge_immediately">]>;
29
+ on_decrease: z.ZodUnion<readonly [z.ZodLiteral<"prorate">, z.ZodLiteral<"refund_immediately">, z.ZodLiteral<"no_action">]>;
30
+ }, z.core.$strip>>;
31
+ rollover: z.ZodOptional<z.ZodObject<{
32
+ max: z.ZodNumber;
33
+ expiry_duration_type: z.ZodUnion<readonly [z.ZodLiteral<"month">, z.ZodLiteral<"forever">]>;
34
+ expiry_duration_length: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$strip>>;
36
+ }, z.core.$strip>;
37
+ export declare const FreeTrialSchema: z.ZodObject<{
38
+ duration_type: z.ZodUnion<readonly [z.ZodLiteral<"day">, z.ZodLiteral<"month">, z.ZodLiteral<"year">]>;
39
+ duration_length: z.ZodNumber;
40
+ card_required: z.ZodBoolean;
41
+ }, z.core.$strip>;
42
+ export declare const PlanSchema: z.ZodObject<{
43
+ description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
44
+ add_on: z.ZodDefault<z.ZodBoolean>;
45
+ default: z.ZodDefault<z.ZodBoolean>;
46
+ price: z.ZodOptional<z.ZodObject<{
47
+ amount: z.ZodNumber;
48
+ interval: z.ZodUnion<readonly [z.ZodLiteral<"month">, z.ZodLiteral<"quarter">, z.ZodLiteral<"semi_annual">, z.ZodLiteral<"year">]>;
49
+ }, z.core.$strip>>;
50
+ features: z.ZodOptional<z.ZodArray<z.ZodObject<{
51
+ feature_id: z.ZodString;
52
+ granted_balance: z.ZodOptional<z.ZodNumber>;
53
+ unlimited: z.ZodOptional<z.ZodBoolean>;
54
+ reset: z.ZodOptional<z.ZodObject<{
55
+ interval: z.ZodUnion<readonly [z.ZodLiteral<"one_off">, z.ZodLiteral<"hour">, z.ZodLiteral<"day">, z.ZodLiteral<"week">, z.ZodLiteral<"month">, z.ZodLiteral<"quarter">, z.ZodLiteral<"year">]>;
56
+ interval_count: z.ZodOptional<z.ZodNumber>;
57
+ reset_when_enabled: z.ZodOptional<z.ZodBoolean>;
58
+ }, z.core.$strip>>;
59
+ price: z.ZodOptional<z.ZodObject<{
60
+ amount: z.ZodOptional<z.ZodNumber>;
61
+ tiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
+ to: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"inf">]>;
63
+ amount: z.ZodNumber;
64
+ }, z.core.$strip>>>;
65
+ interval: z.ZodUnion<readonly [z.ZodLiteral<"month">, z.ZodLiteral<"quarter">, z.ZodLiteral<"semi_annual">, z.ZodLiteral<"year">]>;
66
+ interval_count: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
67
+ billing_units: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
68
+ usage_model: z.ZodUnion<readonly [z.ZodLiteral<"prepaid">, z.ZodLiteral<"pay_per_use">]>;
69
+ max_purchase: z.ZodOptional<z.ZodNumber>;
70
+ }, z.core.$strip>>;
71
+ proration: z.ZodOptional<z.ZodObject<{
72
+ on_increase: z.ZodUnion<readonly [z.ZodLiteral<"prorate">, z.ZodLiteral<"charge_immediately">]>;
73
+ on_decrease: z.ZodUnion<readonly [z.ZodLiteral<"prorate">, z.ZodLiteral<"refund_immediately">, z.ZodLiteral<"no_action">]>;
74
+ }, z.core.$strip>>;
75
+ rollover: z.ZodOptional<z.ZodObject<{
76
+ max: z.ZodNumber;
77
+ expiry_duration_type: z.ZodUnion<readonly [z.ZodLiteral<"month">, z.ZodLiteral<"forever">]>;
78
+ expiry_duration_length: z.ZodOptional<z.ZodNumber>;
79
+ }, z.core.$strip>>;
80
+ }, z.core.$strip>>>;
81
+ free_trial: z.ZodOptional<z.ZodNullable<z.ZodObject<{
82
+ duration_type: z.ZodUnion<readonly [z.ZodLiteral<"day">, z.ZodLiteral<"month">, z.ZodLiteral<"year">]>;
83
+ duration_length: z.ZodNumber;
84
+ card_required: z.ZodBoolean;
85
+ }, z.core.$strip>>>;
86
+ id: z.ZodString;
87
+ name: z.ZodString;
88
+ group: z.ZodDefault<z.ZodString>;
89
+ }, z.core.$strip>;
90
+ export type ResetInterval = "one_off" | "hour" | "day" | "week" | "month" | "quarter" | "year";
91
+ export type RolloverExpiryDurationType = "month" | "forever";
92
+ export type BillingInterval = "month" | "quarter" | "semi_annual" | "year";
93
+ export type BillingMethod = "prepaid" | "usage_based";
94
+ export type OnIncrease = "prorate" | "charge_immediately";
95
+ export type OnDecrease = "prorate" | "refund_immediately" | "no_action";
96
+ type ResetConfig = {
97
+ /** How often usage resets (e.g., 'month', 'day') */
98
+ interval: ResetInterval;
99
+ /** Number of intervals between resets (default: 1) */
100
+ interval_count?: number;
101
+ };
102
+ type ProrationConfig = {
103
+ /** Behavior when quantity increases */
104
+ on_increase: OnIncrease;
105
+ /** Behavior when quantity decreases */
106
+ on_decrease: OnDecrease;
107
+ };
108
+ type RolloverConfig = {
109
+ /** Maximum amount that can roll over (null for unlimited) */
110
+ max: number | null;
111
+ /** How long rollover lasts before expiring */
112
+ expiry_duration_type: RolloverExpiryDurationType;
113
+ /** Duration length for rollover expiry */
114
+ expiry_duration_length?: number;
115
+ };
116
+ type PlanFeatureBaseFields = {
117
+ /** Reference to the feature being configured */
118
+ feature_id: string;
119
+ /** Amount of usage included in this plan */
120
+ included?: number;
121
+ /** Whether usage is unlimited */
122
+ unlimited?: boolean;
123
+ /** Proration rules for quantity changes */
124
+ proration?: ProrationConfig;
125
+ /** Rollover policy for unused usage */
126
+ rollover?: RolloverConfig;
127
+ };
128
+ type PriceWithoutInterval = {
129
+ /** Flat price per unit */
130
+ amount?: number;
131
+ /** Tiered pricing structure based on usage ranges */
132
+ tiers?: Array<{
133
+ to: number | "inf";
134
+ amount: number;
135
+ }>;
136
+ /** Number of units per billing cycle */
137
+ billing_units?: number;
138
+ /** Billing method: 'prepaid' or 'usage_based' */
139
+ billing_method: BillingMethod;
140
+ /** Maximum purchasable quantity */
141
+ max_purchase?: number;
142
+ /** Cannot have price.interval when using top-level reset */
143
+ interval?: never;
144
+ interval_count?: never;
145
+ };
146
+ type PriceWithInterval = {
147
+ /** Flat price per unit */
148
+ amount?: number;
149
+ /** Tiered pricing structure based on usage ranges */
150
+ tiers?: Array<{
151
+ to: number | "inf";
152
+ amount: number;
153
+ }>;
154
+ /** Number of units per billing cycle */
155
+ billing_units?: number;
156
+ /** Billing method: 'prepaid' or 'usage_based' */
157
+ billing_method: BillingMethod;
158
+ /** Maximum purchasable quantity */
159
+ max_purchase?: number;
160
+ /** Billing interval (e.g., 'month', 'day') */
161
+ interval: ResetInterval;
162
+ /** Number of intervals between billing cycles (default: 1) */
163
+ interval_count?: number;
164
+ };
165
+ /**
166
+ * Plan feature with top-level reset configuration.
167
+ * Use this for free allocations or features that reset but aren't priced per-use.
168
+ */
169
+ export type PlanFeatureWithReset = PlanFeatureBaseFields & {
170
+ /** Reset configuration for usage limits */
171
+ reset: ResetConfig;
172
+ /** Optional pricing (cannot have price.interval when using top-level reset) */
173
+ price?: PriceWithoutInterval;
174
+ };
175
+ /**
176
+ * Plan feature with pricing that includes interval configuration.
177
+ * Use this for usage-based pricing where interval determines billing cycle.
178
+ */
179
+ export type PlanFeatureWithPriceInterval = PlanFeatureBaseFields & {
180
+ /** Cannot have top-level reset when using price.interval */
181
+ reset?: never;
182
+ /** Pricing configuration with billing interval */
183
+ price: PriceWithInterval;
184
+ };
185
+ /**
186
+ * Plan feature without any reset configuration.
187
+ * Use this for continuous-use features (like seats) that don't reset.
188
+ */
189
+ export type PlanFeatureNoReset = PlanFeatureBaseFields & {
190
+ /** No reset for continuous-use features */
191
+ reset?: never;
192
+ /** Optional pricing without interval */
193
+ price?: PriceWithoutInterval;
194
+ };
195
+ /**
196
+ * Plan feature configuration with mutually exclusive reset patterns:
197
+ * - PlanFeatureWithReset: Top-level reset (for free allocations)
198
+ * - PlanFeatureWithPriceInterval: price.interval (for usage-based pricing billing cycle)
199
+ * - PlanFeatureNoReset: No reset (for continuous-use features like seats)
200
+ */
201
+ export type PlanFeature = PlanFeatureWithReset | PlanFeatureWithPriceInterval | PlanFeatureNoReset;
202
+ export type FreeTrial = z.infer<typeof FreeTrialSchema>;
203
+ export type Plan = {
204
+ /** Unique identifier for the plan */
205
+ id: string;
206
+ /** Display name for the plan */
207
+ name: string;
208
+ /** Optional description explaining what this plan offers */
209
+ description?: string | null;
210
+ /** Grouping identifier for organizing related plans */
211
+ group?: string;
212
+ /** Whether this plan can be purchased alongside other plans */
213
+ add_on?: boolean;
214
+ /** Whether to automatically enable this plan for new customers */
215
+ auto_enable?: boolean;
216
+ /** Base price for the plan */
217
+ price?: {
218
+ /** Price in your currency (e.g., 50 for $50.00) */
219
+ amount: number;
220
+ /** Billing frequency */
221
+ interval: BillingInterval | ResetInterval;
222
+ };
223
+ /** Features included with usage limits and pricing */
224
+ features?: PlanFeature[];
225
+ /** Free trial period before billing begins */
226
+ free_trial?: FreeTrial | null;
227
+ };
228
+ export {};
@@ -0,0 +1 @@
1
+ export * from './compose/index.js';
@@ -0,0 +1,52 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
+ var __promiseAll = (args) => Promise.all(args);
30
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ // source/compose/builders/builderFunctions.ts
33
+ var plan = (params) => {
34
+ return {
35
+ ...params,
36
+ description: params.description ?? null,
37
+ add_on: params.add_on ?? false,
38
+ auto_enable: params.auto_enable ?? false,
39
+ group: params.group ?? ""
40
+ };
41
+ };
42
+ var feature = (params) => {
43
+ return params;
44
+ };
45
+ var planFeature = (params) => {
46
+ return params;
47
+ };
48
+ export {
49
+ planFeature,
50
+ plan,
51
+ feature
52
+ };