kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: tiny kitty bean toes
rodzic
f54470cb45
commit
1532fa6345
|
@ -24,6 +24,8 @@ exports[`loadAgenticConfig > basic-raw-free-json 1`] = `
|
|||
"slug": "free",
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -51,6 +53,8 @@ exports[`loadAgenticConfig > basic-raw-free-ts 1`] = `
|
|||
"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-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).]`;
|
||||
|
||||
|
@ -149,6 +153,8 @@ exports[`loadAgenticConfig > pricing-3-plans 1`] = `
|
|||
"slug": "pro",
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -190,7 +196,7 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
|
|||
"interval": 2592000,
|
||||
"maxPerInterval": 1000,
|
||||
},
|
||||
"slug": "custom",
|
||||
"slug": "custom-test",
|
||||
"unitAmount": 100,
|
||||
"usageType": "metered",
|
||||
},
|
||||
|
@ -212,7 +218,7 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
|
|||
"interval": 2592000,
|
||||
"maxPerInterval": 1500,
|
||||
},
|
||||
"slug": "custom",
|
||||
"slug": "custom-test",
|
||||
"unitAmount": 80,
|
||||
"usageType": "metered",
|
||||
},
|
||||
|
@ -221,6 +227,8 @@ exports[`loadAgenticConfig > pricing-custom-0 1`] = `
|
|||
"slug": "basic-annual",
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -261,6 +269,8 @@ exports[`loadAgenticConfig > pricing-freemium 1`] = `
|
|||
"trialPeriodDays": 7,
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -281,7 +291,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
|
|||
"lineItems": [
|
||||
{
|
||||
"amount": 0,
|
||||
"slug": "custom",
|
||||
"slug": "custom-base",
|
||||
"usageType": "licensed",
|
||||
},
|
||||
],
|
||||
|
@ -293,7 +303,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
|
|||
"lineItems": [
|
||||
{
|
||||
"amount": 100,
|
||||
"slug": "custom",
|
||||
"slug": "custom-base",
|
||||
"usageType": "licensed",
|
||||
},
|
||||
],
|
||||
|
@ -305,7 +315,7 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
|
|||
"lineItems": [
|
||||
{
|
||||
"amount": 70,
|
||||
"slug": "custom",
|
||||
"slug": "custom-base",
|
||||
"usageType": "licensed",
|
||||
},
|
||||
],
|
||||
|
@ -313,6 +323,8 @@ exports[`loadAgenticConfig > pricing-monthly-annual 1`] = `
|
|||
"slug": "basic-annual",
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -373,5 +385,7 @@ exports[`loadAgenticConfig > pricing-pay-as-you-go 1`] = `
|
|||
"slug": "pay-as-you-go",
|
||||
},
|
||||
],
|
||||
"toolConfigs": [],
|
||||
"version": undefined,
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -24,7 +24,7 @@ export default defineConfig({
|
|||
usageType: 'metered',
|
||||
billingScheme: 'per_unit',
|
||||
unitAmount: 0.467
|
||||
}
|
||||
} as any
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -9,7 +9,7 @@ export default defineConfig({
|
|||
slug: 'free',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'licensed',
|
||||
amount: 0
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ export default defineConfig({
|
|||
slug: 'starter',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'metered',
|
||||
billingScheme: 'per_unit',
|
||||
unitAmount: 100
|
||||
|
|
|
@ -11,7 +11,7 @@ export default defineConfig({
|
|||
interval: 'month',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'licensed',
|
||||
amount: 100
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export default defineConfig({
|
|||
interval: 'year',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'licensed',
|
||||
amount: 70
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ export default defineConfig({
|
|||
slug: 'basic',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'licensed',
|
||||
amount: 100
|
||||
},
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'licensed',
|
||||
amount: 200
|
||||
}
|
||||
|
|
|
@ -27,12 +27,14 @@ export default defineConfig({
|
|||
amount: 500
|
||||
},
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'metered',
|
||||
billingScheme: 'per_unit',
|
||||
unitAmount: 100,
|
||||
rateLimit: {
|
||||
maxPerInterval: 1000,
|
||||
// TODO
|
||||
// interval: '30d' // 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
|
||||
},
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-test',
|
||||
usageType: 'metered',
|
||||
billingScheme: 'per_unit',
|
||||
unitAmount: 80, // 20% discount
|
||||
|
|
|
@ -10,7 +10,7 @@ export default defineConfig({
|
|||
slug: 'free',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-base',
|
||||
usageType: 'licensed',
|
||||
amount: 0
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default defineConfig({
|
|||
interval: 'month',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-base',
|
||||
usageType: 'licensed',
|
||||
amount: 100
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ export default defineConfig({
|
|||
interval: 'year',
|
||||
lineItems: [
|
||||
{
|
||||
slug: 'custom',
|
||||
slug: 'custom-base',
|
||||
usageType: 'licensed',
|
||||
amount: 70
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export * from './agentic-project-config'
|
||||
export * from './auth-subjects'
|
||||
export * from './mcp'
|
||||
export type * as openapi from './openapi'
|
||||
export type * as openapi from './openapi.d.ts'
|
||||
export * from './origin-adapter'
|
||||
export * from './pricing'
|
||||
export * from './rate-limit'
|
||||
|
|
|
@ -275,20 +275,44 @@ export const pricingPlanMeteredLineItemSchema =
|
|||
.optional()
|
||||
})
|
||||
)
|
||||
export type PricingPlanMeteredLineItem = Simplify<
|
||||
| (Omit<
|
||||
z.infer<typeof pricingPlanMeteredLineItemSchema>,
|
||||
'billingScheme' | 'tiers' | 'tiersMode'
|
||||
> & {
|
||||
export type PricingPlanMeteredLineItem =
|
||||
| {
|
||||
usageType: 'metered'
|
||||
billingScheme: 'per_unit'
|
||||
})
|
||||
| (Omit<
|
||||
z.infer<typeof pricingPlanMeteredLineItemSchema>,
|
||||
'billingScheme' | 'unitAmount'
|
||||
> & {
|
||||
unitAmount: number
|
||||
label?: string
|
||||
unitLabel?: string
|
||||
rateLimit?: {
|
||||
interval: number
|
||||
maxPerInterval: number
|
||||
}
|
||||
defaultAggregation?: {
|
||||
formula: 'sum' | 'count' | 'last'
|
||||
}
|
||||
transformQuantity?: {
|
||||
divideBy: number
|
||||
round: 'down' | 'up'
|
||||
}
|
||||
}
|
||||
| {
|
||||
usageType: 'metered'
|
||||
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
|
||||
|
@ -321,9 +345,11 @@ export const requestsPricingPlanLineItemSchema =
|
|||
*/
|
||||
unitLabel: z.string().default('API calls').optional()
|
||||
})
|
||||
export type RequestsPricingPlanLineItem = PricingPlanMeteredLineItem & {
|
||||
slug: 'requests'
|
||||
}
|
||||
export type RequestsPricingPlanLineItem = Simplify<
|
||||
PricingPlanMeteredLineItem & {
|
||||
slug: 'requests'
|
||||
}
|
||||
>
|
||||
|
||||
/**
|
||||
* PricingPlanLineItems represent a single line-item in a Stripe Subscription.
|
||||
|
@ -378,19 +404,35 @@ export const pricingPlanLineItemSchema = z
|
|||
.openapi('PricingPlanLineItem')
|
||||
// export type PricingPlanLineItem = z.infer<typeof pricingPlanLineItemSchema>
|
||||
|
||||
// This is a more complex discriminated union based on both `slug` and `usageType`
|
||||
export type PricingPlanLineItem = Simplify<
|
||||
// This is a more complex discriminated union based on:
|
||||
// `slug`, `usageType`, and `billingScheme`
|
||||
export type PricingPlanLineItem =
|
||||
| BasePricingPlanLineItem
|
||||
| RequestsPricingPlanLineItem
|
||||
| (
|
||||
| (Omit<PricingPlanLicensedLineItem, 'slug'> & {
|
||||
slug: CustomPricingPlanLineItemSlug
|
||||
})
|
||||
| (Omit<PricingPlanMeteredLineItem, 'slug'> & {
|
||||
slug: CustomPricingPlanLineItemSlug
|
||||
})
|
||||
)
|
||||
>
|
||||
| ({
|
||||
slug: CustomPricingPlanLineItemSlug
|
||||
usageType: 'licensed'
|
||||
} & Omit<PricingPlanLicensedLineItem, 'slug' | 'usageType'>)
|
||||
| ({
|
||||
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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import type { PricingPlan } from '@agentic/platform-types'
|
||||
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 Project = components['schemas']['Project']
|
||||
|
|
Ładowanie…
Reference in New Issue