From c479508c98adfbb2354c149ad0ef09201f509103 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Thu, 9 Jan 2025 13:07:11 +0000 Subject: [PATCH 1/2] Use `.at(-1)` in preference of lodash `_.last` Change-type: patch --- src/sbvr-api/permissions.ts | 2 +- src/sbvr-api/sbvr-utils.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sbvr-api/permissions.ts b/src/sbvr-api/permissions.ts index 37f95192f..dea92be7b 100644 --- a/src/sbvr-api/permissions.ts +++ b/src/sbvr-api/permissions.ts @@ -1742,7 +1742,7 @@ export const addPermissions = async ( request: ODataRequest & { permissionType?: PermissionCheck }, ): Promise => { const { resourceName, odataQuery, odataBinds } = request; - const vocabulary = _.last(request.translateVersions)!; + const vocabulary = request.translateVersions.at(-1)!; let abstractSqlModel = sbvrUtils.getAbstractSqlModel(request); let { permissionType } = request; diff --git a/src/sbvr-api/sbvr-utils.ts b/src/sbvr-api/sbvr-utils.ts index 5eae6d644..bb42023ed 100644 --- a/src/sbvr-api/sbvr-utils.ts +++ b/src/sbvr-api/sbvr-utils.ts @@ -898,7 +898,7 @@ export const runRule = (() => { } let fetchingViolators = false; - const ruleAbs = _.last(abstractSqlModel.rules); + const ruleAbs = abstractSqlModel.rules.at(-1); if (ruleAbs == null) { throw new Error('Unable to generate rule'); } @@ -1181,7 +1181,7 @@ const getFinalAbstractSqlModel = ( 'translateVersions' | 'finalAbstractSqlModel' >, ): AbstractSQLCompiler.AbstractSqlModel => { - const finalModel = _.last(request.translateVersions)!; + const finalModel = request.translateVersions.at(-1)!; return (request.finalAbstractSqlModel ??= models[finalModel].abstractSql); }; @@ -1906,7 +1906,7 @@ const runPost = async ( if (rowsAffected === 0) { throw new PermissionError(); } - await validateModel(tx, _.last(request.translateVersions)!, request); + await validateModel(tx, request.translateVersions.at(-1)!, request); return insertId; }; @@ -1978,7 +1978,7 @@ const runPut = async ( ({ rowsAffected } = await runQuery(tx, request, undefined, true)); } if (rowsAffected > 0) { - await validateModel(tx, _.last(request.translateVersions)!, request); + await validateModel(tx, request.translateVersions.at(-1)!, request); } }; @@ -2008,7 +2008,7 @@ const runDelete = async ( ): Promise => { const { rowsAffected } = await runQuery(tx, request, undefined, true); if (rowsAffected > 0) { - await validateModel(tx, _.last(request.translateVersions)!, request); + await validateModel(tx, request.translateVersions.at(-1)!, request); } }; From cef68084a2670d797559c2fd4a36825be67b7729 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Thu, 9 Jan 2025 13:14:52 +0000 Subject: [PATCH 2/2] Use for-of loops in preference of lodash `_.forEach` Change-type: patch --- Gruntfile.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gruntfile.ts b/Gruntfile.ts index 74f3e1228..31368f659 100644 --- a/Gruntfile.ts +++ b/Gruntfile.ts @@ -13,7 +13,7 @@ const serverConfigs = { server: serverConfig, }; -_.forEach(serverConfigs, (config) => { +for (const config of Object.values(serverConfigs)) { config.optimization = { minimizer: [ new TerserPlugin({ @@ -32,7 +32,7 @@ _.forEach(serverConfigs, (config) => { }), ], }; -}); +} export = (grunt: typeof Grunt) => { grunt.initConfig({ @@ -96,8 +96,8 @@ export = (grunt: typeof Grunt) => { }, rename: (() => { - const renames: _.Dictionary<{ src: string; dest: string }> = {}; - _.forEach(serverConfigs, (_config, task) => { + const renames: Record = {}; + for (const task of Object.keys(serverConfigs)) { renames[task] = { src: 'out/pine.js', dest: `out/pine-${task}-<%= grunt.option('version') %>.js`, @@ -106,7 +106,7 @@ export = (grunt: typeof Grunt) => { src: 'out/pine.js.map', dest: `out/pine-${task}-<%= grunt.option('version') %>.js.map`, }; - }); + } return renames; })(),