@read-frog/api-contract 0.8.0 → 0.9.0

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.
@@ -70,6 +70,18 @@ export const PUBLIC_APP_ERROR_DEFS = {
70
70
  message: "Notebase column is used by a card template",
71
71
  status: 409,
72
72
  },
73
+ NOTE_LIMIT_EXCEEDED: {
74
+ message: "Upgrade is required to create more Notebase notes",
75
+ status: 403,
76
+ },
77
+ BILLING_NOT_CONFIGURED: {
78
+ message: "Billing is not configured",
79
+ status: 503,
80
+ },
81
+ BILLING_CUSTOMER_NOT_FOUND: {
82
+ message: "Billing customer not found",
83
+ status: 404,
84
+ },
73
85
  CARD_NOT_REVIEWABLE: {
74
86
  message: "Card cannot be reviewed in its current state",
75
87
  status: 409,
@@ -0,0 +1,41 @@
1
+ import { z } from "zod"
2
+
3
+ export const billingIntervalSchema = z.enum(["month", "year"])
4
+ export type BillingInterval = z.infer<typeof billingIntervalSchema>
5
+
6
+ export const billingSubscriptionStatusSchema = z.enum([
7
+ "incomplete",
8
+ "incomplete_expired",
9
+ "trialing",
10
+ "active",
11
+ "past_due",
12
+ "canceled",
13
+ "unpaid",
14
+ "paused",
15
+ ])
16
+ export type BillingSubscriptionStatus = z.infer<typeof billingSubscriptionStatusSchema>
17
+
18
+ export const billingPlanSchema = z.enum(["free", "pro"])
19
+ export type BillingPlan = z.infer<typeof billingPlanSchema>
20
+
21
+ export const billingStatusSchema = z.object({
22
+ plan: billingPlanSchema,
23
+ status: billingSubscriptionStatusSchema.nullable(),
24
+ interval: billingIntervalSchema.nullable(),
25
+ currentPeriodEnd: z.coerce.date().nullable(),
26
+ cancelAtPeriodEnd: z.boolean(),
27
+ unlimitedNotebaseNotes: z.boolean(),
28
+ notebaseNoteLimit: z.number().int().positive(),
29
+ notebaseNoteCount: z.number().int().min(0),
30
+ }).strict()
31
+ export type BillingStatus = z.infer<typeof billingStatusSchema>
32
+
33
+ export const billingCreateCheckoutSessionInputSchema = z.object({
34
+ interval: billingIntervalSchema,
35
+ }).strict()
36
+ export type BillingCreateCheckoutSessionInput = z.infer<typeof billingCreateCheckoutSessionInputSchema>
37
+
38
+ export const billingSessionUrlOutputSchema = z.object({
39
+ url: z.url(),
40
+ }).strict()
41
+ export type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>
@@ -1,5 +1,8 @@
1
+ import type { RefinementCtx } from "zod"
1
2
  import { z } from "zod"
2
3
 
4
+ const HOSTED_AI_SYSTEM_FALLBACK_REMOVAL_DATE = "2026-07-11"
5
+
3
6
  export const HostedAiOutputFieldTypeSchema = z.enum(["string", "number"])
4
7
 
5
8
  export const HostedAiOutputFieldSchema = z.strictObject({
@@ -7,18 +10,44 @@ export const HostedAiOutputFieldSchema = z.strictObject({
7
10
  type: HostedAiOutputFieldTypeSchema,
8
11
  })
9
12
 
13
+ const HostedAiInstructionsSchema = z.string().trim().min(1).max(16000)
14
+
15
+ interface HostedAiInstructionsCompatibilityInput {
16
+ instructions?: string
17
+ system?: string
18
+ }
19
+
20
+ function validateHostedAiInstructionsCompatibility(
21
+ input: HostedAiInstructionsCompatibilityInput,
22
+ ctx: RefinementCtx<HostedAiInstructionsCompatibilityInput>,
23
+ ): void {
24
+ if (input.instructions !== undefined || input.system !== undefined) {
25
+ return
26
+ }
27
+
28
+ ctx.addIssue({
29
+ code: "custom",
30
+ message: `instructions is required. The deprecated system field is accepted as a temporary fallback until ${HOSTED_AI_SYSTEM_FALLBACK_REMOVAL_DATE}.`,
31
+ path: ["instructions"],
32
+ })
33
+ }
34
+
10
35
  export const HostedAiStreamTextInputSchema = z.strictObject({
11
- system: z.string().trim().min(1).max(16000),
36
+ instructions: HostedAiInstructionsSchema.optional(),
37
+ system: HostedAiInstructionsSchema.optional(),
12
38
  prompt: z.string().trim().min(1).max(32000),
13
39
  temperature: z.number().min(0).max(2).optional(),
14
- })
40
+ }).superRefine(validateHostedAiInstructionsCompatibility)
15
41
 
16
42
  export const HostedAiStreamStructuredObjectInputSchema = z.strictObject({
17
- system: z.string().trim().min(1).max(16000),
43
+ instructions: HostedAiInstructionsSchema.optional(),
44
+ system: HostedAiInstructionsSchema.optional(),
18
45
  prompt: z.string().trim().min(1).max(32000),
19
46
  outputSchema: z.array(HostedAiOutputFieldSchema).min(1).max(32),
20
47
  temperature: z.number().min(0).max(2).optional(),
21
48
  }).superRefine((input, ctx) => {
49
+ validateHostedAiInstructionsCompatibility(input, ctx)
50
+
22
51
  const fieldNames = new Set<string>()
23
52
 
24
53
  input.outputSchema.forEach((field, index) => {