rapida-partner 1.0.0

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 (107) hide show
  1. package/README.md +85 -0
  2. package/index.ts +13 -0
  3. package/package.json +27 -0
  4. package/rapidaObject.json +3024 -0
  5. package/src/constants/options/agendaStatus.ts +3 -0
  6. package/src/constants/options/citiesFromBrazil.ts +27852 -0
  7. package/src/constants/options/countriesFromEarth.ts +1761 -0
  8. package/src/constants/options/currencies.ts +142 -0
  9. package/src/constants/options/eventJobs.ts +94 -0
  10. package/src/constants/options/events.ts +22 -0
  11. package/src/constants/options/hours.ts +26 -0
  12. package/src/constants/options/languages.ts +34 -0
  13. package/src/constants/options/statesFromBrazil.ts +29 -0
  14. package/src/controllers/ts_project_to_json_project.ts +17 -0
  15. package/src/controllers/validate-project-json-schema.ts +11 -0
  16. package/src/examples/components/forms/character.form.ts +92 -0
  17. package/src/examples/components/forms/company.form.ts +648 -0
  18. package/src/examples/components/forms/movie.form.ts +205 -0
  19. package/src/examples/components/forms/movieGenre.form.ts +43 -0
  20. package/src/examples/components/forms/person.form.ts +474 -0
  21. package/src/examples/components/lists/character.list.ts +47 -0
  22. package/src/examples/components/lists/company.list.ts +49 -0
  23. package/src/examples/components/lists/movie.list.ts +60 -0
  24. package/src/examples/components/lists/movieGenre.list.ts +51 -0
  25. package/src/examples/components/lists/person.list.ts +50 -0
  26. package/src/examples/modules/character.ts +13 -0
  27. package/src/examples/modules/company.ts +13 -0
  28. package/src/examples/modules/movie.ts +17 -0
  29. package/src/examples/modules/person.ts +13 -0
  30. package/src/examples/projects/movieBackoffice.ts +110 -0
  31. package/src/interfaces/backend-framework-structure.interface.ts +44 -0
  32. package/src/interfaces/data-card.interface.ts +102 -0
  33. package/src/interfaces/data-chart.interface.ts +84 -0
  34. package/src/interfaces/data-detail.interface.ts +123 -0
  35. package/src/interfaces/data-grid.interface.ts +48 -0
  36. package/src/interfaces/data-table.interface.ts +84 -0
  37. package/src/interfaces/form-array.interface.ts +14 -0
  38. package/src/interfaces/form-autocomplete.interface.ts +79 -0
  39. package/src/interfaces/form-button.interface.ts +34 -0
  40. package/src/interfaces/form-condition.interface.ts +26 -0
  41. package/src/interfaces/form-datepicker.interface.ts +18 -0
  42. package/src/interfaces/form-fieldset.interface.ts +13 -0
  43. package/src/interfaces/form-file.interface.ts +57 -0
  44. package/src/interfaces/form-input.interface.ts +69 -0
  45. package/src/interfaces/form-numeric.interface.ts +22 -0
  46. package/src/interfaces/form-pattern.interface.ts +16 -0
  47. package/src/interfaces/form-radiogroup.interface.ts +21 -0
  48. package/src/interfaces/form-select.interface.ts +60 -0
  49. package/src/interfaces/form-switch.interface.ts +15 -0
  50. package/src/interfaces/form-tab.interface.ts +17 -0
  51. package/src/interfaces/form.interface.ts +73 -0
  52. package/src/interfaces/frontend-framework-structure.interface.ts +39 -0
  53. package/src/interfaces/layout-dashboard.interface.ts +52 -0
  54. package/src/interfaces/layout-panel.interface.ts +45 -0
  55. package/src/interfaces/list.interface.ts +50 -0
  56. package/src/interfaces/project-backend.interface.ts +48 -0
  57. package/src/interfaces/project-style.interface.ts +129 -0
  58. package/src/interfaces/project.interface.ts +79 -0
  59. package/src/interfaces/yaml-template-skeleton.interface.ts +35 -0
  60. package/src/schemas/backend-framework-structure.schema.json +194 -0
  61. package/src/schemas/backend.ref.json +77 -0
  62. package/src/schemas/bdd-and-e2e-narratives.ref.json +57 -0
  63. package/src/schemas/bdd-and-e2e.json +36 -0
  64. package/src/schemas/business-plan.ref.json +25 -0
  65. package/src/schemas/business-rules.ref.json +34 -0
  66. package/src/schemas/component-one-of.ref.json +15 -0
  67. package/src/schemas/dashboard.ref.json +111 -0
  68. package/src/schemas/data-card.ref.json +245 -0
  69. package/src/schemas/data-chart.ref.json +168 -0
  70. package/src/schemas/data-detail.ref.json +297 -0
  71. package/src/schemas/data-grid.ref.json +101 -0
  72. package/src/schemas/data-table.ref.json +181 -0
  73. package/src/schemas/external-application.ref.json +97 -0
  74. package/src/schemas/form-array.ref.json +35 -0
  75. package/src/schemas/form-autocomplete-options-api.ref.json +53 -0
  76. package/src/schemas/form-autocomplete.ref.json +204 -0
  77. package/src/schemas/form-button.ref.json +88 -0
  78. package/src/schemas/form-common-api-request.ref.json +29 -0
  79. package/src/schemas/form-common-filters-from-other-form-fields.ref.json +22 -0
  80. package/src/schemas/form-common-form-fields-filled-by-api-response.ref.json +28 -0
  81. package/src/schemas/form-condition.ref.json +70 -0
  82. package/src/schemas/form-datepicker.ref.json +50 -0
  83. package/src/schemas/form-fieldset.ref.json +28 -0
  84. package/src/schemas/form-file.ref.json +115 -0
  85. package/src/schemas/form-input.ref.json +105 -0
  86. package/src/schemas/form-numeric.ref.json +60 -0
  87. package/src/schemas/form-one-of.ref.json +22 -0
  88. package/src/schemas/form-pattern.ref.json +42 -0
  89. package/src/schemas/form-radiogroup.ref.json +64 -0
  90. package/src/schemas/form-select.ref.json +123 -0
  91. package/src/schemas/form-switch.ref.json +39 -0
  92. package/src/schemas/form-tab.ref.json +50 -0
  93. package/src/schemas/form.ref.json +107 -0
  94. package/src/schemas/frontend-framework-structure.schema.json +178 -0
  95. package/src/schemas/frontend.ref.json +30 -0
  96. package/src/schemas/list.ref.json +196 -0
  97. package/src/schemas/module.ref.json +39 -0
  98. package/src/schemas/panel.ref.json +127 -0
  99. package/src/schemas/project.schema.json +39 -0
  100. package/src/schemas/todo.ref.json +10 -0
  101. package/src/utils/email.ts +56 -0
  102. package/src/utils/env.ts +9 -0
  103. package/src/utils/file.ts +139 -0
  104. package/src/utils/json.ts +100 -0
  105. package/src/utils/path.ts +51 -0
  106. package/src/utils/rapida-project.ts +17 -0
  107. package/tsconfig.json +27 -0
