@amritk/generate-parsers 0.1.0

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,34 @@
1
+ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
2
+ /**
3
+ * Defines custom extension properties that can be added to specific schema
4
+ * definitions during the build process.
5
+ *
6
+ * The outer key is the definition name (matching the $defs key in the root
7
+ * schema, e.g., "parameter", "operation"). The inner key is the extension
8
+ * property name (e.g., "x-enabled", "x-internal"). The value is a JSON
9
+ * Schema that validates the extension property and generates its TypeScript type.
10
+ *
11
+ * Extensions are merged into the schema properties before type and parser
12
+ * generation, so each extension gets full type safety and runtime validation.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const extensions: SchemaExtensions = {
17
+ * parameter: {
18
+ * 'x-enabled': { type: 'boolean' },
19
+ * 'x-internal': { type: 'boolean', default: false },
20
+ * },
21
+ * operation: {
22
+ * 'x-codegen': {
23
+ * type: 'object',
24
+ * properties: {
25
+ * methodName: { type: 'string' },
26
+ * },
27
+ * },
28
+ * },
29
+ * }
30
+ *
31
+ * const files = buildSchema(schema, 'Document', markdownDocumentation, extensions)
32
+ * ```
33
+ */
34
+ export type SchemaExtensions = Record<string, Record<string, JSONSchema>>;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@amritk/generate-parsers",
3
+ "version": "0.1.0",
4
+ "description": "Generate TypeScript parsers and type definitions from JSON Schemas.",
5
+ "module": "./dist/index.js",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "amritk",
9
+ "keywords": [
10
+ "json-schema",
11
+ "typescript",
12
+ "parser",
13
+ "code-generation",
14
+ "mjst"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/amritk/mjst.git",
19
+ "directory": "packages/generate-parsers"
20
+ },
21
+ "homepage": "https://github.com/amritk/mjst/tree/main/packages/generate-parsers#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/amritk/mjst/issues"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "bun run build:code && bun run build:types",
30
+ "build:code": "bun build ./src/index.ts --outdir=dist --target=node",
31
+ "build:types": "tsc -p .",
32
+ "generate-readme": "bun run ./scripts/generate-readme.ts"
33
+ },
34
+ "imports": {
35
+ "#generators/*": "./src/generators/*.ts",
36
+ "#helpers/*": "./src/helpers/*.ts",
37
+ "#types/*": "./src/types/*.ts"
38
+ },
39
+ "exports": {
40
+ ".": {
41
+ "bun": "./src/index.ts",
42
+ "default": "./dist/index.js",
43
+ "types": "./dist/index.d.ts"
44
+ }
45
+ },
46
+ "dependencies": {
47
+ "json-schema-typed": "catalog:",
48
+ "@amritk/helpers": "workspace:*",
49
+ "@amritk/generate-markdown": "workspace:*"
50
+ }
51
+ }