npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@appliedengdesign/cnccodes-json-schema

v0.3.0

Published

JSON Schema for CNC G & M Codes

Downloads

17

Readme

NPM Version NPM DL MIT License

Follow @appliedengdesign

CNCCodes JSON Schema

This project is a schema definition for using JSON to store description and usage information about G & M codes. It was developed out of a necessity for G-Code Reference. It will be updated as the needs arise for the various types of G/M codes and various Machine Tools or 3D Printers.

Latest NPM Version: v0.3.0

Latest Draft Schema Version: 2022-07

Previous Versions: 2022-06

Schema

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://appliedengdesign.github.io/cnccodes-json-schema/draft/2022-07/schema",
    "title": "G/M Code Dictionary",
    "description": "JSON Schema for CNC G & M Codes",
    "type": "object",
    "required": [
        "title",
        "description",
        "type",
        "machineType"
    ],
    "properties": {
        "$schema": {
            "description": "Link to this schema",
            "type": "string"
        },
        "title": {
            "description": "Descriptive title of the JSON Reference",
            "type": "string"
        },
        "description": {
            "description": "Description of the JSON Reference",
            "type": "string"
        },
        "keywords": {
            "description": "An Array of string keywords describing the JSON Reference (Optional)",
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "type": {
            "description": "The type of code (G or M)",
            "type": "string",
            "enum": [
                "gcode",
                "mcode"
            ]
        },
        "machineType": {
            "description": "The type of CNC machine",
            "type": "string",
            "enum": [
                "edm",
                "mill",
                "lathe",
                "laser",
                "printer",
                "swiss"
            ]
        },
        "variant": {
            "description": "Defined if G/M Codes are for specific MTB/3DP Variant. (Must be lower case, 3-8 characters)",
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 8,
                    "pattern": "[a-z0-9]"
                },
                "remove": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "uniqueItems": true
                }
            }
        },
        "codes": {
            "description": "Individual G/M Codes",
            "type": "object",
            "patternProperties": {
                "^G|^M": {
                    "type": "object",
                    "properties": {
                        "category": {
                            "description": "Category for the code",
                            "type": "string",
                            "enum": [
                                "motion",
                                "coordinate",
                                "compensation",
                                "canned",
                                "other",
                                "mcode"
                            ]
                        },
                        "modal": {
                            "description": "Modal / Non-Modal (boolean)",
                            "type": "boolean"
                        },
                        "shortDesc": {
                            "description": "A short description of the code",
                            "type": "string",
                            "minLength": 3
                        },
                        "desc": {
                            "description": "A longer description with markdown formatting",
                            "type": "string",
                            "minLength": 3
                        },
                        "parameters": {
                            "$ref": "#/$defs/parameters"
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "category",
                        "shortDesc"
                    ]
                },
                "additionalProperties": false
            },
            "minProperties": 1
        }
    },
    "additionalProperties": false,
    "$defs": {
        "parameters": {
            "description": "An array of possible parameters to the code",
            "type": "object",
            "patternProperties": {
                "^[A-Z]{1}": {
                    "type": "object",
                    "properties": {
                        "shortDesc": {
                            "description": "A short description of the parameter",
                            "type": "string",
                            "minLength": 3
                        },
                        "desc": {
                            "description": "A description of the parameter",
                            "type": "string",
                            "minLength": 3
                        },
                        "optional": {
                            "description": "Parameter is required (boolean)",
                            "type": "boolean"
                        }
                    },
                    "required": [
                        "shortDesc",
                        "optional"
                    ],
                    "additionalProperties": false
                }
            },
            "minProperties": 1
        }
    }
}

Goals

Provide a an accurate JSON Schema to validate JSON files containing G & M code information.

Usage

Use the schema in your JSON that describes a set of G & M codes in your project (Or use our gcode-reference project) by adding https://appliedengdesign.github.io/cnccodes-json-schema/draft/2022-06/schema to your $schema reference in your JSON file.

Alternatively, you can install this as a package inside of your Javscript or Typescript project:

Install the latest version:

npm install @appliedengdesign/cnccodes-json-schema

Reference the schema file from node_modules:

node_modules/@appliedengdesign/cnccodes-json-schema/dist/schema/cnccodes.schema.json

Or use directly in script applications:

// Import the Schema
import { cncCodesJSONSchema } from 'cnccodes-json-schema';
// OR
const cncCodesJSONSchema = require('cnccodes-json-schema');

// Use schema with AJV
const Ajv = require('ajv').default;
const validate = ajv.compile(cncCodesJSONSchema);

Issues

If you find any bugs or issues with the package, please create a new GitHub issue.

Contributing

For information on contributing, please refer to the CONTRIBUTING doc for workflows and best practices.

About Applied Eng & Design

We are a full service engineering and design firm, specializing in CAD/CAM, CNC milling, rapid prototyping, training and more. We also like to dabble in Arudino / RaspberryPi projects, electronics, drones and robotics projects! Subscribe to our YouTube channel for videos on our projects, screencast tutorials, and more!

Follow us on Twitter & Instagram, and like our Facebook Page!

License

This extension is licensed under the MIT License.