feat: tiny kitty bean toes

pull/715/head
Travis Fischer 2025-06-01 02:44:46 +07:00
rodzic f54470cb45
commit 1532fa6345
10 zmienionych plików z 104 dodań i 46 usunięć

Wyświetl plik

@ -24,6 +24,8 @@ exports[`loadAgenticConfig > basic-raw-free-json 1`] = `
"slug": "free", "slug": "free",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -51,6 +53,8 @@ exports[`loadAgenticConfig > basic-raw-free-ts 1`] = `
"slug": "free", "slug": "free",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -74,7 +78,7 @@ exports[`loadAgenticConfig > invalid: invalid-origin-url-3 1`] = `[ZodValidation
exports[`loadAgenticConfig > invalid: pricing-base-inconsistent 1`] = `[ZodValidationError: Validation error: Invalid PricingPlanLineItem "base": reserved "base" LineItems must have "licensed" usage type. at "pricingPlans[1].lineItems[0]"]`; exports[`loadAgenticConfig > invalid: pricing-base-inconsistent 1`] = `[ZodValidationError: Validation error: Invalid PricingPlanLineItem "base": reserved "base" LineItems must have "licensed" usage type. at "pricingPlans[1].lineItems[0]"]`;
exports[`loadAgenticConfig > invalid: pricing-custom-inconsistent 1`] = `[Error: Invalid pricingPlans: all PricingPlans which contain the same LineItems (by slug "custom") must have the same usage type ("licensed" or "metered").]`; exports[`loadAgenticConfig > invalid: pricing-custom-inconsistent 1`] = `[Error: Invalid pricingPlans: all PricingPlans which contain the same LineItems (by slug "custom-test") must have the same usage type ("licensed" or "metered").]`;
exports[`loadAgenticConfig > invalid: pricing-duplicate-0 1`] = `[Error: Invalid pricingPlans: duplicate PricingPlan slugs. All PricingPlan slugs must be unique (e.g. "free", "starter-monthly", "pro-annual", etc).]`; exports[`loadAgenticConfig > invalid: pricing-duplicate-0 1`] = `[Error: Invalid pricingPlans: duplicate PricingPlan slugs. All PricingPlan slugs must be unique (e.g. "free", "starter-monthly", "pro-annual", etc).]`;
@ -149,6 +153,8 @@ exports[`loadAgenticConfig > pricing-3-plans 1`] = `
"slug": "pro", "slug": "pro",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -190,7 +196,7 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
"interval": 2592000, "interval": 2592000,
"maxPerInterval": 1000, "maxPerInterval": 1000,
}, },
"slug": "custom", "slug": "custom-test",
"unitAmount": 100, "unitAmount": 100,
"usageType": "metered", "usageType": "metered",
}, },
@ -212,7 +218,7 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
"interval": 2592000, "interval": 2592000,
"maxPerInterval": 1500, "maxPerInterval": 1500,
}, },
"slug": "custom", "slug": "custom-test",
"unitAmount": 80, "unitAmount": 80,
"usageType": "metered", "usageType": "metered",
}, },
@ -221,6 +227,8 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
"slug": "basic-annual", "slug": "basic-annual",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -261,6 +269,8 @@ exports[`loadAgenticConfig > pricing-freemium 1`] = `
"trialPeriodDays": 7, "trialPeriodDays": 7,
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -281,7 +291,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
"lineItems": [ "lineItems": [
{ {
"amount": 0, "amount": 0,
"slug": "custom", "slug": "custom-base",
"usageType": "licensed", "usageType": "licensed",
}, },
], ],
@ -293,7 +303,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
"lineItems": [ "lineItems": [
{ {
"amount": 100, "amount": 100,
"slug": "custom", "slug": "custom-base",
"usageType": "licensed", "usageType": "licensed",
}, },
], ],
@ -305,7 +315,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
"lineItems": [ "lineItems": [
{ {
"amount": 70, "amount": 70,
"slug": "custom", "slug": "custom-base",
"usageType": "licensed", "usageType": "licensed",
}, },
], ],
@ -313,6 +323,8 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
"slug": "basic-annual", "slug": "basic-annual",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;
@ -373,5 +385,7 @@ exports[`loadAgenticConfig > pricing-pay-as-you-go 1`] = `
"slug": "pay-as-you-go", "slug": "pay-as-you-go",
}, },
], ],
"toolConfigs": [],
"version": undefined,
} }
`; `;

