@genesislcap/blank-app-seed 3.16.1 → 3.17.1

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 (137) hide show
  1. package/.genx/.genxrc.js +1 -1
  2. package/.genx/.prettierrc +5 -0
  3. package/.genx/configure.js +19 -10
  4. package/.genx/details.js +1 -1
  5. package/.genx/eslint.config.mjs +20 -0
  6. package/.genx/package-lock.json +1173 -0
  7. package/.genx/package.json +14 -1
  8. package/.genx/prompts/api.js +12 -20
  9. package/.genx/prompts/server.js +55 -54
  10. package/.genx/prompts/ui.js +40 -13
  11. package/.genx/prompts/validators.js +16 -6
  12. package/.genx/prompts.js +11 -4
  13. package/.genx/scripts/update-versions.js +9 -4
  14. package/.genx/static.js +96 -0
  15. package/.genx/templates/angular/route.hbs +14 -0
  16. package/.genx/templates/angular/route.styles.hbs +3 -0
  17. package/.genx/templates/angular/route.template.hbs +8 -0
  18. package/.genx/utils/excludeFrameworks.js +29 -0
  19. package/.genx/utils/formatJSONValue.js +9 -0
  20. package/.genx/utils/formatRouteData.js +36 -0
  21. package/.genx/utils/generateCsv.js +13 -0
  22. package/.genx/utils/generateRoute.js +64 -0
  23. package/.genx/utils/getCombinedCsvData.js +72 -0
  24. package/.genx/utils/getLayoutType.js +10 -0
  25. package/.genx/utils/gridColumnsSerializer.js +17 -0
  26. package/.genx/utils/gridOptionsSerializer.js +33 -0
  27. package/.genx/utils/index.js +25 -0
  28. package/.genx/utils/makeDirectory.js +9 -0
  29. package/.genx/utils/normalizeFrameworkAlias.js +5 -0
  30. package/.genx/utils/parseJSONArgument.js +13 -0
  31. package/.genx/utils/registerPartials.js +25 -0
  32. package/.genx/utils/validateFrameworkAlias.js +8 -0
  33. package/.genx/utils/validateRoute.js +8 -0
  34. package/.genx/versions.json +2 -2
  35. package/CHANGELOG.md +14 -0
  36. package/client-tmp/angular/README.md +27 -0
  37. package/client-tmp/angular/angular.json +136 -0
  38. package/client-tmp/angular/globals.d.ts +6 -0
  39. package/client-tmp/angular/package.json +51 -0
  40. package/client-tmp/angular/src/app/app.component.css +0 -0
  41. package/client-tmp/angular/src/app/app.component.html +3 -0
  42. package/client-tmp/angular/src/app/app.component.spec.ts +29 -0
  43. package/client-tmp/angular/src/app/app.component.ts +26 -0
  44. package/client-tmp/angular/src/app/app.config.ts +7 -0
  45. package/client-tmp/angular/src/app/app.routes.ts +28 -0
  46. package/client-tmp/angular/src/app/guards/auth.guard.ts +25 -0
  47. package/client-tmp/angular/src/app/pages/auth-login/auth-login.component.css +4 -0
  48. package/client-tmp/angular/src/app/pages/auth-login/auth-login.component.html +1 -0
  49. package/client-tmp/angular/src/app/pages/auth-login/auth-login.component.spec.ts +22 -0
  50. package/client-tmp/angular/src/app/pages/auth-login/auth-login.component.ts +12 -0
  51. package/client-tmp/angular/src/app/pages/home/home.component.css +3 -0
  52. package/client-tmp/angular/src/app/pages/home/home.component.html +1 -0
  53. package/client-tmp/angular/src/app/pages/home/home.component.ts +16 -0
  54. package/client-tmp/angular/src/app/services/auth.service.ts +14 -0
  55. package/client-tmp/angular/src/app/share/foundation-auth.ts +21 -0
  56. package/client-tmp/angular/src/app/share/foundation-login.ts +37 -0
  57. package/client-tmp/angular/src/app/share/genesis-components.ts +15 -0
  58. package/client-tmp/angular/src/assets/.gitkeep +0 -0
  59. package/client-tmp/angular/src/environments/environment.prod.ts +5 -0
  60. package/client-tmp/angular/src/environments/environment.ts +6 -0
  61. package/client-tmp/angular/src/index.html +13 -0
  62. package/client-tmp/angular/src/main.ts +6 -0
  63. package/client-tmp/angular/src/styles.css +13 -0
  64. package/client-tmp/angular/tsconfig.app.json +15 -0
  65. package/client-tmp/angular/tsconfig.json +33 -0
  66. package/client-tmp/angular/tsconfig.spec.json +14 -0
  67. package/client-tmp/angular/webpack.dev.config.js +14 -0
  68. package/client-tmp/angular/webpack.prod.config.js +14 -0
  69. package/client-tmp/angular/webpack.shared.config.js +42 -0
  70. package/client-tmp/react/react-file.ts +1 -0
  71. package/client-tmp/web-components/public/favicon.ico +0 -0
  72. package/package.json +1 -1
  73. package/.genx/utils.js +0 -212
  74. /package/.genx/templates/{route.hbs → web-components/route.hbs} +0 -0
  75. /package/.genx/templates/{route.styles.hbs → web-components/route.styles.hbs} +0 -0
  76. /package/.genx/templates/{route.template.hbs → web-components/route.template.hbs} +0 -0
  77. /package/{client/public → client-tmp/angular/src}/favicon.ico +0 -0
  78. /package/{client → client-tmp/web-components}/.editorconfig +0 -0
  79. /package/{client → client-tmp/web-components}/.prettierignore +0 -0
  80. /package/{client → client-tmp/web-components}/Dockerfile +0 -0
  81. /package/{client → client-tmp/web-components}/README.md +0 -0
  82. /package/{client → client-tmp/web-components}/build.gradle.kts +0 -0
  83. /package/{client → client-tmp/web-components}/docs/images/lsp_jetbrains_one.png +0 -0
  84. /package/{client → client-tmp/web-components}/docs/images/lsp_jetbrains_two.png +0 -0
  85. /package/{client → client-tmp/web-components}/docs/images/lsp_vscode_one.png +0 -0
  86. /package/{client → client-tmp/web-components}/docs/images/lsp_vscode_two.png +0 -0
  87. /package/{client → client-tmp/web-components}/index.html +0 -0
  88. /package/{client → client-tmp/web-components}/package.json +0 -0
  89. /package/{client → client-tmp/web-components}/playwright.config.ts +0 -0
  90. /package/{client → client-tmp/web-components}/public/initSSO.js +0 -0
  91. /package/{client → client-tmp/web-components}/settings.gradle.kts +0 -0
  92. /package/{client → client-tmp/web-components}/src/components/components.ts +0 -0
  93. /package/{client → client-tmp/web-components}/src/components/index.ts +0 -0
  94. /package/{client → client-tmp/web-components}/src/components/not-permitted-component/index.ts +0 -0
  95. /package/{client → client-tmp/web-components}/src/components/not-permitted-component/not-permitted-component.styles.ts +0 -0
  96. /package/{client → client-tmp/web-components}/src/components/not-permitted-component/not-permitted-component.template.ts +0 -0
  97. /package/{client → client-tmp/web-components}/src/components/not-permitted-component/not-permitted-component.ts +0 -0
  98. /package/{client → client-tmp/web-components}/src/index.federated.ts +0 -0
  99. /package/{client → client-tmp/web-components}/src/index.ts +0 -0
  100. /package/{client → client-tmp/web-components}/src/layouts/default.ts +0 -0
  101. /package/{client → client-tmp/web-components}/src/layouts/index.ts +0 -0
  102. /package/{client → client-tmp/web-components}/src/main/index.ts +0 -0
  103. /package/{client → client-tmp/web-components}/src/main/main.css +0 -0
  104. /package/{client → client-tmp/web-components}/src/main/main.styles.ts +0 -0
  105. /package/{client → client-tmp/web-components}/src/main/main.template.ts +0 -0
  106. /package/{client → client-tmp/web-components}/src/main/main.ts +0 -0
  107. /package/{client → client-tmp/web-components}/src/pbc/README.md +0 -0
  108. /package/{client → client-tmp/web-components}/src/routes/config.ts +0 -0
  109. /package/{client → client-tmp/web-components}/src/routes/index.ts +0 -0
  110. /package/{client → client-tmp/web-components}/src/routes/not-found/not-found.styles.ts +0 -0
  111. /package/{client → client-tmp/web-components}/src/routes/not-found/not-found.template.ts +0 -0
  112. /package/{client → client-tmp/web-components}/src/routes/not-found/not-found.ts +0 -0
  113. /package/{client → client-tmp/web-components}/src/routes/not-permitted/not-permitted.styles.ts +0 -0
  114. /package/{client → client-tmp/web-components}/src/routes/not-permitted/not-permitted.template.ts +0 -0
  115. /package/{client → client-tmp/web-components}/src/routes/not-permitted/not-permitted.ts +0 -0
  116. /package/{client → client-tmp/web-components}/src/routes/types.ts +0 -0
  117. /package/{client → client-tmp/web-components}/src/store/index.ts +0 -0
  118. /package/{client → client-tmp/web-components}/src/store/store.ts +0 -0
  119. /package/{client → client-tmp/web-components}/src/styles/design-tokens.json +0 -0
  120. /package/{client → client-tmp/web-components}/src/styles/index.ts +0 -0
  121. /package/{client → client-tmp/web-components}/src/styles/styles.ts +0 -0
  122. /package/{client → client-tmp/web-components}/src/styles/typography.ts +0 -0
  123. /package/{client → client-tmp/web-components}/src/types.ts +0 -0
  124. /package/{client → client-tmp/web-components}/src/typings.d.ts +0 -0
  125. /package/{client → client-tmp/web-components}/src/utils/fdc3.ts +0 -0
  126. /package/{client → client-tmp/web-components}/src/utils/formatters.ts +0 -0
  127. /package/{client → client-tmp/web-components}/src/utils/index.ts +0 -0
  128. /package/{client → client-tmp/web-components}/src/utils/logger.ts +0 -0
  129. /package/{client → client-tmp/web-components}/src/utils/permissions.ts +0 -0
  130. /package/{client → client-tmp/web-components}/test/README.md +0 -0
  131. /package/{client → client-tmp/web-components}/test/e2e/fixture.ts +0 -0
  132. /package/{client → client-tmp/web-components}/test/e2e/flows/001-protected.e2e.ts +0 -0
  133. /package/{client → client-tmp/web-components}/test/e2e/index.ts +0 -0
  134. /package/{client → client-tmp/web-components}/test/e2e/pages/index.ts +0 -0
  135. /package/{client → client-tmp/web-components}/test/e2e/pages/protected.ts +0 -0
  136. /package/{client → client-tmp/web-components}/test/unit/sample.test.ts +0 -0
  137. /package/{client → client-tmp/web-components}/tsconfig.json +0 -0
