Registry / database / luren-schema

luren-schema

JSON →
library0.2.8jsnpmunverified

A TypeScript module for Luren that uses decorators to define schemas, metadata, and validation for objects. Current stable version 0.2.8 (low release cadence). Key differentiator: uses decorators to inject type metadata at class definition, enabling schema generation (`getJsSchema`) and runtime operations (validate, serialize, deserialize) without separate schema files. Requires experimentalDecorators enabled. Built-in types: string, boolean, number, integer, date, array, object. Limited community adoption.

npm install luren-schema
INSTALL
IMPORT
SIG · LUREN-SCHEMA
L
luren-schema
databasejavascriptv0.2.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Schema
import { Schema } from 'luren-schema'
const { Schema } = require('luren-schema')
ESM-only; requires TypeScript decorators enabled ('experimentalDecorators': true).
Prop
import { Prop } from 'luren-schema'
import Prop from 'luren-schema'
Named export, not default.
getJsSchema
import { getJsSchema } from 'luren-schema'
Function to generate JavaScript schema from decorated class.
JsTypes
import { JsTypes } from 'luren-schema'
const JsTypes = require('luren-schema').JsTypes
Contains validate, serialize, deserialize methods.

Defines a Person class with decorators, generates a schema, validates, serializes, and deserializes an instance.

import { Schema, Prop, getJsSchema, JsTypes } from 'luren-schema'; @Schema({ title: 'person', additionalProperties: true }) class Person { @Prop({ required: true, type: 'string' }) public name: string; @Prop({ required: true }) public password: string; constructor(name: string, password: string) { this.name = name; this.password = password; } public greeting() { console.log(`Hi, I'm ${this.name}`); } } const person = new Person('My Name', 'my_password'); const schema = getJsSchema(Person); const [valid, errorMsg] = JsTypes.validate(person, schema); const data = JsTypes.serialize(person, schema); const p = JsTypes.deserialize({ name: 'John', password: 'encrypted_passwd' }, schema); p.greeting();
Debug
Known issues
breakingPackage name is 'luren-schema' but exports are from root; no subpath exports.
fix
Import directly from 'luren-schema' (no subpaths).
affects: 0.x
deprecatedUses TypeScript experimental decorators, which may change in future TS versions.
fix
Consider using libraries with standard decorators if TS stabilizes them.
affects: >=0.2.0
gotchaAll properties must be public or have decorators; private properties without @Prop are ignored.
fix
Ensure every property you want in the schema has @Prop decorator.
affects: >=0.2.0
gotchaSerialization does not include password property by default; only public properties with @Prop are serialized.
fix
Add @Prop decorator with serialization options if needed.
affects: >=0.2.0
gotchaValidation returns [true] or [false, string] tuple — check length or first element.
fix
Use array destructuring: const [valid, error] = JsTypes.validate(obj, schema);
affects: >=0.1.0
Errors
Common errors & fixes
Support for the experimental syntax 'decorators' isn't currently enabled
TypeScript needs decorator support enabled.
fix
Add '"experimentalDecorators": true' to tsconfig.json.
TypeError: Class constructor Person cannot be invoked without 'new'
Importing class without instantiating; likely using reflection requires correct instantiation.
fix
Ensure you create an instance with 'new Person(...)' before calling JsTypes methods.
Cannot find module 'luren-schema'
Package not installed or missing from node_modules.
fix
Run 'npm install luren-schema' and ensure import path is correct.
Upgrade
Version history
0.2.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
luren-schema — npm install luren-schema · libregistry