@adhd/apigen-core-client 0.1.1 → 0.1.3

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.
@@ -1,9 +1,34 @@
1
+ import { Plugin } from './plugin';
1
2
  import { GeneratedSchemas, ComposedSchemas } from './types';
2
3
 
3
4
  interface SlimMiddleware {
4
5
  id: string;
5
6
  envelope?: Record<string, unknown>;
6
7
  }
8
+ /**
9
+ * DEBT-APIGEN-ENVELOPE-CAPABILITY-UNWIRED-001: reduce a set of loaded `--use`
10
+ * plugins' envelope-contributing capabilities into the `SlimMiddleware[]`
11
+ * shape {@link composeSchemas} consumes (SPEC §9.1).
12
+ *
13
+ * Two capabilities contribute request-side envelope fields, and a plugin may
14
+ * declare either or both:
15
+ * - `capabilities.envelope.request` — the dedicated `EnvelopeCapability`
16
+ * (declares fields without wrapping the operation in a Layer).
17
+ * - `capabilities.layer.envelopeFields` — a `LayerCapability`'s own "extra
18
+ * fields I need on the request side" declaration (its doc comment: "merged
19
+ * into the effective descriptor's envelope schema before serving begins").
20
+ *
21
+ * Both merge into ONE envelope map per plugin, keyed by the plugin's own `id`
22
+ * — the same `id` `composeSchemas()` stamps as the `x-apigen-envelope`
23
+ * pluginId, so `envelopeKey`/`envelopeCliFlag`/`envelopeEnvVar`
24
+ * (`@adhd/apigen-engine-naming`) bind to `x-<id>-<field>` /
25
+ * `--<id>-<field>` / `APIGEN_<ID>_<FIELD>` for the field's OWN plugin, not a
26
+ * hardcoded default.
27
+ *
28
+ * Plugins contributing neither capability are omitted (composeSchemas treats
29
+ * `envelope: undefined` as "no contribution", same as `false`-suppressed).
30
+ */
31
+ export declare function pluginsToEnvelopeMiddlewares(plugins: readonly Plugin[]): SlimMiddleware[];
7
32
  /**
8
33
  * Merges domain schemas with middleware envelope fields.
9
34
  *
@@ -71,7 +71,7 @@ export interface ApigenSchemaHints {
71
71
  *
72
72
  * Identity is carried by the tokenized `words`; the original `raw` spelling is
73
73
  * preserved so a same-host plugin can reproduce it, but every transport derives
74
- * its own casing from `words` via `@adhd/apigen-naming` (kebab for HTTP/CLI,
74
+ * its own casing from `words` via `@adhd/apigen-engine-naming` (kebab for HTTP/CLI,
75
75
  * `_`-joined for MCP, Pascal for gRPC). Casing is therefore per-plugin, never
76
76
  * baked into the descriptor.
77
77
  */
package/lib/types.d.ts CHANGED
@@ -18,6 +18,7 @@ export type ComposedSchemas = Record<string, {
18
18
  output: Record<string, unknown>;
19
19
  hasCtx?: boolean;
20
20
  'x-apigen-safe'?: boolean;
21
+ 'x-apigen-envelope'?: Record<string, string>;
21
22
  }>;
22
23
  export type ExportMode = {
23
24
  type: 'named';
@@ -44,6 +45,19 @@ export interface PluginInput {
44
45
  * a default stderr logger when this is absent.
45
46
  */
46
47
  logger?: Logger;
48
+ /**
49
+ * DEBT-APIGEN-PLUGIN-MCP-GENERATE-OPERATIONS-001: the full merged
50
+ * `Operation[]` descriptor (the same set `buildDescriptor()` produces),
51
+ * threaded through so `generate()` can call the real `project(op)` for
52
+ * every operation instead of falling back to a best-effort synthesized
53
+ * `Operation` (exact only for the single-source-file case; wrong for
54
+ * multi-file namespaces / npm-specifier importPath / default-object
55
+ * exports). Lifted from `RunInput` (BUG-APIGEN-024) onto the base
56
+ * `PluginInput` so both `generate()` and `run()` get real ops from the
57
+ * same field. Optional: absent for non-TS-extraction paths (e.g.
58
+ * py-flask) where nothing was extracted to describe.
59
+ */
60
+ operations?: Operation[];
47
61
  }
48
62
  export interface PluginOutput {
49
63
  files: Array<{
@@ -54,15 +68,6 @@ export interface PluginOutput {
54
68
  }
55
69
  export interface RunInput extends PluginInput {
56
70
  signal?: AbortSignal;
57
- /**
58
- * BUG-APIGEN-024: the full merged `Operation[]` descriptor (the same set
59
- * `buildDescriptor()` produces), threaded through so a `--use` mount plugin
60
- * (e.g. `apigen-plugin-openapi`) can build its real `Descriptor` instead of
61
- * the empty-`operations` stub `collectMountRoutes()` used to synthesize.
62
- * Absent for non-TS-extraction run paths (e.g. py-flask), where mount
63
- * plugins have nothing extracted to describe.
64
- */
65
- operations?: Operation[];
66
71
  }
67
72
  /** Source-language tags understood by apigen's routing layer. */
68
73
  export type PluginLanguage = 'ts' | 'py' | 'rust' | 'go' | 'java';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adhd/apigen-core-client",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "dependencies": {
5
5
  "ts-morph": "^23.0.0",
6
6
  "ts-json-schema-generator": "^2.3.0",
7
7
  "pino": "10.3.1",
8
8
  "typescript": "^6.0.3",
9
- "@adhd/apigen-base-logical": "^0.0.2"
9
+ "@adhd/apigen-base-logical": "^0.0.4"
10
10
  },
11
11
  "main": "./index.js",
12
12
  "module": "./index.mjs",