@@ -0,0 +1,3 @@
1
+ :host {
2
+ height: 100%;
3
+ }
@@ -0,0 +1,16 @@
1
+ import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+
4
+ @Component({
5
+ selector: 'app-protected',
6
+ standalone: true,
7
+ imports: [
8
+ CommonModule,
9
+ ],
10
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
11
+ templateUrl: './home.component.html',
12
+ styleUrls: ['./home.component.css'],
13
+ })
14
+ export class HomeComponent {
15
+
16
+ }
@@ -0,0 +1,14 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Auth } from '@genesislcap/foundation-comms';
3
+ import {DI} from "@microsoft/fast-foundation";
4
+
5
+ @Injectable({
6
+ providedIn: 'root',
7
+ })
8
+ export class AuthService {
9
+
10
+ async isUserAuthenticated(): Promise<boolean> {
11
+ const auth: Auth = DI.getOrCreateDOMContainer().get(Auth);
12
+ return auth.isLoggedIn
13
+ }
14
+ }
@@ -0,0 +1,21 @@
1
+ // import { configure } from '@genesislcap/foundation-auth/config';
2
+ import type { Router } from '@angular/router';
3
+ import { INTERNAL_URLS } from '../app.routes';
4
+
5
+ /**
6
+ * Configure the micro frontend
7
+ */
8
+ export const configureFoundationAuth = ({
9
+ router,
10
+ connectService,
11
+ }: {
12
+ router: Router;
13
+ connectService: any;
14
+ }) => null
15
+ // configure({
16
+ // omitRoutes: ['request-account'],
17
+ // postLoginRedirect: async () => {
18
+ // await connectService.init();
19
+ // router.navigate([`/${INTERNAL_URLS.homepage}`]);
20
+ // },
21
+ // });
@@ -0,0 +1,37 @@
1
+ import {configure, define} from '@genesislcap/foundation-login';
2
+ import type { Router } from '@angular/router';
3
+ import { INTERNAL_URLS } from '../app.routes';
4
+ import { DI } from '@microsoft/fast-foundation';
5
+
6
+ const ssoSettings =
7
+ typeof GENX_ENABLE_SSO !== 'undefined' && GENX_ENABLE_SSO === true
8
+ ? {
9
+ autoAuth: true,
10
+ sso: {
11
+ toggled: true,
12
+ identityProvidersPath: 'sso/list',
13
+ },
14
+ }
15
+ : {};
16
+
17
+ /**
18
+ * Configure the micro frontend
19
+ */
20
+ export const configureFoundationLogin = ({
21
+ router,
22
+ }: {
23
+ router: Router;
24
+ }) => {
25
+ configure(DI.getOrCreateDOMContainer(), {
26
+ showConnectionIndicator: true,
27
+ hostPath: INTERNAL_URLS.auth,
28
+ redirectHandler: () => {
29
+ router.navigate([INTERNAL_URLS.homepage])
30
+ },
31
+ ...ssoSettings,
32
+ });
33
+
34
+ return define({
35
+ name: `client-app-login`,
36
+ });
37
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ provideDesignSystem as provideZeroDesignSystem,
3
+ baseComponents as zeroBaseComponents,
4
+ } from '@genesislcap/foundation-zero';
5
+ import { zeroGridComponents } from '@genesislcap/foundation-zero-grid-pro';
6
+ import { g2plotChartsComponents } from '@genesislcap/g2plot-chart';
7
+ import { EntityManagement } from '@genesislcap/foundation-entity-management';
8
+
9
+ EntityManagement;
10
+
11
+ provideZeroDesignSystem().register(
12
+ zeroBaseComponents,
13
+ zeroGridComponents,
14
+ g2plotChartsComponents,
15
+ );
File without changes
@@ -0,0 +1,5 @@
1
+ export const environment = {
2
+ production: true,
3
+ PORT: 6060,
4
+ GENX_ENABLE_SSO: {{enableSSO}}
5
+ };
@@ -0,0 +1,6 @@
1
+ export const environment = {
2
+ production: false,
3
+ API_HOST: '{{apiHost}}',
4
+ PORT: 6060,
5
+ GENX_ENABLE_SSO: {{enableSSO}}
6
+ };
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{capitalCase appName}}</title>
6
+ <base href="/">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
9
+ </head>
10
+ <body>
11
+ <{{rootElement}}></{{rootElement}}>
12
+ </body>
13
+ </html>
@@ -0,0 +1,6 @@
1
+ import { bootstrapApplication } from '@angular/platform-browser';
2
+ import { appConfig } from './app/app.config';
3
+ import { AppComponent } from './app/app.component';
4
+
5
+ bootstrapApplication(AppComponent, appConfig)
6
+ .catch((err) => console.error(err));
@@ -0,0 +1,13 @@
1
+ html,
2
+ body {
3
+ width: 100%;
4
+ height: 100%;
5
+ padding: 0;
6
+ margin: 0;
7
+ }
8
+
9
+ zero-design-system-provider {
10
+ height: 100%;
11
+ display: flex;
12
+ flex-direction: column;
13
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "./out-tsc/app",
6
+ "types": []
7
+ },
8
+ "files": [
9
+ "src/main.ts"
10
+ ],
11
+ "include": [
12
+ "src/**/*.d.ts",
13
+ "globals.d.ts",
14
+ ]
15
+ }
@@ -0,0 +1,33 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "compileOnSave": false,
4
+ "compilerOptions": {
5
+ "outDir": "./dist/out-tsc",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "noImplicitOverride": true,
9
+ "noPropertyAccessFromIndexSignature": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "skipLibCheck": true,
13
+ "esModuleInterop": true,
14
+ "sourceMap": true,
15
+ "declaration": false,
16
+ "experimentalDecorators": true,
17
+ "moduleResolution": "node",
18
+ "importHelpers": true,
19
+ "target": "ES2022",
20
+ "module": "ES2022",
21
+ "useDefineForClassFields": false,
22
+ "lib": [
23
+ "ES2022",
24
+ "dom"
25
+ ]
26
+ },
27
+ "angularCompilerOptions": {
28
+ "enableI18nLegacyMessageIdFormat": false,
29
+ "strictInjectionParameters": true,
30
+ "strictInputAccessModifiers": true,
31
+ "strictTemplates": true
32
+ }
33
+ }
@@ -0,0 +1,14 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "./out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "include": [
11
+ "src/**/*.spec.ts",
12
+ "src/**/*.d.ts"
13
+ ]
14
+ }
@@ -0,0 +1,14 @@
1
+ const webpackSharedConfig = require('./webpack.shared.config');
2
+ const { DefinePlugin } = require('webpack');
3
+ const environment = require('./src/environments/environment.ts').environment;
4
+ const envKeys = Object.keys(environment).reduce((prev, next) => {
5
+ prev[next] = JSON.stringify(environment[next]);
6
+ return prev;
7
+ }, {});
8
+
9
+ module.exports = {
10
+ ...webpackSharedConfig,
11
+ plugins: [
12
+ new DefinePlugin(envKeys),
13
+ ],
14
+ };
@@ -0,0 +1,14 @@
1
+ const webpackSharedConfig = require('./webpack.shared.config');
2
+ const { DefinePlugin } = require('webpack');
3
+ const environment = require('./src/environments/environment.prod.ts').environment;
4
+ const envKeys = Object.keys(environment).reduce((prev, next) => {
5
+ prev[next] = JSON.stringify(environment[next]);
6
+ return prev;
7
+ }, {});
8
+
9
+ module.exports = {
10
+ ...webpackSharedConfig,
11
+ plugins: [
12
+ new DefinePlugin(envKeys),
13
+ ],
14
+ };
@@ -0,0 +1,42 @@
1
+ const path = require('path');
2
+
3
+ // Register ts-node to transpile environments TypeScript file
4
+ require('ts-node').register({
5
+ transpileOnly: true,
6
+ compilerOptions: {
7
+ module: 'commonjs'
8
+ }
9
+ });
10
+
11
+ module.exports = {
12
+ module: {
13
+ rules: [
14
+ {
15
+ test: /\.(png|jpe?g|gif)$/i,
16
+ use: [
17
+ {
18
+ loader: 'file-loader',
19
+ },
20
+ ],
21
+ },
22
+ {
23
+ test: /\.svg$/,
24
+ use: [
25
+ {
26
+ loader: 'svg-url-loader',
27
+ options: {},
28
+ },
29
+ ],
30
+ },
31
+ ],
32
+ },
33
+ resolve: {
34
+ alias: {
35
+ 'foundationZero/ZeroDesignSystem': path.resolve(
36
+ __dirname,
37
+ 'node_modules/@genesislcap/foundation-zero',
38
+ ),
39
+ },
40
+ },
41
+ };
42
+
@@ -0,0 +1 @@
1
+ // WIP
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/blank-app-seed",
3
3
  "description": "Genesis Blank App Seed",