@@ -0,0 +1,100 @@
1
+ import * as fs from "fs";
2
+ import Ajv from "ajv";
3
+ import addFormats from "ajv-formats";
4
+ import { schemasPath } from "./path";
5
+
6
+ const ajv = new Ajv({ strict: false });
7
+ addFormats(ajv); // Add formats like "date", "email", etc.
8
+
9
+ const addedSchemas = new Set<string>();
10
+
11
+ const getJsonFile = (filePath: string): any => {
12
+ try {
13
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
14
+ } catch (error: any) {
15
+ console.error(`Error reading file from path: ${filePath}`, error);
16
+ return null;
17
+ }
18
+ };
19
+
20
+ const validateProjectJson = (
21
+ jsonProjectInstance: any,
22
+ jsonSchemaName: string
23
+ ): boolean => {
24
+ try {
25
+ const jsonSchemaInstance = getJsonFile(
26
+ `${schemasPath}/${jsonSchemaName}.schema.json`
27
+ );
28
+
29
+ if (!jsonSchemaInstance) {
30
+ throw new Error(`Schema ${jsonSchemaName} not found`);
31
+ }
32
+
33
+ const refs: string[] = [];
34
+ const jsonProjectObject = JSON.parse(jsonProjectInstance);
35
+
36
+ groupJsonSchemaRefs(jsonSchemaInstance, refs);
37
+
38
+ if (refs.length > 0) {
39
+ addRefsToSchema(refs);
40
+ }
41
+
42
+ const validate = ajv.compile(jsonSchemaInstance);
43
+ const valid = validate(jsonProjectObject);
44
+
45
+ if (!valid) {
46
+ console.info(validate.errors);
47
+ return false;
48
+ }
49
+
50
+ console.info("Project JSON is valid");
51
+
52
+ return true;
53
+ } catch (error: any) {
54
+ console.error(error);
55
+ return false;
56
+ }
57
+ };
58
+
59
+ const groupJsonSchemaRefs = (obj: any, refs: string[]): void => {
60
+ if (typeof obj === "object" && obj !== null) {
61
+ if (Array.isArray(obj)) {
62
+ for (const item of obj) {
63
+ groupJsonSchemaRefs(item, refs);
64
+ }
65
+ } else {
66
+ for (const key in obj) {
67
+ if (key === "$ref" && typeof obj[key] === "string") {
68
+ refs.push(obj[key]);
69
+ } else {
70
+ groupJsonSchemaRefs(obj[key], refs);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ };
76
+
77
+ const addRefsToSchema = (refs: string[]) => {
78
+ const newRefs: string[] = [];
79
+
80
+ refs.forEach((ref) => {
81
+ const refContent = getJsonFile(`${schemasPath}/${ref}`);
82
+
83
+ if (!addedSchemas.has(ref)) {
84
+ groupJsonSchemaRefs(refContent, newRefs);
85
+
86
+ if (refContent) {
87
+ ajv.addSchema(refContent, refContent["$id"]);
88
+ addedSchemas.add(ref);
89
+ } else {
90
+ throw new Error(`Referenced schema ${ref} not found`);
91
+ }
92
+ }
93
+ });
94
+
95
+ if (newRefs.length > 0) {
96
+ addRefsToSchema(newRefs);
97
+ }
98
+ };
99
+
100
+ export { getJsonFile, validateProjectJson };
@@ -0,0 +1,51 @@
1
+ import * as chp from 'child_process';
2
+
3
+ import * as path from 'path';
4
+ import { rootPath } from './env';
5
+
6
+ /**
7
+ * Apps paths
8
+ */
9
+ const appsPath = path.join(rootPath!, 'rapida-apps');
10
+ const examplesPath = path.join(rootPath!, 'src', 'examples');
11
+ const modelsPath = path.join(rootPath!, 'src', 'models');
12
+ const schemasPath = path.join(rootPath!, 'src', 'schemas');
13
+ const scriptsPath = path.join(rootPath!, 'src', 'scripts');
14
+
15
+ /**
16
+ * Rapida's paths
17
+ */
18
+ const frontendFrameworkStructuresPath = path.join(
19
+ rootPath!,
20
+ 'models',
21
+ 'frontend',
22
+ 'json',
23
+ 'frontend-framework-structures'
24
+ );
25
+ const backendFrameworkStructuresPath = path.join(
26
+ rootPath!,
27
+ 'models',
28
+ 'backend',
29
+ 'json',
30
+ 'backend-framework-structures'
31
+ );
32
+
33
+ const doesDirectoryExist = (directoryPath: string): boolean => {
34
+ try {
35
+ chp.execSync(`ls ${directoryPath}`, { stdio: 'ignore' });
36
+ return true;
37
+ } catch (error) {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ export {
43
+ appsPath,
44
+ examplesPath,
45
+ modelsPath,
46
+ schemasPath,
47
+ scriptsPath,
48
+ frontendFrameworkStructuresPath,
49
+ backendFrameworkStructuresPath,
50
+ doesDirectoryExist
51
+ };
@@ -0,0 +1,17 @@
1
+ import type { IProject } from "../interfaces/project.interface";
2
+ import { getJsonFile } from "./json";
3
+ import { modelsPath } from "./path";
4
+
5
+ const getProjectJson = (projectName: string) => {
6
+ try {
7
+ const jsonProject: IProject = getJsonFile(
8
+ `${modelsPath}/apps/${projectName}`
9
+ );
10
+
11
+ return jsonProject;
12
+ } catch (error) {
13
+ console.error(error);
14
+ }
15
+ };
16
+
17
+ export { getProjectJson };
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }