@polytric/openws-spec 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js","../../node_modules/.pnpm/@pocketgems+schema@0.1.3/node_modules/@pocketgems/schema/src/schema.js","../package.json","../src/spec-schema.ts","../src/spec-schema.json","../src/index.ts"],"sourcesContent":["'use strict'\nmodule.exports = rfdc\n\nfunction copyBuffer (cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nfunction rfdc (opts) {\n opts = opts || {}\n if (opts.circles) return rfdcCircles(opts)\n\n const constructorHandlers = new Map()\n constructorHandlers.set(Date, (o) => new Date(o))\n constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)))\n constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))\n if (opts.constructorHandlers) {\n for (const handler of opts.constructorHandlers) {\n constructorHandlers.set(handler[0], handler[1])\n }\n }\n\n let handler = null\n\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length)\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]\n const cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, clone)\n }\n const o2 = {}\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, clone)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = clone(cur)\n }\n }\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, cloneProto)\n }\n const o2 = {}\n for (const k in o) {\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, cloneProto)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n return o2\n }\n}\n\nfunction rfdcCircles (opts) {\n const refs = []\n const refsNew = []\n\n const constructorHandlers = new Map()\n constructorHandlers.set(Date, (o) => new Date(o))\n constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)))\n constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))\n if (opts.constructorHandlers) {\n for (const handler of opts.constructorHandlers) {\n constructorHandlers.set(handler[0], handler[1])\n }\n }\n\n let handler = null\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length)\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]\n const cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n const index = refs.indexOf(cur)\n if (index !== -1) {\n a2[k] = refsNew[index]\n } else {\n a2[k] = fn(cur)\n }\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, clone)\n }\n const o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, clone)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n const i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = clone(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, cloneProto)\n }\n const o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (const k in o) {\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k] = handler(cur, cloneProto)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n const i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n}\n","const assert = require('assert')\n\nlet ajv // only defined if needed\nconst deepcopy = require('rfdc')() // cspell:disable-line\n\n/**\n * Thrown if a compiled schema validator is asked to validate an invalid value.\n */\nclass ValidationError extends Error {\n /**\n * @param {string} name a user-provided name describing the schema\n * @param {*} badValue the value which did not validate\n * @param {Object} errors how badValue failed to conform to the schema\n * @param {Object} expectedSchema The JSON schema used in schema validation\n */\n constructor (name, badValue, errors, expectedSchema) {\n super(`Validation Error: ${name}`)\n this.badValue = badValue\n this.validationErrors = errors\n this.expectedSchema = expectedSchema\n // istanbul ignore next\n if (['localhost', 'webpack'].includes(process.env.NODE_ENV)) {\n console.error(JSON.stringify(errors, null, 2))\n }\n }\n}\n\nconst INT32_MAX = Math.pow(2, 31) - 1\nconst INT32_MIN = -Math.pow(2, 31)\nconst TIMESTAMP_MIN = '2000-01-01T00:00:00Z'\nconst TIMESTAMP_MAX = '9999-01-01T00:00:00Z'\nconst EPOCH_IN_MILLISECONDS_MIN = new Date(TIMESTAMP_MIN).getTime()\nconst EPOCH_IN_MILLISECONDS_MAX = new Date(TIMESTAMP_MAX).getTime()\nconst EPOCH_IN_SECONDS_MIN = EPOCH_IN_MILLISECONDS_MIN / 1000\nconst EPOCH_IN_SECONDS_MAX = EPOCH_IN_MILLISECONDS_MAX / 1000\n\n// javascript is limited in how it can represent >53 bit numbers\n// so 2^62 is naturally the best we can do\nconst INT64_MAX = Math.pow(2, 62)\nconst INT64_MIN = -Math.pow(2, 62)\n\n/**\n * The base schema object\n */\nclass BaseSchema {\n /**\n * The json schema type\n */\n static JSON_SCHEMA_TYPE\n\n /**\n * The max* property name.\n */\n static MAX_PROP_NAME\n\n /**\n * The min* property name.\n */\n static MIN_PROP_NAME\n\n /**\n * Constructs a schema object\n */\n constructor () {\n /**\n * Flag to indicate whether an object is a Todea Schema object.\n */\n this.isTodeaSchema = true\n\n /**\n * For compatibility with fluent-schema. Indicates if an object is a\n * fluent-schema object.\n */\n this.isFluentSchema = true\n\n /**\n * Stores json schema properties, e.g. type, description, maxLength, etc...\n */\n this.__properties = {}\n\n /**\n * Indicates whether an object is locked. See {@link lock}.\n */\n this.__isLocked = false\n this.__isOptional = false\n this.__setProp('type', this.constructor.JSON_SCHEMA_TYPE)\n }\n\n /**\n * Locks a Todea Schema object from modifications.\n */\n lock () {\n this.__isLocked = true\n return this\n }\n\n /**\n * Sets a value in __properties. Throws if object is locked (unless the\n * property is allowed to be overridden), or property with\n * the same name already exists and override is not allowed.\n * @param {String} name Name of the property\n * @param {*} val The value for the property\n * @param {Object} [options={}]\n * @param {Boolean} [options.allowOverride=false] If true property override\n * is allowed.\n */\n __setProp (name, val, { allowOverride = false } = {}) {\n assert.ok(!this.__isLocked || allowOverride,\n 'Schema is locked. Call copy then further modify the schema')\n assert.ok(allowOverride ||\n !Object.prototype.hasOwnProperty.call(this.__properties, name),\n `Property ${name} is already set.`)\n const shouldCopy = this.__isLocked || (allowOverride &&\n Object.prototype.hasOwnProperty.call(this.__properties, name))\n const ret = shouldCopy ? this.copy() : this\n ret.__properties[name] = val\n if (this.__isLocked) {\n ret.lock()\n }\n return ret\n }\n\n /**\n * @param {String} name Name of a property\n * @return The value associated with name.\n */\n getProp (name) {\n return this.__properties[name]\n }\n\n /**\n * If property with name does not exist, the default value is set.\n * @param {String} name\n * @param {*} defaultValue\n * @return The value associated with name.\n */\n __setDefaultProp (name, defaultValue) {\n if (!Object.prototype.hasOwnProperty.call(this.__properties, name)) {\n this.__setProp(name, defaultValue)\n }\n return this.getProp(name)\n }\n\n /**\n * Sets a title.\n * @param {String} t The title of the schema.\n */\n title (t) {\n assert.ok(typeof t === 'string', 'Title must be a string.')\n return this.__setProp('title', t, { allowOverride: true })\n }\n\n /**\n * Sets a description.\n * @param {String|Array<String>} t The description of the schema. If an array\n * of strings are passed in, they will be joined by a space to form the\n * description.\n */\n desc (d) {\n assert.ok(typeof d === 'string', 'Description must be a string.')\n d = d.trim().replace(/\\n/g, ' ')\n return this.__setProp('description', d, { allowOverride: true })\n }\n\n /**\n * Sets a default value for schema.\n *\n * According to JsonSchema, default value is just metadata and does not\n * serve any validation purpose with in JsonSchema. External tools may\n * choose to use this value to setup defaults, and implementations of\n * JsonSchema validator may choose to validate the type of default values,\n * but it's not required. Since when the default is used to populate the\n * json, there will be something downstream that validates the json and\n * catches issues, we omit schema validation for simplicity.\n *\n * @param {*} d The default value.\n */\n default (d) {\n assert(d !== undefined, 'Default value must be defined')\n Object.freeze(d)\n return this.__setProp('default', d)\n }\n\n getDefault () {\n return this.properties().default\n }\n\n hasDefault () {\n return Object.prototype.hasOwnProperty.call(this.properties(), 'default')\n }\n\n /**\n * Marks a schema as optional. Schemas are required by default.\n */\n optional () {\n assert(!this.__isLocked, 'Schema is locked.')\n this.__isOptional = true\n return this\n }\n\n /**\n * Convenient getter indicates if the schema is required / not optional.\n * See {@link optional}.\n */\n get required () {\n return !this.__isOptional\n }\n\n /**\n * Sets schemas readOnly property.\n * @param {Boolean} [r=true] If the schema value should be readOnly.\n */\n readOnly (r = true) {\n return this.__setProp('readOnly', r)\n }\n\n /**\n * Updates schemas examples.\n * @param {Array<String|Array<String>>} es A list of examples. Each example\n * may be a string, or a list of strings. In case of a list of strings, the\n * strings will be joined by a space character and used as one example.\n */\n examples (es) {\n assert.ok(Array.isArray(es), 'Examples must be an array')\n es = es.map(e => {\n return Array.isArray(e) ? e.join(' ') : e\n })\n return this.__setProp('examples', es, { allowOverride: true })\n }\n\n /**\n * Returns a JSON Schema. It exists for compatibility with fluent-schema.\n */\n valueOf () {\n return this.jsonSchema()\n }\n\n /**\n * The visitable in a visitor pattern. Used for exporting schema.\n * @param {Exporter} visitor a schema exporter. @see JSONSchemaExporter\n */\n // istanbul ignore next\n export (visitor) {\n throw new Error('Subclass must override')\n }\n\n properties () {\n return this.__properties\n }\n\n /**\n * @return JSON Schema with the schema version keyword at the root level.\n */\n jsonSchema () {\n const exporter = new JSONSchemaExporter()\n return exporter.export(this)\n }\n\n /**\n * Returns a validator function which throws ValidationError if the value it\n * is asked to validate does not match the schema.\n *\n * Locks the current schema.\n *\n * @param {string} name the name of this schema (to distinguish errors)\n * @param {*} [compiler] the ajv or equivalent JSON schema compiler to use\n * @param {returnSchemaToo} [returnSchemaToo] whether to return jsonSchema as\n * well as the validator\n * @returns {Function} call on a value to validate it; throws on error\n */\n compile (name, compiler, returnSchemaToo) {\n assert.ok(name, 'name is required')\n if (!compiler) {\n if (!ajv) {\n ajv = new (require('ajv'))({\n allErrors: true,\n useDefaults: true,\n strictSchema: false\n })\n }\n compiler = ajv\n }\n this.lock()\n const jsonSchema = this.jsonSchema()\n const validate = compiler.compile(jsonSchema)\n const assertValid = v => {\n if (!validate(v)) {\n throw new ValidationError(name, v, validate.errors, jsonSchema)\n }\n }\n if (returnSchemaToo) {\n return { jsonSchema, assertValid }\n }\n return assertValid\n }\n\n /**\n * See {@link compile}.\n * @returns {Object} contains jsonSchema and assertValid\n */\n getValidatorAndJSONSchema (name, compiler) {\n return this.compile(name, compiler, true)\n }\n\n /**\n * @return A copy of the Todea Schema object. Locked objects become unlocked.\n *\n */\n copy () {\n const ret = new this.constructor()\n ret.__properties = deepcopy(this.__properties)\n ret.__isOptional = this.__isOptional\n return ret\n }\n\n // max / min support\n /**\n * Validate input to min/max.\n * @param {String} name Property name\n * @param {Integer} val A non-negative integer for min/max.\n */\n __validateRangeProperty (name, val) {\n assert.ok(Number.isInteger(val), `${name} must be an integer`)\n assert.ok(val >= 0, `${name} must be a non-negative number`)\n }\n\n /**\n * Set a min property depending on schema type.\n * @param {Integer} val A non-negative integer for min/max.\n */\n min (val) {\n const name = this.constructor.MIN_PROP_NAME\n this.__validateRangeProperty(name, val)\n const max = this.getProp(this.constructor.MAX_PROP_NAME)\n assert.ok(max === undefined || max >= val, 'min must be less than max')\n return this.__setProp(name, val)\n }\n\n /**\n * Set a max property depending on schema type.\n * @param {Integer} val A non-negative integer for min/max.\n */\n max (val) {\n const name = this.constructor.MAX_PROP_NAME\n this.__validateRangeProperty(name, val)\n const min = this.getProp(this.constructor.MIN_PROP_NAME)\n assert.ok(min === undefined || min <= val, 'max must be more than min')\n return this.__setProp(name, val)\n }\n}\n\n/**\n * The ObjectSchema class.\n */\nclass ObjectSchema extends BaseSchema {\n static JSON_SCHEMA_TYPE = 'object'\n static MAX_PROP_NAME = 'maxProperties'\n static MIN_PROP_NAME = 'minProperties'\n\n /**\n * Creates an object schema object.\n * @param {Object} [props={}] Keys must be strings, values must be schema\n * objects. Passing props is the same as calling S.obj().props(props).\n */\n constructor (props = {}) {\n super()\n this.objectSchemas = {}\n this.patternSchemas = {}\n this.props(props)\n }\n\n /**\n * Set an object schema's object property.\n * @param {String} name The name of the property.\n * @param {BaseSchema} schema Any subclass of BaseSchema. Schema gets locked.\n */\n prop (name, schema) {\n assert.ok(!this.__isLocked,\n 'Schema is locked. Call copy then further modify the schema')\n assert.ok(typeof name === 'string', 'Property name must be strings.')\n const properties = this.__setDefaultProp('properties', {})\n assert.ok(!Object.prototype.hasOwnProperty.call(properties, name),\n `Property with key ${name} already exists`)\n assert.ok(schema !== undefined, `Property ${name} must define a schema`)\n\n this.objectSchemas[name] = schema.lock()\n properties[name] = schema.properties()\n if (schema.required) {\n this.__setDefaultProp('required', []).push(name)\n }\n return this\n }\n\n /**\n * A mapping of property names to schemas. Calls this.prop() in a loop.\n * @param {Object} props Keys must be strings, values must be schema\n * objects.\n */\n props (props) {\n for (const [name, p] of Object.entries(props)) {\n this.prop(name, p)\n }\n return this\n }\n\n /**\n * A mapping of propertyProperties to schemas.\n * @param {Object} props Keys must be regex, values must be schema\n */\n patternProps (props) {\n for (const [name, schema] of Object.entries(props)) {\n const properties = this.__setDefaultProp('patternProperties', {})\n assert.ok(!Object.prototype.hasOwnProperty.call(properties, name),\n `Pattern ${name} already exists`)\n const anchoredName = getAnchoredPattern(name)\n this.patternSchemas[anchoredName] = schema.lock()\n properties[anchoredName] = schema.properties()\n }\n return this\n }\n\n copy () {\n const ret = super.copy()\n Object.assign(ret.objectSchemas, this.objectSchemas)\n Object.assign(ret.patternSchemas, this.patternSchemas)\n return ret\n }\n\n properties () {\n const ret = super.properties()\n // Allow any key if no key is defined.\n const hasProperty = Object.keys(this.objectSchemas).length > 0 ||\n Object.keys(this.patternSchemas).length > 0\n const hasAdditionalProperties = !!this.additionalProperties // make it bool\n ret.additionalProperties = !hasProperty || hasAdditionalProperties\n return ret\n }\n\n export (visitor) {\n return visitor.exportObject(this)\n }\n}\n\n/**\n * The ArraySchema class.\n */\nclass ArraySchema extends BaseSchema {\n static JSON_SCHEMA_TYPE = 'array'\n static MAX_PROP_NAME = 'maxItems'\n static MIN_PROP_NAME = 'minItems'\n\n /**\n * Creates an array schema object.\n * @param {BaseSchema} [items] An optional parameter to items(). If provided,\n * it is the same as calling S.arr().items(items).\n */\n constructor (items) {\n super()\n this.itemsSchema = undefined\n if (items) {\n this.items(items)\n }\n }\n\n /**\n * Set the schema for items in array\n * @param {BaseSchema} items Any subclass of BaseSchema. Schema gets locked.\n */\n items (items) {\n assert.ok(!this.itemsSchema, 'Items is already set.')\n this.itemsSchema = items.lock()\n this.__setProp('items', items.properties())\n return this\n }\n\n copy () {\n const ret = super.copy()\n ret.itemsSchema = this.itemsSchema\n return ret\n }\n\n export (visitor) {\n return visitor.exportArray(this)\n }\n}\n\n/**\n * The NumberSchema class.\n */\nclass NumberSchema extends BaseSchema {\n static JSON_SCHEMA_TYPE = 'number'\n static MAX_PROP_NAME = 'maximum'\n static MIN_PROP_NAME = 'minimum'\n\n constructor () {\n super()\n this.__isFloat = false\n }\n\n /**\n * Validate input to min/max.\n * @param {String} name Property name\n * @param {Integer} val A finite number for min/max.\n */\n __validateRangeProperty (name, val) {\n assert.ok(Number.isFinite(val), `${name} must be a number`)\n }\n\n asFloat () {\n assert(!this.__isLocked, 'Schema is locked')\n this.__isFloat = true\n return this\n }\n\n get isFloat () {\n return this.__isFloat\n }\n\n export (visitor) {\n return visitor.exportNumber(this)\n }\n\n copy () {\n const ret = super.copy()\n ret.__isFloat = this.__isFloat\n return ret\n }\n}\n\n/**\n * The IntegerSchema class.\n */\nclass IntegerSchema extends NumberSchema {\n static JSON_SCHEMA_TYPE = 'integer'\n\n /**\n * Validate input to min/max.\n * @param {String} name Property name\n * @param {Integer} val An integer for min/max.\n */\n __validateRangeProperty (name, val) {\n assert.ok(Number.isInteger(val), `${name} must be an integer`)\n }\n\n /**\n * sets limit on how large max or min can be.\n * Validates current min/max to ensure they work correctly\n */\n __setSafeRangeLimit (val) {\n const max = this.getProp(this.constructor.MAX_PROP_NAME)\n if (max === undefined) {\n this.max(val)\n } else {\n assert.ok(max <= val, `max cannot exceed ${val}`)\n }\n const min = this.getProp(this.constructor.MIN_PROP_NAME)\n if (min === undefined) {\n this.min(-val)\n } else {\n assert.ok(min >= -val, `min must be larger than ${-val}`)\n }\n return this\n }\n\n /**\n * applies range for Int32 values\n */\n asInt32 () {\n return this.__setSafeRangeLimit(INT32_MAX)\n }\n\n /**\n * applies range for int64 values\n */\n asInt64 () {\n return this.__setSafeRangeLimit(INT64_MAX)\n }\n\n asFloat = undefined\n\n export (visitor) {\n return visitor.exportInteger(this)\n }\n}\n\n/**\n * The StringSchema class.\n */\nclass StringSchema extends BaseSchema {\n static JSON_SCHEMA_TYPE = 'string'\n static MAX_PROP_NAME = 'maxLength'\n static MIN_PROP_NAME = 'minLength'\n\n /**\n * Set valid values for the string schema.\n * @param {Array<String>} validValues Valid values for the string. There must\n * be at least 2 valid values.\n */\n enum (validValues) {\n const values = Array.isArray(validValues) ? validValues : [...arguments]\n assert(values.length >= 1, 'Enum must contain at least 1 value.')\n return this.__setProp('enum', values)\n }\n\n /**\n * A pattern for the string.\n * @param {String|RegExp} pattern The pattern for the string. Can be a string\n * with regex syntax, or a RegExp object.\n */\n pattern (pattern) {\n if (pattern instanceof RegExp) {\n pattern = pattern.source\n }\n assert(typeof pattern === 'string', 'Pattern must be a string')\n const anchoredPattern = getAnchoredPattern(pattern)\n return this.__setProp('pattern', anchoredPattern)\n }\n\n export (visitor) {\n return visitor.exportString(this)\n }\n}\n\n/**\n * The BooleanSchema class.\n */\nclass BooleanSchema extends BaseSchema {\n static JSON_SCHEMA_TYPE = 'boolean'\n\n export (visitor) {\n return visitor.exportBoolean(this)\n }\n}\n\n/**\n * The MapSchema class.\n */\nclass MapSchema extends ObjectSchema {\n constructor () {\n super()\n // deprecate obj methods\n this.prop = undefined\n this.props = undefined\n this.patternProps = undefined\n\n this.finalized = false\n this.keySchema = undefined\n this.valueSchema = undefined\n }\n\n /**\n * Set a key pattern for the map.\n * @param {String} keyPattern A pattern for keys\n */\n keyPattern (pattern) {\n assert(!this.keySchema, 'key pattern already set')\n this.keySchema = S.str.pattern(pattern).lock()\n this.__tryFinalizeSchema()\n return this\n }\n\n /**\n * Set a value schema for the map.\n * @param {BaseSchema} value Any subclass of BaseSchema for the values of map\n */\n value (value) {\n assert(!this.valueSchema, 'value schema already set')\n assert(value.required, 'value must be required')\n this.valueSchema = value.lock()\n this.__tryFinalizeSchema()\n return this\n }\n\n lock () {\n this.__finalizeSchema()\n return super.lock()\n }\n\n __finalizeSchema () {\n assert(this.valueSchema, 'Must have a value schema')\n if (!this.keySchema) {\n this.keySchema = S.str\n }\n this.__tryFinalizeSchema()\n }\n\n __tryFinalizeSchema () {\n if (this.keySchema && this.valueSchema && !this.finalized) {\n this.finalized = true\n super.patternProps({\n [this.keySchema?.getProp('pattern') ?? '.*']: this.valueSchema\n })\n }\n }\n\n export (visitor) {\n this.__finalizeSchema()\n return visitor.exportMap(this)\n }\n\n copy () {\n const ret = super.copy()\n ret.finalized = this.finalized\n ret.keySchema = this.keySchema.copy()\n ret.valueSchema = this.valueSchema.copy()\n return ret\n }\n}\n\nclass MediaSchema extends StringSchema {\n type (t) {\n this.__setProp('contentMediaType', t)\n return this\n }\n\n encoding (e) {\n assert(['binary', 'base64', 'utf-8'].includes(e),\n 'Encoding must be binary, base64 or utf-8')\n this.__setProp('contentEncoding', e)\n return this\n }\n\n export (visitor) {\n return visitor.exportMedia(this)\n }\n}\n\nclass JSONSchemaExporter {\n constructor () {\n const methods = [\n 'exportString',\n 'exportInteger',\n 'exportNumber',\n 'exportObject',\n 'exportArray',\n 'exportBoolean',\n 'exportMap',\n 'exportMedia'\n ]\n\n for (const method of methods) {\n Object.defineProperty(this, method, {\n get: () => {\n return (schema) => {\n return schema.properties()\n }\n }\n })\n }\n }\n\n export (schema) {\n const ret = deepcopy(schema.export(this))\n ret.$schema = 'http://json-schema.org/draft-07/schema#'\n return ret\n }\n}\n\n/**\n * The S object to be exported.\n * Noteworthily, it is safe to deprecate certain schema types simply by\n * deleting the corresponding accessor.\n */\nclass S {\n /**\n * @param {Object} object See {@link ObjectSchema#constructor}\n * @return A new ObjectSchema object.\n */\n static obj (object) { return new ObjectSchema(object) }\n\n /**\n * @param {BaseSchema} schema See {@link ArraySchema#constructor}\n * @return A new ArraySchema object.\n */\n static arr (schema) { return new ArraySchema(schema) }\n\n /**\n * Get a new NumberSchema object.\n */\n static get double () { return new NumberSchema() }\n\n /**\n * Get a new IntegerSchema object.\n */\n static get int () { return new IntegerSchema() }\n\n /**\n * Get a new StringSchema object.\n */\n static get str () { return new StringSchema() }\n\n /**\n * Get a new BooleanSchema object.\n */\n static get bool () { return new BooleanSchema() }\n\n /**\n * Get a new MapSchema object.\n */\n static get map () { return new MapSchema() }\n\n /**\n * Get a new MediaSchema object.\n */\n static get media () { return new MediaSchema() }\n /**\n * Lock all schemas in a dictionary (in-place).\n * @param {Object<Schema>} schemas a map of schema values\n * @returns the input map of schema values\n */\n static lock (schemas) {\n Object.values(schemas).forEach(x => x.lock())\n return schemas\n }\n\n /**\n * Sets all schemas as optional (in-place).\n * @param {Object<Schema>} schemas a map of schema values\n * @returns the input map of schema values\n */\n static optional (schemas) {\n Object.values(schemas).forEach(x => x.optional())\n return schemas\n }\n\n static PATTERN = {\n UUID_PATTERN: /^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/\n }\n\n /**\n * Common schemas.\n */\n static SCHEMAS = S.lock({\n UUID: S.str.desc('An UUID. It is normally generated by calling uuidv4().')\n .pattern(S.PATTERN.UUID_PATTERN),\n STR_ANDU: S.str.desc('Only hyphens, underscores, letters and numbers are permitted.')\n .pattern(/^[-_a-zA-Z0-9]+$/),\n // oversimplified, quick regex to check that a string looks like an email\n STR_EMAIL: S.str.pattern(/^[^A-Z ]+@.+$/)\n .desc('an e-mail address (lowercase only)').lock(),\n TIMESTAMP: S.str\n .pattern(/\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d{3}Z/)\n .desc(`An UTC timestamp with millisecond precision, for example,\n 2021-02-15T20:15:59.321Z`),\n TIMESTAMP_WITH_TZ: S.str\n .pattern(/\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d(\\.\\d*)?([+-][0-2]\\d:[0-5]\\d|Z)/)\n .desc(`Timestamp with time zone and optional millisecond precision,\n for example,\n 2021-02-15T20:15:59Z,\n 2022-09-15T16:48:28.9097226Z,\n 2021-02-15T11:55:20-05:00,\n 2021-02-15T11:55:20.9097226+08:00`),\n EPOCH_IN_SECONDS: S.int.min(EPOCH_IN_SECONDS_MIN)\n .max(EPOCH_IN_SECONDS_MAX).desc(`Unix epoch time format in seconds from\n ${TIMESTAMP_MIN} to ${TIMESTAMP_MAX}.`),\n EPOCH_IN_MILLISECONDS: S.int.min(EPOCH_IN_MILLISECONDS_MIN)\n .max(EPOCH_IN_MILLISECONDS_MAX).desc(`Unix epoch time format in\n milliseconds from ${TIMESTAMP_MIN} to ${TIMESTAMP_MAX}.`).asInt64()\n })\n\n /** Thrown if validation fails. */\n static ValidationError = ValidationError\n\n static INT32_MAX = INT32_MAX\n\n static INT32_MIN = INT32_MIN\n\n static INT64_MAX = INT64_MAX\n\n static INT64_MIN = INT64_MIN\n}\n\nfunction getAnchoredPattern (pattern) {\n let anchoredName = pattern\n if (pattern[0] !== '^') {\n anchoredName = '^' + pattern\n }\n if (pattern[pattern.length - 1] !== '$') {\n anchoredName += '$'\n }\n return anchoredName\n}\n\nmodule.exports = S\n","{\n \"name\": \"@polytric/openws-spec\",\n \"version\": \"0.0.2\",\n \"description\": \"Polytric OpenWS Specification\",\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./builder\": {\n \"types\": \"./dist/builder.d.ts\",\n \"import\": \"./dist/builder.js\",\n \"require\": \"./dist/builder.cjs\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\",\n \"import\": \"./dist/types.js\",\n \"require\": \"./dist/types.cjs\"\n }\n },\n \"files\": [\n \"dist\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"keywords\": [\n \"openws\",\n \"specification\",\n \"websocket\"\n ],\n \"author\": \"Polytric\",\n \"license\": \"Apache-2.0\",\n \"scripts\": {\n \"build\": \"pnpm emit && tsup\",\n \"emit\": \"tsx -e \\\"import schema from './src/spec-schema.ts'; console.log(JSON.stringify(schema.jsonSchema()))\\\" > ./src/spec-schema.json\",\n \"prepublishOnly\": \"pnpm build\",\n \"test:builder\": \"nodemon -w dist -w test/builder.cjs test/builder.cjs\",\n \"test:validate\": \"tsx test/validate-spec.ts\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"ajv\": \"^8.17.1\"\n },\n \"devDependencies\": {\n \"@pocketgems/schema\": \"^0.1.3\",\n \"nodemon\": \"^3.1.11\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\"\n },\n \"packageManager\": \"pnpm@10.26.1\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import S from '@pocketgems/schema'\n\nconst keyPattern = '[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?'\n\nconst messageSchema = S.obj({\n payload: S.obj({}).desc(\n 'Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this'\n ),\n description: S.str.optional(),\n from: S.arr(S.str).desc('A list of roles that can send this message').optional(),\n})\n\nmessageSchema.additionalProperties = true\n\nconst endpointSchema = S.obj({\n host: S.str,\n port: S.int.min(1).max(65535),\n path: S.str,\n})\n\nendpointSchema.additionalProperties = true\n\nconst roleSchema = S.obj({\n endpoints: S.arr(endpointSchema)\n .min(1)\n .optional()\n .desc(\n 'A role can declare an endpoint to accept connections from other roles, normally used by servers'\n ),\n messages: S.map\n .keyPattern(keyPattern)\n .value(messageSchema)\n .desc(\n \"A message accepted by the role and handled by the role, and roles can send messages other roles accepts. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented).\"\n ),\n description: S.str.optional(),\n})\n\nroleSchema.additionalProperties = true\n\nconst networkSchema = S.obj({\n roles: S.map\n .min(1)\n .keyPattern(keyPattern)\n .desc(\n 'A network is a collection of roles that exchange messages. Multiple roles can coexist in the same network. The simplest network contains a server-client pair.'\n )\n .value(roleSchema),\n description: S.str.optional(),\n})\n\nnetworkSchema.additionalProperties = true\n\nconst openWsSchema = S.obj({\n openws: S.str.enum('0.0.1', '0.0.2').desc('The OpenWS schema version'),\n title: S.str.desc('A title for the overall system.').optional(),\n description: S.str\n .desc(\n 'A high level description of the overall system, including all networks and all roles'\n )\n .optional(),\n version: S.str.desc('A version string').optional(),\n networks: S.map.min(1).keyPattern(keyPattern).value(networkSchema),\n})\n\nopenWsSchema.additionalProperties = true\n\nexport default openWsSchema\n","{\"type\":\"object\",\"properties\":{\"openws\":{\"type\":\"string\",\"enum\":[\"0.0.1\",\"0.0.2\"],\"description\":\"The OpenWS schema version\"},\"title\":{\"type\":\"string\",\"description\":\"A title for the overall system.\"},\"description\":{\"type\":\"string\",\"description\":\"A high level description of the overall system, including all networks and all roles\"},\"version\":{\"type\":\"string\",\"description\":\"A version string\"},\"networks\":{\"type\":\"object\",\"minProperties\":1,\"patternProperties\":{\"^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$\":{\"type\":\"object\",\"properties\":{\"roles\":{\"type\":\"object\",\"minProperties\":1,\"description\":\"A network is a collection of roles that exchange messages. Multiple roles can coexist in the same network. The simplest network contains a server-client pair.\",\"patternProperties\":{\"^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$\":{\"type\":\"object\",\"properties\":{\"endpoints\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"host\":{\"type\":\"string\"},\"port\":{\"type\":\"integer\",\"minimum\":1,\"maximum\":65535},\"path\":{\"type\":\"string\"}},\"required\":[\"host\",\"port\",\"path\"],\"additionalProperties\":true},\"minItems\":1,\"description\":\"A role can declare an endpoint to accept connections from other roles, normally used by servers\"},\"messages\":{\"type\":\"object\",\"patternProperties\":{\"^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$\":{\"type\":\"object\",\"properties\":{\"payload\":{\"type\":\"object\",\"description\":\"Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this\",\"additionalProperties\":true},\"description\":{\"type\":\"string\"},\"from\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"description\":\"A list of roles that can send this message\"}},\"required\":[\"payload\"],\"additionalProperties\":true}},\"description\":\"A message accepted by the role and handled by the role, and roles can send messages other roles accepts. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented).\",\"additionalProperties\":false},\"description\":{\"type\":\"string\"}},\"required\":[\"messages\"],\"additionalProperties\":true}},\"additionalProperties\":false},\"description\":{\"type\":\"string\"}},\"required\":[\"roles\"],\"additionalProperties\":true}},\"additionalProperties\":false}},\"required\":[\"openws\",\"networks\"],\"additionalProperties\":true,\"$schema\":\"http://json-schema.org/draft-07/schema#\"}\n","import pkg from '../package.json'\n\nimport specSchemaValidator from './spec-schema'\n\nexport const VERSION = pkg.version\n\nexport { default as specSchema } from './spec-schema.json'\n\nlet validator: (spec: any) => void\n\nexport function validate(spec: any): void {\n validator = validator ?? specSchemaValidator.compile('Validator')\n validator(spec)\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AACA,WAAO,UAA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escriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { SchemaObject } from 'ajv'\n\ntype PrimitiveValue = string | number | boolean | null\ntype JsonObject = { [key: string]: JsonValue }\nexport type JsonValue = PrimitiveValue | Array<JsonValue> | JsonObject\n\nexport interface CommonMetadata {\n name: string\n description?: string\n version?: string\n\n [key: string]: any\n}\n\nexport interface Message extends CommonMetadata {\n payload: SchemaObject\n from?: string[]\n}\n\nexport interface Endpoint {\n scheme: string\n host: string\n port: number\n path: string\n}\n\nexport interface Role extends CommonMetadata {\n messages: { [key: string]: Message }\n endpoints?: Endpoint[]\n}\n\nexport interface Network extends CommonMetadata {\n roles: { [key: string]: Role }\n}\n\nexport interface Spec extends CommonMetadata {\n openws: string\n networks: { [key: string]: Network }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,42 @@
1
+ import { SchemaObject } from 'ajv';
2
+
3
+ type PrimitiveValue = string | number | boolean | null;
4
+ type JsonObject = {
5
+ [key: string]: JsonValue;
6
+ };
7
+ type JsonValue = PrimitiveValue | Array<JsonValue> | JsonObject;
8
+ interface CommonMetadata {
9
+ name: string;
10
+ description?: string;
11
+ version?: string;
12
+ [key: string]: any;
13
+ }
14
+ interface Message extends CommonMetadata {
15
+ payload: SchemaObject;
16
+ from?: string[];
17
+ }
18
+ interface Endpoint {
19
+ scheme: string;
20
+ host: string;
21
+ port: number;
22
+ path: string;
23
+ }
24
+ interface Role extends CommonMetadata {
25
+ messages: {
26
+ [key: string]: Message;
27
+ };
28
+ endpoints?: Endpoint[];
29
+ }
30
+ interface Network extends CommonMetadata {
31
+ roles: {
32
+ [key: string]: Role;
33
+ };
34
+ }
35
+ interface Spec extends CommonMetadata {
36
+ openws: string;
37
+ networks: {
38
+ [key: string]: Network;
39
+ };
40
+ }
41
+
42
+ export type { CommonMetadata, Endpoint, JsonValue, Message, Network, Role, Spec };
@@ -0,0 +1,42 @@
1
+ import { SchemaObject } from 'ajv';
2
+
3
+ type PrimitiveValue = string | number | boolean | null;
4
+ type JsonObject = {
5
+ [key: string]: JsonValue;
6
+ };
7
+ type JsonValue = PrimitiveValue | Array<JsonValue> | JsonObject;
8
+ interface CommonMetadata {
9
+ name: string;
10
+ description?: string;
11
+ version?: string;
12
+ [key: string]: any;
13
+ }
14
+ interface Message extends CommonMetadata {
15
+ payload: SchemaObject;
16
+ from?: string[];
17
+ }
18
+ interface Endpoint {
19
+ scheme: string;
20
+ host: string;
21
+ port: number;
22
+ path: string;
23
+ }
24
+ interface Role extends CommonMetadata {
25
+ messages: {
26
+ [key: string]: Message;
27
+ };
28
+ endpoints?: Endpoint[];
29
+ }
30
+ interface Network extends CommonMetadata {
31
+ roles: {
32
+ [key: string]: Role;
33
+ };
34
+ }
35
+ interface Spec extends CommonMetadata {
36
+ openws: string;
37
+ networks: {
38
+ [key: string]: Network;
39
+ };
40
+ }
41
+
42
+ export type { CommonMetadata, Endpoint, JsonValue, Message, Network, Role, Spec };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,30 +1,57 @@
1
1
  {
2
2
  "name": "@polytric/openws-spec",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Polytric OpenWS Specification",
5
- "module": "commonjs",
6
- "main": "index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./builder": {
15
+ "types": "./dist/builder.d.ts",
16
+ "import": "./dist/builder.js",
17
+ "require": "./dist/builder.cjs"
18
+ },
19
+ "./types": {
20
+ "types": "./dist/types.d.ts",
21
+ "import": "./dist/types.js",
22
+ "require": "./dist/types.cjs"
23
+ }
24
+ },
7
25
  "files": [
8
- "index.js",
9
- "spec.json",
26
+ "dist",
10
27
  "LICENSE",
11
- "spec.js"
28
+ "README.md"
12
29
  ],
13
30
  "keywords": [
14
- "websocket",
15
31
  "openws",
16
- "specification"
32
+ "specification",
33
+ "websocket"
17
34
  ],
18
- "publishConfig": {
19
- "access": "public"
20
- },
21
35
  "author": "Polytric",
22
36
  "license": "Apache-2.0",
23
37
  "dependencies": {
24
- "@pocketgems/schema": "^0.1.3"
38
+ "ajv": "^8.17.1"
39
+ },
40
+ "devDependencies": {
41
+ "@pocketgems/schema": "^0.1.3",
42
+ "nodemon": "^3.1.11",
43
+ "tsup": "^8.5.1",
44
+ "tsx": "^4.21.0",
45
+ "typescript": "^5.9.3"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
25
49
  },
26
50
  "scripts": {
27
- "emit": "node spec.js > spec.json",
28
- "test": "node test/validate-spec.js && echo valid"
51
+ "build": "pnpm emit && tsup",
52
+ "emit": "tsx -e \"import schema from './src/spec-schema.ts'; console.log(JSON.stringify(schema.jsonSchema()))\" > ./src/spec-schema.json",
53
+ "test:builder": "nodemon -w dist -w test/builder.cjs test/builder.cjs",
54
+ "test:validate": "tsx test/validate-spec.ts",
55
+ "typecheck": "tsc --noEmit"
29
56
  }
