mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add a definition of atlassian-crowd-client (#26782)
* Add a definition of atlassian-crowd-client * [atlassian-crowd-client] Fix a wrong definition. * Add `"strictFunctionTypes": true` * [atlassian-crowd-client] Fix a compile error. * [atlassian-crowd-client] Use `export =` instead of `export default`. * Use `export =` instead of `export default` * Use `import = require`
This commit is contained in:
parent
deb7d8beaf
commit
dc86478557
10
types/atlassian-crowd-client/api.d.ts
vendored
Normal file
10
types/atlassian-crowd-client/api.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { Settings } from "./settings";
|
||||
|
||||
declare class CrowdApi {
|
||||
settings: Settings;
|
||||
constructor(settings: Settings);
|
||||
request(method: string, path: string, data?: any): Promise<any>;
|
||||
log(...args: any[]): void;
|
||||
}
|
||||
|
||||
export = CrowdApi;
|
||||
44
types/atlassian-crowd-client/atlassian-crowd-client-tests.ts
Normal file
44
types/atlassian-crowd-client/atlassian-crowd-client-tests.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import CrowdClient = require("atlassian-crowd-client");
|
||||
import Attributes = require("atlassian-crowd-client/lib/models/attributes");
|
||||
import Group = require("atlassian-crowd-client/lib/models/group");
|
||||
import Session = require("atlassian-crowd-client/lib/models/session");
|
||||
import User = require("atlassian-crowd-client/lib/models/user");
|
||||
|
||||
// Initialize the Crowd client:
|
||||
const crowd = new CrowdClient({
|
||||
baseUrl: "https://crowd.example.com/",
|
||||
application: {
|
||||
name: "demo",
|
||||
password: "example"
|
||||
}
|
||||
});
|
||||
|
||||
// Create a new user:
|
||||
crowd.user.create(new User("John", "Doe", "John Doe", "johndoe@example.com", "johndoe", "secret"));
|
||||
// Remove
|
||||
crowd.user.remove("johndoe");
|
||||
|
||||
// Authenticate to Crowd:
|
||||
crowd.session.create("someusername", "somepassword").then((session: Session) => {
|
||||
// Fetch the user profile:
|
||||
crowd.session.getUser(session.token).then((user: User) => {
|
||||
console.log("Hello, " + user.displayname);
|
||||
});
|
||||
});
|
||||
|
||||
// Find all active groups (using Crowd Query Language):
|
||||
crowd.search.group("active=true").then((groups: string[] | Group[]) => {
|
||||
console.log("Found groups: " + groups.length);
|
||||
});
|
||||
|
||||
const group = new Group("testgroup1", "Test group");
|
||||
|
||||
const attributes = new Attributes({
|
||||
foo: "Foo",
|
||||
bar: ["Bar", "Baz"],
|
||||
obj: { a: "A" }
|
||||
});
|
||||
|
||||
crowd.group.attributes.set(group.groupname, attributes).then(() => {
|
||||
console.log("Group attribute is set.");
|
||||
});
|
||||
117
types/atlassian-crowd-client/index.d.ts
vendored
Normal file
117
types/atlassian-crowd-client/index.d.ts
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
// Type definitions for atlassian-crowd-client 2.0
|
||||
// Project: https://github.com/ghengeveld/atlassian-crowd-client
|
||||
// Definitions by: mtgto <https://github.com/mtgto>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import CrowdApi = require("./api");
|
||||
import { Settings } from "./settings";
|
||||
import Attributes = require("./lib/models/attributes");
|
||||
import Group = require("./lib/models/group");
|
||||
import User = require("./lib/models/user");
|
||||
import Session = require("./lib/models/session");
|
||||
import ValidationFactors = require("./lib/models/validation-factors");
|
||||
|
||||
export = CrowdClient;
|
||||
declare class CrowdClient extends CrowdApi {
|
||||
settings: Settings;
|
||||
|
||||
constructor(settings: Settings);
|
||||
|
||||
user: {
|
||||
get: (username: string, withAttributes?: boolean) => Promise<User>;
|
||||
create: (user: User) => Promise<User>;
|
||||
update: (username: string, user: User) => Promise<User>;
|
||||
rename: (oldname: string, newname: string) => Promise<void>;
|
||||
remove: (username: string) => Promise<void>;
|
||||
attributes: {
|
||||
list: (username: string) => Promise<Attributes>;
|
||||
set: (username: string, attributes: Attributes) => Promise<Attributes>;
|
||||
remove: (username: string, attributename: string) => Promise<void>;
|
||||
password: {
|
||||
set: (username: string, password: string) => Promise<void>;
|
||||
reset: (username: string) => Promise<void>;
|
||||
};
|
||||
username: {
|
||||
request: (email: string) => Promise<void>;
|
||||
};
|
||||
};
|
||||
groups: {
|
||||
get: (username: string, groupname: string, nested?: boolean) => Promise<string>;
|
||||
list: (username: string, nested?: boolean, startIndex?: number, maxResults?: number) => Promise<string[]>;
|
||||
add: (username: string, groupname: string) => Promise<void>;
|
||||
remove: (username: string, groupname: string) => Promise<void>;
|
||||
};
|
||||
};
|
||||
group: {
|
||||
get: (groupname: string, withAttributes?: boolean) => Promise<Group>;
|
||||
create: (group: Group) => Promise<Group>;
|
||||
update: (groupname: string, group: Group) => Promise<Group>;
|
||||
remove: (groupname: string) => Promise<void>;
|
||||
attributes: {
|
||||
list: (groupname: string) => Promise<Attributes>;
|
||||
set: (groupname: string, attributes: Attributes) => Promise<Attributes>;
|
||||
remove: (groupname: string, attributename: string) => Promise<void>;
|
||||
};
|
||||
users: {
|
||||
get: (groupname: string, username: string, nested?: boolean) => Promise<string>;
|
||||
list: (
|
||||
groupname: string,
|
||||
nested?: boolean,
|
||||
startIndex?: number,
|
||||
maxResults?: number,
|
||||
expand?: boolean,
|
||||
) => Promise<string[] | User[]>;
|
||||
add: (groupname: string, username: string) => Promise<void>;
|
||||
remove: (groupname: string, username: string) => Promise<void>;
|
||||
};
|
||||
parents: {
|
||||
get: (groupname: string, parentname: string, nested?: boolean) => Promise<string>;
|
||||
list: (groupname: string, nested?: boolean, startIndex?: number, maxResults?: number) => Promise<string[]>;
|
||||
add: (groupname: string, parentname: string) => Promise<void>;
|
||||
};
|
||||
children: {
|
||||
get: (groupname: string, childname: string, nested?: boolean) => Promise<string>;
|
||||
list: (groupname: string, nested?: boolean, startIndex?: number, maxResults?: number) => Promise<string[]>;
|
||||
add: (groupname: string, childname: string) => Promise<void>;
|
||||
remove: (groupname: string, childname: string) => Promise<void>;
|
||||
};
|
||||
membership: () => Promise<string>;
|
||||
};
|
||||
authentication: {
|
||||
authenticate: (username: string, password: string) => Promise<User>;
|
||||
};
|
||||
search: {
|
||||
user: (
|
||||
restriction: string,
|
||||
expand?: boolean,
|
||||
startIndex?: number,
|
||||
maxResults?: number,
|
||||
) => Promise<string[] | User[]>;
|
||||
group: (
|
||||
restriction: string,
|
||||
expand?: boolean,
|
||||
startIndex?: number,
|
||||
maxResults?: number,
|
||||
) => Promise<string[] | Group[]>;
|
||||
};
|
||||
session: {
|
||||
getUser: (token: string) => Promise<User>;
|
||||
validate: (token: string, validationFactors?: ValidationFactors) => Promise<Session>;
|
||||
create: (
|
||||
username: string,
|
||||
password: string,
|
||||
validationFactors?: ValidationFactors,
|
||||
duration?: number,
|
||||
) => Promise<Session>;
|
||||
createUnvalidated: (
|
||||
username: string,
|
||||
validationFactors?: ValidationFactors,
|
||||
duration?: number,
|
||||
) => Promise<Session>;
|
||||
remove: (token: string) => Promise<void>;
|
||||
removeAll: (username: string, exclude?: string) => Promise<void>;
|
||||
};
|
||||
config: {
|
||||
cookie: () => Promise<any>;
|
||||
};
|
||||
}
|
||||
8
types/atlassian-crowd-client/lib/models/attributes.d.ts
vendored
Normal file
8
types/atlassian-crowd-client/lib/models/attributes.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export = Attributes;
|
||||
declare class Attributes {
|
||||
readonly attributes: {[name: string]: any};
|
||||
|
||||
constructor(attributePairs: {[name: string]: any});
|
||||
toCrowd(stringify?: (attr: any) => string): any;
|
||||
static fromCrowd(attributesArr: ReadonlyArray<{name: string}>, parse?: (json: string) => any): Attributes;
|
||||
}
|
||||
18
types/atlassian-crowd-client/lib/models/group.d.ts
vendored
Normal file
18
types/atlassian-crowd-client/lib/models/group.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
export = Group;
|
||||
declare class Group {
|
||||
readonly groupname: string;
|
||||
readonly description: string;
|
||||
readonly active: boolean;
|
||||
readonly attributes?: any;
|
||||
|
||||
constructor(groupname: string, description?: string, active?: boolean, attributes?: any);
|
||||
toCrowd(): GroupObj;
|
||||
static fromCrowd(obj: {name: string, description?: string, active?: boolean, attributes: any}): Group;
|
||||
}
|
||||
|
||||
interface GroupObj {
|
||||
readonly type: "GROUP";
|
||||
readonly name: string;
|
||||
readonly description: string;
|
||||
readonly active: boolean;
|
||||
}
|
||||
16
types/atlassian-crowd-client/lib/models/session.d.ts
vendored
Normal file
16
types/atlassian-crowd-client/lib/models/session.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
export = Session;
|
||||
declare class Session {
|
||||
readonly token: string;
|
||||
readonly createdAt: Date;
|
||||
readonly expiresAt: Date;
|
||||
|
||||
constructor(token: string, createdAt: Date, expiresAt: Date);
|
||||
toCrowd(): SessionObj;
|
||||
static fromCrowd(obj: SessionObj): Session;
|
||||
}
|
||||
|
||||
interface SessionObj {
|
||||
readonly token: string;
|
||||
readonly "created-date": number;
|
||||
readonly "expiry-date": number;
|
||||
}
|
||||
25
types/atlassian-crowd-client/lib/models/user.d.ts
vendored
Normal file
25
types/atlassian-crowd-client/lib/models/user.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
export = User;
|
||||
declare class User {
|
||||
readonly firstname: string;
|
||||
readonly lastname: string;
|
||||
readonly displayname: string;
|
||||
readonly email: string;
|
||||
readonly username: string;
|
||||
readonly password?: string;
|
||||
readonly active: boolean;
|
||||
readonly attributes: {[key: string]: any};
|
||||
|
||||
constructor(firstname: string, lastname: string, displayname: string, email: string, username: string, password?: string, active?: boolean, attributes?: any);
|
||||
toCrowd(): UserObj;
|
||||
static fromCrowd(userObj: UserObj): User;
|
||||
}
|
||||
|
||||
interface UserObj {
|
||||
readonly "name": string;
|
||||
readonly "first-name": string;
|
||||
readonly "last-name": string;
|
||||
readonly "display-name": string;
|
||||
readonly "email": string;
|
||||
readonly "active": boolean;
|
||||
readonly "password"?: { value: string };
|
||||
}
|
||||
12
types/atlassian-crowd-client/lib/models/validation-factors.d.ts
vendored
Normal file
12
types/atlassian-crowd-client/lib/models/validation-factors.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export = ValidationFactors;
|
||||
declare class ValidationFactors {
|
||||
readonly validationFactors: any;
|
||||
|
||||
constructor(validationFactorPairs: any);
|
||||
toCrowd(): ValidationFactorsObj;
|
||||
static fromCrowd(validationFactorsObj: ValidationFactorsObj): ValidationFactors;
|
||||
}
|
||||
|
||||
interface ValidationFactorsObj {
|
||||
validationFactors: any[];
|
||||
}
|
||||
12
types/atlassian-crowd-client/settings.d.ts
vendored
Normal file
12
types/atlassian-crowd-client/settings.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export interface Settings {
|
||||
readonly baseUrl: string;
|
||||
readonly application: {
|
||||
readonly name: string;
|
||||
readonly password: string;
|
||||
}
|
||||
readonly nesting?: boolean;
|
||||
readonly sessionTimeout?: number;
|
||||
readonly debug?: boolean;
|
||||
readonly attributesParser?: (json: string) => any;
|
||||
readonly attributesEncoder?: (obj: any) => string;
|
||||
}
|
||||
24
types/atlassian-crowd-client/tsconfig.json
Normal file
24
types/atlassian-crowd-client/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"atlassian-crowd-client-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/atlassian-crowd-client/tslint.json
Normal file
1
types/atlassian-crowd-client/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user