Wyświetl plik

@ -24,7 +24,7 @@ export default defineConfig({
usageType: 'metered', usageType: 'metered',
billingScheme: 'per_unit', billingScheme: 'per_unit',
unitAmount: 0.467 unitAmount: 0.467
} } as any
] ]
} }
] ]

Wyświetl plik

@ -9,7 +9,7 @@ export default defineConfig({
slug: 'free', slug: 'free',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'licensed', usageType: 'licensed',
amount: 0 amount: 0
} }
@ -20,7 +20,7 @@ export default defineConfig({
slug: 'starter', slug: 'starter',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'metered', usageType: 'metered',
billingScheme: 'per_unit', billingScheme: 'per_unit',
unitAmount: 100 unitAmount: 100

Wyświetl plik

@ -11,7 +11,7 @@ export default defineConfig({
interval: 'month', interval: 'month',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'licensed', usageType: 'licensed',
amount: 100 amount: 100
} }
@ -23,7 +23,7 @@ export default defineConfig({
interval: 'year', interval: 'year',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'licensed', usageType: 'licensed',
amount: 70 amount: 70
} }

Wyświetl plik

@ -9,12 +9,12 @@ export default defineConfig({
slug: 'basic', slug: 'basic',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'licensed', usageType: 'licensed',
amount: 100 amount: 100
}, },
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'licensed', usageType: 'licensed',
amount: 200 amount: 200
} }

Wyświetl plik

