@read-frog/api-contract 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { eventIterator, oc } from "@orpc/contract";
2
- import { BETA_FEATURE_KEYS, NOTEBASE_COLUMN_MAX_WIDTH, NOTEBASE_COLUMN_MIN_WIDTH, SRS_REVIEW_DURATION_MS_MAX, activeScheduleStatusSchema, cardIdentityShape, cardMemoryStateShape, cardStateSchema, cardStateSchema as cardStateSchema$1, cardTemplateConfigSchema, fsrsReviewLogSnapshotSchema, getVideoIdFromUrl, notebaseColumnConfigSchema, reviewRatingSchema, scheduleStatusSchema, scheduleStatusSchema as scheduleStatusSchema$1, schedulingParamsSchema, schedulingParamsShape, srsStepSchema, srsWeightsSchema, transcriptSegmentSchema } from "@read-frog/definitions";
2
+ import { BETA_FEATURE_KEYS, EBOOK_ALLOWED_COVER_CONTENT_TYPES, NOTEBASE_COLUMN_MAX_WIDTH, NOTEBASE_COLUMN_MIN_WIDTH, SRS_REVIEW_DURATION_MS_MAX, activeScheduleStatusSchema, cardIdentityShape, cardMemoryStateShape, cardStateSchema, cardStateSchema as cardStateSchema$1, cardTemplateConfigSchema, fsrsReviewLogSnapshotSchema, getVideoIdFromUrl, notebaseColumnConfigSchema, reviewRatingSchema, scheduleStatusSchema, scheduleStatusSchema as scheduleStatusSchema$1, schedulingParamsSchema, schedulingParamsShape, srsStepSchema, srsWeightsSchema, transcriptSegmentSchema } from "@read-frog/definitions";
3
3
  import { z } from "zod";
4
4
  //#region src/schemas/beta-access.ts
5
5
  const BetaFeatureKeySchema = z.enum(BETA_FEATURE_KEYS);
@@ -157,6 +157,26 @@ const PUBLIC_APP_ERROR_DEFS = {
157
157
  CONCURRENT_POSITION_CONFLICT: {
158
158
  message: "Concurrent position conflict, please retry",
159
159
  status: 409
160
+ },
161
+ EBOOK_BETA_RESTRICTED: {
162
+ message: "Ebooks are currently in beta for selected accounts",
163
+ status: 403
164
+ },
165
+ EBOOK_NOT_FOUND: {
166
+ message: "Ebook not found",
167
+ status: 404
168
+ },
169
+ EBOOK_LIMIT_EXCEEDED: {
170
+ message: "Upgrade is required to upload more ebooks",
171
+ status: 403
172
+ },
173
+ EBOOK_FILE_TOO_LARGE: {
174
+ message: "Ebook file exceeds the maximum allowed size",
175
+ status: 413
176
+ },
177
+ EBOOK_UPLOAD_NOT_COMPLETED: {
178
+ message: "Ebook upload has not been completed",
179
+ status: 409
160
180
  }
161
181
  };
162
182
  function isPublicAppErrorCode(code) {
@@ -386,6 +406,129 @@ const cardTemplateContract = {
386
406
  }).input(CardTemplateDeleteInputSchema).output(CardTemplateDeleteOutputSchema)
387
407
  };
388
408
  //#endregion
