@read-frog/api-contract 0.14.0 → 0.16.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.
Files changed (41) hide show
  1. package/dist/index.d.ts +1186 -481
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +326 -97
  4. package/dist/index.js.map +1 -1
  5. package/package.json +15 -14
  6. package/src/contracts/beta-access.ts +3 -6
  7. package/src/contracts/billing.ts +5 -5
  8. package/src/contracts/card-template.ts +45 -39
  9. package/src/contracts/card.ts +22 -19
  10. package/src/contracts/ebook.ts +13 -11
  11. package/src/contracts/hosted-ai.ts +5 -5
  12. package/src/contracts/mcp-connection.ts +26 -0
  13. package/src/contracts/notebase-column.ts +40 -32
  14. package/src/contracts/notebase-row.ts +85 -45
  15. package/src/contracts/notebase.ts +60 -40
  16. package/src/contracts/shared.ts +21 -2
  17. package/src/contracts/srs.ts +96 -63
  18. package/src/contracts/stats.ts +9 -11
  19. package/src/contracts/user.ts +3 -3
  20. package/src/contracts/video-transcript.ts +22 -12
  21. package/src/index.ts +40 -33
  22. package/src/public-errors.ts +74 -51
  23. package/src/schemas/beta-access.ts +12 -10
  24. package/src/schemas/billing.ts +103 -59
  25. package/src/schemas/card.ts +66 -63
  26. package/src/schemas/ebook.ts +165 -129
  27. package/src/schemas/hosted-ai.ts +84 -74
  28. package/src/schemas/mcp-connection.ts +28 -0
  29. package/src/schemas/notebase-column.ts +50 -36
  30. package/src/schemas/notebase-row.ts +88 -57
  31. package/src/schemas/notebase-stats.ts +28 -20
  32. package/src/schemas/notebase-view.ts +59 -49
  33. package/src/schemas/notebase.ts +136 -96
  34. package/src/schemas/pagination.ts +9 -0
  35. package/src/schemas/resource-mutation.ts +6 -0
  36. package/src/schemas/srs-stats.ts +30 -22
  37. package/src/schemas/srs.ts +152 -106
  38. package/src/schemas/stats.ts +27 -21
  39. package/src/schemas/timezone.ts +19 -16
  40. package/src/schemas/user.ts +27 -19
  41. package/src/schemas/video-transcript.ts +33 -32
@@ -1,11 +1,11 @@
1
- import type { ErrorMap } from "@orpc/contract"
2
- import { z } from "zod"
3
- import { HostedAiCreditPolicyIdSchema, HostedAiModelTierSchema } from "./schemas/hosted-ai"
1
+ import type { ErrorMap } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ import { HostedAiCreditPolicyIdSchema, HostedAiModelTierSchema } from "./schemas/hosted-ai";
4
4
 
5
5
  interface PublicAppErrorDefinition {
6
- data?: z.ZodTypeAny
7
- message: string
8
- status: number
6
+ data?: z.ZodTypeAny;
7
+ message: string;
8
+ status: number;
9
9
  }
10
10
 
11
11
  export const CellValidationFailureReasonSchema = z.enum([
@@ -13,35 +13,41 @@ export const CellValidationFailureReasonSchema = z.enum([
13
13
  "type_mismatch",
14
14
  "invalid_select_option",
15
15
  "invalid_date_format",
16
- ])
17
- export type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>
16
+ ]);
17
+ export type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>;
18
18
 
19
- export const CellValidationFailureDetailsSchema = z.object({
20
- expectedFormat: z.string().optional(),
21
- expectedType: z.string().optional(),
22
- receivedType: z.string().optional(),
23
- receivedValue: z.unknown().optional(),
24
- validOptions: z.array(z.string()).optional(),
25
- }).strict()
26
- export type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>
19
+ export const CellValidationFailureDetailsSchema = z
20
+ .object({
21
+ expectedFormat: z.string().optional(),
22
+ expectedType: z.string().optional(),
23
+ receivedType: z.string().optional(),
24
+ receivedValue: z.unknown().optional(),
25
+ validOptions: z.array(z.string()).optional(),
26
+ })
27
+ .strict();
28
+ export type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>;
27
29
 
28
- export const CellValidationFailedDataSchema = z.object({
29
- notebaseColumnId: z.string(),
30
- details: CellValidationFailureDetailsSchema,
31
- reason: CellValidationFailureReasonSchema,
32
- /** Index of the failing row within a batch input (createMany / initialRows). */
33
- rowIndex: z.number().int().min(0).optional(),
34
- }).strict()
35
- export type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>
30
+ export const CellValidationFailedDataSchema = z
31
+ .object({
32
+ notebaseColumnId: z.string(),
33
+ details: CellValidationFailureDetailsSchema,
34
+ reason: CellValidationFailureReasonSchema,
35
+ /** Index of the failing row within a batch input (createMany / initialRows). */
36
+ rowIndex: z.number().int().min(0).optional(),
37
+ })
38
+ .strict();
39
+ export type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>;
36
40
 
37
- export const CardTemplateInvalidColumnsDataSchema = z.object({
38
- notebaseColumnIds: z.array(z.string()),
39
- }).strict()
40
- export type CardTemplateInvalidColumnsData = z.infer<typeof CardTemplateInvalidColumnsDataSchema>
41
+ export const CardTemplateInvalidColumnsDataSchema = z
42
+ .object({
43
+ notebaseColumnIds: z.array(z.string()),
44
+ })
45
+ .strict();
46
+ export type CardTemplateInvalidColumnsData = z.infer<typeof CardTemplateInvalidColumnsDataSchema>;
41
47
 
42
48
  export const HostedAiTierRestrictedDataSchema = z.strictObject({
43
49
  modelTier: HostedAiModelTierSchema,
44
- })
50
+ });
45
51
 
46
52
  export const HostedAiQuotaExhaustedDataSchema = z.strictObject({
47
53
  modelTier: HostedAiModelTierSchema,
@@ -52,9 +58,18 @@ export const HostedAiQuotaExhaustedDataSchema = z.strictObject({
52
58
  policyId: HostedAiCreditPolicyIdSchema,
53
59
  usedPercent: z.number().min(0).max(100),
54
60
  resetAt: z.iso.datetime().nullable(),
55
- })
61
+ });
56
62
 
57
63
  export const PUBLIC_APP_ERROR_DEFS = {
64
+ RESOURCE_UPDATE_CONFLICT: {
65
+ message: "The resource changed. Read it again before updating.",
66
+ status: 409,
67
+ },
68
+ RESOURCE_ALREADY_EXISTS: { message: "A resource with this ID already exists.", status: 409 },
69
+ FIELD_TYPE_CHANGE_UNSUPPORTED: {
70
+ message: "This operation cannot change the field type.",
71
+ status: 400,
72
+ },
58
73
  HOSTED_AI_TIER_RESTRICTED: {
59
74
  data: HostedAiTierRestrictedDataSchema,
60
75
  message: "This Built-in AI tier is not available for this account",
@@ -226,40 +241,48 @@ export const PUBLIC_APP_ERROR_DEFS = {
226
241
  message: "Ebook upload has not been completed",
227
242
  status: 409,
228
243
  },
229
- } as const satisfies Record<string, PublicAppErrorDefinition>
244
+ } as const satisfies Record<string, PublicAppErrorDefinition>;
230
245
 
231
- export type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS
246
+ export type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS;
232
247
 
233
- export type PublicAppErrorData<TCode extends PublicAppErrorCode>
234
- = (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }
248
+ export type PublicAppErrorData<TCode extends PublicAppErrorCode> =
249
+ (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }
235
250
  ? z.output<TSchema>
236
- : undefined
251
+ : undefined;
237
252
 
238
253
  export function isPublicAppErrorCode(code: string | undefined): code is PublicAppErrorCode {
239
- return code !== undefined && code in PUBLIC_APP_ERROR_DEFS
254
+ return code !== undefined && code in PUBLIC_APP_ERROR_DEFS;
240
255
  }
241
256
 
242
257
  export function getPublicErrorDefinition<TCode extends PublicAppErrorCode>(code: TCode) {
243
- return PUBLIC_APP_ERROR_DEFS[code]
258
+ return PUBLIC_APP_ERROR_DEFS[code];
244
259
  }
245
260
 
246
261
  export function pickPublicErrorMap<const TCodes extends readonly PublicAppErrorCode[]>(
247
262
  ...codes: TCodes
248
263
  ) {
249
- return Object.fromEntries(codes.map((code) => {
250
- const definition = PUBLIC_APP_ERROR_DEFS[code]
264
+ return Object.fromEntries(
265
+ codes.map((code) => {
266
+ const definition = PUBLIC_APP_ERROR_DEFS[code];
251
267
 
252
- if ("data" in definition) {
253
- return [code, {
254
- data: definition.data,
255
- message: definition.message,
256
- status: definition.status,
257
- }]
258
- }
268
+ if ("data" in definition) {
269
+ return [
270
+ code,
271
+ {
272
+ data: definition.data,
273
+ message: definition.message,
274
+ status: definition.status,
275
+ },
276
+ ];
277
+ }
259
278
 
260
- return [code, {
261
- message: definition.message,
262
- status: definition.status,
263
- }]
264
- })) as Pick<ErrorMap, TCodes[number]>
279
+ return [
280
+ code,
281
+ {
282
+ message: definition.message,
283
+ status: definition.status,
284
+ },
285
+ ];
286
+ }),
287
+ ) as Pick<ErrorMap, TCodes[number]>;
265
288
  }
@@ -1,16 +1,18 @@
1
- import { BETA_FEATURE_KEYS } from "@read-frog/definitions"
2
- import { z } from "zod"
1
+ import { BETA_FEATURE_KEYS } from "@read-frog/definitions";
2
+ import { z } from "zod";
3
3
 
4
- export const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS)
5
- export type BetaFeatureKey = z.infer<typeof BetaFeatureKeySchema>
4
+ export const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS);
5
+ export type BetaFeatureKey = z.infer<typeof BetaFeatureKeySchema>;
6
6
 
7
- export const BetaAccessStatusInputSchema = z.object({
8
- featureKey: BetaFeatureKeySchema,
9
- }).strict()
10
- export type BetaAccessStatusInput = z.infer<typeof BetaAccessStatusInputSchema>
7
+ export const BetaAccessStatusInputSchema = z
8
+ .object({
9
+ featureKey: BetaFeatureKeySchema,
10
+ })
11
+ .strict();
12
+ export type BetaAccessStatusInput = z.infer<typeof BetaAccessStatusInputSchema>;
11
13
 
12
14
  export const BetaAccessStatusOutputSchema = z.object({
13
15
  featureKey: BetaFeatureKeySchema,
14
16
  allowed: z.boolean(),
15
- })
16
- export type BetaAccessStatusOutput = z.infer<typeof BetaAccessStatusOutputSchema>
17
+ });
18
+ export type BetaAccessStatusOutput = z.infer<typeof BetaAccessStatusOutputSchema>;
@@ -1,7 +1,7 @@
1
- import { z } from "zod"
1
+ import { z } from "zod";
2
2
 
3
- export const billingIntervalSchema = z.enum(["month", "year"])
4
- export type BillingInterval = z.infer<typeof billingIntervalSchema>
3
+ export const billingIntervalSchema = z.enum(["month", "year"]);
4
+ export type BillingInterval = z.infer<typeof billingIntervalSchema>;
5
5
 
6
6
  export const billingSubscriptionStatusSchema = z.enum([
7
7
  "incomplete",
@@ -12,18 +12,44 @@ export const billingSubscriptionStatusSchema = z.enum([
12
12
  "canceled",
13
13
  "unpaid",
14
14
  "paused",
15
- ])
16
- export type BillingSubscriptionStatus = z.infer<typeof billingSubscriptionStatusSchema>
15
+ ]);
16
+ export type BillingSubscriptionStatus = z.infer<typeof billingSubscriptionStatusSchema>;
17
17
 
