diff --git a/package.json b/package.json index e3602c0..874fcc5 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "files": [ "dist" ], + "types": "types/index.d.ts", "scripts": { "test": "mocha --recursive --timeout 100000", "test-nodes": "mocha --recursive test/nodesTests/*.js --timeout 100000", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0658582 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es6", + "downlevelIteration": true, + "module": "commonjs", + "declaration": true, + "declarationDir": "./types", + "outDir": "./dist", + "allowSyntheticDefaultImports": true, + "strict": true, + "resolveJsonModule": true, + "removeComments": false, + "esModuleInterop": true, + "noImplicitAny": false, + "allowJs": true + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules" + ], + "lib": [ + "ESNext" + ] +} diff --git a/types/apiReqs/apiReqsClient.d.ts b/types/apiReqs/apiReqsClient.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/types/apiReqs/apiReqsClient.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/apiReqs/apiReqsUser.d.ts b/types/apiReqs/apiReqsUser.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/types/apiReqs/apiReqsUser.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/types/apiReqs/apiRequests.d.ts b/types/apiReqs/apiRequests.d.ts new file mode 100644 index 0000000..4f2cdd3 --- /dev/null +++ b/types/apiReqs/apiRequests.d.ts @@ -0,0 +1,2 @@ +export const client: typeof import("./apiReqsClient"); +export const user: typeof import("./apiReqsUser"); diff --git a/types/constants/apiReqNames.d.ts b/types/constants/apiReqNames.d.ts new file mode 100644 index 0000000..83e7ffc --- /dev/null +++ b/types/constants/apiReqNames.d.ts @@ -0,0 +1,61 @@ +export const createUser: string; +export const getAllUsers: string; +export const getUser: string; +export const getPlatformTransactions: string; +export const getUserTransactions: string; +export const getPlatformNodes: string; +export const getInstitutions: string; +export const triggerDummyTransactions: string; +export const issuePublicKey: string; +export const createSubscription: string; +export const getAllSubscriptions: string; +export const getSubscription: string; +export const updateSubscription: string; +export const addUserKyc: string; +export const deleteExistingDocument: string; +export const updateUser: string; +export const getUserDuplicates: string; +export const swapDuplicateUsers: string; +export const _grabRefreshToken: string; +export const _oauthUser: string; +export const createNode: string; +export const verifyAchMfa: string; +export const getAllUserNodes: string; +export const getNode: string; +export const generateUboForm: string; +export const getStatementsByUser: string; +export const getStatementsByNode: string; +export const shipCardNode: string; +export const resetCardNode: string; +export const verifyMicroDeposits: string; +export const reinitiateMicroDeposits: string; +export const updateNode: string; +export const deleteNode: string; +export const generateApplePayToken: string; +export const createTransaction: string; +export const getTransaction: string; +export const getAllNodeTransactions: string; +export const deleteTransaction: string; +export const commentOnStatus: string; +export const disputeCardTransaction: string; +export const getAllSubnets: string; +export const getSubnet: string; +export const createSubnet: string; +export const updateSubnet: string; +export const pushToMobileWallet: string; +export const registerNewFingerprint: string; +export const supplyDevice2FA: string; +export const verifyFingerprint2FA: string; +export const locateAtms: string; +export const verifyAddress: string; +export const getCryptoQuotes: string; +export const getCryptoMarketData: string; +export const getWebhookLogs: string; +export const shipCard: string; +export const updateIpAddress: string; +export const getTradeMarketData: string; +export const verifyRoutingNumber: string; +export const createBatchTransactions: string; +export const getAllCardShipments: string; +export const getCardShipment: string; +export const deleteCardShipment: string; diff --git a/types/helpers/buildHeaders.d.ts b/types/helpers/buildHeaders.d.ts new file mode 100644 index 0000000..8ba0fc4 --- /dev/null +++ b/types/helpers/buildHeaders.d.ts @@ -0,0 +1,12 @@ +declare function _exports({ client_id, client_secret, oauth_key, fingerprint, ip_address, idempotency_key }: { + client_id: any; + client_secret: any; + oauth_key: any; + fingerprint: any; + ip_address: any; + idempotency_key: any; +}): { + 'Content-Type': string; + 'X-SP-USER-IP': any; +}; +export = _exports; diff --git a/types/helpers/buildUrls.d.ts b/types/helpers/buildUrls.d.ts new file mode 100644 index 0000000..cac9ff4 --- /dev/null +++ b/types/helpers/buildUrls.d.ts @@ -0,0 +1,29 @@ +export function addQueryParams({ originalUrl, amount, query, page, per_page, filter, show_refresh_tokens, full_dehydrate, force_refresh, type, zip, lat, lon, radius, limit, currency, foreign_transaction, is_credit, subnet_id, ticker }: { + originalUrl: any; + amount: any; + query: any; + page: any; + per_page: any; + filter: any; + show_refresh_tokens: any; + full_dehydrate: any; + force_refresh: any; + type: any; + zip: any; + lat: any; + lon: any; + radius: any; + limit: any; + currency: any; + foreign_transaction: any; + is_credit: any; + subnet_id: any; + ticker: any; +}): any; +export function replacePathParams({ originalUrl, user_id, node_id, trans_id, subnet_id }: { + originalUrl: any; + user_id: any; + node_id: any; + trans_id: any; + subnet_id: any; +}): any; diff --git a/types/helpers/clientHelpers.d.ts b/types/helpers/clientHelpers.d.ts new file mode 100644 index 0000000..26ff2be --- /dev/null +++ b/types/helpers/clientHelpers.d.ts @@ -0,0 +1,7 @@ +export function checkOptions(headerObj: any, options: any): any; +export function instantiateUser({ data, headerObj, client }: { + data: any; + headerObj: any; + client: any; +}): Promise; +import User = require("../lib/User"); diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..1e7ec55 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,3 @@ +import Client = require("./lib/Client"); +import User = require("./lib/User"); +export { Client, User }; diff --git a/types/lib/Client.d.ts b/types/lib/Client.d.ts new file mode 100644 index 0000000..12adcd3 --- /dev/null +++ b/types/lib/Client.d.ts @@ -0,0 +1,39 @@ +export = Client; +declare class Client { + constructor({ client_id, client_secret, fingerprint, ip_address, isProduction }: { + client_id: any; + client_secret: any; + fingerprint: any; + ip_address: any; + isProduction: any; + }); + client_id: any; + client_secret: any; + fingerprint: any; + ip_address: any; + isProduction: any; + host: string; + headers: { + 'Content-Type': string; + 'X-SP-USER-IP': any; + }; + createUser(bodyParams: any, ip_address: any, options?: null): Promise; + getAllUsers(queryParams?: {}): any; + getUser(user_id: any, options?: null): Promise; + getPlatformTransactions(queryParams?: {}): any; + getPlatformNodes(queryParams?: {}): any; + getInstitutions(): any; + issuePublicKey(scope?: string[], userId?: null): any; + createSubscription(url: any, scope?: string[], idempotency_key?: null): any; + getAllSubscriptions(queryParams?: {}): any; + getSubscription(subscription_id: any): any; + updateSubscription(subscription_id: any, bodyParams?: {}): any; + locateAtms(queryParams?: {}): any; + verifyAddress(queryParams?: {}): any; + verifyRoutingNumber(queryParams?: {}): any; + getCryptoQuotes(): any; + getCryptoMarketData(queryParams?: {}): any; + getWebhookLogs(): any; + getTradeMarketData(queryParams?: {}): any; +} +import User = require("./User"); diff --git a/types/lib/User.d.ts b/types/lib/User.d.ts new file mode 100644 index 0000000..8a3e394 --- /dev/null +++ b/types/lib/User.d.ts @@ -0,0 +1,130 @@ +export = User; +declare class User { + constructor({ data, headerObj, client }: { + data: any; + headerObj: any; + client: any; + }); + id: any; + body: any; + host: any; + fingerprint: any; + ip_address: any; + oauth_key: string; + client: any; + headers: { + 'Content-Type': string; + 'X-SP-USER-IP': any; + }; + addUserKyc(bodyParams?: {}): any; + deleteExistingDocument(bodyParams?: {}): any; + updateUser(bodyParams?: {}): any; + /** + * GET ALL USER DUPLICATES + * + * @returns Promise + * + * [Get User Duplicates Docs]{@link https://docs.synapsefi.com/api-references/users/manage-duplicates#example-request} + */ + getUserDuplicates(): any; + /** + * SWAP DUPLICATE USER + * @param {String} swap_to_user_id required: User ID you'd like to swap the open status with + * + * @returns Promise + * + * [Swap Duplicate User Docs]{@link https://docs.synapsefi.com/api-references/users/manage-duplicates#example-request-1} + */ + swapDuplicateUsers(swap_to_user_id: string): any; + _grabRefreshToken(): any; + _oauthUser(bodyParams?: {}): any; + createNode(bodyParams?: {}, idempotency_key?: null): any; + verifyAchMfa(access_token: any, mfa_answer: any, idempotency_key?: null): any; + getAllUserNodes(queryParams?: {}): any; + getNode(node_id: any, queryParams?: {}): any; + getUserTransactions(queryParams?: {}): any; + triggerDummyTransactions(node_id: any, queryParams?: {}): any; + generateUboForm(bodyParams: any): any; + getStatementsByUser(queryParams?: {}): any; + getStatementsByNode(node_id: any, queryParams?: {}): any; + shipCardNode(node_id: any, bodyParams: any): any; + resetCardNode(node_id: any): any; + verifyMicroDeposits(node_id: any, bodyParams: any): any; + reinitiateMicroDeposits(node_id: any): any; + updateNode(node_id: any, bodyParams: any): any; + deleteNode(node_id: any): any; + generateApplePayToken(node_id: any, bodyParams: any): any; + createTransaction(node_id: any, bodyParams: any, idempotency_key?: null): any; + /** + * + * @param {String} node_id required: id of node on which to create bulk transactions + * @param {Object} bodyParams required: body of post request, must have transactions key, which is an array of transaction objects + * @param {Array} bodyParams.transactions + * + * @returns Promise + * + * Idempotency keys can be provided for each transaction, inside each transaction object's `extra` key. + * + * e.g. `{ transactions: [{ extra: { idempotency_key: 'idemPotKeyStr' } }] }` + * + * [Batch Transaction Docs]{@link https://docs.synapsefi.com/api-references/transactions/create-batch-transactions} + * [Trans Object Details]{@link https://docs.synapsefi.com/api-references/transactions/transaction-object-details} + */ + createBatchTransactions(node_id: string, bodyParams: { + transactions: any[]; + }): any; + getTransaction(node_id: any, trans_id: any): any; + getAllNodeTransactions(node_id: any, queryParams?: {}): any; + deleteTransaction(node_id: any, trans_id: any): any; + commentOnStatus(node_id: any, trans_id: any, bodyParams: any): any; + disputeCardTransaction(node_id: any, trans_id: any, bodyParams: any): any; + getAllSubnets(node_id: any, queryParams?: {}): any; + getSubnet(node_id: any, subnet_id: any, queryParams?: {}): any; + createSubnet(node_id: any, bodyParams: any, idempotency_key?: null): any; + updateSubnet(node_id: any, subnet_id: any, bodyParams?: {}): any; + pushToMobileWallet(node_id: any, subnet_id: any, bodyParams?: {}): any; + shipCard(node_id: any, subnet_id: any, bodyParams?: {}): any; + /** + * GET ALL CARD SHIPMENTS + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} queryParams optional: body of post request, can contain page and per_page keys indicating the amount of card shipments returned + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/view-all-subnet-shipments} + */ + getAllCardShipments(node_id: string, subnet_id: string, queryParams?: any): any; + /** + * GET A SINGLE CARD SHIPMENT + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} shipment_id requred: id of card shipment + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/view-shipment} + */ + getCardShipment(node_id: string, subnet_id: string, shipment_id: any): any; + /** + * DELETE A SINGLE CARD SHIPMENT + * @param {String} node_id required: id of node belonging to the subnet + * @param {String} subnet_id required: id of card subnet for the card shipments + * @param {Object} shipment_id requred: id of card shipment + * + * @returns Promise + * + * + * [Get Card Shipment Docs]{@link https://docs.synapsefi.com/api-references/shipments/cancel-shipment} + */ + deleteCardShipment(node_id: string, subnet_id: string, shipment_id: any): any; + registerNewFingerprint(fp: any): Promise; + supplyDevice2FA(fp: any, device: any): Promise; + verifyFingerprint2FA(fp: any, validation_pin: any): Promise; + updateIpAddress(ip: any): { + 'Content-Type': string; + 'X-SP-USER-IP': any; + }; +}