1.0.9 • Published 9 months ago

@murmurations/jsig v1.0.9

Weekly downloads
-
License
GPLv3
Repository
-
Last release
9 months ago

JSON Schema Instance Generator

This project is licensed under the terms of the GNU General Public License v3.0

Installation

Using npm:

npm install @murmurations/jsig

Examples

1. parseSchemas

import { parseSchemas } from '@murmurations/jsig'

const url = 'https://example.com/schema.json'
const schemaNames = ['schema1', 'schema2']

try {
  const result = await parseSchemas(url, schemaNames)
  console.log(result)
} catch (error) {
  console.error(error)
}

2. generateSchemaInstance

import { generateSchemaInstance } from '@murmurations/jsig'

const schema = {
  // Schema definition
}

// The following data is an example of the data, you should use the formData directly
const data = {
  // Input data
  name: ['John Doe'],
  age: [30],
  email: ['john.doe@example.com'],
  // If key contains ".", it will be parsed to an Object
  'address.zip': [10000],
  'address.city': ['City'],
  // If key contains "[]", it will be parsed to an Array
  'tags[0]': ['self']
}

// data should be directly from the formData without making any changes
const formData = new FormData(event.target)
let data = {}
for (let key of formData.keys()) {
  data[key] = formData.getAll(key)
}

try {
  const result = await generateSchemaInstance(schema, data)
  console.log(result)
} catch (error) {
  console.error(error)
}

Local Development

Install dependencies

npm install

Build the package

npm run build

Use package in another project (run command in that project's directory)

npm install --no-save ../JSONSchemaInstanceGenerator

Install latest pre-release version in another project (run command in that project's directory)

npm install @murmurations/jsig@pre

Reference

  1. ECMAScript Modules in Node.js
  2. Best practices for creating a modern npm package
  3. Gotchas in Remix
1.0.9

9 months ago

1.0.9-pre.0

9 months ago

1.0.8

11 months ago

1.0.8-pre.0

12 months ago

1.0.8-pre.2

11 months ago

1.0.8-pre.1

11 months ago

1.0.8-pre.4

11 months ago

1.0.8-pre.3

11 months ago

1.0.7

1 year ago

1.0.7-pre.0

1 year ago

1.0.6

1 year ago

1.0.6-pre.0

1 year ago

1.0.5

1 year ago

1.0.5-pre.0

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.3-pre.1

2 years ago

1.0.3-pre.0

2 years ago

1.0.2-pre.1

2 years ago

1.0.4

2 years ago

1.0.1-pre.1

2 years ago

1.0.3

2 years ago

1.0.1-pre.0

2 years ago

1.0.2-pre.0

2 years ago

1.0.4-pre.1

2 years ago

1.0.0

2 years ago

1.0.0-pre.2

2 years ago