delete some routes so we can try to fit the compute quota

This commit is contained in:
Ra
2025-09-02 14:56:02 -07:00
parent 899900f99c
commit a3ef608825
8 changed files with 7046 additions and 501 deletions

View File

@@ -4,13 +4,13 @@
"": {
"name": "auditly-functions",
"dependencies": {
"@google-cloud/vertexai": "^1.4.0",
"firebase-admin": "^12.1.1",
"firebase-functions": "^5.0.1",
"stripe": "^18.4.0",
"@google-cloud/vertexai": "^1.10.0",
"firebase-admin": "^12.7.0",
"firebase-functions": "^6.4.0",
"stripe": "^18.5.0",
},
"devDependencies": {
"firebase-functions-test": "^3.1.0",
"firebase-functions-test": "^3.4.1",
},
},
},
@@ -235,7 +235,7 @@
"@types/cors": ["@types/cors@2.8.19", "", { "dependencies": { "@types/node": "*" } }, "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg=="],
"@types/express": ["@types/express@4.17.3", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "*", "@types/serve-static": "*" } }, "sha512-I8cGRJj3pyOLs/HndoP+25vOqhqWkAZsWMEmq1qXy/b/M3ppufecUwaK2/TVDVxcV61/iSdhykUjQQ2DLSrTdg=="],
"@types/express": ["@types/express@4.17.23", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", "@types/qs": "*", "@types/serve-static": "*" } }, "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ=="],
"@types/express-serve-static-core": ["@types/express-serve-static-core@4.19.6", "", { "dependencies": { "@types/node": "*", "@types/qs": "*", "@types/range-parser": "*", "@types/send": "*" } }, "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A=="],
@@ -505,7 +505,7 @@
"firebase-admin": ["firebase-admin@12.7.0", "", { "dependencies": { "@fastify/busboy": "^3.0.0", "@firebase/database-compat": "1.0.8", "@firebase/database-types": "1.0.5", "@types/node": "^22.0.1", "farmhash-modern": "^1.1.0", "jsonwebtoken": "^9.0.0", "jwks-rsa": "^3.1.0", "node-forge": "^1.3.1", "uuid": "^10.0.0" }, "optionalDependencies": { "@google-cloud/firestore": "^7.7.0", "@google-cloud/storage": "^7.7.0" } }, "sha512-raFIrOyTqREbyXsNkSHyciQLfv8AUZazehPaQS1lZBSCDYW74FYXU0nQZa3qHI4K+hawohlDbywZ4+qce9YNxA=="],
"firebase-functions": ["firebase-functions@5.1.1", "", { "dependencies": { "@types/cors": "^2.8.5", "@types/express": "4.17.3", "cors": "^2.8.5", "express": "^4.17.1", "protobufjs": "^7.2.2" }, "peerDependencies": { "firebase-admin": "^11.10.0 || ^12.0.0" }, "bin": { "firebase-functions": "lib/bin/firebase-functions.js" } }, "sha512-KkyKZE98Leg/C73oRyuUYox04PQeeBThdygMfeX+7t1cmKWYKa/ZieYa89U8GHgED+0mF7m7wfNZOfbURYxIKg=="],
"firebase-functions": ["firebase-functions@6.4.0", "", { "dependencies": { "@types/cors": "^2.8.5", "@types/express": "^4.17.21", "cors": "^2.8.5", "express": "^4.21.0", "protobufjs": "^7.2.2" }, "peerDependencies": { "firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0" }, "bin": { "firebase-functions": "lib/bin/firebase-functions.js" } }, "sha512-Q/LGhJrmJEhT0dbV60J4hCkVSeOM6/r7xJS/ccmkXzTWMjo+UPAYX9zlQmGlEjotstZ0U9GtQSJSgbB2Z+TJDg=="],
"firebase-functions-test": ["firebase-functions-test@3.4.1", "", { "dependencies": { "@types/lodash": "^4.14.104", "lodash": "^4.17.5", "ts-deepmerge": "^2.0.1" }, "peerDependencies": { "firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0", "firebase-functions": ">=4.9.0", "jest": ">=28.0.0" } }, "sha512-qAq0oszrBGdf4bnCF6t4FoSgMsepeIXh0Pi/FhikSE6e+TvKKGpfrfUP/5pFjJZxFcLsweoau88KydCql4xSeg=="],
@@ -899,7 +899,7 @@
"strip-json-comments": ["strip-json-comments@3.1.1", "", {}, "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig=="],
"stripe": ["stripe@18.4.0", "", { "dependencies": { "qs": "^6.11.0" }, "peerDependencies": { "@types/node": ">=12.x.x" }, "optionalPeers": ["@types/node"] }, "sha512-LKFeDnDYo4U/YzNgx2Lc9PT9XgKN0JNF1iQwZxgkS4lOw5NunWCnzyH5RhTlD3clIZnf54h7nyMWkS8VXPmtTQ=="],
"stripe": ["stripe@18.5.0", "", { "dependencies": { "qs": "^6.11.0" }, "peerDependencies": { "@types/node": ">=12.x.x" }, "optionalPeers": ["@types/node"] }, "sha512-Hp+wFiEQtCB0LlNgcFh5uVyKznpDjzyUZ+CNVEf+I3fhlYvh7rZruIg+jOwzJRCpy0ZTPMjlzm7J2/M2N6d+DA=="],
"strnum": ["strnum@1.1.2", "", {}, "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA=="],
@@ -1015,8 +1015,6 @@
"jsonwebtoken/jws": ["jws@3.2.2", "", { "dependencies": { "jwa": "^1.4.1", "safe-buffer": "^5.0.1" } }, "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA=="],
"jwks-rsa/@types/express": ["@types/express@4.17.23", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", "@types/qs": "*", "@types/serve-static": "*" } }, "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ=="],
"micromatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
"p-locate/p-limit": ["p-limit@2.3.0", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="],

File diff suppressed because it is too large Load Diff

6590
functions/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,17 +9,17 @@
"logs": "firebase functions:log"
},
"engines": {
"node": "18"
"node": "22"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^12.1.1",
"firebase-functions": "^5.0.1",
"@google-cloud/vertexai": "^1.4.0",
"stripe": "^18.4.0"
"@google-cloud/vertexai": "^1.10.0",
"firebase-admin": "^12.7.0",
"firebase-functions": "^6.4.0",
"stripe": "^18.5.0"
},
"devDependencies": {
"firebase-functions-test": "^3.1.0"
"firebase-functions-test": "^3.4.1"
},
"private": true
}

View File

@@ -359,9 +359,11 @@ export const OrgProvider: React.FC<{ children: React.ReactNode; selectedOrgId: s
});
const departmentBreakdown = Array.from(deptMap.entries()).map(([department, count]) => ({ department, count }));
let response, report: CompanyReport;
try {
// Use secure API for AI generation
let response = await secureApi.generateCompanyWiki({
response = await secureApi.generateCompanyWiki({
...org,
metrics: {
totalEmployees,
@@ -373,21 +375,21 @@ export const OrgProvider: React.FC<{ children: React.ReactNode; selectedOrgId: s
console.log('Company insights generated via AI successfully');
// Combine concrete metrics with AI insights
let report: CompanyReport = {
id: Date.now().toString(),
createdAt: Date.now(),
// Use AI-generated insights for subjective analysis
// Override with our concrete metrics
overview: {
totalEmployees,
departmentBreakdown,
submissionRate,
lastUpdated: Date.now(),
averagePerformanceScore: (response as any)?.overview?.averagePerformanceScore || 0,
riskLevel: (response as any)?.overview?.riskLevel || 'Unknown'
},
...(response as any)
};
// report = {
// id: Date.now().toString(),
// createdAt: Date.now(),
// // Use AI-generated insights for subjective analysis
// // Override with our concrete metrics
// overview: {
// totalEmployees,
// departmentBreakdown,
// submissionRate,
// lastUpdated: Date.now(),
// averagePerformanceScore: (response as any)?.overview?.averagePerformanceScore || 0,
// riskLevel: (response as any)?.overview?.riskLevel || 'Unknown'
// },
// ...(response as any)
// };
console.log('Final company report object:', report);
// await saveFullCompanyReport(report);

View File

@@ -4,6 +4,7 @@ import { useAuth } from '../contexts/AuthContext';
import { useOrg } from '../contexts/OrgContext';
import { onboardingSteps, OnboardingFormData, initializeOnboardingData } from '../data/onboardingSteps';
import { secureApi } from '../services/secureApi';
import { uploadCompanyLogo } from '../services/imageStorageService';
import {
FigmaOnboardingIntro,
FigmaOnboardingQuestion,
@@ -88,6 +89,7 @@ const Onboarding: React.FC = () => {
onboardingCompleted: true,
updatedAt: Date.now(),
});
await generateCompanyWiki();
navigate('/reports', { replace: true });
} catch (error) {
console.error('Error completing onboarding:', error);
@@ -104,10 +106,17 @@ const Onboarding: React.FC = () => {
}
};
const handleLogoUpload = (file: File) => {
// Create object URL for preview
const logoUrl = URL.createObjectURL(file);
updateFormData('companyLogo', logoUrl);
const handleLogoUpload = async (file: File) => {
try {
// Upload image to Firebase storage and get the stored image data
const uploadedImage = await uploadCompanyLogo(file, orgId);
// Store the dataUrl (base64) from the uploaded image
updateFormData('companyLogo', uploadedImage.dataUrl);
} catch (error) {
console.error('Failed to upload company logo:', error);
// Optionally show user feedback here
alert('Failed to upload logo. Please try again.');
}
};
const getSectionInfo = () => {

View File

@@ -265,7 +265,7 @@ class SecureApiService {
}
async generateCompanyWiki(org: any, submissions: any[] = []): Promise<CompanyReport> {
const response = await this.makeRequest<{ report: CompanyReport }>('generateCompanyWiki', 'POST', { org, submissions });
const response = await this.makeRequest<{ report: CompanyReport }>('generateCompanyReport', 'POST', { org, submissions });
return response.report;
}

View File

@@ -37,6 +37,9 @@ export const processImage = async (
const img = new Image();
img.onload = () => {
// Clean up the object URL to free memory
URL.revokeObjectURL(img.src);
// Calculate dimensions to maintain aspect ratio
let { width, height } = calculateDimensions(
img.width,
@@ -78,6 +81,8 @@ export const processImage = async (
};
img.onerror = () => {
// Clean up the object URL in case of error
URL.revokeObjectURL(img.src);
reject(new Error('Failed to load image'));
};