Skip to content

Commit

Permalink
move core query-builder logic out to @finos/legend-query-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Sep 13, 2022
1 parent 80c5575 commit c938c51
Show file tree
Hide file tree
Showing 216 changed files with 805 additions and 348 deletions.
35 changes: 35 additions & 0 deletions .changeset/shiny-dryers-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
'@finos/babel-preset-legend-studio': patch
'@finos/eslint-plugin-legend-studio': patch
'@finos/legend-application': patch
'@finos/legend-application-query': patch
'@finos/legend-application-query-bootstrap': patch
'@finos/legend-application-query-deployment': patch
'@finos/legend-application-studio': patch
'@finos/legend-application-studio-bootstrap': patch
'@finos/legend-application-studio-deployment': patch
'@finos/legend-application-taxonomy': patch
'@finos/legend-application-taxonomy-bootstrap': patch
'@finos/legend-application-taxonomy-deployment': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-application-studio-management-toolkit': patch
'@finos/legend-extension-application-studio-query-builder': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-mastery': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-persistence-cloud': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-tracer-zipkin': patch
'@finos/legend-graph': patch
'@finos/legend-query-builder': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-storage': patch
'@finos/stylelint-config-legend-studio': patch
---
5 changes: 5 additions & 0 deletions .changeset/violet-doors-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-application-query': major
---

**BREAKING CHANGE:** Move core `query-builder` logic out to `@finos/legend-query-builder`.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@import '@finos/legend-art/lib/index.css';
@import '@finos/legend-application/lib/index.css';
@import '@finos/legend-query-builder/lib/index.css';
@import '@finos/legend-application-query/lib/index.css';
@import '@finos/legend-extension-dsl-data-space/lib/index.css';

Expand Down
4 changes: 1 addition & 3 deletions packages/legend-application-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@ag-grid-community/client-side-row-model": "28.1.1",
"@ag-grid-community/core": "28.1.1",
"@ag-grid-community/react": "28.1.1",
"@finos/legend-application": "workspace:*",
"@finos/legend-art": "workspace:*",
"@finos/legend-graph": "workspace:*",
"@finos/legend-query-builder": "workspace:*",
"@finos/legend-server-depot": "workspace:*",
"@finos/legend-shared": "workspace:*",
"@finos/legend-storage": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-mod
import { BrowserRouter } from 'react-router-dom';
import { LegendQueryApplication } from '../components/LegendQueryApplication.js';
import { LegendQueryPluginManager } from './LegendQueryPluginManager.js';
import { QueryBuilder_GraphManagerPreset } from '../graphManager/QueryBuilder_GraphManagerPreset.js';
import { getRootElement } from '@finos/legend-art';
import { CorePureGraphManagerPlugin } from '@finos/legend-graph';
import {
type LegendQueryApplicationConfigurationData,
LegendQueryApplicationConfig,
} from './LegendQueryApplicationConfig.js';
import { QueryBuilder_GraphManagerPreset } from '@finos/legend-query-builder';

export const setupLegendQueryUILibrary = async (): Promise<void> => {
// Register module extensions for `ag-grid`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
QueryExportState,
ServiceQueryCreatorStore,
} from '../stores/QueryEditorStore.js';
import { QueryBuilder } from './query-builder/QueryBuilder.js';
import {
type ApplicationStore,
useApplicationStore,
Expand All @@ -72,9 +71,12 @@ import {
} from '@finos/legend-graph';
import { flowResult } from 'mobx';
import { useLegendQueryApplicationStore } from './LegendQueryBaseStoreProvider.js';
import type { QueryBuilderState } from '../stores/query-builder/QueryBuilderState.js';
import type { LegendQueryApplicationConfig } from '../application/LegendQueryApplicationConfig.js';
import type { LegendQueryApplicationPlugin } from '../stores/LegendQueryApplicationPlugin.js';
import {
QueryBuilder,
type QueryBuilderState,
} from '@finos/legend-query-builder';

const QueryExportDialogContent = observer(
(props: { exportState: QueryExportState }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ import { TEST__getTestLegendQueryApplicationConfig } from '../stores/QueryEditor
import { LegendQueryPluginManager } from '../application/LegendQueryPluginManager.js';
import { ExistingQueryEditor } from './QueryEditor.js';
import { generateExistingQueryEditorRoute } from '../stores/LegendQueryRouter.js';
import { QUERY_BUILDER_TEST_ID } from './query-builder/QueryBuilder_TestID.js';
import type { Entity } from '@finos/legend-storage';
import { ExistingQueryEditorStore } from '../stores/QueryEditorStore.js';
import { LegendQueryBaseStoreProvider } from './LegendQueryBaseStoreProvider.js';
import type { LegendQueryApplicationStore } from '../stores/LegendQueryBaseStore.js';
import type { QueryBuilderState } from '../stores/query-builder/QueryBuilderState.js';
import {
type QueryBuilderState,
QUERY_BUILDER_TEST_ID,
} from '@finos/legend-query-builder';

export const TEST__LegendQueryBaseStoreProvider: React.FC<{
children: React.ReactNode;
Expand Down
15 changes: 0 additions & 15 deletions packages/legend-application-query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export * from './application/LegendQuery.js';
export * from './components/LegendQueryBaseStoreProvider.js';
export * from './stores/LegendQueryBaseStore.js';

export { QueryBuilder_PureProtocolProcessorPlugin } from './graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js';

export {
QueryEditorStoreContext,
useQueryEditorStore,
Expand All @@ -43,16 +41,3 @@ export {
} from './stores/LegendQueryBaseStore.js';
export { LEGEND_QUERY_APP_EVENT } from './LegendQueryAppEvent.js';
export { LegendQueryEventService } from './stores/LegendQueryEventService.js';

// query builder core
export { QUERY_BUILDER_TEST_ID } from './components/query-builder/QueryBuilder_TestID.js';
export { QueryBuilder } from './components/query-builder/QueryBuilder.js';
export { QueryBuilderState } from './stores/query-builder/QueryBuilderState.js';

export {
QueryBuilderClassSelector,
buildRuntimeValueOption,
getRuntimeOptionFormatter,
} from './components/query-builder/QueryBuilderSideBar.js';
export { ClassQueryBuilderState } from './stores/query-builder/workflows/ClassQueryBuilderState.js';
export { ServiceQueryBuilderState } from './stores/query-builder/workflows/ServiceQueryBuilderState.js';
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import { LegendApplicationPlugin } from '@finos/legend-application';
import type { Query } from '@finos/legend-graph';
import type { QueryBuilderState } from '@finos/legend-query-builder';
import type React from 'react';
import type { LegendQueryPluginManager } from '../application/LegendQueryPluginManager.js';
import type { QueryBuilderState } from './query-builder/QueryBuilderState.js';
import type { QueryEditorStore } from './QueryEditorStore.js';
import type { QuerySetupState, QuerySetupStore } from './QuerySetupStore.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ import {
type GraphBuilderReport,
GraphManagerTelemetry,
extractElementNameFromPath,
isSystemElement,
QuerySearchSpecification,
Mapping,
type Runtime,
} from '@finos/legend-graph';
import type { QueryBuilderState } from './query-builder/QueryBuilderState.js';
import {
generateExistingQueryEditorRoute,
generateMappingQueryCreatorRoute,
Expand All @@ -69,12 +67,13 @@ import { TAB_SIZE, APPLICATION_EVENT } from '@finos/legend-application';
import type { LegendQueryPluginManager } from '../application/LegendQueryPluginManager.js';
import { LegendQueryEventService } from './LegendQueryEventService.js';
import type { LegendQueryApplicationStore } from './LegendQueryBaseStore.js';
import { ClassQueryBuilderState } from './query-builder/workflows/ClassQueryBuilderState.js';
import { MappingQueryBuilderState } from './query-builder/workflows/MappingQueryBuilderState.js';
import {
type QueryBuilderState,
type ServiceExecutionContext,
ClassQueryBuilderState,
MappingQueryBuilderState,
ServiceQueryBuilderState,
} from './query-builder/workflows/ServiceQueryBuilderState.js';
} from '@finos/legend-query-builder';

const QUERY_BUILDER_SEARCH_TEXT_MIN_LENGTH = 3;
const QUERY_BUILDER_QUERY_LOAD_MAX_AMOUNT = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ import {
ProjectData,
} from '@finos/legend-server-depot';
import type { Entity } from '@finos/legend-storage';
import { getQueryBuilderGraphManagerExtension } from '../graphManager/protocol/pure/QueryBuilder_PureGraphManagerExtension.js';
import { LEGEND_QUERY_APP_EVENT } from '../LegendQueryAppEvent.js';
import type { ServiceExecutionAnalysisResult } from '../graphManager/action/analytics/ServiceExecutionAnalysis.js';
import type { MappingRuntimeCompatibilityAnalysisResult } from '../graphManager/action/analytics/MappingRuntimeCompatibilityAnalysis.js';
import { APPLICATION_EVENT, TAB_SIZE } from '@finos/legend-application';
import type { LegendQueryPluginManager } from '../application/LegendQueryPluginManager.js';
import type { LegendQueryApplicationStore } from './LegendQueryBaseStore.js';
import {
type MappingRuntimeCompatibilityAnalysisResult,
type ServiceExecutionAnalysisResult,
getQueryBuilderGraphManagerExtension,
} from '@finos/legend-query-builder';

export abstract class QuerySetupState {
setupStore: QuerySetupStore;
Expand Down
11 changes: 0 additions & 11 deletions packages/legend-application-query/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,5 @@
* limitations under the License.
*/

@forward 'deps';
@forward 'query-builder';
@forward 'query-builder-setup';
@forward 'query-builder-explorer';
@forward 'query-builder-filter';
@forward 'query-builder-post-filter';
@forward 'query-builder-projection';
@forward 'query-builder-graph-fetch-tree';
@forward 'query-setup';
@forward 'query-editor';
@forward 'query-builder-functions-explorer';
@forward 'query-builder-property-search-panel';
@forward 'service-query-plugin';
1 change: 1 addition & 0 deletions packages/legend-application-query/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{ "path": "../legend-storage/tsconfig.build.json" },
{ "path": "../legend-server-depot/tsconfig.build.json" },
{ "path": "../legend-application/tsconfig.build.json" },
{ "path": "../legend-query-builder/tsconfig.build.json" },
{ "path": "../legend-art/tsconfig.build.json" }
]
}
1 change: 1 addition & 0 deletions packages/legend-application-query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{ "path": "../legend-storage" },
{ "path": "../legend-server-depot" },
{ "path": "../legend-application" },
{ "path": "../legend-query-builder" },
{ "path": "../legend-art" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,39 @@
import { ApplicationStore } from './ApplicationStore.js';
import { createBrowserHistory } from 'history';
import { WebApplicationNavigator } from './WebApplicationNavigator.js';
import type { LegendApplicationConfig } from '../application/LegendApplicationConfig.js';
import type { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager.js';
import { LegendApplicationConfig } from '../application/LegendApplicationConfig.js';
import { LegendApplicationPluginManager } from '../application/LegendApplicationPluginManager.js';
import type { LegendApplicationPlugin } from './LegendApplicationPlugin.js';
import type {
GraphManagerPluginManager,
PureGraphManagerPlugin,
PureGraphPlugin,
PureProtocolProcessorPlugin,
} from '@finos/legend-graph';

export const TEST_DATA__applicationVersion = {
buildTime: '2001-01-01T00:00:00-0000',
version: 'test-version',
commitSHA: 'test-commit-id',
};

class TEST__LegendApplicationConfig extends LegendApplicationConfig {}

export const TEST__getGenericApplicationConfig = (
extraConfigData = {},
): LegendApplicationConfig => {
const config = new TEST__LegendApplicationConfig({
configData: {
env: 'TEST',
appName: 'TEST',
...extraConfigData,
},
versionData: TEST_DATA__applicationVersion,
baseUrl: '/query/',
});
return config;
};

export const TEST__getTestApplicationStore = <
T extends LegendApplicationConfig,
V extends LegendApplicationPlugin,
Expand All @@ -39,3 +62,46 @@ export const TEST__getTestApplicationStore = <
new WebApplicationNavigator(createBrowserHistory()),
pluginManager,
);

export class TEST__LegendApplicationPluginManager
extends LegendApplicationPluginManager<LegendApplicationPlugin>
implements GraphManagerPluginManager
{
private pureProtocolProcessorPlugins: PureProtocolProcessorPlugin[] = [];
private pureGraphManagerPlugins: PureGraphManagerPlugin[] = [];
private pureGraphPlugins: PureGraphPlugin[] = [];

private constructor() {
super();
}

static create(): TEST__LegendApplicationPluginManager {
return new TEST__LegendApplicationPluginManager();
}

registerPureProtocolProcessorPlugin(
plugin: PureProtocolProcessorPlugin,
): void {
this.pureProtocolProcessorPlugins.push(plugin);
}

registerPureGraphManagerPlugin(plugin: PureGraphManagerPlugin): void {
this.pureGraphManagerPlugins.push(plugin);
}

registerPureGraphPlugin(plugin: PureGraphPlugin): void {
this.pureGraphPlugins.push(plugin);
}

getPureGraphManagerPlugins(): PureGraphManagerPlugin[] {
return [...this.pureGraphManagerPlugins];
}

getPureProtocolProcessorPlugins(): PureProtocolProcessorPlugin[] {
return [...this.pureProtocolProcessorPlugins];
}

getPureGraphPlugins(): PureGraphPlugin[] {
return [...this.pureGraphPlugins];
}
}
3 changes: 2 additions & 1 deletion packages/legend-dev-utils/jest/setupTestEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ import { jest } from '@jest/globals';
// Increase timeout for some long running tests
jest.setTimeout(10000);
// Runs failed tests n-times until they pass or until the max number of retries is exhausted.
jest.retryTimes(2);
// jest.retryTimes(2);
jest.retryTimes(0);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import packageJson from '../package.json';
import { AbstractPreset } from '@finos/legend-shared';
import { QueryBuilder_LegendStudioApplicationPlugin } from './components/QueryBuilder_LegendStudioApplicationPlugin.js';
import { QueryBuilder_PureProtocolProcessorPlugin } from '@finos/legend-application-query';
import { QueryBuilder_PureProtocolProcessorPlugin } from '@finos/legend-query-builder';

export class QueryBuilder_LegendStudioApplicationPreset extends AbstractPreset {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import {
QueryBuilder,
type QueryBuilderState,
} from '@finos/legend-application-query';
} from '@finos/legend-query-builder';
import { QUERY_BUILDER_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../stores/QueryBuilder_LegendStudioApplicationNavigationContext.js';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
import {
QueryBuilderClassSelector,
type QueryBuilderState,
} from '@finos/legend-application-query';
} from '@finos/legend-query-builder';
import { MappingExecutionQueryBuilderState } from '../stores/MappingExecutionQueryBuilderState.js';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useApplicationStore } from '@finos/legend-application';
import { assertErrorThrown, hashObject } from '@finos/legend-shared';
import { PencilIcon } from '@finos/legend-art';
import { isStubbed_RawLambda } from '@finos/legend-graph';
import type { QueryBuilderState } from '@finos/legend-application-query';
import type { QueryBuilderState } from '@finos/legend-query-builder';
import { MappingExecutionQueryBuilderState } from '../stores/MappingExecutionQueryBuilderState.js';

export const MappingTestQueryBuilder = observer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ import {
Service,
} from '@finos/legend-graph';
import { QueryBuilder_EditorExtensionState } from '../stores/QueryBuilder_EditorExtensionState.js';
import {
type QueryBuilderState,
setupLegendQueryUILibrary,
ClassQueryBuilderState,
} from '@finos/legend-application-query';
import { setupLegendQueryUILibrary } from '@finos/legend-application-query';
import { assertErrorThrown, guaranteeNonNullable } from '@finos/legend-shared';
import { useState } from 'react';
import { observer } from 'mobx-react-lite';
import type { LegendApplicationSetup } from '@finos/legend-application';
import { QUERY_BUILDER_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../stores/QueryBuilder_LegendStudioApplicationNavigationContext.js';
import {
ClassQueryBuilderState,
QueryBuilderState,
} from '@finos/legend-query-builder';

const promoteQueryToService = async (
packagePath: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
import {
type QueryBuilderState,
ServiceQueryBuilderState,
} from '@finos/legend-application-query';
} from '@finos/legend-query-builder';

export const ServiceQueryBuilder = observer(
(props: {
Expand Down

0 comments on commit c938c51

Please sign in to comment.