Skip to content

Commit 3b1e60c

Browse files
authored
make formatVersion optional (#23)
fixes #22
1 parent a9dcc87 commit 3b1e60c

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- `formatVersion` is now optional on documents and templates
13+
1014
## [8.2.0] - 2025-05-04
1115

1216
### Added

src/raw.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export interface DocumentContent {
340340
*/
341341
fontName: string;
342342
/** the format version, this should always be 1 */
343-
formatVersion: number;
343+
formatVersion?: number;
344344
/** the last opened page, starts at zero */
345345
lastOpenedPage?: number;
346346
/**
@@ -440,7 +440,6 @@ const documentContent = properties(
440440
extraMetadata: values(string()),
441441
fileType: enumeration("epub", "notebook", "pdf"),
442442
fontName: string(),
443-
formatVersion: uint8(),
444443
lineHeight: int32(),
445444
orientation: enumeration("portrait", "landscape"),
446445
pageCount: uint32(),
@@ -457,6 +456,7 @@ const documentContent = properties(
457456
customZoomPageWidth: float64(),
458457
customZoomScale: float64(),
459458
dummyDocument: boolean(),
459+
formatVersion: uint8(),
460460
keyboardMetadata: properties(
461461
{
462462
count: uint32(),
@@ -516,7 +516,7 @@ export interface TemplateContent {
516516
/** semantic version for this template */
517517
templateVersion: string;
518518
/** template configuration format version (currently just `1`) */
519-
formatVersion: number;
519+
formatVersion?: number;
520520
/**
521521
* which screens the template supports:
522522
*
@@ -530,19 +530,23 @@ export interface TemplateContent {
530530
items: object[];
531531
}
532532

533-
const templateContent = properties({
534-
name: string(),
535-
author: string(),
536-
iconData: string(),
537-
categories: elements(string()),
538-
labels: elements(string()),
539-
orientation: enumeration("portrait", "landscape"),
540-
templateVersion: string(),
541-
formatVersion: uint8(),
542-
supportedScreens: elements(enumeration("rm2", "rmPP")),
543-
constants: elements(values(int32())),
544-
items: elements(empty() as CompiledSchema<object, unknown>),
545-
}) satisfies CompiledSchema<TemplateContent, unknown>;
533+
const templateContent = properties(
534+
{
535+
name: string(),
536+
author: string(),
537+
iconData: string(),
538+
categories: elements(string()),
539+
labels: elements(string()),
540+
orientation: enumeration("portrait", "landscape"),
541+
templateVersion: string(),
542+
supportedScreens: elements(enumeration("rm2", "rmPP")),
543+
constants: elements(values(int32())),
544+
items: elements(empty() as CompiledSchema<object, unknown>),
545+
},
546+
{
547+
formatVersion: uint8(),
548+
},
549+
) satisfies CompiledSchema<TemplateContent, unknown>;
546550

547551
/** content metadata for any item */
548552
export type Content = CollectionContent | DocumentContent | TemplateContent;

0 commit comments

Comments
 (0)