18
- export const billingPlanSchema = z.enum(["free", "pro", "ultra"])
19
- export type BillingPlan = z.infer<typeof billingPlanSchema>
18
+ export const billingPlanSchema = z.enum(["free", "pro", "ultra"]);
19
+ export type BillingPlan = z.infer<typeof billingPlanSchema>;
20
+
21
+ /**
22
+ * Whether a plan may use a feature, given the plans that feature allows.
23
+ *
24
+ * An explicit set rather than a minimum tier: there is no rank table to keep in
25
+ * step with the plan enum, and any combination is expressible by writing it
26
+ * down. The cost is that nothing derives from it automatically -- a feature's
27
+ * pricing-card placement is a companion edit, noted at each `*_ALLOWED_PLANS`.
28
+ */
29
+ export function isPlanAllowed(plan: BillingPlan, allowed: readonly BillingPlan[]): boolean {
30
+ return allowed.includes(plan);
31
+ }
32
+
33
+ /**
34
+ * Plans that may use the remote MCP server.
35
+ *
36
+ * Read by the server-side gate AND by the website's copy, so the page cannot
37
+ * promise access the API refuses. `satisfies` keeps the literal tuple type so
38
+ * the UI can render the plan names from this constant instead of hardcoding
39
+ * them.
40
+ *
41
+ * Companion edit when this changes: the feature bullet in
42
+ * `apps/www/src/routes/pricing.tsx` lives on the lowest allowed plan's card
43
+ * (higher cards inherit it through their "everything in <lower plan>" line).
44
+ */
45
+ export const MCP_ALLOWED_PLANS = ["ultra"] as const satisfies readonly BillingPlan[];
20
46
 
21
47
  // Plans a user can actively check out into (the free tier has no price).
22
- export const billingCheckoutPlanSchema = z.enum(["pro", "ultra"])
23
- export type BillingCheckoutPlan = z.infer<typeof billingCheckoutPlanSchema>
48
+ export const billingCheckoutPlanSchema = z.enum(["pro", "ultra"]);
49
+ export type BillingCheckoutPlan = z.infer<typeof billingCheckoutPlanSchema>;
24
50
 
25
- export const billingCurrencySchema = z.enum(["usd", "cad", "cny"])
26
- export type BillingCurrency = z.infer<typeof billingCurrencySchema>
51
+ export const billingCurrencySchema = z.enum(["usd", "cad", "cny"]);
52
+ export type BillingCurrency = z.infer<typeof billingCurrencySchema>;
27
53
 
28
54
  export const billingLocaleSchema = z.enum([
29
55
  "en",
@@ -35,58 +61,76 @@ export const billingLocaleSchema = z.enum([
35
61
  "vi",
36
62
  "zh",
37
63
  "zh-TW",
38
- ])
39
- export type BillingLocale = z.infer<typeof billingLocaleSchema>
64
+ ]);
65
+ export type BillingLocale = z.infer<typeof billingLocaleSchema>;
40
66
 
41
- export const billingAccessSourceSchema = z.enum(["subscription", "pass"])
42
- export type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>
67
+ export const billingAccessSourceSchema = z.enum(["subscription", "pass"]);
68
+ export type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>;
43
69
 
44
- export const billingScheduledChangeSchema = z.object({
45
- plan: billingCheckoutPlanSchema,
46
- interval: billingIntervalSchema,
47
- effectiveAt: z.coerce.date(),
48
- }).strict()
49
- export type BillingScheduledChange = z.infer<typeof billingScheduledChangeSchema>
70
+ export const billingScheduledChangeSchema = z
71
+ .object({
72
+ plan: billingCheckoutPlanSchema,
73
+ interval: billingIntervalSchema,
74
+ effectiveAt: z.coerce.date(),
75
+ })
76
+ .strict();
77
+ export type BillingScheduledChange = z.infer<typeof billingScheduledChangeSchema>;
50
78
 
