@trigger.dev/billing
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1513,2 +1513,19 @@ import { z, ZodType } from 'zod'; | ||
declare const CustomerPortalRequestBodySchema: z.ZodObject<{ | ||
returnUrl: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
returnUrl: string; | ||
}, { | ||
returnUrl: string; | ||
}>; | ||
type CustomerPortalRequestBody = z.infer<typeof CustomerPortalRequestBodySchema>; | ||
declare const CustomerPortalSchema: z.ZodObject<{ | ||
customerPortalUrl: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
customerPortalUrl?: string | undefined; | ||
}, { | ||
customerPortalUrl?: string | undefined; | ||
}>; | ||
type CustomerPortal = z.infer<typeof CustomerPortalSchema>; | ||
declare const ErrorSchema: z.ZodObject<{ | ||
@@ -1549,2 +1566,3 @@ error: z.ZodString; | ||
type SetPlanResponse = Result<typeof SubscribeResultSchema>; | ||
type CustomerPortalResponse = Result<typeof CustomerPortalSchema>; | ||
declare class BillingClient { | ||
@@ -1556,5 +1574,6 @@ private readonly config; | ||
setPlan(orgId: string, body: SetPlanBody): Promise<SetPlanResponse>; | ||
fetch<TSchema extends ZodType = z.ZodTypeAny>(path: string, schema: TSchema): Promise<Result<TSchema>>; | ||
createPortalSession(orgId: string, body: CustomerPortalRequestBody): Promise<CustomerPortalResponse>; | ||
fetch<TSchema extends ZodType = z.ZodTypeAny>(path: string, schema: TSchema, requestInit?: RequestInit): Promise<Result<TSchema>>; | ||
} | ||
export { type ActiveSubscription, ActiveSubscriptionSchema, BillingClient, BracketSchema, type CanceledSubscriptionResult, type CreateSubscriptionFlowStart, type CurrentPlan, type CurrentPlanResponse, CurrentPlanSchema, type Error, ErrorSchema, type Plan, type PlanDefinition, PlanDefinitionSchema, PlanSchema, type Plans, type PlansResponse, PlansSchema, type PricedMetric, PricedMetricSchema, RunPricingSchema, type SetPlanBody, SetPlanBodySchema, type SetPlanResponse, type SubscribeResult, SubscribeResultSchema, type UpdatedSubscriptionResult, estimate }; | ||
export { type ActiveSubscription, ActiveSubscriptionSchema, BillingClient, BracketSchema, type CanceledSubscriptionResult, type CreateSubscriptionFlowStart, type CurrentPlan, type CurrentPlanResponse, CurrentPlanSchema, type CustomerPortal, type CustomerPortalRequestBody, CustomerPortalRequestBodySchema, type CustomerPortalResponse, CustomerPortalSchema, type Error, ErrorSchema, type Plan, type PlanDefinition, PlanDefinitionSchema, PlanSchema, type Plans, type PlansResponse, PlansSchema, type PricedMetric, PricedMetricSchema, RunPricingSchema, type SetPlanBody, SetPlanBodySchema, type SetPlanResponse, type SubscribeResult, SubscribeResultSchema, type UpdatedSubscriptionResult, estimate }; |
@@ -156,8 +156,17 @@ // src/schemas/planDefinitions.ts | ||
// src/schemas/error.ts | ||
// src/schemas/portal.ts | ||
import { z as z6 } from "zod"; | ||
var ErrorSchema = z6.object({ | ||
error: z6.string() | ||
var CustomerPortalRequestBodySchema = z6.object({ | ||
returnUrl: z6.string() | ||
}); | ||
var CustomerPortalSchema = z6.object({ | ||
customerPortalUrl: z6.string().optional() | ||
}); | ||
// src/schemas/error.ts | ||
import { z as z7 } from "zod"; | ||
var ErrorSchema = z7.object({ | ||
error: z7.string() | ||
}); | ||
// src/cost.ts | ||
@@ -288,10 +297,32 @@ function planCost({ | ||
`/api/v1/orgs/${orgId}/subscription`, | ||
SubscribeResultSchema | ||
SubscribeResultSchema, | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify(body) | ||
} | ||
); | ||
} | ||
async fetch(path, schema) { | ||
async createPortalSession(orgId, body) { | ||
return await this.fetch( | ||
`/api/v1/orgs/${orgId}/subscription/portal`, | ||
CustomerPortalSchema, | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify(body) | ||
} | ||
); | ||
} | ||
async fetch(path, schema, requestInit) { | ||
const response = await fetch(`${this.config.url}${path}`, { | ||
headers: { | ||
...requestInit == null ? void 0 : requestInit.headers, | ||
Authorization: `Bearer ${this.config.apiKey}` | ||
} | ||
}, | ||
...requestInit | ||
}); | ||
@@ -319,2 +350,4 @@ if (!response.ok) { | ||
CurrentPlanSchema, | ||
CustomerPortalRequestBodySchema, | ||
CustomerPortalSchema, | ||
ErrorSchema, | ||
@@ -321,0 +354,0 @@ PlanDefinitionSchema, |
{ | ||
"name": "@trigger.dev/billing", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Calculates the billing for a given organization", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160061
2305