{"_id":"@asyncapi/keeper","_rev":"7-02ceae43b73017824c6fb2a38904389b","name":"@asyncapi/keeper","dist-tags":{"latest":"0.5.0"},"versions":{"0.0.1":{"name":"@asyncapi/keeper","version":"0.0.1","author":{"name":"Adi Boghawala","email":"boghawalaadi@gmail.com"},"license":"Apache-2.0","_id":"@asyncapi/keeper@0.0.1","maintainers":[{"name":"fmvilas","email":"fmvilas@gmail.com"},{"name":"derberg","email":"lpgornicki@gmail.com"},{"name":"asyncapi-bot","email":"derberg@wp.pl"}],"homepage":"https://github.com/asyncapi/generator#readme","bugs":{"url":"https://github.com/asyncapi/generator/issues"},"dist":{"shasum":"e17581c464169168e339015fc9f3125e543a2a3d","tarball":"https://registry.npmjs.org/@asyncapi/keeper/-/keeper-0.0.1.tgz","fileCount":7,"integrity":"sha512-7q6tVWhgULb4tEBgS0Cy7n6Ohh7P6mVVrU+W1rXiLNKdrkn7MzINDqL9/axHB+RZKJpl0KkJS7TgnaPAbReT5A==","signatures":[{"sig":"MEUCIGNdvI1dsyNuOlGbWw1Z4W3Jvc5aDPIOrWIJjgokHwqTAiEAwIX5Y+QZ4hOuSjAIQJOpMciV7cpHQWkLK7dxUngzTW8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16024},"jest":{"transform":{"^.+\\.jsx?$":"jest-esm-transformer"},"setupFiles":["<rootDir>/jest.setup.js"],"moduleNameMapper":{"^nimma/(.*)":"<rootDir>/../../node_modules/nimma/dist/cjs/$1","^nimma/legacy$":"<rootDir>/../../node_modules/nimma/dist/legacy/cjs/index.js","^@hyperjump/browser/jref$":"<rootDir>/../../node_modules/@hyperjump/browser/lib/jref/index.js","^@hyperjump/json-schema/experimental$":"<rootDir>/node_modules/@hyperjump/json-schema/lib/experimental.js"},"moduleFileExtensions":["js","json","jsx"],"transformIgnorePatterns":["node_modules/(?!@hyperjump)"]},"main":"lib/index.js","babel":{"presets":["@babel/preset-env"]},"gitHead":"5757a66b98c1f002f82b4fa16473ba3a27f21f58","scripts":{"lint":"eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore .","test":"npm run pretest && jest --coverage","build":"babel src --out-dir lib","pretest":"npm run build","lint:fix":"eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore . --fix"},"_npmUser":{"name":"asyncapi-bot","email":"derberg@wp.pl"},"repository":{"url":"git+https://github.com/asyncapi/generator.git","type":"git"},"_npmVersion":"10.8.2","description":"AsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07)","directories":{},"_nodeVersion":"18.20.8","dependencies":{"@asyncapi/parser":"^3.4.0","@hyperjump/json-schema":"^1.16.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.3.1","@babel/cli":"^7.25.9","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","jest-esm-transformer":"^1.0.0","@ungap/structured-clone":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/keeper_0.0.1_1756104732662_0.6414802879195312","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@asyncapi/keeper","version":"0.5.0","author":{"name":"Adi Boghawala","email":"boghawalaadi@gmail.com"},"license":"Apache-2.0","_id":"@asyncapi/keeper@0.5.0","maintainers":[{"name":"fmvilas","email":"fmvilas@gmail.com"},{"name":"derberg","email":"lpgornicki@gmail.com"},{"name":"asyncapi-bot","email":"derberg@wp.pl"}],"homepage":"https://github.com/asyncapi/generator#readme","bugs":{"url":"https://github.com/asyncapi/generator/issues"},"dist":{"shasum":"5cfa79ac03daa916cbd08541132751e960b20085","tarball":"https://registry.npmjs.org/@asyncapi/keeper/-/keeper-0.5.0.tgz","fileCount":2,"integrity":"sha512-Zm53UCSyM7miyXJs9GzExPSv4O91zFsCA7qMMjUDMV5UAawgGb8w3nTkMlZFo/16AqvitiYrPx2sttupeG/K2w==","signatures":[{"sig":"MEUCIQC9K8UmqxDKsve/l0Rgk8MeLEMOCu9gSae4UcTZWRgSlwIgFfjr58v18w+SiGGZ+kIkV3g/2iIHObW+diLqXxCuDL0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@asyncapi%2fkeeper@0.5.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5537},"main":"lib/index.js","babel":{"presets":["@babel/preset-env"]},"gitHead":"7eb7fb275ee824d34c0e7e1ff8fd1d2c96b4248e","scripts":{"lint":"eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore .","test":"npm run pretest && jest --coverage","build":"babel src --out-dir lib","pretest":"npm run build","lint:fix":"eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore . --fix"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:91f81668-042f-4f9c-a70b-c29d21775c3a"}},"repository":{"url":"git+https://github.com/asyncapi/generator.git","type":"git"},"_npmVersion":"11.6.2","description":"AsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07)","directories":{},"_nodeVersion":"24.11.1","dependencies":{"ajv":"^8.17.1","@asyncapi/parser":"^3.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.3.1","@babel/cli":"^7.25.9","babel-jest":"^27.3.1","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","jest-esm-transformer":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/keeper_0.5.0_1764832598014_0.5310382022907136","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-08-25T06:52:12.532Z","modified":"2026-07-31T14:02:55.916Z","0.0.1":"2025-08-25T06:52:12.851Z","0.0.2":"2025-11-24T03:10:08.513Z","0.0.3":"2025-11-24T03:58:37.450Z","0.5.0":"2025-12-04T07:16:38.158Z"},"bugs":{"url":"https://github.com/asyncapi/generator/issues"},"author":{"name":"Adi Boghawala","email":"boghawalaadi@gmail.com"},"license":"Apache-2.0","homepage":"https://github.com/asyncapi/generator#readme","repository":{"url":"git+https://github.com/asyncapi/generator.git","type":"git"},"description":"AsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07)","maintainers":[{"email":"lpgornicki@gmail.com","name":"derberg"}],"readme":"## @asyncapi/keeper\n\nAsyncAPI message payload validation library that validates messages against JSON Schema (Draft-07).\n\n### Installation\n\n```bash\nnpm install @asyncapi/keeper\n```\n\n### API\n\n#### `await compileSchemas(schemas)`\n\n#### Parameters\n\n| Parameter | Type               | Description                                                                 | Required |\n|-----------|--------------------|-----------------------------------------------------------------------------|----------|\n| `schemas` | `Array<Object>`    | Array of JSON Schema Draft-07 objects representing valid message structures  | Yes      |\n\n#### Returns\n`Promise<Array<function>>` — Array of compiled schema validator functions.\n\n#### `await compileSchemasByOperationId(asyncapiFilepath, operationId)`\n\n#### Parameters\n\n| Parameter           | Type         | Description                                                                                 | Required |\n|---------------------|--------------|---------------------------------------------------------------------------------------------|----------|\n| `asyncapiFilepath`  | `string`     | Path to the AsyncAPI document file.                                                         | Yes      |\n| `operationId`       | `string`     | The ID of the operation to extract message schemas from.                                    | Yes      |\n\n#### Returns\n`Promise<Array<function>>` — Array of compiled schema validator functions for the operation's messages.\n\n#### `validateMessage(compiledSchemas, message)`\n\n#### Parameters\n\n| Parameter        | Type               | Description                                                                 | Required |\n|------------------|--------------------|-----------------------------------------------------------------------------|----------|\n| `compiledSchemas`| `Array<function>`  | Array of compiled schema validator functions                                | Yes      |\n| `message`        | `any`              | The message payload to validate (any non-null value)                       | Yes      |\n\n#### Returns\n`{ isValid: boolean, validationErrors?: Array<object> }` — Object containing validation result and errors if invalid.\n\n#### `removeCompiledSchemas()`\n\n#### Returns\n`void` — Unregisters all currently registered schemas from the validator.\n\n### Usage\n\n#### Basic Schema Compilation and Validation\n\n```js \nimport { compileSchemas, validateMessage, removeCompiledSchemas } from '@asyncapi/keeper';\n\n// Example schemas (JSON Schema Draft-07 objects)\nconst schemas = [\n  {\n    type: 'object',\n    properties: {\n      content: { type: 'string' },\n      timestamp: { type: 'string', format: 'date-time' }\n    },\n    required: ['content', 'timestamp'],\n    additionalProperties: false\n  },\n  {\n    type: 'object',\n    properties: {\n      content: { type: 'string' }\n    },\n    required: ['content'],\n    additionalProperties: false\n  }\n];\n\n// Compile schemas\nconst compiledSchemas = await compileSchemas(schemas);\n\n// Validate messages\nconst message1 = { content: 'Hello', timestamp: '2024-05-01T12:00:00Z' };\nconst result1 = validateMessage(compiledSchemas, message1);\nconsole.log('Valid:', result1.isValid); // true\nconsole.log('Errors:', result1.validationErrors); // undefined\n\nconst message2 = { content: 42 }; // Invalid: content should be string\nconst result2 = validateMessage(compiledSchemas, message2);\nconsole.log('Valid:', result2.isValid); // false\nconsole.log('Errors:', result2.validationErrors); // Array of validation errors\n\n// Clean up\nremoveCompiledSchemas();\n```\n\n#### Operation-Specific Validation\n\n```js\nimport { compileSchemasByOperationId, validateMessage, removeCompiledSchemas } from '@asyncapi/keeper';\nimport path from 'path';\n\nconst asyncapiFilepath = path.resolve(__dirname, './asyncapi.yaml'); // Path to your AsyncAPI document\nconst operationId = 'sendHelloMessage'; // The operationId to validate against\n\n// Compile schemas for specific operation\nconst compiledSchemas = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n\n// Validate message against operation schemas\nconst message = { content: 'Hello from operation' };\nconst result = validateMessage(compiledSchemas, message);\nconsole.log('Valid for operation:', result.isValid); // true or false\n\n// Clean up\nremoveCompiledSchemas();\n```","readmeFilename":"README.md"}