mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat: add new typings for cloud-config-client (#38007)
This commit is contained in:
parent
0d9b406920
commit
871e4ab3d1
29
types/cloud-config-client/cloud-config-client-tests.ts
Normal file
29
types/cloud-config-client/cloud-config-client-tests.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import client = require('cloud-config-client');
|
||||
|
||||
client.load({
|
||||
name: 'invoices'
|
||||
}).then(config => {
|
||||
const conf = config; // $ExpectType Config
|
||||
const value1 = config.get('this.is.a.key'); // $ExpectType any
|
||||
});
|
||||
|
||||
// Async through IFFE
|
||||
|
||||
(async () => {
|
||||
const config = await client.load({name: 'invoices'}); // $ExpectType Config
|
||||
})();
|
||||
|
||||
// With additional options
|
||||
|
||||
client.load({
|
||||
name: 'invoices',
|
||||
profiles: ['profile1', 'profile2'],
|
||||
label: 'label',
|
||||
auth: {
|
||||
pass: 'password',
|
||||
user: 'admin',
|
||||
}
|
||||
}).then(config => {
|
||||
const conf = config; // $ExpectType Config
|
||||
const value1 = config.get('this.is.a.key'); // $ExpectType any
|
||||
});
|
||||
65
types/cloud-config-client/index.d.ts
vendored
Normal file
65
types/cloud-config-client/index.d.ts
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// Type definitions for cloud-config-client 1.4
|
||||
// Project: https://github.com/victorherraiz/cloud-config-client#readme
|
||||
// Definitions by: Jeroen Claassens <https://github.com/favna>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import http = require('http');
|
||||
import https = require('https');
|
||||
|
||||
export function load(options: Options, callback?: LoadCallback): Promise<Config>;
|
||||
|
||||
export abstract class Config {
|
||||
constructor(data: ConfigData, context: { [key: string]: any });
|
||||
|
||||
properties(): { [key: string]: any };
|
||||
raw(): { [key: string]: any };
|
||||
get(keyParts: string): any;
|
||||
forEach(callback: (property: string, value: string) => void, includeOverridden?: boolean): void;
|
||||
toObject(): { [key: string]: any };
|
||||
toString(spaces: number): string;
|
||||
}
|
||||
|
||||
export interface ConfigFile {
|
||||
name: string;
|
||||
source: ConfigSource;
|
||||
}
|
||||
|
||||
export interface ConfigSource {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ConfigData {
|
||||
name: string;
|
||||
profiles: string[];
|
||||
label: string;
|
||||
version: string;
|
||||
propertySources: ConfigFile[];
|
||||
}
|
||||
|
||||
export interface Auth {
|
||||
user: string;
|
||||
pass: string;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
endpoint?: string;
|
||||
rejectUnauthorized?: boolean;
|
||||
|
||||
/** @deprecated use name */
|
||||
application?: string;
|
||||
name: string;
|
||||
profiles?: string | string[];
|
||||
label?: string;
|
||||
auth?: Auth;
|
||||
agent?: http.Agent | https.Agent;
|
||||
context?: {
|
||||
[key: string]: any
|
||||
};
|
||||
}
|
||||
|
||||
export interface LoadCallback {
|
||||
(error: Error, config?: Config): void;
|
||||
}
|
||||
23
types/cloud-config-client/tsconfig.json
Normal file
23
types/cloud-config-client/tsconfig.json
Normal 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",
|
||||
"cloud-config-client-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cloud-config-client/tslint.json
Normal file
1
types/cloud-config-client/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user