• TypeScript 97.7%
  • JavaScript 2.3%
Find a file
DigiToegankelijk NLdoc d45fed3bdc Merge branch 'renovate/redocly-cli-2.x-lockfile' into 'main'
chore(deps): update dependency @redocly/cli to v2.14.2

See merge request logius/nldoc/spec/event!446
2025-12-30 20:19:22 +00:00
.vscode chore: newline 2025-04-01 16:22:31 +02:00
src fix: fix casing of contentType on done-event 2025-05-06 20:42:31 +02:00
test fix: import assertion -> with 2025-04-03 21:46:14 +02:00
.editorconfig chore: set .editorconfig 2025-04-22 01:06:03 +00:00
.gitignore feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00
.gitlab-ci.yml fix: update references (GitLab migration) 2025-04-03 21:09:24 +02:00
.npmrc fix: update references (GitLab migration) 2025-04-03 21:09:24 +02:00
.nvmrc chore(deps): update node.js to v24 2025-11-01 05:11:13 +00:00
.prettierignore feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00
.releaserc feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00
CHANGELOG.md chore(release): 3.0.32 2025-05-12 14:20:23 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:25:41 +00:00
eslint.config.mjs fix: update references (GitLab migration) 2025-04-03 21:09:24 +02:00
example-generator.yaml feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00
index.ts fix: import assertion -> with 2025-04-03 21:46:14 +02:00
LICENSE chore: add license 2025-04-15 00:18:39 +02:00
package-lock.json chore(deps): update dependency @redocly/cli to v2.14.2 2025-12-30 20:09:51 +00:00
package.json chore(deps): update node.js to v24 2025-11-01 05:11:13 +00:00
prettier.config.mjs fix: update references (GitLab migration) 2025-04-03 21:09:24 +02:00
README.md docs: update readme 2025-08-18 11:58:56 +02:00
renovate.json chore: npm install twice 2025-11-05 14:07:59 +00:00
tsconfig.dist.json feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00
tsconfig.json feat(NLD-740): specification of conversion events 2025-03-31 16:34:04 +02:00

NLdoc Event Specification

pipeline status coverage report Latest Release NPM Version

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

  1. Clone the repository:

    git clone https://gitlab.com/logius/nldoc/spec/event.git
    cd event-specification
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Available Scripts

  • npm run test - Run the test suite with Vitest and coverage
  • npm run build - Build the OpenAPI specification, examples, and TypeScript files
  • npm run lint - Lint the codebase using ESLint
  • npm run format - Format code using Prettier
  • npm run format:check - Check code formatting
  • npm run fix - Auto-fix linting and formatting issues
  • npm run lint:openapi - Generate an HTML report for the OpenAPI specification

Building Components

The build process consists of several steps:

  1. OpenAPI Generation: npm run build:openapi - Generates the OpenAPI JSON specification
  2. Example Extraction: npm run build:examples - Extracts valid and invalid test examples
  3. TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
  4. 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 timestamp
  • traceId: Unique identifier for tracing the conversion request
  • context: 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:

  1. Locally: After building, open public/index.html in your browser
  2. Online: View the latest release documentation

Testing

Run the test suite:

npm test

Contributing

We welcome contributions! Please ensure:

  1. All tests pass (npm test)
  2. Code is properly formatted (npm run format:check)
  3. Linting rules are followed (npm run lint)
  4. 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