@me1a/tool-async-api-builder 0.0.0-stage → 0.1.4
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/README.md +79 -2
- package/dist/application/build-pipeline.d.ts +11 -0
- package/dist/application/build-pipeline.d.ts.map +1 -0
- package/dist/application/build-pipeline.js +100 -0
- package/dist/application/build-pipeline.js.map +1 -0
- package/dist/application/resolve-config.d.ts +11 -0
- package/dist/application/resolve-config.d.ts.map +1 -0
- package/dist/application/resolve-config.js +31 -0
- package/dist/application/resolve-config.js.map +1 -0
- package/dist/application/verify-contracts.d.ts +6 -0
- package/dist/application/verify-contracts.d.ts.map +1 -0
- package/dist/application/verify-contracts.js +69 -0
- package/dist/application/verify-contracts.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +91 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/domain/schema-routing.d.ts +8 -0
- package/dist/domain/schema-routing.d.ts.map +1 -0
- package/dist/domain/schema-routing.js +23 -0
- package/dist/domain/schema-routing.js.map +1 -0
- package/dist/domain/types.d.ts +56 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +2 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/buf/buf-config.d.ts +7 -0
- package/dist/infrastructure/buf/buf-config.d.ts.map +1 -0
- package/dist/infrastructure/buf/buf-config.js +109 -0
- package/dist/infrastructure/buf/buf-config.js.map +1 -0
- package/dist/infrastructure/export-json-schema.d.ts +6 -0
- package/dist/infrastructure/export-json-schema.d.ts.map +1 -0
- package/dist/infrastructure/export-json-schema.js +40 -0
- package/dist/infrastructure/export-json-schema.js.map +1 -0
- package/dist/infrastructure/export-yaml.d.ts +6 -0
- package/dist/infrastructure/export-yaml.d.ts.map +1 -0
- package/dist/infrastructure/export-yaml.js +41 -0
- package/dist/infrastructure/export-yaml.js.map +1 -0
- package/dist/infrastructure/generate-proto.d.ts +5 -0
- package/dist/infrastructure/generate-proto.d.ts.map +1 -0
- package/dist/infrastructure/generate-proto.js +367 -0
- package/dist/infrastructure/generate-proto.js.map +1 -0
- package/dist/infrastructure/generate-sdk.d.ts +6 -0
- package/dist/infrastructure/generate-sdk.d.ts.map +1 -0
- package/dist/infrastructure/generate-sdk.js +209 -0
- package/dist/infrastructure/generate-sdk.js.map +1 -0
- package/dist/infrastructure/load-contracts.d.ts +5 -0
- package/dist/infrastructure/load-contracts.d.ts.map +1 -0
- package/dist/infrastructure/load-contracts.js +39 -0
- package/dist/infrastructure/load-contracts.js.map +1 -0
- package/dist/infrastructure/templates/native-ws-ts.d.ts +7 -0
- package/dist/infrastructure/templates/native-ws-ts.d.ts.map +1 -0
- package/dist/infrastructure/templates/native-ws-ts.js +334 -0
- package/dist/infrastructure/templates/native-ws-ts.js.map +1 -0
- package/dist/infrastructure/templates/nats-rust.d.ts +7 -0
- package/dist/infrastructure/templates/nats-rust.d.ts.map +1 -0
- package/dist/infrastructure/templates/nats-rust.js +345 -0
- package/dist/infrastructure/templates/nats-rust.js.map +1 -0
- package/dist/infrastructure/templates/nats-ts.d.ts +5 -0
- package/dist/infrastructure/templates/nats-ts.d.ts.map +1 -0
- package/dist/infrastructure/templates/nats-ts.js +200 -0
- package/dist/infrastructure/templates/nats-ts.js.map +1 -0
- package/package.json +68 -4
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @me1a/tool-async-api-builder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generic AsyncAPI 3.x **contract verification** and **SDK builder** (TypeScript + Rust, NATS Core + native WebSocket).
|
|
4
|
+
|
|
5
|
+
Contract sources (`*.schema.ts`) stay in your monorepo package (e.g. `packages/async-api`). This library only converts and validates them.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Validate every *.schema.ts under the package layout
|
|
11
|
+
async-api-builder verify --root path/to/packages/async-api
|
|
12
|
+
|
|
13
|
+
# Verify, then export JSON/YAML, generate .proto, buf, and TS/Rust SDKs
|
|
14
|
+
async-api-builder build --root path/to/packages/async-api
|
|
15
|
+
|
|
16
|
+
# Keep prior generated stubs (e.g. when buf is flaky in watch mode)
|
|
17
|
+
async-api-builder build --root path/to/packages/async-api --skip-clean
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Environment:
|
|
21
|
+
|
|
22
|
+
- `ASYNC_API_BUF_LOCAL_PLUGINS=1` — use local `protoc-gen-es` / `protoc-gen-prost` instead of BSR remotes (Docker / offline).
|
|
23
|
+
|
|
24
|
+
## Default layout
|
|
25
|
+
|
|
26
|
+
Relative to `--root`:
|
|
27
|
+
|
|
28
|
+
| Path | Role |
|
|
29
|
+
|------|------|
|
|
30
|
+
| `src/async-api/*.schema.ts` | Sources |
|
|
31
|
+
| `src/async-api/proto` | Generated `.proto` |
|
|
32
|
+
| `src/async-api/schemas` | Generated JSON/YAML |
|
|
33
|
+
| `src/async-api/sdk` | Generated TypeScript SDK |
|
|
34
|
+
| `rust/sdk` | Generated Rust crates |
|
|
35
|
+
|
|
36
|
+
## Library API
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import {
|
|
40
|
+
buildAsyncApi,
|
|
41
|
+
resolveConfigFromRoot,
|
|
42
|
+
verifyContracts,
|
|
43
|
+
} from "@me1a/tool-async-api-builder";
|
|
44
|
+
|
|
45
|
+
const layout = resolveConfigFromRoot("/path/to/packages/async-api");
|
|
46
|
+
await verifyContracts(layout);
|
|
47
|
+
await buildAsyncApi(layout, { skipClean: false });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Develop
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
yarn install
|
|
54
|
+
yarn build
|
|
55
|
+
yarn test
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Release
|
|
59
|
+
|
|
60
|
+
Publishes `@me1a/tool-async-api-builder` to npm on a `v*` tag push (same flow as `@me1a/ui`).
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# clean working tree on main
|
|
64
|
+
yarn release:patch # or :minor / :major
|
|
65
|
+
# or: yarn release -- patch [--no-push] [--dry-run]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This bumps `package.json`, commits (`Release X.Y.Z`), tags `vX.Y.Z`, and pushes branch + tags (unless `--no-push`). The deploy workflow then builds, tests, and publishes.
|
|
69
|
+
|
|
70
|
+
Also ensure:
|
|
71
|
+
|
|
72
|
+
1. GitHub secret `NPM_PUBLISH_TOKEN` (same token/robot as other `@me1a` packages if shared).
|
|
73
|
+
2. On [npmjs.com](https://www.npmjs.com), link the package to this GitHub repo for trusted publishing if not already done for the scope.
|
|
74
|
+
|
|
75
|
+
The workflow skips publish if that version already exists on the registry, then runs `npm publish --access public --ignore-scripts`. npm provenance needs a **public** GitHub repo; this package is published without `--provenance` while the source repo is private.
|
|
76
|
+
|
|
77
|
+
## Consumers
|
|
78
|
+
|
|
79
|
+
- **parsing-platform** vendors this package at `vendor/tool-async-api-builder` (`file:` dep) for Docker build context. Sync from this sibling repo after changes (see that tree's `VENDOR.md`).
|
|
80
|
+
- **app-skeleton** / **seo-platform** can adopt the same CLI later (phase 2).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AsyncApiProjectLayout, BuildOptions } from "../domain/types.js";
|
|
2
|
+
declare function clearOutputDirectories(layout: AsyncApiProjectLayout): void;
|
|
3
|
+
/** True when a prior buf generate left protobuf stubs (verify / skip-clean fallback). */
|
|
4
|
+
declare function protobufStubsPresent(layout: AsyncApiProjectLayout): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Verify contracts, then run the full AsyncAPI → proto → buf → SDK pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildAsyncApi(layout: AsyncApiProjectLayout, options?: BuildOptions): Promise<void>;
|
|
9
|
+
/** Re-export for callers that only need stub presence checks in tests. */
|
|
10
|
+
export { protobufStubsPresent, clearOutputDirectories };
|
|
11
|
+
//# sourceMappingURL=build-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-pipeline.d.ts","sourceRoot":"","sources":["../../src/application/build-pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,oBAAoB,CAAC;AA+B5B,iBAAS,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAWnE;AAED,yFAAyF;AACzF,iBAAS,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAcpE;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAkDf;AAED,0EAA0E;AAC1E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { existsSync, renameSync, rmSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { runBufGenerate } from "../infrastructure/buf/buf-config.js";
|
|
4
|
+
import { exportJsonSchemas } from "../infrastructure/export-json-schema.js";
|
|
5
|
+
import { exportYamlSchemas } from "../infrastructure/export-yaml.js";
|
|
6
|
+
import { generateProto, schemaNameToProtoPkg, } from "../infrastructure/generate-proto.js";
|
|
7
|
+
import { generateSdk } from "../infrastructure/generate-sdk.js";
|
|
8
|
+
import { listSchemaFiles } from "../infrastructure/load-contracts.js";
|
|
9
|
+
import { verifyContracts } from "./verify-contracts.js";
|
|
10
|
+
function relocateTsProtobufOutputToSchemaFolders(layout) {
|
|
11
|
+
const schemaFiles = listSchemaFiles(layout);
|
|
12
|
+
for (const f of schemaFiles) {
|
|
13
|
+
const schemaName = f.replace(".schema.ts", "");
|
|
14
|
+
const protoPkg = schemaNameToProtoPkg(schemaName);
|
|
15
|
+
if (protoPkg === schemaName)
|
|
16
|
+
continue;
|
|
17
|
+
const src = join(layout.tsSdkDir, protoPkg);
|
|
18
|
+
const dest = join(layout.tsSdkDir, schemaName);
|
|
19
|
+
if (existsSync(src)) {
|
|
20
|
+
if (existsSync(dest)) {
|
|
21
|
+
rmSync(dest, { recursive: true, force: true });
|
|
22
|
+
}
|
|
23
|
+
renameSync(src, dest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function clearOutputDirectories(layout) {
|
|
28
|
+
const dirs = [
|
|
29
|
+
layout.schemasOutDir,
|
|
30
|
+
layout.protoDir,
|
|
31
|
+
layout.tsSdkDir,
|
|
32
|
+
layout.rustSdkDir,
|
|
33
|
+
];
|
|
34
|
+
for (const dirPath of dirs) {
|
|
35
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
36
|
+
console.log(`🗑️ Cleared ${dirPath}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** True when a prior buf generate left protobuf stubs (verify / skip-clean fallback). */
|
|
40
|
+
function protobufStubsPresent(layout) {
|
|
41
|
+
const schemaFiles = listSchemaFiles(layout);
|
|
42
|
+
if (schemaFiles.length === 0)
|
|
43
|
+
return false;
|
|
44
|
+
return schemaFiles.every((f) => {
|
|
45
|
+
const schemaName = f.replace(".schema.ts", "");
|
|
46
|
+
const protoPkg = schemaNameToProtoPkg(schemaName);
|
|
47
|
+
const tsMarker = join(layout.tsSdkDir, schemaName);
|
|
48
|
+
const rustMarker = join(layout.rustSdkDir, protoPkg);
|
|
49
|
+
// After relocate, TS lives under schemaName; before relocate under protoPkg.
|
|
50
|
+
return ((existsSync(tsMarker) || existsSync(join(layout.tsSdkDir, protoPkg))) &&
|
|
51
|
+
existsSync(rustMarker));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Verify contracts, then run the full AsyncAPI → proto → buf → SDK pipeline.
|
|
56
|
+
*/
|
|
57
|
+
export async function buildAsyncApi(layout, options = {}) {
|
|
58
|
+
console.log("🚀 Starting AsyncAPI Build Pipeline...");
|
|
59
|
+
console.log("\n0a. Verifying AsyncAPI contracts...");
|
|
60
|
+
const report = await verifyContracts(layout);
|
|
61
|
+
if (!report.ok) {
|
|
62
|
+
for (const issue of report.issues) {
|
|
63
|
+
console.error(`❌ [${issue.schemaName}] ${issue.message}`);
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Contract verification failed with ${report.issues.length} issue(s)`);
|
|
66
|
+
}
|
|
67
|
+
console.log(`✅ ${report.contracts.length} contract(s) verified`);
|
|
68
|
+
if (options.skipClean) {
|
|
69
|
+
console.log("\n0. Skipping clean (--skip-clean)");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log("\n0. Clearing output directories...");
|
|
73
|
+
clearOutputDirectories(layout);
|
|
74
|
+
}
|
|
75
|
+
console.log("\n1. Exporting JSON schemas...");
|
|
76
|
+
await exportJsonSchemas(layout);
|
|
77
|
+
console.log("\n2. Exporting YAML schemas...");
|
|
78
|
+
await exportYamlSchemas(layout);
|
|
79
|
+
console.log("\n3. Generating .proto from AsyncAPI...");
|
|
80
|
+
await generateProto(layout);
|
|
81
|
+
console.log("\n4. buf generate (protobuf stubs)...");
|
|
82
|
+
try {
|
|
83
|
+
runBufGenerate(layout);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (options.skipClean && protobufStubsPresent(layout)) {
|
|
87
|
+
console.warn("⚠️ buf generate failed; reusing existing protobuf stubs (--skip-clean)");
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
relocateTsProtobufOutputToSchemaFolders(layout);
|
|
94
|
+
console.log("\n5. Generating AsyncAPI SDKs (TypeScript • Rust)...");
|
|
95
|
+
await generateSdk(layout);
|
|
96
|
+
console.log("\n✨ AsyncAPI Build Pipeline completed successfully!");
|
|
97
|
+
}
|
|
98
|
+
/** Re-export for callers that only need stub presence checks in tests. */
|
|
99
|
+
export { protobufStubsPresent, clearOutputDirectories };
|
|
100
|
+
//# sourceMappingURL=build-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-pipeline.js","sourceRoot":"","sources":["../../src/application/build-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,aAAa,EACb,oBAAoB,GACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,SAAS,uCAAuC,CAC9C,MAA6B;IAE7B,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,UAAU;YAAE,SAAS;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE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C,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACvD,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,cAAc,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,SAAS,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;YACtD,OAAO,CAAC,IAAI,CACV,yEAAyE,CAC1E,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,uCAAuC,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;IAE1B,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;AACrE,CAAC;AAED,0EAA0E;AAC1E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AsyncApiProjectConfig, AsyncApiProjectLayout } from "../domain/types.js";
|
|
2
|
+
/** Identity helper for typed config objects. */
|
|
3
|
+
export declare function defineConfig(config: AsyncApiProjectConfig): AsyncApiProjectConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve package layout. Relative path fields are relative to `packageRoot`.
|
|
6
|
+
* Defaults match `packages/async-api` in app-skeleton / parsing-platform.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveConfig(config: AsyncApiProjectConfig): AsyncApiProjectLayout;
|
|
9
|
+
/** Convenience: resolve from a package root with defaults. */
|
|
10
|
+
export declare function resolveConfigFromRoot(packageRoot: string): AsyncApiProjectLayout;
|
|
11
|
+
//# sourceMappingURL=resolve-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/application/resolve-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAO5B,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,qBAAqB,GAC5B,qBAAqB,CAEvB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,qBAAqB,GAC5B,qBAAqB,CAgCvB;AAED,8DAA8D;AAC9D,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,qBAAqB,CAEhF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
2
|
+
function resolvePath(packageRoot, value, fallback) {
|
|
3
|
+
const raw = value ?? fallback;
|
|
4
|
+
return isAbsolute(raw) ? raw : join(packageRoot, raw);
|
|
5
|
+
}
|
|
6
|
+
/** Identity helper for typed config objects. */
|
|
7
|
+
export function defineConfig(config) {
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve package layout. Relative path fields are relative to `packageRoot`.
|
|
12
|
+
* Defaults match `packages/async-api` in app-skeleton / parsing-platform.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveConfig(config) {
|
|
15
|
+
const packageRoot = resolve(config.packageRoot);
|
|
16
|
+
return {
|
|
17
|
+
packageRoot,
|
|
18
|
+
schemasDir: resolvePath(packageRoot, config.schemasDir, "src/async-api"),
|
|
19
|
+
protoDir: resolvePath(packageRoot, config.protoDir, "src/async-api/proto"),
|
|
20
|
+
schemasOutDir: resolvePath(packageRoot, config.schemasOutDir, "src/async-api/schemas"),
|
|
21
|
+
schemasDistDir: resolvePath(packageRoot, config.schemasDistDir, "dist/async-api/schemas"),
|
|
22
|
+
tsSdkDir: resolvePath(packageRoot, config.tsSdkDir, "src/async-api/sdk"),
|
|
23
|
+
rustWorkspaceDir: resolvePath(packageRoot, config.rustWorkspaceDir, "rust"),
|
|
24
|
+
rustSdkDir: resolvePath(packageRoot, config.rustSdkDir, "rust/sdk"),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Convenience: resolve from a package root with defaults. */
|
|
28
|
+
export function resolveConfigFromRoot(packageRoot) {
|
|
29
|
+
return resolveConfig({ packageRoot });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=resolve-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/application/resolve-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOtD,SAAS,WAAW,CAAC,WAAmB,EAAE,KAAyB,EAAE,QAAgB;IACnF,MAAM,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC;IAC9B,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAC1B,MAA6B;IAE7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA6B;IAE7B,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,OAAO;QACL,WAAW;QACX,UAAU,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC;QACxE,QAAQ,EAAE,WAAW,CACnB,WAAW,EACX,MAAM,CAAC,QAAQ,EACf,qBAAqB,CACtB;QACD,aAAa,EAAE,WAAW,CACxB,WAAW,EACX,MAAM,CAAC,aAAa,EACpB,uBAAuB,CACxB;QACD,cAAc,EAAE,WAAW,CACzB,WAAW,EACX,MAAM,CAAC,cAAc,EACrB,wBAAwB,CACzB;QACD,QAAQ,EAAE,WAAW,CACnB,WAAW,EACX,MAAM,CAAC,QAAQ,EACf,mBAAmB,CACpB;QACD,gBAAgB,EAAE,WAAW,CAC3B,WAAW,EACX,MAAM,CAAC,gBAAgB,EACvB,MAAM,CACP;QACD,UAAU,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACvD,OAAO,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AsyncApiProjectLayout, VerificationReport } from "../domain/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate every `*.schema.ts` under the project layout before SDK generation.
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyContracts(layout: AsyncApiProjectLayout): Promise<VerificationReport>;
|
|
6
|
+
//# sourceMappingURL=verify-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-contracts.d.ts","sourceRoot":"","sources":["../../src/application/verify-contracts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAK5B;;GAEG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAqE7B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Parser } from "@asyncapi/parser";
|
|
2
|
+
import { hasKnownTransport } from "../domain/schema-routing.js";
|
|
3
|
+
import { discoverContracts } from "../infrastructure/load-contracts.js";
|
|
4
|
+
const EXPECTED_ASYNCAPI_VERSION = "3.0.0";
|
|
5
|
+
/**
|
|
6
|
+
* Validate every `*.schema.ts` under the project layout before SDK generation.
|
|
7
|
+
*/
|
|
8
|
+
export async function verifyContracts(layout) {
|
|
9
|
+
const parser = new Parser();
|
|
10
|
+
const issues = [];
|
|
11
|
+
const contracts = await discoverContracts(layout);
|
|
12
|
+
if (contracts.length === 0) {
|
|
13
|
+
issues.push({
|
|
14
|
+
schemaName: "*",
|
|
15
|
+
filePath: layout.schemasDir,
|
|
16
|
+
message: `No AsyncAPI *.schema.ts files with an \`asyncapi\` export found in ${layout.schemasDir}`,
|
|
17
|
+
});
|
|
18
|
+
return { ok: false, contracts, issues };
|
|
19
|
+
}
|
|
20
|
+
for (const contract of contracts) {
|
|
21
|
+
const { schemaName, filePath, spec, companionOnly } = contract;
|
|
22
|
+
if (spec.asyncapi !== EXPECTED_ASYNCAPI_VERSION) {
|
|
23
|
+
issues.push({
|
|
24
|
+
schemaName,
|
|
25
|
+
filePath,
|
|
26
|
+
message: `Expected asyncapi "${EXPECTED_ASYNCAPI_VERSION}", got "${String(spec.asyncapi)}"`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const { document, diagnostics } = await parser.parse(spec);
|
|
30
|
+
const errors = diagnostics.filter((d) => d.severity === 0);
|
|
31
|
+
if (errors.length > 0) {
|
|
32
|
+
for (const err of errors) {
|
|
33
|
+
issues.push({
|
|
34
|
+
schemaName,
|
|
35
|
+
filePath,
|
|
36
|
+
message: err.message ?? "AsyncAPI parser error",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!document) {
|
|
41
|
+
issues.push({
|
|
42
|
+
schemaName,
|
|
43
|
+
filePath,
|
|
44
|
+
message: "Parser returned no document",
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (document.channels().all().length === 0) {
|
|
49
|
+
issues.push({
|
|
50
|
+
schemaName,
|
|
51
|
+
filePath,
|
|
52
|
+
message: "Document must declare at least one channel",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!companionOnly && !hasKnownTransport(schemaName)) {
|
|
56
|
+
issues.push({
|
|
57
|
+
schemaName,
|
|
58
|
+
filePath,
|
|
59
|
+
message: "Basename must include websocket, -ws., nats, -mq., or -pubsub. (no other transports are generated)",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
ok: issues.length === 0,
|
|
65
|
+
contracts,
|
|
66
|
+
issues,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=verify-contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-contracts.js","sourceRoot":"","sources":["../../src/application/verify-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAMhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA6B;IAE7B,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAElD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC;YACV,UAAU,EAAE,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,OAAO,EAAE,sEAAsE,MAAM,CAAC,UAAU,EAAE;SACnG,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,EAAE,UAAU,EAAE,QAAQ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AQ;gBACR,OAAO,EACL,oGAAoG;aACvG,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QACvB,SAAS;QACT,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":""}
|
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { buildAsyncApi } from "../application/build-pipeline.js";
|
|
4
|
+
import { resolveConfigFromRoot } from "../application/resolve-config.js";
|
|
5
|
+
import { verifyContracts } from "../application/verify-contracts.js";
|
|
6
|
+
function printHelp() {
|
|
7
|
+
console.log(`Usage: async-api-builder <command> [options]
|
|
8
|
+
|
|
9
|
+
Commands:
|
|
10
|
+
verify Validate AsyncAPI *.schema.ts contracts
|
|
11
|
+
build Verify then generate JSON/YAML, protobuf, and SDKs
|
|
12
|
+
|
|
13
|
+
Options:
|
|
14
|
+
--root <path> Contract package root (default: cwd)
|
|
15
|
+
--skip-clean Keep existing generated outputs (build only)
|
|
16
|
+
-h, --help Show this help
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
function parseArgs(argv) {
|
|
20
|
+
const args = [...argv];
|
|
21
|
+
let command;
|
|
22
|
+
let root = process.cwd();
|
|
23
|
+
let skipClean = false;
|
|
24
|
+
let help = false;
|
|
25
|
+
while (args.length > 0) {
|
|
26
|
+
const a = args.shift();
|
|
27
|
+
if (a === "-h" || a === "--help") {
|
|
28
|
+
help = true;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (a === "--skip-clean") {
|
|
32
|
+
skipClean = true;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (a === "--root") {
|
|
36
|
+
const value = args.shift();
|
|
37
|
+
if (!value) {
|
|
38
|
+
throw new Error("--root requires a path");
|
|
39
|
+
}
|
|
40
|
+
root = resolve(value);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (a.startsWith("-")) {
|
|
44
|
+
throw new Error(`Unknown option: ${a}`);
|
|
45
|
+
}
|
|
46
|
+
if (!command) {
|
|
47
|
+
command = a;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Unexpected argument: ${a}`);
|
|
51
|
+
}
|
|
52
|
+
return { command, root, skipClean, help };
|
|
53
|
+
}
|
|
54
|
+
async function main() {
|
|
55
|
+
const { command, root, skipClean, help } = parseArgs(process.argv.slice(2));
|
|
56
|
+
if (help || !command) {
|
|
57
|
+
printHelp();
|
|
58
|
+
process.exit(help ? 0 : 1);
|
|
59
|
+
}
|
|
60
|
+
const layout = resolveConfigFromRoot(root);
|
|
61
|
+
if (command === "verify") {
|
|
62
|
+
const report = await verifyContracts(layout);
|
|
63
|
+
if (!report.ok) {
|
|
64
|
+
for (const issue of report.issues) {
|
|
65
|
+
console.error(`❌ [${issue.schemaName}] ${issue.message}`);
|
|
66
|
+
}
|
|
67
|
+
console.error(`\nVerification failed with ${report.issues.length} issue(s)`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
console.log(`✅ Verified ${report.contracts.length} AsyncAPI contract(s) in ${layout.schemasDir}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (command === "build") {
|
|
74
|
+
try {
|
|
75
|
+
await buildAsyncApi(layout, { skipClean });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error("❌ Failed to build AsyncAPI:", error);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.error(`Unknown command: ${command}`);
|
|
84
|
+
printHelp();
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
main().catch((error) => {
|
|
88
|
+
console.error(error);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;CAUb,CAAC,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAc;IAM/B,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,IAAI,OAA2B,CAAC;IAChC,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC;QACxB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,GAAG,IAAI,CAAC;YACZ,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,cAAc,EAAE,CAAC;YACzB,SAAS,GAAG,IAAI,CAAC;YACjB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC5C,CAAC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M,CAAC,MAAM,WAAW,CAC9D,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,GAAG,CACT,cAAc,MAAM,CAAC,SAAS,CAAC,MAAM,4BAA4B,MAAM,CAAC,UAAU,EAAE,CACrF,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IAC7C,SAAS,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Basename selects native WebSocket TS SDK. */
|
|
2
|
+
export declare function isWebSocketSchemaName(schemaName: string): boolean;
|
|
3
|
+
/** Basename selects NATS Core producer/consumer layout (TS, Rust). */
|
|
4
|
+
export declare function isNatsSchemaName(schemaName: string): boolean;
|
|
5
|
+
export declare function isCompanionDocOnlySpec(spec: unknown): boolean;
|
|
6
|
+
/** Non-companion schemas must match a known SDK transport. */
|
|
7
|
+
export declare function hasKnownTransport(schemaName: string): boolean;
|
|
8
|
+
//# sourceMappingURL=schema-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-routing.d.ts","sourceRoot":"","sources":["../../src/domain/schema-routing.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAMjE;AAED,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAI7D;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Basename selects native WebSocket TS SDK. */
|
|
2
|
+
export function isWebSocketSchemaName(schemaName) {
|
|
3
|
+
return (schemaName.includes("websocket") ||
|
|
4
|
+
/** e.g. `customer-streaming-ws.v1` — avoids naive `.includes("ws")`. */
|
|
5
|
+
schemaName.includes("-ws."));
|
|
6
|
+
}
|
|
7
|
+
/** Basename selects NATS Core producer/consumer layout (TS, Rust). */
|
|
8
|
+
export function isNatsSchemaName(schemaName) {
|
|
9
|
+
return (schemaName.includes("nats") ||
|
|
10
|
+
schemaName.includes("-mq.") ||
|
|
11
|
+
schemaName.includes("-pubsub."));
|
|
12
|
+
}
|
|
13
|
+
export function isCompanionDocOnlySpec(spec) {
|
|
14
|
+
if (!spec || typeof spec !== "object")
|
|
15
|
+
return false;
|
|
16
|
+
const info = spec.info;
|
|
17
|
+
return info?.["x-companion-spec"] === true;
|
|
18
|
+
}
|
|
19
|
+
/** Non-companion schemas must match a known SDK transport. */
|
|
20
|
+
export function hasKnownTransport(schemaName) {
|
|
21
|
+
return isWebSocketSchemaName(schemaName) || isNatsSchemaName(schemaName);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=schema-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-routing.js","sourceRoot":"","sources":["../../src/domain/schema-routing.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC;QAChC,wEAAwE;QACxE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAC5B,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3B,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3B,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAa;IAClD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,IAAI,GAAI,IAA8C,CAAC,IAAI,CAAC;IAClE,OAAO,IAAI,EAAE,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,OAAO,qBAAqB,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolved paths for an AsyncAPI contract package (defaults match
|
|
3
|
+
* `packages/async-api` layout used by app-skeleton / parsing-platform).
|
|
4
|
+
*/
|
|
5
|
+
export interface AsyncApiProjectLayout {
|
|
6
|
+
/** Absolute path to the contract package root. */
|
|
7
|
+
packageRoot: string;
|
|
8
|
+
/** Directory containing `*.schema.ts` sources. */
|
|
9
|
+
schemasDir: string;
|
|
10
|
+
/** Generated `.proto` output. */
|
|
11
|
+
protoDir: string;
|
|
12
|
+
/** Generated JSON/YAML under src. */
|
|
13
|
+
schemasOutDir: string;
|
|
14
|
+
/** Generated JSON/YAML under dist (compiled package). */
|
|
15
|
+
schemasDistDir: string;
|
|
16
|
+
/** Generated TypeScript SDK root. */
|
|
17
|
+
tsSdkDir: string;
|
|
18
|
+
/** Rust workspace root (`Cargo.toml` written here). */
|
|
19
|
+
rustWorkspaceDir: string;
|
|
20
|
+
/** Generated Rust SDK crates. */
|
|
21
|
+
rustSdkDir: string;
|
|
22
|
+
}
|
|
23
|
+
/** Partial overrides relative to `packageRoot` (or absolute). */
|
|
24
|
+
export interface AsyncApiProjectConfig {
|
|
25
|
+
packageRoot: string;
|
|
26
|
+
schemasDir?: string;
|
|
27
|
+
protoDir?: string;
|
|
28
|
+
schemasOutDir?: string;
|
|
29
|
+
schemasDistDir?: string;
|
|
30
|
+
tsSdkDir?: string;
|
|
31
|
+
rustWorkspaceDir?: string;
|
|
32
|
+
rustSdkDir?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface LoadedContract {
|
|
35
|
+
/** Basename without `.schema.ts` (e.g. `billing-mq.v1`). */
|
|
36
|
+
schemaName: string;
|
|
37
|
+
/** Absolute path to the `*.schema.ts` file. */
|
|
38
|
+
filePath: string;
|
|
39
|
+
/** Spec object that declares `asyncapi`. */
|
|
40
|
+
spec: Record<string, unknown>;
|
|
41
|
+
companionOnly: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ContractIssue {
|
|
44
|
+
schemaName: string;
|
|
45
|
+
filePath: string;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
export interface VerificationReport {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
contracts: LoadedContract[];
|
|
51
|
+
issues: ContractIssue[];
|
|
52
|
+
}
|
|
53
|
+
export interface BuildOptions {
|
|
54
|
+
skipClean?: boolean;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["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aAAa,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/domain/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { buildAsyncApi } from "./application/build-pipeline.js";
|
|
2
|
+
export { defineConfig, resolveConfig, resolveConfigFromRoot, } from "./application/resolve-config.js";
|
|
3
|
+
export { verifyContracts } from "./application/verify-contracts.js";
|
|
4
|
+
export { hasKnownTransport, isCompanionDocOnlySpec, isNatsSchemaName, isWebSocketSchemaName, } from "./domain/schema-routing.js";
|
|
5
|
+
export type { AsyncApiProjectConfig, AsyncApiProjectLayout, BuildOptions, ContractIssue, LoadedContract, VerificationReport, } from "./domain/types.js";
|
|
6
|
+
export { collectProtoMessageNames, generateSdk, } from "./infrastructure/generate-sdk.js";
|
|
7
|
+
export { generateProto, generateProtoForSpec, schemaNameToProtoPkg, } from "./infrastructure/generate-proto.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { buildAsyncApi } from "./application/build-pipeline.js";
|
|
2
|
+
export { defineConfig, resolveConfig, resolveConfigFromRoot, } from "./application/resolve-config.js";
|
|
3
|
+
export { verifyContracts } from "./application/verify-contracts.js";
|
|
4
|
+
export { hasKnownTransport, isCompanionDocOnlySpec, isNatsSchemaName, isWebSocketSchemaName, } from "./domain/schema-routing.js";
|
|
5
|
+
export { collectProtoMessageNames, generateSdk, } from "./infrastructure/generate-sdk.js";
|
|
6
|
+
export { generateProto, generateProtoForSpec, schemaNameToProtoPkg, } from "./infrastructure/generate-proto.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AASpC,OAAO,EACL,wBAAwB,EACxB,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsyncApiProjectLayout } from "../../domain/types.js";
|
|
2
|
+
export declare function buildBufConfig(layout: AsyncApiProjectLayout): string;
|
|
3
|
+
export declare function buildBufTemplate(layout: AsyncApiProjectLayout): string;
|
|
4
|
+
export declare function buildBufTemplateLocal(layout: AsyncApiProjectLayout): string;
|
|
5
|
+
export declare function resolveBufTemplate(layout: AsyncApiProjectLayout): string;
|
|
6
|
+
export declare function runBufGenerate(layout: AsyncApiProjectLayout): void;
|
|
7
|
+
//# sourceMappingURL=buf-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buf-config.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/buf/buf-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAMnE,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAMpE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAetE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAe3E;AAWD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAIxE;AAmBD,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAmClE"}
|