@varavel/vdl-plugin-sdk 0.0.0 → 0.1.1

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.
package/LICENSE CHANGED
File without changes
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ <p align="center">
2
+ <img
3
+ src="https://raw.githubusercontent.com/varavelio/vdl/9cb8432f972f986ba91ffa1e4fe82220a8aa373f/assets/png/vdl.png"
4
+ alt="VDL logo"
5
+ width="130"
6
+ />
7
+ </p>
8
+
9
+ <h1 align="center">VDL Plugin SDK</h1>
10
+
11
+ <p align="center">
12
+ Build VDL plugins in TypeScript with typed IR models, utility helpers, and a simple CLI for checking and bundling plugin packages.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://github.com/varavelio/vdl-plugin-sdk/actions">
17
+ <img src="https://github.com/varavelio/vdl-plugin-sdk/actions/workflows/ci.yaml/badge.svg" alt="CI status"/>
18
+ </a>
19
+ <a href="https://github.com/varavelio/vdl-plugin-sdk/releases/latest">
20
+ <img src="https://img.shields.io/github/release/varavelio/vdl-plugin-sdk.svg" alt="Release Version"/>
21
+ </a>
22
+ <a href="https://www.npmjs.com/package/@varavel/vdl-plugin-sdk">
23
+ <img src="https://img.shields.io/npm/v/%40varavel%2Fvdl-plugin-sdk" alt="NPM Version"/>
24
+ </a>
25
+ <a href="https://github.com/varavelio/vdl-plugin-sdk">
26
+ <img src="https://img.shields.io/github/stars/varavelio/vdl-plugin-sdk?style=flat&label=github+stars" alt="GitHub Stars"/>
27
+ </a>
28
+ <a href="LICENSE">
29
+ <img src="https://img.shields.io/github/license/varavelio/vdl-plugin-sdk.svg" alt="License"/>
30
+ </a>
31
+ </p>
32
+
33
+ ## Install
34
+
35
+ This is a reference install command. In most cases you do not need it manually:
36
+ `vdl plugin init` and the official
37
+ [`vdl-plugin-template`](https://github.com/varavelio/vdl-plugin-template)
38
+ already include this SDK by default.
39
+
40
+ ```bash
41
+ npm install @varavel/vdl-plugin-sdk
42
+ ```
43
+
44
+ ## What You Get
45
+
46
+ - `definePlugin(...)` to declare a plugin handler with typed input and output.
47
+ - Generated VDL IR types exported directly from the package.
48
+ - `getAnnotation` and `getAnnotationArgs` for reading annotations.
49
+ - `unwrapLiteral<T>()` for reading constants and annotation values.
50
+ - `getOptionString`, `getOptionBool`, `getOptionNumber`, and `getOptionArray` for reading plugin options.
51
+ - A `vdl-plugin` binary that supports `check` and `build`.
52
+
53
+ ## Quick Start
54
+
55
+ Every VDL plugin should export a `definePlugin(...)` handler from `src/index.ts`.
56
+
57
+ Create `src/index.ts` in your plugin project:
58
+
59
+ ```ts
60
+ import { definePlugin } from "@varavel/vdl-plugin-sdk";
61
+
62
+ export const generate = definePlugin((input) => {
63
+ // Your plugin logic goes here
64
+ // Feel free to explore the plugin input
65
+ console.log(input.version) // The VDL version without v prefix
66
+ console.log(input.options) // Any option that the user passed to the plugin via vdl.config.vdl
67
+ console.log(input.ir) // VDL intermediate representation from where your plugin generates code
68
+
69
+ return {
70
+ files: [
71
+ {
72
+ path: "hello.txt",
73
+ content: "Hello from VDL Plugin SDK",
74
+ },
75
+ ],
76
+ };
77
+ });
78
+ ```
79
+
80
+ ## Plugin Workflow
81
+
82
+ Every plugin follows the same release flow:
83
+
84
+ 1. Create and export a `definePlugin(...)` handler in `./src/index.ts`.
85
+ 2. Run `vdl-plugin build` to bundle the plugin into `./dist/index.js`.
86
+ 3. Commit `./dist/index.js` to the repository.
87
+ 4. Publish a new release on GitHub including all your files, including `./dist/index.js`.
88
+ 5. When the plugin is used, VDL reads `./dist/index.js` directly from your GitHub releases.
89
+
90
+ ## API
91
+
92
+ Import every helper below from `@varavel/vdl-plugin-sdk`. The generated IR types are also exported from the same package.
93
+
94
+ ### Plugin API
95
+
96
+ - `definePlugin(handler)` wraps and returns your plugin entrypoint.
97
+ - `VdlPluginHandler` is the function type for a plugin handler.
98
+
99
+ ### Annotation API
100
+
101
+ - `getAnnotation(annotations, name)` returns the first matching annotation or `undefined`.
102
+ - `getAnnotationArgs(annotations, name)` returns the raw literal argument stored in the annotation.
103
+
104
+ ### Literal API
105
+
106
+ - `unwrapLiteral<T>(value)` resolves a `LiteralValue` into a plain JavaScript value.
107
+
108
+ ### Option API
109
+
110
+ Use these helpers to read `input.options` safely:
111
+
112
+ - `getOptionString(options, key, defaultValue)` reads string values.
113
+ - `getOptionBool(options, key, defaultValue)` reads booleans from truthy/falsy values.
114
+ - Accepted truthy values: `true`, `1`, `yes`, `on`, `enable`, `enabled`, `y`.
115
+ - Accepted falsy values: `false`, `0`, `no`, `off`, `disable`, `disabled`, `n`.
116
+ - `getOptionNumber(options, key, defaultValue)` parses numbers and falls back safely for invalid input.
117
+ - `getOptionArray(options, key, defaultValue?, separator?)` splits a delimited string into a trimmed string array.
118
+
119
+ ```ts
120
+ import {
121
+ getOptionArray,
122
+ getOptionBool,
123
+ getOptionNumber,
124
+ getOptionString,
125
+ } from "@varavel/vdl-plugin-sdk";
126
+
127
+ const prefix = getOptionString(input.options, "prefix", "Model");
128
+ const strict = getOptionBool(input.options, "strict", false);
129
+ const version = getOptionNumber(input.options, "version", 1);
130
+ const tags = getOptionArray(input.options, "tags", [], ",");
131
+ ```
132
+
133
+ ## CLI
134
+
135
+ Use the bundled binary in scripts or with `npx`:
136
+
137
+ ```bash
138
+ npx vdl-plugin check
139
+ npx vdl-plugin build
140
+ ```
141
+
142
+ - `check` runs TypeScript without emitting files.
143
+ - `build` bundles the required `src/index.ts` entry into `dist/index.js`.
144
+
145
+ Example `package.json` scripts:
146
+
147
+ ```json
148
+ {
149
+ "scripts": {
150
+ "check": "vdl-plugin check",
151
+ "build": "vdl-plugin build"
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## TypeScript Setup
157
+
158
+ You can extend the shared base config exported by the SDK:
159
+
160
+ ```json
161
+ {
162
+ "extends": "@varavel/vdl-plugin-sdk/tsconfig.base.json"
163
+ }
164
+ ```
165
+
166
+ ## License
167
+
168
+ This project is released under the MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from "node:child_process";
4
+ import { createRequire } from "node:module";
5
+ import { resolve } from "node:path";
6
+ import * as esbuild from "esbuild";
7
+
8
+ const require = createRequire(import.meta.url);
9
+ const command = process.argv[2];
10
+
11
+ function printHelp() {
12
+ console.log(`Usage: vdl-plugin <command>
13
+
14
+ Commands:
15
+ check Run TypeScript type checks without emitting files
16
+ build Bundle the plugin from src/index.ts into dist/index.js`);
17
+ }
18
+
19
+ function runCheck() {
20
+ console.log("Running TypeScript type checks...");
21
+
22
+ try {
23
+ const tscPath = require.resolve("typescript/bin/tsc");
24
+ execFileSync(process.execPath, [tscPath, "--noEmit"], { stdio: "inherit" });
25
+ console.log("Type checks completed successfully.");
26
+ } catch {
27
+ process.exit(1);
28
+ }
29
+ }
30
+
31
+ function runBuild() {
32
+ console.log("Building VDL plugin...");
33
+
34
+ try {
35
+ esbuild.buildSync({
36
+ entryPoints: [resolve(process.cwd(), "src/index.ts")],
37
+ outfile: resolve(process.cwd(), "dist/index.js"),
38
+ format: "cjs",
39
+ platform: "neutral",
40
+ target: "es2015",
41
+ bundle: true,
42
+ minify: true,
43
+ treeShaking: true,
44
+ });
45
+
46
+ console.log("Plugin built successfully at dist/index.js.");
47
+ } catch (error) {
48
+ console.error("Failed to build the plugin.");
49
+ if (error instanceof Error && error.message) {
50
+ console.error(error.message);
51
+ }
52
+ process.exit(1);
53
+ }
54
+ }
55
+
56
+ if (command === "check") {
57
+ runCheck();
58
+ } else if (command === "build") {
59
+ runBuild();
60
+ } else {
61
+ if (command) {
62
+ console.error(`Unknown command: ${command}`);
63
+ }
64
+ printHelp();
65
+ process.exit(1);
66
+ }
@@ -1,5 +1,30 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/ir.ts
2
+ //#region src/define-plugin.ts
3
+ /**
4
+ * Defines a VDL plugin by wrapping the provided handler function. This is a helper function
5
+ * that can be used to create plugins in a more concise way.
6
+ *
7
+ * Example usage:
8
+ * ```typescript
9
+ * import { definePlugin } from "@varavel/vdl-plugin-sdk";
10
+ *
11
+ * export const generate = definePlugin((input) => {
12
+ * // Plugin logic goes here
13
+ * return {
14
+ * files: [],
15
+ * errors: []
16
+ * };
17
+ * });
18
+ * ```
19
+ *
20
+ * @param handler - The plugin handler function that contains the logic for processing the input and generating the output.
21
+ * @returns The same handler function, which can be exported as the plugin's main entry point.
22
+ */
23
+ function definePlugin(handler) {
24
+ return handler;
25
+ }
26
+ //#endregion
27
+ //#region src/types/types.ts
3
28
  const EnumValueTypeList = ["string", "int"];
4
29
  function isEnumValueType(value) {
5
30
  return EnumValueTypeList.includes(value);
@@ -286,6 +311,72 @@ function validateObjectEntry(input, path = "ObjectEntry") {
286
311
  }
287
312
  return null;
288
313
  }
314
+ function hydratePluginInput(input) {
315
+ return {
316
+ version: input.version,
317
+ ir: hydrateIrSchema(input.ir),
318
+ options: input.options
319
+ };
320
+ }
321
+ function validatePluginInput(input, path = "PluginInput") {
322
+ if (input === null || input === void 0 || typeof input !== "object") return `${path}: expected object, got ${typeof input}`;
323
+ const obj = input;
324
+ if (obj.ir === void 0 || obj.ir === null) return `${path}.ir: required field is missing`;
325
+ {
326
+ const err = validateIrSchema(obj.ir, `${path}.ir`);
327
+ if (err !== null) return err;
328
+ }
329
+ return null;
330
+ }
331
+ function hydratePluginOutput(input) {
332
+ return {
333
+ files: input.files ? input.files.map((el) => hydratePluginOutputFile(el)) : input.files,
334
+ errors: input.errors ? input.errors.map((el) => hydratePluginOutputError(el)) : input.errors
335
+ };
336
+ }
337
+ function validatePluginOutput(input, path = "PluginOutput") {
338
+ if (input === null || input === void 0 || typeof input !== "object") return `${path}: expected object, got ${typeof input}`;
339
+ const obj = input;
340
+ if (obj.files !== void 0 && obj.files !== null) {
341
+ if (!Array.isArray(obj.files)) return `${path}.files: expected array, got ${typeof obj.files}`;
342
+ for (let i = 0; i < obj.files.length; i++) {
343
+ const err = validatePluginOutputFile(obj.files[i], `${path}.files[${i}]`);
344
+ if (err !== null) return err;
345
+ }
346
+ }
347
+ if (obj.errors !== void 0 && obj.errors !== null) {
348
+ if (!Array.isArray(obj.errors)) return `${path}.errors: expected array, got ${typeof obj.errors}`;
349
+ for (let i = 0; i < obj.errors.length; i++) {
350
+ const err = validatePluginOutputError(obj.errors[i], `${path}.errors[${i}]`);
351
+ if (err !== null) return err;
352
+ }
353
+ }
354
+ return null;
355
+ }
356
+ function hydratePluginOutputError(input) {
357
+ return {
358
+ message: input.message,
359
+ position: input.position ? hydratePosition(input.position) : input.position
360
+ };
361
+ }
362
+ function validatePluginOutputError(input, path = "PluginOutputError") {
363
+ if (input === null || input === void 0 || typeof input !== "object") return `${path}: expected object, got ${typeof input}`;
364
+ const obj = input;
365
+ if (obj.position !== void 0 && obj.position !== null) {
366
+ const err = validatePosition(obj.position, `${path}.position`);
367
+ if (err !== null) return err;
368
+ }
369
+ return null;
370
+ }
371
+ function hydratePluginOutputFile(input) {
372
+ return {
373
+ path: input.path,
374
+ content: input.content
375
+ };
376
+ }
377
+ function validatePluginOutputFile(_input, _path = "PluginOutputFile") {
378
+ return null;
379
+ }
289
380
  function hydratePosition(input) {
290
381
  return {
291
382
  file: input.file,
@@ -384,10 +475,142 @@ function validateTypeRef(input, path = "TypeRef") {
384
475
  return null;
385
476
  }
386
477
  //#endregion
478
+ //#region src/utils/annotations.ts
479
+ /**
480
+ * Returns the first annotation that matches the provided name.
481
+ */
482
+ function getAnnotation(annotations, name) {
483
+ if (!annotations) return void 0;
484
+ return annotations.find((anno) => anno.name === name);
485
+ }
486
+ /**
487
+ * Returns the raw literal argument stored in an annotation.
488
+ *
489
+ * VDL annotations currently expose a single literal argument.
490
+ * Pair this helper with `unwrapLiteral` when you need a plain JavaScript value.
491
+ */
492
+ function getAnnotationArgs(annotations, name) {
493
+ const anno = getAnnotation(annotations, name);
494
+ return anno === null || anno === void 0 ? void 0 : anno.argument;
495
+ }
496
+ //#endregion
497
+ //#region src/utils/literals.ts
498
+ /**
499
+ * Resolves a `LiteralValue` into its native JavaScript representation.
500
+ *
501
+ * Pass a generic when you already know the expected shape.
502
+ * Omit it to get `unknown` and narrow the result yourself.
503
+ *
504
+ * The generic only affects TypeScript types. It does not validate the runtime value.
505
+ */
506
+ function unwrapLiteral(value) {
507
+ return unwrapLiteralValue(value);
508
+ }
509
+ /**
510
+ * Performs the recursive literal resolution used by `unwrapLiteral`.
511
+ */
512
+ function unwrapLiteralValue(value) {
513
+ switch (value.kind) {
514
+ case "string": return value.stringValue;
515
+ case "int": return value.intValue;
516
+ case "float": return value.floatValue;
517
+ case "bool": return value.boolValue;
518
+ case "object": {
519
+ var _value$objectEntries;
520
+ const resolvedObject = {};
521
+ const entries = (_value$objectEntries = value.objectEntries) !== null && _value$objectEntries !== void 0 ? _value$objectEntries : [];
522
+ for (const entry of entries) resolvedObject[entry.key] = unwrapLiteralValue(entry.value);
523
+ return resolvedObject;
524
+ }
525
+ case "array":
526
+ var _value$arrayItems;
527
+ return ((_value$arrayItems = value.arrayItems) !== null && _value$arrayItems !== void 0 ? _value$arrayItems : []).map((item) => unwrapLiteralValue(item));
528
+ default: return null;
529
+ }
530
+ }
531
+ //#endregion
532
+ //#region src/utils/options.ts
533
+ /**
534
+ * Returns a string option or the provided fallback when the key is missing.
535
+ */
536
+ function getOptionString(options, key, defaultValue) {
537
+ const value = options === null || options === void 0 ? void 0 : options[key];
538
+ return value === void 0 ? defaultValue : value;
539
+ }
540
+ /**
541
+ * Returns a boolean option using common truthy and falsy string values.
542
+ *
543
+ * Accepted truthy values: `true`, `1`, `yes`, `on`, `enable`, `enabled`, `y`.
544
+ *
545
+ * Accepted falsy values: `false`, `0`, `no`, `off`, `disable`, `disabled`, `n`.
546
+ *
547
+ * Invalid values fall back to the provided default.
548
+ */
549
+ function getOptionBool(options, key, defaultValue) {
550
+ const value = options === null || options === void 0 ? void 0 : options[key];
551
+ if (value === void 0) return defaultValue;
552
+ switch (value.trim().toLowerCase()) {
553
+ case "true":
554
+ case "1":
555
+ case "yes":
556
+ case "on":
557
+ case "enable":
558
+ case "enabled":
559
+ case "y": return true;
560
+ case "false":
561
+ case "0":
562
+ case "no":
563
+ case "off":
564
+ case "disable":
565
+ case "disabled":
566
+ case "n": return false;
567
+ default: return defaultValue;
568
+ }
569
+ }
570
+ /**
571
+ * Returns a numeric option or the provided fallback when parsing fails.
572
+ *
573
+ * Empty, invalid, and non-finite values fall back to the default.
574
+ */
575
+ function getOptionNumber(options, key, defaultValue) {
576
+ const value = options === null || options === void 0 ? void 0 : options[key];
577
+ if (value === void 0) return defaultValue;
578
+ const trimmedValue = value.trim();
579
+ if (trimmedValue === "") return defaultValue;
580
+ const parsedValue = Number(trimmedValue);
581
+ return Number.isFinite(parsedValue) ? parsedValue : defaultValue;
582
+ }
583
+ /**
584
+ * Returns a string array option from a separator-delimited value.
585
+ *
586
+ * Empty items are removed and each entry is trimmed.
587
+ *
588
+ * Missing values return the provided default.
589
+ *
590
+ * @example
591
+ * // For options: { "features": "feature1, feature2, feature3" }
592
+ * getOptionArray(options, "features", [], ",")
593
+ * // returns ["feature1", "feature2", "feature3"]
594
+ */
595
+ function getOptionArray(options, key, defaultValue = [], separator = ",") {
596
+ const value = options === null || options === void 0 ? void 0 : options[key];
597
+ if (value === void 0) return defaultValue;
598
+ const trimmedValue = value.trim();
599
+ if (trimmedValue === "") return [];
600
+ return trimmedValue.split(separator).map((item) => item.trim()).filter((item) => item.length > 0);
601
+ }
602
+ //#endregion
387
603
  exports.EnumValueTypeList = EnumValueTypeList;
388
604
  exports.LiteralKindList = LiteralKindList;
389
605
  exports.PrimitiveTypeList = PrimitiveTypeList;
390
606
  exports.TypeKindList = TypeKindList;
607
+ exports.definePlugin = definePlugin;
608
+ exports.getAnnotation = getAnnotation;
609
+ exports.getAnnotationArgs = getAnnotationArgs;
610
+ exports.getOptionArray = getOptionArray;
611
+ exports.getOptionBool = getOptionBool;
612
+ exports.getOptionNumber = getOptionNumber;
613
+ exports.getOptionString = getOptionString;
391
614
  exports.hydrateAnnotation = hydrateAnnotation;
392
615
  exports.hydrateConstantDef = hydrateConstantDef;
393
616
  exports.hydrateEnumDef = hydrateEnumDef;
@@ -396,6 +619,10 @@ exports.hydrateField = hydrateField;
396
619
  exports.hydrateIrSchema = hydrateIrSchema;
397
620
  exports.hydrateLiteralValue = hydrateLiteralValue;
398
621
  exports.hydrateObjectEntry = hydrateObjectEntry;
622
+ exports.hydratePluginInput = hydratePluginInput;
623
+ exports.hydratePluginOutput = hydratePluginOutput;
624
+ exports.hydratePluginOutputError = hydratePluginOutputError;
625
+ exports.hydratePluginOutputFile = hydratePluginOutputFile;
399
626
  exports.hydratePosition = hydratePosition;
400
627
  exports.hydrateTopLevelDoc = hydrateTopLevelDoc;
401
628
  exports.hydrateTypeDef = hydrateTypeDef;
@@ -404,6 +631,7 @@ exports.isEnumValueType = isEnumValueType;
404
631
  exports.isLiteralKind = isLiteralKind;
405
632
  exports.isPrimitiveType = isPrimitiveType;
406
633
  exports.isTypeKind = isTypeKind;
634
+ exports.unwrapLiteral = unwrapLiteral;
407
635
  exports.validateAnnotation = validateAnnotation;
408
636
  exports.validateConstantDef = validateConstantDef;
409
637
  exports.validateEnumDef = validateEnumDef;
@@ -412,9 +640,13 @@ exports.validateField = validateField;
412
640
  exports.validateIrSchema = validateIrSchema;
413
641
  exports.validateLiteralValue = validateLiteralValue;
414
642
  exports.validateObjectEntry = validateObjectEntry;
643
+ exports.validatePluginInput = validatePluginInput;
644
+ exports.validatePluginOutput = validatePluginOutput;
645
+ exports.validatePluginOutputError = validatePluginOutputError;
646
+ exports.validatePluginOutputFile = validatePluginOutputFile;
415
647
  exports.validatePosition = validatePosition;
416
648
  exports.validateTopLevelDoc = validateTopLevelDoc;
417
649
  exports.validateTypeDef = validateTypeDef;
418
650
  exports.validateTypeRef = validateTypeRef;
419
651
 
420
- //# sourceMappingURL=ir.cjs.map
652
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/define-plugin.ts","../src/types/types.ts","../src/utils/annotations.ts","../src/utils/literals.ts","../src/utils/options.ts"],"sourcesContent":["import type { PluginInput, PluginOutput } from \"./types\";\n\n/**\n * Defines a VDL plugin handler function.\n *\n * @param input - The input data for the plugin containing the IR and other relevant information.\n * @returns The output data from the plugin containing the generated files and any errors.\n */\nexport type VdlPluginHandler = (input: PluginInput) => PluginOutput;\n\n/**\n * Defines a VDL plugin by wrapping the provided handler function. This is a helper function\n * that can be used to create plugins in a more concise way.\n *\n * Example usage:\n * ```typescript\n * import { definePlugin } from \"@varavel/vdl-plugin-sdk\";\n *\n * export const generate = definePlugin((input) => {\n * // Plugin logic goes here\n * return {\n * files: [],\n * errors: []\n * };\n * });\n * ```\n *\n * @param handler - The plugin handler function that contains the logic for processing the input and generating the output.\n * @returns The same handler function, which can be exported as the plugin's main entry point.\n */\nexport function definePlugin(handler: VdlPluginHandler): VdlPluginHandler {\n return handler;\n}\n","// Code generated by VDL v0.4.0-alpha.5. DO NOT EDIT.\n// If you edit this file, it will be overwritten the next time it is generated.\n//\n// For more information about VDL, visit https://vdl.varavel.com\n\n/* eslint-disable */\n/* tslint:disable */\n// biome-ignore-all lint: Generated by VDL\n\n// -----------------------------------------------------------------------------\n// Enumerations\n// -----------------------------------------------------------------------------\n\n/**\n * Underlying storage kind used by an enum\n */\nexport type EnumValueType = \"string\" | \"int\";\n\nexport const EnumValueTypeList: EnumValueType[] = [\n \"string\",\n \"int\",\n];\n\nexport function isEnumValueType(value: unknown): value is EnumValueType {\n return EnumValueTypeList.includes(value as EnumValueType);\n}\n\n/**\n * Kind discriminator for LiteralValue.\n * \n * LiteralValue is used for fully resolved literal data in:\n * \n * - constant values\n * - annotation arguments\n */\nexport type LiteralKind = \"string\" | \"int\" | \"float\" | \"bool\" | \"object\" | \"array\";\n\nexport const LiteralKindList: LiteralKind[] = [\n \"string\",\n \"int\",\n \"float\",\n \"bool\",\n \"object\",\n \"array\",\n];\n\nexport function isLiteralKind(value: unknown): value is LiteralKind {\n return LiteralKindList.includes(value as LiteralKind);\n}\n\n/**\n * Primitive scalar type names\n */\nexport type PrimitiveType = \"string\" | \"int\" | \"float\" | \"bool\" | \"datetime\";\n\nexport const PrimitiveTypeList: PrimitiveType[] = [\n \"string\",\n \"int\",\n \"float\",\n \"bool\",\n \"datetime\",\n];\n\nexport function isPrimitiveType(value: unknown): value is PrimitiveType {\n return PrimitiveTypeList.includes(value as PrimitiveType);\n}\n\n/**\n * Kind discriminator for TypeRef\n */\nexport type TypeKind = \"primitive\" | \"type\" | \"enum\" | \"array\" | \"map\" | \"object\";\n\nexport const TypeKindList: TypeKind[] = [\n \"primitive\",\n \"type\",\n \"enum\",\n \"array\",\n \"map\",\n \"object\",\n];\n\nexport function isTypeKind(value: unknown): value is TypeKind {\n return TypeKindList.includes(value as TypeKind);\n}\n\n// -----------------------------------------------------------------------------\n// Domain Types\n// -----------------------------------------------------------------------------\n\n/**\n * Annotation Annotation metadata preserved in IR.\n * \n * `name` is the annotation identifier without the `@` prefix.\n * `argument`, when present, is fully resolved as a LiteralValue.\n */\nexport type Annotation = {\n position: Position\n name: string\n argument?: LiteralValue\n}\n\nexport function hydrateAnnotation(input: Annotation): Annotation {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedArgument = input.argument ? hydrateLiteralValue(input.argument) : input.argument\n return {\n position: hydratedPosition,\n name: hydratedName,\n argument: hydratedArgument,\n }\n}\n\nexport function validateAnnotation(input: unknown, path = \"Annotation\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.argument !== undefined && obj.argument !== null) {\n {\n const err = validateLiteralValue(obj.argument, `${path}.argument`);\n if (err !== null) return err;\n }\n }\n return null;\n}\n\n/**\n * ConstantDef Fully resolved constant definition.\n * \n * `typeRef` is explicit or inferred by analysis.\n * `value` contains the fully resolved literal payload.\n */\nexport type ConstantDef = {\n position: Position\n name: string\n doc?: string\n annotations: Annotation[]\n typeRef: TypeRef\n value: LiteralValue\n}\n\nexport function hydrateConstantDef(input: ConstantDef): ConstantDef {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedDoc = input.doc ? input.doc : input.doc\n const hydratedAnnotations = input.annotations.map(el => hydrateAnnotation(el))\n const hydratedTypeRef = hydrateTypeRef(input.typeRef)\n const hydratedValue = hydrateLiteralValue(input.value)\n return {\n position: hydratedPosition,\n name: hydratedName,\n doc: hydratedDoc,\n annotations: hydratedAnnotations,\n typeRef: hydratedTypeRef,\n value: hydratedValue,\n }\n}\n\nexport function validateConstantDef(input: unknown, path = \"ConstantDef\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.annotations === undefined || obj.annotations === null) {\n return `${path}.annotations: required field is missing`;\n }\n {\n if (!Array.isArray(obj.annotations)) {\n return `${path}.annotations: expected array, got ${typeof obj.annotations}`;\n }\n for (let i = 0; i < obj.annotations.length; i++) {\n {\n const err = validateAnnotation(obj.annotations[i], `${path}.annotations[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.typeRef === undefined || obj.typeRef === null) {\n return `${path}.typeRef: required field is missing`;\n }\n {\n const err = validateTypeRef(obj.typeRef, `${path}.typeRef`);\n if (err !== null) return err;\n }\n if (obj.value === undefined || obj.value === null) {\n return `${path}.value: required field is missing`;\n }\n {\n const err = validateLiteralValue(obj.value, `${path}.value`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * EnumDef Flattened enum definition.\n * \n * All enum spreads are already expanded into `members`.\n */\nexport type EnumDef = {\n position: Position\n name: string\n doc?: string\n annotations: Annotation[]\n enumType: EnumValueType\n members: EnumMember[]\n}\n\nexport function hydrateEnumDef(input: EnumDef): EnumDef {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedDoc = input.doc ? input.doc : input.doc\n const hydratedAnnotations = input.annotations.map(el => hydrateAnnotation(el))\n const hydratedEnumType = input.enumType\n const hydratedMembers = input.members.map(el => hydrateEnumMember(el))\n return {\n position: hydratedPosition,\n name: hydratedName,\n doc: hydratedDoc,\n annotations: hydratedAnnotations,\n enumType: hydratedEnumType,\n members: hydratedMembers,\n }\n}\n\nexport function validateEnumDef(input: unknown, path = \"EnumDef\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.annotations === undefined || obj.annotations === null) {\n return `${path}.annotations: required field is missing`;\n }\n {\n if (!Array.isArray(obj.annotations)) {\n return `${path}.annotations: expected array, got ${typeof obj.annotations}`;\n }\n for (let i = 0; i < obj.annotations.length; i++) {\n {\n const err = validateAnnotation(obj.annotations[i], `${path}.annotations[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.enumType === undefined || obj.enumType === null) {\n return `${path}.enumType: required field is missing`;\n }\n {\n if (!isEnumValueType(obj.enumType)) {\n return `${path}.enumType: invalid enum value '${obj.enumType}' for EnumValueType`;\n }\n }\n if (obj.members === undefined || obj.members === null) {\n return `${path}.members: required field is missing`;\n }\n {\n if (!Array.isArray(obj.members)) {\n return `${path}.members: expected array, got ${typeof obj.members}`;\n }\n for (let i = 0; i < obj.members.length; i++) {\n {\n const err = validateEnumMember(obj.members[i], `${path}.members[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n return null;\n}\n\n/**\n * EnumMember Enum member definition\n */\nexport type EnumMember = {\n position: Position\n name: string\n value: LiteralValue\n doc?: string\n annotations: Annotation[]\n}\n\nexport function hydrateEnumMember(input: EnumMember): EnumMember {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedValue = hydrateLiteralValue(input.value)\n const hydratedDoc = input.doc ? input.doc : input.doc\n const hydratedAnnotations = input.annotations.map(el => hydrateAnnotation(el))\n return {\n position: hydratedPosition,\n name: hydratedName,\n value: hydratedValue,\n doc: hydratedDoc,\n annotations: hydratedAnnotations,\n }\n}\n\nexport function validateEnumMember(input: unknown, path = \"EnumMember\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.value === undefined || obj.value === null) {\n return `${path}.value: required field is missing`;\n }\n {\n const err = validateLiteralValue(obj.value, `${path}.value`);\n if (err !== null) return err;\n }\n if (obj.annotations === undefined || obj.annotations === null) {\n return `${path}.annotations: required field is missing`;\n }\n {\n if (!Array.isArray(obj.annotations)) {\n return `${path}.annotations: expected array, got ${typeof obj.annotations}`;\n }\n for (let i = 0; i < obj.annotations.length; i++) {\n {\n const err = validateAnnotation(obj.annotations[i], `${path}.annotations[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n return null;\n}\n\n/**\n * Field Flattened object/type field definition\n */\nexport type Field = {\n position: Position\n name: string\n doc?: string\n optional: boolean\n annotations: Annotation[]\n typeRef: TypeRef\n}\n\nexport function hydrateField(input: Field): Field {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedDoc = input.doc ? input.doc : input.doc\n const hydratedOptional = input.optional\n const hydratedAnnotations = input.annotations.map(el => hydrateAnnotation(el))\n const hydratedTypeRef = hydrateTypeRef(input.typeRef)\n return {\n position: hydratedPosition,\n name: hydratedName,\n doc: hydratedDoc,\n optional: hydratedOptional,\n annotations: hydratedAnnotations,\n typeRef: hydratedTypeRef,\n }\n}\n\nexport function validateField(input: unknown, path = \"Field\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.annotations === undefined || obj.annotations === null) {\n return `${path}.annotations: required field is missing`;\n }\n {\n if (!Array.isArray(obj.annotations)) {\n return `${path}.annotations: expected array, got ${typeof obj.annotations}`;\n }\n for (let i = 0; i < obj.annotations.length; i++) {\n {\n const err = validateAnnotation(obj.annotations[i], `${path}.annotations[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.typeRef === undefined || obj.typeRef === null) {\n return `${path}.typeRef: required field is missing`;\n }\n {\n const err = validateTypeRef(obj.typeRef, `${path}.typeRef`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * IrSchema IrSchema is the generator-facing representation of a VDL program.\n * \n * This model is intentionally \"flat\" and \"resolved\":\n * \n * - spreads are already expanded\n * - references are already resolved\n * - collections are in deterministic order\n * \n * A code generator should be able to consume IrSchema directly, without needing\n * to re-run parser or semantic-analysis logic.\n */\nexport type IrSchema = {\n entryPoint: string\n constants: ConstantDef[]\n enums: EnumDef[]\n types: TypeDef[]\n docs: TopLevelDoc[]\n}\n\nexport function hydrateIrSchema(input: IrSchema): IrSchema {\n const hydratedEntryPoint = input.entryPoint\n const hydratedConstants = input.constants.map(el => hydrateConstantDef(el))\n const hydratedEnums = input.enums.map(el => hydrateEnumDef(el))\n const hydratedTypes = input.types.map(el => hydrateTypeDef(el))\n const hydratedDocs = input.docs.map(el => hydrateTopLevelDoc(el))\n return {\n entryPoint: hydratedEntryPoint,\n constants: hydratedConstants,\n enums: hydratedEnums,\n types: hydratedTypes,\n docs: hydratedDocs,\n }\n}\n\nexport function validateIrSchema(input: unknown, path = \"IrSchema\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.constants === undefined || obj.constants === null) {\n return `${path}.constants: required field is missing`;\n }\n {\n if (!Array.isArray(obj.constants)) {\n return `${path}.constants: expected array, got ${typeof obj.constants}`;\n }\n for (let i = 0; i < obj.constants.length; i++) {\n {\n const err = validateConstantDef(obj.constants[i], `${path}.constants[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.enums === undefined || obj.enums === null) {\n return `${path}.enums: required field is missing`;\n }\n {\n if (!Array.isArray(obj.enums)) {\n return `${path}.enums: expected array, got ${typeof obj.enums}`;\n }\n for (let i = 0; i < obj.enums.length; i++) {\n {\n const err = validateEnumDef(obj.enums[i], `${path}.enums[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.types === undefined || obj.types === null) {\n return `${path}.types: required field is missing`;\n }\n {\n if (!Array.isArray(obj.types)) {\n return `${path}.types: expected array, got ${typeof obj.types}`;\n }\n for (let i = 0; i < obj.types.length; i++) {\n {\n const err = validateTypeDef(obj.types[i], `${path}.types[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.docs === undefined || obj.docs === null) {\n return `${path}.docs: required field is missing`;\n }\n {\n if (!Array.isArray(obj.docs)) {\n return `${path}.docs: expected array, got ${typeof obj.docs}`;\n }\n for (let i = 0; i < obj.docs.length; i++) {\n {\n const err = validateTopLevelDoc(obj.docs[i], `${path}.docs[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n return null;\n}\n\n/**\n * LiteralValue Fully resolved literal value.\n * \n * The selected payload is determined by `kind`:\n * \n * - `string` -> `stringValue`\n * - `int` -> `intValue`\n * - `float` -> `floatValue`\n * - `bool` -> `boolValue`\n * - `object` -> `objectEntries`\n * - `array` -> `arrayItems`\n */\nexport type LiteralValue = {\n position: Position\n kind: LiteralKind\n stringValue?: string\n intValue?: number\n floatValue?: number\n boolValue?: boolean\n objectEntries?: ObjectEntry[]\n arrayItems?: LiteralValue[]\n}\n\nexport function hydrateLiteralValue(input: LiteralValue): LiteralValue {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedKind = input.kind\n const hydratedStringValue = input.stringValue ? input.stringValue : input.stringValue\n const hydratedIntValue = input.intValue ? input.intValue : input.intValue\n const hydratedFloatValue = input.floatValue ? input.floatValue : input.floatValue\n const hydratedBoolValue = input.boolValue ? input.boolValue : input.boolValue\n const hydratedObjectEntries = input.objectEntries ? input.objectEntries.map(el => hydrateObjectEntry(el)) : input.objectEntries\n const hydratedArrayItems = input.arrayItems ? input.arrayItems.map(el => hydrateLiteralValue(el)) : input.arrayItems\n return {\n position: hydratedPosition,\n kind: hydratedKind,\n stringValue: hydratedStringValue,\n intValue: hydratedIntValue,\n floatValue: hydratedFloatValue,\n boolValue: hydratedBoolValue,\n objectEntries: hydratedObjectEntries,\n arrayItems: hydratedArrayItems,\n }\n}\n\nexport function validateLiteralValue(input: unknown, path = \"LiteralValue\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.kind === undefined || obj.kind === null) {\n return `${path}.kind: required field is missing`;\n }\n {\n if (!isLiteralKind(obj.kind)) {\n return `${path}.kind: invalid enum value '${obj.kind}' for LiteralKind`;\n }\n }\n if (obj.objectEntries !== undefined && obj.objectEntries !== null) {\n {\n if (!Array.isArray(obj.objectEntries)) {\n return `${path}.objectEntries: expected array, got ${typeof obj.objectEntries}`;\n }\n for (let i = 0; i < obj.objectEntries.length; i++) {\n {\n const err = validateObjectEntry(obj.objectEntries[i], `${path}.objectEntries[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n }\n if (obj.arrayItems !== undefined && obj.arrayItems !== null) {\n {\n if (!Array.isArray(obj.arrayItems)) {\n return `${path}.arrayItems: expected array, got ${typeof obj.arrayItems}`;\n }\n for (let i = 0; i < obj.arrayItems.length; i++) {\n {\n const err = validateLiteralValue(obj.arrayItems[i], `${path}.arrayItems[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n }\n return null;\n}\n\n/**\n * ObjectEntry Key/value pair inside an object LiteralValue payload\n */\nexport type ObjectEntry = {\n position: Position\n key: string\n value: LiteralValue\n}\n\nexport function hydrateObjectEntry(input: ObjectEntry): ObjectEntry {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedKey = input.key\n const hydratedValue = hydrateLiteralValue(input.value)\n return {\n position: hydratedPosition,\n key: hydratedKey,\n value: hydratedValue,\n }\n}\n\nexport function validateObjectEntry(input: unknown, path = \"ObjectEntry\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.value === undefined || obj.value === null) {\n return `${path}.value: required field is missing`;\n }\n {\n const err = validateLiteralValue(obj.value, `${path}.value`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * PluginInput PluginInput represents the data payload sent to a plugin.\n * \n * The plugin receives this as a single argument containing the complete\n * Intermediate Representation of the VDL schema along with any user-defined\n * configuration options from `vdl.config.vdl`.\n */\nexport type PluginInput = {\n version: string\n ir: IrSchema\n options: Record<string, string>\n}\n\nexport function hydratePluginInput(input: PluginInput): PluginInput {\n const hydratedVersion = input.version\n const hydratedIr = hydrateIrSchema(input.ir)\n const hydratedOptions = input.options\n return {\n version: hydratedVersion,\n ir: hydratedIr,\n options: hydratedOptions,\n }\n}\n\nexport function validatePluginInput(input: unknown, path = \"PluginInput\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.ir === undefined || obj.ir === null) {\n return `${path}.ir: required field is missing`;\n }\n {\n const err = validateIrSchema(obj.ir, `${path}.ir`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * PluginOutput PluginOutput represents the response payload returned by the `plugin` function.\n * \n * After processing the input schema, the plugin outputs this object containing\n * all files to be generated or errors to be displayed to the user.\n * \n * If there are no errors and at least one file is returned, VDL will write each\n * file to the specified path within the output directory. If there are errors,\n * VDL will display them to the user and not write any files.\n */\nexport type PluginOutput = {\n files?: PluginOutputFile[]\n errors?: PluginOutputError[]\n}\n\nexport function hydratePluginOutput(input: PluginOutput): PluginOutput {\n const hydratedFiles = input.files ? input.files.map(el => hydratePluginOutputFile(el)) : input.files\n const hydratedErrors = input.errors ? input.errors.map(el => hydratePluginOutputError(el)) : input.errors\n return {\n files: hydratedFiles,\n errors: hydratedErrors,\n }\n}\n\nexport function validatePluginOutput(input: unknown, path = \"PluginOutput\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.files !== undefined && obj.files !== null) {\n {\n if (!Array.isArray(obj.files)) {\n return `${path}.files: expected array, got ${typeof obj.files}`;\n }\n for (let i = 0; i < obj.files.length; i++) {\n {\n const err = validatePluginOutputFile(obj.files[i], `${path}.files[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n }\n if (obj.errors !== undefined && obj.errors !== null) {\n {\n if (!Array.isArray(obj.errors)) {\n return `${path}.errors: expected array, got ${typeof obj.errors}`;\n }\n for (let i = 0; i < obj.errors.length; i++) {\n {\n const err = validatePluginOutputError(obj.errors[i], `${path}.errors[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n }\n return null;\n}\n\n/**\n * PluginOutputError A structured error reported by the plugin.\n */\nexport type PluginOutputError = {\n message: string\n position?: Position\n}\n\nexport function hydratePluginOutputError(input: PluginOutputError): PluginOutputError {\n const hydratedMessage = input.message\n const hydratedPosition = input.position ? hydratePosition(input.position) : input.position\n return {\n message: hydratedMessage,\n position: hydratedPosition,\n }\n}\n\nexport function validatePluginOutputError(input: unknown, path = \"PluginOutputError\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position !== undefined && obj.position !== null) {\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n }\n return null;\n}\n\n/**\n * PluginOutputFile PluginOutputFile represents a single generated file produced by the plugin.\n * \n * This abstraction allows plugins to generate multiple files from a single\n * invocation, enabling patterns like one-file-per-type or splitting large\n * outputs across multiple modules.\n */\nexport type PluginOutputFile = {\n path: string\n content: string\n}\n\nexport function hydratePluginOutputFile(input: PluginOutputFile): PluginOutputFile {\n const hydratedPath = input.path\n const hydratedContent = input.content\n return {\n path: hydratedPath,\n content: hydratedContent,\n }\n}\n\nexport function validatePluginOutputFile(_input: unknown, _path = \"PluginOutputFile\"): string | null {\n return null;\n}\n\n/**\n * Position It represents a position within a file and is used for error\n * reporting, diagnostics, plugins, and tooling support.\n */\nexport type Position = {\n file: string\n line: number\n column: number\n}\n\nexport function hydratePosition(input: Position): Position {\n const hydratedFile = input.file\n const hydratedLine = input.line\n const hydratedColumn = input.column\n return {\n file: hydratedFile,\n line: hydratedLine,\n column: hydratedColumn,\n }\n}\n\nexport function validatePosition(_input: unknown, _path = \"Position\"): string | null {\n return null;\n}\n\n/**\n * TopLevelDoc Standalone documentation block.\n * \n * Used for top-level docstrings that are not attached to a type/enum/constant.\n */\nexport type TopLevelDoc = {\n position: Position\n content: string\n}\n\nexport function hydrateTopLevelDoc(input: TopLevelDoc): TopLevelDoc {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedContent = input.content\n return {\n position: hydratedPosition,\n content: hydratedContent,\n }\n}\n\nexport function validateTopLevelDoc(input: unknown, path = \"TopLevelDoc\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * TypeDef Flattened type definition.\n * \n * All spreads are already expanded. The unified `typeRef` describes what this\n * type IS, a primitive, custom reference, map, array, or object with fields.\n */\nexport type TypeDef = {\n position: Position\n name: string\n doc?: string\n annotations: Annotation[]\n typeRef: TypeRef\n}\n\nexport function hydrateTypeDef(input: TypeDef): TypeDef {\n const hydratedPosition = hydratePosition(input.position)\n const hydratedName = input.name\n const hydratedDoc = input.doc ? input.doc : input.doc\n const hydratedAnnotations = input.annotations.map(el => hydrateAnnotation(el))\n const hydratedTypeRef = hydrateTypeRef(input.typeRef)\n return {\n position: hydratedPosition,\n name: hydratedName,\n doc: hydratedDoc,\n annotations: hydratedAnnotations,\n typeRef: hydratedTypeRef,\n }\n}\n\nexport function validateTypeDef(input: unknown, path = \"TypeDef\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.position === undefined || obj.position === null) {\n return `${path}.position: required field is missing`;\n }\n {\n const err = validatePosition(obj.position, `${path}.position`);\n if (err !== null) return err;\n }\n if (obj.annotations === undefined || obj.annotations === null) {\n return `${path}.annotations: required field is missing`;\n }\n {\n if (!Array.isArray(obj.annotations)) {\n return `${path}.annotations: expected array, got ${typeof obj.annotations}`;\n }\n for (let i = 0; i < obj.annotations.length; i++) {\n {\n const err = validateAnnotation(obj.annotations[i], `${path}.annotations[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n if (obj.typeRef === undefined || obj.typeRef === null) {\n return `${path}.typeRef: required field is missing`;\n }\n {\n const err = validateTypeRef(obj.typeRef, `${path}.typeRef`);\n if (err !== null) return err;\n }\n return null;\n}\n\n/**\n * TypeRef Normalized type reference used by fields and constants.\n * \n * `kind` selects which payload fields are meaningful. Generators should inspect\n * `kind` first, then read the related payload fields.\n */\nexport type TypeRef = {\n kind: TypeKind\n primitiveName?: PrimitiveType\n typeName?: string\n enumName?: string\n enumType?: EnumValueType\n arrayType?: TypeRef\n arrayDims?: number\n mapType?: TypeRef\n objectFields?: Field[]\n}\n\nexport function hydrateTypeRef(input: TypeRef): TypeRef {\n const hydratedKind = input.kind\n const hydratedPrimitiveName = input.primitiveName ? input.primitiveName : input.primitiveName\n const hydratedTypeName = input.typeName ? input.typeName : input.typeName\n const hydratedEnumName = input.enumName ? input.enumName : input.enumName\n const hydratedEnumType = input.enumType ? input.enumType : input.enumType\n const hydratedArrayType = input.arrayType ? hydrateTypeRef(input.arrayType) : input.arrayType\n const hydratedArrayDims = input.arrayDims ? input.arrayDims : input.arrayDims\n const hydratedMapType = input.mapType ? hydrateTypeRef(input.mapType) : input.mapType\n const hydratedObjectFields = input.objectFields ? input.objectFields.map(el => hydrateField(el)) : input.objectFields\n return {\n kind: hydratedKind,\n primitiveName: hydratedPrimitiveName,\n typeName: hydratedTypeName,\n enumName: hydratedEnumName,\n enumType: hydratedEnumType,\n arrayType: hydratedArrayType,\n arrayDims: hydratedArrayDims,\n mapType: hydratedMapType,\n objectFields: hydratedObjectFields,\n }\n}\n\nexport function validateTypeRef(input: unknown, path = \"TypeRef\"): string | null {\n if (input === null || input === undefined || typeof input !== \"object\") {\n return `${path}: expected object, got ${typeof input}`;\n }\n const obj = input as Record<string, unknown>;\n\n if (obj.kind === undefined || obj.kind === null) {\n return `${path}.kind: required field is missing`;\n }\n {\n if (!isTypeKind(obj.kind)) {\n return `${path}.kind: invalid enum value '${obj.kind}' for TypeKind`;\n }\n }\n if (obj.primitiveName !== undefined && obj.primitiveName !== null) {\n {\n if (!isPrimitiveType(obj.primitiveName)) {\n return `${path}.primitiveName: invalid enum value '${obj.primitiveName}' for PrimitiveType`;\n }\n }\n }\n if (obj.enumType !== undefined && obj.enumType !== null) {\n {\n if (!isEnumValueType(obj.enumType)) {\n return `${path}.enumType: invalid enum value '${obj.enumType}' for EnumValueType`;\n }\n }\n }\n if (obj.arrayType !== undefined && obj.arrayType !== null) {\n {\n const err = validateTypeRef(obj.arrayType, `${path}.arrayType`);\n if (err !== null) return err;\n }\n }\n if (obj.mapType !== undefined && obj.mapType !== null) {\n {\n const err = validateTypeRef(obj.mapType, `${path}.mapType`);\n if (err !== null) return err;\n }\n }\n if (obj.objectFields !== undefined && obj.objectFields !== null) {\n {\n if (!Array.isArray(obj.objectFields)) {\n return `${path}.objectFields: expected array, got ${typeof obj.objectFields}`;\n }\n for (let i = 0; i < obj.objectFields.length; i++) {\n {\n const err = validateField(obj.objectFields[i], `${path}.objectFields[${i}]`);\n if (err !== null) return err;\n }\n }\n }\n }\n return null;\n}\n","import type { Annotation, LiteralValue } from \"../types\";\n\n/**\n * Returns the first annotation that matches the provided name.\n */\nexport function getAnnotation(\n annotations: Annotation[] | undefined,\n name: string,\n): Annotation | undefined {\n if (!annotations) return undefined;\n return annotations.find((anno) => anno.name === name);\n}\n\n/**\n * Returns the raw literal argument stored in an annotation.\n *\n * VDL annotations currently expose a single literal argument.\n * Pair this helper with `unwrapLiteral` when you need a plain JavaScript value.\n */\nexport function getAnnotationArgs(\n annotations: Annotation[] | undefined,\n name: string,\n): LiteralValue | undefined {\n const anno = getAnnotation(annotations, name);\n return anno?.argument;\n}\n","import type { LiteralValue } from \"../types\";\n\n/**\n * Native JavaScript value produced by `unwrapLiteral`.\n *\n * `undefined` is preserved when a literal is missing its kind-specific payload.\n * `null` is returned for unknown literal kinds to keep the resolver non-throwing.\n */\nexport type UnwrappedLiteral =\n | string\n | number\n | boolean\n | null\n | undefined\n | UnwrappedLiteral[]\n | { [key: string]: UnwrappedLiteral };\n\n/**\n * Resolves a `LiteralValue` into its native JavaScript representation.\n *\n * Pass a generic when you already know the expected shape.\n * Omit it to get `unknown` and narrow the result yourself.\n *\n * The generic only affects TypeScript types. It does not validate the runtime value.\n */\nexport function unwrapLiteral<T = unknown>(value: LiteralValue): T {\n return unwrapLiteralValue(value) as T;\n}\n\n/**\n * Performs the recursive literal resolution used by `unwrapLiteral`.\n */\nfunction unwrapLiteralValue(value: LiteralValue): UnwrappedLiteral {\n switch (value.kind) {\n case \"string\":\n return value.stringValue;\n case \"int\":\n return value.intValue;\n case \"float\":\n return value.floatValue;\n case \"bool\":\n return value.boolValue;\n case \"object\": {\n const resolvedObject: { [key: string]: UnwrappedLiteral } = {};\n const entries = value.objectEntries ?? [];\n\n for (const entry of entries) {\n resolvedObject[entry.key] = unwrapLiteralValue(entry.value);\n }\n\n return resolvedObject;\n }\n case \"array\": {\n const items = value.arrayItems ?? [];\n return items.map((item) => unwrapLiteralValue(item));\n }\n default:\n return null;\n }\n}\n","/**\n * Returns a string option or the provided fallback when the key is missing.\n */\nexport function getOptionString(\n options: Record<string, string> | undefined,\n key: string,\n defaultValue: string,\n): string {\n const value = options?.[key];\n return value === undefined ? defaultValue : value;\n}\n\n/**\n * Returns a boolean option using common truthy and falsy string values.\n *\n * Accepted truthy values: `true`, `1`, `yes`, `on`, `enable`, `enabled`, `y`.\n *\n * Accepted falsy values: `false`, `0`, `no`, `off`, `disable`, `disabled`, `n`.\n *\n * Invalid values fall back to the provided default.\n */\nexport function getOptionBool(\n options: Record<string, string> | undefined,\n key: string,\n defaultValue: boolean,\n): boolean {\n const value = options?.[key];\n\n if (value === undefined) {\n return defaultValue;\n }\n\n switch (value.trim().toLowerCase()) {\n case \"true\":\n case \"1\":\n case \"yes\":\n case \"on\":\n case \"enable\":\n case \"enabled\":\n case \"y\":\n return true;\n case \"false\":\n case \"0\":\n case \"no\":\n case \"off\":\n case \"disable\":\n case \"disabled\":\n case \"n\":\n return false;\n default:\n return defaultValue;\n }\n}\n\n/**\n * Returns a numeric option or the provided fallback when parsing fails.\n *\n * Empty, invalid, and non-finite values fall back to the default.\n */\nexport function getOptionNumber(\n options: Record<string, string> | undefined,\n key: string,\n defaultValue: number,\n): number {\n const value = options?.[key];\n\n if (value === undefined) {\n return defaultValue;\n }\n\n const trimmedValue = value.trim();\n\n if (trimmedValue === \"\") {\n return defaultValue;\n }\n\n const parsedValue = Number(trimmedValue);\n return Number.isFinite(parsedValue) ? parsedValue : defaultValue;\n}\n\n/**\n * Returns a string array option from a separator-delimited value.\n *\n * Empty items are removed and each entry is trimmed.\n *\n * Missing values return the provided default.\n *\n * @example\n * // For options: { \"features\": \"feature1, feature2, feature3\" }\n * getOptionArray(options, \"features\", [], \",\")\n * // returns [\"feature1\", \"feature2\", \"feature3\"]\n */\nexport function getOptionArray(\n options: Record<string, string> | undefined,\n key: string,\n defaultValue: string[] = [],\n separator = \",\",\n): string[] {\n const value = options?.[key];\n\n if (value === undefined) {\n return defaultValue;\n }\n\n const trimmedValue = value.trim();\n\n if (trimmedValue === \"\") {\n return [];\n }\n\n return trimmedValue\n .split(separator)\n .map((item) => item.trim())\n .filter((item) => item.length > 0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aAAa,SAA6C;AACxE,QAAO;;;;ACbT,MAAa,oBAAqC,CAChD,UACA,MACD;AAED,SAAgB,gBAAgB,OAAwC;AACtE,QAAO,kBAAkB,SAAS,MAAuB;;AAa3D,MAAa,kBAAiC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,cAAc,OAAsC;AAClE,QAAO,gBAAgB,SAAS,MAAqB;;AAQvD,MAAa,oBAAqC;CAChD;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,gBAAgB,OAAwC;AACtE,QAAO,kBAAkB,SAAS,MAAuB;;AAQ3D,MAAa,eAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,WAAW,OAAmC;AAC5D,QAAO,aAAa,SAAS,MAAkB;;AAmBjD,SAAgB,k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