diff --git a/components/plaid/actions/create-access-token/create-access-token.mjs b/components/plaid/actions/create-access-token/create-access-token.mjs new file mode 100644 index 0000000000000..eda2324aa9624 --- /dev/null +++ b/components/plaid/actions/create-access-token/create-access-token.mjs @@ -0,0 +1,32 @@ +import app from "../../plaid.app.mjs"; + +export default { + key: "plaid-create-access-token", + name: "Create Access Token", + description: "Exchange a Link `public_token` for an API `access_token`. [See the documentation](https://plaid.com/docs/api/items/#itempublic_tokenexchange).", + version: "0.0.1", + type: "action", + props: { + app, + publicToken: { + propDefinition: [ + app, + "publicToken", + ], + }, + }, + async run({ $ }) { + const { + app, + publicToken, + } = this; + + const response = await app.exchangePublicToken({ + public_token: publicToken, + }); + + $.export("$summary", "Successfully created access token for public token"); + + return response; + }, +}; diff --git a/components/plaid/actions/create-sandbox-public-token/create-sandbox-public-token.mjs b/components/plaid/actions/create-sandbox-public-token/create-sandbox-public-token.mjs new file mode 100644 index 0000000000000..a3a7680bda373 --- /dev/null +++ b/components/plaid/actions/create-sandbox-public-token/create-sandbox-public-token.mjs @@ -0,0 +1,80 @@ +import app from "../../plaid.app.mjs"; +import institutions from "../../common/sandbox-institutions.mjs"; + +export default { + key: "plaid-create-sandbox-public-token", + name: "Create Sandbox Public Token", + description: "Creates a valid `public_token` for an arbitrary institution ID, initial products, and test credentials. [See the documentation](https://plaid.com/docs/api/sandbox/#sandboxpublic_tokencreate).", + version: "0.0.1", + type: "action", + props: { + app, + institutionId: { + type: "string", + label: "Institution ID", + description: "The ID of the institution the Item will be associated with", + options: Object.values(institutions), + }, + initialProducts: { + type: "string[]", + label: "Initial Products", + description: "The products to initially pull for the Item. May be any products that the specified institution supports.", + options: [ + "assets", + "auth", + "balance", + "employment", + "identity", + "income_verification", + "identity_verification", + "investments", + "liabilities", + "payment_initiation", + "standing_orders", + "statements", + "transactions", + "transfer", + ], + }, + webhookUrl: { + type: "string", + label: "Webhook URL", + description: "The URL to which Plaid should send webhook notifications. You must configure at least one webhook to enable webhooks.", + optional: true, + }, + userToken: { + type: "string", + label: "User Token", + description: "The user token associated with the User data is being requested for.", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + institutionId, + initialProducts, + webhookUrl, + userToken, + } = this; + + const response = await app.createSandboxPublicToken({ + institution_id: institutionId, + initial_products: initialProducts, + user_token: userToken, + ...( + webhookUrl + ? { + options: { + webhook: webhookUrl, + }, + } + : {} + ), + }); + + $.export("$summary", `Successfully created sandbox public token for institution ${institutionId}`); + + return response; + }, +}; diff --git a/components/plaid/actions/create-user/create-user.mjs b/components/plaid/actions/create-user/create-user.mjs new file mode 100644 index 0000000000000..7a57fee3dc9bd --- /dev/null +++ b/components/plaid/actions/create-user/create-user.mjs @@ -0,0 +1,135 @@ +import app from "../../plaid.app.mjs"; + +export default { + key: "plaid-create-user", + name: "Create User", + description: "Creates a user ID and token to be used with Plaid Check, Income, or Multi-Item Link flow. [See the documentation](https://plaid.com/docs/api/users/#usercreate).", + version: "0.0.1", + type: "action", + props: { + app, + clientUserId: { + type: "string", + label: "Client User ID", + description: "A unique ID representing the end user. Maximum of 128 characters. Typically this will be a user ID number from your application. Personally identifiable information, such as an email address or phone number, should not be used in the client_user_id.", + optional: false, + }, + includeConsumerReportUserIdentity: { + type: "boolean", + label: "Include Consumer Report User Identity", + description: "Whether to include the consumer report user identity. This is required for all Plaid Check customers.", + optional: true, + reloadProps: true, + }, + }, + additionalProps() { + if (!this.includeConsumerReportUserIdentity) { + return {}; + } + + return { + firstName: { + type: "string", + label: "First Name", + description: "The user's first name", + }, + lastName: { + type: "string", + label: "Last Name", + description: "The user's last name", + }, + phoneNumbers: { + type: "string[]", + label: "Phone Numbers", + description: "The user's phone number, in E.164 format: +{countrycode}{number}. For example: `+14157452130`. Phone numbers provided in other formats will be parsed on a best-effort basis. Phone number input is validated against valid number ranges; number strings that do not match a real-world phone numbering scheme may cause the request to fail, even in the Sandbox test environment.", + }, + emails: { + type: "string[]", + label: "Emails", + description: "The user's emails", + }, + ssnLast4: { + type: "string", + label: "SSN Last 4", + description: "The last 4 digits of the user's social security number.", + optional: true, + }, + dateOfBirth: { + type: "string", + label: "Date of Birth", + description: "To be provided in the format `yyyy-mm-dd`. This field is required for all Plaid Check customers.", + }, + primaryAddressCity: { + type: "string", + label: "City", + description: "The full city name for the primary address", + }, + primaryAddressRegion: { + type: "string", + label: "Region/State", + description: "The region or state. Example: `NC`", + }, + primaryAddressStreet: { + type: "string", + label: "Street", + description: "The full street address. Example: `564 Main Street, APT 15`", + }, + primaryAddressPostalCode: { + type: "string", + label: "Postal Code", + description: "The postal code", + }, + primaryAddressCountry: { + type: "string", + label: "Country", + description: "The ISO 3166-1 alpha-2 country code", + }, + }; + }, + async run({ $ }) { + const { + app, + clientUserId, + includeConsumerReportUserIdentity, + firstName, + lastName, + phoneNumbers, + emails, + ssnLast4, + dateOfBirth, + primaryAddressCity, + primaryAddressRegion, + primaryAddressStreet, + primaryAddressPostalCode, + primaryAddressCountry, + } = this; + + const response = await app.createUser({ + client_user_id: clientUserId, + ...(includeConsumerReportUserIdentity + ? { + consumer_report_user_identity: { + first_name: firstName, + last_name: lastName, + phone_numbers: phoneNumbers, + emails: emails, + date_of_birth: dateOfBirth, + ssn_last_4: ssnLast4, + primary_address: { + city: primaryAddressCity, + region: primaryAddressRegion, + street: primaryAddressStreet, + postal_code: primaryAddressPostalCode, + country: primaryAddressCountry, + }, + }, + } + : {} + ), + }); + + $.export("$summary", `Successfully created user with ID \`${response.user_id}\`.`); + + return response; + }, +}; diff --git a/components/plaid/actions/get-real-time-balance/get-real-time-balance.mjs b/components/plaid/actions/get-real-time-balance/get-real-time-balance.mjs new file mode 100644 index 0000000000000..477ad58529ca4 --- /dev/null +++ b/components/plaid/actions/get-real-time-balance/get-real-time-balance.mjs @@ -0,0 +1,47 @@ +import app from "../../plaid.app.mjs"; + +export default { + key: "plaid-get-real-time-balance", + name: "Get Real-Time Balance", + description: "Get the real-time balance for each of an Item's accounts. [See the documentation](https://plaid.com/docs/api/products/balance/#accountsbalanceget).", + version: "0.0.1", + type: "action", + props: { + app, + accessToken: { + propDefinition: [ + app, + "accessToken", + ], + }, + accountIds: { + type: "string[]", + label: "Account IDs", + description: "The specific account IDs to filter by. If not provided, all accounts will be returned.", + propDefinition: [ + app, + "accountId", + ({ accessToken }) => ({ + accessToken, + }), + ], + }, + }, + async run({ $ }) { + const { + app, + accessToken, + accountIds, + } = this; + + const response = await app.getAccountsBalance({ + access_token: accessToken, + options: { + account_ids: accountIds, + }, + }); + + $.export("$summary", "Successfully fetched account balances"); + return response; + }, +}; diff --git a/components/plaid/actions/get-transactions/get-transactions.mjs b/components/plaid/actions/get-transactions/get-transactions.mjs new file mode 100644 index 0000000000000..ceb16c7053183 --- /dev/null +++ b/components/plaid/actions/get-transactions/get-transactions.mjs @@ -0,0 +1,100 @@ +import app from "../../plaid.app.mjs"; + +export default { + key: "plaid-get-transactions", + name: "Get Transactions", + description: "Retrieves user-authorized transaction data for a specified date range. [See the documentation](https://plaid.com/docs/api/products/transactions/#transactionsget)", + version: "0.0.1", + type: "action", + props: { + app, + accessToken: { + propDefinition: [ + app, + "accessToken", + ], + }, + startDate: { + propDefinition: [ + app, + "startDate", + ], + }, + endDate: { + propDefinition: [ + app, + "endDate", + ], + }, + accountIds: { + type: "string[]", + label: "Account IDs", + description: "A list of `account_ids` to retrieve for the Item. Note: An error will be returned if a provided `account_id` is not associated with the Item.", + propDefinition: [ + app, + "accountId", + ({ accessToken }) => ({ + accessToken, + }), + ], + }, + includeOriginalDescription: { + type: "boolean", + label: "Include Original Description", + description: "Include the raw unparsed transaction description from the financial institution.", + default: false, + optional: true, + }, + daysRequested: { + type: "integer", + label: "Days Requested", + description: "Number of days of transaction history to request from the financial institution. Only applies when Transactions product hasn't been initialized. Min: 1, Max: 730, Default: 90.", + min: 1, + max: 730, + optional: true, + }, + }, + async run({ $ }) { + const { + app, + accessToken, + startDate, + endDate, + accountIds, + includeOriginalDescription, + daysRequested, + } = this; + + const options = {}; + + if (accountIds?.length) { + options.account_ids = accountIds; + } + + if (includeOriginalDescription !== undefined) { + options.include_original_description = includeOriginalDescription; + } + + if (daysRequested) { + options.days_requested = daysRequested; + } + + const transactions = await app.paginate({ + resourcesFn: app.getTransactions, + resourcesFnArgs: { + access_token: accessToken, + start_date: startDate, + end_date: endDate, + ...(Object.keys(options).length > 0 && { + options, + }), + }, + resourceName: "transactions", + }); + + const transactionCount = transactions?.length || 0; + $.export("$summary", `Successfully retrieved ${transactionCount} transactions from ${startDate} to ${endDate}`); + + return transactions; + }, +}; diff --git a/components/plaid/common/constants.mjs b/components/plaid/common/constants.mjs new file mode 100644 index 0000000000000..b48fc6e113f7a --- /dev/null +++ b/components/plaid/common/constants.mjs @@ -0,0 +1,7 @@ +const DEFAULT_LIMIT = 100; +const DEFAULT_MAX = 600; + +export default { + DEFAULT_LIMIT, + DEFAULT_MAX, +}; diff --git a/components/plaid/common/sandbox-institutions.mjs b/components/plaid/common/sandbox-institutions.mjs new file mode 100644 index 0000000000000..8d04851c6f8f4 --- /dev/null +++ b/components/plaid/common/sandbox-institutions.mjs @@ -0,0 +1,70 @@ +export default { + INS_109508: { + label: "First Platypus Bank (non-OAuth bank)", + value: "ins_109508", + }, + INS_109509: { + label: "First Gingham Credit Union (non-OAuth bank)", + value: "ins_109509", + }, + INS_109510: { + label: "Tattersall Federal Credit Union (non-OAuth bank)", + value: "ins_109510", + }, + INS_109511: { + label: "Tartan Bank (non-OAuth bank)", + value: "ins_109511", + }, + INS_109512: { + label: "Houndstooth Bank (for Instant Match and Automated Micro-deposit testing)", + value: "ins_109512", + }, + INS_43: { + label: "Tartan-Dominion Bank of Canada (Canadian bank)", + value: "ins_43", + }, + INS_116834: { + label: "Flexible Platypus Open Banking (UK Bank)", + value: "ins_116834", + }, + INS_117650: { + label: "Royal Bank of Plaid (UK Bank)", + value: "ins_117650", + }, + INS_127287: { + label: "Platypus OAuth Bank (for OAuth testing)", + value: "ins_127287", + }, + INS_132241: { + label: "First Platypus OAuth App2App Bank (for App-to-App OAuth testing)", + value: "ins_132241", + }, + INS_117181: { + label: "Flexible Platypus Open Banking (for OAuth QR code authentication testing)", + value: "ins_117181", + }, + INS_135858: { + label: "Windowpane Bank (for Instant Micro-deposit testing)", + value: "ins_135858", + }, + INS_132363: { + label: "Unhealthy Platypus Bank - Degraded", + value: "ins_132363", + }, + INS_132361: { + label: "Unhealthy Platypus Bank - Down", + value: "ins_132361", + }, + INS_133402: { + label: "Unsupported Platypus Bank - Institution Not Supported", + value: "ins_133402", + }, + INS_133502: { + label: "Platypus Bank RUX Auth (formerly for testing legacy RUX flows)", + value: "ins_133502", + }, + INS_133503: { + label: "Platypus Bank RUX Match (formerly for testing legacy RUX flows)", + value: "ins_133503", + }, +}; diff --git a/components/plaid/common/utils.mjs b/components/plaid/common/utils.mjs new file mode 100644 index 0000000000000..de7ee6c4a4692 --- /dev/null +++ b/components/plaid/common/utils.mjs @@ -0,0 +1,17 @@ +async function iterate(iterations) { + const items = []; + for await (const item of iterations) { + items.push(item); + } + return items; +} + +function getNestedProperty(obj, propertyString) { + const properties = propertyString.split("."); + return properties.reduce((prev, curr) => prev?.[curr], obj); +} + +export default { + iterate, + getNestedProperty, +}; diff --git a/components/plaid/package.json b/components/plaid/package.json index 7f32adbc649c1..4016241054653 100644 --- a/components/plaid/package.json +++ b/components/plaid/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/plaid", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream plaid Components", "main": "plaid.app.mjs", "keywords": [ @@ -13,6 +13,7 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^3.0.0" + "@pipedream/platform": "^3.0.3", + "plaid": "^33.0.0" } } diff --git a/components/plaid/plaid.app.mjs b/components/plaid/plaid.app.mjs index 0936822d9c23a..90246b499573f 100644 --- a/components/plaid/plaid.app.mjs +++ b/components/plaid/plaid.app.mjs @@ -1,11 +1,282 @@ +import { + PlaidApi, + Configuration, +} from "plaid"; +import constants from "./common/constants.mjs"; +import utils from "./common/utils.mjs"; + export default { type: "app", app: "plaid", - propDefinitions: {}, + propDefinitions: { + accessToken: { + type: "string", + label: "Access Token", + description: "The access token associated with the Item data is being requested for.", + }, + accountId: { + type: "string", + label: "Account ID", + description: "The specific account ID to filter by.", + optional: true, + async options({ accessToken }) { + if (!accessToken) { + return []; + } + + const { accounts } = await this.getAccounts({ + access_token: accessToken, + }); + return accounts.map(({ + account_id: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + startDate: { + type: "string", + label: "Start Date", + description: "The earliest date for which to fetch transaction data. Dates should be formatted as `YYYY-MM-DD`.", + }, + endDate: { + type: "string", + label: "End Date", + description: "The latest date for which to fetch transaction data. Dates should be formatted as `YYYY-MM-DD`.", + }, + publicToken: { + type: "string", + label: "Public Token", + description: "Your `public_token`, obtained from the Link `onSuccess` callback or **Create Sandbox Public Token** action component.", + }, + products: { + type: "string[]", + label: "Products", + description: "List of Plaid product(s) you wish to use. If launching Link in update mode, should be omitted (unless you are using update mode to add Income or Assets to an Item); required otherwise. [See the documentation](https://plaid.com/docs/api/link/#link-token-create-request-products).", + optional: true, + options: [ + "assets", + "auth", + "beacon", + "employment", + "identity", + "income_verification", + "identity_verification", + "investments", + "liabilities", + "payment_initiation", + "standing_orders", + "signal", + "statements", + "transactions", + "transfer", + "cra_base_report", + "cra_income_insights", + "cra_partner_insights", + "cra_network_insights", + "cra_cashflow_insights", + "layer", + ], + }, + requiredIfSupportedProducts: { + type: "string[]", + label: "Required If Supported Products", + description: "List of Plaid product(s) you wish to use only if the institution and account(s) selected by the user support the product. Institutions that do not support these products will still be shown in Link. The products will only be extracted and billed if the user selects an institution and account type that supports them. [See the documentation](https://plaid.com/docs/api/link/#link-token-create-request-required-if-supported-products).", + optional: true, + options: [ + "auth", + "identity", + "investments", + "liabilities", + "transactions", + "signal", + "statements", + ], + }, + optionalProducts: { + type: "string[]", + label: "Optional Products", + description: "List of Plaid product(s) that will enhance the consumer's use case, but that your app can function without. Plaid will attempt to fetch data for these products on a best-effort basis, and failure to support these products will not affect Item creation. [See the documentation](https://plaid.com/docs/api/link/#link-token-create-request-optional-products).", + optional: true, + options: [ + "auth", + "identity", + "investments", + "liabilities", + "signal", + "statements", + "transactions", + ], + }, + additionalConsentedProducts: { + type: "string[]", + label: "Additional Consented Products", + description: "List of additional Plaid product(s) you wish to collect consent for to support your use case. These products will not be billed until you start using them by calling the relevant endpoints. [See the documentation](https://plaid.com/docs/api/link/#link-token-create-request-additional-consented-products).", + optional: true, + options: [ + "auth", + "balance_plus", + "identity", + "investments", + "liabilities", + "transactions", + "signal", + ], + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getConf() { + const { + client_id: clientId, + client_secret: clientSecret, + environment: basePath, + } = this.$auth; + return new Configuration({ + basePath, + baseOptions: { + headers: { + "PLAID-CLIENT-ID": clientId, + "PLAID-SECRET": clientSecret, + }, + }, + }); + }, + getClient() { + return new PlaidApi(this.getConf()); + }, + async makeRequest({ + method, debug = false, otherOptions, ...args + } = {}) { + if (debug) { + console.log("Request args", args); + console.log("Request otherOptions", otherOptions); + console.log("Request method", method); + } + + if (!method) { + throw new Error("Method is required"); + } + + const client = this.getClient(); + try { + const response = await client[method](args, otherOptions); + + if (debug) { + console.log("Response", response); + } + + if (response.status !== 200) { + console.log("Status error", response); + throw new Error(`Status error: ${response.status} ${response.statusText}`); + } + + return response?.data; + } catch (error) { + console.error("Error making request", error.response); + throw new Error(JSON.stringify(error.response.data, null, 2)); + } + }, + createSandboxPublicToken(args = {}) { + return this.makeRequest({ + method: "sandboxPublicTokenCreate", + ...args, + }); + }, + exchangePublicToken(args = {}) { + return this.makeRequest({ + method: "itemPublicTokenExchange", + ...args, + }); + }, + getAccountsBalance(args = {}) { + return this.makeRequest({ + method: "accountsBalanceGet", + ...args, + }); + }, + getTransactions(args = {}) { + return this.makeRequest({ + method: "transactionsGet", + ...args, + }); + }, + getAccounts(args = {}) { + return this.makeRequest({ + method: "accountsGet", + ...args, + }); + }, + createLinkToken(args = {}) { + return this.makeRequest({ + method: "linkTokenCreate", + ...args, + }); + }, + getLinkToken(args = {}) { + return this.makeRequest({ + method: "linkTokenGet", + ...args, + }); + }, + createUser(args = {}) { + return this.makeRequest({ + method: "userCreate", + ...args, + }); + }, + async *getIterations({ + resourcesFn, resourcesFnArgs, resourceName, + lastDateAt, dateField, + max = constants.DEFAULT_MAX, + }) { + let offset = 0; + let resourcesCount = 0; + + while (true) { + const response = + await resourcesFn({ + ...resourcesFnArgs, + options: { + ...resourcesFnArgs?.options, + count: constants.DEFAULT_LIMIT, + offset, + }, + }); + + const nextResources = utils.getNestedProperty(response, resourceName); + + if (!nextResources?.length) { + console.log("No more resources found"); + return; + } + + for (const resource of nextResources) { + const isDateGreater = + lastDateAt + && Date.parse(resource[dateField]) >= Date.parse(lastDateAt); + + if (!lastDateAt || isDateGreater) { + yield resource; + resourcesCount += 1; + } + + if (resourcesCount >= max) { + console.log("Reached max resources"); + return; + } + } + + if (nextResources.length < constants.DEFAULT_LIMIT) { + console.log("No next page found"); + return; + } + + offset += constants.DEFAULT_LIMIT; + } + }, + paginate(args = {}) { + return utils.iterate(this.getIterations(args)); }, }, }; diff --git a/components/plaid/sources/common/events.mjs b/components/plaid/sources/common/events.mjs new file mode 100644 index 0000000000000..b857ff039de81 --- /dev/null +++ b/components/plaid/sources/common/events.mjs @@ -0,0 +1,31 @@ +const WEBHOOK_TYPE = { + ITEM: "ITEM", + ASSETS: "ASSETS", + TRANSACTIONS: "TRANSACTIONS", +}; + +const WEBHOOK_CODE = { + [WEBHOOK_TYPE.TRANSACTIONS]: { + INITIAL_UPDATE: "INITIAL_UPDATE", + HISTORICAL_UPDATE: "HISTORICAL_UPDATE", + DEFAULT_UPDATE: "DEFAULT_UPDATE", + TRANSACTIONS_REMOVED: "TRANSACTIONS_REMOVED", + SYNC_UPDATES_AVAILABLE: "SYNC_UPDATES_AVAILABLE", + }, + [WEBHOOK_TYPE.ASSETS]: { + PRODUCT_READY: "PRODUCT_READY", + ERROR: "ERROR", + }, + [WEBHOOK_TYPE.ITEM]: { + ERROR: "ERROR", + NEW_ACCOUNTS_AVAILABLE: "NEW_ACCOUNTS_AVAILABLE", + PENDING_EXPIRATION: "PENDING_EXPIRATION", + USER_PERMISSION_REVOKED: "USER_PERMISSION_REVOKED", + WEBHOOK_UPDATE_ACKNOWLEDGED: "WEBHOOK_UPDATE_ACKNOWLEDGED", + }, +}; + +export default { + WEBHOOK_TYPE, + WEBHOOK_CODE, +}; diff --git a/components/plaid/sources/common/webhook.mjs b/components/plaid/sources/common/webhook.mjs new file mode 100644 index 0000000000000..bf481357774a1 --- /dev/null +++ b/components/plaid/sources/common/webhook.mjs @@ -0,0 +1,88 @@ +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../plaid.app.mjs"; + +export default { + props: { + app, + db: "$.service.db", + http: "$.interface.http", + products: { + propDefinition: [ + app, + "products", + ], + }, + requiredIfSupportedProducts: { + propDefinition: [ + app, + "requiredIfSupportedProducts", + ], + }, + optionalProducts: { + propDefinition: [ + app, + "optionalProducts", + ], + }, + additionalConsentedProducts: { + propDefinition: [ + app, + "additionalConsentedProducts", + ], + }, + }, + hooks: { + async activate() { + const { + app, + getCreateLinkTokenArgs, + http: { endpoint: webhook }, + } = this; + + const response = await app.createLinkToken({ + user: { + client_user_id: "pdTestUser", + }, + client_name: "Pipedream App", + language: "en", + country_codes: [ + "US", + ], + products: [ + "transactions", + "assets", + ], + webhook, + update: { + account_selection_enabled: true, + }, + ...getCreateLinkTokenArgs(), + }); + console.log("createLinkToken response", response); + }, + }, + methods: { + generateMeta() { + throw new ConfigurationError("generateMeta is not implemented"); + }, + getCreateLinkTokenArgs() { + return {}; + }, + isEventRelevant() { + return true; + }, + processResource(resource) { + this.$emit(resource, this.generateMeta(resource)); + }, + }, + async run({ body }) { + const { + isEventRelevant, + processResource, + } = this; + + if (isEventRelevant(body)) { + processResource(body); + } + }, +}; diff --git a/components/plaid/sources/new-accounts-available-instant/new-accounts-available-instant.mjs b/components/plaid/sources/new-accounts-available-instant/new-accounts-available-instant.mjs new file mode 100644 index 0000000000000..53be6568d9756 --- /dev/null +++ b/components/plaid/sources/new-accounts-available-instant/new-accounts-available-instant.mjs @@ -0,0 +1,33 @@ +import common from "../common/webhook.mjs"; +import events from "../common/events.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "plaid-new-accounts-available-instant", + name: "New Accounts Available (Instant)", + description: "Emit new event when there are new accounts available at the Financial Institution. [See the documentation](https://plaid.com/docs/api/webhooks/).", + type: "source", + version: "0.0.1", + dedupe: "unique", + props: { + ...common.props, + }, + methods: { + ...common.methods, + isEventRelevant(resource) { + const webhookType = events.WEBHOOK_TYPE.ITEM; + const webhookCode = events.WEBHOOK_CODE[webhookType].NEW_ACCOUNTS_AVAILABLE; + return resource.webhook_type === webhookType && resource.webhook_code === webhookCode; + }, + generateMeta(resource) { + const ts = Date.now(); + return { + id: ts, + summary: `New Event: ${resource.webhook_type}.${resource.webhook_code}`, + ts, + }; + }, + }, + sampleEmit, +}; diff --git a/components/plaid/sources/new-accounts-available-instant/test-event.mjs b/components/plaid/sources/new-accounts-available-instant/test-event.mjs new file mode 100644 index 0000000000000..91ebe2d3bb848 --- /dev/null +++ b/components/plaid/sources/new-accounts-available-instant/test-event.mjs @@ -0,0 +1,7 @@ +export default { + "environment": "sandbox", + "error": null, + "item_id": "MqpWMopmPPhaon7EAZEgsqQ4p4qe3Rc9br7re", + "webhook_code": "NEW_ACCOUNTS_AVAILABLE", + "webhook_type": "ITEM" +}; diff --git a/components/plaid/sources/new-event-instant/new-event-instant.mjs b/components/plaid/sources/new-event-instant/new-event-instant.mjs new file mode 100644 index 0000000000000..4f6d3a0795f1c --- /dev/null +++ b/components/plaid/sources/new-event-instant/new-event-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/webhook.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "plaid-new-event-instant", + name: "New Event (Instant)", + description: "Emit new event when there are changes to Plaid Items or the status of asynchronous processes. [See the documentation](https://plaid.com/docs/api/webhooks/).", + type: "source", + version: "0.0.1", + dedupe: "unique", + methods: { + ...common.methods, + generateMeta(resource) { + const ts = Date.now(); + return { + id: ts, + summary: `New Event: ${resource.webhook_type}.${resource.webhook_code}`, + ts, + }; + }, + }, + sampleEmit, +}; diff --git a/components/plaid/sources/new-event-instant/test-event.mjs b/components/plaid/sources/new-event-instant/test-event.mjs new file mode 100644 index 0000000000000..cf0ba1760ac1c --- /dev/null +++ b/components/plaid/sources/new-event-instant/test-event.mjs @@ -0,0 +1,8 @@ +export default { + "environment": "sandbox", + "error": null, + "item_id": "MqpWMopmPPhaon7EAZEgsqQ4p4qe3Rc9br7re", + "new_webhook_url": "https://9708da2a66c1566b25dac75619c6d555.m.pipedream.net", + "webhook_code": "WEBHOOK_UPDATE_ACKNOWLEDGED", + "webhook_type": "ITEM" +}; \ No newline at end of file diff --git a/components/plaid/sources/sync-updates-available-instant/sync-updates-available-instant.mjs b/components/plaid/sources/sync-updates-available-instant/sync-updates-available-instant.mjs new file mode 100644 index 0000000000000..d0df6de6f4461 --- /dev/null +++ b/components/plaid/sources/sync-updates-available-instant/sync-updates-available-instant.mjs @@ -0,0 +1,30 @@ +import common from "../common/webhook.mjs"; +import events from "../common/events.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "plaid-sync-updates-available-instant", + name: "Sync Updates Available (Instant)", + description: "Emit new event when there are new updates available for a connected account. [See the documentation](https://plaid.com/docs/api/webhooks/).", + type: "source", + version: "0.0.1", + dedupe: "unique", + methods: { + ...common.methods, + isEventRelevant(resource) { + const webhookType = events.WEBHOOK_TYPE.TRANSACTIONS; + const webhookCode = events.WEBHOOK_CODE[webhookType].SYNC_UPDATES_AVAILABLE; + return resource.webhook_type === webhookType && resource.webhook_code === webhookCode; + }, + generateMeta(resource) { + const ts = Date.now(); + return { + id: ts, + summary: `New Event: ${resource.webhook_type}.${resource.webhook_code}`, + ts, + }; + }, + }, + sampleEmit, +}; diff --git a/components/plaid/sources/sync-updates-available-instant/test-event.mjs b/components/plaid/sources/sync-updates-available-instant/test-event.mjs new file mode 100644 index 0000000000000..28387ed93a678 --- /dev/null +++ b/components/plaid/sources/sync-updates-available-instant/test-event.mjs @@ -0,0 +1,8 @@ +export default { + "environment": "sandbox", + "historical_update_complete": true, + "initial_update_complete": true, + "item_id": "MqpWMopmPPhaon7EAZEgsqQ4p4qe3Rc9br7re", + "webhook_code": "SYNC_UPDATES_AVAILABLE", + "webhook_type": "TRANSACTIONS" +}; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15332352c2280..fa0d8715fb602 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9940,8 +9940,11 @@ importers: components/plaid: dependencies: '@pipedream/platform': - specifier: ^3.0.0 + specifier: ^3.0.3 version: 3.0.3 + plaid: + specifier: ^33.0.0 + version: 33.0.0 components/plain: dependencies: @@ -15379,14 +15382,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/browsers: dependencies: '@sparticuz/chromium': @@ -20482,8 +20477,8 @@ packages: '@types/node@18.19.68': resolution: {integrity: sha512-QGtpFH1vB99ZmTa63K4/FU8twThj4fuVSBkGddTp7uIL/cuoLWIUSL2RcOaigBhfR+hg5pgGkBnkoOxrTVBMKw==} - '@types/node@18.19.80': - resolution: {integrity: sha512-kEWeMwMeIvxYkeg1gTc01awpwLbfMRZXdIhwRcakd/KlK53jmRC26LqcbIt7fnAQTu5GzlnWmzA3H6+l1u6xxQ==} + '@types/node@18.19.87': + resolution: {integrity: sha512-OIAAu6ypnVZHmsHCeJ+7CCSub38QNBS9uceMQeg7K5Ur0Jr+wG9wEOEvvMbhp09pxD5czIUy/jND7s7Tb6Nw7A==} '@types/node@20.17.30': resolution: {integrity: sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==} @@ -21159,6 +21154,9 @@ packages: axios@1.8.4: resolution: {integrity: sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==} + axios@1.9.0: + resolution: {integrity: sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==} + axobject-query@4.1.0: resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} engines: {node: '>= 0.4'} @@ -23642,6 +23640,9 @@ packages: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} + fp-ts@2.16.10: + resolution: {integrity: sha512-vuROzbNVfCmUkZSUbnWSltR1sbheyQbTzug7LB/46fEa1c0EucLeBaCEUE0gF3ZGUGBt9lVUiziGOhhj6K1ORA==} + fp-ts@2.16.9: resolution: {integrity: sha512-+I2+FnVB+tVaxcYyQkHUq7ZdKScaBlX53A41mxQtpIccsfyv8PzdzP7fzp2AY832T4aoK6UZ5WRX/ebGd8uZuQ==} @@ -27216,6 +27217,10 @@ packages: pkg-types@1.2.1: resolution: {integrity: sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==} + plaid@33.0.0: + resolution: {integrity: sha512-xqch/Gn1GeWg/Mpg8E0zGTocplmFHP5BQjwpG8lLgY5L5Kexn1UdURkSfvEHTE9rmywsxinJy8Xkuoi+1WEBmg==} + engines: {node: '>=10.0.0'} + platform@1.3.6: resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} @@ -33253,7 +33258,7 @@ snapshots: '@definitelytyped/utils@0.1.8': dependencies: '@qiwi/npm-registry-client': 8.9.1 - '@types/node': 18.19.80 + '@types/node': 18.19.87 cachedir: 2.4.0 charm: 1.0.2 minimatch: 9.0.5 @@ -35201,9 +35206,9 @@ snapshots: '@pipedream/platform@3.0.3': dependencies: - axios: 1.8.4(debug@3.2.7) - fp-ts: 2.16.9 - io-ts: 2.2.22(fp-ts@2.16.9) + axios: 1.9.0 + fp-ts: 2.16.10 + io-ts: 2.2.22(fp-ts@2.16.10) querystring: 0.2.1 transitivePeerDependencies: - debug @@ -35629,8 +35634,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: @@ -37659,7 +37662,7 @@ snapshots: dependencies: undici-types: 5.26.5 - '@types/node@18.19.80': + '@types/node@18.19.87': dependencies: undici-types: 5.26.5 @@ -38390,7 +38393,7 @@ snapshots: dependencies: '@aws-sdk/util-utf8-browser': 3.259.0 '@httptoolkit/websocket-stream': 6.0.1 - axios: 1.8.4(debug@3.2.7) + axios: 1.9.0 buffer: 6.0.3 crypto-js: 4.2.0 mqtt: 4.3.8 @@ -38496,6 +38499,14 @@ snapshots: transitivePeerDependencies: - debug + axios@1.9.0: + dependencies: + follow-redirects: 1.15.9(debug@3.2.7) + form-data: 4.0.2 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + axobject-query@4.1.0: {} b4a@1.6.7: {} @@ -41571,6 +41582,8 @@ snapshots: forwarded@0.2.0: {} + fp-ts@2.16.10: {} + fp-ts@2.16.9: {} fraction.js@4.3.7: {} @@ -42815,9 +42828,9 @@ snapshots: dependencies: fp-ts: 2.16.9 - io-ts@2.2.22(fp-ts@2.16.9): + io-ts@2.2.22(fp-ts@2.16.10): dependencies: - fp-ts: 2.16.9 + fp-ts: 2.16.10 ip-address@9.0.5: dependencies: @@ -46054,7 +46067,7 @@ snapshots: openai@4.97.0(ws@8.18.0)(zod@3.24.4): dependencies: - '@types/node': 18.19.80 + '@types/node': 18.19.87 '@types/node-fetch': 2.6.12 abort-controller: 3.0.0 agentkeepalive: 4.5.0 @@ -46479,6 +46492,12 @@ snapshots: mlly: 1.7.3 pathe: 1.1.2 + plaid@33.0.0: + dependencies: + axios: 1.9.0 + transitivePeerDependencies: + - debug + platform@1.3.6: {} playwright-core@1.41.2: {}