generated from Exabyte-io/template-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
SOF-6328: in-memory entity #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9c852c5
update: remove schema mix logic
k0stik 7c27ceb
Merge branch 'main' of github.com:Exabyte-io/code.js into update/SOF-…
k0stik 10cfe81
chore: update esse
k0stik 6a311b4
Merge branch 'update/SOF-6186' of github.com:Exabyte-io/code.js into …
k0stik c8be965
chore: new esse version
k0stik d31653e
chore: update esse
k0stik 6987177
fix: clean schemaId before mergeAllOf
k0stik cf58a05
fix: clean schemaId
k0stik bcc1520
chore: rename json schema test
k0stik f987919
chore: update esse
k0stik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,104 +1,21 @@ | ||
| import { JSONSchemasInterface } from "../JSONSchemasInterface"; | ||
|
|
||
| export const baseSchemas = { | ||
| Material: "material", | ||
| Entity: "system/entity", | ||
| BankMaterial: "material", | ||
| Workflow: "workflow", | ||
| Subworkflow: "workflow/subworkflow", | ||
| BankWorkflow: "workflow", | ||
| Job: "job", | ||
| Application: "software/application", | ||
| Executable: "software/executable", | ||
| Flavor: "software/flavor", | ||
| Template: "software/template", | ||
| AssertionUnit: "workflow/unit/assertion", | ||
| AssignmentUnit: "workflow/unit/assignment", | ||
| ConditionUnit: "workflow/unit/condition", | ||
| ExecutionUnit: "workflow/unit/execution", | ||
| IOUnit: "workflow/unit/io", | ||
| MapUnit: "workflow/unit/map", | ||
| ProcessingUnit: "workflow/unit/processing", | ||
| ReduceUnit: "workflow/unit/reduce", | ||
| SubworkflowUnit: "workflow/unit", | ||
| Unit: "workflow/unit", | ||
| Project: "project", | ||
| }; | ||
|
|
||
| export const entityMix = [ | ||
| "system/description-object", | ||
| "system/base-entity-set", | ||
| "system/sharing", | ||
| "system/metadata", | ||
| "system/defaultable", | ||
| ]; | ||
|
|
||
| export const subWorkflowMix = ["system/system-name", "system/is-multi-material"]; | ||
|
|
||
| export const workflowMix = ["workflow/base-flow", "system/history", "system/is-outdated"]; | ||
|
|
||
| export const bankMaterialMix = ["material/conventional", "system/creator-account"]; | ||
|
|
||
| export const bankWorkflowMix = ["system/creator-account"]; | ||
|
|
||
| export const jobMix = ["system/status", "system/job-extended"]; | ||
|
|
||
| export const unitMix = [ | ||
| "system/unit-extended", | ||
| "system/status", | ||
| "workflow/unit/runtime/runtime-items", | ||
| ]; | ||
|
|
||
| export const assignmentUnitMix = ["system/scope"]; | ||
|
|
||
| export const flavorMix = ["system/is-multi-material"]; | ||
|
|
||
| export const systemEntityMix = ["system/entity"]; | ||
|
|
||
| export const projectMix = ["system/status"]; | ||
|
|
||
| export const mixSchemas = { | ||
| Entity: [...entityMix], | ||
| Material: [...entityMix], | ||
| BankMaterial: [...entityMix, ...bankMaterialMix], | ||
| Workflow: [...entityMix, ...subWorkflowMix, ...workflowMix], | ||
| Subworkflow: [...subWorkflowMix], | ||
| BankWorkflow: [...entityMix, ...subWorkflowMix, ...workflowMix, ...bankWorkflowMix], | ||
| Job: [...entityMix, ...jobMix], | ||
| Application: [...entityMix, ...systemEntityMix], | ||
| Executable: [...entityMix, ...systemEntityMix], | ||
| Flavor: [...entityMix, ...flavorMix, ...systemEntityMix], | ||
| Template: [...entityMix, ...systemEntityMix], | ||
| AssertionUnit: [...unitMix], | ||
| AssignmentUnit: [...unitMix, ...assignmentUnitMix], | ||
| ConditionUnit: [...unitMix], | ||
| ExecutionUnit: [...unitMix], | ||
| IOUnit: [...unitMix], | ||
| MapUnit: [...unitMix], | ||
| ProcessingUnit: [...unitMix], | ||
| ReduceUnit: [...unitMix], | ||
| SubworkflowUnit: [...unitMix], | ||
| Unit: [...unitMix], | ||
| Project: [...entityMix, ...systemEntityMix, ...projectMix], | ||
| }; | ||
| export const schemas = {}; | ||
|
|
||
| /** | ||
| * Returns previously registered schema for InMemoryEntity | ||
| * @param {*} className | ||
| * @returns | ||
| */ | ||
| export function getSchemaByClassName(className) { | ||
| return baseSchemas[className] ? JSONSchemasInterface.schemaById(baseSchemas[className]) : null; | ||
| } | ||
|
|
||
| export function getMixSchemasByClassName(className) { | ||
| return mixSchemas[className] | ||
| ? mixSchemas[className].map((schemaId) => JSONSchemasInterface.schemaById(schemaId)) | ||
| : []; | ||
| return schemas[className] ? JSONSchemasInterface.schemaById(schemas[className]) : null; | ||
| } | ||
|
|
||
| /** | ||
| * Register additional Entity classes to be resolved with jsonSchema property | ||
| * @param {String} className - class name derived from InMemoryEntity | ||
| * @param {String} classBaseSchema - base schemaId | ||
| * @param {Array} classMixSchemas - array of schemaId to mix | ||
| * @param {String} schemaId - class schemaId | ||
| */ | ||
| export function registerClassName(className, classBaseSchema, classMixSchemas) { | ||
| baseSchemas[className] = classBaseSchema; | ||
| mixSchemas[className] = classMixSchemas; | ||
| export function registerClassName(className, schemaId) { | ||
| schemas[className] = schemaId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,91 @@ | ||
| import { expect } from "chai"; | ||
| import { assert, expect } from "chai"; | ||
|
|
||
| import { JSONSchemasInterface } from "../src/JSONSchemasInterface"; | ||
| import { baseSchemas, mixSchemas } from "../src/utils/schemas"; | ||
|
|
||
| describe("JSONSchemasInterface", () => { | ||
| it("can find main schema", () => { | ||
| Object.values(baseSchemas).forEach((schemaId) => { | ||
| const schema = JSONSchemasInterface.schemaById(schemaId); | ||
| expect(schema).to.be.an("object"); | ||
| }); | ||
| }); | ||
|
|
||
| it("can find mix schemas", () => { | ||
| Object.values(mixSchemas).forEach((schemaIds) => { | ||
| schemaIds.forEach((schemaId) => { | ||
| const schema = JSONSchemasInterface.schemaById(schemaId); | ||
| expect(schema).to.be.an("object"); | ||
| }); | ||
| }); | ||
| it("can find schema", () => { | ||
| const schema = JSONSchemasInterface.schemaById("workflow"); | ||
| expect(schema).to.be.an("object"); | ||
| }); | ||
|
|
||
| it("can match schemas", () => { | ||
| const schemaId = Object.values(baseSchemas)[0]; | ||
| const schema = JSONSchemasInterface.matchSchema({ | ||
| schemaId: { | ||
| $regex: schemaId, | ||
| $regex: "workflow", | ||
| }, | ||
| }); | ||
|
|
||
| expect(schema).to.be.an("object"); | ||
| }); | ||
|
|
||
| it("can find registered schemas", () => { | ||
| it("can find registered schemas; the schema is merged and clean", () => { | ||
| JSONSchemasInterface.registerSchema({ | ||
| schemaId: "test-schema-id", | ||
| schemaId: "system/in-set", | ||
| $schema: "http://json-schema.org/draft-04/schema#", | ||
| title: "System in-set schema", | ||
| properties: { | ||
| testProp: { | ||
| inSet: { | ||
| type: "array", | ||
| items: { | ||
| allOf: [ | ||
| { | ||
| schemaId: "system/entity-reference", | ||
| $schema: "http://json-schema.org/draft-04/schema#", | ||
| title: "entity reference schema", | ||
| properties: { | ||
| _id: { | ||
| description: "entity identity", | ||
| type: "string", | ||
| }, | ||
| cls: { | ||
| description: "entity class", | ||
| type: "string", | ||
| }, | ||
| slug: { | ||
| description: "entity slug", | ||
| type: "string", | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| type: "object", | ||
| properties: { | ||
| type: { | ||
| type: "string", | ||
| }, | ||
| index: { | ||
| type: "number", | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| valueMapFunction: { | ||
| description: "Specifies the function to convert the currentValue in UI.", | ||
| type: "string", | ||
| enum: [ | ||
| "toString", | ||
| "toContactUs", | ||
| "toPlusMinusSign", | ||
| "toUnlimited", | ||
| "toSupportSeverity", | ||
| ], | ||
| default: "toString", | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const schema = JSONSchemasInterface.schemaById("test-schema-id"); | ||
| const schema = JSONSchemasInterface.schemaById("system/in-set"); | ||
|
|
||
| expect(schema).to.be.an("object"); | ||
| assert(schema.schemaId, "system/in-set"); | ||
| expect(schema.properties.inSet.items.schemaId).to.be.an("undefined"); | ||
| expect(schema.properties.inSet.items.properties).to.be.an("object"); | ||
| expect(schema.properties.valueMapFunction.enum[0]).to.be.an("string"); | ||
| expect(schema.properties.valueMapFunction.enum[1]).to.be.an("string"); | ||
| expect(schema.properties.valueMapFunction.enum[2]).to.be.an("string"); | ||
| expect(schema.properties.valueMapFunction.enum[3]).to.be.an("string"); | ||
| expect(schema.properties.valueMapFunction.enum[4]).to.be.an("string"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.