Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ldap-schema-ts-generator

saostad19MIT4.0.14TypeScript support: included

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.

ldap, schema, typescript, interface, type, definition, generator, type, active, directory

readme

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:

`ts Account.ts import { Top } from "./Top"; import { MsExchBaseClass } from "./MsExchBaseClass";

/** - object class: container

    • child of class: top
    • dn: CN=Container,CN=Schema,CN=Configuration,DC=ki,DC=local / export interface Container extends Top, MsExchBaseClass { /* - attributeSyntax: 2.5.5.12
      • attributeID: 2.5.4.3
      • adminDisplayName: Common-Name
      • adminDescription: Common-Name
      • dn: CN=Common-Name,CN=Schema,CN=Configuration,DC=ki,DC=local */ readonly cn: string;

    /** - attributeSyntax: 2.5.5.12

      • attributeID: 1.2.840.113556.1.2.508
      • adminDisplayName: ms-Exch-X500-RDN
      • adminDescription: ms-Exch-X500-RDN
      • dn: CN=ms-Exch-X500-RDN,CN=Schema,CN=Configuration,DC=ki,DC=local */ x500RDN?: string;

    /** - attributeSyntax: 2.5.5.4

      • attributeID: 1.2.840.113556.1.4.7000.102.65
      • adminDisplayName: ms-Exch-Template-RDNs
      • adminDescription: ms-Exch-Template-RDNs
      • dn: CN=ms-Exch-Template-RDNs,CN=Schema,CN=Configuration,DC=ki,DC=local */ msExchTemplateRDNs?: string[];

    /** - attributeSyntax: 2.5.5.1

      • attributeID: 1.2.840.113556.1.4.7000.102.50004
      • adminDisplayName: ms-Exch-Policy-List
      • adminDescription: ms-Exch-Policy-List
      • dn: CN=ms-Exch-Policy-List,CN=Schema,CN=Configuration,DC=ki,DC=local */ msExchPolicyList?: object[];

    /** - attributeSyntax: 2.5.5.9

      • attributeID: 1.2.840.113556.1.2.296
      • adminDisplayName: ms-Exch-Container-Info
      • adminDescription: ms-Exch-Container-Info
      • dn: CN=ms-Exch-Container-Info,CN=Schema,CN=Configuration,DC=ki,DC=local */ containerInfo?: number;

    /** - attributeSyntax: 2.5.5.1

      • attributeID: 1.2.840.113556.1.4.1840
      • adminDisplayName: ms-DS-Object-Reference
      • adminDescription: A link to the object that uses the data stored in the object that contains this attribute.
      • dn: CN=ms-DS-Object-Reference,CN=Schema,CN=Configuration,DC=ki,DC=local */ "msDS-ObjectReference"?: object[]; } `

