Skip to content

Commit

Permalink
🔖 Release v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed Apr 14, 2024
1 parent 888a9c8 commit 19d4240
Show file tree
Hide file tree
Showing 13 changed files with 455 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2024-04-14

### Added

- (S)FTP exporter
Expand Down Expand Up @@ -67,6 +69,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.1.0...HEAD
[1.2.0]: https://github.com/ortfo/db/-/releases/tag/v1.2.0
[1.1.0]: https://github.com/ortfo/db/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/ortfo/db/compare/v0.3.2...v1.0.0
[0.3.2]: https://github.com/ortfo/db/compare/v0.3.1...v0.3.2
Expand All @@ -75,3 +78,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.2.0...main
2 changes: 1 addition & 1 deletion meta.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package ortfodb

const Version = "1.1.0"
const Version = "1.2.0"
149 changes: 149 additions & 0 deletions packages/python/ortfodb/exporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
from typing import List, Optional, Any, Dict, TypeVar, Callable, Type, cast


T = TypeVar("T")


def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
assert isinstance(x, list)
return [f(y) for y in x]


def from_str(x: Any) -> str:
assert isinstance(x, str)
return x


def from_none(x: Any) -> Any:
assert x is None
return x


def from_union(fs, x):
for f in fs:
try:
return f(x)
except:
pass
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 from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x


def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()


class ExporterSchema:
log: Optional[List[str]]
"""Log a message. The first argument is the verb, the second is the color, the third is the
message.
"""
run: Optional[str]
"""Run a command in a shell"""

def __init__(self, log: Optional[List[str]], run: Optional[str]) -> None:
self.log = log
self.run = run

@staticmethod
def from_dict(obj: Any) -> 'ExporterSchema':
assert isinstance(obj, dict)
log = from_union([lambda x: from_list(from_str, x), from_none], obj.get("log"))
run = from_union([from_str, from_none], obj.get("run"))
return ExporterSchema(log, run)

def to_dict(self) -> dict:
result: dict = {}
if self.log is not None:
result["log"] = from_union([lambda x: from_list(from_str, x), from_none], self.log)
if self.run is not None:
result["run"] = from_union([from_str, from_none], self.run)
return result


class Exporter:
after: Optional[List[ExporterSchema]]
"""Commands to run after the build finishes. Go text template that receives .Data and
.Database, the built database.
"""
before: Optional[List[ExporterSchema]]
"""Commands to run before the build starts. Go text template that receives .Data"""

data: Optional[Dict[str, Any]]
"""Initial data"""

description: str
"""Some documentation about the exporter"""

name: str
"""The name of the exporter"""

requires: Optional[List[str]]
"""List of programs that are required to be available in the PATH for the exporter to run."""

verbose: Optional[bool]
"""If true, will show every command that is run"""

work: Optional[List[ExporterSchema]]
"""Commands to run during the build, for each work. Go text template that receives .Data and
.Work, the current work.
"""

def __init__(self, after: Optional[List[ExporterSchema]], before: Optional[List[ExporterSchema]], data: Optional[Dict[str, Any]], description: str, name: str, requires: Optional[List[str]], verbose: Optional[bool], work: Optional[List[ExporterSchema]]) -> None:
self.after = after
self.before = before
self.data = data
self.description = description
self.name = name
self.requires = requires
self.verbose = verbose
self.work = work

@staticmethod
def from_dict(obj: Any) -> 'Exporter':
assert isinstance(obj, dict)
after = from_union([lambda x: from_list(ExporterSchema.from_dict, x), from_none], obj.get("after"))
before = from_union([lambda x: from_list(ExporterSchema.from_dict, x), from_none], obj.get("before"))
data = from_union([lambda x: from_dict(lambda x: x, x), from_none], obj.get("data"))
description = from_str(obj.get("description"))
name = from_str(obj.get("name"))
requires = from_union([lambda x: from_list(from_str, x), from_none], obj.get("requires"))
verbose = from_union([from_bool, from_none], obj.get("verbose"))
work = from_union([lambda x: from_list(ExporterSchema.from_dict, x), from_none], obj.get("work"))
return Exporter(after, before, data, description, name, requires, verbose, work)

def to_dict(self) -> dict:
result: dict = {}
if self.after is not None:
result["after"] = from_union([lambda x: from_list(lambda x: to_class(ExporterSchema, x), x), from_none], self.after)
if self.before is not None:
result["before"] = from_union([lambda x: from_list(lambda x: to_class(ExporterSchema, x), x), from_none], self.before)
if self.data is not None:
result["data"] = from_union([lambda x: from_dict(lambda x: x, x), from_none], self.data)
result["description"] = from_str(self.description)
result["name"] = from_str(self.name)
if self.requires is not None:
result["requires"] = from_union([lambda x: from_list(from_str, x), from_none], self.requires)
if self.verbose is not None:
result["verbose"] = from_union([from_bool, from_none], self.verbose)
if self.work is not None:
result["work"] = from_union([lambda x: from_list(lambda x: to_class(ExporterSchema, x), x), from_none], self.work)
return result


def exporter_from_dict(s: Any) -> Exporter:
return Exporter.from_dict(s)


def exporter_to_dict(x: Exporter) -> Any:
return to_class(Exporter, x)
2 changes: 1 addition & 1 deletion packages/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ortfodb"
version = "1.1.0"
version = "1.2.0"
description = "ortfodb client library"
authors = ["Ewen Le Bihan <hey@ewen.works>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ortfodb"
version = "1.1.0"
version = "1.2.0"
edition = "2021"
description = "An ortfodb (https://github.com/ortfo/db) client library for Rust."
license = "MIT"
Expand Down
54 changes: 54 additions & 0 deletions packages/rust/src/exporter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Example code that deserializes and serializes the model.
// extern crate serde;
// #[macro_use]
// extern crate serde_derive;
// extern crate serde_json;
//
// use ortfodb::exporter;
//
// fn main() {
// let json = r#"{"answer": 42}"#;
// let model: exporter = serde_json::from_str(&json).unwrap();
// }

use serde::{Serialize, Deserialize};
use std::collections::HashMap;

#[derive(Serialize, Deserialize)]
pub struct Exporter {
/// Commands to run after the build finishes. Go text template that receives .Data and
/// .Database, the built database.
pub after: Option<Vec<ExporterSchema>>,

/// Commands to run before the build starts. Go text template that receives .Data
pub before: Option<Vec<ExporterSchema>>,

/// Initial data
pub data: Option<HashMap<String, Option<serde_json::Value>>>,

/// Some documentation about the exporter
pub description: String,

/// The name of the exporter
pub name: String,

/// List of programs that are required to be available in the PATH for the exporter to run.
pub requires: Option<Vec<String>>,

/// If true, will show every command that is run
pub verbose: Option<bool>,

/// Commands to run during the build, for each work. Go text template that receives .Data and
/// .Work, the current work.
pub work: Option<Vec<ExporterSchema>>,
}

#[derive(Serialize, Deserialize)]
pub struct ExporterSchema {
/// Log a message. The first argument is the verb, the second is the color, the third is the
/// message.
pub log: Option<Vec<String>>,

/// Run a command in a shell
pub run: Option<String>,
}
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ortfo/db",
"version": "1.1.0",
"version": "1.2.0",
"description": "ortfodb client library",
"scripts": {
"build": "tsc -p tsconfig.json --declaration --outDir dist"
Expand Down
Loading

0 comments on commit 19d4240

Please sign in to comment.