Skip to content

Commit

Permalink
HCK-9016: Update dependencies (#244)
Browse files Browse the repository at this point in the history
* HCK-8896: Move view script creation to the provider

* HCK-8896: Refactor functions

* HCK-8896: fix script

* HCK-8896: fix script

* HCK-9016: move require statement to the root scope of module

* HCK-9016: Update helpers

* HCK-9016: Update more files

* HCK-9016: Update more files

* HCK-9016: Update more files

* HCK-9016: Add lodash optimization to esbuild

* HCK-9016: update async dependency

* HCK-9016: resolve SQ warning & fix falling test
  • Loading branch information
Nightlngale authored Dec 9, 2024
1 parent e7b7711 commit 0ef7e40
Show file tree
Hide file tree
Showing 47 changed files with 741 additions and 677 deletions.
8 changes: 8 additions & 0 deletions esbuild.package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const esbuild = require('esbuild');
const { clean } = require('esbuild-plugin-clean');
const { copy } = require('esbuild-plugin-copy');
const { copyFolderFiles, addReleaseFlag } = require('@hackolade/hck-esbuild-plugins-pack');
const { EXCLUDED_EXTENSIONS, EXCLUDED_FILES, DEFAULT_RELEASE_FOLDER_PATH } = require('./buildConstants');

Expand All @@ -22,10 +23,17 @@ esbuild
outdir: RELEASE_FOLDER_PATH,
minify: true,
logLevel: 'info',
external: ['lodash'],
plugins: [
clean({
patterns: [DEFAULT_RELEASE_FOLDER_PATH],
}),
copy({
assets: {
from: [path.join('node_modules', 'lodash', '**', '*')],
to: [path.join('node_modules', 'lodash')],
},
}),
copyFolderFiles({
fromPath: __dirname,
targetFolderPath: RELEASE_FOLDER_PATH,
Expand Down
2 changes: 1 addition & 1 deletion forward_engineering/alterScript/alterScriptBuilder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash');
const { getAlterScriptDtos, joinAlterScriptDtosIntoAlterScript } = require('./alterScriptFromDeltaHelper');
const { AlterScriptDto } = require('./types/AlterScriptDto');
const { CoreData, App } = require('../types/coreApplicationTypes');
Expand Down Expand Up @@ -64,7 +65,6 @@ const doesEntityLevelAlterScriptContainDropStatements = (data, app) => entityLev
const getContainerLevelAlterScriptDtos =
(data, app) =>
({ internalDefinitions, externalDefinitions, modelDefinitions, entitiesJsonSchema }) => {
const _ = app.require('lodash');
const deltaModelSchema = _.first(Object.values(entitiesJsonSchema)) || {};
const definitions = [modelDefinitions, internalDefinitions, externalDefinitions];
return getAlterScriptDtos(deltaModelSchema, definitions, data, app);
Expand Down
32 changes: 16 additions & 16 deletions forward_engineering/alterScript/alterScriptFromDeltaHelper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash');
const {
getDeleteContainerScriptDto,
getModifyContainerScriptDtos,
Expand Down Expand Up @@ -60,7 +61,7 @@ const assertNoEmptyStatements = scripts => {
/**
* @return {Array<AlterScriptDto>}
* */
const getAlterContainersScriptDtos = ({ schema, isUnityCatalogSupports, provider, _, data }) => {
const getAlterContainersScriptDtos = ({ schema, isUnityCatalogSupports, provider, data }) => {
const dbVersion = data.modelData[0].dbVersion;
const addedScriptDtos = getItems(schema, 'containers', 'added')
.map(getAddContainerScriptDto(isUnityCatalogSupports, dbVersion))
Expand All @@ -69,7 +70,7 @@ const getAlterContainersScriptDtos = ({ schema, isUnityCatalogSupports, provider
.map(getDeleteContainerScriptDto(provider, dbVersion))
.filter(Boolean);
const modifiedScriptDtos = getItems(schema, 'containers', 'modified')
.flatMap(getModifyContainerScriptDtos(provider, _, isUnityCatalogSupports, dbVersion))
.flatMap(getModifyContainerScriptDtos(provider, isUnityCatalogSupports, dbVersion))
.filter(Boolean);

return [...deletedScriptDtos, ...addedScriptDtos, ...modifiedScriptDtos];
Expand Down Expand Up @@ -108,7 +109,7 @@ const filterOutExistingStatements = ({ alterScriptDtos, existingAlterStatements
/**
* @return Array<AlterScriptDto>
* */
const getAlterCollectionsScriptDtos = ({ schema, definitions, provider, data, _, app }) => {
const getAlterCollectionsScriptDtos = ({ schema, definitions, provider, data, app }) => {
const existingAlterStatements = new Set();
const getCollectionScripts = (items, compMode, getScript) =>
items.filter(item => item.compMod?.[compMode]).flatMap(getScript);
Expand Down Expand Up @@ -156,7 +157,7 @@ const getAlterCollectionsScriptDtos = ({ schema, definitions, provider, data, _,
let modifiedCollectionPrimaryKeysScriptDtos = [];
if (getDBVersionNumber(dbVersion) >= Runtime.RUNTIME_SUPPORTING_PK_FK_CONSTRAINTS) {
modifiedCollectionPrimaryKeysScriptDtos = getItems(schema, 'entities', 'modified').flatMap(item =>
getModifyPkConstraintsScripts(_, provider)({ collection: item, dbVersion }),
getModifyPkConstraintsScripts(provider)({ collection: item, dbVersion }),
);
}

Expand Down Expand Up @@ -210,7 +211,7 @@ const getAlterCollectionsScriptDtos = ({ schema, definitions, provider, data, _,
/**
* @return Array<AlterScriptDto>
* */
const getAlterViewsScriptDtos = (schema, provider, _, dbVersion) => {
const getAlterViewsScriptDtos = (schema, provider, dbVersion) => {
/**
* @return Array<AlterScriptDto>
* */
Expand All @@ -231,7 +232,7 @@ const getAlterViewsScriptDtos = (schema, provider, _, dbVersion) => {
const addedViewScriptDtos = getViewScripts(
getItems(schema, 'views', 'added'),
'created',
getAddViewsScripts(provider, _),
getAddViewsScripts(provider),
);
const deletedViewScriptDtos = getViewScripts(
getItems(schema, 'views', 'deleted'),
Expand All @@ -240,7 +241,7 @@ const getAlterViewsScriptDtos = (schema, provider, _, dbVersion) => {
);
const modifiedViewScriptDtos = getColumnScripts(
getItems(schema, 'views', 'modified'),
getModifyViewsScripts(provider, _, dbVersion),
getModifyViewsScripts(provider, dbVersion),
);

return [...deletedViewScriptDtos, ...addedViewScriptDtos, ...modifiedViewScriptDtos];
Expand All @@ -249,7 +250,7 @@ const getAlterViewsScriptDtos = (schema, provider, _, dbVersion) => {
/**
* @return Array<AlterScriptDto>
* */
const getAlterRelationshipsScriptDtos = ({ schema, ddlProvider, _ }) => {
const getAlterRelationshipsScriptDtos = ({ schema, ddlProvider }) => {
const deletedRelationships = getItems(schema, 'relationships', 'deleted').filter(
relationship => relationship.role?.compMod?.deleted,
);
Expand All @@ -258,9 +259,9 @@ const getAlterRelationshipsScriptDtos = ({ schema, ddlProvider, _ }) => {
);
const modifiedRelationships = getItems(schema, 'relationships', 'modified');

const deleteFkScripts = getDeleteForeignKeyScripts(ddlProvider, _)(deletedRelationships);
const addFkScripts = getAddForeignKeyScripts(ddlProvider, _)(addedRelationships);
const modifiedFkScripts = getModifyForeignKeyScripts(ddlProvider, _)(modifiedRelationships);
const deleteFkScripts = getDeleteForeignKeyScripts(ddlProvider)(deletedRelationships);
const addFkScripts = getAddForeignKeyScripts(ddlProvider)(addedRelationships);
const modifiedFkScripts = getModifyForeignKeyScripts(ddlProvider)(modifiedRelationships);

return [...deleteFkScripts, ...addFkScripts, ...modifiedFkScripts];
};
Expand Down Expand Up @@ -300,15 +301,14 @@ const getAlterStatementsWithCommentedUnwantedDDL = (scriptDtos, data) => {
* */
const getAlterScriptDtos = (schema, definitions, data, app) => {
const provider = require('../ddlProvider/ddlProvider')(app);
const _ = app.require('lodash');
const dbVersion = data.modelData[0].dbVersion;
const isUnityCatalogSupports = isSupportUnityCatalog(dbVersion);
const containersScriptDtos = getAlterContainersScriptDtos({ schema, isUnityCatalogSupports, provider, _, data });
const collectionsScriptDtos = getAlterCollectionsScriptDtos({ schema, definitions, provider, data, _, app });
const viewsScriptDtos = getAlterViewsScriptDtos(schema, provider, _, dbVersion);
const containersScriptDtos = getAlterContainersScriptDtos({ schema, isUnityCatalogSupports, provider, data });
const collectionsScriptDtos = getAlterCollectionsScriptDtos({ schema, definitions, provider, data, app });
const viewsScriptDtos = getAlterViewsScriptDtos(schema, provider, dbVersion);
let relationshipsScriptDtos = [];
if (isUnityCatalogSupports) {
relationshipsScriptDtos = getAlterRelationshipsScriptDtos({ schema, ddlProvider: provider, _ });
relationshipsScriptDtos = getAlterRelationshipsScriptDtos({ schema, ddlProvider: provider });
}

return [...containersScriptDtos, ...collectionsScriptDtos, ...viewsScriptDtos, ...relationshipsScriptDtos];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash');
const { getDatabaseStatement, getDatabaseAlterStatement, getBucketKeyword } = require('../../helpers/databaseHelper');
const {
getEntityData,
Expand Down Expand Up @@ -82,11 +83,11 @@ const extractNamesFromCompMod = compMod => {
/**
* @return {(container: Object) => Array<AlterScriptDto>}
* */
const getModifyContainerScriptDtos = (provider, _, isUnityCatalogSupports, dbVersion) => container => {
const getModifyContainerScriptDtos = (provider, isUnityCatalogSupports, dbVersion) => container => {
const compMod = _.get(container, 'role.compMod', {});
const names = extractNamesFromCompMod(compMod);

const didPropertiesChange = getIsChangeProperties(_)({ ...compMod, name: names }, otherContainerProperties);
const didPropertiesChange = getIsChangeProperties({ ...compMod, name: names }, otherContainerProperties);
const containerData = { ...getContainerData(compMod), name: names.new };
const catalogName = isSupportUnityCatalog(dbVersion) ? prepareName(compMod?.catalogName?.new) : undefined;
const databaseName = getDatabaseName({ role: { ...containerData, name: names.old } });
Expand Down
Loading

0 comments on commit 0ef7e40

Please sign in to comment.