mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #30783 from pluma/ldap-filters
Added ldap-filters@2.2
This commit is contained in:
60
types/ldap-filters/index.d.ts
vendored
Normal file
60
types/ldap-filters/index.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// Type definitions for ldap-filters 2.2
|
||||
// Project: https://github.com/tapmodo/node-ldap-filters
|
||||
// Definitions by: Alan Plum <https://github.com/pluma>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
interface Filter {
|
||||
toString(indent?: boolean | number): string;
|
||||
simplify(): Filter;
|
||||
match(data: object): boolean;
|
||||
}
|
||||
|
||||
declare namespace Filter {
|
||||
let escape_chars: string[];
|
||||
let indent: number;
|
||||
let indent_char: string;
|
||||
let collapse_not: boolean;
|
||||
|
||||
function escape(value: string): string;
|
||||
function unescape(value: string): string;
|
||||
function parse(input: string): Filter;
|
||||
function matchString(data: string | string[], filter: Filter): boolean;
|
||||
function matchSubstring(data: string | string[], filter: Filter): boolean;
|
||||
function matchApprox(data: string | string[], filter: Filter): boolean;
|
||||
function matchGTE(data: string | string[], filter: Filter): boolean;
|
||||
function matchLTE(data: string | string[], filter: Filter): boolean;
|
||||
function attribute(name: string): Attribute;
|
||||
function AND(filters: Filter[]): Group;
|
||||
function OR(filters: Filter[]): Group;
|
||||
function NOT(filter: Filter): GroupNot;
|
||||
|
||||
interface Group {
|
||||
type: string;
|
||||
comp: string;
|
||||
filters: Filter[];
|
||||
toString(indent?: boolean | number): string;
|
||||
match(data: object): boolean;
|
||||
}
|
||||
|
||||
interface GroupNot extends Group {
|
||||
simplify(): Filter;
|
||||
}
|
||||
|
||||
interface Attribute {
|
||||
name: string;
|
||||
escapeChars: string[];
|
||||
escape(value: string): string;
|
||||
present(): Filter;
|
||||
raw(value: string): Filter;
|
||||
equalTo(value: string): Filter;
|
||||
endsWith(value: string): Filter;
|
||||
startsWith(value: string): Filter;
|
||||
contains(value: string): Filter;
|
||||
approx(value: string): Filter;
|
||||
lte(value: string): Filter;
|
||||
gte(value: string): Filter;
|
||||
}
|
||||
}
|
||||
|
||||
export = Filter;
|
||||
28
types/ldap-filters/ldap-filters-tests.ts
Normal file
28
types/ldap-filters/ldap-filters-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import Filter = require("ldap-filters");
|
||||
|
||||
Filter.collapse_not = false;
|
||||
|
||||
const output = Filter.AND([
|
||||
Filter.attribute("givenName").equalTo("jenny"),
|
||||
Filter.attribute("sn").equalTo("jensen")
|
||||
]);
|
||||
|
||||
console.log(output.toString());
|
||||
|
||||
Filter.parse("(&(givenName=jenny)(sn=jensen))");
|
||||
|
||||
Filter.parse("(&(uid=jenny))").simplify();
|
||||
|
||||
const filter = Filter.parse(
|
||||
"(&(givenName=jenny)(sn=jensen)(|(c=us)(st=ontario)))"
|
||||
);
|
||||
|
||||
filter.toString();
|
||||
filter.toString(true);
|
||||
filter.toString(2);
|
||||
|
||||
const parsed = Filter.parse("(&(givenName~=jeni)(sn=jensen))");
|
||||
const data = { givenName: "Jenny", sn: "Jensen" };
|
||||
console.log(parsed.match(data));
|
||||
16
types/ldap-filters/tsconfig.json
Normal file
16
types/ldap-filters/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "ldap-filters-tests.ts"]
|
||||
}
|
||||
1
types/ldap-filters/tslint.json
Normal file
1
types/ldap-filters/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user