|
1 | 1 | import { JSONSchemasInterface } from "../JSONSchemasInterface"; |
2 | 2 |
|
3 | | -export const baseSchemas = { |
4 | | - Material: "material", |
5 | | - Entity: "system/entity", |
6 | | - BankMaterial: "material", |
7 | | - Workflow: "workflow", |
8 | | - Subworkflow: "workflow/subworkflow", |
9 | | - BankWorkflow: "workflow", |
10 | | - Job: "job", |
11 | | - Application: "software/application", |
12 | | - Executable: "software/executable", |
13 | | - Flavor: "software/flavor", |
14 | | - Template: "software/template", |
15 | | - AssertionUnit: "workflow/unit/assertion", |
16 | | - AssignmentUnit: "workflow/unit/assignment", |
17 | | - ConditionUnit: "workflow/unit/condition", |
18 | | - ExecutionUnit: "workflow/unit/execution", |
19 | | - IOUnit: "workflow/unit/io", |
20 | | - MapUnit: "workflow/unit/map", |
21 | | - ProcessingUnit: "workflow/unit/processing", |
22 | | - ReduceUnit: "workflow/unit/reduce", |
23 | | - SubworkflowUnit: "workflow/unit", |
24 | | - Unit: "workflow/unit", |
25 | | - Project: "project", |
26 | | -}; |
27 | | - |
28 | | -export const entityMix = [ |
29 | | - "system/description-object", |
30 | | - "system/base-entity-set", |
31 | | - "system/sharing", |
32 | | - "system/metadata", |
33 | | - "system/defaultable", |
34 | | -]; |
35 | | - |
36 | | -export const subWorkflowMix = ["system/system-name", "system/is-multi-material"]; |
37 | | - |
38 | | -export const workflowMix = ["workflow/base-flow", "system/history", "system/is-outdated"]; |
39 | | - |
40 | | -export const bankMaterialMix = ["material/conventional", "system/creator-account"]; |
41 | | - |
42 | | -export const bankWorkflowMix = ["system/creator-account"]; |
43 | | - |
44 | | -export const jobMix = ["system/status", "system/job-extended"]; |
45 | | - |
46 | | -export const unitMix = [ |
47 | | - "system/unit-extended", |
48 | | - "system/status", |
49 | | - "workflow/unit/runtime/runtime-items", |
50 | | -]; |
51 | | - |
52 | | -export const assignmentUnitMix = ["system/scope"]; |
53 | | - |
54 | | -export const flavorMix = ["system/is-multi-material"]; |
55 | | - |
56 | | -export const systemEntityMix = ["system/entity"]; |
57 | | - |
58 | | -export const projectMix = ["system/status"]; |
59 | | - |
60 | | -export const mixSchemas = { |
61 | | - Entity: [...entityMix], |
62 | | - Material: [...entityMix], |
63 | | - BankMaterial: [...entityMix, ...bankMaterialMix], |
64 | | - Workflow: [...entityMix, ...subWorkflowMix, ...workflowMix], |
65 | | - Subworkflow: [...subWorkflowMix], |
66 | | - BankWorkflow: [...entityMix, ...subWorkflowMix, ...workflowMix, ...bankWorkflowMix], |
67 | | - Job: [...entityMix, ...jobMix], |
68 | | - Application: [...entityMix, ...systemEntityMix], |
69 | | - Executable: [...entityMix, ...systemEntityMix], |
70 | | - Flavor: [...entityMix, ...flavorMix, ...systemEntityMix], |
71 | | - Template: [...entityMix, ...systemEntityMix], |
72 | | - AssertionUnit: [...unitMix], |
73 | | - AssignmentUnit: [...unitMix, ...assignmentUnitMix], |
74 | | - ConditionUnit: [...unitMix], |
75 | | - ExecutionUnit: [...unitMix], |
76 | | - IOUnit: [...unitMix], |
77 | | - MapUnit: [...unitMix], |
78 | | - ProcessingUnit: [...unitMix], |
79 | | - ReduceUnit: [...unitMix], |
80 | | - SubworkflowUnit: [...unitMix], |
81 | | - Unit: [...unitMix], |
82 | | - Project: [...entityMix, ...systemEntityMix, ...projectMix], |
83 | | -}; |
| 3 | +export const schemas = {}; |
84 | 4 |
|
| 5 | +/** |
| 6 | + * Returns previously registered schema for InMemoryEntity |
| 7 | + * @param {*} className |
| 8 | + * @returns |
| 9 | + */ |
85 | 10 | export function getSchemaByClassName(className) { |
86 | | - return baseSchemas[className] ? JSONSchemasInterface.schemaById(baseSchemas[className]) : null; |
87 | | -} |
88 | | - |
89 | | -export function getMixSchemasByClassName(className) { |
90 | | - return mixSchemas[className] |
91 | | - ? mixSchemas[className].map((schemaId) => JSONSchemasInterface.schemaById(schemaId)) |
92 | | - : []; |
| 11 | + return schemas[className] ? JSONSchemasInterface.schemaById(schemas[className]) : null; |
93 | 12 | } |
94 | 13 |
|
95 | 14 | /** |
96 | 15 | * Register additional Entity classes to be resolved with jsonSchema property |
97 | 16 | * @param {String} className - class name derived from InMemoryEntity |
98 | | - * @param {String} classBaseSchema - base schemaId |
99 | | - * @param {Array} classMixSchemas - array of schemaId to mix |
| 17 | + * @param {String} schemaId - class schemaId |
100 | 18 | */ |
101 | | -export function registerClassName(className, classBaseSchema, classMixSchemas) { |
102 | | - baseSchemas[className] = classBaseSchema; |
103 | | - mixSchemas[className] = classMixSchemas; |
| 19 | +export function registerClassName(className, schemaId) { |
| 20 | + schemas[className] = schemaId; |
104 | 21 | } |
0 commit comments