Skip to content

Commit

Permalink
chore(deps): update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed May 17, 2024
1 parent 08d70a8 commit b1d4938
Show file tree
Hide file tree
Showing 10 changed files with 497 additions and 746 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG NODE_VER=21-alpine
ARG NODE_VER=20-alpine
ARG DIR=/usr/src/app/

FROM node:$NODE_VER AS install
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"@oada/client": "^5.1.0",
"@oada/jobs": "^4.5.1",
"@oada/list-lib": "4.2.6",
"@oada/list-lib": "4.3.0",
"@oada/poll": "^1.0.4",
"@oada/types": "^3.5.3",
"@overleaf/o-error": "^3.4.0",
Expand All @@ -56,56 +56,56 @@
"convict": "^6.2.4",
"convict-format-with-moment": "^6.2.0",
"convict-format-with-validator": "^6.2.0",
"cron": "^2.4.4",
"cron": "^3.1.7",
"csvjson": "^5.1.0",
"date-fns": "^2.30.0",
"date-fns": "^3.6.0",
"debug": "^4.3.4",
"dotenv": "^16.4.5",
"es-main": "^1.3.0",
"form-data": "^4.0.0",
"fuse.js": "^6.6.2",
"js-sha256": "^0.9.0",
"fuse.js": "^7.0.0",
"js-sha256": "^0.11.0",
"json-pointer": "^0.6.2",
"json-ptr": "^3.1.1",
"jszip": "^3.10.1",
"ksuid": "^3.0.0",
"lodash": "^4.17.21",
"md5": "^2.3.0",
"moment": "^2.30.1",
"mssql": "^8.1.4",
"mssql": "^10.0.2",
"serialize-error": "^11.0.3",
"sha256": "^0.2.0",
"tslib": "^2.6.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
},
"devDependencies": {
"@ava/typescript": "^5.0.0",
"@tsconfig/node16": "^16.1.3",
"@tsconfig/node20": "^20.1.4",
"@types/bluebird": "^3.5.42",
"@types/convict": "^6.1.6",
"@types/convict-format-with-validator": "^6.0.5",
"@types/cron": "^2.4.0",
"@types/debug": "^4.1.12",
"@types/lodash": "^4.17.1",
"@types/lodash": "^4.17.4",
"@types/md5": "^2.3.5",
"@types/mssql": "^8.1.2",
"@types/node": "^20.12.11",
"@types/mssql": "^9.1.5",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@yarnpkg/sdks": "^3.1.2",
"ava": "^6.1.3",
"bluebird": "^3.7.2",
"c8": "^7.14.0",
"chai": "^4.4.1",
"c8": "^9.1.0",
"chai": "^5.1.1",
"chai-as-promised": "^7.1.2",
"eslint": "^8.57.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-xo": "^0.45.0",
"eslint-config-xo-typescript": "^4.0.0",
"eslint-formatter-pretty": "^6.0.1",
"eslint-import-resolver-node": "^0.3.9",
"eslint-plugin-array-func": "^3.1.8",
"eslint-plugin-ava": "^13.2.0",
"eslint-plugin-array-func": "^5.0.1",
"eslint-plugin-ava": "^15.0.1",
"eslint-plugin-escompat": "^3.4.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
Expand All @@ -114,15 +114,15 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-no-secrets": "^1.0.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^1.15.0",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-sonarjs": "^0.15.0",
"eslint-plugin-regexp": "^2.5.0",
"eslint-plugin-security": "^3.0.0",
"eslint-plugin-sonarjs": "^1.0.3",
"eslint-plugin-unicorn": "^53.0.0",
"prettier": "^3.2.5",
"typescript": "5.4.5"
Expand Down
74 changes: 40 additions & 34 deletions src/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2021 Qlever LLC
* Copyright 2021 Qlever LLC
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,7 @@ import csvjson from 'csvjson';
import debug from 'debug';
import ksuid from 'ksuid';
import moment from 'moment';
import type Link from '@oada/types/oada/link/v1.js';

const DOMAIN = config.get('trellis.domain');
const TOKEN = config.get('trellis.token');
Expand Down Expand Up @@ -111,7 +112,7 @@ export async function makeFinalReport() {
path: `${SERVICE_PATH}/businesses/${bid}/documents`,
})
.then((r) => r.data)
.catch(() => {});
.catch(() => { });
if (!docs) {
return;
}
Expand All @@ -120,14 +121,17 @@ export async function makeFinalReport() {
(index) => !index.startsWith('_'),
);

for await (const docid of documentKeys) {
if (!docid) return;
for await (const docId of documentKeys) {
if (!docId) {
return;
}

const document = await oada
.get({
path: `${SERVICE_PATH}/businesses/${bid}/documents/${docid}`,
path: `${SERVICE_PATH}/businesses/${bid}/documents/${docId}`,
})
.then((r) => r.data)
.catch(() => {});
.catch(() => { });

if (!document) {
return;
Expand Down Expand Up @@ -155,10 +159,10 @@ export async function makeFinalReport() {
document,
'food-logiq-mirror.shareSource.sourceBusiness.name',
);
const status = _.get(
const status = `${_.get(
document,
'food-logiq-mirror.shareSource.approvalInfo.status',
);
)!}`;
const user = _.get(
document,
'food-logiq-mirror.shareSource.approvalInfo.setBy._id',
Expand All @@ -183,31 +187,31 @@ export async function makeFinalReport() {
try {
await axios({
method: 'head',
url: `${FL_DOMAIN}/v2/businesses/${CO_ID}/documents/${docid}`,
url: `${FL_DOMAIN}/v2/businesses/${CO_ID}/documents/${docId}`,
headers: {
Authorization: `${FL_TOKEN}`,
},
});
} catch (error: unknown) {
// @ts-expect-error stupid errors
if (error.response.status === 404) {
console.log(`Document has been deleted in FL`, { docid, bid });
otherReport.flDeleted[docid] = { docid, bid, status, user };
console.log(`Document has been deleted in FL`, { docid: docId, bid });
otherReport.flDeleted[docId] = { docid: docId, bid, status, user };
finalReport.flDeleted++;
} else throw error as Error;
}

// 2. Get the associated job
const { data: meta } = await oada
.get({
path: `${SERVICE_PATH}/businesses/${bid}/documents/${docid}/_meta`,
path: `${SERVICE_PATH}/businesses/${bid}/documents/${docId}/_meta`,
})
.catch(() => ({ data: undefined }));
if (!meta) {
return;
}

const jobs = _.get(meta, 'services.fl-sync.jobs') ?? {};
const jobs: Record<string, Link> = _.get(meta, 'services.fl-sync.jobs') ?? {};
if (Object.keys(jobs).length <= 0) {
finalReport.missingFlSyncJob = finalReport.missingFlSyncJob ?? 0;
finalReport.missingFlSyncJob++;
Expand All @@ -217,8 +221,8 @@ export async function makeFinalReport() {
otherReport.missingFlSyncJobs = otherReport.missingFlSyncJobs ?? {};
otherReport.missingFlSyncJobs[status] =
otherReport.missingFlSyncJobs[status] ?? {};
otherReport.missingFlSyncJobs[status][docid] = {
docid,
otherReport.missingFlSyncJobs[status][docId] = {
docid: docId,
bid,
status,
user,
Expand All @@ -227,20 +231,22 @@ export async function makeFinalReport() {
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
console.log({ docid, bid, status, user });
otherReport.approvedButNoJob[docid] = { docid, bid, status, user };
console.log({ docid: docId, bid, status, user });
otherReport.approvedButNoJob[docId] = { docid: docId, bid, status, user };
}

return;
}

const jobkey = mostRecentKsuid(Object.keys(jobs));
if (!jobkey) return;
const jobid = jobs[jobkey]._id;
if (!jobkey) {
return;
}
const jobId = jobs[jobkey]?._id;

const job: any = await oada
.get({
path: `/${jobid}`,
path: `/${jobId}`,
})
.then((r) => r.data);

Expand All @@ -260,8 +266,8 @@ export async function makeFinalReport() {
'FoodLogiQ Status': status,
// @ts-expect-error
'Trellis Result': humanReadableJobError[jobError],
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docid}`,
'FoodLogiQ Document ID': docid,
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docId}`,
'FoodLogiQ Document ID': docId,
'FoodLogiQ Supplier ID': bid,
});

Expand All @@ -279,23 +285,23 @@ export async function makeFinalReport() {
'Supplier': busName,
'FoodLogiQ Status': status,
'Trellis Result': 'Success',
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docid}`,
'FoodLogiQ Document ID': docid,
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docId}`,
'FoodLogiQ Document ID': docId,
'FoodLogiQ Supplier ID': bid,
});
console.log({ docid, jobid, status: job.status });
console.log({ docid: docId, jobid: jobId, status: job.status });
} else {
finalReport.otherErrors++;
otherReport.otherErrors[docid] = { docid, bid, jobid };
otherReport.otherErrors[docId] = { docid: docId, bid, jobid: jobId };
spreadsheet.push({
'Document Name': documentName,
'Document Type': type,
'Date Created': createDate,
'Supplier': busName,
'FoodLogiQ Status': status,
'Trellis Result': 'Other Trellis Error',
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docid}`,
'FoodLogiQ Document ID': docid,
'FoodLogiQ Link': `https://connect.foodlogiq.com/businesses/${CO_ID}/documents/detail/${docId}`,
'FoodLogiQ Document ID': docId,
'FoodLogiQ Supplier ID': bid,
});
return;
Expand All @@ -318,12 +324,12 @@ export async function makeFinalReport() {
finalReport.flStatuses[status].notInLaserfiche =
finalReport.flStatuses[status].notInLaserfiche || 0;
finalReport.flStatuses[status].notInLaserfiche++;
otherReport.notInLaserfiche[docid] = { docid, bid, jobid };
otherReport.notInLaserfiche[docId] = { docid: docId, bid, jobid: jobId };
if (status === 'approved') {
otherReport.approvedNotInLaserfiche[docid] = {
docid,
otherReport.approvedNotInLaserfiche[docId] = {
docid: docId,
bid,
jobid,
jobid: jobId,
};
}
}
Expand Down Expand Up @@ -403,8 +409,8 @@ function fixHeaders(csv: string, headers: string[]) {
export function mostRecentKsuid(keys: string[]) {
return keys.length > 0
? keys
.map((k) => ksuid.parse(k))
.reduce((a, b) => (a.compare(b) > 0 ? a : b)).string
.map((k) => ksuid.parse(k))
.reduce((a, b) => (a.compare(b) > 0 ? a : b)).string
: undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions src/reportConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import type { ReportConfig } from '@oada/jobs';

export const docReportConfig: ReportConfig = {
export const docReportConfig = {
jobMappings: {
'Document Name': '/config/name',
'Document Type': '/config/type',
Expand Down Expand Up @@ -45,9 +45,9 @@ export const docReportConfig: ReportConfig = {
'target-error-already-approved':
'Document already approved; Extraction Failure',
},
};
} as const satisfies ReportConfig;

export const tpReportConfig: ReportConfig = {
export const tpReportConfig = {
jobMappings: {
'FL Name': '/config/fl-business/business/name',
'FL Address': '/config/fl-business/business/address/addressLineOne',
Expand All @@ -57,7 +57,7 @@ export const tpReportConfig: ReportConfig = {
'Error Message': '/fl-business-incomplete-reason',
},
errorMappings: {},
};
} as const satisfies ReportConfig;

export const tpReportFilter = (job: any) =>
Object.values(job.updates).some(
Expand Down
4 changes: 2 additions & 2 deletions src/tree.masterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const temporary = {
},
},
},
};
} as const;
export const tree: Record<string, any> = {
bookmarks: {
_type: 'application/vnd.oada.bookmarks.1+json',
Expand Down Expand Up @@ -151,6 +151,6 @@ export const tree: Record<string, any> = {
},
},
},
};
} as const;

export default tree;
2 changes: 1 addition & 1 deletion src/tree.mirrorWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ export const tree: Record<string, any> = {
},
},
},
};
} as const;

export default tree;
6 changes: 3 additions & 3 deletions src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const docsTree = {
'documents': {
'_type': 'application/vnd.oada.trellisfw.documents.1+json',
'*': {
// Cois, letters-of-guarantee, fsqa-audits, etc.
// COIs, letters-of-guarantee, fsqa-audits, etc.
'_type': 'application/vnd.oada.trellisfw.documents.1+json',
'*': {
// Individual docs here
Expand All @@ -43,7 +43,7 @@ const docsTree = {
},
},
},
};
} as const;
export const tree: Record<string, any> = {
bookmarks: {
_type: 'application/vnd.oada.bookmarks.1+json',
Expand Down Expand Up @@ -174,6 +174,6 @@ export const tree: Record<string, any> = {
shared: docsTree,
},
},
};
} as const;

export default tree;
Loading

0 comments on commit b1d4938

Please sign in to comment.