@varavel/vdl-plugin-sdk 0.0.0 → 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.
- package/LICENSE +0 -0
- package/README.md +120 -0
- package/bin/vdl-plugin.js +66 -0
- package/dist/{ir.cjs → index.cjs} +159 -2
- package/dist/index.cjs.map +1 -0
- package/dist/{ir.d.cts → index.d.cts} +128 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/{ir.d.ts → index.d.ts} +128 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/{ir.js → index.js} +148 -3
- package/dist/index.js.map +1 -0
- package/package.json +18 -5
- package/schemas/common/position.vdl +14 -0
- package/schemas/ir.vdl +319 -0
- package/schemas/plugin.vdl +19 -0
- package/schemas/plugin_input.vdl +30 -0
- package/schemas/plugin_output.vdl +72 -0
- package/src/define-plugin.ts +33 -0
- package/src/index.ts +6 -0
- package/src/runtime.ts +10 -0
- package/src/types/index.ts +10 -0
- package/src/{ir.ts → types/types.ts} +341 -282
- package/src/utils/annotations.test.ts +86 -0
- package/src/utils/annotations.ts +26 -0
- package/src/utils/literals.test.ts +115 -0
- package/src/utils/literals.ts +60 -0
- package/tsconfig.base.json +18 -0
- package/dist/ir.cjs.map +0 -1
- package/dist/ir.d.cts.map +0 -1
- package/dist/ir.d.ts.map +0 -1
- package/dist/ir.js.map +0 -1
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
- A `vdl-plugin` binary that supports `check` and `build`.
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
Every VDL plugin should export a `definePlugin(...)` handler from `src/index.ts`.
|
|
55
|
+
|
|
56
|
+
Create `src/index.ts` in your plugin project:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { definePlugin } from "@varavel/vdl-plugin-sdk";
|
|
60
|
+
|
|
61
|
+
export const generate = definePlugin((_input) => {
|
|
62
|
+
// Your plugin logic goes here.
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
files: [
|
|
66
|
+
{
|
|
67
|
+
path: "hello.txt",
|
|
68
|
+
content: "Hello from VDL Plugin SDK",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Plugin Workflow
|
|
76
|
+
|
|
77
|
+
Every plugin follows the same release flow:
|
|
78
|
+
|
|
79
|
+
1. Create and export a `definePlugin(...)` handler in `./src/index.ts`.
|
|
80
|
+
2. Run `vdl-plugin build` to bundle the plugin into `./dist/index.js`.
|
|
81
|
+
3. Commit `./dist/index.js` to the repository.
|
|
82
|
+
4. Publish a new release on GitHub including all your files (including `./dist/index.js`).
|
|
83
|
+
5. When the plugin is used, VDL reads `./dist/index.js` directly from your GitHub relases.
|
|
84
|
+
|
|
85
|
+
## CLI
|
|
86
|
+
|
|
87
|
+
Use the bundled binary in scripts or with `npx`:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx vdl-plugin check
|
|
91
|
+
npx vdl-plugin build
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- `check` runs TypeScript without emitting files.
|
|
95
|
+
- `build` bundles the required `src/index.ts` entry into `dist/index.js`.
|
|
96
|
+
|
|
97
|
+
Example `package.json` scripts:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"scripts": {
|
|
102
|
+
"check": "vdl-plugin check",
|
|
103
|
+
"build": "vdl-plugin build"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## TypeScript Setup
|
|
109
|
+
|
|
110
|
+
You can extend the shared base config exported by the SDK:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"extends": "@varavel/vdl-plugin-sdk/tsconfig.base.json"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
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/
|
|
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,67 @@ 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
|
|
387
532
|
exports.EnumValueTypeList = EnumValueTypeList;
|
|
388
533
|
exports.LiteralKindList = LiteralKindList;
|
|
389
534
|
exports.PrimitiveTypeList = PrimitiveTypeList;
|
|
390
535
|
exports.TypeKindList = TypeKindList;
|
|
536
|
+
exports.definePlugin = definePlugin;
|
|
537
|
+
exports.getAnnotation = getAnnotation;
|
|
538
|
+
exports.getAnnotationArgs = getAnnotationArgs;
|
|
391
539
|
exports.hydrateAnnotation = hydrateAnnotation;
|
|
392
540
|
exports.hydrateConstantDef = hydrateConstantDef;
|
|
393
541
|
exports.hydrateEnumDef = hydrateEnumDef;
|
|
@@ -396,6 +544,10 @@ exports.hydrateField = hydrateField;
|
|
|
396
544
|
exports.hydrateIrSchema = hydrateIrSchema;
|
|
397
545
|
exports.hydrateLiteralValue = hydrateLiteralValue;
|
|
398
546
|
exports.hydrateObjectEntry = hydrateObjectEntry;
|
|
547
|
+
exports.hydratePluginInput = hydratePluginInput;
|
|
548
|
+
exports.hydratePluginOutput = hydratePluginOutput;
|
|
549
|
+
exports.hydratePluginOutputError = hydratePluginOutputError;
|
|
550
|
+
exports.hydratePluginOutputFile = hydratePluginOutputFile;
|
|
399
551
|
exports.hydratePosition = hydratePosition;
|
|
400
552
|
exports.hydrateTopLevelDoc = hydrateTopLevelDoc;
|
|
401
553
|
exports.hydrateTypeDef = hydrateTypeDef;
|
|
@@ -404,6 +556,7 @@ exports.isEnumValueType = isEnumValueType;
|
|
|
404
556
|
exports.isLiteralKind = isLiteralKind;
|
|
405
557
|
exports.isPrimitiveType = isPrimitiveType;
|
|
406
558
|
exports.isTypeKind = isTypeKind;
|
|
559
|
+
exports.unwrapLiteral = unwrapLiteral;
|
|
407
560
|
exports.validateAnnotation = validateAnnotation;
|
|
408
561
|
exports.validateConstantDef = validateConstantDef;
|
|
409
562
|
exports.validateEnumDef = validateEnumDef;
|
|
@@ -412,9 +565,13 @@ exports.validateField = validateField;
|
|
|
412
565
|
exports.validateIrSchema = validateIrSchema;
|
|
413
566
|
exports.validateLiteralValue = validateLiteralValue;
|
|
414
567
|
exports.validateObjectEntry = validateObjectEntry;
|
|
568
|
+
exports.validatePluginInput = validatePluginInput;
|
|
569
|
+
exports.validatePluginOutput = validatePluginOutput;
|
|
570
|
+
exports.validatePluginOutputError = validatePluginOutputError;
|
|
571
|
+
exports.validatePluginOutputFile = validatePluginOutputFile;
|
|
415
572
|
exports.validatePosition = validatePosition;
|
|
416
573
|
exports.validateTopLevelDoc = validateTopLevelDoc;
|
|
417
574
|
exports.validateTypeDef = validateTypeDef;
|
|
418
575
|
exports.validateTypeRef = validateTypeRef;
|
|
419
576
|
|
|
420
|
-
//# sourceMappingURL=
|
|
577
|
+
//# 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"],"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"],"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,kBAAkB,OAA+B;AAI/D,QAAO;EACL,UAJuB,gBAAgB,MAAM,SAAS;EAKtD,MAJmB,MAAM;EAKzB,UAJuB,MAAM,WAAW,oBAAoB,MAAM,SAAS,GAAG,MAAM;EAKrF;;AAGH,SAAgB,mBAAmB,OAAgB,OAAO,cAA6B;AACrF,KAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,OAAO,UAAU,SAC5D,QAAO,GAAG,KAAK,yBAAyB,OAAO;CAEjD,MAAM,MAAM;AAEZ,KAAI,IAAI,aAAa,KAAA,KAAa,IAAI,aAAa,KACjD,QAAO,GAAG,KAAK;CAEjB;EACE,MAAM,MAAM,iBAAiB,IAAI,UAAU,GAAG,KAAK,WAAW;AAC9D,MAAI,QAAQ,KAAM,QAAO;;AAE3B,KAAI,IAAI,aAAa,KAAA,KAAa,I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AAA,KAAA,IAAO,KAAM;;;;;;;;;;;;ACCf,SAAgB,cAA2B,OAAwB;AACjE,QAAO,mBAAmB,MAAM;;;;;AAMlC,SAAS,mBAAmB,OAAuC;AACjE,SAAQ,MAAM,MAAd;EACE,KAAK,SACH,QAAO,MAAM;EACf,KAAK,MACH,QAAO,MAAM;EACf,KAAK,QACH,QAAO,MAAM;EACf,KAAK,OACH,QAAO,MAAM;EACf,KAAK,UAAU;;GACb,MAAM,iBAAsD,EAAE;GAC9D,MAAM,WAAA,uBAAU,MAAM,mBAAA,QAAA,yBAAA,KAAA,IAAA,uBAAiB,EAAE;AAEzC,QAAK,MAAM,SAAS,QAClB,gBAAe,MAAM,OAAO,mBAAmB,MAAM,MAAM;AAG7D,UAAO;;EAET,KAAK;;AAEH,YAAA,oBADc,MAAM,gBAAA,QAAA,sBAAA,KAAA,IAAA,oBAAc,EAAE,EACvB,KAAK,SAAS,mBAAmB,KAAK,CAAC;EAEtD,QACE,QAAO"}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/runtime.d.ts
|
|
2
|
+
declare global {
|
|
3
|
+
const console: {
|
|
4
|
+
log(...args: unknown[]): void;
|
|
5
|
+
info(...args: unknown[]): void;
|
|
6
|
+
warn(...args: unknown[]): void;
|
|
7
|
+
error(...args: unknown[]): void;
|
|
8
|
+
};
|
|
9
|
+
} //# sourceMappingURL=runtime.d.ts.map
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/types/types.d.ts
|
|
2
12
|
/**
|
|
3
13
|
* Underlying storage kind used by an enum
|
|
4
14
|
*/
|
|
@@ -152,6 +162,58 @@ type ObjectEntry = {
|
|
|
152
162
|
};
|
|
153
163
|
declare function hydrateObjectEntry(input: ObjectEntry): ObjectEntry;
|
|
154
164
|
declare function validateObjectEntry(input: unknown, path?: string): string | null;
|
|
165
|
+
/**
|
|
166
|
+
* PluginInput PluginInput represents the data payload sent to a plugin.
|
|
167
|
+
*
|
|
168
|
+
* The plugin receives this as a single argument containing the complete
|
|
169
|
+
* Intermediate Representation of the VDL schema along with any user-defined
|
|
170
|
+
* configuration options from `vdl.config.vdl`.
|
|
171
|
+
*/
|
|
172
|
+
type PluginInput = {
|
|
173
|
+
version: string;
|
|
174
|
+
ir: IrSchema;
|
|
175
|
+
options: Record<string, string>;
|
|
176
|
+
};
|
|
177
|
+
declare function hydratePluginInput(input: PluginInput): PluginInput;
|
|
178
|
+
declare function validatePluginInput(input: unknown, path?: string): string | null;
|
|
179
|
+
/**
|
|
180
|
+
* PluginOutput PluginOutput represents the response payload returned by the `plugin` function.
|
|
181
|
+
*
|
|
182
|
+
* After processing the input schema, the plugin outputs this object containing
|
|
183
|
+
* all files to be generated or errors to be displayed to the user.
|
|
184
|
+
*
|
|
185
|
+
* If there are no errors and at least one file is returned, VDL will write each
|
|
186
|
+
* file to the specified path within the output directory. If there are errors,
|
|
187
|
+
* VDL will display them to the user and not write any files.
|
|
188
|
+
*/
|
|
189
|
+
type PluginOutput = {
|
|
190
|
+
files?: PluginOutputFile[];
|
|
191
|
+
errors?: PluginOutputError[];
|
|
192
|
+
};
|
|
193
|
+
declare function hydratePluginOutput(input: PluginOutput): PluginOutput;
|
|
194
|
+
declare function validatePluginOutput(input: unknown, path?: string): string | null;
|
|
195
|
+
/**
|
|
196
|
+
* PluginOutputError A structured error reported by the plugin.
|
|
197
|
+
*/
|
|
198
|
+
type PluginOutputError = {
|
|
199
|
+
message: string;
|
|
200
|
+
position?: Position;
|
|
201
|
+
};
|
|
202
|
+
declare function hydratePluginOutputError(input: PluginOutputError): PluginOutputError;
|
|
203
|
+
declare function validatePluginOutputError(input: unknown, path?: string): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* PluginOutputFile PluginOutputFile represents a single generated file produced by the plugin.
|
|
206
|
+
*
|
|
207
|
+
* This abstraction allows plugins to generate multiple files from a single
|
|
208
|
+
* invocation, enabling patterns like one-file-per-type or splitting large
|
|
209
|
+
* outputs across multiple modules.
|
|
210
|
+
*/
|
|
211
|
+
type PluginOutputFile = {
|
|
212
|
+
path: string;
|
|
213
|
+
content: string;
|
|
214
|
+
};
|
|
215
|
+
declare function hydratePluginOutputFile(input: PluginOutputFile): PluginOutputFile;
|
|
216
|
+
declare function validatePluginOutputFile(_input: unknown, _path?: string): string | null;
|
|
155
217
|
/**
|
|
156
218
|
* Position It represents a position within a file and is used for error
|
|
157
219
|
* reporting, diagnostics, plugins, and tooling support.
|
|
@@ -209,5 +271,68 @@ type TypeRef = {
|
|
|
209
271
|
declare function hydrateTypeRef(input: TypeRef): TypeRef;
|
|
210
272
|
declare function validateTypeRef(input: unknown, path?: string): string | null;
|
|
211
273
|
//#endregion
|
|
212
|
-
|
|
213
|
-
|
|
274
|
+
//#region src/define-plugin.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* Defines a VDL plugin handler function.
|
|
277
|
+
*
|
|
278
|
+
* @param input - The input data for the plugin containing the IR and other relevant information.
|
|
279
|
+
* @returns The output data from the plugin containing the generated files and any errors.
|
|
280
|
+
*/
|
|
281
|
+
type VdlPluginHandler = (input: PluginInput) => PluginOutput;
|
|
282
|
+
/**
|
|
283
|
+
* Defines a VDL plugin by wrapping the provided handler function. This is a helper function
|
|
284
|
+
* that can be used to create plugins in a more concise way.
|
|
285
|
+
*
|
|
286
|
+
* Example usage:
|
|
287
|
+
* ```typescript
|
|
288
|
+
* import { definePlugin } from "@varavel/vdl-plugin-sdk";
|
|
289
|
+
*
|
|
290
|
+
* export const generate = definePlugin((input) => {
|
|
291
|
+
* // Plugin logic goes here
|
|
292
|
+
* return {
|
|
293
|
+
* files: [],
|
|
294
|
+
* errors: []
|
|
295
|
+
* };
|
|
296
|
+
* });
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @param handler - The plugin handler function that contains the logic for processing the input and generating the output.
|
|
300
|
+
* @returns The same handler function, which can be exported as the plugin's main entry point.
|
|
301
|
+
*/
|
|
302
|
+
declare function definePlugin(handler: VdlPluginHandler): VdlPluginHandler;
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/utils/annotations.d.ts
|
|
305
|
+
/**
|
|
306
|
+
* Returns the first annotation that matches the provided name.
|
|
307
|
+
*/
|
|
308
|
+
declare function getAnnotation(annotations: Annotation[] | undefined, name: string): Annotation | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* Returns the raw literal argument stored in an annotation.
|
|
311
|
+
*
|
|
312
|
+
* VDL annotations currently expose a single literal argument.
|
|
313
|
+
* Pair this helper with `unwrapLiteral` when you need a plain JavaScript value.
|
|
314
|
+
*/
|
|
315
|
+
declare function getAnnotationArgs(annotations: Annotation[] | undefined, name: string): LiteralValue | undefined;
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/utils/literals.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Native JavaScript value produced by `unwrapLiteral`.
|
|
320
|
+
*
|
|
321
|
+
* `undefined` is preserved when a literal is missing its kind-specific payload.
|
|
322
|
+
* `null` is returned for unknown literal kinds to keep the resolver non-throwing.
|
|
323
|
+
*/
|
|
324
|
+
type UnwrappedLiteral = string | number | boolean | null | undefined | UnwrappedLiteral[] | {
|
|
325
|
+
[key: string]: UnwrappedLiteral;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Resolves a `LiteralValue` into its native JavaScript representation.
|
|
329
|
+
*
|
|
330
|
+
* Pass a generic when you already know the expected shape.
|
|
331
|
+
* Omit it to get `unknown` and narrow the result yourself.
|
|
332
|
+
*
|
|
333
|
+
* The generic only affects TypeScript types. It does not validate the runtime value.
|
|
334
|
+
*/
|
|
335
|
+
declare function unwrapLiteral<T = unknown>(value: LiteralValue): T;
|
|
336
|
+
//#endregion
|
|
337
|
+
export { Annotation, ConstantDef, EnumDef, EnumMember, EnumValueType, EnumValueTypeList, Field, IrSchema, LiteralKind, LiteralKindList, LiteralValue, ObjectEntry, PluginInput, PluginOutput, PluginOutputError, PluginOutputFile, Position, PrimitiveType, PrimitiveTypeList, TopLevelDoc, TypeDef, TypeKind, TypeKindList, TypeRef, UnwrappedLiteral, VdlPluginHandler, definePlugin, getAnnotation, getAnnotationArgs, hydrateAnnotation, hydrateConstantDef, hydrateEnumDef, hydrateEnumMember, hydrateField, hydrateIrSchema, hydrateLiteralValue, hydrateObjectEntry, hydratePluginInput, hydratePluginOutput, hydratePluginOutputError, hydratePluginOutputFile, hydratePosition, hydrateTopLevelDoc, hydrateTypeDef, hydrateTypeRef, isEnumValueType, isLiteralKind, isPrimitiveType, isTypeKind, unwrapLiteral, validateAnnotation, validateConstantDef, validateEnumDef, validateEnumMember, validateField, validateIrSchema, validateLiteralValue, validateObjectEntry, validatePluginInput, validatePluginOutput, validatePluginOutputError, validatePluginOutputFile, validatePosition, validateTopLevelDoc, validateTypeDef, validateTypeRef };
|
|
338
|
+
//# sourceMappingURL=index.d.cts.map
|