@middlewr/contracts 0.0.12 → 0.0.13
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.
- package/dist/cjs/billing.schema.d.ts +25 -0
- package/dist/cjs/billing.schema.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +99 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +275 -231
- package/dist/cjs/workspaces.schema.d.ts +10 -0
- package/dist/cjs/workspaces.schema.d.ts.map +1 -1
- package/dist/esm/billing.schema.d.ts +25 -0
- package/dist/esm/billing.schema.d.ts.map +1 -0
- package/dist/esm/index.d.ts +99 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +270 -231
- package/dist/esm/workspaces.schema.d.ts +10 -0
- package/dist/esm/workspaces.schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/billing.schema.ts +25 -0
- package/src/index.ts +21 -0
- package/src/workspaces.schema.ts +5 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const BillingStatusSchema = z.object({
|
|
4
|
+
billing_plan: z.string(),
|
|
5
|
+
billing_status: z.string(),
|
|
6
|
+
billing_email: z.string().nullable(),
|
|
7
|
+
billing_current_period_end: z.coerce.date().nullable(),
|
|
8
|
+
billing_cancel_at_period_end: z.boolean(),
|
|
9
|
+
billing_customer_id: z.string().nullable(),
|
|
10
|
+
billing_subscription_id: z.string().nullable(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const CreateCheckoutInputSchema = z.object({
|
|
14
|
+
plan: z.enum(['pro', 'business']),
|
|
15
|
+
success_url: z.string().url().optional(),
|
|
16
|
+
billing_email: z.string().email().optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const CheckoutSessionSchema = z.object({
|
|
20
|
+
url: z.string().url(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const CustomerPortalSchema = z.object({
|
|
24
|
+
url: z.string().url(),
|
|
25
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { oc } from '@orpc/contract';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { ApiKeySchema, CreateApiKeyInputSchema, CreateApiKeyResponseSchema } from './api-keys.schema';
|
|
6
|
+
import { BillingStatusSchema, CheckoutSessionSchema, CreateCheckoutInputSchema, CustomerPortalSchema } from './billing.schema';
|
|
6
7
|
import {
|
|
7
8
|
ApiKeyIdParamSchema,
|
|
8
9
|
DomainIdParamSchema,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
|
|
33
34
|
export * from './analytics.schema';
|
|
34
35
|
export * from './api-keys.schema';
|
|
36
|
+
export * from './billing.schema';
|
|
35
37
|
export * from './common.schema';
|
|
36
38
|
export * from './domains.schema';
|
|
37
39
|
export * from './links.schema';
|
|
@@ -207,6 +209,24 @@ export const domainsContract = {
|
|
|
207
209
|
.output(DomainSchema),
|
|
208
210
|
};
|
|
209
211
|
|
|
212
|
+
// Billing contract
|
|
213
|
+
export const billingContract = {
|
|
214
|
+
status: oc
|
|
215
|
+
.route({ method: 'GET', path: '/api/workspaces/{workspace_id}/billing' })
|
|
216
|
+
.input(WorkspaceIdParamSchema)
|
|
217
|
+
.output(BillingStatusSchema),
|
|
218
|
+
|
|
219
|
+
checkout: oc
|
|
220
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/billing/checkout' })
|
|
221
|
+
.input(WorkspaceIdParamSchema.merge(CreateCheckoutInputSchema))
|
|
222
|
+
.output(CheckoutSessionSchema),
|
|
223
|
+
|
|
224
|
+
portal: oc
|
|
225
|
+
.route({ method: 'POST', path: '/api/workspaces/{workspace_id}/billing/portal' })
|
|
226
|
+
.input(WorkspaceIdParamSchema)
|
|
227
|
+
.output(CustomerPortalSchema),
|
|
228
|
+
};
|
|
229
|
+
|
|
210
230
|
// Full contract
|
|
211
231
|
export const contract = {
|
|
212
232
|
users: usersContract,
|
|
@@ -216,6 +236,7 @@ export const contract = {
|
|
|
216
236
|
links: linksContract,
|
|
217
237
|
tags: tagsContract,
|
|
218
238
|
domains: domainsContract,
|
|
239
|
+
billing: billingContract,
|
|
219
240
|
};
|
|
220
241
|
|
|
221
242
|
export type Contract = typeof contract;
|
package/src/workspaces.schema.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { z } from 'zod';
|
|
|
3
3
|
export const WorkspaceSchema = z.object({
|
|
4
4
|
id: z.string().uuid(),
|
|
5
5
|
name: z.string(),
|
|
6
|
+
billing_plan: z.string(),
|
|
7
|
+
billing_status: z.string(),
|
|
8
|
+
billing_email: z.string().nullable(),
|
|
9
|
+
billing_current_period_end: z.coerce.date().nullable(),
|
|
10
|
+
billing_cancel_at_period_end: z.boolean(),
|
|
6
11
|
created_at: z.coerce.date(),
|
|
7
12
|
updated_at: z.coerce.date().nullable(),
|
|
8
13
|
});
|