Add type definitions for solution-center-communicator (#10779)

* Add type definitions for solution-center-communicator

* refactor(typings): change parameter type
This commit is contained in:
Dami
2016-08-30 03:08:56 +09:00
committed by Masahiro Wakame
parent fa33748396
commit b779ab60e5
2 changed files with 147 additions and 0 deletions
@@ -0,0 +1,22 @@
/// <reference path="solution-center-communicator.d.ts" />
import * as ScCommunicator from 'solution-center-communicator';
var environment: ScCommunicator.Environment = {
NAME: 'TEST',
URL: 'https://norris.test.zalan.do',
DOMAIN: '.zalan.do',
PORT: '',
USER_SERVICE: 'https://um.norris.test.zalan.do',
TOKEN_SERVICE: 'https://tm.norris.test.zalan.do',
MODULE_SERVICE: 'https://ms.norris.test.zalan.do'
};
var environments: ScCommunicator.Environments;
environments.TESTING = environment;
var environmentsProvider: ScCommunicator.ScEnvironmentsProvider;
environmentsProvider.setCurrentEnvironment(environment);
environmentsProvider.getCurrentEnvironment();
environmentsProvider.getSpecificEnvironment('TESTING');
@@ -0,0 +1,125 @@
// Type definitions for Solution Center Communicator 2.2.0
// Project: https://github.com/zalando-incubator/solution-center-communicator
// Definitions by: Damián García <https://github.com/dami-gg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace ScCommunicator {
interface Environment {
/**
* Name of the environment
*/
NAME: string;
/**
* URL where to reach the frontend of the environment
*/
URL: string;
/**
* Domain where to set a cookie in case it's needed for that environment
*/
DOMAIN: string;
/**
* In case that the domain is localhost, a port can be also specified
*/
PORT?: string;
/**
* URL where to reach the user management service API
*/
USER_SERVICE?: string;
/**
* URL where to reach the token management service API
*/
TOKEN_SERVICE?: string;
/**
* URL where to reach the merchant management service API
*/
MERCHANT_SERVICE?: string;
/**
* URL where to reach the GoodData service API
*/
GOODDATA_SERVICE?: string;
/**
* URL where to reach the module service API
*/
MODULE_SERVICE?: string;
}
interface Environments {
/**
* Production environment
*/
PRODUCTION: Environment;
/**
* Stage environment
*/
STAGE: Environment;
/**
* Integration environment
*/
INTEGRATION: Environment;
/**
* Development environment
*/
DEVELOPMENT: Environment;
/**
* Local environment
*/
LOCAL: Environment;
/**
* Testing environment
*/
TESTING: Environment;
}
interface ScEnvironmentsProvider {
/**
* Get current environment
* If environment was not previously configured, use default environment
*
* @public
* @returns {Object} Current or default environment
*/
getCurrentEnvironment(): Environment;
/**
* Get specific environment
*
* @public
* @param {string} name - Environment name
* @returns {Object} Specific or default environment
*/
getSpecificEnvironment(name: string): Environment;
/**
* Set current environment
*
* @public
* @param {string|Object} env - Environment name or custom environment object
* @returns {Object} Named or custom environment
*/
setCurrentEnvironment(env: any): Environment;
/**
* Access to the public methods of the service
*/
$get(): any;
}
}
declare module "solution-center-communicator" {
export = ScCommunicator;
}