Typescript typedef and meta-data generator for LDAP Schema
It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.
How to use
npm i ldap-schema-ts-generator
import { Client, IClientConfig } from "ldap-ts-client";
import {
getSchemaAttributes,
getSchemaClasses,
generateInterfaceFiles,
} from "ldap-schema-ts-generator";
const options = {
user: "**********",
pass: "************",
ldapServerUrl: "ldap://domain.com",
baseDn: "DC=domain,DC=com",
};
const client = new Client(options);
const objectAttributes = await getSchemaAttributes({ client });
const objectClasses = await getSchemaClasses({ client });
await generateInterfaceFiles({ objectAttributes, objectClasses });
}
API
use api website for more details
Functionalities
- generate typescript interfaces for each object class
- generate relations between attributes (json)
- generate graphql schema:
- type for each object class
- basic CRUD operations for each object class
- generate typescript enum for supported:
- controls
- capabilities
- extensions
- policies
- structural classes
Sample Generated File:
import { Top } from "./Top";
import { MsExchBaseClass } from "./MsExchBaseClass";
export interface Container extends Top, MsExchBaseClass {
readonly cn: string;
x500RDN?: string;
msExchTemplateRDNs?: string[];
msExchPolicyList?: object[];
containerInfo?: number;
"msDS-ObjectReference"?: object[];
}
TODO:
Know Issues
- when extends to another interface sometimes a field is optional but in other interface is not so typescript gives compatibility warning which prevent generated code to be executed with typescript complier. to fix the problem an extra comment
// @ts-ignore
added in top of all generated interfaces
Credit