51
- export const billingStatusSchema = z.object({
52
- plan: billingPlanSchema,
53
- status: billingSubscriptionStatusSchema.nullable(),
54
- interval: billingIntervalSchema.nullable(),
55
- currentPeriodEnd: z.coerce.date().nullable(),
56
- /**
57
- * When the subscription terminates, or null if it renews. Replaces the
58
- * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the
59
- * Customer Portal no longer sets it, and the termination date is not always
60
- * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.
61
- */
62
- cancelAt: z.coerce.date().nullable(),
63
- accessSource: billingAccessSourceSchema.nullable(),
64
- scheduledChange: billingScheduledChangeSchema.nullable(),
65
- unlimitedNotebaseNotes: z.boolean(),
66
- notebaseNoteLimit: z.number().int().positive(),
67
- notebaseNoteCount: z.number().int().min(0),
68
- }).strict()
69
- export type BillingStatus = z.infer<typeof billingStatusSchema>
79
+ export const billingStatusSchema = z
80
+ .object({
81
+ plan: billingPlanSchema,
82
+ status: billingSubscriptionStatusSchema.nullable(),
83
+ interval: billingIntervalSchema.nullable(),
84
+ currentPeriodEnd: z.coerce.date().nullable(),
85
+ /**
86
+ * When the subscription terminates, or null if it renews. Replaces the
87
+ * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the
88
+ * Customer Portal no longer sets it, and the termination date is not always
89
+ * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.
90
+ */
91
+ cancelAt: z.coerce.date().nullable(),
92
+ accessSource: billingAccessSourceSchema.nullable(),
93
+ scheduledChange: billingScheduledChangeSchema.nullable(),
94
+ unlimitedNotebaseNotes: z.boolean(),
95
+ notebaseNoteLimit: z.number().int().positive(),
96
+ notebaseNoteCount: z.number().int().min(0),
97
+ })
98
+ .strict();
99
+ export type BillingStatus = z.infer<typeof billingStatusSchema>;
70
100
 
71
- export const billingCreateCheckoutSessionInputSchema = z.object({
72
- currency: billingCurrencySchema,
73
- interval: billingIntervalSchema,
74
- locale: billingLocaleSchema,
75
- plan: billingCheckoutPlanSchema.default("pro"),
76
- }).strict()
77
- export type BillingCreateCheckoutSessionInput = z.infer<typeof billingCreateCheckoutSessionInputSchema>
101
+ export const billingCreateCheckoutSessionInputSchema = z
102
+ .object({
103
+ currency: billingCurrencySchema,
104
+ interval: billingIntervalSchema,
105
+ locale: billingLocaleSchema,
106
+ plan: billingCheckoutPlanSchema.default("pro"),
107
+ })
108
+ .strict();
109
+ export type BillingCreateCheckoutSessionInput = z.infer<
110
+ typeof billingCreateCheckoutSessionInputSchema
111
+ >;
78
112
 
79
- export const billingCreateCustomerPortalSessionInputSchema = z.object({
80
- locale: billingLocaleSchema,
81
- }).strict()
82
- export type BillingCreateCustomerPortalSessionInput = z.infer<typeof billingCreateCustomerPortalSessionInputSchema>
113
+ export const billingCreateCustomerPortalSessionInputSchema = z
114
+ .object({
115
+ locale: billingLocaleSchema,
116
+ })
117
+ .strict();
118
+ export type BillingCreateCustomerPortalSessionInput = z.infer<
119
+ typeof billingCreateCustomerPortalSessionInputSchema
120
+ >;
83
121
 
84
- export const billingSessionUrlOutputSchema = z.object({
85
- url: z.url(),
86
- }).strict()
87
- export type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>
122
+ export const billingSessionUrlOutputSchema = z
123
+ .object({
124
+ url: z.url(),
125
+ })
126
+ .strict();
127
+ export type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>;
88
128
 
89
- export const billingCancelScheduledChangeOutputSchema = z.object({
90
- success: z.literal(true),
91
- }).strict()
92
- export type BillingCancelScheduledChangeOutput = z.infer<typeof billingCancelScheduledChangeOutputSchema>
129
+ export const billingCancelScheduledChangeOutputSchema = z
130
+ .object({
131
+ success: z.literal(true),
132
+ })
133
+ .strict();
134
+ export type BillingCancelScheduledChangeOutput = z.infer<
135
+ typeof billingCancelScheduledChangeOutputSchema
136
+ >;
@@ -1,17 +1,16 @@
1
+ import { paginationShape, pageSchema } from "./pagination";
2
+ import { deletionResultSchema, expectedUpdatedAtSchema } from "./resource-mutation";
1
3
  import {
2
4
  cardIdentityShape,
3
5
  cardMemoryStateShape,
4
6
  cardStateSchema,
5
7
  cardTemplateConfigSchema,
6
8
  scheduleStatusSchema,
7
- } from "@read-frog/definitions"
8
- import { z } from "zod"
9
+ } from "@read-frog/definitions";
10
+ import { z } from "zod";
9
11
 
