@adhd/apigen-core-client 0.1.2 → 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
  *
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';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@adhd/apigen-core-client",
3
- "version": "0.1.2",
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.3"
9
+ "@adhd/apigen-base-logical": "^0.0.4"
10
10
  },
11
11
  "main": "./index.js",
12
12
  "module": "./index.mjs",