4
- "version": "3.16.1",
4
+ "version": "3.17.1",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
7
7
  "release": "semantic-release"
package/.genx/utils.js DELETED
@@ -1,212 +0,0 @@
1
- const {existsSync, mkdirSync, readFileSync} = require('node:fs');
2
- const { resolve } = require('node:path');
3
-
4
- const makeDirectory = (directory) => {
5
- if (!existsSync(directory)) {
6
- mkdirSync(directory);
7
- }
8
- };
9
-
10
- const registerPartials = ({ registerPartial }) => {
11
- registerPartial('grid-layout', resolve(__dirname, 'templates/gridLayout.hbs'))
12
- registerPartial('tabs-layout', resolve(__dirname, 'templates/tabsLayout.hbs'))
13
- registerPartial('horizontal-layout', resolve(__dirname, 'templates/horizontalLayout.hbs'))
14
- registerPartial('smart-form', resolve(__dirname, 'templates/form.hbs'))
15
- registerPartial('chart', resolve(__dirname, 'templates/chart.hbs'))
16
- registerPartial('entity-manager', resolve(__dirname, 'templates/entityManager.hbs'))
17
- registerPartial('grid-pro', resolve(__dirname, 'templates/grid.hbs'))
18
- };
19
-
20
- const generateRoute = (route, { writeFileWithData, changeCase }) => {
21
- const routeName = changeCase.paramCase(route.name);
22
- makeDirectory(resolve(__dirname, `../client/src/routes/${routeName}`));
23
- writeFileWithData(resolve(__dirname, `../client/src/routes/${routeName}/${routeName}.ts`), {route}, resolve(__dirname, 'templates/route.hbs'));
24
- writeFileWithData(resolve(__dirname, `../client/src/routes/${routeName}/${routeName}.template.ts`), {route}, resolve(__dirname, 'templates/route.template.hbs'));
25
- writeFileWithData(resolve(__dirname, `../client/src/routes/${routeName}/${routeName}.styles.ts`), {route}, resolve(__dirname, 'templates/route.styles.hbs'));
26
- };
27
-
28
- const generateCsv = (entity, { writeFileWithData }) => {
29
- writeFileWithData(resolve(__dirname, `../server/{{appName}}-app/src/main/genesis/data/${entity.name}.csv`), {entity}, resolve(__dirname, 'templates/csv.hbs'));
30
- };
31
-
32
- const prepareCsvData = (entity) => {
33
- if (!entity.data?.length) return null;
34
-
35
- const data = entity.data.map((rows) => ({
36
- rows: rows?.map((x, index) => ({
37
- name: x,
38
- isLast: index === rows.length - 1,
39
- })),
40
- }));
41
-
42
- return data;
43
- };
44
-
45
- function csvToObject(csv) {
46
- const lines = csv
47
- .split('\n')
48
- .map((x) => x.replaceAll('"', ''))
49
- .filter((line) => line.trim() !== '');
50
- const fieldsRow = lines[0].split(',').map((field) => field.trim());
51
- const fields = fieldsRow.map((field, index) => ({
52
- name: field.toUpperCase(),
53
- isLast: index === fieldsRow.length - 1,
54
- }));
55
-
56
- const data = lines.slice(1).map((line) => {
57
- const rows = line.split(',').map((value, index) => ({
58
- name: value.trim(),
59
- isLast: index === fieldsRow.length - 1,
60
- }));
61
- return { rows };
62
- });
63
-
64
- return { fields, data };
65
- }
66
-
67
- const getCombinedCsvData = (entity) => {
68
- let csvFile;
69
- const combinedCsv = {
70
- name: entity.name.toUpperCase(),
71
- fields: entity.fields?.map((field, index) => ({
72
- name: field.toUpperCase(),
73
- isLast: index === entity.fields.length - 1,
74
- })),
75
- data: prepareCsvData(entity),
76
- };
77
-
78
- if (entity.mode?.toLowerCase() === 'append') {
79
- const path = resolve(
80
- __dirname,
81
- `../server/{{appName}}-app/src/main/genesis/data/${entity.name}.csv`
82
- );
83
-
84
- try {
85
- csvFile = readFileSync(path, 'utf8');
86
- } catch (err) {
87
- console.log('File to append not found - creating a new CSV file');
88
- }
89
-
90
- if (csvFile) {
91
- const existingCsv = csvToObject(csvFile);
92
- combinedCsv.fields = existingCsv.fields;
93
- combinedCsv.data = [...existingCsv.data, ...prepareCsvData(entity)];
94
- }
95
- }
96
-
97
- return combinedCsv;
98
- };
99
-
100
- const formatJSONValue = (value) => {
101
- try {
102
- return value ? JSON.stringify(value, null, 2) : undefined;
103
- } catch (e) {
104
- console.warn('Could not serialise value to JSON', value, e);
105
- }
106
- }
107
-
108
- const gridOptionsSerializer = (options, pad = ' ') => {
109
- if (!options) {
110
- return undefined;
111
- }
112
- try {
113
- let output = `{\n`;
114
- Object.keys(options).forEach((key) => {
115
- const value = options[key];
116
- if (key === 'columns') {
117
- output += `${pad}${'columnDefs'}: ${gridColumnsSerializer(value)},\n`;
118
- } else if (value?.type === 'function' || value?.type === 'valueFormatter') {
119
- const args = value.arguments?.map(JSON.stringify).join(', ');
120
- output += `${pad}${key}: ${value.name}(${args}),\n`;
121
- } else if (key === 'hide') {
122
- output += `${pad}${key}: ${value},\n`;
123
- } else {
124
- output += `${pad}${key}: ${formatJSONValue(value)},\n`;
125
- }
126
- });
127
- output += `${pad}}\n`;
128
- return output;
129
- } catch (e) {
130
- return undefined;
131
- }
132
- };
133
-
134
- const gridColumnsSerializer = (columns, pad = ' ') => {
135
- if (!columns) {
136
- return undefined;
137
- }
138
- try {
139
- const columnsSerialized = columns.map((column) => gridOptionsSerializer(column));
140
- return `[\n${pad}${columnsSerialized}]`;
141
- } catch (e) {
142
- return undefined;
143
- }
144
- }
145
-
146
- const validateRoute = (route) => {
147
- if (!route.name) {
148
- console.warn('Invalid route - missing name', route);
149
- }
150
- return !!route.name;
151
- }
152
-
153
- const getLayoutType = (route) => {
154
- if (route?.tiles?.length < 4) {
155
- return 'horizontal-layout'
156
- } else if (route?.tiles?.length === 4) {
157
- return 'grid-layout'
158
- }
159
- return 'tabs-layout'
160
- }
161
-
162
- const formatRouteData = (route) => {
163
- const layoutKey = route?.layoutKey || `${route.name}_${Date.now()}`;
164
- const layoutType = route?.layoutType || getLayoutType(route);
165
-
166
- const FDC3ClickCategory = 'fdc3';
167
- const FDC3EventHandlersEnabled = !!route.tiles?.find(t => t.config?.gridOptions?.onRowClicked?.category === FDC3ClickCategory);
168
-
169
- const tiles = route.tiles?.map(tile => ({
170
- ...tile,
171
- config: {
172
- ...(tile.config || {}),
173
- gridOptions: gridOptionsSerializer(tile.config?.gridOptions),
174
- createFormUiSchema: formatJSONValue(tile.config?.createFormUiSchema),
175
- updateFormUiSchema: formatJSONValue(tile.config?.updateFormUiSchema),
176
- uischema: formatJSONValue(tile.config?.uischema),
177
- columns: gridColumnsSerializer(tile.config?.columns)
178
- }
179
- }));
180
-
181
- return {
182
- ...route,
183
- layoutType,
184
- layoutKey,
185
- tiles,
186
- FDC3EventHandlersEnabled,
187
- }
188
- };
189
-
190
- const parseJSONArgument = (name, defaultValue) =>
191
- (value) => {
192
- if (!value){
193
- return defaultValue;
194
- }
195
- try {
196
- return JSON.parse(value);
197
- } catch (error) {
198
- console.error(`Error parsing "${name}" parameter as JSON:`, error.message);
199
- return defaultValue;
200
- }
201
- }
202
-
203
- module.exports = {
204
- makeDirectory,
205
- registerPartials,
206
- generateRoute,
207
- validateRoute,
208
- generateCsv,
209
- getCombinedCsvData,
210
- formatRouteData,
211
- parseJSONArgument,
212
- };
File without changes