30
57
  }
package/index.js DELETED
@@ -1,11 +0,0 @@
1
- const spec = require('./spec')
2
-
3
- let validator
4
-
5
- module.exports = {
6
- spec: require('./spec.json'),
7
- validate: (schema) => {
8
- validator = validator ?? spec.compile('Validator')
9
- validator(schema)
10
- }
11
- }
package/spec.js DELETED
@@ -1,62 +0,0 @@
1
- const S = require("@pocketgems/schema");
2
-
3
- const keyPattern = "[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]";
4
-
5
- const OpenWSSchema = S.obj({
6
- openws: S.str.enum("0.0.1").desc("The OpenWS schema version"),
7
- info: S.obj({
8
- title: S.str.desc("A title for the overall system.").optional(),
9
- description: S.str
10
- .desc(
11
- "A high level description of the overall system, including all networks and all participants"
12
- )
13
- .optional(),
14
- version: S.str.desc("A version string").optional(),
15
- }),
16
- networks: S.map
17
- .min(1)
18
- .keyPattern(keyPattern)
19
- .value(
20
- S.obj({
21
- participants: S.map
22
- .min(2)
23
- .keyPattern(keyPattern)
24
- .desc(
25
- "A participant is a server or client in the network. Multiple server and clients can coexist in the same network. The simplest network contains a server-client pair."
26
- )
27
- .value(
28
- S.obj({
29
- endpoints: S.arr(
30
- S.obj({
31
- host: S.str,
32
- port: S.int.min(0).max(65535).default(443),
33
- path: S.str.default('/'),
34
- })
35
- ).min(1).optional().desc('A participant can declare an endpoint to accept connections from other participants, normally used by servers'),
36
- handlers: S.map
37
- .min(1)
38
- .keyPattern(keyPattern)
39
- .value(
40
- S.obj({
41
- payload: S.obj({})
42
- .min(1)
43
- .desc(
44
- "Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this"
45
- ),
46
- description: S.str.optional()
47
- })
48
- )
49
- .desc(
50
- "A handler is implemented by a participant, and participants can invoke others handlers. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented)."
51
- ),
52
- })
53
- ),
54
- })
55
- ),
56
- });
57
-
58
- if (require.main === module) {
59
- console.log(JSON.stringify(OpenWSSchema.jsonSchema()));
60
- }
61
-
62
- module.exports = OpenWSSchema;
package/spec.json DELETED
@@ -1 +0,0 @@
1
- {"type":"object","properties":{"openws":{"type":"string","enum":["0.0.1"],"description":"The OpenWS schema version"},"info":{"type":"object","properties":{"title":{"type":"string","description":"A title for the overall system."},"description":{"type":"string","description":"A high level description of the overall system, including all networks and all participants"},"version":{"type":"string","description":"A version string"}},"additionalProperties":false},"networks":{"type":"object","minProperties":1,"patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"participants":{"type":"object","minProperties":2,"description":"A participant is a server or client in the network. Multiple server and clients can coexist in the same network. The simplest network contains a server-client pair.","patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"endpoints":{"type":"array","items":{"type":"object","properties":{"host":{"type":"string"},"port":{"type":"integer","minimum":0,"maximum":65535,"default":443},"path":{"type":"string","default":"/"}},"required":["host","port","path"],"additionalProperties":false},"minItems":1,"description":"A participant can declare an endpoint to accept connections from other participants, normally used by servers"},"handlers":{"type":"object","minProperties":1,"patternProperties":{"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$":{"type":"object","properties":{"payload":{"type":"object","minProperties":1,"description":"Must be a valid JSON schema spec. For brevity, openws omits this spec, but implementations should valid this","additionalProperties":true},"description":{"type":"string"}},"required":["payload"],"additionalProperties":false}},"description":"A handler is implemented by a participant, and participants can invoke others handlers. The OpenWS spec only defines the shape of the payload, and how things get encoded / decoded on the wire, it doesn't determine behavior (through through description the behavior can be documented).","additionalProperties":false}},"required":["handlers"],"additionalProperties":false}},"additionalProperties":false}},"required":["participants"],"additionalProperties":false}},"additionalProperties":false}},"required":["openws","info","networks"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}