diff --git a/package-lock.json b/package-lock.json index af6bb411c..d302da293 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@layer5/meshery-design-embed": "^0.4.0", + "@layer5/schemas": "^0.0.6-6", "@mui/material": "^5.15.11", "@types/mui-datatables": "*", "billboard.js": "^3.14.3", @@ -2281,6 +2282,12 @@ "react-dom": ">=17.0.2" } }, + "node_modules/@layer5/schemas": { + "version": "0.0.6-6", + "resolved": "https://registry.npmjs.org/@layer5/schemas/-/schemas-0.0.6-6.tgz", + "integrity": "sha512-tldsv1sd1ihmmv3glsNTavJnaGU89FnExjy+8XeiZsg3KBmgT8/C8C56gTna6+5VDad2PdxMTMSlgoMgdOEv/Q==", + "license": "ISC" + }, "node_modules/@mui/core-downloads-tracker": { "version": "5.16.14", "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.16.14.tgz", diff --git a/package.json b/package.json index b946072a9..845aa54f9 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@layer5/meshery-design-embed": "^0.4.0", + "@layer5/schemas": "^0.0.6-6", "@mui/material": "^5.15.11", "@types/mui-datatables": "*", "billboard.js": "^3.14.3", diff --git a/src/schemas/createAndEditEnvironment/schema.tsx b/src/schemas/createAndEditEnvironment/schema.tsx index 1165fd70e..3b6bdcde3 100644 --- a/src/schemas/createAndEditEnvironment/schema.tsx +++ b/src/schemas/createAndEditEnvironment/schema.tsx @@ -1,27 +1,27 @@ +import { EnvironmentDefinitionV1Beta1OpenApiSchema } from '@layer5/schemas'; + +const environmentSchema = EnvironmentDefinitionV1Beta1OpenApiSchema.components.schemas; const createAndEditEnvironmentSchema = { title: 'Environment', required: ['name'], properties: { description: { - description: - 'An environment is a collection of resources, such as connections & credentail. Provide a detailed description to clarify the purpose of this environment and the types of resources it encompasses. You can modify the description at any time. Learn more about environments [here](https://docs.meshery.io/concepts/logical/environments).', + description: environmentSchema.environmentPayload.properties.description.description, format: 'textarea', title: 'Description', - type: 'string', + type: environmentSchema.environmentPayload.properties.description.type, 'x-rjsf-grid-area': '12' }, name: { - description: - 'An environment is a collection of resources. Provide a name that meaningfully represents these resources. You can change the name of the environment even after its creation.', + description: environmentSchema.environmentPayload.properties.name.description, title: 'Name', - type: 'string', + type: environmentSchema.environmentPayload.properties.name.type, 'x-rjsf-grid-area': '12' }, organization: { - type: 'string', + type: environmentSchema.environmentPayload.properties.OrganizationID.type, title: 'Organization', - description: - 'Select an organization in which you want to create this new environment. Keep in mind that the organization cannot be changed after creation.', + description: environmentSchema.environmentPayload.properties.OrganizationID.description, enum: [], enumNames: [], 'x-rjsf-grid-area': '12' diff --git a/src/schemas/createAndEditWorkspace/schema.tsx b/src/schemas/createAndEditWorkspace/schema.tsx index 856537f7a..c8906153b 100644 --- a/src/schemas/createAndEditWorkspace/schema.tsx +++ b/src/schemas/createAndEditWorkspace/schema.tsx @@ -1,27 +1,27 @@ /** * Schema for create or edit workspace modals */ +import { WorkspaceDefinitionV1Beta1OpenApiSchema } from '@layer5/schemas'; + +const workspaceSchema = WorkspaceDefinitionV1Beta1OpenApiSchema.components.schemas; const createAndEditWorkspace = { properties: { description: { - description: - "Workspaces serve as a virtual space for your team-based work, allows you to control access and more, Provide a detailed description to clarify the purpose of this workspace. Remember you can changes description of workspace after it's creations too. Learn more about workspaces [here](https://docs.meshery.io/concepts/logical/workspaces)", + description: workspaceSchema.workspacePayload.properties.description.description, format: 'textarea', title: 'Description', - type: 'string', + type: workspaceSchema.workspacePayload.properties.description.type, 'x-rjsf-grid-area': '12' }, name: { - description: - 'Provide a name that meaningfully represents this workspace. You can change the name of the workspace even after its creation.', + description: workspaceSchema.workspacePayload.properties.name.description, title: 'Name', - type: 'string', + type: workspaceSchema.workspacePayload.properties.name.type, 'x-rjsf-grid-area': '12' }, organization: { - type: 'string', - description: - 'Select an organization in which you want to create this new workspace. Keep in mind that the organization cannot be changed after creation.', + type: workspaceSchema.workspacePayload.properties.organization_id.type, + description: workspaceSchema.workspacePayload.properties.organization_id.description, title: 'Organization', enum: [], enumNames: [], @@ -29,7 +29,7 @@ const createAndEditWorkspace = { } }, type: 'object', - required: ['name', 'organization'] + required: workspaceSchema.workspacePayload.required }; export default createAndEditWorkspace; diff --git a/src/schemas/importDesign/schema.tsx b/src/schemas/importDesign/schema.tsx index 32c01dec1..0d3b21774 100644 --- a/src/schemas/importDesign/schema.tsx +++ b/src/schemas/importDesign/schema.tsx @@ -1,29 +1,24 @@ +import { DesignDefinitionV1Beta1OpenApiSchema } from '@layer5/schemas'; + +const DesignSchema = DesignDefinitionV1Beta1OpenApiSchema.components.schemas; + const importDesignSchema = { type: 'object', properties: { name: { - type: 'string', + type: DesignSchema.MesheryPatternImportRequestBody.properties.name.type, title: 'Design file name', - default: 'Untitled Design', + default: DesignSchema.MesheryPatternImportRequestBody.properties.name.default, 'x-rjsf-grid-area': '12', - description: - 'Provide a name for your design file. This name will help you identify the file more easily. You can also change the name of your design after importing it.' + description: DesignSchema.MesheryPatternImportRequestBody.properties.name.description }, - // designType: { - // title: 'Design type', - // enum: ['Helm Chart', 'Kubernetes Manifest', 'Docker Compose', 'Meshery Design'], - // 'x-rjsf-grid-area': '6', - // description: - // "Select the type of design you are uploading. The 'Design Type' determines the format, structure, and content of the file you are uploading. Choose the appropriate design type that matches the nature of your file. Checkout https://docs.meshery.io/guides/configuration-management/creating-a-meshery-design to learn more about designs" - // }, uploadType: { title: 'Upload method', enum: ['File Upload', 'URL Import'], default: 'URL Import', 'x-rjsf-grid-area': '12', - description: - "Choose the method you prefer to upload your design file. Select 'File Upload' if you have the file on your local system, or 'URL Import' if you have the file hosted online." + description: DesignSchema.MesheryPatternImportRequestBody.description } }, @@ -39,10 +34,9 @@ const importDesignSchema = { then: { properties: { file: { - type: 'string', - format: 'file', - description: - 'Supported formats: Kubernetes Manifests, Helm Charts, Docker Compose, and Meshery Designs. See [Import Designs Documentation](https://docs.meshery.io/guides/configuration-management/importing-designs#import-designs-using-meshery-ui) for details', + type: DesignSchema.MesheryPatternImportRequestBody.properties.file.type, + format: DesignSchema.MesheryPatternImportRequestBody.properties.file.format, + description: DesignSchema.MesheryPatternImportRequestBody.properties.file.description, 'x-rjsf-grid-area': '12' } }, @@ -60,11 +54,10 @@ const importDesignSchema = { then: { properties: { url: { - type: 'string', - format: 'uri', + type: DesignSchema.MesheryPatternImportRequestBody.properties.url.type, + format: DesignSchema.MesheryPatternImportRequestBody.properties.url.format, title: 'URL', - description: - 'Provide the URL of the file you want to import. This should be a direct URL to a single file, for example: https://raw.github.com/your-design-file.yaml. Also, ensure that design is in a supported format: Kubernetes Manifest, Helm Chart, Docker Compose, or Meshery Design. See [Import Designs Documentation](https://docs.meshery.io/guides/configuration-management/importing-designs#import-designs-using-meshery-ui) for details', + description: DesignSchema.MesheryPatternImportRequestBody.properties.url.description, 'x-rjsf-grid-area': '12' } }, diff --git a/src/schemas/importModel/schema.tsx b/src/schemas/importModel/schema.tsx index 6269cbbda..c15ec750b 100644 --- a/src/schemas/importModel/schema.tsx +++ b/src/schemas/importModel/schema.tsx @@ -1,20 +1,18 @@ +import { ModelDefinitionV1Beta1OpenApiSchema } from '@layer5/schemas'; + +const ModelSchema = ModelDefinitionV1Beta1OpenApiSchema.components.schemas; const importModelSchema = { type: 'object', required: ['uploadType'], properties: { uploadType: { - type: 'string', + type: ModelSchema.ImportRequest.properties.uploadType.type, title: 'Upload method', enum: ['File Import', 'URL Import', 'CSV Import'], - enumDescriptions: [ - 'Upload a model file (.tar, .tar.gz, .tgz) from your local system', - 'Import a model file using a direct URL to the source', - 'Upload separate CSV files for model definitions, components, and their relationships' - ], + enumDescriptions: ModelSchema.ImportRequest.properties.uploadType.enumDescriptions, default: 'Select the Upload Method', 'x-rjsf-grid-area': '12', - description: - "Choose the method you prefer to upload your model file. Select 'File Import' or 'CSV Import' if you have the file on your local system or 'URL Import' if you have the file hosted online." + description: ModelSchema.ImportRequest.properties.uploadType.description } }, allOf: [ @@ -29,10 +27,9 @@ const importModelSchema = { then: { properties: { file: { - type: 'string', - format: 'file', - description: - 'Supported model file formats are: .tar, .tar.gz, and .tgz. See [Import Models Documentation](https://docs.meshery.io/guides/configuration-management/importing-models#import-models-using-meshery-ui) for details', + type: ModelSchema.ImportBody.oneOf[0].properties.modelFile?.type, + format: ModelSchema.ImportBody.oneOf[0].properties.modelFile?.format, + description: ModelSchema.ImportBody.oneOf[0].properties.modelFile?.description, 'x-rjsf-grid-area': '12' } }, @@ -50,11 +47,10 @@ const importModelSchema = { then: { properties: { url: { - type: 'string', - format: 'uri', + type: ModelSchema.ImportBody.oneOf[1].properties.url?.type, + format: ModelSchema.ImportBody.oneOf[1].properties.url?.format, title: 'URL', - description: - 'A direct URL to a single model file, for example: https://raw.github.com/your-model-file.tar. Supported model file formats are: .tar, .tar.gz, and .tgz. \n\nFor bulk import of your model use the GitHub connection or CSV files. See [Import Models Documentation](https://docs.meshery.io/guides/configuration-management/importing-models#import-models-using-meshery-ui) for details', + description: ModelSchema.ImportBody.oneOf[1].properties.url?.description, 'x-rjsf-grid-area': '12', disabled: true } diff --git a/src/schemas/publishCatalogItem/schema.tsx b/src/schemas/publishCatalogItem/schema.tsx index 06295112f..3aff31210 100644 --- a/src/schemas/publishCatalogItem/schema.tsx +++ b/src/schemas/publishCatalogItem/schema.tsx @@ -1,3 +1,7 @@ +import { CatalogDataDefinitionV1Alpha1OpenApiSchema } from '@layer5/schemas'; + +const CatalogDataDefinitionV1Alpha1Schema = + CatalogDataDefinitionV1Alpha1OpenApiSchema.components.schemas.CatalogData; /** * Schema for publish catalog item modal; * Can be use for publishing filters and designs @@ -6,12 +10,9 @@ const publishCatalogItemSchema = { type: 'object', properties: { compatibility: { - type: 'array', + type: CatalogDataDefinitionV1Alpha1Schema.properties.compatibility.type, title: 'Technology', - items: { - enum: ['kubernetes'], - type: 'string' - }, + items: CatalogDataDefinitionV1Alpha1Schema.properties.compatibility.items, uniqueItems: true, minItems: 1, description: @@ -19,38 +20,27 @@ const publishCatalogItemSchema = { 'x-rjsf-grid-area': 6 }, pattern_caveats: { - type: 'string', - title: 'Caveats and Considerations', - description: - 'Specific stipulations to consider and known behaviors to be aware of when using this design.', + type: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_caveats.type, + title: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_caveats.title, + description: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_caveats.description, format: 'textarea', 'x-rjsf-grid-area': 12, 'x-encode-in-uri': true }, pattern_info: { - type: 'string', - title: 'Description', - description: 'Purpose of the design along with its intended and unintended uses.', + type: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_info.type, + title: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_info.title, + description: CatalogDataDefinitionV1Alpha1Schema.properties.pattern_info.description, format: 'textarea', 'x-rjsf-grid-area': 12, 'x-encode-in-uri': true }, type: { - type: 'string', - title: 'Type', - enum: [ - 'Deployment', - 'Observability', - 'Resiliency', - 'Scaling', - 'Security', - 'Traffic-management', - 'Troubleshooting', - 'Workloads' - ], - default: 'Deployment', - description: - 'Categorization of the type of design or operational flow depicted in this design.', + type: CatalogDataDefinitionV1Alpha1Schema.properties.type.type, + title: CatalogDataDefinitionV1Alpha1Schema.properties.type.title, + enum: CatalogDataDefinitionV1Alpha1Schema.properties.type.enum, + default: CatalogDataDefinitionV1Alpha1Schema.properties.type.default, + description: CatalogDataDefinitionV1Alpha1Schema.properties.type.description, 'x-rjsf-grid-area': 6 } },