@xuda.io/ai_module 1.1.4725 → 1.1.4727
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +582 -581
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5591,7 +5591,8 @@ setTimeout(async () => {
|
|
|
5591
5591
|
// account_profile_info,
|
|
5592
5592
|
// );
|
|
5593
5593
|
|
|
5594
|
-
ret = await get_business_info(uid, '', 'moti411@gmail.com', account_profile_info);
|
|
5594
|
+
// ret = await get_business_info(uid, '', 'moti411@gmail.com', account_profile_info);
|
|
5595
|
+
ret = await get_business_info(uid, '', 'eden.ioshka@gmail.com', account_profile_info);
|
|
5595
5596
|
// ret = await get_person_info(uid, 'lidan ben shlush', 'dan@locksmith-star.com', account_profile_info);
|
|
5596
5597
|
// debugger;
|
|
5597
5598
|
console.log(ret);
|
|
@@ -7160,143 +7161,143 @@ const get_image_blob_from_downloaded_image = async function (url) {
|
|
|
7160
7161
|
return images[0];
|
|
7161
7162
|
};
|
|
7162
7163
|
|
|
7163
|
-
export const get_business_info = async function (uid, name, email, account_profile_info) {
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7164
|
+
// export const get_business_info = async function (uid, name, email, account_profile_info) {
|
|
7165
|
+
// // Extract lists from your JSON categories array
|
|
7166
|
+
// const categories = [
|
|
7167
|
+
// {
|
|
7168
|
+
// id: 'ind_technology',
|
|
7169
|
+
// name: 'Technology',
|
|
7170
|
+
// sub: ['Software Development', 'AI & Machine Learning', 'Cybersecurity', 'Cloud Computing', 'IT Services', 'SaaS & Platforms', 'Hardware & Electronics'],
|
|
7171
|
+
// },
|
|
7172
|
+
// {
|
|
7173
|
+
// id: 'ind_marketing',
|
|
7174
|
+
// name: 'Marketing & Advertising',
|
|
7175
|
+
// sub: ['Digital Marketing', 'PPC & SEO', 'Content Creation', 'Branding', 'Social Media Management', 'Email Marketing', 'Market Research'],
|
|
7176
|
+
// },
|
|
7177
|
+
// {
|
|
7178
|
+
// id: 'ind_sales',
|
|
7179
|
+
// name: 'Sales',
|
|
7180
|
+
// sub: ['B2B Sales', 'B2C Sales', 'Real Estate Sales', 'Account Management', 'Lead Generation', 'Inside Sales', 'Field Sales'],
|
|
7181
|
+
// },
|
|
7182
|
+
// {
|
|
7183
|
+
// id: 'ind_finance',
|
|
7184
|
+
// name: 'Finance & Accounting',
|
|
7185
|
+
// sub: ['Banking', 'Investment', 'Financial Planning', 'Accounting', 'Bookkeeping', 'Insurance', 'FinTech'],
|
|
7186
|
+
// },
|
|
7187
|
+
// {
|
|
7188
|
+
// id: 'ind_healthcare',
|
|
7189
|
+
// name: 'Healthcare',
|
|
7190
|
+
// sub: ['Medical Clinics', 'Hospitals', 'Pharma', 'Mental Health', 'Healthcare IT', 'Home Care', 'Medical Research'],
|
|
7191
|
+
// },
|
|
7192
|
+
// {
|
|
7193
|
+
// id: 'ind_realestate',
|
|
7194
|
+
// name: 'Real Estate',
|
|
7195
|
+
// sub: ['Residential Real Estate', 'Commercial Real Estate', 'Property Management', 'Investment & BRRRR', 'Construction', 'Architecture', 'Interior Design'],
|
|
7196
|
+
// },
|
|
7197
|
+
// {
|
|
7198
|
+
// id: 'ind_ecommerce',
|
|
7199
|
+
// name: 'E-commerce',
|
|
7200
|
+
// sub: ['Online Store', 'Dropshipping', 'Amazon FBA', 'Marketplace Selling', 'Retail', 'Inventory Management', 'Fulfillment & Logistics'],
|
|
7201
|
+
// },
|
|
7202
|
+
// {
|
|
7203
|
+
// id: 'ind_education',
|
|
7204
|
+
// name: 'Education',
|
|
7205
|
+
// sub: ['Schools', 'Universities', 'Private Tutoring', 'Online Courses', 'EdTech', 'Training & Development'],
|
|
7206
|
+
// },
|
|
7207
|
+
// {
|
|
7208
|
+
// id: 'ind_hospitality',
|
|
7209
|
+
// name: 'Hospitality & Travel',
|
|
7210
|
+
// sub: ['Hotels', 'Restaurants', 'Cafes & Bars', 'Travel Agencies', 'Tourism', 'Events & Catering', 'Transportation'],
|
|
7211
|
+
// },
|
|
7212
|
+
// {
|
|
7213
|
+
// id: 'ind_professional',
|
|
7214
|
+
// name: 'Professional Services',
|
|
7215
|
+
// sub: ['Legal', 'Consulting', 'HR & Recruiting', 'Accounting Firms', 'Business Services', 'Management Consulting'],
|
|
7216
|
+
// },
|
|
7217
|
+
// {
|
|
7218
|
+
// id: 'ind_manufacturing',
|
|
7219
|
+
// name: 'Manufacturing',
|
|
7220
|
+
// sub: ['Automotive', 'Industrial', 'Textile', 'Electronics', 'Food Production', 'Machinery', 'Chemicals'],
|
|
7221
|
+
// },
|
|
7222
|
+
// {
|
|
7223
|
+
// id: 'ind_nonprofit',
|
|
7224
|
+
// name: 'Nonprofit & Government',
|
|
7225
|
+
// sub: ['NGOs', 'Municipality', 'Government Services', 'Public Health', 'Community Organizations', 'Education Programs'],
|
|
7226
|
+
// },
|
|
7227
|
+
// {
|
|
7228
|
+
// id: 'ind_media',
|
|
7229
|
+
// name: 'Media & Entertainment',
|
|
7230
|
+
// sub: ['Film & Video', 'Music', 'Publishing', 'Gaming', 'News & Journalism', 'Influencers', 'Production Studios'],
|
|
7231
|
+
// },
|
|
7232
|
+
// {
|
|
7233
|
+
// id: 'ind_logistics',
|
|
7234
|
+
// name: 'Logistics & Transportation',
|
|
7235
|
+
// sub: ['Shipping', 'Trucking', 'Last-Mile Delivery', 'Warehousing', 'Freight Forwarding', 'Route Optimization'],
|
|
7236
|
+
// },
|
|
7237
|
+
// {
|
|
7238
|
+
// id: 'ind_energy',
|
|
7239
|
+
// name: 'Energy & Utilities',
|
|
7240
|
+
// sub: ['Solar', 'Oil & Gas', 'Electricity Providers', 'Water Utilities', 'Environmental Services', 'Renewable Energy'],
|
|
7241
|
+
// },
|
|
7242
|
+
// {
|
|
7243
|
+
// id: 'ind_construction',
|
|
7244
|
+
// name: 'Construction & Trades',
|
|
7245
|
+
// sub: ['General Contracting', 'Roofing', 'Plumbing', 'HVAC', 'Electrical', 'Renovation', 'Engineering'],
|
|
7246
|
+
// },
|
|
7247
|
+
// {
|
|
7248
|
+
// id: 'ind_food',
|
|
7249
|
+
// name: 'Food & Beverage',
|
|
7250
|
+
// sub: ['Restaurants', 'Catering', 'Food Manufacturing', 'Bakeries', 'Bars & Nightlife', 'Food Delivery'],
|
|
7251
|
+
// },
|
|
7252
|
+
// {
|
|
7253
|
+
// id: 'ind_retail',
|
|
7254
|
+
// name: 'Retail',
|
|
7255
|
+
// sub: ['Physical Stores', 'Boutiques', 'Supermarkets', 'Consumer Goods', 'Fashion Retail', 'Home Goods'],
|
|
7256
|
+
// },
|
|
7257
|
+
// ];
|
|
7258
|
+
// const categoryNames = categories.map((c) => c.name);
|
|
7259
|
+
// const allSubCategories = categories.flatMap((c) => c.sub);
|
|
7259
7260
|
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7261
|
+
// const business_info_ret = await submit_chat_gpt_prompt({
|
|
7262
|
+
// uid,
|
|
7263
|
+
// prompt: `Research the company: "${name}" (${email}).
|
|
7264
|
+
// 1. get the company name.
|
|
7265
|
+
// 2. get the domain name from the email.
|
|
7266
|
+
// 2. Provide a professional one-sentence biography of the company.
|
|
7267
|
+
// 3. Categorize them using the provided industry lists.
|
|
7268
|
+
// 4. Identify their primary country as a 2-letter ISO code (e.g., 'US').`,
|
|
7269
|
+
// model: 'gpt-5-nano',
|
|
7270
|
+
// response_format: z.object({
|
|
7271
|
+
// business_name: z.string().describe('the company name'),
|
|
7272
|
+
// business_domain: z.string().describe('the email domain name'),
|
|
7273
|
+
// business_bio: z.string().describe('A concise, professional one-sentence summary of what the business does'),
|
|
7274
|
+
// business_size: z.enum(['unknown', 'small', 'medium', 'large', 'enterprise']),
|
|
7275
|
+
// business_category: z.enum(categoryNames),
|
|
7276
|
+
// business_sub_category: z.enum(allSubCategories),
|
|
7277
|
+
// business_country: z.string().length(2).describe("2-letter ISO country code (e.g., 'US')"),
|
|
7278
|
+
// }),
|
|
7279
|
+
// metadata: { func: 'get_business_info' },
|
|
7280
|
+
// account_profile_info,
|
|
7281
|
+
// tools: [{ type: 'web_search_preview' }],
|
|
7282
|
+
// });
|
|
7282
7283
|
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7284
|
+
// try {
|
|
7285
|
+
// if (business_info_ret.code > -1) {
|
|
7286
|
+
// const data = typeof business_info_ret.data === 'string' ? JSON.parse(business_info_ret.data) : business_info_ret.data;
|
|
7286
7287
|
|
|
7287
|
-
|
|
7288
|
-
|
|
7288
|
+
// // Standardize country to uppercase
|
|
7289
|
+
// if (data.business_country) data.business_country = data.business_country.toUpperCase();
|
|
7289
7290
|
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7291
|
+
// // Logic to attach the ID for your database
|
|
7292
|
+
// const matched = categories.find((c) => c.name === data.business_category);
|
|
7293
|
+
// data.business_category_id = matched ? matched.id : null;
|
|
7293
7294
|
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
};
|
|
7295
|
+
// return data;
|
|
7296
|
+
// }
|
|
7297
|
+
// } catch (error) {
|
|
7298
|
+
// console.error('Error in get_business_info:', error);
|
|
7299
|
+
// }
|
|
7300
|
+
// };
|
|
7300
7301
|
|
|
7301
7302
|
const get_chat_picture_cache = async function (uid, docType, key) {
|
|
7302
7303
|
if (!key || typeof key !== 'string') return null;
|
|
@@ -8700,499 +8701,499 @@ Category:`;
|
|
|
8700
8701
|
}
|
|
8701
8702
|
};
|
|
8702
8703
|
|
|
8703
|
-
|
|
8704
|
-
//
|
|
8704
|
+
export const get_business_info = async function (uid, name, email, account_profile_info) {
|
|
8705
|
+
// ========== HELPER FUNCTIONS ==========
|
|
8705
8706
|
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8707
|
+
function validatePhoneNumber(phone) {
|
|
8708
|
+
if (!phone || phone.toLowerCase() === 'not available' || phone.trim() === '') {
|
|
8709
|
+
return 'Not available';
|
|
8710
|
+
}
|
|
8710
8711
|
|
|
8711
|
-
|
|
8712
|
-
|
|
8712
|
+
const cleaned = phone.replace(/[^\d\+\(\)\-\s]/g, '');
|
|
8713
|
+
const digitCount = (cleaned.match(/\d/g) || []).length;
|
|
8713
8714
|
|
|
8714
|
-
//
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8715
|
+
// Require at least 7 digits for a valid phone number
|
|
8716
|
+
if (digitCount < 7) {
|
|
8717
|
+
return 'Not available';
|
|
8718
|
+
}
|
|
8718
8719
|
|
|
8719
|
-
|
|
8720
|
-
|
|
8720
|
+
return cleaned.trim();
|
|
8721
|
+
}
|
|
8721
8722
|
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8723
|
+
function validateWebsite(website) {
|
|
8724
|
+
if (!website || website.toLowerCase() === 'not available' || website.trim() === '') {
|
|
8725
|
+
return 'Not available';
|
|
8726
|
+
}
|
|
8726
8727
|
|
|
8727
|
-
|
|
8728
|
+
const trimmed = website.trim();
|
|
8728
8729
|
|
|
8729
|
-
//
|
|
8730
|
-
|
|
8731
|
-
//
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8730
|
+
// Ensure URL has proper protocol
|
|
8731
|
+
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) {
|
|
8732
|
+
// Check if it looks like a domain
|
|
8733
|
+
if (trimmed.includes('.') && !trimmed.includes(' ')) {
|
|
8734
|
+
return `https://${trimmed.replace(/^www\./, '')}`;
|
|
8735
|
+
}
|
|
8736
|
+
return 'Not available';
|
|
8737
|
+
}
|
|
8737
8738
|
|
|
8738
|
-
|
|
8739
|
-
|
|
8739
|
+
return trimmed;
|
|
8740
|
+
}
|
|
8740
8741
|
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8742
|
+
function cleanStreetAddress(street) {
|
|
8743
|
+
if (!street || street.toLowerCase() === 'not available' || street.trim() === '') {
|
|
8744
|
+
return 'Not available';
|
|
8745
|
+
}
|
|
8745
8746
|
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8747
|
+
return street
|
|
8748
|
+
.replace(/\s+/g, ' ')
|
|
8749
|
+
.replace(/,\s*$/g, '') // Remove trailing commas
|
|
8750
|
+
.trim();
|
|
8751
|
+
}
|
|
8751
8752
|
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8753
|
+
function cleanText(text) {
|
|
8754
|
+
if (!text || text.toLowerCase() === 'not available' || text.trim() === '') {
|
|
8755
|
+
return 'Not available';
|
|
8756
|
+
}
|
|
8756
8757
|
|
|
8757
|
-
|
|
8758
|
-
|
|
8758
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
8759
|
+
}
|
|
8759
8760
|
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8761
|
+
function cleanZipCode(zip, country) {
|
|
8762
|
+
if (!zip || zip.toLowerCase() === 'not available' || zip.trim() === '') {
|
|
8763
|
+
return 'Not available';
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8766
|
+
const cleaned = zip.trim();
|
|
8767
|
+
|
|
8768
|
+
// Country-specific formatting
|
|
8769
|
+
switch (country) {
|
|
8770
|
+
case 'US':
|
|
8771
|
+
// US ZIP: 5 digits or 5-4 format
|
|
8772
|
+
return cleaned.replace(/\D/g, '').replace(/^(\d{5})(\d{4})$/, '$1-$2');
|
|
8773
|
+
case 'CA':
|
|
8774
|
+
// Canada: A1A 1A1 format
|
|
8775
|
+
return cleaned.toUpperCase().replace(/\s+/g, '');
|
|
8776
|
+
case 'UK':
|
|
8777
|
+
// UK: various formats, preserve as is but uppercase
|
|
8778
|
+
return cleaned.toUpperCase();
|
|
8779
|
+
case 'AU':
|
|
8780
|
+
// Australia: 4 digits
|
|
8781
|
+
return cleaned.replace(/\D/g, '');
|
|
8782
|
+
default:
|
|
8783
|
+
return cleaned;
|
|
8784
|
+
}
|
|
8785
|
+
}
|
|
8764
8786
|
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
//
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8787
|
+
function cleanStateProvince(state, country) {
|
|
8788
|
+
if (!state || state.toLowerCase() === 'not available' || state.trim() === '') {
|
|
8789
|
+
return 'Not available';
|
|
8790
|
+
}
|
|
8791
|
+
|
|
8792
|
+
const cleaned = state.trim();
|
|
8793
|
+
|
|
8794
|
+
// Standardize US state abbreviations
|
|
8795
|
+
if (country === 'US') {
|
|
8796
|
+
const stateMap = {
|
|
8797
|
+
alabama: 'AL',
|
|
8798
|
+
alaska: 'AK',
|
|
8799
|
+
arizona: 'AZ',
|
|
8800
|
+
arkansas: 'AR',
|
|
8801
|
+
california: 'CA',
|
|
8802
|
+
colorado: 'CO',
|
|
8803
|
+
connecticut: 'CT',
|
|
8804
|
+
delaware: 'DE',
|
|
8805
|
+
florida: 'FL',
|
|
8806
|
+
georgia: 'GA',
|
|
8807
|
+
hawaii: 'HI',
|
|
8808
|
+
idaho: 'ID',
|
|
8809
|
+
illinois: 'IL',
|
|
8810
|
+
indiana: 'IN',
|
|
8811
|
+
iowa: 'IA',
|
|
8812
|
+
kansas: 'KS',
|
|
8813
|
+
kentucky: 'KY',
|
|
8814
|
+
louisiana: 'LA',
|
|
8815
|
+
maine: 'ME',
|
|
8816
|
+
maryland: 'MD',
|
|
8817
|
+
massachusetts: 'MA',
|
|
8818
|
+
michigan: 'MI',
|
|
8819
|
+
minnesota: 'MN',
|
|
8820
|
+
mississippi: 'MS',
|
|
8821
|
+
missouri: 'MO',
|
|
8822
|
+
montana: 'MT',
|
|
8823
|
+
nebraska: 'NE',
|
|
8824
|
+
nevada: 'NV',
|
|
8825
|
+
'new hampshire': 'NH',
|
|
8826
|
+
'new jersey': 'NJ',
|
|
8827
|
+
'new mexico': 'NM',
|
|
8828
|
+
'new york': 'NY',
|
|
8829
|
+
'north carolina': 'NC',
|
|
8830
|
+
'north dakota': 'ND',
|
|
8831
|
+
ohio: 'OH',
|
|
8832
|
+
oklahoma: 'OK',
|
|
8833
|
+
oregon: 'OR',
|
|
8834
|
+
pennsylvania: 'PA',
|
|
8835
|
+
'rhode island': 'RI',
|
|
8836
|
+
'south carolina': 'SC',
|
|
8837
|
+
'south dakota': 'SD',
|
|
8838
|
+
tennessee: 'TN',
|
|
8839
|
+
texas: 'TX',
|
|
8840
|
+
utah: 'UT',
|
|
8841
|
+
vermont: 'VT',
|
|
8842
|
+
virginia: 'VA',
|
|
8843
|
+
washington: 'WA',
|
|
8844
|
+
'west virginia': 'WV',
|
|
8845
|
+
wisconsin: 'WI',
|
|
8846
|
+
wyoming: 'WY',
|
|
8847
|
+
'district of columbia': 'DC',
|
|
8848
|
+
};
|
|
8785
8849
|
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8850
|
+
const lowerState = cleaned.toLowerCase();
|
|
8851
|
+
if (stateMap[lowerState]) {
|
|
8852
|
+
return stateMap[lowerState];
|
|
8853
|
+
}
|
|
8790
8854
|
|
|
8791
|
-
//
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
// alabama: 'AL',
|
|
8797
|
-
// alaska: 'AK',
|
|
8798
|
-
// arizona: 'AZ',
|
|
8799
|
-
// arkansas: 'AR',
|
|
8800
|
-
// california: 'CA',
|
|
8801
|
-
// colorado: 'CO',
|
|
8802
|
-
// connecticut: 'CT',
|
|
8803
|
-
// delaware: 'DE',
|
|
8804
|
-
// florida: 'FL',
|
|
8805
|
-
// georgia: 'GA',
|
|
8806
|
-
// hawaii: 'HI',
|
|
8807
|
-
// idaho: 'ID',
|
|
8808
|
-
// illinois: 'IL',
|
|
8809
|
-
// indiana: 'IN',
|
|
8810
|
-
// iowa: 'IA',
|
|
8811
|
-
// kansas: 'KS',
|
|
8812
|
-
// kentucky: 'KY',
|
|
8813
|
-
// louisiana: 'LA',
|
|
8814
|
-
// maine: 'ME',
|
|
8815
|
-
// maryland: 'MD',
|
|
8816
|
-
// massachusetts: 'MA',
|
|
8817
|
-
// michigan: 'MI',
|
|
8818
|
-
// minnesota: 'MN',
|
|
8819
|
-
// mississippi: 'MS',
|
|
8820
|
-
// missouri: 'MO',
|
|
8821
|
-
// montana: 'MT',
|
|
8822
|
-
// nebraska: 'NE',
|
|
8823
|
-
// nevada: 'NV',
|
|
8824
|
-
// 'new hampshire': 'NH',
|
|
8825
|
-
// 'new jersey': 'NJ',
|
|
8826
|
-
// 'new mexico': 'NM',
|
|
8827
|
-
// 'new york': 'NY',
|
|
8828
|
-
// 'north carolina': 'NC',
|
|
8829
|
-
// 'north dakota': 'ND',
|
|
8830
|
-
// ohio: 'OH',
|
|
8831
|
-
// oklahoma: 'OK',
|
|
8832
|
-
// oregon: 'OR',
|
|
8833
|
-
// pennsylvania: 'PA',
|
|
8834
|
-
// 'rhode island': 'RI',
|
|
8835
|
-
// 'south carolina': 'SC',
|
|
8836
|
-
// 'south dakota': 'SD',
|
|
8837
|
-
// tennessee: 'TN',
|
|
8838
|
-
// texas: 'TX',
|
|
8839
|
-
// utah: 'UT',
|
|
8840
|
-
// vermont: 'VT',
|
|
8841
|
-
// virginia: 'VA',
|
|
8842
|
-
// washington: 'WA',
|
|
8843
|
-
// 'west virginia': 'WV',
|
|
8844
|
-
// wisconsin: 'WI',
|
|
8845
|
-
// wyoming: 'WY',
|
|
8846
|
-
// 'district of columbia': 'DC',
|
|
8847
|
-
// };
|
|
8855
|
+
// If already 2-letter code, uppercase it
|
|
8856
|
+
if (/^[A-Z]{2}$/i.test(cleaned)) {
|
|
8857
|
+
return cleaned.toUpperCase();
|
|
8858
|
+
}
|
|
8859
|
+
}
|
|
8848
8860
|
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
// return stateMap[lowerState];
|
|
8852
|
-
// }
|
|
8861
|
+
return cleaned;
|
|
8862
|
+
}
|
|
8853
8863
|
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
// }
|
|
8864
|
+
function cleanCountry(country) {
|
|
8865
|
+
if (!country || country.toLowerCase() === 'not available' || country.trim() === '') {
|
|
8866
|
+
return 'Not available';
|
|
8867
|
+
}
|
|
8859
8868
|
|
|
8860
|
-
//
|
|
8861
|
-
|
|
8869
|
+
// Convert 2-letter codes to full country names for display
|
|
8870
|
+
const countryMap = {
|
|
8871
|
+
US: 'United States',
|
|
8872
|
+
CA: 'Canada',
|
|
8873
|
+
UK: 'United Kingdom',
|
|
8874
|
+
GB: 'United Kingdom',
|
|
8875
|
+
AU: 'Australia',
|
|
8876
|
+
DE: 'Germany',
|
|
8877
|
+
FR: 'France',
|
|
8878
|
+
JP: 'Japan',
|
|
8879
|
+
CN: 'China',
|
|
8880
|
+
IN: 'India',
|
|
8881
|
+
BR: 'Brazil',
|
|
8882
|
+
MX: 'Mexico',
|
|
8883
|
+
};
|
|
8862
8884
|
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
// }
|
|
8885
|
+
const upperCountry = country.toUpperCase();
|
|
8886
|
+
return countryMap[upperCountry] || upperCountry;
|
|
8887
|
+
}
|
|
8867
8888
|
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
// US: 'United States',
|
|
8871
|
-
// CA: 'Canada',
|
|
8872
|
-
// UK: 'United Kingdom',
|
|
8873
|
-
// GB: 'United Kingdom',
|
|
8874
|
-
// AU: 'Australia',
|
|
8875
|
-
// DE: 'Germany',
|
|
8876
|
-
// FR: 'France',
|
|
8877
|
-
// JP: 'Japan',
|
|
8878
|
-
// CN: 'China',
|
|
8879
|
-
// IN: 'India',
|
|
8880
|
-
// BR: 'Brazil',
|
|
8881
|
-
// MX: 'Mexico',
|
|
8882
|
-
// };
|
|
8889
|
+
function formatFullAddress(data) {
|
|
8890
|
+
const parts = [];
|
|
8883
8891
|
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8892
|
+
if (data.business_address_street && data.business_address_street !== 'Not available') {
|
|
8893
|
+
parts.push(data.business_address_street);
|
|
8894
|
+
}
|
|
8887
8895
|
|
|
8888
|
-
|
|
8889
|
-
|
|
8896
|
+
const cityStateZip = [];
|
|
8897
|
+
if (data.business_address_city && data.business_address_city !== 'Not available') {
|
|
8898
|
+
cityStateZip.push(data.business_address_city);
|
|
8899
|
+
}
|
|
8890
8900
|
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8901
|
+
if (data.business_address_state && data.business_address_state !== 'Not available') {
|
|
8902
|
+
cityStateZip.push(data.business_address_state);
|
|
8903
|
+
}
|
|
8894
8904
|
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
// }
|
|
8905
|
+
if (data.business_address_zip && data.business_address_zip !== 'Not available') {
|
|
8906
|
+
cityStateZip.push(data.business_address_zip);
|
|
8907
|
+
}
|
|
8899
8908
|
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8909
|
+
if (cityStateZip.length > 0) {
|
|
8910
|
+
parts.push(cityStateZip.join(', '));
|
|
8911
|
+
}
|
|
8903
8912
|
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8913
|
+
if (data.business_address_country && data.business_address_country !== 'Not available') {
|
|
8914
|
+
parts.push(data.business_address_country);
|
|
8915
|
+
}
|
|
8907
8916
|
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
// }
|
|
8917
|
+
return parts.length > 0 ? parts.join(', ') : 'Not available';
|
|
8918
|
+
}
|
|
8911
8919
|
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
// }
|
|
8920
|
+
function getRegionFromState(state, country) {
|
|
8921
|
+
if (country !== 'US' || state === 'Not available') return null;
|
|
8915
8922
|
|
|
8916
|
-
|
|
8917
|
-
|
|
8923
|
+
const regions = {
|
|
8924
|
+
Northeast: ['CT', 'ME', 'MA', 'NH', 'RI', 'VT', 'NJ', 'NY', 'PA'],
|
|
8925
|
+
Midwest: ['IL', 'IN', 'MI', 'OH', 'WI', 'IA', 'KS', 'MN', 'MO', 'NE', 'ND', 'SD'],
|
|
8926
|
+
South: ['DE', 'FL', 'GA', 'MD', 'NC', 'SC', 'VA', 'DC', 'WV', 'AL', 'KY', 'MS', 'TN', 'AR', 'LA', 'OK', 'TX'],
|
|
8927
|
+
West: ['AZ', 'CO', 'ID', 'MT', 'NV', 'NM', 'UT', 'WY', 'AK', 'CA', 'HI', 'OR', 'WA'],
|
|
8928
|
+
};
|
|
8918
8929
|
|
|
8919
|
-
|
|
8920
|
-
|
|
8930
|
+
for (const [region, states] of Object.entries(regions)) {
|
|
8931
|
+
if (states.includes(state)) {
|
|
8932
|
+
return region;
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8921
8935
|
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
// Midwest: ['IL', 'IN', 'MI', 'OH', 'WI', 'IA', 'KS', 'MN', 'MO', 'NE', 'ND', 'SD'],
|
|
8925
|
-
// South: ['DE', 'FL', 'GA', 'MD', 'NC', 'SC', 'VA', 'DC', 'WV', 'AL', 'KY', 'MS', 'TN', 'AR', 'LA', 'OK', 'TX'],
|
|
8926
|
-
// West: ['AZ', 'CO', 'ID', 'MT', 'NV', 'NM', 'UT', 'WY', 'AK', 'CA', 'HI', 'OR', 'WA'],
|
|
8927
|
-
// };
|
|
8936
|
+
return null;
|
|
8937
|
+
}
|
|
8928
8938
|
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
// return region;
|
|
8932
|
-
// }
|
|
8933
|
-
// }
|
|
8939
|
+
function getDefaultBusinessInfo(name, email, error = null) {
|
|
8940
|
+
const domain = email.includes('@') ? email.split('@')[1] : '';
|
|
8934
8941
|
|
|
8935
|
-
|
|
8936
|
-
|
|
8942
|
+
return {
|
|
8943
|
+
business_name: name,
|
|
8944
|
+
business_domain: domain,
|
|
8945
|
+
business_bio: 'Information not available',
|
|
8946
|
+
business_size: 'unknown',
|
|
8947
|
+
business_category: 'Professional Services',
|
|
8948
|
+
business_sub_category: 'Business Services',
|
|
8949
|
+
business_country: 'US',
|
|
8950
|
+
business_phone: 'Not available',
|
|
8951
|
+
business_website: 'Not available',
|
|
8952
|
+
|
|
8953
|
+
// Address components
|
|
8954
|
+
business_address_street: 'Not available',
|
|
8955
|
+
business_address_city: 'Not available',
|
|
8956
|
+
business_address_state: 'Not available',
|
|
8957
|
+
business_address_zip: 'Not available',
|
|
8958
|
+
business_address_country: 'Not available',
|
|
8959
|
+
business_address_full: 'Not available',
|
|
8937
8960
|
|
|
8938
|
-
//
|
|
8939
|
-
|
|
8961
|
+
// Structured objects
|
|
8962
|
+
business_category_id: null,
|
|
8963
|
+
business_address: {
|
|
8964
|
+
street: 'Not available',
|
|
8965
|
+
city: 'Not available',
|
|
8966
|
+
state: 'Not available',
|
|
8967
|
+
zip: 'Not available',
|
|
8968
|
+
country: 'Not available',
|
|
8969
|
+
full: 'Not available',
|
|
8970
|
+
coordinates: null,
|
|
8971
|
+
timezone: null,
|
|
8972
|
+
},
|
|
8973
|
+
business_location: {
|
|
8974
|
+
region: null,
|
|
8975
|
+
metro_area: null,
|
|
8976
|
+
is_headquarters: null,
|
|
8977
|
+
},
|
|
8978
|
+
error: error || 'API call failed',
|
|
8979
|
+
};
|
|
8980
|
+
}
|
|
8940
8981
|
|
|
8941
|
-
//
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8982
|
+
// Extract lists from your JSON categories array
|
|
8983
|
+
const categories = [
|
|
8984
|
+
{
|
|
8985
|
+
id: 'ind_technology',
|
|
8986
|
+
name: 'Technology',
|
|
8987
|
+
sub: ['Software Development', 'AI & Machine Learning', 'Cybersecurity', 'Cloud Computing', 'IT Services', 'SaaS & Platforms', 'Hardware & Electronics'],
|
|
8988
|
+
},
|
|
8989
|
+
{
|
|
8990
|
+
id: 'ind_marketing',
|
|
8991
|
+
name: 'Marketing & Advertising',
|
|
8992
|
+
sub: ['Digital Marketing', 'PPC & SEO', 'Content Creation', 'Branding', 'Social Media Management', 'Email Marketing', 'Market Research'],
|
|
8993
|
+
},
|
|
8994
|
+
{
|
|
8995
|
+
id: 'ind_sales',
|
|
8996
|
+
name: 'Sales',
|
|
8997
|
+
sub: ['B2B Sales', 'B2C Sales', 'Real Estate Sales', 'Account Management', 'Lead Generation', 'Inside Sales', 'Field Sales'],
|
|
8998
|
+
},
|
|
8999
|
+
{
|
|
9000
|
+
id: 'ind_finance',
|
|
9001
|
+
name: 'Finance & Accounting',
|
|
9002
|
+
sub: ['Banking', 'Investment', 'Financial Planning', 'Accounting', 'Bookkeeping', 'Insurance', 'FinTech'],
|
|
9003
|
+
},
|
|
9004
|
+
{
|
|
9005
|
+
id: 'ind_healthcare',
|
|
9006
|
+
name: 'Healthcare',
|
|
9007
|
+
sub: ['Medical Clinics', 'Hospitals', 'Pharma', 'Mental Health', 'Healthcare IT', 'Home Care', 'Medical Research'],
|
|
9008
|
+
},
|
|
9009
|
+
{
|
|
9010
|
+
id: 'ind_realestate',
|
|
9011
|
+
name: 'Real Estate',
|
|
9012
|
+
sub: ['Residential Real Estate', 'Commercial Real Estate', 'Property Management', 'Investment & BRRRR', 'Construction', 'Architecture', 'Interior Design'],
|
|
9013
|
+
},
|
|
9014
|
+
{
|
|
9015
|
+
id: 'ind_ecommerce',
|
|
9016
|
+
name: 'E-commerce',
|
|
9017
|
+
sub: ['Online Store', 'Dropshipping', 'Amazon FBA', 'Marketplace Selling', 'Retail', 'Inventory Management', 'Fulfillment & Logistics'],
|
|
9018
|
+
},
|
|
9019
|
+
{
|
|
9020
|
+
id: 'ind_education',
|
|
9021
|
+
name: 'Education',
|
|
9022
|
+
sub: ['Schools', 'Universities', 'Private Tutoring', 'Online Courses', 'EdTech', 'Training & Development'],
|
|
9023
|
+
},
|
|
9024
|
+
{
|
|
9025
|
+
id: 'ind_hospitality',
|
|
9026
|
+
name: 'Hospitality & Travel',
|
|
9027
|
+
sub: ['Hotels', 'Restaurants', 'Cafes & Bars', 'Travel Agencies', 'Tourism', 'Events & Catering', 'Transportation'],
|
|
9028
|
+
},
|
|
9029
|
+
{
|
|
9030
|
+
id: 'ind_professional',
|
|
9031
|
+
name: 'Professional Services',
|
|
9032
|
+
sub: ['Legal', 'Consulting', 'HR & Recruiting', 'Accounting Firms', 'Business Services', 'Management Consulting'],
|
|
9033
|
+
},
|
|
9034
|
+
{
|
|
9035
|
+
id: 'ind_manufacturing',
|
|
9036
|
+
name: 'Manufacturing',
|
|
9037
|
+
sub: ['Automotive', 'Industrial', 'Textile', 'Electronics', 'Food Production', 'Machinery', 'Chemicals'],
|
|
9038
|
+
},
|
|
9039
|
+
{
|
|
9040
|
+
id: 'ind_nonprofit',
|
|
9041
|
+
name: 'Nonprofit & Government',
|
|
9042
|
+
sub: ['NGOs', 'Municipality', 'Government Services', 'Public Health', 'Community Organizations', 'Education Programs'],
|
|
9043
|
+
},
|
|
9044
|
+
{
|
|
9045
|
+
id: 'ind_media',
|
|
9046
|
+
name: 'Media & Entertainment',
|
|
9047
|
+
sub: ['Film & Video', 'Music', 'Publishing', 'Gaming', 'News & Journalism', 'Influencers', 'Production Studios'],
|
|
9048
|
+
},
|
|
9049
|
+
{
|
|
9050
|
+
id: 'ind_logistics',
|
|
9051
|
+
name: 'Logistics & Transportation',
|
|
9052
|
+
sub: ['Shipping', 'Trucking', 'Last-Mile Delivery', 'Warehousing', 'Freight Forwarding', 'Route Optimization'],
|
|
9053
|
+
},
|
|
9054
|
+
{
|
|
9055
|
+
id: 'ind_energy',
|
|
9056
|
+
name: 'Energy & Utilities',
|
|
9057
|
+
sub: ['Solar', 'Oil & Gas', 'Electricity Providers', 'Water Utilities', 'Environmental Services', 'Renewable Energy'],
|
|
9058
|
+
},
|
|
9059
|
+
{
|
|
9060
|
+
id: 'ind_construction',
|
|
9061
|
+
name: 'Construction & Trades',
|
|
9062
|
+
sub: ['General Contracting', 'Roofing', 'Plumbing', 'HVAC', 'Electrical', 'Renovation', 'Engineering'],
|
|
9063
|
+
},
|
|
9064
|
+
{
|
|
9065
|
+
id: 'ind_food',
|
|
9066
|
+
name: 'Food & Beverage',
|
|
9067
|
+
sub: ['Restaurants', 'Catering', 'Food Manufacturing', 'Bakeries', 'Bars & Nightlife', 'Food Delivery'],
|
|
9068
|
+
},
|
|
9069
|
+
{
|
|
9070
|
+
id: 'ind_retail',
|
|
9071
|
+
name: 'Retail',
|
|
9072
|
+
sub: ['Physical Stores', 'Boutiques', 'Supermarkets', 'Consumer Goods', 'Fashion Retail', 'Home Goods'],
|
|
9073
|
+
},
|
|
9074
|
+
];
|
|
9075
|
+
const categoryNames = categories.map((c) => c.name);
|
|
9076
|
+
const allSubCategories = categories.flatMap((c) => c.sub);
|
|
8980
9077
|
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
// id: 'ind_technology',
|
|
8985
|
-
// name: 'Technology',
|
|
8986
|
-
// sub: ['Software Development', 'AI & Machine Learning', 'Cybersecurity', 'Cloud Computing', 'IT Services', 'SaaS & Platforms', 'Hardware & Electronics'],
|
|
8987
|
-
// },
|
|
8988
|
-
// {
|
|
8989
|
-
// id: 'ind_marketing',
|
|
8990
|
-
// name: 'Marketing & Advertising',
|
|
8991
|
-
// sub: ['Digital Marketing', 'PPC & SEO', 'Content Creation', 'Branding', 'Social Media Management', 'Email Marketing', 'Market Research'],
|
|
8992
|
-
// },
|
|
8993
|
-
// {
|
|
8994
|
-
// id: 'ind_sales',
|
|
8995
|
-
// name: 'Sales',
|
|
8996
|
-
// sub: ['B2B Sales', 'B2C Sales', 'Real Estate Sales', 'Account Management', 'Lead Generation', 'Inside Sales', 'Field Sales'],
|
|
8997
|
-
// },
|
|
8998
|
-
// {
|
|
8999
|
-
// id: 'ind_finance',
|
|
9000
|
-
// name: 'Finance & Accounting',
|
|
9001
|
-
// sub: ['Banking', 'Investment', 'Financial Planning', 'Accounting', 'Bookkeeping', 'Insurance', 'FinTech'],
|
|
9002
|
-
// },
|
|
9003
|
-
// {
|
|
9004
|
-
// id: 'ind_healthcare',
|
|
9005
|
-
// name: 'Healthcare',
|
|
9006
|
-
// sub: ['Medical Clinics', 'Hospitals', 'Pharma', 'Mental Health', 'Healthcare IT', 'Home Care', 'Medical Research'],
|
|
9007
|
-
// },
|
|
9008
|
-
// {
|
|
9009
|
-
// id: 'ind_realestate',
|
|
9010
|
-
// name: 'Real Estate',
|
|
9011
|
-
// sub: ['Residential Real Estate', 'Commercial Real Estate', 'Property Management', 'Investment & BRRRR', 'Construction', 'Architecture', 'Interior Design'],
|
|
9012
|
-
// },
|
|
9013
|
-
// {
|
|
9014
|
-
// id: 'ind_ecommerce',
|
|
9015
|
-
// name: 'E-commerce',
|
|
9016
|
-
// sub: ['Online Store', 'Dropshipping', 'Amazon FBA', 'Marketplace Selling', 'Retail', 'Inventory Management', 'Fulfillment & Logistics'],
|
|
9017
|
-
// },
|
|
9018
|
-
// {
|
|
9019
|
-
// id: 'ind_education',
|
|
9020
|
-
// name: 'Education',
|
|
9021
|
-
// sub: ['Schools', 'Universities', 'Private Tutoring', 'Online Courses', 'EdTech', 'Training & Development'],
|
|
9022
|
-
// },
|
|
9023
|
-
// {
|
|
9024
|
-
// id: 'ind_hospitality',
|
|
9025
|
-
// name: 'Hospitality & Travel',
|
|
9026
|
-
// sub: ['Hotels', 'Restaurants', 'Cafes & Bars', 'Travel Agencies', 'Tourism', 'Events & Catering', 'Transportation'],
|
|
9027
|
-
// },
|
|
9028
|
-
// {
|
|
9029
|
-
// id: 'ind_professional',
|
|
9030
|
-
// name: 'Professional Services',
|
|
9031
|
-
// sub: ['Legal', 'Consulting', 'HR & Recruiting', 'Accounting Firms', 'Business Services', 'Management Consulting'],
|
|
9032
|
-
// },
|
|
9033
|
-
// {
|
|
9034
|
-
// id: 'ind_manufacturing',
|
|
9035
|
-
// name: 'Manufacturing',
|
|
9036
|
-
// sub: ['Automotive', 'Industrial', 'Textile', 'Electronics', 'Food Production', 'Machinery', 'Chemicals'],
|
|
9037
|
-
// },
|
|
9038
|
-
// {
|
|
9039
|
-
// id: 'ind_nonprofit',
|
|
9040
|
-
// name: 'Nonprofit & Government',
|
|
9041
|
-
// sub: ['NGOs', 'Municipality', 'Government Services', 'Public Health', 'Community Organizations', 'Education Programs'],
|
|
9042
|
-
// },
|
|
9043
|
-
// {
|
|
9044
|
-
// id: 'ind_media',
|
|
9045
|
-
// name: 'Media & Entertainment',
|
|
9046
|
-
// sub: ['Film & Video', 'Music', 'Publishing', 'Gaming', 'News & Journalism', 'Influencers', 'Production Studios'],
|
|
9047
|
-
// },
|
|
9048
|
-
// {
|
|
9049
|
-
// id: 'ind_logistics',
|
|
9050
|
-
// name: 'Logistics & Transportation',
|
|
9051
|
-
// sub: ['Shipping', 'Trucking', 'Last-Mile Delivery', 'Warehousing', 'Freight Forwarding', 'Route Optimization'],
|
|
9052
|
-
// },
|
|
9053
|
-
// {
|
|
9054
|
-
// id: 'ind_energy',
|
|
9055
|
-
// name: 'Energy & Utilities',
|
|
9056
|
-
// sub: ['Solar', 'Oil & Gas', 'Electricity Providers', 'Water Utilities', 'Environmental Services', 'Renewable Energy'],
|
|
9057
|
-
// },
|
|
9058
|
-
// {
|
|
9059
|
-
// id: 'ind_construction',
|
|
9060
|
-
// name: 'Construction & Trades',
|
|
9061
|
-
// sub: ['General Contracting', 'Roofing', 'Plumbing', 'HVAC', 'Electrical', 'Renovation', 'Engineering'],
|
|
9062
|
-
// },
|
|
9063
|
-
// {
|
|
9064
|
-
// id: 'ind_food',
|
|
9065
|
-
// name: 'Food & Beverage',
|
|
9066
|
-
// sub: ['Restaurants', 'Catering', 'Food Manufacturing', 'Bakeries', 'Bars & Nightlife', 'Food Delivery'],
|
|
9067
|
-
// },
|
|
9068
|
-
// {
|
|
9069
|
-
// id: 'ind_retail',
|
|
9070
|
-
// name: 'Retail',
|
|
9071
|
-
// sub: ['Physical Stores', 'Boutiques', 'Supermarkets', 'Consumer Goods', 'Fashion Retail', 'Home Goods'],
|
|
9072
|
-
// },
|
|
9073
|
-
// ];
|
|
9074
|
-
// const categoryNames = categories.map((c) => c.name);
|
|
9075
|
-
// const allSubCategories = categories.flatMap((c) => c.sub);
|
|
9078
|
+
const business_info_ret = await submit_chat_gpt_prompt({
|
|
9079
|
+
uid,
|
|
9080
|
+
prompt: `Research the company: "${name}" (${email}).
|
|
9076
9081
|
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9082
|
+
REQUIRED INFORMATION:
|
|
9083
|
+
1. Company name (official name)
|
|
9084
|
+
2. Email domain name
|
|
9085
|
+
3. Professional one-sentence biography
|
|
9086
|
+
4. Industry category and sub-category
|
|
9087
|
+
5. Primary country (2-letter ISO code)
|
|
9088
|
+
6. Telephone number
|
|
9089
|
+
7. Website URL
|
|
9090
|
+
8. COMPLETE ADDRESS DETAILS:
|
|
9091
|
+
- Full street address (street number, street name, suite/apt if applicable)
|
|
9092
|
+
- City
|
|
9093
|
+
- State/Province (use abbreviation where standard)
|
|
9094
|
+
- Zip/Postal code
|
|
9095
|
+
- Country
|
|
9096
|
+
|
|
9097
|
+
ADDRESS FORMATTING EXAMPLES:
|
|
9098
|
+
- Full street: "1600 Amphitheatre Parkway"
|
|
9099
|
+
- City: "Mountain View"
|
|
9100
|
+
- State: "CA"
|
|
9101
|
+
- Zip: "94043"
|
|
9102
|
+
- Country: "US"
|
|
9103
|
+
- Full address: "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA"
|
|
9080
9104
|
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
//
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
// business_size: z.enum(['unknown', 'small', 'medium', 'large', 'enterprise']),
|
|
9118
|
-
// business_category: z.enum(categoryNames),
|
|
9119
|
-
// business_sub_category: z.enum(allSubCategories),
|
|
9120
|
-
// business_country: z.string().length(2).describe('2-letter ISO country code'),
|
|
9121
|
-
// business_phone: z.string().describe("Telephone number or 'Not available'"),
|
|
9122
|
-
// business_website: z.string().describe("Website URL or 'Not available'"),
|
|
9123
|
-
|
|
9124
|
-
// // Complete address components
|
|
9125
|
-
// business_address_street: z.string().describe('Full street address (number, street, suite)'),
|
|
9126
|
-
// business_address_city: z.string().describe('City name'),
|
|
9127
|
-
// business_address_state: z.string().describe('State/Province (abbreviation if standard)'),
|
|
9128
|
-
// business_address_zip: z.string().describe('Zip/Postal code'),
|
|
9129
|
-
// business_address_country: z.string().describe('Country name'),
|
|
9130
|
-
// business_address_full: z.string().describe('Complete formatted address'),
|
|
9131
|
-
// }),
|
|
9132
|
-
// metadata: {
|
|
9133
|
-
// func: 'get_business_info',
|
|
9134
|
-
// company_name: name,
|
|
9135
|
-
// company_email: email,
|
|
9136
|
-
// },
|
|
9137
|
-
// account_profile_info,
|
|
9138
|
-
// tools: [{ type: 'web_search_preview' }],
|
|
9139
|
-
// });
|
|
9105
|
+
INSTRUCTIONS:
|
|
9106
|
+
- Use web search to find accurate information
|
|
9107
|
+
- If not found online, infer from typical patterns
|
|
9108
|
+
- For unknown info, use "Not available"
|
|
9109
|
+
- For US states, use 2-letter abbreviations (CA, NY, TX, etc.)
|
|
9110
|
+
- For other countries, use standard regional names
|
|
9111
|
+
|
|
9112
|
+
Be as precise and accurate as possible.`,
|
|
9113
|
+
model: 'gpt-4o-mini',
|
|
9114
|
+
response_format: z.object({
|
|
9115
|
+
business_name: z.string().describe('Official company name'),
|
|
9116
|
+
business_domain: z.string().describe('Domain name from email'),
|
|
9117
|
+
business_bio: z.string().describe('One-sentence professional summary'),
|
|
9118
|
+
business_size: z.enum(['unknown', 'small', 'medium', 'large', 'enterprise']),
|
|
9119
|
+
business_category: z.enum(categoryNames),
|
|
9120
|
+
business_sub_category: z.enum(allSubCategories),
|
|
9121
|
+
business_country: z.string().length(2).describe('2-letter ISO country code'),
|
|
9122
|
+
business_phone: z.string().describe("Telephone number or 'Not available'"),
|
|
9123
|
+
business_website: z.string().describe("Website URL or 'Not available'"),
|
|
9124
|
+
|
|
9125
|
+
// Complete address components
|
|
9126
|
+
business_address_street: z.string().describe('Full street address (number, street, suite)'),
|
|
9127
|
+
business_address_city: z.string().describe('City name'),
|
|
9128
|
+
business_address_state: z.string().describe('State/Province (abbreviation if standard)'),
|
|
9129
|
+
business_address_zip: z.string().describe('Zip/Postal code'),
|
|
9130
|
+
business_address_country: z.string().describe('Country name'),
|
|
9131
|
+
business_address_full: z.string().describe('Complete formatted address'),
|
|
9132
|
+
}),
|
|
9133
|
+
metadata: {
|
|
9134
|
+
func: 'get_business_info',
|
|
9135
|
+
company_name: name,
|
|
9136
|
+
company_email: email,
|
|
9137
|
+
},
|
|
9138
|
+
account_profile_info,
|
|
9139
|
+
tools: [{ type: 'web_search_preview' }],
|
|
9140
|
+
});
|
|
9140
9141
|
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9142
|
+
try {
|
|
9143
|
+
if (business_info_ret.code > -1) {
|
|
9144
|
+
const data = typeof business_info_ret.data === 'string' ? JSON.parse(business_info_ret.data) : business_info_ret.data;
|
|
9144
9145
|
|
|
9145
|
-
//
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9146
|
+
// Standardize country codes to uppercase
|
|
9147
|
+
if (data.business_country) data.business_country = data.business_country.toUpperCase();
|
|
9148
|
+
if (data.business_address_country) {
|
|
9149
|
+
data.business_address_country = data.business_address_country.toUpperCase();
|
|
9150
|
+
}
|
|
9150
9151
|
|
|
9151
|
-
//
|
|
9152
|
-
|
|
9153
|
-
|
|
9152
|
+
// Logic to attach the ID for your database
|
|
9153
|
+
const matched = categories.find((c) => c.name === data.business_category);
|
|
9154
|
+
data.business_category_id = matched ? matched.id : null;
|
|
9154
9155
|
|
|
9155
|
-
//
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
//
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
//
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9156
|
+
// Validate and clean all contact information
|
|
9157
|
+
data.business_phone = validatePhoneNumber(data.business_phone);
|
|
9158
|
+
data.business_website = validateWebsite(data.business_website);
|
|
9159
|
+
|
|
9160
|
+
// Clean and standardize all address components
|
|
9161
|
+
data.business_address_street = cleanStreetAddress(data.business_address_street);
|
|
9162
|
+
data.business_address_city = cleanText(data.business_address_city);
|
|
9163
|
+
data.business_address_zip = cleanZipCode(data.business_address_zip, data.business_country);
|
|
9164
|
+
data.business_address_state = cleanStateProvince(data.business_address_state, data.business_country);
|
|
9165
|
+
data.business_address_country = cleanCountry(data.business_address_country || data.business_country);
|
|
9166
|
+
data.business_address_full = formatFullAddress(data);
|
|
9167
|
+
|
|
9168
|
+
// Create a comprehensive structured address object
|
|
9169
|
+
data.business_address = {
|
|
9170
|
+
street: data.business_address_street,
|
|
9171
|
+
city: data.business_address_city,
|
|
9172
|
+
state: data.business_address_state,
|
|
9173
|
+
zip: data.business_address_zip,
|
|
9174
|
+
country: data.business_address_country,
|
|
9175
|
+
full: data.business_address_full,
|
|
9176
|
+
coordinates: null, // Can be populated later with geocoding
|
|
9177
|
+
timezone: null, // Can be populated later
|
|
9178
|
+
};
|
|
9178
9179
|
|
|
9179
|
-
//
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9180
|
+
// Generate additional useful fields
|
|
9181
|
+
data.business_location = {
|
|
9182
|
+
region: getRegionFromState(data.business_address_state, data.business_country),
|
|
9183
|
+
metro_area: null, // Can be populated later
|
|
9184
|
+
is_headquarters: null, // Can be determined from address pattern
|
|
9185
|
+
};
|
|
9185
9186
|
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9187
|
+
return data;
|
|
9188
|
+
} else {
|
|
9189
|
+
console.error('Business info API call failed:', business_info_ret);
|
|
9190
|
+
return getDefaultBusinessInfo(name, email);
|
|
9191
|
+
}
|
|
9192
|
+
} catch (error) {
|
|
9193
|
+
console.error('Error in get_business_info:', error);
|
|
9194
|
+
return getDefaultBusinessInfo(name, email, error.message);
|
|
9195
|
+
}
|
|
9196
|
+
};
|
|
9196
9197
|
|
|
9197
9198
|
export const get_person_info = async function (uid, name, email, account_profile_info, email_context = '') {
|
|
9198
9199
|
// ========== HELPER FUNCTIONS ==========
|