@janiscommerce/view-schema-validator

2.126.0 • Public • Published

view-schema-validator

Build Status Coverage Status npm version

Validator and Builder for View Schemas for JANIS VIEWS

Installation

npm install  @janiscommerce/view-schema-validator

Usage

npx @janiscommerce/view-schema-validator build -i=/schemas -o=/build

Commands

build        Validate, compile and write new file or files JSON with valid schemas and defaults include.
validate     Validate if the file or files are valid schemas

Options:

--input, -i     write a relative dir folder or dir file
--output, -o    write a relative dir fordel for your outputs
--service, -s   write a service local for resolve endpoints
--schemasFolder, -f  write the name of the folder where the partials schemes are
--env, -e       write a current environment for resolve endpoints
--minified, -m  write build minified json files
--watch, -w     watch input and execute on changes

Examples

Recursively validating and building directory

npx @janiscommerce/view-schema-validator validate -i=/schemas
npx @janiscommerce/view-schema-validator build -i=/schemas -o=/build

Validate or Build a file

Accepts files json and Yaml

npx @janiscommerce/view-schema-validator validate -i=/schemas/browse.json
npx @janiscommerce/view-schema-validator build -i=/schemas/browse.yml -o=/build

Recursively validating and building directory and watching for changes

npx @janiscommerce/view-schema-validator validate -i=/schemas -w
npx @janiscommerce/view-schema-validator build -i=/schemas -o=/build -w

Reference resolving

All files ending with .partial.yml or .partial.json will not be validated or builded and may be used to resolve references in other schemas

/schemas
/schemas/browse.yml
/schemas/section.partial.yml
/schemas/anotherSection.partial.json

Usage partials references

sections:
  - name: mainFormSection
    rootComponent: MainForm
    icon: catalogue

    fieldsGroup:
      - name: detail
        position: left
        icon: catalogue
        collapsible: true
        defaultOpen: true
        fields:
          - $ref: fields/idText.partial.yml

          - name: name
            component: Input

          - name: descriptionTwo
            component: Textarea

  - $ref: sections/browse.partial.yml

The final paths would be like this

view-schemas/fields/idText.partial.json

view-schemas/sections/browse.partial.yml

Usage partials into other partials

Example folder with partials

view-schemas
|__fields
|____idText.partial.yml
|__sections
|____browse.partial.yml

Example of use in view-schemas/sections/browse.partial.yml

name: someBrowse
rootComponent: BrowseSection
source:
  service: sac
  namespace: claim-semaphore
  method: browse
  resolve: false
fields:
  - $ref: ../fields/idText.partial.json

  - name: name
    component: BoldText

  - name: color
    component: Text

Readme

Keywords

none

Package Sidebar

Install

npm i @janiscommerce/view-schema-validator

Weekly Downloads

453

Version

2.126.0

License

ISC

Unpacked Size

163 kB

Total Files

185

Last publish

Collaborators

  • janiscommerce