@finos/legend-application-repl 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/Const.d.ts +25 -0
  4. package/lib/Const.d.ts.map +1 -0
  5. package/lib/Const.js +26 -0
  6. package/lib/Const.js.map +1 -0
  7. package/lib/application/LegendREPLGridClient.d.ts +27 -0
  8. package/lib/application/LegendREPLGridClient.d.ts.map +1 -0
  9. package/lib/application/LegendREPLGridClient.js +40 -0
  10. package/lib/application/LegendREPLGridClient.js.map +1 -0
  11. package/lib/application/LegendREPLGridClientApplicationConfig.d.ts +29 -0
  12. package/lib/application/LegendREPLGridClientApplicationConfig.d.ts.map +1 -0
  13. package/lib/application/LegendREPLGridClientApplicationConfig.js +33 -0
  14. package/lib/application/LegendREPLGridClientApplicationConfig.js.map +1 -0
  15. package/lib/application/LegendREPLGridClientPluginManager.d.ts +32 -0
  16. package/lib/application/LegendREPLGridClientPluginManager.d.ts.map +1 -0
  17. package/lib/application/LegendREPLGridClientPluginManager.js +46 -0
  18. package/lib/application/LegendREPLGridClientPluginManager.js.map +1 -0
  19. package/lib/components/AgGrid.d.ts +22 -0
  20. package/lib/components/AgGrid.d.ts.map +1 -0
  21. package/lib/components/AgGrid.js +43 -0
  22. package/lib/components/AgGrid.js.map +1 -0
  23. package/lib/components/Core_LegendREPLGridClientApplicationPlugin.d.ts +23 -0
  24. package/lib/components/Core_LegendREPLGridClientApplicationPlugin.d.ts.map +1 -0
  25. package/lib/components/Core_LegendREPLGridClientApplicationPlugin.js +35 -0
  26. package/lib/components/Core_LegendREPLGridClientApplicationPlugin.js.map +1 -0
  27. package/lib/components/LegendREPLGridClientApplication.d.ts +24 -0
  28. package/lib/components/LegendREPLGridClientApplication.d.ts.map +1 -0
  29. package/lib/components/LegendREPLGridClientApplication.js +32 -0
  30. package/lib/components/LegendREPLGridClientApplication.js.map +1 -0
  31. package/lib/components/LegendREPLGridClientFrameworkProvider.d.ts +22 -0
  32. package/lib/components/LegendREPLGridClientFrameworkProvider.d.ts.map +1 -0
  33. package/lib/components/LegendREPLGridClientFrameworkProvider.js +29 -0
  34. package/lib/components/LegendREPLGridClientFrameworkProvider.js.map +1 -0
  35. package/lib/components/REPLGridClient.d.ts +18 -0
  36. package/lib/components/REPLGridClient.d.ts.map +1 -0
  37. package/lib/components/REPLGridClient.js +56 -0
  38. package/lib/components/REPLGridClient.js.map +1 -0
  39. package/lib/components/REPLGridClientStoreProvider.d.ts +22 -0
  40. package/lib/components/REPLGridClientStoreProvider.d.ts.map +1 -0
  41. package/lib/components/REPLGridClientStoreProvider.js +32 -0
  42. package/lib/components/REPLGridClientStoreProvider.js.map +1 -0
  43. package/lib/components/grid/GridUtils.d.ts +29 -0
  44. package/lib/components/grid/GridUtils.d.ts.map +1 -0
  45. package/lib/components/grid/GridUtils.js +152 -0
  46. package/lib/components/grid/GridUtils.js.map +1 -0
  47. package/lib/components/grid/REPLGridServerResult.d.ts +22 -0
  48. package/lib/components/grid/REPLGridServerResult.d.ts.map +1 -0
  49. package/lib/components/grid/REPLGridServerResult.js +26 -0
  50. package/lib/components/grid/REPLGridServerResult.js.map +1 -0
  51. package/lib/components/grid/ServerSideDataSource.d.ts +32 -0
  52. package/lib/components/grid/ServerSideDataSource.d.ts.map +1 -0
  53. package/lib/components/grid/ServerSideDataSource.js +107 -0
  54. package/lib/components/grid/ServerSideDataSource.js.map +1 -0
  55. package/lib/components/grid/TDSLambdaBuilder.d.ts +19 -0
  56. package/lib/components/grid/TDSLambdaBuilder.d.ts.map +1 -0
  57. package/lib/components/grid/TDSLambdaBuilder.js +277 -0
  58. package/lib/components/grid/TDSLambdaBuilder.js.map +1 -0
  59. package/lib/components/grid/TDSRequest.d.ts +90 -0
  60. package/lib/components/grid/TDSRequest.d.ts.map +1 -0
  61. package/lib/components/grid/TDSRequest.js +120 -0
  62. package/lib/components/grid/TDSRequest.js.map +1 -0
  63. package/lib/grid.css +17 -0
  64. package/lib/grid.css.map +1 -0
  65. package/lib/index.css +17 -0
  66. package/lib/index.css.map +1 -0
  67. package/lib/index.d.ts +22 -0
  68. package/lib/index.d.ts.map +1 -0
  69. package/lib/index.js +37 -0
  70. package/lib/index.js.map +1 -0
  71. package/lib/package.json +88 -0
  72. package/lib/repl.css +17 -0
  73. package/lib/repl.css.map +1 -0
  74. package/lib/server/REPLServerClient.d.ts +28 -0
  75. package/lib/server/REPLServerClient.d.ts.map +1 -0
  76. package/lib/server/REPLServerClient.js +30 -0
  77. package/lib/server/REPLServerClient.js.map +1 -0
  78. package/lib/stores/LegendREPLGridClientApplicationPlugin.d.ts +26 -0
  79. package/lib/stores/LegendREPLGridClientApplicationPlugin.d.ts.map +1 -0
  80. package/lib/stores/LegendREPLGridClientApplicationPlugin.js +27 -0
  81. package/lib/stores/LegendREPLGridClientApplicationPlugin.js.map +1 -0
  82. package/lib/stores/LegendREPLGridClientBaseStore.d.ts +25 -0
  83. package/lib/stores/LegendREPLGridClientBaseStore.d.ts.map +1 -0
  84. package/lib/stores/LegendREPLGridClientBaseStore.js +24 -0
  85. package/lib/stores/LegendREPLGridClientBaseStore.js.map +1 -0
  86. package/lib/stores/REPLGridClientStore.d.ts +31 -0
  87. package/lib/stores/REPLGridClientStore.d.ts.map +1 -0
  88. package/lib/stores/REPLGridClientStore.js +101 -0
  89. package/lib/stores/REPLGridClientStore.js.map +1 -0
  90. package/lib/stores/REPLGridState.d.ts +38 -0
  91. package/lib/stores/REPLGridState.d.ts.map +1 -0
  92. package/lib/stores/REPLGridState.js +81 -0
  93. package/lib/stores/REPLGridState.js.map +1 -0
  94. package/package.json +88 -0
  95. package/src/Const.ts +27 -0
  96. package/src/application/LegendREPLGridClient.tsx +66 -0
  97. package/src/application/LegendREPLGridClientApplicationConfig.ts +64 -0
  98. package/src/application/LegendREPLGridClientPluginManager.ts +67 -0
  99. package/src/components/AgGrid.tsx +65 -0
  100. package/src/components/Core_LegendREPLGridClientApplicationPlugin.tsx +42 -0
  101. package/src/components/LegendREPLGridClientApplication.tsx +61 -0
  102. package/src/components/LegendREPLGridClientFrameworkProvider.tsx +63 -0
  103. package/src/components/REPLGridClient.tsx +157 -0
  104. package/src/components/REPLGridClientStoreProvider.tsx +61 -0
  105. package/src/components/grid/GridUtils.ts +190 -0
  106. package/src/components/grid/REPLGridServerResult.ts +30 -0
  107. package/src/components/grid/ServerSideDataSource.ts +184 -0
  108. package/src/components/grid/TDSLambdaBuilder.ts +413 -0
  109. package/src/components/grid/TDSRequest.ts +153 -0
  110. package/src/index.tsx +40 -0
  111. package/src/server/REPLServerClient.ts +74 -0
  112. package/src/stores/LegendREPLGridClientApplicationPlugin.ts +30 -0
  113. package/src/stores/LegendREPLGridClientBaseStore.ts +34 -0
  114. package/src/stores/REPLGridClientStore.ts +153 -0
  115. package/src/stores/REPLGridState.ts +102 -0
  116. package/tsconfig.json +66 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { guaranteeNonNullable } from '@finos/legend-shared';
17
+ import { getAggregationTDSColumnCustomizations, getTDSRowData, } from '../components/grid/GridUtils.js';
18
+ import { action, computed, makeObservable, observable } from 'mobx';
19
+ export class REPLGridState {
20
+ initialResult;
21
+ currentResult;
22
+ columns;
23
+ currentQuery;
24
+ currentSubQuery;
25
+ licenseKey;
26
+ initialQueryLambda;
27
+ constructor() {
28
+ makeObservable(this, {
29
+ initialResult: observable,
30
+ initialQueryLambda: observable,
31
+ currentResult: observable,
32
+ currentQuery: observable,
33
+ currentSubQuery: observable,
34
+ licenseKey: observable,
35
+ columns: observable,
36
+ setInitialResult: action,
37
+ setCurrentQuery: action,
38
+ setCurrentSubQuery: action,
39
+ setColumns: action,
40
+ setInitialQueryLambda: action,
41
+ setCurrentResult: action,
42
+ setLicenseKey: action,
43
+ rowData: computed,
44
+ columnDefs: computed,
45
+ });
46
+ }
47
+ setInitialQueryLambda(val) {
48
+ this.initialQueryLambda = val;
49
+ }
50
+ setCurrentQuery(val) {
51
+ this.currentQuery = val;
52
+ }
53
+ setCurrentSubQuery(val) {
54
+ this.currentSubQuery = val;
55
+ }
56
+ setInitialResult(val) {
57
+ this.initialResult = val;
58
+ }
59
+ setCurrentResult(val) {
60
+ this.currentResult = val;
61
+ }
62
+ setColumns(val) {
63
+ this.columns = val;
64
+ }
65
+ setLicenseKey(val) {
66
+ this.licenseKey = val;
67
+ }
68
+ get rowData() {
69
+ return this.initialResult ? getTDSRowData(this.initialResult.result) : [];
70
+ }
71
+ get columnDefs() {
72
+ return this.columns
73
+ ? this.columns.map((c) => ({
74
+ field: c,
75
+ headerName: c,
76
+ ...getAggregationTDSColumnCustomizations(this.licenseKey ? true : false, guaranteeNonNullable(this.initialResult), c),
77
+ }))
78
+ : [];
79
+ }
80
+ }
81
+ //# sourceMappingURL=REPLGridState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"REPLGridState.js","sourceRoot":"","sources":["../../src/stores/REPLGridState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,qCAAqC,EACrC,aAAa,GAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIpE,MAAM,OAAO,aAAa;IACxB,aAAa,CAAkC;IAC/C,aAAa,CAAkC;IAC/C,OAAO,CAAwB;IAC/B,YAAY,CAAsB;IAClC,eAAe,CAAsB;IACrC,UAAU,CAAsB;IAChC,kBAAkB,CAAyB;IAE3C;QACE,cAAc,CAAC,IAAI,EAAE;YACnB,aAAa,EAAE,UAAU;YACzB,kBAAkB,EAAE,UAAU;YAC9B,aAAa,EAAE,UAAU;YACzB,YAAY,EAAE,UAAU;YACxB,eAAe,EAAE,UAAU;YAC3B,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,UAAU;YACnB,gBAAgB,EAAE,MAAM;YACxB,eAAe,EAAE,MAAM;YACvB,kBAAkB,EAAE,MAAM;YAC1B,UAAU,EAAE,MAAM;YAClB,qBAAqB,EAAE,MAAM;YAC7B,gBAAgB,EAAE,MAAM;YACxB,aAAa,EAAE,MAAM;YACrB,OAAO,EAAE,QAAQ;YACjB,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB,CAAC,GAA0B;QAC9C,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC;IAChC,CAAC;IAED,eAAe,CAAC,GAAuB;QACrC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC;IAC1B,CAAC;IAED,kBAAkB,CAAC,GAAuB;QACxC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,GAAmC;QAClD,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC;IAC3B,CAAC;IAED,gBAAgB,CAAC,GAAmC;QAClD,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC;IAC3B,CAAC;IAED,UAAU,CAAC,GAAa;QACtB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;IAED,aAAa,CAAC,GAAuB;QACnC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO;YACjB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvB,KAAK,EAAE,CAAC;gBACR,UAAU,EAAE,CAAC;gBACb,GAAG,qCAAqC,CACtC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9B,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,EACxC,CAAC,CACF;aACF,CAAC,CAAC;YACL,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@finos/legend-application-repl",
3
+ "version": "0.0.2",
4
+ "description": "Legend REPL Grid client application core",
5
+ "keywords": [
6
+ "legend",
7
+ "legend-application",
8
+ "legend-repl",
9
+ "repl"
10
+ ],
11
+ "homepage": "https://github.com/finos/legend-studio/tree/master/packages/legend-application-repl",
12
+ "bugs": {
13
+ "url": "https://github.com/finos/legend-studio/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/finos/legend-studio.git",
18
+ "directory": "packages/legend-application-repl"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "sideEffects": false,
22
+ "type": "module",
23
+ "exports": {
24
+ ".": "./lib/index.js",
25
+ "./lib/index.css": "./lib/index.css"
26
+ },
27
+ "module": "lib/index.js",
28
+ "types": "lib/index.d.ts",
29
+ "scripts": {
30
+ "build": "yarn clean && yarn build:sass && yarn build:ts",
31
+ "build:sass": "cross-env INIT_CWD=$INIT_CWD node ../../scripts/workflow/buildSass.js",
32
+ "build:ts": "tsc --project ./tsconfig.build.json",
33
+ "clean": "npm-run-all clean:cache clean:lib",
34
+ "clean:cache": "rimraf \"build\"",
35
+ "clean:lib": "rimraf \"lib\"",
36
+ "dev": "npm-run-all --parallel dev:sass dev:ts",
37
+ "dev:sass": "sass style:lib --watch --load-path=../../node_modules/@finos/legend-art/scss",
38
+ "dev:ts": "tsc --watch --preserveWatchOutput",
39
+ "lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location ./build/.eslintcache --report-unused-disable-directives --parser-options=project:\"./tsconfig.json\" \"./src/**/*.{js,ts,tsx}\"",
40
+ "publish:prepare": "node ../../scripts/release/preparePublishContent.js",
41
+ "publish:snapshot": "node ../../scripts/release/publishDevSnapshot.js",
42
+ "test": "jest",
43
+ "test:watch": "jest --watch"
44
+ },
45
+ "dependencies": {
46
+ "@ag-grid-community/client-side-row-model": "30.2.0",
47
+ "@ag-grid-community/core": "30.2.0",
48
+ "@ag-grid-community/react": "30.2.0",
49
+ "@ag-grid-community/styles": "30.2.0",
50
+ "@ag-grid-enterprise/core": "30.2.0",
51
+ "@ag-grid-enterprise/menu": "30.2.0",
52
+ "@ag-grid-enterprise/row-grouping": "30.2.0",
53
+ "@ag-grid-enterprise/server-side-row-model": "30.2.0",
54
+ "@finos/legend-application": "15.0.72",
55
+ "@finos/legend-graph": "31.9.5",
56
+ "@finos/legend-lego": "1.2.18",
57
+ "@finos/legend-shared": "10.0.33",
58
+ "@types/react": "18.2.31",
59
+ "@types/react-dom": "18.2.14",
60
+ "mobx": "6.10.2",
61
+ "mobx-react-lite": "4.0.5",
62
+ "monaco-editor": "0.44.0",
63
+ "react": "18.2.0",
64
+ "react-dnd": "16.0.1",
65
+ "react-dom": "18.2.0",
66
+ "serializr": "3.0.2"
67
+ },
68
+ "devDependencies": {
69
+ "@finos/legend-dev-utils": "2.1.3",
70
+ "@jest/globals": "29.7.0",
71
+ "cross-env": "7.0.3",
72
+ "eslint": "8.52.0",
73
+ "jest": "29.7.0",
74
+ "npm-run-all": "4.1.5",
75
+ "rimraf": "5.0.5",
76
+ "sass": "1.69.4",
77
+ "typescript": "5.2.2"
78
+ },
79
+ "peerDependencies": {
80
+ "react": "^18.0.0"
81
+ },
82
+ "publishConfig": {
83
+ "directory": "build/publishContent"
84
+ },
85
+ "extensions": {
86
+ "applicationREPLGridClientPlugin": "@finos/legend-application-repl-plugin-core"
87
+ }
88
+ }
package/src/Const.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export enum LEGEND_REPL_EVENT {
18
+ FETCH_TDS_FAILURE = 'repl.fetch-tds.failure',
19
+ BUILD_TDS_EQUEST_FAILURE = 'repl.build-tds-request.failure',
20
+ }
21
+
22
+ export const FILTER_FUNCTION_NAME = 'filter';
23
+ export const SORT_FUNCTION_NAME = 'sort';
24
+ export const GROUPBY_FUNCTION_NAME = 'groupBy';
25
+ export const NOT_FUNCTION_NAME = 'not';
26
+
27
+ export const DEFAULT_VARIABLE_NAME = 'x';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { createRoot } from 'react-dom/client';
18
+ import {
19
+ type LegendApplicationConfig,
20
+ type LegendApplicationConfigurationInput,
21
+ LegendApplication,
22
+ ApplicationStoreProvider,
23
+ Core_LegendApplicationPlugin,
24
+ getApplicationRootElement,
25
+ } from '@finos/legend-application';
26
+ import {
27
+ LegendREPLGridClientApplicationConfig,
28
+ type LegendREPLGridClientApplicationConfigData,
29
+ } from './LegendREPLGridClientApplicationConfig.js';
30
+ import { LegendREPLGridClientPluginManager } from './LegendREPLGridClientPluginManager.js';
31
+ import { LegendREPLGridClientWebApplication } from '../components/LegendREPLGridClientApplication.js';
32
+ import { Core_LegendREPLGridClientApplicationPlugin } from '../components/Core_LegendREPLGridClientApplicationPlugin.js';
33
+ import type { LegendREPLGridClientApplicationStore } from '../stores/LegendREPLGridClientBaseStore.js';
34
+
35
+ export class LegendREPLGridClient extends LegendApplication {
36
+ declare config: LegendREPLGridClientApplicationConfig;
37
+ declare pluginManager: LegendREPLGridClientPluginManager;
38
+
39
+ static create(): LegendREPLGridClient {
40
+ const application = new LegendREPLGridClient(
41
+ LegendREPLGridClientPluginManager.create(),
42
+ );
43
+ application.withBasePlugins([
44
+ new Core_LegendApplicationPlugin(),
45
+ new Core_LegendREPLGridClientApplicationPlugin(),
46
+ ]);
47
+ application.withBasePresets([]);
48
+ return application;
49
+ }
50
+
51
+ async configureApplication(
52
+ input: LegendApplicationConfigurationInput<LegendREPLGridClientApplicationConfigData>,
53
+ ): Promise<LegendApplicationConfig> {
54
+ return new LegendREPLGridClientApplicationConfig(input);
55
+ }
56
+
57
+ async loadApplication(
58
+ applicationStore: LegendREPLGridClientApplicationStore,
59
+ ): Promise<void> {
60
+ createRoot(getApplicationRootElement()).render(
61
+ <ApplicationStoreProvider store={applicationStore}>
62
+ <LegendREPLGridClientWebApplication baseUrl={this.baseAddress} />
63
+ </ApplicationStoreProvider>,
64
+ );
65
+ }
66
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ assertNonNullable,
19
+ guaranteeNonEmptyString,
20
+ } from '@finos/legend-shared';
21
+ import {
22
+ type LegendApplicationConfigurationData,
23
+ type LegendApplicationConfigurationInput,
24
+ LegendApplicationConfig,
25
+ } from '@finos/legend-application';
26
+
27
+ export interface LegendREPLGridClientApplicationConfigData
28
+ extends LegendApplicationConfigurationData {
29
+ repl: {
30
+ url: string;
31
+ // NOTE: configure this to `true` to ignore the URL specified in the config
32
+ // so we can serve this application staticly with backend
33
+ dynamic?: boolean;
34
+ };
35
+ }
36
+
37
+ export class LegendREPLGridClientApplicationConfig extends LegendApplicationConfig {
38
+ readonly replUrl: string;
39
+ readonly useDynamicREPLServer: boolean = false;
40
+
41
+ constructor(
42
+ input: LegendApplicationConfigurationInput<LegendREPLGridClientApplicationConfigData>,
43
+ ) {
44
+ super(input);
45
+
46
+ assertNonNullable(
47
+ input.configData.repl,
48
+ `Can't configure application: 'repl' field is missing`,
49
+ );
50
+ this.replUrl = LegendApplicationConfig.resolveAbsoluteUrl(
51
+ guaranteeNonEmptyString(
52
+ input.configData.repl.url,
53
+ `Can't configure application: 'repl.url' field is missing or empty`,
54
+ ),
55
+ );
56
+ if (input.configData.repl.dynamic !== undefined) {
57
+ this.useDynamicREPLServer = Boolean(input.configData.repl.dynamic);
58
+ }
59
+ }
60
+
61
+ override getDefaultApplicationStorageKey(): string {
62
+ return 'legend-repl';
63
+ }
64
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type {
18
+ GraphManagerPluginManager,
19
+ PureGraphManagerPlugin,
20
+ PureGraphPlugin,
21
+ PureProtocolProcessorPlugin,
22
+ } from '@finos/legend-graph';
23
+ import { LegendApplicationPluginManager } from '@finos/legend-application';
24
+ import type { LegendREPLGridClientApplicationPlugin } from '../stores/LegendREPLGridClientApplicationPlugin.js';
25
+
26
+ export class LegendREPLGridClientPluginManager
27
+ extends LegendApplicationPluginManager<LegendREPLGridClientApplicationPlugin>
28
+ implements GraphManagerPluginManager
29
+ {
30
+ private pureProtocolProcessorPlugins: PureProtocolProcessorPlugin[] = [];
31
+ private pureGraphManagerPlugins: PureGraphManagerPlugin[] = [];
32
+ private pureGraphPlugins: PureGraphPlugin[] = [];
33
+
34
+ private constructor() {
35
+ super();
36
+ }
37
+
38
+ static create(): LegendREPLGridClientPluginManager {
39
+ return new LegendREPLGridClientPluginManager();
40
+ }
41
+
42
+ registerPureProtocolProcessorPlugin(
43
+ plugin: PureProtocolProcessorPlugin,
44
+ ): void {
45
+ this.pureProtocolProcessorPlugins.push(plugin);
46
+ }
47
+
48
+ registerPureGraphManagerPlugin(plugin: PureGraphManagerPlugin): void {
49
+ this.pureGraphManagerPlugins.push(plugin);
50
+ }
51
+
52
+ registerPureGraphPlugin(plugin: PureGraphPlugin): void {
53
+ this.pureGraphPlugins.push(plugin);
54
+ }
55
+
56
+ getPureGraphManagerPlugins(): PureGraphManagerPlugin[] {
57
+ return [...this.pureGraphManagerPlugins];
58
+ }
59
+
60
+ getPureProtocolProcessorPlugins(): PureProtocolProcessorPlugin[] {
61
+ return [...this.pureProtocolProcessorPlugins];
62
+ }
63
+
64
+ getPureGraphPlugins(): PureGraphPlugin[] {
65
+ return [...this.pureGraphPlugins];
66
+ }
67
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ AgGridReact,
19
+ type AgGridReactProps,
20
+ type AgReactUiProps,
21
+ } from '@ag-grid-community/react';
22
+ import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
23
+ import { ModuleRegistry } from '@ag-grid-community/core';
24
+ import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
25
+ import { RowGroupingModule } from '@ag-grid-enterprise/row-grouping';
26
+ import { MenuModule } from '@ag-grid-enterprise/menu';
27
+ import { getDefaultColumnDefintions } from '../components/grid/GridUtils.js';
28
+ import { LicenseManager } from '@ag-grid-enterprise/core';
29
+
30
+ const communityModules = [ClientSideRowModelModule];
31
+ const enterpriseModules = [
32
+ ServerSideRowModelModule,
33
+ RowGroupingModule,
34
+ MenuModule,
35
+ ];
36
+ const allModules = communityModules.concat(enterpriseModules);
37
+
38
+ export function AgGridComponent<TData = unknown>(
39
+ props: (AgGridReactProps<TData> | AgReactUiProps<TData>) & {
40
+ licenseKey: string;
41
+ },
42
+ ): JSX.Element {
43
+ let isAgGridLicenseEnabled = false;
44
+ if (props.licenseKey) {
45
+ LicenseManager.setLicenseKey(JSON.stringify(props.licenseKey));
46
+ isAgGridLicenseEnabled = true;
47
+ }
48
+
49
+ return (
50
+ <AgGridReact
51
+ rowGroupPanelShow={isAgGridLicenseEnabled ? 'always' : 'never'}
52
+ suppressBrowserResizeObserver={true}
53
+ suppressScrollOnNewData={true}
54
+ alwaysMultiSort={true}
55
+ rowModelType={isAgGridLicenseEnabled ? 'serverSide' : 'clientSide'}
56
+ {...props}
57
+ defaultColDef={getDefaultColumnDefintions(isAgGridLicenseEnabled)}
58
+ modules={isAgGridLicenseEnabled ? allModules : communityModules}
59
+ />
60
+ );
61
+ }
62
+
63
+ export const configureAgGridComponent = (): void => {
64
+ ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule]);
65
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { LegendApplicationSetup } from '@finos/legend-application';
18
+ import packageJson from '../../package.json' assert { type: 'json' };
19
+ import { LegendREPLGridClientApplicationPlugin } from '../stores/LegendREPLGridClientApplicationPlugin.js';
20
+ import { configureAgGridComponent } from './AgGrid.js';
21
+ import {
22
+ configureCodeEditorComponent,
23
+ setupPureLanguageService,
24
+ } from '@finos/legend-lego/code-editor';
25
+
26
+ export class Core_LegendREPLGridClientApplicationPlugin extends LegendREPLGridClientApplicationPlugin {
27
+ static NAME = packageJson.extensions.applicationREPLGridClientPlugin;
28
+
29
+ constructor() {
30
+ super(Core_LegendREPLGridClientApplicationPlugin.NAME, packageJson.version);
31
+ }
32
+
33
+ override getExtraApplicationSetups(): LegendApplicationSetup[] {
34
+ return [
35
+ async (applicationStore) => {
36
+ configureAgGridComponent();
37
+ await configureCodeEditorComponent(applicationStore);
38
+ setupPureLanguageService();
39
+ },
40
+ ];
41
+ }
42
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ BrowserEnvironmentProvider,
19
+ Route,
20
+ Switch,
21
+ type TEMPORARY__ReactRouterComponentType,
22
+ } from '@finos/legend-application/browser';
23
+ import { Editor } from './REPLGridClient.js';
24
+ import { LegendREPLGridClientFrameworkProvider } from './LegendREPLGridClientFrameworkProvider.js';
25
+ import { observer } from 'mobx-react-lite';
26
+ import { withEditorStore } from './REPLGridClientStoreProvider.js';
27
+
28
+ export const LEGEND_REPL_GRID_CLIENT_ROUTE_PATTERN = Object.freeze({
29
+ GRID: `/grid`,
30
+ });
31
+
32
+ export const LegendREPLGridClientRouter = withEditorStore(
33
+ observer(() => (
34
+ <div className="app">
35
+ <Switch>
36
+ <Route
37
+ exact={true}
38
+ path={[LEGEND_REPL_GRID_CLIENT_ROUTE_PATTERN.GRID]}
39
+ component={
40
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
41
+ Editor as TEMPORARY__ReactRouterComponentType
42
+ }
43
+ />
44
+ </Switch>
45
+ </div>
46
+ )),
47
+ );
48
+
49
+ export const LegendREPLGridClientWebApplication: React.FC<{
50
+ baseUrl: string;
51
+ }> = (props) => {
52
+ const { baseUrl } = props;
53
+
54
+ return (
55
+ <BrowserEnvironmentProvider baseUrl={baseUrl}>
56
+ <LegendREPLGridClientFrameworkProvider>
57
+ <LegendREPLGridClientRouter />
58
+ </LegendREPLGridClientFrameworkProvider>
59
+ </BrowserEnvironmentProvider>
60
+ );
61
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { createContext } from 'react';
18
+ import { useLocalObservable } from 'mobx-react-lite';
19
+ import {
20
+ ApplicationFrameworkProvider,
21
+ useApplicationStore,
22
+ } from '@finos/legend-application';
23
+ import type { LegendREPLGridClientPluginManager } from '../application/LegendREPLGridClientPluginManager.js';
24
+ import type { LegendREPLGridClientApplicationConfig } from '../application/LegendREPLGridClientApplicationConfig.js';
25
+ import {
26
+ type LegendREPLGridClientApplicationStore,
27
+ LegendREPLGridClientBaseStore,
28
+ } from '../stores/LegendREPLGridClientBaseStore.js';
29
+
30
+ export const useLegendREPLGridClientApplicationStore =
31
+ (): LegendREPLGridClientApplicationStore =>
32
+ useApplicationStore<
33
+ LegendREPLGridClientApplicationConfig,
34
+ LegendREPLGridClientPluginManager
35
+ >();
36
+
37
+ const LegendREPLGridClientBaseStoreContext = createContext<
38
+ LegendREPLGridClientBaseStore | undefined
39
+ >(undefined);
40
+
41
+ const LegendREPLGridClientBaseStoreProvider: React.FC<{
42
+ children: React.ReactNode;
43
+ }> = ({ children }) => {
44
+ const applicationStore = useLegendREPLGridClientApplicationStore();
45
+ const store = useLocalObservable(
46
+ () => new LegendREPLGridClientBaseStore(applicationStore),
47
+ );
48
+ return (
49
+ <LegendREPLGridClientBaseStoreContext.Provider value={store}>
50
+ {children}
51
+ </LegendREPLGridClientBaseStoreContext.Provider>
52
+ );
53
+ };
54
+
55
+ export const LegendREPLGridClientFrameworkProvider: React.FC<{
56
+ children: React.ReactNode;
57
+ }> = ({ children }) => (
58
+ <ApplicationFrameworkProvider>
59
+ <LegendREPLGridClientBaseStoreProvider>
60
+ {children}
61
+ </LegendREPLGridClientBaseStoreProvider>
62
+ </ApplicationFrameworkProvider>
63
+ );