TODO:

  • <input disabled="" type="checkbox"> handle relations (forwardLink/BackLink) via linkID field
  • <input checked="" disabled="" type="checkbox"> change relation DN fields type from object to string
  • <input checked="" disabled="" type="checkbox"> generate Enum for ldap controls supported by server from RootDSE
  • <input checked="" disabled="" type="checkbox"> generate Enum for ldap capabilities supported by server from RootDSE
  • <input checked="" disabled="" type="checkbox"> generate Enum for ldap extensions supported by server from RootDSE
  • <input checked="" disabled="" type="checkbox"> generate Enum for ldap policies supported by server from RootDSE
  • <input disabled="" type="checkbox"> generate Base DNs from RootDSE (List of DNs of all the naming contexts and application partitions maintained by the DC)
  • <input disabled="" type="checkbox"> generate naming contexts fields from RootDSE (e.g. defaultNamingContext, configurationNamingContext, schemaNamingContext, rootNamingContext)
  • <input disabled="" type="checkbox"> Active Directory create a functionality to fetch all meta data about server ref
  • <input disabled="" type="checkbox"> Active Directory Group Type Flags and UserAccountControl flags
  • <input disabled="" type="checkbox"> add option to customize generated file names with prefix/postfix (now it 's using Pascal case of ldap display name as interface and file name)
  • <input disabled="" type="checkbox"> create out folders if not exist instead of throwing error
  • <input checked="" disabled="" type="checkbox"> generate graphql types and CRUD operations
    • <input checked="" disabled="" type="checkbox"> generate Type for each objectClass in schema
      • <input checked="" disabled="" type="checkbox"> generate custom scalar types (e.g. Date)
      • <input checked="" disabled="" type="checkbox"> respect inheritance
      • <input disabled="" type="checkbox"> respect relations by linkID attribute
    • <input checked="" disabled="" type="checkbox"> use dn as identification field
    • <input checked="" disabled="" type="checkbox"> generate general operations for each Type:
      • <input checked="" disabled="" type="checkbox"> Query get all
      • <input checked="" disabled="" type="checkbox"> Query get by dn
      • <input checked="" disabled="" type="checkbox"> Mutation delete by dn
      • <input checked="" disabled="" type="checkbox"> Mutation update by dn (input only not readonly attributes)

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

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

v4.0.13

16 August 2022

v4.0.12

16 August 2022

v4.0.11

20 July 2022

v4.0.10

19 July 2022

  • fix: create output folders recursively instead of just fail c006380
  • doc: change log f7bc0d7

v4.0.9

11 July 2022

v4.0.8

2 March 2021

v4.0.7

10 June 2020

v4.0.6

8 June 2020

  • moved USA to top in the iso country codes c5593ac
  • doc: change log 25e4257

v4.0.5

7 June 2020

v4.0.4

4 June 2020

  • fix: default value assignment for generateInterfaceFiles func ebba78d
  • doc: change log 2d698ba

v4.0.3

4 June 2020

v4.0.2

4 June 2020

  • fix: replace '@ts-ignore' with '@ts-expect-error' in generated ts interface files 600d986
  • doc: change log 57e7ed9

v4.0.1

4 June 2020

v4.0.0

4 June 2020

v4.0.0-beta2

4 June 2020

v4.0.0-beta1

4 June 2020

  • Breaking change: breaking: api changed to follow soul of statefull connection of LDAP protocol c282f36
  • doc: change log 5251671

v3.9.1

3 June 2020

v3.9.0

2 June 2020

  • feat: generate json file for ISO-3166 country codes that used in active-directory "c", "co", "countryCode" attributes becfa83
  • doc: change log 190dbbc

v3.8.0

1 June 2020

  • feat: added a list of iso-3166 country codes for future uses ce2c172

v3.8.0-beta

1 June 2020

  • doc: added comments to explain functionalities 7ab50d4
  • feat: generate active directory specific function to get iso country a927e83
  • doc: change log e0dceec

v3.7.4

29 May 2020

  • fix: removed non editable distinguishedName field from update input e89fff0
  • doc: change log c778d82

v3.7.3

25 May 2020

  • fix: generated graphql resolver types 8a197cf
  • doc: change log 6a0934f

v3.7.2

25 May 2020

  • fix: generated graphql resolver has un-necessary required fields e0bb201
  • doc: change log 5a6f494

v3.7.1

25 May 2020

v3.7.0

18 May 2020

v3.7.0-beta1

18 May 2020

v3.6.0

18 May 2020

  • feat: generate graphql used custom scalar 4f7990b
  • doc: change log fe437c2

v3.5.2

14 May 2020

v3.5.1

14 May 2020

  • fix: parssing generate-graphql-type-files parametters 8215e34
  • doc: change log 220cb5a

v3.5.0

13 May 2020

  • feat: added exceptions base on OID for graphql typemap 70e4d8f
  • fix: wrong info in comments 7e5675f
  • doc: change log 237e596

v3.4.1

12 May 2020

  • package: updated 0d4f0e1
  • generate ldap date-time attributes as graphql Date 81237a9
  • doc: change log 058fffc

v3.4.0

30 April 2020

  • feat: added more meta data in attributes info fe32d2c
  • doc: change log 3df4082

v3.3.0

30 April 2020

  • feat: generate schema attributes meta data 47e5a7b
  • fix: graphql types now values are array to be easier to use in production efed2da
  • doc: change log 3618949

v3.2.0

28 April 2020

  • package: updated 07f3412
  • middle: bug fix generating graphql types 6ba04e2
  • feat: generate client-side query and mutations callsed generateClientSideDocuments e06f5ef

v3.1.2

25 April 2020

  • fix: camelcase graphql fields to mach best practices 3a79a56
  • doc: change log 5521425

v3.1.1

24 April 2020

  • fix: graphql operations are now camelcase for compatibility by best practices 7cc7cfe
  • package: replaced pascal-case with change-case e74bc80
  • doc: JSDoc added for generic param StructuralClasses d80e6b2

v3.1.0

24 April 2020

  • feat: optional criteria paramaeter for graphq getAll queries 603c140
  • doc: change log cee9fb5

v3.0.0

24 April 2020

  • Breaking: Enums now generate with postfix Enum in their name c3c461b
  • doc: change log 8c8d372

v2.6.0

24 April 2020

  • feat: added option for just generate graphql schema files for specific classes a780a91
  • feat: generateStructuralClassesFile added 52cda7f
  • doc: change log 9f79aba

v2.5.1

24 April 2020

v2.5.0

23 April 2020