
Security News
Frontier AI Is Now Critical Infrastructure
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.
@nldoc/event-types
Advanced tools
TypeScript type definitions for NLdoc events. This library provides Zod schemas and TypeScript types for validating and working with NLdoc event data, ensuring type safety and runtime validation for event-driven document processing workflows.
This package defines standardized event types for the NLdoc document processing system:
All events include common fields (timestamp, traceId) and are validated using Zod schemas for both compile-time type safety and runtime validation.
Install the package via npm:
npm install @nldoc/event-types
Or using yarn:
yarn add @nldoc/event-types
import {
DoneEvent,
ProgressEvent,
ErrorEvent,
Event,
EventType
} from '@nldoc/event-types';
// Parse and validate a done event
const rawEvent = {
timestamp: "2024-01-15T10:30:00Z",
traceId: "abc123",
type: "https://event.spec.nldoc.nl/done",
context: {
contentType: "application/pdf",
location: "https://storage.example.com/document.pdf"
}
};
try {
const typedEvent: DoneEvent = await DoneEvent.parseAsync(rawEvent);
console.log("Document processed successfully:", typedEvent.context.location);
} catch (error) {
console.error("Invalid event format:", error);
}
// Handle different event types
async function handleEvent(eventData: unknown) {
const event = await Event.parseAsync(eventData);
switch (event.type) {
case EventType.QUEUED:
console.log("Document queued for processing");
break;
case EventType.PROGRESS:
console.log(`Progress: ${event.context.position}/${event.context.target} ${event.context.subject}s`);
break;
case EventType.DONE:
console.log("Processing complete:", event.context.location);
break;
case EventType.ERROR:
console.error("Processing error:", event.context);
break;
}
}
Indicates a document has been queued for processing.
{
timestamp: string; // ISO 8601 datetime
traceId: string; // Unique trace identifier
type: "https://event.spec.nldoc.nl/queued";
context: {}; // Empty context object
}
Reports processing progress for pages or documents.
{
timestamp: string;
traceId: string;
type: "https://event.spec.nldoc.nl/progress";
context: {
subject: "page" | "document"; // What is being processed
target: number; // Total number to process
position: number; // Current position
};
}
Signals successful completion with result information.
{
timestamp: string;
traceId: string;
type: "https://event.spec.nldoc.nl/done";
context: {
contentType: string; // MIME type of the result
location: string; // URL where result can be accessed
};
}
Handles various error scenarios with detailed context.
{
timestamp: string;
traceId: string;
type: "https://event.spec.nldoc.nl/error";
context: ErrorContext; // Discriminated union of error types
}
The ErrorContext supports multiple error scenarios:
Clone the repository:
git clone https://gitlab.com/logius/nldoc/lib/typescript/event-types.git
cd event-types
Install dependencies:
npm install
Build the project:
npm run build
npm test - Run the test suite with Vitest and coveragenpm run test:watch - Run tests in watch modenpm run build - Compile TypeScript to JavaScriptnpm run build:check - Type-check without buildingnpm 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 issuesThe project is organized as follows:
src/: Contains the TypeScript source files
src/__test__/: Test helpers and utilitiessrc/**/*.spec.ts: Test filessrc/events.ts: Main event type definitionssrc/index.ts: Package exportsdist/: Compiled JavaScript outputWhen adding new event types:
src/events.tsEventType enumEvent unionThe types are tested against valid and invalid examples from the NLdoc event specification. Test data is automatically downloaded on first run.
Run the test suite:
npm test
The tests validate:
Event - Union type of all event typesQueuedEvent, DoneEvent, ProgressEvent, ErrorEvent - Individual event typesErrorContext - Discriminated union of error contextsEventType - Enum of event type URLsAll types include corresponding Zod schemas for runtime validation:
Event.parseAsync() - Validate any eventDoneEvent.parseAsync() - Validate done eventsWe welcome contributions! Please ensure:
npm test)npm run format:check)npm run lint)This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
FAQs
NLdoc's Type Definitions for Events
We found that @nldoc/event-types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.