Skip to content

Commit

Permalink
breaking: api changed to follow soul of statefull connection of LDAP …
Browse files Browse the repository at this point in the history
…protocol
  • Loading branch information
Ostad authored and Ostad committed Jun 4, 2020
1 parent 5251671 commit c282f36
Show file tree
Hide file tree
Showing 72 changed files with 836 additions and 2,091 deletions.
52 changes: 17 additions & 35 deletions README.md
Expand Up @@ -2,27 +2,14 @@

It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.

### 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

### How to use

```
npm i ldap-schema-ts-generator
```

```ts
import { Client, IClientConfig } from "ldap-ts-client";
import {
getSchemaAttributes,
getSchemaClasses,
Expand All @@ -33,40 +20,36 @@ const options = {
user: "**********",
pass: "************",
ldapServerUrl: "ldap://domain.com",
baseDn: "DC=domain,DC=com",
};
const client = new Client(options);

const schemaDn = await getSchemaNamingContext({ options });

const objectAttributes = await getSchemaAttributes({ schemaDn, options });
const objectAttributes = await getSchemaAttributes({ client });

const objectClasses = await getSchemaClasses({ schemaDn, options });
const objectClasses = await getSchemaClasses({ client });

await generateInterfaceFiles({ objectAttributes, objectClasses });
}

```

### Options:

```ts
options?: {
/** default generated folder of root directory of you project */
outputFolder?: string;
/** use prettier to format generated files. default true */
usePrettier?: boolean;
/** create index file for output folder. default true */
indexFile: boolean;
};

```

### API

use [api website](https://saostad.github.io/ldap-schema-ts-generator/modules/_index_.html) for more details

### Result
### Functionalities

creates typescript interface for each LDAP class that exist in schema
- 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:

Expand All @@ -78,7 +61,6 @@ import { MsExchBaseClass } from "./MsExchBaseClass";
* - 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
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/search.json

Large diffs are not rendered by default.

66 changes: 25 additions & 41 deletions docs/index.html
Expand Up @@ -68,30 +68,11 @@ <h1>ldap-schema-ts-generator</h1>
<h1>Typescript typedef and meta-data generator for LDAP Schema</h1>
</a>
<p>It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.</p>
<a href="#functionalities" id="functionalities" style="color: inherit; text-decoration: none;">
<h3>Functionalities</h3>
</a>
<ul>
<li>generate typescript interfaces for each object class</li>
<li>generate relations between attributes (json)</li>
<li>generate graphql schema:<ul>
<li>type for each object class</li>
<li>basic CRUD operations for each object class</li>
</ul>
</li>
<li>generate typescript enum for supported:<ul>
<li>controls</li>
<li>capabilities</li>
<li>extensions</li>
<li>policies</li>
<li>structural classes</li>
</ul>
</li>
</ul>
<a href="#how-to-use" id="how-to-use" style="color: inherit; text-decoration: none;">
<h3>How to use</h3>
</a>
<pre><code><span class="hljs-built_in">npm</span> i ldap-schema-ts-generator</code></pre><pre><code class="language-ts"><span class="hljs-keyword">import</span> {
<pre><code><span class="hljs-built_in">npm</span> i ldap-schema-ts-generator</code></pre><pre><code class="language-ts"><span class="hljs-keyword">import</span> { Client, IClientConfig } <span class="hljs-keyword">from</span> <span class="hljs-string">"ldap-ts-client"</span>;
<span class="hljs-keyword">import</span> {
getSchemaAttributes,
getSchemaClasses,
generateInterfaceFiles,
Expand All @@ -101,37 +82,41 @@ <h3>How to use</h3>
user: <span class="hljs-string">"**********"</span>,
pass: <span class="hljs-string">"************"</span>,
ldapServerUrl: <span class="hljs-string">"ldap://domain.com"</span>,
baseDn: <span class="hljs-string">"DC=domain,DC=com"</span>,
};
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> Client(options);

<span class="hljs-keyword">const</span> schemaDn = <span class="hljs-keyword">await</span> getSchemaNamingContext({ options });
<span class="hljs-keyword">const</span> objectAttributes = <span class="hljs-keyword">await</span> getSchemaAttributes({ client });

<span class="hljs-keyword">const</span> objectAttributes = <span class="hljs-keyword">await</span> getSchemaAttributes({ schemaDn, options });

<span class="hljs-keyword">const</span> objectClasses = <span class="hljs-keyword">await</span> getSchemaClasses({ schemaDn, options });
<span class="hljs-keyword">const</span> objectClasses = <span class="hljs-keyword">await</span> getSchemaClasses({ client });

<span class="hljs-keyword">await</span> generateInterfaceFiles({ objectAttributes, objectClasses });
}
</code></pre>
<a href="#options" id="options" style="color: inherit; text-decoration: none;">
<h3>Options:</h3>
</a>
<pre><code class="language-ts">options?: {
<span class="hljs-comment">/** default generated folder of root directory of you project */</span>
outputFolder?: <span class="hljs-built_in">string</span>;
<span class="hljs-comment">/** use prettier to format generated files. default true */</span>
usePrettier?: <span class="hljs-built_in">boolean</span>;
<span class="hljs-comment">/** create index file for output folder. default true */</span>
indexFile: <span class="hljs-built_in">boolean</span>;
};
</code></pre>
<a href="#api" id="api" style="color: inherit; text-decoration: none;">
<h3>API</h3>
</a>
<p>use <a href="https://saostad.github.io/ldap-schema-ts-generator/modules/_index_.html">api website</a> for more details</p>
<a href="#result" id="result" style="color: inherit; text-decoration: none;">
<h3>Result</h3>
<a href="#functionalities" id="functionalities" style="color: inherit; text-decoration: none;">
<h3>Functionalities</h3>
</a>
<p>creates typescript interface for each LDAP class that exist in schema</p>
<ul>
<li>generate typescript interfaces for each object class</li>
<li>generate relations between attributes (json)</li>
<li>generate graphql schema:<ul>
<li>type for each object class</li>
<li>basic CRUD operations for each object class</li>
</ul>
</li>
<li>generate typescript enum for supported:<ul>
<li>controls</li>
<li>capabilities</li>
<li>extensions</li>
<li>policies</li>
<li>structural classes</li>
</ul>
</li>
</ul>
<a href="#sample-generated-file" id="sample-generated-file" style="color: inherit; text-decoration: none;">
<h3>Sample Generated File:</h3>
</a>
Expand All @@ -142,7 +127,6 @@ <h3>Sample Generated File:</h3>
* - child of class: top
* - dn: CN=Container,CN=Schema,CN=Configuration,DC=ki,DC=local
*/</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">interface</span> Container <span class="hljs-keyword">extends</span> Top, MsExchBaseClass {
<span class="hljs-comment">/** - attributeSyntax: 2.5.5.12
* - attributeID: 2.5.4.3
Expand Down
24 changes: 12 additions & 12 deletions docs/interfaces/_services_attribute_.schemaattribute.html
Expand Up @@ -114,7 +114,7 @@ <h3>admin<wbr>Description</h3>
<div class="tsd-signature tsd-kind-icon">admin<wbr>Description<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#admindescription" class="tsd-signature-type">AdminDescription</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L30">services/attribute.ts:30</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L32">services/attribute.ts:32</a></li>
</ul>
</aside>
</section>
Expand All @@ -124,7 +124,7 @@ <h3>admin<wbr>Display<wbr>Name</h3>
<div class="tsd-signature tsd-kind-icon">admin<wbr>Display<wbr>Name<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#admindisplayname" class="tsd-signature-type">AdminDisplayName</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L29">services/attribute.ts:29</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L31">services/attribute.ts:31</a></li>
</ul>
</aside>
</section>
Expand All @@ -134,7 +134,7 @@ <h3>attributeID</h3>
<div class="tsd-signature tsd-kind-icon">attributeID<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#attributeid" class="tsd-signature-type">AttributeID</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L25">services/attribute.ts:25</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L27">services/attribute.ts:27</a></li>
</ul>
</aside>
</section>
Expand All @@ -144,7 +144,7 @@ <h3>attribute<wbr>Syntax</h3>
<div class="tsd-signature tsd-kind-icon">attribute<wbr>Syntax<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#attributesyntax" class="tsd-signature-type">AttributeSyntax</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L26">services/attribute.ts:26</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L28">services/attribute.ts:28</a></li>
</ul>
</aside>
</section>
Expand All @@ -154,7 +154,7 @@ <h3>cn</h3>
<div class="tsd-signature tsd-kind-icon">cn<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#cn" class="tsd-signature-type">CN</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L24">services/attribute.ts:24</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L26">services/attribute.ts:26</a></li>
</ul>
</aside>
</section>
Expand All @@ -164,7 +164,7 @@ <h3>is<wbr>Single<wbr>Valued</h3>
<div class="tsd-signature tsd-kind-icon">is<wbr>Single<wbr>Valued<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#issinglevalued" class="tsd-signature-type">IsSingleValued</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L27">services/attribute.ts:27</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L29">services/attribute.ts:29</a></li>
</ul>
</aside>
</section>
Expand All @@ -174,7 +174,7 @@ <h3>lDAPDisplay<wbr>Name</h3>
<div class="tsd-signature tsd-kind-icon">lDAPDisplay<wbr>Name<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#ldapdisplayname" class="tsd-signature-type">LDAPDisplayName</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L32">services/attribute.ts:32</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L34">services/attribute.ts:34</a></li>
</ul>
</aside>
</section>
Expand All @@ -184,7 +184,7 @@ <h3>oMSyntax</h3>
<div class="tsd-signature tsd-kind-icon">oMSyntax<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#omsyntax" class="tsd-signature-type">OMSyntax</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L31">services/attribute.ts:31</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L33">services/attribute.ts:33</a></li>
</ul>
</aside>
</section>
Expand All @@ -194,7 +194,7 @@ <h3>object<wbr>Category</h3>
<div class="tsd-signature tsd-kind-icon">object<wbr>Category<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#objectcategory" class="tsd-signature-type">ObjectCategory</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L35">services/attribute.ts:35</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L37">services/attribute.ts:37</a></li>
</ul>
</aside>
</section>
Expand All @@ -204,7 +204,7 @@ <h3>show<wbr>InAdvanced<wbr>View<wbr>Only</h3>
<div class="tsd-signature tsd-kind-icon">show<wbr>InAdvanced<wbr>View<wbr>Only<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#showinadvancedviewonly" class="tsd-signature-type">ShowInAdvancedViewOnly</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L28">services/attribute.ts:28</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L30">services/attribute.ts:30</a></li>
</ul>
</aside>
</section>
Expand All @@ -214,7 +214,7 @@ <h3>system<wbr>Flags</h3>
<div class="tsd-signature tsd-kind-icon">system<wbr>Flags<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#systemflags" class="tsd-signature-type">SystemFlags</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L34">services/attribute.ts:34</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L36">services/attribute.ts:36</a></li>
</ul>
</aside>
</section>
Expand All @@ -224,7 +224,7 @@ <h3>system<wbr>Only</h3>
<div class="tsd-signature tsd-kind-icon">system<wbr>Only<span class="tsd-signature-symbol">:</span> <a href="../modules/_typings_general_types_.html#systemonly" class="tsd-signature-type">SystemOnly</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/ce4e29a/src/services/attribute.ts#L33">services/attribute.ts:33</a></li>
<li>Defined in <a href="https://github.com/saostad/ldap-schema-ts-generator/blob/5251671/src/services/attribute.ts#L35">services/attribute.ts:35</a></li>
</ul>
</aside>
</section>
Expand Down

0 comments on commit c282f36

Please sign in to comment.