{"_id":"@dangzhuotong/schemastery","name":"@dangzhuotong/schemastery","dist-tags":{"latest":"3.18.1"},"versions":{"3.18.1":{"name":"@dangzhuotong/schemastery","description":"Type driven schema validator","version":"3.18.1","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/deepseek-ai/deepseek-harness.git","directory":"vendor/schemastery"},"type":"module","main":"lib/index.cjs","module":"lib/index.mjs","types":"lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.cjs"},"./src/*":"./src/*","./package.json":"./package.json"},"author":{"name":"Shigma","email":"shigma10826@gmail.com"},"license":"MIT","dependencies":{"@standard-schema/spec":"^1.1.0","@dangzhuotong/cosmokit":"^1.8.2"},"_id":"@dangzhuotong/schemastery@3.18.1","gitHead":"53baf21dfae3d134fa248f36dafb4ab1fe28e55c","bugs":{"url":"https://github.com/deepseek-ai/deepseek-harness/issues"},"homepage":"https://github.com/deepseek-ai/deepseek-harness#readme","_integrity":"sha512-qbUx41tqBH3RKJ9YMFc5WZuQq7kvUfdTJ143XSe93AR9YaOV9xjSNO9OOnhZnPWEIin+phKGnnJQHyk3YD2MaA==","_resolved":"D:\\Coding\\deepseek-harness-master\\dist\\npm\\vendor\\dangzhuotong-schemastery-3.18.1.tgz","_from":"file:D:/Coding/deepseek-harness-master/dist/npm/vendor/dangzhuotong-schemastery-3.18.1.tgz","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-qbUx41tqBH3RKJ9YMFc5WZuQq7kvUfdTJ143XSe93AR9YaOV9xjSNO9OOnhZnPWEIin+phKGnnJQHyk3YD2MaA==","shasum":"7e0b12f236015b80e9265674003a67a7ef8ebba7","tarball":"https://registry.npmjs.org/@dangzhuotong/schemastery/-/schemastery-3.18.1.tgz","fileCount":8,"unpackedSize":108060,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFoJ1wJIMizUWBdeIGJGjWM4iWo0l/gcwauNmoznfYOqAiEAwsh28pHafEATntRv8VnrJ4MAoSYDk6xKz8mjCno1/t4="}]},"_npmUser":{"name":"dangzhuotong","email":"353199054@qq.com"},"directories":{},"maintainers":[{"name":"dangzhuotong","email":"353199054@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/schemastery_3.18.1_1787281252631_0.8172390057464567"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-21T03:00:52.376Z","3.18.1":"2026-08-21T03:00:52.784Z","modified":"2026-08-21T03:00:53.061Z"},"maintainers":[{"name":"dangzhuotong","email":"353199054@qq.com"}],"description":"Type driven schema validator","homepage":"https://github.com/deepseek-ai/deepseek-harness#readme","repository":{"type":"git","url":"git+https://github.com/deepseek-ai/deepseek-harness.git","directory":"vendor/schemastery"},"author":{"name":"Shigma","email":"shigma10826@gmail.com"},"bugs":{"url":"https://github.com/deepseek-ai/deepseek-harness/issues"},"license":"MIT","readme":"# Schemastery\n\n[![Codecov](https://img.shields.io/codecov/c/github/shigma/schemastery?style=flat-square)](https://codecov.io/gh/shigma/schemastery)\n[![downloads](https://img.shields.io/npm/dm/schemastery?style=flat-square)](https://www.npmjs.com/package/schemastery)\n[![npm](https://img.shields.io/npm/v/schemastery?style=flat-square)](https://www.npmjs.com/package/schemastery)\n[![GitHub](https://img.shields.io/github/license/shigma/schemastery?style=flat-square)](https://github.com/shigma/schemastery/blob/master/LICENSE)\n\nType Driven Schema Validator.\n\n## Features\n\n- **Lightweight.** Much smaller than other validation libraries.\n- **Easy to use.** You can use any schema as a function or constructor directly.\n- **Powerful.** Schemastery supports some advanced types such as `union`, `intersect` and `transform`.\n- **Extensible.** You can create your own schema types via `Schema.extend()`.\n- **Serializable.** Schema objects can be serialized into JSON and then be hydrated in another environment.\n\n## Basic Examples\n\n### use as validator (JavaScript)\n\n```js\nconst Schema = require('schemastery')\n\nconst validate = Schema.number().default(10)\n\nvalidate(0)     // 0\nvalidate(null)  // 10\nvalidate('')    // TypeError\n```\n\n### use as constructor (TypeScript)\n\n```ts\nimport Schema from 'schemastery'\n\ninterface Config {\n  foo: Record<string, string>\n  bar: string[]\n}\n\nconst Config = Schema.object({\n  foo: Schema.dict(Schema.string()).default({}),\n  bar: Schema.array(Schema.string()).default([]),\n})\n\n// config is an instance of Config\n// in this case, that is { foo: {}, bar: [] }\nconst config = new Config()\n```\n\n## General Types\n\n### Schema.any()\n\nAssert that the value is of any type.\n\n```js\nconst validate = Schema.any()\n\nvalidate()            // undefined\nvalidate(0)           // 0\nvalidate({})          // {}\n```\n\n### Schema.never()\n\nAssert that the value is nullable.\n\n```js\nconst validate = Schema.never()\n\nvalidate()            // undefined\nvalidate(0)           // TypeError\nvalidate({})          // TypeError\n```\n\n### Schema.const(value)\n\nAssert that the value is equal to the given constant.\n\n```js\nconst validate = Schema.const(10)\n\nvalidate(10)          // 10\nvalidate(0)           // TypeError\n```\n\n### Schema.number()\n\nAssert that the value is a number.\n\n```js\nconst validate = Schema.number()\n\nvalidate()            // undefined\nvalidate(1)           // 1\nvalidate('')          // TypeError\n```\n\n### Schema.string()\n\nAssert that the value is a string.\n\n```js\nconst validate = Schema.string()\n\nvalidate()            // undefined\nvalidate(0)           // TypeError\nvalidate('foo')       // 'foo'\n```\n\n### Schema.boolean()\n\nAssert that the value is a boolean.\n\n```js\nconst validate = Schema.boolean()\n\nvalidate()            // undefined\nvalidate(0)           // TypeError\nvalidate(true)        // true\n```\n\n### Schema.is(constructor)\n\nAssert that the value is an instance of the given constructor.\n\n```js\nconst validate = Schema.is(RegExp)\n\nvalidate()            // undefined\nvalidate(/foo/)       // /foo/\nvalidate('foo')       // TypeError\n```\n\n### Schema.array(inner)\n\nAssert that the value is an array of `inner`. The default value will be `[]` if not specified.\n\n```js\nconst validate = Schema.array(Schema.number())\n\nvalidate()                  // []\nvalidate(0)                 // TypeError\nvalidate([0, 1])            // [0, 1]\nvalidate([0, '1'])          // TypeError\n```\n\n### Schema.dict(inner)\n\nAssert that the value is a dictionary of `inner`. The default value will be `{}` if not specified.\n\n```js\nconst validate = Schema.dict(Schema.number())\n\nvalidate()                  // {}\nvalidate(0)                 // TypeError\nvalidate({ a: 0, b: 1 })    // { a: 0, b: 1 }\nvalidate({ a: 0, b: '1' })  // TypeError\n```\n\n### Schema.tuple(list)\n\nAssert that the value is a tuple whose each element is of corresponding subtype. The default value will be `[]` if not specified.\n\n```js\nconst validate = Schema.tuple([\n  Schema.number(),\n  Schema.string(),\n])\n\nvalidate()                  // []\nvalidate([0])               // { a: 0 }\nvalidate([0, 1])            // TypeError\nvalidate([0, '1'])          // [0, '1']\n```\n\n### Schema.object(dict)\n\nAssert that the value is an object whose each property is of corresponding subtype. The default value will be `{}` if not specified.\n\n```js\nconst validate = Schema.object({\n  a: Schema.number(),\n  b: Schema.string(),\n})\n\nvalidate()                  // {}\nvalidate({ a: 0 })          // { a: 0 }\nvalidate({ a: 0, b: 1 })    // TypeError\nvalidate({ a: 0, b: '1' })  // { a: 0, b: '1' }\n```\n\n### Schema.union(list)\n\nAssert that the value is one of the specified types.\n\n```js\nconst validate = Schema.union([\n  Schema.number(),\n  Schema.string(),\n])\n\nvalidate()                  // undefined\nvalidate(0)                 // 0\nvalidate('1')               // '1'\nvalidate(true)              // TypeError\n```\n\n### Schema.intersect(list)\n\nAssert that the value should match each specified type.\n\n```js\nconst validate = Schema.intersect([\n  Schema.object({ a: Schema.string().required() }),\n  Schema.object({ b: Schema.number().default(0) }),\n])\n\nvalidate()                  // TypeError\nvalidate({ a: '' })         // { a: '', b: 0 }\nvalidate({ a: '', b: 1 })   // { a: '', b: 1 }\nvalidate({ a: '', b: '2' }) // TypeError\n```\n\n### Schema.transform(inner, callback)\n\nAssert that the value is of the specified subtype and then transformed by `callback`.\n\n```js\nconst validate = Schema.transform(Schema.number().default(0), n => n + 1)\n\nvalidate()                  // 1\nvalidate('0')               // TypeError\nvalidate(10)                // 11\n```\n\n## Instance Methods\n\nNote: `default` and `required` are mutually exclusive.\n\n### schema.required()\n\nAssert that the value is not nullable.\n\n### schema.default(value)\n\nSet the fallback value when nullable.\n\n### schema.description(text)\n\nSet the description of the schema.\n\n### schema.simplify(value)\n\nNormalize a value by removing parts that are equal to schema defaults. This is\nuseful when storing user configuration and keeping persisted files compact.\n\n```js\nconst Config = Schema.object({\n  foo: Schema.string().default(''),\n  bar: Schema.number().default(0),\n})\n\nConfig.simplify({ foo: '', bar: 1 }) // { bar: 1 }\n```\n\n## Validation Options\n\nAll schemas are callable. The second argument accepts validation options:\n\n```js\nconst Config = Schema.object({\n  foo: Schema.number(),\n})\n\nConfig({ foo: '1' }, { autofix: true }) // {}\n```\n\n- `autofix`: remove invalid object properties where possible.\n- `ignore`: skip validation for selected values and schema nodes.\n- `path`: provide an initial path for nested validation errors.\n\n## Shorthand Syntax\n\nSome shorthand syntax is available for inner types.\n\n- `undefined` -> `Schema.any()`\n- `String` -> `Schema.string()`\n- `Number` -> `Schema.number()`\n- `Boolean` -> `Schema.boolean()`\n- `1` -> `Schema.const(1)` (only for primitive types)\n- `Date` -> `Schema.is(Date)`\n\n```js\nSchema.array(String)        // Schema.array(Schema.string())\nSchema.dict(RegExp)         // Schema.dict(Schema.is(RegExp))\nSchema.union([1, 2])        // Schema.union([Schema.const(1), Schema.const(2)])\n```\n\nYou can also use `Schema.from()` to get the inferred schema from a shorthand value.\n\n```js\nSchema.from()               // Schema.any()\nSchema.from(Date)           // Schema.is(Date)\nSchema.from('foo')          // Schema.const('foo')\n```\n\n## Advanced Examples\n\nHere are some examples which demonstrate how to define advanced types.\n\n### Enumeration\n\n```js\nconst Enum = Schema.union(['red', 'blue'])\n\nEnum('red')                 // 'red'\nEnum('blue')                // 'blue'\nEnum('green')               // TypeError\n```\n\n### ToString\n\n```js\nconst ToString = Schema.transform(Schema.any(), v => String(v))\n\nToString('')                // ''\nToString(0)                 // '0'\nToString({})                // '{}'\n```\n\n### Listable\n\n```js\nconst Listable = Schema.union([\n  Schema.array(Number),\n  Schema.transform(Number, n => [n]),\n]).default([])\n\nListable()                  // []\nListable(0)                 // [0]\nListable([1, 2])            // [1, 2]\n```\n\n### Alias\n\n```js\nconst Config = Schema.dict(Number, Schema.union([\n  'foo',\n  Schema.transform('bar', () => 'foo'),\n]))\n\nConfig({ foo: 1 })          // { foo: 1 }\nConfig({ bar: 2 })          // { foo: 2 }\nConfig({ bar: '3' })        // TypeError\n```\n\n## Extensibility\n\nCustom schema types are registered with `Schema.extend(type, resolve)`. A\nresolver receives the input value, schema node, validation options, and a strict\nflag. Return `[value]` for accepted input, or `[value, adapted]` when the caller\nshould write an adapted value back to the source object.\n\n```js\nSchema.extend('trimmed', (data, schema, options) => {\n  if (typeof data !== 'string') {\n    throw new Schema.ValidationError(`expected string but got ${data}`, options)\n  }\n  return [data.trim()]\n})\n```\n\n## Serializability\n\n```js\nconst schema1 = Schema.object({\n  foo: Schema.string(),\n  bar: Schema.number(),\n})\n\n// should have the same effect as schema1\nconst schema2 = new Schema(JSON.parse(JSON.stringify(schema1)))\n```\n\nSchemastery also exposes the Standard Schema `~standard` property, so compatible\ntools can validate values without depending on Schemastery-specific APIs.\n","readmeFilename":"README.md","_rev":"1-deecf88116d74d5afd83ef6718b67037"}