@ -27,12 +27,14 @@ export default defineConfig({
amount: 500 amount: 500
}, },
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'metered', usageType: 'metered',
billingScheme: 'per_unit', billingScheme: 'per_unit',
unitAmount: 100, unitAmount: 100,
rateLimit: { rateLimit: {
maxPerInterval: 1000, maxPerInterval: 1000,
// TODO
// interval: '30d' // 60 * 60 * 24 * 30 // 30 days in seconds
interval: 60 * 60 * 24 * 30 // 30 days in seconds interval: 60 * 60 * 24 * 30 // 30 days in seconds
} }
} }
@ -49,7 +51,7 @@ export default defineConfig({
amount: 400 * 12 // 20% discount amount: 400 * 12 // 20% discount
}, },
{ {
slug: 'custom', slug: 'custom-test',
usageType: 'metered', usageType: 'metered',
billingScheme: 'per_unit', billingScheme: 'per_unit',
unitAmount: 80, // 20% discount unitAmount: 80, // 20% discount

Wyświetl plik

@ -10,7 +10,7 @@ export default defineConfig({
slug: 'free', slug: 'free',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-base',
usageType: 'licensed', usageType: 'licensed',
amount: 0 amount: 0
} }
@ -22,7 +22,7 @@ export default defineConfig({
interval: 'month', interval: 'month',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-base',
usageType: 'licensed', usageType: 'licensed',
amount: 100 amount: 100
} }
@ -34,7 +34,7 @@ export default defineConfig({
interval: 'year', interval: 'year',
lineItems: [ lineItems: [
{ {
slug: 'custom', slug: 'custom-base',
usageType: 'licensed', usageType: 'licensed',
amount: 70 amount: 70
} }

Wyświetl plik

@ -1,7 +1,7 @@
export * from './agentic-project-config' export * from './agentic-project-config'
export * from './auth-subjects' export * from './auth-subjects'
export * from './mcp' export * from './mcp'
export type * as openapi from './openapi' export type * as openapi from './openapi.d.ts'
export * from './origin-adapter' export * from './origin-adapter'
export * from './pricing' export * from './pricing'
export * from './rate-limit' export * from './rate-limit'

Wyświetl plik

@ -275,20 +275,44 @@ export const pricingPlanMeteredLineItemSchema =
.optional() .optional()
}) })
) )
export type PricingPlanMeteredLineItem = Simplify< export type PricingPlanMeteredLineItem =
| (Omit< | {
z.infer<typeof pricingPlanMeteredLineItemSchema>, usageType: 'metered'
'billingScheme' | 'tiers' | 'tiersMode'
> & {
billingScheme: 'per_unit' billingScheme: 'per_unit'
}) unitAmount: number
| (Omit< label?: string
z.infer<typeof pricingPlanMeteredLineItemSchema>, unitLabel?: string
'billingScheme' | 'unitAmount' rateLimit?: {
> & { interval: number
maxPerInterval: number
}
defaultAggregation?: {
formula: 'sum' | 'count' | 'last'
}
transformQuantity?: {
divideBy: number
round: 'down' | 'up'
}
}
| {
usageType: 'metered'
billingScheme: 'tiered' billingScheme: 'tiered'
}) tiers: PricingPlanTier[]
> tiersMode: 'graduated' | 'volume'
label?: string
unitLabel?: string
rateLimit?: {
interval: number
maxPerInterval: number
}
defaultAggregation?: {
formula: 'sum' | 'count' | 'last'
}
transformQuantity?: {
divideBy: number
round: 'down' | 'up'
}
}
/** /**
* The `base` LineItem is used to charge a fixed amount for a service using * The `base` LineItem is used to charge a fixed amount for a service using
@ -321,9 +345,11 @@ export const requestsPricingPlanLineItemSchema =
*/ */
unitLabel: z.string().default('API calls').optional() unitLabel: z.string().default('API calls').optional()
}) })
export type RequestsPricingPlanLineItem = PricingPlanMeteredLineItem & { export type RequestsPricingPlanLineItem = Simplify<
slug: 'requests' PricingPlanMeteredLineItem & {
} slug: 'requests'
}
>
/** /**
* PricingPlanLineItems represent a single line-item in a Stripe Subscription. * PricingPlanLineItems represent a single line-item in a Stripe Subscription.
@ -378,19 +404,35 @@ export const pricingPlanLineItemSchema = z
.openapi('PricingPlanLineItem') .openapi('PricingPlanLineItem')
// export type PricingPlanLineItem = z.infer<typeof pricingPlanLineItemSchema> // export type PricingPlanLineItem = z.infer<typeof pricingPlanLineItemSchema>
// This is a more complex discriminated union based on both `slug` and `usageType` // This is a more complex discriminated union based on:
export type PricingPlanLineItem = Simplify< // `slug`, `usageType`, and `billingScheme`
export type PricingPlanLineItem =
| BasePricingPlanLineItem | BasePricingPlanLineItem
| RequestsPricingPlanLineItem | RequestsPricingPlanLineItem
| ( | ({
| (Omit<PricingPlanLicensedLineItem, 'slug'> & { slug: CustomPricingPlanLineItemSlug
slug: CustomPricingPlanLineItemSlug usageType: 'licensed'
}) } & Omit<PricingPlanLicensedLineItem, 'slug' | 'usageType'>)
| (Omit<PricingPlanMeteredLineItem, 'slug'> & { | ({
slug: CustomPricingPlanLineItemSlug slug: CustomPricingPlanLineItemSlug
}) usageType: 'metered'
) billingScheme: 'per_unit'
> } & Omit<
PricingPlanMeteredLineItem & {
billingScheme: 'per_unit'
},
'slug' | 'usageType' | 'billingScheme' | 'tiers' | 'tiersMode'
>)
| ({
slug: CustomPricingPlanLineItemSlug
usageType: 'metered'
billingScheme: 'tiered'
} & Omit<
PricingPlanMeteredLineItem & {
billingScheme: 'tiered'
},
'slug' | 'usageType' | 'billingScheme' | 'unitAmount'
>)
/** /**
* Represents the config for a single Stripe subscription plan with one or more * Represents the config for a single Stripe subscription plan with one or more

Wyświetl plik

@ -7,7 +7,7 @@
import type { PricingPlan } from '@agentic/platform-types' import type { PricingPlan } from '@agentic/platform-types'
import type { Simplify } from 'type-fest' import type { Simplify } from 'type-fest'
import type { components } from './openapi' import type { components } from './openapi.d.ts'
export type Consumer = components['schemas']['Consumer'] export type Consumer = components['schemas']['Consumer']
export type Project = components['schemas']['Project'] export type Project = components['schemas']['Project']