terse-types 0.0.30 → 0.0.31

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/Billing.js CHANGED
@@ -59,8 +59,14 @@ export const usageResponseSchema = z.object({
59
59
  });
60
60
  export const billingContextResponseSchema = z.object({
61
61
  billingEnabled: z.boolean(),
62
- balance: balanceSummarySchema,
63
- usage: usageResponseSchema
62
+ balance: balanceSummarySchema
63
+ });
64
+ export const billingStatusResponseSchema = z.object({
65
+ billingEnabled: z.boolean(),
66
+ hasStripeCustomer: z.boolean(),
67
+ hasActivePaidSubscription: z.boolean(),
68
+ canManageBilling: z.boolean(),
69
+ planKey: planKeySchema.nullable()
64
70
  });
65
71
  export const completedEventUsageSchema = z.object({
66
72
  inputTokens: z.number().nonnegative(),
@@ -138,7 +144,9 @@ export const billingContextQuerySchema = z.object({
138
144
  .transform(timezone => timezone || DEFAULT_BILLING_CONTEXT_TIMEZONE)
139
145
  .refine(isValidTimezone, { message: "Invalid timezone" })
140
146
  });
141
- export const getOrCreateCustomerRequestBodySchema = z.object({}).strict();
147
+ /** Query params for GET /billing/usage-buckets (same range semantics as the chart on the billing page). */
148
+ export const billingUsageBucketsQuerySchema = billingContextQuerySchema;
149
+ export const billingUsageBucketsResponseSchema = usageResponseSchema;
142
150
  export const billingStripeRedirectResponseSchema = z.object({
143
151
  url: z.string()
144
152
  });
@@ -160,9 +168,6 @@ export function parseRunGateDenyReason(raw) {
160
168
  const parsed = runGateDenyReasonSchema.safeParse(raw);
161
169
  return parsed.success ? parsed.data : "credits_exhausted";
162
170
  }
163
- export const getOrCreateCustomerResponseSchema = z.object({
164
- customerId: z.string()
165
- });
166
171
  export const planSchema = z.object({
167
172
  key: planKeySchema,
168
173
  name: z.string(),
@@ -189,7 +194,8 @@ export const BILLING_SERVICE_JWT_AUDIENCE = "terse-billing";
189
194
  export const BILLING_SERVICE_CALLBACK_JWT_ISSUER = "terse-billing";
190
195
  export const BILLING_SERVICE_CALLBACK_JWT_AUDIENCE = "terse-api";
191
196
  export const terseBillingJwtClaimsSchema = z.object({
192
- organizationId: z.string().min(1)
197
+ organizationId: z.string().min(1),
198
+ userId: z.string().min(1).optional()
193
199
  });
194
200
  export const BillingRoutes = billingRoutes;
195
201
  export class CreditGateDeniedError extends Error {
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "CATALOG": "/billing/catalog",
3
+ "STATUS": "/billing/status",
3
4
  "CONTEXT": "/billing/context",
5
+ "USAGE_BUCKETS": "/billing/usage-buckets",
4
6
  "CHECKOUT_SESSION": "/billing/checkout-session",
5
7
  "CHANGE": "/billing/change",
6
8
  "PORTAL_SESSION": "/billing/portal-session",
@@ -0,0 +1 @@
1
+ export type Decision = "approve" | "reject";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { BillingContextQuery } from "./Billing.js";
1
+ import type { BillingContextQuery, BillingUsageBucketsQuery } from "./Billing.js";
2
2
  import { GetRunHistoryParams } from "./RunHistoryTypes.js";
3
3
  import type { StatsInterval } from "./types.js";
4
4
  export declare const currentUserKey: () => readonly [string];
@@ -52,5 +52,7 @@ export declare const projectDeploysKey: (projectId: string) => readonly [string,
52
52
  export declare const projectSourceFilesKey: (projectId: string) => readonly [string, string];
53
53
  export declare const projectSourceFileContentKey: (projectId: string, fileId: string) => readonly [string, string, string];
54
54
  export declare const billingContextKey: (params?: Partial<BillingContextQuery>) => readonly [string, string, string, string];
55
+ export declare const billingUsageBucketsKey: (params?: Partial<BillingUsageBucketsQuery>) => readonly [string, string, string, string];
55
56
  export declare const billingCatalogKey: () => readonly [string];
57
+ export declare const billingStatusKey: () => readonly [string];
56
58
  export declare const organizationProjectsKey: () => readonly [string];
@@ -151,5 +151,12 @@ export const billingContextKey = (params) => [
151
151
  params?.start?.toISOString() ?? "",
152
152
  params?.end?.toISOString() ?? ""
153
153
  ];
154
+ export const billingUsageBucketsKey = (params) => [
155
+ "billingUsageBuckets",
156
+ params?.timezone ?? "",
157
+ params?.start?.toISOString() ?? "",
158
+ params?.end?.toISOString() ?? ""
159
+ ];
154
160
  export const billingCatalogKey = () => ["billingCatalog"];
161
+ export const billingStatusKey = () => ["billingStatus"];
155
162
  export const organizationProjectsKey = () => ["organization-projects"];
@@ -26,11 +26,11 @@ export type RunHistoryDecisionAction = z.infer<typeof runHistoryDecisionActionSc
26
26
  export declare const RUN_HISTORY_ACTION_TYPES: readonly ["create", "update", "delete", "read", "approve", "error"];
27
27
  export declare const runHistoryActionTypeSchema: z.ZodEnum<{
28
28
  error: "error";
29
+ approve: "approve";
29
30
  create: "create";
30
31
  update: "update";
31
32
  delete: "delete";
32
33
  read: "read";
33
- approve: "approve";
34
34
  }>;
35
35
  export type RunHistoryActionType = z.infer<typeof runHistoryActionTypeSchema>;
36
36
  export declare const outputItemSchema: z.ZodObject<{
@@ -47,11 +47,11 @@ export declare const runHistoryActionBaseSchema: z.ZodObject<{
47
47
  step_id: z.ZodOptional<z.ZodString>;
48
48
  type: z.ZodEnum<{
49
49
  error: "error";
50
+ approve: "approve";
50
51
  create: "create";
51
52
  update: "update";
52
53
  delete: "delete";
53
54
  read: "read";
54
- approve: "approve";
55
55
  }>;
56
56
  isReadOnly: z.ZodOptional<z.ZodBoolean>;
57
57
  output_items: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -14,44 +14,12 @@ export declare enum LinearStateName {
14
14
  Done = "Done",
15
15
  Canceled = "Canceled"
16
16
  }
17
- export interface Ticket {
18
- id: string;
19
- identifier: string;
20
- title: string;
21
- description?: string;
22
- state: {
23
- id: string;
24
- name: string;
25
- };
26
- assignee?: {
27
- id: string;
28
- name: string;
29
- } | null;
30
- priority?: number;
31
- labels?: Array<{
32
- id: string;
33
- name: string;
34
- color: string;
35
- }>;
36
- estimate?: number;
37
- dueDate?: string;
38
- project?: {
39
- id: string;
40
- name: string;
41
- } | null;
42
- team?: {
43
- id: string;
44
- name: string;
45
- key: string;
46
- };
47
- createdAt: string;
48
- updatedAt: string;
49
- }
50
- export interface User {
17
+ interface User {
51
18
  id: string;
52
19
  name: string;
53
20
  email: string;
54
21
  }
22
+ export { User as TicketSystemUser };
55
23
  export interface UserContext {
56
24
  userInfo: User;
57
25
  teams: Team[];
@@ -59,11 +27,11 @@ export interface UserContext {
59
27
  ticketStates: TicketState[];
60
28
  milestones: Milestone[];
61
29
  }
62
- export interface TicketState {
30
+ interface TicketState {
63
31
  id: string;
64
32
  name: string;
65
33
  }
66
- export interface Milestone {
34
+ interface Milestone {
67
35
  id: string;
68
36
  name: string;
69
37
  }
@@ -75,78 +43,19 @@ export interface Organization {
75
43
  userCount: number;
76
44
  projects: Project[];
77
45
  }
78
- export type Project = {
46
+ type Project = {
79
47
  id: string;
80
48
  name: string;
81
49
  description?: string;
82
50
  updates: Update[];
83
51
  };
84
- export type Update = {
52
+ type Update = {
85
53
  id: string;
86
54
  title: string;
87
55
  description?: string;
88
56
  };
89
- export interface Comment {
90
- id: string;
91
- authorId: string;
92
- body: string;
93
- createdAt: string;
94
- updatedAt?: string;
95
- [key: string]: any;
96
- }
97
57
  export interface Team {
98
58
  id: string;
99
59
  name: string;
100
60
  key: string;
101
61
  }
102
- export interface CommitAssociation {
103
- sha: string;
104
- message: string;
105
- url: string;
106
- repository: string;
107
- branch?: string;
108
- }
109
- export interface CreateTicketInput {
110
- title: string;
111
- teamId: string;
112
- description?: string;
113
- state?: {
114
- id: string;
115
- name: string;
116
- };
117
- assignee?: string;
118
- priority?: number;
119
- project?: {
120
- id: string;
121
- name: string;
122
- };
123
- milestone?: {
124
- id: string;
125
- name: string;
126
- };
127
- associatedCommits?: CommitAssociation[];
128
- issueType?: string;
129
- }
130
- export interface UpdateTicketInput {
131
- title: string;
132
- teamId: string;
133
- description?: string;
134
- state?: {
135
- id: string;
136
- name: string;
137
- };
138
- assignee?: string;
139
- priority?: number;
140
- project?: {
141
- id: string;
142
- name: string;
143
- };
144
- milestone?: {
145
- id: string;
146
- name: string;
147
- };
148
- associatedCommits?: CommitAssociation[];
149
- }
150
- export interface TicketWebhookHandler {
151
- (ticket: Ticket): void | Promise<void>;
152
- }