@read-frog/api-contract 0.14.0 → 0.15.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 (39) hide show
  1. package/dist/index.d.ts +1105 -475
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +264 -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/notebase-column.ts +40 -32
  13. package/src/contracts/notebase-row.ts +85 -45
  14. package/src/contracts/notebase.ts +60 -40
  15. package/src/contracts/shared.ts +21 -2
  16. package/src/contracts/srs.ts +96 -63
  17. package/src/contracts/stats.ts +9 -11
  18. package/src/contracts/user.ts +3 -3
  19. package/src/contracts/video-transcript.ts +22 -12
  20. package/src/index.ts +37 -33
  21. package/src/public-errors.ts +74 -51
  22. package/src/schemas/beta-access.ts +12 -10
  23. package/src/schemas/billing.ts +77 -59
  24. package/src/schemas/card.ts +66 -63
  25. package/src/schemas/ebook.ts +165 -129
  26. package/src/schemas/hosted-ai.ts +84 -74
  27. package/src/schemas/notebase-column.ts +50 -36
  28. package/src/schemas/notebase-row.ts +88 -57
  29. package/src/schemas/notebase-stats.ts +28 -20
  30. package/src/schemas/notebase-view.ts +59 -49
  31. package/src/schemas/notebase.ts +136 -96
  32. package/src/schemas/pagination.ts +9 -0
  33. package/src/schemas/resource-mutation.ts +6 -0
  34. package/src/schemas/srs-stats.ts +30 -22
  35. package/src/schemas/srs.ts +152 -106
  36. package/src/schemas/stats.ts +27 -21
  37. package/src/schemas/timezone.ts +19 -16
  38. package/src/schemas/user.ts +27 -19
  39. 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,18 @@ 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
20
 
21
21
  // 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>
22
+ export const billingCheckoutPlanSchema = z.enum(["pro", "ultra"]);
23
+ export type BillingCheckoutPlan = z.infer<typeof billingCheckoutPlanSchema>;
24
24
 
25
- export const billingCurrencySchema = z.enum(["usd", "cad", "cny"])
26
- export type BillingCurrency = z.infer<typeof billingCurrencySchema>
25
+ export const billingCurrencySchema = z.enum(["usd", "cad", "cny"]);
26
+ export type BillingCurrency = z.infer<typeof billingCurrencySchema>;
27
27
 
28
28
  export const billingLocaleSchema = z.enum([
29
29
  "en",
@@ -35,58 +35,76 @@ export const billingLocaleSchema = z.enum([
35
35
  "vi",
36
36
  "zh",
37
37
  "zh-TW",
38
- ])
39
- export type BillingLocale = z.infer<typeof billingLocaleSchema>
38
+ ]);
39
+ export type BillingLocale = z.infer<typeof billingLocaleSchema>;
40
40
 
41
- export const billingAccessSourceSchema = z.enum(["subscription", "pass"])
42
- export type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>
41
+ export const billingAccessSourceSchema = z.enum(["subscription", "pass"]);
42
+ export type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>;
43
43
 
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>
44
+ export const billingScheduledChangeSchema = z
45
+ .object({
46
+ plan: billingCheckoutPlanSchema,
47
+ interval: billingIntervalSchema,
48
+ effectiveAt: z.coerce.date(),
49
+ })
50
+ .strict();
51
+ export type BillingScheduledChange = z.infer<typeof billingScheduledChangeSchema>;
50
52
 
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>
53
+ export const billingStatusSchema = z
54
+ .object({
55
+ plan: billingPlanSchema,
56
+ status: billingSubscriptionStatusSchema.nullable(),
57
+ interval: billingIntervalSchema.nullable(),
58
+ currentPeriodEnd: z.coerce.date().nullable(),
59
+ /**
60
+ * When the subscription terminates, or null if it renews. Replaces the
61
+ * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the
62
+ * Customer Portal no longer sets it, and the termination date is not always
63
+ * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.
64
+ */
65
+ cancelAt: z.coerce.date().nullable(),
66
+ accessSource: billingAccessSourceSchema.nullable(),
67
+ scheduledChange: billingScheduledChangeSchema.nullable(),
68
+ unlimitedNotebaseNotes: z.boolean(),
69
+ notebaseNoteLimit: z.number().int().positive(),
70
+ notebaseNoteCount: z.number().int().min(0),
71
+ })
72
+ .strict();
73
+ export type BillingStatus = z.infer<typeof billingStatusSchema>;
70
74
 
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>
75
+ export const billingCreateCheckoutSessionInputSchema = z
76
+ .object({
77
+ currency: billingCurrencySchema,
78
+ interval: billingIntervalSchema,
79
+ locale: billingLocaleSchema,
80
+ plan: billingCheckoutPlanSchema.default("pro"),
81
+ })
82
+ .strict();
83
+ export type BillingCreateCheckoutSessionInput = z.infer<
84
+ typeof billingCreateCheckoutSessionInputSchema
85
+ >;
78
86
 
79
- export const billingCreateCustomerPortalSessionInputSchema = z.object({
80
- locale: billingLocaleSchema,
81
- }).strict()
82
- export type BillingCreateCustomerPortalSessionInput = z.infer<typeof billingCreateCustomerPortalSessionInputSchema>
87
+ export const billingCreateCustomerPortalSessionInputSchema = z
88
+ .object({
89
+ locale: billingLocaleSchema,
90
+ })
91
+ .strict();
92
+ export type BillingCreateCustomerPortalSessionInput = z.infer<
93
+ typeof billingCreateCustomerPortalSessionInputSchema
94
+ >;
83
95
 
84
- export const billingSessionUrlOutputSchema = z.object({
85
- url: z.url(),
86
- }).strict()
87
- export type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>
96
+ export const billingSessionUrlOutputSchema = z
97
+ .object({
98
+ url: z.url(),
99
+ })
100
+ .strict();
101
+ export type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>;
88
102
 
89
- export const billingCancelScheduledChangeOutputSchema = z.object({
90
- success: z.literal(true),
91
- }).strict()
92
- export type BillingCancelScheduledChangeOutput = z.infer<typeof billingCancelScheduledChangeOutputSchema>
103
+ export const billingCancelScheduledChangeOutputSchema = z
104
+ .object({
105
+ success: z.literal(true),
106
+ })
107
+ .strict();
108
+ export type BillingCancelScheduledChangeOutput = z.infer<
109
+ typeof billingCancelScheduledChangeOutputSchema
110
+ >;
@@ -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>;