Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions packages/oxa-core/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@ import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const CLI_PATH = join(__dirname, "..", "dist", "cli.js");

// Valid minimal document
// Valid minimal document (only required fields)
const validDocument = {
type: "Document",
metadata: {},
title: [{ type: "Text", value: "Hello", classes: [], data: {} }],
children: [],
};

const validYaml = `type: Document
metadata: {}
title:
- type: Text
value: Hello
classes: []
data: {}
children: []
`;

Expand Down Expand Up @@ -148,9 +140,7 @@ describe("oxa validate", () => {
const heading = {
type: "Heading",
level: 1,
classes: [],
data: {},
children: [{ type: "Text", value: "Title", classes: [], data: {} }],
children: [{ type: "Text", value: "Title" }],
};
const { exitCode } = await execa(
"node",
Expand Down
29 changes: 5 additions & 24 deletions packages/oxa-core/src/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,21 @@ import {
getTypeNames,
} from "./validate.js";

// Valid minimal document
// Valid minimal document (only required fields)
const validDocument = {
type: "Document",
metadata: {},
title: [{ type: "Text", value: "Hello", classes: [], data: {} }],
children: [],
};

// Valid document with content
// Valid document with content (using minimal nested objects)
const validDocumentWithContent = {
type: "Document",
metadata: { author: "Test" },
title: [{ type: "Text", value: "Test Document", classes: [], data: {} }],
title: [{ type: "Text", value: "Test Document" }],
children: [
{
type: "Paragraph",
classes: [],
data: {},
children: [{ type: "Text", value: "Hello world", classes: [], data: {} }],
children: [{ type: "Text", value: "Hello world" }],
},
],
};
Expand All @@ -51,7 +47,6 @@ describe("validate", () => {
const result = validate({ type: "Document" });
expect(result.valid).toBe(false);
expect(result.errors.length).toBeGreaterThan(0);
expect(result.errors.some((e) => e.message.includes("title"))).toBe(true);
expect(result.errors.some((e) => e.message.includes("children"))).toBe(
true,
);
Expand All @@ -74,9 +69,7 @@ describe("validate", () => {
const heading = {
type: "Heading",
level: 1,
classes: [],
data: {},
children: [{ type: "Text", value: "Title", classes: [], data: {} }],
children: [{ type: "Text", value: "Title" }],
};
const result = validate(heading, { type: "Heading" });
expect(result.valid).toBe(true);
Expand Down Expand Up @@ -122,12 +115,6 @@ describe("validateYaml", () => {
it("returns valid for correct YAML", () => {
const yaml = `
type: Document
metadata: {}
title:
- type: Text
value: Hello
classes: []
data: {}
children: []
`;
const result = validateYaml(yaml);
Expand Down Expand Up @@ -163,12 +150,6 @@ describe("validateFile", () => {
writeFileSync(
yamlFile,
`type: Document
metadata: {}
title:
- type: Text
value: Hello
classes: []
data: {}
children: []
`,
);
Expand Down
40 changes: 22 additions & 18 deletions packages/oxa-types-py/src/oxa_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ class Document(BaseModel):
data: dict[str, Any] | None = Field(
default=None, description="Arbitrary key-value data attached to the node."
)
metadata: dict[str, Any] = Field(description="Arbitrary document metadata.")
title: list["Inline"] = Field(description="The document title as inline content.")
metadata: dict[str, Any] | None = Field(
default=None, description="Arbitrary document metadata."
)
title: list["Inline"] | None = Field(
default=None, description="The document title as inline content."
)
children: list["Block"] = Field(description="The block content of the document.")


Expand All @@ -41,11 +45,11 @@ class Heading(BaseModel):
id: str | None = Field(
default=None, description="A unique identifier for the node."
)
classes: list[str] = Field(
description="A list of class names for styling or semantics."
classes: list[str] | None = Field(
default=None, description="A list of class names for styling or semantics."
)
data: dict[str, Any] = Field(
description="Arbitrary key-value data attached to the node."
data: dict[str, Any] | None = Field(
default=None, description="Arbitrary key-value data attached to the node."
)
level: int = Field(description="The heading level (1-6).")
children: list["Inline"] = Field(description="The inline content of the heading.")
Expand All @@ -60,11 +64,11 @@ class Paragraph(BaseModel):
id: str | None = Field(
default=None, description="A unique identifier for the node."
)
classes: list[str] = Field(
description="A list of class names for styling or semantics."
classes: list[str] | None = Field(
default=None, description="A list of class names for styling or semantics."
)
data: dict[str, Any] = Field(
description="Arbitrary key-value data attached to the node."
data: dict[str, Any] | None = Field(
default=None, description="Arbitrary key-value data attached to the node."
)
children: list["Inline"] = Field(description="The inline content of the paragraph.")

Expand All @@ -78,11 +82,11 @@ class Strong(BaseModel):
id: str | None = Field(
default=None, description="A unique identifier for the node."
)
classes: list[str] = Field(
description="A list of class names for styling or semantics."
classes: list[str] | None = Field(
default=None, description="A list of class names for styling or semantics."
)
data: dict[str, Any] = Field(
description="Arbitrary key-value data attached to the node."
data: dict[str, Any] | None = Field(
default=None, description="Arbitrary key-value data attached to the node."
)
children: list["Inline"] = Field(description="The inline content to emphasize.")

Expand All @@ -96,11 +100,11 @@ class Text(BaseModel):
id: str | None = Field(
default=None, description="A unique identifier for the node."
)
classes: list[str] = Field(
description="A list of class names for styling or semantics."
classes: list[str] | None = Field(
default=None, description="A list of class names for styling or semantics."
)
data: dict[str, Any] = Field(
description="Arbitrary key-value data attached to the node."
data: dict[str, Any] | None = Field(
default=None, description="Arbitrary key-value data attached to the node."
)
value: str = Field(description="The text content.")

Expand Down
30 changes: 20 additions & 10 deletions packages/oxa-types-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ pub struct Document {
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
/// Arbitrary document metadata.
pub metadata: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<serde_json::Value>,
/// The document title as inline content.
pub title: Vec<Inline>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<Vec<Inline>>,
/// The block content of the document.
pub children: Vec<Block>,
}
Expand All @@ -40,9 +42,11 @@ pub struct Heading {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// A list of class names for styling or semantics.
pub classes: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<String>>,
/// Arbitrary key-value data attached to the node.
pub data: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
/// The heading level (1-6).
pub level: i64,
/// The inline content of the heading.
Expand All @@ -58,9 +62,11 @@ pub struct Paragraph {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// A list of class names for styling or semantics.
pub classes: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<String>>,
/// Arbitrary key-value data attached to the node.
pub data: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
/// The inline content of the paragraph.
pub children: Vec<Inline>,
}
Expand All @@ -74,9 +80,11 @@ pub struct Strong {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// A list of class names for styling or semantics.
pub classes: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<String>>,
/// Arbitrary key-value data attached to the node.
pub data: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
/// The inline content to emphasize.
pub children: Vec<Inline>,
}
Expand All @@ -90,9 +98,11 @@ pub struct Text {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// A list of class names for styling or semantics.
pub classes: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<String>>,
/// Arbitrary key-value data attached to the node.
pub data: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>,
/// The text content.
pub value: String,
}
Expand Down
20 changes: 10 additions & 10 deletions packages/oxa-types-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export interface Document {
/**
* Arbitrary document metadata.
*/
metadata: Record<string, unknown>;
metadata?: Record<string, unknown>;
/**
* The document title as inline content.
*/
title: Inline[];
title?: Inline[];
/**
* The block content of the document.
*/
Expand All @@ -54,11 +54,11 @@ export interface Heading {
/**
* A list of class names for styling or semantics.
*/
classes: string[];
classes?: string[];
/**
* Arbitrary key-value data attached to the node.
*/
data: Record<string, unknown>;
data?: Record<string, unknown>;
/**
* The heading level (1-6).
*/
Expand All @@ -84,11 +84,11 @@ export interface Paragraph {
/**
* A list of class names for styling or semantics.
*/
classes: string[];
classes?: string[];
/**
* Arbitrary key-value data attached to the node.
*/
data: Record<string, unknown>;
data?: Record<string, unknown>;
/**
* The inline content of the paragraph.
*/
Expand All @@ -110,11 +110,11 @@ export interface Strong {
/**
* A list of class names for styling or semantics.
*/
classes: string[];
classes?: string[];
/**
* Arbitrary key-value data attached to the node.
*/
data: Record<string, unknown>;
data?: Record<string, unknown>;
/**
* The inline content to emphasize.
*/
Expand All @@ -136,11 +136,11 @@ export interface Text {
/**
* A list of class names for styling or semantics.
*/
classes: string[];
classes?: string[];
/**
* Arbitrary key-value data attached to the node.
*/
data: Record<string, unknown>;
data?: Record<string, unknown>;
/**
* The text content.
*/
Expand Down
2 changes: 0 additions & 2 deletions schema/Document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ properties:
$ref: "./Block.yaml"
required:
- type
- metadata
- title
- children
2 changes: 0 additions & 2 deletions schema/Heading.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ required:
- type
- level
- children
- classes
- data
2 changes: 0 additions & 2 deletions schema/Paragraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ properties:
required:
- type
- children
- classes
- data
2 changes: 0 additions & 2 deletions schema/Strong.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ properties:
required:
- type
- children
- classes
- data
2 changes: 0 additions & 2 deletions schema/Text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ properties:
required:
- type
- value
- classes
- data
Loading