fix: daletl body spec and types

This commit is contained in:
Artemy Egorov 2024-07-28 22:30:19 +03:00
parent bac4c25681
commit 1626ef38eb
6 changed files with 9 additions and 9 deletions

2
libs/rust/Cargo.lock generated
View file

@ -4,7 +4,7 @@ version = 3
[[package]] [[package]]
name = "dalet" name = "dalet"
version = "1.0.0-pre1" version = "1.0.0-pre2"
dependencies = [ dependencies = [
"serde", "serde",
] ]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "dalet" name = "dalet"
version = "1.0.0-pre1" version = "1.0.0-pre2"
edition = "2021" edition = "2021"
authors = ["artegoser"] authors = ["artegoser"]
license = "MIT" license = "MIT"

View file

@ -16,7 +16,7 @@ impl Tag {
#[derive(Debug)] #[derive(Debug)]
pub enum Body { pub enum Body {
Text(String), Text(String),
Tag(Box<Tag>), Tags(Vec<Tag>),
Null, Null,
} }
@ -27,8 +27,8 @@ impl Serialize for Body {
{ {
match *self { match *self {
Body::Text(ref text) => serializer.serialize_str(text), Body::Text(ref text) => serializer.serialize_str(text),
Body::Tag(ref tag) => tag.serialize(serializer), Body::Tags(ref tag) => tag.serialize(serializer),
Body::Null => serializer.serialize_str("null"), Body::Null => serializer.serialize_none(),
} }
} }
} }
@ -48,7 +48,7 @@ impl Serialize for Argument {
match *self { match *self {
Argument::Text(ref text) => serializer.serialize_str(text), Argument::Text(ref text) => serializer.serialize_str(text),
Argument::Number(number) => serializer.serialize_i8(number), Argument::Number(number) => serializer.serialize_i8(number),
Argument::Null => serializer.serialize_str("null"), Argument::Null => serializer.serialize_none(),
} }
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "@txtdot/dalet", "name": "@txtdot/dalet",
"version": "1.0.0-pre0", "version": "1.0.0-pre1",
"description": "Dalet implementation in typescript", "description": "Dalet implementation in typescript",
"main": "dist/lib.js", "main": "dist/lib.js",
"types": "dist/lib.d.ts", "types": "dist/lib.d.ts",

View file

@ -3,7 +3,7 @@ import { bodyToRaw } from "../utils";
export type Root = Tag[]; export type Root = Tag[];
export type Argument = string | number | null; export type Argument = string | number | null;
export type Body = Tag[] | null; export type Body = string | Tag[] | null;
export interface Tag { export interface Tag {
id: number; id: number;

View file

@ -21,7 +21,7 @@ All tags specification is in [Tags](./tags.md).
```typescript ```typescript
interface Tag { interface Tag {
id: number; id: number;
body: Tag[] | null; body: string | Tag[] | null;
argument: string | number | null; argument: string | number | null;
} }
``` ```