10
- export {
11
- cardStateSchema,
12
- scheduleStatusSchema,
13
- }
14
- export type { CardState, ScheduleStatus } from "@read-frog/definitions"
12
+ export { cardStateSchema, scheduleStatusSchema };
13
+ export type { CardState, ScheduleStatus } from "@read-frog/definitions";
15
14
 
16
15
  export const cardTemplateSchema = z.object({
17
16
  id: z.uuid(),
@@ -20,101 +19,105 @@ export const cardTemplateSchema = z.object({
20
19
  config: cardTemplateConfigSchema,
21
20
  createdAt: z.coerce.date(),
22
21
  updatedAt: z.coerce.date(),
23
- })
24
- export type CardTemplate = z.infer<typeof cardTemplateSchema>
22
+ });
23
+ export type CardTemplate = z.infer<typeof cardTemplateSchema>;
25
24
 
26
25
  export const CardTemplateListInputSchema = z.object({
27
- notebaseId: z.uuid(),
28
- })
29
- export type CardTemplateListInput = z.infer<typeof CardTemplateListInputSchema>
26
+ ...paginationShape,
27
+ notebaseId: z.uuid().optional(),
28
+ });
29
+ export type CardTemplateListInput = z.infer<typeof CardTemplateListInputSchema>;
30
30
 
31
- export const CardTemplateListOutputSchema = z.array(cardTemplateSchema)
32
- export type CardTemplateListOutput = z.infer<typeof CardTemplateListOutputSchema>
31
+ export const CardTemplateListOutputSchema = pageSchema(cardTemplateSchema);
32
+ export type CardTemplateListOutput = z.infer<typeof CardTemplateListOutputSchema>;
33
33
 
34
34
  export const CardTemplateGetInputSchema = z.object({
35
35
  id: z.uuid(),
36
- })
37
- export type CardTemplateGetInput = z.infer<typeof CardTemplateGetInputSchema>
38
-
39
- export const CardTemplateGetOutputSchema = cardTemplateSchema
40
- export type CardTemplateGetOutput = z.infer<typeof CardTemplateGetOutputSchema>
41
-
42
- export const CardTemplateCreateInputSchema = z.object({
43
- id: z.uuid().optional(),
44
- notebaseId: z.uuid(),
45
- name: z.string().min(1),
46
- config: cardTemplateConfigSchema,
47
- }).strict()
48
- export type CardTemplateCreateInput = z.infer<typeof CardTemplateCreateInputSchema>
36
+ });
37
+ export type CardTemplateGetInput = z.infer<typeof CardTemplateGetInputSchema>;
38
+
39
+ export const CardTemplateGetOutputSchema = cardTemplateSchema;
40
+ export type CardTemplateGetOutput = z.infer<typeof CardTemplateGetOutputSchema>;
41
+
42
+ export const CardTemplateCreateInputSchema = z
43
+ .object({
44
+ id: z.uuid().optional(),
45
+ notebaseId: z.uuid(),
46
+ name: z.string().min(1),
47
+ config: cardTemplateConfigSchema,
48
+ })
49
+ .strict();
50
+ export type CardTemplateCreateInput = z.infer<typeof CardTemplateCreateInputSchema>;
49
51
 
50
52
  export const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({
51
53
  txid: z.number(),
52
- })
53
- export type CardTemplateCreateOutput = z.infer<typeof CardTemplateCreateOutputSchema>
54
-
55
- export const CardTemplateUpdateInputSchema = z.object({
56
- id: z.uuid(),
57
- name: z.string().min(1).optional(),
58
- config: cardTemplateConfigSchema.optional(),
59
- }).strict()
60
- export type CardTemplateUpdateInput = z.infer<typeof CardTemplateUpdateInputSchema>
54
+ });
55
+ export type CardTemplateCreateOutput = z.infer<typeof CardTemplateCreateOutputSchema>;
56
+
57
+ export const CardTemplateUpdateInputSchema = z
58
+ .object({
59
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
60
+ id: z.uuid(),
61
+ name: z.string().min(1).optional(),
62
+ config: cardTemplateConfigSchema.optional(),
63
+ })
64
+ .strict();
65
+ export type CardTemplateUpdateInput = z.infer<typeof CardTemplateUpdateInputSchema>;
61
66
 
