diff --git a/CHANGELOG.md b/CHANGELOG.md index 616959a..def92d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.6.0] - 2024-04-27 + ### Added - field abbreviations to paragraph blocks that maps abbreviations to their HTML definitions @@ -152,6 +154,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release [Unreleased]: https://github.com/ortfo/db/compare/v1.5.0...HEAD +[1.6.0]: https://github.com/ortfo/db/-/releases/tag/v1.6.0 [1.5.0]: https://github.com/ortfo/db/compare/v1.4.1...v1.5.0 [1.4.1]: https://github.com/ortfo/db/compare/v1.4.0...v1.4.1 [1.4.0]: https://github.com/ortfo/db/compare/v1.3.0...v1.4.0 @@ -165,3 +168,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [0.2.0]: https://github.com/ortfo/db/releases/tag/v0.2.0 [//]: # (C3-2-DKAC:GGH:Rortfo/db:Tv{t}) + +[unreleased]: https://github.com/ortfo/db/-/compare/v1.6.0...main diff --git a/README.md b/README.md index eec294a..373609d 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Available Commands: completion Generate the autocompletion script for the specified shell exporters Commands related to ortfo/db exporters help Help about any command + lsp Start a Language Server Protocol server for ortfo replicate Replicate a database directory from a built database file. schemas Output JSON schemas for ortfodb's various resources diff --git a/docs/changelog.md b/docs/changelog.md index 3670c35..616959a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - errors when encountering duplicate block IDs, empty blocks and other edge cases in descriptions - support for `null` values in layouts. this gets rendered as a special layout cell "ghost" (see `ortfodb.EmptyLayoutCell` for the value). This is useful to add empty spaces in a grid of images, for example - lsp subcommand for LSP support +- Database.FindWork to facilitate alias resolution when finding works in a database ### Changed diff --git a/docs/commands/exporters-doc.md b/docs/commands/exporters-doc.md index 6054094..a638d5b 100644 --- a/docs/commands/exporters-doc.md +++ b/docs/commands/exporters-doc.md @@ -15,9 +15,7 @@ ortfodb exporters doc [flags] ```ansi $ ortfodb exporters help localize -localize  Export separately the database as a single database for each language. The -`content` field of each work is localized, meaning it's not an object mapping -languages to localized content, but the content directly, in the language. +localize  Export separately the database as a single database for each language. The `content` field of each work is localized, meaning it's not an object mapping languages to localized content, but the content directly, in the language.  Options:  • filename_template  diff --git a/docs/commands/global-options.md b/docs/commands/global-options.md index 6187928..d0f3287 100644 --- a/docs/commands/global-options.md +++ b/docs/commands/global-options.md @@ -30,6 +30,7 @@ Manage your portfolio's database — See https://github.com/ortfo/db for more in * [ortfodb add](add.md) - Add a new project to your portfolio * [ortfodb build](build.md) - Build the database * [ortfodb exporters](exporters.md) - Commands related to ortfo/db exporters +* [ortfodb lsp](lsp.md) - Start a Language Server Protocol server for ortfo * [ortfodb replicate](replicate.md) - Replicate a database directory from a built database file. * [ortfodb schemas](schemas.md) - Output JSON schemas for ortfodb's various resources diff --git a/docs/commands/lsp.md b/docs/commands/lsp.md new file mode 100644 index 0000000..0d83168 --- /dev/null +++ b/docs/commands/lsp.md @@ -0,0 +1,30 @@ +--- +editLink: false +--- + +# ortfodb lsp + +Start a Language Server Protocol server for ortfo + +``` +ortfodb lsp [flags] +``` + +## Options + +| Shorthand | Flag | Argument | Description | Default value | +| --- | --- | --- | --- | --- | +| -h | ‐‐help | | help for lsp +| | ‐‐stdio | | Used for compatibility with VSCode. Ignored (the server is always started in stdio mode) + +## Options inherited from parent commands + +| Shorthand | Flag | Argument | Description | Default value | +| --- | --- | --- | --- | --- | +| -c | ‐‐config | string | config file path | ortfodb.yaml +| | ‐‐scattered | | Operate in scattered mode. In scattered mode, the description.md files are searched inside `.ortfo' folders in every folder of the database directory, instead of directly in the database directory's folders. See https://github.com/ortfo/ + +## See also + +* [ortfodb](global-options.md) - Manage your portfolio's database + diff --git a/go.mod b/go.mod index 83e43d3..fc20e46 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,6 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect - github.com/bluele/gcache v0.0.2 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/catppuccin/go v0.2.0 // indirect github.com/charmbracelet/bubbles v0.18.0 // indirect @@ -67,7 +66,6 @@ require ( github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/lithdew/quickjs v0.0.0-20200714182134-aaa42285c9d2 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-localereader v0.0.1 // indirect @@ -104,7 +102,6 @@ require ( require ( github.com/FurqanSoftware/goldmark-d2 v0.0.0-20240222042550-23ef2a4e585c - github.com/FurqanSoftware/goldmark-katex v0.0.0-20230820031700-1c400212c1e1 github.com/MakeNowJust/heredoc v1.0.0 github.com/Masterminds/sprig/v3 v3.2.3 github.com/PuerkitoBio/goquery v1.9.1 // indirect diff --git a/go.sum b/go.sum index 169042a..bdacfbd 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,6 @@ github.com/EdlinOrg/prominentcolor v1.0.0 h1:sQNY8Dtsv3PK3J1LbmrDmtlZm9Y9U8Loi1i github.com/EdlinOrg/prominentcolor v1.0.0/go.mod h1:mYmDsxfcmBz6izH/SqtSzfsUiZdPNPpPgUPKCZq70KQ= github.com/FurqanSoftware/goldmark-d2 v0.0.0-20240222042550-23ef2a4e585c h1:lkvzSLfTKUAk/tc2RLD4Ibgk3xVMxUwp9VkOVyO/+vA= github.com/FurqanSoftware/goldmark-d2 v0.0.0-20240222042550-23ef2a4e585c/go.mod h1:oT5hllDAs21uHEC9PKpf80k5WDraw2omGwa4pNYXb2g= -github.com/FurqanSoftware/goldmark-katex v0.0.0-20230820031700-1c400212c1e1 h1:zm4WOvvzOeEiA47eE74RTNTi/FC5Cpw6R4fk/4hxdpc= -github.com/FurqanSoftware/goldmark-katex v0.0.0-20230820031700-1c400212c1e1/go.mod h1:Z4lsscLMP+DMuc7k7AU0TsFRA2xQWTGhOp9zELvG1lQ= github.com/JohannesKaufmann/html-to-markdown v1.5.0 h1:cEAcqpxk0hUJOXEVGrgILGW76d1GpyGY7PCnAaWQyAI= github.com/JohannesKaufmann/html-to-markdown v1.5.0/go.mod h1:QTO/aTyEDukulzu269jY0xiHeAGsNxmuUBo2Q0hPsK8= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= @@ -48,8 +46,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= -github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw= -github.com/bluele/gcache v0.0.2/go.mod h1:m15KV+ECjptwSPxKhOhQoAFQVtUFjTVkc3H8o0t/fp0= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= @@ -189,8 +185,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lafriks/go-svg v0.4.0 h1:XgciXbad7H0js3c0Uk47dmGFJ9pCRlG7vP+mlqDEq6w= github.com/lafriks/go-svg v0.4.0/go.mod h1:7Qj5mwY/s5NcPAZwbjyB/V8Hlet3ZYznx3ltPac2K+s= -github.com/lithdew/quickjs v0.0.0-20200714182134-aaa42285c9d2 h1:9o8F2Jlv6jetf9FKdseYhgv036iyW87vi9DoFd2O76s= -github.com/lithdew/quickjs v0.0.0-20200714182134-aaa42285c9d2/go.mod h1:zkXUczDT56GViklqUXAzmvSKkGTxV2jrG/NOWqHAbT8= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= diff --git a/manpages/ortfodb-add.1 b/manpages/ortfodb-add.1 index 7e33b2b..70a8b0b 100644 --- a/manpages/ortfodb-add.1 +++ b/manpages/ortfodb-add.1 @@ -43,4 +43,4 @@ Create a new project in the appropriate folder. ID is the work's slug. .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-build.1 b/manpages/ortfodb-build.1 index c031abe..d9109b6 100644 --- a/manpages/ortfodb-build.1 +++ b/manpages/ortfodb-build.1 @@ -69,4 +69,4 @@ If include-works is provided, only works that match the pattern will be included .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-exporters-doc.1 b/manpages/ortfodb-exporters-doc.1 index 00bc1a0..f1a5c69 100644 --- a/manpages/ortfodb-exporters-doc.1 +++ b/manpages/ortfodb-exporters-doc.1 @@ -36,9 +36,7 @@ Get help for a specific exporter .EX $ ortfodb exporters help localize -localize  Export separately the database as a single database for each language. The - `content` field of each work is localized, meaning it's not an object mapping - languages to localized content, but the content directly, in the language. +localize  Export separately the database as a single database for each language. The `content` field of each work is localized, meaning it's not an object mapping languages to localized content, but the content directly, in the language.  Options:  • filename_template  @@ -62,4 +60,4 @@ Feel free to change these configuration values. Check out the exporter's documen .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-exporters-init.1 b/manpages/ortfodb-exporters-init.1 index a0be251..5615da5 100644 --- a/manpages/ortfodb-exporters-init.1 +++ b/manpages/ortfodb-exporters-init.1 @@ -39,4 +39,4 @@ Create a new exporter .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-exporters-list.1 b/manpages/ortfodb-exporters-list.1 index 506ce5e..fa66355 100644 --- a/manpages/ortfodb-exporters-list.1 +++ b/manpages/ortfodb-exporters-list.1 @@ -39,4 +39,4 @@ List all available exporters .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-exporters.1 b/manpages/ortfodb-exporters.1 index 9207482..2956f4f 100644 --- a/manpages/ortfodb-exporters.1 +++ b/manpages/ortfodb-exporters.1 @@ -39,4 +39,4 @@ Commands related to ortfo/db exporters .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-lsp.1 b/manpages/ortfodb-lsp.1 new file mode 100644 index 0000000..2a763e7 --- /dev/null +++ b/manpages/ortfodb-lsp.1 @@ -0,0 +1,46 @@ +.nh +.TH "ORTFODB" "1" "Apr 2024" "https://ortfo.org/db" "ortfo/db Manual" + +.SH NAME +.PP +ortfodb-lsp - Start a Language Server Protocol server for ortfo + + +.SH SYNOPSIS +.PP +\fBortfodb lsp [flags]\fP + + +.SH DESCRIPTION +.PP +Start a Language Server Protocol server for ortfo + + +.SH OPTIONS +.PP +\fB-h\fP, \fB--help\fP[=false] + help for lsp + +.PP +\fB--stdio\fP[=false] + Used for compatibility with VSCode. Ignored (the server is always started in stdio mode) + + +.SH OPTIONS INHERITED FROM PARENT COMMANDS +.PP +\fB-c\fP, \fB--config\fP="ortfodb.yaml" + config file path + +.PP +\fB--scattered\fP[=false] + Operate in scattered mode. In scattered mode, the description.md files are searched inside `.ortfo' folders in every folder of the database directory, instead of directly in the database directory's folders. See https://github.com/ortfo/ + + +.SH SEE ALSO +.PP +\fBortfodb(1)\fP + + +.SH HISTORY +.PP +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-replicate.1 b/manpages/ortfodb-replicate.1 index 4e6a3e4..ccb1115 100644 --- a/manpages/ortfodb-replicate.1 +++ b/manpages/ortfodb-replicate.1 @@ -53,4 +53,4 @@ Example: ortfodb replicate ./database.json ./replicated-database/ .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb-schemas.1 b/manpages/ortfodb-schemas.1 index 896a09a..f55840a 100644 --- a/manpages/ortfodb-schemas.1 +++ b/manpages/ortfodb-schemas.1 @@ -47,4 +47,4 @@ Output the JSON schema for: .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/manpages/ortfodb.1 b/manpages/ortfodb.1 index 3af2e9d..53c4a2f 100644 --- a/manpages/ortfodb.1 +++ b/manpages/ortfodb.1 @@ -40,9 +40,9 @@ Manage your portfolio's database — See https://github.com/ortfo/db for more in .SH SEE ALSO .PP -\fBortfodb-add(1)\fP, \fBortfodb-build(1)\fP, \fBortfodb-exporters(1)\fP, \fBortfodb-replicate(1)\fP, \fBortfodb-schemas(1)\fP +\fBortfodb-add(1)\fP, \fBortfodb-build(1)\fP, \fBortfodb-exporters(1)\fP, \fBortfodb-lsp(1)\fP, \fBortfodb-replicate(1)\fP, \fBortfodb-schemas(1)\fP .SH HISTORY .PP -22-Apr-2024 Auto generated by spf13/cobra +27-Apr-2024 Auto generated by spf13/cobra diff --git a/packages/crystal/src/configuration.cr b/packages/crystal/src/configuration.cr index b9a255f..1f2ceeb 100644 --- a/packages/crystal/src/configuration.cr +++ b/packages/crystal/src/configuration.cr @@ -6,9 +6,6 @@ module Ortfodb class Configuration include JSON::Serializable - @[JSON::Field(key: "build metadata file")] - property build_metadata_file : String? - # Exporter-specific configuration. Maps exporter names to their configuration. property exporters : Hash(String, Hash(String, JSON::Any?))? diff --git a/packages/crystal/src/database.cr b/packages/crystal/src/database.cr index f45b880..64c6e34 100644 --- a/packages/crystal/src/database.cr +++ b/packages/crystal/src/database.cr @@ -2,10 +2,10 @@ require "json" module Ortfodb -alias Database = Hash(String, AnalyzedWork) +alias Database = Hash(String, Work) -# AnalyzedWork represents a complete work, with analyzed mediae. -class AnalyzedWork +# Work represents a given work in the database. +class Work include JSON::Serializable @[JSON::Field(key: "builtAt")] @@ -27,6 +27,8 @@ end class LocalizedContent include JSON::Serializable + property abbreviations : Hash(String, String) + property blocks : Array(ContentBlock) property footnotes : Hash(String, String) @@ -66,6 +68,11 @@ class ContentBlock # in seconds property duration : Float64 + # Hash of the media file, used for caching purposes. Could also serve as an integrity + # check. + # The value is the MD5 hash, base64-encoded. + property hash : String + @[JSON::Field(key: "hasSound")] property has_sound : Bool diff --git a/packages/php/src/Configuration.php b/packages/php/src/Configuration.php index c725e07..3250fd2 100644 --- a/packages/php/src/Configuration.php +++ b/packages/php/src/Configuration.php @@ -5,7 +5,6 @@ // This is a autogenerated file:Configuration class Configuration { - private ?string $buildMetadataFile; // json:build metadata file Optional private ?stdClass $exporters; // json:exporters Optional private ?ExtractColorsConfiguration $extractColors; // json:extract colors Optional private ?MakeGIFSConfiguration $makeGifs; // json:make gifs Optional @@ -17,7 +16,6 @@ class Configuration { private ?TechnologiesConfiguration $technologies; // json:technologies Optional /** - * @param string|null $buildMetadataFile * @param stdClass|null $exporters * @param ExtractColorsConfiguration|null $extractColors * @param MakeGIFSConfiguration|null $makeGifs @@ -28,8 +26,7 @@ class Configuration { * @param TagsConfiguration|null $tags * @param TechnologiesConfiguration|null $technologies */ - public function __construct(?string $buildMetadataFile, ?stdClass $exporters, ?ExtractColorsConfiguration $extractColors, ?MakeGIFSConfiguration $makeGifs, ?MakeThumbnailsConfiguration $makeThumbnails, ?MediaConfiguration $media, string $projectsAt, string $scatteredModeFolder, ?TagsConfiguration $tags, ?TechnologiesConfiguration $technologies) { - $this->buildMetadataFile = $buildMetadataFile; + public function __construct(?stdClass $exporters, ?ExtractColorsConfiguration $extractColors, ?MakeGIFSConfiguration $makeGifs, ?MakeThumbnailsConfiguration $makeThumbnails, ?MediaConfiguration $media, string $projectsAt, string $scatteredModeFolder, ?TagsConfiguration $tags, ?TechnologiesConfiguration $technologies) { $this->exporters = $exporters; $this->extractColors = $extractColors; $this->makeGifs = $makeGifs; @@ -41,66 +38,6 @@ public function __construct(?string $buildMetadataFile, ?stdClass $exporters, ?E $this->technologies = $technologies; } - /** - * @param ?string $value - * @throws Exception - * @return ?string - */ - public static function fromBuildMetadataFile(?string $value): ?string { - if (!is_null($value)) { - return $value; /*string*/ - } else { - return null; - } - } - - /** - * @throws Exception - * @return ?string - */ - public function toBuildMetadataFile(): ?string { - if (Configuration::validateBuildMetadataFile($this->buildMetadataFile)) { - if (!is_null($this->buildMetadataFile)) { - return $this->buildMetadataFile; /*string*/ - } else { - return null; - } - } - throw new Exception('never get to this Configuration::buildMetadataFile'); - } - - /** - * @param string|null - * @return bool - * @throws Exception - */ - public static function validateBuildMetadataFile(?string $value): bool { - if (!is_null($value)) { - if (!is_string($value)) { - throw new Exception("Attribute Error:Configuration::buildMetadataFile"); - } - } - return true; - } - - /** - * @throws Exception - * @return ?string - */ - public function getBuildMetadataFile(): ?string { - if (Configuration::validateBuildMetadataFile($this->buildMetadataFile)) { - return $this->buildMetadataFile; - } - throw new Exception('never get to getBuildMetadataFile Configuration::buildMetadataFile'); - } - - /** - * @return ?string - */ - public static function sampleBuildMetadataFile(): ?string { - return 'Configuration::buildMetadataFile::31'; /*31:buildMetadataFile*/ - } - /** * Exporter-specific configuration. Maps exporter names to their configuration. * @@ -204,7 +141,7 @@ function sample(): stdClass { $out = new stdClass(); function sample(): stdClass { $out = new stdClass(); - $out->{'Configuration'} = 'AnyType::Configuration::exporters::32';/*32:exporters*/ + $out->{'Configuration'} = 'AnyType::Configuration::exporters::31';/*31:exporters*/ return $out; } return sample(); @@ -268,7 +205,7 @@ public function getExtractColors(): ?ExtractColorsConfiguration { * @return ?ExtractColorsConfiguration */ public static function sampleExtractColors(): ?ExtractColorsConfiguration { - return ExtractColorsConfiguration::sample(); /*33:extractColors*/ + return ExtractColorsConfiguration::sample(); /*32:extractColors*/ } /** @@ -326,7 +263,7 @@ public function getMakeGifs(): ?MakeGIFSConfiguration { * @return ?MakeGIFSConfiguration */ public static function sampleMakeGifs(): ?MakeGIFSConfiguration { - return MakeGIFSConfiguration::sample(); /*34:makeGifs*/ + return MakeGIFSConfiguration::sample(); /*33:makeGifs*/ } /** @@ -384,7 +321,7 @@ public function getMakeThumbnails(): ?MakeThumbnailsConfiguration { * @return ?MakeThumbnailsConfiguration */ public static function sampleMakeThumbnails(): ?MakeThumbnailsConfiguration { - return MakeThumbnailsConfiguration::sample(); /*35:makeThumbnails*/ + return MakeThumbnailsConfiguration::sample(); /*34:makeThumbnails*/ } /** @@ -442,7 +379,7 @@ public function getMedia(): ?MediaConfiguration { * @return ?MediaConfiguration */ public static function sampleMedia(): ?MediaConfiguration { - return MediaConfiguration::sample(); /*36:media*/ + return MediaConfiguration::sample(); /*35:media*/ } /** @@ -502,7 +439,7 @@ public function getProjectsAt(): string { * @return string */ public static function sampleProjectsAt(): string { - return 'Configuration::projectsAt::37'; /*37:projectsAt*/ + return 'Configuration::projectsAt::36'; /*36:projectsAt*/ } /** @@ -552,7 +489,7 @@ public function getScatteredModeFolder(): string { * @return string */ public static function sampleScatteredModeFolder(): string { - return 'Configuration::scatteredModeFolder::38'; /*38:scatteredModeFolder*/ + return 'Configuration::scatteredModeFolder::37'; /*37:scatteredModeFolder*/ } /** @@ -610,7 +547,7 @@ public function getTags(): ?TagsConfiguration { * @return ?TagsConfiguration */ public static function sampleTags(): ?TagsConfiguration { - return TagsConfiguration::sample(); /*39:tags*/ + return TagsConfiguration::sample(); /*38:tags*/ } /** @@ -668,7 +605,7 @@ public function getTechnologies(): ?TechnologiesConfiguration { * @return ?TechnologiesConfiguration */ public static function sampleTechnologies(): ?TechnologiesConfiguration { - return TechnologiesConfiguration::sample(); /*40:technologies*/ + return TechnologiesConfiguration::sample(); /*39:technologies*/ } /** @@ -676,8 +613,7 @@ public static function sampleTechnologies(): ?TechnologiesConfiguration { * @return bool */ public function validate(): bool { - return Configuration::validateBuildMetadataFile($this->buildMetadataFile) - || Configuration::validateExporters($this->exporters) + return Configuration::validateExporters($this->exporters) || Configuration::validateExtractColors($this->extractColors) || Configuration::validateMakeGifs($this->makeGifs) || Configuration::validateMakeThumbnails($this->makeThumbnails) @@ -694,7 +630,6 @@ public function validate(): bool { */ public function to(): stdClass { $out = new stdClass(); - $out->{'build metadata file'} = $this->toBuildMetadataFile(); $out->{'exporters'} = $this->toExporters(); $out->{'extract colors'} = $this->toExtractColors(); $out->{'make gifs'} = $this->toMakeGifs(); @@ -714,8 +649,7 @@ public function to(): stdClass { */ public static function from(stdClass $obj): Configuration { return new Configuration( - Configuration::fromBuildMetadataFile($obj->{'build metadata file'}) - ,Configuration::fromExporters($obj->{'exporters'}) + Configuration::fromExporters($obj->{'exporters'}) ,Configuration::fromExtractColors($obj->{'extract colors'}) ,Configuration::fromMakeGifs($obj->{'make gifs'}) ,Configuration::fromMakeThumbnails($obj->{'make thumbnails'}) @@ -732,8 +666,7 @@ public static function from(stdClass $obj): Configuration { */ public static function sample(): Configuration { return new Configuration( - Configuration::sampleBuildMetadataFile() - ,Configuration::sampleExporters() + Configuration::sampleExporters() ,Configuration::sampleExtractColors() ,Configuration::sampleMakeGifs() ,Configuration::sampleMakeThumbnails() diff --git a/packages/php/src/Database.php b/packages/php/src/Database.php index 139aaa3..869fd81 100644 --- a/packages/php/src/Database.php +++ b/packages/php/src/Database.php @@ -5,7 +5,7 @@ // This is a autogenerated file:Database class Database { - private string $builtAt; // json:builtAt Required + private DateTime $builtAt; // json:builtAt Required private stdClass $content; // json:content Required private string $descriptionHash; // json:descriptionHash Required private string $id; // json:id Required @@ -13,14 +13,14 @@ class Database { private bool $partial; // json:Partial Required /** - * @param string $builtAt + * @param DateTime $builtAt * @param stdClass $content * @param string $descriptionHash * @param string $id * @param WorkMetadata $metadata * @param bool $partial */ - public function __construct(string $builtAt, stdClass $content, string $descriptionHash, string $id, WorkMetadata $metadata, bool $partial) { + public function __construct(DateTime $builtAt, stdClass $content, string $descriptionHash, string $id, WorkMetadata $metadata, bool $partial) { $this->builtAt = $builtAt; $this->content = $content; $this->descriptionHash = $descriptionHash; @@ -32,10 +32,14 @@ public function __construct(string $builtAt, stdClass $content, string $descript /** * @param string $value * @throws Exception - * @return string + * @return DateTime */ - public static function fromBuiltAt(string $value): string { - return $value; /*string*/ + public static function fromBuiltAt(string $value): DateTime { + $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value); + if (!is_a($tmp, 'DateTime')) { + throw new Exception('Attribute Error:Database::'); + } + return $tmp; } /** @@ -44,28 +48,28 @@ public static function fromBuiltAt(string $value): string { */ public function toBuiltAt(): string { if (Database::validateBuiltAt($this->builtAt)) { - return $this->builtAt; /*string*/ + return $this->builtAt->format(DateTimeInterface::ISO8601); } throw new Exception('never get to this Database::builtAt'); } /** - * @param string + * @param DateTime * @return bool * @throws Exception */ - public static function validateBuiltAt(string $value): bool { - if (!is_string($value)) { - throw new Exception("Attribute Error:Database::builtAt"); + public static function validateBuiltAt(DateTime $value): bool { + if (!is_a($value, 'DateTime')) { + throw new Exception('Attribute Error:Database::builtAt'); } return true; } /** * @throws Exception - * @return string + * @return DateTime */ - public function getBuiltAt(): string { + public function getBuiltAt(): DateTime { if (Database::validateBuiltAt($this->builtAt)) { return $this->builtAt; } @@ -73,10 +77,10 @@ public function getBuiltAt(): string { } /** - * @return string + * @return DateTime */ - public static function sampleBuiltAt(): string { - return 'Database::builtAt::31'; /*31:builtAt*/ + public static function sampleBuiltAt(): DateTime { + return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-10T12:10:10+00:00'); } /** @@ -408,24 +412,98 @@ public static function sample(): Database { // This is a autogenerated file:LocalizedContent class LocalizedContent { + private stdClass $abbreviations; // json:abbreviations Required private array $blocks; // json:blocks Required private stdClass $footnotes; // json:footnotes Required private array $layout; // json:layout Required private string $title; // json:title Required /** + * @param stdClass $abbreviations * @param array $blocks * @param stdClass $footnotes * @param array $layout * @param string $title */ - public function __construct(array $blocks, stdClass $footnotes, array $layout, string $title) { + public function __construct(stdClass $abbreviations, array $blocks, stdClass $footnotes, array $layout, string $title) { + $this->abbreviations = $abbreviations; $this->blocks = $blocks; $this->footnotes = $footnotes; $this->layout = $layout; $this->title = $title; } + /** + * @param stdClass $value + * @throws Exception + * @return stdClass + */ + public static function fromAbbreviations(stdClass $value): stdClass { + function from($my): stdClass { + $out = new stdClass(); + foreach ($my as $k => $v) { + $out->$k = $v; /*string*/ + } + return $out; + } + return from($value); + } + + /** + * @throws Exception + * @return stdClass + */ + public function toAbbreviations(): stdClass { + if (LocalizedContent::validateAbbreviations($this->abbreviations)) { + function to($my): stdClass { + $out = new stdClass(); + foreach ($my as $k => $v) { + $my->$k = $v; /*string*/ + } + return $out; + } + return to($this->abbreviations); + } + throw new Exception('never get to this LocalizedContent::abbreviations'); + } + + /** + * @param stdClass + * @return bool + * @throws Exception + */ + public static function validateAbbreviations(stdClass $value): bool { + foreach ($value as $k => $v) { + if (!is_string($v)) { + throw new Exception("Attribute Error:LocalizedContent::abbreviations"); + } + } + return true; + } + + /** + * @throws Exception + * @return stdClass + */ + public function getAbbreviations(): stdClass { + if (LocalizedContent::validateAbbreviations($this->abbreviations)) { + return $this->abbreviations; + } + throw new Exception('never get to getAbbreviations LocalizedContent::abbreviations'); + } + + /** + * @return stdClass + */ + public static function sampleAbbreviations(): stdClass { + function sample(): stdClass { + $out = new stdClass(); + $out->{'LocalizedContent'} = 'LocalizedContent::abbreviations::31'; /*31:abbreviations*/ + return $out; + } + return sample(); + } + /** * @param array $value * @throws Exception @@ -481,8 +559,8 @@ public function getBlocks(): array { */ public static function sampleBlocks(): array { return array( - ContentBlock::sample() /*31:*/ - ); /* 31:blocks*/ + ContentBlock::sample() /*32:*/ + ); /* 32:blocks*/ } /** @@ -550,7 +628,7 @@ public function getFootnotes(): stdClass { public static function sampleFootnotes(): stdClass { function sample(): stdClass { $out = new stdClass(); - $out->{'LocalizedContent'} = 'LocalizedContent::footnotes::32'; /*32:footnotes*/ + $out->{'LocalizedContent'} = 'LocalizedContent::footnotes::33'; /*33:footnotes*/ return $out; } return sample(); @@ -623,9 +701,9 @@ public function getLayout(): array { public static function sampleLayout(): array { return array( array( - 'LocalizedContent::::33' /*33:*/ - ); /* 33:*/ - ); /* 33:layout*/ + 'LocalizedContent::::34' /*34:*/ + ); /* 34:*/ + ); /* 34:layout*/ } /** @@ -675,7 +753,7 @@ public function getTitle(): string { * @return string */ public static function sampleTitle(): string { - return 'LocalizedContent::title::34'; /*34:title*/ + return 'LocalizedContent::title::35'; /*35:title*/ } /** @@ -683,7 +761,8 @@ public static function sampleTitle(): string { * @return bool */ public function validate(): bool { - return LocalizedContent::validateBlocks($this->blocks) + return LocalizedContent::validateAbbreviations($this->abbreviations) + || LocalizedContent::validateBlocks($this->blocks) || LocalizedContent::validateFootnotes($this->footnotes) || LocalizedContent::validateLayout($this->layout) || LocalizedContent::validateTitle($this->title); @@ -695,6 +774,7 @@ public function validate(): bool { */ public function to(): stdClass { $out = new stdClass(); + $out->{'abbreviations'} = $this->toAbbreviations(); $out->{'blocks'} = $this->toBlocks(); $out->{'footnotes'} = $this->toFootnotes(); $out->{'layout'} = $this->toLayout(); @@ -709,7 +789,8 @@ public function to(): stdClass { */ public static function from(stdClass $obj): LocalizedContent { return new LocalizedContent( - LocalizedContent::fromBlocks($obj->{'blocks'}) + LocalizedContent::fromAbbreviations($obj->{'abbreviations'}) + ,LocalizedContent::fromBlocks($obj->{'blocks'}) ,LocalizedContent::fromFootnotes($obj->{'footnotes'}) ,LocalizedContent::fromLayout($obj->{'layout'}) ,LocalizedContent::fromTitle($obj->{'title'}) @@ -721,7 +802,8 @@ public static function from(stdClass $obj): LocalizedContent { */ public static function sample(): LocalizedContent { return new LocalizedContent( - LocalizedContent::sampleBlocks() + LocalizedContent::sampleAbbreviations() + ,LocalizedContent::sampleBlocks() ,LocalizedContent::sampleFootnotes() ,LocalizedContent::sampleLayout() ,LocalizedContent::sampleTitle() @@ -743,6 +825,7 @@ class ContentBlock { private ImageDimensions $dimensions; // json:dimensions Required private string $distSource; // json:distSource Required private float $duration; // json:duration Required + private string $hash; // json:hash Required private bool $hasSound; // json:hasSound Required private string $id; // json:id Required private int $index; // json:index Required @@ -751,7 +834,7 @@ class ContentBlock { private int $size; // json:size Required private string $text; // json:text Required private ThumbnailsMap $thumbnails; // json:thumbnails Required - private string $thumbnailsBuiltAt; // json:thumbnailsBuiltAt Required + private DateTime $thumbnailsBuiltAt; // json:thumbnailsBuiltAt Required private string $title; // json:title Required private string $type; // json:type Required private string $url; // json:url Required @@ -768,6 +851,7 @@ class ContentBlock { * @param ImageDimensions $dimensions * @param string $distSource * @param float $duration + * @param string $hash * @param bool $hasSound * @param string $id * @param int $index @@ -776,12 +860,12 @@ class ContentBlock { * @param int $size * @param string $text * @param ThumbnailsMap $thumbnails - * @param string $thumbnailsBuiltAt + * @param DateTime $thumbnailsBuiltAt * @param string $title * @param string $type * @param string $url */ - public function __construct(string $alt, bool $analyzed, string $anchor, MediaAttributes $attributes, string $caption, ColorPalette $colors, string $content, string $contentType, ImageDimensions $dimensions, string $distSource, float $duration, bool $hasSound, string $id, int $index, bool $online, string $relativeSource, int $size, string $text, ThumbnailsMap $thumbnails, string $thumbnailsBuiltAt, string $title, string $type, string $url) { + public function __construct(string $alt, bool $analyzed, string $anchor, MediaAttributes $attributes, string $caption, ColorPalette $colors, string $content, string $contentType, ImageDimensions $dimensions, string $distSource, float $duration, string $hash, bool $hasSound, string $id, int $index, bool $online, string $relativeSource, int $size, string $text, ThumbnailsMap $thumbnails, DateTime $thumbnailsBuiltAt, string $title, string $type, string $url) { $this->alt = $alt; $this->analyzed = $analyzed; $this->anchor = $anchor; @@ -793,6 +877,7 @@ public function __construct(string $alt, bool $analyzed, string $anchor, MediaAt $this->dimensions = $dimensions; $this->distSource = $distSource; $this->duration = $duration; + $this->hash = $hash; $this->hasSound = $hasSound; $this->id = $id; $this->index = $index; @@ -1381,6 +1466,66 @@ public static function sampleDuration(): float { return 41.041; /*41:duration*/ } + /** + * Hash of the media file, used for caching purposes. Could also serve as an integritycheck.The value is the MD5 hash, base64-encoded. + * + * @param string $value + * @throws Exception + * @return string + */ + public static function fromHash(string $value): string { + return $value; /*string*/ + } + + /** + * Hash of the media file, used for caching purposes. Could also serve as an integritycheck.The value is the MD5 hash, base64-encoded. + * + * @throws Exception + * @return string + */ + public function toHash(): string { + if (ContentBlock::validateHash($this->hash)) { + return $this->hash; /*string*/ + } + throw new Exception('never get to this ContentBlock::hash'); + } + + /** + * Hash of the media file, used for caching purposes. Could also serve as an integritycheck.The value is the MD5 hash, base64-encoded. + * + * @param string + * @return bool + * @throws Exception + */ + public static function validateHash(string $value): bool { + if (!is_string($value)) { + throw new Exception("Attribute Error:ContentBlock::hash"); + } + return true; + } + + /** + * Hash of the media file, used for caching purposes. Could also serve as an integritycheck.The value is the MD5 hash, base64-encoded. + * + * @throws Exception + * @return string + */ + public function getHash(): string { + if (ContentBlock::validateHash($this->hash)) { + return $this->hash; + } + throw new Exception('never get to getHash ContentBlock::hash'); + } + + /** + * Hash of the media file, used for caching purposes. Could also serve as an integritycheck.The value is the MD5 hash, base64-encoded. + * + * @return string + */ + public static function sampleHash(): string { + return 'ContentBlock::hash::42'; /*42:hash*/ + } + /** * @param bool $value * @throws Exception @@ -1428,7 +1573,7 @@ public function getHasSound(): bool { * @return bool */ public static function sampleHasSound(): bool { - return true; /*42:hasSound*/ + return true; /*43:hasSound*/ } /** @@ -1478,7 +1623,7 @@ public function getID(): string { * @return string */ public static function sampleID(): string { - return 'ContentBlock::id::43'; /*43:id*/ + return 'ContentBlock::id::44'; /*44:id*/ } /** @@ -1528,7 +1673,7 @@ public function getIndex(): int { * @return int */ public static function sampleIndex(): int { - return 44; /*44:index*/ + return 45; /*45:index*/ } /** @@ -1578,7 +1723,7 @@ public function getOnline(): bool { * @return bool */ public static function sampleOnline(): bool { - return true; /*45:online*/ + return true; /*46:online*/ } /** @@ -1628,7 +1773,7 @@ public function getRelativeSource(): string { * @return string */ public static function sampleRelativeSource(): string { - return 'ContentBlock::relativeSource::46'; /*46:relativeSource*/ + return 'ContentBlock::relativeSource::47'; /*47:relativeSource*/ } /** @@ -1688,7 +1833,7 @@ public function getSize(): int { * @return int */ public static function sampleSize(): int { - return 47; /*47:size*/ + return 48; /*48:size*/ } /** @@ -1738,7 +1883,7 @@ public function getText(): string { * @return string */ public static function sampleText(): string { - return 'ContentBlock::text::48'; /*48:text*/ + return 'ContentBlock::text::49'; /*49:text*/ } /** @@ -1786,16 +1931,20 @@ public function getThumbnails(): ThumbnailsMap { * @return ThumbnailsMap */ public static function sampleThumbnails(): ThumbnailsMap { - return ThumbnailsMap::sample(); /*49:thumbnails*/ + return ThumbnailsMap::sample(); /*50:thumbnails*/ } /** * @param string $value * @throws Exception - * @return string + * @return DateTime */ - public static function fromThumbnailsBuiltAt(string $value): string { - return $value; /*string*/ + public static function fromThumbnailsBuiltAt(string $value): DateTime { + $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value); + if (!is_a($tmp, 'DateTime')) { + throw new Exception('Attribute Error:ContentBlock::'); + } + return $tmp; } /** @@ -1804,28 +1953,28 @@ public static function fromThumbnailsBuiltAt(string $value): string { */ public function toThumbnailsBuiltAt(): string { if (ContentBlock::validateThumbnailsBuiltAt($this->thumbnailsBuiltAt)) { - return $this->thumbnailsBuiltAt; /*string*/ + return $this->thumbnailsBuiltAt->format(DateTimeInterface::ISO8601); } throw new Exception('never get to this ContentBlock::thumbnailsBuiltAt'); } /** - * @param string + * @param DateTime * @return bool * @throws Exception */ - public static function validateThumbnailsBuiltAt(string $value): bool { - if (!is_string($value)) { - throw new Exception("Attribute Error:ContentBlock::thumbnailsBuiltAt"); + public static function validateThumbnailsBuiltAt(DateTime $value): bool { + if (!is_a($value, 'DateTime')) { + throw new Exception('Attribute Error:ContentBlock::thumbnailsBuiltAt'); } return true; } /** * @throws Exception - * @return string + * @return DateTime */ - public function getThumbnailsBuiltAt(): string { + public function getThumbnailsBuiltAt(): DateTime { if (ContentBlock::validateThumbnailsBuiltAt($this->thumbnailsBuiltAt)) { return $this->thumbnailsBuiltAt; } @@ -1833,10 +1982,10 @@ public function getThumbnailsBuiltAt(): string { } /** - * @return string + * @return DateTime */ - public static function sampleThumbnailsBuiltAt(): string { - return 'ContentBlock::thumbnailsBuiltAt::50'; /*50:thumbnailsBuiltAt*/ + public static function sampleThumbnailsBuiltAt(): DateTime { + return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-21T12:21:21+00:00'); } /** @@ -1886,7 +2035,7 @@ public function getTitle(): string { * @return string */ public static function sampleTitle(): string { - return 'ContentBlock::title::51'; /*51:title*/ + return 'ContentBlock::title::52'; /*52:title*/ } /** @@ -1936,7 +2085,7 @@ public function getType(): string { * @return string */ public static function sampleType(): string { - return 'ContentBlock::type::52'; /*52:type*/ + return 'ContentBlock::type::53'; /*53:type*/ } /** @@ -1986,7 +2135,7 @@ public function getURL(): string { * @return string */ public static function sampleURL(): string { - return 'ContentBlock::url::53'; /*53:url*/ + return 'ContentBlock::url::54'; /*54:url*/ } /** @@ -2005,6 +2154,7 @@ public function validate(): bool { || ContentBlock::validateDimensions($this->dimensions) || ContentBlock::validateDistSource($this->distSource) || ContentBlock::validateDuration($this->duration) + || ContentBlock::validateHash($this->hash) || ContentBlock::validateHasSound($this->hasSound) || ContentBlock::validateID($this->id) || ContentBlock::validateIndex($this->index) @@ -2036,6 +2186,7 @@ public function to(): stdClass { $out->{'dimensions'} = $this->toDimensions(); $out->{'distSource'} = $this->toDistSource(); $out->{'duration'} = $this->toDuration(); + $out->{'hash'} = $this->toHash(); $out->{'hasSound'} = $this->toHasSound(); $out->{'id'} = $this->toID(); $out->{'index'} = $this->toIndex(); @@ -2069,6 +2220,7 @@ public static function from(stdClass $obj): ContentBlock { ,ContentBlock::fromDimensions($obj->{'dimensions'}) ,ContentBlock::fromDistSource($obj->{'distSource'}) ,ContentBlock::fromDuration($obj->{'duration'}) + ,ContentBlock::fromHash($obj->{'hash'}) ,ContentBlock::fromHasSound($obj->{'hasSound'}) ,ContentBlock::fromID($obj->{'id'}) ,ContentBlock::fromIndex($obj->{'index'}) @@ -2100,6 +2252,7 @@ public static function sample(): ContentBlock { ,ContentBlock::sampleDimensions() ,ContentBlock::sampleDistSource() ,ContentBlock::sampleDuration() + ,ContentBlock::sampleHash() ,ContentBlock::sampleHasSound() ,ContentBlock::sampleID() ,ContentBlock::sampleIndex() diff --git a/packages/python/ortfodb/configuration.py b/packages/python/ortfodb/configuration.py index a6d2c1a..60b0dbf 100644 --- a/packages/python/ortfodb/configuration.py +++ b/packages/python/ortfodb/configuration.py @@ -1,4 +1,4 @@ -from typing import List, Any, Optional, Dict, TypeVar, Callable, Type, cast +from typing import List, Any, Dict, Optional, TypeVar, Callable, Type, cast T = TypeVar("T") @@ -24,6 +24,11 @@ def from_int(x: Any) -> int: return x +def from_dict(f: Callable[[Any], T], x: Any) -> Dict[str, T]: + assert isinstance(x, dict) + return { k: f(v) for (k, v) in x.items() } + + def from_none(x: Any) -> Any: assert x is None return x @@ -38,11 +43,6 @@ def from_union(fs, x): assert False -def from_dict(f: Callable[[Any], T], x: Any) -> Dict[str, T]: - assert isinstance(x, dict) - return { k: f(v) for (k, v) in x.items() } - - def to_class(c: Type[T], x: Any) -> dict: assert isinstance(x, c) return cast(Any, x).to_dict() @@ -186,7 +186,6 @@ def to_dict(self) -> dict: class Configuration: """Configuration represents what the ortfodb.yaml configuration file describes.""" - build_metadata_file: Optional[str] exporters: Optional[Dict[str, Dict[str, Any]]] """Exporter-specific configuration. Maps exporter names to their configuration.""" @@ -201,8 +200,7 @@ class Configuration: tags: Optional[TagsConfiguration] technologies: Optional[TechnologiesConfiguration] - def __init__(self, build_metadata_file: Optional[str], exporters: Optional[Dict[str, Dict[str, Any]]], extract_colors: Optional[ExtractColorsConfiguration], make_gifs: Optional[MakeGIFSConfiguration], make_thumbnails: Optional[MakeThumbnailsConfiguration], media: Optional[MediaConfiguration], projects_at: str, scattered_mode_folder: str, tags: Optional[TagsConfiguration], technologies: Optional[TechnologiesConfiguration]) -> None: - self.build_metadata_file = build_metadata_file + def __init__(self, exporters: Optional[Dict[str, Dict[str, Any]]], extract_colors: Optional[ExtractColorsConfiguration], make_gifs: Optional[MakeGIFSConfiguration], make_thumbnails: Optional[MakeThumbnailsConfiguration], media: Optional[MediaConfiguration], projects_at: str, scattered_mode_folder: str, tags: Optional[TagsConfiguration], technologies: Optional[TechnologiesConfiguration]) -> None: self.exporters = exporters self.extract_colors = extract_colors self.make_gifs = make_gifs @@ -216,7 +214,6 @@ def __init__(self, build_metadata_file: Optional[str], exporters: Optional[Dict[ @staticmethod def from_dict(obj: Any) -> 'Configuration': assert isinstance(obj, dict) - build_metadata_file = from_union([from_str, from_none], obj.get("build metadata file")) exporters = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none], obj.get("exporters")) extract_colors = from_union([ExtractColorsConfiguration.from_dict, from_none], obj.get("extract colors")) make_gifs = from_union([MakeGIFSConfiguration.from_dict, from_none], obj.get("make gifs")) @@ -226,12 +223,10 @@ def from_dict(obj: Any) -> 'Configuration': scattered_mode_folder = from_str(obj.get("scattered mode folder")) tags = from_union([TagsConfiguration.from_dict, from_none], obj.get("tags")) technologies = from_union([TechnologiesConfiguration.from_dict, from_none], obj.get("technologies")) - return Configuration(build_metadata_file, exporters, extract_colors, make_gifs, make_thumbnails, media, projects_at, scattered_mode_folder, tags, technologies) + return Configuration(exporters, extract_colors, make_gifs, make_thumbnails, media, projects_at, scattered_mode_folder, tags, technologies) def to_dict(self) -> dict: result: dict = {} - if self.build_metadata_file is not None: - result["build metadata file"] = from_union([from_str, from_none], self.build_metadata_file) if self.exporters is not None: result["exporters"] = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none], self.exporters) if self.extract_colors is not None: diff --git a/packages/python/ortfodb/database.py b/packages/python/ortfodb/database.py index ff94212..8dc43d2 100644 --- a/packages/python/ortfodb/database.py +++ b/packages/python/ortfodb/database.py @@ -1,4 +1,6 @@ -from typing import Any, List, Dict, TypeVar, Type, cast, Callable +from typing import Any, Dict, List, TypeVar, Type, cast, Callable +from datetime import datetime +import dateutil.parser T = TypeVar("T") @@ -29,21 +31,25 @@ def to_float(x: Any) -> float: return x +def from_datetime(x: Any) -> datetime: + return dateutil.parser.parse(x) + + def to_class(c: Type[T], x: Any) -> dict: assert isinstance(x, c) return cast(Any, x).to_dict() -def from_list(f: Callable[[Any], T], x: Any) -> List[T]: - assert isinstance(x, list) - return [f(y) for y in x] - - def from_dict(f: Callable[[Any], T], x: Any) -> Dict[str, T]: assert isinstance(x, dict) return { k: f(v) for (k, v) in x.items() } +def from_list(f: Callable[[Any], T], x: Any) -> List[T]: + assert isinstance(x, list) + return [f(y) for y in x] + + class MediaAttributes: """MediaAttributes stores which HTML attributes should be added to the media.""" @@ -184,6 +190,11 @@ class ContentBlock: duration: float """in seconds""" + hash: str + """Hash of the media file, used for caching purposes. Could also serve as an integrity + check. + The value is the MD5 hash, base64-encoded. + """ has_sound: bool id: str index: int @@ -194,12 +205,12 @@ class ContentBlock: text: str thumbnails: ThumbnailsMap - thumbnails_built_at: str + thumbnails_built_at: datetime title: str type: str url: str - def __init__(self, alt: str, analyzed: bool, anchor: str, attributes: MediaAttributes, caption: str, colors: ColorPalette, content: str, content_type: str, dimensions: ImageDimensions, dist_source: str, duration: float, has_sound: bool, id: str, index: int, online: bool, relative_source: str, size: int, text: str, thumbnails: ThumbnailsMap, thumbnails_built_at: str, title: str, type: str, url: str) -> None: + def __init__(self, alt: str, analyzed: bool, anchor: str, attributes: MediaAttributes, caption: str, colors: ColorPalette, content: str, content_type: str, dimensions: ImageDimensions, dist_source: str, duration: float, hash: str, has_sound: bool, id: str, index: int, online: bool, relative_source: str, size: int, text: str, thumbnails: ThumbnailsMap, thumbnails_built_at: datetime, title: str, type: str, url: str) -> None: self.alt = alt self.analyzed = analyzed self.anchor = anchor @@ -211,6 +222,7 @@ def __init__(self, alt: str, analyzed: bool, anchor: str, attributes: MediaAttri self.dimensions = dimensions self.dist_source = dist_source self.duration = duration + self.hash = hash self.has_sound = has_sound self.id = id self.index = index @@ -238,6 +250,7 @@ def from_dict(obj: Any) -> 'ContentBlock': dimensions = ImageDimensions.from_dict(obj.get("dimensions")) dist_source = from_str(obj.get("distSource")) duration = from_float(obj.get("duration")) + hash = from_str(obj.get("hash")) has_sound = from_bool(obj.get("hasSound")) id = from_str(obj.get("id")) index = from_int(obj.get("index")) @@ -246,11 +259,11 @@ def from_dict(obj: Any) -> 'ContentBlock': size = from_int(obj.get("size")) text = from_str(obj.get("text")) thumbnails = ThumbnailsMap.from_dict(obj.get("thumbnails")) - thumbnails_built_at = from_str(obj.get("thumbnailsBuiltAt")) + thumbnails_built_at = from_datetime(obj.get("thumbnailsBuiltAt")) title = from_str(obj.get("title")) type = from_str(obj.get("type")) url = from_str(obj.get("url")) - return ContentBlock(alt, analyzed, anchor, attributes, caption, colors, content, content_type, dimensions, dist_source, duration, has_sound, id, index, online, relative_source, size, text, thumbnails, thumbnails_built_at, title, type, url) + return ContentBlock(alt, analyzed, anchor, attributes, caption, colors, content, content_type, dimensions, dist_source, duration, hash, has_sound, id, index, online, relative_source, size, text, thumbnails, thumbnails_built_at, title, type, url) def to_dict(self) -> dict: result: dict = {} @@ -265,6 +278,7 @@ def to_dict(self) -> dict: result["dimensions"] = to_class(ImageDimensions, self.dimensions) result["distSource"] = from_str(self.dist_source) result["duration"] = to_float(self.duration) + result["hash"] = from_str(self.hash) result["hasSound"] = from_bool(self.has_sound) result["id"] = from_str(self.id) result["index"] = from_int(self.index) @@ -273,7 +287,7 @@ def to_dict(self) -> dict: result["size"] = from_int(self.size) result["text"] = from_str(self.text) result["thumbnails"] = to_class(ThumbnailsMap, self.thumbnails) - result["thumbnailsBuiltAt"] = from_str(self.thumbnails_built_at) + result["thumbnailsBuiltAt"] = self.thumbnails_built_at.isoformat() result["title"] = from_str(self.title) result["type"] = from_str(self.type) result["url"] = from_str(self.url) @@ -281,12 +295,14 @@ def to_dict(self) -> dict: class LocalizedContent: + abbreviations: Dict[str, str] blocks: List[ContentBlock] footnotes: Dict[str, str] layout: List[List[str]] title: str - def __init__(self, blocks: List[ContentBlock], footnotes: Dict[str, str], layout: List[List[str]], title: str) -> None: + def __init__(self, abbreviations: Dict[str, str], blocks: List[ContentBlock], footnotes: Dict[str, str], layout: List[List[str]], title: str) -> None: + self.abbreviations = abbreviations self.blocks = blocks self.footnotes = footnotes self.layout = layout @@ -295,14 +311,16 @@ def __init__(self, blocks: List[ContentBlock], footnotes: Dict[str, str], layout @staticmethod def from_dict(obj: Any) -> 'LocalizedContent': assert isinstance(obj, dict) + abbreviations = from_dict(from_str, obj.get("abbreviations")) blocks = from_list(ContentBlock.from_dict, obj.get("blocks")) footnotes = from_dict(from_str, obj.get("footnotes")) layout = from_list(lambda x: from_list(from_str, x), obj.get("layout")) title = from_str(obj.get("title")) - return LocalizedContent(blocks, footnotes, layout, title) + return LocalizedContent(abbreviations, blocks, footnotes, layout, title) def to_dict(self) -> dict: result: dict = {} + result["abbreviations"] = from_dict(from_str, self.abbreviations) result["blocks"] = from_list(lambda x: to_class(ContentBlock, x), self.blocks) result["footnotes"] = from_dict(from_str, self.footnotes) result["layout"] = from_list(lambda x: from_list(from_str, x), self.layout) @@ -395,17 +413,17 @@ def to_dict(self) -> dict: return result -class AnalyzedWork: - """AnalyzedWork represents a complete work, with analyzed mediae.""" +class Work: + """Work represents a given work in the database.""" - built_at: str + built_at: datetime content: Dict[str, LocalizedContent] description_hash: str id: str metadata: WorkMetadata partial: bool - def __init__(self, built_at: str, content: Dict[str, LocalizedContent], description_hash: str, id: str, metadata: WorkMetadata, partial: bool) -> None: + def __init__(self, built_at: datetime, content: Dict[str, LocalizedContent], description_hash: str, id: str, metadata: WorkMetadata, partial: bool) -> None: self.built_at = built_at self.content = content self.description_hash = description_hash @@ -414,19 +432,19 @@ def __init__(self, built_at: str, content: Dict[str, LocalizedContent], descript self.partial = partial @staticmethod - def from_dict(obj: Any) -> 'AnalyzedWork': + def from_dict(obj: Any) -> 'Work': assert isinstance(obj, dict) - built_at = from_str(obj.get("builtAt")) + built_at = from_datetime(obj.get("builtAt")) content = from_dict(LocalizedContent.from_dict, obj.get("content")) description_hash = from_str(obj.get("descriptionHash")) id = from_str(obj.get("id")) metadata = WorkMetadata.from_dict(obj.get("metadata")) partial = from_bool(obj.get("Partial")) - return AnalyzedWork(built_at, content, description_hash, id, metadata, partial) + return Work(built_at, content, description_hash, id, metadata, partial) def to_dict(self) -> dict: result: dict = {} - result["builtAt"] = from_str(self.built_at) + result["builtAt"] = self.built_at.isoformat() result["content"] = from_dict(lambda x: to_class(LocalizedContent, x), self.content) result["descriptionHash"] = from_str(self.description_hash) result["id"] = from_str(self.id) @@ -435,9 +453,9 @@ def to_dict(self) -> dict: return result -def database_from_dict(s: Any) -> Dict[str, AnalyzedWork]: - return from_dict(AnalyzedWork.from_dict, s) +def database_from_dict(s: Any) -> Dict[str, Work]: + return from_dict(Work.from_dict, s) -def database_to_dict(x: Dict[str, AnalyzedWork]) -> Any: - return from_dict(lambda x: to_class(AnalyzedWork, x), x) +def database_to_dict(x: Dict[str, Work]) -> Any: + return from_dict(lambda x: to_class(Work, x), x) diff --git a/packages/python/pyproject.toml b/packages/python/pyproject.toml index 41e0abc..bd62378 100644 --- a/packages/python/pyproject.toml +++ b/packages/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ortfodb" -version = "1.5.0" +version = "1.6.0" description = "ortfodb client library" authors = ["Ewen Le Bihan "] license = "MIT" diff --git a/packages/ruby/lib/ortfodb/configuration.rb b/packages/ruby/lib/ortfodb/configuration.rb index 883ac7b..e83747a 100644 --- a/packages/ruby/lib/ortfodb/configuration.rb +++ b/packages/ruby/lib/ortfodb/configuration.rb @@ -198,7 +198,6 @@ def to_json(options = nil) # Configuration represents what the ortfodb.yaml configuration file describes. class Configuration < Dry::Struct - attribute :build_metadata_file, Types::String.optional # Exporter-specific configuration. Maps exporter names to their configuration. attribute :exporters, Types::Hash.meta(of: Types::Hash.meta(of: Types::Any)).optional @@ -218,7 +217,6 @@ class Configuration < Dry::Struct def self.from_dynamic!(d) d = Types::Hash[d] new( - build_metadata_file: d["build metadata file"], exporters: Types::Hash.optional[d["exporters"]]&.map { |k, v| [k, Types::Hash[v].map { |k, v| [k, Types::Any[v]] }.to_h] }&.to_h, extract_colors: d["extract colors"] ? ExtractColorsConfiguration.from_dynamic!(d["extract colors"]) : nil, make_gifs: d["make gifs"] ? MakeGIFSConfiguration.from_dynamic!(d["make gifs"]) : nil, @@ -237,7 +235,6 @@ def self.from_json!(json) def to_dynamic { - "build metadata file" => build_metadata_file, "exporters" => exporters, "extract colors" => extract_colors&.to_dynamic, "make gifs" => make_gifs&.to_dynamic, diff --git a/packages/ruby/lib/ortfodb/database.rb b/packages/ruby/lib/ortfodb/database.rb index 1350c9c..4df5b0b 100644 --- a/packages/ruby/lib/ortfodb/database.rb +++ b/packages/ruby/lib/ortfodb/database.rb @@ -184,6 +184,11 @@ class ContentBlock < Dry::Struct # in seconds attribute :duration, Types::Double + # Hash of the media file, used for caching purposes. Could also serve as an integrity + # check. + # The value is the MD5 hash, base64-encoded. + attribute :content_block_hash, Types::String + attribute :has_sound, Types::Bool attribute :id, Types::String attribute :index, Types::Integer @@ -214,6 +219,7 @@ def self.from_dynamic!(d) dimensions: ImageDimensions.from_dynamic!(d.fetch("dimensions")), dist_source: d.fetch("distSource"), duration: d.fetch("duration"), + content_block_hash: d.fetch("hash"), has_sound: d.fetch("hasSound"), id: d.fetch("id"), index: d.fetch("index"), @@ -246,6 +252,7 @@ def to_dynamic "dimensions" => dimensions.to_dynamic, "distSource" => dist_source, "duration" => duration, + "hash" => content_block_hash, "hasSound" => has_sound, "id" => id, "index" => index, @@ -267,18 +274,20 @@ def to_json(options = nil) end class LocalizedContent < Dry::Struct - attribute :blocks, Types.Array(ContentBlock) - attribute :footnotes, Types::Hash.meta(of: Types::String) - attribute :layout, Types.Array(Types.Array(Types::String)) - attribute :title, Types::String + attribute :abbreviations, Types::Hash.meta(of: Types::String) + attribute :blocks, Types.Array(ContentBlock) + attribute :footnotes, Types::Hash.meta(of: Types::String) + attribute :layout, Types.Array(Types.Array(Types::String)) + attribute :title, Types::String def self.from_dynamic!(d) d = Types::Hash[d] new( - blocks: d.fetch("blocks").map { |x| ContentBlock.from_dynamic!(x) }, - footnotes: Types::Hash[d.fetch("footnotes")].map { |k, v| [k, Types::String[v]] }.to_h, - layout: d.fetch("layout"), - title: d.fetch("title"), + abbreviations: Types::Hash[d.fetch("abbreviations")].map { |k, v| [k, Types::String[v]] }.to_h, + blocks: d.fetch("blocks").map { |x| ContentBlock.from_dynamic!(x) }, + footnotes: Types::Hash[d.fetch("footnotes")].map { |k, v| [k, Types::String[v]] }.to_h, + layout: d.fetch("layout"), + title: d.fetch("title"), ) end @@ -288,10 +297,11 @@ def self.from_json!(json) def to_dynamic { - "blocks" => blocks.map { |x| x.to_dynamic }, - "footnotes" => footnotes, - "layout" => layout, - "title" => title, + "abbreviations" => abbreviations, + "blocks" => blocks.map { |x| x.to_dynamic }, + "footnotes" => footnotes, + "layout" => layout, + "title" => title, } end @@ -388,8 +398,8 @@ def to_json(options = nil) end end - # AnalyzedWork represents a complete work, with analyzed mediae. - class AnalyzedWork < Dry::Struct + # Work represents a given work in the database. + class Work < Dry::Struct attribute :built_at, Types::String attribute :content, Types::Hash.meta(of: LocalizedContent) attribute :description_hash, Types::String @@ -432,7 +442,7 @@ def to_json(options = nil) module Ortfodb class Database def self.from_json!(json) - Types::Hash[JSON.parse(json, quirks_mode: true)].map { |k, v| [k, AnalyzedWork.from_dynamic!(v)] }.to_h + Types::Hash[JSON.parse(json, quirks_mode: true)].map { |k, v| [k, Work.from_dynamic!(v)] }.to_h end end end diff --git a/packages/ruby/lib/ortfodb/version.rb b/packages/ruby/lib/ortfodb/version.rb index 57c845f..3bc50a1 100644 --- a/packages/ruby/lib/ortfodb/version.rb +++ b/packages/ruby/lib/ortfodb/version.rb @@ -1,3 +1,3 @@ module Ortfodb - VERSION = "1.5.0" + VERSION = "1.6.0" end diff --git a/packages/rust/Cargo.toml b/packages/rust/Cargo.toml index 5a1aecc..cbd0b37 100644 --- a/packages/rust/Cargo.toml +++ b/packages/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ortfodb" -version = "1.5.0" +version = "1.6.0" edition = "2021" description = "An ortfodb (https://github.com/ortfo/db) client library for Rust." license = "MIT" diff --git a/packages/rust/src/configuration.rs b/packages/rust/src/configuration.rs index fbc7720..f1abdd3 100644 --- a/packages/rust/src/configuration.rs +++ b/packages/rust/src/configuration.rs @@ -17,9 +17,6 @@ use std::collections::HashMap; /// Configuration represents what the ortfodb.yaml configuration file describes. #[derive(Serialize, Deserialize)] pub struct Configuration { - #[serde(rename = "build metadata file")] - pub build_metadata_file: Option, - /// Exporter-specific configuration. Maps exporter names to their configuration. pub exporters: Option>>>, diff --git a/packages/rust/src/database.rs b/packages/rust/src/database.rs index afccb91..5421f3b 100644 --- a/packages/rust/src/database.rs +++ b/packages/rust/src/database.rs @@ -14,12 +14,12 @@ use serde::{Serialize, Deserialize}; use std::collections::HashMap; -pub type Database = HashMap; +pub type Database = HashMap; -/// AnalyzedWork represents a complete work, with analyzed mediae. +/// Work represents a given work in the database. #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct AnalyzedWork { +pub struct Work { pub built_at: String, pub content: HashMap, @@ -36,6 +36,8 @@ pub struct AnalyzedWork { #[derive(Serialize, Deserialize)] pub struct LocalizedContent { + pub abbreviations: HashMap, + pub blocks: Vec, pub footnotes: HashMap, @@ -73,6 +75,11 @@ pub struct ContentBlock { /// in seconds pub duration: f64, + /// Hash of the media file, used for caching purposes. Could also serve as an integrity + /// check. + /// The value is the MD5 hash, base64-encoded. + pub hash: String, + pub has_sound: bool, pub id: String, diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 582afa8..9a06c8d 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@ortfo/db", - "version": "1.5.0", + "version": "1.6.0", "description": "ortfodb client library", "scripts": { "build": "tsc -p tsconfig.json --declaration --outDir dist" diff --git a/packages/typescript/src/configuration.ts b/packages/typescript/src/configuration.ts index a13b424..99a6ea0 100644 --- a/packages/typescript/src/configuration.ts +++ b/packages/typescript/src/configuration.ts @@ -11,7 +11,6 @@ * Configuration represents what the ortfodb.yaml configuration file describes. */ export interface Configuration { - "build metadata file"?: string; /** * Exporter-specific configuration. Maps exporter names to their configuration. */ @@ -234,7 +233,6 @@ function r(name: string) { const typeMap: any = { "Configuration": o([ - { json: "build metadata file", js: "build metadata file", typ: u(undefined, "") }, { json: "exporters", js: "exporters", typ: u(undefined, m(m("any"))) }, { json: "extract colors", js: "extract colors", typ: u(undefined, r("ExtractColorsConfiguration")) }, { json: "make gifs", js: "make gifs", typ: u(undefined, r("MakeGIFSConfiguration")) }, diff --git a/packages/typescript/src/database.ts b/packages/typescript/src/database.ts index 271317a..b0cdeab 100644 --- a/packages/typescript/src/database.ts +++ b/packages/typescript/src/database.ts @@ -8,10 +8,10 @@ // match the expected interface, even if the JSON is valid. /** - * AnalyzedWork represents a complete work, with analyzed mediae. + * Work represents a given work in the database. */ export interface Database { - builtAt: string; + builtAt: Date; content: { [key: string]: LocalizedContent }; descriptionHash: string; id: string; @@ -20,10 +20,11 @@ export interface Database { } export interface LocalizedContent { - blocks: ContentBlock[]; - footnotes: { [key: string]: string }; - layout: Array; - title: string; + abbreviations: { [key: string]: string }; + blocks: ContentBlock[]; + footnotes: { [key: string]: string }; + layout: Array; + title: string; } export interface ContentBlock { @@ -46,7 +47,13 @@ export interface ContentBlock { /** * in seconds */ - duration: number; + duration: number; + /** + * Hash of the media file, used for caching purposes. Could also serve as an integrity + * check. + * The value is the MD5 hash, base64-encoded. + */ + hash: string; hasSound: boolean; id: string; index: number; @@ -58,7 +65,7 @@ export interface ContentBlock { size: number; text: string; thumbnails: ThumbnailsMap; - thumbnailsBuiltAt: string; + thumbnailsBuiltAt: Date; title: string; type: string; url: string; @@ -309,7 +316,7 @@ function r(name: string) { const typeMap: any = { "Database": o([ - { json: "builtAt", js: "builtAt", typ: "" }, + { json: "builtAt", js: "builtAt", typ: Date }, { json: "content", js: "content", typ: m(r("LocalizedContent")) }, { json: "descriptionHash", js: "descriptionHash", typ: "" }, { json: "id", js: "id", typ: "" }, @@ -317,6 +324,7 @@ const typeMap: any = { { json: "Partial", js: "Partial", typ: true }, ], false), "LocalizedContent": o([ + { json: "abbreviations", js: "abbreviations", typ: m("") }, { json: "blocks", js: "blocks", typ: a(r("ContentBlock")) }, { json: "footnotes", js: "footnotes", typ: m("") }, { json: "layout", js: "layout", typ: a(a("")) }, @@ -334,6 +342,7 @@ const typeMap: any = { { json: "dimensions", js: "dimensions", typ: r("ImageDimensions") }, { json: "distSource", js: "distSource", typ: "" }, { json: "duration", js: "duration", typ: 3.14 }, + { json: "hash", js: "hash", typ: "" }, { json: "hasSound", js: "hasSound", typ: true }, { json: "id", js: "id", typ: "" }, { json: "index", js: "index", typ: 0 }, @@ -342,7 +351,7 @@ const typeMap: any = { { json: "size", js: "size", typ: 0 }, { json: "text", js: "text", typ: "" }, { json: "thumbnails", js: "thumbnails", typ: r("ThumbnailsMap") }, - { json: "thumbnailsBuiltAt", js: "thumbnailsBuiltAt", typ: "" }, + { json: "thumbnailsBuiltAt", js: "thumbnailsBuiltAt", typ: Date }, { json: "title", js: "title", typ: "" }, { json: "type", js: "type", typ: "" }, { json: "url", js: "url", typ: "" }, diff --git a/schemas/configuration.schema.json b/schemas/configuration.schema.json index 6cb5d74..786cd5c 100644 --- a/schemas/configuration.schema.json +++ b/schemas/configuration.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://raw.githubusercontent.com/ortfo/db/v1.5.0/schemas/configuration.schema.json", + "$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.0/schemas/configuration.schema.json", "$ref": "#/$defs/Configuration", "$defs": { "Configuration": { @@ -14,9 +14,6 @@ "make thumbnails": { "$ref": "#/$defs/MakeThumbnailsConfiguration" }, - "build metadata file": { - "type": "string" - }, "media": { "$ref": "#/$defs/MediaConfiguration" }, diff --git a/schemas/database.schema.json b/schemas/database.schema.json index 7f6eb29..f00c731 100644 --- a/schemas/database.schema.json +++ b/schemas/database.schema.json @@ -1,41 +1,15 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://raw.githubusercontent.com/ortfo/db/v1.5.0/schemas/database.schema.json", + "$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.0/schemas/database.schema.json", "$ref": "#/$defs/Database", "$defs": { - "AnalyzedWork": { - "properties": { - "id": { - "type": "string" - }, - "builtAt": { - "type": "string" - }, - "descriptionHash": { - "type": "string" - }, - "metadata": { - "$ref": "#/$defs/WorkMetadata" - }, - "content": { - "$ref": "#/$defs/LocalizableContent" - }, - "Partial": { - "type": "boolean" - } + "Abbreviations": { + "additionalProperties": { + "type": "string" }, - "additionalProperties": false, "type": "object", - "required": [ - "id", - "builtAt", - "descriptionHash", - "metadata", - "content", - "Partial" - ], - "description": "AnalyzedWork represents a complete work, with analyzed mediae.", - "title": "AnalyzedWork" + "description": "Abbreviations represents the abbreviations declared in a description.md file.", + "title": "Abbreviations" }, "ColorPalette": { "properties": { @@ -112,7 +86,8 @@ "$ref": "#/$defs/ThumbnailsMap" }, "thumbnailsBuiltAt": { - "type": "string" + "type": "string", + "format": "date-time" }, "attributes": { "$ref": "#/$defs/MediaAttributes" @@ -121,6 +96,10 @@ "type": "boolean", "description": "whether the media has been analyzed" }, + "hash": { + "type": "string", + "description": "Hash of the media file, used for caching purposes. Could also serve as an integrity check.\nThe value is the MD5 hash, base64-encoded." + }, "content": { "type": "string", "description": "html" @@ -157,6 +136,7 @@ "thumbnailsBuiltAt", "attributes", "analyzed", + "hash", "content", "text", "title", @@ -166,7 +146,7 @@ }, "Database": { "additionalProperties": { - "$ref": "#/$defs/AnalyzedWork" + "$ref": "#/$defs/Work" }, "type": "object", "title": "Database" @@ -252,6 +232,9 @@ }, "footnotes": { "$ref": "#/$defs/Footnotes" + }, + "abbreviations": { + "$ref": "#/$defs/Abbreviations" } }, "additionalProperties": false, @@ -260,7 +243,8 @@ "layout", "blocks", "title", - "footnotes" + "footnotes", + "abbreviations" ], "title": "LocalizedContent" }, @@ -309,6 +293,41 @@ "type": "object", "title": "ThumbnailsMap" }, + "Work": { + "properties": { + "id": { + "type": "string" + }, + "builtAt": { + "type": "string", + "format": "date-time" + }, + "descriptionHash": { + "type": "string" + }, + "metadata": { + "$ref": "#/$defs/WorkMetadata" + }, + "content": { + "$ref": "#/$defs/LocalizableContent" + }, + "Partial": { + "type": "boolean" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "builtAt", + "descriptionHash", + "metadata", + "content", + "Partial" + ], + "description": "Work represents a given work in the database.", + "title": "Work" + }, "WorkMetadata": { "properties": { "aliases": { diff --git a/schemas/exporter.schema.json b/schemas/exporter.schema.json index b8225e3..37cd975 100644 --- a/schemas/exporter.schema.json +++ b/schemas/exporter.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://raw.githubusercontent.com/ortfo/db/v1.5.0/schemas/exporter.schema.json", + "$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.0/schemas/exporter.schema.json", "$ref": "#/$defs/ExporterManifest", "$defs": { "ExporterCommand": { diff --git a/schemas/tags.schema.json b/schemas/tags.schema.json index 07fe074..5db442e 100644 --- a/schemas/tags.schema.json +++ b/schemas/tags.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://raw.githubusercontent.com/ortfo/db/v1.5.0/schemas/tags.schema.json", + "$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.0/schemas/tags.schema.json", "$ref": "#/$defs/tags", "$defs": { "Tag": { diff --git a/schemas/technologies.schema.json b/schemas/technologies.schema.json index 26835e7..a9265bf 100644 --- a/schemas/technologies.schema.json +++ b/schemas/technologies.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://raw.githubusercontent.com/ortfo/db/v1.5.0/schemas/technologies.schema.json", + "$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.0/schemas/technologies.schema.json", "$ref": "#/$defs/technologies", "$defs": { "Technology": {