@adhd/apigen-core 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/README.md +38 -0
- package/index.d.ts +10 -0
- package/index.js +31412 -0
- package/index.mjs +380115 -0
- package/lib/apigen-core.d.ts +1 -0
- package/lib/compose-schemas.d.ts +16 -0
- package/lib/descriptor.d.ts +202 -0
- package/lib/extract-classes.d.ts +30 -0
- package/lib/extract.d.ts +34 -0
- package/lib/extractors/default-export.d.ts +8 -0
- package/lib/extractors/named-object.d.ts +8 -0
- package/lib/extractors/named.d.ts +17 -0
- package/lib/generate-schemas.d.ts +9 -0
- package/lib/plugin.d.ts +433 -0
- package/lib/schema-builders/morph-fallback.d.ts +2 -0
- package/lib/schema-builders/ts-json-schema.d.ts +4 -0
- package/lib/types.d.ts +68 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @adhd/apigen-core
|
|
2
|
+
|
|
3
|
+
Schema **extraction** and **composition** for apigen, plus the shared types and the
|
|
4
|
+
`OutputPlugin` contract every target plugin implements. Pure TypeScript — safe in Node and
|
|
5
|
+
the browser (**platform: shared**).
|
|
6
|
+
|
|
7
|
+
Part of [apigen](../README.md). For end-to-end usage see [`../cli`](../cli).
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
Reads a TypeScript source with [ts-morph](https://ts-morph.com/), derives JSON Schemas for
|
|
12
|
+
each exported function's parameters and return type (via `ts-json-schema-generator`), and
|
|
13
|
+
composes them with any middleware-contributed envelope fields. The first parameter named
|
|
14
|
+
`ctx` is excluded from the schema by convention (name-only).
|
|
15
|
+
|
|
16
|
+
## Public API
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { generateSchemas, composeSchemas } from '@adhd/apigen-core'
|
|
20
|
+
import type {
|
|
21
|
+
GeneratedSchemas, ComposedSchemas, ExportMode, GenerateSchemasOptions,
|
|
22
|
+
PluginInput, PluginOutput, RunInput, OutputPlugin, Logger,
|
|
23
|
+
} from '@adhd/apigen-core'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- **`generateSchemas(opts)`** — source file → per-export input/output JSON Schemas.
|
|
27
|
+
- **`composeSchemas(...)`** — fold middleware envelope fields into the composed `input`
|
|
28
|
+
(always with a `data: {}` wrapper, even for zero-param functions).
|
|
29
|
+
- **`OutputPlugin`** — `{ id, generate(input): PluginOutput, run?(input): Promise<void> }`.
|
|
30
|
+
`PluginOutput.files` is language-agnostic (`{ path, content }[]`), so plugins may emit any
|
|
31
|
+
file type.
|
|
32
|
+
|
|
33
|
+
## Develop
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx nx build apigen-core
|
|
37
|
+
npx nx test apigen-core
|
|
38
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { GeneratedSchemas, ComposedSchemas, ExportMode, GenerateSchemasOptions, PluginInput, PluginOutput, RunInput, OutputPlugin, } from './lib/types';
|
|
2
|
+
export type { Operation, OperationKind, Segment, TypeText, JSONSchema, ApigenSchemaHints, } from './lib/descriptor';
|
|
3
|
+
export type { Plugin, TargetCapability, LayerCapability, MountCapability, MountedOperation, EnvelopeCapability, Call, Next, Result, Chunk, Transport, Extensions, Descriptor, Harness, Server, File, } from './lib/plugin';
|
|
4
|
+
export type { Logger } from 'pino';
|
|
5
|
+
export { generateSchemas } from './lib/generate-schemas';
|
|
6
|
+
export { composeSchemas } from './lib/compose-schemas';
|
|
7
|
+
export { extract, tokenize } from './lib/extract';
|
|
8
|
+
export type { ExtractOptions } from './lib/extract';
|
|
9
|
+
export { extractClasses } from './lib/extract-classes';
|
|
10
|
+
export type { ExtractClassesOptions } from './lib/extract-classes';
|