diff --git a/components/demandbase/actions/company-lookup/company-lookup.mjs b/components/demandbase/actions/company-lookup/company-lookup.mjs new file mode 100644 index 0000000000000..ae74c6c5f5395 --- /dev/null +++ b/components/demandbase/actions/company-lookup/company-lookup.mjs @@ -0,0 +1,291 @@ +import app from "../../demandbase.app.mjs"; +import utils from "../../common/utils.mjs"; +import agents from "../../common/agents.mjs"; +import states from "../../common/states.mjs"; + +export default { + key: "demandbase-company-lookup", + name: "Company Lookup", + description: "Build a list of company names along with company ID, city, state and country using rich filters.. [See the documentation](https://kb.demandbase.com/hc/en-us/articles/7273850579227--POST-Company-Lookup).", + version: "0.0.1", + type: "action", + props: { + app, + agents: { + type: "string[]", + label: "Agents", + description: "The agent IDs.", + optional: true, + options: Object.values(agents), + }, + areaCodes: { + type: "string[]", + label: "Area Codes", + description: "List of area codes.", + optional: true, + }, + businessTypes: { + type: "string[]", + label: "Business Types", + description: "List of business types.", + optional: true, + options: [ + "public", + "private", + "school", + "government", + "organization", + ], + }, + cities: { + type: "string[]", + label: "Cities", + description: "List of cities.", + optional: true, + }, + companyStatus: { + type: "string[]", + label: "Company Status", + description: "List of company statuses.", + optional: true, + options: [ + "operating", + "subsidiary", + "acquired", + ], + }, + countries: { + type: "string[]", + label: "Countries", + description: "List of country IDs.", + propDefinition: [ + app, + "countryId", + ], + }, + fiscalYearEnd: { + type: "string", + label: "Fiscal Year End", + description: "The fiscal year end. Eg. `january`.", + optional: true, + }, + fortuneRanking: { + type: "string", + label: "Fortune Ranking", + description: "The fortune ranking.", + optional: true, + options: [ + "fortune500", + "fortune1000", + ], + }, + industries: { + propDefinition: [ + app, + "industries", + ], + }, + subIndustries: { + label: "Sub Industries", + description: "List of sub industry IDs.", + propDefinition: [ + app, + "industries", + ({ industries: industryIds }) => ({ + listSubindustries: true, + industryIds, + }), + ], + }, + keywords: { + type: "string", + label: "Keywords", + description: "Keywords.", + optional: true, + }, + companyName: { + type: "string", + label: "Company Name", + description: "Name of the company.", + optional: true, + }, + minEmployees: { + type: "integer", + label: "Min Employees", + description: "Minimum number of employees.", + optional: true, + }, + maxEmployees: { + type: "integer", + label: "Max Employees", + description: "Maximum number of employees.", + optional: true, + }, + minRevenue: { + type: "integer", + label: "Min Revenue", + description: "Minimum revenue (Millions of $).", + optional: true, + }, + maxRevenue: { + type: "integer", + label: "Max Revenue", + description: "Maximum revenue (Millions of $).", + optional: true, + }, + categoryIds: { + propDefinition: [ + app, + "categoryIds", + ], + }, + hasPhone: { + type: "boolean", + label: "Has Phone", + description: "View companies with a phone number.", + optional: true, + }, + regions: { + type: "string[]", + label: "Regions", + description: "List of regions.", + optional: true, + options: [ + "Africa", + "Asia", + "Europe", + "MiddleEast", + "NorthAmerica", + "Oceania", + "SouthAmerica", + ], + }, + street: { + type: "string", + label: "Street", + description: "Street name.", + optional: true, + }, + state: { + type: "string[]", + label: "States", + description: "List of state IDs.", + optional: true, + options: states, + }, + zipCodes: { + type: "string[]", + label: "Zip Codes", + description: "List of zip codes.", + optional: true, + }, + businessStructure: { + type: "string", + label: "Business Structure", + description: "Business structure.", + optional: true, + options: [ + "globalParent", + "uncategorized", + "subsidiary", + "group", + "independent", + ], + }, + sortBy: { + type: "string", + label: "Sort By", + description: "Attributes used to sort the list of results.", + optional: true, + options: [ + "popularity", + "revenue", + "employee_count", + "businessType", + "location", + ], + }, + sortOrder: { + type: "string", + label: "Sort Order", + description: "Sort order.", + optional: true, + options: [ + "asc", + "desc", + ], + }, + }, + methods: { + companyLookup(args = {}) { + return this.app.post({ + path: "/target/company/lookup", + ...args, + }); + }, + }, + async run({ $ }) { + const { + companyLookup, + agents, + areaCodes, + businessTypes, + cities, + companyStatus, + countries, + fiscalYearEnd, + fortuneRanking, + industries, + subIndustries, + keywords, + companyName, + minEmployees, + maxEmployees, + minRevenue, + maxRevenue, + categoryIds, + hasPhone, + regions, + street, + state, + zipCodes, + sortBy, + sortOrder, + } = this; + + const response = await companyLookup({ + $, + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + data: utils.getUrlEncodedData({ + agents, + areaCodes, + businessTypes, + cities, + companyStatus, + countries, + fiscalYearEnd, + fortuneRanking, + industries, + subIndustries, + keywords, + companyName, + minEmployees, + maxEmployees, + minRevenue, + maxRevenue, + categoryIds, + hasPhone, + regions, + street, + state, + zipCodes, + sortBy, + sortOrder, + }), + }); + $.export("$summary", "Successfully built company list."); + return response; + }, +}; diff --git a/components/demandbase/actions/contact-search/contact-search.mjs b/components/demandbase/actions/contact-search/contact-search.mjs new file mode 100644 index 0000000000000..c594bf5d533dd --- /dev/null +++ b/components/demandbase/actions/contact-search/contact-search.mjs @@ -0,0 +1,258 @@ +import app from "../../demandbase.app.mjs"; +import states from "../../common/states.mjs"; +import utils from "../../common/utils.mjs"; + +export default { + key: "demandbase-contact-search", + name: "Contact Search", + description: "Fetch a list of contacts. [See the documentation](https://kb.demandbase.com/hc/en-us/articles/7274525391515--GET-Contact-Search).", + version: "0.0.1", + type: "action", + props: { + app, + // eslint-disable-next-line pipedream/props-label, pipedream/props-description + info: { + type: "alert", + alertType: "info", + content: "**Email**, **Last Name** or **Full Name** should be present in the search query.", + }, + email: { + type: "string", + label: "Email", + description: "The email address of the contact.", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "Contact last name.", + optional: true, + }, + fullName: { + type: "string", + label: "Full Name", + description: "Contact full name.", + optional: true, + }, + firstName: { + type: "string", + label: "First Name", + description: "Contact first name.", + optional: true, + }, + middleName: { + type: "string", + label: "Middle Name", + description: "Contact middle name.", + optional: true, + }, + country: { + label: "Country", + description: "Country name.", + propDefinition: [ + app, + "countryId", + () => ({ + mapper: ({ countryName }) => countryName, + }), + ], + }, + state: { + type: "string", + label: "State", + description: "State name for company search.", + optional: true, + options: states.map(({ label }) => label), + }, + city: { + type: "string", + label: "City", + description: "City Name of company search.", + optional: true, + }, + zip: { + type: "string", + label: "Zip", + description: "Zip code for company search.", + optional: true, + }, + peopleCountries: { + type: "string[]", + label: "People Countries", + description: "People country Ids.", + propDefinition: [ + app, + "countryId", + ], + }, + peopleStates: { + type: "string[]", + label: "People States", + description: "People states.", + optional: true, + options: states, + }, + peopleCities: { + type: "string[]", + label: "People Cities", + description: "People Cities.", + optional: true, + }, + peopleArea: { + type: "string", + label: "People Area", + description: "Area for the search.", + optional: true, + }, + peopleAddress: { + type: "string", + label: "People Address", + description: "Address for the search.", + optional: true, + }, + companyName: { + type: "string", + label: "Company Name", + description: "Contact current Company Name", + optional: true, + }, + companyWebsite: { + type: "string", + label: "Company Website", + description: "Contact current Company website (Only as Relevence filter).", + optional: true, + }, + active: { + type: "boolean", + label: "Active", + description: "If present will return only **active** or **inactive** records, depending on the value (true or false)", + optional: true, + }, + isEmailRequired: { + type: "boolean", + label: "Is Email Required", + description: "If present and equals to `true`, the API will return only contact having an email address.", + optional: true, + }, + isPhoneRequired: { + type: "boolean", + label: "Is Phone Required", + description: "If present and equals to `true`, the API will return only contact having a phone number.", + optional: true, + }, + emailValidationStatus: { + type: "string[]", + label: "Email Validation Status", + description: "It allows you to retrieve the validation status of the email.", + optional: true, + options: [ + "ValidDomain", + "ValidEmail", + ], + }, + minContactConfidenceScore: { + type: "integer", + label: "Min Contact Confidence Score", + description: "The minimum contact confidence score. The valid values range from `0` to `100`.", + optional: true, + min: 0, + max: 100, + }, + maxContactConfidenceScore: { + type: "integer", + label: "Max Contact Confidence Score", + description: "The maximum contact confidence score. The valid values range from `0` to `100`.", + optional: true, + min: 0, + max: 100, + }, + phoneType: { + type: "string", + label: "Phone Type", + description: "Accepts DIRECT, CORP, MOBILE, and ANY to find the corresponding contact's phone numbers.", + optional: true, + options: [ + "DIRECT", + "CORP", + "MOBILE", + "ANY", + ], + }, + titles: { + type: "string", + label: "Titles", + description: "Return the job titles of an executive.", + optional: true, + }, + }, + methods: { + contactSearch(args = {}) { + return this.app._makeRequest({ + path: "/contacts", + ...args, + }); + }, + }, + async run({ $ }) { + const { + contactSearch, + email, + lastName, + firstName, + middleName, + fullName, + country, + state, + city, + zip, + peopleCountries, + peopleStates, + peopleCities, + peopleArea, + peopleAddress, + companyName, + companyWebsite, + active, + isEmailRequired, + isPhoneRequired, + emailValidationStatus, + minContactConfidenceScore, + maxContactConfidenceScore, + phoneType, + titles, + } = this; + + const response = await contactSearch({ + $, + params: { + email, + lastName, + firstName, + middleName, + fullName, + country, + state, + city, + zip, + peopleCountries: utils.arrayToCommaSeparatedList(peopleCountries), + peopleStates: utils.arrayToCommaSeparatedList(peopleStates), + peopleCities: utils.arrayToCommaSeparatedList(peopleCities), + peopleArea, + peopleAddress, + companyName, + companyWebsite, + active, + isEmailRequired, + isPhoneRequired, + emailValidationStatus: utils.arrayToCommaSeparatedList(emailValidationStatus), + minContactConfidenceScore, + maxContactConfidenceScore, + phoneType, + titles, + resultsPerPage: 50, + }, + }); + $.export("$summary", "Successfully fetched contacts."); + return response; + }, +}; diff --git a/components/demandbase/common/agents.mjs b/components/demandbase/common/agents.mjs new file mode 100644 index 0000000000000..255b91a8d9652 --- /dev/null +++ b/components/demandbase/common/agents.mjs @@ -0,0 +1,74 @@ +export default { + LEADERSHIP_CHANGES: { + value: "LEADERSHIP_CHANGES", + label: "Leadership Changes", + }, + NEW_OFFERINGS: { + value: "NEW_OFFERINGS", + label: "New Offerings", + }, + ACQUISITIONS: { + value: "ACQUISITIONS", + label: "Acquisitions", + }, + PARTNERSHIPS: { + value: "PARTNERSHIPS", + label: "Partnerships", + }, + EXPANDING_OPERATIONS: { + value: "EXPANDING_OPERATIONS", + label: "Expanding Operations", + }, + COST_CUTTING: { + value: "COST_CUTTING", + label: "Cost Cutting", + }, + OUTPERFORMING: { + value: "OUTPERFORMING", + label: "Outperforming", + }, + UNDERPERFORMING: { + value: "UNDERPERFORMING", + label: "Underperforming", + }, + COMPANY_PRESENTATION: { + value: "COMPANY_PRESENTATION", + label: "Company Presentation", + }, + LITIGATION: { + value: "LITIGATION", + label: "Litigation", + }, + COMPLIANCE: { + value: "COMPLIANCE", + label: "Compliance", + }, + RESEARCH_DEVELOPMENT: { + value: "RESEARCH_DEVELOPMENT", + label: "Research & Development", + }, + DATA_SECURITY: { + value: "DATA_SECURITY", + label: "Data Security", + }, + FUNDING_DEVELOPMENTS: { + value: "FUNDING_DEVELOPMENTS", + label: "Funding Developments", + }, + BANKRUPTCY_RESTRUCTURING: { + value: "BANKRUPTCY_RESTRUCTURING", + label: "Bankruptcy & Restructuring", + }, + REALESTATE_DEALS: { + value: "REALESTATE_DEALS", + label: "Real Estate: Deals", + }, + REALESTATE_CONSTRUCTION: { + value: "REALESTATE_CONSTRUCTION", + label: "Real Estate: Construction", + }, + CORPORATE_CHALLENGES: { + value: "CORPORATE_CHALLENGES", + label: "Corporate Challenges", + }, +}; diff --git a/components/demandbase/common/constants.mjs b/components/demandbase/common/constants.mjs new file mode 100644 index 0000000000000..6e3b0444ee07b --- /dev/null +++ b/components/demandbase/common/constants.mjs @@ -0,0 +1,20 @@ +const BASE_URL = "https://api.insideview.com"; +const VERSION_PATH = "/api/v1"; + +const SUBSCRIPTION_ID = "subscriptionId"; +const SECRET = "secret"; + +const SUBSCRIPTION_TYPE = { + COMPANY: "company", + COMPANY_NEWS: "companyNews", + PEOPLE: "people", + COMPANY_FAMILY_TREE: "companyFamilyTree", +}; + +export default { + BASE_URL, + VERSION_PATH, + SUBSCRIPTION_ID, + SECRET, + SUBSCRIPTION_TYPE, +}; diff --git a/components/demandbase/common/states.mjs b/components/demandbase/common/states.mjs new file mode 100644 index 0000000000000..795471c024aa8 --- /dev/null +++ b/components/demandbase/common/states.mjs @@ -0,0 +1,1622 @@ +export default [ + { + value: "AK", + label: "Alaska", + }, + { + value: "AL", + label: "Alabama", + }, + { + value: "AR", + label: "Arkansas", + }, + { + value: "AZ", + label: "Arizona", + }, + { + value: "CA", + label: "California", + }, + { + value: "CO", + label: "Colorado", + }, + { + value: "CT", + label: "Connecticut", + }, + { + value: "DC", + label: "District of Columbia", + }, + { + value: "DE", + label: "Delaware", + }, + { + value: "FL", + label: "Florida", + }, + { + value: "GA", + label: "Georgia", + }, + { + value: "HI", + label: "Hawaii", + }, + { + value: "IA", + label: "Iowa", + }, + { + value: "ID", + label: "Idaho", + }, + { + value: "IL", + label: "Illinois", + }, + { + value: "IN", + label: "Indiana", + }, + { + value: "KS", + label: "Kansas", + }, + { + value: "KY", + label: "Kentucky", + }, + { + value: "LA", + label: "Louisiana", + }, + { + value: "MA", + label: "Massachusetts", + }, + { + value: "MD", + label: "Maryland", + }, + { + value: "ME", + label: "Maine", + }, + { + value: "MI", + label: "Michigan", + }, + { + value: "MN", + label: "Minnesota", + }, + { + value: "MO", + label: "Missouri", + }, + { + value: "MS", + label: "Mississippi", + }, + { + value: "MT", + label: "Montana", + }, + { + value: "NC", + label: "North Carolina", + }, + { + value: "ND", + label: "North Dakota", + }, + { + value: "NE", + label: "Nebraska", + }, + { + value: "NH", + label: "New Hampshire", + }, + { + value: "NJ", + label: "New Jersey", + }, + { + value: "NM", + label: "New Mexico", + }, + { + value: "NV", + label: "Nevada", + }, + { + value: "NY", + label: "New York", + }, + { + value: "OH", + label: "Ohio", + }, + { + value: "OK", + label: "Oklahoma", + }, + { + value: "OR", + label: "Oregon", + }, + { + value: "PA", + label: "Pennsylvania", + }, + { + value: "RI", + label: "Rhode Island", + }, + { + value: "SC", + label: "South Carolina", + }, + { + value: "SD", + label: "South Dakota", + }, + { + value: "TN", + label: "Tennessee", + }, + { + value: "TX", + label: "Texas", + }, + { + value: "UT", + label: "Utah", + }, + { + value: "VA", + label: "Virginia", + }, + { + value: "VT", + label: "Vermont", + }, + { + value: "WA", + label: "Washington", + }, + { + value: "WI", + label: "Wisconsin", + }, + { + value: "WV", + label: "West Virginia", + }, + { + value: "WY", + label: "Wyoming", + }, + { + value: "AA", + label: "US Armed Forces - Americas", + }, + { + value: "AE", + label: "US Armed Forces - Europe", + }, + { + value: "AP", + label: "US Armed Forces - Pacific", + }, + { + value: "East Midlands", + label: "East Midlands", + }, + { + value: "East of England", + label: "East of England", + }, + { + value: "Greater London", + label: "Greater London", + }, + { + value: "North East", + label: "North East", + }, + { + value: "North West", + label: "North West", + }, + { + value: "Northern Ireland", + label: "Northern Ireland", + }, + { + value: "Scotland", + label: "Scotland", + }, + { + value: "South East", + label: "South East", + }, + { + value: "South West", + label: "South West", + }, + { + value: "Wales", + label: "Wales", + }, + { + value: "West Midlands", + label: "West Midlands", + }, + { + value: "Yorkshire and the Humber", + label: "Yorkshire and the Humber", + }, + { + value: "ACT", + label: "Australian Capital Territory", + }, + { + value: "NSW", + label: "New South Wales", + }, + { + value: "NT", + label: "Northern Territory", + }, + { + value: "QLD", + label: "Queensland", + }, + { + value: "SA", + label: "South Australia", + }, + { + value: "TAS", + label: "Tasmania", + }, + { + value: "VIC", + label: "Victoria", + }, + { + value: "WA", + label: "Western Australia", + }, + { + value: "ON", + label: "Ontario", + }, + { + value: "QC", + label: "Québec", + }, + { + value: "BC", + label: "British Columbia", + }, + { + value: "AB", + label: "Alberta", + }, + { + value: "MB", + label: "Manitoba", + }, + { + value: "SK", + label: "Saskatchewan", + }, + { + value: "NS", + label: "Nova Scotia", + }, + { + value: "NB", + label: "New Brunswick", + }, + { + value: "NL", + label: "Newfoundland and Labrador", + }, + { + value: "PE", + label: "Prince Edward Island", + }, + { + value: "YT", + label: "Yukon", + }, + { + value: "NT", + label: "Northwest Territories", + }, + { + value: "NU", + label: "Nunavut", + }, + { + value: "Anhui", + label: "Anhui", + }, + { + value: "Beijing", + label: "Beijing", + }, + { + value: "Chongqing", + label: "Chongqing", + }, + { + value: "Fujian", + label: "Fujian", + }, + { + value: "Gansu", + label: "Gansu", + }, + { + value: "Guangdong", + label: "Guangdong", + }, + { + value: "Guangxi Zhuang", + label: "Guangxi Zhuang", + }, + { + value: "Guizhou", + label: "Guizhou", + }, + { + value: "Hainan", + label: "Hainan", + }, + { + value: "Hebei", + label: "Hebei", + }, + { + value: "Heilongjiang", + label: "Heilongjiang", + }, + { + value: "Henan", + label: "Henan", + }, + { + value: "Hubei", + label: "Hubei", + }, + { + value: "Hunan", + label: "Hunan", + }, + { + value: "Jiangsu", + label: "Jiangsu", + }, + { + value: "Jiangxi", + label: "Jiangxi", + }, + { + value: "Jilin", + label: "Jilin", + }, + { + value: "Liaoning", + label: "Liaoning", + }, + { + value: "Nei Mongol", + label: "Nei Mongol", + }, + { + value: "Ningxia Hui", + label: "Ningxia Hui", + }, + { + value: "Qinghai", + label: "Qinghai", + }, + { + value: "Shaanxi", + label: "Shaanxi", + }, + { + value: "Shandong", + label: "Shandong", + }, + { + value: "Shanghai", + label: "Shanghai", + }, + { + value: "Shanxi", + label: "Shanxi", + }, + { + value: "Sichuan", + label: "Sichuan", + }, + { + value: "Tianjin", + label: "Tianjin", + }, + { + value: "Xinjiang Uygur", + label: "Xinjiang Uygur", + }, + { + value: "Xizang", + label: "Xizang", + }, + { + value: "Yunnan", + label: "Yunnan", + }, + { + value: "Zhejiang", + label: "Zhejiang", + }, + { + value: "Andaman and Nicobar Islands", + label: "Andaman and Nicobar Islands", + }, + { + value: "Andhra Pradesh", + label: "Andhra Pradesh", + }, + { + value: "Arunachal Pradesh", + label: "Arunachal Pradesh", + }, + { + value: "Assam", + label: "Assam", + }, + { + value: "Bihar", + label: "Bihar", + }, + { + value: "Chandigarh", + label: "Chandigarh", + }, + { + value: "Chhattisgarh", + label: "Chhattisgarh", + }, + { + value: "Delhi", + label: "Delhi", + }, + { + value: "Dadra and Nagar Haveli and Daman and Diu", + label: "Dadra and Nagar Haveli and Daman and Diu", + }, + { + value: "Goa", + label: "Goa", + }, + { + value: "Gujarat", + label: "Gujarat", + }, + { + value: "Himachal Pradesh", + label: "Himachal Pradesh", + }, + { + value: "Haryana", + label: "Haryana", + }, + { + value: "Jharkhand", + label: "Jharkhand", + }, + { + value: "Jammu and Kashmir", + label: "Jammu and Kashmir", + }, + { + value: "Karnataka", + label: "Karnataka", + }, + { + value: "Kerala", + label: "Kerala", + }, + { + value: "Lakshadweep", + label: "Lakshadweep", + }, + { + value: "Maharashtra", + label: "Maharashtra", + }, + { + value: "Meghalaya", + label: "Meghalaya", + }, + { + value: "Manipur", + label: "Manipur", + }, + { + value: "Madhya Pradesh", + label: "Madhya Pradesh", + }, + { + value: "Mizoram", + label: "Mizoram", + }, + { + value: "Nagaland", + label: "Nagaland", + }, + { + value: "Odisha", + label: "Odisha", + }, + { + value: "Punjab", + label: "Punjab", + }, + { + value: "Puducherry", + label: "Puducherry", + }, + { + value: "Rajasthan", + label: "Rajasthan", + }, + { + value: "Sikkim", + label: "Sikkim", + }, + { + value: "Tamil Nadu", + label: "Tamil Nadu", + }, + { + value: "Telangana", + label: "Telangana", + }, + { + value: "Tripura", + label: "Tripura", + }, + { + value: "Uttarakhand", + label: "Uttarakhand", + }, + { + value: "Uttar Pradesh", + label: "Uttar Pradesh", + }, + { + value: "West Bengal", + label: "West Bengal", + }, + { + value: "Ladakh", + label: "Ladakh", + }, + { + value: "Co. Carlow", + label: "Co. Carlow", + }, + { + value: "Co. Cavan", + label: "Co. Cavan", + }, + { + value: "Co. Clare", + label: "Co. Clare", + }, + { + value: "Co. Cork", + label: "Co. Cork", + }, + { + value: "Co. Donegal", + label: "Co. Donegal", + }, + { + value: "Co. Dublin", + label: "Co. Dublin", + }, + { + value: "Co. Galway", + label: "Co. Galway", + }, + { + value: "Co. Kerry", + label: "Co. Kerry", + }, + { + value: "Co. Kildare", + label: "Co. Kildare", + }, + { + value: "Co. Kilkenny", + label: "Co. Kilkenny", + }, + { + value: "Co. Laois", + label: "Co. Laois", + }, + { + value: "Co. Leitrim", + label: "Co. Leitrim", + }, + { + value: "Co. Limerick", + label: "Co. Limerick", + }, + { + value: "Co. Longford", + label: "Co. Longford", + }, + { + value: "Co. Louth", + label: "Co. Louth", + }, + { + value: "Co. Mayo", + label: "Co. Mayo", + }, + { + value: "Co. Meath", + label: "Co. Meath", + }, + { + value: "Co. Monaghan", + label: "Co. Monaghan", + }, + { + value: "Co. Offaly", + label: "Co. Offaly", + }, + { + value: "Co. Roscommon", + label: "Co. Roscommon", + }, + { + value: "Co. Sligo", + label: "Co. Sligo", + }, + { + value: "Co. Tipperary", + label: "Co. Tipperary", + }, + { + value: "Co. Waterford", + label: "Co. Waterford", + }, + { + value: "Co. Westmeath", + label: "Co. Westmeath", + }, + { + value: "Co. Wexford", + label: "Co. Wexford", + }, + { + value: "Co. Wicklow", + label: "Co. Wicklow", + }, + { + value: "AG", + label: "Agrigento", + }, + { + value: "AL", + label: "Alessandria", + }, + { + value: "AN", + label: "Ancona", + }, + { + value: "AO", + label: "Aosta", + }, + { + value: "AP", + label: "Ascoli Piceno", + }, + { + value: "AT", + label: "Asti", + }, + { + value: "AV", + label: "Avellino", + }, + { + value: "BA", + label: "Bari", + }, + { + value: "BT", + label: "Barletta-Andria-Trani", + }, + { + value: "BL", + label: "Belluno", + }, + { + value: "BN", + label: "Benevento", + }, + { + value: "BG", + label: "Bergamo", + }, + { + value: "BI", + label: "Biella", + }, + { + value: "BO", + label: "Bologna", + }, + { + value: "BZ", + label: "Bolzano", + }, + { + value: "BS", + label: "Brescia", + }, + { + value: "BR", + label: "Brindisi", + }, + { + value: "CA", + label: "Cagliari", + }, + { + value: "CT", + label: "Catania", + }, + { + value: "CZ", + label: "Catanzaro", + }, + { + value: "CH", + label: "Chieti", + }, + { + value: "CO", + label: "Como", + }, + { + value: "CS", + label: "Cosenza", + }, + { + value: "CR", + label: "Cremona", + }, + { + value: "KR", + label: "Crotone", + }, + { + value: "CN", + label: "Cuneo", + }, + { + value: "EN", + label: "Enna", + }, + { + value: "FM", + label: "Fermo", + }, + { + value: "FE", + label: "Ferrara", + }, + { + value: "FI", + label: "Firenze", + }, + { + value: "FG", + label: "Foggia", + }, + { + value: "FC", + label: "Forlì-Cesena", + }, + { + value: "FR", + label: "Frosinone", + }, + { + value: "GE", + label: "Genova", + }, + { + value: "GR", + label: "Grosseto", + }, + { + value: "IM", + label: "Imperia", + }, + { + value: "IS", + label: "Isernia", + }, + { + value: "AQ", + label: "L'Aquila", + }, + { + value: "SP", + label: "La Spezia", + }, + { + value: "LT", + label: "Latina", + }, + { + value: "LE", + label: "Lecce", + }, + { + value: "LC", + label: "Lecco", + }, + { + value: "LI", + label: "Livorno", + }, + { + value: "LO", + label: "Lodi", + }, + { + value: "LU", + label: "Lucca", + }, + { + value: "MC", + label: "Macerata", + }, + { + value: "MN", + label: "Mantova", + }, + { + value: "MS", + label: "Massa-Carrara", + }, + { + value: "MT", + label: "Matera", + }, + { + value: "ME", + label: "Messina", + }, + { + value: "MI", + label: "Milano", + }, + { + value: "MO", + label: "Modena", + }, + { + value: "MB", + label: "Monza e Brianza", + }, + { + value: "NA", + label: "Napoli", + }, + { + value: "NO", + label: "Novara", + }, + { + value: "NU", + label: "Nuoro", + }, + { + value: "OR", + label: "Oristano", + }, + { + value: "PD", + label: "Padova", + }, + { + value: "PA", + label: "Palermo", + }, + { + value: "PR", + label: "Parma", + }, + { + value: "PV", + label: "Pavia", + }, + { + value: "PG", + label: "Perugia", + }, + { + value: "PU", + label: "Pesaro e Urbino", + }, + { + value: "PE", + label: "Pescara", + }, + { + value: "PC", + label: "Piacenza", + }, + { + value: "PI", + label: "Pisa", + }, + { + value: "PT", + label: "Pistoia", + }, + { + value: "PZ", + label: "Potenza", + }, + { + value: "PO", + label: "Prato", + }, + { + value: "RG", + label: "Ragusa", + }, + { + value: "RA", + label: "Ravenna", + }, + { + value: "RC", + label: "Reggio Calabria", + }, + { + value: "RE", + label: "Reggio Emilia", + }, + { + value: "RI", + label: "Rieti", + }, + { + value: "RN", + label: "Rimini", + }, + { + value: "RM", + label: "Roma", + }, + { + value: "RO", + label: "Rovigo", + }, + { + value: "SA", + label: "Salerno", + }, + { + value: "SS", + label: "Sassari", + }, + { + value: "SV", + label: "Savona", + }, + { + value: "SI", + label: "Siena", + }, + { + value: "SR", + label: "Siracusa", + }, + { + value: "SO", + label: "Sondrio", + }, + { + value: "SD", + label: "Sud Sardegna", + }, + { + value: "TA", + label: "Taranto", + }, + { + value: "TE", + label: "Teramo", + }, + { + value: "TR", + label: "Terni", + }, + { + value: "TO", + label: "Torino", + }, + { + value: "TP", + label: "Trapani", + }, + { + value: "TN", + label: "Trento", + }, + { + value: "TV", + label: "Treviso", + }, + { + value: "VA", + label: "Varese", + }, + { + value: "VE", + label: "Venezia", + }, + { + value: "VB", + label: "Verbano-Cusio-Ossola", + }, + { + value: "VC", + label: "Vercelli", + }, + { + value: "VR", + label: "Verona", + }, + { + value: "VV", + label: "Vibo Valentia", + }, + { + value: "VI", + label: "Vicenza", + }, + { + value: "VT", + label: "Viterbo", + }, + { + value: "GO", + label: "Gorizia", + }, + { + value: "PN", + label: "Pordenone", + }, + { + value: "TS", + label: "Trieste", + }, + { + value: "UD", + label: "Udine", + }, + { + value: "Auckland", + label: "Auckland", + }, + { + value: "Bay of Plenty", + label: "Bay of Plenty", + }, + { + value: "Canterbury", + label: "Canterbury", + }, + { + value: "Gisborne", + label: "Gisborne", + }, + { + value: "Hawke's Bay", + label: "Hawke's Bay", + }, + { + value: "Manawatu-Wanganui", + label: "Manawatu-Wanganui", + }, + { + value: "Marlborough", + label: "Marlborough", + }, + { + value: "Nelson", + label: "Nelson", + }, + { + value: "Northland", + label: "Northland", + }, + { + value: "Otago", + label: "Otago", + }, + { + value: "Southland", + label: "Southland", + }, + { + value: "Taranaki", + label: "Taranaki", + }, + { + value: "Tasman", + label: "Tasman", + }, + { + value: "Waikato", + label: "Waikato", + }, + { + value: "Wellington", + label: "Wellington", + }, + { + value: "West Coast", + label: "West Coast", + }, + { + value: "Chatham Islands Territory", + label: "Chatham Islands Territory", + }, + { + value: "Eastern Cape", + label: "Eastern Cape", + }, + { + value: "Free State", + label: "Free State", + }, + { + value: "Gauteng", + label: "Gauteng", + }, + { + value: "KwaZulu-Natal", + label: "KwaZulu-Natal", + }, + { + value: "Limpopo", + label: "Limpopo", + }, + { + value: "Mpumalanga", + label: "Mpumalanga", + }, + { + value: "Northern Cape", + label: "Northern Cape", + }, + { + value: "Western Cape", + label: "Western Cape", + }, + { + value: "AC", + label: "Acre", + }, + { + value: "AL", + label: "Alagoas", + }, + { + value: "AP", + label: "Amapá", + }, + { + value: "AM", + label: "Amazonas", + }, + { + value: "BA", + label: "Bahia", + }, + { + value: "CE", + label: "Ceará", + }, + { + value: "DF", + label: "Distrito Federal", + }, + { + value: "ES", + label: "Espírito Santo", + }, + { + value: "GO", + label: "Goiás", + }, + { + value: "MA", + label: "Maranhão", + }, + { + value: "MT", + label: "Mato Grosso", + }, + { + value: "MS", + label: "Mato Grosso do Sul", + }, + { + value: "MG", + label: "Minas Gerais", + }, + { + value: "PR", + label: "Paraná", + }, + { + value: "PB", + label: "Paraíba", + }, + { + value: "PA", + label: "Pará", + }, + { + value: "PE", + label: "Pernambuco", + }, + { + value: "PI", + label: "Piauí", + }, + { + value: "RN", + label: "Rio Grande do Norte", + }, + { + value: "RS", + label: "Rio Grande do Sul", + }, + { + value: "RJ", + label: "Rio de Janeiro", + }, + { + value: "RO", + label: "Rondônia", + }, + { + value: "RR", + label: "Roraima", + }, + { + value: "SC", + label: "Santa Catarina", + }, + { + value: "SE", + label: "Sergipe", + }, + { + value: "SP", + label: "São Paulo", + }, + { + value: "TO", + label: "Tocantins", + }, + { + value: "AGU", + label: "Aguascalientes", + }, + { + value: "BCN", + label: "Baja California", + }, + { + value: "BCS", + label: "Baja California Sur", + }, + { + value: "CAM", + label: "Campeche", + }, + { + value: "CHP", + label: "Chiapas", + }, + { + value: "CHH", + label: "Chihuahua", + }, + { + value: "CMX", + label: "Ciudad de México", + }, + { + value: "COA", + label: "Coahuila", + }, + { + value: "COL", + label: "Colima", + }, + { + value: "DUR", + label: "Durango", + }, + { + value: "GUA", + label: "Guanajuato", + }, + { + value: "GRO", + label: "Guerrero", + }, + { + value: "HID", + label: "Hidalgo", + }, + { + value: "JAL", + label: "Jalisco", + }, + { + value: "MIC", + label: "Michoacán", + }, + { + value: "MOR", + label: "Morelos", + }, + { + value: "MEX", + label: "State of Mexico", + }, + { + value: "NAY", + label: "Nayarit", + }, + { + value: "NLE", + label: "Nuevo León", + }, + { + value: "OAX", + label: "Oaxaca", + }, + { + value: "PUE", + label: "Puebla", + }, + { + value: "QUE", + label: "Querétaro", + }, + { + value: "ROO", + label: "Quintana Roo", + }, + { + value: "SLP", + label: "San Luis Potosí", + }, + { + value: "SIN", + label: "Sinaloa", + }, + { + value: "SON", + label: "Sonora", + }, + { + value: "TAB", + label: "Tabasco", + }, + { + value: "TAM", + label: "Tamaulipas", + }, + { + value: "TLA", + label: "Tlaxcala", + }, + { + value: "VER", + label: "Veracruz", + }, + { + value: "YUC", + label: "Yucatán", + }, + { + value: "ZAC", + label: "Zacatecas", + }, + { + value: "Aargau", + label: "Aargau", + }, + { + value: "Appenzell Ausserrhoden", + label: "Appenzell Ausserrhoden", + }, + { + value: "Appenzell Innerrhoden", + label: "Appenzell Innerrhoden", + }, + { + value: "Basel-Landschaft", + label: "Basel-Landschaft", + }, + { + value: "Basel-Stadt", + label: "Basel-Stadt", + }, + { + value: "Bern", + label: "Bern", + }, + { + value: "Freiburg", + label: "Freiburg", + }, + { + value: "Genève", + label: "Genève", + }, + { + value: "Glarus", + label: "Glarus", + }, + { + value: "Graubünden", + label: "Graubünden", + }, + { + value: "Jura", + label: "Jura", + }, + { + value: "Luzern", + label: "Luzern", + }, + { + value: "Neuchâtel", + label: "Neuchâtel", + }, + { + value: "Nidwalden", + label: "Nidwalden", + }, + { + value: "Obwalden", + label: "Obwalden", + }, + { + value: "Sankt Gallen", + label: "Sankt Gallen", + }, + { + value: "Schaffhausen", + label: "Schaffhausen", + }, + { + value: "Schwyz", + label: "Schwyz", + }, + { + value: "Solothurn", + label: "Solothurn", + }, + { + value: "Thurgau", + label: "Thurgau", + }, + { + value: "Ticino", + label: "Ticino", + }, + { + value: "Uri", + label: "Uri", + }, + { + value: "Valais", + label: "Valais", + }, + { + value: "Vaud", + label: "Vaud", + }, + { + value: "Zug", + label: "Zug", + }, + { + value: "Zürich", + label: "Zürich", + }, + { + value: "Drenthe", + label: "Drenthe", + }, + { + value: "Flevoland", + label: "Flevoland", + }, + { + value: "Fryslân", + label: "Fryslân", + }, + { + value: "Gelderland", + label: "Gelderland", + }, + { + value: "Groningen", + label: "Groningen", + }, + { + value: "Limburg", + label: "Limburg", + }, + { + value: "North Brabant", + label: "North Brabant", + }, + { + value: "North Holland", + label: "North Holland", + }, + { + value: "Overijssel", + label: "Overijssel", + }, + { + value: "Utrecht", + label: "Utrecht", + }, + { + value: "Zeeland", + label: "Zeeland", + }, + { + value: "South Holland", + label: "South Holland", + }, +]; diff --git a/components/demandbase/common/utils.mjs b/components/demandbase/common/utils.mjs new file mode 100644 index 0000000000000..1c490499c39e1 --- /dev/null +++ b/components/demandbase/common/utils.mjs @@ -0,0 +1,26 @@ +import { URLSearchParams } from "url"; + +function arrayToCommaSeparatedList(array) { + return array?.join(","); +} + +function getUrlEncodedData(data) { + const params = new URLSearchParams(); + Object.entries(data) + .forEach(([ + key, + value, + ]) => { + if (Array.isArray(value) && value.length) { + params.append(key, arrayToCommaSeparatedList(value)); + } else if (value) { + params.append(key, value); + } + }); + return params.toString(); +} + +export default { + arrayToCommaSeparatedList, + getUrlEncodedData, +}; diff --git a/components/demandbase/demandbase.app.mjs b/components/demandbase/demandbase.app.mjs index de53a87b7d83f..f867af1a7ab2d 100644 --- a/components/demandbase/demandbase.app.mjs +++ b/components/demandbase/demandbase.app.mjs @@ -1,11 +1,159 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "demandbase", - propDefinitions: {}, + propDefinitions: { + industries: { + type: "string[]", + label: "Industries", + description: "List of industry IDs.", + optional: true, + async options({ + listSubindustries = false, + industryIds, + }) { + const { industries } = await this.listIndustries(); + + if (industryIds && listSubindustries) { + return industryIds.flatMap((industryId) => { + const industry = + industries.find(({ industry: { industryId: id } }) => id === industryId); + return industry?.subIndustries + ?.map(({ + industryId: value, + industryName: label, + }) => ({ + label, + value, + })) || []; + }); + } + + return industries.map(({ + industry: { + industryId: value, + industryName: label, + }, + }) => ({ + label, + value, + })); + }, + }, + countryId: { + type: "string", + label: "Country ID", + description: "The country ID.", + optional: true, + async options({ + mapper = ({ + countryId: value, + countryName: label, + }) => ({ + label, + value, + }), + }) { + const { countries } = await this.listCountries(); + return countries.map(mapper); + }, + }, + categoryIds: { + type: "string[]", + label: "Category IDs", + description: "List of category IDs.", + optional: true, + async options() { + const { categories } = await this.listTechnologies(); + return categories.map(({ + categoryId: value, categoryName: label, + }) => ({ + label, + value, + })); + }, + }, + companyId: { + type: "string", + label: "Company ID", + description: "The company ID.", + optional: true, + async options({ page }) { + const { companies } = await this.listCompanies({ + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + params: { + page: page + 1, + resultsPerPage: 100, + }, + }); + return companies.map(({ + companyId: value, + name: label, + }) => ({ + label, + value, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://api.insideview.com/api/v1${path}`; + }, + getHeaders(headers) { + return { + accessToken: this.$auth.oauth_access_token, + Accept: "application/json", + ...headers, + }; + }, + _makeRequest({ + $ = this, path, headers, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + headers: this.getHeaders(headers), + }); + }, + post(args = {}) { + return this._makeRequest({ + method: "POST", + ...args, + }); + }, + delete(args = {}) { + return this._makeRequest({ + method: "DELETE", + ...args, + }); + }, + listIndustries(args = {}) { + return this._makeRequest({ + path: "/reference/industries", + ...args, + }); + }, + listCountries(args = {}) { + return this._makeRequest({ + path: "/reference/countries", + ...args, + }); + }, + listTechnologies(args = {}) { + return this._makeRequest({ + path: "/reference/techProfile", + ...args, + }); + }, + listCompanies(args = {}) { + return this.post({ + path: "/target/companies", + ...args, + }); }, }, }; diff --git a/components/demandbase/package.json b/components/demandbase/package.json index 95799f7a78eb6..b96929195c983 100644 --- a/components/demandbase/package.json +++ b/components/demandbase/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/demandbase", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Demandbase Components", "main": "demandbase.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/demandbase/sources/common/webhook.mjs b/components/demandbase/sources/common/webhook.mjs new file mode 100644 index 0000000000000..fc3afb1614417 --- /dev/null +++ b/components/demandbase/sources/common/webhook.mjs @@ -0,0 +1,120 @@ +import { createHmac } from "crypto"; +import { v4 as uuidv4 } from "uuid"; +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../demandbase.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + props: { + app, + db: "$.service.db", + http: { + type: "$.interface.http", + customResponse: true, + }, + }, + hooks: { + async activate() { + const { + createSubscription, + getData, + http: { endpoint: webhook }, + setSubscriptionId, + setSecret, + } = this; + + const signingSecret = uuidv4(); + + const response = + await createSubscription({ + data: { + webhook, + signingSecret, + ...getData(), + }, + }); + + setSubscriptionId(response.subscriptionId); + setSecret(signingSecret); + }, + async deactivate() { + const { + deleteSubscription, + getSubscriptionId, + } = this; + + const subscriptionId = getSubscriptionId(); + if (subscriptionId) { + await deleteSubscription({ + subscriptionId, + }); + } + }, + }, + methods: { + getData() { + throw new ConfigurationError("getData is not implemented"); + }, + generateMeta() { + throw new ConfigurationError("generateMeta is not implemented"); + }, + setSubscriptionId(value) { + this.db.set(constants.SUBSCRIPTION_ID, value); + }, + getSubscriptionId() { + return this.db.get(constants.SUBSCRIPTION_ID); + }, + setSecret(value) { + this.db.set(constants.SECRET, value); + }, + getSecret() { + return this.db.get(constants.SECRET); + }, + getSubscriptionType() { + throw new ConfigurationError("getSubscriptionType is not implemented"); + }, + processResource(resource) { + this.$emit(resource, this.generateMeta(resource)); + }, + createSubscription(args = {}) { + return this.app.post({ + path: "/subscription", + ...args, + }); + }, + deleteSubscription({ + subscriptionId, ...args + } = {}) { + return this.app.delete({ + path: `/subscription/${subscriptionId}`, + ...args, + }); + }, + validateSignature(headers, rawBody) { + const signature = headers["X-InsideViewAPI-AlertDataSignature"]; + const signingSecret = this.getSecret(); + const computedSignature = + createHmac("sha1", signingSecret) + .update(rawBody) + .digest("hex"); + + if (signature !== computedSignature) { + throw new Error("Invalid signature"); + } + }, + }, + async run({ + method, body, headers, rawBody, + }) { + if (method === "HEAD") { + return this.http.respond({ + status: 200, + headers: { + "X-InsideViewAPI-ValidationCode": headers["X-InsideViewAPI-ValidationCode"], + }, + }); + } + this.validateSignature(headers, rawBody); + this.processResource(body); + }, +}; diff --git a/components/demandbase/sources/new-company-change-instant/new-company-change-instant.mjs b/components/demandbase/sources/new-company-change-instant/new-company-change-instant.mjs new file mode 100644 index 0000000000000..c4d2b167a00b7 --- /dev/null +++ b/components/demandbase/sources/new-company-change-instant/new-company-change-instant.mjs @@ -0,0 +1,44 @@ +import common from "../common/webhook.mjs"; +import constants from "../../common/constants.mjs"; +import utils from "../../common/utils.mjs"; + +export default { + ...common, + key: "demandbase-new-company-change-instant", + name: "New Company Change (Instant)", + description: "Emit new event when a company changes. [See the documentation](https://kb.demandbase.com/hc/en-us/articles/7273680247707--POST-Create-Subscription).", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + ...common.props, + companyIds: { + type: "string[]", + label: "Company IDs", + description: "List of company IDs.", + optional: false, + propDefinition: [ + common.props.app, + "companyId", + ], + }, + }, + methods: { + ...common.methods, + getData() { + return { + subscriptionType: constants.SUBSCRIPTION_TYPE.COMPANY, + frecuency: "1day", + name: "New Company Change", + companyIds: utils.arrayToCommaSeparatedList(this.companyIds), + }; + }, + generateMeta(resource) { + return { + id: resource.alertId, + summary: `New Company Change: ${resource.alertId}`, + ts: Date.parse(resource.date), + }; + }, + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 227bc6cf3053f..0ae1892cef648 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -313,8 +313,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/adobe_photoshop_lightroom: - specifiers: {} + components/adobe_photoshop_lightroom: {} components/adobe_sign: {} @@ -2663,7 +2662,11 @@ importers: specifier: ^2.1.0 version: 2.1.0 - components/demandbase: {} + components/demandbase: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/demio: dependencies: @@ -7549,8 +7552,7 @@ importers: specifier: ^0.9.0 version: 0.9.0 - components/opnform: - specifiers: {} + components/opnform: {} components/opsgenie: dependencies: @@ -32337,8 +32339,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: