mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
add plaid-link defs (#34602)
* add plaid-link defs * set "strictFunctionTypes": true * correct github link * Type functions * delete comments * use string union type instead of enum * correct argument casing
This commit is contained in:
committed by
Daniel Rosenwasser
parent
1f2b237c9d
commit
3ac4e15ccc
Vendored
+114
@@ -0,0 +1,114 @@
|
||||
// Type definitions for non-npm package plaid-link-browser 2.0
|
||||
// Project: https://github.com/plaid/link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
|
||||
// Definitions by: Aaron Holderman <https://github.com/afholderman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Plaid: {
|
||||
create(params: Plaid.CreateConfig): Plaid.LinkHandler;
|
||||
open(): void;
|
||||
exit(force?: boolean): void;
|
||||
};
|
||||
linkHandler: Plaid.LinkHandler;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Plaid {
|
||||
interface CreateConfig {
|
||||
clientName: string;
|
||||
product: Product[];
|
||||
key: string;
|
||||
env: Environment;
|
||||
onSuccess: OnSuccess;
|
||||
onExit?: OnExit;
|
||||
onEvent?: OnEvent;
|
||||
onLoad?: OnLoad;
|
||||
language?: Language;
|
||||
user?: User;
|
||||
token?: string;
|
||||
isWebView?: boolean;
|
||||
}
|
||||
|
||||
type OnSuccess = (
|
||||
public_token: string,
|
||||
metadata: OnSuccessMetaData
|
||||
) => void;
|
||||
type OnExit = (error: Error | null, metadata: OnExitMetaData) => void;
|
||||
type OnEvent = (eventName: EventName, metadata: OnEventMetaData) => void;
|
||||
type OnLoad = () => void;
|
||||
|
||||
interface LinkHandler {
|
||||
open: () => void;
|
||||
institutions: Institution[];
|
||||
}
|
||||
type Product = "transactions" | "auth" | "identity" | "income" | "assets";
|
||||
type Environment = "development" | "sandbox" | "production";
|
||||
type Language = "en" | "fr";
|
||||
type VerificationStatus =
|
||||
| "pending_automatic_verification"
|
||||
| "pending_manual_verification"
|
||||
| "manually_verified";
|
||||
type EventName =
|
||||
| "ERROR"
|
||||
| "EXIT"
|
||||
| "HANDOFF"
|
||||
| "OPEN"
|
||||
| "OPEN_MY_PLAID"
|
||||
| "SEARCH_INSTITUTION"
|
||||
| "SELECT_INSTITUTION"
|
||||
| "TRANSITION_VIEW";
|
||||
interface User {
|
||||
legalName: string;
|
||||
emailAddress: string;
|
||||
}
|
||||
interface Institution {
|
||||
name: string;
|
||||
institution_id: string;
|
||||
auth: boolean;
|
||||
transactions: boolean;
|
||||
}
|
||||
interface Account {
|
||||
id: string;
|
||||
name: string;
|
||||
mask: string;
|
||||
type: string;
|
||||
subtype: string;
|
||||
verification_status: VerificationStatus;
|
||||
}
|
||||
interface Error {
|
||||
display_message: string;
|
||||
error_code: string;
|
||||
error_message: string;
|
||||
error_type: string;
|
||||
}
|
||||
interface OnSuccessMetaData {
|
||||
link_session_id: string;
|
||||
institution: {
|
||||
name: string;
|
||||
institution_id: string;
|
||||
};
|
||||
accounts: Account[];
|
||||
}
|
||||
interface OnExitMetaData {
|
||||
link_session_id: string;
|
||||
request_id: string;
|
||||
institution: Institution;
|
||||
status: string;
|
||||
}
|
||||
interface OnEventMetaData {
|
||||
error_code: string;
|
||||
error_message: string;
|
||||
error_type: string;
|
||||
exit_status: string;
|
||||
institution_id: string;
|
||||
institution_name: string;
|
||||
institution_search_query: string;
|
||||
link_session_id: string;
|
||||
mfa_type: string;
|
||||
request_id: string;
|
||||
timestamp: string;
|
||||
view_name: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Plaid } from "plaid-link";
|
||||
|
||||
const product: Plaid.Product = "auth";
|
||||
const env: Plaid.Environment = "sandbox";
|
||||
const language: Plaid.Language = "en";
|
||||
const user: Plaid.User = {
|
||||
legalName: "Test Name",
|
||||
emailAddress: "test@test.com"
|
||||
};
|
||||
|
||||
const config: Plaid.CreateConfig = {
|
||||
clientName: "Test Client Name",
|
||||
product: [product],
|
||||
key: "API_KEY",
|
||||
env,
|
||||
language,
|
||||
user,
|
||||
onSuccess: () => {}
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": ["index.d.ts", "plaid-link-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user