- TypeScript 97.7%
- JavaScript 2.3%
chore(deps): update dependency @redocly/cli to v2.14.2 See merge request logius/nldoc/spec/event!446 |
||
|---|---|---|
| .vscode | ||
| src | ||
| test | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .npmrc | ||
| .nvmrc | ||
| .prettierignore | ||
| .releaserc | ||
| CHANGELOG.md | ||
| CODEOWNERS | ||
| eslint.config.mjs | ||
| example-generator.yaml | ||
| index.ts | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| prettier.config.mjs | ||
| README.md | ||
| renovate.json | ||
| tsconfig.dist.json | ||
| tsconfig.json | ||
NLdoc Event Specification
An OpenAPI 3.1.0 compatible specification for describing conversion events. This TypeScript library provides a comprehensive schema framework for representing events that occur during document conversion processes.
Overview
This specification defines a standardized schema for describing various types of conversion events including:
- Queued events (conversion has been queued for processing)
- Progress events (tracking conversion progress for pages/documents)
- Completion events (conversion finished with result location)
- Error events (handling various error scenarios during conversion)
The specification provides a consistent, type-safe way to describe and handle conversion events, enabling better monitoring, error handling, and integration with document conversion systems.
Getting Started
Prerequisites
- Node.js >= 22.0.0 < 23.0.0
- npm >= 10.0.0 < 12.0.0
Installation
Install the package via npm:
npm install @nldoc/event-specification
Or using yarn:
yarn add @nldoc/event-specification
Basic Usage
import {
specification,
validExamples,
invalidExamples
} from '@nldoc/event-specification';
// Access the OpenAPI specification
console.log(specification);
// Use valid examples for testing
console.log(validExamples);
// Use invalid examples for validation testing
console.log(invalidExamples);
Accessing the OpenAPI Specification
After building the project, the complete OpenAPI 3.1.0 specification is available at:
# Build the project first
npm run build
# The OpenAPI specification is now available at:
# - public/openapi.json (JSON format)
# - public/index.html (Interactive HTML documentation)
Development
Local Setup
-
Clone the repository:
git clone https://gitlab.com/logius/nldoc/spec/event.git cd event-specification -
Install dependencies:
npm install -
Build the project:
npm run build
Available Scripts
npm run test- Run the test suite with Vitest and coveragenpm run build- Build the OpenAPI specification, examples, and TypeScript filesnpm run lint- Lint the codebase using ESLintnpm run format- Format code using Prettiernpm run format:check- Check code formattingnpm run fix- Auto-fix linting and formatting issuesnpm run lint:openapi- Generate an HTML report for the OpenAPI specification
Building Components
The build process consists of several steps:
- OpenAPI Generation:
npm run build:openapi- Generates the OpenAPI JSON specification - Example Extraction:
npm run build:examples- Extracts valid and invalid test examples - TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
- Documentation:
npm run build:redocly- Generates HTML documentation using Redocly
Event Types
The specification supports various conversion event types:
Core Events
- queued: Indicates a conversion has been queued for processing
- done: Conversion has finished successfully with result location and content type
- progress: Reports progress during conversion (page/document level)
- error: Indicates an error occurred during conversion
Error Contexts
The error event supports multiple error contexts with specific error codes:
- invalid_content_type: Content type of file to be converted is not supported
- Includes actual content type and expected content types
- too_many_pages: Document exceeds the maximum page limit
- Includes actual page count and limit
- unexpected: An unexpected error has occurred during conversion
Event Structure
All events follow a standard structure:
type: The event type URL (e.g.,https://event.spec.nldoc.nl/queued)timestamp: ISO 8601 formatted timestamptraceId: Unique identifier for tracing the conversion requestcontext: Event-specific context data
Example event:
{
"type": "https://event.spec.nldoc.nl/done",
"timestamp": "2025-03-31T12:54:39Z",
"traceId": "74d30da1-f18d-4aa2-8656-1d3bea92a37c",
"context": {
"contentType": "text/html",
"location": "c54cf74d-a79f-498c-a9a9-ee83f0dadf82"
}
}
API Documentation
The generated OpenAPI specification can be viewed:
- Locally: After building, open
public/index.htmlin your browser - Online: View the latest release documentation
Testing
Run the test suite:
npm test
Contributing
We welcome contributions! Please ensure:
- All tests pass (
npm test) - Code is properly formatted (
npm run format:check) - Linting rules are followed (
npm run lint) - OpenAPI specification is valid (
npm run lint:openapi)
License
This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
Acknowledgements
- Built on OpenAPI 3.1.0 specification
- Uses Redocly for API documentation generation