62
67
  export const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({
63
68
  txid: z.number(),
64
- })
65
- export type CardTemplateUpdateOutput = z.infer<typeof CardTemplateUpdateOutputSchema>
69
+ });
70
+ export type CardTemplateUpdateOutput = z.infer<typeof CardTemplateUpdateOutputSchema>;
66
71
 
67
72
  export const CardTemplateDeleteInputSchema = z.object({
68
73
  id: z.uuid(),
69
- })
70
- export type CardTemplateDeleteInput = z.infer<typeof CardTemplateDeleteInputSchema>
74
+ });
75
+ export type CardTemplateDeleteInput = z.infer<typeof CardTemplateDeleteInputSchema>;
71
76
 
72
- export const CardTemplateDeleteOutputSchema = z.object({
73
- txid: z.number(),
74
- })
75
- export type CardTemplateDeleteOutput = z.infer<typeof CardTemplateDeleteOutputSchema>
77
+ export const CardTemplateDeleteOutputSchema = deletionResultSchema;
78
+ export type CardTemplateDeleteOutput = z.infer<typeof CardTemplateDeleteOutputSchema>;
76
79
 
77
80
  export const cardSchema = z.object({
78
81
  ...cardIdentityShape,
79
82
  ...cardMemoryStateShape,
80
83
  createdAt: z.coerce.date(),
81
84
  updatedAt: z.coerce.date(),
82
- })
83
- export type Card = z.infer<typeof cardSchema>
85
+ });
86
+ export type Card = z.infer<typeof cardSchema>;
84
87
 
85
88
  export const renderedCardSchema = cardSchema.extend({
86
89
  front: z.string(),
87
90
  back: z.string(),
88
- })
89
- export type RenderedCard = z.infer<typeof renderedCardSchema>
91
+ });
92
+ export type RenderedCard = z.infer<typeof renderedCardSchema>;
90
93
 
91
94
  export const CardListInputSchema = z.object({
92
- notebaseId: z.uuid(),
95
+ notebaseId: z.uuid().optional(),
93
96
  templateId: z.uuid().optional(),
94
- limit: z.number().int().min(1).max(500).optional(),
95
- offset: z.number().int().min(0).optional(),
96
- })
97
- export type CardListInput = z.infer<typeof CardListInputSchema>
97
+ scheduleStatus: scheduleStatusSchema.optional(),
98
+ ...paginationShape,
99
+ });
100
+ export type CardListInput = z.infer<typeof CardListInputSchema>;
98
101
 
99
- export const CardListOutputSchema = z.array(renderedCardSchema)
100
- export type CardListOutput = z.infer<typeof CardListOutputSchema>
102
+ export const CardListOutputSchema = pageSchema(renderedCardSchema);
103
+ export type CardListOutput = z.infer<typeof CardListOutputSchema>;
101
104
 
102
105
  export const CardGetInputSchema = z.object({
103
106
  id: z.uuid(),
104
- })
105
- export type CardGetInput = z.infer<typeof CardGetInputSchema>
107
+ });
108
+ export type CardGetInput = z.infer<typeof CardGetInputSchema>;
106
109
 
107
- export const CardGetOutputSchema = renderedCardSchema
108
- export type CardGetOutput = z.infer<typeof CardGetOutputSchema>
110
+ export const CardGetOutputSchema = renderedCardSchema;
111
+ export type CardGetOutput = z.infer<typeof CardGetOutputSchema>;
109
112
 
110
113
  export const CardGenerateInputSchema = z.object({
111
114
  notebaseId: z.uuid(),
112
115
  templateId: z.uuid().optional(),
113
- })
114
- export type CardGenerateInput = z.infer<typeof CardGenerateInputSchema>
116
+ });
117
+ export type CardGenerateInput = z.infer<typeof CardGenerateInputSchema>;
115
118
 
116
119
  export const CardGenerateOutputSchema = z.object({
117
120
  created: z.number().int().min(0),
118
121
  txid: z.number(),
119
- })
120
- export type CardGenerateOutput = z.infer<typeof CardGenerateOutputSchema>
122
+ });
123
+ export type CardGenerateOutput = z.infer<typeof CardGenerateOutputSchema>;