@read-frog/api-contract 0.12.6 → 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 +1171 -480
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +301 -103
  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 -7
  20. package/src/index.ts +37 -33
  21. package/src/public-errors.ts +97 -51
  22. package/src/schemas/beta-access.ts +12 -10
  23. package/src/schemas/billing.ts +77 -53
  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 +53 -24
package/dist/index.js CHANGED
@@ -261,6 +261,18 @@ const HostedAiQuotaExhaustedDataSchema = z.strictObject({
261
261
  resetAt: z.iso.datetime().nullable()
262
262
  });
263
263
  const PUBLIC_APP_ERROR_DEFS = {
264
+ RESOURCE_UPDATE_CONFLICT: {
265
+ message: "The resource changed. Read it again before updating.",
266
+ status: 409
267
+ },
268
+ RESOURCE_ALREADY_EXISTS: {
269
+ message: "A resource with this ID already exists.",
270
+ status: 409
271
+ },
272
+ FIELD_TYPE_CHANGE_UNSUPPORTED: {
273
+ message: "This operation cannot change the field type.",
274
+ status: 400
275
+ },
264
276
  HOSTED_AI_TIER_RESTRICTED: {
265
277
  data: HostedAiTierRestrictedDataSchema,
266
278
  message: "This Built-in AI tier is not available for this account",
@@ -283,6 +295,14 @@ const PUBLIC_APP_ERROR_DEFS = {
283
295
  message: "Video transcription is currently in beta for selected accounts",
284
296
  status: 403
285
297
  },
298
+ VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED: {
299
+ message: "AI subtitles require a Pro or Ultra subscription",
300
+ status: 403
301
+ },
302
+ VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED: {
303
+ message: "Update your payment method to generate new AI subtitles",
304
+ status: 402
305
+ },
286
306
  VIDEO_TRANSCRIPT_NOT_FOUND: {
287
307
  message: "Video transcript not found",
288
308
  status: 404
@@ -295,6 +315,10 @@ const PUBLIC_APP_ERROR_DEFS = {
295
315
  message: "Monthly transcription quota exceeded",
296
316
  status: 429
297
317
  },
318
+ VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH: {
319
+ message: "This video is longer than AI subtitles support",
320
+ status: 422
321
+ },
298
322
  NOTEBASE_COLUMN_NOT_FOUND: {
299
323
  message: "Notebase column not found",
300
324
  status: 404
@@ -476,7 +500,13 @@ const billingStatusSchema = z.object({
476
500
  status: billingSubscriptionStatusSchema.nullable(),
477
501
  interval: billingIntervalSchema.nullable(),
478
502
  currentPeriodEnd: z.coerce.date().nullable(),
479
- cancelAtPeriodEnd: z.boolean(),
503
+ /**
504
+ * When the subscription terminates, or null if it renews. Replaces the
505
+ * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the
506
+ * Customer Portal no longer sets it, and the termination date is not always
507
+ * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.
508
+ */
509
+ cancelAt: z.coerce.date().nullable(),
480
510
  accessSource: billingAccessSourceSchema.nullable(),
481
511
  scheduledChange: billingScheduledChangeSchema.nullable(),
482
512
  unlimitedNotebaseNotes: z.boolean(),
@@ -522,6 +552,42 @@ const billingContract = {
522
552
  }).output(billingCancelScheduledChangeOutputSchema)
523
553
  };
524
554
  //#endregion
555
+ //#region src/contracts/shared.ts
556
+ /**
557
+ * Declares a procedure that is exposed to agents as an MCP tool, not only to
558
+ * the REST/OpenAPI surface.
559
+ *
560
+ * oRPC types `~orpc.route` as the widened `Route`, so `route.summary` reads back
561
+ * as `string | undefined` whatever is passed in. `$meta` is the only channel it
562
+ * keeps generic, so the prose is mirrored there and stays a required `string`
563
+ * for tool definitions. OpenAPI keeps reading `route`.
564
+ */
565
+ function defineAgentProcedure(route) {
566
+ return oc.$meta({
567
+ summary: route.summary,
568
+ description: route.description
569
+ }).route(route);
570
+ }
571
+ //#endregion
572
+ //#region src/schemas/pagination.ts
573
+ const paginationShape = {
574
+ limit: z.number().int().min(1).max(500).optional(),
575
+ offset: z.number().int().min(0).optional()
576
+ };
577
+ function pageSchema(itemSchema) {
578
+ return z.object({
579
+ items: z.array(itemSchema),
580
+ hasMore: z.boolean()
581
+ });
582
+ }
583
+ //#endregion
584
+ //#region src/schemas/resource-mutation.ts
585
+ const expectedUpdatedAtSchema = z.iso.datetime({ offset: true });
586
+ const deletionResultSchema = z.object({
587
+ id: z.uuid(),
588
+ txid: z.number()
589
+ });
590
+ //#endregion
525
591
  //#region src/schemas/card.ts
526
592
  const cardTemplateSchema = z.object({
527
593
  id: z.uuid(),
@@ -531,8 +597,11 @@ const cardTemplateSchema = z.object({
531
597
  createdAt: z.coerce.date(),
532
598
  updatedAt: z.coerce.date()
533
599
  });
534
- const CardTemplateListInputSchema = z.object({ notebaseId: z.uuid() });
535
- const CardTemplateListOutputSchema = z.array(cardTemplateSchema);
600
+ const CardTemplateListInputSchema = z.object({
601
+ ...paginationShape,
602
+ notebaseId: z.uuid().optional()
603
+ });
604
+ const CardTemplateListOutputSchema = pageSchema(cardTemplateSchema);
536
605
  const CardTemplateGetInputSchema = z.object({ id: z.uuid() });
537
606
  const CardTemplateGetOutputSchema = cardTemplateSchema;
538
607
  const CardTemplateCreateInputSchema = z.object({
@@ -543,13 +612,14 @@ const CardTemplateCreateInputSchema = z.object({
543
612
  }).strict();
544
613
  const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({ txid: z.number() });
545
614
  const CardTemplateUpdateInputSchema = z.object({
615
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
546
616
  id: z.uuid(),
547
617
  name: z.string().min(1).optional(),
548
618
  config: cardTemplateConfigSchema.optional()
549
619
  }).strict();
550
620
  const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({ txid: z.number() });
551
621
  const CardTemplateDeleteInputSchema = z.object({ id: z.uuid() });
552
- const CardTemplateDeleteOutputSchema = z.object({ txid: z.number() });
622
+ const CardTemplateDeleteOutputSchema = deletionResultSchema;
553
623
  const cardSchema = z.object({
554
624
  ...cardIdentityShape,
555
625
  ...cardMemoryStateShape,
@@ -561,12 +631,12 @@ const renderedCardSchema = cardSchema.extend({
561
631
  back: z.string()
562
632
  });
563
633
  const CardListInputSchema = z.object({
564
- notebaseId: z.uuid(),
634
+ notebaseId: z.uuid().optional(),
565
635
  templateId: z.uuid().optional(),
566
- limit: z.number().int().min(1).max(500).optional(),
567
- offset: z.number().int().min(0).optional()
636
+ scheduleStatus: scheduleStatusSchema.optional(),
637
+ ...paginationShape
568
638
  });
569
- const CardListOutputSchema = z.array(renderedCardSchema);
639
+ const CardListOutputSchema = pageSchema(renderedCardSchema);
570
640
  const CardGetInputSchema = z.object({ id: z.uuid() });
571
641
  const CardGetOutputSchema = renderedCardSchema;
572
642
  const CardGenerateInputSchema = z.object({
@@ -578,24 +648,23 @@ const CardGenerateOutputSchema = z.object({
578
648
  txid: z.number()
579
649
  });
580
650
  //#endregion
581
- //#region src/contracts/shared.ts
582
- const notebaseProcedure = oc;
583
- //#endregion
584
651
  //#region src/contracts/card.ts
585
652
  const cardContract = {
586
- list: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
653
+ list: defineAgentProcedure({
587
654
  method: "GET",
588
655
  path: "/cards",
589
- summary: "List rendered cards",
656
+ summary: "List cards",
657
+ description: "Browse owned cards with rendered fronts, backs, source IDs and learning state. Optionally filter by notebase, template or scheduleStatus. Supports limit and offset pagination.",
590
658
  tags: ["Cards"]
591
- }).input(CardListInputSchema).output(CardListOutputSchema),
592
- get: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND")).route({
659
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(CardListInputSchema).output(CardListOutputSchema),
660
+ get: defineAgentProcedure({
593
661
  method: "GET",
594
662
  path: "/cards/{id}",
595
- summary: "Get rendered card",
663
+ summary: "Get card",
664
+ description: "Read one owned card with its rendered front, back, source IDs and learning state.",
596
665
  tags: ["Cards"]
597
- }).input(CardGetInputSchema).output(CardGetOutputSchema),
598
- generate: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_NOT_FOUND")).route({
666
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND")).input(CardGetInputSchema).output(CardGetOutputSchema),
667
+ generate: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_NOT_FOUND")).route({
599
668
  method: "POST",
600
669
  path: "/cards/generate",
601
670
  summary: "Generate missing cards",
@@ -605,36 +674,41 @@ const cardContract = {
605
674
  //#endregion
606
675
  //#region src/contracts/card-template.ts
607
676
  const cardTemplateContract = {
608
- list: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
677
+ list: defineAgentProcedure({
609
678
  method: "GET",
610
679
  path: "/card-templates",
611
680
  summary: "List card templates",
681
+ description: "List owned card templates, optionally filtered by notebase. Supports limit and offset pagination.",
612
682
  tags: ["Card Templates"]
613
- }).input(CardTemplateListInputSchema).output(CardTemplateListOutputSchema),
614
- get: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).route({
683
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(CardTemplateListInputSchema).output(CardTemplateListOutputSchema),
684
+ get: defineAgentProcedure({
615
685
  method: "GET",
616
686
  path: "/card-templates/{id}",
617
687
  summary: "Get card template",
688
+ description: "Read the complete definition and updatedAt timestamp of an owned card template.",
618
689
  tags: ["Card Templates"]
619
- }).input(CardTemplateGetInputSchema).output(CardTemplateGetOutputSchema),
620
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).route({
690
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).input(CardTemplateGetInputSchema).output(CardTemplateGetOutputSchema),
691
+ create: defineAgentProcedure({
621
692
  method: "POST",
622
693
  path: "/card-templates",
623
694
  summary: "Create card template",
695
+ description: "Create a template in an owned notebase using existing field IDs in its patterns. This generates cards for existing notes.",
624
696
  tags: ["Card Templates"]
625
- }).input(CardTemplateCreateInputSchema).output(CardTemplateCreateOutputSchema),
626
- update: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).route({
697
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(CardTemplateCreateInputSchema).output(CardTemplateCreateOutputSchema),
698
+ update: defineAgentProcedure({
627
699
  method: "PATCH",
628
700
  path: "/card-templates/{id}",
629
701
  summary: "Update card template",
702
+ description: "Change an owned template name or definition. Rendered cards reflect the saved template. expectedUpdatedAt guards against editing stale data.",
630
703
  tags: ["Card Templates"]
631
- }).input(CardTemplateUpdateInputSchema).output(CardTemplateUpdateOutputSchema),
632
- delete: notebaseProcedure.errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).route({
704
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND", "CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT")).input(CardTemplateUpdateInputSchema).output(CardTemplateUpdateOutputSchema),
705
+ delete: defineAgentProcedure({
633
706
  method: "DELETE",
634
707
  path: "/card-templates/{id}",
635
708
  summary: "Delete card template",
709
+ description: "Permanently delete an owned template and its generated cards and review records. Source notes are preserved.",
636
710
  tags: ["Card Templates"]
637
- }).input(CardTemplateDeleteInputSchema).output(CardTemplateDeleteOutputSchema)
711
+ }).errors(pickPublicErrorMap("CARD_TEMPLATE_NOT_FOUND")).input(CardTemplateDeleteInputSchema).output(CardTemplateDeleteOutputSchema)
638
712
  };
639
713
  //#endregion
640
714
  //#region src/schemas/ebook.ts
@@ -848,6 +922,7 @@ const notebaseColumnCreateDataSchema = z.object({
848
922
  config: notebaseColumnConfigSchema
849
923
  }).strict();
850
924
  const notebaseColumnUpdateDataSchema = z.object({
925
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional(),
851
926
  name: z.string().min(1).optional(),
852
927
  config: notebaseColumnConfigSchema.optional(),
853
928
  width: notebaseColumnWidthSchema.nullable().optional(),
@@ -857,14 +932,20 @@ const NotebaseColumnCreateInputSchema = z.object({
857
932
  notebaseId: z.uuid(),
858
933
  data: notebaseColumnCreateDataSchema
859
934
  });
860
- const NotebaseColumnCreateOutputSchema = z.object({ txid: z.number() });
935
+ const NotebaseColumnCreateOutputSchema = z.object({
936
+ field: notebaseColumnSchema,
937
+ txid: z.number()
938
+ });
861
939
  const NotebaseColumnUpdateInputSchema = z.object({
862
940
  notebaseColumnId: z.uuid(),
863
941
  data: notebaseColumnUpdateDataSchema
864
942
  });
865
- const NotebaseColumnUpdateOutputSchema = z.object({ txid: z.number() });
943
+ const NotebaseColumnUpdateOutputSchema = z.object({
944
+ field: notebaseColumnSchema,
945
+ txid: z.number()
946
+ });
866
947
  const NotebaseColumnDeleteInputSchema = z.object({ notebaseColumnId: z.uuid() });
867
- const NotebaseColumnDeleteOutputSchema = z.object({ txid: z.number() });
948
+ const NotebaseColumnDeleteOutputSchema = deletionResultSchema;
868
949
  const NotebaseColumnReorderInputSchema = z.object({
869
950
  notebaseId: z.uuid(),
870
951
  ids: z.array(z.uuid())
@@ -885,12 +966,18 @@ const notebaseRowCreateDataSchema = z.object({
885
966
  id: z.uuid().optional(),
886
967
  cells: notebaseRowCellsSchema.optional()
887
968
  }).strict();
888
- const notebaseRowUpdateDataSchema = z.object({ cells: notebaseRowCellsSchema.optional() }).strict();
969
+ const notebaseRowUpdateDataSchema = z.object({
970
+ cells: notebaseRowCellsSchema.optional(),
971
+ expectedUpdatedAt: expectedUpdatedAtSchema.optional()
972
+ }).strict();
889
973
  const NotebaseRowCreateInputSchema = z.object({
890
974
  notebaseId: z.uuid(),
891
975
  data: notebaseRowCreateDataSchema
892
976
  });
893
- const NotebaseRowCreateOutputSchema = z.object({ txid: z.number() });
977
+ const NotebaseRowCreateOutputSchema = z.object({
978
+ note: notebaseRowSchema,
979
+ txid: z.number()
980
+ });
894
981
  const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50;
895
982
  const NotebaseRowCreateManyInputSchema = z.object({
896
983
  notebaseId: z.uuid(),
@@ -914,7 +1001,10 @@ const NotebaseRowCreateManyInputSchema = z.object({
914
1001
  seenIds.add(row.id);
915
1002
  });
916
1003
  });
917
- const NotebaseRowCreateManyOutputSchema = z.object({ txid: z.number() });
1004
+ const NotebaseRowCreateManyOutputSchema = z.object({
1005
+ items: z.array(notebaseRowSchema),
1006
+ txid: z.number()
1007
+ });
918
1008
  const NotebaseRowUpdateInputSchema = z.object({
919
1009
  notebaseRowId: z.uuid(),
920
1010
  data: notebaseRowUpdateDataSchema
@@ -929,12 +1019,23 @@ const NotebaseRowUpdateOutputSchema = z.object({
929
1019
  txid: z.number()
930
1020
  });
931
1021
  const NotebaseRowDeleteInputSchema = z.object({ notebaseRowId: z.uuid() });
932
- const NotebaseRowDeleteOutputSchema = z.object({ txid: z.number() });
1022
+ const NotebaseRowDeleteOutputSchema = deletionResultSchema;
933
1023
  const NotebaseRowReorderInputSchema = z.object({
934
1024
  notebaseId: z.uuid(),
935
1025
  ids: z.array(z.uuid())
936
1026
  });
937
1027
  const NotebaseRowReorderOutputSchema = z.object({ txid: z.number() });
1028
+ const NotebaseRowListInputSchema = z.object({
1029
+ notebaseId: z.uuid().optional(),
1030
+ query: z.string().trim().min(2).max(200).optional(),
1031
+ ...paginationShape
1032
+ }).refine((input) => input.query === void 0 || input.notebaseId !== void 0, {
1033
+ error: "notebaseId is required when query is set",
1034
+ path: ["notebaseId"]
1035
+ });
1036
+ const NotebaseRowListOutputSchema = pageSchema(notebaseRowSchema);
1037
+ const NotebaseRowGetInputSchema = z.object({ id: z.uuid() });
1038
+ const NotebaseRowGetOutputSchema = notebaseRowSchema;
938
1039
  //#endregion
939
1040
  //#region src/schemas/notebase-view.ts
940
1041
  const notebaseViewTypeSchema = z.enum([
@@ -988,10 +1089,11 @@ const notebaseViewSchema = z.object({
988
1089
  //#endregion
989
1090
  //#region src/schemas/notebase.ts
990
1091
  const NotebaseListInputSchema = z.object({});
991
- const NotebaseListItemSchema = z.object({
1092
+ const notebaseSummarySchema = z.object({
992
1093
  id: z.string(),
993
1094
  name: z.string()
994
1095
  });
1096
+ const NotebaseListItemSchema = notebaseSummarySchema;
995
1097
  const NotebaseListOutputSchema = z.array(NotebaseListItemSchema);
996
1098
  const notebaseSchema = z.object({
997
1099
  id: z.string(),
@@ -1052,7 +1154,10 @@ const notebaseCreateDataSchema = z.object({
1052
1154
  }).optional()
1053
1155
  }).strict();
1054
1156
  const NotebaseCreateInputSchema = notebaseCreateDataSchema;
1055
- const NotebaseCreateOutputSchema = z.object({ txid: z.number() });
1157
+ const NotebaseCreateOutputSchema = z.object({
1158
+ notebase: notebaseSchema,
1159
+ txid: z.number()
1160
+ });
1056
1161
  const notebaseUpdateDataSchema = z.object({
1057
1162
  name: z.string().min(1).optional(),
1058
1163
  srsNewPerDay: schedulingParamsShape.newPerDay.optional(),
@@ -1060,10 +1165,19 @@ const notebaseUpdateDataSchema = z.object({
1060
1165
  srsDesiredRetention: schedulingParamsShape.desiredRetention.optional()
1061
1166
  }).strict();
1062
1167
  const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({ id: z.uuid() });
1063
- const NotebaseUpdateOutputSchema = z.object({ txid: z.number() });
1168
+ const NotebaseUpdateOutputSchema = z.object({
1169
+ notebase: notebaseSchema,
1170
+ txid: z.number()
1171
+ });
1064
1172
  const NotebaseDeleteInputSchema = z.object({ id: z.uuid() });
1065
- const NotebaseDeleteOutputSchema = z.object({ txid: z.number() });
1173
+ const NotebaseDeleteOutputSchema = deletionResultSchema;
1066
1174
  const NotebaseGetInputSchema = z.object({ id: z.uuid() });
1175
+ const NotebaseGetSummaryInputSchema = z.object({ id: z.uuid() });
1176
+ const NotebaseGetSummaryOutputSchema = notebaseSummarySchema.extend({
1177
+ srsNewPerDay: schedulingParamsShape.newPerDay,
1178
+ srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,
1179
+ srsDesiredRetention: schedulingParamsShape.desiredRetention
1180
+ });
1067
1181
  const NotebaseGetSchemaInputSchema = z.object({ id: z.uuid() });
1068
1182
  const NotebaseGetOutputSchema = notebaseSchema.extend({
1069
1183
  createdAt: z.coerce.date(),
@@ -1081,65 +1195,80 @@ const NotebaseGetSchemaOutputSchema = z.object({
1081
1195
  //#endregion
1082
1196
  //#region src/contracts/notebase.ts
1083
1197
  const notebaseContract = {
1084
- list: notebaseProcedure.route({
1198
+ list: defineAgentProcedure({
1085
1199
  method: "GET",
1086
1200
  path: "/notebases",
1087
1201
  summary: "List notebases",
1202
+ description: "List the notebases (word books) owned by the current user.",
1088
1203
  tags: ["Notebases"]
1089
1204
  }).input(NotebaseListInputSchema).output(NotebaseListOutputSchema),
1090
- get: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1205
+ getSummary: defineAgentProcedure({
1206
+ method: "GET",
1207
+ path: "/notebases/{id}/summary",
1208
+ summary: "Get notebase summary",
1209
+ description: "Read the name and public study settings of an owned notebase without loading note content.",
1210
+ tags: ["Notebases"]
1211
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseGetSummaryInputSchema).output(NotebaseGetSummaryOutputSchema),
1212
+ get: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1091
1213
  method: "GET",
1092
1214
  path: "/notebases/{id}",
1093
1215
  summary: "Get notebase with notebase columns, rows, and views",
1094
1216
  tags: ["Notebases"]
1095
1217
  }).input(NotebaseGetInputSchema).output(NotebaseGetOutputSchema),
1096
- getSchema: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1218
+ getSchema: defineAgentProcedure({
1097
1219
  method: "GET",
1098
1220
  path: "/notebases/{id}/schema",
1099
1221
  summary: "Get notebase schema",
1222
+ description: "Read an owned notebase name and field definitions, including field IDs, types and updatedAt timestamps. Does not return note content.",
1100
1223
  tags: ["Notebases"]
1101
- }).input(NotebaseGetSchemaInputSchema).output(NotebaseGetSchemaOutputSchema),
1102
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTE_LIMIT_EXCEEDED", "CELL_VALIDATION_FAILED")).route({
1224
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseGetSchemaInputSchema).output(NotebaseGetSchemaOutputSchema),
1225
+ create: defineAgentProcedure({
1103
1226
  method: "POST",
1104
1227
  path: "/notebases",
1105
1228
  summary: "Create notebase",
1229
+ description: "Create an owned notebase with optional initial fields and notes. Client-provided entity IDs are supported; duplicate IDs produce a conflict.",
1106
1230
  tags: ["Notebases"]
1107
- }).input(NotebaseCreateInputSchema).output(NotebaseCreateOutputSchema),
1108
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1231
+ }).errors(pickPublicErrorMap("NOTE_LIMIT_EXCEEDED", "CELL_VALIDATION_FAILED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseCreateInputSchema).output(NotebaseCreateOutputSchema),
1232
+ update: defineAgentProcedure({
1109
1233
  method: "PUT",
1110
1234
  path: "/notebases/{id}",
1111
1235
  summary: "Update notebase",
1236
+ description: "Update the supplied name or public study settings of an owned notebase, preserving omitted properties.",
1112
1237
  tags: ["Notebases"]
1113
- }).input(NotebaseUpdateInputSchema).output(NotebaseUpdateOutputSchema),
1114
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1238
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseUpdateInputSchema).output(NotebaseUpdateOutputSchema),
1239
+ delete: defineAgentProcedure({
1115
1240
  method: "DELETE",
1116
1241
  path: "/notebases/{id}",
1117
1242
  summary: "Delete notebase",
1243
+ description: "Permanently delete an owned notebase and its fields, notes, templates, cards and review records. Return the deleted notebase ID.",
1118
1244
  tags: ["Notebases"]
1119
- }).input(NotebaseDeleteInputSchema).output(NotebaseDeleteOutputSchema)
1245
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseDeleteInputSchema).output(NotebaseDeleteOutputSchema)
1120
1246
  };
1121
1247
  //#endregion
1122
1248
  //#region src/contracts/notebase-column.ts
1123
1249
  const notebaseColumnContract = {
1124
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1250
+ create: defineAgentProcedure({
1125
1251
  method: "POST",
1126
1252
  path: "/notebase-columns",
1127
- summary: "Create notebase column",
1253
+ summary: "Create notebase field",
1254
+ description: "Create a field in an owned notebase. The returned field ID is used as a key in note cells.",
1128
1255
  tags: ["Notebase Columns"]
1129
- }).input(NotebaseColumnCreateInputSchema).output(NotebaseColumnCreateOutputSchema),
1130
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND")).route({
1256
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseColumnCreateInputSchema).output(NotebaseColumnCreateOutputSchema),
1257
+ update: defineAgentProcedure({
1131
1258
  method: "PATCH",
1132
1259
  path: "/notebase-columns/{notebaseColumnId}",
1133
- summary: "Update notebase column",
1260
+ summary: "Update notebase field",
1261
+ description: "Update an owned field without changing its type. Removing select options clears affected note values. expectedUpdatedAt guards against editing stale data.",
1134
1262
  tags: ["Notebase Columns"]
1135
- }).input(NotebaseColumnUpdateInputSchema).output(NotebaseColumnUpdateOutputSchema),
1136
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND", "PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED", "CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE", "CONCURRENT_POSITION_CONFLICT")).route({
1263
+ }).errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT", "FIELD_TYPE_CHANGE_UNSUPPORTED")).input(NotebaseColumnUpdateInputSchema).output(NotebaseColumnUpdateOutputSchema),
1264
+ delete: defineAgentProcedure({
1137
1265
  method: "DELETE",
1138
1266
  path: "/notebase-columns/{notebaseColumnId}",
1139
- summary: "Delete notebase column",
1267
+ summary: "Delete notebase field",
1268
+ description: "Delete an owned field and remove its values from notes. Primary fields and fields referenced by templates cannot be deleted.",
1140
1269
  tags: ["Notebase Columns"]
1141
- }).input(NotebaseColumnDeleteInputSchema).output(NotebaseColumnDeleteOutputSchema),
1142
- reorder: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1270
+ }).errors(pickPublicErrorMap("NOTEBASE_COLUMN_NOT_FOUND", "PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED", "CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE", "CONCURRENT_POSITION_CONFLICT")).input(NotebaseColumnDeleteInputSchema).output(NotebaseColumnDeleteOutputSchema),
1271
+ reorder: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1143
1272
  method: "POST",
1144
1273
  path: "/notebase-columns/reorder",
1145
1274
  summary: "Reorder notebase columns",
@@ -1149,31 +1278,49 @@ const notebaseColumnContract = {
1149
1278
  //#endregion
1150
1279
  //#region src/contracts/notebase-row.ts
1151
1280
  const notebaseRowContract = {
1152
- create: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).route({
1281
+ list: defineAgentProcedure({
1282
+ method: "GET",
1283
+ path: "/notebase-rows",
1284
+ summary: "List or search notes",
1285
+ description: "List or search owned notes, optionally within one notebase. Supply query to search; omit it to browse, which returns every note in scope rather than a filtered set. Searching requires notebaseId and covers that one notebase, so cover several by listing them first and calling this once per notebase. The query filter is at least two characters, matches a literal case-insensitive substring, and only searches fields of type string, so values in number, boolean, date and select fields are never matched. Supports limit and offset pagination.",
1286
+ tags: ["Notebase Rows"]
1287
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(NotebaseRowListInputSchema).output(NotebaseRowListOutputSchema),
1288
+ get: defineAgentProcedure({
1289
+ method: "GET",
1290
+ path: "/notebase-rows/{id}",
1291
+ summary: "Get note",
1292
+ description: "Read one owned note with field-ID values and the updatedAt timestamp used for modification checks.",
1293
+ tags: ["Notebase Rows"]
1294
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND")).input(NotebaseRowGetInputSchema).output(NotebaseRowGetOutputSchema),
1295
+ create: defineAgentProcedure({
1153
1296
  method: "POST",
1154
1297
  path: "/notebase-rows",
1155
- summary: "Create notebase row",
1298
+ summary: "Create note",
1299
+ description: "Create a note in an owned notebase using field IDs and their declared value types. Existing templates generate cards. A duplicate entity ID produces a conflict.",
1156
1300
  tags: ["Notebase Rows"]
1157
- }).input(NotebaseRowCreateInputSchema).output(NotebaseRowCreateOutputSchema),
1158
- createMany: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).route({
1301
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseRowCreateInputSchema).output(NotebaseRowCreateOutputSchema),
1302
+ createMany: defineAgentProcedure({
1159
1303
  method: "POST",
1160
1304
  path: "/notebase-rows/batch",
1161
- summary: "Create notebase rows in a single transaction",
1305
+ summary: "Create notes",
1306
+ description: "Create 1–50 notes atomically in one owned notebase. Cells use field IDs and declared value types. Existing templates generate cards. Duplicate entity IDs roll back the whole batch.",
1162
1307
  tags: ["Notebase Rows"]
1163
- }).input(NotebaseRowCreateManyInputSchema).output(NotebaseRowCreateManyOutputSchema),
1164
- update: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CELL_VALIDATION_FAILED")).route({
1308
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CELL_VALIDATION_FAILED", "CONCURRENT_POSITION_CONFLICT", "NOTE_LIMIT_EXCEEDED")).errors(pickPublicErrorMap("RESOURCE_ALREADY_EXISTS")).input(NotebaseRowCreateManyInputSchema).output(NotebaseRowCreateManyOutputSchema),
1309
+ update: defineAgentProcedure({
1165
1310
  method: "PATCH",
1166
1311
  path: "/notebase-rows/{notebaseRowId}",
1167
- summary: "Update notebase row cells",
1312
+ summary: "Update note",
1313
+ description: "Merge supplied fields into an owned note, preserving omitted fields. Use null to clear a field. expectedUpdatedAt guards against editing stale data; reread on a modification conflict.",
1168
1314
  tags: ["Notebase Rows"]
1169
- }).input(NotebaseRowUpdateInputSchema).output(NotebaseRowUpdateOutputSchema),
1170
- delete: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1315
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CELL_VALIDATION_FAILED")).errors(pickPublicErrorMap("RESOURCE_UPDATE_CONFLICT")).input(NotebaseRowUpdateInputSchema).output(NotebaseRowUpdateOutputSchema),
1316
+ delete: defineAgentProcedure({
1171
1317
  method: "DELETE",
1172
1318
  path: "/notebase-rows/{notebaseRowId}",
1173
- summary: "Delete notebase row",
1319
+ summary: "Delete note",
1320
+ description: "Permanently delete an owned note and its derived cards and review records. Return the deleted note ID.",
1174
1321
  tags: ["Notebase Rows"]
1175
- }).input(NotebaseRowDeleteInputSchema).output(NotebaseRowDeleteOutputSchema),
1176
- reorder: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1322
+ }).errors(pickPublicErrorMap("NOTEBASE_ROW_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).input(NotebaseRowDeleteInputSchema).output(NotebaseRowDeleteOutputSchema),
1323
+ reorder: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND", "CONCURRENT_POSITION_CONFLICT")).route({
1177
1324
  method: "POST",
1178
1325
  path: "/notebase-rows/reorder",
1179
1326
  summary: "Reorder notebase rows",
@@ -1215,7 +1362,10 @@ const srsReviewInputSchema = z.object({
1215
1362
  durationMs: z.number().int().min(0).max(SRS_REVIEW_DURATION_MS_MAX),
1216
1363
  timezone: timezoneSchema
1217
1364
  }).strict();
1218
- const srsRollbackReviewInputSchema = z.object({ cardId: z.uuid() }).strict();
1365
+ const srsRollbackReviewInputSchema = z.object({
1366
+ expectedReviewId: z.uuid().optional(),
1367
+ cardId: z.uuid()
1368
+ }).strict();
1219
1369
  const srsScheduleStatusStatsSchema = z.record(activeScheduleStatusSchema, z.number().int().min(0));
1220
1370
  const srsScheduleStatusStatsInputSchema = z.object({
1221
1371
  notebaseIds: z.array(z.uuid()).optional(),
@@ -1243,8 +1393,15 @@ const srsRevlogSchema = z.object({
1243
1393
  createdAt: z.coerce.date()
1244
1394
  });
1245
1395
  const srsRevlogWithoutSnapshotSchema = srsRevlogSchema.omit({ fsrsReviewLogSnapshot: true });
1246
- const srsListCardRevlogsInputSchema = z.object({ cardId: z.uuid() }).strict();
1247
- const srsListCardRevlogsOutputSchema = z.object({ items: z.array(srsRevlogWithoutSnapshotSchema) }).strict();
1396
+ const srsListCardRevlogsInputSchema = z.object({
1397
+ ...paginationShape,
1398
+ notebaseId: z.uuid().optional(),
1399
+ cardId: z.uuid().optional()
1400
+ }).strict();
1401
+ const srsListCardRevlogsOutputSchema = z.object({
1402
+ items: z.array(srsRevlogWithoutSnapshotSchema),
1403
+ hasMore: z.boolean()
1404
+ }).strict();
1248
1405
  const srsReviewOutputSchema = z.object({
1249
1406
  card: cardSchema,
1250
1407
  revlog: srsRevlogSchema,
@@ -1259,6 +1416,16 @@ const srsRollbackReviewOutputSchema = z.object({
1259
1416
  const srsTxidOutputSchema = z.object({ txid: z.number() });
1260
1417
  const srsSetCardBuriedOutputSchema = srsTxidOutputSchema;
1261
1418
  const srsSetCardSuspendedOutputSchema = srsTxidOutputSchema;
1419
+ const srsListUnreadOptimizerResultsInputSchema = z.object({}).strict();
1420
+ const srsOptimizerUnreadResultSchema = z.object({
1421
+ runId: z.uuid(),
1422
+ notebaseName: z.string().min(1),
1423
+ revlogCount: z.number().int().positive(),
1424
+ improvement: z.number().nonnegative().nullable()
1425
+ }).strict();
1426
+ const srsListUnreadOptimizerResultsOutputSchema = z.array(srsOptimizerUnreadResultSchema);
1427
+ const srsAcknowledgeOptimizerResultsInputSchema = z.object({ runIds: z.array(z.uuid()).min(1) }).strict();
1428
+ const srsAcknowledgeOptimizerResultsOutputSchema = z.object({ acknowledgedCount: z.number().int().nonnegative() }).strict();
1262
1429
  function formatLastReviewTime(lastReviewTime) {
1263
1430
  return lastReviewTime ? new Date(lastReviewTime).toISOString() : nullLastReviewTimeSentinel;
1264
1431
  }
@@ -1295,42 +1462,60 @@ function bytesToUuid(bytes) {
1295
1462
  //#endregion
1296
1463
  //#region src/contracts/srs.ts
1297
1464
  const srsContract = {
1298
- scheduleStatusStats: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1465
+ scheduleStatusStats: defineAgentProcedure({
1299
1466
  method: "GET",
1300
1467
  path: "/srs/schedule-status-stats",
1301
- summary: "List today schedule status stats for notebases",
1468
+ summary: "Get study statistics",
1469
+ description: "Read existing study queue counts for owned notebases in the supplied timezone. Does not return note content or card faces.",
1470
+ tags: ["SRS"]
1471
+ }).errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).input(srsScheduleStatusStatsInputSchema).output(srsScheduleStatusStatsOutputSchema),
1472
+ listUnreadOptimizerResults: oc.route({
1473
+ method: "GET",
1474
+ path: "/srs/optimizer-results/unread",
1475
+ summary: "List unread applied SRS optimizer results",
1302
1476
  tags: ["SRS"]
1303
- }).input(srsScheduleStatusStatsInputSchema).output(srsScheduleStatusStatsOutputSchema),
1304
- listCardRevlogs: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND")).route({
1477
+ }).input(srsListUnreadOptimizerResultsInputSchema).output(srsListUnreadOptimizerResultsOutputSchema),
1478
+ acknowledgeOptimizerResults: oc.route({
1479
+ method: "POST",
1480
+ path: "/srs/optimizer-results/acknowledge",
1481
+ summary: "Acknowledge current SRS optimizer results",
1482
+ tags: ["SRS"]
1483
+ }).input(srsAcknowledgeOptimizerResultsInputSchema).output(srsAcknowledgeOptimizerResultsOutputSchema),
1484
+ listCardRevlogs: defineAgentProcedure({
1305
1485
  method: "GET",
1306
- path: "/srs/cards/{cardId}/revlogs",
1307
- summary: "List complete review history for a card",
1486
+ path: "/srs/revlogs",
1487
+ summary: "List review history",
1488
+ description: "Read owned review records, optionally filtered by notebase or card. Supports limit and offset pagination. Note content, card faces and rollback snapshots are excluded.",
1308
1489
  tags: ["SRS"]
1309
- }).input(srsListCardRevlogsInputSchema).output(srsListCardRevlogsOutputSchema),
1310
- review: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_NOT_REVIEWABLE", "CARD_REVIEW_STATE_STALE")).route({
1490
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "NOTEBASE_NOT_FOUND")).input(srsListCardRevlogsInputSchema).output(srsListCardRevlogsOutputSchema),
1491
+ review: defineAgentProcedure({
1311
1492
  method: "POST",
1312
1493
  path: "/srs/review",
1313
- summary: "Review a card with SRS scheduling",
1494
+ summary: "Record review",
1495
+ description: "Submit one rating for a known owned card without a queue, session or prerequisite read. Existing SRS eligibility, scheduling and sibling rules apply. The optional id is the existing state-derived review ID, not an arbitrary UUID; calls without a stable id are not guaranteed to deduplicate.",
1314
1496
  tags: ["SRS"]
1315
- }).input(srsReviewInputSchema).output(srsReviewOutputSchema),
1316
- rollbackReview: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_REVIEW_ROLLBACK_UNAVAILABLE")).route({
1497
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_NOT_REVIEWABLE", "CARD_REVIEW_STATE_STALE")).input(srsReviewInputSchema).output(srsReviewOutputSchema),
1498
+ rollbackReview: defineAgentProcedure({
1317
1499
  method: "POST",
1318
1500
  path: "/srs/review/rollback",
1319
- summary: "Roll back the latest SRS review for a card",
1501
+ summary: "Undo review",
1502
+ description: "Undo the latest eligible review of one owned card, preserving existing SRS restrictions and sibling restoration. expectedReviewId guards against undoing an earlier review on a retry.",
1320
1503
  tags: ["SRS"]
1321
- }).input(srsRollbackReviewInputSchema).output(srsRollbackReviewOutputSchema),
1322
- setCardBuried: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_BURIED", "CARD_NOT_BURIED", "CARD_STATUS_CHANGE_UNAVAILABLE")).route({
1504
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_REVIEW_ROLLBACK_UNAVAILABLE", "CARD_REVIEW_STATE_STALE")).input(srsRollbackReviewInputSchema).output(srsRollbackReviewOutputSchema),
1505
+ setCardBuried: defineAgentProcedure({
1323
1506
  method: "POST",
1324
1507
  path: "/srs/card/bury",
1325
- summary: "Manually bury or unbury a card",
1508
+ summary: "Set card buried",
1509
+ description: "Bury or unbury one owned card. enabled=true buries and enabled=false unburies it. Existing state-change rules apply.",
1326
1510
  tags: ["SRS"]
1327
- }).input(srsSetCardBuriedInputSchema).output(srsSetCardBuriedOutputSchema),
1328
- setCardSuspended: notebaseProcedure.errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_SUSPENDED", "CARD_NOT_SUSPENDED", "CARD_STATUS_CHANGE_UNAVAILABLE")).route({
1511
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_BURIED", "CARD_NOT_BURIED", "CARD_STATUS_CHANGE_UNAVAILABLE")).input(srsSetCardBuriedInputSchema).output(srsSetCardBuriedOutputSchema),
1512
+ setCardSuspended: defineAgentProcedure({
1329
1513
  method: "POST",
1330
1514
  path: "/srs/card/suspend",
1331
- summary: "Manually suspend or unsuspend a card",
1515
+ summary: "Set card suspended",
1516
+ description: "Suspend or resume one owned card. enabled=true suspends and enabled=false resumes it. Existing state-change rules apply.",
1332
1517
  tags: ["SRS"]
1333
- }).input(srsSetCardSuspendedInputSchema).output(srsSetCardSuspendedOutputSchema)
1518
+ }).errors(pickPublicErrorMap("CARD_NOT_FOUND", "CARD_ALREADY_SUSPENDED", "CARD_NOT_SUSPENDED", "CARD_STATUS_CHANGE_UNAVAILABLE")).input(srsSetCardSuspendedInputSchema).output(srsSetCardSuspendedOutputSchema)
1334
1519
  };
1335
1520
  //#endregion
1336
1521
  //#region src/schemas/notebase-stats.ts
@@ -1385,19 +1570,19 @@ const activityStatsOutputSchema = z.object({
1385
1570
  //#endregion
1386
1571
  //#region src/contracts/stats.ts
1387
1572
  const statsContract = {
1388
- activity: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1573
+ activity: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1389
1574
  method: "GET",
1390
1575
  path: "/stats/activity",
1391
1576
  summary: "Get SRS and notebase activity statistics",
1392
1577
  tags: ["Statistics"]
1393
1578
  }).input(statsInputSchema).output(activityStatsOutputSchema),
1394
- srsMemoryGrowth: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1579
+ srsMemoryGrowth: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1395
1580
  method: "GET",
1396
1581
  path: "/srs/stats/memory-growth",
1397
1582
  summary: "Get SRS long-term memory growth statistics",
1398
1583
  tags: ["Statistics"]
1399
1584
  }).input(statsInputSchema).output(srsMemoryGrowthStatsOutputSchema),
1400
- notebaseRowGrowth: notebaseProcedure.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1585
+ notebaseRowGrowth: oc.errors(pickPublicErrorMap("NOTEBASE_NOT_FOUND")).route({
1401
1586
  method: "GET",
1402
1587
  path: "/notebases/stats/row-growth",
1403
1588
  summary: "Get notebase row growth statistics",
@@ -1455,12 +1640,25 @@ const videoTranscriptSubtitlesSchema = z.object({
1455
1640
  detectedLanguage: z.string().nullable(),
1456
1641
  segments: z.array(transcriptSegmentSchema)
1457
1642
  });
1458
- const videoTranscriptCreateInputSchema = z.object({ url: z.url().refine((url) => getVideoIdFromUrl(url) !== null, { message: "url must be a supported video URL" }) }).strict();
1643
+ const videoTranscriptCreateInputSchema = z.object({
1644
+ url: z.url().refine((url) => getVideoIdFromUrl(url) !== null, { message: "url must be a supported video URL" }),
1645
+ durationSec: z.number().int().positive()
1646
+ }).strict();
1459
1647
  const videoTranscriptGetInputSchema = z.object({ id: z.uuid() }).strict();
1648
+ const videoTranscriptUsagePoolSchema = z.object({
1649
+ id: z.string(),
1650
+ usedMinutes: z.number().int(),
1651
+ limitMinutes: z.number().int(),
1652
+ remainingMinutes: z.number().int(),
1653
+ resetAt: z.iso.datetime().nullable(),
1654
+ expiresAt: z.iso.datetime().nullable()
1655
+ });
1460
1656
  const videoTranscriptUsageSchema = z.object({
1461
1657
  usedMinutes: z.number().int(),
1462
1658
  limitMinutes: z.number().int(),
1463
- remainingMinutes: z.number().int()
1659
+ remainingMinutes: z.number().int(),
1660
+ plan: billingPlanSchema,
1661
+ pools: z.array(videoTranscriptUsagePoolSchema)
1464
1662
  });
1465
1663
  //#endregion
1466
1664
  //#region src/index.ts
@@ -1478,7 +1676,7 @@ const contract = {
1478
1676
  stats: statsContract,
1479
1677
  user: userContract,
1480
1678
  videoTranscript: {
1481
- create: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED")).route({
1679
+ create: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED", "VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED", "VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED", "VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH")).route({
1482
1680
  method: "POST",
1483
1681
  path: "/video-transcripts",
1484
1682
  summary: "Create or reuse a video transcription job",
@@ -1490,13 +1688,13 @@ const contract = {
1490
1688
  summary: "Get the caller's monthly transcription quota usage",
1491
1689
  tags: ["Video Transcription"]
1492
1690
  }).output(videoTranscriptUsageSchema),
1493
- get: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPT_NOT_FOUND")).route({
1691
+ get: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPT_NOT_FOUND", "VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED")).route({
1494
1692
  method: "GET",
1495
1693
  path: "/video-transcripts/{id}",
1496
1694
  summary: "Get a video transcription job's status",
1497
1695
  tags: ["Video Transcription"]
1498
1696
  }).input(videoTranscriptGetInputSchema).output(videoTranscriptResourceSchema),
1499
- getSubtitles: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPT_NOT_FOUND", "VIDEO_TRANSCRIPT_NOT_READY")).route({
1697
+ getSubtitles: oc.errors(pickPublicErrorMap("VIDEO_TRANSCRIPT_NOT_FOUND", "VIDEO_TRANSCRIPT_NOT_READY", "VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED")).route({
1500
1698
  method: "GET",
1501
1699
  path: "/video-transcripts/{id}/subtitles",
1502
1700
  summary: "Get a completed video transcript's subtitles",
@@ -1505,6 +1703,6 @@ const contract = {
1505
1703
  }
1506
1704
  };
1507
1705
  //#endregion
1508
- export { BetaAccessStatusInputSchema, BetaAccessStatusOutputSchema, BetaFeatureKeySchema, CardGenerateInputSchema, CardGenerateOutputSchema, CardGetInputSchema, CardGetOutputSchema, CardListInputSchema, CardListOutputSchema, CardTemplateCreateInputSchema, CardTemplateCreateOutputSchema, CardTemplateDeleteInputSchema, CardTemplateDeleteOutputSchema, CardTemplateGetInputSchema, CardTemplateGetOutputSchema, CardTemplateInvalidColumnsDataSchema, CardTemplateListInputSchema, CardTemplateListOutputSchema, CardTemplateUpdateInputSchema, CardTemplateUpdateOutputSchema, CellValidationFailedDataSchema, CellValidationFailureDetailsSchema, CellValidationFailureReasonSchema, HOSTED_AI_CLIENT_STREAM_PART_TYPES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiCreditPeriodKindSchema, HostedAiCreditPolicyIdSchema, HostedAiCreditStatusSchema, HostedAiFeatureSchema, HostedAiFeatureStatusSchema, HostedAiModelTierSchema, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiQuotaExhaustedDataSchema, HostedAiQuotaScopeSchema, HostedAiRateLimitErrorDataSchema, HostedAiRequestIdSchema, HostedAiStatusInputSchema, HostedAiStatusOutputSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, HostedAiTierRestrictedDataSchema, HostedAiTierStatusSchema, HostedAiUnavailableReasonSchema, NOTEBASE_ROW_CREATE_MANY_MAX_ROWS, NotebaseColumnCreateInputSchema, NotebaseColumnCreateOutputSchema, NotebaseColumnDeleteInputSchema, NotebaseColumnDeleteOutputSchema, NotebaseColumnReorderInputSchema, NotebaseColumnReorderOutputSchema, NotebaseColumnUpdateInputSchema, NotebaseColumnUpdateOutputSchema, NotebaseCreateInputSchema, NotebaseCreateOutputSchema, NotebaseDeleteInputSchema, NotebaseDeleteOutputSchema, NotebaseGetInputSchema, NotebaseGetOutputSchema, NotebaseGetSchemaInputSchema, NotebaseGetSchemaOutputSchema, NotebaseListInputSchema, NotebaseListItemSchema, NotebaseListOutputSchema, NotebaseRowCreateInputSchema, NotebaseRowCreateManyInputSchema, NotebaseRowCreateManyOutputSchema, NotebaseRowCreateOutputSchema, NotebaseRowDeleteInputSchema, NotebaseRowDeleteOutputSchema, NotebaseRowReorderInputSchema, NotebaseRowReorderOutputSchema, NotebaseRowUpdateInputSchema, NotebaseRowUpdateOutputSchema, NotebaseUpdateInputSchema, NotebaseUpdateOutputSchema, PUBLIC_APP_ERROR_DEFS, SRS_REVIEW_CLIENT_ID_NAMESPACE, SRS_REVIEW_DURATION_MS_MAX, activityStatsOutputSchema, billingAccessSourceSchema, billingCancelScheduledChangeOutputSchema, billingCheckoutPlanSchema, billingCreateCheckoutSessionInputSchema, billingCreateCustomerPortalSessionInputSchema, billingCurrencySchema, billingIntervalSchema, billingLocaleSchema, billingPlanSchema, billingScheduledChangeSchema, billingSessionUrlOutputSchema, billingStatusSchema, billingSubscriptionStatusSchema, cardSchema, cardStateSchema, cardTemplateSchema, contract, createSrsReviewClientId, ebookCoverContentTypeSchema, ebookDeleteInputSchema, ebookDeleteOutputSchema, ebookDetailSchema, ebookFinalizeUploadInputSchema, ebookFinalizeUploadOutputSchema, ebookGetDownloadUrlInputSchema, ebookGetDownloadUrlOutputSchema, ebookGetInputSchema, ebookGetOutputSchema, ebookListInputSchema, ebookListItemSchema, ebookListOutputSchema, ebookPresignedPostSchema, ebookQuotaSchema, ebookRenameDataSchema, ebookRenameInputSchema, ebookRenameOutputSchema, ebookRequestUploadInputSchema, ebookRequestUploadOutputSchema, ebookStatusSchema, ebookUpdateProgressDataSchema, ebookUpdateProgressInputSchema, ebookUpdateProgressOutputSchema, getPublicErrorDefinition, isPublicAppErrorCode, notebaseActivityStatsItemSchema, notebaseActivityStatsOutputSchema, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowGrowthStatsItemSchema, notebaseRowGrowthStatsOutputSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsActivityStatsItemSchema, srsActivityStatsOutputSchema, srsListCardRevlogsInputSchema, srsListCardRevlogsOutputSchema, srsManualCardStatusInputSchema, srsMemoryGrowthStatsItemSchema, srsMemoryGrowthStatsOutputSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, statsInputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsageSchema };
1706
+ export { BetaAccessStatusInputSchema, BetaAccessStatusOutputSchema, BetaFeatureKeySchema, CardGenerateInputSchema, CardGenerateOutputSchema, CardGetInputSchema, CardGetOutputSchema, CardListInputSchema, CardListOutputSchema, CardTemplateCreateInputSchema, CardTemplateCreateOutputSchema, CardTemplateDeleteInputSchema, CardTemplateDeleteOutputSchema, CardTemplateGetInputSchema, CardTemplateGetOutputSchema, CardTemplateInvalidColumnsDataSchema, CardTemplateListInputSchema, CardTemplateListOutputSchema, CardTemplateUpdateInputSchema, CardTemplateUpdateOutputSchema, CellValidationFailedDataSchema, CellValidationFailureDetailsSchema, CellValidationFailureReasonSchema, HOSTED_AI_CLIENT_STREAM_PART_TYPES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiCreditPeriodKindSchema, HostedAiCreditPolicyIdSchema, HostedAiCreditStatusSchema, HostedAiFeatureSchema, HostedAiFeatureStatusSchema, HostedAiModelTierSchema, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiQuotaExhaustedDataSchema, HostedAiQuotaScopeSchema, HostedAiRateLimitErrorDataSchema, HostedAiRequestIdSchema, HostedAiStatusInputSchema, HostedAiStatusOutputSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, HostedAiTierRestrictedDataSchema, HostedAiTierStatusSchema, HostedAiUnavailableReasonSchema, NOTEBASE_ROW_CREATE_MANY_MAX_ROWS, NotebaseColumnCreateInputSchema, NotebaseColumnCreateOutputSchema, NotebaseColumnDeleteInputSchema, NotebaseColumnDeleteOutputSchema, NotebaseColumnReorderInputSchema, NotebaseColumnReorderOutputSchema, NotebaseColumnUpdateInputSchema, NotebaseColumnUpdateOutputSchema, NotebaseCreateInputSchema, NotebaseCreateOutputSchema, NotebaseDeleteInputSchema, NotebaseDeleteOutputSchema, NotebaseGetInputSchema, NotebaseGetOutputSchema, NotebaseGetSchemaInputSchema, NotebaseGetSchemaOutputSchema, NotebaseGetSummaryInputSchema, NotebaseGetSummaryOutputSchema, NotebaseListInputSchema, NotebaseListItemSchema, NotebaseListOutputSchema, NotebaseRowCreateInputSchema, NotebaseRowCreateManyInputSchema, NotebaseRowCreateManyOutputSchema, NotebaseRowCreateOutputSchema, NotebaseRowDeleteInputSchema, NotebaseRowDeleteOutputSchema, NotebaseRowGetInputSchema, NotebaseRowGetOutputSchema, NotebaseRowListInputSchema, NotebaseRowListOutputSchema, NotebaseRowReorderInputSchema, NotebaseRowReorderOutputSchema, NotebaseRowUpdateInputSchema, NotebaseRowUpdateOutputSchema, NotebaseUpdateInputSchema, NotebaseUpdateOutputSchema, PUBLIC_APP_ERROR_DEFS, SRS_REVIEW_CLIENT_ID_NAMESPACE, SRS_REVIEW_DURATION_MS_MAX, activityStatsOutputSchema, billingAccessSourceSchema, billingCancelScheduledChangeOutputSchema, billingCheckoutPlanSchema, billingCreateCheckoutSessionInputSchema, billingCreateCustomerPortalSessionInputSchema, billingCurrencySchema, billingIntervalSchema, billingLocaleSchema, billingPlanSchema, billingScheduledChangeSchema, billingSessionUrlOutputSchema, billingStatusSchema, billingSubscriptionStatusSchema, cardSchema, cardStateSchema, cardTemplateSchema, contract, createSrsReviewClientId, defineAgentProcedure, deletionResultSchema, ebookCoverContentTypeSchema, ebookDeleteInputSchema, ebookDeleteOutputSchema, ebookDetailSchema, ebookFinalizeUploadInputSchema, ebookFinalizeUploadOutputSchema, ebookGetDownloadUrlInputSchema, ebookGetDownloadUrlOutputSchema, ebookGetInputSchema, ebookGetOutputSchema, ebookListInputSchema, ebookListItemSchema, ebookListOutputSchema, ebookPresignedPostSchema, ebookQuotaSchema, ebookRenameDataSchema, ebookRenameInputSchema, ebookRenameOutputSchema, ebookRequestUploadInputSchema, ebookRequestUploadOutputSchema, ebookStatusSchema, ebookUpdateProgressDataSchema, ebookUpdateProgressInputSchema, ebookUpdateProgressOutputSchema, expectedUpdatedAtSchema, getPublicErrorDefinition, isPublicAppErrorCode, notebaseActivityStatsItemSchema, notebaseActivityStatsOutputSchema, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowGrowthStatsItemSchema, notebaseRowGrowthStatsOutputSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseSummarySchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pageSchema, paginationShape, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsAcknowledgeOptimizerResultsInputSchema, srsAcknowledgeOptimizerResultsOutputSchema, srsActivityStatsItemSchema, srsActivityStatsOutputSchema, srsListCardRevlogsInputSchema, srsListCardRevlogsOutputSchema, srsListUnreadOptimizerResultsInputSchema, srsListUnreadOptimizerResultsOutputSchema, srsManualCardStatusInputSchema, srsMemoryGrowthStatsItemSchema, srsMemoryGrowthStatsOutputSchema, srsOptimizerUnreadResultSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, statsInputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsagePoolSchema, videoTranscriptUsageSchema };
1509
1707
 
1510
1708
  //# sourceMappingURL=index.js.map