ski-mask
Schema validation tool for Snowplow Iglu JSON schemas.
Last updated 2 years ago by premjg .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install ski-mask 
SYNC missed versions from official npm registry.

NPM

Ski Mask

Schema validation tool for Snowplow Iglu JSON schemas.


Command line Usage

  1. Install ski-mask
npm install ski-mask -g
# Or
yarn global add ski-mask
  1. Grab a valid Iglu resolver.json file that resolves to your Iglu server(s).

  2. Run ski-mask to validate the payload.

ski-mask -r ./path/to/resolver.json -d ./path/to/snowplow-payload-data.json

Example

  1. Prepare your data.json file that represents your Snowplow Payload.
{
	"schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
	"data": {
		"event_name": "link_click",
		"schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0",
		"data": {
			"targetUrl": "https://myawesomeurl.com/data",
			"elementId": "bestElementEver"
		}
	}
}
  1. Grab your Iglu resolver config file and name it something like resolver.json.
{
	"schema": "iglu:com.snowplowanalytics.iglu/resolver-config/jsonschema/1-0-0",
	"data":
	{
		"cachesize": 500,
		"repositories":
		[
			{
				"name": "iglu central",
				"priority": 0,
				"vendorprefixes":
				[
					"com.snowplowanalytics.snowplow"
				],
				"connection":
				{
					"http":
					{
						"uri": "http://iglucentral.com"
					}
				}
			},
			{
				"name": "my iglu server",
				"priority": 1,
				"vendorprefixes":
				[
					"com.my-iglu-server"
				],
				"connection":
				{
					"http":
					{
						"uri": "http://awesome-schemas.my-iglu-server.com"
					}
				}
			}
		]
	}
}
  1. Run ski-mask to validate the payload.
ski-mask -r ./path/to/resolver.json -d ./path/to/snowplow-payload-data.json

Programmatic usage

  1. Add ski-mask to your package.json
npm install ski-mask --dev
# or
yarn add ski-mask --dev
  1. Use the API
const skiMask = require('ski-mask');
// or import validate from 'ski-mask'


const payload = {
	"schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
	"data": {
		"event_name": "link_click",
		"schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0",
		"data": {
			"targetUrl": "https://myawesomeurl.com/data",
			"elementId": "bestElementEver"
		}
	}
};

const resolverConfig = {
	"schema": "iglu:com.snowplowanalytics.iglu/resolver-config/jsonschema/1-0-0",
	"data":
	{
		"cacheSize": 500,
		"repositories":
		[
			{
				"name": "Iglu Central",
				"priority": 0,
				"vendorPrefixes":
				[
					"com.snowplowanalytics.snowplow"
				],
				"connection":
				{
					"http":
					{
						"uri": "http://iglucentral.com"
					}
				}
			},
			{
				"name": "My Iglu Server",
				"priority": 1,
				"vendorPrefixes":
				[
					"com.my-iglu-server"
				],
				"connection":
				{
					"http":
					{
						"uri": "http://awesome-schemas.my-iglu-server.com"
					}
				}
			}
		]
	}
};

skiMask.validate(payload, resolverConfig).then(
	msg => console.log(msg)
)

// Will yield a result object

// {
//   success: true,
//   message: 'All Valid'
// }

// or

// {
//   success: false,
//   message: 'some error message',
//   context: 'some context for the error message'
// }

Current Tags

  • 1.1.3                                ...           latest (2 years ago)

8 Versions

  • 1.1.3                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (10)
Dev Dependencies (22)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |