Type definitions for npm module: alks-node (#36628)

* initial commit for alks-node type definitions

* linter formatting

* added moment dependency

* added ts 2.2 comment under header
This commit is contained in:
matthoang08 2019-07-11 14:27:13 -05:00 committed by Armando Aguirre
parent 6f203f860a
commit 40a2808bc0
5 changed files with 203 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import {
Auth,
Account,
AwsKey,
createIamKey,
createIamRole,
createIamTrustRole,
createKey,
createLongTermKey,
deleteIamRole,
deleteLongTermKey,
generateConsoleUrl,
getAccounts,
getDurations,
getIamRoleTypes,
refreshTokenToAccessToken,
} from 'alks-node';
const auth: Auth = {
password: 'pass',
token: 'token',
};
const acct: Account = {
alksAccount: 'alksAcct',
alksRole: 'alksRole',
server: 'server',
userid: 'userId',
};
const awsKey: AwsKey = {
accessKey: 'accessKey',
secretKey: 'secretKey',
sessionToken: 'sessionToken',
};
createIamKey(acct, auth, 1, {}, () => {});
createIamRole(acct, auth, 'roleName', 'roleType', true, {}, () => {});
createIamTrustRole(acct, auth, 'roleName', 'roleType', 'trustArn', {}, () => {});
createKey(acct, auth, 1, {}, () => {});
createLongTermKey(acct, auth, 'iamUserName', {}, () => {});
deleteIamRole(acct, auth, 'roleName', {}, () => {});
deleteLongTermKey(acct, auth, 'iamUserName', {}, () => {});
generateConsoleUrl(awsKey, {}, () => {});
getAccounts('server', 'userId', auth, {}, () => {});
getDurations(acct, auth, {}, () => {});
getIamRoleTypes('server', 'userId', auth, {}, () => {});
refreshTokenToAccessToken(acct, 'token', {}, () => {});

125
types/alks-node/index.d.ts vendored Normal file
View File

@ -0,0 +1,125 @@
// Type definitions for alks-node 0.9
// Project: https://github.com/Cox-Automotive/alks-node#readme
// Definitions by: Matt Hoang <https://github.com/matthoang08>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { Moment } from 'moment';
export interface Auth {
token?: string;
password?: string;
}
export interface Account {
userid: string;
server: string;
alksAccount: string;
alksRole: string;
}
export interface AlksAccount {
account: string;
role: string;
iam?: boolean;
}
export interface LongTermKeyData {
accessKey: string;
secretKey: string;
iamUserName: string;
iamUserArn: string;
alksAccount: string;
alksRole: string;
}
export interface KeyData {
accessKey: string;
secretKey: string;
sessionToken: string;
alksAccount: string;
alksRole: string;
sessionTime: string;
expires: Moment;
}
export interface AwsKey {
accessKey: string;
secretKey: string;
sessionToken: string;
}
export function getDurations(
account: Account,
auth: Auth,
opts: object,
callback: (err: Error, duration: number[]) => void
): void;
export function createKey(
account: Account,
auth: Auth,
duration: number,
opts: object,
callback: (err: Error, key: KeyData) => void
): void;
export function createIamKey(
account: Account,
auth: Auth,
duration: number,
opts: object,
callback: (err: Error, key: KeyData) => void
): void;
export function createLongTermKey(
account: Account,
auth: Auth,
iamUserName: string,
opts: object,
callback: (err: Error, data: LongTermKeyData) => void
): void;
export function createIamRole(
account: Account,
auth: Auth,
roleName: string,
roleType: string,
includeDefaultPolicies: boolean,
opts: object,
callback: (err: Error, body: any) => void
): void;
export function createIamTrustRole(
account: Account,
auth: Auth,
roleName: string,
roleType: string,
trustArn: string,
opts: object,
callback: (err: Error, body: any) => void
): void;
export function getAccounts(
server: string,
userid: string,
auth: Auth,
opts: object,
callback: (err: Error, accounts: AlksAccount[]) => void
): void;
export function getIamRoleTypes(
server: string,
userid: string,
auth: Auth,
opts: object,
callback: (err: Error, body: any) => void
): void;
export function generateConsoleUrl(key: AwsKey, opts: object, callback: (err: Error, url: string) => void): void;
export function deleteIamRole(
account: Account,
auth: Auth,
roleName: string,
opts: object,
callback: (err: Error, body: any) => void
): void;
export function deleteLongTermKey(
account: Account,
auth: Auth,
iamUserName: string,
opts: object,
callback: (err: Error, body: any) => void
): void;
export function refreshTokenToAccessToken(
account: Account,
token: string,
opts: object,
callback: (err: Error, body: any) => void
): void;

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"moment": ">=2.15.2"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"alks-node-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }