@read-frog/api-contract 0.22.0 → 0.23.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@read-frog/api-contract",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,10 @@
1
1
  import type { ErrorMap } from "@orpc/contract";
2
2
  import { z } from "zod";
3
- import { HostedAiCreditPolicyIdSchema, HostedAiModelTierSchema } from "./schemas/hosted-ai";
3
+ import {
4
+ HostedAiCreditPolicyIdSchema,
5
+ HostedAiModelTierSchema,
6
+ HostedAiUpgradePlanSchema,
7
+ } from "./schemas/hosted-ai";
4
8
 
5
9
  interface PublicAppErrorDefinition {
6
10
  data?: z.ZodTypeAny;
@@ -74,6 +78,8 @@ export type CardTemplateNotebaseColumnInUseData = z.infer<
74
78
 
75
79
  export const HostedAiTierRestrictedDataSchema = z.strictObject({
76
80
  modelTier: HostedAiModelTierSchema,
81
+ /** The cheapest plan that unlocks it; a client offers "Pro or Ultra" for `pro`. */
82
+ upgradeTo: HostedAiUpgradePlanSchema,
77
83
  });
78
84
 
79
85
  export const HostedAiQuotaExhaustedDataSchema = z.strictObject({
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { billingPlanSchema } from "./billing";
2
3
 
3
4
  export const HostedAiOutputFieldTypeSchema = z.enum(["string", "number"]);
4
5
 
@@ -159,13 +160,25 @@ export const HOSTED_AI_CLIENT_STREAM_PART_TYPES = [
159
160
  */
160
161
  export const HostedAiStatusInputSchema = z.object({});
161
162
 
163
+ /**
164
+ * `pro_required` means the Pro plan or any plan above it; `ultra_required`
165
+ * means Ultra. Appended last, so a client that predates a value falls back on
166
+ * its own default instead of misreading it.
167
+ */
162
168
  export const HostedAiUnavailableReasonSchema = z.enum([
163
169
  "authentication_required",
164
170
  "ultra_required",
165
171
  "quota_exhausted",
166
172
  "service_unavailable",
173
+ "pro_required",
167
174
  ]);
168
175
 
176
+ /**
177
+ * The cheapest plan an account would need to buy for something it cannot use
178
+ * now. Any plan above it works too, so `pro` reads as "Pro or Ultra".
179
+ */
180
+ export const HostedAiUpgradePlanSchema = billingPlanSchema.exclude(["free"]);
181
+
169
182
  export const HostedAiCreditPolicyIdSchema = z.enum([
170
183
  "custom-action-guest-daily-v1",
171
184
  "custom-action-user-daily-v1",
@@ -246,10 +259,18 @@ export const HostedAiTierStatusSchema = z.strictObject({
246
259
  available: z.boolean(),
247
260
  unavailableReason: HostedAiUnavailableReasonSchema.nullable(),
248
261
  /**
249
- * Viewer-independent product fact: no non-Ultra account can ever use this
250
- * feature/tier, so signing in alone will not unlock it. Unlike the fields
251
- * above, this does not vary with the caller's identity or plan — clients use
252
- * it to label Ultra-only options rather than to gate the current user.
262
+ * The cheapest plan this account would need to use the tier, or null when it
263
+ * needs none: its plan or a one-time pool already covers it, or the tier is
264
+ * open to every signed-in account. For a guest it is the plan needed after
265
+ * signing in. Clients badge an option with it and offer that plan.
266
+ */
267
+ upgradeTo: HostedAiUpgradePlanSchema.nullable(),
268
+ /**
269
+ * @deprecated Read `upgradeTo`. Viewer-independent product fact: no
270
+ * non-Ultra account can ever use this feature/tier. Extensions released
271
+ * before `upgradeTo` badge options with it, including for Ultra accounts.
272
+ *
273
+ * TODO(2026-11-21): remove once those extensions have drained (#710).
253
274
  */
254
275
  requiresUltra: z.boolean(),
255
276
  modelRevision: z.string().trim().min(1),
@@ -302,6 +323,7 @@ export type HostedAiNoteSuggestionObject = z.infer<typeof HostedAiNoteSuggestion
302
323
  export type HostedAiStreamPart = z.infer<typeof HostedAiStreamPartSchema>;
303
324
  export type HostedAiStatusInput = z.infer<typeof HostedAiStatusInputSchema>;
304
325
  export type HostedAiUnavailableReason = z.infer<typeof HostedAiUnavailableReasonSchema>;
326
+ export type HostedAiUpgradePlan = z.infer<typeof HostedAiUpgradePlanSchema>;
305
327
  export type HostedAiCreditPolicyId = z.infer<typeof HostedAiCreditPolicyIdSchema>;
306
328
  export type HostedAiCreditPeriodKind = z.infer<typeof HostedAiCreditPeriodKindSchema>;
307
329
  export type HostedAiQuotaScope = z.infer<typeof HostedAiQuotaScopeSchema>;