@ir-kit/asyncapi-typescript 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.md +21 -0
- package/README.md +124 -0
- package/dist/ast/raw-text-node.d.ts +21 -0
- package/dist/ast/raw-text-node.d.ts.map +1 -0
- package/dist/ast/raw-text-node.js +37 -0
- package/dist/ast/raw-text-node.js.map +1 -0
- package/dist/ast/ts-build.d.ts +42 -0
- package/dist/ast/ts-build.d.ts.map +1 -0
- package/dist/ast/ts-build.js +93 -0
- package/dist/ast/ts-build.js.map +1 -0
- package/dist/ast/ts-node.d.ts +25 -0
- package/dist/ast/ts-node.d.ts.map +1 -0
- package/dist/ast/ts-node.js +41 -0
- package/dist/ast/ts-node.js.map +1 -0
- package/dist/ast/ts-renderer.d.ts +21 -0
- package/dist/ast/ts-renderer.d.ts.map +1 -0
- package/dist/ast/ts-renderer.js +79 -0
- package/dist/ast/ts-renderer.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator.d.ts +13 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +63 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/plugin.d.ts +149 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +51 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/amqplib/bundle/amqp.gen.ts +99 -0
- package/dist/plugins/amqplib/config.d.ts +3 -0
- package/dist/plugins/amqplib/config.d.ts.map +1 -0
- package/dist/plugins/amqplib/config.js +2 -0
- package/dist/plugins/amqplib/config.js.map +1 -0
- package/dist/plugins/amqplib/index.d.ts +3 -0
- package/dist/plugins/amqplib/index.d.ts.map +1 -0
- package/dist/plugins/amqplib/index.js +2 -0
- package/dist/plugins/amqplib/index.js.map +1 -0
- package/dist/plugins/amqplib/plugin.d.ts +4 -0
- package/dist/plugins/amqplib/plugin.d.ts.map +1 -0
- package/dist/plugins/amqplib/plugin.js +18 -0
- package/dist/plugins/amqplib/plugin.js.map +1 -0
- package/dist/plugins/amqplib/types.d.ts +5 -0
- package/dist/plugins/amqplib/types.d.ts.map +1 -0
- package/dist/plugins/amqplib/types.js +2 -0
- package/dist/plugins/amqplib/types.js.map +1 -0
- package/dist/plugins/dispatch/bundle/dispatch.gen.ts +188 -0
- package/dist/plugins/dispatch/config.d.ts +3 -0
- package/dist/plugins/dispatch/config.d.ts.map +1 -0
- package/dist/plugins/dispatch/config.js +2 -0
- package/dist/plugins/dispatch/config.js.map +1 -0
- package/dist/plugins/dispatch/index.d.ts +3 -0
- package/dist/plugins/dispatch/index.d.ts.map +1 -0
- package/dist/plugins/dispatch/index.js +2 -0
- package/dist/plugins/dispatch/index.js.map +1 -0
- package/dist/plugins/dispatch/plugin.d.ts +12 -0
- package/dist/plugins/dispatch/plugin.d.ts.map +1 -0
- package/dist/plugins/dispatch/plugin.js +54 -0
- package/dist/plugins/dispatch/plugin.js.map +1 -0
- package/dist/plugins/dispatch/types.d.ts +6 -0
- package/dist/plugins/dispatch/types.d.ts.map +1 -0
- package/dist/plugins/dispatch/types.js +2 -0
- package/dist/plugins/dispatch/types.js.map +1 -0
- package/dist/plugins/event-map/config.d.ts +3 -0
- package/dist/plugins/event-map/config.d.ts.map +1 -0
- package/dist/plugins/event-map/config.js +4 -0
- package/dist/plugins/event-map/config.js.map +1 -0
- package/dist/plugins/event-map/index.d.ts +3 -0
- package/dist/plugins/event-map/index.d.ts.map +1 -0
- package/dist/plugins/event-map/index.js +2 -0
- package/dist/plugins/event-map/index.js.map +1 -0
- package/dist/plugins/event-map/plugin.d.ts +3 -0
- package/dist/plugins/event-map/plugin.d.ts.map +1 -0
- package/dist/plugins/event-map/plugin.js +62 -0
- package/dist/plugins/event-map/plugin.js.map +1 -0
- package/dist/plugins/event-map/types.d.ts +8 -0
- package/dist/plugins/event-map/types.d.ts.map +1 -0
- package/dist/plugins/event-map/types.js +2 -0
- package/dist/plugins/event-map/types.js.map +1 -0
- package/dist/plugins/events/config.d.ts +3 -0
- package/dist/plugins/events/config.d.ts.map +1 -0
- package/dist/plugins/events/config.js +4 -0
- package/dist/plugins/events/config.js.map +1 -0
- package/dist/plugins/events/index.d.ts +3 -0
- package/dist/plugins/events/index.d.ts.map +1 -0
- package/dist/plugins/events/index.js +2 -0
- package/dist/plugins/events/index.js.map +1 -0
- package/dist/plugins/events/plugin.d.ts +3 -0
- package/dist/plugins/events/plugin.d.ts.map +1 -0
- package/dist/plugins/events/plugin.js +48 -0
- package/dist/plugins/events/plugin.js.map +1 -0
- package/dist/plugins/events/types.d.ts +8 -0
- package/dist/plugins/events/types.d.ts.map +1 -0
- package/dist/plugins/events/types.js +2 -0
- package/dist/plugins/events/types.js.map +1 -0
- package/dist/plugins/index-barrel/config.d.ts +3 -0
- package/dist/plugins/index-barrel/config.d.ts.map +1 -0
- package/dist/plugins/index-barrel/config.js +2 -0
- package/dist/plugins/index-barrel/config.js.map +1 -0
- package/dist/plugins/index-barrel/index.d.ts +3 -0
- package/dist/plugins/index-barrel/index.d.ts.map +1 -0
- package/dist/plugins/index-barrel/index.js +2 -0
- package/dist/plugins/index-barrel/index.js.map +1 -0
- package/dist/plugins/index-barrel/plugin.d.ts +9 -0
- package/dist/plugins/index-barrel/plugin.d.ts.map +1 -0
- package/dist/plugins/index-barrel/plugin.js +47 -0
- package/dist/plugins/index-barrel/plugin.js.map +1 -0
- package/dist/plugins/index-barrel/types.d.ts +5 -0
- package/dist/plugins/index-barrel/types.d.ts.map +1 -0
- package/dist/plugins/index-barrel/types.js +2 -0
- package/dist/plugins/index-barrel/types.js.map +1 -0
- package/dist/plugins/typescript/config.d.ts +3 -0
- package/dist/plugins/typescript/config.d.ts.map +1 -0
- package/dist/plugins/typescript/config.js +4 -0
- package/dist/plugins/typescript/config.js.map +1 -0
- package/dist/plugins/typescript/index.d.ts +3 -0
- package/dist/plugins/typescript/index.d.ts.map +1 -0
- package/dist/plugins/typescript/index.js +2 -0
- package/dist/plugins/typescript/index.js.map +1 -0
- package/dist/plugins/typescript/plugin.d.ts +13 -0
- package/dist/plugins/typescript/plugin.d.ts.map +1 -0
- package/dist/plugins/typescript/plugin.js +67 -0
- package/dist/plugins/typescript/plugin.js.map +1 -0
- package/dist/plugins/typescript/types.d.ts +8 -0
- package/dist/plugins/typescript/types.d.ts.map +1 -0
- package/dist/plugins/typescript/types.js +2 -0
- package/dist/plugins/typescript/types.js.map +1 -0
- package/dist/runtime/copy-bundle.d.ts +16 -0
- package/dist/runtime/copy-bundle.d.ts.map +1 -0
- package/dist/runtime/copy-bundle.js +38 -0
- package/dist/runtime/copy-bundle.js.map +1 -0
- package/dist/runtime/load-document.d.ts +8 -0
- package/dist/runtime/load-document.d.ts.map +1 -0
- package/dist/runtime/load-document.js +21 -0
- package/dist/runtime/load-document.js.map +1 -0
- package/dist/runtime/order-plugins.d.ts +8 -0
- package/dist/runtime/order-plugins.d.ts.map +1 -0
- package/dist/runtime/order-plugins.js +31 -0
- package/dist/runtime/order-plugins.js.map +1 -0
- package/dist/runtime/plugin-instance.d.ts +18 -0
- package/dist/runtime/plugin-instance.d.ts.map +1 -0
- package/dist/runtime/plugin-instance.js +72 -0
- package/dist/runtime/plugin-instance.js.map +1 -0
- package/package.json +84 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ahmed Rowaihi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @ir-kit/asyncapi-typescript
|
|
2
|
+
|
|
3
|
+
AsyncAPI 3.0 → TypeScript generator. Plugin-compose architecture.
|
|
4
|
+
|
|
5
|
+
Each plugin emits one slice of generated code (types, Events const, dispatch helpers, AMQP helpers, framework adapters). Caller picks which plugins to enable; orchestrator topologically sorts by `dependsOn` and writes via `@hey-api/codegen-core`'s `Project` pipeline.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add -D @ir-kit/asyncapi-typescript
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer deps (most are dev-only at consumer side):
|
|
14
|
+
|
|
15
|
+
- `@asyncapi/parser` `>=3.0.0`
|
|
16
|
+
- `@asyncapi/modelina` `>=5.0.0`
|
|
17
|
+
- `@hey-api/codegen-core` `>=0.8.0`
|
|
18
|
+
- `@ir-kit/asyncapi-core`, `@ir-kit/asyncapi-core`, `@ir-kit/codegen-core`
|
|
19
|
+
- `typescript` `>=5.0.0`
|
|
20
|
+
- `amqplib` `>=0.10.0` *(optional — only if you enable the `amqplib` plugin)*
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
amqplib,
|
|
27
|
+
dispatch,
|
|
28
|
+
eventMap,
|
|
29
|
+
events,
|
|
30
|
+
generate,
|
|
31
|
+
indexBarrel,
|
|
32
|
+
typescript,
|
|
33
|
+
} from "@ir-kit/asyncapi-typescript";
|
|
34
|
+
|
|
35
|
+
await generate({
|
|
36
|
+
input: "./asyncapi.yaml",
|
|
37
|
+
output: "./generated",
|
|
38
|
+
plugins: [
|
|
39
|
+
typescript(),
|
|
40
|
+
events(),
|
|
41
|
+
eventMap(),
|
|
42
|
+
dispatch(),
|
|
43
|
+
amqplib(),
|
|
44
|
+
indexBarrel(),
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For a full RabbitMQ run (producer + consumer end-to-end), see `examples/asyncapi-events-playground/` in the ir-kit monorepo.
|
|
50
|
+
|
|
51
|
+
## Built-in plugins
|
|
52
|
+
|
|
53
|
+
| Plugin | File(s) emitted | Description |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `typescript()` | `types.gen.ts` | TS interfaces from message payload schemas (via `@asyncapi/modelina`). Names taken from spec message ids. |
|
|
56
|
+
| `events()` | `events.gen.ts` | `Events` const with `{type, routingKey, exchange, exchangeType, contentType}` per channel/operation, plus an `EventName` type alias |
|
|
57
|
+
| `eventMap()` | `event-map.gen.ts` | `EventMap` keyed by event-type literal → message interface, `AnyMessage` union, `isMessageOfType` discriminator |
|
|
58
|
+
| `dispatch()` | `dispatch.gen.ts` + `handlers.gen.ts` | Generic `Registry` runtime (with `.on(...)`, `.dispatch`, `.toCallback(...)`, `.bindings`) + spec-bound `handlers()` factory |
|
|
59
|
+
| `amqplib()` | `amqp.gen.ts` | `assertExchanges` / `bindAndConsume` / `publish` helpers — pure passthroughs to `amqplib` (no hidden defaults) |
|
|
60
|
+
| `indexBarrel()` | `index.gen.ts` | Barrel re-export of every other enabled plugin's surface |
|
|
61
|
+
|
|
62
|
+
Plugins compose freely. Each plugin's `dependsOn` ensures correct ordering even if the user lists them out of order.
|
|
63
|
+
|
|
64
|
+
## Authoring custom plugins
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { definePluginConfig } from "@ir-kit/asyncapi-typescript";
|
|
68
|
+
|
|
69
|
+
export const myPlugin = definePluginConfig<
|
|
70
|
+
"my-plugin",
|
|
71
|
+
{ fileName?: string },
|
|
72
|
+
{ fileName: string },
|
|
73
|
+
unknown
|
|
74
|
+
>({
|
|
75
|
+
name: "my-plugin",
|
|
76
|
+
defaultConfig: { fileName: "my.gen.ts" },
|
|
77
|
+
dependsOn: ["typescript"], // run after the typescript plugin
|
|
78
|
+
handler(plugin) {
|
|
79
|
+
for (const ev of plugin.forEach("message")) {
|
|
80
|
+
if (ev.type !== "message") continue;
|
|
81
|
+
// ...inspect ev.message...
|
|
82
|
+
}
|
|
83
|
+
plugin.emit({
|
|
84
|
+
path: plugin.config.fileName,
|
|
85
|
+
content: "// my custom code\n",
|
|
86
|
+
});
|
|
87
|
+
// or, for AST emission:
|
|
88
|
+
// plugin.emitTs("my.gen.ts", [ts.factory.createXxx(...), ...], { header: "// ..." });
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The `PluginInstance` exposes:
|
|
94
|
+
|
|
95
|
+
- `plugin.config` — typed resolved config
|
|
96
|
+
- `plugin.api` — typed plugin api (other plugins fetch via `plugin.getApi(name)`)
|
|
97
|
+
- `plugin.document` — the parsed `AsyncAPIDocumentInterface`
|
|
98
|
+
- `plugin.files` — files emitted so far (for plugins like `index-barrel` that inspect prior output)
|
|
99
|
+
- `plugin.emit({path, content})` — emit a file as raw text
|
|
100
|
+
- `plugin.emitTs(path, statements, {header?})` — emit a file as `ts.Statement[]` (rendered via TypeScript's printer)
|
|
101
|
+
- `plugin.getApi<T>(name)` — fetch another plugin's exposed api
|
|
102
|
+
- `plugin.forEach('message' | 'channel' | 'operation', ...)` — iterate spec entities
|
|
103
|
+
|
|
104
|
+
## How the pipeline works
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
asyncapi.yaml
|
|
108
|
+
└─ @asyncapi/parser → AsyncAPIDocumentInterface
|
|
109
|
+
└─ orchestrator (topological sort by dependsOn)
|
|
110
|
+
└─ for each plugin:
|
|
111
|
+
handler(PluginInstance)
|
|
112
|
+
├─ plugin.emit(rawText) → RawTextNode → Project.files
|
|
113
|
+
└─ plugin.emitTs(stmts) → TsStatementNode → Project.files
|
|
114
|
+
└─ project.plan() + project.render()
|
|
115
|
+
├─ TsStatementRenderer → ts.createPrinter
|
|
116
|
+
└─ RawTextRenderer → concat
|
|
117
|
+
└─ write outputs to disk
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Related
|
|
121
|
+
|
|
122
|
+
- [`actions/asyncapi-regen`](../../actions/asyncapi-regen) — GitHub Action wrapping this generator
|
|
123
|
+
- [`@ir-kit/openapi-typescript`](../openapi-typescript) — sister generator for OpenAPI 3.x specs
|
|
124
|
+
- [`fixtures/user-events.yaml`](../../fixtures/user-events.yaml) — minimal AsyncAPI 3.0 spec used by tests
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnalysisContext, Symbol as CoreSymbol, File, Node as ICoreNode, NodeScope } from "@hey-api/codegen-core";
|
|
2
|
+
/** INode wrapper around pre-rendered text. Used for Modelina output and bundle copies. */
|
|
3
|
+
export declare class RawTextNode implements ICoreNode<string> {
|
|
4
|
+
readonly "~brand" = "heyapi.node";
|
|
5
|
+
readonly language = "typescript";
|
|
6
|
+
exported?: boolean;
|
|
7
|
+
root: boolean;
|
|
8
|
+
scope?: NodeScope;
|
|
9
|
+
symbol?: CoreSymbol;
|
|
10
|
+
file?: File;
|
|
11
|
+
private _name;
|
|
12
|
+
private readonly _text;
|
|
13
|
+
constructor(text: string, options?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
});
|
|
16
|
+
get name(): ICoreNode["name"];
|
|
17
|
+
analyze(_: AnalysisContext): void;
|
|
18
|
+
clone(): this;
|
|
19
|
+
toAst(): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=raw-text-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-text-node.d.ts","sourceRoot":"","sources":["../../src/ast/raw-text-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,MAAM,IAAI,UAAU,EACpB,IAAI,EACJ,IAAI,IAAI,SAAS,EACjB,SAAS,EAEV,MAAM,uBAAuB,CAAC;AAG/B,0FAA0F;AAC1F,qBAAa,WAAY,YAAW,SAAS,CAAC,MAAM,CAAC;IACnD,QAAQ,CAAC,QAAQ,iBAAa;IAC9B,QAAQ,CAAC,QAAQ,gBAAgB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;IAMzD,IAAI,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,CAQ5B;IAED,OAAO,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI;IAEjC,KAAK,IAAI,IAAI;IAMb,KAAK,IAAI,MAAM;CAGhB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { nodeBrand, ref } from "@hey-api/codegen-core";
|
|
2
|
+
/** INode wrapper around pre-rendered text. Used for Modelina output and bundle copies. */
|
|
3
|
+
export class RawTextNode {
|
|
4
|
+
"~brand" = nodeBrand;
|
|
5
|
+
language = "typescript";
|
|
6
|
+
exported;
|
|
7
|
+
root;
|
|
8
|
+
scope;
|
|
9
|
+
symbol;
|
|
10
|
+
file;
|
|
11
|
+
_name;
|
|
12
|
+
_text;
|
|
13
|
+
constructor(text, options = {}) {
|
|
14
|
+
this._text = text;
|
|
15
|
+
this._name = ref(options.name ?? "raw");
|
|
16
|
+
this.root = true;
|
|
17
|
+
}
|
|
18
|
+
get name() {
|
|
19
|
+
return {
|
|
20
|
+
...this._name,
|
|
21
|
+
set: (value) => {
|
|
22
|
+
this._name = ref(typeof value === "string" ? value : String(value));
|
|
23
|
+
},
|
|
24
|
+
toString: () => this._name["~ref"],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
analyze(_) { }
|
|
28
|
+
clone() {
|
|
29
|
+
const cloned = Object.create(Object.getPrototypeOf(this));
|
|
30
|
+
Object.assign(cloned, this);
|
|
31
|
+
return cloned;
|
|
32
|
+
}
|
|
33
|
+
toAst() {
|
|
34
|
+
return this._text;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=raw-text-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-text-node.js","sourceRoot":"","sources":["../../src/ast/raw-text-node.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEvD,0FAA0F;AAC1F,MAAM,OAAO,WAAW;IACb,QAAQ,GAAG,SAAS,CAAC;IACrB,QAAQ,GAAG,YAAY,CAAC;IACjC,QAAQ,CAAW;IACnB,IAAI,CAAU;IACd,KAAK,CAAa;IAClB,MAAM,CAAc;IACpB,IAAI,CAAQ;IAEJ,KAAK,CAAc;IACV,KAAK,CAAS;IAE/B,YAAY,IAAY,EAAE,UAA6B,EAAE;QACvD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO;YACL,GAAG,IAAI,CAAC,KAAK;YACb,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;SACd,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,CAAkB,IAAS,CAAC;IAEpC,KAAK;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export declare const lit: {
|
|
3
|
+
readonly string: (s: string) => ts.StringLiteral;
|
|
4
|
+
readonly number: (n: number) => ts.NumericLiteral;
|
|
5
|
+
readonly boolean: (b: boolean) => ts.TrueLiteral | ts.FalseLiteral;
|
|
6
|
+
readonly null: () => ts.NullLiteral;
|
|
7
|
+
readonly undefined: () => ts.Identifier;
|
|
8
|
+
};
|
|
9
|
+
export declare function obj(entries: Readonly<Record<string, ts.Expression>>): ts.ObjectLiteralExpression;
|
|
10
|
+
export declare function arr(elements: ReadonlyArray<ts.Expression>): ts.ArrayLiteralExpression;
|
|
11
|
+
export declare function asConst(expr: ts.Expression): ts.AsExpression;
|
|
12
|
+
export declare function exportConst(name: string, init: ts.Expression): ts.VariableStatement;
|
|
13
|
+
export declare function exportTypeAlias(name: string, type: ts.TypeNode): ts.TypeAliasDeclaration;
|
|
14
|
+
export declare function exportInterface(name: string, members: ReadonlyArray<ts.TypeElement>): ts.InterfaceDeclaration;
|
|
15
|
+
export declare function exportFromBarrel(named: ReadonlyArray<{
|
|
16
|
+
name: string;
|
|
17
|
+
isType?: boolean;
|
|
18
|
+
}>, module: string): ts.ExportDeclaration;
|
|
19
|
+
export declare function exportTypeStarFrom(module: string): ts.ExportDeclaration;
|
|
20
|
+
export declare const tn: {
|
|
21
|
+
readonly ref: (name: string, args?: ReadonlyArray<ts.TypeNode>) => ts.TypeReferenceNode;
|
|
22
|
+
readonly string: () => ts.KeywordTypeNode<ts.SyntaxKind.StringKeyword>;
|
|
23
|
+
readonly number: () => ts.KeywordTypeNode<ts.SyntaxKind.NumberKeyword>;
|
|
24
|
+
readonly boolean: () => ts.KeywordTypeNode<ts.SyntaxKind.BooleanKeyword>;
|
|
25
|
+
readonly any: () => ts.KeywordTypeNode<ts.SyntaxKind.AnyKeyword>;
|
|
26
|
+
readonly unknown: () => ts.KeywordTypeNode<ts.SyntaxKind.UnknownKeyword>;
|
|
27
|
+
readonly never: () => ts.KeywordTypeNode<ts.SyntaxKind.NeverKeyword>;
|
|
28
|
+
readonly literalString: (s: string) => ts.LiteralTypeNode;
|
|
29
|
+
/** Property signature for an interface body: `name: type;` (or `name?: type;`). */
|
|
30
|
+
readonly property: (name: string, type: ts.TypeNode, optional?: boolean) => ts.PropertySignature;
|
|
31
|
+
readonly typeOf: (name: string) => ts.TypeQueryNode;
|
|
32
|
+
/** `keyof T` */
|
|
33
|
+
readonly keyOf: (inner: ts.TypeNode) => ts.TypeOperatorNode;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Print a list of top-level statements as the body of a TypeScript file.
|
|
37
|
+
* `header` is prepended verbatim (use it for the `// AUTO-GENERATED` line).
|
|
38
|
+
*/
|
|
39
|
+
export declare function printFile(statements: ReadonlyArray<ts.Node>, options?: {
|
|
40
|
+
header?: string;
|
|
41
|
+
}): string;
|
|
42
|
+
//# sourceMappingURL=ts-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-build.d.ts","sourceRoot":"","sources":["../../src/ast/ts-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAiB5B,eAAO,MAAM,GAAG;yBACF,MAAM;yBACN,MAAM;0BACL,OAAO;;;CAGZ,CAAC;AAEX,wBAAgB,GAAG,CACjB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,GAC/C,EAAE,CAAC,uBAAuB,CAO5B;AAED,wBAAgB,GAAG,CACjB,QAAQ,EAAE,aAAa,CAAC,EAAE,CAAC,UAAU,CAAC,GACrC,EAAE,CAAC,sBAAsB,CAE3B;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,YAAY,CAK5D;AAMD,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,EAAE,CAAC,UAAU,GAClB,EAAE,CAAC,iBAAiB,CAQtB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,EAAE,CAAC,QAAQ,GAChB,EAAE,CAAC,oBAAoB,CAOzB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,WAAW,CAAC,GACrC,EAAE,CAAC,oBAAoB,CAQzB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,EACxD,MAAM,EAAE,MAAM,GACb,EAAE,CAAC,iBAAiB,CAetB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAOvE;AAMD,eAAO,MAAM,EAAE;yBACD,MAAM,SAAS,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC;;;;;;;gCAQlC,MAAM;IAEzB,mFAAmF;8BAClE,MAAM,QAAQ,EAAE,CAAC,QAAQ;4BAO3B,MAAM;IAErB,gBAAgB;4BACD,EAAE,CAAC,QAAQ;CAElB,CAAC;AAgBX;;;GAGG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,EAClC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,MAAM,CAQR"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Tiny ergonomic shorthands over `ts.factory`. Inspired by hey-api's
|
|
4
|
+
* unpublished ts-dsl — same idea (typed AST builders + printer), built
|
|
5
|
+
* directly on the official TypeScript compiler API.
|
|
6
|
+
*
|
|
7
|
+
* Use these from plugins instead of string concatenation: refactor-safe,
|
|
8
|
+
* properly formatted, mistakes caught at compile time.
|
|
9
|
+
*/
|
|
10
|
+
const f = ts.factory;
|
|
11
|
+
// ============================================================
|
|
12
|
+
// Expressions
|
|
13
|
+
// ============================================================
|
|
14
|
+
export const lit = {
|
|
15
|
+
string: (s) => f.createStringLiteral(s),
|
|
16
|
+
number: (n) => f.createNumericLiteral(n),
|
|
17
|
+
boolean: (b) => (b ? f.createTrue() : f.createFalse()),
|
|
18
|
+
null: () => f.createNull(),
|
|
19
|
+
undefined: () => f.createIdentifier("undefined"),
|
|
20
|
+
};
|
|
21
|
+
export function obj(entries) {
|
|
22
|
+
return f.createObjectLiteralExpression(Object.entries(entries).map(([k, v]) => f.createPropertyAssignment(asPropertyName(k), v)),
|
|
23
|
+
/* multiLine */ true);
|
|
24
|
+
}
|
|
25
|
+
export function arr(elements) {
|
|
26
|
+
return f.createArrayLiteralExpression([...elements], /* multiLine */ true);
|
|
27
|
+
}
|
|
28
|
+
export function asConst(expr) {
|
|
29
|
+
return f.createAsExpression(expr, f.createTypeReferenceNode("const", undefined));
|
|
30
|
+
}
|
|
31
|
+
// ============================================================
|
|
32
|
+
// Statements / declarations
|
|
33
|
+
// ============================================================
|
|
34
|
+
export function exportConst(name, init) {
|
|
35
|
+
return f.createVariableStatement([f.createModifier(ts.SyntaxKind.ExportKeyword)], f.createVariableDeclarationList([f.createVariableDeclaration(name, undefined, undefined, init)], ts.NodeFlags.Const));
|
|
36
|
+
}
|
|
37
|
+
export function exportTypeAlias(name, type) {
|
|
38
|
+
return f.createTypeAliasDeclaration([f.createModifier(ts.SyntaxKind.ExportKeyword)], name, undefined, type);
|
|
39
|
+
}
|
|
40
|
+
export function exportInterface(name, members) {
|
|
41
|
+
return f.createInterfaceDeclaration([f.createModifier(ts.SyntaxKind.ExportKeyword)], name, undefined, undefined, [...members]);
|
|
42
|
+
}
|
|
43
|
+
export function exportFromBarrel(named, module) {
|
|
44
|
+
return f.createExportDeclaration(undefined,
|
|
45
|
+
/* isTypeOnly */ false, f.createNamedExports(named.map((n) => f.createExportSpecifier(n.isType ?? false, undefined, f.createIdentifier(n.name)))), f.createStringLiteral(module));
|
|
46
|
+
}
|
|
47
|
+
export function exportTypeStarFrom(module) {
|
|
48
|
+
return f.createExportDeclaration(undefined,
|
|
49
|
+
/* isTypeOnly */ true, undefined, f.createStringLiteral(module));
|
|
50
|
+
}
|
|
51
|
+
// ============================================================
|
|
52
|
+
// Type nodes
|
|
53
|
+
// ============================================================
|
|
54
|
+
export const tn = {
|
|
55
|
+
ref: (name, args) => f.createTypeReferenceNode(name, args ? [...args] : undefined),
|
|
56
|
+
string: () => f.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
57
|
+
number: () => f.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
|
|
58
|
+
boolean: () => f.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),
|
|
59
|
+
any: () => f.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
|
|
60
|
+
unknown: () => f.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),
|
|
61
|
+
never: () => f.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword),
|
|
62
|
+
literalString: (s) => f.createLiteralTypeNode(f.createStringLiteral(s)),
|
|
63
|
+
/** Property signature for an interface body: `name: type;` (or `name?: type;`). */
|
|
64
|
+
property: (name, type, optional = false) => f.createPropertySignature(undefined, asPropertyName(name), optional ? f.createToken(ts.SyntaxKind.QuestionToken) : undefined, type),
|
|
65
|
+
typeOf: (name) => f.createTypeQueryNode(f.createIdentifier(name), undefined),
|
|
66
|
+
/** `keyof T` */
|
|
67
|
+
keyOf: (inner) => f.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, inner),
|
|
68
|
+
};
|
|
69
|
+
// ============================================================
|
|
70
|
+
// Printer
|
|
71
|
+
// ============================================================
|
|
72
|
+
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
73
|
+
const blankSourceFile = ts.createSourceFile("_.ts", "", ts.ScriptTarget.ESNext,
|
|
74
|
+
/* setParentNodes */ false, ts.ScriptKind.TS);
|
|
75
|
+
/**
|
|
76
|
+
* Print a list of top-level statements as the body of a TypeScript file.
|
|
77
|
+
* `header` is prepended verbatim (use it for the `// AUTO-GENERATED` line).
|
|
78
|
+
*/
|
|
79
|
+
export function printFile(statements, options = {}) {
|
|
80
|
+
const body = printer.printList(ts.ListFormat.MultiLine, f.createNodeArray([...statements]), blankSourceFile);
|
|
81
|
+
const header = options.header ?? "";
|
|
82
|
+
return header + (header && !header.endsWith("\n") ? "\n" : "") + body;
|
|
83
|
+
}
|
|
84
|
+
// ============================================================
|
|
85
|
+
// Internals
|
|
86
|
+
// ============================================================
|
|
87
|
+
/** Use a string literal property name when it isn't a valid identifier. */
|
|
88
|
+
function asPropertyName(name) {
|
|
89
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name)
|
|
90
|
+
? f.createIdentifier(name)
|
|
91
|
+
: f.createStringLiteral(name);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ts-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-build.js","sourceRoot":"","sources":["../../src/ast/ts-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;GAOG;AAEH,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,+DAA+D;AAC/D,eAAe;AACf,+DAA+D;AAE/D,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAChD,OAAO,EAAE,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC;CACxC,CAAC;AAEX,MAAM,UAAU,GAAG,CACjB,OAAgD;IAEhD,OAAO,CAAC,CAAC,6BAA6B,CACpC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CACrC,CAAC,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CACjD;IACD,eAAe,CAAC,IAAI,CACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,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B,UAAkC,EAClC,UAA+B,EAAE;IAEjC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAC5B,EAAE,CAAC,UAAU,CAAC,SAAS,EACvB,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAClC,eAAe,CAChB,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IACpC,OAAO,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;AACxE,CAAC;AAED,+DAA+D;AAC/D,aAAa;AACb,+DAA+D;AAE/D,2EAA2E;AAC3E,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5C,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC1B,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AnalysisContext, Symbol as CoreSymbol, File, Node as ICoreNode, NodeScope } from "@hey-api/codegen-core";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
/** INode wrapper around a `ts.Statement`. Mirrors hey-api's `TsDsl` base. */
|
|
4
|
+
export declare class TsStatementNode implements ICoreNode<ts.Statement> {
|
|
5
|
+
readonly "~brand" = "heyapi.node";
|
|
6
|
+
readonly language = "typescript";
|
|
7
|
+
exported?: boolean;
|
|
8
|
+
root: boolean;
|
|
9
|
+
scope?: NodeScope;
|
|
10
|
+
symbol?: CoreSymbol;
|
|
11
|
+
file?: File;
|
|
12
|
+
private _name;
|
|
13
|
+
private readonly _statement;
|
|
14
|
+
constructor(statement: ts.Statement, options?: {
|
|
15
|
+
name: string;
|
|
16
|
+
exported?: boolean;
|
|
17
|
+
root?: boolean;
|
|
18
|
+
scope?: NodeScope;
|
|
19
|
+
});
|
|
20
|
+
get name(): ICoreNode["name"];
|
|
21
|
+
analyze(_: AnalysisContext): void;
|
|
22
|
+
clone(): this;
|
|
23
|
+
toAst(): ts.Statement;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ts-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-node.d.ts","sourceRoot":"","sources":["../../src/ast/ts-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,MAAM,IAAI,UAAU,EACpB,IAAI,EACJ,IAAI,IAAI,SAAS,EACjB,SAAS,EAEV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,6EAA6E;AAC7E,qBAAa,eAAgB,YAAW,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7D,QAAQ,CAAC,QAAQ,iBAAa;IAC9B,QAAQ,CAAC,QAAQ,gBAAgB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;gBAGxC,SAAS,EAAE,EAAE,CAAC,SAAS,EACvB,OAAO,GAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,SAAS,CAAC;KAGnB;IASH,IAAI,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,CAQ5B;IAED,OAAO,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI;IAEjC,KAAK,IAAI,IAAI;IAMb,KAAK,IAAI,EAAE,CAAC,SAAS;CAGtB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { nodeBrand, ref } from "@hey-api/codegen-core";
|
|
2
|
+
/** INode wrapper around a `ts.Statement`. Mirrors hey-api's `TsDsl` base. */
|
|
3
|
+
export class TsStatementNode {
|
|
4
|
+
"~brand" = nodeBrand;
|
|
5
|
+
language = "typescript";
|
|
6
|
+
exported;
|
|
7
|
+
root;
|
|
8
|
+
scope;
|
|
9
|
+
symbol;
|
|
10
|
+
file;
|
|
11
|
+
_name;
|
|
12
|
+
_statement;
|
|
13
|
+
constructor(statement, options = {
|
|
14
|
+
name: "anon",
|
|
15
|
+
}) {
|
|
16
|
+
this._statement = statement;
|
|
17
|
+
this._name = ref(options.name);
|
|
18
|
+
this.exported = options.exported;
|
|
19
|
+
this.root = options.root ?? true;
|
|
20
|
+
this.scope = options.scope ?? "value";
|
|
21
|
+
}
|
|
22
|
+
get name() {
|
|
23
|
+
return {
|
|
24
|
+
...this._name,
|
|
25
|
+
set: (value) => {
|
|
26
|
+
this._name = ref(typeof value === "string" ? value : String(value));
|
|
27
|
+
},
|
|
28
|
+
toString: () => this._name["~ref"],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
analyze(_) { }
|
|
32
|
+
clone() {
|
|
33
|
+
const cloned = Object.create(Object.getPrototypeOf(this));
|
|
34
|
+
Object.assign(cloned, this);
|
|
35
|
+
return cloned;
|
|
36
|
+
}
|
|
37
|
+
toAst() {
|
|
38
|
+
return this._statement;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ts-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-node.js","sourceRoot":"","sources":["../../src/ast/ts-node.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAGvD,6EAA6E;AAC7E,MAAM,OAAO,eAAe;IACjB,QAA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21 @@
|
|
|
1
|
+
import type { RenderContext, Renderer } from "@hey-api/codegen-core";
|
|
2
|
+
/**
|
|
3
|
+
* Renders TS files: optional header (passed in by the orchestrator,
|
|
4
|
+
* keyed on logical path) prints first, then imports declared via
|
|
5
|
+
* codegen-core's File graph (`file.imports`), then body statements
|
|
6
|
+
* (`TsStatementNode`s). Plugins emit cross-file imports through
|
|
7
|
+
* `plugin.emitTs({ imports })`, never inline
|
|
8
|
+
* `ts.factory.createImportDeclaration`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TsStatementRenderer implements Renderer {
|
|
11
|
+
private readonly headers;
|
|
12
|
+
constructor(headers: Map<string, string>);
|
|
13
|
+
supports(ctx: RenderContext): boolean;
|
|
14
|
+
render(ctx: RenderContext): string;
|
|
15
|
+
}
|
|
16
|
+
/** Renders files whose nodes are `RawTextNode`s by concatenating their text. */
|
|
17
|
+
export declare class RawTextRenderer implements Renderer {
|
|
18
|
+
supports(ctx: RenderContext): boolean;
|
|
19
|
+
render(ctx: RenderContext): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ts-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-renderer.d.ts","sourceRoot":"","sources":["../../src/ast/ts-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,aAAa,EACb,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAgB/B;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzD,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;IAMrC,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM;CAoBnC;AAED,gFAAgF;AAChF,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;IAKrC,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM;CAOnC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { RawTextNode } from "./raw-text-node.js";
|
|
4
|
+
import { TsStatementNode } from "./ts-node.js";
|
|
5
|
+
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
6
|
+
const blank = ts.createSourceFile("_.ts", "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
|
|
7
|
+
const f = ts.factory;
|
|
8
|
+
/**
|
|
9
|
+
* Renders TS files: optional header (passed in by the orchestrator,
|
|
10
|
+
* keyed on logical path) prints first, then imports declared via
|
|
11
|
+
* codegen-core's File graph (`file.imports`), then body statements
|
|
12
|
+
* (`TsStatementNode`s). Plugins emit cross-file imports through
|
|
13
|
+
* `plugin.emitTs({ imports })`, never inline
|
|
14
|
+
* `ts.factory.createImportDeclaration`.
|
|
15
|
+
*/
|
|
16
|
+
export class TsStatementRenderer {
|
|
17
|
+
headers;
|
|
18
|
+
constructor(headers) {
|
|
19
|
+
this.headers = headers;
|
|
20
|
+
}
|
|
21
|
+
supports(ctx) {
|
|
22
|
+
if (ctx.file.language !== "typescript")
|
|
23
|
+
return false;
|
|
24
|
+
const nodes = Array.from(ctx.file.nodes);
|
|
25
|
+
return nodes.length > 0 && nodes.every((n) => n instanceof TsStatementNode);
|
|
26
|
+
}
|
|
27
|
+
render(ctx) {
|
|
28
|
+
const importStatements = [];
|
|
29
|
+
for (const group of ctx.file.imports) {
|
|
30
|
+
const decl = importDeclarationFor(group, ctx.file);
|
|
31
|
+
if (decl)
|
|
32
|
+
importStatements.push(decl);
|
|
33
|
+
}
|
|
34
|
+
const bodyStatements = [];
|
|
35
|
+
for (const node of ctx.file.nodes) {
|
|
36
|
+
if (node instanceof TsStatementNode)
|
|
37
|
+
bodyStatements.push(node.toAst());
|
|
38
|
+
}
|
|
39
|
+
const printed = printer.printList(ts.ListFormat.MultiLine, f.createNodeArray([...importStatements, ...bodyStatements]), blank);
|
|
40
|
+
const header = this.headers.get(ctx.file.logicalFilePath);
|
|
41
|
+
if (!header)
|
|
42
|
+
return printed;
|
|
43
|
+
const headerText = header.endsWith("\n") ? header : `${header}\n`;
|
|
44
|
+
return headerText + printed;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Renders files whose nodes are `RawTextNode`s by concatenating their text. */
|
|
48
|
+
export class RawTextRenderer {
|
|
49
|
+
supports(ctx) {
|
|
50
|
+
const nodes = Array.from(ctx.file.nodes);
|
|
51
|
+
return nodes.length > 0 && nodes.every((n) => n instanceof RawTextNode);
|
|
52
|
+
}
|
|
53
|
+
render(ctx) {
|
|
54
|
+
const parts = [];
|
|
55
|
+
for (const node of ctx.file.nodes) {
|
|
56
|
+
if (node instanceof RawTextNode)
|
|
57
|
+
parts.push(node.toAst());
|
|
58
|
+
}
|
|
59
|
+
return parts.join("");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function importDeclarationFor(group, importer) {
|
|
63
|
+
if (group.kind !== "named")
|
|
64
|
+
return undefined;
|
|
65
|
+
const modulePath = relativeModulePath(importer.logicalFilePath, group.from.logicalFilePath);
|
|
66
|
+
return f.createImportDeclaration(undefined, f.createImportClause(group.isTypeOnly ? ts.SyntaxKind.TypeKeyword : undefined, undefined, f.createNamedImports(group.imports.map((m) => f.createImportSpecifier(m.isTypeOnly, undefined, f.createIdentifier(m.localName ?? m.sourceName))))), f.createStringLiteral(modulePath));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compute a TS-style relative module specifier between two logical (no-extension)
|
|
70
|
+
* file paths. Always emits POSIX separators and a leading `./` for sibling files
|
|
71
|
+
* so the output works the same on Windows hosts and resolves correctly under
|
|
72
|
+
* `moduleResolution: bundler` / `nodenext`.
|
|
73
|
+
*/
|
|
74
|
+
function relativeModulePath(fromLogical, toLogical) {
|
|
75
|
+
const fromDir = posix.dirname(fromLogical);
|
|
76
|
+
const rel = posix.relative(fromDir, toLogical);
|
|
77
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ts-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-renderer.js","sourceRoot":"","sources":["../../src/ast/ts-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAQlC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;AACvE,MAAM,KAAK,GAAG,EAAE,CAAC,gBAAgB,CAC/B,MAAM,EACN,EAAE,EACF,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,KAAK,EACL,EAAE,CAAC,UAAU,CAAC,EAAE,CACjB,CAAC;AACF,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IACD;IAA7B,YAA6B,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAE7D,QAAQ,CAAC,GAAkB;QACzB,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,YAAY;YAAE,OAAO,KAAK,CAAC;QACrD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,eAAe,CAAC,CAAC;IAC9E,CAAC;IAED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OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;AAChD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { type GenerateOptions, type GenerateResult, generate, } from "./orchestrator.js";
|
|
2
|
+
export { type AnyRegisteredPlugin, definePluginConfig, type ForEachEvent, type ForEachKind, type GeneratedFile, iterateDocument, type PluginDefinition, type PluginHooks, type PluginInstance, type RegisteredPlugin, } from "./plugin.js";
|
|
3
|
+
export type { AmqplibPluginConfig, AmqplibResolvedConfig, } from "./plugins/amqplib/index.js";
|
|
4
|
+
export { amqplib } from "./plugins/amqplib/index.js";
|
|
5
|
+
export type { DispatchPluginConfig, DispatchResolvedConfig, } from "./plugins/dispatch/index.js";
|
|
6
|
+
export { dispatch } from "./plugins/dispatch/index.js";
|
|
7
|
+
export type { EventMapPluginConfig, EventMapResolvedConfig, } from "./plugins/event-map/index.js";
|
|
8
|
+
export { eventMap } from "./plugins/event-map/index.js";
|
|
9
|
+
export type { EventsPluginConfig, EventsResolvedConfig, } from "./plugins/events/index.js";
|
|
10
|
+
export { events } from "./plugins/events/index.js";
|
|
11
|
+
export type { IndexBarrelConfig, IndexBarrelResolvedConfig, } from "./plugins/index-barrel/index.js";
|
|
12
|
+
export { indexBarrel } from "./plugins/index-barrel/index.js";
|
|
13
|
+
export type { TypescriptPluginConfig, TypescriptResolvedConfig, } from "./plugins/typescript/index.js";
|
|
14
|
+
export { typescript } from "./plugins/typescript/index.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,YAAY,EACV,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,YAAY,EACV,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,YAAY,EACV,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { generate, } from "./orchestrator.js";
|
|
2
|
+
export { definePluginConfig, iterateDocument, } from "./plugin.js";
|
|
3
|
+
export { amqplib } from "./plugins/amqplib/index.js";
|
|
4
|
+
export { dispatch } from "./plugins/dispatch/index.js";
|
|
5
|
+
export { eventMap } from "./plugins/event-map/index.js";
|
|
6
|
+
export { events } from "./plugins/events/index.js";
|
|
7
|
+
export { indexBarrel } from "./plugins/index-barrel/index.js";
|
|
8
|
+
export { typescript } from "./plugins/typescript/index.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,kBAAkB,EAIlB,eAAe,GAKhB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKvD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAKxD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAKnD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAK9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AsyncAPIDocumentInterface } from "@asyncapi/parser";
|
|
2
|
+
import { type AnyRegisteredPlugin, type GeneratedFile } from "./plugin.js";
|
|
3
|
+
export interface GenerateOptions {
|
|
4
|
+
input: string | AsyncAPIDocumentInterface;
|
|
5
|
+
output: string;
|
|
6
|
+
plugins: ReadonlyArray<AnyRegisteredPlugin>;
|
|
7
|
+
}
|
|
8
|
+
export interface GenerateResult {
|
|
9
|
+
output: string;
|
|
10
|
+
files: ReadonlyArray<GeneratedFile>;
|
|
11
|
+
}
|
|
12
|
+
export declare function generate(opts: GenerateOptions): Promise<GenerateResult>;
|
|
13
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAWlE,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAK3E,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,GAAG,yBAAyB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CACrC;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA4C7E"}
|