409
+ //#region src/schemas/ebook.ts
410
+ const ebookStatusSchema = z.enum(["pending", "ready"]);
411
+ const ebookCoverContentTypeSchema = z.enum(EBOOK_ALLOWED_COVER_CONTENT_TYPES);
412
+ const ebookListItemSchema = z.object({
413
+ id: z.uuid(),
414
+ title: z.string(),
415
+ author: z.string().nullable(),
416
+ language: z.string().nullable(),
417
+ fileByteSize: z.number().int(),
418
+ status: ebookStatusSchema,
419
+ progressFraction: z.number(),
420
+ lastReadAt: z.coerce.date().nullable(),
421
+ coverUrl: z.url().nullable(),
422
+ createdAt: z.coerce.date(),
423
+ updatedAt: z.coerce.date()
424
+ }).strict();
425
+ const ebookDetailSchema = ebookListItemSchema.extend({ progressCfi: z.string().nullable() });
426
+ const ebookQuotaSchema = z.object({
427
+ count: z.number().int().min(0),
428
+ limit: z.number().int().min(0)
429
+ }).strict();
430
+ const ebookListInputSchema = z.object({}).strict();
431
+ const ebookListOutputSchema = z.object({
432
+ items: z.array(ebookListItemSchema),
433
+ quota: ebookQuotaSchema
434
+ }).strict();
435
+ const ebookGetInputSchema = z.object({ id: z.uuid() }).strict();
436
+ const ebookGetOutputSchema = z.object({ ebook: ebookDetailSchema }).strict();
437
+ const ebookRequestUploadInputSchema = z.object({
438
+ title: z.string().min(1).max(500),
439
+ author: z.string().max(500).optional(),
440
+ language: z.string().max(35).optional(),
441
+ coverContentType: ebookCoverContentTypeSchema.optional()
442
+ }).strict();
443
+ /**
444
+ * S3 POST form policy. `fields` must be appended to the form in iteration order
445
+ * with the file last; S3 ignores anything sent after the `file` part.
446
+ */
447
+ const ebookPresignedPostSchema = z.object({
448
+ url: z.url(),
449
+ fields: z.record(z.string(), z.string())
450
+ }).strict();
451
+ const ebookRequestUploadOutputSchema = z.object({
452
+ ebookId: z.uuid(),
453
+ upload: ebookPresignedPostSchema,
454
+ coverUpload: ebookPresignedPostSchema.nullable(),
455
+ expiresAt: z.coerce.date()
456
+ }).strict();
457
+ const ebookFinalizeUploadInputSchema = z.object({ ebookId: z.uuid() }).strict();
458
+ const ebookFinalizeUploadOutputSchema = z.object({ ebook: ebookListItemSchema }).strict();
459
+ const ebookGetDownloadUrlInputSchema = z.object({ id: z.uuid() }).strict();
460
+ const ebookGetDownloadUrlOutputSchema = z.object({
461
+ url: z.url(),
462
+ expiresAt: z.coerce.date()
463
+ }).strict();
464
+ const ebookUpdateProgressDataSchema = z.object({
465
+ cfi: z.string().max(2e3),
466
+ fraction: z.number().min(0).max(1)
467
+ }).strict();
468
+ const ebookUpdateProgressInputSchema = ebookUpdateProgressDataSchema.extend({ id: z.uuid() });
469
+ const ebookUpdateProgressOutputSchema = z.object({ lastReadAt: z.coerce.date() }).strict();
470
+ const ebookRenameDataSchema = z.object({
471
+ title: z.string().min(1).max(500),
472
+ author: z.string().max(500).nullable().optional()
473
+ }).strict();
474
+ const ebookRenameInputSchema = ebookRenameDataSchema.extend({ id: z.uuid() });
475
+ const ebookRenameOutputSchema = z.object({ ebook: ebookListItemSchema }).strict();
476
+ const ebookDeleteInputSchema = z.object({ id: z.uuid() }).strict();
477
+ const ebookDeleteOutputSchema = z.object({ id: z.uuid() }).strict();
478
+ //#endregion
479
+ //#region src/contracts/ebook.ts
480
+ const ebookProcedure = oc;
481
+ const ebookContract = {
482
+ list: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED")).route({
483
+ method: "GET",
484
+ path: "/ebooks",
485
+ summary: "List ebooks with quota",
486
+ tags: ["Ebooks"]
487
+ }).input(ebookListInputSchema).output(ebookListOutputSchema),
488
+ get: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND")).route({
489
+ method: "GET",
490
+ path: "/ebooks/{id}",
491
+ summary: "Get an ebook with reading progress",
492
+ tags: ["Ebooks"]
493
+ }).input(ebookGetInputSchema).output(ebookGetOutputSchema),
494
+ requestUpload: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_LIMIT_EXCEEDED")).route({
495
+ method: "POST",
496
+ path: "/ebooks/uploads",
497
+ summary: "Request presigned upload URLs for a new ebook",
498
+ tags: ["Ebooks"]
499
+ }).input(ebookRequestUploadInputSchema).output(ebookRequestUploadOutputSchema),
500
+ finalizeUpload: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND", "EBOOK_UPLOAD_NOT_COMPLETED", "EBOOK_FILE_TOO_LARGE")).route({
501
+ method: "POST",
502
+ path: "/ebooks/{ebookId}/finalize",
503
+ summary: "Finalize an ebook upload",
504
+ tags: ["Ebooks"]
505
+ }).input(ebookFinalizeUploadInputSchema).output(ebookFinalizeUploadOutputSchema),
506
+ getDownloadUrl: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND")).route({
507
+ method: "GET",
508
+ path: "/ebooks/{id}/download-url",
509
+ summary: "Get a presigned download URL for an ebook",
510
+ tags: ["Ebooks"]
511
+ }).input(ebookGetDownloadUrlInputSchema).output(ebookGetDownloadUrlOutputSchema),
512
+ updateProgress: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND")).route({
513
+ method: "PATCH",
514
+ path: "/ebooks/{id}/progress",
515
+ summary: "Update ebook reading progress",
516
+ tags: ["Ebooks"]
517
+ }).input(ebookUpdateProgressInputSchema).output(ebookUpdateProgressOutputSchema),
518
+ rename: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND")).route({
519
+ method: "PATCH",
520
+ path: "/ebooks/{id}",
521
+ summary: "Rename an ebook",
522
+ tags: ["Ebooks"]
523
+ }).input(ebookRenameInputSchema).output(ebookRenameOutputSchema),
524
+ delete: ebookProcedure.errors(pickPublicErrorMap("EBOOK_BETA_RESTRICTED", "EBOOK_NOT_FOUND")).route({
525
+ method: "DELETE",
526
+ path: "/ebooks/{id}",
527
+ summary: "Delete an ebook",
528
+ tags: ["Ebooks"]
529
+ }).input(ebookDeleteInputSchema).output(ebookDeleteOutputSchema)
530
+ };
531
+ //#endregion
389
532
  //#region src/schemas/hosted-ai.ts
390
533
  const HOSTED_AI_SYSTEM_FALLBACK_REMOVAL_DATE = "2026-07-11";
391
534
  const HostedAiOutputFieldTypeSchema = z.enum(["string", "number"]);
@@ -1045,6 +1188,7 @@ const contract = {
1045
1188
  billing: billingContract,
1046
1189
  card: cardContract,
1047
1190
  cardTemplate: cardTemplateContract,
1191
+ ebook: ebookContract,
1048
1192
  hostedAi: hostedAiContract,
1049
1193
  notebase: notebaseContract,
1050
1194
  notebaseColumn: notebaseColumnContract,
@@ -1079,6 +1223,6 @@ const contract = {
1079
1223
  }
1080
1224
  };
1081
1225
  //#endregion
1082
- 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_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, 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, billingAccessSourceSchema, billingCancelScheduledChangeOutputSchema, billingCheckoutPlanSchema, billingCreateCheckoutSessionInputSchema, billingCreateCustomerPortalSessionInputSchema, billingCurrencySchema, billingIntervalSchema, billingLocaleSchema, billingPlanSchema, billingScheduledChangeSchema, billingSessionUrlOutputSchema, billingStatusSchema, billingSubscriptionStatusSchema, cardSchema, cardStateSchema, cardTemplateSchema, contract, createSrsReviewClientId, getPublicErrorDefinition, isPublicAppErrorCode, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsManualCardStatusInputSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsageSchema };
1226
+ 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_NOTE_SUGGESTION_MAX_NOTES, HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS, HostedAiNoteSuggestionObjectSchema, HostedAiNoteSuggestionStreamInputSchema, HostedAiOutputFieldSchema, HostedAiOutputFieldTypeSchema, HostedAiStreamPartSchema, HostedAiStreamStructuredObjectInputSchema, HostedAiStreamTextInputSchema, 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, 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, notebaseColumnCreateDataSchema, notebaseColumnSchema, notebaseColumnUpdateDataSchema, notebaseColumnWidthSchema, notebaseCreateDataSchema, notebaseRowCellsSchema, notebaseRowCreateDataSchema, notebaseRowSchema, notebaseRowUpdateDataSchema, notebaseSchema, notebaseUpdateDataSchema, notebaseViewConfigSchema, notebaseViewCreateDataSchema, notebaseViewFilterSchema, notebaseViewFiltersSchema, notebaseViewSchema, notebaseViewSortSchema, notebaseViewSortsSchema, notebaseViewTypeSchema, notebaseViewUpdateDataSchema, pickPublicErrorMap, renderedCardSchema, reviewRatingSchema, scheduleStatusSchema, schedulingParamsSchema, srsManualCardStatusInputSchema, srsReviewInputSchema, srsReviewOutputSchema, srsRevlogSchema, srsRevlogWithoutSnapshotSchema, srsRollbackReviewInputSchema, srsRollbackReviewOutputSchema, srsScheduleStatusStatsInputSchema, srsScheduleStatusStatsOutputSchema, srsScheduleStatusStatsSchema, srsSetCardBuriedInputSchema, srsSetCardBuriedOutputSchema, srsSetCardSuspendedInputSchema, srsSetCardSuspendedOutputSchema, srsTxidOutputSchema, stepSchema, timezoneSchema, userEnsureTimezoneInputSchema, userEnsureTimezoneOutputSchema, userUpdateTimezoneInputSchema, userUpdateTimezoneOutputSchema, videoTranscriptCreateInputSchema, videoTranscriptGetInputSchema, videoTranscriptResourceSchema, videoTranscriptStatusSchema, videoTranscriptSubtitlesSchema, videoTranscriptUsageSchema };
1083
1227
 
1084
1228
  //# sourceMappingURL=index.js.map