koji-tools types (#37726)

* Add koji-tools type definitions

* Prettier

* Linted

* Add remaining exports

* CRLF conversion

* Remove namespace
This commit is contained in:
Jeff Peterson
2019-08-23 14:49:21 -07:00
committed by Sheetal Nandi
parent 63b8cdc3a3
commit 30dd1a6359
4 changed files with 90 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for koji-tools 0.5
// Project: https://github.com/madewithkoji/koji-tools
// Definitions by: Jeff Peterson <https://github.com/bdjeffyp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/**
* Server-side function that sets file watchers on all .koji customization
* files and allows for hot reloading of these properties.
*/
export function watch(): void;
/**
* Sets up Koji.config parameters for each client and handles communication
* between the Koji live preview iframe and your app.
*/
export function pageLoad(options?: object): void;
/**
* Wrapper for fetch that takes objects from Koji.routes.
*/
export function request(route: object, params?: object): Promise<any>;
/**
* After the 'pwaPromptReady' event has fired, this function will make a popup
* installation prompt appear.
*/
export function pwaPrompt(): any;
/**
* An auto-generated list of all of the Koji Customization Controls (VCCs) your
* application has setup. When Koji.watch() is being used this list updates automatically.
*/
export const config: object;
/**
* A auto-generated list of routes based on koji.json files in your project that are
* used in Koji.request() to request the backend of your app.
*/
export const routes: object;
export const pwa: any;
/**
* Registers a callback on a Koji event.
* @param event name of the event being called
* @param callback method to execute when the event occurs
*/
export function on(event: string, callback: () => void): void;
/**
* Resolve the value of a user's secret from the Koji Keystore. Secrets are used for
* values that are not intended to be read by other users when a project is remixed.
*/
export function resolveSecret(key: string): string | null;
+11
View File
@@ -0,0 +1,11 @@
import * as Koji from 'koji-tools';
Koji.watch();
Koji.pageLoad();
Koji.request({ url: 'www.test.org' });
Koji.pwaPrompt();
const myConfig = Koji.config;
const myRoutes = Koji.routes;
const myPwaInstaller = Koji.pwa;
Koji.on('test', () => 'Hello, world!');
const mySecret = Koji.resolveSecret('verySecretKey');
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"koji-tools-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }