mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 09:41:45 +00:00
Add Typings for microservice-utilities
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
// Type definitions for microservice-utilities 0.1
|
||||
// Project: https://github.com/Cimpress-MCP/microservice-utilities.js
|
||||
// Definitions by: Daan Boerlage <https://github.com/runebaas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* Authorizer
|
||||
*/
|
||||
|
||||
export interface AuthorizerConfiguration {
|
||||
jwkKeyListUrl: string;
|
||||
authorizerContextResolver?: string;
|
||||
}
|
||||
|
||||
export interface AuthorizerPolicy {
|
||||
principalId: string;
|
||||
policyDocument: object;
|
||||
}
|
||||
|
||||
export class Authorizer {
|
||||
constructor(logFunction: (msg: any) => void, configuration: AuthorizerConfiguration);
|
||||
getPolicy(request: object): Promise<AuthorizerPolicy>;
|
||||
}
|
||||
|
||||
/**
|
||||
* PlatformClient
|
||||
*/
|
||||
|
||||
export interface PlatformClientConfiguration {
|
||||
client: object;
|
||||
}
|
||||
|
||||
export interface PlatformClientResponse {
|
||||
data?: any;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: any;
|
||||
config: object;
|
||||
request?: any;
|
||||
}
|
||||
|
||||
export class PlatformClient {
|
||||
constructor(logFunction: (msg: any) => void, tokenResolverFunction?: Promise<() => string>, configuration?: PlatformClientConfiguration)
|
||||
get(url: string, headers?: object, type?: string): Promise<PlatformClientResponse>;
|
||||
post(url: string, data: object, headers?: object): Promise<PlatformClientResponse>;
|
||||
put(url: string, data: object, headers?: object): Promise<PlatformClientResponse>;
|
||||
patch(url: string, data: object, headers?: object): Promise<PlatformClientResponse>;
|
||||
delete(url: string, headers?: object): Promise<PlatformClientResponse>;
|
||||
head(url: string, headers?: object): Promise<PlatformClientResponse>;
|
||||
options(url: string, headers?: object): Promise<PlatformClientResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* RequestLogger
|
||||
*/
|
||||
|
||||
export interface RequestLoggerConfiguration {
|
||||
logFunction?: (msg: any) => void;
|
||||
extendErrorObjects?: boolean;
|
||||
jsonSpace?: number;
|
||||
}
|
||||
|
||||
export class RequestLogger {
|
||||
constructor(configuration?: RequestLoggerConfiguration);
|
||||
log(msg: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* ServiceTokenProvider
|
||||
*/
|
||||
|
||||
export interface ServiceTokenProviderConfiguration {
|
||||
clientId: string;
|
||||
encryptedClientSecret: string;
|
||||
audience: string;
|
||||
tokenEndpoint: string;
|
||||
}
|
||||
|
||||
export class ServiceTokenProvider {
|
||||
constructor(httpClient: object, kmsClient: object, configuration?: ServiceTokenProviderConfiguration);
|
||||
getToken(): Promise<string>;
|
||||
getTokenWithoutCache(): Promise<string>;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Authorizer, PlatformClient, RequestLogger, ServiceTokenProvider } from 'microservice-utilities';
|
||||
|
||||
const authorizer = new Authorizer((msg: any) => msg, {jwkKeyListUrl: 'aaa'});
|
||||
const authorizerPolicy = authorizer.getPolicy({test: true});
|
||||
|
||||
const platformClient = new PlatformClient((msg: any) => msg);
|
||||
platformClient.get('https://www.typescriptlang.org/');
|
||||
platformClient.post('https://www.typescriptlang.org/', {testData: 'abc'});
|
||||
|
||||
const serviceTokenProvider = new ServiceTokenProvider(platformClient, {});
|
||||
|
||||
const requestLogger = new RequestLogger({jsonSpace: 4});
|
||||
requestLogger.log('hello world');
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"microservice-utilities-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user